@formatjs/intl-localematcher 0.10.1 → 0.10.2

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/index.js CHANGED
@@ -1,11 +1,59 @@
1
1
  import { memoize } from "@formatjs/fast-memoize";
2
2
  // packages/intl-localematcher/abstract/CanonicalizeLocaleList.ts
3
+ let canonicalIntl = globalThis.Intl;
4
+ const getOwnDescriptor = Object.getOwnPropertyDescriptor;
5
+ const apply$2 = Reflect.apply;
6
+ function ownCanonicalizer() {
7
+ const descriptor = canonicalIntl && getOwnDescriptor(canonicalIntl, "getCanonicalLocales");
8
+ return descriptor && getOwnDescriptor(descriptor, "value")?.value;
9
+ }
10
+ let canonicalize$1 = ownCanonicalizer();
3
11
  /**
4
12
  * http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist
5
13
  * @param locales
6
14
  */
7
15
  function CanonicalizeLocaleList(locales) {
8
- return Intl.getCanonicalLocales(locales);
16
+ if (canonicalIntl === void 0) canonicalIntl = globalThis.Intl;
17
+ const installed = ownCanonicalizer();
18
+ if (typeof installed === "function") canonicalize$1 = installed;
19
+ return apply$2(canonicalize$1, canonicalIntl, [locales]);
20
+ }
21
+ // packages/intl-localematcher/abstract/intrinsics.ts
22
+ const apply$1 = Reflect.apply;
23
+ const includes = Array.prototype.includes;
24
+ const indexOf = Array.prototype.indexOf;
25
+ function arrayIncludes(values, search) {
26
+ return apply$1(includes, values, [search]);
27
+ }
28
+ function arrayIndexOf(values, search) {
29
+ return apply$1(indexOf, values, [search]);
30
+ }
31
+ const find = Array.prototype.find;
32
+ function arrayFind(values, predicate) {
33
+ return apply$1(find, values, [predicate]);
34
+ }
35
+ const defineProperty = Object.defineProperty;
36
+ function setDataProperty(target, key, value) {
37
+ defineProperty(target, key, {
38
+ __proto__: null,
39
+ value,
40
+ writable: true,
41
+ enumerable: true,
42
+ configurable: true
43
+ });
44
+ }
45
+ const stringSlice = Function.prototype.call.bind(String.prototype.slice);
46
+ const stringIndexOf = Function.prototype.call.bind(String.prototype.indexOf);
47
+ const stringLastIndexOf = Function.prototype.call.bind(String.prototype.lastIndexOf);
48
+ const stringLowerCase = Function.prototype.call.bind(String.prototype.toLowerCase);
49
+ const stringCharCodeAt = Function.prototype.call.bind(String.prototype.charCodeAt);
50
+ const split = String.prototype.split;
51
+ const hyphen = {
52
+ __proto__: null,
53
+ toString: () => "-"
54
+ };
55
+ function splitLocaleSubtags(value) {
56
+ return apply$1(split, value, [hyphen]);
9
57
  }
10
58
  // node_modules/.aspect_rules_js/@formatjs_generated+cldr.core@0.0.0/node_modules/@formatjs_generated/cldr.core/matching.js
