@formatjs/intl-getcanonicallocales 3.4.1 → 3.4.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.d.ts +3 -1
- package/index.js +361 -276
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/polyfill-force.js +435 -305
- package/polyfill-force.js.map +1 -1
- package/polyfill.iife.js +436 -306
- package/polyfill.js +436 -306
- package/polyfill.js.map +1 -1
- package/should-polyfill.js +1 -1
- package/should-polyfill.js.map +1 -1
package/polyfill-force.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// packages/ecma262-abstract/IsObject.js
|
|
2
|
-
/** Includes browser host objects such as document.all. */
|
|
3
2
|
function IsObject(value) {
|
|
4
3
|
return value !== null && (typeof value === "object" || typeof value === "function" || typeof value === "undefined" && value !== void 0);
|
|
5
4
|
}
|
|
@@ -12,6 +11,7 @@ Number.isInteger;
|
|
|
12
11
|
Number.isFinite;
|
|
13
12
|
Number.isSafeInteger;
|
|
14
13
|
const TypeErrorConstructor$1 = TypeError;
|
|
14
|
+
const RangeErrorConstructor = RangeError;
|
|
15
15
|
const arrayApply = Reflect.apply;
|
|
16
16
|
const every = Array.prototype.every;
|
|
17
17
|
Array.prototype.some;
|
|
@@ -19,28 +19,55 @@ function arrayEvery(values, predicate) {
|
|
|
19
19
|
return arrayApply(every, values, [predicate]);
|
|
20
20
|
}
|
|
21
21
|
const includes = Array.prototype.includes;
|
|
22
|
-
const indexOf = Array.prototype.indexOf;
|
|
22
|
+
const indexOf$1 = Array.prototype.indexOf;
|
|
23
23
|
function arrayIncludes(values, search) {
|
|
24
24
|
return arrayApply(includes, values, [search]);
|
|
25
25
|
}
|
|
26
26
|
function arrayIndexOf(values, search) {
|
|
27
|
-
return arrayApply(indexOf, values, [search]);
|
|
27
|
+
return arrayApply(indexOf$1, values, [search]);
|
|
28
|
+
}
|
|
29
|
+
const defineProperty$3 = Object.defineProperty;
|
|
30
|
+
function setDataProperty(target, key, value) {
|
|
31
|
+
defineProperty$3(target, key, {
|
|
32
|
+
__proto__: null,
|
|
33
|
+
value,
|
|
34
|
+
writable: true,
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true
|
|
37
|
+
});
|
|
28
38
|
}
|
|
29
39
|
// packages/intl-getcanonicallocales/locale-brand.ts
|
|
30
40
|
const apply$1 = Reflect.apply;
|
|
31
41
|
const defineProperty$2 = Object.defineProperty;
|
|
32
|
-
|
|
42
|
+
const localeBrandRegistry = {
|
|
43
|
+
readers: void 0,
|
|
44
|
+
parent: void 0
|
|
45
|
+
};
|
|
46
|
+
function rootRegistry(registry) {
|
|
47
|
+
while (registry.parent) registry = registry.parent;
|
|
48
|
+
return registry;
|
|
49
|
+
}
|
|
33
50
|
function addLocaleBrandReader(read) {
|
|
34
51
|
if (typeof read !== "function") throw new TypeErrorConstructor$1("Locale brand reader must be callable");
|
|
35
|
-
|
|
36
|
-
readers =
|
|
52
|
+
const registry = rootRegistry(localeBrandRegistry);
|
|
53
|
+
for (let node = registry.readers; node; node = node.next) if (node.read === read) return;
|
|
54
|
+
registry.readers = {
|
|
37
55
|
read,
|
|
38
|
-
next: readers
|
|
56
|
+
next: registry.readers
|
|
39
57
|
};
|
|
40
58
|
}
|
|
59
|
+
function connectLocaleBrandReaders(other) {
|
|
60
|
+
const ownRoot = rootRegistry(localeBrandRegistry);
|
|
61
|
+
const otherRoot = rootRegistry(other);
|
|
62
|
+
if (ownRoot === otherRoot) return;
|
|
63
|
+
const readers = ownRoot.readers;
|
|
64
|
+
ownRoot.parent = otherRoot;
|
|
65
|
+
ownRoot.readers = void 0;
|
|
66
|
+
for (let node = readers; node; node = node.next) addLocaleBrandReader(node.read);
|
|
67
|
+
}
|
|
41
68
|
function getLocaleBrandReaders() {
|
|
42
69
|
const result = [];
|
|
43
|
-
for (let node = readers; node; node = node.next) defineProperty$2(result, result.length, {
|
|
70
|
+
for (let node = rootRegistry(localeBrandRegistry).readers; node; node = node.next) defineProperty$2(result, result.length, {
|
|
44
71
|
value: node.read,
|
|
45
72
|
writable: true,
|
|
46
73
|
enumerable: true,
|
|
@@ -50,18 +77,22 @@ function getLocaleBrandReaders() {
|
|
|
50
77
|
}
|
|
51
78
|
function localeString(value) {
|
|
52
79
|
if (!IsObject(value)) return void 0;
|
|
53
|
-
for (let node = readers; node; node = node.next) {
|
|
80
|
+
for (let node = rootRegistry(localeBrandRegistry).readers; node; node = node.next) {
|
|
54
81
|
const tag = node.read(value);
|
|
55
82
|
if (typeof tag === "string") return tag;
|
|
56
83
|
}
|
|
57
84
|
}
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
85
|
+
const intl$1 = typeof Intl === "undefined" ? void 0 : Intl;
|
|
86
|
+
const currentCanonicalizer = intl$1?.getCanonicalLocales;
|
|
87
|
+
const currentLocale = intl$1?.Locale;
|
|
88
|
+
if (currentCanonicalizer?.__localeBrandRegistry) connectLocaleBrandReaders(currentCanonicalizer.__localeBrandRegistry);
|
|
89
|
+
const snapshot = currentLocale?.__getLocaleBrandReaders;
|
|
90
|
+
if (currentLocale?.__localeBrandRegistry) connectLocaleBrandReaders(currentLocale.__localeBrandRegistry);
|
|
91
|
+
else if (typeof snapshot === "function") {
|
|
92
|
+
const known = apply$1(snapshot, currentLocale, []);
|
|
62
93
|
for (let index = 0; index < known.length; index++) addLocaleBrandReader(known[index]);
|
|
63
94
|
} else {
|
|
64
|
-
const nativeToString =
|
|
95
|
+
const nativeToString = currentLocale?.prototype.toString;
|
|
65
96
|
if (typeof nativeToString === "function") addLocaleBrandReader((value) => {
|
|
66
97
|
try {
|
|
67
98
|
const tag = apply$1(nativeToString, value, []);
|
|
@@ -81,12 +112,7 @@ function ToObject(arg) {
|
|
|
81
112
|
}
|
|
82
113
|
// packages/intl-getcanonicallocales/appendToList.ts
|
|
83
114
|
function appendToList(list, ...values) {
|
|
84
|
-
for (
|
|
85
|
-
value,
|
|
86
|
-
writable: true,
|
|
87
|
-
enumerable: true,
|
|
88
|
-
configurable: true
|
|
89
|
-
});
|
|
115
|
+
for (let index = 0; index < values.length; index++) setDataProperty(list, list.length, values[index]);
|
|
90
116
|
}
|
|
91
117
|
// packages/ecma262-abstract/ToString.js
|
|
92
118
|
const StringConstructor = String;
|
|
@@ -1474,31 +1500,235 @@ const variantAlias = {
|
|
|
1474
1500
|
"heploc": "alalc97",
|
|
1475
1501
|
"polytoni": "polyton"
|
|
1476
1502
|
};
|
|
1503
|
+
// packages/intl-getcanonicallocales/parser.ts
|
|
1504
|
+
const lowerCase = Function.prototype.call.bind(String.prototype.toLowerCase);
|
|
1505
|
+
const create$2 = Object.create;
|
|
1506
|
+
const charCodeAt = Function.prototype.call.bind(String.prototype.charCodeAt);
|
|
1507
|
+
const indexOf = Function.prototype.call.bind(String.prototype.indexOf);
|
|
1508
|
+
const slice$2 = Function.prototype.call.bind(String.prototype.slice);
|
|
1509
|
+
const shift = Function.prototype.call.bind(Array.prototype.shift);
|
|
1510
|
+
const join = Function.prototype.call.bind(Array.prototype.join);
|
|
1511
|
+
function splitSubtags(value, separator = "-") {
|
|
1512
|
+
const parts = [];
|
|
1513
|
+
let start = 0;
|
|
1514
|
+
let end = indexOf(value, separator, start);
|
|
1515
|
+
while (end !== -1) {
|
|
1516
|
+
appendToList(parts, slice$2(value, start, end));
|
|
1517
|
+
start = end + separator.length;
|
|
1518
|
+
end = indexOf(value, separator, start);
|
|
1519
|
+
}
|
|
1520
|
+
appendToList(parts, slice$2(value, start));
|
|
1521
|
+
return parts;
|
|
1522
|
+
}
|
|
1523
|
+
function isLetter(code) {
|
|
1524
|
+
return code >= 65 && code <= 90 || code >= 97 && code <= 122;
|
|
1525
|
+
}
|
|
1526
|
+
function isDigit(code) {
|
|
1527
|
+
return code >= 48 && code <= 57;
|
|
1528
|
+
}
|
|
1529
|
+
function isSubtag(value, min, max, digits = false) {
|
|
1530
|
+
if (value.length < min || value.length > max) return false;
|
|
1531
|
+
for (let i = 0; i < value.length; i++) {
|
|
1532
|
+
const code = charCodeAt(value, i);
|
|
1533
|
+
if (!isLetter(code) && !(digits && isDigit(code))) return false;
|
|
1534
|
+
}
|
|
1535
|
+
return true;
|
|
1536
|
+
}
|
|
1537
|
+
function isUnicodeKey(value) {
|
|
1538
|
+
return value.length === 2 && isSubtag(value, 2, 2, true) && isLetter(charCodeAt(value, 1));
|
|
1539
|
+
}
|
|
1540
|
+
function isTransformedKey(value) {
|
|
1541
|
+
return value.length === 2 && isLetter(charCodeAt(value, 0)) && isDigit(charCodeAt(value, 1));
|
|
1542
|
+
}
|
|
1543
|
+
function isUnicodeLanguageSubtag(lang) {
|
|
1544
|
+
return lang.length !== 4 && isSubtag(lang, 2, 8);
|
|
1545
|
+
}
|
|
1546
|
+
function isUnicodeRegionSubtag(region) {
|
|
1547
|
+
return isSubtag(region, 2, 2) || region.length === 3 && isDigit(charCodeAt(region, 0)) && isDigit(charCodeAt(region, 1)) && isDigit(charCodeAt(region, 2));
|
|
1548
|
+
}
|
|
1549
|
+
function isUnicodeScriptSubtag(script) {
|
|
1550
|
+
return isSubtag(script, 4, 4);
|
|
1551
|
+
}
|
|
1552
|
+
function isUnicodeVariantSubtag(variant) {
|
|
1553
|
+
return isSubtag(variant, 5, 8, true) || isSubtag(variant, 4, 4, true) && isDigit(charCodeAt(variant, 0));
|
|
1554
|
+
}
|
|
1555
|
+
function parseUnicodeLanguageId(chunks) {
|
|
1556
|
+
if (typeof chunks === "string") chunks = splitSubtags(chunks);
|
|
1557
|
+
const lang = shift(chunks);
|
|
1558
|
+
if (!lang) throw new RangeErrorConstructor("Missing unicode_language_subtag");
|
|
1559
|
+
if (lang === "root") return {
|
|
1560
|
+
lang: "root",
|
|
1561
|
+
variants: []
|
|
1562
|
+
};
|
|
1563
|
+
if (!isUnicodeLanguageSubtag(lang)) throw new RangeErrorConstructor("Malformed unicode_language_subtag");
|
|
1564
|
+
let script;
|
|
1565
|
+
if (chunks.length && isUnicodeScriptSubtag(chunks[0])) script = shift(chunks);
|
|
1566
|
+
let region;
|
|
1567
|
+
if (chunks.length && isUnicodeRegionSubtag(chunks[0])) region = shift(chunks);
|
|
1568
|
+
const variants = [];
|
|
1569
|
+
const seenVariants = create$2(null);
|
|
1570
|
+
while (chunks.length && isUnicodeVariantSubtag(chunks[0])) {
|
|
1571
|
+
const variant = shift(chunks);
|
|
1572
|
+
const key = lowerCase(variant);
|
|
1573
|
+
if (seenVariants[key]) throw new RangeErrorConstructor(`Duplicate variant "${variant}"`);
|
|
1574
|
+
seenVariants[key] = true;
|
|
1575
|
+
appendToList(variants, variant);
|
|
1576
|
+
}
|
|
1577
|
+
return {
|
|
1578
|
+
lang,
|
|
1579
|
+
script,
|
|
1580
|
+
region,
|
|
1581
|
+
variants
|
|
1582
|
+
};
|
|
1583
|
+
}
|
|
1584
|
+
function parseUnicodeExtension(chunks) {
|
|
1585
|
+
const keywords = [];
|
|
1586
|
+
let keyword;
|
|
1587
|
+
while (chunks.length && (keyword = parseKeyword(chunks))) appendToList(keywords, keyword);
|
|
1588
|
+
if (keywords.length) return {
|
|
1589
|
+
type: "u",
|
|
1590
|
+
keywords,
|
|
1591
|
+
attributes: []
|
|
1592
|
+
};
|
|
1593
|
+
const attributes = [];
|
|
1594
|
+
while (chunks.length && isSubtag(chunks[0], 3, 8, true)) appendToList(attributes, shift(chunks));
|
|
1595
|
+
while (chunks.length && (keyword = parseKeyword(chunks))) appendToList(keywords, keyword);
|
|
1596
|
+
if (keywords.length || attributes.length) return {
|
|
1597
|
+
type: "u",
|
|
1598
|
+
attributes,
|
|
1599
|
+
keywords
|
|
1600
|
+
};
|
|
1601
|
+
throw new RangeErrorConstructor("Malformed unicode_extension");
|
|
1602
|
+
}
|
|
1603
|
+
function parseKeyword(chunks) {
|
|
1604
|
+
let key;
|
|
1605
|
+
if (!isUnicodeKey(chunks[0])) return;
|
|
1606
|
+
key = shift(chunks);
|
|
1607
|
+
const type = [];
|
|
1608
|
+
while (chunks.length && isSubtag(chunks[0], 3, 8, true)) appendToList(type, shift(chunks));
|
|
1609
|
+
let value = "";
|
|
1610
|
+
if (type.length) value = join(type, "-");
|
|
1611
|
+
return [key, value];
|
|
1612
|
+
}
|
|
1613
|
+
function parseTransformedExtension(chunks) {
|
|
1614
|
+
let lang;
|
|
1615
|
+
if (chunks.length && isUnicodeLanguageSubtag(chunks[0])) lang = parseUnicodeLanguageId(chunks);
|
|
1616
|
+
const fields = [];
|
|
1617
|
+
while (chunks.length && isTransformedKey(chunks[0])) {
|
|
1618
|
+
const key = shift(chunks);
|
|
1619
|
+
const value = [];
|
|
1620
|
+
while (chunks.length && isSubtag(chunks[0], 3, 8, true)) appendToList(value, shift(chunks));
|
|
1621
|
+
if (!value.length) throw new RangeErrorConstructor(`Missing tvalue for tkey "${key}"`);
|
|
1622
|
+
appendToList(fields, [key, join(value, "-")]);
|
|
1623
|
+
}
|
|
1624
|
+
if (lang || fields.length) return {
|
|
1625
|
+
type: "t",
|
|
1626
|
+
fields,
|
|
1627
|
+
lang
|
|
1628
|
+
};
|
|
1629
|
+
throw new RangeErrorConstructor("Malformed transformed_extension");
|
|
1630
|
+
}
|
|
1631
|
+
function parsePuExtension(chunks) {
|
|
1632
|
+
const exts = [];
|
|
1633
|
+
while (chunks.length && isSubtag(chunks[0], 1, 8, true)) appendToList(exts, shift(chunks));
|
|
1634
|
+
if (exts.length) return {
|
|
1635
|
+
type: "x",
|
|
1636
|
+
value: join(exts, "-")
|
|
1637
|
+
};
|
|
1638
|
+
throw new RangeErrorConstructor("Malformed private_use_extension");
|
|
1639
|
+
}
|
|
1640
|
+
function parseOtherExtensionValue(chunks) {
|
|
1641
|
+
const exts = [];
|
|
1642
|
+
while (chunks.length && isSubtag(chunks[0], 2, 8, true)) appendToList(exts, shift(chunks));
|
|
1643
|
+
if (exts.length) return join(exts, "-");
|
|
1644
|
+
throw new RangeErrorConstructor("Missing extension value");
|
|
1645
|
+
}
|
|
1646
|
+
function parseExtensions(chunks) {
|
|
1647
|
+
if (!chunks.length) return { extensions: [] };
|
|
1648
|
+
const extensions = [];
|
|
1649
|
+
let unicodeExtension;
|
|
1650
|
+
let transformedExtension;
|
|
1651
|
+
let puExtension;
|
|
1652
|
+
const otherExtensionMap = create$2(null);
|
|
1653
|
+
do {
|
|
1654
|
+
const singleton = shift(chunks);
|
|
1655
|
+
if (!isSubtag(singleton, 1, 1, true)) throw new RangeErrorConstructor("Malformed extension type");
|
|
1656
|
+
const type = lowerCase(singleton);
|
|
1657
|
+
switch (type) {
|
|
1658
|
+
case "u":
|
|
1659
|
+
if (unicodeExtension) throw new RangeErrorConstructor("There can only be 1 -u- extension");
|
|
1660
|
+
unicodeExtension = parseUnicodeExtension(chunks);
|
|
1661
|
+
appendToList(extensions, unicodeExtension);
|
|
1662
|
+
break;
|
|
1663
|
+
case "t":
|
|
1664
|
+
if (transformedExtension) throw new RangeErrorConstructor("There can only be 1 -t- extension");
|
|
1665
|
+
transformedExtension = parseTransformedExtension(chunks);
|
|
1666
|
+
appendToList(extensions, transformedExtension);
|
|
1667
|
+
break;
|
|
1668
|
+
case "x":
|
|
1669
|
+
if (puExtension) throw new RangeErrorConstructor("There can only be 1 -x- extension");
|
|
1670
|
+
puExtension = parsePuExtension(chunks);
|
|
1671
|
+
appendToList(extensions, puExtension);
|
|
1672
|
+
break;
|
|
1673
|
+
default:
|
|
1674
|
+
if (type in otherExtensionMap) throw new RangeErrorConstructor(`There can only be 1 -${type}- extension`);
|
|
1675
|
+
const extension = {
|
|
1676
|
+
type,
|
|
1677
|
+
value: parseOtherExtensionValue(chunks)
|
|
1678
|
+
};
|
|
1679
|
+
otherExtensionMap[extension.type] = extension;
|
|
1680
|
+
appendToList(extensions, extension);
|
|
1681
|
+
}
|
|
1682
|
+
} while (chunks.length);
|
|
1683
|
+
return { extensions };
|
|
1684
|
+
}
|
|
1685
|
+
function parseUnicodeLocaleId(locale) {
|
|
1686
|
+
const chunks = splitSubtags(locale);
|
|
1687
|
+
const lang = parseUnicodeLanguageId(chunks);
|
|
1688
|
+
if (lang.lang === "root") throw new RangeErrorConstructor("Invalid language tag: root");
|
|
1689
|
+
return {
|
|
1690
|
+
lang,
|
|
1691
|
+
...parseExtensions(chunks)
|
|
1692
|
+
};
|
|
1693
|
+
}
|
|
1477
1694
|
// packages/intl-getcanonicallocales/emitter.ts
|
|
1695
|
+
function appendSubtag(tag, subtag) {
|
|
1696
|
+
if (!subtag) return tag;
|
|
1697
|
+
return tag ? tag + "-" + subtag : subtag;
|
|
1698
|
+
}
|
|
1478
1699
|
function emitUnicodeLanguageId(lang) {
|
|
1479
1700
|
if (!lang) return "";
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1701
|
+
let tag = appendSubtag(appendSubtag(lang.lang, lang.script), lang.region);
|
|
1702
|
+
const variants = lang.variants;
|
|
1703
|
+
for (let i = 0; variants && i < variants.length; i++) tag = appendSubtag(tag, variants[i]);
|
|
1704
|
+
return tag;
|
|
1705
|
+
}
|
|
1706
|
+
function appendFields(tag, fields) {
|
|
1707
|
+
for (let i = 0; i < fields.length; i++) {
|
|
1708
|
+
const field = fields[i];
|
|
1709
|
+
tag = appendSubtag(tag, field[0]);
|
|
1710
|
+
if (field.length > 1) tag = appendSubtag(tag, field[1]);
|
|
1711
|
+
}
|
|
1712
|
+
return tag;
|
|
1486
1713
|
}
|
|
1487
1714
|
function emitUnicodeLocaleId({ lang, extensions }) {
|
|
1488
|
-
|
|
1489
|
-
for (
|
|
1490
|
-
|
|
1715
|
+
let tag = emitUnicodeLanguageId(lang);
|
|
1716
|
+
for (let i = 0; i < extensions.length; i++) {
|
|
1717
|
+
const ext = extensions[i];
|
|
1718
|
+
tag = appendSubtag(tag, ext.type);
|
|
1491
1719
|
switch (ext.type) {
|
|
1492
1720
|
case "u":
|
|
1493
|
-
|
|
1721
|
+
for (let j = 0; j < ext.attributes.length; j++) tag = appendSubtag(tag, ext.attributes[j]);
|
|
1722
|
+
tag = appendFields(tag, ext.keywords);
|
|
1494
1723
|
break;
|
|
1495
1724
|
case "t":
|
|
1496
|
-
|
|
1725
|
+
tag = appendSubtag(tag, lowerCase(emitUnicodeLanguageId(ext.lang)));
|
|
1726
|
+
tag = appendFields(tag, ext.fields);
|
|
1497
1727
|
break;
|
|
1498
|
-
default:
|
|
1728
|
+
default: tag = appendSubtag(tag, ext.value);
|
|
1499
1729
|
}
|
|
1500
1730
|
}
|
|
1501
|
-
return
|
|
1731
|
+
return tag;
|
|
1502
1732
|
}
|
|
1503
1733
|
// node_modules/.aspect_rules_js/@formatjs_generated+cldr.core@0.0.0/node_modules/@formatjs_generated/cldr.core/likelySubtags.js
|
|
1504
1734
|
const likelySubtags = {
|
|
@@ -9371,199 +9601,37 @@ const likelySubtags = {
|
|
|
9371
9601
|
"zza": "zza-Latn-TR",
|
|
9372
9602
|
"zzj": "zzj-Hani-CN"
|
|
9373
9603
|
};
|
|
9374
|
-
// packages/intl-getcanonicallocales/parser.ts
|
|
9375
|
-
function isLetter(code) {
|
|
9376
|
-
return code >= 65 && code <= 90 || code >= 97 && code <= 122;
|
|
9377
|
-
}
|
|
9378
|
-
function isDigit(code) {
|
|
9379
|
-
return code >= 48 && code <= 57;
|
|
9380
|
-
}
|
|
9381
|
-
function isSubtag(value, min, max, digits = false) {
|
|
9382
|
-
if (value.length < min || value.length > max) return false;
|
|
9383
|
-
for (let i = 0; i < value.length; i++) {
|
|
9384
|
-
const code = value.charCodeAt(i);
|
|
9385
|
-
if (!isLetter(code) && !(digits && isDigit(code))) return false;
|
|
9386
|
-
}
|
|
9387
|
-
return true;
|
|
9388
|
-
}
|
|
9389
|
-
function isUnicodeKey(value) {
|
|
9390
|
-
return value.length === 2 && isSubtag(value, 2, 2, true) && isLetter(value.charCodeAt(1));
|
|
9391
|
-
}
|
|
9392
|
-
function isTransformedKey(value) {
|
|
9393
|
-
return value.length === 2 && isLetter(value.charCodeAt(0)) && isDigit(value.charCodeAt(1));
|
|
9394
|
-
}
|
|
9395
|
-
function isOtherExtensionType(value) {
|
|
9396
|
-
const type = value.toLowerCase();
|
|
9397
|
-
return isSubtag(type, 1, 1, true) && type !== "t" && type !== "u" && type !== "x";
|
|
9398
|
-
}
|
|
9399
|
-
function isUnicodeLanguageSubtag(lang) {
|
|
9400
|
-
return lang.length !== 4 && isSubtag(lang, 2, 8);
|
|
9401
|
-
}
|
|
9402
|
-
function isUnicodeRegionSubtag(region) {
|
|
9403
|
-
return isSubtag(region, 2, 2) || region.length === 3 && isDigit(region.charCodeAt(0)) && isDigit(region.charCodeAt(1)) && isDigit(region.charCodeAt(2));
|
|
9404
|
-
}
|
|
9405
|
-
function isUnicodeScriptSubtag(script) {
|
|
9406
|
-
return isSubtag(script, 4, 4);
|
|
9407
|
-
}
|
|
9408
|
-
function isUnicodeVariantSubtag(variant) {
|
|
9409
|
-
return isSubtag(variant, 5, 8, true) || isSubtag(variant, 4, 4, true) && isDigit(variant.charCodeAt(0));
|
|
9410
|
-
}
|
|
9411
|
-
function parseUnicodeLanguageId(chunks) {
|
|
9412
|
-
if (typeof chunks === "string") chunks = chunks.split("-");
|
|
9413
|
-
const lang = chunks.shift();
|
|
9414
|
-
if (!lang) throw new RangeError("Missing unicode_language_subtag");
|
|
9415
|
-
if (lang === "root") return {
|
|
9416
|
-
lang: "root",
|
|
9417
|
-
variants: []
|
|
9418
|
-
};
|
|
9419
|
-
if (!isUnicodeLanguageSubtag(lang)) throw new RangeError("Malformed unicode_language_subtag");
|
|
9420
|
-
let script;
|
|
9421
|
-
if (chunks.length && isUnicodeScriptSubtag(chunks[0])) script = chunks.shift();
|
|
9422
|
-
let region;
|
|
9423
|
-
if (chunks.length && isUnicodeRegionSubtag(chunks[0])) region = chunks.shift();
|
|
9424
|
-
const variants = {};
|
|
9425
|
-
while (chunks.length && isUnicodeVariantSubtag(chunks[0])) {
|
|
9426
|
-
const variant = chunks.shift();
|
|
9427
|
-
if (variant in variants) throw new RangeError(`Duplicate variant "${variant}"`);
|
|
9428
|
-
variants[variant] = 1;
|
|
9429
|
-
}
|
|
9430
|
-
return {
|
|
9431
|
-
lang,
|
|
9432
|
-
script,
|
|
9433
|
-
region,
|
|
9434
|
-
variants: Object.keys(variants)
|
|
9435
|
-
};
|
|
9436
|
-
}
|
|
9437
|
-
function parseUnicodeExtension(chunks) {
|
|
9438
|
-
const keywords = [];
|
|
9439
|
-
let keyword;
|
|
9440
|
-
while (chunks.length && (keyword = parseKeyword(chunks))) appendToList(keywords, keyword);
|
|
9441
|
-
if (keywords.length) return {
|
|
9442
|
-
type: "u",
|
|
9443
|
-
keywords,
|
|
9444
|
-
attributes: []
|
|
9445
|
-
};
|
|
9446
|
-
const attributes = [];
|
|
9447
|
-
while (chunks.length && isSubtag(chunks[0], 3, 8, true)) appendToList(attributes, chunks.shift());
|
|
9448
|
-
while (chunks.length && (keyword = parseKeyword(chunks))) appendToList(keywords, keyword);
|
|
9449
|
-
if (keywords.length || attributes.length) return {
|
|
9450
|
-
type: "u",
|
|
9451
|
-
attributes,
|
|
9452
|
-
keywords
|
|
9453
|
-
};
|
|
9454
|
-
throw new RangeError("Malformed unicode_extension");
|
|
9455
|
-
}
|
|
9456
|
-
function parseKeyword(chunks) {
|
|
9457
|
-
let key;
|
|
9458
|
-
if (!isUnicodeKey(chunks[0])) return;
|
|
9459
|
-
key = chunks.shift();
|
|
9460
|
-
const type = [];
|
|
9461
|
-
while (chunks.length && isSubtag(chunks[0], 3, 8, true)) appendToList(type, chunks.shift());
|
|
9462
|
-
let value = "";
|
|
9463
|
-
if (type.length) value = type.join("-");
|
|
9464
|
-
return [key, value];
|
|
9465
|
-
}
|
|
9466
|
-
function parseTransformedExtension(chunks) {
|
|
9467
|
-
let lang;
|
|
9468
|
-
if (chunks.length && isUnicodeLanguageSubtag(chunks[0])) lang = parseUnicodeLanguageId(chunks);
|
|
9469
|
-
const fields = [];
|
|
9470
|
-
while (chunks.length && isTransformedKey(chunks[0])) {
|
|
9471
|
-
const key = chunks.shift();
|
|
9472
|
-
const value = [];
|
|
9473
|
-
while (chunks.length && isSubtag(chunks[0], 3, 8, true)) appendToList(value, chunks.shift());
|
|
9474
|
-
if (!value.length) throw new RangeError(`Missing tvalue for tkey "${key}"`);
|
|
9475
|
-
appendToList(fields, [key, value.join("-")]);
|
|
9476
|
-
}
|
|
9477
|
-
if (lang || fields.length) return {
|
|
9478
|
-
type: "t",
|
|
9479
|
-
fields,
|
|
9480
|
-
lang
|
|
9481
|
-
};
|
|
9482
|
-
throw new RangeError("Malformed transformed_extension");
|
|
9483
|
-
}
|
|
9484
|
-
function parsePuExtension(chunks) {
|
|
9485
|
-
const exts = [];
|
|
9486
|
-
while (chunks.length && isSubtag(chunks[0], 1, 8, true)) appendToList(exts, chunks.shift());
|
|
9487
|
-
if (exts.length) return {
|
|
9488
|
-
type: "x",
|
|
9489
|
-
value: exts.join("-")
|
|
9490
|
-
};
|
|
9491
|
-
throw new RangeError("Malformed private_use_extension");
|
|
9492
|
-
}
|
|
9493
|
-
function parseOtherExtensionValue(chunks) {
|
|
9494
|
-
const exts = [];
|
|
9495
|
-
while (chunks.length && isSubtag(chunks[0], 2, 8, true)) appendToList(exts, chunks.shift());
|
|
9496
|
-
if (exts.length) return exts.join("-");
|
|
9497
|
-
throw new RangeError("Missing extension value");
|
|
9498
|
-
}
|
|
9499
|
-
function parseExtensions(chunks) {
|
|
9500
|
-
if (!chunks.length) return { extensions: [] };
|
|
9501
|
-
const extensions = [];
|
|
9502
|
-
let unicodeExtension;
|
|
9503
|
-
let transformedExtension;
|
|
9504
|
-
let puExtension;
|
|
9505
|
-
const otherExtensionMap = {};
|
|
9506
|
-
do {
|
|
9507
|
-
const type = chunks.shift().toLowerCase();
|
|
9508
|
-
switch (type) {
|
|
9509
|
-
case "u":
|
|
9510
|
-
case "U":
|
|
9511
|
-
if (unicodeExtension) throw new RangeError("There can only be 1 -u- extension");
|
|
9512
|
-
unicodeExtension = parseUnicodeExtension(chunks);
|
|
9513
|
-
appendToList(extensions, unicodeExtension);
|
|
9514
|
-
break;
|
|
9515
|
-
case "t":
|
|
9516
|
-
case "T":
|
|
9517
|
-
if (transformedExtension) throw new RangeError("There can only be 1 -t- extension");
|
|
9518
|
-
transformedExtension = parseTransformedExtension(chunks);
|
|
9519
|
-
appendToList(extensions, transformedExtension);
|
|
9520
|
-
break;
|
|
9521
|
-
case "x":
|
|
9522
|
-
case "X":
|
|
9523
|
-
if (puExtension) throw new RangeError("There can only be 1 -x- extension");
|
|
9524
|
-
puExtension = parsePuExtension(chunks);
|
|
9525
|
-
appendToList(extensions, puExtension);
|
|
9526
|
-
break;
|
|
9527
|
-
default:
|
|
9528
|
-
if (!isOtherExtensionType(type)) throw new RangeError("Malformed extension type");
|
|
9529
|
-
if (type in otherExtensionMap) throw new RangeError(`There can only be 1 -${type}- extension`);
|
|
9530
|
-
const extension = {
|
|
9531
|
-
type,
|
|
9532
|
-
value: parseOtherExtensionValue(chunks)
|
|
9533
|
-
};
|
|
9534
|
-
otherExtensionMap[extension.type] = extension;
|
|
9535
|
-
appendToList(extensions, extension);
|
|
9536
|
-
}
|
|
9537
|
-
} while (chunks.length);
|
|
9538
|
-
return { extensions };
|
|
9539
|
-
}
|
|
9540
|
-
function parseUnicodeLocaleId(locale) {
|
|
9541
|
-
const chunks = locale.split("-");
|
|
9542
|
-
return {
|
|
9543
|
-
lang: parseUnicodeLanguageId(chunks),
|
|
9544
|
-
...parseExtensions(chunks)
|
|
9545
|
-
};
|
|
9546
|
-
}
|
|
9547
9604
|
// packages/intl-getcanonicallocales/canonicalizer.ts
|
|
9605
|
+
const create$1 = Object.create;
|
|
9606
|
+
const keys = Object.keys;
|
|
9607
|
+
const hasOwn = Function.prototype.call.bind(Object.prototype.hasOwnProperty);
|
|
9608
|
+
const upperCase = Function.prototype.call.bind(String.prototype.toUpperCase);
|
|
9609
|
+
const slice$1 = Function.prototype.call.bind(String.prototype.slice);
|
|
9610
|
+
const sort = Function.prototype.call.bind(Array.prototype.sort);
|
|
9611
|
+
const find = Function.prototype.call.bind(Array.prototype.find);
|
|
9612
|
+
function fromTable(table, key) {
|
|
9613
|
+
return table && hasOwn(table, key) ? table[key] : void 0;
|
|
9614
|
+
}
|
|
9548
9615
|
function canonicalizeAttrs(strs) {
|
|
9549
|
-
|
|
9550
|
-
|
|
9551
|
-
|
|
9552
|
-
}, {})).sort();
|
|
9616
|
+
const seen = create$1(null);
|
|
9617
|
+
for (let i = 0; i < strs.length; i++) seen[lowerCase(strs[i])] = true;
|
|
9618
|
+
return sort(keys(seen));
|
|
9553
9619
|
}
|
|
9554
9620
|
function canonicalizeKVs(arr, extension) {
|
|
9555
|
-
const seen =
|
|
9621
|
+
const seen = create$1(null);
|
|
9622
|
+
const aliases = fromTable(extensionAlias, extension);
|
|
9556
9623
|
const result = [];
|
|
9557
|
-
for (
|
|
9558
|
-
const
|
|
9559
|
-
|
|
9560
|
-
seen
|
|
9561
|
-
|
|
9562
|
-
|
|
9563
|
-
|
|
9624
|
+
for (let i = 0; i < arr.length; i++) {
|
|
9625
|
+
const field = arr[i];
|
|
9626
|
+
const key = lowerCase(field[0]);
|
|
9627
|
+
if (seen[key]) continue;
|
|
9628
|
+
seen[key] = true;
|
|
9629
|
+
const value = field.length === 2 ? lowerCase(field[1]) : "";
|
|
9630
|
+
let canonical = fromTable(fromTable(aliases, key), value) || value;
|
|
9631
|
+
if (extension === "u" && (key === "rg" || key === "sd")) canonical = fromTable(subdivisionAlias, canonical) || canonical;
|
|
9564
9632
|
appendToList(result, !canonical || extension === "u" && canonical === "true" ? [key] : [key, canonical]);
|
|
9565
9633
|
}
|
|
9566
|
-
return
|
|
9634
|
+
return sort(result, compareKV);
|
|
9567
9635
|
}
|
|
9568
9636
|
function compareKV(t1, t2) {
|
|
9569
9637
|
return t1[0] < t2[0] ? -1 : t1[0] > t2[0] ? 1 : 0;
|
|
@@ -9573,20 +9641,28 @@ function compareExtension(e1, e2) {
|
|
|
9573
9641
|
if (e2.type === "x") return -1;
|
|
9574
9642
|
return e1.type < e2.type ? -1 : e1.type > e2.type ? 1 : 0;
|
|
9575
9643
|
}
|
|
9576
|
-
function
|
|
9577
|
-
const result = [
|
|
9578
|
-
for (
|
|
9644
|
+
function replaceVariants(source, removed, replacement) {
|
|
9645
|
+
const result = [];
|
|
9646
|
+
for (let i = 0; i < source.length; i++) {
|
|
9647
|
+
const variant = source[i];
|
|
9648
|
+
if (!arrayIncludes(removed, variant)) appendToList(result, variant);
|
|
9649
|
+
}
|
|
9650
|
+
for (let i = 0; i < replacement.length; i++) {
|
|
9651
|
+
const variant = replacement[i];
|
|
9652
|
+
if (!arrayIncludes(result, variant)) appendToList(result, variant);
|
|
9653
|
+
}
|
|
9579
9654
|
return result;
|
|
9580
9655
|
}
|
|
9581
9656
|
function compareLanguageAliasRules(a, b) {
|
|
9582
9657
|
const fields = (id) => [
|
|
9583
|
-
|
|
9584
|
-
|
|
9585
|
-
|
|
9658
|
+
+(id.lang !== "und"),
|
|
9659
|
+
+!!id.script,
|
|
9660
|
+
+!!id.region,
|
|
9586
9661
|
id.variants.length
|
|
9587
9662
|
];
|
|
9588
9663
|
const left = fields(a.type), right = fields(b.type);
|
|
9589
|
-
|
|
9664
|
+
let difference = 0;
|
|
9665
|
+
for (let i = 0; i < left.length; i++) difference += right[i] - left[i];
|
|
9590
9666
|
if (difference) return difference;
|
|
9591
9667
|
for (let i = 0; i < left.length; i++) if (!!left[i] !== !!right[i]) return right[i] ? 1 : -1;
|
|
9592
9668
|
const leftTag = emitUnicodeLanguageId(a.type), rightTag = emitUnicodeLanguageId(b.type);
|
|
@@ -9595,14 +9671,14 @@ function compareLanguageAliasRules(a, b) {
|
|
|
9595
9671
|
const languageAliasRules = Object.keys(languageAlias).reduce((rules, from) => {
|
|
9596
9672
|
const to = languageAlias[from];
|
|
9597
9673
|
let type;
|
|
9598
|
-
const source = from
|
|
9674
|
+
const source = splitSubtags(from);
|
|
9599
9675
|
try {
|
|
9600
9676
|
type = parseUnicodeLanguageId(source);
|
|
9601
9677
|
} catch {
|
|
9602
9678
|
return rules;
|
|
9603
9679
|
}
|
|
9604
9680
|
if (source.length) return rules;
|
|
9605
|
-
const target = to
|
|
9681
|
+
const target = splitSubtags(to);
|
|
9606
9682
|
const replacement = parseUnicodeLanguageId(target);
|
|
9607
9683
|
if (target.length) throw new Error(`Invalid language alias replacement: ${to}`);
|
|
9608
9684
|
appendToList(rules, {
|
|
@@ -9615,15 +9691,18 @@ const languageAliasRules = Object.keys(languageAlias).reduce((rules, from) => {
|
|
|
9615
9691
|
return groups;
|
|
9616
9692
|
}, Object.create(null));
|
|
9617
9693
|
function canonicalizeUnicodeLanguageId(unicodeLanguageId) {
|
|
9618
|
-
unicodeLanguageId.lang = unicodeLanguageId.lang
|
|
9619
|
-
if (unicodeLanguageId.script) unicodeLanguageId.script = unicodeLanguageId.script[0]
|
|
9620
|
-
if (unicodeLanguageId.region) unicodeLanguageId.region = unicodeLanguageId.region
|
|
9621
|
-
|
|
9694
|
+
unicodeLanguageId.lang = lowerCase(unicodeLanguageId.lang);
|
|
9695
|
+
if (unicodeLanguageId.script) unicodeLanguageId.script = upperCase(unicodeLanguageId.script[0]) + lowerCase(slice$1(unicodeLanguageId.script, 1));
|
|
9696
|
+
if (unicodeLanguageId.region) unicodeLanguageId.region = upperCase(unicodeLanguageId.region);
|
|
9697
|
+
const lowerVariants = [];
|
|
9698
|
+
for (let i = 0; i < unicodeLanguageId.variants.length; i++) appendToList(lowerVariants, lowerCase(unicodeLanguageId.variants[i]));
|
|
9699
|
+
unicodeLanguageId.variants = lowerVariants;
|
|
9622
9700
|
const original = emitUnicodeLanguageId(unicodeLanguageId);
|
|
9623
9701
|
let finalLangAst = unicodeLanguageId;
|
|
9624
9702
|
const matches = ({ type }) => (!type.script || type.script === finalLangAst.script) && (!type.region || type.region === finalLangAst.region) && arrayEvery(type.variants, (variant) => arrayIncludes(finalLangAst.variants, variant));
|
|
9625
|
-
const
|
|
9626
|
-
const
|
|
9703
|
+
const rules = languageAliasRules[finalLangAst.lang];
|
|
9704
|
+
const languageRule = rules && find(rules, matches);
|
|
9705
|
+
const undRule = finalLangAst.lang !== "und" && languageAliasRules.und ? find(languageAliasRules.und, matches) : void 0;
|
|
9627
9706
|
const matched = !languageRule ? undRule : !undRule ? languageRule : compareLanguageAliasRules(languageRule, undRule) <= 0 ? languageRule : undRule;
|
|
9628
9707
|
if (matched) {
|
|
9629
9708
|
const { type, replacement } = matched;
|
|
@@ -9631,44 +9710,50 @@ function canonicalizeUnicodeLanguageId(unicodeLanguageId) {
|
|
|
9631
9710
|
lang: type.lang !== "und" || finalLangAst.lang === "und" ? replacement.lang : finalLangAst.lang,
|
|
9632
9711
|
script: type.script ? replacement.script : finalLangAst.script || replacement.script,
|
|
9633
9712
|
region: type.region ? replacement.region : finalLangAst.region || replacement.region,
|
|
9634
|
-
variants:
|
|
9713
|
+
variants: replaceVariants(finalLangAst.variants, type.variants, replacement.variants)
|
|
9635
9714
|
};
|
|
9636
9715
|
return canonicalizeUnicodeLanguageId(finalLangAst);
|
|
9637
9716
|
}
|
|
9638
9717
|
if (finalLangAst.region) {
|
|
9639
|
-
const region = finalLangAst.region
|
|
9640
|
-
const regionAlias = territoryAlias
|
|
9718
|
+
const region = upperCase(finalLangAst.region);
|
|
9719
|
+
const regionAlias = fromTable(territoryAlias, region);
|
|
9641
9720
|
let replacedRegion;
|
|
9642
9721
|
if (regionAlias) {
|
|
9643
|
-
const regions = regionAlias
|
|
9722
|
+
const regions = splitSubtags(regionAlias, " ");
|
|
9644
9723
|
replacedRegion = regions[0];
|
|
9645
|
-
const likelySubtag = likelySubtags
|
|
9724
|
+
const likelySubtag = fromTable(likelySubtags, emitUnicodeLanguageId({
|
|
9646
9725
|
lang: finalLangAst.lang,
|
|
9647
9726
|
script: finalLangAst.script,
|
|
9648
9727
|
variants: []
|
|
9649
|
-
})
|
|
9728
|
+
})) || fromTable(likelySubtags, finalLangAst.lang);
|
|
9650
9729
|
if (likelySubtag) {
|
|
9651
|
-
const { region: likelyRegion } = parseUnicodeLanguageId(likelySubtag
|
|
9730
|
+
const { region: likelyRegion } = parseUnicodeLanguageId(likelySubtag);
|
|
9652
9731
|
if (likelyRegion && arrayIndexOf(regions, likelyRegion) > -1) replacedRegion = likelyRegion;
|
|
9653
9732
|
}
|
|
9654
9733
|
}
|
|
9655
9734
|
if (replacedRegion) finalLangAst.region = replacedRegion;
|
|
9656
|
-
finalLangAst.region = finalLangAst.region
|
|
9735
|
+
finalLangAst.region = upperCase(finalLangAst.region);
|
|
9657
9736
|
}
|
|
9658
9737
|
if (finalLangAst.script) {
|
|
9659
|
-
finalLangAst.script = finalLangAst.script[0]
|
|
9660
|
-
|
|
9738
|
+
finalLangAst.script = upperCase(finalLangAst.script[0]) + lowerCase(slice$1(finalLangAst.script, 1));
|
|
9739
|
+
const alias = fromTable(scriptAlias, finalLangAst.script);
|
|
9740
|
+
if (alias) finalLangAst.script = alias;
|
|
9661
9741
|
}
|
|
9662
9742
|
if (finalLangAst.variants.length) {
|
|
9663
9743
|
for (let i = 0; i < finalLangAst.variants.length; i++) {
|
|
9664
|
-
|
|
9665
|
-
if (
|
|
9666
|
-
const alias = variantAlias[variant];
|
|
9744
|
+
const alias = fromTable(variantAlias, lowerCase(finalLangAst.variants[i]));
|
|
9745
|
+
if (alias) {
|
|
9667
9746
|
if (isUnicodeVariantSubtag(alias)) finalLangAst.variants[i] = alias;
|
|
9668
9747
|
else if (isUnicodeLanguageSubtag(alias)) finalLangAst.lang = alias;
|
|
9669
9748
|
}
|
|
9670
9749
|
}
|
|
9671
|
-
finalLangAst.variants
|
|
9750
|
+
const variants = sort(finalLangAst.variants);
|
|
9751
|
+
let count = 1;
|
|
9752
|
+
for (let i = 1; i < variants.length; i++) {
|
|
9753
|
+
const variant = variants[i];
|
|
9754
|
+
if (variant !== variants[count - 1]) variants[count++] = variant;
|
|
9755
|
+
}
|
|
9756
|
+
variants.length = count;
|
|
9672
9757
|
}
|
|
9673
9758
|
return emitUnicodeLanguageId(finalLangAst) === original ? finalLangAst : canonicalizeUnicodeLanguageId(finalLangAst);
|
|
9674
9759
|
}
|
|
@@ -9682,30 +9767,27 @@ function canonicalizeUnicodeLanguageId(unicodeLanguageId) {
|
|
|
9682
9767
|
function CanonicalizeUnicodeLocaleId(locale) {
|
|
9683
9768
|
locale.lang = canonicalizeUnicodeLanguageId(locale.lang);
|
|
9684
9769
|
if (locale.extensions) {
|
|
9685
|
-
for (
|
|
9686
|
-
|
|
9687
|
-
|
|
9688
|
-
|
|
9689
|
-
|
|
9690
|
-
|
|
9691
|
-
|
|
9692
|
-
|
|
9693
|
-
|
|
9694
|
-
|
|
9770
|
+
for (let i = 0; i < locale.extensions.length; i++) {
|
|
9771
|
+
const extension = locale.extensions[i];
|
|
9772
|
+
switch (extension.type) {
|
|
9773
|
+
case "u":
|
|
9774
|
+
extension.keywords = canonicalizeKVs(extension.keywords, "u");
|
|
9775
|
+
if (extension.attributes) extension.attributes = canonicalizeAttrs(extension.attributes);
|
|
9776
|
+
break;
|
|
9777
|
+
case "t":
|
|
9778
|
+
if (extension.lang) extension.lang = canonicalizeUnicodeLanguageId(extension.lang);
|
|
9779
|
+
extension.fields = canonicalizeKVs(extension.fields, "t");
|
|
9780
|
+
break;
|
|
9781
|
+
default: extension.value = lowerCase(extension.value);
|
|
9782
|
+
}
|
|
9695
9783
|
}
|
|
9696
|
-
locale.extensions
|
|
9784
|
+
sort(locale.extensions, compareExtension);
|
|
9697
9785
|
}
|
|
9698
9786
|
return locale;
|
|
9699
9787
|
}
|
|
9700
9788
|
// packages/intl-getcanonicallocales/index.ts
|
|
9701
|
-
/**
|
|
9702
|
-
* ECMA-402 §9.2.1 CanonicalizeLocaleList, steps 3–7.
|
|
9703
|
-
* https://tc39.es/ecma402/#sec-canonicalizelocalelist
|
|
9704
|
-
* https://github.com/tc39/ecma402/blob/b1c961988b9a07894b1dc3dc2b5626ea48387d61/spec/negotiation.html#L51-L70
|
|
9705
|
-
*/
|
|
9706
9789
|
function CanonicalizeLocaleList(locales) {
|
|
9707
9790
|
if (locales === void 0) return [];
|
|
9708
|
-
if (locales === null) throw new TypeErrorConstructor$1("Cannot convert null to an object");
|
|
9709
9791
|
const singleLocale = localeString(locales);
|
|
9710
9792
|
const list = typeof locales === "string" ? [locales] : singleLocale !== void 0 ? [singleLocale] : ToObject(locales);
|
|
9711
9793
|
const length = +list.length;
|
|
@@ -9720,12 +9802,15 @@ function CanonicalizeLocaleList(locales) {
|
|
|
9720
9802
|
}
|
|
9721
9803
|
return seen;
|
|
9722
9804
|
}
|
|
9723
|
-
|
|
9805
|
+
const getCanonicalLocales = { getCanonicalLocales(locales) {
|
|
9724
9806
|
return CanonicalizeLocaleList(locales);
|
|
9725
|
-
}
|
|
9807
|
+
} }.getCanonicalLocales;
|
|
9726
9808
|
Object.defineProperties(getCanonicalLocales, {
|
|
9727
9809
|
__addLocaleBrandReader: { value: addLocaleBrandReader },
|
|
9728
|
-
|
|
9810
|
+
__connectLocaleBrandReaders: { value: connectLocaleBrandReaders },
|
|
9811
|
+
__getLocaleBrandReaders: { value: getLocaleBrandReaders },
|
|
9812
|
+
__localeBrandRegistry: { value: localeBrandRegistry },
|
|
9813
|
+
__readLocaleTag: { value: localeString }
|
|
9729
9814
|
});
|
|
9730
9815
|
// node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js
|
|
9731
9816
|
const apply = Reflect.apply;
|
|
@@ -9812,7 +9897,9 @@ const strategies = {
|
|
|
9812
9897
|
variadic: strategyVariadic,
|
|
9813
9898
|
monadic: strategyMonadic
|
|
9814
9899
|
};
|
|
9815
|
-
|
|
9900
|
+
String.prototype.repeat;
|
|
9901
|
+
Array.from;
|
|
9902
|
+
Array.prototype.join;
|
|
9816
9903
|
function defineProperty(target, name, { value }) {
|
|
9817
9904
|
Object.defineProperty(target, name, {
|
|
9818
9905
|
configurable: true,
|
|
@@ -9822,17 +9909,25 @@ function defineProperty(target, name, { value }) {
|
|
|
9822
9909
|
});
|
|
9823
9910
|
}
|
|
9824
9911
|
function ensureIntl() {
|
|
9825
|
-
if (typeof Intl === "undefined")
|
|
9826
|
-
|
|
9827
|
-
|
|
9828
|
-
|
|
9829
|
-
|
|
9830
|
-
|
|
9912
|
+
if (typeof Intl === "undefined") {
|
|
9913
|
+
const intl = {};
|
|
9914
|
+
if (typeof Symbol !== "undefined") Object.defineProperty(intl, Symbol.toStringTag, {
|
|
9915
|
+
value: "Intl",
|
|
9916
|
+
writable: false,
|
|
9917
|
+
enumerable: false,
|
|
9918
|
+
configurable: true
|
|
9919
|
+
});
|
|
9920
|
+
Object.defineProperty(globalThis, "Intl", {
|
|
9921
|
+
configurable: true,
|
|
9922
|
+
enumerable: false,
|
|
9923
|
+
writable: true,
|
|
9924
|
+
value: intl
|
|
9925
|
+
});
|
|
9926
|
+
}
|
|
9831
9927
|
if (providerIntl === void 0) providerIntl = Intl;
|
|
9832
9928
|
return Intl;
|
|
9833
9929
|
}
|
|
9834
9930
|
memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
|
|
9835
|
-
memoize((...args) => new Intl.PluralRules(...args), { strategy: strategies.variadic });
|
|
9836
9931
|
memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic });
|
|
9837
9932
|
const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
9838
9933
|
strategies.variadic;
|
|
@@ -9841,43 +9936,78 @@ function ownIntlProvider(name) {
|
|
|
9841
9936
|
const descriptor = providerIntl && getOwnPropertyDescriptor(providerIntl, name);
|
|
9842
9937
|
return (descriptor && getOwnPropertyDescriptor(descriptor, "value"))?.value;
|
|
9843
9938
|
}
|
|
9844
|
-
let
|
|
9845
|
-
let
|
|
9939
|
+
let numberFormatIntrinsic = ownIntlProvider("NumberFormat");
|
|
9940
|
+
let listFormatIntrinsic = ownIntlProvider("ListFormat");
|
|
9941
|
+
let pluralRulesProvider = ownIntlProvider("PluralRules");
|
|
9846
9942
|
const getFormatterPrototype = Object.getPrototypeOf;
|
|
9847
|
-
|
|
9848
|
-
const
|
|
9849
|
-
const
|
|
9850
|
-
const
|
|
9851
|
-
const
|
|
9852
|
-
const
|
|
9853
|
-
|
|
9854
|
-
|
|
9855
|
-
|
|
9856
|
-
|
|
9857
|
-
|
|
9858
|
-
|
|
9859
|
-
|
|
9860
|
-
|
|
9861
|
-
|
|
9862
|
-
|
|
9863
|
-
|
|
9864
|
-
|
|
9865
|
-
|
|
9866
|
-
|
|
9867
|
-
|
|
9868
|
-
|
|
9943
|
+
function formatterMethodLookup(name) {
|
|
9944
|
+
const methods = /* @__PURE__ */ new WeakMap();
|
|
9945
|
+
const owners = /* @__PURE__ */ new WeakMap();
|
|
9946
|
+
const getMethod = methods.get.bind(methods);
|
|
9947
|
+
const setMethod = methods.set.bind(methods);
|
|
9948
|
+
const getOwner = owners.get.bind(owners);
|
|
9949
|
+
const setOwner = owners.set.bind(owners);
|
|
9950
|
+
return (Constructor) => {
|
|
9951
|
+
const cached = getMethod(Constructor);
|
|
9952
|
+
if (cached) return cached;
|
|
9953
|
+
let prototype = getOwnPropertyDescriptor(Constructor, "prototype")?.value;
|
|
9954
|
+
while (prototype != null) {
|
|
9955
|
+
const inherited = getOwner(prototype);
|
|
9956
|
+
if (inherited) {
|
|
9957
|
+
setMethod(Constructor, inherited);
|
|
9958
|
+
return inherited;
|
|
9959
|
+
}
|
|
9960
|
+
const descriptor = getOwnPropertyDescriptor(prototype, name);
|
|
9961
|
+
const value = descriptor && getOwnPropertyDescriptor(descriptor, "value");
|
|
9962
|
+
if (value && typeof value.value === "function") {
|
|
9963
|
+
const method = value.value;
|
|
9964
|
+
setMethod(Constructor, method);
|
|
9965
|
+
setOwner(prototype, method);
|
|
9966
|
+
return method;
|
|
9967
|
+
}
|
|
9968
|
+
prototype = getFormatterPrototype(prototype);
|
|
9869
9969
|
}
|
|
9870
|
-
|
|
9871
|
-
}
|
|
9970
|
+
};
|
|
9872
9971
|
}
|
|
9873
|
-
|
|
9874
|
-
|
|
9972
|
+
const findFormatterPartsMethod = formatterMethodLookup("formatToParts");
|
|
9973
|
+
const findPluralRulesSelectMethod = formatterMethodLookup("select");
|
|
9974
|
+
if (typeof numberFormatIntrinsic === "function") findFormatterPartsMethod(numberFormatIntrinsic);
|
|
9975
|
+
if (typeof listFormatIntrinsic === "function") findFormatterPartsMethod(listFormatIntrinsic);
|
|
9976
|
+
if (typeof pluralRulesProvider === "function") findPluralRulesSelectMethod(pluralRulesProvider);
|
|
9875
9977
|
const numberFormatMemoizers = /* @__PURE__ */ new WeakMap();
|
|
9876
9978
|
numberFormatMemoizers.get.bind(numberFormatMemoizers);
|
|
9877
9979
|
numberFormatMemoizers.set.bind(numberFormatMemoizers);
|
|
9878
9980
|
const listFormatMemoizers = /* @__PURE__ */ new WeakMap();
|
|
9879
9981
|
listFormatMemoizers.get.bind(listFormatMemoizers);
|
|
9880
9982
|
listFormatMemoizers.set.bind(listFormatMemoizers);
|
|
9881
|
-
|
|
9983
|
+
const pluralRulesMemoizers = /* @__PURE__ */ new WeakMap();
|
|
9984
|
+
pluralRulesMemoizers.get.bind(pluralRulesMemoizers);
|
|
9985
|
+
pluralRulesMemoizers.set.bind(pluralRulesMemoizers);
|
|
9986
|
+
// packages/ecma402-abstract/CanonicalizeLocaleList.js
|
|
9987
|
+
let canonicalIntl = globalThis.Intl;
|
|
9988
|
+
const canonicalDescriptor = Object.getOwnPropertyDescriptor;
|
|
9989
|
+
const canonicalDefine = Object.defineProperty;
|
|
9990
|
+
const canonicalIsExtensible = Object.isExtensible;
|
|
9991
|
+
const providerKey = Symbol.for("@formatjs/intlCanonicalizeLocaleList");
|
|
9992
|
+
function ownCanonicalProvider() {
|
|
9993
|
+
const descriptor = canonicalIntl && canonicalDescriptor(canonicalIntl, "getCanonicalLocales");
|
|
9994
|
+
return (descriptor && canonicalDescriptor(descriptor, "value"))?.value;
|
|
9995
|
+
}
|
|
9996
|
+
ownCanonicalProvider();
|
|
9997
|
+
function registerCanonicalizeLocaleList(intl, provider) {
|
|
9998
|
+
if (canonicalIntl === void 0) canonicalIntl = intl;
|
|
9999
|
+
if (canonicalIntl === intl);
|
|
10000
|
+
try {
|
|
10001
|
+
if (canonicalDescriptor(intl, providerKey) || canonicalIsExtensible(intl)) canonicalDefine(intl, providerKey, {
|
|
10002
|
+
__proto__: null,
|
|
10003
|
+
configurable: true,
|
|
10004
|
+
value: provider
|
|
10005
|
+
});
|
|
10006
|
+
} catch {}
|
|
10007
|
+
}
|
|
10008
|
+
// packages/intl-getcanonicallocales/polyfill-force.ts
|
|
10009
|
+
const intl = ensureIntl();
|
|
10010
|
+
defineProperty(intl, "getCanonicalLocales", { value: getCanonicalLocales });
|
|
10011
|
+
registerCanonicalizeLocaleList(intl, getCanonicalLocales);
|
|
9882
10012
|
|
|
9883
10013
|
//# sourceMappingURL=polyfill-force.js.map
|