@formatjs/intl-getcanonicallocales 3.3.1 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/polyfill.iife.js CHANGED
@@ -1,3 +1,84 @@
1
+ // packages/ecma262-abstract/IsObject.js
2
+ /** Includes browser host objects such as document.all. */
3
+ function IsObject(value) {
4
+ return value !== null && (typeof value === "object" || typeof value === "function" || typeof value === "undefined" && value !== void 0);
5
+ }
6
+ // packages/ecma262-abstract/intrinsics.js
7
+ const objectFrom = Object;
8
+ const mathMin = Math.min;
9
+ const mathMax = Math.max;
10
+ const mathTrunc = Math.trunc;
11
+ Number.isInteger;
12
+ Number.isFinite;
13
+ Number.isSafeInteger;
14
+ const TypeErrorConstructor$1 = TypeError;
15
+ const arrayApply = Reflect.apply;
16
+ const every = Array.prototype.every;
17
+ Array.prototype.some;
18
+ function arrayEvery(values, predicate) {
19
+ return arrayApply(every, values, [predicate]);
20
+ }
21
+ const includes = Array.prototype.includes;
22
+ const indexOf = Array.prototype.indexOf;
23
+ function arrayIncludes(values, search) {
24
+ return arrayApply(includes, values, [search]);
25
+ }
26
+ function arrayIndexOf(values, search) {
27
+ return arrayApply(indexOf, values, [search]);
28
+ }
29
+ // packages/intl-getcanonicallocales/locale-brand.ts
30
+ const apply$1 = Reflect.apply;
31
+ const defineProperty$2 = Object.defineProperty;
32
+ let readers;
33
+ function addLocaleBrandReader(read) {
34
+ if (typeof read !== "function") throw new TypeErrorConstructor$1("Locale brand reader must be callable");
35
+ for (let node = readers; node; node = node.next) if (node.read === read) return;
36
+ readers = {
37
+ read,
38
+ next: readers
39
+ };
40
+ }
41
+ function getLocaleBrandReaders() {
42
+ const result = [];
43
+ for (let node = readers; node; node = node.next) defineProperty$2(result, result.length, {
44
+ value: node.read,
45
+ writable: true,
46
+ enumerable: true,
47
+ configurable: true
48
+ });
49
+ return result;
50
+ }
51
+ function localeString(value) {
52
+ if (!IsObject(value)) return void 0;
53
+ for (let node = readers; node; node = node.next) {
54
+ const tag = node.read(value);
55
+ if (typeof tag === "string") return tag;
56
+ }
57
+ }
58
+ const LocaleConstructor = typeof Intl === "undefined" ? void 0 : Intl.Locale;
59
+ const snapshot = LocaleConstructor?.__getLocaleBrandReaders;
60
+ if (typeof snapshot === "function") {
61
+ const known = apply$1(snapshot, LocaleConstructor, []);
62
+ for (let index = 0; index < known.length; index++) addLocaleBrandReader(known[index]);
63
+ } else {
64
+ const nativeToString = LocaleConstructor?.prototype.toString;
65
+ if (typeof nativeToString === "function") addLocaleBrandReader((value) => {
66
+ try {
67
+ const tag = apply$1(nativeToString, value, []);
68
+ return typeof tag === "string" ? tag : void 0;
69
+ } catch {
70
+ return;
71
+ }
72
+ });
73
+ }
74
+ // packages/ecma262-abstract/ToObject.js
75
+ /**
76
+ * https://tc39.es/ecma262/#sec-toobject
77
+ */
78
+ function ToObject(arg) {
79
+ if (arg === void 0 || arg === null) throw new TypeErrorConstructor$1("undefined/null cannot be converted to object");
80
+ return objectFrom(arg);
81
+ }
1
82
  // packages/intl-getcanonicallocales/appendToList.ts
