@formatjs/icu-messageformat-parser 2.0.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.
Files changed (51) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +25 -0
  3. package/error.d.ts +69 -0
  4. package/error.d.ts.map +1 -0
  5. package/error.js +66 -0
  6. package/index.d.ts +5 -0
  7. package/index.d.ts.map +1 -0
  8. package/index.js +47 -0
  9. package/lib/error.d.ts +69 -0
  10. package/lib/error.d.ts.map +1 -0
  11. package/lib/error.js +63 -0
  12. package/lib/index.d.ts +5 -0
  13. package/lib/index.d.ts.map +1 -0
  14. package/lib/index.js +43 -0
  15. package/lib/manipulator.d.ts +14 -0
  16. package/lib/manipulator.d.ts.map +1 -0
  17. package/lib/manipulator.js +52 -0
  18. package/lib/no-parser.d.ts +3 -0
  19. package/lib/no-parser.d.ts.map +1 -0
  20. package/lib/no-parser.js +4 -0
  21. package/lib/parser.d.ts +143 -0
  22. package/lib/parser.d.ts.map +1 -0
  23. package/lib/parser.js +1267 -0
  24. package/lib/printer.d.ts +5 -0
  25. package/lib/printer.d.ts.map +1 -0
  26. package/lib/printer.js +91 -0
  27. package/lib/regex.generated.d.ts +3 -0
  28. package/lib/regex.generated.d.ts.map +1 -0
  29. package/lib/regex.generated.js +3 -0
  30. package/lib/types.d.ts +129 -0
  31. package/lib/types.d.ts.map +1 -0
  32. package/lib/types.js +94 -0
  33. package/manipulator.d.ts +14 -0
  34. package/manipulator.d.ts.map +1 -0
  35. package/manipulator.js +56 -0
  36. package/no-parser.d.ts +3 -0
  37. package/no-parser.d.ts.map +1 -0
  38. package/no-parser.js +9 -0
  39. package/package.json +13 -0
  40. package/parser.d.ts +143 -0
  41. package/parser.d.ts.map +1 -0
  42. package/parser.js +1270 -0
  43. package/printer.d.ts +5 -0
  44. package/printer.d.ts.map +1 -0
  45. package/printer.js +97 -0
  46. package/regex.generated.d.ts +3 -0
  47. package/regex.generated.d.ts.map +1 -0
  48. package/regex.generated.js +6 -0
  49. package/types.d.ts +129 -0
  50. package/types.d.ts.map +1 -0
  51. package/types.js +110 -0
