@formatjs/intl-locale 5.3.9 → 5.3.11

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
@@ -4,6 +4,21 @@ import { timezones } from "@formatjs_generated/cldr.locale/timezones.js";
4
4
  import { hourCycles } from "@formatjs_generated/cldr.locale/hour-cycles.js";
5
5
  import { calendars } from "@formatjs_generated/cldr.locale/calendars.js";
6
6
  import { weekData } from "@formatjs_generated/cldr.locale/week-data.js";
7
+ //#region packages/ecma262-abstract/ToString.js
8
+ /**
9
+ * https://tc39.es/ecma262/#sec-tostring
10
+ */
11
+ function ToString$1(o) {
12
+ if (typeof o === "symbol") throw TypeError("Cannot convert a Symbol value to a string");
13
+ return String(o);
14
+ }
15
+ //#endregion
16
+ //#region packages/ecma402-abstract/IsUnicodeLocaleIdentifierType.js
17
+ /** Tests the Unicode locale identifier `type` grammar, not locale support. */
18
+ function IsUnicodeLocaleIdentifierType(value) {
19
+ return /^[a-z0-9]{3,8}(-[a-z0-9]{3,8})*(?![\s\S])/i.test(value);
20
+ }
21
+ //#endregion
7
22
  //#region packages/ecma262-abstract/HasOwnProperty.js
8
23
  /**
9
24
  * https://www.ecma-international.org/ecma-262/11.0/index.html#sec-hasownproperty
@@ -42,15 +57,6 @@ function CoerceOptionsToObject(options) {
42
57
  return ToObject(options);
43
58
  }
44
59
  //#endregion
45
- //#region packages/ecma262-abstract/ToString.js
46
- /**
47
- * https://tc39.es/ecma262/#sec-tostring
48
- */
49
- function ToString(o) {
50
- if (typeof o === "symbol") throw TypeError("Cannot convert a Symbol value to a string");
51
- return String(o);
52
- }
53
- //#endregion
54
60
  //#region packages/ecma402-abstract/GetOption.js
55
61
  /**
56
62
  * https://tc39.es/ecma402/#sec-getoption
@@ -61,12 +67,12 @@ function ToString(o) {
61
67
  * @param fallback
62
68
  */