2
83
  function appendToList(list, ...values) {
3
84
  for (const value of values) Object.defineProperty(list, list.length, {
@@ -8,12 +89,14 @@ function appendToList(list, ...values) {
8
89
  });
9
90
  }
10
91
  // packages/ecma262-abstract/ToString.js
92
+ const StringConstructor = String;
93
+ const TypeErrorConstructor = TypeError;
11
94
  /**
12
95
  * https://tc39.es/ecma262/#sec-tostring
13
96
  */
14
97
  function ToString(o) {
15
- if (typeof o === "symbol") throw TypeError("Cannot convert a Symbol value to a string");
16
- return String(o);
98
+ if (typeof o === "symbol") throw TypeErrorConstructor("Cannot convert a Symbol value to a string");
99
+ return StringConstructor(o);
17
100
  }
18
101
  // node_modules/.aspect_rules_js/@formatjs_generated+cldr.core@0.0.0/node_modules/@formatjs_generated/cldr.core/aliases.js
19
102
  const subdivisionAlias = {
@@ -9486,11 +9569,13 @@ function compareKV(t1, t2) {
9486
9569
  return t1[0] < t2[0] ? -1 : t1[0] > t2[0] ? 1 : 0;
9487
9570
  }
9488
9571
  function compareExtension(e1, e2) {
9572
+ if (e1.type === "x") return e2.type === "x" ? 0 : 1;
9573
+ if (e2.type === "x") return -1;
9489
9574
  return e1.type < e2.type ? -1 : e1.type > e2.type ? 1 : 0;
9490
9575
  }
9491
9576
  function mergeVariants(v1, v2) {
9492
9577
  const result = [...v1];
9493
- for (const v of v2) if (v1.indexOf(v) < 0) appendToList(result, v);
9578
+ for (const v of v2) if (arrayIndexOf(v1, v) < 0) appendToList(result, v);
9494
9579
  return result;
9495
9580
  }
9496
9581
  function compareLanguageAliasRules(a, b) {
@@ -9536,7 +9621,7 @@ function canonicalizeUnicodeLanguageId(unicodeLanguageId) {
9536
9621
  unicodeLanguageId.variants = unicodeLanguageId.variants.map((v) => v.toLowerCase());
9537
9622
  const original = emitUnicodeLanguageId(unicodeLanguageId);
9538
9623
  let finalLangAst = unicodeLanguageId;
9539
- const matches = ({ type }) => (!type.script || type.script === finalLangAst.script) && (!type.region || type.region === finalLangAst.region) && type.variants.every((variant) => finalLangAst.variants.includes(variant));
9624
+ const matches = ({ type }) => (!type.script || type.script === finalLangAst.script) && (!type.region || type.region === finalLangAst.region) && arrayEvery(type.variants, (variant) => arrayIncludes(finalLangAst.variants, variant));
9540
9625
  const languageRule = languageAliasRules[finalLangAst.lang]?.find(matches);
9541
9626
  const undRule = finalLangAst.lang === "und" ? void 0 : languageAliasRules.und?.find(matches);
9542
9627
  const matched = !languageRule ? undRule : !undRule ? languageRule : compareLanguageAliasRules(languageRule, undRule) <= 0 ? languageRule : undRule;
@@ -9546,7 +9631,7 @@ function canonicalizeUnicodeLanguageId(unicodeLanguageId) {
9546
9631
  lang: type.lang !== "und" || finalLangAst.lang === "und" ? replacement.lang : finalLangAst.lang,
9547
9632
  script: type.script ? replacement.script : finalLangAst.script || replacement.script,
9548
9633
  region: type.region ? replacement.region : finalLangAst.region || replacement.region,
9549
- variants: mergeVariants(finalLangAst.variants.filter((v) => !type.variants.includes(v)), replacement.variants)
9634
+ variants: mergeVariants(finalLangAst.variants.filter((v) => !arrayIncludes(type.variants, v)), replacement.variants)
9550
9635
  };
9551
9636
  return canonicalizeUnicodeLanguageId(finalLangAst);
9552
9637
  }
@@ -9564,7 +9649,7 @@ function canonicalizeUnicodeLanguageId(unicodeLanguageId) {
9564
9649
  })] || likelySubtags[finalLangAst.lang];
9565
9650
  if (likelySubtag) {
9566
9651
  const { region: likelyRegion } = parseUnicodeLanguageId(likelySubtag.split("-"));
9567
- if (likelyRegion && regions.indexOf(likelyRegion) > -1) replacedRegion = likelyRegion;
9652
+ if (likelyRegion && arrayIndexOf(regions, likelyRegion) > -1) replacedRegion = likelyRegion;
9568
9653
  }
9569
9654
  }
9570
9655
  if (replacedRegion) finalLangAst.region = replacedRegion;
@@ -9613,15 +9698,6 @@ function CanonicalizeUnicodeLocaleId(locale) {
9613
9698
  return locale;
9614
9699
  }
9615
9700
  // packages/intl-getcanonicallocales/index.ts
9616
- const originalLocaleToString = typeof Intl !== "undefined" ? Intl.Locale?.prototype.toString : void 0;
9617
- function localeString(value) {
9618
- if (value === null || typeof value !== "object" && typeof value !== "function") return void 0;
9619
- const currentLocaleToString = typeof Intl !== "undefined" ? Intl.Locale?.prototype.toString : void 0;
9620
- for (const method of [originalLocaleToString, currentLocaleToString]) if (method) try {
9621
- const tag = method.call(value);
9622
- if (typeof tag === "string") return tag;
9623
- } catch {}
9624
- }
9625
9701
  /**
9626
9702
  * ECMA-402 §9.2.1 CanonicalizeLocaleList, steps 3–7.
9627
9703
  * https://tc39.es/ecma402/#sec-canonicalizelocalelist
@@ -9629,33 +9705,46 @@ function localeString(value) {
9629
9705
  */
