gt-react 10.19.16 → 10.19.18

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/dist/browser.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { LocaleConfig, formatCutoff, formatMessage, isValidLocale, requiresTranslation, resolveCanonicalLocale, standardizeLocale } from "@generaltranslation/format";
2
2
  import { GT } from "generaltranslation";
3
3
  import * as e from "react";
4
- import React, { Children, Suspense, cloneElement, isValidElement, use, useCallback, useMemo } from "react";
4
+ import t$1, { Children, Suspense, cloneElement, isValidElement, use, useMemo } from "react";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
6
  //#region \0rolldown/runtime.js
7
7
  var __defProp = Object.defineProperty;
@@ -31,26 +31,46 @@ var __copyProps = (to, from, except, desc) => {
31
31
  };
32
32
  var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
33
33
  //#endregion
34
- //#region src/shared/messages.ts
35
- const PACKAGE_NAME = "gt-react";
36
- const BROWSER_ENVIRONMENT_ERROR = `${PACKAGE_NAME}/browser Error: The ${PACKAGE_NAME}/browser module requires a browser environment`;
37
- const GENERIC_BROWSER_ENVIRONMENT_ERROR = `${PACKAGE_NAME} Error: You are trying to import a browser-only module into a non-browser environment.`;
38
- const BROWSER_I18N_MANAGER_NOT_INITIALIZED_ERROR = `${PACKAGE_NAME} Error: BrowserI18nManager not initialized. Invoke initializeGT() to initialize.`;
39
- const createTranslationFailedDueToBrowserEnvironmentWarning = (message) => `${PACKAGE_NAME} Warning: Translation failed for t("${typeof message === "string" ? message : "`" + message?.join("${}") + "`"}") because it was used outside of a browser environment. Falling back to original message.`;
40
- const createNoLocaleCouldBeDeterminedFromCustomGetLocaleWarning = ({ customLocale, defaultLocale }) => `${PACKAGE_NAME} Warning: Custom getLocale() function returned an unsupported locale: "${customLocale}". Falling back to default locale: "${defaultLocale}".`;
41
- const createInvalidLocaleWarning = (locale) => `${PACKAGE_NAME} Warning: Invalid locale: "${locale}".`;
42
- //#endregion
43
- //#region src/i18n-context/utils/enforceBrowser.ts
44
- /**
45
- * @internal
46
- *
47
- * Throws an error when imported outside of a browser environment.
48
- */
49
- function enforceBrowser(errorMessage = GENERIC_BROWSER_ENVIRONMENT_ERROR) {
50
- if (typeof window === "undefined") throw new Error(errorMessage);
34
+ //#region ../core/dist/base64-r7YWJYWt.mjs
35
+ function ensureSentence(text) {
36
+ const trimmed = text.trim();
37
+ if (!trimmed) return "";
38
+ return /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;
39
+ }
40
+ function stripSentence(text) {
41
+ const trimmed = text.trim();
42
+ let end = trimmed.length;
43
+ while (end > 0) {
44
+ const char = trimmed[end - 1];
45
+ if (char !== "." && char !== "!" && char !== "?") break;
46
+ end -= 1;
47
+ }
48
+ return trimmed.slice(0, end);
49
+ }
50
+ function lowercaseFirstWord(text) {
51
+ return text.replace(/^[A-Z][a-z]/, (match) => match.toLowerCase());
52
+ }
53
+ function formatDetails(details) {
54
+ if (!details) return "";
55
+ const detailText = Array.isArray(details) ? details.join(", ") : details;
56
+ if (!detailText.trim()) return "";
57
+ return ensureSentence(`Details: ${detailText}`);
58
+ }
59
+ function createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {
60
+ const prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : "";
61
+ const whatAndWhy = why ? `${stripSentence(whatHappened)} because ${lowercaseFirstWord(stripSentence(why))}` : whatHappened;
62
+ const shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));
63
+ const messageParts = [
64
+ whatAndWhy,
65
+ reassurance,
66
+ shouldCombineWayOut ? `${stripSentence(fix)}, or ${lowercaseFirstWord(stripSentence(wayOut))}` : fix,
67
+ shouldCombineWayOut ? void 0 : wayOut,
68
+ formatDetails(details)
69
+ ].filter((part) => !!part).map(ensureSentence);
70
+ if (docsUrl) messageParts.push(`Learn more: ${docsUrl}`);
71
+ const message = messageParts.join(" ");
72
+ return prefix ? `${prefix} ${message}` : message;
51
73
  }
52
- //#endregion
53
- //#region ../core/dist/base64-CWITCfhU.mjs
54
74
  const defaultCacheUrl = "https://cdn.gtx.dev";
55
75
  //#endregion
56
76
  //#region ../core/dist/isVariable-fAKEB7gF.mjs
@@ -4191,6 +4211,56 @@ function condenseVars(icuString) {
4191
4211
  }));
4192
4212
  }
4193
4213
  //#endregion
4214
+ //#region src/shared/messages.ts
4215
+ const PACKAGE_NAME = "gt-react";
4216
+ const BROWSER_ENVIRONMENT_ERROR = createDiagnosticMessage({
4217
+ source: `${PACKAGE_NAME}/browser`,
4218
+ severity: "Error",
4219
+ whatHappened: "This module requires a browser environment",
4220
+ fix: "Import it only from client-side code"
4221
+ });
4222
+ const GENERIC_BROWSER_ENVIRONMENT_ERROR = createDiagnosticMessage({
4223
+ source: PACKAGE_NAME,
4224
+ severity: "Error",
4225
+ whatHappened: "A browser-only module was imported outside the browser",
4226
+ fix: "Move this import to client-side code"
4227
+ });
4228
+ const BROWSER_I18N_MANAGER_NOT_INITIALIZED_ERROR = createDiagnosticMessage({
4229
+ source: PACKAGE_NAME,
4230
+ severity: "Error",
4231
+ whatHappened: "BrowserI18nManager is not initialized",
4232
+ fix: "Call initializeGT() before using browser translation APIs"
4233
+ });
4234
+ const createTranslationFailedDueToBrowserEnvironmentWarning = (message) => createDiagnosticMessage({
4235
+ source: PACKAGE_NAME,
4236
+ severity: "Warning",
4237
+ whatHappened: `t("${typeof message === "string" ? message : "`" + message?.join("${}") + "`"}") could not be translated because it ran outside the browser`,
4238
+ wayOut: "The original message will render as a fallback"
4239
+ });
4240
+ const createNoLocaleCouldBeDeterminedFromCustomGetLocaleWarning = ({ customLocale, defaultLocale }) => createDiagnosticMessage({
4241
+ source: PACKAGE_NAME,
4242
+ severity: "Warning",
4243
+ whatHappened: `Custom getLocale() returned unsupported locale "${customLocale}"`,
4244
+ wayOut: `Falling back to default locale "${defaultLocale}"`,
4245
+ fix: "Add the locale to your config if you want to support it"
4246
+ });
4247
+ const createInvalidLocaleWarning = (locale) => createDiagnosticMessage({
4248
+ source: PACKAGE_NAME,
4249
+ severity: "Warning",
4250
+ whatHappened: `Locale "${locale}" is not valid`,
4251
+ fix: "Use a valid BCP 47 locale code or add a custom mapping"
4252
+ });
4253
+ //#endregion
4254
+ //#region src/i18n-context/utils/enforceBrowser.ts
4255
+ /**
4256
+ * @internal
4257
+ *
4258
+ * Throws an error when imported outside of a browser environment.
4259
+ */
4260
+ function enforceBrowser(errorMessage = GENERIC_BROWSER_ENVIRONMENT_ERROR) {
4261
+ if (typeof window === "undefined") throw new Error(errorMessage);
4262
+ }
4263
+ //#endregion
4194
4264
  //#region ../i18n/dist/isEncodedTranslationOptions-BOwWa_-J.mjs