11
59
  const matchingData = {
@@ -1758,19 +1806,38 @@ const matchingData = {
1758
1806
  "demotion": 5
1759
1807
  };
1760
1808
  // packages/intl-localematcher/abstract/utils.ts
1809
+ const apply = Reflect.apply;
1810
+ const some = Array.prototype.some;
1811
+ const sortLocaleIndexes = Array.prototype.sort;
1812
+ const freezeLocaleList = Object.freeze;
1813
+ const LocaleError = Error;
1814
+ const LocaleMap = Map;
1815
+ const LocaleSet$1 = Set;
1816
+ const addLocaleSet = Function.prototype.call.bind(LocaleSet$1.prototype.add);
1817
+ const hasLocaleSet = Function.prototype.call.bind(LocaleSet$1.prototype.has);
1818
+ const minDistance = Math.min;
1819
+ const maxDistance = Math.max;
1761
1820
  function splitUnicodeExtension(locale) {
1762
- const subtags = locale.split("-");
1821
+ const subtags = splitLocaleSubtags(locale);
1763
1822
  for (let i = 1; i < subtags.length; i++) {
1764
1823
  if (subtags[i] === "x") break;
1765
1824
  if (subtags[i] !== "u") continue;
1766
1825
  let end = i + 1;
1767
1826
  while (end < subtags.length && subtags[end].length > 1) end++;
1827
+ let base = subtags[0];
1828
+ for (let j = 1; j < i; j++) base += "-" + subtags[j];
1829
+ for (let j = end; j < subtags.length; j++) base += "-" + subtags[j];
1830
+ let extension = "";
1831
+ for (let j = i; j < end; j++) extension += "-" + subtags[j];
1768
1832
  return {
1769
- locale: [...subtags.slice(0, i), ...subtags.slice(end)].join("-"),
1770
- extension: "-" + subtags.slice(i, end).join("-")
1833
+ locale: base,
1834
+ extension
1771
1835
  };
1772
1836
  }
1773
- return { locale };
1837
+ return {
1838
+ locale,
1839
+ extension: void 0
1840
+ };
1774
1841
  }
1775
1842
  /**
1776
1843
  * Asserts that a condition is true, throwing an error if it is not.
@@ -1787,18 +1854,18 @@ function splitUnicodeExtension(locale) {
1787
1854
  * // locale is now narrowed to non-undefined type
1788
1855
  * ```
1789
1856
  */
1790
- function invariant(condition, message, Err = Error) {
1857
+ function invariant(condition, message, Err = LocaleError) {
1791
1858
  if (!condition) throw new Err(message);
1792
1859
  }
1793
1860
  const DEFAULT_MATCHING_THRESHOLD = matchingData.defaults[1];
1794
1861
  const DISTANCE_SCALE = 8;
1795
1862
  const MIN_LSR_DISTANCE = matchingData.minLsrDistance;
1796
- const languageAliases = new Set(matchingData.canonicalAliases.language);
1797
- const scriptAliases = new Set(matchingData.canonicalAliases.script);
1798
- const regionAliases = new Set(matchingData.canonicalAliases.region);
1863
+ const languageAliases = new LocaleSet$1(matchingData.canonicalAliases.language);
1864
+ const scriptAliases = new LocaleSet$1(matchingData.canonicalAliases.script);
1865
+ const regionAliases = new LocaleSet$1(matchingData.canonicalAliases.region);
1799
1866
  function ascii(value, start, end, min, max) {
1800
1867
  for (let i = start; i < end; i++) {
1801
- const code = value.charCodeAt(i);
1868
+ const code = stringCharCodeAt(value, i);
1802
1869
  if (code < min || code > max) return false;
1803
1870
  }
1804
1871
  return true;
@@ -1816,21 +1883,21 @@ function pseudoRegion(value) {
1816
1883
  return value === "XA" || value === "XB" || value === "XC";
1817
1884
  }
1818
1885
  function prefix(tag) {
1819
- let end = tag.indexOf("-");
1886
+ let end = stringIndexOf(tag, "-");
1820
1887
  if (end < 0) end = tag.length;
1821
- const language = tag.slice(0, end);
1888
+ const language = stringSlice(tag, 0, end);
1822
1889
  let script = "";
1823
1890
  let region = "";
1824
1891
  if (end < tag.length) {
1825
- let next = tag.indexOf("-", end + 1);
1892
+ let next = stringIndexOf(tag, "-", end + 1);
1826
1893
  if (next < 0) next = tag.length;
1827
- let part = tag.slice(end + 1, next);
1894
+ let part = stringSlice(tag, end + 1, next);
1828
1895
  if (scriptSubtag(part)) {
1829
1896
  script = part;
1830
1897
  end = next;
1831
- next = tag.indexOf("-", end + 1);
1898
+ next = stringIndexOf(tag, "-", end + 1);
1832
1899
  if (next < 0) next = tag.length;
1833
- part = tag.slice(end + 1, next);
1900
+ part = stringSlice(tag, end + 1, next);
1834
1901
  }
1835
1902
  if (regionSubtag(part)) {
1836
1903
  region = part;
@@ -1848,9 +1915,16 @@ function fields(tag) {
1848
1915
  const parsed = prefix(tag);
1849
1916
  const language = parsed.language;
1850
1917
  let { script, region } = parsed;
1851
- const parts = parsed.end < tag.length ? tag.slice(parsed.end + 1).split("-") : [];
1852
- const extension = parts.findIndex((part) => part.length === 1);
1853
- const pseudo = (extension < 0 ? parts : parts.slice(0, extension)).find((p) => p === "psaccent" || p === "psbidi" || p === "pscrack");
1918
+ const parts = parsed.end < tag.length ? splitLocaleSubtags(stringSlice(tag, parsed.end + 1)) : [];
1919
+ let pseudo;
1920
+ for (let index = 0; index < parts.length; index++) {
1921
+ const part = parts[index];
1922
+ if (part.length === 1) break;
1923
+ if (part === "psaccent" || part === "psbidi" || part === "pscrack") {
1924
+ pseudo = part;
1925
+ break;
1926
+ }
1927
+ }
1854
1928
  if (!pseudo && !pseudoRegion(region)) {
1855
1929
  if (script === "Zzzz") script = "";
1856
1930
  if (region === "ZZ") region = "";
@@ -1862,18 +1936,72 @@ function fields(tag) {
1862
1936
  region,
1863
1937
  flags,
1864
1938
  pseudo,
1865
- key: tag === "und" || tag.startsWith("und-x-") ? tag : `${language}|${script}|${region}|${flags}|${pseudo || ""}`
1939
+ key: tag === "und" || stringIndexOf(tag, "und-x-") === 0 ? tag : `${language}|${script}|${region}|${flags}|${pseudo || ""}`
1866
1940
  };
1867
1941
  }
1868
1942
  const stringKey = (value) => value;
1869
1943
  const canonicalize = memoize((tag) => {
1870
1944
  const basic = prefix(tag);
1871
- if (basic.end === tag.length && languageSubtag(basic.language) && !languageAliases.has(basic.language) && !scriptAliases.has(basic.script) && !regionAliases.has(basic.region)) return tag;
1872
- return Intl.getCanonicalLocales(tag)[0];
1945
+ if (basic.end === tag.length && languageSubtag(basic.language) && !hasLocaleSet(languageAliases, basic.language) && !hasLocaleSet(scriptAliases, basic.script) && !hasLocaleSet(regionAliases, basic.region)) return tag;
1946
+ return CanonicalizeLocaleList(tag)[0];
1873
1947
  }, { serializer: stringKey });
1948
+ const localeDescriptor = Object.getOwnPropertyDescriptor;
1949
+ const localePrototype = Object.getPrototypeOf;
1950
+ const LocaleTypeError = TypeError;
1951
+ const localeOperations = /* @__PURE__ */ new WeakMap();
1952
+ const getLocaleOperations = localeOperations.get.bind(localeOperations);
1953
+ const setLocaleOperations = localeOperations.set.bind(localeOperations);
1954
+ let localeIntl = globalThis.Intl;
1955
+ let localeConstructor;
1956
+ function localeDescriptorMember(object, key, member = "value") {
1957
+ const descriptor = localeDescriptor(object, key);
1958
+ return descriptor && localeDescriptor(descriptor, member)?.value;
1959
+ }
1960
+ function localeFieldReader(prototype, key) {
1961
+ const reader = localeDescriptorMember(prototype, key, "get");
1962
+ return typeof reader === "function" ? reader : void 0;
1963
+ }
1964
+ function captureLocaleOperations(prototype) {
1965
+ if (prototype === null) return void 0;
1966
+ const cached = getLocaleOperations(prototype);
1967
+ if (cached) return cached;
1968
+ const inherited = captureLocaleOperations(localePrototype(prototype));
1969
+ const ownMaximize = localeDescriptorMember(prototype, "maximize");
1970
+ const operations = {
1971
+ maximize: typeof ownMaximize === "function" ? ownMaximize : inherited?.maximize,
1972
+ language: localeFieldReader(prototype, "language") ?? inherited?.language,
1973
+ script: localeFieldReader(prototype, "script") ?? inherited?.script,
1974
+ region: localeFieldReader(prototype, "region") ?? inherited?.region
1975
+ };
1976
+ setLocaleOperations(prototype, operations);
1977
+ return operations;
1978
+ }
1979
+ function getLocaleConstructor() {
1980
+ if (localeIntl === void 0) localeIntl = globalThis.Intl;
1981
+ const installed = localeIntl && localeDescriptorMember(localeIntl, "Locale");
1982
+ if (typeof installed === "function" && installed !== localeConstructor) {
1983
+ const prototype = localeDescriptorMember(installed, "prototype");
1984
+ if (typeof prototype === "object" && prototype !== null || typeof prototype === "function") captureLocaleOperations(prototype);
1985
+ localeConstructor = installed;
1986
+ }
1987
+ return localeConstructor;
1988
+ }
1989
+ getLocaleConstructor();
1990
+ function maximizeLocale(tag) {
1991
+ const Constructor = getLocaleConstructor();
1992
+ if (!Constructor) throw new LocaleTypeError("Intl.Locale provider is unavailable");
1993
+ const locale = new Constructor(tag);
1994
+ const maximize = captureLocaleOperations(localePrototype(locale))?.maximize;
1995
+ if (!maximize) throw new LocaleTypeError("Intl.Locale maximize is unavailable");
1996
+ return apply(maximize, locale, []);
1997
+ }
1998
+ function readLocaleField(locale, key) {
1999
+ const reader = captureLocaleOperations(localePrototype(locale))?.[key];
2000
+ return reader && apply(reader, locale, []);
2001
+ }
1874
2002
  const maximal = memoize((tag) => {
1875
2003
  const input = fields(tag);
1876
- if (tag === "und" || tag.startsWith("und-x-")) return {
2004
+ if (tag === "und" || stringIndexOf(tag, "und-x-") === 0) return {
1877
2005
  ...input,
1878
2006
  language: tag,
1879
2007
  script: "",
@@ -1896,24 +2024,20 @@ const maximal = memoize((tag) => {
1896
2024
  key: `${language}|${script}|${region}|${flags}`
1897
2025
  };
1898
2026
  }
1899
- const locale = new Intl.Locale(tag).maximize();
2027
+ const locale = maximizeLocale(tag);
1900
2028
  let flags = input.flags;
1901
- if (matchingData.macroRegions.includes(input.region)) {
1902
- const regionLocale = new Intl.Locale(`und-${input.region}`).maximize();
1903
- if (input.language === "und" && (!input.script || input.script === regionLocale.script) || !input.script && !new Intl.Locale(input.language).maximize().script) flags &= -2;
2029
+ if (arrayIncludes(matchingData.macroRegions, input.region)) {
2030
+ const regionLocale = maximizeLocale(`und-${input.region}`);
2031
+ if (input.language === "und" && (!input.script || input.script === readLocaleField(regionLocale, "script")) || !input.script && !readLocaleField(maximizeLocale(input.language), "script")) flags &= -2;
1904
2032
  }
1905
- let language = locale.language;
1906
- let script = locale.script || "";
1907
- let region = locale.region || "";
2033
+ let language = readLocaleField(locale, "language");
2034
+ let script = readLocaleField(locale, "script") || "";
2035
+ let region = readLocaleField(locale, "region") || "";
1908
2036
  if (language === "und" || !script || !region) {
1909
- const fallback = new Intl.Locale([
1910
- "und",
1911
- script,
1912
- region
1913
- ].filter(Boolean).join("-")).maximize();
1914
- if (language === "und") language = fallback.language === "und" ? "en" : fallback.language;
1915
- script ||= fallback.script || "Latn";
1916
- region ||= fallback.region || "US";
2037
+ const fallback = maximizeLocale("und" + (script ? "-" + script : "") + (region ? "-" + region : ""));
2038
+ if (language === "und") language = readLocaleField(fallback, "language") === "und" ? "en" : readLocaleField(fallback, "language");
2039
+ script ||= readLocaleField(fallback, "script") || "Latn";
2040
+ region ||= readLocaleField(fallback, "region") || "US";
1917
2041
  }
1918
2042
  return {
1919
2043
  language,
@@ -1925,33 +2049,38 @@ const maximal = memoize((tag) => {
1925
2049
  }, { serializer: stringKey });
1926
2050
  function rawKey(tag) {
1927
2051
  if (tag === "und") return "@und";
1928
- if (tag.startsWith("und-x-")) return tag;
2052
+ if (stringIndexOf(tag, "und-x-") === 0) return tag;
1929
2053
  const parsed = prefix(tag);
1930
- const base = tag.slice(0, parsed.end);
2054
+ const base = stringSlice(tag, 0, parsed.end);
1931
2055
  if (pseudoRegion(parsed.region)) return base;
1932
- if (tag.includes("-ps")) {
2056
+ if (stringIndexOf(tag, "-ps") !== -1) {
1933
2057
  const input = fields(tag);
1934
2058
  if (input.pseudo) return input.key;
1935
2059
  }
1936
2060
  if (parsed.script !== "Zzzz" && parsed.region !== "ZZ") return base;
1937
- return [
1938
- parsed.language,
1939
- parsed.script === "Zzzz" ? "" : parsed.script,
1940
- parsed.region === "ZZ" ? "" : parsed.region
1941
- ].filter(Boolean).join("-");
2061
+ const script = parsed.script === "Zzzz" ? "" : parsed.script;
2062
+ const region = parsed.region === "ZZ" ? "" : parsed.region;
2063
+ return parsed.language + (script ? "-" + script : "") + (region ? "-" + region : "");
2064
+ }
2065
+ const hasOwnMatchingKey = Function.prototype.call.bind(Object.prototype.hasOwnProperty);
2066
+ function matchingValue(table, key) {
2067
+ return hasOwnMatchingKey(table, key) ? table[key] : void 0;
1942
2068
  }
1943
2069
  function distance(desired, supported) {
1944
2070
  const languages = `${desired.language}|${supported.language}`;
1945
- let result = desired.language === supported.language ? 0 : matchingData.language[languages] ?? matchingData.defaults[0];
1946
- if (desired.script !== supported.script) result += matchingData.script[`${languages}|${desired.script}|${supported.script}`] ?? matchingData.defaults[1];
2071
+ let result = desired.language === supported.language ? 0 : matchingValue(matchingData.language, languages) ?? matchingData.defaults[0];
2072
+ if (desired.script !== supported.script) result += matchingValue(matchingData.script, `${languages}|${desired.script}|${supported.script}`) ?? matchingData.defaults[1];
1947
2073
  if (desired.region !== supported.region) {
1948
- const matrix = matchingData.region[`${languages}|${desired.script}|${supported.script}`] ?? matchingData.region[`${languages}|*|*`];
1949
- const desiredPartitions = matchingData.regions[desired.region];
1950
- const supportedPartitions = matchingData.regions[supported.region];
2074
+ const matrix = matchingValue(matchingData.region, `${languages}|${desired.script}|${supported.script}`) ?? matchingValue(matchingData.region, `${languages}|*|*`);
2075
+ const desiredPartitions = matchingValue(matchingData.regions, desired.region);
2076
+ const supportedPartitions = matchingValue(matchingData.regions, supported.region);
1951
2077
  let regionDistance = matchingData.defaults[2];
1952
2078
  if (matrix && desiredPartitions && supportedPartitions) {
1953
2079
  regionDistance = 0;
1954
- for (const d of desiredPartitions) for (const s of supportedPartitions) regionDistance = Math.max(regionDistance, matrix[d * matchingData.partitionCount + s]);
2080
+ for (let i = 0; i < desiredPartitions.length; i++) {
2081
+ const row = desiredPartitions[i] * matchingData.partitionCount;
2082
+ for (let j = 0; j < supportedPartitions.length; j++) regionDistance = maxDistance(regionDistance, matrix[row + supportedPartitions[j]]);
2083
+ }
1955
2084
  }
1956
2085
  result += regionDistance;
1957
2086
  }
@@ -1960,66 +2089,83 @@ function distance(desired, supported) {
1960
2089
  /** ICU language/script/region distance, including fractional explicit-subtag ties. */
1961
2090
  const findMatchingDistance = memoize((desired, supported) => distance(maximal(canonicalize(desired)), maximal(canonicalize(supported))), { serializer: (args) => `${args[0]}|${args[1]}` });
1962
2091
  const supportedCache = /* @__PURE__ */ new WeakMap();
2092
+ const getSupported = supportedCache.get.bind(supportedCache);
2093
+ const setSupported = supportedCache.set.bind(supportedCache);
1963
2094
  const immutableLocaleLists = /* @__PURE__ */ new WeakSet();
2095
+ const markLocaleListImmutable = immutableLocaleLists.add.bind(immutableLocaleLists);
2096
+ const isLocaleListImmutable = immutableLocaleLists.has.bind(immutableLocaleLists);
1964
2097
  let paradigms;
1965
2098
  function createLocaleListSnapshot(locales) {
1966
- const snapshot = Object.freeze(Array.from(locales));
1967
- immutableLocaleLists.add(snapshot);
2099
+ const snapshot = [];
2100
+ for (let index = 0; index < locales.length; index++) setDataProperty(snapshot, `${index}`, locales[index]);
2101
+ markLocaleListImmutable(freezeLocaleList(snapshot));
1968
2102
  return snapshot;
1969
2103
  }
1970
2104
  function equivalentKey(lsr) {
1971
2105
  return `${lsr.language}|${lsr.script}|${lsr.region}`;
1972
2106
  }
1973
2107
  function prepare(locales) {
1974
- const immutable = immutableLocaleLists.has(locales);
1975
- let result = supportedCache.get(locales);
1976
- if (result && !immutable && (result.original.length !== locales.length || result.original.some((tag, index) => tag !== locales[index]))) result = void 0;
2108
+ const immutable = isLocaleListImmutable(locales);
2109
+ let result = getSupported(locales);
2110
+ if (result && !immutable && (result.original.length !== locales.length || apply(some, result.original, [(tag, index) => tag !== locales[index]]))) result = void 0;
1977
2111
  if (!result) {
1978
2112
  result = {
2113
+ __proto__: null,
1979
2114
  original: immutable ? locales : Array.from(locales),
1980
2115
  tags: [],
1981
- raw: /* @__PURE__ */ new Map(),
1982
- orders: /* @__PURE__ */ new Map(),
1983
- best: /* @__PURE__ */ new Map()
2116
+ raw: new LocaleMap(),
2117
+ orders: new LocaleMap(),
2118
+ best: new LocaleMap()
1984
2119
  };
1985
- supportedCache.set(locales, result);
2120
+ setSupported(locales, result);
1986
2121
  }
1987
2122
  return result;
1988
2123
  }
2124
+ const getLocaleMap = Function.prototype.call.bind(LocaleMap.prototype.get);
2125
+ const hasLocaleMap = Function.prototype.call.bind(LocaleMap.prototype.has);
2126
+ const setLocaleMap = Function.prototype.call.bind(LocaleMap.prototype.set);
2127
+ const localeMapSize = Object.getOwnPropertyDescriptor(LocaleMap.prototype, "size").get;
2128
+ const clearLocaleMap = LocaleMap.prototype.clear;
1989
2129
  function rawMatch(data, key) {
1990
- const cached = data.raw.get(key);
2130
+ const cached = getLocaleMap(data.raw, key);
1991
2131
  if (cached !== void 0) return cached;
1992
2132
  for (let index = data.tags.length; index < data.original.length; index++) {
1993
2133
  const tag = canonicalize(data.original[index]);
1994
- Object.defineProperty(data.tags, index, {
1995
- value: tag,
1996
- writable: true,
1997
- enumerable: true,
1998
- configurable: true
1999
- });
2134
+ setDataProperty(data.tags, `${index}`, tag);
2000
2135
  const candidate = rawKey(tag);
2001
- if (!data.raw.has(candidate)) data.raw.set(candidate, index);
2002
- if (candidate === key) return data.raw.get(candidate);
2136
+ if (!hasLocaleMap(data.raw, candidate)) setLocaleMap(data.raw, candidate, index);
2137
+ if (candidate === key) return getLocaleMap(data.raw, candidate);
2003
2138
  }
2004
2139
  }
2005
2140
  function order(data, defaultLocale) {
2006
- let result = data.orders.get(defaultLocale);
2141
+ let result = getLocaleMap(data.orders, defaultLocale);
2007
2142
  if (!result) {
2008
2143
  if (!data.maximal) {
2009
- data.maximal = data.tags.map(maximal);
2010
- data.exact = /* @__PURE__ */ new Map();
2011
- data.maximal.forEach((lsr, index) => {
2012
- if (!data.exact.has(lsr.key)) data.exact.set(lsr.key, index);
2013
- });
2144
+ const profiles = [];
2145
+ for (let index = 0; index < data.tags.length; index++) setDataProperty(profiles, `${index}`, maximal(data.tags[index]));
2146
+ data.maximal = profiles;
2147
+ const exact = new LocaleMap();
2148
+ data.exact = exact;
2149
+ for (let index = 0; index < profiles.length; index++) {
2150
+ const { key } = profiles[index];
2151
+ if (!hasLocaleMap(exact, key)) setLocaleMap(exact, key, index);
2152
+ }
2153
+ }
2154
+ if (!paradigms) {
2155
+ const keys = new LocaleSet$1();
2156
+ const tags = matchingData.paradigms;
2157
+ for (let index = 0; index < tags.length; index++) addLocaleSet(keys, equivalentKey(maximal(canonicalize(tags[index]))));
2158
+ paradigms = keys;
2014
2159
  }
2015
- paradigms ??= new Set(matchingData.paradigms.map((tag) => equivalentKey(maximal(canonicalize(tag)))));
2016
2160
  const defaultKey = defaultLocale ? equivalentKey(maximal(canonicalize(defaultLocale))) : "";
2017
2161
  const rank = (index) => {
2018
2162
  const key = equivalentKey(data.maximal[index]);
2019
- return key === defaultKey ? 0 : paradigms.has(key) ? 1 : 2;
2163
+ return key === defaultKey ? 0 : hasLocaleSet(paradigms, key) ? 1 : 2;
2020
2164
  };
2021
- result = data.tags.map((_, i) => i).sort((a, b) => rank(a) - rank(b));
2022
- data.orders.set(defaultLocale, result);
2165
+ result = [];
2166
+ for (let index = 0; index < data.tags.length; index++) setDataProperty(result, `${index}`, index);
2167
+ apply(sortLocaleIndexes, result, [(a, b) => rank(a) - rank(b)]);
2168
+ setLocaleMap(data.orders, defaultLocale, result);
2023
2169
  }
2024
2170
  return result;
2025
2171
  }
@@ -2032,17 +2178,15 @@ function moreLikely(candidate, previous) {
2032
2178
  function equivalentMatch(desired, data) {
2033
2179
  let best;
2034
2180
  for (let flags = 0; flags < 8; flags++) {
2035
- const key = [
2036
- flags & 4 ? desired.language : "und",
2037
- flags & 2 ? desired.script : "",
2038
- flags & 1 ? desired.region : ""
2039
- ].filter(Boolean).join("-");
2040
- const index = data.raw.get(key);
2181
+ let key = flags & 4 ? desired.language : "und";
2182
+ if (flags & 2 && desired.script) key += "-" + desired.script;
2183
+ if (flags & 1 && desired.region) key += "-" + desired.region;
2184
+ const index = getLocaleMap(data.raw, key);
2041
2185
  if (index === void 0) continue;
2042
2186
  const supported = maximal(data.tags[index]);
2043
2187
  if (equivalentKey(desired) !== equivalentKey(supported)) continue;
2044
2188
  const d = distance(desired, supported);
2045
- if (d < Math.min(1, MIN_LSR_DISTANCE) && (!best || d < best.distance || d === best.distance && index < best.index)) best = {
2189
+ if (d < minDistance(1, MIN_LSR_DISTANCE) && (!best || d < best.distance || d === best.distance && index < best.index)) best = {
2046
2190
  index,
2047
2191
  distance: d
2048
2192
  };
@@ -2051,7 +2195,10 @@ function equivalentMatch(desired, data) {
2051
2195
  }
2052
2196
  /** Cached exact LSR lookup, then ICU distance matching. Threshold is exclusive. */
2053
2197
  function findBestMatch(requestedLocales, supportedLocales, threshold = DEFAULT_MATCHING_THRESHOLD, defaultLocale = supportedLocales[0] || "", collectDistances = true) {
2054
- const result = { distances: {} };
2198
+ const result = {
2199
+ __proto__: null,
2200
+ distances: {}
2201
+ };
2055
2202
  if (!supportedLocales.length || !requestedLocales.length || threshold <= 0) return result;
2056
2203
  const data = prepare(supportedLocales);
2057
2204
  const demotion = matchingData.demotion;
@@ -2069,9 +2216,9 @@ function findBestMatch(requestedLocales, supportedLocales, threshold = DEFAULT_M
2069
2216
  const desired = maximal(canonical);
2070
2217
  const cacheKey = `${canonical}|${defaultLocale}`;
2071
2218
  if (!collectDistances) {
2072
- const equivalent = data.best.get(cacheKey) || equivalentMatch(desired, data);
2073
- if (equivalent && equivalent.distance < Math.min(1, MIN_LSR_DISTANCE)) {
2074
- data.best.set(cacheKey, equivalent);
2219
+ const equivalent = getLocaleMap(data.best, cacheKey) || equivalentMatch(desired, data);
2220
+ if (equivalent && equivalent.distance < minDistance(1, MIN_LSR_DISTANCE)) {
2221
+ setLocaleMap(data.best, cacheKey, equivalent);
2075
2222
  if (equivalent.distance < bestDistance) {
2076
2223
  bestDistance = equivalent.distance;
2077
2224
  result.matchedDesiredLocale = desiredTag;
@@ -2082,21 +2229,22 @@ function findBestMatch(requestedLocales, supportedLocales, threshold = DEFAULT_M
2082
2229
  }
2083
2230
  }
2084
2231
  const indexes = order(data, defaultLocale);
2085
- const exact = data.exact.get(desired.key);
2232
+ const exact = getLocaleMap(data.exact, desired.key);
2086
2233
  if (exact !== void 0) {
2087
2234
  result.matchedDesiredLocale = desiredTag;
2088
2235
  result.matchedSupportedLocale = supportedLocales[exact];
2089
2236
  if (collectDistances) result.distances[desiredTag] = { [supportedLocales[exact]]: i * demotion };
2090
2237
  return result;
2091
2238
  }
2092
- let best = collectDistances ? void 0 : data.best.get(cacheKey);
2239
+ let best = collectDistances ? void 0 : getLocaleMap(data.best, cacheKey);
2093
2240
  if (!best) {
2094
2241
  best = {
2095
2242
  index: -1,
2096
- distance: Infinity
2243
+ distance: 1e400
2097
2244
  };
2098
2245
  const distances = {};
2099
- for (const index of indexes) {
2246
+ for (let candidate = 0; candidate < indexes.length; candidate++) {
2247
+ const index = indexes[candidate];
2100
2248
  const d = collectDistances ? findMatchingDistance(desiredTag, supportedLocales[index]) : distance(desired, data.maximal[index]);
2101
2249
  if (collectDistances) distances[supportedLocales[index]] = d + i * demotion;
2102
2250
  if (d < best.distance || d === best.distance && d >= 1 && best.index >= 0 && moreLikely(data.maximal[index], data.maximal[best.index])) best = {
@@ -2106,8 +2254,8 @@ function findBestMatch(requestedLocales, supportedLocales, threshold = DEFAULT_M
2106
2254
  }
2107
2255
  if (collectDistances) result.distances[desiredTag] = distances;
2108
2256
  else {
2109
- if (data.best.size >= 256) data.best.clear();
2110
- data.best.set(cacheKey, best);
2257
+ if (apply(localeMapSize, data.best, []) >= 256) apply(clearLocaleMap, data.best, []);
2258
+ setLocaleMap(data.best, cacheKey, best);
2111
2259
  }
2112
2260
  }
2113
2261
  if (best.distance < bestDistance) {
@@ -2121,7 +2269,7 @@ function findBestMatch(requestedLocales, supportedLocales, threshold = DEFAULT_M
2121
2269
  }
2122
2270
  // packages/intl-localematcher/abstract/BestFitMatcher.ts
2123
2271
  /**
2124
- * https://tc39.es/ecma402/#sec-bestfitmatcher
2272
+ * https://tc39.es/ecma402/#sec-lookupmatchinglocalebybestfit
2125
2273
  * @param availableLocales
2126
2274
  * @param requestedLocales
2127
2275
  * @param getDefaultLocale
@@ -2129,19 +2277,24 @@ function findBestMatch(requestedLocales, supportedLocales, threshold = DEFAULT_M
2129
2277
  function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
2130
2278
  let foundLocale;
2131
2279
  let extension;
2132
- const noExtensionLocaleMap = Object.create(null);
2133
- const noExtensionLocales = requestedLocales.map((l) => {
2134
- const { locale: noExtensionLocale } = splitUnicodeExtension(l);
2135
- noExtensionLocaleMap[noExtensionLocale] ??= l;
2136
- return noExtensionLocale;
2137
- });
2280
+ const noExtensionLocaleMap = { __proto__: null };
2281
+ const noExtensionLocales = [];
2282
+ for (let index = 0; index < requestedLocales.length; index++) {
2283
+ const locale = requestedLocales[index];
2284
+ const { locale: noExtensionLocale } = splitUnicodeExtension(locale);
2285
+ noExtensionLocaleMap[noExtensionLocale] ??= locale;
2286
+ setDataProperty(noExtensionLocales, `${index}`, noExtensionLocale);
2287
+ }
2138
2288
  const defaultLocale = getDefaultLocale();
2139
2289
  const result = findBestMatch(noExtensionLocales, availableLocales, void 0, defaultLocale, false);
2140
2290
  if (result.matchedSupportedLocale && result.matchedDesiredLocale) {
2141
2291
  foundLocale = result.matchedSupportedLocale;
2142
2292
  extension = splitUnicodeExtension(noExtensionLocaleMap[result.matchedDesiredLocale]).extension;
2143
2293
  }
2144
- if (!foundLocale) return { locale: defaultLocale };
2294
+ if (!foundLocale) return {
2295
+ locale: defaultLocale,
2296
+ extension: void 0
2297
+ };
2145
2298
  return {
2146
2299
  locale: foundLocale,
2147
2300
  extension
@@ -2373,75 +2526,87 @@ const extensionAlias = {
2373
2526
  }
2374
2527
  };
2375
2528
  // packages/intl-localematcher/abstract/CanonicalizeUValue.ts
2529
+ const hasOwn = Function.prototype.call.bind(Object.prototype.hasOwnProperty);
2530
+ const fromCharCode = String.fromCharCode;
2376
2531
  function CanonicalizeUValue(ukey, uvalue) {
2377
2532
  invariant(ukey !== void 0, `ukey must be defined`);
2378
2533
  let canonicalized = "";
2379
2534
  for (let i = 0; i < uvalue.length; i++) {
2380
- const code = uvalue.charCodeAt(i);
2381
- canonicalized += code >= 65 && code <= 90 ? String.fromCharCode(code + 32) : uvalue[i];
2535
+ const code = stringCharCodeAt(uvalue, i);
2536
+ canonicalized += code >= 65 && code <= 90 ? fromCharCode(code + 32) : uvalue[i];
2382
2537
  }
2383
- const aliases = Object.prototype.hasOwnProperty.call(extensionAlias.u, ukey) ? extensionAlias.u[ukey] : void 0;
2384
- if (aliases && Object.prototype.hasOwnProperty.call(aliases, canonicalized)) canonicalized = aliases[canonicalized];
2385
- if ((ukey === "rg" || ukey === "sd") && Object.prototype.hasOwnProperty.call(subdivisionAlias, canonicalized)) canonicalized = subdivisionAlias[canonicalized];
2538
+ const aliases = hasOwn(extensionAlias.u, ukey) ? extensionAlias.u[ukey] : void 0;
2539
+ if (aliases && hasOwn(aliases, canonicalized)) canonicalized = aliases[canonicalized];
2540
+ if ((ukey === "rg" || ukey === "sd") && hasOwn(subdivisionAlias, canonicalized)) canonicalized = subdivisionAlias[canonicalized];
2386
2541
  return canonicalized === "true" ? "" : canonicalized;
2387
2542
  }
2388
2543
  // packages/intl-localematcher/abstract/CanonicalizeUnicodeLocaleId.ts
2389
2544
  function CanonicalizeUnicodeLocaleId(locale) {
2390
- return Intl.getCanonicalLocales(locale)[0];
2545
+ return CanonicalizeLocaleList(locale)[0];
2391
2546
  }
2392
2547
  // packages/intl-localematcher/abstract/InsertUnicodeExtensionAndCanonicalize.ts
2393
2548
  function InsertUnicodeExtensionAndCanonicalize(locale, attributes, keywords) {
2394
2549
  invariant(splitUnicodeExtension(locale).extension === void 0, "Expected locale to not have a Unicode locale extension");
2395
2550
  let extension = "-u";
2396
- for (const attr of attributes) extension += `-${attr}`;
2397
- for (const kw of keywords) {
2398
- const { key, value } = kw;
2551
+ for (let i = 0; i < attributes.length; i++) extension += `-${attributes[i]}`;
2552
+ for (let i = 0; i < keywords.length; i++) {
2553
+ const { key, value } = keywords[i];
2399
2554
  extension += `-${key}`;
2400
2555
  if (value !== "") extension += `-${value}`;
2401
2556
  }
2402
2557
  if (extension === "-u") return CanonicalizeUnicodeLocaleId(locale);
2403
- let privateIndex = locale.indexOf("-x-");
2558
+ let privateIndex = stringIndexOf(locale, "-x-");
2404
2559
  let newLocale;
2405
2560
  if (privateIndex === -1) newLocale = locale + extension;
2406
2561
  else {
2407
- let preExtension = locale.slice(0, privateIndex);
2408
- let postExtension = locale.slice(privateIndex);
2562
+ let preExtension = stringSlice(locale, 0, privateIndex);
2563
+ let postExtension = stringSlice(locale, privateIndex);
2409
2564
  newLocale = preExtension + extension + postExtension;
2410
2565
  }
2411
2566
  return CanonicalizeUnicodeLocaleId(newLocale);
2412
2567
  }
2413
2568
  // packages/intl-localematcher/abstract/BestAvailableLocale.ts
2569
+ const LocaleSet = Set;
2570
+ const setAdd = Function.prototype.call.bind(Set.prototype.add);
2571
+ const setHas = Function.prototype.call.bind(Set.prototype.has);
2414
2572
  const availableLocalesSetCache = /* @__PURE__ */ new WeakMap();
2573
+ const getAvailableLocales = availableLocalesSetCache.get.bind(availableLocalesSetCache);
2574
+ const setAvailableLocales = availableLocalesSetCache.set.bind(availableLocalesSetCache);
2415
2575
  /**
2416
- * https://tc39.es/ecma402/#sec-bestavailablelocale
2576
+ * https://tc39.es/ecma402/#sec-lookupmatchinglocalebyprefix
2417
2577
  * @param availableLocales
2418
2578
  * @param locale
2419
2579
  */
2420
2580
  function BestAvailableLocale(availableLocales, locale) {
2421
- let availableSet = availableLocalesSetCache.get(availableLocales);
2581
+ let availableSet = getAvailableLocales(availableLocales);
2422
2582
  if (!availableSet) {
2423
- availableSet = new Set(availableLocales);
2424
- availableLocalesSetCache.set(availableLocales, availableSet);
2583
+ availableSet = new LocaleSet();
2584
+ for (let i = 0; i < availableLocales.length; i++) setAdd(availableSet, availableLocales[i]);
2585
+ setAvailableLocales(availableLocales, availableSet);
2425
2586
  }
2426
2587
  let candidate = locale;
2427
2588
  while (true) {
2428
- if (availableSet.has(candidate)) return candidate;
2429
- let pos = candidate.lastIndexOf("-");
2589
+ if (setHas(availableSet, candidate)) return candidate;
2590
+ let pos = stringLastIndexOf(candidate, "-");
2430
2591
  if (!~pos) return;
2431
2592
  if (pos >= 2 && candidate[pos - 2] === "-") pos -= 2;
2432
- candidate = candidate.slice(0, pos);
2593
+ candidate = stringSlice(candidate, 0, pos);
2433
2594
  }
2434
2595
  }
2435
2596
  // packages/intl-localematcher/abstract/LookupMatcher.ts
2436
2597
  /**
2437
- * https://tc39.es/ecma402/#sec-lookupmatcher
2598
+ * https://tc39.es/ecma402/#sec-lookupmatchinglocalebyprefix
2438
2599
  * @param availableLocales
2439
2600
  * @param requestedLocales
2440
2601
  * @param getDefaultLocale
2441
2602
  */
2442
2603
  function LookupMatcher(availableLocales, requestedLocales, getDefaultLocale) {
2443
- const result = { locale: "" };
2444
- for (const locale of requestedLocales) {
2604
+ const result = {
2605
+ locale: "",
2606
+ extension: void 0
2607
+ };
2608
+ for (let i = 0; i < requestedLocales.length; i++) {
2609
+ const locale = requestedLocales[i];
2445
2610
  const { locale: noExtensionLocale, extension } = splitUnicodeExtension(locale);
2446
2611
  const availableLocale = BestAvailableLocale(availableLocales, noExtensionLocale);
2447
2612
  if (availableLocale) {
@@ -2455,28 +2620,28 @@ function LookupMatcher(availableLocales, requestedLocales, getDefaultLocale) {
2455
2620
  }
2456
2621
  // packages/intl-localematcher/abstract/UnicodeExtensionComponents.ts
2457
2622
  function UnicodeExtensionComponents(extension) {
2458
- invariant(extension === extension.toLowerCase(), "Expected extension to be lowercase");
2459
- invariant(extension.slice(0, 3) === "-u-", "Expected extension to be a Unicode locale extension");
2623
+ invariant(extension === stringLowerCase(extension), "Expected extension to be lowercase");
2624
+ invariant(stringSlice(extension, 0, 3) === "-u-", "Expected extension to be a Unicode locale extension");
2460
2625
  const attributes = [];
2461
2626
  const keywords = [];
2462
2627
  let keyword;
2463
2628
  let size = extension.length;
2464
2629
  let k = 3;
2465
2630
  while (k < size) {
2466
- let e = extension.indexOf("-", k);
2631
+ let e = stringIndexOf(extension, "-", k);
2467
2632
  let len;
2468
2633
  if (e === -1) len = size - k;
2469
2634
  else len = e - k;
2470
- let subtag = extension.slice(k, k + len);
2635
+ let subtag = stringSlice(extension, k, k + len);
2471
2636
  invariant(len >= 2, "Expected a subtag to have at least 2 characters");
2472
2637
  if (keyword === void 0 && len != 2) {
2473
- if (attributes.indexOf(subtag) === -1) attributes.push(subtag);
2638
+ if (arrayIndexOf(attributes, subtag) === -1) setDataProperty(attributes, `${attributes.length}`, subtag);
2474
2639
  } else if (len === 2) {
2475
2640
  keyword = {
2476
2641
  key: subtag,
2477
2642
  value: ""
2478
2643
  };
2479
- if (keywords.find((k) => k.key === keyword?.key) === void 0) keywords.push(keyword);
2644
+ if (arrayFind(keywords, (k) => k.key === keyword?.key) === void 0) setDataProperty(keywords, `${keywords.length}`, keyword);
2480
2645
  } else if (keyword?.value === "") keyword.value = subtag;
2481
2646
  else {
2482
2647
  invariant(keyword !== void 0, "Expected keyword to be defined");
@@ -2491,25 +2656,45 @@ function UnicodeExtensionComponents(extension) {
2491
2656
  }
2492
2657
  // packages/intl-localematcher/abstract/ResolveLocale.ts
2493
2658
  const availableLocaleArrays = /* @__PURE__ */ new WeakMap();
2659
+ const getLocaleArray = availableLocaleArrays.get.bind(availableLocaleArrays);
2660
+ const setLocaleArray = availableLocaleArrays.set.bind(availableLocaleArrays);
2661
+ const localeApply = Reflect.apply;
2662
+ const localeIsArray = Array.isArray;
2663
+ const localeSetValues = Set.prototype.values;
2664
+ const localeSetSize = Object.getOwnPropertyDescriptor(Set.prototype, "size").get;
2665
+ const localeSetNext = Object.getPrototypeOf((/* @__PURE__ */ new Set()).values()).next;
2666
+ const localeLowerCase = String.prototype.toLowerCase;
2494
2667
  function localeArray(locales, bestFit) {
2495
- if (Array.isArray(locales)) return locales;
2668
+ if (localeIsArray(locales)) return locales;
2496
2669
  const available = locales;
2497
- let cached = availableLocaleArrays.get(available);
2498
- if (cached?.original.length !== available.size) cached = void 0;
2670
+ let cached = getLocaleArray(available);
2671
+ if (cached?.original.length !== localeApply(localeSetSize, available, [])) cached = void 0;
2499
2672
  if (cached) {
2500
2673
  const original = cached.original;
2501
2674
  let index = 0;
2502
- for (const locale of available) if (original[index++] !== locale) {
2503
- cached = void 0;
2504
- break;
2675
+ const iterator = localeApply(localeSetValues, available, []);
2676
+ for (;;) {
2677
+ const next = localeApply(localeSetNext, iterator, []);
2678
+ if (next.done) break;
2679
+ if (original[index++] !== next.value) {
2680
+ cached = void 0;
2681
+ break;
2682
+ }
2505
2683
  }
2506
2684
  }
2507
2685
  if (!cached) {
2686
+ const original = [];
2687
+ const iterator = localeApply(localeSetValues, available, []);
2688
+ for (;;) {
2689
+ const next = localeApply(localeSetNext, iterator, []);
2690
+ if (next.done) break;
2691
+ setDataProperty(original, `${original.length}`, next.value);
2692
+ }
2508
2693
  cached = {
2509
- original: Array.from(available),
2694
+ original,
2510
2695
  snapshot: void 0
2511
2696
  };
2512
- availableLocaleArrays.set(available, cached);
2697
+ setLocaleArray(available, cached);
2513
2698
  }
2514
2699
  if (!bestFit) return cached.original;
2515
2700
  return cached.snapshot ??= createLocaleListSnapshot(cached.original);
@@ -2528,7 +2713,7 @@ function ResolveLocale(availableLocales, requestedLocales, options, relevantExte
2528
2713
  };
2529
2714
  let foundLocale = r.locale;
2530
2715
  let foundLocaleData = localeData[foundLocale];
2531
- const result = Object.create(null);
2716
+ const result = { __proto__: null };
2532
2717
  result.locale = "en";
2533
2718
  result.dataLocale = foundLocale;
2534
2719
  let components;
@@ -2538,24 +2723,25 @@ function ResolveLocale(availableLocales, requestedLocales, options, relevantExte
2538
2723
  keywords = components.keywords;
2539
2724
  } else keywords = [];
2540
2725
  let supportedKeywords = [];
2541
- for (const key of relevantExtensionKeys) {
2726
+ for (let keyIndex = 0; keyIndex < relevantExtensionKeys.length; keyIndex++) {
2727
+ const key = relevantExtensionKeys[keyIndex];
2542
2728
  let keyLocaleData = foundLocaleData?.[key] ?? [];
2543
- invariant(Array.isArray(keyLocaleData), `keyLocaleData for ${key} must be an array`);
2729
+ invariant(localeIsArray(keyLocaleData), `keyLocaleData for ${key} must be an array`);
2544
2730
  let value = keyLocaleData[0];
2545
2731
  invariant(value == null || typeof value === "string", `value must be a string, null, or undefined`);
2546
2732
  let supportedKeyword;
2547
- let entry = keywords.find((k) => k.key === key);
2733
+ let entry = arrayFind(keywords, (k) => k.key === key);
2548
2734
  if (entry) {
2549
2735
  let requestedValue = entry.value;
2550
2736
  if (requestedValue !== "") {
2551
- if (keyLocaleData.indexOf(requestedValue) > -1) {
2737
+ if (arrayIndexOf(keyLocaleData, requestedValue) > -1) {
2552
2738
  value = requestedValue;
2553
2739
  supportedKeyword = {
2554
2740
  key,
2555
2741
  value
2556
2742
  };
2557
2743
  }
2558
- } else if (keyLocaleData.indexOf("true") > -1) {
2744
+ } else if (arrayIndexOf(keyLocaleData, "true") > -1) {
2559
2745
  value = "true";
2560
2746
  supportedKeyword = {
2561
2747
  key,
@@ -2566,14 +2752,14 @@ function ResolveLocale(availableLocales, requestedLocales, options, relevantExte
2566
2752
  let optionsValue = options[key];
2567
2753
  invariant(optionsValue == null || typeof optionsValue === "string", `optionsValue must be a string or undefined`);
2568
2754
  if (typeof optionsValue === "string") {
2569
- optionsValue = CanonicalizeUValue(key.toLowerCase(), optionsValue);
2755
+ optionsValue = CanonicalizeUValue(localeApply(localeLowerCase, key, []), optionsValue);
2570
2756
  if (optionsValue === "") optionsValue = "true";
2571
2757
  }
2572
- if (optionsValue !== void 0 && optionsValue !== value && keyLocaleData.indexOf(optionsValue) > -1) {
2758
+ if (optionsValue !== void 0 && optionsValue !== value && arrayIndexOf(keyLocaleData, optionsValue) > -1) {
2573
2759
  value = optionsValue;
2574
2760
  supportedKeyword = void 0;
2575
2761
  }
2576
- if (supportedKeyword) supportedKeywords.push(supportedKeyword);
2762
+ if (supportedKeyword) setDataProperty(supportedKeywords, `${supportedKeywords.length}`, supportedKeyword);
2577
2763
  result[key] = value;
2578
2764
  }
2579
2765
  let supportedAttributes = [];