9630
9706
  function CanonicalizeLocaleList(locales) {
9631
9707
  if (locales === void 0) return [];
9632
- if (locales === null) throw new TypeError("Cannot convert null to an object");
9708
+ if (locales === null) throw new TypeErrorConstructor$1("Cannot convert null to an object");
9633
9709
  const singleLocale = localeString(locales);
9634
- const list = typeof locales === "string" ? [locales] : singleLocale !== void 0 ? [singleLocale] : Object(locales);
9710
+ const list = typeof locales === "string" ? [locales] : singleLocale !== void 0 ? [singleLocale] : ToObject(locales);
9635
9711
  const length = +list.length;
9636
- const len = isNaN(length) ? 0 : Math.min(Math.max(Math.floor(length), 0), 9007199254740991);
9712
+ const len = length !== length ? 0 : mathMin(mathMax(mathTrunc(length), 0), 9007199254740991);
9637
9713
  const seen = [];
9638
9714
  for (let k = 0; k < len; k++) {
9639
9715
  if (!(k in list)) continue;
9640
9716
  const value = list[k];
9641
- if (value === null || ![
9642
- "string",
9643
- "object",
9644
- "function"
9645
- ].includes(typeof value)) throw new TypeError("Locale list entries must be strings or objects");
9717
+ if (typeof value !== "string" && !IsObject(value)) throw new TypeErrorConstructor$1("Locale list entries must be strings or objects");
9646
9718
  const canonicalizedTag = emitUnicodeLocaleId(CanonicalizeUnicodeLocaleId(parseUnicodeLocaleId(localeString(value) ?? ToString(value))));
9647
- if (seen.indexOf(canonicalizedTag) < 0) appendToList(seen, canonicalizedTag);
9719
+ if (arrayIndexOf(seen, canonicalizedTag) < 0) appendToList(seen, canonicalizedTag);
9648
9720
  }
9649
9721
  return seen;
9650
9722
  }
9651
9723
  function getCanonicalLocales(locales) {
9652
9724
  return CanonicalizeLocaleList(locales);
9653
9725
  }
9726
+ Object.defineProperties(getCanonicalLocales, {
9727
+ __addLocaleBrandReader: { value: addLocaleBrandReader },
9728
+ __getLocaleBrandReaders: { value: getLocaleBrandReaders }
9729
+ });
9654
9730
  // packages/intl-getcanonicallocales/should-polyfill.ts
9655
9731
  function shouldPolyfill() {
9656
- return typeof Intl === "undefined" || !("getCanonicalLocales" in Intl) || Intl.getCanonicalLocales("und-x-private")[0] === "x-private";
9732
+ if (typeof Intl === "undefined" || typeof Intl.getCanonicalLocales !== "function") return true;
9733
+ try {
9734
+ const canonicalize = Intl.getCanonicalLocales;
9735
+ return canonicalize("und-x-private")[0] !== "und-x-private" || canonicalize("en-u-aa-yes")[0] !== "en-u-aa-yes" || canonicalize("en-u-kn-yes")[0] !== "en-u-kn";
9736
+ } catch {
9737
+ return true;
9738
+ }
9657
9739
  }
9658
9740
  // node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js
9741
+ const apply = Reflect.apply;
9742
+ const bind = Function.prototype.bind;
9743
+ const slice = Array.prototype.slice;
9744
+ const stringify = JSON.stringify;
9745
+ const create = Object.create;
9746
+ const defineProperty$1 = Object.defineProperty;
9747
+ const setPrototypeOf = Object.setPrototypeOf;
9659
9748
  function memoize(fn, options) {
9660
9749
  const cache = options && options.cache ? options.cache : cacheDefault;
9661
9750
  const serializer = options && options.serializer ? options.serializer : serializerDefault;
@@ -9671,23 +9760,29 @@ function monadic(fn, cache, serializer, arg) {
9671
9760
  const cacheKey = isPrimitive(arg) ? arg : serializer(arg);
9672
9761
  let computedValue = cache.get(cacheKey);
9673
9762
  if (typeof computedValue === "undefined") {
9674
- computedValue = fn.call(this, arg);
9763
+ computedValue = apply(fn, this, [arg]);
9675
9764
  cache.set(cacheKey, computedValue);
9676
9765
  }
9677
9766
  return computedValue;
9678
9767
  }
9679
9768
  function variadic(fn, cache, serializer) {
9680
- const args = Array.prototype.slice.call(arguments, 3);
9769
+ const args = apply(slice, arguments, [3]);
9770
+ if (serializer === serializerDefault) setPrototypeOf(args, null);
9681
9771
  const cacheKey = serializer(args);
9682
9772
  let computedValue = cache.get(cacheKey);
9683
9773
  if (typeof computedValue === "undefined") {
9684
- computedValue = fn.apply(this, args);
9774
+ computedValue = apply(fn, this, args);
9685
9775
  cache.set(cacheKey, computedValue);
9686
9776
  }
9687
9777
  return computedValue;
9688
9778
  }
9689
9779
  function assemble(fn, context, strategy, cache, serialize) {
9690
- return strategy.bind(context, fn, cache, serialize);
9780
+ return apply(bind, strategy, [
9781
+ context,
9782
+ fn,
9783
+ cache,
9784
+ serialize
9785
+ ]);
9691
9786
  }
9692
9787
  function strategyDefault(fn, options) {
9693
9788
  const strategy = fn.length === 1 ? monadic : variadic;
@@ -9700,11 +9795,18 @@ function strategyMonadic(fn, options) {
9700
9795
  return assemble(fn, this, monadic, options.cache.create(), options.serializer);
9701
9796
  }
9702
9797
  const serializerDefault = function() {
9703
- return JSON.stringify(arguments);
9798
+ setPrototypeOf(arguments, null);
9799
+ return stringify(arguments);
9704
9800
  };
9705
9801
  var ObjectWithoutPrototypeCache = class {
9706
9802
  constructor() {
9707
- this.cache = Object.create(null);
9803
+ defineProperty$1(this, "cache", {
9804
+ __proto__: null,
9805
+ value: create(null),
9806
+ writable: true,
9807
+ enumerable: true,
9808
+ configurable: true
9809
+ });
9708
9810
  }
9709
9811
  get(key) {
9710
9812
  return this.cache[key];
@@ -9736,11 +9838,56 @@ function ensureIntl() {
9736
9838
  writable: true,
9737
9839
  value: {}
9738
9840
  });
9841
+ if (providerIntl === void 0) providerIntl = Intl;
9739
9842
  return Intl;
9740
9843
  }
9741
9844
  memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
9742
9845
  memoize((...args) => new Intl.PluralRules(...args), { strategy: strategies.variadic });
9743
9846
  memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic });
