{"version":3,"file":"useDictionaryAsync.mjs","names":[],"sources":["../../../src/server/useDictionaryAsync.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n  DeclaredLocales,\n  LocalesValues,\n  StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionaryAsync = async <\n  const T extends Dictionary,\n  const L extends LocalesValues = DeclaredLocales,\n>(\n  dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n  locale?: L,\n  fallbackLocale?: DeclaredLocales\n) => {\n  const localeTarget =\n    locale ??\n    getServerContext<LocalesValues>(IntlayerServerContext) ??\n    fallbackLocale ??\n    internationalization.defaultLocale;\n\n  const dictionary = await (dictionaryPromise as any)[localeTarget]?.();\n\n  return useDictionary<T, L>(dictionary, localeTarget as L);\n};\n"],"mappings":";;;;;;;;;;;AAgBA,MAAa,qBAAqB,OAIhC,mBACA,QACA,mBACG;CACH,MAAM,eACJ,UACA,iBAAgC,sBAAsB,IACtD,kBACA,qBAAqB;AAIvB,QAAO,cAAoB,MAFD,kBAA0B,iBAAiB,EAE9B,aAAkB"}