UNPKG

208 kBJavaScriptView Raw
1/* MIT License
2
3Copyright (c) 2021-Present Anthony Fu <https://github.com/antfu>
4Copyright (c) 2021-Present Matias Capeletto <https://github.com/patak-dev>
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in all
14copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22SOFTWARE.
23 */
24import { builtinModules, createRequire } from "module";
25import { pathToFileURL, fileURLToPath } from "url";
26import vm from "vm";
27import path from "path";
28import "fs";
29import assert from "assert";
30import { format as format$1, inspect } from "util";
31function normalizeWindowsPath(input = "") {
32 if (!input.includes("\\")) {
33 return input;
34 }
35 return input.replace(/\\/g, "/");
36}
37const _UNC_REGEX = /^[/][/]/;
38const _UNC_DRIVE_REGEX = /^[/][/]([.]{1,2}[/])?([a-zA-Z]):[/]/;
39const _IS_ABSOLUTE_RE = /^\/|^\\|^[a-zA-Z]:[/\\]/;
40const sep = "/";
41const delimiter = ":";
42const normalize = function(path2) {
43 if (path2.length === 0) {
44 return ".";
45 }
46 path2 = normalizeWindowsPath(path2);
47 const isUNCPath = path2.match(_UNC_REGEX);
48 const hasUNCDrive = isUNCPath && path2.match(_UNC_DRIVE_REGEX);
49 const isPathAbsolute = isAbsolute(path2);
50 const trailingSeparator = path2[path2.length - 1] === "/";
51 path2 = normalizeString(path2, !isPathAbsolute);
52 if (path2.length === 0) {
53 if (isPathAbsolute) {
54 return "/";
55 }
56 return trailingSeparator ? "./" : ".";
57 }
58 if (trailingSeparator) {
59 path2 += "/";
60 }
61 if (isUNCPath) {
62 if (hasUNCDrive) {
63 return `//./${path2}`;
64 }
65 return `//${path2}`;
66 }
67 return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
68};
69const join = function(...args) {
70 if (args.length === 0) {
71 return ".";
72 }
73 let joined;
74 for (let i = 0; i < args.length; ++i) {
75 const arg = args[i];
76 if (arg.length > 0) {
77 if (joined === void 0) {
78 joined = arg;
79 } else {
80 joined += `/${arg}`;
81 }
82 }
83 }
84 if (joined === void 0) {
85 return ".";
86 }
87 return normalize(joined);
88};
89const resolve = function(...args) {
90 args = args.map((arg) => normalizeWindowsPath(arg));
91 let resolvedPath = "";
92 let resolvedAbsolute = false;
93 for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
94 const path2 = i >= 0 ? args[i] : process.cwd();
95 if (path2.length === 0) {
96 continue;
97 }
98 resolvedPath = `${path2}/${resolvedPath}`;
99 resolvedAbsolute = isAbsolute(path2);
100 }
101 resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
102 if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
103 return `/${resolvedPath}`;
104 }
105 return resolvedPath.length > 0 ? resolvedPath : ".";
106};
107function normalizeString(path2, allowAboveRoot) {
108 let res = "";
109 let lastSegmentLength = 0;
110 let lastSlash = -1;
111 let dots = 0;
112 let char = null;
113 for (let i = 0; i <= path2.length; ++i) {
114 if (i < path2.length) {
115 char = path2[i];
116 } else if (char === "/") {
117 break;
118 } else {
119 char = "/";
120 }
121 if (char === "/") {
122 if (lastSlash === i - 1 || dots === 1)
123 ;
124 else if (dots === 2) {
125 if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
126 if (res.length > 2) {
127 const lastSlashIndex = res.lastIndexOf("/");
128 if (lastSlashIndex === -1) {
129 res = "";
130 lastSegmentLength = 0;
131 } else {
132 res = res.slice(0, lastSlashIndex);
133 lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
134 }
135 lastSlash = i;
136 dots = 0;
137 continue;
138 } else if (res.length !== 0) {
139 res = "";
140 lastSegmentLength = 0;
141 lastSlash = i;
142 dots = 0;
143 continue;
144 }
145 }
146 if (allowAboveRoot) {
147 res += res.length > 0 ? "/.." : "..";
148 lastSegmentLength = 2;
149 }
150 } else {
151 if (res.length > 0) {
152 res += `/${path2.slice(lastSlash + 1, i)}`;
153 } else {
154 res = path2.slice(lastSlash + 1, i);
155 }
156 lastSegmentLength = i - lastSlash - 1;
157 }
158 lastSlash = i;
159 dots = 0;
160 } else if (char === "." && dots !== -1) {
161 ++dots;
162 } else {
163 dots = -1;
164 }
165 }
166 return res;
167}
168const isAbsolute = function(p) {
169 return _IS_ABSOLUTE_RE.test(p);
170};
171const toNamespacedPath = function(p) {
172 return normalizeWindowsPath(p);
173};
174const extname = function(p) {
175 return path.posix.extname(normalizeWindowsPath(p));
176};
177const relative = function(from, to) {
178 return path.posix.relative(normalizeWindowsPath(from), normalizeWindowsPath(to));
179};
180const dirname = function(p) {
181 return path.posix.dirname(normalizeWindowsPath(p));
182};
183const format = function(p) {
184 return normalizeWindowsPath(path.posix.format(p));
185};
186const basename = function(p, ext) {
187 return path.posix.basename(normalizeWindowsPath(p), ext);
188};
189const parse = function(p) {
190 return path.posix.parse(normalizeWindowsPath(p));
191};
192const _path = /* @__PURE__ */ Object.freeze({
193 __proto__: null,
194 sep,
195 delimiter,
196 normalize,
197 join,
198 resolve,
199 normalizeString,
200 isAbsolute,
201 toNamespacedPath,
202 extname,
203 relative,
204 dirname,
205 format,
206 basename,
207 parse
208});
209({
210 ..._path
211});
212var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 154, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 161, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 19306, 9, 87, 9, 39, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4706, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 262, 6, 10, 9, 357, 0, 62, 13, 1495, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
213var astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 68, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 85, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 190, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1070, 4050, 582, 8634, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 43, 8, 8936, 3, 2, 6, 2, 1, 2, 290, 46, 2, 18, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 482, 44, 11, 6, 17, 0, 322, 29, 19, 43, 1269, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4152, 8, 221, 3, 5761, 15, 7472, 3104, 541, 1507, 4938];
214var nonASCIIidentifierChars = "\u200C\u200D\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECD\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1ABF-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA8FF-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F";
215var nonASCIIidentifierStartChars = "\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\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\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\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\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-\u1711\u171F-\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-\u1B4C\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-\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-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\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-\uAB69\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";
216var reservedWords = {
217 3: "abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",
218 5: "class enum extends super const export import",
219 6: "enum",
220 strict: "implements interface let package private protected public static yield",
221 strictBind: "eval arguments"
222};
223var ecma5AndLessKeywords = "break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this";
224var keywords$1 = {
225 5: ecma5AndLessKeywords,
226 "5module": ecma5AndLessKeywords + " export import",
227 6: ecma5AndLessKeywords + " const class extends export import super"
228};
229var keywordRelationalOperator = /^in(stanceof)?$/;
230var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
231var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
232function isInAstralSet(code, set) {
233 var pos = 65536;
234 for (var i = 0; i < set.length; i += 2) {
235 pos += set[i];
236 if (pos > code) {
237 return false;
238 }
239 pos += set[i + 1];
240 if (pos >= code) {
241 return true;
242 }
243 }
244}
245function isIdentifierStart(code, astral) {
246 if (code < 65) {
247 return code === 36;
248 }
249 if (code < 91) {
250 return true;
251 }
252 if (code < 97) {
253 return code === 95;
254 }
255 if (code < 123) {
256 return true;
257 }
258 if (code <= 65535) {
259 return code >= 170 && nonASCIIidentifierStart.test(String.fromCharCode(code));
260 }
261 if (astral === false) {
262 return false;
263 }
264 return isInAstralSet(code, astralIdentifierStartCodes);
265}
266function isIdentifierChar(code, astral) {
267 if (code < 48) {
268 return code === 36;
269 }
270 if (code < 58) {
271 return true;
272 }
273 if (code < 65) {
274 return false;
275 }
276 if (code < 91) {
277 return true;
278 }
279 if (code < 97) {
280 return code === 95;
281 }
282 if (code < 123) {
283 return true;
284 }
285 if (code <= 65535) {
286 return code >= 170 && nonASCIIidentifier.test(String.fromCharCode(code));
287 }
288 if (astral === false) {
289 return false;
290 }
291 return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
292}
293var TokenType = function TokenType2(label, conf) {
294 if (conf === void 0)
295 conf = {};
296 this.label = label;
297 this.keyword = conf.keyword;
298 this.beforeExpr = !!conf.beforeExpr;
299 this.startsExpr = !!conf.startsExpr;
300 this.isLoop = !!conf.isLoop;
301 this.isAssign = !!conf.isAssign;
302 this.prefix = !!conf.prefix;
303 this.postfix = !!conf.postfix;
304 this.binop = conf.binop || null;
305 this.updateContext = null;
306};
307function binop(name, prec) {
308 return new TokenType(name, { beforeExpr: true, binop: prec });
309}
310var beforeExpr = { beforeExpr: true }, startsExpr = { startsExpr: true };
311var keywords = {};
312function kw(name, options) {
313 if (options === void 0)
314 options = {};
315 options.keyword = name;
316 return keywords[name] = new TokenType(name, options);
317}
318var types$1 = {
319 num: new TokenType("num", startsExpr),
320 regexp: new TokenType("regexp", startsExpr),
321 string: new TokenType("string", startsExpr),
322 name: new TokenType("name", startsExpr),
323 privateId: new TokenType("privateId", startsExpr),
324 eof: new TokenType("eof"),
325 bracketL: new TokenType("[", { beforeExpr: true, startsExpr: true }),
326 bracketR: new TokenType("]"),
327 braceL: new TokenType("{", { beforeExpr: true, startsExpr: true }),
328 braceR: new TokenType("}"),
329 parenL: new TokenType("(", { beforeExpr: true, startsExpr: true }),
330 parenR: new TokenType(")"),
331 comma: new TokenType(",", beforeExpr),
332 semi: new TokenType(";", beforeExpr),
333 colon: new TokenType(":", beforeExpr),
334 dot: new TokenType("."),
335 question: new TokenType("?", beforeExpr),
336 questionDot: new TokenType("?."),
337 arrow: new TokenType("=>", beforeExpr),
338 template: new TokenType("template"),
339 invalidTemplate: new TokenType("invalidTemplate"),
340 ellipsis: new TokenType("...", beforeExpr),
341 backQuote: new TokenType("`", startsExpr),
342 dollarBraceL: new TokenType("${", { beforeExpr: true, startsExpr: true }),
343 eq: new TokenType("=", { beforeExpr: true, isAssign: true }),
344 assign: new TokenType("_=", { beforeExpr: true, isAssign: true }),
345 incDec: new TokenType("++/--", { prefix: true, postfix: true, startsExpr: true }),
346 prefix: new TokenType("!/~", { beforeExpr: true, prefix: true, startsExpr: true }),
347 logicalOR: binop("||", 1),
348 logicalAND: binop("&&", 2),
349 bitwiseOR: binop("|", 3),
350 bitwiseXOR: binop("^", 4),
351 bitwiseAND: binop("&", 5),
352 equality: binop("==/!=/===/!==", 6),
353 relational: binop("</>/<=/>=", 7),
354 bitShift: binop("<</>>/>>>", 8),
355 plusMin: new TokenType("+/-", { beforeExpr: true, binop: 9, prefix: true, startsExpr: true }),
356 modulo: binop("%", 10),
357 star: binop("*", 10),
358 slash: binop("/", 10),
359 starstar: new TokenType("**", { beforeExpr: true }),
360 coalesce: binop("??", 1),
361 _break: kw("break"),
362 _case: kw("case", beforeExpr),
363 _catch: kw("catch"),
364 _continue: kw("continue"),
365 _debugger: kw("debugger"),
366 _default: kw("default", beforeExpr),
367 _do: kw("do", { isLoop: true, beforeExpr: true }),
368 _else: kw("else", beforeExpr),
369 _finally: kw("finally"),
370 _for: kw("for", { isLoop: true }),
371 _function: kw("function", startsExpr),
372 _if: kw("if"),
373 _return: kw("return", beforeExpr),
374 _switch: kw("switch"),
375 _throw: kw("throw", beforeExpr),
376 _try: kw("try"),
377 _var: kw("var"),
378 _const: kw("const"),
379 _while: kw("while", { isLoop: true }),
380 _with: kw("with"),
381 _new: kw("new", { beforeExpr: true, startsExpr: true }),
382 _this: kw("this", startsExpr),
383 _super: kw("super", startsExpr),
384 _class: kw("class", startsExpr),
385 _extends: kw("extends", beforeExpr),
386 _export: kw("export"),
387 _import: kw("import", startsExpr),
388 _null: kw("null", startsExpr),
389 _true: kw("true", startsExpr),
390 _false: kw("false", startsExpr),
391 _in: kw("in", { beforeExpr: true, binop: 7 }),
392 _instanceof: kw("instanceof", { beforeExpr: true, binop: 7 }),
393 _typeof: kw("typeof", { beforeExpr: true, prefix: true, startsExpr: true }),
394 _void: kw("void", { beforeExpr: true, prefix: true, startsExpr: true }),
395 _delete: kw("delete", { beforeExpr: true, prefix: true, startsExpr: true })
396};
397var lineBreak = /\r\n?|\n|\u2028|\u2029/;
398var lineBreakG = new RegExp(lineBreak.source, "g");
399function isNewLine(code) {
400 return code === 10 || code === 13 || code === 8232 || code === 8233;
401}
402function nextLineBreak(code, from, end) {
403 if (end === void 0)
404 end = code.length;
405 for (var i = from; i < end; i++) {
406 var next = code.charCodeAt(i);
407 if (isNewLine(next)) {
408 return i < end - 1 && next === 13 && code.charCodeAt(i + 1) === 10 ? i + 2 : i + 1;
409 }
410 }
411 return -1;
412}
413var nonASCIIwhitespace = /[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/;
414var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
415var ref = Object.prototype;
416var hasOwnProperty = ref.hasOwnProperty;
417var toString = ref.toString;
418var hasOwn = Object.hasOwn || function(obj, propName) {
419 return hasOwnProperty.call(obj, propName);
420};
421var isArray = Array.isArray || function(obj) {
422 return toString.call(obj) === "[object Array]";
423};
424function wordsRegexp(words) {
425 return new RegExp("^(?:" + words.replace(/ /g, "|") + ")$");
426}
427function codePointToString(code) {
428 if (code <= 65535) {
429 return String.fromCharCode(code);
430 }
431 code -= 65536;
432 return String.fromCharCode((code >> 10) + 55296, (code & 1023) + 56320);
433}
434var loneSurrogate = /(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/;
435var Position = function Position2(line, col) {
436 this.line = line;
437 this.column = col;
438};
439Position.prototype.offset = function offset(n) {
440 return new Position(this.line, this.column + n);
441};
442var SourceLocation = function SourceLocation2(p, start, end) {
443 this.start = start;
444 this.end = end;
445 if (p.sourceFile !== null) {
446 this.source = p.sourceFile;
447 }
448};
449function getLineInfo(input, offset2) {
450 for (var line = 1, cur = 0; ; ) {
451 var nextBreak = nextLineBreak(input, cur, offset2);
452 if (nextBreak < 0) {
453 return new Position(line, offset2 - cur);
454 }
455 ++line;
456 cur = nextBreak;
457 }
458}
459var defaultOptions = {
460 ecmaVersion: null,
461 sourceType: "script",
462 onInsertedSemicolon: null,
463 onTrailingComma: null,
464 allowReserved: null,
465 allowReturnOutsideFunction: false,
466 allowImportExportEverywhere: false,
467 allowAwaitOutsideFunction: null,
468 allowSuperOutsideMethod: null,
469 allowHashBang: false,
470 locations: false,
471 onToken: null,
472 onComment: null,
473 ranges: false,
474 program: null,
475 sourceFile: null,
476 directSourceFile: null,
477 preserveParens: false
478};
479var warnedAboutEcmaVersion = false;
480function getOptions(opts) {
481 var options = {};
482 for (var opt in defaultOptions) {
483 options[opt] = opts && hasOwn(opts, opt) ? opts[opt] : defaultOptions[opt];
484 }
485 if (options.ecmaVersion === "latest") {
486 options.ecmaVersion = 1e8;
487 } else if (options.ecmaVersion == null) {
488 if (!warnedAboutEcmaVersion && typeof console === "object" && console.warn) {
489 warnedAboutEcmaVersion = true;
490 console.warn("Since Acorn 8.0.0, options.ecmaVersion is required.\nDefaulting to 2020, but this will stop working in the future.");
491 }
492 options.ecmaVersion = 11;
493 } else if (options.ecmaVersion >= 2015) {
494 options.ecmaVersion -= 2009;
495 }
496 if (options.allowReserved == null) {
497 options.allowReserved = options.ecmaVersion < 5;
498 }
499 if (opts.allowHashBang == null) {
500 options.allowHashBang = options.ecmaVersion >= 14;
501 }
502 if (isArray(options.onToken)) {
503 var tokens = options.onToken;
504 options.onToken = function(token) {
505 return tokens.push(token);
506 };
507 }
508 if (isArray(options.onComment)) {
509 options.onComment = pushComment(options, options.onComment);
510 }
511 return options;
512}
513function pushComment(options, array) {
514 return function(block, text, start, end, startLoc, endLoc) {
515 var comment = {
516 type: block ? "Block" : "Line",
517 value: text,
518 start,
519 end
520 };
521 if (options.locations) {
522 comment.loc = new SourceLocation(this, startLoc, endLoc);
523 }
524 if (options.ranges) {
525 comment.range = [start, end];
526 }
527 array.push(comment);
528 };
529}
530var SCOPE_TOP = 1, SCOPE_FUNCTION = 2, SCOPE_ASYNC = 4, SCOPE_GENERATOR = 8, SCOPE_ARROW = 16, SCOPE_SIMPLE_CATCH = 32, SCOPE_SUPER = 64, SCOPE_DIRECT_SUPER = 128, SCOPE_CLASS_STATIC_BLOCK = 256, SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK;
531function functionFlags(async, generator) {
532 return SCOPE_FUNCTION | (async ? SCOPE_ASYNC : 0) | (generator ? SCOPE_GENERATOR : 0);
533}
534var BIND_NONE = 0, BIND_VAR = 1, BIND_LEXICAL = 2, BIND_FUNCTION = 3, BIND_SIMPLE_CATCH = 4, BIND_OUTSIDE = 5;
535var Parser = function Parser2(options, input, startPos) {
536 this.options = options = getOptions(options);
537 this.sourceFile = options.sourceFile;
538 this.keywords = wordsRegexp(keywords$1[options.ecmaVersion >= 6 ? 6 : options.sourceType === "module" ? "5module" : 5]);
539 var reserved = "";
540 if (options.allowReserved !== true) {
541 reserved = reservedWords[options.ecmaVersion >= 6 ? 6 : options.ecmaVersion === 5 ? 5 : 3];
542 if (options.sourceType === "module") {
543 reserved += " await";
544 }
545 }
546 this.reservedWords = wordsRegexp(reserved);
547 var reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict;
548 this.reservedWordsStrict = wordsRegexp(reservedStrict);
549 this.reservedWordsStrictBind = wordsRegexp(reservedStrict + " " + reservedWords.strictBind);
550 this.input = String(input);
551 this.containsEsc = false;
552 if (startPos) {
553 this.pos = startPos;
554 this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1;
555 this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length;
556 } else {
557 this.pos = this.lineStart = 0;
558 this.curLine = 1;
559 }
560 this.type = types$1.eof;
561 this.value = null;
562 this.start = this.end = this.pos;
563 this.startLoc = this.endLoc = this.curPosition();
564 this.lastTokEndLoc = this.lastTokStartLoc = null;
565 this.lastTokStart = this.lastTokEnd = this.pos;
566 this.context = this.initialContext();
567 this.exprAllowed = true;
568 this.inModule = options.sourceType === "module";
569 this.strict = this.inModule || this.strictDirective(this.pos);
570 this.potentialArrowAt = -1;
571 this.potentialArrowInForAwait = false;
572 this.yieldPos = this.awaitPos = this.awaitIdentPos = 0;
573 this.labels = [];
574 this.undefinedExports = /* @__PURE__ */ Object.create(null);
575 if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === "#!") {
576 this.skipLineComment(2);
577 }
578 this.scopeStack = [];
579 this.enterScope(SCOPE_TOP);
580 this.regexpState = null;
581 this.privateNameStack = [];
582};
583var prototypeAccessors = { inFunction: { configurable: true }, inGenerator: { configurable: true }, inAsync: { configurable: true }, canAwait: { configurable: true }, allowSuper: { configurable: true }, allowDirectSuper: { configurable: true }, treatFunctionsAsVar: { configurable: true }, allowNewDotTarget: { configurable: true }, inClassStaticBlock: { configurable: true } };
584Parser.prototype.parse = function parse2() {
585 var node = this.options.program || this.startNode();
586 this.nextToken();
587 return this.parseTopLevel(node);
588};
589prototypeAccessors.inFunction.get = function() {
590 return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0;
591};
592prototypeAccessors.inGenerator.get = function() {
593 return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0 && !this.currentVarScope().inClassFieldInit;
594};
595prototypeAccessors.inAsync.get = function() {
596 return (this.currentVarScope().flags & SCOPE_ASYNC) > 0 && !this.currentVarScope().inClassFieldInit;
597};
598prototypeAccessors.canAwait.get = function() {
599 for (var i = this.scopeStack.length - 1; i >= 0; i--) {
600 var scope = this.scopeStack[i];
601 if (scope.inClassFieldInit || scope.flags & SCOPE_CLASS_STATIC_BLOCK) {
602 return false;
603 }
604 if (scope.flags & SCOPE_FUNCTION) {
605 return (scope.flags & SCOPE_ASYNC) > 0;
606 }
607 }
608 return this.inModule && this.options.ecmaVersion >= 13 || this.options.allowAwaitOutsideFunction;
609};
610prototypeAccessors.allowSuper.get = function() {
611 var ref2 = this.currentThisScope();
612 var flags = ref2.flags;
613 var inClassFieldInit = ref2.inClassFieldInit;
614 return (flags & SCOPE_SUPER) > 0 || inClassFieldInit || this.options.allowSuperOutsideMethod;
615};
616prototypeAccessors.allowDirectSuper.get = function() {
617 return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0;
618};
619prototypeAccessors.treatFunctionsAsVar.get = function() {
620 return this.treatFunctionsAsVarInScope(this.currentScope());
621};
622prototypeAccessors.allowNewDotTarget.get = function() {
623 var ref2 = this.currentThisScope();
624 var flags = ref2.flags;
625 var inClassFieldInit = ref2.inClassFieldInit;
626 return (flags & (SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK)) > 0 || inClassFieldInit;
627};
628prototypeAccessors.inClassStaticBlock.get = function() {
629 return (this.currentVarScope().flags & SCOPE_CLASS_STATIC_BLOCK) > 0;
630};
631Parser.extend = function extend() {
632 var plugins = [], len = arguments.length;
633 while (len--)
634 plugins[len] = arguments[len];
635 var cls = this;
636 for (var i = 0; i < plugins.length; i++) {
637 cls = plugins[i](cls);
638 }
639 return cls;
640};
641Parser.parse = function parse3(input, options) {
642 return new this(options, input).parse();
643};
644Parser.parseExpressionAt = function parseExpressionAt(input, pos, options) {
645 var parser = new this(options, input, pos);
646 parser.nextToken();
647 return parser.parseExpression();
648};
649Parser.tokenizer = function tokenizer(input, options) {
650 return new this(options, input);
651};
652Object.defineProperties(Parser.prototype, prototypeAccessors);
653var pp$9 = Parser.prototype;
654var literal = /^(?:'((?:\\.|[^'\\])*?)'|"((?:\\.|[^"\\])*?)")/;
655pp$9.strictDirective = function(start) {
656 if (this.options.ecmaVersion < 5) {
657 return false;
658 }
659 for (; ; ) {
660 skipWhiteSpace.lastIndex = start;
661 start += skipWhiteSpace.exec(this.input)[0].length;
662 var match = literal.exec(this.input.slice(start));
663 if (!match) {
664 return false;
665 }
666 if ((match[1] || match[2]) === "use strict") {
667 skipWhiteSpace.lastIndex = start + match[0].length;
668 var spaceAfter = skipWhiteSpace.exec(this.input), end = spaceAfter.index + spaceAfter[0].length;
669 var next = this.input.charAt(end);
670 return next === ";" || next === "}" || lineBreak.test(spaceAfter[0]) && !(/[(`.[+\-/*%<>=,?^&]/.test(next) || next === "!" && this.input.charAt(end + 1) === "=");
671 }
672 start += match[0].length;
673 skipWhiteSpace.lastIndex = start;
674 start += skipWhiteSpace.exec(this.input)[0].length;
675 if (this.input[start] === ";") {
676 start++;
677 }
678 }
679};
680pp$9.eat = function(type) {
681 if (this.type === type) {
682 this.next();
683 return true;
684 } else {
685 return false;
686 }
687};
688pp$9.isContextual = function(name) {
689 return this.type === types$1.name && this.value === name && !this.containsEsc;
690};
691pp$9.eatContextual = function(name) {
692 if (!this.isContextual(name)) {
693 return false;
694 }
695 this.next();
696 return true;
697};
698pp$9.expectContextual = function(name) {
699 if (!this.eatContextual(name)) {
700 this.unexpected();
701 }
702};
703pp$9.canInsertSemicolon = function() {
704 return this.type === types$1.eof || this.type === types$1.braceR || lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
705};
706pp$9.insertSemicolon = function() {
707 if (this.canInsertSemicolon()) {
708 if (this.options.onInsertedSemicolon) {
709 this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc);
710 }
711 return true;
712 }
713};
714pp$9.semicolon = function() {
715 if (!this.eat(types$1.semi) && !this.insertSemicolon()) {
716 this.unexpected();
717 }
718};
719pp$9.afterTrailingComma = function(tokType, notNext) {
720 if (this.type === tokType) {
721 if (this.options.onTrailingComma) {
722 this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc);
723 }
724 if (!notNext) {
725 this.next();
726 }
727 return true;
728 }
729};
730pp$9.expect = function(type) {
731 this.eat(type) || this.unexpected();
732};
733pp$9.unexpected = function(pos) {
734 this.raise(pos != null ? pos : this.start, "Unexpected token");
735};
736var DestructuringErrors = function DestructuringErrors2() {
737 this.shorthandAssign = this.trailingComma = this.parenthesizedAssign = this.parenthesizedBind = this.doubleProto = -1;
738};
739pp$9.checkPatternErrors = function(refDestructuringErrors, isAssign) {
740 if (!refDestructuringErrors) {
741 return;
742 }
743 if (refDestructuringErrors.trailingComma > -1) {
744 this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element");
745 }
746 var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind;
747 if (parens > -1) {
748 this.raiseRecoverable(parens, isAssign ? "Assigning to rvalue" : "Parenthesized pattern");
749 }
750};
751pp$9.checkExpressionErrors = function(refDestructuringErrors, andThrow) {
752 if (!refDestructuringErrors) {
753 return false;
754 }
755 var shorthandAssign = refDestructuringErrors.shorthandAssign;
756 var doubleProto = refDestructuringErrors.doubleProto;
757 if (!andThrow) {
758 return shorthandAssign >= 0 || doubleProto >= 0;
759 }
760 if (shorthandAssign >= 0) {
761 this.raise(shorthandAssign, "Shorthand property assignments are valid only in destructuring patterns");
762 }
763 if (doubleProto >= 0) {
764 this.raiseRecoverable(doubleProto, "Redefinition of __proto__ property");
765 }
766};
767pp$9.checkYieldAwaitInDefaultParams = function() {
768 if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos)) {
769 this.raise(this.yieldPos, "Yield expression cannot be a default value");
770 }
771 if (this.awaitPos) {
772 this.raise(this.awaitPos, "Await expression cannot be a default value");
773 }
774};
775pp$9.isSimpleAssignTarget = function(expr) {
776 if (expr.type === "ParenthesizedExpression") {
777 return this.isSimpleAssignTarget(expr.expression);
778 }
779 return expr.type === "Identifier" || expr.type === "MemberExpression";
780};
781var pp$8 = Parser.prototype;
782pp$8.parseTopLevel = function(node) {
783 var exports = /* @__PURE__ */ Object.create(null);
784 if (!node.body) {
785 node.body = [];
786 }
787 while (this.type !== types$1.eof) {
788 var stmt = this.parseStatement(null, true, exports);
789 node.body.push(stmt);
790 }
791 if (this.inModule) {
792 for (var i = 0, list = Object.keys(this.undefinedExports); i < list.length; i += 1) {
793 var name = list[i];
794 this.raiseRecoverable(this.undefinedExports[name].start, "Export '" + name + "' is not defined");
795 }
796 }
797 this.adaptDirectivePrologue(node.body);
798 this.next();
799 node.sourceType = this.options.sourceType;
800 return this.finishNode(node, "Program");
801};
802var loopLabel = { kind: "loop" }, switchLabel = { kind: "switch" };
803pp$8.isLet = function(context) {
804 if (this.options.ecmaVersion < 6 || !this.isContextual("let")) {
805 return false;
806 }
807 skipWhiteSpace.lastIndex = this.pos;
808 var skip = skipWhiteSpace.exec(this.input);
809 var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);
810 if (nextCh === 91 || nextCh === 92 || nextCh > 55295 && nextCh < 56320) {
811 return true;
812 }
813 if (context) {
814 return false;
815 }
816 if (nextCh === 123) {
817 return true;
818 }
819 if (isIdentifierStart(nextCh, true)) {
820 var pos = next + 1;
821 while (isIdentifierChar(nextCh = this.input.charCodeAt(pos), true)) {
822 ++pos;
823 }
824 if (nextCh === 92 || nextCh > 55295 && nextCh < 56320) {
825 return true;
826 }
827 var ident = this.input.slice(next, pos);
828 if (!keywordRelationalOperator.test(ident)) {
829 return true;
830 }
831 }
832 return false;
833};
834pp$8.isAsyncFunction = function() {
835 if (this.options.ecmaVersion < 8 || !this.isContextual("async")) {
836 return false;
837 }
838 skipWhiteSpace.lastIndex = this.pos;
839 var skip = skipWhiteSpace.exec(this.input);
840 var next = this.pos + skip[0].length, after;
841 return !lineBreak.test(this.input.slice(this.pos, next)) && this.input.slice(next, next + 8) === "function" && (next + 8 === this.input.length || !(isIdentifierChar(after = this.input.charCodeAt(next + 8)) || after > 55295 && after < 56320));
842};
843pp$8.parseStatement = function(context, topLevel, exports) {
844 var starttype = this.type, node = this.startNode(), kind;
845 if (this.isLet(context)) {
846 starttype = types$1._var;
847 kind = "let";
848 }
849 switch (starttype) {
850 case types$1._break:
851 case types$1._continue:
852 return this.parseBreakContinueStatement(node, starttype.keyword);
853 case types$1._debugger:
854 return this.parseDebuggerStatement(node);
855 case types$1._do:
856 return this.parseDoStatement(node);
857 case types$1._for:
858 return this.parseForStatement(node);
859 case types$1._function:
860 if (context && (this.strict || context !== "if" && context !== "label") && this.options.ecmaVersion >= 6) {
861 this.unexpected();
862 }
863 return this.parseFunctionStatement(node, false, !context);
864 case types$1._class:
865 if (context) {
866 this.unexpected();
867 }
868 return this.parseClass(node, true);
869 case types$1._if:
870 return this.parseIfStatement(node);
871 case types$1._return:
872 return this.parseReturnStatement(node);
873 case types$1._switch:
874 return this.parseSwitchStatement(node);
875 case types$1._throw:
876 return this.parseThrowStatement(node);
877 case types$1._try:
878 return this.parseTryStatement(node);
879 case types$1._const:
880 case types$1._var:
881 kind = kind || this.value;
882 if (context && kind !== "var") {
883 this.unexpected();
884 }
885 return this.parseVarStatement(node, kind);
886 case types$1._while:
887 return this.parseWhileStatement(node);
888 case types$1._with:
889 return this.parseWithStatement(node);
890 case types$1.braceL:
891 return this.parseBlock(true, node);
892 case types$1.semi:
893 return this.parseEmptyStatement(node);
894 case types$1._export:
895 case types$1._import:
896 if (this.options.ecmaVersion > 10 && starttype === types$1._import) {
897 skipWhiteSpace.lastIndex = this.pos;
898 var skip = skipWhiteSpace.exec(this.input);
899 var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);
900 if (nextCh === 40 || nextCh === 46) {
901 return this.parseExpressionStatement(node, this.parseExpression());
902 }
903 }
904 if (!this.options.allowImportExportEverywhere) {
905 if (!topLevel) {
906 this.raise(this.start, "'import' and 'export' may only appear at the top level");
907 }
908 if (!this.inModule) {
909 this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'");
910 }
911 }
912 return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports);
913 default:
914 if (this.isAsyncFunction()) {
915 if (context) {
916 this.unexpected();
917 }
918 this.next();
919 return this.parseFunctionStatement(node, true, !context);
920 }
921 var maybeName = this.value, expr = this.parseExpression();
922 if (starttype === types$1.name && expr.type === "Identifier" && this.eat(types$1.colon)) {
923 return this.parseLabeledStatement(node, maybeName, expr, context);
924 } else {
925 return this.parseExpressionStatement(node, expr);
926 }
927 }
928};
929pp$8.parseBreakContinueStatement = function(node, keyword) {
930 var isBreak = keyword === "break";
931 this.next();
932 if (this.eat(types$1.semi) || this.insertSemicolon()) {
933 node.label = null;
934 } else if (this.type !== types$1.name) {
935 this.unexpected();
936 } else {
937 node.label = this.parseIdent();
938 this.semicolon();
939 }
940 var i = 0;
941 for (; i < this.labels.length; ++i) {
942 var lab = this.labels[i];
943 if (node.label == null || lab.name === node.label.name) {
944 if (lab.kind != null && (isBreak || lab.kind === "loop")) {
945 break;
946 }
947 if (node.label && isBreak) {
948 break;
949 }
950 }
951 }
952 if (i === this.labels.length) {
953 this.raise(node.start, "Unsyntactic " + keyword);
954 }
955 return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
956};
957pp$8.parseDebuggerStatement = function(node) {
958 this.next();
959 this.semicolon();
960 return this.finishNode(node, "DebuggerStatement");
961};
962pp$8.parseDoStatement = function(node) {
963 this.next();
964 this.labels.push(loopLabel);
965 node.body = this.parseStatement("do");
966 this.labels.pop();
967 this.expect(types$1._while);
968 node.test = this.parseParenExpression();
969 if (this.options.ecmaVersion >= 6) {
970 this.eat(types$1.semi);
971 } else {
972 this.semicolon();
973 }
974 return this.finishNode(node, "DoWhileStatement");
975};
976pp$8.parseForStatement = function(node) {
977 this.next();
978 var awaitAt = this.options.ecmaVersion >= 9 && this.canAwait && this.eatContextual("await") ? this.lastTokStart : -1;
979 this.labels.push(loopLabel);
980 this.enterScope(0);
981 this.expect(types$1.parenL);
982 if (this.type === types$1.semi) {
983 if (awaitAt > -1) {
984 this.unexpected(awaitAt);
985 }
986 return this.parseFor(node, null);
987 }
988 var isLet = this.isLet();
989 if (this.type === types$1._var || this.type === types$1._const || isLet) {
990 var init$1 = this.startNode(), kind = isLet ? "let" : this.value;
991 this.next();
992 this.parseVar(init$1, true, kind);
993 this.finishNode(init$1, "VariableDeclaration");
994 if ((this.type === types$1._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) && init$1.declarations.length === 1) {
995 if (this.options.ecmaVersion >= 9) {
996 if (this.type === types$1._in) {
997 if (awaitAt > -1) {
998 this.unexpected(awaitAt);
999 }
1000 } else {
1001 node.await = awaitAt > -1;
1002 }
1003 }
1004 return this.parseForIn(node, init$1);
1005 }
1006 if (awaitAt > -1) {
1007 this.unexpected(awaitAt);
1008 }
1009 return this.parseFor(node, init$1);
1010 }
1011 var startsWithLet = this.isContextual("let"), isForOf = false;
1012 var refDestructuringErrors = new DestructuringErrors();
1013 var init = this.parseExpression(awaitAt > -1 ? "await" : true, refDestructuringErrors);
1014 if (this.type === types$1._in || (isForOf = this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
1015 if (this.options.ecmaVersion >= 9) {
1016 if (this.type === types$1._in) {
1017 if (awaitAt > -1) {
1018 this.unexpected(awaitAt);
1019 }
1020 } else {
1021 node.await = awaitAt > -1;
1022 }
1023 }
1024 if (startsWithLet && isForOf) {
1025 this.raise(init.start, "The left-hand side of a for-of loop may not start with 'let'.");
1026 }
1027 this.toAssignable(init, false, refDestructuringErrors);
1028 this.checkLValPattern(init);
1029 return this.parseForIn(node, init);
1030 } else {
1031 this.checkExpressionErrors(refDestructuringErrors, true);
1032 }
1033 if (awaitAt > -1) {
1034 this.unexpected(awaitAt);
1035 }
1036 return this.parseFor(node, init);
1037};
1038pp$8.parseFunctionStatement = function(node, isAsync, declarationPosition) {
1039 this.next();
1040 return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync);
1041};
1042pp$8.parseIfStatement = function(node) {
1043 this.next();
1044 node.test = this.parseParenExpression();
1045 node.consequent = this.parseStatement("if");
1046 node.alternate = this.eat(types$1._else) ? this.parseStatement("if") : null;
1047 return this.finishNode(node, "IfStatement");
1048};
1049pp$8.parseReturnStatement = function(node) {
1050 if (!this.inFunction && !this.options.allowReturnOutsideFunction) {
1051 this.raise(this.start, "'return' outside of function");
1052 }
1053 this.next();
1054 if (this.eat(types$1.semi) || this.insertSemicolon()) {
1055 node.argument = null;
1056 } else {
1057 node.argument = this.parseExpression();
1058 this.semicolon();
1059 }
1060 return this.finishNode(node, "ReturnStatement");
1061};
1062pp$8.parseSwitchStatement = function(node) {
1063 this.next();
1064 node.discriminant = this.parseParenExpression();
1065 node.cases = [];
1066 this.expect(types$1.braceL);
1067 this.labels.push(switchLabel);
1068 this.enterScope(0);
1069 var cur;
1070 for (var sawDefault = false; this.type !== types$1.braceR; ) {
1071 if (this.type === types$1._case || this.type === types$1._default) {
1072 var isCase = this.type === types$1._case;
1073 if (cur) {
1074 this.finishNode(cur, "SwitchCase");
1075 }
1076 node.cases.push(cur = this.startNode());
1077 cur.consequent = [];
1078 this.next();
1079 if (isCase) {
1080 cur.test = this.parseExpression();
1081 } else {
1082 if (sawDefault) {
1083 this.raiseRecoverable(this.lastTokStart, "Multiple default clauses");
1084 }
1085 sawDefault = true;
1086 cur.test = null;
1087 }
1088 this.expect(types$1.colon);
1089 } else {
1090 if (!cur) {
1091 this.unexpected();
1092 }
1093 cur.consequent.push(this.parseStatement(null));
1094 }
1095 }
1096 this.exitScope();
1097 if (cur) {
1098 this.finishNode(cur, "SwitchCase");
1099 }
1100 this.next();
1101 this.labels.pop();
1102 return this.finishNode(node, "SwitchStatement");
1103};
1104pp$8.parseThrowStatement = function(node) {
1105 this.next();
1106 if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) {
1107 this.raise(this.lastTokEnd, "Illegal newline after throw");
1108 }
1109 node.argument = this.parseExpression();
1110 this.semicolon();
1111 return this.finishNode(node, "ThrowStatement");
1112};
1113var empty$1 = [];
1114pp$8.parseTryStatement = function(node) {
1115 this.next();
1116 node.block = this.parseBlock();
1117 node.handler = null;
1118 if (this.type === types$1._catch) {
1119 var clause = this.startNode();
1120 this.next();
1121 if (this.eat(types$1.parenL)) {
1122 clause.param = this.parseBindingAtom();
1123 var simple = clause.param.type === "Identifier";
1124 this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0);
1125 this.checkLValPattern(clause.param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL);
1126 this.expect(types$1.parenR);
1127 } else {
1128 if (this.options.ecmaVersion < 10) {
1129 this.unexpected();
1130 }
1131 clause.param = null;
1132 this.enterScope(0);
1133 }
1134 clause.body = this.parseBlock(false);
1135 this.exitScope();
1136 node.handler = this.finishNode(clause, "CatchClause");
1137 }
1138 node.finalizer = this.eat(types$1._finally) ? this.parseBlock() : null;
1139 if (!node.handler && !node.finalizer) {
1140 this.raise(node.start, "Missing catch or finally clause");
1141 }
1142 return this.finishNode(node, "TryStatement");
1143};
1144pp$8.parseVarStatement = function(node, kind) {
1145 this.next();
1146 this.parseVar(node, false, kind);
1147 this.semicolon();
1148 return this.finishNode(node, "VariableDeclaration");
1149};
1150pp$8.parseWhileStatement = function(node) {
1151 this.next();
1152 node.test = this.parseParenExpression();
1153 this.labels.push(loopLabel);
1154 node.body = this.parseStatement("while");
1155 this.labels.pop();
1156 return this.finishNode(node, "WhileStatement");
1157};
1158pp$8.parseWithStatement = function(node) {
1159 if (this.strict) {
1160 this.raise(this.start, "'with' in strict mode");
1161 }
1162 this.next();
1163 node.object = this.parseParenExpression();
1164 node.body = this.parseStatement("with");
1165 return this.finishNode(node, "WithStatement");
1166};
1167pp$8.parseEmptyStatement = function(node) {
1168 this.next();
1169 return this.finishNode(node, "EmptyStatement");
1170};
1171pp$8.parseLabeledStatement = function(node, maybeName, expr, context) {
1172 for (var i$1 = 0, list = this.labels; i$1 < list.length; i$1 += 1) {
1173 var label = list[i$1];
1174 if (label.name === maybeName) {
1175 this.raise(expr.start, "Label '" + maybeName + "' is already declared");
1176 }
1177 }
1178 var kind = this.type.isLoop ? "loop" : this.type === types$1._switch ? "switch" : null;
1179 for (var i = this.labels.length - 1; i >= 0; i--) {
1180 var label$1 = this.labels[i];
1181 if (label$1.statementStart === node.start) {
1182 label$1.statementStart = this.start;
1183 label$1.kind = kind;
1184 } else {
1185 break;
1186 }
1187 }
1188 this.labels.push({ name: maybeName, kind, statementStart: this.start });
1189 node.body = this.parseStatement(context ? context.indexOf("label") === -1 ? context + "label" : context : "label");
1190 this.labels.pop();
1191 node.label = expr;
1192 return this.finishNode(node, "LabeledStatement");
1193};
1194pp$8.parseExpressionStatement = function(node, expr) {
1195 node.expression = expr;
1196 this.semicolon();
1197 return this.finishNode(node, "ExpressionStatement");
1198};
1199pp$8.parseBlock = function(createNewLexicalScope, node, exitStrict) {
1200 if (createNewLexicalScope === void 0)
1201 createNewLexicalScope = true;
1202 if (node === void 0)
1203 node = this.startNode();
1204 node.body = [];
1205 this.expect(types$1.braceL);
1206 if (createNewLexicalScope) {
1207 this.enterScope(0);
1208 }
1209 while (this.type !== types$1.braceR) {
1210 var stmt = this.parseStatement(null);
1211 node.body.push(stmt);
1212 }
1213 if (exitStrict) {
1214 this.strict = false;
1215 }
1216 this.next();
1217 if (createNewLexicalScope) {
1218 this.exitScope();
1219 }
1220 return this.finishNode(node, "BlockStatement");
1221};
1222pp$8.parseFor = function(node, init) {
1223 node.init = init;
1224 this.expect(types$1.semi);
1225 node.test = this.type === types$1.semi ? null : this.parseExpression();
1226 this.expect(types$1.semi);
1227 node.update = this.type === types$1.parenR ? null : this.parseExpression();
1228 this.expect(types$1.parenR);
1229 node.body = this.parseStatement("for");
1230 this.exitScope();
1231 this.labels.pop();
1232 return this.finishNode(node, "ForStatement");
1233};
1234pp$8.parseForIn = function(node, init) {
1235 var isForIn = this.type === types$1._in;
1236 this.next();
1237 if (init.type === "VariableDeclaration" && init.declarations[0].init != null && (!isForIn || this.options.ecmaVersion < 8 || this.strict || init.kind !== "var" || init.declarations[0].id.type !== "Identifier")) {
1238 this.raise(
1239 init.start,
1240 (isForIn ? "for-in" : "for-of") + " loop variable declaration may not have an initializer"
1241 );
1242 }
1243 node.left = init;
1244 node.right = isForIn ? this.parseExpression() : this.parseMaybeAssign();
1245 this.expect(types$1.parenR);
1246 node.body = this.parseStatement("for");
1247 this.exitScope();
1248 this.labels.pop();
1249 return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement");
1250};
1251pp$8.parseVar = function(node, isFor, kind) {
1252 node.declarations = [];
1253 node.kind = kind;
1254 for (; ; ) {
1255 var decl = this.startNode();
1256 this.parseVarId(decl, kind);
1257 if (this.eat(types$1.eq)) {
1258 decl.init = this.parseMaybeAssign(isFor);
1259 } else if (kind === "const" && !(this.type === types$1._in || this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
1260 this.unexpected();
1261 } else if (decl.id.type !== "Identifier" && !(isFor && (this.type === types$1._in || this.isContextual("of")))) {
1262 this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value");
1263 } else {
1264 decl.init = null;
1265 }
1266 node.declarations.push(this.finishNode(decl, "VariableDeclarator"));
1267 if (!this.eat(types$1.comma)) {
1268 break;
1269 }
1270 }
1271 return node;
1272};
1273pp$8.parseVarId = function(decl, kind) {
1274 decl.id = this.parseBindingAtom();
1275 this.checkLValPattern(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false);
1276};
1277var FUNC_STATEMENT = 1, FUNC_HANGING_STATEMENT = 2, FUNC_NULLABLE_ID = 4;
1278pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, forInit) {
1279 this.initFunction(node);
1280 if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync) {
1281 if (this.type === types$1.star && statement & FUNC_HANGING_STATEMENT) {
1282 this.unexpected();
1283 }
1284 node.generator = this.eat(types$1.star);
1285 }
1286 if (this.options.ecmaVersion >= 8) {
1287 node.async = !!isAsync;
1288 }
1289 if (statement & FUNC_STATEMENT) {
1290 node.id = statement & FUNC_NULLABLE_ID && this.type !== types$1.name ? null : this.parseIdent();
1291 if (node.id && !(statement & FUNC_HANGING_STATEMENT)) {
1292 this.checkLValSimple(node.id, this.strict || node.generator || node.async ? this.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION);
1293 }
1294 }
1295 var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
1296 this.yieldPos = 0;
1297 this.awaitPos = 0;
1298 this.awaitIdentPos = 0;
1299 this.enterScope(functionFlags(node.async, node.generator));
1300 if (!(statement & FUNC_STATEMENT)) {
1301 node.id = this.type === types$1.name ? this.parseIdent() : null;
1302 }
1303 this.parseFunctionParams(node);
1304 this.parseFunctionBody(node, allowExpressionBody, false, forInit);
1305 this.yieldPos = oldYieldPos;
1306 this.awaitPos = oldAwaitPos;
1307 this.awaitIdentPos = oldAwaitIdentPos;
1308 return this.finishNode(node, statement & FUNC_STATEMENT ? "FunctionDeclaration" : "FunctionExpression");
1309};
1310pp$8.parseFunctionParams = function(node) {
1311 this.expect(types$1.parenL);
1312 node.params = this.parseBindingList(types$1.parenR, false, this.options.ecmaVersion >= 8);
1313 this.checkYieldAwaitInDefaultParams();
1314};
1315pp$8.parseClass = function(node, isStatement) {
1316 this.next();
1317 var oldStrict = this.strict;
1318 this.strict = true;
1319 this.parseClassId(node, isStatement);
1320 this.parseClassSuper(node);
1321 var privateNameMap = this.enterClassBody();
1322 var classBody = this.startNode();
1323 var hadConstructor = false;
1324 classBody.body = [];
1325 this.expect(types$1.braceL);
1326 while (this.type !== types$1.braceR) {
1327 var element = this.parseClassElement(node.superClass !== null);
1328 if (element) {
1329 classBody.body.push(element);
1330 if (element.type === "MethodDefinition" && element.kind === "constructor") {
1331 if (hadConstructor) {
1332 this.raise(element.start, "Duplicate constructor in the same class");
1333 }
1334 hadConstructor = true;
1335 } else if (element.key && element.key.type === "PrivateIdentifier" && isPrivateNameConflicted(privateNameMap, element)) {
1336 this.raiseRecoverable(element.key.start, "Identifier '#" + element.key.name + "' has already been declared");
1337 }
1338 }
1339 }
1340 this.strict = oldStrict;
1341 this.next();
1342 node.body = this.finishNode(classBody, "ClassBody");
1343 this.exitClassBody();
1344 return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
1345};
1346pp$8.parseClassElement = function(constructorAllowsSuper) {
1347 if (this.eat(types$1.semi)) {
1348 return null;
1349 }
1350 var ecmaVersion = this.options.ecmaVersion;
1351 var node = this.startNode();
1352 var keyName = "";
1353 var isGenerator = false;
1354 var isAsync = false;
1355 var kind = "method";
1356 var isStatic = false;
1357 if (this.eatContextual("static")) {
1358 if (ecmaVersion >= 13 && this.eat(types$1.braceL)) {
1359 this.parseClassStaticBlock(node);
1360 return node;
1361 }
1362 if (this.isClassElementNameStart() || this.type === types$1.star) {
1363 isStatic = true;
1364 } else {
1365 keyName = "static";
1366 }
1367 }
1368 node.static = isStatic;
1369 if (!keyName && ecmaVersion >= 8 && this.eatContextual("async")) {
1370 if ((this.isClassElementNameStart() || this.type === types$1.star) && !this.canInsertSemicolon()) {
1371 isAsync = true;
1372 } else {
1373 keyName = "async";
1374 }
1375 }
1376 if (!keyName && (ecmaVersion >= 9 || !isAsync) && this.eat(types$1.star)) {
1377 isGenerator = true;
1378 }
1379 if (!keyName && !isAsync && !isGenerator) {
1380 var lastValue = this.value;
1381 if (this.eatContextual("get") || this.eatContextual("set")) {
1382 if (this.isClassElementNameStart()) {
1383 kind = lastValue;
1384 } else {
1385 keyName = lastValue;
1386 }
1387 }
1388 }
1389 if (keyName) {
1390 node.computed = false;
1391 node.key = this.startNodeAt(this.lastTokStart, this.lastTokStartLoc);
1392 node.key.name = keyName;
1393 this.finishNode(node.key, "Identifier");
1394 } else {
1395 this.parseClassElementName(node);
1396 }
1397 if (ecmaVersion < 13 || this.type === types$1.parenL || kind !== "method" || isGenerator || isAsync) {
1398 var isConstructor = !node.static && checkKeyName(node, "constructor");
1399 var allowsDirectSuper = isConstructor && constructorAllowsSuper;
1400 if (isConstructor && kind !== "method") {
1401 this.raise(node.key.start, "Constructor can't have get/set modifier");
1402 }
1403 node.kind = isConstructor ? "constructor" : kind;
1404 this.parseClassMethod(node, isGenerator, isAsync, allowsDirectSuper);
1405 } else {
1406 this.parseClassField(node);
1407 }
1408 return node;
1409};
1410pp$8.isClassElementNameStart = function() {
1411 return this.type === types$1.name || this.type === types$1.privateId || this.type === types$1.num || this.type === types$1.string || this.type === types$1.bracketL || this.type.keyword;
1412};
1413pp$8.parseClassElementName = function(element) {
1414 if (this.type === types$1.privateId) {
1415 if (this.value === "constructor") {
1416 this.raise(this.start, "Classes can't have an element named '#constructor'");
1417 }
1418 element.computed = false;
1419 element.key = this.parsePrivateIdent();
1420 } else {
1421 this.parsePropertyName(element);
1422 }
1423};
1424pp$8.parseClassMethod = function(method, isGenerator, isAsync, allowsDirectSuper) {
1425 var key = method.key;
1426 if (method.kind === "constructor") {
1427 if (isGenerator) {
1428 this.raise(key.start, "Constructor can't be a generator");
1429 }
1430 if (isAsync) {
1431 this.raise(key.start, "Constructor can't be an async method");
1432 }
1433 } else if (method.static && checkKeyName(method, "prototype")) {
1434 this.raise(key.start, "Classes may not have a static property named prototype");
1435 }
1436 var value = method.value = this.parseMethod(isGenerator, isAsync, allowsDirectSuper);
1437 if (method.kind === "get" && value.params.length !== 0) {
1438 this.raiseRecoverable(value.start, "getter should have no params");
1439 }
1440 if (method.kind === "set" && value.params.length !== 1) {
1441 this.raiseRecoverable(value.start, "setter should have exactly one param");
1442 }
1443 if (method.kind === "set" && value.params[0].type === "RestElement") {
1444 this.raiseRecoverable(value.params[0].start, "Setter cannot use rest params");
1445 }
1446 return this.finishNode(method, "MethodDefinition");
1447};
1448pp$8.parseClassField = function(field) {
1449 if (checkKeyName(field, "constructor")) {
1450 this.raise(field.key.start, "Classes can't have a field named 'constructor'");
1451 } else if (field.static && checkKeyName(field, "prototype")) {
1452 this.raise(field.key.start, "Classes can't have a static field named 'prototype'");
1453 }
1454 if (this.eat(types$1.eq)) {
1455 var scope = this.currentThisScope();
1456 var inClassFieldInit = scope.inClassFieldInit;
1457 scope.inClassFieldInit = true;
1458 field.value = this.parseMaybeAssign();
1459 scope.inClassFieldInit = inClassFieldInit;
1460 } else {
1461 field.value = null;
1462 }
1463 this.semicolon();
1464 return this.finishNode(field, "PropertyDefinition");
1465};
1466pp$8.parseClassStaticBlock = function(node) {
1467 node.body = [];
1468 var oldLabels = this.labels;
1469 this.labels = [];
1470 this.enterScope(SCOPE_CLASS_STATIC_BLOCK | SCOPE_SUPER);
1471 while (this.type !== types$1.braceR) {
1472 var stmt = this.parseStatement(null);
1473 node.body.push(stmt);
1474 }
1475 this.next();
1476 this.exitScope();
1477 this.labels = oldLabels;
1478 return this.finishNode(node, "StaticBlock");
1479};
1480pp$8.parseClassId = function(node, isStatement) {
1481 if (this.type === types$1.name) {
1482 node.id = this.parseIdent();
1483 if (isStatement) {
1484 this.checkLValSimple(node.id, BIND_LEXICAL, false);
1485 }
1486 } else {
1487 if (isStatement === true) {
1488 this.unexpected();
1489 }
1490 node.id = null;
1491 }
1492};
1493pp$8.parseClassSuper = function(node) {
1494 node.superClass = this.eat(types$1._extends) ? this.parseExprSubscripts(false) : null;
1495};
1496pp$8.enterClassBody = function() {
1497 var element = { declared: /* @__PURE__ */ Object.create(null), used: [] };
1498 this.privateNameStack.push(element);
1499 return element.declared;
1500};
1501pp$8.exitClassBody = function() {
1502 var ref2 = this.privateNameStack.pop();
1503 var declared = ref2.declared;
1504 var used = ref2.used;
1505 var len = this.privateNameStack.length;
1506 var parent = len === 0 ? null : this.privateNameStack[len - 1];
1507 for (var i = 0; i < used.length; ++i) {
1508 var id = used[i];
1509 if (!hasOwn(declared, id.name)) {
1510 if (parent) {
1511 parent.used.push(id);
1512 } else {
1513 this.raiseRecoverable(id.start, "Private field '#" + id.name + "' must be declared in an enclosing class");
1514 }
1515 }
1516 }
1517};
1518function isPrivateNameConflicted(privateNameMap, element) {
1519 var name = element.key.name;
1520 var curr = privateNameMap[name];
1521 var next = "true";
1522 if (element.type === "MethodDefinition" && (element.kind === "get" || element.kind === "set")) {
1523 next = (element.static ? "s" : "i") + element.kind;
1524 }
1525 if (curr === "iget" && next === "iset" || curr === "iset" && next === "iget" || curr === "sget" && next === "sset" || curr === "sset" && next === "sget") {
1526 privateNameMap[name] = "true";
1527 return false;
1528 } else if (!curr) {
1529 privateNameMap[name] = next;
1530 return false;
1531 } else {
1532 return true;
1533 }
1534}
1535function checkKeyName(node, name) {
1536 var computed = node.computed;
1537 var key = node.key;
1538 return !computed && (key.type === "Identifier" && key.name === name || key.type === "Literal" && key.value === name);
1539}
1540pp$8.parseExport = function(node, exports) {
1541 this.next();
1542 if (this.eat(types$1.star)) {
1543 if (this.options.ecmaVersion >= 11) {
1544 if (this.eatContextual("as")) {
1545 node.exported = this.parseModuleExportName();
1546 this.checkExport(exports, node.exported, this.lastTokStart);
1547 } else {
1548 node.exported = null;
1549 }
1550 }
1551 this.expectContextual("from");
1552 if (this.type !== types$1.string) {
1553 this.unexpected();
1554 }
1555 node.source = this.parseExprAtom();
1556 this.semicolon();
1557 return this.finishNode(node, "ExportAllDeclaration");
1558 }
1559 if (this.eat(types$1._default)) {
1560 this.checkExport(exports, "default", this.lastTokStart);
1561 var isAsync;
1562 if (this.type === types$1._function || (isAsync = this.isAsyncFunction())) {
1563 var fNode = this.startNode();
1564 this.next();
1565 if (isAsync) {
1566 this.next();
1567 }
1568 node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync);
1569 } else if (this.type === types$1._class) {
1570 var cNode = this.startNode();
1571 node.declaration = this.parseClass(cNode, "nullableID");
1572 } else {
1573 node.declaration = this.parseMaybeAssign();
1574 this.semicolon();
1575 }
1576 return this.finishNode(node, "ExportDefaultDeclaration");
1577 }
1578 if (this.shouldParseExportStatement()) {
1579 node.declaration = this.parseStatement(null);
1580 if (node.declaration.type === "VariableDeclaration") {
1581 this.checkVariableExport(exports, node.declaration.declarations);
1582 } else {
1583 this.checkExport(exports, node.declaration.id, node.declaration.id.start);
1584 }
1585 node.specifiers = [];
1586 node.source = null;
1587 } else {
1588 node.declaration = null;
1589 node.specifiers = this.parseExportSpecifiers(exports);
1590 if (this.eatContextual("from")) {
1591 if (this.type !== types$1.string) {
1592 this.unexpected();
1593 }
1594 node.source = this.parseExprAtom();
1595 } else {
1596 for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
1597 var spec = list[i];
1598 this.checkUnreserved(spec.local);
1599 this.checkLocalExport(spec.local);
1600 if (spec.local.type === "Literal") {
1601 this.raise(spec.local.start, "A string literal cannot be used as an exported binding without `from`.");
1602 }
1603 }
1604 node.source = null;
1605 }
1606 this.semicolon();
1607 }
1608 return this.finishNode(node, "ExportNamedDeclaration");
1609};
1610pp$8.checkExport = function(exports, name, pos) {
1611 if (!exports) {
1612 return;
1613 }
1614 if (typeof name !== "string") {
1615 name = name.type === "Identifier" ? name.name : name.value;
1616 }
1617 if (hasOwn(exports, name)) {
1618 this.raiseRecoverable(pos, "Duplicate export '" + name + "'");
1619 }
1620 exports[name] = true;
1621};
1622pp$8.checkPatternExport = function(exports, pat) {
1623 var type = pat.type;
1624 if (type === "Identifier") {
1625 this.checkExport(exports, pat, pat.start);
1626 } else if (type === "ObjectPattern") {
1627 for (var i = 0, list = pat.properties; i < list.length; i += 1) {
1628 var prop = list[i];
1629 this.checkPatternExport(exports, prop);
1630 }
1631 } else if (type === "ArrayPattern") {
1632 for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {
1633 var elt = list$1[i$1];
1634 if (elt) {
1635 this.checkPatternExport(exports, elt);
1636 }
1637 }
1638 } else if (type === "Property") {
1639 this.checkPatternExport(exports, pat.value);
1640 } else if (type === "AssignmentPattern") {
1641 this.checkPatternExport(exports, pat.left);
1642 } else if (type === "RestElement") {
1643 this.checkPatternExport(exports, pat.argument);
1644 } else if (type === "ParenthesizedExpression") {
1645 this.checkPatternExport(exports, pat.expression);
1646 }
1647};
1648pp$8.checkVariableExport = function(exports, decls) {
1649 if (!exports) {
1650 return;
1651 }
1652 for (var i = 0, list = decls; i < list.length; i += 1) {
1653 var decl = list[i];
1654 this.checkPatternExport(exports, decl.id);
1655 }
1656};
1657pp$8.shouldParseExportStatement = function() {
1658 return this.type.keyword === "var" || this.type.keyword === "const" || this.type.keyword === "class" || this.type.keyword === "function" || this.isLet() || this.isAsyncFunction();
1659};
1660pp$8.parseExportSpecifiers = function(exports) {
1661 var nodes = [], first = true;
1662 this.expect(types$1.braceL);
1663 while (!this.eat(types$1.braceR)) {
1664 if (!first) {
1665 this.expect(types$1.comma);
1666 if (this.afterTrailingComma(types$1.braceR)) {
1667 break;
1668 }
1669 } else {
1670 first = false;
1671 }
1672 var node = this.startNode();
1673 node.local = this.parseModuleExportName();
1674 node.exported = this.eatContextual("as") ? this.parseModuleExportName() : node.local;
1675 this.checkExport(
1676 exports,
1677 node.exported,
1678 node.exported.start
1679 );
1680 nodes.push(this.finishNode(node, "ExportSpecifier"));
1681 }
1682 return nodes;
1683};
1684pp$8.parseImport = function(node) {
1685 this.next();
1686 if (this.type === types$1.string) {
1687 node.specifiers = empty$1;
1688 node.source = this.parseExprAtom();
1689 } else {
1690 node.specifiers = this.parseImportSpecifiers();
1691 this.expectContextual("from");
1692 node.source = this.type === types$1.string ? this.parseExprAtom() : this.unexpected();
1693 }
1694 this.semicolon();
1695 return this.finishNode(node, "ImportDeclaration");
1696};
1697pp$8.parseImportSpecifiers = function() {
1698 var nodes = [], first = true;
1699 if (this.type === types$1.name) {
1700 var node = this.startNode();
1701 node.local = this.parseIdent();
1702 this.checkLValSimple(node.local, BIND_LEXICAL);
1703 nodes.push(this.finishNode(node, "ImportDefaultSpecifier"));
1704 if (!this.eat(types$1.comma)) {
1705 return nodes;
1706 }
1707 }
1708 if (this.type === types$1.star) {
1709 var node$1 = this.startNode();
1710 this.next();
1711 this.expectContextual("as");
1712 node$1.local = this.parseIdent();
1713 this.checkLValSimple(node$1.local, BIND_LEXICAL);
1714 nodes.push(this.finishNode(node$1, "ImportNamespaceSpecifier"));
1715 return nodes;
1716 }
1717 this.expect(types$1.braceL);
1718 while (!this.eat(types$1.braceR)) {
1719 if (!first) {
1720 this.expect(types$1.comma);
1721 if (this.afterTrailingComma(types$1.braceR)) {
1722 break;
1723 }
1724 } else {
1725 first = false;
1726 }
1727 var node$2 = this.startNode();
1728 node$2.imported = this.parseModuleExportName();
1729 if (this.eatContextual("as")) {
1730 node$2.local = this.parseIdent();
1731 } else {
1732 this.checkUnreserved(node$2.imported);
1733 node$2.local = node$2.imported;
1734 }
1735 this.checkLValSimple(node$2.local, BIND_LEXICAL);
1736 nodes.push(this.finishNode(node$2, "ImportSpecifier"));
1737 }
1738 return nodes;
1739};
1740pp$8.parseModuleExportName = function() {
1741 if (this.options.ecmaVersion >= 13 && this.type === types$1.string) {
1742 var stringLiteral = this.parseLiteral(this.value);
1743 if (loneSurrogate.test(stringLiteral.value)) {
1744 this.raise(stringLiteral.start, "An export name cannot include a lone surrogate.");
1745 }
1746 return stringLiteral;
1747 }
1748 return this.parseIdent(true);
1749};
1750pp$8.adaptDirectivePrologue = function(statements) {
1751 for (var i = 0; i < statements.length && this.isDirectiveCandidate(statements[i]); ++i) {
1752 statements[i].directive = statements[i].expression.raw.slice(1, -1);
1753 }
1754};
1755pp$8.isDirectiveCandidate = function(statement) {
1756 return this.options.ecmaVersion >= 5 && statement.type === "ExpressionStatement" && statement.expression.type === "Literal" && typeof statement.expression.value === "string" && (this.input[statement.start] === '"' || this.input[statement.start] === "'");
1757};
1758var pp$7 = Parser.prototype;
1759pp$7.toAssignable = function(node, isBinding, refDestructuringErrors) {
1760 if (this.options.ecmaVersion >= 6 && node) {
1761 switch (node.type) {
1762 case "Identifier":
1763 if (this.inAsync && node.name === "await") {
1764 this.raise(node.start, "Cannot use 'await' as identifier inside an async function");
1765 }
1766 break;
1767 case "ObjectPattern":
1768 case "ArrayPattern":
1769 case "AssignmentPattern":
1770 case "RestElement":
1771 break;
1772 case "ObjectExpression":
1773 node.type = "ObjectPattern";
1774 if (refDestructuringErrors) {
1775 this.checkPatternErrors(refDestructuringErrors, true);
1776 }
1777 for (var i = 0, list = node.properties; i < list.length; i += 1) {
1778 var prop = list[i];
1779 this.toAssignable(prop, isBinding);
1780 if (prop.type === "RestElement" && (prop.argument.type === "ArrayPattern" || prop.argument.type === "ObjectPattern")) {
1781 this.raise(prop.argument.start, "Unexpected token");
1782 }
1783 }
1784 break;
1785 case "Property":
1786 if (node.kind !== "init") {
1787 this.raise(node.key.start, "Object pattern can't contain getter or setter");
1788 }
1789 this.toAssignable(node.value, isBinding);
1790 break;
1791 case "ArrayExpression":
1792 node.type = "ArrayPattern";
1793 if (refDestructuringErrors) {
1794 this.checkPatternErrors(refDestructuringErrors, true);
1795 }
1796 this.toAssignableList(node.elements, isBinding);
1797 break;
1798 case "SpreadElement":
1799 node.type = "RestElement";
1800 this.toAssignable(node.argument, isBinding);
1801 if (node.argument.type === "AssignmentPattern") {
1802 this.raise(node.argument.start, "Rest elements cannot have a default value");
1803 }
1804 break;
1805 case "AssignmentExpression":
1806 if (node.operator !== "=") {
1807 this.raise(node.left.end, "Only '=' operator can be used for specifying default value.");
1808 }
1809 node.type = "AssignmentPattern";
1810 delete node.operator;
1811 this.toAssignable(node.left, isBinding);
1812 break;
1813 case "ParenthesizedExpression":
1814 this.toAssignable(node.expression, isBinding, refDestructuringErrors);
1815 break;
1816 case "ChainExpression":
1817 this.raiseRecoverable(node.start, "Optional chaining cannot appear in left-hand side");
1818 break;
1819 case "MemberExpression":
1820 if (!isBinding) {
1821 break;
1822 }
1823 default:
1824 this.raise(node.start, "Assigning to rvalue");
1825 }
1826 } else if (refDestructuringErrors) {
1827 this.checkPatternErrors(refDestructuringErrors, true);
1828 }
1829 return node;
1830};
1831pp$7.toAssignableList = function(exprList, isBinding) {
1832 var end = exprList.length;
1833 for (var i = 0; i < end; i++) {
1834 var elt = exprList[i];
1835 if (elt) {
1836 this.toAssignable(elt, isBinding);
1837 }
1838 }
1839 if (end) {
1840 var last = exprList[end - 1];
1841 if (this.options.ecmaVersion === 6 && isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier") {
1842 this.unexpected(last.argument.start);
1843 }
1844 }
1845 return exprList;
1846};
1847pp$7.parseSpread = function(refDestructuringErrors) {
1848 var node = this.startNode();
1849 this.next();
1850 node.argument = this.parseMaybeAssign(false, refDestructuringErrors);
1851 return this.finishNode(node, "SpreadElement");
1852};
1853pp$7.parseRestBinding = function() {
1854 var node = this.startNode();
1855 this.next();
1856 if (this.options.ecmaVersion === 6 && this.type !== types$1.name) {
1857 this.unexpected();
1858 }
1859 node.argument = this.parseBindingAtom();
1860 return this.finishNode(node, "RestElement");
1861};
1862pp$7.parseBindingAtom = function() {
1863 if (this.options.ecmaVersion >= 6) {
1864 switch (this.type) {
1865 case types$1.bracketL:
1866 var node = this.startNode();
1867 this.next();
1868 node.elements = this.parseBindingList(types$1.bracketR, true, true);
1869 return this.finishNode(node, "ArrayPattern");
1870 case types$1.braceL:
1871 return this.parseObj(true);
1872 }
1873 }
1874 return this.parseIdent();
1875};
1876pp$7.parseBindingList = function(close, allowEmpty, allowTrailingComma) {
1877 var elts = [], first = true;
1878 while (!this.eat(close)) {
1879 if (first) {
1880 first = false;
1881 } else {
1882 this.expect(types$1.comma);
1883 }
1884 if (allowEmpty && this.type === types$1.comma) {
1885 elts.push(null);
1886 } else if (allowTrailingComma && this.afterTrailingComma(close)) {
1887 break;
1888 } else if (this.type === types$1.ellipsis) {
1889 var rest = this.parseRestBinding();
1890 this.parseBindingListItem(rest);
1891 elts.push(rest);
1892 if (this.type === types$1.comma) {
1893 this.raise(this.start, "Comma is not permitted after the rest element");
1894 }
1895 this.expect(close);
1896 break;
1897 } else {
1898 var elem = this.parseMaybeDefault(this.start, this.startLoc);
1899 this.parseBindingListItem(elem);
1900 elts.push(elem);
1901 }
1902 }
1903 return elts;
1904};
1905pp$7.parseBindingListItem = function(param) {
1906 return param;
1907};
1908pp$7.parseMaybeDefault = function(startPos, startLoc, left) {
1909 left = left || this.parseBindingAtom();
1910 if (this.options.ecmaVersion < 6 || !this.eat(types$1.eq)) {
1911 return left;
1912 }
1913 var node = this.startNodeAt(startPos, startLoc);
1914 node.left = left;
1915 node.right = this.parseMaybeAssign();
1916 return this.finishNode(node, "AssignmentPattern");
1917};
1918pp$7.checkLValSimple = function(expr, bindingType, checkClashes) {
1919 if (bindingType === void 0)
1920 bindingType = BIND_NONE;
1921 var isBind = bindingType !== BIND_NONE;
1922 switch (expr.type) {
1923 case "Identifier":
1924 if (this.strict && this.reservedWordsStrictBind.test(expr.name)) {
1925 this.raiseRecoverable(expr.start, (isBind ? "Binding " : "Assigning to ") + expr.name + " in strict mode");
1926 }
1927 if (isBind) {
1928 if (bindingType === BIND_LEXICAL && expr.name === "let") {
1929 this.raiseRecoverable(expr.start, "let is disallowed as a lexically bound name");
1930 }
1931 if (checkClashes) {
1932 if (hasOwn(checkClashes, expr.name)) {
1933 this.raiseRecoverable(expr.start, "Argument name clash");
1934 }
1935 checkClashes[expr.name] = true;
1936 }
1937 if (bindingType !== BIND_OUTSIDE) {
1938 this.declareName(expr.name, bindingType, expr.start);
1939 }
1940 }
1941 break;
1942 case "ChainExpression":
1943 this.raiseRecoverable(expr.start, "Optional chaining cannot appear in left-hand side");
1944 break;
1945 case "MemberExpression":
1946 if (isBind) {
1947 this.raiseRecoverable(expr.start, "Binding member expression");
1948 }
1949 break;
1950 case "ParenthesizedExpression":
1951 if (isBind) {
1952 this.raiseRecoverable(expr.start, "Binding parenthesized expression");
1953 }
1954 return this.checkLValSimple(expr.expression, bindingType, checkClashes);
1955 default:
1956 this.raise(expr.start, (isBind ? "Binding" : "Assigning to") + " rvalue");
1957 }
1958};
1959pp$7.checkLValPattern = function(expr, bindingType, checkClashes) {
1960 if (bindingType === void 0)
1961 bindingType = BIND_NONE;
1962 switch (expr.type) {
1963 case "ObjectPattern":
1964 for (var i = 0, list = expr.properties; i < list.length; i += 1) {
1965 var prop = list[i];
1966 this.checkLValInnerPattern(prop, bindingType, checkClashes);
1967 }
1968 break;
1969 case "ArrayPattern":
1970 for (var i$1 = 0, list$1 = expr.elements; i$1 < list$1.length; i$1 += 1) {
1971 var elem = list$1[i$1];
1972 if (elem) {
1973 this.checkLValInnerPattern(elem, bindingType, checkClashes);
1974 }
1975 }
1976 break;
1977 default:
1978 this.checkLValSimple(expr, bindingType, checkClashes);
1979 }
1980};
1981pp$7.checkLValInnerPattern = function(expr, bindingType, checkClashes) {
1982 if (bindingType === void 0)
1983 bindingType = BIND_NONE;
1984 switch (expr.type) {
1985 case "Property":
1986 this.checkLValInnerPattern(expr.value, bindingType, checkClashes);
1987 break;
1988 case "AssignmentPattern":
1989 this.checkLValPattern(expr.left, bindingType, checkClashes);
1990 break;
1991 case "RestElement":
1992 this.checkLValPattern(expr.argument, bindingType, checkClashes);
1993 break;
1994 default:
1995 this.checkLValPattern(expr, bindingType, checkClashes);
1996 }
1997};
1998var TokContext = function TokContext2(token, isExpr, preserveSpace, override, generator) {
1999 this.token = token;
2000 this.isExpr = !!isExpr;
2001 this.preserveSpace = !!preserveSpace;
2002 this.override = override;
2003 this.generator = !!generator;
2004};
2005var types = {
2006 b_stat: new TokContext("{", false),
2007 b_expr: new TokContext("{", true),
2008 b_tmpl: new TokContext("${", false),
2009 p_stat: new TokContext("(", false),
2010 p_expr: new TokContext("(", true),
2011 q_tmpl: new TokContext("`", true, true, function(p) {
2012 return p.tryReadTemplateToken();
2013 }),
2014 f_stat: new TokContext("function", false),
2015 f_expr: new TokContext("function", true),
2016 f_expr_gen: new TokContext("function", true, false, null, true),
2017 f_gen: new TokContext("function", false, false, null, true)
2018};
2019var pp$6 = Parser.prototype;
2020pp$6.initialContext = function() {
2021 return [types.b_stat];
2022};
2023pp$6.curContext = function() {
2024 return this.context[this.context.length - 1];
2025};
2026pp$6.braceIsBlock = function(prevType) {
2027 var parent = this.curContext();
2028 if (parent === types.f_expr || parent === types.f_stat) {
2029 return true;
2030 }
2031 if (prevType === types$1.colon && (parent === types.b_stat || parent === types.b_expr)) {
2032 return !parent.isExpr;
2033 }
2034 if (prevType === types$1._return || prevType === types$1.name && this.exprAllowed) {
2035 return lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
2036 }
2037 if (prevType === types$1._else || prevType === types$1.semi || prevType === types$1.eof || prevType === types$1.parenR || prevType === types$1.arrow) {
2038 return true;
2039 }
2040 if (prevType === types$1.braceL) {
2041 return parent === types.b_stat;
2042 }
2043 if (prevType === types$1._var || prevType === types$1._const || prevType === types$1.name) {
2044 return false;
2045 }
2046 return !this.exprAllowed;
2047};
2048pp$6.inGeneratorContext = function() {
2049 for (var i = this.context.length - 1; i >= 1; i--) {
2050 var context = this.context[i];
2051 if (context.token === "function") {
2052 return context.generator;
2053 }
2054 }
2055 return false;
2056};
2057pp$6.updateContext = function(prevType) {
2058 var update, type = this.type;
2059 if (type.keyword && prevType === types$1.dot) {
2060 this.exprAllowed = false;
2061 } else if (update = type.updateContext) {
2062 update.call(this, prevType);
2063 } else {
2064 this.exprAllowed = type.beforeExpr;
2065 }
2066};
2067pp$6.overrideContext = function(tokenCtx) {
2068 if (this.curContext() !== tokenCtx) {
2069 this.context[this.context.length - 1] = tokenCtx;
2070 }
2071};
2072types$1.parenR.updateContext = types$1.braceR.updateContext = function() {
2073 if (this.context.length === 1) {
2074 this.exprAllowed = true;
2075 return;
2076 }
2077 var out = this.context.pop();
2078 if (out === types.b_stat && this.curContext().token === "function") {
2079 out = this.context.pop();
2080 }
2081 this.exprAllowed = !out.isExpr;
2082};
2083types$1.braceL.updateContext = function(prevType) {
2084 this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr);
2085 this.exprAllowed = true;
2086};
2087types$1.dollarBraceL.updateContext = function() {
2088 this.context.push(types.b_tmpl);
2089 this.exprAllowed = true;
2090};
2091types$1.parenL.updateContext = function(prevType) {
2092 var statementParens = prevType === types$1._if || prevType === types$1._for || prevType === types$1._with || prevType === types$1._while;
2093 this.context.push(statementParens ? types.p_stat : types.p_expr);
2094 this.exprAllowed = true;
2095};
2096types$1.incDec.updateContext = function() {
2097};
2098types$1._function.updateContext = types$1._class.updateContext = function(prevType) {
2099 if (prevType.beforeExpr && prevType !== types$1._else && !(prevType === types$1.semi && this.curContext() !== types.p_stat) && !(prevType === types$1._return && lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) && !((prevType === types$1.colon || prevType === types$1.braceL) && this.curContext() === types.b_stat)) {
2100 this.context.push(types.f_expr);
2101 } else {
2102 this.context.push(types.f_stat);
2103 }
2104 this.exprAllowed = false;
2105};
2106types$1.backQuote.updateContext = function() {
2107 if (this.curContext() === types.q_tmpl) {
2108 this.context.pop();
2109 } else {
2110 this.context.push(types.q_tmpl);
2111 }
2112 this.exprAllowed = false;
2113};
2114types$1.star.updateContext = function(prevType) {
2115 if (prevType === types$1._function) {
2116 var index = this.context.length - 1;
2117 if (this.context[index] === types.f_expr) {
2118 this.context[index] = types.f_expr_gen;
2119 } else {
2120 this.context[index] = types.f_gen;
2121 }
2122 }
2123 this.exprAllowed = true;
2124};
2125types$1.name.updateContext = function(prevType) {
2126 var allowed = false;
2127 if (this.options.ecmaVersion >= 6 && prevType !== types$1.dot) {
2128 if (this.value === "of" && !this.exprAllowed || this.value === "yield" && this.inGeneratorContext()) {
2129 allowed = true;
2130 }
2131 }
2132 this.exprAllowed = allowed;
2133};
2134var pp$5 = Parser.prototype;
2135pp$5.checkPropClash = function(prop, propHash, refDestructuringErrors) {
2136 if (this.options.ecmaVersion >= 9 && prop.type === "SpreadElement") {
2137 return;
2138 }
2139 if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand)) {
2140 return;
2141 }
2142 var key = prop.key;
2143 var name;
2144 switch (key.type) {
2145 case "Identifier":
2146 name = key.name;
2147 break;
2148 case "Literal":
2149 name = String(key.value);
2150 break;
2151 default:
2152 return;
2153 }
2154 var kind = prop.kind;
2155 if (this.options.ecmaVersion >= 6) {
2156 if (name === "__proto__" && kind === "init") {
2157 if (propHash.proto) {
2158 if (refDestructuringErrors) {
2159 if (refDestructuringErrors.doubleProto < 0) {
2160 refDestructuringErrors.doubleProto = key.start;
2161 }
2162 } else {
2163 this.raiseRecoverable(key.start, "Redefinition of __proto__ property");
2164 }
2165 }
2166 propHash.proto = true;
2167 }
2168 return;
2169 }
2170 name = "$" + name;
2171 var other = propHash[name];
2172 if (other) {
2173 var redefinition;
2174 if (kind === "init") {
2175 redefinition = this.strict && other.init || other.get || other.set;
2176 } else {
2177 redefinition = other.init || other[kind];
2178 }
2179 if (redefinition) {
2180 this.raiseRecoverable(key.start, "Redefinition of property");
2181 }
2182 } else {
2183 other = propHash[name] = {
2184 init: false,
2185 get: false,
2186 set: false
2187 };
2188 }
2189 other[kind] = true;
2190};
2191pp$5.parseExpression = function(forInit, refDestructuringErrors) {
2192 var startPos = this.start, startLoc = this.startLoc;
2193 var expr = this.parseMaybeAssign(forInit, refDestructuringErrors);
2194 if (this.type === types$1.comma) {
2195 var node = this.startNodeAt(startPos, startLoc);
2196 node.expressions = [expr];
2197 while (this.eat(types$1.comma)) {
2198 node.expressions.push(this.parseMaybeAssign(forInit, refDestructuringErrors));
2199 }
2200 return this.finishNode(node, "SequenceExpression");
2201 }
2202 return expr;
2203};
2204pp$5.parseMaybeAssign = function(forInit, refDestructuringErrors, afterLeftParse) {
2205 if (this.isContextual("yield")) {
2206 if (this.inGenerator) {
2207 return this.parseYield(forInit);
2208 } else {
2209 this.exprAllowed = false;
2210 }
2211 }
2212 var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1, oldDoubleProto = -1;
2213 if (refDestructuringErrors) {
2214 oldParenAssign = refDestructuringErrors.parenthesizedAssign;
2215 oldTrailingComma = refDestructuringErrors.trailingComma;
2216 oldDoubleProto = refDestructuringErrors.doubleProto;
2217 refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = -1;
2218 } else {
2219 refDestructuringErrors = new DestructuringErrors();
2220 ownDestructuringErrors = true;
2221 }
2222 var startPos = this.start, startLoc = this.startLoc;
2223 if (this.type === types$1.parenL || this.type === types$1.name) {
2224 this.potentialArrowAt = this.start;
2225 this.potentialArrowInForAwait = forInit === "await";
2226 }
2227 var left = this.parseMaybeConditional(forInit, refDestructuringErrors);
2228 if (afterLeftParse) {
2229 left = afterLeftParse.call(this, left, startPos, startLoc);
2230 }
2231 if (this.type.isAssign) {
2232 var node = this.startNodeAt(startPos, startLoc);
2233 node.operator = this.value;
2234 if (this.type === types$1.eq) {
2235 left = this.toAssignable(left, false, refDestructuringErrors);
2236 }
2237 if (!ownDestructuringErrors) {
2238 refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.doubleProto = -1;
2239 }
2240 if (refDestructuringErrors.shorthandAssign >= left.start) {
2241 refDestructuringErrors.shorthandAssign = -1;
2242 }
2243 if (this.type === types$1.eq) {
2244 this.checkLValPattern(left);
2245 } else {
2246 this.checkLValSimple(left);
2247 }
2248 node.left = left;
2249 this.next();
2250 node.right = this.parseMaybeAssign(forInit);
2251 if (oldDoubleProto > -1) {
2252 refDestructuringErrors.doubleProto = oldDoubleProto;
2253 }
2254 return this.finishNode(node, "AssignmentExpression");
2255 } else {
2256 if (ownDestructuringErrors) {
2257 this.checkExpressionErrors(refDestructuringErrors, true);
2258 }
2259 }
2260 if (oldParenAssign > -1) {
2261 refDestructuringErrors.parenthesizedAssign = oldParenAssign;
2262 }
2263 if (oldTrailingComma > -1) {
2264 refDestructuringErrors.trailingComma = oldTrailingComma;
2265 }
2266 return left;
2267};
2268pp$5.parseMaybeConditional = function(forInit, refDestructuringErrors) {
2269 var startPos = this.start, startLoc = this.startLoc;
2270 var expr = this.parseExprOps(forInit, refDestructuringErrors);
2271 if (this.checkExpressionErrors(refDestructuringErrors)) {
2272 return expr;
2273 }
2274 if (this.eat(types$1.question)) {
2275 var node = this.startNodeAt(startPos, startLoc);
2276 node.test = expr;
2277 node.consequent = this.parseMaybeAssign();
2278 this.expect(types$1.colon);
2279 node.alternate = this.parseMaybeAssign(forInit);
2280 return this.finishNode(node, "ConditionalExpression");
2281 }
2282 return expr;
2283};
2284pp$5.parseExprOps = function(forInit, refDestructuringErrors) {
2285 var startPos = this.start, startLoc = this.startLoc;
2286 var expr = this.parseMaybeUnary(refDestructuringErrors, false, false, forInit);
2287 if (this.checkExpressionErrors(refDestructuringErrors)) {
2288 return expr;
2289 }
2290 return expr.start === startPos && expr.type === "ArrowFunctionExpression" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, forInit);
2291};
2292pp$5.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, forInit) {
2293 var prec = this.type.binop;
2294 if (prec != null && (!forInit || this.type !== types$1._in)) {
2295 if (prec > minPrec) {
2296 var logical = this.type === types$1.logicalOR || this.type === types$1.logicalAND;
2297 var coalesce = this.type === types$1.coalesce;
2298 if (coalesce) {
2299 prec = types$1.logicalAND.binop;
2300 }
2301 var op = this.value;
2302 this.next();
2303 var startPos = this.start, startLoc = this.startLoc;
2304 var right = this.parseExprOp(this.parseMaybeUnary(null, false, false, forInit), startPos, startLoc, prec, forInit);
2305 var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical || coalesce);
2306 if (logical && this.type === types$1.coalesce || coalesce && (this.type === types$1.logicalOR || this.type === types$1.logicalAND)) {
2307 this.raiseRecoverable(this.start, "Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses");
2308 }
2309 return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, forInit);
2310 }
2311 }
2312 return left;
2313};
2314pp$5.buildBinary = function(startPos, startLoc, left, right, op, logical) {
2315 if (right.type === "PrivateIdentifier") {
2316 this.raise(right.start, "Private identifier can only be left side of binary expression");
2317 }
2318 var node = this.startNodeAt(startPos, startLoc);
2319 node.left = left;
2320 node.operator = op;
2321 node.right = right;
2322 return this.finishNode(node, logical ? "LogicalExpression" : "BinaryExpression");
2323};
2324pp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forInit) {
2325 var startPos = this.start, startLoc = this.startLoc, expr;
2326 if (this.isContextual("await") && this.canAwait) {
2327 expr = this.parseAwait(forInit);
2328 sawUnary = true;
2329 } else if (this.type.prefix) {
2330 var node = this.startNode(), update = this.type === types$1.incDec;
2331 node.operator = this.value;
2332 node.prefix = true;
2333 this.next();
2334 node.argument = this.parseMaybeUnary(null, true, update, forInit);
2335 this.checkExpressionErrors(refDestructuringErrors, true);
2336 if (update) {
2337 this.checkLValSimple(node.argument);
2338 } else if (this.strict && node.operator === "delete" && node.argument.type === "Identifier") {
2339 this.raiseRecoverable(node.start, "Deleting local variable in strict mode");
2340 } else if (node.operator === "delete" && isPrivateFieldAccess(node.argument)) {
2341 this.raiseRecoverable(node.start, "Private fields can not be deleted");
2342 } else {
2343 sawUnary = true;
2344 }
2345 expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
2346 } else if (!sawUnary && this.type === types$1.privateId) {
2347 if (forInit || this.privateNameStack.length === 0) {
2348 this.unexpected();
2349 }
2350 expr = this.parsePrivateIdent();
2351 if (this.type !== types$1._in) {
2352 this.unexpected();
2353 }
2354 } else {
2355 expr = this.parseExprSubscripts(refDestructuringErrors, forInit);
2356 if (this.checkExpressionErrors(refDestructuringErrors)) {
2357 return expr;
2358 }
2359 while (this.type.postfix && !this.canInsertSemicolon()) {
2360 var node$1 = this.startNodeAt(startPos, startLoc);
2361 node$1.operator = this.value;
2362 node$1.prefix = false;
2363 node$1.argument = expr;
2364 this.checkLValSimple(expr);
2365 this.next();
2366 expr = this.finishNode(node$1, "UpdateExpression");
2367 }
2368 }
2369 if (!incDec && this.eat(types$1.starstar)) {
2370 if (sawUnary) {
2371 this.unexpected(this.lastTokStart);
2372 } else {
2373 return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false, false, forInit), "**", false);
2374 }
2375 } else {
2376 return expr;
2377 }
2378};
2379function isPrivateFieldAccess(node) {
2380 return node.type === "MemberExpression" && node.property.type === "PrivateIdentifier" || node.type === "ChainExpression" && isPrivateFieldAccess(node.expression);
2381}
2382pp$5.parseExprSubscripts = function(refDestructuringErrors, forInit) {
2383 var startPos = this.start, startLoc = this.startLoc;
2384 var expr = this.parseExprAtom(refDestructuringErrors, forInit);
2385 if (expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")") {
2386 return expr;
2387 }
2388 var result = this.parseSubscripts(expr, startPos, startLoc, false, forInit);
2389 if (refDestructuringErrors && result.type === "MemberExpression") {
2390 if (refDestructuringErrors.parenthesizedAssign >= result.start) {
2391 refDestructuringErrors.parenthesizedAssign = -1;
2392 }
2393 if (refDestructuringErrors.parenthesizedBind >= result.start) {
2394 refDestructuringErrors.parenthesizedBind = -1;
2395 }
2396 if (refDestructuringErrors.trailingComma >= result.start) {
2397 refDestructuringErrors.trailingComma = -1;
2398 }
2399 }
2400 return result;
2401};
2402pp$5.parseSubscripts = function(base, startPos, startLoc, noCalls, forInit) {
2403 var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" && this.lastTokEnd === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 && this.potentialArrowAt === base.start;
2404 var optionalChained = false;
2405 while (true) {
2406 var element = this.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit);
2407 if (element.optional) {
2408 optionalChained = true;
2409 }
2410 if (element === base || element.type === "ArrowFunctionExpression") {
2411 if (optionalChained) {
2412 var chainNode = this.startNodeAt(startPos, startLoc);
2413 chainNode.expression = element;
2414 element = this.finishNode(chainNode, "ChainExpression");
2415 }
2416 return element;
2417 }
2418 base = element;
2419 }
2420};
2421pp$5.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit) {
2422 var optionalSupported = this.options.ecmaVersion >= 11;
2423 var optional = optionalSupported && this.eat(types$1.questionDot);
2424 if (noCalls && optional) {
2425 this.raise(this.lastTokStart, "Optional chaining cannot appear in the callee of new expressions");
2426 }
2427 var computed = this.eat(types$1.bracketL);
2428 if (computed || optional && this.type !== types$1.parenL && this.type !== types$1.backQuote || this.eat(types$1.dot)) {
2429 var node = this.startNodeAt(startPos, startLoc);
2430 node.object = base;
2431 if (computed) {
2432 node.property = this.parseExpression();
2433 this.expect(types$1.bracketR);
2434 } else if (this.type === types$1.privateId && base.type !== "Super") {
2435 node.property = this.parsePrivateIdent();
2436 } else {
2437 node.property = this.parseIdent(this.options.allowReserved !== "never");
2438 }
2439 node.computed = !!computed;
2440 if (optionalSupported) {
2441 node.optional = optional;
2442 }
2443 base = this.finishNode(node, "MemberExpression");
2444 } else if (!noCalls && this.eat(types$1.parenL)) {
2445 var refDestructuringErrors = new DestructuringErrors(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
2446 this.yieldPos = 0;
2447 this.awaitPos = 0;
2448 this.awaitIdentPos = 0;
2449 var exprList = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors);
2450 if (maybeAsyncArrow && !optional && !this.canInsertSemicolon() && this.eat(types$1.arrow)) {
2451 this.checkPatternErrors(refDestructuringErrors, false);
2452 this.checkYieldAwaitInDefaultParams();
2453 if (this.awaitIdentPos > 0) {
2454 this.raise(this.awaitIdentPos, "Cannot use 'await' as identifier inside an async function");
2455 }
2456 this.yieldPos = oldYieldPos;
2457 this.awaitPos = oldAwaitPos;
2458 this.awaitIdentPos = oldAwaitIdentPos;
2459 return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, true, forInit);
2460 }
2461 this.checkExpressionErrors(refDestructuringErrors, true);
2462 this.yieldPos = oldYieldPos || this.yieldPos;
2463 this.awaitPos = oldAwaitPos || this.awaitPos;
2464 this.awaitIdentPos = oldAwaitIdentPos || this.awaitIdentPos;
2465 var node$1 = this.startNodeAt(startPos, startLoc);
2466 node$1.callee = base;
2467 node$1.arguments = exprList;
2468 if (optionalSupported) {
2469 node$1.optional = optional;
2470 }
2471 base = this.finishNode(node$1, "CallExpression");
2472 } else if (this.type === types$1.backQuote) {
2473 if (optional || optionalChained) {
2474 this.raise(this.start, "Optional chaining cannot appear in the tag of tagged template expressions");
2475 }
2476 var node$2 = this.startNodeAt(startPos, startLoc);
2477 node$2.tag = base;
2478 node$2.quasi = this.parseTemplate({ isTagged: true });
2479 base = this.finishNode(node$2, "TaggedTemplateExpression");
2480 }
2481 return base;
2482};
2483pp$5.parseExprAtom = function(refDestructuringErrors, forInit) {
2484 if (this.type === types$1.slash) {
2485 this.readRegexp();
2486 }
2487 var node, canBeArrow = this.potentialArrowAt === this.start;
2488 switch (this.type) {
2489 case types$1._super:
2490 if (!this.allowSuper) {
2491 this.raise(this.start, "'super' keyword outside a method");
2492 }
2493 node = this.startNode();
2494 this.next();
2495 if (this.type === types$1.parenL && !this.allowDirectSuper) {
2496 this.raise(node.start, "super() call outside constructor of a subclass");
2497 }
2498 if (this.type !== types$1.dot && this.type !== types$1.bracketL && this.type !== types$1.parenL) {
2499 this.unexpected();
2500 }
2501 return this.finishNode(node, "Super");
2502 case types$1._this:
2503 node = this.startNode();
2504 this.next();
2505 return this.finishNode(node, "ThisExpression");
2506 case types$1.name:
2507 var startPos = this.start, startLoc = this.startLoc, containsEsc = this.containsEsc;
2508 var id = this.parseIdent(false);
2509 if (this.options.ecmaVersion >= 8 && !containsEsc && id.name === "async" && !this.canInsertSemicolon() && this.eat(types$1._function)) {
2510 this.overrideContext(types.f_expr);
2511 return this.parseFunction(this.startNodeAt(startPos, startLoc), 0, false, true, forInit);
2512 }
2513 if (canBeArrow && !this.canInsertSemicolon()) {
2514 if (this.eat(types$1.arrow)) {
2515 return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false, forInit);
2516 }
2517 if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === types$1.name && !containsEsc && (!this.potentialArrowInForAwait || this.value !== "of" || this.containsEsc)) {
2518 id = this.parseIdent(false);
2519 if (this.canInsertSemicolon() || !this.eat(types$1.arrow)) {
2520 this.unexpected();
2521 }
2522 return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true, forInit);
2523 }
2524 }
2525 return id;
2526 case types$1.regexp:
2527 var value = this.value;
2528 node = this.parseLiteral(value.value);
2529 node.regex = { pattern: value.pattern, flags: value.flags };
2530 return node;
2531 case types$1.num:
2532 case types$1.string:
2533 return this.parseLiteral(this.value);
2534 case types$1._null:
2535 case types$1._true:
2536 case types$1._false:
2537 node = this.startNode();
2538 node.value = this.type === types$1._null ? null : this.type === types$1._true;
2539 node.raw = this.type.keyword;
2540 this.next();
2541 return this.finishNode(node, "Literal");
2542 case types$1.parenL:
2543 var start = this.start, expr = this.parseParenAndDistinguishExpression(canBeArrow, forInit);
2544 if (refDestructuringErrors) {
2545 if (refDestructuringErrors.parenthesizedAssign < 0 && !this.isSimpleAssignTarget(expr)) {
2546 refDestructuringErrors.parenthesizedAssign = start;
2547 }
2548 if (refDestructuringErrors.parenthesizedBind < 0) {
2549 refDestructuringErrors.parenthesizedBind = start;
2550 }
2551 }
2552 return expr;
2553 case types$1.bracketL:
2554 node = this.startNode();
2555 this.next();
2556 node.elements = this.parseExprList(types$1.bracketR, true, true, refDestructuringErrors);
2557 return this.finishNode(node, "ArrayExpression");
2558 case types$1.braceL:
2559 this.overrideContext(types.b_expr);
2560 return this.parseObj(false, refDestructuringErrors);
2561 case types$1._function:
2562 node = this.startNode();
2563 this.next();
2564 return this.parseFunction(node, 0);
2565 case types$1._class:
2566 return this.parseClass(this.startNode(), false);
2567 case types$1._new:
2568 return this.parseNew();
2569 case types$1.backQuote:
2570 return this.parseTemplate();
2571 case types$1._import:
2572 if (this.options.ecmaVersion >= 11) {
2573 return this.parseExprImport();
2574 } else {
2575 return this.unexpected();
2576 }
2577 default:
2578 this.unexpected();
2579 }
2580};
2581pp$5.parseExprImport = function() {
2582 var node = this.startNode();
2583 if (this.containsEsc) {
2584 this.raiseRecoverable(this.start, "Escape sequence in keyword import");
2585 }
2586 var meta = this.parseIdent(true);
2587 switch (this.type) {
2588 case types$1.parenL:
2589 return this.parseDynamicImport(node);
2590 case types$1.dot:
2591 node.meta = meta;
2592 return this.parseImportMeta(node);
2593 default:
2594 this.unexpected();
2595 }
2596};
2597pp$5.parseDynamicImport = function(node) {
2598 this.next();
2599 node.source = this.parseMaybeAssign();
2600 if (!this.eat(types$1.parenR)) {
2601 var errorPos = this.start;
2602 if (this.eat(types$1.comma) && this.eat(types$1.parenR)) {
2603 this.raiseRecoverable(errorPos, "Trailing comma is not allowed in import()");
2604 } else {
2605 this.unexpected(errorPos);
2606 }
2607 }
2608 return this.finishNode(node, "ImportExpression");
2609};
2610pp$5.parseImportMeta = function(node) {
2611 this.next();
2612 var containsEsc = this.containsEsc;
2613 node.property = this.parseIdent(true);
2614 if (node.property.name !== "meta") {
2615 this.raiseRecoverable(node.property.start, "The only valid meta property for import is 'import.meta'");
2616 }
2617 if (containsEsc) {
2618 this.raiseRecoverable(node.start, "'import.meta' must not contain escaped characters");
2619 }
2620 if (this.options.sourceType !== "module" && !this.options.allowImportExportEverywhere) {
2621 this.raiseRecoverable(node.start, "Cannot use 'import.meta' outside a module");
2622 }
2623 return this.finishNode(node, "MetaProperty");
2624};
2625pp$5.parseLiteral = function(value) {
2626 var node = this.startNode();
2627 node.value = value;
2628 node.raw = this.input.slice(this.start, this.end);
2629 if (node.raw.charCodeAt(node.raw.length - 1) === 110) {
2630 node.bigint = node.raw.slice(0, -1).replace(/_/g, "");
2631 }
2632 this.next();
2633 return this.finishNode(node, "Literal");
2634};
2635pp$5.parseParenExpression = function() {
2636 this.expect(types$1.parenL);
2637 var val = this.parseExpression();
2638 this.expect(types$1.parenR);
2639 return val;
2640};
2641pp$5.parseParenAndDistinguishExpression = function(canBeArrow, forInit) {
2642 var startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8;
2643 if (this.options.ecmaVersion >= 6) {
2644 this.next();
2645 var innerStartPos = this.start, innerStartLoc = this.startLoc;
2646 var exprList = [], first = true, lastIsComma = false;
2647 var refDestructuringErrors = new DestructuringErrors(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, spreadStart;
2648 this.yieldPos = 0;
2649 this.awaitPos = 0;
2650 while (this.type !== types$1.parenR) {
2651 first ? first = false : this.expect(types$1.comma);
2652 if (allowTrailingComma && this.afterTrailingComma(types$1.parenR, true)) {
2653 lastIsComma = true;
2654 break;
2655 } else if (this.type === types$1.ellipsis) {
2656 spreadStart = this.start;
2657 exprList.push(this.parseParenItem(this.parseRestBinding()));
2658 if (this.type === types$1.comma) {
2659 this.raise(this.start, "Comma is not permitted after the rest element");
2660 }
2661 break;
2662 } else {
2663 exprList.push(this.parseMaybeAssign(false, refDestructuringErrors, this.parseParenItem));
2664 }
2665 }
2666 var innerEndPos = this.lastTokEnd, innerEndLoc = this.lastTokEndLoc;
2667 this.expect(types$1.parenR);
2668 if (canBeArrow && !this.canInsertSemicolon() && this.eat(types$1.arrow)) {
2669 this.checkPatternErrors(refDestructuringErrors, false);
2670 this.checkYieldAwaitInDefaultParams();
2671 this.yieldPos = oldYieldPos;
2672 this.awaitPos = oldAwaitPos;
2673 return this.parseParenArrowList(startPos, startLoc, exprList, forInit);
2674 }
2675 if (!exprList.length || lastIsComma) {
2676 this.unexpected(this.lastTokStart);
2677 }
2678 if (spreadStart) {
2679 this.unexpected(spreadStart);
2680 }
2681 this.checkExpressionErrors(refDestructuringErrors, true);
2682 this.yieldPos = oldYieldPos || this.yieldPos;
2683 this.awaitPos = oldAwaitPos || this.awaitPos;
2684 if (exprList.length > 1) {
2685 val = this.startNodeAt(innerStartPos, innerStartLoc);
2686 val.expressions = exprList;
2687 this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc);
2688 } else {
2689 val = exprList[0];
2690 }
2691 } else {
2692 val = this.parseParenExpression();
2693 }
2694 if (this.options.preserveParens) {
2695 var par = this.startNodeAt(startPos, startLoc);
2696 par.expression = val;
2697 return this.finishNode(par, "ParenthesizedExpression");
2698 } else {
2699 return val;
2700 }
2701};
2702pp$5.parseParenItem = function(item) {
2703 return item;
2704};
2705pp$5.parseParenArrowList = function(startPos, startLoc, exprList, forInit) {
2706 return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, false, forInit);
2707};
2708var empty = [];
2709pp$5.parseNew = function() {
2710 if (this.containsEsc) {
2711 this.raiseRecoverable(this.start, "Escape sequence in keyword new");
2712 }
2713 var node = this.startNode();
2714 var meta = this.parseIdent(true);
2715 if (this.options.ecmaVersion >= 6 && this.eat(types$1.dot)) {
2716 node.meta = meta;
2717 var containsEsc = this.containsEsc;
2718 node.property = this.parseIdent(true);
2719 if (node.property.name !== "target") {
2720 this.raiseRecoverable(node.property.start, "The only valid meta property for new is 'new.target'");
2721 }
2722 if (containsEsc) {
2723 this.raiseRecoverable(node.start, "'new.target' must not contain escaped characters");
2724 }
2725 if (!this.allowNewDotTarget) {
2726 this.raiseRecoverable(node.start, "'new.target' can only be used in functions and class static block");
2727 }
2728 return this.finishNode(node, "MetaProperty");
2729 }
2730 var startPos = this.start, startLoc = this.startLoc, isImport = this.type === types$1._import;
2731 node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true, false);
2732 if (isImport && node.callee.type === "ImportExpression") {
2733 this.raise(startPos, "Cannot use new with import()");
2734 }
2735 if (this.eat(types$1.parenL)) {
2736 node.arguments = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false);
2737 } else {
2738 node.arguments = empty;
2739 }
2740 return this.finishNode(node, "NewExpression");
2741};
2742pp$5.parseTemplateElement = function(ref2) {
2743 var isTagged = ref2.isTagged;
2744 var elem = this.startNode();
2745 if (this.type === types$1.invalidTemplate) {
2746 if (!isTagged) {
2747 this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal");
2748 }
2749 elem.value = {
2750 raw: this.value,
2751 cooked: null
2752 };
2753 } else {
2754 elem.value = {
2755 raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, "\n"),
2756 cooked: this.value
2757 };
2758 }
2759 this.next();
2760 elem.tail = this.type === types$1.backQuote;
2761 return this.finishNode(elem, "TemplateElement");
2762};
2763pp$5.parseTemplate = function(ref2) {
2764 if (ref2 === void 0)
2765 ref2 = {};
2766 var isTagged = ref2.isTagged;
2767 if (isTagged === void 0)
2768 isTagged = false;
2769 var node = this.startNode();
2770 this.next();
2771 node.expressions = [];
2772 var curElt = this.parseTemplateElement({ isTagged });
2773 node.quasis = [curElt];
2774 while (!curElt.tail) {
2775 if (this.type === types$1.eof) {
2776 this.raise(this.pos, "Unterminated template literal");
2777 }
2778 this.expect(types$1.dollarBraceL);
2779 node.expressions.push(this.parseExpression());
2780 this.expect(types$1.braceR);
2781 node.quasis.push(curElt = this.parseTemplateElement({ isTagged }));
2782 }
2783 this.next();
2784 return this.finishNode(node, "TemplateLiteral");
2785};
2786pp$5.isAsyncProp = function(prop) {
2787 return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" && (this.type === types$1.name || this.type === types$1.num || this.type === types$1.string || this.type === types$1.bracketL || this.type.keyword || this.options.ecmaVersion >= 9 && this.type === types$1.star) && !lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
2788};
2789pp$5.parseObj = function(isPattern, refDestructuringErrors) {
2790 var node = this.startNode(), first = true, propHash = {};
2791 node.properties = [];
2792 this.next();
2793 while (!this.eat(types$1.braceR)) {
2794 if (!first) {
2795 this.expect(types$1.comma);
2796 if (this.options.ecmaVersion >= 5 && this.afterTrailingComma(types$1.braceR)) {
2797 break;
2798 }
2799 } else {
2800 first = false;
2801 }
2802 var prop = this.parseProperty(isPattern, refDestructuringErrors);
2803 if (!isPattern) {
2804 this.checkPropClash(prop, propHash, refDestructuringErrors);
2805 }
2806 node.properties.push(prop);
2807 }
2808 return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression");
2809};
2810pp$5.parseProperty = function(isPattern, refDestructuringErrors) {
2811 var prop = this.startNode(), isGenerator, isAsync, startPos, startLoc;
2812 if (this.options.ecmaVersion >= 9 && this.eat(types$1.ellipsis)) {
2813 if (isPattern) {
2814 prop.argument = this.parseIdent(false);
2815 if (this.type === types$1.comma) {
2816 this.raise(this.start, "Comma is not permitted after the rest element");
2817 }
2818 return this.finishNode(prop, "RestElement");
2819 }
2820 prop.argument = this.parseMaybeAssign(false, refDestructuringErrors);
2821 if (this.type === types$1.comma && refDestructuringErrors && refDestructuringErrors.trailingComma < 0) {
2822 refDestructuringErrors.trailingComma = this.start;
2823 }
2824 return this.finishNode(prop, "SpreadElement");
2825 }
2826 if (this.options.ecmaVersion >= 6) {
2827 prop.method = false;
2828 prop.shorthand = false;
2829 if (isPattern || refDestructuringErrors) {
2830 startPos = this.start;
2831 startLoc = this.startLoc;
2832 }
2833 if (!isPattern) {
2834 isGenerator = this.eat(types$1.star);
2835 }
2836 }
2837 var containsEsc = this.containsEsc;
2838 this.parsePropertyName(prop);
2839 if (!isPattern && !containsEsc && this.options.ecmaVersion >= 8 && !isGenerator && this.isAsyncProp(prop)) {
2840 isAsync = true;
2841 isGenerator = this.options.ecmaVersion >= 9 && this.eat(types$1.star);
2842 this.parsePropertyName(prop, refDestructuringErrors);
2843 } else {
2844 isAsync = false;
2845 }
2846 this.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc);
2847 return this.finishNode(prop, "Property");
2848};
2849pp$5.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc) {
2850 if ((isGenerator || isAsync) && this.type === types$1.colon) {
2851 this.unexpected();
2852 }
2853 if (this.eat(types$1.colon)) {
2854 prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors);
2855 prop.kind = "init";
2856 } else if (this.options.ecmaVersion >= 6 && this.type === types$1.parenL) {
2857 if (isPattern) {
2858 this.unexpected();
2859 }
2860 prop.kind = "init";
2861 prop.method = true;
2862 prop.value = this.parseMethod(isGenerator, isAsync);
2863 } else if (!isPattern && !containsEsc && this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" && (prop.key.name === "get" || prop.key.name === "set") && (this.type !== types$1.comma && this.type !== types$1.braceR && this.type !== types$1.eq)) {
2864 if (isGenerator || isAsync) {
2865 this.unexpected();
2866 }
2867 prop.kind = prop.key.name;
2868 this.parsePropertyName(prop);
2869 prop.value = this.parseMethod(false);
2870 var paramCount = prop.kind === "get" ? 0 : 1;
2871 if (prop.value.params.length !== paramCount) {
2872 var start = prop.value.start;
2873 if (prop.kind === "get") {
2874 this.raiseRecoverable(start, "getter should have no params");
2875 } else {
2876 this.raiseRecoverable(start, "setter should have exactly one param");
2877 }
2878 } else {
2879 if (prop.kind === "set" && prop.value.params[0].type === "RestElement") {
2880 this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params");
2881 }
2882 }
2883 } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
2884 if (isGenerator || isAsync) {
2885 this.unexpected();
2886 }
2887 this.checkUnreserved(prop.key);
2888 if (prop.key.name === "await" && !this.awaitIdentPos) {
2889 this.awaitIdentPos = startPos;
2890 }
2891 prop.kind = "init";
2892 if (isPattern) {
2893 prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key));
2894 } else if (this.type === types$1.eq && refDestructuringErrors) {
2895 if (refDestructuringErrors.shorthandAssign < 0) {
2896 refDestructuringErrors.shorthandAssign = this.start;
2897 }
2898 prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key));
2899 } else {
2900 prop.value = this.copyNode(prop.key);
2901 }
2902 prop.shorthand = true;
2903 } else {
2904 this.unexpected();
2905 }
2906};
2907pp$5.parsePropertyName = function(prop) {
2908 if (this.options.ecmaVersion >= 6) {
2909 if (this.eat(types$1.bracketL)) {
2910 prop.computed = true;
2911 prop.key = this.parseMaybeAssign();
2912 this.expect(types$1.bracketR);
2913 return prop.key;
2914 } else {
2915 prop.computed = false;
2916 }
2917 }
2918 return prop.key = this.type === types$1.num || this.type === types$1.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never");
2919};
2920pp$5.initFunction = function(node) {
2921 node.id = null;
2922 if (this.options.ecmaVersion >= 6) {
2923 node.generator = node.expression = false;
2924 }
2925 if (this.options.ecmaVersion >= 8) {
2926 node.async = false;
2927 }
2928};
2929pp$5.parseMethod = function(isGenerator, isAsync, allowDirectSuper) {
2930 var node = this.startNode(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
2931 this.initFunction(node);
2932 if (this.options.ecmaVersion >= 6) {
2933 node.generator = isGenerator;
2934 }
2935 if (this.options.ecmaVersion >= 8) {
2936 node.async = !!isAsync;
2937 }
2938 this.yieldPos = 0;
2939 this.awaitPos = 0;
2940 this.awaitIdentPos = 0;
2941 this.enterScope(functionFlags(isAsync, node.generator) | SCOPE_SUPER | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0));
2942 this.expect(types$1.parenL);
2943 node.params = this.parseBindingList(types$1.parenR, false, this.options.ecmaVersion >= 8);
2944 this.checkYieldAwaitInDefaultParams();
2945 this.parseFunctionBody(node, false, true, false);
2946 this.yieldPos = oldYieldPos;
2947 this.awaitPos = oldAwaitPos;
2948 this.awaitIdentPos = oldAwaitIdentPos;
2949 return this.finishNode(node, "FunctionExpression");
2950};
2951pp$5.parseArrowExpression = function(node, params, isAsync, forInit) {
2952 var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
2953 this.enterScope(functionFlags(isAsync, false) | SCOPE_ARROW);
2954 this.initFunction(node);
2955 if (this.options.ecmaVersion >= 8) {
2956 node.async = !!isAsync;
2957 }
2958 this.yieldPos = 0;
2959 this.awaitPos = 0;
2960 this.awaitIdentPos = 0;
2961 node.params = this.toAssignableList(params, true);
2962 this.parseFunctionBody(node, true, false, forInit);
2963 this.yieldPos = oldYieldPos;
2964 this.awaitPos = oldAwaitPos;
2965 this.awaitIdentPos = oldAwaitIdentPos;
2966 return this.finishNode(node, "ArrowFunctionExpression");
2967};
2968pp$5.parseFunctionBody = function(node, isArrowFunction, isMethod, forInit) {
2969 var isExpression = isArrowFunction && this.type !== types$1.braceL;
2970 var oldStrict = this.strict, useStrict = false;
2971 if (isExpression) {
2972 node.body = this.parseMaybeAssign(forInit);
2973 node.expression = true;
2974 this.checkParams(node, false);
2975 } else {
2976 var nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params);
2977 if (!oldStrict || nonSimple) {
2978 useStrict = this.strictDirective(this.end);
2979 if (useStrict && nonSimple) {
2980 this.raiseRecoverable(node.start, "Illegal 'use strict' directive in function with non-simple parameter list");
2981 }
2982 }
2983 var oldLabels = this.labels;
2984 this.labels = [];
2985 if (useStrict) {
2986 this.strict = true;
2987 }
2988 this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && !isMethod && this.isSimpleParamList(node.params));
2989 if (this.strict && node.id) {
2990 this.checkLValSimple(node.id, BIND_OUTSIDE);
2991 }
2992 node.body = this.parseBlock(false, void 0, useStrict && !oldStrict);
2993 node.expression = false;
2994 this.adaptDirectivePrologue(node.body.body);
2995 this.labels = oldLabels;
2996 }
2997 this.exitScope();
2998};
2999pp$5.isSimpleParamList = function(params) {
3000 for (var i = 0, list = params; i < list.length; i += 1) {
3001 var param = list[i];
3002 if (param.type !== "Identifier") {
3003 return false;
3004 }
3005 }
3006 return true;
3007};
3008pp$5.checkParams = function(node, allowDuplicates) {
3009 var nameHash = /* @__PURE__ */ Object.create(null);
3010 for (var i = 0, list = node.params; i < list.length; i += 1) {
3011 var param = list[i];
3012 this.checkLValInnerPattern(param, BIND_VAR, allowDuplicates ? null : nameHash);
3013 }
3014};
3015pp$5.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestructuringErrors) {
3016 var elts = [], first = true;
3017 while (!this.eat(close)) {
3018 if (!first) {
3019 this.expect(types$1.comma);
3020 if (allowTrailingComma && this.afterTrailingComma(close)) {
3021 break;
3022 }
3023 } else {
3024 first = false;
3025 }
3026 var elt = void 0;
3027 if (allowEmpty && this.type === types$1.comma) {
3028 elt = null;
3029 } else if (this.type === types$1.ellipsis) {
3030 elt = this.parseSpread(refDestructuringErrors);
3031 if (refDestructuringErrors && this.type === types$1.comma && refDestructuringErrors.trailingComma < 0) {
3032 refDestructuringErrors.trailingComma = this.start;
3033 }
3034 } else {
3035 elt = this.parseMaybeAssign(false, refDestructuringErrors);
3036 }
3037 elts.push(elt);
3038 }
3039 return elts;
3040};
3041pp$5.checkUnreserved = function(ref2) {
3042 var start = ref2.start;
3043 var end = ref2.end;
3044 var name = ref2.name;
3045 if (this.inGenerator && name === "yield") {
3046 this.raiseRecoverable(start, "Cannot use 'yield' as identifier inside a generator");
3047 }
3048 if (this.inAsync && name === "await") {
3049 this.raiseRecoverable(start, "Cannot use 'await' as identifier inside an async function");
3050 }
3051 if (this.currentThisScope().inClassFieldInit && name === "arguments") {
3052 this.raiseRecoverable(start, "Cannot use 'arguments' in class field initializer");
3053 }
3054 if (this.inClassStaticBlock && (name === "arguments" || name === "await")) {
3055 this.raise(start, "Cannot use " + name + " in class static initialization block");
3056 }
3057 if (this.keywords.test(name)) {
3058 this.raise(start, "Unexpected keyword '" + name + "'");
3059 }
3060 if (this.options.ecmaVersion < 6 && this.input.slice(start, end).indexOf("\\") !== -1) {
3061 return;
3062 }
3063 var re = this.strict ? this.reservedWordsStrict : this.reservedWords;
3064 if (re.test(name)) {
3065 if (!this.inAsync && name === "await") {
3066 this.raiseRecoverable(start, "Cannot use keyword 'await' outside an async function");
3067 }
3068 this.raiseRecoverable(start, "The keyword '" + name + "' is reserved");
3069 }
3070};
3071pp$5.parseIdent = function(liberal, isBinding) {
3072 var node = this.startNode();
3073 if (this.type === types$1.name) {
3074 node.name = this.value;
3075 } else if (this.type.keyword) {
3076 node.name = this.type.keyword;
3077 if ((node.name === "class" || node.name === "function") && (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46)) {
3078 this.context.pop();
3079 }
3080 } else {
3081 this.unexpected();
3082 }
3083 this.next(!!liberal);
3084 this.finishNode(node, "Identifier");
3085 if (!liberal) {
3086 this.checkUnreserved(node);
3087 if (node.name === "await" && !this.awaitIdentPos) {
3088 this.awaitIdentPos = node.start;
3089 }
3090 }
3091 return node;
3092};
3093pp$5.parsePrivateIdent = function() {
3094 var node = this.startNode();
3095 if (this.type === types$1.privateId) {
3096 node.name = this.value;
3097 } else {
3098 this.unexpected();
3099 }
3100 this.next();
3101 this.finishNode(node, "PrivateIdentifier");
3102 if (this.privateNameStack.length === 0) {
3103 this.raise(node.start, "Private field '#" + node.name + "' must be declared in an enclosing class");
3104 } else {
3105 this.privateNameStack[this.privateNameStack.length - 1].used.push(node);
3106 }
3107 return node;
3108};
3109pp$5.parseYield = function(forInit) {
3110 if (!this.yieldPos) {
3111 this.yieldPos = this.start;
3112 }
3113 var node = this.startNode();
3114 this.next();
3115 if (this.type === types$1.semi || this.canInsertSemicolon() || this.type !== types$1.star && !this.type.startsExpr) {
3116 node.delegate = false;
3117 node.argument = null;
3118 } else {
3119 node.delegate = this.eat(types$1.star);
3120 node.argument = this.parseMaybeAssign(forInit);
3121 }
3122 return this.finishNode(node, "YieldExpression");
3123};
3124pp$5.parseAwait = function(forInit) {
3125 if (!this.awaitPos) {
3126 this.awaitPos = this.start;
3127 }
3128 var node = this.startNode();
3129 this.next();
3130 node.argument = this.parseMaybeUnary(null, true, false, forInit);
3131 return this.finishNode(node, "AwaitExpression");
3132};
3133var pp$4 = Parser.prototype;
3134pp$4.raise = function(pos, message) {
3135 var loc = getLineInfo(this.input, pos);
3136 message += " (" + loc.line + ":" + loc.column + ")";
3137 var err = new SyntaxError(message);
3138 err.pos = pos;
3139 err.loc = loc;
3140 err.raisedAt = this.pos;
3141 throw err;
3142};
3143pp$4.raiseRecoverable = pp$4.raise;
3144pp$4.curPosition = function() {
3145 if (this.options.locations) {
3146 return new Position(this.curLine, this.pos - this.lineStart);
3147 }
3148};
3149var pp$3 = Parser.prototype;
3150var Scope = function Scope2(flags) {
3151 this.flags = flags;
3152 this.var = [];
3153 this.lexical = [];
3154 this.functions = [];
3155 this.inClassFieldInit = false;
3156};
3157pp$3.enterScope = function(flags) {
3158 this.scopeStack.push(new Scope(flags));
3159};
3160pp$3.exitScope = function() {
3161 this.scopeStack.pop();
3162};
3163pp$3.treatFunctionsAsVarInScope = function(scope) {
3164 return scope.flags & SCOPE_FUNCTION || !this.inModule && scope.flags & SCOPE_TOP;
3165};
3166pp$3.declareName = function(name, bindingType, pos) {
3167 var redeclared = false;
3168 if (bindingType === BIND_LEXICAL) {
3169 var scope = this.currentScope();
3170 redeclared = scope.lexical.indexOf(name) > -1 || scope.functions.indexOf(name) > -1 || scope.var.indexOf(name) > -1;
3171 scope.lexical.push(name);
3172 if (this.inModule && scope.flags & SCOPE_TOP) {
3173 delete this.undefinedExports[name];
3174 }
3175 } else if (bindingType === BIND_SIMPLE_CATCH) {
3176 var scope$1 = this.currentScope();
3177 scope$1.lexical.push(name);
3178 } else if (bindingType === BIND_FUNCTION) {
3179 var scope$2 = this.currentScope();
3180 if (this.treatFunctionsAsVar) {
3181 redeclared = scope$2.lexical.indexOf(name) > -1;
3182 } else {
3183 redeclared = scope$2.lexical.indexOf(name) > -1 || scope$2.var.indexOf(name) > -1;
3184 }
3185 scope$2.functions.push(name);
3186 } else {
3187 for (var i = this.scopeStack.length - 1; i >= 0; --i) {
3188 var scope$3 = this.scopeStack[i];
3189 if (scope$3.lexical.indexOf(name) > -1 && !(scope$3.flags & SCOPE_SIMPLE_CATCH && scope$3.lexical[0] === name) || !this.treatFunctionsAsVarInScope(scope$3) && scope$3.functions.indexOf(name) > -1) {
3190 redeclared = true;
3191 break;
3192 }
3193 scope$3.var.push(name);
3194 if (this.inModule && scope$3.flags & SCOPE_TOP) {
3195 delete this.undefinedExports[name];
3196 }
3197 if (scope$3.flags & SCOPE_VAR) {
3198 break;
3199 }
3200 }
3201 }
3202 if (redeclared) {
3203 this.raiseRecoverable(pos, "Identifier '" + name + "' has already been declared");
3204 }
3205};
3206pp$3.checkLocalExport = function(id) {
3207 if (this.scopeStack[0].lexical.indexOf(id.name) === -1 && this.scopeStack[0].var.indexOf(id.name) === -1) {
3208 this.undefinedExports[id.name] = id;
3209 }
3210};
3211pp$3.currentScope = function() {
3212 return this.scopeStack[this.scopeStack.length - 1];
3213};
3214pp$3.currentVarScope = function() {
3215 for (var i = this.scopeStack.length - 1; ; i--) {
3216 var scope = this.scopeStack[i];
3217 if (scope.flags & SCOPE_VAR) {
3218 return scope;
3219 }
3220 }
3221};
3222pp$3.currentThisScope = function() {
3223 for (var i = this.scopeStack.length - 1; ; i--) {
3224 var scope = this.scopeStack[i];
3225 if (scope.flags & SCOPE_VAR && !(scope.flags & SCOPE_ARROW)) {
3226 return scope;
3227 }
3228 }
3229};
3230var Node = function Node2(parser, pos, loc) {
3231 this.type = "";
3232 this.start = pos;
3233 this.end = 0;
3234 if (parser.options.locations) {
3235 this.loc = new SourceLocation(parser, loc);
3236 }
3237 if (parser.options.directSourceFile) {
3238 this.sourceFile = parser.options.directSourceFile;
3239 }
3240 if (parser.options.ranges) {
3241 this.range = [pos, 0];
3242 }
3243};
3244var pp$2 = Parser.prototype;
3245pp$2.startNode = function() {
3246 return new Node(this, this.start, this.startLoc);
3247};
3248pp$2.startNodeAt = function(pos, loc) {
3249 return new Node(this, pos, loc);
3250};
3251function finishNodeAt(node, type, pos, loc) {
3252 node.type = type;
3253 node.end = pos;
3254 if (this.options.locations) {
3255 node.loc.end = loc;
3256 }
3257 if (this.options.ranges) {
3258 node.range[1] = pos;
3259 }
3260 return node;
3261}
3262pp$2.finishNode = function(node, type) {
3263 return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc);
3264};
3265pp$2.finishNodeAt = function(node, type, pos, loc) {
3266 return finishNodeAt.call(this, node, type, pos, loc);
3267};
3268pp$2.copyNode = function(node) {
3269 var newNode = new Node(this, node.start, this.startLoc);
3270 for (var prop in node) {
3271 newNode[prop] = node[prop];
3272 }
3273 return newNode;
3274};
3275var ecma9BinaryProperties = "ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS";
3276var ecma10BinaryProperties = ecma9BinaryProperties + " Extended_Pictographic";
3277var ecma11BinaryProperties = ecma10BinaryProperties;
3278var ecma12BinaryProperties = ecma11BinaryProperties + " EBase EComp EMod EPres ExtPict";
3279var ecma13BinaryProperties = ecma12BinaryProperties;
3280var unicodeBinaryProperties = {
3281 9: ecma9BinaryProperties,
3282 10: ecma10BinaryProperties,
3283 11: ecma11BinaryProperties,
3284 12: ecma12BinaryProperties,
3285 13: ecma13BinaryProperties
3286};
3287var unicodeGeneralCategoryValues = "Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu";
3288var ecma9ScriptValues = "Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb";
3289var ecma10ScriptValues = ecma9ScriptValues + " Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd";
3290var ecma11ScriptValues = ecma10ScriptValues + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho";
3291var ecma12ScriptValues = ecma11ScriptValues + " Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi";
3292var ecma13ScriptValues = ecma12ScriptValues + " Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith";
3293var unicodeScriptValues = {
3294 9: ecma9ScriptValues,
3295 10: ecma10ScriptValues,
3296 11: ecma11ScriptValues,
3297 12: ecma12ScriptValues,
3298 13: ecma13ScriptValues
3299};
3300var data = {};
3301function buildUnicodeData(ecmaVersion) {
3302 var d = data[ecmaVersion] = {
3303 binary: wordsRegexp(unicodeBinaryProperties[ecmaVersion] + " " + unicodeGeneralCategoryValues),
3304 nonBinary: {
3305 General_Category: wordsRegexp(unicodeGeneralCategoryValues),
3306 Script: wordsRegexp(unicodeScriptValues[ecmaVersion])
3307 }
3308 };
3309 d.nonBinary.Script_Extensions = d.nonBinary.Script;
3310 d.nonBinary.gc = d.nonBinary.General_Category;
3311 d.nonBinary.sc = d.nonBinary.Script;
3312 d.nonBinary.scx = d.nonBinary.Script_Extensions;
3313}
3314for (var i = 0, list = [9, 10, 11, 12, 13]; i < list.length; i += 1) {
3315 var ecmaVersion = list[i];
3316 buildUnicodeData(ecmaVersion);
3317}
3318var pp$1 = Parser.prototype;
3319var RegExpValidationState = function RegExpValidationState2(parser) {
3320 this.parser = parser;
3321 this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "") + (parser.options.ecmaVersion >= 13 ? "d" : "");
3322 this.unicodeProperties = data[parser.options.ecmaVersion >= 13 ? 13 : parser.options.ecmaVersion];
3323 this.source = "";
3324 this.flags = "";
3325 this.start = 0;
3326 this.switchU = false;
3327 this.switchN = false;
3328 this.pos = 0;
3329 this.lastIntValue = 0;
3330 this.lastStringValue = "";
3331 this.lastAssertionIsQuantifiable = false;
3332 this.numCapturingParens = 0;
3333 this.maxBackReference = 0;
3334 this.groupNames = [];
3335 this.backReferenceNames = [];
3336};
3337RegExpValidationState.prototype.reset = function reset(start, pattern, flags) {
3338 var unicode = flags.indexOf("u") !== -1;
3339 this.start = start | 0;
3340 this.source = pattern + "";
3341 this.flags = flags;
3342 this.switchU = unicode && this.parser.options.ecmaVersion >= 6;
3343 this.switchN = unicode && this.parser.options.ecmaVersion >= 9;
3344};
3345RegExpValidationState.prototype.raise = function raise(message) {
3346 this.parser.raiseRecoverable(this.start, "Invalid regular expression: /" + this.source + "/: " + message);
3347};
3348RegExpValidationState.prototype.at = function at(i, forceU) {
3349 if (forceU === void 0)
3350 forceU = false;
3351 var s = this.source;
3352 var l = s.length;
3353 if (i >= l) {
3354 return -1;
3355 }
3356 var c = s.charCodeAt(i);
3357 if (!(forceU || this.switchU) || c <= 55295 || c >= 57344 || i + 1 >= l) {
3358 return c;
3359 }
3360 var next = s.charCodeAt(i + 1);
3361 return next >= 56320 && next <= 57343 ? (c << 10) + next - 56613888 : c;
3362};
3363RegExpValidationState.prototype.nextIndex = function nextIndex(i, forceU) {
3364 if (forceU === void 0)
3365 forceU = false;
3366 var s = this.source;
3367 var l = s.length;
3368 if (i >= l) {
3369 return l;
3370 }
3371 var c = s.charCodeAt(i), next;
3372 if (!(forceU || this.switchU) || c <= 55295 || c >= 57344 || i + 1 >= l || (next = s.charCodeAt(i + 1)) < 56320 || next > 57343) {
3373 return i + 1;
3374 }
3375 return i + 2;
3376};
3377RegExpValidationState.prototype.current = function current(forceU) {
3378 if (forceU === void 0)
3379 forceU = false;
3380 return this.at(this.pos, forceU);
3381};
3382RegExpValidationState.prototype.lookahead = function lookahead(forceU) {
3383 if (forceU === void 0)
3384 forceU = false;
3385 return this.at(this.nextIndex(this.pos, forceU), forceU);
3386};
3387RegExpValidationState.prototype.advance = function advance(forceU) {
3388 if (forceU === void 0)
3389 forceU = false;
3390 this.pos = this.nextIndex(this.pos, forceU);
3391};
3392RegExpValidationState.prototype.eat = function eat(ch, forceU) {
3393 if (forceU === void 0)
3394 forceU = false;
3395 if (this.current(forceU) === ch) {
3396 this.advance(forceU);
3397 return true;
3398 }
3399 return false;
3400};
3401pp$1.validateRegExpFlags = function(state) {
3402 var validFlags = state.validFlags;
3403 var flags = state.flags;
3404 for (var i = 0; i < flags.length; i++) {
3405 var flag = flags.charAt(i);
3406 if (validFlags.indexOf(flag) === -1) {
3407 this.raise(state.start, "Invalid regular expression flag");
3408 }
3409 if (flags.indexOf(flag, i + 1) > -1) {
3410 this.raise(state.start, "Duplicate regular expression flag");
3411 }
3412 }
3413};
3414pp$1.validateRegExpPattern = function(state) {
3415 this.regexp_pattern(state);
3416 if (!state.switchN && this.options.ecmaVersion >= 9 && state.groupNames.length > 0) {
3417 state.switchN = true;
3418 this.regexp_pattern(state);
3419 }
3420};
3421pp$1.regexp_pattern = function(state) {
3422 state.pos = 0;
3423 state.lastIntValue = 0;
3424 state.lastStringValue = "";
3425 state.lastAssertionIsQuantifiable = false;
3426 state.numCapturingParens = 0;
3427 state.maxBackReference = 0;
3428 state.groupNames.length = 0;
3429 state.backReferenceNames.length = 0;
3430 this.regexp_disjunction(state);
3431 if (state.pos !== state.source.length) {
3432 if (state.eat(41)) {
3433 state.raise("Unmatched ')'");
3434 }
3435 if (state.eat(93) || state.eat(125)) {
3436 state.raise("Lone quantifier brackets");
3437 }
3438 }
3439 if (state.maxBackReference > state.numCapturingParens) {
3440 state.raise("Invalid escape");
3441 }
3442 for (var i = 0, list = state.backReferenceNames; i < list.length; i += 1) {
3443 var name = list[i];
3444 if (state.groupNames.indexOf(name) === -1) {
3445 state.raise("Invalid named capture referenced");
3446 }
3447 }
3448};
3449pp$1.regexp_disjunction = function(state) {
3450 this.regexp_alternative(state);
3451 while (state.eat(124)) {
3452 this.regexp_alternative(state);
3453 }
3454 if (this.regexp_eatQuantifier(state, true)) {
3455 state.raise("Nothing to repeat");
3456 }
3457 if (state.eat(123)) {
3458 state.raise("Lone quantifier brackets");
3459 }
3460};
3461pp$1.regexp_alternative = function(state) {
3462 while (state.pos < state.source.length && this.regexp_eatTerm(state)) {
3463 }
3464};
3465pp$1.regexp_eatTerm = function(state) {
3466 if (this.regexp_eatAssertion(state)) {
3467 if (state.lastAssertionIsQuantifiable && this.regexp_eatQuantifier(state)) {
3468 if (state.switchU) {
3469 state.raise("Invalid quantifier");
3470 }
3471 }
3472 return true;
3473 }
3474 if (state.switchU ? this.regexp_eatAtom(state) : this.regexp_eatExtendedAtom(state)) {
3475 this.regexp_eatQuantifier(state);
3476 return true;
3477 }
3478 return false;
3479};
3480pp$1.regexp_eatAssertion = function(state) {
3481 var start = state.pos;
3482 state.lastAssertionIsQuantifiable = false;
3483 if (state.eat(94) || state.eat(36)) {
3484 return true;
3485 }
3486 if (state.eat(92)) {
3487 if (state.eat(66) || state.eat(98)) {
3488 return true;
3489 }
3490 state.pos = start;
3491 }
3492 if (state.eat(40) && state.eat(63)) {
3493 var lookbehind = false;
3494 if (this.options.ecmaVersion >= 9) {
3495 lookbehind = state.eat(60);
3496 }
3497 if (state.eat(61) || state.eat(33)) {
3498 this.regexp_disjunction(state);
3499 if (!state.eat(41)) {
3500 state.raise("Unterminated group");
3501 }
3502 state.lastAssertionIsQuantifiable = !lookbehind;
3503 return true;
3504 }
3505 }
3506 state.pos = start;
3507 return false;
3508};
3509pp$1.regexp_eatQuantifier = function(state, noError) {
3510 if (noError === void 0)
3511 noError = false;
3512 if (this.regexp_eatQuantifierPrefix(state, noError)) {
3513 state.eat(63);
3514 return true;
3515 }
3516 return false;
3517};
3518pp$1.regexp_eatQuantifierPrefix = function(state, noError) {
3519 return state.eat(42) || state.eat(43) || state.eat(63) || this.regexp_eatBracedQuantifier(state, noError);
3520};
3521pp$1.regexp_eatBracedQuantifier = function(state, noError) {
3522 var start = state.pos;
3523 if (state.eat(123)) {
3524 var min = 0, max = -1;
3525 if (this.regexp_eatDecimalDigits(state)) {
3526 min = state.lastIntValue;
3527 if (state.eat(44) && this.regexp_eatDecimalDigits(state)) {
3528 max = state.lastIntValue;
3529 }
3530 if (state.eat(125)) {
3531 if (max !== -1 && max < min && !noError) {
3532 state.raise("numbers out of order in {} quantifier");
3533 }
3534 return true;
3535 }
3536 }
3537 if (state.switchU && !noError) {
3538 state.raise("Incomplete quantifier");
3539 }
3540 state.pos = start;
3541 }
3542 return false;
3543};
3544pp$1.regexp_eatAtom = function(state) {
3545 return this.regexp_eatPatternCharacters(state) || state.eat(46) || this.regexp_eatReverseSolidusAtomEscape(state) || this.regexp_eatCharacterClass(state) || this.regexp_eatUncapturingGroup(state) || this.regexp_eatCapturingGroup(state);
3546};
3547pp$1.regexp_eatReverseSolidusAtomEscape = function(state) {
3548 var start = state.pos;
3549 if (state.eat(92)) {
3550 if (this.regexp_eatAtomEscape(state)) {
3551 return true;
3552 }
3553 state.pos = start;
3554 }
3555 return false;
3556};
3557pp$1.regexp_eatUncapturingGroup = function(state) {
3558 var start = state.pos;
3559 if (state.eat(40)) {
3560 if (state.eat(63) && state.eat(58)) {
3561 this.regexp_disjunction(state);
3562 if (state.eat(41)) {
3563 return true;
3564 }
3565 state.raise("Unterminated group");
3566 }
3567 state.pos = start;
3568 }
3569 return false;
3570};
3571pp$1.regexp_eatCapturingGroup = function(state) {
3572 if (state.eat(40)) {
3573 if (this.options.ecmaVersion >= 9) {
3574 this.regexp_groupSpecifier(state);
3575 } else if (state.current() === 63) {
3576 state.raise("Invalid group");
3577 }
3578 this.regexp_disjunction(state);
3579 if (state.eat(41)) {
3580 state.numCapturingParens += 1;
3581 return true;
3582 }
3583 state.raise("Unterminated group");
3584 }
3585 return false;
3586};
3587pp$1.regexp_eatExtendedAtom = function(state) {
3588 return state.eat(46) || this.regexp_eatReverseSolidusAtomEscape(state) || this.regexp_eatCharacterClass(state) || this.regexp_eatUncapturingGroup(state) || this.regexp_eatCapturingGroup(state) || this.regexp_eatInvalidBracedQuantifier(state) || this.regexp_eatExtendedPatternCharacter(state);
3589};
3590pp$1.regexp_eatInvalidBracedQuantifier = function(state) {
3591 if (this.regexp_eatBracedQuantifier(state, true)) {
3592 state.raise("Nothing to repeat");
3593 }
3594 return false;
3595};
3596pp$1.regexp_eatSyntaxCharacter = function(state) {
3597 var ch = state.current();
3598 if (isSyntaxCharacter(ch)) {
3599 state.lastIntValue = ch;
3600 state.advance();
3601 return true;
3602 }
3603 return false;
3604};
3605function isSyntaxCharacter(ch) {
3606 return ch === 36 || ch >= 40 && ch <= 43 || ch === 46 || ch === 63 || ch >= 91 && ch <= 94 || ch >= 123 && ch <= 125;
3607}
3608pp$1.regexp_eatPatternCharacters = function(state) {
3609 var start = state.pos;
3610 var ch = 0;
3611 while ((ch = state.current()) !== -1 && !isSyntaxCharacter(ch)) {
3612 state.advance();
3613 }
3614 return state.pos !== start;
3615};
3616pp$1.regexp_eatExtendedPatternCharacter = function(state) {
3617 var ch = state.current();
3618 if (ch !== -1 && ch !== 36 && !(ch >= 40 && ch <= 43) && ch !== 46 && ch !== 63 && ch !== 91 && ch !== 94 && ch !== 124) {
3619 state.advance();
3620 return true;
3621 }
3622 return false;
3623};
3624pp$1.regexp_groupSpecifier = function(state) {
3625 if (state.eat(63)) {
3626 if (this.regexp_eatGroupName(state)) {
3627 if (state.groupNames.indexOf(state.lastStringValue) !== -1) {
3628 state.raise("Duplicate capture group name");
3629 }
3630 state.groupNames.push(state.lastStringValue);
3631 return;
3632 }
3633 state.raise("Invalid group");
3634 }
3635};
3636pp$1.regexp_eatGroupName = function(state) {
3637 state.lastStringValue = "";
3638 if (state.eat(60)) {
3639 if (this.regexp_eatRegExpIdentifierName(state) && state.eat(62)) {
3640 return true;
3641 }
3642 state.raise("Invalid capture group name");
3643 }
3644 return false;
3645};
3646pp$1.regexp_eatRegExpIdentifierName = function(state) {
3647 state.lastStringValue = "";
3648 if (this.regexp_eatRegExpIdentifierStart(state)) {
3649 state.lastStringValue += codePointToString(state.lastIntValue);
3650 while (this.regexp_eatRegExpIdentifierPart(state)) {
3651 state.lastStringValue += codePointToString(state.lastIntValue);
3652 }
3653 return true;
3654 }
3655 return false;
3656};
3657pp$1.regexp_eatRegExpIdentifierStart = function(state) {
3658 var start = state.pos;
3659 var forceU = this.options.ecmaVersion >= 11;
3660 var ch = state.current(forceU);
3661 state.advance(forceU);
3662 if (ch === 92 && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {
3663 ch = state.lastIntValue;
3664 }
3665 if (isRegExpIdentifierStart(ch)) {
3666 state.lastIntValue = ch;
3667 return true;
3668 }
3669 state.pos = start;
3670 return false;
3671};
3672function isRegExpIdentifierStart(ch) {
3673 return isIdentifierStart(ch, true) || ch === 36 || ch === 95;
3674}
3675pp$1.regexp_eatRegExpIdentifierPart = function(state) {
3676 var start = state.pos;
3677 var forceU = this.options.ecmaVersion >= 11;
3678 var ch = state.current(forceU);
3679 state.advance(forceU);
3680 if (ch === 92 && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {
3681 ch = state.lastIntValue;
3682 }
3683 if (isRegExpIdentifierPart(ch)) {
3684 state.lastIntValue = ch;
3685 return true;
3686 }
3687 state.pos = start;
3688 return false;
3689};
3690function isRegExpIdentifierPart(ch) {
3691 return isIdentifierChar(ch, true) || ch === 36 || ch === 95 || ch === 8204 || ch === 8205;
3692}
3693pp$1.regexp_eatAtomEscape = function(state) {
3694 if (this.regexp_eatBackReference(state) || this.regexp_eatCharacterClassEscape(state) || this.regexp_eatCharacterEscape(state) || state.switchN && this.regexp_eatKGroupName(state)) {
3695 return true;
3696 }
3697 if (state.switchU) {
3698 if (state.current() === 99) {
3699 state.raise("Invalid unicode escape");
3700 }
3701 state.raise("Invalid escape");
3702 }
3703 return false;
3704};
3705pp$1.regexp_eatBackReference = function(state) {
3706 var start = state.pos;
3707 if (this.regexp_eatDecimalEscape(state)) {
3708 var n = state.lastIntValue;
3709 if (state.switchU) {
3710 if (n > state.maxBackReference) {
3711 state.maxBackReference = n;
3712 }
3713 return true;
3714 }
3715 if (n <= state.numCapturingParens) {
3716 return true;
3717 }
3718 state.pos = start;
3719 }
3720 return false;
3721};
3722pp$1.regexp_eatKGroupName = function(state) {
3723 if (state.eat(107)) {
3724 if (this.regexp_eatGroupName(state)) {
3725 state.backReferenceNames.push(state.lastStringValue);
3726 return true;
3727 }
3728 state.raise("Invalid named reference");
3729 }
3730 return false;
3731};
3732pp$1.regexp_eatCharacterEscape = function(state) {
3733 return this.regexp_eatControlEscape(state) || this.regexp_eatCControlLetter(state) || this.regexp_eatZero(state) || this.regexp_eatHexEscapeSequence(state) || this.regexp_eatRegExpUnicodeEscapeSequence(state, false) || !state.switchU && this.regexp_eatLegacyOctalEscapeSequence(state) || this.regexp_eatIdentityEscape(state);
3734};
3735pp$1.regexp_eatCControlLetter = function(state) {
3736 var start = state.pos;
3737 if (state.eat(99)) {
3738 if (this.regexp_eatControlLetter(state)) {
3739 return true;
3740 }
3741 state.pos = start;
3742 }
3743 return false;
3744};
3745pp$1.regexp_eatZero = function(state) {
3746 if (state.current() === 48 && !isDecimalDigit(state.lookahead())) {
3747 state.lastIntValue = 0;
3748 state.advance();
3749 return true;
3750 }
3751 return false;
3752};
3753pp$1.regexp_eatControlEscape = function(state) {
3754 var ch = state.current();
3755 if (ch === 116) {
3756 state.lastIntValue = 9;
3757 state.advance();
3758 return true;
3759 }
3760 if (ch === 110) {
3761 state.lastIntValue = 10;
3762 state.advance();
3763 return true;
3764 }
3765 if (ch === 118) {
3766 state.lastIntValue = 11;
3767 state.advance();
3768 return true;
3769 }
3770 if (ch === 102) {
3771 state.lastIntValue = 12;
3772 state.advance();
3773 return true;
3774 }
3775 if (ch === 114) {
3776 state.lastIntValue = 13;
3777 state.advance();
3778 return true;
3779 }
3780 return false;
3781};
3782pp$1.regexp_eatControlLetter = function(state) {
3783 var ch = state.current();
3784 if (isControlLetter(ch)) {
3785 state.lastIntValue = ch % 32;
3786 state.advance();
3787 return true;
3788 }
3789 return false;
3790};
3791function isControlLetter(ch) {
3792 return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122;
3793}
3794pp$1.regexp_eatRegExpUnicodeEscapeSequence = function(state, forceU) {
3795 if (forceU === void 0)
3796 forceU = false;
3797 var start = state.pos;
3798 var switchU = forceU || state.switchU;
3799 if (state.eat(117)) {
3800 if (this.regexp_eatFixedHexDigits(state, 4)) {
3801 var lead = state.lastIntValue;
3802 if (switchU && lead >= 55296 && lead <= 56319) {
3803 var leadSurrogateEnd = state.pos;
3804 if (state.eat(92) && state.eat(117) && this.regexp_eatFixedHexDigits(state, 4)) {
3805 var trail = state.lastIntValue;
3806 if (trail >= 56320 && trail <= 57343) {
3807 state.lastIntValue = (lead - 55296) * 1024 + (trail - 56320) + 65536;
3808 return true;
3809 }
3810 }
3811 state.pos = leadSurrogateEnd;
3812 state.lastIntValue = lead;
3813 }
3814 return true;
3815 }
3816 if (switchU && state.eat(123) && this.regexp_eatHexDigits(state) && state.eat(125) && isValidUnicode(state.lastIntValue)) {
3817 return true;
3818 }
3819 if (switchU) {
3820 state.raise("Invalid unicode escape");
3821 }
3822 state.pos = start;
3823 }
3824 return false;
3825};
3826function isValidUnicode(ch) {
3827 return ch >= 0 && ch <= 1114111;
3828}
3829pp$1.regexp_eatIdentityEscape = function(state) {
3830 if (state.switchU) {
3831 if (this.regexp_eatSyntaxCharacter(state)) {
3832 return true;
3833 }
3834 if (state.eat(47)) {
3835 state.lastIntValue = 47;
3836 return true;
3837 }
3838 return false;
3839 }
3840 var ch = state.current();
3841 if (ch !== 99 && (!state.switchN || ch !== 107)) {
3842 state.lastIntValue = ch;
3843 state.advance();
3844 return true;
3845 }
3846 return false;
3847};
3848pp$1.regexp_eatDecimalEscape = function(state) {
3849 state.lastIntValue = 0;
3850 var ch = state.current();
3851 if (ch >= 49 && ch <= 57) {
3852 do {
3853 state.lastIntValue = 10 * state.lastIntValue + (ch - 48);
3854 state.advance();
3855 } while ((ch = state.current()) >= 48 && ch <= 57);
3856 return true;
3857 }
3858 return false;
3859};
3860pp$1.regexp_eatCharacterClassEscape = function(state) {
3861 var ch = state.current();
3862 if (isCharacterClassEscape(ch)) {
3863 state.lastIntValue = -1;
3864 state.advance();
3865 return true;
3866 }
3867 if (state.switchU && this.options.ecmaVersion >= 9 && (ch === 80 || ch === 112)) {
3868 state.lastIntValue = -1;
3869 state.advance();
3870 if (state.eat(123) && this.regexp_eatUnicodePropertyValueExpression(state) && state.eat(125)) {
3871 return true;
3872 }
3873 state.raise("Invalid property name");
3874 }
3875 return false;
3876};
3877function isCharacterClassEscape(ch) {
3878 return ch === 100 || ch === 68 || ch === 115 || ch === 83 || ch === 119 || ch === 87;
3879}
3880pp$1.regexp_eatUnicodePropertyValueExpression = function(state) {
3881 var start = state.pos;
3882 if (this.regexp_eatUnicodePropertyName(state) && state.eat(61)) {
3883 var name = state.lastStringValue;
3884 if (this.regexp_eatUnicodePropertyValue(state)) {
3885 var value = state.lastStringValue;
3886 this.regexp_validateUnicodePropertyNameAndValue(state, name, value);
3887 return true;
3888 }
3889 }
3890 state.pos = start;
3891 if (this.regexp_eatLoneUnicodePropertyNameOrValue(state)) {
3892 var nameOrValue = state.lastStringValue;
3893 this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue);
3894 return true;
3895 }
3896 return false;
3897};
3898pp$1.regexp_validateUnicodePropertyNameAndValue = function(state, name, value) {
3899 if (!hasOwn(state.unicodeProperties.nonBinary, name)) {
3900 state.raise("Invalid property name");
3901 }
3902 if (!state.unicodeProperties.nonBinary[name].test(value)) {
3903 state.raise("Invalid property value");
3904 }
3905};
3906pp$1.regexp_validateUnicodePropertyNameOrValue = function(state, nameOrValue) {
3907 if (!state.unicodeProperties.binary.test(nameOrValue)) {
3908 state.raise("Invalid property name");
3909 }
3910};
3911pp$1.regexp_eatUnicodePropertyName = function(state) {
3912 var ch = 0;
3913 state.lastStringValue = "";
3914 while (isUnicodePropertyNameCharacter(ch = state.current())) {
3915 state.lastStringValue += codePointToString(ch);
3916 state.advance();
3917 }
3918 return state.lastStringValue !== "";
3919};
3920function isUnicodePropertyNameCharacter(ch) {
3921 return isControlLetter(ch) || ch === 95;
3922}
3923pp$1.regexp_eatUnicodePropertyValue = function(state) {
3924 var ch = 0;
3925 state.lastStringValue = "";
3926 while (isUnicodePropertyValueCharacter(ch = state.current())) {
3927 state.lastStringValue += codePointToString(ch);
3928 state.advance();
3929 }
3930 return state.lastStringValue !== "";
3931};
3932function isUnicodePropertyValueCharacter(ch) {
3933 return isUnicodePropertyNameCharacter(ch) || isDecimalDigit(ch);
3934}
3935pp$1.regexp_eatLoneUnicodePropertyNameOrValue = function(state) {
3936 return this.regexp_eatUnicodePropertyValue(state);
3937};
3938pp$1.regexp_eatCharacterClass = function(state) {
3939 if (state.eat(91)) {
3940 state.eat(94);
3941 this.regexp_classRanges(state);
3942 if (state.eat(93)) {
3943 return true;
3944 }
3945 state.raise("Unterminated character class");
3946 }
3947 return false;
3948};
3949pp$1.regexp_classRanges = function(state) {
3950 while (this.regexp_eatClassAtom(state)) {
3951 var left = state.lastIntValue;
3952 if (state.eat(45) && this.regexp_eatClassAtom(state)) {
3953 var right = state.lastIntValue;
3954 if (state.switchU && (left === -1 || right === -1)) {
3955 state.raise("Invalid character class");
3956 }
3957 if (left !== -1 && right !== -1 && left > right) {
3958 state.raise("Range out of order in character class");
3959 }
3960 }
3961 }
3962};
3963pp$1.regexp_eatClassAtom = function(state) {
3964 var start = state.pos;
3965 if (state.eat(92)) {
3966 if (this.regexp_eatClassEscape(state)) {
3967 return true;
3968 }
3969 if (state.switchU) {
3970 var ch$1 = state.current();
3971 if (ch$1 === 99 || isOctalDigit(ch$1)) {
3972 state.raise("Invalid class escape");
3973 }
3974 state.raise("Invalid escape");
3975 }
3976 state.pos = start;
3977 }
3978 var ch = state.current();
3979 if (ch !== 93) {
3980 state.lastIntValue = ch;
3981 state.advance();
3982 return true;
3983 }
3984 return false;
3985};
3986pp$1.regexp_eatClassEscape = function(state) {
3987 var start = state.pos;
3988 if (state.eat(98)) {
3989 state.lastIntValue = 8;
3990 return true;
3991 }
3992 if (state.switchU && state.eat(45)) {
3993 state.lastIntValue = 45;
3994 return true;
3995 }
3996 if (!state.switchU && state.eat(99)) {
3997 if (this.regexp_eatClassControlLetter(state)) {
3998 return true;
3999 }
4000 state.pos = start;
4001 }
4002 return this.regexp_eatCharacterClassEscape(state) || this.regexp_eatCharacterEscape(state);
4003};
4004pp$1.regexp_eatClassControlLetter = function(state) {
4005 var ch = state.current();
4006 if (isDecimalDigit(ch) || ch === 95) {
4007 state.lastIntValue = ch % 32;
4008 state.advance();
4009 return true;
4010 }
4011 return false;
4012};
4013pp$1.regexp_eatHexEscapeSequence = function(state) {
4014 var start = state.pos;
4015 if (state.eat(120)) {
4016 if (this.regexp_eatFixedHexDigits(state, 2)) {
4017 return true;
4018 }
4019 if (state.switchU) {
4020 state.raise("Invalid escape");
4021 }
4022 state.pos = start;
4023 }
4024 return false;
4025};
4026pp$1.regexp_eatDecimalDigits = function(state) {
4027 var start = state.pos;
4028 var ch = 0;
4029 state.lastIntValue = 0;
4030 while (isDecimalDigit(ch = state.current())) {
4031 state.lastIntValue = 10 * state.lastIntValue + (ch - 48);
4032 state.advance();
4033 }
4034 return state.pos !== start;
4035};
4036function isDecimalDigit(ch) {
4037 return ch >= 48 && ch <= 57;
4038}
4039pp$1.regexp_eatHexDigits = function(state) {
4040 var start = state.pos;
4041 var ch = 0;
4042 state.lastIntValue = 0;
4043 while (isHexDigit(ch = state.current())) {
4044 state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
4045 state.advance();
4046 }
4047 return state.pos !== start;
4048};
4049function isHexDigit(ch) {
4050 return ch >= 48 && ch <= 57 || ch >= 65 && ch <= 70 || ch >= 97 && ch <= 102;
4051}
4052function hexToInt(ch) {
4053 if (ch >= 65 && ch <= 70) {
4054 return 10 + (ch - 65);
4055 }
4056 if (ch >= 97 && ch <= 102) {
4057 return 10 + (ch - 97);
4058 }
4059 return ch - 48;
4060}
4061pp$1.regexp_eatLegacyOctalEscapeSequence = function(state) {
4062 if (this.regexp_eatOctalDigit(state)) {
4063 var n1 = state.lastIntValue;
4064 if (this.regexp_eatOctalDigit(state)) {
4065 var n2 = state.lastIntValue;
4066 if (n1 <= 3 && this.regexp_eatOctalDigit(state)) {
4067 state.lastIntValue = n1 * 64 + n2 * 8 + state.lastIntValue;
4068 } else {
4069 state.lastIntValue = n1 * 8 + n2;
4070 }
4071 } else {
4072 state.lastIntValue = n1;
4073 }
4074 return true;
4075 }
4076 return false;
4077};
4078pp$1.regexp_eatOctalDigit = function(state) {
4079 var ch = state.current();
4080 if (isOctalDigit(ch)) {
4081 state.lastIntValue = ch - 48;
4082 state.advance();
4083 return true;
4084 }
4085 state.lastIntValue = 0;
4086 return false;
4087};
4088function isOctalDigit(ch) {
4089 return ch >= 48 && ch <= 55;
4090}
4091pp$1.regexp_eatFixedHexDigits = function(state, length) {
4092 var start = state.pos;
4093 state.lastIntValue = 0;
4094 for (var i = 0; i < length; ++i) {
4095 var ch = state.current();
4096 if (!isHexDigit(ch)) {
4097 state.pos = start;
4098 return false;
4099 }
4100 state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
4101 state.advance();
4102 }
4103 return true;
4104};
4105var Token = function Token2(p) {
4106 this.type = p.type;
4107 this.value = p.value;
4108 this.start = p.start;
4109 this.end = p.end;
4110 if (p.options.locations) {
4111 this.loc = new SourceLocation(p, p.startLoc, p.endLoc);
4112 }
4113 if (p.options.ranges) {
4114 this.range = [p.start, p.end];
4115 }
4116};
4117var pp = Parser.prototype;
4118pp.next = function(ignoreEscapeSequenceInKeyword) {
4119 if (!ignoreEscapeSequenceInKeyword && this.type.keyword && this.containsEsc) {
4120 this.raiseRecoverable(this.start, "Escape sequence in keyword " + this.type.keyword);
4121 }
4122 if (this.options.onToken) {
4123 this.options.onToken(new Token(this));
4124 }
4125 this.lastTokEnd = this.end;
4126 this.lastTokStart = this.start;
4127 this.lastTokEndLoc = this.endLoc;
4128 this.lastTokStartLoc = this.startLoc;
4129 this.nextToken();
4130};
4131pp.getToken = function() {
4132 this.next();
4133 return new Token(this);
4134};
4135if (typeof Symbol !== "undefined") {
4136 pp[Symbol.iterator] = function() {
4137 var this$1$1 = this;
4138 return {
4139 next: function() {
4140 var token = this$1$1.getToken();
4141 return {
4142 done: token.type === types$1.eof,
4143 value: token
4144 };
4145 }
4146 };
4147 };
4148}
4149pp.nextToken = function() {
4150 var curContext = this.curContext();
4151 if (!curContext || !curContext.preserveSpace) {
4152 this.skipSpace();
4153 }
4154 this.start = this.pos;
4155 if (this.options.locations) {
4156 this.startLoc = this.curPosition();
4157 }
4158 if (this.pos >= this.input.length) {
4159 return this.finishToken(types$1.eof);
4160 }
4161 if (curContext.override) {
4162 return curContext.override(this);
4163 } else {
4164 this.readToken(this.fullCharCodeAtPos());
4165 }
4166};
4167pp.readToken = function(code) {
4168 if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92) {
4169 return this.readWord();
4170 }
4171 return this.getTokenFromCode(code);
4172};
4173pp.fullCharCodeAtPos = function() {
4174 var code = this.input.charCodeAt(this.pos);
4175 if (code <= 55295 || code >= 56320) {
4176 return code;
4177 }
4178 var next = this.input.charCodeAt(this.pos + 1);
4179 return next <= 56319 || next >= 57344 ? code : (code << 10) + next - 56613888;
4180};
4181pp.skipBlockComment = function() {
4182 var startLoc = this.options.onComment && this.curPosition();
4183 var start = this.pos, end = this.input.indexOf("*/", this.pos += 2);
4184 if (end === -1) {
4185 this.raise(this.pos - 2, "Unterminated comment");
4186 }
4187 this.pos = end + 2;
4188 if (this.options.locations) {
4189 for (var nextBreak = void 0, pos = start; (nextBreak = nextLineBreak(this.input, pos, this.pos)) > -1; ) {
4190 ++this.curLine;
4191 pos = this.lineStart = nextBreak;
4192 }
4193 }
4194 if (this.options.onComment) {
4195 this.options.onComment(
4196 true,
4197 this.input.slice(start + 2, end),
4198 start,
4199 this.pos,
4200 startLoc,
4201 this.curPosition()
4202 );
4203 }
4204};
4205pp.skipLineComment = function(startSkip) {
4206 var start = this.pos;
4207 var startLoc = this.options.onComment && this.curPosition();
4208 var ch = this.input.charCodeAt(this.pos += startSkip);
4209 while (this.pos < this.input.length && !isNewLine(ch)) {
4210 ch = this.input.charCodeAt(++this.pos);
4211 }
4212 if (this.options.onComment) {
4213 this.options.onComment(
4214 false,
4215 this.input.slice(start + startSkip, this.pos),
4216 start,
4217 this.pos,
4218 startLoc,
4219 this.curPosition()
4220 );
4221 }
4222};
4223pp.skipSpace = function() {
4224 loop:
4225 while (this.pos < this.input.length) {
4226 var ch = this.input.charCodeAt(this.pos);
4227 switch (ch) {
4228 case 32:
4229 case 160:
4230 ++this.pos;
4231 break;
4232 case 13:
4233 if (this.input.charCodeAt(this.pos + 1) === 10) {
4234 ++this.pos;
4235 }
4236 case 10:
4237 case 8232:
4238 case 8233:
4239 ++this.pos;
4240 if (this.options.locations) {
4241 ++this.curLine;
4242 this.lineStart = this.pos;
4243 }
4244 break;
4245 case 47:
4246 switch (this.input.charCodeAt(this.pos + 1)) {
4247 case 42:
4248 this.skipBlockComment();
4249 break;
4250 case 47:
4251 this.skipLineComment(2);
4252 break;
4253 default:
4254 break loop;
4255 }
4256 break;
4257 default:
4258 if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {
4259 ++this.pos;
4260 } else {
4261 break loop;
4262 }
4263 }
4264 }
4265};
4266pp.finishToken = function(type, val) {
4267 this.end = this.pos;
4268 if (this.options.locations) {
4269 this.endLoc = this.curPosition();
4270 }
4271 var prevType = this.type;
4272 this.type = type;
4273 this.value = val;
4274 this.updateContext(prevType);
4275};
4276pp.readToken_dot = function() {
4277 var next = this.input.charCodeAt(this.pos + 1);
4278 if (next >= 48 && next <= 57) {
4279 return this.readNumber(true);
4280 }
4281 var next2 = this.input.charCodeAt(this.pos + 2);
4282 if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) {
4283 this.pos += 3;
4284 return this.finishToken(types$1.ellipsis);
4285 } else {
4286 ++this.pos;
4287 return this.finishToken(types$1.dot);
4288 }
4289};
4290pp.readToken_slash = function() {
4291 var next = this.input.charCodeAt(this.pos + 1);
4292 if (this.exprAllowed) {
4293 ++this.pos;
4294 return this.readRegexp();
4295 }
4296 if (next === 61) {
4297 return this.finishOp(types$1.assign, 2);
4298 }
4299 return this.finishOp(types$1.slash, 1);
4300};
4301pp.readToken_mult_modulo_exp = function(code) {
4302 var next = this.input.charCodeAt(this.pos + 1);
4303 var size = 1;
4304 var tokentype = code === 42 ? types$1.star : types$1.modulo;
4305 if (this.options.ecmaVersion >= 7 && code === 42 && next === 42) {
4306 ++size;
4307 tokentype = types$1.starstar;
4308 next = this.input.charCodeAt(this.pos + 2);
4309 }
4310 if (next === 61) {
4311 return this.finishOp(types$1.assign, size + 1);
4312 }
4313 return this.finishOp(tokentype, size);
4314};
4315pp.readToken_pipe_amp = function(code) {
4316 var next = this.input.charCodeAt(this.pos + 1);
4317 if (next === code) {
4318 if (this.options.ecmaVersion >= 12) {
4319 var next2 = this.input.charCodeAt(this.pos + 2);
4320 if (next2 === 61) {
4321 return this.finishOp(types$1.assign, 3);
4322 }
4323 }
4324 return this.finishOp(code === 124 ? types$1.logicalOR : types$1.logicalAND, 2);
4325 }
4326 if (next === 61) {
4327 return this.finishOp(types$1.assign, 2);
4328 }
4329 return this.finishOp(code === 124 ? types$1.bitwiseOR : types$1.bitwiseAND, 1);
4330};
4331pp.readToken_caret = function() {
4332 var next = this.input.charCodeAt(this.pos + 1);
4333 if (next === 61) {
4334 return this.finishOp(types$1.assign, 2);
4335 }
4336 return this.finishOp(types$1.bitwiseXOR, 1);
4337};
4338pp.readToken_plus_min = function(code) {
4339 var next = this.input.charCodeAt(this.pos + 1);
4340 if (next === code) {
4341 if (next === 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 62 && (this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) {
4342 this.skipLineComment(3);
4343 this.skipSpace();
4344 return this.nextToken();
4345 }
4346 return this.finishOp(types$1.incDec, 2);
4347 }
4348 if (next === 61) {
4349 return this.finishOp(types$1.assign, 2);
4350 }
4351 return this.finishOp(types$1.plusMin, 1);
4352};
4353pp.readToken_lt_gt = function(code) {
4354 var next = this.input.charCodeAt(this.pos + 1);
4355 var size = 1;
4356 if (next === code) {
4357 size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;
4358 if (this.input.charCodeAt(this.pos + size) === 61) {
4359 return this.finishOp(types$1.assign, size + 1);
4360 }
4361 return this.finishOp(types$1.bitShift, size);
4362 }
4363 if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 && this.input.charCodeAt(this.pos + 3) === 45) {
4364 this.skipLineComment(4);
4365 this.skipSpace();
4366 return this.nextToken();
4367 }
4368 if (next === 61) {
4369 size = 2;
4370 }
4371 return this.finishOp(types$1.relational, size);
4372};
4373pp.readToken_eq_excl = function(code) {
4374 var next = this.input.charCodeAt(this.pos + 1);
4375 if (next === 61) {
4376 return this.finishOp(types$1.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2);
4377 }
4378 if (code === 61 && next === 62 && this.options.ecmaVersion >= 6) {
4379 this.pos += 2;
4380 return this.finishToken(types$1.arrow);
4381 }
4382 return this.finishOp(code === 61 ? types$1.eq : types$1.prefix, 1);
4383};
4384pp.readToken_question = function() {
4385 var ecmaVersion = this.options.ecmaVersion;
4386 if (ecmaVersion >= 11) {
4387 var next = this.input.charCodeAt(this.pos + 1);
4388 if (next === 46) {
4389 var next2 = this.input.charCodeAt(this.pos + 2);
4390 if (next2 < 48 || next2 > 57) {
4391 return this.finishOp(types$1.questionDot, 2);
4392 }
4393 }
4394 if (next === 63) {
4395 if (ecmaVersion >= 12) {
4396 var next2$1 = this.input.charCodeAt(this.pos + 2);
4397 if (next2$1 === 61) {
4398 return this.finishOp(types$1.assign, 3);
4399 }
4400 }
4401 return this.finishOp(types$1.coalesce, 2);
4402 }
4403 }
4404 return this.finishOp(types$1.question, 1);
4405};
4406pp.readToken_numberSign = function() {
4407 var ecmaVersion = this.options.ecmaVersion;
4408 var code = 35;
4409 if (ecmaVersion >= 13) {
4410 ++this.pos;
4411 code = this.fullCharCodeAtPos();
4412 if (isIdentifierStart(code, true) || code === 92) {
4413 return this.finishToken(types$1.privateId, this.readWord1());
4414 }
4415 }
4416 this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");
4417};
4418pp.getTokenFromCode = function(code) {
4419 switch (code) {
4420 case 46:
4421 return this.readToken_dot();
4422 case 40:
4423 ++this.pos;
4424 return this.finishToken(types$1.parenL);
4425 case 41:
4426 ++this.pos;
4427 return this.finishToken(types$1.parenR);
4428 case 59:
4429 ++this.pos;
4430 return this.finishToken(types$1.semi);
4431 case 44:
4432 ++this.pos;
4433 return this.finishToken(types$1.comma);
4434 case 91:
4435 ++this.pos;
4436 return this.finishToken(types$1.bracketL);
4437 case 93:
4438 ++this.pos;
4439 return this.finishToken(types$1.bracketR);
4440 case 123:
4441 ++this.pos;
4442 return this.finishToken(types$1.braceL);
4443 case 125:
4444 ++this.pos;
4445 return this.finishToken(types$1.braceR);
4446 case 58:
4447 ++this.pos;
4448 return this.finishToken(types$1.colon);
4449 case 96:
4450 if (this.options.ecmaVersion < 6) {
4451 break;
4452 }
4453 ++this.pos;
4454 return this.finishToken(types$1.backQuote);
4455 case 48:
4456 var next = this.input.charCodeAt(this.pos + 1);
4457 if (next === 120 || next === 88) {
4458 return this.readRadixNumber(16);
4459 }
4460 if (this.options.ecmaVersion >= 6) {
4461 if (next === 111 || next === 79) {
4462 return this.readRadixNumber(8);
4463 }
4464 if (next === 98 || next === 66) {
4465 return this.readRadixNumber(2);
4466 }
4467 }
4468 case 49:
4469 case 50:
4470 case 51:
4471 case 52:
4472 case 53:
4473 case 54:
4474 case 55:
4475 case 56:
4476 case 57:
4477 return this.readNumber(false);
4478 case 34:
4479 case 39:
4480 return this.readString(code);
4481 case 47:
4482 return this.readToken_slash();
4483 case 37:
4484 case 42:
4485 return this.readToken_mult_modulo_exp(code);
4486 case 124:
4487 case 38:
4488 return this.readToken_pipe_amp(code);
4489 case 94:
4490 return this.readToken_caret();
4491 case 43:
4492 case 45:
4493 return this.readToken_plus_min(code);
4494 case 60:
4495 case 62:
4496 return this.readToken_lt_gt(code);
4497 case 61:
4498 case 33:
4499 return this.readToken_eq_excl(code);
4500 case 63:
4501 return this.readToken_question();
4502 case 126:
4503 return this.finishOp(types$1.prefix, 1);
4504 case 35:
4505 return this.readToken_numberSign();
4506 }
4507 this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'");
4508};
4509pp.finishOp = function(type, size) {
4510 var str = this.input.slice(this.pos, this.pos + size);
4511 this.pos += size;
4512 return this.finishToken(type, str);
4513};
4514pp.readRegexp = function() {
4515 var escaped, inClass, start = this.pos;
4516 for (; ; ) {
4517 if (this.pos >= this.input.length) {
4518 this.raise(start, "Unterminated regular expression");
4519 }
4520 var ch = this.input.charAt(this.pos);
4521 if (lineBreak.test(ch)) {
4522 this.raise(start, "Unterminated regular expression");
4523 }
4524 if (!escaped) {
4525 if (ch === "[") {
4526 inClass = true;
4527 } else if (ch === "]" && inClass) {
4528 inClass = false;
4529 } else if (ch === "/" && !inClass) {
4530 break;
4531 }
4532 escaped = ch === "\\";
4533 } else {
4534 escaped = false;
4535 }
4536 ++this.pos;
4537 }
4538 var pattern = this.input.slice(start, this.pos);
4539 ++this.pos;
4540 var flagsStart = this.pos;
4541 var flags = this.readWord1();
4542 if (this.containsEsc) {
4543 this.unexpected(flagsStart);
4544 }
4545 var state = this.regexpState || (this.regexpState = new RegExpValidationState(this));
4546 state.reset(start, pattern, flags);
4547 this.validateRegExpFlags(state);
4548 this.validateRegExpPattern(state);
4549 var value = null;
4550 try {
4551 value = new RegExp(pattern, flags);
4552 } catch (e) {
4553 }
4554 return this.finishToken(types$1.regexp, { pattern, flags, value });
4555};
4556pp.readInt = function(radix, len, maybeLegacyOctalNumericLiteral) {
4557 var allowSeparators = this.options.ecmaVersion >= 12 && len === void 0;
4558 var isLegacyOctalNumericLiteral = maybeLegacyOctalNumericLiteral && this.input.charCodeAt(this.pos) === 48;
4559 var start = this.pos, total = 0, lastCode = 0;
4560 for (var i = 0, e = len == null ? Infinity : len; i < e; ++i, ++this.pos) {
4561 var code = this.input.charCodeAt(this.pos), val = void 0;
4562 if (allowSeparators && code === 95) {
4563 if (isLegacyOctalNumericLiteral) {
4564 this.raiseRecoverable(this.pos, "Numeric separator is not allowed in legacy octal numeric literals");
4565 }
4566 if (lastCode === 95) {
4567 this.raiseRecoverable(this.pos, "Numeric separator must be exactly one underscore");
4568 }
4569 if (i === 0) {
4570 this.raiseRecoverable(this.pos, "Numeric separator is not allowed at the first of digits");
4571 }
4572 lastCode = code;
4573 continue;
4574 }
4575 if (code >= 97) {
4576 val = code - 97 + 10;
4577 } else if (code >= 65) {
4578 val = code - 65 + 10;
4579 } else if (code >= 48 && code <= 57) {
4580 val = code - 48;
4581 } else {
4582 val = Infinity;
4583 }
4584 if (val >= radix) {
4585 break;
4586 }
4587 lastCode = code;
4588 total = total * radix + val;
4589 }
4590 if (allowSeparators && lastCode === 95) {
4591 this.raiseRecoverable(this.pos - 1, "Numeric separator is not allowed at the last of digits");
4592 }
4593 if (this.pos === start || len != null && this.pos - start !== len) {
4594 return null;
4595 }
4596 return total;
4597};
4598function stringToNumber(str, isLegacyOctalNumericLiteral) {
4599 if (isLegacyOctalNumericLiteral) {
4600 return parseInt(str, 8);
4601 }
4602 return parseFloat(str.replace(/_/g, ""));
4603}
4604function stringToBigInt(str) {
4605 if (typeof BigInt !== "function") {
4606 return null;
4607 }
4608 return BigInt(str.replace(/_/g, ""));
4609}
4610pp.readRadixNumber = function(radix) {
4611 var start = this.pos;
4612 this.pos += 2;
4613 var val = this.readInt(radix);
4614 if (val == null) {
4615 this.raise(this.start + 2, "Expected number in radix " + radix);
4616 }
4617 if (this.options.ecmaVersion >= 11 && this.input.charCodeAt(this.pos) === 110) {
4618 val = stringToBigInt(this.input.slice(start, this.pos));
4619 ++this.pos;
4620 } else if (isIdentifierStart(this.fullCharCodeAtPos())) {
4621 this.raise(this.pos, "Identifier directly after number");
4622 }
4623 return this.finishToken(types$1.num, val);
4624};
4625pp.readNumber = function(startsWithDot) {
4626 var start = this.pos;
4627 if (!startsWithDot && this.readInt(10, void 0, true) === null) {
4628 this.raise(start, "Invalid number");
4629 }
4630 var octal = this.pos - start >= 2 && this.input.charCodeAt(start) === 48;
4631 if (octal && this.strict) {
4632 this.raise(start, "Invalid number");
4633 }
4634 var next = this.input.charCodeAt(this.pos);
4635 if (!octal && !startsWithDot && this.options.ecmaVersion >= 11 && next === 110) {
4636 var val$1 = stringToBigInt(this.input.slice(start, this.pos));
4637 ++this.pos;
4638 if (isIdentifierStart(this.fullCharCodeAtPos())) {
4639 this.raise(this.pos, "Identifier directly after number");
4640 }
4641 return this.finishToken(types$1.num, val$1);
4642 }
4643 if (octal && /[89]/.test(this.input.slice(start, this.pos))) {
4644 octal = false;
4645 }
4646 if (next === 46 && !octal) {
4647 ++this.pos;
4648 this.readInt(10);
4649 next = this.input.charCodeAt(this.pos);
4650 }
4651 if ((next === 69 || next === 101) && !octal) {
4652 next = this.input.charCodeAt(++this.pos);
4653 if (next === 43 || next === 45) {
4654 ++this.pos;
4655 }
4656 if (this.readInt(10) === null) {
4657 this.raise(start, "Invalid number");
4658 }
4659 }
4660 if (isIdentifierStart(this.fullCharCodeAtPos())) {
4661 this.raise(this.pos, "Identifier directly after number");
4662 }
4663 var val = stringToNumber(this.input.slice(start, this.pos), octal);
4664 return this.finishToken(types$1.num, val);
4665};
4666pp.readCodePoint = function() {
4667 var ch = this.input.charCodeAt(this.pos), code;
4668 if (ch === 123) {
4669 if (this.options.ecmaVersion < 6) {
4670 this.unexpected();
4671 }
4672 var codePos = ++this.pos;
4673 code = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos);
4674 ++this.pos;
4675 if (code > 1114111) {
4676 this.invalidStringToken(codePos, "Code point out of bounds");
4677 }
4678 } else {
4679 code = this.readHexChar(4);
4680 }
4681 return code;
4682};
4683pp.readString = function(quote) {
4684 var out = "", chunkStart = ++this.pos;
4685 for (; ; ) {
4686 if (this.pos >= this.input.length) {
4687 this.raise(this.start, "Unterminated string constant");
4688 }
4689 var ch = this.input.charCodeAt(this.pos);
4690 if (ch === quote) {
4691 break;
4692 }
4693 if (ch === 92) {
4694 out += this.input.slice(chunkStart, this.pos);
4695 out += this.readEscapedChar(false);
4696 chunkStart = this.pos;
4697 } else if (ch === 8232 || ch === 8233) {
4698 if (this.options.ecmaVersion < 10) {
4699 this.raise(this.start, "Unterminated string constant");
4700 }
4701 ++this.pos;
4702 if (this.options.locations) {
4703 this.curLine++;
4704 this.lineStart = this.pos;
4705 }
4706 } else {
4707 if (isNewLine(ch)) {
4708 this.raise(this.start, "Unterminated string constant");
4709 }
4710 ++this.pos;
4711 }
4712 }
4713 out += this.input.slice(chunkStart, this.pos++);
4714 return this.finishToken(types$1.string, out);
4715};
4716var INVALID_TEMPLATE_ESCAPE_ERROR = {};
4717pp.tryReadTemplateToken = function() {
4718 this.inTemplateElement = true;
4719 try {
4720 this.readTmplToken();
4721 } catch (err) {
4722 if (err === INVALID_TEMPLATE_ESCAPE_ERROR) {
4723 this.readInvalidTemplateToken();
4724 } else {
4725 throw err;
4726 }
4727 }
4728 this.inTemplateElement = false;
4729};
4730pp.invalidStringToken = function(position, message) {
4731 if (this.inTemplateElement && this.options.ecmaVersion >= 9) {
4732 throw INVALID_TEMPLATE_ESCAPE_ERROR;
4733 } else {
4734 this.raise(position, message);
4735 }
4736};
4737pp.readTmplToken = function() {
4738 var out = "", chunkStart = this.pos;
4739 for (; ; ) {
4740 if (this.pos >= this.input.length) {
4741 this.raise(this.start, "Unterminated template");
4742 }
4743 var ch = this.input.charCodeAt(this.pos);
4744 if (ch === 96 || ch === 36 && this.input.charCodeAt(this.pos + 1) === 123) {
4745 if (this.pos === this.start && (this.type === types$1.template || this.type === types$1.invalidTemplate)) {
4746 if (ch === 36) {
4747 this.pos += 2;
4748 return this.finishToken(types$1.dollarBraceL);
4749 } else {
4750 ++this.pos;
4751 return this.finishToken(types$1.backQuote);
4752 }
4753 }
4754 out += this.input.slice(chunkStart, this.pos);
4755 return this.finishToken(types$1.template, out);
4756 }
4757 if (ch === 92) {
4758 out += this.input.slice(chunkStart, this.pos);
4759 out += this.readEscapedChar(true);
4760 chunkStart = this.pos;
4761 } else if (isNewLine(ch)) {
4762 out += this.input.slice(chunkStart, this.pos);
4763 ++this.pos;
4764 switch (ch) {
4765 case 13:
4766 if (this.input.charCodeAt(this.pos) === 10) {
4767 ++this.pos;
4768 }
4769 case 10:
4770 out += "\n";
4771 break;
4772 default:
4773 out += String.fromCharCode(ch);
4774 break;
4775 }
4776 if (this.options.locations) {
4777 ++this.curLine;
4778 this.lineStart = this.pos;
4779 }
4780 chunkStart = this.pos;
4781 } else {
4782 ++this.pos;
4783 }
4784 }
4785};
4786pp.readInvalidTemplateToken = function() {
4787 for (; this.pos < this.input.length; this.pos++) {
4788 switch (this.input[this.pos]) {
4789 case "\\":
4790 ++this.pos;
4791 break;
4792 case "$":
4793 if (this.input[this.pos + 1] !== "{") {
4794 break;
4795 }
4796 case "`":
4797 return this.finishToken(types$1.invalidTemplate, this.input.slice(this.start, this.pos));
4798 }
4799 }
4800 this.raise(this.start, "Unterminated template");
4801};
4802pp.readEscapedChar = function(inTemplate) {
4803 var ch = this.input.charCodeAt(++this.pos);
4804 ++this.pos;
4805 switch (ch) {
4806 case 110:
4807 return "\n";
4808 case 114:
4809 return "\r";
4810 case 120:
4811 return String.fromCharCode(this.readHexChar(2));
4812 case 117:
4813 return codePointToString(this.readCodePoint());
4814 case 116:
4815 return " ";
4816 case 98:
4817 return "\b";
4818 case 118:
4819 return "\v";
4820 case 102:
4821 return "\f";
4822 case 13:
4823 if (this.input.charCodeAt(this.pos) === 10) {
4824 ++this.pos;
4825 }
4826 case 10:
4827 if (this.options.locations) {
4828 this.lineStart = this.pos;
4829 ++this.curLine;
4830 }
4831 return "";
4832 case 56:
4833 case 57:
4834 if (this.strict) {
4835 this.invalidStringToken(
4836 this.pos - 1,
4837 "Invalid escape sequence"
4838 );
4839 }
4840 if (inTemplate) {
4841 var codePos = this.pos - 1;
4842 this.invalidStringToken(
4843 codePos,
4844 "Invalid escape sequence in template string"
4845 );
4846 return null;
4847 }
4848 default:
4849 if (ch >= 48 && ch <= 55) {
4850 var octalStr = this.input.substr(this.pos - 1, 3).match(/^[0-7]+/)[0];
4851 var octal = parseInt(octalStr, 8);
4852 if (octal > 255) {
4853 octalStr = octalStr.slice(0, -1);
4854 octal = parseInt(octalStr, 8);
4855 }
4856 this.pos += octalStr.length - 1;
4857 ch = this.input.charCodeAt(this.pos);
4858 if ((octalStr !== "0" || ch === 56 || ch === 57) && (this.strict || inTemplate)) {
4859 this.invalidStringToken(
4860 this.pos - 1 - octalStr.length,
4861 inTemplate ? "Octal literal in template string" : "Octal literal in strict mode"
4862 );
4863 }
4864 return String.fromCharCode(octal);
4865 }
4866 if (isNewLine(ch)) {
4867 return "";
4868 }
4869 return String.fromCharCode(ch);
4870 }
4871};
4872pp.readHexChar = function(len) {
4873 var codePos = this.pos;
4874 var n = this.readInt(16, len);
4875 if (n === null) {
4876 this.invalidStringToken(codePos, "Bad character escape sequence");
4877 }
4878 return n;
4879};
4880pp.readWord1 = function() {
4881 this.containsEsc = false;
4882 var word = "", first = true, chunkStart = this.pos;
4883 var astral = this.options.ecmaVersion >= 6;
4884 while (this.pos < this.input.length) {
4885 var ch = this.fullCharCodeAtPos();
4886 if (isIdentifierChar(ch, astral)) {
4887 this.pos += ch <= 65535 ? 1 : 2;
4888 } else if (ch === 92) {
4889 this.containsEsc = true;
4890 word += this.input.slice(chunkStart, this.pos);
4891 var escStart = this.pos;
4892 if (this.input.charCodeAt(++this.pos) !== 117) {
4893 this.invalidStringToken(this.pos, "Expecting Unicode escape sequence \\uXXXX");
4894 }
4895 ++this.pos;
4896 var esc = this.readCodePoint();
4897 if (!(first ? isIdentifierStart : isIdentifierChar)(esc, astral)) {
4898 this.invalidStringToken(escStart, "Invalid Unicode escape");
4899 }
4900 word += codePointToString(esc);
4901 chunkStart = this.pos;
4902 } else {
4903 break;
4904 }
4905 first = false;
4906 }
4907 return word + this.input.slice(chunkStart, this.pos);
4908};
4909pp.readWord = function() {
4910 var word = this.readWord1();
4911 var type = types$1.name;
4912 if (this.keywords.test(word)) {
4913 type = keywords[word];
4914 }
4915 return this.finishToken(type, word);
4916};
4917var version = "8.8.0";
4918Parser.acorn = {
4919 Parser,
4920 version,
4921 defaultOptions,
4922 Position,
4923 SourceLocation,
4924 getLineInfo,
4925 Node,
4926 TokenType,
4927 tokTypes: types$1,
4928 keywordTypes: keywords,
4929 TokContext,
4930 tokContexts: types,
4931 isIdentifierChar,
4932 isIdentifierStart,
4933 Token,
4934 isNewLine,
4935 lineBreak,
4936 lineBreakG,
4937 nonASCIIwhitespace
4938};
4939const BUILTIN_MODULES = new Set(builtinModules);
4940const isWindows$1 = process.platform === "win32";
4941const own$1 = {}.hasOwnProperty;
4942const messages = /* @__PURE__ */ new Map();
4943const nodeInternalPrefix = "__node_internal_";
4944let userStackTraceLimit;
4945createError(
4946 "ERR_INVALID_MODULE_SPECIFIER",
4947 (request, reason, base = void 0) => {
4948 return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
4949 },
4950 TypeError
4951);
4952createError(
4953 "ERR_INVALID_PACKAGE_CONFIG",
4954 (path2, base, message) => {
4955 return `Invalid package config ${path2}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
4956 },
4957 Error
4958);
4959createError(
4960 "ERR_INVALID_PACKAGE_TARGET",
4961 (pkgPath, key, target, isImport = false, base = void 0) => {
4962 const relError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
4963 if (key === ".") {
4964 assert(isImport === false);
4965 return `Invalid "exports" main target ${JSON.stringify(target)} defined in the package config ${pkgPath}package.json${base ? ` imported from ${base}` : ""}${relError ? '; targets must start with "./"' : ""}`;
4966 }
4967 return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(
4968 target
4969 )} defined for '${key}' in the package config ${pkgPath}package.json${base ? ` imported from ${base}` : ""}${relError ? '; targets must start with "./"' : ""}`;
4970 },
4971 Error
4972);
4973createError(
4974 "ERR_MODULE_NOT_FOUND",
4975 (path2, base, type = "package") => {
4976 return `Cannot find ${type} '${path2}' imported from ${base}`;
4977 },
4978 Error
4979);
4980createError(
4981 "ERR_PACKAGE_IMPORT_NOT_DEFINED",
4982 (specifier, packagePath, base) => {
4983 return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath}package.json` : ""} imported from ${base}`;
4984 },
4985 TypeError
4986);
4987createError(
4988 "ERR_PACKAGE_PATH_NOT_EXPORTED",
4989 (pkgPath, subpath, base = void 0) => {
4990 if (subpath === ".") {
4991 return `No "exports" main defined in ${pkgPath}package.json${base ? ` imported from ${base}` : ""}`;
4992 }
4993 return `Package subpath '${subpath}' is not defined by "exports" in ${pkgPath}package.json${base ? ` imported from ${base}` : ""}`;
4994 },
4995 Error
4996);
4997createError(
4998 "ERR_UNSUPPORTED_DIR_IMPORT",
4999 "Directory import '%s' is not supported resolving ES modules imported from %s",
5000 Error
5001);
5002createError(
5003 "ERR_UNKNOWN_FILE_EXTENSION",
5004 'Unknown file extension "%s" for %s',
5005 TypeError
5006);
5007createError(
5008 "ERR_INVALID_ARG_VALUE",
5009 (name, value, reason = "is invalid") => {
5010 let inspected = inspect(value);
5011 if (inspected.length > 128) {
5012 inspected = `${inspected.slice(0, 128)}...`;
5013 }
5014 const type = name.includes(".") ? "property" : "argument";
5015 return `The ${type} '${name}' ${reason}. Received ${inspected}`;
5016 },
5017 TypeError
5018);
5019createError(
5020 "ERR_UNSUPPORTED_ESM_URL_SCHEME",
5021 (url) => {
5022 let message = "Only file and data URLs are supported by the default ESM loader";
5023 if (isWindows$1 && url.protocol.length === 2) {
5024 message += ". On Windows, absolute paths must be valid file:// URLs";
5025 }
5026 message += `. Received protocol '${url.protocol}'`;
5027 return message;
5028 },
5029 Error
5030);
5031function createError(sym, value, def) {
5032 messages.set(sym, value);
5033 return makeNodeErrorWithCode(def, sym);
5034}
5035function makeNodeErrorWithCode(Base, key) {
5036 return NodeError;
5037 function NodeError(...args) {
5038 const limit = Error.stackTraceLimit;
5039 if (isErrorStackTraceLimitWritable()) {
5040 Error.stackTraceLimit = 0;
5041 }
5042 const error = new Base();
5043 if (isErrorStackTraceLimitWritable()) {
5044 Error.stackTraceLimit = limit;
5045 }
5046 const message = getMessage(key, args, error);
5047 Object.defineProperty(error, "message", {
5048 value: message,
5049 enumerable: false,
5050 writable: true,
5051 configurable: true
5052 });
5053 Object.defineProperty(error, "toString", {
5054 value() {
5055 return `${this.name} [${key}]: ${this.message}`;
5056 },
5057 enumerable: false,
5058 writable: true,
5059 configurable: true
5060 });
5061 addCodeToName(error, Base.name, key);
5062 error.code = key;
5063 return error;
5064 }
5065}
5066const addCodeToName = hideStackFrames(
5067 function(error, name, code) {
5068 error = captureLargerStackTrace(error);
5069 error.name = `${name} [${code}]`;
5070 error.stack;
5071 if (name === "SystemError") {
5072 Object.defineProperty(error, "name", {
5073 value: name,
5074 enumerable: false,
5075 writable: true,
5076 configurable: true
5077 });
5078 } else {
5079 delete error.name;
5080 }
5081 }
5082);
5083function isErrorStackTraceLimitWritable() {
5084 const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
5085 if (desc === void 0) {
5086 return Object.isExtensible(Error);
5087 }
5088 return own$1.call(desc, "writable") ? desc.writable : desc.set !== void 0;
5089}
5090function hideStackFrames(fn) {
5091 const hidden = nodeInternalPrefix + fn.name;
5092 Object.defineProperty(fn, "name", { value: hidden });
5093 return fn;
5094}
5095const captureLargerStackTrace = hideStackFrames(
5096 function(error) {
5097 const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
5098 if (stackTraceLimitIsWritable) {
5099 userStackTraceLimit = Error.stackTraceLimit;
5100 Error.stackTraceLimit = Number.POSITIVE_INFINITY;
5101 }
5102 Error.captureStackTrace(error);
5103 if (stackTraceLimitIsWritable) {
5104 Error.stackTraceLimit = userStackTraceLimit;
5105 }
5106 return error;
5107 }
5108);
5109function getMessage(key, args, self) {
5110 const message = messages.get(key);
5111 if (typeof message === "function") {
5112 assert(
5113 message.length <= args.length,
5114 `Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${message.length}).`
5115 );
5116 return Reflect.apply(message, self, args);
5117 }
5118 const expectedLength = (message.match(/%[dfijoOs]/g) || []).length;
5119 assert(
5120 expectedLength === args.length,
5121 `Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${expectedLength}).`
5122 );
5123 if (args.length === 0) {
5124 return message;
5125 }
5126 args.unshift(message);
5127 return Reflect.apply(format$1, null, args);
5128}
5129Object.freeze(["node", "import"]);
5130function isNodeBuiltin(id = "") {
5131 id = id.replace(/^node:/, "").split("/")[0];
5132 return BUILTIN_MODULES.has(id);
5133}
5134pathToFileURL(process.cwd());
5135var browser = { exports: {} };
5136var ms;
5137var hasRequiredMs;
5138function requireMs() {
5139 if (hasRequiredMs)
5140 return ms;
5141 hasRequiredMs = 1;
5142 var s = 1e3;
5143 var m = s * 60;
5144 var h = m * 60;
5145 var d = h * 24;
5146 var w = d * 7;
5147 var y = d * 365.25;
5148 ms = function(val, options) {
5149 options = options || {};
5150 var type = typeof val;
5151 if (type === "string" && val.length > 0) {
5152 return parse4(val);
5153 } else if (type === "number" && isFinite(val)) {
5154 return options.long ? fmtLong(val) : fmtShort(val);
5155 }
5156 throw new Error(
5157 "val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
5158 );
5159 };
5160 function parse4(str) {
5161 str = String(str);
5162 if (str.length > 100) {
5163 return;
5164 }
5165 var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
5166 str
5167 );
5168 if (!match) {
5169 return;
5170 }
5171 var n = parseFloat(match[1]);
5172 var type = (match[2] || "ms").toLowerCase();
5173 switch (type) {
5174 case "years":
5175 case "year":
5176 case "yrs":
5177 case "yr":
5178 case "y":
5179 return n * y;
5180 case "weeks":
5181 case "week":
5182 case "w":
5183 return n * w;
5184 case "days":
5185 case "day":
5186 case "d":
5187 return n * d;
5188 case "hours":
5189 case "hour":
5190 case "hrs":
5191 case "hr":
5192 case "h":
5193 return n * h;
5194 case "minutes":
5195 case "minute":
5196 case "mins":
5197 case "min":
5198 case "m":
5199 return n * m;
5200 case "seconds":
5201 case "second":
5202 case "secs":
5203 case "sec":
5204 case "s":
5205 return n * s;
5206 case "milliseconds":
5207 case "millisecond":
5208 case "msecs":
5209 case "msec":
5210 case "ms":
5211 return n;
5212 default:
5213 return void 0;
5214 }
5215 }
5216 function fmtShort(ms2) {
5217 var msAbs = Math.abs(ms2);
5218 if (msAbs >= d) {
5219 return Math.round(ms2 / d) + "d";
5220 }
5221 if (msAbs >= h) {
5222 return Math.round(ms2 / h) + "h";
5223 }
5224 if (msAbs >= m) {
5225 return Math.round(ms2 / m) + "m";
5226 }
5227 if (msAbs >= s) {
5228 return Math.round(ms2 / s) + "s";
5229 }
5230 return ms2 + "ms";
5231 }
5232 function fmtLong(ms2) {
5233 var msAbs = Math.abs(ms2);
5234 if (msAbs >= d) {
5235 return plural(ms2, msAbs, d, "day");
5236 }
5237 if (msAbs >= h) {
5238 return plural(ms2, msAbs, h, "hour");
5239 }
5240 if (msAbs >= m) {
5241 return plural(ms2, msAbs, m, "minute");
5242 }
5243 if (msAbs >= s) {
5244 return plural(ms2, msAbs, s, "second");
5245 }
5246 return ms2 + " ms";
5247 }
5248 function plural(ms2, msAbs, n, name) {
5249 var isPlural = msAbs >= n * 1.5;
5250 return Math.round(ms2 / n) + " " + name + (isPlural ? "s" : "");
5251 }
5252 return ms;
5253}
5254function setup(env) {
5255 createDebug2.debug = createDebug2;
5256 createDebug2.default = createDebug2;
5257 createDebug2.coerce = coerce;
5258 createDebug2.disable = disable;
5259 createDebug2.enable = enable;
5260 createDebug2.enabled = enabled;
5261 createDebug2.humanize = requireMs();
5262 createDebug2.destroy = destroy;
5263 Object.keys(env).forEach((key) => {
5264 createDebug2[key] = env[key];
5265 });
5266 createDebug2.names = [];
5267 createDebug2.skips = [];
5268 createDebug2.formatters = {};
5269 function selectColor(namespace) {
5270 let hash = 0;
5271 for (let i = 0; i < namespace.length; i++) {
5272 hash = (hash << 5) - hash + namespace.charCodeAt(i);
5273 hash |= 0;
5274 }
5275 return createDebug2.colors[Math.abs(hash) % createDebug2.colors.length];
5276 }
5277 createDebug2.selectColor = selectColor;
5278 function createDebug2(namespace) {
5279 let prevTime;
5280 let enableOverride = null;
5281 let namespacesCache;
5282 let enabledCache;
5283 function debug(...args) {
5284 if (!debug.enabled) {
5285 return;
5286 }
5287 const self = debug;
5288 const curr = Number(new Date());
5289 const ms2 = curr - (prevTime || curr);
5290 self.diff = ms2;
5291 self.prev = prevTime;
5292 self.curr = curr;
5293 prevTime = curr;
5294 args[0] = createDebug2.coerce(args[0]);
5295 if (typeof args[0] !== "string") {
5296 args.unshift("%O");
5297 }
5298 let index = 0;
5299 args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format2) => {
5300 if (match === "%%") {
5301 return "%";
5302 }
5303 index++;
5304 const formatter = createDebug2.formatters[format2];
5305 if (typeof formatter === "function") {
5306 const val = args[index];
5307 match = formatter.call(self, val);
5308 args.splice(index, 1);
5309 index--;
5310 }
5311 return match;
5312 });
5313 createDebug2.formatArgs.call(self, args);
5314 const logFn = self.log || createDebug2.log;
5315 logFn.apply(self, args);
5316 }
5317 debug.namespace = namespace;
5318 debug.useColors = createDebug2.useColors();
5319 debug.color = createDebug2.selectColor(namespace);
5320 debug.extend = extend2;
5321 debug.destroy = createDebug2.destroy;
5322 Object.defineProperty(debug, "enabled", {
5323 enumerable: true,
5324 configurable: false,
5325 get: () => {
5326 if (enableOverride !== null) {
5327 return enableOverride;
5328 }
5329 if (namespacesCache !== createDebug2.namespaces) {
5330 namespacesCache = createDebug2.namespaces;
5331 enabledCache = createDebug2.enabled(namespace);
5332 }
5333 return enabledCache;
5334 },
5335 set: (v) => {
5336 enableOverride = v;
5337 }
5338 });
5339 if (typeof createDebug2.init === "function") {
5340 createDebug2.init(debug);
5341 }
5342 return debug;
5343 }
5344 function extend2(namespace, delimiter2) {
5345 const newDebug = createDebug2(this.namespace + (typeof delimiter2 === "undefined" ? ":" : delimiter2) + namespace);
5346 newDebug.log = this.log;
5347 return newDebug;
5348 }
5349 function enable(namespaces) {
5350 createDebug2.save(namespaces);
5351 createDebug2.namespaces = namespaces;
5352 createDebug2.names = [];
5353 createDebug2.skips = [];
5354 let i;
5355 const split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/);
5356 const len = split.length;
5357 for (i = 0; i < len; i++) {
5358 if (!split[i]) {
5359 continue;
5360 }
5361 namespaces = split[i].replace(/\*/g, ".*?");
5362 if (namespaces[0] === "-") {
5363 createDebug2.skips.push(new RegExp("^" + namespaces.slice(1) + "$"));
5364 } else {
5365 createDebug2.names.push(new RegExp("^" + namespaces + "$"));
5366 }
5367 }
5368 }
5369 function disable() {
5370 const namespaces = [
5371 ...createDebug2.names.map(toNamespace),
5372 ...createDebug2.skips.map(toNamespace).map((namespace) => "-" + namespace)
5373 ].join(",");
5374 createDebug2.enable("");
5375 return namespaces;
5376 }
5377 function enabled(name) {
5378 if (name[name.length - 1] === "*") {
5379 return true;
5380 }
5381 let i;
5382 let len;
5383 for (i = 0, len = createDebug2.skips.length; i < len; i++) {
5384 if (createDebug2.skips[i].test(name)) {
5385 return false;
5386 }
5387 }
5388 for (i = 0, len = createDebug2.names.length; i < len; i++) {
5389 if (createDebug2.names[i].test(name)) {
5390 return true;
5391 }
5392 }
5393 return false;
5394 }
5395 function toNamespace(regexp) {
5396 return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*");
5397 }
5398 function coerce(val) {
5399 if (val instanceof Error) {
5400 return val.stack || val.message;
5401 }
5402 return val;
5403 }
5404 function destroy() {
5405 console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
5406 }
5407 createDebug2.enable(createDebug2.load());
5408 return createDebug2;
5409}
5410var common = setup;
5411(function(module, exports) {
5412 exports.formatArgs = formatArgs;
5413 exports.save = save;
5414 exports.load = load;
5415 exports.useColors = useColors;
5416 exports.storage = localstorage();
5417 exports.destroy = (() => {
5418 let warned = false;
5419 return () => {
5420 if (!warned) {
5421 warned = true;
5422 console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
5423 }
5424 };
5425 })();
5426 exports.colors = [
5427 "#0000CC",
5428 "#0000FF",
5429 "#0033CC",
5430 "#0033FF",
5431 "#0066CC",
5432 "#0066FF",
5433 "#0099CC",
5434 "#0099FF",
5435 "#00CC00",
5436 "#00CC33",
5437 "#00CC66",
5438 "#00CC99",
5439 "#00CCCC",
5440 "#00CCFF",
5441 "#3300CC",
5442 "#3300FF",
5443 "#3333CC",
5444 "#3333FF",
5445 "#3366CC",
5446 "#3366FF",
5447 "#3399CC",
5448 "#3399FF",
5449 "#33CC00",
5450 "#33CC33",
5451 "#33CC66",
5452 "#33CC99",
5453 "#33CCCC",
5454 "#33CCFF",
5455 "#6600CC",
5456 "#6600FF",
5457 "#6633CC",
5458 "#6633FF",
5459 "#66CC00",
5460 "#66CC33",
5461 "#9900CC",
5462 "#9900FF",
5463 "#9933CC",
5464 "#9933FF",
5465 "#99CC00",
5466 "#99CC33",
5467 "#CC0000",
5468 "#CC0033",
5469 "#CC0066",
5470 "#CC0099",
5471 "#CC00CC",
5472 "#CC00FF",
5473 "#CC3300",
5474 "#CC3333",
5475 "#CC3366",
5476 "#CC3399",
5477 "#CC33CC",
5478 "#CC33FF",
5479 "#CC6600",
5480 "#CC6633",
5481 "#CC9900",
5482 "#CC9933",
5483 "#CCCC00",
5484 "#CCCC33",
5485 "#FF0000",
5486 "#FF0033",
5487 "#FF0066",
5488 "#FF0099",
5489 "#FF00CC",
5490 "#FF00FF",
5491 "#FF3300",
5492 "#FF3333",
5493 "#FF3366",
5494 "#FF3399",
5495 "#FF33CC",
5496 "#FF33FF",
5497 "#FF6600",
5498 "#FF6633",
5499 "#FF9900",
5500 "#FF9933",
5501 "#FFCC00",
5502 "#FFCC33"
5503 ];
5504 function useColors() {
5505 if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
5506 return true;
5507 }
5508 if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
5509 return false;
5510 }
5511 return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
5512 }
5513 function formatArgs(args) {
5514 args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
5515 if (!this.useColors) {
5516 return;
5517 }
5518 const c = "color: " + this.color;
5519 args.splice(1, 0, c, "color: inherit");
5520 let index = 0;
5521 let lastC = 0;
5522 args[0].replace(/%[a-zA-Z%]/g, (match) => {
5523 if (match === "%%") {
5524 return;
5525 }
5526 index++;
5527 if (match === "%c") {
5528 lastC = index;
5529 }
5530 });
5531 args.splice(lastC, 0, c);
5532 }
5533 exports.log = console.debug || console.log || (() => {
5534 });
5535 function save(namespaces) {
5536 try {
5537 if (namespaces) {
5538 exports.storage.setItem("debug", namespaces);
5539 } else {
5540 exports.storage.removeItem("debug");
5541 }
5542 } catch (error) {
5543 }
5544 }
5545 function load() {
5546 let r;
5547 try {
5548 r = exports.storage.getItem("debug");
5549 } catch (error) {
5550 }
5551 if (!r && typeof process !== "undefined" && "env" in process) {
5552 r = process.env.DEBUG;
5553 }
5554 return r;
5555 }
5556 function localstorage() {
5557 try {
5558 return localStorage;
5559 } catch (error) {
5560 }
5561 }
5562 module.exports = common(exports);
5563 const { formatters } = module.exports;
5564 formatters.j = function(v) {
5565 try {
5566 return JSON.stringify(v);
5567 } catch (error) {
5568 return "[UnexpectedJSONParseError]: " + error.message;
5569 }
5570 };
5571})(browser, browser.exports);
5572const createDebug = browser.exports;
5573const isWindows = process.platform === "win32";
5574function slash(str) {
5575 return str.replace(/\\/g, "/");
5576}
5577function mergeSlashes(str) {
5578 return str.replace(/\/\//g, "/");
5579}
5580function normalizeRequestId(id, base) {
5581 if (base && id.startsWith(base))
5582 id = `/${id.slice(base.length)}`;
5583 return id.replace(/^\/@id\/__x00__/, "\0").replace(/^\/@id\//, "").replace(/^__vite-browser-external:/, "").replace(/^(node|file):/, "").replace(/^\/+/, "/").replace(/\?v=\w+/, "?").replace(/&v=\w+/, "").replace(/\?t=\w+/, "?").replace(/&t=\w+/, "").replace(/\?import/, "?").replace(/&import/, "").replace(/\?&/, "?").replace(/\?+$/, "");
5584}
5585function normalizeModuleId(id) {
5586 return id.replace(/\\/g, "/").replace(/^\/@fs\//, "/").replace(/^file:\//, "/").replace(/^\/+/, "/");
5587}
5588function isPrimitive(v) {
5589 return v !== Object(v);
5590}
5591function toFilePath(id, root) {
5592 let absolute = id.startsWith("/@fs/") ? id.slice(4) : id.startsWith(root) ? id : id.startsWith("/") ? resolve(root, id.slice(1)) : id;
5593 if (absolute.startsWith("//"))
5594 absolute = absolute.slice(1);
5595 return isWindows && absolute.startsWith("/") ? slash(fileURLToPath(pathToFileURL(absolute.slice(1)).href)) : absolute;
5596}
5597const debugExecute = createDebug("vite-node:client:execute");
5598const debugNative = createDebug("vite-node:client:native");
5599const DEFAULT_REQUEST_STUBS = {
5600 "/@vite/client": {
5601 injectQuery: (id) => id,
5602 createHotContext() {
5603 return {
5604 accept: () => {
5605 },
5606 prune: () => {
5607 },
5608 dispose: () => {
5609 },
5610 decline: () => {
5611 },
5612 invalidate: () => {
5613 },
5614 on: () => {
5615 }
5616 };
5617 },
5618 updateStyle(id, css) {
5619 if (typeof document === "undefined")
5620 return;
5621 const element = document.getElementById(id);
5622 if (element)
5623 element.remove();
5624 const head = document.querySelector("head");
5625 const style = document.createElement("style");
5626 style.setAttribute("type", "text/css");
5627 style.id = id;
5628 style.innerHTML = css;
5629 head == null ? void 0 : head.appendChild(style);
5630 }
5631 }
5632};
5633class ModuleCacheMap extends Map {
5634 normalizePath(fsPath) {
5635 return normalizeModuleId(fsPath);
5636 }
5637 update(fsPath, mod) {
5638 fsPath = this.normalizePath(fsPath);
5639 if (!super.has(fsPath))
5640 super.set(fsPath, mod);
5641 else
5642 Object.assign(super.get(fsPath), mod);
5643 return this;
5644 }
5645 set(fsPath, mod) {
5646 fsPath = this.normalizePath(fsPath);
5647 return super.set(fsPath, mod);
5648 }
5649 get(fsPath) {
5650 fsPath = this.normalizePath(fsPath);
5651 if (!super.has(fsPath))
5652 super.set(fsPath, {});
5653 return super.get(fsPath);
5654 }
5655 delete(fsPath) {
5656 fsPath = this.normalizePath(fsPath);
5657 return super.delete(fsPath);
5658 }
5659 invalidateDepTree(ids, invalidated = /* @__PURE__ */ new Set()) {
5660 for (const _id of ids) {
5661 const id = this.normalizePath(_id);
5662 if (invalidated.has(id))
5663 continue;
5664 invalidated.add(id);
5665 const mod = super.get(id);
5666 if (mod == null ? void 0 : mod.importers)
5667 this.invalidateDepTree(mod.importers, invalidated);
5668 super.delete(id);
5669 }
5670 return invalidated;
5671 }
5672 invalidateSubDepTree(ids, invalidated = /* @__PURE__ */ new Set()) {
5673 for (const _id of ids) {
5674 const id = this.normalizePath(_id);
5675 if (invalidated.has(id))
5676 continue;
5677 invalidated.add(id);
5678 const subIds = Array.from(super.entries()).filter(([, mod]) => {
5679 var _a;
5680 return (_a = mod.importers) == null ? void 0 : _a.has(id);
5681 }).map(([key]) => key);
5682 subIds.length && this.invalidateSubDepTree(subIds, invalidated);
5683 super.delete(id);
5684 }
5685 return invalidated;
5686 }
5687}
5688class ViteNodeRunner {
5689 constructor(options) {
5690 this.options = options;
5691 this.root = options.root ?? process.cwd();
5692 this.moduleCache = options.moduleCache ?? new ModuleCacheMap();
5693 this.debug = options.debug ?? (typeof process !== "undefined" ? !!process.env.VITE_NODE_DEBUG_RUNNER : false);
5694 }
5695 async executeFile(file) {
5696 return await this.cachedRequest(`/@fs/${slash(resolve(file))}`, []);
5697 }
5698 async executeId(id) {
5699 return await this.cachedRequest(id, []);
5700 }
5701 async cachedRequest(rawId, callstack) {
5702 const id = normalizeRequestId(rawId, this.options.base);
5703 const fsPath = toFilePath(id, this.root);
5704 const mod = this.moduleCache.get(fsPath);
5705 const importee = callstack[callstack.length - 1];
5706 if (!mod.importers)
5707 mod.importers = /* @__PURE__ */ new Set();
5708 if (importee)
5709 mod.importers.add(importee);
5710 if (callstack.includes(fsPath) && mod.exports)
5711 return mod.exports;
5712 if (mod.promise)
5713 return mod.promise;
5714 const promise = this.directRequest(id, fsPath, callstack);
5715 Object.assign(mod, { promise });
5716 return await promise;
5717 }
5718 async directRequest(id, fsPath, _callstack) {
5719 const callstack = [..._callstack, fsPath];
5720 const mod = this.moduleCache.get(fsPath);
5721 const request = async (dep) => {
5722 var _a;
5723 const depFsPath = toFilePath(normalizeRequestId(dep, this.options.base), this.root);
5724 const getStack = () => {
5725 return `stack:
5726${[...callstack, depFsPath].reverse().map((p) => `- ${p}`).join("\n")}`;
5727 };
5728 let debugTimer;
5729 if (this.debug)
5730 debugTimer = setTimeout(() => console.warn(() => `module ${depFsPath} takes over 2s to load.
5731${getStack()}`), 2e3);
5732 try {
5733 if (callstack.includes(depFsPath)) {
5734 const depExports = (_a = this.moduleCache.get(depFsPath)) == null ? void 0 : _a.exports;
5735 if (depExports)
5736 return depExports;
5737 throw new Error(`[vite-node] Failed to resolve circular dependency, ${getStack()}`);
5738 }
5739 return await this.cachedRequest(dep, callstack);
5740 } finally {
5741 if (debugTimer)
5742 clearTimeout(debugTimer);
5743 }
5744 };
5745 Object.defineProperty(request, "callstack", { get: () => callstack });
5746 const resolveId = async (dep, callstackPosition = 1) => {
5747 if (this.options.resolveId && this.shouldResolveId(dep)) {
5748 let importer = callstack[callstack.length - callstackPosition];
5749 if (importer && importer.startsWith("mock:"))
5750 importer = importer.slice(5);
5751 const { id: id2 } = await this.options.resolveId(dep, importer) || {};
5752 dep = id2 && isAbsolute(id2) ? mergeSlashes(`/@fs/${id2}`) : id2 || dep;
5753 }
5754 return dep;
5755 };
5756 id = await resolveId(id, 2);
5757 const requestStubs = this.options.requestStubs || DEFAULT_REQUEST_STUBS;
5758 if (id in requestStubs)
5759 return requestStubs[id];
5760 let { code: transformed, externalize } = await this.options.fetchModule(id);
5761 if (externalize) {
5762 debugNative(externalize);
5763 const exports2 = await this.interopedImport(externalize);
5764 mod.exports = exports2;
5765 return exports2;
5766 }
5767 if (transformed == null)
5768 throw new Error(`[vite-node] Failed to load ${id}`);
5769 const url = pathToFileURL(fsPath).href;
5770 const meta = { url };
5771 const exports = /* @__PURE__ */ Object.create(null);
5772 Object.defineProperty(exports, Symbol.toStringTag, {
5773 value: "Module",
5774 enumerable: false,
5775 configurable: false
5776 });
5777 const cjsExports = new Proxy(exports, {
5778 get(_, p, receiver) {
5779 return Reflect.get(exports, p, receiver);
5780 },
5781 set(_, p, value) {
5782 if (p !== "default") {
5783 if (!Reflect.has(exports, "default"))
5784 exports.default = {};
5785 if (exports.default === null || typeof exports.default !== "object") {
5786 defineExport(exports, p, () => void 0);
5787 return true;
5788 }
5789 exports.default[p] = value;
5790 defineExport(exports, p, () => value);
5791 return true;
5792 }
5793 return Reflect.set(exports, p, value);
5794 }
5795 });
5796 Object.assign(mod, { code: transformed, exports });
5797 const __filename = fileURLToPath(url);
5798 const moduleProxy = {
5799 set exports(value) {
5800 exportAll(cjsExports, value);
5801 cjsExports.default = value;
5802 },
5803 get exports() {
5804 return cjsExports;
5805 }
5806 };
5807 let hotContext;
5808 if (this.options.createHotContext) {
5809 Object.defineProperty(meta, "hot", {
5810 enumerable: true,
5811 get: () => {
5812 var _a, _b;
5813 hotContext || (hotContext = (_b = (_a = this.options).createHotContext) == null ? void 0 : _b.call(_a, this, `/@fs/${fsPath}`));
5814 return hotContext;
5815 }
5816 });
5817 }
5818 const context = this.prepareContext({
5819 __vite_ssr_import__: request,
5820 __vite_ssr_dynamic_import__: request,
5821 __vite_ssr_exports__: exports,
5822 __vite_ssr_exportAll__: (obj) => exportAll(exports, obj),
5823 __vite_ssr_import_meta__: meta,
5824 __vitest_resolve_id__: resolveId,
5825 require: createRequire(url),
5826 exports: cjsExports,
5827 module: moduleProxy,
5828 __filename,
5829 __dirname: dirname(__filename)
5830 });
5831 debugExecute(__filename);
5832 if (transformed[0] === "#")
5833 transformed = transformed.replace(/^\#\!.*/, (s) => " ".repeat(s.length));
5834 const fn = vm.runInThisContext(`'use strict';async (${Object.keys(context).join(",")})=>{{${transformed}
5835}}`, {
5836 filename: fsPath,
5837 lineOffset: 0
5838 });
5839 await fn(...Object.values(context));
5840 return exports;
5841 }
5842 prepareContext(context) {
5843 return context;
5844 }
5845 shouldResolveId(dep) {
5846 if (isNodeBuiltin(dep) || dep in (this.options.requestStubs || DEFAULT_REQUEST_STUBS) || dep.startsWith("/@vite"))
5847 return false;
5848 return !isAbsolute(dep) || !extname(dep);
5849 }
5850 shouldInterop(path2, mod) {
5851 if (this.options.interopDefault === false)
5852 return false;
5853 return !path2.endsWith(".mjs") && "default" in mod;
5854 }
5855 async interopedImport(path2) {
5856 const mod = await import(path2);
5857 if (this.shouldInterop(path2, mod)) {
5858 const tryDefault = this.hasNestedDefault(mod);
5859 return new Proxy(mod, {
5860 get: proxyMethod("get", tryDefault),
5861 set: proxyMethod("set", tryDefault),
5862 has: proxyMethod("has", tryDefault),
5863 deleteProperty: proxyMethod("deleteProperty", tryDefault)
5864 });
5865 }
5866 return mod;
5867 }
5868 hasNestedDefault(target) {
5869 return "__esModule" in target && target.__esModule && "default" in target.default;
5870 }
5871}
5872function proxyMethod(name, tryDefault) {
5873 return function(target, key, ...args) {
5874 const result = Reflect[name](target, key, ...args);
5875 if (isPrimitive(target.default))
5876 return result;
5877 if (tryDefault && key === "default" || typeof result === "undefined")
5878 return Reflect[name](target.default, key, ...args);
5879 return result;
5880 };
5881}
5882function defineExport(exports, key, value) {
5883 Object.defineProperty(exports, key, {
5884 enumerable: true,
5885 configurable: true,
5886 get: value
5887 });
5888}
5889function exportAll(exports, sourceModule) {
5890 if (exports === sourceModule)
5891 return;
5892 if (typeof sourceModule !== "object" || Array.isArray(sourceModule) || !sourceModule)
5893 return;
5894 for (const key in sourceModule) {
5895 if (key !== "default") {
5896 try {
5897 defineExport(exports, key, () => sourceModule[key]);
5898 } catch (_err) {
5899 }
5900 }
5901 }
5902}
5903export {
5904 DEFAULT_REQUEST_STUBS,
5905 ModuleCacheMap,
5906 ViteNodeRunner
5907};