9847
+ const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
9848
+ strategies.variadic;
9849
+ let providerIntl = globalThis.Intl;
9850
+ function ownIntlProvider(name) {
9851
+ const descriptor = providerIntl && getOwnPropertyDescriptor(providerIntl, name);
9852
+ return (descriptor && getOwnPropertyDescriptor(descriptor, "value"))?.value;
9853
+ }
9854
+ let numberFormatProvider = ownIntlProvider("NumberFormat");
9855
+ let listFormatProvider = ownIntlProvider("ListFormat");
9856
+ const getFormatterPrototype = Object.getPrototypeOf;
9857
+ const formatterPartsMethods = /* @__PURE__ */ new WeakMap();
9858
+ const formatterPartsOwners = /* @__PURE__ */ new WeakMap();
9859
+ const getPartsMethod = formatterPartsMethods.get.bind(formatterPartsMethods);
9860
+ const setPartsMethod = formatterPartsMethods.set.bind(formatterPartsMethods);
9861
+ const getPartsOwner = formatterPartsOwners.get.bind(formatterPartsOwners);
9862
+ const setPartsOwner = formatterPartsOwners.set.bind(formatterPartsOwners);
9863
+ function findFormatterPartsMethod(Constructor) {
9864
+ const cached = getPartsMethod(Constructor);
9865
+ if (cached) return cached;
9866
+ let prototype = getOwnPropertyDescriptor(Constructor, "prototype")?.value;
9867
+ while (prototype != null) {
9868
+ const inherited = getPartsOwner(prototype);
9869
+ if (inherited) {
9870
+ setPartsMethod(Constructor, inherited);
9871
+ return inherited;
9872
+ }
9873
+ const descriptor = getOwnPropertyDescriptor(prototype, "formatToParts");
9874
+ const value = descriptor && getOwnPropertyDescriptor(descriptor, "value");
9875
+ if (value && typeof value.value === "function") {
9876
+ setPartsMethod(Constructor, value.value);
9877
+ setPartsOwner(prototype, value.value);
9878
+ return value.value;
9879
+ }
9880
+ prototype = getFormatterPrototype(prototype);
9881
+ }
9882
+ }
9883
+ if (typeof numberFormatProvider === "function") findFormatterPartsMethod(numberFormatProvider);
9884
+ if (typeof listFormatProvider === "function") findFormatterPartsMethod(listFormatProvider);
9885
+ const numberFormatMemoizers = /* @__PURE__ */ new WeakMap();
9886
+ numberFormatMemoizers.get.bind(numberFormatMemoizers);
9887
+ numberFormatMemoizers.set.bind(numberFormatMemoizers);
9888
+ const listFormatMemoizers = /* @__PURE__ */ new WeakMap();
9889
+ listFormatMemoizers.get.bind(listFormatMemoizers);
9890
+ listFormatMemoizers.set.bind(listFormatMemoizers);
9744
9891
  // packages/intl-getcanonicallocales/polyfill.ts
9745
9892
  const intl = ensureIntl();
9746
9893
  if (shouldPolyfill()) defineProperty(intl, "getCanonicalLocales", { value: getCanonicalLocales });