4195
4265
  var logger_default = {
4196
4266
  warn(message) {
@@ -4325,7 +4395,7 @@ function sanitizeJsxChildren(childrenAsObjects) {
4325
4395
  return Array.isArray(childrenAsObjects) ? childrenAsObjects.map(sanitizeChild) : sanitizeChild(childrenAsObjects);
4326
4396
  }
4327
4397
  //#endregion
4328
- //#region ../i18n/dist/versionId-B2xfz6jP.mjs
4398
+ //#region ../i18n/dist/versionId-BTjLA0FZ.mjs
4329
4399
  /**
4330
4400
  * Throw errors if there are any errors and log warnings if there are any warnings
4331
4401
  * @param {ValidationResult[]} results - The results to print
@@ -4371,9 +4441,9 @@ function getLoadTranslationsType(config) {
4371
4441
  * Requirements:
4372
4442
  * - REMOTE:
4373
4443
  * - GT_REMOTE:
4374
- * - projectId is required
4444
+ * - projectId is needed
4375
4445
  * - CUSTOM:
4376
- * - loadTranslations is required
4446
+ * - loadTranslations is needed
4377
4447
  * - DISABLED:
4378
4448
  * - no requirements
4379
4449
  */
@@ -4385,13 +4455,19 @@ function validateLoadTranslations(params) {
4385
4455
  case "gt-remote":
4386
4456
  if (!projectId) results.push({
4387
4457
  type: "warning",
4388
- message: "projectId is required when loading translations from a remote store"
4458
+ message: createDiagnosticMessage({
4459
+ whatHappened: "Loading translations from a remote store needs a projectId",
4460
+ fix: "Add projectId to the I18nManager config or disable remote translation loading"
4461
+ })
4389
4462
  });
4390
4463
  break;
4391
4464
  case "custom":
4392
4465
  if (!loadTranslations) results.push({
4393
4466
  type: "error",
4394
- message: "loadTranslations is required when loading translations from a custom loader"
4467
+ message: createDiagnosticMessage({
4468
+ whatHappened: "Custom translation loading needs loadTranslations",
4469
+ fix: "Provide a loadTranslations function or disable custom translation loading"
4470
+ })
4395
4471
  });
4396
4472
  break;
4397
4473
  case "disabled": break;
@@ -4404,8 +4480,9 @@ function validateLoadTranslations(params) {
4404
4480
  * @returns The runtime translation type
4405
4481
  */
4406
4482
  function getTranslationApiType(params) {
4407
- if ((params.runtimeUrl === void 0 || params.runtimeUrl === "https://runtime2.gtx.dev") && params.projectId && (params.devApiKey || params.apiKey)) return "gt";
4408
- else if (params.runtimeUrl) return "custom";
4483
+ const usesDefaultRuntimeUrl = params.runtimeUrl === void 0 || params.runtimeUrl === "https://runtime2.gtx.dev";
4484
+ if (usesDefaultRuntimeUrl && params.projectId && (params.devApiKey || params.apiKey)) return "gt";
4485
+ else if (params.runtimeUrl && !usesDefaultRuntimeUrl) return "custom";
4409
4486
  else return "disabled";
4410
4487
  }
4411
4488
  /**
@@ -4421,8 +4498,8 @@ function getTranslationApiType(params) {
4421
4498
  * Requirements:
4422
4499
  * - CUSTOM:
4423
4500
  * - GT:
4424
- * - projectId is required
4425
- * - devApiKey or apiKey is required
4501
+ * - projectId is needed
4502
+ * - devApiKey or apiKey is needed
4426
4503
  * - DISABLED:
4427
4504
  * - no requirements
4428
4505
  *
@@ -4435,11 +4512,17 @@ function validateTranslationApi(params) {
4435
4512
  case "gt":
4436
4513
  if (!params.projectId) results.push({
4437
4514
  type: "warning",
4438
- message: "projectId is required"
4515
+ message: createDiagnosticMessage({
4516
+ whatHappened: "Runtime translation needs a projectId",
4517
+ fix: "Add projectId to the I18nManager config or disable runtime translation"
4518
+ })
4439
4519
  });
4440
4520
  if (!params.devApiKey && !params.apiKey) results.push({
4441
4521
  type: "warning",
4442
- message: "devApiKey or apiKey is required"
4522
+ message: createDiagnosticMessage({
4523
+ whatHappened: "Runtime translation needs devApiKey or apiKey",
4524
+ fix: "Add credentials to the I18nManager config or disable runtime translation"
4525
+ })
4443
4526
  });
4444
4527
  break;
4445
4528
  case "disabled": break;
@@ -4468,7 +4551,10 @@ function validateLocales(params) {
4468
4551
  new Set([...defaultLocale ? [defaultLocale] : [], ...locales || []]).forEach((locale) => {
4469
4552
  if (!isValidLocale(locale, customMapping)) results.push({
4470
4553
  type: "error",
4471
- message: `Invalid locale: ${locale}`
4554
+ message: createDiagnosticMessage({
4555
+ whatHappened: `Locale "${locale}" is not valid`,
4556
+ fix: "Use a valid BCP 47 locale code or add a custom mapping"
4557
+ })
4472
4558
  });
4473
4559
  });
4474
4560
  return results;
@@ -4483,7 +4569,10 @@ function validateDictionary(params) {
4483
4569
  const results = [];
4484
4570
  if (params.loadDictionary && !params.dictionary) results.push({
4485
4571
  type: "error",
4486
- message: "dictionary is required when loadDictionary is provided"
4572
+ message: createDiagnosticMessage({
4573
+ whatHappened: "loadDictionary needs a source dictionary",
4574
+ fix: "Provide dictionary so the default locale has source content"
4575
+ })
4487
4576
  });
4488
4577
  return results;
4489
4578
  }
@@ -4572,83 +4661,269 @@ function routeCreateTranslationLoader({ type, remoteTranslationLoaderParams, loa
4572
4661
  case "disabled": return createFallbackTranslationLoader();
4573
4662
  }
4574
4663
  }
4575
- function isPlainObject(value) {
4576
- if (value == null || typeof value !== "object") return false;
4577
- const prototype = Object.getPrototypeOf(value);
4578
- return prototype === Object.prototype || prototype === null;
4664
+ function getDictionaryPath(id) {
4665
+ const path = id ? id.split(".") : [];
4666
+ for (const segment of path) assertSafeDictionaryPathSegment(segment, id);
4667
+ return path;
4668
+ }
4669
+ function assertSafeDictionaryPathSegment(segment, path) {
4670
+ if (segment === "__proto__" || segment === "constructor" || segment === "prototype") throw new Error(`Dictionary path "${path}" contains an unsafe segment`);
4579
4671
  }
4580
- function copyCacheValue(value) {
4581
- if (Array.isArray(value)) return [...value];
4582
- if (isPlainObject(value)) return { ...value };
4583
- return value;
4672
+ function isDictionaryObject(value) {
4673
+ return typeof value === "object" && value != null && !Array.isArray(value);
4674
+ }
4675
+ function cloneDictionaryValue(value) {
4676
+ if (value === void 0 || typeof value === "string") return value;
4677
+ return structuredClone(value);
4678
+ }
4679
+ function getDictionaryValueAtPath(dictionary, path) {
4680
+ let current = dictionary;
4681
+ for (const segment of getDictionaryPath(path)) {
4682
+ if (!isDictionaryObject(current)) return;
4683
+ current = current[segment];
4684
+ }
4685
+ return current;
4686
+ }
4687
+ function setDictionaryValueAtPath(dictionary, path, value) {
4688
+ const segments = getDictionaryPath(path);
4689
+ if (isDictionaryObject(value)) assertSafeDictionaryObject(value, path);
4690
+ if (segments.length === 0) {
4691
+ if (isDictionaryObject(value)) replaceDictionary(dictionary, value);
4692
+ return;
4693
+ }
4694
+ let current = dictionary;
4695
+ for (const segment of segments.slice(0, -1)) {
4696
+ const next = current[segment];
4697
+ if (!isDictionaryObject(next)) current[segment] = {};
4698
+ current = current[segment];
4699
+ }
4700
+ const leafSegment = segments[segments.length - 1];
4701
+ current[leafSegment] = value;
4702
+ }
4703
+ function getDictionaryEntry(value) {
4704
+ if (!isDictionaryLeafNode(value)) return;
4705
+ return {
4706
+ entry: Array.isArray(value) ? value[0] : value,
4707
+ options: Array.isArray(value) ? value[1] ?? {} : {}
4708
+ };
4709
+ }
4710
+ function getDictionaryValue(value) {
4711
+ if (Object.keys(value.options).length === 0) return value.entry;
4712
+ return [value.entry, value.options];
4713
+ }
4714
+ function resolveDictionaryLookupOptions(options) {
4715
+ const { $format, context, ...rest } = options;
4716
+ return {
4717
+ ...rest,
4718
+ $format: isStringFormat($format) ? $format : "ICU",
4719
+ ...rest.$context === void 0 && typeof context === "string" && { $context: context }
4720
+ };
4721
+ }
4722
+ function isDictionaryLeafNode(value) {
4723
+ if (typeof value === "string") return true;
4724
+ if (!Array.isArray(value) || typeof value[0] !== "string") return false;
4725
+ if (value.length === 1) return true;
4726
+ return value.length === 2 && isDictionaryOptions(value[1]);
4727
+ }
4728
+ function isDictionaryOptions(value) {
4729
+ if (typeof value !== "object" || value == null || Array.isArray(value)) return false;
4730
+ const options = value;
4731
+ return (options.$context === void 0 || typeof options.$context === "string") && (options.$format === void 0 || isStringFormat(options.$format)) && (options.$maxChars === void 0 || typeof options.$maxChars === "number") && (options.context === void 0 || typeof options.context === "string");
4732
+ }
4733
+ function isStringFormat(value) {
4734
+ return value === "ICU" || value === "I18NEXT" || value === "STRING";
4735
+ }
4736
+ function replaceDictionary(target, source) {
4737
+ for (const key of Object.keys(target)) delete target[key];
4738
+ for (const key of Object.keys(source)) target[key] = source[key];
4584
4739
  }
4740
+ function assertSafeDictionaryObject(dictionary, parentPath = "") {
4741
+ for (const [key, value] of Object.entries(dictionary)) {
4742
+ const path = parentPath ? `${parentPath}.${key}` : key;
4743
+ assertSafeDictionaryPathSegment(key, path);
4744
+ if (isDictionaryObject(value)) assertSafeDictionaryObject(value, path);
4745
+ }
4746
+ }
4747
+ var DictionarySourceNotFoundError = class extends Error {
4748
+ constructor(id) {
4749
+ super(`I18nManager: source dictionary entry ${id} is not defined`);
4750
+ this.name = "DictionarySourceNotFoundError";
4751
+ }
4752
+ };
4585
4753
  /**
4586
- * Cache class
4587
- * This is designed in such a way that it is the responsibility of the client
4588
- * to invoke the cache miss method when a cache miss occurs.
4589
- *
4590
- * TODO: maybe add "OutputValue" as a reflection of "InputKey"
4591
- */
4592
- var Cache = class {
4593
- /**
4594
- * Constructor
4595
- * @param {Object} params - The parameters for the cache
4596
- * @param {Record<CacheKey, CacheValue>} params.init - The initial cache
4597
- * @param {CacheLifecycle} [lifecycle] - Optional lifecycle callbacks
4598
- */
4599
- constructor(init, lifecycle) {
4600
- this.cache = {};
4601
- this.fallbackPromises = {};
4754
+ * Builds the dictionary value for a requested path by combining existing target
4755
+ * translations with runtime translations of any source leaves that are missing.
4756
+ */
4757
+ async function materializeDictionaryValue({ key, sourceValue, targetValue, translateEntry }) {
4758
+ if (getDictionaryEntry(targetValue) !== void 0) return cloneDictionaryValue(targetValue);
4759
+ if (isDictionaryObject(targetValue) && !isDictionaryObject(sourceValue)) return cloneDictionaryValue(targetValue);
4760
+ const sourceEntry = getDictionaryEntry(sourceValue);
4761
+ if (sourceEntry !== void 0) return await translateEntry(key, sourceEntry);
4762
+ if (!isDictionaryObject(sourceValue)) throw new DictionarySourceNotFoundError(key);
4763
+ const targetDictionary = isDictionaryObject(targetValue) ? targetValue : {};
4764
+ const keys = new Set([...Object.keys(sourceValue), ...Object.keys(targetDictionary)]);
4765
+ const entries = await Promise.all(Array.from(keys).map(async (childKey) => {
4766
+ const childPath = key ? `${key}.${childKey}` : childKey;
4767
+ assertSafeDictionaryPathSegment(childKey, childPath);
4768
+ const childSource = sourceValue[childKey];
4769
+ if (childSource === void 0) return [childKey, cloneDictionaryValue(targetDictionary[childKey])];
4770
+ return [childKey, await materializeDictionaryValue({
4771
+ key: childPath,
4772
+ sourceValue: childSource,
4773
+ targetValue: targetDictionary[childKey],
4774
+ translateEntry
4775
+ })];
4776
+ }));
4777
+ return Object.fromEntries(entries);
4778
+ }
4779
+ function cloneDictionaryEntry(entry) {
4780
+ return {
4781
+ entry: entry.entry,
4782
+ options: structuredClone(entry.options)
4783
+ };
4784
+ }
4785
+ var DictionaryCache = class {
4786
+ constructor({ init, lifecycle = {}, runtimeTranslate }) {
4787
+ this.pendingTranslations = /* @__PURE__ */ new Map();
4788
+ this.pendingMaterializations = /* @__PURE__ */ new Map();
4602
4789
  this.cache = structuredClone(init);
4603
- this.onHit = lifecycle?.onHit;
4604
- this.onMiss = lifecycle?.onMiss;
4790
+ this.runtimeTranslate = runtimeTranslate;
4791
+ this.lifecycle = lifecycle;
4605
4792
  }
4606
- /**
4607
- * Set the value for a key
4608
- */
4609
- setCache(cacheKey, value) {
4610
- this.cache[cacheKey] = value;
4793
+ getEntry(key) {
4794
+ const value = getDictionaryValueAtPath(this.cache, key);
4795
+ const entry = getDictionaryEntry(value);
4796
+ if (entry === void 0) return;
4797
+ const outputEntry = cloneDictionaryEntry(entry);
4798
+ this.lifecycle.onHit?.({
4799
+ inputKey: key,
4800
+ cacheKey: key,
4801
+ cacheValue: value,
4802
+ outputValue: outputEntry
4803
+ });
4804
+ return outputEntry;
4611
4805
  }
4612
- /**
4613
- * Look up the key
4614
- */
4615
- getCache(key) {
4616
- const cacheKey = this.genKey(key);
4617
- return this.cache[cacheKey];
4806
+ getValue(key) {
4807
+ const value = getDictionaryValueAtPath(this.cache, key);
4808
+ if (value === void 0) return;
4809
+ const outputValue = cloneDictionaryValue(value);
4810
+ this.lifecycle.onDictionaryObjectCacheHit?.({
4811
+ inputKey: key,
4812
+ cacheKey: key,
4813
+ cacheValue: value,
4814
+ outputValue
4815
+ });
4816
+ return outputValue;
4817
+ }
4818
+ setValue(key, value) {
4819
+ setDictionaryValueAtPath(this.cache, key, cloneDictionaryValue(value));
4618
4820
  }
4619
- /**
4620
- * Get the internal cache
4621
- * @returns The internal cache
4622
- *
4623
- * @internal - used by gt-tanstack-start
4624
- */
4625
4821
  getInternalCache() {
4626
- return Object.fromEntries(Object.entries(this.cache).map(([key, value]) => [key, copyCacheValue(value)]));
4822
+ return cloneDictionaryValue(this.cache);
4823
+ }
4824
+ async materializeValue(key, sourceValue, targetValue = getDictionaryValueAtPath(this.cache, key)) {
4825
+ let materializationPromise = this.pendingMaterializations.get(key);
4826
+ if (!materializationPromise) {
4827
+ materializationPromise = materializeDictionaryValue({
4828
+ key,
4829
+ sourceValue,
4830
+ targetValue,
4831
+ translateEntry: async (entryKey, sourceEntry) => getDictionaryValue(await this.materializeEntry(entryKey, sourceEntry))
4832
+ }).then((value) => {
4833
+ this.setValue(key, value);
4834
+ return value;
4835
+ });
4836
+ this.pendingMaterializations.set(key, materializationPromise);
4837
+ }
4838
+ try {
4839
+ return await materializationPromise;
4840
+ } finally {
4841
+ this.pendingMaterializations.delete(key);
4842
+ }
4627
4843
  }
4628
- /**
4629
- * Get the mutable cache for subclasses that need custom read/write behavior.
4630
- */
4631
- getMutableCache() {
4632
- return this.cache;
4844
+ async materializeEntry(key, sourceEntry) {
4845
+ let translationPromise = this.pendingTranslations.get(key);
4846
+ if (!translationPromise) {
4847
+ translationPromise = this.runtimeTranslate(key, sourceEntry).then((value) => {
4848
+ setDictionaryValueAtPath(this.cache, key, value);
4849
+ const entry = getDictionaryEntry(value);
4850
+ if (entry === void 0) throw new Error("DictionaryCache materializeEntry did not return a DictionaryEntry");
4851
+ this.lifecycle.onMiss?.({
4852
+ inputKey: key,
4853
+ cacheKey: key,
4854
+ cacheValue: value,
4855
+ outputValue: cloneDictionaryEntry(entry)
4856
+ });
4857
+ return cloneDictionaryEntry(entry);
4858
+ });
4859
+ this.pendingTranslations.set(key, translationPromise);
4860
+ }
4861
+ try {
4862
+ return cloneDictionaryEntry(await translationPromise);
4863
+ } finally {
4864
+ this.pendingTranslations.delete(key);
4865
+ }
4633
4866
  }
4634
- /**
4635
- * Fallback to the value from the fallback function on a cache miss
4636
- * @important assumes that the fallback error handling done upstream
4637
- */
4638
- async missCache(...args) {
4639
- const key = args[0];
4640
- const cacheKey = this.genKey(key);
4641
- if (this.fallbackPromises[cacheKey] !== void 0) return await this.fallbackPromises[cacheKey];
4642
- const fallbackPromise = this.fallback(...args);
4643
- this.fallbackPromises[cacheKey] = fallbackPromise;
4867
+ };
4868
+ var ResourceCache = class {
4869
+ constructor({ load, lifecycle = {}, ttl }) {
4870
+ this.cache = /* @__PURE__ */ new Map();
4871
+ this.pendingLoads = /* @__PURE__ */ new Map();
4872
+ this.loadResource = load;
4873
+ this.lifecycle = lifecycle;
4874
+ this.ttl = ttl === null ? -1 : ttl ?? 6e4;
4875
+ }
4876
+ get(key) {
4877
+ const entry = this.cache.get(key);
4878
+ if (!entry || this.isExpired(entry)) return;
4879
+ this.lifecycle.onHit?.({
4880
+ inputKey: key,
4881
+ cacheKey: key,
4882
+ cacheValue: entry,
4883
+ outputValue: entry.value
4884
+ });
4885
+ return entry.value;
4886
+ }
4887
+ set(key, value, { expiresAt = this.getExpiresAt() } = {}) {
4888
+ this.cache.set(key, {
4889
+ expiresAt,
4890
+ value
4891
+ });
4892
+ }
4893
+ async getOrLoad(key) {
4894
+ return this.get(key) ?? await this.load(key);
4895
+ }
4896
+ async load(key) {
4897
+ let loadPromise = this.pendingLoads.get(key);
4898
+ if (!loadPromise) {
4899
+ loadPromise = this.loadResource(key).then((value) => {
4900
+ const entry = {
4901
+ expiresAt: this.getExpiresAt(),
4902
+ value
4903
+ };
4904
+ this.cache.set(key, entry);
4905
+ this.lifecycle.onMiss?.({
4906
+ inputKey: key,
4907
+ cacheKey: key,
4908
+ cacheValue: entry,
4909
+ outputValue: entry.value
4910
+ });
4911
+ return entry;
4912
+ });
4913
+ this.pendingLoads.set(key, loadPromise);
4914
+ }
4644
4915
  try {
4645
- const value = await fallbackPromise;
4646
- this.setCache(cacheKey, value);
4647
- return value;
4916
+ return (await loadPromise).value;
4648
4917
  } finally {
4649
- delete this.fallbackPromises[cacheKey];
4918
+ this.pendingLoads.delete(key);
4650
4919
  }
4651
4920
  }
4921
+ getExpiresAt() {
4922
+ return this.ttl < 0 ? this.ttl : Date.now() + this.ttl;
4923
+ }
4924
+ isExpired(entry) {
4925
+ return entry.expiresAt > 0 && entry.expiresAt < Date.now();
4926
+ }
4652
4927
  };
4653
4928
  /**
4654
4929
  * Hash a message string
@@ -4693,20 +4968,22 @@ function normalizeBatchConfig(batchConfig) {
4693
4968
  * Locale logic is handled at the LocalesCache level. Use a callback function that has the
4694
4969
  * locale parameter embedded if you wish to use the locale code.
4695
4970
  */
4696
- var TranslationsCache = class extends Cache {
4971
+ var TranslationsCache = class {
4697
4972
  /**
4698
4973
  * Constructor
4699
4974
  * @param {Object} params - The parameters for the cache
4700
4975
  * @param {Record<Hash, TranslationValue>} params.init - The initial cache
4701
4976
  * @param {Function} params.fallback - Get the fallback value for a cache miss
4702
4977
  */
4703
- constructor({ init, translateMany, lifecycle, batchConfig }) {
4704
- super(init, lifecycle);
4705
- this._queue = [];
4706
- this._batchTimer = null;
4707
- this._activeRequests = 0;
4708
- this._translateMany = translateMany;
4709
- this._batchConfig = normalizeBatchConfig(batchConfig);
4978
+ constructor({ init, translateMany, lifecycle = {}, batchConfig }) {
4979
+ this.pendingTranslations = /* @__PURE__ */ new Map();
4980
+ this.queue = [];
4981
+ this.batchTimer = null;
4982
+ this.activeRequests = 0;
4983
+ this.cache = structuredClone(init);
4984
+ this.translateMany = translateMany;
4985
+ this.batchConfig = normalizeBatchConfig(batchConfig);
4986
+ this.lifecycle = lifecycle;
4710
4987
  }
4711
4988
  /**
4712
4989
  * Get the translation value for a given key
@@ -4714,10 +4991,11 @@ var TranslationsCache = class extends Cache {
4714
4991
  * @returns The translation value
4715
4992
  */
4716
4993
  get(key) {
4717
- const value = this.getCache(key);
4718
- if (value != null && this.onHit) this.onHit({
4994
+ const cacheKey = this.getCacheKey(key);
4995
+ const value = this.cache[cacheKey];
4996
+ if (value != null) this.lifecycle.onHit?.({
4719
4997
  inputKey: key,
4720
- cacheKey: this.genKey(key),
4998
+ cacheKey,
4721
4999
  cacheValue: value,
4722
5000
  outputValue: value
4723
5001
  });
@@ -4729,75 +5007,64 @@ var TranslationsCache = class extends Cache {
4729
5007
  * @returns The translation value
4730
5008
  */
4731
5009
  async miss(key) {
4732
- const value = await this.missCache(key);
4733
- if (value != null && this.onMiss) this.onMiss({
4734
- inputKey: key,
4735
- cacheKey: this.genKey(key),
4736
- cacheValue: value,
4737
- outputValue: value
4738
- });
4739
- return value;
5010
+ const cacheKey = this.getCacheKey(key);
5011
+ let translationPromise = this.pendingTranslations.get(cacheKey);
5012
+ if (!translationPromise) {
5013
+ translationPromise = this.translate(key);
5014
+ this.pendingTranslations.set(cacheKey, translationPromise);
5015
+ }
5016
+ try {
5017
+ const value = await translationPromise;
5018
+ if (value != null) this.lifecycle.onMiss?.({
5019
+ inputKey: key,
5020
+ cacheKey,
5021
+ cacheValue: value,
5022
+ outputValue: value
5023
+ });
5024
+ return value;
5025
+ } finally {
5026
+ this.pendingTranslations.delete(cacheKey);
5027
+ }
4740
5028
  }
4741
- /**
4742
- * Generate a key for the cache
4743
- * @param key - The translation key
4744
- * @returns The key
4745
- */
4746
- genKey(key) {
5029
+ getInternalCache() {
5030
+ return structuredClone(this.cache);
5031
+ }
5032
+ getCacheKey(key) {
4747
5033
  return hashMessage(key.message, key.options);
4748
5034
  }
4749
- /**
4750
- * Get the fallback value for a cache miss
4751
- * @param key - The translation key
4752
- * @returns The fallback value
4753
- */
4754
- fallback(key) {
4755
- const translationPromise = this._enqueueTranslation(key);
4756
- if (this._queue.length >= this._batchConfig.maxBatchSize) this._flushNow();
4757
- else this._scheduleBatch();
5035
+ translate(key) {
5036
+ const translationPromise = this.enqueueTranslation(key);
5037
+ if (this.queue.length >= this.batchConfig.maxBatchSize) this.flushNow();
5038
+ else this.scheduleBatch();
4758
5039
  return translationPromise;
4759
5040
  }
4760
- /**
4761
- * Flush the queue now
4762
- */
4763
- _flushNow() {
4764
- if (this._batchTimer) {
4765
- clearTimeout(this._batchTimer);
4766
- this._batchTimer = null;
5041
+ flushNow() {
5042
+ if (this.batchTimer) {
5043
+ clearTimeout(this.batchTimer);
5044
+ this.batchTimer = null;
4767
5045
  }
4768
- this._drainQueue();
4769
- }
4770
- /**
4771
- * Schedule a batch of translations
4772
- */
4773
- _scheduleBatch() {
4774
- if (this._batchTimer) return;
4775
- this._batchTimer = setTimeout(() => {
4776
- this._batchTimer = null;
4777
- this._drainQueue();
4778
- }, this._batchConfig.batchInterval);
4779
- }
4780
- /**
4781
- * Drain the queue
4782
- */
4783
- _drainQueue() {
4784
- while (this._queue.length > 0 && this._activeRequests < this._batchConfig.maxConcurrentRequests) {
4785
- const batch = this._queue.splice(0, this._batchConfig.maxBatchSize);
4786
- this._sendBatchRequest(batch);
5046
+ this.drainQueue();
5047
+ }
5048
+ scheduleBatch() {
5049
+ if (this.batchTimer) return;
5050
+ this.batchTimer = setTimeout(() => {
5051
+ this.batchTimer = null;
5052
+ this.drainQueue();
5053
+ }, this.batchConfig.batchInterval);
5054
+ }
5055
+ drainQueue() {
5056
+ while (this.queue.length > 0 && this.activeRequests < this.batchConfig.maxConcurrentRequests) {
5057
+ const batch = this.queue.splice(0, this.batchConfig.maxBatchSize);
5058
+ this.sendBatchRequest(batch);
4787
5059
  }
4788
- if (this._queue.length > 0) this._scheduleBatch();
5060
+ if (this.queue.length > 0) this.scheduleBatch();
4789
5061
  }
4790
- /**
4791
- * Enqueue translation request and return a promise that resolves when the translation is ready
4792
- * @param {TranslationKey<TranslationValue>} key - The translation key
4793
- * @returns {Promise<TranslationValue>} The translation promise
4794
- */
4795
- _enqueueTranslation(key) {
4796
- const hash = this.genKey(key);
5062
+ enqueueTranslation(key) {
5063
+ const hash = this.getCacheKey(key);
4797
5064
  const options = key.options;
4798
5065
  const metadataOptions = options;
4799
5066
  return new Promise((resolve, reject) => {
4800
- this._queue.push({
5067
+ this.queue.push({
4801
5068
  key: hash,
4802
5069
  source: key.message,
4803
5070
  metadata: {
@@ -4812,38 +5079,28 @@ var TranslationsCache = class extends Cache {
4812
5079
  });
4813
5080
  });
4814
5081
  }
4815
- /**
4816
- * Send a batch request for translations
4817
- * @param {QueueEntry<TranslationValue>[]} batch - The batch of requests to send
4818
- */
4819
- async _sendBatchRequest(batch) {
4820
- this._activeRequests++;
5082
+ async sendBatchRequest(batch) {
5083
+ this.activeRequests++;
4821
5084
  const requests = convertBatchToTranslateManyParams(batch);
4822
- const response = await this._sendBatchRequestWithErrorHandling(batch, requests);
4823
- if (response) this._handleTranslationResponse(batch, response);
4824
- this._activeRequests--;
5085
+ const response = await this.sendBatchRequestWithErrorHandling(batch, requests);
5086
+ if (response) this.handleTranslationResponse(batch, response);
5087
+ this.activeRequests--;
4825
5088
  }
4826
- /**
4827
- * Send a translation request with error handling
4828
- */
4829
- async _sendBatchRequestWithErrorHandling(batch, requests) {
5089
+ async sendBatchRequestWithErrorHandling(batch, requests) {
4830
5090
  try {
4831
- return await this._translateMany(requests);
5091
+ return await this.translateMany(requests);
4832
5092
  } catch (error) {
4833
5093
  for (const entry of batch) entry.reject(error);
4834
5094
  return;
4835
5095
  }
4836
5096
  }
4837
- /**
4838
- * Handle a translation response
4839
- */
4840
- _handleTranslationResponse(batch, response) {
5097
+ handleTranslationResponse(batch, response) {
4841
5098
  for (const entry of batch) {
4842
5099
  const { key } = entry;
4843
5100
  const result = response[key];
4844
5101
  if (result && result.success) {
4845
5102
  const translation = result.translation;
4846
- this.setCache(key, translation);
5103
+ this.cache[key] = translation;
4847
5104
  entry.resolve(translation);
4848
5105
  } else entry.reject(result?.error);
4849
5106
  }
@@ -4861,415 +5118,87 @@ function convertBatchToTranslateManyParams(batch) {
4861
5118
  return acc;
4862
5119
  }, {});
4863
5120
  }
4864
- /**
4865
- * Default cache expiry time in milliseconds
4866
- */
4867
- const DEFAULT_CACHE_EXPIRY_TIME = 6e4;
4868
- /**
4869
- * Cache for looking up translations by locale
4870
- */
4871
- var LocalesCache = class extends Cache {
4872
- /**
4873
- * Constructor
4874
- * @param {Object} params - The parameters for the cache
4875
- * @param {Record<string, CacheEntry<TranslationValue>>} params.init - The initial cache
4876
- * @param {number | null} params.ttl - The time to live for cache entries
4877
- * @param {SafeTranslationsLoader<TranslationValue>} params.loadTranslations - The translation loader function
4878
- * @param {CreateTranslateMany} params.createTranslateMany - Factory function for creating a translate many function
4879
- */
4880
- constructor({ init = {}, ttl, batchConfig, loadTranslations, createTranslateMany, lifecycle: { onLocalesCacheHit: onHit, onLocalesCacheMiss: onMiss, onTranslationsCacheHit, onTranslationsCacheMiss } }) {
4881
- super(init, {
4882
- onHit,
4883
- onMiss
5121
+ var LocalesCache = class {
5122
+ constructor({ ttl, batchConfig, defaultLocale, dictionary = {}, loadTranslations, loadDictionary, createTranslateMany, translateDictionaryEntry, lifecycle }) {
5123
+ this.translations = new ResourceCache({
5124
+ ttl,
5125
+ load: async (locale) => new TranslationsCache({
5126
+ init: await loadTranslations(locale),
5127
+ lifecycle: createTranslationsCacheLifecycle(locale, lifecycle),
5128
+ translateMany: createTranslateMany(locale),
5129
+ batchConfig
5130
+ }),
5131
+ lifecycle: {
5132
+ onHit: lifecycle.onLocalesCacheHit,
5133
+ onMiss: lifecycle.onLocalesCacheMiss
5134
+ }
4884
5135
  });
4885
- this.ttl = DEFAULT_CACHE_EXPIRY_TIME;
4886
- this.ttl = ttl === null ? -1 : ttl ?? 6e4;
4887
- this._translationLoader = loadTranslations;
4888
- this._createTranslateMany = createTranslateMany;
4889
- this._batchConfig = batchConfig;
4890
- this._onTranslationsCacheHit = onTranslationsCacheHit;
4891
- this._onTranslationsCacheMiss = onTranslationsCacheMiss;
4892
- }
4893
- /**
4894
- * Get the translations for a given locale
4895
- * @param key - The locale
4896
- * @returns The translations
4897
- */
4898
- get(key) {
4899
- const entry = this.getCache(key);
4900
- if (!entry || entry.expiresAt > 0 && entry.expiresAt < Date.now()) return;
4901
- const value = entry.translationsCache;
4902
- if (value != null && this.onHit) this.onHit({
4903
- inputKey: key,
4904
- cacheKey: this.genKey(key),
4905
- cacheValue: entry,
4906
- outputValue: value
5136
+ this.dictionaries = new ResourceCache({
5137
+ ttl,
5138
+ load: async (locale) => createDictionaryCache({
5139
+ locale,
5140
+ dictionary: await loadDictionary(locale),
5141
+ translate: translateDictionaryEntry,
5142
+ lifecycle
5143
+ }),
5144
+ lifecycle: {
5145
+ onHit: lifecycle.onLocalesDictionaryCacheHit,
5146
+ onMiss: lifecycle.onLocalesDictionaryCacheMiss
5147
+ }
4907
5148
  });
4908
- return value;
5149
+ this.dictionaries.set(defaultLocale, createDictionaryCache({
5150
+ locale: defaultLocale,
5151
+ dictionary,
5152
+ translate: translateDictionaryEntry,
5153
+ lifecycle
5154
+ }), { expiresAt: -1 });
4909
5155
  }
4910
- /**
4911
- * Miss the cache
4912
- * @param key - The locale
4913
- * @returns The translations cache
4914
- */
4915
- async miss(key) {
4916
- const cacheValue = await this.missCache(key);
4917
- const value = cacheValue.translationsCache;
4918
- if (value != null && this.onMiss) this.onMiss({
4919
- inputKey: key,
4920
- cacheKey: this.genKey(key),
4921
- cacheValue,
4922
- outputValue: value
4923
- });
4924
- return value;
5156
+ getTranslations(locale) {
5157
+ return this.translations.get(locale);
4925
5158
  }
4926
- /**
4927
- * Generate the cache key for a given locale
4928
- * @param key - The locale
4929
- * @returns The cache key
4930
- *
4931
- * This is just an identity function, no transformation needed
4932
- */
4933
- genKey(key) {
4934
- return key;
5159
+ getOrLoadTranslations(locale) {
5160
+ return this.translations.getOrLoad(locale);
4935
5161
  }
4936
- /**
4937
- * Fallback for a cache miss
4938
- * @param locale - The locale
4939
- * @returns The cache entry
4940
- */
4941
- async fallback(locale) {
4942
- return {
4943
- translationsCache: new TranslationsCache({
4944
- init: await this._translationLoader(locale),
4945
- lifecycle: this._createTranslationsCacheLifecycle(locale),
4946
- translateMany: this._createTranslateMany(locale),
4947
- batchConfig: this._batchConfig
4948
- }),
4949
- expiresAt: this.ttl < 0 ? this.ttl : Date.now() + this.ttl
4950
- };
5162
+ getDictionary(locale) {
5163
+ return this.dictionaries.get(locale);
4951
5164
  }
4952
- /**
4953
- * Create the translations cache lifecycle
4954
- * @param locale - The locale
4955
- * @returns The translations cache lifecycle
4956
- */
4957
- _createTranslationsCacheLifecycle(locale) {
4958
- return {
4959
- onHit: this._onTranslationsCacheHit ? (params) => this._onTranslationsCacheHit({
4960
- locale,
4961
- ...params
4962
- }) : void 0,
4963
- onMiss: this._onTranslationsCacheMiss ? (params) => this._onTranslationsCacheMiss({
4964
- locale,
4965
- ...params
4966
- }) : void 0
4967
- };
5165
+ getOrLoadDictionary(locale) {
5166
+ return this.dictionaries.getOrLoad(locale);
4968
5167
  }
4969
5168
  };
4970
- function getDictionaryPath(id) {
4971
- if (!id) return [];
4972
- return id.split(".");
4973
- }
4974
- function isDictionaryValue(value) {
4975
- return typeof value === "object" && value != null && !Array.isArray(value);
4976
- }
4977
- function getDictionaryEntry(value) {
4978
- if (!isDictionaryLeafNode(value)) return;
5169
+ function createTranslationsCacheLifecycle(locale, lifecycle) {
4979
5170
  return {
4980
- entry: Array.isArray(value) ? value[0] : value,
4981
- options: Array.isArray(value) ? value[1] ?? {} : {}
4982
- };
4983
- }
4984
- function getDictionaryValue(value) {
4985
- if (Object.keys(value.options).length === 0) return value.entry;
4986
- return [value.entry, value.options];
4987
- }
4988
- function resolveDictionaryLookupOptions(options) {
4989
- const { $format, ...rest } = options;
4990
- return {
4991
- ...rest,
4992
- $format: isStringFormat($format) ? $format : "ICU",
4993
- ...rest.$context === void 0 && typeof rest.context === "string" && { $context: rest.context }
5171
+ onHit: withLocale(locale, lifecycle.onTranslationsCacheHit),
5172
+ onMiss: withLocale(locale, lifecycle.onTranslationsCacheMiss)
4994
5173
  };
4995
5174
  }
4996
- function isDictionaryLeafNode(value) {
4997
- if (typeof value === "string") return true;
4998
- if (!Array.isArray(value) || typeof value[0] !== "string") return false;
4999
- if (value.length === 1) return true;
5000
- return value.length === 2 && isDictionaryOptions(value[1]);
5001
- }
5002
- function isDictionaryOptions(value) {
5003
- if (typeof value !== "object" || value == null || Array.isArray(value)) return false;
5004
- const options = value;
5005
- return (options.$context === void 0 || typeof options.$context === "string") && (options.$format === void 0 || isStringFormat(options.$format)) && (options.$maxChars === void 0 || typeof options.$maxChars === "number") && (options.context === void 0 || typeof options.context === "string");
5006
- }
5007
- function isStringFormat(value) {
5008
- return value === "ICU" || value === "I18NEXT" || value === "STRING";
5175
+ function createDictionaryCache({ locale, dictionary, translate, lifecycle }) {
5176
+ const { onDictionaryCacheHit, onDictionaryCacheMiss, onDictionaryObjectCacheHit } = lifecycle;
5177
+ return new DictionaryCache({
5178
+ init: dictionary,
5179
+ runtimeTranslate: (key, sourceEntry) => translate(locale, key, sourceEntry),
5180
+ lifecycle: {
5181
+ onHit: withLocale(locale, onDictionaryCacheHit),
5182
+ onMiss: withLocale(locale, onDictionaryCacheMiss),
5183
+ onDictionaryObjectCacheHit: withLocale(locale, onDictionaryObjectCacheHit)
5184
+ }
5185
+ });
5009
5186
  }
5010
- function replaceDictionary(target, source) {
5011
- for (const key of Object.keys(target)) delete target[key];
5012
- Object.assign(target, source);
5187
+ function withLocale(locale, callback) {
5188
+ return callback ? (params) => callback({
5189
+ locale,
5190
+ ...params
5191
+ }) : void 0;
5013
5192
  }
5014
- var DictionarySourceNotFoundError = class extends Error {
5015
- constructor(id) {
5016
- super(`I18nManager: source dictionary entry ${id} is not defined`);
5017
- this.name = "DictionarySourceNotFoundError";
5018
- }
5019
- };
5020
- /**
5021
- * A cache for a single locale's dictionary
5022
- *
5023
- * Principles:
5024
- * - This class is language agnostic, and should never store the locale code as a parameter.
5025
- * Locale logic is handled at the LocalesDictionaryCache level. Use a callback function
5026
- * that has the locale parameter embedded if you wish to use the locale code.
5027
- */
5028
- var DictionaryCache = class extends Cache {
5029
- /**
5030
- * Constructor
5031
- * @param {Object} params - The parameters for the cache
5032
- * @param {Dictionary} params.init - The initial cache
5033
- */
5034
- constructor({ init, lifecycle, runtimeTranslate }) {
5035
- super(init, lifecycle);
5036
- this._runtimeTranslate = runtimeTranslate;
5037
- this.onHitObj = lifecycle?.onHitObj;
5038
- this.onMissObj = lifecycle?.onMissObj;
5039
- }
5040
- /**
5041
- * Get the dictionary value for a given key
5042
- * @param key - The dictionary key
5043
- * @returns The dictionary value
5044
- */
5045
- get(key) {
5046
- const value = this.getCache(key);
5047
- const entry = getDictionaryEntry(value);
5048
- if (entry === void 0) return;
5049
- if (this.onHit) this.onHit({
5050
- inputKey: key,
5051
- cacheKey: this.genKey(key),
5052
- cacheValue: value,
5053
- outputValue: entry
5054
- });
5055
- return entry;
5056
- }
5057
- set(key, value) {
5058
- const dictionaryValue = getDictionaryValue(value);
5059
- this.setCache(this.genKey(key), dictionaryValue);
5060
- }
5061
- getObj(key) {
5062
- const value = this.getCache(key);
5063
- if (value === void 0) return;
5064
- const outputValue = structuredClone(value);
5065
- if (this.onHitObj) this.onHitObj({
5066
- inputKey: key,
5067
- cacheKey: this.genKey(key),
5068
- cacheValue: value,
5069
- outputValue
5070
- });
5071
- return outputValue;
5072
- }
5073
- setObj(key, value) {
5074
- this.setCache(this.genKey(key), structuredClone(value));
5075
- }
5076
- async missObj(key, sourceObject) {
5077
- const sourceEntry = getDictionaryEntry(sourceObject);
5078
- if (sourceEntry !== void 0) return getDictionaryValue(await this.miss(key, sourceEntry));
5079
- if (!isDictionaryValue(sourceObject)) throw new DictionarySourceNotFoundError(key);
5080
- const translatedEntries = await Promise.all(Object.entries(sourceObject).map(async ([childKey, childSource]) => {
5081
- const childPath = key ? `${key}.${childKey}` : childKey;
5082
- return [childKey, await this.missObj(childPath, childSource)];
5083
- }));
5084
- const translatedObject = Object.fromEntries(translatedEntries);
5085
- this.setObj(key, translatedObject);
5086
- return translatedObject;
5087
- }
5088
- /**
5089
- * Miss the cache
5090
- * @param key - The dictionary key
5091
- * @returns The dictionary value
5092
- */
5093
- async miss(key, sourceEntry) {
5094
- const value = await this.missCache(key, sourceEntry);
5095
- const entry = getDictionaryEntry(value);
5096
- if (entry === void 0) throw new Error("DictionaryCache missCache did not return a DictionaryEntry");
5097
- if (this.onMiss) this.onMiss({
5098
- inputKey: key,
5099
- cacheKey: this.genKey(key),
5100
- cacheValue: value,
5101
- outputValue: entry
5102
- });
5103
- return entry;
5104
- }
5105
- /**
5106
- * Set the value for a key
5107
- */
5108
- setCache(cacheKey, value) {
5109
- const cache = this.getMutableCache();
5110
- const dictionaryPath = getDictionaryPath(cacheKey);
5111
- if (dictionaryPath.length === 0) {
5112
- if (isDictionaryValue(value)) replaceDictionary(cache, value);
5113
- return;
5114
- }
5115
- let current = cache;
5116
- for (const key of dictionaryPath.slice(0, -1)) {
5117
- const next = current[key];
5118
- if (!isDictionaryValue(next)) current[key] = {};
5119
- current = current[key];
5120
- }
5121
- current[dictionaryPath[dictionaryPath.length - 1]] = value;
5122
- }
5123
- /**
5124
- * Look up the key
5125
- */
5126
- getCache(key) {
5127
- const dictionaryPath = getDictionaryPath(this.genKey(key));
5128
- let current = this.getMutableCache();
5129
- if (dictionaryPath.length === 0) return current;
5130
- for (const pathSegment of dictionaryPath) {
5131
- if (!isDictionaryValue(current)) return;
5132
- current = current[pathSegment];
5133
- }
5134
- return current;
5135
- }
5136
- /**
5137
- * Generate a key for the cache
5138
- * @param key - The dictionary key
5139
- * @returns The key
5140
- */
5141
- genKey(key) {
5142
- return key;
5143
- }
5144
- /**
5145
- * Get the fallback value for a cache miss
5146
- * @param key - The dictionary key
5147
- * @returns The fallback value
5148
- *
5149
- * @throws {Error} - If the fallback is not implemented
5150
- */
5151
- fallback(key, sourceEntry) {
5152
- return this._runtimeTranslate(key, sourceEntry);
5153
- }
5154
- };
5155
- /**
5156
- * Cache for looking up dictionaries by locale
5157
- */
5158
- var LocalesDictionaryCache = class extends Cache {
5159
- /**
5160
- * Constructor
5161
- * @param {Object} params - The parameters for the cache
5162
- * @param {number | null} params.ttl - The time to live for cache entries
5163
- * @param {DictionaryLoader} params.loadDictionary - The dictionary loader function
5164
- */
5165
- constructor({ ttl, defaultLocale, dictionary = {}, loadDictionary, runtimeTranslate, lifecycle: { onLocalesDictionaryCacheHit: onHit, onLocalesDictionaryCacheMiss: onMiss, onDictionaryCacheHit, onDictionaryCacheMiss, onDictionaryObjectCacheHit } }) {
5166
- super({}, {
5167
- onHit,
5168
- onMiss
5169
- });
5170
- this.ttl = DEFAULT_CACHE_EXPIRY_TIME;
5171
- this.ttl = ttl === null ? -1 : ttl ?? 6e4;
5172
- this._dictionaryLoader = loadDictionary;
5173
- this._runtimeTranslate = runtimeTranslate;
5174
- this._onDictionaryCacheHit = onDictionaryCacheHit;
5175
- this._onDictionaryCacheMiss = onDictionaryCacheMiss;
5176
- this._onDictionaryObjectCacheHit = onDictionaryObjectCacheHit;
5177
- this.setCache(defaultLocale, {
5178
- dictionaryCache: new DictionaryCache({
5179
- init: dictionary,
5180
- runtimeTranslate: this._createDictionaryRuntimeTranslate(defaultLocale),
5181
- lifecycle: this._createDictionaryCacheLifecycle(defaultLocale)
5182
- }),
5183
- expiresAt: -1
5184
- });
5185
- }
5186
- /**
5187
- * Get the dictionary for a given locale
5188
- * @param key - The locale
5189
- * @returns The dictionary
5190
- */
5191
- get(key) {
5192
- const entry = this.getCache(key);
5193
- if (!entry || entry.expiresAt > 0 && entry.expiresAt < Date.now()) return;
5194
- const value = entry.dictionaryCache;
5195
- if (value != null && this.onHit) this.onHit({
5196
- inputKey: key,
5197
- cacheKey: this.genKey(key),
5198
- cacheValue: entry,
5199
- outputValue: value
5200
- });
5201
- return value;
5202
- }
5203
- /**
5204
- * Miss the cache
5205
- * @param key - The locale
5206
- * @returns The dictionary cache
5207
- */
5208
- async miss(key) {
5209
- const cacheValue = await this.missCache(key);
5210
- const value = cacheValue.dictionaryCache;
5211
- if (value != null && this.onMiss) this.onMiss({
5212
- inputKey: key,
5213
- cacheKey: this.genKey(key),
5214
- cacheValue,
5215
- outputValue: value
5216
- });
5217
- return value;
5218
- }
5219
- /**
5220
- * Generate the cache key for a given locale
5221
- * @param key - The locale
5222
- * @returns The cache key
5223
- *
5224
- * This is just an identity function, no transformation needed
5225
- */
5226
- genKey(key) {
5227
- return key;
5228
- }
5229
- /**
5230
- * Fallback for a cache miss
5231
- * @param locale - The locale
5232
- * @returns The cache entry
5233
- */
5234
- async fallback(locale) {
5235
- return {
5236
- dictionaryCache: new DictionaryCache({
5237
- init: await this._dictionaryLoader(locale),
5238
- runtimeTranslate: this._createDictionaryRuntimeTranslate(locale),
5239
- lifecycle: this._createDictionaryCacheLifecycle(locale)
5240
- }),
5241
- expiresAt: this.ttl < 0 ? this.ttl : Date.now() + this.ttl
5242
- };
5243
- }
5244
- /**
5245
- * Create the dictionary cache lifecycle
5246
- * @param locale - The locale
5247
- * @returns The dictionary cache lifecycle
5248
- */
5249
- _createDictionaryCacheLifecycle(locale) {
5250
- return {
5251
- onHit: this._onDictionaryCacheHit ? (params) => this._onDictionaryCacheHit({
5252
- locale,
5253
- ...params
5254
- }) : void 0,
5255
- onMiss: this._onDictionaryCacheMiss ? (params) => this._onDictionaryCacheMiss({
5256
- locale,
5257
- ...params
5258
- }) : void 0,
5259
- onHitObj: this._onDictionaryObjectCacheHit ? (params) => this._onDictionaryObjectCacheHit({
5260
- locale,
5261
- ...params
5262
- }) : void 0
5263
- };
5264
- }
5265
- _createDictionaryRuntimeTranslate(locale) {
5266
- return (key, sourceEntry) => this._runtimeTranslate(locale, key, sourceEntry);
5267
- }
5268
- };
5193
+ const LOCALES_CACHE_HIT_EVENT_NAME = "locales-cache-hit";
5269
5194
  const LOCALES_CACHE_MISS_EVENT_NAME = "locales-cache-miss";
5195
+ const TRANSLATIONS_CACHE_HIT_EVENT_NAME = "translations-cache-hit";
5270
5196
  const TRANSLATIONS_CACHE_MISS_EVENT_NAME = "translations-cache-miss";
5197
+ const LOCALES_DICTIONARY_CACHE_HIT_EVENT_NAME = "locales-dictionary-cache-hit";
5271
5198
  const LOCALES_DICTIONARY_CACHE_MISS_EVENT_NAME = "locales-dictionary-cache-miss";
5199
+ const DICTIONARY_CACHE_HIT_EVENT_NAME = "dictionary-cache-hit";
5272
5200
  const DICTIONARY_CACHE_MISS_EVENT_NAME = "dictionary-cache-miss";
5201
+ const DICTIONARY_OBJECT_CACHE_HIT_EVENT_NAME = "dictionary-object-cache-hit";
5273
5202
  /**
5274
5203
  * Maps consumer-facing lifecycle callbacks to internal locales cache lifecycle callbacks.
5275
5204
  * The consumer API exposes simplified params (locale, hash, value) while the internal
@@ -5277,22 +5206,24 @@ const DICTIONARY_CACHE_MISS_EVENT_NAME = "dictionary-cache-miss";
5277
5206
  *
5278
5207
  * @deprecated - move to subscription api instead
5279
5208
  */
5280
- function createLifecycleCallbacks(emit) {
5209
+ function createLifecycleCallbacks(emit, hasListeners = () => true) {
5281
5210
  return {
5282
5211
  onLocalesCacheHit: (params) => {
5283
- emit("locales-cache-hit", {
5212
+ if (!hasListeners("locales-cache-hit")) return;
5213
+ emit(LOCALES_CACHE_HIT_EVENT_NAME, {
5284
5214
  locale: params.inputKey,
5285
5215
  translations: params.outputValue.getInternalCache()
5286
5216
  });
5287
5217
  },
5288
5218
  onLocalesCacheMiss: (params) => {
5219
+ if (!hasListeners("locales-cache-miss")) return;
5289
5220
  emit(LOCALES_CACHE_MISS_EVENT_NAME, {
5290
5221
  locale: params.inputKey,
5291
5222
  translations: params.outputValue.getInternalCache()
5292
5223
  });
5293
5224
  },
5294
5225
  onTranslationsCacheHit: (params) => {
5295
- emit("translations-cache-hit", {
5226
+ emit(TRANSLATIONS_CACHE_HIT_EVENT_NAME, {
5296
5227
  locale: params.locale,
5297
5228
  hash: params.cacheKey,
5298
5229
  translation: params.outputValue
@@ -5306,19 +5237,21 @@ function createLifecycleCallbacks(emit) {
5306
5237
  });
5307
5238
  },
5308
5239
  onLocalesDictionaryCacheHit: (params) => {
5309
- emit("locales-dictionary-cache-hit", {
5240
+ if (!hasListeners("locales-dictionary-cache-hit")) return;
5241
+ emit(LOCALES_DICTIONARY_CACHE_HIT_EVENT_NAME, {
5310
5242
  locale: params.inputKey,
5311
5243
  dictionary: params.outputValue.getInternalCache()
5312
5244
  });
5313
5245
  },
5314
5246
  onLocalesDictionaryCacheMiss: (params) => {
5247
+ if (!hasListeners("locales-dictionary-cache-miss")) return;
5315
5248
  emit(LOCALES_DICTIONARY_CACHE_MISS_EVENT_NAME, {
5316
5249
  locale: params.inputKey,
5317
5250
  dictionary: params.outputValue.getInternalCache()
5318
5251
  });
5319
5252
  },
5320
5253
  onDictionaryCacheHit: (params) => {
5321
- emit("dictionary-cache-hit", {
5254
+ emit(DICTIONARY_CACHE_HIT_EVENT_NAME, {
5322
5255
  locale: params.locale,
5323
5256
  id: params.cacheKey,
5324
5257
  dictionaryEntry: params.outputValue
@@ -5332,7 +5265,7 @@ function createLifecycleCallbacks(emit) {
5332
5265
  });
5333
5266
  },
5334
5267
  onDictionaryObjectCacheHit: (params) => {
5335
- emit("dictionary-object-cache-hit", {
5268
+ emit(DICTIONARY_OBJECT_CACHE_HIT_EVENT_NAME, {
5336
5269
  locale: params.locale,
5337
5270
  id: params.cacheKey,
5338
5271
  dictionaryValue: params.outputValue
@@ -5367,6 +5300,9 @@ var EventEmitter = class {
5367
5300
  emit(eventName, event) {
5368
5301
  this.listeners[eventName]?.forEach((subscriber) => subscriber(event));
5369
5302
  }
5303
+ hasListeners(eventName) {
5304
+ return (this.listeners[eventName]?.size ?? 0) > 0;
5305
+ }
5370
5306
  };
5371
5307
  /**
5372
5308
  * Subscribes to the lifecycle callbacks and emits the events to the event emitter
@@ -5376,7 +5312,7 @@ var EventEmitter = class {
5376
5312
  * and is only used internally
5377
5313
  */
5378
5314
  function subscribeLifecycleCallbacks({ onLocalesCacheHit, onLocalesCacheMiss, onTranslationsCacheHit, onTranslationsCacheMiss, onLocalesDictionaryCacheHit, onLocalesDictionaryCacheMiss, onDictionaryCacheHit, onDictionaryCacheMiss, onDictionaryObjectCacheHit }, subscribe) {
5379
- if (onLocalesCacheHit) subscribe("locales-cache-hit", (event) => {
5315
+ if (onLocalesCacheHit) subscribe(LOCALES_CACHE_HIT_EVENT_NAME, (event) => {
5380
5316
  onLocalesCacheHit({
5381
5317
  ...event,
5382
5318
  value: event.translations
@@ -5388,7 +5324,7 @@ function subscribeLifecycleCallbacks({ onLocalesCacheHit, onLocalesCacheMiss, on
5388
5324
  value: event.translations
5389
5325
  });
5390
5326
  });
5391
- if (onTranslationsCacheHit) subscribe("translations-cache-hit", (event) => {
5327
+ if (onTranslationsCacheHit) subscribe(TRANSLATIONS_CACHE_HIT_EVENT_NAME, (event) => {
5392
5328
  onTranslationsCacheHit({
5393
5329
  ...event,
5394
5330
  value: event.translation
@@ -5400,19 +5336,19 @@ function subscribeLifecycleCallbacks({ onLocalesCacheHit, onLocalesCacheMiss, on
5400
5336
  value: event.translation
5401
5337
  });
5402
5338
  });
5403
- if (onLocalesDictionaryCacheHit) subscribe("locales-dictionary-cache-hit", (event) => {
5339
+ if (onLocalesDictionaryCacheHit) subscribe(LOCALES_DICTIONARY_CACHE_HIT_EVENT_NAME, (event) => {
5404
5340
  onLocalesDictionaryCacheHit(event);
5405
5341
  });
5406
5342
  if (onLocalesDictionaryCacheMiss) subscribe(LOCALES_DICTIONARY_CACHE_MISS_EVENT_NAME, (event) => {
5407
5343
  onLocalesDictionaryCacheMiss(event);
5408
5344
  });
5409
- if (onDictionaryCacheHit) subscribe("dictionary-cache-hit", (event) => {
5345
+ if (onDictionaryCacheHit) subscribe(DICTIONARY_CACHE_HIT_EVENT_NAME, (event) => {
5410
5346
  onDictionaryCacheHit(event);
5411
5347
  });
5412
5348
  if (onDictionaryCacheMiss) subscribe(DICTIONARY_CACHE_MISS_EVENT_NAME, (event) => {
5413
5349
  onDictionaryCacheMiss(event);
5414
5350
  });
5415
- if (onDictionaryObjectCacheHit) subscribe("dictionary-object-cache-hit", (event) => {
5351
+ if (onDictionaryObjectCacheHit) subscribe(DICTIONARY_OBJECT_CACHE_HIT_EVENT_NAME, (event) => {
5416
5352
  onDictionaryObjectCacheHit(event);
5417
5353
  });
5418
5354
  }
@@ -5443,26 +5379,32 @@ var I18nManager = class extends EventEmitter {
5443
5379
  locales: this.config.locales,
5444
5380
  customMapping: this.config.customMapping
5445
5381
  });
5446
- const loadTranslations = createTranslationLoader(params);
5447
- const loadDictionary = createDictionaryLoader(params);
5382
+ const loadTranslations = routeCreateTranslationLoader({
5383
+ loadTranslations: params.loadTranslations,
5384
+ type: getLoadTranslationsType(params),
5385
+ remoteTranslationLoaderParams: {
5386
+ cacheUrl: params.cacheUrl,
5387
+ projectId: params.projectId,
5388
+ _versionId: params._versionId,
5389
+ _branchId: params._branchId,
5390
+ customMapping: params.customMapping
5391
+ }
5392
+ });
5393
+ const loadDictionary = params.loadDictionary ?? (() => Promise.resolve({}));
5448
5394
  const runtimeTranslationTimeout = this.config.runtimeTranslation?.timeout ?? DEFAULT_TRANSLATION_TIMEOUT;
5449
5395
  const runtimeTranslationMetadata = this.config.runtimeTranslation?.metadata ?? {};
5450
5396
  const createTranslateMany = createTranslateManyFactory(this.getGTClassClean(), runtimeTranslationTimeout, runtimeTranslationMetadata);
5451
5397
  subscribeLifecycleCallbacks(params.lifecycle ?? {}, (...args) => this.subscribe(...args));
5452
- const lifecycle = createLifecycleCallbacks((...args) => this.emit(...args));
5398
+ const lifecycle = createLifecycleCallbacks((...args) => this.emit(...args), (eventName) => this.hasListeners(eventName));
5453
5399
  this.localesCache = new LocalesCache({
5454
- loadTranslations,
5455
- createTranslateMany,
5456
- lifecycle,
5457
- ttl: this.config.cacheExpiryTime,
5458
- batchConfig: this.config.batchConfig
5459
- });
5460
- this.localesDictionaryCache = new LocalesDictionaryCache({
5461
5400
  defaultLocale: this.config.defaultLocale,
5462
5401
  dictionary: params.dictionary,
5402
+ loadTranslations,
5463
5403
  loadDictionary,
5464
- runtimeTranslate: (locale, id, sourceEntry) => this.dictionaryRuntimeTranslate(locale, id, sourceEntry),
5404
+ createTranslateMany,
5405
+ translateDictionaryEntry: (locale, id, sourceEntry) => this.translateDictionaryEntry(locale, id, sourceEntry),
5465
5406
  ttl: this.config.cacheExpiryTime,
5407
+ batchConfig: this.config.batchConfig,
5466
5408
  lifecycle
5467
5409
  });
5468
5410
  }
@@ -5534,9 +5476,7 @@ var I18nManager = class extends EventEmitter {
5534
5476
  try {
5535
5477
  const translationLocale = this.resolveCacheLocale(locale);
5536
5478
  if (!translationLocale) return {};
5537
- let txCache = this.localesCache.get(translationLocale);
5538
- if (!txCache) txCache = await this.localesCache.miss(translationLocale);
5539
- return txCache.getInternalCache();
5479
+ return (await this.localesCache.getOrLoadTranslations(translationLocale)).getInternalCache();
5540
5480
  } catch (error) {
5541
5481
  this.handleError(error);
5542
5482
  return {};
@@ -5549,10 +5489,8 @@ var I18nManager = class extends EventEmitter {
5549
5489
  async loadDictionary(locale) {
5550
5490
  try {
5551
5491
  const dictionaryLocale = this.resolveCacheLocale(locale);
5552
- if (!dictionaryLocale) return this.localesDictionaryCache.get(this.config.defaultLocale)?.getInternalCache() ?? {};
5553
- let dictionaryCache = this.localesDictionaryCache.get(dictionaryLocale);
5554
- if (!dictionaryCache) dictionaryCache = await this.localesDictionaryCache.miss(dictionaryLocale);
5555
- return dictionaryCache.getInternalCache();
5492
+ if (!dictionaryLocale) return this.getDefaultDictionaryCache()?.getInternalCache() ?? {};
5493
+ return (await this.localesCache.getOrLoadDictionary(dictionaryLocale)).getInternalCache();
5556
5494
  } catch (error) {
5557
5495
  this.handleError(error);
5558
5496
  return {};
@@ -5563,8 +5501,8 @@ var I18nManager = class extends EventEmitter {
5563
5501
  */
5564
5502
  lookupDictionary(locale, id) {
5565
5503
  try {
5566
- const dictionaryLocale = this.resolveCacheLocale(locale) ?? this.config.defaultLocale;
5567
- return this.localesDictionaryCache.get(dictionaryLocale)?.get(id);
5504
+ const dictionaryLocale = this.resolveDictionaryCacheLocale(locale);
5505
+ return this.localesCache.getDictionary(dictionaryLocale)?.getEntry(id);
5568
5506
  } catch (error) {
5569
5507
  this.handleError(error);
5570
5508
  return;
@@ -5575,8 +5513,8 @@ var I18nManager = class extends EventEmitter {
5575
5513
  */
5576
5514
  lookupDictionaryObj(locale, id) {
5577
5515
  try {
5578
- const dictionaryLocale = this.resolveCacheLocale(locale) ?? this.config.defaultLocale;
5579
- return this.localesDictionaryCache.get(dictionaryLocale)?.getObj(id);
5516
+ const dictionaryLocale = this.resolveDictionaryCacheLocale(locale);
5517
+ return this.localesCache.getDictionary(dictionaryLocale)?.getValue(id);
5580
5518
  } catch (error) {
5581
5519
  this.handleError(error);
5582
5520
  return;
@@ -5589,19 +5527,10 @@ var I18nManager = class extends EventEmitter {
5589
5527
  async lookupDictionaryWithFallback(locale, id) {
5590
5528
  try {
5591
5529
  const dictionaryLocale = this.resolveCacheLocale(locale);
5592
- if (!dictionaryLocale) {
5593
- const sourceEntry = this.localesDictionaryCache.get(this.config.defaultLocale)?.get(id);
5594
- if (sourceEntry === void 0) throw new DictionarySourceNotFoundError(id);
5595
- return sourceEntry;
5596
- }
5597
- let dictionaryCache = this.localesDictionaryCache.get(dictionaryLocale);
5598
- if (!dictionaryCache) dictionaryCache = await this.localesDictionaryCache.miss(dictionaryLocale);
5599
- let dictionaryEntry = dictionaryCache.get(id);
5600
- if (dictionaryEntry === void 0) {
5601
- const sourceEntry = this.localesDictionaryCache.get(this.config.defaultLocale)?.get(id);
5602
- if (sourceEntry === void 0) throw new DictionarySourceNotFoundError(id);
5603
- dictionaryEntry = await dictionaryCache.miss(id, sourceEntry);
5604
- }
5530
+ if (!dictionaryLocale) return this.getSourceDictionaryEntry(id);
5531
+ const dictionaryCache = await this.localesCache.getOrLoadDictionary(dictionaryLocale);
5532
+ let dictionaryEntry = dictionaryCache.getEntry(id);
5533
+ if (dictionaryEntry === void 0) dictionaryEntry = await dictionaryCache.materializeEntry(id, this.getSourceDictionaryEntry(id));
5605
5534
  return dictionaryEntry;
5606
5535
  } catch (error) {
5607
5536
  this.handleError(error);
@@ -5615,25 +5544,41 @@ var I18nManager = class extends EventEmitter {
5615
5544
  async lookupDictionaryObjWithFallback(locale, id) {
5616
5545
  try {
5617
5546
  const dictionaryLocale = this.resolveCacheLocale(locale);
5618
- if (!dictionaryLocale) {
5619
- const sourceObject = this.localesDictionaryCache.get(this.config.defaultLocale)?.getObj(id);
5620
- if (sourceObject === void 0) throw new DictionarySourceNotFoundError(id);
5621
- return sourceObject;
5622
- }
5623
- let dictionaryCache = this.localesDictionaryCache.get(dictionaryLocale);
5624
- if (!dictionaryCache) dictionaryCache = await this.localesDictionaryCache.miss(dictionaryLocale);
5625
- let dictionaryObject = dictionaryCache.getObj(id);
5626
- if (dictionaryObject === void 0) {
5627
- const sourceObject = this.localesDictionaryCache.get(this.config.defaultLocale)?.getObj(id);
5628
- if (sourceObject === void 0) throw new DictionarySourceNotFoundError(id);
5629
- dictionaryObject = await dictionaryCache.missObj(id, sourceObject);
5547
+ if (!dictionaryLocale) return this.getSourceDictionaryObject(id);
5548
+ const dictionaryCache = await this.localesCache.getOrLoadDictionary(dictionaryLocale);
5549
+ const targetObject = dictionaryCache.getValue(id);
5550
+ const sourceObject = this.getSourceDictionaryObject(id, { throwOnMissing: false });
5551
+ if (sourceObject === void 0) {
5552
+ if (targetObject !== void 0) return targetObject;
5553
+ throw new DictionarySourceNotFoundError(id);
5630
5554
  }
5631
- return dictionaryObject;
5555
+ return await dictionaryCache.materializeValue(id, sourceObject, targetObject);
5632
5556
  } catch (error) {
5633
5557
  this.handleError(error);
5634
5558
  return;
5635
5559
  }
5636
5560
  }
5561
+ async translateDictionaryEntry(locale, id, sourceEntry) {
5562
+ const translation = await this.lookupTranslationWithFallbackResolved(locale, sourceEntry.entry, resolveDictionaryLookupOptions(sourceEntry.options));
5563
+ if (typeof translation !== "string") throw new Error(`Dictionary entry "${id}" could not be translated into a string. Check the source entry and translation loader output.`);
5564
+ return translation;
5565
+ }
5566
+ getSourceDictionaryEntry(id) {
5567
+ const sourceEntry = this.getDefaultDictionaryCache()?.getEntry(id);
5568
+ if (sourceEntry === void 0) throw new DictionarySourceNotFoundError(id);
5569
+ return sourceEntry;
5570
+ }
5571
+ getSourceDictionaryObject(id, { throwOnMissing = true } = {}) {
5572
+ const sourceObject = this.getDefaultDictionaryCache()?.getValue(id);
5573
+ if (sourceObject === void 0 && throwOnMissing) throw new DictionarySourceNotFoundError(id);
5574
+ return sourceObject;
5575
+ }
5576
+ getDefaultDictionaryCache() {
5577
+ return this.localesCache.getDictionary(this.config.defaultLocale);
5578
+ }
5579
+ resolveDictionaryCacheLocale(locale) {
5580
+ return this.resolveCacheLocale(locale) ?? this.config.defaultLocale;
5581
+ }
5637
5582
  /**
5638
5583
  * Just lookup a translation
5639
5584
  */
@@ -5641,7 +5586,7 @@ var I18nManager = class extends EventEmitter {
5641
5586
  try {
5642
5587
  const { translationLocale, options: lookupOptions } = this.resolveLookupParams(locale, options);
5643
5588
  if (!translationLocale) return message;
5644
- const txCache = this.localesCache.get(translationLocale);
5589
+ const txCache = this.localesCache.getTranslations(translationLocale);
5645
5590
  if (!txCache) return void 0;
5646
5591
  return txCache.get({
5647
5592
  message,
@@ -5679,9 +5624,7 @@ var I18nManager = class extends EventEmitter {
5679
5624
  if (!translationLocale) return (message) => message;
5680
5625
  const resolvedPrefetchEntries = resolvePrefetchEntriesByLocale(prefetchEntries, translationLocale, (entryLocale) => this.resolveCacheLocale(entryLocale) ?? this.resolveLocale(entryLocale));
5681
5626
  if (resolvedPrefetchEntries.length !== prefetchEntries.length) logger_default.warn(`I18nManager: getLookupTranslation(): prefetchEntries must all be the same locale, ignoring all entries that are not for ${translationLocale}`);
5682
- let txCache = this.localesCache.get(translationLocale);
5683
- if (!txCache) txCache = await this.localesCache.miss(translationLocale);
5684
- if (!txCache) return () => void 0;
5627
+ const txCache = await this.localesCache.getOrLoadTranslations(translationLocale);
5685
5628
  await Promise.all(resolvedPrefetchEntries.filter((entry) => txCache.get(entry) == null).map((entry) => txCache.miss(entry)));
5686
5629
  return (message, options = {}) => {
5687
5630
  return txCache.get({
@@ -5753,7 +5696,7 @@ var I18nManager = class extends EventEmitter {
5753
5696
  }
5754
5697
  resolveLocale(locale) {
5755
5698
  const resolvedLocale = this.localeConfig.determineLocale(locale);
5756
- if (!this.localeConfig.isValidLocale(locale) || !resolvedLocale) throw new Error(`I18nManager: validateLocale(): locale ${locale} is not valid`);
5699
+ if (!this.localeConfig.isValidLocale(locale) || !resolvedLocale) throw new Error(`Locale "${locale}" is not valid. Use a valid BCP 47 locale code or add a custom mapping.`);
5757
5700
  return resolvedLocale;
5758
5701
  }
5759
5702
  /**
@@ -5783,8 +5726,7 @@ var I18nManager = class extends EventEmitter {
5783
5726
  async lookupTranslationWithFallbackResolved(locale, message, options) {
5784
5727
  const { translationLocale, options: lookupOptions } = this.resolveLookupParams(locale, options);
5785
5728
  if (!translationLocale) return message;
5786
- let txCache = this.localesCache.get(translationLocale);
5787
- if (!txCache) txCache = await this.localesCache.miss(translationLocale);
5729
+ const txCache = await this.localesCache.getOrLoadTranslations(translationLocale);
5788
5730
  let translation = txCache.get({
5789
5731
  message,
5790
5732
  options: lookupOptions
@@ -5796,14 +5738,6 @@ var I18nManager = class extends EventEmitter {
5796
5738
  return translation;
5797
5739
  }
5798
5740
  /**
5799
- * Runtime lookup function for dictionaries
5800
- */
5801
- async dictionaryRuntimeTranslate(locale, id, sourceEntry) {
5802
- const translation = await this.lookupTranslationWithFallbackResolved(locale, sourceEntry.entry, resolveDictionaryLookupOptions(sourceEntry.options));
5803
- if (typeof translation !== "string") throw new Error(`I18nManager: dictionaryRuntimeTranslate(): unable to translate dictionary entry ${id}`);
5804
- return translation;
5805
- }
5806
- /**
5807
5741
  * A helper function to create a gt class that is locale agnostic
5808
5742
  * This is helpful for when our getLocale function is bound to a
5809
5743
  * specific context
@@ -5900,28 +5834,6 @@ function resolvePrefetchEntriesByLocale(prefetchEntries, locale, resolveLocale)
5900
5834
  }
5901
5835
  });
5902
5836
  }
5903
- /**
5904
- * Helper function for creating a translation loader
5905
- */
5906
- function createTranslationLoader(params) {
5907
- return routeCreateTranslationLoader({
5908
- loadTranslations: params.loadTranslations,
5909
- type: getLoadTranslationsType(params),
5910
- remoteTranslationLoaderParams: {
5911
- cacheUrl: params.cacheUrl,
5912
- projectId: params.projectId,
5913
- _versionId: params._versionId,
5914
- _branchId: params._branchId,
5915
- customMapping: params.customMapping
5916
- }
5917
- });
5918
- }
5919
- /**
5920
- * Helper function for creating a dictionary loader
5921
- */
5922
- function createDictionaryLoader(params) {
5923
- return params.loadDictionary ?? (() => Promise.resolve({}));
5924
- }
5925
5837
  let i18nManager = void 0;
5926
5838
  let fallbackDefaultLocale = "en";
5927
5839
  const fallbackConditionStore = { getLocale: () => fallbackDefaultLocale };
@@ -5933,7 +5845,7 @@ let conditionStore = fallbackConditionStore;
5933
5845
  */
5934
5846
  function getI18nManager() {
5935
5847
  if (!i18nManager) {
5936
- logger_default.warn("getI18nManager(): Translation failed because I18nManager not initialized.");
5848
+ logger_default.warn("getI18nManager(): I18nManager was not initialized. Falling back to the default locale until initializeGT() configures translations.");
5937
5849
  i18nManager = new I18nManager({
5938
5850
  defaultLocale: "en",
5939
5851
  locales: ["en"]
@@ -6227,7 +6139,40 @@ var c = Object.defineProperty, l = Object.getOwnPropertyDescriptor, u = Object.g
6227
6139
  });
6228
6140
  return e;
6229
6141
  }, g = (e) => d.call(e, `module.exports`) ? e[`module.exports`] : h(c({}, `__esModule`, { value: !0 }), e);
6230
- function C(e) {
6142
+ function b(e) {
6143
+ let t = e.trim();
6144
+ return t ? /[.!?)]$/.test(t) ? t : `${t}.` : ``;
6145
+ }
6146
+ function x(e) {
6147
+ let t = e.trim(), n = t.length;
6148
+ for (; n > 0;) {
6149
+ let e = t[n - 1];
6150
+ if (e !== `.` && e !== `!` && e !== `?`) break;
6151
+ --n;
6152
+ }
6153
+ return t.slice(0, n);
6154
+ }
6155
+ function te(e) {
6156
+ return e.replace(/^[A-Z][a-z]/, (e) => e.toLowerCase());
6157
+ }
6158
+ function ne(e) {
6159
+ if (!e) return ``;
6160
+ let t = Array.isArray(e) ? e.join(`, `) : e;
6161
+ return t.trim() ? b(`Details: ${t}`) : ``;
6162
+ }
6163
+ function S({ source: e, severity: t, whatHappened: n, reassurance: r, why: i, fix: a, wayOut: o, details: s, docsUrl: c }) {
6164
+ let l = e ? t ? `${e} ${t}:` : `${e}:` : t ? `${t}:` : ``, u = i ? `${x(n)} because ${te(x(i))}` : n, d = !!a && !!o && /^[a-z]/.test(x(o)), f = [
6165
+ u,
6166
+ r,
6167
+ d ? `${x(a)}, or ${te(x(o))}` : a,
6168
+ d ? void 0 : o,
6169
+ ne(s)
6170
+ ].filter((e) => !!e).map(b);
6171
+ c && f.push(`Learn more: ${c}`);
6172
+ let p = f.join(` `);
6173
+ return l ? `${l} ${p}` : p;
6174
+ }
6175
+ function E(e) {
6231
6176
  let t = e;
6232
6177
  if (t && typeof t == `object` && typeof t.k == `string`) {
6233
6178
  let e = Object.keys(t);
@@ -6235,43 +6180,43 @@ function C(e) {
6235
6180
  }
6236
6181
  return !1;
6237
6182
  }
6238
- function w(e) {
6183
+ function ie(e) {
6239
6184
  return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === `Uint8Array` && `BYTES_PER_ELEMENT` in e && e.BYTES_PER_ELEMENT === 1;
6240
6185
  }
6241
- function T$1(e, t, n = ``) {
6242
- let r = w(e), i = e?.length, a = t !== void 0;
6186
+ function D(e, t, n = ``) {
6187
+ let r = ie(e), i = e?.length, a = t !== void 0;
6243
6188
  if (!r || a && i !== t) {
6244
6189
  let o = n && `"${n}" `, s = a ? ` of length ${t}` : ``, c = r ? `length=${i}` : `type=${typeof e}`, l = o + `expected Uint8Array` + s + `, got ` + c;
6245
6190
  throw r ? RangeError(l) : TypeError(l);
6246
6191
  }
6247
6192
  return e;
6248
6193
  }
6249
- function E(e, t = !0) {
6194
+ function ae(e, t = !0) {
6250
6195
  if (e.destroyed) throw Error(`Hash instance has been destroyed`);
6251
6196
  if (t && e.finished) throw Error(`Hash#digest() has already been called`);
6252
6197
  }
6253
- function D(e, t) {
6254
- T$1(e, void 0, `digestInto() output`);
6198
+ function oe(e, t) {
6199
+ D(e, void 0, `digestInto() output`);
6255
6200
  let n = t.outputLen;
6256
6201
  if (e.length < n) throw RangeError(`"digestInto() output" expected to be of length >=` + n);
6257
6202
  }
6258
- function O(...e) {
6203
+ function se(...e) {
6259
6204
  for (let t = 0; t < e.length; t++) e[t].fill(0);
6260
6205
  }
6261
- function k(e) {
6206
+ function ce(e) {
6262
6207
  return new DataView(e.buffer, e.byteOffset, e.byteLength);
6263
6208
  }
6264
- function A(e, t) {
6209
+ function O(e, t) {
6265
6210
  return e << 32 - t | e >>> t;
6266
6211
  }
6267
6212
  new Uint8Array(new Uint32Array([287454020]).buffer)[0];
6268
6213
  typeof Uint8Array.from([]).toHex == `function` && Uint8Array.fromHex;
6269
6214
  Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, `0`));
6270
- function oe(e, t = {}) {
6215
+ function pe(e, t = {}) {
6271
6216
  let n = (t, n) => e(n).update(t).digest(), r = e(void 0);
6272
6217
  return n.outputLen = r.outputLen, n.blockLen = r.blockLen, n.canXOF = r.canXOF, n.create = (t) => e(t), Object.assign(n, t), Object.freeze(n);
6273
6218
  }
6274
- const se = (e) => ({ oid: Uint8Array.from([
6219
+ const me = (e) => ({ oid: Uint8Array.from([
6275
6220
  6,
6276
6221
  9,
6277
6222
  96,
@@ -6284,13 +6229,13 @@ const se = (e) => ({ oid: Uint8Array.from([
6284
6229
  2,
6285
6230
  e
6286
6231
  ]) });
6287
- function ce(e, t, n) {
6232
+ function he(e, t, n) {
6288
6233
  return e & t ^ ~e & n;
6289
6234
  }
6290
- function le(e, t, n) {
6235
+ function ge(e, t, n) {
6291
6236
  return e & t ^ e & n ^ t & n;
6292
6237
  }
6293
- var ue = class {
6238
+ var _e = class {
6294
6239
  blockLen;
6295
6240
  outputLen;
6296
6241
  canXOF = !1;
@@ -6303,15 +6248,15 @@ var ue = class {
6303
6248
  pos = 0;
6304
6249
  destroyed = !1;
6305
6250
  constructor(e, t, n, r) {
6306
- this.blockLen = e, this.outputLen = t, this.padOffset = n, this.isLE = r, this.buffer = new Uint8Array(e), this.view = k(this.buffer);
6251
+ this.blockLen = e, this.outputLen = t, this.padOffset = n, this.isLE = r, this.buffer = new Uint8Array(e), this.view = ce(this.buffer);
6307
6252
  }
6308
6253
  update(e) {
6309
- E(this), T$1(e);
6254
+ ae(this), D(e);
6310
6255
  let { view: t, buffer: n, blockLen: r } = this, i = e.length;
6311
6256
  for (let a = 0; a < i;) {
6312
6257
  let o = Math.min(r - this.pos, i - a);
6313
6258
  if (o === r) {
6314
- let t = k(e);
6259
+ let t = ce(e);
6315
6260
  for (; r <= i - a; a += r) this.process(t, a);
6316
6261
  continue;
6317
6262
  }
@@ -6320,12 +6265,12 @@ var ue = class {
6320
6265
  return this.length += e.length, this.roundClean(), this;
6321
6266
  }
6322
6267
  digestInto(e) {
6323
- E(this), D(e, this), this.finished = !0;
6268
+ ae(this), oe(e, this), this.finished = !0;
6324
6269
  let { buffer: t, view: n, blockLen: r, isLE: i } = this, { pos: a } = this;
6325
- t[a++] = 128, O(this.buffer.subarray(a)), this.padOffset > r - a && (this.process(n, 0), a = 0);
6270
+ t[a++] = 128, se(this.buffer.subarray(a)), this.padOffset > r - a && (this.process(n, 0), a = 0);
6326
6271
  for (let e = a; e < r; e++) t[e] = 0;
6327
6272
  n.setBigUint64(r - 8, BigInt(this.length * 8), i), this.process(n, 0);
6328
- let o = k(e), s = this.outputLen;
6273
+ let o = ce(e), s = this.outputLen;
6329
6274
  if (s % 4) throw Error(`_sha2: outputLen must be aligned to 32bit`);
6330
6275
  let c = s / 4, l = this.get();
6331
6276
  if (c > l.length) throw Error(`_sha2: outputLen bigger than state`);
@@ -6346,7 +6291,7 @@ var ue = class {
6346
6291
  return this._cloneInto();
6347
6292
  }
6348
6293
  };
6349
- const j = Uint32Array.from([
6294
+ const k = Uint32Array.from([
6350
6295
  1779033703,
6351
6296
  3144134277,
6352
6297
  1013904242,
@@ -6355,25 +6300,25 @@ const j = Uint32Array.from([
6355
6300
  2600822924,
6356
6301
  528734635,
6357
6302
  1541459225
6358
- ]), M = BigInt(2 ** 32 - 1), de = BigInt(32);
6359
- function fe(e, t = !1) {
6303
+ ]), A = BigInt(2 ** 32 - 1), ve = BigInt(32);
6304
+ function ye(e, t = !1) {
6360
6305
  return t ? {
6361
- h: Number(e & M),
6362
- l: Number(e >> de & M)
6306
+ h: Number(e & A),
6307
+ l: Number(e >> ve & A)
6363
6308
  } : {
6364
- h: Number(e >> de & M) | 0,
6365
- l: Number(e & M) | 0
6309
+ h: Number(e >> ve & A) | 0,
6310
+ l: Number(e & A) | 0
6366
6311
  };
6367
6312
  }
6368
- function pe(e, t = !1) {
6313
+ function be(e, t = !1) {
6369
6314
  let n = e.length, r = new Uint32Array(n), i = new Uint32Array(n);
6370
6315
  for (let a = 0; a < n; a++) {
6371
- let { h: n, l: o } = fe(e[a], t);
6316
+ let { h: n, l: o } = ye(e[a], t);
6372
6317
  [r[a], i[a]] = [n, o];
6373
6318
  }
6374
6319
  return [r, i];
6375
6320
  }
6376
- const me = Uint32Array.from([
6321
+ const xe = Uint32Array.from([
6377
6322
  1116352408,
6378
6323
  1899447441,
6379
6324
  3049323471,
@@ -6438,8 +6383,8 @@ const me = Uint32Array.from([
6438
6383
  2756734187,
6439
6384
  3204031479,
6440
6385
  3329325298
6441
- ]), N = new Uint32Array(64);
6442
- var he = class extends ue {
6386
+ ]), j = new Uint32Array(64);
6387
+ var Se = class extends _e {
6443
6388
  constructor(e) {
6444
6389
  super(64, e, 8, !1);
6445
6390
  }
@@ -6460,41 +6405,41 @@ var he = class extends ue {
6460
6405
  this.A = e | 0, this.B = t | 0, this.C = n | 0, this.D = r | 0, this.E = i | 0, this.F = a | 0, this.G = o | 0, this.H = s | 0;
6461
6406
  }
6462
6407
  process(e, t) {
6463
- for (let n = 0; n < 16; n++, t += 4) N[n] = e.getUint32(t, !1);
6408
+ for (let n = 0; n < 16; n++, t += 4) j[n] = e.getUint32(t, !1);
6464
6409
  for (let e = 16; e < 64; e++) {
6465
- let t = N[e - 15], n = N[e - 2], r = A(t, 7) ^ A(t, 18) ^ t >>> 3;
6466
- N[e] = (A(n, 17) ^ A(n, 19) ^ n >>> 10) + N[e - 7] + r + N[e - 16] | 0;
6410
+ let t = j[e - 15], n = j[e - 2], r = O(t, 7) ^ O(t, 18) ^ t >>> 3;
6411
+ j[e] = (O(n, 17) ^ O(n, 19) ^ n >>> 10) + j[e - 7] + r + j[e - 16] | 0;
6467
6412
  }
6468
6413
  let { A: n, B: r, C: i, D: a, E: o, F: s, G: c, H: l } = this;
6469
6414
  for (let e = 0; e < 64; e++) {
6470
- let t = A(o, 6) ^ A(o, 11) ^ A(o, 25), u = l + t + ce(o, s, c) + me[e] + N[e] | 0, d = (A(n, 2) ^ A(n, 13) ^ A(n, 22)) + le(n, r, i) | 0;
6415
+ let t = O(o, 6) ^ O(o, 11) ^ O(o, 25), u = l + t + he(o, s, c) + xe[e] + j[e] | 0, d = (O(n, 2) ^ O(n, 13) ^ O(n, 22)) + ge(n, r, i) | 0;
6471
6416
  l = c, c = s, s = o, o = a + u | 0, a = i, i = r, r = n, n = u + d | 0;
6472
6417
  }
6473
6418
  n = n + this.A | 0, r = r + this.B | 0, i = i + this.C | 0, a = a + this.D | 0, o = o + this.E | 0, s = s + this.F | 0, c = c + this.G | 0, l = l + this.H | 0, this.set(n, r, i, a, o, s, c, l);
6474
6419
  }
6475
6420
  roundClean() {
6476
- O(N);
6421
+ se(j);
6477
6422
  }
6478
6423
  destroy() {
6479
- this.destroyed = !0, this.set(0, 0, 0, 0, 0, 0, 0, 0), O(this.buffer);
6480
- }
6481
- }, ge = class extends he {
6482
- A = j[0] | 0;
6483
- B = j[1] | 0;
6484
- C = j[2] | 0;
6485
- D = j[3] | 0;
6486
- E = j[4] | 0;
6487
- F = j[5] | 0;
6488
- G = j[6] | 0;
6489
- H = j[7] | 0;
6424
+ this.destroyed = !0, this.set(0, 0, 0, 0, 0, 0, 0, 0), se(this.buffer);
6425
+ }
6426
+ }, Ce = class extends Se {
6427
+ A = k[0] | 0;
6428
+ B = k[1] | 0;
6429
+ C = k[2] | 0;
6430
+ D = k[3] | 0;
6431
+ E = k[4] | 0;
6432
+ F = k[5] | 0;
6433
+ G = k[6] | 0;
6434
+ H = k[7] | 0;
6490
6435
  constructor() {
6491
6436
  super(32);
6492
6437
  }
6493
6438
  };
6494
- const _e = pe(`0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817`.split(`.`).map((e) => BigInt(e)));
6495
- _e[0], _e[1];
6496
- oe(() => new ge(), se(1));
6497
- const ye = (e) => `generaltranslation Formatting Error: Invalid cutoff style: ${e}.`, be = `DEFAULT_TERMINATOR_KEY`, xe = {
6439
+ const we = be(`0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817`.split(`.`).map((e) => BigInt(e)));
6440
+ we[0], we[1];
6441
+ pe(() => new Ce(), me(1));
6442
+ const Ee = (e) => `generaltranslation Formatting Error: Invalid cutoff style: ${e}.`, De = `DEFAULT_TERMINATOR_KEY`, Oe = {
6498
6443
  ellipsis: {
6499
6444
  fr: {
6500
6445
  terminator: `…`,
@@ -6508,37 +6453,35 @@ const ye = (e) => `generaltranslation Formatting Error: Invalid cutoff style: ${
6508
6453
  terminator: `……`,
6509
6454
  separator: void 0
6510
6455
  },
6511
- [be]: {
6456
+ [De]: {
6512
6457
  terminator: `…`,
6513
6458
  separator: void 0
6514
6459
  }
6515
6460
  },
6516
- none: { [be]: {
6461
+ none: { [De]: {
6517
6462
  terminator: void 0,
6518
6463
  separator: void 0
6519
6464
  } }
6520
6465
  };
6521
- var Se = class {
6522
- constructor(e, t = {}) {
6466
+ var ke = class e {
6467
+ static resolveLocale(e) {
6523
6468
  try {
6524
- let t = e ? Array.isArray(e) ? e.map((e) => String(e)) : [String(e)] : [`en`], n = Intl.getCanonicalLocales(t);
6525
- this.locale = n.length ? n[0] : `en`;
6469
+ let t = e ? Array.isArray(e) ? e.map(String) : [String(e)] : [`en`], [n] = Intl.getCanonicalLocales(t);
6470
+ return n ?? `en`;
6526
6471
  } catch {
6527
- this.locale = `en`;
6472
+ return `en`;
6528
6473
  }
6529
- if (!xe[t.style ?? `ellipsis`]) throw Error(ye(t.style ?? `ellipsis`));
6530
- let n, r;
6531
- if (t.maxChars !== void 0) {
6532
- n = t.style ?? `ellipsis`;
6533
- let e = new Intl.Locale(this.locale).language;
6534
- r = xe[n][e] || xe[n].DEFAULT_TERMINATOR_KEY;
6535
- }
6536
- let i = t.terminator ?? r?.terminator, a = i == null ? void 0 : t.separator ?? r?.separator;
6537
- this.additionLength = (i?.length ?? 0) + (a?.length ?? 0), t.maxChars !== void 0 && Math.abs(t.maxChars) < this.additionLength && (i = void 0, a = void 0), this.options = {
6538
- maxChars: t.maxChars,
6539
- style: n,
6540
- terminator: i,
6541
- separator: a
6474
+ }
6475
+ constructor(t, n = {}) {
6476
+ this.locale = e.resolveLocale(t);
6477
+ let r = n.style ?? `ellipsis`;
6478
+ if (!Oe[r]) throw Error(Ee(r));
6479
+ let i = n.maxChars === void 0 ? void 0 : Oe[r][new Intl.Locale(this.locale).language] || Oe[r].DEFAULT_TERMINATOR_KEY, a = n.terminator ?? i?.terminator, o = a == null ? void 0 : n.separator ?? i?.separator;
6480
+ this.additionLength = (a?.length ?? 0) + (o?.length ?? 0), n.maxChars !== void 0 && Math.abs(n.maxChars) < this.additionLength && (a = void 0, o = void 0), this.options = {
6481
+ maxChars: n.maxChars,
6482
+ style: n.maxChars === void 0 ? void 0 : r,
6483
+ terminator: a,
6484
+ separator: o
6542
6485
  };
6543
6486
  }
6544
6487
  format(e) {
@@ -6560,7 +6503,7 @@ var Se = class {
6560
6503
  return this.options;
6561
6504
  }
6562
6505
  };
6563
- const Ce = {
6506
+ const Ae = {
6564
6507
  Collator: Intl.Collator,
6565
6508
  DateTimeFormat: Intl.DateTimeFormat,
6566
6509
  DisplayNames: Intl.DisplayNames,
@@ -6570,83 +6513,85 @@ const Ce = {
6570
6513
  PluralRules: Intl.PluralRules,
6571
6514
  RelativeTimeFormat: Intl.RelativeTimeFormat,
6572
6515
  Segmenter: Intl.Segmenter,
6573
- CutoffFormat: Se
6574
- }, we = new class {
6516
+ CutoffFormat: ke
6517
+ }, je = new class {
6575
6518
  constructor() {
6576
6519
  this.cache = {};
6577
6520
  }
6578
- _generateKey(e, t = {}) {
6521
+ generateKey(e, t = {}) {
6579
6522
  return `${e ? Array.isArray(e) ? e.map((e) => String(e)).join(`,`) : String(e) : `undefined`}:${t ? JSON.stringify(t, Object.keys(t).sort()) : `{}`}`;
6580
6523
  }
6581
6524
  get(e, ...t) {
6582
- let [n = `en`, r = {}] = t, i = this._generateKey(n, r), a = this.cache[e]?.[i];
6583
- return a === void 0 && (a = new Ce[e](...t), this.cache[e] || (this.cache[e] = {}), this.cache[e][i] = a), a;
6525
+ let [n = `en`, r = {}] = t, i = this.generateKey(n, r), a = this.cache[e];
6526
+ a === void 0 && (a = {}, this.cache[e] = a);
6527
+ let o = a[i];
6528
+ return o === void 0 && (o = new Ae[e](...t), a[i] = o), o;
6584
6529
  }
6585
6530
  }();
6586
- function Te(e) {
6587
- return we.get(`PluralRules`, e);
6588
- }
6589
- var P = m({
6590
- __addDisposableResource: () => Ze,
6591
- __assign: () => R,
6592
- __asyncDelegator: () => Ue,
6593
- __asyncGenerator: () => He,
6594
- __asyncValues: () => We,
6595
- __await: () => I,
6596
- __awaiter: () => Fe,
6597
- __classPrivateFieldGet: () => Je,
6598
- __classPrivateFieldIn: () => Xe,
6599
- __classPrivateFieldSet: () => Ye,
6600
- __createBinding: () => z,
6601
- __decorate: () => Oe,
6602
- __disposeResources: () => Qe,
6603
- __esDecorate: () => Ae,
6604
- __exportStar: () => Le,
6605
- __extends: () => Ee,
6606
- __generator: () => Ie,
6607
- __importDefault: () => qe,
6608
- __importStar: () => Ke,
6609
- __makeTemplateObject: () => Ge,
6610
- __metadata: () => Pe,
6611
- __param: () => ke,
6612
- __propKey: () => Me,
6613
- __read: () => Re,
6614
- __rest: () => De,
6615
- __rewriteRelativeImportExtension: () => $e,
6616
- __runInitializers: () => je,
6617
- __setFunctionName: () => Ne,
6618
- __spread: () => ze,
6619
- __spreadArray: () => Ve,
6620
- __spreadArrays: () => Be,
6621
- __values: () => F,
6622
- default: () => nt
6531
+ function Me(e) {
6532
+ return je.get(`PluralRules`, e);
6533
+ }
6534
+ var M = m({
6535
+ __addDisposableResource: () => it,
6536
+ __assign: () => F,
6537
+ __asyncDelegator: () => Xe,
6538
+ __asyncGenerator: () => Ye,
6539
+ __asyncValues: () => Ze,
6540
+ __await: () => P,
6541
+ __awaiter: () => He,
6542
+ __classPrivateFieldGet: () => tt,
6543
+ __classPrivateFieldIn: () => rt,
6544
+ __classPrivateFieldSet: () => nt,
6545
+ __createBinding: () => I,
6546
+ __decorate: () => Fe,
6547
+ __disposeResources: () => at,
6548
+ __esDecorate: () => Le,
6549
+ __exportStar: () => We,
6550
+ __extends: () => Ne,
6551
+ __generator: () => Ue,
6552
+ __importDefault: () => et,
6553
+ __importStar: () => $e,
6554
+ __makeTemplateObject: () => Qe,
6555
+ __metadata: () => Ve,
6556
+ __param: () => Ie,
6557
+ __propKey: () => ze,
6558
+ __read: () => Ge,
6559
+ __rest: () => Pe,
6560
+ __rewriteRelativeImportExtension: () => ot,
6561
+ __runInitializers: () => Re,
6562
+ __setFunctionName: () => Be,
6563
+ __spread: () => Ke,
6564
+ __spreadArray: () => Je,
6565
+ __spreadArrays: () => qe,
6566
+ __values: () => N,
6567
+ default: () => ut
6623
6568
  });
6624
- function Ee(e, t) {
6569
+ function Ne(e, t) {
6625
6570
  if (typeof t != `function` && t !== null) throw TypeError(`Class extends value ` + String(t) + ` is not a constructor or null`);
6626
- L(e, t);
6571
+ st(e, t);
6627
6572
  function n() {
6628
6573
  this.constructor = e;
6629
6574
  }
6630
6575
  e.prototype = t === null ? Object.create(t) : (n.prototype = t.prototype, new n());
6631
6576
  }
6632
- function De(e, t) {
6577
+ function Pe(e, t) {
6633
6578
  var n = {};
6634
6579
  for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]);
6635
6580
  if (e != null && typeof Object.getOwnPropertySymbols == `function`) for (var i = 0, r = Object.getOwnPropertySymbols(e); i < r.length; i++) t.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[i]) && (n[r[i]] = e[r[i]]);
6636
6581
  return n;
6637
6582
  }
6638
- function Oe(e, t, n, r) {
6583
+ function Fe(e, t, n, r) {
6639
6584
  var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
6640
6585
  if (typeof Reflect == `object` && typeof Reflect.decorate == `function`) a = Reflect.decorate(e, t, n, r);
6641
6586
  else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
6642
6587
  return i > 3 && a && Object.defineProperty(t, n, a), a;
6643
6588
  }
6644
- function ke(e, t) {
6589
+ function Ie(e, t) {
6645
6590
  return function(n, r) {
6646
6591
  t(n, r, e);
6647
6592
  };
6648
6593
  }
6649
- function Ae(e, t, n, r, i, a) {
6594
+ function Le(e, t, n, r, i, a) {
6650
6595
  function o(e) {
6651
6596
  if (e !== void 0 && typeof e != `function`) throw TypeError(`Function expected`);
6652
6597
  return e;
@@ -6671,23 +6616,23 @@ function Ae(e, t, n, r, i, a) {
6671
6616
  }
6672
6617
  l && Object.defineProperty(l, r.name, u), f = !0;
6673
6618
  }
6674
- function je(e, t, n) {
6619
+ function Re(e, t, n) {
6675
6620
  for (var r = arguments.length > 2, i = 0; i < t.length; i++) n = r ? t[i].call(e, n) : t[i].call(e);
6676
6621
  return r ? n : void 0;
6677
6622
  }
6678
- function Me(e) {
6623
+ function ze(e) {
6679
6624
  return typeof e == `symbol` ? e : `${e}`;
6680
6625
  }
6681
- function Ne(e, t, n) {
6626
+ function Be(e, t, n) {
6682
6627
  return typeof t == `symbol` && (t = t.description ? `[${t.description}]` : ``), Object.defineProperty(e, `name`, {
6683
6628
  configurable: !0,
6684
6629
  value: n ? `${n} ${t}` : t
6685
6630
  });
6686
6631
  }
6687
- function Pe(e, t) {
6632
+ function Ve(e, t) {
6688
6633
  if (typeof Reflect == `object` && typeof Reflect.metadata == `function`) return Reflect.metadata(e, t);
6689
6634
  }
6690
- function Fe(e, t, n, r) {
6635
+ function He(e, t, n, r) {
6691
6636
  function i(e) {
6692
6637
  return e instanceof n ? e : new n(function(t) {
6693
6638
  t(e);
@@ -6714,7 +6659,7 @@ function Fe(e, t, n, r) {
6714
6659
  c((r = r.apply(e, t || [])).next());
6715
6660
  });
6716
6661
  }
6717
- function Ie(e, t) {
6662
+ function Ue(e, t) {
6718
6663
  var n = {
6719
6664
  label: 0,
6720
6665
  sent: function() {
@@ -6784,10 +6729,10 @@ function Ie(e, t) {
6784
6729
  };
6785
6730
  }
6786
6731
  }
6787
- function Le(e, t) {
6788
- for (var n in e) n !== `default` && !Object.prototype.hasOwnProperty.call(t, n) && z(t, e, n);
6732
+ function We(e, t) {
6733
+ for (var n in e) n !== `default` && !Object.prototype.hasOwnProperty.call(t, n) && I(t, e, n);
6789
6734
  }
6790
- function F(e) {
6735
+ function N(e) {
6791
6736
  var t = typeof Symbol == `function` && Symbol.iterator, n = t && e[t], r = 0;
6792
6737
  if (n) return n.call(e);
6793
6738
  if (e && typeof e.length == `number`) return { next: function() {
@@ -6798,7 +6743,7 @@ function F(e) {
6798
6743
  } };
6799
6744
  throw TypeError(t ? `Object is not iterable.` : `Symbol.iterator is not defined.`);
6800
6745
  }
6801
- function Re(e, t) {
6746
+ function Ge(e, t) {
6802
6747
  var n = typeof Symbol == `function` && e[Symbol.iterator];
6803
6748
  if (!n) return e;
6804
6749
  var r = n.call(e), i, a = [], o;
@@ -6815,23 +6760,23 @@ function Re(e, t) {
6815
6760
  }
6816
6761
  return a;
6817
6762
  }
6818
- function ze() {
6819
- for (var e = [], t = 0; t < arguments.length; t++) e = e.concat(Re(arguments[t]));
6763
+ function Ke() {
6764
+ for (var e = [], t = 0; t < arguments.length; t++) e = e.concat(Ge(arguments[t]));
6820
6765
  return e;
6821
6766
  }
6822
- function Be() {
6767
+ function qe() {
6823
6768
  for (var e = 0, t = 0, n = arguments.length; t < n; t++) e += arguments[t].length;
6824
6769
  for (var r = Array(e), i = 0, t = 0; t < n; t++) for (var a = arguments[t], o = 0, s = a.length; o < s; o++, i++) r[i] = a[o];
6825
6770
  return r;
6826
6771
  }
6827
- function Ve(e, t, n) {
6772
+ function Je(e, t, n) {
6828
6773
  if (n || arguments.length === 2) for (var r = 0, i = t.length, a; r < i; r++) (a || !(r in t)) && (a ||= Array.prototype.slice.call(t, 0, r), a[r] = t[r]);
6829
6774
  return e.concat(a || Array.prototype.slice.call(t));
6830
6775
  }
6831
- function I(e) {
6832
- return this instanceof I ? (this.v = e, this) : new I(e);
6776
+ function P(e) {
6777
+ return this instanceof P ? (this.v = e, this) : new P(e);
6833
6778
  }
6834
- function He(e, t, n) {
6779
+ function Ye(e, t, n) {
6835
6780
  if (!Symbol.asyncIterator) throw TypeError(`Symbol.asyncIterator is not defined.`);
6836
6781
  var r = n.apply(e, t || []), i, a = [];
6837
6782
  return i = Object.create((typeof AsyncIterator == `function` ? AsyncIterator : Object).prototype), s(`next`), s(`throw`), s(`return`, o), i[Symbol.asyncIterator] = function() {
@@ -6862,7 +6807,7 @@ function He(e, t, n) {
6862
6807
  }
6863
6808
  }
6864
6809
  function l(e) {
6865
- e.value instanceof I ? Promise.resolve(e.value.v).then(u, d) : f(a[0][2], e);
6810
+ e.value instanceof P ? Promise.resolve(e.value.v).then(u, d) : f(a[0][2], e);
6866
6811
  }
6867
6812
  function u(e) {
6868
6813
  c(`next`, e);
@@ -6874,7 +6819,7 @@ function He(e, t, n) {
6874
6819
  e(t), a.shift(), a.length && c(a[0][0], a[0][1]);
6875
6820
  }
6876
6821
  }
6877
- function Ue(e) {
6822
+ function Xe(e) {
6878
6823
  var t, n;
6879
6824
  return t = {}, r(`next`), r(`throw`, function(e) {
6880
6825
  throw e;
@@ -6884,16 +6829,16 @@ function Ue(e) {
6884
6829
  function r(r, i) {
6885
6830
  t[r] = e[r] ? function(t) {
6886
6831
  return (n = !n) ? {
6887
- value: I(e[r](t)),
6832
+ value: P(e[r](t)),
6888
6833
  done: !1
6889
6834
  } : i ? i(t) : t;
6890
6835
  } : i;
6891
6836
  }
6892
6837
  }
6893
- function We(e) {
6838
+ function Ze(e) {
6894
6839
  if (!Symbol.asyncIterator) throw TypeError(`Symbol.asyncIterator is not defined.`);
6895
6840
  var t = e[Symbol.asyncIterator], n;
6896
- return t ? t.call(e) : (e = typeof F == `function` ? F(e) : e[Symbol.iterator](), n = {}, r(`next`), r(`throw`), r(`return`), n[Symbol.asyncIterator] = function() {
6841
+ return t ? t.call(e) : (e = typeof N == `function` ? N(e) : e[Symbol.iterator](), n = {}, r(`next`), r(`throw`), r(`return`), n[Symbol.asyncIterator] = function() {
6897
6842
  return this;
6898
6843
  }, n);
6899
6844
  function r(t) {
@@ -6912,34 +6857,34 @@ function We(e) {
6912
6857
  }, t);
6913
6858
  }
6914
6859
  }
6915
- function Ge(e, t) {
6860
+ function Qe(e, t) {
6916
6861
  return Object.defineProperty ? Object.defineProperty(e, `raw`, { value: t }) : e.raw = t, e;
6917
6862
  }
6918
- function Ke(e) {
6863
+ function $e(e) {
6919
6864
  if (e && e.__esModule) return e;
6920
6865
  var t = {};
6921
- if (e != null) for (var n = B(e), r = 0; r < n.length; r++) n[r] !== `default` && z(t, e, n[r]);
6922
- return et(t, e), t;
6866
+ if (e != null) for (var n = L(e), r = 0; r < n.length; r++) n[r] !== `default` && I(t, e, n[r]);
6867
+ return ct(t, e), t;
6923
6868
  }
6924
- function qe(e) {
6869
+ function et(e) {
6925
6870
  return e && e.__esModule ? e : { default: e };
6926
6871
  }
6927
- function Je(e, t, n, r) {
6872
+ function tt(e, t, n, r) {
6928
6873
  if (n === `a` && !r) throw TypeError(`Private accessor was defined without a getter`);
6929
6874
  if (typeof t == `function` ? e !== t || !r : !t.has(e)) throw TypeError(`Cannot read private member from an object whose class did not declare it`);
6930
6875
  return n === `m` ? r : n === `a` ? r.call(e) : r ? r.value : t.get(e);
6931
6876
  }
6932
- function Ye(e, t, n, r, i) {
6877
+ function nt(e, t, n, r, i) {
6933
6878
  if (r === `m`) throw TypeError(`Private method is not writable`);
6934
6879
  if (r === `a` && !i) throw TypeError(`Private accessor was defined without a setter`);
6935
6880
  if (typeof t == `function` ? e !== t || !i : !t.has(e)) throw TypeError(`Cannot write private member to an object whose class did not declare it`);
6936
6881
  return r === `a` ? i.call(e, n) : i ? i.value = n : t.set(e, n), n;
6937
6882
  }
6938
- function Xe(e, t) {
6883
+ function rt(e, t) {
6939
6884
  if (t === null || typeof t != `object` && typeof t != `function`) throw TypeError(`Cannot use 'in' operator on non-object`);
6940
6885
  return typeof e == `function` ? t === e : e.has(t);
6941
6886
  }
6942
- function Ze(e, t, n) {
6887
+ function it(e, t, n) {
6943
6888
  if (t != null) {
6944
6889
  if (typeof t != `object` && typeof t != `function`) throw TypeError(`Object expected.`);
6945
6890
  var r, i;
@@ -6966,9 +6911,9 @@ function Ze(e, t, n) {
6966
6911
  } else n && e.stack.push({ async: !0 });
6967
6912
  return t;
6968
6913
  }
6969
- function Qe(e) {
6914
+ function at(e) {
6970
6915
  function t(t) {
6971
- e.error = e.hasError ? new tt(t, e.error, `An error was suppressed during disposal.`) : t, e.hasError = !0;
6916
+ e.error = e.hasError ? new lt(t, e.error, `An error was suppressed during disposal.`) : t, e.hasError = !0;
6972
6917
  }
6973
6918
  var n, r = 0;
6974
6919
  function i() {
@@ -6988,24 +6933,24 @@ function Qe(e) {
6988
6933
  }
6989
6934
  return i();
6990
6935
  }
6991
- function $e(e, t) {
6936
+ function ot(e, t) {
6992
6937
  return typeof e == `string` && /^\.\.?\//.test(e) ? e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(e, n, r, i, a) {
6993
6938
  return n ? t ? `.jsx` : `.js` : r && (!i || !a) ? e : r + i + `.` + a.toLowerCase() + `js`;
6994
6939
  }) : e;
6995
6940
  }
6996
- var L, R, z, et, B, tt, nt, V = f((() => {
6997
- L = function(e, t) {
6998
- return L = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, t) {
6941
+ var st, F, I, ct, L, lt, ut, R = f((() => {
6942
+ st = function(e, t) {
6943
+ return st = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, t) {
6999
6944
  e.__proto__ = t;
7000
6945
  } || function(e, t) {
7001
6946
  for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
7002
- }, L(e, t);
7003
- }, R = function() {
7004
- return R = Object.assign || function(e) {
6947
+ }, st(e, t);
6948
+ }, F = function() {
6949
+ return F = Object.assign || function(e) {
7005
6950
  for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n], t) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
7006
6951
  return e;
7007
- }, R.apply(this, arguments);
7008
- }, z = Object.create ? (function(e, t, n, r) {
6952
+ }, F.apply(this, arguments);
6953
+ }, I = Object.create ? (function(e, t, n, r) {
7009
6954
  r === void 0 && (r = n);
7010
6955
  var i = Object.getOwnPropertyDescriptor(t, n);
7011
6956
  (!i || (`get` in i ? !t.__esModule : i.writable || i.configurable)) && (i = {
@@ -7016,63 +6961,63 @@ var L, R, z, et, B, tt, nt, V = f((() => {
7016
6961
  }), Object.defineProperty(e, r, i);
7017
6962
  }) : (function(e, t, n, r) {
7018
6963
  r === void 0 && (r = n), e[r] = t[n];
7019
- }), et = Object.create ? (function(e, t) {
6964
+ }), ct = Object.create ? (function(e, t) {
7020
6965
  Object.defineProperty(e, `default`, {
7021
6966
  enumerable: !0,
7022
6967
  value: t
7023
6968
  });
7024
6969
  }) : function(e, t) {
7025
6970
  e.default = t;
7026
- }, B = function(e) {
7027
- return B = Object.getOwnPropertyNames || function(e) {
6971
+ }, L = function(e) {
6972
+ return L = Object.getOwnPropertyNames || function(e) {
7028
6973
  var t = [];
7029
6974
  for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && (t[t.length] = n);
7030
6975
  return t;
7031
- }, B(e);
7032
- }, tt = typeof SuppressedError == `function` ? SuppressedError : function(e, t, n) {
6976
+ }, L(e);
6977
+ }, lt = typeof SuppressedError == `function` ? SuppressedError : function(e, t, n) {
7033
6978
  var r = Error(n);
7034
6979
  return r.name = `SuppressedError`, r.error = e, r.suppressed = t, r;
7035
- }, nt = {
7036
- __extends: Ee,
7037
- __assign: R,
7038
- __rest: De,
7039
- __decorate: Oe,
7040
- __param: ke,
7041
- __esDecorate: Ae,
7042
- __runInitializers: je,
7043
- __propKey: Me,
7044
- __setFunctionName: Ne,
7045
- __metadata: Pe,
7046
- __awaiter: Fe,
7047
- __generator: Ie,
7048
- __createBinding: z,
7049
- __exportStar: Le,
7050
- __values: F,
7051
- __read: Re,
7052
- __spread: ze,
7053
- __spreadArrays: Be,
7054
- __spreadArray: Ve,
7055
- __await: I,
7056
- __asyncGenerator: He,
7057
- __asyncDelegator: Ue,
7058
- __asyncValues: We,
7059
- __makeTemplateObject: Ge,
7060
- __importStar: Ke,
7061
- __importDefault: qe,
7062
- __classPrivateFieldGet: Je,
7063
- __classPrivateFieldSet: Ye,
7064
- __classPrivateFieldIn: Xe,
7065
- __addDisposableResource: Ze,
7066
- __disposeResources: Qe,
7067
- __rewriteRelativeImportExtension: $e
6980
+ }, ut = {
6981
+ __extends: Ne,
6982
+ __assign: F,
6983
+ __rest: Pe,
6984
+ __decorate: Fe,
6985
+ __param: Ie,
6986
+ __esDecorate: Le,
6987
+ __runInitializers: Re,
6988
+ __propKey: ze,
6989
+ __setFunctionName: Be,
6990
+ __metadata: Ve,
6991
+ __awaiter: He,
6992
+ __generator: Ue,
6993
+ __createBinding: I,
6994
+ __exportStar: We,
6995
+ __values: N,
6996
+ __read: Ge,
6997
+ __spread: Ke,
6998
+ __spreadArrays: qe,
6999
+ __spreadArray: Je,
7000
+ __await: P,
7001
+ __asyncGenerator: Ye,
7002
+ __asyncDelegator: Xe,
7003
+ __asyncValues: Ze,
7004
+ __makeTemplateObject: Qe,
7005
+ __importStar: $e,
7006
+ __importDefault: et,
7007
+ __classPrivateFieldGet: tt,
7008
+ __classPrivateFieldSet: nt,
7009
+ __classPrivateFieldIn: rt,
7010
+ __addDisposableResource: it,
7011
+ __disposeResources: at,
7012
+ __rewriteRelativeImportExtension: ot
7068
7013
  };
7069
- })), rt = p(((e) => {
7014
+ })), dt = p(((e) => {
7070
7015
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.ErrorKind = void 0;
7071
7016
  var t;
7072
7017
  (function(e) {
7073
7018
  e[e.EXPECT_ARGUMENT_CLOSING_BRACE = 1] = `EXPECT_ARGUMENT_CLOSING_BRACE`, e[e.EMPTY_ARGUMENT = 2] = `EMPTY_ARGUMENT`, e[e.MALFORMED_ARGUMENT = 3] = `MALFORMED_ARGUMENT`, e[e.EXPECT_ARGUMENT_TYPE = 4] = `EXPECT_ARGUMENT_TYPE`, e[e.INVALID_ARGUMENT_TYPE = 5] = `INVALID_ARGUMENT_TYPE`, e[e.EXPECT_ARGUMENT_STYLE = 6] = `EXPECT_ARGUMENT_STYLE`, e[e.INVALID_NUMBER_SKELETON = 7] = `INVALID_NUMBER_SKELETON`, e[e.INVALID_DATE_TIME_SKELETON = 8] = `INVALID_DATE_TIME_SKELETON`, e[e.EXPECT_NUMBER_SKELETON = 9] = `EXPECT_NUMBER_SKELETON`, e[e.EXPECT_DATE_TIME_SKELETON = 10] = `EXPECT_DATE_TIME_SKELETON`, e[e.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE = 11] = `UNCLOSED_QUOTE_IN_ARGUMENT_STYLE`, e[e.EXPECT_SELECT_ARGUMENT_OPTIONS = 12] = `EXPECT_SELECT_ARGUMENT_OPTIONS`, e[e.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE = 13] = `EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE`, e[e.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE = 14] = `INVALID_PLURAL_ARGUMENT_OFFSET_VALUE`, e[e.EXPECT_SELECT_ARGUMENT_SELECTOR = 15] = `EXPECT_SELECT_ARGUMENT_SELECTOR`, e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR = 16] = `EXPECT_PLURAL_ARGUMENT_SELECTOR`, e[e.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT = 17] = `EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT`, e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT = 18] = `EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT`, e[e.INVALID_PLURAL_ARGUMENT_SELECTOR = 19] = `INVALID_PLURAL_ARGUMENT_SELECTOR`, e[e.DUPLICATE_PLURAL_ARGUMENT_SELECTOR = 20] = `DUPLICATE_PLURAL_ARGUMENT_SELECTOR`, e[e.DUPLICATE_SELECT_ARGUMENT_SELECTOR = 21] = `DUPLICATE_SELECT_ARGUMENT_SELECTOR`, e[e.MISSING_OTHER_CLAUSE = 22] = `MISSING_OTHER_CLAUSE`, e[e.INVALID_TAG = 23] = `INVALID_TAG`, e[e.INVALID_TAG_NAME = 25] = `INVALID_TAG_NAME`, e[e.UNMATCHED_CLOSING_TAG = 26] = `UNMATCHED_CLOSING_TAG`, e[e.UNCLOSED_TAG = 27] = `UNCLOSED_TAG`;
7074
7019
  })(t || (e.ErrorKind = t = {}));
7075
- })), H = p(((e) => {
7020
+ })), z = p(((e) => {
7076
7021
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.SKELETON_TYPE = e.TYPE = void 0, e.isLiteralElement = r, e.isArgumentElement = i, e.isNumberElement = a, e.isDateElement = o, e.isTimeElement = s, e.isSelectElement = c, e.isPluralElement = l, e.isPoundElement = u, e.isTagElement = d, e.isNumberSkeleton = f, e.isDateTimeSkeleton = p, e.createLiteralElement = m, e.createNumberElement = h;
7077
7022
  var t;
7078
7023
  (function(e) {
@@ -7128,9 +7073,9 @@ var L, R, z, et, B, tt, nt, V = f((() => {
7128
7073
  style: n
7129
7074
  };
7130
7075
  }
7131
- })), it = p(((e) => {
7076
+ })), ft = p(((e) => {
7132
7077
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.WHITE_SPACE_REGEX = e.SPACE_SEPARATOR_REGEX = void 0, e.SPACE_SEPARATOR_REGEX = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/, e.WHITE_SPACE_REGEX = /[\t-\r \x85\u200E\u200F\u2028\u2029]/;
7133
- })), at = p(((e) => {
7078
+ })), pt = p(((e) => {
7134
7079
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.parseDateTimeSkeleton = n;
7135
7080
  var t = /(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;
7136
7081
  function n(e) {
@@ -7230,11 +7175,11 @@ var L, R, z, et, B, tt, nt, V = f((() => {
7230
7175
  return ``;
7231
7176
  }), n;
7232
7177
  }
7233
- })), ot = p(((e) => {
7178
+ })), mt = p(((e) => {
7234
7179
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.WHITE_SPACE_REGEX = void 0, e.WHITE_SPACE_REGEX = /[\t-\r \x85\u200E\u200F\u2028\u2029]/i;
7235
- })), st = p(((e) => {
7180
+ })), ht = p(((e) => {
7236
7181
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.parseNumberSkeletonFromString = r, e.parseNumberSkeleton = p;
7237
- var t = (V(), g(P)), n = ot();
7182
+ var t = (R(), g(M)), n = mt();
7238
7183
  function r(e) {
7239
7184
  if (e.length === 0) throw Error(`Number skeleton cannot be empty`);
7240
7185
  for (var t = e.split(n.WHITE_SPACE_REGEX).filter(function(e) {
@@ -7412,11 +7357,11 @@ var L, R, z, et, B, tt, nt, V = f((() => {
7412
7357
  }
7413
7358
  return n;
7414
7359
  }
7415
- })), ct = p(((e) => {
7360
+ })), gt = p(((e) => {
7416
7361
  Object.defineProperty(e, `__esModule`, { value: !0 });
7417
- var t = (V(), g(P));
7418
- t.__exportStar(at(), e), t.__exportStar(st(), e);
7419
- })), lt = p(((e) => {
7362
+ var t = (R(), g(M));
7363
+ t.__exportStar(pt(), e), t.__exportStar(ht(), e);
7364
+ })), _t = p(((e) => {
7420
7365
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.timeData = void 0, e.timeData = {
7421
7366
  "001": [`H`, `h`],
7422
7367
  419: [
@@ -8573,9 +8518,9 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8573
8518
  `h`
8574
8519
  ]
8575
8520
  };
8576
- })), ut = p(((e) => {
8521
+ })), vt = p(((e) => {
8577
8522
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.getBestPattern = n;
8578
- var t = lt();
8523
+ var t = _t();
8579
8524
  function n(e, t) {
8580
8525
  for (var n = ``, i = 0; i < e.length; i++) {
8581
8526
  var a = e.charAt(i);
@@ -8600,9 +8545,9 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8600
8545
  var r = e.language, i;
8601
8546
  return r !== `root` && (i = e.maximize().region), (t.timeData[i || ``] || t.timeData[r || ``] || t.timeData[`${r}-001`] || t.timeData[`001`])[0];
8602
8547
  }
8603
- })), dt = p(((e) => {
8548
+ })), yt = p(((e) => {
8604
8549
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.Parser = void 0;
8605
- var t = (V(), g(P)), n = rt(), r = H(), i = it(), a = ct(), o = ut(), s = RegExp(`^${i.SPACE_SEPARATOR_REGEX.source}*`), c = RegExp(`${i.SPACE_SEPARATOR_REGEX.source}*\$`);
8550
+ var t = (R(), g(M)), n = dt(), r = z(), i = ft(), a = gt(), o = vt(), s = RegExp(`^${i.SPACE_SEPARATOR_REGEX.source}*`), c = RegExp(`${i.SPACE_SEPARATOR_REGEX.source}*\$`);
8606
8551
  function l(e, t) {
8607
8552
  return {
8608
8553
  start: e,
@@ -8613,21 +8558,21 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8613
8558
  return typeof e == `number` && isFinite(e) && Math.floor(e) === e && Math.abs(e) <= 9007199254740991;
8614
8559
  }, v = !0;
8615
8560
  try {
8616
- v = C(`([^\\p{White_Space}\\p{Pattern_Syntax}]*)`, `yu`).exec(`a`)?.[0] === `a`;
8561
+ v = S(`([^\\p{White_Space}\\p{Pattern_Syntax}]*)`, `yu`).exec(`a`)?.[0] === `a`;
8617
8562
  } catch {
8618
8563
  v = !1;
8619
8564
  }
8620
- var y = u ? function(e, t, n) {
8565
+ var ee = u ? function(e, t, n) {
8621
8566
  return e.startsWith(t, n);
8622
8567
  } : function(e, t, n) {
8623
8568
  return e.slice(n, n + t.length) === t;
8624
- }, b = d ? String.fromCodePoint : function() {
8569
+ }, y = d ? String.fromCodePoint : function() {
8625
8570
  for (var e = [...arguments], t = ``, n = e.length, r = 0, i; n > r;) {
8626
8571
  if (i = e[r++], i > 1114111) throw RangeError(i + ` is not a valid code point`);
8627
8572
  t += i < 65536 ? String.fromCharCode(i) : String.fromCharCode(((i -= 65536) >> 10) + 55296, i % 1024 + 56320);
8628
8573
  }
8629
8574
  return t;
8630
- }, ee = f ? Object.fromEntries : function(e) {
8575
+ }, b = f ? Object.fromEntries : function(e) {
8631
8576
  for (var t = {}, n = 0, r = e; n < r.length; n++) {
8632
8577
  var i = r[n], a = i[0];
8633
8578
  t[a] = i[1];
@@ -8641,31 +8586,31 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8641
8586
  var r = e.charCodeAt(t), i;
8642
8587
  return r < 55296 || r > 56319 || t + 1 === n || (i = e.charCodeAt(t + 1)) < 56320 || i > 57343 ? r : (r - 55296 << 10) + (i - 56320) + 65536;
8643
8588
  }
8644
- }, S = m ? function(e) {
8589
+ }, te = m ? function(e) {
8645
8590
  return e.trimStart();
8646
8591
  } : function(e) {
8647
8592
  return e.replace(s, ``);
8648
- }, te = h ? function(e) {
8593
+ }, ne = h ? function(e) {
8649
8594
  return e.trimEnd();
8650
8595
  } : function(e) {
8651
8596
  return e.replace(c, ``);
8652
8597
  };
8653
- function C(e, t) {
8598
+ function S(e, t) {
8654
8599
  return new RegExp(e, t);
8655
8600
  }
8656
- var w;
8601
+ var C;
8657
8602
  if (v) {
8658
- var T = C(`([^\\p{White_Space}\\p{Pattern_Syntax}]*)`, `yu`);
8659
- w = function(e, t) {
8660
- return T.lastIndex = t, T.exec(e)[1] ?? ``;
8603
+ var w = S(`([^\\p{White_Space}\\p{Pattern_Syntax}]*)`, `yu`);
8604
+ C = function(e, t) {
8605
+ return w.lastIndex = t, w.exec(e)[1] ?? ``;
8661
8606
  };
8662
- } else w = function(e, t) {
8607
+ } else C = function(e, t) {
8663
8608
  for (var n = [];;) {
8664
8609
  var r = x(e, t);
8665
- if (r === void 0 || k(r) || A(r)) break;
8610
+ if (r === void 0 || ie(r) || D(r)) break;
8666
8611
  n.push(r), t += r >= 65536 ? 2 : 1;
8667
8612
  }
8668
- return b.apply(void 0, n);
8613
+ return y.apply(void 0, n);
8669
8614
  };
8670
8615
  e.Parser = function() {
8671
8616
  function e(e, t) {
@@ -8695,7 +8640,7 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8695
8640
  } else if (o === 60 && !this.ignoreTag && this.peek() === 47) {
8696
8641
  if (i) break;
8697
8642
  return this.error(n.ErrorKind.UNMATCHED_CLOSING_TAG, l(this.clonePosition(), this.clonePosition()));
8698
- } else if (o === 60 && !this.ignoreTag && E(this.peek() || 0)) {
8643
+ } else if (o === 60 && !this.ignoreTag && T(this.peek() || 0)) {
8699
8644
  var s = this.parseTag(e, t);
8700
8645
  if (s.err) return s;
8701
8646
  a.push(s.val);
@@ -8726,7 +8671,7 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8726
8671
  if (o.err) return o;
8727
8672
  var s = o.val, c = this.clonePosition();
8728
8673
  if (this.bumpIf(`</`)) {
8729
- if (this.isEOF() || !E(this.char())) return this.error(n.ErrorKind.INVALID_TAG, l(c, this.clonePosition()));
8674
+ if (this.isEOF() || !T(this.char())) return this.error(n.ErrorKind.INVALID_TAG, l(c, this.clonePosition()));
8730
8675
  var u = this.clonePosition();
8731
8676
  return a === this.parseTagName() ? (this.bumpSpace(), this.bumpIf(`>`) ? {
8732
8677
  val: {
@@ -8741,7 +8686,7 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8741
8686
  } else return this.error(n.ErrorKind.INVALID_TAG, l(i, this.clonePosition()));
8742
8687
  }, e.prototype.parseTagName = function() {
8743
8688
  var e = this.offset();
8744
- for (this.bump(); !this.isEOF() && O(this.char());) this.bump();
8689
+ for (this.bump(); !this.isEOF() && E(this.char());) this.bump();
8745
8690
  return this.message.slice(e, this.offset());
8746
8691
  }, e.prototype.parseLiteral = function(e, t) {
8747
8692
  for (var n = this.clonePosition(), i = ``;;) {
@@ -8772,7 +8717,7 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8772
8717
  err: null
8773
8718
  };
8774
8719
  }, e.prototype.tryParseLeftAngleBracket = function() {
8775
- return !this.isEOF() && this.char() === 60 && (this.ignoreTag || !D(this.peek() || 0)) ? (this.bump(), `<`) : null;
8720
+ return !this.isEOF() && this.char() === 60 && (this.ignoreTag || !re(this.peek() || 0)) ? (this.bump(), `<`) : null;
8776
8721
  }, e.prototype.tryParseQuote = function(e) {
8777
8722
  if (this.isEOF() || this.char() !== 39) return null;
8778
8723
  switch (this.peek()) {
@@ -8798,11 +8743,11 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8798
8743
  else t.push(n);
8799
8744
  this.bump();
8800
8745
  }
8801
- return b.apply(void 0, t);
8746
+ return y.apply(void 0, t);
8802
8747
  }, e.prototype.tryParseUnquoted = function(e, t) {
8803
8748
  if (this.isEOF()) return null;
8804
8749
  var n = this.char();
8805
- return n === 60 || n === 123 || n === 35 && (t === `plural` || t === `selectordinal`) || n === 125 && e > 0 ? null : (this.bump(), b(n));
8750
+ return n === 60 || n === 123 || n === 35 && (t === `plural` || t === `selectordinal`) || n === 125 && e > 0 ? null : (this.bump(), y(n));
8806
8751
  }, e.prototype.parseArgument = function(e, t) {
8807
8752
  var i = this.clonePosition();
8808
8753
  if (this.bump(), this.bumpSpace(), this.isEOF()) return this.error(n.ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, l(i, this.clonePosition()));
@@ -8823,7 +8768,7 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8823
8768
  default: return this.error(n.ErrorKind.MALFORMED_ARGUMENT, l(i, this.clonePosition()));
8824
8769
  }
8825
8770
  }, e.prototype.parseIdentifierIfPossible = function() {
8826
- var e = this.clonePosition(), t = this.offset(), n = w(this.message, t), r = t + n.length;
8771
+ var e = this.clonePosition(), t = this.offset(), n = C(this.message, t), r = t + n.length;
8827
8772
  return this.bumpTo(r), {
8828
8773
  value: n,
8829
8774
  location: l(e, this.clonePosition())
@@ -8841,7 +8786,7 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8841
8786
  this.bumpSpace();
8842
8787
  var m = this.clonePosition(), h = this.parseSimpleArgStyleIfPossible();
8843
8788
  if (h.err) return h;
8844
- var g = te(h.val);
8789
+ var g = ne(h.val);
8845
8790
  if (g.length === 0) return this.error(n.ErrorKind.EXPECT_ARGUMENT_STYLE, l(this.clonePosition(), this.clonePosition()));
8846
8791
  p = {
8847
8792
  style: g,
@@ -8851,10 +8796,10 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8851
8796
  var _ = this.tryParseArgumentClose(c);
8852
8797
  if (_.err) return _;
8853
8798
  var v = l(c, this.clonePosition());
8854
- if (p && y(p?.style, `::`, 0)) {
8855
- var b = S(p.style.slice(2));
8799
+ if (p && ee(p?.style, `::`, 0)) {
8800
+ var y = te(p.style.slice(2));
8856
8801
  if (d === `number`) {
8857
- var h = this.parseNumberSkeletonFromString(b, p.styleLocation);
8802
+ var h = this.parseNumberSkeletonFromString(y, p.styleLocation);
8858
8803
  return h.err ? h : {
8859
8804
  val: {
8860
8805
  type: r.TYPE.number,
@@ -8865,9 +8810,9 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8865
8810
  err: null
8866
8811
  };
8867
8812
  } else {
8868
- if (b.length === 0) return this.error(n.ErrorKind.EXPECT_DATE_TIME_SKELETON, v);
8869
- var x = b;
8870
- this.locale && (x = (0, o.getBestPattern)(b, this.locale));
8813
+ if (y.length === 0) return this.error(n.ErrorKind.EXPECT_DATE_TIME_SKELETON, v);
8814
+ var x = y;
8815
+ this.locale && (x = (0, o.getBestPattern)(y, this.locale));
8871
8816
  var g = {
8872
8817
  type: r.SKELETON_TYPE.dateTime,
8873
8818
  pattern: x,
@@ -8897,38 +8842,38 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8897
8842
  case `plural`:
8898
8843
  case `selectordinal`:
8899
8844
  case `select`:
8900
- var C = this.clonePosition();
8901
- if (this.bumpSpace(), !this.bumpIf(`,`)) return this.error(n.ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, l(C, t.__assign({}, C)));
8845
+ var S = this.clonePosition();
8846
+ if (this.bumpSpace(), !this.bumpIf(`,`)) return this.error(n.ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, l(S, t.__assign({}, S)));
8902
8847
  this.bumpSpace();
8903
- var w = this.parseIdentifierIfPossible(), T = 0;
8904
- if (d !== `select` && w.value === `offset`) {
8848
+ var C = this.parseIdentifierIfPossible(), w = 0;
8849
+ if (d !== `select` && C.value === `offset`) {
8905
8850
  if (!this.bumpIf(`:`)) return this.error(n.ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, l(this.clonePosition(), this.clonePosition()));
8906
8851
  this.bumpSpace();
8907
8852
  var h = this.tryParseDecimalInteger(n.ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, n.ErrorKind.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);
8908
8853
  if (h.err) return h;
8909
- this.bumpSpace(), w = this.parseIdentifierIfPossible(), T = h.val;
8854
+ this.bumpSpace(), C = this.parseIdentifierIfPossible(), w = h.val;
8910
8855
  }
8911
- var E = this.tryParsePluralOrSelectOptions(e, d, i, w);
8912
- if (E.err) return E;
8856
+ var T = this.tryParsePluralOrSelectOptions(e, d, i, C);
8857
+ if (T.err) return T;
8913
8858
  var _ = this.tryParseArgumentClose(c);
8914
8859
  if (_.err) return _;
8915
- var D = l(c, this.clonePosition());
8860
+ var re = l(c, this.clonePosition());
8916
8861
  return d === `select` ? {
8917
8862
  val: {
8918
8863
  type: r.TYPE.select,
8919
8864
  value: s,
8920
- options: ee(E.val),
8921
- location: D
8865
+ options: b(T.val),
8866
+ location: re
8922
8867
  },
8923
8868
  err: null
8924
8869
  } : {
8925
8870
  val: {
8926
8871
  type: r.TYPE.plural,
8927
8872
  value: s,
8928
- options: ee(E.val),
8929
- offset: T,
8873
+ options: b(T.val),
8874
+ offset: w,
8930
8875
  pluralType: d === `plural` ? `cardinal` : `ordinal`,
8931
- location: D
8876
+ location: re
8932
8877
  },
8933
8878
  err: null
8934
8879
  };
@@ -9052,7 +8997,7 @@ var L, R, z, et, B, tt, nt, V = f((() => {
9052
8997
  e === 10 ? (this.position.line += 1, this.position.column = 1, this.position.offset += 1) : (this.position.column += 1, this.position.offset += e < 65536 ? 1 : 2);
9053
8998
  }
9054
8999
  }, e.prototype.bumpIf = function(e) {
9055
- if (y(this.message, e, this.offset())) {
9000
+ if (ee(this.message, e, this.offset())) {
9056
9001
  for (var t = 0; t < e.length; t++) this.bump();
9057
9002
  return !0;
9058
9003
  }
@@ -9069,31 +9014,31 @@ var L, R, z, et, B, tt, nt, V = f((() => {
9069
9014
  if (this.bump(), this.isEOF()) break;
9070
9015
  }
9071
9016
  }, e.prototype.bumpSpace = function() {
9072
- for (; !this.isEOF() && k(this.char());) this.bump();
9017
+ for (; !this.isEOF() && ie(this.char());) this.bump();
9073
9018
  }, e.prototype.peek = function() {
9074
9019
  if (this.isEOF()) return null;
9075
9020
  var e = this.char(), t = this.offset();
9076
9021
  return this.message.charCodeAt(t + (e >= 65536 ? 2 : 1)) ?? null;
9077
9022
  }, e;
9078
9023
  }();
9079
- function E(e) {
9024
+ function T(e) {
9080
9025
  return e >= 97 && e <= 122 || e >= 65 && e <= 90;
9081
9026
  }
9082
- function D(e) {
9083
- return E(e) || e === 47;
9027
+ function re(e) {
9028
+ return T(e) || e === 47;
9084
9029
  }
9085
- function O(e) {
9030
+ function E(e) {
9086
9031
  return e === 45 || e === 46 || e >= 48 && e <= 57 || e === 95 || e >= 97 && e <= 122 || e >= 65 && e <= 90 || e == 183 || e >= 192 && e <= 214 || e >= 216 && e <= 246 || e >= 248 && e <= 893 || e >= 895 && e <= 8191 || e >= 8204 && e <= 8205 || e >= 8255 && e <= 8256 || e >= 8304 && e <= 8591 || e >= 11264 && e <= 12271 || e >= 12289 && e <= 55295 || e >= 63744 && e <= 64975 || e >= 65008 && e <= 65533 || e >= 65536 && e <= 983039;
9087
9032
  }
9088
- function k(e) {
9033
+ function ie(e) {
9089
9034
  return e >= 9 && e <= 13 || e === 32 || e === 133 || e >= 8206 && e <= 8207 || e === 8232 || e === 8233;
9090
9035
  }
9091
- function A(e) {
9036
+ function D(e) {
9092
9037
  return e >= 33 && e <= 35 || e === 36 || e >= 37 && e <= 39 || e === 40 || e === 41 || e === 42 || e === 43 || e === 44 || e === 45 || e >= 46 && e <= 47 || e >= 58 && e <= 59 || e >= 60 && e <= 62 || e >= 63 && e <= 64 || e === 91 || e === 92 || e === 93 || e === 94 || e === 96 || e === 123 || e === 124 || e === 125 || e === 126 || e === 161 || e >= 162 && e <= 165 || e === 166 || e === 167 || e === 169 || e === 171 || e === 172 || e === 174 || e === 176 || e === 177 || e === 182 || e === 187 || e === 191 || e === 215 || e === 247 || e >= 8208 && e <= 8213 || e >= 8214 && e <= 8215 || e === 8216 || e === 8217 || e === 8218 || e >= 8219 && e <= 8220 || e === 8221 || e === 8222 || e === 8223 || e >= 8224 && e <= 8231 || e >= 8240 && e <= 8248 || e === 8249 || e === 8250 || e >= 8251 && e <= 8254 || e >= 8257 && e <= 8259 || e === 8260 || e === 8261 || e === 8262 || e >= 8263 && e <= 8273 || e === 8274 || e === 8275 || e >= 8277 && e <= 8286 || e >= 8592 && e <= 8596 || e >= 8597 && e <= 8601 || e >= 8602 && e <= 8603 || e >= 8604 && e <= 8607 || e === 8608 || e >= 8609 && e <= 8610 || e === 8611 || e >= 8612 && e <= 8613 || e === 8614 || e >= 8615 && e <= 8621 || e === 8622 || e >= 8623 && e <= 8653 || e >= 8654 && e <= 8655 || e >= 8656 && e <= 8657 || e === 8658 || e === 8659 || e === 8660 || e >= 8661 && e <= 8691 || e >= 8692 && e <= 8959 || e >= 8960 && e <= 8967 || e === 8968 || e === 8969 || e === 8970 || e === 8971 || e >= 8972 && e <= 8991 || e >= 8992 && e <= 8993 || e >= 8994 && e <= 9e3 || e === 9001 || e === 9002 || e >= 9003 && e <= 9083 || e === 9084 || e >= 9085 && e <= 9114 || e >= 9115 && e <= 9139 || e >= 9140 && e <= 9179 || e >= 9180 && e <= 9185 || e >= 9186 && e <= 9254 || e >= 9255 && e <= 9279 || e >= 9280 && e <= 9290 || e >= 9291 && e <= 9311 || e >= 9472 && e <= 9654 || e === 9655 || e >= 9656 && e <= 9664 || e === 9665 || e >= 9666 && e <= 9719 || e >= 9720 && e <= 9727 || e >= 9728 && e <= 9838 || e === 9839 || e >= 9840 && e <= 10087 || e === 10088 || e === 10089 || e === 10090 || e === 10091 || e === 10092 || e === 10093 || e === 10094 || e === 10095 || e === 10096 || e === 10097 || e === 10098 || e === 10099 || e === 10100 || e === 10101 || e >= 10132 && e <= 10175 || e >= 10176 && e <= 10180 || e === 10181 || e === 10182 || e >= 10183 && e <= 10213 || e === 10214 || e === 10215 || e === 10216 || e === 10217 || e === 10218 || e === 10219 || e === 10220 || e === 10221 || e === 10222 || e === 10223 || e >= 10224 && e <= 10239 || e >= 10240 && e <= 10495 || e >= 10496 && e <= 10626 || e === 10627 || e === 10628 || e === 10629 || e === 10630 || e === 10631 || e === 10632 || e === 10633 || e === 10634 || e === 10635 || e === 10636 || e === 10637 || e === 10638 || e === 10639 || e === 10640 || e === 10641 || e === 10642 || e === 10643 || e === 10644 || e === 10645 || e === 10646 || e === 10647 || e === 10648 || e >= 10649 && e <= 10711 || e === 10712 || e === 10713 || e === 10714 || e === 10715 || e >= 10716 && e <= 10747 || e === 10748 || e === 10749 || e >= 10750 && e <= 11007 || e >= 11008 && e <= 11055 || e >= 11056 && e <= 11076 || e >= 11077 && e <= 11078 || e >= 11079 && e <= 11084 || e >= 11085 && e <= 11123 || e >= 11124 && e <= 11125 || e >= 11126 && e <= 11157 || e === 11158 || e >= 11159 && e <= 11263 || e >= 11776 && e <= 11777 || e === 11778 || e === 11779 || e === 11780 || e === 11781 || e >= 11782 && e <= 11784 || e === 11785 || e === 11786 || e === 11787 || e === 11788 || e === 11789 || e >= 11790 && e <= 11798 || e === 11799 || e >= 11800 && e <= 11801 || e === 11802 || e === 11803 || e === 11804 || e === 11805 || e >= 11806 && e <= 11807 || e === 11808 || e === 11809 || e === 11810 || e === 11811 || e === 11812 || e === 11813 || e === 11814 || e === 11815 || e === 11816 || e === 11817 || e >= 11818 && e <= 11822 || e === 11823 || e >= 11824 && e <= 11833 || e >= 11834 && e <= 11835 || e >= 11836 && e <= 11839 || e === 11840 || e === 11841 || e === 11842 || e >= 11843 && e <= 11855 || e >= 11856 && e <= 11857 || e === 11858 || e >= 11859 && e <= 11903 || e >= 12289 && e <= 12291 || e === 12296 || e === 12297 || e === 12298 || e === 12299 || e === 12300 || e === 12301 || e === 12302 || e === 12303 || e === 12304 || e === 12305 || e >= 12306 && e <= 12307 || e === 12308 || e === 12309 || e === 12310 || e === 12311 || e === 12312 || e === 12313 || e === 12314 || e === 12315 || e === 12316 || e === 12317 || e >= 12318 && e <= 12319 || e === 12320 || e === 12336 || e === 64830 || e === 64831 || e >= 65093 && e <= 65094;
9093
9038
  }
9094
- })), ft = p(((e) => {
9039
+ })), bt = p(((e) => {
9095
9040
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.hoistSelectors = s, e.isStructurallySame = l;
9096
- var t = (V(), g(P)), n = H();
9041
+ var t = (R(), g(M)), n = z();
9097
9042
  function r(e) {
9098
9043
  return Array.isArray(e) ? t.__spreadArray([], e.map(r), !0) : typeof e == `object` && e ? Object.keys(e).reduce(function(t, n) {
9099
9044
  return t[n] = r(e[n]), t;
@@ -9150,9 +9095,9 @@ var L, R, z, et, B, tt, nt, V = f((() => {
9150
9095
  error: Error(`Different number of variables: [${Array.from(r.keys()).join(`, `)}] vs [${Array.from(i.keys()).join(`, `)}]`)
9151
9096
  };
9152
9097
  }
9153
- })), pt = p(((e) => {
9098
+ })), xt = p(((e) => {
9154
9099
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.isStructurallySame = e._Parser = void 0, e.parse = o;
9155
- var t = (V(), g(P)), n = rt(), r = dt(), i = H();
9100
+ var t = (R(), g(M)), n = dt(), r = yt(), i = z();
9156
9101
  function a(e) {
9157
9102
  e.forEach(function(e) {
9158
9103
  if (delete e.location, (0, i.isSelectElement)(e) || (0, i.isPluralElement)(e)) for (var t in e.options) delete e.options[t].location, a(e.options[t].value);
@@ -9171,17 +9116,17 @@ var L, R, z, et, B, tt, nt, V = f((() => {
9171
9116
  }
9172
9117
  return i?.captureLocation || a(o.val), o.val;
9173
9118
  }
9174
- t.__exportStar(H(), e), e._Parser = r.Parser;
9175
- var s = ft();
9119
+ t.__exportStar(z(), e), e._Parser = r.Parser;
9120
+ var s = bt();
9176
9121
  Object.defineProperty(e, `isStructurallySame`, {
9177
9122
  enumerable: !0,
9178
9123
  get: function() {
9179
9124
  return s.isStructurallySame;
9180
9125
  }
9181
9126
  });
9182
- })), mt = p(((e) => {
9127
+ })), St = p(((e) => {
9183
9128
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.printAST = r;
9184
- var t = (V(), g(P)), n = H();
9129
+ var t = (R(), g(M)), n = z();
9185
9130
  function r(e) {
9186
9131
  return i(e, !1);
9187
9132
  }
@@ -9244,10 +9189,10 @@ var L, R, z, et, B, tt, nt, V = f((() => {
9244
9189
  ].join(`,`)}}`;
9245
9190
  }
9246
9191
  }));
9247
- pt();
9248
- H();
9249
- mt();
9250
- const gt = [
9192
+ xt();
9193
+ z();
9194
+ St();
9195
+ const wt = [
9251
9196
  `singular`,
9252
9197
  `plural`,
9253
9198
  `dual`,
@@ -9258,11 +9203,11 @@ const gt = [
9258
9203
  `many`,
9259
9204
  `other`
9260
9205
  ];
9261
- function _t(e) {
9262
- return gt.includes(e);
9206
+ function Tt(e) {
9207
+ return wt.includes(e);
9263
9208
  }
9264
- function vt(e, t = gt, n = [`en`]) {
9265
- let r = Te(n).select(e), i = Math.abs(e);
9209
+ function Et(e, t = wt, n = [`en`]) {
9210
+ let r = Me(n).select(e), i = Math.abs(e);
9266
9211
  if (i === 0 && t.includes(`zero`)) return `zero`;
9267
9212
  if (i === 1) {
9268
9213
  if (t.includes(`singular`)) return `singular`;
@@ -9275,20 +9220,20 @@ function vt(e, t = gt, n = [`en`]) {
9275
9220
  }
9276
9221
  return r === `two` && t.includes(`dual`) ? `dual` : t.includes(r) ? r : r === `two` && t.includes(`dual`) ? `dual` : r === `two` && t.includes(`plural`) ? `plural` : r === `two` && t.includes(`other`) ? `other` : r === `few` && t.includes(`plural`) ? `plural` : r === `few` && t.includes(`other`) ? `other` : r === `many` && t.includes(`plural`) ? `plural` : r === `many` && t.includes(`other`) ? `other` : r === `other` && t.includes(`plural`) ? `plural` : ``;
9277
9222
  }
9278
- const yt = {
9223
+ const Dt = {
9279
9224
  variable: `v`,
9280
9225
  number: `n`,
9281
9226
  datetime: `d`,
9282
9227
  currency: `c`,
9283
9228
  "relative-time": `rt`
9284
9229
  };
9285
- function bt(e) {
9286
- return yt[e];
9230
+ function Ot(e) {
9231
+ return Dt[e];
9287
9232
  }
9288
- const K = `_gt_`;
9289
- RegExp(`^${K}\\d+$`);
9290
- RegExp(`^${K}$`);
9291
- function Nt(e, n = 0) {
9233
+ const U = `_gt_`;
9234
+ RegExp(`^${U}\\d+$`);
9235
+ RegExp(`^${U}$`);
9236
+ function Vt(e, n = 0) {
9292
9237
  let r = n, a = (e) => {
9293
9238
  let { type: t, props: n } = e;
9294
9239
  r += 1;
@@ -9302,11 +9247,11 @@ function Nt(e, n = 0) {
9302
9247
  if (a) {
9303
9248
  let e = a.split(`-`);
9304
9249
  if ((e[1] === `automatic` || e[2] === `automatic`) && (i.injectionType = `automatic`), e[0] === `translate` && (e[0] = `fragment`), e[0] === `variable` && (i.variableType = e?.[1] || `variable`), e[0] === `plural`) {
9305
- let e = Object.entries(n).reduce((e, [t, n]) => (_t(t) && (e[t] = Nt(n, r)), e), {});
9250
+ let e = Object.entries(n).reduce((e, [t, n]) => (Tt(t) && (e[t] = Vt(n, r)), e), {});
9306
9251
  Object.keys(e).length && (i.branches = e);
9307
9252
  }
9308
9253
  if (e[0] === `branch`) {
9309
- let { children: e, branch: t, ...a } = n, o = Object.fromEntries(Object.entries(a).filter(([e]) => !e.startsWith(`data-`))), s = Object.entries(o).reduce((e, [t, n]) => (e[t] = Nt(n, r), e), {});
9254
+ let { children: e, branch: t, ...a } = n, o = Object.fromEntries(Object.entries(a).filter(([e]) => !e.startsWith(`data-`))), s = Object.entries(o).reduce((e, [t, n]) => (e[t] = Vt(n, r), e), {});
9310
9255
  Object.keys(s).length && (i.branches = s);
9311
9256
  }
9312
9257
  i.transformation = e[0];
@@ -9318,50 +9263,97 @@ function Nt(e, n = 0) {
9318
9263
  ...n,
9319
9264
  "data-_gt": r
9320
9265
  };
9321
- return n.children && !r.variableType && (i.children = c(n.children)), e.type === React.Fragment && (i[`data-_gt`].transformation = `fragment`), React.cloneElement(e, i);
9266
+ return n.children && !r.variableType && (i.children = c(n.children)), e.type === t$1.Fragment && (i[`data-_gt`].transformation = `fragment`), t$1.cloneElement(e, i);
9322
9267
  }
9323
9268
  function s(e) {
9324
9269
  return isValidElement(e) ? o(e) : e;
9325
9270
  }
9326
9271
  function c(e) {
9327
- return Array.isArray(e) ? React.Children.map(e, s) : s(e);
9272
+ return Array.isArray(e) ? t$1.Children.map(e, s) : s(e);
9328
9273
  }
9329
9274
  return c(e);
9330
9275
  }
9331
- const q = `@generaltranslation/react-core`;
9332
- `${q}`, `${q}`, `${q}`, `${q}`, `${q}`, `${q}`;
9333
- `${q}`, `${q}`, `${q}`, `${q}`;
9334
- const Lt = `${q} Warning: A <_T> component was found injected outside of a <Derive> boundary. This may affect translation resolution for this component.`;
9335
- function Rt(e) {
9336
- return Bt(e, 0);
9276
+ const Ht = `@generaltranslation/react-core`;
9277
+ function W(e) {
9278
+ return S({
9279
+ source: Ht,
9280
+ ...e
9281
+ });
9282
+ }
9283
+ W({
9284
+ severity: `Error`,
9285
+ whatHappened: `Runtime translation needs a project ID`,
9286
+ fix: `Add projectId to your <GTProvider> configuration or set GT_PROJECT_ID in your environment`,
9287
+ docsUrl: `https://generaltranslation.com/dashboard`
9288
+ }), W({
9289
+ severity: `Error`,
9290
+ whatHappened: `Production environments cannot use a development API key`,
9291
+ fix: `Replace it with a production API key before deploying`
9292
+ }), W({
9293
+ severity: `Error`,
9294
+ whatHappened: `The API key is available to client-side production code`,
9295
+ fix: `Move translation credentials to a server-only environment before deploying`
9296
+ }), W({
9297
+ severity: `Error`,
9298
+ whatHappened: `Runtime translation is not configured`,
9299
+ fix: `Add projectId and devApiKey to your environment, or pass them to <GTProvider> directly`
9300
+ }), W({
9301
+ severity: `Error`,
9302
+ whatHappened: `Runtime translations could not be loaded`,
9303
+ wayOut: `Source content will render as a fallback`,
9304
+ fix: `Check your runtime translation configuration and try again`
9305
+ }), W({
9306
+ severity: `Error`,
9307
+ whatHappened: `Runtime translation could not be completed`
9308
+ });
9309
+ W({
9310
+ severity: `Warning`,
9311
+ whatHappened: `Runtime translation needs a project ID`,
9312
+ fix: `Add projectId to <GTProvider> or set GT_PROJECT_ID in your environment`,
9313
+ docsUrl: `https://generaltranslation.com/dashboard`
9314
+ }), W({
9315
+ severity: `Warning`,
9316
+ whatHappened: `Runtime translation needs a development API key`,
9317
+ fix: `Find your development API key at generaltranslation.com/dashboard, or set runtimeUrl to an empty string to disable runtime translation`
9318
+ }), W({
9319
+ severity: `Warning`,
9320
+ whatHappened: `Runtime translation timed out`
9321
+ }), W({
9322
+ severity: `Warning`,
9323
+ whatHappened: `No dictionary was found`,
9324
+ fix: `Pass a dictionary to <GTProvider> or configure a dictionary loader before rendering translations`
9325
+ });
9326
+ const Kt = `${Ht} Warning: A <_T> component was found injected outside of a <Derive> boundary. This may affect translation resolution for this component.`;
9327
+ function qt(e) {
9328
+ return K(e, 0);
9337
9329
  }
9338
- function zt(e, t) {
9339
- let { type: n, props: i } = e, a = Vt(n);
9330
+ function Jt(e, t) {
9331
+ let { type: n, props: i } = e, a = Yt(n);
9340
9332
  if (typeof i != `object` || !i) return e;
9341
9333
  if (a) {
9342
9334
  let { componentType: n, injectionType: o } = a;
9343
9335
  if (n === `variable`) return e;
9344
- if (n === `branch`) return cloneElement(e, { ...Object.entries(i).reduce((e, [n, r]) => (n !== `branch` && !n.startsWith(`data-`) ? e[n] = J(r, t) : e[n] = r, e), {}) });
9345
- if (n === `plural`) return cloneElement(e, { ...Object.entries(i).reduce((e, [n, r]) => (_t(n) || n === `children` ? e[n] = J(r, t) : e[n] = r, e), {}) });
9336
+ if (n === `branch`) return cloneElement(e, { ...Object.entries(i).reduce((e, [n, r]) => (n !== `branch` && !n.startsWith(`data-`) ? e[n] = G(r, t) : e[n] = r, e), {}) });
9337
+ if (n === `plural`) return cloneElement(e, { ...Object.entries(i).reduce((e, [n, r]) => (Tt(n) || n === `children` ? e[n] = G(r, t) : e[n] = r, e), {}) });
9346
9338
  if (n === `derive`) return cloneElement(e, {
9347
9339
  ...i,
9348
- ...`children` in i && { children: Bt(i.children, t + 1) }
9340
+ ...`children` in i && { children: K(i.children, t + 1) }
9349
9341
  });
9350
- if (n === `translate` && o === `automatic` && t > 0) return `children` in i ? Bt(i.children, t) : void 0;
9351
- n === `translate` && o === `automatic` && console.warn(Lt);
9342
+ if (n === `translate` && o === `automatic` && t > 0) return `children` in i ? K(i.children, t) : void 0;
9343
+ n === `translate` && o === `automatic` && console.warn(Kt);
9352
9344
  }
9353
9345
  return cloneElement(e, {
9354
9346
  ...i,
9355
- ...`children` in i && { children: Bt(i.children, t) }
9347
+ ...`children` in i && { children: K(i.children, t) }
9356
9348
  });
9357
9349
  }
9358
- function J(e, t) {
9359
- return isValidElement(e) ? zt(e, t) : e;
9350
+ function G(e, t) {
9351
+ return isValidElement(e) ? Jt(e, t) : e;
9360
9352
  }
9361
- function Bt(e, t) {
9362
- return Array.isArray(e) ? Children.map(e, (e) => J(e, t)) : J(e, t);
9353
+ function K(e, t) {
9354
+ return Array.isArray(e) ? Children.map(e, (e) => G(e, t)) : G(e, t);
9363
9355
  }
9364
- function Vt(e) {
9356
+ function Yt(e) {
9365
9357
  let t = typeof e == `function` && `_gtt` in e ? e._gtt : void 0;
9366
9358
  if (t == null || typeof t != `string`) return;
9367
9359
  let n = t.split(`-`);
@@ -9370,27 +9362,27 @@ function Vt(e) {
9370
9362
  injectionType: n[1] === `automatic` || n[2] === `automatic` ? `automatic` : `manual`
9371
9363
  };
9372
9364
  }
9373
- const Ht = {
9365
+ const Xt = {
9374
9366
  variable: `value`,
9375
9367
  number: `n`,
9376
9368
  datetime: `date`,
9377
9369
  currency: `cost`,
9378
9370
  "relative-time": `time`
9379
9371
  };
9380
- function Ut(e = {}, t) {
9381
- return typeof e.name == `string` ? e.name : `_gt_${Ht[t] || `value`}_${e[`data-_gt`]?.id}`;
9372
+ function Zt(e = {}, t) {
9373
+ return typeof e.name == `string` ? e.name : `_gt_${Xt[t] || `value`}_${e[`data-_gt`]?.id}`;
9382
9374
  }
9383
- function Wt(e) {
9384
- return React.isValidElement(e);
9375
+ function Qt(e) {
9376
+ return t$1.isValidElement(e);
9385
9377
  }
9386
- const Gt = {
9378
+ const $t = {
9387
9379
  pl: `placeholder`,
9388
9380
  ti: `title`,
9389
9381
  alt: `alt`,
9390
9382
  arl: `aria-label`,
9391
9383
  arb: `aria-labelledby`,
9392
9384
  ard: `aria-describedby`
9393
- }, Kt = (e) => {
9385
+ }, en = (e) => {
9394
9386
  if (!e) return ``;
9395
9387
  let { type: t, props: n } = e;
9396
9388
  if (t && typeof t == `function`) {
@@ -9398,15 +9390,15 @@ const Gt = {
9398
9390
  if (`name` in t && typeof t.name == `string` && t.name) return t.name;
9399
9391
  }
9400
9392
  return t && typeof t == `string` ? t : n.href ? `a` : n[`data-_gt`]?.id ? `C${n[`data-_gt`].id}` : `function`;
9401
- }, qt = (e, t, n) => {
9402
- let r = Object.entries(Gt).reduce((e, [n, r]) => {
9393
+ }, tn = (e, t, n) => {
9394
+ let r = Object.entries($t).reduce((e, [n, r]) => {
9403
9395
  let i = t[r];
9404
9396
  return typeof i == `string` && (e[n] = i), e;
9405
9397
  }, {});
9406
9398
  if (e === `plural` && n) {
9407
9399
  let e = {};
9408
9400
  Object.entries(n).forEach(([t, n]) => {
9409
- e[t] = Y(n);
9401
+ e[t] = q(n);
9410
9402
  }), r = {
9411
9403
  ...r,
9412
9404
  b: e,
@@ -9416,7 +9408,7 @@ const Gt = {
9416
9408
  if (e === `branch` && n) {
9417
9409
  let e = {};
9418
9410
  Object.entries(n).forEach(([t, n]) => {
9419
- e[t] = Y(n);
9411
+ e[t] = q(n);
9420
9412
  }), r = {
9421
9413
  ...r,
9422
9414
  b: e,
@@ -9424,27 +9416,27 @@ const Gt = {
9424
9416
  };
9425
9417
  }
9426
9418
  return Object.keys(r).length ? r : void 0;
9427
- }, Jt = (e) => {
9428
- let { props: t } = e, n = { t: Kt(e) };
9419
+ }, nn = (e) => {
9420
+ let { props: t } = e, n = { t: en(e) };
9429
9421
  if (t[`data-_gt`]) {
9430
9422
  let e = t[`data-_gt`], r = e.transformation;
9431
9423
  if (r === `variable`) {
9432
- let n = e.variableType || `variable`, r = Ut(t, n), i = bt(n);
9424
+ let n = e.variableType || `variable`, r = Zt(t, n), i = Ot(n);
9433
9425
  return {
9434
9426
  i: e.id,
9435
9427
  k: r,
9436
9428
  v: i
9437
9429
  };
9438
9430
  }
9439
- n.i = e.id, n.d = qt(r, t, e.branches);
9440
- let i = Object.entries(Gt).reduce((e, [n, r]) => {
9431
+ n.i = e.id, n.d = tn(r, t, e.branches);
9432
+ let i = Object.entries($t).reduce((e, [n, r]) => {
9441
9433
  let i = t[r];
9442
9434
  return typeof i == `string` && (e[n] = i), e;
9443
9435
  }, {});
9444
9436
  if (r === `plural` && e.branches) {
9445
9437
  let t = {};
9446
9438
  Object.entries(e.branches).forEach(([e, n]) => {
9447
- t[e] = Y(n);
9439
+ t[e] = q(n);
9448
9440
  }), i = {
9449
9441
  ...i,
9450
9442
  b: t,
@@ -9454,7 +9446,7 @@ const Gt = {
9454
9446
  if (r === `branch` && e.branches) {
9455
9447
  let t = {};
9456
9448
  Object.entries(e.branches).forEach(([e, n]) => {
9457
- t[e] = Y(n);
9449
+ t[e] = q(n);
9458
9450
  }), i = {
9459
9451
  ...i,
9460
9452
  b: t,
@@ -9463,23 +9455,23 @@ const Gt = {
9463
9455
  }
9464
9456
  n.d = Object.keys(i).length ? i : void 0;
9465
9457
  }
9466
- return t.children && (n.c = Y(t.children)), n;
9467
- }, Yt = (e) => Wt(e) ? Jt(e) : typeof e == `number` ? e.toString() : e;
9468
- function Y(e) {
9469
- return Array.isArray(e) ? e.map(Yt) : Yt(e);
9458
+ return t.children && (n.c = q(t.children)), n;
9459
+ }, rn = (e) => Qt(e) ? nn(e) : typeof e == `number` ? e.toString() : e;
9460
+ function q(e) {
9461
+ return Array.isArray(e) ? e.map(rn) : rn(e);
9470
9462
  }
9471
- function Xt(e, t, n) {
9463
+ function J(e, t, n) {
9472
9464
  let r = ``, i = null;
9473
- return typeof e == `number` && !i && n && (r = vt(e, Object.keys(n).filter(_t), t)), r && !i && (i = n[r]), i;
9465
+ return typeof e == `number` && !i && n && (r = Et(e, Object.keys(n).filter(Tt), t)), r && !i && (i = n[r]), i;
9474
9466
  }
9475
- function $t(e) {
9467
+ function on(e) {
9476
9468
  return typeof e == `object` && !!e && `data-_gt` in e && typeof e[`data-_gt`] == `object` && !!e[`data-_gt`] && `transformation` in e[`data-_gt`] && e[`data-_gt`]?.transformation === `variable`;
9477
9469
  }
9478
- function en(e) {
9470
+ function sn(e) {
9479
9471
  let t = e[`data-_gt`]?.variableType || `variable`;
9480
9472
  return {
9481
- variableName: Ut(e, t),
9482
- variableType: bt(t),
9473
+ variableName: Zt(e, t),
9474
+ variableType: Ot(t),
9483
9475
  injectionType: e[`data-_gt`]?.injectionType || `manual`,
9484
9476
  variableValue: (() => {
9485
9477
  if (e.value !== void 0) return e.value;
@@ -9498,14 +9490,14 @@ function en(e) {
9498
9490
  })()
9499
9491
  };
9500
9492
  }
9501
- function nn(e) {
9493
+ function ln(e) {
9502
9494
  return e && e.props && e.props[`data-_gt`] ? e.props[`data-_gt`] : null;
9503
9495
  }
9504
9496
  function Z({ children: e, defaultLocale: n = `en`, renderVariable: r }) {
9505
9497
  let i = (e) => {
9506
- let i = nn(e);
9507
- if ($t(e.props)) {
9508
- let { variableType: t, variableValue: i, variableOptions: a, injectionType: o } = en(e.props);
9498
+ let i = ln(e);
9499
+ if (on(e.props)) {
9500
+ let { variableType: t, variableValue: i, variableOptions: a, injectionType: o } = sn(e.props);
9509
9501
  return r({
9510
9502
  variableType: t,
9511
9503
  variableValue: i,
@@ -9517,30 +9509,30 @@ function Z({ children: e, defaultLocale: n = `en`, renderVariable: r }) {
9517
9509
  if (i?.transformation === `plural`) {
9518
9510
  let t = i.branches || {};
9519
9511
  if (typeof e.props.n != `number`) return e.props.children == null ? null : o(e.props.children);
9520
- let r = Xt(e.props.n, [n], t);
9512
+ let r = J(e.props.n, [n], t);
9521
9513
  return o(r === null ? e.props.children : r);
9522
9514
  }
9523
9515
  if (i?.transformation === `branch`) {
9524
9516
  let { children: t, branch: n } = e.props, r = i.branches || {}, a = n == null || n === `` ? void 0 : n.toString();
9525
9517
  return o(a && r[a] !== void 0 ? r[a] : t);
9526
9518
  }
9527
- return i?.transformation === `fragment` ? React.createElement(React.Fragment, {
9519
+ return i?.transformation === `fragment` ? t$1.createElement(t$1.Fragment, {
9528
9520
  key: e.props.key,
9529
9521
  children: o(e.props.children)
9530
- }) : e.props.children ? React.cloneElement(e, {
9522
+ }) : e.props.children ? t$1.cloneElement(e, {
9531
9523
  ...e.props,
9532
9524
  "data-_gt": void 0,
9533
9525
  children: o(e.props.children)
9534
- }) : React.cloneElement(e, {
9526
+ }) : t$1.cloneElement(e, {
9535
9527
  ...e.props,
9536
9528
  "data-_gt": void 0
9537
9529
  });
9538
- }, a = (e) => React.isValidElement(e) ? i(e) : e, o = (e) => Array.isArray(e) ? React.Children.map(e, a) : a(e);
9530
+ }, a = (e) => t$1.isValidElement(e) ? i(e) : e, o = (e) => Array.isArray(e) ? t$1.Children.map(e, a) : a(e);
9539
9531
  return o(e);
9540
9532
  }
9541
- function rn({ sourceElement: e, targetElement: n, locales: r = [`en`], renderVariable: i }) {
9533
+ function un({ sourceElement: e, targetElement: n, locales: r = [`en`], renderVariable: i }) {
9542
9534
  let { props: a } = e, o = a[`data-_gt`], s = o?.transformation, c = n.d, l = {};
9543
- if (c && Object.entries(Gt).forEach(([e, t]) => {
9535
+ if (c && Object.entries($t).forEach(([e, t]) => {
9544
9536
  c[e] && (l[t] = c[e]);
9545
9537
  }), s === `plural`) {
9546
9538
  let t = e.props.n;
@@ -9549,7 +9541,7 @@ function rn({ sourceElement: e, targetElement: n, locales: r = [`en`], renderVar
9549
9541
  defaultLocale: r[0],
9550
9542
  renderVariable: i
9551
9543
  });
9552
- let a = Xt(t, r, o.branches || {}), s = a === null ? e.props.children : a, c = Xt(t, r, n.d?.b || {});
9544
+ let a = J(t, r, o.branches || {}), s = a === null ? e.props.children : a, c = J(t, r, n.d?.b || {});
9553
9545
  return Q({
9554
9546
  source: s,
9555
9547
  target: c === null ? n.c : c,
@@ -9566,7 +9558,7 @@ function rn({ sourceElement: e, targetElement: n, locales: r = [`en`], renderVar
9566
9558
  renderVariable: i
9567
9559
  });
9568
9560
  }
9569
- return s === `fragment` && n.c ? React.createElement(React.Fragment, {
9561
+ return s === `fragment` && n.c ? t$1.createElement(t$1.Fragment, {
9570
9562
  key: e.props.key,
9571
9563
  children: Q({
9572
9564
  source: a.children,
@@ -9574,7 +9566,7 @@ function rn({ sourceElement: e, targetElement: n, locales: r = [`en`], renderVar
9574
9566
  locales: r,
9575
9567
  renderVariable: i
9576
9568
  })
9577
- }) : a?.children && n?.c ? React.cloneElement(e, {
9569
+ }) : a?.children && n?.c ? t$1.cloneElement(e, {
9578
9570
  ...a,
9579
9571
  ...l,
9580
9572
  "data-_gt": void 0,
@@ -9599,18 +9591,18 @@ function Q({ source: e, target: n, locales: r = [`en`], renderVariable: i }) {
9599
9591
  if (typeof n == `string`) return n;
9600
9592
  if (Array.isArray(n) && !Array.isArray(e) && e && (e = [e]), Array.isArray(e) && Array.isArray(n)) {
9601
9593
  let a = {}, o = {}, c = {}, l = e.filter((e) => {
9602
- if (React.isValidElement(e)) if ($t(e.props)) {
9603
- let { variableName: t, variableValue: n, variableOptions: r, injectionType: i } = en(e.props);
9594
+ if (t$1.isValidElement(e)) if (on(e.props)) {
9595
+ let { variableName: t, variableValue: n, variableOptions: r, injectionType: i } = sn(e.props);
9604
9596
  a[t] = n, o[t] = r, c[t] = i;
9605
9597
  } else return !0;
9606
9598
  return !1;
9607
9599
  }), u = (e) => l.find((t) => {
9608
- let n = nn(t);
9600
+ let n = ln(t);
9609
9601
  return n?.id === void 0 ? !1 : n.id === e.i;
9610
9602
  }) || l.shift();
9611
9603
  return n.map((e, n) => {
9612
- if (typeof e == `string`) return jsx(React.Fragment, { children: e }, `string_${n}`);
9613
- if (C(e)) return jsx(React.Fragment, { children: i({
9604
+ if (typeof e == `string`) return jsx(t$1.Fragment, { children: e }, `string_${n}`);
9605
+ if (E(e)) return jsx(t$1.Fragment, { children: i({
9614
9606
  variableType: e.v || `v`,
9615
9607
  variableValue: a[e.k],
9616
9608
  variableOptions: o[e.k],
@@ -9618,7 +9610,7 @@ function Q({ source: e, target: n, locales: r = [`en`], renderVariable: i }) {
9618
9610
  injectionType: c[e.k] || `manual`
9619
9611
  }) }, `var_${n}`);
9620
9612
  let l = u(e);
9621
- return l ? jsx(React.Fragment, { children: rn({
9613
+ return l ? jsx(t$1.Fragment, { children: un({
9622
9614
  sourceElement: l,
9623
9615
  targetElement: e,
9624
9616
  locales: r,
@@ -9627,16 +9619,16 @@ function Q({ source: e, target: n, locales: r = [`en`], renderVariable: i }) {
9627
9619
  });
9628
9620
  }
9629
9621
  if (n && typeof n == `object` && !Array.isArray(n)) {
9630
- let a = C(n) ? `variable` : `element`;
9631
- if (React.isValidElement(e)) {
9632
- if (a === `element`) return rn({
9622
+ let a = E(n) ? `variable` : `element`;
9623
+ if (t$1.isValidElement(e)) {
9624
+ if (a === `element`) return un({
9633
9625
  sourceElement: e,
9634
9626
  targetElement: n,
9635
9627
  locales: r,
9636
9628
  renderVariable: i
9637
9629
  });
9638
- if ($t(e.props)) {
9639
- let { variableValue: t, variableOptions: n, variableType: a, injectionType: o } = en(e.props);
9630
+ if (on(e.props)) {
9631
+ let { variableValue: t, variableOptions: n, variableType: a, injectionType: o } = sn(e.props);
9640
9632
  return i({
9641
9633
  variableType: a,
9642
9634
  variableValue: t,
@@ -9653,33 +9645,32 @@ function Q({ source: e, target: n, locales: r = [`en`], renderVariable: i }) {
9653
9645
  renderVariable: i
9654
9646
  });
9655
9647
  }
9656
- const sn = `generaltranslation.locale`;
9648
+ const pn = `generaltranslation.locale`;
9657
9649
  e.use;
9658
- function Hn({ children: e }) {
9650
+ function Jn({ children: e }) {
9659
9651
  return e;
9660
9652
  }
9661
- function Un(e) {
9662
- return Hn(e);
9653
+ function Yn(e) {
9654
+ return Jn(e);
9663
9655
  }
9664
- Hn._gtt = `derive`, Un._gtt = `derive`;
9656
+ Jn._gtt = `derive`, Yn._gtt = `derive`;
9665
9657
  //#endregion
9666
- //#region src/i18n-context/browser-i18n-manager/utils/cookies.ts
9658
+ //#region src/shared/cookies.ts
9667
9659
  /**
9668
- * Minimally parses a cookie value for a given cookie name
9660
+ * Minimally parses a cookie value for a given cookie name.
9669
9661
  * @param cookieName - The name of the cookie
9670
- * @returns The locale from the cookie or undefined if not found or invalid
9662
+ * @returns The cookie value, or undefined when it is not found
9671
9663
  */
9672
- function getCookieValue({ cookieName }) {
9664
+ function getCookieValue(cookieName) {
9673
9665
  if (typeof document === "undefined") return void 0;
9674
9666
  return document.cookie.split("; ").find((row) => row.startsWith(`${cookieName}=`))?.split("=")[1];
9675
9667
  }
9676
9668
  /**
9677
- * Sets a cookie value for a given cookie name
9669
+ * Sets a cookie value for a given cookie name.
9678
9670
  * @param cookieName - The name of the cookie
9679
9671
  * @param value - The value to set
9680
- * @returns The value that was set
9681
9672
  */
9682
- function setCookieValue({ cookieName, value }) {
9673
+ function setCookieValue(cookieName, value) {
9683
9674
  if (typeof document === "undefined") return;
9684
9675
  document.cookie = `${cookieName}=${value};path=/`;
9685
9676
  }
@@ -9693,7 +9684,7 @@ function setCookieValue({ cookieName, value }) {
9693
9684
  * @returns The determined locale
9694
9685
  *
9695
9686
  */
9696
- function determineLocale({ defaultLocale, locales, customMapping, localeCookieName = sn, getLocale }) {
9687
+ function determineLocale({ defaultLocale, locales, customMapping, localeCookieName = pn, getLocale }) {
9697
9688
  const localeConfig = {
9698
9689
  defaultLocale,
9699
9690
  locales,
@@ -9713,7 +9704,7 @@ function determineLocale({ defaultLocale, locales, customMapping, localeCookieNa
9713
9704
  return determinedLocale;
9714
9705
  }
9715
9706
  const candidates = [];
9716
- const cookieLocale = getCookieValue({ cookieName: localeCookieName });
9707
+ const cookieLocale = getCookieValue(localeCookieName);
9717
9708
  if (cookieLocale) candidates.push(cookieLocale);
9718
9709
  const navigatorLocales = navigator?.languages || [];
9719
9710
  candidates.push(...navigatorLocales);
@@ -9728,7 +9719,7 @@ var BrowserConditionStore = class {
9728
9719
  /**
9729
9720
  * @param {BrowserConditionStoreConstructorParams} params - The configuration for the BrowserConditionStore
9730
9721
  */
9731
- constructor({ getLocale, localeCookieName = sn, ...localeConfig } = {}) {
9722
+ constructor({ getLocale, localeCookieName = pn, ...localeConfig } = {}) {
9732
9723
  this.localeConfig = localeConfig;
9733
9724
  this.customGetLocale = getLocale;
9734
9725
  this.localeCookieName = localeCookieName;
@@ -9744,10 +9735,7 @@ var BrowserConditionStore = class {
9744
9735
  });
9745
9736
  }
9746
9737
  setLocale(locale) {
9747
- setCookieValue({
9748
- cookieName: this.localeCookieName,
9749
- value: locale
9750
- });
9738
+ setCookieValue(this.localeCookieName, locale);
9751
9739
  }
9752
9740
  };
9753
9741
  //#endregion
@@ -10161,7 +10149,7 @@ async function bootstrap(params) {
10161
10149
  */
10162
10150
  function Branch({ children, branch, ...branches }) {
10163
10151
  const branchKey = branch?.toString();
10164
- if (typeof branch === "string" && branch.startsWith("data-")) branch = void 0;
10152
+ if (branchKey?.startsWith("data-")) return children;
10165
10153
  return branchKey && typeof branches[branchKey] !== "undefined" ? branches[branchKey] : children;
10166
10154
  }
10167
10155
  /**
@@ -10188,7 +10176,7 @@ function Plural({ children, n, locales: localesProp, ...branches }) {
10188
10176
  getDefaultLocale()
10189
10177
  ];
10190
10178
  if (typeof n !== "number") return children;
10191
- const branch = Xt(n, locales, branches);
10179
+ const branch = J(n, locales, branches);
10192
10180
  return branch != null ? branch : children;
10193
10181
  }
10194
10182
  /**
@@ -10221,8 +10209,8 @@ function Derive({ children }) {
10221
10209
  /**
10222
10210
  * Equivalent to the `<Derive>` component, but used for auto insertion.
10223
10211
  */
10224
- function GtInternalDerive({ children }) {
10225
- return children;
10212
+ function GtInternalDerive(props) {
10213
+ return Derive(props);
10226
10214
  }
10227
10215
  /** @internal _gtt - The GT transformation and injection identifier for the component. */
10228
10216
  Derive._gtt = "derive";
@@ -10272,7 +10260,7 @@ const t = (messageOrStrings, ...values) => {
10272
10260
  */
10273
10261
  function handleTaggedTemplateLiteralTranslation(messageOrStrings, values) {
10274
10262
  const locale = getLocale();
10275
- const translatedInterpolatedTemplate = resolveTranslationSync(locale, interpolateTemplateLiteral(messageOrStrings, values));
10263
+ const translatedInterpolatedTemplate = resolveTranslationSync(locale, messageOrStrings.map((string, index) => string + (values[index] ?? "")).join(""));
10276
10264
  if (translatedInterpolatedTemplate) return translatedInterpolatedTemplate;
10277
10265
  const { message, variables } = extractInterpolatableValues(messageOrStrings, values);
10278
10266
  return resolveTranslationSyncWithFallback(locale, message, variables);
@@ -10301,17 +10289,6 @@ function extractInterpolatableValues(strings, values) {
10301
10289
  variables
10302
10290
  };
10303
10291
  }
10304
- /**
10305
- * Interpolate a template literal
10306
- * @param message - The message to interpolate.
10307
- * @param variables - The variables to interpolate.
10308
- * @returns The interpolated message.
10309
- */
10310
- function interpolateTemplateLiteral(strings, values) {
10311
- return strings.map((string, index) => {
10312
- return string + (values[index] ?? "");
10313
- }).join("");
10314
- }
10315
10292
  //#endregion
10316
10293
  //#region src/i18n-context/functions/translation/GtInternalRuntimeTranslateString.ts
10317
10294
  /**
@@ -10362,27 +10339,18 @@ function Num(props) {
10362
10339
  GtInternalNum._gtt = "variable-number-automatic";
10363
10340
  Num._gtt = "variable-number";
10364
10341
  //#endregion
10365
- //#region src/i18n-context/functions/variables/utils/computeVar.ts
10366
- /**
10367
- * Internal implementation of Var component for standardization
10368
- * @internal
10369
- */
10370
- function computeVar({ children }) {
10371
- return children;
10372
- }
10373
- //#endregion
10374
10342
  //#region src/i18n-context/functions/variables/GtInternalVar.tsx
10375
10343
  /**
10376
10344
  * Equivalent to the `<Var>` component, but used for auto insertion
10377
10345
  */
10378
10346
  function GtInternalVar({ children }) {
10379
- return computeVar({ children });
10347
+ return children;
10380
10348
  }
10381
10349
  /**
10382
10350
  * User facing version of the Var component
10383
10351
  */
10384
10352
  function Var({ children }) {
10385
- return computeVar({ children });
10353
+ return children;
10386
10354
  }
10387
10355
  /** @internal _gtt - The GT transformation and injection identifier for the component. */
10388
10356
  Var._gtt = "variable-variable";
@@ -10442,6 +10410,7 @@ GtInternalDateTime._gtt = "variable-datetime-automatic";
10442
10410
  DateTime._gtt = "variable-datetime";
10443
10411
  //#endregion
10444
10412
  //#region src/i18n-context/functions/variables/utils/renderVariable.tsx
10413
+ const getStringOrNumberValue = (value) => typeof value === "string" || typeof value === "number" || value == null ? value : void 0;
10445
10414
  /**
10446
10415
  * Custom override for the renderVariable function
10447
10416
  * to use the GtInternal components instead of the regular components
@@ -10458,7 +10427,7 @@ const renderVariable = ({ variableType, variableValue, variableOptions, injectio
10458
10427
  switch (variableType) {
10459
10428
  case "n": return /* @__PURE__ */ jsx(injectionType === "automatic" ? Num : GtInternalNum, {
10460
10429
  options: variableOptions,
10461
- children: typeof variableValue === "string" || typeof variableValue === "number" ? variableValue : variableValue == null ? variableValue : void 0
10430
+ children: getStringOrNumberValue(variableValue)
10462
10431
  });
10463
10432
  case "d": return /* @__PURE__ */ jsx(injectionType === "automatic" ? DateTime : GtInternalDateTime, {
10464
10433
  options: variableOptions,
@@ -10466,11 +10435,11 @@ const renderVariable = ({ variableType, variableValue, variableOptions, injectio
10466
10435
  });
10467
10436
  case "c": return /* @__PURE__ */ jsx(injectionType === "automatic" ? Currency : GtInternalCurrency, {
10468
10437
  options: variableOptions,
10469
- children: typeof variableValue === "string" || typeof variableValue === "number" ? variableValue : variableValue == null ? variableValue : void 0
10438
+ children: getStringOrNumberValue(variableValue)
10470
10439
  });
10471
10440
  default: {
10472
10441
  const renderedValue = variableValue;
10473
- return injectionType === "automatic" ? computeVar({ children: renderedValue }) : /* @__PURE__ */ jsx(Var, { children: renderedValue });
10442
+ return injectionType === "automatic" ? renderedValue : /* @__PURE__ */ jsx(Var, { children: renderedValue });
10474
10443
  }
10475
10444
  }
10476
10445
  };
@@ -10495,10 +10464,29 @@ GtInternalTranslateJsx._gtt = "translate-client-automatic";
10495
10464
  * Implementation for the T component logic
10496
10465
  */
10497
10466
  function useComputeT({ children: sourceChildren, ...params }) {
10498
- const { taggedSourceChildren, sourceJsxChildren, renderSourceChildren, options } = usePrepSourceRender({
10499
- sourceChildren,
10500
- params
10467
+ const taggedSourceChildren = useMemo(() => Vt(qt(sourceChildren)), [sourceChildren]);
10468
+ const sourceJsxChildren = useMemo(() => q(taggedSourceChildren), [taggedSourceChildren]);
10469
+ const renderSourceChildren = () => Z({
10470
+ children: taggedSourceChildren,
10471
+ defaultLocale: getLocale(),
10472
+ renderVariable
10501
10473
  });
10474
+ const options = useMemo(() => ({
10475
+ $format: "JSX",
10476
+ $context: params.context,
10477
+ $id: params.id,
10478
+ $_hash: params._hash,
10479
+ ...params
10480
+ }), [
10481
+ params.format,
10482
+ params.context,
10483
+ params.id,
10484
+ params._hash,
10485
+ params.$format,
10486
+ params.$context,
10487
+ params.$id,
10488
+ params.$_hash
10489
+ ]);
10502
10490
  const targetLocale = getLocale();
10503
10491
  if (!requiresTranslation(getDefaultLocale(), targetLocale)) return renderSourceChildren();
10504
10492
  const targetOptions = {
@@ -10524,44 +10512,6 @@ function useComputeT({ children: sourceChildren, ...params }) {
10524
10512
  return renderSourceChildren();
10525
10513
  }
10526
10514
  /**
10527
- * Returns the tagged source children and the default render function for the source children
10528
- */
10529
- function usePrepSourceRender({ sourceChildren, params }) {
10530
- const taggedSourceChildren = useMemo(() => Nt(Rt(sourceChildren)), [sourceChildren]);
10531
- return {
10532
- taggedSourceChildren,
10533
- sourceJsxChildren: useMemo(() => Y(taggedSourceChildren), [taggedSourceChildren]),
10534
- renderSourceChildren: useCallback(() => {
10535
- return Z({
10536
- children: taggedSourceChildren,
10537
- defaultLocale: getLocale(),
10538
- renderVariable
10539
- });
10540
- }, [taggedSourceChildren]),
10541
- options: useMemo(() => normalizeParameters(params), [
10542
- params.context,
10543
- params.id,
10544
- params._hash,
10545
- params.$format,
10546
- params.$context,
10547
- params.$id,
10548
- params.$_hash
10549
- ])
10550
- };
10551
- }
10552
- /**
10553
- * Normalizes the parameters into a lookup options object.
10554
- */
10555
- function normalizeParameters(parameters) {
10556
- return {
10557
- $format: "JSX",
10558
- $context: parameters.context,
10559
- $id: parameters.id,
10560
- $_hash: parameters._hash,
10561
- ...parameters
10562
- };
10563
- }
10564
- /**
10565
10515
  * Dev-only translation resolver that uses React Suspense.
10566
10516
  * Sync cache check already happened in computeT() — this only handles cache misses.
10567
10517
  * use() suspends until the async translation resolves.
@@ -10686,13 +10636,12 @@ function _convertCustomNamesToMapping(customNames) {
10686
10636
  */
10687
10637
  function InternalLocaleSelector({ locale, locales, customNames, customMapping = _convertCustomNamesToMapping(customNames), setLocale, getLocaleProperties, ...props }) {
10688
10638
  const getDisplayName = (locale) => {
10689
- if (customMapping && customMapping[locale]) {
10690
- if (typeof customMapping[locale] === "string") return customMapping[locale];
10691
- if (customMapping[locale].name) return customMapping[locale].name;
10692
- }
10639
+ const customLocale = customMapping?.[locale];
10640
+ if (typeof customLocale === "string") return customLocale;
10641
+ if (customLocale?.name) return customLocale.name;
10693
10642
  return capitalizeName(getLocaleProperties(locale).nativeNameWithRegionCode);
10694
10643
  };
10695
- if (!locales || locales.length === 0 || !setLocale) return null;
10644
+ if (!locales?.length || !setLocale) return null;
10696
10645
  return /* @__PURE__ */ jsxs("select", {
10697
10646
  ...props,
10698
10647
  value: locale || "",