63
69
  function GetOption(opts, prop, type, values, fallback) {
64
- if (typeof opts !== "object") throw new TypeError("Options must be an object");
70
+ if (opts === null || typeof opts !== "object" && typeof opts !== "function") throw new TypeError("Options must be an object");
65
71
  let value = opts[prop];
66
72
  if (value !== void 0) {
67
73
  if (type !== "boolean" && type !== "string") throw new TypeError("invalid type");
68
74
  if (type === "boolean") value = Boolean(value);
69
- if (type === "string") value = ToString(value);
75
+ if (type === "string") value = ToString$1(value);
70
76
  if (values !== void 0 && !values.filter((val) => val == value).length) throw new RangeError(`${value} is not within ${values.join(", ")}`);
71
77
  return value;
72
78
  }
@@ -180,6 +186,13 @@ memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variad
180
186
  //#endregion
181
187
  //#region node_modules/.aspect_rules_js/@formatjs+intl-supportedvaluesof@0.0.0/node_modules/@formatjs/intl-supportedvaluesof/index.js
182
188
  /**
189
+ * https://tc39.es/ecma262/#sec-tostring
190
+ */
191
+ function ToString(o) {
192
+ if (typeof o === "symbol") throw TypeError("Cannot convert a Symbol value to a string");
193
+ return String(o);
194
+ }
195
+ /**
183
196
  * Implementation: Memoized factory for Intl.DateTimeFormat instances
184
197
  *
185
198
  * Creates and caches DateTimeFormat instances to avoid repeated instantiation overhead.
@@ -251,24 +264,48 @@ const collations = [
251
264
  "unihan",
252
265
  "zhuyin"
253
266
  ];
254
- /**
255
- * Implementation: Tests if a collation is supported by attempting to create
256
- * a Collator with that collation and verifying it was accepted.
257
- *
258
- * CLDR Data: Candidate values come from CLDR collation types
259
- */
267
+ const collationCandidateLocales = {
268
+ "compat": ["ar"],
269
+ "trad": [
270
+ "bn",
271
+ "es",
272
+ "fi",
273
+ "kn",
274
+ "sa",
275
+ "sv",
276
+ "vi"
277
+ ],
278
+ "digits-after": ["cs"],
279
+ "eor": [
280
+ "de",
281
+ "de-AT",
282
+ "en"
283
+ ],
284
+ "phonebk": ["de", "de-AT"],
285
+ "private-kana": ["ja"],
286
+ "unihan": [
287
+ "ja",
288
+ "ko",
289
+ "zh",
290
+ "zh-Hant"
291
+ ],
292
+ "searchjl": ["ko"],
293
+ "phonetic": ["ln"],
294
+ "emoji": ["en"],
295
+ "private-unihan": ["en"],
296
+ "dict": ["si"],
297
+ "pinyin": ["zh", "zh-Hant"],
298
+ "private-pinyin": ["zh", "zh-Hant"],
299
+ "stroke": ["zh", "zh-Hant"],
300
+ "zhuyin": ["zh", "zh-Hant"]
301
+ };
260
302
  function isSupportedCollation(collation) {
261
- try {
262
- return Intl.Collator(`en-u-co-${collation}`).resolvedOptions().collation === collation;
303
+ const candidates = collationCandidateLocales[collation] || ["en"];
304
+ for (const locale of candidates) try {
305
+ if (new Intl.Collator(`${locale}-u-co-${collation}`).resolvedOptions().collation === collation) return true;
263
306
  } catch {}
264
307
  return false;
265
308
  }
266
- /**
267
- * ECMA-402 Spec: Returns supported collation identifiers
268
- * ECMA-402 Spec: Results must be sorted lexicographically
269
- *
270
- * Implementation: Filters CLDR list against actual runtime support
271
- */
272
309
  function getSupportedCollations() {
273
310
  return collations.filter(isSupportedCollation).sort();
274
311
  }
@@ -816,8 +853,8 @@ const timezones$1 = [
816
853
  "America/Aruba",
817
854
  "America/Asuncion",
818
855
  "America/Atikokan",
819
- "America/Bahia_Banderas",
820
856
  "America/Bahia",
857
+ "America/Bahia_Banderas",
821
858
  "America/Barbados",
822
859
  "America/Belem",
823
860
  "America/Belize",
@@ -840,8 +877,8 @@ const timezones$1 = [
840
877
  "America/Cuiaba",
841
878
  "America/Curacao",
842
879
  "America/Danmarkshavn",
843
- "America/Dawson_Creek",
844
880
  "America/Dawson",
881
+ "America/Dawson_Creek",
845
882
  "America/Denver",
846
883
  "America/Detroit",
847
884
  "America/Dominica",
@@ -910,8 +947,8 @@ const timezones$1 = [
910
947
  "America/Pangnirtung",
911
948
  "America/Paramaribo",
912
949
  "America/Phoenix",
913
- "America/Port_of_Spain",
914
950
  "America/Port-au-Prince",
951
+ "America/Port_of_Spain",
915
952
  "America/Porto_Velho",
916
953
  "America/Puerto_Rico",
917
954
  "America/Punta_Arenas",
@@ -1062,6 +1099,34 @@ const timezones$1 = [
1062
1099
  "Australia/Melbourne",
1063
1100
  "Australia/Perth",
1064
1101
  "Australia/Sydney",
1102
+ "Etc/GMT",
1103
+ "Etc/GMT+1",
1104
+ "Etc/GMT+10",
1105
+ "Etc/GMT+11",
1106
+ "Etc/GMT+12",
1107
+ "Etc/GMT+2",
1108
+ "Etc/GMT+3",
1109
+ "Etc/GMT+4",
1110
+ "Etc/GMT+5",
1111
+ "Etc/GMT+6",
1112
+ "Etc/GMT+7",
1113
+ "Etc/GMT+8",
1114
+ "Etc/GMT+9",
1115
+ "Etc/GMT-1",
1116
+ "Etc/GMT-10",
1117
+ "Etc/GMT-11",
1118
+ "Etc/GMT-12",
1119
+ "Etc/GMT-13",
1120
+ "Etc/GMT-14",
1121
+ "Etc/GMT-2",
1122
+ "Etc/GMT-3",
1123
+ "Etc/GMT-4",
1124
+ "Etc/GMT-5",
1125
+ "Etc/GMT-6",
1126
+ "Etc/GMT-7",
1127
+ "Etc/GMT-8",
1128
+ "Etc/GMT-9",
1129
+ "Etc/UTC",
1065
1130
  "Europe/Amsterdam",
1066
1131
  "Europe/Andorra",
1067
1132
  "Europe/Astrakhan",
@@ -1083,8 +1148,8 @@ const timezones$1 = [
1083
1148
  "Europe/Istanbul",
1084
1149
  "Europe/Jersey",
1085
1150
  "Europe/Kaliningrad",
1086
- "Europe/Kyiv",
1087
1151
  "Europe/Kirov",
1152
+ "Europe/Kyiv",
1088
1153
  "Europe/Lisbon",
1089
1154
  "Europe/Ljubljana",
1090
1155
  "Europe/London",
@@ -1140,7 +1205,6 @@ const timezones$1 = [
1140
1205
  "Pacific/Chuuk",
1141
1206
  "Pacific/Easter",
1142
1207
  "Pacific/Efate",
1143
- "Pacific/Kanton",
1144
1208
  "Pacific/Fakaofo",
1145
1209
  "Pacific/Fiji",
1146
1210
  "Pacific/Funafuti",
@@ -1149,6 +1213,7 @@ const timezones$1 = [
1149
1213
  "Pacific/Guadalcanal",
1150
1214
  "Pacific/Guam",
1151
1215
  "Pacific/Honolulu",
1216
+ "Pacific/Kanton",
1152
1217
  "Pacific/Kiritimati",
1153
1218
  "Pacific/Kosrae",
1154
1219
  "Pacific/Kwajalein",
@@ -1170,7 +1235,8 @@ const timezones$1 = [
1170
1235
  "Pacific/Tarawa",
1171
1236
  "Pacific/Tongatapu",
1172
1237
  "Pacific/Wake",
1173
- "Pacific/Wallis"
1238
+ "Pacific/Wallis",
1239
+ "UTC"
1174
1240
  ];
1175
1241
  /**
1176
1242
  * Implementation: Tests if a timezone is supported by attempting to create
@@ -1211,9 +1277,11 @@ const units = [
1211
1277
  "terabyte",
1212
1278
  "day",
1213
1279
  "hour",
1280
+ "microsecond",
1214
1281
  "millisecond",
1215
1282
  "minute",
1216
1283
  "month",
1284
+ "nanosecond",
1217
1285
  "second",
1218
1286
  "week",
1219
1287
  "year",
@@ -1264,7 +1332,9 @@ function getSupportedUnits() {
1264
1332
  }
1265
1333
  /**
1266
1334
  * ECMA-402 Spec: Intl.supportedValuesOf(key)
1335
+ * ECMA-402 §8.3.2 Intl.supportedValuesOf, step 1.
1267
1336
  * https://tc39.es/ecma402/#sec-intl.supportedvaluesof
1337
+ * https://github.com/tc39/ecma402/blob/b1c961988b9a07894b1dc3dc2b5626ea48387d61/spec/intl.html#L103
1268
1338
  *
1269
1339
  * Returns an array containing the supported calendar, collation, currency,
1270
1340
  * numbering systems, time zone, or unit values supported by the implementation.
@@ -1276,7 +1346,8 @@ function getSupportedUnits() {
1276
1346
  * @param key - The category of values to return
1277
1347
  * @returns A sorted array of unique string values
1278
1348
  */
1279
- function supportedValuesOf(key) {
1349
+ const supportedValuesOf = { supportedValuesOf(key) {
1350
+ key = ToString(key);
1280
1351
  switch (key) {
1281
1352
  case "calendar": return getSupportedCalendars();
1282
1353
  case "collation": return getSupportedCollations();
@@ -1286,9 +1357,519 @@ function supportedValuesOf(key) {
1286
1357
  case "unit": return getSupportedUnits();
1287
1358
  default: throw RangeError("Invalid key: " + key);
1288
1359
  }
1289
- }
1360
+ } }.supportedValuesOf;
1290
1361
  //#endregion
1291
1362
  //#region node_modules/.aspect_rules_js/@formatjs+intl-getcanonicallocales@0.0.0/node_modules/@formatjs/intl-getcanonicallocales/index.js
1363
+ function appendToList(list, ...values) {
1364
+ for (const value of values) Object.defineProperty(list, list.length, {
1365
+ value,
1366
+ writable: true,
1367
+ enumerable: true,
1368
+ configurable: true
1369
+ });
1370
+ }
1371
+ const languageAlias = {
1372
+ "aa-saaho": "ssy",
1373
+ "aam": "aas",
1374
+ "aar": "aa",
1375
+ "abk": "ab",
1376
+ "adp": "dz",
1377
+ "afr": "af",
1378
+ "agp": "apf",
1379
+ "ais": "ami",
1380
+ "ajp": "apc",
1381
+ "ajt": "aeb",
1382
+ "aju": "jrb",
1383
+ "aka": "ak",
1384
+ "alb": "sq",
1385
+ "als": "sq",
1386
+ "amh": "am",
1387
+ "ara": "ar",
1388
+ "arb": "ar",
1389
+ "arg": "an",
1390
+ "arm": "hy",
1391
+ "art-lojban": "jbo",
1392
+ "asd": "snz",
1393
+ "asm": "as",
1394
+ "aue": "ktz",
1395
+ "ava": "av",
1396
+ "ave": "ae",
1397
+ "aym": "ay",
1398
+ "ayr": "ay",
1399
+ "ayx": "nun",
1400
+ "aze": "az",
1401
+ "azj": "az",
1402
+ "bak": "ba",
1403
+ "bam": "bm",
1404
+ "baq": "eu",
1405
+ "baz": "nvo",
1406
+ "bcc": "bal",
1407
+ "bcl": "bik",
1408
+ "bel": "be",
1409
+ "ben": "bn",
1410
+ "bgm": "bcg",
1411
+ "bh": "bho",
1412
+ "bhk": "fbl",
1413
+ "bic": "bir",
1414
+ "bih": "bho",
1415
+ "bis": "bi",
1416
+ "bjd": "drl",
1417
+ "bjq": "bzc",
1418
+ "bkb": "ebk",
1419
+ "blg": "iba",
1420
+ "bod": "bo",
1421
+ "bos": "bs",
1422
+ "bre": "br",
1423
+ "btb": "beb",
1424
+ "bul": "bg",
1425
+ "bur": "my",
1426
+ "bxk": "luy",
1427
+ "bxr": "bua",
1428
+ "cat": "ca",
1429
+ "ccq": "rki",
1430
+ "cel-gaulish": "xtg",
1431
+ "ces": "cs",
1432
+ "cha": "ch",
1433
+ "che": "ce",
1434
+ "chi": "zh",
1435
+ "chu": "cu",
1436
+ "chv": "cv",
1437
+ "cjr": "mom",
1438
+ "cka": "cmr",
1439
+ "cld": "syr",
1440
+ "cls": "sa",
1441
+ "cmk": "xch",
1442
+ "cmn": "zh",
1443
+ "cnr": "sr-ME",
1444
+ "cor": "kw",
1445
+ "cos": "co",
1446
+ "coy": "pij",
1447
+ "cqu": "quh",
1448
+ "cre": "cr",
1449
+ "cwd": "cr",
1450
+ "cym": "cy",
1451
+ "cze": "cs",
1452
+ "daf": "dnj",
1453
+ "dan": "da",
1454
+ "dap": "njz",
1455
+ "dek": "sqm",
1456
+ "deu": "de",
1457
+ "dgo": "doi",
1458
+ "dhd": "mwr",
1459
+ "dik": "din",
1460
+ "diq": "zza",
1461
+ "dit": "dif",
1462
+ "div": "dv",
1463
+ "djl": "dze",
1464
+ "dkl": "aqd",
1465
+ "drh": "mn",
1466
+ "drr": "kzk",
1467
+ "drw": "fa-AF",
1468
+ "dud": "uth",
1469
+ "duj": "dwu",
1470
+ "dut": "nl",
1471
+ "dwl": "dbt",
1472
+ "dzo": "dz",
1473
+ "ekk": "et",
1474
+ "ell": "el",
1475
+ "elp": "amq",
1476
+ "emk": "man",
1477
+ "en-GB-oed": "en-GB-oxendict",
1478
+ "eng": "en",
1479
+ "epo": "eo",
1480
+ "esk": "ik",
1481
+ "est": "et",
1482
+ "eus": "eu",
1483
+ "ewe": "ee",
1484
+ "fao": "fo",
1485
+ "fas": "fa",
1486
+ "fat": "ak",
1487
+ "fij": "fj",
1488
+ "fin": "fi",
1489
+ "fra": "fr",
1490
+ "fre": "fr",
1491
+ "fry": "fy",
1492
+ "fuc": "ff",
1493
+ "ful": "ff",
1494
+ "gav": "dev",
1495
+ "gaz": "om",
1496
+ "gbc": "wny",
1497
+ "gbo": "grb",
1498
+ "geo": "ka",
1499
+ "ger": "de",
1500
+ "gfx": "vaj",
1501
+ "ggn": "gvr",
1502
+ "ggo": "esg",
1503
+ "ggr": "gtu",
1504
+ "gio": "aou",
1505
+ "gla": "gd",
1506
+ "gle": "ga",
1507
+ "glg": "gl",
1508
+ "gli": "kzk",
1509
+ "glv": "gv",
1510
+ "gno": "gon",
1511
+ "gom": "kok",
1512
+ "gre": "el",
1513
+ "grn": "gn",
1514
+ "gti": "nyc",
1515
+ "gug": "gn",
1516
+ "guj": "gu",
1517
+ "guv": "duz",
1518
+ "gya": "gba",
1519
+ "hat": "ht",
1520
+ "hau": "ha",
1521
+ "hbs": "sr-Latn",
1522
+ "hdn": "hai",
1523
+ "hea": "hmn",
1524
+ "heb": "he",
1525
+ "her": "hz",
1526
+ "him": "srx",
1527
+ "hin": "hi",
1528
+ "hmo": "ho",
1529
+ "hrr": "jal",
1530
+ "hrv": "hr",
1531
+ "hun": "hu",
1532
+ "hy-arevmda": "hyw",
1533
+ "hye": "hy",
1534
+ "i-ami": "ami",
1535
+ "i-bnn": "bnn",
1536
+ "i-default": "en-x-i-default",
1537
+ "i-enochian": "und-x-i-enochian",
1538
+ "i-hak": "hak",
1539
+ "i-klingon": "tlh",
1540
+ "i-lux": "lb",
1541
+ "i-mingo": "see-x-i-mingo",
1542
+ "i-navajo": "nv",
1543
+ "i-pwn": "pwn",
1544
+ "i-tao": "tao",
1545
+ "i-tay": "tay",
1546
+ "i-tsu": "tsu",
1547
+ "ibi": "opa",
1548
+ "ibo": "ig",
1549
+ "ice": "is",
1550
+ "ido": "io",
1551
+ "iii": "ii",
1552
+ "ike": "iu",
1553
+ "iku": "iu",
1554
+ "ile": "ie",
1555
+ "ill": "ilm",
1556
+ "ilw": "gal",
1557
+ "in": "id",
1558
+ "ina": "ia",
1559
+ "ind": "id",
1560
+ "ipk": "ik",
1561
+ "isl": "is",
1562
+ "ita": "it",
1563
+ "iw": "he",
1564
+ "izi": "eza",
1565
+ "jar": "jgk",
1566
+ "jav": "jv",
1567
+ "jeg": "oyb",
1568
+ "ji": "yi",
1569
+ "jpn": "ja",
1570
+ "jw": "jv",
1571
+ "kal": "kl",
1572
+ "kan": "kn",
1573
+ "kas": "ks",
1574
+ "kat": "ka",
1575
+ "kau": "kr",
1576
+ "kaz": "kk",
1577
+ "kdv": "zkd",
1578
+ "kgc": "tdf",
1579
+ "kgd": "ncq",
1580
+ "kgh": "kml",
1581
+ "kgm": "plu",
1582
+ "khk": "mn",
1583
+ "khm": "km",
1584
+ "kik": "ki",
1585
+ "kin": "rw",
1586
+ "kir": "ky",
1587
+ "kmr": "ku",
1588
+ "knc": "kr",
1589
+ "kng": "kg",
1590
+ "koj": "kwv",
1591
+ "kom": "kv",
1592
+ "kon": "kg",
1593
+ "kor": "ko",
1594
+ "kpp": "jkm",
1595
+ "kpv": "kv",
1596
+ "krm": "bmf",
1597
+ "ktr": "dtp",
1598
+ "kua": "kj",
1599
+ "kur": "ku",
1600
+ "kvs": "gdj",
1601
+ "kwq": "yam",
1602
+ "kxe": "tvd",
1603
+ "kxl": "kru",
1604
+ "kzh": "dgl",
1605
+ "kzj": "dtp",
1606
+ "kzt": "dtp",
1607
+ "lak": "ksp",
1608
+ "lao": "lo",
1609
+ "lat": "la",
1610
+ "lav": "lv",
1611
+ "lbk": "bnc",
1612
+ "leg": "enl",
1613
+ "lii": "raq",
1614
+ "lim": "li",
1615
+ "lin": "ln",
1616
+ "lit": "lt",
1617
+ "llo": "ngt",
1618
+ "lmm": "rmx",
1619
+ "ltz": "lb",
1620
+ "lub": "lu",
1621
+ "lug": "lg",
1622
+ "lvs": "lv",
1623
+ "mac": "mk",
1624
+ "mah": "mh",
1625
+ "mal": "ml",
1626
+ "mao": "mi",
1627
+ "mar": "mr",
1628
+ "may": "ms",
1629
+ "meg": "cir",
1630
+ "mgx": "jbk",
1631
+ "mhr": "chm",
1632
+ "mkd": "mk",
1633
+ "mlg": "mg",
1634
+ "mlt": "mt",
1635
+ "mnt": "wnn",
1636
+ "mo": "ro",
1637
+ "mof": "xnt",
1638
+ "mol": "ro",
1639
+ "mon": "mn",
1640
+ "mri": "mi",
1641
+ "msa": "ms",
1642
+ "mst": "mry",
1643
+ "mup": "raj",
1644
+ "mwd": "dmw",
1645
+ "mwj": "vaj",
1646
+ "mya": "my",
1647
+ "myd": "aog",
1648
+ "myt": "mry",
1649
+ "nad": "xny",
1650
+ "nau": "na",
1651
+ "nav": "nv",
1652
+ "nbf": "nru",
1653
+ "nbl": "nr",
1654
+ "nbx": "gll",
1655
+ "ncp": "kdz",
1656
+ "nde": "nd",
1657
+ "ndo": "ng",
1658
+ "nep": "ne",
1659
+ "nld": "nl",
1660
+ "nln": "azd",
1661
+ "nlr": "nrk",
1662
+ "nno": "nn",
1663
+ "nns": "nbr",
1664
+ "nnx": "ngv",
1665
+ "no-bok": "nb",
1666
+ "no-bokmal": "nb",
1667
+ "no-nyn": "nn",
1668
+ "no-nynorsk": "nn",
1669
+ "nob": "nb",
1670
+ "nom": "cbr",
1671
+ "noo": "dtd",
1672
+ "nor": "no",
1673
+ "npi": "ne",
1674
+ "nte": "eko",
1675
+ "nts": "pij",
1676
+ "nxu": "bpp",
1677
+ "nya": "ny",
1678
+ "oci": "oc",
1679
+ "ojg": "oj",
1680
+ "oji": "oj",
1681
+ "ori": "or",
1682
+ "orm": "om",
1683
+ "ory": "or",
1684
+ "oss": "os",
1685
+ "oun": "vaj",
1686
+ "pan": "pa",
1687
+ "pat": "kxr",
1688
+ "pbu": "ps",
1689
+ "pcr": "adx",
1690
+ "per": "fa",
1691
+ "pes": "fa",
1692
+ "pli": "pi",
1693
+ "plt": "mg",
1694
+ "pmc": "huw",
1695
+ "pmk": "crr",
1696
+ "pmu": "phr",
1697
+ "pnb": "lah",
1698
+ "pol": "pl",
1699
+ "por": "pt",
1700
+ "ppa": "bfy",
1701
+ "ppr": "lcq",
1702
+ "prp": "gu",
1703
+ "prs": "fa-AF",
1704
+ "pry": "prt",
1705
+ "pus": "ps",
1706
+ "puz": "pub",
1707
+ "que": "qu",
1708
+ "quz": "qu",
1709
+ "rmr": "emx",
1710
+ "rmy": "rom",
1711
+ "roh": "rm",
1712
+ "ron": "ro",
1713
+ "rum": "ro",
1714
+ "run": "rn",
1715
+ "rus": "ru",
1716
+ "sag": "sg",
1717
+ "san": "sa",
1718
+ "sap": "aqt",
1719
+ "sca": "hle",
1720
+ "scc": "sr",
1721
+ "scr": "hr",
1722
+ "sgl": "isk",
1723
+ "sgn-BE-FR": "sfb",
1724
+ "sgn-BE-NL": "vgt",
1725
+ "sgn-BR": "bzs",
1726
+ "sgn-CH-DE": "sgg",
1727
+ "sgn-CO": "csn",
1728
+ "sgn-DE": "gsg",
1729
+ "sgn-DK": "dsl",
1730
+ "sgn-ES": "ssp",
1731
+ "sgn-FR": "fsl",
1732
+ "sgn-GB": "bfi",
1733
+ "sgn-GR": "gss",
1734
+ "sgn-IE": "isg",
1735
+ "sgn-IT": "ise",
1736
+ "sgn-JP": "jsl",
1737
+ "sgn-MX": "mfs",
1738
+ "sgn-NI": "ncs",
1739
+ "sgn-NL": "dse",
1740
+ "sgn-NO": "nsi",
1741
+ "sgn-PT": "psr",
1742
+ "sgn-SE": "swl",
1743
+ "sgn-US": "ase",
1744
+ "sgn-ZA": "sfs",
1745
+ "sh": "sr-Latn",
1746
+ "sin": "si",
1747
+ "skk": "oyb",
1748
+ "slk": "sk",
1749
+ "slo": "sk",
1750
+ "slv": "sl",
1751
+ "smd": "kmb",
1752
+ "sme": "se",
1753
+ "smo": "sm",
1754
+ "sna": "sn",
1755
+ "snb": "iba",
1756
+ "snd": "sd",
1757
+ "som": "so",
1758
+ "sot": "st",
1759
+ "spa": "es",
1760
+ "spy": "kln",
1761
+ "sqi": "sq",
1762
+ "src": "sc",
1763
+ "srd": "sc",
1764
+ "srp": "sr",
1765
+ "ssw": "ss",
1766
+ "sul": "sgd",
1767
+ "sum": "ulw",
1768
+ "sun": "su",
1769
+ "swa": "sw",
1770
+ "swc": "sw-CD",
1771
+ "swe": "sv",
1772
+ "swh": "sw",
1773
+ "szd": "umi",
1774
+ "tah": "ty",
1775
+ "tam": "ta",
1776
+ "tat": "tt",
1777
+ "tdu": "dtp",
1778
+ "tel": "te",
1779
+ "tgg": "bjp",
1780
+ "tgk": "tg",
1781
+ "tgl": "fil",
1782
+ "tha": "th",
1783
+ "thc": "tpo",
1784
+ "thw": "ola",
1785
+ "thx": "oyb",
1786
+ "tib": "bo",
1787
+ "tid": "itd",
1788
+ "tie": "ras",
1789
+ "tir": "ti",
1790
+ "tkk": "twm",
1791
+ "tl": "fil",
1792
+ "tlw": "weo",
1793
+ "tmk": "tdg",
1794
+ "tmp": "tyj",
1795
+ "tne": "kak",
1796
+ "tnf": "fa-AF",
1797
+ "ton": "to",
1798
+ "tpw": "tpn",
1799
+ "tsf": "taj",
1800
+ "tsn": "tn",
1801
+ "tso": "ts",
1802
+ "ttq": "tmh",
1803
+ "tuk": "tk",
1804
+ "tur": "tr",
1805
+ "tw": "ak",
1806
+ "twi": "ak",
1807
+ "uig": "ug",
1808
+ "ukr": "uk",
1809
+ "umu": "del",
1810
+ "und-aaland": "und-AX",
1811
+ "und-arevela": "und",
1812
+ "und-arevmda": "und",
1813
+ "und-bokmal": "und",
1814
+ "und-hakka": "und",
1815
+ "und-hepburn-heploc": "und-alalc97",
1816
+ "und-lojban": "und",
1817
+ "und-nynorsk": "und",
1818
+ "und-saaho": "und",
1819
+ "und-xiang": "und",
1820
+ "unp": "wro",
1821
+ "uok": "ema",
1822
+ "urd": "ur",
1823
+ "uzb": "uz",
1824
+ "uzn": "uz",
1825
+ "ven": "ve",
1826
+ "vie": "vi",
1827
+ "vol": "vo",
1828
+ "wel": "cy",
1829
+ "wgw": "wgb",
1830
+ "wit": "nol",
1831
+ "wiw": "nwo",
1832
+ "wln": "wa",
1833
+ "wol": "wo",
1834
+ "xba": "cax",
1835
+ "xho": "xh",
1836
+ "xia": "acn",
1837
+ "xkh": "waw",
1838
+ "xpe": "kpe",
1839
+ "xrq": "dmw",
1840
+ "xsj": "suj",
1841
+ "xsl": "den",
1842
+ "xss": "zko",
1843
+ "ybd": "rki",
1844
+ "ydd": "yi",
1845
+ "yen": "ynq",
1846
+ "yid": "yi",
1847
+ "yiy": "yrm",
1848
+ "yma": "lrr",
1849
+ "ymt": "mtm",
1850
+ "yor": "yo",
1851
+ "yos": "zom",
1852
+ "yuu": "yug",
1853
+ "zai": "zap",
1854
+ "zh-cmn": "zh",
1855
+ "zh-cmn-Hans": "zh-Hans",
1856
+ "zh-cmn-Hant": "zh-Hant",
1857
+ "zh-gan": "gan",
1858
+ "zh-guoyu": "zh",
1859
+ "zh-hakka": "hak",
1860
+ "zh-min": "nan-x-zh-min",
1861
+ "zh-min-nan": "nan",
1862
+ "zh-wuu": "wuu",
1863
+ "zh-xiang": "hsn",
1864
+ "zh-yue": "yue",
1865
+ "zha": "za",
1866
+ "zho": "zh",
1867
+ "zir": "scv",
1868
+ "zkb": "kjh",
1869
+ "zsm": "ms",
1870
+ "zul": "zu",
1871
+ "zyb": "za"
1872
+ };
1292
1873
  function emitUnicodeLanguageId(lang) {
1293
1874
  if (!lang) return "";
1294
1875
  return [
@@ -1301,17 +1882,15 @@ function emitUnicodeLanguageId(lang) {
1301
1882
  function emitUnicodeLocaleId({ lang, extensions }) {
1302
1883
  const chunks = [emitUnicodeLanguageId(lang)];
1303
1884
  for (const ext of extensions) {
1304
- chunks.push(ext.type);
1885
+ appendToList(chunks, ext.type);
1305
1886
  switch (ext.type) {
1306
1887
  case "u":
1307
- chunks.push(...ext.attributes, ...ext.keywords.reduce((all, kv) => all.concat(kv), []));
1888
+ appendToList(chunks, ...ext.attributes, ...ext.keywords.reduce((all, kv) => all.concat(kv), []));
1308
1889
  break;
1309
1890
  case "t":
1310
- chunks.push(emitUnicodeLanguageId(ext.lang), ...ext.fields.reduce((all, kv) => all.concat(kv), []));
1311
- break;
1312
- default:
1313
- chunks.push(ext.value);
1891
+ appendToList(chunks, emitUnicodeLanguageId(ext.lang).toLowerCase(), ...ext.fields.reduce((all, kv) => all.concat(kv), []));
1314
1892
  break;
1893
+ default: appendToList(chunks, ext.value);
1315
1894
  }
1316
1895
  }
1317
1896
  return chunks.filter(Boolean).join("-");
@@ -9106,19 +9685,32 @@ const likelySubtags = {
9106
9685
  "zza": "zza-Latn-TR",
9107
9686
  "zzj": "zzj-Hani-CN"
9108
9687
  };
9109
- const ALPHANUM_1_8 = /^[a-z0-9]{1,8}$/i;
9110
- const ALPHANUM_2_8 = /^[a-z0-9]{2,8}$/i;
9111
- const ALPHANUM_3_8$1 = /^[a-z0-9]{3,8}$/i;
9112
- const KEY_REGEX = /^[a-z0-9][a-z]$/i;
9113
- const TYPE_REGEX = /^[a-z0-9]{3,8}$/i;
9114
- const ALPHA_4 = /^[a-z]{4}$/i;
9115
- const OTHER_EXTENSION_TYPE = /^[0-9a-svwyz]$/i;
9116
- const UNICODE_REGION_SUBTAG_REGEX = /^([a-z]{2}|[0-9]{3})$/i;
9117
- const UNICODE_VARIANT_SUBTAG_REGEX = /^([a-z0-9]{5,8}|[0-9][a-z0-9]{3})$/i;
9118
- const UNICODE_LANGUAGE_SUBTAG_REGEX = /^([a-z]{2,3}|[a-z]{5,8})$/i;
9119
- const TKEY_REGEX = /^[a-z][0-9]$/i;
9688
+ function isLetter(code) {
9689
+ return code >= 65 && code <= 90 || code >= 97 && code <= 122;
9690
+ }
9691
+ function isDigit(code) {
9692
+ return code >= 48 && code <= 57;
9693
+ }
9694
+ function isSubtag(value, min, max, digits = false) {
9695
+ if (value.length < min || value.length > max) return false;
9696
+ for (let i = 0; i < value.length; i++) {
9697
+ const code = value.charCodeAt(i);
9698
+ if (!isLetter(code) && !(digits && isDigit(code))) return false;
9699
+ }
9700
+ return true;
9701
+ }
9702
+ function isUnicodeKey(value) {
9703
+ return value.length === 2 && isSubtag(value, 2, 2, true) && isLetter(value.charCodeAt(1));
9704
+ }
9705
+ function isTransformedKey(value) {
9706
+ return value.length === 2 && isLetter(value.charCodeAt(0)) && isDigit(value.charCodeAt(1));
9707
+ }
9708
+ function isOtherExtensionType(value) {
9709
+ const type = value.toLowerCase();
9710
+ return isSubtag(type, 1, 1, true) && type !== "t" && type !== "u" && type !== "x";
9711
+ }
9120
9712
  function isUnicodeLanguageSubtag(lang) {
9121
- return UNICODE_LANGUAGE_SUBTAG_REGEX.test(lang);
9713
+ return lang.length !== 4 && isSubtag(lang, 2, 8);
9122
9714
  }
9123
9715
  function isStructurallyValidLanguageTag(tag) {
9124
9716
  try {
@@ -9129,13 +9721,13 @@ function isStructurallyValidLanguageTag(tag) {
9129
9721
  return true;
9130
9722
  }
9131
9723
  function isUnicodeRegionSubtag(region) {
9132
- return UNICODE_REGION_SUBTAG_REGEX.test(region);
9724
+ return isSubtag(region, 2, 2) || region.length === 3 && isDigit(region.charCodeAt(0)) && isDigit(region.charCodeAt(1)) && isDigit(region.charCodeAt(2));
9133
9725
  }
9134
9726
  function isUnicodeScriptSubtag(script) {
9135
- return ALPHA_4.test(script);
9727
+ return isSubtag(script, 4, 4);
9136
9728
  }
9137
9729
  function isUnicodeVariantSubtag(variant) {
9138
- return UNICODE_VARIANT_SUBTAG_REGEX.test(variant);
9730
+ return isSubtag(variant, 5, 8, true) || isSubtag(variant, 4, 4, true) && isDigit(variant.charCodeAt(0));
9139
9731
  }
9140
9732
  function parseUnicodeLanguageId(chunks) {
9141
9733
  if (typeof chunks === "string") chunks = chunks.split("-");
@@ -9166,15 +9758,15 @@ function parseUnicodeLanguageId(chunks) {
9166
9758
  function parseUnicodeExtension(chunks) {
9167
9759
  const keywords = [];
9168
9760
  let keyword;
9169
- while (chunks.length && (keyword = parseKeyword(chunks))) keywords.push(keyword);
9761
+ while (chunks.length && (keyword = parseKeyword(chunks))) appendToList(keywords, keyword);
9170
9762
  if (keywords.length) return {
9171
9763
  type: "u",
9172
9764
  keywords,
9173
9765
  attributes: []
9174
9766
  };
9175
9767
  const attributes = [];
9176
- while (chunks.length && ALPHANUM_3_8$1.test(chunks[0])) attributes.push(chunks.shift());
9177
- while (chunks.length && (keyword = parseKeyword(chunks))) keywords.push(keyword);
9768
+ while (chunks.length && isSubtag(chunks[0], 3, 8, true)) appendToList(attributes, chunks.shift());
9769
+ while (chunks.length && (keyword = parseKeyword(chunks))) appendToList(keywords, keyword);
9178
9770
  if (keywords.length || attributes.length) return {
9179
9771
  type: "u",
9180
9772
  attributes,
@@ -9184,28 +9776,26 @@ function parseUnicodeExtension(chunks) {
9184
9776
  }
9185
9777
  function parseKeyword(chunks) {
9186
9778
  let key;
9187
- if (!KEY_REGEX.test(chunks[0])) return;
9779
+ if (!isUnicodeKey(chunks[0])) return;
9188
9780
  key = chunks.shift();
9189
9781
  const type = [];
9190
- while (chunks.length && TYPE_REGEX.test(chunks[0])) type.push(chunks.shift());
9782
+ while (chunks.length && isSubtag(chunks[0], 3, 8, true)) appendToList(type, chunks.shift());
9191
9783
  let value = "";
9192
9784
  if (type.length) value = type.join("-");
9193
9785
  return [key, value];
9194
9786
  }
9195
9787
  function parseTransformedExtension(chunks) {
9196
9788
  let lang;
9197
- try {
9198
- lang = parseUnicodeLanguageId(chunks);
9199
- } catch {}
9789
+ if (chunks.length && isUnicodeLanguageSubtag(chunks[0])) lang = parseUnicodeLanguageId(chunks);
9200
9790
  const fields = [];
9201
- while (chunks.length && TKEY_REGEX.test(chunks[0])) {
9791
+ while (chunks.length && isTransformedKey(chunks[0])) {
9202
9792
  const key = chunks.shift();
9203
9793
  const value = [];
9204
- while (chunks.length && ALPHANUM_3_8$1.test(chunks[0])) value.push(chunks.shift());
9794
+ while (chunks.length && isSubtag(chunks[0], 3, 8, true)) appendToList(value, chunks.shift());
9205
9795
  if (!value.length) throw new RangeError(`Missing tvalue for tkey "${key}"`);
9206
- fields.push([key, value.join("-")]);
9796
+ appendToList(fields, [key, value.join("-")]);
9207
9797
  }
9208
- if (fields.length) return {
9798
+ if (lang || fields.length) return {
9209
9799
  type: "t",
9210
9800
  fields,
9211
9801
  lang
@@ -9214,7 +9804,7 @@ function parseTransformedExtension(chunks) {
9214
9804
  }
9215
9805
  function parsePuExtension(chunks) {
9216
9806
  const exts = [];
9217
- while (chunks.length && ALPHANUM_1_8.test(chunks[0])) exts.push(chunks.shift());
9807
+ while (chunks.length && isSubtag(chunks[0], 1, 8, true)) appendToList(exts, chunks.shift());
9218
9808
  if (exts.length) return {
9219
9809
  type: "x",
9220
9810
  value: exts.join("-")
@@ -9223,9 +9813,9 @@ function parsePuExtension(chunks) {
9223
9813
  }
9224
9814
  function parseOtherExtensionValue(chunks) {
9225
9815
  const exts = [];
9226
- while (chunks.length && ALPHANUM_2_8.test(chunks[0])) exts.push(chunks.shift());
9816
+ while (chunks.length && isSubtag(chunks[0], 2, 8, true)) appendToList(exts, chunks.shift());
9227
9817
  if (exts.length) return exts.join("-");
9228
- return "";
9818
+ throw new RangeError("Missing extension value");
9229
9819
  }
9230
9820
  function parseExtensions(chunks) {
9231
9821
  if (!chunks.length) return { extensions: [] };
@@ -9235,36 +9825,35 @@ function parseExtensions(chunks) {
9235
9825
  let puExtension;
9236
9826
  const otherExtensionMap = {};
9237
9827
  do {
9238
- const type = chunks.shift();
9828
+ const type = chunks.shift().toLowerCase();
9239
9829
  switch (type) {
9240
9830
  case "u":
9241
9831
  case "U":
9242
9832
  if (unicodeExtension) throw new RangeError("There can only be 1 -u- extension");
9243
9833
  unicodeExtension = parseUnicodeExtension(chunks);
9244
- extensions.push(unicodeExtension);
9834
+ appendToList(extensions, unicodeExtension);
9245
9835
  break;
9246
9836
  case "t":
9247
9837
  case "T":
9248
9838
  if (transformedExtension) throw new RangeError("There can only be 1 -t- extension");
9249
9839
  transformedExtension = parseTransformedExtension(chunks);
9250
- extensions.push(transformedExtension);
9840
+ appendToList(extensions, transformedExtension);
9251
9841
  break;
9252
9842
  case "x":
9253
9843
  case "X":
9254
9844
  if (puExtension) throw new RangeError("There can only be 1 -x- extension");
9255
9845
  puExtension = parsePuExtension(chunks);
9256
- extensions.push(puExtension);
9846
+ appendToList(extensions, puExtension);
9257
9847
  break;
9258
9848
  default:
9259
- if (!OTHER_EXTENSION_TYPE.test(type)) throw new RangeError("Malformed extension type");
9849
+ if (!isOtherExtensionType(type)) throw new RangeError("Malformed extension type");
9260
9850
  if (type in otherExtensionMap) throw new RangeError(`There can only be 1 -${type}- extension`);
9261
9851
  const extension = {
9262
9852
  type,
9263
9853
  value: parseOtherExtensionValue(chunks)
9264
9854
  };
9265
9855
  otherExtensionMap[extension.type] = extension;
9266
- extensions.push(extension);
9267
- break;
9856
+ appendToList(extensions, extension);
9268
9857
  }
9269
9858
  } while (chunks.length);
9270
9859
  return { extensions };
@@ -9276,12 +9865,53 @@ function parseUnicodeLocaleId(locale) {
9276
9865
  ...parseExtensions(chunks)
9277
9866
  };
9278
9867
  }
9868
+ function compareLanguageAliasRules(a, b) {
9869
+ const fields = (id) => [
9870
+ Number(id.lang !== "und"),
9871
+ Number(!!id.script),
9872
+ Number(!!id.region),
9873
+ id.variants.length
9874
+ ];
9875
+ const left = fields(a.type), right = fields(b.type);
9876
+ const difference = right.reduce((a, b) => a + b, 0) - left.reduce((a, b) => a + b, 0);
9877
+ if (difference) return difference;
9878
+ for (let i = 0; i < left.length; i++) if (!!left[i] !== !!right[i]) return right[i] ? 1 : -1;
9879
+ const leftTag = emitUnicodeLanguageId(a.type), rightTag = emitUnicodeLanguageId(b.type);
9880
+ return leftTag < rightTag ? -1 : leftTag > rightTag ? 1 : 0;
9881
+ }
9882
+ Object.keys(languageAlias).reduce((rules, from) => {
9883
+ const to = languageAlias[from];
9884
+ let type;
9885
+ const source = from.split("-");
9886
+ try {
9887
+ type = parseUnicodeLanguageId(source);
9888
+ } catch {
9889
+ return rules;
9890
+ }
9891
+ if (source.length) return rules;
9892
+ const target = to.split("-");
9893
+ const replacement = parseUnicodeLanguageId(target);
9894
+ if (target.length) throw new Error(`Invalid language alias replacement: ${to}`);
9895
+ appendToList(rules, {
9896
+ type,
9897
+ replacement
9898
+ });
9899
+ return rules;
9900
+ }, []).sort(compareLanguageAliasRules).reduce((groups, rule) => {
9901
+ appendToList(groups[rule.type.lang] ||= [], rule);
9902
+ return groups;
9903
+ }, Object.create(null));
9904
+ typeof Intl !== "undefined" && Intl.Locale?.prototype.toString;
9279
9905
  //#endregion
9280
9906
  //#region packages/intl-locale/get_internal_slots.ts
9281
9907
  const internalSlotMap = /* @__PURE__ */ new WeakMap();
9282
- function getInternalSlots(x, internalSlotsList = []) {
9908
+ function getInternalSlotsIfPresent(x) {
9909
+ return internalSlotMap.get(x);
9910
+ }
9911
+ function getInternalSlots(x, internalSlotsList) {
9283
9912
  let internalSlots = internalSlotMap.get(x);
9284
9913
  if (!internalSlots) {
9914
+ if (internalSlotsList === void 0) throw new TypeError("Intl.Locale method called on incompatible receiver");
9285
9915
  internalSlots = Object.create(null, internalSlotsList.reduce((all, prop) => {
9286
9916
  all[prop] = {
9287
9917
  enumerable: false,
@@ -9296,29 +9926,36 @@ function getInternalSlots(x, internalSlotsList = []) {
9296
9926
  }
9297
9927
  //#endregion
9298
9928
  //#region packages/intl-locale/preference-data.ts
9299
- function getCalendarPreferenceDataForRegion(region) {
9300
- return (calendars[(region ? region.toUpperCase() : null) || ""] || calendars["001"]).map((c) => {
9301
- if (c === "gregorian") return "gregory";
9302
- if (c === "islamic-civil") return "islamicc";
9303
- return c;
9304
- });
9929
+ function getCalendarPreferenceDataForRegion(region, regionOverride, language) {
9930
+ for (const candidate of [regionOverride, region]) {
9931
+ if (!candidate) continue;
9932
+ const territory = candidate.toUpperCase();
9933
+ const values = calendars[`${language}-${territory}`] || calendars[territory];
9934
+ if (values) return values.map((c) => c === "gregorian" ? "gregory" : c);
9935
+ }
9936
+ return ["gregory"];
9305
9937
  }
9306
- function getHourCyclesPreferenceDataForLocaleOrRegion(locale, region) {
9307
- const _locale = locale.toLowerCase();
9308
- const _region = region ? region.toUpperCase() : "";
9309
- return [...hourCycles[_locale] || hourCycles[_region] || hourCycles[`${_locale}-001`] || hourCycles["001"]];
9938
+ function getHourCyclesPreferenceDataForLocaleOrRegion(language, region, regionOverride) {
9939
+ for (const candidate of [regionOverride, region]) {
9940
+ if (!candidate) continue;
9941
+ const territory = candidate.toUpperCase();
9942
+ const values = hourCycles[`${language}-${territory}`] || hourCycles[territory];
9943
+ if (values) return [...values];
9944
+ }
9945
+ return ["h23"];
9310
9946
  }
9311
9947
  function getTimeZonePreferenceForRegion(region) {
9312
9948
  const territory = region.toLowerCase();
9313
9949
  if (timezones[territory]) return [...timezones[territory]];
9314
9950
  return [];
9315
9951
  }
9316
- function getWeekDataForRegion(region) {
9317
- return weekData[(region ? region.toUpperCase() : "") || "001"] || weekData["001"];
9952
+ function getWeekDataForRegion(region, regionOverride) {
9953
+ const _region = region ? region.toUpperCase() : "";
9954
+ const override = (regionOverride || "").toUpperCase();
9955
+ return weekData[override] || weekData[_region] || weekData["001"];
9318
9956
  }
9319
9957
  //#endregion
9320
9958
  //#region packages/intl-locale/index.ts
9321
- const ALPHANUM_3_8 = /^[a-z0-9]{3,8}$/i;
9322
9959
  const RELEVANT_EXTENSION_KEYS = [
9323
9960
  "ca",
9324
9961
  "co",
@@ -9328,17 +9965,23 @@ const RELEVANT_EXTENSION_KEYS = [
9328
9965
  "nu",
9329
9966
  "fw"
9330
9967
  ];
9331
- const UNICODE_TYPE_REGEX = /^[a-z0-9]{3,8}(-[a-z0-9]{3,8})*$/i;
9332
9968
  function applyOptionsToTag(tag, options) {
9333
9969
  invariant(typeof tag === "string", "language tag must be a string");
9334
9970
  invariant(isStructurallyValidLanguageTag(tag), "malformed language tag", RangeError);
9971
+ tag = Intl.getCanonicalLocales(tag)[0];
9335
9972
  const language = GetOption(options, "language", "string", void 0, void 0);
9336
9973
  if (language !== void 0) invariant(isUnicodeLanguageSubtag(language), "Malformed unicode_language_subtag", RangeError);
9337
9974
  const script = GetOption(options, "script", "string", void 0, void 0);
9338
9975
  if (script !== void 0) invariant(isUnicodeScriptSubtag(script), "Malformed unicode_script_subtag", RangeError);
9339
9976
  const region = GetOption(options, "region", "string", void 0, void 0);
9340
9977
  if (region !== void 0) invariant(isUnicodeRegionSubtag(region), "Malformed unicode_region_subtag", RangeError);
9978
+ const variants = GetOption(options, "variants", "string", void 0, void 0);
9341
9979
  const languageId = parseUnicodeLanguageId(tag);
9980
+ if (variants !== void 0) {
9981
+ const subtags = variants.replace(/[A-Z]/g, (character) => character.toLowerCase()).split("-");
9982
+ if (subtags.some((variant) => !isUnicodeVariantSubtag(variant)) || new Set(subtags).size !== subtags.length) throw new RangeError("Malformed unicode_variant_subtag");
9983
+ languageId.variants = subtags;
9984
+ }
9342
9985
  if (language !== void 0) languageId.lang = language;
9343
9986
  if (script !== void 0) languageId.script = script;
9344
9987
  if (region !== void 0) languageId.region = region;
@@ -9380,6 +10023,8 @@ function applyUnicodeExtensionToTag(tag, options, relevantExtensionKeys) {
9380
10023
  });
9381
10024
  } else unicodeExtension.keywords = keywords;
9382
10025
  result.locale = Intl.getCanonicalLocales(emitUnicodeLocaleId(ast))[0];
10026
+ const canonicalExtension = parseUnicodeLocaleId(result.locale).extensions.find((extension) => extension.type === "u");
10027
+ for (const key of relevantExtensionKeys) result[key] = canonicalExtension?.keywords.find((keyword) => keyword[0] === key)?.[1];
9383
10028
  return result;
9384
10029
  }
9385
10030
  function mergeUnicodeLanguageId(lang, script, region, variants = [], replacement) {
@@ -9398,49 +10043,38 @@ function mergeUnicodeLanguageId(lang, script, region, variants = [], replacement
9398
10043
  }
9399
10044
  function addLikelySubtags(tag) {
9400
10045
  const ast = parseUnicodeLocaleId(tag);
9401
- const { lang, script, region, variants } = ast.lang;
9402
- if (script && region) {
9403
- const match = likelySubtags[emitUnicodeLanguageId({
10046
+ const { lang, variants } = ast.lang;
10047
+ const script = ast.lang.script === "Zzzz" ? void 0 : ast.lang.script;
10048
+ const region = ast.lang.region === "ZZ" ? void 0 : ast.lang.region;
10049
+ if (lang !== "und" && script && region) return tag;
10050
+ for (const candidate of [
10051
+ {
9404
10052
  lang,
9405
10053
  script,
9406
10054
  region,
9407
10055
  variants: []
9408
- })];
9409
- if (match) {
9410
- ast.lang = mergeUnicodeLanguageId(void 0, void 0, void 0, variants, parseUnicodeLanguageId(match));
9411
- return emitUnicodeLocaleId(ast);
9412
- }
9413
- }
9414
- if (script) {
9415
- const match = likelySubtags[emitUnicodeLanguageId({
10056
+ },
10057
+ {
9416
10058
  lang,
9417
10059
  script,
9418
10060
  variants: []
9419
- })];
9420
- if (match) {
9421
- ast.lang = mergeUnicodeLanguageId(void 0, void 0, region, variants, parseUnicodeLanguageId(match));
9422
- return emitUnicodeLocaleId(ast);
9423
- }
9424
- }
9425
- if (region) {
9426
- const match = likelySubtags[emitUnicodeLanguageId({
10061
+ },
10062
+ {
9427
10063
  lang,
9428
10064
  region,
9429
10065
  variants: []
9430
- })];
9431
- if (match) {
9432
- ast.lang = mergeUnicodeLanguageId(void 0, script, void 0, variants, parseUnicodeLanguageId(match));
9433
- return emitUnicodeLocaleId(ast);
10066
+ },
10067
+ {
10068
+ lang,
10069
+ variants: []
9434
10070
  }
10071
+ ]) {
10072
+ const match = likelySubtags[emitUnicodeLanguageId(candidate)];
10073
+ if (!match) continue;
10074
+ ast.lang = mergeUnicodeLanguageId(lang, script, region, variants, parseUnicodeLanguageId(match));
10075
+ return emitUnicodeLocaleId(ast);
9435
10076
  }
9436
- const match = likelySubtags[lang] || likelySubtags[emitUnicodeLanguageId({
9437
- lang: "und",
9438
- script,
9439
- variants: []
9440
- })];
9441
- if (!match) throw new Error(`No match for addLikelySubtags`);
9442
- ast.lang = mergeUnicodeLanguageId(void 0, script, region, variants, parseUnicodeLanguageId(match));
9443
- return emitUnicodeLocaleId(ast);
10077
+ return tag;
9444
10078
  }
9445
10079
  /**
9446
10080
  * From: https://github.com/unicode-org/icu/blob/4231ca5be053a22a1be24eb891817458c97db709/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java#L2395
@@ -9449,11 +10083,11 @@ function addLikelySubtags(tag) {
9449
10083
  function removeLikelySubtags(tag) {
9450
10084
  let maxLocale = addLikelySubtags(tag);
9451
10085
  if (!maxLocale) return tag;
10086
+ const ast = parseUnicodeLocaleId(maxLocale);
9452
10087
  maxLocale = emitUnicodeLanguageId({
9453
10088
  ...parseUnicodeLanguageId(maxLocale),
9454
10089
  variants: []
9455
10090
  });
9456
- const ast = parseUnicodeLocaleId(tag);
9457
10091
  const { lang: { lang, script, region, variants } } = ast;
9458
10092
  if (addLikelySubtags(emitUnicodeLanguageId({
9459
10093
  lang,
@@ -9482,7 +10116,7 @@ function removeLikelySubtags(tag) {
9482
10116
  lang: mergeUnicodeLanguageId(lang, script, void 0, variants)
9483
10117
  });
9484
10118
  }
9485
- return tag;
10119
+ return emitUnicodeLocaleId(ast);
9486
10120
  }
9487
10121
  function createArrayFromListOrRestricted(list, restricted) {
9488
10122
  let result = list;
@@ -9493,13 +10127,19 @@ function calendarsOfLocale(loc) {
9493
10127
  const locInternalSlots = getInternalSlots(loc);
9494
10128
  const restricted = locInternalSlots.calendar;
9495
10129
  const locale = locInternalSlots.locale;
9496
- let region;
9497
- if (locale !== "root") region = loc.maximize().region;
9498
- return createArrayFromListOrRestricted(getCalendarPreferenceDataForRegion(region), restricted);
10130
+ const { region, regionOverride } = regionPreference(loc);
10131
+ return createArrayFromListOrRestricted(getCalendarPreferenceDataForRegion(region, regionOverride, parseUnicodeLanguageId(locale).lang), restricted);
9499
10132
  }
9500
10133
  function collationsOfLocale(loc) {
9501
- const restricted = getInternalSlots(loc).collation;
9502
- const supportedCollations = supportedValuesOf("collation").filter((co) => co !== "standard" && co !== "search");
10134
+ const locInternalSlots = getInternalSlots(loc);
10135
+ const restricted = locInternalSlots.collation;
10136
+ if (restricted !== void 0) return [restricted];
10137
+ const locale = locInternalSlots.locale;
10138
+ if (!Intl.Collator.supportedLocalesOf([locale], { localeMatcher: "lookup" }).length) return ["emoji", "eor"];
10139
+ const supportedCollations = supportedValuesOf("collation").filter((co) => co !== "standard" && co !== "search" && new Intl.Collator(locale, {
10140
+ collation: co,
10141
+ localeMatcher: "lookup"
10142
+ }).resolvedOptions().collation === co);
9503
10143
  supportedCollations.sort();
9504
10144
  return createArrayFromListOrRestricted(supportedCollations, restricted);
9505
10145
  }
@@ -9507,9 +10147,8 @@ function hourCyclesOfLocale(loc) {
9507
10147
  const locInternalSlots = getInternalSlots(loc);
9508
10148
  const restricted = locInternalSlots.hourCycle;
9509
10149
  const locale = locInternalSlots.locale;
9510
- let region;
9511
- if (locale !== "root") region = loc.maximize().region;
9512
- return createArrayFromListOrRestricted(getHourCyclesPreferenceDataForLocaleOrRegion(locale, region), restricted);
10150
+ const { region, regionOverride } = regionPreference(loc);
10151
+ return createArrayFromListOrRestricted(getHourCyclesPreferenceDataForLocaleOrRegion(parseUnicodeLanguageId(locale).lang, region, regionOverride), restricted);
9513
10152
  }
9514
10153
  function numberingSystemsOfLocale(loc) {
9515
10154
  const locInternalSlots = getInternalSlots(loc);
@@ -9533,13 +10172,25 @@ function translateCharacterOrder(order) {
9533
10172
  return "ltr";
9534
10173
  }
9535
10174
  function characterDirectionOfLocale(loc) {
9536
- return translateCharacterOrder(characterOrders[loc.minimize().toString()]);
10175
+ const locale = loc.minimize().toString();
10176
+ return translateCharacterOrder(characterOrders[locale]);
9537
10177
  }
9538
- function weekInfoOfLocale(loc) {
10178
+ function regionPreference(loc) {
9539
10179
  const locale = getInternalSlots(loc).locale;
9540
- let region;
9541
- if (locale !== "root") region = loc.maximize().region;
9542
- return getWeekDataForRegion(region);
10180
+ const ast = parseUnicodeLocaleId(locale);
10181
+ const extension = ast.extensions.find((ext) => ext.type === "u");
10182
+ const subdivisionRegion = (key) => {
10183
+ const match = (extension?.keywords.find((entry) => entry[0] === key)?.[1])?.match(/^([a-z]{2}|[0-9]{3})[a-z0-9]{1,4}$/i);
10184
+ return match ? new Locale(`und-${match[1]}`).region : void 0;
10185
+ };
10186
+ return {
10187
+ region: ast.lang.region || subdivisionRegion("sd") || parseUnicodeLanguageId(addLikelySubtags(locale)).region || "001",
10188
+ regionOverride: subdivisionRegion("rg")
10189
+ };
10190
+ }
10191
+ function weekInfoOfLocale(loc) {
10192
+ const { region, regionOverride } = regionPreference(loc);
10193
+ return getWeekDataForRegion(region, regionOverride);
9543
10194
  }
9544
10195
  const TABLE_1 = [
9545
10196
  "sun",
@@ -9551,7 +10202,7 @@ const TABLE_1 = [
9551
10202
  "sat"
9552
10203
  ];
9553
10204
  function weekdayToString(fw) {
9554
- return TABLE_1[+fw];
10205
+ return /^[0-7]$/.test(fw) ? TABLE_1[Number(fw) % 7] : fw;
9555
10206
  }
9556
10207
  var Locale = class Locale {
9557
10208
  constructor(tag, opts) {
@@ -9568,30 +10219,30 @@ var Locale = class Locale {
9568
10219
  if (relevantExtensionKeys.indexOf("kf") > -1) internalSlotsList.push("caseFirst");
9569
10220
  if (relevantExtensionKeys.indexOf("kn") > -1) internalSlotsList.push("numeric");
9570
10221
  if (tag === void 0) throw new TypeError("First argument to Intl.Locale constructor can't be empty or missing");
9571
- if (typeof tag !== "string" && typeof tag !== "object") throw new TypeError("tag must be a string or object");
10222
+ if (tag === null || typeof tag !== "string" && typeof tag !== "object" && typeof tag !== "function") throw new TypeError("tag must be a string or object");
9572
10223
  let tagInternalSlots;
9573
- if (typeof tag === "object" && (tagInternalSlots = getInternalSlots(tag)) && HasOwnProperty(tagInternalSlots, "initializedLocale")) tag = tagInternalSlots.locale;
9574
- else tag = tag.toString();
10224
+ if (typeof tag === "object" && (tagInternalSlots = getInternalSlotsIfPresent(tag)) && HasOwnProperty(tagInternalSlots, "initializedLocale")) tag = tagInternalSlots.locale;
10225
+ else tag = ToString$1(tag);
9575
10226
  let internalSlots = getInternalSlots(this, internalSlotsList);
9576
10227
  let options = CoerceOptionsToObject(opts);
9577
10228
  tag = applyOptionsToTag(tag, options);
9578
10229
  const opt = Object.create(null);
9579
10230
  const calendar = GetOption(options, "calendar", "string", void 0, void 0);
9580
10231
  if (calendar !== void 0) {
9581
- if (!UNICODE_TYPE_REGEX.test(calendar)) throw new RangeError("invalid calendar");
10232
+ if (!IsUnicodeLocaleIdentifierType(calendar)) throw new RangeError("invalid calendar");
9582
10233
  }
9583
10234
  opt.ca = calendar;
9584
10235
  const collation = GetOption(options, "collation", "string", void 0, void 0);
9585
10236
  if (collation !== void 0) {
9586
- if (!UNICODE_TYPE_REGEX.test(collation)) throw new RangeError("invalid collation");
10237
+ if (!IsUnicodeLocaleIdentifierType(collation)) throw new RangeError("invalid collation");
9587
10238
  }
9588
10239
  opt.co = collation;
9589
10240
  let fw = GetOption(options, "firstDayOfWeek", "string", void 0, void 0);
9590
10241
  if (fw !== void 0) {
9591
10242
  fw = weekdayToString(fw);
9592
- if (!ALPHANUM_3_8.test(fw)) throw new RangeError("Invalid firstDayOfWeek");
10243
+ if (!IsUnicodeLocaleIdentifierType(fw)) throw new RangeError("Invalid firstDayOfWeek");
9593
10244
  }
9594
- opt.fw = fw;
10245
+ opt.fw = fw?.toLowerCase();
9595
10246
  opt.hc = GetOption(options, "hourCycle", "string", [
9596
10247
  "h11",
9597
10248
  "h12",
@@ -9609,7 +10260,7 @@ var Locale = class Locale {
9609
10260
  opt.kn = kn;
9610
10261
  const numberingSystem = GetOption(options, "numberingSystem", "string", void 0, void 0);
9611
10262
  if (numberingSystem !== void 0) {
9612
- if (!UNICODE_TYPE_REGEX.test(numberingSystem)) throw new RangeError("Invalid numberingSystem");
10263
+ if (!IsUnicodeLocaleIdentifierType(numberingSystem)) throw new RangeError("Invalid numberingSystem");
9613
10264
  }
9614
10265
  opt.nu = numberingSystem;
9615
10266
  const r = applyUnicodeExtensionToTag(tag, opt, relevantExtensionKeys);
@@ -9619,7 +10270,7 @@ var Locale = class Locale {
9619
10270
  internalSlots.firstDayOfWeek = r.fw;
9620
10271
  internalSlots.hourCycle = r.hc;
9621
10272
  if (relevantExtensionKeys.indexOf("kf") > -1) internalSlots.caseFirst = r.kf;
9622
- if (relevantExtensionKeys.indexOf("kn") > -1) internalSlots.numeric = SameValue(r.kn, "true");
10273
+ if (relevantExtensionKeys.indexOf("kn") > -1) internalSlots.numeric = r.kn === "" || SameValue(r.kn, "true");
9623
10274
  internalSlots.numberingSystem = r.nu;
9624
10275
  }
9625
10276
  /**
@@ -9628,7 +10279,8 @@ var Locale = class Locale {
9628
10279
  maximize() {
9629
10280
  const locale = getInternalSlots(this).locale;
9630
10281
  try {
9631
- return new Locale(addLikelySubtags(locale));
10282
+ const maximizedLocale = addLikelySubtags(locale);
10283
+ return new Locale(maximizedLocale);
9632
10284
  } catch {
9633
10285
  return new Locale(locale);
9634
10286
  }
@@ -9639,13 +10291,16 @@ var Locale = class Locale {
9639
10291
  minimize() {
9640
10292
  const locale = getInternalSlots(this).locale;
9641
10293
  try {
9642
- return new Locale(removeLikelySubtags(locale));
10294
+ const minimizedLocale = removeLikelySubtags(locale);
10295
+ return new Locale(minimizedLocale);
9643
10296
  } catch {
9644
10297
  return new Locale(locale);
9645
10298
  }
9646
10299
  }
9647
10300
  toString() {
9648
- return getInternalSlots(this).locale;
10301
+ const slots = getInternalSlots(this);
10302
+ if (!HasOwnProperty(slots, "initializedLocale")) throw new TypeError("Error uninitialized locale");
10303
+ return slots.locale;
9649
10304
  }
9650
10305
  get baseName() {
9651
10306
  const locale = getInternalSlots(this).locale;
@@ -9759,7 +10414,9 @@ var Locale = class Locale {
9759
10414
  }
9760
10415
  /**
9761
10416
  * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo
9762
- * https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getWeekInfo
10417
+ * ECMA-402 §15.3.22 Intl.Locale.prototype.getWeekInfo, steps 3–7.
10418
+ * https://tc39.es/ecma402/#sec-Intl.Locale.prototype.getWeekInfo
10419
+ * https://github.com/tc39/ecma402/blob/b1c961988b9a07894b1dc3dc2b5626ea48387d61/spec/locale.html#L420-L424
9763
10420
  */
9764
10421
  getWeekInfo() {
9765
10422
  const info = Object.create(Object.prototype);
@@ -9768,10 +10425,10 @@ var Locale = class Locale {
9768
10425
  const wi = weekInfoOfLocale(this);
9769
10426
  const we = wi.weekend;
9770
10427
  createDataProperty(info, "firstDay", wi.firstDay);
9771
- createDataProperty(info, "weekend", we);
9772
- createDataProperty(info, "minimalDays", wi.minimalDays);
10428
+ createDataProperty(info, "weekend", [...we]);
9773
10429
  const fw = internalSlots.firstDayOfWeek;
9774
- if (fw !== void 0) info.firstDay = fw;
10430
+ const day = TABLE_1.indexOf(fw);
10431
+ if (day !== -1) info.firstDay = day || 7;
9775
10432
  return info;
9776
10433
  }
9777
10434
  static {