package/polyfill.js CHANGED
@@ -1,3 +1,84 @@
1
+ // packages/ecma262-abstract/IsObject.js
2
+ /** Includes browser host objects such as document.all. */
3
+ function IsObject(value) {
4
+ return value !== null && (typeof value === "object" || typeof value === "function" || typeof value === "undefined" && value !== void 0);
5
+ }
6
+ // packages/ecma262-abstract/intrinsics.js
7
+ const objectFrom = Object;
8
+ const mathMin = Math.min;
9
+ const mathMax = Math.max;
10
+ const mathTrunc = Math.trunc;
11
+ Number.isInteger;
12
+ Number.isFinite;
13
+ Number.isSafeInteger;
14
+ const TypeErrorConstructor$1 = TypeError;
15
+ const arrayApply = Reflect.apply;
16
+ const every = Array.prototype.every;
17
+ Array.prototype.some;
18
+ function arrayEvery(values, predicate) {
19
+ return arrayApply(every, values, [predicate]);
20
+ }
21
+ const includes = Array.prototype.includes;
22
+ const indexOf = Array.prototype.indexOf;
23
+ function arrayIncludes(values, search) {
24
+ return arrayApply(includes, values, [search]);
25
+ }
26
+ function arrayIndexOf(values, search) {
27
+ return arrayApply(indexOf, values, [search]);
28
+ }
29
+ // packages/intl-getcanonicallocales/locale-brand.ts
30
+ const apply$1 = Reflect.apply;
31
+ const defineProperty$2 = Object.defineProperty;
32
+ let readers;
33
+ function addLocaleBrandReader(read) {
34
+ if (typeof read !== "function") throw new TypeErrorConstructor$1("Locale brand reader must be callable");
35
+ for (let node = readers; node; node = node.next) if (node.read === read) return;
36
+ readers = {
37
+ read,
38
+ next: readers
39
+ };
40
+ }
41
+ function getLocaleBrandReaders() {
42
+ const result = [];
43
+ for (let node = readers; node; node = node.next) defineProperty$2(result, result.length, {
44
+ value: node.read,
45
+ writable: true,
46
+ enumerable: true,
47
+ configurable: true
48
+ });
49
+ return result;
50
+ }
51
+ function localeString(value) {
52
+ if (!IsObject(value)) return void 0;
53
+ for (let node = readers; node; node = node.next) {
54
+ const tag = node.read(value);
55
+ if (typeof tag === "string") return tag;
56
+ }
57
+ }
58
+ const LocaleConstructor = typeof Intl === "undefined" ? void 0 : Intl.Locale;
59
+ const snapshot = LocaleConstructor?.__getLocaleBrandReaders;
60
+ if (typeof snapshot === "function") {
61
+ const known = apply$1(snapshot, LocaleConstructor, []);
62
+ for (let index = 0; index < known.length; index++) addLocaleBrandReader(known[index]);
63
+ } else {
64
+ const nativeToString = LocaleConstructor?.prototype.toString;
65
+ if (typeof nativeToString === "function") addLocaleBrandReader((value) => {
66
+ try {
67
+ const tag = apply$1(nativeToString, value, []);
68
+ return typeof tag === "string" ? tag : void 0;
69
+ } catch {
70
+ return;
71
+ }
72
+ });
73
+ }
74
+ // packages/ecma262-abstract/ToObject.js
75
+ /**
76
+ * https://tc39.es/ecma262/#sec-toobject
77
+ */
78
+ function ToObject(arg) {
79
+ if (arg === void 0 || arg === null) throw new TypeErrorConstructor$1("undefined/null cannot be converted to object");
80
+ return objectFrom(arg);
81
+ }
1
82
  // packages/intl-getcanonicallocales/appendToList.ts
