@arcgis/arcade-languageservice 5.2.0-next.11 → 5.2.0-next.111

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 CHANGED
@@ -1,1927 +1,9 @@
1
- import { CompletionItemKind as x, InsertTextFormat as B, InsertTextMode as S, DiagnosticSeverity as A } from "vscode-languageserver-types";
2
- import { DiagnosticSeverity as fi } from "vscode-languageserver-types";
3
- import { isDictionaryVariable as Ge, isValueVariable as Ee, ApiService as Je } from "@arcgis/languages-api-utils";
4
- const V = {
5
- False: "false",
6
- Null: "null",
7
- True: "true"
8
- }, f = {
9
- Break: "break",
10
- Continue: "continue",
11
- Else: "else",
12
- For: "for",
13
- Function: "function",
14
- If: "if",
15
- Import: "import",
16
- Export: "export",
17
- In: "in",
18
- Return: "return",
19
- Var: "var",
20
- While: "while"
21
- }, te = {
22
- From: "from",
23
- Of: "of"
24
- }, u = {
25
- AssignmentExpression: "AssignmentExpression",
26
- ArrayExpression: "ArrayExpression",
27
- BlockComment: "BlockComment",
28
- BlockStatement: "BlockStatement",
29
- BinaryExpression: "BinaryExpression",
30
- BreakStatement: "BreakStatement",
31
- CallExpression: "CallExpression",
32
- ContinueStatement: "ContinueStatement",
33
- EmptyStatement: "EmptyStatement",
34
- ExpressionStatement: "ExpressionStatement",
35
- ExportNamedDeclaration: "ExportNamedDeclaration",
36
- ForStatement: "ForStatement",
37
- ForInStatement: "ForInStatement",
38
- ForOfStatement: "ForOfStatement",
39
- FunctionDeclaration: "FunctionDeclaration",
40
- Identifier: "Identifier",
41
- IfStatement: "IfStatement",
42
- ImportDeclaration: "ImportDeclaration",
43
- ImportDefaultSpecifier: "ImportDefaultSpecifier",
44
- LineComment: "LineComment",
45
- Literal: "Literal",
46
- LogicalExpression: "LogicalExpression",
47
- MemberAccessChainExpression: "MemberAccessChainExpression",
48
- MemberExpression: "MemberExpression",
49
- ObjectExpression: "ObjectExpression",
50
- Program: "Program",
51
- Property: "Property",
52
- ReturnStatement: "ReturnStatement",
53
- SafeMemberExpression: "SafeMemberExpression",
54
- TemplateElement: "TemplateElement",
55
- TemplateLiteral: "TemplateLiteral",
56
- UnaryExpression: "UnaryExpression",
57
- UpdateExpression: "UpdateExpression",
58
- VariableDeclaration: "VariableDeclaration",
59
- VariableDeclarator: "VariableDeclarator",
60
- WhileStatement: "WhileStatement"
61
- }, ue = ["++", "--"], Ne = ["-", "+", "!", "~"], Me = ["=", "/=", "*=", "%=", "+=", "-="], Ue = ["||", "&&"], Qe = [
62
- "|",
63
- "&",
64
- ">>",
65
- "<<",
66
- ">>>",
67
- "^",
68
- "==",
69
- "!=",
70
- "<",
71
- "<=",
72
- ">",
73
- ">=",
74
- "+",
75
- "-",
76
- "*",
77
- "/",
78
- "%"
79
- ], w = "?.", q = {
80
- "||": 1,
81
- "&&": 2,
82
- "|": 3,
83
- "^": 4,
84
- "&": 5,
85
- "==": 6,
86
- "!=": 6,
87
- "<": 7,
88
- ">": 7,
89
- "<=": 7,
90
- ">=": 7,
91
- "<<": 8,
92
- ">>": 8,
93
- ">>>": 8,
94
- "+": 9,
95
- "-": 9,
96
- "*": 10,
97
- "/": 10,
98
- "%": 10
99
- }, l = {
100
- BooleanLiteral: 1,
101
- EOF: 2,
102
- Identifier: 3,
103
- Keyword: 4,
104
- NullLiteral: 5,
105
- NumericLiteral: 6,
106
- Punctuator: 7,
107
- StringLiteral: 8,
108
- Template: 10
109
- }, Oe = [
110
- "Unknown",
111
- "Boolean",
112
- "<end>",
113
- "Identifier",
114
- "Keyword",
115
- "Null",
116
- "Numeric",
117
- "Punctuator",
118
- "String",
119
- "RegularExpression",
120
- "Template"
121
- ], h = {
122
- InvalidModuleUri: "InvalidModuleUri",
123
- ForInOfLoopInitializer: "ForInOfLoopInitializer",
124
- IdentifierExpected: "IdentifierExpected",
125
- InvalidEscapedReservedWord: "InvalidEscapedReservedWord",
126
- InvalidExpression: "InvalidExpression",
127
- InvalidFunctionIdentifier: "InvalidFunctionIdentifier",
128
- InvalidHexEscapeSequence: "InvalidHexEscapeSequence",
129
- InvalidLeftHandSideInAssignment: "InvalidLeftHandSideInAssignment",
130
- InvalidLeftHandSideInForIn: "InvalidLeftHandSideInForIn",
131
- InvalidTemplateHead: "InvalidTemplateHead",
132
- InvalidVariableAssignment: "InvalidVariableAssignment",
133
- KeyMustBeString: "KeyMustBeString",
134
- NoFunctionInsideBlock: "NoFunctionInsideBlock",
135
- NoFunctionInsideFunction: "NoFunctionInsideFunction",
136
- ModuleExportRootOnly: "ModuleExportRootOnly",
137
- ModuleImportRootOnly: "ModuleImportRootOnly",
138
- PunctuatorExpected: "PunctuatorExpected",
139
- TemplateOctalLiteral: "TemplateOctalLiteral",
140
- UnexpectedBoolean: "UnexpectedBoolean",
141
- UnexpectedEndOfScript: "UnexpectedEndOfScript",
142
- UnexpectedIdentifier: "UnexpectedIdentifier",
143
- UnexpectedKeyword: "UnexpectedKeyword",
144
- UnexpectedNull: "UnexpectedNull",
145
- UnexpectedNumber: "UnexpectedNumber",
146
- UnexpectedPunctuator: "UnexpectedPunctuator",
147
- UnexpectedString: "UnexpectedString",
148
- UnexpectedTemplate: "UnexpectedTemplate",
149
- UnexpectedToken: "UnexpectedToken"
150
- }, je = {
151
- [h.InvalidModuleUri]: "Module uri must be a text literal.",
152
- [h.ForInOfLoopInitializer]: "for-in loop variable declaration may not have an initializer.",
153
- [h.IdentifierExpected]: "'${value}' is an invalid identifier.",
154
- [h.InvalidEscapedReservedWord]: "Keyword cannot contain escaped characters.",
155
- [h.InvalidExpression]: "Invalid expression.",
156
- [h.InvalidFunctionIdentifier]: "'${value}' is an invalid function identifier.",
157
- [h.InvalidHexEscapeSequence]: "Invalid hexadecimal escape sequence.",
158
- [h.InvalidLeftHandSideInAssignment]: "Invalid left-hand side in assignment.",
159
- [h.InvalidLeftHandSideInForIn]: "Invalid left-hand side in for-in.",
160
- [h.InvalidTemplateHead]: "Invalid template structure.",
161
- [h.InvalidVariableAssignment]: "Invalid variable assignment.",
162
- [h.KeyMustBeString]: "Object property keys must be a word starting with a letter.",
163
- [h.NoFunctionInsideBlock]: "Functions cannot be declared inside of code blocks.",
164
- [h.NoFunctionInsideFunction]: "Functions cannot be declared inside another function.",
165
- [h.ModuleExportRootOnly]: "Module exports cannot be declared inside of code blocks.",
166
- [h.ModuleImportRootOnly]: "Module import cannot be declared inside of code blocks.",
167
- [h.PunctuatorExpected]: "'${value}' expected.",
168
- [h.TemplateOctalLiteral]: "Octal literals are not allowed in template literals.",
169
- [h.UnexpectedBoolean]: "Unexpected boolean literal.",
170
- [h.UnexpectedEndOfScript]: "Unexpected end of Arcade expression.",
171
- [h.UnexpectedIdentifier]: "Unexpected identifier.",
172
- [h.UnexpectedKeyword]: "Unexpected keyword.",
173
- [h.UnexpectedNull]: "Unexpected null literal.",
174
- [h.UnexpectedNumber]: "Unexpected number.",
175
- [h.UnexpectedPunctuator]: "Unexpected punctuator.",
176
- [h.UnexpectedString]: "Unexpected text literal.",
177
- [h.UnexpectedTemplate]: "Unexpected quasi '${value}'.",
178
- [h.UnexpectedToken]: "Unexpected token '${value}'."
179
- };
180
- class z extends Error {
181
- constructor({ code: e, index: t, line: i, column: r, len: s = 0, description: a, data: o }) {
182
- super(a ?? e), this.declaredRootClass = "esri.arcade.lib.diagnostic", this.name = "ParsingError", this.code = e, this.index = t, this.line = i, this.column = r, this.len = s, this.data = o, this.description = a, this.range = {
183
- start: { line: i, column: r - 1 },
184
- end: { line: i, column: r + s }
185
- }, Error.captureStackTrace?.(
186
- this,
187
- z
188
- );
189
- }
190
- }
191
- function Ze(n) {
192
- return !!n && typeof n == "object" && "type" in n && n.type === u.Program;
193
- }
194
- function b(n) {
195
- return !!n && typeof n == "object" && "type" in n && n.type === u.BlockStatement;
196
- }
197
- function Xe(n) {
198
- return !!n && typeof n == "object" && "type" in n && n.type === u.BlockComment;
199
- }
200
- function pe(n) {
201
- return !!n && typeof n == "object" && "type" in n && n.type === u.EmptyStatement;
202
- }
203
- function Ye(n) {
204
- return !!n && typeof n == "object" && "type" in n && n.type === u.ExpressionStatement;
205
- }
206
- function ge(n) {
207
- return !!n && typeof n == "object" && "type" in n && n.type === u.FunctionDeclaration;
208
- }
209
- function ae(n) {
210
- return !!n && typeof n == "object" && "type" in n && n.type === u.IfStatement;
211
- }
212
- function G(n) {
213
- return !!n && typeof n == "object" && "type" in n && n.type === u.VariableDeclaration;
214
- }
215
- function J(n) {
216
- return !!n && typeof n == "object" && "type" in n && n.type === u.ArrayExpression;
217
- }
218
- function oe(n) {
219
- return !!n && typeof n == "object" && "type" in n && n.type === u.BinaryExpression;
220
- }
221
- function I(n) {
222
- return !!n && typeof n == "object" && "type" in n && n.type === u.Identifier;
223
- }
224
- function ze(n) {
225
- return !!n && typeof n == "object" && "type" in n && n.type === u.Literal;
226
- }
227
- function ce(n) {
228
- return !!n && typeof n == "object" && "type" in n && n.type === u.LogicalExpression;
229
- }
230
- function xe(n) {
231
- return !!n && typeof n == "object" && "type" in n && n.type === u.ObjectExpression;
232
- }
233
- function Fe(n) {
234
- return !!n && typeof n == "object" && "type" in n && n.type === u.MemberExpression;
235
- }
236
- function et(n) {
237
- return !!n && typeof n == "object" && "type" in n && n.type === u.SafeMemberExpression;
238
- }
239
- function tt(n) {
240
- return !!n && typeof n == "object" && "type" in n && n.type === u.MemberAccessChainExpression;
241
- }
242
- function it(n) {
243
- return !!n && typeof n == "object" && "type" in n && n.type === u.UnaryExpression;
244
- }
245
- function nt(n) {
246
- return !!n && typeof n == "object" && "type" in n && n.type === u.UpdateExpression;
247
- }
248
- function Ve(n) {
249
- return !!n && typeof n == "object" && "type" in n && n.type === u.VariableDeclarator;
250
- }
251
- function rt(n) {
252
- return !!n && typeof n == "object" && "type" in n && n.type === u.Property;
253
- }
254
- function ie(n, e) {
255
- return e.loc.end.line === n.loc.start.line && e.loc.end.column <= n.loc.start.column;
256
- }
257
- function Ae(n, e) {
258
- return n.range[0] >= e.range[0] && n.range[1] <= e.range[1];
259
- }
260
- class st {
261
- constructor() {
262
- this.comments = [], this._nodeStack = [], this._newComments = [];
263
- }
264
- insertInnerComments(e) {
265
- if (!b(e) || e.body.length !== 0)
266
- return;
267
- const t = [];
268
- for (let i = this._newComments.length - 1; i >= 0; i--) {
269
- const r = this._newComments[i];
270
- e.range[1] >= r.range[0] && (t.unshift(r), this._newComments.splice(i, 1));
271
- }
272
- t.length && (e.innerComments = t);
273
- }
274
- attachTrailingComments(e) {
275
- const t = this._nodeStack.at(-1);
276
- if (!t)
277
- return;
278
- if (b(e) && Ae(t, e))
279
- for (let r = this._newComments.length - 1; r >= 0; r--) {
280
- const s = this._newComments[r];
281
- Ae(s, e) && (t.trailingComments = [...t.trailingComments ?? [], s], this._newComments.splice(r, 1));
282
- }
283
- let i = [];
284
- if (this._newComments.length > 0)
285
- for (let r = this._newComments.length - 1; r >= 0; r--) {
286
- const s = this._newComments[r];
287
- ie(s, t) ? (t.trailingComments = [...t.trailingComments ?? [], s], this._newComments.splice(r, 1)) : ie(s, e) && (i.unshift(s), this._newComments.splice(r, 1));
288
- }
289
- if (t.trailingComments) {
290
- const r = t.trailingComments[0];
291
- ie(r, e) && (i = [...i, ...t.trailingComments], delete t.trailingComments);
292
- }
293
- i.length > 0 && (e.trailingComments = i);
294
- }
295
- attachLeadingComments(e) {
296
- let t;
297
- for (; this._nodeStack.length > 0; ) {
298
- const s = this._nodeStack[this._nodeStack.length - 1];
299
- if (e.range[0] <= s.range[0]) {
300
- t = s, this._nodeStack.pop();
301
- continue;
302
- }
303
- break;
304
- }
305
- const i = [], r = [];
306
- if (t != null) {
307
- if (!t.leadingComments)
308
- return;
309
- for (let s = t.leadingComments.length - 1; s >= 0; s--) {
310
- const a = t.leadingComments[s];
311
- if (e.range[0] >= a.range[1]) {
312
- i.unshift(a), t.leadingComments.splice(s, 1);
313
- continue;
314
- }
315
- Ve(e) && !Xe(a) && (r.unshift(a), t.leadingComments.splice(s, 1));
316
- }
317
- t.leadingComments.length === 0 && delete t.leadingComments, i.length && (e.leadingComments = i), r.length && (e.trailingComments = [...r, ...e.trailingComments ?? []]);
318
- return;
319
- }
320
- for (let s = this._newComments.length - 1; s >= 0; s--) {
321
- const a = this._newComments[s];
322
- e.range[0] >= a.range[0] && (i.unshift(a), this._newComments.splice(s, 1));
323
- }
324
- i.length && (e.leadingComments = i);
325
- }
326
- attachComments(e) {
327
- if (Ze(e) && e.body.length > 0) {
328
- const t = this._nodeStack.at(-1);
329
- if (t) {
330
- t.trailingComments = [...t.trailingComments ?? [], ...this._newComments], this._newComments.length = 0, this._nodeStack.pop();
331
- return;
332
- }
333
- e.trailingComments = [...this._newComments], this._newComments.length = 0;
334
- return;
335
- }
336
- this.attachTrailingComments(e), this.attachLeadingComments(e), this.insertInnerComments(e), this._nodeStack.push(e);
337
- }
338
- collectComment(e) {
339
- this.comments.push(e), this._newComments.push(e);
340
- }
341
- }
342
- const ut = /\$\{(.*?)\}/gu;
343
- function he(n, e) {
344
- const t = je[n];
345
- return e ? t.replace(ut, (i, r) => e[r]?.toString() ?? "") : t;
346
- }
347
- class _e {
348
- constructor(e = !1) {
349
- this.tolerant = e, this.errors = [];
350
- }
351
- recordError(e) {
352
- this.errors.push(e);
353
- }
354
- tolerate(e) {
355
- if (this.tolerant)
356
- this.recordError(e);
357
- else
358
- throw e;
359
- }
360
- throwError(e) {
361
- throw e.description ??= he(e.code, e.data), new z(e);
362
- }
363
- tolerateError(e) {
364
- e.description ??= he(e.code, e.data);
365
- const t = new z(e);
366
- if (this.tolerant)
367
- this.recordError(t);
368
- else
369
- throw t;
370
- }
371
- }
372
- function ye(n, e) {
373
- if (!n)
374
- throw new Error(`ASSERT: ${e}`);
375
- }
376
- const Be = {
377
- // Unicode v12.1.0 NonAsciiIdentifierStart:
378
- 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,
379
- // Unicode v12.1.0 NonAsciiIdentifierPart:
380
- 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
381
- }, m = {
382
- fromCodePoint(n) {
383
- return n < 65536 ? String.fromCharCode(n) : String.fromCharCode(55296 + (n - 65536 >> 10)) + String.fromCharCode(56320 + (n - 65536 & 1023));
384
- },
385
- // https://tc39.github.io/ecma262/#sec-white-space
386
- isWhiteSpace(n) {
387
- return n === 32 || n === 9 || n === 11 || n === 12 || n === 160 || n >= 5760 && [
388
- 5760,
389
- 8192,
390
- 8193,
391
- 8194,
392
- 8195,
393
- 8196,
394
- 8197,
395
- 8198,
396
- 8199,
397
- 8200,
398
- 8201,
399
- 8202,
400
- 8239,
401
- 8287,
402
- 12288,
403
- 65279
404
- ].includes(n);
405
- },
406
- // https://tc39.github.io/ecma262/#sec-line-terminators
407
- isLineTerminator(n) {
408
- return n === 10 || n === 13 || n === 8232 || n === 8233;
409
- },
410
- // https://tc39.github.io/ecma262/#sec-names-and-keywords
411
- isIdentifierStart(n) {
412
- return n === 36 || n === 95 || // $ (dollar) and _ (underscore)
413
- n >= 65 && n <= 90 || // A..Z
414
- n >= 97 && n <= 122 || // a..z
415
- n === 92 || // \ (backslash)
416
- n >= 128 && Be.NonAsciiIdentifierStart.test(m.fromCodePoint(n));
417
- },
418
- isIdentifierPart(n) {
419
- return n === 36 || n === 95 || // $ (dollar) and _ (underscore)
420
- n >= 65 && n <= 90 || // A..Z
421
- n >= 97 && n <= 122 || // a..z
422
- n >= 48 && n <= 57 || // 0..9
423
- n === 92 || // \ (backslash)
424
- n >= 128 && Be.NonAsciiIdentifierPart.test(m.fromCodePoint(n));
425
- },
426
- // https://tc39.github.io/ecma262/#sec-literals-numeric-literals
427
- isDecimalDigit(n) {
428
- return n >= 48 && n <= 57;
429
- },
430
- isHexDigit(n) {
431
- return n >= 48 && n <= 57 || // 0..9
432
- n >= 65 && n <= 70 || // A..F
433
- n >= 97 && n <= 102;
434
- },
435
- isOctalDigit(n) {
436
- return n >= 48 && n <= 55;
437
- }
438
- };
439
- function Se(n) {
440
- return "0123456789abcdef".indexOf(n.toLowerCase());
441
- }
442
- function ne(n) {
443
- return "01234567".indexOf(n);
444
- }
445
- const N = [[], [], []];
446
- ue.forEach((n) => N[n.length - 1].push(n));
447
- Ne.forEach((n) => N[n.length - 1].push(n));
448
- Ue.forEach((n) => N[n.length - 1].push(n));
449
- Me.forEach((n) => N[n.length - 1].push(n));
450
- Qe.forEach((n) => N[n.length - 1].push(n));
451
- N[w.length - 1].push(w);
452
- class $e {
453
- constructor(e, t) {
454
- this.source = e, this.errorHandler = t, this._length = e.length, this.index = 0, this.lineNumber = 1, this.lineStart = 0, this.curlyStack = [];
455
- }
456
- saveState() {
457
- return {
458
- index: this.index,
459
- lineNumber: this.lineNumber,
460
- lineStart: this.lineStart,
461
- curlyStack: this.curlyStack.slice()
462
- };
463
- }
464
- restoreState(e) {
465
- this.index = e.index, this.lineNumber = e.lineNumber, this.lineStart = e.lineStart, this.curlyStack = e.curlyStack;
466
- }
467
- eof() {
468
- return this.index >= this._length;
469
- }
470
- throwUnexpectedToken(e = h.UnexpectedToken) {
471
- this.errorHandler.throwError({
472
- code: e,
473
- index: this.index,
474
- line: this.lineNumber,
475
- column: this.index - this.lineStart + 1,
476
- data: { value: this.source.charAt(this.index) }
477
- });
478
- }
479
- tolerateUnexpectedToken(e = h.UnexpectedToken) {
480
- this.errorHandler.tolerateError({
481
- code: e,
482
- index: this.index,
483
- line: this.lineNumber,
484
- column: this.index - this.lineStart + 1
485
- });
486
- }
487
- skipSingleLineComment(e) {
488
- const t = [], i = this.index - e, r = {
489
- start: {
490
- line: this.lineNumber,
491
- column: this.index - this.lineStart - e
492
- },
493
- end: { line: 0, column: 0 }
494
- // Fake for now
495
- };
496
- for (; !this.eof(); ) {
497
- const a = this.source.charCodeAt(this.index);
498
- if (this.index += 1, m.isLineTerminator(a)) {
499
- r.end = {
500
- line: this.lineNumber,
501
- column: this.index - this.lineStart - 1
502
- };
503
- const o = {
504
- multiLine: !1,
505
- start: i + e,
506
- end: this.index - 1,
507
- range: [i, this.index - 1],
508
- loc: r
509
- };
510
- return t.push(o), a === 13 && this.source.charCodeAt(this.index) === 10 && (this.index += 1), this.lineNumber += 1, this.lineStart = this.index, t;
511
- }
512
- }
513
- r.end = {
514
- line: this.lineNumber,
515
- column: this.index - this.lineStart
516
- };
517
- const s = {
518
- multiLine: !1,
519
- start: i + e,
520
- end: this.index,
521
- range: [i, this.index],
522
- loc: r
523
- };
524
- return t.push(s), t;
525
- }
526
- skipMultiLineComment() {
527
- const e = [], t = this.index - 2, i = {
528
- start: {
529
- line: this.lineNumber,
530
- column: this.index - this.lineStart - 2
531
- },
532
- end: { line: 0, column: 0 }
533
- // Fake for now
534
- };
535
- for (; !this.eof(); ) {
536
- const s = this.source.charCodeAt(this.index);
537
- if (m.isLineTerminator(s))
538
- s === 13 && this.source.charCodeAt(this.index + 1) === 10 && (this.index += 1), this.lineNumber += 1, this.index += 1, this.lineStart = this.index;
539
- else if (s === 42) {
540
- if (this.source.charCodeAt(this.index + 1) === 47) {
541
- this.index += 2, i.end = {
542
- line: this.lineNumber,
543
- column: this.index - this.lineStart
544
- };
545
- const a = {
546
- multiLine: !0,
547
- start: t + 2,
548
- end: this.index - 2,
549
- range: [t, this.index],
550
- loc: i
551
- };
552
- return e.push(a), e;
553
- }
554
- this.index += 1;
555
- } else
556
- this.index += 1;
557
- }
558
- i.end = {
559
- line: this.lineNumber,
560
- column: this.index - this.lineStart
561
- };
562
- const r = {
563
- multiLine: !0,
564
- start: t + 2,
565
- end: this.index,
566
- range: [t, this.index],
567
- loc: i
568
- };
569
- return e.push(r), this.tolerateUnexpectedToken(), e;
570
- }
571
- scanComments() {
572
- let e = [];
573
- for (; !this.eof(); ) {
574
- let t = this.source.charCodeAt(this.index);
575
- if (m.isWhiteSpace(t))
576
- this.index += 1;
577
- else if (m.isLineTerminator(t))
578
- this.index += 1, t === 13 && this.source.charCodeAt(this.index) === 10 && (this.index += 1), this.lineNumber += 1, this.lineStart = this.index;
579
- else if (t === 47)
580
- if (t = this.source.charCodeAt(this.index + 1), t === 47) {
581
- this.index += 2;
582
- const i = this.skipSingleLineComment(2);
583
- e = [...e, ...i];
584
- } else if (t === 42) {
585
- this.index += 2;
586
- const i = this.skipMultiLineComment();
587
- e = [...e, ...i];
588
- } else
589
- break;
590
- else
591
- break;
592
- }
593
- return e;
594
- }
595
- isKeyword(e) {
596
- switch (e = e.toLowerCase(), e.length) {
597
- case 2:
598
- return e === f.If || e === f.In;
599
- case 3:
600
- return e === f.Var || e === f.For;
601
- case 4:
602
- return e === f.Else;
603
- case 5:
604
- return e === f.Break || e === f.While;
605
- case 6:
606
- return e === f.Return || e === f.Import || e === f.Export;
607
- case 8:
608
- return e === f.Function || e === f.Continue;
609
- default:
610
- return !1;
611
- }
612
- }
613
- codePointAt(e) {
614
- let t = this.source.charCodeAt(e);
615
- if (t >= 55296 && t <= 56319) {
616
- const i = this.source.charCodeAt(e + 1);
617
- i >= 56320 && i <= 57343 && (t = (t - 55296) * 1024 + i - 56320 + 65536);
618
- }
619
- return t;
620
- }
621
- scanHexEscape(e) {
622
- const t = e === "u" ? 4 : 2;
623
- let i = 0;
624
- for (let r = 0; r < t; r++)
625
- if (!this.eof() && m.isHexDigit(this.source.charCodeAt(this.index)))
626
- i = i * 16 + Se(this.source[this.index] ?? ""), this.index += 1;
627
- else
628
- return null;
629
- return String.fromCharCode(i);
630
- }
631
- scanUnicodeCodePointEscape() {
632
- let e = this.source[this.index], t = 0;
633
- for (e === "}" && this.throwUnexpectedToken(); !this.eof() && (e = this.source[this.index] ?? "", this.index += 1, !!m.isHexDigit(e.charCodeAt(0))); )
634
- t = t * 16 + Se(e);
635
- return (t > 1114111 || e !== "}") && this.throwUnexpectedToken(), m.fromCodePoint(t);
636
- }
637
- getIdentifier() {
638
- const e = this.index;
639
- for (this.index += 1; !this.eof(); ) {
640
- const t = this.source.charCodeAt(this.index);
641
- if (t === 92)
642
- return this.index = e, this.getComplexIdentifier();
643
- if (t >= 55296 && t < 57343)
644
- return this.index = e, this.getComplexIdentifier();
645
- if (m.isIdentifierPart(t))
646
- this.index += 1;
647
- else
648
- break;
649
- }
650
- return this.source.slice(e, this.index);
651
- }
652
- getComplexIdentifier() {
653
- let e = this.codePointAt(this.index), t = m.fromCodePoint(e);
654
- this.index += t.length;
655
- let i;
656
- 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 === "\\" || !m.isIdentifierStart(i.charCodeAt(0))) && this.throwUnexpectedToken()), t = i); !this.eof() && (e = this.codePointAt(this.index), !!m.isIdentifierPart(e)); )
657
- i = m.fromCodePoint(e), t += i, this.index += i.length, e === 92 && (t = t.substring(0, t.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 === "\\" || !m.isIdentifierPart(i.charCodeAt(0))) && this.throwUnexpectedToken()), t += i);
658
- return t;
659
- }
660
- octalToDecimal(e) {
661
- let t = e !== "0", i = ne(e);
662
- return !this.eof() && m.isOctalDigit(this.source.charCodeAt(this.index)) && (t = !0, i = i * 8 + ne(this.source[this.index] ?? ""), this.index += 1, "0123".includes(e) && !this.eof() && m.isOctalDigit(this.source.charCodeAt(this.index)) && (i = i * 8 + ne(this.source[this.index] ?? ""), this.index += 1)), { code: i, octal: t };
663
- }
664
- // https://tc39.github.io/ecma262/#sec-names-and-keywords
665
- scanIdentifier() {
666
- let e;
667
- const t = this.index, i = this.source.charCodeAt(t) === 92 ? this.getComplexIdentifier() : this.getIdentifier();
668
- if (i.length === 1 ? e = l.Identifier : this.isKeyword(i) ? e = l.Keyword : i.toLowerCase() === V.Null ? e = l.NullLiteral : i.toLowerCase() === V.True || i.toLowerCase() === V.False ? e = l.BooleanLiteral : e = l.Identifier, e !== l.Identifier && t + i.length !== this.index) {
669
- const r = this.index;
670
- this.index = t, this.tolerateUnexpectedToken(h.InvalidEscapedReservedWord), this.index = r;
671
- }
672
- return {
673
- type: e,
674
- value: i,
675
- lineNumber: this.lineNumber,
676
- lineStart: this.lineStart,
677
- start: t,
678
- end: this.index
679
- };
680
- }
681
- // https://tc39.github.io/ecma262/#sec-punctuators
682
- scanPunctuator() {
683
- const e = this.index;
684
- let t = this.source[this.index] ?? "";
685
- switch (t) {
686
- case "(":
687
- case "{":
688
- t === "{" && this.curlyStack.push("{"), this.index += 1;
689
- break;
690
- case ".":
691
- this.index += 1;
692
- break;
693
- case "}":
694
- this.index += 1, this.curlyStack.pop();
695
- break;
696
- case ")":
697
- case ";":
698
- case ",":
699
- case "[":
700
- case "]":
701
- case ":":
702
- case "~":
703
- this.index += 1;
704
- break;
705
- default:
706
- for (let i = N.length; i > 0; i--)
707
- if (t = this.source.substring(this.index, this.index + i), N[i - 1]?.includes(t)) {
708
- this.index += i;
709
- break;
710
- }
711
- }
712
- return this.index === e && this.throwUnexpectedToken(), {
713
- type: l.Punctuator,
714
- value: t,
715
- lineNumber: this.lineNumber,
716
- lineStart: this.lineStart,
717
- start: e,
718
- end: this.index
719
- };
720
- }
721
- // https://tc39.github.io/ecma262/#sec-literals-numeric-literals
722
- scanHexLiteral(e) {
723
- let t = "";
724
- for (; !this.eof() && m.isHexDigit(this.source.charCodeAt(this.index)); )
725
- t += this.source[this.index], this.index += 1;
726
- return t.length === 0 && this.throwUnexpectedToken(), m.isIdentifierStart(this.source.charCodeAt(this.index)) && this.throwUnexpectedToken(), {
727
- type: l.NumericLiteral,
728
- value: Number.parseInt(`0x${t}`, 16),
729
- lineNumber: this.lineNumber,
730
- lineStart: this.lineStart,
731
- start: e,
732
- end: this.index
733
- };
734
- }
735
- scanBinaryLiteral(e) {
736
- let t = "";
737
- for (; !this.eof(); ) {
738
- const i = this.source[this.index];
739
- if (i !== "0" && i !== "1")
740
- break;
741
- t += this.source[this.index], this.index += 1;
742
- }
743
- if (t.length === 0 && this.throwUnexpectedToken(), !this.eof()) {
744
- const i = this.source.charCodeAt(this.index);
745
- (m.isIdentifierStart(i) || m.isDecimalDigit(i)) && this.throwUnexpectedToken();
746
- }
747
- return {
748
- type: l.NumericLiteral,
749
- value: Number.parseInt(t, 2),
750
- lineNumber: this.lineNumber,
751
- lineStart: this.lineStart,
752
- start: e,
753
- end: this.index
754
- };
755
- }
756
- scanOctalLiteral(e, t) {
757
- let i = "", r = !1;
758
- for (m.isOctalDigit(e.charCodeAt(0)) && (r = !0, i = `0${this.source[this.index]}`), this.index += 1; !this.eof() && m.isOctalDigit(this.source.charCodeAt(this.index)); )
759
- i += this.source[this.index], this.index += 1;
760
- return !r && i.length === 0 && this.throwUnexpectedToken(), (m.isIdentifierStart(this.source.charCodeAt(this.index)) || m.isDecimalDigit(this.source.charCodeAt(this.index))) && this.throwUnexpectedToken(), {
761
- type: l.NumericLiteral,
762
- value: Number.parseInt(i, 8),
763
- lineNumber: this.lineNumber,
764
- lineStart: this.lineStart,
765
- start: t,
766
- end: this.index
767
- };
768
- }
769
- scanNumericLiteral() {
770
- const e = this.index;
771
- let t = this.source[e] ?? "";
772
- ye(
773
- m.isDecimalDigit(t.charCodeAt(0)) || t === ".",
774
- "Numeric literal must start with a decimal digit or a decimal point"
775
- );
776
- let i = "";
777
- if (t !== ".") {
778
- if (i = this.source[this.index] ?? "", this.index += 1, t = this.source[this.index] ?? "", i === "0") {
779
- if (t === "x" || t === "X")
780
- return this.index += 1, this.scanHexLiteral(e);
781
- if (t === "b" || t === "B")
782
- return this.index += 1, this.scanBinaryLiteral(e);
783
- if (t === "o" || t === "O")
784
- return this.scanOctalLiteral(t, e);
785
- }
786
- for (; m.isDecimalDigit(this.source.charCodeAt(this.index)); )
787
- i += this.source[this.index], this.index += 1;
788
- t = this.source[this.index] ?? "";
789
- }
790
- if (t === ".") {
791
- for (i += this.source[this.index], this.index += 1; m.isDecimalDigit(this.source.charCodeAt(this.index)); )
792
- i += this.source[this.index], this.index += 1;
793
- t = this.source[this.index] ?? "";
794
- }
795
- if (t === "e" || t === "E")
796
- if (i += this.source[this.index], this.index += 1, t = this.source[this.index] ?? "", (t === "+" || t === "-") && (i += this.source[this.index], this.index += 1), m.isDecimalDigit(this.source.charCodeAt(this.index)))
797
- for (; m.isDecimalDigit(this.source.charCodeAt(this.index)); )
798
- i += this.source[this.index], this.index += 1;
799
- else
800
- this.throwUnexpectedToken();
801
- return m.isIdentifierStart(this.source.charCodeAt(this.index)) && this.throwUnexpectedToken(), {
802
- type: l.NumericLiteral,
803
- value: Number.parseFloat(i),
804
- lineNumber: this.lineNumber,
805
- lineStart: this.lineStart,
806
- start: e,
807
- end: this.index
808
- };
809
- }
810
- scanStringLiteral() {
811
- const e = this.index;
812
- let t = this.source[e];
813
- ye(t === "'" || t === '"', "String literal must starts with a quote"), this.index += 1;
814
- let i = !1, r = "";
815
- for (; !this.eof(); ) {
816
- let s = this.source[this.index] ?? "";
817
- if (this.index += 1, s === t) {
818
- t = "";
819
- break;
820
- }
821
- if (s === "\\")
822
- if (s = this.source[this.index] ?? "", this.index += 1, !s || !m.isLineTerminator(s.charCodeAt(0)))
823
- switch (s) {
824
- case "u":
825
- if (this.source[this.index] === "{")
826
- this.index += 1, r += this.scanUnicodeCodePointEscape();
827
- else {
828
- const a = this.scanHexEscape(s);
829
- a === null && this.throwUnexpectedToken(), r += a;
830
- }
831
- break;
832
- case "x": {
833
- const a = this.scanHexEscape(s);
834
- a === null && this.throwUnexpectedToken(h.InvalidHexEscapeSequence), r += a;
835
- break;
836
- }
837
- case "n":
838
- r += `
839
- `;
840
- break;
841
- case "r":
842
- r += "\r";
843
- break;
844
- case "t":
845
- r += " ";
846
- break;
847
- case "b":
848
- r += "\b";
849
- break;
850
- case "f":
851
- r += "\f";
852
- break;
853
- case "v":
854
- r += "\v";
855
- break;
856
- case "8":
857
- case "9":
858
- r += s, this.tolerateUnexpectedToken();
859
- break;
860
- default:
861
- if (s && m.isOctalDigit(s.charCodeAt(0))) {
862
- const a = this.octalToDecimal(s);
863
- i = a.octal || i, r += String.fromCharCode(a.code);
864
- } else
865
- r += s;
866
- break;
867
- }
868
- else
869
- this.lineNumber += 1, s === "\r" && this.source[this.index] === `
870
- ` && (this.index += 1), this.lineStart = this.index;
871
- else {
872
- if (m.isLineTerminator(s.charCodeAt(0)))
873
- break;
874
- r += s;
875
- }
876
- }
877
- return t !== "" && (this.index = e, this.throwUnexpectedToken()), {
878
- type: l.StringLiteral,
879
- value: r,
880
- lineNumber: this.lineNumber,
881
- lineStart: this.lineStart,
882
- start: e,
883
- end: this.index
884
- };
885
- }
886
- scanTemplate() {
887
- let e = "", t = !1;
888
- const i = this.index, r = this.source[i] === "`";
889
- let s = !1, a = 2;
890
- for (this.index += 1; !this.eof(); ) {
891
- let o = this.source[this.index] ?? "";
892
- if (this.index += 1, o === "`") {
893
- a = 1, s = !0, t = !0;
894
- break;
895
- }
896
- if (o === "$") {
897
- if (this.source[this.index] === "{") {
898
- this.curlyStack.push("${"), this.index += 1, t = !0;
899
- break;
900
- }
901
- e += o;
902
- continue;
903
- }
904
- if (o === "\\") {
905
- if (o = this.source[this.index] ?? "", this.index += 1, m.isLineTerminator(o.charCodeAt(0)))
906
- this.lineNumber += 1, o === "\r" && this.source[this.index] === `
907
- ` && (this.index += 1), this.lineStart = this.index;
908
- else
909
- switch (o) {
910
- case "n":
911
- e += `
912
- `;
913
- break;
914
- case "r":
915
- e += "\r";
916
- break;
917
- case "t":
918
- e += " ";
919
- break;
920
- case "u":
921
- if (this.source[this.index] === "{")
922
- this.index += 1, e += this.scanUnicodeCodePointEscape();
923
- else {
924
- const c = this.index, d = this.scanHexEscape(o);
925
- d !== null ? e += d : (this.index = c, e += o);
926
- }
927
- break;
928
- case "x": {
929
- const c = this.scanHexEscape(o);
930
- c === null && this.throwUnexpectedToken(h.InvalidHexEscapeSequence), e += c;
931
- break;
932
- }
933
- case "b":
934
- e += "\b";
935
- break;
936
- case "f":
937
- e += "\f";
938
- break;
939
- case "v":
940
- e += "\v";
941
- break;
942
- default:
943
- o === "0" ? (m.isDecimalDigit(this.source.charCodeAt(this.index)) && this.throwUnexpectedToken(h.TemplateOctalLiteral), e += "\0") : m.isOctalDigit(o.charCodeAt(0)) ? this.throwUnexpectedToken(h.TemplateOctalLiteral) : e += o;
944
- break;
945
- }
946
- continue;
947
- }
948
- if (m.isLineTerminator(o.charCodeAt(0))) {
949
- this.lineNumber += 1, o === "\r" && this.source[this.index] === `
950
- ` && (this.index += 1), this.lineStart = this.index, e += `
951
- `;
952
- continue;
953
- }
954
- e += o;
955
- }
956
- return t || this.throwUnexpectedToken(), r || this.curlyStack.pop(), {
957
- type: l.Template,
958
- value: this.source.slice(i + 1, this.index - a),
959
- cooked: e,
960
- head: r,
961
- tail: s,
962
- lineNumber: this.lineNumber,
963
- lineStart: this.lineStart,
964
- start: i,
965
- end: this.index
966
- };
967
- }
968
- lex() {
969
- if (this.eof())
970
- return {
971
- type: l.EOF,
972
- value: "",
973
- lineNumber: this.lineNumber,
974
- lineStart: this.lineStart,
975
- start: this.index,
976
- end: this.index
977
- };
978
- const e = this.source.charCodeAt(this.index);
979
- return m.isIdentifierStart(e) ? this.scanIdentifier() : e === 40 || e === 41 || e === 59 ? this.scanPunctuator() : e === 39 || e === 34 ? this.scanStringLiteral() : e === 46 ? m.isDecimalDigit(this.source.charCodeAt(this.index + 1)) ? this.scanNumericLiteral() : this.scanPunctuator() : m.isDecimalDigit(e) ? this.scanNumericLiteral() : e === 96 || e === 125 && this.curlyStack[this.curlyStack.length - 1] === "${" ? this.scanTemplate() : e >= 55296 && e < 57343 && m.isIdentifierStart(this.codePointAt(this.index)) ? this.scanIdentifier() : this.scanPunctuator();
980
- }
981
- }
982
- const y = {
983
- None: 0,
984
- Function: 1,
985
- IfClause: 2,
986
- ForLoop: 4,
987
- ForOfLoop: 8,
988
- WhileLoop: 16
989
- }, re = {
990
- AsObject: 0,
991
- Automatic: 1
992
- };
993
- function Ie(n, e = 0) {
994
- let t = n.start - n.lineStart, i = n.lineNumber;
995
- return t < 0 && (t += e, i -= 1), { index: n.start, line: i, column: t };
996
- }
997
- function be(n) {
998
- return [
999
- { index: n.range[0], ...n.loc.start },
1000
- { index: n.range[1], ...n.loc.end }
1001
- ];
1002
- }
1003
- function we(n) {
1004
- return n in q ? q[n] : 0;
1005
- }
1006
- class at {
1007
- constructor(e, t = {}, i) {
1008
- this.delegate = i, this.hasLineTerminator = !1, this.options = {
1009
- tokens: typeof t.tokens == "boolean" && t.tokens,
1010
- comments: typeof t.comments == "boolean" && t.comments,
1011
- tolerant: typeof t.tolerant == "boolean" && t.tolerant
1012
- }, this.options.comments && (this.commentHandler = new st()), this.errorHandler = new _e(this.options.tolerant), this.scanner = new $e(e, this.errorHandler), this.context = {
1013
- isAssignmentTarget: !1,
1014
- blockContext: y.None,
1015
- curlyParsingType: re.AsObject
1016
- }, this.rawToken = {
1017
- type: l.EOF,
1018
- value: "",
1019
- lineNumber: this.scanner.lineNumber,
1020
- lineStart: 0,
1021
- start: 0,
1022
- end: 0
1023
- }, this.tokens = [], this.startMarker = {
1024
- index: 0,
1025
- line: this.scanner.lineNumber,
1026
- column: 0
1027
- }, this.endMarker = {
1028
- index: 0,
1029
- line: this.scanner.lineNumber,
1030
- column: 0
1031
- }, this.readNextRawToken(), this.endMarker = {
1032
- index: this.scanner.index,
1033
- line: this.scanner.lineNumber,
1034
- column: this.scanner.index - this.scanner.lineStart
1035
- };
1036
- }
1037
- throwIfInvalidType(e, t, {
1038
- validTypes: i,
1039
- invalidTypes: r
1040
- }) {
1041
- i?.some((s) => e.type === s) || r?.some((s) => e.type === s) && this.throwError(h.InvalidExpression, t);
1042
- }
1043
- throwError(e, t, i = this.endMarker) {
1044
- const { index: r, line: s, column: a } = t, o = i.index - r - 1;
1045
- this.errorHandler.throwError({ code: e, index: r, line: s, column: a + 1, len: o });
1046
- }
1047
- tolerateError(e, t) {
1048
- throw new Error("######################################### !!!");
1049
- }
1050
- // Throw an exception because of the token.
1051
- unexpectedTokenError(e = {}) {
1052
- const { rawToken: t } = e;
1053
- let { code: i, data: r } = e, s;
1054
- if (t) {
1055
- if (!i)
1056
- switch (t.type) {
1057
- case l.EOF:
1058
- i = h.UnexpectedEndOfScript;
1059
- break;
1060
- case l.Identifier:
1061
- i = h.UnexpectedIdentifier;
1062
- break;
1063
- case l.NumericLiteral:
1064
- i = h.UnexpectedNumber;
1065
- break;
1066
- case l.StringLiteral:
1067
- i = h.UnexpectedString;
1068
- break;
1069
- case l.Template:
1070
- i = h.UnexpectedTemplate;
1071
- break;
1072
- }
1073
- s = t.value.toString();
1074
- } else
1075
- s = "ILLEGAL";
1076
- i ??= h.UnexpectedToken, r ??= { value: s };
1077
- const a = he(i, r);
1078
- if (t) {
1079
- const d = t.start, E = t.lineNumber, F = t.start - t.lineStart + 1;
1080
- return new z({
1081
- code: i,
1082
- index: d,
1083
- line: E,
1084
- column: F,
1085
- len: t.end - t.start - 1,
1086
- data: r,
1087
- description: a
1088
- });
1089
- }
1090
- const { index: o, line: c } = this.endMarker;
1091
- return new z({ code: i, index: o, line: c, column: this.endMarker.column + 1, data: r, description: a });
1092
- }
1093
- throwUnexpectedToken(e = {}) {
1094
- throw e.rawToken ??= this.rawToken, this.unexpectedTokenError(e);
1095
- }
1096
- collectComments(e) {
1097
- const { commentHandler: t } = this;
1098
- !t || !e.length || e.forEach((i) => {
1099
- const r = {
1100
- type: i.multiLine ? u.BlockComment : u.LineComment,
1101
- value: this.getSourceValue(i),
1102
- range: i.range,
1103
- loc: i.loc
1104
- };
1105
- t.collectComment(r);
1106
- });
1107
- }
1108
- peekAhead(e) {
1109
- const t = () => (this.scanner.scanComments(), this.scanner.lex()), i = this.scanner.saveState(), r = e.call(this, t);
1110
- return this.scanner.restoreState(i), r;
1111
- }
1112
- getSourceValue(e) {
1113
- return this.scanner.source.slice(e.start, e.end);
1114
- }
1115
- convertToToken(e) {
1116
- return {
1117
- type: Oe[e.type],
1118
- value: this.getSourceValue(e),
1119
- range: [e.start, e.end],
1120
- loc: {
1121
- start: {
1122
- line: this.startMarker.line,
1123
- column: this.startMarker.column
1124
- },
1125
- end: {
1126
- line: this.scanner.lineNumber,
1127
- column: this.scanner.index - this.scanner.lineStart
1128
- }
1129
- }
1130
- };
1131
- }
1132
- readNextRawToken() {
1133
- this.endMarker.index = this.scanner.index, this.endMarker.line = this.scanner.lineNumber, this.endMarker.column = this.scanner.index - this.scanner.lineStart;
1134
- const e = this.rawToken;
1135
- 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 !== l.EOF && this.tokens.push(this.convertToToken(this.rawToken));
1136
- }
1137
- captureStartMarker() {
1138
- return {
1139
- index: this.startMarker.index,
1140
- line: this.startMarker.line,
1141
- column: this.startMarker.column
1142
- };
1143
- }
1144
- getItemLocation(e) {
1145
- return {
1146
- range: [e.index, this.endMarker.index],
1147
- loc: {
1148
- start: {
1149
- line: e.line,
1150
- column: e.column
1151
- },
1152
- end: {
1153
- line: this.endMarker.line,
1154
- column: this.endMarker.column
1155
- }
1156
- }
1157
- };
1158
- }
1159
- finalize(e) {
1160
- return (this.delegate ?? this.commentHandler) && (this.commentHandler?.attachComments(e), this.delegate?.(e)), e;
1161
- }
1162
- expectPunctuator(e) {
1163
- const t = this.rawToken;
1164
- if (this.matchPunctuator(e)) {
1165
- this.readNextRawToken();
1166
- return;
1167
- }
1168
- this.throwUnexpectedToken({ rawToken: t, code: h.PunctuatorExpected, data: { value: e } });
1169
- }
1170
- expectKeyword(e) {
1171
- if (this.rawToken.type === l.Keyword && this.rawToken.value.toLowerCase() === e.toString()) {
1172
- this.readNextRawToken();
1173
- return;
1174
- }
1175
- this.throwUnexpectedToken({ rawToken: this.rawToken });
1176
- }
1177
- expectContextualKeyword(e) {
1178
- if (this.rawToken.type === l.Identifier && this.rawToken.value.toLowerCase() === e) {
1179
- this.readNextRawToken();
1180
- return;
1181
- }
1182
- this.throwUnexpectedToken({ rawToken: this.rawToken });
1183
- }
1184
- matchKeyword(e) {
1185
- return this.rawToken.type === l.Keyword && this.rawToken.value.toLowerCase() === e;
1186
- }
1187
- matchContextualKeyword(e) {
1188
- return this.rawToken.type === l.Identifier && this.rawToken.value === e;
1189
- }
1190
- matchPunctuator(e) {
1191
- return this.rawToken.type === l.Punctuator && this.rawToken.value === e;
1192
- }
1193
- getMatchingPunctuator(e) {
1194
- if (typeof e == "string" && (e = e.split("")), !(this.rawToken.type !== l.Punctuator || !e.length))
1195
- return e.find(this.matchPunctuator.bind(this));
1196
- }
1197
- // Cover grammar support.
1198
- //
1199
- // When an assignment expression position starts with an left parenthesis, the determination of the type
1200
- // of the syntax is to be deferred arbitrarily long until the end of the parentheses pair (plus a lookahead)
1201
- // or the first comma. This situation also defers the determination of all the expressions nested in the pair.
1202
- //
1203
- // There are two productions that can be parsed in a parentheses pair that needs to be determined
1204
- // after the outermost pair is closed. They are:
1205
- //
1206
- // 1. AssignmentExpression
1207
- // 2. AssignmentTargets
1208
- //
1209
- // In order to avoid exponential backtracking, we use two flags to denote if the production can be
1210
- // assignment target.
1211
- //
1212
- // The two productions have the relationship:
1213
- //
1214
- // AssignmentTargets ⊆ AssignmentExpression
1215
- //
1216
- // with a single exception that CoverInitializedName when used directly in an Expression, generates
1217
- // an early error.
1218
- //
1219
- // isolateCoverGrammar function runs the given parser function with a new cover grammar context, and it does not
1220
- // effect the current flags. This means the production the parser parses is only used as an expression. Therefore
1221
- // the CoverInitializedName check is conducted.
1222
- //
1223
- // inheritCoverGrammar function runs the given parse function with a new cover grammar context, and it propagates
1224
- // the flags outside of the parser. This means the production the parser parses is used as a part of a potential
1225
- // pattern. The CoverInitializedName check is deferred.
1226
- isolateCoverGrammar(e) {
1227
- const t = this.context.isAssignmentTarget;
1228
- this.context.isAssignmentTarget = !0;
1229
- const i = e.call(this);
1230
- return this.context.isAssignmentTarget = t, i;
1231
- }
1232
- inheritCoverGrammar(e) {
1233
- const t = this.context.isAssignmentTarget;
1234
- this.context.isAssignmentTarget = !0;
1235
- const i = e.call(this);
1236
- return this.context.isAssignmentTarget &&= t, i;
1237
- }
1238
- withBlockContext(e, t) {
1239
- const i = this.context.blockContext;
1240
- this.context.blockContext |= e;
1241
- const r = this.context.curlyParsingType;
1242
- this.context.curlyParsingType = re.Automatic;
1243
- const s = t.call(this);
1244
- return this.context.blockContext = i, this.context.curlyParsingType = r, s;
1245
- }
1246
- consumeSemicolon() {
1247
- if (this.matchPunctuator(";")) {
1248
- this.readNextRawToken();
1249
- return;
1250
- }
1251
- if (!this.hasLineTerminator) {
1252
- if (this.rawToken.type === l.EOF || this.matchPunctuator("}")) {
1253
- this.endMarker.index = this.startMarker.index, this.endMarker.line = this.startMarker.line, this.endMarker.column = this.startMarker.column;
1254
- return;
1255
- }
1256
- this.throwUnexpectedToken({ rawToken: this.rawToken });
1257
- }
1258
- }
1259
- parsePrimaryExpression() {
1260
- const e = this.captureStartMarker(), t = this.rawToken;
1261
- switch (t.type) {
1262
- case l.Identifier:
1263
- return this.readNextRawToken(), this.finalize({
1264
- type: u.Identifier,
1265
- name: t.value,
1266
- ...this.getItemLocation(e)
1267
- });
1268
- case l.NumericLiteral:
1269
- case l.StringLiteral:
1270
- return this.context.isAssignmentTarget = !1, this.readNextRawToken(), this.finalize({
1271
- type: u.Literal,
1272
- value: t.value,
1273
- raw: this.getSourceValue(t),
1274
- isString: typeof t.value == "string",
1275
- ...this.getItemLocation(e)
1276
- });
1277
- case l.BooleanLiteral:
1278
- return this.context.isAssignmentTarget = !1, this.readNextRawToken(), this.finalize({
1279
- type: u.Literal,
1280
- value: t.value.toLowerCase() === V.True,
1281
- raw: this.getSourceValue(t),
1282
- isString: !1,
1283
- ...this.getItemLocation(e)
1284
- });
1285
- case l.NullLiteral:
1286
- return this.context.isAssignmentTarget = !1, this.readNextRawToken(), this.finalize({
1287
- type: u.Literal,
1288
- value: null,
1289
- raw: this.getSourceValue(t),
1290
- isString: !1,
1291
- ...this.getItemLocation(e)
1292
- });
1293
- case l.Template:
1294
- return this.parseTemplateLiteral();
1295
- case l.Punctuator:
1296
- switch (t.value) {
1297
- case "(":
1298
- return this.inheritCoverGrammar(this.parseGroupExpression.bind(this));
1299
- case "[":
1300
- return this.inheritCoverGrammar(this.parseArrayInitializer.bind(this));
1301
- case "{":
1302
- return this.inheritCoverGrammar(this.parseObjectExpression.bind(this));
1303
- default:
1304
- return this.throwUnexpectedToken({ rawToken: this.rawToken });
1305
- }
1306
- case l.Keyword:
1307
- return this.context.isAssignmentTarget = !1, this.throwUnexpectedToken({ rawToken: this.rawToken });
1308
- default:
1309
- return this.throwUnexpectedToken({ rawToken: this.rawToken });
1310
- }
1311
- }
1312
- parseArrayInitializer() {
1313
- const e = this.captureStartMarker();
1314
- this.expectPunctuator("[");
1315
- const t = [];
1316
- for (; !this.matchPunctuator("]"); ) {
1317
- const i = this.captureStartMarker();
1318
- this.matchPunctuator(",") ? (this.readNextRawToken(), this.throwError(h.InvalidExpression, i)) : (t.push(this.inheritCoverGrammar(this.parseAssignmentExpression.bind(this))), this.matchPunctuator("]") || this.expectPunctuator(","));
1319
- }
1320
- return this.expectPunctuator("]"), this.finalize({ type: u.ArrayExpression, elements: t, ...this.getItemLocation(e) });
1321
- }
1322
- parseObjectPropertyKey() {
1323
- const e = this.captureStartMarker(), t = this.rawToken;
1324
- switch (t.type) {
1325
- case l.StringLiteral:
1326
- return this.readNextRawToken(), this.finalize({
1327
- type: u.Literal,
1328
- value: t.value,
1329
- raw: this.getSourceValue(t),
1330
- isString: !0,
1331
- ...this.getItemLocation(e)
1332
- });
1333
- case l.Identifier:
1334
- case l.BooleanLiteral:
1335
- case l.NullLiteral:
1336
- case l.Keyword:
1337
- return this.readNextRawToken(), this.finalize({
1338
- type: u.Identifier,
1339
- name: t.value,
1340
- ...this.getItemLocation(e)
1341
- });
1342
- default:
1343
- this.throwError(h.KeyMustBeString, e);
1344
- }
1345
- }
1346
- parseObjectProperty() {
1347
- const e = this.rawToken, t = this.captureStartMarker(), i = this.parseObjectPropertyKey();
1348
- let r = !1, s = null;
1349
- return this.matchPunctuator(":") ? (this.readNextRawToken(), s = this.inheritCoverGrammar(this.parseAssignmentExpression.bind(this))) : e.type === l.Identifier ? (r = !0, s = this.finalize({
1350
- type: u.Identifier,
1351
- name: e.value,
1352
- ...this.getItemLocation(t)
1353
- })) : this.throwUnexpectedToken({ rawToken: this.rawToken }), this.finalize({
1354
- type: u.Property,
1355
- kind: "init",
1356
- key: i,
1357
- value: s,
1358
- shorthand: r,
1359
- ...this.getItemLocation(t)
1360
- });
1361
- }
1362
- parseObjectExpression() {
1363
- const e = this.captureStartMarker();
1364
- this.expectPunctuator("{");
1365
- const t = [];
1366
- for (; !this.matchPunctuator("}"); )
1367
- t.push(this.parseObjectProperty()), this.matchPunctuator("}") || this.expectPunctuator(",");
1368
- return this.expectPunctuator("}"), this.finalize({ type: u.ObjectExpression, properties: t, ...this.getItemLocation(e) });
1369
- }
1370
- parseTemplateElement(e = !1) {
1371
- const t = this.rawToken;
1372
- t.type !== l.Template && this.throwUnexpectedToken({ rawToken: t }), e && !t.head && this.throwUnexpectedToken({ code: h.InvalidTemplateHead, rawToken: t });
1373
- const i = this.captureStartMarker();
1374
- this.readNextRawToken();
1375
- const { value: r, cooked: s, tail: a } = t, o = this.finalize({
1376
- type: u.TemplateElement,
1377
- value: { raw: r, cooked: s },
1378
- tail: a,
1379
- ...this.getItemLocation(i)
1380
- });
1381
- return o.loc.start.column += 1, o.loc.end.column -= a ? 1 : 2, o;
1382
- }
1383
- parseTemplateLiteral() {
1384
- const e = this.captureStartMarker(), t = [], i = [];
1385
- let r = this.parseTemplateElement(!0);
1386
- for (i.push(r); !r.tail; )
1387
- t.push(this.parseExpression()), r = this.parseTemplateElement(), i.push(r);
1388
- return this.finalize({
1389
- type: u.TemplateLiteral,
1390
- quasis: i,
1391
- expressions: t,
1392
- ...this.getItemLocation(e)
1393
- });
1394
- }
1395
- parseGroupExpression() {
1396
- this.expectPunctuator("(");
1397
- const e = this.inheritCoverGrammar(this.parseAssignmentExpression.bind(this));
1398
- return this.expectPunctuator(")"), e;
1399
- }
1400
- parseArguments() {
1401
- this.expectPunctuator("(");
1402
- const e = [];
1403
- if (!this.matchPunctuator(")"))
1404
- for (; ; ) {
1405
- const t = this.isolateCoverGrammar(this.parseAssignmentExpression.bind(this));
1406
- if (e.push(t), this.matchPunctuator(")") || (this.expectPunctuator(","), this.matchPunctuator(")")))
1407
- break;
1408
- }
1409
- return this.expectPunctuator(")"), e;
1410
- }
1411
- parseMemberName() {
1412
- const e = this.rawToken, t = this.captureStartMarker();
1413
- return this.readNextRawToken(), e.type !== l.NullLiteral && e.type !== l.Identifier && e.type !== l.Keyword && e.type !== l.BooleanLiteral && this.throwUnexpectedToken({ rawToken: e }), this.finalize({
1414
- type: u.Identifier,
1415
- name: e.value,
1416
- ...this.getItemLocation(t)
1417
- });
1418
- }
1419
- parseLeftHandSideExpression() {
1420
- const e = this.captureStartMarker();
1421
- let t = this.inheritCoverGrammar(this.parsePrimaryExpression.bind(this)), i = !1, r;
1422
- for (; r = this.getMatchingPunctuator(["(", "[", ".", w]); ) {
1423
- let s = !1;
1424
- switch (r === w && (i = !0, s = !0, this.expectPunctuator(w), this.getMatchingPunctuator("[") ? r = "[" : r = "."), r) {
1425
- case "(": {
1426
- this.context.isAssignmentTarget = !1;
1427
- const a = this.parseArguments();
1428
- t = this.finalize({
1429
- type: u.CallExpression,
1430
- callee: t,
1431
- arguments: a,
1432
- ...this.getItemLocation(e)
1433
- });
1434
- continue;
1435
- }
1436
- case "[": {
1437
- this.context.isAssignmentTarget = !s, this.expectPunctuator("[");
1438
- const a = this.isolateCoverGrammar(() => this.parseExpression());
1439
- this.expectPunctuator("]"), t = this.finalize({
1440
- type: s ? u.SafeMemberExpression : u.MemberExpression,
1441
- computed: !0,
1442
- object: t,
1443
- property: a,
1444
- ...this.getItemLocation(e)
1445
- });
1446
- continue;
1447
- }
1448
- case ".": {
1449
- this.context.isAssignmentTarget = !s, s || this.expectPunctuator(".");
1450
- const a = this.parseMemberName();
1451
- t = this.finalize({
1452
- type: s ? u.SafeMemberExpression : u.MemberExpression,
1453
- computed: !1,
1454
- object: t,
1455
- property: a,
1456
- ...this.getItemLocation(e)
1457
- });
1458
- continue;
1459
- }
1460
- }
1461
- }
1462
- return i ? this.finalize({
1463
- type: u.MemberAccessChainExpression,
1464
- expression: t,
1465
- ...this.getItemLocation(e)
1466
- }) : t;
1467
- }
1468
- parseUpdateExpression() {
1469
- const e = this.captureStartMarker();
1470
- let t = this.getMatchingPunctuator(ue);
1471
- if (t) {
1472
- this.readNextRawToken();
1473
- const a = this.captureStartMarker(), o = this.inheritCoverGrammar(this.parseUnaryExpression.bind(this));
1474
- return o.type !== u.Identifier && o.type !== u.MemberExpression && o.type !== u.CallExpression && this.throwError(h.InvalidExpression, a), this.context.isAssignmentTarget || this.tolerateError(h.InvalidLeftHandSideInAssignment, e), this.context.isAssignmentTarget = !1, this.finalize({
1475
- type: u.UpdateExpression,
1476
- operator: t,
1477
- argument: o,
1478
- prefix: !0,
1479
- ...this.getItemLocation(e)
1480
- });
1481
- }
1482
- const i = this.captureStartMarker(), r = this.inheritCoverGrammar(this.parseLeftHandSideExpression.bind(this)), s = this.captureStartMarker();
1483
- return this.hasLineTerminator || (t = this.getMatchingPunctuator(ue), !t) ? r : (r.type !== u.Identifier && r.type !== u.MemberExpression && this.throwError(h.InvalidExpression, i, s), this.context.isAssignmentTarget || this.tolerateError(h.InvalidLeftHandSideInAssignment, e), this.readNextRawToken(), this.context.isAssignmentTarget = !1, this.finalize({
1484
- type: u.UpdateExpression,
1485
- operator: t,
1486
- argument: r,
1487
- prefix: !1,
1488
- ...this.getItemLocation(e)
1489
- }));
1490
- }
1491
- parseUnaryExpression() {
1492
- const e = this.getMatchingPunctuator(Ne);
1493
- if (e) {
1494
- const t = this.captureStartMarker();
1495
- this.readNextRawToken();
1496
- const i = this.inheritCoverGrammar(this.parseUnaryExpression.bind(this));
1497
- return this.context.isAssignmentTarget = !1, this.finalize({
1498
- type: u.UnaryExpression,
1499
- operator: e,
1500
- argument: i,
1501
- prefix: !0,
1502
- ...this.getItemLocation(t)
1503
- });
1504
- }
1505
- return this.parseUpdateExpression();
1506
- }
1507
- parseBinaryExpression() {
1508
- const e = this.rawToken;
1509
- let t = this.inheritCoverGrammar(this.parseUnaryExpression.bind(this));
1510
- if (this.rawToken.type !== l.Punctuator)
1511
- return t;
1512
- const i = this.rawToken.value;
1513
- let r = we(i);
1514
- if (r === 0)
1515
- return t;
1516
- this.readNextRawToken(), this.context.isAssignmentTarget = !1;
1517
- const s = [e, this.rawToken];
1518
- let a = t, o = this.inheritCoverGrammar(
1519
- this.parseUnaryExpression.bind(this)
1520
- );
1521
- const c = [a, i, o], d = [r];
1522
- for (; this.rawToken.type === l.Punctuator && (r = we(this.rawToken.value)) > 0; ) {
1523
- for (; c.length > 2 && r <= d[d.length - 1]; ) {
1524
- o = c.pop();
1525
- const k = c.pop();
1526
- d.pop(), a = c.pop(), s.pop();
1527
- const R = s[s.length - 1], ee = Ie(R, R.lineStart);
1528
- c.push(this.finalize(this.createBinaryOrLogicalExpression(ee, k, a, o)));
1529
- }
1530
- c.push(this.rawToken.value), d.push(r), s.push(this.rawToken), this.readNextRawToken(), c.push(this.inheritCoverGrammar(this.parseUnaryExpression.bind(this)));
1531
- }
1532
- let E = c.length - 1;
1533
- t = c[E];
1534
- let F = s.pop();
1535
- for (; E > 1; ) {
1536
- const k = s.pop();
1537
- if (!k)
1538
- break;
1539
- const R = F?.lineStart, ee = Ie(k, R), qe = c[E - 1];
1540
- t = this.finalize(
1541
- this.createBinaryOrLogicalExpression(ee, qe, c[E - 2], t)
1542
- ), E -= 2, F = k;
1543
- }
1544
- return t;
1545
- }
1546
- createBinaryOrLogicalExpression(e, t, i, r) {
1547
- return Ue.includes(t) ? ((i.type === u.AssignmentExpression || i.type === u.UpdateExpression) && this.throwError(h.InvalidExpression, ...be(i)), (r.type === u.AssignmentExpression || r.type === u.UpdateExpression) && this.throwError(h.InvalidExpression, ...be(i)), {
1548
- type: u.LogicalExpression,
1549
- operator: t,
1550
- left: i,
1551
- right: r,
1552
- ...this.getItemLocation(e)
1553
- }) : {
1554
- type: u.BinaryExpression,
1555
- operator: t,
1556
- left: i,
1557
- right: r,
1558
- ...this.getItemLocation(e)
1559
- };
1560
- }
1561
- parseAssignmentExpression() {
1562
- const e = this.captureStartMarker(), t = this.inheritCoverGrammar(this.parseBinaryExpression.bind(this)), i = this.captureStartMarker(), r = this.getMatchingPunctuator(Me);
1563
- if (!r)
1564
- return t;
1565
- t.type !== u.Identifier && t.type !== u.MemberExpression && this.throwError(h.InvalidExpression, e, i), this.context.isAssignmentTarget || this.tolerateError(h.InvalidLeftHandSideInAssignment, e), this.matchPunctuator("=") || (this.context.isAssignmentTarget = !1), this.readNextRawToken();
1566
- const s = this.isolateCoverGrammar(this.parseAssignmentExpression.bind(this));
1567
- return this.finalize({
1568
- type: u.AssignmentExpression,
1569
- left: t,
1570
- operator: r,
1571
- right: s,
1572
- ...this.getItemLocation(e)
1573
- });
1574
- }
1575
- parseExpression() {
1576
- return this.isolateCoverGrammar(this.parseAssignmentExpression.bind(this));
1577
- }
1578
- parseStatements(e) {
1579
- const t = [];
1580
- for (; this.rawToken.type !== l.EOF && !this.matchPunctuator(e); ) {
1581
- const i = this.parseStatementListItem();
1582
- pe(i) || t.push(i);
1583
- }
1584
- return t;
1585
- }
1586
- parseStatementListItem() {
1587
- return this.context.isAssignmentTarget = !0, this.matchKeyword(f.Function) ? this.parseFunctionDeclaration() : this.matchKeyword(f.Export) ? this.parseExportDeclaration() : this.matchKeyword(f.Import) ? this.parseImportDeclaration() : this.parseStatement();
1588
- }
1589
- parseBlock() {
1590
- const e = this.captureStartMarker();
1591
- this.expectPunctuator("{");
1592
- const t = this.parseStatements("}");
1593
- return this.expectPunctuator("}"), this.finalize({ type: u.BlockStatement, body: t, ...this.getItemLocation(e) });
1594
- }
1595
- parseObjectStatement() {
1596
- const e = this.captureStartMarker(), t = this.parseObjectExpression();
1597
- return this.finalize({
1598
- type: u.ExpressionStatement,
1599
- expression: t,
1600
- ...this.getItemLocation(e)
1601
- });
1602
- }
1603
- parseBlockOrObjectStatement() {
1604
- return this.context.curlyParsingType === re.AsObject ? this.parseObjectStatement() : this.peekAhead((e) => {
1605
- let t = e();
1606
- return !(t.type !== l.Identifier && t.type !== l.StringLiteral || (t = e(), t.type !== l.Punctuator || t.value !== ":"));
1607
- }) ? this.parseObjectStatement() : this.parseBlock();
1608
- }
1609
- parseIdentifier() {
1610
- const e = this.rawToken;
1611
- if (e.type !== l.Identifier)
1612
- return null;
1613
- const t = this.captureStartMarker();
1614
- return this.readNextRawToken(), this.finalize({
1615
- type: u.Identifier,
1616
- name: e.value,
1617
- ...this.getItemLocation(t)
1618
- });
1619
- }
1620
- parseVariableDeclarator() {
1621
- const e = this.captureStartMarker(), t = this.parseIdentifier();
1622
- t || this.throwUnexpectedToken({ code: h.IdentifierExpected });
1623
- let i = null;
1624
- if (this.matchPunctuator("=")) {
1625
- this.readNextRawToken();
1626
- const r = this.rawToken;
1627
- try {
1628
- i = this.isolateCoverGrammar(this.parseAssignmentExpression.bind(this));
1629
- } catch {
1630
- this.throwUnexpectedToken({ rawToken: r, code: h.InvalidVariableAssignment });
1631
- }
1632
- }
1633
- return this.finalize({ type: u.VariableDeclarator, id: t, init: i, ...this.getItemLocation(e) });
1634
- }
1635
- parseVariableDeclarators() {
1636
- const e = [this.parseVariableDeclarator()];
1637
- for (; this.matchPunctuator(","); )
1638
- this.readNextRawToken(), e.push(this.parseVariableDeclarator());
1639
- return e;
1640
- }
1641
- parseVariableDeclaration() {
1642
- const e = this.captureStartMarker();
1643
- this.expectKeyword(f.Var);
1644
- const t = this.parseVariableDeclarators();
1645
- return this.consumeSemicolon(), this.finalize({
1646
- type: u.VariableDeclaration,
1647
- declarations: t,
1648
- kind: "var",
1649
- ...this.getItemLocation(e)
1650
- });
1651
- }
1652
- parseEmptyStatement() {
1653
- const e = this.captureStartMarker();
1654
- return this.expectPunctuator(";"), this.finalize({ type: u.EmptyStatement, ...this.getItemLocation(e) });
1655
- }
1656
- parseExpressionStatement() {
1657
- const e = this.captureStartMarker(), t = this.parseExpression();
1658
- return this.consumeSemicolon(), this.finalize({
1659
- type: u.ExpressionStatement,
1660
- expression: t,
1661
- ...this.getItemLocation(e)
1662
- });
1663
- }
1664
- parseIfClause() {
1665
- return this.withBlockContext(y.IfClause, this.parseStatement.bind(this));
1666
- }
1667
- parseIfStatement() {
1668
- const e = this.captureStartMarker();
1669
- this.expectKeyword(f.If), this.expectPunctuator("(");
1670
- const t = this.captureStartMarker(), i = this.parseExpression(), r = this.captureStartMarker();
1671
- this.expectPunctuator(")"), (i.type === u.AssignmentExpression || i.type === u.UpdateExpression) && this.throwError(h.InvalidExpression, t, r);
1672
- const s = this.parseIfClause();
1673
- let a = null;
1674
- return this.matchKeyword(f.Else) && (this.readNextRawToken(), a = this.parseIfClause()), this.finalize({
1675
- type: u.IfStatement,
1676
- test: i,
1677
- consequent: s,
1678
- alternate: a,
1679
- ...this.getItemLocation(e)
1680
- });
1681
- }
1682
- parseWhileStatement() {
1683
- const e = this.captureStartMarker();
1684
- this.expectKeyword(f.While), this.expectPunctuator("(");
1685
- const t = this.captureStartMarker(), i = this.parseExpression(), r = this.captureStartMarker();
1686
- this.expectPunctuator(")"), (i.type === u.AssignmentExpression || i.type === u.UpdateExpression) && this.throwError(h.InvalidExpression, t, r);
1687
- const s = this.withBlockContext(y.WhileLoop, this.parseStatement.bind(this));
1688
- return this.finalize({
1689
- type: u.WhileStatement,
1690
- test: i,
1691
- body: s,
1692
- ...this.getItemLocation(e)
1693
- });
1694
- }
1695
- parseForStatement() {
1696
- let e = u.ForStatement, t = null, i = null, r = null, s = null, a = null;
1697
- const o = this.captureStartMarker();
1698
- if (this.expectKeyword(f.For), this.expectPunctuator("("), this.matchKeyword(f.Var)) {
1699
- const d = this.captureStartMarker();
1700
- this.readNextRawToken();
1701
- const E = this.parseVariableDeclarators();
1702
- t = this.finalize({
1703
- type: u.VariableDeclaration,
1704
- declarations: E,
1705
- kind: "var",
1706
- ...this.getItemLocation(d)
1707
- });
1708
- const F = this.matchKeyword(f.In), k = this.matchContextualKeyword(te.Of);
1709
- E.length === 1 && (F || k) && (E[0].init && this.throwError(h.ForInOfLoopInitializer, d), e = F ? u.ForInStatement : u.ForOfStatement, s = t);
1710
- } else if (!this.matchPunctuator(";")) {
1711
- const d = this.context.isAssignmentTarget, E = this.captureStartMarker();
1712
- t = this.inheritCoverGrammar(this.parseAssignmentExpression.bind(this));
1713
- const F = this.matchKeyword(f.In), k = this.matchContextualKeyword(te.Of);
1714
- F || k ? (this.context.isAssignmentTarget || this.tolerateError(h.InvalidLeftHandSideInForIn, E), t.type !== u.Identifier && this.throwError(h.InvalidLeftHandSideInForIn, E), e = F ? u.ForInStatement : u.ForOfStatement, s = t) : this.context.isAssignmentTarget = d;
1715
- }
1716
- e === u.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(), a = this.parseExpression()), this.expectPunctuator(")");
1717
- const c = this.withBlockContext(
1718
- e === u.ForOfStatement ? y.ForOfLoop : y.ForLoop,
1719
- () => this.isolateCoverGrammar(this.parseStatement.bind(this))
1720
- );
1721
- return e === u.ForInStatement || e === u.ForOfStatement ? this.finalize({
1722
- type: e,
1723
- left: s,
1724
- right: a,
1725
- body: c,
1726
- ...this.getItemLocation(o)
1727
- }) : this.finalize({
1728
- type: e,
1729
- init: t,
1730
- test: i,
1731
- update: r,
1732
- body: c,
1733
- ...this.getItemLocation(o)
1734
- });
1735
- }
1736
- parseContinueStatement() {
1737
- const e = this.captureStartMarker();
1738
- return this.expectKeyword(f.Continue), this.consumeSemicolon(), this.finalize({ type: u.ContinueStatement, ...this.getItemLocation(e) });
1739
- }
1740
- parseBreakStatement() {
1741
- const e = this.captureStartMarker();
1742
- return this.expectKeyword(f.Break), this.consumeSemicolon(), this.finalize({ type: u.BreakStatement, ...this.getItemLocation(e) });
1743
- }
1744
- parseReturnStatement() {
1745
- const e = this.captureStartMarker();
1746
- this.expectKeyword(f.Return);
1747
- const t = !this.matchPunctuator(";") && !this.matchPunctuator("}") && !this.hasLineTerminator && this.rawToken.type !== l.EOF || this.rawToken.type === l.StringLiteral || this.rawToken.type === l.Template ? this.parseExpression() : null;
1748
- return this.consumeSemicolon(), this.finalize({ type: u.ReturnStatement, argument: t, ...this.getItemLocation(e) });
1749
- }
1750
- parseStatement() {
1751
- switch (this.rawToken.type) {
1752
- case l.BooleanLiteral:
1753
- case l.NullLiteral:
1754
- case l.NumericLiteral:
1755
- case l.StringLiteral:
1756
- case l.Template:
1757
- case l.Identifier:
1758
- return this.parseExpressionStatement();
1759
- case l.Punctuator:
1760
- return this.rawToken.value === "{" ? this.parseBlockOrObjectStatement() : this.rawToken.value === "(" ? this.parseExpressionStatement() : this.rawToken.value === ";" ? this.parseEmptyStatement() : this.parseExpressionStatement();
1761
- case l.Keyword:
1762
- switch (this.rawToken.value.toLowerCase()) {
1763
- case f.Break:
1764
- return this.parseBreakStatement();
1765
- case f.Continue:
1766
- return this.parseContinueStatement();
1767
- case f.For:
1768
- return this.parseForStatement();
1769
- case f.Function:
1770
- return this.parseFunctionDeclaration();
1771
- case f.If:
1772
- return this.parseIfStatement();
1773
- case f.Return:
1774
- return this.parseReturnStatement();
1775
- case f.Var:
1776
- return this.parseVariableDeclaration();
1777
- case f.While:
1778
- return this.parseWhileStatement();
1779
- default:
1780
- return this.parseExpressionStatement();
1781
- }
1782
- default:
1783
- return this.throwUnexpectedToken({ rawToken: this.rawToken });
1784
- }
1785
- }
1786
- parseFormalParameters() {
1787
- const e = [];
1788
- if (this.expectPunctuator("("), !this.matchPunctuator(")"))
1789
- for (; this.rawToken.type !== l.EOF; ) {
1790
- const t = this.parseIdentifier();
1791
- if (t || this.throwUnexpectedToken({ rawToken: this.rawToken, code: h.IdentifierExpected }), e.push(t), this.matchPunctuator(")") || (this.expectPunctuator(","), this.matchPunctuator(")")))
1792
- break;
1793
- }
1794
- return this.expectPunctuator(")"), e;
1795
- }
1796
- parseFunctionDeclaration() {
1797
- (this.context.blockContext & y.Function) === y.Function && this.throwUnexpectedToken({ code: h.NoFunctionInsideFunction }), ((this.context.blockContext & y.WhileLoop) === y.WhileLoop || (this.context.blockContext & y.ForOfLoop) === y.ForOfLoop || (this.context.blockContext & y.IfClause) === y.IfClause) && this.throwUnexpectedToken({ code: h.NoFunctionInsideBlock });
1798
- const e = this.captureStartMarker();
1799
- this.expectKeyword(f.Function);
1800
- const t = this.parseIdentifier();
1801
- t || this.throwUnexpectedToken({ code: h.InvalidFunctionIdentifier });
1802
- const i = this.parseFormalParameters(), r = this.context.blockContext;
1803
- this.context.blockContext |= y.Function;
1804
- const s = this.parseBlock();
1805
- return this.context.blockContext = r, this.finalize({
1806
- type: u.FunctionDeclaration,
1807
- id: t,
1808
- params: i,
1809
- body: s,
1810
- ...this.getItemLocation(e)
1811
- });
1812
- }
1813
- parseScript() {
1814
- const e = this.captureStartMarker(), t = this.parseStatements(), i = this.finalize({
1815
- type: u.Program,
1816
- body: t,
1817
- ...this.getItemLocation(e)
1818
- });
1819
- return this.options.tokens && (i.tokens = this.tokens), this.options.tolerant && (i.errors = this.errorHandler.errors), i;
1820
- }
1821
- parseExportDeclaration() {
1822
- this.context.blockContext !== y.None && this.throwUnexpectedToken({ code: h.ModuleExportRootOnly });
1823
- let e = null;
1824
- const t = this.captureStartMarker();
1825
- return this.expectKeyword(f.Export), this.matchKeyword(f.Var) ? e = this.parseVariableDeclaration() : this.matchKeyword("function") ? e = this.parseFunctionDeclaration() : this.throwUnexpectedToken({ code: h.InvalidExpression }), this.finalize({
1826
- type: u.ExportNamedDeclaration,
1827
- declaration: e,
1828
- specifiers: [],
1829
- source: null,
1830
- ...this.getItemLocation(t)
1831
- });
1832
- }
1833
- // The module specified part of a import XX from 'MODULESPECIFIER'
1834
- parseModuleSpecifier() {
1835
- const e = this.captureStartMarker(), t = this.rawToken;
1836
- if (t.type === l.StringLiteral)
1837
- return this.readNextRawToken(), this.finalize({
1838
- type: u.Literal,
1839
- value: t.value,
1840
- raw: this.getSourceValue(t),
1841
- isString: !0,
1842
- ...this.getItemLocation(e)
1843
- });
1844
- this.throwError(h.InvalidModuleUri, e);
1845
- }
1846
- parseDefaultSpecifier() {
1847
- const e = this.captureStartMarker(), t = this.parseIdentifier();
1848
- return t || this.throwUnexpectedToken({ code: h.IdentifierExpected }), this.finalize({
1849
- type: u.ImportDefaultSpecifier,
1850
- local: t,
1851
- ...this.getItemLocation(e)
1852
- });
1853
- }
1854
- parseImportDeclaration() {
1855
- this.context.blockContext !== y.None && this.throwUnexpectedToken({ code: h.ModuleImportRootOnly });
1856
- const e = this.captureStartMarker();
1857
- this.expectKeyword(f.Import);
1858
- const t = this.parseDefaultSpecifier();
1859
- this.expectContextualKeyword(te.From);
1860
- const i = this.parseModuleSpecifier();
1861
- return this.finalize({
1862
- type: u.ImportDeclaration,
1863
- specifiers: [t],
1864
- source: i,
1865
- ...this.getItemLocation(e)
1866
- });
1867
- }
1868
- }
1869
- class ot {
1870
- constructor(e, t) {
1871
- this.errorHandler = new _e(), this.errorHandler.tolerant = t ? typeof t.tolerant == "boolean" && t.tolerant : !1, this.scanner = new $e(e, this.errorHandler), this.trackComments = t ? typeof t.comment == "boolean" && t.comment : !1, this.buffer = [];
1872
- }
1873
- errors() {
1874
- return this.errorHandler.errors;
1875
- }
1876
- /**
1877
- * Used by the exposed method 'tokenize'
1878
- */
1879
- getNextToken() {
1880
- if (this.buffer.length === 0) {
1881
- const e = this.scanner.scanComments();
1882
- if (this.trackComments && e.forEach((t) => {
1883
- const i = this.scanner.source.slice(t.start, t.end), r = {
1884
- type: t.multiLine ? u.BlockComment : u.LineComment,
1885
- value: i,
1886
- range: t.range,
1887
- loc: t.loc
1888
- };
1889
- this.buffer.push(r);
1890
- }), !this.scanner.eof()) {
1891
- const t = {
1892
- line: this.scanner.lineNumber,
1893
- column: this.scanner.index - this.scanner.lineStart
1894
- }, i = this.scanner.lex(), r = {
1895
- line: this.scanner.lineNumber,
1896
- column: this.scanner.index - this.scanner.lineStart
1897
- }, s = {
1898
- type: Oe[i.type],
1899
- value: this.scanner.source.slice(i.start, i.end),
1900
- range: [i.start, i.end],
1901
- loc: { start: t, end: r }
1902
- };
1903
- this.buffer.push(s);
1904
- }
1905
- }
1906
- return this.buffer.shift();
1907
- }
1908
- }
1909
- function Re(n, e, t) {
1910
- return new at(n, e, t).parseScript();
1911
- }
1912
- function ct(n, e, t) {
1913
- const i = new ot(n, e), r = [];
1914
- let s;
1915
- try {
1916
- let a;
1917
- for (; a = i.getNextToken(); )
1918
- t && (a = t(a)), r.push(a);
1919
- } catch (a) {
1920
- a instanceof Error && i.errorHandler.tolerate(a);
1921
- }
1922
- return i.errorHandler.tolerant && (s = i.errors()), { tokens: r, errors: s };
1923
- }
1924
- const p = {
1
+ import * as a from "@arcgis/arcade-parser";
2
+ import { Keywords as ee, Literals as te } from "@arcgis/arcade-parser";
3
+ import { CompletionItemKind as m, InsertTextFormat as x, InsertTextMode as L, DiagnosticSeverity as g } from "vscode-languageserver-types";
4
+ import { DiagnosticSeverity as ht } from "vscode-languageserver-types";
5
+ import { isDictionaryVariable as ie, isValueVariable as R, ApiService as ne } from "@arcgis/languages-api-utils";
6
+ const h = {
1925
7
  AlreadyDefined: "AlreadyDefined",
1926
8
  ApiConflict: "ApiConflict",
1927
9
  AssignedNeverUsed: "AssignedNeverUsed",
@@ -1943,61 +25,61 @@ const p = {
1943
25
  UnexpectedEmptyFunction: "UnexpectedEmptyFunction",
1944
26
  UnexpectedPropertyIdentifier: "UnexpectedPropertyIdentifier",
1945
27
  UnknownPropertyIdentifier: "UnknownPropertyIdentifier"
1946
- }, ht = {
1947
- [p.AlreadyDefined]: "'${identifier}' is already defined.",
1948
- [p.ApiConflict]: "'${identifier}' is already defined as an Arcade constant or function.",
1949
- [p.AssignedNeverUsed]: "'${identifier}' is assigned but never used.",
1950
- [p.DefinedNeverAssigned]: "'${identifier}' is defined but never assigned.",
1951
- [p.DefinedNeverUsed]: "'${identifier}' is defined but never used.",
1952
- [p.EmptyBlockStatement]: "Empty block statement.",
1953
- [p.ExecutionError]: "Execution Error: '${stack}'",
1954
- [p.InvalidApiFunctionUsage]: "Arcade function '${identifier}' not used in a call expression.",
1955
- [p.InvalidConstantIdentifier]: "Invalid constant identifier, expecting ${list}.",
1956
- [p.InvalidPropertyIdentifier]: "Invalid property identifier, expecting ${list}.",
1957
- [p.NoArgumentExpected]: "Expecting no argument.",
1958
- [p.NotADictionary]: "'${identifier}' doesn't have properties.",
1959
- [p.NotDefined]: "'${identifier}' is not defined.",
1960
- [p.NotEnoughArguments]: "Expecting at least ${min} argument(s).",
1961
- [p.ProfileVariablesAreImmutable]: "Profile variables cannot be modified.",
1962
- [p.ProfileVariablesConflict]: "'${identifier}' is already defined as a profile variable.",
1963
- [p.ReservedKeyword]: "'${identifier}' is a reserved keyword.",
1964
- [p.TooManyArguments]: "Too many arguments, expecting ${max}.",
1965
- [p.UnexpectedEmptyFunction]: "Unexpected empty function '${identifier}'.",
1966
- [p.UnexpectedPropertyIdentifier]: "Unexpected property identifier.",
1967
- [p.UnknownPropertyIdentifier]: "Unknown property identifier '${identifier}'.",
1968
- ...je
28
+ }, se = {
29
+ [h.AlreadyDefined]: "'${identifier}' is already defined.",
30
+ [h.ApiConflict]: "'${identifier}' is already defined as an Arcade constant or function.",
31
+ [h.AssignedNeverUsed]: "'${identifier}' is assigned but never used.",
32
+ [h.DefinedNeverAssigned]: "'${identifier}' is defined but never assigned.",
33
+ [h.DefinedNeverUsed]: "'${identifier}' is defined but never used.",
34
+ [h.EmptyBlockStatement]: "Empty block statement.",
35
+ [h.ExecutionError]: "Execution Error: '${stack}'",
36
+ [h.InvalidApiFunctionUsage]: "Arcade function '${identifier}' not used in a call expression.",
37
+ [h.InvalidConstantIdentifier]: "Invalid constant identifier, expecting ${list}.",
38
+ [h.InvalidPropertyIdentifier]: "Invalid property identifier, expecting ${list}.",
39
+ [h.NoArgumentExpected]: "Expecting no argument.",
40
+ [h.NotADictionary]: "'${identifier}' doesn't have properties.",
41
+ [h.NotDefined]: "'${identifier}' is not defined.",
42
+ [h.NotEnoughArguments]: "Expecting at least ${min} argument(s).",
43
+ [h.ProfileVariablesAreImmutable]: "Profile variables cannot be modified.",
44
+ [h.ProfileVariablesConflict]: "'${identifier}' is already defined as a profile variable.",
45
+ [h.ReservedKeyword]: "'${identifier}' is a reserved keyword.",
46
+ [h.TooManyArguments]: "Too many arguments, expecting ${max}.",
47
+ [h.UnexpectedEmptyFunction]: "Unexpected empty function '${identifier}'.",
48
+ [h.UnexpectedPropertyIdentifier]: "Unexpected property identifier.",
49
+ [h.UnknownPropertyIdentifier]: "Unknown property identifier '${identifier}'.",
50
+ ...a.DiagnosticMessages
1969
51
  };
1970
- function Q(n, e) {
52
+ function B(n, e) {
1971
53
  return n.line - e.line || n.column - e.column;
1972
54
  }
1973
- function lt(n, e) {
55
+ function re(n, e) {
1974
56
  const t = {
1975
57
  start: n.loc.start,
1976
58
  end: n.loc.end
1977
- }, i = (r) => Dt(t, r.loc);
1978
- return Q(t.start, t.end) < 0 && (t.start = { ...t.start }, e.skipSpaces(t.start), Q(t.start, t.end) < 0 && (t.end = { ...t.end }, e.skipSpaces(t.end, !0))), n.leadingComments?.forEach(i), n.trailingComments?.forEach(i), t;
59
+ }, i = (s) => ae(t, s.loc);
60
+ return B(t.start, t.end) < 0 && (t.start = { ...t.start }, e.skipSpaces(t.start), B(t.start, t.end) < 0 && (t.end = { ...t.end }, e.skipSpaces(t.end, !0))), n.leadingComments?.forEach(i), n.trailingComments?.forEach(i), t;
1979
61
  }
1980
- function Dt(n, e) {
1981
- Q(e.start, n.start) < 0 && (n.start = e.start), Q(n.end, e.end) < 0 && (n.end = e.end);
62
+ function ae(n, e) {
63
+ B(e.start, n.start) < 0 && (n.start = e.start), B(n.end, e.end) < 0 && (n.end = e.end);
1982
64
  }
1983
- const pt = /\S/u;
1984
- function W(n = "") {
1985
- return !pt.test(n);
65
+ const oe = /\S/u;
66
+ function D(n = "") {
67
+ return !oe.test(n);
1986
68
  }
1987
- const se = {
69
+ const V = {
1988
70
  indentWidth: 2,
1989
71
  wrapColumn: 80,
1990
72
  quote: null
1991
73
  };
1992
- function de(n) {
74
+ function O(n) {
1993
75
  return {
1994
- indentWidth: n?.indentWidth ?? se.indentWidth,
1995
- wrapColumn: n?.wrapColumn ?? se.wrapColumn,
1996
- quote: n?.quote ?? se.quote
76
+ indentWidth: n?.indentWidth ?? V.indentWidth,
77
+ wrapColumn: n?.wrapColumn ?? V.wrapColumn,
78
+ quote: n?.quote ?? V.quote
1997
79
  };
1998
80
  }
1999
- const dt = /^\s*/u, mt = /\u000D\u000A|\u000D(?!\u000A)|\u000A|\u2028|\u2029/u;
2000
- class Z {
81
+ const ce = /^\s*/u, le = /\u000D\u000A|\u000D(?!\u000A)|\u000A|\u2028|\u2029/u;
82
+ class M {
2001
83
  // private cachedIndentWidth: number | void = void 0;
2002
84
  constructor(e) {
2003
85
  this.lineRecords = e, this.length = e.length;
@@ -2007,16 +89,16 @@ class Z {
2007
89
  if (typeof e != "string")
2008
90
  return e;
2009
91
  const i = t?.indentWidth;
2010
- return new Z(
2011
- e.split(mt).map((s) => {
2012
- const a = dt.exec(s)?.[0] ?? "";
92
+ return new M(
93
+ e.split(le).map((r) => {
94
+ const o = ce.exec(r)?.[0] ?? "";
2013
95
  return {
2014
- line: s,
2015
- indentation: ft(a, i),
96
+ line: r,
97
+ indentation: ue(o, i),
2016
98
  // Boolean indicating whether this line can be re-indented.
2017
99
  locked: !1,
2018
- sliceStart: a.length,
2019
- sliceEnd: s.length
100
+ sliceStart: o.length,
101
+ sliceEnd: r.length
2020
102
  };
2021
103
  })
2022
104
  );
@@ -2025,15 +107,15 @@ class Z {
2025
107
  return this.sliceString(this.firstPos(), this.lastPos());
2026
108
  }
2027
109
  charAt(e) {
2028
- const { line: t, column: i } = e, r = this.lineRecords[t - 1];
2029
- if (typeof r > "u" || i < 0)
110
+ const { line: t, column: i } = e, s = this.lineRecords[t - 1];
111
+ if (typeof s > "u" || i < 0)
2030
112
  return "";
2031
- const s = this.getIndentationAt(t);
2032
- if (i < s)
113
+ const r = this.getIndentationAt(t);
114
+ if (i < r)
2033
115
  return " ";
2034
- const a = i + r.sliceStart - s;
2035
- return a === r.sliceEnd && t < this.length ? `
2036
- ` : a >= r.sliceEnd ? "" : r.line.charAt(a);
116
+ const o = i + s.sliceStart - r;
117
+ return o === s.sliceEnd && t < this.length ? `
118
+ ` : o >= s.sliceEnd ? "" : s.line.charAt(o);
2037
119
  }
2038
120
  getIndentationAt(e) {
2039
121
  return Math.max(this.lineRecords[e - 1].indentation, 0);
@@ -2044,14 +126,14 @@ class Z {
2044
126
  }
2045
127
  getStatementLineSeparators(e) {
2046
128
  const t = this.slice(e, this.skipSpaces({ ...e }) ?? this.lastPos());
2047
- return t.length === 1 || !W(t.lineRecords[1].line) ? [`
129
+ return t.length === 1 || !D(t.lineRecords[1].line) ? [`
2048
130
  `] : [`
2049
131
  `, `
2050
132
  `];
2051
133
  }
2052
134
  getLeadingCommentSeparators(e) {
2053
135
  const t = this.slice(e, this.skipSpaces({ ...e }) ?? this.lastPos());
2054
- return t.length === 1 ? [" "] : W(t.lineRecords[1].line) ? [`
136
+ return t.length === 1 ? [" "] : D(t.lineRecords[1].line) ? [`
2055
137
  `, `
2056
138
  `] : [`
2057
139
  `];
@@ -2061,14 +143,14 @@ class Z {
2061
143
  return Math.max(e.column, 0) < this.getLineLength(i) ? (e.column += 1, t ? !!this.skipSpaces(e) : !0) : i < this.length ? (e.line += 1, e.column = 0, t ? !!this.skipSpaces(e) : !0) : !1;
2062
144
  }
2063
145
  prevPos(e, t = !1) {
2064
- let i = e.line, r = e.column;
2065
- if (r < 1) {
146
+ let i = e.line, s = e.column;
147
+ if (s < 1) {
2066
148
  if (i -= 1, i < 1)
2067
149
  return !1;
2068
- r = this.getLineLength(i);
150
+ s = this.getLineLength(i);
2069
151
  } else
2070
- r = Math.min(r - 1, this.getLineLength(i));
2071
- return e.line = i, e.column = r, t ? !!this.skipSpaces(e, !0) : !0;
152
+ s = Math.min(s - 1, this.getLineLength(i));
153
+ return e.line = i, e.column = s, t ? !!this.skipSpaces(e, !0) : !0;
2072
154
  }
2073
155
  firstPos() {
2074
156
  return { line: 1, column: 0 };
@@ -2082,11 +164,11 @@ class Z {
2082
164
  skipSpaces(e, t = !1) {
2083
165
  if (t) {
2084
166
  for (; this.prevPos(e); )
2085
- if (!W(this.charAt(e)) && this.nextPos(e))
167
+ if (!D(this.charAt(e)) && this.nextPos(e))
2086
168
  return e;
2087
169
  return null;
2088
170
  } else {
2089
- for (; W(this.charAt(e)); )
171
+ for (; D(this.charAt(e)); )
2090
172
  if (!this.nextPos(e))
2091
173
  return null;
2092
174
  return e;
@@ -2098,29 +180,29 @@ class Z {
2098
180
  if (t ??= this.lastPos(), !e)
2099
181
  throw new Error("cannot slice with end but not start");
2100
182
  const i = this.lineRecords.slice(e.line - 1, t.line);
2101
- return e.line === t.line ? i[0] = O(i[0], e.column, t.column) : (i[0] = O(i[0], e.column), i.push(O(i.pop() ?? i[0], 0, t.column))), new Z(i);
183
+ return e.line === t.line ? i[0] = N(i[0], e.column, t.column) : (i[0] = N(i[0], e.column), i.push(N(i.pop() ?? i[0], 0, t.column))), new M(i);
2102
184
  }
2103
185
  sliceString(e = this.firstPos(), t = this.lastPos()) {
2104
186
  const i = [];
2105
- for (let r = e.line; r <= t.line; r++) {
2106
- let s = this.lineRecords[r - 1];
2107
- r === e.line ? r === t.line ? s = O(s, e.column, t.column) : s = O(s, e.column) : r === t.line && (s = O(s, 0, t.column));
2108
- let a = "";
2109
- const o = Math.max(s.indentation, 0);
2110
- o > 0 && (a += new Array(o + 1).join(" ")), a += s.line.slice(s.sliceStart, s.sliceEnd), i.push(a);
187
+ for (let s = e.line; s <= t.line; s++) {
188
+ let r = this.lineRecords[s - 1];
189
+ s === e.line ? s === t.line ? r = N(r, e.column, t.column) : r = N(r, e.column) : s === t.line && (r = N(r, 0, t.column));
190
+ let o = "";
191
+ const c = Math.max(r.indentation, 0);
192
+ c > 0 && (o += new Array(c + 1).join(" ")), o += r.line.slice(r.sliceStart, r.sliceEnd), i.push(o);
2111
193
  }
2112
194
  return i.join(`
2113
195
  `);
2114
196
  }
2115
197
  }
2116
- function ft(n, e = 2) {
198
+ function ue(n, e = 2) {
2117
199
  let t = 0;
2118
200
  const i = n.length;
2119
- for (let r = 0; r < i; r++)
2120
- switch (n.charCodeAt(r)) {
201
+ for (let s = 0; s < i; s++)
202
+ switch (n.charCodeAt(s)) {
2121
203
  case 9: {
2122
- const s = Math.ceil(t / e) * e;
2123
- s === t ? t += e : t = s;
204
+ const r = Math.ceil(t / e) * e;
205
+ r === t ? t += e : t = r;
2124
206
  break;
2125
207
  }
2126
208
  case 11:
@@ -2138,26 +220,26 @@ function ft(n, e = 2) {
2138
220
  }
2139
221
  return t;
2140
222
  }
2141
- function O(n, e, t) {
2142
- let i = n.sliceStart, r = n.sliceEnd, s = Math.max(n.indentation, 0);
2143
- const a = s + r - i;
2144
- return t ??= a, e = Math.max(e, 0), t = Math.min(t, a), t = Math.max(t, e), t < s ? (s = t, r = i) : r -= a - t, e < s ? s -= e : (e -= s, s = 0, i += e), n.indentation === s && n.sliceStart === i && n.sliceEnd === r ? n : {
223
+ function N(n, e, t) {
224
+ let i = n.sliceStart, s = n.sliceEnd, r = Math.max(n.indentation, 0);
225
+ const o = r + s - i;
226
+ return t ??= o, e = Math.max(e, 0), t = Math.min(t, o), t = Math.max(t, e), t < r ? (r = t, s = i) : s -= o - t, e < r ? r -= e : (e -= r, r = 0, i += e), n.indentation === r && n.sliceStart === i && n.sliceEnd === s ? n : {
2145
227
  line: n.line,
2146
- indentation: s,
228
+ indentation: r,
2147
229
  sliceStart: i,
2148
- sliceEnd: r
230
+ sliceEnd: s
2149
231
  };
2150
232
  }
2151
- function ke(n, e, t) {
233
+ function K(n, e, t) {
2152
234
  return !n && !t ? "" : n ? t ? `${n}${e}${t}` : n : t;
2153
235
  }
2154
- const Ct = /\u000D\u000A|\u000D(?!\u000A)|\u000A|\u2028|\u2029/u;
2155
- class D {
236
+ const he = /\u000D\u000A|\u000D(?!\u000A)|\u000A|\u2028|\u2029/u;
237
+ class u {
2156
238
  constructor(e = []) {
2157
239
  this.lines = e;
2158
240
  }
2159
241
  static fromString(e) {
2160
- return new D(e.split(Ct));
242
+ return new u(e.split(he));
2161
243
  }
2162
244
  /**
2163
245
  * Append the elements lines together into a new FormattedLines.
@@ -2166,7 +248,7 @@ class D {
2166
248
  * @returns
2167
249
  */
2168
250
  static appendLines(e = []) {
2169
- const t = new D();
251
+ const t = new u();
2170
252
  return e.forEach((i) => {
2171
253
  i != null && (typeof i == "string" ? t.lines.push(i) : t.lines.push(...i.lines));
2172
254
  }), t;
@@ -2180,12 +262,12 @@ class D {
2180
262
  * @returns
2181
263
  */
2182
264
  static joinLines(e = [], t = "") {
2183
- const i = new D();
2184
- return e.forEach((r) => {
2185
- if (r == null)
265
+ const i = new u();
266
+ return e.forEach((s) => {
267
+ if (s == null)
2186
268
  return;
2187
- const s = i.lines.pop() ?? "";
2188
- typeof r == "string" ? i.lines.push(ke(s, t, r)) : (i.lines.push(ke(s, t, r.lines.slice(0)[0])), i.lines.push(...r.lines.slice(1)));
269
+ const r = i.lines.pop() ?? "";
270
+ typeof s == "string" ? i.lines.push(K(r, t, s)) : (i.lines.push(K(r, t, s.lines.slice(0)[0])), i.lines.push(...s.lines.slice(1)));
2189
271
  }), i;
2190
272
  }
2191
273
  /**
@@ -2199,16 +281,16 @@ class D {
2199
281
  * @param indentation
2200
282
  * @returns
2201
283
  */
2202
- static aggregateLines(e, t, i, r, s) {
284
+ static aggregateLines(e, t, i, s, r) {
2203
285
  if (i.isEmpty)
2204
286
  return e;
2205
287
  if (!t || e.isEmpty)
2206
- return i.indentFirstLine(s);
2207
- const a = r.start.line - t.end.line;
2208
- if (a === 0)
2209
- return D.joinLines([e, " ", i]);
2210
- const o = a === 1 ? void 0 : "";
2211
- return D.appendLines([e, o, i.indentFirstLine(s)]);
288
+ return i.indentFirstLine(r);
289
+ const o = s.start.line - t.end.line;
290
+ if (o === 0)
291
+ return u.joinLines([e, " ", i]);
292
+ const c = o === 1 ? void 0 : "";
293
+ return u.appendLines([e, c, i.indentFirstLine(r)]);
2212
294
  }
2213
295
  get isEmpty() {
2214
296
  return this.lines.length === 0 || this.lines.length === 1 && this.lines[0].length === 0;
@@ -2223,7 +305,7 @@ class D {
2223
305
  return (this.lines[this.lines.length - 1] ?? "").length;
2224
306
  }
2225
307
  surroundWith(e = "", t = "") {
2226
- return !e && !t ? this : this.isEmpty ? new D([e + t]) : this.lines.length === 1 ? new D([e + this.lines[0] + t]) : D.joinLines([e, this, t]);
308
+ return !e && !t ? this : this.isEmpty ? new u([e + t]) : this.lines.length === 1 ? new u([e + this.lines[0] + t]) : u.joinLines([e, this, t]);
2227
309
  }
2228
310
  indentFirstLine(e = "") {
2229
311
  return this.isEmpty ? this : (this.lines[0] = e + this.lines[0], this);
@@ -2236,53 +318,53 @@ class D {
2236
318
  return this.lines.join(e);
2237
319
  }
2238
320
  }
2239
- function me(n, e) {
321
+ function W(n, e) {
2240
322
  return n * (e.indentWidth ?? 2);
2241
323
  }
2242
- function M(n = 0, e) {
2243
- const { indentWidth: t = 2 } = de(e);
324
+ function w(n = 0, e) {
325
+ const { indentWidth: t = 2 } = O(e);
2244
326
  return new Array(n * t + 1).join(" ");
2245
327
  }
2246
- function K(n) {
328
+ function F(n) {
2247
329
  return n.replace(/['"]/gu, (e) => e === '"' ? "'" : '"');
2248
330
  }
2249
- function Et(n, e) {
331
+ function pe(n, e) {
2250
332
  switch (n.type) {
2251
- case u.UnaryExpression:
2252
- return (Fe(e) || et(e)) && e.object === n;
2253
- case u.BinaryExpression:
2254
- case u.LogicalExpression:
333
+ case a.NodeTypes.UnaryExpression:
334
+ return (a.isMemberExpression(e) || a.isSafeMemberExpression(e)) && e.object === n;
335
+ case a.NodeTypes.BinaryExpression:
336
+ case a.NodeTypes.LogicalExpression:
2255
337
  switch (e.type) {
2256
- case u.UnaryExpression:
338
+ case a.NodeTypes.UnaryExpression:
2257
339
  return !0;
2258
- case u.MemberExpression:
2259
- case u.SafeMemberExpression:
340
+ case a.NodeTypes.MemberExpression:
341
+ case a.NodeTypes.SafeMemberExpression:
2260
342
  return e.object === n;
2261
- case u.BinaryExpression:
2262
- case u.LogicalExpression:
2263
- return q[e.operator] > q[n.operator];
343
+ case a.NodeTypes.BinaryExpression:
344
+ case a.NodeTypes.LogicalExpression:
345
+ return a.OperatorPrecedence[e.operator] > a.OperatorPrecedence[n.operator];
2264
346
  default:
2265
347
  return !1;
2266
348
  }
2267
- case u.Literal:
2268
- return Fe(e) && typeof n.value == "number" && e.object === n;
2269
- case u.AssignmentExpression:
349
+ case a.NodeTypes.Literal:
350
+ return a.isMemberExpression(e) && typeof n.value == "number" && e.object === n;
351
+ case a.NodeTypes.AssignmentExpression:
2270
352
  switch (e.type) {
2271
- case u.UnaryExpression:
2272
- case u.BinaryExpression:
2273
- case u.LogicalExpression:
2274
- case u.ReturnStatement:
353
+ case a.NodeTypes.UnaryExpression:
354
+ case a.NodeTypes.BinaryExpression:
355
+ case a.NodeTypes.LogicalExpression:
356
+ case a.NodeTypes.ReturnStatement:
2275
357
  return !0;
2276
- case u.MemberExpression:
2277
- case u.SafeMemberExpression:
358
+ case a.NodeTypes.MemberExpression:
359
+ case a.NodeTypes.SafeMemberExpression:
2278
360
  return e.object === n;
2279
361
  default:
2280
362
  return !1;
2281
363
  }
2282
- case u.MemberAccessChainExpression:
364
+ case a.NodeTypes.MemberAccessChainExpression:
2283
365
  switch (e.type) {
2284
- case u.MemberExpression:
2285
- case u.SafeMemberExpression:
366
+ case a.NodeTypes.MemberExpression:
367
+ case a.NodeTypes.SafeMemberExpression:
2286
368
  return e.object === n;
2287
369
  default:
2288
370
  return !1;
@@ -2291,101 +373,101 @@ function Et(n, e) {
2291
373
  return !1;
2292
374
  }
2293
375
  }
2294
- function C(n, e, t) {
376
+ function f(n, e, t) {
2295
377
  switch (n?.type) {
2296
- case u.BinaryExpression:
2297
- case u.LogicalExpression:
2298
- return gt(n, e, t);
2299
- case u.AssignmentExpression:
2300
- return new fe(n, e, t);
2301
- case u.MemberExpression:
2302
- case u.SafeMemberExpression:
2303
- return new At(n, e, t);
2304
- case u.Identifier:
2305
- return new le(n, e, t);
2306
- case u.CallExpression:
2307
- return new Ft(n, e, t);
2308
- case u.ObjectExpression:
2309
- return U(n, e, t);
2310
- case u.ArrayExpression:
2311
- return U(n, e, t);
2312
- case u.Literal:
2313
- return new le(n, e, t);
2314
- case u.UpdateExpression:
2315
- case u.UnaryExpression:
2316
- case u.MemberAccessChainExpression:
2317
- return new Ke(n, e, t);
2318
- case u.TemplateLiteral:
2319
- return new Bt(n, e, t);
2320
- case u.VariableDeclaration:
2321
- return new De(n, e, t);
378
+ case a.NodeTypes.BinaryExpression:
379
+ case a.NodeTypes.LogicalExpression:
380
+ return fe(n, e, t);
381
+ case a.NodeTypes.AssignmentExpression:
382
+ return new U(n, e, t);
383
+ case a.NodeTypes.MemberExpression:
384
+ case a.NodeTypes.SafeMemberExpression:
385
+ return new ge(n, e, t);
386
+ case a.NodeTypes.Identifier:
387
+ return new z(n, e, t);
388
+ case a.NodeTypes.CallExpression:
389
+ return new me(n, e, t);
390
+ case a.NodeTypes.ObjectExpression:
391
+ return T(n, e, t);
392
+ case a.NodeTypes.ArrayExpression:
393
+ return T(n, e, t);
394
+ case a.NodeTypes.Literal:
395
+ return new z(n, e, t);
396
+ case a.NodeTypes.UpdateExpression:
397
+ case a.NodeTypes.UnaryExpression:
398
+ case a.NodeTypes.MemberAccessChainExpression:
399
+ return new G(n, e, t);
400
+ case a.NodeTypes.TemplateLiteral:
401
+ return new xe(n, e, t);
402
+ case a.NodeTypes.VariableDeclaration:
403
+ return new _(n, e, t);
2322
404
  default:
2323
405
  throw new Error(`unknown type: ${JSON.stringify(n)}`);
2324
406
  }
2325
407
  }
2326
- function U(n, e, t) {
2327
- const i = new Y(n, e, t);
408
+ function T(n, e, t) {
409
+ const i = new j(n, e, t);
2328
410
  switch (n.type) {
2329
- case u.ArrayExpression:
411
+ case a.NodeTypes.ArrayExpression:
2330
412
  return i.setupCollection(
2331
- n.elements.map((r) => C(r, n, t)),
413
+ n.elements.map((s) => f(s, n, t)),
2332
414
  "SquareBrackets"
2333
415
  ), i;
2334
- case u.ObjectExpression:
416
+ case a.NodeTypes.ObjectExpression:
2335
417
  return i.setupCollection(
2336
- n.properties.map((r) => new yt(r, n, t)),
418
+ n.properties.map((s) => new ye(s, n, t)),
2337
419
  "CurlyBrackets"
2338
420
  ), i;
2339
- case u.VariableDeclaration:
421
+ case a.NodeTypes.VariableDeclaration:
2340
422
  return i.prefix = "var ", i.setupCollection(
2341
- n.declarations.map((r) => We(r, n, t)),
423
+ n.declarations.map((s) => Y(s, n, t)),
2342
424
  "None"
2343
425
  ), i;
2344
- case u.FunctionDeclaration:
426
+ case a.NodeTypes.FunctionDeclaration:
2345
427
  return i.prefix = `function ${n.id.name}`, i.setupCollection(
2346
- n.params.map((r) => C(r, n, t)),
428
+ n.params.map((s) => f(s, n, t)),
2347
429
  "Parentheses"
2348
430
  ), i;
2349
- case u.ForStatement:
431
+ case a.NodeTypes.ForStatement:
2350
432
  return i.prefix = "for ", i.setupCollection(
2351
433
  [
2352
- C(n.init, n, t),
2353
- C(n.test, n, t),
2354
- C(n.update, n, t)
434
+ f(n.init, n, t),
435
+ f(n.test, n, t),
436
+ f(n.update, n, t)
2355
437
  ],
2356
438
  "Parentheses",
2357
439
  ";"
2358
440
  ), i;
2359
- case u.ForInStatement:
2360
- case u.ForOfStatement:
2361
- return i.prefix = "for ", i.setupCollection([new fe(n, e, t)], "Parentheses", ""), i;
2362
- case u.IfStatement:
2363
- return i.prefix = "if ", i.setupCollection([C(n.test, n, t)], "Parentheses", ""), i;
2364
- case u.WhileStatement:
2365
- return i.prefix = "while ", i.setupCollection([C(n.test, n, t)], "Parentheses", ""), i;
441
+ case a.NodeTypes.ForInStatement:
442
+ case a.NodeTypes.ForOfStatement:
443
+ return i.prefix = "for ", i.setupCollection([new U(n, e, t)], "Parentheses", ""), i;
444
+ case a.NodeTypes.IfStatement:
445
+ return i.prefix = "if ", i.setupCollection([f(n.test, n, t)], "Parentheses", ""), i;
446
+ case a.NodeTypes.WhileStatement:
447
+ return i.prefix = "while ", i.setupCollection([f(n.test, n, t)], "Parentheses", ""), i;
2366
448
  default:
2367
449
  return i;
2368
450
  }
2369
451
  }
2370
- function We(n, e, t) {
2371
- return n.init ? new fe(n, e, t) : new le(n.id, e, t);
452
+ function Y(n, e, t) {
453
+ return n.init ? new U(n, e, t) : new z(n.id, e, t);
2372
454
  }
2373
- function gt(n, e, t) {
2374
- const r = [
2375
- ...X(n.left, n.operator),
2376
- ...X(n.right, n.operator)
2377
- ].map((a) => C(a, n, t)), s = new Y(n, e, t);
2378
- return s.setupCollection(r, "None", ` ${n.operator}`), s;
455
+ function fe(n, e, t) {
456
+ const s = [
457
+ ...$(n.left, n.operator),
458
+ ...$(n.right, n.operator)
459
+ ].map((o) => f(o, n, t)), r = new j(n, e, t);
460
+ return r.setupCollection(s, "None", ` ${n.operator}`), r;
2379
461
  }
2380
- function X(n, e) {
2381
- return n.type !== u.BinaryExpression && n.type !== u.LogicalExpression ? [n] : n.operator !== e ? [n] : [
2382
- ...X(n.left, e),
2383
- ...X(n.right, e)
462
+ function $(n, e) {
463
+ return n.type !== a.NodeTypes.BinaryExpression && n.type !== a.NodeTypes.LogicalExpression ? [n] : n.operator !== e ? [n] : [
464
+ ...$(n.left, e),
465
+ ...$(n.right, e)
2384
466
  ];
2385
467
  }
2386
- class L {
468
+ class E {
2387
469
  constructor(e, t, i) {
2388
- this.node = e, this.parent = t, this.options = i, this.prefix = "", this.suffix = "", this.groupingParentheses = !1, this.groupingParentheses = Et(e, t);
470
+ this.node = e, this.parent = t, this.options = i, this.prefix = "", this.suffix = "", this.groupingParentheses = !1, this.groupingParentheses = pe(e, t);
2389
471
  }
2390
472
  get openingParenthesis() {
2391
473
  return this.groupingParentheses ? "(" : "";
@@ -2400,10 +482,10 @@ class L {
2400
482
  return [this.closingParenthesis, this.suffix].join("");
2401
483
  }
2402
484
  finalize(e) {
2403
- return typeof e == "string" && (e = D.fromString(e)), e.surroundWith(this.leadingString, this.trailingString);
485
+ return typeof e == "string" && (e = u.fromString(e)), e.surroundWith(this.leadingString, this.trailingString);
2404
486
  }
2405
487
  }
2406
- class Y extends L {
488
+ class j extends E {
2407
489
  constructor(e, t, i) {
2408
490
  super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "CollectionPrinter", this.bracketsType = "None", this.separator = ",", this.printers = [];
2409
491
  }
@@ -2439,251 +521,251 @@ class Y extends L {
2439
521
  }
2440
522
  }
2441
523
  getLinesLevel(e = 0) {
2442
- return this.bracketsType !== "None" || Ye(this.parent) || Ve(this.parent) || (ce(this.node) || oe(this.node)) && (ce(this.parent) || oe(this.parent)) ? e + 1 : e;
524
+ return this.bracketsType !== "None" || a.isExpressionStatement(this.parent) || a.isVariableDeclarator(this.parent) || (a.isLogicalExpression(this.node) || a.isBinaryExpression(this.node)) && (a.isLogicalExpression(this.parent) || a.isBinaryExpression(this.parent)) ? e + 1 : e;
2443
525
  }
2444
526
  finalize(e, t = "singleLine", i = 0) {
2445
527
  if (this.bracketsType === "None")
2446
528
  return super.finalize(e);
2447
- const r = this.getOpeningBracket(e.isEmpty, t), s = this.getClosingBracket(e.isEmpty, t);
529
+ const s = this.getOpeningBracket(e.isEmpty, t), r = this.getClosingBracket(e.isEmpty, t);
2448
530
  if (t === "singleLine")
2449
- return super.finalize(e.surroundWith(r, s));
2450
- const a = M(i, this.options);
2451
- return super.finalize(D.appendLines([r, e, a + s]));
531
+ return super.finalize(e.surroundWith(s, r));
532
+ const o = w(i, this.options);
533
+ return super.finalize(u.appendLines([s, e, o + r]));
2452
534
  }
2453
535
  singleLineFormat(e = 0) {
2454
536
  const t = this.printers.length - 1;
2455
- return D.joinLines(
537
+ return u.joinLines(
2456
538
  this.printers.map(
2457
- (i, r) => i.format("singleLine", e).suffixWith(r < t ? this.separator : "")
539
+ (i, s) => i.format("singleLine", e).suffixWith(s < t ? this.separator : "")
2458
540
  ),
2459
541
  " "
2460
542
  );
2461
543
  }
2462
544
  optimizedPrinterFormat(e, t, i = 0) {
2463
- const r = this.getLinesLevel(i), s = M(r, this.options), a = this.bracketsType === "None" && t === 0 ? "" : s, o = t < this.printers.length - 1 ? this.separator : "", c = e.format("singleLine", r).suffixWith(o);
2464
- return c.maxLineLength + s.length <= this.options.wrapColumn ? c.indentFirstLine(a) : e.format("multiline", r).suffixWith(o).indentFirstLine(a);
545
+ const s = this.getLinesLevel(i), r = w(s, this.options), o = this.bracketsType === "None" && t === 0 ? "" : r, c = t < this.printers.length - 1 ? this.separator : "", l = e.format("singleLine", s).suffixWith(c);
546
+ return l.maxLineLength + r.length <= this.options.wrapColumn ? l.indentFirstLine(o) : e.format("multiline", s).suffixWith(c).indentFirstLine(o);
2465
547
  }
2466
548
  multilineFormat(e = 0) {
2467
- return D.appendLines(
549
+ return u.appendLines(
2468
550
  this.printers.map((t, i) => this.optimizedPrinterFormat(t, i, e))
2469
551
  );
2470
552
  }
2471
553
  format(e = "singleLine", t = 0) {
2472
554
  if (this.printers.length === 0) {
2473
- const r = this.getOpeningBracket(!0, e), s = this.getClosingBracket(!0, e);
2474
- return super.finalize(D.fromString(r + s));
555
+ const s = this.getOpeningBracket(!0, e), r = this.getClosingBracket(!0, e);
556
+ return super.finalize(u.fromString(s + r));
2475
557
  }
2476
558
  if (e === "singleLine") {
2477
- const r = this.singleLineFormat(t);
2478
- return this.finalize(r, e, t);
559
+ const s = this.singleLineFormat(t);
560
+ return this.finalize(s, e, t);
2479
561
  }
2480
562
  const i = this.multilineFormat(t);
2481
563
  return this.finalize(i, e, t);
2482
564
  }
2483
565
  }
2484
- const xt = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/u;
2485
- class le extends L {
566
+ const de = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/u;
567
+ class z extends E {
2486
568
  constructor(e, t, i) {
2487
569
  super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "StringPrinter";
2488
570
  }
2489
571
  format() {
2490
- if (I(this.node))
572
+ if (a.isIdentifier(this.node))
2491
573
  return this.finalize(this.node.name);
2492
574
  if (typeof this.node.value != "string")
2493
575
  return this.finalize(this.node.raw);
2494
- if (rt(this.parent) && this.parent.key === this.node && ze(this.node) && typeof this.node.value == "string" && xt.test(this.node.value))
576
+ if (a.isProperty(this.parent) && this.parent.key === this.node && a.isLiteral(this.node) && typeof this.node.value == "string" && de.test(this.node.value))
2495
577
  return this.finalize(this.node.value);
2496
578
  switch (this.options.quote) {
2497
579
  case "auto": {
2498
- const e = JSON.stringify(this.node.value), t = K(JSON.stringify(K(this.node.value)));
580
+ const e = JSON.stringify(this.node.value), t = F(JSON.stringify(F(this.node.value)));
2499
581
  return this.finalize(e.length > t.length ? t : e);
2500
582
  }
2501
583
  case "single":
2502
- return this.finalize(K(JSON.stringify(K(this.node.value))));
584
+ return this.finalize(F(JSON.stringify(F(this.node.value))));
2503
585
  default:
2504
586
  return this.finalize(JSON.stringify(this.node.value));
2505
587
  }
2506
588
  }
2507
589
  }
2508
- class Ke extends L {
590
+ class G extends E {
2509
591
  constructor(e, t, i) {
2510
592
  super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "SingleExpressionPrinter";
2511
- const r = it(e), s = nt(e);
2512
- if (r || s) {
2513
- this.prefix = r ? e.operator : "", this.suffix = s && !e.prefix ? e.operator : "", this.printer = C(e.argument, e, this.options);
593
+ const s = a.isUnaryExpression(e), r = a.isUpdateExpression(e);
594
+ if (s || r) {
595
+ this.prefix = s ? e.operator : "", this.suffix = r && !e.prefix ? e.operator : "", this.printer = f(e.argument, e, this.options);
2514
596
  return;
2515
597
  }
2516
- if (tt(e)) {
2517
- this.printer = C(e.expression, e, this.options);
598
+ if (a.isMemberAccessChainExpression(e)) {
599
+ this.printer = f(e.expression, e, this.options);
2518
600
  return;
2519
601
  }
2520
- this.printer = C(e, t, this.options);
602
+ this.printer = f(e, t, this.options);
2521
603
  }
2522
604
  format(e = "singleLine", t = 0) {
2523
605
  return this.finalize(this.printer.format(e, t));
2524
606
  }
2525
607
  }
2526
- class De extends L {
608
+ class _ extends E {
2527
609
  constructor(e, t, i) {
2528
- super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "VariableDeclaratorsPrinter", e.declarations.length === 1 ? (this.printer = We(e.declarations[0], e, this.options), this.printer.prefix = "var ") : this.printer = U(e, t, this.options);
610
+ super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "VariableDeclaratorsPrinter", e.declarations.length === 1 ? (this.printer = Y(e.declarations[0], e, this.options), this.printer.prefix = "var ") : this.printer = T(e, t, this.options);
2529
611
  }
2530
612
  format(e = "singleLine", t = 0) {
2531
613
  return this.finalize(this.printer.format(e, t));
2532
614
  }
2533
615
  }
2534
- class Ft extends L {
616
+ class me extends E {
2535
617
  constructor(e, t, i) {
2536
- super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "CallExpressionPrinter", this.argumentsPrinter = new Y(e, t, i), this.argumentsPrinter.setupCollection(
2537
- e.arguments.map((r) => C(r, e, i)),
618
+ super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "CallExpressionPrinter", this.argumentsPrinter = new j(e, t, i), this.argumentsPrinter.setupCollection(
619
+ e.arguments.map((s) => f(s, e, i)),
2538
620
  "Parentheses"
2539
- ), I(e.callee) ? this.argumentsPrinter.prefix = e.callee.name : this.calleePrinter = C(e.callee, t, i);
621
+ ), a.isIdentifier(e.callee) ? this.argumentsPrinter.prefix = e.callee.name : this.calleePrinter = f(e.callee, t, i);
2540
622
  }
2541
623
  format(e = "singleLine", t = 0) {
2542
624
  if (!this.calleePrinter)
2543
625
  return this.finalize(this.argumentsPrinter.format(e, t));
2544
- let i = this.calleePrinter.format("singleLine", t), r = this.argumentsPrinter.format("singleLine", t);
626
+ let i = this.calleePrinter.format("singleLine", t), s = this.argumentsPrinter.format("singleLine", t);
2545
627
  if (e === "singleLine")
2546
- return this.finalize(D.joinLines([i, r]));
2547
- let s = me(t, this.options) + this.leadingString.length + i.firstLineLength;
2548
- return s + 1 < this.options.wrapColumn ? (r = this.argumentsPrinter.format("multiline", t), this.finalize(D.joinLines([i, r]))) : (i = this.calleePrinter.format("multiline", t), s = i.lastLineLength, s + r.maxLineLength > this.options.wrapColumn && (r = this.argumentsPrinter.format("multiline", t + 1)), this.finalize(D.joinLines([i, r])));
628
+ return this.finalize(u.joinLines([i, s]));
629
+ let r = W(t, this.options) + this.leadingString.length + i.firstLineLength;
630
+ return r + 1 < this.options.wrapColumn ? (s = this.argumentsPrinter.format("multiline", t), this.finalize(u.joinLines([i, s]))) : (i = this.calleePrinter.format("multiline", t), r = i.lastLineLength, r + s.maxLineLength > this.options.wrapColumn && (s = this.argumentsPrinter.format("multiline", t + 1)), this.finalize(u.joinLines([i, s])));
2549
631
  }
2550
632
  }
2551
- class At extends L {
633
+ class ge extends E {
2552
634
  constructor(e, t, i) {
2553
- if (super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "MemberExpressionPrinter", this.objectPrinter = C(e.object, e, this.options), e.computed) {
2554
- const r = new Y(e.property, e, this.options);
2555
- r.setupCollection([C(e.property, e, this.options)], "SquareBrackets"), r.prefix = e.type === "SafeMemberExpression" ? w : "", this.propertyPrinter = r;
635
+ if (super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "MemberExpressionPrinter", this.objectPrinter = f(e.object, e, this.options), e.computed) {
636
+ const s = new j(e.property, e, this.options);
637
+ s.setupCollection([f(e.property, e, this.options)], "SquareBrackets"), s.prefix = e.type === "SafeMemberExpression" ? a.SafeAccessOperator : "", this.propertyPrinter = s;
2556
638
  } else {
2557
- const r = new Ke(e.property, e, this.options);
2558
- r.prefix = e.type === "SafeMemberExpression" ? w : ".", this.propertyPrinter = r;
639
+ const s = new G(e.property, e, this.options);
640
+ s.prefix = e.type === "SafeMemberExpression" ? a.SafeAccessOperator : ".", this.propertyPrinter = s;
2559
641
  }
2560
642
  }
2561
643
  format(e = "singleLine", t = 0) {
2562
- let i = this.objectPrinter.format("singleLine", t), r = this.propertyPrinter.format("singleLine", t);
644
+ let i = this.objectPrinter.format("singleLine", t), s = this.propertyPrinter.format("singleLine", t);
2563
645
  if (e === "singleLine")
2564
- return this.finalize(D.joinLines([i, r]));
2565
- let s = me(t, this.options) + this.leadingString.length + i.firstLineLength;
2566
- s > this.options.wrapColumn && (i = this.objectPrinter.format("multiline", t), s = i.lastLineLength);
2567
- let a = r.firstLineLength + this.trailingString.length;
2568
- if (s + a < this.options.wrapColumn)
2569
- return this.finalize(D.joinLines([i, r]));
646
+ return this.finalize(u.joinLines([i, s]));
647
+ let r = W(t, this.options) + this.leadingString.length + i.firstLineLength;
648
+ r > this.options.wrapColumn && (i = this.objectPrinter.format("multiline", t), r = i.lastLineLength);
649
+ let o = s.firstLineLength + this.trailingString.length;
650
+ if (r + o < this.options.wrapColumn)
651
+ return this.finalize(u.joinLines([i, s]));
2570
652
  if (this.node.computed)
2571
- return this.finalize(D.joinLines([i, this.propertyPrinter.format("multiline", t)]));
2572
- const o = t + 1, c = M(o, this.options);
2573
- return r = this.propertyPrinter.format("singleLine", t), a = c.length + r.lastLineLength + this.trailingString.length, a > this.options.wrapColumn && (r = this.propertyPrinter.format("multiline", o)), this.finalize(D.appendLines([i, r.indentFirstLine(c)]));
653
+ return this.finalize(u.joinLines([i, this.propertyPrinter.format("multiline", t)]));
654
+ const c = t + 1, l = w(c, this.options);
655
+ return s = this.propertyPrinter.format("singleLine", t), o = l.length + s.lastLineLength + this.trailingString.length, o > this.options.wrapColumn && (s = this.propertyPrinter.format("multiline", c)), this.finalize(u.appendLines([i, s.indentFirstLine(l)]));
2574
656
  }
2575
657
  }
2576
- class yt extends L {
658
+ class ye extends E {
2577
659
  constructor(e, t, i) {
2578
- super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "PropertyPrinter", this.key = C(e.key, e, this.options), e.shorthand || (this.key.suffix = ":", this.value = C(e.value, e, this.options));
660
+ super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "PropertyPrinter", this.key = f(e.key, e, this.options), e.shorthand || (this.key.suffix = ":", this.value = f(e.value, e, this.options));
2579
661
  }
2580
662
  format(e = "singleLine", t = 0) {
2581
663
  if (this.node.shorthand || !this.value)
2582
664
  return this.finalize(this.key.format(e, t));
2583
665
  const i = this.key.format("singleLine", t);
2584
666
  if (e === "singleLine") {
2585
- const o = this.value.format("singleLine", t);
2586
- return this.finalize(D.joinLines([i, o], " "));
667
+ const c = this.value.format("singleLine", t);
668
+ return this.finalize(u.joinLines([i, c], " "));
2587
669
  }
2588
- if (J(this.node.value) || J(this.node.value)) {
2589
- const o = this.value.format("multiline", t);
2590
- return this.finalize(D.joinLines([i, o], " "));
670
+ if (a.isArrayExpression(this.node.value) || a.isArrayExpression(this.node.value)) {
671
+ const c = this.value.format("multiline", t);
672
+ return this.finalize(u.joinLines([i, c], " "));
2591
673
  }
2592
- const r = M(t + 1, this.options);
2593
- let s = this.value.format("singleLine", t + 1).indentFirstLine(r);
2594
- return s.maxLineLength + this.trailingString.length + 1 <= this.options.wrapColumn ? this.finalize(D.appendLines([i, s])) : (s = this.value.format("multiline", t + 1).indentFirstLine(r), this.finalize(D.appendLines([i, s])));
674
+ const s = w(t + 1, this.options);
675
+ let r = this.value.format("singleLine", t + 1).indentFirstLine(s);
676
+ return r.maxLineLength + this.trailingString.length + 1 <= this.options.wrapColumn ? this.finalize(u.appendLines([i, r])) : (r = this.value.format("multiline", t + 1).indentFirstLine(s), this.finalize(u.appendLines([i, r])));
2595
677
  }
2596
678
  }
2597
- class fe extends L {
679
+ class U extends E {
2598
680
  constructor(e, t, i) {
2599
681
  switch (super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "OperationPrinter", this.operator = "", this.noNewLineWrapping = !1, e.type) {
2600
- case u.AssignmentExpression:
2601
- this.leftPrinter = C(e.left, e, this.options), this.operator = ` ${e.operator}`, this.rightPrinter = C(e.right, e, this.options), this.noNewLineWrapping = (I(e.left) || ze(e.left)) && (J(e.right) || xe(e.right));
682
+ case a.NodeTypes.AssignmentExpression:
683
+ this.leftPrinter = f(e.left, e, this.options), this.operator = ` ${e.operator}`, this.rightPrinter = f(e.right, e, this.options), this.noNewLineWrapping = (a.isIdentifier(e.left) || a.isLiteral(e.left)) && (a.isArrayExpression(e.right) || a.isObjectExpression(e.right));
2602
684
  return;
2603
- case u.VariableDeclarator:
2604
- this.leftPrinter = C(e.id, e, this.options), e.init && (this.operator = " =", this.rightPrinter = C(e.init, e, this.options)), this.noNewLineWrapping = J(e.init) || xe(e.init);
685
+ case a.NodeTypes.VariableDeclarator:
686
+ this.leftPrinter = f(e.id, e, this.options), e.init && (this.operator = " =", this.rightPrinter = f(e.init, e, this.options)), this.noNewLineWrapping = a.isArrayExpression(e.init) || a.isObjectExpression(e.init);
2605
687
  return;
2606
- case u.ForInStatement:
2607
- case u.ForOfStatement:
2608
- this.leftPrinter = C(e.left, e, this.options), this.operator = e.type === "ForInStatement" ? " in" : " of", this.rightPrinter = C(e.right, e, this.options);
688
+ case a.NodeTypes.ForInStatement:
689
+ case a.NodeTypes.ForOfStatement:
690
+ this.leftPrinter = f(e.left, e, this.options), this.operator = e.type === "ForInStatement" ? " in" : " of", this.rightPrinter = f(e.right, e, this.options);
2609
691
  return;
2610
- case u.BinaryExpression:
2611
- case u.LogicalExpression:
2612
- this.leftPrinter = C(e.left, e, this.options), this.operator = ` ${e.operator}`, this.rightPrinter = C(e.right, e, this.options);
692
+ case a.NodeTypes.BinaryExpression:
693
+ case a.NodeTypes.LogicalExpression:
694
+ this.leftPrinter = f(e.left, e, this.options), this.operator = ` ${e.operator}`, this.rightPrinter = f(e.right, e, this.options);
2613
695
  return;
2614
696
  }
2615
697
  }
2616
698
  format(e = "singleLine", t = 0) {
2617
699
  if (!this.rightPrinter)
2618
700
  return this.finalize(this.leftPrinter.format(e, t));
2619
- let i = this.leftPrinter.format("singleLine", t).suffixWith(this.operator), r = this.rightPrinter.format("singleLine", t);
701
+ let i = this.leftPrinter.format("singleLine", t).suffixWith(this.operator), s = this.rightPrinter.format("singleLine", t);
2620
702
  if (e === "singleLine")
2621
- return this.finalize(D.joinLines([i, r], " "));
2622
- let s = me(t, this.options) + this.leadingString.length + i.maxLineLength + 1;
2623
- s > this.options.wrapColumn && (i = this.leftPrinter.format("multiline", t).suffixWith(this.operator), s = i.lastLineLength + 1);
2624
- const a = r.firstLineLength + this.trailingString.length + 1;
2625
- if (s + a < this.options.wrapColumn)
2626
- return this.finalize(D.joinLines([i, r], " "));
2627
- const o = this.rightPrinter.format("multiline", t);
2628
- return o.firstLineLength + this.trailingString.length + 1 + s < this.options.wrapColumn || this.noNewLineWrapping ? this.finalize(D.joinLines([i, o], " ")) : (a > this.options.wrapColumn && (r = this.rightPrinter.format("multiline", t + 1)), r = r.indentFirstLine(M(t + 1)), this.finalize(D.appendLines([i, r])));
703
+ return this.finalize(u.joinLines([i, s], " "));
704
+ let r = W(t, this.options) + this.leadingString.length + i.maxLineLength + 1;
705
+ r > this.options.wrapColumn && (i = this.leftPrinter.format("multiline", t).suffixWith(this.operator), r = i.lastLineLength + 1);
706
+ const o = s.firstLineLength + this.trailingString.length + 1;
707
+ if (r + o < this.options.wrapColumn)
708
+ return this.finalize(u.joinLines([i, s], " "));
709
+ const c = this.rightPrinter.format("multiline", t);
710
+ return c.firstLineLength + this.trailingString.length + 1 + r < this.options.wrapColumn || this.noNewLineWrapping ? this.finalize(u.joinLines([i, c], " ")) : (o > this.options.wrapColumn && (s = this.rightPrinter.format("multiline", t + 1)), s = s.indentFirstLine(w(t + 1)), this.finalize(u.appendLines([i, s])));
2629
711
  }
2630
712
  }
2631
- class Bt extends L {
713
+ class xe extends E {
2632
714
  constructor(e, t, i) {
2633
715
  super(e, t, i), this.node = e, this.parent = t, this.options = i, this.type = "TemplateLiteralPrinter", this.parts = [];
2634
- const r = e.expressions.map(
2635
- (s) => C(s, e, this.options)
716
+ const s = e.expressions.map(
717
+ (r) => f(r, e, this.options)
2636
718
  );
2637
- this.parts.push("`"), e.quasis.forEach((s, a) => {
2638
- this.parts.push(s.value.raw), a < r.length && (this.parts.push("${"), this.parts.push(r[a]), this.parts.push("}"));
719
+ this.parts.push("`"), e.quasis.forEach((r, o) => {
720
+ this.parts.push(r.value.raw), o < s.length && (this.parts.push("${"), this.parts.push(s[o]), this.parts.push("}"));
2639
721
  }), this.parts.push("`");
2640
722
  }
2641
723
  format(e = "singleLine", t = 0) {
2642
724
  return this.finalize(
2643
- D.joinLines(this.parts.map((i) => typeof i == "string" ? i : i.format(e, t)))
725
+ u.joinLines(this.parts.map((i) => typeof i == "string" ? i : i.format(e, t)))
2644
726
  );
2645
727
  }
2646
728
  }
2647
- function St(n) {
729
+ function Le(n) {
2648
730
  const e = { ...n.leadingComments?.slice(0, 1)[0]?.loc.start ?? n.loc.start }, t = { ...n.trailingComments?.slice(-1)[0]?.loc.end ?? n.loc.end };
2649
731
  return { start: e, end: t };
2650
732
  }
2651
- function It(n) {
2652
- return n.trailingComments?.slice(-1)[0]?.type === u.LineComment;
733
+ function Ee(n) {
734
+ return n.trailingComments?.slice(-1)[0]?.type === a.NodeTypes.LineComment;
2653
735
  }
2654
- class T {
736
+ class I {
2655
737
  constructor(e, t, i) {
2656
- this.node = e, this.parent = t, this.options = i, this.indentStatementFirstLine = !0, this.externalOffset = 0, this.options = de(this.options);
738
+ this.node = e, this.parent = t, this.options = i, this.indentStatementFirstLine = !0, this.externalOffset = 0, this.options = O(this.options);
2657
739
  }
2658
740
  createStatementPrinter(e) {
2659
741
  switch (e.type) {
2660
- case u.Program:
2661
- return new $(e, this.node, this.options);
2662
- case u.ImportDeclaration:
2663
- return new vt(e, this.node, this.options);
2664
- case u.ExpressionStatement:
2665
- return new Lt(e, this.node, this.options);
2666
- case u.FunctionDeclaration:
742
+ case a.NodeTypes.Program:
743
+ return new A(e, this.node, this.options);
744
+ case a.NodeTypes.ImportDeclaration:
745
+ return new Ne(e, this.node, this.options);
746
+ case a.NodeTypes.ExpressionStatement:
747
+ return new we(e, this.node, this.options);
748
+ case a.NodeTypes.FunctionDeclaration:
749
+ return new Q(e, this.node, this.options);
750
+ case a.NodeTypes.ExportNamedDeclaration:
751
+ return a.isVariableDeclaration(e) ? new J(e, this.node, this.options) : new Q(e, this.node, this.options);
752
+ case a.NodeTypes.BlockStatement:
753
+ return new A(e, this.node, this.options);
754
+ case a.NodeTypes.ReturnStatement:
2667
755
  return new Te(e, this.node, this.options);
2668
- case u.ExportNamedDeclaration:
2669
- return G(e) ? new Le(e, this.node, this.options) : new Te(e, this.node, this.options);
2670
- case u.BlockStatement:
2671
- return new $(e, this.node, this.options);
2672
- case u.ReturnStatement:
2673
- return new Tt(e, this.node, this.options);
2674
- case u.VariableDeclaration:
2675
- return new Le(e, this.node, this.options);
2676
- case u.IfStatement:
2677
- return new wt(e, this.node, this.options);
2678
- case u.ForStatement:
2679
- case u.ForInStatement:
2680
- case u.ForOfStatement:
2681
- case u.WhileStatement:
2682
- return new kt(e, this.node, this.options);
2683
- case u.EmptyStatement:
2684
- case u.BreakStatement:
2685
- case u.ContinueStatement:
2686
- return new bt(e, this.node, this.options);
756
+ case a.NodeTypes.VariableDeclaration:
757
+ return new J(e, this.node, this.options);
758
+ case a.NodeTypes.IfStatement:
759
+ return new Se(e, this.node, this.options);
760
+ case a.NodeTypes.ForStatement:
761
+ case a.NodeTypes.ForInStatement:
762
+ case a.NodeTypes.ForOfStatement:
763
+ case a.NodeTypes.WhileStatement:
764
+ return new be(e, this.node, this.options);
765
+ case a.NodeTypes.EmptyStatement:
766
+ case a.NodeTypes.BreakStatement:
767
+ case a.NodeTypes.ContinueStatement:
768
+ return new Ie(e, this.node, this.options);
2687
769
  default:
2688
770
  throw new Error(`unknown type: ${JSON.stringify(e)}`);
2689
771
  }
@@ -2702,7 +784,7 @@ class T {
2702
784
  return this.cachedBody = { body: i, level: t }, i;
2703
785
  }
2704
786
  getStatementIndentation(e = 0) {
2705
- return this.indentStatementFirstLine ? M(e, this.options) : "";
787
+ return this.indentStatementFirstLine ? w(e, this.options) : "";
2706
788
  }
2707
789
  getStatementIndentationLength(e = 0) {
2708
790
  return this.indentStatementFirstLine ? e * this.options.indentWidth : 0;
@@ -2713,7 +795,7 @@ class T {
2713
795
  * @returns
2714
796
  */
2715
797
  getIndentation(e = 0) {
2716
- return M(e, this.options);
798
+ return w(e, this.options);
2717
799
  }
2718
800
  /**
2719
801
  * Once the statement has been formatted, we need to wrap the leading and the
@@ -2726,68 +808,68 @@ class T {
2726
808
  const i = this.getStatementIndentation(t);
2727
809
  if (!this.node.leadingComments?.length && !this.node.trailingComments?.length)
2728
810
  return e.indentFirstLine(i);
2729
- const r = (this.node.leadingComments ?? []).reduce(
2730
- (o, c) => {
2731
- const d = this.formatComment(c);
811
+ const s = (this.node.leadingComments ?? []).reduce(
812
+ (c, l) => {
813
+ const p = this.formatComment(l);
2732
814
  return {
2733
- formattedLines: D.aggregateLines(
2734
- o.formattedLines,
2735
- o.location,
2736
- d,
2737
- c.loc,
815
+ formattedLines: u.aggregateLines(
816
+ c.formattedLines,
817
+ c.location,
818
+ p,
819
+ l.loc,
2738
820
  i
2739
821
  ),
2740
- location: c.loc
822
+ location: l.loc
2741
823
  };
2742
824
  },
2743
- { formattedLines: new D() }
2744
- ), s = D.aggregateLines(
2745
- r.formattedLines,
2746
- r.location,
825
+ { formattedLines: new u() }
826
+ ), r = u.aggregateLines(
827
+ s.formattedLines,
828
+ s.location,
2747
829
  e,
2748
830
  this.node.loc,
2749
831
  i
2750
832
  );
2751
833
  return (this.node.trailingComments?.reduce(
2752
- (o, c) => {
2753
- const d = this.formatComment(c);
834
+ (c, l) => {
835
+ const p = this.formatComment(l);
2754
836
  return {
2755
- formattedLines: D.aggregateLines(
2756
- o.formattedLines,
2757
- o.location,
2758
- d,
2759
- c.loc,
837
+ formattedLines: u.aggregateLines(
838
+ c.formattedLines,
839
+ c.location,
840
+ p,
841
+ l.loc,
2760
842
  i
2761
843
  ),
2762
- location: c.loc
844
+ location: l.loc
2763
845
  };
2764
846
  },
2765
- { formattedLines: s, location: this.node.loc }
2766
- ) ?? { formattedLines: s }).formattedLines;
847
+ { formattedLines: r, location: this.node.loc }
848
+ ) ?? { formattedLines: r }).formattedLines;
2767
849
  }
2768
850
  formatInnerComments(e = 0) {
2769
- if (!b(this.node) || !Array.isArray(this.node.innerComments) || !this.node.innerComments.length)
2770
- return new D();
851
+ if (!a.isBlockStatement(this.node) || !Array.isArray(this.node.innerComments) || !this.node.innerComments.length)
852
+ return new u();
2771
853
  const t = this.getIndentation(e);
2772
854
  return this.node.innerComments.reduce(
2773
- (r, s) => {
2774
- const a = this.formatComment(s);
855
+ (s, r) => {
856
+ const o = this.formatComment(r);
2775
857
  return {
2776
- formattedLines: D.aggregateLines(
2777
- r.formattedLines,
2778
- r.location,
2779
- a,
2780
- s.loc,
858
+ formattedLines: u.aggregateLines(
859
+ s.formattedLines,
860
+ s.location,
861
+ o,
862
+ r.loc,
2781
863
  t
2782
864
  ),
2783
- location: s.loc
865
+ location: r.loc
2784
866
  };
2785
867
  },
2786
- { formattedLines: new D() }
868
+ { formattedLines: new u() }
2787
869
  ).formattedLines;
2788
870
  }
2789
871
  formatComment(e) {
2790
- return e.type === u.BlockComment ? D.fromString(e.value).surroundWith("/*", "*/") : D.fromString(e.value.trimEnd()).surroundWith("//");
872
+ return e.type === a.NodeTypes.BlockComment ? u.fromString(e.value).surroundWith("/*", "*/") : u.fromString(e.value.trimEnd()).surroundWith("//");
2791
873
  }
2792
874
  /**
2793
875
  * Invoked for a single line format. Measure is the length of the statement would fit
@@ -2801,38 +883,38 @@ class T {
2801
883
  return this.externalOffset + i + this.getStatementIndentationLength(t) + e.lastLineLength <= this.options.wrapColumn;
2802
884
  }
2803
885
  }
2804
- class $ extends T {
886
+ class A extends I {
2805
887
  constructor(e, t, i) {
2806
- super(e, t, i), this.node = e, this.printers = [], this.printers = e.body.map((r) => this.createStatementPrinter(r));
888
+ super(e, t, i), this.node = e, this.printers = [], this.printers = e.body.map((s) => this.createStatementPrinter(s));
2807
889
  }
2808
890
  format(e = 0) {
2809
891
  if (this.printers.length === 0)
2810
892
  return this.formatEmptyBlock(e);
2811
- const t = [], i = b(this.node);
893
+ const t = [], i = a.isBlockStatement(this.node);
2812
894
  i && t.push("{");
2813
- const r = i ? e + 1 : e;
2814
- let s;
2815
- return this.printers.forEach((a) => {
2816
- if (pe(a.node))
895
+ const s = i ? e + 1 : e;
896
+ let r;
897
+ return this.printers.forEach((o) => {
898
+ if (a.isEmptyStatement(o.node))
2817
899
  return;
2818
- const o = St(a.node);
2819
- s && o.start.line - s.end.line > 1 && t.push(""), s = o, t.push(a.format(r));
2820
- }), i && t.push(`${this.getIndentation(e)}}`), this.addComments(D.appendLines(t), e);
900
+ const c = Le(o.node);
901
+ r && c.start.line - r.end.line > 1 && t.push(""), r = c, t.push(o.format(s));
902
+ }), i && t.push(`${this.getIndentation(e)}}`), this.addComments(u.appendLines(t), e);
2821
903
  }
2822
904
  formatEmptyBlock(e = 0) {
2823
- if (!b(this.node))
2824
- return this.addComments(D.fromString(""), e);
2825
- const t = this.formatInnerComments(e + 1), i = "{", r = `${this.getIndentation(e)}}`;
2826
- return t.isEmpty ? ae(this.parent) ? this.addComments(D.appendLines([i, r]), e) : this.addComments(D.fromString("{}"), e) : this.addComments(D.appendLines([i, t, r]), e);
905
+ if (!a.isBlockStatement(this.node))
906
+ return this.addComments(u.fromString(""), e);
907
+ const t = this.formatInnerComments(e + 1), i = "{", s = `${this.getIndentation(e)}}`;
908
+ return t.isEmpty ? a.isIfStatement(this.parent) ? this.addComments(u.appendLines([i, s]), e) : this.addComments(u.fromString("{}"), e) : this.addComments(u.appendLines([i, t, s]), e);
2827
909
  }
2828
910
  }
2829
- class bt extends T {
911
+ class Ie extends I {
2830
912
  constructor(e, t, i) {
2831
913
  switch (super(e, t, i), this.node = e, this.keyword = "", this.node.type) {
2832
- case u.ContinueStatement:
914
+ case a.NodeTypes.ContinueStatement:
2833
915
  this.keyword = "continue;";
2834
916
  break;
2835
- case u.BreakStatement:
917
+ case a.NodeTypes.BreakStatement:
2836
918
  this.keyword = "break;";
2837
919
  break;
2838
920
  default:
@@ -2840,15 +922,15 @@ class bt extends T {
2840
922
  }
2841
923
  }
2842
924
  format(e = 0) {
2843
- return this.addComments(D.fromString(this.keyword), e);
925
+ return this.addComments(u.fromString(this.keyword), e);
2844
926
  }
2845
927
  }
2846
- class Le extends T {
928
+ class J extends I {
2847
929
  constructor(e, t, i) {
2848
- if (super(e, t, i), this.node = e, G(e))
2849
- this.printer = new De(e, t, i);
2850
- else if (G(e.declaration))
2851
- this.printer = new De(e.declaration, t, i), this.printer.prefix = "export ";
930
+ if (super(e, t, i), this.node = e, a.isVariableDeclaration(e))
931
+ this.printer = new _(e, t, i);
932
+ else if (a.isVariableDeclaration(e.declaration))
933
+ this.printer = new _(e.declaration, t, i), this.printer.prefix = "export ";
2852
934
  else
2853
935
  throw new Error(`invalid type: ${JSON.stringify(e)}`);
2854
936
  }
@@ -2861,12 +943,12 @@ class Le extends T {
2861
943
  return this.addComments(this.printer.format("multiline", e).suffixWith(";"), e);
2862
944
  }
2863
945
  }
2864
- class Te extends T {
946
+ class Q extends I {
2865
947
  constructor(e, t, i) {
2866
- if (super(e, t, i), this.node = e, ge(e))
2867
- this.header = U(e, t, i), this.body = new $(e.body, e, i);
2868
- else if (ge(e.declaration))
2869
- this.header = U(e.declaration, t, i), this.header.prefix = "export ", this.body = new $(e.declaration.body, e, i);
948
+ if (super(e, t, i), this.node = e, a.isFunctionDeclaration(e))
949
+ this.header = T(e, t, i), this.body = new A(e.body, e, i);
950
+ else if (a.isFunctionDeclaration(e.declaration))
951
+ this.header = T(e.declaration, t, i), this.header.prefix = "export ", this.body = new A(e.declaration.body, e, i);
2870
952
  else
2871
953
  throw new Error(`invalid type: ${JSON.stringify(e)}`);
2872
954
  }
@@ -2874,70 +956,70 @@ class Te extends T {
2874
956
  this.body.indentStatementFirstLine = !1;
2875
957
  const i = this.getFormattedBody(this.body, e);
2876
958
  if (t === "singleLine" || t === "optimized") {
2877
- const s = this.header.format("singleLine", e);
2878
- if (t === "singleLine" || this.canFitSingleLine(s, e, i.firstLineLength + 1))
2879
- return this.addComments(D.joinLines([s, i], " "), e);
959
+ const r = this.header.format("singleLine", e);
960
+ if (t === "singleLine" || this.canFitSingleLine(r, e, i.firstLineLength + 1))
961
+ return this.addComments(u.joinLines([r, i], " "), e);
2880
962
  }
2881
- const r = this.header.format("multiline", e);
2882
- return this.addComments(D.joinLines([r, i], " "), e);
963
+ const s = this.header.format("multiline", e);
964
+ return this.addComments(u.joinLines([s, i], " "), e);
2883
965
  }
2884
966
  }
2885
- class wt extends T {
967
+ class Se extends I {
2886
968
  constructor(e, t, i) {
2887
- super(e, t, i), this.node = e, this.header = U(e, t, i), this.consequent = this.createStatementPrinter(e.consequent), this.consequent.indentStatementFirstLine = !1, e.alternate && (this.alternate = this.createStatementPrinter(e.alternate), this.alternate.indentStatementFirstLine = !1);
969
+ super(e, t, i), this.node = e, this.header = T(e, t, i), this.consequent = this.createStatementPrinter(e.consequent), this.consequent.indentStatementFirstLine = !1, e.alternate && (this.alternate = this.createStatementPrinter(e.alternate), this.alternate.indentStatementFirstLine = !1);
2888
970
  }
2889
971
  format(e = 0, t = "optimized") {
2890
- let i = !1, r;
972
+ let i = !1, s;
2891
973
  if (t === "singleLine" || t === "optimized") {
2892
- const c = this.header.format("singleLine", e), d = b(this.node.consequent) ? 2 : 0;
2893
- (t === "singleLine" || this.canFitSingleLine(c, e, d)) && (r = c);
2894
- }
2895
- r || (i = !0, r = this.header.format("multiline", e));
2896
- let s;
2897
- if (b(this.node.consequent)) {
2898
- const c = this.consequent.format(e, "optimized");
2899
- s = D.joinLines([r, " ", c]);
2900
- } else if (i || ae(this.node.consequent)) {
974
+ const l = this.header.format("singleLine", e), p = a.isBlockStatement(this.node.consequent) ? 2 : 0;
975
+ (t === "singleLine" || this.canFitSingleLine(l, e, p)) && (s = l);
976
+ }
977
+ s || (i = !0, s = this.header.format("multiline", e));
978
+ let r;
979
+ if (a.isBlockStatement(this.node.consequent)) {
980
+ const l = this.consequent.format(e, "optimized");
981
+ r = u.joinLines([s, " ", l]);
982
+ } else if (i || a.isIfStatement(this.node.consequent)) {
2901
983
  this.consequent.indentStatementFirstLine = !0;
2902
- let c = this.consequent.format(e + 1, "singleLine");
2903
- this.canFitSingleLine(c, e + 1) || (c = this.consequent.format(e + 1, "multiline")), s = D.appendLines([r, c]);
984
+ let l = this.consequent.format(e + 1, "singleLine");
985
+ this.canFitSingleLine(l, e + 1) || (l = this.consequent.format(e + 1, "multiline")), r = u.appendLines([s, l]);
2904
986
  } else {
2905
987
  this.consequent.indentStatementFirstLine = !1;
2906
- let c = this.consequent.format(e, "singleLine");
2907
- this.canFitSingleLine(c, 0, r.lastLineLength + 1) ? s = D.joinLines([r, " ", c]) : (this.consequent.indentStatementFirstLine = !0, c = this.consequent.format(e + 1, "optimized"), s = D.appendLines([r, c]));
988
+ let l = this.consequent.format(e, "singleLine");
989
+ this.canFitSingleLine(l, 0, s.lastLineLength + 1) ? r = u.joinLines([s, " ", l]) : (this.consequent.indentStatementFirstLine = !0, l = this.consequent.format(e + 1, "optimized"), r = u.appendLines([s, l]));
2908
990
  }
2909
991
  if (!this.alternate)
2910
- return this.addComments(s, e);
2911
- const a = It(this.node.consequent) || !b(this.node.consequent);
2912
- let o;
2913
- if (this.alternate.externalOffset = 0, b(this.node.alternate) || ae(this.node.alternate))
2914
- this.alternate.indentStatementFirstLine = !1, this.alternate.externalOffset = a ? 5 : s.lastLineLength + 6, o = this.alternate.format(e, "optimized"), o = D.joinLines(["else ", o]);
992
+ return this.addComments(r, e);
993
+ const o = Ee(this.node.consequent) || !a.isBlockStatement(this.node.consequent);
994
+ let c;
995
+ if (this.alternate.externalOffset = 0, a.isBlockStatement(this.node.alternate) || a.isIfStatement(this.node.alternate))
996
+ this.alternate.indentStatementFirstLine = !1, this.alternate.externalOffset = o ? 5 : r.lastLineLength + 6, c = this.alternate.format(e, "optimized"), c = u.joinLines(["else ", c]);
2915
997
  else {
2916
- const c = a ? 4 : s.lastLineLength + 4;
2917
- this.alternate.indentStatementFirstLine = !1, o = this.alternate.format(e, "singleLine"), this.canFitSingleLine(o, e, c + 1) ? o = D.joinLines(["else ", o]) : (this.alternate.indentStatementFirstLine = !0, o = this.alternate.format(e + 1, "optimized"), o = D.appendLines(["else", o]));
998
+ const l = o ? 4 : r.lastLineLength + 4;
999
+ this.alternate.indentStatementFirstLine = !1, c = this.alternate.format(e, "singleLine"), this.canFitSingleLine(c, e, l + 1) ? c = u.joinLines(["else ", c]) : (this.alternate.indentStatementFirstLine = !0, c = this.alternate.format(e + 1, "optimized"), c = u.appendLines(["else", c]));
2918
1000
  }
2919
- return a ? s = D.appendLines([s, o.indentFirstLine(this.getIndentation(e))]) : s = D.joinLines([s, o], " "), this.addComments(s, e);
1001
+ return o ? r = u.appendLines([r, c.indentFirstLine(this.getIndentation(e))]) : r = u.joinLines([r, c], " "), this.addComments(r, e);
2920
1002
  }
2921
1003
  }
2922
- class kt extends T {
1004
+ class be extends I {
2923
1005
  constructor(e, t, i) {
2924
- super(e, t, i), this.node = e, this.header = U(e, t, i), this.body = this.createStatementPrinter(e.body);
1006
+ super(e, t, i), this.node = e, this.header = T(e, t, i), this.body = this.createStatementPrinter(e.body);
2925
1007
  }
2926
1008
  format(e = 0, t = "optimized") {
2927
1009
  this.body.indentStatementFirstLine = !1;
2928
1010
  const i = this.getFormattedBody(this.body, e);
2929
1011
  if (t === "singleLine" || t === "optimized") {
2930
- const s = this.header.format("singleLine", e);
2931
- if (t === "singleLine" || this.canFitSingleLine(s, e, i.firstLineLength + 1))
2932
- return this.addComments(D.joinLines([s, i], " "), e);
1012
+ const r = this.header.format("singleLine", e);
1013
+ if (t === "singleLine" || this.canFitSingleLine(r, e, i.firstLineLength + 1))
1014
+ return this.addComments(u.joinLines([r, i], " "), e);
2933
1015
  }
2934
- const r = this.header.format("multiline", e);
2935
- return this.addComments(D.joinLines([r, i], " "), e);
1016
+ const s = this.header.format("multiline", e);
1017
+ return this.addComments(u.joinLines([s, i], " "), e);
2936
1018
  }
2937
1019
  }
2938
- class Lt extends T {
1020
+ class we extends I {
2939
1021
  constructor(e, t, i) {
2940
- super(e, t, i), this.node = e, this.expression = C(e.expression, e, i);
1022
+ super(e, t, i), this.node = e, this.expression = f(e.expression, e, i);
2941
1023
  }
2942
1024
  format(e = 0, t = "optimized") {
2943
1025
  if (t === "singleLine" || t === "optimized") {
@@ -2948,31 +1030,31 @@ class Lt extends T {
2948
1030
  return this.addComments(this.expression.format("multiline", e).suffixWith(";"), e);
2949
1031
  }
2950
1032
  }
2951
- class Tt extends T {
1033
+ class Te extends I {
2952
1034
  constructor(e, t, i) {
2953
- super(e, t, i), this.node = e, this.argument = C(e.argument, e, i);
1035
+ super(e, t, i), this.node = e, this.argument = f(e.argument, e, i);
2954
1036
  }
2955
1037
  format(e = 0, t = "optimized") {
2956
1038
  if (t === "singleLine" || t === "optimized") {
2957
- const a = this.argument.format("singleLine", e).surroundWith("return ", ";");
2958
- if (t === "singleLine" || this.canFitSingleLine(a, e))
2959
- return this.addComments(a, e);
1039
+ const o = this.argument.format("singleLine", e).surroundWith("return ", ";");
1040
+ if (t === "singleLine" || this.canFitSingleLine(o, e))
1041
+ return this.addComments(o, e);
2960
1042
  }
2961
- if (!ce(this.node.argument) && !oe(this.node.argument)) {
2962
- const a = this.argument.format("multiline", e).surroundWith("return ", ";");
2963
- return this.addComments(a, e);
1043
+ if (!a.isLogicalExpression(this.node.argument) && !a.isBinaryExpression(this.node.argument)) {
1044
+ const o = this.argument.format("multiline", e).surroundWith("return ", ";");
1045
+ return this.addComments(o, e);
2964
1046
  }
2965
- const i = this.getIndentation(e + 1), r = this.argument.format("multiline", e + 1).indentFirstLine(i), s = this.getIndentation(e);
2966
- return this.addComments(D.appendLines(["return (", r, `${s});`]), e);
1047
+ const i = this.getIndentation(e + 1), s = this.argument.format("multiline", e + 1).indentFirstLine(i), r = this.getIndentation(e);
1048
+ return this.addComments(u.appendLines(["return (", s, `${r});`]), e);
2967
1049
  }
2968
1050
  }
2969
- class vt extends T {
1051
+ class Ne extends I {
2970
1052
  constructor(e, t, i) {
2971
- super(e, t, i), this.node = e, this.libraryNamePrinter = C(e.specifiers[0].local, e, i), this.librarySourcePrinter = C(e.source, e, i);
1053
+ super(e, t, i), this.node = e, this.libraryNamePrinter = f(e.specifiers[0].local, e, i), this.librarySourcePrinter = f(e.source, e, i);
2972
1054
  }
2973
1055
  format(e = 0) {
2974
1056
  return this.addComments(
2975
- D.joinLines([
1057
+ u.joinLines([
2976
1058
  "import",
2977
1059
  " ",
2978
1060
  this.libraryNamePrinter.format("singleLine", e),
@@ -2983,147 +1065,147 @@ class vt extends T {
2983
1065
  );
2984
1066
  }
2985
1067
  }
2986
- const Pt = { quote: "auto" };
2987
- function Di(n, e = {}) {
1068
+ const Pe = { quote: "auto" };
1069
+ function ot(n, e = {}) {
2988
1070
  try {
2989
- const t = n.getText(), i = n.positionAt(t.length), r = { start: { line: 0, character: 0 }, end: i }, s = { ...Pt, ...e.formattingOptions ?? {} }, a = Nt(t, s);
2990
- return [{ range: r, newText: a }];
1071
+ const t = n.getText(), i = n.positionAt(t.length), s = { start: { line: 0, character: 0 }, end: i }, r = { ...Pe, ...e.formattingOptions ?? {} }, o = Ce(t, r);
1072
+ return [{ range: s, newText: o }];
2991
1073
  } catch (t) {
2992
1074
  return console.error("Arcade Formatting Error:", t), [];
2993
1075
  }
2994
1076
  }
2995
- function Nt(n, e) {
1077
+ function Ce(n, e) {
2996
1078
  if (!n)
2997
1079
  return "";
2998
- const t = de(e), i = Z.fromString(n, t), r = i.toString(), s = Re(r, {
1080
+ const t = O(e), i = M.fromString(n, t), s = i.toString(), r = a.parse(s, {
2999
1081
  tolerant: !0,
3000
1082
  comments: !0
3001
- }), a = lt(s, i);
3002
- return s.loc.start = a.start, s.loc.end = a.end, new $(s, null, t).format().toString();
1083
+ }), o = re(r, i);
1084
+ return r.loc.start = o.start, r.loc.end = o.end, new A(r, null, t).format().toString();
3003
1085
  }
3004
- const Mt = Object.values(f), Ut = Object.values(V), Ot = ["case", "catch", "debugger", "switch", "try"], jt = Ut.map((n) => ({ label: n, kind: x.Constant })), zt = Mt.map((n) => ({ label: n, kind: x.Keyword })), Vt = [
1086
+ const ve = Object.values(ee), Ae = Object.values(te), De = ["case", "catch", "debugger", "switch", "try"], Fe = Ae.map((n) => ({ label: n, kind: m.Constant })), ke = ve.map((n) => ({ label: n, kind: m.Keyword })), Be = [
3005
1087
  {
3006
1088
  label: "exportfunction",
3007
- kind: x.Snippet,
1089
+ kind: m.Snippet,
3008
1090
  detail: "Export Function Statement",
3009
1091
  insertText: `export function \${1:functionName} ($2) {
3010
1092
  $0
3011
1093
  }`,
3012
- insertTextMode: S.adjustIndentation,
3013
- insertTextFormat: B.Snippet
1094
+ insertTextMode: L.adjustIndentation,
1095
+ insertTextFormat: x.Snippet
3014
1096
  },
3015
1097
  {
3016
1098
  label: "exportvar",
3017
- kind: x.Snippet,
1099
+ kind: m.Snippet,
3018
1100
  detail: "Export Variable Statement",
3019
1101
  insertText: "export var ${0:variableName}\n",
3020
- insertTextMode: S.adjustIndentation,
3021
- insertTextFormat: B.Snippet
1102
+ insertTextMode: L.adjustIndentation,
1103
+ insertTextFormat: x.Snippet
3022
1104
  },
3023
1105
  {
3024
1106
  label: "for",
3025
- kind: x.Snippet,
1107
+ kind: m.Snippet,
3026
1108
  detail: "For Loop Statement",
3027
- insertText: "for (var ${1:i} = 0; ${1:i} < ${2:array.length}; ${1:i}++) {\n $0\n}",
3028
- insertTextMode: S.adjustIndentation,
3029
- insertTextFormat: B.Snippet
1109
+ insertText: "for (var ${1:i} = 0; ${1:i} < ${2:Count(arr)}; ${1:i}++) {\n $0\n}",
1110
+ insertTextMode: L.adjustIndentation,
1111
+ insertTextFormat: x.Snippet
3030
1112
  },
3031
1113
  {
3032
1114
  label: "forin",
3033
- kind: x.Snippet,
1115
+ kind: m.Snippet,
3034
1116
  detail: "For-In Loop Statement",
3035
1117
  insertText: "for (var ${1:i} in ${2:arrayOrObject}) {\n $0\n}",
3036
- insertTextMode: S.adjustIndentation,
3037
- insertTextFormat: B.Snippet
1118
+ insertTextMode: L.adjustIndentation,
1119
+ insertTextFormat: x.Snippet
3038
1120
  },
3039
1121
  {
3040
1122
  label: "forof",
3041
- kind: x.Snippet,
1123
+ kind: m.Snippet,
3042
1124
  detail: "For-Of Loop Statement",
3043
1125
  insertText: "for (var ${1:i} of ${2:arrayOrObject}) {\n $0\n}",
3044
- insertTextMode: S.adjustIndentation,
3045
- insertTextFormat: B.Snippet
1126
+ insertTextMode: L.adjustIndentation,
1127
+ insertTextFormat: x.Snippet
3046
1128
  },
3047
1129
  {
3048
1130
  label: "function",
3049
- kind: x.Snippet,
1131
+ kind: m.Snippet,
3050
1132
  detail: "Function Statement",
3051
1133
  insertText: `function \${1:functionName} ($2) {
3052
1134
  $0
3053
1135
  }`,
3054
- insertTextMode: S.adjustIndentation,
3055
- insertTextFormat: B.Snippet
1136
+ insertTextMode: L.adjustIndentation,
1137
+ insertTextFormat: x.Snippet
3056
1138
  },
3057
1139
  {
3058
1140
  label: "if",
3059
- kind: x.Snippet,
1141
+ kind: m.Snippet,
3060
1142
  detail: "If Statement",
3061
1143
  insertText: `if (\${1:1==1}) {
3062
1144
  $0
3063
1145
  }`,
3064
- insertTextMode: S.adjustIndentation,
3065
- insertTextFormat: B.Snippet
1146
+ insertTextMode: L.adjustIndentation,
1147
+ insertTextFormat: x.Snippet
3066
1148
  },
3067
1149
  {
3068
1150
  label: "ifelse",
3069
- kind: x.Snippet,
1151
+ kind: m.Snippet,
3070
1152
  detail: "If-Else Statement",
3071
1153
  insertText: `if (\${1:1==1}) {
3072
1154
  $0
3073
1155
  } else {
3074
1156
 
3075
1157
  }`,
3076
- insertTextMode: S.adjustIndentation,
3077
- insertTextFormat: B.Snippet
1158
+ insertTextMode: L.adjustIndentation,
1159
+ insertTextFormat: x.Snippet
3078
1160
  },
3079
1161
  {
3080
1162
  label: "else",
3081
- kind: x.Snippet,
1163
+ kind: m.Snippet,
3082
1164
  detail: "Else Statement",
3083
1165
  insertText: `else {
3084
1166
  $0
3085
1167
  }`,
3086
- insertTextMode: S.adjustIndentation,
3087
- insertTextFormat: B.Snippet
1168
+ insertTextMode: L.adjustIndentation,
1169
+ insertTextFormat: x.Snippet
3088
1170
  },
3089
1171
  {
3090
1172
  label: "import",
3091
- kind: x.Snippet,
1173
+ kind: m.Snippet,
3092
1174
  detail: "Import Statement",
3093
1175
  insertText: 'import ${1:namespace} from "${0:uri}"',
3094
- insertTextMode: S.adjustIndentation,
3095
- insertTextFormat: B.Snippet
1176
+ insertTextMode: L.adjustIndentation,
1177
+ insertTextFormat: x.Snippet
3096
1178
  },
3097
1179
  {
3098
1180
  label: "while",
3099
- kind: x.Snippet,
1181
+ kind: m.Snippet,
3100
1182
  detail: "While Loop Statement",
3101
1183
  insertText: `while (\${1:false}) {
3102
1184
  $0
3103
1185
  }`,
3104
- insertTextMode: S.adjustIndentation,
3105
- insertTextFormat: B.Snippet
1186
+ insertTextMode: L.adjustIndentation,
1187
+ insertTextFormat: x.Snippet
3106
1188
  }
3107
- ], _t = /\$\{(.*?)\}/gu;
3108
- function _(n, e) {
3109
- return e ? n.replace(_t, (t, i) => e[i].toString()) : n;
1189
+ ], Me = /\$\{(.*?)\}/gu;
1190
+ function v(n, e) {
1191
+ return e ? n.replace(Me, (t, i) => e[i].toString()) : n;
3110
1192
  }
3111
- const Ce = /[-[\]/{}()*+?.\\^$|]/gu;
3112
- function $t(n, e) {
1193
+ const q = /[-[\]/{}()*+?.\\^$|]/gu;
1194
+ function $e(n, e) {
3113
1195
  return n.line > e.end.line;
3114
1196
  }
3115
- function Rt(n, e) {
1197
+ function je(n, e) {
3116
1198
  return n.line < e.start.line;
3117
1199
  }
3118
- function He(n, e) {
3119
- return !(Rt(n, e) || $t(n, e) || n.line === e.start.line && n.column < e.start.column || n.line === e.end.line && n.column > e.end.column);
1200
+ function X(n, e) {
1201
+ return !(je(n, e) || $e(n, e) || n.line === e.start.line && n.column < e.start.column || n.line === e.end.line && n.column > e.end.column);
3120
1202
  }
3121
- const g = {
1203
+ const d = {
3122
1204
  None: 0,
3123
1205
  Keywords: 1,
3124
1206
  All: 255,
3125
1207
  NoKeywords: 254
3126
- }, v = {
1208
+ }, S = {
3127
1209
  identifiers: "a",
3128
1210
  profileVariables: "aa",
3129
1211
  constants: "ab",
@@ -3132,63 +1214,63 @@ const g = {
3132
1214
  snippets: "b",
3133
1215
  keywords: "c"
3134
1216
  };
3135
- function Wt(n, e, t, i = {}) {
3136
- const r = n.getText({ start: { line: 0, character: 0 }, end: e }), { tokens: s, errors: a = [] } = ct(r, { loc: !0, tolerant: !0 });
3137
- if (a.length)
1217
+ function Ve(n, e, t, i = {}) {
1218
+ const s = n.getText({ start: { line: 0, character: 0 }, end: e }), { tokens: r, errors: o = [] } = a.tokenize(s, { loc: !0, tolerant: !0 });
1219
+ if (o.length)
3138
1220
  return { isIncomplete: !1, items: [] };
3139
- let o = s.at(s.length - 1), c = "";
3140
- const d = ni(e);
3141
- o?.type === "Identifier" && He(d, o.loc) && (c = o.value, s.pop(), o = s[s.length - 1]);
3142
- const E = {
1221
+ let c = r.at(r.length - 1), l = "";
1222
+ const p = Ye(e);
1223
+ c?.type === "Identifier" && X(p, c.loc) && (l = c.value, r.pop(), c = r[r.length - 1]);
1224
+ const y = {
3143
1225
  variables: i.profile?.variables ?? [],
3144
- additionalCompletionItems: (i.snippets ?? []).map((F) => ({
3145
- kind: x.Snippet,
3146
- insertTextMode: S.adjustIndentation,
3147
- insertTextFormat: B.Snippet,
3148
- ...F
1226
+ additionalCompletionItems: (i.snippets ?? []).map((C) => ({
1227
+ kind: m.Snippet,
1228
+ insertTextMode: L.adjustIndentation,
1229
+ insertTextFormat: x.Snippet,
1230
+ ...C
3149
1231
  })),
3150
1232
  apiDatabase: t
3151
1233
  };
3152
- return o?.type === "Punctuator" && (o.value === "." || o.value === w) ? Ht(s, c, E) : Kt(s, c, d, E);
1234
+ return c?.type === "Punctuator" && (c.value === "." || c.value === a.SafeAccessOperator) ? _e(r, l, y) : ze(r, l, p, y);
3153
1235
  }
3154
- function Kt(n, e, t, i) {
3155
- const r = Jt(n, t);
3156
- if (r === g.None)
1236
+ function ze(n, e, t, i) {
1237
+ const s = Ue(n, t);
1238
+ if (s === d.None)
3157
1239
  return { isIncomplete: !1, items: [] };
3158
- const s = Xt(n), a = [], o = new RegExp(e.replaceAll(Ce, "\\$&"), "i");
3159
- return s.forEach((c, d) => {
3160
- o.test(d) && a.push({ ...c, sortText: v.identifiers });
3161
- }), i.variables.forEach((c) => {
3162
- o.test(c.name) && c.completion && a.push({ ...c.completion, sortText: v.profileVariables });
3163
- }), ve(r) && Vt.forEach((c) => {
3164
- c.label.startsWith(e) && a.push({ ...c, sortText: v.snippets });
3165
- }), i.additionalCompletionItems.forEach((c) => {
3166
- o.test(c.label) && a.push({ ...c, sortText: v.snippets });
3167
- }), ve(r) && zt.forEach((c) => {
3168
- o.test(c.label) && a.push({ ...c, sortText: v.keywords });
3169
- }), jt.forEach((c) => {
3170
- o.test(c.label) && a.push({ ...c, sortText: v.literals });
3171
- }), i.apiDatabase.constantDefinitions.forEach((c, d) => {
3172
- c.type === "constant" && c.disableDocumentation === !0 || !o.test(d) || a.push({ ...c.completion, sortText: v.constants });
3173
- }), i.apiDatabase.functionDefinitions.forEach((c, d) => {
3174
- o.test(d) && c.overloads.forEach((E) => {
3175
- E.disableDocumentation || a.push({ ...E.completion, sortText: v.functions });
1240
+ const r = Ke(n), o = [], c = new RegExp(e.replaceAll(q, "\\$&"), "i");
1241
+ return r.forEach((l, p) => {
1242
+ c.test(p) && o.push({ ...l, sortText: S.identifiers });
1243
+ }), i.variables.forEach((l) => {
1244
+ c.test(l.name) && l.completion && o.push({ ...l.completion, sortText: S.profileVariables });
1245
+ }), H(s) && Be.forEach((l) => {
1246
+ l.label.startsWith(e) && o.push({ ...l, sortText: S.snippets });
1247
+ }), i.additionalCompletionItems.forEach((l) => {
1248
+ c.test(l.label) && o.push({ ...l, sortText: S.snippets });
1249
+ }), H(s) && ke.forEach((l) => {
1250
+ c.test(l.label) && o.push({ ...l, sortText: S.keywords });
1251
+ }), Fe.forEach((l) => {
1252
+ c.test(l.label) && o.push({ ...l, sortText: S.literals });
1253
+ }), i.apiDatabase.constantDefinitions.forEach((l, p) => {
1254
+ l.type === "constant" && l.disableDocumentation === !0 || !c.test(p) || o.push({ ...l.completion, sortText: S.constants });
1255
+ }), i.apiDatabase.functionDefinitions.forEach((l, p) => {
1256
+ c.test(p) && l.overloads.forEach((y) => {
1257
+ y.disableDocumentation || o.push({ ...y.completion, sortText: S.functions });
3176
1258
  });
3177
- }), { isIncomplete: !1, items: a };
1259
+ }), { isIncomplete: !1, items: o };
3178
1260
  }
3179
- function Ht(n, e, t) {
1261
+ function _e(n, e, t) {
3180
1262
  const i = [...n];
3181
- let r = i.pop();
3182
- const s = r;
3183
- let a = [];
3184
- for (; r && !(r.type !== "Punctuator" || r.value !== "." && r.value !== w || (r = i.pop(), r?.type !== "Identifier")); )
3185
- a = [r.value.toLowerCase(), ...a], r = i.pop();
3186
- if (a.length === 0 || !s)
1263
+ let s = i.pop();
1264
+ const r = s;
1265
+ let o = [];
1266
+ for (; s && !(s.type !== "Punctuator" || s.value !== "." && s.value !== a.SafeAccessOperator || (s = i.pop(), s?.type !== "Identifier")); )
1267
+ o = [s.value.toLowerCase(), ...o], s = i.pop();
1268
+ if (o.length === 0 || !r)
3187
1269
  return { isIncomplete: !1, items: [] };
3188
- let o = qt(a, e, t);
3189
- return o || (o = Gt(a, e, s, t), o) ? o : { isIncomplete: !1, items: [] };
1270
+ let c = Oe(o, e, t);
1271
+ return c || (c = We(o, e, r, t), c) ? c : { isIncomplete: !1, items: [] };
3190
1272
  }
3191
- function qt(n, e, t) {
1273
+ function Oe(n, e, t) {
3192
1274
  if (n.length > 1)
3193
1275
  return null;
3194
1276
  const i = t.apiDatabase.constantDefinitions.get(n[0]);
@@ -3196,61 +1278,61 @@ function qt(n, e, t) {
3196
1278
  return null;
3197
1279
  if (i.type !== "namespace")
3198
1280
  return { isIncomplete: !1, items: [] };
3199
- const r = [], s = new RegExp(e.replaceAll(Ce, "\\$&"), "i");
3200
- return i.members.forEach((a) => {
3201
- a.disableDocumentation === !0 || !s.test(a.name) || r.push(a.completion);
3202
- }), { isIncomplete: !1, items: r };
1281
+ const s = [], r = new RegExp(e.replaceAll(q, "\\$&"), "i");
1282
+ return i.members.forEach((o) => {
1283
+ o.disableDocumentation === !0 || !r.test(o.name) || s.push(o.completion);
1284
+ }), { isIncomplete: !1, items: s };
3203
1285
  }
3204
- function Gt(n, e, t, i) {
1286
+ function We(n, e, t, i) {
3205
1287
  if (!i.variables.length || !n.length)
3206
1288
  return null;
3207
- let r = n.shift(), s = i.variables;
3208
- for (; r; ) {
3209
- const d = s.find((E) => E.name.toLowerCase() === r);
3210
- if (!Ge(d))
1289
+ let s = n.shift(), r = i.variables;
1290
+ for (; s; ) {
1291
+ const p = r.find((y) => y.name.toLowerCase() === s);
1292
+ if (!ie(p))
3211
1293
  return null;
3212
- s = d.properties ?? [], r = n.shift();
1294
+ r = p.properties ?? [], s = n.shift();
3213
1295
  }
3214
- const a = [], o = new RegExp(e.replaceAll(Ce, "\\$&"), "i"), c = ri(t.loc.start);
3215
- return s.forEach((d) => {
3216
- o.test(d.name) && d.completion && (t.value === "." ? a.push(ii(c, d.completion)) : a.push(d.completion));
3217
- }), { isIncomplete: !1, items: a };
1296
+ const o = [], c = new RegExp(e.replaceAll(q, "\\$&"), "i"), l = Ge(t.loc.start);
1297
+ return r.forEach((p) => {
1298
+ c.test(p.name) && p.completion && (t.value === "." ? o.push(Ze(l, p.completion)) : o.push(p.completion));
1299
+ }), { isIncomplete: !1, items: o };
3218
1300
  }
3219
- function ve(n) {
3220
- return (n & g.Keywords) === g.Keywords;
1301
+ function H(n) {
1302
+ return (n & d.Keywords) === d.Keywords;
3221
1303
  }
3222
- function Jt(n, e) {
1304
+ function Ue(n, e) {
3223
1305
  if (!n.length)
3224
- return g.All;
1306
+ return d.All;
3225
1307
  const t = n[n.length - 1];
3226
1308
  switch (t.type) {
3227
1309
  case "Identifier":
3228
- return g.All;
1310
+ return d.All;
3229
1311
  case "Keyword":
3230
- return ["return", "in", "else"].includes(t.value) ? g.NoKeywords : g.None;
1312
+ return ["return", "in", "else"].includes(t.value) ? d.NoKeywords : d.None;
3231
1313
  case "Punctuator":
3232
- return Qt(n);
1314
+ return qe(n);
3233
1315
  case "Template":
3234
- return t.value.endsWith("${") ? g.NoKeywords : g.All;
1316
+ return t.value.endsWith("${") ? d.NoKeywords : d.All;
3235
1317
  default:
3236
- return He(e, t.loc) ? g.None : g.All;
1318
+ return X(e, t.loc) ? d.None : d.All;
3237
1319
  }
3238
1320
  }
3239
- function Qt(n) {
1321
+ function qe(n) {
3240
1322
  const e = [...n];
3241
1323
  let t = e.pop();
3242
1324
  if (!t)
3243
- return g.All;
1325
+ return d.All;
3244
1326
  if (t.type !== "Punctuator")
3245
- return g.None;
1327
+ return d.None;
3246
1328
  if (t.value !== "(" && t.value !== ",")
3247
- return g.All;
1329
+ return d.All;
3248
1330
  if (t.value === "(")
3249
- return Pe(e);
1331
+ return Z(e);
3250
1332
  let i = 0;
3251
1333
  for (t = e.pop(); t; ) {
3252
1334
  if (t.type === "Keyword")
3253
- return g.None;
1335
+ return d.None;
3254
1336
  if (t.type !== "Punctuator") {
3255
1337
  t = e.pop();
3256
1338
  continue;
@@ -3261,26 +1343,26 @@ function Qt(n) {
3261
1343
  }
3262
1344
  if (t.value === "[") {
3263
1345
  if (i === 0)
3264
- return g.NoKeywords;
1346
+ return d.NoKeywords;
3265
1347
  i += 1, t = e.pop();
3266
1348
  continue;
3267
1349
  }
3268
1350
  if (t.value === "(") {
3269
1351
  if (i === 0)
3270
- return Pe(e);
1352
+ return Z(e);
3271
1353
  i += 1, t = e.pop();
3272
1354
  continue;
3273
1355
  }
3274
1356
  t = e.pop();
3275
1357
  }
3276
- return g.None;
1358
+ return d.None;
3277
1359
  }
3278
- function Pe(n) {
1360
+ function Z(n) {
3279
1361
  const e = [...n];
3280
1362
  let t = e.pop();
3281
- return t ? t.type === "Keyword" ? t.value.toLowerCase() === "for" ? g.All : g.NoKeywords : t.type !== "Identifier" ? g.All : (t = e.pop(), t?.type === "Keyword" && t.value.toLowerCase() === "function" ? g.None : g.NoKeywords) : g.All;
1363
+ return t ? t.type === "Keyword" ? t.value.toLowerCase() === "for" ? d.All : d.NoKeywords : t.type !== "Identifier" ? d.All : (t = e.pop(), t?.type === "Keyword" && t.value.toLowerCase() === "function" ? d.None : d.NoKeywords) : d.All;
3282
1364
  }
3283
- class Zt {
1365
+ class Re {
3284
1366
  constructor(e) {
3285
1367
  this.tokens = e, this.currentIndex = 0;
3286
1368
  }
@@ -3298,24 +1380,24 @@ class Zt {
3298
1380
  return this.tokens[this.currentIndex];
3299
1381
  }
3300
1382
  }
3301
- const H = {
1383
+ const k = {
3302
1384
  parameterFormat: "(parameter) ${name}",
3303
1385
  variableFormat: "var ${name}",
3304
1386
  functionFormat: "function ${name} (${paramsDetail})"
3305
1387
  };
3306
- function Xt(n) {
1388
+ function Ke(n) {
3307
1389
  const e = /* @__PURE__ */ new Map();
3308
1390
  if (!n.length)
3309
1391
  return e;
3310
- const t = new Zt(n);
1392
+ const t = new Re(n);
3311
1393
  for (; t.current; ) {
3312
1394
  if (t.current.type === "Keyword") {
3313
1395
  if (t.current.value.toLowerCase() === "var") {
3314
- t.increment(), Yt(t, e);
1396
+ t.increment(), Je(t, e);
3315
1397
  continue;
3316
1398
  }
3317
1399
  if (t.current.value.toLowerCase() === "function") {
3318
- t.increment(), ei(t, e);
1400
+ t.increment(), Qe(t, e);
3319
1401
  continue;
3320
1402
  }
3321
1403
  }
@@ -3323,84 +1405,84 @@ function Xt(n) {
3323
1405
  }
3324
1406
  return e;
3325
1407
  }
3326
- function Yt(n, e) {
1408
+ function Je(n, e) {
3327
1409
  for (; n.current; ) {
3328
1410
  if (n.current.type !== "Identifier")
3329
1411
  return;
3330
1412
  const t = n.current.value, i = t.toLowerCase();
3331
1413
  e.set(i, {
3332
1414
  label: t,
3333
- kind: x.Variable,
3334
- detail: _(H.variableFormat, { name: t })
1415
+ kind: m.Variable,
1416
+ detail: v(k.variableFormat, { name: t })
3335
1417
  });
3336
- const r = n.increment();
3337
- if (r?.type !== "Punctuator")
1418
+ const s = n.increment();
1419
+ if (s?.type !== "Punctuator")
3338
1420
  return;
3339
- if (r.value === ",") {
1421
+ if (s.value === ",") {
3340
1422
  n.increment();
3341
1423
  continue;
3342
1424
  }
3343
- if (r.value === "=") {
3344
- n.increment(), ti(n);
1425
+ if (s.value === "=") {
1426
+ n.increment(), He(n);
3345
1427
  continue;
3346
1428
  }
3347
1429
  }
3348
1430
  }
3349
- function ei(n, e) {
1431
+ function Qe(n, e) {
3350
1432
  for (; n.current; ) {
3351
1433
  if (n.current.type !== "Identifier")
3352
1434
  return;
3353
- const t = n.current.value, i = t.toLowerCase(), r = {
1435
+ const t = n.current.value, i = t.toLowerCase(), s = {
3354
1436
  label: t,
3355
- kind: x.Function,
3356
- detail: _(H.functionFormat, { name: t, paramsDetail: "" }),
1437
+ kind: m.Function,
1438
+ detail: v(k.functionFormat, { name: t, paramsDetail: "" }),
3357
1439
  insertText: `${t}()`,
3358
- insertTextMode: S.adjustIndentation,
3359
- insertTextFormat: B.Snippet
1440
+ insertTextMode: L.adjustIndentation,
1441
+ insertTextFormat: x.Snippet
3360
1442
  };
3361
- e.set(i, r);
3362
- let s = n.increment();
3363
- if (!P(s, "("))
1443
+ e.set(i, s);
1444
+ let r = n.increment();
1445
+ if (!b(r, "("))
3364
1446
  return;
3365
- s = n.increment();
3366
- const a = [];
3367
- for (; s && !(s.type !== "Identifier" || (a.push(s.value), s = n.increment(), !P(s, ","))); )
3368
- s = n.increment();
3369
- if (a.length) {
3370
- r.detail = _(H.functionFormat, {
3371
- name: r.label,
3372
- paramsDetail: a.join(", ")
1447
+ r = n.increment();
1448
+ const o = [];
1449
+ for (; r && !(r.type !== "Identifier" || (o.push(r.value), r = n.increment(), !b(r, ","))); )
1450
+ r = n.increment();
1451
+ if (o.length) {
1452
+ s.detail = v(k.functionFormat, {
1453
+ name: s.label,
1454
+ paramsDetail: o.join(", ")
3373
1455
  });
3374
- const d = a.map((E, F) => `\${${F + 1}:${E}}`).join(", ");
3375
- r.insertText = `${r.label}(${d})`;
1456
+ const p = o.map((y, C) => `\${${C + 1}:${y}}`).join(", ");
1457
+ s.insertText = `${s.label}(${p})`;
3376
1458
  }
3377
- if (!P(s, ")") || (s = n.increment(), !P(s, "{")))
1459
+ if (!b(r, ")") || (r = n.increment(), !b(r, "{")))
3378
1460
  return;
3379
- s = n.increment();
3380
- const o = n.currentIndex;
3381
- let c = 1;
3382
- for (; s && c > 0; )
3383
- P(s, "{") ? c += 1 : P(s, "}") && (c -= 1), s = n.increment();
3384
- if (c === 0)
1461
+ r = n.increment();
1462
+ const c = n.currentIndex;
1463
+ let l = 1;
1464
+ for (; r && l > 0; )
1465
+ b(r, "{") ? l += 1 : b(r, "}") && (l -= 1), r = n.increment();
1466
+ if (l === 0)
3385
1467
  return;
3386
- n.currentIndex = o, a.forEach((d) => {
3387
- const E = d.toLowerCase();
3388
- e.set(E, {
3389
- label: d,
3390
- kind: x.Variable,
3391
- detail: _(H.parameterFormat, { name: d })
1468
+ n.currentIndex = c, o.forEach((p) => {
1469
+ const y = p.toLowerCase();
1470
+ e.set(y, {
1471
+ label: p,
1472
+ kind: m.Variable,
1473
+ detail: v(k.parameterFormat, { name: p })
3392
1474
  });
3393
1475
  });
3394
1476
  }
3395
1477
  }
3396
- function P(n, e) {
1478
+ function b(n, e) {
3397
1479
  return n?.type === "Punctuator" && n.value === e;
3398
1480
  }
3399
- function ti(n) {
1481
+ function He(n) {
3400
1482
  let e = 0;
3401
1483
  for (; n.current; ) {
3402
1484
  if (n.current.type === "Keyword") {
3403
- if (P(n.previous, ".") || P(n.previous, w)) {
1485
+ if (b(n.previous, ".") || b(n.previous, a.SafeAccessOperator)) {
3404
1486
  n.increment();
3405
1487
  continue;
3406
1488
  }
@@ -3431,7 +1513,7 @@ function ti(n) {
3431
1513
  n.increment();
3432
1514
  }
3433
1515
  }
3434
- function ii(n, e) {
1516
+ function Ze(n, e) {
3435
1517
  return e.insertText?.startsWith("[") && (e.additionalTextEdits = [
3436
1518
  {
3437
1519
  newText: "",
@@ -3445,105 +1527,105 @@ function ii(n, e) {
3445
1527
  }
3446
1528
  ]), e;
3447
1529
  }
3448
- function ni(n) {
1530
+ function Ye(n) {
3449
1531
  return { line: n.line + 1, column: n.character };
3450
1532
  }
3451
- function ri(n) {
1533
+ function Ge(n) {
3452
1534
  return { line: n.line - 1, character: n.column };
3453
1535
  }
3454
- class si {
1536
+ class Xe {
3455
1537
  constructor(e, t = []) {
3456
1538
  this._apiDatabase = e, this._profileVariables = t, this._isInBlock = !1, this._isInCallExpression = !1, this._identifierBeingAssigned = void 0, this._assignmentValidationMode = "disabled", this._scriptScopeIdentifiers = /* @__PURE__ */ new Map(), this._diagnostics = [], this._undeclaredIdentifiersInFunctions = /* @__PURE__ */ new Map(), this.handleException = (i) => {
3457
- if (ui(i)) {
3458
- const { range: r, code: s, data: a } = i;
3459
- this.logDiagnostic(r, { code: s, data: a });
1539
+ if (et(i)) {
1540
+ const { range: s, code: r, data: o } = i;
1541
+ this.logDiagnostic(s, { code: r, data: o });
3460
1542
  } else
3461
1543
  this.logDiagnostic(
3462
1544
  { start: { line: 1, column: 0 }, end: { line: 1, column: 0 } },
3463
- { code: p.ExecutionError, data: { stack: i.stack ?? "" } }
1545
+ { code: h.ExecutionError, data: { stack: i.stack ?? "" } }
3464
1546
  );
3465
1547
  }, this.validateStatement = (i) => {
3466
1548
  if (i)
3467
1549
  switch (i.type) {
3468
- case u.BlockStatement:
1550
+ case a.NodeTypes.BlockStatement:
3469
1551
  i.body.forEach(this.validateStatement);
3470
1552
  return;
3471
- case u.VariableDeclaration:
3472
- i.declarations.forEach((r) => this.validateVariableDeclarator(r));
1553
+ case a.NodeTypes.VariableDeclaration:
1554
+ i.declarations.forEach((s) => this.validateVariableDeclarator(s));
3473
1555
  return;
3474
- case u.FunctionDeclaration:
1556
+ case a.NodeTypes.FunctionDeclaration:
3475
1557
  this.validateFunctionDeclaration(i);
3476
1558
  return;
3477
- case u.ExportNamedDeclaration:
1559
+ case a.NodeTypes.ExportNamedDeclaration:
3478
1560
  this.validateExportDeclaration(i);
3479
1561
  return;
3480
- case u.ImportDeclaration:
1562
+ case a.NodeTypes.ImportDeclaration:
3481
1563
  this.validateImportDeclaration(i);
3482
1564
  return;
3483
- case u.WhileStatement:
1565
+ case a.NodeTypes.WhileStatement:
3484
1566
  this.validateWhileStatement(i);
3485
1567
  return;
3486
- case u.ForStatement:
1568
+ case a.NodeTypes.ForStatement:
3487
1569
  this.validateForStatement(i);
3488
1570
  return;
3489
- case u.ForInStatement:
3490
- case u.ForOfStatement:
1571
+ case a.NodeTypes.ForInStatement:
1572
+ case a.NodeTypes.ForOfStatement:
3491
1573
  this.validateForInOfStatement(i);
3492
1574
  return;
3493
- case u.IfStatement:
1575
+ case a.NodeTypes.IfStatement:
3494
1576
  this.validateIfStatement(i);
3495
1577
  return;
3496
- case u.ReturnStatement:
1578
+ case a.NodeTypes.ReturnStatement:
3497
1579
  this.validateExpression(i.argument);
3498
1580
  return;
3499
- case u.ExpressionStatement:
1581
+ case a.NodeTypes.ExpressionStatement:
3500
1582
  this.validateExpression(i.expression);
3501
1583
  return;
3502
1584
  // No issue statement
3503
- case u.BreakStatement:
3504
- case u.ContinueStatement:
3505
- case u.EmptyStatement:
1585
+ case a.NodeTypes.BreakStatement:
1586
+ case a.NodeTypes.ContinueStatement:
1587
+ case a.NodeTypes.EmptyStatement:
3506
1588
  return;
3507
1589
  }
3508
1590
  }, this.validateExpression = (i) => {
3509
1591
  if (i)
3510
1592
  switch (i.type) {
3511
- case u.AssignmentExpression:
1593
+ case a.NodeTypes.AssignmentExpression:
3512
1594
  this.validateAssignmentExpression(i);
3513
1595
  return;
3514
- case u.CallExpression:
1596
+ case a.NodeTypes.CallExpression:
3515
1597
  this.validateCallExpression(i);
3516
1598
  return;
3517
- case u.Identifier:
1599
+ case a.NodeTypes.Identifier:
3518
1600
  this.validateIdentifier(i);
3519
1601
  return;
3520
- case u.Literal:
1602
+ case a.NodeTypes.Literal:
3521
1603
  this.validateLiteral(i);
3522
1604
  return;
3523
- case u.ArrayExpression:
1605
+ case a.NodeTypes.ArrayExpression:
3524
1606
  i.elements.forEach(this.validateExpression);
3525
1607
  return;
3526
- case u.ObjectExpression:
1608
+ case a.NodeTypes.ObjectExpression:
3527
1609
  this.validateObjectExpression(i);
3528
1610
  return;
3529
- case u.MemberAccessChainExpression:
1611
+ case a.NodeTypes.MemberAccessChainExpression:
3530
1612
  this.validateMemberAccessChainExpression(i);
3531
1613
  return;
3532
- case u.UnaryExpression:
1614
+ case a.NodeTypes.UnaryExpression:
3533
1615
  this.validateUnaryExpression(i);
3534
1616
  return;
3535
- case u.UpdateExpression:
1617
+ case a.NodeTypes.UpdateExpression:
3536
1618
  this.validateUpdateExpression(i);
3537
1619
  return;
3538
- case u.BinaryExpression:
3539
- case u.LogicalExpression:
1620
+ case a.NodeTypes.BinaryExpression:
1621
+ case a.NodeTypes.LogicalExpression:
3540
1622
  this.validateBinaryAndLogicalExpression(i);
3541
1623
  return;
3542
- case u.SafeMemberExpression:
3543
- case u.MemberExpression:
1624
+ case a.NodeTypes.SafeMemberExpression:
1625
+ case a.NodeTypes.MemberExpression:
3544
1626
  this.validateMemberExpression(i);
3545
1627
  return;
3546
- case u.TemplateLiteral:
1628
+ case a.NodeTypes.TemplateLiteral:
3547
1629
  i.expressions.forEach(this.validateExpression);
3548
1630
  return;
3549
1631
  default:
@@ -3557,11 +1639,11 @@ class si {
3557
1639
  this._isInBlock = !1, this._identifierBeingAssigned = void 0, this._assignmentValidationMode = "disabled", this._diagnostics = [], this._scriptScopeIdentifiers.clear(), this._undeclaredIdentifiersInFunctions.clear(), this._functionScopeIdentifiers = void 0;
3558
1640
  let t = null;
3559
1641
  try {
3560
- t = Re(e, { tolerant: !0 }), this.handleErrors(t.errors), t.body.forEach(this.validateStatement), this.diagnoseIdentifiers(), this._undeclaredIdentifiersInFunctions.size > 0 && this._undeclaredIdentifiersInFunctions.forEach((i) => {
3561
- for (const r of i)
3562
- this.logDiagnostic(r.node.loc, {
3563
- code: p.NotDefined,
3564
- data: { identifier: r.node.name }
1642
+ t = a.parse(e, { tolerant: !0 }), this.handleErrors(t.errors), t.body.forEach(this.validateStatement), this.diagnoseIdentifiers(), this._undeclaredIdentifiersInFunctions.size > 0 && this._undeclaredIdentifiersInFunctions.forEach((i) => {
1643
+ for (const s of i)
1644
+ this.logDiagnostic(s.node.loc, {
1645
+ code: h.NotDefined,
1646
+ data: { identifier: s.node.name }
3565
1647
  });
3566
1648
  });
3567
1649
  } catch (i) {
@@ -3585,9 +1667,9 @@ class si {
3585
1667
  }
3586
1668
  logDiagnostic(e, t) {
3587
1669
  const i = {
3588
- severity: A.Error,
1670
+ severity: g.Error,
3589
1671
  ...t,
3590
- message: _(ht[t.code], t.data),
1672
+ message: v(se[t.code], t.data),
3591
1673
  range: {
3592
1674
  start: { line: e.start.line - 1, character: e.start.column },
3593
1675
  end: { line: e.end.line - 1, character: e.end.column }
@@ -3625,10 +1707,10 @@ class si {
3625
1707
  }
3626
1708
  validateFunctionDeclaration(e) {
3627
1709
  this.recordFunctionIdentifier(e), this.inFunctionScope(() => {
3628
- e.params.forEach((t) => this.recordParamAsIdentifier(t)), j(e.body) && this.logDiagnostic(e.body.loc, {
3629
- code: p.UnexpectedEmptyFunction,
1710
+ e.params.forEach((t) => this.recordParamAsIdentifier(t)), P(e.body) && this.logDiagnostic(e.body.loc, {
1711
+ code: h.UnexpectedEmptyFunction,
3630
1712
  data: { identifier: e.id.name },
3631
- severity: A.Warning
1713
+ severity: g.Warning
3632
1714
  }), this.validateStatement(e.body);
3633
1715
  });
3634
1716
  }
@@ -3639,48 +1721,48 @@ class si {
3639
1721
  this.recordImportIdentifier(e);
3640
1722
  }
3641
1723
  validateForStatement(e) {
3642
- G(e.init) ? this.inBlock(this.validateStatement, e.init) : this.validateExpression(e.init), this.validateExpression(e.update), this.validateExpression(e.test), j(e.body) && this.logDiagnostic(e.body.loc, {
3643
- code: p.EmptyBlockStatement,
3644
- severity: A.Warning
1724
+ a.isVariableDeclaration(e.init) ? this.inBlock(this.validateStatement, e.init) : this.validateExpression(e.init), this.validateExpression(e.update), this.validateExpression(e.test), P(e.body) && this.logDiagnostic(e.body.loc, {
1725
+ code: h.EmptyBlockStatement,
1726
+ severity: g.Warning
3645
1727
  }), this.inBlock(this.validateStatement, e.body);
3646
1728
  }
3647
1729
  validateWhileStatement(e) {
3648
- this.validateExpression(e.test), j(e.body) && this.logDiagnostic(e.body.loc, {
3649
- code: p.EmptyBlockStatement,
3650
- severity: A.Warning
1730
+ this.validateExpression(e.test), P(e.body) && this.logDiagnostic(e.body.loc, {
1731
+ code: h.EmptyBlockStatement,
1732
+ severity: g.Warning
3651
1733
  }), this.inBlock(this.validateStatement, e.body);
3652
1734
  }
3653
1735
  validateForInOfStatement(e) {
3654
- if (I(e.left)) {
1736
+ if (a.isIdentifier(e.left)) {
3655
1737
  const t = this._assignmentValidationMode;
3656
1738
  this._assignmentValidationMode = "left", this._identifierBeingAssigned = e.left.name.toLowerCase(), this.validateExpression(e.left), this._assignmentValidationMode = t;
3657
1739
  } else
3658
1740
  this.recordVariableIdentifier(e.left.declarations[0].id, { initialized: !0, inBlock: !0 });
3659
- this.validateExpression(e.right), j(e.body) && this.logDiagnostic(e.body.loc, {
3660
- code: p.EmptyBlockStatement,
3661
- severity: A.Warning
1741
+ this.validateExpression(e.right), P(e.body) && this.logDiagnostic(e.body.loc, {
1742
+ code: h.EmptyBlockStatement,
1743
+ severity: g.Warning
3662
1744
  }), this.validateStatement(e.body);
3663
1745
  }
3664
1746
  validateIfStatement(e) {
3665
- this.validateExpression(e.test), j(e.consequent) && this.logDiagnostic(e.consequent.loc, {
3666
- code: p.EmptyBlockStatement,
3667
- severity: A.Warning
3668
- }), e.alternate && j(e.alternate) && this.logDiagnostic(e.alternate.loc, {
3669
- code: p.EmptyBlockStatement,
3670
- severity: A.Warning
1747
+ this.validateExpression(e.test), P(e.consequent) && this.logDiagnostic(e.consequent.loc, {
1748
+ code: h.EmptyBlockStatement,
1749
+ severity: g.Warning
1750
+ }), e.alternate && P(e.alternate) && this.logDiagnostic(e.alternate.loc, {
1751
+ code: h.EmptyBlockStatement,
1752
+ severity: g.Warning
3671
1753
  }), this.inBlock(this.validateStatement, e.consequent), this.inBlock(this.validateStatement, e.alternate);
3672
1754
  }
3673
1755
  validateAssignmentExpression(e) {
3674
1756
  const t = this._identifierBeingAssigned, i = this._assignmentValidationMode;
3675
- I(e.left) && (this._identifierBeingAssigned = e.left.name.toLowerCase(), this._assignmentValidationMode = "left"), this.validateExpression(e.left), I(e.left) && (this._assignmentValidationMode = "right"), this.validateExpression(e.right), this._identifierBeingAssigned = t, this._assignmentValidationMode = i;
1757
+ a.isIdentifier(e.left) && (this._identifierBeingAssigned = e.left.name.toLowerCase(), this._assignmentValidationMode = "left"), this.validateExpression(e.left), a.isIdentifier(e.left) && (this._assignmentValidationMode = "right"), this.validateExpression(e.right), this._identifierBeingAssigned = t, this._assignmentValidationMode = i;
3676
1758
  }
3677
1759
  validateCallExpression(e) {
3678
1760
  const t = this._isInCallExpression;
3679
- if (this._isInCallExpression = !0, this.validateExpression(e.callee), I(e.callee)) {
3680
- const i = e.callee.name.toLowerCase(), r = this.getIdentifierInfo(i), s = this._apiDatabase?.functionDefinitions.get(i);
3681
- if (!r && s) {
3682
- const a = ai(s, e.arguments.length);
3683
- a && this.logDiagnostic(e.loc, a);
1761
+ if (this._isInCallExpression = !0, this.validateExpression(e.callee), a.isIdentifier(e.callee)) {
1762
+ const i = e.callee.name.toLowerCase(), s = this.getIdentifierInfo(i), r = this._apiDatabase?.functionDefinitions.get(i);
1763
+ if (!s && r) {
1764
+ const o = tt(r, e.arguments.length);
1765
+ o && this.logDiagnostic(e.loc, o);
3684
1766
  }
3685
1767
  }
3686
1768
  e.arguments.forEach(this.validateExpression), this._isInCallExpression = t;
@@ -3702,30 +1784,30 @@ class si {
3702
1784
  if (this._isInCallExpression)
3703
1785
  return;
3704
1786
  this.logDiagnostic(e.loc, {
3705
- code: p.InvalidApiFunctionUsage,
1787
+ code: h.InvalidApiFunctionUsage,
3706
1788
  data: { identifier: e.name }
3707
1789
  });
3708
1790
  return;
3709
1791
  }
3710
1792
  if (this._isInFunctionScope) {
3711
- let r = this._undeclaredIdentifiersInFunctions.get(t);
3712
- r || (r = [], this._undeclaredIdentifiersInFunctions.set(t, r)), r.push({ node: e, identifier: t });
1793
+ let s = this._undeclaredIdentifiersInFunctions.get(t);
1794
+ s || (s = [], this._undeclaredIdentifiersInFunctions.set(t, s)), s.push({ node: e, identifier: t });
3713
1795
  return;
3714
1796
  }
3715
- this.logDiagnostic(e.loc, { code: p.NotDefined, data: { identifier: e.name } });
1797
+ this.logDiagnostic(e.loc, { code: h.NotDefined, data: { identifier: e.name } });
3716
1798
  }
3717
1799
  }
3718
1800
  validateLiteral(e) {
3719
- ci(e.raw).forEach((t) => {
1801
+ nt(e.raw).forEach((t) => {
3720
1802
  const i = this.getIdentifierInfo(t.toLowerCase());
3721
1803
  i && (i.used = !0);
3722
1804
  });
3723
1805
  }
3724
1806
  logProfileOrApiConflict(e) {
3725
- const t = e.name.toLowerCase(), i = this.isProfileVariable(t), r = this.isApiItem(t);
3726
- !i && !r || this.logDiagnostic(e.loc, {
3727
- code: i ? p.ProfileVariablesConflict : p.ApiConflict,
3728
- severity: A.Warning,
1807
+ const t = e.name.toLowerCase(), i = this.isProfileVariable(t), s = this.isApiItem(t);
1808
+ !i && !s || this.logDiagnostic(e.loc, {
1809
+ code: i ? h.ProfileVariablesConflict : h.ApiConflict,
1810
+ severity: g.Warning,
3729
1811
  data: {
3730
1812
  identifier: e.name
3731
1813
  }
@@ -3733,9 +1815,9 @@ class si {
3733
1815
  }
3734
1816
  logReservedKeywordsConflict(e) {
3735
1817
  const t = e.name.toLowerCase();
3736
- Ot.includes(t) && this.logDiagnostic(e.loc, {
3737
- code: p.ReservedKeyword,
3738
- severity: A.Warning,
1818
+ De.includes(t) && this.logDiagnostic(e.loc, {
1819
+ code: h.ReservedKeyword,
1820
+ severity: g.Warning,
3739
1821
  data: {
3740
1822
  identifier: e.name
3741
1823
  }
@@ -3760,155 +1842,155 @@ class si {
3760
1842
  }
3761
1843
  validateMemberExpression(e) {
3762
1844
  const t = this.flattenMemberExpressionAndValidate(e), i = t[0].object;
3763
- this.disableRecordIdentifierAssignment(this.validateExpression, i), I(i) && (this.getIdentifierInfo(i.name.toLowerCase()) || this.validateMemberExpressionWithProfile(t) || this.validateConstantMemberExpression(t));
1845
+ this.disableRecordIdentifierAssignment(this.validateExpression, i), a.isIdentifier(i) && (this.getIdentifierInfo(i.name.toLowerCase()) || this.validateMemberExpressionWithProfile(t) || this.validateConstantMemberExpression(t));
3764
1846
  }
3765
1847
  flattenMemberExpressionAndValidate(e) {
3766
1848
  switch (e.type) {
3767
- case u.SafeMemberExpression:
3768
- case u.MemberExpression:
3769
- return (!I(e.property) || e.computed) && this.validateExpression(e.property), [...this.flattenMemberExpressionAndValidate(e.object), e];
1849
+ case a.NodeTypes.SafeMemberExpression:
1850
+ case a.NodeTypes.MemberExpression:
1851
+ return (!a.isIdentifier(e.property) || e.computed) && this.validateExpression(e.property), [...this.flattenMemberExpressionAndValidate(e.object), e];
3770
1852
  default:
3771
1853
  return [];
3772
1854
  }
3773
1855
  }
3774
1856
  extractAndValidatePropertyName(e) {
3775
1857
  switch (e.type) {
3776
- case u.Identifier:
1858
+ case a.NodeTypes.Identifier:
3777
1859
  return e.name.toLowerCase();
3778
- case u.Literal:
3779
- return typeof e.value != "string" ? (this.logDiagnostic(e.loc, { code: p.UnexpectedPropertyIdentifier }), null) : e.value.toLowerCase();
1860
+ case a.NodeTypes.Literal:
1861
+ return typeof e.value != "string" ? (this.logDiagnostic(e.loc, { code: h.UnexpectedPropertyIdentifier }), null) : e.value.toLowerCase();
3780
1862
  default:
3781
- return this.logDiagnostic(e.loc, { code: p.UnexpectedPropertyIdentifier }), null;
1863
+ return this.logDiagnostic(e.loc, { code: h.UnexpectedPropertyIdentifier }), null;
3782
1864
  }
3783
1865
  }
3784
1866
  validateConstantMemberExpression(e) {
3785
1867
  const t = e[0];
3786
- if (!I(t.object))
1868
+ if (!a.isIdentifier(t.object))
3787
1869
  return !1;
3788
- const i = t.object.name.toLowerCase(), r = this._apiDatabase?.constantDefinitions.get(i);
3789
- if (!r)
1870
+ const i = t.object.name.toLowerCase(), s = this._apiDatabase?.constantDefinitions.get(i);
1871
+ if (!s)
3790
1872
  return !1;
3791
- if (r.type !== "namespace")
1873
+ if (s.type !== "namespace")
3792
1874
  return this.logDiagnostic(t.property.loc, {
3793
- code: p.NotADictionary,
1875
+ code: h.NotADictionary,
3794
1876
  data: { identifier: i }
3795
1877
  }), !0;
3796
- const s = this.extractAndValidatePropertyName(t.property);
3797
- if (!s)
1878
+ const r = this.extractAndValidatePropertyName(t.property);
1879
+ if (!r)
3798
1880
  return !0;
3799
- if (!r.members.some((a) => a.name.toLowerCase() === s)) {
3800
- const a = r.members.reduce(
3801
- (o, c) => `${o}${o ? " | " : ""}${c.completion.label.split(".").pop()}`,
1881
+ if (!s.members.some((o) => o.name.toLowerCase() === r)) {
1882
+ const o = s.members.reduce(
1883
+ (c, l) => `${c}${c ? " | " : ""}${l.completion.label.split(".").pop()}`,
3802
1884
  ""
3803
1885
  );
3804
1886
  this.logDiagnostic(t.property.loc, {
3805
- code: p.InvalidConstantIdentifier,
3806
- data: { list: a }
1887
+ code: h.InvalidConstantIdentifier,
1888
+ data: { list: o }
3807
1889
  });
3808
1890
  }
3809
- return e.length > 1 && this.logDiagnostic(e[1].property.loc, { code: p.UnexpectedPropertyIdentifier }), !0;
1891
+ return e.length > 1 && this.logDiagnostic(e[1].property.loc, { code: h.UnexpectedPropertyIdentifier }), !0;
3810
1892
  }
3811
1893
  validateMemberExpressionWithProfile(e) {
3812
1894
  const t = e[0];
3813
- if (t.object.type !== u.Identifier)
1895
+ if (t.object.type !== a.NodeTypes.Identifier)
3814
1896
  return !1;
3815
- const i = t.object.name.toLowerCase(), r = this._profileVariables.find((a) => a.name.toLowerCase() === i);
3816
- if (!r)
1897
+ const i = t.object.name.toLowerCase(), s = this._profileVariables.find((o) => o.name.toLowerCase() === i);
1898
+ if (!s)
3817
1899
  return !1;
3818
- if (Ee(r))
1900
+ if (R(s))
3819
1901
  return this.logDiagnostic(t.object.loc, {
3820
- code: p.NotADictionary,
3821
- data: { identifier: r.name }
1902
+ code: h.NotADictionary,
1903
+ data: { identifier: s.name }
3822
1904
  }), !0;
3823
1905
  if (this._identifierBeingAssigned === i)
3824
- return this.logDiagnostic(t.loc, { code: p.ProfileVariablesAreImmutable }), !0;
3825
- let s = r;
3826
- for (let a = 0; a < e.length; a++) {
3827
- if (e[a].computed)
1906
+ return this.logDiagnostic(t.loc, { code: h.ProfileVariablesAreImmutable }), !0;
1907
+ let r = s;
1908
+ for (let o = 0; o < e.length; o++) {
1909
+ if (e[o].computed)
3828
1910
  return !0;
3829
- if (Ee(s))
3830
- return this.logDiagnostic(e[a - 1]?.property.loc ?? e[a].object.loc, {
3831
- code: p.NotADictionary,
3832
- data: { identifier: s.name }
1911
+ if (R(r))
1912
+ return this.logDiagnostic(e[o - 1]?.property.loc ?? e[o].object.loc, {
1913
+ code: h.NotADictionary,
1914
+ data: { identifier: r.name }
3833
1915
  }), !0;
3834
- const o = this.extractAndValidatePropertyName(e[a].property);
3835
- if (!o)
1916
+ const c = this.extractAndValidatePropertyName(e[o].property);
1917
+ if (!c)
3836
1918
  return !0;
3837
- if (!s.properties || s.properties.length === 0)
3838
- return this.logDiagnostic(e[a].property.loc, {
3839
- code: p.UnknownPropertyIdentifier,
3840
- data: { identifier: o },
3841
- severity: A.Warning
1919
+ if (!r.properties || r.properties.length === 0)
1920
+ return this.logDiagnostic(e[o].property.loc, {
1921
+ code: h.UnknownPropertyIdentifier,
1922
+ data: { identifier: c },
1923
+ severity: g.Warning
3842
1924
  }), !0;
3843
- const c = s.properties.find(
3844
- (d) => d.name.toLowerCase() === o
1925
+ const l = r.properties.find(
1926
+ (p) => p.name.toLowerCase() === c
3845
1927
  );
3846
- if (!c) {
3847
- const d = s.properties.reduce(
3848
- (E, F) => `${E}${E ? " | " : ""}${F.name.split(".").pop()}`,
1928
+ if (!l) {
1929
+ const p = r.properties.reduce(
1930
+ (y, C) => `${y}${y ? " | " : ""}${C.name.split(".").pop()}`,
3849
1931
  ""
3850
1932
  );
3851
- return this.logDiagnostic(e[a].property.loc, {
3852
- code: p.InvalidPropertyIdentifier,
3853
- data: { list: d }
1933
+ return this.logDiagnostic(e[o].property.loc, {
1934
+ code: h.InvalidPropertyIdentifier,
1935
+ data: { list: p }
3854
1936
  }), !0;
3855
1937
  }
3856
- s = c;
1938
+ r = l;
3857
1939
  }
3858
1940
  return !0;
3859
1941
  }
3860
1942
  recordVariableIdentifier(e, t) {
3861
1943
  this.logReservedKeywordsConflict(e), this.logProfileOrApiConflict(e);
3862
1944
  const i = e.name.toLowerCase();
3863
- let r = this.getIdentifierInfo(i);
3864
- const s = this._isInFunctionScope && r?.scope === "function", a = !this._isInFunctionScope && r?.scope === "script";
3865
- (s || a) && this.logDiagnostic(e.loc, {
3866
- code: p.AlreadyDefined,
1945
+ let s = this.getIdentifierInfo(i);
1946
+ const r = this._isInFunctionScope && s?.scope === "function", o = !this._isInFunctionScope && s?.scope === "script";
1947
+ (r || o) && this.logDiagnostic(e.loc, {
1948
+ code: h.AlreadyDefined,
3867
1949
  data: { identifier: e.name },
3868
- severity: A.Warning
1950
+ severity: g.Warning
3869
1951
  });
3870
- const o = t.inBlock ?? this._isInBlock, { initialized: c } = t;
3871
- if (!r || this._isInFunctionScope && r.scope !== "function") {
3872
- const d = this._isInFunctionScope ? "function" : o ? "block" : "script";
3873
- r = {
1952
+ const c = t.inBlock ?? this._isInBlock, { initialized: l } = t;
1953
+ if (!s || this._isInFunctionScope && s.scope !== "function") {
1954
+ const p = this._isInFunctionScope ? "function" : c ? "block" : "script";
1955
+ s = {
3874
1956
  node: e,
3875
1957
  used: !1,
3876
- initialized: c,
3877
- scope: d
1958
+ initialized: l,
1959
+ scope: p
3878
1960
  };
3879
1961
  } else
3880
- r.node = e, r.used = !1, r.initialized = c;
3881
- return r.scope === "block" && !o && (r.scope = "script", this.logDiagnostic(e.loc, {
3882
- code: p.AlreadyDefined,
1962
+ s.node = e, s.used = !1, s.initialized = l;
1963
+ return s.scope === "block" && !c && (s.scope = "script", this.logDiagnostic(e.loc, {
1964
+ code: h.AlreadyDefined,
3883
1965
  data: { identifier: e.name },
3884
- severity: A.Warning
3885
- })), this.setIdentifierInfo(i, r), !1;
1966
+ severity: g.Warning
1967
+ })), this.setIdentifierInfo(i, s), !1;
3886
1968
  }
3887
1969
  recordImportIdentifier(e) {
3888
1970
  const t = e.specifiers[0].local;
3889
1971
  this.logProfileOrApiConflict(t);
3890
1972
  const i = t.name.toLowerCase();
3891
- let r = this.getIdentifierInfo(i);
3892
- r?.scope && this.logDiagnostic(e.specifiers[0].local.loc, {
3893
- code: p.AlreadyDefined,
1973
+ let s = this.getIdentifierInfo(i);
1974
+ s?.scope && this.logDiagnostic(e.specifiers[0].local.loc, {
1975
+ code: h.AlreadyDefined,
3894
1976
  data: { identifier: e.specifiers[0].local.name },
3895
- severity: A.Warning
3896
- }), r = {
1977
+ severity: g.Warning
1978
+ }), s = {
3897
1979
  node: e.specifiers[0].local,
3898
1980
  used: !1,
3899
- ...r,
1981
+ ...s,
3900
1982
  scope: "script",
3901
1983
  initialized: !0
3902
- }, this.setIdentifierInfo(i, r);
1984
+ }, this.setIdentifierInfo(i, s);
3903
1985
  }
3904
1986
  recordFunctionIdentifier(e) {
3905
1987
  this.logProfileOrApiConflict(e.id);
3906
1988
  const t = e.id.name.toLowerCase();
3907
1989
  let i = this.getIdentifierInfo(t);
3908
1990
  i?.scope && this.logDiagnostic(e.id.loc, {
3909
- code: p.AlreadyDefined,
1991
+ code: h.AlreadyDefined,
3910
1992
  data: { identifier: e.id.name },
3911
- severity: A.Warning
1993
+ severity: g.Warning
3912
1994
  }), i = {
3913
1995
  node: e.id,
3914
1996
  used: !1,
@@ -3923,62 +2005,80 @@ class si {
3923
2005
  diagnoseIdentifiers() {
3924
2006
  (this._functionScopeIdentifiers ?? this._scriptScopeIdentifiers).forEach((e) => {
3925
2007
  e.used ? e.initialized || this.logDiagnostic(e.node.loc, {
3926
- code: p.DefinedNeverAssigned,
2008
+ code: h.DefinedNeverAssigned,
3927
2009
  data: { identifier: e.node.name },
3928
- severity: A.Warning
2010
+ severity: g.Warning
3929
2011
  }) : this.logDiagnostic(e.node.loc, {
3930
- code: e.initialized ? p.AssignedNeverUsed : p.DefinedNeverUsed,
2012
+ code: e.initialized ? h.AssignedNeverUsed : h.DefinedNeverUsed,
3931
2013
  data: { identifier: e.node.name },
3932
- severity: A.Warning
2014
+ severity: g.Warning
3933
2015
  });
3934
2016
  });
3935
2017
  }
3936
2018
  }
3937
- function ui(n) {
2019
+ function et(n) {
3938
2020
  return !!n && n.name === "ParsingError";
3939
2021
  }
3940
- function j(n) {
3941
- return pe(n) || b(n) && !n.body.length;
2022
+ function P(n) {
2023
+ return a.isEmptyStatement(n) || a.isBlockStatement(n) && !n.body.length;
3942
2024
  }
3943
- function ai(n, e) {
2025
+ function tt(n, e) {
3944
2026
  const { min: t, max: i } = n.overloads.reduce(
3945
- (r, s) => {
3946
- const { min: a, max: o } = s.parametersInfo;
3947
- return r.min >= 0 && (r.min = Math.min(a, r.min)), r.max >= 0 && (r.max = o < 0 ? o : Math.max(o, r.max)), r;
2027
+ (s, r) => {
2028
+ const { min: o, max: c } = r.parametersInfo;
2029
+ return s.min >= 0 && (s.min = Math.min(o, s.min)), s.max >= 0 && (s.max = c < 0 ? c : Math.max(c, s.max)), s;
3948
2030
  },
3949
2031
  { min: Number.POSITIVE_INFINITY, max: 0 }
3950
2032
  );
3951
- return e < t ? t > 0 ? { code: p.NotEnoughArguments, data: { min: t } } : { code: p.NoArgumentExpected } : i >= 0 && e > i ? { code: p.TooManyArguments, data: { max: i } } : null;
2033
+ return e < t ? t > 0 ? { code: h.NotEnoughArguments, data: { min: t } } : { code: h.NoArgumentExpected } : i >= 0 && e > i ? { code: h.TooManyArguments, data: { max: i } } : null;
3952
2034
  }
3953
- const oi = /\B@\w+/gu;
3954
- function ci(n = "") {
3955
- return Array.from(n.matchAll(oi), (e) => e[0].slice(1));
2035
+ const it = /\B@\w+/gu;
2036
+ function nt(n = "") {
2037
+ return Array.from(n.matchAll(it), (e) => e[0].slice(1));
3956
2038
  }
3957
- class pi {
2039
+ class ct {
2040
+ /** @public */
2041
+ constructor() {
2042
+ }
2043
+ /**
2044
+ * @public
2045
+ * @param settings
2046
+ */
3958
2047
  configure(e) {
3959
- this.apiService = new Je(e);
2048
+ this.apiService = new ne(e);
3960
2049
  }
2050
+ /**
2051
+ * @public
2052
+ * @param document
2053
+ * @param context
2054
+ */
3961
2055
  async doValidation(e, t) {
3962
2056
  if (!this.apiService)
3963
2057
  return [];
3964
- const i = await this.apiService.getApiDatabase(t), { profile: { variables: r = [] } = {} } = t, { diagnostics: s } = new si(i, r).validateScript(e.getText());
3965
- return s;
2058
+ const i = await this.apiService.getApiDatabase(t), { profile: { variables: s = [] } = {} } = t, { diagnostics: r } = new Xe(i, s).validateScript(e.getText());
2059
+ return r;
3966
2060
  }
2061
+ /**
2062
+ * @public
2063
+ * @param document
2064
+ * @param position
2065
+ * @param context
2066
+ */
3967
2067
  async doComplete(e, t, i) {
3968
2068
  if (!this.apiService)
3969
2069
  return { isIncomplete: !1, items: [] };
3970
- const r = await this.apiService.getApiDatabase(i);
3971
- return Wt(e, t, r, i);
2070
+ const s = await this.apiService.getApiDatabase(i);
2071
+ return Ve(e, t, s, i);
3972
2072
  }
3973
2073
  }
3974
2074
  export {
3975
- Mt as ArcadeKeywords,
3976
- pi as ArcadeLanguageService,
3977
- Ut as ArcadeLiterals,
3978
- Ot as ArcadeReservedKeywords,
3979
- ht as DiagnosticMessages,
3980
- fi as DiagnosticSeverity,
3981
- p as ValidationDiagnosticCodes,
3982
- Di as arcadeFormat,
3983
- Nt as format
2075
+ ve as ArcadeKeywords,
2076
+ ct as ArcadeLanguageService,
2077
+ Ae as ArcadeLiterals,
2078
+ De as ArcadeReservedKeywords,
2079
+ se as DiagnosticMessages,
2080
+ ht as DiagnosticSeverity,
2081
+ h as ValidationDiagnosticCodes,
2082
+ ot as arcadeFormat,
2083
+ Ce as format
3984
2084
  };