{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAqBD,MAAM,kDAAc,CAAA,GAAA,sCAAI,EAAE,aAAa,CAAgB;AAMvD;;CAEC,GACD,SAAS,6CAAuB,KAAkC;IAChE,IAAI,UAAC,MAAM,YAAE,QAAQ,EAAC,GAAG;IACzB,IAAI,QAAgB,CAAA,GAAA,sCAAI,EAAE,OAAO,CAAC,IAAO,CAAA;oBACvC;YACA,WAAW,CAAA,GAAA,+BAAI,EAAE,UAAU,QAAQ;QACrC,CAAA,GAAI;QAAC;KAAO;IAEZ,qBACE,0DAAC,kCAAY,QAAQ;QAAC,OAAO;OAC1B;AAGP;AAMA;;CAEC,GACD,SAAS,oDAA8B,KAAyC;IAC9E,IAAI,YAAC,QAAQ,EAAC,GAAG;IACjB,IAAI,gBAAgB,CAAA,GAAA,0CAAe;IAEnC,qBACE,0DAAC,kCAAY,QAAQ;QAAC,OAAO;OAC1B;AAGP;AAKO,SAAS,0CAAa,KAAwB;IACnD,IAAI,UAAC,MAAM,YAAE,QAAQ,EAAC,GAAG;IAEzB,+EAA+E;IAC/E,mEAAmE;IACnE,IAAI,QACF,qBAAO,0DAAC;QAAuB,QAAQ;QAAQ,UAAU;;IAG3D,qBAAO,0DAAC;QAA8B,UAAU;;AAClD;AAKO,SAAS;IACd,IAAI,gBAAgB,CAAA,GAAA,0CAAe;IACnC,IAAI,UAAU,CAAA,GAAA,uBAAS,EAAE;IACzB,OAAO,WAAW;AACpB","sources":["packages/react-aria/src/i18n/I18nProvider.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Direction} from '@react-types/shared';\nimport {isRTL} from './utils';\nimport React, {JSX, ReactNode, useContext} from 'react';\nimport {useDefaultLocale} from './useDefaultLocale';\n\nexport interface Locale {\n  /** The [BCP47](https://www.ietf.org/rfc/bcp/bcp47.txt) language code for the locale. */\n  locale: string,\n  /** The writing direction for the locale. */\n  direction: Direction\n}\n\nexport interface I18nProviderProps {\n  /** Contents that should have the locale applied. */\n  children: ReactNode,\n  /** The locale to apply to the children. */\n  locale?: string\n}\n\nconst I18nContext = React.createContext<Locale | null>(null);\n\ninterface I18nProviderWithLocaleProps extends I18nProviderProps {\n  locale: string\n}\n\n/**\n * Internal component that handles the case when locale is provided.\n */\nfunction I18nProviderWithLocale(props: I18nProviderWithLocaleProps): JSX.Element {\n  let {locale, children} = props;  \n  let value: Locale = React.useMemo(() => ({\n    locale,\n    direction: isRTL(locale) ? 'rtl' : 'ltr'\n  }), [locale]);\n\n  return (\n    <I18nContext.Provider value={value}>\n      {children}\n    </I18nContext.Provider>\n  );\n}\n\ninterface I18nProviderWithDefaultLocaleProps {\n  children: ReactNode\n}\n\n/**\n * Internal component that handles the case when no locale is provided.\n */\nfunction I18nProviderWithDefaultLocale(props: I18nProviderWithDefaultLocaleProps): JSX.Element {\n  let {children} = props;\n  let defaultLocale = useDefaultLocale();\n\n  return (\n    <I18nContext.Provider value={defaultLocale}>\n      {children}\n    </I18nContext.Provider>\n  );\n}\n\n/**\n * Provides the locale for the application to all child components.\n */\nexport function I18nProvider(props: I18nProviderProps): JSX.Element {\n  let {locale, children} = props;\n\n  // Conditionally render different components to avoid calling useDefaultLocale.\n  // This is necessary because useDefaultLocale triggers a re-render.\n  if (locale) {\n    return <I18nProviderWithLocale locale={locale} children={children} />;\n  }\n\n  return <I18nProviderWithDefaultLocale children={children} />;\n}\n\n/**\n * Returns the current locale and layout direction.\n */\nexport function useLocale(): Locale {\n  let defaultLocale = useDefaultLocale();\n  let context = useContext(I18nContext);\n  return context || defaultLocale;\n}\n"],"names":[],"version":3,"file":"I18nProvider.cjs.map"}