2
83
  function appendToList(list, ...values) {
3
84
  for (const value of values) Object.defineProperty(list, list.length, {
@@ -8,12 +89,14 @@ function appendToList(list, ...values) {
8
89
  });
9
90
  }
10
91
  // packages/ecma262-abstract/ToString.js
92
+ const StringConstructor = String;
93
+ const TypeErrorConstructor = TypeError;
11
94
  /**
12
95
  * https://tc39.es/ecma262/#sec-tostring
13
96
  */
14
97
  function ToString(o) {
15
- if (typeof o === "symbol") throw TypeError("Cannot convert a Symbol value to a string");
16
- return String(o);
98
+ if (typeof o === "symbol") throw TypeErrorConstructor("Cannot convert a Symbol value to a string");
99
+ return StringConstructor(o);
17
100
  }
18
101
  // node_modules/.aspect_rules_js/@formatjs_generated+cldr.core@0.0.0/node_modules/@formatjs_generated/cldr.core/aliases.js
19
102
  const subdivisionAlias = {
@@ -9486,11 +9569,13 @@ function compareKV(t1, t2) {
9486
9569
  return t1[0] < t2[0] ? -1 : t1[0] > t2[0] ? 1 : 0;
9487
9570
  }
9488
9571
  function compareExtension(e1, e2) {
9572
+ if (e1.type === "x") return e2.type === "x" ? 0 : 1;
9573
+ if (e2.type === "x") return -1;
9489
9574
  return e1.type < e2.type ? -1 : e1.type > e2.type ? 1 : 0;
9490
9575
  }
9491
9576
  function mergeVariants(v1, v2) {
9492
9577
  const result = [...v1];
9493
- for (const v of v2) if (v1.indexOf(v) < 0) appendToList(result, v);
9578
+ for (const v of v2) if (arrayIndexOf(v1, v) < 0) appendToList(result, v);
9494
9579
  return result;
9495
9580
  }
9496
9581
  function compareLanguageAliasRules(a, b) {
@@ -9536,7 +9621,7 @@ function canonicalizeUnicodeLanguageId(unicodeLanguageId) {
9536
9621
  unicodeLanguageId.variants = unicodeLanguageId.variants.map((v) => v.toLowerCase());
9537
9622
  const original = emitUnicodeLanguageId(unicodeLanguageId);
9538
9623
  let finalLangAst = unicodeLanguageId;
9539
- const matches = ({ type }) => (!type.script || type.script === finalLangAst.script) && (!type.region || type.region === finalLangAst.region) && type.variants.every((variant) => finalLangAst.variants.includes(variant));
9624
+ const matches = ({ type }) => (!type.script || type.script === finalLangAst.script) && (!type.region || type.region === finalLangAst.region) && arrayEvery(type.variants, (variant) => arrayIncludes(finalLangAst.variants, variant));
9540
9625
  const languageRule = languageAliasRules[finalLangAst.lang]?.find(matches);
9541
9626
  const undRule = finalLangAst.lang === "und" ? void 0 : languageAliasRules.und?.find(matches);
9542
9627
  const matched = !languageRule ? undRule : !undRule ? languageRule : compareLanguageAliasRules(languageRule, undRule) <= 0 ? languageRule : undRule;
@@ -9546,7 +9631,7 @@ function canonicalizeUnicodeLanguageId(unicodeLanguageId) {
9546
9631
  lang: type.lang !== "und" || finalLangAst.lang === "und" ? replacement.lang : finalLangAst.lang,
9547
9632
  script: type.script ? replacement.script : finalLangAst.script || replacement.script,
9548
9633
  region: type.region ? replacement.region : finalLangAst.region || replacement.region,
9549
- variants: mergeVariants(finalLangAst.variants.filter((v) => !type.variants.includes(v)), replacement.variants)
9634
+ variants: mergeVariants(finalLangAst.variants.filter((v) => !arrayIncludes(type.variants, v)), replacement.variants)
9550
9635
  };
9551
9636
  return canonicalizeUnicodeLanguageId(finalLangAst);
9552
9637
  }
@@ -9564,7 +9649,7 @@ function canonicalizeUnicodeLanguageId(unicodeLanguageId) {
9564
9649
  })] || likelySubtags[finalLangAst.lang];
9565
9650
  if (likelySubtag) {
9566
9651
  const { region: likelyRegion } = parseUnicodeLanguageId(likelySubtag.split("-"));
9567
- if (likelyRegion && regions.indexOf(likelyRegion) > -1) replacedRegion = likelyRegion;
9652
+ if (likelyRegion && arrayIndexOf(regions, likelyRegion) > -1) replacedRegion = likelyRegion;
9568
9653
  }
9569
9654
  }
9570
9655
  if (replacedRegion) finalLangAst.region = replacedRegion;
@@ -9613,15 +9698,6 @@ function CanonicalizeUnicodeLocaleId(locale) {
9613
9698
  return locale;
9614
9699
  }
9615
9700
  // packages/intl-getcanonicallocales/index.ts
9616
- const originalLocaleToString = typeof Intl !== "undefined" ? Intl.Locale?.prototype.toString : void 0;
9617
- function localeString(value) {
9618
- if (value === null || typeof value !== "object" && typeof value !== "function") return void 0;
9619
- const currentLocaleToString = typeof Intl !== "undefined" ? Intl.Locale?.prototype.toString : void 0;
9620
- for (const method of [originalLocaleToString, currentLocaleToString]) if (method) try {
9621
- const tag = method.call(value);
9622
- if (typeof tag === "string") return tag;
9623
- } catch {}
9624
- }
9625
9701
  /**
9626
9702
  * ECMA-402 §9.2.1 CanonicalizeLocaleList, steps 3–7.
9627
9703
  * https://tc39.es/ecma402/#sec-canonicalizelocalelist
@@ -9629,33 +9705,46 @@ function localeString(value) {
9629
9705
  */
