generaltranslation 8.2.8 → 8.2.9

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.
Files changed (60) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/{ApiError-4zIP-twr.cjs → ApiError-CZ45tkW6.cjs} +1 -1
  3. package/dist/{ApiError-4zIP-twr.cjs.map → ApiError-CZ45tkW6.cjs.map} +1 -1
  4. package/dist/{ApiError-Bv7vlzyQ.mjs → ApiError-IYfaOR30.mjs} +1 -1
  5. package/dist/{ApiError-Bv7vlzyQ.mjs.map → ApiError-IYfaOR30.mjs.map} +1 -1
  6. package/dist/IntlCache-Ccg_cQPR.mjs +195 -0
  7. package/dist/IntlCache-Ccg_cQPR.mjs.map +1 -0
  8. package/dist/IntlCache-k2qfrDqB.cjs +212 -0
  9. package/dist/IntlCache-k2qfrDqB.cjs.map +1 -0
  10. package/dist/base64-C1sogiix.mjs +70 -0
  11. package/dist/base64-C1sogiix.mjs.map +1 -0
  12. package/dist/base64-CUcEPEC5.cjs +111 -0
  13. package/dist/base64-CUcEPEC5.cjs.map +1 -0
  14. package/dist/core-CJMv4fMa.d.cts +209 -0
  15. package/dist/core-DOrYXXpO.mjs +1487 -0
  16. package/dist/core-DOrYXXpO.mjs.map +1 -0
  17. package/dist/core-DtPj_ruw.d.mts +209 -0
  18. package/dist/core-LS3Pia40.cjs +1666 -0
  19. package/dist/core-LS3Pia40.cjs.map +1 -0
  20. package/dist/core.cjs +8 -0
  21. package/dist/core.d.cts +2 -0
  22. package/dist/core.d.mts +2 -0
  23. package/dist/core.mjs +2 -0
  24. package/dist/errors.cjs +1 -1
  25. package/dist/errors.mjs +1 -1
  26. package/dist/{id-CPbVYREY.mjs → id-BmOyfaug.mjs} +2 -2
  27. package/dist/{id-CPbVYREY.mjs.map → id-BmOyfaug.mjs.map} +1 -1
  28. package/dist/{id-VXBgyXu2.cjs → id-COlX5v3V.cjs} +6 -6
  29. package/dist/{id-VXBgyXu2.cjs.map → id-COlX5v3V.cjs.map} +1 -1
  30. package/dist/id.cjs +1 -1
  31. package/dist/id.d.cts +1 -1
  32. package/dist/id.d.mts +1 -1
  33. package/dist/id.mjs +1 -1
  34. package/dist/index.cjs +59 -1518
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +4 -162
  37. package/dist/index.d.mts +4 -162
  38. package/dist/index.mjs +6 -1441
  39. package/dist/index.mjs.map +1 -1
  40. package/dist/internal.cjs +602 -44
  41. package/dist/internal.cjs.map +1 -0
  42. package/dist/internal.d.cts +1 -1
  43. package/dist/internal.d.mts +1 -1
  44. package/dist/internal.mjs +562 -2
  45. package/dist/internal.mjs.map +1 -0
  46. package/dist/{sha2-DKowBr6H.cjs → isVariable-B08mggBy.cjs} +18 -18
  47. package/dist/isVariable-B08mggBy.cjs.map +1 -0
  48. package/dist/{stableStringify-DgDlE_pD.mjs → isVariable-CYsKFHvR.mjs} +19 -19
  49. package/dist/isVariable-CYsKFHvR.mjs.map +1 -0
  50. package/dist/{types-DazaDJbs.d.mts → types-Dfy_sRLD.d.mts} +1 -1
  51. package/dist/{types-BJdoI1d1.d.cts → types-mZeu4HS3.d.cts} +1 -1
  52. package/dist/types.d.cts +1 -1
  53. package/dist/types.d.mts +1 -1
  54. package/package.json +17 -1
  55. package/dist/internal-B3QbyI_5.mjs +0 -820
  56. package/dist/internal-B3QbyI_5.mjs.map +0 -1
  57. package/dist/internal-DIHQF9gs.cjs +0 -1070
  58. package/dist/internal-DIHQF9gs.cjs.map +0 -1
  59. package/dist/sha2-DKowBr6H.cjs.map +0 -1
  60. package/dist/stableStringify-DgDlE_pD.mjs.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,1198 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region \0rolldown/runtime.js
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
- get: ((k) => from[k]).bind(null, key),
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
- value: mod,
21
- enumerable: true
22
- }) : target, mod));
23
- //#endregion
24
- const require_internal = require("./internal-DIHQF9gs.cjs");
25
- const require_ApiError = require("./ApiError-4zIP-twr.cjs");
26
- const require_id = require("./id-VXBgyXu2.cjs");
27
- let intl_messageformat = require("intl-messageformat");
28
- intl_messageformat = __toESM(intl_messageformat);
29
- //#region src/locales/isValidLocale.ts
30
- const scriptExceptions = [
31
- "Cham",
32
- "Jamo",
33
- "Kawi",
34
- "Lisu",
35
- "Toto",
36
- "Thai"
37
- ];
38
- const isCustomLanguage = (language) => {
39
- return language >= "qaa" && language <= "qtz";
40
- };
41
- /**
42
- * Checks if a given BCP 47 language code is valid.
43
- * @param {string} code - The BCP 47 language code to validate.
44
- * @param {CustomMapping} [customMapping] - The custom mapping to use for validation.
45
- * @returns {boolean} True if the BCP 47 code is valid, false otherwise.
46
- * @internal
47
- */
48
- const _isValidLocale = (locale, customMapping) => {
49
- if (customMapping?.[locale] && typeof customMapping[locale] === "object" && "code" in customMapping[locale] && customMapping[locale].code) locale = customMapping[locale].code;
50
- try {
51
- const { language, region, script } = require_internal.intlCache.get("Locale", locale);
52
- if (locale.split("-").length !== (() => {
53
- let partCount = 1;
54
- if (region) partCount += 1;
55
- if (script) partCount += 1;
56
- return partCount;
57
- })()) return false;
58
- if (require_internal.intlCache.get("DisplayNames", ["en"], { type: "language" }).of(language) === language && !isCustomLanguage(language)) return false;
59
- if (region) {
60
- if (require_internal.intlCache.get("DisplayNames", ["en"], { type: "region" }).of(region) === region) return false;
61
- }
62
- if (script) {
63
- if (require_internal.intlCache.get("DisplayNames", ["en"], { type: "script" }).of(script) === script && !scriptExceptions.includes(script)) return false;
64
- }
65
- return true;
66
- } catch {
67
- return false;
68
- }
69
- };
70
- /**
71
- * Standardizes a BCP 47 locale to ensure correct formatting.
72
- * @param {string} locale - The BCP 47 locale to standardize.
73
- * @returns {string} The standardized BCP 47 locale, or an empty string if invalid.
74
- * @internal
75
- */
76
- const _standardizeLocale = (locale) => {
77
- try {
78
- return Intl.getCanonicalLocales(locale)[0];
79
- } catch {
80
- return locale;
81
- }
82
- };
83
- //#endregion
84
- //#region src/locales/isSameDialect.ts
85
- function checkTwoLocalesAreSameDialect(codeA, codeB) {
86
- const { language: languageA, region: regionA, script: scriptA } = require_internal.intlCache.get("Locale", codeA);
87
- const { language: languageB, region: regionB, script: scriptB } = require_internal.intlCache.get("Locale", codeB);
88
- if (languageA !== languageB) return false;
89
- if (regionA && regionB && regionA !== regionB) return false;
90
- if (scriptA && scriptB && scriptA !== scriptB) return false;
91
- return true;
92
- }
93
- /**
94
- * Test two or more language codes to determine if they are exactly the same
95
- * e.g. "en-US" and "en" would be exactly the same.
96
- * "en-GB" and "en" would be exactly the same.
97
- * "en-GB" and "en-US" would be different.
98
- * @internal
99
- */
100
- function _isSameDialect(...locales) {
101
- try {
102
- const flattenedCodes = locales.flat().map(_standardizeLocale);
103
- for (let i = 0; i < flattenedCodes.length; i++) for (let j = i + 1; j < flattenedCodes.length; j++) if (!checkTwoLocalesAreSameDialect(flattenedCodes[i], flattenedCodes[j])) return false;
104
- return true;
105
- } catch (error) {
106
- console.error(error);
107
- return false;
108
- }
109
- }
110
- //#endregion
111
- //#region src/locales/isSameLanguage.ts
112
- /**
113
- * @internal
114
- */
115
- function _isSameLanguage(...locales) {
116
- try {
117
- const languages = locales.flat().map((locale) => require_internal.intlCache.get("Locale", locale).language);
118
- return languages.every((language) => language === languages[0]);
119
- } catch (error) {
120
- console.error(error);
121
- return false;
122
- }
123
- }
124
- //#endregion
125
- //#region src/locales/requiresTranslation.ts
126
- /**
127
- * Given a target locale and a source locale, determines whether a translation is required
128
- * If the target locale and the source locale are the same, returns false, otherwise returns true
129
- * If a translation is not possible due to the target locale being outside of the optional approvedLanguages scope, also returns false
130
- * @internal
131
- */
132
- function _requiresTranslation(sourceLocale, targetLocale, approvedLocales, customMapping) {
133
- if (!_isValidLocale(sourceLocale, customMapping) || !_isValidLocale(targetLocale, customMapping) || approvedLocales && approvedLocales.some((approvedLocale) => !_isValidLocale(approvedLocale, customMapping))) return false;
134
- if (_isSameDialect(sourceLocale, targetLocale)) return false;
135
- if (approvedLocales && !approvedLocales.some((approvedLocale) => _isSameLanguage(targetLocale, approvedLocale))) return false;
136
- return true;
137
- }
138
- //#endregion
139
- //#region src/locales/customLocaleMapping.ts
140
- const getCustomProperty = (customMapping, locale, property) => {
141
- if (customMapping?.[locale]) {
142
- if (typeof customMapping[locale] === "string") return property === "name" ? customMapping[locale] : void 0;
143
- return customMapping[locale][property];
144
- }
145
- };
146
- /**
147
- * Checks if a given locale should use the canonical locale.
148
- * @param locale - The locale to check if it should use the canonical locale
149
- * @param customMapping - The custom mapping to use for checking if the locale should use the canonical locale
150
- * @returns True if the locale should use the canonical locale, false otherwise
151
- */
152
- const shouldUseCanonicalLocale = (locale, customMapping) => {
153
- return !!(customMapping?.[locale] && typeof customMapping[locale] === "object" && "code" in customMapping[locale] && customMapping[locale].code && _isValidLocale(customMapping[locale].code));
154
- };
155
- //#endregion
156
- //#region src/locales/getLocaleEmoji.ts
157
- /**
158
- * @internal
159
- */
160
- function _getLocaleEmoji(locale, customMapping) {
161
- const aliasedLocale = locale;
162
- if (customMapping && shouldUseCanonicalLocale(locale, customMapping)) locale = customMapping[locale].code;
163
- try {
164
- const standardizedLocale = _standardizeLocale(locale);
165
- const localeObject = require_internal.intlCache.get("Locale", standardizedLocale);
166
- const { language, region } = localeObject;
167
- if (customMapping) for (const l of [
168
- aliasedLocale,
169
- locale,
170
- standardizedLocale,
171
- language
172
- ]) {
173
- const customEmoji = getCustomProperty(customMapping, l, "emoji");
174
- if (customEmoji) return customEmoji;
175
- }
176
- if (region && emojis[region]) return emojis[region];
177
- const extrapolated = localeObject.maximize();
178
- const extrapolatedRegion = extrapolated.region || "";
179
- return exceptions[extrapolated.language] || emojis[extrapolatedRegion] || "🌍";
180
- } catch {
181
- return defaultEmoji;
182
- }
183
- }
184
- const europeAfricaGlobe = "🌍";
185
- const asiaAustraliaGlobe = "🌏";
186
- const defaultEmoji = europeAfricaGlobe;
187
- const exceptions = {
188
- ca: europeAfricaGlobe,
189
- eu: europeAfricaGlobe,
190
- ku: europeAfricaGlobe,
191
- bo: asiaAustraliaGlobe,
192
- ug: asiaAustraliaGlobe,
193
- gd: "🏴󠁧󠁢󠁳󠁣󠁴󠁿",
194
- cy: "🏴󠁧󠁢󠁷󠁬󠁳󠁿",
195
- gv: "🇮🇲",
196
- grc: "🏺"
197
- };
198
- const emojis = {
199
- AF: "🇦🇫",
200
- AX: "🇦🇽",
201
- AL: "🇦🇱",
202
- DZ: "🇩🇿",
203
- AS: "🇦🇸",
204
- AD: "🇦🇩",
205
- AO: "🇦🇴",
206
- AI: "🇦🇮",
207
- AQ: "🇦🇶",
208
- AG: "🇦🇬",
209
- AR: "🇦🇷",
210
- AM: "🇦🇲",
211
- AW: "🇦🇼",
212
- AU: "🇦🇺",
213
- AT: "🇦🇹",
214
- AZ: "🇦🇿",
215
- BS: "🇧🇸",
216
- BH: "🇧🇭",
217
- BD: "🇧🇩",
218
- BB: "🇧🇧",
219
- BY: "🇧🇾",
220
- BE: "🇧🇪",
221
- BZ: "🇧🇿",
222
- BJ: "🇧🇯",
223
- BM: "🇧🇲",
224
- BT: "🇧🇹",
225
- BO: "🇧🇴",
226
- BQ: "🇧🇶",
227
- BA: "🇧🇦",
228
- BW: "🇧🇼",
229
- BV: "🇧🇻",
230
- BR: "🇧🇷",
231
- IO: "🇮🇴",
232
- BN: "🇧🇳",
233
- BG: "🇧🇬",
234
- BF: "🇧🇫",
235
- BI: "🇧🇮",
236
- CV: "🇨🇻",
237
- KH: "🇰🇭",
238
- CM: "🇨🇲",
239
- CA: "🇨🇦",
240
- KY: "🇰🇾",
241
- CF: "🇨🇫",
242
- TD: "🇹🇩",
243
- CL: "🇨🇱",
244
- CN: "🇨🇳",
245
- CX: "🇨🇽",
246
- CC: "🇨🇨",
247
- CO: "🇨🇴",
248
- KM: "🇰🇲",
249
- CD: "🇨🇩",
250
- CG: "🇨🇬",
251
- CK: "🇨🇰",
252
- CR: "🇨🇷",
253
- CI: "🇨🇮",
254
- HR: "🇭🇷",
255
- CU: "🇨🇺",
256
- CW: "🇨🇼",
257
- CY: "🇨🇾",
258
- CZ: "🇨🇿",
259
- DK: "🇩🇰",
260
- DJ: "🇩🇯",
261
- DM: "🇩🇲",
262
- DO: "🇩🇴",
263
- EC: "🇪🇨",
264
- EG: "🇪🇬",
265
- SV: "🇸🇻",
266
- GQ: "🇬🇶",
267
- ER: "🇪🇷",
268
- EE: "🇪🇪",
269
- SZ: "🇸🇿",
270
- ET: "🇪🇹",
271
- FK: "🇫🇰",
272
- FO: "🇫🇴",
273
- FJ: "🇫🇯",
274
- FI: "🇫🇮",
275
- FR: "🇫🇷",
276
- GF: "🇬🇫",
277
- PF: "🇵🇫",
278
- TF: "🇹🇫",
279
- GA: "🇬🇦",
280
- GM: "🇬🇲",
281
- GE: "🇬🇪",
282
- DE: "🇩🇪",
283
- GH: "🇬🇭",
284
- GI: "🇬🇮",
285
- GR: "🇬🇷",
286
- GL: "🇬🇱",
287
- GD: "🇬🇩",
288
- GP: "🇬🇵",
289
- GU: "🇬🇺",
290
- GT: "🇬🇹",
291
- GG: "🇬🇬",
292
- GN: "🇬🇳",
293
- GW: "🇬🇼",
294
- GY: "🇬🇾",
295
- HT: "🇭🇹",
296
- HM: "🇭🇲",
297
- VA: "🇻🇦",
298
- HN: "🇭🇳",
299
- HK: "🇭🇰",
300
- HU: "🇭🇺",
301
- IS: "🇮🇸",
302
- IN: "🇮🇳",
303
- ID: "🇮🇩",
304
- IR: "🇮🇷",
305
- IQ: "🇮🇶",
306
- IE: "🇮🇪",
307
- IM: "🇮🇲",
308
- IL: "🇮🇱",
309
- IT: "🇮🇹",
310
- JM: "🇯🇲",
311
- JP: "🇯🇵",
312
- JE: "🇯🇪",
313
- JO: "🇯🇴",
314
- KZ: "🇰🇿",
315
- KE: "🇰🇪",
316
- KI: "🇰🇮",
317
- KP: "🇰🇵",
318
- KR: "🇰🇷",
319
- KW: "🇰🇼",
320
- KG: "🇰🇬",
321
- LA: "🇱🇦",
322
- LV: "🇱🇻",
323
- LB: "🇱🇧",
324
- LS: "🇱🇸",
325
- LR: "🇱🇷",
326
- LY: "🇱🇾",
327
- LI: "🇱🇮",
328
- LT: "🇱🇹",
329
- LU: "🇱🇺",
330
- MO: "🇲🇴",
331
- MG: "🇲🇬",
332
- MW: "🇲🇼",
333
- MY: "🇲🇾",
334
- MV: "🇲🇻",
335
- ML: "🇲🇱",
336
- MT: "🇲🇹",
337
- MH: "🇲🇭",
338
- MQ: "🇲🇶",
339
- MR: "🇲🇷",
340
- MU: "🇲🇺",
341
- YT: "🇾🇹",
342
- MX: "🇲🇽",
343
- FM: "🇫🇲",
344
- MD: "🇲🇩",
345
- MC: "🇲🇨",
346
- MN: "🇲🇳",
347
- ME: "🇲🇪",
348
- MS: "🇲🇸",
349
- MA: "🇲🇦",
350
- MZ: "🇲🇿",
351
- MM: "🇲🇲",
352
- NA: "🇳🇦",
353
- NR: "🇳🇷",
354
- NP: "🇳🇵",
355
- NL: "🇳🇱",
356
- NC: "🇳🇨",
357
- NZ: "🇳🇿",
358
- NI: "🇳🇮",
359
- NE: "🇳🇪",
360
- NG: "🇳🇬",
361
- NU: "🇳🇺",
362
- NF: "🇳🇫",
363
- MK: "🇲🇰",
364
- MP: "🇲🇵",
365
- NO: "🇳🇴",
366
- OM: "🇴🇲",
367
- PK: "🇵🇰",
368
- PW: "🇵🇼",
369
- PS: "🇵🇸",
370
- PA: "🇵🇦",
371
- PG: "🇵🇬",
372
- PY: "🇵🇾",
373
- PE: "🇵🇪",
374
- PH: "🇵🇭",
375
- PN: "🇵🇳",
376
- PL: "🇵🇱",
377
- PT: "🇵🇹",
378
- PR: "🇵🇷",
379
- QA: "🇶🇦",
380
- RE: "🇷🇪",
381
- RO: "🇷🇴",
382
- RU: "🇷🇺",
383
- RW: "🇷🇼",
384
- BL: "🇧🇱",
385
- SH: "🇸🇭",
386
- KN: "🇰🇳",
387
- LC: "🇱🇨",
388
- MF: "🇲🇫",
389
- PM: "🇵🇲",
390
- VC: "🇻🇨",
391
- WS: "🇼🇸",
392
- SM: "🇸🇲",
393
- ST: "🇸🇹",
394
- SA: "🇸🇦",
395
- SN: "🇸🇳",
396
- RS: "🇷🇸",
397
- SC: "🇸🇨",
398
- SL: "🇸🇱",
399
- SG: "🇸🇬",
400
- SX: "🇸🇽",
401
- SK: "🇸🇰",
402
- SI: "🇸🇮",
403
- SB: "🇸🇧",
404
- SO: "🇸🇴",
405
- ZA: "🇿🇦",
406
- GS: "🇬🇸",
407
- SS: "🇸🇸",
408
- ES: "🇪🇸",
409
- LK: "🇱🇰",
410
- SD: "🇸🇩",
411
- SR: "🇸🇷",
412
- SJ: "🇸🇯",
413
- SE: "🇸🇪",
414
- CH: "🇨🇭",
415
- SY: "🇸🇾",
416
- TW: "🇹🇼",
417
- TJ: "🇹🇯",
418
- TZ: "🇹🇿",
419
- TH: "🇹🇭",
420
- TL: "🇹🇱",
421
- TG: "🇹🇬",
422
- TK: "🇹🇰",
423
- TO: "🇹🇴",
424
- TT: "🇹🇹",
425
- TN: "🇹🇳",
426
- TR: "🇹🇷",
427
- TM: "🇹🇲",
428
- TC: "🇹🇨",
429
- TV: "🇹🇻",
430
- UG: "🇺🇬",
431
- UA: "🇺🇦",
432
- AE: "🇦🇪",
433
- GB: "🇬🇧",
434
- US: "🇺🇸",
435
- UM: "🇺🇲",
436
- UY: "🇺🇾",
437
- UZ: "🇺🇿",
438
- VU: "🇻🇺",
439
- VE: "🇻🇪",
440
- VN: "🇻🇳",
441
- VG: "🇻🇬",
442
- VI: "🇻🇮",
443
- WF: "🇼🇫",
444
- EH: "🇪🇭",
445
- YE: "🇾🇪",
446
- ZM: "🇿🇲",
447
- ZW: "🇿🇼",
448
- EU: "🇪🇺",
449
- "419": "🌎"
450
- };
451
- //#endregion
452
- //#region src/locales/getLocaleProperties.ts
453
- /**
454
- * Creates a set of custom locale properties from a custom mapping.
455
- *
456
- * @param lArray - An array of locale codes to search for in the custom mapping.
457
- * @param customMapping - Optional custom mapping of locale codes to names.
458
- * @returns A partial set of locale properties, or undefined if no custom mapping is provided.
459
- */
460
- function createCustomLocaleProperties(lArray, customMapping) {
461
- if (customMapping) {
462
- let merged = {};
463
- for (const l of lArray) {
464
- const value = customMapping[l];
465
- if (value) {
466
- if (typeof value === "string") merged.name ||= value;
467
- else if (value) merged = {
468
- ...value,
469
- ...merged
470
- };
471
- }
472
- }
473
- return merged;
474
- }
475
- }
476
- /**
477
- * @internal
478
- */
479
- function _getLocaleProperties(locale, defaultLocale = "en", customMapping) {
480
- const aliasedLocale = locale;
481
- if (customMapping && shouldUseCanonicalLocale(locale, customMapping)) locale = customMapping[locale].code;
482
- defaultLocale ||= "en";
483
- try {
484
- const standardizedLocale = _standardizeLocale(locale);
485
- const localeObject = require_internal.intlCache.get("Locale", locale);
486
- const languageCode = localeObject.language;
487
- const customLocaleProperties = createCustomLocaleProperties([
488
- aliasedLocale,
489
- locale,
490
- standardizedLocale,
491
- languageCode
492
- ], customMapping);
493
- const baseRegion = localeObject.region;
494
- const maximizedLocale = localeObject.maximize();
495
- const maximizedCode = maximizedLocale.toString();
496
- const regionCode = localeObject.region || customLocaleProperties?.regionCode || maximizedLocale.region || "";
497
- const scriptCode = localeObject.script || customLocaleProperties?.scriptCode || maximizedLocale.script || "";
498
- const minimizedCode = localeObject.minimize().toString();
499
- const defaultLanguageOrder = [
500
- defaultLocale,
501
- locale,
502
- "en"
503
- ];
504
- const nativeLanguageOrder = [
505
- locale,
506
- defaultLocale,
507
- "en"
508
- ];
509
- const languageNames = require_internal.intlCache.get("DisplayNames", defaultLanguageOrder, { type: "language" });
510
- const nativeLanguageNames = require_internal.intlCache.get("DisplayNames", nativeLanguageOrder, { type: "language" });
511
- const customName = customLocaleProperties?.name;
512
- const customNativeName = customLocaleProperties?.nativeName || customLocaleProperties?.name;
513
- const name = customName || languageNames.of(locale) || locale;
514
- const nativeName = customNativeName || nativeLanguageNames.of(locale) || locale;
515
- const maximizedName = customLocaleProperties?.maximizedName || customName || languageNames.of(maximizedCode) || locale;
516
- const nativeMaximizedName = customLocaleProperties?.nativeMaximizedName || customNativeName || nativeLanguageNames.of(maximizedCode) || locale;
517
- const minimizedName = customLocaleProperties?.minimizedName || customName || languageNames.of(minimizedCode) || locale;
518
- const nativeMinimizedName = customLocaleProperties?.nativeMinimizedName || customNativeName || nativeLanguageNames.of(minimizedCode) || locale;
519
- const languageName = customLocaleProperties?.languageName || customName || languageNames.of(languageCode) || locale;
520
- const nativeLanguageName = customLocaleProperties?.nativeLanguageName || customNativeName || nativeLanguageNames.of(languageCode) || locale;
521
- const nameWithRegionCode = customLocaleProperties?.nameWithRegionCode || baseRegion ? `${languageName} (${baseRegion})` : name;
522
- const nativeNameWithRegionCode = customLocaleProperties?.nativeNameWithRegionCode || (baseRegion ? `${nativeLanguageName} (${baseRegion})` : nativeName) || nameWithRegionCode;
523
- const regionNames = require_internal.intlCache.get("DisplayNames", defaultLanguageOrder, { type: "region" });
524
- const nativeRegionNames = require_internal.intlCache.get("DisplayNames", nativeLanguageOrder, { type: "region" });
525
- const regionName = customLocaleProperties?.regionName || (regionCode ? regionNames.of(regionCode) : "") || "";
526
- const nativeRegionName = customLocaleProperties?.nativeRegionName || (regionCode ? nativeRegionNames.of(regionCode) : "") || "";
527
- const scriptNames = require_internal.intlCache.get("DisplayNames", defaultLanguageOrder, { type: "script" });
528
- const nativeScriptNames = require_internal.intlCache.get("DisplayNames", nativeLanguageOrder, { type: "script" });
529
- return {
530
- code: standardizedLocale,
531
- name,
532
- nativeName,
533
- maximizedCode,
534
- maximizedName,
535
- nativeMaximizedName,
536
- minimizedCode,
537
- minimizedName,
538
- nativeMinimizedName,
539
- languageCode,
540
- languageName,
541
- nativeLanguageName,
542
- nameWithRegionCode,
543
- nativeNameWithRegionCode,
544
- regionCode,
545
- regionName,
546
- nativeRegionName,
547
- scriptCode,
548
- scriptName: customLocaleProperties?.scriptName || (scriptCode ? scriptNames.of(scriptCode) : "") || "",
549
- nativeScriptName: customLocaleProperties?.nativeScriptName || (scriptCode ? nativeScriptNames.of(scriptCode) : "") || "",
550
- emoji: customLocaleProperties?.emoji || _getLocaleEmoji(standardizedLocale, customMapping)
551
- };
552
- } catch {
553
- let code = _isValidLocale(locale) ? _standardizeLocale(locale) : locale;
554
- const codeParts = code?.split("-");
555
- let languageCode = codeParts?.[0] || code || "";
556
- let regionCode = codeParts.length > 2 ? codeParts?.[2] : codeParts?.[1] || "";
557
- let scriptCode = codeParts?.[3] || "";
558
- const customLocaleProperties = createCustomLocaleProperties([code, languageCode], customMapping);
559
- code = customLocaleProperties?.code || code;
560
- const name = customLocaleProperties?.name || code;
561
- const nativeName = customLocaleProperties?.nativeName || name;
562
- const maximizedCode = customLocaleProperties?.maximizedCode || code;
563
- const maximizedName = customLocaleProperties?.maximizedName || name;
564
- const nativeMaximizedName = customLocaleProperties?.nativeMaximizedName || nativeName;
565
- const minimizedCode = customLocaleProperties?.minimizedCode || code;
566
- const minimizedName = customLocaleProperties?.minimizedName || name;
567
- const nativeMinimizedName = customLocaleProperties?.nativeMinimizedName || nativeName;
568
- languageCode = customLocaleProperties?.languageCode || languageCode;
569
- const languageName = customLocaleProperties?.languageName || name;
570
- const nativeLanguageName = customLocaleProperties?.nativeLanguageName || nativeName;
571
- regionCode = customLocaleProperties?.regionCode || regionCode;
572
- const regionName = customLocaleProperties?.regionName || "";
573
- const nativeRegionName = customLocaleProperties?.nativeRegionName || "";
574
- scriptCode = customLocaleProperties?.scriptCode || scriptCode;
575
- const scriptName = customLocaleProperties?.scriptName || "";
576
- const nativeScriptName = customLocaleProperties?.nativeScriptName || "";
577
- const nameWithRegionCode = customLocaleProperties?.nameWithRegionCode || (regionName ? `${languageName} (${regionName})` : name);
578
- const nativeNameWithRegionCode = customLocaleProperties?.nativeNameWithRegionCode || (nativeRegionName ? `${nativeLanguageName} (${nativeRegionName})` : nativeName);
579
- const emoji = customLocaleProperties?.emoji || "🌍";
580
- return {
581
- code,
582
- name,
583
- nativeName,
584
- maximizedCode,
585
- maximizedName,
586
- nativeMaximizedName,
587
- minimizedCode,
588
- minimizedName,
589
- nativeMinimizedName,
590
- languageCode,
591
- languageName,
592
- nativeLanguageName,
593
- nameWithRegionCode,
594
- nativeNameWithRegionCode,
595
- regionCode,
596
- regionName,
597
- nativeRegionName,
598
- scriptCode,
599
- scriptName,
600
- nativeScriptName,
601
- emoji
602
- };
603
- }
604
- }
605
- //#endregion
606
- //#region src/locales/determineLocale.ts
607
- /**
608
- * Given a list of locales and a list of approved locales, sorted in preference order
609
- * Determines which locale is the best match among the approved locales, prioritizing exact matches and falling back to dialects of the same language
610
- * @internal
611
- */
612
- function _determineLocale(locales, approvedLocales, customMapping) {
613
- if (typeof locales === "string") locales = [locales];
614
- locales = locales.filter((locale) => _isValidLocale(locale, customMapping)).map(_standardizeLocale);
615
- approvedLocales = approvedLocales.filter((locale) => _isValidLocale(locale, customMapping)).map(_standardizeLocale);
616
- for (const locale of locales) {
617
- const candidates = approvedLocales.filter((approvedLocale) => _isSameLanguage(locale, approvedLocale));
618
- const getMatchingCode = ({ locale, languageCode, minimizedCode, regionCode, scriptCode }) => {
619
- const locales = [
620
- locale,
621
- `${languageCode}-${regionCode}`,
622
- `${languageCode}-${scriptCode}`,
623
- minimizedCode
624
- ];
625
- for (const l of locales) if (candidates.includes(l)) return l;
626
- return null;
627
- };
628
- const { languageCode, ...codes } = _getLocaleProperties(locale);
629
- const matchingCode = getMatchingCode({
630
- locale,
631
- languageCode,
632
- ...codes
633
- }) || getMatchingCode({
634
- locale: languageCode,
635
- ..._getLocaleProperties(languageCode)
636
- });
637
- if (matchingCode) return matchingCode;
638
- }
639
- }
640
- //#endregion
641
- //#region src/logging/logger.ts
642
- const LOG_LEVELS = {
643
- debug: 0,
644
- info: 1,
645
- warn: 2,
646
- error: 3,
647
- off: 4
648
- };
649
- const LOG_COLORS = {
650
- debug: "\x1B[36m",
651
- info: "\x1B[32m",
652
- warn: "\x1B[33m",
653
- error: "\x1B[31m",
654
- off: ""
655
- };
656
- const RESET_COLOR = "\x1B[0m";
657
- /**
658
- * Get the configured log level from environment variable or default to 'warn'
659
- */
660
- function getConfiguredLogLevel() {
661
- if (typeof process !== "undefined" && process.env?._GT_LOG_LEVEL) {
662
- const envLevel = process.env._GT_LOG_LEVEL.toLowerCase();
663
- if (envLevel in LOG_LEVELS) return envLevel;
664
- }
665
- return "warn";
666
- }
667
- /**
668
- * Console log handler that outputs formatted messages to console
669
- */
670
- var ConsoleLogHandler = class {
671
- constructor(config) {
672
- this.config = config;
673
- }
674
- handle(entry) {
675
- const parts = [];
676
- if (this.config.includeTimestamp) parts.push(`[${entry.timestamp.toISOString()}]`);
677
- const colorCode = LOG_COLORS[entry.level];
678
- const levelText = `[${entry.level.toUpperCase()}]`;
679
- parts.push(`${colorCode}${levelText}${RESET_COLOR}`);
680
- if (this.config.prefix) parts.push(`[${this.config.prefix}]`);
681
- if (this.config.includeContext && entry.context) parts.push(`[${entry.context}]`);
682
- parts.push(entry.message);
683
- if (entry.metadata && Object.keys(entry.metadata).length > 0) parts.push(`\n Metadata: ${JSON.stringify(entry.metadata, null, 2)}`);
684
- const formattedMessage = parts.join(" ");
685
- switch (entry.level) {
686
- case "debug":
687
- console.debug(formattedMessage);
688
- break;
689
- case "info":
690
- console.info(formattedMessage);
691
- break;
692
- case "warn":
693
- console.warn(formattedMessage);
694
- break;
695
- case "error":
696
- console.error(formattedMessage);
697
- break;
698
- }
699
- }
700
- };
701
- /**
702
- * Main Logger class providing structured logging capabilities
703
- */
704
- var Logger = class {
705
- constructor(config = {}) {
706
- this.config = {
707
- level: getConfiguredLogLevel(),
708
- includeTimestamp: true,
709
- includeContext: true,
710
- enableConsole: true,
711
- handlers: [],
712
- ...config
713
- };
714
- this.handlers = [...this.config.handlers || []];
715
- if (this.config.enableConsole) this.handlers.push(new ConsoleLogHandler(this.config));
716
- }
717
- /**
718
- * Add a custom log handler
719
- */
720
- addHandler(handler) {
721
- this.handlers.push(handler);
722
- }
723
- /**
724
- * Remove a log handler
725
- */
726
- removeHandler(handler) {
727
- const index = this.handlers.indexOf(handler);
728
- if (index > -1) this.handlers.splice(index, 1);
729
- }
730
- /**
731
- * Update logger configuration
732
- */
733
- configure(config) {
734
- this.config = {
735
- ...this.config,
736
- ...config
737
- };
738
- }
739
- /**
740
- * Check if a log level should be output based on current configuration
741
- */
742
- shouldLog(level) {
743
- return LOG_LEVELS[level] >= LOG_LEVELS[this.config.level];
744
- }
745
- /**
746
- * Internal logging method that creates log entries and passes them to handlers
747
- */
748
- log(level, message, context, metadata) {
749
- if (!this.shouldLog(level)) return;
750
- const entry = {
751
- level,
752
- message,
753
- timestamp: /* @__PURE__ */ new Date(),
754
- context,
755
- metadata
756
- };
757
- this.handlers.forEach((handler) => {
758
- try {
759
- handler.handle(entry);
760
- } catch (error) {
761
- console.error("Error in log handler:", error);
762
- }
763
- });
764
- }
765
- /**
766
- * Log a debug message
767
- * Used for detailed diagnostic information, typically of interest only when diagnosing problems
768
- */
769
- debug(message, context, metadata) {
770
- this.log("debug", message, context, metadata);
771
- }
772
- /**
773
- * Log an info message
774
- * Used for general information about application operation
775
- */
776
- info(message, context, metadata) {
777
- this.log("info", message, context, metadata);
778
- }
779
- /**
780
- * Log a warning message
781
- * Used for potentially problematic situations that don't prevent operation
782
- */
783
- warn(message, context, metadata) {
784
- this.log("warn", message, context, metadata);
785
- }
786
- /**
787
- * Log an error message
788
- * Used for error events that might still allow the application to continue
789
- */
790
- error(message, context, metadata) {
791
- this.log("error", message, context, metadata);
792
- }
793
- /**
794
- * Create a child logger with a specific context
795
- */
796
- child(context) {
797
- return new ContextLogger(this, context);
798
- }
799
- /**
800
- * Get current logger configuration
801
- */
802
- getConfig() {
803
- return { ...this.config };
804
- }
805
- };
806
- /**
807
- * Context logger that automatically includes context information
808
- */
809
- var ContextLogger = class ContextLogger {
810
- constructor(logger, context) {
811
- this.logger = logger;
812
- this.context = context;
813
- }
814
- debug(message, metadata) {
815
- this.logger.debug(message, this.context, metadata);
816
- }
817
- info(message, metadata) {
818
- this.logger.info(message, this.context, metadata);
819
- }
820
- warn(message, metadata) {
821
- this.logger.warn(message, this.context, metadata);
822
- }
823
- error(message, metadata) {
824
- this.logger.error(message, this.context, metadata);
825
- }
826
- child(childContext) {
827
- return new ContextLogger(this.logger, `${this.context}:${childContext}`);
828
- }
829
- };
830
- const defaultLogger = new Logger({
831
- level: getConfiguredLogLevel(),
832
- includeTimestamp: true,
833
- includeContext: true,
834
- prefix: "GT"
835
- });
836
- const fetchLogger = defaultLogger.child("fetch");
837
- defaultLogger.child("validation");
838
- defaultLogger.child("formatting");
839
- defaultLogger.child("locale");
840
- const gtInstanceLogger = defaultLogger.child("GT instance");
841
- //#endregion
842
- //#region src/formatting/format.ts
843
- /**
844
- * Formats a string value with cutoff behavior according to the specified locales and options.
845
- *
846
- * @param {Object} params - The parameters for the cutoff formatting.
847
- * @param {string} params.value - The string value to format with cutoff behavior.
848
- * @param {string | string[]} [params.locales='en'] - The locales to use for formatting.
849
- * @param {CutoffFormatOptions} [params.options={}] - Additional options for cutoff formatting.
850
- * @param {number} [params.options.maxChars] - The maximum number of characters to display.
851
- * @param {CutoffFormatStyle} [params.options.style='ellipsis'] - The style of the terminator.
852
- * @param {string} [params.options.terminator] - Optional override for the terminator to use.
853
- * @param {string} [params.options.separator] - Optional override for the separator between terminator and value.
854
- *
855
- * @returns {string} The formatted string with terminator applied if cutoff occurs.
856
- * @internal
857
- *
858
- * @example
859
- * _formatCutoff({ value: 'Hello, world!', options: { maxChars: 8 } }); // Returns 'Hello, w...'
860
- *
861
- * Will fallback to an empty string if formatting fails.
862
- */
863
- function _formatCutoff({ value, locales = "en", options = {} }) {
864
- return require_internal.intlCache.get("CutoffFormat", locales, options).format(value);
865
- }
866
- /**
867
- * Formats a message according to the specified locales and options.
868
- *
869
- * @param {string} message - The message to format.
870
- * @param {string | string[]} [locales='en'] - The locales to use for formatting.
871
- * @param {Record<string, any>} [variables={}] - The variables to use for formatting.
872
- * @returns {string} The formatted message.
873
- * @internal
874
- *
875
- * Will fallback to an empty string
876
- * TODO: add this to custom formats
877
- */
878
- function _formatMessageICU(message, locales = "en", variables = {}) {
879
- return new intl_messageformat.default(message, locales).format(variables)?.toString() ?? "";
880
- }
881
- /**
882
- * Returns the message as-is without any formatting.
883
- *
884
- * @param {string} message - The message to return.
885
- * @returns {string} The original message, unchanged.
886
- * @internal
887
- *
888
- * TODO: add this to custom formats
889
- */
890
- function _formatMessageString(message) {
891
- return message;
892
- }
893
- /**
894
- * Formats a number according to the specified locales and options.
895
- *
896
- * @param {Object} params - The parameters for the number formatting.
897
- * @param {number} params.value - The number to format.
898
- * @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.
899
- * @param {Intl.NumberFormatOptions} [params.options={}] - Additional options for number formatting.
900
- *
901
- * @returns {string} The formatted number.
902
- * @internal
903
- */
904
- function _formatNum({ value, locales = ["en"], options = {} }) {
905
- return require_internal.intlCache.get("NumberFormat", locales, {
906
- numberingSystem: "latn",
907
- ...options
908
- }).format(value);
909
- }
910
- /**
911
- * Formats a date according to the specified locales and options.
912
- *
913
- * @param {Object} params - The parameters for the date formatting.
914
- * @param {Date} params.value - The date to format.
915
- * @param {string | string[]} [params.locales='en'] - The locales to use for formatting.
916
- * @param {Intl.DateTimeFormatOptions} [params.options={}] - Additional options for date formatting.
917
- *
918
- * @returns {string} The formatted date.
919
- * @internal
920
- */
921
- function _formatDateTime({ value, locales = ["en"], options = {} }) {
922
- return require_internal.intlCache.get("DateTimeFormat", locales, {
923
- calendar: "gregory",
924
- numberingSystem: "latn",
925
- ...options
926
- }).format(value);
927
- }
928
- /**
929
- * Formats a currency value according to the specified locales, currency, and options.
930
- *
931
- * @param {Object} params - The parameters for the currency formatting.
932
- * @param {number} params.value - The currency value to format.
933
- * @param {string} params.currency - The currency code (e.g., 'USD').
934
- * @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.
935
- * @param {Intl.NumberFormatOptions} [params.options={}] - Additional options for currency formatting.
936
- *
937
- * @returns {string} The formatted currency value.
938
- * @internal
939
- */
940
- function _formatCurrency({ value, locales = ["en"], currency = "USD", options = {} }) {
941
- return require_internal.intlCache.get("NumberFormat", locales, {
942
- style: "currency",
943
- currency,
944
- numberingSystem: "latn",
945
- ...options
946
- }).format(value);
947
- }
948
- /**
949
- * Formats a list of items according to the specified locales and options.
950
- *
951
- * @param {Object} params - The parameters for the list formatting.
952
- * @param {Array<string | number>} params.value - The list of items to format.
953
- * @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.
954
- * @param {Intl.ListFormatOptions} [params.options={}] - Additional options for list formatting.
955
- *
956
- * @returns {string} The formatted list.
957
- * @internal
958
- */
959
- function _formatList({ value, locales = ["en"], options = {} }) {
960
- return require_internal.intlCache.get("ListFormat", locales, {
961
- type: "conjunction",
962
- style: "long",
963
- ...options
964
- }).format(value);
965
- }
966
- /**
967
- * Formats a list of items according to the specified locales and options.
968
- * @param {Object} params - The parameters for the list formatting.
969
- * @param {Array<T>} params.value - The list of items to format.
970
- * @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.
971
- * @param {Intl.ListFormatOptions} [params.options={}] - Additional options for list formatting.
972
- * @returns {Array<T | string>} The formatted list parts.
973
- * @internal
974
- */
975
- function _formatListToParts({ value, locales = ["en"], options = {} }) {
976
- const formatListParts = require_internal.intlCache.get("ListFormat", locales, {
977
- type: "conjunction",
978
- style: "long",
979
- ...options
980
- }).formatToParts(value.map(() => "1"));
981
- let partIndex = 0;
982
- return formatListParts.map((part) => {
983
- if (part.type === "element") return value[partIndex++];
984
- return part.value;
985
- });
986
- }
987
- /**
988
- * Selects the best unit and computes the value for relative time formatting
989
- * based on the difference between a date and a base date.
990
- * @param {Date} date - The target date.
991
- * @param {Date} baseDate - The base date to compute relative time from. Must be provided by the caller for hydration safety.
992
- * @returns {{ value: number, unit: Intl.RelativeTimeFormatUnit }} The computed value and unit.
993
- * @internal
994
- */
995
- function _selectRelativeTimeUnit(date, baseDate) {
996
- const now = baseDate.getTime();
997
- const diffMs = date.getTime() - now;
998
- const absDiffMs = Math.abs(diffMs);
999
- const sign = diffMs < 0 ? -1 : 1;
1000
- const seconds = Math.floor(absDiffMs / 1e3);
1001
- const minutes = Math.floor(absDiffMs / (1e3 * 60));
1002
- const hours = Math.floor(absDiffMs / (1e3 * 60 * 60));
1003
- const days = Math.floor(absDiffMs / (1e3 * 60 * 60 * 24));
1004
- const weeks = Math.floor(absDiffMs / (1e3 * 60 * 60 * 24 * 7));
1005
- const months = Math.floor(absDiffMs / (1e3 * 60 * 60 * 24 * 30));
1006
- const years = Math.floor(absDiffMs / (1e3 * 60 * 60 * 24 * 365));
1007
- if (seconds < 60) return {
1008
- value: sign * seconds,
1009
- unit: "second"
1010
- };
1011
- if (minutes < 60) return {
1012
- value: sign * minutes,
1013
- unit: "minute"
1014
- };
1015
- if (hours < 24) return {
1016
- value: sign * hours,
1017
- unit: "hour"
1018
- };
1019
- if (days < 7) return {
1020
- value: sign * days,
1021
- unit: "day"
1022
- };
1023
- if (days < 28) return {
1024
- value: sign * weeks,
1025
- unit: "week"
1026
- };
1027
- if (months < 1) return {
1028
- value: sign * weeks,
1029
- unit: "week"
1030
- };
1031
- if (months < 12) return {
1032
- value: sign * months,
1033
- unit: "month"
1034
- };
1035
- if (years < 1) return {
1036
- value: sign * months,
1037
- unit: "month"
1038
- };
1039
- return {
1040
- value: sign * years,
1041
- unit: "year"
1042
- };
1043
- }
1044
- /**
1045
- * Formats a relative time from a Date, automatically selecting the best unit.
1046
- * @internal
1047
- */
1048
- function _formatRelativeTimeFromDate({ date, baseDate, locales = ["en"], options = {} }) {
1049
- const { value, unit } = _selectRelativeTimeUnit(date, baseDate);
1050
- return _formatRelativeTime({
1051
- value,
1052
- unit,
1053
- locales,
1054
- options
1055
- });
1056
- }
1057
- /**
1058
- * Formats a relative time value according to the specified locales and options.
1059
- *
1060
- * @param {Object} params - The parameters for the relative time formatting.
1061
- * @param {number} params.value - The relative time value to format.
1062
- * @param {Intl.RelativeTimeFormatUnit} params.unit - The unit of time (e.g., 'second', 'minute', 'hour', 'day', 'week', 'month', 'year').
1063
- * @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.
1064
- * @param {Intl.RelativeTimeFormatOptions} [params.options={}] - Additional options for relative time formatting.
1065
- *
1066
- * @returns {string} The formatted relative time string.
1067
- * @internal
1068
- */
1069
- function _formatRelativeTime({ value, unit, locales = ["en"], options = {} }) {
1070
- return require_internal.intlCache.get("RelativeTimeFormat", locales, {
1071
- style: "long",
1072
- numeric: "auto",
1073
- ...options
1074
- }).format(value, unit);
1075
- }
1076
- //#endregion
1077
- //#region src/locales/getLocaleName.ts
1078
- /**
1079
- * Retrieves the display name(s) of locale code(s) using Intl.DisplayNames.
1080
- *
1081
- * @param {string} locale - A BCP-47 locale code.
1082
- * @param {string} [defaultLocale=libraryDefaultLocale] - The locale for display names.
1083
- * @returns {string} The display name(s) corresponding to the code(s), or empty string(s) if invalid.
1084
- * @internal
1085
- */
1086
- function _getLocaleName(locale, defaultLocale = "en", customMapping) {
1087
- const aliasedLocale = locale;
1088
- if (customMapping && shouldUseCanonicalLocale(locale, customMapping)) locale = customMapping[locale].code;
1089
- defaultLocale ||= "en";
1090
- try {
1091
- const standardizedLocale = _standardizeLocale(locale);
1092
- if (customMapping) for (const l of [
1093
- aliasedLocale,
1094
- locale,
1095
- standardizedLocale,
1096
- require_internal.intlCache.get("Locale", standardizedLocale).language
1097
- ]) {
1098
- const customName = getCustomProperty(customMapping, l, "name");
1099
- if (customName) return customName;
1100
- }
1101
- return require_internal.intlCache.get("DisplayNames", [
1102
- defaultLocale,
1103
- standardizedLocale,
1104
- "en"
1105
- ], { type: "language" }).of(standardizedLocale) || "";
1106
- } catch {
1107
- return "";
1108
- }
1109
- }
1110
- //#endregion
1111
- //#region src/locales/getLocaleDirection.ts
1112
- /**
1113
- * Get the text direction for a given locale code using the Intl.Locale API.
1114
- *
1115
- * @param {string} code - The locale code to check.
1116
- * @returns {string} - 'rtl' if the language is right-to-left, otherwise 'ltr'.
1117
- * @internal
1118
- */
1119
- function _getLocaleDirection(code) {
1120
- try {
1121
- const textInfoDirection = extractDirectionWithTextInfo(require_internal.intlCache.get("Locale", code));
1122
- if (textInfoDirection) return textInfoDirection;
1123
- } catch {}
1124
- const { scriptCode, languageCode } = _getLocaleProperties(code);
1125
- if (scriptCode) return isRtlScript(scriptCode) ? "rtl" : "ltr";
1126
- if (languageCode) return isRtlLanguage(languageCode) ? "rtl" : "ltr";
1127
- return "ltr";
1128
- }
1129
- const RTL_SCRIPTS = new Set([
1130
- "arab",
1131
- "adlm",
1132
- "hebr",
1133
- "nkoo",
1134
- "rohg",
1135
- "samr",
1136
- "syrc",
1137
- "thaa",
1138
- "yezi"
1139
- ]);
1140
- const RTL_LANGUAGES = new Set([
1141
- "ar",
1142
- "arc",
1143
- "ckb",
1144
- "dv",
1145
- "fa",
1146
- "he",
1147
- "iw",
1148
- "ku",
1149
- "lrc",
1150
- "nqo",
1151
- "ps",
1152
- "pnb",
1153
- "sd",
1154
- "syr",
1155
- "ug",
1156
- "ur",
1157
- "yi"
1158
- ]);
1159
- /**
1160
- * Handles extracting direction via textInfo property
1161
- * @param Locale - Intl.Locale object
1162
- * @returns {'ltr' | 'rtl'} - The direction of the locale
1163
- *
1164
- * Intl.Locale.prototype.getTextInfo() / textInfo property incorporated in ES2024 Specification.
1165
- * This is not supported by all browsers yet.
1166
- * See: {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo#browser_compatibility}
1167
- */
1168
- function extractDirectionWithTextInfo(locale) {
1169
- if ("textInfo" in locale && typeof locale.textInfo === "object" && locale.textInfo !== null && "direction" in locale.textInfo && (locale.textInfo?.direction === "rtl" || locale.textInfo?.direction === "ltr")) return locale.textInfo?.direction;
1170
- }
1171
- function isRtlScript(script) {
1172
- return script ? RTL_SCRIPTS.has(script.toLowerCase()) : false;
1173
- }
1174
- function isRtlLanguage(language) {
1175
- return language ? RTL_LANGUAGES.has(language.toLowerCase()) : false;
1176
- }
1177
- //#endregion
1178
- //#region src/locales/isSupersetLocale.ts
1179
- /**
1180
- * @internal
1181
- */
1182
- function _isSupersetLocale(superLocale, subLocale) {
1183
- try {
1184
- const { language: languageSuper, region: regionSuper, script: scriptSuper } = require_internal.intlCache.get("Locale", _standardizeLocale(superLocale));
1185
- const { language: languageSub, region: regionSub, script: scriptSub } = require_internal.intlCache.get("Locale", _standardizeLocale(subLocale));
1186
- if (languageSuper !== languageSub) return false;
1187
- if (regionSuper && regionSuper !== regionSub) return false;
1188
- if (scriptSuper && scriptSuper !== scriptSub) return false;
1189
- return true;
1190
- } catch (error) {
1191
- console.error(error);
1192
- return false;
1193
- }
1194
- }
1195
- //#endregion
2
+ const require_IntlCache = require("./IntlCache-k2qfrDqB.cjs");
3
+ const require_core = require("./core-LS3Pia40.cjs");
4
+ const require_base64 = require("./base64-CUcEPEC5.cjs");
5
+ const require_ApiError = require("./ApiError-CZ45tkW6.cjs");
6
+ const require_id = require("./id-COlX5v3V.cjs");
1196
7
  //#region src/logging/errors.ts
