{"version":3,"file":"getTranslationsSnapshot.mjs","names":[],"sources":["../../../src/functions/helpers/getTranslationsSnapshot.ts"],"sourcesContent":["import { Hash, Locale } from 'gt-i18n/internal/types';\nimport { Translation } from 'gt-i18n/types';\nimport {\n  createDiagnosticMessage,\n  formatDiagnosticErrorDetails,\n} from 'generaltranslation/internal';\nimport { getReactI18nCache } from '../../i18n-cache/singleton-operations';\n\n/**\n * Serializable cached translations for provider hydration; a failed load\n * yields a snapshot with no entry for the locale, so hydration caches nothing\n * and a later lookup retries. TODO: perhaps move to /i18n for type generics\n */\nexport async function getTranslationsSnapshot(\n  locale: Locale\n): Promise<Record<Locale, Record<Hash, Translation>>> {\n  const i18nCache = getReactI18nCache();\n  try {\n    return { [locale]: await i18nCache.loadTranslations(locale) };\n  } catch (error) {\n    console.warn(\n      createDiagnosticMessage({\n        source: '@generaltranslation/react-core',\n        severity: 'Warning',\n        whatHappened: `Could not load translations for locale \"${locale}\", so content for this locale renders untranslated`,\n        why: 'the translation loader failed, usually because translations for this locale have not been generated yet',\n        fix: 'Generate translations for this locale, or check your loadTranslations configuration.',\n        details: formatDiagnosticErrorDetails(error),\n      })\n    );\n    return {};\n  }\n}\n"],"mappings":"sLAaA,eAAsB,EACpB,EACoD,CACpD,IAAM,EAAY,GAAmB,CACrC,GAAI,CACF,MAAO,EAAG,GAAS,MAAM,EAAU,iBAAiB,EAAO,CAAE,OACtD,EAAO,CAWd,OAVA,QAAQ,KACN,EAAwB,CACtB,OAAQ,iCACR,SAAU,UACV,aAAc,2CAA2C,EAAO,oDAChE,IAAK,0GACL,IAAK,uFACL,QAAS,EAA6B,EAAM,CAC7C,CAAC,CACH,CACM,EAAE"}