9630
9706
  function CanonicalizeLocaleList(locales) {
9631
9707
  if (locales === void 0) return [];
9632
- if (locales === null) throw new TypeError("Cannot convert null to an object");
9708
+ if (locales === null) throw new TypeErrorConstructor$1("Cannot convert null to an object");
9633
9709
  const singleLocale = localeString(locales);
9634
- const list = typeof locales === "string" ? [locales] : singleLocale !== void 0 ? [singleLocale] : Object(locales);
9710
+ const list = typeof locales === "string" ? [locales] : singleLocale !== void 0 ? [singleLocale] : ToObject(locales);
9635
9711
  const length = +list.length;
9636
- const len = isNaN(length) ? 0 : Math.min(Math.max(Math.floor(length), 0), 9007199254740991);
9712
+ const len = length !== length ? 0 : mathMin(mathMax(mathTrunc(length), 0), 9007199254740991);
9637
9713
  const seen = [];
9638
9714
  for (let k = 0; k < len; k++) {
9639
9715
  if (!(k in list)) continue;
9640
9716
  const value = list[k];
9641
- if (value === null || ![
9642
- "string",
9643
- "object",
9644
- "function"
9645
- ].includes(typeof value)) throw new TypeError("Locale list entries must be strings or objects");
9717
+ if (typeof value !== "string" && !IsObject(value)) throw new TypeErrorConstructor$1("Locale list entries must be strings or objects");
9646
9718
  const canonicalizedTag = emitUnicodeLocaleId(CanonicalizeUnicodeLocaleId(parseUnicodeLocaleId(localeString(value) ?? ToString(value))));
9647
- if (seen.indexOf(canonicalizedTag) < 0) appendToList(seen, canonicalizedTag);
9719
+ if (arrayIndexOf(seen, canonicalizedTag) < 0) appendToList(seen, canonicalizedTag);
9648
9720
  }
9649
9721
  return seen;
9650
9722
  }
9651
9723
  function getCanonicalLocales(locales) {
9652
9724
  return CanonicalizeLocaleList(locales);
9653
9725
  }
9726
+ Object.defineProperties(getCanonicalLocales, {
9727
+ __addLocaleBrandReader: { value: addLocaleBrandReader },
9728
+ __getLocaleBrandReaders: { value: getLocaleBrandReaders }
9729
+ });
9654
9730
  // packages/intl-getcanonicallocales/should-polyfill.ts
9655
9731
  function shouldPolyfill() {
9656
- return typeof Intl === "undefined" || !("getCanonicalLocales" in Intl) || Intl.getCanonicalLocales("und-x-private")[0] === "x-private";
9732
+ if (typeof Intl === "undefined" || typeof Intl.getCanonicalLocales !== "function") return true;
9733
+ try {
9734
+ const canonicalize = Intl.getCanonicalLocales;
9735
+ return canonicalize("und-x-private")[0] !== "und-x-private" || canonicalize("en-u-aa-yes")[0] !== "en-u-aa-yes" || canonicalize("en-u-kn-yes")[0] !== "en-u-kn";
9736
+ } catch {
9737
+ return true;
9738
+ }
9657
9739
  }
9658
9740
  // node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js
9741
+ const apply = Reflect.apply;
9742
+ const bind = Function.prototype.bind;
9743
+ const slice = Array.prototype.slice;
9744
+ const stringify = JSON.stringify;
9745
+ const create = Object.create;
9746
+ const defineProperty$1 = Object.defineProperty;
9747
+ const setPrototypeOf = Object.setPrototypeOf;
9659
9748
  function memoize(fn, options) {
9660
9749
  const cache = options && options.cache ? options.cache : cacheDefault;
9661
9750
  const serializer = options && options.serializer ? options.serializer : serializerDefault;
@@ -9671,23 +9760,29 @@ function monadic(fn, cache, serializer, arg) {
9671
9760
  const cacheKey = isPrimitive(arg) ? arg : serializer(arg);
9672
9761
  let computedValue = cache.get(cacheKey);
9673
9762
  if (typeof computedValue === "undefined") {
9674
- computedValue = fn.call(this, arg);
9763
+ computedValue = apply(fn, this, [arg]);
9675
9764
  cache.set(cacheKey, computedValue);
9676
9765
  }
9677
9766
  return computedValue;
9678
9767
  }
9679
9768
  function variadic(fn, cache, serializer) {
9680
- const args = Array.prototype.slice.call(arguments, 3);
9769
+ const args = apply(slice, arguments, [3]);
9770
+ if (serializer === serializerDefault) setPrototypeOf(args, null);
9681
9771
  const cacheKey = serializer(args);
9682
9772
  let computedValue = cache.get(cacheKey);
9683
9773
  if (typeof computedValue === "undefined") {
9684
- computedValue = fn.apply(this, args);
9774
+ computedValue = apply(fn, this, args);
9685
9775
  cache.set(cacheKey, computedValue);
9686
9776
  }
9687
9777
  return computedValue;
9688
9778
  }
9689
9779
  function assemble(fn, context, strategy, cache, serialize) {
9690
- return strategy.bind(context, fn, cache, serialize);
9780
+ return apply(bind, strategy, [
9781
+ context,
9782
+ fn,
9783
+ cache,
9784
+ serialize
9785
+ ]);
9691
9786
  }
9692
9787
  function strategyDefault(fn, options) {
9693
9788
  const strategy = fn.length === 1 ? monadic : variadic;
@@ -9700,11 +9795,18 @@ function strategyMonadic(fn, options) {
9700
9795
  return assemble(fn, this, monadic, options.cache.create(), options.serializer);
9701
9796
  }
9702
9797
  const serializerDefault = function() {
9703
- return JSON.stringify(arguments);
9798
+ setPrototypeOf(arguments, null);
9799
+ return stringify(arguments);
9704
9800
  };
9705
9801
  var ObjectWithoutPrototypeCache = class {
9706
9802
  constructor() {
9707
- this.cache = Object.create(null);
9803
+ defineProperty$1(this, "cache", {
9804
+ __proto__: null,
9805
+ value: create(null),
9806
+ writable: true,
9807
+ enumerable: true,
9808
+ configurable: true
9809
+ });
9708
9810
  }
9709
9811
  get(key) {
9710
9812
  return this.cache[key];
@@ -9736,11 +9838,56 @@ function ensureIntl() {
9736
9838
  writable: true,
9737
9839
  value: {}
9738
9840
  });
9841
+ if (providerIntl === void 0) providerIntl = Intl;
9739
9842
  return Intl;
9740
9843
  }
9741
9844
  memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
9742
9845
  memoize((...args) => new Intl.PluralRules(...args), { strategy: strategies.variadic });
9743
9846
  memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic });
