@arcgis/arcade-parser 5.2.0-next.94

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/dist/index.js ADDED
@@ -0,0 +1,2342 @@
1
+ const w = {
2
+ False: "false",
3
+ Null: "null",
4
+ True: "true"
5
+ }, l = {
6
+ Break: "break",
7
+ Continue: "continue",
8
+ Else: "else",
9
+ For: "for",
10
+ Function: "function",
11
+ If: "if",
12
+ Import: "import",
13
+ Export: "export",
14
+ In: "in",
15
+ Return: "return",
16
+ Var: "var",
17
+ While: "while"
18
+ }, T = {
19
+ From: "from",
20
+ Of: "of"
21
+ }, n = {
22
+ AssignmentExpression: "AssignmentExpression",
23
+ ArrayExpression: "ArrayExpression",
24
+ BlockComment: "BlockComment",
25
+ BlockStatement: "BlockStatement",
26
+ BinaryExpression: "BinaryExpression",
27
+ BreakStatement: "BreakStatement",
28
+ CallExpression: "CallExpression",
29
+ ContinueStatement: "ContinueStatement",
30
+ EmptyStatement: "EmptyStatement",
31
+ ExpressionStatement: "ExpressionStatement",
32
+ ExportNamedDeclaration: "ExportNamedDeclaration",
33
+ ExportSpecifier: "ExportSpecifier",
34
+ ForStatement: "ForStatement",
35
+ ForInStatement: "ForInStatement",
36
+ ForOfStatement: "ForOfStatement",
37
+ FunctionDeclaration: "FunctionDeclaration",
38
+ Identifier: "Identifier",
39
+ IfStatement: "IfStatement",
40
+ ImportDeclaration: "ImportDeclaration",
41
+ ImportDefaultSpecifier: "ImportDefaultSpecifier",
42
+ LineComment: "LineComment",
43
+ Literal: "Literal",
44
+ LogicalExpression: "LogicalExpression",
45
+ MemberAccessChainExpression: "MemberAccessChainExpression",
46
+ MemberExpression: "MemberExpression",
47
+ ObjectExpression: "ObjectExpression",
48
+ Program: "Program",
49
+ Property: "Property",
50
+ ReturnStatement: "ReturnStatement",
51
+ SafeMemberExpression: "SafeMemberExpression",
52
+ TemplateElement: "TemplateElement",
53
+ TemplateLiteral: "TemplateLiteral",
54
+ UnaryExpression: "UnaryExpression",
55
+ UpdateExpression: "UpdateExpression",
56
+ VariableDeclaration: "VariableDeclaration",
57
+ VariableDeclarator: "VariableDeclarator",
58
+ WhileStatement: "WhileStatement"
59
+ }, M = ["++", "--"], G = ["-", "+", "!", "~"], W = ["=", "/=", "*=", "%=", "+=", "-="], q = ["||", "&&"], Z = [
60
+ "|",
61
+ "&",
62
+ ">>",
63
+ "<<",
64
+ ">>>",
65
+ "^",
66
+ "==",
67
+ "!=",
68
+ "<",
69
+ "<=",
70
+ ">",
71
+ ">=",
72
+ "+",
73
+ "-",
74
+ "*",
75
+ "/",
76
+ "%"
77
+ ], g = "?.", P = {
78
+ "||": 1,
79
+ "&&": 2,
80
+ "|": 3,
81
+ "^": 4,
82
+ "&": 5,
83
+ "==": 6,
84
+ "!=": 6,
85
+ "<": 7,
86
+ ">": 7,
87
+ "<=": 7,
88
+ ">=": 7,
89
+ "<<": 8,
90
+ ">>": 8,
91
+ ">>>": 8,
92
+ "+": 9,
93
+ "-": 9,
94
+ "*": 10,
95
+ "/": 10,
96
+ "%": 10
97
+ }, o = {
98
+ Unknown: 0,
99
+ BooleanLiteral: 1,
100
+ EOF: 2,
101
+ Identifier: 3,
102
+ Keyword: 4,
103
+ NullLiteral: 5,
104
+ NumericLiteral: 6,
105
+ Punctuator: 7,
106
+ StringLiteral: 8,
107
+ Template: 10
108
+ }, $ = [
109
+ "Unknown",
110
+ "Boolean",
111
+ "<end>",
112
+ "Identifier",
113
+ "Keyword",
114
+ "Null",
115
+ "Numeric",
116
+ "Punctuator",
117
+ "String",
118
+ "RegularExpression",
119
+ "Template"
120
+ ], a = {
121
+ InvalidModuleUri: "InvalidModuleUri",
122
+ ForInOfLoopInitializer: "ForInOfLoopInitializer",
123
+ IdentifierExpected: "IdentifierExpected",
124
+ InvalidEscapedReservedWord: "InvalidEscapedReservedWord",
125
+ InvalidExpression: "InvalidExpression",
126
+ InvalidFunctionIdentifier: "InvalidFunctionIdentifier",
127
+ InvalidHexEscapeSequence: "InvalidHexEscapeSequence",
128
+ InvalidLeftHandSideInAssignment: "InvalidLeftHandSideInAssignment",
129
+ InvalidLeftHandSideInForIn: "InvalidLeftHandSideInForIn",
130
+ InvalidTemplateHead: "InvalidTemplateHead",
131
+ InvalidVariableAssignment: "InvalidVariableAssignment",
132
+ KeyMustBeString: "KeyMustBeString",
133
+ NoFunctionInsideBlock: "NoFunctionInsideBlock",
134
+ NoFunctionInsideFunction: "NoFunctionInsideFunction",
135
+ ModuleExportRootOnly: "ModuleExportRootOnly",
136
+ ModuleImportRootOnly: "ModuleImportRootOnly",
137
+ PunctuatorExpected: "PunctuatorExpected",
138
+ TemplateOctalLiteral: "TemplateOctalLiteral",
139
+ UnexpectedBoolean: "UnexpectedBoolean",
140
+ UnexpectedEndOfScript: "UnexpectedEndOfScript",
141
+ UnexpectedIdentifier: "UnexpectedIdentifier",
142
+ UnexpectedKeyword: "UnexpectedKeyword",
143
+ UnexpectedNull: "UnexpectedNull",
144
+ UnexpectedNumber: "UnexpectedNumber",
145
+ UnexpectedPunctuator: "UnexpectedPunctuator",
146
+ UnexpectedString: "UnexpectedString",
147
+ UnexpectedTemplate: "UnexpectedTemplate",
148
+ UnexpectedToken: "UnexpectedToken"
149
+ }, ee = {
150
+ [a.InvalidModuleUri]: "Module uri must be a text literal.",
151
+ [a.ForInOfLoopInitializer]: "for-in loop variable declaration may not have an initializer.",
152
+ [a.IdentifierExpected]: "'${value}' is an invalid identifier.",
153
+ [a.InvalidEscapedReservedWord]: "Keyword cannot contain escaped characters.",
154
+ [a.InvalidExpression]: "Invalid expression.",
155
+ [a.InvalidFunctionIdentifier]: "'${value}' is an invalid function identifier.",
156
+ [a.InvalidHexEscapeSequence]: "Invalid hexadecimal escape sequence.",
157
+ [a.InvalidLeftHandSideInAssignment]: "Invalid left-hand side in assignment.",
158
+ [a.InvalidLeftHandSideInForIn]: "Invalid left-hand side in for-in.",
159
+ [a.InvalidTemplateHead]: "Invalid template structure.",
160
+ [a.InvalidVariableAssignment]: "Invalid variable assignment.",
161
+ [a.KeyMustBeString]: "Object property keys must be a word starting with a letter.",
162
+ [a.NoFunctionInsideBlock]: "Functions cannot be declared inside of code blocks.",
163
+ [a.NoFunctionInsideFunction]: "Functions cannot be declared inside another function.",
164
+ [a.ModuleExportRootOnly]: "Module exports cannot be declared inside of code blocks.",
165
+ [a.ModuleImportRootOnly]: "Module import cannot be declared inside of code blocks.",
166
+ [a.PunctuatorExpected]: "'${value}' expected.",
167
+ [a.TemplateOctalLiteral]: "Octal literals are not allowed in template literals.",
168
+ [a.UnexpectedBoolean]: "Unexpected boolean literal.",
169
+ [a.UnexpectedEndOfScript]: "Unexpected end of Arcade expression.",
170
+ [a.UnexpectedIdentifier]: "Unexpected identifier.",
171
+ [a.UnexpectedKeyword]: "Unexpected keyword.",
172
+ [a.UnexpectedNull]: "Unexpected null literal.",
173
+ [a.UnexpectedNumber]: "Unexpected number.",
174
+ [a.UnexpectedPunctuator]: "Unexpected punctuator.",
175
+ [a.UnexpectedString]: "Unexpected text literal.",
176
+ [a.UnexpectedTemplate]: "Unexpected quasi '${value}'.",
177
+ [a.UnexpectedToken]: "Unexpected token '${value}'."
178
+ };
179
+ class y extends Error {
180
+ /**
181
+ * @public
182
+ * @param diagnosticApi
183
+ */
184
+ constructor({ code: e, index: u, line: i, column: r, len: s = 0, description: D, data: h }) {
185
+ super(D ?? e), this.declaredRootClass = "esri.arcade.lib.diagnostic", this.name = "ParsingError", this.code = e, this.index = u, this.line = i, this.column = r, this.len = s, this.data = h, this.description = D, this.range = {
186
+ start: { line: i, column: r - 1 },
187
+ end: { line: i, column: r + s }
188
+ }, Error.captureStackTrace?.(
189
+ this,
190
+ y
191
+ );
192
+ }
193
+ }
194
+ function te(t) {
195
+ return !!t && typeof t == "object" && "type" in t && t.type === n.Program;
196
+ }
197
+ function ue(t) {
198
+ if (!t || typeof t != "object" || !("type" in t))
199
+ return !1;
200
+ switch (t.type) {
201
+ case n.BlockStatement:
202
+ case n.BreakStatement:
203
+ case n.ContinueStatement:
204
+ case n.EmptyStatement:
205
+ case n.ExpressionStatement:
206
+ case n.ForInStatement:
207
+ case n.ForStatement:
208
+ case n.FunctionDeclaration:
209
+ case n.IfStatement:
210
+ case n.ReturnStatement:
211
+ case n.VariableDeclaration:
212
+ return !0;
213
+ default:
214
+ return !1;
215
+ }
216
+ }
217
+ function O(t) {
218
+ return !!t && typeof t == "object" && "type" in t && t.type === n.BlockStatement;
219
+ }
220
+ function ie(t) {
221
+ return !!t && typeof t == "object" && "type" in t && t.type === n.BlockComment;
222
+ }
223
+ function le(t) {
224
+ return !!t && typeof t == "object" && "type" in t && t.type === n.BreakStatement;
225
+ }
226
+ function pe(t) {
227
+ return !!t && typeof t == "object" && "type" in t && t.type === n.ContinueStatement;
228
+ }
229
+ function re(t) {
230
+ return !!t && typeof t == "object" && "type" in t && t.type === n.EmptyStatement;
231
+ }
232
+ function Ce(t) {
233
+ return !!t && typeof t == "object" && "type" in t && t.type === n.ExpressionStatement;
234
+ }
235
+ function de(t) {
236
+ return !!t && typeof t == "object" && "type" in t && t.type === n.ForInStatement;
237
+ }
238
+ function Ee(t) {
239
+ return !!t && typeof t == "object" && "type" in t && t.type === n.ForOfStatement;
240
+ }
241
+ function Fe(t) {
242
+ return !!t && typeof t == "object" && "type" in t && t.type === n.ForStatement;
243
+ }
244
+ function Ae(t) {
245
+ return !!t && typeof t == "object" && "type" in t && t.type === n.FunctionDeclaration;
246
+ }
247
+ function me(t) {
248
+ return !!t && typeof t == "object" && "type" in t && t.type === n.IfStatement;
249
+ }
250
+ function xe(t) {
251
+ return !!t && typeof t == "object" && "type" in t && t.type === n.ReturnStatement;
252
+ }
253
+ function fe(t) {
254
+ return !!t && typeof t == "object" && "type" in t && t.type === n.VariableDeclaration;
255
+ }
256
+ function ne(t) {
257
+ if (!t || typeof t != "object" || !("type" in t))
258
+ return !1;
259
+ switch (t.type) {
260
+ case n.ArrayExpression:
261
+ case n.AssignmentExpression:
262
+ case n.BinaryExpression:
263
+ case n.CallExpression:
264
+ case n.Identifier:
265
+ case n.Literal:
266
+ case n.LogicalExpression:
267
+ case n.MemberExpression:
268
+ case n.ObjectExpression:
269
+ case n.TemplateLiteral:
270
+ case n.UpdateExpression:
271
+ case n.UnaryExpression:
272
+ return !0;
273
+ default:
274
+ return !1;
275
+ }
276
+ }
277
+ function Be(t) {
278
+ return !!t && typeof t == "object" && "type" in t && t.type === n.ArrayExpression;
279
+ }
280
+ function ke(t) {
281
+ return !!t && typeof t == "object" && "type" in t && t.type === n.AssignmentExpression;
282
+ }
283
+ function ye(t) {
284
+ return !!t && typeof t == "object" && "type" in t && t.type === n.BinaryExpression;
285
+ }
286
+ function ge(t) {
287
+ return !!t && typeof t == "object" && "type" in t && t.type === n.CallExpression;
288
+ }
289
+ function Se(t) {
290
+ return !!t && typeof t == "object" && "type" in t && t.type === n.Identifier;
291
+ }
292
+ function we(t) {
293
+ return !!t && typeof t == "object" && "type" in t && t.type === n.Literal;
294
+ }
295
+ function be(t) {
296
+ return !!t && typeof t == "object" && "type" in t && t.type === n.LogicalExpression;
297
+ }
298
+ function Te(t) {
299
+ return !!t && typeof t == "object" && "type" in t && t.type === n.ObjectExpression;
300
+ }
301
+ function Ie(t) {
302
+ return !!t && typeof t == "object" && "type" in t && t.type === n.TemplateLiteral;
303
+ }
304
+ function Le(t) {
305
+ return !!t && typeof t == "object" && "type" in t && t.type === n.MemberExpression;
306
+ }
307
+ function ve(t) {
308
+ return !!t && typeof t == "object" && "type" in t && t.type === n.SafeMemberExpression;
309
+ }
310
+ function Me(t) {
311
+ return !!t && typeof t == "object" && "type" in t && t.type === n.MemberAccessChainExpression;
312
+ }
313
+ function Ne(t) {
314
+ return !!t && typeof t == "object" && "type" in t && t.type === n.UnaryExpression;
315
+ }
316
+ function Ue(t) {
317
+ return !!t && typeof t == "object" && "type" in t && t.type === n.UpdateExpression;
318
+ }
319
+ function se(t) {
320
+ return !!t && typeof t == "object" && "type" in t && t.type === n.VariableDeclarator;
321
+ }
322
+ function Pe(t) {
323
+ return !!t && typeof t == "object" && "type" in t && t.type === n.Property;
324
+ }
325
+ function Oe(t) {
326
+ return !!t && typeof t == "object" && "type" in t && t.type === n.TemplateElement;
327
+ }
328
+ function I(t, e) {
329
+ return e.loc.end.line === t.loc.start.line && e.loc.end.column <= t.loc.start.column;
330
+ }
331
+ function j(t, e) {
332
+ return t.range[0] >= e.range[0] && t.range[1] <= e.range[1];
333
+ }
334
+ class ae {
335
+ constructor() {
336
+ this.comments = [], this._nodeStack = [], this._newComments = [];
337
+ }
338
+ insertInnerComments(e) {
339
+ if (!O(e) || e.body.length !== 0)
340
+ return;
341
+ const u = [];
342
+ for (let i = this._newComments.length - 1; i >= 0; i--) {
343
+ const r = this._newComments[i];
344
+ e.range[1] >= r.range[0] && (u.unshift(r), this._newComments.splice(i, 1));
345
+ }
346
+ u.length && (e.innerComments = u);
347
+ }
348
+ attachTrailingComments(e) {
349
+ const u = this._nodeStack.at(-1);
350
+ if (!u)
351
+ return;
352
+ if (O(e) && j(u, e))
353
+ for (let r = this._newComments.length - 1; r >= 0; r--) {
354
+ const s = this._newComments[r];
355
+ j(s, e) && (u.trailingComments = [...u.trailingComments ?? [], s], this._newComments.splice(r, 1));
356
+ }
357
+ let i = [];
358
+ if (this._newComments.length > 0)
359
+ for (let r = this._newComments.length - 1; r >= 0; r--) {
360
+ const s = this._newComments[r];
361
+ I(s, u) ? (u.trailingComments = [...u.trailingComments ?? [], s], this._newComments.splice(r, 1)) : I(s, e) && (i.unshift(s), this._newComments.splice(r, 1));
362
+ }
363
+ if (u.trailingComments) {
364
+ const r = u.trailingComments[0];
365
+ I(r, e) && (i = [...i, ...u.trailingComments], delete u.trailingComments);
366
+ }
367
+ i.length > 0 && (e.trailingComments = i);
368
+ }
369
+ attachLeadingComments(e) {
370
+ let u;
371
+ for (; this._nodeStack.length > 0; ) {
372
+ const s = this._nodeStack[this._nodeStack.length - 1];
373
+ if (e.range[0] <= s.range[0]) {
374
+ u = s, this._nodeStack.pop();
375
+ continue;
376
+ }
377
+ break;
378
+ }
379
+ const i = [], r = [];
380
+ if (u != null) {
381
+ if (!u.leadingComments)
382
+ return;
383
+ for (let s = u.leadingComments.length - 1; s >= 0; s--) {
384
+ const D = u.leadingComments[s];
385
+ if (e.range[0] >= D.range[1]) {
386
+ i.unshift(D), u.leadingComments.splice(s, 1);
387
+ continue;
388
+ }
389
+ se(e) && !ie(D) && (r.unshift(D), u.leadingComments.splice(s, 1));
390
+ }
391
+ u.leadingComments.length === 0 && delete u.leadingComments, i.length && (e.leadingComments = i), r.length && (e.trailingComments = [...r, ...e.trailingComments ?? []]);
392
+ return;
393
+ }
394
+ for (let s = this._newComments.length - 1; s >= 0; s--) {
395
+ const D = this._newComments[s];
396
+ e.range[0] >= D.range[0] && (i.unshift(D), this._newComments.splice(s, 1));
397
+ }
398
+ i.length && (e.leadingComments = i);
399
+ }
400
+ attachComments(e) {
401
+ if (te(e) && e.body.length > 0) {
402
+ const u = this._nodeStack.at(-1);
403
+ if (u) {
404
+ u.trailingComments = [...u.trailingComments ?? [], ...this._newComments], this._newComments.length = 0, this._nodeStack.pop();
405
+ return;
406
+ }
407
+ e.trailingComments = [...this._newComments], this._newComments.length = 0;
408
+ return;
409
+ }
410
+ this.attachTrailingComments(e), this.attachLeadingComments(e), this.insertInnerComments(e), this._nodeStack.push(e);
411
+ }
412
+ collectComment(e) {
413
+ this.comments.push(e), this._newComments.push(e);
414
+ }
415
+ }
416
+ const oe = /\$\{(.*?)\}/gu;
417
+ function N(t, e) {
418
+ const u = ee[t];
419
+ return e ? u.replace(oe, (i, r) => e[r]?.toString() ?? "") : u;
420
+ }
421
+ class J {
422
+ constructor(e = !1) {
423
+ this.tolerant = e, this.errors = [];
424
+ }
425
+ recordError(e) {
426
+ this.errors.push(e);
427
+ }
428
+ tolerate(e) {
429
+ if (this.tolerant)
430
+ this.recordError(e);
431
+ else
432
+ throw e;
433
+ }
434
+ throwError(e) {
435
+ throw e.description ??= N(e.code, e.data), new y(e);
436
+ }
437
+ tolerateError(e) {
438
+ e.description ??= N(e.code, e.data);
439
+ const u = new y(e);
440
+ if (this.tolerant)
441
+ this.recordError(u);
442
+ else
443
+ throw u;
444
+ }
445
+ }
446
+ function R(t, e) {
447
+ if (!t)
448
+ throw new Error(`ASSERT: ${e}`);
449
+ }
450
+ const z = {
451
+ // Unicode v12.1.0 NonAsciiIdentifierStart:
452
+ NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEF\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7C6\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB67\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/u,
453
+ // Unicode v12.1.0 NonAsciiIdentifierPart:
454
+ NonAsciiIdentifierPart: /[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05EF-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u07FD\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D3-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u09FE\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1878\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CD0-\u1CD2\u1CD4-\u1CFA\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEF\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7C6\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB67\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD27\uDD30-\uDD39\uDF00-\uDF1C\uDF27\uDF30-\uDF50\uDFE0-\uDFF6]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD44-\uDD46\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDC9-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3B-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC5E\uDC5F\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB8\uDEC0-\uDEC9\uDF00-\uDF1A\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDC00-\uDC3A\uDCA0-\uDCE9\uDCFF\uDDA0-\uDDA7\uDDAA-\uDDD7\uDDDA-\uDDE1\uDDE3\uDDE4\uDE00-\uDE3E\uDE47\uDE50-\uDE99\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD8E\uDD90\uDD91\uDD93-\uDD98\uDDA0-\uDDA9\uDEE0-\uDEF6]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF4F-\uDF87\uDF8F-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDD00-\uDD2C\uDD30-\uDD3D\uDD40-\uDD49\uDD4E\uDEC0-\uDEF9]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4B\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/u
455
+ }, c = {
456
+ fromCodePoint(t) {
457
+ return t < 65536 ? String.fromCharCode(t) : String.fromCharCode(55296 + (t - 65536 >> 10)) + String.fromCharCode(56320 + (t - 65536 & 1023));
458
+ },
459
+ // https://tc39.github.io/ecma262/#sec-white-space
460
+ isWhiteSpace(t) {
461
+ return t === 32 || t === 9 || t === 11 || t === 12 || t === 160 || t >= 5760 && [
462
+ 5760,
463
+ 8192,
464
+ 8193,
465
+ 8194,
466
+ 8195,
467
+ 8196,
468
+ 8197,
469
+ 8198,
470
+ 8199,
471
+ 8200,
472
+ 8201,
473
+ 8202,
474
+ 8239,
475
+ 8287,
476
+ 12288,
477
+ 65279
478
+ ].includes(t);
479
+ },
480
+ // https://tc39.github.io/ecma262/#sec-line-terminators
481
+ isLineTerminator(t) {
482
+ return t === 10 || t === 13 || t === 8232 || t === 8233;
483
+ },
484
+ // https://tc39.github.io/ecma262/#sec-names-and-keywords
485
+ isIdentifierStart(t) {
486
+ return t === 36 || t === 95 || // $ (dollar) and _ (underscore)
487
+ t >= 65 && t <= 90 || // A..Z
488
+ t >= 97 && t <= 122 || // a..z
489
+ t === 92 || // \ (backslash)
490
+ t >= 128 && z.NonAsciiIdentifierStart.test(c.fromCodePoint(t));
491
+ },
492
+ isIdentifierPart(t) {
493
+ return t === 36 || t === 95 || // $ (dollar) and _ (underscore)
494
+ t >= 65 && t <= 90 || // A..Z
495
+ t >= 97 && t <= 122 || // a..z
496
+ t >= 48 && t <= 57 || // 0..9
497
+ t === 92 || // \ (backslash)
498
+ t >= 128 && z.NonAsciiIdentifierPart.test(c.fromCodePoint(t));
499
+ },
500
+ // https://tc39.github.io/ecma262/#sec-literals-numeric-literals
501
+ isDecimalDigit(t) {
502
+ return t >= 48 && t <= 57;
503
+ },
504
+ isHexDigit(t) {
505
+ return t >= 48 && t <= 57 || // 0..9
506
+ t >= 65 && t <= 70 || // A..F
507
+ t >= 97 && t <= 102;
508
+ },
509
+ isOctalDigit(t) {
510
+ return t >= 48 && t <= 55;
511
+ }
512
+ };
513
+ function H(t) {
514
+ return "0123456789abcdef".indexOf(t.toLowerCase());
515
+ }
516
+ function L(t) {
517
+ return "01234567".indexOf(t);
518
+ }
519
+ const B = [[], [], []];
520
+ M.forEach((t) => B[t.length - 1].push(t));
521
+ G.forEach((t) => B[t.length - 1].push(t));
522
+ q.forEach((t) => B[t.length - 1].push(t));
523
+ W.forEach((t) => B[t.length - 1].push(t));
524
+ Z.forEach((t) => B[t.length - 1].push(t));
525
+ B[g.length - 1].push(g);
526
+ class X {
527
+ constructor(e, u) {
528
+ this.source = e, this.errorHandler = u, this._length = e.length, this.index = 0, this.lineNumber = 1, this.lineStart = 0, this.curlyStack = [];
529
+ }
530
+ saveState() {
531
+ return {
532
+ index: this.index,
533
+ lineNumber: this.lineNumber,
534
+ lineStart: this.lineStart,
535
+ curlyStack: this.curlyStack.slice()
536
+ };
537
+ }
538
+ restoreState(e) {
539
+ this.index = e.index, this.lineNumber = e.lineNumber, this.lineStart = e.lineStart, this.curlyStack = e.curlyStack;
540
+ }
541
+ eof() {
542
+ return this.index >= this._length;
543
+ }
544
+ throwUnexpectedToken(e = a.UnexpectedToken) {
545
+ this.errorHandler.throwError({
546
+ code: e,
547
+ index: this.index,
548
+ line: this.lineNumber,
549
+ column: this.index - this.lineStart + 1,
550
+ data: { value: this.source.charAt(this.index) }
551
+ });
552
+ }
553
+ tolerateUnexpectedToken(e = a.UnexpectedToken) {
554
+ this.errorHandler.tolerateError({
555
+ code: e,
556
+ index: this.index,
557
+ line: this.lineNumber,
558
+ column: this.index - this.lineStart + 1
559
+ });
560
+ }
561
+ skipSingleLineComment(e) {
562
+ const u = [], i = this.index - e, r = {
563
+ start: {
564
+ line: this.lineNumber,
565
+ column: this.index - this.lineStart - e
566
+ },
567
+ end: { line: 0, column: 0 }
568
+ // Fake for now
569
+ };
570
+ for (; !this.eof(); ) {
571
+ const D = this.source.charCodeAt(this.index);
572
+ if (this.index += 1, c.isLineTerminator(D)) {
573
+ r.end = {
574
+ line: this.lineNumber,
575
+ column: this.index - this.lineStart - 1
576
+ };
577
+ const h = {
578
+ multiLine: !1,
579
+ start: i + e,
580
+ end: this.index - 1,
581
+ range: [i, this.index - 1],
582
+ loc: r
583
+ };
584
+ return u.push(h), D === 13 && this.source.charCodeAt(this.index) === 10 && (this.index += 1), this.lineNumber += 1, this.lineStart = this.index, u;
585
+ }
586
+ }
587
+ r.end = {
588
+ line: this.lineNumber,
589
+ column: this.index - this.lineStart
590
+ };
591
+ const s = {
592
+ multiLine: !1,
593
+ start: i + e,
594
+ end: this.index,
595
+ range: [i, this.index],
596
+ loc: r
597
+ };
598
+ return u.push(s), u;
599
+ }
600
+ skipMultiLineComment() {
601
+ const e = [], u = this.index - 2, i = {
602
+ start: {
603
+ line: this.lineNumber,
604
+ column: this.index - this.lineStart - 2
605
+ },
606
+ end: { line: 0, column: 0 }
607
+ // Fake for now
608
+ };
609
+ for (; !this.eof(); ) {
610
+ const s = this.source.charCodeAt(this.index);
611
+ if (c.isLineTerminator(s))
612
+ s === 13 && this.source.charCodeAt(this.index + 1) === 10 && (this.index += 1), this.lineNumber += 1, this.index += 1, this.lineStart = this.index;
613
+ else if (s === 42) {
614
+ if (this.source.charCodeAt(this.index + 1) === 47) {
615
+ this.index += 2, i.end = {
616
+ line: this.lineNumber,
617
+ column: this.index - this.lineStart
618
+ };
619
+ const D = {
620
+ multiLine: !0,
621
+ start: u + 2,
622
+ end: this.index - 2,
623
+ range: [u, this.index],
624
+ loc: i
625
+ };
626
+ return e.push(D), e;
627
+ }
628
+ this.index += 1;
629
+ } else
630
+ this.index += 1;
631
+ }
632
+ i.end = {
633
+ line: this.lineNumber,
634
+ column: this.index - this.lineStart
635
+ };
636
+ const r = {
637
+ multiLine: !0,
638
+ start: u + 2,
639
+ end: this.index,
640
+ range: [u, this.index],
641
+ loc: i
642
+ };
643
+ return e.push(r), this.tolerateUnexpectedToken(), e;
644
+ }
645
+ scanComments() {
646
+ let e = [];
647
+ for (; !this.eof(); ) {
648
+ let u = this.source.charCodeAt(this.index);
649
+ if (c.isWhiteSpace(u))
650
+ this.index += 1;
651
+ else if (c.isLineTerminator(u))
652
+ this.index += 1, u === 13 && this.source.charCodeAt(this.index) === 10 && (this.index += 1), this.lineNumber += 1, this.lineStart = this.index;
653
+ else if (u === 47)
654
+ if (u = this.source.charCodeAt(this.index + 1), u === 47) {
655
+ this.index += 2;
656
+ const i = this.skipSingleLineComment(2);
657
+ e = [...e, ...i];
658
+ } else if (u === 42) {
659
+ this.index += 2;
660
+ const i = this.skipMultiLineComment();
661
+ e = [...e, ...i];
662
+ } else
663
+ break;
664
+ else
665
+ break;
666
+ }
667
+ return e;
668
+ }
669
+ isKeyword(e) {
670
+ switch (e = e.toLowerCase(), e.length) {
671
+ case 2:
672
+ return e === l.If || e === l.In;
673
+ case 3:
674
+ return e === l.Var || e === l.For;
675
+ case 4:
676
+ return e === l.Else;
677
+ case 5:
678
+ return e === l.Break || e === l.While;
679
+ case 6:
680
+ return e === l.Return || e === l.Import || e === l.Export;
681
+ case 8:
682
+ return e === l.Function || e === l.Continue;
683
+ default:
684
+ return !1;
685
+ }
686
+ }
687
+ codePointAt(e) {
688
+ let u = this.source.charCodeAt(e);
689
+ if (u >= 55296 && u <= 56319) {
690
+ const i = this.source.charCodeAt(e + 1);
691
+ i >= 56320 && i <= 57343 && (u = (u - 55296) * 1024 + i - 56320 + 65536);
692
+ }
693
+ return u;
694
+ }
695
+ scanHexEscape(e) {
696
+ const u = e === "u" ? 4 : 2;
697
+ let i = 0;
698
+ for (let r = 0; r < u; r++)
699
+ if (!this.eof() && c.isHexDigit(this.source.charCodeAt(this.index)))
700
+ i = i * 16 + H(this.source[this.index] ?? ""), this.index += 1;
701
+ else
702
+ return null;
703
+ return String.fromCharCode(i);
704
+ }
705
+ scanUnicodeCodePointEscape() {
706
+ let e = this.source[this.index], u = 0;
707
+ for (e === "}" && this.throwUnexpectedToken(); !this.eof() && (e = this.source[this.index] ?? "", this.index += 1, !!c.isHexDigit(e.charCodeAt(0))); )
708
+ u = u * 16 + H(e);
709
+ return (u > 1114111 || e !== "}") && this.throwUnexpectedToken(), c.fromCodePoint(u);
710
+ }
711
+ getIdentifier() {
712
+ const e = this.index;
713
+ for (this.index += 1; !this.eof(); ) {
714
+ const u = this.source.charCodeAt(this.index);
715
+ if (u === 92)
716
+ return this.index = e, this.getComplexIdentifier();
717
+ if (u >= 55296 && u < 57343)
718
+ return this.index = e, this.getComplexIdentifier();
719
+ if (c.isIdentifierPart(u))
720
+ this.index += 1;
721
+ else
722
+ break;
723
+ }
724
+ return this.source.slice(e, this.index);
725
+ }
726
+ getComplexIdentifier() {
727
+ let e = this.codePointAt(this.index), u = c.fromCodePoint(e);
728
+ this.index += u.length;
729
+ let i;
730
+ for (e === 92 && (this.source.charCodeAt(this.index) !== 117 && this.throwUnexpectedToken(), this.index += 1, this.source[this.index] === "{" ? (this.index += 1, i = this.scanUnicodeCodePointEscape()) : (i = this.scanHexEscape("u"), (i === null || i === "\\" || !c.isIdentifierStart(i.charCodeAt(0))) && this.throwUnexpectedToken()), u = i); !this.eof() && (e = this.codePointAt(this.index), !!c.isIdentifierPart(e)); )
731
+ i = c.fromCodePoint(e), u += i, this.index += i.length, e === 92 && (u = u.substring(0, u.length - 1), this.source.charCodeAt(this.index) !== 117 && this.throwUnexpectedToken(), this.index += 1, this.source[this.index] === "{" ? (this.index += 1, i = this.scanUnicodeCodePointEscape()) : (i = this.scanHexEscape("u"), (i === null || i === "\\" || !c.isIdentifierPart(i.charCodeAt(0))) && this.throwUnexpectedToken()), u += i);
732
+ return u;
733
+ }
734
+ octalToDecimal(e) {
735
+ let u = e !== "0", i = L(e);
736
+ return !this.eof() && c.isOctalDigit(this.source.charCodeAt(this.index)) && (u = !0, i = i * 8 + L(this.source[this.index] ?? ""), this.index += 1, "0123".includes(e) && !this.eof() && c.isOctalDigit(this.source.charCodeAt(this.index)) && (i = i * 8 + L(this.source[this.index] ?? ""), this.index += 1)), { code: i, octal: u };
737
+ }
738
+ // https://tc39.github.io/ecma262/#sec-names-and-keywords
739
+ scanIdentifier() {
740
+ let e;
741
+ const u = this.index, i = this.source.charCodeAt(u) === 92 ? this.getComplexIdentifier() : this.getIdentifier();
742
+ if (i.length === 1 ? e = o.Identifier : this.isKeyword(i) ? e = o.Keyword : i.toLowerCase() === w.Null ? e = o.NullLiteral : i.toLowerCase() === w.True || i.toLowerCase() === w.False ? e = o.BooleanLiteral : e = o.Identifier, e !== o.Identifier && u + i.length !== this.index) {
743
+ const r = this.index;
744
+ this.index = u, this.tolerateUnexpectedToken(a.InvalidEscapedReservedWord), this.index = r;
745
+ }
746
+ return {
747
+ type: e,
748
+ value: i,
749
+ lineNumber: this.lineNumber,
750
+ lineStart: this.lineStart,
751
+ start: u,
752
+ end: this.index
753
+ };
754
+ }
755
+ // https://tc39.github.io/ecma262/#sec-punctuators
756
+ scanPunctuator() {
757
+ const e = this.index;
758
+ let u = this.source[this.index] ?? "";
759
+ switch (u) {
760
+ case "(":
761
+ case "{":
762
+ u === "{" && this.curlyStack.push("{"), this.index += 1;
763
+ break;
764
+ case ".":
765
+ this.index += 1;
766
+ break;
767
+ case "}":
768
+ this.index += 1, this.curlyStack.pop();
769
+ break;
770
+ case ")":
771
+ case ";":
772
+ case ",":
773
+ case "[":
774
+ case "]":
775
+ case ":":
776
+ case "~":
777
+ this.index += 1;
778
+ break;
779
+ default:
780
+ for (let i = B.length; i > 0; i--)
781
+ if (u = this.source.substring(this.index, this.index + i), B[i - 1]?.includes(u)) {
782
+ this.index += i;
783
+ break;
784
+ }
785
+ }
786
+ return this.index === e && this.throwUnexpectedToken(), {
787
+ type: o.Punctuator,
788
+ value: u,
789
+ lineNumber: this.lineNumber,
790
+ lineStart: this.lineStart,
791
+ start: e,
792
+ end: this.index
793
+ };
794
+ }
795
+ // https://tc39.github.io/ecma262/#sec-literals-numeric-literals
796
+ scanHexLiteral(e) {
797
+ let u = "";
798
+ for (; !this.eof() && c.isHexDigit(this.source.charCodeAt(this.index)); )
799
+ u += this.source[this.index], this.index += 1;
800
+ return u.length === 0 && this.throwUnexpectedToken(), c.isIdentifierStart(this.source.charCodeAt(this.index)) && this.throwUnexpectedToken(), {
801
+ type: o.NumericLiteral,
802
+ value: Number.parseInt(`0x${u}`, 16),
803
+ lineNumber: this.lineNumber,
804
+ lineStart: this.lineStart,
805
+ start: e,
806
+ end: this.index
807
+ };
808
+ }
809
+ scanBinaryLiteral(e) {
810
+ let u = "";
811
+ for (; !this.eof(); ) {
812
+ const i = this.source[this.index];
813
+ if (i !== "0" && i !== "1")
814
+ break;
815
+ u += this.source[this.index], this.index += 1;
816
+ }
817
+ if (u.length === 0 && this.throwUnexpectedToken(), !this.eof()) {
818
+ const i = this.source.charCodeAt(this.index);
819
+ (c.isIdentifierStart(i) || c.isDecimalDigit(i)) && this.throwUnexpectedToken();
820
+ }
821
+ return {
822
+ type: o.NumericLiteral,
823
+ value: Number.parseInt(u, 2),
824
+ lineNumber: this.lineNumber,
825
+ lineStart: this.lineStart,
826
+ start: e,
827
+ end: this.index
828
+ };
829
+ }
830
+ scanOctalLiteral(e, u) {
831
+ let i = "", r = !1;
832
+ for (c.isOctalDigit(e.charCodeAt(0)) && (r = !0, i = `0${this.source[this.index]}`), this.index += 1; !this.eof() && c.isOctalDigit(this.source.charCodeAt(this.index)); )
833
+ i += this.source[this.index], this.index += 1;
834
+ return !r && i.length === 0 && this.throwUnexpectedToken(), (c.isIdentifierStart(this.source.charCodeAt(this.index)) || c.isDecimalDigit(this.source.charCodeAt(this.index))) && this.throwUnexpectedToken(), {
835
+ type: o.NumericLiteral,
836
+ value: Number.parseInt(i, 8),
837
+ lineNumber: this.lineNumber,
838
+ lineStart: this.lineStart,
839
+ start: u,
840
+ end: this.index
841
+ };
842
+ }
843
+ scanNumericLiteral() {
844
+ const e = this.index;
845
+ let u = this.source[e] ?? "";
846
+ R(
847
+ c.isDecimalDigit(u.charCodeAt(0)) || u === ".",
848
+ "Numeric literal must start with a decimal digit or a decimal point"
849
+ );
850
+ let i = "";
851
+ if (u !== ".") {
852
+ if (i = this.source[this.index] ?? "", this.index += 1, u = this.source[this.index] ?? "", i === "0") {
853
+ if (u === "x" || u === "X")
854
+ return this.index += 1, this.scanHexLiteral(e);
855
+ if (u === "b" || u === "B")
856
+ return this.index += 1, this.scanBinaryLiteral(e);
857
+ if (u === "o" || u === "O")
858
+ return this.scanOctalLiteral(u, e);
859
+ }
860
+ for (; c.isDecimalDigit(this.source.charCodeAt(this.index)); )
861
+ i += this.source[this.index], this.index += 1;
862
+ u = this.source[this.index] ?? "";
863
+ }
864
+ if (u === ".") {
865
+ for (i += this.source[this.index], this.index += 1; c.isDecimalDigit(this.source.charCodeAt(this.index)); )
866
+ i += this.source[this.index], this.index += 1;
867
+ u = this.source[this.index] ?? "";
868
+ }
869
+ if (u === "e" || u === "E")
870
+ if (i += this.source[this.index], this.index += 1, u = this.source[this.index] ?? "", (u === "+" || u === "-") && (i += this.source[this.index], this.index += 1), c.isDecimalDigit(this.source.charCodeAt(this.index)))
871
+ for (; c.isDecimalDigit(this.source.charCodeAt(this.index)); )
872
+ i += this.source[this.index], this.index += 1;
873
+ else
874
+ this.throwUnexpectedToken();
875
+ return c.isIdentifierStart(this.source.charCodeAt(this.index)) && this.throwUnexpectedToken(), {
876
+ type: o.NumericLiteral,
877
+ value: Number.parseFloat(i),
878
+ lineNumber: this.lineNumber,
879
+ lineStart: this.lineStart,
880
+ start: e,
881
+ end: this.index
882
+ };
883
+ }
884
+ scanStringLiteral() {
885
+ const e = this.index;
886
+ let u = this.source[e];
887
+ R(u === "'" || u === '"', "String literal must starts with a quote"), this.index += 1;
888
+ let i = !1, r = "";
889
+ for (; !this.eof(); ) {
890
+ let s = this.source[this.index] ?? "";
891
+ if (this.index += 1, s === u) {
892
+ u = "";
893
+ break;
894
+ }
895
+ if (s === "\\")
896
+ if (s = this.source[this.index] ?? "", this.index += 1, !s || !c.isLineTerminator(s.charCodeAt(0)))
897
+ switch (s) {
898
+ case "u":
899
+ if (this.source[this.index] === "{")
900
+ this.index += 1, r += this.scanUnicodeCodePointEscape();
901
+ else {
902
+ const D = this.scanHexEscape(s);
903
+ D === null && this.throwUnexpectedToken(), r += D;
904
+ }
905
+ break;
906
+ case "x": {
907
+ const D = this.scanHexEscape(s);
908
+ D === null && this.throwUnexpectedToken(a.InvalidHexEscapeSequence), r += D;
909
+ break;
910
+ }
911
+ case "n":
912
+ r += `
913
+ `;
914
+ break;
915
+ case "r":
916
+ r += "\r";
917
+ break;
918
+ case "t":
919
+ r += " ";
920
+ break;
921
+ case "b":
922
+ r += "\b";
923
+ break;
924
+ case "f":
925
+ r += "\f";
926
+ break;
927
+ case "v":
928
+ r += "\v";
929
+ break;
930
+ case "8":
931
+ case "9":
932
+ r += s, this.tolerateUnexpectedToken();
933
+ break;
934
+ default:
935
+ if (s && c.isOctalDigit(s.charCodeAt(0))) {
936
+ const D = this.octalToDecimal(s);
937
+ i = D.octal || i, r += String.fromCharCode(D.code);
938
+ } else
939
+ r += s;
940
+ break;
941
+ }
942
+ else
943
+ this.lineNumber += 1, s === "\r" && this.source[this.index] === `
944
+ ` && (this.index += 1), this.lineStart = this.index;
945
+ else {
946
+ if (c.isLineTerminator(s.charCodeAt(0)))
947
+ break;
948
+ r += s;
949
+ }
950
+ }
951
+ return u !== "" && (this.index = e, this.throwUnexpectedToken()), {
952
+ type: o.StringLiteral,
953
+ value: r,
954
+ lineNumber: this.lineNumber,
955
+ lineStart: this.lineStart,
956
+ start: e,
957
+ end: this.index
958
+ };
959
+ }
960
+ scanTemplate() {
961
+ let e = "", u = !1;
962
+ const i = this.index, r = this.source[i] === "`";
963
+ let s = !1, D = 2;
964
+ for (this.index += 1; !this.eof(); ) {
965
+ let h = this.source[this.index] ?? "";
966
+ if (this.index += 1, h === "`") {
967
+ D = 1, s = !0, u = !0;
968
+ break;
969
+ }
970
+ if (h === "$") {
971
+ if (this.source[this.index] === "{") {
972
+ this.curlyStack.push("${"), this.index += 1, u = !0;
973
+ break;
974
+ }
975
+ e += h;
976
+ continue;
977
+ }
978
+ if (h === "\\") {
979
+ if (h = this.source[this.index] ?? "", this.index += 1, c.isLineTerminator(h.charCodeAt(0)))
980
+ this.lineNumber += 1, h === "\r" && this.source[this.index] === `
981
+ ` && (this.index += 1), this.lineStart = this.index;
982
+ else
983
+ switch (h) {
984
+ case "n":
985
+ e += `
986
+ `;
987
+ break;
988
+ case "r":
989
+ e += "\r";
990
+ break;
991
+ case "t":
992
+ e += " ";
993
+ break;
994
+ case "u":
995
+ if (this.source[this.index] === "{")
996
+ this.index += 1, e += this.scanUnicodeCodePointEscape();
997
+ else {
998
+ const d = this.index, F = this.scanHexEscape(h);
999
+ F !== null ? e += F : (this.index = d, e += h);
1000
+ }
1001
+ break;
1002
+ case "x": {
1003
+ const d = this.scanHexEscape(h);
1004
+ d === null && this.throwUnexpectedToken(a.InvalidHexEscapeSequence), e += d;
1005
+ break;
1006
+ }
1007
+ case "b":
1008
+ e += "\b";
1009
+ break;
1010
+ case "f":
1011
+ e += "\f";
1012
+ break;
1013
+ case "v":
1014
+ e += "\v";
1015
+ break;
1016
+ default:
1017
+ h === "0" ? (c.isDecimalDigit(this.source.charCodeAt(this.index)) && this.throwUnexpectedToken(a.TemplateOctalLiteral), e += "\0") : c.isOctalDigit(h.charCodeAt(0)) ? this.throwUnexpectedToken(a.TemplateOctalLiteral) : e += h;
1018
+ break;
1019
+ }
1020
+ continue;
1021
+ }
1022
+ if (c.isLineTerminator(h.charCodeAt(0))) {
1023
+ this.lineNumber += 1, h === "\r" && this.source[this.index] === `
1024
+ ` && (this.index += 1), this.lineStart = this.index, e += `
1025
+ `;
1026
+ continue;
1027
+ }
1028
+ e += h;
1029
+ }
1030
+ return u || this.throwUnexpectedToken(), r || this.curlyStack.pop(), {
1031
+ type: o.Template,
1032
+ value: this.source.slice(i + 1, this.index - D),
1033
+ cooked: e,
1034
+ head: r,
1035
+ tail: s,
1036
+ lineNumber: this.lineNumber,
1037
+ lineStart: this.lineStart,
1038
+ start: i,
1039
+ end: this.index
1040
+ };
1041
+ }
1042
+ lex() {
1043
+ if (this.eof())
1044
+ return {
1045
+ type: o.EOF,
1046
+ value: "",
1047
+ lineNumber: this.lineNumber,
1048
+ lineStart: this.lineStart,
1049
+ start: this.index,
1050
+ end: this.index
1051
+ };
1052
+ const e = this.source.charCodeAt(this.index);
1053
+ return c.isIdentifierStart(e) ? this.scanIdentifier() : e === 40 || e === 41 || e === 59 ? this.scanPunctuator() : e === 39 || e === 34 ? this.scanStringLiteral() : e === 46 ? c.isDecimalDigit(this.source.charCodeAt(this.index + 1)) ? this.scanNumericLiteral() : this.scanPunctuator() : c.isDecimalDigit(e) ? this.scanNumericLiteral() : e === 96 || e === 125 && this.curlyStack[this.curlyStack.length - 1] === "${" ? this.scanTemplate() : e >= 55296 && e < 57343 && c.isIdentifierStart(this.codePointAt(this.index)) ? this.scanIdentifier() : this.scanPunctuator();
1054
+ }
1055
+ }
1056
+ const E = {
1057
+ None: 0,
1058
+ Function: 1,
1059
+ IfClause: 2,
1060
+ ForLoop: 4,
1061
+ ForOfLoop: 8,
1062
+ WhileLoop: 16
1063
+ }, v = {
1064
+ AsObject: 0,
1065
+ Automatic: 1
1066
+ };
1067
+ function K(t, e = 0) {
1068
+ let u = t.start - t.lineStart, i = t.lineNumber;
1069
+ return u < 0 && (u += e, i -= 1), { index: t.start, line: i, column: u };
1070
+ }
1071
+ function V(t) {
1072
+ return [
1073
+ { index: t.range[0], ...t.loc.start },
1074
+ { index: t.range[1], ...t.loc.end }
1075
+ ];
1076
+ }
1077
+ function _(t) {
1078
+ return t in P ? P[t] : 0;
1079
+ }
1080
+ class De {
1081
+ constructor(e, u = {}, i) {
1082
+ this.delegate = i, this.hasLineTerminator = !1, this.options = {
1083
+ tokens: typeof u.tokens == "boolean" && u.tokens,
1084
+ comments: typeof u.comments == "boolean" && u.comments,
1085
+ tolerant: typeof u.tolerant == "boolean" && u.tolerant
1086
+ }, this.options.comments && (this.commentHandler = new ae()), this.errorHandler = new J(this.options.tolerant), this.scanner = new X(e, this.errorHandler), this.context = {
1087
+ isAssignmentTarget: !1,
1088
+ blockContext: E.None,
1089
+ curlyParsingType: v.AsObject
1090
+ }, this.rawToken = {
1091
+ type: o.EOF,
1092
+ value: "",
1093
+ lineNumber: this.scanner.lineNumber,
1094
+ lineStart: 0,
1095
+ start: 0,
1096
+ end: 0
1097
+ }, this.tokens = [], this.startMarker = {
1098
+ index: 0,
1099
+ line: this.scanner.lineNumber,
1100
+ column: 0
1101
+ }, this.endMarker = {
1102
+ index: 0,
1103
+ line: this.scanner.lineNumber,
1104
+ column: 0
1105
+ }, this.readNextRawToken(), this.endMarker = {
1106
+ index: this.scanner.index,
1107
+ line: this.scanner.lineNumber,
1108
+ column: this.scanner.index - this.scanner.lineStart
1109
+ };
1110
+ }
1111
+ throwIfInvalidType(e, u, {
1112
+ validTypes: i,
1113
+ invalidTypes: r
1114
+ }) {
1115
+ i?.some((s) => e.type === s) || r?.some((s) => e.type === s) && this.throwError(a.InvalidExpression, u);
1116
+ }
1117
+ throwError(e, u, i = this.endMarker) {
1118
+ const { index: r, line: s, column: D } = u, h = i.index - r - 1;
1119
+ this.errorHandler.throwError({ code: e, index: r, line: s, column: D + 1, len: h });
1120
+ }
1121
+ tolerateError(e, u) {
1122
+ throw new Error("######################################### !!!");
1123
+ }
1124
+ // Throw an exception because of the token.
1125
+ unexpectedTokenError(e = {}) {
1126
+ const { rawToken: u } = e;
1127
+ let { code: i, data: r } = e, s;
1128
+ if (u) {
1129
+ if (!i)
1130
+ switch (u.type) {
1131
+ case o.EOF:
1132
+ i = a.UnexpectedEndOfScript;
1133
+ break;
1134
+ case o.Identifier:
1135
+ i = a.UnexpectedIdentifier;
1136
+ break;
1137
+ case o.NumericLiteral:
1138
+ i = a.UnexpectedNumber;
1139
+ break;
1140
+ case o.StringLiteral:
1141
+ i = a.UnexpectedString;
1142
+ break;
1143
+ case o.Template:
1144
+ i = a.UnexpectedTemplate;
1145
+ break;
1146
+ }
1147
+ s = u.value.toString();
1148
+ } else
1149
+ s = "ILLEGAL";
1150
+ i ??= a.UnexpectedToken, r ??= { value: s };
1151
+ const D = N(i, r);
1152
+ if (u) {
1153
+ const F = u.start, A = u.lineNumber, m = u.start - u.lineStart + 1;
1154
+ return new y({
1155
+ code: i,
1156
+ index: F,
1157
+ line: A,
1158
+ column: m,
1159
+ len: u.end - u.start - 1,
1160
+ data: r,
1161
+ description: D
1162
+ });
1163
+ }
1164
+ const { index: h, line: d } = this.endMarker;
1165
+ return new y({ code: i, index: h, line: d, column: this.endMarker.column + 1, data: r, description: D });
1166
+ }
1167
+ throwUnexpectedToken(e = {}) {
1168
+ throw e.rawToken ??= this.rawToken, this.unexpectedTokenError(e);
1169
+ }
1170
+ collectComments(e) {
1171
+ const { commentHandler: u } = this;
1172
+ !u || !e.length || e.forEach((i) => {
1173
+ const r = {
1174
+ type: i.multiLine ? n.BlockComment : n.LineComment,
1175
+ value: this.getSourceValue(i),
1176
+ range: i.range,
1177
+ loc: i.loc
1178
+ };
1179
+ u.collectComment(r);
1180
+ });
1181
+ }
1182
+ peekAhead(e) {
1183
+ const u = () => (this.scanner.scanComments(), this.scanner.lex()), i = this.scanner.saveState(), r = e.call(this, u);
1184
+ return this.scanner.restoreState(i), r;
1185
+ }
1186
+ getSourceValue(e) {
1187
+ return this.scanner.source.slice(e.start, e.end);
1188
+ }
1189
+ convertToToken(e) {
1190
+ return {
1191
+ type: $[e.type],
1192
+ value: this.getSourceValue(e),
1193
+ range: [e.start, e.end],
1194
+ loc: {
1195
+ start: {
1196
+ line: this.startMarker.line,
1197
+ column: this.startMarker.column
1198
+ },
1199
+ end: {
1200
+ line: this.scanner.lineNumber,
1201
+ column: this.scanner.index - this.scanner.lineStart
1202
+ }
1203
+ }
1204
+ };
1205
+ }
1206
+ readNextRawToken() {
1207
+ this.endMarker.index = this.scanner.index, this.endMarker.line = this.scanner.lineNumber, this.endMarker.column = this.scanner.index - this.scanner.lineStart;
1208
+ const e = this.rawToken;
1209
+ this.collectComments(this.scanner.scanComments()), this.scanner.index !== this.startMarker.index && (this.startMarker.index = this.scanner.index, this.startMarker.line = this.scanner.lineNumber, this.startMarker.column = this.scanner.index - this.scanner.lineStart), this.rawToken = this.scanner.lex(), this.hasLineTerminator = e.lineNumber !== this.rawToken.lineNumber, this.options.tokens && this.rawToken.type !== o.EOF && this.tokens.push(this.convertToToken(this.rawToken));
1210
+ }
1211
+ captureStartMarker() {
1212
+ return {
1213
+ index: this.startMarker.index,
1214
+ line: this.startMarker.line,
1215
+ column: this.startMarker.column
1216
+ };
1217
+ }
1218
+ getItemLocation(e) {
1219
+ return {
1220
+ range: [e.index, this.endMarker.index],
1221
+ loc: {
1222
+ start: {
1223
+ line: e.line,
1224
+ column: e.column
1225
+ },
1226
+ end: {
1227
+ line: this.endMarker.line,
1228
+ column: this.endMarker.column
1229
+ }
1230
+ }
1231
+ };
1232
+ }
1233
+ finalize(e) {
1234
+ return (this.delegate ?? this.commentHandler) && (this.commentHandler?.attachComments(e), this.delegate?.(e)), e;
1235
+ }
1236
+ expectPunctuator(e) {
1237
+ const u = this.rawToken;
1238
+ if (this.matchPunctuator(e)) {
1239
+ this.readNextRawToken();
1240
+ return;
1241
+ }
1242
+ this.throwUnexpectedToken({ rawToken: u, code: a.PunctuatorExpected, data: { value: e } });
1243
+ }
1244
+ expectKeyword(e) {
1245
+ if (this.rawToken.type === o.Keyword && this.rawToken.value.toLowerCase() === e.toString()) {
1246
+ this.readNextRawToken();
1247
+ return;
1248
+ }
1249
+ this.throwUnexpectedToken({ rawToken: this.rawToken });
1250
+ }
1251
+ expectContextualKeyword(e) {
1252
+ if (this.rawToken.type === o.Identifier && this.rawToken.value.toLowerCase() === e) {
1253
+ this.readNextRawToken();
1254
+ return;
1255
+ }
1256
+ this.throwUnexpectedToken({ rawToken: this.rawToken });
1257
+ }
1258
+ matchKeyword(e) {
1259
+ return this.rawToken.type === o.Keyword && this.rawToken.value.toLowerCase() === e;
1260
+ }
1261
+ matchContextualKeyword(e) {
1262
+ return this.rawToken.type === o.Identifier && this.rawToken.value === e;
1263
+ }
1264
+ matchPunctuator(e) {
1265
+ return this.rawToken.type === o.Punctuator && this.rawToken.value === e;
1266
+ }
1267
+ getMatchingPunctuator(e) {
1268
+ if (typeof e == "string" && (e = e.split("")), !(this.rawToken.type !== o.Punctuator || !e.length))
1269
+ return e.find(this.matchPunctuator.bind(this));
1270
+ }
1271
+ // Cover grammar support.
1272
+ //
1273
+ // When an assignment expression position starts with an left parenthesis, the determination of the type
1274
+ // of the syntax is to be deferred arbitrarily long until the end of the parentheses pair (plus a lookahead)
1275
+ // or the first comma. This situation also defers the determination of all the expressions nested in the pair.
1276
+ //
1277
+ // There are two productions that can be parsed in a parentheses pair that needs to be determined
1278
+ // after the outermost pair is closed. They are:
1279
+ //
1280
+ // 1. AssignmentExpression
1281
+ // 2. AssignmentTargets
1282
+ //
1283
+ // In order to avoid exponential backtracking, we use two flags to denote if the production can be
1284
+ // assignment target.
1285
+ //
1286
+ // The two productions have the relationship:
1287
+ //
1288
+ // AssignmentTargets ⊆ AssignmentExpression
1289
+ //
1290
+ // with a single exception that CoverInitializedName when used directly in an Expression, generates
1291
+ // an early error.
1292
+ //
1293
+ // isolateCoverGrammar function runs the given parser function with a new cover grammar context, and it does not
1294
+ // effect the current flags. This means the production the parser parses is only used as an expression. Therefore
1295
+ // the CoverInitializedName check is conducted.
1296
+ //
1297
+ // inheritCoverGrammar function runs the given parse function with a new cover grammar context, and it propagates
1298
+ // the flags outside of the parser. This means the production the parser parses is used as a part of a potential
1299
+ // pattern. The CoverInitializedName check is deferred.
1300
+ isolateCoverGrammar(e) {
1301
+ const u = this.context.isAssignmentTarget;
1302
+ this.context.isAssignmentTarget = !0;
1303
+ const i = e.call(this);
1304
+ return this.context.isAssignmentTarget = u, i;
1305
+ }
1306
+ inheritCoverGrammar(e) {
1307
+ const u = this.context.isAssignmentTarget;
1308
+ this.context.isAssignmentTarget = !0;
1309
+ const i = e.call(this);
1310
+ return this.context.isAssignmentTarget &&= u, i;
1311
+ }
1312
+ withBlockContext(e, u) {
1313
+ const i = this.context.blockContext;
1314
+ this.context.blockContext |= e;
1315
+ const r = this.context.curlyParsingType;
1316
+ this.context.curlyParsingType = v.Automatic;
1317
+ const s = u.call(this);
1318
+ return this.context.blockContext = i, this.context.curlyParsingType = r, s;
1319
+ }
1320
+ consumeSemicolon() {
1321
+ if (this.matchPunctuator(";")) {
1322
+ this.readNextRawToken();
1323
+ return;
1324
+ }
1325
+ if (!this.hasLineTerminator) {
1326
+ if (this.rawToken.type === o.EOF || this.matchPunctuator("}")) {
1327
+ this.endMarker.index = this.startMarker.index, this.endMarker.line = this.startMarker.line, this.endMarker.column = this.startMarker.column;
1328
+ return;
1329
+ }
1330
+ this.throwUnexpectedToken({ rawToken: this.rawToken });
1331
+ }
1332
+ }
1333
+ parsePrimaryExpression() {
1334
+ const e = this.captureStartMarker(), u = this.rawToken;
1335
+ switch (u.type) {
1336
+ case o.Identifier:
1337
+ return this.readNextRawToken(), this.finalize({
1338
+ type: n.Identifier,
1339
+ name: u.value,
1340
+ ...this.getItemLocation(e)
1341
+ });
1342
+ case o.NumericLiteral:
1343
+ case o.StringLiteral:
1344
+ return this.context.isAssignmentTarget = !1, this.readNextRawToken(), this.finalize({
1345
+ type: n.Literal,
1346
+ value: u.value,
1347
+ raw: this.getSourceValue(u),
1348
+ isString: typeof u.value == "string",
1349
+ ...this.getItemLocation(e)
1350
+ });
1351
+ case o.BooleanLiteral:
1352
+ return this.context.isAssignmentTarget = !1, this.readNextRawToken(), this.finalize({
1353
+ type: n.Literal,
1354
+ value: u.value.toLowerCase() === w.True,
1355
+ raw: this.getSourceValue(u),
1356
+ isString: !1,
1357
+ ...this.getItemLocation(e)
1358
+ });
1359
+ case o.NullLiteral:
1360
+ return this.context.isAssignmentTarget = !1, this.readNextRawToken(), this.finalize({
1361
+ type: n.Literal,
1362
+ value: null,
1363
+ raw: this.getSourceValue(u),
1364
+ isString: !1,
1365
+ ...this.getItemLocation(e)
1366
+ });
1367
+ case o.Template:
1368
+ return this.parseTemplateLiteral();
1369
+ case o.Punctuator:
1370
+ switch (u.value) {
1371
+ case "(":
1372
+ return this.inheritCoverGrammar(this.parseGroupExpression.bind(this));
1373
+ case "[":
1374
+ return this.inheritCoverGrammar(this.parseArrayInitializer.bind(this));
1375
+ case "{":
1376
+ return this.inheritCoverGrammar(this.parseObjectExpression.bind(this));
1377
+ default:
1378
+ return this.throwUnexpectedToken({ rawToken: this.rawToken });
1379
+ }
1380
+ case o.Keyword:
1381
+ return this.context.isAssignmentTarget = !1, this.throwUnexpectedToken({ rawToken: this.rawToken });
1382
+ default:
1383
+ return this.throwUnexpectedToken({ rawToken: this.rawToken });
1384
+ }
1385
+ }
1386
+ parseArrayInitializer() {
1387
+ const e = this.captureStartMarker();
1388
+ this.expectPunctuator("[");
1389
+ const u = [];
1390
+ for (; !this.matchPunctuator("]"); ) {
1391
+ const i = this.captureStartMarker();
1392
+ this.matchPunctuator(",") ? (this.readNextRawToken(), this.throwError(a.InvalidExpression, i)) : (u.push(this.inheritCoverGrammar(this.parseAssignmentExpression.bind(this))), this.matchPunctuator("]") || this.expectPunctuator(","));
1393
+ }
1394
+ return this.expectPunctuator("]"), this.finalize({ type: n.ArrayExpression, elements: u, ...this.getItemLocation(e) });
1395
+ }
1396
+ parseObjectPropertyKey() {
1397
+ const e = this.captureStartMarker(), u = this.rawToken;
1398
+ switch (u.type) {
1399
+ case o.StringLiteral:
1400
+ return this.readNextRawToken(), this.finalize({
1401
+ type: n.Literal,
1402
+ value: u.value,
1403
+ raw: this.getSourceValue(u),
1404
+ isString: !0,
1405
+ ...this.getItemLocation(e)
1406
+ });
1407
+ case o.Identifier:
1408
+ case o.BooleanLiteral:
1409
+ case o.NullLiteral:
1410
+ case o.Keyword:
1411
+ return this.readNextRawToken(), this.finalize({
1412
+ type: n.Identifier,
1413
+ name: u.value,
1414
+ ...this.getItemLocation(e)
1415
+ });
1416
+ default:
1417
+ this.throwError(a.KeyMustBeString, e);
1418
+ }
1419
+ }
1420
+ parseObjectProperty() {
1421
+ const e = this.rawToken, u = this.captureStartMarker(), i = this.parseObjectPropertyKey();
1422
+ let r = !1, s = null;
1423
+ return this.matchPunctuator(":") ? (this.readNextRawToken(), s = this.inheritCoverGrammar(this.parseAssignmentExpression.bind(this))) : e.type === o.Identifier ? (r = !0, s = this.finalize({
1424
+ type: n.Identifier,
1425
+ name: e.value,
1426
+ ...this.getItemLocation(u)
1427
+ })) : this.throwUnexpectedToken({ rawToken: this.rawToken }), this.finalize({
1428
+ type: n.Property,
1429
+ kind: "init",
1430
+ key: i,
1431
+ value: s,
1432
+ shorthand: r,
1433
+ ...this.getItemLocation(u)
1434
+ });
1435
+ }
1436
+ parseObjectExpression() {
1437
+ const e = this.captureStartMarker();
1438
+ this.expectPunctuator("{");
1439
+ const u = [];
1440
+ for (; !this.matchPunctuator("}"); )
1441
+ u.push(this.parseObjectProperty()), this.matchPunctuator("}") || this.expectPunctuator(",");
1442
+ return this.expectPunctuator("}"), this.finalize({ type: n.ObjectExpression, properties: u, ...this.getItemLocation(e) });
1443
+ }
1444
+ parseTemplateElement(e = !1) {
1445
+ const u = this.rawToken;
1446
+ u.type !== o.Template && this.throwUnexpectedToken({ rawToken: u }), e && !u.head && this.throwUnexpectedToken({ code: a.InvalidTemplateHead, rawToken: u });
1447
+ const i = this.captureStartMarker();
1448
+ this.readNextRawToken();
1449
+ const { value: r, cooked: s, tail: D } = u, h = this.finalize({
1450
+ type: n.TemplateElement,
1451
+ value: { raw: r, cooked: s },
1452
+ tail: D,
1453
+ ...this.getItemLocation(i)
1454
+ });
1455
+ return h.loc.start.column += 1, h.loc.end.column -= D ? 1 : 2, h;
1456
+ }
1457
+ parseTemplateLiteral() {
1458
+ const e = this.captureStartMarker(), u = [], i = [];
1459
+ let r = this.parseTemplateElement(!0);
1460
+ for (i.push(r); !r.tail; )
1461
+ u.push(this.parseExpression()), r = this.parseTemplateElement(), i.push(r);
1462
+ return this.finalize({
1463
+ type: n.TemplateLiteral,
1464
+ quasis: i,
1465
+ expressions: u,
1466
+ ...this.getItemLocation(e)
1467
+ });
1468
+ }
1469
+ parseGroupExpression() {
1470
+ this.expectPunctuator("(");
1471
+ const e = this.inheritCoverGrammar(this.parseAssignmentExpression.bind(this));
1472
+ return this.expectPunctuator(")"), e;
1473
+ }
1474
+ parseArguments() {
1475
+ this.expectPunctuator("(");
1476
+ const e = [];
1477
+ if (!this.matchPunctuator(")"))
1478
+ for (; ; ) {
1479
+ const u = this.isolateCoverGrammar(this.parseAssignmentExpression.bind(this));
1480
+ if (e.push(u), this.matchPunctuator(")") || (this.expectPunctuator(","), this.matchPunctuator(")")))
1481
+ break;
1482
+ }
1483
+ return this.expectPunctuator(")"), e;
1484
+ }
1485
+ parseMemberName() {
1486
+ const e = this.rawToken, u = this.captureStartMarker();
1487
+ return this.readNextRawToken(), e.type !== o.NullLiteral && e.type !== o.Identifier && e.type !== o.Keyword && e.type !== o.BooleanLiteral && this.throwUnexpectedToken({ rawToken: e }), this.finalize({
1488
+ type: n.Identifier,
1489
+ name: e.value,
1490
+ ...this.getItemLocation(u)
1491
+ });
1492
+ }
1493
+ parseLeftHandSideExpression() {
1494
+ const e = this.captureStartMarker();
1495
+ let u = this.inheritCoverGrammar(this.parsePrimaryExpression.bind(this)), i = !1, r;
1496
+ for (; r = this.getMatchingPunctuator(["(", "[", ".", g]); ) {
1497
+ let s = !1;
1498
+ switch (r === g && (i = !0, s = !0, this.expectPunctuator(g), this.getMatchingPunctuator("[") ? r = "[" : r = "."), r) {
1499
+ case "(": {
1500
+ this.context.isAssignmentTarget = !1;
1501
+ const D = this.parseArguments();
1502
+ u = this.finalize({
1503
+ type: n.CallExpression,
1504
+ callee: u,
1505
+ arguments: D,
1506
+ ...this.getItemLocation(e)
1507
+ });
1508
+ continue;
1509
+ }
1510
+ case "[": {
1511
+ this.context.isAssignmentTarget = !s, this.expectPunctuator("[");
1512
+ const D = this.isolateCoverGrammar(() => this.parseExpression());
1513
+ this.expectPunctuator("]"), u = this.finalize({
1514
+ type: s ? n.SafeMemberExpression : n.MemberExpression,
1515
+ computed: !0,
1516
+ object: u,
1517
+ property: D,
1518
+ ...this.getItemLocation(e)
1519
+ });
1520
+ continue;
1521
+ }
1522
+ case ".": {
1523
+ this.context.isAssignmentTarget = !s, s || this.expectPunctuator(".");
1524
+ const D = this.parseMemberName();
1525
+ u = this.finalize({
1526
+ type: s ? n.SafeMemberExpression : n.MemberExpression,
1527
+ computed: !1,
1528
+ object: u,
1529
+ property: D,
1530
+ ...this.getItemLocation(e)
1531
+ });
1532
+ continue;
1533
+ }
1534
+ }
1535
+ }
1536
+ return i ? this.finalize({
1537
+ type: n.MemberAccessChainExpression,
1538
+ expression: u,
1539
+ ...this.getItemLocation(e)
1540
+ }) : u;
1541
+ }
1542
+ parseUpdateExpression() {
1543
+ const e = this.captureStartMarker();
1544
+ let u = this.getMatchingPunctuator(M);
1545
+ if (u) {
1546
+ this.readNextRawToken();
1547
+ const D = this.captureStartMarker(), h = this.inheritCoverGrammar(this.parseUnaryExpression.bind(this));
1548
+ return h.type !== n.Identifier && h.type !== n.MemberExpression && h.type !== n.CallExpression && this.throwError(a.InvalidExpression, D), this.context.isAssignmentTarget || this.tolerateError(a.InvalidLeftHandSideInAssignment, e), this.context.isAssignmentTarget = !1, this.finalize({
1549
+ type: n.UpdateExpression,
1550
+ operator: u,
1551
+ argument: h,
1552
+ prefix: !0,
1553
+ ...this.getItemLocation(e)
1554
+ });
1555
+ }
1556
+ const i = this.captureStartMarker(), r = this.inheritCoverGrammar(this.parseLeftHandSideExpression.bind(this)), s = this.captureStartMarker();
1557
+ return this.hasLineTerminator || (u = this.getMatchingPunctuator(M), !u) ? r : (r.type !== n.Identifier && r.type !== n.MemberExpression && this.throwError(a.InvalidExpression, i, s), this.context.isAssignmentTarget || this.tolerateError(a.InvalidLeftHandSideInAssignment, e), this.readNextRawToken(), this.context.isAssignmentTarget = !1, this.finalize({
1558
+ type: n.UpdateExpression,
1559
+ operator: u,
1560
+ argument: r,
1561
+ prefix: !1,
1562
+ ...this.getItemLocation(e)
1563
+ }));
1564
+ }
1565
+ parseUnaryExpression() {
1566
+ const e = this.getMatchingPunctuator(G);
1567
+ if (e) {
1568
+ const u = this.captureStartMarker();
1569
+ this.readNextRawToken();
1570
+ const i = this.inheritCoverGrammar(this.parseUnaryExpression.bind(this));
1571
+ return this.context.isAssignmentTarget = !1, this.finalize({
1572
+ type: n.UnaryExpression,
1573
+ operator: e,
1574
+ argument: i,
1575
+ prefix: !0,
1576
+ ...this.getItemLocation(u)
1577
+ });
1578
+ }
1579
+ return this.parseUpdateExpression();
1580
+ }
1581
+ parseBinaryExpression() {
1582
+ const e = this.rawToken;
1583
+ let u = this.inheritCoverGrammar(this.parseUnaryExpression.bind(this));
1584
+ if (this.rawToken.type !== o.Punctuator)
1585
+ return u;
1586
+ const i = this.rawToken.value;
1587
+ let r = _(i);
1588
+ if (r === 0)
1589
+ return u;
1590
+ this.readNextRawToken(), this.context.isAssignmentTarget = !1;
1591
+ const s = [e, this.rawToken];
1592
+ let D = u, h = this.inheritCoverGrammar(
1593
+ this.parseUnaryExpression.bind(this)
1594
+ );
1595
+ const d = [D, i, h], F = [r];
1596
+ for (; this.rawToken.type === o.Punctuator && (r = _(this.rawToken.value)) > 0; ) {
1597
+ for (; d.length > 2 && r <= F[F.length - 1]; ) {
1598
+ h = d.pop();
1599
+ const f = d.pop();
1600
+ F.pop(), D = d.pop(), s.pop();
1601
+ const S = s[s.length - 1], b = K(S, S.lineStart);
1602
+ d.push(this.finalize(this.createBinaryOrLogicalExpression(b, f, D, h)));
1603
+ }
1604
+ d.push(this.rawToken.value), F.push(r), s.push(this.rawToken), this.readNextRawToken(), d.push(this.inheritCoverGrammar(this.parseUnaryExpression.bind(this)));
1605
+ }
1606
+ let A = d.length - 1;
1607
+ u = d[A];
1608
+ let m = s.pop();
1609
+ for (; A > 1; ) {
1610
+ const f = s.pop();
1611
+ if (!f)
1612
+ break;
1613
+ const S = m?.lineStart, b = K(f, S), Y = d[A - 1];
1614
+ u = this.finalize(
1615
+ this.createBinaryOrLogicalExpression(b, Y, d[A - 2], u)
1616
+ ), A -= 2, m = f;
1617
+ }
1618
+ return u;
1619
+ }
1620
+ createBinaryOrLogicalExpression(e, u, i, r) {
1621
+ return q.includes(u) ? ((i.type === n.AssignmentExpression || i.type === n.UpdateExpression) && this.throwError(a.InvalidExpression, ...V(i)), (r.type === n.AssignmentExpression || r.type === n.UpdateExpression) && this.throwError(a.InvalidExpression, ...V(i)), {
1622
+ type: n.LogicalExpression,
1623
+ operator: u,
1624
+ left: i,
1625
+ right: r,
1626
+ ...this.getItemLocation(e)
1627
+ }) : {
1628
+ type: n.BinaryExpression,
1629
+ operator: u,
1630
+ left: i,
1631
+ right: r,
1632
+ ...this.getItemLocation(e)
1633
+ };
1634
+ }
1635
+ parseAssignmentExpression() {
1636
+ const e = this.captureStartMarker(), u = this.inheritCoverGrammar(this.parseBinaryExpression.bind(this)), i = this.captureStartMarker(), r = this.getMatchingPunctuator(W);
1637
+ if (!r)
1638
+ return u;
1639
+ u.type !== n.Identifier && u.type !== n.MemberExpression && this.throwError(a.InvalidExpression, e, i), this.context.isAssignmentTarget || this.tolerateError(a.InvalidLeftHandSideInAssignment, e), this.matchPunctuator("=") || (this.context.isAssignmentTarget = !1), this.readNextRawToken();
1640
+ const s = this.isolateCoverGrammar(this.parseAssignmentExpression.bind(this));
1641
+ return this.finalize({
1642
+ type: n.AssignmentExpression,
1643
+ left: u,
1644
+ operator: r,
1645
+ right: s,
1646
+ ...this.getItemLocation(e)
1647
+ });
1648
+ }
1649
+ parseExpression() {
1650
+ return this.isolateCoverGrammar(this.parseAssignmentExpression.bind(this));
1651
+ }
1652
+ parseStatements(e) {
1653
+ const u = [];
1654
+ for (; this.rawToken.type !== o.EOF && !this.matchPunctuator(e); ) {
1655
+ const i = this.parseStatementListItem();
1656
+ re(i) || u.push(i);
1657
+ }
1658
+ return u;
1659
+ }
1660
+ parseStatementListItem() {
1661
+ return this.context.isAssignmentTarget = !0, this.matchKeyword(l.Function) ? this.parseFunctionDeclaration() : this.matchKeyword(l.Export) ? this.parseExportDeclaration() : this.matchKeyword(l.Import) ? this.parseImportDeclaration() : this.parseStatement();
1662
+ }
1663
+ parseBlock() {
1664
+ const e = this.captureStartMarker();
1665
+ this.expectPunctuator("{");
1666
+ const u = this.parseStatements("}");
1667
+ return this.expectPunctuator("}"), this.finalize({ type: n.BlockStatement, body: u, ...this.getItemLocation(e) });
1668
+ }
1669
+ parseObjectStatement() {
1670
+ const e = this.captureStartMarker(), u = this.parseObjectExpression();
1671
+ return this.finalize({
1672
+ type: n.ExpressionStatement,
1673
+ expression: u,
1674
+ ...this.getItemLocation(e)
1675
+ });
1676
+ }
1677
+ parseBlockOrObjectStatement() {
1678
+ return this.context.curlyParsingType === v.AsObject ? this.parseObjectStatement() : this.peekAhead((u) => {
1679
+ let i = u();
1680
+ return !(i.type !== o.Identifier && i.type !== o.StringLiteral || (i = u(), i.type !== o.Punctuator || i.value !== ":"));
1681
+ }) ? this.parseObjectStatement() : this.parseBlock();
1682
+ }
1683
+ parseIdentifier() {
1684
+ const e = this.rawToken;
1685
+ if (e.type !== o.Identifier)
1686
+ return null;
1687
+ const u = this.captureStartMarker();
1688
+ return this.readNextRawToken(), this.finalize({
1689
+ type: n.Identifier,
1690
+ name: e.value,
1691
+ ...this.getItemLocation(u)
1692
+ });
1693
+ }
1694
+ parseVariableDeclarator() {
1695
+ const e = this.captureStartMarker(), u = this.parseIdentifier();
1696
+ u || this.throwUnexpectedToken({ code: a.IdentifierExpected });
1697
+ let i = null;
1698
+ if (this.matchPunctuator("=")) {
1699
+ this.readNextRawToken();
1700
+ const r = this.rawToken;
1701
+ try {
1702
+ i = this.isolateCoverGrammar(this.parseAssignmentExpression.bind(this));
1703
+ } catch {
1704
+ this.throwUnexpectedToken({ rawToken: r, code: a.InvalidVariableAssignment });
1705
+ }
1706
+ }
1707
+ return this.finalize({ type: n.VariableDeclarator, id: u, init: i, ...this.getItemLocation(e) });
1708
+ }
1709
+ parseVariableDeclarators() {
1710
+ const e = [this.parseVariableDeclarator()];
1711
+ for (; this.matchPunctuator(","); )
1712
+ this.readNextRawToken(), e.push(this.parseVariableDeclarator());
1713
+ return e;
1714
+ }
1715
+ parseVariableDeclaration() {
1716
+ const e = this.captureStartMarker();
1717
+ this.expectKeyword(l.Var);
1718
+ const u = this.parseVariableDeclarators();
1719
+ return this.consumeSemicolon(), this.finalize({
1720
+ type: n.VariableDeclaration,
1721
+ declarations: u,
1722
+ kind: "var",
1723
+ ...this.getItemLocation(e)
1724
+ });
1725
+ }
1726
+ parseEmptyStatement() {
1727
+ const e = this.captureStartMarker();
1728
+ return this.expectPunctuator(";"), this.finalize({ type: n.EmptyStatement, ...this.getItemLocation(e) });
1729
+ }
1730
+ parseExpressionStatement() {
1731
+ const e = this.captureStartMarker(), u = this.parseExpression();
1732
+ return this.consumeSemicolon(), this.finalize({
1733
+ type: n.ExpressionStatement,
1734
+ expression: u,
1735
+ ...this.getItemLocation(e)
1736
+ });
1737
+ }
1738
+ parseIfClause() {
1739
+ return this.withBlockContext(E.IfClause, this.parseStatement.bind(this));
1740
+ }
1741
+ parseIfStatement() {
1742
+ const e = this.captureStartMarker();
1743
+ this.expectKeyword(l.If), this.expectPunctuator("(");
1744
+ const u = this.captureStartMarker(), i = this.parseExpression(), r = this.captureStartMarker();
1745
+ this.expectPunctuator(")"), (i.type === n.AssignmentExpression || i.type === n.UpdateExpression) && this.throwError(a.InvalidExpression, u, r);
1746
+ const s = this.parseIfClause();
1747
+ let D = null;
1748
+ return this.matchKeyword(l.Else) && (this.readNextRawToken(), D = this.parseIfClause()), this.finalize({
1749
+ type: n.IfStatement,
1750
+ test: i,
1751
+ consequent: s,
1752
+ alternate: D,
1753
+ ...this.getItemLocation(e)
1754
+ });
1755
+ }
1756
+ parseWhileStatement() {
1757
+ const e = this.captureStartMarker();
1758
+ this.expectKeyword(l.While), this.expectPunctuator("(");
1759
+ const u = this.captureStartMarker(), i = this.parseExpression(), r = this.captureStartMarker();
1760
+ this.expectPunctuator(")"), (i.type === n.AssignmentExpression || i.type === n.UpdateExpression) && this.throwError(a.InvalidExpression, u, r);
1761
+ const s = this.withBlockContext(E.WhileLoop, this.parseStatement.bind(this));
1762
+ return this.finalize({
1763
+ type: n.WhileStatement,
1764
+ test: i,
1765
+ body: s,
1766
+ ...this.getItemLocation(e)
1767
+ });
1768
+ }
1769
+ parseForStatement() {
1770
+ let e = n.ForStatement, u = null, i = null, r = null, s = null, D = null;
1771
+ const h = this.captureStartMarker();
1772
+ if (this.expectKeyword(l.For), this.expectPunctuator("("), this.matchKeyword(l.Var)) {
1773
+ const F = this.captureStartMarker();
1774
+ this.readNextRawToken();
1775
+ const A = this.parseVariableDeclarators();
1776
+ u = this.finalize({
1777
+ type: n.VariableDeclaration,
1778
+ declarations: A,
1779
+ kind: "var",
1780
+ ...this.getItemLocation(F)
1781
+ });
1782
+ const m = this.matchKeyword(l.In), f = this.matchContextualKeyword(T.Of);
1783
+ A.length === 1 && (m || f) && (A[0].init && this.throwError(a.ForInOfLoopInitializer, F), e = m ? n.ForInStatement : n.ForOfStatement, s = u);
1784
+ } else if (!this.matchPunctuator(";")) {
1785
+ const F = this.context.isAssignmentTarget, A = this.captureStartMarker();
1786
+ u = this.inheritCoverGrammar(this.parseAssignmentExpression.bind(this));
1787
+ const m = this.matchKeyword(l.In), f = this.matchContextualKeyword(T.Of);
1788
+ m || f ? (this.context.isAssignmentTarget || this.tolerateError(a.InvalidLeftHandSideInForIn, A), u.type !== n.Identifier && this.throwError(a.InvalidLeftHandSideInForIn, A), e = m ? n.ForInStatement : n.ForOfStatement, s = u) : this.context.isAssignmentTarget = F;
1789
+ }
1790
+ e === n.ForStatement ? (this.expectPunctuator(";"), i = this.matchPunctuator(";") ? null : this.isolateCoverGrammar(this.parseExpression.bind(this)), this.expectPunctuator(";"), r = this.matchPunctuator(")") ? null : this.isolateCoverGrammar(this.parseExpression.bind(this))) : (this.readNextRawToken(), D = this.parseExpression()), this.expectPunctuator(")");
1791
+ const d = this.withBlockContext(
1792
+ e === n.ForOfStatement ? E.ForOfLoop : E.ForLoop,
1793
+ () => this.isolateCoverGrammar(this.parseStatement.bind(this))
1794
+ );
1795
+ return e === n.ForInStatement || e === n.ForOfStatement ? this.finalize({
1796
+ type: e,
1797
+ left: s,
1798
+ right: D,
1799
+ body: d,
1800
+ ...this.getItemLocation(h)
1801
+ }) : this.finalize({
1802
+ type: e,
1803
+ init: u,
1804
+ test: i,
1805
+ update: r,
1806
+ body: d,
1807
+ ...this.getItemLocation(h)
1808
+ });
1809
+ }
1810
+ parseContinueStatement() {
1811
+ const e = this.captureStartMarker();
1812
+ return this.expectKeyword(l.Continue), this.consumeSemicolon(), this.finalize({ type: n.ContinueStatement, ...this.getItemLocation(e) });
1813
+ }
1814
+ parseBreakStatement() {
1815
+ const e = this.captureStartMarker();
1816
+ return this.expectKeyword(l.Break), this.consumeSemicolon(), this.finalize({ type: n.BreakStatement, ...this.getItemLocation(e) });
1817
+ }
1818
+ parseReturnStatement() {
1819
+ const e = this.captureStartMarker();
1820
+ this.expectKeyword(l.Return);
1821
+ const i = !this.matchPunctuator(";") && !this.matchPunctuator("}") && !this.hasLineTerminator && this.rawToken.type !== o.EOF || this.rawToken.type === o.StringLiteral || this.rawToken.type === o.Template ? this.parseExpression() : null;
1822
+ return this.consumeSemicolon(), this.finalize({ type: n.ReturnStatement, argument: i, ...this.getItemLocation(e) });
1823
+ }
1824
+ parseStatement() {
1825
+ switch (this.rawToken.type) {
1826
+ case o.BooleanLiteral:
1827
+ case o.NullLiteral:
1828
+ case o.NumericLiteral:
1829
+ case o.StringLiteral:
1830
+ case o.Template:
1831
+ case o.Identifier:
1832
+ return this.parseExpressionStatement();
1833
+ case o.Punctuator:
1834
+ return this.rawToken.value === "{" ? this.parseBlockOrObjectStatement() : this.rawToken.value === "(" ? this.parseExpressionStatement() : this.rawToken.value === ";" ? this.parseEmptyStatement() : this.parseExpressionStatement();
1835
+ case o.Keyword:
1836
+ switch (this.rawToken.value.toLowerCase()) {
1837
+ case l.Break:
1838
+ return this.parseBreakStatement();
1839
+ case l.Continue:
1840
+ return this.parseContinueStatement();
1841
+ case l.For:
1842
+ return this.parseForStatement();
1843
+ case l.Function:
1844
+ return this.parseFunctionDeclaration();
1845
+ case l.If:
1846
+ return this.parseIfStatement();
1847
+ case l.Return:
1848
+ return this.parseReturnStatement();
1849
+ case l.Var:
1850
+ return this.parseVariableDeclaration();
1851
+ case l.While:
1852
+ return this.parseWhileStatement();
1853
+ default:
1854
+ return this.parseExpressionStatement();
1855
+ }
1856
+ default:
1857
+ return this.throwUnexpectedToken({ rawToken: this.rawToken });
1858
+ }
1859
+ }
1860
+ parseFormalParameters() {
1861
+ const e = [];
1862
+ if (this.expectPunctuator("("), !this.matchPunctuator(")"))
1863
+ for (; this.rawToken.type !== o.EOF; ) {
1864
+ const u = this.parseIdentifier();
1865
+ if (u || this.throwUnexpectedToken({ rawToken: this.rawToken, code: a.IdentifierExpected }), e.push(u), this.matchPunctuator(")") || (this.expectPunctuator(","), this.matchPunctuator(")")))
1866
+ break;
1867
+ }
1868
+ return this.expectPunctuator(")"), e;
1869
+ }
1870
+ parseFunctionDeclaration() {
1871
+ (this.context.blockContext & E.Function) === E.Function && this.throwUnexpectedToken({ code: a.NoFunctionInsideFunction }), ((this.context.blockContext & E.WhileLoop) === E.WhileLoop || (this.context.blockContext & E.ForOfLoop) === E.ForOfLoop || (this.context.blockContext & E.IfClause) === E.IfClause) && this.throwUnexpectedToken({ code: a.NoFunctionInsideBlock });
1872
+ const e = this.captureStartMarker();
1873
+ this.expectKeyword(l.Function);
1874
+ const u = this.parseIdentifier();
1875
+ u || this.throwUnexpectedToken({ code: a.InvalidFunctionIdentifier });
1876
+ const i = this.parseFormalParameters(), r = this.context.blockContext;
1877
+ this.context.blockContext |= E.Function;
1878
+ const s = this.parseBlock();
1879
+ return this.context.blockContext = r, this.finalize({
1880
+ type: n.FunctionDeclaration,
1881
+ id: u,
1882
+ params: i,
1883
+ body: s,
1884
+ ...this.getItemLocation(e)
1885
+ });
1886
+ }
1887
+ parseScript() {
1888
+ const e = this.captureStartMarker(), u = this.parseStatements(), i = this.finalize({
1889
+ type: n.Program,
1890
+ body: u,
1891
+ ...this.getItemLocation(e)
1892
+ });
1893
+ return this.options.tokens && (i.tokens = this.tokens), this.options.tolerant && (i.errors = this.errorHandler.errors), i;
1894
+ }
1895
+ parseExportDeclaration() {
1896
+ this.context.blockContext !== E.None && this.throwUnexpectedToken({ code: a.ModuleExportRootOnly });
1897
+ let e = null;
1898
+ const u = this.captureStartMarker();
1899
+ return this.expectKeyword(l.Export), this.matchKeyword(l.Var) ? e = this.parseVariableDeclaration() : this.matchKeyword("function") ? e = this.parseFunctionDeclaration() : this.throwUnexpectedToken({ code: a.InvalidExpression }), this.finalize({
1900
+ type: n.ExportNamedDeclaration,
1901
+ declaration: e,
1902
+ specifiers: [],
1903
+ source: null,
1904
+ ...this.getItemLocation(u)
1905
+ });
1906
+ }
1907
+ // The module specified part of a import XX from 'MODULESPECIFIER'
1908
+ parseModuleSpecifier() {
1909
+ const e = this.captureStartMarker(), u = this.rawToken;
1910
+ if (u.type === o.StringLiteral)
1911
+ return this.readNextRawToken(), this.finalize({
1912
+ type: n.Literal,
1913
+ value: u.value,
1914
+ raw: this.getSourceValue(u),
1915
+ isString: !0,
1916
+ ...this.getItemLocation(e)
1917
+ });
1918
+ this.throwError(a.InvalidModuleUri, e);
1919
+ }
1920
+ parseDefaultSpecifier() {
1921
+ const e = this.captureStartMarker(), u = this.parseIdentifier();
1922
+ return u || this.throwUnexpectedToken({ code: a.IdentifierExpected }), this.finalize({
1923
+ type: n.ImportDefaultSpecifier,
1924
+ local: u,
1925
+ ...this.getItemLocation(e)
1926
+ });
1927
+ }
1928
+ parseImportDeclaration() {
1929
+ this.context.blockContext !== E.None && this.throwUnexpectedToken({ code: a.ModuleImportRootOnly });
1930
+ const e = this.captureStartMarker();
1931
+ this.expectKeyword(l.Import);
1932
+ const u = this.parseDefaultSpecifier();
1933
+ this.expectContextualKeyword(T.From);
1934
+ const i = this.parseModuleSpecifier();
1935
+ return this.finalize({
1936
+ type: n.ImportDeclaration,
1937
+ specifiers: [u],
1938
+ source: i,
1939
+ ...this.getItemLocation(e)
1940
+ });
1941
+ }
1942
+ }
1943
+ class ce {
1944
+ constructor(e, u) {
1945
+ this.errorHandler = new J(), this.errorHandler.tolerant = u ? typeof u.tolerant == "boolean" && u.tolerant : !1, this.scanner = new X(e, this.errorHandler), this.trackComments = u ? typeof u.comment == "boolean" && u.comment : !1, this.buffer = [];
1946
+ }
1947
+ errors() {
1948
+ return this.errorHandler.errors;
1949
+ }
1950
+ /**
1951
+ * Used by the exposed method 'tokenize'
1952
+ */
1953
+ getNextToken() {
1954
+ if (this.buffer.length === 0) {
1955
+ const e = this.scanner.scanComments();
1956
+ if (this.trackComments && e.forEach((u) => {
1957
+ const i = this.scanner.source.slice(u.start, u.end), r = {
1958
+ type: u.multiLine ? n.BlockComment : n.LineComment,
1959
+ value: i,
1960
+ range: u.range,
1961
+ loc: u.loc
1962
+ };
1963
+ this.buffer.push(r);
1964
+ }), !this.scanner.eof()) {
1965
+ const u = {
1966
+ line: this.scanner.lineNumber,
1967
+ column: this.scanner.index - this.scanner.lineStart
1968
+ }, i = this.scanner.lex(), r = {
1969
+ line: this.scanner.lineNumber,
1970
+ column: this.scanner.index - this.scanner.lineStart
1971
+ }, s = {
1972
+ type: $[i.type],
1973
+ value: this.scanner.source.slice(i.start, i.end),
1974
+ range: [i.start, i.end],
1975
+ loc: { start: u, end: r }
1976
+ };
1977
+ this.buffer.push(s);
1978
+ }
1979
+ }
1980
+ return this.buffer.shift();
1981
+ }
1982
+ }
1983
+ function he(t) {
1984
+ return {
1985
+ type: "Program",
1986
+ body: t.body.map((e) => x(e)),
1987
+ comments: t.comments?.map((e) => U(e))
1988
+ };
1989
+ }
1990
+ function Q(t) {
1991
+ return {
1992
+ loc: {
1993
+ start: {
1994
+ line: t.loc.start.line,
1995
+ column: t.loc.start.column
1996
+ },
1997
+ end: {
1998
+ line: t.loc.end.line,
1999
+ column: t.loc.end.column
2000
+ }
2001
+ },
2002
+ range: [t.range[0], t.range[1]]
2003
+ };
2004
+ }
2005
+ function C(t) {
2006
+ return {
2007
+ leadingComments: t.leadingComments?.map((e) => U(e)),
2008
+ trailingComments: t.trailingComments?.map((e) => U(e)),
2009
+ ...Q(t)
2010
+ };
2011
+ }
2012
+ function U(t) {
2013
+ return {
2014
+ type: t.type,
2015
+ value: t.value,
2016
+ ...Q(t)
2017
+ };
2018
+ }
2019
+ function k(t) {
2020
+ if (!t)
2021
+ return null;
2022
+ if (ue(t))
2023
+ return x(t);
2024
+ if (ne(t))
2025
+ return p(t);
2026
+ switch (t.type) {
2027
+ case "Program":
2028
+ return he(t);
2029
+ case "ImportDefaultSpecifier":
2030
+ return {
2031
+ type: "ImportSpecifier",
2032
+ local: p(t.local),
2033
+ ...C(t)
2034
+ };
2035
+ case "Property":
2036
+ return {
2037
+ type: "Property",
2038
+ key: p(t.key),
2039
+ value: p(t.value),
2040
+ shorthand: t.shorthand,
2041
+ ...C(t)
2042
+ };
2043
+ case "TemplateElement":
2044
+ return {
2045
+ type: "TemplateElement",
2046
+ value: {
2047
+ raw: t.value.raw,
2048
+ cooked: t.value.cooked
2049
+ },
2050
+ tail: t.tail,
2051
+ ...C(t)
2052
+ };
2053
+ case "VariableDeclarator":
2054
+ return {
2055
+ type: "VariableDeclarator",
2056
+ id: p(t.id),
2057
+ init: p(t.init),
2058
+ ...C(t)
2059
+ };
2060
+ }
2061
+ }
2062
+ function x(t) {
2063
+ if (!t)
2064
+ return null;
2065
+ switch (t.type) {
2066
+ case "BlockStatement":
2067
+ return {
2068
+ type: "BlockStatement",
2069
+ body: t.body.map((e) => x(e)),
2070
+ ...C(t)
2071
+ };
2072
+ case "BreakStatement":
2073
+ return {
2074
+ type: "BreakStatement",
2075
+ ...C(t)
2076
+ };
2077
+ case "ContinueStatement":
2078
+ return {
2079
+ type: "ContinueStatement",
2080
+ ...C(t)
2081
+ };
2082
+ case "EmptyStatement":
2083
+ return {
2084
+ type: "EmptyStatement",
2085
+ ...C(t)
2086
+ };
2087
+ case "ExportNamedDeclaration":
2088
+ return {
2089
+ type: "ExportNamedDeclaration",
2090
+ declaration: x(t.declaration),
2091
+ specifiers: t.specifiers.map((e) => ({
2092
+ type: "ExportSpecifier",
2093
+ exported: p(e.exported),
2094
+ local: p(e.local)
2095
+ })),
2096
+ source: p(t.source),
2097
+ ...C(t)
2098
+ };
2099
+ case "ExpressionStatement":
2100
+ return {
2101
+ type: "ExpressionStatement",
2102
+ expression: p(t.expression),
2103
+ ...C(t)
2104
+ };
2105
+ case "ForInStatement":
2106
+ case "ForOfStatement":
2107
+ return {
2108
+ type: t.type,
2109
+ left: k(t.left),
2110
+ right: p(t.right),
2111
+ body: x(t.body),
2112
+ ...C(t)
2113
+ };
2114
+ case "ForStatement":
2115
+ return {
2116
+ type: "ForStatement",
2117
+ init: k(t.init),
2118
+ test: p(t.test),
2119
+ update: p(t.update),
2120
+ body: x(t.body),
2121
+ ...C(t)
2122
+ };
2123
+ case "FunctionDeclaration":
2124
+ return {
2125
+ type: "FunctionDeclaration",
2126
+ id: p(t.id),
2127
+ params: t.params.map((e) => p(e)),
2128
+ body: x(t.body),
2129
+ ...C(t)
2130
+ };
2131
+ case "IfStatement":
2132
+ return {
2133
+ type: "IfStatement",
2134
+ test: p(t.test),
2135
+ consequent: x(t.consequent),
2136
+ alternate: x(t.alternate),
2137
+ ...C(t)
2138
+ };
2139
+ case "ImportDeclaration":
2140
+ return {
2141
+ type: "ImportDeclaration",
2142
+ specifiers: t.specifiers.map((e) => k(e)),
2143
+ source: p(t.source),
2144
+ ...C(t)
2145
+ };
2146
+ case "ReturnStatement":
2147
+ return {
2148
+ type: "ReturnStatement",
2149
+ argument: p(t.argument),
2150
+ ...C(t)
2151
+ };
2152
+ case "VariableDeclaration":
2153
+ return {
2154
+ type: "VariableDeclaration",
2155
+ declarations: t.declarations.map((e) => k(e)),
2156
+ ...C(t)
2157
+ };
2158
+ case "WhileStatement":
2159
+ return {
2160
+ type: "WhileStatement",
2161
+ test: p(t.test),
2162
+ body: x(t.body),
2163
+ ...C(t)
2164
+ };
2165
+ }
2166
+ }
2167
+ function p(t) {
2168
+ if (!t)
2169
+ return null;
2170
+ switch (t.type) {
2171
+ case "ArrayExpression":
2172
+ return {
2173
+ type: "ArrayExpression",
2174
+ elements: t.elements.map((e) => e ? p(e) : null),
2175
+ ...C(t)
2176
+ };
2177
+ case "AssignmentExpression":
2178
+ return {
2179
+ type: "AssignmentExpression",
2180
+ operator: t.operator,
2181
+ left: p(t.left),
2182
+ right: p(t.right),
2183
+ ...C(t)
2184
+ };
2185
+ case "BinaryExpression":
2186
+ return {
2187
+ type: "BinaryExpression",
2188
+ operator: t.operator,
2189
+ left: p(t.left),
2190
+ right: p(t.right),
2191
+ ...C(t)
2192
+ };
2193
+ case "CallExpression":
2194
+ return {
2195
+ type: "CallExpression",
2196
+ callee: p(t.callee),
2197
+ arguments: t.arguments.map((e) => p(e)),
2198
+ ...C(t)
2199
+ };
2200
+ case "Identifier":
2201
+ return {
2202
+ type: "Identifier",
2203
+ name: t.name,
2204
+ ...C(t)
2205
+ };
2206
+ case "Literal":
2207
+ return {
2208
+ type: "Literal",
2209
+ isString: t.isString,
2210
+ value: t.value,
2211
+ raw: t.raw,
2212
+ ...C(t)
2213
+ };
2214
+ case "LogicalExpression":
2215
+ return {
2216
+ type: "LogicalExpression",
2217
+ operator: t.operator,
2218
+ left: p(t.left),
2219
+ right: p(t.right),
2220
+ ...C(t)
2221
+ };
2222
+ case "MemberAccessChainExpression":
2223
+ return {
2224
+ type: "MemberAccessChainExpression",
2225
+ expression: p(t.expression),
2226
+ ...C(t)
2227
+ };
2228
+ case "MemberExpression":
2229
+ return {
2230
+ type: "MemberExpression",
2231
+ computed: t.computed,
2232
+ object: p(t.object),
2233
+ property: p(t.property),
2234
+ ...C(t)
2235
+ };
2236
+ case "ObjectExpression":
2237
+ return {
2238
+ type: "ObjectExpression",
2239
+ properties: t.properties.map((e) => k(e)),
2240
+ ...C(t)
2241
+ };
2242
+ case "SafeMemberExpression":
2243
+ return {
2244
+ type: "SafeMemberExpression",
2245
+ computed: t.computed,
2246
+ object: p(t.object),
2247
+ property: p(t.property),
2248
+ ...C(t)
2249
+ };
2250
+ case "TemplateLiteral":
2251
+ return {
2252
+ type: "TemplateLiteral",
2253
+ quasis: t.quasis.map((e) => k(e)),
2254
+ expressions: t.expressions.map((e) => p(e)),
2255
+ ...C(t)
2256
+ };
2257
+ case "UnaryExpression":
2258
+ return {
2259
+ type: "UnaryExpression",
2260
+ operator: t.operator,
2261
+ argument: p(t.argument),
2262
+ ...C(t)
2263
+ };
2264
+ case "UpdateExpression":
2265
+ return {
2266
+ type: "UpdateExpression",
2267
+ operator: t.operator,
2268
+ argument: p(t.argument),
2269
+ prefix: t.prefix,
2270
+ ...C(t)
2271
+ };
2272
+ }
2273
+ }
2274
+ function je(t, e, u) {
2275
+ return new De(t, e, u).parseScript();
2276
+ }
2277
+ function Re(t, e, u) {
2278
+ const i = new ce(t, e), r = [];
2279
+ let s;
2280
+ try {
2281
+ let D;
2282
+ for (; D = i.getNextToken(); )
2283
+ u && (D = u(D)), r.push(D);
2284
+ } catch (D) {
2285
+ D instanceof Error && i.errorHandler.tolerate(D);
2286
+ }
2287
+ return i.errorHandler.tolerant && (s = i.errors()), { tokens: r, errors: s };
2288
+ }
2289
+ export {
2290
+ W as AssignmentOperators,
2291
+ Z as BinaryOperators,
2292
+ T as ContextualKeywords,
2293
+ y as Diagnostic,
2294
+ a as DiagnosticCodes,
2295
+ ee as DiagnosticMessages,
2296
+ l as Keywords,
2297
+ w as Literals,
2298
+ q as LogicalOperators,
2299
+ n as NodeTypes,
2300
+ P as OperatorPrecedence,
2301
+ g as SafeAccessOperator,
2302
+ $ as TokenNames,
2303
+ o as TokenTypes,
2304
+ G as UnaryOperators,
2305
+ M as UpdateOperators,
2306
+ he as convertProgramToJSON,
2307
+ Be as isArrayExpression,
2308
+ ke as isAssignmentExpression,
2309
+ ye as isBinaryExpression,
2310
+ ie as isBlockComment,
2311
+ O as isBlockStatement,
2312
+ le as isBreakStatement,
2313
+ ge as isCallExpression,
2314
+ pe as isContinueStatement,
2315
+ re as isEmptyStatement,
2316
+ ne as isExpression,
2317
+ Ce as isExpressionStatement,
2318
+ de as isForInStatement,
2319
+ Ee as isForOfStatement,
2320
+ Fe as isForStatement,
2321
+ Ae as isFunctionDeclaration,
2322
+ Se as isIdentifier,
2323
+ me as isIfStatement,
2324
+ we as isLiteral,
2325
+ be as isLogicalExpression,
2326
+ Me as isMemberAccessChainExpression,
2327
+ Le as isMemberExpression,
2328
+ Te as isObjectExpression,
2329
+ te as isProgram,
2330
+ Pe as isProperty,
2331
+ xe as isReturnStatement,
2332
+ ve as isSafeMemberExpression,
2333
+ ue as isStatement,
2334
+ Oe as isTemplateElement,
2335
+ Ie as isTemplateLiteral,
2336
+ Ne as isUnaryExpression,
2337
+ Ue as isUpdateExpression,
2338
+ fe as isVariableDeclaration,
2339
+ se as isVariableDeclarator,
2340
+ je as parse,
2341
+ Re as tokenize
2342
+ };