@eldrajs/sdk 0.2.7 → 0.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.
@@ -0,0 +1,902 @@
1
+ import { i as ResolveLocale, n as usesBundledData, r as LookupSupportedLocales, t as cached } from "../locale-DOZdbAbY.js";
2
+ //#region ../../node_modules/.pnpm/@formatjs+intl-listformat@8.3.15/node_modules/@formatjs/intl-listformat/index.js
3
+ const defaultContent = {
4
+ "aa": ["aa-ET"],
5
+ "ab": ["ab-GE"],
6
+ "af": ["af-ZA"],
7
+ "agq": ["agq-CM"],
8
+ "ak": ["ak-GH"],
9
+ "am": ["am-ET"],
10
+ "an": ["an-ES"],
11
+ "ann": ["ann-NG"],
12
+ "apc": ["apc-SY"],
13
+ "ar": ["ar-001"],
14
+ "arn": ["arn-CL"],
15
+ "as": ["as-IN"],
16
+ "asa": ["asa-TZ"],
17
+ "ast": ["ast-ES"],
18
+ "az-Arab": ["az-Arab-IR"],
19
+ "az-Cyrl": ["az-Cyrl-AZ"],
20
+ "az-Latn": ["az-Latn-AZ"],
21
+ "ba": ["ba-RU"],
22
+ "bal-Arab": ["bal-Arab-PK"],
23
+ "bal-Latn": ["bal-Latn-PK"],
24
+ "bas": ["bas-CM"],
25
+ "be": ["be-BY"],
26
+ "bem": ["bem-ZM"],
27
+ "bew": ["bew-ID"],
28
+ "bez": ["bez-TZ"],
29
+ "bg": ["bg-BG"],
30
+ "bgc": ["bgc-IN"],
31
+ "bgn": ["bgn-PK"],
32
+ "bho": ["bho-IN"],
33
+ "blo": ["blo-BJ"],
34
+ "blt": ["blt-VN"],
35
+ "bm": ["bm-ML"],
36
+ "bm-Nkoo": ["bm-Nkoo-ML"],
37
+ "bn": ["bn-BD"],
38
+ "bo": ["bo-CN"],
39
+ "bqi": ["bqi-IR"],
40
+ "br": ["br-FR"],
41
+ "brx": ["brx-IN"],
42
+ "bs-Cyrl": ["bs-Cyrl-BA"],
43
+ "bs-Latn": ["bs-Latn-BA"],
44
+ "bss": ["bss-CM"],
45
+ "bua": ["bua-RU"],
46
+ "byn": ["byn-ER"],
47
+ "ca": ["ca-ES"],
48
+ "cad": ["cad-US"],
49
+ "cch": ["cch-NG"],
50
+ "ccp": ["ccp-BD"],
51
+ "ce": ["ce-RU"],
52
+ "ceb": ["ceb-PH"],
53
+ "cgg": ["cgg-UG"],
54
+ "cho": ["cho-US"],
55
+ "chr": ["chr-US"],
56
+ "cic": ["cic-US"],
57
+ "ckb": ["ckb-IQ"],
58
+ "co": ["co-FR"],
59
+ "cop": ["cop-EG"],
60
+ "cs": ["cs-CZ"],
61
+ "csw": ["csw-CA"],
62
+ "cu": ["cu-RU"],
63
+ "cv": ["cv-RU"],
64
+ "cy": ["cy-GB"],
65
+ "da": ["da-DK"],
66
+ "dav": ["dav-KE"],
67
+ "de": ["de-DE"],
68
+ "dje": ["dje-NE"],
69
+ "doi": ["doi-IN"],
70
+ "dsb": ["dsb-DE"],
71
+ "dua": ["dua-CM"],
72
+ "dv": ["dv-MV"],
73
+ "dyo": ["dyo-SN"],
74
+ "dz": ["dz-BT"],
75
+ "ebu": ["ebu-KE"],
76
+ "ee": ["ee-GH"],
77
+ "el": ["el-GR"],
78
+ "en-Dsrt": ["en-Dsrt-US"],
79
+ "en-Shaw": ["en-Shaw-GB"],
80
+ "en": ["en-US"],
81
+ "eo": ["eo-001"],
82
+ "es": ["es-ES"],
83
+ "et": ["et-EE"],
84
+ "eu": ["eu-ES"],
85
+ "ewo": ["ewo-CM"],
86
+ "fa": ["fa-IR"],
87
+ "ff-Adlm": ["ff-Adlm-GN"],
88
+ "ff-Latn": ["ff-Latn-SN"],
89
+ "fi": ["fi-FI"],
90
+ "fil": ["fil-PH"],
91
+ "fo": ["fo-FO"],
92
+ "fr": ["fr-FR"],
93
+ "frr": ["frr-DE"],
94
+ "fur": ["fur-IT"],
95
+ "fy": ["fy-NL"],
96
+ "ga": ["ga-IE"],
97
+ "gaa": ["gaa-GH"],
98
+ "gd": ["gd-GB"],
99
+ "gez": ["gez-ET"],
100
+ "gl": ["gl-ES"],
101
+ "gn": ["gn-PY"],
102
+ "gsw": ["gsw-CH"],
103
+ "gu": ["gu-IN"],
104
+ "guz": ["guz-KE"],
105
+ "gv": ["gv-IM"],
106
+ "ha-Arab": ["ha-Arab-NG"],
107
+ "ha": ["ha-NG"],
108
+ "haw": ["haw-US"],
109
+ "he": ["he-IL"],
110
+ "hi": ["hi-IN"],
111
+ "hi-Latn": ["hi-Latn-IN"],
112
+ "hnj-Hmnp": ["hnj-Hmnp-US"],
113
+ "hr": ["hr-HR"],
114
+ "hsb": ["hsb-DE"],
115
+ "ht": ["ht-HT"],
116
+ "hu": ["hu-HU"],
117
+ "hy": ["hy-AM"],
118
+ "ia": ["ia-001"],
119
+ "id": ["id-ID"],
120
+ "ie": ["ie-EE"],
121
+ "ig": ["ig-NG"],
122
+ "ii": ["ii-CN"],
123
+ "io": ["io-001"],
124
+ "is": ["is-IS"],
125
+ "it": ["it-IT"],
126
+ "iu": ["iu-CA"],
127
+ "iu-Latn": ["iu-Latn-CA"],
128
+ "ja": ["ja-JP"],
129
+ "jbo": ["jbo-001"],
130
+ "jgo": ["jgo-CM"],
131
+ "jmc": ["jmc-TZ"],
132
+ "jv": ["jv-ID"],
133
+ "ka": ["ka-GE"],
134
+ "kaa-Cyrl": ["kaa-Cyrl-UZ"],
135
+ "kaa-Latn": ["kaa-Latn-UZ"],
136
+ "kab": ["kab-DZ"],
137
+ "kaj": ["kaj-NG"],
138
+ "kam": ["kam-KE"],
139
+ "kcg": ["kcg-NG"],
140
+ "kde": ["kde-TZ"],
141
+ "kea": ["kea-CV"],
142
+ "kek": ["kek-GT"],
143
+ "ken": ["ken-CM"],
144
+ "kgp": ["kgp-BR"],
145
+ "khq": ["khq-ML"],
146
+ "ki": ["ki-KE"],
147
+ "kk-Arab": ["kk-Arab-CN"],
148
+ "kk-Cyrl": ["kk-Cyrl-KZ"],
149
+ "kkj": ["kkj-CM"],
150
+ "kl": ["kl-GL"],
151
+ "kln": ["kln-KE"],
152
+ "km": ["km-KH"],
153
+ "kn": ["kn-IN"],
154
+ "ko": ["ko-KR"],
155
+ "kok-Deva": ["kok-Deva-IN"],
156
+ "kok-Latn": ["kok-Latn-IN"],
157
+ "kpe": ["kpe-LR"],
158
+ "ks-Arab": ["ks-Arab-IN"],
159
+ "ks-Deva": ["ks-Deva-IN"],
160
+ "ksb": ["ksb-TZ"],
161
+ "ksf": ["ksf-CM"],
162
+ "ksh": ["ksh-DE"],
163
+ "ku-Arab": ["ku-Arab-IQ"],
164
+ "ku-Latn": ["ku-Latn-TR"],
165
+ "kw": ["kw-GB"],
166
+ "kxv-Deva": ["kxv-Deva-IN"],
167
+ "kxv-Latn": ["kxv-Latn-IN"],
168
+ "kxv-Orya": ["kxv-Orya-IN"],
169
+ "kxv-Telu": ["kxv-Telu-IN"],
170
+ "ky": ["ky-KG"],
171
+ "la": ["la-VA"],
172
+ "lag": ["lag-TZ"],
173
+ "lb": ["lb-LU"],
174
+ "lg": ["lg-UG"],
175
+ "lij": ["lij-IT"],
176
+ "lkt": ["lkt-US"],
177
+ "lld": ["lld-IT"],
178
+ "lmo": ["lmo-IT"],
179
+ "ln": ["ln-CD"],
180
+ "lo": ["lo-LA"],
181
+ "lrc": ["lrc-IR"],
182
+ "lt": ["lt-LT"],
183
+ "ltg": ["ltg-LV"],
184
+ "lu": ["lu-CD"],
185
+ "luo": ["luo-KE"],
186
+ "luy": ["luy-KE"],
187
+ "lv": ["lv-LV"],
188
+ "lzz": ["lzz-TR"],
189
+ "mai": ["mai-IN"],
190
+ "mas": ["mas-KE"],
191
+ "mdf": ["mdf-RU"],
192
+ "mer": ["mer-KE"],
193
+ "mfe": ["mfe-MU"],
194
+ "mg": ["mg-MG"],
195
+ "mgh": ["mgh-MZ"],
196
+ "mgo": ["mgo-CM"],
197
+ "mhn": ["mhn-IT"],
198
+ "mi": ["mi-NZ"],
199
+ "mic": ["mic-CA"],
200
+ "mk": ["mk-MK"],
201
+ "ml": ["ml-IN"],
202
+ "mn": ["mn-MN"],
203
+ "mn-Mong": ["mn-Mong-CN"],
204
+ "mni-Beng": ["mni-Beng-IN"],
205
+ "mni-Mtei": ["mni-Mtei-IN"],
206
+ "moh": ["moh-CA"],
207
+ "mr": ["mr-IN"],
208
+ "ms-Arab": ["ms-Arab-MY"],
209
+ "ms": ["ms-MY"],
210
+ "mt": ["mt-MT"],
211
+ "mua": ["mua-CM"],
212
+ "mus": ["mus-US"],
213
+ "mww-Hmnp": ["mww-Hmnp-US"],
214
+ "my": ["my-MM"],
215
+ "myv": ["myv-RU"],
216
+ "mzn": ["mzn-IR"],
217
+ "naq": ["naq-NA"],
218
+ "nb": ["nb-NO"],
219
+ "nd": ["nd-ZW"],
220
+ "nds": ["nds-DE"],
221
+ "ne": ["ne-NP"],
222
+ "nl": ["nl-NL"],
223
+ "nmg": ["nmg-CM"],
224
+ "nn": ["nn-NO"],
225
+ "nnh": ["nnh-CM"],
226
+ "nqo": ["nqo-GN"],
227
+ "nr": ["nr-ZA"],
228
+ "nso": ["nso-ZA"],
229
+ "nus": ["nus-SS"],
230
+ "nv": ["nv-US"],
231
+ "ny": ["ny-MW"],
232
+ "nyn": ["nyn-UG"],
233
+ "oc": ["oc-FR"],
234
+ "oka": ["oka-CA"],
235
+ "om": ["om-ET"],
236
+ "or": ["or-IN"],
237
+ "os": ["os-GE"],
238
+ "osa": ["osa-US"],
239
+ "pa-Arab": ["pa-Arab-PK"],
240
+ "pa-Guru": ["pa-Guru-IN"],
241
+ "pap": ["pap-CW"],
242
+ "pcm": ["pcm-NG"],
243
+ "pi-Latn": ["pi-Latn-GB"],
244
+ "pis": ["pis-SB"],
245
+ "pl": ["pl-PL"],
246
+ "pms": ["pms-IT"],
247
+ "prg": ["prg-PL"],
248
+ "ps": ["ps-AF"],
249
+ "pt": ["pt-BR"],
250
+ "qu": ["qu-PE"],
251
+ "quc": ["quc-GT"],
252
+ "raj": ["raj-IN"],
253
+ "rhg-Rohg": ["rhg-Rohg-MM"],
254
+ "rif": ["rif-MA"],
255
+ "rm": ["rm-CH"],
256
+ "rn": ["rn-BI"],
257
+ "ro": ["ro-RO"],
258
+ "rof": ["rof-TZ"],
259
+ "ru": ["ru-RU"],
260
+ "rw": ["rw-RW"],
261
+ "rwk": ["rwk-TZ"],
262
+ "sa": ["sa-IN"],
263
+ "sah": ["sah-RU"],
264
+ "saq": ["saq-KE"],
265
+ "sat-Deva": ["sat-Deva-IN"],
266
+ "sat-Olck": ["sat-Olck-IN"],
267
+ "sbp": ["sbp-TZ"],
268
+ "sc": ["sc-IT"],
269
+ "scn": ["scn-IT"],
270
+ "sd-Arab": ["sd-Arab-PK"],
271
+ "sd-Deva": ["sd-Deva-IN"],
272
+ "sdh": ["sdh-IR"],
273
+ "se": ["se-NO"],
274
+ "seh": ["seh-MZ"],
275
+ "ses": ["ses-ML"],
276
+ "sg": ["sg-CF"],
277
+ "sgs": ["sgs-LT"],
278
+ "shi-Latn": ["shi-Latn-MA"],
279
+ "shi-Tfng": ["shi-Tfng-MA"],
280
+ "shn": ["shn-MM"],
281
+ "si": ["si-LK"],
282
+ "sid": ["sid-ET"],
283
+ "sk": ["sk-SK"],
284
+ "skr": ["skr-PK"],
285
+ "sl": ["sl-SI"],
286
+ "sma": ["sma-SE"],
287
+ "smj": ["smj-SE"],
288
+ "smn": ["smn-FI"],
289
+ "sms": ["sms-FI"],
290
+ "sn": ["sn-ZW"],
291
+ "so": ["so-SO"],
292
+ "sq": ["sq-AL"],
293
+ "sr-Cyrl": ["sr-Cyrl-RS"],
294
+ "sr-Latn": ["sr-Latn-RS"],
295
+ "ss": ["ss-ZA"],
296
+ "ssy": ["ssy-ER"],
297
+ "st": ["st-ZA"],
298
+ "su-Latn": ["su-Latn-ID"],
299
+ "suz-Deva": ["suz-Deva-NP"],
300
+ "suz-Sunu": ["suz-Sunu-NP"],
301
+ "sv": ["sv-SE"],
302
+ "sw": ["sw-TZ"],
303
+ "syr": ["syr-IQ"],
304
+ "szl": ["szl-PL"],
305
+ "ta": ["ta-IN"],
306
+ "te": ["te-IN"],
307
+ "teo": ["teo-UG"],
308
+ "tg": ["tg-TJ"],
309
+ "th": ["th-TH"],
310
+ "ti": ["ti-ET"],
311
+ "tig": ["tig-ER"],
312
+ "tk": ["tk-TM"],
313
+ "tn": ["tn-ZA"],
314
+ "to": ["to-TO"],
315
+ "tok": ["tok-001"],
316
+ "tpi": ["tpi-PG"],
317
+ "tr": ["tr-TR"],
318
+ "trv": ["trv-TW"],
319
+ "trw": ["trw-PK"],
320
+ "ts": ["ts-ZA"],
321
+ "tt": ["tt-RU"],
322
+ "twq": ["twq-NE"],
323
+ "tyv": ["tyv-RU"],
324
+ "tzm": ["tzm-MA"],
325
+ "ug": ["ug-CN"],
326
+ "uk": ["uk-UA"],
327
+ "ur": ["ur-PK"],
328
+ "uz-Arab": ["uz-Arab-AF"],
329
+ "uz-Cyrl": ["uz-Cyrl-UZ"],
330
+ "uz-Latn": ["uz-Latn-UZ"],
331
+ "vai-Latn": ["vai-Latn-LR"],
332
+ "vai-Vaii": ["vai-Vaii-LR"],
333
+ "ve": ["ve-ZA"],
334
+ "vec": ["vec-IT"],
335
+ "vi": ["vi-VN"],
336
+ "vmw": ["vmw-MZ"],
337
+ "vo": ["vo-001"],
338
+ "vun": ["vun-TZ"],
339
+ "wa": ["wa-BE"],
340
+ "wae": ["wae-CH"],
341
+ "wal": ["wal-ET"],
342
+ "wbp": ["wbp-AU"],
343
+ "wo": ["wo-SN"],
344
+ "xh": ["xh-ZA"],
345
+ "xnr": ["xnr-IN"],
346
+ "xog": ["xog-UG"],
347
+ "yav": ["yav-CM"],
348
+ "yi": ["yi-UA"],
349
+ "yo": ["yo-NG"],
350
+ "yrl": ["yrl-BR"],
351
+ "yue-Hans": ["yue-Hans-CN"],
352
+ "yue-Hant": ["yue-Hant-HK"],
353
+ "za": ["za-CN"],
354
+ "zgh": ["zgh-MA"],
355
+ "zh-Hans": ["zh-Hans-CN"],
356
+ "zh-Hant": ["zh-Hant-TW"],
357
+ "zh-Latn": ["zh-Latn-CN"],
358
+ "zu": ["zu-ZA"]
359
+ };
360
+ const explicitLocales = /* @__PURE__ */ new WeakMap();
361
+ function registerLocaleData(locale, data, localeData, availableLocales) {
362
+ let loaded = explicitLocales.get(localeData);
363
+ if (!loaded) {
364
+ loaded = /* @__PURE__ */ new Set();
365
+ explicitLocales.set(localeData, loaded);
366
+ }
367
+ loaded.add(locale);
368
+ const locales = [locale, ...defaultContent[locale] || []];
369
+ for (const tag of locales) {
370
+ if (tag === locale || !loaded.has(tag) || localeData[tag] === void 0) localeData[tag] = data;
371
+ availableLocales.add(tag);
372
+ }
373
+ for (const tag of locales) {
374
+ const parts = tag.split("-");
375
+ const fallbacks = [];
376
+ while (parts.length > 1) {
377
+ if (parts.length > 2 && parts[1].length === 4) fallbacks.push([parts[0], ...parts.slice(2)].join("-"));
378
+ parts.pop();
379
+ fallbacks.push(parts.join("-"));
380
+ }
381
+ for (const fallback of fallbacks) {
382
+ if (localeData[fallback] === void 0) localeData[fallback] = localeData[tag];
383
+ availableLocales.add(fallback);
384
+ }
385
+ }
386
+ }
387
+ /**
388
+ * http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist
389
+ * @param locales
390
+ */
391
+ function CanonicalizeLocaleList(locales) {
392
+ return Intl.getCanonicalLocales(locales);
393
+ }
394
+ /**
395
+ * https://tc39.es/ecma262/#sec-tostring
396
+ */
397
+ function ToString(o) {
398
+ if (typeof o === "symbol") throw TypeError("Cannot convert a Symbol value to a string");
399
+ return String(o);
400
+ }
401
+ /**
402
+ * https://tc39.es/ecma402/#sec-getoption
403
+ * @param opts
404
+ * @param prop
405
+ * @param type
406
+ * @param values
407
+ * @param fallback
408
+ */
409
+ function GetOption(opts, prop, type, values, fallback) {
410
+ if (opts === null || typeof opts !== "object" && typeof opts !== "function") throw new TypeError("Options must be an object");
411
+ let value = opts[prop];
412
+ if (value !== void 0) {
413
+ if (type !== "boolean" && type !== "string") throw new TypeError("invalid type");
414
+ if (type === "boolean") value = Boolean(value);
415
+ if (type === "string") value = ToString(value);
416
+ if (values !== void 0 && !values.filter((val) => val == value).length) throw new RangeError(`${value} is not within ${values.join(", ")}`);
417
+ return value;
418
+ }
419
+ return fallback;
420
+ }
421
+ /**
422
+ * ECMA-262 §7.3.36 GetOptionsObject, steps 2–3.
423
+ * https://tc39.es/ecma262/#sec-getoptionsobject
424
+ * https://github.com/tc39/ecma262/blob/dcf59856a8184792a9e42f0ffb7dc064094a5dcc/spec.html#L7008-L7010
425
+ * @param options
426
+ * @returns
427
+ */
428
+ function GetOptionsObject(options) {
429
+ if (typeof options === "undefined") return Object.create(null);
430
+ if (options !== null && (typeof options === "object" || typeof options === "function")) return options;
431
+ throw new TypeError("Options must be an object");
432
+ }
433
+ function memoize(fn, options) {
434
+ const cache = options && options.cache ? options.cache : cacheDefault;
435
+ const serializer = options && options.serializer ? options.serializer : serializerDefault;
436
+ return (options && options.strategy ? options.strategy : strategyDefault)(fn, {
437
+ cache,
438
+ serializer
439
+ });
440
+ }
441
+ function isPrimitive(value) {
442
+ return value == null || typeof value === "number" || typeof value === "boolean";
443
+ }
444
+ function monadic(fn, cache, serializer, arg) {
445
+ const cacheKey = isPrimitive(arg) ? arg : serializer(arg);
446
+ let computedValue = cache.get(cacheKey);
447
+ if (typeof computedValue === "undefined") {
448
+ computedValue = fn.call(this, arg);
449
+ cache.set(cacheKey, computedValue);
450
+ }
451
+ return computedValue;
452
+ }
453
+ function variadic(fn, cache, serializer) {
454
+ const args = Array.prototype.slice.call(arguments, 3);
455
+ const cacheKey = serializer(args);
456
+ let computedValue = cache.get(cacheKey);
457
+ if (typeof computedValue === "undefined") {
458
+ computedValue = fn.apply(this, args);
459
+ cache.set(cacheKey, computedValue);
460
+ }
461
+ return computedValue;
462
+ }
463
+ function assemble(fn, context, strategy, cache, serialize) {
464
+ return strategy.bind(context, fn, cache, serialize);
465
+ }
466
+ function strategyDefault(fn, options) {
467
+ const strategy = fn.length === 1 ? monadic : variadic;
468
+ return assemble(fn, this, strategy, options.cache.create(), options.serializer);
469
+ }
470
+ function strategyVariadic(fn, options) {
471
+ return assemble(fn, this, variadic, options.cache.create(), options.serializer);
472
+ }
473
+ function strategyMonadic(fn, options) {
474
+ return assemble(fn, this, monadic, options.cache.create(), options.serializer);
475
+ }
476
+ const serializerDefault = function() {
477
+ return JSON.stringify(arguments);
478
+ };
479
+ var ObjectWithoutPrototypeCache = class {
480
+ constructor() {
481
+ this.cache = Object.create(null);
482
+ }
483
+ get(key) {
484
+ return this.cache[key];
485
+ }
486
+ set(key, value) {
487
+ this.cache[key] = value;
488
+ }
489
+ };
490
+ const cacheDefault = { create: function create() {
491
+ return new ObjectWithoutPrototypeCache();
492
+ } };
493
+ const strategies = {
494
+ variadic: strategyVariadic,
495
+ monadic: strategyMonadic
496
+ };
497
+ function setInternalSlot(map, pl, field, value) {
498
+ if (!map.get(pl)) map.set(pl, Object.create(null));
499
+ const slots = map.get(pl);
500
+ slots[field] = value;
501
+ }
502
+ function getInternalSlot(map, pl, field) {
503
+ return getMultiInternalSlots(map, pl, field)[field];
504
+ }
505
+ function getMultiInternalSlots(map, pl, ...fields) {
506
+ const slots = map.get(pl);
507
+ if (!slots) throw new TypeError(`${pl} InternalSlot has not been initialized`);
508
+ return fields.reduce((all, f) => {
509
+ all[f] = slots[f];
510
+ return all;
511
+ }, Object.create(null));
512
+ }
513
+ function isLiteralPart(patternPart) {
514
+ return patternPart.type === "literal";
515
+ }
516
+ function invariant(condition, message, Err = Error) {
517
+ if (!condition) throw new Err(message);
518
+ }
519
+ memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
520
+ memoize((...args) => new Intl.PluralRules(...args), { strategy: strategies.variadic });
521
+ memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic });
522
+ /**
523
+ * Partition a pattern into a list of literals and placeholders
524
+ * https://tc39.es/ecma402/#sec-partitionpattern
525
+ * @param pattern
526
+ */
527
+ function PartitionPattern(pattern) {
528
+ const result = [];
529
+ let beginIndex = pattern.indexOf("{");
530
+ let endIndex = 0;
531
+ let nextIndex = 0;
532
+ const length = pattern.length;
533
+ while (beginIndex < pattern.length && beginIndex > -1) {
534
+ endIndex = pattern.indexOf("}", beginIndex);
535
+ invariant(endIndex > beginIndex, `Invalid pattern ${pattern}`);
536
+ if (beginIndex > nextIndex) result.push({
537
+ type: "literal",
538
+ value: pattern.substring(nextIndex, beginIndex)
539
+ });
540
+ result.push({
541
+ type: pattern.substring(beginIndex + 1, endIndex),
542
+ value: void 0
543
+ });
544
+ nextIndex = endIndex + 1;
545
+ beginIndex = pattern.indexOf("{", nextIndex);
546
+ }
547
+ if (nextIndex < length) result.push({
548
+ type: "literal",
549
+ value: pattern.substring(nextIndex, length)
550
+ });
551
+ return result;
552
+ }
553
+ /**
554
+ * https://tc39.es/ecma262/#sec-toobject
555
+ */
556
+ function ToObject(arg) {
557
+ if (arg == null) throw new TypeError("undefined/null cannot be converted to object");
558
+ return Object(arg);
559
+ }
560
+ /**
561
+ * https://tc39.es/ecma402/#sec-supportedlocales
562
+ * @param availableLocales
563
+ * @param requestedLocales
564
+ * @param options
565
+ */
566
+ function SupportedLocales(availableLocales, requestedLocales, options) {
567
+ let matcher = "best fit";
568
+ if (options !== void 0) {
569
+ options = ToObject(options);
570
+ matcher = GetOption(options, "localeMatcher", "string", ["lookup", "best fit"], "best fit");
571
+ }
572
+ if (matcher === "best fit") return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
573
+ return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
574
+ }
575
+ function validateInstance(instance, method) {
576
+ if (!(instance instanceof ListFormat)) throw new TypeError(`Method Intl.ListFormat.prototype.${method} called on incompatible receiver ${String(instance)}`);
577
+ }
578
+ /**
579
+ * https://tc39.es/proposal-intl-list-format/#sec-createstringlistfromiterable
580
+ * @param iterable list
581
+ */
582
+ function stringListFromIterable(iterable) {
583
+ if (iterable === void 0) return [];
584
+ const elements = [];
585
+ for (const value of iterable) {
586
+ if (typeof value !== "string") throw new TypeError("Iterable yielded a non-string value");
587
+ elements.push(value);
588
+ }
589
+ return elements;
590
+ }
591
+ function createPartsFromList(internalSlotMap, lf, list) {
592
+ const size = list.length;
593
+ if (size === 0) return [];
594
+ if (size === 2) return deconstructPattern(getInternalSlot(internalSlotMap, lf, "templatePair"), {
595
+ "0": {
596
+ type: "element",
597
+ value: list[0]
598
+ },
599
+ "1": {
600
+ type: "element",
601
+ value: list[1]
602
+ }
603
+ });
604
+ let parts = {
605
+ type: "element",
606
+ value: list[size - 1]
607
+ };
608
+ let i = size - 2;
609
+ while (i >= 0) {
610
+ let pattern;
611
+ if (i === 0) pattern = getInternalSlot(internalSlotMap, lf, "templateStart");
612
+ else if (i < size - 2) pattern = getInternalSlot(internalSlotMap, lf, "templateMiddle");
613
+ else pattern = getInternalSlot(internalSlotMap, lf, "templateEnd");
614
+ const head = {
615
+ type: "element",
616
+ value: list[i]
617
+ };
618
+ parts = deconstructPattern(pattern, {
619
+ "0": head,
620
+ "1": parts
621
+ });
622
+ i--;
623
+ }
624
+ return parts;
625
+ }
626
+ function deconstructPattern(pattern, placeables) {
627
+ const patternParts = PartitionPattern(pattern);
628
+ const result = [];
629
+ for (const patternPart of patternParts) {
630
+ const { type: part } = patternPart;
631
+ if (isLiteralPart(patternPart)) result.push({
632
+ type: "literal",
633
+ value: patternPart.value
634
+ });
635
+ else {
636
+ invariant(part in placeables, `${part} is missing from placables`);
637
+ const subst = placeables[part];
638
+ if (Array.isArray(subst)) result.push(...subst);
639
+ else result.push(subst);
640
+ }
641
+ }
642
+ return result;
643
+ }
644
+ var ListFormat = class ListFormat {
645
+ constructor(locales, options) {
646
+ if (!(this && this instanceof ListFormat ? this.constructor : void 0)) throw new TypeError("Intl.ListFormat must be called with 'new'");
647
+ setInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, "initializedListFormat", true);
648
+ const requestedLocales = CanonicalizeLocaleList(locales);
649
+ const opt = Object.create(null);
650
+ const opts = GetOptionsObject(options);
651
+ opt.localeMatcher = GetOption(opts, "localeMatcher", "string", ["best fit", "lookup"], "best fit");
652
+ const { localeData } = ListFormat;
653
+ const r = ResolveLocale(ListFormat.availableLocales, requestedLocales, opt, ListFormat.relevantExtensionKeys, localeData, ListFormat.getDefaultLocale);
654
+ setInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, "locale", r.locale);
655
+ const type = GetOption(opts, "type", "string", [
656
+ "conjunction",
657
+ "disjunction",
658
+ "unit"
659
+ ], "conjunction");
660
+ setInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, "type", type);
661
+ const style = GetOption(opts, "style", "string", [
662
+ "long",
663
+ "short",
664
+ "narrow"
665
+ ], "long");
666
+ setInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, "style", style);
667
+ const { dataLocale } = r;
668
+ const dataLocaleData = localeData[dataLocale];
669
+ invariant(!!dataLocaleData, `Missing locale data for ${dataLocale}`);
670
+ const templates = dataLocaleData[type][style];
671
+ setInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, "templatePair", templates.pair);
672
+ setInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, "templateStart", templates.start);
673
+ setInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, "templateMiddle", templates.middle);
674
+ setInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, "templateEnd", templates.end);
675
+ }
676
+ format(elements) {
677
+ validateInstance(this, "format");
678
+ let result = "";
679
+ const parts = createPartsFromList(ListFormat.__INTERNAL_SLOT_MAP__, this, stringListFromIterable(elements));
680
+ if (!Array.isArray(parts)) return parts.value;
681
+ for (const p of parts) result += p.value;
682
+ return result;
683
+ }
684
+ formatToParts(elements) {
685
+ validateInstance(this, "format");
686
+ const parts = createPartsFromList(ListFormat.__INTERNAL_SLOT_MAP__, this, stringListFromIterable(elements));
687
+ if (!Array.isArray(parts)) return [parts];
688
+ const result = [];
689
+ for (const part of parts) result.push({ ...part });
690
+ return result;
691
+ }
692
+ resolvedOptions() {
693
+ validateInstance(this, "resolvedOptions");
694
+ return {
695
+ locale: getInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, "locale"),
696
+ type: getInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, "type"),
697
+ style: getInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, "style")
698
+ };
699
+ }
700
+ static supportedLocalesOf(locales, options) {
701
+ return SupportedLocales(ListFormat.availableLocales, CanonicalizeLocaleList(locales), options);
702
+ }
703
+ static __addLocaleData(...data) {
704
+ for (const { data: d, locale } of data) {
705
+ registerLocaleData(locale, d, ListFormat.localeData, ListFormat.availableLocales);
706
+ if (!ListFormat.__defaultLocale) ListFormat.__defaultLocale = locale;
707
+ }
708
+ }
709
+ static {
710
+ this.localeData = {};
711
+ }
712
+ static {
713
+ this.availableLocales = /* @__PURE__ */ new Set();
714
+ }
715
+ static {
716
+ this.__defaultLocale = "";
717
+ }
718
+ static getDefaultLocale() {
719
+ return ListFormat.__defaultLocale;
720
+ }
721
+ static {
722
+ this.relevantExtensionKeys = [];
723
+ }
724
+ static {
725
+ this.polyfilled = true;
726
+ }
727
+ static {
728
+ this.__INTERNAL_SLOT_MAP__ = /* @__PURE__ */ new WeakMap();
729
+ }
730
+ };
731
+ try {
732
+ if (typeof Symbol !== "undefined") Object.defineProperty(ListFormat.prototype, Symbol.toStringTag, {
733
+ value: "Intl.ListFormat",
734
+ writable: false,
735
+ enumerable: false,
736
+ configurable: true
737
+ });
738
+ Object.defineProperty(ListFormat.prototype.constructor, "length", {
739
+ value: 0,
740
+ writable: false,
741
+ enumerable: false,
742
+ configurable: true
743
+ });
744
+ Object.defineProperty(ListFormat.supportedLocalesOf, "length", {
745
+ value: 1,
746
+ writable: false,
747
+ enumerable: false,
748
+ configurable: true
749
+ });
750
+ } catch {}
751
+ //#endregion
752
+ //#region src/format/data/list-en.json
753
+ var list_en_default = {
754
+ data: {
755
+ "conjunction": {
756
+ "long": {
757
+ "end": "{0}, and {1}",
758
+ "middle": "{0}, {1}",
759
+ "pair": "{0} and {1}",
760
+ "start": "{0}, {1}"
761
+ },
762
+ "narrow": {
763
+ "end": "{0}, {1}",
764
+ "middle": "{0}, {1}",
765
+ "pair": "{0}, {1}",
766
+ "start": "{0}, {1}"
767
+ },
768
+ "short": {
769
+ "end": "{0}, & {1}",
770
+ "middle": "{0}, {1}",
771
+ "pair": "{0} & {1}",
772
+ "start": "{0}, {1}"
773
+ }
774
+ },
775
+ "disjunction": {
776
+ "long": {
777
+ "end": "{0}, or {1}",
778
+ "middle": "{0}, {1}",
779
+ "pair": "{0} or {1}",
780
+ "start": "{0}, {1}"
781
+ },
782
+ "narrow": {
783
+ "end": "{0}, or {1}",
784
+ "middle": "{0}, {1}",
785
+ "pair": "{0} or {1}",
786
+ "start": "{0}, {1}"
787
+ },
788
+ "short": {
789
+ "end": "{0}, or {1}",
790
+ "middle": "{0}, {1}",
791
+ "pair": "{0} or {1}",
792
+ "start": "{0}, {1}"
793
+ }
794
+ },
795
+ "unit": {
796
+ "long": {
797
+ "end": "{0}, {1}",
798
+ "middle": "{0}, {1}",
799
+ "pair": "{0}, {1}",
800
+ "start": "{0}, {1}"
801
+ },
802
+ "narrow": {
803
+ "end": "{0} {1}",
804
+ "middle": "{0} {1}",
805
+ "pair": "{0} {1}",
806
+ "start": "{0} {1}"
807
+ },
808
+ "short": {
809
+ "end": "{0}, {1}",
810
+ "middle": "{0}, {1}",
811
+ "pair": "{0}, {1}",
812
+ "start": "{0}, {1}"
813
+ }
814
+ }
815
+ },
816
+ locale: "en"
817
+ };
818
+ //#endregion
819
+ //#region src/format/data/list-is.json
820
+ var list_is_default = {
821
+ data: {
822
+ "conjunction": {
823
+ "long": {
824
+ "end": "{0} og {1}",
825
+ "middle": "{0}, {1}",
826
+ "pair": "{0} og {1}",
827
+ "start": "{0}, {1}"
828
+ },
829
+ "narrow": {
830
+ "end": "{0}, {1}",
831
+ "middle": "{0}, {1}",
832
+ "pair": "{0}, {1}",
833
+ "start": "{0}, {1}"
834
+ },
835
+ "short": {
836
+ "end": "{0} og {1}",
837
+ "middle": "{0}, {1}",
838
+ "pair": "{0} og {1}",
839
+ "start": "{0}, {1}"
840
+ }
841
+ },
842
+ "disjunction": {
843
+ "long": {
844
+ "end": "{0} eða {1}",
845
+ "middle": "{0}, {1}",
846
+ "pair": "{0} eða {1}",
847
+ "start": "{0}, {1}"
848
+ },
849
+ "narrow": {
850
+ "end": "{0} eða {1}",
851
+ "middle": "{0}, {1}",
852
+ "pair": "{0} eða {1}",
853
+ "start": "{0}, {1}"
854
+ },
855
+ "short": {
856
+ "end": "{0} eða {1}",
857
+ "middle": "{0}, {1}",
858
+ "pair": "{0} eða {1}",
859
+ "start": "{0}, {1}"
860
+ }
861
+ },
862
+ "unit": {
863
+ "long": {
864
+ "end": "{0} og {1}",
865
+ "middle": "{0}, {1}",
866
+ "pair": "{0} og {1}",
867
+ "start": "{0}, {1}"
868
+ },
869
+ "narrow": {
870
+ "end": "{0} og {1}",
871
+ "middle": "{0} {1}",
872
+ "pair": "{0} og {1}",
873
+ "start": "{0} {1}"
874
+ },
875
+ "short": {
876
+ "end": "{0} og {1}",
877
+ "middle": "{0}, {1}",
878
+ "pair": "{0} og {1}",
879
+ "start": "{0}, {1}"
880
+ }
881
+ }
882
+ },
883
+ locale: "is"
884
+ };
885
+ //#endregion
886
+ //#region src/format/list.ts
887
+ let loaded = false;
888
+ const formats = /* @__PURE__ */ new Map();
889
+ /** `new Intl.ListFormat(locale, options)` with the same text everywhere: `a, b og c`. */
890
+ function listFormat(locale, options = {}) {
891
+ return cached(formats, locale, options, () => {
892
+ if (!usesBundledData(locale)) return new Intl.ListFormat(locale, options);
893
+ new Intl.ListFormat("en", options);
894
+ if (!loaded) {
895
+ ListFormat.__addLocaleData(list_en_default, list_is_default);
896
+ loaded = true;
897
+ }
898
+ return new ListFormat(locale, options);
899
+ });
900
+ }
901
+ //#endregion
902
+ export { listFormat };