package/lib/parser.js ADDED
@@ -0,0 +1,1267 @@
1
+ var _a;
2
+ import { __assign } from "tslib";
3
+ import { ErrorKind } from './error';
4
+ import { SKELETON_TYPE, TYPE, } from './types';
5
+ import { SPACE_SEPARATOR_REGEX } from './regex.generated';
6
+ import { parseNumberSkeleton, parseNumberSkeletonFromString, parseDateTimeSkeleton, } from '@formatjs/icu-skeleton-parser';
7
+ var SPACE_SEPARATOR_START_REGEX = new RegExp("^" + SPACE_SEPARATOR_REGEX.source + "*");
8
+ var SPACE_SEPARATOR_END_REGEX = new RegExp(SPACE_SEPARATOR_REGEX.source + "*$");
9
+ function createLocation(start, end) {
10
+ return { start: start, end: end };
11
+ }
12
+ // #region Ponyfills
13
+ // Consolidate these variables up top for easier toggling during debugging
14
+ var hasNativeStartsWith = !!String.prototype.startsWith;
15
+ var hasNativeFromCodePoint = !!String.fromCodePoint;
16
+ var hasNativeFromEntries = !!Object.fromEntries;
17
+ var hasNativeCodePointAt = !!String.prototype.codePointAt;
18
+ var hasTrimStart = !!String.prototype.trimStart;
19
+ var hasTrimEnd = !!String.prototype.trimEnd;
20
+ var hasNativeIsSafeInteger = !!Number.isSafeInteger;
21
+ var isSafeInteger = hasNativeIsSafeInteger
22
+ ? Number.isSafeInteger
23
+ : function (n) {
24
+ return (typeof n === 'number' &&
25
+ isFinite(n) &&
26
+ Math.floor(n) === n &&
27
+ Math.abs(n) <= 0x1fffffffffffff);
28
+ };
29
+ // IE11 does not support y and u.
30
+ var REGEX_SUPPORTS_U_AND_Y = true;
31
+ try {
32
+ var re = RE('([^\\p{White_Space}\\p{Pattern_Syntax}]*)', 'yu');
33
+ /**
34
+ * legacy Edge or Xbox One browser
35
+ * Unicode flag support: supported
36
+ * Pattern_Syntax support: not supported
37
+ * See https://github.com/formatjs/formatjs/issues/2822
38
+ */
39
+ REGEX_SUPPORTS_U_AND_Y = ((_a = re.exec('a')) === null || _a === void 0 ? void 0 : _a[0]) === 'a';
40
+ }
41
+ catch (_) {
42
+ REGEX_SUPPORTS_U_AND_Y = false;
43
+ }
44
+ var startsWith = hasNativeStartsWith
45
+ ? // Native
46
+ function startsWith(s, search, position) {
47
+ return s.startsWith(search, position);
48
+ }
49
+ : // For IE11
50
+ function startsWith(s, search, position) {
51
+ return s.slice(position, position + search.length) === search;
52
+ };
53
+ var fromCodePoint = hasNativeFromCodePoint
54
+ ? String.fromCodePoint
55
+ : // IE11
56
+ function fromCodePoint() {
57
+ var codePoints = [];
58
+ for (var _i = 0; _i < arguments.length; _i++) {
59
+ codePoints[_i] = arguments[_i];
60
+ }
61
+ var elements = '';
62
+ var length = codePoints.length;
63
+ var i = 0;
64
+ var code;
65
+ while (length > i) {
66
+ code = codePoints[i++];
67
+ if (code > 0x10ffff)
68
+ throw RangeError(code + ' is not a valid code point');
69
+ elements +=
70
+ code < 0x10000
71
+ ? String.fromCharCode(code)
72
+ : String.fromCharCode(((code -= 0x10000) >> 10) + 0xd800, (code % 0x400) + 0xdc00);
73
+ }
74
+ return elements;
75
+ };
76
+ var fromEntries =
77
+ // native
78
+ hasNativeFromEntries
79
+ ? Object.fromEntries
80
+ : // Ponyfill
81
+ function fromEntries(entries) {
82
+ var obj = {};
83
+ for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
84
+ var _a = entries_1[_i], k = _a[0], v = _a[1];
85
+ obj[k] = v;
86
+ }
87
+ return obj;
88
+ };
89
+ var codePointAt = hasNativeCodePointAt
90
+ ? // Native
91
+ function codePointAt(s, index) {
92
+ return s.codePointAt(index);
93
+ }
94
+ : // IE 11
95
+ function codePointAt(s, index) {
96
+ var size = s.length;
97
+ if (index < 0 || index >= size) {
98
+ return undefined;
99
+ }
100
+ var first = s.charCodeAt(index);
101
+ var second;
102
+ return first < 0xd800 ||
103
+ first > 0xdbff ||
104
+ index + 1 === size ||
105
+ (second = s.charCodeAt(index + 1)) < 0xdc00 ||
106
+ second > 0xdfff
107
+ ? first
108
+ : ((first - 0xd800) << 10) + (second - 0xdc00) + 0x10000;
109
+ };
110
+ var trimStart = hasTrimStart
111
+ ? // Native
112
+ function trimStart(s) {
113
+ return s.trimStart();
114
+ }
115
+ : // Ponyfill
116
+ function trimStart(s) {
117
+ return s.replace(SPACE_SEPARATOR_START_REGEX, '');
118
+ };
119
+ var trimEnd = hasTrimEnd
120
+ ? // Native
121
+ function trimEnd(s) {
122
+ return s.trimEnd();
123
+ }
124
+ : // Ponyfill
125
+ function trimEnd(s) {
126
+ return s.replace(SPACE_SEPARATOR_END_REGEX, '');
127
+ };
128
+ // Prevent minifier to translate new RegExp to literal form that might cause syntax error on IE11.
129
+ function RE(s, flag) {
130
+ return new RegExp(s, flag);
131
+ }
132
+ // #endregion
133
+ var matchIdentifierAtIndex;
134
+ if (REGEX_SUPPORTS_U_AND_Y) {
135
+ // Native
136
+ var IDENTIFIER_PREFIX_RE_1 = RE('([^\\p{White_Space}\\p{Pattern_Syntax}]*)', 'yu');
137
+ matchIdentifierAtIndex = function matchIdentifierAtIndex(s, index) {
138
+ var _a;
139
+ IDENTIFIER_PREFIX_RE_1.lastIndex = index;
140
+ var match = IDENTIFIER_PREFIX_RE_1.exec(s);
141
+ return (_a = match[1]) !== null && _a !== void 0 ? _a : '';
142
+ };
143
+ }
144
+ else {
145
+ // IE11
146
+ matchIdentifierAtIndex = function matchIdentifierAtIndex(s, index) {
147
+ var match = [];
148
+ while (true) {
149
+ var c = codePointAt(s, index);
150
+ if (c === undefined || _isWhiteSpace(c) || _isPatternSyntax(c)) {
151
+ break;
152
+ }
153
+ match.push(c);
154
+ index += c >= 0x10000 ? 2 : 1;
155
+ }
156
+ return fromCodePoint.apply(void 0, match);
157
+ };
158
+ }
159
+ var Parser = /** @class */ (function () {
160
+ function Parser(message, options) {
161
+ if (options === void 0) { options = {}; }
162
+ this.message = message;
163
+ this.position = { offset: 0, line: 1, column: 1 };
164
+ this.ignoreTag = !!options.ignoreTag;
165
+ this.requiresOtherClause = !!options.requiresOtherClause;
166
+ this.shouldParseSkeletons = !!options.shouldParseSkeletons;
167
+ }
168
+ Parser.prototype.parse = function () {
169
+ if (this.offset() !== 0) {
170
+ throw Error('parser can only be used once');
171
+ }
172
+ return this.parseMessage(0, '', false);
173
+ };
174
+ Parser.prototype.parseMessage = function (nestingLevel, parentArgType, expectingCloseTag) {
175
+ var elements = [];
176
+ while (!this.isEOF()) {
177
+ var char = this.char();
178
+ if (char === 123 /* `{` */) {
179
+ var result = this.parseArgument(nestingLevel, expectingCloseTag);
180
+ if (result.err) {
181
+ return result;
182
+ }
183
+ elements.push(result.val);
184
+ }
185
+ else if (char === 125 /* `}` */ && nestingLevel > 0) {
186
+ break;
187
+ }
188
+ else if (char === 35 /* `#` */ &&
189
+ (parentArgType === 'plural' || parentArgType === 'selectordinal')) {
190
+ var position = this.clonePosition();
191
+ this.bump();
192
+ elements.push({
193
+ type: TYPE.pound,
194
+ location: createLocation(position, this.clonePosition()),
195
+ });
196
+ }
197
+ else if (char === 60 /* `<` */ &&
198
+ !this.ignoreTag &&
199
+ this.peek() === 47 // char code for '/'
200
+ ) {
201
+ if (expectingCloseTag) {
202
+ break;
203
+ }
204
+ else {
205
+ return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(this.clonePosition(), this.clonePosition()));
206
+ }
207
+ }
208
+ else if (char === 60 /* `<` */ &&
209
+ !this.ignoreTag &&
210
+ _isAlpha(this.peek() || 0)) {
211
+ var result = this.parseTag(nestingLevel, parentArgType);
212
+ if (result.err) {
213
+ return result;
214
+ }
215
+ elements.push(result.val);
216
+ }
217
+ else {
218
+ var result = this.parseLiteral(nestingLevel, parentArgType);
219
+ if (result.err) {
220
+ return result;
221
+ }
222
+ elements.push(result.val);
223
+ }
224
+ }
225
+ return { val: elements, err: null };
226
+ };
227
+ /**
228
+ * A tag name must start with an ASCII lower/upper case letter. The grammar is based on the
229
+ * [custom element name][] except that a dash is NOT always mandatory and uppercase letters
230
+ * are accepted:
231
+ *
232
+ * ```
233
+ * tag ::= "<" tagName (whitespace)* "/>" | "<" tagName (whitespace)* ">" message "</" tagName (whitespace)* ">"
234
+ * tagName ::= [a-z] (PENChar)*
235
+ * PENChar ::=
236
+ * "-" | "." | [0-9] | "_" | [a-z] | [A-Z] | #xB7 | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x37D] |
237
+ * [#x37F-#x1FFF] | [#x200C-#x200D] | [#x203F-#x2040] | [#x2070-#x218F] | [#x2C00-#x2FEF] |
238
+ * [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
239
+ * ```
240
+ *
241
+ * [custom element name]: https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
242
+ * NOTE: We're a bit more lax here since HTML technically does not allow uppercase HTML element but we do
243
+ * since other tag-based engines like React allow it
244
+ */
245
+ Parser.prototype.parseTag = function (nestingLevel, parentArgType) {
246
+ var startPosition = this.clonePosition();
247
+ this.bump(); // `<`
248
+ var tagName = this.parseTagName();
249
+ this.bumpSpace();
250
+ if (this.bumpIf('/>')) {
251
+ // Self closing tag
252
+ return {
253
+ val: {
254
+ type: TYPE.literal,
255
+ value: "<" + tagName + "/>",
256
+ location: createLocation(startPosition, this.clonePosition()),
257
+ },
258
+ err: null,
259
+ };
260
+ }
261
+ else if (this.bumpIf('>')) {
262
+ var childrenResult = this.parseMessage(nestingLevel + 1, parentArgType, true);
263
+ if (childrenResult.err) {
264
+ return childrenResult;
265
+ }
266
+ var children = childrenResult.val;
267
+ // Expecting a close tag
268
+ var endTagStartPosition = this.clonePosition();
269
+ if (this.bumpIf('</')) {
270
+ if (this.isEOF() || !_isAlpha(this.char())) {
271
+ return this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition()));
272
+ }
273
+ var closingTagNameStartPosition = this.clonePosition();
274
+ var closingTagName = this.parseTagName();
275
+ if (tagName !== closingTagName) {
276
+ return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(closingTagNameStartPosition, this.clonePosition()));
277
+ }
278
+ this.bumpSpace();
279
+ if (!this.bumpIf('>')) {
280
+ return this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition()));
281
+ }
282
+ return {
283
+ val: {
284
+ type: TYPE.tag,
285
+ value: tagName,
286
+ children: children,
287
+ location: createLocation(startPosition, this.clonePosition()),
288
+ },
289
+ err: null,
290
+ };
291
+ }
292
+ else {
293
+ return this.error(ErrorKind.UNCLOSED_TAG, createLocation(startPosition, this.clonePosition()));
294
+ }
295
+ }
296
+ else {
297
+ return this.error(ErrorKind.INVALID_TAG, createLocation(startPosition, this.clonePosition()));
298
+ }
299
+ };
300
+ /**
301
+ * This method assumes that the caller has peeked ahead for the first tag character.
302
+ */
303
+ Parser.prototype.parseTagName = function () {
304
+ var startOffset = this.offset();
305
+ this.bump(); // the first tag name character
306
+ while (!this.isEOF() && _isPotentialElementNameChar(this.char())) {
307
+ this.bump();
308
+ }
309
+ return this.message.slice(startOffset, this.offset());
310
+ };
311
+ Parser.prototype.parseLiteral = function (nestingLevel, parentArgType) {
312
+ var start = this.clonePosition();
313
+ var value = '';
314
+ while (true) {
315
+ var parseQuoteResult = this.tryParseQuote(parentArgType);
316
+ if (parseQuoteResult) {
317
+ value += parseQuoteResult;
318
+ continue;
319
+ }
320
+ var parseUnquotedResult = this.tryParseUnquoted(nestingLevel, parentArgType);
321
+ if (parseUnquotedResult) {
322
+ value += parseUnquotedResult;
323
+ continue;
324
+ }
325
+ var parseLeftAngleResult = this.tryParseLeftAngleBracket();
326
+ if (parseLeftAngleResult) {
327
+ value += parseLeftAngleResult;
328
+ continue;
329
+ }
330
+ break;
331
+ }
332
+ var location = createLocation(start, this.clonePosition());
333
+ return {
334
+ val: { type: TYPE.literal, value: value, location: location },
335
+ err: null,
336
+ };
337
+ };
338
+ Parser.prototype.tryParseLeftAngleBracket = function () {
339
+ if (!this.isEOF() &&
340
+ this.char() === 60 /* `<` */ &&
341
+ (this.ignoreTag ||
342
+ // If at the opening tag or closing tag position, bail.
343
+ !_isAlphaOrSlash(this.peek() || 0))) {
344
+ this.bump(); // `<`
345
+ return '<';
346
+ }
347
+ return null;
348
+ };
349
+ /**
350
+ * Starting with ICU 4.8, an ASCII apostrophe only starts quoted text if it immediately precedes
351
+ * a character that requires quoting (that is, "only where needed"), and works the same in
352
+ * nested messages as on the top level of the pattern. The new behavior is otherwise compatible.
353
+ */
354
+ Parser.prototype.tryParseQuote = function (parentArgType) {
355
+ if (this.isEOF() || this.char() !== 39 /* `'` */) {
356
+ return null;
357
+ }
358
+ // Parse escaped char following the apostrophe, or early return if there is no escaped char.
359
+ // Check if is valid escaped character
360
+ switch (this.peek()) {
361
+ case 39 /* `'` */:
362
+ // double quote, should return as a single quote.
363
+ this.bump();
364
+ this.bump();
365
+ return "'";
366
+ // '{', '<', '>', '}'
367
+ case 123:
368
+ case 60:
369
+ case 62:
370
+ case 125:
371
+ break;
372
+ case 35: // '#'
373
+ if (parentArgType === 'plural' || parentArgType === 'selectordinal') {
374
+ break;
375
+ }
376
+ return null;
377
+ default:
378
+ return null;
379
+ }
380
+ this.bump(); // apostrophe
381
+ var codePoints = [this.char()]; // escaped char
382
+ this.bump();
383
+ // read chars until the optional closing apostrophe is found
384
+ while (!this.isEOF()) {
385
+ var ch = this.char();
386
+ if (ch === 39 /* `'` */) {
387
+ if (this.peek() === 39 /* `'` */) {
388
+ codePoints.push(39);
389
+ // Bump one more time because we need to skip 2 characters.
390
+ this.bump();
391
+ }
392
+ else {
393
+ // Optional closing apostrophe.
394
+ this.bump();
395
+ break;
396
+ }
397
+ }
398
+ else {
399
+ codePoints.push(ch);
400
+ }
401
+ this.bump();
402
+ }
403
+ return fromCodePoint.apply(void 0, codePoints);
404
+ };
405
+ Parser.prototype.tryParseUnquoted = function (nestingLevel, parentArgType) {
406
+ if (this.isEOF()) {
407
+ return null;
408
+ }
409
+ var ch = this.char();
410
+ if (ch === 60 /* `<` */ ||
411
+ ch === 123 /* `{` */ ||
412
+ (ch === 35 /* `#` */ &&
413
+ (parentArgType === 'plural' || parentArgType === 'selectordinal')) ||
414
+ (ch === 125 /* `}` */ && nestingLevel > 0)) {
415
+ return null;
416
+ }
417
+ else {
418
+ this.bump();
419
+ return fromCodePoint(ch);
420
+ }
421
+ };
422
+ Parser.prototype.parseArgument = function (nestingLevel, expectingCloseTag) {
423
+ var openingBracePosition = this.clonePosition();
424
+ this.bump(); // `{`
425
+ this.bumpSpace();
426
+ if (this.isEOF()) {
427
+ return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
428
+ }
429
+ if (this.char() === 125 /* `}` */) {
430
+ this.bump();
431
+ return this.error(ErrorKind.EMPTY_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
432
+ }
433
+ // argument name
434
+ var value = this.parseIdentifierIfPossible().value;
435
+ if (!value) {
436
+ return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
437
+ }
438
+ this.bumpSpace();
439
+ if (this.isEOF()) {
440
+ return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
441
+ }
442
+ switch (this.char()) {
443
+ // Simple argument: `{name}`
444
+ case 125 /* `}` */: {
445
+ this.bump(); // `}`
446
+ return {
447
+ val: {
448
+ type: TYPE.argument,
449
+ // value does not include the opening and closing braces.
450
+ value: value,
451
+ location: createLocation(openingBracePosition, this.clonePosition()),
452
+ },
453
+ err: null,
454
+ };
455
+ }
456
+ // Argument with options: `{name, format, ...}`
457
+ case 44 /* `,` */: {
458
+ this.bump(); // `,`
459
+ this.bumpSpace();
460
+ if (this.isEOF()) {
461
+ return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
462
+ }
463
+ return this.parseArgumentOptions(nestingLevel, expectingCloseTag, value, openingBracePosition);
464
+ }
465
+ default:
466
+ return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
467
+ }
468
+ };
469
+ /**
470
+ * Advance the parser until the end of the identifier, if it is currently on
471
+ * an identifier character. Return an empty string otherwise.
472
+ */
473
+ Parser.prototype.parseIdentifierIfPossible = function () {
474
+ var startingPosition = this.clonePosition();
475
+ var startOffset = this.offset();
476
+ var value = matchIdentifierAtIndex(this.message, startOffset);
477
+ var endOffset = startOffset + value.length;
478
+ this.bumpTo(endOffset);
479
+ var endPosition = this.clonePosition();
480
+ var location = createLocation(startingPosition, endPosition);
481
+ return { value: value, location: location };
482
+ };
483
+ Parser.prototype.parseArgumentOptions = function (nestingLevel, expectingCloseTag, value, openingBracePosition) {
484
+ var _a;
485
+ // Parse this range:
486
+ // {name, type, style}
487
+ // ^---^
488
+ var typeStartPosition = this.clonePosition();
489
+ var argType = this.parseIdentifierIfPossible().value;
490
+ var typeEndPosition = this.clonePosition();
491
+ switch (argType) {
492
+ case '':
493
+ // Expecting a style string number, date, time, plural, selectordinal, or select.
494
+ return this.error(ErrorKind.EXPECT_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
495
+ case 'number':
496
+ case 'date':
497
+ case 'time': {
498
+ // Parse this range:
499
+ // {name, number, style}
500
+ // ^-------^
501
+ this.bumpSpace();
502
+ var styleAndLocation = null;
503
+ if (this.bumpIf(',')) {
504
+ this.bumpSpace();
505
+ var styleStartPosition = this.clonePosition();
506
+ var result = this.parseSimpleArgStyleIfPossible();
507
+ if (result.err) {
508
+ return result;
509
+ }
510
+ var style = trimEnd(result.val);
511
+ if (style.length === 0) {
512
+ return this.error(ErrorKind.EXPECT_ARGUMENT_STYLE, createLocation(this.clonePosition(), this.clonePosition()));
513
+ }
514
+ var styleLocation = createLocation(styleStartPosition, this.clonePosition());
515
+ styleAndLocation = { style: style, styleLocation: styleLocation };
516
+ }
517
+ var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
518
+ if (argCloseResult.err) {
519
+ return argCloseResult;
520
+ }
521
+ var location_1 = createLocation(openingBracePosition, this.clonePosition());
522
+ // Extract style or skeleton
523
+ if (styleAndLocation && startsWith(styleAndLocation === null || styleAndLocation === void 0 ? void 0 : styleAndLocation.style, '::', 0)) {
524
+ // Skeleton starts with `::`.
525
+ var skeleton = trimStart(styleAndLocation.style.slice(2));
526
+ if (argType === 'number') {
527
+ var result = this.parseNumberSkeletonFromString(skeleton, styleAndLocation.styleLocation);
528
+ if (result.err) {
529
+ return result;
530
+ }
531
+ return {
532
+ val: { type: TYPE.number, value: value, location: location_1, style: result.val },
533
+ err: null,
534
+ };
535
+ }
536
+ else {
537
+ if (skeleton.length === 0) {
538
+ return this.error(ErrorKind.EXPECT_DATE_TIME_SKELETON, location_1);
539
+ }
540
+ var style = {
541
+ type: SKELETON_TYPE.dateTime,
542
+ pattern: skeleton,
543
+ location: styleAndLocation.styleLocation,
544
+ parsedOptions: this.shouldParseSkeletons
545
+ ? parseDateTimeSkeleton(skeleton)
546
+ : {},
547
+ };
548
+ var type = argType === 'date' ? TYPE.date : TYPE.time;
549
+ return {
550
+ val: { type: type, value: value, location: location_1, style: style },
551
+ err: null,
552
+ };
553
+ }
554
+ }
555
+ // Regular style or no style.
556
+ return {
557
+ val: {
558
+ type: argType === 'number'
559
+ ? TYPE.number
560
+ : argType === 'date'
561
+ ? TYPE.date
562
+ : TYPE.time,
563
+ value: value,
564
+ location: location_1,
565
+ style: (_a = styleAndLocation === null || styleAndLocation === void 0 ? void 0 : styleAndLocation.style) !== null && _a !== void 0 ? _a : null,
566
+ },
567
+ err: null,
568
+ };
569
+ }
570
+ case 'plural':
571
+ case 'selectordinal':
572
+ case 'select': {
573
+ // Parse this range:
574
+ // {name, plural, options}
575
+ // ^---------^
576
+ var typeEndPosition_1 = this.clonePosition();
577
+ this.bumpSpace();
578
+ if (!this.bumpIf(',')) {
579
+ return this.error(ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, createLocation(typeEndPosition_1, __assign({}, typeEndPosition_1)));
580
+ }
581
+ this.bumpSpace();
582
+ // Parse offset:
583
+ // {name, plural, offset:1, options}
584
+ // ^-----^
585
+ //
586
+ // or the first option:
587
+ //
588
+ // {name, plural, one {...} other {...}}
589
+ // ^--^
590
+ var identifierAndLocation = this.parseIdentifierIfPossible();
591
+ var pluralOffset = 0;
592
+ if (argType !== 'select' && identifierAndLocation.value === 'offset') {
593
+ if (!this.bumpIf(':')) {
594
+ return this.error(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, createLocation(this.clonePosition(), this.clonePosition()));
595
+ }
596
+ this.bumpSpace();
597
+ var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, ErrorKind.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);
598
+ if (result.err) {
599
+ return result;
600
+ }
601
+ // Parse another identifier for option parsing
602
+ this.bumpSpace();
603
+ identifierAndLocation = this.parseIdentifierIfPossible();
604
+ pluralOffset = result.val;
605
+ }
606
+ var optionsResult = this.tryParsePluralOrSelectOptions(nestingLevel, argType, expectingCloseTag, identifierAndLocation);
607
+ if (optionsResult.err) {
608
+ return optionsResult;
609
+ }
610
+ var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
611
+ if (argCloseResult.err) {
612
+ return argCloseResult;
613
+ }
614
+ var location_2 = createLocation(openingBracePosition, this.clonePosition());
615
+ if (argType === 'select') {
616
+ return {
617
+ val: {
618
+ type: TYPE.select,
619
+ value: value,
620
+ options: fromEntries(optionsResult.val),
621
+ location: location_2,
622
+ },
623
+ err: null,
624
+ };
625
+ }
626
+ else {
627
+ return {
628
+ val: {
629
+ type: TYPE.plural,
630
+ value: value,
631
+ options: fromEntries(optionsResult.val),
632
+ offset: pluralOffset,
633
+ pluralType: argType === 'plural' ? 'cardinal' : 'ordinal',
634
+ location: location_2,
635
+ },
636
+ err: null,
637
+ };
638
+ }
639
+ }
640
+ default:
641
+ return this.error(ErrorKind.INVALID_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
642
+ }
643
+ };
644
+ Parser.prototype.tryParseArgumentClose = function (openingBracePosition) {
645
+ // Parse: {value, number, ::currency/GBP }
646
+ //
647
+ if (this.isEOF() || this.char() !== 125 /* `}` */) {
648
+ return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
649
+ }
650
+ this.bump(); // `}`
651
+ return { val: true, err: null };
652
+ };
653
+ /**
654
+ * See: https://github.com/unicode-org/icu/blob/af7ed1f6d2298013dc303628438ec4abe1f16479/icu4c/source/common/messagepattern.cpp#L659
655
+ */
656
+ Parser.prototype.parseSimpleArgStyleIfPossible = function () {
657
+ var nestedBraces = 0;
658
+ var startPosition = this.clonePosition();
659
+ while (!this.isEOF()) {
660
+ var ch = this.char();
661
+ switch (ch) {
662
+ case 39 /* `'` */: {
663
+ // Treat apostrophe as quoting but include it in the style part.
664
+ // Find the end of the quoted literal text.
665
+ this.bump();
666
+ var apostrophePosition = this.clonePosition();
667
+ if (!this.bumpUntil("'")) {
668
+ return this.error(ErrorKind.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE, createLocation(apostrophePosition, this.clonePosition()));
669
+ }
670
+ this.bump();
671
+ break;
672
+ }
673
+ case 123 /* `{` */: {
674
+ nestedBraces += 1;
675
+ this.bump();
676
+ break;
677
+ }
678
+ case 125 /* `}` */: {
679
+ if (nestedBraces > 0) {
680
+ nestedBraces -= 1;
681
+ }
682
+ else {
683
+ return {
684
+ val: this.message.slice(startPosition.offset, this.offset()),
685
+ err: null,
686
+ };
687
+ }
688
+ break;
689
+ }
690
+ default:
691
+ this.bump();
692
+ break;
693
+ }
694
+ }
695
+ return {
696
+ val: this.message.slice(startPosition.offset, this.offset()),
697
+ err: null,
698
+ };
699
+ };
700
+ Parser.prototype.parseNumberSkeletonFromString = function (skeleton, location) {
701
+ var tokens = [];
702
+ try {
703
+ tokens = parseNumberSkeletonFromString(skeleton);
704
+ }
705
+ catch (e) {
706
+ return this.error(ErrorKind.INVALID_NUMBER_SKELETON, location);
707
+ }
708
+ return {
709
+ val: {
710
+ type: SKELETON_TYPE.number,
711
+ tokens: tokens,
712
+ location: location,
713
+ parsedOptions: this.shouldParseSkeletons
714
+ ? parseNumberSkeleton(tokens)
715
+ : {},
716
+ },
717
+ err: null,
718
+ };
719
+ };
720
+ /**
721
+ * @param nesting_level The current nesting level of messages.
722
+ * This can be positive when parsing message fragment in select or plural argument options.
723
+ * @param parent_arg_type The parent argument's type.
724
+ * @param parsed_first_identifier If provided, this is the first identifier-like selector of
725
+ * the argument. It is a by-product of a previous parsing attempt.
726
+ * @param expecting_close_tag If true, this message is directly or indirectly nested inside
727
+ * between a pair of opening and closing tags. The nested message will not parse beyond
728
+ * the closing tag boundary.
729
+ */
730
+ Parser.prototype.tryParsePluralOrSelectOptions = function (nestingLevel, parentArgType, expectCloseTag, parsedFirstIdentifier) {
731
+ var _a;
732
+ var hasOtherClause = false;
733
+ var options = [];
734
+ var parsedSelectors = new Set();
735
+ var selector = parsedFirstIdentifier.value, selectorLocation = parsedFirstIdentifier.location;
736
+ // Parse:
737
+ // one {one apple}
738
+ // ^--^
739
+ while (true) {
740
+ if (selector.length === 0) {
741
+ var startPosition = this.clonePosition();
742
+ if (parentArgType !== 'select' && this.bumpIf('=')) {
743
+ // Try parse `={number}` selector
744
+ var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, ErrorKind.INVALID_PLURAL_ARGUMENT_SELECTOR);
745
+ if (result.err) {
746
+ return result;
747
+ }
748
+ selectorLocation = createLocation(startPosition, this.clonePosition());
749
+ selector = this.message.slice(startPosition.offset, this.offset());
750
+ }
751
+ else {
752
+ break;
753
+ }
754
+ }
755
+ // Duplicate selector clauses
756
+ if (parsedSelectors.has(selector)) {
757
+ return this.error(parentArgType === 'select'
758
+ ? ErrorKind.DUPLICATE_SELECT_ARGUMENT_SELECTOR
759
+ : ErrorKind.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, selectorLocation);
760
+ }
761
+ if (selector === 'other') {
762
+ hasOtherClause = true;
763
+ }
764
+ // Parse:
765
+ // one {one apple}
766
+ // ^----------^
767
+ this.bumpSpace();
768
+ var openingBracePosition = this.clonePosition();
769
+ if (!this.bumpIf('{')) {
770
+ return this.error(parentArgType === 'select'
771
+ ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT
772
+ : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT, createLocation(this.clonePosition(), this.clonePosition()));
773
+ }
774
+ var fragmentResult = this.parseMessage(nestingLevel + 1, parentArgType, expectCloseTag);
775
+ if (fragmentResult.err) {
776
+ return fragmentResult;
777
+ }
778
+ var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
779
+ if (argCloseResult.err) {
780
+ return argCloseResult;
781
+ }
782
+ options.push([
783
+ selector,
784
+ {
785
+ value: fragmentResult.val,
786
+ location: createLocation(openingBracePosition, this.clonePosition()),
787
+ },
788
+ ]);
789
+ // Keep track of the existing selectors
790
+ parsedSelectors.add(selector);
791
+ // Prep next selector clause.
792
+ this.bumpSpace();
793
+ (_a = this.parseIdentifierIfPossible(), selector = _a.value, selectorLocation = _a.location);
794
+ }
795
+ if (options.length === 0) {
796
+ return this.error(parentArgType === 'select'
797
+ ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR
798
+ : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, createLocation(this.clonePosition(), this.clonePosition()));
799
+ }
800
+ if (this.requiresOtherClause && !hasOtherClause) {
801
+ return this.error(ErrorKind.MISSING_OTHER_CLAUSE, createLocation(this.clonePosition(), this.clonePosition()));
802
+ }
803
+ return { val: options, err: null };
804
+ };
805
+ Parser.prototype.tryParseDecimalInteger = function (expectNumberError, invalidNumberError) {
806
+ var sign = 1;
807
+ var startingPosition = this.clonePosition();
808
+ if (this.bumpIf('+')) {
809
+ }
810
+ else if (this.bumpIf('-')) {
811
+ sign = -1;
812
+ }
813
+ var hasDigits = false;
814
+ var decimal = 0;
815
+ while (!this.isEOF()) {
816
+ var ch = this.char();
817
+ if (ch >= 48 /* `0` */ && ch <= 57 /* `9` */) {
818
+ hasDigits = true;
819
+ decimal = decimal * 10 + (ch - 48);
820
+ this.bump();
821
+ }
822
+ else {
823
+ break;
824
+ }
825
+ }
826
+ var location = createLocation(startingPosition, this.clonePosition());
827
+ if (!hasDigits) {
828
+ return this.error(expectNumberError, location);
829
+ }
830
+ decimal *= sign;
831
+ if (!isSafeInteger(decimal)) {
832
+ return this.error(invalidNumberError, location);
833
+ }
834
+ return { val: decimal, err: null };
835
+ };
836
+ Parser.prototype.offset = function () {
837
+ return this.position.offset;
838
+ };
839
+ Parser.prototype.isEOF = function () {
840
+ return this.offset() === this.message.length;
841
+ };
842
+ Parser.prototype.clonePosition = function () {
843
+ // This is much faster than `Object.assign` or spread.
844
+ return {
845
+ offset: this.position.offset,
846
+ line: this.position.line,
847
+ column: this.position.column,
848
+ };
849
+ };
850
+ /**
851
+ * Return the code point at the current position of the parser.
852
+ * Throws if the index is out of bound.
853
+ */
854
+ Parser.prototype.char = function () {
855
+ var offset = this.position.offset;
856
+ if (offset >= this.message.length) {
857
+ throw Error('out of bound');
858
+ }
859
+ var code = codePointAt(this.message, offset);
860
+ if (code === undefined) {
861
+ throw Error("Offset " + offset + " is at invalid UTF-16 code unit boundary");
862
+ }
863
+ return code;
864
+ };
865
+ Parser.prototype.error = function (kind, location) {
866
+ return {
867
+ val: null,
868
+ err: {
869
+ kind: kind,
870
+ message: this.message,
871
+ location: location,
872
+ },
873
+ };
874
+ };
875
+ /** Bump the parser to the next UTF-16 code unit. */
876
+ Parser.prototype.bump = function () {
877
+ if (this.isEOF()) {
878
+ return;
879
+ }
880
+ var code = this.char();
881
+ if (code === 10 /* '\n' */) {
882
+ this.position.line += 1;
883
+ this.position.column = 1;
884
+ this.position.offset += 1;
885
+ }
886
+ else {
887
+ this.position.column += 1;
888
+ // 0 ~ 0x10000 -> unicode BMP, otherwise skip the surrogate pair.
889
+ this.position.offset += code < 0x10000 ? 1 : 2;
890
+ }
891
+ };
892
+ /**
893
+ * If the substring starting at the current position of the parser has
894
+ * the given prefix, then bump the parser to the character immediately
895
+ * following the prefix and return true. Otherwise, don't bump the parser
896
+ * and return false.
897
+ */
898
+ Parser.prototype.bumpIf = function (prefix) {
899
+ if (startsWith(this.message, prefix, this.offset())) {
900
+ for (var i = 0; i < prefix.length; i++) {
901
+ this.bump();
902
+ }
903
+ return true;
904
+ }
905
+ return false;
906
+ };
907
+ /**
908
+ * Bump the parser until the pattern character is found and return `true`.
909
+ * Otherwise bump to the end of the file and return `false`.
910
+ */
911
+ Parser.prototype.bumpUntil = function (pattern) {
912
+ var currentOffset = this.offset();
913
+ var index = this.message.indexOf(pattern, currentOffset);
914
+ if (index >= 0) {
915
+ this.bumpTo(index);
916
+ return true;
917
+ }
918
+ else {
919
+ this.bumpTo(this.message.length);
920
+ return false;
921
+ }
922
+ };
923
+ /**
924
+ * Bump the parser to the target offset.
925
+ * If target offset is beyond the end of the input, bump the parser to the end of the input.
926
+ */
927
+ Parser.prototype.bumpTo = function (targetOffset) {
928
+ if (this.offset() > targetOffset) {
929
+ throw Error("targetOffset " + targetOffset + " must be greater than or equal to the current offset " + this.offset());
930
+ }
931
+ targetOffset = Math.min(targetOffset, this.message.length);
932
+ while (true) {
933
+ var offset = this.offset();
934
+ if (offset === targetOffset) {
935
+ break;
936
+ }
937
+ if (offset > targetOffset) {
938
+ throw Error("targetOffset " + targetOffset + " is at invalid UTF-16 code unit boundary");
939
+ }
940
+ this.bump();
941
+ if (this.isEOF()) {
942
+ break;
943
+ }
944
+ }
945
+ };
946
+ /** advance the parser through all whitespace to the next non-whitespace code unit. */
947
+ Parser.prototype.bumpSpace = function () {
948
+ while (!this.isEOF() && _isWhiteSpace(this.char())) {
949
+ this.bump();
950
+ }
951
+ };
952
+ /**
953
+ * Peek at the *next* Unicode codepoint in the input without advancing the parser.
954
+ * If the input has been exhausted, then this returns null.
955
+ */
956
+ Parser.prototype.peek = function () {
957
+ if (this.isEOF()) {
958
+ return null;
959
+ }
960
+ var code = this.char();
961
+ var offset = this.offset();
962
+ var nextCode = this.message.charCodeAt(offset + (code >= 0x10000 ? 2 : 1));
963
+ return nextCode !== null && nextCode !== void 0 ? nextCode : null;
964
+ };
965
+ return Parser;
966
+ }());
967
+ export { Parser };
968
+ /**
969
+ * This check if codepoint is alphabet (lower & uppercase)
970
+ * @param codepoint
971
+ * @returns
972
+ */
973
+ function _isAlpha(codepoint) {
974
+ return ((codepoint >= 97 && codepoint <= 122) ||
975
+ (codepoint >= 65 && codepoint <= 90));
976
+ }
977
+ function _isAlphaOrSlash(codepoint) {
978
+ return _isAlpha(codepoint) || codepoint === 47; /* '/' */
979
+ }
980
+ /** See `parseTag` function docs. */
981
+ function _isPotentialElementNameChar(c) {
982
+ return (c === 45 /* '-' */ ||
983
+ c === 46 /* '.' */ ||
984
+ (c >= 48 && c <= 57) /* 0..9 */ ||
985
+ c === 95 /* '_' */ ||
986
+ (c >= 97 && c <= 122) /** a..z */ ||
987
+ (c >= 65 && c <= 90) /* A..Z */ ||
988
+ c == 0xb7 ||
989
+ (c >= 0xc0 && c <= 0xd6) ||
990
+ (c >= 0xd8 && c <= 0xf6) ||
991
+ (c >= 0xf8 && c <= 0x37d) ||
992
+ (c >= 0x37f && c <= 0x1fff) ||
993
+ (c >= 0x200c && c <= 0x200d) ||
994
+ (c >= 0x203f && c <= 0x2040) ||
995
+ (c >= 0x2070 && c <= 0x218f) ||
996
+ (c >= 0x2c00 && c <= 0x2fef) ||
997
+ (c >= 0x3001 && c <= 0xd7ff) ||
998
+ (c >= 0xf900 && c <= 0xfdcf) ||
999
+ (c >= 0xfdf0 && c <= 0xfffd) ||
1000
+ (c >= 0x10000 && c <= 0xeffff));
1001
+ }
1002
+ /**
1003
+ * Code point equivalent of regex `\p{White_Space}`.
1004
+ * From: https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt
1005
+ */
1006
+ function _isWhiteSpace(c) {
1007
+ return ((c >= 0x0009 && c <= 0x000d) ||
1008
+ c === 0x0020 ||
1009
+ c === 0x0085 ||
1010
+ (c >= 0x200e && c <= 0x200f) ||
1011
+ c === 0x2028 ||
1012
+ c === 0x2029);
1013
+ }
1014
+ /**
1015
+ * Code point equivalent of regex `\p{Pattern_Syntax}`.
1016
+ * See https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt
1017
+ */
1018
+ function _isPatternSyntax(c) {
1019
+ return ((c >= 0x0021 && c <= 0x0023) ||
1020
+ c === 0x0024 ||
1021
+ (c >= 0x0025 && c <= 0x0027) ||
1022
+ c === 0x0028 ||
1023
+ c === 0x0029 ||
1024
+ c === 0x002a ||
1025
+ c === 0x002b ||
1026
+ c === 0x002c ||
1027
+ c === 0x002d ||
1028
+ (c >= 0x002e && c <= 0x002f) ||
1029
+ (c >= 0x003a && c <= 0x003b) ||
1030
+ (c >= 0x003c && c <= 0x003e) ||
1031
+ (c >= 0x003f && c <= 0x0040) ||
1032
+ c === 0x005b ||
1033
+ c === 0x005c ||
1034
+ c === 0x005d ||
1035
+ c === 0x005e ||
1036
+ c === 0x0060 ||
1037
+ c === 0x007b ||
1038
+ c === 0x007c ||
1039
+ c === 0x007d ||
1040
+ c === 0x007e ||
1041
+ c === 0x00a1 ||
1042
+ (c >= 0x00a2 && c <= 0x00a5) ||
1043
+ c === 0x00a6 ||
1044
+ c === 0x00a7 ||
1045
+ c === 0x00a9 ||
1046
+ c === 0x00ab ||
1047
+ c === 0x00ac ||
1048
+ c === 0x00ae ||
1049
+ c === 0x00b0 ||
1050
+ c === 0x00b1 ||
1051
+ c === 0x00b6 ||
1052
+ c === 0x00bb ||
1053
+ c === 0x00bf ||
1054
+ c === 0x00d7 ||
1055
+ c === 0x00f7 ||
1056
+ (c >= 0x2010 && c <= 0x2015) ||
1057
+ (c >= 0x2016 && c <= 0x2017) ||
1058
+ c === 0x2018 ||
1059
+ c === 0x2019 ||
1060
+ c === 0x201a ||
1061
+ (c >= 0x201b && c <= 0x201c) ||
1062
+ c === 0x201d ||
1063
+ c === 0x201e ||
1064
+ c === 0x201f ||
1065
+ (c >= 0x2020 && c <= 0x2027) ||
1066
+ (c >= 0x2030 && c <= 0x2038) ||
1067
+ c === 0x2039 ||
1068
+ c === 0x203a ||
1069
+ (c >= 0x203b && c <= 0x203e) ||
1070
+ (c >= 0x2041 && c <= 0x2043) ||
1071
+ c === 0x2044 ||
1072
+ c === 0x2045 ||
1073
+ c === 0x2046 ||
1074
+ (c >= 0x2047 && c <= 0x2051) ||
1075
+ c === 0x2052 ||
1076
+ c === 0x2053 ||
1077
+ (c >= 0x2055 && c <= 0x205e) ||
1078
+ (c >= 0x2190 && c <= 0x2194) ||
1079
+ (c >= 0x2195 && c <= 0x2199) ||
1080
+ (c >= 0x219a && c <= 0x219b) ||
1081
+ (c >= 0x219c && c <= 0x219f) ||
1082
+ c === 0x21a0 ||
1083
+ (c >= 0x21a1 && c <= 0x21a2) ||
1084
+ c === 0x21a3 ||
1085
+ (c >= 0x21a4 && c <= 0x21a5) ||
1086
+ c === 0x21a6 ||
1087
+ (c >= 0x21a7 && c <= 0x21ad) ||
1088
+ c === 0x21ae ||
1089
+ (c >= 0x21af && c <= 0x21cd) ||
1090
+ (c >= 0x21ce && c <= 0x21cf) ||
1091
+ (c >= 0x21d0 && c <= 0x21d1) ||
1092
+ c === 0x21d2 ||
1093
+ c === 0x21d3 ||
1094
+ c === 0x21d4 ||
1095
+ (c >= 0x21d5 && c <= 0x21f3) ||
1096
+ (c >= 0x21f4 && c <= 0x22ff) ||
1097
+ (c >= 0x2300 && c <= 0x2307) ||
1098
+ c === 0x2308 ||
1099
+ c === 0x2309 ||
1100
+ c === 0x230a ||
1101
+ c === 0x230b ||
1102
+ (c >= 0x230c && c <= 0x231f) ||
1103
+ (c >= 0x2320 && c <= 0x2321) ||
1104
+ (c >= 0x2322 && c <= 0x2328) ||
1105
+ c === 0x2329 ||
1106
+ c === 0x232a ||
1107
+ (c >= 0x232b && c <= 0x237b) ||
1108
+ c === 0x237c ||
1109
+ (c >= 0x237d && c <= 0x239a) ||
1110
+ (c >= 0x239b && c <= 0x23b3) ||
1111
+ (c >= 0x23b4 && c <= 0x23db) ||
1112
+ (c >= 0x23dc && c <= 0x23e1) ||
1113
+ (c >= 0x23e2 && c <= 0x2426) ||
1114
+ (c >= 0x2427 && c <= 0x243f) ||
1115
+ (c >= 0x2440 && c <= 0x244a) ||
1116
+ (c >= 0x244b && c <= 0x245f) ||
1117
+ (c >= 0x2500 && c <= 0x25b6) ||
1118
+ c === 0x25b7 ||
1119
+ (c >= 0x25b8 && c <= 0x25c0) ||
1120
+ c === 0x25c1 ||
1121
+ (c >= 0x25c2 && c <= 0x25f7) ||
1122
+ (c >= 0x25f8 && c <= 0x25ff) ||
1123
+ (c >= 0x2600 && c <= 0x266e) ||
1124
+ c === 0x266f ||
1125
+ (c >= 0x2670 && c <= 0x2767) ||
1126
+ c === 0x2768 ||
1127
+ c === 0x2769 ||
1128
+ c === 0x276a ||
1129
+ c === 0x276b ||
1130
+ c === 0x276c ||
1131
+ c === 0x276d ||
1132
+ c === 0x276e ||
1133
+ c === 0x276f ||
1134
+ c === 0x2770 ||
1135
+ c === 0x2771 ||
1136
+ c === 0x2772 ||
1137
+ c === 0x2773 ||
1138
+ c === 0x2774 ||
1139
+ c === 0x2775 ||
1140
+ (c >= 0x2794 && c <= 0x27bf) ||
1141
+ (c >= 0x27c0 && c <= 0x27c4) ||
1142
+ c === 0x27c5 ||
1143
+ c === 0x27c6 ||
1144
+ (c >= 0x27c7 && c <= 0x27e5) ||
1145
+ c === 0x27e6 ||
1146
+ c === 0x27e7 ||
1147
+ c === 0x27e8 ||
1148
+ c === 0x27e9 ||
1149
+ c === 0x27ea ||
1150
+ c === 0x27eb ||
1151
+ c === 0x27ec ||
1152
+ c === 0x27ed ||
1153
+ c === 0x27ee ||
1154
+ c === 0x27ef ||
1155
+ (c >= 0x27f0 && c <= 0x27ff) ||
1156
+ (c >= 0x2800 && c <= 0x28ff) ||
1157
+ (c >= 0x2900 && c <= 0x2982) ||
1158
+ c === 0x2983 ||
1159
+ c === 0x2984 ||
1160
+ c === 0x2985 ||
1161
+ c === 0x2986 ||
1162
+ c === 0x2987 ||
1163
+ c === 0x2988 ||
1164
+ c === 0x2989 ||
1165
+ c === 0x298a ||
1166
+ c === 0x298b ||
1167
+ c === 0x298c ||
1168
+ c === 0x298d ||
1169
+ c === 0x298e ||
1170
+ c === 0x298f ||
1171
+ c === 0x2990 ||
1172
+ c === 0x2991 ||
1173
+ c === 0x2992 ||
1174
+ c === 0x2993 ||
1175
+ c === 0x2994 ||
1176
+ c === 0x2995 ||
1177
+ c === 0x2996 ||
1178
+ c === 0x2997 ||
1179
+ c === 0x2998 ||
1180
+ (c >= 0x2999 && c <= 0x29d7) ||
1181
+ c === 0x29d8 ||
1182
+ c === 0x29d9 ||
1183
+ c === 0x29da ||
1184
+ c === 0x29db ||
1185
+ (c >= 0x29dc && c <= 0x29fb) ||
1186
+ c === 0x29fc ||
1187
+ c === 0x29fd ||
1188
+ (c >= 0x29fe && c <= 0x2aff) ||
1189
+ (c >= 0x2b00 && c <= 0x2b2f) ||
1190
+ (c >= 0x2b30 && c <= 0x2b44) ||
1191
+ (c >= 0x2b45 && c <= 0x2b46) ||
1192
+ (c >= 0x2b47 && c <= 0x2b4c) ||
1193
+ (c >= 0x2b4d && c <= 0x2b73) ||
1194
+ (c >= 0x2b74 && c <= 0x2b75) ||
1195
+ (c >= 0x2b76 && c <= 0x2b95) ||
1196
+ c === 0x2b96 ||
1197
+ (c >= 0x2b97 && c <= 0x2bff) ||
1198
+ (c >= 0x2e00 && c <= 0x2e01) ||
1199
+ c === 0x2e02 ||
1200
+ c === 0x2e03 ||
1201
+ c === 0x2e04 ||
1202
+ c === 0x2e05 ||
1203
+ (c >= 0x2e06 && c <= 0x2e08) ||
1204
+ c === 0x2e09 ||
1205
+ c === 0x2e0a ||
1206
+ c === 0x2e0b ||
1207
+ c === 0x2e0c ||
1208
+ c === 0x2e0d ||
1209
+ (c >= 0x2e0e && c <= 0x2e16) ||
1210
+ c === 0x2e17 ||
1211
+ (c >= 0x2e18 && c <= 0x2e19) ||
1212
+ c === 0x2e1a ||
1213
+ c === 0x2e1b ||
1214
+ c === 0x2e1c ||
1215
+ c === 0x2e1d ||
1216
+ (c >= 0x2e1e && c <= 0x2e1f) ||
1217
+ c === 0x2e20 ||
1218
+ c === 0x2e21 ||
1219
+ c === 0x2e22 ||
1220
+ c === 0x2e23 ||
1221
+ c === 0x2e24 ||
1222
+ c === 0x2e25 ||
1223
+ c === 0x2e26 ||
1224
+ c === 0x2e27 ||
1225
+ c === 0x2e28 ||
1226
+ c === 0x2e29 ||
1227
+ (c >= 0x2e2a && c <= 0x2e2e) ||
1228
+ c === 0x2e2f ||
1229
+ (c >= 0x2e30 && c <= 0x2e39) ||
1230
+ (c >= 0x2e3a && c <= 0x2e3b) ||
1231
+ (c >= 0x2e3c && c <= 0x2e3f) ||
1232
+ c === 0x2e40 ||
1233
+ c === 0x2e41 ||
1234
+ c === 0x2e42 ||
1235
+ (c >= 0x2e43 && c <= 0x2e4f) ||
1236
+ (c >= 0x2e50 && c <= 0x2e51) ||
1237
+ c === 0x2e52 ||
1238
+ (c >= 0x2e53 && c <= 0x2e7f) ||
1239
+ (c >= 0x3001 && c <= 0x3003) ||
1240
+ c === 0x3008 ||
1241
+ c === 0x3009 ||
1242
+ c === 0x300a ||
1243
+ c === 0x300b ||
1244
+ c === 0x300c ||
1245
+ c === 0x300d ||
1246
+ c === 0x300e ||
1247
+ c === 0x300f ||
1248
+ c === 0x3010 ||
1249
+ c === 0x3011 ||
1250
+ (c >= 0x3012 && c <= 0x3013) ||
1251
+ c === 0x3014 ||
1252
+ c === 0x3015 ||
1253
+ c === 0x3016 ||
1254
+ c === 0x3017 ||
1255
+ c === 0x3018 ||
1256
+ c === 0x3019 ||
1257
+ c === 0x301a ||
1258
+ c === 0x301b ||
1259
+ c === 0x301c ||
1260
+ c === 0x301d ||
1261
+ (c >= 0x301e && c <= 0x301f) ||
1262
+ c === 0x3020 ||
1263
+ c === 0x3030 ||
1264
+ c === 0xfd3e ||
1265
+ c === 0xfd3f ||
1266
+ (c >= 0xfe45 && c <= 0xfe46));
1267
+ }