@common.js/formatjs__icu-messageformat-parser 3.5.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js ADDED
@@ -0,0 +1,2683 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ SKELETON_TYPE: function() {
13
+ return SKELETON_TYPE;
14
+ },
15
+ TYPE: function() {
16
+ return TYPE;
17
+ },
18
+ "_Parser": function() {
19
+ return _Parser;
20
+ },
21
+ createLiteralElement: function() {
22
+ return createLiteralElement;
23
+ },
24
+ createNumberElement: function() {
25
+ return createNumberElement;
26
+ },
27
+ isArgumentElement: function() {
28
+ return isArgumentElement;
29
+ },
30
+ isDateElement: function() {
31
+ return isDateElement;
32
+ },
33
+ isDateTimeSkeleton: function() {
34
+ return isDateTimeSkeleton;
35
+ },
36
+ isLiteralElement: function() {
37
+ return isLiteralElement;
38
+ },
39
+ isNumberElement: function() {
40
+ return isNumberElement;
41
+ },
42
+ isNumberSkeleton: function() {
43
+ return isNumberSkeleton;
44
+ },
45
+ isPluralElement: function() {
46
+ return isPluralElement;
47
+ },
48
+ isPoundElement: function() {
49
+ return isPoundElement;
50
+ },
51
+ isSelectElement: function() {
52
+ return isSelectElement;
53
+ },
54
+ isStructurallySame: function() {
55
+ return isStructurallySame;
56
+ },
57
+ isTagElement: function() {
58
+ return isTagElement;
59
+ },
60
+ isTimeElement: function() {
61
+ return isTimeElement;
62
+ },
63
+ parse: function() {
64
+ return parse;
65
+ }
66
+ });
67
+ var _icuSkeletonParser = require("@formatjs/icu-skeleton-parser");
68
+ function _arrayLikeToArray(arr, len) {
69
+ if (len == null || len > arr.length) len = arr.length;
70
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
71
+ return arr2;
72
+ }
73
+ function _arrayWithHoles(arr) {
74
+ if (Array.isArray(arr)) return arr;
75
+ }
76
+ function _arrayWithoutHoles(arr) {
77
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
78
+ }
79
+ function _classCallCheck(instance, Constructor) {
80
+ if (!(instance instanceof Constructor)) {
81
+ throw new TypeError("Cannot call a class as a function");
82
+ }
83
+ }
84
+ function _defineProperties(target, props) {
85
+ for(var i = 0; i < props.length; i++){
86
+ var descriptor = props[i];
87
+ descriptor.enumerable = descriptor.enumerable || false;
88
+ descriptor.configurable = true;
89
+ if ("value" in descriptor) descriptor.writable = true;
90
+ Object.defineProperty(target, descriptor.key, descriptor);
91
+ }
92
+ }
93
+ function _createClass(Constructor, protoProps, staticProps) {
94
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
95
+ if (staticProps) _defineProperties(Constructor, staticProps);
96
+ return Constructor;
97
+ }
98
+ function _defineProperty(obj, key, value) {
99
+ if (key in obj) {
100
+ Object.defineProperty(obj, key, {
101
+ value: value,
102
+ enumerable: true,
103
+ configurable: true,
104
+ writable: true
105
+ });
106
+ } else {
107
+ obj[key] = value;
108
+ }
109
+ return obj;
110
+ }
111
+ function _iterableToArray(iter) {
112
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
113
+ }
114
+ function _iterableToArrayLimit(arr, i) {
115
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
116
+ if (_i == null) return;
117
+ var _arr = [];
118
+ var _n = true;
119
+ var _d = false;
120
+ var _s, _e;
121
+ try {
122
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
123
+ _arr.push(_s.value);
124
+ if (i && _arr.length === i) break;
125
+ }
126
+ } catch (err) {
127
+ _d = true;
128
+ _e = err;
129
+ } finally{
130
+ try {
131
+ if (!_n && _i["return"] != null) _i["return"]();
132
+ } finally{
133
+ if (_d) throw _e;
134
+ }
135
+ }
136
+ return _arr;
137
+ }
138
+ function _nonIterableRest() {
139
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
140
+ }
141
+ function _nonIterableSpread() {
142
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
143
+ }
144
+ function _objectSpread(target) {
145
+ for(var i = 1; i < arguments.length; i++){
146
+ var source = arguments[i] != null ? arguments[i] : {};
147
+ var ownKeys = Object.keys(source);
148
+ if (typeof Object.getOwnPropertySymbols === "function") {
149
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
150
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
151
+ }));
152
+ }
153
+ ownKeys.forEach(function(key) {
154
+ _defineProperty(target, key, source[key]);
155
+ });
156
+ }
157
+ return target;
158
+ }
159
+ function _slicedToArray(arr, i) {
160
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
161
+ }
162
+ function _toConsumableArray(arr) {
163
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
164
+ }
165
+ function _unsupportedIterableToArray(o, minLen) {
166
+ if (!o) return;
167
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
168
+ var n = Object.prototype.toString.call(o).slice(8, -1);
169
+ if (n === "Object" && o.constructor) n = o.constructor.name;
170
+ if (n === "Map" || n === "Set") return Array.from(n);
171
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
172
+ }
173
+ //#region packages/icu-messageformat-parser/error.ts
174
+ var ErrorKind = /* @__PURE__ */ function(ErrorKind) {
175
+ /** Argument is unclosed (e.g. `{0`) */ ErrorKind[ErrorKind["EXPECT_ARGUMENT_CLOSING_BRACE"] = 1] = "EXPECT_ARGUMENT_CLOSING_BRACE";
176
+ /** Argument is empty (e.g. `{}`). */ ErrorKind[ErrorKind["EMPTY_ARGUMENT"] = 2] = "EMPTY_ARGUMENT";
177
+ /** Argument is malformed (e.g. `{foo!}``) */ ErrorKind[ErrorKind["MALFORMED_ARGUMENT"] = 3] = "MALFORMED_ARGUMENT";
178
+ /** Expect an argument type (e.g. `{foo,}`) */ ErrorKind[ErrorKind["EXPECT_ARGUMENT_TYPE"] = 4] = "EXPECT_ARGUMENT_TYPE";
179
+ /** Unsupported argument type (e.g. `{foo,foo}`) */ ErrorKind[ErrorKind["INVALID_ARGUMENT_TYPE"] = 5] = "INVALID_ARGUMENT_TYPE";
180
+ /** Expect an argument style (e.g. `{foo, number, }`) */ ErrorKind[ErrorKind["EXPECT_ARGUMENT_STYLE"] = 6] = "EXPECT_ARGUMENT_STYLE";
181
+ /** The number skeleton is invalid. */ ErrorKind[ErrorKind["INVALID_NUMBER_SKELETON"] = 7] = "INVALID_NUMBER_SKELETON";
182
+ /** The date time skeleton is invalid. */ ErrorKind[ErrorKind["INVALID_DATE_TIME_SKELETON"] = 8] = "INVALID_DATE_TIME_SKELETON";
183
+ /** Exepct a number skeleton following the `::` (e.g. `{foo, number, ::}`) */ ErrorKind[ErrorKind["EXPECT_NUMBER_SKELETON"] = 9] = "EXPECT_NUMBER_SKELETON";
184
+ /** Exepct a date time skeleton following the `::` (e.g. `{foo, date, ::}`) */ ErrorKind[ErrorKind["EXPECT_DATE_TIME_SKELETON"] = 10] = "EXPECT_DATE_TIME_SKELETON";
185
+ /** Unmatched apostrophes in the argument style (e.g. `{foo, number, 'test`) */ ErrorKind[ErrorKind["UNCLOSED_QUOTE_IN_ARGUMENT_STYLE"] = 11] = "UNCLOSED_QUOTE_IN_ARGUMENT_STYLE";
186
+ /** Missing select argument options (e.g. `{foo, select}`) */ ErrorKind[ErrorKind["EXPECT_SELECT_ARGUMENT_OPTIONS"] = 12] = "EXPECT_SELECT_ARGUMENT_OPTIONS";
187
+ /** Expecting an offset value in `plural` or `selectordinal` argument (e.g `{foo, plural, offset}`) */ ErrorKind[ErrorKind["EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE"] = 13] = "EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE";
188
+ /** Offset value in `plural` or `selectordinal` is invalid (e.g. `{foo, plural, offset: x}`) */ ErrorKind[ErrorKind["INVALID_PLURAL_ARGUMENT_OFFSET_VALUE"] = 14] = "INVALID_PLURAL_ARGUMENT_OFFSET_VALUE";
189
+ /** Expecting a selector in `select` argument (e.g `{foo, select}`) */ ErrorKind[ErrorKind["EXPECT_SELECT_ARGUMENT_SELECTOR"] = 15] = "EXPECT_SELECT_ARGUMENT_SELECTOR";
190
+ /** Expecting a selector in `plural` or `selectordinal` argument (e.g `{foo, plural}`) */ ErrorKind[ErrorKind["EXPECT_PLURAL_ARGUMENT_SELECTOR"] = 16] = "EXPECT_PLURAL_ARGUMENT_SELECTOR";
191
+ /** Expecting a message fragment after the `select` selector (e.g. `{foo, select, apple}`) */ ErrorKind[ErrorKind["EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT"] = 17] = "EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT";
192
+ /**
193
+ * Expecting a message fragment after the `plural` or `selectordinal` selector
194
+ * (e.g. `{foo, plural, one}`)
195
+ */ ErrorKind[ErrorKind["EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT"] = 18] = "EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT";
196
+ /** Selector in `plural` or `selectordinal` is malformed (e.g. `{foo, plural, =x {#}}`) */ ErrorKind[ErrorKind["INVALID_PLURAL_ARGUMENT_SELECTOR"] = 19] = "INVALID_PLURAL_ARGUMENT_SELECTOR";
197
+ /**
198
+ * Duplicate selectors in `plural` or `selectordinal` argument.
199
+ * (e.g. {foo, plural, one {#} one {#}})
200
+ */ ErrorKind[ErrorKind["DUPLICATE_PLURAL_ARGUMENT_SELECTOR"] = 20] = "DUPLICATE_PLURAL_ARGUMENT_SELECTOR";
201
+ /** Duplicate selectors in `select` argument.
202
+ * (e.g. {foo, select, apple {apple} apple {apple}})
203
+ */ ErrorKind[ErrorKind["DUPLICATE_SELECT_ARGUMENT_SELECTOR"] = 21] = "DUPLICATE_SELECT_ARGUMENT_SELECTOR";
204
+ /** Plural or select argument option must have `other` clause. */ ErrorKind[ErrorKind["MISSING_OTHER_CLAUSE"] = 22] = "MISSING_OTHER_CLAUSE";
205
+ /** The tag is malformed. (e.g. `<bold!>foo</bold!>) */ ErrorKind[ErrorKind["INVALID_TAG"] = 23] = "INVALID_TAG";
206
+ /** The tag name is invalid. (e.g. `<123>foo</123>`) */ ErrorKind[ErrorKind["INVALID_TAG_NAME"] = 25] = "INVALID_TAG_NAME";
207
+ /** The closing tag does not match the opening tag. (e.g. `<bold>foo</italic>`) */ ErrorKind[ErrorKind["UNMATCHED_CLOSING_TAG"] = 26] = "UNMATCHED_CLOSING_TAG";
208
+ /** The opening tag has unmatched closing tag. (e.g. `<bold>foo`) */ ErrorKind[ErrorKind["UNCLOSED_TAG"] = 27] = "UNCLOSED_TAG";
209
+ return ErrorKind;
210
+ }({});
211
+ //#endregion
212
+ //#region packages/icu-messageformat-parser/types.ts
213
+ var TYPE = /* @__PURE__ */ function(TYPE) {
214
+ /**
215
+ * Raw text
216
+ */ TYPE[TYPE["literal"] = 0] = "literal";
217
+ /**
218
+ * Variable w/o any format, e.g `var` in `this is a {var}`
219
+ */ TYPE[TYPE["argument"] = 1] = "argument";
220
+ /**
221
+ * Variable w/ number format
222
+ */ TYPE[TYPE["number"] = 2] = "number";
223
+ /**
224
+ * Variable w/ date format
225
+ */ TYPE[TYPE["date"] = 3] = "date";
226
+ /**
227
+ * Variable w/ time format
228
+ */ TYPE[TYPE["time"] = 4] = "time";
229
+ /**
230
+ * Variable w/ select format
231
+ */ TYPE[TYPE["select"] = 5] = "select";
232
+ /**
233
+ * Variable w/ plural format
234
+ */ TYPE[TYPE["plural"] = 6] = "plural";
235
+ /**
236
+ * Only possible within plural argument.
237
+ * This is the `#` symbol that will be substituted with the count.
238
+ */ TYPE[TYPE["pound"] = 7] = "pound";
239
+ /**
240
+ * XML-like tag
241
+ */ TYPE[TYPE["tag"] = 8] = "tag";
242
+ return TYPE;
243
+ }({});
244
+ var SKELETON_TYPE = /* @__PURE__ */ function(SKELETON_TYPE) {
245
+ SKELETON_TYPE[SKELETON_TYPE["number"] = 0] = "number";
246
+ SKELETON_TYPE[SKELETON_TYPE["dateTime"] = 1] = "dateTime";
247
+ return SKELETON_TYPE;
248
+ }({});
249
+ /**
250
+ * Type Guards
251
+ */ function isLiteralElement(el) {
252
+ return el.type === 0;
253
+ }
254
+ function isArgumentElement(el) {
255
+ return el.type === 1;
256
+ }
257
+ function isNumberElement(el) {
258
+ return el.type === 2;
259
+ }
260
+ function isDateElement(el) {
261
+ return el.type === 3;
262
+ }
263
+ function isTimeElement(el) {
264
+ return el.type === 4;
265
+ }
266
+ function isSelectElement(el) {
267
+ return el.type === 5;
268
+ }
269
+ function isPluralElement(el) {
270
+ return el.type === 6;
271
+ }
272
+ function isPoundElement(el) {
273
+ return el.type === 7;
274
+ }
275
+ function isTagElement(el) {
276
+ return el.type === 8;
277
+ }
278
+ function isNumberSkeleton(el) {
279
+ return !!(el && typeof el === "object" && el.type === 0);
280
+ }
281
+ function isDateTimeSkeleton(el) {
282
+ return !!(el && typeof el === "object" && el.type === 1);
283
+ }
284
+ function createLiteralElement(value) {
285
+ return {
286
+ type: 0,
287
+ value: value
288
+ };
289
+ }
290
+ function createNumberElement(value, style) {
291
+ return {
292
+ type: 2,
293
+ value: value,
294
+ style: style
295
+ };
296
+ }
297
+ //#endregion
298
+ //#region node_modules/.aspect_rules_js/@formatjs_generated+unicode@0.0.0/node_modules/@formatjs_generated/unicode/icu-messageformat-parser-regex.js
299
+ var SPACE_SEPARATOR_REGEX = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/;
300
+ //#endregion
301
+ //#region node_modules/.aspect_rules_js/@formatjs_generated+cldr.core@0.0.0/node_modules/@formatjs_generated/cldr.core/time-data.js
302
+ var timeData = {
303
+ "001": [
304
+ "H",
305
+ "h"
306
+ ],
307
+ "419": [
308
+ "h",
309
+ "H",
310
+ "hB",
311
+ "hb"
312
+ ],
313
+ "AC": [
314
+ "H",
315
+ "h",
316
+ "hb",
317
+ "hB"
318
+ ],
319
+ "AD": [
320
+ "H",
321
+ "hB"
322
+ ],
323
+ "AE": [
324
+ "h",
325
+ "hB",
326
+ "hb",
327
+ "H"
328
+ ],
329
+ "AF": [
330
+ "H",
331
+ "hb",
332
+ "hB",
333
+ "h"
334
+ ],
335
+ "AG": [
336
+ "h",
337
+ "hb",
338
+ "H",
339
+ "hB"
340
+ ],
341
+ "AI": [
342
+ "H",
343
+ "h",
344
+ "hb",
345
+ "hB"
346
+ ],
347
+ "AL": [
348
+ "h",
349
+ "H",
350
+ "hB"
351
+ ],
352
+ "AM": [
353
+ "H",
354
+ "hB"
355
+ ],
356
+ "AO": [
357
+ "H",
358
+ "hB"
359
+ ],
360
+ "AR": [
361
+ "h",
362
+ "H",
363
+ "hB",
364
+ "hb"
365
+ ],
366
+ "AS": [
367
+ "h",
368
+ "H"
369
+ ],
370
+ "AT": [
371
+ "H",
372
+ "hB"
373
+ ],
374
+ "AU": [
375
+ "h",
376
+ "hb",
377
+ "H",
378
+ "hB"
379
+ ],
380
+ "AW": [
381
+ "H",
382
+ "hB"
383
+ ],
384
+ "AX": [
385
+ "H"
386
+ ],
387
+ "AZ": [
388
+ "H",
389
+ "hB",
390
+ "h"
391
+ ],
392
+ "BA": [
393
+ "H",
394
+ "hB",
395
+ "h"
396
+ ],
397
+ "BB": [
398
+ "h",
399
+ "hb",
400
+ "H",
401
+ "hB"
402
+ ],
403
+ "BD": [
404
+ "h",
405
+ "hB",
406
+ "H"
407
+ ],
408
+ "BE": [
409
+ "H",
410
+ "hB"
411
+ ],
412
+ "BF": [
413
+ "H",
414
+ "hB"
415
+ ],
416
+ "BG": [
417
+ "H",
418
+ "hB",
419
+ "h"
420
+ ],
421
+ "BH": [
422
+ "h",
423
+ "hB",
424
+ "hb",
425
+ "H"
426
+ ],
427
+ "BI": [
428
+ "H",
429
+ "h"
430
+ ],
431
+ "BJ": [
432
+ "H",
433
+ "hB"
434
+ ],
435
+ "BL": [
436
+ "H",
437
+ "hB"
438
+ ],
439
+ "BM": [
440
+ "h",
441
+ "hb",
442
+ "H",
443
+ "hB"
444
+ ],
445
+ "BN": [
446
+ "hb",
447
+ "hB",
448
+ "h",
449
+ "H"
450
+ ],
451
+ "BO": [
452
+ "h",
453
+ "H",
454
+ "hB",
455
+ "hb"
456
+ ],
457
+ "BQ": [
458
+ "H"
459
+ ],
460
+ "BR": [
461
+ "H",
462
+ "hB"
463
+ ],
464
+ "BS": [
465
+ "h",
466
+ "hb",
467
+ "H",
468
+ "hB"
469
+ ],
470
+ "BT": [
471
+ "h",
472
+ "H"
473
+ ],
474
+ "BW": [
475
+ "H",
476
+ "h",
477
+ "hb",
478
+ "hB"
479
+ ],
480
+ "BY": [
481
+ "H",
482
+ "h"
483
+ ],
484
+ "BZ": [
485
+ "H",
486
+ "h",
487
+ "hb",
488
+ "hB"
489
+ ],
490
+ "CA": [
491
+ "h",
492
+ "hb",
493
+ "H",
494
+ "hB"
495
+ ],
496
+ "CC": [
497
+ "H",
498
+ "h",
499
+ "hb",
500
+ "hB"
501
+ ],
502
+ "CD": [
503
+ "hB",
504
+ "H"
505
+ ],
506
+ "CF": [
507
+ "H",
508
+ "h",
509
+ "hB"
510
+ ],
511
+ "CG": [
512
+ "H",
513
+ "hB"
514
+ ],
515
+ "CH": [
516
+ "H",
517
+ "hB",
518
+ "h"
519
+ ],
520
+ "CI": [
521
+ "H",
522
+ "hB"
523
+ ],
524
+ "CK": [
525
+ "H",
526
+ "h",
527
+ "hb",
528
+ "hB"
529
+ ],
530
+ "CL": [
531
+ "h",
532
+ "H",
533
+ "hB",
534
+ "hb"
535
+ ],
536
+ "CM": [
537
+ "H",
538
+ "h",
539
+ "hB"
540
+ ],
541
+ "CN": [
542
+ "H",
543
+ "hB",
544
+ "hb",
545
+ "h"
546
+ ],
547
+ "CO": [
548
+ "h",
549
+ "H",
550
+ "hB",
551
+ "hb"
552
+ ],
553
+ "CP": [
554
+ "H"
555
+ ],
556
+ "CR": [
557
+ "h",
558
+ "H",
559
+ "hB",
560
+ "hb"
561
+ ],
562
+ "CU": [
563
+ "h",
564
+ "H",
565
+ "hB",
566
+ "hb"
567
+ ],
568
+ "CV": [
569
+ "H",
570
+ "hB"
571
+ ],
572
+ "CW": [
573
+ "H",
574
+ "hB"
575
+ ],
576
+ "CX": [
577
+ "H",
578
+ "h",
579
+ "hb",
580
+ "hB"
581
+ ],
582
+ "CY": [
583
+ "h",
584
+ "H",
585
+ "hb",
586
+ "hB"
587
+ ],
588
+ "CZ": [
589
+ "H"
590
+ ],
591
+ "DE": [
592
+ "H",
593
+ "hB"
594
+ ],
595
+ "DG": [
596
+ "H",
597
+ "h",
598
+ "hb",
599
+ "hB"
600
+ ],
601
+ "DJ": [
602
+ "h",
603
+ "H"
604
+ ],
605
+ "DK": [
606
+ "H"
607
+ ],
608
+ "DM": [
609
+ "h",
610
+ "hb",
611
+ "H",
612
+ "hB"
613
+ ],
614
+ "DO": [
615
+ "h",
616
+ "H",
617
+ "hB",
618
+ "hb"
619
+ ],
620
+ "DZ": [
621
+ "h",
622
+ "hB",
623
+ "hb",
624
+ "H"
625
+ ],
626
+ "EA": [
627
+ "H",
628
+ "h",
629
+ "hB",
630
+ "hb"
631
+ ],
632
+ "EC": [
633
+ "h",
634
+ "H",
635
+ "hB",
636
+ "hb"
637
+ ],
638
+ "EE": [
639
+ "H",
640
+ "hB"
641
+ ],
642
+ "EG": [
643
+ "h",
644
+ "hB",
645
+ "hb",
646
+ "H"
647
+ ],
648
+ "EH": [
649
+ "h",
650
+ "hB",
651
+ "hb",
652
+ "H"
653
+ ],
654
+ "ER": [
655
+ "h",
656
+ "H"
657
+ ],
658
+ "ES": [
659
+ "H",
660
+ "hB",
661
+ "h",
662
+ "hb"
663
+ ],
664
+ "ET": [
665
+ "hB",
666
+ "hb",
667
+ "h",
668
+ "H"
669
+ ],
670
+ "FI": [
671
+ "H"
672
+ ],
673
+ "FJ": [
674
+ "h",
675
+ "hb",
676
+ "H",
677
+ "hB"
678
+ ],
679
+ "FK": [
680
+ "H",
681
+ "h",
682
+ "hb",
683
+ "hB"
684
+ ],
685
+ "FM": [
686
+ "h",
687
+ "hb",
688
+ "H",
689
+ "hB"
690
+ ],
691
+ "FO": [
692
+ "H",
693
+ "h"
694
+ ],
695
+ "FR": [
696
+ "H",
697
+ "hB"
698
+ ],
699
+ "GA": [
700
+ "H",
701
+ "hB"
702
+ ],
703
+ "GB": [
704
+ "H",
705
+ "h",
706
+ "hb",
707
+ "hB"
708
+ ],
709
+ "GD": [
710
+ "h",
711
+ "hb",
712
+ "H",
713
+ "hB"
714
+ ],
715
+ "GE": [
716
+ "H",
717
+ "hB",
718
+ "h"
719
+ ],
720
+ "GF": [
721
+ "H",
722
+ "hB"
723
+ ],
724
+ "GG": [
725
+ "H",
726
+ "h",
727
+ "hb",
728
+ "hB"
729
+ ],
730
+ "GH": [
731
+ "h",
732
+ "H"
733
+ ],
734
+ "GI": [
735
+ "H",
736
+ "h",
737
+ "hb",
738
+ "hB"
739
+ ],
740
+ "GL": [
741
+ "H",
742
+ "h"
743
+ ],
744
+ "GM": [
745
+ "h",
746
+ "hb",
747
+ "H",
748
+ "hB"
749
+ ],
750
+ "GN": [
751
+ "H",
752
+ "hB"
753
+ ],
754
+ "GP": [
755
+ "H",
756
+ "hB"
757
+ ],
758
+ "GQ": [
759
+ "H",
760
+ "hB",
761
+ "h",
762
+ "hb"
763
+ ],
764
+ "GR": [
765
+ "h",
766
+ "H",
767
+ "hb",
768
+ "hB"
769
+ ],
770
+ "GS": [
771
+ "H",
772
+ "h",
773
+ "hb",
774
+ "hB"
775
+ ],
776
+ "GT": [
777
+ "h",
778
+ "H",
779
+ "hB",
780
+ "hb"
781
+ ],
782
+ "GU": [
783
+ "h",
784
+ "hb",
785
+ "H",
786
+ "hB"
787
+ ],
788
+ "GW": [
789
+ "H",
790
+ "hB"
791
+ ],
792
+ "GY": [
793
+ "h",
794
+ "hb",
795
+ "H",
796
+ "hB"
797
+ ],
798
+ "HK": [
799
+ "h",
800
+ "hB",
801
+ "hb",
802
+ "H"
803
+ ],
804
+ "HN": [
805
+ "h",
806
+ "H",
807
+ "hB",
808
+ "hb"
809
+ ],
810
+ "HR": [
811
+ "H",
812
+ "hB"
813
+ ],
814
+ "HU": [
815
+ "H",
816
+ "h"
817
+ ],
818
+ "IC": [
819
+ "H",
820
+ "h",
821
+ "hB",
822
+ "hb"
823
+ ],
824
+ "ID": [
825
+ "H"
826
+ ],
827
+ "IE": [
828
+ "H",
829
+ "h",
830
+ "hb",
831
+ "hB"
832
+ ],
833
+ "IL": [
834
+ "H",
835
+ "hB"
836
+ ],
837
+ "IM": [
838
+ "H",
839
+ "h",
840
+ "hb",
841
+ "hB"
842
+ ],
843
+ "IN": [
844
+ "h",
845
+ "H"
846
+ ],
847
+ "IO": [
848
+ "H",
849
+ "h",
850
+ "hb",
851
+ "hB"
852
+ ],
853
+ "IQ": [
854
+ "h",
855
+ "hB",
856
+ "hb",
857
+ "H"
858
+ ],
859
+ "IR": [
860
+ "hB",
861
+ "H"
862
+ ],
863
+ "IS": [
864
+ "H"
865
+ ],
866
+ "IT": [
867
+ "H",
868
+ "hB"
869
+ ],
870
+ "JE": [
871
+ "H",
872
+ "h",
873
+ "hb",
874
+ "hB"
875
+ ],
876
+ "JM": [
877
+ "h",
878
+ "hb",
879
+ "H",
880
+ "hB"
881
+ ],
882
+ "JO": [
883
+ "h",
884
+ "hB",
885
+ "hb",
886
+ "H"
887
+ ],
888
+ "JP": [
889
+ "H",
890
+ "K",
891
+ "h"
892
+ ],
893
+ "KE": [
894
+ "hB",
895
+ "hb",
896
+ "H",
897
+ "h"
898
+ ],
899
+ "KG": [
900
+ "H",
901
+ "h",
902
+ "hB",
903
+ "hb"
904
+ ],
905
+ "KH": [
906
+ "hB",
907
+ "h",
908
+ "H",
909
+ "hb"
910
+ ],
911
+ "KI": [
912
+ "h",
913
+ "hb",
914
+ "H",
915
+ "hB"
916
+ ],
917
+ "KM": [
918
+ "H",
919
+ "h",
920
+ "hB",
921
+ "hb"
922
+ ],
923
+ "KN": [
924
+ "h",
925
+ "hb",
926
+ "H",
927
+ "hB"
928
+ ],
929
+ "KP": [
930
+ "h",
931
+ "H",
932
+ "hB",
933
+ "hb"
934
+ ],
935
+ "KR": [
936
+ "h",
937
+ "H",
938
+ "hB",
939
+ "hb"
940
+ ],
941
+ "KW": [
942
+ "h",
943
+ "hB",
944
+ "hb",
945
+ "H"
946
+ ],
947
+ "KY": [
948
+ "h",
949
+ "hb",
950
+ "H",
951
+ "hB"
952
+ ],
953
+ "KZ": [
954
+ "H",
955
+ "hB"
956
+ ],
957
+ "LA": [
958
+ "H",
959
+ "hb",
960
+ "hB",
961
+ "h"
962
+ ],
963
+ "LB": [
964
+ "h",
965
+ "hB",
966
+ "hb",
967
+ "H"
968
+ ],
969
+ "LC": [
970
+ "h",
971
+ "hb",
972
+ "H",
973
+ "hB"
974
+ ],
975
+ "LI": [
976
+ "H",
977
+ "hB",
978
+ "h"
979
+ ],
980
+ "LK": [
981
+ "H",
982
+ "h",
983
+ "hB",
984
+ "hb"
985
+ ],
986
+ "LR": [
987
+ "h",
988
+ "hb",
989
+ "H",
990
+ "hB"
991
+ ],
992
+ "LS": [
993
+ "h",
994
+ "H"
995
+ ],
996
+ "LT": [
997
+ "H",
998
+ "h",
999
+ "hb",
1000
+ "hB"
1001
+ ],
1002
+ "LU": [
1003
+ "H",
1004
+ "h",
1005
+ "hB"
1006
+ ],
1007
+ "LV": [
1008
+ "H",
1009
+ "hB",
1010
+ "hb",
1011
+ "h"
1012
+ ],
1013
+ "LY": [
1014
+ "h",
1015
+ "hB",
1016
+ "hb",
1017
+ "H"
1018
+ ],
1019
+ "MA": [
1020
+ "H",
1021
+ "h",
1022
+ "hB",
1023
+ "hb"
1024
+ ],
1025
+ "MC": [
1026
+ "H",
1027
+ "hB"
1028
+ ],
1029
+ "MD": [
1030
+ "H",
1031
+ "hB"
1032
+ ],
1033
+ "ME": [
1034
+ "H",
1035
+ "hB",
1036
+ "h"
1037
+ ],
1038
+ "MF": [
1039
+ "H",
1040
+ "hB"
1041
+ ],
1042
+ "MG": [
1043
+ "H",
1044
+ "h"
1045
+ ],
1046
+ "MH": [
1047
+ "h",
1048
+ "hb",
1049
+ "H",
1050
+ "hB"
1051
+ ],
1052
+ "MK": [
1053
+ "H",
1054
+ "h",
1055
+ "hb",
1056
+ "hB"
1057
+ ],
1058
+ "ML": [
1059
+ "H"
1060
+ ],
1061
+ "MM": [
1062
+ "hB",
1063
+ "hb",
1064
+ "H",
1065
+ "h"
1066
+ ],
1067
+ "MN": [
1068
+ "H",
1069
+ "h",
1070
+ "hb",
1071
+ "hB"
1072
+ ],
1073
+ "MO": [
1074
+ "h",
1075
+ "hB",
1076
+ "hb",
1077
+ "H"
1078
+ ],
1079
+ "MP": [
1080
+ "h",
1081
+ "hb",
1082
+ "H",
1083
+ "hB"
1084
+ ],
1085
+ "MQ": [
1086
+ "H",
1087
+ "hB"
1088
+ ],
1089
+ "MR": [
1090
+ "h",
1091
+ "hB",
1092
+ "hb",
1093
+ "H"
1094
+ ],
1095
+ "MS": [
1096
+ "H",
1097
+ "h",
1098
+ "hb",
1099
+ "hB"
1100
+ ],
1101
+ "MT": [
1102
+ "H",
1103
+ "h"
1104
+ ],
1105
+ "MU": [
1106
+ "H",
1107
+ "h"
1108
+ ],
1109
+ "MV": [
1110
+ "H",
1111
+ "h"
1112
+ ],
1113
+ "MW": [
1114
+ "h",
1115
+ "hb",
1116
+ "H",
1117
+ "hB"
1118
+ ],
1119
+ "MX": [
1120
+ "h",
1121
+ "H",
1122
+ "hB",
1123
+ "hb"
1124
+ ],
1125
+ "MY": [
1126
+ "hb",
1127
+ "hB",
1128
+ "h",
1129
+ "H"
1130
+ ],
1131
+ "MZ": [
1132
+ "H",
1133
+ "hB"
1134
+ ],
1135
+ "NA": [
1136
+ "h",
1137
+ "H",
1138
+ "hB",
1139
+ "hb"
1140
+ ],
1141
+ "NC": [
1142
+ "H",
1143
+ "hB"
1144
+ ],
1145
+ "NE": [
1146
+ "H"
1147
+ ],
1148
+ "NF": [
1149
+ "H",
1150
+ "h",
1151
+ "hb",
1152
+ "hB"
1153
+ ],
1154
+ "NG": [
1155
+ "H",
1156
+ "h",
1157
+ "hb",
1158
+ "hB"
1159
+ ],
1160
+ "NI": [
1161
+ "h",
1162
+ "H",
1163
+ "hB",
1164
+ "hb"
1165
+ ],
1166
+ "NL": [
1167
+ "H",
1168
+ "hB"
1169
+ ],
1170
+ "NO": [
1171
+ "H",
1172
+ "h"
1173
+ ],
1174
+ "NP": [
1175
+ "H",
1176
+ "h",
1177
+ "hB"
1178
+ ],
1179
+ "NR": [
1180
+ "H",
1181
+ "h",
1182
+ "hb",
1183
+ "hB"
1184
+ ],
1185
+ "NU": [
1186
+ "H",
1187
+ "h",
1188
+ "hb",
1189
+ "hB"
1190
+ ],
1191
+ "NZ": [
1192
+ "h",
1193
+ "hb",
1194
+ "H",
1195
+ "hB"
1196
+ ],
1197
+ "OM": [
1198
+ "h",
1199
+ "hB",
1200
+ "hb",
1201
+ "H"
1202
+ ],
1203
+ "PA": [
1204
+ "h",
1205
+ "H",
1206
+ "hB",
1207
+ "hb"
1208
+ ],
1209
+ "PE": [
1210
+ "h",
1211
+ "H",
1212
+ "hB",
1213
+ "hb"
1214
+ ],
1215
+ "PF": [
1216
+ "H",
1217
+ "h",
1218
+ "hB"
1219
+ ],
1220
+ "PG": [
1221
+ "h",
1222
+ "H"
1223
+ ],
1224
+ "PH": [
1225
+ "h",
1226
+ "hB",
1227
+ "hb",
1228
+ "H"
1229
+ ],
1230
+ "PK": [
1231
+ "h",
1232
+ "hB",
1233
+ "H"
1234
+ ],
1235
+ "PL": [
1236
+ "H",
1237
+ "h"
1238
+ ],
1239
+ "PM": [
1240
+ "H",
1241
+ "hB"
1242
+ ],
1243
+ "PN": [
1244
+ "H",
1245
+ "h",
1246
+ "hb",
1247
+ "hB"
1248
+ ],
1249
+ "PR": [
1250
+ "h",
1251
+ "H",
1252
+ "hB",
1253
+ "hb"
1254
+ ],
1255
+ "PS": [
1256
+ "h",
1257
+ "hB",
1258
+ "hb",
1259
+ "H"
1260
+ ],
1261
+ "PT": [
1262
+ "H",
1263
+ "hB"
1264
+ ],
1265
+ "PW": [
1266
+ "h",
1267
+ "H"
1268
+ ],
1269
+ "PY": [
1270
+ "h",
1271
+ "H",
1272
+ "hB",
1273
+ "hb"
1274
+ ],
1275
+ "QA": [
1276
+ "h",
1277
+ "hB",
1278
+ "hb",
1279
+ "H"
1280
+ ],
1281
+ "RE": [
1282
+ "H",
1283
+ "hB"
1284
+ ],
1285
+ "RO": [
1286
+ "H",
1287
+ "hB"
1288
+ ],
1289
+ "RS": [
1290
+ "H",
1291
+ "hB",
1292
+ "h"
1293
+ ],
1294
+ "RU": [
1295
+ "H"
1296
+ ],
1297
+ "RW": [
1298
+ "H",
1299
+ "h"
1300
+ ],
1301
+ "SA": [
1302
+ "h",
1303
+ "hB",
1304
+ "hb",
1305
+ "H"
1306
+ ],
1307
+ "SB": [
1308
+ "h",
1309
+ "hb",
1310
+ "H",
1311
+ "hB"
1312
+ ],
1313
+ "SC": [
1314
+ "H",
1315
+ "h",
1316
+ "hB"
1317
+ ],
1318
+ "SD": [
1319
+ "h",
1320
+ "hB",
1321
+ "hb",
1322
+ "H"
1323
+ ],
1324
+ "SE": [
1325
+ "H"
1326
+ ],
1327
+ "SG": [
1328
+ "h",
1329
+ "hb",
1330
+ "H",
1331
+ "hB"
1332
+ ],
1333
+ "SH": [
1334
+ "H",
1335
+ "h",
1336
+ "hb",
1337
+ "hB"
1338
+ ],
1339
+ "SI": [
1340
+ "H",
1341
+ "hB"
1342
+ ],
1343
+ "SJ": [
1344
+ "H"
1345
+ ],
1346
+ "SK": [
1347
+ "H"
1348
+ ],
1349
+ "SL": [
1350
+ "h",
1351
+ "hb",
1352
+ "H",
1353
+ "hB"
1354
+ ],
1355
+ "SM": [
1356
+ "H",
1357
+ "h",
1358
+ "hB"
1359
+ ],
1360
+ "SN": [
1361
+ "H",
1362
+ "h",
1363
+ "hB"
1364
+ ],
1365
+ "SO": [
1366
+ "h",
1367
+ "H"
1368
+ ],
1369
+ "SR": [
1370
+ "H",
1371
+ "hB"
1372
+ ],
1373
+ "SS": [
1374
+ "h",
1375
+ "hb",
1376
+ "H",
1377
+ "hB"
1378
+ ],
1379
+ "ST": [
1380
+ "H",
1381
+ "hB"
1382
+ ],
1383
+ "SV": [
1384
+ "h",
1385
+ "H",
1386
+ "hB",
1387
+ "hb"
1388
+ ],
1389
+ "SX": [
1390
+ "H",
1391
+ "h",
1392
+ "hb",
1393
+ "hB"
1394
+ ],
1395
+ "SY": [
1396
+ "h",
1397
+ "hB",
1398
+ "hb",
1399
+ "H"
1400
+ ],
1401
+ "SZ": [
1402
+ "h",
1403
+ "hb",
1404
+ "H",
1405
+ "hB"
1406
+ ],
1407
+ "TA": [
1408
+ "H",
1409
+ "h",
1410
+ "hb",
1411
+ "hB"
1412
+ ],
1413
+ "TC": [
1414
+ "h",
1415
+ "hb",
1416
+ "H",
1417
+ "hB"
1418
+ ],
1419
+ "TD": [
1420
+ "h",
1421
+ "H",
1422
+ "hB"
1423
+ ],
1424
+ "TF": [
1425
+ "H",
1426
+ "h",
1427
+ "hB"
1428
+ ],
1429
+ "TG": [
1430
+ "H",
1431
+ "hB"
1432
+ ],
1433
+ "TH": [
1434
+ "H",
1435
+ "h"
1436
+ ],
1437
+ "TJ": [
1438
+ "H",
1439
+ "h"
1440
+ ],
1441
+ "TL": [
1442
+ "H",
1443
+ "hB",
1444
+ "hb",
1445
+ "h"
1446
+ ],
1447
+ "TM": [
1448
+ "H",
1449
+ "h"
1450
+ ],
1451
+ "TN": [
1452
+ "h",
1453
+ "hB",
1454
+ "hb",
1455
+ "H"
1456
+ ],
1457
+ "TO": [
1458
+ "h",
1459
+ "H"
1460
+ ],
1461
+ "TR": [
1462
+ "H",
1463
+ "hB"
1464
+ ],
1465
+ "TT": [
1466
+ "h",
1467
+ "hb",
1468
+ "H",
1469
+ "hB"
1470
+ ],
1471
+ "TW": [
1472
+ "hB",
1473
+ "hb",
1474
+ "h",
1475
+ "H"
1476
+ ],
1477
+ "TZ": [
1478
+ "hB",
1479
+ "hb",
1480
+ "H",
1481
+ "h"
1482
+ ],
1483
+ "UA": [
1484
+ "H",
1485
+ "hB",
1486
+ "h"
1487
+ ],
1488
+ "UG": [
1489
+ "hB",
1490
+ "hb",
1491
+ "H",
1492
+ "h"
1493
+ ],
1494
+ "UM": [
1495
+ "h",
1496
+ "hb",
1497
+ "H",
1498
+ "hB"
1499
+ ],
1500
+ "US": [
1501
+ "h",
1502
+ "hb",
1503
+ "H",
1504
+ "hB"
1505
+ ],
1506
+ "UY": [
1507
+ "h",
1508
+ "H",
1509
+ "hB",
1510
+ "hb"
1511
+ ],
1512
+ "UZ": [
1513
+ "H",
1514
+ "hB",
1515
+ "h"
1516
+ ],
1517
+ "VA": [
1518
+ "H",
1519
+ "h",
1520
+ "hB"
1521
+ ],
1522
+ "VC": [
1523
+ "h",
1524
+ "hb",
1525
+ "H",
1526
+ "hB"
1527
+ ],
1528
+ "VE": [
1529
+ "h",
1530
+ "H",
1531
+ "hB",
1532
+ "hb"
1533
+ ],
1534
+ "VG": [
1535
+ "h",
1536
+ "hb",
1537
+ "H",
1538
+ "hB"
1539
+ ],
1540
+ "VI": [
1541
+ "h",
1542
+ "hb",
1543
+ "H",
1544
+ "hB"
1545
+ ],
1546
+ "VN": [
1547
+ "H",
1548
+ "h"
1549
+ ],
1550
+ "VU": [
1551
+ "h",
1552
+ "H"
1553
+ ],
1554
+ "WF": [
1555
+ "H",
1556
+ "hB"
1557
+ ],
1558
+ "WS": [
1559
+ "h",
1560
+ "H"
1561
+ ],
1562
+ "XK": [
1563
+ "H",
1564
+ "hB",
1565
+ "h"
1566
+ ],
1567
+ "YE": [
1568
+ "h",
1569
+ "hB",
1570
+ "hb",
1571
+ "H"
1572
+ ],
1573
+ "YT": [
1574
+ "H",
1575
+ "hB"
1576
+ ],
1577
+ "ZA": [
1578
+ "H",
1579
+ "h",
1580
+ "hb",
1581
+ "hB"
1582
+ ],
1583
+ "ZM": [
1584
+ "h",
1585
+ "hb",
1586
+ "H",
1587
+ "hB"
1588
+ ],
1589
+ "ZW": [
1590
+ "H",
1591
+ "h"
1592
+ ],
1593
+ "af-ZA": [
1594
+ "H",
1595
+ "h",
1596
+ "hB",
1597
+ "hb"
1598
+ ],
1599
+ "ar-001": [
1600
+ "h",
1601
+ "hB",
1602
+ "hb",
1603
+ "H"
1604
+ ],
1605
+ "ca-ES": [
1606
+ "H",
1607
+ "h",
1608
+ "hB"
1609
+ ],
1610
+ "en-001": [
1611
+ "h",
1612
+ "hb",
1613
+ "H",
1614
+ "hB"
1615
+ ],
1616
+ "en-HK": [
1617
+ "h",
1618
+ "hb",
1619
+ "H",
1620
+ "hB"
1621
+ ],
1622
+ "en-IL": [
1623
+ "H",
1624
+ "h",
1625
+ "hb",
1626
+ "hB"
1627
+ ],
1628
+ "en-MY": [
1629
+ "h",
1630
+ "hb",
1631
+ "H",
1632
+ "hB"
1633
+ ],
1634
+ "es-BR": [
1635
+ "H",
1636
+ "h",
1637
+ "hB",
1638
+ "hb"
1639
+ ],
1640
+ "es-ES": [
1641
+ "H",
1642
+ "h",
1643
+ "hB",
1644
+ "hb"
1645
+ ],
1646
+ "es-GQ": [
1647
+ "H",
1648
+ "h",
1649
+ "hB",
1650
+ "hb"
1651
+ ],
1652
+ "fr-CA": [
1653
+ "H",
1654
+ "h",
1655
+ "hB"
1656
+ ],
1657
+ "gl-ES": [
1658
+ "H",
1659
+ "h",
1660
+ "hB"
1661
+ ],
1662
+ "gu-IN": [
1663
+ "hB",
1664
+ "hb",
1665
+ "h",
1666
+ "H"
1667
+ ],
1668
+ "hi-IN": [
1669
+ "hB",
1670
+ "h",
1671
+ "H"
1672
+ ],
1673
+ "it-CH": [
1674
+ "H",
1675
+ "h",
1676
+ "hB"
1677
+ ],
1678
+ "it-IT": [
1679
+ "H",
1680
+ "h",
1681
+ "hB"
1682
+ ],
1683
+ "kn-IN": [
1684
+ "hB",
1685
+ "h",
1686
+ "H"
1687
+ ],
1688
+ "ku-SY": [
1689
+ "H",
1690
+ "hB"
1691
+ ],
1692
+ "ml-IN": [
1693
+ "hB",
1694
+ "h",
1695
+ "H"
1696
+ ],
1697
+ "mr-IN": [
1698
+ "hB",
1699
+ "hb",
1700
+ "h",
1701
+ "H"
1702
+ ],
1703
+ "pa-IN": [
1704
+ "hB",
1705
+ "hb",
1706
+ "h",
1707
+ "H"
1708
+ ],
1709
+ "ta-IN": [
1710
+ "hB",
1711
+ "h",
1712
+ "hb",
1713
+ "H"
1714
+ ],
1715
+ "te-IN": [
1716
+ "hB",
1717
+ "h",
1718
+ "H"
1719
+ ],
1720
+ "zu-ZA": [
1721
+ "H",
1722
+ "hB",
1723
+ "hb",
1724
+ "h"
1725
+ ]
1726
+ };
1727
+ //#endregion
1728
+ //#region packages/icu-messageformat-parser/date-time-pattern-generator.ts
1729
+ /**
1730
+ * Returns the best matching date time pattern if a date time skeleton
1731
+ * pattern is provided with a locale. Follows the Unicode specification:
1732
+ * https://www.unicode.org/reports/tr35/tr35-dates.html#table-mapping-requested-time-skeletons-to-patterns
1733
+ * @param skeleton date time skeleton pattern that possibly includes j, J or C
1734
+ * @param locale
1735
+ */ function getBestPattern(skeleton, locale) {
1736
+ var skeletonCopy = "";
1737
+ for(var patternPos = 0; patternPos < skeleton.length; patternPos++){
1738
+ var patternChar = skeleton.charAt(patternPos);
1739
+ if (patternChar === "j") {
1740
+ var extraLength = 0;
1741
+ while(patternPos + 1 < skeleton.length && skeleton.charAt(patternPos + 1) === patternChar){
1742
+ extraLength++;
1743
+ patternPos++;
1744
+ }
1745
+ var hourLen = 1 + (extraLength & 1);
1746
+ var dayPeriodLen = extraLength < 2 ? 1 : 3 + (extraLength >> 1);
1747
+ var dayPeriodChar = "a";
1748
+ var hourChar = getDefaultHourSymbolFromLocale(locale);
1749
+ if (hourChar == "H" || hourChar == "k") dayPeriodLen = 0;
1750
+ while(dayPeriodLen-- > 0)skeletonCopy += dayPeriodChar;
1751
+ while(hourLen-- > 0)skeletonCopy = hourChar + skeletonCopy;
1752
+ } else if (patternChar === "J") skeletonCopy += "H";
1753
+ else skeletonCopy += patternChar;
1754
+ }
1755
+ return skeletonCopy;
1756
+ }
1757
+ /**
1758
+ * Maps the [hour cycle type](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/hourCycle)
1759
+ * of the given `locale` to the corresponding time pattern.
1760
+ * @param locale
1761
+ */ function getDefaultHourSymbolFromLocale(locale) {
1762
+ var hourCycle = locale.hourCycle;
1763
+ if (hourCycle === void 0 && locale.hourCycles && locale.hourCycles.length) hourCycle = locale.hourCycles[0];
1764
+ if (hourCycle) switch(hourCycle){
1765
+ case "h24":
1766
+ return "k";
1767
+ case "h23":
1768
+ return "H";
1769
+ case "h12":
1770
+ return "h";
1771
+ case "h11":
1772
+ return "K";
1773
+ default:
1774
+ throw new Error("Invalid hourCycle");
1775
+ }
1776
+ var languageTag = locale.language;
1777
+ var regionTag;
1778
+ if (languageTag !== "root") regionTag = locale.maximize().region;
1779
+ return (timeData[regionTag || ""] || timeData[languageTag || ""] || timeData["".concat(languageTag, "-001")] || timeData["001"])[0];
1780
+ }
1781
+ //#endregion
1782
+ //#region packages/icu-messageformat-parser/parser.ts
1783
+ var SPACE_SEPARATOR_START_REGEX = new RegExp("^".concat(SPACE_SEPARATOR_REGEX.source, "*"));
1784
+ var SPACE_SEPARATOR_END_REGEX = new RegExp("".concat(SPACE_SEPARATOR_REGEX.source, "*$"));
1785
+ function createLocation(start, end) {
1786
+ return {
1787
+ start: start,
1788
+ end: end
1789
+ };
1790
+ }
1791
+ var hasNativeFromEntries = !!Object.fromEntries;
1792
+ var hasTrimStart = !!String.prototype.trimStart;
1793
+ var hasTrimEnd = !!String.prototype.trimEnd;
1794
+ var fromEntries = hasNativeFromEntries ? Object.fromEntries : function fromEntries(entries) {
1795
+ var obj = {};
1796
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1797
+ try {
1798
+ for(var _iterator = entries[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1799
+ var _value = _slicedToArray(_step.value, 2), k = _value[0], v = _value[1];
1800
+ obj[k] = v;
1801
+ }
1802
+ } catch (err) {
1803
+ _didIteratorError = true;
1804
+ _iteratorError = err;
1805
+ } finally{
1806
+ try {
1807
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1808
+ _iterator.return();
1809
+ }
1810
+ } finally{
1811
+ if (_didIteratorError) {
1812
+ throw _iteratorError;
1813
+ }
1814
+ }
1815
+ }
1816
+ return obj;
1817
+ };
1818
+ var trimStart = hasTrimStart ? function trimStart(s) {
1819
+ return s.trimStart();
1820
+ } : function trimStart(s) {
1821
+ return s.replace(SPACE_SEPARATOR_START_REGEX, "");
1822
+ };
1823
+ var trimEnd = hasTrimEnd ? function trimEnd(s) {
1824
+ return s.trimEnd();
1825
+ } : function trimEnd(s) {
1826
+ return s.replace(SPACE_SEPARATOR_END_REGEX, "");
1827
+ };
1828
+ var IDENTIFIER_PREFIX_RE = /* @__PURE__ */ new RegExp("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
1829
+ function matchIdentifierAtIndex(s, index) {
1830
+ IDENTIFIER_PREFIX_RE.lastIndex = index;
1831
+ var ref;
1832
+ return (ref = IDENTIFIER_PREFIX_RE.exec(s)[1]) !== null && ref !== void 0 ? ref : "";
1833
+ }
1834
+ function plainTopLevelEndPosition(message) {
1835
+ if (message.length === 0) return null;
1836
+ var line = 1;
1837
+ var column = 1;
1838
+ for(var offset = 0; offset < message.length;){
1839
+ var code = message.charCodeAt(offset);
1840
+ switch(code){
1841
+ case 35:
1842
+ case 39:
1843
+ case 60:
1844
+ case 123:
1845
+ case 125:
1846
+ return null;
1847
+ }
1848
+ if (code === 10) {
1849
+ line++;
1850
+ column = 1;
1851
+ offset++;
1852
+ } else {
1853
+ column++;
1854
+ if (code >= 55296 && code <= 56319 && offset + 1 < message.length) {
1855
+ var next = message.charCodeAt(offset + 1);
1856
+ offset += next >= 56320 && next <= 57343 ? 2 : 1;
1857
+ } else offset++;
1858
+ }
1859
+ }
1860
+ return {
1861
+ offset: message.length,
1862
+ line: line,
1863
+ column: column
1864
+ };
1865
+ }
1866
+ var Parser = /*#__PURE__*/ function() {
1867
+ "use strict";
1868
+ function Parser(message) {
1869
+ var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1870
+ _classCallCheck(this, Parser);
1871
+ this.message = message;
1872
+ this.position = {
1873
+ offset: 0,
1874
+ line: 1,
1875
+ column: 1
1876
+ };
1877
+ this.ignoreTag = !!options.ignoreTag;
1878
+ this.locale = options.locale;
1879
+ this.requiresOtherClause = !!options.requiresOtherClause;
1880
+ this.shouldParseSkeletons = !!options.shouldParseSkeletons;
1881
+ }
1882
+ _createClass(Parser, [
1883
+ {
1884
+ key: "parse",
1885
+ value: function parse() {
1886
+ if (this.offset() !== 0) throw Error("parser can only be used once");
1887
+ if (this.message.length > 0) {
1888
+ var firstCode = this.message.charCodeAt(0);
1889
+ if (firstCode !== 35 && firstCode !== 39 && firstCode !== 60 && firstCode !== 123 && firstCode !== 125) {
1890
+ var plainEndPosition = plainTopLevelEndPosition(this.message);
1891
+ if (plainEndPosition) {
1892
+ var start = this.clonePosition();
1893
+ this.position = plainEndPosition;
1894
+ return {
1895
+ val: [
1896
+ {
1897
+ type: 0,
1898
+ value: this.message,
1899
+ location: createLocation(start, this.clonePosition())
1900
+ }
1901
+ ],
1902
+ err: null
1903
+ };
1904
+ }
1905
+ }
1906
+ }
1907
+ return this.parseMessage(0, "", false);
1908
+ }
1909
+ },
1910
+ {
1911
+ key: "parseMessage",
1912
+ value: function parseMessage(nestingLevel, parentArgType, expectingCloseTag) {
1913
+ var elements = [];
1914
+ while(!this.isEOF()){
1915
+ var char = this.char();
1916
+ if (char === 123) {
1917
+ var result = this.parseArgument(nestingLevel, expectingCloseTag);
1918
+ if (result.err) return result;
1919
+ elements.push(result.val);
1920
+ } else if (char === 125 && nestingLevel > 0) break;
1921
+ else if (char === 35 && (parentArgType === "plural" || parentArgType === "selectordinal")) {
1922
+ var position = this.clonePosition();
1923
+ this.bump();
1924
+ elements.push({
1925
+ type: 7,
1926
+ location: createLocation(position, this.clonePosition())
1927
+ });
1928
+ } else if (char === 60 && !this.ignoreTag && this.peek() === 47) if (expectingCloseTag) break;
1929
+ else return this.error(26, createLocation(this.clonePosition(), this.clonePosition()));
1930
+ else if (char === 60 && !this.ignoreTag && _isAlpha(this.peek() || 0)) {
1931
+ var result1 = this.parseTag(nestingLevel, parentArgType);
1932
+ if (result1.err) return result1;
1933
+ elements.push(result1.val);
1934
+ } else {
1935
+ var result2 = this.parseLiteral(nestingLevel, parentArgType);
1936
+ if (result2.err) return result2;
1937
+ elements.push(result2.val);
1938
+ }
1939
+ }
1940
+ return {
1941
+ val: elements,
1942
+ err: null
1943
+ };
1944
+ }
1945
+ },
1946
+ {
1947
+ /**
1948
+ * A tag name must start with an ASCII lower/upper case letter. The grammar is based on the
1949
+ * [custom element name][] except that a dash is NOT always mandatory and uppercase letters
1950
+ * are accepted:
1951
+ *
1952
+ * ```
1953
+ * tag ::= "<" tagName (whitespace)* "/>" | "<" tagName (whitespace)* ">" message "</" tagName (whitespace)* ">"
1954
+ * tagName ::= [a-z] (PENChar)*
1955
+ * PENChar ::=
1956
+ * "-" | "." | [0-9] | "_" | [a-z] | [A-Z] | #xB7 | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x37D] |
1957
+ * [#x37F-#x1FFF] | [#x200C-#x200D] | [#x203F-#x2040] | [#x2070-#x218F] | [#x2C00-#x2FEF] |
1958
+ * [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
1959
+ * ```
1960
+ *
1961
+ * [custom element name]: https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
1962
+ * NOTE: We're a bit more lax here since HTML technically does not allow uppercase HTML element but we do
1963
+ * since other tag-based engines like React allow it
1964
+ */ key: "parseTag",
1965
+ value: function parseTag(nestingLevel, parentArgType) {
1966
+ var startPosition = this.clonePosition();
1967
+ this.bump();
1968
+ var tagName = this.parseTagName();
1969
+ this.bumpSpace();
1970
+ if (this.bumpIf("/>")) return {
1971
+ val: {
1972
+ type: 0,
1973
+ value: "<".concat(tagName, "/>"),
1974
+ location: createLocation(startPosition, this.clonePosition())
1975
+ },
1976
+ err: null
1977
+ };
1978
+ else if (this.bumpIf(">")) {
1979
+ var childrenResult = this.parseMessage(nestingLevel + 1, parentArgType, true);
1980
+ if (childrenResult.err) return childrenResult;
1981
+ var children = childrenResult.val;
1982
+ var endTagStartPosition = this.clonePosition();
1983
+ if (this.bumpIf("</")) {
1984
+ if (this.isEOF() || !_isAlpha(this.char())) return this.error(23, createLocation(endTagStartPosition, this.clonePosition()));
1985
+ var closingTagNameStartPosition = this.clonePosition();
1986
+ if (tagName !== this.parseTagName()) return this.error(26, createLocation(closingTagNameStartPosition, this.clonePosition()));
1987
+ this.bumpSpace();
1988
+ if (!this.bumpIf(">")) return this.error(23, createLocation(endTagStartPosition, this.clonePosition()));
1989
+ return {
1990
+ val: {
1991
+ type: 8,
1992
+ value: tagName,
1993
+ children: children,
1994
+ location: createLocation(startPosition, this.clonePosition())
1995
+ },
1996
+ err: null
1997
+ };
1998
+ } else return this.error(27, createLocation(startPosition, this.clonePosition()));
1999
+ } else return this.error(23, createLocation(startPosition, this.clonePosition()));
2000
+ }
2001
+ },
2002
+ {
2003
+ /**
2004
+ * This method assumes that the caller has peeked ahead for the first tag character.
2005
+ */ key: "parseTagName",
2006
+ value: function parseTagName() {
2007
+ var startOffset = this.offset();
2008
+ this.bump();
2009
+ while(!this.isEOF() && _isPotentialElementNameChar(this.char()))this.bump();
2010
+ return this.message.slice(startOffset, this.offset());
2011
+ }
2012
+ },
2013
+ {
2014
+ key: "parseLiteral",
2015
+ value: function parseLiteral(nestingLevel, parentArgType) {
2016
+ var start = this.clonePosition();
2017
+ var value = "";
2018
+ while(true){
2019
+ var parseQuoteResult = this.tryParseQuote(parentArgType);
2020
+ if (parseQuoteResult) {
2021
+ value += parseQuoteResult;
2022
+ continue;
2023
+ }
2024
+ var parseUnquotedResult = this.tryParseUnquoted(nestingLevel, parentArgType);
2025
+ if (parseUnquotedResult) {
2026
+ value += parseUnquotedResult;
2027
+ continue;
2028
+ }
2029
+ var parseLeftAngleResult = this.tryParseLeftAngleBracket();
2030
+ if (parseLeftAngleResult) {
2031
+ value += parseLeftAngleResult;
2032
+ continue;
2033
+ }
2034
+ break;
2035
+ }
2036
+ var location = createLocation(start, this.clonePosition());
2037
+ return {
2038
+ val: {
2039
+ type: 0,
2040
+ value: value,
2041
+ location: location
2042
+ },
2043
+ err: null
2044
+ };
2045
+ }
2046
+ },
2047
+ {
2048
+ key: "tryParseLeftAngleBracket",
2049
+ value: function tryParseLeftAngleBracket() {
2050
+ if (!this.isEOF() && this.char() === 60 && (this.ignoreTag || !_isAlphaOrSlash(this.peek() || 0))) {
2051
+ this.bump();
2052
+ return "<";
2053
+ }
2054
+ return null;
2055
+ }
2056
+ },
2057
+ {
2058
+ /**
2059
+ * Starting with ICU 4.8, an ASCII apostrophe only starts quoted text if it immediately precedes
2060
+ * a character that requires quoting (that is, "only where needed"), and works the same in
2061
+ * nested messages as on the top level of the pattern. The new behavior is otherwise compatible.
2062
+ */ key: "tryParseQuote",
2063
+ value: function tryParseQuote(parentArgType) {
2064
+ var _String;
2065
+ if (this.isEOF() || this.char() !== 39) return null;
2066
+ switch(this.peek()){
2067
+ case 39:
2068
+ this.bump();
2069
+ this.bump();
2070
+ return "'";
2071
+ case 123:
2072
+ case 60:
2073
+ case 62:
2074
+ case 125:
2075
+ break;
2076
+ case 35:
2077
+ if (parentArgType === "plural" || parentArgType === "selectordinal") break;
2078
+ return null;
2079
+ default:
2080
+ return null;
2081
+ }
2082
+ this.bump();
2083
+ var codePoints = [
2084
+ this.char()
2085
+ ];
2086
+ this.bump();
2087
+ while(!this.isEOF()){
2088
+ var ch = this.char();
2089
+ if (ch === 39) if (this.peek() === 39) {
2090
+ codePoints.push(39);
2091
+ this.bump();
2092
+ } else {
2093
+ this.bump();
2094
+ break;
2095
+ }
2096
+ else codePoints.push(ch);
2097
+ this.bump();
2098
+ }
2099
+ return (_String = String).fromCodePoint.apply(_String, _toConsumableArray(codePoints));
2100
+ }
2101
+ },
2102
+ {
2103
+ key: "tryParseUnquoted",
2104
+ value: function tryParseUnquoted(nestingLevel, parentArgType) {
2105
+ if (this.isEOF()) return null;
2106
+ var ch = this.char();
2107
+ if (ch === 60 || ch === 123 || ch === 35 && (parentArgType === "plural" || parentArgType === "selectordinal") || ch === 125 && nestingLevel > 0) return null;
2108
+ else {
2109
+ this.bump();
2110
+ return String.fromCodePoint(ch);
2111
+ }
2112
+ }
2113
+ },
2114
+ {
2115
+ key: "parseArgument",
2116
+ value: function parseArgument(nestingLevel, expectingCloseTag) {
2117
+ var openingBracePosition = this.clonePosition();
2118
+ this.bump();
2119
+ this.bumpSpace();
2120
+ if (this.isEOF()) return this.error(1, createLocation(openingBracePosition, this.clonePosition()));
2121
+ if (this.char() === 125) {
2122
+ this.bump();
2123
+ return this.error(2, createLocation(openingBracePosition, this.clonePosition()));
2124
+ }
2125
+ var value = this.parseIdentifierIfPossible().value;
2126
+ if (!value) return this.error(3, createLocation(openingBracePosition, this.clonePosition()));
2127
+ this.bumpSpace();
2128
+ if (this.isEOF()) return this.error(1, createLocation(openingBracePosition, this.clonePosition()));
2129
+ switch(this.char()){
2130
+ case 125:
2131
+ this.bump();
2132
+ return {
2133
+ val: {
2134
+ type: 1,
2135
+ value: value,
2136
+ location: createLocation(openingBracePosition, this.clonePosition())
2137
+ },
2138
+ err: null
2139
+ };
2140
+ case 44:
2141
+ this.bump();
2142
+ this.bumpSpace();
2143
+ if (this.isEOF()) return this.error(1, createLocation(openingBracePosition, this.clonePosition()));
2144
+ return this.parseArgumentOptions(nestingLevel, expectingCloseTag, value, openingBracePosition);
2145
+ default:
2146
+ return this.error(3, createLocation(openingBracePosition, this.clonePosition()));
2147
+ }
2148
+ }
2149
+ },
2150
+ {
2151
+ /**
2152
+ * Advance the parser until the end of the identifier, if it is currently on
2153
+ * an identifier character. Return an empty string otherwise.
2154
+ */ key: "parseIdentifierIfPossible",
2155
+ value: function parseIdentifierIfPossible() {
2156
+ var startingPosition = this.clonePosition();
2157
+ var startOffset = this.offset();
2158
+ var value = matchIdentifierAtIndex(this.message, startOffset);
2159
+ var endOffset = startOffset + value.length;
2160
+ this.bumpTo(endOffset);
2161
+ return {
2162
+ value: value,
2163
+ location: createLocation(startingPosition, this.clonePosition())
2164
+ };
2165
+ }
2166
+ },
2167
+ {
2168
+ key: "parseArgumentOptions",
2169
+ value: function parseArgumentOptions(nestingLevel, expectingCloseTag, value, openingBracePosition) {
2170
+ var typeStartPosition = this.clonePosition();
2171
+ var argType = this.parseIdentifierIfPossible().value;
2172
+ var typeEndPosition = this.clonePosition();
2173
+ switch(argType){
2174
+ case "":
2175
+ return this.error(4, createLocation(typeStartPosition, typeEndPosition));
2176
+ case "number":
2177
+ case "date":
2178
+ case "time":
2179
+ {
2180
+ this.bumpSpace();
2181
+ var styleAndLocation = null;
2182
+ if (this.bumpIf(",")) {
2183
+ this.bumpSpace();
2184
+ var styleStartPosition = this.clonePosition();
2185
+ var result = this.parseSimpleArgStyleIfPossible();
2186
+ if (result.err) return result;
2187
+ var style = trimEnd(result.val);
2188
+ if (style.length === 0) return this.error(6, createLocation(this.clonePosition(), this.clonePosition()));
2189
+ styleAndLocation = {
2190
+ style: style,
2191
+ styleLocation: createLocation(styleStartPosition, this.clonePosition())
2192
+ };
2193
+ }
2194
+ var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
2195
+ if (argCloseResult.err) return argCloseResult;
2196
+ var location = createLocation(openingBracePosition, this.clonePosition());
2197
+ if (styleAndLocation && styleAndLocation.style.startsWith("::")) {
2198
+ var skeleton = trimStart(styleAndLocation.style.slice(2));
2199
+ if (argType === "number") {
2200
+ var result1 = this.parseNumberSkeletonFromString(skeleton, styleAndLocation.styleLocation);
2201
+ if (result1.err) return result1;
2202
+ return {
2203
+ val: {
2204
+ type: 2,
2205
+ value: value,
2206
+ location: location,
2207
+ style: result1.val
2208
+ },
2209
+ err: null
2210
+ };
2211
+ } else {
2212
+ if (skeleton.length === 0) return this.error(10, location);
2213
+ var dateTimePattern = skeleton;
2214
+ if (this.locale) dateTimePattern = getBestPattern(skeleton, this.locale);
2215
+ var style1 = {
2216
+ type: 1,
2217
+ pattern: dateTimePattern,
2218
+ location: styleAndLocation.styleLocation,
2219
+ parsedOptions: this.shouldParseSkeletons ? (0, _icuSkeletonParser.parseDateTimeSkeleton)(dateTimePattern) : {}
2220
+ };
2221
+ return {
2222
+ val: {
2223
+ type: argType === "date" ? 3 : 4,
2224
+ value: value,
2225
+ location: location,
2226
+ style: style1
2227
+ },
2228
+ err: null
2229
+ };
2230
+ }
2231
+ }
2232
+ var ref;
2233
+ return {
2234
+ val: {
2235
+ type: argType === "number" ? 2 : argType === "date" ? 3 : 4,
2236
+ value: value,
2237
+ location: location,
2238
+ style: (ref = styleAndLocation === null || styleAndLocation === void 0 ? void 0 : styleAndLocation.style) !== null && ref !== void 0 ? ref : null
2239
+ },
2240
+ err: null
2241
+ };
2242
+ }
2243
+ case "plural":
2244
+ case "selectordinal":
2245
+ case "select":
2246
+ {
2247
+ var typeEndPosition1 = this.clonePosition();
2248
+ this.bumpSpace();
2249
+ if (!this.bumpIf(",")) return this.error(12, createLocation(typeEndPosition1, _objectSpread({}, typeEndPosition1)));
2250
+ this.bumpSpace();
2251
+ var identifierAndLocation = this.parseIdentifierIfPossible();
2252
+ var pluralOffset = 0;
2253
+ if (argType !== "select" && identifierAndLocation.value === "offset") {
2254
+ if (!this.bumpIf(":")) return this.error(13, createLocation(this.clonePosition(), this.clonePosition()));
2255
+ this.bumpSpace();
2256
+ var result2 = this.tryParseDecimalInteger(13, 14);
2257
+ if (result2.err) return result2;
2258
+ this.bumpSpace();
2259
+ identifierAndLocation = this.parseIdentifierIfPossible();
2260
+ pluralOffset = result2.val;
2261
+ }
2262
+ var optionsResult = this.tryParsePluralOrSelectOptions(nestingLevel, argType, expectingCloseTag, identifierAndLocation);
2263
+ if (optionsResult.err) return optionsResult;
2264
+ var argCloseResult1 = this.tryParseArgumentClose(openingBracePosition);
2265
+ if (argCloseResult1.err) return argCloseResult1;
2266
+ var location1 = createLocation(openingBracePosition, this.clonePosition());
2267
+ if (argType === "select") return {
2268
+ val: {
2269
+ type: 5,
2270
+ value: value,
2271
+ options: fromEntries(optionsResult.val),
2272
+ location: location1
2273
+ },
2274
+ err: null
2275
+ };
2276
+ else return {
2277
+ val: {
2278
+ type: 6,
2279
+ value: value,
2280
+ options: fromEntries(optionsResult.val),
2281
+ offset: pluralOffset,
2282
+ pluralType: argType === "plural" ? "cardinal" : "ordinal",
2283
+ location: location1
2284
+ },
2285
+ err: null
2286
+ };
2287
+ }
2288
+ default:
2289
+ return this.error(5, createLocation(typeStartPosition, typeEndPosition));
2290
+ }
2291
+ }
2292
+ },
2293
+ {
2294
+ key: "tryParseArgumentClose",
2295
+ value: function tryParseArgumentClose(openingBracePosition) {
2296
+ if (this.isEOF() || this.char() !== 125) return this.error(1, createLocation(openingBracePosition, this.clonePosition()));
2297
+ this.bump();
2298
+ return {
2299
+ val: true,
2300
+ err: null
2301
+ };
2302
+ }
2303
+ },
2304
+ {
2305
+ /**
2306
+ * See: https://github.com/unicode-org/icu/blob/af7ed1f6d2298013dc303628438ec4abe1f16479/icu4c/source/common/messagepattern.cpp#L659
2307
+ */ key: "parseSimpleArgStyleIfPossible",
2308
+ value: function parseSimpleArgStyleIfPossible() {
2309
+ var nestedBraces = 0;
2310
+ var startPosition = this.clonePosition();
2311
+ while(!this.isEOF())switch(this.char()){
2312
+ case 39:
2313
+ {
2314
+ this.bump();
2315
+ var apostrophePosition = this.clonePosition();
2316
+ if (!this.bumpUntil("'")) return this.error(11, createLocation(apostrophePosition, this.clonePosition()));
2317
+ this.bump();
2318
+ break;
2319
+ }
2320
+ case 123:
2321
+ nestedBraces += 1;
2322
+ this.bump();
2323
+ break;
2324
+ case 125:
2325
+ if (nestedBraces > 0) nestedBraces -= 1;
2326
+ else return {
2327
+ val: this.message.slice(startPosition.offset, this.offset()),
2328
+ err: null
2329
+ };
2330
+ break;
2331
+ default:
2332
+ this.bump();
2333
+ break;
2334
+ }
2335
+ return {
2336
+ val: this.message.slice(startPosition.offset, this.offset()),
2337
+ err: null
2338
+ };
2339
+ }
2340
+ },
2341
+ {
2342
+ key: "parseNumberSkeletonFromString",
2343
+ value: function parseNumberSkeletonFromString(skeleton, location) {
2344
+ var tokens = [];
2345
+ try {
2346
+ tokens = (0, _icuSkeletonParser.parseNumberSkeletonFromString)(skeleton);
2347
+ } catch (e) {
2348
+ return this.error(7, location);
2349
+ }
2350
+ return {
2351
+ val: {
2352
+ type: 0,
2353
+ tokens: tokens,
2354
+ location: location,
2355
+ parsedOptions: this.shouldParseSkeletons ? (0, _icuSkeletonParser.parseNumberSkeleton)(tokens) : {}
2356
+ },
2357
+ err: null
2358
+ };
2359
+ }
2360
+ },
2361
+ {
2362
+ /**
2363
+ * @param nesting_level The current nesting level of messages.
2364
+ * This can be positive when parsing message fragment in select or plural argument options.
2365
+ * @param parent_arg_type The parent argument's type.
2366
+ * @param parsed_first_identifier If provided, this is the first identifier-like selector of
2367
+ * the argument. It is a by-product of a previous parsing attempt.
2368
+ * @param expecting_close_tag If true, this message is directly or indirectly nested inside
2369
+ * between a pair of opening and closing tags. The nested message will not parse beyond
2370
+ * the closing tag boundary.
2371
+ */ key: "tryParsePluralOrSelectOptions",
2372
+ value: function tryParsePluralOrSelectOptions(nestingLevel, parentArgType, expectCloseTag, parsedFirstIdentifier) {
2373
+ var hasOtherClause = false;
2374
+ var options = [];
2375
+ var parsedSelectors = /* @__PURE__ */ new Set();
2376
+ var selector = parsedFirstIdentifier.value, selectorLocation = parsedFirstIdentifier.location;
2377
+ while(true){
2378
+ if (selector.length === 0) {
2379
+ var startPosition = this.clonePosition();
2380
+ if (parentArgType !== "select" && this.bumpIf("=")) {
2381
+ var result = this.tryParseDecimalInteger(16, 19);
2382
+ if (result.err) return result;
2383
+ selectorLocation = createLocation(startPosition, this.clonePosition());
2384
+ selector = this.message.slice(startPosition.offset, this.offset());
2385
+ } else break;
2386
+ }
2387
+ if (parsedSelectors.has(selector)) return this.error(parentArgType === "select" ? 21 : 20, selectorLocation);
2388
+ if (selector === "other") hasOtherClause = true;
2389
+ this.bumpSpace();
2390
+ var openingBracePosition = this.clonePosition();
2391
+ if (!this.bumpIf("{")) return this.error(parentArgType === "select" ? 17 : 18, createLocation(this.clonePosition(), this.clonePosition()));
2392
+ var fragmentResult = this.parseMessage(nestingLevel + 1, parentArgType, expectCloseTag);
2393
+ if (fragmentResult.err) return fragmentResult;
2394
+ var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
2395
+ if (argCloseResult.err) return argCloseResult;
2396
+ options.push([
2397
+ selector,
2398
+ {
2399
+ value: fragmentResult.val,
2400
+ location: createLocation(openingBracePosition, this.clonePosition())
2401
+ }
2402
+ ]);
2403
+ parsedSelectors.add(selector);
2404
+ this.bumpSpace();
2405
+ var ref;
2406
+ ref = this.parseIdentifierIfPossible(), selector = ref.value, selectorLocation = ref.location, ref;
2407
+ }
2408
+ if (options.length === 0) return this.error(parentArgType === "select" ? 15 : 16, createLocation(this.clonePosition(), this.clonePosition()));
2409
+ if (this.requiresOtherClause && !hasOtherClause) return this.error(22, createLocation(this.clonePosition(), this.clonePosition()));
2410
+ return {
2411
+ val: options,
2412
+ err: null
2413
+ };
2414
+ }
2415
+ },
2416
+ {
2417
+ key: "tryParseDecimalInteger",
2418
+ value: function tryParseDecimalInteger(expectNumberError, invalidNumberError) {
2419
+ var sign = 1;
2420
+ var startingPosition = this.clonePosition();
2421
+ if (this.bumpIf("+")) {} else if (this.bumpIf("-")) sign = -1;
2422
+ var hasDigits = false;
2423
+ var decimal = 0;
2424
+ while(!this.isEOF()){
2425
+ var ch = this.char();
2426
+ if (ch >= 48 && ch <= 57) {
2427
+ hasDigits = true;
2428
+ decimal = decimal * 10 + (ch - 48);
2429
+ this.bump();
2430
+ } else break;
2431
+ }
2432
+ var location = createLocation(startingPosition, this.clonePosition());
2433
+ if (!hasDigits) return this.error(expectNumberError, location);
2434
+ decimal *= sign;
2435
+ if (!Number.isSafeInteger(decimal)) return this.error(invalidNumberError, location);
2436
+ return {
2437
+ val: decimal,
2438
+ err: null
2439
+ };
2440
+ }
2441
+ },
2442
+ {
2443
+ key: "offset",
2444
+ value: function offset() {
2445
+ return this.position.offset;
2446
+ }
2447
+ },
2448
+ {
2449
+ key: "isEOF",
2450
+ value: function isEOF() {
2451
+ return this.offset() === this.message.length;
2452
+ }
2453
+ },
2454
+ {
2455
+ key: "clonePosition",
2456
+ value: function clonePosition() {
2457
+ return {
2458
+ offset: this.position.offset,
2459
+ line: this.position.line,
2460
+ column: this.position.column
2461
+ };
2462
+ }
2463
+ },
2464
+ {
2465
+ /**
2466
+ * Return the code point at the current position of the parser.
2467
+ * Throws if the index is out of bound.
2468
+ */ key: "char",
2469
+ value: function char() {
2470
+ var offset = this.position.offset;
2471
+ if (offset >= this.message.length) throw Error("out of bound");
2472
+ var code = this.message.codePointAt(offset);
2473
+ if (code === void 0) throw Error("Offset ".concat(offset, " is at invalid UTF-16 code unit boundary"));
2474
+ return code;
2475
+ }
2476
+ },
2477
+ {
2478
+ key: "error",
2479
+ value: function error(kind, location) {
2480
+ return {
2481
+ val: null,
2482
+ err: {
2483
+ kind: kind,
2484
+ message: this.message,
2485
+ location: location
2486
+ }
2487
+ };
2488
+ }
2489
+ },
2490
+ {
2491
+ /** Bump the parser to the next UTF-16 code unit. */ key: "bump",
2492
+ value: function bump() {
2493
+ if (this.isEOF()) return;
2494
+ var code = this.char();
2495
+ if (code === 10) {
2496
+ this.position.line += 1;
2497
+ this.position.column = 1;
2498
+ this.position.offset += 1;
2499
+ } else {
2500
+ this.position.column += 1;
2501
+ this.position.offset += code < 65536 ? 1 : 2;
2502
+ }
2503
+ }
2504
+ },
2505
+ {
2506
+ /**
2507
+ * If the substring starting at the current position of the parser has
2508
+ * the given prefix, then bump the parser to the character immediately
2509
+ * following the prefix and return true. Otherwise, don't bump the parser
2510
+ * and return false.
2511
+ */ key: "bumpIf",
2512
+ value: function bumpIf(prefix) {
2513
+ if (this.message.startsWith(prefix, this.offset())) {
2514
+ for(var i = 0; i < prefix.length; i++)this.bump();
2515
+ return true;
2516
+ }
2517
+ return false;
2518
+ }
2519
+ },
2520
+ {
2521
+ /**
2522
+ * Bump the parser until the pattern character is found and return `true`.
2523
+ * Otherwise bump to the end of the file and return `false`.
2524
+ */ key: "bumpUntil",
2525
+ value: function bumpUntil(pattern) {
2526
+ var currentOffset = this.offset();
2527
+ var index = this.message.indexOf(pattern, currentOffset);
2528
+ if (index >= 0) {
2529
+ this.bumpTo(index);
2530
+ return true;
2531
+ } else {
2532
+ this.bumpTo(this.message.length);
2533
+ return false;
2534
+ }
2535
+ }
2536
+ },
2537
+ {
2538
+ /**
2539
+ * Bump the parser to the target offset.
2540
+ * If target offset is beyond the end of the input, bump the parser to the end of the input.
2541
+ */ key: "bumpTo",
2542
+ value: function bumpTo(targetOffset) {
2543
+ if (this.offset() > targetOffset) throw Error("targetOffset ".concat(targetOffset, " must be greater than or equal to the current offset ").concat(this.offset()));
2544
+ targetOffset = Math.min(targetOffset, this.message.length);
2545
+ while(true){
2546
+ var offset = this.offset();
2547
+ if (offset === targetOffset) break;
2548
+ if (offset > targetOffset) throw Error("targetOffset ".concat(targetOffset, " is at invalid UTF-16 code unit boundary"));
2549
+ this.bump();
2550
+ if (this.isEOF()) break;
2551
+ }
2552
+ }
2553
+ },
2554
+ {
2555
+ /** advance the parser through all whitespace to the next non-whitespace code unit. */ key: "bumpSpace",
2556
+ value: function bumpSpace() {
2557
+ while(!this.isEOF() && _isWhiteSpace(this.char()))this.bump();
2558
+ }
2559
+ },
2560
+ {
2561
+ /**
2562
+ * Peek at the *next* Unicode codepoint in the input without advancing the parser.
2563
+ * If the input has been exhausted, then this returns null.
2564
+ */ key: "peek",
2565
+ value: function peek() {
2566
+ if (this.isEOF()) return null;
2567
+ var code = this.char();
2568
+ var offset = this.offset();
2569
+ var ref;
2570
+ return (ref = this.message.charCodeAt(offset + (code >= 65536 ? 2 : 1))) !== null && ref !== void 0 ? ref : null;
2571
+ }
2572
+ }
2573
+ ]);
2574
+ return Parser;
2575
+ }();
2576
+ /**
2577
+ * This check if codepoint is alphabet (lower & uppercase)
2578
+ * @param codepoint
2579
+ * @returns
2580
+ */ function _isAlpha(codepoint) {
2581
+ return codepoint >= 97 && codepoint <= 122 || codepoint >= 65 && codepoint <= 90;
2582
+ }
2583
+ function _isAlphaOrSlash(codepoint) {
2584
+ return _isAlpha(codepoint) || codepoint === 47;
2585
+ }
2586
+ /** See `parseTag` function docs. */ function _isPotentialElementNameChar(c) {
2587
+ 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;
2588
+ }
2589
+ /**
2590
+ * Code point equivalent of regex `\p{White_Space}`.
2591
+ * From: https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt
2592
+ */ function _isWhiteSpace(c) {
2593
+ return c >= 9 && c <= 13 || c === 32 || c === 133 || c >= 8206 && c <= 8207 || c === 8232 || c === 8233;
2594
+ }
2595
+ //#endregion
2596
+ //#region packages/icu-messageformat-parser/manipulator.ts
2597
+ /**
2598
+ * Collect all variables in an AST to Record<string, TYPE>
2599
+ * @param ast AST to collect variables from
2600
+ * @param vars Record of variable name to variable type
2601
+ */ function collectVariables(ast) {
2602
+ var vars = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : /* @__PURE__ */ new Map();
2603
+ ast.forEach(function(el) {
2604
+ if (isArgumentElement(el) || isDateElement(el) || isTimeElement(el) || isNumberElement(el)) if (vars.has(el.value)) {
2605
+ var existingType = vars.get(el.value);
2606
+ if (existingType !== el.type && existingType !== 6 && existingType !== 5) throw new Error("Variable ".concat(el.value, " has conflicting types"));
2607
+ } else vars.set(el.value, el.type);
2608
+ if (isPluralElement(el) || isSelectElement(el)) {
2609
+ vars.set(el.value, el.type);
2610
+ Object.keys(el.options).forEach(function(k) {
2611
+ collectVariables(el.options[k].value, vars);
2612
+ });
2613
+ }
2614
+ if (isTagElement(el)) {
2615
+ vars.set(el.value, el.type);
2616
+ collectVariables(el.children, vars);
2617
+ }
2618
+ });
2619
+ }
2620
+ /**
2621
+ * Check if 2 ASTs are structurally the same. This primarily means that
2622
+ * they have the same variables with the same type
2623
+ * @param a
2624
+ * @param b
2625
+ * @returns
2626
+ */ function isStructurallySame(a, b) {
2627
+ var aVars = /* @__PURE__ */ new Map();
2628
+ var bVars = /* @__PURE__ */ new Map();
2629
+ collectVariables(a, aVars);
2630
+ collectVariables(b, bVars);
2631
+ if (aVars.size !== bVars.size) return {
2632
+ success: false,
2633
+ error: /* @__PURE__ */ new Error("Different number of variables: [".concat(Array.from(aVars.keys()).join(", "), "] vs [").concat(Array.from(bVars.keys()).join(", "), "]"))
2634
+ };
2635
+ return Array.from(aVars.entries()).reduce(function(result, param) {
2636
+ var _param = _slicedToArray(param, 2), key = _param[0], type = _param[1];
2637
+ if (!result.success) return result;
2638
+ var bType = bVars.get(key);
2639
+ if (bType == null) return {
2640
+ success: false,
2641
+ error: /* @__PURE__ */ new Error("Missing variable ".concat(key, " in message"))
2642
+ };
2643
+ if (bType !== type) return {
2644
+ success: false,
2645
+ error: /* @__PURE__ */ new Error("Variable ".concat(key, " has conflicting types: ").concat(TYPE[type], " vs ").concat(TYPE[bType]))
2646
+ };
2647
+ return result;
2648
+ }, {
2649
+ success: true
2650
+ });
2651
+ }
2652
+ //#endregion
2653
+ //#region packages/icu-messageformat-parser/index.ts
2654
+ function pruneLocation(els) {
2655
+ els.forEach(function(el) {
2656
+ delete el.location;
2657
+ if (isSelectElement(el) || isPluralElement(el)) for(var k in el.options){
2658
+ delete el.options[k].location;
2659
+ pruneLocation(el.options[k].value);
2660
+ }
2661
+ else if (isNumberElement(el) && isNumberSkeleton(el.style)) delete el.style.location;
2662
+ else if ((isDateElement(el) || isTimeElement(el)) && isDateTimeSkeleton(el.style)) delete el.style.location;
2663
+ else if (isTagElement(el)) pruneLocation(el.children);
2664
+ });
2665
+ }
2666
+ function parse(message) {
2667
+ var opts = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
2668
+ opts = _objectSpread({
2669
+ shouldParseSkeletons: true,
2670
+ requiresOtherClause: true
2671
+ }, opts);
2672
+ var result = new Parser(message, opts).parse();
2673
+ if (result.err) {
2674
+ var error = SyntaxError(ErrorKind[result.err.kind]);
2675
+ error.location = result.err.location;
2676
+ error.originalMessage = result.err.message;
2677
+ throw error;
2678
+ }
2679
+ if (!(opts === null || opts === void 0 ? void 0 : opts.captureLocation)) pruneLocation(result.val);
2680
+ return result.val;
2681
+ }
2682
+ var _Parser = Parser;
2683
+ //# sourceMappingURL=index.js.map