nitro-nightly 3.0.1-20251203-231615-3a2d2662 → 3.0.1-20251204-201435-0c3150df

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/_build/common.mjs +1 -1
  2. package/dist/_build/rolldown.mjs +9 -10
  3. package/dist/_build/rollup.mjs +13 -20
  4. package/dist/_build/vite.build.mjs +12 -14
  5. package/dist/_build/vite.plugin.mjs +20 -23
  6. package/dist/_chunks/{Ddt06bL8.mjs → CycPUgTQ.mjs} +1 -1
  7. package/dist/_chunks/{BY3yPF44.mjs → DT-wSyHv.mjs} +1 -1
  8. package/dist/_chunks/{CytQIojr.mjs → DzjzT3Xu.mjs} +1 -1
  9. package/dist/{_dev.mjs → _chunks/dcDd0pkY.mjs} +22 -23
  10. package/dist/_chunks/{CvxEFBdh.mjs → vCTaGRPD.mjs} +2 -2
  11. package/dist/_libs/@pi0/vite-plugin-fullstack.mjs +1923 -0
  12. package/dist/_libs/@rollup/plugin-commonjs.mjs +3859 -0
  13. package/dist/_libs/{plugin-inject.mjs → @rollup/plugin-inject.mjs} +2 -3
  14. package/dist/_libs/{plugin-node-resolve.mjs → @rollup/plugin-node-resolve.mjs} +424 -5
  15. package/dist/_libs/{plugin-replace.mjs → @rollup/plugin-replace.mjs} +1 -1
  16. package/dist/_libs/estree-walker.mjs +1 -144
  17. package/dist/_libs/tinyglobby.mjs +1 -2
  18. package/dist/_libs/unimport.mjs +3 -4
  19. package/dist/_libs/unwasm.mjs +1 -1
  20. package/dist/_presets.mjs +2 -2
  21. package/dist/builder.d.mts +4 -4
  22. package/dist/builder.mjs +7 -7
  23. package/dist/cli/_chunks/detect-acorn.mjs +2 -2
  24. package/dist/cli/_chunks/dev.mjs +2 -2
  25. package/dist/runtime/internal/vite/{dev-worker.mjs → node-runner.mjs} +30 -5
  26. package/dist/types/index.d.mts +36 -38
  27. package/dist/vite.mjs +12 -14
  28. package/package.json +3 -3
  29. package/dist/_libs/commondir.mjs +0 -22
  30. package/dist/_libs/deepmerge.mjs +0 -86
  31. package/dist/_libs/fdir.mjs +0 -514
  32. package/dist/_libs/function-bind.mjs +0 -63
  33. package/dist/_libs/hasown.mjs +0 -14
  34. package/dist/_libs/is-core-module.mjs +0 -220
  35. package/dist/_libs/is-module.mjs +0 -13
  36. package/dist/_libs/is-reference.mjs +0 -33
  37. package/dist/_libs/js-tokens.mjs +0 -382
  38. package/dist/_libs/magic-string.mjs +0 -939
  39. package/dist/_libs/path-parse.mjs +0 -47
  40. package/dist/_libs/picomatch.mjs +0 -1673
  41. package/dist/_libs/plugin-commonjs.mjs +0 -1491
  42. package/dist/_libs/strip-literal.mjs +0 -51
  43. package/dist/_libs/vite-plugin-fullstack.mjs +0 -561
  44. /package/dist/_chunks/{DJvLZH4H.mjs → Df3_4Pam.mjs} +0 -0
  45. /package/dist/_libs/{gen-mapping.mjs → @jridgewell/gen-mapping.mjs} +0 -0
  46. /package/dist/_libs/{remapping.mjs → @jridgewell/remapping.mjs} +0 -0
  47. /package/dist/_libs/{plugin-alias.mjs → @rollup/plugin-alias.mjs} +0 -0
  48. /package/dist/_libs/{plugin-json.mjs → @rollup/plugin-json.mjs} +0 -0