1197
8
  const GT_ERROR_PREFIX = "GT Error:";
1198
9
  const translationTimeoutError = (timeout) => `${GT_ERROR_PREFIX} Translation request timed out after ${timeout}ms.`;
@@ -1220,7 +31,7 @@ const invalidLocalesError = (locales) => `${GT_ERROR_PREFIX} Invalid locales: ${
1220
31
  async function fetchWithTimeout(url, options, timeout) {
1221
32
  const controller = new AbortController();
1222
33
  const signal = controller.signal;
1223
- timeout = timeout ? timeout : require_internal.defaultTimeout;
34
+ timeout = timeout ? timeout : require_IntlCache.defaultTimeout;
1224
35
  const timeoutId = timeout ? setTimeout(() => controller.abort(), timeout) : null;
1225
36
  try {
1226
37
  return await fetch(url, {
@@ -1255,11 +66,11 @@ async function validateResponse(response) {
1255
66
  function handleFetchError(error, timeout) {
1256
67
  if (error instanceof Error && error.name === "AbortError") {
1257
68
  const errorMessage = translationTimeoutError(timeout);
1258
- fetchLogger.error(errorMessage);
69
+ require_core.fetchLogger.error(errorMessage);
1259
70
  throw new Error(errorMessage);
1260
71
  }
1261
72
  const errorMessage = translationRequestFailedError(error instanceof Error ? error.message : String(error));
1262
- fetchLogger.error(errorMessage);
73
+ require_core.fetchLogger.error(errorMessage);
1263
74
  throw error;
1264
75
  }
1265
76
  //#endregion
@@ -1469,7 +280,7 @@ async function processBatches(items, processor, options = {}) {
1469
280
  * @returns The result of the API call
1470
281
  */
1471
282
  async function _enqueueFiles(files, options, config) {
1472
- require_internal.validateFileFormatTransforms(files);
283
+ require_base64.validateFileFormatTransforms(files);
1473
284
  const result = await processBatches(files, async (batch) => {
1474
285
  const apiResult = await apiRequest(config, "/v2/project/translations/enqueue", {
1475
286
  body: {
@@ -1529,7 +340,7 @@ async function _downloadFileBatch(requests, options, config) {
1529
340
  timeout: options.timeout
1530
341
  })).files.map((file) => ({
1531
342
  ...file,
1532
- data: require_internal.decode(file.data)
343
+ data: require_base64.decode(file.data)
1533
344
  }));
1534
345
  }, { batchSize: 100 });
1535
346
  }
@@ -1591,45 +402,20 @@ function _getRegionProperties(region, defaultLocale = "en", customMapping) {
1591
402
  try {
1592
403
  return {
1593
404
  code: region,
1594
- name: require_internal.intlCache.get("DisplayNames", [defaultLocale, "en"], { type: "region" }).of(region) || region,
1595
- emoji: emojis[region] || "🌍",
405
+ name: require_IntlCache.intlCache.get("DisplayNames", [defaultLocale, "en"], { type: "region" }).of(region) || region,
406
+ emoji: require_core.emojis[region] || "🌍",
1596
407
  ...customMapping?.[region]
1597
408
  };
1598
409
  } catch {
1599
410
  return {
1600
411
  code: region,
1601
412
  name: region,
1602
- emoji: defaultEmoji,
413
+ emoji: require_core.defaultEmoji,
1603
414
  ...customMapping?.[region]
1604
415
  };
1605
416
  }
1606
417
  }
1607
418
  //#endregion
1608
- //#region src/locales/resolveAliasLocale.ts
1609
- /**
1610
- * Resolves the alias locale for a given locale.
1611
- * @param locale - The locale to resolve the alias locale for
1612
- * @param customMapping - The custom mapping to use for resolving the alias locale
1613
- * @returns The alias locale
1614
- */
1615
- function _resolveAliasLocale(locale, customMapping) {
1616
- let reverseCustomMapping;
1617
- if (customMapping) reverseCustomMapping = Object.fromEntries(Object.entries(customMapping).filter(([, value]) => value && typeof value === "object" && "code" in value).map(([key, value]) => [value.code, key]));
1618
- return reverseCustomMapping?.[locale] || locale;
1619
- }
1620
- //#endregion
1621
- //#region src/locales/resolveCanonicalLocale.ts
1622
- /**
1623
- * Resolves the canonical locale for a given locale.
1624
- * @param locale - The locale to resolve the canonical locale for
1625
- * @param customMapping - The custom mapping to use for resolving the canonical locale
1626
- * @returns The canonical locale
1627
- */
1628
- function _resolveCanonicalLocale(locale, customMapping) {
1629
- if (customMapping && shouldUseCanonicalLocale(locale, customMapping)) return customMapping[locale].code;
1630
- return locale;
1631
- }
1632
- //#endregion
1633
419
  //#region src/translate/uploadSourceFiles.ts
1634
420
  /**
1635
421
  * @internal
@@ -1644,7 +430,7 @@ async function _uploadSourceFiles(files, options, config) {
1644
430
  return (await apiRequest(config, "/v2/project/files/upload-files", {
1645
431
  body: {
1646
432
  data: batch.map(({ source }) => ({ source: {
1647
- content: require_internal.encode(source.content),
433
+ content: require_base64.encode(source.content),
1648
434
  fileName: source.fileName,
1649
435
  fileFormat: source.fileFormat,
1650
436
  locale: source.locale,
@@ -1673,13 +459,13 @@ async function _uploadSourceFiles(files, options, config) {
1673
459
  * @returns Promise resolving to a BatchList with all uploaded files
1674
460
  */
1675
461
  async function _uploadTranslations(files, options, config) {
1676
- require_internal.validateFileFormatTransforms(files.map(({ source }) => source));
462
+ require_base64.validateFileFormatTransforms(files.map(({ source }) => source));
1677
463
  return processBatches(files, async (batch) => {
1678
464
  return (await apiRequest(config, "/v2/project/files/upload-translations", {
1679
465
  body: {
1680
466
  data: batch.map(({ source, translations }) => ({
1681
467
  source: {
1682
- content: require_internal.encode(source.content),
468
+ content: require_base64.encode(source.content),
1683
469
  fileName: source.fileName,
1684
470
  fileFormat: source.fileFormat,
1685
471
  transformFormat: source.transformFormat,
@@ -1691,7 +477,7 @@ async function _uploadTranslations(files, options, config) {
1691
477
  branchId: source.branchId
1692
478
  },
1693
479
  translations: translations.map((t) => ({
1694
- content: require_internal.encode(t.content),
480
+ content: require_base64.encode(t.content),
1695
481
  fileName: t.fileName,
1696
482
  fileFormat: t.fileFormat,
1697
483
  locale: t.locale,
@@ -1741,7 +527,7 @@ async function _querySourceFile(query, options, config) {
1741
527
  */
1742
528
  async function _getProjectData(projectId, options, config) {
1743
529
  const { baseUrl } = config;
1744
- const timeout = options.timeout ? options.timeout : require_internal.defaultTimeout;
530
+ const timeout = options.timeout ? options.timeout : require_IntlCache.defaultTimeout;
1745
531
  const url = `${baseUrl || "https://api2.gtx.dev"}/v2/project/info/${encodeURIComponent(projectId)}`;
1746
532
  let response;
1747
533
  try {
@@ -1957,158 +743,6 @@ async function _publishFiles(files, config) {
1957
743
  return await apiRequest(config, "/v2/project/files/publish", { body: { files } });
1958
744
  }
1959
745
  //#endregion
1960
- //#region src/LocaleConfig.ts
1961
- /**
1962
- * LocaleConfig is a client-safe locale and formatting helper.
1963
- *
1964
- * It intentionally does not store project IDs, API keys, runtime URLs, or any
1965
- * translation credentials. It only stores locale metadata needed to resolve
1966
- * aliases, choose formatting fallbacks, and format values with Intl.
1967
- */
1968
- var LocaleConfig = class {
1969
- constructor({ defaultLocale = "en", locales = [], customMapping } = {}) {
1970
- this.defaultLocale = defaultLocale;
1971
- this.locales = locales;
1972
- this.customMapping = customMapping;
1973
- }
1974
- get translationLocales() {
1975
- return this.locales.length ? this.locales : void 0;
1976
- }
1977
- resolveCanonicalLocaleList(locales) {
1978
- return locales.map((locale) => this.resolveCanonicalLocale(locale));
1979
- }
1980
- resolveCanonicalLocaleArgs(locales) {
1981
- return locales.map((locale) => Array.isArray(locale) ? this.resolveCanonicalLocaleList(locale) : this.resolveCanonicalLocale(locale));
1982
- }
1983
- toLocaleList(locales) {
1984
- return Array.isArray(locales) ? locales : [locales];
1985
- }
1986
- getFormattingLocales(targetLocale, locales) {
1987
- return (locales !== void 0 ? this.toLocaleList(locales) : [
1988
- targetLocale,
1989
- this.defaultLocale,
1990
- "en"
1991
- ]).filter((locale) => !!locale).map((locale) => this.resolveCanonicalLocale(locale));
1992
- }
1993
- formatNum(value, targetLocale, options = {}) {
1994
- const { locales, ...intlOptions } = options;
1995
- return _formatNum({
1996
- value,
1997
- locales: this.getFormattingLocales(targetLocale, locales),
1998
- options: intlOptions
1999
- });
2000
- }
2001
- formatDateTime(value, targetLocale, options = {}) {
2002
- const { locales, ...intlOptions } = options;
2003
- return _formatDateTime({
2004
- value,
2005
- locales: this.getFormattingLocales(targetLocale, locales),
2006
- options: intlOptions
2007
- });
2008
- }
2009
- formatCurrency(value, currency, targetLocale, options = {}) {
2010
- const { locales, ...intlOptions } = options;
2011
- return _formatCurrency({
2012
- value,
2013
- currency,
2014
- locales: this.getFormattingLocales(targetLocale, locales),
2015
- options: intlOptions
2016
- });
2017
- }
2018
- formatRelativeTime(value, unit, targetLocale, options = {}) {
2019
- const { locales, ...intlOptions } = options;
2020
- return _formatRelativeTime({
2021
- value,
2022
- unit,
2023
- locales: this.getFormattingLocales(targetLocale, locales),
2024
- options: intlOptions
2025
- });
2026
- }
2027
- formatRelativeTimeFromDate(date, targetLocale, options = {}) {
2028
- const { locales, baseDate, ...intlOptions } = options;
2029
- return _formatRelativeTimeFromDate({
2030
- date,
2031
- baseDate: baseDate ?? /* @__PURE__ */ new Date(),
2032
- locales: this.getFormattingLocales(targetLocale, locales),
2033
- options: intlOptions
2034
- });
2035
- }
2036
- formatCutoff(value, targetLocale, options = {}) {
2037
- const { locales, ...formatOptions } = options;
2038
- return _formatCutoff({
2039
- value,
2040
- locales: this.getFormattingLocales(targetLocale, locales),
2041
- options: formatOptions
2042
- });
2043
- }
2044
- formatMessage(message, targetLocale, options = {}) {
2045
- const { locales, variables, dataFormat } = options;
2046
- if (dataFormat === "STRING") return _formatMessageString(message);
2047
- return _formatMessageICU(message, this.getFormattingLocales(targetLocale, locales), variables);
2048
- }
2049
- formatList(array, targetLocale, options = {}) {
2050
- const { locales, ...intlOptions } = options;
2051
- return _formatList({
2052
- value: array,
2053
- locales: this.getFormattingLocales(targetLocale, locales),
2054
- options: intlOptions
2055
- });
2056
- }
2057
- formatListToParts(array, targetLocale, options = {}) {
2058
- const { locales, ...intlOptions } = options;
2059
- return _formatListToParts({
2060
- value: array,
2061
- locales: this.getFormattingLocales(targetLocale, locales),
2062
- options: intlOptions
2063
- });
2064
- }
2065
- getLocaleName(locale) {
2066
- return _getLocaleName(locale, this.defaultLocale, this.customMapping);
2067
- }
2068
- getLocaleEmoji(locale) {
2069
- return _getLocaleEmoji(locale, this.customMapping);
2070
- }
2071
- getLocaleProperties(locale) {
2072
- return _getLocaleProperties(locale, this.defaultLocale, this.customMapping);
2073
- }
2074
- requiresTranslation(targetLocale, sourceLocale = this.defaultLocale, approvedLocales = this.translationLocales) {
2075
- return _requiresTranslation(this.resolveCanonicalLocale(sourceLocale), this.resolveCanonicalLocale(targetLocale), approvedLocales ? this.resolveCanonicalLocaleList(approvedLocales) : void 0, this.customMapping);
2076
- }
2077
- determineLocale(locales, approvedLocales = this.locales) {
2078
- const approvedLocalePairs = approvedLocales.map((locale) => ({
2079
- locale,
2080
- canonicalLocale: this.resolveCanonicalLocale(locale)
2081
- }));
2082
- const resolvedLocale = _determineLocale(Array.isArray(locales) ? this.resolveCanonicalLocaleList(locales) : this.resolveCanonicalLocale(locales), approvedLocalePairs.map(({ canonicalLocale }) => canonicalLocale), this.customMapping);
2083
- if (!resolvedLocale) return void 0;
2084
- return approvedLocalePairs.find(({ canonicalLocale }) => canonicalLocale === resolvedLocale)?.locale || this.resolveAliasLocale(resolvedLocale);
2085
- }
2086
- getLocaleDirection(locale) {
2087
- return _getLocaleDirection(this.resolveCanonicalLocale(locale));
2088
- }
2089
- isValidLocale(locale) {
2090
- return _isValidLocale(locale, this.customMapping);
2091
- }
2092
- resolveCanonicalLocale(locale) {
2093
- return _resolveCanonicalLocale(locale, this.customMapping);
2094
- }
2095
- resolveAliasLocale(locale) {
2096
- return _resolveAliasLocale(locale, this.customMapping);
2097
- }
2098
- standardizeLocale(locale) {
2099
- return _standardizeLocale(locale);
2100
- }
2101
- isSameDialect(...locales) {
2102
- return _isSameDialect(...this.resolveCanonicalLocaleArgs(locales));
2103
- }
2104
- isSameLanguage(...locales) {
2105
- return _isSameLanguage(...this.resolveCanonicalLocaleArgs(locales));
2106
- }
2107
- isSupersetLocale(superLocale, subLocale) {
2108
- return _isSupersetLocale(this.resolveCanonicalLocale(superLocale), this.resolveCanonicalLocale(subLocale));
2109
- }
2110
- };
2111
- //#endregion
2112
746
  //#region src/index.ts
2113
747
  /**
2114
748
  * GT is the core driver for the General Translation library.
@@ -2125,7 +759,7 @@ var LocaleConfig = class {
2125
759
  * });
2126
760
  */
2127
761
  var GT = class {
2128
- /** Client-safe locale and formatting helpers */
762
+ /** Runtime-safe locale and formatting helpers */
2129
763
  get localeConfig() {
2130
764
  return this._localeConfig;
2131
765
  }
@@ -2157,19 +791,19 @@ var GT = class {
2157
791
  if (devApiKey) this.devApiKey = devApiKey;
2158
792
  if (projectId) this.projectId = projectId;
2159
793
  if (sourceLocale) {
2160
- this.sourceLocale = _standardizeLocale(sourceLocale);
2161
- if (!_isValidLocale(this.sourceLocale, customMapping)) throw new Error(invalidLocaleError(this.sourceLocale));
794
+ this.sourceLocale = require_core._standardizeLocale(sourceLocale);
795
+ if (!require_core._isValidLocale(this.sourceLocale, customMapping)) throw new Error(invalidLocaleError(this.sourceLocale));
2162
796
  }
2163
797
  if (targetLocale) {
2164
- this.targetLocale = _standardizeLocale(targetLocale);
2165
- if (!_isValidLocale(this.targetLocale, customMapping)) throw new Error(invalidLocaleError(this.targetLocale));
798
+ this.targetLocale = require_core._standardizeLocale(targetLocale);
799
+ if (!require_core._isValidLocale(this.targetLocale, customMapping)) throw new Error(invalidLocaleError(this.targetLocale));
2166
800
  }
2167
801
  if (locales) {
2168
802
  const result = [];
2169
803
  const invalidLocales = [];
2170
804
  locales.forEach((locale) => {
2171
- const standardizedLocale = _standardizeLocale(locale);
2172
- if (_isValidLocale(standardizedLocale)) result.push(standardizedLocale);
805
+ const standardizedLocale = require_core._standardizeLocale(locale);
806
+ if (require_core._isValidLocale(standardizedLocale)) result.push(standardizedLocale);
2173
807
  else invalidLocales.push(locale);
2174
808
  });
2175
809
  if (invalidLocales.length > 0) throw new Error(invalidLocalesError(invalidLocales));
@@ -2180,7 +814,7 @@ var GT = class {
2180
814
  this.customMapping = customMapping;
2181
815
  this.reverseCustomMapping = Object.fromEntries(Object.entries(customMapping).filter(([, value]) => value && typeof value === "object" && "code" in value).map(([key, value]) => [value.code, key]));
2182
816
  }
2183
- this._localeConfig = new LocaleConfig({
817
+ this._localeConfig = new require_core.LocaleConfig({
2184
818
  defaultLocale: this.sourceLocale,
2185
819
  locales: this.locales ?? [],
2186
820
  customMapping: this.customMapping
@@ -2334,12 +968,12 @@ var GT = class {
2334
968
  };
2335
969
  if (!mergedOptions.sourceLocale) {
2336
970
  const error = noSourceLocaleProvidedError("enqueueFiles");
2337
- gtInstanceLogger.error(error);
971
+ require_core.gtInstanceLogger.error(error);
2338
972
  throw new Error(error);
2339
973
  }
2340
974
  if (!mergedOptions.targetLocales || mergedOptions.targetLocales.length === 0) {
2341
975
  const error = noTargetLocaleProvidedError("enqueueFiles");
2342
- gtInstanceLogger.error(error);
976
+ require_core.gtInstanceLogger.error(error);
2343
977
  throw new Error(error);
2344
978
  }
2345
979
  mergedOptions = {
@@ -2553,7 +1187,7 @@ var GT = class {
2553
1187
  let targetLocale = options?.targetLocale || this.targetLocale;
2554
1188
  if (!targetLocale) {
2555
1189
  const error = noTargetLocaleProvidedError("translate");
2556
- gtInstanceLogger.error(error);
1190
+ require_core.gtInstanceLogger.error(error);
2557
1191
  throw new Error(error);
2558
1192
  }
2559
1193
  targetLocale = this.resolveCanonicalLocale(targetLocale);
@@ -2570,7 +1204,7 @@ var GT = class {
2570
1204
  let targetLocale = options?.targetLocale || this.targetLocale;
2571
1205
  if (!targetLocale) {
2572
1206
  const error = noTargetLocaleProvidedError("translateMany");
2573
- gtInstanceLogger.error(error);
1207
+ require_core.gtInstanceLogger.error(error);
2574
1208
  throw new Error(error);
2575
1209
  }
2576
1210
  targetLocale = this.resolveCanonicalLocale(targetLocale);
@@ -2635,7 +1269,7 @@ var GT = class {
2635
1269
  };
2636
1270
  if (!mergedOptions.sourceLocale) {
2637
1271
  const error = noSourceLocaleProvidedError("uploadTranslations");
2638
- gtInstanceLogger.error(error);
1272
+ require_core.gtInstanceLogger.error(error);
2639
1273
  throw new Error(error);
2640
1274
  }
2641
1275
  const result = await _uploadTranslations(files.map((f) => ({
@@ -2954,7 +1588,7 @@ var GT = class {
2954
1588
  if (!sourceLocale) throw new Error(noSourceLocaleProvidedError("requiresTranslation"));
2955
1589
  if (!targetLocale) throw new Error(noTargetLocaleProvidedError("requiresTranslation"));
2956
1590
  if (customMapping === this.customMapping) return this.localeConfig.requiresTranslation(targetLocale, sourceLocale, approvedLocales);
2957
- return _requiresTranslation(sourceLocale, targetLocale, approvedLocales, customMapping);
1591
+ return require_core._requiresTranslation(sourceLocale, targetLocale, approvedLocales, customMapping);
2958
1592
  }
2959
1593
  /**
2960
1594
  * Determines the best matching locale from the provided approved locales list.
@@ -2969,7 +1603,7 @@ var GT = class {
2969
1603
  */
2970
1604
  determineLocale(locales, approvedLocales = this.locales || [], customMapping = this.customMapping) {
2971
1605
  if (customMapping === this.customMapping) return this.localeConfig.determineLocale(locales, approvedLocales ?? []);
2972
- return _determineLocale(locales, approvedLocales, customMapping);
1606
+ return require_core._determineLocale(locales, approvedLocales, customMapping);
2973
1607
  }
2974
1608
  /**
2975
1609
  * Gets the text direction for a given locale code.
@@ -3001,7 +1635,7 @@ var GT = class {
3001
1635
  isValidLocale(locale = this.targetLocale, customMapping = this.customMapping) {
3002
1636
  if (!locale) throw new Error(noTargetLocaleProvidedError("isValidLocale"));
3003
1637
  if (customMapping === this.customMapping) return this.localeConfig.isValidLocale(locale);
3004
- return _isValidLocale(locale, customMapping);
1638
+ return require_core._isValidLocale(locale, customMapping);
3005
1639
  }
3006
1640
  /**
3007
1641
  * Resolves the canonical locale for a given locale.
@@ -3012,7 +1646,7 @@ var GT = class {
3012
1646
  resolveCanonicalLocale(locale = this.targetLocale, customMapping = this.customMapping) {
3013
1647
  if (!locale) throw new Error(noTargetLocaleProvidedError("resolveCanonicalLocale"));
3014
1648
  if (customMapping === this.customMapping) return this.localeConfig.resolveCanonicalLocale(locale);
3015
- return _resolveCanonicalLocale(locale, customMapping);
1649
+ return require_core._resolveCanonicalLocale(locale, customMapping);
3016
1650
  }
3017
1651
  /**
3018
1652
  * Resolves the alias locale for a given locale.
@@ -3023,7 +1657,7 @@ var GT = class {
3023
1657
  resolveAliasLocale(locale, customMapping = this.customMapping) {
3024
1658
  if (!locale) throw new Error(noTargetLocaleProvidedError("resolveAliasLocale"));
3025
1659
  if (customMapping === this.customMapping) return this.localeConfig.resolveAliasLocale(locale);
3026
- return _resolveAliasLocale(locale, customMapping);
1660
+ return require_core._resolveAliasLocale(locale, customMapping);
3027
1661
  }
3028
1662
  /**
3029
1663
  * Standardizes a BCP 47 locale code to ensure correct formatting.
@@ -3088,72 +1722,6 @@ var GT = class {
3088
1722
  }
3089
1723
  };
3090
1724
  /**
3091
- * Formats a string with cutoff behavior, applying a terminator when the string exceeds the maximum character limit.
3092
- *
3093
- * This standalone function provides cutoff formatting functionality without requiring a GT instance.
3094
- * The locales parameter is required for proper terminator selection based on the target language.
3095
- *
3096
- * @param {string} value - The string value to format with cutoff behavior.
3097
- * @param {Object} [options] - Configuration options for cutoff formatting.
3098
- * @param {string | string[]} [options.locales] - The locales to use for terminator selection.
3099
- * @param {number} [options.maxChars] - The maximum number of characters to display.
3100
- * - Undefined values are treated as no cutoff.
3101
- * - Negative values follow .slice() behavior and terminator will be added before the value.
3102
- * - 0 will result in an empty string.
3103
- * - If cutoff results in an empty string, no terminator is added.
3104
- * @param {CutoffFormatStyle} [options.style='ellipsis'] - The style of the terminator.
3105
- * @param {string} [options.terminator] - Optional override the terminator to use.
3106
- * @param {string} [options.separator] - Optional override the separator to use between the terminator and the value.
3107
- * - If no terminator is provided, then separator is ignored.
3108
- * @returns {string} The formatted string with terminator applied if cutoff occurs.
3109
- *
3110
- * @example
3111
- * formatCutoff('Hello, world!', { locales: 'en-US', maxChars: 8 });
3112
- * // Returns: 'Hello, w...'
3113
- *
3114
- * @example
3115
- * formatCutoff('Hello, world!', { locales: 'en-US', maxChars: -3 });
3116
- * // Returns: '...ld!'
3117
- *
3118
- * @example
3119
- * formatCutoff('Very long text that needs cutting', {
3120
- * locales: 'en-US',
3121
- * maxChars: 15,
3122
- * style: 'ellipsis',
3123
- * separator: ' '
3124
- * });
3125
- * // Returns: 'Very long text ...'
3126
- */
3127
- function formatCutoff(value, options) {
3128
- return _formatCutoff({
3129
- value,
3130
- locales: options?.locales,
3131
- options
3132
- });
3133
- }
3134
- /**
3135
- * Formats a message according to the specified locales and options.
3136
- *
3137
- * @param {string} message - The message to format.
3138
- * @param {string | string[]} [locales='en'] - The locales to use for formatting.
3139
- * @param {FormatVariables} [variables={}] - The variables to use for formatting.
3140
- * @param {StringFormat} [dataFormat='ICU'] - The format of the message. (When STRING, the message is returned as is)
3141
- * @returns {string} The formatted message.
3142
- *
3143
- * @example
3144
- * formatMessage('Hello {name}', { name: 'John' });
3145
- * // Returns: "Hello John"
3146
- *
3147
- * formatMessage('Hello {name}', { name: 'John' }, { locales: ['fr'] });
3148
- * // Returns: "Bonjour John"
3149
- */
3150
- function formatMessage(message, options) {
3151
- switch (options?.dataFormat) {
3152
- case "STRING": return _formatMessageString(message);
3153
- default: return _formatMessageICU(message, options?.locales, options?.variables);
3154
- }
3155
- }
3156
- /**
3157
1725
  * Formats a number according to the specified locales and options.
3158
1726
  * @param {Object} params - The parameters for the number formatting.
3159
1727
  * @param {number} params.value - The number to format.
@@ -3162,7 +1730,7 @@ function formatMessage(message, options) {
3162
1730
  * @returns {string} The formatted number.
3163
1731
  */
3164
1732
  function formatNum(number, options) {
3165
- return _formatNum({
1733
+ return require_core._formatNum({
3166
1734
  value: number,
3167
1735
  locales: options.locales,
3168
1736
  options
@@ -3177,7 +1745,7 @@ function formatNum(number, options) {
3177
1745
  * @returns {string} The formatted date.
3178
1746
  */
3179
1747
  function formatDateTime(date, options) {
3180
- return _formatDateTime({
1748
+ return require_core._formatDateTime({
3181
1749
  value: date,
3182
1750
  locales: options?.locales,
3183
1751
  options
@@ -3193,7 +1761,7 @@ function formatDateTime(date, options) {
3193
1761
  * @returns {string} The formatted currency value.
3194
1762
  */
3195
1763
  function formatCurrency(value, currency, options) {
3196
- return _formatCurrency({
1764
+ return require_core._formatCurrency({
3197
1765
  value,
3198
1766
  currency,
3199
1767
  locales: options.locales,
@@ -3209,7 +1777,7 @@ function formatCurrency(value, currency, options) {
3209
1777
  * @returns {string} The formatted list.
3210
1778
  */
3211
1779
  function formatList(array, options) {
3212
- return _formatList({
1780
+ return require_core._formatList({
3213
1781
  value: array,
3214
1782
  locales: options.locales,
3215
1783
  options
@@ -3224,7 +1792,7 @@ function formatList(array, options) {
3224
1792
  * @returns {Array<T | string>} The formatted list parts
3225
1793
  */
3226
1794
  function formatListToParts(array, options) {
3227
- return _formatListToParts({
1795
+ return require_core._formatListToParts({
3228
1796
  value: array,
3229
1797
  locales: options?.locales,
3230
1798
  options
@@ -3240,7 +1808,7 @@ function formatListToParts(array, options) {
3240
1808
  * @returns {string} The formatted relative time string.
3241
1809
  */
3242
1810
  function formatRelativeTime(value, unit, options) {
3243
- return _formatRelativeTime({
1811
+ return require_core._formatRelativeTime({
3244
1812
  value,
3245
1813
  unit,
3246
1814
  locales: options.locales,
@@ -3257,7 +1825,7 @@ function formatRelativeTime(value, unit, options) {
3257
1825
  */
3258
1826
  function formatRelativeTimeFromDate(date, options) {
3259
1827
  const { locales, baseDate, ...intlOptions } = options;
3260
- return _formatRelativeTimeFromDate({
1828
+ return require_core._formatRelativeTimeFromDate({
3261
1829
  date,
3262
1830
  baseDate: baseDate ?? /* @__PURE__ */ new Date(),
3263
1831
  locales,
@@ -3273,7 +1841,7 @@ function formatRelativeTimeFromDate(date, options) {
3273
1841
  * @returns {string} The display name corresponding to the code.
3274
1842
  */
3275
1843
  function getLocaleName(locale, defaultLocale, customMapping) {
3276
- return _getLocaleName(locale, defaultLocale, customMapping);
1844
+ return require_core._getLocaleName(locale, defaultLocale, customMapping);
3277
1845
  }
3278
1846
  /**
3279
1847
  * Retrieves an emoji based on a given locale code, taking into account region, language, and specific exceptions.
@@ -3285,7 +1853,7 @@ function getLocaleName(locale, defaultLocale, customMapping) {
3285
1853
  * @returns The emoji representing the locale or its region, or a default emoji if no specific match is found.
3286
1854
  */
3287
1855
  function getLocaleEmoji(locale, customMapping) {
3288
- return _getLocaleEmoji(locale, customMapping);
1856
+ return require_core._getLocaleEmoji(locale, customMapping);
3289
1857
  }
3290
1858
  /**
3291
1859
  * Generates linguistic details for a given locale code.
@@ -3322,7 +1890,7 @@ function getLocaleEmoji(locale, customMapping) {
3322
1890
  * @property {string} emoji - The emoji associated with the locale's region, if applicable.
3323
1891
  */
3324
1892
  function getLocaleProperties(locale, defaultLocale, customMapping) {
3325
- return _getLocaleProperties(locale, defaultLocale, customMapping);
1893
+ return require_core._getLocaleProperties(locale, defaultLocale, customMapping);
3326
1894
  }
3327
1895
  /**
3328
1896
  * Retrieves multiple properties for a given region code, including:
@@ -3376,7 +1944,7 @@ function getRegionProperties(region, defaultLocale, customMapping) {
3376
1944
  * @returns {boolean} - Returns `true` if translation is required, otherwise `false`.
3377
1945
  */
3378
1946
  function requiresTranslation(sourceLocale, targetLocale, approvedLocales, customMapping) {
3379
- return _requiresTranslation(sourceLocale, targetLocale, approvedLocales, customMapping);
1947
+ return require_core._requiresTranslation(sourceLocale, targetLocale, approvedLocales, customMapping);
3380
1948
  }
3381
1949
  /**
3382
1950
  * Determines the best matching locale from the provided approved locales list.
@@ -3385,7 +1953,7 @@ function requiresTranslation(sourceLocale, targetLocale, approvedLocales, custom
3385
1953
  * @returns {string | undefined} - The best matching locale from the approvedLocales list, or undefined if no match is found.
3386
1954
  */
3387
1955
  function determineLocale(locales, approvedLocales = [], customMapping = void 0) {
3388
- return _determineLocale(locales, approvedLocales, customMapping);
1956
+ return require_core._determineLocale(locales, approvedLocales, customMapping);
3389
1957
  }
3390
1958
  /**
3391
1959
  * Get the text direction for a given locale code using the Intl.Locale API.
@@ -3394,16 +1962,7 @@ function determineLocale(locales, approvedLocales = [], customMapping = void 0)
3394
1962
  * @returns {string} - 'rtl' if the locale is right-to-left, otherwise 'ltr'.
3395
1963
  */
3396
1964
  function getLocaleDirection(locale) {
3397
- return _getLocaleDirection(locale);
3398
- }
3399
- /**
3400
- * Checks if a given BCP 47 locale code is valid.
3401
- * @param {string} locale - The BCP 47 locale code to validate.
3402
- * @param {CustomMapping} [customMapping] - The custom mapping to use for validation.
3403
- * @returns {boolean} True if the BCP 47 code is valid, false otherwise.
3404
- */
3405
- function isValidLocale(locale, customMapping) {
3406
- return _isValidLocale(locale, customMapping);
1965
+ return require_core._getLocaleDirection(locale);
3407
1966
  }
3408
1967
  /**
3409
1968
  * Resolves the alias locale for a given locale.
@@ -3412,24 +1971,7 @@ function isValidLocale(locale, customMapping) {
3412
1971
  * @returns {string} The alias locale
3413
1972
  */
3414
1973
  function resolveAliasLocale(locale, customMapping) {
3415
- return _resolveAliasLocale(locale, customMapping);
3416
- }
3417
- /**
3418
- * Resolves the canonical locale for a given locale.
3419
- * @param {string} locale - The locale to resolve the canonical locale for
3420
- * @param {CustomMapping} [customMapping] - The custom mapping to use for resolving the canonical locale
3421
- * @returns {string} The canonical locale
3422
- */
3423
- function resolveCanonicalLocale(locale, customMapping) {
3424
- return _resolveCanonicalLocale(locale, customMapping);
3425
- }
3426
- /**
3427
- * Standardizes a BCP 47 locale code to ensure correct formatting.
3428
- * @param {string} locale - The BCP 47 locale code to standardize.
3429
- * @returns {string} The standardized BCP 47 locale code or an empty string if it is an invalid code.
3430
- */
3431
- function standardizeLocale(locale) {
3432
- return _standardizeLocale(locale);
1974
+ return require_core._resolveAliasLocale(locale, customMapping);
3433
1975
  }
3434
1976
  /**
3435
1977
  * Checks if multiple BCP 47 locale codes represent the same dialect.
@@ -3437,7 +1979,7 @@ function standardizeLocale(locale) {
3437
1979
  * @returns {boolean} True if all BCP 47 codes represent the same dialect, false otherwise.
3438
1980
  */
3439
1981
  function isSameDialect(...locales) {
3440
- return _isSameDialect(...locales);
1982
+ return require_core._isSameDialect(...locales);
3441
1983
  }
3442
1984
  /**
3443
1985
  * Checks if multiple BCP 47 locale codes represent the same language.
@@ -3445,7 +1987,7 @@ function isSameDialect(...locales) {
3445
1987
  * @returns {boolean} True if all BCP 47 codes represent the same language, false otherwise.
3446
1988
  */
3447
1989
  function isSameLanguage(...locales) {
3448
- return _isSameLanguage(...locales);
1990
+ return require_core._isSameLanguage(...locales);
3449
1991
  }
3450
1992
  /**
3451
1993
  * Checks if a locale is a superset of another locale.
@@ -3456,21 +1998,20 @@ function isSameLanguage(...locales) {
3456
1998
  * @returns {boolean} True if the first locale is a superset of the second locale, false otherwise.
3457
1999
  */
3458
2000
  function isSupersetLocale(superLocale, subLocale) {
3459
- return _isSupersetLocale(superLocale, subLocale);
2001
+ return require_core._isSupersetLocale(superLocale, subLocale);
3460
2002
  }
3461
2003
  const API_VERSION = API_VERSION$1;
3462
2004
  //#endregion
3463
2005
  exports.API_VERSION = API_VERSION;
3464
2006
  exports.GT = GT;
3465
- exports.LocaleConfig = LocaleConfig;
3466
- exports.__toESM = __toESM;
2007
+ exports.LocaleConfig = require_core.LocaleConfig;
3467
2008
  exports.determineLocale = determineLocale;
3468
2009
  exports.formatCurrency = formatCurrency;
3469
- exports.formatCutoff = formatCutoff;
2010
+ exports.formatCutoff = require_core.formatCutoff;
3470
2011
  exports.formatDateTime = formatDateTime;
3471
2012
  exports.formatList = formatList;
3472
2013
  exports.formatListToParts = formatListToParts;
3473
- exports.formatMessage = formatMessage;
2014
+ exports.formatMessage = require_core.formatMessage;
3474
2015
  exports.formatNum = formatNum;
3475
2016
  exports.formatRelativeTime = formatRelativeTime;
3476
2017
  exports.formatRelativeTimeFromDate = formatRelativeTimeFromDate;
@@ -3482,10 +2023,10 @@ exports.getRegionProperties = getRegionProperties;
3482
2023
  exports.isSameDialect = isSameDialect;
3483
2024
  exports.isSameLanguage = isSameLanguage;
3484
2025
  exports.isSupersetLocale = isSupersetLocale;
3485
- exports.isValidLocale = isValidLocale;
2026
+ exports.isValidLocale = require_core.isValidLocale;
3486
2027
  exports.requiresTranslation = requiresTranslation;
3487
2028
  exports.resolveAliasLocale = resolveAliasLocale;
3488
- exports.resolveCanonicalLocale = resolveCanonicalLocale;
3489
- exports.standardizeLocale = standardizeLocale;
2029
+ exports.resolveCanonicalLocale = require_core.resolveCanonicalLocale;
2030
+ exports.standardizeLocale = require_core.standardizeLocale;
3490
2031
 
3491
2032
  //# sourceMappingURL=index.cjs.map