rsbuild-plugin-dts 0.20.0 → 0.20.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/350.js ADDED
@@ -0,0 +1,3592 @@
1
+ import node_fs from "node:fs";
2
+ import promises from "node:fs/promises";
3
+ import { createRequire } from "node:module";
4
+ import { platform } from "node:os";
5
+ import node_path, { basename, dirname, extname, isAbsolute, join, normalize, relative as external_node_path_relative, resolve } from "node:path";
6
+ import { styleText } from "node:util";
7
+ import { logger } from "@rsbuild/core";
8
+ import fs_0, * as __rspack_external_fs from "fs";
9
+ import path_0, { basename as external_path_basename, dirname as external_path_dirname, normalize as external_path_normalize, posix, relative as external_path_relative, resolve as external_path_resolve, sep as external_path_sep } from "path";
10
+ import { fileURLToPath } from "url";
11
+ import { createRequire as external_module_createRequire } from "module";
12
+ import { __webpack_require__ } from "./rslib-runtime.js";
13
+ import { createRequire as __rspack_createRequire } from "node:module";
14
+ const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
15
+ __webpack_require__.add({
16
+ "../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js" (module, __unused_rspack_exports, __webpack_require__) {
17
+ const pico = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js");
18
+ const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js");
19
+ function picomatch(glob, options, returnState = false) {
20
+ if (options && (null === options.windows || void 0 === options.windows)) options = {
21
+ ...options,
22
+ windows: utils.isWindows()
23
+ };
24
+ return pico(glob, options, returnState);
25
+ }
26
+ Object.assign(picomatch, pico);
27
+ module.exports = picomatch;
28
+ },
29
+ "../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js" (module) {
30
+ const WIN_SLASH = '\\\\/';
31
+ const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
32
+ const DOT_LITERAL = '\\.';
33
+ const PLUS_LITERAL = '\\+';
34
+ const QMARK_LITERAL = '\\?';
35
+ const SLASH_LITERAL = '\\/';
36
+ const ONE_CHAR = '(?=.)';
37
+ const QMARK = '[^/]';
38
+ const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
39
+ const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
40
+ const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
41
+ const NO_DOT = `(?!${DOT_LITERAL})`;
42
+ const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
43
+ const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
44
+ const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
45
+ const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
46
+ const STAR = `${QMARK}*?`;
47
+ const SEP = '/';
48
+ const POSIX_CHARS = {
49
+ DOT_LITERAL,
50
+ PLUS_LITERAL,
51
+ QMARK_LITERAL,
52
+ SLASH_LITERAL,
53
+ ONE_CHAR,
54
+ QMARK,
55
+ END_ANCHOR,
56
+ DOTS_SLASH,
57
+ NO_DOT,
58
+ NO_DOTS,
59
+ NO_DOT_SLASH,
60
+ NO_DOTS_SLASH,
61
+ QMARK_NO_DOT,
62
+ STAR,
63
+ START_ANCHOR,
64
+ SEP
65
+ };
66
+ const WINDOWS_CHARS = {
67
+ ...POSIX_CHARS,
68
+ SLASH_LITERAL: `[${WIN_SLASH}]`,
69
+ QMARK: WIN_NO_SLASH,
70
+ STAR: `${WIN_NO_SLASH}*?`,
71
+ DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
72
+ NO_DOT: `(?!${DOT_LITERAL})`,
73
+ NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
74
+ NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
75
+ NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
76
+ QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
77
+ START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
78
+ END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
79
+ SEP: '\\'
80
+ };
81
+ const POSIX_REGEX_SOURCE = {
82
+ alnum: 'a-zA-Z0-9',
83
+ alpha: 'a-zA-Z',
84
+ ascii: '\\x00-\\x7F',
85
+ blank: ' \\t',
86
+ cntrl: '\\x00-\\x1F\\x7F',
87
+ digit: '0-9',
88
+ graph: '\\x21-\\x7E',
89
+ lower: 'a-z',
90
+ print: '\\x20-\\x7E ',
91
+ punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
92
+ space: ' \\t\\r\\n\\v\\f',
93
+ upper: 'A-Z',
94
+ word: 'A-Za-z0-9_',
95
+ xdigit: 'A-Fa-f0-9'
96
+ };
97
+ module.exports = {
98
+ MAX_LENGTH: 65536,
99
+ POSIX_REGEX_SOURCE,
100
+ REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
101
+ REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
102
+ REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
103
+ REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
104
+ REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
105
+ REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
106
+ REPLACEMENTS: {
107
+ __proto__: null,
108
+ '***': '*',
109
+ '**/**': '**',
110
+ '**/**/**': '**'
111
+ },
112
+ CHAR_0: 48,
113
+ CHAR_9: 57,
114
+ CHAR_UPPERCASE_A: 65,
115
+ CHAR_LOWERCASE_A: 97,
116
+ CHAR_UPPERCASE_Z: 90,
117
+ CHAR_LOWERCASE_Z: 122,
118
+ CHAR_LEFT_PARENTHESES: 40,
119
+ CHAR_RIGHT_PARENTHESES: 41,
120
+ CHAR_ASTERISK: 42,
121
+ CHAR_AMPERSAND: 38,
122
+ CHAR_AT: 64,
123
+ CHAR_BACKWARD_SLASH: 92,
124
+ CHAR_CARRIAGE_RETURN: 13,
125
+ CHAR_CIRCUMFLEX_ACCENT: 94,
126
+ CHAR_COLON: 58,
127
+ CHAR_COMMA: 44,
128
+ CHAR_DOT: 46,
129
+ CHAR_DOUBLE_QUOTE: 34,
130
+ CHAR_EQUAL: 61,
131
+ CHAR_EXCLAMATION_MARK: 33,
132
+ CHAR_FORM_FEED: 12,
133
+ CHAR_FORWARD_SLASH: 47,
134
+ CHAR_GRAVE_ACCENT: 96,
135
+ CHAR_HASH: 35,
136
+ CHAR_HYPHEN_MINUS: 45,
137
+ CHAR_LEFT_ANGLE_BRACKET: 60,
138
+ CHAR_LEFT_CURLY_BRACE: 123,
139
+ CHAR_LEFT_SQUARE_BRACKET: 91,
140
+ CHAR_LINE_FEED: 10,
141
+ CHAR_NO_BREAK_SPACE: 160,
142
+ CHAR_PERCENT: 37,
143
+ CHAR_PLUS: 43,
144
+ CHAR_QUESTION_MARK: 63,
145
+ CHAR_RIGHT_ANGLE_BRACKET: 62,
146
+ CHAR_RIGHT_CURLY_BRACE: 125,
147
+ CHAR_RIGHT_SQUARE_BRACKET: 93,
148
+ CHAR_SEMICOLON: 59,
149
+ CHAR_SINGLE_QUOTE: 39,
150
+ CHAR_SPACE: 32,
151
+ CHAR_TAB: 9,
152
+ CHAR_UNDERSCORE: 95,
153
+ CHAR_VERTICAL_LINE: 124,
154
+ CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
155
+ extglobChars (chars) {
156
+ return {
157
+ '!': {
158
+ type: 'negate',
159
+ open: '(?:(?!(?:',
160
+ close: `))${chars.STAR})`
161
+ },
162
+ '?': {
163
+ type: 'qmark',
164
+ open: '(?:',
165
+ close: ')?'
166
+ },
167
+ '+': {
168
+ type: 'plus',
169
+ open: '(?:',
170
+ close: ')+'
171
+ },
172
+ '*': {
173
+ type: 'star',
174
+ open: '(?:',
175
+ close: ')*'
176
+ },
177
+ '@': {
178
+ type: 'at',
179
+ open: '(?:',
180
+ close: ')'
181
+ }
182
+ };
183
+ },
184
+ globChars (win32) {
185
+ return true === win32 ? WINDOWS_CHARS : POSIX_CHARS;
186
+ }
187
+ };
188
+ },
189
+ "../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.js" (module, __unused_rspack_exports, __webpack_require__) {
190
+ const constants = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js");
191
+ const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js");
192
+ const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants;
193
+ const expandRange = (args, options)=>{
194
+ if ('function' == typeof options.expandRange) return options.expandRange(...args, options);
195
+ args.sort();
196
+ const value = `[${args.join('-')}]`;
197
+ try {
198
+ new RegExp(value);
199
+ } catch (ex) {
200
+ return args.map((v)=>utils.escapeRegex(v)).join('..');
201
+ }
202
+ return value;
203
+ };
204
+ const syntaxError = (type, char)=>`Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
205
+ const parse = (input, options)=>{
206
+ if ('string' != typeof input) throw new TypeError('Expected a string');
207
+ input = REPLACEMENTS[input] || input;
208
+ const opts = {
209
+ ...options
210
+ };
211
+ const max = 'number' == typeof opts.maxLength ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
212
+ let len = input.length;
213
+ if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
214
+ const bos = {
215
+ type: 'bos',
216
+ value: '',
217
+ output: opts.prepend || ''
218
+ };
219
+ const tokens = [
220
+ bos
221
+ ];
222
+ const capture = opts.capture ? '' : '?:';
223
+ const PLATFORM_CHARS = constants.globChars(opts.windows);
224
+ const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
225
+ const { DOT_LITERAL, PLUS_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOT_SLASH, NO_DOTS_SLASH, QMARK, QMARK_NO_DOT, STAR, START_ANCHOR } = PLATFORM_CHARS;
226
+ const globstar = (opts)=>`(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
227
+ const nodot = opts.dot ? '' : NO_DOT;
228
+ const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
229
+ let star = true === opts.bash ? globstar(opts) : STAR;
230
+ if (opts.capture) star = `(${star})`;
231
+ if ('boolean' == typeof opts.noext) opts.noextglob = opts.noext;
232
+ const state = {
233
+ input,
234
+ index: -1,
235
+ start: 0,
236
+ dot: true === opts.dot,
237
+ consumed: '',
238
+ output: '',
239
+ prefix: '',
240
+ backtrack: false,
241
+ negated: false,
242
+ brackets: 0,
243
+ braces: 0,
244
+ parens: 0,
245
+ quotes: 0,
246
+ globstar: false,
247
+ tokens
248
+ };
249
+ input = utils.removePrefix(input, state);
250
+ len = input.length;
251
+ const extglobs = [];
252
+ const braces = [];
253
+ const stack = [];
254
+ let prev = bos;
255
+ let value;
256
+ const eos = ()=>state.index === len - 1;
257
+ const peek = state.peek = (n = 1)=>input[state.index + n];
258
+ const advance = state.advance = ()=>input[++state.index] || '';
259
+ const remaining = ()=>input.slice(state.index + 1);
260
+ const consume = (value = '', num = 0)=>{
261
+ state.consumed += value;
262
+ state.index += num;
263
+ };
264
+ const append = (token)=>{
265
+ state.output += null != token.output ? token.output : token.value;
266
+ consume(token.value);
267
+ };
268
+ const negate = ()=>{
269
+ let count = 1;
270
+ while('!' === peek() && ('(' !== peek(2) || '?' === peek(3))){
271
+ advance();
272
+ state.start++;
273
+ count++;
274
+ }
275
+ if (count % 2 === 0) return false;
276
+ state.negated = true;
277
+ state.start++;
278
+ return true;
279
+ };
280
+ const increment = (type)=>{
281
+ state[type]++;
282
+ stack.push(type);
283
+ };
284
+ const decrement = (type)=>{
285
+ state[type]--;
286
+ stack.pop();
287
+ };
288
+ const push = (tok)=>{
289
+ if ('globstar' === prev.type) {
290
+ const isBrace = state.braces > 0 && ('comma' === tok.type || 'brace' === tok.type);
291
+ const isExtglob = true === tok.extglob || extglobs.length && ('pipe' === tok.type || 'paren' === tok.type);
292
+ if ('slash' !== tok.type && 'paren' !== tok.type && !isBrace && !isExtglob) {
293
+ state.output = state.output.slice(0, -prev.output.length);
294
+ prev.type = 'star';
295
+ prev.value = '*';
296
+ prev.output = star;
297
+ state.output += prev.output;
298
+ }
299
+ }
300
+ if (extglobs.length && 'paren' !== tok.type) extglobs[extglobs.length - 1].inner += tok.value;
301
+ if (tok.value || tok.output) append(tok);
302
+ if (prev && 'text' === prev.type && 'text' === tok.type) {
303
+ prev.output = (prev.output || prev.value) + tok.value;
304
+ prev.value += tok.value;
305
+ return;
306
+ }
307
+ tok.prev = prev;
308
+ tokens.push(tok);
309
+ prev = tok;
310
+ };
311
+ const extglobOpen = (type, value)=>{
312
+ const token = {
313
+ ...EXTGLOB_CHARS[value],
314
+ conditions: 1,
315
+ inner: ''
316
+ };
317
+ token.prev = prev;
318
+ token.parens = state.parens;
319
+ token.output = state.output;
320
+ const output = (opts.capture ? '(' : '') + token.open;
321
+ increment('parens');
322
+ push({
323
+ type,
324
+ value,
325
+ output: state.output ? '' : ONE_CHAR
326
+ });
327
+ push({
328
+ type: 'paren',
329
+ extglob: true,
330
+ value: advance(),
331
+ output
332
+ });
333
+ extglobs.push(token);
334
+ };
335
+ const extglobClose = (token)=>{
336
+ let output = token.close + (opts.capture ? ')' : '');
337
+ let rest;
338
+ if ('negate' === token.type) {
339
+ let extglobStar = star;
340
+ if (token.inner && token.inner.length > 1 && token.inner.includes('/')) extglobStar = globstar(opts);
341
+ if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) output = token.close = `)$))${extglobStar}`;
342
+ if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
343
+ const expression = parse(rest, {
344
+ ...options,
345
+ fastpaths: false
346
+ }).output;
347
+ output = token.close = `)${expression})${extglobStar})`;
348
+ }
349
+ if ('bos' === token.prev.type) state.negatedExtglob = true;
350
+ }
351
+ push({
352
+ type: 'paren',
353
+ extglob: true,
354
+ value,
355
+ output
356
+ });
357
+ decrement('parens');
358
+ };
359
+ if (false !== opts.fastpaths && !/(^[*!]|[/()[\]{}"])/.test(input)) {
360
+ let backslashes = false;
361
+ let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index)=>{
362
+ if ('\\' === first) {
363
+ backslashes = true;
364
+ return m;
365
+ }
366
+ if ('?' === first) {
367
+ if (esc) return esc + first + (rest ? QMARK.repeat(rest.length) : '');
368
+ if (0 === index) return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
369
+ return QMARK.repeat(chars.length);
370
+ }
371
+ if ('.' === first) return DOT_LITERAL.repeat(chars.length);
372
+ if ('*' === first) {
373
+ if (esc) return esc + first + (rest ? star : '');
374
+ return star;
375
+ }
376
+ return esc ? m : `\\${m}`;
377
+ });
378
+ if (true === backslashes) output = true === opts.unescape ? output.replace(/\\/g, '') : output.replace(/\\+/g, (m)=>m.length % 2 === 0 ? '\\\\' : m ? '\\' : '');
379
+ if (output === input && true === opts.contains) {
380
+ state.output = input;
381
+ return state;
382
+ }
383
+ state.output = utils.wrapOutput(output, state, options);
384
+ return state;
385
+ }
386
+ while(!eos()){
387
+ value = advance();
388
+ if ('\u0000' === value) continue;
389
+ if ('\\' === value) {
390
+ const next = peek();
391
+ if ('/' === next && true !== opts.bash) continue;
392
+ if ('.' === next || ';' === next) continue;
393
+ if (!next) {
394
+ value += '\\';
395
+ push({
396
+ type: 'text',
397
+ value
398
+ });
399
+ continue;
400
+ }
401
+ const match = /^\\+/.exec(remaining());
402
+ let slashes = 0;
403
+ if (match && match[0].length > 2) {
404
+ slashes = match[0].length;
405
+ state.index += slashes;
406
+ if (slashes % 2 !== 0) value += '\\';
407
+ }
408
+ if (true === opts.unescape) value = advance();
409
+ else value += advance();
410
+ if (0 === state.brackets) {
411
+ push({
412
+ type: 'text',
413
+ value
414
+ });
415
+ continue;
416
+ }
417
+ }
418
+ if (state.brackets > 0 && (']' !== value || '[' === prev.value || '[^' === prev.value)) {
419
+ if (false !== opts.posix && ':' === value) {
420
+ const inner = prev.value.slice(1);
421
+ if (inner.includes('[')) {
422
+ prev.posix = true;
423
+ if (inner.includes(':')) {
424
+ const idx = prev.value.lastIndexOf('[');
425
+ const pre = prev.value.slice(0, idx);
426
+ const rest = prev.value.slice(idx + 2);
427
+ const posix = POSIX_REGEX_SOURCE[rest];
428
+ if (posix) {
429
+ prev.value = pre + posix;
430
+ state.backtrack = true;
431
+ advance();
432
+ if (!bos.output && 1 === tokens.indexOf(prev)) bos.output = ONE_CHAR;
433
+ continue;
434
+ }
435
+ }
436
+ }
437
+ }
438
+ if ('[' === value && ':' !== peek() || '-' === value && ']' === peek()) value = `\\${value}`;
439
+ if (']' === value && ('[' === prev.value || '[^' === prev.value)) value = `\\${value}`;
440
+ if (true === opts.posix && '!' === value && '[' === prev.value) value = '^';
441
+ prev.value += value;
442
+ append({
443
+ value
444
+ });
445
+ continue;
446
+ }
447
+ if (1 === state.quotes && '"' !== value) {
448
+ value = utils.escapeRegex(value);
449
+ prev.value += value;
450
+ append({
451
+ value
452
+ });
453
+ continue;
454
+ }
455
+ if ('"' === value) {
456
+ state.quotes = 1 === state.quotes ? 0 : 1;
457
+ if (true === opts.keepQuotes) push({
458
+ type: 'text',
459
+ value
460
+ });
461
+ continue;
462
+ }
463
+ if ('(' === value) {
464
+ increment('parens');
465
+ push({
466
+ type: 'paren',
467
+ value
468
+ });
469
+ continue;
470
+ }
471
+ if (')' === value) {
472
+ if (0 === state.parens && true === opts.strictBrackets) throw new SyntaxError(syntaxError('opening', '('));
473
+ const extglob = extglobs[extglobs.length - 1];
474
+ if (extglob && state.parens === extglob.parens + 1) {
475
+ extglobClose(extglobs.pop());
476
+ continue;
477
+ }
478
+ push({
479
+ type: 'paren',
480
+ value,
481
+ output: state.parens ? ')' : '\\)'
482
+ });
483
+ decrement('parens');
484
+ continue;
485
+ }
486
+ if ('[' === value) {
487
+ if (true !== opts.nobracket && remaining().includes(']')) increment('brackets');
488
+ else {
489
+ if (true !== opts.nobracket && true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', ']'));
490
+ value = `\\${value}`;
491
+ }
492
+ push({
493
+ type: 'bracket',
494
+ value
495
+ });
496
+ continue;
497
+ }
498
+ if (']' === value) {
499
+ if (true === opts.nobracket || prev && 'bracket' === prev.type && 1 === prev.value.length) {
500
+ push({
501
+ type: 'text',
502
+ value,
503
+ output: `\\${value}`
504
+ });
505
+ continue;
506
+ }
507
+ if (0 === state.brackets) {
508
+ if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('opening', '['));
509
+ push({
510
+ type: 'text',
511
+ value,
512
+ output: `\\${value}`
513
+ });
514
+ continue;
515
+ }
516
+ decrement('brackets');
517
+ const prevValue = prev.value.slice(1);
518
+ if (true !== prev.posix && '^' === prevValue[0] && !prevValue.includes('/')) value = `/${value}`;
519
+ prev.value += value;
520
+ append({
521
+ value
522
+ });
523
+ if (false === opts.literalBrackets || utils.hasRegexChars(prevValue)) continue;
524
+ const escaped = utils.escapeRegex(prev.value);
525
+ state.output = state.output.slice(0, -prev.value.length);
526
+ if (true === opts.literalBrackets) {
527
+ state.output += escaped;
528
+ prev.value = escaped;
529
+ continue;
530
+ }
531
+ prev.value = `(${capture}${escaped}|${prev.value})`;
532
+ state.output += prev.value;
533
+ continue;
534
+ }
535
+ if ('{' === value && true !== opts.nobrace) {
536
+ increment('braces');
537
+ const open = {
538
+ type: 'brace',
539
+ value,
540
+ output: '(',
541
+ outputIndex: state.output.length,
542
+ tokensIndex: state.tokens.length
543
+ };
544
+ braces.push(open);
545
+ push(open);
546
+ continue;
547
+ }
548
+ if ('}' === value) {
549
+ const brace = braces[braces.length - 1];
550
+ if (true === opts.nobrace || !brace) {
551
+ push({
552
+ type: 'text',
553
+ value,
554
+ output: value
555
+ });
556
+ continue;
557
+ }
558
+ let output = ')';
559
+ if (true === brace.dots) {
560
+ const arr = tokens.slice();
561
+ const range = [];
562
+ for(let i = arr.length - 1; i >= 0; i--){
563
+ tokens.pop();
564
+ if ('brace' === arr[i].type) break;
565
+ if ('dots' !== arr[i].type) range.unshift(arr[i].value);
566
+ }
567
+ output = expandRange(range, opts);
568
+ state.backtrack = true;
569
+ }
570
+ if (true !== brace.comma && true !== brace.dots) {
571
+ const out = state.output.slice(0, brace.outputIndex);
572
+ const toks = state.tokens.slice(brace.tokensIndex);
573
+ brace.value = brace.output = '\\{';
574
+ value = output = '\\}';
575
+ state.output = out;
576
+ for (const t of toks)state.output += t.output || t.value;
577
+ }
578
+ push({
579
+ type: 'brace',
580
+ value,
581
+ output
582
+ });
583
+ decrement('braces');
584
+ braces.pop();
585
+ continue;
586
+ }
587
+ if ('|' === value) {
588
+ if (extglobs.length > 0) extglobs[extglobs.length - 1].conditions++;
589
+ push({
590
+ type: 'text',
591
+ value
592
+ });
593
+ continue;
594
+ }
595
+ if (',' === value) {
596
+ let output = value;
597
+ const brace = braces[braces.length - 1];
598
+ if (brace && 'braces' === stack[stack.length - 1]) {
599
+ brace.comma = true;
600
+ output = '|';
601
+ }
602
+ push({
603
+ type: 'comma',
604
+ value,
605
+ output
606
+ });
607
+ continue;
608
+ }
609
+ if ('/' === value) {
610
+ if ('dot' === prev.type && state.index === state.start + 1) {
611
+ state.start = state.index + 1;
612
+ state.consumed = '';
613
+ state.output = '';
614
+ tokens.pop();
615
+ prev = bos;
616
+ continue;
617
+ }
618
+ push({
619
+ type: 'slash',
620
+ value,
621
+ output: SLASH_LITERAL
622
+ });
623
+ continue;
624
+ }
625
+ if ('.' === value) {
626
+ if (state.braces > 0 && 'dot' === prev.type) {
627
+ if ('.' === prev.value) prev.output = DOT_LITERAL;
628
+ const brace = braces[braces.length - 1];
629
+ prev.type = 'dots';
630
+ prev.output += value;
631
+ prev.value += value;
632
+ brace.dots = true;
633
+ continue;
634
+ }
635
+ if (state.braces + state.parens === 0 && 'bos' !== prev.type && 'slash' !== prev.type) {
636
+ push({
637
+ type: 'text',
638
+ value,
639
+ output: DOT_LITERAL
640
+ });
641
+ continue;
642
+ }
643
+ push({
644
+ type: 'dot',
645
+ value,
646
+ output: DOT_LITERAL
647
+ });
648
+ continue;
649
+ }
650
+ if ('?' === value) {
651
+ const isGroup = prev && '(' === prev.value;
652
+ if (!isGroup && true !== opts.noextglob && '(' === peek() && '?' !== peek(2)) {
653
+ extglobOpen('qmark', value);
654
+ continue;
655
+ }
656
+ if (prev && 'paren' === prev.type) {
657
+ const next = peek();
658
+ let output = value;
659
+ if ('(' === prev.value && !/[!=<:]/.test(next) || '<' === next && !/<([!=]|\w+>)/.test(remaining())) output = `\\${value}`;
660
+ push({
661
+ type: 'text',
662
+ value,
663
+ output
664
+ });
665
+ continue;
666
+ }
667
+ if (true !== opts.dot && ('slash' === prev.type || 'bos' === prev.type)) {
668
+ push({
669
+ type: 'qmark',
670
+ value,
671
+ output: QMARK_NO_DOT
672
+ });
673
+ continue;
674
+ }
675
+ push({
676
+ type: 'qmark',
677
+ value,
678
+ output: QMARK
679
+ });
680
+ continue;
681
+ }
682
+ if ('!' === value) {
683
+ if (true !== opts.noextglob && '(' === peek()) {
684
+ if ('?' !== peek(2) || !/[!=<:]/.test(peek(3))) {
685
+ extglobOpen('negate', value);
686
+ continue;
687
+ }
688
+ }
689
+ if (true !== opts.nonegate && 0 === state.index) {
690
+ negate();
691
+ continue;
692
+ }
693
+ }
694
+ if ('+' === value) {
695
+ if (true !== opts.noextglob && '(' === peek() && '?' !== peek(2)) {
696
+ extglobOpen('plus', value);
697
+ continue;
698
+ }
699
+ if (prev && '(' === prev.value || false === opts.regex) {
700
+ push({
701
+ type: 'plus',
702
+ value,
703
+ output: PLUS_LITERAL
704
+ });
705
+ continue;
706
+ }
707
+ if (prev && ('bracket' === prev.type || 'paren' === prev.type || 'brace' === prev.type) || state.parens > 0) {
708
+ push({
709
+ type: 'plus',
710
+ value
711
+ });
712
+ continue;
713
+ }
714
+ push({
715
+ type: 'plus',
716
+ value: PLUS_LITERAL
717
+ });
718
+ continue;
719
+ }
720
+ if ('@' === value) {
721
+ if (true !== opts.noextglob && '(' === peek() && '?' !== peek(2)) {
722
+ push({
723
+ type: 'at',
724
+ extglob: true,
725
+ value,
726
+ output: ''
727
+ });
728
+ continue;
729
+ }
730
+ push({
731
+ type: 'text',
732
+ value
733
+ });
734
+ continue;
735
+ }
736
+ if ('*' !== value) {
737
+ if ('$' === value || '^' === value) value = `\\${value}`;
738
+ const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
739
+ if (match) {
740
+ value += match[0];
741
+ state.index += match[0].length;
742
+ }
743
+ push({
744
+ type: 'text',
745
+ value
746
+ });
747
+ continue;
748
+ }
749
+ if (prev && ('globstar' === prev.type || true === prev.star)) {
750
+ prev.type = 'star';
751
+ prev.star = true;
752
+ prev.value += value;
753
+ prev.output = star;
754
+ state.backtrack = true;
755
+ state.globstar = true;
756
+ consume(value);
757
+ continue;
758
+ }
759
+ let rest = remaining();
760
+ if (true !== opts.noextglob && /^\([^?]/.test(rest)) {
761
+ extglobOpen('star', value);
762
+ continue;
763
+ }
764
+ if ('star' === prev.type) {
765
+ if (true === opts.noglobstar) {
766
+ consume(value);
767
+ continue;
768
+ }
769
+ const prior = prev.prev;
770
+ const before = prior.prev;
771
+ const isStart = 'slash' === prior.type || 'bos' === prior.type;
772
+ const afterStar = before && ('star' === before.type || 'globstar' === before.type);
773
+ if (true === opts.bash && (!isStart || rest[0] && '/' !== rest[0])) {
774
+ push({
775
+ type: 'star',
776
+ value,
777
+ output: ''
778
+ });
779
+ continue;
780
+ }
781
+ const isBrace = state.braces > 0 && ('comma' === prior.type || 'brace' === prior.type);
782
+ const isExtglob = extglobs.length && ('pipe' === prior.type || 'paren' === prior.type);
783
+ if (!isStart && 'paren' !== prior.type && !isBrace && !isExtglob) {
784
+ push({
785
+ type: 'star',
786
+ value,
787
+ output: ''
788
+ });
789
+ continue;
790
+ }
791
+ while('/**' === rest.slice(0, 3)){
792
+ const after = input[state.index + 4];
793
+ if (after && '/' !== after) break;
794
+ rest = rest.slice(3);
795
+ consume('/**', 3);
796
+ }
797
+ if ('bos' === prior.type && eos()) {
798
+ prev.type = 'globstar';
799
+ prev.value += value;
800
+ prev.output = globstar(opts);
801
+ state.output = prev.output;
802
+ state.globstar = true;
803
+ consume(value);
804
+ continue;
805
+ }
806
+ if ('slash' === prior.type && 'bos' !== prior.prev.type && !afterStar && eos()) {
807
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
808
+ prior.output = `(?:${prior.output}`;
809
+ prev.type = 'globstar';
810
+ prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
811
+ prev.value += value;
812
+ state.globstar = true;
813
+ state.output += prior.output + prev.output;
814
+ consume(value);
815
+ continue;
816
+ }
817
+ if ('slash' === prior.type && 'bos' !== prior.prev.type && '/' === rest[0]) {
818
+ const end = void 0 !== rest[1] ? '|$' : '';
819
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
820
+ prior.output = `(?:${prior.output}`;
821
+ prev.type = 'globstar';
822
+ prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
823
+ prev.value += value;
824
+ state.output += prior.output + prev.output;
825
+ state.globstar = true;
826
+ consume(value + advance());
827
+ push({
828
+ type: 'slash',
829
+ value: '/',
830
+ output: ''
831
+ });
832
+ continue;
833
+ }
834
+ if ('bos' === prior.type && '/' === rest[0]) {
835
+ prev.type = 'globstar';
836
+ prev.value += value;
837
+ prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
838
+ state.output = prev.output;
839
+ state.globstar = true;
840
+ consume(value + advance());
841
+ push({
842
+ type: 'slash',
843
+ value: '/',
844
+ output: ''
845
+ });
846
+ continue;
847
+ }
848
+ state.output = state.output.slice(0, -prev.output.length);
849
+ prev.type = 'globstar';
850
+ prev.output = globstar(opts);
851
+ prev.value += value;
852
+ state.output += prev.output;
853
+ state.globstar = true;
854
+ consume(value);
855
+ continue;
856
+ }
857
+ const token = {
858
+ type: 'star',
859
+ value,
860
+ output: star
861
+ };
862
+ if (true === opts.bash) {
863
+ token.output = '.*?';
864
+ if ('bos' === prev.type || 'slash' === prev.type) token.output = nodot + token.output;
865
+ push(token);
866
+ continue;
867
+ }
868
+ if (prev && ('bracket' === prev.type || 'paren' === prev.type) && true === opts.regex) {
869
+ token.output = value;
870
+ push(token);
871
+ continue;
872
+ }
873
+ if (state.index === state.start || 'slash' === prev.type || 'dot' === prev.type) {
874
+ if ('dot' === prev.type) {
875
+ state.output += NO_DOT_SLASH;
876
+ prev.output += NO_DOT_SLASH;
877
+ } else if (true === opts.dot) {
878
+ state.output += NO_DOTS_SLASH;
879
+ prev.output += NO_DOTS_SLASH;
880
+ } else {
881
+ state.output += nodot;
882
+ prev.output += nodot;
883
+ }
884
+ if ('*' !== peek()) {
885
+ state.output += ONE_CHAR;
886
+ prev.output += ONE_CHAR;
887
+ }
888
+ }
889
+ push(token);
890
+ }
891
+ while(state.brackets > 0){
892
+ if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', ']'));
893
+ state.output = utils.escapeLast(state.output, '[');
894
+ decrement('brackets');
895
+ }
896
+ while(state.parens > 0){
897
+ if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', ')'));
898
+ state.output = utils.escapeLast(state.output, '(');
899
+ decrement('parens');
900
+ }
901
+ while(state.braces > 0){
902
+ if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', '}'));
903
+ state.output = utils.escapeLast(state.output, '{');
904
+ decrement('braces');
905
+ }
906
+ if (true !== opts.strictSlashes && ('star' === prev.type || 'bracket' === prev.type)) push({
907
+ type: 'maybe_slash',
908
+ value: '',
909
+ output: `${SLASH_LITERAL}?`
910
+ });
911
+ if (true === state.backtrack) {
912
+ state.output = '';
913
+ for (const token of state.tokens){
914
+ state.output += null != token.output ? token.output : token.value;
915
+ if (token.suffix) state.output += token.suffix;
916
+ }
917
+ }
918
+ return state;
919
+ };
920
+ parse.fastpaths = (input, options)=>{
921
+ const opts = {
922
+ ...options
923
+ };
924
+ const max = 'number' == typeof opts.maxLength ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
925
+ const len = input.length;
926
+ if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
927
+ input = REPLACEMENTS[input] || input;
928
+ const { DOT_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOTS, NO_DOTS_SLASH, STAR, START_ANCHOR } = constants.globChars(opts.windows);
929
+ const nodot = opts.dot ? NO_DOTS : NO_DOT;
930
+ const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
931
+ const capture = opts.capture ? '' : '?:';
932
+ const state = {
933
+ negated: false,
934
+ prefix: ''
935
+ };
936
+ let star = true === opts.bash ? '.*?' : STAR;
937
+ if (opts.capture) star = `(${star})`;
938
+ const globstar = (opts)=>{
939
+ if (true === opts.noglobstar) return star;
940
+ return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
941
+ };
942
+ const create = (str)=>{
943
+ switch(str){
944
+ case '*':
945
+ return `${nodot}${ONE_CHAR}${star}`;
946
+ case '.*':
947
+ return `${DOT_LITERAL}${ONE_CHAR}${star}`;
948
+ case '*.*':
949
+ return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
950
+ case '*/*':
951
+ return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
952
+ case '**':
953
+ return nodot + globstar(opts);
954
+ case '**/*':
955
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
956
+ case '**/*.*':
957
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
958
+ case '**/.*':
959
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
960
+ default:
961
+ {
962
+ const match = /^(.*?)\.(\w+)$/.exec(str);
963
+ if (!match) return;
964
+ const source = create(match[1]);
965
+ if (!source) return;
966
+ return source + DOT_LITERAL + match[2];
967
+ }
968
+ }
969
+ };
970
+ const output = utils.removePrefix(input, state);
971
+ let source = create(output);
972
+ if (source && true !== opts.strictSlashes) source += `${SLASH_LITERAL}?`;
973
+ return source;
974
+ };
975
+ module.exports = parse;
976
+ },
977
+ "../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js" (module, __unused_rspack_exports, __webpack_require__) {
978
+ const scan = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.js");
979
+ const parse = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.js");
980
+ const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js");
981
+ const constants = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js");
982
+ const isObject = (val)=>val && 'object' == typeof val && !Array.isArray(val);
983
+ const picomatch = (glob, options, returnState = false)=>{
984
+ if (Array.isArray(glob)) {
985
+ const fns = glob.map((input)=>picomatch(input, options, returnState));
986
+ const arrayMatcher = (str)=>{
987
+ for (const isMatch of fns){
988
+ const state = isMatch(str);
989
+ if (state) return state;
990
+ }
991
+ return false;
992
+ };
993
+ return arrayMatcher;
994
+ }
995
+ const isState = isObject(glob) && glob.tokens && glob.input;
996
+ if ('' === glob || 'string' != typeof glob && !isState) throw new TypeError('Expected pattern to be a non-empty string');
997
+ const opts = options || {};
998
+ const posix = opts.windows;
999
+ const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
1000
+ const state = regex.state;
1001
+ delete regex.state;
1002
+ let isIgnored = ()=>false;
1003
+ if (opts.ignore) {
1004
+ const ignoreOpts = {
1005
+ ...options,
1006
+ ignore: null,
1007
+ onMatch: null,
1008
+ onResult: null
1009
+ };
1010
+ isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
1011
+ }
1012
+ const matcher = (input, returnObject = false)=>{
1013
+ const { isMatch, match, output } = picomatch.test(input, regex, options, {
1014
+ glob,
1015
+ posix
1016
+ });
1017
+ const result = {
1018
+ glob,
1019
+ state,
1020
+ regex,
1021
+ posix,
1022
+ input,
1023
+ output,
1024
+ match,
1025
+ isMatch
1026
+ };
1027
+ if ('function' == typeof opts.onResult) opts.onResult(result);
1028
+ if (false === isMatch) {
1029
+ result.isMatch = false;
1030
+ return returnObject ? result : false;
1031
+ }
1032
+ if (isIgnored(input)) {
1033
+ if ('function' == typeof opts.onIgnore) opts.onIgnore(result);
1034
+ result.isMatch = false;
1035
+ return returnObject ? result : false;
1036
+ }
1037
+ if ('function' == typeof opts.onMatch) opts.onMatch(result);
1038
+ return returnObject ? result : true;
1039
+ };
1040
+ if (returnState) matcher.state = state;
1041
+ return matcher;
1042
+ };
1043
+ picomatch.test = (input, regex, options, { glob, posix } = {})=>{
1044
+ if ('string' != typeof input) throw new TypeError('Expected input to be a string');
1045
+ if ('' === input) return {
1046
+ isMatch: false,
1047
+ output: ''
1048
+ };
1049
+ const opts = options || {};
1050
+ const format = opts.format || (posix ? utils.toPosixSlashes : null);
1051
+ let match = input === glob;
1052
+ let output = match && format ? format(input) : input;
1053
+ if (false === match) {
1054
+ output = format ? format(input) : input;
1055
+ match = output === glob;
1056
+ }
1057
+ if (false === match || true === opts.capture) match = true === opts.matchBase || true === opts.basename ? picomatch.matchBase(input, regex, options, posix) : regex.exec(output);
1058
+ return {
1059
+ isMatch: Boolean(match),
1060
+ match,
1061
+ output
1062
+ };
1063
+ };
1064
+ picomatch.matchBase = (input, glob, options)=>{
1065
+ const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
1066
+ return regex.test(utils.basename(input));
1067
+ };
1068
+ picomatch.isMatch = (str, patterns, options)=>picomatch(patterns, options)(str);
1069
+ picomatch.parse = (pattern, options)=>{
1070
+ if (Array.isArray(pattern)) return pattern.map((p)=>picomatch.parse(p, options));
1071
+ return parse(pattern, {
1072
+ ...options,
1073
+ fastpaths: false
1074
+ });
1075
+ };
1076
+ picomatch.scan = (input, options)=>scan(input, options);
1077
+ picomatch.compileRe = (state, options, returnOutput = false, returnState = false)=>{
1078
+ if (true === returnOutput) return state.output;
1079
+ const opts = options || {};
1080
+ const prepend = opts.contains ? '' : '^';
1081
+ const append = opts.contains ? '' : '$';
1082
+ let source = `${prepend}(?:${state.output})${append}`;
1083
+ if (state && true === state.negated) source = `^(?!${source}).*$`;
1084
+ const regex = picomatch.toRegex(source, options);
1085
+ if (true === returnState) regex.state = state;
1086
+ return regex;
1087
+ };
1088
+ picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false)=>{
1089
+ if (!input || 'string' != typeof input) throw new TypeError('Expected a non-empty string');
1090
+ let parsed = {
1091
+ negated: false,
1092
+ fastpaths: true
1093
+ };
1094
+ if (false !== options.fastpaths && ('.' === input[0] || '*' === input[0])) parsed.output = parse.fastpaths(input, options);
1095
+ if (!parsed.output) parsed = parse(input, options);
1096
+ return picomatch.compileRe(parsed, options, returnOutput, returnState);
1097
+ };
1098
+ picomatch.toRegex = (source, options)=>{
1099
+ try {
1100
+ const opts = options || {};
1101
+ return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
1102
+ } catch (err) {
1103
+ if (options && true === options.debug) throw err;
1104
+ return /$^/;
1105
+ }
1106
+ };
1107
+ picomatch.constants = constants;
1108
+ module.exports = picomatch;
1109
+ },
1110
+ "../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.js" (module, __unused_rspack_exports, __webpack_require__) {
1111
+ const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js");
1112
+ 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 } = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js");
1113
+ const isPathSeparator = (code)=>code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
1114
+ const depth = (token)=>{
1115
+ if (true !== token.isPrefix) token.depth = token.isGlobstar ? 1 / 0 : 1;
1116
+ };
1117
+ const scan = (input, options)=>{
1118
+ const opts = options || {};
1119
+ const length = input.length - 1;
1120
+ const scanToEnd = true === opts.parts || true === opts.scanToEnd;
1121
+ const slashes = [];
1122
+ const tokens = [];
1123
+ const parts = [];
1124
+ let str = input;
1125
+ let index = -1;
1126
+ let start = 0;
1127
+ let lastIndex = 0;
1128
+ let isBrace = false;
1129
+ let isBracket = false;
1130
+ let isGlob = false;
1131
+ let isExtglob = false;
1132
+ let isGlobstar = false;
1133
+ let braceEscaped = false;
1134
+ let backslashes = false;
1135
+ let negated = false;
1136
+ let negatedExtglob = false;
1137
+ let finished = false;
1138
+ let braces = 0;
1139
+ let prev;
1140
+ let code;
1141
+ let token = {
1142
+ value: '',
1143
+ depth: 0,
1144
+ isGlob: false
1145
+ };
1146
+ const eos = ()=>index >= length;
1147
+ const peek = ()=>str.charCodeAt(index + 1);
1148
+ const advance = ()=>{
1149
+ prev = code;
1150
+ return str.charCodeAt(++index);
1151
+ };
1152
+ while(index < length){
1153
+ code = advance();
1154
+ let next;
1155
+ if (code === CHAR_BACKWARD_SLASH) {
1156
+ backslashes = token.backslashes = true;
1157
+ code = advance();
1158
+ if (code === CHAR_LEFT_CURLY_BRACE) braceEscaped = true;
1159
+ continue;
1160
+ }
1161
+ if (true === braceEscaped || code === CHAR_LEFT_CURLY_BRACE) {
1162
+ braces++;
1163
+ while(true !== eos() && (code = advance())){
1164
+ if (code === CHAR_BACKWARD_SLASH) {
1165
+ backslashes = token.backslashes = true;
1166
+ advance();
1167
+ continue;
1168
+ }
1169
+ if (code === CHAR_LEFT_CURLY_BRACE) {
1170
+ braces++;
1171
+ continue;
1172
+ }
1173
+ if (true !== braceEscaped && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
1174
+ isBrace = token.isBrace = true;
1175
+ isGlob = token.isGlob = true;
1176
+ finished = true;
1177
+ if (true === scanToEnd) continue;
1178
+ break;
1179
+ }
1180
+ if (true !== braceEscaped && code === CHAR_COMMA) {
1181
+ isBrace = token.isBrace = true;
1182
+ isGlob = token.isGlob = true;
1183
+ finished = true;
1184
+ if (true === scanToEnd) continue;
1185
+ break;
1186
+ }
1187
+ if (code === CHAR_RIGHT_CURLY_BRACE) {
1188
+ braces--;
1189
+ if (0 === braces) {
1190
+ braceEscaped = false;
1191
+ isBrace = token.isBrace = true;
1192
+ finished = true;
1193
+ break;
1194
+ }
1195
+ }
1196
+ }
1197
+ if (true === scanToEnd) continue;
1198
+ break;
1199
+ }
1200
+ if (code === CHAR_FORWARD_SLASH) {
1201
+ slashes.push(index);
1202
+ tokens.push(token);
1203
+ token = {
1204
+ value: '',
1205
+ depth: 0,
1206
+ isGlob: false
1207
+ };
1208
+ if (true === finished) continue;
1209
+ if (prev === CHAR_DOT && index === start + 1) {
1210
+ start += 2;
1211
+ continue;
1212
+ }
1213
+ lastIndex = index + 1;
1214
+ continue;
1215
+ }
1216
+ if (true !== opts.noext) {
1217
+ const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
1218
+ if (true === isExtglobChar && peek() === CHAR_LEFT_PARENTHESES) {
1219
+ isGlob = token.isGlob = true;
1220
+ isExtglob = token.isExtglob = true;
1221
+ finished = true;
1222
+ if (code === CHAR_EXCLAMATION_MARK && index === start) negatedExtglob = true;
1223
+ if (true === scanToEnd) {
1224
+ while(true !== eos() && (code = advance())){
1225
+ if (code === CHAR_BACKWARD_SLASH) {
1226
+ backslashes = token.backslashes = true;
1227
+ code = advance();
1228
+ continue;
1229
+ }
1230
+ if (code === CHAR_RIGHT_PARENTHESES) {
1231
+ isGlob = token.isGlob = true;
1232
+ finished = true;
1233
+ break;
1234
+ }
1235
+ }
1236
+ continue;
1237
+ }
1238
+ break;
1239
+ }
1240
+ }
1241
+ if (code === CHAR_ASTERISK) {
1242
+ if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
1243
+ isGlob = token.isGlob = true;
1244
+ finished = true;
1245
+ if (true === scanToEnd) continue;
1246
+ break;
1247
+ }
1248
+ if (code === CHAR_QUESTION_MARK) {
1249
+ isGlob = token.isGlob = true;
1250
+ finished = true;
1251
+ if (true === scanToEnd) continue;
1252
+ break;
1253
+ }
1254
+ if (code === CHAR_LEFT_SQUARE_BRACKET) {
1255
+ while(true !== eos() && (next = advance())){
1256
+ if (next === CHAR_BACKWARD_SLASH) {
1257
+ backslashes = token.backslashes = true;
1258
+ advance();
1259
+ continue;
1260
+ }
1261
+ if (next === CHAR_RIGHT_SQUARE_BRACKET) {
1262
+ isBracket = token.isBracket = true;
1263
+ isGlob = token.isGlob = true;
1264
+ finished = true;
1265
+ break;
1266
+ }
1267
+ }
1268
+ if (true === scanToEnd) continue;
1269
+ break;
1270
+ }
1271
+ if (true !== opts.nonegate && code === CHAR_EXCLAMATION_MARK && index === start) {
1272
+ negated = token.negated = true;
1273
+ start++;
1274
+ continue;
1275
+ }
1276
+ if (true !== opts.noparen && code === CHAR_LEFT_PARENTHESES) {
1277
+ isGlob = token.isGlob = true;
1278
+ if (true === scanToEnd) {
1279
+ while(true !== eos() && (code = advance())){
1280
+ if (code === CHAR_LEFT_PARENTHESES) {
1281
+ backslashes = token.backslashes = true;
1282
+ code = advance();
1283
+ continue;
1284
+ }
1285
+ if (code === CHAR_RIGHT_PARENTHESES) {
1286
+ finished = true;
1287
+ break;
1288
+ }
1289
+ }
1290
+ continue;
1291
+ }
1292
+ break;
1293
+ }
1294
+ if (true === isGlob) {
1295
+ finished = true;
1296
+ if (true === scanToEnd) continue;
1297
+ break;
1298
+ }
1299
+ }
1300
+ if (true === opts.noext) {
1301
+ isExtglob = false;
1302
+ isGlob = false;
1303
+ }
1304
+ let base = str;
1305
+ let prefix = '';
1306
+ let glob = '';
1307
+ if (start > 0) {
1308
+ prefix = str.slice(0, start);
1309
+ str = str.slice(start);
1310
+ lastIndex -= start;
1311
+ }
1312
+ if (base && true === isGlob && lastIndex > 0) {
1313
+ base = str.slice(0, lastIndex);
1314
+ glob = str.slice(lastIndex);
1315
+ } else if (true === isGlob) {
1316
+ base = '';
1317
+ glob = str;
1318
+ } else base = str;
1319
+ if (base && '' !== base && '/' !== base && base !== str) {
1320
+ if (isPathSeparator(base.charCodeAt(base.length - 1))) base = base.slice(0, -1);
1321
+ }
1322
+ if (true === opts.unescape) {
1323
+ if (glob) glob = utils.removeBackslashes(glob);
1324
+ if (base && true === backslashes) base = utils.removeBackslashes(base);
1325
+ }
1326
+ const state = {
1327
+ prefix,
1328
+ input,
1329
+ start,
1330
+ base,
1331
+ glob,
1332
+ isBrace,
1333
+ isBracket,
1334
+ isGlob,
1335
+ isExtglob,
1336
+ isGlobstar,
1337
+ negated,
1338
+ negatedExtglob
1339
+ };
1340
+ if (true === opts.tokens) {
1341
+ state.maxDepth = 0;
1342
+ if (!isPathSeparator(code)) tokens.push(token);
1343
+ state.tokens = tokens;
1344
+ }
1345
+ if (true === opts.parts || true === opts.tokens) {
1346
+ let prevIndex;
1347
+ for(let idx = 0; idx < slashes.length; idx++){
1348
+ const n = prevIndex ? prevIndex + 1 : start;
1349
+ const i = slashes[idx];
1350
+ const value = input.slice(n, i);
1351
+ if (opts.tokens) {
1352
+ if (0 === idx && 0 !== start) {
1353
+ tokens[idx].isPrefix = true;
1354
+ tokens[idx].value = prefix;
1355
+ } else tokens[idx].value = value;
1356
+ depth(tokens[idx]);
1357
+ state.maxDepth += tokens[idx].depth;
1358
+ }
1359
+ if (0 !== idx || '' !== value) parts.push(value);
1360
+ prevIndex = i;
1361
+ }
1362
+ if (prevIndex && prevIndex + 1 < input.length) {
1363
+ const value = input.slice(prevIndex + 1);
1364
+ parts.push(value);
1365
+ if (opts.tokens) {
1366
+ tokens[tokens.length - 1].value = value;
1367
+ depth(tokens[tokens.length - 1]);
1368
+ state.maxDepth += tokens[tokens.length - 1].depth;
1369
+ }
1370
+ }
1371
+ state.slashes = slashes;
1372
+ state.parts = parts;
1373
+ }
1374
+ return state;
1375
+ };
1376
+ module.exports = scan;
1377
+ },
1378
+ "../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js" (__unused_rspack_module, exports, __webpack_require__) {
1379
+ const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js");
1380
+ exports.isObject = (val)=>null !== val && 'object' == typeof val && !Array.isArray(val);
1381
+ exports.hasRegexChars = (str)=>REGEX_SPECIAL_CHARS.test(str);
1382
+ exports.isRegexChar = (str)=>1 === str.length && exports.hasRegexChars(str);
1383
+ exports.escapeRegex = (str)=>str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
1384
+ exports.toPosixSlashes = (str)=>str.replace(REGEX_BACKSLASH, '/');
1385
+ exports.isWindows = ()=>{
1386
+ if ("u" > typeof navigator && navigator.platform) {
1387
+ const platform = navigator.platform.toLowerCase();
1388
+ return 'win32' === platform || 'windows' === platform;
1389
+ }
1390
+ if ("u" > typeof process && process.platform) return 'win32' === process.platform;
1391
+ return false;
1392
+ };
1393
+ exports.removeBackslashes = (str)=>str.replace(REGEX_REMOVE_BACKSLASH, (match)=>'\\' === match ? '' : match);
1394
+ exports.escapeLast = (input, char, lastIdx)=>{
1395
+ const idx = input.lastIndexOf(char, lastIdx);
1396
+ if (-1 === idx) return input;
1397
+ if ('\\' === input[idx - 1]) return exports.escapeLast(input, char, idx - 1);
1398
+ return `${input.slice(0, idx)}\\${input.slice(idx)}`;
1399
+ };
1400
+ exports.removePrefix = (input, state = {})=>{
1401
+ let output = input;
1402
+ if (output.startsWith('./')) {
1403
+ output = output.slice(2);
1404
+ state.prefix = './';
1405
+ }
1406
+ return output;
1407
+ };
1408
+ exports.wrapOutput = (input, state = {}, options = {})=>{
1409
+ const prepend = options.contains ? '' : '^';
1410
+ const append = options.contains ? '' : '$';
1411
+ let output = `${prepend}(?:${input})${append}`;
1412
+ if (true === state.negated) output = `(?:^(?!${output}).*$)`;
1413
+ return output;
1414
+ };
1415
+ exports.basename = (path, { windows } = {})=>{
1416
+ const segs = path.split(windows ? /[\\/]/ : '/');
1417
+ const last = segs[segs.length - 1];
1418
+ if ('' === last) return segs[segs.length - 2];
1419
+ return last;
1420
+ };
1421
+ }
1422
+ });
1423
+ var __require = /* @__PURE__ */ external_module_createRequire(import.meta.url);
1424
+ function cleanPath(path) {
1425
+ let normalized = external_path_normalize(path);
1426
+ if (normalized.length > 1 && normalized[normalized.length - 1] === external_path_sep) normalized = normalized.substring(0, normalized.length - 1);
1427
+ return normalized;
1428
+ }
1429
+ const SLASHES_REGEX = /[\\/]/g;
1430
+ function convertSlashes(path, separator) {
1431
+ return path.replace(SLASHES_REGEX, separator);
1432
+ }
1433
+ const WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
1434
+ function isRootDirectory(path) {
1435
+ return "/" === path || WINDOWS_ROOT_DIR_REGEX.test(path);
1436
+ }
1437
+ function normalizePath(path, options) {
1438
+ const { resolvePaths, normalizePath: normalizePath$1, pathSeparator } = options;
1439
+ const pathNeedsCleaning = "win32" === process.platform && path.includes("/") || path.startsWith(".");
1440
+ if (resolvePaths) path = external_path_resolve(path);
1441
+ if (normalizePath$1 || pathNeedsCleaning) path = cleanPath(path);
1442
+ if ("." === path) return "";
1443
+ const needsSeperator = path[path.length - 1] !== pathSeparator;
1444
+ return convertSlashes(needsSeperator ? path + pathSeparator : path, pathSeparator);
1445
+ }
1446
+ function joinPathWithBasePath(filename, directoryPath) {
1447
+ return directoryPath + filename;
1448
+ }
1449
+ function joinPathWithRelativePath(root, options) {
1450
+ return function(filename, directoryPath) {
1451
+ const sameRoot = directoryPath.startsWith(root);
1452
+ if (sameRoot) return directoryPath.slice(root.length) + filename;
1453
+ return convertSlashes(external_path_relative(root, directoryPath), options.pathSeparator) + options.pathSeparator + filename;
1454
+ };
1455
+ }
1456
+ function joinPath(filename) {
1457
+ return filename;
1458
+ }
1459
+ function joinDirectoryPath(filename, directoryPath, separator) {
1460
+ return directoryPath + filename + separator;
1461
+ }
1462
+ function build$7(root, options) {
1463
+ const { relativePaths, includeBasePath } = options;
1464
+ return relativePaths && root ? joinPathWithRelativePath(root, options) : includeBasePath ? joinPathWithBasePath : joinPath;
1465
+ }
1466
+ function pushDirectoryWithRelativePath(root) {
1467
+ return function(directoryPath, paths) {
1468
+ paths.push(directoryPath.substring(root.length) || ".");
1469
+ };
1470
+ }
1471
+ function pushDirectoryFilterWithRelativePath(root) {
1472
+ return function(directoryPath, paths, filters) {
1473
+ const relativePath = directoryPath.substring(root.length) || ".";
1474
+ if (filters.every((filter)=>filter(relativePath, true))) paths.push(relativePath);
1475
+ };
1476
+ }
1477
+ const pushDirectory = (directoryPath, paths)=>{
1478
+ paths.push(directoryPath || ".");
1479
+ };
1480
+ const pushDirectoryFilter = (directoryPath, paths, filters)=>{
1481
+ const path = directoryPath || ".";
1482
+ if (filters.every((filter)=>filter(path, true))) paths.push(path);
1483
+ };
1484
+ const empty$2 = ()=>{};
1485
+ function build$6(root, options) {
1486
+ const { includeDirs, filters, relativePaths } = options;
1487
+ if (!includeDirs) return empty$2;
1488
+ if (relativePaths) return filters && filters.length ? pushDirectoryFilterWithRelativePath(root) : pushDirectoryWithRelativePath(root);
1489
+ return filters && filters.length ? pushDirectoryFilter : pushDirectory;
1490
+ }
1491
+ const pushFileFilterAndCount = (filename, _paths, counts, filters)=>{
1492
+ if (filters.every((filter)=>filter(filename, false))) counts.files++;
1493
+ };
1494
+ const pushFileFilter = (filename, paths, _counts, filters)=>{
1495
+ if (filters.every((filter)=>filter(filename, false))) paths.push(filename);
1496
+ };
1497
+ const pushFileCount = (_filename, _paths, counts, _filters)=>{
1498
+ counts.files++;
1499
+ };
1500
+ const pushFile = (filename, paths)=>{
1501
+ paths.push(filename);
1502
+ };
1503
+ const empty$1 = ()=>{};
1504
+ function build$5(options) {
1505
+ const { excludeFiles, filters, onlyCounts } = options;
1506
+ if (excludeFiles) return empty$1;
1507
+ if (filters && filters.length) return onlyCounts ? pushFileFilterAndCount : pushFileFilter;
1508
+ if (onlyCounts) return pushFileCount;
1509
+ return pushFile;
1510
+ }
1511
+ const getArray = (paths)=>paths;
1512
+ const getArrayGroup = ()=>[
1513
+ ""
1514
+ ].slice(0, 0);
1515
+ function build$4(options) {
1516
+ return options.group ? getArrayGroup : getArray;
1517
+ }
1518
+ const groupFiles = (groups, directory, files)=>{
1519
+ groups.push({
1520
+ directory,
1521
+ files,
1522
+ dir: directory
1523
+ });
1524
+ };
1525
+ const empty = ()=>{};
1526
+ function build$3(options) {
1527
+ return options.group ? groupFiles : empty;
1528
+ }
1529
+ const resolveSymlinksAsync = function(path, state, callback$1) {
1530
+ const { queue, fs, options: { suppressErrors } } = state;
1531
+ queue.enqueue();
1532
+ fs.realpath(path, (error, resolvedPath)=>{
1533
+ if (error) return queue.dequeue(suppressErrors ? null : error, state);
1534
+ fs.stat(resolvedPath, (error$1, stat)=>{
1535
+ if (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);
1536
+ if (stat.isDirectory() && isRecursive(path, resolvedPath, state)) return queue.dequeue(null, state);
1537
+ callback$1(stat, resolvedPath);
1538
+ queue.dequeue(null, state);
1539
+ });
1540
+ });
1541
+ };
1542
+ const resolveSymlinks = function(path, state, callback$1) {
1543
+ const { queue, fs, options: { suppressErrors } } = state;
1544
+ queue.enqueue();
1545
+ try {
1546
+ const resolvedPath = fs.realpathSync(path);
1547
+ const stat = fs.statSync(resolvedPath);
1548
+ if (stat.isDirectory() && isRecursive(path, resolvedPath, state)) return;
1549
+ callback$1(stat, resolvedPath);
1550
+ } catch (e) {
1551
+ if (!suppressErrors) throw e;
1552
+ }
1553
+ };
1554
+ function build$2(options, isSynchronous) {
1555
+ if (!options.resolveSymlinks || options.excludeSymlinks) return null;
1556
+ return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
1557
+ }
1558
+ function isRecursive(path, resolved, state) {
1559
+ if (state.options.useRealPaths) return isRecursiveUsingRealPaths(resolved, state);
1560
+ let parent = external_path_dirname(path);
1561
+ let depth = 1;
1562
+ while(parent !== state.root && depth < 2){
1563
+ const resolvedPath = state.symlinks.get(parent);
1564
+ const isSameRoot = !!resolvedPath && (resolvedPath === resolved || resolvedPath.startsWith(resolved) || resolved.startsWith(resolvedPath));
1565
+ if (isSameRoot) depth++;
1566
+ else parent = external_path_dirname(parent);
1567
+ }
1568
+ state.symlinks.set(path, resolved);
1569
+ return depth > 1;
1570
+ }
1571
+ function isRecursiveUsingRealPaths(resolved, state) {
1572
+ return state.visited.includes(resolved + state.options.pathSeparator);
1573
+ }
1574
+ const onlyCountsSync = (state)=>state.counts;
1575
+ const groupsSync = (state)=>state.groups;
1576
+ const defaultSync = (state)=>state.paths;
1577
+ const limitFilesSync = (state)=>state.paths.slice(0, state.options.maxFiles);
1578
+ const onlyCountsAsync = (state, error, callback$1)=>{
1579
+ report(error, callback$1, state.counts, state.options.suppressErrors);
1580
+ return null;
1581
+ };
1582
+ const defaultAsync = (state, error, callback$1)=>{
1583
+ report(error, callback$1, state.paths, state.options.suppressErrors);
1584
+ return null;
1585
+ };
1586
+ const limitFilesAsync = (state, error, callback$1)=>{
1587
+ report(error, callback$1, state.paths.slice(0, state.options.maxFiles), state.options.suppressErrors);
1588
+ return null;
1589
+ };
1590
+ const groupsAsync = (state, error, callback$1)=>{
1591
+ report(error, callback$1, state.groups, state.options.suppressErrors);
1592
+ return null;
1593
+ };
1594
+ function report(error, callback$1, output, suppressErrors) {
1595
+ callback$1(error && !suppressErrors ? error : null, output);
1596
+ }
1597
+ function build$1(options, isSynchronous) {
1598
+ const { onlyCounts, group, maxFiles } = options;
1599
+ if (onlyCounts) return isSynchronous ? onlyCountsSync : onlyCountsAsync;
1600
+ if (group) return isSynchronous ? groupsSync : groupsAsync;
1601
+ if (maxFiles) return isSynchronous ? limitFilesSync : limitFilesAsync;
1602
+ return isSynchronous ? defaultSync : defaultAsync;
1603
+ }
1604
+ const readdirOpts = {
1605
+ withFileTypes: true
1606
+ };
1607
+ const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1)=>{
1608
+ state.queue.enqueue();
1609
+ if (currentDepth < 0) return state.queue.dequeue(null, state);
1610
+ const { fs } = state;
1611
+ state.visited.push(crawlPath);
1612
+ state.counts.directories++;
1613
+ fs.readdir(crawlPath || ".", readdirOpts, (error, entries = [])=>{
1614
+ callback$1(entries, directoryPath, currentDepth);
1615
+ state.queue.dequeue(state.options.suppressErrors ? null : error, state);
1616
+ });
1617
+ };
1618
+ const walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1)=>{
1619
+ const { fs } = state;
1620
+ if (currentDepth < 0) return;
1621
+ state.visited.push(crawlPath);
1622
+ state.counts.directories++;
1623
+ let entries = [];
1624
+ try {
1625
+ entries = fs.readdirSync(crawlPath || ".", readdirOpts);
1626
+ } catch (e) {
1627
+ if (!state.options.suppressErrors) throw e;
1628
+ }
1629
+ callback$1(entries, directoryPath, currentDepth);
1630
+ };
1631
+ function build(isSynchronous) {
1632
+ return isSynchronous ? walkSync : walkAsync;
1633
+ }
1634
+ var Queue = class {
1635
+ count = 0;
1636
+ constructor(onQueueEmpty){
1637
+ this.onQueueEmpty = onQueueEmpty;
1638
+ }
1639
+ enqueue() {
1640
+ this.count++;
1641
+ return this.count;
1642
+ }
1643
+ dequeue(error, output) {
1644
+ if (this.onQueueEmpty && (--this.count <= 0 || error)) {
1645
+ this.onQueueEmpty(error, output);
1646
+ if (error) {
1647
+ output.controller.abort();
1648
+ this.onQueueEmpty = void 0;
1649
+ }
1650
+ }
1651
+ }
1652
+ };
1653
+ var Counter = class {
1654
+ _files = 0;
1655
+ _directories = 0;
1656
+ set files(num) {
1657
+ this._files = num;
1658
+ }
1659
+ get files() {
1660
+ return this._files;
1661
+ }
1662
+ set directories(num) {
1663
+ this._directories = num;
1664
+ }
1665
+ get directories() {
1666
+ return this._directories;
1667
+ }
1668
+ get dirs() {
1669
+ return this._directories;
1670
+ }
1671
+ };
1672
+ var Aborter = class {
1673
+ aborted = false;
1674
+ abort() {
1675
+ this.aborted = true;
1676
+ }
1677
+ };
1678
+ var Walker = class {
1679
+ root;
1680
+ isSynchronous;
1681
+ state;
1682
+ joinPath;
1683
+ pushDirectory;
1684
+ pushFile;
1685
+ getArray;
1686
+ groupFiles;
1687
+ resolveSymlink;
1688
+ walkDirectory;
1689
+ callbackInvoker;
1690
+ constructor(root, options, callback$1){
1691
+ this.isSynchronous = !callback$1;
1692
+ this.callbackInvoker = build$1(options, this.isSynchronous);
1693
+ this.root = normalizePath(root, options);
1694
+ this.state = {
1695
+ root: isRootDirectory(this.root) ? this.root : this.root.slice(0, -1),
1696
+ paths: [
1697
+ ""
1698
+ ].slice(0, 0),
1699
+ groups: [],
1700
+ counts: new Counter(),
1701
+ options,
1702
+ queue: new Queue((error, state)=>this.callbackInvoker(state, error, callback$1)),
1703
+ symlinks: /* @__PURE__ */ new Map(),
1704
+ visited: [
1705
+ ""
1706
+ ].slice(0, 0),
1707
+ controller: new Aborter(),
1708
+ fs: options.fs || __rspack_external_fs
1709
+ };
1710
+ this.joinPath = build$7(this.root, options);
1711
+ this.pushDirectory = build$6(this.root, options);
1712
+ this.pushFile = build$5(options);
1713
+ this.getArray = build$4(options);
1714
+ this.groupFiles = build$3(options);
1715
+ this.resolveSymlink = build$2(options, this.isSynchronous);
1716
+ this.walkDirectory = build(this.isSynchronous);
1717
+ }
1718
+ start() {
1719
+ this.pushDirectory(this.root, this.state.paths, this.state.options.filters);
1720
+ this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk);
1721
+ return this.isSynchronous ? this.callbackInvoker(this.state, null) : null;
1722
+ }
1723
+ walk = (entries, directoryPath, depth)=>{
1724
+ const { paths, options: { filters, resolveSymlinks: resolveSymlinks$1, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator }, controller } = this.state;
1725
+ if (controller.aborted || signal && signal.aborted || maxFiles && paths.length > maxFiles) return;
1726
+ const files = this.getArray(this.state.paths);
1727
+ for(let i = 0; i < entries.length; ++i){
1728
+ const entry = entries[i];
1729
+ if (entry.isFile() || entry.isSymbolicLink() && !resolveSymlinks$1 && !excludeSymlinks) {
1730
+ const filename = this.joinPath(entry.name, directoryPath);
1731
+ this.pushFile(filename, files, this.state.counts, filters);
1732
+ } else if (entry.isDirectory()) {
1733
+ let path = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
1734
+ if (exclude && exclude(entry.name, path)) continue;
1735
+ this.pushDirectory(path, paths, filters);
1736
+ this.walkDirectory(this.state, path, path, depth - 1, this.walk);
1737
+ } else if (this.resolveSymlink && entry.isSymbolicLink()) {
1738
+ let path = joinPathWithBasePath(entry.name, directoryPath);
1739
+ this.resolveSymlink(path, this.state, (stat, resolvedPath)=>{
1740
+ if (stat.isDirectory()) {
1741
+ resolvedPath = normalizePath(resolvedPath, this.state.options);
1742
+ if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path + pathSeparator)) return;
1743
+ this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path + pathSeparator, depth - 1, this.walk);
1744
+ } else {
1745
+ resolvedPath = useRealPaths ? resolvedPath : path;
1746
+ const filename = external_path_basename(resolvedPath);
1747
+ const directoryPath$1 = normalizePath(external_path_dirname(resolvedPath), this.state.options);
1748
+ resolvedPath = this.joinPath(filename, directoryPath$1);
1749
+ this.pushFile(resolvedPath, files, this.state.counts, filters);
1750
+ }
1751
+ });
1752
+ }
1753
+ }
1754
+ this.groupFiles(this.state.groups, directoryPath, files);
1755
+ };
1756
+ };
1757
+ function promise(root, options) {
1758
+ return new Promise((resolve$1, reject)=>{
1759
+ callback(root, options, (err, output)=>{
1760
+ if (err) return reject(err);
1761
+ resolve$1(output);
1762
+ });
1763
+ });
1764
+ }
1765
+ function callback(root, options, callback$1) {
1766
+ let walker = new Walker(root, options, callback$1);
1767
+ walker.start();
1768
+ }
1769
+ function sync(root, options) {
1770
+ const walker = new Walker(root, options);
1771
+ return walker.start();
1772
+ }
1773
+ var APIBuilder = class {
1774
+ constructor(root, options){
1775
+ this.root = root;
1776
+ this.options = options;
1777
+ }
1778
+ withPromise() {
1779
+ return promise(this.root, this.options);
1780
+ }
1781
+ withCallback(cb) {
1782
+ callback(this.root, this.options, cb);
1783
+ }
1784
+ sync() {
1785
+ return sync(this.root, this.options);
1786
+ }
1787
+ };
1788
+ let pm = null;
1789
+ try {
1790
+ __require.resolve("picomatch");
1791
+ pm = __require("picomatch");
1792
+ } catch {}
1793
+ var Builder = class {
1794
+ globCache = {};
1795
+ options = {
1796
+ maxDepth: 1 / 0,
1797
+ suppressErrors: true,
1798
+ pathSeparator: external_path_sep,
1799
+ filters: []
1800
+ };
1801
+ globFunction;
1802
+ constructor(options){
1803
+ this.options = {
1804
+ ...this.options,
1805
+ ...options
1806
+ };
1807
+ this.globFunction = this.options.globFunction;
1808
+ }
1809
+ group() {
1810
+ this.options.group = true;
1811
+ return this;
1812
+ }
1813
+ withPathSeparator(separator) {
1814
+ this.options.pathSeparator = separator;
1815
+ return this;
1816
+ }
1817
+ withBasePath() {
1818
+ this.options.includeBasePath = true;
1819
+ return this;
1820
+ }
1821
+ withRelativePaths() {
1822
+ this.options.relativePaths = true;
1823
+ return this;
1824
+ }
1825
+ withDirs() {
1826
+ this.options.includeDirs = true;
1827
+ return this;
1828
+ }
1829
+ withMaxDepth(depth) {
1830
+ this.options.maxDepth = depth;
1831
+ return this;
1832
+ }
1833
+ withMaxFiles(limit) {
1834
+ this.options.maxFiles = limit;
1835
+ return this;
1836
+ }
1837
+ withFullPaths() {
1838
+ this.options.resolvePaths = true;
1839
+ this.options.includeBasePath = true;
1840
+ return this;
1841
+ }
1842
+ withErrors() {
1843
+ this.options.suppressErrors = false;
1844
+ return this;
1845
+ }
1846
+ withSymlinks({ resolvePaths = true } = {}) {
1847
+ this.options.resolveSymlinks = true;
1848
+ this.options.useRealPaths = resolvePaths;
1849
+ return this.withFullPaths();
1850
+ }
1851
+ withAbortSignal(signal) {
1852
+ this.options.signal = signal;
1853
+ return this;
1854
+ }
1855
+ normalize() {
1856
+ this.options.normalizePath = true;
1857
+ return this;
1858
+ }
1859
+ filter(predicate) {
1860
+ this.options.filters.push(predicate);
1861
+ return this;
1862
+ }
1863
+ onlyDirs() {
1864
+ this.options.excludeFiles = true;
1865
+ this.options.includeDirs = true;
1866
+ return this;
1867
+ }
1868
+ exclude(predicate) {
1869
+ this.options.exclude = predicate;
1870
+ return this;
1871
+ }
1872
+ onlyCounts() {
1873
+ this.options.onlyCounts = true;
1874
+ return this;
1875
+ }
1876
+ crawl(root) {
1877
+ return new APIBuilder(root || ".", this.options);
1878
+ }
1879
+ withGlobFunction(fn) {
1880
+ this.globFunction = fn;
1881
+ return this;
1882
+ }
1883
+ crawlWithOptions(root, options) {
1884
+ this.options = {
1885
+ ...this.options,
1886
+ ...options
1887
+ };
1888
+ return new APIBuilder(root || ".", this.options);
1889
+ }
1890
+ glob(...patterns) {
1891
+ if (this.globFunction) return this.globWithOptions(patterns);
1892
+ return this.globWithOptions(patterns, {
1893
+ dot: true
1894
+ });
1895
+ }
1896
+ globWithOptions(patterns, ...options) {
1897
+ const globFn = this.globFunction || pm;
1898
+ if (!globFn) throw new Error("Please specify a glob function to use glob matching.");
1899
+ var isMatch = this.globCache[patterns.join("\0")];
1900
+ if (!isMatch) {
1901
+ isMatch = globFn(patterns, ...options);
1902
+ this.globCache[patterns.join("\0")] = isMatch;
1903
+ }
1904
+ this.options.filters.push((path)=>isMatch(path));
1905
+ return this;
1906
+ }
1907
+ };
1908
+ const picomatch = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js");
1909
+ const isReadonlyArray = Array.isArray;
1910
+ const isWin = "win32" === process.platform;
1911
+ const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
1912
+ function getPartialMatcher(patterns, options = {}) {
1913
+ const patternsCount = patterns.length;
1914
+ const patternsParts = Array(patternsCount);
1915
+ const matchers = Array(patternsCount);
1916
+ const globstarEnabled = !options.noglobstar;
1917
+ for(let i = 0; i < patternsCount; i++){
1918
+ const parts = splitPattern(patterns[i]);
1919
+ patternsParts[i] = parts;
1920
+ const partsCount = parts.length;
1921
+ const partMatchers = Array(partsCount);
1922
+ for(let j = 0; j < partsCount; j++)partMatchers[j] = picomatch(parts[j], options);
1923
+ matchers[i] = partMatchers;
1924
+ }
1925
+ return (input)=>{
1926
+ const inputParts = input.split("/");
1927
+ if (".." === inputParts[0] && ONLY_PARENT_DIRECTORIES.test(input)) return true;
1928
+ for(let i = 0; i < patterns.length; i++){
1929
+ const patternParts = patternsParts[i];
1930
+ const matcher = matchers[i];
1931
+ const inputPatternCount = inputParts.length;
1932
+ const minParts = Math.min(inputPatternCount, patternParts.length);
1933
+ let j = 0;
1934
+ while(j < minParts){
1935
+ const part = patternParts[j];
1936
+ if (part.includes("/")) return true;
1937
+ const match = matcher[j](inputParts[j]);
1938
+ if (!match) break;
1939
+ if (globstarEnabled && "**" === part) return true;
1940
+ j++;
1941
+ }
1942
+ if (j === inputPatternCount) return true;
1943
+ }
1944
+ return false;
1945
+ };
1946
+ }
1947
+ const WIN32_ROOT_DIR = /^[A-Z]:\/$/i;
1948
+ const isRoot = isWin ? (p)=>WIN32_ROOT_DIR.test(p) : (p)=>"/" === p;
1949
+ function buildFormat(cwd, root, absolute) {
1950
+ if (cwd === root || root.startsWith(`${cwd}/`)) {
1951
+ if (absolute) {
1952
+ const start = isRoot(cwd) ? cwd.length : cwd.length + 1;
1953
+ return (p, isDir)=>p.slice(start, isDir ? -1 : void 0) || ".";
1954
+ }
1955
+ const prefix = root.slice(cwd.length + 1);
1956
+ if (prefix) return (p, isDir)=>{
1957
+ if ("." === p) return prefix;
1958
+ const result = `${prefix}/${p}`;
1959
+ return isDir ? result.slice(0, -1) : result;
1960
+ };
1961
+ return (p, isDir)=>isDir && "." !== p ? p.slice(0, -1) : p;
1962
+ }
1963
+ if (absolute) return (p)=>posix.relative(cwd, p) || ".";
1964
+ return (p)=>posix.relative(cwd, `${root}/${p}`) || ".";
1965
+ }
1966
+ function buildRelative(cwd, root) {
1967
+ if (root.startsWith(`${cwd}/`)) {
1968
+ const prefix = root.slice(cwd.length + 1);
1969
+ return (p)=>`${prefix}/${p}`;
1970
+ }
1971
+ return (p)=>{
1972
+ const result = posix.relative(cwd, `${root}/${p}`);
1973
+ if (p.endsWith("/") && "" !== result) return `${result}/`;
1974
+ return result || ".";
1975
+ };
1976
+ }
1977
+ const splitPatternOptions = {
1978
+ parts: true
1979
+ };
1980
+ function splitPattern(path$1) {
1981
+ var _result$parts;
1982
+ const result = picomatch.scan(path$1, splitPatternOptions);
1983
+ return (null == (_result$parts = result.parts) ? void 0 : _result$parts.length) ? result.parts : [
1984
+ path$1
1985
+ ];
1986
+ }
1987
+ const ESCAPED_WIN32_BACKSLASHES = /\\(?![()[\]{}!+@])/g;
1988
+ function convertPosixPathToPattern(path$1) {
1989
+ return escapePosixPath(path$1);
1990
+ }
1991
+ function convertWin32PathToPattern(path$1) {
1992
+ return escapeWin32Path(path$1).replace(ESCAPED_WIN32_BACKSLASHES, "/");
1993
+ }
1994
+ const convertPathToPattern = isWin ? convertWin32PathToPattern : convertPosixPathToPattern;
1995
+ const POSIX_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
1996
+ const WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
1997
+ const escapePosixPath = (path$1)=>path$1.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
1998
+ const escapeWin32Path = (path$1)=>path$1.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
1999
+ const escapePath = isWin ? escapeWin32Path : escapePosixPath;
2000
+ function isDynamicPattern(pattern, options) {
2001
+ if ((null == options ? void 0 : options.caseSensitiveMatch) === false) return true;
2002
+ const scan = picomatch.scan(pattern);
2003
+ return scan.isGlob || scan.negated;
2004
+ }
2005
+ function log(...tasks) {
2006
+ console.log(`[tinyglobby ${/* @__PURE__ */ new Date().toLocaleTimeString("es")}]`, ...tasks);
2007
+ }
2008
+ const PARENT_DIRECTORY = /^(\/?\.\.)+/;
2009
+ const ESCAPING_BACKSLASHES = /\\(?=[()[\]{}!*+?@|])/g;
2010
+ const BACKSLASHES = /\\/g;
2011
+ function normalizePattern(pattern, expandDirectories, cwd, props, isIgnore) {
2012
+ let result = pattern;
2013
+ if (pattern.endsWith("/")) result = pattern.slice(0, -1);
2014
+ if (!result.endsWith("*") && expandDirectories) result += "/**";
2015
+ const escapedCwd = escapePath(cwd);
2016
+ result = path_0.isAbsolute(result.replace(ESCAPING_BACKSLASHES, "")) ? posix.relative(escapedCwd, result) : posix.normalize(result);
2017
+ const parentDirectoryMatch = PARENT_DIRECTORY.exec(result);
2018
+ const parts = splitPattern(result);
2019
+ if (null == parentDirectoryMatch ? void 0 : parentDirectoryMatch[0]) {
2020
+ const n = (parentDirectoryMatch[0].length + 1) / 3;
2021
+ let i = 0;
2022
+ const cwdParts = escapedCwd.split("/");
2023
+ while(i < n && parts[i + n] === cwdParts[cwdParts.length + i - n]){
2024
+ result = result.slice(0, (n - i - 1) * 3) + result.slice((n - i) * 3 + parts[i + n].length + 1) || ".";
2025
+ i++;
2026
+ }
2027
+ const potentialRoot = posix.join(cwd, parentDirectoryMatch[0].slice(3 * i));
2028
+ if (!potentialRoot.startsWith(".") && props.root.length > potentialRoot.length) {
2029
+ props.root = potentialRoot;
2030
+ props.depthOffset = -n + i;
2031
+ }
2032
+ }
2033
+ if (!isIgnore && props.depthOffset >= 0) {
2034
+ null != props.commonPath || (props.commonPath = parts);
2035
+ const newCommonPath = [];
2036
+ const length = Math.min(props.commonPath.length, parts.length);
2037
+ for(let i = 0; i < length; i++){
2038
+ const part = parts[i];
2039
+ if ("**" === part && !parts[i + 1]) {
2040
+ newCommonPath.pop();
2041
+ break;
2042
+ }
2043
+ if (part !== props.commonPath[i] || isDynamicPattern(part) || i === parts.length - 1) break;
2044
+ newCommonPath.push(part);
2045
+ }
2046
+ props.depthOffset = newCommonPath.length;
2047
+ props.commonPath = newCommonPath;
2048
+ props.root = newCommonPath.length > 0 ? posix.join(cwd, ...newCommonPath) : cwd;
2049
+ }
2050
+ return result;
2051
+ }
2052
+ function processPatterns({ patterns = [
2053
+ "**/*"
2054
+ ], ignore = [], expandDirectories = true }, cwd, props) {
2055
+ if ("string" == typeof patterns) patterns = [
2056
+ patterns
2057
+ ];
2058
+ if ("string" == typeof ignore) ignore = [
2059
+ ignore
2060
+ ];
2061
+ const matchPatterns = [];
2062
+ const ignorePatterns = [];
2063
+ for (const pattern of ignore)if (pattern) {
2064
+ if ("!" !== pattern[0] || "(" === pattern[1]) ignorePatterns.push(normalizePattern(pattern, expandDirectories, cwd, props, true));
2065
+ }
2066
+ for (const pattern of patterns)if (pattern) {
2067
+ if ("!" !== pattern[0] || "(" === pattern[1]) matchPatterns.push(normalizePattern(pattern, expandDirectories, cwd, props, false));
2068
+ else if ("!" !== pattern[1] || "(" === pattern[2]) ignorePatterns.push(normalizePattern(pattern.slice(1), expandDirectories, cwd, props, true));
2069
+ }
2070
+ return {
2071
+ match: matchPatterns,
2072
+ ignore: ignorePatterns
2073
+ };
2074
+ }
2075
+ function formatPaths(paths, relative) {
2076
+ for(let i = paths.length - 1; i >= 0; i--){
2077
+ const path$1 = paths[i];
2078
+ paths[i] = relative(path$1);
2079
+ }
2080
+ return paths;
2081
+ }
2082
+ function normalizeCwd(cwd) {
2083
+ if (!cwd) return process.cwd().replace(BACKSLASHES, "/");
2084
+ if (cwd instanceof URL) return fileURLToPath(cwd).replace(BACKSLASHES, "/");
2085
+ return path_0.resolve(cwd).replace(BACKSLASHES, "/");
2086
+ }
2087
+ function getCrawler(patterns, inputOptions = {}) {
2088
+ const options = process.env.TINYGLOBBY_DEBUG ? {
2089
+ ...inputOptions,
2090
+ debug: true
2091
+ } : inputOptions;
2092
+ const cwd = normalizeCwd(options.cwd);
2093
+ if (options.debug) log("globbing with:", {
2094
+ patterns,
2095
+ options,
2096
+ cwd
2097
+ });
2098
+ if (Array.isArray(patterns) && 0 === patterns.length) return [
2099
+ {
2100
+ sync: ()=>[],
2101
+ withPromise: async ()=>[]
2102
+ },
2103
+ false
2104
+ ];
2105
+ const props = {
2106
+ root: cwd,
2107
+ commonPath: null,
2108
+ depthOffset: 0
2109
+ };
2110
+ const processed = processPatterns({
2111
+ ...options,
2112
+ patterns
2113
+ }, cwd, props);
2114
+ if (options.debug) log("internal processing patterns:", processed);
2115
+ const matchOptions = {
2116
+ dot: options.dot,
2117
+ nobrace: false === options.braceExpansion,
2118
+ nocase: false === options.caseSensitiveMatch,
2119
+ noextglob: false === options.extglob,
2120
+ noglobstar: false === options.globstar,
2121
+ posix: true
2122
+ };
2123
+ const matcher = picomatch(processed.match, {
2124
+ ...matchOptions,
2125
+ ignore: processed.ignore
2126
+ });
2127
+ const ignore = picomatch(processed.ignore, matchOptions);
2128
+ const partialMatcher = getPartialMatcher(processed.match, matchOptions);
2129
+ const format = buildFormat(cwd, props.root, options.absolute);
2130
+ const formatExclude = options.absolute ? format : buildFormat(cwd, props.root, true);
2131
+ const fdirOptions = {
2132
+ filters: [
2133
+ options.debug ? (p, isDirectory)=>{
2134
+ const path$1 = format(p, isDirectory);
2135
+ const matches = matcher(path$1);
2136
+ if (matches) log(`matched ${path$1}`);
2137
+ return matches;
2138
+ } : (p, isDirectory)=>matcher(format(p, isDirectory))
2139
+ ],
2140
+ exclude: options.debug ? (_, p)=>{
2141
+ const relativePath = formatExclude(p, true);
2142
+ const skipped = "." !== relativePath && !partialMatcher(relativePath) || ignore(relativePath);
2143
+ skipped ? log(`skipped ${p}`) : log(`crawling ${p}`);
2144
+ return skipped;
2145
+ } : (_, p)=>{
2146
+ const relativePath = formatExclude(p, true);
2147
+ return "." !== relativePath && !partialMatcher(relativePath) || ignore(relativePath);
2148
+ },
2149
+ fs: options.fs ? {
2150
+ readdir: options.fs.readdir || fs_0.readdir,
2151
+ readdirSync: options.fs.readdirSync || fs_0.readdirSync,
2152
+ realpath: options.fs.realpath || fs_0.realpath,
2153
+ realpathSync: options.fs.realpathSync || fs_0.realpathSync,
2154
+ stat: options.fs.stat || fs_0.stat,
2155
+ statSync: options.fs.statSync || fs_0.statSync
2156
+ } : void 0,
2157
+ pathSeparator: "/",
2158
+ relativePaths: true,
2159
+ resolveSymlinks: true,
2160
+ signal: options.signal
2161
+ };
2162
+ if (void 0 !== options.deep) fdirOptions.maxDepth = Math.round(options.deep - props.depthOffset);
2163
+ if (options.absolute) {
2164
+ fdirOptions.relativePaths = false;
2165
+ fdirOptions.resolvePaths = true;
2166
+ fdirOptions.includeBasePath = true;
2167
+ }
2168
+ if (false === options.followSymbolicLinks) {
2169
+ fdirOptions.resolveSymlinks = false;
2170
+ fdirOptions.excludeSymlinks = true;
2171
+ }
2172
+ if (options.onlyDirectories) {
2173
+ fdirOptions.excludeFiles = true;
2174
+ fdirOptions.includeDirs = true;
2175
+ } else if (false === options.onlyFiles) fdirOptions.includeDirs = true;
2176
+ props.root = props.root.replace(BACKSLASHES, "");
2177
+ const root = props.root;
2178
+ if (options.debug) log("internal properties:", props);
2179
+ const relative = cwd !== root && !options.absolute && buildRelative(cwd, props.root);
2180
+ return [
2181
+ new Builder(fdirOptions).crawl(root),
2182
+ relative
2183
+ ];
2184
+ }
2185
+ async function glob(patternsOrOptions, options) {
2186
+ if (patternsOrOptions && (null == options ? void 0 : options.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
2187
+ const isModern = isReadonlyArray(patternsOrOptions) || "string" == typeof patternsOrOptions;
2188
+ const opts = isModern ? options : patternsOrOptions;
2189
+ const patterns = isModern ? patternsOrOptions : patternsOrOptions.patterns;
2190
+ const [crawler, relative] = getCrawler(patterns, opts);
2191
+ if (!relative) return crawler.withPromise();
2192
+ return formatPaths(await crawler.withPromise(), relative);
2193
+ }
2194
+ const index_js_namespaceObject = __rspack_createRequire_require("../compiled/tsconfig-paths/index.js");
2195
+ var comma = ",".charCodeAt(0);
2196
+ var semicolon = ";".charCodeAt(0);
2197
+ var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2198
+ var intToChar = new Uint8Array(64);
2199
+ var charToInt = new Uint8Array(128);
2200
+ for(let i = 0; i < chars.length; i++){
2201
+ const c = chars.charCodeAt(i);
2202
+ intToChar[i] = c;
2203
+ charToInt[c] = i;
2204
+ }
2205
+ function encodeInteger(builder, num, relative) {
2206
+ let delta = num - relative;
2207
+ delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
2208
+ do {
2209
+ let clamped = 31 & delta;
2210
+ delta >>>= 5;
2211
+ if (delta > 0) clamped |= 32;
2212
+ builder.write(intToChar[clamped]);
2213
+ }while (delta > 0);
2214
+ return num;
2215
+ }
2216
+ var bufLength = 16384;
2217
+ var td = "u" > typeof TextDecoder ? /* @__PURE__ */ new TextDecoder() : "u" > typeof Buffer ? {
2218
+ decode (buf) {
2219
+ const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
2220
+ return out.toString();
2221
+ }
2222
+ } : {
2223
+ decode (buf) {
2224
+ let out = "";
2225
+ for(let i = 0; i < buf.length; i++)out += String.fromCharCode(buf[i]);
2226
+ return out;
2227
+ }
2228
+ };
2229
+ var StringWriter = class {
2230
+ constructor(){
2231
+ this.pos = 0;
2232
+ this.out = "";
2233
+ this.buffer = new Uint8Array(bufLength);
2234
+ }
2235
+ write(v) {
2236
+ const { buffer } = this;
2237
+ buffer[this.pos++] = v;
2238
+ if (this.pos === bufLength) {
2239
+ this.out += td.decode(buffer);
2240
+ this.pos = 0;
2241
+ }
2242
+ }
2243
+ flush() {
2244
+ const { buffer, out, pos } = this;
2245
+ return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
2246
+ }
2247
+ };
2248
+ function encode(decoded) {
2249
+ const writer = new StringWriter();
2250
+ let sourcesIndex = 0;
2251
+ let sourceLine = 0;
2252
+ let sourceColumn = 0;
2253
+ let namesIndex = 0;
2254
+ for(let i = 0; i < decoded.length; i++){
2255
+ const line = decoded[i];
2256
+ if (i > 0) writer.write(semicolon);
2257
+ if (0 === line.length) continue;
2258
+ let genColumn = 0;
2259
+ for(let j = 0; j < line.length; j++){
2260
+ const segment = line[j];
2261
+ if (j > 0) writer.write(comma);
2262
+ genColumn = encodeInteger(writer, segment[0], genColumn);
2263
+ if (1 !== segment.length) {
2264
+ sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
2265
+ sourceLine = encodeInteger(writer, segment[2], sourceLine);
2266
+ sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
2267
+ if (4 !== segment.length) namesIndex = encodeInteger(writer, segment[4], namesIndex);
2268
+ }
2269
+ }
2270
+ }
2271
+ return writer.flush();
2272
+ }
2273
+ class BitSet {
2274
+ constructor(arg){
2275
+ this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
2276
+ }
2277
+ add(n) {
2278
+ this.bits[n >> 5] |= 1 << (31 & n);
2279
+ }
2280
+ has(n) {
2281
+ return !!(this.bits[n >> 5] & 1 << (31 & n));
2282
+ }
2283
+ }
2284
+ class Chunk {
2285
+ constructor(start, end, content){
2286
+ this.start = start;
2287
+ this.end = end;
2288
+ this.original = content;
2289
+ this.intro = '';
2290
+ this.outro = '';
2291
+ this.content = content;
2292
+ this.storeName = false;
2293
+ this.edited = false;
2294
+ this.previous = null;
2295
+ this.next = null;
2296
+ }
2297
+ appendLeft(content) {
2298
+ this.outro += content;
2299
+ }
2300
+ appendRight(content) {
2301
+ this.intro = this.intro + content;
2302
+ }
2303
+ clone() {
2304
+ const chunk = new Chunk(this.start, this.end, this.original);
2305
+ chunk.intro = this.intro;
2306
+ chunk.outro = this.outro;
2307
+ chunk.content = this.content;
2308
+ chunk.storeName = this.storeName;
2309
+ chunk.edited = this.edited;
2310
+ return chunk;
2311
+ }
2312
+ contains(index) {
2313
+ return this.start < index && index < this.end;
2314
+ }
2315
+ eachNext(fn) {
2316
+ let chunk = this;
2317
+ while(chunk){
2318
+ fn(chunk);
2319
+ chunk = chunk.next;
2320
+ }
2321
+ }
2322
+ eachPrevious(fn) {
2323
+ let chunk = this;
2324
+ while(chunk){
2325
+ fn(chunk);
2326
+ chunk = chunk.previous;
2327
+ }
2328
+ }
2329
+ edit(content, storeName, contentOnly) {
2330
+ this.content = content;
2331
+ if (!contentOnly) {
2332
+ this.intro = '';
2333
+ this.outro = '';
2334
+ }
2335
+ this.storeName = storeName;
2336
+ this.edited = true;
2337
+ return this;
2338
+ }
2339
+ prependLeft(content) {
2340
+ this.outro = content + this.outro;
2341
+ }
2342
+ prependRight(content) {
2343
+ this.intro = content + this.intro;
2344
+ }
2345
+ reset() {
2346
+ this.intro = '';
2347
+ this.outro = '';
2348
+ if (this.edited) {
2349
+ this.content = this.original;
2350
+ this.storeName = false;
2351
+ this.edited = false;
2352
+ }
2353
+ }
2354
+ split(index) {
2355
+ const sliceIndex = index - this.start;
2356
+ const originalBefore = this.original.slice(0, sliceIndex);
2357
+ const originalAfter = this.original.slice(sliceIndex);
2358
+ this.original = originalBefore;
2359
+ const newChunk = new Chunk(index, this.end, originalAfter);
2360
+ newChunk.outro = this.outro;
2361
+ this.outro = '';
2362
+ this.end = index;
2363
+ if (this.edited) {
2364
+ newChunk.edit('', false);
2365
+ this.content = '';
2366
+ } else this.content = originalBefore;
2367
+ newChunk.next = this.next;
2368
+ if (newChunk.next) newChunk.next.previous = newChunk;
2369
+ newChunk.previous = this;
2370
+ this.next = newChunk;
2371
+ return newChunk;
2372
+ }
2373
+ toString() {
2374
+ return this.intro + this.content + this.outro;
2375
+ }
2376
+ trimEnd(rx) {
2377
+ this.outro = this.outro.replace(rx, '');
2378
+ if (this.outro.length) return true;
2379
+ const trimmed = this.content.replace(rx, '');
2380
+ if (trimmed.length) {
2381
+ if (trimmed !== this.content) {
2382
+ this.split(this.start + trimmed.length).edit('', void 0, true);
2383
+ if (this.edited) this.edit(trimmed, this.storeName, true);
2384
+ }
2385
+ return true;
2386
+ }
2387
+ this.edit('', void 0, true);
2388
+ this.intro = this.intro.replace(rx, '');
2389
+ if (this.intro.length) return true;
2390
+ }
2391
+ trimStart(rx) {
2392
+ this.intro = this.intro.replace(rx, '');
2393
+ if (this.intro.length) return true;
2394
+ const trimmed = this.content.replace(rx, '');
2395
+ if (trimmed.length) {
2396
+ if (trimmed !== this.content) {
2397
+ const newChunk = this.split(this.end - trimmed.length);
2398
+ if (this.edited) newChunk.edit(trimmed, this.storeName, true);
2399
+ this.edit('', void 0, true);
2400
+ }
2401
+ return true;
2402
+ }
2403
+ this.edit('', void 0, true);
2404
+ this.outro = this.outro.replace(rx, '');
2405
+ if (this.outro.length) return true;
2406
+ }
2407
+ }
2408
+ function getBtoa() {
2409
+ if ("u" > typeof globalThis && 'function' == typeof globalThis.btoa) return (str)=>globalThis.btoa(unescape(encodeURIComponent(str)));
2410
+ if ('function' == typeof Buffer) return (str)=>Buffer.from(str, 'utf-8').toString('base64');
2411
+ return ()=>{
2412
+ throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
2413
+ };
2414
+ }
2415
+ const btoa = /*#__PURE__*/ getBtoa();
2416
+ class SourceMap {
2417
+ constructor(properties){
2418
+ this.version = 3;
2419
+ this.file = properties.file;
2420
+ this.sources = properties.sources;
2421
+ this.sourcesContent = properties.sourcesContent;
2422
+ this.names = properties.names;
2423
+ this.mappings = encode(properties.mappings);
2424
+ if (void 0 !== properties.x_google_ignoreList) this.x_google_ignoreList = properties.x_google_ignoreList;
2425
+ if (void 0 !== properties.debugId) this.debugId = properties.debugId;
2426
+ }
2427
+ toString() {
2428
+ return JSON.stringify(this);
2429
+ }
2430
+ toUrl() {
2431
+ return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
2432
+ }
2433
+ }
2434
+ function guessIndent(code) {
2435
+ const lines = code.split('\n');
2436
+ const tabbed = lines.filter((line)=>/^\t+/.test(line));
2437
+ const spaced = lines.filter((line)=>/^ {2,}/.test(line));
2438
+ if (0 === tabbed.length && 0 === spaced.length) return null;
2439
+ if (tabbed.length >= spaced.length) return '\t';
2440
+ const min = spaced.reduce((previous, current)=>{
2441
+ const numSpaces = /^ +/.exec(current)[0].length;
2442
+ return Math.min(numSpaces, previous);
2443
+ }, 1 / 0);
2444
+ return new Array(min + 1).join(' ');
2445
+ }
2446
+ function getRelativePath(from, to) {
2447
+ const fromParts = from.split(/[/\\]/);
2448
+ const toParts = to.split(/[/\\]/);
2449
+ fromParts.pop();
2450
+ while(fromParts[0] === toParts[0]){
2451
+ fromParts.shift();
2452
+ toParts.shift();
2453
+ }
2454
+ if (fromParts.length) {
2455
+ let i = fromParts.length;
2456
+ while(i--)fromParts[i] = '..';
2457
+ }
2458
+ return fromParts.concat(toParts).join('/');
2459
+ }
2460
+ const magic_string_es_toString = Object.prototype.toString;
2461
+ function isObject(thing) {
2462
+ return '[object Object]' === magic_string_es_toString.call(thing);
2463
+ }
2464
+ function getLocator(source) {
2465
+ const originalLines = source.split('\n');
2466
+ const lineOffsets = [];
2467
+ for(let i = 0, pos = 0; i < originalLines.length; i++){
2468
+ lineOffsets.push(pos);
2469
+ pos += originalLines[i].length + 1;
2470
+ }
2471
+ return function(index) {
2472
+ let i = 0;
2473
+ let j = lineOffsets.length;
2474
+ while(i < j){
2475
+ const m = i + j >> 1;
2476
+ if (index < lineOffsets[m]) j = m;
2477
+ else i = m + 1;
2478
+ }
2479
+ const line = i - 1;
2480
+ const column = index - lineOffsets[line];
2481
+ return {
2482
+ line,
2483
+ column
2484
+ };
2485
+ };
2486
+ }
2487
+ const wordRegex = /\w/;
2488
+ class Mappings {
2489
+ constructor(hires){
2490
+ this.hires = hires;
2491
+ this.generatedCodeLine = 0;
2492
+ this.generatedCodeColumn = 0;
2493
+ this.raw = [];
2494
+ this.rawSegments = this.raw[this.generatedCodeLine] = [];
2495
+ this.pending = null;
2496
+ }
2497
+ addEdit(sourceIndex, content, loc, nameIndex) {
2498
+ if (content.length) {
2499
+ const contentLengthMinusOne = content.length - 1;
2500
+ let contentLineEnd = content.indexOf('\n', 0);
2501
+ let previousContentLineEnd = -1;
2502
+ while(contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd){
2503
+ const segment = [
2504
+ this.generatedCodeColumn,
2505
+ sourceIndex,
2506
+ loc.line,
2507
+ loc.column
2508
+ ];
2509
+ if (nameIndex >= 0) segment.push(nameIndex);
2510
+ this.rawSegments.push(segment);
2511
+ this.generatedCodeLine += 1;
2512
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
2513
+ this.generatedCodeColumn = 0;
2514
+ previousContentLineEnd = contentLineEnd;
2515
+ contentLineEnd = content.indexOf('\n', contentLineEnd + 1);
2516
+ }
2517
+ const segment = [
2518
+ this.generatedCodeColumn,
2519
+ sourceIndex,
2520
+ loc.line,
2521
+ loc.column
2522
+ ];
2523
+ if (nameIndex >= 0) segment.push(nameIndex);
2524
+ this.rawSegments.push(segment);
2525
+ this.advance(content.slice(previousContentLineEnd + 1));
2526
+ } else if (this.pending) {
2527
+ this.rawSegments.push(this.pending);
2528
+ this.advance(content);
2529
+ }
2530
+ this.pending = null;
2531
+ }
2532
+ addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
2533
+ let originalCharIndex = chunk.start;
2534
+ let first = true;
2535
+ let charInHiresBoundary = false;
2536
+ while(originalCharIndex < chunk.end){
2537
+ if ('\n' === original[originalCharIndex]) {
2538
+ loc.line += 1;
2539
+ loc.column = 0;
2540
+ this.generatedCodeLine += 1;
2541
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
2542
+ this.generatedCodeColumn = 0;
2543
+ first = true;
2544
+ charInHiresBoundary = false;
2545
+ } else {
2546
+ if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
2547
+ const segment = [
2548
+ this.generatedCodeColumn,
2549
+ sourceIndex,
2550
+ loc.line,
2551
+ loc.column
2552
+ ];
2553
+ if ('boundary' === this.hires) if (wordRegex.test(original[originalCharIndex])) {
2554
+ if (!charInHiresBoundary) {
2555
+ this.rawSegments.push(segment);
2556
+ charInHiresBoundary = true;
2557
+ }
2558
+ } else {
2559
+ this.rawSegments.push(segment);
2560
+ charInHiresBoundary = false;
2561
+ }
2562
+ else this.rawSegments.push(segment);
2563
+ }
2564
+ loc.column += 1;
2565
+ this.generatedCodeColumn += 1;
2566
+ first = false;
2567
+ }
2568
+ originalCharIndex += 1;
2569
+ }
2570
+ this.pending = null;
2571
+ }
2572
+ advance(str) {
2573
+ if (!str) return;
2574
+ const lines = str.split('\n');
2575
+ if (lines.length > 1) {
2576
+ for(let i = 0; i < lines.length - 1; i++){
2577
+ this.generatedCodeLine++;
2578
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
2579
+ }
2580
+ this.generatedCodeColumn = 0;
2581
+ }
2582
+ this.generatedCodeColumn += lines[lines.length - 1].length;
2583
+ }
2584
+ }
2585
+ const magic_string_es_n = '\n';
2586
+ const warned = {
2587
+ insertLeft: false,
2588
+ insertRight: false,
2589
+ storeName: false
2590
+ };
2591
+ class MagicString {
2592
+ constructor(string, options = {}){
2593
+ const chunk = new Chunk(0, string.length, string);
2594
+ Object.defineProperties(this, {
2595
+ original: {
2596
+ writable: true,
2597
+ value: string
2598
+ },
2599
+ outro: {
2600
+ writable: true,
2601
+ value: ''
2602
+ },
2603
+ intro: {
2604
+ writable: true,
2605
+ value: ''
2606
+ },
2607
+ firstChunk: {
2608
+ writable: true,
2609
+ value: chunk
2610
+ },
2611
+ lastChunk: {
2612
+ writable: true,
2613
+ value: chunk
2614
+ },
2615
+ lastSearchedChunk: {
2616
+ writable: true,
2617
+ value: chunk
2618
+ },
2619
+ byStart: {
2620
+ writable: true,
2621
+ value: {}
2622
+ },
2623
+ byEnd: {
2624
+ writable: true,
2625
+ value: {}
2626
+ },
2627
+ filename: {
2628
+ writable: true,
2629
+ value: options.filename
2630
+ },
2631
+ indentExclusionRanges: {
2632
+ writable: true,
2633
+ value: options.indentExclusionRanges
2634
+ },
2635
+ sourcemapLocations: {
2636
+ writable: true,
2637
+ value: new BitSet()
2638
+ },
2639
+ storedNames: {
2640
+ writable: true,
2641
+ value: {}
2642
+ },
2643
+ indentStr: {
2644
+ writable: true,
2645
+ value: void 0
2646
+ },
2647
+ ignoreList: {
2648
+ writable: true,
2649
+ value: options.ignoreList
2650
+ },
2651
+ offset: {
2652
+ writable: true,
2653
+ value: options.offset || 0
2654
+ }
2655
+ });
2656
+ this.byStart[0] = chunk;
2657
+ this.byEnd[string.length] = chunk;
2658
+ }
2659
+ addSourcemapLocation(char) {
2660
+ this.sourcemapLocations.add(char);
2661
+ }
2662
+ append(content) {
2663
+ if ('string' != typeof content) throw new TypeError('outro content must be a string');
2664
+ this.outro += content;
2665
+ return this;
2666
+ }
2667
+ appendLeft(index, content) {
2668
+ index += this.offset;
2669
+ if ('string' != typeof content) throw new TypeError('inserted content must be a string');
2670
+ this._split(index);
2671
+ const chunk = this.byEnd[index];
2672
+ if (chunk) chunk.appendLeft(content);
2673
+ else this.intro += content;
2674
+ return this;
2675
+ }
2676
+ appendRight(index, content) {
2677
+ index += this.offset;
2678
+ if ('string' != typeof content) throw new TypeError('inserted content must be a string');
2679
+ this._split(index);
2680
+ const chunk = this.byStart[index];
2681
+ if (chunk) chunk.appendRight(content);
2682
+ else this.outro += content;
2683
+ return this;
2684
+ }
2685
+ clone() {
2686
+ const cloned = new MagicString(this.original, {
2687
+ filename: this.filename,
2688
+ offset: this.offset
2689
+ });
2690
+ let originalChunk = this.firstChunk;
2691
+ let clonedChunk = cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone();
2692
+ while(originalChunk){
2693
+ cloned.byStart[clonedChunk.start] = clonedChunk;
2694
+ cloned.byEnd[clonedChunk.end] = clonedChunk;
2695
+ const nextOriginalChunk = originalChunk.next;
2696
+ const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
2697
+ if (nextClonedChunk) {
2698
+ clonedChunk.next = nextClonedChunk;
2699
+ nextClonedChunk.previous = clonedChunk;
2700
+ clonedChunk = nextClonedChunk;
2701
+ }
2702
+ originalChunk = nextOriginalChunk;
2703
+ }
2704
+ cloned.lastChunk = clonedChunk;
2705
+ if (this.indentExclusionRanges) cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
2706
+ cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
2707
+ cloned.intro = this.intro;
2708
+ cloned.outro = this.outro;
2709
+ return cloned;
2710
+ }
2711
+ generateDecodedMap(options) {
2712
+ options = options || {};
2713
+ const sourceIndex = 0;
2714
+ const names = Object.keys(this.storedNames);
2715
+ const mappings = new Mappings(options.hires);
2716
+ const locate = getLocator(this.original);
2717
+ if (this.intro) mappings.advance(this.intro);
2718
+ this.firstChunk.eachNext((chunk)=>{
2719
+ const loc = locate(chunk.start);
2720
+ if (chunk.intro.length) mappings.advance(chunk.intro);
2721
+ if (chunk.edited) mappings.addEdit(sourceIndex, chunk.content, loc, chunk.storeName ? names.indexOf(chunk.original) : -1);
2722
+ else mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
2723
+ if (chunk.outro.length) mappings.advance(chunk.outro);
2724
+ });
2725
+ if (this.outro) mappings.advance(this.outro);
2726
+ return {
2727
+ file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
2728
+ sources: [
2729
+ options.source ? getRelativePath(options.file || '', options.source) : options.file || ''
2730
+ ],
2731
+ sourcesContent: options.includeContent ? [
2732
+ this.original
2733
+ ] : void 0,
2734
+ names,
2735
+ mappings: mappings.raw,
2736
+ x_google_ignoreList: this.ignoreList ? [
2737
+ sourceIndex
2738
+ ] : void 0
2739
+ };
2740
+ }
2741
+ generateMap(options) {
2742
+ return new SourceMap(this.generateDecodedMap(options));
2743
+ }
2744
+ _ensureindentStr() {
2745
+ if (void 0 === this.indentStr) this.indentStr = guessIndent(this.original);
2746
+ }
2747
+ _getRawIndentString() {
2748
+ this._ensureindentStr();
2749
+ return this.indentStr;
2750
+ }
2751
+ getIndentString() {
2752
+ this._ensureindentStr();
2753
+ return null === this.indentStr ? '\t' : this.indentStr;
2754
+ }
2755
+ indent(indentStr, options) {
2756
+ const pattern = /^[^\r\n]/gm;
2757
+ if (isObject(indentStr)) {
2758
+ options = indentStr;
2759
+ indentStr = void 0;
2760
+ }
2761
+ if (void 0 === indentStr) {
2762
+ this._ensureindentStr();
2763
+ indentStr = this.indentStr || '\t';
2764
+ }
2765
+ if ('' === indentStr) return this;
2766
+ options = options || {};
2767
+ const isExcluded = {};
2768
+ if (options.exclude) {
2769
+ const exclusions = 'number' == typeof options.exclude[0] ? [
2770
+ options.exclude
2771
+ ] : options.exclude;
2772
+ exclusions.forEach((exclusion)=>{
2773
+ for(let i = exclusion[0]; i < exclusion[1]; i += 1)isExcluded[i] = true;
2774
+ });
2775
+ }
2776
+ let shouldIndentNextCharacter = false !== options.indentStart;
2777
+ const replacer = (match)=>{
2778
+ if (shouldIndentNextCharacter) return `${indentStr}${match}`;
2779
+ shouldIndentNextCharacter = true;
2780
+ return match;
2781
+ };
2782
+ this.intro = this.intro.replace(pattern, replacer);
2783
+ let charIndex = 0;
2784
+ let chunk = this.firstChunk;
2785
+ while(chunk){
2786
+ const end = chunk.end;
2787
+ if (chunk.edited) {
2788
+ if (!isExcluded[charIndex]) {
2789
+ chunk.content = chunk.content.replace(pattern, replacer);
2790
+ if (chunk.content.length) shouldIndentNextCharacter = '\n' === chunk.content[chunk.content.length - 1];
2791
+ }
2792
+ } else {
2793
+ charIndex = chunk.start;
2794
+ while(charIndex < end){
2795
+ if (!isExcluded[charIndex]) {
2796
+ const char = this.original[charIndex];
2797
+ if ('\n' === char) shouldIndentNextCharacter = true;
2798
+ else if ('\r' !== char && shouldIndentNextCharacter) {
2799
+ shouldIndentNextCharacter = false;
2800
+ if (charIndex === chunk.start) chunk.prependRight(indentStr);
2801
+ else {
2802
+ this._splitChunk(chunk, charIndex);
2803
+ chunk = chunk.next;
2804
+ chunk.prependRight(indentStr);
2805
+ }
2806
+ }
2807
+ }
2808
+ charIndex += 1;
2809
+ }
2810
+ }
2811
+ charIndex = chunk.end;
2812
+ chunk = chunk.next;
2813
+ }
2814
+ this.outro = this.outro.replace(pattern, replacer);
2815
+ return this;
2816
+ }
2817
+ insert() {
2818
+ throw new Error('magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)');
2819
+ }
2820
+ insertLeft(index, content) {
2821
+ if (!warned.insertLeft) {
2822
+ console.warn('magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead');
2823
+ warned.insertLeft = true;
2824
+ }
2825
+ return this.appendLeft(index, content);
2826
+ }
2827
+ insertRight(index, content) {
2828
+ if (!warned.insertRight) {
2829
+ console.warn('magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead');
2830
+ warned.insertRight = true;
2831
+ }
2832
+ return this.prependRight(index, content);
2833
+ }
2834
+ move(start, end, index) {
2835
+ start += this.offset;
2836
+ end += this.offset;
2837
+ index += this.offset;
2838
+ if (index >= start && index <= end) throw new Error('Cannot move a selection inside itself');
2839
+ this._split(start);
2840
+ this._split(end);
2841
+ this._split(index);
2842
+ const first = this.byStart[start];
2843
+ const last = this.byEnd[end];
2844
+ const oldLeft = first.previous;
2845
+ const oldRight = last.next;
2846
+ const newRight = this.byStart[index];
2847
+ if (!newRight && last === this.lastChunk) return this;
2848
+ const newLeft = newRight ? newRight.previous : this.lastChunk;
2849
+ if (oldLeft) oldLeft.next = oldRight;
2850
+ if (oldRight) oldRight.previous = oldLeft;
2851
+ if (newLeft) newLeft.next = first;
2852
+ if (newRight) newRight.previous = last;
2853
+ if (!first.previous) this.firstChunk = last.next;
2854
+ if (!last.next) {
2855
+ this.lastChunk = first.previous;
2856
+ this.lastChunk.next = null;
2857
+ }
2858
+ first.previous = newLeft;
2859
+ last.next = newRight || null;
2860
+ if (!newLeft) this.firstChunk = first;
2861
+ if (!newRight) this.lastChunk = last;
2862
+ return this;
2863
+ }
2864
+ overwrite(start, end, content, options) {
2865
+ options = options || {};
2866
+ return this.update(start, end, content, {
2867
+ ...options,
2868
+ overwrite: !options.contentOnly
2869
+ });
2870
+ }
2871
+ update(start, end, content, options) {
2872
+ start += this.offset;
2873
+ end += this.offset;
2874
+ if ('string' != typeof content) throw new TypeError('replacement content must be a string');
2875
+ if (0 !== this.original.length) {
2876
+ while(start < 0)start += this.original.length;
2877
+ while(end < 0)end += this.original.length;
2878
+ }
2879
+ if (end > this.original.length) throw new Error('end is out of bounds');
2880
+ if (start === end) throw new Error('Cannot overwrite a zero-length range – use appendLeft or prependRight instead');
2881
+ this._split(start);
2882
+ this._split(end);
2883
+ if (true === options) {
2884
+ if (!warned.storeName) {
2885
+ console.warn('The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string');
2886
+ warned.storeName = true;
2887
+ }
2888
+ options = {
2889
+ storeName: true
2890
+ };
2891
+ }
2892
+ const storeName = void 0 !== options ? options.storeName : false;
2893
+ const overwrite = void 0 !== options ? options.overwrite : false;
2894
+ if (storeName) {
2895
+ const original = this.original.slice(start, end);
2896
+ Object.defineProperty(this.storedNames, original, {
2897
+ writable: true,
2898
+ value: true,
2899
+ enumerable: true
2900
+ });
2901
+ }
2902
+ const first = this.byStart[start];
2903
+ const last = this.byEnd[end];
2904
+ if (first) {
2905
+ let chunk = first;
2906
+ while(chunk !== last){
2907
+ if (chunk.next !== this.byStart[chunk.end]) throw new Error('Cannot overwrite across a split point');
2908
+ chunk = chunk.next;
2909
+ chunk.edit('', false);
2910
+ }
2911
+ first.edit(content, storeName, !overwrite);
2912
+ } else {
2913
+ const newChunk = new Chunk(start, end, '').edit(content, storeName);
2914
+ last.next = newChunk;
2915
+ newChunk.previous = last;
2916
+ }
2917
+ return this;
2918
+ }
2919
+ prepend(content) {
2920
+ if ('string' != typeof content) throw new TypeError('outro content must be a string');
2921
+ this.intro = content + this.intro;
2922
+ return this;
2923
+ }
2924
+ prependLeft(index, content) {
2925
+ index += this.offset;
2926
+ if ('string' != typeof content) throw new TypeError('inserted content must be a string');
2927
+ this._split(index);
2928
+ const chunk = this.byEnd[index];
2929
+ if (chunk) chunk.prependLeft(content);
2930
+ else this.intro = content + this.intro;
2931
+ return this;
2932
+ }
2933
+ prependRight(index, content) {
2934
+ index += this.offset;
2935
+ if ('string' != typeof content) throw new TypeError('inserted content must be a string');
2936
+ this._split(index);
2937
+ const chunk = this.byStart[index];
2938
+ if (chunk) chunk.prependRight(content);
2939
+ else this.outro = content + this.outro;
2940
+ return this;
2941
+ }
2942
+ remove(start, end) {
2943
+ start += this.offset;
2944
+ end += this.offset;
2945
+ if (0 !== this.original.length) {
2946
+ while(start < 0)start += this.original.length;
2947
+ while(end < 0)end += this.original.length;
2948
+ }
2949
+ if (start === end) return this;
2950
+ if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
2951
+ if (start > end) throw new Error('end must be greater than start');
2952
+ this._split(start);
2953
+ this._split(end);
2954
+ let chunk = this.byStart[start];
2955
+ while(chunk){
2956
+ chunk.intro = '';
2957
+ chunk.outro = '';
2958
+ chunk.edit('');
2959
+ chunk = end > chunk.end ? this.byStart[chunk.end] : null;
2960
+ }
2961
+ return this;
2962
+ }
2963
+ reset(start, end) {
2964
+ start += this.offset;
2965
+ end += this.offset;
2966
+ if (0 !== this.original.length) {
2967
+ while(start < 0)start += this.original.length;
2968
+ while(end < 0)end += this.original.length;
2969
+ }
2970
+ if (start === end) return this;
2971
+ if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
2972
+ if (start > end) throw new Error('end must be greater than start');
2973
+ this._split(start);
2974
+ this._split(end);
2975
+ let chunk = this.byStart[start];
2976
+ while(chunk){
2977
+ chunk.reset();
2978
+ chunk = end > chunk.end ? this.byStart[chunk.end] : null;
2979
+ }
2980
+ return this;
2981
+ }
2982
+ lastChar() {
2983
+ if (this.outro.length) return this.outro[this.outro.length - 1];
2984
+ let chunk = this.lastChunk;
2985
+ do {
2986
+ if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
2987
+ if (chunk.content.length) return chunk.content[chunk.content.length - 1];
2988
+ if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
2989
+ }while (chunk = chunk.previous);
2990
+ if (this.intro.length) return this.intro[this.intro.length - 1];
2991
+ return '';
2992
+ }
2993
+ lastLine() {
2994
+ let lineIndex = this.outro.lastIndexOf(magic_string_es_n);
2995
+ if (-1 !== lineIndex) return this.outro.substr(lineIndex + 1);
2996
+ let lineStr = this.outro;
2997
+ let chunk = this.lastChunk;
2998
+ do {
2999
+ if (chunk.outro.length > 0) {
3000
+ lineIndex = chunk.outro.lastIndexOf(magic_string_es_n);
3001
+ if (-1 !== lineIndex) return chunk.outro.substr(lineIndex + 1) + lineStr;
3002
+ lineStr = chunk.outro + lineStr;
3003
+ }
3004
+ if (chunk.content.length > 0) {
3005
+ lineIndex = chunk.content.lastIndexOf(magic_string_es_n);
3006
+ if (-1 !== lineIndex) return chunk.content.substr(lineIndex + 1) + lineStr;
3007
+ lineStr = chunk.content + lineStr;
3008
+ }
3009
+ if (chunk.intro.length > 0) {
3010
+ lineIndex = chunk.intro.lastIndexOf(magic_string_es_n);
3011
+ if (-1 !== lineIndex) return chunk.intro.substr(lineIndex + 1) + lineStr;
3012
+ lineStr = chunk.intro + lineStr;
3013
+ }
3014
+ }while (chunk = chunk.previous);
3015
+ lineIndex = this.intro.lastIndexOf(magic_string_es_n);
3016
+ if (-1 !== lineIndex) return this.intro.substr(lineIndex + 1) + lineStr;
3017
+ return this.intro + lineStr;
3018
+ }
3019
+ slice(start = 0, end = this.original.length - this.offset) {
3020
+ start += this.offset;
3021
+ end += this.offset;
3022
+ if (0 !== this.original.length) {
3023
+ while(start < 0)start += this.original.length;
3024
+ while(end < 0)end += this.original.length;
3025
+ }
3026
+ let result = '';
3027
+ let chunk = this.firstChunk;
3028
+ while(chunk && (chunk.start > start || chunk.end <= start)){
3029
+ if (chunk.start < end && chunk.end >= end) return result;
3030
+ chunk = chunk.next;
3031
+ }
3032
+ if (chunk && chunk.edited && chunk.start !== start) throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
3033
+ const startChunk = chunk;
3034
+ while(chunk){
3035
+ if (chunk.intro && (startChunk !== chunk || chunk.start === start)) result += chunk.intro;
3036
+ const containsEnd = chunk.start < end && chunk.end >= end;
3037
+ if (containsEnd && chunk.edited && chunk.end !== end) throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
3038
+ const sliceStart = startChunk === chunk ? start - chunk.start : 0;
3039
+ const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
3040
+ result += chunk.content.slice(sliceStart, sliceEnd);
3041
+ if (chunk.outro && (!containsEnd || chunk.end === end)) result += chunk.outro;
3042
+ if (containsEnd) break;
3043
+ chunk = chunk.next;
3044
+ }
3045
+ return result;
3046
+ }
3047
+ snip(start, end) {
3048
+ const clone = this.clone();
3049
+ clone.remove(0, start);
3050
+ clone.remove(end, clone.original.length);
3051
+ return clone;
3052
+ }
3053
+ _split(index) {
3054
+ if (this.byStart[index] || this.byEnd[index]) return;
3055
+ let chunk = this.lastSearchedChunk;
3056
+ let previousChunk = chunk;
3057
+ const searchForward = index > chunk.end;
3058
+ while(chunk){
3059
+ if (chunk.contains(index)) return this._splitChunk(chunk, index);
3060
+ chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
3061
+ if (chunk === previousChunk) return;
3062
+ previousChunk = chunk;
3063
+ }
3064
+ }
3065
+ _splitChunk(chunk, index) {
3066
+ if (chunk.edited && chunk.content.length) {
3067
+ const loc = getLocator(this.original)(index);
3068
+ throw new Error(`Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`);
3069
+ }
3070
+ const newChunk = chunk.split(index);
3071
+ this.byEnd[index] = chunk;
3072
+ this.byStart[index] = newChunk;
3073
+ this.byEnd[newChunk.end] = newChunk;
3074
+ if (chunk === this.lastChunk) this.lastChunk = newChunk;
3075
+ this.lastSearchedChunk = chunk;
3076
+ return true;
3077
+ }
3078
+ toString() {
3079
+ let str = this.intro;
3080
+ let chunk = this.firstChunk;
3081
+ while(chunk){
3082
+ str += chunk.toString();
3083
+ chunk = chunk.next;
3084
+ }
3085
+ return str + this.outro;
3086
+ }
3087
+ isEmpty() {
3088
+ let chunk = this.firstChunk;
3089
+ do if (chunk.intro.length && chunk.intro.trim() || chunk.content.length && chunk.content.trim() || chunk.outro.length && chunk.outro.trim()) return false;
3090
+ while (chunk = chunk.next);
3091
+ return true;
3092
+ }
3093
+ length() {
3094
+ let chunk = this.firstChunk;
3095
+ let length = 0;
3096
+ do length += chunk.intro.length + chunk.content.length + chunk.outro.length;
3097
+ while (chunk = chunk.next);
3098
+ return length;
3099
+ }
3100
+ trimLines() {
3101
+ return this.trim('[\\r\\n]');
3102
+ }
3103
+ trim(charType) {
3104
+ return this.trimStart(charType).trimEnd(charType);
3105
+ }
3106
+ trimEndAborted(charType) {
3107
+ const rx = new RegExp((charType || '\\s') + '+$');
3108
+ this.outro = this.outro.replace(rx, '');
3109
+ if (this.outro.length) return true;
3110
+ let chunk = this.lastChunk;
3111
+ do {
3112
+ const end = chunk.end;
3113
+ const aborted = chunk.trimEnd(rx);
3114
+ if (chunk.end !== end) {
3115
+ if (this.lastChunk === chunk) this.lastChunk = chunk.next;
3116
+ this.byEnd[chunk.end] = chunk;
3117
+ this.byStart[chunk.next.start] = chunk.next;
3118
+ this.byEnd[chunk.next.end] = chunk.next;
3119
+ }
3120
+ if (aborted) return true;
3121
+ chunk = chunk.previous;
3122
+ }while (chunk);
3123
+ return false;
3124
+ }
3125
+ trimEnd(charType) {
3126
+ this.trimEndAborted(charType);
3127
+ return this;
3128
+ }
3129
+ trimStartAborted(charType) {
3130
+ const rx = new RegExp('^' + (charType || '\\s') + '+');
3131
+ this.intro = this.intro.replace(rx, '');
3132
+ if (this.intro.length) return true;
3133
+ let chunk = this.firstChunk;
3134
+ do {
3135
+ const end = chunk.end;
3136
+ const aborted = chunk.trimStart(rx);
3137
+ if (chunk.end !== end) {
3138
+ if (chunk === this.lastChunk) this.lastChunk = chunk.next;
3139
+ this.byEnd[chunk.end] = chunk;
3140
+ this.byStart[chunk.next.start] = chunk.next;
3141
+ this.byEnd[chunk.next.end] = chunk.next;
3142
+ }
3143
+ if (aborted) return true;
3144
+ chunk = chunk.next;
3145
+ }while (chunk);
3146
+ return false;
3147
+ }
3148
+ trimStart(charType) {
3149
+ this.trimStartAborted(charType);
3150
+ return this;
3151
+ }
3152
+ hasChanged() {
3153
+ return this.original !== this.toString();
3154
+ }
3155
+ _replaceRegexp(searchValue, replacement) {
3156
+ function getReplacement(match, str) {
3157
+ if ('string' == typeof replacement) return replacement.replace(/\$(\$|&|\d+)/g, (_, i)=>{
3158
+ if ('$' === i) return '$';
3159
+ if ('&' === i) return match[0];
3160
+ const num = +i;
3161
+ if (num < match.length) return match[+i];
3162
+ return `$${i}`;
3163
+ });
3164
+ return replacement(...match, match.index, str, match.groups);
3165
+ }
3166
+ function matchAll(re, str) {
3167
+ let match;
3168
+ const matches = [];
3169
+ while(match = re.exec(str))matches.push(match);
3170
+ return matches;
3171
+ }
3172
+ if (searchValue.global) {
3173
+ const matches = matchAll(searchValue, this.original);
3174
+ matches.forEach((match)=>{
3175
+ if (null != match.index) {
3176
+ const replacement = getReplacement(match, this.original);
3177
+ if (replacement !== match[0]) this.overwrite(match.index, match.index + match[0].length, replacement);
3178
+ }
3179
+ });
3180
+ } else {
3181
+ const match = this.original.match(searchValue);
3182
+ if (match && null != match.index) {
3183
+ const replacement = getReplacement(match, this.original);
3184
+ if (replacement !== match[0]) this.overwrite(match.index, match.index + match[0].length, replacement);
3185
+ }
3186
+ }
3187
+ return this;
3188
+ }
3189
+ _replaceString(string, replacement) {
3190
+ const { original } = this;
3191
+ const index = original.indexOf(string);
3192
+ if (-1 !== index) {
3193
+ if ('function' == typeof replacement) replacement = replacement(string, index, original);
3194
+ if (string !== replacement) this.overwrite(index, index + string.length, replacement);
3195
+ }
3196
+ return this;
3197
+ }
3198
+ replace(searchValue, replacement) {
3199
+ if ('string' == typeof searchValue) return this._replaceString(searchValue, replacement);
3200
+ return this._replaceRegexp(searchValue, replacement);
3201
+ }
3202
+ _replaceAllString(string, replacement) {
3203
+ const { original } = this;
3204
+ const stringLength = string.length;
3205
+ for(let index = original.indexOf(string); -1 !== index; index = original.indexOf(string, index + stringLength)){
3206
+ const previous = original.slice(index, index + stringLength);
3207
+ let _replacement = replacement;
3208
+ if ('function' == typeof replacement) _replacement = replacement(previous, index, original);
3209
+ if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
3210
+ }
3211
+ return this;
3212
+ }
3213
+ replaceAll(searchValue, replacement) {
3214
+ if ('string' == typeof searchValue) return this._replaceAllString(searchValue, replacement);
3215
+ if (!searchValue.global) throw new TypeError('MagicString.prototype.replaceAll called with a non-global RegExp argument');
3216
+ return this._replaceRegexp(searchValue, replacement);
3217
+ }
3218
+ }
3219
+ Object.prototype.hasOwnProperty;
3220
+ const utils_require = createRequire(import.meta.url);
3221
+ let astGrepNapi;
3222
+ const loadAstGrepNapi = ()=>{
3223
+ if (!astGrepNapi) astGrepNapi = utils_require('@ast-grep/napi');
3224
+ return astGrepNapi;
3225
+ };
3226
+ const ts = utils_require("typescript");
3227
+ const createStyler = (style)=>(text)=>styleText(style, String(text));
3228
+ const color = {
3229
+ bold: createStyler('bold'),
3230
+ cyan: createStyler('cyan'),
3231
+ dim: createStyler('dim'),
3232
+ reset: createStyler('reset'),
3233
+ underline: createStyler('underline'),
3234
+ yellow: createStyler('yellow')
3235
+ };
3236
+ const JS_EXTENSIONS = [
3237
+ 'js',
3238
+ 'mjs',
3239
+ 'jsx',
3240
+ '(?<!\\.d\\.)ts',
3241
+ '(?<!\\.d\\.)mts',
3242
+ '(?<!\\.d\\.)cts',
3243
+ 'tsx',
3244
+ 'cjs',
3245
+ 'cjsx',
3246
+ 'mjsx',
3247
+ 'mtsx',
3248
+ 'ctsx'
3249
+ ];
3250
+ const JS_EXTENSIONS_PATTERN = new RegExp(`\\.(${JS_EXTENSIONS.join('|')})$`);
3251
+ function loadTsconfig(tsconfigPath) {
3252
+ const configFile = ts.readConfigFile(tsconfigPath, ts.sys.readFile.bind(ts.sys));
3253
+ const configFileContent = ts.parseJsonConfigFileContent(configFile.config, ts.sys, node_path.dirname(tsconfigPath));
3254
+ return configFileContent;
3255
+ }
3256
+ function mergeAliasWithTsConfigPaths(paths, alias = {}) {
3257
+ const mergedPaths = {};
3258
+ if (alias && 'object' == typeof alias && Object.keys(alias).length > 0) {
3259
+ for (const [key, value] of Object.entries(alias))if ('string' == typeof value && value.trim()) mergedPaths[key] = [
3260
+ value
3261
+ ];
3262
+ }
3263
+ if (paths) {
3264
+ for (const [key, value] of Object.entries(paths))if (Array.isArray(value) && value.length > 0) {
3265
+ if (!mergedPaths[key]) mergedPaths[key] = [
3266
+ ...value
3267
+ ];
3268
+ }
3269
+ }
3270
+ return Object.keys(mergedPaths).length > 0 ? mergedPaths : {};
3271
+ }
3272
+ const TEMP_FOLDER = '.rslib';
3273
+ const TEMP_DTS_DIR = `${TEMP_FOLDER}/declarations`;
3274
+ function ensureTempDeclarationDir(cwd, name) {
3275
+ const dirPath = node_path.join(cwd, TEMP_DTS_DIR, name);
3276
+ if (node_fs.existsSync(dirPath)) return dirPath;
3277
+ node_fs.mkdirSync(dirPath, {
3278
+ recursive: true
3279
+ });
3280
+ const gitIgnorePath = node_path.join(cwd, TEMP_FOLDER, '.gitignore');
3281
+ node_fs.writeFileSync(gitIgnorePath, '**/*\n');
3282
+ return dirPath;
3283
+ }
3284
+ async function pathExists(path) {
3285
+ return node_fs.promises.access(path).then(()=>true).catch(()=>false);
3286
+ }
3287
+ async function utils_isDirectory(filePath) {
3288
+ try {
3289
+ const stat = await promises.stat(filePath);
3290
+ return stat.isDirectory();
3291
+ } catch {
3292
+ return false;
3293
+ }
3294
+ }
3295
+ async function emptyDir(dir) {
3296
+ if (!await pathExists(dir)) return;
3297
+ try {
3298
+ for (const file of (await node_fs.promises.readdir(dir)))await node_fs.promises.rm(node_path.resolve(dir, file), {
3299
+ recursive: true,
3300
+ force: true
3301
+ });
3302
+ } catch (err) {
3303
+ logger.warn(`Failed to empty dir: ${dir}`);
3304
+ logger.warn(err);
3305
+ }
3306
+ }
3307
+ async function clearTempDeclarationDir(cwd) {
3308
+ const dirPath = node_path.join(cwd, TEMP_DTS_DIR);
3309
+ await emptyDir(dirPath);
3310
+ }
3311
+ const prettyTime = (seconds)=>{
3312
+ const format = (time)=>color.bold(time);
3313
+ if (seconds < 10) {
3314
+ const digits = seconds >= 0.01 ? 2 : 3;
3315
+ return `${format(seconds.toFixed(digits))} s`;
3316
+ }
3317
+ if (seconds < 60) return `${format(seconds.toFixed(1))} s`;
3318
+ const minutes = Math.floor(seconds / 60);
3319
+ const minutesLabel = `${format(minutes.toFixed(0))} m`;
3320
+ const remainingSeconds = seconds % 60;
3321
+ if (0 === remainingSeconds) return minutesLabel;
3322
+ const secondsLabel = `${format(remainingSeconds.toFixed(remainingSeconds % 1 === 0 ? 0 : 1))} s`;
3323
+ return `${minutesLabel} ${secondsLabel}`;
3324
+ };
3325
+ const convertPath = (path)=>{
3326
+ if ('win32' === platform()) return convertPathToPattern(path);
3327
+ return path;
3328
+ };
3329
+ function getTimeCost(start) {
3330
+ const second = (Date.now() - start) / 1000;
3331
+ return prettyTime(second);
3332
+ }
3333
+ async function addBannerAndFooter(dtsFile, banner, footer) {
3334
+ const content = await promises.readFile(dtsFile, 'utf-8');
3335
+ const code = new MagicString(content);
3336
+ if (banner && !content.trimStart().startsWith(banner.trim())) code.prepend(`${banner}\n`);
3337
+ if (footer && !content.trimEnd().endsWith(footer.trim())) code.append(`\n${footer}\n`);
3338
+ if (code.hasChanged()) await promises.writeFile(dtsFile, code.toString());
3339
+ }
3340
+ async function addExtension(redirect, dtsFile, path, jsExtension, dtsExtension) {
3341
+ if (!redirect.extension) return path;
3342
+ if (!isAbsolute(path) && !path.startsWith('.')) return path;
3343
+ const candidatePaths = [];
3344
+ if (await utils_isDirectory(join(dirname(dtsFile), path))) candidatePaths.push(`${path.replace(/\/+$/, '')}/index`);
3345
+ candidatePaths.push(path);
3346
+ const dtsCandidates = '.d.mts' === dtsExtension || '.d.cts' === dtsExtension ? [
3347
+ {
3348
+ dtsExtension,
3349
+ jsExtension
3350
+ },
3351
+ {
3352
+ dtsExtension: '.d.ts',
3353
+ jsExtension: '.js'
3354
+ }
3355
+ ] : [
3356
+ {
3357
+ dtsExtension,
3358
+ jsExtension
3359
+ }
3360
+ ];
3361
+ for (const candidatePath of candidatePaths)for (const candidate of dtsCandidates)if (await pathExists(join(dirname(dtsFile), `${candidatePath}${candidate.dtsExtension}`))) return `${candidatePath}${candidate.jsExtension}`;
3362
+ return path;
3363
+ }
3364
+ async function redirectDtsImports(dtsFile, dtsExtension, redirect, matchPath, outDir, rootDir) {
3365
+ const content = await promises.readFile(dtsFile, 'utf-8');
3366
+ const code = new MagicString(content);
3367
+ const { parseAsync } = loadAstGrepNapi();
3368
+ const sgNode = (await parseAsync("typescript", content)).root();
3369
+ const matcher = {
3370
+ rule: {
3371
+ any: [
3372
+ {
3373
+ kind: 'import_statement',
3374
+ has: {
3375
+ field: 'source',
3376
+ has: {
3377
+ pattern: '$IMP',
3378
+ kind: 'string_fragment'
3379
+ }
3380
+ }
3381
+ },
3382
+ {
3383
+ kind: 'import_statement',
3384
+ has: {
3385
+ kind: 'import_require_clause',
3386
+ has: {
3387
+ field: 'source',
3388
+ has: {
3389
+ pattern: '$IMP',
3390
+ kind: 'string_fragment'
3391
+ }
3392
+ }
3393
+ }
3394
+ },
3395
+ {
3396
+ kind: 'export_statement',
3397
+ has: {
3398
+ field: 'source',
3399
+ has: {
3400
+ pattern: '$IMP',
3401
+ kind: 'string_fragment'
3402
+ }
3403
+ }
3404
+ },
3405
+ {
3406
+ any: [
3407
+ {
3408
+ pattern: 'require($A)'
3409
+ },
3410
+ {
3411
+ pattern: 'import($A)'
3412
+ }
3413
+ ],
3414
+ has: {
3415
+ field: 'arguments',
3416
+ has: {
3417
+ has: {
3418
+ pattern: '$IMP',
3419
+ kind: 'string_fragment'
3420
+ }
3421
+ }
3422
+ }
3423
+ }
3424
+ ]
3425
+ }
3426
+ };
3427
+ const matchModule = sgNode.findAll(matcher).map((match)=>{
3428
+ const matchNode = match.getMatch('IMP');
3429
+ return {
3430
+ n: matchNode.text(),
3431
+ s: matchNode.range().start.index,
3432
+ e: matchNode.range().end.index
3433
+ };
3434
+ });
3435
+ const jsExtension = dtsExtension.replace(/\.d\.ts$/, '.js').replace(/\.d\.cts$/, '.cjs').replace(/\.d\.mts$/, '.mjs');
3436
+ for (const imp of matchModule){
3437
+ const { n: importPath, s: start, e: end } = imp;
3438
+ if (importPath) try {
3439
+ let absoluteImportPath = matchPath(importPath, void 0, void 0, [
3440
+ '.jsx',
3441
+ '.tsx',
3442
+ '.js',
3443
+ '.ts',
3444
+ '.mjs',
3445
+ '.mts',
3446
+ '.cjs',
3447
+ '.cts',
3448
+ '.d.ts'
3449
+ ]);
3450
+ let redirectImportPath = importPath;
3451
+ if (absoluteImportPath?.endsWith('.d')) absoluteImportPath = absoluteImportPath.slice(0, -2);
3452
+ if (absoluteImportPath && !absoluteImportPath.includes('node_modules') && redirect.path) {
3453
+ const relativeRootDir = node_path.relative(normalize(rootDir), normalize(absoluteImportPath));
3454
+ const isOutsideRootdir = relativeRootDir.startsWith('..') || node_path.isAbsolute(relativeRootDir);
3455
+ if (isOutsideRootdir) {
3456
+ const relativePath = external_node_path_relative(dirname(dtsFile), absoluteImportPath);
3457
+ redirectImportPath = relativePath.startsWith('..') ? relativePath : `./${relativePath}`;
3458
+ } else {
3459
+ const originalFilePath = resolve(rootDir, external_node_path_relative(outDir, dtsFile));
3460
+ const originalSourceDir = dirname(originalFilePath);
3461
+ const relativePath = external_node_path_relative(originalSourceDir, absoluteImportPath);
3462
+ redirectImportPath = relativePath.startsWith('..') ? relativePath : `./${relativePath}`;
3463
+ }
3464
+ }
3465
+ const ext = extname(redirectImportPath);
3466
+ const shouldAddExtension = redirectImportPath !== importPath || importPath.startsWith('.') || isAbsolute(importPath);
3467
+ if (ext) if (JS_EXTENSIONS_PATTERN.test(redirectImportPath)) {
3468
+ if (redirect.extension) redirectImportPath = redirectImportPath.replace(/\.[^.]+$/, jsExtension);
3469
+ } else redirectImportPath = await addExtension(redirect, dtsFile, redirectImportPath, jsExtension, dtsExtension);
3470
+ else if (shouldAddExtension) redirectImportPath = await addExtension(redirect, dtsFile, redirectImportPath, jsExtension, dtsExtension);
3471
+ const normalizedRedirectImportPath = redirectImportPath.split(node_path.sep).join('/');
3472
+ code.overwrite(start, end, normalizedRedirectImportPath);
3473
+ } catch (err) {
3474
+ logger.warn(err);
3475
+ }
3476
+ }
3477
+ if (code.hasChanged()) await promises.writeFile(dtsFile, code.toString());
3478
+ }
3479
+ async function processDtsFiles(bundle, dir, dtsExtension, redirect, tsconfigPath, rootDir, paths, banner, footer) {
3480
+ if (bundle) return;
3481
+ let matchPath;
3482
+ if (redirect.path || redirect.extension) {
3483
+ const result = (0, index_js_namespaceObject.loadConfig)(tsconfigPath);
3484
+ if ('failed' === result.resultType) return void logger.error(result.message);
3485
+ const { absoluteBaseUrl, addMatchAll } = result;
3486
+ const mainFields = [];
3487
+ matchPath = (0, index_js_namespaceObject.createMatchPath)(absoluteBaseUrl, paths, mainFields, addMatchAll);
3488
+ }
3489
+ const dtsFiles = await globDtsFiles(dir, [
3490
+ `/**/*${dtsExtension}`
3491
+ ]);
3492
+ await Promise.all(dtsFiles.map(async (file)=>{
3493
+ try {
3494
+ if (banner || footer) await addBannerAndFooter(file, banner, footer);
3495
+ if ((redirect.path || redirect.extension) && matchPath) await redirectDtsImports(file, dtsExtension, redirect, matchPath, dir, rootDir);
3496
+ } catch (error) {
3497
+ logger.error(`Failed to rename declaration file ${file}: ${error}`);
3498
+ }
3499
+ }));
3500
+ }
3501
+ function processSourceEntry(bundle, entryConfig) {
3502
+ if (!bundle) return [];
3503
+ if (entryConfig && Object.values(entryConfig).every((val)=>'string' == typeof val)) {
3504
+ const entries = Object.entries(entryConfig).map(([name, path])=>({
3505
+ name,
3506
+ path
3507
+ }));
3508
+ if (0 === entries.length) {
3509
+ const noValidEntryError = new Error(`Can not find a valid entry for ${color.cyan('dts.bundle')} option, please check your entry config.`);
3510
+ noValidEntryError.stack = '';
3511
+ throw noValidEntryError;
3512
+ }
3513
+ return entries;
3514
+ }
3515
+ const error = new Error('@microsoft/api-extractor only support entry of Record<string, string> type to bundle declaration files, please check your entry config.');
3516
+ error.stack = '';
3517
+ throw error;
3518
+ }
3519
+ async function calcLongestCommonPath(absPaths) {
3520
+ if (0 === absPaths.length) return null;
3521
+ const sep = node_path.posix.sep;
3522
+ const splitPaths = absPaths.map((p)=>p.split(sep));
3523
+ let lcaFragments = splitPaths[0];
3524
+ for(let i = 1; i < splitPaths.length; i++){
3525
+ const currentPath = splitPaths[i];
3526
+ const minLength = Math.min(lcaFragments.length, currentPath.length);
3527
+ let j = 0;
3528
+ while(j < minLength && lcaFragments[j] === currentPath[j])j++;
3529
+ lcaFragments = lcaFragments.slice(0, j);
3530
+ }
3531
+ let lca = lcaFragments.length > 0 ? lcaFragments.join(sep) : sep;
3532
+ const stats = await promises.stat(lca);
3533
+ if (stats?.isFile()) lca = node_path.dirname(lca);
3534
+ return lca;
3535
+ }
3536
+ const globDtsFiles = async (dir, patterns)=>{
3537
+ const dtsFiles = await Promise.all(patterns.map(async (pattern)=>glob(convertPath(join(dir, pattern)), {
3538
+ absolute: true,
3539
+ dot: true
3540
+ })));
3541
+ return dtsFiles.flat();
3542
+ };
3543
+ async function cleanDtsFiles(dir) {
3544
+ const patterns = [
3545
+ '/**/*.d.ts',
3546
+ '/**/*.d.cts',
3547
+ '/**/*.d.mts',
3548
+ '/**/*.d.ts.map',
3549
+ '/**/*.d.cts.map',
3550
+ '/**/*.d.mts.map'
3551
+ ];
3552
+ const allFiles = await globDtsFiles(dir, patterns);
3553
+ await Promise.all(allFiles.map(async (file)=>promises.rm(file, {
3554
+ force: true
3555
+ })));
3556
+ }
3557
+ async function cleanTsBuildInfoFile(tsconfigPath, compilerOptions) {
3558
+ const tsconfigDir = dirname(tsconfigPath);
3559
+ const { outDir, rootDir, tsBuildInfoFile } = compilerOptions;
3560
+ let tsbuildInfoFilePath;
3561
+ if (tsBuildInfoFile && isAbsolute(tsBuildInfoFile)) tsbuildInfoFilePath = tsBuildInfoFile;
3562
+ else {
3563
+ const defaultFileName = `${basename(tsconfigPath, '.json')}${tsBuildInfoFile ?? '.tsbuildinfo'}`;
3564
+ tsbuildInfoFilePath = outDir ? rootDir ? join(outDir, external_node_path_relative(resolve(tsconfigDir, rootDir), tsconfigDir), defaultFileName) : join(outDir, defaultFileName) : join(tsconfigDir, defaultFileName);
3565
+ }
3566
+ if (await pathExists(tsbuildInfoFilePath)) await promises.rm(tsbuildInfoFilePath, {
3567
+ force: true
3568
+ });
3569
+ }
3570
+ function getDtsEmitPath(pathFromPlugin, declarationDir, distPathRoot) {
3571
+ return pathFromPlugin ?? declarationDir ?? distPathRoot;
3572
+ }
3573
+ function warnIfOutside(cwd, dir, label) {
3574
+ if (dir) {
3575
+ const normalizedCwd = normalize(cwd);
3576
+ const normalizedDir = normalize(dir);
3577
+ const relDir = external_node_path_relative(normalizedCwd, normalizedDir);
3578
+ if (relDir.startsWith('..')) logger.warn(`The resolved ${label} ${color.cyan(normalizedDir)} is outside the project root ${color.cyan(normalizedCwd)}, please check your tsconfig file.`);
3579
+ }
3580
+ }
3581
+ function renameDtsFile(fileName, dtsExtension, bundle) {
3582
+ if (bundle) return fileName;
3583
+ if (fileName.endsWith('.d.ts.map')) return fileName.replace(/\.d\.ts\.map$/, `${dtsExtension}.map`);
3584
+ return fileName.replace(/\.d\.ts$/, dtsExtension);
3585
+ }
3586
+ function updateDeclarationMapContent(fileName, content, dtsExtension, bundle, hasDeclarationMap = false) {
3587
+ if (bundle || !hasDeclarationMap) return content;
3588
+ if (fileName.endsWith('.d.ts')) return content.replace(/(\/\/# sourceMappingURL=.+)\.d\.ts\.map/g, `$1${dtsExtension}.map`);
3589
+ if (fileName.endsWith('.d.ts.map')) return content.replace(/("file":"[^"]*)\.d\.ts"/g, `$1${dtsExtension}"`);
3590
+ return content;
3591
+ }
3592
+ export { addBannerAndFooter, calcLongestCommonPath, cleanDtsFiles, cleanTsBuildInfoFile, clearTempDeclarationDir, color, ensureTempDeclarationDir, getDtsEmitPath, getTimeCost, globDtsFiles, loadTsconfig, mergeAliasWithTsConfigPaths, processDtsFiles, processSourceEntry, renameDtsFile, ts, updateDeclarationMapContent, warnIfOutside };