9847
+ const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
9848
+ strategies.variadic;
9849
+ let providerIntl = globalThis.Intl;
9850
+ function ownIntlProvider(name) {
9851
+ const descriptor = providerIntl && getOwnPropertyDescriptor(providerIntl, name);
9852
+ return (descriptor && getOwnPropertyDescriptor(descriptor, "value"))?.value;
9853
+ }
9854
+ let numberFormatProvider = ownIntlProvider("NumberFormat");
9855
+ let listFormatProvider = ownIntlProvider("ListFormat");
9856
+ const getFormatterPrototype = Object.getPrototypeOf;
9857
+ const formatterPartsMethods = /* @__PURE__ */ new WeakMap();
9858
+ const formatterPartsOwners = /* @__PURE__ */ new WeakMap();
9859
+ const getPartsMethod = formatterPartsMethods.get.bind(formatterPartsMethods);
9860
+ const setPartsMethod = formatterPartsMethods.set.bind(formatterPartsMethods);
9861
+ const getPartsOwner = formatterPartsOwners.get.bind(formatterPartsOwners);
9862
+ const setPartsOwner = formatterPartsOwners.set.bind(formatterPartsOwners);
9863
+ function findFormatterPartsMethod(Constructor) {
9864
+ const cached = getPartsMethod(Constructor);
9865
+ if (cached) return cached;
9866
+ let prototype = getOwnPropertyDescriptor(Constructor, "prototype")?.value;
9867
+ while (prototype != null) {
9868
+ const inherited = getPartsOwner(prototype);
9869
+ if (inherited) {
9870
+ setPartsMethod(Constructor, inherited);
9871
+ return inherited;
9872
+ }
9873
+ const descriptor = getOwnPropertyDescriptor(prototype, "formatToParts");
9874
+ const value = descriptor && getOwnPropertyDescriptor(descriptor, "value");
9875
+ if (value && typeof value.value === "function") {
9876
+ setPartsMethod(Constructor, value.value);
9877
+ setPartsOwner(prototype, value.value);
9878
+ return value.value;
9879
+ }
9880
+ prototype = getFormatterPrototype(prototype);
9881
+ }
9882
+ }
9883
+ if (typeof numberFormatProvider === "function") findFormatterPartsMethod(numberFormatProvider);
9884
+ if (typeof listFormatProvider === "function") findFormatterPartsMethod(listFormatProvider);
9885
+ const numberFormatMemoizers = /* @__PURE__ */ new WeakMap();
9886
+ numberFormatMemoizers.get.bind(numberFormatMemoizers);
9887
+ numberFormatMemoizers.set.bind(numberFormatMemoizers);
9888
+ const listFormatMemoizers = /* @__PURE__ */ new WeakMap();
9889
+ listFormatMemoizers.get.bind(listFormatMemoizers);
9890
+ listFormatMemoizers.set.bind(listFormatMemoizers);
9744
9891
  // packages/intl-getcanonicallocales/polyfill.ts
9745
9892
  const intl = ensureIntl();
9746
9893
  if (shouldPolyfill()) defineProperty(intl, "getCanonicalLocales", { value: getCanonicalLocales });