@@ -0,0 +1,3859 @@
1
+ import { i as __toESM, n as __require$1, t as __commonJSMin } from "../../_chunks/QkUO_zA6.mjs";
2
+ import { r as MagicString } from "../@pi0/vite-plugin-fullstack.mjs";
3
+ import * as nativeFs$1 from "fs";
4
+ import { existsSync, readFileSync, statSync } from "fs";
5
+ import { basename, dirname, extname, isAbsolute, join, normalize, posix, relative, resolve, sep, win32 } from "path";
6
+ import { createRequire } from "module";
7
+
8
+ //#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js
9
+ var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
10
+ const WIN_SLASH = "\\\\/";
11
+ const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
12
+ /**
13
+ * Posix glob regex
14
+ */
15
+ const DOT_LITERAL = "\\.";
16
+ const PLUS_LITERAL = "\\+";
17
+ const QMARK_LITERAL = "\\?";
18
+ const SLASH_LITERAL = "\\/";
19
+ const ONE_CHAR = "(?=.)";
20
+ const QMARK = "[^/]";
21
+ const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
22
+ const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
23
+ const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
24
+ const POSIX_CHARS = {
25
+ DOT_LITERAL,
26
+ PLUS_LITERAL,
27
+ QMARK_LITERAL,
28
+ SLASH_LITERAL,
29
+ ONE_CHAR,
30
+ QMARK,
31
+ END_ANCHOR,
32
+ DOTS_SLASH,
33
+ NO_DOT: `(?!${DOT_LITERAL})`,
34
+ NO_DOTS: `(?!${START_ANCHOR}${DOTS_SLASH})`,
35
+ NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`,
36
+ NO_DOTS_SLASH: `(?!${DOTS_SLASH})`,
37
+ QMARK_NO_DOT: `[^.${SLASH_LITERAL}]`,
38
+ STAR: `${QMARK}*?`,
39
+ START_ANCHOR,
40
+ SEP: "/"
41
+ };
42
+ /**
43
+ * Windows glob regex
44
+ */
45
+ const WINDOWS_CHARS = {
46
+ ...POSIX_CHARS,
47
+ SLASH_LITERAL: `[${WIN_SLASH}]`,
48
+ QMARK: WIN_NO_SLASH,
49
+ STAR: `${WIN_NO_SLASH}*?`,
50
+ DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
51
+ NO_DOT: `(?!${DOT_LITERAL})`,
52
+ NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
53
+ NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
54
+ NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
55
+ QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
56
+ START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
57
+ END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
58
+ SEP: "\\"
59
+ };
60
+ /**
61
+ * POSIX Bracket Regex
62
+ */
63
+ const POSIX_REGEX_SOURCE$1 = {
64
+ alnum: "a-zA-Z0-9",
65
+ alpha: "a-zA-Z",
66
+ ascii: "\\x00-\\x7F",
67
+ blank: " \\t",
68
+ cntrl: "\\x00-\\x1F\\x7F",
69
+ digit: "0-9",
70
+ graph: "\\x21-\\x7E",
71
+ lower: "a-z",
72
+ print: "\\x20-\\x7E ",
73
+ punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
74
+ space: " \\t\\r\\n\\v\\f",
75
+ upper: "A-Z",
76
+ word: "A-Za-z0-9_",
77
+ xdigit: "A-Fa-f0-9"
78
+ };
79
+ module.exports = {
80
+ MAX_LENGTH: 1024 * 64,
81
+ POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
82
+ REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
83
+ REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
84
+ REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
85
+ REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
86
+ REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
87
+ REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
88
+ REPLACEMENTS: {
89
+ __proto__: null,
90
+ "***": "*",
91
+ "**/**": "**",
92
+ "**/**/**": "**"
93
+ },
94
+ CHAR_0: 48,
95
+ CHAR_9: 57,
96
+ CHAR_UPPERCASE_A: 65,
97
+ CHAR_LOWERCASE_A: 97,
98
+ CHAR_UPPERCASE_Z: 90,
99
+ CHAR_LOWERCASE_Z: 122,
100
+ CHAR_LEFT_PARENTHESES: 40,
101
+ CHAR_RIGHT_PARENTHESES: 41,
102
+ CHAR_ASTERISK: 42,
103
+ CHAR_AMPERSAND: 38,
104
+ CHAR_AT: 64,
105
+ CHAR_BACKWARD_SLASH: 92,
106
+ CHAR_CARRIAGE_RETURN: 13,
107
+ CHAR_CIRCUMFLEX_ACCENT: 94,
108
+ CHAR_COLON: 58,
109
+ CHAR_COMMA: 44,
110
+ CHAR_DOT: 46,
111
+ CHAR_DOUBLE_QUOTE: 34,
112
+ CHAR_EQUAL: 61,
113
+ CHAR_EXCLAMATION_MARK: 33,
114
+ CHAR_FORM_FEED: 12,
115
+ CHAR_FORWARD_SLASH: 47,
116
+ CHAR_GRAVE_ACCENT: 96,
117
+ CHAR_HASH: 35,
118
+ CHAR_HYPHEN_MINUS: 45,
119
+ CHAR_LEFT_ANGLE_BRACKET: 60,
120
+ CHAR_LEFT_CURLY_BRACE: 123,
121
+ CHAR_LEFT_SQUARE_BRACKET: 91,
122
+ CHAR_LINE_FEED: 10,
123
+ CHAR_NO_BREAK_SPACE: 160,
124
+ CHAR_PERCENT: 37,
125
+ CHAR_PLUS: 43,
126
+ CHAR_QUESTION_MARK: 63,
127
+ CHAR_RIGHT_ANGLE_BRACKET: 62,
128
+ CHAR_RIGHT_CURLY_BRACE: 125,
129
+ CHAR_RIGHT_SQUARE_BRACKET: 93,
130
+ CHAR_SEMICOLON: 59,
131
+ CHAR_SINGLE_QUOTE: 39,
132
+ CHAR_SPACE: 32,
133
+ CHAR_TAB: 9,
134
+ CHAR_UNDERSCORE: 95,
135
+ CHAR_VERTICAL_LINE: 124,
136
+ CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
137
+ extglobChars(chars) {
138
+ return {
139
+ "!": {
140
+ type: "negate",
141
+ open: "(?:(?!(?:",
142
+ close: `))${chars.STAR})`
143
+ },
144
+ "?": {
145
+ type: "qmark",
146
+ open: "(?:",
147
+ close: ")?"
148
+ },
149
+ "+": {
150
+ type: "plus",
151
+ open: "(?:",
152
+ close: ")+"
153
+ },
154
+ "*": {
155
+ type: "star",
156
+ open: "(?:",
157
+ close: ")*"
158
+ },
159
+ "@": {
160
+ type: "at",
161
+ open: "(?:",
162
+ close: ")"
163
+ }
164
+ };
165
+ },
166
+ globChars(win32$1) {
167
+ return win32$1 === true ? WINDOWS_CHARS : POSIX_CHARS;
168
+ }
169
+ };
170
+ }));
171
+
172
+ //#endregion
173
+ //#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js
174
+ var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
175
+ const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = require_constants();
176
+ exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
177
+ exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
178
+ exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
179
+ exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
180
+ exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
181
+ exports.isWindows = () => {
182
+ if (typeof navigator !== "undefined" && navigator.platform) {
183
+ const platform = navigator.platform.toLowerCase();
184
+ return platform === "win32" || platform === "windows";
185
+ }
186
+ if (typeof process !== "undefined" && process.platform) return process.platform === "win32";
187
+ return false;
188
+ };
189
+ exports.removeBackslashes = (str) => {
190
+ return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
191
+ return match === "\\" ? "" : match;
192
+ });
193
+ };
194
+ exports.escapeLast = (input, char, lastIdx) => {
195
+ const idx = input.lastIndexOf(char, lastIdx);
196
+ if (idx === -1) return input;
197
+ if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
198
+ return `${input.slice(0, idx)}\\${input.slice(idx)}`;
199
+ };
200
+ exports.removePrefix = (input, state = {}) => {
201
+ let output = input;
202
+ if (output.startsWith("./")) {
203
+ output = output.slice(2);
204
+ state.prefix = "./";
205
+ }
206
+ return output;
207
+ };
208
+ exports.wrapOutput = (input, state = {}, options = {}) => {
209
+ let output = `${options.contains ? "" : "^"}(?:${input})${options.contains ? "" : "$"}`;
210
+ if (state.negated === true) output = `(?:^(?!${output}).*$)`;
211
+ return output;
212
+ };
213
+ exports.basename = (path$2, { windows } = {}) => {
214
+ const segs = path$2.split(windows ? /[\\/]/ : "/");
215
+ const last = segs[segs.length - 1];
216
+ if (last === "") return segs[segs.length - 2];
217
+ return last;
218
+ };
219
+ }));
220
+
221
+ //#endregion
222
+ //#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.js
223
+ var require_scan = /* @__PURE__ */ __commonJSMin(((exports, module) => {
224
+ const utils$3 = require_utils();
225
+ const { CHAR_ASTERISK, CHAR_AT, CHAR_BACKWARD_SLASH, CHAR_COMMA, CHAR_DOT, CHAR_EXCLAMATION_MARK, CHAR_FORWARD_SLASH, CHAR_LEFT_CURLY_BRACE, CHAR_LEFT_PARENTHESES, CHAR_LEFT_SQUARE_BRACKET, CHAR_PLUS, CHAR_QUESTION_MARK, CHAR_RIGHT_CURLY_BRACE, CHAR_RIGHT_PARENTHESES, CHAR_RIGHT_SQUARE_BRACKET } = require_constants();
226
+ const isPathSeparator = (code) => {
227
+ return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
228
+ };
229
+ const depth = (token) => {
230
+ if (token.isPrefix !== true) token.depth = token.isGlobstar ? Infinity : 1;
231
+ };
232
+ /**
233
+ * Quickly scans a glob pattern and returns an object with a handful of
234
+ * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
235
+ * `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
236
+ * with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
237
+ *
238
+ * ```js
239
+ * const pm = require('picomatch');
240
+ * console.log(pm.scan('foo/bar/*.js'));
241
+ * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
242
+ * ```
243
+ * @param {String} `str`
244
+ * @param {Object} `options`
245
+ * @return {Object} Returns an object with tokens and regex source string.
246
+ * @api public
247
+ */
248
+ const scan$1 = (input, options) => {
249
+ const opts = options || {};
250
+ const length = input.length - 1;
251
+ const scanToEnd = opts.parts === true || opts.scanToEnd === true;
252
+ const slashes = [];
253
+ const tokens = [];
254
+ const parts = [];
255
+ let str = input;
256
+ let index = -1;
257
+ let start = 0;
258
+ let lastIndex = 0;
259
+ let isBrace = false;
260
+ let isBracket = false;
261
+ let isGlob = false;
262
+ let isExtglob = false;
263
+ let isGlobstar = false;
264
+ let braceEscaped = false;
265
+ let backslashes = false;
266
+ let negated = false;
267
+ let negatedExtglob = false;
268
+ let finished = false;
269
+ let braces = 0;
270
+ let prev;
271
+ let code;
272
+ let token = {
273
+ value: "",
274
+ depth: 0,
275
+ isGlob: false
276
+ };
277
+ const eos = () => index >= length;
278
+ const peek = () => str.charCodeAt(index + 1);
279
+ const advance = () => {
280
+ prev = code;
281
+ return str.charCodeAt(++index);
282
+ };
283
+ while (index < length) {
284
+ code = advance();
285
+ let next;
286
+ if (code === CHAR_BACKWARD_SLASH) {
287
+ backslashes = token.backslashes = true;
288
+ code = advance();
289
+ if (code === CHAR_LEFT_CURLY_BRACE) braceEscaped = true;
290
+ continue;
291
+ }
292
+ if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
293
+ braces++;
294
+ while (eos() !== true && (code = advance())) {
295
+ if (code === CHAR_BACKWARD_SLASH) {
296
+ backslashes = token.backslashes = true;
297
+ advance();
298
+ continue;
299
+ }
300
+ if (code === CHAR_LEFT_CURLY_BRACE) {
301
+ braces++;
302
+ continue;
303
+ }
304
+ if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
305
+ isBrace = token.isBrace = true;
306
+ isGlob = token.isGlob = true;
307
+ finished = true;
308
+ if (scanToEnd === true) continue;
309
+ break;
310
+ }
311
+ if (braceEscaped !== true && code === CHAR_COMMA) {
312
+ isBrace = token.isBrace = true;
313
+ isGlob = token.isGlob = true;
314
+ finished = true;
315
+ if (scanToEnd === true) continue;
316
+ break;
317
+ }
318
+ if (code === CHAR_RIGHT_CURLY_BRACE) {
319
+ braces--;
320
+ if (braces === 0) {
321
+ braceEscaped = false;
322
+ isBrace = token.isBrace = true;
323
+ finished = true;
324
+ break;
325
+ }
326
+ }
327
+ }
328
+ if (scanToEnd === true) continue;
329
+ break;
330
+ }
331
+ if (code === CHAR_FORWARD_SLASH) {
332
+ slashes.push(index);
333
+ tokens.push(token);
334
+ token = {
335
+ value: "",
336
+ depth: 0,
337
+ isGlob: false
338
+ };
339
+ if (finished === true) continue;
340
+ if (prev === CHAR_DOT && index === start + 1) {
341
+ start += 2;
342
+ continue;
343
+ }
344
+ lastIndex = index + 1;
345
+ continue;
346
+ }
347
+ if (opts.noext !== true) {
348
+ if ((code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK) === true && peek() === CHAR_LEFT_PARENTHESES) {
349
+ isGlob = token.isGlob = true;
350
+ isExtglob = token.isExtglob = true;
351
+ finished = true;
352
+ if (code === CHAR_EXCLAMATION_MARK && index === start) negatedExtglob = true;
353
+ if (scanToEnd === true) {
354
+ while (eos() !== true && (code = advance())) {
355
+ if (code === CHAR_BACKWARD_SLASH) {
356
+ backslashes = token.backslashes = true;
357
+ code = advance();
358
+ continue;
359
+ }
360
+ if (code === CHAR_RIGHT_PARENTHESES) {
361
+ isGlob = token.isGlob = true;
362
+ finished = true;
363
+ break;
364
+ }
365
+ }
366
+ continue;
367
+ }
368
+ break;
369
+ }
370
+ }
371
+ if (code === CHAR_ASTERISK) {
372
+ if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
373
+ isGlob = token.isGlob = true;
374
+ finished = true;
375
+ if (scanToEnd === true) continue;
376
+ break;
377
+ }
378
+ if (code === CHAR_QUESTION_MARK) {
379
+ isGlob = token.isGlob = true;
380
+ finished = true;
381
+ if (scanToEnd === true) continue;
382
+ break;
383
+ }
384
+ if (code === CHAR_LEFT_SQUARE_BRACKET) {
385
+ while (eos() !== true && (next = advance())) {
386
+ if (next === CHAR_BACKWARD_SLASH) {
387
+ backslashes = token.backslashes = true;
388
+ advance();
389
+ continue;
390
+ }
391
+ if (next === CHAR_RIGHT_SQUARE_BRACKET) {
392
+ isBracket = token.isBracket = true;
393
+ isGlob = token.isGlob = true;
394
+ finished = true;
395
+ break;
396
+ }
397
+ }
398
+ if (scanToEnd === true) continue;
399
+ break;
400
+ }
401
+ if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
402
+ negated = token.negated = true;
403
+ start++;
404
+ continue;
405
+ }
406
+ if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
407
+ isGlob = token.isGlob = true;
408
+ if (scanToEnd === true) {
409
+ while (eos() !== true && (code = advance())) {
410
+ if (code === CHAR_LEFT_PARENTHESES) {
411
+ backslashes = token.backslashes = true;
412
+ code = advance();
413
+ continue;
414
+ }
415
+ if (code === CHAR_RIGHT_PARENTHESES) {
416
+ finished = true;
417
+ break;
418
+ }
419
+ }
420
+ continue;
421
+ }
422
+ break;
423
+ }
424
+ if (isGlob === true) {
425
+ finished = true;
426
+ if (scanToEnd === true) continue;
427
+ break;
428
+ }
429
+ }
430
+ if (opts.noext === true) {
431
+ isExtglob = false;
432
+ isGlob = false;
433
+ }
434
+ let base = str;
435
+ let prefix = "";
436
+ let glob = "";
437
+ if (start > 0) {
438
+ prefix = str.slice(0, start);
439
+ str = str.slice(start);
440
+ lastIndex -= start;
441
+ }
442
+ if (base && isGlob === true && lastIndex > 0) {
443
+ base = str.slice(0, lastIndex);
444
+ glob = str.slice(lastIndex);
445
+ } else if (isGlob === true) {
446
+ base = "";
447
+ glob = str;
448
+ } else base = str;
449
+ if (base && base !== "" && base !== "/" && base !== str) {
450
+ if (isPathSeparator(base.charCodeAt(base.length - 1))) base = base.slice(0, -1);
451
+ }
452
+ if (opts.unescape === true) {
453
+ if (glob) glob = utils$3.removeBackslashes(glob);
454
+ if (base && backslashes === true) base = utils$3.removeBackslashes(base);
455
+ }
456
+ const state = {
457
+ prefix,
458
+ input,
459
+ start,
460
+ base,
461
+ glob,
462
+ isBrace,
463
+ isBracket,
464
+ isGlob,
465
+ isExtglob,
466
+ isGlobstar,
467
+ negated,
468
+ negatedExtglob
469
+ };
470
+ if (opts.tokens === true) {
471
+ state.maxDepth = 0;
472
+ if (!isPathSeparator(code)) tokens.push(token);
473
+ state.tokens = tokens;
474
+ }
475
+ if (opts.parts === true || opts.tokens === true) {
476
+ let prevIndex;
477
+ for (let idx = 0; idx < slashes.length; idx++) {
478
+ const n = prevIndex ? prevIndex + 1 : start;
479
+ const i = slashes[idx];
480
+ const value = input.slice(n, i);
481
+ if (opts.tokens) {
482
+ if (idx === 0 && start !== 0) {
483
+ tokens[idx].isPrefix = true;
484
+ tokens[idx].value = prefix;
485
+ } else tokens[idx].value = value;
486
+ depth(tokens[idx]);
487
+ state.maxDepth += tokens[idx].depth;
488
+ }
489
+ if (idx !== 0 || value !== "") parts.push(value);
490
+ prevIndex = i;
491
+ }
492
+ if (prevIndex && prevIndex + 1 < input.length) {
493
+ const value = input.slice(prevIndex + 1);
494
+ parts.push(value);
495
+ if (opts.tokens) {
496
+ tokens[tokens.length - 1].value = value;
497
+ depth(tokens[tokens.length - 1]);
498
+ state.maxDepth += tokens[tokens.length - 1].depth;
499
+ }
500
+ }
501
+ state.slashes = slashes;
502
+ state.parts = parts;
503
+ }
504
+ return state;
505
+ };
506
+ module.exports = scan$1;
507
+ }));
508
+
509
+ //#endregion
510
+ //#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.js
511
+ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
512
+ const constants$1 = require_constants();
513
+ const utils$2 = require_utils();
514
+ /**
515
+ * Constants
516
+ */
517
+ const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants$1;
518
+ /**
519
+ * Helpers
520
+ */
521
+ const expandRange = (args, options) => {
522
+ if (typeof options.expandRange === "function") return options.expandRange(...args, options);
523
+ args.sort();
524
+ const value = `[${args.join("-")}]`;
525
+ try {
526
+ new RegExp(value);
527
+ } catch (ex) {
528
+ return args.map((v) => utils$2.escapeRegex(v)).join("..");
529
+ }
530
+ return value;
531
+ };
532
+ /**
533
+ * Create the message for a syntax error
534
+ */
535
+ const syntaxError = (type, char) => {
536
+ return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
537
+ };
538
+ /**
539
+ * Parse the given input string.
540
+ * @param {String} input
541
+ * @param {Object} options
542
+ * @return {Object}
543
+ */
544
+ const parse$1 = (input, options) => {
545
+ if (typeof input !== "string") throw new TypeError("Expected a string");
546
+ input = REPLACEMENTS[input] || input;
547
+ const opts = { ...options };
548
+ const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
549
+ let len = input.length;
550
+ if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
551
+ const bos = {
552
+ type: "bos",
553
+ value: "",
554
+ output: opts.prepend || ""
555
+ };
556
+ const tokens = [bos];
557
+ const capture = opts.capture ? "" : "?:";
558
+ const PLATFORM_CHARS = constants$1.globChars(opts.windows);
559
+ const EXTGLOB_CHARS = constants$1.extglobChars(PLATFORM_CHARS);
560
+ const { DOT_LITERAL: DOT_LITERAL$1, PLUS_LITERAL: PLUS_LITERAL$1, SLASH_LITERAL: SLASH_LITERAL$1, ONE_CHAR: ONE_CHAR$1, DOTS_SLASH: DOTS_SLASH$1, NO_DOT, NO_DOT_SLASH, NO_DOTS_SLASH, QMARK: QMARK$1, QMARK_NO_DOT, STAR, START_ANCHOR: START_ANCHOR$1 } = PLATFORM_CHARS;
561
+ const globstar = (opts$1) => {
562
+ return `(${capture}(?:(?!${START_ANCHOR$1}${opts$1.dot ? DOTS_SLASH$1 : DOT_LITERAL$1}).)*?)`;
563
+ };
564
+ const nodot = opts.dot ? "" : NO_DOT;
565
+ const qmarkNoDot = opts.dot ? QMARK$1 : QMARK_NO_DOT;
566
+ let star = opts.bash === true ? globstar(opts) : STAR;
567
+ if (opts.capture) star = `(${star})`;
568
+ if (typeof opts.noext === "boolean") opts.noextglob = opts.noext;
569
+ const state = {
570
+ input,
571
+ index: -1,
572
+ start: 0,
573
+ dot: opts.dot === true,
574
+ consumed: "",
575
+ output: "",
576
+ prefix: "",
577
+ backtrack: false,
578
+ negated: false,
579
+ brackets: 0,
580
+ braces: 0,
581
+ parens: 0,
582
+ quotes: 0,
583
+ globstar: false,
584
+ tokens
585
+ };
586
+ input = utils$2.removePrefix(input, state);
587
+ len = input.length;
588
+ const extglobs = [];
589
+ const braces = [];
590
+ const stack = [];
591
+ let prev = bos;
592
+ let value;
593
+ /**
594
+ * Tokenizing helpers
595
+ */
596
+ const eos = () => state.index === len - 1;
597
+ const peek = state.peek = (n = 1) => input[state.index + n];
598
+ const advance = state.advance = () => input[++state.index] || "";
599
+ const remaining = () => input.slice(state.index + 1);
600
+ const consume = (value$1 = "", num = 0) => {
601
+ state.consumed += value$1;
602
+ state.index += num;
603
+ };
604
+ const append = (token) => {
605
+ state.output += token.output != null ? token.output : token.value;
606
+ consume(token.value);
607
+ };
608
+ const negate = () => {
609
+ let count = 1;
610
+ while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
611
+ advance();
612
+ state.start++;
613
+ count++;
614
+ }
615
+ if (count % 2 === 0) return false;
616
+ state.negated = true;
617
+ state.start++;
618
+ return true;
619
+ };
620
+ const increment = (type) => {
621
+ state[type]++;
622
+ stack.push(type);
623
+ };
624
+ const decrement = (type) => {
625
+ state[type]--;
626
+ stack.pop();
627
+ };
628
+ /**
629
+ * Push tokens onto the tokens array. This helper speeds up
630
+ * tokenizing by 1) helping us avoid backtracking as much as possible,
631
+ * and 2) helping us avoid creating extra tokens when consecutive
632
+ * characters are plain text. This improves performance and simplifies
633
+ * lookbehinds.
634
+ */
635
+ const push = (tok) => {
636
+ if (prev.type === "globstar") {
637
+ const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
638
+ const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
639
+ if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
640
+ state.output = state.output.slice(0, -prev.output.length);
641
+ prev.type = "star";
642
+ prev.value = "*";
643
+ prev.output = star;
644
+ state.output += prev.output;
645
+ }
646
+ }
647
+ if (extglobs.length && tok.type !== "paren") extglobs[extglobs.length - 1].inner += tok.value;
648
+ if (tok.value || tok.output) append(tok);
649
+ if (prev && prev.type === "text" && tok.type === "text") {
650
+ prev.output = (prev.output || prev.value) + tok.value;
651
+ prev.value += tok.value;
652
+ return;
653
+ }
654
+ tok.prev = prev;
655
+ tokens.push(tok);
656
+ prev = tok;
657
+ };
658
+ const extglobOpen = (type, value$1) => {
659
+ const token = {
660
+ ...EXTGLOB_CHARS[value$1],
661
+ conditions: 1,
662
+ inner: ""
663
+ };
664
+ token.prev = prev;
665
+ token.parens = state.parens;
666
+ token.output = state.output;
667
+ const output = (opts.capture ? "(" : "") + token.open;
668
+ increment("parens");
669
+ push({
670
+ type,
671
+ value: value$1,
672
+ output: state.output ? "" : ONE_CHAR$1
673
+ });
674
+ push({
675
+ type: "paren",
676
+ extglob: true,
677
+ value: advance(),
678
+ output
679
+ });
680
+ extglobs.push(token);
681
+ };
682
+ const extglobClose = (token) => {
683
+ let output = token.close + (opts.capture ? ")" : "");
684
+ let rest;
685
+ if (token.type === "negate") {
686
+ let extglobStar = star;
687
+ if (token.inner && token.inner.length > 1 && token.inner.includes("/")) extglobStar = globstar(opts);
688
+ if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) output = token.close = `)$))${extglobStar}`;
689
+ if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) output = token.close = `)${parse$1(rest, {
690
+ ...options,
691
+ fastpaths: false
692
+ }).output})${extglobStar})`;
693
+ if (token.prev.type === "bos") state.negatedExtglob = true;
694
+ }
695
+ push({
696
+ type: "paren",
697
+ extglob: true,
698
+ value,
699
+ output
700
+ });
701
+ decrement("parens");
702
+ };
703
+ /**
704
+ * Fast paths
705
+ */
706
+ if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
707
+ let backslashes = false;
708
+ let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
709
+ if (first === "\\") {
710
+ backslashes = true;
711
+ return m;
712
+ }
713
+ if (first === "?") {
714
+ if (esc) return esc + first + (rest ? QMARK$1.repeat(rest.length) : "");
715
+ if (index === 0) return qmarkNoDot + (rest ? QMARK$1.repeat(rest.length) : "");
716
+ return QMARK$1.repeat(chars.length);
717
+ }
718
+ if (first === ".") return DOT_LITERAL$1.repeat(chars.length);
719
+ if (first === "*") {
720
+ if (esc) return esc + first + (rest ? star : "");
721
+ return star;
722
+ }
723
+ return esc ? m : `\\${m}`;
724
+ });
725
+ if (backslashes === true) if (opts.unescape === true) output = output.replace(/\\/g, "");
726
+ else output = output.replace(/\\+/g, (m) => {
727
+ return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
728
+ });
729
+ if (output === input && opts.contains === true) {
730
+ state.output = input;
731
+ return state;
732
+ }
733
+ state.output = utils$2.wrapOutput(output, state, options);
734
+ return state;
735
+ }
736
+ /**
737
+ * Tokenize input until we reach end-of-string
738
+ */
739
+ while (!eos()) {
740
+ value = advance();
741
+ if (value === "\0") continue;
742
+ /**
743
+ * Escaped characters
744
+ */
745
+ if (value === "\\") {
746
+ const next = peek();
747
+ if (next === "/" && opts.bash !== true) continue;
748
+ if (next === "." || next === ";") continue;
749
+ if (!next) {
750
+ value += "\\";
751
+ push({
752
+ type: "text",
753
+ value
754
+ });
755
+ continue;
756
+ }
757
+ const match = /^\\+/.exec(remaining());
758
+ let slashes = 0;
759
+ if (match && match[0].length > 2) {
760
+ slashes = match[0].length;
761
+ state.index += slashes;
762
+ if (slashes % 2 !== 0) value += "\\";
763
+ }
764
+ if (opts.unescape === true) value = advance();
765
+ else value += advance();
766
+ if (state.brackets === 0) {
767
+ push({
768
+ type: "text",
769
+ value
770
+ });
771
+ continue;
772
+ }
773
+ }
774
+ /**
775
+ * If we're inside a regex character class, continue
776
+ * until we reach the closing bracket.
777
+ */
778
+ if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
779
+ if (opts.posix !== false && value === ":") {
780
+ const inner = prev.value.slice(1);
781
+ if (inner.includes("[")) {
782
+ prev.posix = true;
783
+ if (inner.includes(":")) {
784
+ const idx = prev.value.lastIndexOf("[");
785
+ const pre = prev.value.slice(0, idx);
786
+ const posix$1 = POSIX_REGEX_SOURCE[prev.value.slice(idx + 2)];
787
+ if (posix$1) {
788
+ prev.value = pre + posix$1;
789
+ state.backtrack = true;
790
+ advance();
791
+ if (!bos.output && tokens.indexOf(prev) === 1) bos.output = ONE_CHAR$1;
792
+ continue;
793
+ }
794
+ }
795
+ }
796
+ }
797
+ if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") value = `\\${value}`;
798
+ if (value === "]" && (prev.value === "[" || prev.value === "[^")) value = `\\${value}`;
799
+ if (opts.posix === true && value === "!" && prev.value === "[") value = "^";
800
+ prev.value += value;
801
+ append({ value });
802
+ continue;
803
+ }
804
+ /**
805
+ * If we're inside a quoted string, continue
806
+ * until we reach the closing double quote.
807
+ */
808
+ if (state.quotes === 1 && value !== "\"") {
809
+ value = utils$2.escapeRegex(value);
810
+ prev.value += value;
811
+ append({ value });
812
+ continue;
813
+ }
814
+ /**
815
+ * Double quotes
816
+ */
817
+ if (value === "\"") {
818
+ state.quotes = state.quotes === 1 ? 0 : 1;
819
+ if (opts.keepQuotes === true) push({
820
+ type: "text",
821
+ value
822
+ });
823
+ continue;
824
+ }
825
+ /**
826
+ * Parentheses
827
+ */
828
+ if (value === "(") {
829
+ increment("parens");
830
+ push({
831
+ type: "paren",
832
+ value
833
+ });
834
+ continue;
835
+ }
836
+ if (value === ")") {
837
+ if (state.parens === 0 && opts.strictBrackets === true) throw new SyntaxError(syntaxError("opening", "("));
838
+ const extglob = extglobs[extglobs.length - 1];
839
+ if (extglob && state.parens === extglob.parens + 1) {
840
+ extglobClose(extglobs.pop());
841
+ continue;
842
+ }
843
+ push({
844
+ type: "paren",
845
+ value,
846
+ output: state.parens ? ")" : "\\)"
847
+ });
848
+ decrement("parens");
849
+ continue;
850
+ }
851
+ /**
852
+ * Square brackets
853
+ */
854
+ if (value === "[") {
855
+ if (opts.nobracket === true || !remaining().includes("]")) {
856
+ if (opts.nobracket !== true && opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
857
+ value = `\\${value}`;
858
+ } else increment("brackets");
859
+ push({
860
+ type: "bracket",
861
+ value
862
+ });
863
+ continue;
864
+ }
865
+ if (value === "]") {
866
+ if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
867
+ push({
868
+ type: "text",
869
+ value,
870
+ output: `\\${value}`
871
+ });
872
+ continue;
873
+ }
874
+ if (state.brackets === 0) {
875
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("opening", "["));
876
+ push({
877
+ type: "text",
878
+ value,
879
+ output: `\\${value}`
880
+ });
881
+ continue;
882
+ }
883
+ decrement("brackets");
884
+ const prevValue = prev.value.slice(1);
885
+ if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) value = `/${value}`;
886
+ prev.value += value;
887
+ append({ value });
888
+ if (opts.literalBrackets === false || utils$2.hasRegexChars(prevValue)) continue;
889
+ const escaped = utils$2.escapeRegex(prev.value);
890
+ state.output = state.output.slice(0, -prev.value.length);
891
+ if (opts.literalBrackets === true) {
892
+ state.output += escaped;
893
+ prev.value = escaped;
894
+ continue;
895
+ }
896
+ prev.value = `(${capture}${escaped}|${prev.value})`;
897
+ state.output += prev.value;
898
+ continue;
899
+ }
900
+ /**
901
+ * Braces
902
+ */
903
+ if (value === "{" && opts.nobrace !== true) {
904
+ increment("braces");
905
+ const open = {
906
+ type: "brace",
907
+ value,
908
+ output: "(",
909
+ outputIndex: state.output.length,
910
+ tokensIndex: state.tokens.length
911
+ };
912
+ braces.push(open);
913
+ push(open);
914
+ continue;
915
+ }
916
+ if (value === "}") {
917
+ const brace = braces[braces.length - 1];
918
+ if (opts.nobrace === true || !brace) {
919
+ push({
920
+ type: "text",
921
+ value,
922
+ output: value
923
+ });
924
+ continue;
925
+ }
926
+ let output = ")";
927
+ if (brace.dots === true) {
928
+ const arr = tokens.slice();
929
+ const range = [];
930
+ for (let i = arr.length - 1; i >= 0; i--) {
931
+ tokens.pop();
932
+ if (arr[i].type === "brace") break;
933
+ if (arr[i].type !== "dots") range.unshift(arr[i].value);
934
+ }
935
+ output = expandRange(range, opts);
936
+ state.backtrack = true;
937
+ }
938
+ if (brace.comma !== true && brace.dots !== true) {
939
+ const out = state.output.slice(0, brace.outputIndex);
940
+ const toks = state.tokens.slice(brace.tokensIndex);
941
+ brace.value = brace.output = "\\{";
942
+ value = output = "\\}";
943
+ state.output = out;
944
+ for (const t of toks) state.output += t.output || t.value;
945
+ }
946
+ push({
947
+ type: "brace",
948
+ value,
949
+ output
950
+ });
951
+ decrement("braces");
952
+ braces.pop();
953
+ continue;
954
+ }
955
+ /**
956
+ * Pipes
957
+ */
958
+ if (value === "|") {
959
+ if (extglobs.length > 0) extglobs[extglobs.length - 1].conditions++;
960
+ push({
961
+ type: "text",
962
+ value
963
+ });
964
+ continue;
965
+ }
966
+ /**
967
+ * Commas
968
+ */
969
+ if (value === ",") {
970
+ let output = value;
971
+ const brace = braces[braces.length - 1];
972
+ if (brace && stack[stack.length - 1] === "braces") {
973
+ brace.comma = true;
974
+ output = "|";
975
+ }
976
+ push({
977
+ type: "comma",
978
+ value,
979
+ output
980
+ });
981
+ continue;
982
+ }
983
+ /**
984
+ * Slashes
985
+ */
986
+ if (value === "/") {
987
+ if (prev.type === "dot" && state.index === state.start + 1) {
988
+ state.start = state.index + 1;
989
+ state.consumed = "";
990
+ state.output = "";
991
+ tokens.pop();
992
+ prev = bos;
993
+ continue;
994
+ }
995
+ push({
996
+ type: "slash",
997
+ value,
998
+ output: SLASH_LITERAL$1
999
+ });
1000
+ continue;
1001
+ }
1002
+ /**
1003
+ * Dots
1004
+ */
1005
+ if (value === ".") {
1006
+ if (state.braces > 0 && prev.type === "dot") {
1007
+ if (prev.value === ".") prev.output = DOT_LITERAL$1;
1008
+ const brace = braces[braces.length - 1];
1009
+ prev.type = "dots";
1010
+ prev.output += value;
1011
+ prev.value += value;
1012
+ brace.dots = true;
1013
+ continue;
1014
+ }
1015
+ if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
1016
+ push({
1017
+ type: "text",
1018
+ value,
1019
+ output: DOT_LITERAL$1
1020
+ });
1021
+ continue;
1022
+ }
1023
+ push({
1024
+ type: "dot",
1025
+ value,
1026
+ output: DOT_LITERAL$1
1027
+ });
1028
+ continue;
1029
+ }
1030
+ /**
1031
+ * Question marks
1032
+ */
1033
+ if (value === "?") {
1034
+ if (!(prev && prev.value === "(") && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1035
+ extglobOpen("qmark", value);
1036
+ continue;
1037
+ }
1038
+ if (prev && prev.type === "paren") {
1039
+ const next = peek();
1040
+ let output = value;
1041
+ if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) output = `\\${value}`;
1042
+ push({
1043
+ type: "text",
1044
+ value,
1045
+ output
1046
+ });
1047
+ continue;
1048
+ }
1049
+ if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
1050
+ push({
1051
+ type: "qmark",
1052
+ value,
1053
+ output: QMARK_NO_DOT
1054
+ });
1055
+ continue;
1056
+ }
1057
+ push({
1058
+ type: "qmark",
1059
+ value,
1060
+ output: QMARK$1
1061
+ });
1062
+ continue;
1063
+ }
1064
+ /**
1065
+ * Exclamation
1066
+ */
1067
+ if (value === "!") {
1068
+ if (opts.noextglob !== true && peek() === "(") {
1069
+ if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
1070
+ extglobOpen("negate", value);
1071
+ continue;
1072
+ }
1073
+ }
1074
+ if (opts.nonegate !== true && state.index === 0) {
1075
+ negate();
1076
+ continue;
1077
+ }
1078
+ }
1079
+ /**
1080
+ * Plus
1081
+ */
1082
+ if (value === "+") {
1083
+ if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1084
+ extglobOpen("plus", value);
1085
+ continue;
1086
+ }
1087
+ if (prev && prev.value === "(" || opts.regex === false) {
1088
+ push({
1089
+ type: "plus",
1090
+ value,
1091
+ output: PLUS_LITERAL$1
1092
+ });
1093
+ continue;
1094
+ }
1095
+ if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
1096
+ push({
1097
+ type: "plus",
1098
+ value
1099
+ });
1100
+ continue;
1101
+ }
1102
+ push({
1103
+ type: "plus",
1104
+ value: PLUS_LITERAL$1
1105
+ });
1106
+ continue;
1107
+ }
1108
+ /**
1109
+ * Plain text
1110
+ */
1111
+ if (value === "@") {
1112
+ if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1113
+ push({
1114
+ type: "at",
1115
+ extglob: true,
1116
+ value,
1117
+ output: ""
1118
+ });
1119
+ continue;
1120
+ }
1121
+ push({
1122
+ type: "text",
1123
+ value
1124
+ });
1125
+ continue;
1126
+ }
1127
+ /**
1128
+ * Plain text
1129
+ */
1130
+ if (value !== "*") {
1131
+ if (value === "$" || value === "^") value = `\\${value}`;
1132
+ const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
1133
+ if (match) {
1134
+ value += match[0];
1135
+ state.index += match[0].length;
1136
+ }
1137
+ push({
1138
+ type: "text",
1139
+ value
1140
+ });
1141
+ continue;
1142
+ }
1143
+ /**
1144
+ * Stars
1145
+ */
1146
+ if (prev && (prev.type === "globstar" || prev.star === true)) {
1147
+ prev.type = "star";
1148
+ prev.star = true;
1149
+ prev.value += value;
1150
+ prev.output = star;
1151
+ state.backtrack = true;
1152
+ state.globstar = true;
1153
+ consume(value);
1154
+ continue;
1155
+ }
1156
+ let rest = remaining();
1157
+ if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
1158
+ extglobOpen("star", value);
1159
+ continue;
1160
+ }
1161
+ if (prev.type === "star") {
1162
+ if (opts.noglobstar === true) {
1163
+ consume(value);
1164
+ continue;
1165
+ }
1166
+ const prior = prev.prev;
1167
+ const before = prior.prev;
1168
+ const isStart = prior.type === "slash" || prior.type === "bos";
1169
+ const afterStar = before && (before.type === "star" || before.type === "globstar");
1170
+ if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
1171
+ push({
1172
+ type: "star",
1173
+ value,
1174
+ output: ""
1175
+ });
1176
+ continue;
1177
+ }
1178
+ const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
1179
+ const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
1180
+ if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
1181
+ push({
1182
+ type: "star",
1183
+ value,
1184
+ output: ""
1185
+ });
1186
+ continue;
1187
+ }
1188
+ while (rest.slice(0, 3) === "/**") {
1189
+ const after = input[state.index + 4];
1190
+ if (after && after !== "/") break;
1191
+ rest = rest.slice(3);
1192
+ consume("/**", 3);
1193
+ }
1194
+ if (prior.type === "bos" && eos()) {
1195
+ prev.type = "globstar";
1196
+ prev.value += value;
1197
+ prev.output = globstar(opts);
1198
+ state.output = prev.output;
1199
+ state.globstar = true;
1200
+ consume(value);
1201
+ continue;
1202
+ }
1203
+ if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
1204
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
1205
+ prior.output = `(?:${prior.output}`;
1206
+ prev.type = "globstar";
1207
+ prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
1208
+ prev.value += value;
1209
+ state.globstar = true;
1210
+ state.output += prior.output + prev.output;
1211
+ consume(value);
1212
+ continue;
1213
+ }
1214
+ if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
1215
+ const end = rest[1] !== void 0 ? "|$" : "";
1216
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
1217
+ prior.output = `(?:${prior.output}`;
1218
+ prev.type = "globstar";
1219
+ prev.output = `${globstar(opts)}${SLASH_LITERAL$1}|${SLASH_LITERAL$1}${end})`;
1220
+ prev.value += value;
1221
+ state.output += prior.output + prev.output;
1222
+ state.globstar = true;
1223
+ consume(value + advance());
1224
+ push({
1225
+ type: "slash",
1226
+ value: "/",
1227
+ output: ""
1228
+ });
1229
+ continue;
1230
+ }
1231
+ if (prior.type === "bos" && rest[0] === "/") {
1232
+ prev.type = "globstar";
1233
+ prev.value += value;
1234
+ prev.output = `(?:^|${SLASH_LITERAL$1}|${globstar(opts)}${SLASH_LITERAL$1})`;
1235
+ state.output = prev.output;
1236
+ state.globstar = true;
1237
+ consume(value + advance());
1238
+ push({
1239
+ type: "slash",
1240
+ value: "/",
1241
+ output: ""
1242
+ });
1243
+ continue;
1244
+ }
1245
+ state.output = state.output.slice(0, -prev.output.length);
1246
+ prev.type = "globstar";
1247
+ prev.output = globstar(opts);
1248
+ prev.value += value;
1249
+ state.output += prev.output;
1250
+ state.globstar = true;
1251
+ consume(value);
1252
+ continue;
1253
+ }
1254
+ const token = {
1255
+ type: "star",
1256
+ value,
1257
+ output: star
1258
+ };
1259
+ if (opts.bash === true) {
1260
+ token.output = ".*?";
1261
+ if (prev.type === "bos" || prev.type === "slash") token.output = nodot + token.output;
1262
+ push(token);
1263
+ continue;
1264
+ }
1265
+ if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
1266
+ token.output = value;
1267
+ push(token);
1268
+ continue;
1269
+ }
1270
+ if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
1271
+ if (prev.type === "dot") {
1272
+ state.output += NO_DOT_SLASH;
1273
+ prev.output += NO_DOT_SLASH;
1274
+ } else if (opts.dot === true) {
1275
+ state.output += NO_DOTS_SLASH;
1276
+ prev.output += NO_DOTS_SLASH;
1277
+ } else {
1278
+ state.output += nodot;
1279
+ prev.output += nodot;
1280
+ }
1281
+ if (peek() !== "*") {
1282
+ state.output += ONE_CHAR$1;
1283
+ prev.output += ONE_CHAR$1;
1284
+ }
1285
+ }
1286
+ push(token);
1287
+ }
1288
+ while (state.brackets > 0) {
1289
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
1290
+ state.output = utils$2.escapeLast(state.output, "[");
1291
+ decrement("brackets");
1292
+ }
1293
+ while (state.parens > 0) {
1294
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
1295
+ state.output = utils$2.escapeLast(state.output, "(");
1296
+ decrement("parens");
1297
+ }
1298
+ while (state.braces > 0) {
1299
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
1300
+ state.output = utils$2.escapeLast(state.output, "{");
1301
+ decrement("braces");
1302
+ }
1303
+ if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) push({
1304
+ type: "maybe_slash",
1305
+ value: "",
1306
+ output: `${SLASH_LITERAL$1}?`
1307
+ });
1308
+ if (state.backtrack === true) {
1309
+ state.output = "";
1310
+ for (const token of state.tokens) {
1311
+ state.output += token.output != null ? token.output : token.value;
1312
+ if (token.suffix) state.output += token.suffix;
1313
+ }
1314
+ }
1315
+ return state;
1316
+ };
1317
+ /**
1318
+ * Fast paths for creating regular expressions for common glob patterns.
1319
+ * This can significantly speed up processing and has very little downside
1320
+ * impact when none of the fast paths match.
1321
+ */
1322
+ parse$1.fastpaths = (input, options) => {
1323
+ const opts = { ...options };
1324
+ const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
1325
+ const len = input.length;
1326
+ if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
1327
+ input = REPLACEMENTS[input] || input;
1328
+ const { DOT_LITERAL: DOT_LITERAL$1, SLASH_LITERAL: SLASH_LITERAL$1, ONE_CHAR: ONE_CHAR$1, DOTS_SLASH: DOTS_SLASH$1, NO_DOT, NO_DOTS, NO_DOTS_SLASH, STAR, START_ANCHOR: START_ANCHOR$1 } = constants$1.globChars(opts.windows);
1329
+ const nodot = opts.dot ? NO_DOTS : NO_DOT;
1330
+ const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
1331
+ const capture = opts.capture ? "" : "?:";
1332
+ const state = {
1333
+ negated: false,
1334
+ prefix: ""
1335
+ };
1336
+ let star = opts.bash === true ? ".*?" : STAR;
1337
+ if (opts.capture) star = `(${star})`;
1338
+ const globstar = (opts$1) => {
1339
+ if (opts$1.noglobstar === true) return star;
1340
+ return `(${capture}(?:(?!${START_ANCHOR$1}${opts$1.dot ? DOTS_SLASH$1 : DOT_LITERAL$1}).)*?)`;
1341
+ };
1342
+ const create = (str) => {
1343
+ switch (str) {
1344
+ case "*": return `${nodot}${ONE_CHAR$1}${star}`;
1345
+ case ".*": return `${DOT_LITERAL$1}${ONE_CHAR$1}${star}`;
1346
+ case "*.*": return `${nodot}${star}${DOT_LITERAL$1}${ONE_CHAR$1}${star}`;
1347
+ case "*/*": return `${nodot}${star}${SLASH_LITERAL$1}${ONE_CHAR$1}${slashDot}${star}`;
1348
+ case "**": return nodot + globstar(opts);
1349
+ case "**/*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL$1})?${slashDot}${ONE_CHAR$1}${star}`;
1350
+ case "**/*.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL$1})?${slashDot}${star}${DOT_LITERAL$1}${ONE_CHAR$1}${star}`;
1351
+ case "**/.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL$1})?${DOT_LITERAL$1}${ONE_CHAR$1}${star}`;
1352
+ default: {
1353
+ const match = /^(.*?)\.(\w+)$/.exec(str);
1354
+ if (!match) return;
1355
+ const source$1 = create(match[1]);
1356
+ if (!source$1) return;
1357
+ return source$1 + DOT_LITERAL$1 + match[2];
1358
+ }
1359
+ }
1360
+ };
1361
+ let source = create(utils$2.removePrefix(input, state));
1362
+ if (source && opts.strictSlashes !== true) source += `${SLASH_LITERAL$1}?`;
1363
+ return source;
1364
+ };
1365
+ module.exports = parse$1;
1366
+ }));
1367
+
1368
+ //#endregion
1369
+ //#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js
1370
+ var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1371
+ const scan = require_scan();
1372
+ const parse = require_parse();
1373
+ const utils$1 = require_utils();
1374
+ const constants = require_constants();
1375
+ const isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
1376
+ /**
1377
+ * Creates a matcher function from one or more glob patterns. The
1378
+ * returned function takes a string to match as its first argument,
1379
+ * and returns true if the string is a match. The returned matcher
1380
+ * function also takes a boolean as the second argument that, when true,
1381
+ * returns an object with additional information.
1382
+ *
1383
+ * ```js
1384
+ * const picomatch = require('picomatch');
1385
+ * // picomatch(glob[, options]);
1386
+ *
1387
+ * const isMatch = picomatch('*.!(*a)');
1388
+ * console.log(isMatch('a.a')); //=> false
1389
+ * console.log(isMatch('a.b')); //=> true
1390
+ * ```
1391
+ * @name picomatch
1392
+ * @param {String|Array} `globs` One or more glob patterns.
1393
+ * @param {Object=} `options`
1394
+ * @return {Function=} Returns a matcher function.
1395
+ * @api public
1396
+ */
1397
+ const picomatch$1 = (glob, options, returnState = false) => {
1398
+ if (Array.isArray(glob)) {
1399
+ const fns = glob.map((input) => picomatch$1(input, options, returnState));
1400
+ const arrayMatcher = (str) => {
1401
+ for (const isMatch of fns) {
1402
+ const state$1 = isMatch(str);
1403
+ if (state$1) return state$1;
1404
+ }
1405
+ return false;
1406
+ };
1407
+ return arrayMatcher;
1408
+ }
1409
+ const isState = isObject(glob) && glob.tokens && glob.input;
1410
+ if (glob === "" || typeof glob !== "string" && !isState) throw new TypeError("Expected pattern to be a non-empty string");
1411
+ const opts = options || {};
1412
+ const posix$1 = opts.windows;
1413
+ const regex = isState ? picomatch$1.compileRe(glob, options) : picomatch$1.makeRe(glob, options, false, true);
1414
+ const state = regex.state;
1415
+ delete regex.state;
1416
+ let isIgnored = () => false;
1417
+ if (opts.ignore) {
1418
+ const ignoreOpts = {
1419
+ ...options,
1420
+ ignore: null,
1421
+ onMatch: null,
1422
+ onResult: null
1423
+ };
1424
+ isIgnored = picomatch$1(opts.ignore, ignoreOpts, returnState);
1425
+ }
1426
+ const matcher = (input, returnObject = false) => {
1427
+ const { isMatch, match, output } = picomatch$1.test(input, regex, options, {
1428
+ glob,
1429
+ posix: posix$1
1430
+ });
1431
+ const result = {
1432
+ glob,
1433
+ state,
1434
+ regex,
1435
+ posix: posix$1,
1436
+ input,
1437
+ output,
1438
+ match,
1439
+ isMatch
1440
+ };
1441
+ if (typeof opts.onResult === "function") opts.onResult(result);
1442
+ if (isMatch === false) {
1443
+ result.isMatch = false;
1444
+ return returnObject ? result : false;
1445
+ }
1446
+ if (isIgnored(input)) {
1447
+ if (typeof opts.onIgnore === "function") opts.onIgnore(result);
1448
+ result.isMatch = false;
1449
+ return returnObject ? result : false;
1450
+ }
1451
+ if (typeof opts.onMatch === "function") opts.onMatch(result);
1452
+ return returnObject ? result : true;
1453
+ };
1454
+ if (returnState) matcher.state = state;
1455
+ return matcher;
1456
+ };
1457
+ /**
1458
+ * Test `input` with the given `regex`. This is used by the main
1459
+ * `picomatch()` function to test the input string.
1460
+ *
1461
+ * ```js
1462
+ * const picomatch = require('picomatch');
1463
+ * // picomatch.test(input, regex[, options]);
1464
+ *
1465
+ * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
1466
+ * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
1467
+ * ```
1468
+ * @param {String} `input` String to test.
1469
+ * @param {RegExp} `regex`
1470
+ * @return {Object} Returns an object with matching info.
1471
+ * @api public
1472
+ */
1473
+ picomatch$1.test = (input, regex, options, { glob, posix: posix$1 } = {}) => {
1474
+ if (typeof input !== "string") throw new TypeError("Expected input to be a string");
1475
+ if (input === "") return {
1476
+ isMatch: false,
1477
+ output: ""
1478
+ };
1479
+ const opts = options || {};
1480
+ const format = opts.format || (posix$1 ? utils$1.toPosixSlashes : null);
1481
+ let match = input === glob;
1482
+ let output = match && format ? format(input) : input;
1483
+ if (match === false) {
1484
+ output = format ? format(input) : input;
1485
+ match = output === glob;
1486
+ }
1487
+ if (match === false || opts.capture === true) if (opts.matchBase === true || opts.basename === true) match = picomatch$1.matchBase(input, regex, options, posix$1);
1488
+ else match = regex.exec(output);
1489
+ return {
1490
+ isMatch: Boolean(match),
1491
+ match,
1492
+ output
1493
+ };
1494
+ };
1495
+ /**
1496
+ * Match the basename of a filepath.
1497
+ *
1498
+ * ```js
1499
+ * const picomatch = require('picomatch');
1500
+ * // picomatch.matchBase(input, glob[, options]);
1501
+ * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
1502
+ * ```
1503
+ * @param {String} `input` String to test.
1504
+ * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
1505
+ * @return {Boolean}
1506
+ * @api public
1507
+ */
1508
+ picomatch$1.matchBase = (input, glob, options) => {
1509
+ return (glob instanceof RegExp ? glob : picomatch$1.makeRe(glob, options)).test(utils$1.basename(input));
1510
+ };
1511
+ /**
1512
+ * Returns true if **any** of the given glob `patterns` match the specified `string`.
1513
+ *
1514
+ * ```js
1515
+ * const picomatch = require('picomatch');
1516
+ * // picomatch.isMatch(string, patterns[, options]);
1517
+ *
1518
+ * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
1519
+ * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
1520
+ * ```
1521
+ * @param {String|Array} str The string to test.
1522
+ * @param {String|Array} patterns One or more glob patterns to use for matching.
1523
+ * @param {Object} [options] See available [options](#options).
1524
+ * @return {Boolean} Returns true if any patterns match `str`
1525
+ * @api public
1526
+ */
1527
+ picomatch$1.isMatch = (str, patterns, options) => picomatch$1(patterns, options)(str);
1528
+ /**
1529
+ * Parse a glob pattern to create the source string for a regular
1530
+ * expression.
1531
+ *
1532
+ * ```js
1533
+ * const picomatch = require('picomatch');
1534
+ * const result = picomatch.parse(pattern[, options]);
1535
+ * ```
1536
+ * @param {String} `pattern`
1537
+ * @param {Object} `options`
1538
+ * @return {Object} Returns an object with useful properties and output to be used as a regex source string.
1539
+ * @api public
1540
+ */
1541
+ picomatch$1.parse = (pattern, options) => {
1542
+ if (Array.isArray(pattern)) return pattern.map((p) => picomatch$1.parse(p, options));
1543
+ return parse(pattern, {
1544
+ ...options,
1545
+ fastpaths: false
1546
+ });
1547
+ };
1548
+ /**
1549
+ * Scan a glob pattern to separate the pattern into segments.
1550
+ *
1551
+ * ```js
1552
+ * const picomatch = require('picomatch');
1553
+ * // picomatch.scan(input[, options]);
1554
+ *
1555
+ * const result = picomatch.scan('!./foo/*.js');
1556
+ * console.log(result);
1557
+ * { prefix: '!./',
1558
+ * input: '!./foo/*.js',
1559
+ * start: 3,
1560
+ * base: 'foo',
1561
+ * glob: '*.js',
1562
+ * isBrace: false,
1563
+ * isBracket: false,
1564
+ * isGlob: true,
1565
+ * isExtglob: false,
1566
+ * isGlobstar: false,
1567
+ * negated: true }
1568
+ * ```
1569
+ * @param {String} `input` Glob pattern to scan.
1570
+ * @param {Object} `options`
1571
+ * @return {Object} Returns an object with
1572
+ * @api public
1573
+ */
1574
+ picomatch$1.scan = (input, options) => scan(input, options);
1575
+ /**
1576
+ * Compile a regular expression from the `state` object returned by the
1577
+ * [parse()](#parse) method.
1578
+ *
1579
+ * @param {Object} `state`
1580
+ * @param {Object} `options`
1581
+ * @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
1582
+ * @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
1583
+ * @return {RegExp}
1584
+ * @api public
1585
+ */
1586
+ picomatch$1.compileRe = (state, options, returnOutput = false, returnState = false) => {
1587
+ if (returnOutput === true) return state.output;
1588
+ const opts = options || {};
1589
+ const prepend = opts.contains ? "" : "^";
1590
+ const append = opts.contains ? "" : "$";
1591
+ let source = `${prepend}(?:${state.output})${append}`;
1592
+ if (state && state.negated === true) source = `^(?!${source}).*$`;
1593
+ const regex = picomatch$1.toRegex(source, options);
1594
+ if (returnState === true) regex.state = state;
1595
+ return regex;
1596
+ };
1597
+ /**
1598
+ * Create a regular expression from a parsed glob pattern.
1599
+ *
1600
+ * ```js
1601
+ * const picomatch = require('picomatch');
1602
+ * const state = picomatch.parse('*.js');
1603
+ * // picomatch.compileRe(state[, options]);
1604
+ *
1605
+ * console.log(picomatch.compileRe(state));
1606
+ * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
1607
+ * ```
1608
+ * @param {String} `state` The object returned from the `.parse` method.
1609
+ * @param {Object} `options`
1610
+ * @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
1611
+ * @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
1612
+ * @return {RegExp} Returns a regex created from the given pattern.
1613
+ * @api public
1614
+ */
1615
+ picomatch$1.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
1616
+ if (!input || typeof input !== "string") throw new TypeError("Expected a non-empty string");
1617
+ let parsed = {
1618
+ negated: false,
1619
+ fastpaths: true
1620
+ };
1621
+ if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) parsed.output = parse.fastpaths(input, options);
1622
+ if (!parsed.output) parsed = parse(input, options);
1623
+ return picomatch$1.compileRe(parsed, options, returnOutput, returnState);
1624
+ };
1625
+ /**
1626
+ * Create a regular expression from the given regex source string.
1627
+ *
1628
+ * ```js
1629
+ * const picomatch = require('picomatch');
1630
+ * // picomatch.toRegex(source[, options]);
1631
+ *
1632
+ * const { output } = picomatch.parse('*.js');
1633
+ * console.log(picomatch.toRegex(output));
1634
+ * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
1635
+ * ```
1636
+ * @param {String} `source` Regular expression source string.
1637
+ * @param {Object} `options`
1638
+ * @return {RegExp}
1639
+ * @api public
1640
+ */
1641
+ picomatch$1.toRegex = (source, options) => {
1642
+ try {
1643
+ const opts = options || {};
1644
+ return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
1645
+ } catch (err) {
1646
+ if (options && options.debug === true) throw err;
1647
+ return /$^/;
1648
+ }
1649
+ };
1650
+ /**
1651
+ * Picomatch constants.
1652
+ * @return {Object}
1653
+ */
1654
+ picomatch$1.constants = constants;
1655
+ /**
1656
+ * Expose "picomatch"
1657
+ */
1658
+ module.exports = picomatch$1;
1659
+ }));
1660
+
1661
+ //#endregion
1662
+ //#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js
1663
+ var require_picomatch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1664
+ const pico = require_picomatch$1();
1665
+ const utils = require_utils();
1666
+ function picomatch(glob, options, returnState = false) {
1667
+ if (options && (options.windows === null || options.windows === void 0)) options = {
1668
+ ...options,
1669
+ windows: utils.isWindows()
1670
+ };
1671
+ return pico(glob, options, returnState);
1672
+ }
1673
+ Object.assign(picomatch, pico);
1674
+ module.exports = picomatch;
1675
+ }));
1676
+
1677
+ //#endregion
1678
+ //#region node_modules/.pnpm/fdir@6.5.0_picomatch@4.0.3/node_modules/fdir/dist/index.mjs
1679
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
1680
+ function cleanPath(path$2) {
1681
+ let normalized = normalize(path$2);
1682
+ if (normalized.length > 1 && normalized[normalized.length - 1] === sep) normalized = normalized.substring(0, normalized.length - 1);
1683
+ return normalized;
1684
+ }
1685
+ const SLASHES_REGEX = /[\\/]/g;
1686
+ function convertSlashes(path$2, separator) {
1687
+ return path$2.replace(SLASHES_REGEX, separator);
1688
+ }
1689
+ const WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
1690
+ function isRootDirectory(path$2) {
1691
+ return path$2 === "/" || WINDOWS_ROOT_DIR_REGEX.test(path$2);
1692
+ }
1693
+ function normalizePath$1(path$2, options) {
1694
+ const { resolvePaths, normalizePath: normalizePath$1$1, pathSeparator } = options;
1695
+ const pathNeedsCleaning = process.platform === "win32" && path$2.includes("/") || path$2.startsWith(".");
1696
+ if (resolvePaths) path$2 = resolve(path$2);
1697
+ if (normalizePath$1$1 || pathNeedsCleaning) path$2 = cleanPath(path$2);
1698
+ if (path$2 === ".") return "";
1699
+ return convertSlashes(path$2[path$2.length - 1] !== pathSeparator ? path$2 + pathSeparator : path$2, pathSeparator);
1700
+ }
1701
+ function joinPathWithBasePath(filename, directoryPath) {
1702
+ return directoryPath + filename;
1703
+ }
1704
+ function joinPathWithRelativePath(root, options) {
1705
+ return function(filename, directoryPath) {
1706
+ if (directoryPath.startsWith(root)) return directoryPath.slice(root.length) + filename;
1707
+ else return convertSlashes(relative(root, directoryPath), options.pathSeparator) + options.pathSeparator + filename;
1708
+ };
1709
+ }
1710
+ function joinPath(filename) {
1711
+ return filename;
1712
+ }
1713
+ function joinDirectoryPath(filename, directoryPath, separator) {
1714
+ return directoryPath + filename + separator;
1715
+ }
1716
+ function build$7(root, options) {
1717
+ const { relativePaths, includeBasePath } = options;
1718
+ return relativePaths && root ? joinPathWithRelativePath(root, options) : includeBasePath ? joinPathWithBasePath : joinPath;
1719
+ }
1720
+ function pushDirectoryWithRelativePath(root) {
1721
+ return function(directoryPath, paths) {
1722
+ paths.push(directoryPath.substring(root.length) || ".");
1723
+ };
1724
+ }
1725
+ function pushDirectoryFilterWithRelativePath(root) {
1726
+ return function(directoryPath, paths, filters) {
1727
+ const relativePath = directoryPath.substring(root.length) || ".";
1728
+ if (filters.every((filter) => filter(relativePath, true))) paths.push(relativePath);
1729
+ };
1730
+ }
1731
+ const pushDirectory = (directoryPath, paths) => {
1732
+ paths.push(directoryPath || ".");
1733
+ };
1734
+ const pushDirectoryFilter = (directoryPath, paths, filters) => {
1735
+ const path$2 = directoryPath || ".";
1736
+ if (filters.every((filter) => filter(path$2, true))) paths.push(path$2);
1737
+ };
1738
+ const empty$2 = () => {};
1739
+ function build$6(root, options) {
1740
+ const { includeDirs, filters, relativePaths } = options;
1741
+ if (!includeDirs) return empty$2;
1742
+ if (relativePaths) return filters && filters.length ? pushDirectoryFilterWithRelativePath(root) : pushDirectoryWithRelativePath(root);
1743
+ return filters && filters.length ? pushDirectoryFilter : pushDirectory;
1744
+ }
1745
+ const pushFileFilterAndCount = (filename, _paths, counts, filters) => {
1746
+ if (filters.every((filter) => filter(filename, false))) counts.files++;
1747
+ };
1748
+ const pushFileFilter = (filename, paths, _counts, filters) => {
1749
+ if (filters.every((filter) => filter(filename, false))) paths.push(filename);
1750
+ };
1751
+ const pushFileCount = (_filename, _paths, counts, _filters) => {
1752
+ counts.files++;
1753
+ };
1754
+ const pushFile = (filename, paths) => {
1755
+ paths.push(filename);
1756
+ };
1757
+ const empty$1 = () => {};
1758
+ function build$5(options) {
1759
+ const { excludeFiles, filters, onlyCounts } = options;
1760
+ if (excludeFiles) return empty$1;
1761
+ if (filters && filters.length) return onlyCounts ? pushFileFilterAndCount : pushFileFilter;
1762
+ else if (onlyCounts) return pushFileCount;
1763
+ else return pushFile;
1764
+ }
1765
+ const getArray = (paths) => {
1766
+ return paths;
1767
+ };
1768
+ const getArrayGroup = () => {
1769
+ return [""].slice(0, 0);
1770
+ };
1771
+ function build$4(options) {
1772
+ return options.group ? getArrayGroup : getArray;
1773
+ }
1774
+ const groupFiles = (groups, directory, files) => {
1775
+ groups.push({
1776
+ directory,
1777
+ files,
1778
+ dir: directory
1779
+ });
1780
+ };
1781
+ const empty = () => {};
1782
+ function build$3(options) {
1783
+ return options.group ? groupFiles : empty;
1784
+ }
1785
+ const resolveSymlinksAsync = function(path$2, state, callback$1) {
1786
+ const { queue, fs, options: { suppressErrors } } = state;
1787
+ queue.enqueue();
1788
+ fs.realpath(path$2, (error, resolvedPath) => {
1789
+ if (error) return queue.dequeue(suppressErrors ? null : error, state);
1790
+ fs.stat(resolvedPath, (error$1, stat$1) => {
1791
+ if (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);
1792
+ if (stat$1.isDirectory() && isRecursive(path$2, resolvedPath, state)) return queue.dequeue(null, state);
1793
+ callback$1(stat$1, resolvedPath);
1794
+ queue.dequeue(null, state);
1795
+ });
1796
+ });
1797
+ };
1798
+ const resolveSymlinks = function(path$2, state, callback$1) {
1799
+ const { queue, fs, options: { suppressErrors } } = state;
1800
+ queue.enqueue();
1801
+ try {
1802
+ const resolvedPath = fs.realpathSync(path$2);
1803
+ const stat$1 = fs.statSync(resolvedPath);
1804
+ if (stat$1.isDirectory() && isRecursive(path$2, resolvedPath, state)) return;
1805
+ callback$1(stat$1, resolvedPath);
1806
+ } catch (e) {
1807
+ if (!suppressErrors) throw e;
1808
+ }
1809
+ };
1810
+ function build$2(options, isSynchronous) {
1811
+ if (!options.resolveSymlinks || options.excludeSymlinks) return null;
1812
+ return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
1813
+ }
1814
+ function isRecursive(path$2, resolved, state) {
1815
+ if (state.options.useRealPaths) return isRecursiveUsingRealPaths(resolved, state);
1816
+ let parent = dirname(path$2);
1817
+ let depth$1 = 1;
1818
+ while (parent !== state.root && depth$1 < 2) {
1819
+ const resolvedPath = state.symlinks.get(parent);
1820
+ if (!!resolvedPath && (resolvedPath === resolved || resolvedPath.startsWith(resolved) || resolved.startsWith(resolvedPath))) depth$1++;
1821
+ else parent = dirname(parent);
1822
+ }
1823
+ state.symlinks.set(path$2, resolved);
1824
+ return depth$1 > 1;
1825
+ }
1826
+ function isRecursiveUsingRealPaths(resolved, state) {
1827
+ return state.visited.includes(resolved + state.options.pathSeparator);
1828
+ }
1829
+ const onlyCountsSync = (state) => {
1830
+ return state.counts;
1831
+ };
1832
+ const groupsSync = (state) => {
1833
+ return state.groups;
1834
+ };
1835
+ const defaultSync = (state) => {
1836
+ return state.paths;
1837
+ };
1838
+ const limitFilesSync = (state) => {
1839
+ return state.paths.slice(0, state.options.maxFiles);
1840
+ };
1841
+ const onlyCountsAsync = (state, error, callback$1) => {
1842
+ report(error, callback$1, state.counts, state.options.suppressErrors);
1843
+ return null;
1844
+ };
1845
+ const defaultAsync = (state, error, callback$1) => {
1846
+ report(error, callback$1, state.paths, state.options.suppressErrors);
1847
+ return null;
1848
+ };
1849
+ const limitFilesAsync = (state, error, callback$1) => {
1850
+ report(error, callback$1, state.paths.slice(0, state.options.maxFiles), state.options.suppressErrors);
1851
+ return null;
1852
+ };
1853
+ const groupsAsync = (state, error, callback$1) => {
1854
+ report(error, callback$1, state.groups, state.options.suppressErrors);
1855
+ return null;
1856
+ };
1857
+ function report(error, callback$1, output, suppressErrors) {
1858
+ if (error && !suppressErrors) callback$1(error, output);
1859
+ else callback$1(null, output);
1860
+ }
1861
+ function build$1(options, isSynchronous) {
1862
+ const { onlyCounts, group, maxFiles } = options;
1863
+ if (onlyCounts) return isSynchronous ? onlyCountsSync : onlyCountsAsync;
1864
+ else if (group) return isSynchronous ? groupsSync : groupsAsync;
1865
+ else if (maxFiles) return isSynchronous ? limitFilesSync : limitFilesAsync;
1866
+ else return isSynchronous ? defaultSync : defaultAsync;
1867
+ }
1868
+ const readdirOpts = { withFileTypes: true };
1869
+ const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
1870
+ state.queue.enqueue();
1871
+ if (currentDepth < 0) return state.queue.dequeue(null, state);
1872
+ const { fs } = state;
1873
+ state.visited.push(crawlPath);
1874
+ state.counts.directories++;
1875
+ fs.readdir(crawlPath || ".", readdirOpts, (error, entries = []) => {
1876
+ callback$1(entries, directoryPath, currentDepth);
1877
+ state.queue.dequeue(state.options.suppressErrors ? null : error, state);
1878
+ });
1879
+ };
1880
+ const walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
1881
+ const { fs } = state;
1882
+ if (currentDepth < 0) return;
1883
+ state.visited.push(crawlPath);
1884
+ state.counts.directories++;
1885
+ let entries = [];
1886
+ try {
1887
+ entries = fs.readdirSync(crawlPath || ".", readdirOpts);
1888
+ } catch (e) {
1889
+ if (!state.options.suppressErrors) throw e;
1890
+ }
1891
+ callback$1(entries, directoryPath, currentDepth);
1892
+ };
1893
+ function build(isSynchronous) {
1894
+ return isSynchronous ? walkSync : walkAsync;
1895
+ }
1896
+ /**
1897
+ * This is a custom stateless queue to track concurrent async fs calls.
1898
+ * It increments a counter whenever a call is queued and decrements it
1899
+ * as soon as it completes. When the counter hits 0, it calls onQueueEmpty.
1900
+ */
1901
+ var Queue = class {
1902
+ count = 0;
1903
+ constructor(onQueueEmpty) {
1904
+ this.onQueueEmpty = onQueueEmpty;
1905
+ }
1906
+ enqueue() {
1907
+ this.count++;
1908
+ return this.count;
1909
+ }
1910
+ dequeue(error, output) {
1911
+ if (this.onQueueEmpty && (--this.count <= 0 || error)) {
1912
+ this.onQueueEmpty(error, output);
1913
+ if (error) {
1914
+ output.controller.abort();
1915
+ this.onQueueEmpty = void 0;
1916
+ }
1917
+ }
1918
+ }
1919
+ };
1920
+ var Counter = class {
1921
+ _files = 0;
1922
+ _directories = 0;
1923
+ set files(num) {
1924
+ this._files = num;
1925
+ }
1926
+ get files() {
1927
+ return this._files;
1928
+ }
1929
+ set directories(num) {
1930
+ this._directories = num;
1931
+ }
1932
+ get directories() {
1933
+ return this._directories;
1934
+ }
1935
+ /**
1936
+ * @deprecated use `directories` instead
1937
+ */
1938
+ /* c8 ignore next 3 */
1939
+ get dirs() {
1940
+ return this._directories;
1941
+ }
1942
+ };
1943
+ /**
1944
+ * AbortController is not supported on Node 14 so we use this until we can drop
1945
+ * support for Node 14.
1946
+ */
1947
+ var Aborter = class {
1948
+ aborted = false;
1949
+ abort() {
1950
+ this.aborted = true;
1951
+ }
1952
+ };
1953
+ var Walker = class {
1954
+ root;
1955
+ isSynchronous;
1956
+ state;
1957
+ joinPath;
1958
+ pushDirectory;
1959
+ pushFile;
1960
+ getArray;
1961
+ groupFiles;
1962
+ resolveSymlink;
1963
+ walkDirectory;
1964
+ callbackInvoker;
1965
+ constructor(root, options, callback$1) {
1966
+ this.isSynchronous = !callback$1;
1967
+ this.callbackInvoker = build$1(options, this.isSynchronous);
1968
+ this.root = normalizePath$1(root, options);
1969
+ this.state = {
1970
+ root: isRootDirectory(this.root) ? this.root : this.root.slice(0, -1),
1971
+ paths: [""].slice(0, 0),
1972
+ groups: [],
1973
+ counts: new Counter(),
1974
+ options,
1975
+ queue: new Queue((error, state) => this.callbackInvoker(state, error, callback$1)),
1976
+ symlinks: /* @__PURE__ */ new Map(),
1977
+ visited: [""].slice(0, 0),
1978
+ controller: new Aborter(),
1979
+ fs: options.fs || nativeFs$1
1980
+ };
1981
+ this.joinPath = build$7(this.root, options);
1982
+ this.pushDirectory = build$6(this.root, options);
1983
+ this.pushFile = build$5(options);
1984
+ this.getArray = build$4(options);
1985
+ this.groupFiles = build$3(options);
1986
+ this.resolveSymlink = build$2(options, this.isSynchronous);
1987
+ this.walkDirectory = build(this.isSynchronous);
1988
+ }
1989
+ start() {
1990
+ this.pushDirectory(this.root, this.state.paths, this.state.options.filters);
1991
+ this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk);
1992
+ return this.isSynchronous ? this.callbackInvoker(this.state, null) : null;
1993
+ }
1994
+ walk = (entries, directoryPath, depth$1) => {
1995
+ const { paths, options: { filters, resolveSymlinks: resolveSymlinks$1, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator }, controller } = this.state;
1996
+ if (controller.aborted || signal && signal.aborted || maxFiles && paths.length > maxFiles) return;
1997
+ const files = this.getArray(this.state.paths);
1998
+ for (let i = 0; i < entries.length; ++i) {
1999
+ const entry = entries[i];
2000
+ if (entry.isFile() || entry.isSymbolicLink() && !resolveSymlinks$1 && !excludeSymlinks) {
2001
+ const filename = this.joinPath(entry.name, directoryPath);
2002
+ this.pushFile(filename, files, this.state.counts, filters);
2003
+ } else if (entry.isDirectory()) {
2004
+ let path$2 = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
2005
+ if (exclude && exclude(entry.name, path$2)) continue;
2006
+ this.pushDirectory(path$2, paths, filters);
2007
+ this.walkDirectory(this.state, path$2, path$2, depth$1 - 1, this.walk);
2008
+ } else if (this.resolveSymlink && entry.isSymbolicLink()) {
2009
+ let path$2 = joinPathWithBasePath(entry.name, directoryPath);
2010
+ this.resolveSymlink(path$2, this.state, (stat$1, resolvedPath) => {
2011
+ if (stat$1.isDirectory()) {
2012
+ resolvedPath = normalizePath$1(resolvedPath, this.state.options);
2013
+ if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path$2 + pathSeparator)) return;
2014
+ this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path$2 + pathSeparator, depth$1 - 1, this.walk);
2015
+ } else {
2016
+ resolvedPath = useRealPaths ? resolvedPath : path$2;
2017
+ const filename = basename(resolvedPath);
2018
+ const directoryPath$1 = normalizePath$1(dirname(resolvedPath), this.state.options);
2019
+ resolvedPath = this.joinPath(filename, directoryPath$1);
2020
+ this.pushFile(resolvedPath, files, this.state.counts, filters);
2021
+ }
2022
+ });
2023
+ }
2024
+ }
2025
+ this.groupFiles(this.state.groups, directoryPath, files);
2026
+ };
2027
+ };
2028
+ function promise(root, options) {
2029
+ return new Promise((resolve$1, reject) => {
2030
+ callback(root, options, (err, output) => {
2031
+ if (err) return reject(err);
2032
+ resolve$1(output);
2033
+ });
2034
+ });
2035
+ }
2036
+ function callback(root, options, callback$1) {
2037
+ new Walker(root, options, callback$1).start();
2038
+ }
2039
+ function sync(root, options) {
2040
+ return new Walker(root, options).start();
2041
+ }
2042
+ var APIBuilder = class {
2043
+ constructor(root, options) {
2044
+ this.root = root;
2045
+ this.options = options;
2046
+ }
2047
+ withPromise() {
2048
+ return promise(this.root, this.options);
2049
+ }
2050
+ withCallback(cb) {
2051
+ callback(this.root, this.options, cb);
2052
+ }
2053
+ sync() {
2054
+ return sync(this.root, this.options);
2055
+ }
2056
+ };
2057
+ let pm$1 = null;
2058
+ /* c8 ignore next 6 */
2059
+ try {
2060
+ __require.resolve("picomatch");
2061
+ pm$1 = __require("picomatch");
2062
+ } catch {}
2063
+ var Builder = class {
2064
+ globCache = {};
2065
+ options = {
2066
+ maxDepth: Infinity,
2067
+ suppressErrors: true,
2068
+ pathSeparator: sep,
2069
+ filters: []
2070
+ };
2071
+ globFunction;
2072
+ constructor(options) {
2073
+ this.options = {
2074
+ ...this.options,
2075
+ ...options
2076
+ };
2077
+ this.globFunction = this.options.globFunction;
2078
+ }
2079
+ group() {
2080
+ this.options.group = true;
2081
+ return this;
2082
+ }
2083
+ withPathSeparator(separator) {
2084
+ this.options.pathSeparator = separator;
2085
+ return this;
2086
+ }
2087
+ withBasePath() {
2088
+ this.options.includeBasePath = true;
2089
+ return this;
2090
+ }
2091
+ withRelativePaths() {
2092
+ this.options.relativePaths = true;
2093
+ return this;
2094
+ }
2095
+ withDirs() {
2096
+ this.options.includeDirs = true;
2097
+ return this;
2098
+ }
2099
+ withMaxDepth(depth$1) {
2100
+ this.options.maxDepth = depth$1;
2101
+ return this;
2102
+ }
2103
+ withMaxFiles(limit) {
2104
+ this.options.maxFiles = limit;
2105
+ return this;
2106
+ }
2107
+ withFullPaths() {
2108
+ this.options.resolvePaths = true;
2109
+ this.options.includeBasePath = true;
2110
+ return this;
2111
+ }
2112
+ withErrors() {
2113
+ this.options.suppressErrors = false;
2114
+ return this;
2115
+ }
2116
+ withSymlinks({ resolvePaths = true } = {}) {
2117
+ this.options.resolveSymlinks = true;
2118
+ this.options.useRealPaths = resolvePaths;
2119
+ return this.withFullPaths();
2120
+ }
2121
+ withAbortSignal(signal) {
2122
+ this.options.signal = signal;
2123
+ return this;
2124
+ }
2125
+ normalize() {
2126
+ this.options.normalizePath = true;
2127
+ return this;
2128
+ }
2129
+ filter(predicate) {
2130
+ this.options.filters.push(predicate);
2131
+ return this;
2132
+ }
2133
+ onlyDirs() {
2134
+ this.options.excludeFiles = true;
2135
+ this.options.includeDirs = true;
2136
+ return this;
2137
+ }
2138
+ exclude(predicate) {
2139
+ this.options.exclude = predicate;
2140
+ return this;
2141
+ }
2142
+ onlyCounts() {
2143
+ this.options.onlyCounts = true;
2144
+ return this;
2145
+ }
2146
+ crawl(root) {
2147
+ return new APIBuilder(root || ".", this.options);
2148
+ }
2149
+ withGlobFunction(fn) {
2150
+ this.globFunction = fn;
2151
+ return this;
2152
+ }
2153
+ /**
2154
+ * @deprecated Pass options using the constructor instead:
2155
+ * ```ts
2156
+ * new fdir(options).crawl("/path/to/root");
2157
+ * ```
2158
+ * This method will be removed in v7.0
2159
+ */
2160
+ /* c8 ignore next 4 */
2161
+ crawlWithOptions(root, options) {
2162
+ this.options = {
2163
+ ...this.options,
2164
+ ...options
2165
+ };
2166
+ return new APIBuilder(root || ".", this.options);
2167
+ }
2168
+ glob(...patterns) {
2169
+ if (this.globFunction) return this.globWithOptions(patterns);
2170
+ return this.globWithOptions(patterns, ...[{ dot: true }]);
2171
+ }
2172
+ globWithOptions(patterns, ...options) {
2173
+ const globFn = this.globFunction || pm$1;
2174
+ /* c8 ignore next 5 */
2175
+ if (!globFn) throw new Error("Please specify a glob function to use glob matching.");
2176
+ var isMatch = this.globCache[patterns.join("\0")];
2177
+ if (!isMatch) {
2178
+ isMatch = globFn(patterns, ...options);
2179
+ this.globCache[patterns.join("\0")] = isMatch;
2180
+ }
2181
+ this.options.filters.push((path$2) => isMatch(path$2));
2182
+ return this;
2183
+ }
2184
+ };
2185
+
2186
+ //#endregion
2187
+ //#region node_modules/.pnpm/estree-walker@2.0.2/node_modules/estree-walker/dist/esm/estree-walker.js
2188
+ /** @typedef { import('estree').BaseNode} BaseNode */
2189
+ /** @typedef {{
2190
+ skip: () => void;
2191
+ remove: () => void;
2192
+ replace: (node: BaseNode) => void;
2193
+ }} WalkerContext */
2194
+ var WalkerBase = class {
2195
+ constructor() {
2196
+ /** @type {boolean} */
2197
+ this.should_skip = false;
2198
+ /** @type {boolean} */
2199
+ this.should_remove = false;
2200
+ /** @type {BaseNode | null} */
2201
+ this.replacement = null;
2202
+ /** @type {WalkerContext} */
2203
+ this.context = {
2204
+ skip: () => this.should_skip = true,
2205
+ remove: () => this.should_remove = true,
2206
+ replace: (node) => this.replacement = node
2207
+ };
2208
+ }
2209
+ /**
2210
+ *
2211
+ * @param {any} parent
2212
+ * @param {string} prop
2213
+ * @param {number} index
2214
+ * @param {BaseNode} node
2215
+ */
2216
+ replace(parent, prop, index, node) {
2217
+ if (parent) if (index !== null) parent[prop][index] = node;
2218
+ else parent[prop] = node;
2219
+ }
2220
+ /**
2221
+ *
2222
+ * @param {any} parent
2223
+ * @param {string} prop
2224
+ * @param {number} index
2225
+ */
2226
+ remove(parent, prop, index) {
2227
+ if (parent) if (index !== null) parent[prop].splice(index, 1);
2228
+ else delete parent[prop];
2229
+ }
2230
+ };
2231
+ /** @typedef { import('estree').BaseNode} BaseNode */
2232
+ /** @typedef { import('./walker.js').WalkerContext} WalkerContext */
2233
+ /** @typedef {(
2234
+ * this: WalkerContext,
2235
+ * node: BaseNode,
2236
+ * parent: BaseNode,
2237
+ * key: string,
2238
+ * index: number
2239
+ * ) => void} SyncHandler */
2240
+ var SyncWalker = class extends WalkerBase {
2241
+ /**
2242
+ *
2243
+ * @param {SyncHandler} enter
2244
+ * @param {SyncHandler} leave
2245
+ */
2246
+ constructor(enter, leave) {
2247
+ super();
2248
+ /** @type {SyncHandler} */
2249
+ this.enter = enter;
2250
+ /** @type {SyncHandler} */
2251
+ this.leave = leave;
2252
+ }
2253
+ /**
2254
+ *
2255
+ * @param {BaseNode} node
2256
+ * @param {BaseNode} parent
2257
+ * @param {string} [prop]
2258
+ * @param {number} [index]
2259
+ * @returns {BaseNode}
2260
+ */
2261
+ visit(node, parent, prop, index) {
2262
+ if (node) {
2263
+ if (this.enter) {
2264
+ const _should_skip = this.should_skip;
2265
+ const _should_remove = this.should_remove;
2266
+ const _replacement = this.replacement;
2267
+ this.should_skip = false;
2268
+ this.should_remove = false;
2269
+ this.replacement = null;
2270
+ this.enter.call(this.context, node, parent, prop, index);
2271
+ if (this.replacement) {
2272
+ node = this.replacement;
2273
+ this.replace(parent, prop, index, node);
2274
+ }
2275
+ if (this.should_remove) this.remove(parent, prop, index);
2276
+ const skipped = this.should_skip;
2277
+ const removed = this.should_remove;
2278
+ this.should_skip = _should_skip;
2279
+ this.should_remove = _should_remove;
2280
+ this.replacement = _replacement;
2281
+ if (skipped) return node;
2282
+ if (removed) return null;
2283
+ }
2284
+ for (const key in node) {
2285
+ const value = node[key];
2286
+ if (typeof value !== "object") continue;
2287
+ else if (Array.isArray(value)) {
2288
+ for (let i = 0; i < value.length; i += 1) if (value[i] !== null && typeof value[i].type === "string") {
2289
+ if (!this.visit(value[i], node, key, i)) i--;
2290
+ }
2291
+ } else if (value !== null && typeof value.type === "string") this.visit(value, node, key, null);
2292
+ }
2293
+ if (this.leave) {
2294
+ const _replacement = this.replacement;
2295
+ const _should_remove = this.should_remove;
2296
+ this.replacement = null;
2297
+ this.should_remove = false;
2298
+ this.leave.call(this.context, node, parent, prop, index);
2299
+ if (this.replacement) {
2300
+ node = this.replacement;
2301
+ this.replace(parent, prop, index, node);
2302
+ }
2303
+ if (this.should_remove) this.remove(parent, prop, index);
2304
+ const removed = this.should_remove;
2305
+ this.replacement = _replacement;
2306
+ this.should_remove = _should_remove;
2307
+ if (removed) return null;
2308
+ }
2309
+ }
2310
+ return node;
2311
+ }
2312
+ };
2313
+ /** @typedef { import('estree').BaseNode} BaseNode */
2314
+ /** @typedef { import('./sync.js').SyncHandler} SyncHandler */
2315
+ /** @typedef { import('./async.js').AsyncHandler} AsyncHandler */
2316
+ /**
2317
+ *
2318
+ * @param {BaseNode} ast
2319
+ * @param {{
2320
+ * enter?: SyncHandler
2321
+ * leave?: SyncHandler
2322
+ * }} walker
2323
+ * @returns {BaseNode}
2324
+ */
2325
+ function walk(ast, { enter, leave }) {
2326
+ return new SyncWalker(enter, leave).visit(ast, null);
2327
+ }
2328
+
2329
+ //#endregion
2330
+ //#region node_modules/.pnpm/@rollup+pluginutils@5.3.0_rollup@4.53.3/node_modules/@rollup/pluginutils/dist/es/index.js
2331
+ var import_picomatch = /* @__PURE__ */ __toESM(require_picomatch(), 1);
2332
+ const extractors = {
2333
+ ArrayPattern(names, param) {
2334
+ for (const element of param.elements) if (element) extractors[element.type](names, element);
2335
+ },
2336
+ AssignmentPattern(names, param) {
2337
+ extractors[param.left.type](names, param.left);
2338
+ },
2339
+ Identifier(names, param) {
2340
+ names.push(param.name);
2341
+ },
2342
+ MemberExpression() {},
2343
+ ObjectPattern(names, param) {
2344
+ for (const prop of param.properties) if (prop.type === "RestElement") extractors.RestElement(names, prop);
2345
+ else extractors[prop.value.type](names, prop.value);
2346
+ },
2347
+ RestElement(names, param) {
2348
+ extractors[param.argument.type](names, param.argument);
2349
+ }
2350
+ };
2351
+ const extractAssignedNames = function extractAssignedNames$1(param) {
2352
+ const names = [];
2353
+ extractors[param.type](names, param);
2354
+ return names;
2355
+ };
2356
+ const blockDeclarations = {
2357
+ const: true,
2358
+ let: true
2359
+ };
2360
+ var Scope = class {
2361
+ constructor(options = {}) {
2362
+ this.parent = options.parent;
2363
+ this.isBlockScope = !!options.block;
2364
+ this.declarations = Object.create(null);
2365
+ if (options.params) options.params.forEach((param) => {
2366
+ extractAssignedNames(param).forEach((name) => {
2367
+ this.declarations[name] = true;
2368
+ });
2369
+ });
2370
+ }
2371
+ addDeclaration(node, isBlockDeclaration, isVar) {
2372
+ if (!isBlockDeclaration && this.isBlockScope) this.parent.addDeclaration(node, isBlockDeclaration, isVar);
2373
+ else if (node.id) extractAssignedNames(node.id).forEach((name) => {
2374
+ this.declarations[name] = true;
2375
+ });
2376
+ }
2377
+ contains(name) {
2378
+ return this.declarations[name] || (this.parent ? this.parent.contains(name) : false);
2379
+ }
2380
+ };
2381
+ const attachScopes = function attachScopes$1(ast, propertyName = "scope") {
2382
+ let scope = new Scope();
2383
+ walk(ast, {
2384
+ enter(n, parent) {
2385
+ const node = n;
2386
+ if (/(?:Function|Class)Declaration/.test(node.type)) scope.addDeclaration(node, false, false);
2387
+ if (node.type === "VariableDeclaration") {
2388
+ const { kind } = node;
2389
+ const isBlockDeclaration = blockDeclarations[kind];
2390
+ node.declarations.forEach((declaration) => {
2391
+ scope.addDeclaration(declaration, isBlockDeclaration, true);
2392
+ });
2393
+ }
2394
+ let newScope;
2395
+ if (node.type.includes("Function")) {
2396
+ const func = node;
2397
+ newScope = new Scope({
2398
+ parent: scope,
2399
+ block: false,
2400
+ params: func.params
2401
+ });
2402
+ if (func.type === "FunctionExpression" && func.id) newScope.addDeclaration(func, false, false);
2403
+ }
2404
+ if (/For(?:In|Of)?Statement/.test(node.type)) newScope = new Scope({
2405
+ parent: scope,
2406
+ block: true
2407
+ });
2408
+ if (node.type === "BlockStatement" && !parent.type.includes("Function")) newScope = new Scope({
2409
+ parent: scope,
2410
+ block: true
2411
+ });
2412
+ if (node.type === "CatchClause") newScope = new Scope({
2413
+ parent: scope,
2414
+ params: node.param ? [node.param] : [],
2415
+ block: true
2416
+ });
2417
+ if (newScope) {
2418
+ Object.defineProperty(node, propertyName, {
2419
+ value: newScope,
2420
+ configurable: true
2421
+ });
2422
+ scope = newScope;
2423
+ }
2424
+ },
2425
+ leave(n) {
2426
+ if (n[propertyName]) scope = scope.parent;
2427
+ }
2428
+ });
2429
+ return scope;
2430
+ };
2431
+ function isArray(arg) {
2432
+ return Array.isArray(arg);
2433
+ }
2434
+ function ensureArray(thing) {
2435
+ if (isArray(thing)) return thing;
2436
+ if (thing == null) return [];
2437
+ return [thing];
2438
+ }
2439
+ const normalizePathRegExp = new RegExp(`\\${win32.sep}`, "g");
2440
+ const normalizePath = function normalizePath$2(filename) {
2441
+ return filename.replace(normalizePathRegExp, posix.sep);
2442
+ };
2443
+ function getMatcherString(id, resolutionBase) {
2444
+ if (resolutionBase === false || isAbsolute(id) || id.startsWith("**")) return normalizePath(id);
2445
+ const basePath = normalizePath(resolve(resolutionBase || "")).replace(/[-^$*+?.()|[\]{}]/g, "\\$&");
2446
+ return posix.join(basePath, normalizePath(id));
2447
+ }
2448
+ const createFilter = function createFilter$1(include, exclude, options) {
2449
+ const resolutionBase = options && options.resolve;
2450
+ const getMatcher = (id) => id instanceof RegExp ? id : { test: (what) => {
2451
+ return (0, import_picomatch.default)(getMatcherString(id, resolutionBase), { dot: true })(what);
2452
+ } };
2453
+ const includeMatchers = ensureArray(include).map(getMatcher);
2454
+ const excludeMatchers = ensureArray(exclude).map(getMatcher);
2455
+ if (!includeMatchers.length && !excludeMatchers.length) return (id) => typeof id === "string" && !id.includes("\0");
2456
+ return function result(id) {
2457
+ if (typeof id !== "string") return false;
2458
+ if (id.includes("\0")) return false;
2459
+ const pathId = normalizePath(id);
2460
+ for (let i = 0; i < excludeMatchers.length; ++i) {
2461
+ const matcher = excludeMatchers[i];
2462
+ if (matcher instanceof RegExp) matcher.lastIndex = 0;
2463
+ if (matcher.test(pathId)) return false;
2464
+ }
2465
+ for (let i = 0; i < includeMatchers.length; ++i) {
2466
+ const matcher = includeMatchers[i];
2467
+ if (matcher instanceof RegExp) matcher.lastIndex = 0;
2468
+ if (matcher.test(pathId)) return true;
2469
+ }
2470
+ return !includeMatchers.length;
2471
+ };
2472
+ };
2473
+ const forbiddenIdentifiers = new Set(`break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl`.split(" "));
2474
+ forbiddenIdentifiers.add("");
2475
+ const makeLegalIdentifier = function makeLegalIdentifier$1(str) {
2476
+ let identifier = str.replace(/-(\w)/g, (_, letter) => letter.toUpperCase()).replace(/[^$_a-zA-Z0-9]/g, "_");
2477
+ if (/\d/.test(identifier[0]) || forbiddenIdentifiers.has(identifier)) identifier = `_${identifier}`;
2478
+ return identifier || "_";
2479
+ };
2480
+ function stringify(obj) {
2481
+ return (JSON.stringify(obj) || "undefined").replace(/[\u2028\u2029]/g, (char) => `\\u${`000${char.charCodeAt(0).toString(16)}`.slice(-4)}`);
2482
+ }
2483
+ function serializeArray(arr, indent, baseIndent) {
2484
+ let output = "[";
2485
+ const separator = indent ? `\n${baseIndent}${indent}` : "";
2486
+ for (let i = 0; i < arr.length; i++) {
2487
+ const key = arr[i];
2488
+ output += `${i > 0 ? "," : ""}${separator}${serialize(key, indent, baseIndent + indent)}`;
2489
+ }
2490
+ return `${output}${indent ? `\n${baseIndent}` : ""}]`;
2491
+ }
2492
+ function serializeObject(obj, indent, baseIndent) {
2493
+ let output = "{";
2494
+ const separator = indent ? `\n${baseIndent}${indent}` : "";
2495
+ const entries = Object.entries(obj);
2496
+ for (let i = 0; i < entries.length; i++) {
2497
+ const [key, value] = entries[i];
2498
+ const stringKey = makeLegalIdentifier(key) === key ? key : stringify(key);
2499
+ output += `${i > 0 ? "," : ""}${separator}${stringKey}:${indent ? " " : ""}${serialize(value, indent, baseIndent + indent)}`;
2500
+ }
2501
+ return `${output}${indent ? `\n${baseIndent}` : ""}}`;
2502
+ }
2503
+ function serialize(obj, indent, baseIndent) {
2504
+ if (typeof obj === "object" && obj !== null) {
2505
+ if (Array.isArray(obj)) return serializeArray(obj, indent, baseIndent);
2506
+ if (obj instanceof Date) return `new Date(${obj.getTime()})`;
2507
+ if (obj instanceof RegExp) return obj.toString();
2508
+ return serializeObject(obj, indent, baseIndent);
2509
+ }
2510
+ if (typeof obj === "number") {
2511
+ if (obj === Infinity) return "Infinity";
2512
+ if (obj === -Infinity) return "-Infinity";
2513
+ if (obj === 0) return 1 / obj === Infinity ? "0" : "-0";
2514
+ if (obj !== obj) return "NaN";
2515
+ }
2516
+ if (typeof obj === "symbol") {
2517
+ const key = Symbol.keyFor(obj);
2518
+ if (key !== void 0) return `Symbol.for(${stringify(key)})`;
2519
+ }
2520
+ if (typeof obj === "bigint") return `${obj}n`;
2521
+ return stringify(obj);
2522
+ }
2523
+ const hasStringIsWellFormed = "isWellFormed" in String.prototype;
2524
+ function isWellFormedString(input) {
2525
+ if (hasStringIsWellFormed) return input.isWellFormed();
2526
+ return !/\p{Surrogate}/u.test(input);
2527
+ }
2528
+ const dataToEsm = function dataToEsm$1(data, options = {}) {
2529
+ var _a, _b;
2530
+ const t = options.compact ? "" : "indent" in options ? options.indent : " ";
2531
+ const _ = options.compact ? "" : " ";
2532
+ const n = options.compact ? "" : "\n";
2533
+ const declarationType = options.preferConst ? "const" : "var";
2534
+ if (options.namedExports === false || typeof data !== "object" || Array.isArray(data) || data instanceof Date || data instanceof RegExp || data === null) {
2535
+ const code = serialize(data, options.compact ? null : t, "");
2536
+ return `export default${_ || (/^[{[\-\/]/.test(code) ? "" : " ")}${code};`;
2537
+ }
2538
+ let maxUnderbarPrefixLength = 0;
2539
+ for (const key of Object.keys(data)) {
2540
+ const underbarPrefixLength = (_b = (_a = /^(_+)/.exec(key)) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
2541
+ if (underbarPrefixLength > maxUnderbarPrefixLength) maxUnderbarPrefixLength = underbarPrefixLength;
2542
+ }
2543
+ const arbitraryNamePrefix = `${"_".repeat(maxUnderbarPrefixLength + 1)}arbitrary`;
2544
+ let namedExportCode = "";
2545
+ const defaultExportRows = [];
2546
+ const arbitraryNameExportRows = [];
2547
+ for (const [key, value] of Object.entries(data)) if (key === makeLegalIdentifier(key)) {
2548
+ if (options.objectShorthand) defaultExportRows.push(key);
2549
+ else defaultExportRows.push(`${key}:${_}${key}`);
2550
+ namedExportCode += `export ${declarationType} ${key}${_}=${_}${serialize(value, options.compact ? null : t, "")};${n}`;
2551
+ } else {
2552
+ defaultExportRows.push(`${stringify(key)}:${_}${serialize(value, options.compact ? null : t, "")}`);
2553
+ if (options.includeArbitraryNames && isWellFormedString(key)) {
2554
+ const variableName = `${arbitraryNamePrefix}${arbitraryNameExportRows.length}`;
2555
+ namedExportCode += `${declarationType} ${variableName}${_}=${_}${serialize(value, options.compact ? null : t, "")};${n}`;
2556
+ arbitraryNameExportRows.push(`${variableName} as ${JSON.stringify(key)}`);
2557
+ }
2558
+ }
2559
+ const arbitraryExportCode = arbitraryNameExportRows.length > 0 ? `export${_}{${n}${t}${arbitraryNameExportRows.join(`,${n}${t}`)}${n}};${n}` : "";
2560
+ const defaultExportCode = `export default${_}{${n}${t}${defaultExportRows.join(`,${n}${t}`)}${n}};${n}`;
2561
+ return `${namedExportCode}${arbitraryExportCode}${defaultExportCode}`;
2562
+ };
2563
+
2564
+ //#endregion
2565
+ //#region node_modules/.pnpm/commondir@1.0.1/node_modules/commondir/index.js
2566
+ var require_commondir = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2567
+ var path$1 = __require$1("path");
2568
+ module.exports = function(basedir, relfiles) {
2569
+ if (relfiles) var files = relfiles.map(function(r) {
2570
+ return path$1.resolve(basedir, r);
2571
+ });
2572
+ else var files = basedir;
2573
+ var res = files.slice(1).reduce(function(ps, file) {
2574
+ if (!file.match(/^([A-Za-z]:)?\/|\\/)) throw new Error("relative path without a basedir");
2575
+ var xs = file.split(/\/+|\\+/);
2576
+ for (var i = 0; ps[i] === xs[i] && i < Math.min(ps.length, xs.length); i++);
2577
+ return ps.slice(0, i);
2578
+ }, files[0].split(/\/+|\\+/));
2579
+ return res.length > 1 ? res.join("/") : "/";
2580
+ };
2581
+ }));
2582
+
2583
+ //#endregion
2584
+ //#region node_modules/.pnpm/is-reference@1.2.1/node_modules/is-reference/dist/is-reference.js
2585
+ var require_is_reference = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2586
+ (function(global, factory) {
2587
+ typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global = global || self, global.isReference = factory());
2588
+ })(exports, (function() {
2589
+ "use strict";
2590
+ function isReference$1(node, parent) {
2591
+ if (node.type === "MemberExpression") return !node.computed && isReference$1(node.object, node);
2592
+ if (node.type === "Identifier") {
2593
+ if (!parent) return true;
2594
+ switch (parent.type) {
2595
+ case "MemberExpression": return parent.computed || node === parent.object;
2596
+ case "MethodDefinition": return parent.computed;
2597
+ case "FieldDefinition": return parent.computed || node === parent.value;
2598
+ case "Property": return parent.computed || node === parent.value;
2599
+ case "ExportSpecifier":
2600
+ case "ImportSpecifier": return node === parent.local;
2601
+ case "LabeledStatement":
2602
+ case "BreakStatement":
2603
+ case "ContinueStatement": return false;
2604
+ default: return true;
2605
+ }
2606
+ }
2607
+ return false;
2608
+ }
2609
+ return isReference$1;
2610
+ }));
2611
+ }));
2612
+
2613
+ //#endregion
2614
+ //#region node_modules/.pnpm/@rollup+plugin-commonjs@29.0.0_rollup@4.53.3/node_modules/@rollup/plugin-commonjs/dist/es/index.js
2615
+ var import_commondir = /* @__PURE__ */ __toESM(require_commondir(), 1);
2616
+ var import_is_reference = /* @__PURE__ */ __toESM(require_is_reference(), 1);
2617
+ var version = "29.0.0";
2618
+ var peerDependencies = { rollup: "^2.68.0||^3.0.0||^4.0.0" };
2619
+ function tryParse(parse$2, code, id) {
2620
+ try {
2621
+ return parse$2(code, { allowReturnOutsideFunction: true });
2622
+ } catch (err) {
2623
+ err.message += ` in ${id}`;
2624
+ throw err;
2625
+ }
2626
+ }
2627
+ const firstpassGlobal = /\b(?:require|module|exports|global)\b/;
2628
+ const firstpassNoGlobal = /\b(?:require|module|exports)\b/;
2629
+ function hasCjsKeywords(code, ignoreGlobal) {
2630
+ return (ignoreGlobal ? firstpassNoGlobal : firstpassGlobal).test(code);
2631
+ }
2632
+ function analyzeTopLevelStatements(parse$2, code, id) {
2633
+ const ast = tryParse(parse$2, code, id);
2634
+ let isEsModule = false;
2635
+ let hasDefaultExport = false;
2636
+ let hasNamedExports = false;
2637
+ for (const node of ast.body) switch (node.type) {
2638
+ case "ExportDefaultDeclaration":
2639
+ isEsModule = true;
2640
+ hasDefaultExport = true;
2641
+ break;
2642
+ case "ExportNamedDeclaration":
2643
+ isEsModule = true;
2644
+ if (node.declaration) hasNamedExports = true;
2645
+ else for (const specifier of node.specifiers) if (specifier.exported.name === "default") hasDefaultExport = true;
2646
+ else hasNamedExports = true;
2647
+ break;
2648
+ case "ExportAllDeclaration":
2649
+ isEsModule = true;
2650
+ if (node.exported && node.exported.name === "default") hasDefaultExport = true;
2651
+ else hasNamedExports = true;
2652
+ break;
2653
+ case "ImportDeclaration":
2654
+ isEsModule = true;
2655
+ break;
2656
+ }
2657
+ return {
2658
+ isEsModule,
2659
+ hasDefaultExport,
2660
+ hasNamedExports,
2661
+ ast
2662
+ };
2663
+ }
2664
+ function deconflict(scopes, globals, identifier) {
2665
+ let i = 1;
2666
+ let deconflicted = makeLegalIdentifier(identifier);
2667
+ const hasConflicts = () => scopes.some((scope) => scope.contains(deconflicted)) || globals.has(deconflicted);
2668
+ while (hasConflicts()) {
2669
+ deconflicted = makeLegalIdentifier(`${identifier}_${i}`);
2670
+ i += 1;
2671
+ }
2672
+ for (const scope of scopes) scope.declarations[deconflicted] = true;
2673
+ return deconflicted;
2674
+ }
2675
+ function getName(id) {
2676
+ const name = makeLegalIdentifier(basename(id, extname(id)));
2677
+ if (name !== "index") return name;
2678
+ return makeLegalIdentifier(basename(dirname(id)));
2679
+ }
2680
+ function normalizePathSlashes(path$2) {
2681
+ return path$2.replace(/\\/g, "/");
2682
+ }
2683
+ const getVirtualPathForDynamicRequirePath = (path$2, commonDir) => `/${normalizePathSlashes(relative(commonDir, path$2))}`;
2684
+ function capitalize(name) {
2685
+ return name[0].toUpperCase() + name.slice(1);
2686
+ }
2687
+ function getStrictRequiresFilter({ strictRequires }) {
2688
+ switch (strictRequires) {
2689
+ case void 0:
2690
+ case true: return {
2691
+ strictRequiresFilter: () => true,
2692
+ detectCyclesAndConditional: false
2693
+ };
2694
+ case "auto":
2695
+ case "debug":
2696
+ case null: return {
2697
+ strictRequiresFilter: () => false,
2698
+ detectCyclesAndConditional: true
2699
+ };
2700
+ case false: return {
2701
+ strictRequiresFilter: () => false,
2702
+ detectCyclesAndConditional: false
2703
+ };
2704
+ default:
2705
+ if (typeof strictRequires === "string" || Array.isArray(strictRequires)) return {
2706
+ strictRequiresFilter: createFilter(strictRequires),
2707
+ detectCyclesAndConditional: false
2708
+ };
2709
+ throw new Error("Unexpected value for \"strictRequires\" option.");
2710
+ }
2711
+ }
2712
+ function getPackageEntryPoint(dirPath) {
2713
+ let entryPoint = "index.js";
2714
+ try {
2715
+ if (existsSync(join(dirPath, "package.json"))) entryPoint = JSON.parse(readFileSync(join(dirPath, "package.json"), { encoding: "utf8" })).main || entryPoint;
2716
+ } catch (ignored) {}
2717
+ return entryPoint;
2718
+ }
2719
+ function isDirectory(path$2) {
2720
+ try {
2721
+ if (statSync(path$2).isDirectory()) return true;
2722
+ } catch (ignored) {}
2723
+ return false;
2724
+ }
2725
+ function getDynamicRequireModules(patterns, dynamicRequireRoot) {
2726
+ const dynamicRequireModules = /* @__PURE__ */ new Map();
2727
+ const dirNames = /* @__PURE__ */ new Set();
2728
+ for (const pattern of !patterns || Array.isArray(patterns) ? patterns || [] : [patterns]) {
2729
+ const isNegated = pattern.startsWith("!");
2730
+ const modifyMap = (targetPath, resolvedPath) => isNegated ? dynamicRequireModules.delete(targetPath) : dynamicRequireModules.set(targetPath, resolvedPath);
2731
+ for (const path$2 of new Builder().withBasePath().withDirs().glob(isNegated ? pattern.substr(1) : pattern).crawl(relative(".", dynamicRequireRoot)).sync().sort((a, b) => a.localeCompare(b, "en"))) {
2732
+ const resolvedPath = resolve(path$2);
2733
+ const requirePath = normalizePathSlashes(resolvedPath);
2734
+ if (isDirectory(resolvedPath)) {
2735
+ dirNames.add(resolvedPath);
2736
+ const modulePath = resolve(join(resolvedPath, getPackageEntryPoint(path$2)));
2737
+ modifyMap(requirePath, modulePath);
2738
+ modifyMap(normalizePathSlashes(modulePath), modulePath);
2739
+ } else {
2740
+ dirNames.add(dirname(resolvedPath));
2741
+ modifyMap(requirePath, resolvedPath);
2742
+ }
2743
+ }
2744
+ }
2745
+ return {
2746
+ commonDir: dirNames.size ? (0, import_commondir.default)([...dirNames, dynamicRequireRoot]) : null,
2747
+ dynamicRequireModules
2748
+ };
2749
+ }
2750
+ const FAILED_REQUIRE_ERROR = `throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');`;
2751
+ const COMMONJS_REQUIRE_EXPORT = "commonjsRequire";
2752
+ const CREATE_COMMONJS_REQUIRE_EXPORT = "createCommonjsRequire";
2753
+ function getDynamicModuleRegistry(isDynamicRequireModulesEnabled, dynamicRequireModules, commonDir, ignoreDynamicRequires) {
2754
+ if (!isDynamicRequireModulesEnabled) return `export function ${COMMONJS_REQUIRE_EXPORT}(path) {
2755
+ ${FAILED_REQUIRE_ERROR}
2756
+ }`;
2757
+ return `${[...dynamicRequireModules.values()].map((id, index) => `import ${id.endsWith(".json") ? `json${index}` : `{ __require as require${index} }`} from ${JSON.stringify(id)};`).join("\n")}
2758
+
2759
+ var dynamicModules;
2760
+
2761
+ function getDynamicModules() {
2762
+ return dynamicModules || (dynamicModules = {
2763
+ ${[...dynamicRequireModules.keys()].map((id, index) => `\t\t${JSON.stringify(getVirtualPathForDynamicRequirePath(id, commonDir))}: ${id.endsWith(".json") ? `function () { return json${index}; }` : `require${index}`}`).join(",\n")}
2764
+ });
2765
+ }
2766
+
2767
+ export function ${CREATE_COMMONJS_REQUIRE_EXPORT}(originalModuleDir) {
2768
+ function handleRequire(path) {
2769
+ var resolvedPath = commonjsResolve(path, originalModuleDir);
2770
+ if (resolvedPath !== null) {
2771
+ return getDynamicModules()[resolvedPath]();
2772
+ }
2773
+ ${ignoreDynamicRequires ? "return require(path);" : FAILED_REQUIRE_ERROR}
2774
+ }
2775
+ handleRequire.resolve = function (path) {
2776
+ var resolvedPath = commonjsResolve(path, originalModuleDir);
2777
+ if (resolvedPath !== null) {
2778
+ return resolvedPath;
2779
+ }
2780
+ return require.resolve(path);
2781
+ }
2782
+ return handleRequire;
2783
+ }
2784
+
2785
+ function commonjsResolve (path, originalModuleDir) {
2786
+ var shouldTryNodeModules = isPossibleNodeModulesPath(path);
2787
+ path = normalize(path);
2788
+ var relPath;
2789
+ if (path[0] === '/') {
2790
+ originalModuleDir = '';
2791
+ }
2792
+ var modules = getDynamicModules();
2793
+ var checkedExtensions = ['', '.js', '.json'];
2794
+ while (true) {
2795
+ if (!shouldTryNodeModules) {
2796
+ relPath = normalize(originalModuleDir + '/' + path);
2797
+ } else {
2798
+ relPath = normalize(originalModuleDir + '/node_modules/' + path);
2799
+ }
2800
+
2801
+ if (relPath.endsWith('/..')) {
2802
+ break; // Travelled too far up, avoid infinite loop
2803
+ }
2804
+
2805
+ for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) {
2806
+ var resolvedPath = relPath + checkedExtensions[extensionIndex];
2807
+ if (modules[resolvedPath]) {
2808
+ return resolvedPath;
2809
+ }
2810
+ }
2811
+ if (!shouldTryNodeModules) break;
2812
+ var nextDir = normalize(originalModuleDir + '/..');
2813
+ if (nextDir === originalModuleDir) break;
2814
+ originalModuleDir = nextDir;
2815
+ }
2816
+ return null;
2817
+ }
2818
+
2819
+ function isPossibleNodeModulesPath (modulePath) {
2820
+ var c0 = modulePath[0];
2821
+ if (c0 === '/' || c0 === '\\\\') return false;
2822
+ var c1 = modulePath[1], c2 = modulePath[2];
2823
+ if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||
2824
+ (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;
2825
+ if (c1 === ':' && (c2 === '/' || c2 === '\\\\')) return false;
2826
+ return true;
2827
+ }
2828
+
2829
+ function normalize (path) {
2830
+ path = path.replace(/\\\\/g, '/');
2831
+ var parts = path.split('/');
2832
+ var slashed = parts[0] === '';
2833
+ for (var i = 1; i < parts.length; i++) {
2834
+ if (parts[i] === '.' || parts[i] === '') {
2835
+ parts.splice(i--, 1);
2836
+ }
2837
+ }
2838
+ for (var i = 1; i < parts.length; i++) {
2839
+ if (parts[i] !== '..') continue;
2840
+ if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {
2841
+ parts.splice(--i, 2);
2842
+ i--;
2843
+ }
2844
+ }
2845
+ path = parts.join('/');
2846
+ if (slashed && path[0] !== '/') path = '/' + path;
2847
+ else if (path.length === 0) path = '.';
2848
+ return path;
2849
+ }`;
2850
+ }
2851
+ const isWrappedId = (id, suffix) => id.endsWith(suffix);
2852
+ const wrapId = (id, suffix) => `\0${id}${suffix}`;
2853
+ const unwrapId = (wrappedId, suffix) => wrappedId.slice(1, -suffix.length);
2854
+ const PROXY_SUFFIX = "?commonjs-proxy";
2855
+ const WRAPPED_SUFFIX = "?commonjs-wrapped";
2856
+ const EXTERNAL_SUFFIX = "?commonjs-external";
2857
+ const EXPORTS_SUFFIX = "?commonjs-exports";
2858
+ const MODULE_SUFFIX = "?commonjs-module";
2859
+ const ENTRY_SUFFIX = "?commonjs-entry";
2860
+ const ES_IMPORT_SUFFIX = "?commonjs-es-import";
2861
+ const DYNAMIC_MODULES_ID = "\0commonjs-dynamic-modules";
2862
+ const HELPERS_ID = "\0commonjsHelpers.js";
2863
+ const IS_WRAPPED_COMMONJS = "withRequireFunction";
2864
+ const HELPERS = `
2865
+ export var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2866
+
2867
+ export function getDefaultExportFromCjs (x) {
2868
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
2869
+ }
2870
+
2871
+ export function getDefaultExportFromNamespaceIfPresent (n) {
2872
+ return n && Object.prototype.hasOwnProperty.call(n, 'default') ? n['default'] : n;
2873
+ }
2874
+
2875
+ export function getDefaultExportFromNamespaceIfNotNamed (n) {
2876
+ return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n;
2877
+ }
2878
+
2879
+ export function getAugmentedNamespace(n) {
2880
+ if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n;
2881
+ var f = n.default;
2882
+ if (typeof f == "function") {
2883
+ var a = function a () {
2884
+ var isInstance = false;
2885
+ try {
2886
+ isInstance = this instanceof a;
2887
+ } catch {}
2888
+ if (isInstance) {
2889
+ return Reflect.construct(f, arguments, this.constructor);
2890
+ }
2891
+ return f.apply(this, arguments);
2892
+ };
2893
+ a.prototype = f.prototype;
2894
+ } else a = {};
2895
+ Object.defineProperty(a, '__esModule', {value: true});
2896
+ Object.keys(n).forEach(function (k) {
2897
+ var d = Object.getOwnPropertyDescriptor(n, k);
2898
+ Object.defineProperty(a, k, d.get ? d : {
2899
+ enumerable: true,
2900
+ get: function () {
2901
+ return n[k];
2902
+ }
2903
+ });
2904
+ });
2905
+ return a;
2906
+ }
2907
+ `;
2908
+ function getHelpersModule() {
2909
+ return HELPERS;
2910
+ }
2911
+ function getUnknownRequireProxy(id, requireReturnsDefault) {
2912
+ if (requireReturnsDefault === true || id.endsWith(".json")) return `export { default } from ${JSON.stringify(id)};`;
2913
+ const name = getName(id);
2914
+ const exported = requireReturnsDefault === "auto" ? `import { getDefaultExportFromNamespaceIfNotNamed } from "${HELPERS_ID}"; export default /*@__PURE__*/getDefaultExportFromNamespaceIfNotNamed(${name});` : requireReturnsDefault === "preferred" ? `import { getDefaultExportFromNamespaceIfPresent } from "${HELPERS_ID}"; export default /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(${name});` : !requireReturnsDefault ? `import { getAugmentedNamespace } from "${HELPERS_ID}"; export default /*@__PURE__*/getAugmentedNamespace(${name});` : `export default ${name};`;
2915
+ return `import * as ${name} from ${JSON.stringify(id)}; ${exported}`;
2916
+ }
2917
+ async function getStaticRequireProxy(id, requireReturnsDefault, loadModule) {
2918
+ const name = getName(id);
2919
+ const { meta: { commonjs: commonjsMeta } } = await loadModule({ id });
2920
+ if (!commonjsMeta) return getUnknownRequireProxy(id, requireReturnsDefault);
2921
+ if (commonjsMeta.isCommonJS) return `export { __moduleExports as default } from ${JSON.stringify(id)};`;
2922
+ if (!requireReturnsDefault) return `import { getAugmentedNamespace } from "${HELPERS_ID}"; import * as ${name} from ${JSON.stringify(id)}; export default /*@__PURE__*/getAugmentedNamespace(${name});`;
2923
+ if (requireReturnsDefault !== true && (requireReturnsDefault === "namespace" || !commonjsMeta.hasDefaultExport || requireReturnsDefault === "auto" && commonjsMeta.hasNamedExports)) return `import * as ${name} from ${JSON.stringify(id)}; export default ${name};`;
2924
+ return `export { default } from ${JSON.stringify(id)};`;
2925
+ }
2926
+ function getEntryProxy(id, defaultIsModuleExports, getModuleInfo, shebang) {
2927
+ const { meta: { commonjs: commonjsMeta }, hasDefaultExport } = getModuleInfo(id);
2928
+ if (!commonjsMeta || commonjsMeta.isCommonJS !== IS_WRAPPED_COMMONJS) {
2929
+ const stringifiedId = JSON.stringify(id);
2930
+ let code = `export * from ${stringifiedId};`;
2931
+ if (hasDefaultExport) code += `export { default } from ${stringifiedId};`;
2932
+ return shebang + code;
2933
+ }
2934
+ const result = getEsImportProxy(id, defaultIsModuleExports, true);
2935
+ return {
2936
+ ...result,
2937
+ code: shebang + result.code
2938
+ };
2939
+ }
2940
+ function getEsImportProxy(id, defaultIsModuleExports, moduleSideEffects) {
2941
+ const name = getName(id);
2942
+ const exportsName = `${name}Exports`;
2943
+ const requireModule = `require${capitalize(name)}`;
2944
+ let code = `import { getDefaultExportFromCjs } from "${HELPERS_ID}";\nimport { __require as ${requireModule} } from ${JSON.stringify(id)};\nvar ${exportsName} = ${moduleSideEffects ? "" : "/*@__PURE__*/ "}${requireModule}();\nexport { ${exportsName} as __moduleExports };`;
2945
+ if (defaultIsModuleExports === true) code += `\nexport { ${exportsName} as default };`;
2946
+ else if (defaultIsModuleExports === false) code += `\nexport default ${exportsName}.default;`;
2947
+ else code += `\nexport default /*@__PURE__*/getDefaultExportFromCjs(${exportsName});`;
2948
+ return {
2949
+ code,
2950
+ syntheticNamedExports: "__moduleExports"
2951
+ };
2952
+ }
2953
+ function getExternalBuiltinRequireProxy(id) {
2954
+ return `import { createRequire } from 'node:module';
2955
+ const require = createRequire(import.meta.url);
2956
+ export function __require() { return require(${JSON.stringify(id)}); }`;
2957
+ }
2958
+ function getCandidatesForExtension(resolved, extension) {
2959
+ return [resolved + extension, `${resolved}${sep}index${extension}`];
2960
+ }
2961
+ function getCandidates(resolved, extensions) {
2962
+ return extensions.reduce((paths, extension) => paths.concat(getCandidatesForExtension(resolved, extension)), [resolved]);
2963
+ }
2964
+ function resolveExtensions(importee, importer, extensions) {
2965
+ if (importee[0] !== "." || !importer) return void 0;
2966
+ const candidates = getCandidates(resolve(dirname(importer), importee), extensions);
2967
+ for (let i = 0; i < candidates.length; i += 1) try {
2968
+ if (statSync(candidates[i]).isFile()) return { id: candidates[i] };
2969
+ } catch (err) {}
2970
+ }
2971
+ function getResolveId(extensions, isPossibleCjsId) {
2972
+ const currentlyResolving = /* @__PURE__ */ new Map();
2973
+ return {
2974
+ currentlyResolving,
2975
+ async resolveId(importee, importer, resolveOptions) {
2976
+ if (resolveOptions.custom?.["node-resolve"]?.isRequire) return null;
2977
+ const currentlyResolvingForParent = currentlyResolving.get(importer);
2978
+ if (currentlyResolvingForParent && currentlyResolvingForParent.has(importee)) {
2979
+ this.warn({
2980
+ code: "THIS_RESOLVE_WITHOUT_OPTIONS",
2981
+ message: "It appears a plugin has implemented a \"resolveId\" hook that uses \"this.resolve\" without forwarding the third \"options\" parameter of \"resolveId\". This is problematic as it can lead to wrong module resolutions especially for the node-resolve plugin and in certain cases cause early exit errors for the commonjs plugin.\nIn rare cases, this warning can appear if the same file is both imported and required from the same mixed ES/CommonJS module, in which case it can be ignored.",
2982
+ url: "https://rollupjs.org/guide/en/#resolveid"
2983
+ });
2984
+ return null;
2985
+ }
2986
+ if (isWrappedId(importee, WRAPPED_SUFFIX)) return unwrapId(importee, WRAPPED_SUFFIX);
2987
+ if (importee.endsWith(ENTRY_SUFFIX) || isWrappedId(importee, MODULE_SUFFIX) || isWrappedId(importee, EXPORTS_SUFFIX) || isWrappedId(importee, PROXY_SUFFIX) || isWrappedId(importee, ES_IMPORT_SUFFIX) || isWrappedId(importee, EXTERNAL_SUFFIX) || importee.startsWith(HELPERS_ID) || importee === DYNAMIC_MODULES_ID) return importee;
2988
+ if (importer) {
2989
+ if (importer === DYNAMIC_MODULES_ID || isWrappedId(importer, PROXY_SUFFIX) || isWrappedId(importer, ES_IMPORT_SUFFIX) || importer.endsWith(ENTRY_SUFFIX)) return importee;
2990
+ if (isWrappedId(importer, EXTERNAL_SUFFIX)) {
2991
+ if (!await this.resolve(importee, importer, Object.assign({ skipSelf: true }, resolveOptions))) return null;
2992
+ return {
2993
+ id: importee,
2994
+ external: true
2995
+ };
2996
+ }
2997
+ }
2998
+ if (importee.startsWith("\0")) return null;
2999
+ const resolved = await this.resolve(importee, importer, Object.assign({ skipSelf: true }, resolveOptions)) || resolveExtensions(importee, importer, extensions);
3000
+ if (!resolved || resolved.external || resolved.id.endsWith(ENTRY_SUFFIX) || isWrappedId(resolved.id, ES_IMPORT_SUFFIX) || !isPossibleCjsId(resolved.id)) return resolved;
3001
+ const moduleInfo = await this.load(resolved);
3002
+ const { meta: { commonjs: commonjsMeta } } = moduleInfo;
3003
+ if (commonjsMeta) {
3004
+ const { isCommonJS } = commonjsMeta;
3005
+ if (isCommonJS) {
3006
+ if (resolveOptions.isEntry) {
3007
+ moduleInfo.moduleSideEffects = true;
3008
+ return resolved.id + ENTRY_SUFFIX;
3009
+ }
3010
+ if (isCommonJS === IS_WRAPPED_COMMONJS) return {
3011
+ id: wrapId(resolved.id, ES_IMPORT_SUFFIX),
3012
+ meta: { commonjs: { resolved } }
3013
+ };
3014
+ }
3015
+ }
3016
+ return resolved;
3017
+ }
3018
+ };
3019
+ }
3020
+ function getRequireResolver(extensions, detectCyclesAndConditional, currentlyResolving, requireNodeBuiltins) {
3021
+ const knownCjsModuleTypes = Object.create(null);
3022
+ const requiredIds = Object.create(null);
3023
+ const unconditionallyRequiredIds = Object.create(null);
3024
+ const dependencies = Object.create(null);
3025
+ const getDependencies = (id) => dependencies[id] || (dependencies[id] = /* @__PURE__ */ new Set());
3026
+ const isCyclic = (id) => {
3027
+ const dependenciesToCheck = new Set(getDependencies(id));
3028
+ for (const dependency of dependenciesToCheck) {
3029
+ if (dependency === id) return true;
3030
+ for (const childDependency of getDependencies(dependency)) dependenciesToCheck.add(childDependency);
3031
+ }
3032
+ return false;
3033
+ };
3034
+ const fullyAnalyzedModules = Object.create(null);
3035
+ const getTypeForFullyAnalyzedModule = (id) => {
3036
+ const knownType = knownCjsModuleTypes[id];
3037
+ if (knownType !== true || !detectCyclesAndConditional || fullyAnalyzedModules[id]) return knownType;
3038
+ if (isCyclic(id)) return knownCjsModuleTypes[id] = IS_WRAPPED_COMMONJS;
3039
+ return knownType;
3040
+ };
3041
+ const setInitialParentType = (id, initialCommonJSType) => {
3042
+ if (fullyAnalyzedModules[id]) return;
3043
+ knownCjsModuleTypes[id] = initialCommonJSType;
3044
+ if (detectCyclesAndConditional && knownCjsModuleTypes[id] === true && requiredIds[id] && !unconditionallyRequiredIds[id]) knownCjsModuleTypes[id] = IS_WRAPPED_COMMONJS;
3045
+ };
3046
+ const analyzeRequiredModule = async (parentId, resolved, isConditional, loadModule) => {
3047
+ const childId = resolved.id;
3048
+ requiredIds[childId] = true;
3049
+ if (!(isConditional || knownCjsModuleTypes[parentId] === IS_WRAPPED_COMMONJS)) unconditionallyRequiredIds[childId] = true;
3050
+ getDependencies(parentId).add(childId);
3051
+ if (!isCyclic(childId)) await loadModule(resolved);
3052
+ };
3053
+ const getTypeForImportedModule = async (resolved, loadModule) => {
3054
+ if (resolved.id in knownCjsModuleTypes) return knownCjsModuleTypes[resolved.id];
3055
+ const { meta: { commonjs: commonjs$1 } } = await loadModule(resolved);
3056
+ return commonjs$1 && commonjs$1.isCommonJS || false;
3057
+ };
3058
+ return {
3059
+ getWrappedIds: () => Object.keys(knownCjsModuleTypes).filter((id) => knownCjsModuleTypes[id] === IS_WRAPPED_COMMONJS),
3060
+ isRequiredId: (id) => requiredIds[id],
3061
+ async shouldTransformCachedModule({ id: parentId, resolvedSources, meta: { commonjs: parentMeta } }) {
3062
+ if (!(parentMeta && parentMeta.isCommonJS)) knownCjsModuleTypes[parentId] = false;
3063
+ if (isWrappedId(parentId, ES_IMPORT_SUFFIX)) return false;
3064
+ const parentRequires = parentMeta && parentMeta.requires;
3065
+ if (parentRequires) {
3066
+ setInitialParentType(parentId, parentMeta.initialCommonJSType);
3067
+ await Promise.all(parentRequires.map(({ resolved, isConditional }) => analyzeRequiredModule(parentId, resolved, isConditional, this.load)));
3068
+ if (getTypeForFullyAnalyzedModule(parentId) !== parentMeta.isCommonJS) return true;
3069
+ for (const { resolved: { id } } of parentRequires) if (getTypeForFullyAnalyzedModule(id) !== parentMeta.isRequiredCommonJS[id]) return true;
3070
+ fullyAnalyzedModules[parentId] = true;
3071
+ for (const { resolved: { id } } of parentRequires) fullyAnalyzedModules[id] = true;
3072
+ }
3073
+ const parentRequireSet = new Set((parentRequires || []).map(({ resolved: { id } }) => id));
3074
+ return (await Promise.all(Object.keys(resolvedSources).map((source) => resolvedSources[source]).filter(({ id, external }) => !(external || parentRequireSet.has(id))).map(async (resolved) => {
3075
+ if (isWrappedId(resolved.id, ES_IMPORT_SUFFIX)) return await getTypeForImportedModule((await this.load(resolved)).meta.commonjs.resolved, this.load) !== IS_WRAPPED_COMMONJS;
3076
+ return await getTypeForImportedModule(resolved, this.load) === IS_WRAPPED_COMMONJS;
3077
+ }))).some((shouldTransform) => shouldTransform);
3078
+ },
3079
+ resolveRequireSourcesAndUpdateMeta: (rollupContext) => async (parentId, isParentCommonJS, parentMeta, sources) => {
3080
+ parentMeta.initialCommonJSType = isParentCommonJS;
3081
+ parentMeta.requires = [];
3082
+ parentMeta.isRequiredCommonJS = Object.create(null);
3083
+ setInitialParentType(parentId, isParentCommonJS);
3084
+ const currentlyResolvingForParent = currentlyResolving.get(parentId) || /* @__PURE__ */ new Set();
3085
+ currentlyResolving.set(parentId, currentlyResolvingForParent);
3086
+ const requireTargets = await Promise.all(sources.map(async ({ source, isConditional }) => {
3087
+ if (source.startsWith("\0")) return {
3088
+ id: source,
3089
+ allowProxy: false
3090
+ };
3091
+ currentlyResolvingForParent.add(source);
3092
+ const resolved = await rollupContext.resolve(source, parentId, {
3093
+ skipSelf: false,
3094
+ custom: { "node-resolve": { isRequire: true } }
3095
+ }) || resolveExtensions(source, parentId, extensions);
3096
+ currentlyResolvingForParent.delete(source);
3097
+ if (!resolved) return {
3098
+ id: wrapId(source, EXTERNAL_SUFFIX),
3099
+ allowProxy: false
3100
+ };
3101
+ const childId = resolved.id;
3102
+ if (resolved.external) return {
3103
+ id: wrapId(childId, EXTERNAL_SUFFIX),
3104
+ allowProxy: false
3105
+ };
3106
+ parentMeta.requires.push({
3107
+ resolved,
3108
+ isConditional
3109
+ });
3110
+ await analyzeRequiredModule(parentId, resolved, isConditional, rollupContext.load);
3111
+ return {
3112
+ id: childId,
3113
+ allowProxy: true
3114
+ };
3115
+ }));
3116
+ parentMeta.isCommonJS = getTypeForFullyAnalyzedModule(parentId);
3117
+ fullyAnalyzedModules[parentId] = true;
3118
+ return requireTargets.map(({ id: dependencyId, allowProxy }, index) => {
3119
+ let isCommonJS = parentMeta.isRequiredCommonJS[dependencyId] = getTypeForFullyAnalyzedModule(dependencyId);
3120
+ const isExternalWrapped = isWrappedId(dependencyId, EXTERNAL_SUFFIX);
3121
+ let resolvedDependencyId = dependencyId;
3122
+ if (requireNodeBuiltins === true) {
3123
+ if (parentMeta.isCommonJS === IS_WRAPPED_COMMONJS && !allowProxy && isExternalWrapped) {
3124
+ if (unwrapId(dependencyId, EXTERNAL_SUFFIX).startsWith("node:")) {
3125
+ isCommonJS = IS_WRAPPED_COMMONJS;
3126
+ parentMeta.isRequiredCommonJS[dependencyId] = isCommonJS;
3127
+ }
3128
+ } else if (isExternalWrapped && !allowProxy) {
3129
+ const actualExternalId = unwrapId(dependencyId, EXTERNAL_SUFFIX);
3130
+ if (actualExternalId.startsWith("node:")) resolvedDependencyId = actualExternalId;
3131
+ }
3132
+ }
3133
+ const isWrappedCommonJS = isCommonJS === IS_WRAPPED_COMMONJS;
3134
+ fullyAnalyzedModules[dependencyId] = true;
3135
+ const moduleInfo = isWrappedCommonJS && !isExternalWrapped ? rollupContext.getModuleInfo(dependencyId) : null;
3136
+ return {
3137
+ wrappedModuleSideEffects: !isWrappedCommonJS ? false : moduleInfo?.moduleSideEffects ?? true,
3138
+ source: sources[index].source,
3139
+ id: allowProxy ? wrapId(resolvedDependencyId, isWrappedCommonJS ? WRAPPED_SUFFIX : PROXY_SUFFIX) : resolvedDependencyId,
3140
+ isCommonJS
3141
+ };
3142
+ });
3143
+ },
3144
+ isCurrentlyResolving(source, parentId) {
3145
+ const currentlyResolvingForParent = currentlyResolving.get(parentId);
3146
+ return currentlyResolvingForParent && currentlyResolvingForParent.has(source);
3147
+ }
3148
+ };
3149
+ }
3150
+ function validateVersion(actualVersion, peerDependencyVersion, name) {
3151
+ const versionRegexp = /\^(\d+\.\d+\.\d+)/g;
3152
+ let minMajor = Infinity;
3153
+ let minMinor = Infinity;
3154
+ let minPatch = Infinity;
3155
+ let foundVersion;
3156
+ while (foundVersion = versionRegexp.exec(peerDependencyVersion)) {
3157
+ const [foundMajor, foundMinor, foundPatch] = foundVersion[1].split(".").map(Number);
3158
+ if (foundMajor < minMajor) {
3159
+ minMajor = foundMajor;
3160
+ minMinor = foundMinor;
3161
+ minPatch = foundPatch;
3162
+ }
3163
+ }
3164
+ if (!actualVersion) throw new Error(`Insufficient ${name} version: "@rollup/plugin-commonjs" requires at least ${name}@${minMajor}.${minMinor}.${minPatch}.`);
3165
+ const [major, minor, patch] = actualVersion.split(".").map(Number);
3166
+ if (major < minMajor || major === minMajor && (minor < minMinor || minor === minMinor && patch < minPatch)) throw new Error(`Insufficient ${name} version: "@rollup/plugin-commonjs" requires at least ${name}@${minMajor}.${minMinor}.${minPatch} but found ${name}@${actualVersion}.`);
3167
+ }
3168
+ const operators = {
3169
+ "==": (x) => equals(x.left, x.right, false),
3170
+ "!=": (x) => not(operators["=="](x)),
3171
+ "===": (x) => equals(x.left, x.right, true),
3172
+ "!==": (x) => not(operators["==="](x)),
3173
+ "!": (x) => isFalsy(x.argument),
3174
+ "&&": (x) => isTruthy(x.left) && isTruthy(x.right),
3175
+ "||": (x) => isTruthy(x.left) || isTruthy(x.right)
3176
+ };
3177
+ function not(value) {
3178
+ return value === null ? value : !value;
3179
+ }
3180
+ function equals(a, b, strict) {
3181
+ if (a.type !== b.type) return null;
3182
+ if (a.type === "Literal") return strict ? a.value === b.value : a.value == b.value;
3183
+ return null;
3184
+ }
3185
+ function isTruthy(node) {
3186
+ if (!node) return false;
3187
+ if (node.type === "Literal") return !!node.value;
3188
+ if (node.type === "ParenthesizedExpression") return isTruthy(node.expression);
3189
+ if (node.operator in operators) return operators[node.operator](node);
3190
+ return null;
3191
+ }
3192
+ function isFalsy(node) {
3193
+ return not(isTruthy(node));
3194
+ }
3195
+ function getKeypath(node) {
3196
+ const parts = [];
3197
+ while (node.type === "MemberExpression") {
3198
+ if (node.computed) return null;
3199
+ parts.unshift(node.property.name);
3200
+ node = node.object;
3201
+ }
3202
+ if (node.type !== "Identifier") return null;
3203
+ const { name } = node;
3204
+ parts.unshift(name);
3205
+ return {
3206
+ name,
3207
+ keypath: parts.join(".")
3208
+ };
3209
+ }
3210
+ const KEY_COMPILED_ESM = "__esModule";
3211
+ function getDefineCompiledEsmType(node) {
3212
+ const definedPropertyWithExports = getDefinePropertyCallName(node, "exports");
3213
+ const definedProperty = definedPropertyWithExports || getDefinePropertyCallName(node, "module.exports");
3214
+ if (definedProperty && definedProperty.key === KEY_COMPILED_ESM) return isTruthy(definedProperty.value) ? definedPropertyWithExports ? "exports" : "module" : false;
3215
+ return false;
3216
+ }
3217
+ function getDefinePropertyCallName(node, targetName) {
3218
+ const { callee: { object, property } } = node;
3219
+ if (!object || object.type !== "Identifier" || object.name !== "Object") return;
3220
+ if (!property || property.type !== "Identifier" || property.name !== "defineProperty") return;
3221
+ if (node.arguments.length !== 3) return;
3222
+ const targetNames = targetName.split(".");
3223
+ const [target, key, value] = node.arguments;
3224
+ if (targetNames.length === 1) {
3225
+ if (target.type !== "Identifier" || target.name !== targetNames[0]) return;
3226
+ }
3227
+ if (targetNames.length === 2) {
3228
+ if (target.type !== "MemberExpression" || target.object.name !== targetNames[0] || target.property.name !== targetNames[1]) return;
3229
+ }
3230
+ if (value.type !== "ObjectExpression" || !value.properties) return;
3231
+ const valueProperty = value.properties.find((p) => p.key && p.key.name === "value");
3232
+ if (!valueProperty || !valueProperty.value) return;
3233
+ return {
3234
+ key: key.value,
3235
+ value: valueProperty.value
3236
+ };
3237
+ }
3238
+ function isShorthandProperty(parent) {
3239
+ return parent && parent.type === "Property" && parent.shorthand;
3240
+ }
3241
+ function wrapCode(magicString, uses, moduleName, exportsName, indentExclusionRanges) {
3242
+ const args = [];
3243
+ const passedArgs = [];
3244
+ if (uses.module) {
3245
+ args.push("module");
3246
+ passedArgs.push(moduleName);
3247
+ }
3248
+ if (uses.exports) {
3249
+ args.push("exports");
3250
+ passedArgs.push(uses.module ? `${moduleName}.exports` : exportsName);
3251
+ }
3252
+ magicString.trim().indent(" ", { exclude: indentExclusionRanges }).prepend(`(function (${args.join(", ")}) {\n`).append(` \n} (${passedArgs.join(", ")}));`);
3253
+ }
3254
+ function rewriteExportsAndGetExportsBlock(magicString, moduleName, exportsName, exportedExportsName, wrapped, moduleExportsAssignments, firstTopLevelModuleExportsAssignment, exportsAssignmentsByName, topLevelAssignments, defineCompiledEsmExpressions, deconflictedExportNames, code, HELPERS_NAME, exportMode, defaultIsModuleExports, usesRequireWrapper, requireName) {
3255
+ const exports$1 = [];
3256
+ const exportDeclarations = [];
3257
+ if (usesRequireWrapper) getExportsWhenUsingRequireWrapper(magicString, wrapped, exportMode, exports$1, moduleExportsAssignments, exportsAssignmentsByName, moduleName, exportsName, requireName, defineCompiledEsmExpressions);
3258
+ else if (exportMode === "replace") getExportsForReplacedModuleExports(magicString, exports$1, exportDeclarations, moduleExportsAssignments, firstTopLevelModuleExportsAssignment, exportsName, defaultIsModuleExports, HELPERS_NAME);
3259
+ else {
3260
+ if (exportMode === "module") {
3261
+ exportDeclarations.push(`var ${exportedExportsName} = ${moduleName}.exports`);
3262
+ exports$1.push(`${exportedExportsName} as __moduleExports`);
3263
+ } else exports$1.push(`${exportsName} as __moduleExports`);
3264
+ if (wrapped) exportDeclarations.push(getDefaultExportDeclaration(exportedExportsName, defaultIsModuleExports, HELPERS_NAME));
3265
+ else getExports(magicString, exports$1, exportDeclarations, moduleExportsAssignments, exportsAssignmentsByName, deconflictedExportNames, topLevelAssignments, moduleName, exportsName, exportedExportsName, defineCompiledEsmExpressions, HELPERS_NAME, defaultIsModuleExports, exportMode);
3266
+ }
3267
+ if (exports$1.length) exportDeclarations.push(`export { ${exports$1.join(", ")} }`);
3268
+ return `\n\n${exportDeclarations.join(";\n")};`;
3269
+ }
3270
+ function getExportsWhenUsingRequireWrapper(magicString, wrapped, exportMode, exports$1, moduleExportsAssignments, exportsAssignmentsByName, moduleName, exportsName, requireName, defineCompiledEsmExpressions) {
3271
+ exports$1.push(`${requireName} as __require`);
3272
+ if (wrapped) return;
3273
+ if (exportMode === "replace") rewriteModuleExportsAssignments(magicString, moduleExportsAssignments, exportsName);
3274
+ else {
3275
+ rewriteModuleExportsAssignments(magicString, moduleExportsAssignments, `${moduleName}.exports`);
3276
+ for (const [exportName, { nodes }] of exportsAssignmentsByName) for (const { node, type } of nodes) magicString.overwrite(node.start, node.left.end, `${exportMode === "module" && type === "module" ? `${moduleName}.exports` : exportsName}.${exportName}`);
3277
+ replaceDefineCompiledEsmExpressionsAndGetIfRestorable(defineCompiledEsmExpressions, magicString, exportMode, moduleName, exportsName);
3278
+ }
3279
+ }
3280
+ function getExportsForReplacedModuleExports(magicString, exports$1, exportDeclarations, moduleExportsAssignments, firstTopLevelModuleExportsAssignment, exportsName, defaultIsModuleExports, HELPERS_NAME) {
3281
+ for (const { left } of moduleExportsAssignments) magicString.overwrite(left.start, left.end, exportsName);
3282
+ magicString.prependRight(firstTopLevelModuleExportsAssignment.left.start, "var ");
3283
+ exports$1.push(`${exportsName} as __moduleExports`);
3284
+ exportDeclarations.push(getDefaultExportDeclaration(exportsName, defaultIsModuleExports, HELPERS_NAME));
3285
+ }
3286
+ function getDefaultExportDeclaration(exportedExportsName, defaultIsModuleExports, HELPERS_NAME) {
3287
+ return `export default ${defaultIsModuleExports === true ? exportedExportsName : defaultIsModuleExports === false ? `${exportedExportsName}.default` : `/*@__PURE__*/${HELPERS_NAME}.getDefaultExportFromCjs(${exportedExportsName})`}`;
3288
+ }
3289
+ function getExports(magicString, exports$1, exportDeclarations, moduleExportsAssignments, exportsAssignmentsByName, deconflictedExportNames, topLevelAssignments, moduleName, exportsName, exportedExportsName, defineCompiledEsmExpressions, HELPERS_NAME, defaultIsModuleExports, exportMode) {
3290
+ let deconflictedDefaultExportName;
3291
+ for (const { left } of moduleExportsAssignments) magicString.overwrite(left.start, left.end, `${moduleName}.exports`);
3292
+ for (const [exportName, { nodes }] of exportsAssignmentsByName) {
3293
+ const deconflicted = deconflictedExportNames[exportName];
3294
+ let needsDeclaration = true;
3295
+ for (const { node, type } of nodes) {
3296
+ let replacement = `${deconflicted} = ${exportMode === "module" && type === "module" ? `${moduleName}.exports` : exportsName}.${exportName}`;
3297
+ if (needsDeclaration && topLevelAssignments.has(node)) {
3298
+ replacement = `var ${replacement}`;
3299
+ needsDeclaration = false;
3300
+ }
3301
+ magicString.overwrite(node.start, node.left.end, replacement);
3302
+ }
3303
+ if (needsDeclaration) magicString.prepend(`var ${deconflicted};\n`);
3304
+ if (exportName === "default") deconflictedDefaultExportName = deconflicted;
3305
+ else exports$1.push(exportName === deconflicted ? exportName : `${deconflicted} as ${exportName}`);
3306
+ }
3307
+ const isRestorableCompiledEsm = replaceDefineCompiledEsmExpressionsAndGetIfRestorable(defineCompiledEsmExpressions, magicString, exportMode, moduleName, exportsName);
3308
+ if (defaultIsModuleExports === false || defaultIsModuleExports === "auto" && isRestorableCompiledEsm && moduleExportsAssignments.length === 0) exports$1.push(`${deconflictedDefaultExportName || exportedExportsName} as default`);
3309
+ else if (defaultIsModuleExports === true || !isRestorableCompiledEsm && moduleExportsAssignments.length === 0) exports$1.push(`${exportedExportsName} as default`);
3310
+ else exportDeclarations.push(getDefaultExportDeclaration(exportedExportsName, defaultIsModuleExports, HELPERS_NAME));
3311
+ }
3312
+ function rewriteModuleExportsAssignments(magicString, moduleExportsAssignments, exportsName) {
3313
+ for (const { left } of moduleExportsAssignments) magicString.overwrite(left.start, left.end, exportsName);
3314
+ }
3315
+ function replaceDefineCompiledEsmExpressionsAndGetIfRestorable(defineCompiledEsmExpressions, magicString, exportMode, moduleName, exportsName) {
3316
+ let isRestorableCompiledEsm = false;
3317
+ for (const { node, type } of defineCompiledEsmExpressions) {
3318
+ isRestorableCompiledEsm = true;
3319
+ const moduleExportsExpression = node.type === "CallExpression" ? node.arguments[0] : node.left.object;
3320
+ magicString.overwrite(moduleExportsExpression.start, moduleExportsExpression.end, exportMode === "module" && type === "module" ? `${moduleName}.exports` : exportsName);
3321
+ }
3322
+ return isRestorableCompiledEsm;
3323
+ }
3324
+ function isRequireExpression(node, scope) {
3325
+ if (!node) return false;
3326
+ if (node.type !== "CallExpression") return false;
3327
+ if (node.arguments.length === 0) return false;
3328
+ return isRequire(node.callee, scope);
3329
+ }
3330
+ function isRequire(node, scope) {
3331
+ return node.type === "Identifier" && node.name === "require" && !scope.contains("require") || node.type === "MemberExpression" && isModuleRequire(node, scope);
3332
+ }
3333
+ function isModuleRequire({ object, property }, scope) {
3334
+ return object.type === "Identifier" && object.name === "module" && property.type === "Identifier" && property.name === "require" && !scope.contains("module");
3335
+ }
3336
+ function hasDynamicArguments(node) {
3337
+ return node.arguments.length > 1 || node.arguments[0].type !== "Literal" && (node.arguments[0].type !== "TemplateLiteral" || node.arguments[0].expressions.length > 0);
3338
+ }
3339
+ const reservedMethod = {
3340
+ resolve: true,
3341
+ cache: true,
3342
+ main: true
3343
+ };
3344
+ function isNodeRequirePropertyAccess(parent) {
3345
+ return parent && parent.property && reservedMethod[parent.property.name];
3346
+ }
3347
+ function getRequireStringArg(node) {
3348
+ return node.arguments[0].type === "Literal" ? node.arguments[0].value : node.arguments[0].quasis[0].value.cooked;
3349
+ }
3350
+ function getRequireHandlers() {
3351
+ const requireExpressions = [];
3352
+ function addRequireExpression(sourceId, node, scope, usesReturnValue, isInsideTryBlock, isInsideConditional, toBeRemoved) {
3353
+ requireExpressions.push({
3354
+ sourceId,
3355
+ node,
3356
+ scope,
3357
+ usesReturnValue,
3358
+ isInsideTryBlock,
3359
+ isInsideConditional,
3360
+ toBeRemoved
3361
+ });
3362
+ }
3363
+ async function rewriteRequireExpressionsAndGetImportBlock(magicString, topLevelDeclarations, reassignedNames, helpersName, dynamicRequireName, moduleName, exportsName, id, exportMode, resolveRequireSourcesAndUpdateMeta, needsRequireWrapper, isEsModule, isDynamicRequireModulesEnabled, getIgnoreTryCatchRequireStatementMode, commonjsMeta) {
3364
+ const imports = [];
3365
+ imports.push(`import * as ${helpersName} from "${HELPERS_ID}"`);
3366
+ if (dynamicRequireName) imports.push(`import { ${isDynamicRequireModulesEnabled ? CREATE_COMMONJS_REQUIRE_EXPORT : COMMONJS_REQUIRE_EXPORT} as ${dynamicRequireName} } from "${DYNAMIC_MODULES_ID}"`);
3367
+ if (exportMode === "module") imports.push(`import { __module as ${moduleName} } from ${JSON.stringify(wrapId(id, MODULE_SUFFIX))}`, `var ${exportsName} = ${moduleName}.exports`);
3368
+ else if (exportMode === "exports") imports.push(`import { __exports as ${exportsName} } from ${JSON.stringify(wrapId(id, EXPORTS_SUFFIX))}`);
3369
+ const requiresBySource = collectSources(requireExpressions);
3370
+ processRequireExpressions(imports, await resolveRequireSourcesAndUpdateMeta(id, needsRequireWrapper ? IS_WRAPPED_COMMONJS : !isEsModule, commonjsMeta, Object.keys(requiresBySource).map((source) => {
3371
+ return {
3372
+ source,
3373
+ isConditional: requiresBySource[source].every((require$1) => require$1.isInsideConditional)
3374
+ };
3375
+ })), requiresBySource, getIgnoreTryCatchRequireStatementMode, magicString);
3376
+ return imports.length ? `${imports.join(";\n")};\n\n` : "";
3377
+ }
3378
+ return {
3379
+ addRequireExpression,
3380
+ rewriteRequireExpressionsAndGetImportBlock
3381
+ };
3382
+ }
3383
+ function collectSources(requireExpressions) {
3384
+ const requiresBySource = Object.create(null);
3385
+ for (const requireExpression of requireExpressions) {
3386
+ const { sourceId } = requireExpression;
3387
+ if (!requiresBySource[sourceId]) requiresBySource[sourceId] = [];
3388
+ requiresBySource[sourceId].push(requireExpression);
3389
+ }
3390
+ return requiresBySource;
3391
+ }
3392
+ function processRequireExpressions(imports, requireTargets, requiresBySource, getIgnoreTryCatchRequireStatementMode, magicString) {
3393
+ const generateRequireName = getGenerateRequireName();
3394
+ for (const { source, id: resolvedId, isCommonJS, wrappedModuleSideEffects } of requireTargets) {
3395
+ const requires = requiresBySource[source];
3396
+ const name = generateRequireName(requires);
3397
+ let usesRequired = false;
3398
+ let needsImport = false;
3399
+ for (const { node, usesReturnValue, toBeRemoved, isInsideTryBlock } of requires) {
3400
+ const { canConvertRequire, shouldRemoveRequire } = isInsideTryBlock && isWrappedId(resolvedId, EXTERNAL_SUFFIX) ? getIgnoreTryCatchRequireStatementMode(source) : {
3401
+ canConvertRequire: true,
3402
+ shouldRemoveRequire: false
3403
+ };
3404
+ if (shouldRemoveRequire) if (usesReturnValue) magicString.overwrite(node.start, node.end, "undefined");
3405
+ else magicString.remove(toBeRemoved.start, toBeRemoved.end);
3406
+ else if (canConvertRequire) {
3407
+ needsImport = true;
3408
+ if (isCommonJS === IS_WRAPPED_COMMONJS) magicString.overwrite(node.start, node.end, `${wrappedModuleSideEffects ? "" : "/*@__PURE__*/ "}${name}()`);
3409
+ else if (usesReturnValue) {
3410
+ usesRequired = true;
3411
+ magicString.overwrite(node.start, node.end, name);
3412
+ } else magicString.remove(toBeRemoved.start, toBeRemoved.end);
3413
+ }
3414
+ }
3415
+ if (needsImport) if (isCommonJS === IS_WRAPPED_COMMONJS) imports.push(`import { __require as ${name} } from ${JSON.stringify(resolvedId)}`);
3416
+ else imports.push(`import ${usesRequired ? `${name} from ` : ""}${JSON.stringify(resolvedId)}`);
3417
+ }
3418
+ }
3419
+ function getGenerateRequireName() {
3420
+ let uid = 0;
3421
+ return (requires) => {
3422
+ let name;
3423
+ const hasNameConflict = ({ scope }) => scope.contains(name);
3424
+ do {
3425
+ name = `require$$${uid}`;
3426
+ uid += 1;
3427
+ } while (requires.some(hasNameConflict));
3428
+ return name;
3429
+ };
3430
+ }
3431
+ const exportsPattern = /^(?:module\.)?exports(?:\.([a-zA-Z_$][a-zA-Z_$0-9]*))?$/;
3432
+ const functionType = /^(?:FunctionDeclaration|FunctionExpression|ArrowFunctionExpression)$/;
3433
+ async function transformCommonjs(parse$2, code, id, isEsModule, ignoreGlobal, ignoreRequire, ignoreDynamicRequires, getIgnoreTryCatchRequireStatementMode, sourceMap, isDynamicRequireModulesEnabled, dynamicRequireModules, commonDir, astCache, defaultIsModuleExports, needsRequireWrapper, resolveRequireSourcesAndUpdateMeta, isRequired, checkDynamicRequire, commonjsMeta) {
3434
+ const ast = astCache || tryParse(parse$2, code, id);
3435
+ const magicString = new MagicString(code);
3436
+ const uses = {
3437
+ module: false,
3438
+ exports: false,
3439
+ global: false,
3440
+ require: false
3441
+ };
3442
+ const virtualDynamicRequirePath = isDynamicRequireModulesEnabled && getVirtualPathForDynamicRequirePath(dirname(id), commonDir);
3443
+ let scope = attachScopes(ast, "scope");
3444
+ let lexicalDepth = 0;
3445
+ let programDepth = 0;
3446
+ let classBodyDepth = 0;
3447
+ let currentTryBlockEnd = null;
3448
+ let shouldWrap = false;
3449
+ const globals = /* @__PURE__ */ new Set();
3450
+ let currentConditionalNodeEnd = null;
3451
+ const conditionalNodes = /* @__PURE__ */ new Set();
3452
+ const { addRequireExpression, rewriteRequireExpressionsAndGetImportBlock } = getRequireHandlers();
3453
+ const reassignedNames = /* @__PURE__ */ new Set();
3454
+ const topLevelDeclarations = [];
3455
+ const skippedNodes = /* @__PURE__ */ new Set();
3456
+ const moduleAccessScopes = new Set([scope]);
3457
+ const exportsAccessScopes = new Set([scope]);
3458
+ const moduleExportsAssignments = [];
3459
+ let firstTopLevelModuleExportsAssignment = null;
3460
+ const exportsAssignmentsByName = /* @__PURE__ */ new Map();
3461
+ const topLevelAssignments = /* @__PURE__ */ new Set();
3462
+ const topLevelDefineCompiledEsmExpressions = [];
3463
+ const replacedGlobal = [];
3464
+ const replacedThis = [];
3465
+ const replacedDynamicRequires = [];
3466
+ const importedVariables = /* @__PURE__ */ new Set();
3467
+ const indentExclusionRanges = [];
3468
+ walk(ast, {
3469
+ enter(node, parent) {
3470
+ if (skippedNodes.has(node)) {
3471
+ this.skip();
3472
+ return;
3473
+ }
3474
+ if (currentTryBlockEnd !== null && node.start > currentTryBlockEnd) currentTryBlockEnd = null;
3475
+ if (currentConditionalNodeEnd !== null && node.start > currentConditionalNodeEnd) currentConditionalNodeEnd = null;
3476
+ if (currentConditionalNodeEnd === null && conditionalNodes.has(node)) currentConditionalNodeEnd = node.end;
3477
+ programDepth += 1;
3478
+ if (node.scope) ({scope} = node);
3479
+ if (functionType.test(node.type)) lexicalDepth += 1;
3480
+ if (sourceMap) {
3481
+ magicString.addSourcemapLocation(node.start);
3482
+ magicString.addSourcemapLocation(node.end);
3483
+ }
3484
+ switch (node.type) {
3485
+ case "AssignmentExpression":
3486
+ if (node.left.type === "MemberExpression") {
3487
+ const flattened = getKeypath(node.left);
3488
+ if (!flattened || scope.contains(flattened.name)) return;
3489
+ const exportsPatternMatch = exportsPattern.exec(flattened.keypath);
3490
+ if (!exportsPatternMatch || flattened.keypath === "exports") return;
3491
+ const [, exportName] = exportsPatternMatch;
3492
+ uses[flattened.name] = true;
3493
+ if (flattened.keypath === "module.exports") {
3494
+ moduleExportsAssignments.push(node);
3495
+ if (programDepth > 3) moduleAccessScopes.add(scope);
3496
+ else if (!firstTopLevelModuleExportsAssignment) firstTopLevelModuleExportsAssignment = node;
3497
+ } else if (exportName === KEY_COMPILED_ESM) if (programDepth > 3) shouldWrap = true;
3498
+ else topLevelDefineCompiledEsmExpressions.push({
3499
+ node,
3500
+ type: flattened.name
3501
+ });
3502
+ else {
3503
+ const exportsAssignments = exportsAssignmentsByName.get(exportName) || {
3504
+ nodes: [],
3505
+ scopes: /* @__PURE__ */ new Set()
3506
+ };
3507
+ exportsAssignments.nodes.push({
3508
+ node,
3509
+ type: flattened.name
3510
+ });
3511
+ exportsAssignments.scopes.add(scope);
3512
+ exportsAccessScopes.add(scope);
3513
+ exportsAssignmentsByName.set(exportName, exportsAssignments);
3514
+ if (programDepth <= 3) topLevelAssignments.add(node);
3515
+ }
3516
+ skippedNodes.add(node.left);
3517
+ } else for (const name of extractAssignedNames(node.left)) reassignedNames.add(name);
3518
+ return;
3519
+ case "CallExpression": {
3520
+ const defineCompiledEsmType = getDefineCompiledEsmType(node);
3521
+ if (defineCompiledEsmType) {
3522
+ if (programDepth === 3 && parent.type === "ExpressionStatement") {
3523
+ skippedNodes.add(node.arguments[0]);
3524
+ topLevelDefineCompiledEsmExpressions.push({
3525
+ node,
3526
+ type: defineCompiledEsmType
3527
+ });
3528
+ } else shouldWrap = true;
3529
+ return;
3530
+ }
3531
+ if (isDynamicRequireModulesEnabled && node.callee.object && isRequire(node.callee.object, scope) && node.callee.property.name === "resolve") {
3532
+ checkDynamicRequire(node.start);
3533
+ uses.require = true;
3534
+ const requireNode = node.callee.object;
3535
+ replacedDynamicRequires.push(requireNode);
3536
+ skippedNodes.add(node.callee);
3537
+ return;
3538
+ }
3539
+ if (!isRequireExpression(node, scope)) {
3540
+ const keypath = getKeypath(node.callee);
3541
+ if (keypath && importedVariables.has(keypath.name)) currentConditionalNodeEnd = Infinity;
3542
+ return;
3543
+ }
3544
+ skippedNodes.add(node.callee);
3545
+ uses.require = true;
3546
+ if (hasDynamicArguments(node)) {
3547
+ if (isDynamicRequireModulesEnabled) checkDynamicRequire(node.start);
3548
+ if (!ignoreDynamicRequires) replacedDynamicRequires.push(node.callee);
3549
+ return;
3550
+ }
3551
+ const requireStringArg = getRequireStringArg(node);
3552
+ if (!ignoreRequire(requireStringArg)) {
3553
+ const usesReturnValue = parent.type !== "ExpressionStatement";
3554
+ const toBeRemoved = parent.type === "ExpressionStatement" && (!currentConditionalNodeEnd || currentTryBlockEnd !== null && currentTryBlockEnd < currentConditionalNodeEnd) ? parent : node;
3555
+ addRequireExpression(requireStringArg, node, scope, usesReturnValue, currentTryBlockEnd !== null, currentConditionalNodeEnd !== null, toBeRemoved);
3556
+ if (parent.type === "VariableDeclarator" && parent.id.type === "Identifier") for (const name of extractAssignedNames(parent.id)) importedVariables.add(name);
3557
+ }
3558
+ return;
3559
+ }
3560
+ case "ClassBody":
3561
+ classBodyDepth += 1;
3562
+ return;
3563
+ case "ConditionalExpression":
3564
+ case "IfStatement":
3565
+ if (isFalsy(node.test)) skippedNodes.add(node.consequent);
3566
+ else if (isTruthy(node.test)) {
3567
+ if (node.alternate) skippedNodes.add(node.alternate);
3568
+ } else {
3569
+ conditionalNodes.add(node.consequent);
3570
+ if (node.alternate) conditionalNodes.add(node.alternate);
3571
+ }
3572
+ return;
3573
+ case "ArrowFunctionExpression":
3574
+ case "FunctionDeclaration":
3575
+ case "FunctionExpression":
3576
+ if (currentConditionalNodeEnd === null && !(parent.type === "CallExpression" && parent.callee === node)) currentConditionalNodeEnd = node.end;
3577
+ return;
3578
+ case "Identifier": {
3579
+ const { name } = node;
3580
+ if (!(0, import_is_reference.default)(node, parent) || scope.contains(name) || parent.type === "PropertyDefinition" && parent.key === node) return;
3581
+ switch (name) {
3582
+ case "require":
3583
+ uses.require = true;
3584
+ if (isNodeRequirePropertyAccess(parent)) return;
3585
+ if (!ignoreDynamicRequires) {
3586
+ if (isShorthandProperty(parent)) {
3587
+ skippedNodes.add(parent.value);
3588
+ magicString.prependRight(node.start, "require: ");
3589
+ }
3590
+ replacedDynamicRequires.push(node);
3591
+ }
3592
+ return;
3593
+ case "module":
3594
+ case "exports":
3595
+ shouldWrap = true;
3596
+ uses[name] = true;
3597
+ return;
3598
+ case "global":
3599
+ uses.global = true;
3600
+ if (!ignoreGlobal) replacedGlobal.push(node);
3601
+ return;
3602
+ case "define":
3603
+ magicString.overwrite(node.start, node.end, "undefined", { storeName: true });
3604
+ return;
3605
+ default:
3606
+ globals.add(name);
3607
+ return;
3608
+ }
3609
+ }
3610
+ case "LogicalExpression":
3611
+ if (node.operator === "&&") {
3612
+ if (isFalsy(node.left)) skippedNodes.add(node.right);
3613
+ else if (!isTruthy(node.left)) conditionalNodes.add(node.right);
3614
+ } else if (node.operator === "||") {
3615
+ if (isTruthy(node.left)) skippedNodes.add(node.right);
3616
+ else if (!isFalsy(node.left)) conditionalNodes.add(node.right);
3617
+ }
3618
+ return;
3619
+ case "MemberExpression":
3620
+ if (!isDynamicRequireModulesEnabled && isModuleRequire(node, scope)) {
3621
+ uses.require = true;
3622
+ replacedDynamicRequires.push(node);
3623
+ skippedNodes.add(node.object);
3624
+ skippedNodes.add(node.property);
3625
+ }
3626
+ return;
3627
+ case "ReturnStatement":
3628
+ if (lexicalDepth === 0) shouldWrap = true;
3629
+ return;
3630
+ case "ThisExpression":
3631
+ if (lexicalDepth === 0 && !classBodyDepth) {
3632
+ uses.global = true;
3633
+ if (!ignoreGlobal) replacedThis.push(node);
3634
+ }
3635
+ return;
3636
+ case "TryStatement":
3637
+ if (currentTryBlockEnd === null) currentTryBlockEnd = node.block.end;
3638
+ if (currentConditionalNodeEnd === null) currentConditionalNodeEnd = node.end;
3639
+ return;
3640
+ case "UnaryExpression":
3641
+ if (node.operator === "typeof") {
3642
+ const flattened = getKeypath(node.argument);
3643
+ if (!flattened) return;
3644
+ if (scope.contains(flattened.name)) return;
3645
+ if (!isEsModule && (flattened.keypath === "module.exports" || flattened.keypath === "module" || flattened.keypath === "exports")) magicString.overwrite(node.start, node.end, `'object'`, { storeName: false });
3646
+ }
3647
+ return;
3648
+ case "VariableDeclaration":
3649
+ if (!scope.parent) topLevelDeclarations.push(node);
3650
+ return;
3651
+ case "TemplateElement": if (node.value.raw.includes("\n")) indentExclusionRanges.push([node.start, node.end]);
3652
+ }
3653
+ },
3654
+ leave(node) {
3655
+ programDepth -= 1;
3656
+ if (node.scope) scope = scope.parent;
3657
+ if (functionType.test(node.type)) lexicalDepth -= 1;
3658
+ if (node.type === "ClassBody") classBodyDepth -= 1;
3659
+ }
3660
+ });
3661
+ const nameBase = getName(id);
3662
+ const exportsName = deconflict([...exportsAccessScopes], globals, nameBase);
3663
+ const moduleName = deconflict([...moduleAccessScopes], globals, `${nameBase}Module`);
3664
+ const requireName = deconflict([scope], globals, `require${capitalize(nameBase)}`);
3665
+ const isRequiredName = deconflict([scope], globals, `hasRequired${capitalize(nameBase)}`);
3666
+ const helpersName = deconflict([scope], globals, "commonjsHelpers");
3667
+ const dynamicRequireName = replacedDynamicRequires.length > 0 && deconflict([scope], globals, isDynamicRequireModulesEnabled ? CREATE_COMMONJS_REQUIRE_EXPORT : COMMONJS_REQUIRE_EXPORT);
3668
+ const deconflictedExportNames = Object.create(null);
3669
+ for (const [exportName, { scopes }] of exportsAssignmentsByName) deconflictedExportNames[exportName] = deconflict([...scopes], globals, exportName);
3670
+ for (const node of replacedGlobal) magicString.overwrite(node.start, node.end, `${helpersName}.commonjsGlobal`, { storeName: true });
3671
+ for (const node of replacedThis) magicString.overwrite(node.start, node.end, exportsName, { storeName: true });
3672
+ for (const node of replacedDynamicRequires) magicString.overwrite(node.start, node.end, isDynamicRequireModulesEnabled ? `${dynamicRequireName}(${JSON.stringify(virtualDynamicRequirePath)})` : dynamicRequireName, {
3673
+ contentOnly: true,
3674
+ storeName: true
3675
+ });
3676
+ shouldWrap = !isEsModule && (shouldWrap || uses.exports && moduleExportsAssignments.length > 0);
3677
+ if (!(shouldWrap || isRequired || needsRequireWrapper || uses.module || uses.exports || uses.require || topLevelDefineCompiledEsmExpressions.length > 0) && (ignoreGlobal || !uses.global)) return { meta: { commonjs: { isCommonJS: false } } };
3678
+ let leadingComment = "";
3679
+ if (code.startsWith("/*")) {
3680
+ const commentEnd = code.indexOf("*/", 2) + 2;
3681
+ leadingComment = `${code.slice(0, commentEnd)}\n`;
3682
+ magicString.remove(0, commentEnd).trim();
3683
+ }
3684
+ let shebang = "";
3685
+ if (code.startsWith("#!")) {
3686
+ const shebangEndPosition = code.indexOf("\n") + 1;
3687
+ shebang = code.slice(0, shebangEndPosition);
3688
+ magicString.remove(0, shebangEndPosition).trim();
3689
+ }
3690
+ const exportMode = isEsModule ? "none" : shouldWrap ? uses.module ? "module" : "exports" : firstTopLevelModuleExportsAssignment ? exportsAssignmentsByName.size === 0 && topLevelDefineCompiledEsmExpressions.length === 0 ? "replace" : "module" : moduleExportsAssignments.length === 0 ? "exports" : "module";
3691
+ const exportedExportsName = exportMode === "module" ? deconflict([], globals, `${nameBase}Exports`) : exportsName;
3692
+ const importBlock = await rewriteRequireExpressionsAndGetImportBlock(magicString, topLevelDeclarations, reassignedNames, helpersName, dynamicRequireName, moduleName, exportsName, id, exportMode, resolveRequireSourcesAndUpdateMeta, needsRequireWrapper, isEsModule, isDynamicRequireModulesEnabled, getIgnoreTryCatchRequireStatementMode, commonjsMeta);
3693
+ const usesRequireWrapper = commonjsMeta.isCommonJS === IS_WRAPPED_COMMONJS;
3694
+ const exportBlock = isEsModule ? "" : rewriteExportsAndGetExportsBlock(magicString, moduleName, exportsName, exportedExportsName, shouldWrap, moduleExportsAssignments, firstTopLevelModuleExportsAssignment, exportsAssignmentsByName, topLevelAssignments, topLevelDefineCompiledEsmExpressions, deconflictedExportNames, code, helpersName, exportMode, defaultIsModuleExports, usesRequireWrapper, requireName);
3695
+ if (shouldWrap) wrapCode(magicString, uses, moduleName, exportsName, indentExclusionRanges);
3696
+ if (usesRequireWrapper) {
3697
+ magicString.trim().indent(" ", { exclude: indentExclusionRanges });
3698
+ const exported = exportMode === "module" ? `${moduleName}.exports` : exportsName;
3699
+ magicString.prepend(`var ${isRequiredName};
3700
+
3701
+ function ${requireName} () {
3702
+ \tif (${isRequiredName}) return ${exported};
3703
+ \t${isRequiredName} = 1;
3704
+ `).append(`
3705
+ \treturn ${exported};
3706
+ }`);
3707
+ if (exportMode === "replace") magicString.prepend(`var ${exportsName};\n`);
3708
+ }
3709
+ magicString.trim().prepend(shebang + leadingComment + importBlock).append(exportBlock);
3710
+ return {
3711
+ code: magicString.toString(),
3712
+ map: sourceMap ? magicString.generateMap() : null,
3713
+ syntheticNamedExports: isEsModule || usesRequireWrapper ? false : "__moduleExports",
3714
+ meta: { commonjs: {
3715
+ ...commonjsMeta,
3716
+ shebang
3717
+ } }
3718
+ };
3719
+ }
3720
+ const PLUGIN_NAME = "commonjs";
3721
+ function commonjs(options = {}) {
3722
+ const { ignoreGlobal, ignoreDynamicRequires, requireReturnsDefault: requireReturnsDefaultOption, defaultIsModuleExports: defaultIsModuleExportsOption, esmExternals, requireNodeBuiltins = false } = options;
3723
+ const extensions = options.extensions || [".js"];
3724
+ const filter = createFilter(options.include, options.exclude);
3725
+ const isPossibleCjsId = (id) => {
3726
+ const extName = extname(id);
3727
+ return extName === ".cjs" || extensions.includes(extName) && filter(id);
3728
+ };
3729
+ const { strictRequiresFilter, detectCyclesAndConditional } = getStrictRequiresFilter(options);
3730
+ const getRequireReturnsDefault = typeof requireReturnsDefaultOption === "function" ? requireReturnsDefaultOption : () => requireReturnsDefaultOption;
3731
+ let esmExternalIds;
3732
+ const isEsmExternal = typeof esmExternals === "function" ? esmExternals : Array.isArray(esmExternals) ? (esmExternalIds = new Set(esmExternals), (id) => esmExternalIds.has(id)) : () => esmExternals;
3733
+ const getDefaultIsModuleExports = typeof defaultIsModuleExportsOption === "function" ? defaultIsModuleExportsOption : () => typeof defaultIsModuleExportsOption === "boolean" ? defaultIsModuleExportsOption : "auto";
3734
+ const dynamicRequireRoot = typeof options.dynamicRequireRoot === "string" ? resolve(options.dynamicRequireRoot) : process.cwd();
3735
+ const { commonDir, dynamicRequireModules } = getDynamicRequireModules(options.dynamicRequireTargets, dynamicRequireRoot);
3736
+ const isDynamicRequireModulesEnabled = dynamicRequireModules.size > 0;
3737
+ const ignoreRequire = typeof options.ignore === "function" ? options.ignore : Array.isArray(options.ignore) ? (id) => options.ignore.includes(id) : () => false;
3738
+ const getIgnoreTryCatchRequireStatementMode = (id) => {
3739
+ const mode = typeof options.ignoreTryCatch === "function" ? options.ignoreTryCatch(id) : Array.isArray(options.ignoreTryCatch) ? options.ignoreTryCatch.includes(id) : typeof options.ignoreTryCatch !== "undefined" ? options.ignoreTryCatch : true;
3740
+ return {
3741
+ canConvertRequire: mode !== "remove" && mode !== true,
3742
+ shouldRemoveRequire: mode === "remove"
3743
+ };
3744
+ };
3745
+ const { currentlyResolving, resolveId } = getResolveId(extensions, isPossibleCjsId);
3746
+ const sourceMap = options.sourceMap !== false;
3747
+ let requireResolver;
3748
+ function transformAndCheckExports(code, id) {
3749
+ const normalizedId = normalizePathSlashes(id);
3750
+ const { isEsModule, hasDefaultExport, hasNamedExports, ast } = analyzeTopLevelStatements(this.parse, code, id);
3751
+ const commonjsMeta = this.getModuleInfo(id).meta.commonjs || {};
3752
+ if (hasDefaultExport) commonjsMeta.hasDefaultExport = true;
3753
+ if (hasNamedExports) commonjsMeta.hasNamedExports = true;
3754
+ if (!dynamicRequireModules.has(normalizedId) && (!(hasCjsKeywords(code, ignoreGlobal) || requireResolver.isRequiredId(id)) || isEsModule && !options.transformMixedEsModules)) {
3755
+ commonjsMeta.isCommonJS = false;
3756
+ return { meta: { commonjs: commonjsMeta } };
3757
+ }
3758
+ const needsRequireWrapper = !isEsModule && (dynamicRequireModules.has(normalizedId) || strictRequiresFilter(id));
3759
+ const checkDynamicRequire = (position) => {
3760
+ const normalizedDynamicRequireRoot = normalizePathSlashes(dynamicRequireRoot);
3761
+ if (normalizedId.indexOf(normalizedDynamicRequireRoot) !== 0) this.error({
3762
+ code: "DYNAMIC_REQUIRE_OUTSIDE_ROOT",
3763
+ normalizedId,
3764
+ normalizedDynamicRequireRoot,
3765
+ message: `"${normalizedId}" contains dynamic require statements but it is not within the current dynamicRequireRoot "${normalizedDynamicRequireRoot}". You should set dynamicRequireRoot to "${dirname(normalizedId)}" or one of its parent directories.`
3766
+ }, position);
3767
+ };
3768
+ return transformCommonjs(this.parse, code, id, isEsModule, ignoreGlobal || isEsModule, ignoreRequire, ignoreDynamicRequires && !isDynamicRequireModulesEnabled, getIgnoreTryCatchRequireStatementMode, sourceMap, isDynamicRequireModulesEnabled, dynamicRequireModules, commonDir, ast, getDefaultIsModuleExports(id), needsRequireWrapper, requireResolver.resolveRequireSourcesAndUpdateMeta(this), requireResolver.isRequiredId(id), checkDynamicRequire, commonjsMeta);
3769
+ }
3770
+ return {
3771
+ name: PLUGIN_NAME,
3772
+ version,
3773
+ options(rawOptions) {
3774
+ const plugins = Array.isArray(rawOptions.plugins) ? [...rawOptions.plugins] : rawOptions.plugins ? [rawOptions.plugins] : [];
3775
+ plugins.unshift({
3776
+ name: "commonjs--resolver",
3777
+ resolveId
3778
+ });
3779
+ return {
3780
+ ...rawOptions,
3781
+ plugins
3782
+ };
3783
+ },
3784
+ buildStart({ plugins }) {
3785
+ validateVersion(this.meta.rollupVersion, peerDependencies.rollup, "rollup");
3786
+ const nodeResolve = plugins.find(({ name }) => name === "node-resolve");
3787
+ if (nodeResolve) validateVersion(nodeResolve.version, "^13.0.6", "@rollup/plugin-node-resolve");
3788
+ if (options.namedExports != null) this.warn("The namedExports option from \"@rollup/plugin-commonjs\" is deprecated. Named exports are now handled automatically.");
3789
+ requireResolver = getRequireResolver(extensions, detectCyclesAndConditional, currentlyResolving, requireNodeBuiltins);
3790
+ },
3791
+ buildEnd() {
3792
+ if (options.strictRequires === "debug") {
3793
+ const wrappedIds = requireResolver.getWrappedIds();
3794
+ if (wrappedIds.length) this.warn({
3795
+ code: "WRAPPED_IDS",
3796
+ ids: wrappedIds,
3797
+ message: `The commonjs plugin automatically wrapped the following files:\n[\n${wrappedIds.map((id) => `\t${JSON.stringify(relative(process.cwd(), id))}`).join(",\n")}\n]`
3798
+ });
3799
+ else this.warn({
3800
+ code: "WRAPPED_IDS",
3801
+ ids: wrappedIds,
3802
+ message: "The commonjs plugin did not wrap any files."
3803
+ });
3804
+ }
3805
+ },
3806
+ async load(id) {
3807
+ if (id === HELPERS_ID) return getHelpersModule();
3808
+ if (isWrappedId(id, MODULE_SUFFIX)) {
3809
+ const name = getName(unwrapId(id, MODULE_SUFFIX));
3810
+ return {
3811
+ code: `var ${name} = {exports: {}}; export {${name} as __module}`,
3812
+ meta: { commonjs: { isCommonJS: false } }
3813
+ };
3814
+ }
3815
+ if (isWrappedId(id, EXPORTS_SUFFIX)) {
3816
+ const name = getName(unwrapId(id, EXPORTS_SUFFIX));
3817
+ return {
3818
+ code: `var ${name} = {}; export {${name} as __exports}`,
3819
+ meta: { commonjs: { isCommonJS: false } }
3820
+ };
3821
+ }
3822
+ if (isWrappedId(id, EXTERNAL_SUFFIX)) {
3823
+ const actualId = unwrapId(id, EXTERNAL_SUFFIX);
3824
+ if (requireNodeBuiltins === true && actualId.startsWith("node:")) return getExternalBuiltinRequireProxy(actualId);
3825
+ return getUnknownRequireProxy(actualId, isEsmExternal(actualId) ? getRequireReturnsDefault(actualId) : true);
3826
+ }
3827
+ if (id.endsWith(ENTRY_SUFFIX)) {
3828
+ const acutalId = id.slice(0, -15);
3829
+ const { meta: { commonjs: commonjsMeta } } = this.getModuleInfo(acutalId);
3830
+ const shebang = commonjsMeta?.shebang ?? "";
3831
+ return getEntryProxy(acutalId, getDefaultIsModuleExports(acutalId), this.getModuleInfo, shebang);
3832
+ }
3833
+ if (isWrappedId(id, ES_IMPORT_SUFFIX)) {
3834
+ const actualId = unwrapId(id, ES_IMPORT_SUFFIX);
3835
+ return getEsImportProxy(actualId, getDefaultIsModuleExports(actualId), (await this.load({ id: actualId })).moduleSideEffects);
3836
+ }
3837
+ if (id === DYNAMIC_MODULES_ID) return getDynamicModuleRegistry(isDynamicRequireModulesEnabled, dynamicRequireModules, commonDir, ignoreDynamicRequires);
3838
+ if (isWrappedId(id, PROXY_SUFFIX)) {
3839
+ const actualId = unwrapId(id, PROXY_SUFFIX);
3840
+ return getStaticRequireProxy(actualId, getRequireReturnsDefault(actualId), this.load);
3841
+ }
3842
+ return null;
3843
+ },
3844
+ shouldTransformCachedModule(...args) {
3845
+ return requireResolver.shouldTransformCachedModule.call(this, ...args);
3846
+ },
3847
+ transform(code, id) {
3848
+ if (!isPossibleCjsId(id)) return null;
3849
+ try {
3850
+ return transformAndCheckExports.call(this, code, id);
3851
+ } catch (err) {
3852
+ return this.error(err, err.pos);
3853
+ }
3854
+ }
3855
+ };
3856
+ }
3857
+
3858
+ //#endregion
3859
+ export { makeLegalIdentifier as a, require_picomatch as c, dataToEsm as i, attachScopes as n, walk as o, createFilter as r, Builder as s, commonjs as t };