intl-messageformat 10.6.0 → 10.7.0
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/intl-messageformat.esm.js +197 -141
- package/intl-messageformat.iife.js +364 -350
- package/lib/src/core.d.ts +2 -2
- package/lib/src/core.js +1 -1
- package/package.json +5 -5
- package/src/core.d.ts +2 -2
- package/src/core.js +1 -1
- package/src/formatters.js +3 -3
|
@@ -1,8 +1,37 @@
|
|
|
1
1
|
var IntlMessageFormat = (() => {
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
var __objRest = (source, exclude) => {
|
|
24
|
+
var target = {};
|
|
25
|
+
for (var prop in source)
|
|
26
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
27
|
+
target[prop] = source[prop];
|
|
28
|
+
if (source != null && __getOwnPropSymbols)
|
|
29
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
30
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
31
|
+
target[prop] = source[prop];
|
|
32
|
+
}
|
|
33
|
+
return target;
|
|
34
|
+
};
|
|
6
35
|
var __export = (target, all) => {
|
|
7
36
|
for (var name in all)
|
|
8
37
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -16,10 +45,14 @@ var IntlMessageFormat = (() => {
|
|
|
16
45
|
return to;
|
|
17
46
|
};
|
|
18
47
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
48
|
+
var __publicField = (obj, key, value) => {
|
|
49
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
50
|
+
return value;
|
|
51
|
+
};
|
|
19
52
|
|
|
20
|
-
//
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
53
|
+
// packages/intl-messageformat/index.ts
|
|
54
|
+
var intl_messageformat_exports = {};
|
|
55
|
+
__export(intl_messageformat_exports, {
|
|
23
56
|
ErrorCode: () => ErrorCode,
|
|
24
57
|
FormatError: () => FormatError,
|
|
25
58
|
IntlMessageFormat: () => IntlMessageFormat,
|
|
@@ -27,68 +60,12 @@ var IntlMessageFormat = (() => {
|
|
|
27
60
|
InvalidValueTypeError: () => InvalidValueTypeError,
|
|
28
61
|
MissingValueError: () => MissingValueError,
|
|
29
62
|
PART_TYPE: () => PART_TYPE,
|
|
30
|
-
default: () =>
|
|
63
|
+
default: () => intl_messageformat_default,
|
|
31
64
|
formatToParts: () => formatToParts,
|
|
32
65
|
isFormatXMLElementFn: () => isFormatXMLElementFn
|
|
33
66
|
});
|
|
34
67
|
|
|
35
|
-
//
|
|
36
|
-
var extendStatics = function(d, b) {
|
|
37
|
-
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
38
|
-
d2.__proto__ = b2;
|
|
39
|
-
} || function(d2, b2) {
|
|
40
|
-
for (var p in b2)
|
|
41
|
-
if (Object.prototype.hasOwnProperty.call(b2, p))
|
|
42
|
-
d2[p] = b2[p];
|
|
43
|
-
};
|
|
44
|
-
return extendStatics(d, b);
|
|
45
|
-
};
|
|
46
|
-
function __extends(d, b) {
|
|
47
|
-
if (typeof b !== "function" && b !== null)
|
|
48
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
49
|
-
extendStatics(d, b);
|
|
50
|
-
function __() {
|
|
51
|
-
this.constructor = d;
|
|
52
|
-
}
|
|
53
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
54
|
-
}
|
|
55
|
-
var __assign = function() {
|
|
56
|
-
__assign = Object.assign || function __assign2(t) {
|
|
57
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
58
|
-
s = arguments[i];
|
|
59
|
-
for (var p in s)
|
|
60
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
61
|
-
t[p] = s[p];
|
|
62
|
-
}
|
|
63
|
-
return t;
|
|
64
|
-
};
|
|
65
|
-
return __assign.apply(this, arguments);
|
|
66
|
-
};
|
|
67
|
-
function __rest(s, e) {
|
|
68
|
-
var t = {};
|
|
69
|
-
for (var p in s)
|
|
70
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
71
|
-
t[p] = s[p];
|
|
72
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
73
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
74
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
75
|
-
t[p[i]] = s[p[i]];
|
|
76
|
-
}
|
|
77
|
-
return t;
|
|
78
|
-
}
|
|
79
|
-
function __spreadArray(to, from, pack) {
|
|
80
|
-
if (pack || arguments.length === 2)
|
|
81
|
-
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
82
|
-
if (ar || !(i in from)) {
|
|
83
|
-
if (!ar)
|
|
84
|
-
ar = Array.prototype.slice.call(from, 0, i);
|
|
85
|
-
ar[i] = from[i];
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// ../../../../../../../../execroot/formatjs/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/lib/index.js
|
|
68
|
+
// node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/lib/index.js
|
|
92
69
|
function memoize(fn, options) {
|
|
93
70
|
var cache = options && options.cache ? options.cache : cacheDefault;
|
|
94
71
|
var serializer = options && options.serializer ? options.serializer : serializerDefault;
|
|
@@ -155,7 +132,21 @@ var IntlMessageFormat = (() => {
|
|
|
155
132
|
monadic: strategyMonadic
|
|
156
133
|
};
|
|
157
134
|
|
|
158
|
-
//
|
|
135
|
+
// node_modules/.aspect_rules_js/tslib@2.7.0/node_modules/tslib/tslib.es6.mjs
|
|
136
|
+
var __assign = function() {
|
|
137
|
+
__assign = Object.assign || function __assign2(t) {
|
|
138
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
139
|
+
s = arguments[i];
|
|
140
|
+
for (var p in s)
|
|
141
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
142
|
+
t[p] = s[p];
|
|
143
|
+
}
|
|
144
|
+
return t;
|
|
145
|
+
};
|
|
146
|
+
return __assign.apply(this, arguments);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// node_modules/.aspect_rules_js/@formatjs+icu-messageformat-parser@0.0.0/node_modules/@formatjs/icu-messageformat-parser/lib/error.js
|
|
159
150
|
var ErrorKind;
|
|
160
151
|
(function(ErrorKind2) {
|
|
161
152
|
ErrorKind2[ErrorKind2["EXPECT_ARGUMENT_CLOSING_BRACE"] = 1] = "EXPECT_ARGUMENT_CLOSING_BRACE";
|
|
@@ -186,7 +177,7 @@ var IntlMessageFormat = (() => {
|
|
|
186
177
|
ErrorKind2[ErrorKind2["UNCLOSED_TAG"] = 27] = "UNCLOSED_TAG";
|
|
187
178
|
})(ErrorKind || (ErrorKind = {}));
|
|
188
179
|
|
|
189
|
-
//
|
|
180
|
+
// node_modules/.aspect_rules_js/@formatjs+icu-messageformat-parser@0.0.0/node_modules/@formatjs/icu-messageformat-parser/lib/types.js
|
|
190
181
|
var TYPE;
|
|
191
182
|
(function(TYPE2) {
|
|
192
183
|
TYPE2[TYPE2["literal"] = 0] = "literal";
|
|
@@ -238,10 +229,10 @@ var IntlMessageFormat = (() => {
|
|
|
238
229
|
return !!(el && typeof el === "object" && el.type === SKELETON_TYPE.dateTime);
|
|
239
230
|
}
|
|
240
231
|
|
|
241
|
-
//
|
|
232
|
+
// node_modules/.aspect_rules_js/@formatjs+icu-messageformat-parser@0.0.0/node_modules/@formatjs/icu-messageformat-parser/lib/regex.generated.js
|
|
242
233
|
var SPACE_SEPARATOR_REGEX = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/;
|
|
243
234
|
|
|
244
|
-
//
|
|
235
|
+
// node_modules/.aspect_rules_js/@formatjs+icu-skeleton-parser@0.0.0/node_modules/@formatjs/icu-skeleton-parser/lib/date-time.js
|
|
245
236
|
var 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;
|
|
246
237
|
function parseDateTimeSkeleton(skeleton) {
|
|
247
238
|
var result = {};
|
|
@@ -342,10 +333,10 @@ var IntlMessageFormat = (() => {
|
|
|
342
333
|
return result;
|
|
343
334
|
}
|
|
344
335
|
|
|
345
|
-
//
|
|
336
|
+
// node_modules/.aspect_rules_js/@formatjs+icu-skeleton-parser@0.0.0/node_modules/@formatjs/icu-skeleton-parser/lib/regex.generated.js
|
|
346
337
|
var WHITE_SPACE_REGEX = /[\t-\r \x85\u200E\u200F\u2028\u2029]/i;
|
|
347
338
|
|
|
348
|
-
//
|
|
339
|
+
// node_modules/.aspect_rules_js/@formatjs+icu-skeleton-parser@0.0.0/node_modules/@formatjs/icu-skeleton-parser/lib/number.js
|
|
349
340
|
function parseNumberSkeletonFromString(skeleton) {
|
|
350
341
|
if (skeleton.length === 0) {
|
|
351
342
|
throw new Error("Number skeleton cannot be empty");
|
|
@@ -632,7 +623,7 @@ var IntlMessageFormat = (() => {
|
|
|
632
623
|
return result;
|
|
633
624
|
}
|
|
634
625
|
|
|
635
|
-
//
|
|
626
|
+
// node_modules/.aspect_rules_js/@formatjs+icu-messageformat-parser@0.0.0/node_modules/@formatjs/icu-messageformat-parser/lib/time-data.generated.js
|
|
636
627
|
var timeData = {
|
|
637
628
|
"001": [
|
|
638
629
|
"H",
|
|
@@ -2043,7 +2034,7 @@ var IntlMessageFormat = (() => {
|
|
|
2043
2034
|
]
|
|
2044
2035
|
};
|
|
2045
2036
|
|
|
2046
|
-
//
|
|
2037
|
+
// node_modules/.aspect_rules_js/@formatjs+icu-messageformat-parser@0.0.0/node_modules/@formatjs/icu-messageformat-parser/lib/date-time-pattern-generator.js
|
|
2047
2038
|
function getBestPattern(skeleton, locale) {
|
|
2048
2039
|
var skeletonCopy = "";
|
|
2049
2040
|
for (var patternPos = 0; patternPos < skeleton.length; patternPos++) {
|
|
@@ -2105,7 +2096,7 @@ var IntlMessageFormat = (() => {
|
|
|
2105
2096
|
return hourCycles[0];
|
|
2106
2097
|
}
|
|
2107
2098
|
|
|
2108
|
-
//
|
|
2099
|
+
// node_modules/.aspect_rules_js/@formatjs+icu-messageformat-parser@0.0.0/node_modules/@formatjs/icu-messageformat-parser/lib/parser.js
|
|
2109
2100
|
var _a;
|
|
2110
2101
|
var SPACE_SEPARATOR_START_REGEX = new RegExp("^".concat(SPACE_SEPARATOR_REGEX.source, "*"));
|
|
2111
2102
|
var SPACE_SEPARATOR_END_REGEX = new RegExp("".concat(SPACE_SEPARATOR_REGEX.source, "*$"));
|
|
@@ -2910,7 +2901,7 @@ var IntlMessageFormat = (() => {
|
|
|
2910
2901
|
return c >= 33 && c <= 35 || c === 36 || c >= 37 && c <= 39 || c === 40 || c === 41 || c === 42 || c === 43 || c === 44 || c === 45 || c >= 46 && c <= 47 || c >= 58 && c <= 59 || c >= 60 && c <= 62 || c >= 63 && c <= 64 || c === 91 || c === 92 || c === 93 || c === 94 || c === 96 || c === 123 || c === 124 || c === 125 || c === 126 || c === 161 || c >= 162 && c <= 165 || c === 166 || c === 167 || c === 169 || c === 171 || c === 172 || c === 174 || c === 176 || c === 177 || c === 182 || c === 187 || c === 191 || c === 215 || c === 247 || c >= 8208 && c <= 8213 || c >= 8214 && c <= 8215 || c === 8216 || c === 8217 || c === 8218 || c >= 8219 && c <= 8220 || c === 8221 || c === 8222 || c === 8223 || c >= 8224 && c <= 8231 || c >= 8240 && c <= 8248 || c === 8249 || c === 8250 || c >= 8251 && c <= 8254 || c >= 8257 && c <= 8259 || c === 8260 || c === 8261 || c === 8262 || c >= 8263 && c <= 8273 || c === 8274 || c === 8275 || c >= 8277 && c <= 8286 || c >= 8592 && c <= 8596 || c >= 8597 && c <= 8601 || c >= 8602 && c <= 8603 || c >= 8604 && c <= 8607 || c === 8608 || c >= 8609 && c <= 8610 || c === 8611 || c >= 8612 && c <= 8613 || c === 8614 || c >= 8615 && c <= 8621 || c === 8622 || c >= 8623 && c <= 8653 || c >= 8654 && c <= 8655 || c >= 8656 && c <= 8657 || c === 8658 || c === 8659 || c === 8660 || c >= 8661 && c <= 8691 || c >= 8692 && c <= 8959 || c >= 8960 && c <= 8967 || c === 8968 || c === 8969 || c === 8970 || c === 8971 || c >= 8972 && c <= 8991 || c >= 8992 && c <= 8993 || c >= 8994 && c <= 9e3 || c === 9001 || c === 9002 || c >= 9003 && c <= 9083 || c === 9084 || c >= 9085 && c <= 9114 || c >= 9115 && c <= 9139 || c >= 9140 && c <= 9179 || c >= 9180 && c <= 9185 || c >= 9186 && c <= 9254 || c >= 9255 && c <= 9279 || c >= 9280 && c <= 9290 || c >= 9291 && c <= 9311 || c >= 9472 && c <= 9654 || c === 9655 || c >= 9656 && c <= 9664 || c === 9665 || c >= 9666 && c <= 9719 || c >= 9720 && c <= 9727 || c >= 9728 && c <= 9838 || c === 9839 || c >= 9840 && c <= 10087 || c === 10088 || c === 10089 || c === 10090 || c === 10091 || c === 10092 || c === 10093 || c === 10094 || c === 10095 || c === 10096 || c === 10097 || c === 10098 || c === 10099 || c === 10100 || c === 10101 || c >= 10132 && c <= 10175 || c >= 10176 && c <= 10180 || c === 10181 || c === 10182 || c >= 10183 && c <= 10213 || c === 10214 || c === 10215 || c === 10216 || c === 10217 || c === 10218 || c === 10219 || c === 10220 || c === 10221 || c === 10222 || c === 10223 || c >= 10224 && c <= 10239 || c >= 10240 && c <= 10495 || c >= 10496 && c <= 10626 || c === 10627 || c === 10628 || c === 10629 || c === 10630 || c === 10631 || c === 10632 || c === 10633 || c === 10634 || c === 10635 || c === 10636 || c === 10637 || c === 10638 || c === 10639 || c === 10640 || c === 10641 || c === 10642 || c === 10643 || c === 10644 || c === 10645 || c === 10646 || c === 10647 || c === 10648 || c >= 10649 && c <= 10711 || c === 10712 || c === 10713 || c === 10714 || c === 10715 || c >= 10716 && c <= 10747 || c === 10748 || c === 10749 || c >= 10750 && c <= 11007 || c >= 11008 && c <= 11055 || c >= 11056 && c <= 11076 || c >= 11077 && c <= 11078 || c >= 11079 && c <= 11084 || c >= 11085 && c <= 11123 || c >= 11124 && c <= 11125 || c >= 11126 && c <= 11157 || c === 11158 || c >= 11159 && c <= 11263 || c >= 11776 && c <= 11777 || c === 11778 || c === 11779 || c === 11780 || c === 11781 || c >= 11782 && c <= 11784 || c === 11785 || c === 11786 || c === 11787 || c === 11788 || c === 11789 || c >= 11790 && c <= 11798 || c === 11799 || c >= 11800 && c <= 11801 || c === 11802 || c === 11803 || c === 11804 || c === 11805 || c >= 11806 && c <= 11807 || c === 11808 || c === 11809 || c === 11810 || c === 11811 || c === 11812 || c === 11813 || c === 11814 || c === 11815 || c === 11816 || c === 11817 || c >= 11818 && c <= 11822 || c === 11823 || c >= 11824 && c <= 11833 || c >= 11834 && c <= 11835 || c >= 11836 && c <= 11839 || c === 11840 || c === 11841 || c === 11842 || c >= 11843 && c <= 11855 || c >= 11856 && c <= 11857 || c === 11858 || c >= 11859 && c <= 11903 || c >= 12289 && c <= 12291 || c === 12296 || c === 12297 || c === 12298 || c === 12299 || c === 12300 || c === 12301 || c === 12302 || c === 12303 || c === 12304 || c === 12305 || c >= 12306 && c <= 12307 || c === 12308 || c === 12309 || c === 12310 || c === 12311 || c === 12312 || c === 12313 || c === 12314 || c === 12315 || c === 12316 || c === 12317 || c >= 12318 && c <= 12319 || c === 12320 || c === 12336 || c === 64830 || c === 64831 || c >= 65093 && c <= 65094;
|
|
2911
2902
|
}
|
|
2912
2903
|
|
|
2913
|
-
//
|
|
2904
|
+
// node_modules/.aspect_rules_js/@formatjs+icu-messageformat-parser@0.0.0/node_modules/@formatjs/icu-messageformat-parser/lib/index.js
|
|
2914
2905
|
function pruneLocation(els) {
|
|
2915
2906
|
els.forEach(function(el) {
|
|
2916
2907
|
delete el.location;
|
|
@@ -2946,73 +2937,75 @@ var IntlMessageFormat = (() => {
|
|
|
2946
2937
|
return result.val;
|
|
2947
2938
|
}
|
|
2948
2939
|
|
|
2949
|
-
//
|
|
2950
|
-
var ErrorCode
|
|
2951
|
-
(function(ErrorCode2) {
|
|
2940
|
+
// packages/intl-messageformat/src/error.ts
|
|
2941
|
+
var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
|
|
2952
2942
|
ErrorCode2["MISSING_VALUE"] = "MISSING_VALUE";
|
|
2953
2943
|
ErrorCode2["INVALID_VALUE"] = "INVALID_VALUE";
|
|
2954
2944
|
ErrorCode2["MISSING_INTL_API"] = "MISSING_INTL_API";
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
2945
|
+
return ErrorCode2;
|
|
2946
|
+
})(ErrorCode || {});
|
|
2947
|
+
var FormatError = class extends Error {
|
|
2948
|
+
constructor(msg, code, originalMessage) {
|
|
2949
|
+
super(msg);
|
|
2950
|
+
__publicField(this, "code");
|
|
2951
|
+
/**
|
|
2952
|
+
* Original message we're trying to format
|
|
2953
|
+
* `undefined` if we're only dealing w/ AST
|
|
2954
|
+
*
|
|
2955
|
+
* @type {(string | undefined)}
|
|
2956
|
+
* @memberof FormatError
|
|
2957
|
+
*/
|
|
2958
|
+
__publicField(this, "originalMessage");
|
|
2959
|
+
this.code = code;
|
|
2960
|
+
this.originalMessage = originalMessage;
|
|
2961
|
+
}
|
|
2962
|
+
toString() {
|
|
2963
|
+
return `[formatjs Error: ${this.code}] ${this.message}`;
|
|
2964
|
+
}
|
|
2965
|
+
};
|
|
2966
|
+
var InvalidValueError = class extends FormatError {
|
|
2967
|
+
constructor(variableId, value, options, originalMessage) {
|
|
2968
|
+
super(
|
|
2969
|
+
`Invalid values for "${variableId}": "${value}". Options are "${Object.keys(
|
|
2970
|
+
options
|
|
2971
|
+
).join('", "')}"`,
|
|
2972
|
+
"INVALID_VALUE" /* INVALID_VALUE */,
|
|
2973
|
+
originalMessage
|
|
2974
|
+
);
|
|
2975
|
+
}
|
|
2976
|
+
};
|
|
2977
|
+
var InvalidValueTypeError = class extends FormatError {
|
|
2978
|
+
constructor(value, type, originalMessage) {
|
|
2979
|
+
super(
|
|
2980
|
+
`Value for "${value}" must be of type ${type}`,
|
|
2981
|
+
"INVALID_VALUE" /* INVALID_VALUE */,
|
|
2982
|
+
originalMessage
|
|
2983
|
+
);
|
|
2984
|
+
}
|
|
2985
|
+
};
|
|
2986
|
+
var MissingValueError = class extends FormatError {
|
|
2987
|
+
constructor(variableId, originalMessage) {
|
|
2988
|
+
super(
|
|
2989
|
+
`The intl string context variable "${variableId}" was not provided to the string "${originalMessage}"`,
|
|
2990
|
+
"MISSING_VALUE" /* MISSING_VALUE */,
|
|
2991
|
+
originalMessage
|
|
2992
|
+
);
|
|
2993
|
+
}
|
|
2994
|
+
};
|
|
3002
2995
|
|
|
3003
|
-
//
|
|
3004
|
-
var PART_TYPE
|
|
3005
|
-
(function(PART_TYPE2) {
|
|
2996
|
+
// packages/intl-messageformat/src/formatters.ts
|
|
2997
|
+
var PART_TYPE = /* @__PURE__ */ ((PART_TYPE2) => {
|
|
3006
2998
|
PART_TYPE2[PART_TYPE2["literal"] = 0] = "literal";
|
|
3007
2999
|
PART_TYPE2[PART_TYPE2["object"] = 1] = "object";
|
|
3008
|
-
|
|
3000
|
+
return PART_TYPE2;
|
|
3001
|
+
})(PART_TYPE || {});
|
|
3009
3002
|
function mergeLiteral(parts) {
|
|
3010
3003
|
if (parts.length < 2) {
|
|
3011
3004
|
return parts;
|
|
3012
3005
|
}
|
|
3013
|
-
return parts.reduce(
|
|
3014
|
-
|
|
3015
|
-
if (!lastPart || lastPart.type !==
|
|
3006
|
+
return parts.reduce((all, part) => {
|
|
3007
|
+
const lastPart = all[all.length - 1];
|
|
3008
|
+
if (!lastPart || lastPart.type !== 0 /* literal */ || part.type !== 0 /* literal */) {
|
|
3016
3009
|
all.push(part);
|
|
3017
3010
|
} else {
|
|
3018
3011
|
lastPart.value += part.value;
|
|
@@ -3027,17 +3020,16 @@ var IntlMessageFormat = (() => {
|
|
|
3027
3020
|
if (els.length === 1 && isLiteralElement(els[0])) {
|
|
3028
3021
|
return [
|
|
3029
3022
|
{
|
|
3030
|
-
type:
|
|
3023
|
+
type: 0 /* literal */,
|
|
3031
3024
|
value: els[0].value
|
|
3032
3025
|
}
|
|
3033
3026
|
];
|
|
3034
3027
|
}
|
|
3035
|
-
|
|
3036
|
-
for (
|
|
3037
|
-
var el = els_1[_i];
|
|
3028
|
+
const result = [];
|
|
3029
|
+
for (const el of els) {
|
|
3038
3030
|
if (isLiteralElement(el)) {
|
|
3039
3031
|
result.push({
|
|
3040
|
-
type:
|
|
3032
|
+
type: 0 /* literal */,
|
|
3041
3033
|
value: el.value
|
|
3042
3034
|
});
|
|
3043
3035
|
continue;
|
|
@@ -3045,108 +3037,142 @@ var IntlMessageFormat = (() => {
|
|
|
3045
3037
|
if (isPoundElement(el)) {
|
|
3046
3038
|
if (typeof currentPluralValue === "number") {
|
|
3047
3039
|
result.push({
|
|
3048
|
-
type:
|
|
3040
|
+
type: 0 /* literal */,
|
|
3049
3041
|
value: formatters.getNumberFormat(locales).format(currentPluralValue)
|
|
3050
3042
|
});
|
|
3051
3043
|
}
|
|
3052
3044
|
continue;
|
|
3053
3045
|
}
|
|
3054
|
-
|
|
3046
|
+
const { value: varName } = el;
|
|
3055
3047
|
if (!(values && varName in values)) {
|
|
3056
3048
|
throw new MissingValueError(varName, originalMessage);
|
|
3057
3049
|
}
|
|
3058
|
-
|
|
3050
|
+
let value = values[varName];
|
|
3059
3051
|
if (isArgumentElement(el)) {
|
|
3060
3052
|
if (!value || typeof value === "string" || typeof value === "number") {
|
|
3061
3053
|
value = typeof value === "string" || typeof value === "number" ? String(value) : "";
|
|
3062
3054
|
}
|
|
3063
3055
|
result.push({
|
|
3064
|
-
type: typeof value === "string" ?
|
|
3056
|
+
type: typeof value === "string" ? 0 /* literal */ : 1 /* object */,
|
|
3065
3057
|
value
|
|
3066
3058
|
});
|
|
3067
3059
|
continue;
|
|
3068
3060
|
}
|
|
3069
3061
|
if (isDateElement(el)) {
|
|
3070
|
-
|
|
3062
|
+
const style = typeof el.style === "string" ? formats.date[el.style] : isDateTimeSkeleton(el.style) ? el.style.parsedOptions : void 0;
|
|
3071
3063
|
result.push({
|
|
3072
|
-
type:
|
|
3064
|
+
type: 0 /* literal */,
|
|
3073
3065
|
value: formatters.getDateTimeFormat(locales, style).format(value)
|
|
3074
3066
|
});
|
|
3075
3067
|
continue;
|
|
3076
3068
|
}
|
|
3077
3069
|
if (isTimeElement(el)) {
|
|
3078
|
-
|
|
3070
|
+
const style = typeof el.style === "string" ? formats.time[el.style] : isDateTimeSkeleton(el.style) ? el.style.parsedOptions : formats.time.medium;
|
|
3079
3071
|
result.push({
|
|
3080
|
-
type:
|
|
3072
|
+
type: 0 /* literal */,
|
|
3081
3073
|
value: formatters.getDateTimeFormat(locales, style).format(value)
|
|
3082
3074
|
});
|
|
3083
3075
|
continue;
|
|
3084
3076
|
}
|
|
3085
3077
|
if (isNumberElement(el)) {
|
|
3086
|
-
|
|
3078
|
+
const style = typeof el.style === "string" ? formats.number[el.style] : isNumberSkeleton(el.style) ? el.style.parsedOptions : void 0;
|
|
3087
3079
|
if (style && style.scale) {
|
|
3088
3080
|
value = value * (style.scale || 1);
|
|
3089
3081
|
}
|
|
3090
3082
|
result.push({
|
|
3091
|
-
type:
|
|
3083
|
+
type: 0 /* literal */,
|
|
3092
3084
|
value: formatters.getNumberFormat(locales, style).format(value)
|
|
3093
3085
|
});
|
|
3094
3086
|
continue;
|
|
3095
3087
|
}
|
|
3096
3088
|
if (isTagElement(el)) {
|
|
3097
|
-
|
|
3098
|
-
|
|
3089
|
+
const { children, value: value2 } = el;
|
|
3090
|
+
const formatFn = values[value2];
|
|
3099
3091
|
if (!isFormatXMLElementFn(formatFn)) {
|
|
3100
|
-
throw new InvalidValueTypeError(
|
|
3101
|
-
}
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3092
|
+
throw new InvalidValueTypeError(value2, "function", originalMessage);
|
|
3093
|
+
}
|
|
3094
|
+
const parts = formatToParts(
|
|
3095
|
+
children,
|
|
3096
|
+
locales,
|
|
3097
|
+
formatters,
|
|
3098
|
+
formats,
|
|
3099
|
+
values,
|
|
3100
|
+
currentPluralValue
|
|
3101
|
+
);
|
|
3102
|
+
let chunks = formatFn(parts.map((p) => p.value));
|
|
3106
3103
|
if (!Array.isArray(chunks)) {
|
|
3107
3104
|
chunks = [chunks];
|
|
3108
3105
|
}
|
|
3109
|
-
result.push
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3106
|
+
result.push(
|
|
3107
|
+
...chunks.map((c) => {
|
|
3108
|
+
return {
|
|
3109
|
+
type: typeof c === "string" ? 0 /* literal */ : 1 /* object */,
|
|
3110
|
+
value: c
|
|
3111
|
+
};
|
|
3112
|
+
})
|
|
3113
|
+
);
|
|
3115
3114
|
}
|
|
3116
3115
|
if (isSelectElement(el)) {
|
|
3117
|
-
|
|
3116
|
+
const opt = el.options[value] || el.options.other;
|
|
3118
3117
|
if (!opt) {
|
|
3119
|
-
throw new InvalidValueError(
|
|
3120
|
-
|
|
3121
|
-
|
|
3118
|
+
throw new InvalidValueError(
|
|
3119
|
+
el.value,
|
|
3120
|
+
value,
|
|
3121
|
+
Object.keys(el.options),
|
|
3122
|
+
originalMessage
|
|
3123
|
+
);
|
|
3124
|
+
}
|
|
3125
|
+
result.push(
|
|
3126
|
+
...formatToParts(opt.value, locales, formatters, formats, values)
|
|
3127
|
+
);
|
|
3122
3128
|
continue;
|
|
3123
3129
|
}
|
|
3124
3130
|
if (isPluralElement(el)) {
|
|
3125
|
-
|
|
3131
|
+
let opt = el.options[`=${value}`];
|
|
3126
3132
|
if (!opt) {
|
|
3127
3133
|
if (!Intl.PluralRules) {
|
|
3128
|
-
throw new FormatError(
|
|
3134
|
+
throw new FormatError(
|
|
3135
|
+
`Intl.PluralRules is not available in this environment.
|
|
3136
|
+
Try polyfilling it using "@formatjs/intl-pluralrules"
|
|
3137
|
+
`,
|
|
3138
|
+
"MISSING_INTL_API" /* MISSING_INTL_API */,
|
|
3139
|
+
originalMessage
|
|
3140
|
+
);
|
|
3129
3141
|
}
|
|
3130
|
-
|
|
3142
|
+
const rule = formatters.getPluralRules(locales, { type: el.pluralType }).select(value - (el.offset || 0));
|
|
3131
3143
|
opt = el.options[rule] || el.options.other;
|
|
3132
3144
|
}
|
|
3133
3145
|
if (!opt) {
|
|
3134
|
-
throw new InvalidValueError(
|
|
3135
|
-
|
|
3136
|
-
|
|
3146
|
+
throw new InvalidValueError(
|
|
3147
|
+
el.value,
|
|
3148
|
+
value,
|
|
3149
|
+
Object.keys(el.options),
|
|
3150
|
+
originalMessage
|
|
3151
|
+
);
|
|
3152
|
+
}
|
|
3153
|
+
result.push(
|
|
3154
|
+
...formatToParts(
|
|
3155
|
+
opt.value,
|
|
3156
|
+
locales,
|
|
3157
|
+
formatters,
|
|
3158
|
+
formats,
|
|
3159
|
+
values,
|
|
3160
|
+
value - (el.offset || 0)
|
|
3161
|
+
)
|
|
3162
|
+
);
|
|
3137
3163
|
continue;
|
|
3138
3164
|
}
|
|
3139
3165
|
}
|
|
3140
3166
|
return mergeLiteral(result);
|
|
3141
3167
|
}
|
|
3142
3168
|
|
|
3143
|
-
//
|
|
3169
|
+
// packages/intl-messageformat/src/core.ts
|
|
3144
3170
|
function mergeConfig(c1, c2) {
|
|
3145
3171
|
if (!c2) {
|
|
3146
3172
|
return c1;
|
|
3147
3173
|
}
|
|
3148
|
-
return
|
|
3149
|
-
all[k] =
|
|
3174
|
+
return __spreadValues(__spreadValues(__spreadValues({}, c1 || {}), c2 || {}), Object.keys(c1).reduce((all, k) => {
|
|
3175
|
+
all[k] = __spreadValues(__spreadValues({}, c1[k]), c2[k] || {});
|
|
3150
3176
|
return all;
|
|
3151
3177
|
}, {}));
|
|
3152
3178
|
}
|
|
@@ -3154,217 +3180,205 @@ var IntlMessageFormat = (() => {
|
|
|
3154
3180
|
if (!configs) {
|
|
3155
3181
|
return defaultConfig;
|
|
3156
3182
|
}
|
|
3157
|
-
return Object.keys(defaultConfig).reduce(
|
|
3158
|
-
all
|
|
3159
|
-
|
|
3160
|
-
|
|
3183
|
+
return Object.keys(defaultConfig).reduce(
|
|
3184
|
+
(all, k) => {
|
|
3185
|
+
all[k] = mergeConfig(defaultConfig[k], configs[k]);
|
|
3186
|
+
return all;
|
|
3187
|
+
},
|
|
3188
|
+
__spreadValues({}, defaultConfig)
|
|
3189
|
+
);
|
|
3161
3190
|
}
|
|
3162
3191
|
function createFastMemoizeCache(store) {
|
|
3163
3192
|
return {
|
|
3164
|
-
create
|
|
3193
|
+
create() {
|
|
3165
3194
|
return {
|
|
3166
|
-
get
|
|
3195
|
+
get(key) {
|
|
3167
3196
|
return store[key];
|
|
3168
3197
|
},
|
|
3169
|
-
set
|
|
3198
|
+
set(key, value) {
|
|
3170
3199
|
store[key] = value;
|
|
3171
3200
|
}
|
|
3172
3201
|
};
|
|
3173
3202
|
}
|
|
3174
3203
|
};
|
|
3175
3204
|
}
|
|
3176
|
-
function createDefaultFormatters(cache
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
pluralRules: {}
|
|
3182
|
-
};
|
|
3183
|
-
}
|
|
3205
|
+
function createDefaultFormatters(cache = {
|
|
3206
|
+
number: {},
|
|
3207
|
+
dateTime: {},
|
|
3208
|
+
pluralRules: {}
|
|
3209
|
+
}) {
|
|
3184
3210
|
return {
|
|
3185
|
-
getNumberFormat: memoize(
|
|
3186
|
-
var _a2;
|
|
3187
|
-
var args = [];
|
|
3188
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3189
|
-
args[_i] = arguments[_i];
|
|
3190
|
-
}
|
|
3191
|
-
return new ((_a2 = Intl.NumberFormat).bind.apply(_a2, __spreadArray([void 0], args, false)))();
|
|
3192
|
-
}, {
|
|
3211
|
+
getNumberFormat: memoize((...args) => new Intl.NumberFormat(...args), {
|
|
3193
3212
|
cache: createFastMemoizeCache(cache.number),
|
|
3194
3213
|
strategy: strategies.variadic
|
|
3195
3214
|
}),
|
|
3196
|
-
getDateTimeFormat: memoize(
|
|
3197
|
-
var _a2;
|
|
3198
|
-
var args = [];
|
|
3199
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3200
|
-
args[_i] = arguments[_i];
|
|
3201
|
-
}
|
|
3202
|
-
return new ((_a2 = Intl.DateTimeFormat).bind.apply(_a2, __spreadArray([void 0], args, false)))();
|
|
3203
|
-
}, {
|
|
3215
|
+
getDateTimeFormat: memoize((...args) => new Intl.DateTimeFormat(...args), {
|
|
3204
3216
|
cache: createFastMemoizeCache(cache.dateTime),
|
|
3205
3217
|
strategy: strategies.variadic
|
|
3206
3218
|
}),
|
|
3207
|
-
getPluralRules: memoize(
|
|
3208
|
-
var _a2;
|
|
3209
|
-
var args = [];
|
|
3210
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3211
|
-
args[_i] = arguments[_i];
|
|
3212
|
-
}
|
|
3213
|
-
return new ((_a2 = Intl.PluralRules).bind.apply(_a2, __spreadArray([void 0], args, false)))();
|
|
3214
|
-
}, {
|
|
3219
|
+
getPluralRules: memoize((...args) => new Intl.PluralRules(...args), {
|
|
3215
3220
|
cache: createFastMemoizeCache(cache.pluralRules),
|
|
3216
3221
|
strategy: strategies.variadic
|
|
3217
3222
|
})
|
|
3218
3223
|
};
|
|
3219
3224
|
}
|
|
3220
|
-
var
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3225
|
+
var _IntlMessageFormat = class _IntlMessageFormat {
|
|
3226
|
+
constructor(message, locales = _IntlMessageFormat.defaultLocale, overrideFormats, opts) {
|
|
3227
|
+
__publicField(this, "ast");
|
|
3228
|
+
__publicField(this, "locales");
|
|
3229
|
+
__publicField(this, "resolvedLocale");
|
|
3230
|
+
__publicField(this, "formatters");
|
|
3231
|
+
__publicField(this, "formats");
|
|
3232
|
+
__publicField(this, "message");
|
|
3233
|
+
__publicField(this, "formatterCache", {
|
|
3234
|
+
number: {},
|
|
3235
|
+
dateTime: {},
|
|
3236
|
+
pluralRules: {}
|
|
3237
|
+
});
|
|
3238
|
+
__publicField(this, "format", (values) => {
|
|
3239
|
+
const parts = this.formatToParts(values);
|
|
3240
|
+
if (parts.length === 1) {
|
|
3241
|
+
return parts[0].value;
|
|
3242
|
+
}
|
|
3243
|
+
const result = parts.reduce(
|
|
3244
|
+
(all, part) => {
|
|
3245
|
+
if (!all.length || part.type !== 0 /* literal */ || typeof all[all.length - 1] !== "string") {
|
|
3240
3246
|
all.push(part.value);
|
|
3241
3247
|
} else {
|
|
3242
3248
|
all[all.length - 1] += part.value;
|
|
3243
3249
|
}
|
|
3244
3250
|
return all;
|
|
3245
|
-
}, []);
|
|
3246
|
-
if (result.length <= 1) {
|
|
3247
|
-
return result[0] || "";
|
|
3248
|
-
}
|
|
3249
|
-
return result;
|
|
3250
|
-
};
|
|
3251
|
-
this.formatToParts = function(values) {
|
|
3252
|
-
return formatToParts(_this.ast, _this.locales, _this.formatters, _this.formats, values, void 0, _this.message);
|
|
3253
|
-
};
|
|
3254
|
-
this.resolvedOptions = function() {
|
|
3255
|
-
var _a3;
|
|
3256
|
-
return {
|
|
3257
|
-
locale: ((_a3 = _this.resolvedLocale) === null || _a3 === void 0 ? void 0 : _a3.toString()) || Intl.NumberFormat.supportedLocalesOf(_this.locales)[0]
|
|
3258
|
-
};
|
|
3259
|
-
};
|
|
3260
|
-
this.getAst = function() {
|
|
3261
|
-
return _this.ast;
|
|
3262
|
-
};
|
|
3263
|
-
this.locales = locales;
|
|
3264
|
-
this.resolvedLocale = IntlMessageFormat2.resolveLocale(locales);
|
|
3265
|
-
if (typeof message === "string") {
|
|
3266
|
-
this.message = message;
|
|
3267
|
-
if (!IntlMessageFormat2.__parse) {
|
|
3268
|
-
throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");
|
|
3269
|
-
}
|
|
3270
|
-
var _a2 = opts || {}, formatters = _a2.formatters, parseOpts = __rest(_a2, ["formatters"]);
|
|
3271
|
-
this.ast = IntlMessageFormat2.__parse(message, __assign(__assign({}, parseOpts), { locale: this.resolvedLocale }));
|
|
3272
|
-
} else {
|
|
3273
|
-
this.ast = message;
|
|
3274
|
-
}
|
|
3275
|
-
if (!Array.isArray(this.ast)) {
|
|
3276
|
-
throw new TypeError("A message must be provided as a String or AST.");
|
|
3277
|
-
}
|
|
3278
|
-
this.formats = mergeConfigs(IntlMessageFormat2.formats, overrideFormats);
|
|
3279
|
-
this.formatters = opts && opts.formatters || createDefaultFormatters(this.formatterCache);
|
|
3280
|
-
}
|
|
3281
|
-
Object.defineProperty(IntlMessageFormat2, "defaultLocale", {
|
|
3282
|
-
get: function() {
|
|
3283
|
-
if (!IntlMessageFormat2.memoizedDefaultLocale) {
|
|
3284
|
-
IntlMessageFormat2.memoizedDefaultLocale = new Intl.NumberFormat().resolvedOptions().locale;
|
|
3285
|
-
}
|
|
3286
|
-
return IntlMessageFormat2.memoizedDefaultLocale;
|
|
3287
|
-
},
|
|
3288
|
-
enumerable: false,
|
|
3289
|
-
configurable: true
|
|
3290
|
-
});
|
|
3291
|
-
IntlMessageFormat2.memoizedDefaultLocale = null;
|
|
3292
|
-
IntlMessageFormat2.resolveLocale = function(locales) {
|
|
3293
|
-
if (typeof Intl.Locale === "undefined") {
|
|
3294
|
-
return;
|
|
3295
|
-
}
|
|
3296
|
-
var supportedLocales = Intl.NumberFormat.supportedLocalesOf(locales);
|
|
3297
|
-
if (supportedLocales.length > 0) {
|
|
3298
|
-
return new Intl.Locale(supportedLocales[0]);
|
|
3299
|
-
}
|
|
3300
|
-
return new Intl.Locale(typeof locales === "string" ? locales : locales[0]);
|
|
3301
|
-
};
|
|
3302
|
-
IntlMessageFormat2.__parse = parse;
|
|
3303
|
-
IntlMessageFormat2.formats = {
|
|
3304
|
-
number: {
|
|
3305
|
-
integer: {
|
|
3306
|
-
maximumFractionDigits: 0
|
|
3307
|
-
},
|
|
3308
|
-
currency: {
|
|
3309
|
-
style: "currency"
|
|
3310
|
-
},
|
|
3311
|
-
percent: {
|
|
3312
|
-
style: "percent"
|
|
3313
|
-
}
|
|
3314
|
-
},
|
|
3315
|
-
date: {
|
|
3316
|
-
short: {
|
|
3317
|
-
month: "numeric",
|
|
3318
|
-
day: "numeric",
|
|
3319
|
-
year: "2-digit"
|
|
3320
|
-
},
|
|
3321
|
-
medium: {
|
|
3322
|
-
month: "short",
|
|
3323
|
-
day: "numeric",
|
|
3324
|
-
year: "numeric"
|
|
3325
|
-
},
|
|
3326
|
-
long: {
|
|
3327
|
-
month: "long",
|
|
3328
|
-
day: "numeric",
|
|
3329
|
-
year: "numeric"
|
|
3330
|
-
},
|
|
3331
|
-
full: {
|
|
3332
|
-
weekday: "long",
|
|
3333
|
-
month: "long",
|
|
3334
|
-
day: "numeric",
|
|
3335
|
-
year: "numeric"
|
|
3336
|
-
}
|
|
3337
|
-
},
|
|
3338
|
-
time: {
|
|
3339
|
-
short: {
|
|
3340
|
-
hour: "numeric",
|
|
3341
|
-
minute: "numeric"
|
|
3342
|
-
},
|
|
3343
|
-
medium: {
|
|
3344
|
-
hour: "numeric",
|
|
3345
|
-
minute: "numeric",
|
|
3346
|
-
second: "numeric"
|
|
3347
3251
|
},
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
timeZoneName: "short"
|
|
3353
|
-
},
|
|
3354
|
-
full: {
|
|
3355
|
-
hour: "numeric",
|
|
3356
|
-
minute: "numeric",
|
|
3357
|
-
second: "numeric",
|
|
3358
|
-
timeZoneName: "short"
|
|
3359
|
-
}
|
|
3252
|
+
[]
|
|
3253
|
+
);
|
|
3254
|
+
if (result.length <= 1) {
|
|
3255
|
+
return result[0] || "";
|
|
3360
3256
|
}
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3257
|
+
return result;
|
|
3258
|
+
});
|
|
3259
|
+
__publicField(this, "formatToParts", (values) => formatToParts(
|
|
3260
|
+
this.ast,
|
|
3261
|
+
this.locales,
|
|
3262
|
+
this.formatters,
|
|
3263
|
+
this.formats,
|
|
3264
|
+
values,
|
|
3265
|
+
void 0,
|
|
3266
|
+
this.message
|
|
3267
|
+
));
|
|
3268
|
+
__publicField(this, "resolvedOptions", () => {
|
|
3269
|
+
var _a2;
|
|
3270
|
+
return {
|
|
3271
|
+
locale: ((_a2 = this.resolvedLocale) == null ? void 0 : _a2.toString()) || Intl.NumberFormat.supportedLocalesOf(this.locales)[0]
|
|
3272
|
+
};
|
|
3273
|
+
});
|
|
3274
|
+
__publicField(this, "getAst", () => this.ast);
|
|
3275
|
+
this.locales = locales;
|
|
3276
|
+
this.resolvedLocale = _IntlMessageFormat.resolveLocale(locales);
|
|
3277
|
+
if (typeof message === "string") {
|
|
3278
|
+
this.message = message;
|
|
3279
|
+
if (!_IntlMessageFormat.__parse) {
|
|
3280
|
+
throw new TypeError(
|
|
3281
|
+
"IntlMessageFormat.__parse must be set to process `message` of type `string`"
|
|
3282
|
+
);
|
|
3283
|
+
}
|
|
3284
|
+
const _a2 = opts || {}, { formatters } = _a2, parseOpts = __objRest(_a2, ["formatters"]);
|
|
3285
|
+
this.ast = _IntlMessageFormat.__parse(message, __spreadProps(__spreadValues({}, parseOpts), {
|
|
3286
|
+
locale: this.resolvedLocale
|
|
3287
|
+
}));
|
|
3288
|
+
} else {
|
|
3289
|
+
this.ast = message;
|
|
3290
|
+
}
|
|
3291
|
+
if (!Array.isArray(this.ast)) {
|
|
3292
|
+
throw new TypeError("A message must be provided as a String or AST.");
|
|
3293
|
+
}
|
|
3294
|
+
this.formats = mergeConfigs(_IntlMessageFormat.formats, overrideFormats);
|
|
3295
|
+
this.formatters = opts && opts.formatters || createDefaultFormatters(this.formatterCache);
|
|
3296
|
+
}
|
|
3297
|
+
static get defaultLocale() {
|
|
3298
|
+
if (!_IntlMessageFormat.memoizedDefaultLocale) {
|
|
3299
|
+
_IntlMessageFormat.memoizedDefaultLocale = new Intl.NumberFormat().resolvedOptions().locale;
|
|
3300
|
+
}
|
|
3301
|
+
return _IntlMessageFormat.memoizedDefaultLocale;
|
|
3302
|
+
}
|
|
3303
|
+
};
|
|
3304
|
+
__publicField(_IntlMessageFormat, "memoizedDefaultLocale", null);
|
|
3305
|
+
__publicField(_IntlMessageFormat, "resolveLocale", (locales) => {
|
|
3306
|
+
if (typeof Intl.Locale === "undefined") {
|
|
3307
|
+
return;
|
|
3308
|
+
}
|
|
3309
|
+
const supportedLocales = Intl.NumberFormat.supportedLocalesOf(locales);
|
|
3310
|
+
if (supportedLocales.length > 0) {
|
|
3311
|
+
return new Intl.Locale(supportedLocales[0]);
|
|
3312
|
+
}
|
|
3313
|
+
return new Intl.Locale(typeof locales === "string" ? locales : locales[0]);
|
|
3314
|
+
});
|
|
3315
|
+
__publicField(_IntlMessageFormat, "__parse", parse);
|
|
3316
|
+
// Default format options used as the prototype of the `formats` provided to the
|
|
3317
|
+
// constructor. These are used when constructing the internal Intl.NumberFormat
|
|
3318
|
+
// and Intl.DateTimeFormat instances.
|
|
3319
|
+
__publicField(_IntlMessageFormat, "formats", {
|
|
3320
|
+
number: {
|
|
3321
|
+
integer: {
|
|
3322
|
+
maximumFractionDigits: 0
|
|
3323
|
+
},
|
|
3324
|
+
currency: {
|
|
3325
|
+
style: "currency"
|
|
3326
|
+
},
|
|
3327
|
+
percent: {
|
|
3328
|
+
style: "percent"
|
|
3329
|
+
}
|
|
3330
|
+
},
|
|
3331
|
+
date: {
|
|
3332
|
+
short: {
|
|
3333
|
+
month: "numeric",
|
|
3334
|
+
day: "numeric",
|
|
3335
|
+
year: "2-digit"
|
|
3336
|
+
},
|
|
3337
|
+
medium: {
|
|
3338
|
+
month: "short",
|
|
3339
|
+
day: "numeric",
|
|
3340
|
+
year: "numeric"
|
|
3341
|
+
},
|
|
3342
|
+
long: {
|
|
3343
|
+
month: "long",
|
|
3344
|
+
day: "numeric",
|
|
3345
|
+
year: "numeric"
|
|
3346
|
+
},
|
|
3347
|
+
full: {
|
|
3348
|
+
weekday: "long",
|
|
3349
|
+
month: "long",
|
|
3350
|
+
day: "numeric",
|
|
3351
|
+
year: "numeric"
|
|
3352
|
+
}
|
|
3353
|
+
},
|
|
3354
|
+
time: {
|
|
3355
|
+
short: {
|
|
3356
|
+
hour: "numeric",
|
|
3357
|
+
minute: "numeric"
|
|
3358
|
+
},
|
|
3359
|
+
medium: {
|
|
3360
|
+
hour: "numeric",
|
|
3361
|
+
minute: "numeric",
|
|
3362
|
+
second: "numeric"
|
|
3363
|
+
},
|
|
3364
|
+
long: {
|
|
3365
|
+
hour: "numeric",
|
|
3366
|
+
minute: "numeric",
|
|
3367
|
+
second: "numeric",
|
|
3368
|
+
timeZoneName: "short"
|
|
3369
|
+
},
|
|
3370
|
+
full: {
|
|
3371
|
+
hour: "numeric",
|
|
3372
|
+
minute: "numeric",
|
|
3373
|
+
second: "numeric",
|
|
3374
|
+
timeZoneName: "short"
|
|
3375
|
+
}
|
|
3376
|
+
}
|
|
3377
|
+
});
|
|
3378
|
+
var IntlMessageFormat = _IntlMessageFormat;
|
|
3365
3379
|
|
|
3366
|
-
//
|
|
3367
|
-
var
|
|
3368
|
-
return __toCommonJS(
|
|
3380
|
+
// packages/intl-messageformat/index.ts
|
|
3381
|
+
var intl_messageformat_default = IntlMessageFormat;
|
|
3382
|
+
return __toCommonJS(intl_messageformat_exports);
|
|
3369
3383
|
})();
|
|
3370
3384
|
//# sourceMappingURL=intl-messageformat.iife.js.map
|