@equinor/roma-framework 6.0.1-beta.4 → 6.0.1-beta.6
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/{_commonjsHelpers-CIHTj2Un.mjs → _commonjsHelpers-DKlypwS6.mjs} +4 -3724
- package/cypress.mjs +2 -1
- package/dev-portal/package.json +2 -2
- package/dev-portal/roma-framework.umd.js +11961 -71434
- package/package.json +2 -2
- package/roma-framework.mjs +3 -2
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React3 from "react";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
2
|
var extendStatics = function(d, b) {
|
|
4
3
|
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
5
4
|
d2.__proto__ = b2;
|
|
@@ -535,13 +534,13 @@ function handleUnhandledError(error) {
|
|
|
535
534
|
reportUnhandledError(error);
|
|
536
535
|
}
|
|
537
536
|
}
|
|
538
|
-
function defaultErrorHandler
|
|
537
|
+
function defaultErrorHandler(err) {
|
|
539
538
|
throw err;
|
|
540
539
|
}
|
|
541
540
|
var EMPTY_OBSERVER = {
|
|
542
541
|
closed: true,
|
|
543
542
|
next: noop,
|
|
544
|
-
error: defaultErrorHandler
|
|
543
|
+
error: defaultErrorHandler,
|
|
545
544
|
complete: noop
|
|
546
545
|
};
|
|
547
546
|
var observable = (function() {
|
|
@@ -1062,7 +1061,7 @@ function fromIterable(iterable) {
|
|
|
1062
1061
|
}
|
|
1063
1062
|
function fromAsyncIterable(asyncIterable) {
|
|
1064
1063
|
return new Observable(function(subscriber) {
|
|
1065
|
-
process
|
|
1064
|
+
process(asyncIterable, subscriber).catch(function(err) {
|
|
1066
1065
|
return subscriber.error(err);
|
|
1067
1066
|
});
|
|
1068
1067
|
});
|
|
@@ -1070,7 +1069,7 @@ function fromAsyncIterable(asyncIterable) {
|
|
|
1070
1069
|
function fromReadableStreamLike(readableStream) {
|
|
1071
1070
|
return fromAsyncIterable(readableStreamLikeToAsyncGenerator(readableStream));
|
|
1072
1071
|
}
|
|
1073
|
-
function process
|
|
1072
|
+
function process(asyncIterable, subscriber) {
|
|
1074
1073
|
var asyncIterable_1, asyncIterable_1_1;
|
|
1075
1074
|
var e_2, _a;
|
|
1076
1075
|
return __awaiter(this, void 0, void 0, function() {
|
|
@@ -1298,3724 +1297,6 @@ function firstValueFrom(source, config2) {
|
|
|
1298
1297
|
source.subscribe(subscriber);
|
|
1299
1298
|
});
|
|
1300
1299
|
}
|
|
1301
|
-
function memoize(fn, options) {
|
|
1302
|
-
const cache = options && options.cache ? options.cache : cacheDefault;
|
|
1303
|
-
const serializer = options && options.serializer ? options.serializer : serializerDefault;
|
|
1304
|
-
const strategy = options && options.strategy ? options.strategy : strategyDefault;
|
|
1305
|
-
return strategy(fn, {
|
|
1306
|
-
cache,
|
|
1307
|
-
serializer
|
|
1308
|
-
});
|
|
1309
|
-
}
|
|
1310
|
-
function isPrimitive(value) {
|
|
1311
|
-
return value == null || typeof value === "number" || typeof value === "boolean";
|
|
1312
|
-
}
|
|
1313
|
-
function monadic(fn, cache, serializer, arg) {
|
|
1314
|
-
const cacheKey = isPrimitive(arg) ? arg : serializer(arg);
|
|
1315
|
-
let computedValue = cache.get(cacheKey);
|
|
1316
|
-
if (typeof computedValue === "undefined") {
|
|
1317
|
-
computedValue = fn.call(this, arg);
|
|
1318
|
-
cache.set(cacheKey, computedValue);
|
|
1319
|
-
}
|
|
1320
|
-
return computedValue;
|
|
1321
|
-
}
|
|
1322
|
-
function variadic(fn, cache, serializer) {
|
|
1323
|
-
const args = Array.prototype.slice.call(arguments, 3);
|
|
1324
|
-
const cacheKey = serializer(args);
|
|
1325
|
-
let computedValue = cache.get(cacheKey);
|
|
1326
|
-
if (typeof computedValue === "undefined") {
|
|
1327
|
-
computedValue = fn.apply(this, args);
|
|
1328
|
-
cache.set(cacheKey, computedValue);
|
|
1329
|
-
}
|
|
1330
|
-
return computedValue;
|
|
1331
|
-
}
|
|
1332
|
-
function assemble(fn, context, strategy, cache, serialize) {
|
|
1333
|
-
return strategy.bind(context, fn, cache, serialize);
|
|
1334
|
-
}
|
|
1335
|
-
function strategyDefault(fn, options) {
|
|
1336
|
-
const strategy = fn.length === 1 ? monadic : variadic;
|
|
1337
|
-
return assemble(fn, this, strategy, options.cache.create(), options.serializer);
|
|
1338
|
-
}
|
|
1339
|
-
function strategyVariadic(fn, options) {
|
|
1340
|
-
return assemble(fn, this, variadic, options.cache.create(), options.serializer);
|
|
1341
|
-
}
|
|
1342
|
-
const serializerDefault = function() {
|
|
1343
|
-
return JSON.stringify(arguments);
|
|
1344
|
-
};
|
|
1345
|
-
class ObjectWithoutPrototypeCache {
|
|
1346
|
-
cache;
|
|
1347
|
-
constructor() {
|
|
1348
|
-
this.cache = /* @__PURE__ */ Object.create(null);
|
|
1349
|
-
}
|
|
1350
|
-
get(key) {
|
|
1351
|
-
return this.cache[key];
|
|
1352
|
-
}
|
|
1353
|
-
set(key, value) {
|
|
1354
|
-
this.cache[key] = value;
|
|
1355
|
-
}
|
|
1356
|
-
}
|
|
1357
|
-
const cacheDefault = { create: function create() {
|
|
1358
|
-
return new ObjectWithoutPrototypeCache();
|
|
1359
|
-
} };
|
|
1360
|
-
const strategies = {
|
|
1361
|
-
variadic: strategyVariadic
|
|
1362
|
-
};
|
|
1363
|
-
const DATE_TIME_REGEX = /(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;
|
|
1364
|
-
function parseDateTimeSkeleton(skeleton) {
|
|
1365
|
-
const result = {};
|
|
1366
|
-
skeleton.replace(DATE_TIME_REGEX, (match) => {
|
|
1367
|
-
const len = match.length;
|
|
1368
|
-
switch (match[0]) {
|
|
1369
|
-
case "G":
|
|
1370
|
-
result.era = len === 4 ? "long" : len === 5 ? "narrow" : "short";
|
|
1371
|
-
break;
|
|
1372
|
-
case "y":
|
|
1373
|
-
result.year = len === 2 ? "2-digit" : "numeric";
|
|
1374
|
-
break;
|
|
1375
|
-
case "Y":
|
|
1376
|
-
case "u":
|
|
1377
|
-
case "U":
|
|
1378
|
-
case "r":
|
|
1379
|
-
throw new RangeError("`Y/u/U/r` (year) patterns are not supported, use `y` instead");
|
|
1380
|
-
case "q":
|
|
1381
|
-
case "Q":
|
|
1382
|
-
throw new RangeError("`q/Q` (quarter) patterns are not supported");
|
|
1383
|
-
case "M":
|
|
1384
|
-
case "L":
|
|
1385
|
-
result.month = [
|
|
1386
|
-
"numeric",
|
|
1387
|
-
"2-digit",
|
|
1388
|
-
"short",
|
|
1389
|
-
"long",
|
|
1390
|
-
"narrow"
|
|
1391
|
-
][len - 1];
|
|
1392
|
-
break;
|
|
1393
|
-
case "w":
|
|
1394
|
-
case "W":
|
|
1395
|
-
throw new RangeError("`w/W` (week) patterns are not supported");
|
|
1396
|
-
case "d":
|
|
1397
|
-
result.day = ["numeric", "2-digit"][len - 1];
|
|
1398
|
-
break;
|
|
1399
|
-
case "D":
|
|
1400
|
-
case "F":
|
|
1401
|
-
case "g":
|
|
1402
|
-
throw new RangeError("`D/F/g` (day) patterns are not supported, use `d` instead");
|
|
1403
|
-
case "E":
|
|
1404
|
-
result.weekday = len === 4 ? "long" : len === 5 ? "narrow" : "short";
|
|
1405
|
-
break;
|
|
1406
|
-
case "e":
|
|
1407
|
-
if (len < 4) {
|
|
1408
|
-
throw new RangeError("`e..eee` (weekday) patterns are not supported");
|
|
1409
|
-
}
|
|
1410
|
-
result.weekday = [
|
|
1411
|
-
"short",
|
|
1412
|
-
"long",
|
|
1413
|
-
"narrow",
|
|
1414
|
-
"short"
|
|
1415
|
-
][len - 4];
|
|
1416
|
-
break;
|
|
1417
|
-
case "c":
|
|
1418
|
-
if (len < 4) {
|
|
1419
|
-
throw new RangeError("`c..ccc` (weekday) patterns are not supported");
|
|
1420
|
-
}
|
|
1421
|
-
result.weekday = [
|
|
1422
|
-
"short",
|
|
1423
|
-
"long",
|
|
1424
|
-
"narrow",
|
|
1425
|
-
"short"
|
|
1426
|
-
][len - 4];
|
|
1427
|
-
break;
|
|
1428
|
-
case "a":
|
|
1429
|
-
result.hour12 = true;
|
|
1430
|
-
break;
|
|
1431
|
-
case "b":
|
|
1432
|
-
case "B":
|
|
1433
|
-
throw new RangeError("`b/B` (period) patterns are not supported, use `a` instead");
|
|
1434
|
-
case "h":
|
|
1435
|
-
result.hourCycle = "h12";
|
|
1436
|
-
result.hour = ["numeric", "2-digit"][len - 1];
|
|
1437
|
-
break;
|
|
1438
|
-
case "H":
|
|
1439
|
-
result.hourCycle = "h23";
|
|
1440
|
-
result.hour = ["numeric", "2-digit"][len - 1];
|
|
1441
|
-
break;
|
|
1442
|
-
case "K":
|
|
1443
|
-
result.hourCycle = "h11";
|
|
1444
|
-
result.hour = ["numeric", "2-digit"][len - 1];
|
|
1445
|
-
break;
|
|
1446
|
-
case "k":
|
|
1447
|
-
result.hourCycle = "h24";
|
|
1448
|
-
result.hour = ["numeric", "2-digit"][len - 1];
|
|
1449
|
-
break;
|
|
1450
|
-
case "j":
|
|
1451
|
-
case "J":
|
|
1452
|
-
case "C":
|
|
1453
|
-
throw new RangeError("`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead");
|
|
1454
|
-
case "m":
|
|
1455
|
-
result.minute = ["numeric", "2-digit"][len - 1];
|
|
1456
|
-
break;
|
|
1457
|
-
case "s":
|
|
1458
|
-
result.second = ["numeric", "2-digit"][len - 1];
|
|
1459
|
-
break;
|
|
1460
|
-
case "S":
|
|
1461
|
-
case "A":
|
|
1462
|
-
throw new RangeError("`S/A` (second) patterns are not supported, use `s` instead");
|
|
1463
|
-
case "z":
|
|
1464
|
-
result.timeZoneName = len < 4 ? "short" : "long";
|
|
1465
|
-
break;
|
|
1466
|
-
case "Z":
|
|
1467
|
-
case "O":
|
|
1468
|
-
case "v":
|
|
1469
|
-
case "V":
|
|
1470
|
-
case "X":
|
|
1471
|
-
case "x":
|
|
1472
|
-
throw new RangeError("`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead");
|
|
1473
|
-
}
|
|
1474
|
-
return "";
|
|
1475
|
-
});
|
|
1476
|
-
return result;
|
|
1477
|
-
}
|
|
1478
|
-
const WHITE_SPACE_REGEX = /[\t-\r \x85\u200E\u200F\u2028\u2029]/i;
|
|
1479
|
-
function parseNumberSkeletonFromString(skeleton) {
|
|
1480
|
-
if (skeleton.length === 0) {
|
|
1481
|
-
throw new Error("Number skeleton cannot be empty");
|
|
1482
|
-
}
|
|
1483
|
-
const stringTokens = skeleton.split(WHITE_SPACE_REGEX).filter((x) => x.length > 0);
|
|
1484
|
-
const tokens = [];
|
|
1485
|
-
for (const stringToken of stringTokens) {
|
|
1486
|
-
let stemAndOptions = stringToken.split("/");
|
|
1487
|
-
if (stemAndOptions.length === 0) {
|
|
1488
|
-
throw new Error("Invalid number skeleton");
|
|
1489
|
-
}
|
|
1490
|
-
const [stem, ...options] = stemAndOptions;
|
|
1491
|
-
for (const option of options) {
|
|
1492
|
-
if (option.length === 0) {
|
|
1493
|
-
throw new Error("Invalid number skeleton");
|
|
1494
|
-
}
|
|
1495
|
-
}
|
|
1496
|
-
tokens.push({
|
|
1497
|
-
stem,
|
|
1498
|
-
options
|
|
1499
|
-
});
|
|
1500
|
-
}
|
|
1501
|
-
return tokens;
|
|
1502
|
-
}
|
|
1503
|
-
function icuUnitToEcma(unit) {
|
|
1504
|
-
return unit.replace(/^(.*?)-/, "");
|
|
1505
|
-
}
|
|
1506
|
-
const FRACTION_PRECISION_REGEX = /^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g;
|
|
1507
|
-
const SIGNIFICANT_PRECISION_REGEX = /^(@+)?(\+|#+)?[rs]?$/g;
|
|
1508
|
-
const INTEGER_WIDTH_REGEX = /(\*)(0+)|(#+)(0+)|(0+)/g;
|
|
1509
|
-
const CONCISE_INTEGER_WIDTH_REGEX = /^(0+)$/;
|
|
1510
|
-
function parseSignificantPrecision(str) {
|
|
1511
|
-
const result = {};
|
|
1512
|
-
if (str[str.length - 1] === "r") {
|
|
1513
|
-
result.roundingPriority = "morePrecision";
|
|
1514
|
-
} else if (str[str.length - 1] === "s") {
|
|
1515
|
-
result.roundingPriority = "lessPrecision";
|
|
1516
|
-
}
|
|
1517
|
-
str.replace(SIGNIFICANT_PRECISION_REGEX, function(_, g1, g2) {
|
|
1518
|
-
if (typeof g2 !== "string") {
|
|
1519
|
-
result.minimumSignificantDigits = g1.length;
|
|
1520
|
-
result.maximumSignificantDigits = g1.length;
|
|
1521
|
-
} else if (g2 === "+") {
|
|
1522
|
-
result.minimumSignificantDigits = g1.length;
|
|
1523
|
-
} else if (g1[0] === "#") {
|
|
1524
|
-
result.maximumSignificantDigits = g1.length;
|
|
1525
|
-
} else {
|
|
1526
|
-
result.minimumSignificantDigits = g1.length;
|
|
1527
|
-
result.maximumSignificantDigits = g1.length + (typeof g2 === "string" ? g2.length : 0);
|
|
1528
|
-
}
|
|
1529
|
-
return "";
|
|
1530
|
-
});
|
|
1531
|
-
return result;
|
|
1532
|
-
}
|
|
1533
|
-
function parseSign(str) {
|
|
1534
|
-
switch (str) {
|
|
1535
|
-
case "sign-auto":
|
|
1536
|
-
return { signDisplay: "auto" };
|
|
1537
|
-
case "sign-accounting":
|
|
1538
|
-
case "()":
|
|
1539
|
-
return { currencySign: "accounting" };
|
|
1540
|
-
case "sign-always":
|
|
1541
|
-
case "+!":
|
|
1542
|
-
return { signDisplay: "always" };
|
|
1543
|
-
case "sign-accounting-always":
|
|
1544
|
-
case "()!":
|
|
1545
|
-
return {
|
|
1546
|
-
signDisplay: "always",
|
|
1547
|
-
currencySign: "accounting"
|
|
1548
|
-
};
|
|
1549
|
-
case "sign-except-zero":
|
|
1550
|
-
case "+?":
|
|
1551
|
-
return { signDisplay: "exceptZero" };
|
|
1552
|
-
case "sign-accounting-except-zero":
|
|
1553
|
-
case "()?":
|
|
1554
|
-
return {
|
|
1555
|
-
signDisplay: "exceptZero",
|
|
1556
|
-
currencySign: "accounting"
|
|
1557
|
-
};
|
|
1558
|
-
case "sign-never":
|
|
1559
|
-
case "+_":
|
|
1560
|
-
return { signDisplay: "never" };
|
|
1561
|
-
}
|
|
1562
|
-
}
|
|
1563
|
-
function parseConciseScientificAndEngineeringStem(stem) {
|
|
1564
|
-
let result;
|
|
1565
|
-
if (stem[0] === "E" && stem[1] === "E") {
|
|
1566
|
-
result = { notation: "engineering" };
|
|
1567
|
-
stem = stem.slice(2);
|
|
1568
|
-
} else if (stem[0] === "E") {
|
|
1569
|
-
result = { notation: "scientific" };
|
|
1570
|
-
stem = stem.slice(1);
|
|
1571
|
-
}
|
|
1572
|
-
if (result) {
|
|
1573
|
-
const signDisplay = stem.slice(0, 2);
|
|
1574
|
-
if (signDisplay === "+!") {
|
|
1575
|
-
result.signDisplay = "always";
|
|
1576
|
-
stem = stem.slice(2);
|
|
1577
|
-
} else if (signDisplay === "+?") {
|
|
1578
|
-
result.signDisplay = "exceptZero";
|
|
1579
|
-
stem = stem.slice(2);
|
|
1580
|
-
}
|
|
1581
|
-
if (!CONCISE_INTEGER_WIDTH_REGEX.test(stem)) {
|
|
1582
|
-
throw new Error("Malformed concise eng/scientific notation");
|
|
1583
|
-
}
|
|
1584
|
-
result.minimumIntegerDigits = stem.length;
|
|
1585
|
-
}
|
|
1586
|
-
return result;
|
|
1587
|
-
}
|
|
1588
|
-
function parseNotationOptions(opt) {
|
|
1589
|
-
const result = {};
|
|
1590
|
-
const signOpts = parseSign(opt);
|
|
1591
|
-
if (signOpts) {
|
|
1592
|
-
return signOpts;
|
|
1593
|
-
}
|
|
1594
|
-
return result;
|
|
1595
|
-
}
|
|
1596
|
-
function parseNumberSkeleton(tokens) {
|
|
1597
|
-
let result = {};
|
|
1598
|
-
for (const token of tokens) {
|
|
1599
|
-
switch (token.stem) {
|
|
1600
|
-
case "percent":
|
|
1601
|
-
case "%":
|
|
1602
|
-
result.style = "percent";
|
|
1603
|
-
continue;
|
|
1604
|
-
case "%x100":
|
|
1605
|
-
result.style = "percent";
|
|
1606
|
-
result.scale = 100;
|
|
1607
|
-
continue;
|
|
1608
|
-
case "currency":
|
|
1609
|
-
result.style = "currency";
|
|
1610
|
-
result.currency = token.options[0];
|
|
1611
|
-
continue;
|
|
1612
|
-
case "group-off":
|
|
1613
|
-
case ",_":
|
|
1614
|
-
result.useGrouping = false;
|
|
1615
|
-
continue;
|
|
1616
|
-
case "precision-integer":
|
|
1617
|
-
case ".":
|
|
1618
|
-
result.maximumFractionDigits = 0;
|
|
1619
|
-
continue;
|
|
1620
|
-
case "measure-unit":
|
|
1621
|
-
case "unit":
|
|
1622
|
-
result.style = "unit";
|
|
1623
|
-
result.unit = icuUnitToEcma(token.options[0]);
|
|
1624
|
-
continue;
|
|
1625
|
-
case "compact-short":
|
|
1626
|
-
case "K":
|
|
1627
|
-
result.notation = "compact";
|
|
1628
|
-
result.compactDisplay = "short";
|
|
1629
|
-
continue;
|
|
1630
|
-
case "compact-long":
|
|
1631
|
-
case "KK":
|
|
1632
|
-
result.notation = "compact";
|
|
1633
|
-
result.compactDisplay = "long";
|
|
1634
|
-
continue;
|
|
1635
|
-
case "scientific":
|
|
1636
|
-
result = {
|
|
1637
|
-
...result,
|
|
1638
|
-
notation: "scientific",
|
|
1639
|
-
...token.options.reduce((all, opt) => ({
|
|
1640
|
-
...all,
|
|
1641
|
-
...parseNotationOptions(opt)
|
|
1642
|
-
}), {})
|
|
1643
|
-
};
|
|
1644
|
-
continue;
|
|
1645
|
-
case "engineering":
|
|
1646
|
-
result = {
|
|
1647
|
-
...result,
|
|
1648
|
-
notation: "engineering",
|
|
1649
|
-
...token.options.reduce((all, opt) => ({
|
|
1650
|
-
...all,
|
|
1651
|
-
...parseNotationOptions(opt)
|
|
1652
|
-
}), {})
|
|
1653
|
-
};
|
|
1654
|
-
continue;
|
|
1655
|
-
case "notation-simple":
|
|
1656
|
-
result.notation = "standard";
|
|
1657
|
-
continue;
|
|
1658
|
-
case "unit-width-narrow":
|
|
1659
|
-
result.currencyDisplay = "narrowSymbol";
|
|
1660
|
-
result.unitDisplay = "narrow";
|
|
1661
|
-
continue;
|
|
1662
|
-
case "unit-width-short":
|
|
1663
|
-
result.currencyDisplay = "code";
|
|
1664
|
-
result.unitDisplay = "short";
|
|
1665
|
-
continue;
|
|
1666
|
-
case "unit-width-full-name":
|
|
1667
|
-
result.currencyDisplay = "name";
|
|
1668
|
-
result.unitDisplay = "long";
|
|
1669
|
-
continue;
|
|
1670
|
-
case "unit-width-iso-code":
|
|
1671
|
-
result.currencyDisplay = "symbol";
|
|
1672
|
-
continue;
|
|
1673
|
-
case "scale":
|
|
1674
|
-
result.scale = parseFloat(token.options[0]);
|
|
1675
|
-
continue;
|
|
1676
|
-
case "rounding-mode-floor":
|
|
1677
|
-
result.roundingMode = "floor";
|
|
1678
|
-
continue;
|
|
1679
|
-
case "rounding-mode-ceiling":
|
|
1680
|
-
result.roundingMode = "ceil";
|
|
1681
|
-
continue;
|
|
1682
|
-
case "rounding-mode-down":
|
|
1683
|
-
result.roundingMode = "trunc";
|
|
1684
|
-
continue;
|
|
1685
|
-
case "rounding-mode-up":
|
|
1686
|
-
result.roundingMode = "expand";
|
|
1687
|
-
continue;
|
|
1688
|
-
case "rounding-mode-half-even":
|
|
1689
|
-
result.roundingMode = "halfEven";
|
|
1690
|
-
continue;
|
|
1691
|
-
case "rounding-mode-half-down":
|
|
1692
|
-
result.roundingMode = "halfTrunc";
|
|
1693
|
-
continue;
|
|
1694
|
-
case "rounding-mode-half-up":
|
|
1695
|
-
result.roundingMode = "halfExpand";
|
|
1696
|
-
continue;
|
|
1697
|
-
case "integer-width":
|
|
1698
|
-
if (token.options.length > 1) {
|
|
1699
|
-
throw new RangeError("integer-width stems only accept a single optional option");
|
|
1700
|
-
}
|
|
1701
|
-
token.options[0].replace(INTEGER_WIDTH_REGEX, function(_, g1, g2, g3, g4, g5) {
|
|
1702
|
-
if (g1) {
|
|
1703
|
-
result.minimumIntegerDigits = g2.length;
|
|
1704
|
-
} else if (g3 && g4) {
|
|
1705
|
-
throw new Error("We currently do not support maximum integer digits");
|
|
1706
|
-
} else if (g5) {
|
|
1707
|
-
throw new Error("We currently do not support exact integer digits");
|
|
1708
|
-
}
|
|
1709
|
-
return "";
|
|
1710
|
-
});
|
|
1711
|
-
continue;
|
|
1712
|
-
}
|
|
1713
|
-
if (CONCISE_INTEGER_WIDTH_REGEX.test(token.stem)) {
|
|
1714
|
-
result.minimumIntegerDigits = token.stem.length;
|
|
1715
|
-
continue;
|
|
1716
|
-
}
|
|
1717
|
-
if (FRACTION_PRECISION_REGEX.test(token.stem)) {
|
|
1718
|
-
if (token.options.length > 1) {
|
|
1719
|
-
throw new RangeError("Fraction-precision stems only accept a single optional option");
|
|
1720
|
-
}
|
|
1721
|
-
token.stem.replace(FRACTION_PRECISION_REGEX, function(_, g1, g2, g3, g4, g5) {
|
|
1722
|
-
if (g2 === "*") {
|
|
1723
|
-
result.minimumFractionDigits = g1.length;
|
|
1724
|
-
} else if (g3 && g3[0] === "#") {
|
|
1725
|
-
result.maximumFractionDigits = g3.length;
|
|
1726
|
-
} else if (g4 && g5) {
|
|
1727
|
-
result.minimumFractionDigits = g4.length;
|
|
1728
|
-
result.maximumFractionDigits = g4.length + g5.length;
|
|
1729
|
-
} else {
|
|
1730
|
-
result.minimumFractionDigits = g1.length;
|
|
1731
|
-
result.maximumFractionDigits = g1.length;
|
|
1732
|
-
}
|
|
1733
|
-
return "";
|
|
1734
|
-
});
|
|
1735
|
-
const opt = token.options[0];
|
|
1736
|
-
if (opt === "w") {
|
|
1737
|
-
result = {
|
|
1738
|
-
...result,
|
|
1739
|
-
trailingZeroDisplay: "stripIfInteger"
|
|
1740
|
-
};
|
|
1741
|
-
} else if (opt) {
|
|
1742
|
-
result = {
|
|
1743
|
-
...result,
|
|
1744
|
-
...parseSignificantPrecision(opt)
|
|
1745
|
-
};
|
|
1746
|
-
}
|
|
1747
|
-
continue;
|
|
1748
|
-
}
|
|
1749
|
-
if (SIGNIFICANT_PRECISION_REGEX.test(token.stem)) {
|
|
1750
|
-
result = {
|
|
1751
|
-
...result,
|
|
1752
|
-
...parseSignificantPrecision(token.stem)
|
|
1753
|
-
};
|
|
1754
|
-
continue;
|
|
1755
|
-
}
|
|
1756
|
-
const signOpts = parseSign(token.stem);
|
|
1757
|
-
if (signOpts) {
|
|
1758
|
-
result = {
|
|
1759
|
-
...result,
|
|
1760
|
-
...signOpts
|
|
1761
|
-
};
|
|
1762
|
-
}
|
|
1763
|
-
const conciseScientificAndEngineeringOpts = parseConciseScientificAndEngineeringStem(token.stem);
|
|
1764
|
-
if (conciseScientificAndEngineeringOpts) {
|
|
1765
|
-
result = {
|
|
1766
|
-
...result,
|
|
1767
|
-
...conciseScientificAndEngineeringOpts
|
|
1768
|
-
};
|
|
1769
|
-
}
|
|
1770
|
-
}
|
|
1771
|
-
return result;
|
|
1772
|
-
}
|
|
1773
|
-
let TYPE = /* @__PURE__ */ (function(TYPE2) {
|
|
1774
|
-
TYPE2[TYPE2["literal"] = 0] = "literal";
|
|
1775
|
-
TYPE2[TYPE2["argument"] = 1] = "argument";
|
|
1776
|
-
TYPE2[TYPE2["number"] = 2] = "number";
|
|
1777
|
-
TYPE2[TYPE2["date"] = 3] = "date";
|
|
1778
|
-
TYPE2[TYPE2["time"] = 4] = "time";
|
|
1779
|
-
TYPE2[TYPE2["select"] = 5] = "select";
|
|
1780
|
-
TYPE2[TYPE2["plural"] = 6] = "plural";
|
|
1781
|
-
TYPE2[TYPE2["pound"] = 7] = "pound";
|
|
1782
|
-
TYPE2[TYPE2["tag"] = 8] = "tag";
|
|
1783
|
-
return TYPE2;
|
|
1784
|
-
})({});
|
|
1785
|
-
let SKELETON_TYPE = /* @__PURE__ */ (function(SKELETON_TYPE2) {
|
|
1786
|
-
SKELETON_TYPE2[SKELETON_TYPE2["number"] = 0] = "number";
|
|
1787
|
-
SKELETON_TYPE2[SKELETON_TYPE2["dateTime"] = 1] = "dateTime";
|
|
1788
|
-
return SKELETON_TYPE2;
|
|
1789
|
-
})({});
|
|
1790
|
-
function isLiteralElement(el) {
|
|
1791
|
-
return el.type === TYPE.literal;
|
|
1792
|
-
}
|
|
1793
|
-
function isArgumentElement(el) {
|
|
1794
|
-
return el.type === TYPE.argument;
|
|
1795
|
-
}
|
|
1796
|
-
function isNumberElement(el) {
|
|
1797
|
-
return el.type === TYPE.number;
|
|
1798
|
-
}
|
|
1799
|
-
function isDateElement(el) {
|
|
1800
|
-
return el.type === TYPE.date;
|
|
1801
|
-
}
|
|
1802
|
-
function isTimeElement(el) {
|
|
1803
|
-
return el.type === TYPE.time;
|
|
1804
|
-
}
|
|
1805
|
-
function isSelectElement(el) {
|
|
1806
|
-
return el.type === TYPE.select;
|
|
1807
|
-
}
|
|
1808
|
-
function isPluralElement(el) {
|
|
1809
|
-
return el.type === TYPE.plural;
|
|
1810
|
-
}
|
|
1811
|
-
function isPoundElement(el) {
|
|
1812
|
-
return el.type === TYPE.pound;
|
|
1813
|
-
}
|
|
1814
|
-
function isTagElement(el) {
|
|
1815
|
-
return el.type === TYPE.tag;
|
|
1816
|
-
}
|
|
1817
|
-
function isNumberSkeleton(el) {
|
|
1818
|
-
return !!(el && typeof el === "object" && el.type === SKELETON_TYPE.number);
|
|
1819
|
-
}
|
|
1820
|
-
function isDateTimeSkeleton(el) {
|
|
1821
|
-
return !!(el && typeof el === "object" && el.type === SKELETON_TYPE.dateTime);
|
|
1822
|
-
}
|
|
1823
|
-
let ErrorKind = /* @__PURE__ */ (function(ErrorKind2) {
|
|
1824
|
-
ErrorKind2[ErrorKind2["EXPECT_ARGUMENT_CLOSING_BRACE"] = 1] = "EXPECT_ARGUMENT_CLOSING_BRACE";
|
|
1825
|
-
ErrorKind2[ErrorKind2["EMPTY_ARGUMENT"] = 2] = "EMPTY_ARGUMENT";
|
|
1826
|
-
ErrorKind2[ErrorKind2["MALFORMED_ARGUMENT"] = 3] = "MALFORMED_ARGUMENT";
|
|
1827
|
-
ErrorKind2[ErrorKind2["EXPECT_ARGUMENT_TYPE"] = 4] = "EXPECT_ARGUMENT_TYPE";
|
|
1828
|
-
ErrorKind2[ErrorKind2["INVALID_ARGUMENT_TYPE"] = 5] = "INVALID_ARGUMENT_TYPE";
|
|
1829
|
-
ErrorKind2[ErrorKind2["EXPECT_ARGUMENT_STYLE"] = 6] = "EXPECT_ARGUMENT_STYLE";
|
|
1830
|
-
ErrorKind2[ErrorKind2["INVALID_NUMBER_SKELETON"] = 7] = "INVALID_NUMBER_SKELETON";
|
|
1831
|
-
ErrorKind2[ErrorKind2["INVALID_DATE_TIME_SKELETON"] = 8] = "INVALID_DATE_TIME_SKELETON";
|
|
1832
|
-
ErrorKind2[ErrorKind2["EXPECT_NUMBER_SKELETON"] = 9] = "EXPECT_NUMBER_SKELETON";
|
|
1833
|
-
ErrorKind2[ErrorKind2["EXPECT_DATE_TIME_SKELETON"] = 10] = "EXPECT_DATE_TIME_SKELETON";
|
|
1834
|
-
ErrorKind2[ErrorKind2["UNCLOSED_QUOTE_IN_ARGUMENT_STYLE"] = 11] = "UNCLOSED_QUOTE_IN_ARGUMENT_STYLE";
|
|
1835
|
-
ErrorKind2[ErrorKind2["EXPECT_SELECT_ARGUMENT_OPTIONS"] = 12] = "EXPECT_SELECT_ARGUMENT_OPTIONS";
|
|
1836
|
-
ErrorKind2[ErrorKind2["EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE"] = 13] = "EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE";
|
|
1837
|
-
ErrorKind2[ErrorKind2["INVALID_PLURAL_ARGUMENT_OFFSET_VALUE"] = 14] = "INVALID_PLURAL_ARGUMENT_OFFSET_VALUE";
|
|
1838
|
-
ErrorKind2[ErrorKind2["EXPECT_SELECT_ARGUMENT_SELECTOR"] = 15] = "EXPECT_SELECT_ARGUMENT_SELECTOR";
|
|
1839
|
-
ErrorKind2[ErrorKind2["EXPECT_PLURAL_ARGUMENT_SELECTOR"] = 16] = "EXPECT_PLURAL_ARGUMENT_SELECTOR";
|
|
1840
|
-
ErrorKind2[ErrorKind2["EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT"] = 17] = "EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT";
|
|
1841
|
-
ErrorKind2[ErrorKind2["EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT"] = 18] = "EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT";
|
|
1842
|
-
ErrorKind2[ErrorKind2["INVALID_PLURAL_ARGUMENT_SELECTOR"] = 19] = "INVALID_PLURAL_ARGUMENT_SELECTOR";
|
|
1843
|
-
ErrorKind2[ErrorKind2["DUPLICATE_PLURAL_ARGUMENT_SELECTOR"] = 20] = "DUPLICATE_PLURAL_ARGUMENT_SELECTOR";
|
|
1844
|
-
ErrorKind2[ErrorKind2["DUPLICATE_SELECT_ARGUMENT_SELECTOR"] = 21] = "DUPLICATE_SELECT_ARGUMENT_SELECTOR";
|
|
1845
|
-
ErrorKind2[ErrorKind2["MISSING_OTHER_CLAUSE"] = 22] = "MISSING_OTHER_CLAUSE";
|
|
1846
|
-
ErrorKind2[ErrorKind2["INVALID_TAG"] = 23] = "INVALID_TAG";
|
|
1847
|
-
ErrorKind2[ErrorKind2["INVALID_TAG_NAME"] = 25] = "INVALID_TAG_NAME";
|
|
1848
|
-
ErrorKind2[ErrorKind2["UNMATCHED_CLOSING_TAG"] = 26] = "UNMATCHED_CLOSING_TAG";
|
|
1849
|
-
ErrorKind2[ErrorKind2["UNCLOSED_TAG"] = 27] = "UNCLOSED_TAG";
|
|
1850
|
-
return ErrorKind2;
|
|
1851
|
-
})({});
|
|
1852
|
-
const SPACE_SEPARATOR_REGEX = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/;
|
|
1853
|
-
const timeData = {
|
|
1854
|
-
"001": ["H", "h"],
|
|
1855
|
-
"419": [
|
|
1856
|
-
"h",
|
|
1857
|
-
"H",
|
|
1858
|
-
"hB",
|
|
1859
|
-
"hb"
|
|
1860
|
-
],
|
|
1861
|
-
"AC": [
|
|
1862
|
-
"H",
|
|
1863
|
-
"h",
|
|
1864
|
-
"hb",
|
|
1865
|
-
"hB"
|
|
1866
|
-
],
|
|
1867
|
-
"AD": ["H", "hB"],
|
|
1868
|
-
"AE": [
|
|
1869
|
-
"h",
|
|
1870
|
-
"hB",
|
|
1871
|
-
"hb",
|
|
1872
|
-
"H"
|
|
1873
|
-
],
|
|
1874
|
-
"AF": [
|
|
1875
|
-
"H",
|
|
1876
|
-
"hb",
|
|
1877
|
-
"hB",
|
|
1878
|
-
"h"
|
|
1879
|
-
],
|
|
1880
|
-
"AG": [
|
|
1881
|
-
"h",
|
|
1882
|
-
"hb",
|
|
1883
|
-
"H",
|
|
1884
|
-
"hB"
|
|
1885
|
-
],
|
|
1886
|
-
"AI": [
|
|
1887
|
-
"H",
|
|
1888
|
-
"h",
|
|
1889
|
-
"hb",
|
|
1890
|
-
"hB"
|
|
1891
|
-
],
|
|
1892
|
-
"AL": [
|
|
1893
|
-
"h",
|
|
1894
|
-
"H",
|
|
1895
|
-
"hB"
|
|
1896
|
-
],
|
|
1897
|
-
"AM": ["H", "hB"],
|
|
1898
|
-
"AO": ["H", "hB"],
|
|
1899
|
-
"AR": [
|
|
1900
|
-
"h",
|
|
1901
|
-
"H",
|
|
1902
|
-
"hB",
|
|
1903
|
-
"hb"
|
|
1904
|
-
],
|
|
1905
|
-
"AS": ["h", "H"],
|
|
1906
|
-
"AT": ["H", "hB"],
|
|
1907
|
-
"AU": [
|
|
1908
|
-
"h",
|
|
1909
|
-
"hb",
|
|
1910
|
-
"H",
|
|
1911
|
-
"hB"
|
|
1912
|
-
],
|
|
1913
|
-
"AW": ["H", "hB"],
|
|
1914
|
-
"AX": ["H"],
|
|
1915
|
-
"AZ": [
|
|
1916
|
-
"H",
|
|
1917
|
-
"hB",
|
|
1918
|
-
"h"
|
|
1919
|
-
],
|
|
1920
|
-
"BA": [
|
|
1921
|
-
"H",
|
|
1922
|
-
"hB",
|
|
1923
|
-
"h"
|
|
1924
|
-
],
|
|
1925
|
-
"BB": [
|
|
1926
|
-
"h",
|
|
1927
|
-
"hb",
|
|
1928
|
-
"H",
|
|
1929
|
-
"hB"
|
|
1930
|
-
],
|
|
1931
|
-
"BD": [
|
|
1932
|
-
"h",
|
|
1933
|
-
"hB",
|
|
1934
|
-
"H"
|
|
1935
|
-
],
|
|
1936
|
-
"BE": ["H", "hB"],
|
|
1937
|
-
"BF": ["H", "hB"],
|
|
1938
|
-
"BG": [
|
|
1939
|
-
"H",
|
|
1940
|
-
"hB",
|
|
1941
|
-
"h"
|
|
1942
|
-
],
|
|
1943
|
-
"BH": [
|
|
1944
|
-
"h",
|
|
1945
|
-
"hB",
|
|
1946
|
-
"hb",
|
|
1947
|
-
"H"
|
|
1948
|
-
],
|
|
1949
|
-
"BI": ["H", "h"],
|
|
1950
|
-
"BJ": ["H", "hB"],
|
|
1951
|
-
"BL": ["H", "hB"],
|
|
1952
|
-
"BM": [
|
|
1953
|
-
"h",
|
|
1954
|
-
"hb",
|
|
1955
|
-
"H",
|
|
1956
|
-
"hB"
|
|
1957
|
-
],
|
|
1958
|
-
"BN": [
|
|
1959
|
-
"hb",
|
|
1960
|
-
"hB",
|
|
1961
|
-
"h",
|
|
1962
|
-
"H"
|
|
1963
|
-
],
|
|
1964
|
-
"BO": [
|
|
1965
|
-
"h",
|
|
1966
|
-
"H",
|
|
1967
|
-
"hB",
|
|
1968
|
-
"hb"
|
|
1969
|
-
],
|
|
1970
|
-
"BQ": ["H"],
|
|
1971
|
-
"BR": ["H", "hB"],
|
|
1972
|
-
"BS": [
|
|
1973
|
-
"h",
|
|
1974
|
-
"hb",
|
|
1975
|
-
"H",
|
|
1976
|
-
"hB"
|
|
1977
|
-
],
|
|
1978
|
-
"BT": ["h", "H"],
|
|
1979
|
-
"BW": [
|
|
1980
|
-
"H",
|
|
1981
|
-
"h",
|
|
1982
|
-
"hb",
|
|
1983
|
-
"hB"
|
|
1984
|
-
],
|
|
1985
|
-
"BY": ["H", "h"],
|
|
1986
|
-
"BZ": [
|
|
1987
|
-
"H",
|
|
1988
|
-
"h",
|
|
1989
|
-
"hb",
|
|
1990
|
-
"hB"
|
|
1991
|
-
],
|
|
1992
|
-
"CA": [
|
|
1993
|
-
"h",
|
|
1994
|
-
"hb",
|
|
1995
|
-
"H",
|
|
1996
|
-
"hB"
|
|
1997
|
-
],
|
|
1998
|
-
"CC": [
|
|
1999
|
-
"H",
|
|
2000
|
-
"h",
|
|
2001
|
-
"hb",
|
|
2002
|
-
"hB"
|
|
2003
|
-
],
|
|
2004
|
-
"CD": ["hB", "H"],
|
|
2005
|
-
"CF": [
|
|
2006
|
-
"H",
|
|
2007
|
-
"h",
|
|
2008
|
-
"hB"
|
|
2009
|
-
],
|
|
2010
|
-
"CG": ["H", "hB"],
|
|
2011
|
-
"CH": [
|
|
2012
|
-
"H",
|
|
2013
|
-
"hB",
|
|
2014
|
-
"h"
|
|
2015
|
-
],
|
|
2016
|
-
"CI": ["H", "hB"],
|
|
2017
|
-
"CK": [
|
|
2018
|
-
"H",
|
|
2019
|
-
"h",
|
|
2020
|
-
"hb",
|
|
2021
|
-
"hB"
|
|
2022
|
-
],
|
|
2023
|
-
"CL": [
|
|
2024
|
-
"h",
|
|
2025
|
-
"H",
|
|
2026
|
-
"hB",
|
|
2027
|
-
"hb"
|
|
2028
|
-
],
|
|
2029
|
-
"CM": [
|
|
2030
|
-
"H",
|
|
2031
|
-
"h",
|
|
2032
|
-
"hB"
|
|
2033
|
-
],
|
|
2034
|
-
"CN": [
|
|
2035
|
-
"H",
|
|
2036
|
-
"hB",
|
|
2037
|
-
"hb",
|
|
2038
|
-
"h"
|
|
2039
|
-
],
|
|
2040
|
-
"CO": [
|
|
2041
|
-
"h",
|
|
2042
|
-
"H",
|
|
2043
|
-
"hB",
|
|
2044
|
-
"hb"
|
|
2045
|
-
],
|
|
2046
|
-
"CP": ["H"],
|
|
2047
|
-
"CR": [
|
|
2048
|
-
"h",
|
|
2049
|
-
"H",
|
|
2050
|
-
"hB",
|
|
2051
|
-
"hb"
|
|
2052
|
-
],
|
|
2053
|
-
"CU": [
|
|
2054
|
-
"h",
|
|
2055
|
-
"H",
|
|
2056
|
-
"hB",
|
|
2057
|
-
"hb"
|
|
2058
|
-
],
|
|
2059
|
-
"CV": ["H", "hB"],
|
|
2060
|
-
"CW": ["H", "hB"],
|
|
2061
|
-
"CX": [
|
|
2062
|
-
"H",
|
|
2063
|
-
"h",
|
|
2064
|
-
"hb",
|
|
2065
|
-
"hB"
|
|
2066
|
-
],
|
|
2067
|
-
"CY": [
|
|
2068
|
-
"h",
|
|
2069
|
-
"H",
|
|
2070
|
-
"hb",
|
|
2071
|
-
"hB"
|
|
2072
|
-
],
|
|
2073
|
-
"CZ": ["H"],
|
|
2074
|
-
"DE": ["H", "hB"],
|
|
2075
|
-
"DG": [
|
|
2076
|
-
"H",
|
|
2077
|
-
"h",
|
|
2078
|
-
"hb",
|
|
2079
|
-
"hB"
|
|
2080
|
-
],
|
|
2081
|
-
"DJ": ["h", "H"],
|
|
2082
|
-
"DK": ["H"],
|
|
2083
|
-
"DM": [
|
|
2084
|
-
"h",
|
|
2085
|
-
"hb",
|
|
2086
|
-
"H",
|
|
2087
|
-
"hB"
|
|
2088
|
-
],
|
|
2089
|
-
"DO": [
|
|
2090
|
-
"h",
|
|
2091
|
-
"H",
|
|
2092
|
-
"hB",
|
|
2093
|
-
"hb"
|
|
2094
|
-
],
|
|
2095
|
-
"DZ": [
|
|
2096
|
-
"h",
|
|
2097
|
-
"hB",
|
|
2098
|
-
"hb",
|
|
2099
|
-
"H"
|
|
2100
|
-
],
|
|
2101
|
-
"EA": [
|
|
2102
|
-
"H",
|
|
2103
|
-
"h",
|
|
2104
|
-
"hB",
|
|
2105
|
-
"hb"
|
|
2106
|
-
],
|
|
2107
|
-
"EC": [
|
|
2108
|
-
"h",
|
|
2109
|
-
"H",
|
|
2110
|
-
"hB",
|
|
2111
|
-
"hb"
|
|
2112
|
-
],
|
|
2113
|
-
"EE": ["H", "hB"],
|
|
2114
|
-
"EG": [
|
|
2115
|
-
"h",
|
|
2116
|
-
"hB",
|
|
2117
|
-
"hb",
|
|
2118
|
-
"H"
|
|
2119
|
-
],
|
|
2120
|
-
"EH": [
|
|
2121
|
-
"h",
|
|
2122
|
-
"hB",
|
|
2123
|
-
"hb",
|
|
2124
|
-
"H"
|
|
2125
|
-
],
|
|
2126
|
-
"ER": ["h", "H"],
|
|
2127
|
-
"ES": [
|
|
2128
|
-
"H",
|
|
2129
|
-
"hB",
|
|
2130
|
-
"h",
|
|
2131
|
-
"hb"
|
|
2132
|
-
],
|
|
2133
|
-
"ET": [
|
|
2134
|
-
"hB",
|
|
2135
|
-
"hb",
|
|
2136
|
-
"h",
|
|
2137
|
-
"H"
|
|
2138
|
-
],
|
|
2139
|
-
"FI": ["H"],
|
|
2140
|
-
"FJ": [
|
|
2141
|
-
"h",
|
|
2142
|
-
"hb",
|
|
2143
|
-
"H",
|
|
2144
|
-
"hB"
|
|
2145
|
-
],
|
|
2146
|
-
"FK": [
|
|
2147
|
-
"H",
|
|
2148
|
-
"h",
|
|
2149
|
-
"hb",
|
|
2150
|
-
"hB"
|
|
2151
|
-
],
|
|
2152
|
-
"FM": [
|
|
2153
|
-
"h",
|
|
2154
|
-
"hb",
|
|
2155
|
-
"H",
|
|
2156
|
-
"hB"
|
|
2157
|
-
],
|
|
2158
|
-
"FO": ["H", "h"],
|
|
2159
|
-
"FR": ["H", "hB"],
|
|
2160
|
-
"GA": ["H", "hB"],
|
|
2161
|
-
"GB": [
|
|
2162
|
-
"H",
|
|
2163
|
-
"h",
|
|
2164
|
-
"hb",
|
|
2165
|
-
"hB"
|
|
2166
|
-
],
|
|
2167
|
-
"GD": [
|
|
2168
|
-
"h",
|
|
2169
|
-
"hb",
|
|
2170
|
-
"H",
|
|
2171
|
-
"hB"
|
|
2172
|
-
],
|
|
2173
|
-
"GE": [
|
|
2174
|
-
"H",
|
|
2175
|
-
"hB",
|
|
2176
|
-
"h"
|
|
2177
|
-
],
|
|
2178
|
-
"GF": ["H", "hB"],
|
|
2179
|
-
"GG": [
|
|
2180
|
-
"H",
|
|
2181
|
-
"h",
|
|
2182
|
-
"hb",
|
|
2183
|
-
"hB"
|
|
2184
|
-
],
|
|
2185
|
-
"GH": ["h", "H"],
|
|
2186
|
-
"GI": [
|
|
2187
|
-
"H",
|
|
2188
|
-
"h",
|
|
2189
|
-
"hb",
|
|
2190
|
-
"hB"
|
|
2191
|
-
],
|
|
2192
|
-
"GL": ["H", "h"],
|
|
2193
|
-
"GM": [
|
|
2194
|
-
"h",
|
|
2195
|
-
"hb",
|
|
2196
|
-
"H",
|
|
2197
|
-
"hB"
|
|
2198
|
-
],
|
|
2199
|
-
"GN": ["H", "hB"],
|
|
2200
|
-
"GP": ["H", "hB"],
|
|
2201
|
-
"GQ": [
|
|
2202
|
-
"H",
|
|
2203
|
-
"hB",
|
|
2204
|
-
"h",
|
|
2205
|
-
"hb"
|
|
2206
|
-
],
|
|
2207
|
-
"GR": [
|
|
2208
|
-
"h",
|
|
2209
|
-
"H",
|
|
2210
|
-
"hb",
|
|
2211
|
-
"hB"
|
|
2212
|
-
],
|
|
2213
|
-
"GS": [
|
|
2214
|
-
"H",
|
|
2215
|
-
"h",
|
|
2216
|
-
"hb",
|
|
2217
|
-
"hB"
|
|
2218
|
-
],
|
|
2219
|
-
"GT": [
|
|
2220
|
-
"h",
|
|
2221
|
-
"H",
|
|
2222
|
-
"hB",
|
|
2223
|
-
"hb"
|
|
2224
|
-
],
|
|
2225
|
-
"GU": [
|
|
2226
|
-
"h",
|
|
2227
|
-
"hb",
|
|
2228
|
-
"H",
|
|
2229
|
-
"hB"
|
|
2230
|
-
],
|
|
2231
|
-
"GW": ["H", "hB"],
|
|
2232
|
-
"GY": [
|
|
2233
|
-
"h",
|
|
2234
|
-
"hb",
|
|
2235
|
-
"H",
|
|
2236
|
-
"hB"
|
|
2237
|
-
],
|
|
2238
|
-
"HK": [
|
|
2239
|
-
"h",
|
|
2240
|
-
"hB",
|
|
2241
|
-
"hb",
|
|
2242
|
-
"H"
|
|
2243
|
-
],
|
|
2244
|
-
"HN": [
|
|
2245
|
-
"h",
|
|
2246
|
-
"H",
|
|
2247
|
-
"hB",
|
|
2248
|
-
"hb"
|
|
2249
|
-
],
|
|
2250
|
-
"HR": ["H", "hB"],
|
|
2251
|
-
"HU": ["H", "h"],
|
|
2252
|
-
"IC": [
|
|
2253
|
-
"H",
|
|
2254
|
-
"h",
|
|
2255
|
-
"hB",
|
|
2256
|
-
"hb"
|
|
2257
|
-
],
|
|
2258
|
-
"ID": ["H"],
|
|
2259
|
-
"IE": [
|
|
2260
|
-
"H",
|
|
2261
|
-
"h",
|
|
2262
|
-
"hb",
|
|
2263
|
-
"hB"
|
|
2264
|
-
],
|
|
2265
|
-
"IL": ["H", "hB"],
|
|
2266
|
-
"IM": [
|
|
2267
|
-
"H",
|
|
2268
|
-
"h",
|
|
2269
|
-
"hb",
|
|
2270
|
-
"hB"
|
|
2271
|
-
],
|
|
2272
|
-
"IN": ["h", "H"],
|
|
2273
|
-
"IO": [
|
|
2274
|
-
"H",
|
|
2275
|
-
"h",
|
|
2276
|
-
"hb",
|
|
2277
|
-
"hB"
|
|
2278
|
-
],
|
|
2279
|
-
"IQ": [
|
|
2280
|
-
"h",
|
|
2281
|
-
"hB",
|
|
2282
|
-
"hb",
|
|
2283
|
-
"H"
|
|
2284
|
-
],
|
|
2285
|
-
"IR": ["hB", "H"],
|
|
2286
|
-
"IS": ["H"],
|
|
2287
|
-
"IT": ["H", "hB"],
|
|
2288
|
-
"JE": [
|
|
2289
|
-
"H",
|
|
2290
|
-
"h",
|
|
2291
|
-
"hb",
|
|
2292
|
-
"hB"
|
|
2293
|
-
],
|
|
2294
|
-
"JM": [
|
|
2295
|
-
"h",
|
|
2296
|
-
"hb",
|
|
2297
|
-
"H",
|
|
2298
|
-
"hB"
|
|
2299
|
-
],
|
|
2300
|
-
"JO": [
|
|
2301
|
-
"h",
|
|
2302
|
-
"hB",
|
|
2303
|
-
"hb",
|
|
2304
|
-
"H"
|
|
2305
|
-
],
|
|
2306
|
-
"JP": [
|
|
2307
|
-
"H",
|
|
2308
|
-
"K",
|
|
2309
|
-
"h"
|
|
2310
|
-
],
|
|
2311
|
-
"KE": [
|
|
2312
|
-
"hB",
|
|
2313
|
-
"hb",
|
|
2314
|
-
"H",
|
|
2315
|
-
"h"
|
|
2316
|
-
],
|
|
2317
|
-
"KG": [
|
|
2318
|
-
"H",
|
|
2319
|
-
"h",
|
|
2320
|
-
"hB",
|
|
2321
|
-
"hb"
|
|
2322
|
-
],
|
|
2323
|
-
"KH": [
|
|
2324
|
-
"hB",
|
|
2325
|
-
"h",
|
|
2326
|
-
"H",
|
|
2327
|
-
"hb"
|
|
2328
|
-
],
|
|
2329
|
-
"KI": [
|
|
2330
|
-
"h",
|
|
2331
|
-
"hb",
|
|
2332
|
-
"H",
|
|
2333
|
-
"hB"
|
|
2334
|
-
],
|
|
2335
|
-
"KM": [
|
|
2336
|
-
"H",
|
|
2337
|
-
"h",
|
|
2338
|
-
"hB",
|
|
2339
|
-
"hb"
|
|
2340
|
-
],
|
|
2341
|
-
"KN": [
|
|
2342
|
-
"h",
|
|
2343
|
-
"hb",
|
|
2344
|
-
"H",
|
|
2345
|
-
"hB"
|
|
2346
|
-
],
|
|
2347
|
-
"KP": [
|
|
2348
|
-
"h",
|
|
2349
|
-
"H",
|
|
2350
|
-
"hB",
|
|
2351
|
-
"hb"
|
|
2352
|
-
],
|
|
2353
|
-
"KR": [
|
|
2354
|
-
"h",
|
|
2355
|
-
"H",
|
|
2356
|
-
"hB",
|
|
2357
|
-
"hb"
|
|
2358
|
-
],
|
|
2359
|
-
"KW": [
|
|
2360
|
-
"h",
|
|
2361
|
-
"hB",
|
|
2362
|
-
"hb",
|
|
2363
|
-
"H"
|
|
2364
|
-
],
|
|
2365
|
-
"KY": [
|
|
2366
|
-
"h",
|
|
2367
|
-
"hb",
|
|
2368
|
-
"H",
|
|
2369
|
-
"hB"
|
|
2370
|
-
],
|
|
2371
|
-
"KZ": ["H", "hB"],
|
|
2372
|
-
"LA": [
|
|
2373
|
-
"H",
|
|
2374
|
-
"hb",
|
|
2375
|
-
"hB",
|
|
2376
|
-
"h"
|
|
2377
|
-
],
|
|
2378
|
-
"LB": [
|
|
2379
|
-
"h",
|
|
2380
|
-
"hB",
|
|
2381
|
-
"hb",
|
|
2382
|
-
"H"
|
|
2383
|
-
],
|
|
2384
|
-
"LC": [
|
|
2385
|
-
"h",
|
|
2386
|
-
"hb",
|
|
2387
|
-
"H",
|
|
2388
|
-
"hB"
|
|
2389
|
-
],
|
|
2390
|
-
"LI": [
|
|
2391
|
-
"H",
|
|
2392
|
-
"hB",
|
|
2393
|
-
"h"
|
|
2394
|
-
],
|
|
2395
|
-
"LK": [
|
|
2396
|
-
"H",
|
|
2397
|
-
"h",
|
|
2398
|
-
"hB",
|
|
2399
|
-
"hb"
|
|
2400
|
-
],
|
|
2401
|
-
"LR": [
|
|
2402
|
-
"h",
|
|
2403
|
-
"hb",
|
|
2404
|
-
"H",
|
|
2405
|
-
"hB"
|
|
2406
|
-
],
|
|
2407
|
-
"LS": ["h", "H"],
|
|
2408
|
-
"LT": [
|
|
2409
|
-
"H",
|
|
2410
|
-
"h",
|
|
2411
|
-
"hb",
|
|
2412
|
-
"hB"
|
|
2413
|
-
],
|
|
2414
|
-
"LU": [
|
|
2415
|
-
"H",
|
|
2416
|
-
"h",
|
|
2417
|
-
"hB"
|
|
2418
|
-
],
|
|
2419
|
-
"LV": [
|
|
2420
|
-
"H",
|
|
2421
|
-
"hB",
|
|
2422
|
-
"hb",
|
|
2423
|
-
"h"
|
|
2424
|
-
],
|
|
2425
|
-
"LY": [
|
|
2426
|
-
"h",
|
|
2427
|
-
"hB",
|
|
2428
|
-
"hb",
|
|
2429
|
-
"H"
|
|
2430
|
-
],
|
|
2431
|
-
"MA": [
|
|
2432
|
-
"H",
|
|
2433
|
-
"h",
|
|
2434
|
-
"hB",
|
|
2435
|
-
"hb"
|
|
2436
|
-
],
|
|
2437
|
-
"MC": ["H", "hB"],
|
|
2438
|
-
"MD": ["H", "hB"],
|
|
2439
|
-
"ME": [
|
|
2440
|
-
"H",
|
|
2441
|
-
"hB",
|
|
2442
|
-
"h"
|
|
2443
|
-
],
|
|
2444
|
-
"MF": ["H", "hB"],
|
|
2445
|
-
"MG": ["H", "h"],
|
|
2446
|
-
"MH": [
|
|
2447
|
-
"h",
|
|
2448
|
-
"hb",
|
|
2449
|
-
"H",
|
|
2450
|
-
"hB"
|
|
2451
|
-
],
|
|
2452
|
-
"MK": [
|
|
2453
|
-
"H",
|
|
2454
|
-
"h",
|
|
2455
|
-
"hb",
|
|
2456
|
-
"hB"
|
|
2457
|
-
],
|
|
2458
|
-
"ML": ["H"],
|
|
2459
|
-
"MM": [
|
|
2460
|
-
"hB",
|
|
2461
|
-
"hb",
|
|
2462
|
-
"H",
|
|
2463
|
-
"h"
|
|
2464
|
-
],
|
|
2465
|
-
"MN": [
|
|
2466
|
-
"H",
|
|
2467
|
-
"h",
|
|
2468
|
-
"hb",
|
|
2469
|
-
"hB"
|
|
2470
|
-
],
|
|
2471
|
-
"MO": [
|
|
2472
|
-
"h",
|
|
2473
|
-
"hB",
|
|
2474
|
-
"hb",
|
|
2475
|
-
"H"
|
|
2476
|
-
],
|
|
2477
|
-
"MP": [
|
|
2478
|
-
"h",
|
|
2479
|
-
"hb",
|
|
2480
|
-
"H",
|
|
2481
|
-
"hB"
|
|
2482
|
-
],
|
|
2483
|
-
"MQ": ["H", "hB"],
|
|
2484
|
-
"MR": [
|
|
2485
|
-
"h",
|
|
2486
|
-
"hB",
|
|
2487
|
-
"hb",
|
|
2488
|
-
"H"
|
|
2489
|
-
],
|
|
2490
|
-
"MS": [
|
|
2491
|
-
"H",
|
|
2492
|
-
"h",
|
|
2493
|
-
"hb",
|
|
2494
|
-
"hB"
|
|
2495
|
-
],
|
|
2496
|
-
"MT": ["H", "h"],
|
|
2497
|
-
"MU": ["H", "h"],
|
|
2498
|
-
"MV": ["H", "h"],
|
|
2499
|
-
"MW": [
|
|
2500
|
-
"h",
|
|
2501
|
-
"hb",
|
|
2502
|
-
"H",
|
|
2503
|
-
"hB"
|
|
2504
|
-
],
|
|
2505
|
-
"MX": [
|
|
2506
|
-
"h",
|
|
2507
|
-
"H",
|
|
2508
|
-
"hB",
|
|
2509
|
-
"hb"
|
|
2510
|
-
],
|
|
2511
|
-
"MY": [
|
|
2512
|
-
"hb",
|
|
2513
|
-
"hB",
|
|
2514
|
-
"h",
|
|
2515
|
-
"H"
|
|
2516
|
-
],
|
|
2517
|
-
"MZ": ["H", "hB"],
|
|
2518
|
-
"NA": [
|
|
2519
|
-
"h",
|
|
2520
|
-
"H",
|
|
2521
|
-
"hB",
|
|
2522
|
-
"hb"
|
|
2523
|
-
],
|
|
2524
|
-
"NC": ["H", "hB"],
|
|
2525
|
-
"NE": ["H"],
|
|
2526
|
-
"NF": [
|
|
2527
|
-
"H",
|
|
2528
|
-
"h",
|
|
2529
|
-
"hb",
|
|
2530
|
-
"hB"
|
|
2531
|
-
],
|
|
2532
|
-
"NG": [
|
|
2533
|
-
"H",
|
|
2534
|
-
"h",
|
|
2535
|
-
"hb",
|
|
2536
|
-
"hB"
|
|
2537
|
-
],
|
|
2538
|
-
"NI": [
|
|
2539
|
-
"h",
|
|
2540
|
-
"H",
|
|
2541
|
-
"hB",
|
|
2542
|
-
"hb"
|
|
2543
|
-
],
|
|
2544
|
-
"NL": ["H", "hB"],
|
|
2545
|
-
"NO": ["H", "h"],
|
|
2546
|
-
"NP": [
|
|
2547
|
-
"H",
|
|
2548
|
-
"h",
|
|
2549
|
-
"hB"
|
|
2550
|
-
],
|
|
2551
|
-
"NR": [
|
|
2552
|
-
"H",
|
|
2553
|
-
"h",
|
|
2554
|
-
"hb",
|
|
2555
|
-
"hB"
|
|
2556
|
-
],
|
|
2557
|
-
"NU": [
|
|
2558
|
-
"H",
|
|
2559
|
-
"h",
|
|
2560
|
-
"hb",
|
|
2561
|
-
"hB"
|
|
2562
|
-
],
|
|
2563
|
-
"NZ": [
|
|
2564
|
-
"h",
|
|
2565
|
-
"hb",
|
|
2566
|
-
"H",
|
|
2567
|
-
"hB"
|
|
2568
|
-
],
|
|
2569
|
-
"OM": [
|
|
2570
|
-
"h",
|
|
2571
|
-
"hB",
|
|
2572
|
-
"hb",
|
|
2573
|
-
"H"
|
|
2574
|
-
],
|
|
2575
|
-
"PA": [
|
|
2576
|
-
"h",
|
|
2577
|
-
"H",
|
|
2578
|
-
"hB",
|
|
2579
|
-
"hb"
|
|
2580
|
-
],
|
|
2581
|
-
"PE": [
|
|
2582
|
-
"h",
|
|
2583
|
-
"H",
|
|
2584
|
-
"hB",
|
|
2585
|
-
"hb"
|
|
2586
|
-
],
|
|
2587
|
-
"PF": [
|
|
2588
|
-
"H",
|
|
2589
|
-
"h",
|
|
2590
|
-
"hB"
|
|
2591
|
-
],
|
|
2592
|
-
"PG": ["h", "H"],
|
|
2593
|
-
"PH": [
|
|
2594
|
-
"h",
|
|
2595
|
-
"hB",
|
|
2596
|
-
"hb",
|
|
2597
|
-
"H"
|
|
2598
|
-
],
|
|
2599
|
-
"PK": [
|
|
2600
|
-
"h",
|
|
2601
|
-
"hB",
|
|
2602
|
-
"H"
|
|
2603
|
-
],
|
|
2604
|
-
"PL": ["H", "h"],
|
|
2605
|
-
"PM": ["H", "hB"],
|
|
2606
|
-
"PN": [
|
|
2607
|
-
"H",
|
|
2608
|
-
"h",
|
|
2609
|
-
"hb",
|
|
2610
|
-
"hB"
|
|
2611
|
-
],
|
|
2612
|
-
"PR": [
|
|
2613
|
-
"h",
|
|
2614
|
-
"H",
|
|
2615
|
-
"hB",
|
|
2616
|
-
"hb"
|
|
2617
|
-
],
|
|
2618
|
-
"PS": [
|
|
2619
|
-
"h",
|
|
2620
|
-
"hB",
|
|
2621
|
-
"hb",
|
|
2622
|
-
"H"
|
|
2623
|
-
],
|
|
2624
|
-
"PT": ["H", "hB"],
|
|
2625
|
-
"PW": ["h", "H"],
|
|
2626
|
-
"PY": [
|
|
2627
|
-
"h",
|
|
2628
|
-
"H",
|
|
2629
|
-
"hB",
|
|
2630
|
-
"hb"
|
|
2631
|
-
],
|
|
2632
|
-
"QA": [
|
|
2633
|
-
"h",
|
|
2634
|
-
"hB",
|
|
2635
|
-
"hb",
|
|
2636
|
-
"H"
|
|
2637
|
-
],
|
|
2638
|
-
"RE": ["H", "hB"],
|
|
2639
|
-
"RO": ["H", "hB"],
|
|
2640
|
-
"RS": [
|
|
2641
|
-
"H",
|
|
2642
|
-
"hB",
|
|
2643
|
-
"h"
|
|
2644
|
-
],
|
|
2645
|
-
"RU": ["H"],
|
|
2646
|
-
"RW": ["H", "h"],
|
|
2647
|
-
"SA": [
|
|
2648
|
-
"h",
|
|
2649
|
-
"hB",
|
|
2650
|
-
"hb",
|
|
2651
|
-
"H"
|
|
2652
|
-
],
|
|
2653
|
-
"SB": [
|
|
2654
|
-
"h",
|
|
2655
|
-
"hb",
|
|
2656
|
-
"H",
|
|
2657
|
-
"hB"
|
|
2658
|
-
],
|
|
2659
|
-
"SC": [
|
|
2660
|
-
"H",
|
|
2661
|
-
"h",
|
|
2662
|
-
"hB"
|
|
2663
|
-
],
|
|
2664
|
-
"SD": [
|
|
2665
|
-
"h",
|
|
2666
|
-
"hB",
|
|
2667
|
-
"hb",
|
|
2668
|
-
"H"
|
|
2669
|
-
],
|
|
2670
|
-
"SE": ["H"],
|
|
2671
|
-
"SG": [
|
|
2672
|
-
"h",
|
|
2673
|
-
"hb",
|
|
2674
|
-
"H",
|
|
2675
|
-
"hB"
|
|
2676
|
-
],
|
|
2677
|
-
"SH": [
|
|
2678
|
-
"H",
|
|
2679
|
-
"h",
|
|
2680
|
-
"hb",
|
|
2681
|
-
"hB"
|
|
2682
|
-
],
|
|
2683
|
-
"SI": ["H", "hB"],
|
|
2684
|
-
"SJ": ["H"],
|
|
2685
|
-
"SK": ["H"],
|
|
2686
|
-
"SL": [
|
|
2687
|
-
"h",
|
|
2688
|
-
"hb",
|
|
2689
|
-
"H",
|
|
2690
|
-
"hB"
|
|
2691
|
-
],
|
|
2692
|
-
"SM": [
|
|
2693
|
-
"H",
|
|
2694
|
-
"h",
|
|
2695
|
-
"hB"
|
|
2696
|
-
],
|
|
2697
|
-
"SN": [
|
|
2698
|
-
"H",
|
|
2699
|
-
"h",
|
|
2700
|
-
"hB"
|
|
2701
|
-
],
|
|
2702
|
-
"SO": ["h", "H"],
|
|
2703
|
-
"SR": ["H", "hB"],
|
|
2704
|
-
"SS": [
|
|
2705
|
-
"h",
|
|
2706
|
-
"hb",
|
|
2707
|
-
"H",
|
|
2708
|
-
"hB"
|
|
2709
|
-
],
|
|
2710
|
-
"ST": ["H", "hB"],
|
|
2711
|
-
"SV": [
|
|
2712
|
-
"h",
|
|
2713
|
-
"H",
|
|
2714
|
-
"hB",
|
|
2715
|
-
"hb"
|
|
2716
|
-
],
|
|
2717
|
-
"SX": [
|
|
2718
|
-
"H",
|
|
2719
|
-
"h",
|
|
2720
|
-
"hb",
|
|
2721
|
-
"hB"
|
|
2722
|
-
],
|
|
2723
|
-
"SY": [
|
|
2724
|
-
"h",
|
|
2725
|
-
"hB",
|
|
2726
|
-
"hb",
|
|
2727
|
-
"H"
|
|
2728
|
-
],
|
|
2729
|
-
"SZ": [
|
|
2730
|
-
"h",
|
|
2731
|
-
"hb",
|
|
2732
|
-
"H",
|
|
2733
|
-
"hB"
|
|
2734
|
-
],
|
|
2735
|
-
"TA": [
|
|
2736
|
-
"H",
|
|
2737
|
-
"h",
|
|
2738
|
-
"hb",
|
|
2739
|
-
"hB"
|
|
2740
|
-
],
|
|
2741
|
-
"TC": [
|
|
2742
|
-
"h",
|
|
2743
|
-
"hb",
|
|
2744
|
-
"H",
|
|
2745
|
-
"hB"
|
|
2746
|
-
],
|
|
2747
|
-
"TD": [
|
|
2748
|
-
"h",
|
|
2749
|
-
"H",
|
|
2750
|
-
"hB"
|
|
2751
|
-
],
|
|
2752
|
-
"TF": [
|
|
2753
|
-
"H",
|
|
2754
|
-
"h",
|
|
2755
|
-
"hB"
|
|
2756
|
-
],
|
|
2757
|
-
"TG": ["H", "hB"],
|
|
2758
|
-
"TH": ["H", "h"],
|
|
2759
|
-
"TJ": ["H", "h"],
|
|
2760
|
-
"TL": [
|
|
2761
|
-
"H",
|
|
2762
|
-
"hB",
|
|
2763
|
-
"hb",
|
|
2764
|
-
"h"
|
|
2765
|
-
],
|
|
2766
|
-
"TM": ["H", "h"],
|
|
2767
|
-
"TN": [
|
|
2768
|
-
"h",
|
|
2769
|
-
"hB",
|
|
2770
|
-
"hb",
|
|
2771
|
-
"H"
|
|
2772
|
-
],
|
|
2773
|
-
"TO": ["h", "H"],
|
|
2774
|
-
"TR": ["H", "hB"],
|
|
2775
|
-
"TT": [
|
|
2776
|
-
"h",
|
|
2777
|
-
"hb",
|
|
2778
|
-
"H",
|
|
2779
|
-
"hB"
|
|
2780
|
-
],
|
|
2781
|
-
"TW": [
|
|
2782
|
-
"hB",
|
|
2783
|
-
"hb",
|
|
2784
|
-
"h",
|
|
2785
|
-
"H"
|
|
2786
|
-
],
|
|
2787
|
-
"TZ": [
|
|
2788
|
-
"hB",
|
|
2789
|
-
"hb",
|
|
2790
|
-
"H",
|
|
2791
|
-
"h"
|
|
2792
|
-
],
|
|
2793
|
-
"UA": [
|
|
2794
|
-
"H",
|
|
2795
|
-
"hB",
|
|
2796
|
-
"h"
|
|
2797
|
-
],
|
|
2798
|
-
"UG": [
|
|
2799
|
-
"hB",
|
|
2800
|
-
"hb",
|
|
2801
|
-
"H",
|
|
2802
|
-
"h"
|
|
2803
|
-
],
|
|
2804
|
-
"UM": [
|
|
2805
|
-
"h",
|
|
2806
|
-
"hb",
|
|
2807
|
-
"H",
|
|
2808
|
-
"hB"
|
|
2809
|
-
],
|
|
2810
|
-
"US": [
|
|
2811
|
-
"h",
|
|
2812
|
-
"hb",
|
|
2813
|
-
"H",
|
|
2814
|
-
"hB"
|
|
2815
|
-
],
|
|
2816
|
-
"UY": [
|
|
2817
|
-
"h",
|
|
2818
|
-
"H",
|
|
2819
|
-
"hB",
|
|
2820
|
-
"hb"
|
|
2821
|
-
],
|
|
2822
|
-
"UZ": [
|
|
2823
|
-
"H",
|
|
2824
|
-
"hB",
|
|
2825
|
-
"h"
|
|
2826
|
-
],
|
|
2827
|
-
"VA": [
|
|
2828
|
-
"H",
|
|
2829
|
-
"h",
|
|
2830
|
-
"hB"
|
|
2831
|
-
],
|
|
2832
|
-
"VC": [
|
|
2833
|
-
"h",
|
|
2834
|
-
"hb",
|
|
2835
|
-
"H",
|
|
2836
|
-
"hB"
|
|
2837
|
-
],
|
|
2838
|
-
"VE": [
|
|
2839
|
-
"h",
|
|
2840
|
-
"H",
|
|
2841
|
-
"hB",
|
|
2842
|
-
"hb"
|
|
2843
|
-
],
|
|
2844
|
-
"VG": [
|
|
2845
|
-
"h",
|
|
2846
|
-
"hb",
|
|
2847
|
-
"H",
|
|
2848
|
-
"hB"
|
|
2849
|
-
],
|
|
2850
|
-
"VI": [
|
|
2851
|
-
"h",
|
|
2852
|
-
"hb",
|
|
2853
|
-
"H",
|
|
2854
|
-
"hB"
|
|
2855
|
-
],
|
|
2856
|
-
"VN": ["H", "h"],
|
|
2857
|
-
"VU": ["h", "H"],
|
|
2858
|
-
"WF": ["H", "hB"],
|
|
2859
|
-
"WS": ["h", "H"],
|
|
2860
|
-
"XK": [
|
|
2861
|
-
"H",
|
|
2862
|
-
"hB",
|
|
2863
|
-
"h"
|
|
2864
|
-
],
|
|
2865
|
-
"YE": [
|
|
2866
|
-
"h",
|
|
2867
|
-
"hB",
|
|
2868
|
-
"hb",
|
|
2869
|
-
"H"
|
|
2870
|
-
],
|
|
2871
|
-
"YT": ["H", "hB"],
|
|
2872
|
-
"ZA": [
|
|
2873
|
-
"H",
|
|
2874
|
-
"h",
|
|
2875
|
-
"hb",
|
|
2876
|
-
"hB"
|
|
2877
|
-
],
|
|
2878
|
-
"ZM": [
|
|
2879
|
-
"h",
|
|
2880
|
-
"hb",
|
|
2881
|
-
"H",
|
|
2882
|
-
"hB"
|
|
2883
|
-
],
|
|
2884
|
-
"ZW": ["H", "h"],
|
|
2885
|
-
"af-ZA": [
|
|
2886
|
-
"H",
|
|
2887
|
-
"h",
|
|
2888
|
-
"hB",
|
|
2889
|
-
"hb"
|
|
2890
|
-
],
|
|
2891
|
-
"ar-001": [
|
|
2892
|
-
"h",
|
|
2893
|
-
"hB",
|
|
2894
|
-
"hb",
|
|
2895
|
-
"H"
|
|
2896
|
-
],
|
|
2897
|
-
"ca-ES": [
|
|
2898
|
-
"H",
|
|
2899
|
-
"h",
|
|
2900
|
-
"hB"
|
|
2901
|
-
],
|
|
2902
|
-
"en-001": [
|
|
2903
|
-
"h",
|
|
2904
|
-
"hb",
|
|
2905
|
-
"H",
|
|
2906
|
-
"hB"
|
|
2907
|
-
],
|
|
2908
|
-
"en-HK": [
|
|
2909
|
-
"h",
|
|
2910
|
-
"hb",
|
|
2911
|
-
"H",
|
|
2912
|
-
"hB"
|
|
2913
|
-
],
|
|
2914
|
-
"en-IL": [
|
|
2915
|
-
"H",
|
|
2916
|
-
"h",
|
|
2917
|
-
"hb",
|
|
2918
|
-
"hB"
|
|
2919
|
-
],
|
|
2920
|
-
"en-MY": [
|
|
2921
|
-
"h",
|
|
2922
|
-
"hb",
|
|
2923
|
-
"H",
|
|
2924
|
-
"hB"
|
|
2925
|
-
],
|
|
2926
|
-
"es-BR": [
|
|
2927
|
-
"H",
|
|
2928
|
-
"h",
|
|
2929
|
-
"hB",
|
|
2930
|
-
"hb"
|
|
2931
|
-
],
|
|
2932
|
-
"es-ES": [
|
|
2933
|
-
"H",
|
|
2934
|
-
"h",
|
|
2935
|
-
"hB",
|
|
2936
|
-
"hb"
|
|
2937
|
-
],
|
|
2938
|
-
"es-GQ": [
|
|
2939
|
-
"H",
|
|
2940
|
-
"h",
|
|
2941
|
-
"hB",
|
|
2942
|
-
"hb"
|
|
2943
|
-
],
|
|
2944
|
-
"fr-CA": [
|
|
2945
|
-
"H",
|
|
2946
|
-
"h",
|
|
2947
|
-
"hB"
|
|
2948
|
-
],
|
|
2949
|
-
"gl-ES": [
|
|
2950
|
-
"H",
|
|
2951
|
-
"h",
|
|
2952
|
-
"hB"
|
|
2953
|
-
],
|
|
2954
|
-
"gu-IN": [
|
|
2955
|
-
"hB",
|
|
2956
|
-
"hb",
|
|
2957
|
-
"h",
|
|
2958
|
-
"H"
|
|
2959
|
-
],
|
|
2960
|
-
"hi-IN": [
|
|
2961
|
-
"hB",
|
|
2962
|
-
"h",
|
|
2963
|
-
"H"
|
|
2964
|
-
],
|
|
2965
|
-
"it-CH": [
|
|
2966
|
-
"H",
|
|
2967
|
-
"h",
|
|
2968
|
-
"hB"
|
|
2969
|
-
],
|
|
2970
|
-
"it-IT": [
|
|
2971
|
-
"H",
|
|
2972
|
-
"h",
|
|
2973
|
-
"hB"
|
|
2974
|
-
],
|
|
2975
|
-
"kn-IN": [
|
|
2976
|
-
"hB",
|
|
2977
|
-
"h",
|
|
2978
|
-
"H"
|
|
2979
|
-
],
|
|
2980
|
-
"ku-SY": ["H", "hB"],
|
|
2981
|
-
"ml-IN": [
|
|
2982
|
-
"hB",
|
|
2983
|
-
"h",
|
|
2984
|
-
"H"
|
|
2985
|
-
],
|
|
2986
|
-
"mr-IN": [
|
|
2987
|
-
"hB",
|
|
2988
|
-
"hb",
|
|
2989
|
-
"h",
|
|
2990
|
-
"H"
|
|
2991
|
-
],
|
|
2992
|
-
"pa-IN": [
|
|
2993
|
-
"hB",
|
|
2994
|
-
"hb",
|
|
2995
|
-
"h",
|
|
2996
|
-
"H"
|
|
2997
|
-
],
|
|
2998
|
-
"ta-IN": [
|
|
2999
|
-
"hB",
|
|
3000
|
-
"h",
|
|
3001
|
-
"hb",
|
|
3002
|
-
"H"
|
|
3003
|
-
],
|
|
3004
|
-
"te-IN": [
|
|
3005
|
-
"hB",
|
|
3006
|
-
"h",
|
|
3007
|
-
"H"
|
|
3008
|
-
],
|
|
3009
|
-
"zu-ZA": [
|
|
3010
|
-
"H",
|
|
3011
|
-
"hB",
|
|
3012
|
-
"hb",
|
|
3013
|
-
"h"
|
|
3014
|
-
]
|
|
3015
|
-
};
|
|
3016
|
-
function getBestPattern(skeleton, locale) {
|
|
3017
|
-
let skeletonCopy = "";
|
|
3018
|
-
for (let patternPos = 0; patternPos < skeleton.length; patternPos++) {
|
|
3019
|
-
const patternChar = skeleton.charAt(patternPos);
|
|
3020
|
-
if (patternChar === "j") {
|
|
3021
|
-
let extraLength = 0;
|
|
3022
|
-
while (patternPos + 1 < skeleton.length && skeleton.charAt(patternPos + 1) === patternChar) {
|
|
3023
|
-
extraLength++;
|
|
3024
|
-
patternPos++;
|
|
3025
|
-
}
|
|
3026
|
-
let hourLen = 1 + (extraLength & 1);
|
|
3027
|
-
let dayPeriodLen = extraLength < 2 ? 1 : 3 + (extraLength >> 1);
|
|
3028
|
-
let dayPeriodChar = "a";
|
|
3029
|
-
let hourChar = getDefaultHourSymbolFromLocale(locale);
|
|
3030
|
-
if (hourChar == "H" || hourChar == "k") {
|
|
3031
|
-
dayPeriodLen = 0;
|
|
3032
|
-
}
|
|
3033
|
-
while (dayPeriodLen-- > 0) {
|
|
3034
|
-
skeletonCopy += dayPeriodChar;
|
|
3035
|
-
}
|
|
3036
|
-
while (hourLen-- > 0) {
|
|
3037
|
-
skeletonCopy = hourChar + skeletonCopy;
|
|
3038
|
-
}
|
|
3039
|
-
} else if (patternChar === "J") {
|
|
3040
|
-
skeletonCopy += "H";
|
|
3041
|
-
} else {
|
|
3042
|
-
skeletonCopy += patternChar;
|
|
3043
|
-
}
|
|
3044
|
-
}
|
|
3045
|
-
return skeletonCopy;
|
|
3046
|
-
}
|
|
3047
|
-
function getDefaultHourSymbolFromLocale(locale) {
|
|
3048
|
-
let hourCycle = locale.hourCycle;
|
|
3049
|
-
if (hourCycle === void 0 && locale.hourCycles && locale.hourCycles.length) {
|
|
3050
|
-
hourCycle = locale.hourCycles[0];
|
|
3051
|
-
}
|
|
3052
|
-
if (hourCycle) {
|
|
3053
|
-
switch (hourCycle) {
|
|
3054
|
-
case "h24":
|
|
3055
|
-
return "k";
|
|
3056
|
-
case "h23":
|
|
3057
|
-
return "H";
|
|
3058
|
-
case "h12":
|
|
3059
|
-
return "h";
|
|
3060
|
-
case "h11":
|
|
3061
|
-
return "K";
|
|
3062
|
-
default:
|
|
3063
|
-
throw new Error("Invalid hourCycle");
|
|
3064
|
-
}
|
|
3065
|
-
}
|
|
3066
|
-
const languageTag = locale.language;
|
|
3067
|
-
let regionTag;
|
|
3068
|
-
if (languageTag !== "root") {
|
|
3069
|
-
regionTag = locale.maximize().region;
|
|
3070
|
-
}
|
|
3071
|
-
const hourCycles = timeData[regionTag || ""] || timeData[languageTag || ""] || timeData[`${languageTag}-001`] || timeData["001"];
|
|
3072
|
-
return hourCycles[0];
|
|
3073
|
-
}
|
|
3074
|
-
const SPACE_SEPARATOR_START_REGEX = new RegExp(`^${SPACE_SEPARATOR_REGEX.source}*`);
|
|
3075
|
-
const SPACE_SEPARATOR_END_REGEX = new RegExp(`${SPACE_SEPARATOR_REGEX.source}*$`);
|
|
3076
|
-
function createLocation(start, end) {
|
|
3077
|
-
return {
|
|
3078
|
-
start,
|
|
3079
|
-
end
|
|
3080
|
-
};
|
|
3081
|
-
}
|
|
3082
|
-
const hasNativeFromEntries = !!Object.fromEntries;
|
|
3083
|
-
const hasTrimStart = !!String.prototype.trimStart;
|
|
3084
|
-
const hasTrimEnd = !!String.prototype.trimEnd;
|
|
3085
|
-
const fromEntries = hasNativeFromEntries ? Object.fromEntries : function fromEntries2(entries) {
|
|
3086
|
-
const obj = {};
|
|
3087
|
-
for (const [k, v] of entries) {
|
|
3088
|
-
obj[k] = v;
|
|
3089
|
-
}
|
|
3090
|
-
return obj;
|
|
3091
|
-
};
|
|
3092
|
-
const trimStart = hasTrimStart ? function trimStart2(s) {
|
|
3093
|
-
return s.trimStart();
|
|
3094
|
-
} : function trimStart3(s) {
|
|
3095
|
-
return s.replace(SPACE_SEPARATOR_START_REGEX, "");
|
|
3096
|
-
};
|
|
3097
|
-
const trimEnd = hasTrimEnd ? function trimEnd2(s) {
|
|
3098
|
-
return s.trimEnd();
|
|
3099
|
-
} : function trimEnd3(s) {
|
|
3100
|
-
return s.replace(SPACE_SEPARATOR_END_REGEX, "");
|
|
3101
|
-
};
|
|
3102
|
-
const IDENTIFIER_PREFIX_RE = new RegExp("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
|
|
3103
|
-
function matchIdentifierAtIndex(s, index) {
|
|
3104
|
-
IDENTIFIER_PREFIX_RE.lastIndex = index;
|
|
3105
|
-
const match = IDENTIFIER_PREFIX_RE.exec(s);
|
|
3106
|
-
return match[1] ?? "";
|
|
3107
|
-
}
|
|
3108
|
-
class Parser {
|
|
3109
|
-
message;
|
|
3110
|
-
position;
|
|
3111
|
-
locale;
|
|
3112
|
-
ignoreTag;
|
|
3113
|
-
requiresOtherClause;
|
|
3114
|
-
shouldParseSkeletons;
|
|
3115
|
-
constructor(message, options = {}) {
|
|
3116
|
-
this.message = message;
|
|
3117
|
-
this.position = {
|
|
3118
|
-
offset: 0,
|
|
3119
|
-
line: 1,
|
|
3120
|
-
column: 1
|
|
3121
|
-
};
|
|
3122
|
-
this.ignoreTag = !!options.ignoreTag;
|
|
3123
|
-
this.locale = options.locale;
|
|
3124
|
-
this.requiresOtherClause = !!options.requiresOtherClause;
|
|
3125
|
-
this.shouldParseSkeletons = !!options.shouldParseSkeletons;
|
|
3126
|
-
}
|
|
3127
|
-
parse() {
|
|
3128
|
-
if (this.offset() !== 0) {
|
|
3129
|
-
throw Error("parser can only be used once");
|
|
3130
|
-
}
|
|
3131
|
-
return this.parseMessage(0, "", false);
|
|
3132
|
-
}
|
|
3133
|
-
parseMessage(nestingLevel, parentArgType, expectingCloseTag) {
|
|
3134
|
-
let elements = [];
|
|
3135
|
-
while (!this.isEOF()) {
|
|
3136
|
-
const char = this.char();
|
|
3137
|
-
if (char === 123) {
|
|
3138
|
-
const result = this.parseArgument(nestingLevel, expectingCloseTag);
|
|
3139
|
-
if (result.err) {
|
|
3140
|
-
return result;
|
|
3141
|
-
}
|
|
3142
|
-
elements.push(result.val);
|
|
3143
|
-
} else if (char === 125 && nestingLevel > 0) {
|
|
3144
|
-
break;
|
|
3145
|
-
} else if (char === 35 && (parentArgType === "plural" || parentArgType === "selectordinal")) {
|
|
3146
|
-
const position = this.clonePosition();
|
|
3147
|
-
this.bump();
|
|
3148
|
-
elements.push({
|
|
3149
|
-
type: TYPE.pound,
|
|
3150
|
-
location: createLocation(position, this.clonePosition())
|
|
3151
|
-
});
|
|
3152
|
-
} else if (char === 60 && !this.ignoreTag && this.peek() === 47) {
|
|
3153
|
-
if (expectingCloseTag) {
|
|
3154
|
-
break;
|
|
3155
|
-
} else {
|
|
3156
|
-
return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(this.clonePosition(), this.clonePosition()));
|
|
3157
|
-
}
|
|
3158
|
-
} else if (char === 60 && !this.ignoreTag && _isAlpha(this.peek() || 0)) {
|
|
3159
|
-
const result = this.parseTag(nestingLevel, parentArgType);
|
|
3160
|
-
if (result.err) {
|
|
3161
|
-
return result;
|
|
3162
|
-
}
|
|
3163
|
-
elements.push(result.val);
|
|
3164
|
-
} else {
|
|
3165
|
-
const result = this.parseLiteral(nestingLevel, parentArgType);
|
|
3166
|
-
if (result.err) {
|
|
3167
|
-
return result;
|
|
3168
|
-
}
|
|
3169
|
-
elements.push(result.val);
|
|
3170
|
-
}
|
|
3171
|
-
}
|
|
3172
|
-
return {
|
|
3173
|
-
val: elements,
|
|
3174
|
-
err: null
|
|
3175
|
-
};
|
|
3176
|
-
}
|
|
3177
|
-
/**
|
|
3178
|
-
* A tag name must start with an ASCII lower/upper case letter. The grammar is based on the
|
|
3179
|
-
* [custom element name][] except that a dash is NOT always mandatory and uppercase letters
|
|
3180
|
-
* are accepted:
|
|
3181
|
-
*
|
|
3182
|
-
* ```
|
|
3183
|
-
* tag ::= "<" tagName (whitespace)* "/>" | "<" tagName (whitespace)* ">" message "</" tagName (whitespace)* ">"
|
|
3184
|
-
* tagName ::= [a-z] (PENChar)*
|
|
3185
|
-
* PENChar ::=
|
|
3186
|
-
* "-" | "." | [0-9] | "_" | [a-z] | [A-Z] | #xB7 | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x37D] |
|
|
3187
|
-
* [#x37F-#x1FFF] | [#x200C-#x200D] | [#x203F-#x2040] | [#x2070-#x218F] | [#x2C00-#x2FEF] |
|
|
3188
|
-
* [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
|
|
3189
|
-
* ```
|
|
3190
|
-
*
|
|
3191
|
-
* [custom element name]: https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
|
|
3192
|
-
* NOTE: We're a bit more lax here since HTML technically does not allow uppercase HTML element but we do
|
|
3193
|
-
* since other tag-based engines like React allow it
|
|
3194
|
-
*/
|
|
3195
|
-
parseTag(nestingLevel, parentArgType) {
|
|
3196
|
-
const startPosition = this.clonePosition();
|
|
3197
|
-
this.bump();
|
|
3198
|
-
const tagName = this.parseTagName();
|
|
3199
|
-
this.bumpSpace();
|
|
3200
|
-
if (this.bumpIf("/>")) {
|
|
3201
|
-
return {
|
|
3202
|
-
val: {
|
|
3203
|
-
type: TYPE.literal,
|
|
3204
|
-
value: `<${tagName}/>`,
|
|
3205
|
-
location: createLocation(startPosition, this.clonePosition())
|
|
3206
|
-
},
|
|
3207
|
-
err: null
|
|
3208
|
-
};
|
|
3209
|
-
} else if (this.bumpIf(">")) {
|
|
3210
|
-
const childrenResult = this.parseMessage(nestingLevel + 1, parentArgType, true);
|
|
3211
|
-
if (childrenResult.err) {
|
|
3212
|
-
return childrenResult;
|
|
3213
|
-
}
|
|
3214
|
-
const children = childrenResult.val;
|
|
3215
|
-
const endTagStartPosition = this.clonePosition();
|
|
3216
|
-
if (this.bumpIf("</")) {
|
|
3217
|
-
if (this.isEOF() || !_isAlpha(this.char())) {
|
|
3218
|
-
return this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition()));
|
|
3219
|
-
}
|
|
3220
|
-
const closingTagNameStartPosition = this.clonePosition();
|
|
3221
|
-
const closingTagName = this.parseTagName();
|
|
3222
|
-
if (tagName !== closingTagName) {
|
|
3223
|
-
return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(closingTagNameStartPosition, this.clonePosition()));
|
|
3224
|
-
}
|
|
3225
|
-
this.bumpSpace();
|
|
3226
|
-
if (!this.bumpIf(">")) {
|
|
3227
|
-
return this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition()));
|
|
3228
|
-
}
|
|
3229
|
-
return {
|
|
3230
|
-
val: {
|
|
3231
|
-
type: TYPE.tag,
|
|
3232
|
-
value: tagName,
|
|
3233
|
-
children,
|
|
3234
|
-
location: createLocation(startPosition, this.clonePosition())
|
|
3235
|
-
},
|
|
3236
|
-
err: null
|
|
3237
|
-
};
|
|
3238
|
-
} else {
|
|
3239
|
-
return this.error(ErrorKind.UNCLOSED_TAG, createLocation(startPosition, this.clonePosition()));
|
|
3240
|
-
}
|
|
3241
|
-
} else {
|
|
3242
|
-
return this.error(ErrorKind.INVALID_TAG, createLocation(startPosition, this.clonePosition()));
|
|
3243
|
-
}
|
|
3244
|
-
}
|
|
3245
|
-
/**
|
|
3246
|
-
* This method assumes that the caller has peeked ahead for the first tag character.
|
|
3247
|
-
*/
|
|
3248
|
-
parseTagName() {
|
|
3249
|
-
const startOffset = this.offset();
|
|
3250
|
-
this.bump();
|
|
3251
|
-
while (!this.isEOF() && _isPotentialElementNameChar(this.char())) {
|
|
3252
|
-
this.bump();
|
|
3253
|
-
}
|
|
3254
|
-
return this.message.slice(startOffset, this.offset());
|
|
3255
|
-
}
|
|
3256
|
-
parseLiteral(nestingLevel, parentArgType) {
|
|
3257
|
-
const start = this.clonePosition();
|
|
3258
|
-
let value = "";
|
|
3259
|
-
while (true) {
|
|
3260
|
-
const parseQuoteResult = this.tryParseQuote(parentArgType);
|
|
3261
|
-
if (parseQuoteResult) {
|
|
3262
|
-
value += parseQuoteResult;
|
|
3263
|
-
continue;
|
|
3264
|
-
}
|
|
3265
|
-
const parseUnquotedResult = this.tryParseUnquoted(nestingLevel, parentArgType);
|
|
3266
|
-
if (parseUnquotedResult) {
|
|
3267
|
-
value += parseUnquotedResult;
|
|
3268
|
-
continue;
|
|
3269
|
-
}
|
|
3270
|
-
const parseLeftAngleResult = this.tryParseLeftAngleBracket();
|
|
3271
|
-
if (parseLeftAngleResult) {
|
|
3272
|
-
value += parseLeftAngleResult;
|
|
3273
|
-
continue;
|
|
3274
|
-
}
|
|
3275
|
-
break;
|
|
3276
|
-
}
|
|
3277
|
-
const location = createLocation(start, this.clonePosition());
|
|
3278
|
-
return {
|
|
3279
|
-
val: {
|
|
3280
|
-
type: TYPE.literal,
|
|
3281
|
-
value,
|
|
3282
|
-
location
|
|
3283
|
-
},
|
|
3284
|
-
err: null
|
|
3285
|
-
};
|
|
3286
|
-
}
|
|
3287
|
-
tryParseLeftAngleBracket() {
|
|
3288
|
-
if (!this.isEOF() && this.char() === 60 && (this.ignoreTag || !_isAlphaOrSlash(this.peek() || 0))) {
|
|
3289
|
-
this.bump();
|
|
3290
|
-
return "<";
|
|
3291
|
-
}
|
|
3292
|
-
return null;
|
|
3293
|
-
}
|
|
3294
|
-
/**
|
|
3295
|
-
* Starting with ICU 4.8, an ASCII apostrophe only starts quoted text if it immediately precedes
|
|
3296
|
-
* a character that requires quoting (that is, "only where needed"), and works the same in
|
|
3297
|
-
* nested messages as on the top level of the pattern. The new behavior is otherwise compatible.
|
|
3298
|
-
*/
|
|
3299
|
-
tryParseQuote(parentArgType) {
|
|
3300
|
-
if (this.isEOF() || this.char() !== 39) {
|
|
3301
|
-
return null;
|
|
3302
|
-
}
|
|
3303
|
-
switch (this.peek()) {
|
|
3304
|
-
case 39:
|
|
3305
|
-
this.bump();
|
|
3306
|
-
this.bump();
|
|
3307
|
-
return "'";
|
|
3308
|
-
case 123:
|
|
3309
|
-
case 60:
|
|
3310
|
-
case 62:
|
|
3311
|
-
case 125:
|
|
3312
|
-
break;
|
|
3313
|
-
case 35:
|
|
3314
|
-
if (parentArgType === "plural" || parentArgType === "selectordinal") {
|
|
3315
|
-
break;
|
|
3316
|
-
}
|
|
3317
|
-
return null;
|
|
3318
|
-
default:
|
|
3319
|
-
return null;
|
|
3320
|
-
}
|
|
3321
|
-
this.bump();
|
|
3322
|
-
const codePoints = [this.char()];
|
|
3323
|
-
this.bump();
|
|
3324
|
-
while (!this.isEOF()) {
|
|
3325
|
-
const ch = this.char();
|
|
3326
|
-
if (ch === 39) {
|
|
3327
|
-
if (this.peek() === 39) {
|
|
3328
|
-
codePoints.push(39);
|
|
3329
|
-
this.bump();
|
|
3330
|
-
} else {
|
|
3331
|
-
this.bump();
|
|
3332
|
-
break;
|
|
3333
|
-
}
|
|
3334
|
-
} else {
|
|
3335
|
-
codePoints.push(ch);
|
|
3336
|
-
}
|
|
3337
|
-
this.bump();
|
|
3338
|
-
}
|
|
3339
|
-
return String.fromCodePoint(...codePoints);
|
|
3340
|
-
}
|
|
3341
|
-
tryParseUnquoted(nestingLevel, parentArgType) {
|
|
3342
|
-
if (this.isEOF()) {
|
|
3343
|
-
return null;
|
|
3344
|
-
}
|
|
3345
|
-
const ch = this.char();
|
|
3346
|
-
if (ch === 60 || ch === 123 || ch === 35 && (parentArgType === "plural" || parentArgType === "selectordinal") || ch === 125 && nestingLevel > 0) {
|
|
3347
|
-
return null;
|
|
3348
|
-
} else {
|
|
3349
|
-
this.bump();
|
|
3350
|
-
return String.fromCodePoint(ch);
|
|
3351
|
-
}
|
|
3352
|
-
}
|
|
3353
|
-
parseArgument(nestingLevel, expectingCloseTag) {
|
|
3354
|
-
const openingBracePosition = this.clonePosition();
|
|
3355
|
-
this.bump();
|
|
3356
|
-
this.bumpSpace();
|
|
3357
|
-
if (this.isEOF()) {
|
|
3358
|
-
return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
|
|
3359
|
-
}
|
|
3360
|
-
if (this.char() === 125) {
|
|
3361
|
-
this.bump();
|
|
3362
|
-
return this.error(ErrorKind.EMPTY_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
|
|
3363
|
-
}
|
|
3364
|
-
let value = this.parseIdentifierIfPossible().value;
|
|
3365
|
-
if (!value) {
|
|
3366
|
-
return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
|
|
3367
|
-
}
|
|
3368
|
-
this.bumpSpace();
|
|
3369
|
-
if (this.isEOF()) {
|
|
3370
|
-
return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
|
|
3371
|
-
}
|
|
3372
|
-
switch (this.char()) {
|
|
3373
|
-
case 125: {
|
|
3374
|
-
this.bump();
|
|
3375
|
-
return {
|
|
3376
|
-
val: {
|
|
3377
|
-
type: TYPE.argument,
|
|
3378
|
-
value,
|
|
3379
|
-
location: createLocation(openingBracePosition, this.clonePosition())
|
|
3380
|
-
},
|
|
3381
|
-
err: null
|
|
3382
|
-
};
|
|
3383
|
-
}
|
|
3384
|
-
case 44: {
|
|
3385
|
-
this.bump();
|
|
3386
|
-
this.bumpSpace();
|
|
3387
|
-
if (this.isEOF()) {
|
|
3388
|
-
return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
|
|
3389
|
-
}
|
|
3390
|
-
return this.parseArgumentOptions(nestingLevel, expectingCloseTag, value, openingBracePosition);
|
|
3391
|
-
}
|
|
3392
|
-
default:
|
|
3393
|
-
return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
|
|
3394
|
-
}
|
|
3395
|
-
}
|
|
3396
|
-
/**
|
|
3397
|
-
* Advance the parser until the end of the identifier, if it is currently on
|
|
3398
|
-
* an identifier character. Return an empty string otherwise.
|
|
3399
|
-
*/
|
|
3400
|
-
parseIdentifierIfPossible() {
|
|
3401
|
-
const startingPosition = this.clonePosition();
|
|
3402
|
-
const startOffset = this.offset();
|
|
3403
|
-
const value = matchIdentifierAtIndex(this.message, startOffset);
|
|
3404
|
-
const endOffset = startOffset + value.length;
|
|
3405
|
-
this.bumpTo(endOffset);
|
|
3406
|
-
const endPosition = this.clonePosition();
|
|
3407
|
-
const location = createLocation(startingPosition, endPosition);
|
|
3408
|
-
return {
|
|
3409
|
-
value,
|
|
3410
|
-
location
|
|
3411
|
-
};
|
|
3412
|
-
}
|
|
3413
|
-
parseArgumentOptions(nestingLevel, expectingCloseTag, value, openingBracePosition) {
|
|
3414
|
-
let typeStartPosition = this.clonePosition();
|
|
3415
|
-
let argType = this.parseIdentifierIfPossible().value;
|
|
3416
|
-
let typeEndPosition = this.clonePosition();
|
|
3417
|
-
switch (argType) {
|
|
3418
|
-
case "":
|
|
3419
|
-
return this.error(ErrorKind.EXPECT_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
|
|
3420
|
-
case "number":
|
|
3421
|
-
case "date":
|
|
3422
|
-
case "time": {
|
|
3423
|
-
this.bumpSpace();
|
|
3424
|
-
let styleAndLocation = null;
|
|
3425
|
-
if (this.bumpIf(",")) {
|
|
3426
|
-
this.bumpSpace();
|
|
3427
|
-
const styleStartPosition = this.clonePosition();
|
|
3428
|
-
const result = this.parseSimpleArgStyleIfPossible();
|
|
3429
|
-
if (result.err) {
|
|
3430
|
-
return result;
|
|
3431
|
-
}
|
|
3432
|
-
const style = trimEnd(result.val);
|
|
3433
|
-
if (style.length === 0) {
|
|
3434
|
-
return this.error(ErrorKind.EXPECT_ARGUMENT_STYLE, createLocation(this.clonePosition(), this.clonePosition()));
|
|
3435
|
-
}
|
|
3436
|
-
const styleLocation = createLocation(styleStartPosition, this.clonePosition());
|
|
3437
|
-
styleAndLocation = {
|
|
3438
|
-
style,
|
|
3439
|
-
styleLocation
|
|
3440
|
-
};
|
|
3441
|
-
}
|
|
3442
|
-
const argCloseResult = this.tryParseArgumentClose(openingBracePosition);
|
|
3443
|
-
if (argCloseResult.err) {
|
|
3444
|
-
return argCloseResult;
|
|
3445
|
-
}
|
|
3446
|
-
const location = createLocation(openingBracePosition, this.clonePosition());
|
|
3447
|
-
if (styleAndLocation && styleAndLocation.style.startsWith("::")) {
|
|
3448
|
-
let skeleton = trimStart(styleAndLocation.style.slice(2));
|
|
3449
|
-
if (argType === "number") {
|
|
3450
|
-
const result = this.parseNumberSkeletonFromString(skeleton, styleAndLocation.styleLocation);
|
|
3451
|
-
if (result.err) {
|
|
3452
|
-
return result;
|
|
3453
|
-
}
|
|
3454
|
-
return {
|
|
3455
|
-
val: {
|
|
3456
|
-
type: TYPE.number,
|
|
3457
|
-
value,
|
|
3458
|
-
location,
|
|
3459
|
-
style: result.val
|
|
3460
|
-
},
|
|
3461
|
-
err: null
|
|
3462
|
-
};
|
|
3463
|
-
} else {
|
|
3464
|
-
if (skeleton.length === 0) {
|
|
3465
|
-
return this.error(ErrorKind.EXPECT_DATE_TIME_SKELETON, location);
|
|
3466
|
-
}
|
|
3467
|
-
let dateTimePattern = skeleton;
|
|
3468
|
-
if (this.locale) {
|
|
3469
|
-
dateTimePattern = getBestPattern(skeleton, this.locale);
|
|
3470
|
-
}
|
|
3471
|
-
const style = {
|
|
3472
|
-
type: SKELETON_TYPE.dateTime,
|
|
3473
|
-
pattern: dateTimePattern,
|
|
3474
|
-
location: styleAndLocation.styleLocation,
|
|
3475
|
-
parsedOptions: this.shouldParseSkeletons ? parseDateTimeSkeleton(dateTimePattern) : {}
|
|
3476
|
-
};
|
|
3477
|
-
const type = argType === "date" ? TYPE.date : TYPE.time;
|
|
3478
|
-
return {
|
|
3479
|
-
val: {
|
|
3480
|
-
type,
|
|
3481
|
-
value,
|
|
3482
|
-
location,
|
|
3483
|
-
style
|
|
3484
|
-
},
|
|
3485
|
-
err: null
|
|
3486
|
-
};
|
|
3487
|
-
}
|
|
3488
|
-
}
|
|
3489
|
-
return {
|
|
3490
|
-
val: {
|
|
3491
|
-
type: argType === "number" ? TYPE.number : argType === "date" ? TYPE.date : TYPE.time,
|
|
3492
|
-
value,
|
|
3493
|
-
location,
|
|
3494
|
-
style: styleAndLocation?.style ?? null
|
|
3495
|
-
},
|
|
3496
|
-
err: null
|
|
3497
|
-
};
|
|
3498
|
-
}
|
|
3499
|
-
case "plural":
|
|
3500
|
-
case "selectordinal":
|
|
3501
|
-
case "select": {
|
|
3502
|
-
const typeEndPosition2 = this.clonePosition();
|
|
3503
|
-
this.bumpSpace();
|
|
3504
|
-
if (!this.bumpIf(",")) {
|
|
3505
|
-
return this.error(ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, createLocation(typeEndPosition2, { ...typeEndPosition2 }));
|
|
3506
|
-
}
|
|
3507
|
-
this.bumpSpace();
|
|
3508
|
-
let identifierAndLocation = this.parseIdentifierIfPossible();
|
|
3509
|
-
let pluralOffset = 0;
|
|
3510
|
-
if (argType !== "select" && identifierAndLocation.value === "offset") {
|
|
3511
|
-
if (!this.bumpIf(":")) {
|
|
3512
|
-
return this.error(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, createLocation(this.clonePosition(), this.clonePosition()));
|
|
3513
|
-
}
|
|
3514
|
-
this.bumpSpace();
|
|
3515
|
-
const result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, ErrorKind.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);
|
|
3516
|
-
if (result.err) {
|
|
3517
|
-
return result;
|
|
3518
|
-
}
|
|
3519
|
-
this.bumpSpace();
|
|
3520
|
-
identifierAndLocation = this.parseIdentifierIfPossible();
|
|
3521
|
-
pluralOffset = result.val;
|
|
3522
|
-
}
|
|
3523
|
-
const optionsResult = this.tryParsePluralOrSelectOptions(nestingLevel, argType, expectingCloseTag, identifierAndLocation);
|
|
3524
|
-
if (optionsResult.err) {
|
|
3525
|
-
return optionsResult;
|
|
3526
|
-
}
|
|
3527
|
-
const argCloseResult = this.tryParseArgumentClose(openingBracePosition);
|
|
3528
|
-
if (argCloseResult.err) {
|
|
3529
|
-
return argCloseResult;
|
|
3530
|
-
}
|
|
3531
|
-
const location = createLocation(openingBracePosition, this.clonePosition());
|
|
3532
|
-
if (argType === "select") {
|
|
3533
|
-
return {
|
|
3534
|
-
val: {
|
|
3535
|
-
type: TYPE.select,
|
|
3536
|
-
value,
|
|
3537
|
-
options: fromEntries(optionsResult.val),
|
|
3538
|
-
location
|
|
3539
|
-
},
|
|
3540
|
-
err: null
|
|
3541
|
-
};
|
|
3542
|
-
} else {
|
|
3543
|
-
return {
|
|
3544
|
-
val: {
|
|
3545
|
-
type: TYPE.plural,
|
|
3546
|
-
value,
|
|
3547
|
-
options: fromEntries(optionsResult.val),
|
|
3548
|
-
offset: pluralOffset,
|
|
3549
|
-
pluralType: argType === "plural" ? "cardinal" : "ordinal",
|
|
3550
|
-
location
|
|
3551
|
-
},
|
|
3552
|
-
err: null
|
|
3553
|
-
};
|
|
3554
|
-
}
|
|
3555
|
-
}
|
|
3556
|
-
default:
|
|
3557
|
-
return this.error(ErrorKind.INVALID_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
|
|
3558
|
-
}
|
|
3559
|
-
}
|
|
3560
|
-
tryParseArgumentClose(openingBracePosition) {
|
|
3561
|
-
if (this.isEOF() || this.char() !== 125) {
|
|
3562
|
-
return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
|
|
3563
|
-
}
|
|
3564
|
-
this.bump();
|
|
3565
|
-
return {
|
|
3566
|
-
val: true,
|
|
3567
|
-
err: null
|
|
3568
|
-
};
|
|
3569
|
-
}
|
|
3570
|
-
/**
|
|
3571
|
-
* See: https://github.com/unicode-org/icu/blob/af7ed1f6d2298013dc303628438ec4abe1f16479/icu4c/source/common/messagepattern.cpp#L659
|
|
3572
|
-
*/
|
|
3573
|
-
parseSimpleArgStyleIfPossible() {
|
|
3574
|
-
let nestedBraces = 0;
|
|
3575
|
-
const startPosition = this.clonePosition();
|
|
3576
|
-
while (!this.isEOF()) {
|
|
3577
|
-
const ch = this.char();
|
|
3578
|
-
switch (ch) {
|
|
3579
|
-
case 39: {
|
|
3580
|
-
this.bump();
|
|
3581
|
-
let apostrophePosition = this.clonePosition();
|
|
3582
|
-
if (!this.bumpUntil("'")) {
|
|
3583
|
-
return this.error(ErrorKind.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE, createLocation(apostrophePosition, this.clonePosition()));
|
|
3584
|
-
}
|
|
3585
|
-
this.bump();
|
|
3586
|
-
break;
|
|
3587
|
-
}
|
|
3588
|
-
case 123: {
|
|
3589
|
-
nestedBraces += 1;
|
|
3590
|
-
this.bump();
|
|
3591
|
-
break;
|
|
3592
|
-
}
|
|
3593
|
-
case 125: {
|
|
3594
|
-
if (nestedBraces > 0) {
|
|
3595
|
-
nestedBraces -= 1;
|
|
3596
|
-
} else {
|
|
3597
|
-
return {
|
|
3598
|
-
val: this.message.slice(startPosition.offset, this.offset()),
|
|
3599
|
-
err: null
|
|
3600
|
-
};
|
|
3601
|
-
}
|
|
3602
|
-
break;
|
|
3603
|
-
}
|
|
3604
|
-
default:
|
|
3605
|
-
this.bump();
|
|
3606
|
-
break;
|
|
3607
|
-
}
|
|
3608
|
-
}
|
|
3609
|
-
return {
|
|
3610
|
-
val: this.message.slice(startPosition.offset, this.offset()),
|
|
3611
|
-
err: null
|
|
3612
|
-
};
|
|
3613
|
-
}
|
|
3614
|
-
parseNumberSkeletonFromString(skeleton, location) {
|
|
3615
|
-
let tokens = [];
|
|
3616
|
-
try {
|
|
3617
|
-
tokens = parseNumberSkeletonFromString(skeleton);
|
|
3618
|
-
} catch {
|
|
3619
|
-
return this.error(ErrorKind.INVALID_NUMBER_SKELETON, location);
|
|
3620
|
-
}
|
|
3621
|
-
return {
|
|
3622
|
-
val: {
|
|
3623
|
-
type: SKELETON_TYPE.number,
|
|
3624
|
-
tokens,
|
|
3625
|
-
location,
|
|
3626
|
-
parsedOptions: this.shouldParseSkeletons ? parseNumberSkeleton(tokens) : {}
|
|
3627
|
-
},
|
|
3628
|
-
err: null
|
|
3629
|
-
};
|
|
3630
|
-
}
|
|
3631
|
-
/**
|
|
3632
|
-
* @param nesting_level The current nesting level of messages.
|
|
3633
|
-
* This can be positive when parsing message fragment in select or plural argument options.
|
|
3634
|
-
* @param parent_arg_type The parent argument's type.
|
|
3635
|
-
* @param parsed_first_identifier If provided, this is the first identifier-like selector of
|
|
3636
|
-
* the argument. It is a by-product of a previous parsing attempt.
|
|
3637
|
-
* @param expecting_close_tag If true, this message is directly or indirectly nested inside
|
|
3638
|
-
* between a pair of opening and closing tags. The nested message will not parse beyond
|
|
3639
|
-
* the closing tag boundary.
|
|
3640
|
-
*/
|
|
3641
|
-
tryParsePluralOrSelectOptions(nestingLevel, parentArgType, expectCloseTag, parsedFirstIdentifier) {
|
|
3642
|
-
let hasOtherClause = false;
|
|
3643
|
-
const options = [];
|
|
3644
|
-
const parsedSelectors = /* @__PURE__ */ new Set();
|
|
3645
|
-
let { value: selector, location: selectorLocation } = parsedFirstIdentifier;
|
|
3646
|
-
while (true) {
|
|
3647
|
-
if (selector.length === 0) {
|
|
3648
|
-
const startPosition = this.clonePosition();
|
|
3649
|
-
if (parentArgType !== "select" && this.bumpIf("=")) {
|
|
3650
|
-
const result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, ErrorKind.INVALID_PLURAL_ARGUMENT_SELECTOR);
|
|
3651
|
-
if (result.err) {
|
|
3652
|
-
return result;
|
|
3653
|
-
}
|
|
3654
|
-
selectorLocation = createLocation(startPosition, this.clonePosition());
|
|
3655
|
-
selector = this.message.slice(startPosition.offset, this.offset());
|
|
3656
|
-
} else {
|
|
3657
|
-
break;
|
|
3658
|
-
}
|
|
3659
|
-
}
|
|
3660
|
-
if (parsedSelectors.has(selector)) {
|
|
3661
|
-
return this.error(parentArgType === "select" ? ErrorKind.DUPLICATE_SELECT_ARGUMENT_SELECTOR : ErrorKind.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, selectorLocation);
|
|
3662
|
-
}
|
|
3663
|
-
if (selector === "other") {
|
|
3664
|
-
hasOtherClause = true;
|
|
3665
|
-
}
|
|
3666
|
-
this.bumpSpace();
|
|
3667
|
-
const openingBracePosition = this.clonePosition();
|
|
3668
|
-
if (!this.bumpIf("{")) {
|
|
3669
|
-
return this.error(parentArgType === "select" ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT, createLocation(this.clonePosition(), this.clonePosition()));
|
|
3670
|
-
}
|
|
3671
|
-
const fragmentResult = this.parseMessage(nestingLevel + 1, parentArgType, expectCloseTag);
|
|
3672
|
-
if (fragmentResult.err) {
|
|
3673
|
-
return fragmentResult;
|
|
3674
|
-
}
|
|
3675
|
-
const argCloseResult = this.tryParseArgumentClose(openingBracePosition);
|
|
3676
|
-
if (argCloseResult.err) {
|
|
3677
|
-
return argCloseResult;
|
|
3678
|
-
}
|
|
3679
|
-
options.push([selector, {
|
|
3680
|
-
value: fragmentResult.val,
|
|
3681
|
-
location: createLocation(openingBracePosition, this.clonePosition())
|
|
3682
|
-
}]);
|
|
3683
|
-
parsedSelectors.add(selector);
|
|
3684
|
-
this.bumpSpace();
|
|
3685
|
-
({ value: selector, location: selectorLocation } = this.parseIdentifierIfPossible());
|
|
3686
|
-
}
|
|
3687
|
-
if (options.length === 0) {
|
|
3688
|
-
return this.error(parentArgType === "select" ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, createLocation(this.clonePosition(), this.clonePosition()));
|
|
3689
|
-
}
|
|
3690
|
-
if (this.requiresOtherClause && !hasOtherClause) {
|
|
3691
|
-
return this.error(ErrorKind.MISSING_OTHER_CLAUSE, createLocation(this.clonePosition(), this.clonePosition()));
|
|
3692
|
-
}
|
|
3693
|
-
return {
|
|
3694
|
-
val: options,
|
|
3695
|
-
err: null
|
|
3696
|
-
};
|
|
3697
|
-
}
|
|
3698
|
-
tryParseDecimalInteger(expectNumberError, invalidNumberError) {
|
|
3699
|
-
let sign = 1;
|
|
3700
|
-
const startingPosition = this.clonePosition();
|
|
3701
|
-
if (this.bumpIf("+")) ;
|
|
3702
|
-
else if (this.bumpIf("-")) {
|
|
3703
|
-
sign = -1;
|
|
3704
|
-
}
|
|
3705
|
-
let hasDigits = false;
|
|
3706
|
-
let decimal = 0;
|
|
3707
|
-
while (!this.isEOF()) {
|
|
3708
|
-
const ch = this.char();
|
|
3709
|
-
if (ch >= 48 && ch <= 57) {
|
|
3710
|
-
hasDigits = true;
|
|
3711
|
-
decimal = decimal * 10 + (ch - 48);
|
|
3712
|
-
this.bump();
|
|
3713
|
-
} else {
|
|
3714
|
-
break;
|
|
3715
|
-
}
|
|
3716
|
-
}
|
|
3717
|
-
const location = createLocation(startingPosition, this.clonePosition());
|
|
3718
|
-
if (!hasDigits) {
|
|
3719
|
-
return this.error(expectNumberError, location);
|
|
3720
|
-
}
|
|
3721
|
-
decimal *= sign;
|
|
3722
|
-
if (!Number.isSafeInteger(decimal)) {
|
|
3723
|
-
return this.error(invalidNumberError, location);
|
|
3724
|
-
}
|
|
3725
|
-
return {
|
|
3726
|
-
val: decimal,
|
|
3727
|
-
err: null
|
|
3728
|
-
};
|
|
3729
|
-
}
|
|
3730
|
-
offset() {
|
|
3731
|
-
return this.position.offset;
|
|
3732
|
-
}
|
|
3733
|
-
isEOF() {
|
|
3734
|
-
return this.offset() === this.message.length;
|
|
3735
|
-
}
|
|
3736
|
-
clonePosition() {
|
|
3737
|
-
return {
|
|
3738
|
-
offset: this.position.offset,
|
|
3739
|
-
line: this.position.line,
|
|
3740
|
-
column: this.position.column
|
|
3741
|
-
};
|
|
3742
|
-
}
|
|
3743
|
-
/**
|
|
3744
|
-
* Return the code point at the current position of the parser.
|
|
3745
|
-
* Throws if the index is out of bound.
|
|
3746
|
-
*/
|
|
3747
|
-
char() {
|
|
3748
|
-
const offset = this.position.offset;
|
|
3749
|
-
if (offset >= this.message.length) {
|
|
3750
|
-
throw Error("out of bound");
|
|
3751
|
-
}
|
|
3752
|
-
const code = this.message.codePointAt(offset);
|
|
3753
|
-
if (code === void 0) {
|
|
3754
|
-
throw Error(`Offset ${offset} is at invalid UTF-16 code unit boundary`);
|
|
3755
|
-
}
|
|
3756
|
-
return code;
|
|
3757
|
-
}
|
|
3758
|
-
error(kind, location) {
|
|
3759
|
-
return {
|
|
3760
|
-
val: null,
|
|
3761
|
-
err: {
|
|
3762
|
-
kind,
|
|
3763
|
-
message: this.message,
|
|
3764
|
-
location
|
|
3765
|
-
}
|
|
3766
|
-
};
|
|
3767
|
-
}
|
|
3768
|
-
/** Bump the parser to the next UTF-16 code unit. */
|
|
3769
|
-
bump() {
|
|
3770
|
-
if (this.isEOF()) {
|
|
3771
|
-
return;
|
|
3772
|
-
}
|
|
3773
|
-
const code = this.char();
|
|
3774
|
-
if (code === 10) {
|
|
3775
|
-
this.position.line += 1;
|
|
3776
|
-
this.position.column = 1;
|
|
3777
|
-
this.position.offset += 1;
|
|
3778
|
-
} else {
|
|
3779
|
-
this.position.column += 1;
|
|
3780
|
-
this.position.offset += code < 65536 ? 1 : 2;
|
|
3781
|
-
}
|
|
3782
|
-
}
|
|
3783
|
-
/**
|
|
3784
|
-
* If the substring starting at the current position of the parser has
|
|
3785
|
-
* the given prefix, then bump the parser to the character immediately
|
|
3786
|
-
* following the prefix and return true. Otherwise, don't bump the parser
|
|
3787
|
-
* and return false.
|
|
3788
|
-
*/
|
|
3789
|
-
bumpIf(prefix) {
|
|
3790
|
-
if (this.message.startsWith(prefix, this.offset())) {
|
|
3791
|
-
for (let i = 0; i < prefix.length; i++) {
|
|
3792
|
-
this.bump();
|
|
3793
|
-
}
|
|
3794
|
-
return true;
|
|
3795
|
-
}
|
|
3796
|
-
return false;
|
|
3797
|
-
}
|
|
3798
|
-
/**
|
|
3799
|
-
* Bump the parser until the pattern character is found and return `true`.
|
|
3800
|
-
* Otherwise bump to the end of the file and return `false`.
|
|
3801
|
-
*/
|
|
3802
|
-
bumpUntil(pattern) {
|
|
3803
|
-
const currentOffset = this.offset();
|
|
3804
|
-
const index = this.message.indexOf(pattern, currentOffset);
|
|
3805
|
-
if (index >= 0) {
|
|
3806
|
-
this.bumpTo(index);
|
|
3807
|
-
return true;
|
|
3808
|
-
} else {
|
|
3809
|
-
this.bumpTo(this.message.length);
|
|
3810
|
-
return false;
|
|
3811
|
-
}
|
|
3812
|
-
}
|
|
3813
|
-
/**
|
|
3814
|
-
* Bump the parser to the target offset.
|
|
3815
|
-
* If target offset is beyond the end of the input, bump the parser to the end of the input.
|
|
3816
|
-
*/
|
|
3817
|
-
bumpTo(targetOffset) {
|
|
3818
|
-
if (this.offset() > targetOffset) {
|
|
3819
|
-
throw Error(`targetOffset ${targetOffset} must be greater than or equal to the current offset ${this.offset()}`);
|
|
3820
|
-
}
|
|
3821
|
-
targetOffset = Math.min(targetOffset, this.message.length);
|
|
3822
|
-
while (true) {
|
|
3823
|
-
const offset = this.offset();
|
|
3824
|
-
if (offset === targetOffset) {
|
|
3825
|
-
break;
|
|
3826
|
-
}
|
|
3827
|
-
if (offset > targetOffset) {
|
|
3828
|
-
throw Error(`targetOffset ${targetOffset} is at invalid UTF-16 code unit boundary`);
|
|
3829
|
-
}
|
|
3830
|
-
this.bump();
|
|
3831
|
-
if (this.isEOF()) {
|
|
3832
|
-
break;
|
|
3833
|
-
}
|
|
3834
|
-
}
|
|
3835
|
-
}
|
|
3836
|
-
/** advance the parser through all whitespace to the next non-whitespace code unit. */
|
|
3837
|
-
bumpSpace() {
|
|
3838
|
-
while (!this.isEOF() && _isWhiteSpace(this.char())) {
|
|
3839
|
-
this.bump();
|
|
3840
|
-
}
|
|
3841
|
-
}
|
|
3842
|
-
/**
|
|
3843
|
-
* Peek at the *next* Unicode codepoint in the input without advancing the parser.
|
|
3844
|
-
* If the input has been exhausted, then this returns null.
|
|
3845
|
-
*/
|
|
3846
|
-
peek() {
|
|
3847
|
-
if (this.isEOF()) {
|
|
3848
|
-
return null;
|
|
3849
|
-
}
|
|
3850
|
-
const code = this.char();
|
|
3851
|
-
const offset = this.offset();
|
|
3852
|
-
const nextCode = this.message.charCodeAt(offset + (code >= 65536 ? 2 : 1));
|
|
3853
|
-
return nextCode ?? null;
|
|
3854
|
-
}
|
|
3855
|
-
}
|
|
3856
|
-
function _isAlpha(codepoint) {
|
|
3857
|
-
return codepoint >= 97 && codepoint <= 122 || codepoint >= 65 && codepoint <= 90;
|
|
3858
|
-
}
|
|
3859
|
-
function _isAlphaOrSlash(codepoint) {
|
|
3860
|
-
return _isAlpha(codepoint) || codepoint === 47;
|
|
3861
|
-
}
|
|
3862
|
-
function _isPotentialElementNameChar(c) {
|
|
3863
|
-
return c === 45 || c === 46 || c >= 48 && c <= 57 || c === 95 || c >= 97 && c <= 122 || c >= 65 && c <= 90 || c == 183 || c >= 192 && c <= 214 || c >= 216 && c <= 246 || c >= 248 && c <= 893 || c >= 895 && c <= 8191 || c >= 8204 && c <= 8205 || c >= 8255 && c <= 8256 || c >= 8304 && c <= 8591 || c >= 11264 && c <= 12271 || c >= 12289 && c <= 55295 || c >= 63744 && c <= 64975 || c >= 65008 && c <= 65533 || c >= 65536 && c <= 983039;
|
|
3864
|
-
}
|
|
3865
|
-
function _isWhiteSpace(c) {
|
|
3866
|
-
return c >= 9 && c <= 13 || c === 32 || c === 133 || c >= 8206 && c <= 8207 || c === 8232 || c === 8233;
|
|
3867
|
-
}
|
|
3868
|
-
function pruneLocation(els) {
|
|
3869
|
-
els.forEach((el) => {
|
|
3870
|
-
delete el.location;
|
|
3871
|
-
if (isSelectElement(el) || isPluralElement(el)) {
|
|
3872
|
-
for (const k in el.options) {
|
|
3873
|
-
delete el.options[k].location;
|
|
3874
|
-
pruneLocation(el.options[k].value);
|
|
3875
|
-
}
|
|
3876
|
-
} else if (isNumberElement(el) && isNumberSkeleton(el.style)) {
|
|
3877
|
-
delete el.style.location;
|
|
3878
|
-
} else if ((isDateElement(el) || isTimeElement(el)) && isDateTimeSkeleton(el.style)) {
|
|
3879
|
-
delete el.style.location;
|
|
3880
|
-
} else if (isTagElement(el)) {
|
|
3881
|
-
pruneLocation(el.children);
|
|
3882
|
-
}
|
|
3883
|
-
});
|
|
3884
|
-
}
|
|
3885
|
-
function parse(message, opts = {}) {
|
|
3886
|
-
opts = {
|
|
3887
|
-
shouldParseSkeletons: true,
|
|
3888
|
-
requiresOtherClause: true,
|
|
3889
|
-
...opts
|
|
3890
|
-
};
|
|
3891
|
-
const result = new Parser(message, opts).parse();
|
|
3892
|
-
if (result.err) {
|
|
3893
|
-
const error = SyntaxError(ErrorKind[result.err.kind]);
|
|
3894
|
-
error.location = result.err.location;
|
|
3895
|
-
error.originalMessage = result.err.message;
|
|
3896
|
-
throw error;
|
|
3897
|
-
}
|
|
3898
|
-
if (!opts?.captureLocation) {
|
|
3899
|
-
pruneLocation(result.val);
|
|
3900
|
-
}
|
|
3901
|
-
return result.val;
|
|
3902
|
-
}
|
|
3903
|
-
let ErrorCode = /* @__PURE__ */ (function(ErrorCode2) {
|
|
3904
|
-
ErrorCode2["MISSING_VALUE"] = "MISSING_VALUE";
|
|
3905
|
-
ErrorCode2["INVALID_VALUE"] = "INVALID_VALUE";
|
|
3906
|
-
ErrorCode2["MISSING_INTL_API"] = "MISSING_INTL_API";
|
|
3907
|
-
return ErrorCode2;
|
|
3908
|
-
})({});
|
|
3909
|
-
class FormatError extends Error {
|
|
3910
|
-
code;
|
|
3911
|
-
/**
|
|
3912
|
-
* Original message we're trying to format
|
|
3913
|
-
* `undefined` if we're only dealing w/ AST
|
|
3914
|
-
*
|
|
3915
|
-
* @type {(string | undefined)}
|
|
3916
|
-
* @memberof FormatError
|
|
3917
|
-
*/
|
|
3918
|
-
originalMessage;
|
|
3919
|
-
constructor(msg, code, originalMessage) {
|
|
3920
|
-
super(msg);
|
|
3921
|
-
this.code = code;
|
|
3922
|
-
this.originalMessage = originalMessage;
|
|
3923
|
-
}
|
|
3924
|
-
toString() {
|
|
3925
|
-
return `[formatjs Error: ${this.code}] ${this.message}`;
|
|
3926
|
-
}
|
|
3927
|
-
}
|
|
3928
|
-
class InvalidValueError extends FormatError {
|
|
3929
|
-
constructor(variableId, value, options, originalMessage) {
|
|
3930
|
-
super(`Invalid values for "${variableId}": "${value}". Options are "${Object.keys(options).join('", "')}"`, ErrorCode.INVALID_VALUE, originalMessage);
|
|
3931
|
-
}
|
|
3932
|
-
}
|
|
3933
|
-
class InvalidValueTypeError extends FormatError {
|
|
3934
|
-
constructor(value, type, originalMessage) {
|
|
3935
|
-
super(`Value for "${value}" must be of type ${type}`, ErrorCode.INVALID_VALUE, originalMessage);
|
|
3936
|
-
}
|
|
3937
|
-
}
|
|
3938
|
-
class MissingValueError extends FormatError {
|
|
3939
|
-
constructor(variableId, originalMessage) {
|
|
3940
|
-
super(`The intl string context variable "${variableId}" was not provided to the string "${originalMessage}"`, ErrorCode.MISSING_VALUE, originalMessage);
|
|
3941
|
-
}
|
|
3942
|
-
}
|
|
3943
|
-
let PART_TYPE = /* @__PURE__ */ (function(PART_TYPE2) {
|
|
3944
|
-
PART_TYPE2[PART_TYPE2["literal"] = 0] = "literal";
|
|
3945
|
-
PART_TYPE2[PART_TYPE2["object"] = 1] = "object";
|
|
3946
|
-
return PART_TYPE2;
|
|
3947
|
-
})({});
|
|
3948
|
-
function mergeLiteral(parts) {
|
|
3949
|
-
if (parts.length < 2) {
|
|
3950
|
-
return parts;
|
|
3951
|
-
}
|
|
3952
|
-
return parts.reduce((all, part) => {
|
|
3953
|
-
const lastPart = all[all.length - 1];
|
|
3954
|
-
if (!lastPart || lastPart.type !== PART_TYPE.literal || part.type !== PART_TYPE.literal) {
|
|
3955
|
-
all.push(part);
|
|
3956
|
-
} else {
|
|
3957
|
-
lastPart.value += part.value;
|
|
3958
|
-
}
|
|
3959
|
-
return all;
|
|
3960
|
-
}, []);
|
|
3961
|
-
}
|
|
3962
|
-
function isFormatXMLElementFn(el) {
|
|
3963
|
-
return typeof el === "function";
|
|
3964
|
-
}
|
|
3965
|
-
function formatToParts(els, locales, formatters, formats, values, currentPluralValue, originalMessage) {
|
|
3966
|
-
if (els.length === 1 && isLiteralElement(els[0])) {
|
|
3967
|
-
return [{
|
|
3968
|
-
type: PART_TYPE.literal,
|
|
3969
|
-
value: els[0].value
|
|
3970
|
-
}];
|
|
3971
|
-
}
|
|
3972
|
-
const result = [];
|
|
3973
|
-
for (const el of els) {
|
|
3974
|
-
if (isLiteralElement(el)) {
|
|
3975
|
-
result.push({
|
|
3976
|
-
type: PART_TYPE.literal,
|
|
3977
|
-
value: el.value
|
|
3978
|
-
});
|
|
3979
|
-
continue;
|
|
3980
|
-
}
|
|
3981
|
-
if (isPoundElement(el)) {
|
|
3982
|
-
if (typeof currentPluralValue === "number") {
|
|
3983
|
-
result.push({
|
|
3984
|
-
type: PART_TYPE.literal,
|
|
3985
|
-
value: formatters.getNumberFormat(locales).format(currentPluralValue)
|
|
3986
|
-
});
|
|
3987
|
-
}
|
|
3988
|
-
continue;
|
|
3989
|
-
}
|
|
3990
|
-
const { value: varName } = el;
|
|
3991
|
-
if (!(values && varName in values)) {
|
|
3992
|
-
throw new MissingValueError(varName, originalMessage);
|
|
3993
|
-
}
|
|
3994
|
-
let value = values[varName];
|
|
3995
|
-
if (isArgumentElement(el)) {
|
|
3996
|
-
if (!value || typeof value === "string" || typeof value === "number" || typeof value === "bigint") {
|
|
3997
|
-
value = typeof value === "string" || typeof value === "number" || typeof value === "bigint" ? String(value) : "";
|
|
3998
|
-
}
|
|
3999
|
-
result.push({
|
|
4000
|
-
type: typeof value === "string" ? PART_TYPE.literal : PART_TYPE.object,
|
|
4001
|
-
value
|
|
4002
|
-
});
|
|
4003
|
-
continue;
|
|
4004
|
-
}
|
|
4005
|
-
if (isDateElement(el)) {
|
|
4006
|
-
const style = typeof el.style === "string" ? formats.date[el.style] : isDateTimeSkeleton(el.style) ? el.style.parsedOptions : void 0;
|
|
4007
|
-
result.push({
|
|
4008
|
-
type: PART_TYPE.literal,
|
|
4009
|
-
value: formatters.getDateTimeFormat(locales, style).format(value)
|
|
4010
|
-
});
|
|
4011
|
-
continue;
|
|
4012
|
-
}
|
|
4013
|
-
if (isTimeElement(el)) {
|
|
4014
|
-
const style = typeof el.style === "string" ? formats.time[el.style] : isDateTimeSkeleton(el.style) ? el.style.parsedOptions : formats.time.medium;
|
|
4015
|
-
result.push({
|
|
4016
|
-
type: PART_TYPE.literal,
|
|
4017
|
-
value: formatters.getDateTimeFormat(locales, style).format(value)
|
|
4018
|
-
});
|
|
4019
|
-
continue;
|
|
4020
|
-
}
|
|
4021
|
-
if (isNumberElement(el)) {
|
|
4022
|
-
const style = typeof el.style === "string" ? formats.number[el.style] : isNumberSkeleton(el.style) ? el.style.parsedOptions : void 0;
|
|
4023
|
-
if (style && style.scale) {
|
|
4024
|
-
const scale = style.scale || 1;
|
|
4025
|
-
if (typeof value === "bigint") {
|
|
4026
|
-
if (!Number.isInteger(scale)) {
|
|
4027
|
-
throw new TypeError(`Cannot apply fractional scale ${scale} to bigint value. Scale must be an integer when formatting bigint.`);
|
|
4028
|
-
}
|
|
4029
|
-
value = value * BigInt(scale);
|
|
4030
|
-
} else {
|
|
4031
|
-
value = value * scale;
|
|
4032
|
-
}
|
|
4033
|
-
}
|
|
4034
|
-
result.push({
|
|
4035
|
-
type: PART_TYPE.literal,
|
|
4036
|
-
value: formatters.getNumberFormat(locales, style).format(value)
|
|
4037
|
-
});
|
|
4038
|
-
continue;
|
|
4039
|
-
}
|
|
4040
|
-
if (isTagElement(el)) {
|
|
4041
|
-
const { children, value: value2 } = el;
|
|
4042
|
-
const formatFn = values[value2];
|
|
4043
|
-
if (!isFormatXMLElementFn(formatFn)) {
|
|
4044
|
-
throw new InvalidValueTypeError(value2, "function", originalMessage);
|
|
4045
|
-
}
|
|
4046
|
-
const parts = formatToParts(children, locales, formatters, formats, values, currentPluralValue);
|
|
4047
|
-
let chunks = formatFn(parts.map((p) => p.value));
|
|
4048
|
-
if (!Array.isArray(chunks)) {
|
|
4049
|
-
chunks = [chunks];
|
|
4050
|
-
}
|
|
4051
|
-
result.push(...chunks.map((c) => {
|
|
4052
|
-
return {
|
|
4053
|
-
type: typeof c === "string" ? PART_TYPE.literal : PART_TYPE.object,
|
|
4054
|
-
value: c
|
|
4055
|
-
};
|
|
4056
|
-
}));
|
|
4057
|
-
}
|
|
4058
|
-
if (isSelectElement(el)) {
|
|
4059
|
-
const key = value;
|
|
4060
|
-
const opt = (Object.prototype.hasOwnProperty.call(el.options, key) ? el.options[key] : void 0) || el.options.other;
|
|
4061
|
-
if (!opt) {
|
|
4062
|
-
throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
|
|
4063
|
-
}
|
|
4064
|
-
result.push(...formatToParts(opt.value, locales, formatters, formats, values));
|
|
4065
|
-
continue;
|
|
4066
|
-
}
|
|
4067
|
-
if (isPluralElement(el)) {
|
|
4068
|
-
const exactKey = `=${value}`;
|
|
4069
|
-
let opt = Object.prototype.hasOwnProperty.call(el.options, exactKey) ? el.options[exactKey] : void 0;
|
|
4070
|
-
if (!opt) {
|
|
4071
|
-
if (!Intl.PluralRules) {
|
|
4072
|
-
throw new FormatError(`Intl.PluralRules is not available in this environment.
|
|
4073
|
-
Try polyfilling it using "@formatjs/intl-pluralrules"
|
|
4074
|
-
`, ErrorCode.MISSING_INTL_API, originalMessage);
|
|
4075
|
-
}
|
|
4076
|
-
const numericValue2 = typeof value === "bigint" ? Number(value) : value;
|
|
4077
|
-
const rule = formatters.getPluralRules(locales, { type: el.pluralType }).select(numericValue2 - (el.offset || 0));
|
|
4078
|
-
opt = (Object.prototype.hasOwnProperty.call(el.options, rule) ? el.options[rule] : void 0) || el.options.other;
|
|
4079
|
-
}
|
|
4080
|
-
if (!opt) {
|
|
4081
|
-
throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
|
|
4082
|
-
}
|
|
4083
|
-
const numericValue = typeof value === "bigint" ? Number(value) : value;
|
|
4084
|
-
result.push(...formatToParts(opt.value, locales, formatters, formats, values, numericValue - (el.offset || 0)));
|
|
4085
|
-
continue;
|
|
4086
|
-
}
|
|
4087
|
-
}
|
|
4088
|
-
return mergeLiteral(result);
|
|
4089
|
-
}
|
|
4090
|
-
function mergeConfig(c1, c2) {
|
|
4091
|
-
if (!c2) {
|
|
4092
|
-
return c1;
|
|
4093
|
-
}
|
|
4094
|
-
return {
|
|
4095
|
-
...c1,
|
|
4096
|
-
...c2,
|
|
4097
|
-
...Object.keys(c1).reduce((all, k) => {
|
|
4098
|
-
all[k] = {
|
|
4099
|
-
...c1[k],
|
|
4100
|
-
...c2[k]
|
|
4101
|
-
};
|
|
4102
|
-
return all;
|
|
4103
|
-
}, {})
|
|
4104
|
-
};
|
|
4105
|
-
}
|
|
4106
|
-
function mergeConfigs(defaultConfig, configs) {
|
|
4107
|
-
if (!configs) {
|
|
4108
|
-
return defaultConfig;
|
|
4109
|
-
}
|
|
4110
|
-
return Object.keys(defaultConfig).reduce((all, k) => {
|
|
4111
|
-
all[k] = mergeConfig(defaultConfig[k], configs[k]);
|
|
4112
|
-
return all;
|
|
4113
|
-
}, { ...defaultConfig });
|
|
4114
|
-
}
|
|
4115
|
-
function createFastMemoizeCache$1(store) {
|
|
4116
|
-
return { create() {
|
|
4117
|
-
return {
|
|
4118
|
-
get(key) {
|
|
4119
|
-
return store[key];
|
|
4120
|
-
},
|
|
4121
|
-
set(key, value) {
|
|
4122
|
-
store[key] = value;
|
|
4123
|
-
}
|
|
4124
|
-
};
|
|
4125
|
-
} };
|
|
4126
|
-
}
|
|
4127
|
-
function createDefaultFormatters(cache = {
|
|
4128
|
-
number: {},
|
|
4129
|
-
dateTime: {},
|
|
4130
|
-
pluralRules: {}
|
|
4131
|
-
}) {
|
|
4132
|
-
return {
|
|
4133
|
-
getNumberFormat: memoize((...args) => new Intl.NumberFormat(...args), {
|
|
4134
|
-
cache: createFastMemoizeCache$1(cache.number),
|
|
4135
|
-
strategy: strategies.variadic
|
|
4136
|
-
}),
|
|
4137
|
-
getDateTimeFormat: memoize((...args) => new Intl.DateTimeFormat(...args), {
|
|
4138
|
-
cache: createFastMemoizeCache$1(cache.dateTime),
|
|
4139
|
-
strategy: strategies.variadic
|
|
4140
|
-
}),
|
|
4141
|
-
getPluralRules: memoize((...args) => new Intl.PluralRules(...args), {
|
|
4142
|
-
cache: createFastMemoizeCache$1(cache.pluralRules),
|
|
4143
|
-
strategy: strategies.variadic
|
|
4144
|
-
})
|
|
4145
|
-
};
|
|
4146
|
-
}
|
|
4147
|
-
class IntlMessageFormat {
|
|
4148
|
-
ast;
|
|
4149
|
-
locales;
|
|
4150
|
-
resolvedLocale;
|
|
4151
|
-
formatters;
|
|
4152
|
-
formats;
|
|
4153
|
-
message;
|
|
4154
|
-
formatterCache = {
|
|
4155
|
-
number: {},
|
|
4156
|
-
dateTime: {},
|
|
4157
|
-
pluralRules: {}
|
|
4158
|
-
};
|
|
4159
|
-
constructor(message, locales = IntlMessageFormat.defaultLocale, overrideFormats, opts) {
|
|
4160
|
-
this.locales = locales;
|
|
4161
|
-
this.resolvedLocale = IntlMessageFormat.resolveLocale(locales);
|
|
4162
|
-
if (typeof message === "string") {
|
|
4163
|
-
this.message = message;
|
|
4164
|
-
if (!IntlMessageFormat.__parse) {
|
|
4165
|
-
throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");
|
|
4166
|
-
}
|
|
4167
|
-
const { ...parseOpts } = opts || {};
|
|
4168
|
-
this.ast = IntlMessageFormat.__parse(message, {
|
|
4169
|
-
...parseOpts,
|
|
4170
|
-
locale: this.resolvedLocale
|
|
4171
|
-
});
|
|
4172
|
-
} else {
|
|
4173
|
-
this.ast = message;
|
|
4174
|
-
}
|
|
4175
|
-
if (!Array.isArray(this.ast)) {
|
|
4176
|
-
throw new TypeError("A message must be provided as a String or AST.");
|
|
4177
|
-
}
|
|
4178
|
-
this.formats = mergeConfigs(IntlMessageFormat.formats, overrideFormats);
|
|
4179
|
-
this.formatters = opts && opts.formatters || createDefaultFormatters(this.formatterCache);
|
|
4180
|
-
}
|
|
4181
|
-
format = (values) => {
|
|
4182
|
-
const parts = this.formatToParts(values);
|
|
4183
|
-
if (parts.length === 1) {
|
|
4184
|
-
return parts[0].value;
|
|
4185
|
-
}
|
|
4186
|
-
const result = parts.reduce((all, part) => {
|
|
4187
|
-
if (!all.length || part.type !== PART_TYPE.literal || typeof all[all.length - 1] !== "string") {
|
|
4188
|
-
all.push(part.value);
|
|
4189
|
-
} else {
|
|
4190
|
-
all[all.length - 1] += part.value;
|
|
4191
|
-
}
|
|
4192
|
-
return all;
|
|
4193
|
-
}, []);
|
|
4194
|
-
if (result.length <= 1) {
|
|
4195
|
-
return result[0] || "";
|
|
4196
|
-
}
|
|
4197
|
-
return result;
|
|
4198
|
-
};
|
|
4199
|
-
formatToParts = (values) => formatToParts(this.ast, this.locales, this.formatters, this.formats, values, void 0, this.message);
|
|
4200
|
-
resolvedOptions = () => ({ locale: this.resolvedLocale?.toString() || Intl.NumberFormat.supportedLocalesOf(this.locales)[0] });
|
|
4201
|
-
getAst = () => this.ast;
|
|
4202
|
-
static memoizedDefaultLocale = null;
|
|
4203
|
-
static get defaultLocale() {
|
|
4204
|
-
if (!IntlMessageFormat.memoizedDefaultLocale) {
|
|
4205
|
-
IntlMessageFormat.memoizedDefaultLocale = new Intl.NumberFormat().resolvedOptions().locale;
|
|
4206
|
-
}
|
|
4207
|
-
return IntlMessageFormat.memoizedDefaultLocale;
|
|
4208
|
-
}
|
|
4209
|
-
static resolveLocale = (locales) => {
|
|
4210
|
-
if (typeof Intl.Locale === "undefined") {
|
|
4211
|
-
return;
|
|
4212
|
-
}
|
|
4213
|
-
const supportedLocales = Intl.NumberFormat.supportedLocalesOf(locales);
|
|
4214
|
-
if (supportedLocales.length > 0) {
|
|
4215
|
-
return new Intl.Locale(supportedLocales[0]);
|
|
4216
|
-
}
|
|
4217
|
-
return new Intl.Locale(typeof locales === "string" ? locales : locales[0]);
|
|
4218
|
-
};
|
|
4219
|
-
static __parse = parse;
|
|
4220
|
-
// Default format options used as the prototype of the `formats` provided to the
|
|
4221
|
-
// constructor. These are used when constructing the internal Intl.NumberFormat
|
|
4222
|
-
// and Intl.DateTimeFormat instances.
|
|
4223
|
-
static formats = {
|
|
4224
|
-
number: {
|
|
4225
|
-
integer: { maximumFractionDigits: 0 },
|
|
4226
|
-
currency: { style: "currency" },
|
|
4227
|
-
percent: { style: "percent" }
|
|
4228
|
-
},
|
|
4229
|
-
date: {
|
|
4230
|
-
short: {
|
|
4231
|
-
month: "numeric",
|
|
4232
|
-
day: "numeric",
|
|
4233
|
-
year: "2-digit"
|
|
4234
|
-
},
|
|
4235
|
-
medium: {
|
|
4236
|
-
month: "short",
|
|
4237
|
-
day: "numeric",
|
|
4238
|
-
year: "numeric"
|
|
4239
|
-
},
|
|
4240
|
-
long: {
|
|
4241
|
-
month: "long",
|
|
4242
|
-
day: "numeric",
|
|
4243
|
-
year: "numeric"
|
|
4244
|
-
},
|
|
4245
|
-
full: {
|
|
4246
|
-
weekday: "long",
|
|
4247
|
-
month: "long",
|
|
4248
|
-
day: "numeric",
|
|
4249
|
-
year: "numeric"
|
|
4250
|
-
}
|
|
4251
|
-
},
|
|
4252
|
-
time: {
|
|
4253
|
-
short: {
|
|
4254
|
-
hour: "numeric",
|
|
4255
|
-
minute: "numeric"
|
|
4256
|
-
},
|
|
4257
|
-
medium: {
|
|
4258
|
-
hour: "numeric",
|
|
4259
|
-
minute: "numeric",
|
|
4260
|
-
second: "numeric"
|
|
4261
|
-
},
|
|
4262
|
-
long: {
|
|
4263
|
-
hour: "numeric",
|
|
4264
|
-
minute: "numeric",
|
|
4265
|
-
second: "numeric",
|
|
4266
|
-
timeZoneName: "short"
|
|
4267
|
-
},
|
|
4268
|
-
full: {
|
|
4269
|
-
hour: "numeric",
|
|
4270
|
-
minute: "numeric",
|
|
4271
|
-
second: "numeric",
|
|
4272
|
-
timeZoneName: "short"
|
|
4273
|
-
}
|
|
4274
|
-
}
|
|
4275
|
-
};
|
|
4276
|
-
}
|
|
4277
|
-
let IntlErrorCode = /* @__PURE__ */ (function(IntlErrorCode2) {
|
|
4278
|
-
IntlErrorCode2["FORMAT_ERROR"] = "FORMAT_ERROR";
|
|
4279
|
-
IntlErrorCode2["UNSUPPORTED_FORMATTER"] = "UNSUPPORTED_FORMATTER";
|
|
4280
|
-
IntlErrorCode2["INVALID_CONFIG"] = "INVALID_CONFIG";
|
|
4281
|
-
IntlErrorCode2["MISSING_DATA"] = "MISSING_DATA";
|
|
4282
|
-
IntlErrorCode2["MISSING_TRANSLATION"] = "MISSING_TRANSLATION";
|
|
4283
|
-
return IntlErrorCode2;
|
|
4284
|
-
})({});
|
|
4285
|
-
class IntlError extends Error {
|
|
4286
|
-
code;
|
|
4287
|
-
constructor(code, message, exception) {
|
|
4288
|
-
const err = exception ? exception instanceof Error ? exception : new Error(String(exception)) : void 0;
|
|
4289
|
-
super(`[@formatjs/intl Error ${code}] ${message}
|
|
4290
|
-
${err ? `
|
|
4291
|
-
${err.message}
|
|
4292
|
-
${err.stack}` : ""}`);
|
|
4293
|
-
this.code = code;
|
|
4294
|
-
if (typeof Error.captureStackTrace === "function") {
|
|
4295
|
-
Error.captureStackTrace(this, IntlError);
|
|
4296
|
-
}
|
|
4297
|
-
}
|
|
4298
|
-
}
|
|
4299
|
-
class UnsupportedFormatterError extends IntlError {
|
|
4300
|
-
constructor(message, exception) {
|
|
4301
|
-
super(IntlErrorCode.UNSUPPORTED_FORMATTER, message, exception);
|
|
4302
|
-
}
|
|
4303
|
-
}
|
|
4304
|
-
class InvalidConfigError extends IntlError {
|
|
4305
|
-
constructor(message, exception) {
|
|
4306
|
-
super(IntlErrorCode.INVALID_CONFIG, message, exception);
|
|
4307
|
-
}
|
|
4308
|
-
}
|
|
4309
|
-
class MissingDataError extends IntlError {
|
|
4310
|
-
constructor(message, exception) {
|
|
4311
|
-
super(IntlErrorCode.MISSING_DATA, message, exception);
|
|
4312
|
-
}
|
|
4313
|
-
}
|
|
4314
|
-
class IntlFormatError extends IntlError {
|
|
4315
|
-
descriptor;
|
|
4316
|
-
locale;
|
|
4317
|
-
constructor(message, locale, exception) {
|
|
4318
|
-
super(IntlErrorCode.FORMAT_ERROR, `${message}
|
|
4319
|
-
Locale: ${locale}
|
|
4320
|
-
`, exception);
|
|
4321
|
-
this.locale = locale;
|
|
4322
|
-
}
|
|
4323
|
-
}
|
|
4324
|
-
class MessageFormatError extends IntlFormatError {
|
|
4325
|
-
descriptor;
|
|
4326
|
-
locale;
|
|
4327
|
-
constructor(message, locale, descriptor, exception) {
|
|
4328
|
-
super(`${message}
|
|
4329
|
-
MessageID: ${descriptor?.id}
|
|
4330
|
-
Default Message: ${descriptor?.defaultMessage}
|
|
4331
|
-
Description: ${descriptor?.description}
|
|
4332
|
-
`, locale, exception);
|
|
4333
|
-
this.descriptor = descriptor;
|
|
4334
|
-
this.locale = locale;
|
|
4335
|
-
}
|
|
4336
|
-
}
|
|
4337
|
-
class MissingTranslationError extends IntlError {
|
|
4338
|
-
descriptor;
|
|
4339
|
-
constructor(descriptor, locale) {
|
|
4340
|
-
super(IntlErrorCode.MISSING_TRANSLATION, `Missing message: "${descriptor.id}" for locale "${locale}", using ${descriptor.defaultMessage ? `default message (${typeof descriptor.defaultMessage === "string" ? descriptor.defaultMessage : descriptor.defaultMessage.map((e) => e.value ?? JSON.stringify(e)).join()})` : "id"} as fallback.`);
|
|
4341
|
-
this.descriptor = descriptor;
|
|
4342
|
-
}
|
|
4343
|
-
}
|
|
4344
|
-
function invariant$2(condition, message, Err = Error) {
|
|
4345
|
-
if (!condition) {
|
|
4346
|
-
throw new Err(message);
|
|
4347
|
-
}
|
|
4348
|
-
}
|
|
4349
|
-
function filterProps(props, allowlist, defaults = {}) {
|
|
4350
|
-
return allowlist.reduce((filtered, name) => {
|
|
4351
|
-
if (name in props) {
|
|
4352
|
-
filtered[name] = props[name];
|
|
4353
|
-
} else if (name in defaults) {
|
|
4354
|
-
filtered[name] = defaults[name];
|
|
4355
|
-
}
|
|
4356
|
-
return filtered;
|
|
4357
|
-
}, {});
|
|
4358
|
-
}
|
|
4359
|
-
const defaultErrorHandler = (error) => {
|
|
4360
|
-
if (process.env.NODE_ENV !== "production") {
|
|
4361
|
-
console.error(error);
|
|
4362
|
-
}
|
|
4363
|
-
};
|
|
4364
|
-
const defaultWarnHandler = (warning2) => {
|
|
4365
|
-
if (process.env.NODE_ENV !== "production") {
|
|
4366
|
-
console.warn(warning2);
|
|
4367
|
-
}
|
|
4368
|
-
};
|
|
4369
|
-
const DEFAULT_INTL_CONFIG$1 = {
|
|
4370
|
-
formats: {},
|
|
4371
|
-
messages: {},
|
|
4372
|
-
timeZone: void 0,
|
|
4373
|
-
defaultLocale: "en",
|
|
4374
|
-
defaultFormats: {},
|
|
4375
|
-
fallbackOnEmptyString: true,
|
|
4376
|
-
onError: defaultErrorHandler,
|
|
4377
|
-
onWarn: defaultWarnHandler
|
|
4378
|
-
};
|
|
4379
|
-
function createIntlCache() {
|
|
4380
|
-
return {
|
|
4381
|
-
dateTime: {},
|
|
4382
|
-
number: {},
|
|
4383
|
-
message: {},
|
|
4384
|
-
relativeTime: {},
|
|
4385
|
-
pluralRules: {},
|
|
4386
|
-
list: {},
|
|
4387
|
-
displayNames: {}
|
|
4388
|
-
};
|
|
4389
|
-
}
|
|
4390
|
-
function createFastMemoizeCache(store) {
|
|
4391
|
-
return { create() {
|
|
4392
|
-
return {
|
|
4393
|
-
get(key) {
|
|
4394
|
-
return store[key];
|
|
4395
|
-
},
|
|
4396
|
-
set(key, value) {
|
|
4397
|
-
store[key] = value;
|
|
4398
|
-
}
|
|
4399
|
-
};
|
|
4400
|
-
} };
|
|
4401
|
-
}
|
|
4402
|
-
function createFormatters(cache = createIntlCache()) {
|
|
4403
|
-
const RelativeTimeFormat = Intl.RelativeTimeFormat;
|
|
4404
|
-
const ListFormat = Intl.ListFormat;
|
|
4405
|
-
const DisplayNames = Intl.DisplayNames;
|
|
4406
|
-
const getDateTimeFormat = memoize((...args) => new Intl.DateTimeFormat(...args), {
|
|
4407
|
-
cache: createFastMemoizeCache(cache.dateTime),
|
|
4408
|
-
strategy: strategies.variadic
|
|
4409
|
-
});
|
|
4410
|
-
const getNumberFormat = memoize((...args) => new Intl.NumberFormat(...args), {
|
|
4411
|
-
cache: createFastMemoizeCache(cache.number),
|
|
4412
|
-
strategy: strategies.variadic
|
|
4413
|
-
});
|
|
4414
|
-
const getPluralRules = memoize((...args) => new Intl.PluralRules(...args), {
|
|
4415
|
-
cache: createFastMemoizeCache(cache.pluralRules),
|
|
4416
|
-
strategy: strategies.variadic
|
|
4417
|
-
});
|
|
4418
|
-
return {
|
|
4419
|
-
getDateTimeFormat,
|
|
4420
|
-
getNumberFormat,
|
|
4421
|
-
getMessageFormat: memoize((message, locales, overrideFormats, opts) => new IntlMessageFormat(message, locales, overrideFormats, {
|
|
4422
|
-
formatters: {
|
|
4423
|
-
getNumberFormat,
|
|
4424
|
-
getDateTimeFormat,
|
|
4425
|
-
getPluralRules
|
|
4426
|
-
},
|
|
4427
|
-
...opts
|
|
4428
|
-
}), {
|
|
4429
|
-
cache: createFastMemoizeCache(cache.message),
|
|
4430
|
-
strategy: strategies.variadic
|
|
4431
|
-
}),
|
|
4432
|
-
getRelativeTimeFormat: memoize((...args) => new RelativeTimeFormat(...args), {
|
|
4433
|
-
cache: createFastMemoizeCache(cache.relativeTime),
|
|
4434
|
-
strategy: strategies.variadic
|
|
4435
|
-
}),
|
|
4436
|
-
getPluralRules,
|
|
4437
|
-
getListFormat: memoize((...args) => new ListFormat(...args), {
|
|
4438
|
-
cache: createFastMemoizeCache(cache.list),
|
|
4439
|
-
strategy: strategies.variadic
|
|
4440
|
-
}),
|
|
4441
|
-
getDisplayNames: memoize((...args) => new DisplayNames(...args), {
|
|
4442
|
-
cache: createFastMemoizeCache(cache.displayNames),
|
|
4443
|
-
strategy: strategies.variadic
|
|
4444
|
-
})
|
|
4445
|
-
};
|
|
4446
|
-
}
|
|
4447
|
-
function getNamedFormat(formats, type, name, onError) {
|
|
4448
|
-
const formatType = formats && formats[type];
|
|
4449
|
-
let format;
|
|
4450
|
-
if (formatType) {
|
|
4451
|
-
format = formatType[name];
|
|
4452
|
-
}
|
|
4453
|
-
if (format) {
|
|
4454
|
-
return format;
|
|
4455
|
-
}
|
|
4456
|
-
onError(new UnsupportedFormatterError(`No ${type} format named: ${name}`));
|
|
4457
|
-
}
|
|
4458
|
-
function setTimeZoneInOptions(opts, timeZone) {
|
|
4459
|
-
return Object.keys(opts).reduce((all, k) => {
|
|
4460
|
-
all[k] = {
|
|
4461
|
-
timeZone,
|
|
4462
|
-
...opts[k]
|
|
4463
|
-
};
|
|
4464
|
-
return all;
|
|
4465
|
-
}, {});
|
|
4466
|
-
}
|
|
4467
|
-
function deepMergeOptions(opts1, opts2) {
|
|
4468
|
-
const keys = Object.keys({
|
|
4469
|
-
...opts1,
|
|
4470
|
-
...opts2
|
|
4471
|
-
});
|
|
4472
|
-
return keys.reduce((all, k) => {
|
|
4473
|
-
all[k] = {
|
|
4474
|
-
...opts1[k],
|
|
4475
|
-
...opts2[k]
|
|
4476
|
-
};
|
|
4477
|
-
return all;
|
|
4478
|
-
}, {});
|
|
4479
|
-
}
|
|
4480
|
-
function deepMergeFormatsAndSetTimeZone(f1, timeZone) {
|
|
4481
|
-
if (!timeZone) {
|
|
4482
|
-
return f1;
|
|
4483
|
-
}
|
|
4484
|
-
const mfFormats = IntlMessageFormat.formats;
|
|
4485
|
-
return {
|
|
4486
|
-
...mfFormats,
|
|
4487
|
-
...f1,
|
|
4488
|
-
date: deepMergeOptions(setTimeZoneInOptions(mfFormats.date, timeZone), setTimeZoneInOptions(f1.date || {}, timeZone)),
|
|
4489
|
-
time: deepMergeOptions(setTimeZoneInOptions(mfFormats.time, timeZone), setTimeZoneInOptions(f1.time || {}, timeZone))
|
|
4490
|
-
};
|
|
4491
|
-
}
|
|
4492
|
-
const formatMessage$1 = ({ locale, formats, messages, defaultLocale, defaultFormats, fallbackOnEmptyString, onError, timeZone, defaultRichTextElements }, state, messageDescriptor = { id: "" }, values, opts) => {
|
|
4493
|
-
const { id: msgId, defaultMessage } = messageDescriptor;
|
|
4494
|
-
invariant$2(!!msgId, `[@formatjs/intl] An \`id\` must be provided to format a message. You can either:
|
|
4495
|
-
1. Configure your build toolchain with [babel-plugin-formatjs](https://formatjs.github.io/docs/tooling/babel-plugin)
|
|
4496
|
-
or [@formatjs/ts-transformer](https://formatjs.github.io/docs/tooling/ts-transformer) OR
|
|
4497
|
-
2. Configure your \`eslint\` config to include [eslint-plugin-formatjs](https://formatjs.github.io/docs/tooling/linter#enforce-id)
|
|
4498
|
-
to autofix this issue`);
|
|
4499
|
-
const id = String(msgId);
|
|
4500
|
-
const message = messages && Object.prototype.hasOwnProperty.call(messages, id) && messages[id];
|
|
4501
|
-
if (Array.isArray(message) && message.length === 1 && message[0].type === TYPE.literal) {
|
|
4502
|
-
return message[0].value;
|
|
4503
|
-
}
|
|
4504
|
-
values = {
|
|
4505
|
-
...defaultRichTextElements,
|
|
4506
|
-
...values
|
|
4507
|
-
};
|
|
4508
|
-
formats = deepMergeFormatsAndSetTimeZone(formats, timeZone);
|
|
4509
|
-
defaultFormats = deepMergeFormatsAndSetTimeZone(defaultFormats, timeZone);
|
|
4510
|
-
if (!message) {
|
|
4511
|
-
if (fallbackOnEmptyString === false && message === "") {
|
|
4512
|
-
return message;
|
|
4513
|
-
}
|
|
4514
|
-
if (!defaultMessage || locale && locale.toLowerCase() !== defaultLocale.toLowerCase()) {
|
|
4515
|
-
onError(new MissingTranslationError(messageDescriptor, locale));
|
|
4516
|
-
}
|
|
4517
|
-
if (defaultMessage) {
|
|
4518
|
-
try {
|
|
4519
|
-
const formatter = state.getMessageFormat(defaultMessage, defaultLocale, defaultFormats, opts);
|
|
4520
|
-
return formatter.format(values);
|
|
4521
|
-
} catch (e) {
|
|
4522
|
-
onError(new MessageFormatError(`Error formatting default message for: "${id}", rendering default message verbatim`, locale, messageDescriptor, e));
|
|
4523
|
-
return typeof defaultMessage === "string" ? defaultMessage : id;
|
|
4524
|
-
}
|
|
4525
|
-
}
|
|
4526
|
-
return id;
|
|
4527
|
-
}
|
|
4528
|
-
try {
|
|
4529
|
-
const formatter = state.getMessageFormat(message, locale, formats, {
|
|
4530
|
-
formatters: state,
|
|
4531
|
-
...opts
|
|
4532
|
-
});
|
|
4533
|
-
return formatter.format(values);
|
|
4534
|
-
} catch (e) {
|
|
4535
|
-
onError(new MessageFormatError(`Error formatting message: "${id}", using ${defaultMessage ? "default message" : "id"} as fallback.`, locale, messageDescriptor, e));
|
|
4536
|
-
}
|
|
4537
|
-
if (defaultMessage) {
|
|
4538
|
-
try {
|
|
4539
|
-
const formatter = state.getMessageFormat(defaultMessage, defaultLocale, defaultFormats, opts);
|
|
4540
|
-
return formatter.format(values);
|
|
4541
|
-
} catch (e) {
|
|
4542
|
-
onError(new MessageFormatError(`Error formatting the default message for: "${id}", rendering message verbatim`, locale, messageDescriptor, e));
|
|
4543
|
-
}
|
|
4544
|
-
}
|
|
4545
|
-
if (typeof message === "string") {
|
|
4546
|
-
return message;
|
|
4547
|
-
}
|
|
4548
|
-
if (typeof defaultMessage === "string") {
|
|
4549
|
-
return defaultMessage;
|
|
4550
|
-
}
|
|
4551
|
-
return id;
|
|
4552
|
-
};
|
|
4553
|
-
const DATE_TIME_FORMAT_OPTIONS = [
|
|
4554
|
-
"formatMatcher",
|
|
4555
|
-
"timeZone",
|
|
4556
|
-
"hour12",
|
|
4557
|
-
"weekday",
|
|
4558
|
-
"era",
|
|
4559
|
-
"year",
|
|
4560
|
-
"month",
|
|
4561
|
-
"day",
|
|
4562
|
-
"hour",
|
|
4563
|
-
"minute",
|
|
4564
|
-
"second",
|
|
4565
|
-
"timeZoneName",
|
|
4566
|
-
"hourCycle",
|
|
4567
|
-
"dateStyle",
|
|
4568
|
-
"timeStyle",
|
|
4569
|
-
"calendar",
|
|
4570
|
-
"numberingSystem",
|
|
4571
|
-
"fractionalSecondDigits"
|
|
4572
|
-
];
|
|
4573
|
-
function getFormatter$2({ locale, formats, onError, timeZone }, type, getDateTimeFormat, options = {}) {
|
|
4574
|
-
const { format } = options;
|
|
4575
|
-
const defaults = {
|
|
4576
|
-
...timeZone && { timeZone },
|
|
4577
|
-
...format && getNamedFormat(formats, type, format, onError)
|
|
4578
|
-
};
|
|
4579
|
-
let filteredOptions = filterProps(options, DATE_TIME_FORMAT_OPTIONS, defaults);
|
|
4580
|
-
if (type === "time" && !filteredOptions.hour && !filteredOptions.minute && !filteredOptions.second && !filteredOptions.timeStyle && !filteredOptions.dateStyle) {
|
|
4581
|
-
filteredOptions = {
|
|
4582
|
-
...filteredOptions,
|
|
4583
|
-
hour: "numeric",
|
|
4584
|
-
minute: "numeric"
|
|
4585
|
-
};
|
|
4586
|
-
}
|
|
4587
|
-
return getDateTimeFormat(locale, filteredOptions);
|
|
4588
|
-
}
|
|
4589
|
-
function formatDate(config2, getDateTimeFormat, value, options = {}) {
|
|
4590
|
-
const date = typeof value === "string" ? new Date(value || 0) : value;
|
|
4591
|
-
try {
|
|
4592
|
-
return getFormatter$2(config2, "date", getDateTimeFormat, options).format(date);
|
|
4593
|
-
} catch (e) {
|
|
4594
|
-
config2.onError(new IntlFormatError("Error formatting date.", config2.locale, e));
|
|
4595
|
-
}
|
|
4596
|
-
return String(date);
|
|
4597
|
-
}
|
|
4598
|
-
function formatTime(config2, getDateTimeFormat, value, options = {}) {
|
|
4599
|
-
const date = typeof value === "string" ? new Date(value || 0) : value;
|
|
4600
|
-
try {
|
|
4601
|
-
return getFormatter$2(config2, "time", getDateTimeFormat, options).format(date);
|
|
4602
|
-
} catch (e) {
|
|
4603
|
-
config2.onError(new IntlFormatError("Error formatting time.", config2.locale, e));
|
|
4604
|
-
}
|
|
4605
|
-
return String(date);
|
|
4606
|
-
}
|
|
4607
|
-
function formatDateTimeRange(config2, getDateTimeFormat, from2, to, options = {}) {
|
|
4608
|
-
const fromDate = typeof from2 === "string" ? new Date(from2 || 0) : from2;
|
|
4609
|
-
const toDate = typeof to === "string" ? new Date(to || 0) : to;
|
|
4610
|
-
try {
|
|
4611
|
-
return getFormatter$2(config2, "dateTimeRange", getDateTimeFormat, options).formatRange(fromDate, toDate);
|
|
4612
|
-
} catch (e) {
|
|
4613
|
-
config2.onError(new IntlFormatError("Error formatting date time range.", config2.locale, e));
|
|
4614
|
-
}
|
|
4615
|
-
return String(fromDate);
|
|
4616
|
-
}
|
|
4617
|
-
function formatDateToParts(config2, getDateTimeFormat, value, options = {}) {
|
|
4618
|
-
const date = typeof value === "string" ? new Date(value || 0) : value;
|
|
4619
|
-
try {
|
|
4620
|
-
return getFormatter$2(config2, "date", getDateTimeFormat, options).formatToParts(date);
|
|
4621
|
-
} catch (e) {
|
|
4622
|
-
config2.onError(new IntlFormatError("Error formatting date.", config2.locale, e));
|
|
4623
|
-
}
|
|
4624
|
-
return [];
|
|
4625
|
-
}
|
|
4626
|
-
function formatTimeToParts(config2, getDateTimeFormat, value, options = {}) {
|
|
4627
|
-
const date = typeof value === "string" ? new Date(value || 0) : value;
|
|
4628
|
-
try {
|
|
4629
|
-
return getFormatter$2(config2, "time", getDateTimeFormat, options).formatToParts(date);
|
|
4630
|
-
} catch (e) {
|
|
4631
|
-
config2.onError(new IntlFormatError("Error formatting time.", config2.locale, e));
|
|
4632
|
-
}
|
|
4633
|
-
return [];
|
|
4634
|
-
}
|
|
4635
|
-
const DISPLAY_NAMES_OPTONS = [
|
|
4636
|
-
"style",
|
|
4637
|
-
"type",
|
|
4638
|
-
"fallback",
|
|
4639
|
-
"languageDisplay"
|
|
4640
|
-
];
|
|
4641
|
-
function formatDisplayName({ locale, onError }, getDisplayNames, value, options) {
|
|
4642
|
-
const DisplayNames = Intl.DisplayNames;
|
|
4643
|
-
if (!DisplayNames) {
|
|
4644
|
-
onError(new FormatError(`Intl.DisplayNames is not available in this environment.
|
|
4645
|
-
Try polyfilling it using "@formatjs/intl-displaynames"
|
|
4646
|
-
`, ErrorCode.MISSING_INTL_API));
|
|
4647
|
-
}
|
|
4648
|
-
const filteredOptions = filterProps(options, DISPLAY_NAMES_OPTONS);
|
|
4649
|
-
try {
|
|
4650
|
-
return getDisplayNames(locale, filteredOptions).of(value);
|
|
4651
|
-
} catch (e) {
|
|
4652
|
-
onError(new IntlFormatError("Error formatting display name.", locale, e));
|
|
4653
|
-
}
|
|
4654
|
-
}
|
|
4655
|
-
const LIST_FORMAT_OPTIONS = ["type", "style"];
|
|
4656
|
-
const now = Date.now();
|
|
4657
|
-
function generateToken(i) {
|
|
4658
|
-
return `${now}_${i}_${now}`;
|
|
4659
|
-
}
|
|
4660
|
-
function formatList(opts, getListFormat, values, options = {}) {
|
|
4661
|
-
const results = formatListToParts(opts, getListFormat, values, options).reduce((all, el) => {
|
|
4662
|
-
const val = el.value;
|
|
4663
|
-
if (typeof val !== "string") {
|
|
4664
|
-
all.push(val);
|
|
4665
|
-
} else if (typeof all[all.length - 1] === "string") {
|
|
4666
|
-
all[all.length - 1] += val;
|
|
4667
|
-
} else {
|
|
4668
|
-
all.push(val);
|
|
4669
|
-
}
|
|
4670
|
-
return all;
|
|
4671
|
-
}, []);
|
|
4672
|
-
return results.length === 1 ? results[0] : results.length === 0 ? "" : results;
|
|
4673
|
-
}
|
|
4674
|
-
function formatListToParts({ locale, onError }, getListFormat, values, options = {}) {
|
|
4675
|
-
const ListFormat = Intl.ListFormat;
|
|
4676
|
-
if (!ListFormat) {
|
|
4677
|
-
onError(new FormatError(`Intl.ListFormat is not available in this environment.
|
|
4678
|
-
Try polyfilling it using "@formatjs/intl-listformat"
|
|
4679
|
-
`, ErrorCode.MISSING_INTL_API));
|
|
4680
|
-
}
|
|
4681
|
-
const filteredOptions = filterProps(options, LIST_FORMAT_OPTIONS);
|
|
4682
|
-
try {
|
|
4683
|
-
const richValues = {};
|
|
4684
|
-
const serializedValues = Array.from(values).map((v, i) => {
|
|
4685
|
-
if (typeof v === "object" && v !== null) {
|
|
4686
|
-
const id = generateToken(i);
|
|
4687
|
-
richValues[id] = v;
|
|
4688
|
-
return id;
|
|
4689
|
-
}
|
|
4690
|
-
return String(v);
|
|
4691
|
-
});
|
|
4692
|
-
return getListFormat(locale, filteredOptions).formatToParts(serializedValues).map((part) => part.type === "literal" ? part : {
|
|
4693
|
-
...part,
|
|
4694
|
-
value: richValues[part.value] || part.value
|
|
4695
|
-
});
|
|
4696
|
-
} catch (e) {
|
|
4697
|
-
onError(new IntlFormatError("Error formatting list.", locale, e));
|
|
4698
|
-
}
|
|
4699
|
-
return values;
|
|
4700
|
-
}
|
|
4701
|
-
const PLURAL_FORMAT_OPTIONS = ["type"];
|
|
4702
|
-
function formatPlural({ locale, onError }, getPluralRules, value, options = {}) {
|
|
4703
|
-
if (!Intl.PluralRules) {
|
|
4704
|
-
onError(new FormatError(`Intl.PluralRules is not available in this environment.
|
|
4705
|
-
Try polyfilling it using "@formatjs/intl-pluralrules"
|
|
4706
|
-
`, ErrorCode.MISSING_INTL_API));
|
|
4707
|
-
}
|
|
4708
|
-
const filteredOptions = filterProps(options, PLURAL_FORMAT_OPTIONS);
|
|
4709
|
-
try {
|
|
4710
|
-
return getPluralRules(locale, filteredOptions).select(value);
|
|
4711
|
-
} catch (e) {
|
|
4712
|
-
onError(new IntlFormatError("Error formatting plural.", locale, e));
|
|
4713
|
-
}
|
|
4714
|
-
return "other";
|
|
4715
|
-
}
|
|
4716
|
-
const RELATIVE_TIME_FORMAT_OPTIONS = ["numeric", "style"];
|
|
4717
|
-
function getFormatter$1({ locale, formats, onError }, getRelativeTimeFormat, options = {}) {
|
|
4718
|
-
const { format } = options;
|
|
4719
|
-
const defaults = !!format && getNamedFormat(formats, "relative", format, onError) || {};
|
|
4720
|
-
const filteredOptions = filterProps(options, RELATIVE_TIME_FORMAT_OPTIONS, defaults);
|
|
4721
|
-
return getRelativeTimeFormat(locale, filteredOptions);
|
|
4722
|
-
}
|
|
4723
|
-
function formatRelativeTime(config2, getRelativeTimeFormat, value, unit, options = {}) {
|
|
4724
|
-
if (!unit) {
|
|
4725
|
-
unit = "second";
|
|
4726
|
-
}
|
|
4727
|
-
const RelativeTimeFormat = Intl.RelativeTimeFormat;
|
|
4728
|
-
if (!RelativeTimeFormat) {
|
|
4729
|
-
config2.onError(new FormatError(`Intl.RelativeTimeFormat is not available in this environment.
|
|
4730
|
-
Try polyfilling it using "@formatjs/intl-relativetimeformat"
|
|
4731
|
-
`, ErrorCode.MISSING_INTL_API));
|
|
4732
|
-
}
|
|
4733
|
-
try {
|
|
4734
|
-
return getFormatter$1(config2, getRelativeTimeFormat, options).format(value, unit);
|
|
4735
|
-
} catch (e) {
|
|
4736
|
-
config2.onError(new IntlFormatError("Error formatting relative time.", config2.locale, e));
|
|
4737
|
-
}
|
|
4738
|
-
return String(value);
|
|
4739
|
-
}
|
|
4740
|
-
const NUMBER_FORMAT_OPTIONS = [
|
|
4741
|
-
"style",
|
|
4742
|
-
"currency",
|
|
4743
|
-
"unit",
|
|
4744
|
-
"unitDisplay",
|
|
4745
|
-
"useGrouping",
|
|
4746
|
-
"minimumIntegerDigits",
|
|
4747
|
-
"minimumFractionDigits",
|
|
4748
|
-
"maximumFractionDigits",
|
|
4749
|
-
"minimumSignificantDigits",
|
|
4750
|
-
"maximumSignificantDigits",
|
|
4751
|
-
"compactDisplay",
|
|
4752
|
-
"currencyDisplay",
|
|
4753
|
-
"currencySign",
|
|
4754
|
-
"notation",
|
|
4755
|
-
"signDisplay",
|
|
4756
|
-
"unit",
|
|
4757
|
-
"unitDisplay",
|
|
4758
|
-
"numberingSystem",
|
|
4759
|
-
"trailingZeroDisplay",
|
|
4760
|
-
"roundingPriority",
|
|
4761
|
-
"roundingIncrement",
|
|
4762
|
-
"roundingMode"
|
|
4763
|
-
];
|
|
4764
|
-
function getFormatter({ locale, formats, onError }, getNumberFormat, options = {}) {
|
|
4765
|
-
const { format } = options;
|
|
4766
|
-
const defaults = format && getNamedFormat(formats, "number", format, onError) || {};
|
|
4767
|
-
const filteredOptions = filterProps(options, NUMBER_FORMAT_OPTIONS, defaults);
|
|
4768
|
-
return getNumberFormat(locale, filteredOptions);
|
|
4769
|
-
}
|
|
4770
|
-
function formatNumber(config2, getNumberFormat, value, options = {}) {
|
|
4771
|
-
try {
|
|
4772
|
-
return getFormatter(config2, getNumberFormat, options).format(value);
|
|
4773
|
-
} catch (e) {
|
|
4774
|
-
config2.onError(new IntlFormatError("Error formatting number.", config2.locale, e));
|
|
4775
|
-
}
|
|
4776
|
-
return String(value);
|
|
4777
|
-
}
|
|
4778
|
-
function formatNumberToParts(config2, getNumberFormat, value, options = {}) {
|
|
4779
|
-
try {
|
|
4780
|
-
return getFormatter(config2, getNumberFormat, options).formatToParts(value);
|
|
4781
|
-
} catch (e) {
|
|
4782
|
-
config2.onError(new IntlFormatError("Error formatting number.", config2.locale, e));
|
|
4783
|
-
}
|
|
4784
|
-
return [];
|
|
4785
|
-
}
|
|
4786
|
-
function messagesContainString(messages) {
|
|
4787
|
-
const firstMessage = messages ? messages[Object.keys(messages)[0]] : void 0;
|
|
4788
|
-
return typeof firstMessage === "string";
|
|
4789
|
-
}
|
|
4790
|
-
function verifyConfigMessages(config2) {
|
|
4791
|
-
if (config2.onWarn && config2.defaultRichTextElements && messagesContainString(config2.messages || {})) {
|
|
4792
|
-
config2.onWarn(`[@formatjs/intl] "defaultRichTextElements" was specified but "message" was not pre-compiled.
|
|
4793
|
-
Please consider using "@formatjs/cli" to pre-compile your messages for performance.
|
|
4794
|
-
For more details see https://formatjs.github.io/docs/getting-started/message-distribution`);
|
|
4795
|
-
}
|
|
4796
|
-
}
|
|
4797
|
-
function createIntl$1(config2, cache) {
|
|
4798
|
-
const formatters = createFormatters(cache);
|
|
4799
|
-
const resolvedConfig = {
|
|
4800
|
-
...DEFAULT_INTL_CONFIG$1,
|
|
4801
|
-
...config2
|
|
4802
|
-
};
|
|
4803
|
-
const { locale, defaultLocale, onError } = resolvedConfig;
|
|
4804
|
-
if (!locale) {
|
|
4805
|
-
if (onError) {
|
|
4806
|
-
onError(new InvalidConfigError(`"locale" was not configured, using "${defaultLocale}" as fallback. See https://formatjs.github.io/docs/react-intl/api#intlshape for more details`));
|
|
4807
|
-
}
|
|
4808
|
-
resolvedConfig.locale = resolvedConfig.defaultLocale || "en";
|
|
4809
|
-
} else if (!Intl.NumberFormat.supportedLocalesOf(locale).length && onError) {
|
|
4810
|
-
onError(new MissingDataError(`Missing locale data for locale: "${locale}" in Intl.NumberFormat. Using default locale: "${defaultLocale}" as fallback. See https://formatjs.github.io/docs/react-intl#runtime-requirements for more details`));
|
|
4811
|
-
} else if (!Intl.DateTimeFormat.supportedLocalesOf(locale).length && onError) {
|
|
4812
|
-
onError(new MissingDataError(`Missing locale data for locale: "${locale}" in Intl.DateTimeFormat. Using default locale: "${defaultLocale}" as fallback. See https://formatjs.github.io/docs/react-intl#runtime-requirements for more details`));
|
|
4813
|
-
}
|
|
4814
|
-
verifyConfigMessages(resolvedConfig);
|
|
4815
|
-
return {
|
|
4816
|
-
...resolvedConfig,
|
|
4817
|
-
formatters,
|
|
4818
|
-
formatNumber: formatNumber.bind(null, resolvedConfig, formatters.getNumberFormat),
|
|
4819
|
-
formatNumberToParts: formatNumberToParts.bind(null, resolvedConfig, formatters.getNumberFormat),
|
|
4820
|
-
formatRelativeTime: formatRelativeTime.bind(null, resolvedConfig, formatters.getRelativeTimeFormat),
|
|
4821
|
-
formatDate: formatDate.bind(null, resolvedConfig, formatters.getDateTimeFormat),
|
|
4822
|
-
formatDateToParts: formatDateToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat),
|
|
4823
|
-
formatTime: formatTime.bind(null, resolvedConfig, formatters.getDateTimeFormat),
|
|
4824
|
-
formatDateTimeRange: formatDateTimeRange.bind(null, resolvedConfig, formatters.getDateTimeFormat),
|
|
4825
|
-
formatTimeToParts: formatTimeToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat),
|
|
4826
|
-
formatPlural: formatPlural.bind(null, resolvedConfig, formatters.getPluralRules),
|
|
4827
|
-
formatMessage: formatMessage$1.bind(null, resolvedConfig, formatters),
|
|
4828
|
-
$t: formatMessage$1.bind(null, resolvedConfig, formatters),
|
|
4829
|
-
formatList: formatList.bind(null, resolvedConfig, formatters.getListFormat),
|
|
4830
|
-
formatListToParts: formatListToParts.bind(null, resolvedConfig, formatters.getListFormat),
|
|
4831
|
-
formatDisplayName: formatDisplayName.bind(null, resolvedConfig, formatters.getDisplayNames)
|
|
4832
|
-
};
|
|
4833
|
-
}
|
|
4834
|
-
function invariant$1(condition, message, Err = Error) {
|
|
4835
|
-
if (!condition) {
|
|
4836
|
-
throw new Err(message);
|
|
4837
|
-
}
|
|
4838
|
-
}
|
|
4839
|
-
function invariantIntlContext(intl) {
|
|
4840
|
-
invariant$1(intl, "[React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry.");
|
|
4841
|
-
}
|
|
4842
|
-
const DEFAULT_INTL_CONFIG = {
|
|
4843
|
-
...DEFAULT_INTL_CONFIG$1,
|
|
4844
|
-
textComponent: React3.Fragment
|
|
4845
|
-
};
|
|
4846
|
-
const toKeyedReactNodeArray = (children) => {
|
|
4847
|
-
const childrenArray = React3.Children.toArray(children);
|
|
4848
|
-
return childrenArray.map((child, index) => {
|
|
4849
|
-
if (React3.isValidElement(child)) {
|
|
4850
|
-
return /* @__PURE__ */ jsx(React3.Fragment, { children: child }, index);
|
|
4851
|
-
}
|
|
4852
|
-
return child;
|
|
4853
|
-
});
|
|
4854
|
-
};
|
|
4855
|
-
function assignUniqueKeysToParts(formatXMLElementFn) {
|
|
4856
|
-
return function(parts) {
|
|
4857
|
-
return formatXMLElementFn(toKeyedReactNodeArray(parts));
|
|
4858
|
-
};
|
|
4859
|
-
}
|
|
4860
|
-
function shallowEqual(objA, objB) {
|
|
4861
|
-
if (objA === objB) {
|
|
4862
|
-
return true;
|
|
4863
|
-
}
|
|
4864
|
-
if (!objA || !objB) {
|
|
4865
|
-
return false;
|
|
4866
|
-
}
|
|
4867
|
-
var aKeys = Object.keys(objA);
|
|
4868
|
-
var bKeys = Object.keys(objB);
|
|
4869
|
-
var len = aKeys.length;
|
|
4870
|
-
if (bKeys.length !== len) {
|
|
4871
|
-
return false;
|
|
4872
|
-
}
|
|
4873
|
-
for (var i = 0; i < len; i++) {
|
|
4874
|
-
var key = aKeys[i];
|
|
4875
|
-
if (objA[key] !== objB[key] || !Object.prototype.hasOwnProperty.call(objB, key)) {
|
|
4876
|
-
return false;
|
|
4877
|
-
}
|
|
4878
|
-
}
|
|
4879
|
-
return true;
|
|
4880
|
-
}
|
|
4881
|
-
const IntlContext = React3.createContext(null);
|
|
4882
|
-
const Provider = IntlContext.Provider;
|
|
4883
|
-
function useIntl() {
|
|
4884
|
-
const intl = React3.useContext(IntlContext);
|
|
4885
|
-
invariantIntlContext(intl);
|
|
4886
|
-
return intl;
|
|
4887
|
-
}
|
|
4888
|
-
var DisplayName = /* @__PURE__ */ (function(DisplayName2) {
|
|
4889
|
-
DisplayName2["formatDate"] = "FormattedDate";
|
|
4890
|
-
DisplayName2["formatTime"] = "FormattedTime";
|
|
4891
|
-
DisplayName2["formatNumber"] = "FormattedNumber";
|
|
4892
|
-
DisplayName2["formatList"] = "FormattedList";
|
|
4893
|
-
DisplayName2["formatDisplayName"] = "FormattedDisplayName";
|
|
4894
|
-
return DisplayName2;
|
|
4895
|
-
})(DisplayName || {});
|
|
4896
|
-
var DisplayNameParts = /* @__PURE__ */ (function(DisplayNameParts2) {
|
|
4897
|
-
DisplayNameParts2["formatDate"] = "FormattedDateParts";
|
|
4898
|
-
DisplayNameParts2["formatTime"] = "FormattedTimeParts";
|
|
4899
|
-
DisplayNameParts2["formatNumber"] = "FormattedNumberParts";
|
|
4900
|
-
DisplayNameParts2["formatList"] = "FormattedListParts";
|
|
4901
|
-
return DisplayNameParts2;
|
|
4902
|
-
})(DisplayNameParts || {});
|
|
4903
|
-
function createFormattedDateTimePartsComponent(name) {
|
|
4904
|
-
const ComponentParts = (props) => {
|
|
4905
|
-
const intl = useIntl();
|
|
4906
|
-
const { value, children, ...formatProps } = props;
|
|
4907
|
-
const date = typeof value === "string" ? new Date(value || 0) : value;
|
|
4908
|
-
const formattedParts = name === "formatDate" ? intl.formatDateToParts(date, formatProps) : intl.formatTimeToParts(date, formatProps);
|
|
4909
|
-
return children(formattedParts);
|
|
4910
|
-
};
|
|
4911
|
-
ComponentParts.displayName = DisplayNameParts[name];
|
|
4912
|
-
return ComponentParts;
|
|
4913
|
-
}
|
|
4914
|
-
function createFormattedComponent(name) {
|
|
4915
|
-
const Component = (props) => {
|
|
4916
|
-
const intl = useIntl();
|
|
4917
|
-
const { value, children, ...formatProps } = props;
|
|
4918
|
-
const formattedValue = intl[name](value, formatProps);
|
|
4919
|
-
if (typeof children === "function") {
|
|
4920
|
-
return children(formattedValue);
|
|
4921
|
-
}
|
|
4922
|
-
const Text = intl.textComponent || React3.Fragment;
|
|
4923
|
-
return /* @__PURE__ */ jsx(Text, { children: formattedValue });
|
|
4924
|
-
};
|
|
4925
|
-
Component.displayName = DisplayName[name];
|
|
4926
|
-
return Component;
|
|
4927
|
-
}
|
|
4928
|
-
function assignUniqueKeysToFormatXMLElementFnArgument(values) {
|
|
4929
|
-
if (!values) {
|
|
4930
|
-
return values;
|
|
4931
|
-
}
|
|
4932
|
-
return Object.keys(values).reduce((acc, k) => {
|
|
4933
|
-
const v = values[k];
|
|
4934
|
-
acc[k] = isFormatXMLElementFn(v) ? assignUniqueKeysToParts(v) : v;
|
|
4935
|
-
return acc;
|
|
4936
|
-
}, {});
|
|
4937
|
-
}
|
|
4938
|
-
const formatMessage = (config2, formatters, descriptor, rawValues, ...rest) => {
|
|
4939
|
-
const values = assignUniqueKeysToFormatXMLElementFnArgument(rawValues);
|
|
4940
|
-
const chunks = formatMessage$1(config2, formatters, descriptor, values, ...rest);
|
|
4941
|
-
if (Array.isArray(chunks)) {
|
|
4942
|
-
return toKeyedReactNodeArray(chunks);
|
|
4943
|
-
}
|
|
4944
|
-
return chunks;
|
|
4945
|
-
};
|
|
4946
|
-
const createIntl = ({ defaultRichTextElements: rawDefaultRichTextElements, ...config2 }, cache) => {
|
|
4947
|
-
const defaultRichTextElements = assignUniqueKeysToFormatXMLElementFnArgument(rawDefaultRichTextElements);
|
|
4948
|
-
const coreIntl = createIntl$1({
|
|
4949
|
-
...DEFAULT_INTL_CONFIG,
|
|
4950
|
-
...config2,
|
|
4951
|
-
defaultRichTextElements
|
|
4952
|
-
}, cache);
|
|
4953
|
-
const resolvedConfig = {
|
|
4954
|
-
locale: coreIntl.locale,
|
|
4955
|
-
timeZone: coreIntl.timeZone,
|
|
4956
|
-
fallbackOnEmptyString: coreIntl.fallbackOnEmptyString,
|
|
4957
|
-
formats: coreIntl.formats,
|
|
4958
|
-
defaultLocale: coreIntl.defaultLocale,
|
|
4959
|
-
defaultFormats: coreIntl.defaultFormats,
|
|
4960
|
-
messages: coreIntl.messages,
|
|
4961
|
-
onError: coreIntl.onError,
|
|
4962
|
-
defaultRichTextElements
|
|
4963
|
-
};
|
|
4964
|
-
return {
|
|
4965
|
-
...coreIntl,
|
|
4966
|
-
formatMessage: formatMessage.bind(null, resolvedConfig, coreIntl.formatters),
|
|
4967
|
-
$t: formatMessage.bind(null, resolvedConfig, coreIntl.formatters)
|
|
4968
|
-
};
|
|
4969
|
-
};
|
|
4970
|
-
function processIntlConfig(config2) {
|
|
4971
|
-
return {
|
|
4972
|
-
locale: config2.locale,
|
|
4973
|
-
timeZone: config2.timeZone,
|
|
4974
|
-
fallbackOnEmptyString: config2.fallbackOnEmptyString,
|
|
4975
|
-
formats: config2.formats,
|
|
4976
|
-
textComponent: config2.textComponent,
|
|
4977
|
-
messages: config2.messages,
|
|
4978
|
-
defaultLocale: config2.defaultLocale,
|
|
4979
|
-
defaultFormats: config2.defaultFormats,
|
|
4980
|
-
onError: config2.onError,
|
|
4981
|
-
onWarn: config2.onWarn,
|
|
4982
|
-
wrapRichTextChunksInFragment: config2.wrapRichTextChunksInFragment,
|
|
4983
|
-
defaultRichTextElements: config2.defaultRichTextElements
|
|
4984
|
-
};
|
|
4985
|
-
}
|
|
4986
|
-
function IntlProviderImpl(props) {
|
|
4987
|
-
const cacheRef = React3.useRef(createIntlCache());
|
|
4988
|
-
const prevConfigRef = React3.useRef(void 0);
|
|
4989
|
-
const intlRef = React3.useRef(void 0);
|
|
4990
|
-
const filteredProps = {};
|
|
4991
|
-
for (const key in props) {
|
|
4992
|
-
if (props[key] !== void 0) {
|
|
4993
|
-
filteredProps[key] = props[key];
|
|
4994
|
-
}
|
|
4995
|
-
}
|
|
4996
|
-
const config2 = processIntlConfig({
|
|
4997
|
-
...DEFAULT_INTL_CONFIG,
|
|
4998
|
-
...filteredProps
|
|
4999
|
-
});
|
|
5000
|
-
if (!prevConfigRef.current || !shallowEqual(prevConfigRef.current, config2)) {
|
|
5001
|
-
prevConfigRef.current = config2;
|
|
5002
|
-
intlRef.current = createIntl(config2, cacheRef.current);
|
|
5003
|
-
}
|
|
5004
|
-
invariantIntlContext(intlRef.current);
|
|
5005
|
-
return /* @__PURE__ */ jsx(Provider, {
|
|
5006
|
-
value: intlRef.current,
|
|
5007
|
-
children: props.children
|
|
5008
|
-
});
|
|
5009
|
-
}
|
|
5010
|
-
IntlProviderImpl.displayName = "IntlProvider";
|
|
5011
|
-
const IntlProvider = IntlProviderImpl;
|
|
5012
|
-
createFormattedComponent("formatDate");
|
|
5013
|
-
createFormattedComponent("formatTime");
|
|
5014
|
-
createFormattedComponent("formatNumber");
|
|
5015
|
-
createFormattedComponent("formatList");
|
|
5016
|
-
createFormattedComponent("formatDisplayName");
|
|
5017
|
-
createFormattedDateTimePartsComponent("formatDate");
|
|
5018
|
-
createFormattedDateTimePartsComponent("formatTime");
|
|
5019
1300
|
var Action = /* @__PURE__ */ ((Action2) => {
|
|
5020
1301
|
Action2["Pop"] = "POP";
|
|
5021
1302
|
Action2["Push"] = "PUSH";
|
|
@@ -6975,7 +3256,6 @@ export {
|
|
|
6975
3256
|
Action as A,
|
|
6976
3257
|
BehaviorSubject as B,
|
|
6977
3258
|
EmptyError as E,
|
|
6978
|
-
IntlProvider as I,
|
|
6979
3259
|
Link as L,
|
|
6980
3260
|
Observable as O,
|
|
6981
3261
|
Subscription as S,
|