1 | var ReactIntl = (function() {
|
2 | var __create = Object.create;
|
3 | var __defProp = Object.defineProperty;
|
4 | var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5 | var __getOwnPropNames = Object.getOwnPropertyNames;
|
6 | var __getProtoOf = Object.getPrototypeOf;
|
7 | var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8 | var __markAsModule = function(target) {
|
9 | return __defProp(target, "__esModule", { value: true });
|
10 | };
|
11 | var __require = typeof require !== "undefined" ? require : function(x) {
|
12 | throw new Error('Dynamic require of "' + x + '" is not supported');
|
13 | };
|
14 | var __commonJS = function(cb, mod) {
|
15 | return function __require2() {
|
16 | return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
17 | };
|
18 | };
|
19 | var __export = function(target, all) {
|
20 | __markAsModule(target);
|
21 | for (var name in all)
|
22 | __defProp(target, name, { get: all[name], enumerable: true });
|
23 | };
|
24 | var __reExport = function(target, module, desc) {
|
25 | if (module && typeof module === "object" || typeof module === "function")
|
26 | for (var keys = __getOwnPropNames(module), i = 0, n = keys.length, key; i < n; i++) {
|
27 | key = keys[i];
|
28 | if (!__hasOwnProp.call(target, key) && key !== "default")
|
29 | __defProp(target, key, { get: function(k) {
|
30 | return module[k];
|
31 | }.bind(null, key), enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable });
|
32 | }
|
33 | return target;
|
34 | };
|
35 | var __toModule = function(module) {
|
36 | return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: function() {
|
37 | return module.default;
|
38 | }, enumerable: true } : { value: module, enumerable: true })), module);
|
39 | };
|
40 |
|
41 |
|
42 | var require_react_is_development = __commonJS({
|
43 | "node_modules/hoist-non-react-statics/node_modules/react-is/cjs/react-is.development.js": function(exports) {
|
44 | "use strict";
|
45 | if (true) {
|
46 | (function() {
|
47 | "use strict";
|
48 | var hasSymbol = typeof Symbol === "function" && Symbol.for;
|
49 | var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 60103;
|
50 | var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 60106;
|
51 | var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 60107;
|
52 | var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for("react.strict_mode") : 60108;
|
53 | var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 60114;
|
54 | var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 60109;
|
55 | var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 60110;
|
56 | var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for("react.async_mode") : 60111;
|
57 | var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for("react.concurrent_mode") : 60111;
|
58 | var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112;
|
59 | var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113;
|
60 | var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for("react.suspense_list") : 60120;
|
61 | var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115;
|
62 | var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116;
|
63 | var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 60121;
|
64 | var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for("react.fundamental") : 60117;
|
65 | var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for("react.responder") : 60118;
|
66 | var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for("react.scope") : 60119;
|
67 | function isValidElementType(type) {
|
68 | return typeof type === "string" || typeof type === "function" || type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === "object" && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
|
69 | }
|
70 | function typeOf(object) {
|
71 | if (typeof object === "object" && object !== null) {
|
72 | var $$typeof = object.$$typeof;
|
73 | switch ($$typeof) {
|
74 | case REACT_ELEMENT_TYPE:
|
75 | var type = object.type;
|
76 | switch (type) {
|
77 | case REACT_ASYNC_MODE_TYPE:
|
78 | case REACT_CONCURRENT_MODE_TYPE:
|
79 | case REACT_FRAGMENT_TYPE:
|
80 | case REACT_PROFILER_TYPE:
|
81 | case REACT_STRICT_MODE_TYPE:
|
82 | case REACT_SUSPENSE_TYPE:
|
83 | return type;
|
84 | default:
|
85 | var $$typeofType = type && type.$$typeof;
|
86 | switch ($$typeofType) {
|
87 | case REACT_CONTEXT_TYPE:
|
88 | case REACT_FORWARD_REF_TYPE:
|
89 | case REACT_LAZY_TYPE:
|
90 | case REACT_MEMO_TYPE:
|
91 | case REACT_PROVIDER_TYPE:
|
92 | return $$typeofType;
|
93 | default:
|
94 | return $$typeof;
|
95 | }
|
96 | }
|
97 | case REACT_PORTAL_TYPE:
|
98 | return $$typeof;
|
99 | }
|
100 | }
|
101 | return void 0;
|
102 | }
|
103 | var AsyncMode = REACT_ASYNC_MODE_TYPE;
|
104 | var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
105 | var ContextConsumer = REACT_CONTEXT_TYPE;
|
106 | var ContextProvider = REACT_PROVIDER_TYPE;
|
107 | var Element = REACT_ELEMENT_TYPE;
|
108 | var ForwardRef = REACT_FORWARD_REF_TYPE;
|
109 | var Fragment6 = REACT_FRAGMENT_TYPE;
|
110 | var Lazy = REACT_LAZY_TYPE;
|
111 | var Memo = REACT_MEMO_TYPE;
|
112 | var Portal = REACT_PORTAL_TYPE;
|
113 | var Profiler = REACT_PROFILER_TYPE;
|
114 | var StrictMode = REACT_STRICT_MODE_TYPE;
|
115 | var Suspense = REACT_SUSPENSE_TYPE;
|
116 | var hasWarnedAboutDeprecatedIsAsyncMode = false;
|
117 | function isAsyncMode(object) {
|
118 | {
|
119 | if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
120 | hasWarnedAboutDeprecatedIsAsyncMode = true;
|
121 | console["warn"]("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.");
|
122 | }
|
123 | }
|
124 | return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
|
125 | }
|
126 | function isConcurrentMode(object) {
|
127 | return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
|
128 | }
|
129 | function isContextConsumer(object) {
|
130 | return typeOf(object) === REACT_CONTEXT_TYPE;
|
131 | }
|
132 | function isContextProvider(object) {
|
133 | return typeOf(object) === REACT_PROVIDER_TYPE;
|
134 | }
|
135 | function isElement(object) {
|
136 | return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
137 | }
|
138 | function isForwardRef(object) {
|
139 | return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
140 | }
|
141 | function isFragment(object) {
|
142 | return typeOf(object) === REACT_FRAGMENT_TYPE;
|
143 | }
|
144 | function isLazy(object) {
|
145 | return typeOf(object) === REACT_LAZY_TYPE;
|
146 | }
|
147 | function isMemo(object) {
|
148 | return typeOf(object) === REACT_MEMO_TYPE;
|
149 | }
|
150 | function isPortal(object) {
|
151 | return typeOf(object) === REACT_PORTAL_TYPE;
|
152 | }
|
153 | function isProfiler(object) {
|
154 | return typeOf(object) === REACT_PROFILER_TYPE;
|
155 | }
|
156 | function isStrictMode(object) {
|
157 | return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
158 | }
|
159 | function isSuspense(object) {
|
160 | return typeOf(object) === REACT_SUSPENSE_TYPE;
|
161 | }
|
162 | exports.AsyncMode = AsyncMode;
|
163 | exports.ConcurrentMode = ConcurrentMode;
|
164 | exports.ContextConsumer = ContextConsumer;
|
165 | exports.ContextProvider = ContextProvider;
|
166 | exports.Element = Element;
|
167 | exports.ForwardRef = ForwardRef;
|
168 | exports.Fragment = Fragment6;
|
169 | exports.Lazy = Lazy;
|
170 | exports.Memo = Memo;
|
171 | exports.Portal = Portal;
|
172 | exports.Profiler = Profiler;
|
173 | exports.StrictMode = StrictMode;
|
174 | exports.Suspense = Suspense;
|
175 | exports.isAsyncMode = isAsyncMode;
|
176 | exports.isConcurrentMode = isConcurrentMode;
|
177 | exports.isContextConsumer = isContextConsumer;
|
178 | exports.isContextProvider = isContextProvider;
|
179 | exports.isElement = isElement;
|
180 | exports.isForwardRef = isForwardRef;
|
181 | exports.isFragment = isFragment;
|
182 | exports.isLazy = isLazy;
|
183 | exports.isMemo = isMemo;
|
184 | exports.isPortal = isPortal;
|
185 | exports.isProfiler = isProfiler;
|
186 | exports.isStrictMode = isStrictMode;
|
187 | exports.isSuspense = isSuspense;
|
188 | exports.isValidElementType = isValidElementType;
|
189 | exports.typeOf = typeOf;
|
190 | })();
|
191 | }
|
192 | }
|
193 | });
|
194 |
|
195 |
|
196 | var require_react_is = __commonJS({
|
197 | "node_modules/hoist-non-react-statics/node_modules/react-is/index.js": function(exports, module) {
|
198 | "use strict";
|
199 | if (false) {
|
200 | module.exports = null;
|
201 | } else {
|
202 | module.exports = require_react_is_development();
|
203 | }
|
204 | }
|
205 | });
|
206 |
|
207 |
|
208 | var require_hoist_non_react_statics_cjs = __commonJS({
|
209 | "node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js": function(exports, module) {
|
210 | "use strict";
|
211 | var reactIs = require_react_is();
|
212 | var REACT_STATICS = {
|
213 | childContextTypes: true,
|
214 | contextType: true,
|
215 | contextTypes: true,
|
216 | defaultProps: true,
|
217 | displayName: true,
|
218 | getDefaultProps: true,
|
219 | getDerivedStateFromError: true,
|
220 | getDerivedStateFromProps: true,
|
221 | mixins: true,
|
222 | propTypes: true,
|
223 | type: true
|
224 | };
|
225 | var KNOWN_STATICS = {
|
226 | name: true,
|
227 | length: true,
|
228 | prototype: true,
|
229 | caller: true,
|
230 | callee: true,
|
231 | arguments: true,
|
232 | arity: true
|
233 | };
|
234 | var FORWARD_REF_STATICS = {
|
235 | "$$typeof": true,
|
236 | render: true,
|
237 | defaultProps: true,
|
238 | displayName: true,
|
239 | propTypes: true
|
240 | };
|
241 | var MEMO_STATICS = {
|
242 | "$$typeof": true,
|
243 | compare: true,
|
244 | defaultProps: true,
|
245 | displayName: true,
|
246 | propTypes: true,
|
247 | type: true
|
248 | };
|
249 | var TYPE_STATICS = {};
|
250 | TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS;
|
251 | TYPE_STATICS[reactIs.Memo] = MEMO_STATICS;
|
252 | function getStatics(component) {
|
253 | if (reactIs.isMemo(component)) {
|
254 | return MEMO_STATICS;
|
255 | }
|
256 | return TYPE_STATICS[component["$$typeof"]] || REACT_STATICS;
|
257 | }
|
258 | var defineProperty2 = Object.defineProperty;
|
259 | var getOwnPropertyNames = Object.getOwnPropertyNames;
|
260 | var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
261 | var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
262 | var getPrototypeOf = Object.getPrototypeOf;
|
263 | var objectPrototype = Object.prototype;
|
264 | function hoistNonReactStatics2(targetComponent, sourceComponent, blacklist) {
|
265 | if (typeof sourceComponent !== "string") {
|
266 | if (objectPrototype) {
|
267 | var inheritedComponent = getPrototypeOf(sourceComponent);
|
268 | if (inheritedComponent && inheritedComponent !== objectPrototype) {
|
269 | hoistNonReactStatics2(targetComponent, inheritedComponent, blacklist);
|
270 | }
|
271 | }
|
272 | var keys = getOwnPropertyNames(sourceComponent);
|
273 | if (getOwnPropertySymbols) {
|
274 | keys = keys.concat(getOwnPropertySymbols(sourceComponent));
|
275 | }
|
276 | var targetStatics = getStatics(targetComponent);
|
277 | var sourceStatics = getStatics(sourceComponent);
|
278 | for (var i = 0; i < keys.length; ++i) {
|
279 | var key = keys[i];
|
280 | if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {
|
281 | var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
|
282 | try {
|
283 | defineProperty2(targetComponent, key, descriptor);
|
284 | } catch (e) {
|
285 | }
|
286 | }
|
287 | }
|
288 | }
|
289 | return targetComponent;
|
290 | }
|
291 | module.exports = hoistNonReactStatics2;
|
292 | }
|
293 | });
|
294 |
|
295 |
|
296 | var require_utils = __commonJS({
|
297 | "bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/utils.js": function(exports) {
|
298 | "use strict";
|
299 | Object.defineProperty(exports, "__esModule", { value: true });
|
300 | exports.invariant = exports.UNICODE_EXTENSION_SEQUENCE_REGEX = void 0;
|
301 | exports.UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
|
302 | function invariant2(condition, message, Err) {
|
303 | if (Err === void 0) {
|
304 | Err = Error;
|
305 | }
|
306 | if (!condition) {
|
307 | throw new Err(message);
|
308 | }
|
309 | }
|
310 | exports.invariant = invariant2;
|
311 | }
|
312 | });
|
313 |
|
314 |
|
315 | var require_BestAvailableLocale = __commonJS({
|
316 | "bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/BestAvailableLocale.js": function(exports) {
|
317 | "use strict";
|
318 | Object.defineProperty(exports, "__esModule", { value: true });
|
319 | exports.BestAvailableLocale = void 0;
|
320 | function BestAvailableLocale(availableLocales, locale) {
|
321 | var candidate = locale;
|
322 | while (true) {
|
323 | if (availableLocales.has(candidate)) {
|
324 | return candidate;
|
325 | }
|
326 | var pos = candidate.lastIndexOf("-");
|
327 | if (!~pos) {
|
328 | return void 0;
|
329 | }
|
330 | if (pos >= 2 && candidate[pos - 2] === "-") {
|
331 | pos -= 2;
|
332 | }
|
333 | candidate = candidate.slice(0, pos);
|
334 | }
|
335 | }
|
336 | exports.BestAvailableLocale = BestAvailableLocale;
|
337 | }
|
338 | });
|
339 |
|
340 |
|
341 | var require_LookupMatcher = __commonJS({
|
342 | "bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/LookupMatcher.js": function(exports) {
|
343 | "use strict";
|
344 | Object.defineProperty(exports, "__esModule", { value: true });
|
345 | exports.LookupMatcher = void 0;
|
346 | var utils_1 = require_utils();
|
347 | var BestAvailableLocale_1 = require_BestAvailableLocale();
|
348 | function LookupMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
349 | var result = { locale: "" };
|
350 | for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
|
351 | var locale = requestedLocales_1[_i];
|
352 | var noExtensionLocale = locale.replace(utils_1.UNICODE_EXTENSION_SEQUENCE_REGEX, "");
|
353 | var availableLocale = BestAvailableLocale_1.BestAvailableLocale(availableLocales, noExtensionLocale);
|
354 | if (availableLocale) {
|
355 | result.locale = availableLocale;
|
356 | if (locale !== noExtensionLocale) {
|
357 | result.extension = locale.slice(noExtensionLocale.length + 1, locale.length);
|
358 | }
|
359 | return result;
|
360 | }
|
361 | }
|
362 | result.locale = getDefaultLocale();
|
363 | return result;
|
364 | }
|
365 | exports.LookupMatcher = LookupMatcher;
|
366 | }
|
367 | });
|
368 |
|
369 |
|
370 | var require_BestFitMatcher = __commonJS({
|
371 | "bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/BestFitMatcher.js": function(exports) {
|
372 | "use strict";
|
373 | Object.defineProperty(exports, "__esModule", { value: true });
|
374 | exports.BestFitMatcher = void 0;
|
375 | var BestAvailableLocale_1 = require_BestAvailableLocale();
|
376 | var utils_1 = require_utils();
|
377 | function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
378 | var minimizedAvailableLocaleMap = Array.from(availableLocales).reduce(function(all, l2) {
|
379 | all[l2] = l2;
|
380 | return all;
|
381 | }, {});
|
382 | var minimizedAvailableLocales = new Set();
|
383 | availableLocales.forEach(function(locale2) {
|
384 | var minimizedLocale = new Intl.Locale(locale2).minimize().toString();
|
385 | minimizedAvailableLocaleMap[minimizedLocale] = locale2;
|
386 | minimizedAvailableLocales.add(minimizedLocale);
|
387 | });
|
388 | var foundLocale;
|
389 | for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
|
390 | var l = requestedLocales_1[_i];
|
391 | if (foundLocale) {
|
392 | break;
|
393 | }
|
394 | var noExtensionLocale = l.replace(utils_1.UNICODE_EXTENSION_SEQUENCE_REGEX, "");
|
395 | if (availableLocales.has(noExtensionLocale)) {
|
396 | foundLocale = noExtensionLocale;
|
397 | break;
|
398 | }
|
399 | if (minimizedAvailableLocales.has(noExtensionLocale)) {
|
400 | foundLocale = noExtensionLocale;
|
401 | break;
|
402 | }
|
403 | var locale = new Intl.Locale(noExtensionLocale);
|
404 | var maximizedRequestedLocale = locale.maximize().toString();
|
405 | var minimizedRequestedLocale = locale.minimize().toString();
|
406 | if (minimizedAvailableLocales.has(minimizedRequestedLocale)) {
|
407 | foundLocale = minimizedRequestedLocale;
|
408 | break;
|
409 | }
|
410 | foundLocale = BestAvailableLocale_1.BestAvailableLocale(minimizedAvailableLocales, maximizedRequestedLocale);
|
411 | }
|
412 | return {
|
413 | locale: foundLocale && minimizedAvailableLocaleMap[foundLocale] || getDefaultLocale()
|
414 | };
|
415 | }
|
416 | exports.BestFitMatcher = BestFitMatcher;
|
417 | }
|
418 | });
|
419 |
|
420 |
|
421 | var require_UnicodeExtensionValue = __commonJS({
|
422 | "bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/UnicodeExtensionValue.js": function(exports) {
|
423 | "use strict";
|
424 | Object.defineProperty(exports, "__esModule", { value: true });
|
425 | exports.UnicodeExtensionValue = void 0;
|
426 | var utils_1 = require_utils();
|
427 | function UnicodeExtensionValue(extension, key) {
|
428 | utils_1.invariant(key.length === 2, "key must have 2 elements");
|
429 | var size = extension.length;
|
430 | var searchValue = "-" + key + "-";
|
431 | var pos = extension.indexOf(searchValue);
|
432 | if (pos !== -1) {
|
433 | var start = pos + 4;
|
434 | var end = start;
|
435 | var k = start;
|
436 | var done = false;
|
437 | while (!done) {
|
438 | var e = extension.indexOf("-", k);
|
439 | var len = void 0;
|
440 | if (e === -1) {
|
441 | len = size - k;
|
442 | } else {
|
443 | len = e - k;
|
444 | }
|
445 | if (len === 2) {
|
446 | done = true;
|
447 | } else if (e === -1) {
|
448 | end = size;
|
449 | done = true;
|
450 | } else {
|
451 | end = e;
|
452 | k = e + 1;
|
453 | }
|
454 | }
|
455 | return extension.slice(start, end);
|
456 | }
|
457 | searchValue = "-" + key;
|
458 | pos = extension.indexOf(searchValue);
|
459 | if (pos !== -1 && pos + 3 === size) {
|
460 | return "";
|
461 | }
|
462 | return void 0;
|
463 | }
|
464 | exports.UnicodeExtensionValue = UnicodeExtensionValue;
|
465 | }
|
466 | });
|
467 |
|
468 |
|
469 | var require_ResolveLocale = __commonJS({
|
470 | "bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/ResolveLocale.js": function(exports) {
|
471 | "use strict";
|
472 | Object.defineProperty(exports, "__esModule", { value: true });
|
473 | exports.ResolveLocale = void 0;
|
474 | var LookupMatcher_1 = require_LookupMatcher();
|
475 | var BestFitMatcher_1 = require_BestFitMatcher();
|
476 | var utils_1 = require_utils();
|
477 | var UnicodeExtensionValue_1 = require_UnicodeExtensionValue();
|
478 | function ResolveLocale2(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData, getDefaultLocale) {
|
479 | var matcher = options.localeMatcher;
|
480 | var r;
|
481 | if (matcher === "lookup") {
|
482 | r = LookupMatcher_1.LookupMatcher(availableLocales, requestedLocales, getDefaultLocale);
|
483 | } else {
|
484 | r = BestFitMatcher_1.BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale);
|
485 | }
|
486 | var foundLocale = r.locale;
|
487 | var result = { locale: "", dataLocale: foundLocale };
|
488 | var supportedExtension = "-u";
|
489 | for (var _i = 0, relevantExtensionKeys_1 = relevantExtensionKeys; _i < relevantExtensionKeys_1.length; _i++) {
|
490 | var key = relevantExtensionKeys_1[_i];
|
491 | utils_1.invariant(foundLocale in localeData, "Missing locale data for " + foundLocale);
|
492 | var foundLocaleData = localeData[foundLocale];
|
493 | utils_1.invariant(typeof foundLocaleData === "object" && foundLocaleData !== null, "locale data " + key + " must be an object");
|
494 | var keyLocaleData = foundLocaleData[key];
|
495 | utils_1.invariant(Array.isArray(keyLocaleData), "keyLocaleData for " + key + " must be an array");
|
496 | var value = keyLocaleData[0];
|
497 | utils_1.invariant(typeof value === "string" || value === null, "value must be string or null but got " + typeof value + " in key " + key);
|
498 | var supportedExtensionAddition = "";
|
499 | if (r.extension) {
|
500 | var requestedValue = UnicodeExtensionValue_1.UnicodeExtensionValue(r.extension, key);
|
501 | if (requestedValue !== void 0) {
|
502 | if (requestedValue !== "") {
|
503 | if (~keyLocaleData.indexOf(requestedValue)) {
|
504 | value = requestedValue;
|
505 | supportedExtensionAddition = "-" + key + "-" + value;
|
506 | }
|
507 | } else if (~requestedValue.indexOf("true")) {
|
508 | value = "true";
|
509 | supportedExtensionAddition = "-" + key;
|
510 | }
|
511 | }
|
512 | }
|
513 | if (key in options) {
|
514 | var optionsValue = options[key];
|
515 | utils_1.invariant(typeof optionsValue === "string" || typeof optionsValue === "undefined" || optionsValue === null, "optionsValue must be String, Undefined or Null");
|
516 | if (~keyLocaleData.indexOf(optionsValue)) {
|
517 | if (optionsValue !== value) {
|
518 | value = optionsValue;
|
519 | supportedExtensionAddition = "";
|
520 | }
|
521 | }
|
522 | }
|
523 | result[key] = value;
|
524 | supportedExtension += supportedExtensionAddition;
|
525 | }
|
526 | if (supportedExtension.length > 2) {
|
527 | var privateIndex = foundLocale.indexOf("-x-");
|
528 | if (privateIndex === -1) {
|
529 | foundLocale = foundLocale + supportedExtension;
|
530 | } else {
|
531 | var preExtension = foundLocale.slice(0, privateIndex);
|
532 | var postExtension = foundLocale.slice(privateIndex, foundLocale.length);
|
533 | foundLocale = preExtension + supportedExtension + postExtension;
|
534 | }
|
535 | foundLocale = Intl.getCanonicalLocales(foundLocale)[0];
|
536 | }
|
537 | result.locale = foundLocale;
|
538 | return result;
|
539 | }
|
540 | exports.ResolveLocale = ResolveLocale2;
|
541 | }
|
542 | });
|
543 |
|
544 |
|
545 | var require_LookupSupportedLocales = __commonJS({
|
546 | "bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/abstract/LookupSupportedLocales.js": function(exports) {
|
547 | "use strict";
|
548 | Object.defineProperty(exports, "__esModule", { value: true });
|
549 | exports.LookupSupportedLocales = void 0;
|
550 | var utils_1 = require_utils();
|
551 | var BestAvailableLocale_1 = require_BestAvailableLocale();
|
552 | function LookupSupportedLocales2(availableLocales, requestedLocales) {
|
553 | var subset = [];
|
554 | for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
|
555 | var locale = requestedLocales_1[_i];
|
556 | var noExtensionLocale = locale.replace(utils_1.UNICODE_EXTENSION_SEQUENCE_REGEX, "");
|
557 | var availableLocale = BestAvailableLocale_1.BestAvailableLocale(availableLocales, noExtensionLocale);
|
558 | if (availableLocale) {
|
559 | subset.push(availableLocale);
|
560 | }
|
561 | }
|
562 | return subset;
|
563 | }
|
564 | exports.LookupSupportedLocales = LookupSupportedLocales2;
|
565 | }
|
566 | });
|
567 |
|
568 |
|
569 | var require_intl_localematcher = __commonJS({
|
570 | "bazel-out/darwin-fastbuild/bin/packages/intl-localematcher/index.js": function(exports) {
|
571 | "use strict";
|
572 | Object.defineProperty(exports, "__esModule", { value: true });
|
573 | exports.ResolveLocale = exports.LookupSupportedLocales = exports.match = void 0;
|
574 | var ResolveLocale_1 = require_ResolveLocale();
|
575 | function match(requestedLocales, availableLocales, defaultLocale, opts) {
|
576 | var locales = availableLocales.reduce(function(all, l) {
|
577 | all.add(l);
|
578 | return all;
|
579 | }, new Set());
|
580 | return ResolveLocale_1.ResolveLocale(locales, requestedLocales, {
|
581 | localeMatcher: (opts === null || opts === void 0 ? void 0 : opts.algorithm) || "best fit"
|
582 | }, [], {}, function() {
|
583 | return defaultLocale;
|
584 | }).locale;
|
585 | }
|
586 | exports.match = match;
|
587 | var LookupSupportedLocales_1 = require_LookupSupportedLocales();
|
588 | Object.defineProperty(exports, "LookupSupportedLocales", { enumerable: true, get: function() {
|
589 | return LookupSupportedLocales_1.LookupSupportedLocales;
|
590 | } });
|
591 | var ResolveLocale_2 = require_ResolveLocale();
|
592 | Object.defineProperty(exports, "ResolveLocale", { enumerable: true, get: function() {
|
593 | return ResolveLocale_2.ResolveLocale;
|
594 | } });
|
595 | }
|
596 | });
|
597 |
|
598 |
|
599 | var lib_exports = {};
|
600 | __export(lib_exports, {
|
601 | FormattedDate: function() {
|
602 | return FormattedDate;
|
603 | },
|
604 | FormattedDateParts: function() {
|
605 | return FormattedDateParts;
|
606 | },
|
607 | FormattedDateTimeRange: function() {
|
608 | return dateTimeRange_default;
|
609 | },
|
610 | FormattedDisplayName: function() {
|
611 | return FormattedDisplayName;
|
612 | },
|
613 | FormattedList: function() {
|
614 | return FormattedList;
|
615 | },
|
616 | FormattedListParts: function() {
|
617 | return FormattedListParts;
|
618 | },
|
619 | FormattedMessage: function() {
|
620 | return message_default;
|
621 | },
|
622 | FormattedNumber: function() {
|
623 | return FormattedNumber;
|
624 | },
|
625 | FormattedNumberParts: function() {
|
626 | return FormattedNumberParts;
|
627 | },
|
628 | FormattedPlural: function() {
|
629 | return plural_default;
|
630 | },
|
631 | FormattedRelativeTime: function() {
|
632 | return relative_default;
|
633 | },
|
634 | FormattedTime: function() {
|
635 | return FormattedTime;
|
636 | },
|
637 | FormattedTimeParts: function() {
|
638 | return FormattedTimeParts;
|
639 | },
|
640 | IntlContext: function() {
|
641 | return Context;
|
642 | },
|
643 | IntlProvider: function() {
|
644 | return provider_default;
|
645 | },
|
646 | InvalidConfigError: function() {
|
647 | return InvalidConfigError;
|
648 | },
|
649 | MessageFormatError: function() {
|
650 | return MessageFormatError;
|
651 | },
|
652 | MissingDataError: function() {
|
653 | return MissingDataError;
|
654 | },
|
655 | MissingTranslationError: function() {
|
656 | return MissingTranslationError;
|
657 | },
|
658 | RawIntlProvider: function() {
|
659 | return Provider;
|
660 | },
|
661 | ReactIntlError: function() {
|
662 | return IntlError;
|
663 | },
|
664 | ReactIntlErrorCode: function() {
|
665 | return IntlErrorCode;
|
666 | },
|
667 | UnsupportedFormatterError: function() {
|
668 | return UnsupportedFormatterError;
|
669 | },
|
670 | createIntl: function() {
|
671 | return createIntl2;
|
672 | },
|
673 | createIntlCache: function() {
|
674 | return createIntlCache;
|
675 | },
|
676 | defineMessage: function() {
|
677 | return defineMessage;
|
678 | },
|
679 | defineMessages: function() {
|
680 | return defineMessages;
|
681 | },
|
682 | injectIntl: function() {
|
683 | return injectIntl;
|
684 | },
|
685 | useIntl: function() {
|
686 | return useIntl;
|
687 | }
|
688 | });
|
689 |
|
690 |
|
691 | var extendStatics = function(d, b) {
|
692 | extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
693 | d2.__proto__ = b2;
|
694 | } || function(d2, b2) {
|
695 | for (var p in b2)
|
696 | if (Object.prototype.hasOwnProperty.call(b2, p))
|
697 | d2[p] = b2[p];
|
698 | };
|
699 | return extendStatics(d, b);
|
700 | };
|
701 | function __extends(d, b) {
|
702 | if (typeof b !== "function" && b !== null)
|
703 | throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
704 | extendStatics(d, b);
|
705 | function __() {
|
706 | this.constructor = d;
|
707 | }
|
708 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
709 | }
|
710 | var __assign = function() {
|
711 | __assign = Object.assign || function __assign2(t) {
|
712 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
713 | s = arguments[i];
|
714 | for (var p in s)
|
715 | if (Object.prototype.hasOwnProperty.call(s, p))
|
716 | t[p] = s[p];
|
717 | }
|
718 | return t;
|
719 | };
|
720 | return __assign.apply(this, arguments);
|
721 | };
|
722 | function __rest(s, e) {
|
723 | var t = {};
|
724 | for (var p in s)
|
725 | if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
726 | t[p] = s[p];
|
727 | if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
728 | for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
729 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
730 | t[p[i]] = s[p[i]];
|
731 | }
|
732 | return t;
|
733 | }
|
734 | function __spreadArray(to, from, pack) {
|
735 | if (pack || arguments.length === 2)
|
736 | for (var i = 0, l = from.length, ar; i < l; i++) {
|
737 | if (ar || !(i in from)) {
|
738 | if (!ar)
|
739 | ar = Array.prototype.slice.call(from, 0, i);
|
740 | ar[i] = from[i];
|
741 | }
|
742 | }
|
743 | return to.concat(ar || from);
|
744 | }
|
745 |
|
746 |
|
747 | var React4 = __toModule(window.React);
|
748 |
|
749 |
|
750 | var React3 = __toModule(window.React);
|
751 |
|
752 |
|
753 | var React2 = __toModule(window.React);
|
754 | var import_hoist_non_react_statics = __toModule(require_hoist_non_react_statics_cjs());
|
755 |
|
756 |
|
757 | var React = __toModule(window.React);
|
758 |
|
759 |
|
760 | var MINUTES_PER_HOUR = 60;
|
761 | var SECONDS_PER_MINUTE = 60;
|
762 | var MS_PER_SECOND = 1e3;
|
763 | var MS_PER_MINUTE = MS_PER_SECOND * SECONDS_PER_MINUTE;
|
764 | var MS_PER_HOUR = MS_PER_MINUTE * MINUTES_PER_HOUR;
|
765 |
|
766 |
|
767 | var SANCTIONED_UNITS = [
|
768 | "angle-degree",
|
769 | "area-acre",
|
770 | "area-hectare",
|
771 | "concentr-percent",
|
772 | "digital-bit",
|
773 | "digital-byte",
|
774 | "digital-gigabit",
|
775 | "digital-gigabyte",
|
776 | "digital-kilobit",
|
777 | "digital-kilobyte",
|
778 | "digital-megabit",
|
779 | "digital-megabyte",
|
780 | "digital-petabyte",
|
781 | "digital-terabit",
|
782 | "digital-terabyte",
|
783 | "duration-day",
|
784 | "duration-hour",
|
785 | "duration-millisecond",
|
786 | "duration-minute",
|
787 | "duration-month",
|
788 | "duration-second",
|
789 | "duration-week",
|
790 | "duration-year",
|
791 | "length-centimeter",
|
792 | "length-foot",
|
793 | "length-inch",
|
794 | "length-kilometer",
|
795 | "length-meter",
|
796 | "length-mile-scandinavian",
|
797 | "length-mile",
|
798 | "length-millimeter",
|
799 | "length-yard",
|
800 | "mass-gram",
|
801 | "mass-kilogram",
|
802 | "mass-ounce",
|
803 | "mass-pound",
|
804 | "mass-stone",
|
805 | "temperature-celsius",
|
806 | "temperature-fahrenheit",
|
807 | "volume-fluid-ounce",
|
808 | "volume-gallon",
|
809 | "volume-liter",
|
810 | "volume-milliliter"
|
811 | ];
|
812 | function removeUnitNamespace(unit) {
|
813 | return unit.slice(unit.indexOf("-") + 1);
|
814 | }
|
815 | var SIMPLE_UNITS = SANCTIONED_UNITS.map(removeUnitNamespace);
|
816 |
|
817 |
|
818 | function invariant(condition, message, Err) {
|
819 | if (Err === void 0) {
|
820 | Err = Error;
|
821 | }
|
822 | if (!condition) {
|
823 | throw new Err(message);
|
824 | }
|
825 | }
|
826 |
|
827 |
|
828 | var S_UNICODE_REGEX = /[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20BF\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC1\uFDFC\uFDFD\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDE8\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEE0-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF73\uDF80-\uDFD8\uDFE0-\uDFEB]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDD78\uDD7A-\uDDCB\uDDCD-\uDE53\uDE60-\uDE6D\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6\uDF00-\uDF92\uDF94-\uDFCA]/;
|
829 |
|
830 |
|
831 | var CARET_S_UNICODE_REGEX = new RegExp("^" + S_UNICODE_REGEX.source);
|
832 | var S_DOLLAR_UNICODE_REGEX = new RegExp(S_UNICODE_REGEX.source + "$");
|
833 |
|
834 |
|
835 | var import_intl_localematcher = __toModule(require_intl_localematcher());
|
836 |
|
837 |
|
838 | var import_intl_localematcher2 = __toModule(require_intl_localematcher());
|
839 |
|
840 |
|
841 | var MissingLocaleDataError = function(_super) {
|
842 | __extends(MissingLocaleDataError2, _super);
|
843 | function MissingLocaleDataError2() {
|
844 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
845 | _this.type = "MISSING_LOCALE_DATA";
|
846 | return _this;
|
847 | }
|
848 | return MissingLocaleDataError2;
|
849 | }(Error);
|
850 |
|
851 |
|
852 | var RangePatternType;
|
853 | (function(RangePatternType2) {
|
854 | RangePatternType2["startRange"] = "startRange";
|
855 | RangePatternType2["shared"] = "shared";
|
856 | RangePatternType2["endRange"] = "endRange";
|
857 | })(RangePatternType || (RangePatternType = {}));
|
858 |
|
859 |
|
860 | var ErrorKind;
|
861 | (function(ErrorKind2) {
|
862 | ErrorKind2[ErrorKind2["EXPECT_ARGUMENT_CLOSING_BRACE"] = 1] = "EXPECT_ARGUMENT_CLOSING_BRACE";
|
863 | ErrorKind2[ErrorKind2["EMPTY_ARGUMENT"] = 2] = "EMPTY_ARGUMENT";
|
864 | ErrorKind2[ErrorKind2["MALFORMED_ARGUMENT"] = 3] = "MALFORMED_ARGUMENT";
|
865 | ErrorKind2[ErrorKind2["EXPECT_ARGUMENT_TYPE"] = 4] = "EXPECT_ARGUMENT_TYPE";
|
866 | ErrorKind2[ErrorKind2["INVALID_ARGUMENT_TYPE"] = 5] = "INVALID_ARGUMENT_TYPE";
|
867 | ErrorKind2[ErrorKind2["EXPECT_ARGUMENT_STYLE"] = 6] = "EXPECT_ARGUMENT_STYLE";
|
868 | ErrorKind2[ErrorKind2["INVALID_NUMBER_SKELETON"] = 7] = "INVALID_NUMBER_SKELETON";
|
869 | ErrorKind2[ErrorKind2["INVALID_DATE_TIME_SKELETON"] = 8] = "INVALID_DATE_TIME_SKELETON";
|
870 | ErrorKind2[ErrorKind2["EXPECT_NUMBER_SKELETON"] = 9] = "EXPECT_NUMBER_SKELETON";
|
871 | ErrorKind2[ErrorKind2["EXPECT_DATE_TIME_SKELETON"] = 10] = "EXPECT_DATE_TIME_SKELETON";
|
872 | ErrorKind2[ErrorKind2["UNCLOSED_QUOTE_IN_ARGUMENT_STYLE"] = 11] = "UNCLOSED_QUOTE_IN_ARGUMENT_STYLE";
|
873 | ErrorKind2[ErrorKind2["EXPECT_SELECT_ARGUMENT_OPTIONS"] = 12] = "EXPECT_SELECT_ARGUMENT_OPTIONS";
|
874 | ErrorKind2[ErrorKind2["EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE"] = 13] = "EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE";
|
875 | ErrorKind2[ErrorKind2["INVALID_PLURAL_ARGUMENT_OFFSET_VALUE"] = 14] = "INVALID_PLURAL_ARGUMENT_OFFSET_VALUE";
|
876 | ErrorKind2[ErrorKind2["EXPECT_SELECT_ARGUMENT_SELECTOR"] = 15] = "EXPECT_SELECT_ARGUMENT_SELECTOR";
|
877 | ErrorKind2[ErrorKind2["EXPECT_PLURAL_ARGUMENT_SELECTOR"] = 16] = "EXPECT_PLURAL_ARGUMENT_SELECTOR";
|
878 | ErrorKind2[ErrorKind2["EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT"] = 17] = "EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT";
|
879 | ErrorKind2[ErrorKind2["EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT"] = 18] = "EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT";
|
880 | ErrorKind2[ErrorKind2["INVALID_PLURAL_ARGUMENT_SELECTOR"] = 19] = "INVALID_PLURAL_ARGUMENT_SELECTOR";
|
881 | ErrorKind2[ErrorKind2["DUPLICATE_PLURAL_ARGUMENT_SELECTOR"] = 20] = "DUPLICATE_PLURAL_ARGUMENT_SELECTOR";
|
882 | ErrorKind2[ErrorKind2["DUPLICATE_SELECT_ARGUMENT_SELECTOR"] = 21] = "DUPLICATE_SELECT_ARGUMENT_SELECTOR";
|
883 | ErrorKind2[ErrorKind2["MISSING_OTHER_CLAUSE"] = 22] = "MISSING_OTHER_CLAUSE";
|
884 | ErrorKind2[ErrorKind2["INVALID_TAG"] = 23] = "INVALID_TAG";
|
885 | ErrorKind2[ErrorKind2["INVALID_TAG_NAME"] = 25] = "INVALID_TAG_NAME";
|
886 | ErrorKind2[ErrorKind2["UNMATCHED_CLOSING_TAG"] = 26] = "UNMATCHED_CLOSING_TAG";
|
887 | ErrorKind2[ErrorKind2["UNCLOSED_TAG"] = 27] = "UNCLOSED_TAG";
|
888 | })(ErrorKind || (ErrorKind = {}));
|
889 |
|
890 |
|
891 | var TYPE;
|
892 | (function(TYPE2) {
|
893 | TYPE2[TYPE2["literal"] = 0] = "literal";
|
894 | TYPE2[TYPE2["argument"] = 1] = "argument";
|
895 | TYPE2[TYPE2["number"] = 2] = "number";
|
896 | TYPE2[TYPE2["date"] = 3] = "date";
|
897 | TYPE2[TYPE2["time"] = 4] = "time";
|
898 | TYPE2[TYPE2["select"] = 5] = "select";
|
899 | TYPE2[TYPE2["plural"] = 6] = "plural";
|
900 | TYPE2[TYPE2["pound"] = 7] = "pound";
|
901 | TYPE2[TYPE2["tag"] = 8] = "tag";
|
902 | })(TYPE || (TYPE = {}));
|
903 | var SKELETON_TYPE;
|
904 | (function(SKELETON_TYPE2) {
|
905 | SKELETON_TYPE2[SKELETON_TYPE2["number"] = 0] = "number";
|
906 | SKELETON_TYPE2[SKELETON_TYPE2["dateTime"] = 1] = "dateTime";
|
907 | })(SKELETON_TYPE || (SKELETON_TYPE = {}));
|
908 | function isLiteralElement(el) {
|
909 | return el.type === TYPE.literal;
|
910 | }
|
911 | function isArgumentElement(el) {
|
912 | return el.type === TYPE.argument;
|
913 | }
|
914 | function isNumberElement(el) {
|
915 | return el.type === TYPE.number;
|
916 | }
|
917 | function isDateElement(el) {
|
918 | return el.type === TYPE.date;
|
919 | }
|
920 | function isTimeElement(el) {
|
921 | return el.type === TYPE.time;
|
922 | }
|
923 | function isSelectElement(el) {
|
924 | return el.type === TYPE.select;
|
925 | }
|
926 | function isPluralElement(el) {
|
927 | return el.type === TYPE.plural;
|
928 | }
|
929 | function isPoundElement(el) {
|
930 | return el.type === TYPE.pound;
|
931 | }
|
932 | function isTagElement(el) {
|
933 | return el.type === TYPE.tag;
|
934 | }
|
935 | function isNumberSkeleton(el) {
|
936 | return !!(el && typeof el === "object" && el.type === SKELETON_TYPE.number);
|
937 | }
|
938 | function isDateTimeSkeleton(el) {
|
939 | return !!(el && typeof el === "object" && el.type === SKELETON_TYPE.dateTime);
|
940 | }
|
941 |
|
942 |
|
943 | var SPACE_SEPARATOR_REGEX = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/;
|
944 |
|
945 |
|
946 | 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;
|
947 | function parseDateTimeSkeleton(skeleton) {
|
948 | var result = {};
|
949 | skeleton.replace(DATE_TIME_REGEX, function(match) {
|
950 | var len = match.length;
|
951 | switch (match[0]) {
|
952 | case "G":
|
953 | result.era = len === 4 ? "long" : len === 5 ? "narrow" : "short";
|
954 | break;
|
955 | case "y":
|
956 | result.year = len === 2 ? "2-digit" : "numeric";
|
957 | break;
|
958 | case "Y":
|
959 | case "u":
|
960 | case "U":
|
961 | case "r":
|
962 | throw new RangeError("`Y/u/U/r` (year) patterns are not supported, use `y` instead");
|
963 | case "q":
|
964 | case "Q":
|
965 | throw new RangeError("`q/Q` (quarter) patterns are not supported");
|
966 | case "M":
|
967 | case "L":
|
968 | result.month = ["numeric", "2-digit", "short", "long", "narrow"][len - 1];
|
969 | break;
|
970 | case "w":
|
971 | case "W":
|
972 | throw new RangeError("`w/W` (week) patterns are not supported");
|
973 | case "d":
|
974 | result.day = ["numeric", "2-digit"][len - 1];
|
975 | break;
|
976 | case "D":
|
977 | case "F":
|
978 | case "g":
|
979 | throw new RangeError("`D/F/g` (day) patterns are not supported, use `d` instead");
|
980 | case "E":
|
981 | result.weekday = len === 4 ? "short" : len === 5 ? "narrow" : "short";
|
982 | break;
|
983 | case "e":
|
984 | if (len < 4) {
|
985 | throw new RangeError("`e..eee` (weekday) patterns are not supported");
|
986 | }
|
987 | result.weekday = ["short", "long", "narrow", "short"][len - 4];
|
988 | break;
|
989 | case "c":
|
990 | if (len < 4) {
|
991 | throw new RangeError("`c..ccc` (weekday) patterns are not supported");
|
992 | }
|
993 | result.weekday = ["short", "long", "narrow", "short"][len - 4];
|
994 | break;
|
995 | case "a":
|
996 | result.hour12 = true;
|
997 | break;
|
998 | case "b":
|
999 | case "B":
|
1000 | throw new RangeError("`b/B` (period) patterns are not supported, use `a` instead");
|
1001 | case "h":
|
1002 | result.hourCycle = "h12";
|
1003 | result.hour = ["numeric", "2-digit"][len - 1];
|
1004 | break;
|
1005 | case "H":
|
1006 | result.hourCycle = "h23";
|
1007 | result.hour = ["numeric", "2-digit"][len - 1];
|
1008 | break;
|
1009 | case "K":
|
1010 | result.hourCycle = "h11";
|
1011 | result.hour = ["numeric", "2-digit"][len - 1];
|
1012 | break;
|
1013 | case "k":
|
1014 | result.hourCycle = "h24";
|
1015 | result.hour = ["numeric", "2-digit"][len - 1];
|
1016 | break;
|
1017 | case "j":
|
1018 | case "J":
|
1019 | case "C":
|
1020 | throw new RangeError("`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead");
|
1021 | case "m":
|
1022 | result.minute = ["numeric", "2-digit"][len - 1];
|
1023 | break;
|
1024 | case "s":
|
1025 | result.second = ["numeric", "2-digit"][len - 1];
|
1026 | break;
|
1027 | case "S":
|
1028 | case "A":
|
1029 | throw new RangeError("`S/A` (second) patterns are not supported, use `s` instead");
|
1030 | case "z":
|
1031 | result.timeZoneName = len < 4 ? "short" : "long";
|
1032 | break;
|
1033 | case "Z":
|
1034 | case "O":
|
1035 | case "v":
|
1036 | case "V":
|
1037 | case "X":
|
1038 | case "x":
|
1039 | throw new RangeError("`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead");
|
1040 | }
|
1041 | return "";
|
1042 | });
|
1043 | return result;
|
1044 | }
|
1045 |
|
1046 |
|
1047 | var WHITE_SPACE_REGEX = /[\t-\r \x85\u200E\u200F\u2028\u2029]/i;
|
1048 |
|
1049 |
|
1050 | function parseNumberSkeletonFromString(skeleton) {
|
1051 | if (skeleton.length === 0) {
|
1052 | throw new Error("Number skeleton cannot be empty");
|
1053 | }
|
1054 | var stringTokens = skeleton.split(WHITE_SPACE_REGEX).filter(function(x) {
|
1055 | return x.length > 0;
|
1056 | });
|
1057 | var tokens = [];
|
1058 | for (var _i = 0, stringTokens_1 = stringTokens; _i < stringTokens_1.length; _i++) {
|
1059 | var stringToken = stringTokens_1[_i];
|
1060 | var stemAndOptions = stringToken.split("/");
|
1061 | if (stemAndOptions.length === 0) {
|
1062 | throw new Error("Invalid number skeleton");
|
1063 | }
|
1064 | var stem = stemAndOptions[0], options = stemAndOptions.slice(1);
|
1065 | for (var _a2 = 0, options_1 = options; _a2 < options_1.length; _a2++) {
|
1066 | var option = options_1[_a2];
|
1067 | if (option.length === 0) {
|
1068 | throw new Error("Invalid number skeleton");
|
1069 | }
|
1070 | }
|
1071 | tokens.push({ stem: stem, options: options });
|
1072 | }
|
1073 | return tokens;
|
1074 | }
|
1075 | function icuUnitToEcma(unit) {
|
1076 | return unit.replace(/^(.*?)-/, "");
|
1077 | }
|
1078 | var FRACTION_PRECISION_REGEX = /^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g;
|
1079 | var SIGNIFICANT_PRECISION_REGEX = /^(@+)?(\+|#+)?[rs]?$/g;
|
1080 | var INTEGER_WIDTH_REGEX = /(\*)(0+)|(#+)(0+)|(0+)/g;
|
1081 | var CONCISE_INTEGER_WIDTH_REGEX = /^(0+)$/;
|
1082 | function parseSignificantPrecision(str) {
|
1083 | var result = {};
|
1084 | if (str[str.length - 1] === "r") {
|
1085 | result.roundingPriority = "morePrecision";
|
1086 | } else if (str[str.length - 1] === "s") {
|
1087 | result.roundingPriority = "lessPrecision";
|
1088 | }
|
1089 | str.replace(SIGNIFICANT_PRECISION_REGEX, function(_, g1, g2) {
|
1090 | if (typeof g2 !== "string") {
|
1091 | result.minimumSignificantDigits = g1.length;
|
1092 | result.maximumSignificantDigits = g1.length;
|
1093 | } else if (g2 === "+") {
|
1094 | result.minimumSignificantDigits = g1.length;
|
1095 | } else if (g1[0] === "#") {
|
1096 | result.maximumSignificantDigits = g1.length;
|
1097 | } else {
|
1098 | result.minimumSignificantDigits = g1.length;
|
1099 | result.maximumSignificantDigits = g1.length + (typeof g2 === "string" ? g2.length : 0);
|
1100 | }
|
1101 | return "";
|
1102 | });
|
1103 | return result;
|
1104 | }
|
1105 | function parseSign(str) {
|
1106 | switch (str) {
|
1107 | case "sign-auto":
|
1108 | return {
|
1109 | signDisplay: "auto"
|
1110 | };
|
1111 | case "sign-accounting":
|
1112 | case "()":
|
1113 | return {
|
1114 | currencySign: "accounting"
|
1115 | };
|
1116 | case "sign-always":
|
1117 | case "+!":
|
1118 | return {
|
1119 | signDisplay: "always"
|
1120 | };
|
1121 | case "sign-accounting-always":
|
1122 | case "()!":
|
1123 | return {
|
1124 | signDisplay: "always",
|
1125 | currencySign: "accounting"
|
1126 | };
|
1127 | case "sign-except-zero":
|
1128 | case "+?":
|
1129 | return {
|
1130 | signDisplay: "exceptZero"
|
1131 | };
|
1132 | case "sign-accounting-except-zero":
|
1133 | case "()?":
|
1134 | return {
|
1135 | signDisplay: "exceptZero",
|
1136 | currencySign: "accounting"
|
1137 | };
|
1138 | case "sign-never":
|
1139 | case "+_":
|
1140 | return {
|
1141 | signDisplay: "never"
|
1142 | };
|
1143 | }
|
1144 | }
|
1145 | function parseConciseScientificAndEngineeringStem(stem) {
|
1146 | var result;
|
1147 | if (stem[0] === "E" && stem[1] === "E") {
|
1148 | result = {
|
1149 | notation: "engineering"
|
1150 | };
|
1151 | stem = stem.slice(2);
|
1152 | } else if (stem[0] === "E") {
|
1153 | result = {
|
1154 | notation: "scientific"
|
1155 | };
|
1156 | stem = stem.slice(1);
|
1157 | }
|
1158 | if (result) {
|
1159 | var signDisplay = stem.slice(0, 2);
|
1160 | if (signDisplay === "+!") {
|
1161 | result.signDisplay = "always";
|
1162 | stem = stem.slice(2);
|
1163 | } else if (signDisplay === "+?") {
|
1164 | result.signDisplay = "exceptZero";
|
1165 | stem = stem.slice(2);
|
1166 | }
|
1167 | if (!CONCISE_INTEGER_WIDTH_REGEX.test(stem)) {
|
1168 | throw new Error("Malformed concise eng/scientific notation");
|
1169 | }
|
1170 | result.minimumIntegerDigits = stem.length;
|
1171 | }
|
1172 | return result;
|
1173 | }
|
1174 | function parseNotationOptions(opt) {
|
1175 | var result = {};
|
1176 | var signOpts = parseSign(opt);
|
1177 | if (signOpts) {
|
1178 | return signOpts;
|
1179 | }
|
1180 | return result;
|
1181 | }
|
1182 | function parseNumberSkeleton(tokens) {
|
1183 | var result = {};
|
1184 | for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
|
1185 | var token = tokens_1[_i];
|
1186 | switch (token.stem) {
|
1187 | case "percent":
|
1188 | case "%":
|
1189 | result.style = "percent";
|
1190 | continue;
|
1191 | case "%x100":
|
1192 | result.style = "percent";
|
1193 | result.scale = 100;
|
1194 | continue;
|
1195 | case "currency":
|
1196 | result.style = "currency";
|
1197 | result.currency = token.options[0];
|
1198 | continue;
|
1199 | case "group-off":
|
1200 | case ",_":
|
1201 | result.useGrouping = false;
|
1202 | continue;
|
1203 | case "precision-integer":
|
1204 | case ".":
|
1205 | result.maximumFractionDigits = 0;
|
1206 | continue;
|
1207 | case "measure-unit":
|
1208 | case "unit":
|
1209 | result.style = "unit";
|
1210 | result.unit = icuUnitToEcma(token.options[0]);
|
1211 | continue;
|
1212 | case "compact-short":
|
1213 | case "K":
|
1214 | result.notation = "compact";
|
1215 | result.compactDisplay = "short";
|
1216 | continue;
|
1217 | case "compact-long":
|
1218 | case "KK":
|
1219 | result.notation = "compact";
|
1220 | result.compactDisplay = "long";
|
1221 | continue;
|
1222 | case "scientific":
|
1223 | result = __assign(__assign(__assign({}, result), { notation: "scientific" }), token.options.reduce(function(all, opt2) {
|
1224 | return __assign(__assign({}, all), parseNotationOptions(opt2));
|
1225 | }, {}));
|
1226 | continue;
|
1227 | case "engineering":
|
1228 | result = __assign(__assign(__assign({}, result), { notation: "engineering" }), token.options.reduce(function(all, opt2) {
|
1229 | return __assign(__assign({}, all), parseNotationOptions(opt2));
|
1230 | }, {}));
|
1231 | continue;
|
1232 | case "notation-simple":
|
1233 | result.notation = "standard";
|
1234 | continue;
|
1235 | case "unit-width-narrow":
|
1236 | result.currencyDisplay = "narrowSymbol";
|
1237 | result.unitDisplay = "narrow";
|
1238 | continue;
|
1239 | case "unit-width-short":
|
1240 | result.currencyDisplay = "code";
|
1241 | result.unitDisplay = "short";
|
1242 | continue;
|
1243 | case "unit-width-full-name":
|
1244 | result.currencyDisplay = "name";
|
1245 | result.unitDisplay = "long";
|
1246 | continue;
|
1247 | case "unit-width-iso-code":
|
1248 | result.currencyDisplay = "symbol";
|
1249 | continue;
|
1250 | case "scale":
|
1251 | result.scale = parseFloat(token.options[0]);
|
1252 | continue;
|
1253 | case "integer-width":
|
1254 | if (token.options.length > 1) {
|
1255 | throw new RangeError("integer-width stems only accept a single optional option");
|
1256 | }
|
1257 | token.options[0].replace(INTEGER_WIDTH_REGEX, function(_, g1, g2, g3, g4, g5) {
|
1258 | if (g1) {
|
1259 | result.minimumIntegerDigits = g2.length;
|
1260 | } else if (g3 && g4) {
|
1261 | throw new Error("We currently do not support maximum integer digits");
|
1262 | } else if (g5) {
|
1263 | throw new Error("We currently do not support exact integer digits");
|
1264 | }
|
1265 | return "";
|
1266 | });
|
1267 | continue;
|
1268 | }
|
1269 | if (CONCISE_INTEGER_WIDTH_REGEX.test(token.stem)) {
|
1270 | result.minimumIntegerDigits = token.stem.length;
|
1271 | continue;
|
1272 | }
|
1273 | if (FRACTION_PRECISION_REGEX.test(token.stem)) {
|
1274 | if (token.options.length > 1) {
|
1275 | throw new RangeError("Fraction-precision stems only accept a single optional option");
|
1276 | }
|
1277 | token.stem.replace(FRACTION_PRECISION_REGEX, function(_, g1, g2, g3, g4, g5) {
|
1278 | if (g2 === "*") {
|
1279 | result.minimumFractionDigits = g1.length;
|
1280 | } else if (g3 && g3[0] === "#") {
|
1281 | result.maximumFractionDigits = g3.length;
|
1282 | } else if (g4 && g5) {
|
1283 | result.minimumFractionDigits = g4.length;
|
1284 | result.maximumFractionDigits = g4.length + g5.length;
|
1285 | } else {
|
1286 | result.minimumFractionDigits = g1.length;
|
1287 | result.maximumFractionDigits = g1.length;
|
1288 | }
|
1289 | return "";
|
1290 | });
|
1291 | var opt = token.options[0];
|
1292 | if (opt === "w") {
|
1293 | result = __assign(__assign({}, result), { trailingZeroDisplay: "stripIfInteger" });
|
1294 | } else if (opt) {
|
1295 | result = __assign(__assign({}, result), parseSignificantPrecision(opt));
|
1296 | }
|
1297 | continue;
|
1298 | }
|
1299 | if (SIGNIFICANT_PRECISION_REGEX.test(token.stem)) {
|
1300 | result = __assign(__assign({}, result), parseSignificantPrecision(token.stem));
|
1301 | continue;
|
1302 | }
|
1303 | var signOpts = parseSign(token.stem);
|
1304 | if (signOpts) {
|
1305 | result = __assign(__assign({}, result), signOpts);
|
1306 | }
|
1307 | var conciseScientificAndEngineeringOpts = parseConciseScientificAndEngineeringStem(token.stem);
|
1308 | if (conciseScientificAndEngineeringOpts) {
|
1309 | result = __assign(__assign({}, result), conciseScientificAndEngineeringOpts);
|
1310 | }
|
1311 | }
|
1312 | return result;
|
1313 | }
|
1314 |
|
1315 |
|
1316 | var _a;
|
1317 | var SPACE_SEPARATOR_START_REGEX = new RegExp("^" + SPACE_SEPARATOR_REGEX.source + "*");
|
1318 | var SPACE_SEPARATOR_END_REGEX = new RegExp(SPACE_SEPARATOR_REGEX.source + "*$");
|
1319 | function createLocation(start, end) {
|
1320 | return { start: start, end: end };
|
1321 | }
|
1322 | var hasNativeStartsWith = !!String.prototype.startsWith;
|
1323 | var hasNativeFromCodePoint = !!String.fromCodePoint;
|
1324 | var hasNativeFromEntries = !!Object.fromEntries;
|
1325 | var hasNativeCodePointAt = !!String.prototype.codePointAt;
|
1326 | var hasTrimStart = !!String.prototype.trimStart;
|
1327 | var hasTrimEnd = !!String.prototype.trimEnd;
|
1328 | var hasNativeIsSafeInteger = !!Number.isSafeInteger;
|
1329 | var isSafeInteger = hasNativeIsSafeInteger ? Number.isSafeInteger : function(n) {
|
1330 | return typeof n === "number" && isFinite(n) && Math.floor(n) === n && Math.abs(n) <= 9007199254740991;
|
1331 | };
|
1332 | var REGEX_SUPPORTS_U_AND_Y = true;
|
1333 | try {
|
1334 | re = RE("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
|
1335 | REGEX_SUPPORTS_U_AND_Y = ((_a = re.exec("a")) === null || _a === void 0 ? void 0 : _a[0]) === "a";
|
1336 | } catch (_) {
|
1337 | REGEX_SUPPORTS_U_AND_Y = false;
|
1338 | }
|
1339 | var re;
|
1340 | var startsWith = hasNativeStartsWith ? function startsWith2(s, search, position) {
|
1341 | return s.startsWith(search, position);
|
1342 | } : function startsWith3(s, search, position) {
|
1343 | return s.slice(position, position + search.length) === search;
|
1344 | };
|
1345 | var fromCodePoint = hasNativeFromCodePoint ? String.fromCodePoint : function fromCodePoint2() {
|
1346 | var codePoints = [];
|
1347 | for (var _i = 0; _i < arguments.length; _i++) {
|
1348 | codePoints[_i] = arguments[_i];
|
1349 | }
|
1350 | var elements = "";
|
1351 | var length = codePoints.length;
|
1352 | var i = 0;
|
1353 | var code;
|
1354 | while (length > i) {
|
1355 | code = codePoints[i++];
|
1356 | if (code > 1114111)
|
1357 | throw RangeError(code + " is not a valid code point");
|
1358 | elements += code < 65536 ? String.fromCharCode(code) : String.fromCharCode(((code -= 65536) >> 10) + 55296, code % 1024 + 56320);
|
1359 | }
|
1360 | return elements;
|
1361 | };
|
1362 | var fromEntries = hasNativeFromEntries ? Object.fromEntries : function fromEntries2(entries) {
|
1363 | var obj = {};
|
1364 | for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
1365 | var _a2 = entries_1[_i], k = _a2[0], v = _a2[1];
|
1366 | obj[k] = v;
|
1367 | }
|
1368 | return obj;
|
1369 | };
|
1370 | var codePointAt = hasNativeCodePointAt ? function codePointAt2(s, index) {
|
1371 | return s.codePointAt(index);
|
1372 | } : function codePointAt3(s, index) {
|
1373 | var size = s.length;
|
1374 | if (index < 0 || index >= size) {
|
1375 | return void 0;
|
1376 | }
|
1377 | var first = s.charCodeAt(index);
|
1378 | var second;
|
1379 | return first < 55296 || first > 56319 || index + 1 === size || (second = s.charCodeAt(index + 1)) < 56320 || second > 57343 ? first : (first - 55296 << 10) + (second - 56320) + 65536;
|
1380 | };
|
1381 | var trimStart = hasTrimStart ? function trimStart2(s) {
|
1382 | return s.trimStart();
|
1383 | } : function trimStart3(s) {
|
1384 | return s.replace(SPACE_SEPARATOR_START_REGEX, "");
|
1385 | };
|
1386 | var trimEnd = hasTrimEnd ? function trimEnd2(s) {
|
1387 | return s.trimEnd();
|
1388 | } : function trimEnd3(s) {
|
1389 | return s.replace(SPACE_SEPARATOR_END_REGEX, "");
|
1390 | };
|
1391 | function RE(s, flag) {
|
1392 | return new RegExp(s, flag);
|
1393 | }
|
1394 | var matchIdentifierAtIndex;
|
1395 | if (REGEX_SUPPORTS_U_AND_Y) {
|
1396 | IDENTIFIER_PREFIX_RE_1 = RE("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
|
1397 | matchIdentifierAtIndex = function matchIdentifierAtIndex2(s, index) {
|
1398 | var _a2;
|
1399 | IDENTIFIER_PREFIX_RE_1.lastIndex = index;
|
1400 | var match = IDENTIFIER_PREFIX_RE_1.exec(s);
|
1401 | return (_a2 = match[1]) !== null && _a2 !== void 0 ? _a2 : "";
|
1402 | };
|
1403 | } else {
|
1404 | matchIdentifierAtIndex = function matchIdentifierAtIndex2(s, index) {
|
1405 | var match = [];
|
1406 | while (true) {
|
1407 | var c = codePointAt(s, index);
|
1408 | if (c === void 0 || _isWhiteSpace(c) || _isPatternSyntax(c)) {
|
1409 | break;
|
1410 | }
|
1411 | match.push(c);
|
1412 | index += c >= 65536 ? 2 : 1;
|
1413 | }
|
1414 | return fromCodePoint.apply(void 0, match);
|
1415 | };
|
1416 | }
|
1417 | var IDENTIFIER_PREFIX_RE_1;
|
1418 | var Parser = function() {
|
1419 | function Parser2(message, options) {
|
1420 | if (options === void 0) {
|
1421 | options = {};
|
1422 | }
|
1423 | this.message = message;
|
1424 | this.position = { offset: 0, line: 1, column: 1 };
|
1425 | this.ignoreTag = !!options.ignoreTag;
|
1426 | this.requiresOtherClause = !!options.requiresOtherClause;
|
1427 | this.shouldParseSkeletons = !!options.shouldParseSkeletons;
|
1428 | }
|
1429 | Parser2.prototype.parse = function() {
|
1430 | if (this.offset() !== 0) {
|
1431 | throw Error("parser can only be used once");
|
1432 | }
|
1433 | return this.parseMessage(0, "", false);
|
1434 | };
|
1435 | Parser2.prototype.parseMessage = function(nestingLevel, parentArgType, expectingCloseTag) {
|
1436 | var elements = [];
|
1437 | while (!this.isEOF()) {
|
1438 | var char = this.char();
|
1439 | if (char === 123) {
|
1440 | var result = this.parseArgument(nestingLevel, expectingCloseTag);
|
1441 | if (result.err) {
|
1442 | return result;
|
1443 | }
|
1444 | elements.push(result.val);
|
1445 | } else if (char === 125 && nestingLevel > 0) {
|
1446 | break;
|
1447 | } else if (char === 35 && (parentArgType === "plural" || parentArgType === "selectordinal")) {
|
1448 | var position = this.clonePosition();
|
1449 | this.bump();
|
1450 | elements.push({
|
1451 | type: TYPE.pound,
|
1452 | location: createLocation(position, this.clonePosition())
|
1453 | });
|
1454 | } else if (char === 60 && !this.ignoreTag && this.peek() === 47) {
|
1455 | if (expectingCloseTag) {
|
1456 | break;
|
1457 | } else {
|
1458 | return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(this.clonePosition(), this.clonePosition()));
|
1459 | }
|
1460 | } else if (char === 60 && !this.ignoreTag && _isAlpha(this.peek() || 0)) {
|
1461 | var result = this.parseTag(nestingLevel, parentArgType);
|
1462 | if (result.err) {
|
1463 | return result;
|
1464 | }
|
1465 | elements.push(result.val);
|
1466 | } else {
|
1467 | var result = this.parseLiteral(nestingLevel, parentArgType);
|
1468 | if (result.err) {
|
1469 | return result;
|
1470 | }
|
1471 | elements.push(result.val);
|
1472 | }
|
1473 | }
|
1474 | return { val: elements, err: null };
|
1475 | };
|
1476 | Parser2.prototype.parseTag = function(nestingLevel, parentArgType) {
|
1477 | var startPosition = this.clonePosition();
|
1478 | this.bump();
|
1479 | var tagName = this.parseTagName();
|
1480 | this.bumpSpace();
|
1481 | if (this.bumpIf("/>")) {
|
1482 | return {
|
1483 | val: {
|
1484 | type: TYPE.literal,
|
1485 | value: "<" + tagName + "/>",
|
1486 | location: createLocation(startPosition, this.clonePosition())
|
1487 | },
|
1488 | err: null
|
1489 | };
|
1490 | } else if (this.bumpIf(">")) {
|
1491 | var childrenResult = this.parseMessage(nestingLevel + 1, parentArgType, true);
|
1492 | if (childrenResult.err) {
|
1493 | return childrenResult;
|
1494 | }
|
1495 | var children = childrenResult.val;
|
1496 | var endTagStartPosition = this.clonePosition();
|
1497 | if (this.bumpIf("</")) {
|
1498 | if (this.isEOF() || !_isAlpha(this.char())) {
|
1499 | return this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition()));
|
1500 | }
|
1501 | var closingTagNameStartPosition = this.clonePosition();
|
1502 | var closingTagName = this.parseTagName();
|
1503 | if (tagName !== closingTagName) {
|
1504 | return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(closingTagNameStartPosition, this.clonePosition()));
|
1505 | }
|
1506 | this.bumpSpace();
|
1507 | if (!this.bumpIf(">")) {
|
1508 | return this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition()));
|
1509 | }
|
1510 | return {
|
1511 | val: {
|
1512 | type: TYPE.tag,
|
1513 | value: tagName,
|
1514 | children: children,
|
1515 | location: createLocation(startPosition, this.clonePosition())
|
1516 | },
|
1517 | err: null
|
1518 | };
|
1519 | } else {
|
1520 | return this.error(ErrorKind.UNCLOSED_TAG, createLocation(startPosition, this.clonePosition()));
|
1521 | }
|
1522 | } else {
|
1523 | return this.error(ErrorKind.INVALID_TAG, createLocation(startPosition, this.clonePosition()));
|
1524 | }
|
1525 | };
|
1526 | Parser2.prototype.parseTagName = function() {
|
1527 | var startOffset = this.offset();
|
1528 | this.bump();
|
1529 | while (!this.isEOF() && _isPotentialElementNameChar(this.char())) {
|
1530 | this.bump();
|
1531 | }
|
1532 | return this.message.slice(startOffset, this.offset());
|
1533 | };
|
1534 | Parser2.prototype.parseLiteral = function(nestingLevel, parentArgType) {
|
1535 | var start = this.clonePosition();
|
1536 | var value = "";
|
1537 | while (true) {
|
1538 | var parseQuoteResult = this.tryParseQuote(parentArgType);
|
1539 | if (parseQuoteResult) {
|
1540 | value += parseQuoteResult;
|
1541 | continue;
|
1542 | }
|
1543 | var parseUnquotedResult = this.tryParseUnquoted(nestingLevel, parentArgType);
|
1544 | if (parseUnquotedResult) {
|
1545 | value += parseUnquotedResult;
|
1546 | continue;
|
1547 | }
|
1548 | var parseLeftAngleResult = this.tryParseLeftAngleBracket();
|
1549 | if (parseLeftAngleResult) {
|
1550 | value += parseLeftAngleResult;
|
1551 | continue;
|
1552 | }
|
1553 | break;
|
1554 | }
|
1555 | var location = createLocation(start, this.clonePosition());
|
1556 | return {
|
1557 | val: { type: TYPE.literal, value: value, location: location },
|
1558 | err: null
|
1559 | };
|
1560 | };
|
1561 | Parser2.prototype.tryParseLeftAngleBracket = function() {
|
1562 | if (!this.isEOF() && this.char() === 60 && (this.ignoreTag || !_isAlphaOrSlash(this.peek() || 0))) {
|
1563 | this.bump();
|
1564 | return "<";
|
1565 | }
|
1566 | return null;
|
1567 | };
|
1568 | Parser2.prototype.tryParseQuote = function(parentArgType) {
|
1569 | if (this.isEOF() || this.char() !== 39) {
|
1570 | return null;
|
1571 | }
|
1572 | switch (this.peek()) {
|
1573 | case 39:
|
1574 | this.bump();
|
1575 | this.bump();
|
1576 | return "'";
|
1577 | case 123:
|
1578 | case 60:
|
1579 | case 62:
|
1580 | case 125:
|
1581 | break;
|
1582 | case 35:
|
1583 | if (parentArgType === "plural" || parentArgType === "selectordinal") {
|
1584 | break;
|
1585 | }
|
1586 | return null;
|
1587 | default:
|
1588 | return null;
|
1589 | }
|
1590 | this.bump();
|
1591 | var codePoints = [this.char()];
|
1592 | this.bump();
|
1593 | while (!this.isEOF()) {
|
1594 | var ch = this.char();
|
1595 | if (ch === 39) {
|
1596 | if (this.peek() === 39) {
|
1597 | codePoints.push(39);
|
1598 | this.bump();
|
1599 | } else {
|
1600 | this.bump();
|
1601 | break;
|
1602 | }
|
1603 | } else {
|
1604 | codePoints.push(ch);
|
1605 | }
|
1606 | this.bump();
|
1607 | }
|
1608 | return fromCodePoint.apply(void 0, codePoints);
|
1609 | };
|
1610 | Parser2.prototype.tryParseUnquoted = function(nestingLevel, parentArgType) {
|
1611 | if (this.isEOF()) {
|
1612 | return null;
|
1613 | }
|
1614 | var ch = this.char();
|
1615 | if (ch === 60 || ch === 123 || ch === 35 && (parentArgType === "plural" || parentArgType === "selectordinal") || ch === 125 && nestingLevel > 0) {
|
1616 | return null;
|
1617 | } else {
|
1618 | this.bump();
|
1619 | return fromCodePoint(ch);
|
1620 | }
|
1621 | };
|
1622 | Parser2.prototype.parseArgument = function(nestingLevel, expectingCloseTag) {
|
1623 | var openingBracePosition = this.clonePosition();
|
1624 | this.bump();
|
1625 | this.bumpSpace();
|
1626 | if (this.isEOF()) {
|
1627 | return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
|
1628 | }
|
1629 | if (this.char() === 125) {
|
1630 | this.bump();
|
1631 | return this.error(ErrorKind.EMPTY_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
|
1632 | }
|
1633 | var value = this.parseIdentifierIfPossible().value;
|
1634 | if (!value) {
|
1635 | return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
|
1636 | }
|
1637 | this.bumpSpace();
|
1638 | if (this.isEOF()) {
|
1639 | return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
|
1640 | }
|
1641 | switch (this.char()) {
|
1642 | case 125: {
|
1643 | this.bump();
|
1644 | return {
|
1645 | val: {
|
1646 | type: TYPE.argument,
|
1647 | value: value,
|
1648 | location: createLocation(openingBracePosition, this.clonePosition())
|
1649 | },
|
1650 | err: null
|
1651 | };
|
1652 | }
|
1653 | case 44: {
|
1654 | this.bump();
|
1655 | this.bumpSpace();
|
1656 | if (this.isEOF()) {
|
1657 | return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
|
1658 | }
|
1659 | return this.parseArgumentOptions(nestingLevel, expectingCloseTag, value, openingBracePosition);
|
1660 | }
|
1661 | default:
|
1662 | return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
|
1663 | }
|
1664 | };
|
1665 | Parser2.prototype.parseIdentifierIfPossible = function() {
|
1666 | var startingPosition = this.clonePosition();
|
1667 | var startOffset = this.offset();
|
1668 | var value = matchIdentifierAtIndex(this.message, startOffset);
|
1669 | var endOffset = startOffset + value.length;
|
1670 | this.bumpTo(endOffset);
|
1671 | var endPosition = this.clonePosition();
|
1672 | var location = createLocation(startingPosition, endPosition);
|
1673 | return { value: value, location: location };
|
1674 | };
|
1675 | Parser2.prototype.parseArgumentOptions = function(nestingLevel, expectingCloseTag, value, openingBracePosition) {
|
1676 | var _a2;
|
1677 | var typeStartPosition = this.clonePosition();
|
1678 | var argType = this.parseIdentifierIfPossible().value;
|
1679 | var typeEndPosition = this.clonePosition();
|
1680 | switch (argType) {
|
1681 | case "":
|
1682 | return this.error(ErrorKind.EXPECT_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
|
1683 | case "number":
|
1684 | case "date":
|
1685 | case "time": {
|
1686 | this.bumpSpace();
|
1687 | var styleAndLocation = null;
|
1688 | if (this.bumpIf(",")) {
|
1689 | this.bumpSpace();
|
1690 | var styleStartPosition = this.clonePosition();
|
1691 | var result = this.parseSimpleArgStyleIfPossible();
|
1692 | if (result.err) {
|
1693 | return result;
|
1694 | }
|
1695 | var style = trimEnd(result.val);
|
1696 | if (style.length === 0) {
|
1697 | return this.error(ErrorKind.EXPECT_ARGUMENT_STYLE, createLocation(this.clonePosition(), this.clonePosition()));
|
1698 | }
|
1699 | var styleLocation = createLocation(styleStartPosition, this.clonePosition());
|
1700 | styleAndLocation = { style: style, styleLocation: styleLocation };
|
1701 | }
|
1702 | var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
|
1703 | if (argCloseResult.err) {
|
1704 | return argCloseResult;
|
1705 | }
|
1706 | var location_1 = createLocation(openingBracePosition, this.clonePosition());
|
1707 | if (styleAndLocation && startsWith(styleAndLocation === null || styleAndLocation === void 0 ? void 0 : styleAndLocation.style, "::", 0)) {
|
1708 | var skeleton = trimStart(styleAndLocation.style.slice(2));
|
1709 | if (argType === "number") {
|
1710 | var result = this.parseNumberSkeletonFromString(skeleton, styleAndLocation.styleLocation);
|
1711 | if (result.err) {
|
1712 | return result;
|
1713 | }
|
1714 | return {
|
1715 | val: { type: TYPE.number, value: value, location: location_1, style: result.val },
|
1716 | err: null
|
1717 | };
|
1718 | } else {
|
1719 | if (skeleton.length === 0) {
|
1720 | return this.error(ErrorKind.EXPECT_DATE_TIME_SKELETON, location_1);
|
1721 | }
|
1722 | var style = {
|
1723 | type: SKELETON_TYPE.dateTime,
|
1724 | pattern: skeleton,
|
1725 | location: styleAndLocation.styleLocation,
|
1726 | parsedOptions: this.shouldParseSkeletons ? parseDateTimeSkeleton(skeleton) : {}
|
1727 | };
|
1728 | var type = argType === "date" ? TYPE.date : TYPE.time;
|
1729 | return {
|
1730 | val: { type: type, value: value, location: location_1, style: style },
|
1731 | err: null
|
1732 | };
|
1733 | }
|
1734 | }
|
1735 | return {
|
1736 | val: {
|
1737 | type: argType === "number" ? TYPE.number : argType === "date" ? TYPE.date : TYPE.time,
|
1738 | value: value,
|
1739 | location: location_1,
|
1740 | style: (_a2 = styleAndLocation === null || styleAndLocation === void 0 ? void 0 : styleAndLocation.style) !== null && _a2 !== void 0 ? _a2 : null
|
1741 | },
|
1742 | err: null
|
1743 | };
|
1744 | }
|
1745 | case "plural":
|
1746 | case "selectordinal":
|
1747 | case "select": {
|
1748 | var typeEndPosition_1 = this.clonePosition();
|
1749 | this.bumpSpace();
|
1750 | if (!this.bumpIf(",")) {
|
1751 | return this.error(ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, createLocation(typeEndPosition_1, __assign({}, typeEndPosition_1)));
|
1752 | }
|
1753 | this.bumpSpace();
|
1754 | var identifierAndLocation = this.parseIdentifierIfPossible();
|
1755 | var pluralOffset = 0;
|
1756 | if (argType !== "select" && identifierAndLocation.value === "offset") {
|
1757 | if (!this.bumpIf(":")) {
|
1758 | return this.error(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, createLocation(this.clonePosition(), this.clonePosition()));
|
1759 | }
|
1760 | this.bumpSpace();
|
1761 | var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, ErrorKind.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);
|
1762 | if (result.err) {
|
1763 | return result;
|
1764 | }
|
1765 | this.bumpSpace();
|
1766 | identifierAndLocation = this.parseIdentifierIfPossible();
|
1767 | pluralOffset = result.val;
|
1768 | }
|
1769 | var optionsResult = this.tryParsePluralOrSelectOptions(nestingLevel, argType, expectingCloseTag, identifierAndLocation);
|
1770 | if (optionsResult.err) {
|
1771 | return optionsResult;
|
1772 | }
|
1773 | var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
|
1774 | if (argCloseResult.err) {
|
1775 | return argCloseResult;
|
1776 | }
|
1777 | var location_2 = createLocation(openingBracePosition, this.clonePosition());
|
1778 | if (argType === "select") {
|
1779 | return {
|
1780 | val: {
|
1781 | type: TYPE.select,
|
1782 | value: value,
|
1783 | options: fromEntries(optionsResult.val),
|
1784 | location: location_2
|
1785 | },
|
1786 | err: null
|
1787 | };
|
1788 | } else {
|
1789 | return {
|
1790 | val: {
|
1791 | type: TYPE.plural,
|
1792 | value: value,
|
1793 | options: fromEntries(optionsResult.val),
|
1794 | offset: pluralOffset,
|
1795 | pluralType: argType === "plural" ? "cardinal" : "ordinal",
|
1796 | location: location_2
|
1797 | },
|
1798 | err: null
|
1799 | };
|
1800 | }
|
1801 | }
|
1802 | default:
|
1803 | return this.error(ErrorKind.INVALID_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
|
1804 | }
|
1805 | };
|
1806 | Parser2.prototype.tryParseArgumentClose = function(openingBracePosition) {
|
1807 | if (this.isEOF() || this.char() !== 125) {
|
1808 | return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
|
1809 | }
|
1810 | this.bump();
|
1811 | return { val: true, err: null };
|
1812 | };
|
1813 | Parser2.prototype.parseSimpleArgStyleIfPossible = function() {
|
1814 | var nestedBraces = 0;
|
1815 | var startPosition = this.clonePosition();
|
1816 | while (!this.isEOF()) {
|
1817 | var ch = this.char();
|
1818 | switch (ch) {
|
1819 | case 39: {
|
1820 | this.bump();
|
1821 | var apostrophePosition = this.clonePosition();
|
1822 | if (!this.bumpUntil("'")) {
|
1823 | return this.error(ErrorKind.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE, createLocation(apostrophePosition, this.clonePosition()));
|
1824 | }
|
1825 | this.bump();
|
1826 | break;
|
1827 | }
|
1828 | case 123: {
|
1829 | nestedBraces += 1;
|
1830 | this.bump();
|
1831 | break;
|
1832 | }
|
1833 | case 125: {
|
1834 | if (nestedBraces > 0) {
|
1835 | nestedBraces -= 1;
|
1836 | } else {
|
1837 | return {
|
1838 | val: this.message.slice(startPosition.offset, this.offset()),
|
1839 | err: null
|
1840 | };
|
1841 | }
|
1842 | break;
|
1843 | }
|
1844 | default:
|
1845 | this.bump();
|
1846 | break;
|
1847 | }
|
1848 | }
|
1849 | return {
|
1850 | val: this.message.slice(startPosition.offset, this.offset()),
|
1851 | err: null
|
1852 | };
|
1853 | };
|
1854 | Parser2.prototype.parseNumberSkeletonFromString = function(skeleton, location) {
|
1855 | var tokens = [];
|
1856 | try {
|
1857 | tokens = parseNumberSkeletonFromString(skeleton);
|
1858 | } catch (e) {
|
1859 | return this.error(ErrorKind.INVALID_NUMBER_SKELETON, location);
|
1860 | }
|
1861 | return {
|
1862 | val: {
|
1863 | type: SKELETON_TYPE.number,
|
1864 | tokens: tokens,
|
1865 | location: location,
|
1866 | parsedOptions: this.shouldParseSkeletons ? parseNumberSkeleton(tokens) : {}
|
1867 | },
|
1868 | err: null
|
1869 | };
|
1870 | };
|
1871 | Parser2.prototype.tryParsePluralOrSelectOptions = function(nestingLevel, parentArgType, expectCloseTag, parsedFirstIdentifier) {
|
1872 | var _a2;
|
1873 | var hasOtherClause = false;
|
1874 | var options = [];
|
1875 | var parsedSelectors = new Set();
|
1876 | var selector = parsedFirstIdentifier.value, selectorLocation = parsedFirstIdentifier.location;
|
1877 | while (true) {
|
1878 | if (selector.length === 0) {
|
1879 | var startPosition = this.clonePosition();
|
1880 | if (parentArgType !== "select" && this.bumpIf("=")) {
|
1881 | var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, ErrorKind.INVALID_PLURAL_ARGUMENT_SELECTOR);
|
1882 | if (result.err) {
|
1883 | return result;
|
1884 | }
|
1885 | selectorLocation = createLocation(startPosition, this.clonePosition());
|
1886 | selector = this.message.slice(startPosition.offset, this.offset());
|
1887 | } else {
|
1888 | break;
|
1889 | }
|
1890 | }
|
1891 | if (parsedSelectors.has(selector)) {
|
1892 | return this.error(parentArgType === "select" ? ErrorKind.DUPLICATE_SELECT_ARGUMENT_SELECTOR : ErrorKind.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, selectorLocation);
|
1893 | }
|
1894 | if (selector === "other") {
|
1895 | hasOtherClause = true;
|
1896 | }
|
1897 | this.bumpSpace();
|
1898 | var openingBracePosition = this.clonePosition();
|
1899 | if (!this.bumpIf("{")) {
|
1900 | return this.error(parentArgType === "select" ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT, createLocation(this.clonePosition(), this.clonePosition()));
|
1901 | }
|
1902 | var fragmentResult = this.parseMessage(nestingLevel + 1, parentArgType, expectCloseTag);
|
1903 | if (fragmentResult.err) {
|
1904 | return fragmentResult;
|
1905 | }
|
1906 | var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
|
1907 | if (argCloseResult.err) {
|
1908 | return argCloseResult;
|
1909 | }
|
1910 | options.push([
|
1911 | selector,
|
1912 | {
|
1913 | value: fragmentResult.val,
|
1914 | location: createLocation(openingBracePosition, this.clonePosition())
|
1915 | }
|
1916 | ]);
|
1917 | parsedSelectors.add(selector);
|
1918 | this.bumpSpace();
|
1919 | _a2 = this.parseIdentifierIfPossible(), selector = _a2.value, selectorLocation = _a2.location;
|
1920 | }
|
1921 | if (options.length === 0) {
|
1922 | return this.error(parentArgType === "select" ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, createLocation(this.clonePosition(), this.clonePosition()));
|
1923 | }
|
1924 | if (this.requiresOtherClause && !hasOtherClause) {
|
1925 | return this.error(ErrorKind.MISSING_OTHER_CLAUSE, createLocation(this.clonePosition(), this.clonePosition()));
|
1926 | }
|
1927 | return { val: options, err: null };
|
1928 | };
|
1929 | Parser2.prototype.tryParseDecimalInteger = function(expectNumberError, invalidNumberError) {
|
1930 | var sign = 1;
|
1931 | var startingPosition = this.clonePosition();
|
1932 | if (this.bumpIf("+")) {
|
1933 | } else if (this.bumpIf("-")) {
|
1934 | sign = -1;
|
1935 | }
|
1936 | var hasDigits = false;
|
1937 | var decimal = 0;
|
1938 | while (!this.isEOF()) {
|
1939 | var ch = this.char();
|
1940 | if (ch >= 48 && ch <= 57) {
|
1941 | hasDigits = true;
|
1942 | decimal = decimal * 10 + (ch - 48);
|
1943 | this.bump();
|
1944 | } else {
|
1945 | break;
|
1946 | }
|
1947 | }
|
1948 | var location = createLocation(startingPosition, this.clonePosition());
|
1949 | if (!hasDigits) {
|
1950 | return this.error(expectNumberError, location);
|
1951 | }
|
1952 | decimal *= sign;
|
1953 | if (!isSafeInteger(decimal)) {
|
1954 | return this.error(invalidNumberError, location);
|
1955 | }
|
1956 | return { val: decimal, err: null };
|
1957 | };
|
1958 | Parser2.prototype.offset = function() {
|
1959 | return this.position.offset;
|
1960 | };
|
1961 | Parser2.prototype.isEOF = function() {
|
1962 | return this.offset() === this.message.length;
|
1963 | };
|
1964 | Parser2.prototype.clonePosition = function() {
|
1965 | return {
|
1966 | offset: this.position.offset,
|
1967 | line: this.position.line,
|
1968 | column: this.position.column
|
1969 | };
|
1970 | };
|
1971 | Parser2.prototype.char = function() {
|
1972 | var offset = this.position.offset;
|
1973 | if (offset >= this.message.length) {
|
1974 | throw Error("out of bound");
|
1975 | }
|
1976 | var code = codePointAt(this.message, offset);
|
1977 | if (code === void 0) {
|
1978 | throw Error("Offset " + offset + " is at invalid UTF-16 code unit boundary");
|
1979 | }
|
1980 | return code;
|
1981 | };
|
1982 | Parser2.prototype.error = function(kind, location) {
|
1983 | return {
|
1984 | val: null,
|
1985 | err: {
|
1986 | kind: kind,
|
1987 | message: this.message,
|
1988 | location: location
|
1989 | }
|
1990 | };
|
1991 | };
|
1992 | Parser2.prototype.bump = function() {
|
1993 | if (this.isEOF()) {
|
1994 | return;
|
1995 | }
|
1996 | var code = this.char();
|
1997 | if (code === 10) {
|
1998 | this.position.line += 1;
|
1999 | this.position.column = 1;
|
2000 | this.position.offset += 1;
|
2001 | } else {
|
2002 | this.position.column += 1;
|
2003 | this.position.offset += code < 65536 ? 1 : 2;
|
2004 | }
|
2005 | };
|
2006 | Parser2.prototype.bumpIf = function(prefix) {
|
2007 | if (startsWith(this.message, prefix, this.offset())) {
|
2008 | for (var i = 0; i < prefix.length; i++) {
|
2009 | this.bump();
|
2010 | }
|
2011 | return true;
|
2012 | }
|
2013 | return false;
|
2014 | };
|
2015 | Parser2.prototype.bumpUntil = function(pattern) {
|
2016 | var currentOffset = this.offset();
|
2017 | var index = this.message.indexOf(pattern, currentOffset);
|
2018 | if (index >= 0) {
|
2019 | this.bumpTo(index);
|
2020 | return true;
|
2021 | } else {
|
2022 | this.bumpTo(this.message.length);
|
2023 | return false;
|
2024 | }
|
2025 | };
|
2026 | Parser2.prototype.bumpTo = function(targetOffset) {
|
2027 | if (this.offset() > targetOffset) {
|
2028 | throw Error("targetOffset " + targetOffset + " must be greater than or equal to the current offset " + this.offset());
|
2029 | }
|
2030 | targetOffset = Math.min(targetOffset, this.message.length);
|
2031 | while (true) {
|
2032 | var offset = this.offset();
|
2033 | if (offset === targetOffset) {
|
2034 | break;
|
2035 | }
|
2036 | if (offset > targetOffset) {
|
2037 | throw Error("targetOffset " + targetOffset + " is at invalid UTF-16 code unit boundary");
|
2038 | }
|
2039 | this.bump();
|
2040 | if (this.isEOF()) {
|
2041 | break;
|
2042 | }
|
2043 | }
|
2044 | };
|
2045 | Parser2.prototype.bumpSpace = function() {
|
2046 | while (!this.isEOF() && _isWhiteSpace(this.char())) {
|
2047 | this.bump();
|
2048 | }
|
2049 | };
|
2050 | Parser2.prototype.peek = function() {
|
2051 | if (this.isEOF()) {
|
2052 | return null;
|
2053 | }
|
2054 | var code = this.char();
|
2055 | var offset = this.offset();
|
2056 | var nextCode = this.message.charCodeAt(offset + (code >= 65536 ? 2 : 1));
|
2057 | return nextCode !== null && nextCode !== void 0 ? nextCode : null;
|
2058 | };
|
2059 | return Parser2;
|
2060 | }();
|
2061 | function _isAlpha(codepoint) {
|
2062 | return codepoint >= 97 && codepoint <= 122 || codepoint >= 65 && codepoint <= 90;
|
2063 | }
|
2064 | function _isAlphaOrSlash(codepoint) {
|
2065 | return _isAlpha(codepoint) || codepoint === 47;
|
2066 | }
|
2067 | function _isPotentialElementNameChar(c) {
|
2068 | 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;
|
2069 | }
|
2070 | function _isWhiteSpace(c) {
|
2071 | return c >= 9 && c <= 13 || c === 32 || c === 133 || c >= 8206 && c <= 8207 || c === 8232 || c === 8233;
|
2072 | }
|
2073 | function _isPatternSyntax(c) {
|
2074 | 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;
|
2075 | }
|
2076 |
|
2077 |
|
2078 | function pruneLocation(els) {
|
2079 | els.forEach(function(el) {
|
2080 | delete el.location;
|
2081 | if (isSelectElement(el) || isPluralElement(el)) {
|
2082 | for (var k in el.options) {
|
2083 | delete el.options[k].location;
|
2084 | pruneLocation(el.options[k].value);
|
2085 | }
|
2086 | } else if (isNumberElement(el) && isNumberSkeleton(el.style)) {
|
2087 | delete el.style.location;
|
2088 | } else if ((isDateElement(el) || isTimeElement(el)) && isDateTimeSkeleton(el.style)) {
|
2089 | delete el.style.location;
|
2090 | } else if (isTagElement(el)) {
|
2091 | pruneLocation(el.children);
|
2092 | }
|
2093 | });
|
2094 | }
|
2095 | function parse(message, opts) {
|
2096 | if (opts === void 0) {
|
2097 | opts = {};
|
2098 | }
|
2099 | opts = __assign({ shouldParseSkeletons: true, requiresOtherClause: true }, opts);
|
2100 | var result = new Parser(message, opts).parse();
|
2101 | if (result.err) {
|
2102 | var error = SyntaxError(ErrorKind[result.err.kind]);
|
2103 | error.location = result.err.location;
|
2104 | error.originalMessage = result.err.message;
|
2105 | throw error;
|
2106 | }
|
2107 | if (!(opts === null || opts === void 0 ? void 0 : opts.captureLocation)) {
|
2108 | pruneLocation(result.val);
|
2109 | }
|
2110 | return result.val;
|
2111 | }
|
2112 |
|
2113 |
|
2114 | function memoize(fn, options) {
|
2115 | var cache = options && options.cache ? options.cache : cacheDefault;
|
2116 | var serializer = options && options.serializer ? options.serializer : serializerDefault;
|
2117 | var strategy = options && options.strategy ? options.strategy : strategyDefault;
|
2118 | return strategy(fn, {
|
2119 | cache: cache,
|
2120 | serializer: serializer
|
2121 | });
|
2122 | }
|
2123 | function isPrimitive(value) {
|
2124 | return value == null || typeof value === "number" || typeof value === "boolean";
|
2125 | }
|
2126 | function monadic(fn, cache, serializer, arg) {
|
2127 | var cacheKey = isPrimitive(arg) ? arg : serializer(arg);
|
2128 | var computedValue = cache.get(cacheKey);
|
2129 | if (typeof computedValue === "undefined") {
|
2130 | computedValue = fn.call(this, arg);
|
2131 | cache.set(cacheKey, computedValue);
|
2132 | }
|
2133 | return computedValue;
|
2134 | }
|
2135 | function variadic(fn, cache, serializer) {
|
2136 | var args = Array.prototype.slice.call(arguments, 3);
|
2137 | var cacheKey = serializer(args);
|
2138 | var computedValue = cache.get(cacheKey);
|
2139 | if (typeof computedValue === "undefined") {
|
2140 | computedValue = fn.apply(this, args);
|
2141 | cache.set(cacheKey, computedValue);
|
2142 | }
|
2143 | return computedValue;
|
2144 | }
|
2145 | function assemble(fn, context, strategy, cache, serialize) {
|
2146 | return strategy.bind(context, fn, cache, serialize);
|
2147 | }
|
2148 | function strategyDefault(fn, options) {
|
2149 | var strategy = fn.length === 1 ? monadic : variadic;
|
2150 | return assemble(fn, this, strategy, options.cache.create(), options.serializer);
|
2151 | }
|
2152 | function strategyVariadic(fn, options) {
|
2153 | return assemble(fn, this, variadic, options.cache.create(), options.serializer);
|
2154 | }
|
2155 | function strategyMonadic(fn, options) {
|
2156 | return assemble(fn, this, monadic, options.cache.create(), options.serializer);
|
2157 | }
|
2158 | var serializerDefault = function() {
|
2159 | return JSON.stringify(arguments);
|
2160 | };
|
2161 | function ObjectWithoutPrototypeCache() {
|
2162 | this.cache = Object.create(null);
|
2163 | }
|
2164 | ObjectWithoutPrototypeCache.prototype.get = function(key) {
|
2165 | return this.cache[key];
|
2166 | };
|
2167 | ObjectWithoutPrototypeCache.prototype.set = function(key, value) {
|
2168 | this.cache[key] = value;
|
2169 | };
|
2170 | var cacheDefault = {
|
2171 | create: function create() {
|
2172 | return new ObjectWithoutPrototypeCache();
|
2173 | }
|
2174 | };
|
2175 | var strategies = {
|
2176 | variadic: strategyVariadic,
|
2177 | monadic: strategyMonadic
|
2178 | };
|
2179 |
|
2180 |
|
2181 | var ErrorCode;
|
2182 | (function(ErrorCode2) {
|
2183 | ErrorCode2["MISSING_VALUE"] = "MISSING_VALUE";
|
2184 | ErrorCode2["INVALID_VALUE"] = "INVALID_VALUE";
|
2185 | ErrorCode2["MISSING_INTL_API"] = "MISSING_INTL_API";
|
2186 | })(ErrorCode || (ErrorCode = {}));
|
2187 | var FormatError = function(_super) {
|
2188 | __extends(FormatError2, _super);
|
2189 | function FormatError2(msg, code, originalMessage) {
|
2190 | var _this = _super.call(this, msg) || this;
|
2191 | _this.code = code;
|
2192 | _this.originalMessage = originalMessage;
|
2193 | return _this;
|
2194 | }
|
2195 | FormatError2.prototype.toString = function() {
|
2196 | return "[formatjs Error: " + this.code + "] " + this.message;
|
2197 | };
|
2198 | return FormatError2;
|
2199 | }(Error);
|
2200 | var InvalidValueError = function(_super) {
|
2201 | __extends(InvalidValueError2, _super);
|
2202 | function InvalidValueError2(variableId, value, options, originalMessage) {
|
2203 | return _super.call(this, 'Invalid values for "' + variableId + '": "' + value + '". Options are "' + Object.keys(options).join('", "') + '"', ErrorCode.INVALID_VALUE, originalMessage) || this;
|
2204 | }
|
2205 | return InvalidValueError2;
|
2206 | }(FormatError);
|
2207 | var InvalidValueTypeError = function(_super) {
|
2208 | __extends(InvalidValueTypeError2, _super);
|
2209 | function InvalidValueTypeError2(value, type, originalMessage) {
|
2210 | return _super.call(this, 'Value for "' + value + '" must be of type ' + type, ErrorCode.INVALID_VALUE, originalMessage) || this;
|
2211 | }
|
2212 | return InvalidValueTypeError2;
|
2213 | }(FormatError);
|
2214 | var MissingValueError = function(_super) {
|
2215 | __extends(MissingValueError2, _super);
|
2216 | function MissingValueError2(variableId, originalMessage) {
|
2217 | return _super.call(this, 'The intl string context variable "' + variableId + '" was not provided to the string "' + originalMessage + '"', ErrorCode.MISSING_VALUE, originalMessage) || this;
|
2218 | }
|
2219 | return MissingValueError2;
|
2220 | }(FormatError);
|
2221 |
|
2222 |
|
2223 | var PART_TYPE;
|
2224 | (function(PART_TYPE2) {
|
2225 | PART_TYPE2[PART_TYPE2["literal"] = 0] = "literal";
|
2226 | PART_TYPE2[PART_TYPE2["object"] = 1] = "object";
|
2227 | })(PART_TYPE || (PART_TYPE = {}));
|
2228 | function mergeLiteral(parts) {
|
2229 | if (parts.length < 2) {
|
2230 | return parts;
|
2231 | }
|
2232 | return parts.reduce(function(all, part) {
|
2233 | var lastPart = all[all.length - 1];
|
2234 | if (!lastPart || lastPart.type !== PART_TYPE.literal || part.type !== PART_TYPE.literal) {
|
2235 | all.push(part);
|
2236 | } else {
|
2237 | lastPart.value += part.value;
|
2238 | }
|
2239 | return all;
|
2240 | }, []);
|
2241 | }
|
2242 | function isFormatXMLElementFn(el) {
|
2243 | return typeof el === "function";
|
2244 | }
|
2245 | function formatToParts2(els, locales, formatters, formats, values, currentPluralValue, originalMessage) {
|
2246 | if (els.length === 1 && isLiteralElement(els[0])) {
|
2247 | return [
|
2248 | {
|
2249 | type: PART_TYPE.literal,
|
2250 | value: els[0].value
|
2251 | }
|
2252 | ];
|
2253 | }
|
2254 | var result = [];
|
2255 | for (var _i = 0, els_1 = els; _i < els_1.length; _i++) {
|
2256 | var el = els_1[_i];
|
2257 | if (isLiteralElement(el)) {
|
2258 | result.push({
|
2259 | type: PART_TYPE.literal,
|
2260 | value: el.value
|
2261 | });
|
2262 | continue;
|
2263 | }
|
2264 | if (isPoundElement(el)) {
|
2265 | if (typeof currentPluralValue === "number") {
|
2266 | result.push({
|
2267 | type: PART_TYPE.literal,
|
2268 | value: formatters.getNumberFormat(locales).format(currentPluralValue)
|
2269 | });
|
2270 | }
|
2271 | continue;
|
2272 | }
|
2273 | var varName = el.value;
|
2274 | if (!(values && varName in values)) {
|
2275 | throw new MissingValueError(varName, originalMessage);
|
2276 | }
|
2277 | var value = values[varName];
|
2278 | if (isArgumentElement(el)) {
|
2279 | if (!value || typeof value === "string" || typeof value === "number") {
|
2280 | value = typeof value === "string" || typeof value === "number" ? String(value) : "";
|
2281 | }
|
2282 | result.push({
|
2283 | type: typeof value === "string" ? PART_TYPE.literal : PART_TYPE.object,
|
2284 | value: value
|
2285 | });
|
2286 | continue;
|
2287 | }
|
2288 | if (isDateElement(el)) {
|
2289 | var style = typeof el.style === "string" ? formats.date[el.style] : isDateTimeSkeleton(el.style) ? el.style.parsedOptions : void 0;
|
2290 | result.push({
|
2291 | type: PART_TYPE.literal,
|
2292 | value: formatters.getDateTimeFormat(locales, style).format(value)
|
2293 | });
|
2294 | continue;
|
2295 | }
|
2296 | if (isTimeElement(el)) {
|
2297 | var style = typeof el.style === "string" ? formats.time[el.style] : isDateTimeSkeleton(el.style) ? el.style.parsedOptions : void 0;
|
2298 | result.push({
|
2299 | type: PART_TYPE.literal,
|
2300 | value: formatters.getDateTimeFormat(locales, style).format(value)
|
2301 | });
|
2302 | continue;
|
2303 | }
|
2304 | if (isNumberElement(el)) {
|
2305 | var style = typeof el.style === "string" ? formats.number[el.style] : isNumberSkeleton(el.style) ? el.style.parsedOptions : void 0;
|
2306 | if (style && style.scale) {
|
2307 | value = value * (style.scale || 1);
|
2308 | }
|
2309 | result.push({
|
2310 | type: PART_TYPE.literal,
|
2311 | value: formatters.getNumberFormat(locales, style).format(value)
|
2312 | });
|
2313 | continue;
|
2314 | }
|
2315 | if (isTagElement(el)) {
|
2316 | var children = el.children, value_1 = el.value;
|
2317 | var formatFn = values[value_1];
|
2318 | if (!isFormatXMLElementFn(formatFn)) {
|
2319 | throw new InvalidValueTypeError(value_1, "function", originalMessage);
|
2320 | }
|
2321 | var parts = formatToParts2(children, locales, formatters, formats, values, currentPluralValue);
|
2322 | var chunks = formatFn(parts.map(function(p) {
|
2323 | return p.value;
|
2324 | }));
|
2325 | if (!Array.isArray(chunks)) {
|
2326 | chunks = [chunks];
|
2327 | }
|
2328 | result.push.apply(result, chunks.map(function(c) {
|
2329 | return {
|
2330 | type: typeof c === "string" ? PART_TYPE.literal : PART_TYPE.object,
|
2331 | value: c
|
2332 | };
|
2333 | }));
|
2334 | }
|
2335 | if (isSelectElement(el)) {
|
2336 | var opt = el.options[value] || el.options.other;
|
2337 | if (!opt) {
|
2338 | throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
|
2339 | }
|
2340 | result.push.apply(result, formatToParts2(opt.value, locales, formatters, formats, values));
|
2341 | continue;
|
2342 | }
|
2343 | if (isPluralElement(el)) {
|
2344 | var opt = el.options["=" + value];
|
2345 | if (!opt) {
|
2346 | if (!Intl.PluralRules) {
|
2347 | throw new FormatError('Intl.PluralRules is not available in this environment.\nTry polyfilling it using "@formatjs/intl-pluralrules"\n', ErrorCode.MISSING_INTL_API, originalMessage);
|
2348 | }
|
2349 | var rule = formatters.getPluralRules(locales, { type: el.pluralType }).select(value - (el.offset || 0));
|
2350 | opt = el.options[rule] || el.options.other;
|
2351 | }
|
2352 | if (!opt) {
|
2353 | throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
|
2354 | }
|
2355 | result.push.apply(result, formatToParts2(opt.value, locales, formatters, formats, values, value - (el.offset || 0)));
|
2356 | continue;
|
2357 | }
|
2358 | }
|
2359 | return mergeLiteral(result);
|
2360 | }
|
2361 |
|
2362 |
|
2363 | function mergeConfig(c1, c2) {
|
2364 | if (!c2) {
|
2365 | return c1;
|
2366 | }
|
2367 | return __assign(__assign(__assign({}, c1 || {}), c2 || {}), Object.keys(c1).reduce(function(all, k) {
|
2368 | all[k] = __assign(__assign({}, c1[k]), c2[k] || {});
|
2369 | return all;
|
2370 | }, {}));
|
2371 | }
|
2372 | function mergeConfigs(defaultConfig, configs) {
|
2373 | if (!configs) {
|
2374 | return defaultConfig;
|
2375 | }
|
2376 | return Object.keys(defaultConfig).reduce(function(all, k) {
|
2377 | all[k] = mergeConfig(defaultConfig[k], configs[k]);
|
2378 | return all;
|
2379 | }, __assign({}, defaultConfig));
|
2380 | }
|
2381 | function createFastMemoizeCache(store) {
|
2382 | return {
|
2383 | create: function() {
|
2384 | return {
|
2385 | get: function(key) {
|
2386 | return store[key];
|
2387 | },
|
2388 | set: function(key, value) {
|
2389 | store[key] = value;
|
2390 | }
|
2391 | };
|
2392 | }
|
2393 | };
|
2394 | }
|
2395 | function createDefaultFormatters(cache) {
|
2396 | if (cache === void 0) {
|
2397 | cache = {
|
2398 | number: {},
|
2399 | dateTime: {},
|
2400 | pluralRules: {}
|
2401 | };
|
2402 | }
|
2403 | return {
|
2404 | getNumberFormat: memoize(function() {
|
2405 | var _a2;
|
2406 | var args = [];
|
2407 | for (var _i = 0; _i < arguments.length; _i++) {
|
2408 | args[_i] = arguments[_i];
|
2409 | }
|
2410 | return new ((_a2 = Intl.NumberFormat).bind.apply(_a2, __spreadArray([void 0], args)))();
|
2411 | }, {
|
2412 | cache: createFastMemoizeCache(cache.number),
|
2413 | strategy: strategies.variadic
|
2414 | }),
|
2415 | getDateTimeFormat: memoize(function() {
|
2416 | var _a2;
|
2417 | var args = [];
|
2418 | for (var _i = 0; _i < arguments.length; _i++) {
|
2419 | args[_i] = arguments[_i];
|
2420 | }
|
2421 | return new ((_a2 = Intl.DateTimeFormat).bind.apply(_a2, __spreadArray([void 0], args)))();
|
2422 | }, {
|
2423 | cache: createFastMemoizeCache(cache.dateTime),
|
2424 | strategy: strategies.variadic
|
2425 | }),
|
2426 | getPluralRules: memoize(function() {
|
2427 | var _a2;
|
2428 | var args = [];
|
2429 | for (var _i = 0; _i < arguments.length; _i++) {
|
2430 | args[_i] = arguments[_i];
|
2431 | }
|
2432 | return new ((_a2 = Intl.PluralRules).bind.apply(_a2, __spreadArray([void 0], args)))();
|
2433 | }, {
|
2434 | cache: createFastMemoizeCache(cache.pluralRules),
|
2435 | strategy: strategies.variadic
|
2436 | })
|
2437 | };
|
2438 | }
|
2439 | var IntlMessageFormat = function() {
|
2440 | function IntlMessageFormat2(message, locales, overrideFormats, opts) {
|
2441 | var _this = this;
|
2442 | if (locales === void 0) {
|
2443 | locales = IntlMessageFormat2.defaultLocale;
|
2444 | }
|
2445 | this.formatterCache = {
|
2446 | number: {},
|
2447 | dateTime: {},
|
2448 | pluralRules: {}
|
2449 | };
|
2450 | this.format = function(values) {
|
2451 | var parts = _this.formatToParts(values);
|
2452 | if (parts.length === 1) {
|
2453 | return parts[0].value;
|
2454 | }
|
2455 | var result = parts.reduce(function(all, part) {
|
2456 | if (!all.length || part.type !== PART_TYPE.literal || typeof all[all.length - 1] !== "string") {
|
2457 | all.push(part.value);
|
2458 | } else {
|
2459 | all[all.length - 1] += part.value;
|
2460 | }
|
2461 | return all;
|
2462 | }, []);
|
2463 | if (result.length <= 1) {
|
2464 | return result[0] || "";
|
2465 | }
|
2466 | return result;
|
2467 | };
|
2468 | this.formatToParts = function(values) {
|
2469 | return formatToParts2(_this.ast, _this.locales, _this.formatters, _this.formats, values, void 0, _this.message);
|
2470 | };
|
2471 | this.resolvedOptions = function() {
|
2472 | return {
|
2473 | locale: Intl.NumberFormat.supportedLocalesOf(_this.locales)[0]
|
2474 | };
|
2475 | };
|
2476 | this.getAst = function() {
|
2477 | return _this.ast;
|
2478 | };
|
2479 | if (typeof message === "string") {
|
2480 | this.message = message;
|
2481 | if (!IntlMessageFormat2.__parse) {
|
2482 | throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");
|
2483 | }
|
2484 | this.ast = IntlMessageFormat2.__parse(message, {
|
2485 | ignoreTag: opts === null || opts === void 0 ? void 0 : opts.ignoreTag
|
2486 | });
|
2487 | } else {
|
2488 | this.ast = message;
|
2489 | }
|
2490 | if (!Array.isArray(this.ast)) {
|
2491 | throw new TypeError("A message must be provided as a String or AST.");
|
2492 | }
|
2493 | this.formats = mergeConfigs(IntlMessageFormat2.formats, overrideFormats);
|
2494 | this.locales = locales;
|
2495 | this.formatters = opts && opts.formatters || createDefaultFormatters(this.formatterCache);
|
2496 | }
|
2497 | Object.defineProperty(IntlMessageFormat2, "defaultLocale", {
|
2498 | get: function() {
|
2499 | if (!IntlMessageFormat2.memoizedDefaultLocale) {
|
2500 | IntlMessageFormat2.memoizedDefaultLocale = new Intl.NumberFormat().resolvedOptions().locale;
|
2501 | }
|
2502 | return IntlMessageFormat2.memoizedDefaultLocale;
|
2503 | },
|
2504 | enumerable: false,
|
2505 | configurable: true
|
2506 | });
|
2507 | IntlMessageFormat2.memoizedDefaultLocale = null;
|
2508 | IntlMessageFormat2.__parse = parse;
|
2509 | IntlMessageFormat2.formats = {
|
2510 | number: {
|
2511 | integer: {
|
2512 | maximumFractionDigits: 0
|
2513 | },
|
2514 | currency: {
|
2515 | style: "currency"
|
2516 | },
|
2517 | percent: {
|
2518 | style: "percent"
|
2519 | }
|
2520 | },
|
2521 | date: {
|
2522 | short: {
|
2523 | month: "numeric",
|
2524 | day: "numeric",
|
2525 | year: "2-digit"
|
2526 | },
|
2527 | medium: {
|
2528 | month: "short",
|
2529 | day: "numeric",
|
2530 | year: "numeric"
|
2531 | },
|
2532 | long: {
|
2533 | month: "long",
|
2534 | day: "numeric",
|
2535 | year: "numeric"
|
2536 | },
|
2537 | full: {
|
2538 | weekday: "long",
|
2539 | month: "long",
|
2540 | day: "numeric",
|
2541 | year: "numeric"
|
2542 | }
|
2543 | },
|
2544 | time: {
|
2545 | short: {
|
2546 | hour: "numeric",
|
2547 | minute: "numeric"
|
2548 | },
|
2549 | medium: {
|
2550 | hour: "numeric",
|
2551 | minute: "numeric",
|
2552 | second: "numeric"
|
2553 | },
|
2554 | long: {
|
2555 | hour: "numeric",
|
2556 | minute: "numeric",
|
2557 | second: "numeric",
|
2558 | timeZoneName: "short"
|
2559 | },
|
2560 | full: {
|
2561 | hour: "numeric",
|
2562 | minute: "numeric",
|
2563 | second: "numeric",
|
2564 | timeZoneName: "short"
|
2565 | }
|
2566 | }
|
2567 | };
|
2568 | return IntlMessageFormat2;
|
2569 | }();
|
2570 |
|
2571 |
|
2572 | var IntlErrorCode;
|
2573 | (function(IntlErrorCode2) {
|
2574 | IntlErrorCode2["FORMAT_ERROR"] = "FORMAT_ERROR";
|
2575 | IntlErrorCode2["UNSUPPORTED_FORMATTER"] = "UNSUPPORTED_FORMATTER";
|
2576 | IntlErrorCode2["INVALID_CONFIG"] = "INVALID_CONFIG";
|
2577 | IntlErrorCode2["MISSING_DATA"] = "MISSING_DATA";
|
2578 | IntlErrorCode2["MISSING_TRANSLATION"] = "MISSING_TRANSLATION";
|
2579 | })(IntlErrorCode || (IntlErrorCode = {}));
|
2580 | var IntlError = function(_super) {
|
2581 | __extends(IntlError2, _super);
|
2582 | function IntlError2(code, message, exception) {
|
2583 | var _this = _super.call(this, "[@formatjs/intl Error " + code + "] " + message + " \n" + (exception ? "\n" + exception.message + "\n" + exception.stack : "")) || this;
|
2584 | _this.code = code;
|
2585 | if (typeof Error.captureStackTrace === "function") {
|
2586 | Error.captureStackTrace(_this, IntlError2);
|
2587 | }
|
2588 | return _this;
|
2589 | }
|
2590 | return IntlError2;
|
2591 | }(Error);
|
2592 | var UnsupportedFormatterError = function(_super) {
|
2593 | __extends(UnsupportedFormatterError2, _super);
|
2594 | function UnsupportedFormatterError2(message, exception) {
|
2595 | return _super.call(this, IntlErrorCode.UNSUPPORTED_FORMATTER, message, exception) || this;
|
2596 | }
|
2597 | return UnsupportedFormatterError2;
|
2598 | }(IntlError);
|
2599 | var InvalidConfigError = function(_super) {
|
2600 | __extends(InvalidConfigError2, _super);
|
2601 | function InvalidConfigError2(message, exception) {
|
2602 | return _super.call(this, IntlErrorCode.INVALID_CONFIG, message, exception) || this;
|
2603 | }
|
2604 | return InvalidConfigError2;
|
2605 | }(IntlError);
|
2606 | var MissingDataError = function(_super) {
|
2607 | __extends(MissingDataError2, _super);
|
2608 | function MissingDataError2(message, exception) {
|
2609 | return _super.call(this, IntlErrorCode.MISSING_DATA, message, exception) || this;
|
2610 | }
|
2611 | return MissingDataError2;
|
2612 | }(IntlError);
|
2613 | var MessageFormatError = function(_super) {
|
2614 | __extends(MessageFormatError2, _super);
|
2615 | function MessageFormatError2(message, locale, descriptor, exception) {
|
2616 | var _this = _super.call(this, IntlErrorCode.FORMAT_ERROR, message + " \nLocale: " + locale + "\nMessageID: " + (descriptor === null || descriptor === void 0 ? void 0 : descriptor.id) + "\nDefault Message: " + (descriptor === null || descriptor === void 0 ? void 0 : descriptor.defaultMessage) + "\nDescription: " + (descriptor === null || descriptor === void 0 ? void 0 : descriptor.description) + " \n", exception) || this;
|
2617 | _this.descriptor = descriptor;
|
2618 | return _this;
|
2619 | }
|
2620 | return MessageFormatError2;
|
2621 | }(IntlError);
|
2622 | var MissingTranslationError = function(_super) {
|
2623 | __extends(MissingTranslationError2, _super);
|
2624 | function MissingTranslationError2(descriptor, locale) {
|
2625 | var _this = _super.call(this, IntlErrorCode.MISSING_TRANSLATION, 'Missing message: "' + descriptor.id + '" for locale "' + locale + '", using ' + (descriptor.defaultMessage ? "default message" : "id") + " as fallback.") || this;
|
2626 | _this.descriptor = descriptor;
|
2627 | return _this;
|
2628 | }
|
2629 | return MissingTranslationError2;
|
2630 | }(IntlError);
|
2631 |
|
2632 |
|
2633 | function filterProps(props, whitelist, defaults) {
|
2634 | if (defaults === void 0) {
|
2635 | defaults = {};
|
2636 | }
|
2637 | return whitelist.reduce(function(filtered, name) {
|
2638 | if (name in props) {
|
2639 | filtered[name] = props[name];
|
2640 | } else if (name in defaults) {
|
2641 | filtered[name] = defaults[name];
|
2642 | }
|
2643 | return filtered;
|
2644 | }, {});
|
2645 | }
|
2646 | var defaultErrorHandler = function(error) {
|
2647 | if (true) {
|
2648 | console.error(error);
|
2649 | }
|
2650 | };
|
2651 | var DEFAULT_INTL_CONFIG = {
|
2652 | formats: {},
|
2653 | messages: {},
|
2654 | timeZone: void 0,
|
2655 | defaultLocale: "en",
|
2656 | defaultFormats: {},
|
2657 | onError: defaultErrorHandler
|
2658 | };
|
2659 | function createIntlCache() {
|
2660 | return {
|
2661 | dateTime: {},
|
2662 | number: {},
|
2663 | message: {},
|
2664 | relativeTime: {},
|
2665 | pluralRules: {},
|
2666 | list: {},
|
2667 | displayNames: {}
|
2668 | };
|
2669 | }
|
2670 | function createFastMemoizeCache2(store) {
|
2671 | return {
|
2672 | create: function() {
|
2673 | return {
|
2674 | get: function(key) {
|
2675 | return store[key];
|
2676 | },
|
2677 | set: function(key, value) {
|
2678 | store[key] = value;
|
2679 | }
|
2680 | };
|
2681 | }
|
2682 | };
|
2683 | }
|
2684 | function createFormatters(cache) {
|
2685 | if (cache === void 0) {
|
2686 | cache = createIntlCache();
|
2687 | }
|
2688 | var RelativeTimeFormat = Intl.RelativeTimeFormat;
|
2689 | var ListFormat = Intl.ListFormat;
|
2690 | var DisplayNames = Intl.DisplayNames;
|
2691 | var getDateTimeFormat = memoize(function() {
|
2692 | var _a2;
|
2693 | var args = [];
|
2694 | for (var _i = 0; _i < arguments.length; _i++) {
|
2695 | args[_i] = arguments[_i];
|
2696 | }
|
2697 | return new ((_a2 = Intl.DateTimeFormat).bind.apply(_a2, __spreadArray([void 0], args)))();
|
2698 | }, {
|
2699 | cache: createFastMemoizeCache2(cache.dateTime),
|
2700 | strategy: strategies.variadic
|
2701 | });
|
2702 | var getNumberFormat = memoize(function() {
|
2703 | var _a2;
|
2704 | var args = [];
|
2705 | for (var _i = 0; _i < arguments.length; _i++) {
|
2706 | args[_i] = arguments[_i];
|
2707 | }
|
2708 | return new ((_a2 = Intl.NumberFormat).bind.apply(_a2, __spreadArray([void 0], args)))();
|
2709 | }, {
|
2710 | cache: createFastMemoizeCache2(cache.number),
|
2711 | strategy: strategies.variadic
|
2712 | });
|
2713 | var getPluralRules = memoize(function() {
|
2714 | var _a2;
|
2715 | var args = [];
|
2716 | for (var _i = 0; _i < arguments.length; _i++) {
|
2717 | args[_i] = arguments[_i];
|
2718 | }
|
2719 | return new ((_a2 = Intl.PluralRules).bind.apply(_a2, __spreadArray([void 0], args)))();
|
2720 | }, {
|
2721 | cache: createFastMemoizeCache2(cache.pluralRules),
|
2722 | strategy: strategies.variadic
|
2723 | });
|
2724 | return {
|
2725 | getDateTimeFormat: getDateTimeFormat,
|
2726 | getNumberFormat: getNumberFormat,
|
2727 | getMessageFormat: memoize(function(message, locales, overrideFormats, opts) {
|
2728 | return new IntlMessageFormat(message, locales, overrideFormats, __assign({ formatters: {
|
2729 | getNumberFormat: getNumberFormat,
|
2730 | getDateTimeFormat: getDateTimeFormat,
|
2731 | getPluralRules: getPluralRules
|
2732 | } }, opts || {}));
|
2733 | }, {
|
2734 | cache: createFastMemoizeCache2(cache.message),
|
2735 | strategy: strategies.variadic
|
2736 | }),
|
2737 | getRelativeTimeFormat: memoize(function() {
|
2738 | var args = [];
|
2739 | for (var _i = 0; _i < arguments.length; _i++) {
|
2740 | args[_i] = arguments[_i];
|
2741 | }
|
2742 | return new (RelativeTimeFormat.bind.apply(RelativeTimeFormat, __spreadArray([void 0], args)))();
|
2743 | }, {
|
2744 | cache: createFastMemoizeCache2(cache.relativeTime),
|
2745 | strategy: strategies.variadic
|
2746 | }),
|
2747 | getPluralRules: getPluralRules,
|
2748 | getListFormat: memoize(function() {
|
2749 | var args = [];
|
2750 | for (var _i = 0; _i < arguments.length; _i++) {
|
2751 | args[_i] = arguments[_i];
|
2752 | }
|
2753 | return new (ListFormat.bind.apply(ListFormat, __spreadArray([void 0], args)))();
|
2754 | }, {
|
2755 | cache: createFastMemoizeCache2(cache.list),
|
2756 | strategy: strategies.variadic
|
2757 | }),
|
2758 | getDisplayNames: memoize(function() {
|
2759 | var args = [];
|
2760 | for (var _i = 0; _i < arguments.length; _i++) {
|
2761 | args[_i] = arguments[_i];
|
2762 | }
|
2763 | return new (DisplayNames.bind.apply(DisplayNames, __spreadArray([void 0], args)))();
|
2764 | }, {
|
2765 | cache: createFastMemoizeCache2(cache.displayNames),
|
2766 | strategy: strategies.variadic
|
2767 | })
|
2768 | };
|
2769 | }
|
2770 | function getNamedFormat(formats, type, name, onError) {
|
2771 | var formatType = formats && formats[type];
|
2772 | var format;
|
2773 | if (formatType) {
|
2774 | format = formatType[name];
|
2775 | }
|
2776 | if (format) {
|
2777 | return format;
|
2778 | }
|
2779 | onError(new UnsupportedFormatterError("No " + type + " format named: " + name));
|
2780 | }
|
2781 |
|
2782 |
|
2783 | function setTimeZoneInOptions(opts, timeZone) {
|
2784 | return Object.keys(opts).reduce(function(all, k) {
|
2785 | all[k] = __assign({ timeZone: timeZone }, opts[k]);
|
2786 | return all;
|
2787 | }, {});
|
2788 | }
|
2789 | function deepMergeOptions(opts1, opts2) {
|
2790 | var keys = Object.keys(__assign(__assign({}, opts1), opts2));
|
2791 | return keys.reduce(function(all, k) {
|
2792 | all[k] = __assign(__assign({}, opts1[k] || {}), opts2[k] || {});
|
2793 | return all;
|
2794 | }, {});
|
2795 | }
|
2796 | function deepMergeFormatsAndSetTimeZone(f1, timeZone) {
|
2797 | if (!timeZone) {
|
2798 | return f1;
|
2799 | }
|
2800 | var mfFormats = IntlMessageFormat.formats;
|
2801 | return __assign(__assign(__assign({}, mfFormats), f1), { date: deepMergeOptions(setTimeZoneInOptions(mfFormats.date, timeZone), setTimeZoneInOptions(f1.date || {}, timeZone)), time: deepMergeOptions(setTimeZoneInOptions(mfFormats.time, timeZone), setTimeZoneInOptions(f1.time || {}, timeZone)) });
|
2802 | }
|
2803 | function formatMessage(_a2, state, messageDescriptor, values, opts) {
|
2804 | var locale = _a2.locale, formats = _a2.formats, messages = _a2.messages, defaultLocale = _a2.defaultLocale, defaultFormats = _a2.defaultFormats, onError = _a2.onError, timeZone = _a2.timeZone, defaultRichTextElements = _a2.defaultRichTextElements;
|
2805 | if (messageDescriptor === void 0) {
|
2806 | messageDescriptor = { id: "" };
|
2807 | }
|
2808 | var msgId = messageDescriptor.id, defaultMessage = messageDescriptor.defaultMessage;
|
2809 | invariant(!!msgId, "[@formatjs/intl] An `id` must be provided to format a message. You can either:\n1. Configure your build toolchain with [babel-plugin-formatjs](https://formatjs.io/docs/tooling/babel-plugin)\nor [@formatjs/ts-transformer](https://formatjs.io/docs/tooling/ts-transformer) OR\n2. Configure your `eslint` config to include [eslint-plugin-formatjs](https://formatjs.io/docs/tooling/linter#enforce-id)\nto autofix this issue");
|
2810 | var id = String(msgId);
|
2811 | var message = messages && Object.prototype.hasOwnProperty.call(messages, id) && messages[id];
|
2812 | if (Array.isArray(message) && message.length === 1 && message[0].type === TYPE.literal) {
|
2813 | return message[0].value;
|
2814 | }
|
2815 | if (!values && message && typeof message === "string" && !defaultRichTextElements) {
|
2816 | return message.replace(/'\{(.*?)\}'/gi, "{$1}");
|
2817 | }
|
2818 | values = __assign(__assign({}, defaultRichTextElements), values || {});
|
2819 | formats = deepMergeFormatsAndSetTimeZone(formats, timeZone);
|
2820 | defaultFormats = deepMergeFormatsAndSetTimeZone(defaultFormats, timeZone);
|
2821 | if (!message) {
|
2822 | if (!defaultMessage || locale && locale.toLowerCase() !== defaultLocale.toLowerCase()) {
|
2823 | onError(new MissingTranslationError(messageDescriptor, locale));
|
2824 | }
|
2825 | if (defaultMessage) {
|
2826 | try {
|
2827 | var formatter = state.getMessageFormat(defaultMessage, defaultLocale, defaultFormats, opts);
|
2828 | return formatter.format(values);
|
2829 | } catch (e) {
|
2830 | onError(new MessageFormatError('Error formatting default message for: "' + id + '", rendering default message verbatim', locale, messageDescriptor, e));
|
2831 | return typeof defaultMessage === "string" ? defaultMessage : id;
|
2832 | }
|
2833 | }
|
2834 | return id;
|
2835 | }
|
2836 | try {
|
2837 | var formatter = state.getMessageFormat(message, locale, formats, __assign({ formatters: state }, opts || {}));
|
2838 | return formatter.format(values);
|
2839 | } catch (e) {
|
2840 | onError(new MessageFormatError('Error formatting message: "' + id + '", using ' + (defaultMessage ? "default message" : "id") + " as fallback.", locale, messageDescriptor, e));
|
2841 | }
|
2842 | if (defaultMessage) {
|
2843 | try {
|
2844 | var formatter = state.getMessageFormat(defaultMessage, defaultLocale, defaultFormats, opts);
|
2845 | return formatter.format(values);
|
2846 | } catch (e) {
|
2847 | onError(new MessageFormatError('Error formatting the default message for: "' + id + '", rendering message verbatim', locale, messageDescriptor, e));
|
2848 | }
|
2849 | }
|
2850 | if (typeof message === "string") {
|
2851 | return message;
|
2852 | }
|
2853 | if (typeof defaultMessage === "string") {
|
2854 | return defaultMessage;
|
2855 | }
|
2856 | return id;
|
2857 | }
|
2858 |
|
2859 |
|
2860 | var DATE_TIME_FORMAT_OPTIONS = [
|
2861 | "localeMatcher",
|
2862 | "formatMatcher",
|
2863 | "timeZone",
|
2864 | "hour12",
|
2865 | "weekday",
|
2866 | "era",
|
2867 | "year",
|
2868 | "month",
|
2869 | "day",
|
2870 | "hour",
|
2871 | "minute",
|
2872 | "second",
|
2873 | "timeZoneName",
|
2874 | "hourCycle",
|
2875 | "dateStyle",
|
2876 | "timeStyle",
|
2877 | "calendar",
|
2878 | "numberingSystem"
|
2879 | ];
|
2880 | function getFormatter(_a2, type, getDateTimeFormat, options) {
|
2881 | var locale = _a2.locale, formats = _a2.formats, onError = _a2.onError, timeZone = _a2.timeZone;
|
2882 | if (options === void 0) {
|
2883 | options = {};
|
2884 | }
|
2885 | var format = options.format;
|
2886 | var defaults = __assign(__assign({}, timeZone && { timeZone: timeZone }), format && getNamedFormat(formats, type, format, onError));
|
2887 | var filteredOptions = filterProps(options, DATE_TIME_FORMAT_OPTIONS, defaults);
|
2888 | if (type === "time" && !filteredOptions.hour && !filteredOptions.minute && !filteredOptions.second && !filteredOptions.timeStyle && !filteredOptions.dateStyle) {
|
2889 | filteredOptions = __assign(__assign({}, filteredOptions), { hour: "numeric", minute: "numeric" });
|
2890 | }
|
2891 | return getDateTimeFormat(locale, filteredOptions);
|
2892 | }
|
2893 | function formatDate(config, getDateTimeFormat) {
|
2894 | var _a2 = [];
|
2895 | for (var _i = 2; _i < arguments.length; _i++) {
|
2896 | _a2[_i - 2] = arguments[_i];
|
2897 | }
|
2898 | var value = _a2[0], _b = _a2[1], options = _b === void 0 ? {} : _b;
|
2899 | var date = typeof value === "string" ? new Date(value || 0) : value;
|
2900 | try {
|
2901 | return getFormatter(config, "date", getDateTimeFormat, options).format(date);
|
2902 | } catch (e) {
|
2903 | config.onError(new IntlError(IntlErrorCode.FORMAT_ERROR, "Error formatting date.", e));
|
2904 | }
|
2905 | return String(date);
|
2906 | }
|
2907 | function formatTime(config, getDateTimeFormat) {
|
2908 | var _a2 = [];
|
2909 | for (var _i = 2; _i < arguments.length; _i++) {
|
2910 | _a2[_i - 2] = arguments[_i];
|
2911 | }
|
2912 | var value = _a2[0], _b = _a2[1], options = _b === void 0 ? {} : _b;
|
2913 | var date = typeof value === "string" ? new Date(value || 0) : value;
|
2914 | try {
|
2915 | return getFormatter(config, "time", getDateTimeFormat, options).format(date);
|
2916 | } catch (e) {
|
2917 | config.onError(new IntlError(IntlErrorCode.FORMAT_ERROR, "Error formatting time.", e));
|
2918 | }
|
2919 | return String(date);
|
2920 | }
|
2921 | function formatDateTimeRange(config, getDateTimeFormat) {
|
2922 | var _a2 = [];
|
2923 | for (var _i = 2; _i < arguments.length; _i++) {
|
2924 | _a2[_i - 2] = arguments[_i];
|
2925 | }
|
2926 | var from = _a2[0], to = _a2[1], _b = _a2[2], options = _b === void 0 ? {} : _b;
|
2927 | var timeZone = config.timeZone, locale = config.locale, onError = config.onError;
|
2928 | var filteredOptions = filterProps(options, DATE_TIME_FORMAT_OPTIONS, timeZone ? { timeZone: timeZone } : {});
|
2929 | try {
|
2930 | return getDateTimeFormat(locale, filteredOptions).formatRange(from, to);
|
2931 | } catch (e) {
|
2932 | onError(new IntlError(IntlErrorCode.FORMAT_ERROR, "Error formatting date time range.", e));
|
2933 | }
|
2934 | return String(from);
|
2935 | }
|
2936 | function formatDateToParts(config, getDateTimeFormat) {
|
2937 | var _a2 = [];
|
2938 | for (var _i = 2; _i < arguments.length; _i++) {
|
2939 | _a2[_i - 2] = arguments[_i];
|
2940 | }
|
2941 | var value = _a2[0], _b = _a2[1], options = _b === void 0 ? {} : _b;
|
2942 | var date = typeof value === "string" ? new Date(value || 0) : value;
|
2943 | try {
|
2944 | return getFormatter(config, "date", getDateTimeFormat, options).formatToParts(date);
|
2945 | } catch (e) {
|
2946 | config.onError(new IntlError(IntlErrorCode.FORMAT_ERROR, "Error formatting date.", e));
|
2947 | }
|
2948 | return [];
|
2949 | }
|
2950 | function formatTimeToParts(config, getDateTimeFormat) {
|
2951 | var _a2 = [];
|
2952 | for (var _i = 2; _i < arguments.length; _i++) {
|
2953 | _a2[_i - 2] = arguments[_i];
|
2954 | }
|
2955 | var value = _a2[0], _b = _a2[1], options = _b === void 0 ? {} : _b;
|
2956 | var date = typeof value === "string" ? new Date(value || 0) : value;
|
2957 | try {
|
2958 | return getFormatter(config, "time", getDateTimeFormat, options).formatToParts(date);
|
2959 | } catch (e) {
|
2960 | config.onError(new IntlError(IntlErrorCode.FORMAT_ERROR, "Error formatting time.", e));
|
2961 | }
|
2962 | return [];
|
2963 | }
|
2964 |
|
2965 |
|
2966 | var DISPLAY_NAMES_OPTONS = [
|
2967 | "localeMatcher",
|
2968 | "style",
|
2969 | "type",
|
2970 | "fallback"
|
2971 | ];
|
2972 | function formatDisplayName(_a2, getDisplayNames, value, options) {
|
2973 | var locale = _a2.locale, onError = _a2.onError;
|
2974 | var DisplayNames = Intl.DisplayNames;
|
2975 | if (!DisplayNames) {
|
2976 | onError(new FormatError('Intl.DisplayNames is not available in this environment.\nTry polyfilling it using "@formatjs/intl-displaynames"\n', ErrorCode.MISSING_INTL_API));
|
2977 | }
|
2978 | var filteredOptions = filterProps(options, DISPLAY_NAMES_OPTONS);
|
2979 | try {
|
2980 | return getDisplayNames(locale, filteredOptions).of(value);
|
2981 | } catch (e) {
|
2982 | onError(new IntlError(IntlErrorCode.FORMAT_ERROR, "Error formatting display name.", e));
|
2983 | }
|
2984 | }
|
2985 |
|
2986 |
|
2987 | var LIST_FORMAT_OPTIONS = [
|
2988 | "localeMatcher",
|
2989 | "type",
|
2990 | "style"
|
2991 | ];
|
2992 | var now = Date.now();
|
2993 | function generateToken(i) {
|
2994 | return now + "_" + i + "_" + now;
|
2995 | }
|
2996 | function formatList(opts, getListFormat, values, options) {
|
2997 | if (options === void 0) {
|
2998 | options = {};
|
2999 | }
|
3000 | var results = formatListToParts(opts, getListFormat, values, options).reduce(function(all, el) {
|
3001 | var val = el.value;
|
3002 | if (typeof val !== "string") {
|
3003 | all.push(val);
|
3004 | } else if (typeof all[all.length - 1] === "string") {
|
3005 | all[all.length - 1] += val;
|
3006 | } else {
|
3007 | all.push(val);
|
3008 | }
|
3009 | return all;
|
3010 | }, []);
|
3011 | return results.length === 1 ? results[0] : results;
|
3012 | }
|
3013 | function formatListToParts(_a2, getListFormat, values, options) {
|
3014 | var locale = _a2.locale, onError = _a2.onError;
|
3015 | if (options === void 0) {
|
3016 | options = {};
|
3017 | }
|
3018 | var ListFormat = Intl.ListFormat;
|
3019 | if (!ListFormat) {
|
3020 | onError(new FormatError('Intl.ListFormat is not available in this environment.\nTry polyfilling it using "@formatjs/intl-listformat"\n', ErrorCode.MISSING_INTL_API));
|
3021 | }
|
3022 | var filteredOptions = filterProps(options, LIST_FORMAT_OPTIONS);
|
3023 | try {
|
3024 | var richValues_1 = {};
|
3025 | var serializedValues = values.map(function(v, i) {
|
3026 | if (typeof v === "object") {
|
3027 | var id = generateToken(i);
|
3028 | richValues_1[id] = v;
|
3029 | return id;
|
3030 | }
|
3031 | return String(v);
|
3032 | });
|
3033 | return getListFormat(locale, filteredOptions).formatToParts(serializedValues).map(function(part) {
|
3034 | return part.type === "literal" ? part : __assign(__assign({}, part), { value: richValues_1[part.value] || part.value });
|
3035 | });
|
3036 | } catch (e) {
|
3037 | onError(new IntlError(IntlErrorCode.FORMAT_ERROR, "Error formatting list.", e));
|
3038 | }
|
3039 | return values;
|
3040 | }
|
3041 |
|
3042 |
|
3043 | var PLURAL_FORMAT_OPTIONS = [
|
3044 | "localeMatcher",
|
3045 | "type"
|
3046 | ];
|
3047 | function formatPlural(_a2, getPluralRules, value, options) {
|
3048 | var locale = _a2.locale, onError = _a2.onError;
|
3049 | if (options === void 0) {
|
3050 | options = {};
|
3051 | }
|
3052 | if (!Intl.PluralRules) {
|
3053 | onError(new FormatError('Intl.PluralRules is not available in this environment.\nTry polyfilling it using "@formatjs/intl-pluralrules"\n', ErrorCode.MISSING_INTL_API));
|
3054 | }
|
3055 | var filteredOptions = filterProps(options, PLURAL_FORMAT_OPTIONS);
|
3056 | try {
|
3057 | return getPluralRules(locale, filteredOptions).select(value);
|
3058 | } catch (e) {
|
3059 | onError(new MessageFormatError("Error formatting plural.", e));
|
3060 | }
|
3061 | return "other";
|
3062 | }
|
3063 |
|
3064 |
|
3065 | var RELATIVE_TIME_FORMAT_OPTIONS = ["numeric", "style"];
|
3066 | function getFormatter2(_a2, getRelativeTimeFormat, options) {
|
3067 | var locale = _a2.locale, formats = _a2.formats, onError = _a2.onError;
|
3068 | if (options === void 0) {
|
3069 | options = {};
|
3070 | }
|
3071 | var format = options.format;
|
3072 | var defaults = !!format && getNamedFormat(formats, "relative", format, onError) || {};
|
3073 | var filteredOptions = filterProps(options, RELATIVE_TIME_FORMAT_OPTIONS, defaults);
|
3074 | return getRelativeTimeFormat(locale, filteredOptions);
|
3075 | }
|
3076 | function formatRelativeTime(config, getRelativeTimeFormat, value, unit, options) {
|
3077 | if (options === void 0) {
|
3078 | options = {};
|
3079 | }
|
3080 | if (!unit) {
|
3081 | unit = "second";
|
3082 | }
|
3083 | var RelativeTimeFormat = Intl.RelativeTimeFormat;
|
3084 | if (!RelativeTimeFormat) {
|
3085 | config.onError(new FormatError('Intl.RelativeTimeFormat is not available in this environment.\nTry polyfilling it using "@formatjs/intl-relativetimeformat"\n', ErrorCode.MISSING_INTL_API));
|
3086 | }
|
3087 | try {
|
3088 | return getFormatter2(config, getRelativeTimeFormat, options).format(value, unit);
|
3089 | } catch (e) {
|
3090 | config.onError(new MessageFormatError("Error formatting relative time.", e));
|
3091 | }
|
3092 | return String(value);
|
3093 | }
|
3094 |
|
3095 |
|
3096 | var NUMBER_FORMAT_OPTIONS = [
|
3097 | "localeMatcher",
|
3098 | "style",
|
3099 | "currency",
|
3100 | "currencyDisplay",
|
3101 | "unit",
|
3102 | "unitDisplay",
|
3103 | "useGrouping",
|
3104 | "minimumIntegerDigits",
|
3105 | "minimumFractionDigits",
|
3106 | "maximumFractionDigits",
|
3107 | "minimumSignificantDigits",
|
3108 | "maximumSignificantDigits",
|
3109 | "compactDisplay",
|
3110 | "currencyDisplay",
|
3111 | "currencySign",
|
3112 | "notation",
|
3113 | "signDisplay",
|
3114 | "unit",
|
3115 | "unitDisplay",
|
3116 | "numberingSystem"
|
3117 | ];
|
3118 | function getFormatter3(_a2, getNumberFormat, options) {
|
3119 | var locale = _a2.locale, formats = _a2.formats, onError = _a2.onError;
|
3120 | if (options === void 0) {
|
3121 | options = {};
|
3122 | }
|
3123 | var format = options.format;
|
3124 | var defaults = format && getNamedFormat(formats, "number", format, onError) || {};
|
3125 | var filteredOptions = filterProps(options, NUMBER_FORMAT_OPTIONS, defaults);
|
3126 | return getNumberFormat(locale, filteredOptions);
|
3127 | }
|
3128 | function formatNumber(config, getNumberFormat, value, options) {
|
3129 | if (options === void 0) {
|
3130 | options = {};
|
3131 | }
|
3132 | try {
|
3133 | return getFormatter3(config, getNumberFormat, options).format(value);
|
3134 | } catch (e) {
|
3135 | config.onError(new IntlError(IntlErrorCode.FORMAT_ERROR, "Error formatting number.", e));
|
3136 | }
|
3137 | return String(value);
|
3138 | }
|
3139 | function formatNumberToParts(config, getNumberFormat, value, options) {
|
3140 | if (options === void 0) {
|
3141 | options = {};
|
3142 | }
|
3143 | try {
|
3144 | return getFormatter3(config, getNumberFormat, options).formatToParts(value);
|
3145 | } catch (e) {
|
3146 | config.onError(new IntlError(IntlErrorCode.FORMAT_ERROR, "Error formatting number.", e));
|
3147 | }
|
3148 | return [];
|
3149 | }
|
3150 |
|
3151 |
|
3152 | function messagesContainString(messages) {
|
3153 | var firstMessage = messages ? messages[Object.keys(messages)[0]] : void 0;
|
3154 | return typeof firstMessage === "string";
|
3155 | }
|
3156 | function verifyConfigMessages(config) {
|
3157 | if (config.defaultRichTextElements && messagesContainString(config.messages || {})) {
|
3158 | console.warn('[@formatjs/intl] "defaultRichTextElements" was specified but "message" was not pre-compiled. \nPlease consider using "@formatjs/cli" to pre-compile your messages for performance.\nFor more details see https://formatjs.io/docs/getting-started/message-distribution');
|
3159 | }
|
3160 | }
|
3161 | function createIntl(config, cache) {
|
3162 | var formatters = createFormatters(cache);
|
3163 | var resolvedConfig = __assign(__assign({}, DEFAULT_INTL_CONFIG), config);
|
3164 | var locale = resolvedConfig.locale, defaultLocale = resolvedConfig.defaultLocale, onError = resolvedConfig.onError;
|
3165 | if (!locale) {
|
3166 | if (onError) {
|
3167 | onError(new InvalidConfigError('"locale" was not configured, using "' + defaultLocale + '" as fallback. See https://formatjs.io/docs/react-intl/api#intlshape for more details'));
|
3168 | }
|
3169 | resolvedConfig.locale = resolvedConfig.defaultLocale || "en";
|
3170 | } else if (!Intl.NumberFormat.supportedLocalesOf(locale).length && onError) {
|
3171 | onError(new MissingDataError('Missing locale data for locale: "' + locale + '" in Intl.NumberFormat. Using default locale: "' + defaultLocale + '" as fallback. See https://formatjs.io/docs/react-intl#runtime-requirements for more details'));
|
3172 | } else if (!Intl.DateTimeFormat.supportedLocalesOf(locale).length && onError) {
|
3173 | onError(new MissingDataError('Missing locale data for locale: "' + locale + '" in Intl.DateTimeFormat. Using default locale: "' + defaultLocale + '" as fallback. See https://formatjs.io/docs/react-intl#runtime-requirements for more details'));
|
3174 | }
|
3175 | verifyConfigMessages(resolvedConfig);
|
3176 | return __assign(__assign({}, resolvedConfig), { formatters: formatters, formatNumber: formatNumber.bind(null, resolvedConfig, formatters.getNumberFormat), formatNumberToParts: formatNumberToParts.bind(null, resolvedConfig, formatters.getNumberFormat), formatRelativeTime: formatRelativeTime.bind(null, resolvedConfig, formatters.getRelativeTimeFormat), formatDate: formatDate.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatDateToParts: formatDateToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatTime: formatTime.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatDateTimeRange: formatDateTimeRange.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatTimeToParts: formatTimeToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatPlural: formatPlural.bind(null, resolvedConfig, formatters.getPluralRules), formatMessage: formatMessage.bind(null, resolvedConfig, formatters), formatList: formatList.bind(null, resolvedConfig, formatters.getListFormat), formatListToParts: formatListToParts.bind(null, resolvedConfig, formatters.getListFormat), formatDisplayName: formatDisplayName.bind(null, resolvedConfig, formatters.getDisplayNames) });
|
3177 | }
|
3178 |
|
3179 |
|
3180 | function invariantIntlContext(intl) {
|
3181 | invariant(intl, "[React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry.");
|
3182 | }
|
3183 | var DEFAULT_INTL_CONFIG2 = __assign(__assign({}, DEFAULT_INTL_CONFIG), { textComponent: React.Fragment });
|
3184 | function assignUniqueKeysToParts(formatXMLElementFn) {
|
3185 | return function(parts) {
|
3186 | return formatXMLElementFn(React.Children.toArray(parts));
|
3187 | };
|
3188 | }
|
3189 | function shallowEqual(objA, objB) {
|
3190 | if (objA === objB) {
|
3191 | return true;
|
3192 | }
|
3193 | if (!objA || !objB) {
|
3194 | return false;
|
3195 | }
|
3196 | var aKeys = Object.keys(objA);
|
3197 | var bKeys = Object.keys(objB);
|
3198 | var len = aKeys.length;
|
3199 | if (bKeys.length !== len) {
|
3200 | return false;
|
3201 | }
|
3202 | for (var i = 0; i < len; i++) {
|
3203 | var key = aKeys[i];
|
3204 | if (objA[key] !== objB[key] || !Object.prototype.hasOwnProperty.call(objB, key)) {
|
3205 | return false;
|
3206 | }
|
3207 | }
|
3208 | return true;
|
3209 | }
|
3210 |
|
3211 |
|
3212 | function getDisplayName(Component) {
|
3213 | return Component.displayName || Component.name || "Component";
|
3214 | }
|
3215 | var IntlContext = React2.createContext(null);
|
3216 | var IntlConsumer = IntlContext.Consumer;
|
3217 | var IntlProvider = IntlContext.Provider;
|
3218 | var Provider = IntlProvider;
|
3219 | var Context = IntlContext;
|
3220 | function injectIntl(WrappedComponent, options) {
|
3221 | var _a2 = options || {}, _b = _a2.intlPropName, intlPropName = _b === void 0 ? "intl" : _b, _c = _a2.forwardRef, forwardRef2 = _c === void 0 ? false : _c, _d = _a2.enforceContext, enforceContext = _d === void 0 ? true : _d;
|
3222 | var WithIntl = function(props) {
|
3223 | return React2.createElement(IntlConsumer, null, function(intl) {
|
3224 | var _a3;
|
3225 | if (enforceContext) {
|
3226 | invariantIntlContext(intl);
|
3227 | }
|
3228 | var intlProp = (_a3 = {}, _a3[intlPropName] = intl, _a3);
|
3229 | return React2.createElement(WrappedComponent, __assign({}, props, intlProp, { ref: forwardRef2 ? props.forwardedRef : null }));
|
3230 | });
|
3231 | };
|
3232 | WithIntl.displayName = "injectIntl(" + getDisplayName(WrappedComponent) + ")";
|
3233 | WithIntl.WrappedComponent = WrappedComponent;
|
3234 | if (forwardRef2) {
|
3235 | return (0, import_hoist_non_react_statics.default)(React2.forwardRef(function(props, ref) {
|
3236 | return React2.createElement(WithIntl, __assign({}, props, { forwardedRef: ref }));
|
3237 | }), WrappedComponent);
|
3238 | }
|
3239 | return (0, import_hoist_non_react_statics.default)(WithIntl, WrappedComponent);
|
3240 | }
|
3241 |
|
3242 |
|
3243 | function useIntl() {
|
3244 | var intl = React3.useContext(Context);
|
3245 | invariantIntlContext(intl);
|
3246 | return intl;
|
3247 | }
|
3248 |
|
3249 |
|
3250 | var DisplayName;
|
3251 | (function(DisplayName2) {
|
3252 | DisplayName2["formatDate"] = "FormattedDate";
|
3253 | DisplayName2["formatTime"] = "FormattedTime";
|
3254 | DisplayName2["formatNumber"] = "FormattedNumber";
|
3255 | DisplayName2["formatList"] = "FormattedList";
|
3256 | DisplayName2["formatDisplayName"] = "FormattedDisplayName";
|
3257 | })(DisplayName || (DisplayName = {}));
|
3258 | var DisplayNameParts;
|
3259 | (function(DisplayNameParts2) {
|
3260 | DisplayNameParts2["formatDate"] = "FormattedDateParts";
|
3261 | DisplayNameParts2["formatTime"] = "FormattedTimeParts";
|
3262 | DisplayNameParts2["formatNumber"] = "FormattedNumberParts";
|
3263 | DisplayNameParts2["formatList"] = "FormattedListParts";
|
3264 | })(DisplayNameParts || (DisplayNameParts = {}));
|
3265 | var FormattedNumberParts = function(props) {
|
3266 | var intl = useIntl();
|
3267 | var value = props.value, children = props.children, formatProps = __rest(props, ["value", "children"]);
|
3268 | return children(intl.formatNumberToParts(value, formatProps));
|
3269 | };
|
3270 | FormattedNumberParts.displayName = "FormattedNumberParts";
|
3271 | var FormattedListParts = function(props) {
|
3272 | var intl = useIntl();
|
3273 | var value = props.value, children = props.children, formatProps = __rest(props, ["value", "children"]);
|
3274 | return children(intl.formatListToParts(value, formatProps));
|
3275 | };
|
3276 | FormattedNumberParts.displayName = "FormattedNumberParts";
|
3277 | function createFormattedDateTimePartsComponent(name) {
|
3278 | var ComponentParts = function(props) {
|
3279 | var intl = useIntl();
|
3280 | var value = props.value, children = props.children, formatProps = __rest(props, ["value", "children"]);
|
3281 | var date = typeof value === "string" ? new Date(value || 0) : value;
|
3282 | var formattedParts = name === "formatDate" ? intl.formatDateToParts(date, formatProps) : intl.formatTimeToParts(date, formatProps);
|
3283 | return children(formattedParts);
|
3284 | };
|
3285 | ComponentParts.displayName = DisplayNameParts[name];
|
3286 | return ComponentParts;
|
3287 | }
|
3288 | function createFormattedComponent(name) {
|
3289 | var Component = function(props) {
|
3290 | var intl = useIntl();
|
3291 | var value = props.value, children = props.children, formatProps = __rest(props, ["value", "children"]);
|
3292 | var formattedValue = intl[name](value, formatProps);
|
3293 | if (typeof children === "function") {
|
3294 | return children(formattedValue);
|
3295 | }
|
3296 | var Text = intl.textComponent || React4.Fragment;
|
3297 | return React4.createElement(Text, null, formattedValue);
|
3298 | };
|
3299 | Component.displayName = DisplayName[name];
|
3300 | return Component;
|
3301 | }
|
3302 |
|
3303 |
|
3304 | var React5 = __toModule(window.React);
|
3305 | function processIntlConfig(config) {
|
3306 | return {
|
3307 | locale: config.locale,
|
3308 | timeZone: config.timeZone,
|
3309 | formats: config.formats,
|
3310 | textComponent: config.textComponent,
|
3311 | messages: config.messages,
|
3312 | defaultLocale: config.defaultLocale,
|
3313 | defaultFormats: config.defaultFormats,
|
3314 | onError: config.onError,
|
3315 | wrapRichTextChunksInFragment: config.wrapRichTextChunksInFragment,
|
3316 | defaultRichTextElements: config.defaultRichTextElements
|
3317 | };
|
3318 | }
|
3319 | function assignUniqueKeysToFormatXMLElementFnArgument(values) {
|
3320 | if (!values) {
|
3321 | return values;
|
3322 | }
|
3323 | return Object.keys(values).reduce(function(acc, k) {
|
3324 | var v = values[k];
|
3325 | acc[k] = isFormatXMLElementFn(v) ? assignUniqueKeysToParts(v) : v;
|
3326 | return acc;
|
3327 | }, {});
|
3328 | }
|
3329 | var formatMessage2 = function(config, formatters, descriptor, rawValues) {
|
3330 | var rest = [];
|
3331 | for (var _i = 4; _i < arguments.length; _i++) {
|
3332 | rest[_i - 4] = arguments[_i];
|
3333 | }
|
3334 | var values = assignUniqueKeysToFormatXMLElementFnArgument(rawValues);
|
3335 | var chunks = formatMessage.apply(void 0, __spreadArray([
|
3336 | config,
|
3337 | formatters,
|
3338 | descriptor,
|
3339 | values
|
3340 | ], rest));
|
3341 | if (Array.isArray(chunks)) {
|
3342 | return React5.Children.toArray(chunks);
|
3343 | }
|
3344 | return chunks;
|
3345 | };
|
3346 | var createIntl2 = function(_a2, cache) {
|
3347 | var rawDefaultRichTextElements = _a2.defaultRichTextElements, config = __rest(_a2, ["defaultRichTextElements"]);
|
3348 | var defaultRichTextElements = assignUniqueKeysToFormatXMLElementFnArgument(rawDefaultRichTextElements);
|
3349 | var coreIntl = createIntl(__assign(__assign(__assign({}, DEFAULT_INTL_CONFIG2), config), { defaultRichTextElements: defaultRichTextElements }), cache);
|
3350 | return __assign(__assign({}, coreIntl), { formatMessage: formatMessage2.bind(null, {
|
3351 | locale: coreIntl.locale,
|
3352 | timeZone: coreIntl.timeZone,
|
3353 | formats: coreIntl.formats,
|
3354 | defaultLocale: coreIntl.defaultLocale,
|
3355 | defaultFormats: coreIntl.defaultFormats,
|
3356 | messages: coreIntl.messages,
|
3357 | onError: coreIntl.onError,
|
3358 | defaultRichTextElements: defaultRichTextElements
|
3359 | }, coreIntl.formatters) });
|
3360 | };
|
3361 | var IntlProvider2 = function(_super) {
|
3362 | __extends(IntlProvider3, _super);
|
3363 | function IntlProvider3() {
|
3364 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
3365 | _this.cache = createIntlCache();
|
3366 | _this.state = {
|
3367 | cache: _this.cache,
|
3368 | intl: createIntl2(processIntlConfig(_this.props), _this.cache),
|
3369 | prevConfig: processIntlConfig(_this.props)
|
3370 | };
|
3371 | return _this;
|
3372 | }
|
3373 | IntlProvider3.getDerivedStateFromProps = function(props, _a2) {
|
3374 | var prevConfig = _a2.prevConfig, cache = _a2.cache;
|
3375 | var config = processIntlConfig(props);
|
3376 | if (!shallowEqual(prevConfig, config)) {
|
3377 | return {
|
3378 | intl: createIntl2(config, cache),
|
3379 | prevConfig: config
|
3380 | };
|
3381 | }
|
3382 | return null;
|
3383 | };
|
3384 | IntlProvider3.prototype.render = function() {
|
3385 | invariantIntlContext(this.state.intl);
|
3386 | return React5.createElement(Provider, { value: this.state.intl }, this.props.children);
|
3387 | };
|
3388 | IntlProvider3.displayName = "IntlProvider";
|
3389 | IntlProvider3.defaultProps = DEFAULT_INTL_CONFIG2;
|
3390 | return IntlProvider3;
|
3391 | }(React5.PureComponent);
|
3392 | var provider_default = IntlProvider2;
|
3393 |
|
3394 |
|
3395 | var React6 = __toModule(window.React);
|
3396 | var MINUTE = 60;
|
3397 | var HOUR = 60 * 60;
|
3398 | var DAY = 60 * 60 * 24;
|
3399 | function selectUnit(seconds) {
|
3400 | var absValue = Math.abs(seconds);
|
3401 | if (absValue < MINUTE) {
|
3402 | return "second";
|
3403 | }
|
3404 | if (absValue < HOUR) {
|
3405 | return "minute";
|
3406 | }
|
3407 | if (absValue < DAY) {
|
3408 | return "hour";
|
3409 | }
|
3410 | return "day";
|
3411 | }
|
3412 | function getDurationInSeconds(unit) {
|
3413 | switch (unit) {
|
3414 | case "second":
|
3415 | return 1;
|
3416 | case "minute":
|
3417 | return MINUTE;
|
3418 | case "hour":
|
3419 | return HOUR;
|
3420 | default:
|
3421 | return DAY;
|
3422 | }
|
3423 | }
|
3424 | function valueToSeconds(value, unit) {
|
3425 | if (!value) {
|
3426 | return 0;
|
3427 | }
|
3428 | switch (unit) {
|
3429 | case "second":
|
3430 | return value;
|
3431 | case "minute":
|
3432 | return value * MINUTE;
|
3433 | default:
|
3434 | return value * HOUR;
|
3435 | }
|
3436 | }
|
3437 | var INCREMENTABLE_UNITS = [
|
3438 | "second",
|
3439 | "minute",
|
3440 | "hour"
|
3441 | ];
|
3442 | function canIncrement(unit) {
|
3443 | if (unit === void 0) {
|
3444 | unit = "second";
|
3445 | }
|
3446 | return INCREMENTABLE_UNITS.indexOf(unit) > -1;
|
3447 | }
|
3448 | var SimpleFormattedRelativeTime = function(props) {
|
3449 | var _a2 = useIntl(), formatRelativeTime2 = _a2.formatRelativeTime, Text = _a2.textComponent;
|
3450 | var children = props.children, value = props.value, unit = props.unit, otherProps = __rest(props, ["children", "value", "unit"]);
|
3451 | var formattedRelativeTime = formatRelativeTime2(value || 0, unit, otherProps);
|
3452 | if (typeof children === "function") {
|
3453 | return children(formattedRelativeTime);
|
3454 | }
|
3455 | if (Text) {
|
3456 | return React6.createElement(Text, null, formattedRelativeTime);
|
3457 | }
|
3458 | return React6.createElement(React6.Fragment, null, formattedRelativeTime);
|
3459 | };
|
3460 | var FormattedRelativeTime = function(_a2) {
|
3461 | var value = _a2.value, unit = _a2.unit, updateIntervalInSeconds = _a2.updateIntervalInSeconds, otherProps = __rest(_a2, ["value", "unit", "updateIntervalInSeconds"]);
|
3462 | invariant(!updateIntervalInSeconds || !!(updateIntervalInSeconds && canIncrement(unit)), "Cannot schedule update with unit longer than hour");
|
3463 | var _b = React6.useState(), prevUnit = _b[0], setPrevUnit = _b[1];
|
3464 | var _c = React6.useState(0), prevValue = _c[0], setPrevValue = _c[1];
|
3465 | var _d = React6.useState(0), currentValueInSeconds = _d[0], setCurrentValueInSeconds = _d[1];
|
3466 | var updateTimer;
|
3467 | if (unit !== prevUnit || value !== prevValue) {
|
3468 | setPrevValue(value || 0);
|
3469 | setPrevUnit(unit);
|
3470 | setCurrentValueInSeconds(canIncrement(unit) ? valueToSeconds(value, unit) : 0);
|
3471 | }
|
3472 | React6.useEffect(function() {
|
3473 | function clearUpdateTimer() {
|
3474 | clearTimeout(updateTimer);
|
3475 | }
|
3476 | clearUpdateTimer();
|
3477 | if (!updateIntervalInSeconds || !canIncrement(unit)) {
|
3478 | return clearUpdateTimer;
|
3479 | }
|
3480 | var nextValueInSeconds = currentValueInSeconds - updateIntervalInSeconds;
|
3481 | var nextUnit = selectUnit(nextValueInSeconds);
|
3482 | if (nextUnit === "day") {
|
3483 | return clearUpdateTimer;
|
3484 | }
|
3485 | var unitDuration2 = getDurationInSeconds(nextUnit);
|
3486 | var remainder = nextValueInSeconds % unitDuration2;
|
3487 | var prevInterestingValueInSeconds = nextValueInSeconds - remainder;
|
3488 | var nextInterestingValueInSeconds = prevInterestingValueInSeconds >= currentValueInSeconds ? prevInterestingValueInSeconds - unitDuration2 : prevInterestingValueInSeconds;
|
3489 | var delayInSeconds = Math.abs(nextInterestingValueInSeconds - currentValueInSeconds);
|
3490 | if (currentValueInSeconds !== nextInterestingValueInSeconds) {
|
3491 | updateTimer = setTimeout(function() {
|
3492 | return setCurrentValueInSeconds(nextInterestingValueInSeconds);
|
3493 | }, delayInSeconds * 1e3);
|
3494 | }
|
3495 | return clearUpdateTimer;
|
3496 | }, [currentValueInSeconds, updateIntervalInSeconds, unit]);
|
3497 | var currentValue = value || 0;
|
3498 | var currentUnit = unit;
|
3499 | if (canIncrement(unit) && typeof currentValueInSeconds === "number" && updateIntervalInSeconds) {
|
3500 | currentUnit = selectUnit(currentValueInSeconds);
|
3501 | var unitDuration = getDurationInSeconds(currentUnit);
|
3502 | currentValue = Math.round(currentValueInSeconds / unitDuration);
|
3503 | }
|
3504 | return React6.createElement(SimpleFormattedRelativeTime, __assign({ value: currentValue, unit: currentUnit }, otherProps));
|
3505 | };
|
3506 | FormattedRelativeTime.displayName = "FormattedRelativeTime";
|
3507 | FormattedRelativeTime.defaultProps = {
|
3508 | value: 0,
|
3509 | unit: "second"
|
3510 | };
|
3511 | var relative_default = FormattedRelativeTime;
|
3512 |
|
3513 |
|
3514 | var React7 = __toModule(window.React);
|
3515 | var FormattedPlural = function(props) {
|
3516 | var _a2 = useIntl(), formatPlural2 = _a2.formatPlural, Text = _a2.textComponent;
|
3517 | var value = props.value, other = props.other, children = props.children;
|
3518 | var pluralCategory = formatPlural2(value, props);
|
3519 | var formattedPlural = props[pluralCategory] || other;
|
3520 | if (typeof children === "function") {
|
3521 | return children(formattedPlural);
|
3522 | }
|
3523 | if (Text) {
|
3524 | return React7.createElement(Text, null, formattedPlural);
|
3525 | }
|
3526 | return formattedPlural;
|
3527 | };
|
3528 | FormattedPlural.defaultProps = {
|
3529 | type: "cardinal"
|
3530 | };
|
3531 | FormattedPlural.displayName = "FormattedPlural";
|
3532 | var plural_default = FormattedPlural;
|
3533 |
|
3534 |
|
3535 | var React8 = __toModule(window.React);
|
3536 | function areEqual(prevProps, nextProps) {
|
3537 | var values = prevProps.values, otherProps = __rest(prevProps, ["values"]);
|
3538 | var nextValues = nextProps.values, nextOtherProps = __rest(nextProps, ["values"]);
|
3539 | return shallowEqual(nextValues, values) && shallowEqual(otherProps, nextOtherProps);
|
3540 | }
|
3541 | function FormattedMessage(props) {
|
3542 | var intl = useIntl();
|
3543 | var formatMessage3 = intl.formatMessage, _a2 = intl.textComponent, Text = _a2 === void 0 ? React8.Fragment : _a2;
|
3544 | var id = props.id, description = props.description, defaultMessage = props.defaultMessage, values = props.values, children = props.children, _b = props.tagName, Component = _b === void 0 ? Text : _b, ignoreTag = props.ignoreTag;
|
3545 | var descriptor = { id: id, description: description, defaultMessage: defaultMessage };
|
3546 | var nodes = formatMessage3(descriptor, values, {
|
3547 | ignoreTag: ignoreTag
|
3548 | });
|
3549 | if (typeof children === "function") {
|
3550 | return children(Array.isArray(nodes) ? nodes : [nodes]);
|
3551 | }
|
3552 | if (Component) {
|
3553 | return React8.createElement(Component, null, React8.Children.toArray(nodes));
|
3554 | }
|
3555 | return React8.createElement(React8.Fragment, null, nodes);
|
3556 | }
|
3557 | FormattedMessage.displayName = "FormattedMessage";
|
3558 | var MemoizedFormattedMessage = React8.memo(FormattedMessage, areEqual);
|
3559 | MemoizedFormattedMessage.displayName = "MemoizedFormattedMessage";
|
3560 | var message_default = MemoizedFormattedMessage;
|
3561 |
|
3562 |
|
3563 | var React9 = __toModule(window.React);
|
3564 | var FormattedDateTimeRange = function(props) {
|
3565 | var intl = useIntl();
|
3566 | var from = props.from, to = props.to, children = props.children, formatProps = __rest(props, ["from", "to", "children"]);
|
3567 | var formattedValue = intl.formatDateTimeRange(from, to, formatProps);
|
3568 | if (typeof children === "function") {
|
3569 | return children(formattedValue);
|
3570 | }
|
3571 | var Text = intl.textComponent || React9.Fragment;
|
3572 | return React9.createElement(Text, null, formattedValue);
|
3573 | };
|
3574 | FormattedDateTimeRange.displayName = "FormattedDateTimeRange";
|
3575 | var dateTimeRange_default = FormattedDateTimeRange;
|
3576 |
|
3577 |
|
3578 | function defineMessages(msgs) {
|
3579 | return msgs;
|
3580 | }
|
3581 | function defineMessage(msg) {
|
3582 | return msg;
|
3583 | }
|
3584 | var FormattedDate = createFormattedComponent("formatDate");
|
3585 | var FormattedTime = createFormattedComponent("formatTime");
|
3586 | var FormattedNumber = createFormattedComponent("formatNumber");
|
3587 | var FormattedList = createFormattedComponent("formatList");
|
3588 | var FormattedDisplayName = createFormattedComponent("formatDisplayName");
|
3589 | var FormattedDateParts = createFormattedDateTimePartsComponent("formatDate");
|
3590 | var FormattedTimeParts = createFormattedDateTimePartsComponent("formatTime");
|
3591 | return lib_exports;
|
3592 | })();
|
3593 |
|
3594 |
|
3595 |
|
3596 |
|
3597 |
|
3598 |
|
3599 |
|
3600 |
|
3601 |
|
3602 |
|
3603 |
|
3604 |
|
3605 |
|
3606 |
|
3607 |
|
3608 |
|
3609 |
|
3610 |
|
3611 |
|
3612 |
|
3613 |
|
3614 |
|
3615 |
|