@generaltranslation/react-core 1.8.21 → 2.0.0-odysseus.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/components-rsc.cjs.min.cjs +2 -0
- package/dist/components-rsc.cjs.min.cjs.map +1 -0
- package/dist/components-rsc.d.ts +531 -0
- package/dist/components-rsc.d.ts.map +1 -0
- package/dist/components-rsc.esm.min.mjs +2 -0
- package/dist/components-rsc.esm.min.mjs.map +1 -0
- package/dist/components.cjs.min.cjs +2 -0
- package/dist/components.cjs.min.cjs.map +1 -0
- package/dist/components.d.ts +495 -0
- package/dist/components.d.ts.map +1 -0
- package/dist/components.esm.min.mjs +2 -0
- package/dist/components.esm.min.mjs.map +1 -0
- package/dist/hooks.cjs.min.cjs +2 -0
- package/dist/hooks.cjs.min.cjs.map +1 -0
- package/dist/hooks.d.ts +130 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.esm.min.mjs +2 -0
- package/dist/hooks.esm.min.mjs.map +1 -0
- package/dist/pure.cjs.min.cjs +2 -0
- package/dist/pure.cjs.min.cjs.map +1 -0
- package/dist/pure.d.ts +677 -0
- package/dist/pure.d.ts.map +1 -0
- package/dist/pure.esm.min.mjs +2 -0
- package/dist/pure.esm.min.mjs.map +1 -0
- package/package.json +40 -35
- package/dist/errors.cjs.min.cjs +0 -2
- package/dist/errors.cjs.min.cjs.map +0 -1
- package/dist/errors.d.ts +0 -5
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.esm.min.mjs +0 -2
- package/dist/errors.esm.min.mjs.map +0 -1
- package/dist/index.cjs.min.cjs +0 -2
- package/dist/index.cjs.min.cjs.map +0 -1
- package/dist/index.d.ts +0 -1385
- package/dist/index.d.ts.map +0 -1
- package/dist/index.esm.min.mjs +0 -2
- package/dist/index.esm.min.mjs.map +0 -1
- package/dist/internal.cjs.min.cjs +0 -2
- package/dist/internal.cjs.min.cjs.map +0 -1
- package/dist/internal.d.ts +0 -765
- package/dist/internal.d.ts.map +0 -1
- package/dist/internal.esm.min.mjs +0 -2
- package/dist/internal.esm.min.mjs.map +0 -1
- package/dist/types.d.ts +0 -437
- package/dist/types.d.ts.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`gt-i18n/internal`),t=require(`react`),n=require(`gt-i18n`),r=require(`generaltranslation`);function i(e){let t=e.trim();return t?/[.!?)]$/.test(t)?t:`${t}.`:``}function a(e){let t=e.trim(),n=t.length;for(;n>0;){let e=t[n-1];if(e!==`.`&&e!==`!`&&e!==`?`)break;--n}return t.slice(0,n)}function o(e){return e.replace(/^[A-Z][a-z]/,e=>e.toLowerCase())}function s(e){if(!e)return``;let t=Array.isArray(e)?e.join(`, `):e;return t.trim()?i(`Details: ${t}`):``}function c(e){if(e!=null)return String(e)}function l({source:e,severity:t,whatHappened:n,reassurance:r,why:c,fix:l,wayOut:u,details:d,docsUrl:f}){let p=e?t?`${e} ${t}:`:`${e}:`:t?`${t}:`:``,m=c?`${a(n)} because ${o(a(c))}`:n,h=!!l&&!!u&&/^[a-z]/.test(a(u)),g=[m,r,h?`${a(l)}, or ${o(a(u))}`:l,h?void 0:u,s(d)].filter(e=>!!e).map(i);f&&g.push(`Learn more: ${f}`);let _=g.join(` `);return p?`${p} ${_}`:_}var u=class extends e.I18nConfig{renderStrategy;constructor(e={},t=`server-render`){super(e),f(t),this.renderStrategy=t}getRenderStrategy(){return this.renderStrategy}};function d(){let t=(0,e.getI18nConfig)();if(p(t))return t;throw Error(l({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`Cannot read ReactI18nConfig after base I18nConfig setup.`,why:`the internal I18nConfig singleton was initialized without react-core render strategy support`,fix:`Initialize GT through gt-react or @generaltranslation/react-core/pure.`}))}function f(e){if(!(e===`SPA`||e===`server-render`))throw Error(l({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`Invalid React render strategy.`,why:`the render strategy must be "SPA" or "server-render", but received "${String(e)}"`,fix:`Initialize GT through gt-react or pass a valid render strategy.`}))}function p(e){return e instanceof u}const{getConditionStore:m,setConditionStore:h,isConditionStoreInitialized:g}=(0,e.createConditionStoreSingleton)(l({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`Cannot read GT runtime context before it has been initialized`,why:`The internal ConditionStore is unavailable`}));function _(){try{return m()}catch(t){let n=(0,e.getRuntimeEnvironment)(),r=d().getRenderStrategy(),i=l({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`Cannot access ConditionStore before it is initialized.`,details:c(t),fix:r===`SPA`?`Initialize GT before reading GT runtime context.`:`Add a <GTProvider> at the root of your component tree.`,wayOut:n===`development`?void 0:r===`SPA`?`Request-specific values will fall back to the default configuration.`:`Request-specific values will fall back to the default configuration. This may cause hydration mismatches.`});if(n===`development`)throw Error(i);return console.error(i),{getLocale:()=>`en`,getRegion:()=>void 0,getEnableI18n:()=>!0,setLocale:()=>{},setRegion:()=>{},setEnableI18n:()=>{}}}}function v(){let e=globalThis;return e.__generaltranslation??={},e.__generaltranslation.reactCore??={},e.__generaltranslation.reactCore}function ee(){let e=v();return e.gtContext??=(0,t.createContext)(void 0),e.gtContext}function y(){let e=(0,t.useContext)(ee());if(e||d().getRenderStrategy()===`SPA`)return e;throw Error(b())}function b(){return l({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`GT runtime context could not be read`,why:`GTContext was accessed outside of a <GTProvider>`,fix:`Add a <GTProvider> at the root of your component tree.`})}function x(){return y()?.conditionStore??_()}function S(){return x().getLocale()}function C(){return x().getRegion()}function w(){return x().getEnableI18n()}function T(){return(0,t.useMemo)(()=>(0,e.getI18nConfig)().getCustomMapping(),[])}function E(){return(0,t.useMemo)(()=>(0,e.getI18nConfig)().getDefaultLocale(),[])}function D(){return(0,t.useMemo)(()=>(0,e.getI18nConfig)().getLocales(),[])}const O=[];function k({locale:t,enableI18n:n,localesProp:r=O}){let i=(0,e.getI18nConfig)().getDefaultLocale();return n&&(0,e.getI18nConfig)().requiresTranslation(t)?[...r,t,i]:[i]}const A=[];function j(e=A){let n=S(),r=w();return(0,t.useMemo)(()=>k({locale:n,enableI18n:r,localesProp:e}),[n,r,e])}function M(){let t=w(),n=S();return t&&(0,e.getI18nConfig)().requiresTranslation(n)}function N(){return(0,t.useMemo)(()=>(0,e.getI18nConfig)().getGTClass(),[])}function P(n){return(0,t.useMemo)(()=>(0,e.getI18nConfig)().getGTClass().getLocaleProperties(n),[n])}function F(n){return(0,t.useMemo)(()=>(0,e.getI18nConfig)().getGTClass().getLocaleDirection(n),[n])}function I(){throw Error(l({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`useVersionId() is not implemented in this entry point`,fix:`Use getVersionId() or import useVersionId() from a supported runtime entry point.`}))}function L(){let e=globalThis;return e.__generaltranslation??={},e.__generaltranslation.reactCore??={},e.__generaltranslation.reactCore}function R(){let e=L().i18nStore;if(!e)throw z();return e}function z(){let e=l({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`Cannot access I18nStore before it is initialized.`,fix:d().getRenderStrategy()===`SPA`?`Initialize GT before reading GT runtime context.`:`Add a <GTProvider> at the root of your component tree.`});return Error(e)}function B(){return y()?.i18nStore||R()}function V(){return y()?.translationsSnapshot||{}}function H(){return y()?.dictionariesSnapshot||{}}function U(){let n=y()?.onMissingTranslation,r=K();return(0,t.useCallback)(t=>{n?n(t):r((0,e.getTranslateListenerKey)(t),{type:`translation`,lookup:t})},[n,r])}function W(){let n=y()?.onMissingDictionaryEntry,r=K();return(0,t.useCallback)(t=>{n?n(t):r((0,e.getDictionaryListenerKey)(t),{type:`dictionaryEntry`,lookup:t})},[n,r])}function G(){let n=y()?.onMissingDictionaryObj,r=K();return(0,t.useCallback)(t=>{n?n(t):r((0,e.getDictionaryListenerKey)(t),{type:`dictionaryObject`,lookup:t})},[n,r])}function K(){let n=(0,e.getI18nConfig)().isDevHotReloadEnabled(),r=M(),i=B(),a=new Map;return(0,t.useEffect)(()=>{!n||!r||a.size===0||a.forEach(({type:e,lookup:t})=>{switch(e){case`translation`:i.translate(t);break;case`dictionaryEntry`:i.translateDictionaryEntry(t);break;case`dictionaryObject`:i.translateDictionaryObject(t);break}})},[n,r,i,a]),(e,t)=>{a.set(e,t)}}function q(n=[]){let r=V(),i=B(),a=(0,e.getI18nConfig)().isDevHotReloadEnabled(),o=U(),s=(0,t.useRef)(null);return s.current??=new Set,Y(n,s),J(s),(0,t.useCallback)(t=>{let n=(0,e.getTranslateListenerKey)(t);a&&s.current.add(n);let c=i.getTranslateSnapshot(t,r);return c==null&&a&&o(t),c},[i,r,o,a])}function J(n){let r=(0,t.useRef)(0),i=B(),a=(0,t.useCallback)(t=>i.subscribeToTranslationEvents(i=>{let a=(0,e.getTranslateListenerKey)(i);n.current.has(a)&&(r.current++,t())}),[i]),o=(0,t.useCallback)(()=>r.current,[]);(0,t.useSyncExternalStore)(a,o,o)}function Y(n,r){let i=B(),a=S(),o=(0,e.getI18nConfig)().isDevHotReloadEnabled(),s=M(),c=V(),l=(0,t.useMemo)(()=>n?.length>0&&s&&o,[n,s,o]),u=(0,t.useMemo)(()=>l?n.map(({message:t,...n})=>{let r=n.$locale??a,i={locale:r,message:t,options:(0,e.createLookupOptions)(r,n,`ICU`)};return[i,(0,e.getTranslateListenerKey)(i)]}):[],[a,l,n]);l&&u.forEach(([,e])=>{r.current.add(e)}),(0,t.useEffect)(()=>{l&&u.filter(([e])=>i.getTranslateSnapshot(e,c)==null).forEach(([e])=>i.translate(e))},[l,i,u,c])}function X(n){let r=S(),i=E(),a=M(),o=q(n);return(0,t.useCallback)((t,n={})=>{if(!a)return(0,e.interpolateMessage)({options:n,source:t,sourceLocale:i});let s=(0,e.createLookupOptions)(n.$locale??r,n,`ICU`);return(0,e.interpolateMessage)({source:t,target:o({locale:s.$locale,message:t,options:s}),options:s,sourceLocale:i})},[i,r,a,o])}function Z(r){let i=X(r);return(0,t.useCallback)((t,r={})=>{if(t==null)return t;let a=(0,n.decodeOptions)(t)??{};return(0,e.isEncodedTranslationOptions)(a)?i(a.$_source,a):i(t,r)},[i])}function Q(){let n=H(),r=B(),i=(0,e.getI18nConfig)().isDevHotReloadEnabled(),a=W(),o=(0,t.useRef)(null);return o.current??=new Set,te(o),(0,t.useCallback)(t=>{let s=(0,e.getDictionaryListenerKey)(t);i&&o.current.add(s);let c=r.getDictionaryEntrySnapshot(t,n);return c==null&&i&&a(t),c},[r,n,i,a])}function te(n){let r=(0,t.useRef)(0),i=B(),a=(0,t.useCallback)(t=>i.subscribeToDictionaryEntryEvents(i=>{let a=(0,e.getDictionaryListenerKey)(i);n.current.has(a)&&(r.current++,t())}),[i]),o=(0,t.useCallback)(()=>r.current,[]);(0,t.useSyncExternalStore)(a,o,o)}function ne(){let n=H(),r=B(),i=(0,e.getI18nConfig)().isDevHotReloadEnabled(),a=G(),o=(0,t.useRef)(null);return o.current??=new Set,re(o),(0,t.useCallback)(t=>{let s=(0,e.getDictionaryListenerKey)(t);i&&o.current.add(s);let c=r.getDictionaryObjectSnapshot(t,n);return c==null&&i&&a(t),c},[r,n,i,a])}function re(n){let r=(0,t.useRef)(0),i=B(),a=(0,t.useCallback)(t=>i.subscribeToDictionaryObjectEvents(i=>{let a=(0,e.getDictionaryListenerKey)(i);n.current.has(a)&&(r.current++,t())}),[i]),o=(0,t.useCallback)(()=>r.current,[]);(0,t.useSyncExternalStore)(a,o,o)}function ie(n){let r=S(),i=E(),a=M(),o=X(),s=Q(),c=ae(n),l=(0,t.useCallback)((t,c={})=>{let l=$(n,t),u=s({locale:i,id:l});if(u===void 0)throw Error(`Dictionary entry ${l} cannot be found`);let d=(0,e.resolveDictionaryLookupOptions)(u.options);if(!a)return o(u.entry,{...d,...(0,e.extractVariables)(c),$locale:i});let f=s({locale:r,id:l});return f?.entry==null?o(u.entry,{...d,...(0,e.extractVariables)(c),$locale:r}):(0,e.renderDictionaryEntry)({sourceLocale:i,targetLocale:r,sourceEntry:u,target:f.entry,dictionaryOptions:d,options:c})},[i,o,n,r,s,a]);return(0,t.useMemo)(()=>Object.assign(l,{obj:c}),[l,c])}function ae(n){let r=S(),i=E(),a=M(),o=X(),s=ne();return(0,t.useCallback)(t=>{let c=$(n,t),l=s({locale:i,id:c});if(l===void 0)throw Error(`Dictionary entry ${c} cannot be found`);let u;return a&&(u=s({locale:r,id:c})),(0,e.renderDictionaryObject)({sourceObject:l,targetObject:u,translate:(e,t)=>o(e.entry,{...t,$locale:a?r:i})})},[i,n,r,s,a,o])}function $(e,t){return e?`${e}.${t}`:t}function oe(e){let n=D(),i=T(),a=S(),o=(0,t.useMemo)(()=>{if(!n||n.length===0)return[];let e=new Intl.Collator;return[...n].sort((t,n)=>e.compare((0,r.getLocaleProperties)(t,a,i).nativeNameWithRegionCode,(0,r.getLocaleProperties)(n,a,i).nativeNameWithRegionCode))},[n,a,i]),s=(0,t.useCallback)(e=>(0,r.getLocaleProperties)(e,e,i),[a,i]);return{locale:a,locales:e||o,getLocaleProperties:s}}function se({regions:n,customMapping:i,prioritizeCurrentLocaleRegion:a=!0,sortRegionsAlphabetically:o=!0}={}){let s=D(),c=T(),l=S(),u=C(),{regionCode:d}=(0,r.getLocaleProperties)(l,l,c),[f,p]=(0,t.useMemo)(()=>{let t=(0,e.getI18nConfig)().getGTClass(l),u=new Map(s.map(e=>{let t=(0,r.getLocaleProperties)(e,l,c);return[t.regionCode,t]})),f=n?[...n]:Array.from(u?.keys()||[d]),p=new Map(f.map(e=>[e,{locale:u?.get(e)?.code||l,...t.getRegionProperties(e),...typeof i?.[e]==`string`?{name:i?.[e]}:i?.[e]}]));if(o&&f.sort((e,t)=>new Intl.Collator().compare(p.get(e).name,p.get(t).name)),a){let e=f.indexOf(d);e>0&&(f.splice(e,1),f.unshift(d))}return[f,p]},[n,i,l,d,s,c,a,o]);return{region:u,regions:f,regionData:p,locale:l,localeRegion:d}}exports.useConditionStore=x,exports.useCustomMapping=T,exports.useDefaultLocale=E,exports.useEnableI18n=w,exports.useFormatLocales=j,exports.useGT=X,exports.useGTClass=N,exports.useInternalLocaleSelector=oe,exports.useInternalRegionSelector=se,exports.useLocale=S,exports.useLocaleDirection=F,exports.useLocaleProperties=P,exports.useLocales=D,exports.useMessages=Z,exports.useRegion=C,exports.useShouldTranslate=M,exports.useTranslations=ie,exports.useVersionId=I;
|
|
2
|
+
//# sourceMappingURL=hooks.cjs.min.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.cjs.min.cjs","names":["I18nConfig","getI18nConfig","getI18nConfig","getReactCoreGlobals","getI18nConfig","EMPTY_LOCALES_PROP","getI18nConfig","useSubscribeToLookups","useSubscribeToLookups"],"sources":["../../core/dist/base64-r7YWJYWt.mjs","../src/setup/i18nConfig.ts","../src/condition-store/singleton-operations.ts","../src/context/context.ts","../src/hooks/condition-store.ts","../src/hooks/i18n-config.ts","../src/hooks/utils/getFormatLocales.ts","../src/hooks/utils.ts","../src/i18n-store/singleton-operations.ts","../src/i18n-store/useI18nStore.ts","../src/hooks/utils/missing-translation.ts","../src/hooks/external-store/useTrackedTranslationResolver.ts","../src/hooks/useGT.ts","../src/hooks/useMessages.ts","../src/hooks/external-store/useTrackedDictionaryResolver.ts","../src/hooks/external-store/useTrackedDictionaryObjResolver.ts","../src/hooks/useTranslations.ts","../src/hooks/useInternalLocaleSelector.ts","../src/hooks/useInternalRegionSelector.ts"],"sourcesContent":["//#region src/settings/settings.ts\nconst libraryDefaultLocale = \"en\";\nconst defaultTimeout = 6e4;\n//#endregion\n//#region src/logging/diagnostics.ts\nfunction ensureSentence(text) {\n\tconst trimmed = text.trim();\n\tif (!trimmed) return \"\";\n\treturn /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\nfunction stripSentence(text) {\n\tconst trimmed = text.trim();\n\tlet end = trimmed.length;\n\twhile (end > 0) {\n\t\tconst char = trimmed[end - 1];\n\t\tif (char !== \".\" && char !== \"!\" && char !== \"?\") break;\n\t\tend -= 1;\n\t}\n\treturn trimmed.slice(0, end);\n}\nfunction lowercaseFirstWord(text) {\n\treturn text.replace(/^[A-Z][a-z]/, (match) => match.toLowerCase());\n}\nfunction formatDetails(details) {\n\tif (!details) return \"\";\n\tconst detailText = Array.isArray(details) ? details.join(\", \") : details;\n\tif (!detailText.trim()) return \"\";\n\treturn ensureSentence(`Details: ${detailText}`);\n}\nfunction formatDiagnosticErrorDetails(error) {\n\tif (error == null) return void 0;\n\treturn String(error);\n}\nfunction createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {\n\tconst prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : \"\";\n\tconst whatAndWhy = why ? `${stripSentence(whatHappened)} because ${lowercaseFirstWord(stripSentence(why))}` : whatHappened;\n\tconst shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n\tconst messageParts = [\n\t\twhatAndWhy,\n\t\treassurance,\n\t\tshouldCombineWayOut ? `${stripSentence(fix)}, or ${lowercaseFirstWord(stripSentence(wayOut))}` : fix,\n\t\tshouldCombineWayOut ? void 0 : wayOut,\n\t\tformatDetails(details)\n\t].filter((part) => !!part).map(ensureSentence);\n\tif (docsUrl) messageParts.push(`Learn more: ${docsUrl}`);\n\tconst message = messageParts.join(\" \");\n\treturn prefix ? `${prefix} ${message}` : message;\n}\n//#endregion\n//#region src/settings/settingsUrls.ts\nconst defaultCacheUrl = \"https://cdn.gtx.dev\";\nconst defaultBaseUrl = \"https://api2.gtx.dev\";\nconst defaultRuntimeApiUrl = \"https://runtime2.gtx.dev\";\n//#endregion\n//#region src/utils/isSupportedFileFormatTransform.ts\nconst SUPPORTED_TRANSFORMATIONS = {\n\tGTJSON: [\"GTJSON\"],\n\tJSON: [\"JSON\"],\n\tPO: [\"PO\"],\n\tPOT: [\"POT\", \"PO\"],\n\tYAML: [\"YAML\"],\n\tMDX: [\"MDX\"],\n\tMD: [\"MD\"],\n\tTS: [\"TS\"],\n\tJS: [\"JS\"],\n\tHTML: [\"HTML\"],\n\tTXT: [\"TXT\"],\n\tTWILIO_CONTENT_JSON: [\"TWILIO_CONTENT_JSON\"]\n};\n/**\n* This function checks if a file format transformation is supported during translation\n* @param from - The source file format.\n* @param to - The target file format.\n* @returns True if the transformation is supported, false otherwise\n*/\nfunction isSupportedFileFormatTransform(from, to) {\n\treturn SUPPORTED_TRANSFORMATIONS[from]?.includes(to) ?? false;\n}\n//#endregion\n//#region src/translate/utils/validateFileFormatTransform.ts\n/**\n* Returns a user-facing validation error when a requested file format transform\n* is missing source format context or is not currently supported.\n*/\nfunction getFileFormatTransformError(file) {\n\tif (!file.transformFormat) return void 0;\n\tconst fileLabel = file.fileName ?? file.fileId ?? \"unknown file\";\n\tif (!file.fileFormat) return `fileFormat is required when transformFormat is provided for ${fileLabel}`;\n\tif (!isSupportedFileFormatTransform(file.fileFormat, file.transformFormat)) return `Unsupported file format transform: ${file.fileFormat} -> ${file.transformFormat}`;\n}\n/**\n* Validates file format transforms before sending upload/enqueue requests.\n*/\nfunction validateFileFormatTransforms(files) {\n\tfor (const file of files) {\n\t\tconst error = getFileFormatTransformError(file);\n\t\tif (error) throw new Error(error);\n\t}\n}\n//#endregion\n//#region src/utils/base64.ts\nfunction encode(data) {\n\tif (typeof Buffer !== \"undefined\") return Buffer.from(data, \"utf8\").toString(\"base64\");\n\tconst bytes = new TextEncoder().encode(data);\n\tlet binary = \"\";\n\tfor (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);\n\treturn btoa(binary);\n}\nfunction decode(base64) {\n\tif (typeof Buffer !== \"undefined\") return Buffer.from(base64, \"base64\").toString(\"utf8\");\n\tconst binary = atob(base64);\n\tconst bytes = new Uint8Array(binary.length);\n\tfor (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);\n\treturn new TextDecoder().decode(bytes);\n}\n//#endregion\nexport { defaultBaseUrl as a, createDiagnosticMessage as c, libraryDefaultLocale as d, isSupportedFileFormatTransform as i, formatDiagnosticErrorDetails as l, encode as n, defaultCacheUrl as o, validateFileFormatTransforms as r, defaultRuntimeApiUrl as s, decode as t, defaultTimeout as u };\n\n//# sourceMappingURL=base64-r7YWJYWt.mjs.map","import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport {\n getI18nConfig as getBaseI18nConfig,\n I18nConfig,\n setI18nConfig as setBaseI18nConfig,\n} from 'gt-i18n/internal';\nimport type { I18nConfigParams } from 'gt-i18n/internal/types';\n\n/**\n * Helps us distinguish behavior for SPA vs server-rendered apps.\n * - server-rendered apps must use context\n * - SPA apps can synchronously access the locale\n */\nexport type RenderStrategy = 'SPA' | 'server-render';\n\nconst defaultRenderStrategy: RenderStrategy = 'server-render';\n\nexport class ReactI18nConfig extends I18nConfig {\n private renderStrategy: RenderStrategy;\n\n constructor(\n params: I18nConfigParams = {},\n renderStrategy: RenderStrategy = defaultRenderStrategy\n ) {\n super(params);\n validateRenderStrategy(renderStrategy);\n this.renderStrategy = renderStrategy;\n }\n\n getRenderStrategy(): RenderStrategy {\n return this.renderStrategy;\n }\n}\n\nexport function getI18nConfig(): ReactI18nConfig {\n const i18nConfig = getBaseI18nConfig();\n if (isReactI18nConfig(i18nConfig)) {\n return i18nConfig;\n }\n throw new Error(\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Cannot read ReactI18nConfig after base I18nConfig setup.',\n why: 'the internal I18nConfig singleton was initialized without react-core render strategy support',\n fix: 'Initialize GT through gt-react or @generaltranslation/react-core/pure.',\n })\n );\n}\n\nexport function setI18nConfig(nextI18nConfig: ReactI18nConfig): void {\n setBaseI18nConfig(nextI18nConfig);\n}\n\nexport function initializeI18nConfig(\n params: I18nConfigParams = {},\n renderStrategy: RenderStrategy = defaultRenderStrategy\n): ReactI18nConfig {\n const nextI18nConfig = new ReactI18nConfig(params, renderStrategy);\n setI18nConfig(nextI18nConfig);\n return nextI18nConfig;\n}\n\nfunction validateRenderStrategy(\n renderStrategy: RenderStrategy\n): asserts renderStrategy is RenderStrategy {\n if (renderStrategy === 'SPA' || renderStrategy === 'server-render') return;\n throw new Error(\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Invalid React render strategy.',\n why: `the render strategy must be \"SPA\" or \"server-render\", but received \"${String(renderStrategy)}\"`,\n fix: 'Initialize GT through gt-react or pass a valid render strategy.',\n })\n );\n}\n\nfunction isReactI18nConfig(\n i18nConfig: I18nConfig\n): i18nConfig is ReactI18nConfig {\n return i18nConfig instanceof ReactI18nConfig;\n}\n","import {\n createDiagnosticMessage,\n formatDiagnosticErrorDetails,\n libraryDefaultLocale,\n} from 'generaltranslation/internal';\nimport {\n createConditionStoreSingleton,\n getRuntimeEnvironment,\n} from 'gt-i18n/internal';\nimport type { ReadonlyConditionStoreInterface } from 'gt-i18n/internal/types';\nimport { getI18nConfig } from '../setup/i18nConfig';\n\nconst conditionStoreNotInitializedError = createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Cannot read GT runtime context before it has been initialized',\n why: 'The internal ConditionStore is unavailable',\n});\n\nconst { getConditionStore, setConditionStore, isConditionStoreInitialized } =\n createConditionStoreSingleton<ReadonlyConditionStoreInterface>(\n conditionStoreNotInitializedError\n );\n\n/**\n * Opinionated decision: add a safety wrapper around the condition store to be more forgiving in production\n * TODO: perhaps this is how condition store should always be accessed\n */\nfunction getReadonlyConditionStoreWithFallback(): ReadonlyConditionStoreInterface {\n try {\n return getConditionStore();\n } catch (error) {\n // Error handling\n const runtimeEnvironment = getRuntimeEnvironment();\n const renderStrategy = getI18nConfig().getRenderStrategy();\n const errorMessage = createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Cannot access ConditionStore before it is initialized.',\n details: formatDiagnosticErrorDetails(error),\n fix:\n renderStrategy === 'SPA'\n ? 'Initialize GT before reading GT runtime context.'\n : 'Add a <GTProvider> at the root of your component tree.',\n wayOut:\n runtimeEnvironment === 'development'\n ? undefined\n : renderStrategy === 'SPA'\n ? 'Request-specific values will fall back to the default configuration.'\n : 'Request-specific values will fall back to the default configuration. This may cause hydration mismatches.',\n });\n\n if (runtimeEnvironment === 'development') {\n throw new Error(errorMessage);\n } else {\n console.error(errorMessage);\n }\n\n // Fallback to default configuration (important: do not set globally)\n return {\n getLocale: () => libraryDefaultLocale,\n getRegion: () => undefined,\n getEnableI18n: () => true,\n setLocale: () => {},\n setRegion: () => {},\n setEnableI18n: () => {},\n };\n }\n}\n\nexport {\n getConditionStore as getReadonlyConditionStore,\n getReadonlyConditionStoreWithFallback,\n setConditionStore as setReadonlyConditionStore,\n isConditionStoreInitialized as isReadonlyConditionStoreInitialized,\n};\n","import {\n Dictionary,\n Hash,\n Locale,\n ReadonlyConditionStoreInterface,\n} from 'gt-i18n/internal/types';\nimport { Translation } from 'gt-i18n/types';\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { createContext, useContext, type Context } from 'react';\nimport { I18nStore } from '../i18n-store/I18nStore';\nimport { getI18nConfig } from '../setup/i18nConfig';\nimport type {\n OnMissingTranslation,\n OnMissingDictionaryEntry,\n OnMissingDictionaryObj,\n} from '../hooks/utils/missing-translation';\n\nexport type GTContextType = {\n /**\n * Source of truth for translations, streamed from server\n * In SPA mode, these won't be accessible and translations\n * can be accessed via useSyncExternalStore() directly\n */\n translationsSnapshot: Record<Locale, Record<Hash, Translation>>;\n dictionariesSnapshot: Record<Locale, Dictionary>;\n /**\n * I18nStore allows us to sync state updates in ConditionStore and I18nCache\n * with renders\n */\n i18nStore: I18nStore;\n /**\n * ConditionStore should always remain separate from i18nStore as\n * it manages how we perform lookups\n */\n conditionStore: ReadonlyConditionStoreInterface;\n /**\n * Custom override behavior on missing translations\n * Used for server triggering tx hmr b/c no access to useEffect\n */\n onMissingTranslation?: OnMissingTranslation;\n onMissingDictionaryEntry?: OnMissingDictionaryEntry;\n onMissingDictionaryObj?: OnMissingDictionaryObj;\n};\n\ntype ReactCoreGlobals = {\n gtContext?: Context<GTContextType | undefined>;\n [key: string]: unknown;\n};\n\ntype GeneralTranslationGlobal = {\n reactCore?: ReactCoreGlobals;\n [key: string]: unknown;\n};\n\ntype GlobalWithGeneralTranslation = {\n __generaltranslation?: GeneralTranslationGlobal;\n};\n\nfunction getReactCoreGlobals(): ReactCoreGlobals {\n const globalObj = globalThis as unknown as GlobalWithGeneralTranslation;\n globalObj.__generaltranslation ??= {};\n // TODO: Consider checking package versions and using a compatibility matrix before sharing global singletons.\n globalObj.__generaltranslation.reactCore ??= {};\n return globalObj.__generaltranslation.reactCore;\n}\n\nexport function getGTContext(): Context<GTContextType | undefined> {\n const reactCoreGlobals = getReactCoreGlobals();\n reactCoreGlobals.gtContext ??= createContext<GTContextType | undefined>(\n undefined\n );\n return reactCoreGlobals.gtContext;\n}\n\nexport function useGTContext(): GTContextType | undefined {\n const context = useContext(getGTContext());\n if (context || getI18nConfig().getRenderStrategy() === 'SPA') {\n return context;\n }\n /**\n * TODO: in a separate PR, we should figure out how to make this more of a forgiving system\n */\n throw new Error(createMissingGTProviderError());\n}\n\nfunction createMissingGTProviderError(): string {\n return createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'GT runtime context could not be read',\n why: 'GTContext was accessed outside of a <GTProvider>',\n fix: 'Add a <GTProvider> at the root of your component tree.',\n });\n}\n","import { ReadonlyConditionStoreInterface } from 'gt-i18n/internal/types';\nimport { getReadonlyConditionStoreWithFallback } from '../condition-store/singleton-operations';\nimport { useGTContext } from '../context/context';\n\n/**\n * NOTE: useSetLocale() and useSetEnableI18n() are not implemented in @generaltranslation/react-core\n * Some server environments are read only, so we cannot implement these hooks.\n */\n\nexport function useConditionStore(): ReadonlyConditionStoreInterface {\n const context = useGTContext();\n return context?.conditionStore ?? getReadonlyConditionStoreWithFallback();\n}\n\n/**\n * Returns the current locale.\n */\nexport function useLocale(): string {\n return useConditionStore().getLocale();\n}\n\n/**\n * Returns the current region, or undefined if no region is set.\n */\nexport function useRegion(): string | undefined {\n return useConditionStore().getRegion();\n}\n\n/**\n * Returns the current enableI18n flag.\n */\nexport function useEnableI18n(): boolean {\n return useConditionStore().getEnableI18n();\n}\n","import { useMemo } from 'react';\nimport { getI18nConfig } from 'gt-i18n/internal';\nimport type { CustomMapping } from 'generaltranslation/types';\n\nexport function useCustomMapping(): CustomMapping {\n return useMemo(() => getI18nConfig().getCustomMapping(), []);\n}\n\nexport function useDefaultLocale(): string {\n return useMemo(() => getI18nConfig().getDefaultLocale(), []);\n}\n\nexport function useLocales(): readonly string[] {\n return useMemo(() => getI18nConfig().getLocales(), []);\n}\n","import { getI18nConfig } from 'gt-i18n/internal';\n\n// Pure helper shared by hook-based and RSC code paths. This module must stay\n// free of hook/context imports so it can be reached from the components-rsc\n// entrypoint.\n\nconst EMPTY_LOCALES_PROP: string[] = [];\n\nexport function getFormatLocales({\n locale,\n enableI18n,\n localesProp = EMPTY_LOCALES_PROP,\n}: {\n locale: string;\n enableI18n: boolean;\n localesProp?: string[];\n}): string[] {\n const defaultLocale = getI18nConfig().getDefaultLocale();\n const shouldTranslate =\n enableI18n && getI18nConfig().requiresTranslation(locale);\n return shouldTranslate\n ? [...localesProp, locale, defaultLocale]\n : [defaultLocale];\n}\n","import type { LocaleProperties } from '@generaltranslation/format/types';\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { useMemo } from 'react';\nimport { useEnableI18n, useLocale } from './condition-store';\nimport { getFormatLocales } from './utils/getFormatLocales';\nimport { getI18nConfig } from 'gt-i18n/internal';\n\nconst EMPTY_LOCALES_PROP: string[] = [];\n\nexport { getFormatLocales };\n\nexport function useFormatLocales(\n localesProp: string[] = EMPTY_LOCALES_PROP\n): string[] {\n const locale = useLocale();\n const enableI18n = useEnableI18n();\n return useMemo(\n () =>\n getFormatLocales({\n locale,\n enableI18n,\n localesProp,\n }),\n [locale, enableI18n, localesProp]\n );\n}\n\nexport function useShouldTranslate(): boolean {\n const enableI18n = useEnableI18n();\n const locale = useLocale();\n return enableI18n && getI18nConfig().requiresTranslation(locale);\n}\n\nexport function useGTClass() {\n return useMemo(() => getI18nConfig().getGTClass(), []);\n}\n\nexport function useLocaleProperties(locale: string): LocaleProperties {\n return useMemo(\n () => getI18nConfig().getGTClass().getLocaleProperties(locale),\n [locale]\n );\n}\n\nexport function useLocaleDirection(locale: string) {\n return useMemo(\n () => getI18nConfig().getGTClass().getLocaleDirection(locale),\n [locale]\n );\n}\n\nexport function useVersionId() {\n throw new Error(\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'useVersionId() is not implemented in this entry point',\n fix: 'Use getVersionId() or import useVersionId() from a supported runtime entry point.',\n })\n );\n}\n","import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { I18nStore } from './I18nStore';\nimport { getI18nConfig } from '../setup/i18nConfig';\n\n// ===== I18n Store ===== //\n\ntype ReactCoreGlobals = {\n i18nStore?: I18nStore;\n [key: string]: unknown;\n};\n\ntype GeneralTranslationGlobal = {\n reactCore?: ReactCoreGlobals;\n [key: string]: unknown;\n};\n\ntype GlobalWithGeneralTranslation = {\n __generaltranslation?: GeneralTranslationGlobal;\n};\n\nfunction getReactCoreGlobals(): ReactCoreGlobals {\n const globalObj = globalThis as unknown as GlobalWithGeneralTranslation;\n globalObj.__generaltranslation ??= {};\n // TODO: Consider checking package versions and using a compatibility matrix before sharing global singletons.\n globalObj.__generaltranslation.reactCore ??= {};\n return globalObj.__generaltranslation.reactCore;\n}\n\nexport function getI18nStore(): I18nStore {\n const i18nStore = getReactCoreGlobals().i18nStore;\n if (!i18nStore) {\n throw createI18nStoreNotInitializedError();\n }\n return i18nStore;\n}\n\nexport function setI18nStore(nextStore: I18nStore): void {\n const reactCoreGlobals = getReactCoreGlobals();\n if (reactCoreGlobals.i18nStore && reactCoreGlobals.i18nStore !== nextStore) {\n console.warn(createI18nStoreOverwriteWarning());\n }\n reactCoreGlobals.i18nStore = nextStore;\n}\n\nexport function isI18nStoreInitialized(): boolean {\n return getReactCoreGlobals().i18nStore !== undefined;\n}\n\nfunction createI18nStoreNotInitializedError(): Error {\n const renderStrategy = getI18nConfig().getRenderStrategy();\n const errorMessage = createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Cannot access I18nStore before it is initialized.',\n fix:\n renderStrategy === 'SPA'\n ? 'Initialize GT before reading GT runtime context.'\n : 'Add a <GTProvider> at the root of your component tree.',\n });\n\n return new Error(errorMessage);\n}\n\nfunction createI18nStoreOverwriteWarning(): string {\n return createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Warning',\n whatHappened: 'Overwriting global i18nStore singleton instance',\n });\n}\n","import { Dictionary, Hash, Locale } from 'gt-i18n/internal/types';\nimport { useGTContext } from '../context/context';\nimport { I18nStore } from './I18nStore';\nimport { getI18nStore } from './singleton-operations';\nimport { Translation } from 'gt-i18n/types';\n\nexport function useI18nStore(): I18nStore {\n const context = useGTContext();\n return context?.i18nStore || getI18nStore();\n}\n\nexport function useTranslationsSnapshot(): Record<\n Locale,\n Record<Hash, Translation>\n> {\n const context = useGTContext();\n return context?.translationsSnapshot || {};\n}\n\nexport function useDictionariesSnapshot(): Record<Locale, Dictionary> {\n const context = useGTContext();\n return context?.dictionariesSnapshot || {};\n}\n","import {\n getDictionaryListenerKey,\n getI18nConfig,\n getTranslateListenerKey,\n} from 'gt-i18n/internal';\nimport { useShouldTranslate } from '../utils';\nimport { useI18nStore } from '../../i18n-store/useI18nStore';\nimport { DictionaryLookup, TranslateLookup } from '../../i18n-store/storeTypes';\nimport { useCallback, useEffect } from 'react';\nimport { Translation } from 'gt-i18n/types';\nimport { useGTContext } from '../../context/context';\n\nexport type OnMissingTranslation = <T extends Translation>(\n lookup: TranslateLookup<T>\n) => void;\nexport type OnMissingDictionaryEntry = (lookup: DictionaryLookup) => void;\n// TODO: rename to OnMissingDictionaryObject\nexport type OnMissingDictionaryObj = (lookup: DictionaryLookup) => void;\n\ntype PendingLookup =\n | {\n type: 'translation';\n lookup: TranslateLookup;\n }\n | {\n type: 'dictionaryEntry' | 'dictionaryObject';\n lookup: DictionaryLookup;\n };\n\n/**\n * Why have custom handleMissing functions?\n *\n * Some runtimes (like server) cannot make useEffect calls, so\n * we need to give them access to a callback where they can embed\n * their own translation calls\n *\n * While this is technnically not pure behavior, this is acceptable\n * in development hot reload\n */\n\n// TODO: reduce code duplication with the three below functions\nexport function useHandleMissingTranslation(): OnMissingTranslation {\n const customHandleMissing = useGTContext()?.onMissingTranslation;\n const pureHandleMissing = useDevHotReloadQueue();\n\n return useCallback(\n (lookup: TranslateLookup) => {\n if (customHandleMissing) {\n customHandleMissing(lookup);\n } else {\n pureHandleMissing(getTranslateListenerKey(lookup), {\n type: 'translation',\n lookup,\n });\n }\n },\n [customHandleMissing, pureHandleMissing]\n );\n}\n\nexport function useHandleMissingDictionaryEntry(): OnMissingDictionaryEntry {\n const customHandleMissing = useGTContext()?.onMissingDictionaryEntry;\n const pureHandleMissing = useDevHotReloadQueue();\n\n return useCallback(\n (lookup: DictionaryLookup) => {\n if (customHandleMissing) {\n customHandleMissing(lookup);\n } else {\n pureHandleMissing(getDictionaryListenerKey(lookup), {\n type: 'dictionaryEntry',\n lookup,\n });\n }\n },\n [customHandleMissing, pureHandleMissing]\n );\n}\n\nexport function useHandleMissingDictionaryObject(): OnMissingDictionaryObj {\n const customHandleMissing = useGTContext()?.onMissingDictionaryObj;\n const pureHandleMissing = useDevHotReloadQueue();\n return useCallback(\n (lookup: DictionaryLookup) => {\n if (customHandleMissing) {\n customHandleMissing(lookup);\n } else {\n pureHandleMissing(getDictionaryListenerKey(lookup), {\n type: 'dictionaryObject',\n lookup,\n });\n }\n },\n [customHandleMissing, pureHandleMissing]\n );\n}\n\n/**\n * HMR translation needs to be deferred to post-commit phase\n */\nfunction useDevHotReloadQueue() {\n const devHotReloadEnabled = getI18nConfig().isDevHotReloadEnabled();\n const shouldTranslate = useShouldTranslate();\n const i18nStore = useI18nStore();\n\n // No memoization bc we want to flush after every render\n // TODO: perhaps should find a way to memoize and flush in a better way than this as it nullifies any useCallback\n const pendingLookups = new Map<string, PendingLookup>();\n\n // Pure react: effects run after render\n useEffect(() => {\n if (!devHotReloadEnabled || !shouldTranslate || pendingLookups.size === 0) {\n return;\n }\n\n pendingLookups.forEach(({ type, lookup }) => {\n switch (type) {\n case 'translation':\n i18nStore.translate(lookup);\n break;\n case 'dictionaryEntry':\n i18nStore.translateDictionaryEntry(lookup);\n break;\n case 'dictionaryObject':\n i18nStore.translateDictionaryObject(lookup);\n break;\n }\n });\n }, [devHotReloadEnabled, shouldTranslate, i18nStore, pendingLookups]);\n\n // No need for useCallback b/c we want access to the pendingLookups map\n return (key: string, pendingLookup: PendingLookup) => {\n pendingLookups.set(key, pendingLookup);\n };\n}\n","import {\n type RefObject,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useSyncExternalStore,\n} from 'react';\nimport {\n createLookupOptions,\n getI18nConfig,\n getTranslateListenerKey,\n} from 'gt-i18n/internal';\nimport type { Translation } from 'gt-i18n/types';\nimport type {\n StoreListener,\n TranslateLookup,\n TranslateSnapshot,\n} from '../../i18n-store/storeTypes';\nimport type { InlineTranslationOptionsFields } from 'gt-i18n/internal/types';\nimport type { StringFormat } from '@generaltranslation/format';\nimport { useLocale } from '../condition-store';\nimport { useShouldTranslate } from '../utils';\nimport {\n useI18nStore,\n useTranslationsSnapshot,\n} from '../../i18n-store/useI18nStore';\nimport { useHandleMissingTranslation } from '../utils/missing-translation';\n\n/**\n * Returns the translation, but also triggers a translation if it is not found\n * when dev hot reload is enabled.\n */\nexport type TrackedTranslationResolver = <T extends Translation>(\n lookup: TranslateLookup<T>\n) => TranslateSnapshot<T>;\n\nexport type Message = InlineTranslationOptionsFields & {\n message: string;\n};\n\n/**\n * NOTE:\n * gt() may be called during render, so tracking intentionally only mutates\n * hook-local refs. This widens the event filter used by our existing\n * useSyncExternalStore subscription, but does not update React state or mutate\n * the translation cache during render.\n *\n * A render that is later aborted may leave behind an extra tracked key. That is\n * acceptable for dev hot reload because the worst case is an unnecessary\n * invalidation for this hook instance, not incorrect rendered output.\n */\n\nexport function useTrackedTranslationResolver(\n messages: Message[] = []\n): TrackedTranslationResolver {\n const translationsSnapshot = useTranslationsSnapshot();\n const i18nStore = useI18nStore();\n const devHotReloadEnabled = getI18nConfig().isDevHotReloadEnabled();\n const onMissingTranslation = useHandleMissingTranslation();\n\n /**\n * Track lookups per hook instance without updating React state during render.\n */\n const trackedKeysRef = useRef<Set<string> | null>(null);\n if (trackedKeysRef.current == null) {\n trackedKeysRef.current = new Set();\n }\n\n // (optimization) Pre-subscribe to compiler-injected lookups\n usePreloadCompilerLookups(messages, trackedKeysRef);\n\n // (tx hot reload) Subscribe to translation updates\n useSubscribeToLookups(trackedKeysRef);\n\n /**\n * Remember that we can make no assumptions about when this cb gets invoked\n * - Resolves translation from lookup\n * - enqueues dev hot reload (if needed)\n */\n return useCallback(\n <T extends Translation>(\n lookup: TranslateLookup<T>\n ): TranslateSnapshot<T> => {\n // Track the lookup for dev hot reload\n const lookupKey = getTranslateListenerKey(lookup);\n if (devHotReloadEnabled) {\n trackedKeysRef.current!.add(lookupKey);\n }\n\n // Resolve the translation from the store\n const translation = i18nStore.getTranslateSnapshot(\n lookup,\n translationsSnapshot\n );\n\n // Trigger a hot reload if the translation is not found\n if (translation == null && devHotReloadEnabled) {\n onMissingTranslation(lookup);\n }\n return translation;\n },\n [i18nStore, translationsSnapshot, onMissingTranslation, devHotReloadEnabled]\n );\n}\n\n/**\n * Subscribe to translation updates, but only trigger re-renders\n * if the lookup is in the tracked keys. Remember that we can make\n * no assumptions about when this list gets updated. Technically,\n * not pure, but this is an acceptable trade since this is\n * really just for translation hot reload.\n *\n * TODO: (separate PR) we can probably do better filtering for adding to the set since this is primarily dev only\n * TODO: reduce code duplication with the other two useSubscribeToLookups functions\n */\nfunction useSubscribeToLookups(trackedKeysRef: RefObject<Set<string> | null>) {\n // invalidation counter for triggering updates\n const versionRef = useRef(0);\n const i18nStore = useI18nStore();\n const subscribe = useCallback(\n (listener: StoreListener) => {\n return i18nStore.subscribeToTranslationEvents((lookup) => {\n const key = getTranslateListenerKey(lookup);\n if (!trackedKeysRef.current!.has(key)) return;\n versionRef.current++;\n listener();\n });\n },\n [i18nStore]\n );\n const getSnapshot = useCallback(() => {\n return versionRef.current;\n }, []);\n\n useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n\n/**\n * Pre-subscribe to compiler-injected lookups\n * trigger translations for them\n *\n * This ref mutation is safe because this is translation hot reload only\n * and effects are deterministic\n */\nfunction usePreloadCompilerLookups(\n messages: Message[],\n trackedKeysRef: RefObject<Set<string> | null>\n) {\n const i18nStore = useI18nStore();\n const locale = useLocale();\n const devHotReloadEnabled = getI18nConfig().isDevHotReloadEnabled();\n const shouldTranslate = useShouldTranslate();\n const translationsSnapshot = useTranslationsSnapshot();\n const txHotReloadEnabled = useMemo(() => {\n return messages?.length > 0 && shouldTranslate && devHotReloadEnabled;\n }, [messages, shouldTranslate, devHotReloadEnabled]);\n\n // Precompute as much as we can\n const lookups: [TranslateLookup<string>, string][] = useMemo(() => {\n if (!txHotReloadEnabled) return [];\n return messages.map(({ message, ...options }) => {\n const targetLocale = options.$locale ?? locale;\n const lookupOptions = createLookupOptions<StringFormat>(\n targetLocale,\n options,\n 'ICU'\n );\n const lookup = {\n locale: targetLocale,\n message,\n options: lookupOptions,\n };\n return [lookup, getTranslateListenerKey(lookup)];\n });\n }, [locale, txHotReloadEnabled, messages]);\n\n // Pre-subscribe to the lookups\n if (txHotReloadEnabled) {\n lookups.forEach(([, lookupKey]) => {\n trackedKeysRef.current!.add(lookupKey);\n });\n }\n\n /**\n * Delegate non-pure operations to post commit\n *\n * (Optimization) Trigger a hot reload if the translation is not found\n * for compiler-injected lookups\n *\n * TODO: for use() + suspense strategy, use a Promise.all()\n * TODO: server side translation invocation\n */\n useEffect(() => {\n if (!txHotReloadEnabled) return;\n\n lookups\n .filter(\n ([lookup]) =>\n i18nStore.getTranslateSnapshot(lookup, translationsSnapshot) == null\n )\n .forEach(([lookup]) => i18nStore.translate(lookup));\n }, [txHotReloadEnabled, i18nStore, lookups, translationsSnapshot]);\n}\n","import { useCallback } from 'react';\nimport { createLookupOptions, interpolateMessage } from 'gt-i18n/internal';\nimport { useLocale } from './condition-store';\nimport { useShouldTranslate } from './utils';\nimport type { GTFunctionType, InlineTranslationOptions } from 'gt-i18n/types';\nimport type { StringFormat } from '@generaltranslation/format/types';\nimport { useDefaultLocale } from './i18n-config';\nimport {\n type Message,\n useTrackedTranslationResolver,\n} from './external-store/useTrackedTranslationResolver';\n\n// ===== Hook ===== //\n\nexport function useGT(_messages?: Message[]): GTFunctionType {\n const locale = useLocale();\n const defaultLocale = useDefaultLocale();\n const shouldTranslate = useShouldTranslate();\n const resolveTranslation = useTrackedTranslationResolver(_messages);\n\n /**\n * gt() string translation callback\n */\n return useCallback(\n (message: string, options: InlineTranslationOptions = {}) => {\n if (!shouldTranslate) {\n return interpolateMessage({\n options,\n source: message,\n sourceLocale: defaultLocale,\n });\n }\n\n const lookupOptions = createLookupOptions<StringFormat>(\n options.$locale ?? locale,\n options,\n 'ICU'\n );\n const translation = resolveTranslation({\n locale: lookupOptions.$locale,\n message,\n options: lookupOptions,\n });\n\n return interpolateMessage({\n source: message,\n target: translation,\n options: lookupOptions,\n sourceLocale: defaultLocale,\n });\n },\n [defaultLocale, locale, shouldTranslate, resolveTranslation]\n );\n}\n","import { useCallback } from 'react';\nimport { decodeOptions } from 'gt-i18n';\nimport { useGT } from './useGT';\nimport type { InlineResolveOptions, MFunctionType } from 'gt-i18n/types';\nimport { isEncodedTranslationOptions } from 'gt-i18n/internal';\nimport { Message } from './external-store/useTrackedTranslationResolver';\n\n// ===== Hook ===== //\n\nexport function useMessages(_messages?: Message[]): MFunctionType {\n const gt = useGT(_messages);\n\n return useCallback(\n <T extends string | null | undefined>(\n encodedMsg: T,\n options: InlineResolveOptions = {}\n ): T extends string ? string : T => {\n if (encodedMsg == null) {\n return encodedMsg as T extends string ? string : T;\n }\n\n const decodedOptions = decodeOptions(encodedMsg) ?? {};\n if (isEncodedTranslationOptions(decodedOptions)) {\n return gt(decodedOptions.$_source, decodedOptions) as T extends string\n ? string\n : T;\n }\n\n return gt(encodedMsg, options) as T extends string ? string : T;\n },\n [gt]\n );\n}\n","import { useCallback, useRef } from 'react';\nimport {\n useDictionariesSnapshot,\n useI18nStore,\n} from '../../i18n-store/useI18nStore';\nimport type {\n DictionaryEntrySnapshot,\n DictionaryLookup,\n StoreListener,\n} from '../../i18n-store/storeTypes';\nimport { getDictionaryListenerKey, getI18nConfig } from 'gt-i18n/internal';\nimport { useSyncExternalStore } from 'react';\nimport type { RefObject } from 'react';\nimport { useHandleMissingDictionaryEntry } from '../utils/missing-translation';\n\nexport type TrackedDictionaryEntryResolver = (\n lookup: DictionaryLookup\n) => DictionaryEntrySnapshot;\n\n// TODO: rename to useTrackedDictionaryEntryResolver\nexport function useTrackedDictionaryResolver(): TrackedDictionaryEntryResolver {\n const dictionariesSnapshot = useDictionariesSnapshot();\n const i18nStore = useI18nStore();\n const devHotReloadEnabled = getI18nConfig().isDevHotReloadEnabled();\n const onMissingDictionaryEntry = useHandleMissingDictionaryEntry();\n\n const trackedKeysRef = useRef<Set<string> | null>(null);\n if (trackedKeysRef.current == null) {\n trackedKeysRef.current = new Set();\n }\n\n // subscribe to dictionary entry updates\n useSubscribeToLookups(trackedKeysRef);\n\n // Resolution callback\n return useCallback(\n (lookup: DictionaryLookup) => {\n // Track the lookup for dev hot reload\n const lookupKey = getDictionaryListenerKey(lookup);\n if (devHotReloadEnabled) {\n trackedKeysRef.current!.add(lookupKey);\n }\n\n // Resolve the dictionary entry from the store\n const dictionaryEntry = i18nStore.getDictionaryEntrySnapshot(\n lookup,\n dictionariesSnapshot\n );\n\n // Hot reload\n if (dictionaryEntry == null && devHotReloadEnabled) {\n onMissingDictionaryEntry(lookup);\n }\n\n return dictionaryEntry;\n },\n [\n i18nStore,\n dictionariesSnapshot,\n devHotReloadEnabled,\n onMissingDictionaryEntry,\n ]\n );\n}\n\nfunction useSubscribeToLookups(trackedKeysRef: RefObject<Set<string> | null>) {\n // invalidation counter for triggering updates\n const versionRef = useRef(0);\n const i18nStore = useI18nStore();\n const subscribe = useCallback(\n (listener: StoreListener) => {\n return i18nStore.subscribeToDictionaryEntryEvents((lookup) => {\n const key = getDictionaryListenerKey(lookup);\n if (!trackedKeysRef.current!.has(key)) return;\n versionRef.current++;\n listener();\n });\n },\n [i18nStore]\n );\n const getSnapshot = useCallback(() => {\n return versionRef.current;\n }, []);\n\n useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n","import { getDictionaryListenerKey, getI18nConfig } from 'gt-i18n/internal';\nimport type {\n DictionaryLookup,\n DictionaryObjectSnapshot,\n StoreListener,\n} from '../../i18n-store/storeTypes';\nimport {\n useDictionariesSnapshot,\n useI18nStore,\n} from '../../i18n-store/useI18nStore';\nimport {\n type RefObject,\n useCallback,\n useRef,\n useSyncExternalStore,\n} from 'react';\nimport { useHandleMissingDictionaryObject } from '../utils/missing-translation';\n\nexport type TrackedDictionaryObjResolver = (\n lookup: DictionaryLookup\n) => DictionaryObjectSnapshot;\n\n// TODO: rename to useTrackedDictionaryObjectResolver\nexport function useTrackedDictionaryObjResolver(): TrackedDictionaryObjResolver {\n const dictionariesSnapshot = useDictionariesSnapshot();\n const i18nStore = useI18nStore();\n const devHotReloadEnabled = getI18nConfig().isDevHotReloadEnabled();\n const onMissingDictionaryObj = useHandleMissingDictionaryObject();\n\n const trackedKeysRef = useRef<Set<string> | null>(null);\n if (trackedKeysRef.current == null) {\n trackedKeysRef.current = new Set();\n }\n\n // subscribe to dictionary entry updates\n useSubscribeToLookups(trackedKeysRef);\n\n // Resolution callback\n return useCallback(\n (lookup: DictionaryLookup) => {\n // Track the lookup for dev hot reload\n const lookupKey = getDictionaryListenerKey(lookup);\n if (devHotReloadEnabled) {\n trackedKeysRef.current!.add(lookupKey);\n }\n\n // Resolve the dictionary entry from the store\n const dictionaryObject = i18nStore.getDictionaryObjectSnapshot(\n lookup,\n dictionariesSnapshot\n );\n\n // Hot reload\n if (dictionaryObject == null && devHotReloadEnabled) {\n onMissingDictionaryObj(lookup);\n }\n\n return dictionaryObject;\n },\n [\n i18nStore,\n dictionariesSnapshot,\n devHotReloadEnabled,\n onMissingDictionaryObj,\n ]\n );\n}\n\nfunction useSubscribeToLookups(trackedKeysRef: RefObject<Set<string> | null>) {\n // invalidation counter for triggering updates\n const versionRef = useRef(0);\n const i18nStore = useI18nStore();\n const subscribe = useCallback(\n (listener: StoreListener) => {\n return i18nStore.subscribeToDictionaryObjectEvents((lookup) => {\n const key = getDictionaryListenerKey(lookup);\n if (!trackedKeysRef.current!.has(key)) return;\n versionRef.current++;\n listener();\n });\n },\n [i18nStore]\n );\n const getSnapshot = useCallback(() => {\n return versionRef.current;\n }, []);\n\n useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n","import { useCallback, useMemo } from 'react';\nimport {\n extractVariables,\n renderDictionaryEntry,\n renderDictionaryObject,\n resolveDictionaryLookupOptions,\n} from 'gt-i18n/internal';\nimport { useLocale } from './condition-store';\nimport { useGT } from './useGT';\nimport type {\n DictionaryObjectTranslation,\n DictionaryTranslationOptions,\n} from 'gt-i18n/types';\nimport { useDefaultLocale } from './i18n-config';\nimport { useShouldTranslate } from './utils';\nimport { useTrackedDictionaryResolver } from './external-store/useTrackedDictionaryResolver';\nimport { useTrackedDictionaryObjResolver } from './external-store/useTrackedDictionaryObjResolver';\n\n// ===== Hook ===== //\n\nexport function useTranslations(rootId?: string): UseTranslationsFunction {\n const locale = useLocale();\n const defaultLocale = useDefaultLocale();\n const shouldTranslate = useShouldTranslate();\n const gt = useGT();\n const resolveDictionaryEntry = useTrackedDictionaryResolver();\n const translateObject = useTranslationsObj(rootId);\n\n const translateEntry = useCallback(\n (suffix: string, options: DictionaryTranslationOptions = {}) => {\n const id = getId(rootId, suffix);\n\n const sourceEntry = resolveDictionaryEntry({\n locale: defaultLocale,\n id,\n });\n if (sourceEntry === undefined) {\n throw new Error(`Dictionary entry ${id} cannot be found`);\n }\n const sourceOptions = resolveDictionaryLookupOptions(sourceEntry.options);\n if (!shouldTranslate) {\n return gt(sourceEntry.entry, {\n ...sourceOptions,\n ...extractVariables(options),\n $locale: defaultLocale,\n });\n }\n\n const targetEntry = resolveDictionaryEntry({ locale, id });\n if (targetEntry?.entry != null) {\n return renderDictionaryEntry({\n sourceLocale: defaultLocale,\n targetLocale: locale,\n sourceEntry,\n target: targetEntry.entry,\n dictionaryOptions: sourceOptions,\n options,\n });\n }\n\n return gt(sourceEntry.entry, {\n ...sourceOptions,\n ...extractVariables(options),\n $locale: locale,\n });\n },\n [defaultLocale, gt, rootId, locale, resolveDictionaryEntry, shouldTranslate]\n );\n\n return useMemo(\n () => Object.assign(translateEntry, { obj: translateObject }),\n [translateEntry, translateObject]\n );\n}\n\nfunction useTranslationsObj(rootId?: string): UseTranslationsObjFunction {\n const locale = useLocale();\n const defaultLocale = useDefaultLocale();\n const shouldTranslate = useShouldTranslate();\n const gt = useGT();\n const resolveDictionaryObject = useTrackedDictionaryObjResolver();\n\n return useCallback(\n (suffix: string) => {\n const entryId = getId(rootId, suffix);\n const sourceObject = resolveDictionaryObject({\n locale: defaultLocale,\n id: entryId,\n });\n if (sourceObject === undefined) {\n throw new Error(`Dictionary entry ${entryId} cannot be found`);\n }\n\n let targetObject = undefined;\n if (shouldTranslate) {\n const targetLookup = { locale, id: entryId };\n targetObject = resolveDictionaryObject(targetLookup);\n }\n\n return renderDictionaryObject({\n sourceObject,\n targetObject,\n translate: (sourceEntry, dictionaryOptions) =>\n gt(sourceEntry.entry, {\n ...dictionaryOptions,\n $locale: shouldTranslate ? locale : defaultLocale,\n }),\n });\n },\n [\n defaultLocale,\n rootId,\n locale,\n resolveDictionaryObject,\n shouldTranslate,\n gt,\n ]\n );\n}\n\n// ===== Lookup Helpers ===== //\n\nfunction getId(prefix: string | undefined, suffix: string): string {\n return prefix ? `${prefix}.${suffix}` : suffix;\n}\n\n// ===== Types ===== //\n\nexport type UseTranslationsFunction = ((\n id: string,\n options?: DictionaryTranslationOptions\n) => string) & {\n obj: (id: string) => DictionaryObjectTranslation;\n};\n\ntype UseTranslationsObjFunction = (id: string) => DictionaryObjectTranslation;\n","import { useCallback, useMemo } from 'react';\nimport { useCustomMapping, useLocales } from './i18n-config';\nimport { useLocale } from './condition-store';\nimport { getLocaleProperties } from 'generaltranslation';\n\nexport function useInternalLocaleSelector(locales?: string[]) {\n // Retrieve the locale, locales, and setLocale function\n const contextLocales = useLocales();\n const customMapping = useCustomMapping();\n const locale = useLocale();\n\n // sort\n const sortedLocales = useMemo(() => {\n if (!contextLocales || contextLocales.length === 0) {\n return [];\n }\n const collator = new Intl.Collator();\n return [...contextLocales].sort((a, b) =>\n collator.compare(\n getLocaleProperties(a, locale, customMapping).nativeNameWithRegionCode,\n getLocaleProperties(b, locale, customMapping).nativeNameWithRegionCode\n )\n );\n }, [contextLocales, locale, customMapping]);\n\n // create getLocaleProperties callback\n const getLocalePropertiesCallback = useCallback(\n (locale: string) => {\n return getLocaleProperties(locale, locale, customMapping);\n },\n [locale, customMapping]\n );\n\n return {\n locale,\n locales: locales ? locales : sortedLocales,\n getLocaleProperties: getLocalePropertiesCallback,\n };\n}\n","import { useMemo } from 'react';\nimport { useCustomMapping, useLocales } from './i18n-config';\nimport { useLocale, useRegion } from './condition-store';\nimport { getLocaleProperties } from 'generaltranslation';\nimport { getI18nConfig } from 'gt-i18n/internal';\n\nexport type RegionData = {\n code: string;\n name: string;\n emoji: string;\n locale: string;\n};\n\nexport type InternalRegionSelectorOptions = {\n regions?: string[];\n customMapping?: {\n [region: string]:\n | string\n | { name?: string; emoji?: string; locale?: string };\n };\n prioritizeCurrentLocaleRegion?: boolean;\n sortRegionsAlphabetically?: boolean;\n};\n\n/**\n * Internal logic for region selection in applications supporting multiple regions.\n *\n * Returns the current region, an ordered list of available regions (inferred\n * from the supported locales when not provided), and a map of region codes to\n * their display data (name, emoji, associated locale).\n */\nexport function useInternalRegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion = true,\n sortRegionsAlphabetically = true,\n}: InternalRegionSelectorOptions = {}) {\n // Retrieve the locale, locales, and region\n const contextLocales = useLocales();\n const localeCustomMapping = useCustomMapping();\n const locale = useLocale();\n const region = useRegion();\n const { regionCode: localeRegion } = getLocaleProperties(\n locale,\n locale,\n localeCustomMapping\n );\n\n const [\n regions, // ordered list of ISO 3166 region codes\n regionData, // map of ISO 3166 region codes to region display data, potentially not ordered\n ] = useMemo<[string[], Map<string, RegionData>]>(() => {\n const gt = getI18nConfig().getGTClass(locale);\n const regionToLocaleMap = new Map(\n contextLocales.map((l) => {\n const lp = getLocaleProperties(l, locale, localeCustomMapping); // has to be directly called so sourceLocale can be in the user's current locale\n return [lp.regionCode, lp];\n })\n );\n\n const regions = _regions\n ? [..._regions]\n : Array.from(regionToLocaleMap?.keys() || [localeRegion]);\n\n const regionData = new Map<string, RegionData>(\n regions.map((r: string) => {\n return [\n r,\n {\n locale: regionToLocaleMap?.get(r)?.code || locale,\n ...gt.getRegionProperties(r),\n ...(typeof customMapping?.[r] === 'string'\n ? { name: customMapping?.[r] }\n : customMapping?.[r]),\n },\n ];\n })\n );\n\n if (sortRegionsAlphabetically) {\n regions.sort((a, b) =>\n new Intl.Collator().compare(\n regionData.get(a)!.name,\n regionData.get(b)!.name\n )\n );\n }\n\n if (prioritizeCurrentLocaleRegion) {\n const localeRegionIndex = regions.indexOf(localeRegion);\n if (localeRegionIndex > 0) {\n // 0 because no action is needed if it's already at the start\n regions.splice(localeRegionIndex, 1);\n regions.unshift(localeRegion);\n }\n }\n\n return [regions, regionData];\n }, [\n _regions,\n customMapping,\n locale,\n localeRegion,\n contextLocales,\n localeCustomMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n ]);\n\n return {\n region,\n regions,\n regionData,\n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CAAC,EAAa,CAAC,CAErD,EAAa,IAAI,IACrB,EAAQ,IAAK,GACJ,CACL,EACA,CACE,OAAQ,GAAmB,IAAI,EAAE,EAAE,MAAQ,EAC3C,GAAG,EAAG,oBAAoB,EAAE,CAC5B,GAAI,OAAO,IAAgB,IAAO,SAC9B,CAAE,KAAM,IAAgB,GAAI,CAC5B,IAAgB,GACrB,CACF,CACD,CACH,CAWD,GATI,GACF,EAAQ,MAAM,EAAG,IACf,IAAI,KAAK,UAAU,CAAC,QAClB,EAAW,IAAI,EAAE,CAAE,KACnB,EAAW,IAAI,EAAE,CAAE,KACpB,CACF,CAGC,EAA+B,CACjC,IAAM,EAAoB,EAAQ,QAAQ,EAAa,CACnD,EAAoB,IAEtB,EAAQ,OAAO,EAAmB,EAAE,CACpC,EAAQ,QAAQ,EAAa,EAIjC,MAAO,CAAC,EAAS,EAAW,EAC3B,CACD,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACD,CAAC,CAEF,MAAO,CACL,SACA,UACA,aACA,SACA,eACD"}
|
package/dist/hooks.d.ts
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { InlineTranslationOptionsFields, ReadonlyConditionStoreInterface } from "gt-i18n/internal/types";
|
|
2
|
+
import { DictionaryObjectTranslation, DictionaryTranslationOptions, GTFunctionType, MFunctionType } from "gt-i18n/types";
|
|
3
|
+
import * as _$generaltranslation from "generaltranslation";
|
|
4
|
+
|
|
5
|
+
//#region src/hooks/condition-store.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* NOTE: useSetLocale() and useSetEnableI18n() are not implemented in @generaltranslation/react-core
|
|
8
|
+
* Some server environments are read only, so we cannot implement these hooks.
|
|
9
|
+
*/
|
|
10
|
+
declare function useConditionStore(): ReadonlyConditionStoreInterface;
|
|
11
|
+
/**
|
|
12
|
+
* Returns the current locale.
|
|
13
|
+
*/
|
|
14
|
+
declare function useLocale(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Returns the current region, or undefined if no region is set.
|
|
17
|
+
*/
|
|
18
|
+
declare function useRegion(): string | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the current enableI18n flag.
|
|
21
|
+
*/
|
|
22
|
+
declare function useEnableI18n(): boolean;
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region ../format/dist/types-COaQnqVZ.d.cts
|
|
25
|
+
//#region src/locales/customLocaleMapping.d.ts
|
|
26
|
+
type CustomMapping = Record<string, string | Partial<LocaleProperties>>; //#endregion
|
|
27
|
+
//#region src/locales/getLocaleProperties.d.ts
|
|
28
|
+
type LocaleProperties = {
|
|
29
|
+
code: string;
|
|
30
|
+
name: string;
|
|
31
|
+
nativeName: string;
|
|
32
|
+
languageCode: string;
|
|
33
|
+
languageName: string;
|
|
34
|
+
nativeLanguageName: string;
|
|
35
|
+
nameWithRegionCode: string;
|
|
36
|
+
nativeNameWithRegionCode: string;
|
|
37
|
+
regionCode: string;
|
|
38
|
+
regionName: string;
|
|
39
|
+
nativeRegionName: string;
|
|
40
|
+
scriptCode: string;
|
|
41
|
+
scriptName: string;
|
|
42
|
+
nativeScriptName: string;
|
|
43
|
+
maximizedCode: string;
|
|
44
|
+
maximizedName: string;
|
|
45
|
+
nativeMaximizedName: string;
|
|
46
|
+
minimizedCode: string;
|
|
47
|
+
minimizedName: string;
|
|
48
|
+
nativeMinimizedName: string;
|
|
49
|
+
emoji: string;
|
|
50
|
+
}; //#endregion
|
|
51
|
+
//#region src/locales/getRegionProperties.d.ts
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/hooks/i18n-config.d.ts
|
|
54
|
+
declare function useCustomMapping(): CustomMapping;
|
|
55
|
+
declare function useDefaultLocale(): string;
|
|
56
|
+
declare function useLocales(): readonly string[];
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/hooks/external-store/useTrackedTranslationResolver.d.ts
|
|
59
|
+
type Message = InlineTranslationOptionsFields & {
|
|
60
|
+
message: string;
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/hooks/useGT.d.ts
|
|
64
|
+
declare function useGT(_messages?: Message[]): GTFunctionType;
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/hooks/useMessages.d.ts
|
|
67
|
+
declare function useMessages(_messages?: Message[]): MFunctionType;
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/hooks/useTranslations.d.ts
|
|
70
|
+
declare function useTranslations(rootId?: string): UseTranslationsFunction;
|
|
71
|
+
type UseTranslationsFunction = ((id: string, options?: DictionaryTranslationOptions) => string) & {
|
|
72
|
+
obj: (id: string) => DictionaryObjectTranslation;
|
|
73
|
+
};
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/hooks/utils.d.ts
|
|
76
|
+
declare function useFormatLocales(localesProp?: string[]): string[];
|
|
77
|
+
declare function useShouldTranslate(): boolean;
|
|
78
|
+
declare function useGTClass(): _$generaltranslation.GT;
|
|
79
|
+
declare function useLocaleProperties(locale: string): LocaleProperties;
|
|
80
|
+
declare function useLocaleDirection(locale: string): "ltr" | "rtl";
|
|
81
|
+
declare function useVersionId(): void;
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/hooks/useInternalLocaleSelector.d.ts
|
|
84
|
+
declare function useInternalLocaleSelector(locales?: string[]): {
|
|
85
|
+
locale: string;
|
|
86
|
+
locales: string[];
|
|
87
|
+
getLocaleProperties: (locale: string) => LocaleProperties;
|
|
88
|
+
};
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/hooks/useInternalRegionSelector.d.ts
|
|
91
|
+
type RegionData = {
|
|
92
|
+
code: string;
|
|
93
|
+
name: string;
|
|
94
|
+
emoji: string;
|
|
95
|
+
locale: string;
|
|
96
|
+
};
|
|
97
|
+
type InternalRegionSelectorOptions = {
|
|
98
|
+
regions?: string[];
|
|
99
|
+
customMapping?: {
|
|
100
|
+
[region: string]: string | {
|
|
101
|
+
name?: string;
|
|
102
|
+
emoji?: string;
|
|
103
|
+
locale?: string;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
prioritizeCurrentLocaleRegion?: boolean;
|
|
107
|
+
sortRegionsAlphabetically?: boolean;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Internal logic for region selection in applications supporting multiple regions.
|
|
111
|
+
*
|
|
112
|
+
* Returns the current region, an ordered list of available regions (inferred
|
|
113
|
+
* from the supported locales when not provided), and a map of region codes to
|
|
114
|
+
* their display data (name, emoji, associated locale).
|
|
115
|
+
*/
|
|
116
|
+
declare function useInternalRegionSelector({
|
|
117
|
+
regions: _regions,
|
|
118
|
+
customMapping,
|
|
119
|
+
prioritizeCurrentLocaleRegion,
|
|
120
|
+
sortRegionsAlphabetically
|
|
121
|
+
}?: InternalRegionSelectorOptions): {
|
|
122
|
+
region: string | undefined;
|
|
123
|
+
regions: string[];
|
|
124
|
+
regionData: Map<string, RegionData>;
|
|
125
|
+
locale: string;
|
|
126
|
+
localeRegion: string;
|
|
127
|
+
};
|
|
128
|
+
//#endregion
|
|
129
|
+
export { type InternalRegionSelectorOptions, type RegionData, useConditionStore, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useGTClass, useInternalLocaleSelector, useInternalRegionSelector, useLocale, useLocaleDirection, useLocaleProperties, useLocales, useMessages, useRegion, useShouldTranslate, useTranslations, useVersionId };
|
|
130
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","names":["CustomMapping","LocaleProperties","Partial","Record","code","name","nativeName","languageCode","languageName","nativeLanguageName","nameWithRegionCode","nativeNameWithRegionCode","regionCode","regionName","nativeRegionName","scriptCode","scriptName","nativeScriptName","maximizedCode","maximizedName","nativeMaximizedName","minimizedCode","minimizedName","nativeMinimizedName","emoji","CustomRegionMapping","region","locale","getRegionProperties","defaultLocale","customMapping","CutoffFormatStyle","TerminatorOptions","terminator","separator","CutoffFormatOptions","maxChars","style","VariableType","Variable","k","i","v","HTML_CONTENT_PROPS","pl","ti","alt","arl","arb","ard","HtmlContentPropKeysRecord","HtmlContentPropValuesRecord","GTProp","JsxChildren","b","t","JsxElement","d","c","JsxChild","StringFormat","DataFormat","StringContent","IcuMessage","StringMessage","I18nextMessage","Content","FormatVariables","Date","S","_","a","f","g","h","l","m","n","o","p","r","s","u","x","y"],"sources":["../src/hooks/condition-store.ts","../../format/dist/types-COaQnqVZ.d.cts","../src/hooks/i18n-config.ts","../src/hooks/external-store/useTrackedTranslationResolver.ts","../src/hooks/useGT.ts","../src/hooks/useMessages.ts","../src/hooks/useTranslations.ts","../src/hooks/utils.ts","../src/hooks/useInternalLocaleSelector.ts","../src/hooks/useInternalRegionSelector.ts"],"mappings":";;;;;;;;;iBASgB,iBAAA,CAAA,GAAqB,+BAAA;;;;iBAQrB,SAAA,CAAA;AAAhB;;;AAAA,iBAOgB,SAAA,CAAA;;AAAhB;;iBAOgB,aAAA,CAAA;;;;KC9BXA,aAAAA,GAAgBG,MAAAA,kBAAwBD,OAAAA,CAAQD,gBAAAA;AAAAA;AAAAA,KAGhDA,gBAAAA;EACHG,IAAAA;EACAC,IAAAA;EACAC,UAAAA;EACAC,YAAAA;EACAC,YAAAA;EACAC,kBAAAA;EACAC,kBAAAA;EACAC,wBAAAA;EACAC,UAAAA;EACAC,UAAAA;EACAC,gBAAAA;EACAC,UAAAA;EACAC,UAAAA;EACAC,gBAAAA;EACAC,aAAAA;EACAC,aAAAA;EACAC,mBAAAA;EACAC,aAAAA;EACAC,aAAAA;EACAC,mBAAAA;EACAC,KAAAA;AAAAA;AAAAA;;;iBCrBc,gBAAA,CAAA,GAAoB,aAAA;AAAA,iBAIpB,gBAAA,CAAA;AAAA,iBAIA,UAAA,CAAA;;;KCyBJ,OAAA,GAAU,8BAAA;EACpB,OAAA;AAAA;;;iBCxBc,KAAA,CAAM,SAAA,GAAY,OAAA,KAAY,cAAA;;;iBCL9B,WAAA,CAAY,SAAA,GAAY,OAAA,KAAY,aAAA;;;iBCWpC,eAAA,CAAgB,MAAA,YAAkB,uBAAA;AAAA,KA4GtC,uBAAA,KACV,EAAA,UACA,OAAA,GAAU,4BAAA;EAEV,GAAA,GAAM,EAAA,aAAe,2BAAA;AAAA;;;iBCzHP,gBAAA,CACd,WAAA;AAAA,iBAec,kBAAA,CAAA;AAAA,iBAMA,UAAA,CAAA,GAAU,oBAAA,CAAA,EAAA;AAAA,iBAIV,mBAAA,CAAoB,MAAA,WAAiB,gBAAA;AAAA,iBAOrC,kBAAA,CAAmB,MAAA;AAAA,iBAOnB,YAAA,CAAA;;;iBC9CA,yBAAA,CAA0B,OAAA;;;2CAAD,gBAAA;AAAA;;;KCC7B,UAAA;EACV,IAAA;EACA,IAAA;EACA,KAAA;EACA,MAAA;AAAA;AAAA,KAGU,6BAAA;EACV,OAAA;EACA,aAAA;IAAA,CACG,MAAA;MAEK,IAAA;MAAe,KAAA;MAAgB,MAAA;IAAA;EAAA;EAEvC,6BAAA;EACA,yBAAA;AAAA;;;ATUF;;;;;iBSAgB,yBAAA,CAAA;EACd,OAAA,EAAS,QAAA;EACT,aAAA;EACA,6BAAA;EACA;AAAA,IACC,6BAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{I18nConfig as e,createConditionStoreSingleton as t,createLookupOptions as n,extractVariables as r,getDictionaryListenerKey as i,getI18nConfig as a,getRuntimeEnvironment as o,getTranslateListenerKey as s,interpolateMessage as c,isEncodedTranslationOptions as l,renderDictionaryEntry as u,renderDictionaryObject as d,resolveDictionaryLookupOptions as f}from"gt-i18n/internal";import{createContext as p,useCallback as m,useContext as ee,useEffect as h,useMemo as g,useRef as _,useSyncExternalStore as v}from"react";import{decodeOptions as te}from"gt-i18n";import{getLocaleProperties as y}from"generaltranslation";function b(e){let t=e.trim();return t?/[.!?)]$/.test(t)?t:`${t}.`:``}function x(e){let t=e.trim(),n=t.length;for(;n>0;){let e=t[n-1];if(e!==`.`&&e!==`!`&&e!==`?`)break;--n}return t.slice(0,n)}function S(e){return e.replace(/^[A-Z][a-z]/,e=>e.toLowerCase())}function C(e){if(!e)return``;let t=Array.isArray(e)?e.join(`, `):e;return t.trim()?b(`Details: ${t}`):``}function ne(e){if(e!=null)return String(e)}function w({source:e,severity:t,whatHappened:n,reassurance:r,why:i,fix:a,wayOut:o,details:s,docsUrl:c}){let l=e?t?`${e} ${t}:`:`${e}:`:t?`${t}:`:``,u=i?`${x(n)} because ${S(x(i))}`:n,d=!!a&&!!o&&/^[a-z]/.test(x(o)),f=[u,r,d?`${x(a)}, or ${S(x(o))}`:a,d?void 0:o,C(s)].filter(e=>!!e).map(b);c&&f.push(`Learn more: ${c}`);let p=f.join(` `);return l?`${l} ${p}`:p}var T=class extends e{renderStrategy;constructor(e={},t=`server-render`){super(e),re(t),this.renderStrategy=t}getRenderStrategy(){return this.renderStrategy}};function E(){let e=a();if(D(e))return e;throw Error(w({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`Cannot read ReactI18nConfig after base I18nConfig setup.`,why:`the internal I18nConfig singleton was initialized without react-core render strategy support`,fix:`Initialize GT through gt-react or @generaltranslation/react-core/pure.`}))}function re(e){if(!(e===`SPA`||e===`server-render`))throw Error(w({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`Invalid React render strategy.`,why:`the render strategy must be "SPA" or "server-render", but received "${String(e)}"`,fix:`Initialize GT through gt-react or pass a valid render strategy.`}))}function D(e){return e instanceof T}const{getConditionStore:O,setConditionStore:ie,isConditionStoreInitialized:ae}=t(w({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`Cannot read GT runtime context before it has been initialized`,why:`The internal ConditionStore is unavailable`}));function k(){try{return O()}catch(e){let t=o(),n=E().getRenderStrategy(),r=w({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`Cannot access ConditionStore before it is initialized.`,details:ne(e),fix:n===`SPA`?`Initialize GT before reading GT runtime context.`:`Add a <GTProvider> at the root of your component tree.`,wayOut:t===`development`?void 0:n===`SPA`?`Request-specific values will fall back to the default configuration.`:`Request-specific values will fall back to the default configuration. This may cause hydration mismatches.`});if(t===`development`)throw Error(r);return console.error(r),{getLocale:()=>`en`,getRegion:()=>void 0,getEnableI18n:()=>!0,setLocale:()=>{},setRegion:()=>{},setEnableI18n:()=>{}}}}function oe(){let e=globalThis;return e.__generaltranslation??={},e.__generaltranslation.reactCore??={},e.__generaltranslation.reactCore}function se(){let e=oe();return e.gtContext??=p(void 0),e.gtContext}function A(){let e=ee(se());if(e||E().getRenderStrategy()===`SPA`)return e;throw Error(ce())}function ce(){return w({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`GT runtime context could not be read`,why:`GTContext was accessed outside of a <GTProvider>`,fix:`Add a <GTProvider> at the root of your component tree.`})}function j(){return A()?.conditionStore??k()}function M(){return j().getLocale()}function N(){return j().getRegion()}function P(){return j().getEnableI18n()}function F(){return g(()=>a().getCustomMapping(),[])}function I(){return g(()=>a().getDefaultLocale(),[])}function L(){return g(()=>a().getLocales(),[])}const R=[];function z({locale:e,enableI18n:t,localesProp:n=R}){let r=a().getDefaultLocale();return t&&a().requiresTranslation(e)?[...n,e,r]:[r]}const B=[];function V(e=B){let t=M(),n=P();return g(()=>z({locale:t,enableI18n:n,localesProp:e}),[t,n,e])}function H(){let e=P(),t=M();return e&&a().requiresTranslation(t)}function U(){return g(()=>a().getGTClass(),[])}function W(e){return g(()=>a().getGTClass().getLocaleProperties(e),[e])}function G(e){return g(()=>a().getGTClass().getLocaleDirection(e),[e])}function K(){throw Error(w({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`useVersionId() is not implemented in this entry point`,fix:`Use getVersionId() or import useVersionId() from a supported runtime entry point.`}))}function q(){let e=globalThis;return e.__generaltranslation??={},e.__generaltranslation.reactCore??={},e.__generaltranslation.reactCore}function le(){let e=q().i18nStore;if(!e)throw ue();return e}function ue(){let e=w({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`Cannot access I18nStore before it is initialized.`,fix:E().getRenderStrategy()===`SPA`?`Initialize GT before reading GT runtime context.`:`Add a <GTProvider> at the root of your component tree.`});return Error(e)}function J(){return A()?.i18nStore||le()}function Y(){return A()?.translationsSnapshot||{}}function X(){return A()?.dictionariesSnapshot||{}}function de(){let e=A()?.onMissingTranslation,t=Z();return m(n=>{e?e(n):t(s(n),{type:`translation`,lookup:n})},[e,t])}function fe(){let e=A()?.onMissingDictionaryEntry,t=Z();return m(n=>{e?e(n):t(i(n),{type:`dictionaryEntry`,lookup:n})},[e,t])}function pe(){let e=A()?.onMissingDictionaryObj,t=Z();return m(n=>{e?e(n):t(i(n),{type:`dictionaryObject`,lookup:n})},[e,t])}function Z(){let e=a().isDevHotReloadEnabled(),t=H(),n=J(),r=new Map;return h(()=>{!e||!t||r.size===0||r.forEach(({type:e,lookup:t})=>{switch(e){case`translation`:n.translate(t);break;case`dictionaryEntry`:n.translateDictionaryEntry(t);break;case`dictionaryObject`:n.translateDictionaryObject(t);break}})},[e,t,n,r]),(e,t)=>{r.set(e,t)}}function me(e=[]){let t=Y(),n=J(),r=a().isDevHotReloadEnabled(),i=de(),o=_(null);return o.current??=new Set,ge(e,o),he(o),m(e=>{let a=s(e);r&&o.current.add(a);let c=n.getTranslateSnapshot(e,t);return c==null&&r&&i(e),c},[n,t,i,r])}function he(e){let t=_(0),n=J(),r=m(r=>n.subscribeToTranslationEvents(n=>{let i=s(n);e.current.has(i)&&(t.current++,r())}),[n]),i=m(()=>t.current,[]);v(r,i,i)}function ge(e,t){let r=J(),i=M(),o=a().isDevHotReloadEnabled(),c=H(),l=Y(),u=g(()=>e?.length>0&&c&&o,[e,c,o]),d=g(()=>u?e.map(({message:e,...t})=>{let r=t.$locale??i,a={locale:r,message:e,options:n(r,t,`ICU`)};return[a,s(a)]}):[],[i,u,e]);u&&d.forEach(([,e])=>{t.current.add(e)}),h(()=>{u&&d.filter(([e])=>r.getTranslateSnapshot(e,l)==null).forEach(([e])=>r.translate(e))},[u,r,d,l])}function Q(e){let t=M(),r=I(),i=H(),a=me(e);return m((e,o={})=>{if(!i)return c({options:o,source:e,sourceLocale:r});let s=n(o.$locale??t,o,`ICU`);return c({source:e,target:a({locale:s.$locale,message:e,options:s}),options:s,sourceLocale:r})},[r,t,i,a])}function _e(e){let t=Q(e);return m((e,n={})=>{if(e==null)return e;let r=te(e)??{};return l(r)?t(r.$_source,r):t(e,n)},[t])}function ve(){let e=X(),t=J(),n=a().isDevHotReloadEnabled(),r=fe(),o=_(null);return o.current??=new Set,ye(o),m(a=>{let s=i(a);n&&o.current.add(s);let c=t.getDictionaryEntrySnapshot(a,e);return c==null&&n&&r(a),c},[t,e,n,r])}function ye(e){let t=_(0),n=J(),r=m(r=>n.subscribeToDictionaryEntryEvents(n=>{let a=i(n);e.current.has(a)&&(t.current++,r())}),[n]),a=m(()=>t.current,[]);v(r,a,a)}function be(){let e=X(),t=J(),n=a().isDevHotReloadEnabled(),r=pe(),o=_(null);return o.current??=new Set,xe(o),m(a=>{let s=i(a);n&&o.current.add(s);let c=t.getDictionaryObjectSnapshot(a,e);return c==null&&n&&r(a),c},[t,e,n,r])}function xe(e){let t=_(0),n=J(),r=m(r=>n.subscribeToDictionaryObjectEvents(n=>{let a=i(n);e.current.has(a)&&(t.current++,r())}),[n]),a=m(()=>t.current,[]);v(r,a,a)}function Se(e){let t=M(),n=I(),i=H(),a=Q(),o=ve(),s=Ce(e),c=m((s,c={})=>{let l=$(e,s),d=o({locale:n,id:l});if(d===void 0)throw Error(`Dictionary entry ${l} cannot be found`);let p=f(d.options);if(!i)return a(d.entry,{...p,...r(c),$locale:n});let m=o({locale:t,id:l});return m?.entry==null?a(d.entry,{...p,...r(c),$locale:t}):u({sourceLocale:n,targetLocale:t,sourceEntry:d,target:m.entry,dictionaryOptions:p,options:c})},[n,a,e,t,o,i]);return g(()=>Object.assign(c,{obj:s}),[c,s])}function Ce(e){let t=M(),n=I(),r=H(),i=Q(),a=be();return m(o=>{let s=$(e,o),c=a({locale:n,id:s});if(c===void 0)throw Error(`Dictionary entry ${s} cannot be found`);let l;return r&&(l=a({locale:t,id:s})),d({sourceObject:c,targetObject:l,translate:(e,a)=>i(e.entry,{...a,$locale:r?t:n})})},[n,e,t,a,r,i])}function $(e,t){return e?`${e}.${t}`:t}function we(e){let t=L(),n=F(),r=M(),i=g(()=>{if(!t||t.length===0)return[];let e=new Intl.Collator;return[...t].sort((t,i)=>e.compare(y(t,r,n).nativeNameWithRegionCode,y(i,r,n).nativeNameWithRegionCode))},[t,r,n]),a=m(e=>y(e,e,n),[r,n]);return{locale:r,locales:e||i,getLocaleProperties:a}}function Te({regions:e,customMapping:t,prioritizeCurrentLocaleRegion:n=!0,sortRegionsAlphabetically:r=!0}={}){let i=L(),o=F(),s=M(),c=N(),{regionCode:l}=y(s,s,o),[u,d]=g(()=>{let c=a().getGTClass(s),u=new Map(i.map(e=>{let t=y(e,s,o);return[t.regionCode,t]})),d=e?[...e]:Array.from(u?.keys()||[l]),f=new Map(d.map(e=>[e,{locale:u?.get(e)?.code||s,...c.getRegionProperties(e),...typeof t?.[e]==`string`?{name:t?.[e]}:t?.[e]}]));if(r&&d.sort((e,t)=>new Intl.Collator().compare(f.get(e).name,f.get(t).name)),n){let e=d.indexOf(l);e>0&&(d.splice(e,1),d.unshift(l))}return[d,f]},[e,t,s,l,i,o,n,r]);return{region:c,regions:u,regionData:d,locale:s,localeRegion:l}}export{j as useConditionStore,F as useCustomMapping,I as useDefaultLocale,P as useEnableI18n,V as useFormatLocales,Q as useGT,U as useGTClass,we as useInternalLocaleSelector,Te as useInternalRegionSelector,M as useLocale,G as useLocaleDirection,W as useLocaleProperties,L as useLocales,_e as useMessages,N as useRegion,H as useShouldTranslate,Se as useTranslations,K as useVersionId};
|
|
2
|
+
//# sourceMappingURL=hooks.esm.min.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.esm.min.mjs","names":["getI18nConfig","getBaseI18nConfig","getI18nConfig","getReactCoreGlobals","getI18nConfig","EMPTY_LOCALES_PROP","getI18nConfig","useSubscribeToLookups","useSubscribeToLookups"],"sources":["../../core/dist/base64-r7YWJYWt.mjs","../src/setup/i18nConfig.ts","../src/condition-store/singleton-operations.ts","../src/context/context.ts","../src/hooks/condition-store.ts","../src/hooks/i18n-config.ts","../src/hooks/utils/getFormatLocales.ts","../src/hooks/utils.ts","../src/i18n-store/singleton-operations.ts","../src/i18n-store/useI18nStore.ts","../src/hooks/utils/missing-translation.ts","../src/hooks/external-store/useTrackedTranslationResolver.ts","../src/hooks/useGT.ts","../src/hooks/useMessages.ts","../src/hooks/external-store/useTrackedDictionaryResolver.ts","../src/hooks/external-store/useTrackedDictionaryObjResolver.ts","../src/hooks/useTranslations.ts","../src/hooks/useInternalLocaleSelector.ts","../src/hooks/useInternalRegionSelector.ts"],"sourcesContent":["//#region src/settings/settings.ts\nconst libraryDefaultLocale = \"en\";\nconst defaultTimeout = 6e4;\n//#endregion\n//#region src/logging/diagnostics.ts\nfunction ensureSentence(text) {\n\tconst trimmed = text.trim();\n\tif (!trimmed) return \"\";\n\treturn /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\nfunction stripSentence(text) {\n\tconst trimmed = text.trim();\n\tlet end = trimmed.length;\n\twhile (end > 0) {\n\t\tconst char = trimmed[end - 1];\n\t\tif (char !== \".\" && char !== \"!\" && char !== \"?\") break;\n\t\tend -= 1;\n\t}\n\treturn trimmed.slice(0, end);\n}\nfunction lowercaseFirstWord(text) {\n\treturn text.replace(/^[A-Z][a-z]/, (match) => match.toLowerCase());\n}\nfunction formatDetails(details) {\n\tif (!details) return \"\";\n\tconst detailText = Array.isArray(details) ? details.join(\", \") : details;\n\tif (!detailText.trim()) return \"\";\n\treturn ensureSentence(`Details: ${detailText}`);\n}\nfunction formatDiagnosticErrorDetails(error) {\n\tif (error == null) return void 0;\n\treturn String(error);\n}\nfunction createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {\n\tconst prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : \"\";\n\tconst whatAndWhy = why ? `${stripSentence(whatHappened)} because ${lowercaseFirstWord(stripSentence(why))}` : whatHappened;\n\tconst shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n\tconst messageParts = [\n\t\twhatAndWhy,\n\t\treassurance,\n\t\tshouldCombineWayOut ? `${stripSentence(fix)}, or ${lowercaseFirstWord(stripSentence(wayOut))}` : fix,\n\t\tshouldCombineWayOut ? void 0 : wayOut,\n\t\tformatDetails(details)\n\t].filter((part) => !!part).map(ensureSentence);\n\tif (docsUrl) messageParts.push(`Learn more: ${docsUrl}`);\n\tconst message = messageParts.join(\" \");\n\treturn prefix ? `${prefix} ${message}` : message;\n}\n//#endregion\n//#region src/settings/settingsUrls.ts\nconst defaultCacheUrl = \"https://cdn.gtx.dev\";\nconst defaultBaseUrl = \"https://api2.gtx.dev\";\nconst defaultRuntimeApiUrl = \"https://runtime2.gtx.dev\";\n//#endregion\n//#region src/utils/isSupportedFileFormatTransform.ts\nconst SUPPORTED_TRANSFORMATIONS = {\n\tGTJSON: [\"GTJSON\"],\n\tJSON: [\"JSON\"],\n\tPO: [\"PO\"],\n\tPOT: [\"POT\", \"PO\"],\n\tYAML: [\"YAML\"],\n\tMDX: [\"MDX\"],\n\tMD: [\"MD\"],\n\tTS: [\"TS\"],\n\tJS: [\"JS\"],\n\tHTML: [\"HTML\"],\n\tTXT: [\"TXT\"],\n\tTWILIO_CONTENT_JSON: [\"TWILIO_CONTENT_JSON\"]\n};\n/**\n* This function checks if a file format transformation is supported during translation\n* @param from - The source file format.\n* @param to - The target file format.\n* @returns True if the transformation is supported, false otherwise\n*/\nfunction isSupportedFileFormatTransform(from, to) {\n\treturn SUPPORTED_TRANSFORMATIONS[from]?.includes(to) ?? false;\n}\n//#endregion\n//#region src/translate/utils/validateFileFormatTransform.ts\n/**\n* Returns a user-facing validation error when a requested file format transform\n* is missing source format context or is not currently supported.\n*/\nfunction getFileFormatTransformError(file) {\n\tif (!file.transformFormat) return void 0;\n\tconst fileLabel = file.fileName ?? file.fileId ?? \"unknown file\";\n\tif (!file.fileFormat) return `fileFormat is required when transformFormat is provided for ${fileLabel}`;\n\tif (!isSupportedFileFormatTransform(file.fileFormat, file.transformFormat)) return `Unsupported file format transform: ${file.fileFormat} -> ${file.transformFormat}`;\n}\n/**\n* Validates file format transforms before sending upload/enqueue requests.\n*/\nfunction validateFileFormatTransforms(files) {\n\tfor (const file of files) {\n\t\tconst error = getFileFormatTransformError(file);\n\t\tif (error) throw new Error(error);\n\t}\n}\n//#endregion\n//#region src/utils/base64.ts\nfunction encode(data) {\n\tif (typeof Buffer !== \"undefined\") return Buffer.from(data, \"utf8\").toString(\"base64\");\n\tconst bytes = new TextEncoder().encode(data);\n\tlet binary = \"\";\n\tfor (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);\n\treturn btoa(binary);\n}\nfunction decode(base64) {\n\tif (typeof Buffer !== \"undefined\") return Buffer.from(base64, \"base64\").toString(\"utf8\");\n\tconst binary = atob(base64);\n\tconst bytes = new Uint8Array(binary.length);\n\tfor (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);\n\treturn new TextDecoder().decode(bytes);\n}\n//#endregion\nexport { defaultBaseUrl as a, createDiagnosticMessage as c, libraryDefaultLocale as d, isSupportedFileFormatTransform as i, formatDiagnosticErrorDetails as l, encode as n, defaultCacheUrl as o, validateFileFormatTransforms as r, defaultRuntimeApiUrl as s, decode as t, defaultTimeout as u };\n\n//# sourceMappingURL=base64-r7YWJYWt.mjs.map","import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport {\n getI18nConfig as getBaseI18nConfig,\n I18nConfig,\n setI18nConfig as setBaseI18nConfig,\n} from 'gt-i18n/internal';\nimport type { I18nConfigParams } from 'gt-i18n/internal/types';\n\n/**\n * Helps us distinguish behavior for SPA vs server-rendered apps.\n * - server-rendered apps must use context\n * - SPA apps can synchronously access the locale\n */\nexport type RenderStrategy = 'SPA' | 'server-render';\n\nconst defaultRenderStrategy: RenderStrategy = 'server-render';\n\nexport class ReactI18nConfig extends I18nConfig {\n private renderStrategy: RenderStrategy;\n\n constructor(\n params: I18nConfigParams = {},\n renderStrategy: RenderStrategy = defaultRenderStrategy\n ) {\n super(params);\n validateRenderStrategy(renderStrategy);\n this.renderStrategy = renderStrategy;\n }\n\n getRenderStrategy(): RenderStrategy {\n return this.renderStrategy;\n }\n}\n\nexport function getI18nConfig(): ReactI18nConfig {\n const i18nConfig = getBaseI18nConfig();\n if (isReactI18nConfig(i18nConfig)) {\n return i18nConfig;\n }\n throw new Error(\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Cannot read ReactI18nConfig after base I18nConfig setup.',\n why: 'the internal I18nConfig singleton was initialized without react-core render strategy support',\n fix: 'Initialize GT through gt-react or @generaltranslation/react-core/pure.',\n })\n );\n}\n\nexport function setI18nConfig(nextI18nConfig: ReactI18nConfig): void {\n setBaseI18nConfig(nextI18nConfig);\n}\n\nexport function initializeI18nConfig(\n params: I18nConfigParams = {},\n renderStrategy: RenderStrategy = defaultRenderStrategy\n): ReactI18nConfig {\n const nextI18nConfig = new ReactI18nConfig(params, renderStrategy);\n setI18nConfig(nextI18nConfig);\n return nextI18nConfig;\n}\n\nfunction validateRenderStrategy(\n renderStrategy: RenderStrategy\n): asserts renderStrategy is RenderStrategy {\n if (renderStrategy === 'SPA' || renderStrategy === 'server-render') return;\n throw new Error(\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Invalid React render strategy.',\n why: `the render strategy must be \"SPA\" or \"server-render\", but received \"${String(renderStrategy)}\"`,\n fix: 'Initialize GT through gt-react or pass a valid render strategy.',\n })\n );\n}\n\nfunction isReactI18nConfig(\n i18nConfig: I18nConfig\n): i18nConfig is ReactI18nConfig {\n return i18nConfig instanceof ReactI18nConfig;\n}\n","import {\n createDiagnosticMessage,\n formatDiagnosticErrorDetails,\n libraryDefaultLocale,\n} from 'generaltranslation/internal';\nimport {\n createConditionStoreSingleton,\n getRuntimeEnvironment,\n} from 'gt-i18n/internal';\nimport type { ReadonlyConditionStoreInterface } from 'gt-i18n/internal/types';\nimport { getI18nConfig } from '../setup/i18nConfig';\n\nconst conditionStoreNotInitializedError = createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Cannot read GT runtime context before it has been initialized',\n why: 'The internal ConditionStore is unavailable',\n});\n\nconst { getConditionStore, setConditionStore, isConditionStoreInitialized } =\n createConditionStoreSingleton<ReadonlyConditionStoreInterface>(\n conditionStoreNotInitializedError\n );\n\n/**\n * Opinionated decision: add a safety wrapper around the condition store to be more forgiving in production\n * TODO: perhaps this is how condition store should always be accessed\n */\nfunction getReadonlyConditionStoreWithFallback(): ReadonlyConditionStoreInterface {\n try {\n return getConditionStore();\n } catch (error) {\n // Error handling\n const runtimeEnvironment = getRuntimeEnvironment();\n const renderStrategy = getI18nConfig().getRenderStrategy();\n const errorMessage = createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Cannot access ConditionStore before it is initialized.',\n details: formatDiagnosticErrorDetails(error),\n fix:\n renderStrategy === 'SPA'\n ? 'Initialize GT before reading GT runtime context.'\n : 'Add a <GTProvider> at the root of your component tree.',\n wayOut:\n runtimeEnvironment === 'development'\n ? undefined\n : renderStrategy === 'SPA'\n ? 'Request-specific values will fall back to the default configuration.'\n : 'Request-specific values will fall back to the default configuration. This may cause hydration mismatches.',\n });\n\n if (runtimeEnvironment === 'development') {\n throw new Error(errorMessage);\n } else {\n console.error(errorMessage);\n }\n\n // Fallback to default configuration (important: do not set globally)\n return {\n getLocale: () => libraryDefaultLocale,\n getRegion: () => undefined,\n getEnableI18n: () => true,\n setLocale: () => {},\n setRegion: () => {},\n setEnableI18n: () => {},\n };\n }\n}\n\nexport {\n getConditionStore as getReadonlyConditionStore,\n getReadonlyConditionStoreWithFallback,\n setConditionStore as setReadonlyConditionStore,\n isConditionStoreInitialized as isReadonlyConditionStoreInitialized,\n};\n","import {\n Dictionary,\n Hash,\n Locale,\n ReadonlyConditionStoreInterface,\n} from 'gt-i18n/internal/types';\nimport { Translation } from 'gt-i18n/types';\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { createContext, useContext, type Context } from 'react';\nimport { I18nStore } from '../i18n-store/I18nStore';\nimport { getI18nConfig } from '../setup/i18nConfig';\nimport type {\n OnMissingTranslation,\n OnMissingDictionaryEntry,\n OnMissingDictionaryObj,\n} from '../hooks/utils/missing-translation';\n\nexport type GTContextType = {\n /**\n * Source of truth for translations, streamed from server\n * In SPA mode, these won't be accessible and translations\n * can be accessed via useSyncExternalStore() directly\n */\n translationsSnapshot: Record<Locale, Record<Hash, Translation>>;\n dictionariesSnapshot: Record<Locale, Dictionary>;\n /**\n * I18nStore allows us to sync state updates in ConditionStore and I18nCache\n * with renders\n */\n i18nStore: I18nStore;\n /**\n * ConditionStore should always remain separate from i18nStore as\n * it manages how we perform lookups\n */\n conditionStore: ReadonlyConditionStoreInterface;\n /**\n * Custom override behavior on missing translations\n * Used for server triggering tx hmr b/c no access to useEffect\n */\n onMissingTranslation?: OnMissingTranslation;\n onMissingDictionaryEntry?: OnMissingDictionaryEntry;\n onMissingDictionaryObj?: OnMissingDictionaryObj;\n};\n\ntype ReactCoreGlobals = {\n gtContext?: Context<GTContextType | undefined>;\n [key: string]: unknown;\n};\n\ntype GeneralTranslationGlobal = {\n reactCore?: ReactCoreGlobals;\n [key: string]: unknown;\n};\n\ntype GlobalWithGeneralTranslation = {\n __generaltranslation?: GeneralTranslationGlobal;\n};\n\nfunction getReactCoreGlobals(): ReactCoreGlobals {\n const globalObj = globalThis as unknown as GlobalWithGeneralTranslation;\n globalObj.__generaltranslation ??= {};\n // TODO: Consider checking package versions and using a compatibility matrix before sharing global singletons.\n globalObj.__generaltranslation.reactCore ??= {};\n return globalObj.__generaltranslation.reactCore;\n}\n\nexport function getGTContext(): Context<GTContextType | undefined> {\n const reactCoreGlobals = getReactCoreGlobals();\n reactCoreGlobals.gtContext ??= createContext<GTContextType | undefined>(\n undefined\n );\n return reactCoreGlobals.gtContext;\n}\n\nexport function useGTContext(): GTContextType | undefined {\n const context = useContext(getGTContext());\n if (context || getI18nConfig().getRenderStrategy() === 'SPA') {\n return context;\n }\n /**\n * TODO: in a separate PR, we should figure out how to make this more of a forgiving system\n */\n throw new Error(createMissingGTProviderError());\n}\n\nfunction createMissingGTProviderError(): string {\n return createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'GT runtime context could not be read',\n why: 'GTContext was accessed outside of a <GTProvider>',\n fix: 'Add a <GTProvider> at the root of your component tree.',\n });\n}\n","import { ReadonlyConditionStoreInterface } from 'gt-i18n/internal/types';\nimport { getReadonlyConditionStoreWithFallback } from '../condition-store/singleton-operations';\nimport { useGTContext } from '../context/context';\n\n/**\n * NOTE: useSetLocale() and useSetEnableI18n() are not implemented in @generaltranslation/react-core\n * Some server environments are read only, so we cannot implement these hooks.\n */\n\nexport function useConditionStore(): ReadonlyConditionStoreInterface {\n const context = useGTContext();\n return context?.conditionStore ?? getReadonlyConditionStoreWithFallback();\n}\n\n/**\n * Returns the current locale.\n */\nexport function useLocale(): string {\n return useConditionStore().getLocale();\n}\n\n/**\n * Returns the current region, or undefined if no region is set.\n */\nexport function useRegion(): string | undefined {\n return useConditionStore().getRegion();\n}\n\n/**\n * Returns the current enableI18n flag.\n */\nexport function useEnableI18n(): boolean {\n return useConditionStore().getEnableI18n();\n}\n","import { useMemo } from 'react';\nimport { getI18nConfig } from 'gt-i18n/internal';\nimport type { CustomMapping } from 'generaltranslation/types';\n\nexport function useCustomMapping(): CustomMapping {\n return useMemo(() => getI18nConfig().getCustomMapping(), []);\n}\n\nexport function useDefaultLocale(): string {\n return useMemo(() => getI18nConfig().getDefaultLocale(), []);\n}\n\nexport function useLocales(): readonly string[] {\n return useMemo(() => getI18nConfig().getLocales(), []);\n}\n","import { getI18nConfig } from 'gt-i18n/internal';\n\n// Pure helper shared by hook-based and RSC code paths. This module must stay\n// free of hook/context imports so it can be reached from the components-rsc\n// entrypoint.\n\nconst EMPTY_LOCALES_PROP: string[] = [];\n\nexport function getFormatLocales({\n locale,\n enableI18n,\n localesProp = EMPTY_LOCALES_PROP,\n}: {\n locale: string;\n enableI18n: boolean;\n localesProp?: string[];\n}): string[] {\n const defaultLocale = getI18nConfig().getDefaultLocale();\n const shouldTranslate =\n enableI18n && getI18nConfig().requiresTranslation(locale);\n return shouldTranslate\n ? [...localesProp, locale, defaultLocale]\n : [defaultLocale];\n}\n","import type { LocaleProperties } from '@generaltranslation/format/types';\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { useMemo } from 'react';\nimport { useEnableI18n, useLocale } from './condition-store';\nimport { getFormatLocales } from './utils/getFormatLocales';\nimport { getI18nConfig } from 'gt-i18n/internal';\n\nconst EMPTY_LOCALES_PROP: string[] = [];\n\nexport { getFormatLocales };\n\nexport function useFormatLocales(\n localesProp: string[] = EMPTY_LOCALES_PROP\n): string[] {\n const locale = useLocale();\n const enableI18n = useEnableI18n();\n return useMemo(\n () =>\n getFormatLocales({\n locale,\n enableI18n,\n localesProp,\n }),\n [locale, enableI18n, localesProp]\n );\n}\n\nexport function useShouldTranslate(): boolean {\n const enableI18n = useEnableI18n();\n const locale = useLocale();\n return enableI18n && getI18nConfig().requiresTranslation(locale);\n}\n\nexport function useGTClass() {\n return useMemo(() => getI18nConfig().getGTClass(), []);\n}\n\nexport function useLocaleProperties(locale: string): LocaleProperties {\n return useMemo(\n () => getI18nConfig().getGTClass().getLocaleProperties(locale),\n [locale]\n );\n}\n\nexport function useLocaleDirection(locale: string) {\n return useMemo(\n () => getI18nConfig().getGTClass().getLocaleDirection(locale),\n [locale]\n );\n}\n\nexport function useVersionId() {\n throw new Error(\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'useVersionId() is not implemented in this entry point',\n fix: 'Use getVersionId() or import useVersionId() from a supported runtime entry point.',\n })\n );\n}\n","import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { I18nStore } from './I18nStore';\nimport { getI18nConfig } from '../setup/i18nConfig';\n\n// ===== I18n Store ===== //\n\ntype ReactCoreGlobals = {\n i18nStore?: I18nStore;\n [key: string]: unknown;\n};\n\ntype GeneralTranslationGlobal = {\n reactCore?: ReactCoreGlobals;\n [key: string]: unknown;\n};\n\ntype GlobalWithGeneralTranslation = {\n __generaltranslation?: GeneralTranslationGlobal;\n};\n\nfunction getReactCoreGlobals(): ReactCoreGlobals {\n const globalObj = globalThis as unknown as GlobalWithGeneralTranslation;\n globalObj.__generaltranslation ??= {};\n // TODO: Consider checking package versions and using a compatibility matrix before sharing global singletons.\n globalObj.__generaltranslation.reactCore ??= {};\n return globalObj.__generaltranslation.reactCore;\n}\n\nexport function getI18nStore(): I18nStore {\n const i18nStore = getReactCoreGlobals().i18nStore;\n if (!i18nStore) {\n throw createI18nStoreNotInitializedError();\n }\n return i18nStore;\n}\n\nexport function setI18nStore(nextStore: I18nStore): void {\n const reactCoreGlobals = getReactCoreGlobals();\n if (reactCoreGlobals.i18nStore && reactCoreGlobals.i18nStore !== nextStore) {\n console.warn(createI18nStoreOverwriteWarning());\n }\n reactCoreGlobals.i18nStore = nextStore;\n}\n\nexport function isI18nStoreInitialized(): boolean {\n return getReactCoreGlobals().i18nStore !== undefined;\n}\n\nfunction createI18nStoreNotInitializedError(): Error {\n const renderStrategy = getI18nConfig().getRenderStrategy();\n const errorMessage = createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Cannot access I18nStore before it is initialized.',\n fix:\n renderStrategy === 'SPA'\n ? 'Initialize GT before reading GT runtime context.'\n : 'Add a <GTProvider> at the root of your component tree.',\n });\n\n return new Error(errorMessage);\n}\n\nfunction createI18nStoreOverwriteWarning(): string {\n return createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Warning',\n whatHappened: 'Overwriting global i18nStore singleton instance',\n });\n}\n","import { Dictionary, Hash, Locale } from 'gt-i18n/internal/types';\nimport { useGTContext } from '../context/context';\nimport { I18nStore } from './I18nStore';\nimport { getI18nStore } from './singleton-operations';\nimport { Translation } from 'gt-i18n/types';\n\nexport function useI18nStore(): I18nStore {\n const context = useGTContext();\n return context?.i18nStore || getI18nStore();\n}\n\nexport function useTranslationsSnapshot(): Record<\n Locale,\n Record<Hash, Translation>\n> {\n const context = useGTContext();\n return context?.translationsSnapshot || {};\n}\n\nexport function useDictionariesSnapshot(): Record<Locale, Dictionary> {\n const context = useGTContext();\n return context?.dictionariesSnapshot || {};\n}\n","import {\n getDictionaryListenerKey,\n getI18nConfig,\n getTranslateListenerKey,\n} from 'gt-i18n/internal';\nimport { useShouldTranslate } from '../utils';\nimport { useI18nStore } from '../../i18n-store/useI18nStore';\nimport { DictionaryLookup, TranslateLookup } from '../../i18n-store/storeTypes';\nimport { useCallback, useEffect } from 'react';\nimport { Translation } from 'gt-i18n/types';\nimport { useGTContext } from '../../context/context';\n\nexport type OnMissingTranslation = <T extends Translation>(\n lookup: TranslateLookup<T>\n) => void;\nexport type OnMissingDictionaryEntry = (lookup: DictionaryLookup) => void;\n// TODO: rename to OnMissingDictionaryObject\nexport type OnMissingDictionaryObj = (lookup: DictionaryLookup) => void;\n\ntype PendingLookup =\n | {\n type: 'translation';\n lookup: TranslateLookup;\n }\n | {\n type: 'dictionaryEntry' | 'dictionaryObject';\n lookup: DictionaryLookup;\n };\n\n/**\n * Why have custom handleMissing functions?\n *\n * Some runtimes (like server) cannot make useEffect calls, so\n * we need to give them access to a callback where they can embed\n * their own translation calls\n *\n * While this is technnically not pure behavior, this is acceptable\n * in development hot reload\n */\n\n// TODO: reduce code duplication with the three below functions\nexport function useHandleMissingTranslation(): OnMissingTranslation {\n const customHandleMissing = useGTContext()?.onMissingTranslation;\n const pureHandleMissing = useDevHotReloadQueue();\n\n return useCallback(\n (lookup: TranslateLookup) => {\n if (customHandleMissing) {\n customHandleMissing(lookup);\n } else {\n pureHandleMissing(getTranslateListenerKey(lookup), {\n type: 'translation',\n lookup,\n });\n }\n },\n [customHandleMissing, pureHandleMissing]\n );\n}\n\nexport function useHandleMissingDictionaryEntry(): OnMissingDictionaryEntry {\n const customHandleMissing = useGTContext()?.onMissingDictionaryEntry;\n const pureHandleMissing = useDevHotReloadQueue();\n\n return useCallback(\n (lookup: DictionaryLookup) => {\n if (customHandleMissing) {\n customHandleMissing(lookup);\n } else {\n pureHandleMissing(getDictionaryListenerKey(lookup), {\n type: 'dictionaryEntry',\n lookup,\n });\n }\n },\n [customHandleMissing, pureHandleMissing]\n );\n}\n\nexport function useHandleMissingDictionaryObject(): OnMissingDictionaryObj {\n const customHandleMissing = useGTContext()?.onMissingDictionaryObj;\n const pureHandleMissing = useDevHotReloadQueue();\n return useCallback(\n (lookup: DictionaryLookup) => {\n if (customHandleMissing) {\n customHandleMissing(lookup);\n } else {\n pureHandleMissing(getDictionaryListenerKey(lookup), {\n type: 'dictionaryObject',\n lookup,\n });\n }\n },\n [customHandleMissing, pureHandleMissing]\n );\n}\n\n/**\n * HMR translation needs to be deferred to post-commit phase\n */\nfunction useDevHotReloadQueue() {\n const devHotReloadEnabled = getI18nConfig().isDevHotReloadEnabled();\n const shouldTranslate = useShouldTranslate();\n const i18nStore = useI18nStore();\n\n // No memoization bc we want to flush after every render\n // TODO: perhaps should find a way to memoize and flush in a better way than this as it nullifies any useCallback\n const pendingLookups = new Map<string, PendingLookup>();\n\n // Pure react: effects run after render\n useEffect(() => {\n if (!devHotReloadEnabled || !shouldTranslate || pendingLookups.size === 0) {\n return;\n }\n\n pendingLookups.forEach(({ type, lookup }) => {\n switch (type) {\n case 'translation':\n i18nStore.translate(lookup);\n break;\n case 'dictionaryEntry':\n i18nStore.translateDictionaryEntry(lookup);\n break;\n case 'dictionaryObject':\n i18nStore.translateDictionaryObject(lookup);\n break;\n }\n });\n }, [devHotReloadEnabled, shouldTranslate, i18nStore, pendingLookups]);\n\n // No need for useCallback b/c we want access to the pendingLookups map\n return (key: string, pendingLookup: PendingLookup) => {\n pendingLookups.set(key, pendingLookup);\n };\n}\n","import {\n type RefObject,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useSyncExternalStore,\n} from 'react';\nimport {\n createLookupOptions,\n getI18nConfig,\n getTranslateListenerKey,\n} from 'gt-i18n/internal';\nimport type { Translation } from 'gt-i18n/types';\nimport type {\n StoreListener,\n TranslateLookup,\n TranslateSnapshot,\n} from '../../i18n-store/storeTypes';\nimport type { InlineTranslationOptionsFields } from 'gt-i18n/internal/types';\nimport type { StringFormat } from '@generaltranslation/format';\nimport { useLocale } from '../condition-store';\nimport { useShouldTranslate } from '../utils';\nimport {\n useI18nStore,\n useTranslationsSnapshot,\n} from '../../i18n-store/useI18nStore';\nimport { useHandleMissingTranslation } from '../utils/missing-translation';\n\n/**\n * Returns the translation, but also triggers a translation if it is not found\n * when dev hot reload is enabled.\n */\nexport type TrackedTranslationResolver = <T extends Translation>(\n lookup: TranslateLookup<T>\n) => TranslateSnapshot<T>;\n\nexport type Message = InlineTranslationOptionsFields & {\n message: string;\n};\n\n/**\n * NOTE:\n * gt() may be called during render, so tracking intentionally only mutates\n * hook-local refs. This widens the event filter used by our existing\n * useSyncExternalStore subscription, but does not update React state or mutate\n * the translation cache during render.\n *\n * A render that is later aborted may leave behind an extra tracked key. That is\n * acceptable for dev hot reload because the worst case is an unnecessary\n * invalidation for this hook instance, not incorrect rendered output.\n */\n\nexport function useTrackedTranslationResolver(\n messages: Message[] = []\n): TrackedTranslationResolver {\n const translationsSnapshot = useTranslationsSnapshot();\n const i18nStore = useI18nStore();\n const devHotReloadEnabled = getI18nConfig().isDevHotReloadEnabled();\n const onMissingTranslation = useHandleMissingTranslation();\n\n /**\n * Track lookups per hook instance without updating React state during render.\n */\n const trackedKeysRef = useRef<Set<string> | null>(null);\n if (trackedKeysRef.current == null) {\n trackedKeysRef.current = new Set();\n }\n\n // (optimization) Pre-subscribe to compiler-injected lookups\n usePreloadCompilerLookups(messages, trackedKeysRef);\n\n // (tx hot reload) Subscribe to translation updates\n useSubscribeToLookups(trackedKeysRef);\n\n /**\n * Remember that we can make no assumptions about when this cb gets invoked\n * - Resolves translation from lookup\n * - enqueues dev hot reload (if needed)\n */\n return useCallback(\n <T extends Translation>(\n lookup: TranslateLookup<T>\n ): TranslateSnapshot<T> => {\n // Track the lookup for dev hot reload\n const lookupKey = getTranslateListenerKey(lookup);\n if (devHotReloadEnabled) {\n trackedKeysRef.current!.add(lookupKey);\n }\n\n // Resolve the translation from the store\n const translation = i18nStore.getTranslateSnapshot(\n lookup,\n translationsSnapshot\n );\n\n // Trigger a hot reload if the translation is not found\n if (translation == null && devHotReloadEnabled) {\n onMissingTranslation(lookup);\n }\n return translation;\n },\n [i18nStore, translationsSnapshot, onMissingTranslation, devHotReloadEnabled]\n );\n}\n\n/**\n * Subscribe to translation updates, but only trigger re-renders\n * if the lookup is in the tracked keys. Remember that we can make\n * no assumptions about when this list gets updated. Technically,\n * not pure, but this is an acceptable trade since this is\n * really just for translation hot reload.\n *\n * TODO: (separate PR) we can probably do better filtering for adding to the set since this is primarily dev only\n * TODO: reduce code duplication with the other two useSubscribeToLookups functions\n */\nfunction useSubscribeToLookups(trackedKeysRef: RefObject<Set<string> | null>) {\n // invalidation counter for triggering updates\n const versionRef = useRef(0);\n const i18nStore = useI18nStore();\n const subscribe = useCallback(\n (listener: StoreListener) => {\n return i18nStore.subscribeToTranslationEvents((lookup) => {\n const key = getTranslateListenerKey(lookup);\n if (!trackedKeysRef.current!.has(key)) return;\n versionRef.current++;\n listener();\n });\n },\n [i18nStore]\n );\n const getSnapshot = useCallback(() => {\n return versionRef.current;\n }, []);\n\n useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n\n/**\n * Pre-subscribe to compiler-injected lookups\n * trigger translations for them\n *\n * This ref mutation is safe because this is translation hot reload only\n * and effects are deterministic\n */\nfunction usePreloadCompilerLookups(\n messages: Message[],\n trackedKeysRef: RefObject<Set<string> | null>\n) {\n const i18nStore = useI18nStore();\n const locale = useLocale();\n const devHotReloadEnabled = getI18nConfig().isDevHotReloadEnabled();\n const shouldTranslate = useShouldTranslate();\n const translationsSnapshot = useTranslationsSnapshot();\n const txHotReloadEnabled = useMemo(() => {\n return messages?.length > 0 && shouldTranslate && devHotReloadEnabled;\n }, [messages, shouldTranslate, devHotReloadEnabled]);\n\n // Precompute as much as we can\n const lookups: [TranslateLookup<string>, string][] = useMemo(() => {\n if (!txHotReloadEnabled) return [];\n return messages.map(({ message, ...options }) => {\n const targetLocale = options.$locale ?? locale;\n const lookupOptions = createLookupOptions<StringFormat>(\n targetLocale,\n options,\n 'ICU'\n );\n const lookup = {\n locale: targetLocale,\n message,\n options: lookupOptions,\n };\n return [lookup, getTranslateListenerKey(lookup)];\n });\n }, [locale, txHotReloadEnabled, messages]);\n\n // Pre-subscribe to the lookups\n if (txHotReloadEnabled) {\n lookups.forEach(([, lookupKey]) => {\n trackedKeysRef.current!.add(lookupKey);\n });\n }\n\n /**\n * Delegate non-pure operations to post commit\n *\n * (Optimization) Trigger a hot reload if the translation is not found\n * for compiler-injected lookups\n *\n * TODO: for use() + suspense strategy, use a Promise.all()\n * TODO: server side translation invocation\n */\n useEffect(() => {\n if (!txHotReloadEnabled) return;\n\n lookups\n .filter(\n ([lookup]) =>\n i18nStore.getTranslateSnapshot(lookup, translationsSnapshot) == null\n )\n .forEach(([lookup]) => i18nStore.translate(lookup));\n }, [txHotReloadEnabled, i18nStore, lookups, translationsSnapshot]);\n}\n","import { useCallback } from 'react';\nimport { createLookupOptions, interpolateMessage } from 'gt-i18n/internal';\nimport { useLocale } from './condition-store';\nimport { useShouldTranslate } from './utils';\nimport type { GTFunctionType, InlineTranslationOptions } from 'gt-i18n/types';\nimport type { StringFormat } from '@generaltranslation/format/types';\nimport { useDefaultLocale } from './i18n-config';\nimport {\n type Message,\n useTrackedTranslationResolver,\n} from './external-store/useTrackedTranslationResolver';\n\n// ===== Hook ===== //\n\nexport function useGT(_messages?: Message[]): GTFunctionType {\n const locale = useLocale();\n const defaultLocale = useDefaultLocale();\n const shouldTranslate = useShouldTranslate();\n const resolveTranslation = useTrackedTranslationResolver(_messages);\n\n /**\n * gt() string translation callback\n */\n return useCallback(\n (message: string, options: InlineTranslationOptions = {}) => {\n if (!shouldTranslate) {\n return interpolateMessage({\n options,\n source: message,\n sourceLocale: defaultLocale,\n });\n }\n\n const lookupOptions = createLookupOptions<StringFormat>(\n options.$locale ?? locale,\n options,\n 'ICU'\n );\n const translation = resolveTranslation({\n locale: lookupOptions.$locale,\n message,\n options: lookupOptions,\n });\n\n return interpolateMessage({\n source: message,\n target: translation,\n options: lookupOptions,\n sourceLocale: defaultLocale,\n });\n },\n [defaultLocale, locale, shouldTranslate, resolveTranslation]\n );\n}\n","import { useCallback } from 'react';\nimport { decodeOptions } from 'gt-i18n';\nimport { useGT } from './useGT';\nimport type { InlineResolveOptions, MFunctionType } from 'gt-i18n/types';\nimport { isEncodedTranslationOptions } from 'gt-i18n/internal';\nimport { Message } from './external-store/useTrackedTranslationResolver';\n\n// ===== Hook ===== //\n\nexport function useMessages(_messages?: Message[]): MFunctionType {\n const gt = useGT(_messages);\n\n return useCallback(\n <T extends string | null | undefined>(\n encodedMsg: T,\n options: InlineResolveOptions = {}\n ): T extends string ? string : T => {\n if (encodedMsg == null) {\n return encodedMsg as T extends string ? string : T;\n }\n\n const decodedOptions = decodeOptions(encodedMsg) ?? {};\n if (isEncodedTranslationOptions(decodedOptions)) {\n return gt(decodedOptions.$_source, decodedOptions) as T extends string\n ? string\n : T;\n }\n\n return gt(encodedMsg, options) as T extends string ? string : T;\n },\n [gt]\n );\n}\n","import { useCallback, useRef } from 'react';\nimport {\n useDictionariesSnapshot,\n useI18nStore,\n} from '../../i18n-store/useI18nStore';\nimport type {\n DictionaryEntrySnapshot,\n DictionaryLookup,\n StoreListener,\n} from '../../i18n-store/storeTypes';\nimport { getDictionaryListenerKey, getI18nConfig } from 'gt-i18n/internal';\nimport { useSyncExternalStore } from 'react';\nimport type { RefObject } from 'react';\nimport { useHandleMissingDictionaryEntry } from '../utils/missing-translation';\n\nexport type TrackedDictionaryEntryResolver = (\n lookup: DictionaryLookup\n) => DictionaryEntrySnapshot;\n\n// TODO: rename to useTrackedDictionaryEntryResolver\nexport function useTrackedDictionaryResolver(): TrackedDictionaryEntryResolver {\n const dictionariesSnapshot = useDictionariesSnapshot();\n const i18nStore = useI18nStore();\n const devHotReloadEnabled = getI18nConfig().isDevHotReloadEnabled();\n const onMissingDictionaryEntry = useHandleMissingDictionaryEntry();\n\n const trackedKeysRef = useRef<Set<string> | null>(null);\n if (trackedKeysRef.current == null) {\n trackedKeysRef.current = new Set();\n }\n\n // subscribe to dictionary entry updates\n useSubscribeToLookups(trackedKeysRef);\n\n // Resolution callback\n return useCallback(\n (lookup: DictionaryLookup) => {\n // Track the lookup for dev hot reload\n const lookupKey = getDictionaryListenerKey(lookup);\n if (devHotReloadEnabled) {\n trackedKeysRef.current!.add(lookupKey);\n }\n\n // Resolve the dictionary entry from the store\n const dictionaryEntry = i18nStore.getDictionaryEntrySnapshot(\n lookup,\n dictionariesSnapshot\n );\n\n // Hot reload\n if (dictionaryEntry == null && devHotReloadEnabled) {\n onMissingDictionaryEntry(lookup);\n }\n\n return dictionaryEntry;\n },\n [\n i18nStore,\n dictionariesSnapshot,\n devHotReloadEnabled,\n onMissingDictionaryEntry,\n ]\n );\n}\n\nfunction useSubscribeToLookups(trackedKeysRef: RefObject<Set<string> | null>) {\n // invalidation counter for triggering updates\n const versionRef = useRef(0);\n const i18nStore = useI18nStore();\n const subscribe = useCallback(\n (listener: StoreListener) => {\n return i18nStore.subscribeToDictionaryEntryEvents((lookup) => {\n const key = getDictionaryListenerKey(lookup);\n if (!trackedKeysRef.current!.has(key)) return;\n versionRef.current++;\n listener();\n });\n },\n [i18nStore]\n );\n const getSnapshot = useCallback(() => {\n return versionRef.current;\n }, []);\n\n useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n","import { getDictionaryListenerKey, getI18nConfig } from 'gt-i18n/internal';\nimport type {\n DictionaryLookup,\n DictionaryObjectSnapshot,\n StoreListener,\n} from '../../i18n-store/storeTypes';\nimport {\n useDictionariesSnapshot,\n useI18nStore,\n} from '../../i18n-store/useI18nStore';\nimport {\n type RefObject,\n useCallback,\n useRef,\n useSyncExternalStore,\n} from 'react';\nimport { useHandleMissingDictionaryObject } from '../utils/missing-translation';\n\nexport type TrackedDictionaryObjResolver = (\n lookup: DictionaryLookup\n) => DictionaryObjectSnapshot;\n\n// TODO: rename to useTrackedDictionaryObjectResolver\nexport function useTrackedDictionaryObjResolver(): TrackedDictionaryObjResolver {\n const dictionariesSnapshot = useDictionariesSnapshot();\n const i18nStore = useI18nStore();\n const devHotReloadEnabled = getI18nConfig().isDevHotReloadEnabled();\n const onMissingDictionaryObj = useHandleMissingDictionaryObject();\n\n const trackedKeysRef = useRef<Set<string> | null>(null);\n if (trackedKeysRef.current == null) {\n trackedKeysRef.current = new Set();\n }\n\n // subscribe to dictionary entry updates\n useSubscribeToLookups(trackedKeysRef);\n\n // Resolution callback\n return useCallback(\n (lookup: DictionaryLookup) => {\n // Track the lookup for dev hot reload\n const lookupKey = getDictionaryListenerKey(lookup);\n if (devHotReloadEnabled) {\n trackedKeysRef.current!.add(lookupKey);\n }\n\n // Resolve the dictionary entry from the store\n const dictionaryObject = i18nStore.getDictionaryObjectSnapshot(\n lookup,\n dictionariesSnapshot\n );\n\n // Hot reload\n if (dictionaryObject == null && devHotReloadEnabled) {\n onMissingDictionaryObj(lookup);\n }\n\n return dictionaryObject;\n },\n [\n i18nStore,\n dictionariesSnapshot,\n devHotReloadEnabled,\n onMissingDictionaryObj,\n ]\n );\n}\n\nfunction useSubscribeToLookups(trackedKeysRef: RefObject<Set<string> | null>) {\n // invalidation counter for triggering updates\n const versionRef = useRef(0);\n const i18nStore = useI18nStore();\n const subscribe = useCallback(\n (listener: StoreListener) => {\n return i18nStore.subscribeToDictionaryObjectEvents((lookup) => {\n const key = getDictionaryListenerKey(lookup);\n if (!trackedKeysRef.current!.has(key)) return;\n versionRef.current++;\n listener();\n });\n },\n [i18nStore]\n );\n const getSnapshot = useCallback(() => {\n return versionRef.current;\n }, []);\n\n useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n","import { useCallback, useMemo } from 'react';\nimport {\n extractVariables,\n renderDictionaryEntry,\n renderDictionaryObject,\n resolveDictionaryLookupOptions,\n} from 'gt-i18n/internal';\nimport { useLocale } from './condition-store';\nimport { useGT } from './useGT';\nimport type {\n DictionaryObjectTranslation,\n DictionaryTranslationOptions,\n} from 'gt-i18n/types';\nimport { useDefaultLocale } from './i18n-config';\nimport { useShouldTranslate } from './utils';\nimport { useTrackedDictionaryResolver } from './external-store/useTrackedDictionaryResolver';\nimport { useTrackedDictionaryObjResolver } from './external-store/useTrackedDictionaryObjResolver';\n\n// ===== Hook ===== //\n\nexport function useTranslations(rootId?: string): UseTranslationsFunction {\n const locale = useLocale();\n const defaultLocale = useDefaultLocale();\n const shouldTranslate = useShouldTranslate();\n const gt = useGT();\n const resolveDictionaryEntry = useTrackedDictionaryResolver();\n const translateObject = useTranslationsObj(rootId);\n\n const translateEntry = useCallback(\n (suffix: string, options: DictionaryTranslationOptions = {}) => {\n const id = getId(rootId, suffix);\n\n const sourceEntry = resolveDictionaryEntry({\n locale: defaultLocale,\n id,\n });\n if (sourceEntry === undefined) {\n throw new Error(`Dictionary entry ${id} cannot be found`);\n }\n const sourceOptions = resolveDictionaryLookupOptions(sourceEntry.options);\n if (!shouldTranslate) {\n return gt(sourceEntry.entry, {\n ...sourceOptions,\n ...extractVariables(options),\n $locale: defaultLocale,\n });\n }\n\n const targetEntry = resolveDictionaryEntry({ locale, id });\n if (targetEntry?.entry != null) {\n return renderDictionaryEntry({\n sourceLocale: defaultLocale,\n targetLocale: locale,\n sourceEntry,\n target: targetEntry.entry,\n dictionaryOptions: sourceOptions,\n options,\n });\n }\n\n return gt(sourceEntry.entry, {\n ...sourceOptions,\n ...extractVariables(options),\n $locale: locale,\n });\n },\n [defaultLocale, gt, rootId, locale, resolveDictionaryEntry, shouldTranslate]\n );\n\n return useMemo(\n () => Object.assign(translateEntry, { obj: translateObject }),\n [translateEntry, translateObject]\n );\n}\n\nfunction useTranslationsObj(rootId?: string): UseTranslationsObjFunction {\n const locale = useLocale();\n const defaultLocale = useDefaultLocale();\n const shouldTranslate = useShouldTranslate();\n const gt = useGT();\n const resolveDictionaryObject = useTrackedDictionaryObjResolver();\n\n return useCallback(\n (suffix: string) => {\n const entryId = getId(rootId, suffix);\n const sourceObject = resolveDictionaryObject({\n locale: defaultLocale,\n id: entryId,\n });\n if (sourceObject === undefined) {\n throw new Error(`Dictionary entry ${entryId} cannot be found`);\n }\n\n let targetObject = undefined;\n if (shouldTranslate) {\n const targetLookup = { locale, id: entryId };\n targetObject = resolveDictionaryObject(targetLookup);\n }\n\n return renderDictionaryObject({\n sourceObject,\n targetObject,\n translate: (sourceEntry, dictionaryOptions) =>\n gt(sourceEntry.entry, {\n ...dictionaryOptions,\n $locale: shouldTranslate ? locale : defaultLocale,\n }),\n });\n },\n [\n defaultLocale,\n rootId,\n locale,\n resolveDictionaryObject,\n shouldTranslate,\n gt,\n ]\n );\n}\n\n// ===== Lookup Helpers ===== //\n\nfunction getId(prefix: string | undefined, suffix: string): string {\n return prefix ? `${prefix}.${suffix}` : suffix;\n}\n\n// ===== Types ===== //\n\nexport type UseTranslationsFunction = ((\n id: string,\n options?: DictionaryTranslationOptions\n) => string) & {\n obj: (id: string) => DictionaryObjectTranslation;\n};\n\ntype UseTranslationsObjFunction = (id: string) => DictionaryObjectTranslation;\n","import { useCallback, useMemo } from 'react';\nimport { useCustomMapping, useLocales } from './i18n-config';\nimport { useLocale } from './condition-store';\nimport { getLocaleProperties } from 'generaltranslation';\n\nexport function useInternalLocaleSelector(locales?: string[]) {\n // Retrieve the locale, locales, and setLocale function\n const contextLocales = useLocales();\n const customMapping = useCustomMapping();\n const locale = useLocale();\n\n // sort\n const sortedLocales = useMemo(() => {\n if (!contextLocales || contextLocales.length === 0) {\n return [];\n }\n const collator = new Intl.Collator();\n return [...contextLocales].sort((a, b) =>\n collator.compare(\n getLocaleProperties(a, locale, customMapping).nativeNameWithRegionCode,\n getLocaleProperties(b, locale, customMapping).nativeNameWithRegionCode\n )\n );\n }, [contextLocales, locale, customMapping]);\n\n // create getLocaleProperties callback\n const getLocalePropertiesCallback = useCallback(\n (locale: string) => {\n return getLocaleProperties(locale, locale, customMapping);\n },\n [locale, customMapping]\n );\n\n return {\n locale,\n locales: locales ? locales : sortedLocales,\n getLocaleProperties: getLocalePropertiesCallback,\n };\n}\n","import { useMemo } from 'react';\nimport { useCustomMapping, useLocales } from './i18n-config';\nimport { useLocale, useRegion } from './condition-store';\nimport { getLocaleProperties } from 'generaltranslation';\nimport { getI18nConfig } from 'gt-i18n/internal';\n\nexport type RegionData = {\n code: string;\n name: string;\n emoji: string;\n locale: string;\n};\n\nexport type InternalRegionSelectorOptions = {\n regions?: string[];\n customMapping?: {\n [region: string]:\n | string\n | { name?: string; emoji?: string; locale?: string };\n };\n prioritizeCurrentLocaleRegion?: boolean;\n sortRegionsAlphabetically?: boolean;\n};\n\n/**\n * Internal logic for region selection in applications supporting multiple regions.\n *\n * Returns the current region, an ordered list of available regions (inferred\n * from the supported locales when not provided), and a map of region codes to\n * their display data (name, emoji, associated locale).\n */\nexport function useInternalRegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion = true,\n sortRegionsAlphabetically = true,\n}: InternalRegionSelectorOptions = {}) {\n // Retrieve the locale, locales, and region\n const contextLocales = useLocales();\n const localeCustomMapping = useCustomMapping();\n const locale = useLocale();\n const region = useRegion();\n const { regionCode: localeRegion } = getLocaleProperties(\n locale,\n locale,\n localeCustomMapping\n );\n\n const [\n regions, // ordered list of ISO 3166 region codes\n regionData, // map of ISO 3166 region codes to region display data, potentially not ordered\n ] = useMemo<[string[], Map<string, RegionData>]>(() => {\n const gt = getI18nConfig().getGTClass(locale);\n const regionToLocaleMap = new Map(\n contextLocales.map((l) => {\n const lp = getLocaleProperties(l, locale, localeCustomMapping); // has to be directly called so sourceLocale can be in the user's current locale\n return [lp.regionCode, lp];\n })\n );\n\n const regions = _regions\n ? [..._regions]\n : Array.from(regionToLocaleMap?.keys() || [localeRegion]);\n\n const regionData = new Map<string, RegionData>(\n regions.map((r: string) => {\n return [\n r,\n {\n locale: regionToLocaleMap?.get(r)?.code || locale,\n ...gt.getRegionProperties(r),\n ...(typeof customMapping?.[r] === 'string'\n ? { name: customMapping?.[r] }\n : customMapping?.[r]),\n },\n ];\n })\n );\n\n if (sortRegionsAlphabetically) {\n regions.sort((a, b) =>\n new Intl.Collator().compare(\n regionData.get(a)!.name,\n regionData.get(b)!.name\n )\n );\n }\n\n if (prioritizeCurrentLocaleRegion) {\n const localeRegionIndex = regions.indexOf(localeRegion);\n if (localeRegionIndex > 0) {\n // 0 because no action is needed if it's already at the start\n regions.splice(localeRegionIndex, 1);\n regions.unshift(localeRegion);\n }\n }\n\n return [regions, regionData];\n }, [\n _regions,\n customMapping,\n locale,\n localeRegion,\n contextLocales,\n localeCustomMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n ]);\n\n return {\n region,\n regions,\n regionData,\n locale,\n localeRegion,\n };\n}\n"],"mappings":"ymBAKA,SAAS,EAAe,EAAM,CAC7B,IAAM,EAAU,EAAK,MAAM,CAE3B,OADK,EACE,UAAU,KAAK,EAAQ,CAAG,EAAU,GAAG,EAAQ,GADjC,GAGtB,SAAS,EAAc,EAAM,CAC5B,IAAM,EAAU,EAAK,MAAM,CACvB,EAAM,EAAQ,OAClB,KAAO,EAAM,GAAG,CACf,IAAM,EAAO,EAAQ,EAAM,GAC3B,GAAI,IAAS,KAAO,IAAS,KAAO,IAAS,IAAK,MAClD,IAED,OAAO,EAAQ,MAAM,EAAG,EAAI,CAE7B,SAAS,EAAmB,EAAM,CACjC,OAAO,EAAK,QAAQ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