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/CHANGELOG.md +22 -0
- package/dist/browser.cjs +1086 -1138
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +80 -110
- package/dist/browser.d.cts.map +1 -1
- package/dist/browser.d.mts +80 -110
- package/dist/browser.d.mts.map +1 -1
- package/dist/browser.mjs +1082 -1133
- package/dist/browser.mjs.map +1 -1
- package/dist/client.cjs +399 -304
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +7 -8
- package/dist/client.d.cts.map +1 -1
- package/dist/client.d.mts +7 -8
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs +399 -303
- package/dist/client.mjs.map +1 -1
- package/dist/index.cjs +602 -420
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -9
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +9 -9
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +601 -418
- package/dist/index.mjs.map +1 -1
- package/dist/internal.cjs +590 -498
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +18 -18
- package/dist/internal.d.cts.map +1 -1
- package/dist/internal.d.mts +8 -8
- package/dist/internal.d.mts.map +1 -1
- package/dist/internal.mjs +556 -464
- package/dist/internal.mjs.map +1 -1
- package/dist/macros.cjs +559 -669
- package/dist/macros.cjs.map +1 -1
- package/dist/macros.mjs +559 -669
- package/dist/macros.mjs.map +1 -1
- package/package.json +7 -7
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
|
|
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
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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-
|
|
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
|
|
4444
|
+
* - projectId is needed
|
|
4375
4445
|
* - CUSTOM:
|
|
4376
|
-
* - loadTranslations is
|
|
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:
|
|
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:
|
|
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
|
-
|
|
4408
|
-
|
|
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
|
|
4425
|
-
* - devApiKey or apiKey is
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
|
4576
|
-
|
|
4577
|
-
const
|
|
4578
|
-
return
|
|
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
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
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
|
-
*
|
|
4587
|
-
*
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
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.
|
|
4604
|
-
this.
|
|
4790
|
+
this.runtimeTranslate = runtimeTranslate;
|
|
4791
|
+
this.lifecycle = lifecycle;
|
|
4605
4792
|
}
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
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
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
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
|
|
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
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
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
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
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
|
-
|
|
4646
|
-
this.setCache(cacheKey, value);
|
|
4647
|
-
return value;
|
|
4916
|
+
return (await loadPromise).value;
|
|
4648
4917
|
} finally {
|
|
4649
|
-
|
|
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
|
|
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
|
-
|
|
4705
|
-
this.
|
|
4706
|
-
this.
|
|
4707
|
-
this.
|
|
4708
|
-
this.
|
|
4709
|
-
this.
|
|
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
|
|
4718
|
-
|
|
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
|
|
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
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
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
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
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
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
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
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
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.
|
|
4769
|
-
}
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
this.
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
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.
|
|
5060
|
+
if (this.queue.length > 0) this.scheduleBatch();
|
|
4789
5061
|
}
|
|
4790
|
-
|
|
4791
|
-
|
|
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.
|
|
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
|
-
|
|
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.
|
|
4823
|
-
if (response) this.
|
|
4824
|
-
this.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
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.
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
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
|
-
|
|
5149
|
+
this.dictionaries.set(defaultLocale, createDictionaryCache({
|
|
5150
|
+
locale: defaultLocale,
|
|
5151
|
+
dictionary,
|
|
5152
|
+
translate: translateDictionaryEntry,
|
|
5153
|
+
lifecycle
|
|
5154
|
+
}), { expiresAt: -1 });
|
|
4909
5155
|
}
|
|
4910
|
-
|
|
4911
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
4981
|
-
|
|
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
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
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
|
|
5011
|
-
|
|
5012
|
-
|
|
5187
|
+
function withLocale(locale, callback) {
|
|
5188
|
+
return callback ? (params) => callback({
|
|
5189
|
+
locale,
|
|
5190
|
+
...params
|
|
5191
|
+
}) : void 0;
|
|
5013
5192
|
}
|
|
5014
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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 =
|
|
5447
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
5553
|
-
|
|
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.
|
|
5567
|
-
return this.
|
|
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.
|
|
5579
|
-
return this.
|
|
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
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
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
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
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
|
|
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.
|
|
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
|
-
|
|
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(`
|
|
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
|
-
|
|
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():
|
|
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
|
|
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
|
|
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
|
|
6242
|
-
let r =
|
|
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
|
|
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
|
|
6254
|
-
|
|
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
|
|
6203
|
+
function se(...e) {
|
|
6259
6204
|
for (let t = 0; t < e.length; t++) e[t].fill(0);
|
|
6260
6205
|
}
|
|
6261
|
-
function
|
|
6206
|
+
function ce(e) {
|
|
6262
6207
|
return new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
6263
6208
|
}
|
|
6264
|
-
function
|
|
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
|
|
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
|
|
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
|
|
6232
|
+
function he(e, t, n) {
|
|
6288
6233
|
return e & t ^ ~e & n;
|
|
6289
6234
|
}
|
|
6290
|
-
function
|
|
6235
|
+
function ge(e, t, n) {
|
|
6291
6236
|
return e & t ^ e & n ^ t & n;
|
|
6292
6237
|
}
|
|
6293
|
-
var
|
|
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 =
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
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,
|
|
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 =
|
|
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
|
|
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
|
-
]),
|
|
6359
|
-
function
|
|
6303
|
+
]), A = BigInt(2 ** 32 - 1), ve = BigInt(32);
|
|
6304
|
+
function ye(e, t = !1) {
|
|
6360
6305
|
return t ? {
|
|
6361
|
-
h: Number(e &
|
|
6362
|
-
l: Number(e >>
|
|
6306
|
+
h: Number(e & A),
|
|
6307
|
+
l: Number(e >> ve & A)
|
|
6363
6308
|
} : {
|
|
6364
|
-
h: Number(e >>
|
|
6365
|
-
l: Number(e &
|
|
6309
|
+
h: Number(e >> ve & A) | 0,
|
|
6310
|
+
l: Number(e & A) | 0
|
|
6366
6311
|
};
|
|
6367
6312
|
}
|
|
6368
|
-
function
|
|
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 } =
|
|
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
|
|
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
|
-
]),
|
|
6442
|
-
var
|
|
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)
|
|
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 =
|
|
6466
|
-
|
|
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 =
|
|
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
|
-
|
|
6421
|
+
se(j);
|
|
6477
6422
|
}
|
|
6478
6423
|
destroy() {
|
|
6479
|
-
this.destroyed = !0, this.set(0, 0, 0, 0, 0, 0, 0, 0),
|
|
6480
|
-
}
|
|
6481
|
-
},
|
|
6482
|
-
A =
|
|
6483
|
-
B =
|
|
6484
|
-
C =
|
|
6485
|
-
D =
|
|
6486
|
-
E =
|
|
6487
|
-
F =
|
|
6488
|
-
G =
|
|
6489
|
-
H =
|
|
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
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
const
|
|
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
|
-
[
|
|
6456
|
+
[De]: {
|
|
6512
6457
|
terminator: `…`,
|
|
6513
6458
|
separator: void 0
|
|
6514
6459
|
}
|
|
6515
6460
|
},
|
|
6516
|
-
none: { [
|
|
6461
|
+
none: { [De]: {
|
|
6517
6462
|
terminator: void 0,
|
|
6518
6463
|
separator: void 0
|
|
6519
6464
|
} }
|
|
6520
6465
|
};
|
|
6521
|
-
var
|
|
6522
|
-
|
|
6466
|
+
var ke = class e {
|
|
6467
|
+
static resolveLocale(e) {
|
|
6523
6468
|
try {
|
|
6524
|
-
let t = e ? Array.isArray(e) ? e.map(
|
|
6525
|
-
|
|
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
|
-
|
|
6472
|
+
return `en`;
|
|
6528
6473
|
}
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
|
|
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
|
|
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:
|
|
6574
|
-
},
|
|
6516
|
+
CutoffFormat: ke
|
|
6517
|
+
}, je = new class {
|
|
6575
6518
|
constructor() {
|
|
6576
6519
|
this.cache = {};
|
|
6577
6520
|
}
|
|
6578
|
-
|
|
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.
|
|
6583
|
-
|
|
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
|
|
6587
|
-
return
|
|
6588
|
-
}
|
|
6589
|
-
var
|
|
6590
|
-
__addDisposableResource: () =>
|
|
6591
|
-
__assign: () =>
|
|
6592
|
-
__asyncDelegator: () =>
|
|
6593
|
-
__asyncGenerator: () =>
|
|
6594
|
-
__asyncValues: () =>
|
|
6595
|
-
__await: () =>
|
|
6596
|
-
__awaiter: () =>
|
|
6597
|
-
__classPrivateFieldGet: () =>
|
|
6598
|
-
__classPrivateFieldIn: () =>
|
|
6599
|
-
__classPrivateFieldSet: () =>
|
|
6600
|
-
__createBinding: () =>
|
|
6601
|
-
__decorate: () =>
|
|
6602
|
-
__disposeResources: () =>
|
|
6603
|
-
__esDecorate: () =>
|
|
6604
|
-
__exportStar: () =>
|
|
6605
|
-
__extends: () =>
|
|
6606
|
-
__generator: () =>
|
|
6607
|
-
__importDefault: () =>
|
|
6608
|
-
__importStar: () =>
|
|
6609
|
-
__makeTemplateObject: () =>
|
|
6610
|
-
__metadata: () =>
|
|
6611
|
-
__param: () =>
|
|
6612
|
-
__propKey: () =>
|
|
6613
|
-
__read: () =>
|
|
6614
|
-
__rest: () =>
|
|
6615
|
-
__rewriteRelativeImportExtension: () =>
|
|
6616
|
-
__runInitializers: () =>
|
|
6617
|
-
__setFunctionName: () =>
|
|
6618
|
-
__spread: () =>
|
|
6619
|
-
__spreadArray: () =>
|
|
6620
|
-
__spreadArrays: () =>
|
|
6621
|
-
__values: () =>
|
|
6622
|
-
default: () =>
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
6589
|
+
function Ie(e, t) {
|
|
6645
6590
|
return function(n, r) {
|
|
6646
6591
|
t(n, r, e);
|
|
6647
6592
|
};
|
|
6648
6593
|
}
|
|
6649
|
-
function
|
|
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
|
|
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
|
|
6623
|
+
function ze(e) {
|
|
6679
6624
|
return typeof e == `symbol` ? e : `${e}`;
|
|
6680
6625
|
}
|
|
6681
|
-
function
|
|
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
|
|
6632
|
+
function Ve(e, t) {
|
|
6688
6633
|
if (typeof Reflect == `object` && typeof Reflect.metadata == `function`) return Reflect.metadata(e, t);
|
|
6689
6634
|
}
|
|
6690
|
-
function
|
|
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
|
|
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
|
|
6788
|
-
for (var n in e) n !== `default` && !Object.prototype.hasOwnProperty.call(t, 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
|
|
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
|
|
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
|
|
6819
|
-
for (var e = [], t = 0; t < arguments.length; t++) e = e.concat(
|
|
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
|
|
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
|
|
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
|
|
6832
|
-
return this instanceof
|
|
6776
|
+
function P(e) {
|
|
6777
|
+
return this instanceof P ? (this.v = e, this) : new P(e);
|
|
6833
6778
|
}
|
|
6834
|
-
function
|
|
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
|
|
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
|
|
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:
|
|
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
|
|
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
|
|
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
|
|
6860
|
+
function Qe(e, t) {
|
|
6916
6861
|
return Object.defineProperty ? Object.defineProperty(e, `raw`, { value: t }) : e.raw = t, e;
|
|
6917
6862
|
}
|
|
6918
|
-
function
|
|
6863
|
+
function $e(e) {
|
|
6919
6864
|
if (e && e.__esModule) return e;
|
|
6920
6865
|
var t = {};
|
|
6921
|
-
if (e != null) for (var n =
|
|
6922
|
-
return
|
|
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
|
|
6869
|
+
function et(e) {
|
|
6925
6870
|
return e && e.__esModule ? e : { default: e };
|
|
6926
6871
|
}
|
|
6927
|
-
function
|
|
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
|
|
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
|
|
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
|
|
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
|
|
6914
|
+
function at(e) {
|
|
6970
6915
|
function t(t) {
|
|
6971
|
-
e.error = e.hasError ? new
|
|
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
|
|
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
|
|
6997
|
-
|
|
6998
|
-
return
|
|
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
|
-
},
|
|
7003
|
-
},
|
|
7004
|
-
return
|
|
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
|
-
},
|
|
7008
|
-
},
|
|
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
|
-
}),
|
|
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
|
-
},
|
|
7027
|
-
return
|
|
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
|
-
},
|
|
7032
|
-
},
|
|
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
|
-
},
|
|
7036
|
-
__extends:
|
|
7037
|
-
__assign:
|
|
7038
|
-
__rest:
|
|
7039
|
-
__decorate:
|
|
7040
|
-
__param:
|
|
7041
|
-
__esDecorate:
|
|
7042
|
-
__runInitializers:
|
|
7043
|
-
__propKey:
|
|
7044
|
-
__setFunctionName:
|
|
7045
|
-
__metadata:
|
|
7046
|
-
__awaiter:
|
|
7047
|
-
__generator:
|
|
7048
|
-
__createBinding:
|
|
7049
|
-
__exportStar:
|
|
7050
|
-
__values:
|
|
7051
|
-
__read:
|
|
7052
|
-
__spread:
|
|
7053
|
-
__spreadArrays:
|
|
7054
|
-
__spreadArray:
|
|
7055
|
-
__await:
|
|
7056
|
-
__asyncGenerator:
|
|
7057
|
-
__asyncDelegator:
|
|
7058
|
-
__asyncValues:
|
|
7059
|
-
__makeTemplateObject:
|
|
7060
|
-
__importStar:
|
|
7061
|
-
__importDefault:
|
|
7062
|
-
__classPrivateFieldGet:
|
|
7063
|
-
__classPrivateFieldSet:
|
|
7064
|
-
__classPrivateFieldIn:
|
|
7065
|
-
__addDisposableResource:
|
|
7066
|
-
__disposeResources:
|
|
7067
|
-
__rewriteRelativeImportExtension:
|
|
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
|
-
})),
|
|
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
|
-
})),
|
|
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
|
-
})),
|
|
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
|
-
})),
|
|
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
|
-
})),
|
|
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
|
-
})),
|
|
7180
|
+
})), ht = p(((e) => {
|
|
7236
7181
|
Object.defineProperty(e, `__esModule`, { value: !0 }), e.parseNumberSkeletonFromString = r, e.parseNumberSkeleton = p;
|
|
7237
|
-
var t = (
|
|
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
|
-
})),
|
|
7360
|
+
})), gt = p(((e) => {
|
|
7416
7361
|
Object.defineProperty(e, `__esModule`, { value: !0 });
|
|
7417
|
-
var t = (
|
|
7418
|
-
t.__exportStar(
|
|
7419
|
-
})),
|
|
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
|
-
})),
|
|
8521
|
+
})), vt = p(((e) => {
|
|
8577
8522
|
Object.defineProperty(e, `__esModule`, { value: !0 }), e.getBestPattern = n;
|
|
8578
|
-
var t =
|
|
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
|
-
})),
|
|
8548
|
+
})), yt = p(((e) => {
|
|
8604
8549
|
Object.defineProperty(e, `__esModule`, { value: !0 }), e.Parser = void 0;
|
|
8605
|
-
var t = (
|
|
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 =
|
|
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
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
8589
|
+
}, te = m ? function(e) {
|
|
8645
8590
|
return e.trimStart();
|
|
8646
8591
|
} : function(e) {
|
|
8647
8592
|
return e.replace(s, ``);
|
|
8648
|
-
},
|
|
8593
|
+
}, ne = h ? function(e) {
|
|
8649
8594
|
return e.trimEnd();
|
|
8650
8595
|
} : function(e) {
|
|
8651
8596
|
return e.replace(c, ``);
|
|
8652
8597
|
};
|
|
8653
|
-
function
|
|
8598
|
+
function S(e, t) {
|
|
8654
8599
|
return new RegExp(e, t);
|
|
8655
8600
|
}
|
|
8656
|
-
var
|
|
8601
|
+
var C;
|
|
8657
8602
|
if (v) {
|
|
8658
|
-
var
|
|
8659
|
-
|
|
8660
|
-
return
|
|
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
|
|
8607
|
+
} else C = function(e, t) {
|
|
8663
8608
|
for (var n = [];;) {
|
|
8664
8609
|
var r = x(e, t);
|
|
8665
|
-
if (r === void 0 ||
|
|
8610
|
+
if (r === void 0 || ie(r) || D(r)) break;
|
|
8666
8611
|
n.push(r), t += r >= 65536 ? 2 : 1;
|
|
8667
8612
|
}
|
|
8668
|
-
return
|
|
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 &&
|
|
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() || !
|
|
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() &&
|
|
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 || !
|
|
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
|
|
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(),
|
|
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 =
|
|
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 =
|
|
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 &&
|
|
8855
|
-
var
|
|
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(
|
|
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 (
|
|
8869
|
-
var x =
|
|
8870
|
-
this.locale && (x = (0, o.getBestPattern)(
|
|
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
|
|
8901
|
-
if (this.bumpSpace(), !this.bumpIf(`,`)) return this.error(n.ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, l(
|
|
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
|
|
8904
|
-
if (d !== `select` &&
|
|
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(),
|
|
8854
|
+
this.bumpSpace(), C = this.parseIdentifierIfPossible(), w = h.val;
|
|
8910
8855
|
}
|
|
8911
|
-
var
|
|
8912
|
-
if (
|
|
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
|
|
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:
|
|
8921
|
-
location:
|
|
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:
|
|
8929
|
-
offset:
|
|
8873
|
+
options: b(T.val),
|
|
8874
|
+
offset: w,
|
|
8930
8875
|
pluralType: d === `plural` ? `cardinal` : `ordinal`,
|
|
8931
|
-
location:
|
|
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 (
|
|
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() &&
|
|
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
|
|
9024
|
+
function T(e) {
|
|
9080
9025
|
return e >= 97 && e <= 122 || e >= 65 && e <= 90;
|
|
9081
9026
|
}
|
|
9082
|
-
function
|
|
9083
|
-
return
|
|
9027
|
+
function re(e) {
|
|
9028
|
+
return T(e) || e === 47;
|
|
9084
9029
|
}
|
|
9085
|
-
function
|
|
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
|
|
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
|
|
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
|
-
})),
|
|
9039
|
+
})), bt = p(((e) => {
|
|
9095
9040
|
Object.defineProperty(e, `__esModule`, { value: !0 }), e.hoistSelectors = s, e.isStructurallySame = l;
|
|
9096
|
-
var t = (
|
|
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
|
-
})),
|
|
9098
|
+
})), xt = p(((e) => {
|
|
9154
9099
|
Object.defineProperty(e, `__esModule`, { value: !0 }), e.isStructurallySame = e._Parser = void 0, e.parse = o;
|
|
9155
|
-
var t = (
|
|
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(
|
|
9175
|
-
var s =
|
|
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
|
-
})),
|
|
9127
|
+
})), St = p(((e) => {
|
|
9183
9128
|
Object.defineProperty(e, `__esModule`, { value: !0 }), e.printAST = r;
|
|
9184
|
-
var t = (
|
|
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
|
-
|
|
9248
|
-
|
|
9249
|
-
|
|
9250
|
-
const
|
|
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
|
|
9262
|
-
return
|
|
9206
|
+
function Tt(e) {
|
|
9207
|
+
return wt.includes(e);
|
|
9263
9208
|
}
|
|
9264
|
-
function
|
|
9265
|
-
let r =
|
|
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
|
|
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
|
|
9286
|
-
return
|
|
9230
|
+
function Ot(e) {
|
|
9231
|
+
return Dt[e];
|
|
9287
9232
|
}
|
|
9288
|
-
const
|
|
9289
|
-
RegExp(`^${
|
|
9290
|
-
RegExp(`^${
|
|
9291
|
-
function
|
|
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]) => (
|
|
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] =
|
|
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 ===
|
|
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) ?
|
|
9272
|
+
return Array.isArray(e) ? t$1.Children.map(e, s) : s(e);
|
|
9328
9273
|
}
|
|
9329
9274
|
return c(e);
|
|
9330
9275
|
}
|
|
9331
|
-
const
|
|
9332
|
-
|
|
9333
|
-
|
|
9334
|
-
|
|
9335
|
-
|
|
9336
|
-
|
|
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
|
|
9339
|
-
let { type: n, props: i } = e, a =
|
|
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] =
|
|
9345
|
-
if (n === `plural`) return cloneElement(e, { ...Object.entries(i).reduce((e, [n, r]) => (
|
|
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:
|
|
9340
|
+
...`children` in i && { children: K(i.children, t + 1) }
|
|
9349
9341
|
});
|
|
9350
|
-
if (n === `translate` && o === `automatic` && t > 0) return `children` in i ?
|
|
9351
|
-
n === `translate` && o === `automatic` && console.warn(
|
|
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:
|
|
9347
|
+
...`children` in i && { children: K(i.children, t) }
|
|
9356
9348
|
});
|
|
9357
9349
|
}
|
|
9358
|
-
function
|
|
9359
|
-
return isValidElement(e) ?
|
|
9350
|
+
function G(e, t) {
|
|
9351
|
+
return isValidElement(e) ? Jt(e, t) : e;
|
|
9360
9352
|
}
|
|
9361
|
-
function
|
|
9362
|
-
return Array.isArray(e) ? Children.map(e, (e) =>
|
|
9353
|
+
function K(e, t) {
|
|
9354
|
+
return Array.isArray(e) ? Children.map(e, (e) => G(e, t)) : G(e, t);
|
|
9363
9355
|
}
|
|
9364
|
-
function
|
|
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
|
|
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
|
|
9381
|
-
return typeof e.name == `string` ? e.name : `_gt_${
|
|
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
|
|
9384
|
-
return
|
|
9375
|
+
function Qt(e) {
|
|
9376
|
+
return t$1.isValidElement(e);
|
|
9385
9377
|
}
|
|
9386
|
-
const
|
|
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
|
-
},
|
|
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
|
-
},
|
|
9402
|
-
let r = Object.entries(
|
|
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] =
|
|
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] =
|
|
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
|
-
},
|
|
9428
|
-
let { props: t } = e, n = { t:
|
|
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 =
|
|
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 =
|
|
9440
|
-
let i = Object.entries(
|
|
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] =
|
|
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] =
|
|
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 =
|
|
9467
|
-
},
|
|
9468
|
-
function
|
|
9469
|
-
return Array.isArray(e) ? e.map(
|
|
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
|
|
9463
|
+
function J(e, t, n) {
|
|
9472
9464
|
let r = ``, i = null;
|
|
9473
|
-
return typeof e == `number` && !i && n && (r =
|
|
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
|
|
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
|
|
9470
|
+
function sn(e) {
|
|
9479
9471
|
let t = e[`data-_gt`]?.variableType || `variable`;
|
|
9480
9472
|
return {
|
|
9481
|
-
variableName:
|
|
9482
|
-
variableType:
|
|
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
|
|
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 =
|
|
9507
|
-
if (
|
|
9508
|
-
let { variableType: t, variableValue: i, variableOptions: a, injectionType: o } =
|
|
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 =
|
|
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` ?
|
|
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 ?
|
|
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
|
-
}) :
|
|
9526
|
+
}) : t$1.cloneElement(e, {
|
|
9535
9527
|
...e.props,
|
|
9536
9528
|
"data-_gt": void 0
|
|
9537
9529
|
});
|
|
9538
|
-
}, 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
|
|
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(
|
|
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 =
|
|
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 ?
|
|
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 ?
|
|
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 (
|
|
9603
|
-
let { variableName: t, variableValue: n, variableOptions: r, injectionType: i } =
|
|
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 =
|
|
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(
|
|
9613
|
-
if (
|
|
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(
|
|
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 =
|
|
9631
|
-
if (
|
|
9632
|
-
if (a === `element`) return
|
|
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 (
|
|
9639
|
-
let { variableValue: t, variableOptions: n, variableType: a, injectionType: o } =
|
|
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
|
|
9648
|
+
const pn = `generaltranslation.locale`;
|
|
9657
9649
|
e.use;
|
|
9658
|
-
function
|
|
9650
|
+
function Jn({ children: e }) {
|
|
9659
9651
|
return e;
|
|
9660
9652
|
}
|
|
9661
|
-
function
|
|
9662
|
-
return
|
|
9653
|
+
function Yn(e) {
|
|
9654
|
+
return Jn(e);
|
|
9663
9655
|
}
|
|
9664
|
-
|
|
9656
|
+
Jn._gtt = `derive`, Yn._gtt = `derive`;
|
|
9665
9657
|
//#endregion
|
|
9666
|
-
//#region src/
|
|
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
|
|
9662
|
+
* @returns The cookie value, or undefined when it is not found
|
|
9671
9663
|
*/
|
|
9672
|
-
function getCookieValue(
|
|
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(
|
|
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 =
|
|
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(
|
|
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 =
|
|
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 (
|
|
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 =
|
|
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(
|
|
10225
|
-
return
|
|
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,
|
|
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
|
|
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
|
|
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:
|
|
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:
|
|
10438
|
+
children: getStringOrNumberValue(variableValue)
|
|
10470
10439
|
});
|
|
10471
10440
|
default: {
|
|
10472
10441
|
const renderedValue = variableValue;
|
|
10473
|
-
return injectionType === "automatic" ?
|
|
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
|
|
10499
|
-
|
|
10500
|
-
|
|
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
|
-
|
|
10690
|
-
|
|
10691
|
-
|
|
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
|
|
10644
|
+
if (!locales?.length || !setLocale) return null;
|
|
10696
10645
|
return /* @__PURE__ */ jsxs("select", {
|
|
10697
10646
|
...props,
|
|
10698
10647
|
value: locale || "",
|