anycodex 0.0.7 → 0.0.9

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.
@@ -0,0 +1,1566 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire } from 'module';
3
+ const require = createRequire(import.meta.url);
4
+
5
+ // ../../node_modules/.pnpm/@isaacs+balanced-match@4.0.1/node_modules/@isaacs/balanced-match/dist/esm/index.js
6
+ var balanced = (a, b, str) => {
7
+ const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
8
+ const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
9
+ const r = ma !== null && mb != null && range(ma, mb, str);
10
+ return r && {
11
+ start: r[0],
12
+ end: r[1],
13
+ pre: str.slice(0, r[0]),
14
+ body: str.slice(r[0] + ma.length, r[1]),
15
+ post: str.slice(r[1] + mb.length)
16
+ };
17
+ };
18
+ var maybeMatch = (reg, str) => {
19
+ const m = str.match(reg);
20
+ return m ? m[0] : null;
21
+ };
22
+ var range = (a, b, str) => {
23
+ let begs, beg, left, right = void 0, result;
24
+ let ai = str.indexOf(a);
25
+ let bi = str.indexOf(b, ai + 1);
26
+ let i = ai;
27
+ if (ai >= 0 && bi > 0) {
28
+ if (a === b) {
29
+ return [ai, bi];
30
+ }
31
+ begs = [];
32
+ left = str.length;
33
+ while (i >= 0 && !result) {
34
+ if (i === ai) {
35
+ begs.push(i);
36
+ ai = str.indexOf(a, i + 1);
37
+ } else if (begs.length === 1) {
38
+ const r = begs.pop();
39
+ if (r !== void 0)
40
+ result = [r, bi];
41
+ } else {
42
+ beg = begs.pop();
43
+ if (beg !== void 0 && beg < left) {
44
+ left = beg;
45
+ right = bi;
46
+ }
47
+ bi = str.indexOf(b, i + 1);
48
+ }
49
+ i = ai < bi && ai >= 0 ? ai : bi;
50
+ }
51
+ if (begs.length && right !== void 0) {
52
+ result = [left, right];
53
+ }
54
+ }
55
+ return result;
56
+ };
57
+
58
+ // ../../node_modules/.pnpm/@isaacs+brace-expansion@5.0.1/node_modules/@isaacs/brace-expansion/dist/esm/index.js
59
+ var escSlash = "\0SLASH" + Math.random() + "\0";
60
+ var escOpen = "\0OPEN" + Math.random() + "\0";
61
+ var escClose = "\0CLOSE" + Math.random() + "\0";
62
+ var escComma = "\0COMMA" + Math.random() + "\0";
63
+ var escPeriod = "\0PERIOD" + Math.random() + "\0";
64
+ var escSlashPattern = new RegExp(escSlash, "g");
65
+ var escOpenPattern = new RegExp(escOpen, "g");
66
+ var escClosePattern = new RegExp(escClose, "g");
67
+ var escCommaPattern = new RegExp(escComma, "g");
68
+ var escPeriodPattern = new RegExp(escPeriod, "g");
69
+ var slashPattern = /\\\\/g;
70
+ var openPattern = /\\{/g;
71
+ var closePattern = /\\}/g;
72
+ var commaPattern = /\\,/g;
73
+ var periodPattern = /\\./g;
74
+ var EXPANSION_MAX = 1e5;
75
+ function numeric(str) {
76
+ return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
77
+ }
78
+ function escapeBraces(str) {
79
+ return str.replace(slashPattern, escSlash).replace(openPattern, escOpen).replace(closePattern, escClose).replace(commaPattern, escComma).replace(periodPattern, escPeriod);
80
+ }
81
+ function unescapeBraces(str) {
82
+ return str.replace(escSlashPattern, "\\").replace(escOpenPattern, "{").replace(escClosePattern, "}").replace(escCommaPattern, ",").replace(escPeriodPattern, ".");
83
+ }
84
+ function parseCommaParts(str) {
85
+ if (!str) {
86
+ return [""];
87
+ }
88
+ const parts = [];
89
+ const m = balanced("{", "}", str);
90
+ if (!m) {
91
+ return str.split(",");
92
+ }
93
+ const { pre, body, post } = m;
94
+ const p = pre.split(",");
95
+ p[p.length - 1] += "{" + body + "}";
96
+ const postParts = parseCommaParts(post);
97
+ if (post.length) {
98
+ ;
99
+ p[p.length - 1] += postParts.shift();
100
+ p.push.apply(p, postParts);
101
+ }
102
+ parts.push.apply(parts, p);
103
+ return parts;
104
+ }
105
+ function expand(str, options = {}) {
106
+ if (!str) {
107
+ return [];
108
+ }
109
+ const { max = EXPANSION_MAX } = options;
110
+ if (str.slice(0, 2) === "{}") {
111
+ str = "\\{\\}" + str.slice(2);
112
+ }
113
+ return expand_(escapeBraces(str), max, true).map(unescapeBraces);
114
+ }
115
+ function embrace(str) {
116
+ return "{" + str + "}";
117
+ }
118
+ function isPadded(el) {
119
+ return /^-?0\d/.test(el);
120
+ }
121
+ function lte(i, y) {
122
+ return i <= y;
123
+ }
124
+ function gte(i, y) {
125
+ return i >= y;
126
+ }
127
+ function expand_(str, max, isTop) {
128
+ const expansions = [];
129
+ const m = balanced("{", "}", str);
130
+ if (!m)
131
+ return [str];
132
+ const pre = m.pre;
133
+ const post = m.post.length ? expand_(m.post, max, false) : [""];
134
+ if (/\$$/.test(m.pre)) {
135
+ for (let k = 0; k < post.length && k < max; k++) {
136
+ const expansion = pre + "{" + m.body + "}" + post[k];
137
+ expansions.push(expansion);
138
+ }
139
+ } else {
140
+ const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
141
+ const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
142
+ const isSequence = isNumericSequence || isAlphaSequence;
143
+ const isOptions = m.body.indexOf(",") >= 0;
144
+ if (!isSequence && !isOptions) {
145
+ if (m.post.match(/,(?!,).*\}/)) {
146
+ str = m.pre + "{" + m.body + escClose + m.post;
147
+ return expand_(str, max, true);
148
+ }
149
+ return [str];
150
+ }
151
+ let n;
152
+ if (isSequence) {
153
+ n = m.body.split(/\.\./);
154
+ } else {
155
+ n = parseCommaParts(m.body);
156
+ if (n.length === 1 && n[0] !== void 0) {
157
+ n = expand_(n[0], max, false).map(embrace);
158
+ if (n.length === 1) {
159
+ return post.map((p) => m.pre + n[0] + p);
160
+ }
161
+ }
162
+ }
163
+ let N;
164
+ if (isSequence && n[0] !== void 0 && n[1] !== void 0) {
165
+ const x = numeric(n[0]);
166
+ const y = numeric(n[1]);
167
+ const width = Math.max(n[0].length, n[1].length);
168
+ let incr = n.length === 3 && n[2] !== void 0 ? Math.abs(numeric(n[2])) : 1;
169
+ let test = lte;
170
+ const reverse = y < x;
171
+ if (reverse) {
172
+ incr *= -1;
173
+ test = gte;
174
+ }
175
+ const pad = n.some(isPadded);
176
+ N = [];
177
+ for (let i = x; test(i, y); i += incr) {
178
+ let c;
179
+ if (isAlphaSequence) {
180
+ c = String.fromCharCode(i);
181
+ if (c === "\\") {
182
+ c = "";
183
+ }
184
+ } else {
185
+ c = String(i);
186
+ if (pad) {
187
+ const need = width - c.length;
188
+ if (need > 0) {
189
+ const z = new Array(need + 1).join("0");
190
+ if (i < 0) {
191
+ c = "-" + z + c.slice(1);
192
+ } else {
193
+ c = z + c;
194
+ }
195
+ }
196
+ }
197
+ }
198
+ N.push(c);
199
+ }
200
+ } else {
201
+ N = [];
202
+ for (let j = 0; j < n.length; j++) {
203
+ N.push.apply(N, expand_(n[j], max, false));
204
+ }
205
+ }
206
+ for (let j = 0; j < N.length; j++) {
207
+ for (let k = 0; k < post.length && expansions.length < max; k++) {
208
+ const expansion = pre + N[j] + post[k];
209
+ if (!isTop || isSequence || expansion) {
210
+ expansions.push(expansion);
211
+ }
212
+ }
213
+ }
214
+ }
215
+ return expansions;
216
+ }
217
+
218
+ // ../../node_modules/.pnpm/minimatch@10.0.3/node_modules/minimatch/dist/esm/assert-valid-pattern.js
219
+ var MAX_PATTERN_LENGTH = 1024 * 64;
220
+ var assertValidPattern = (pattern) => {
221
+ if (typeof pattern !== "string") {
222
+ throw new TypeError("invalid pattern");
223
+ }
224
+ if (pattern.length > MAX_PATTERN_LENGTH) {
225
+ throw new TypeError("pattern is too long");
226
+ }
227
+ };
228
+
229
+ // ../../node_modules/.pnpm/minimatch@10.0.3/node_modules/minimatch/dist/esm/brace-expressions.js
230
+ var posixClasses = {
231
+ "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
232
+ "[:alpha:]": ["\\p{L}\\p{Nl}", true],
233
+ "[:ascii:]": ["\\x00-\\x7f", false],
234
+ "[:blank:]": ["\\p{Zs}\\t", true],
235
+ "[:cntrl:]": ["\\p{Cc}", true],
236
+ "[:digit:]": ["\\p{Nd}", true],
237
+ "[:graph:]": ["\\p{Z}\\p{C}", true, true],
238
+ "[:lower:]": ["\\p{Ll}", true],
239
+ "[:print:]": ["\\p{C}", true],
240
+ "[:punct:]": ["\\p{P}", true],
241
+ "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true],
242
+ "[:upper:]": ["\\p{Lu}", true],
243
+ "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true],
244
+ "[:xdigit:]": ["A-Fa-f0-9", false]
245
+ };
246
+ var braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&");
247
+ var regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
248
+ var rangesToString = (ranges) => ranges.join("");
249
+ var parseClass = (glob, position) => {
250
+ const pos = position;
251
+ if (glob.charAt(pos) !== "[") {
252
+ throw new Error("not in a brace expression");
253
+ }
254
+ const ranges = [];
255
+ const negs = [];
256
+ let i = pos + 1;
257
+ let sawStart = false;
258
+ let uflag = false;
259
+ let escaping = false;
260
+ let negate = false;
261
+ let endPos = pos;
262
+ let rangeStart = "";
263
+ WHILE: while (i < glob.length) {
264
+ const c = glob.charAt(i);
265
+ if ((c === "!" || c === "^") && i === pos + 1) {
266
+ negate = true;
267
+ i++;
268
+ continue;
269
+ }
270
+ if (c === "]" && sawStart && !escaping) {
271
+ endPos = i + 1;
272
+ break;
273
+ }
274
+ sawStart = true;
275
+ if (c === "\\") {
276
+ if (!escaping) {
277
+ escaping = true;
278
+ i++;
279
+ continue;
280
+ }
281
+ }
282
+ if (c === "[" && !escaping) {
283
+ for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) {
284
+ if (glob.startsWith(cls, i)) {
285
+ if (rangeStart) {
286
+ return ["$.", false, glob.length - pos, true];
287
+ }
288
+ i += cls.length;
289
+ if (neg)
290
+ negs.push(unip);
291
+ else
292
+ ranges.push(unip);
293
+ uflag = uflag || u;
294
+ continue WHILE;
295
+ }
296
+ }
297
+ }
298
+ escaping = false;
299
+ if (rangeStart) {
300
+ if (c > rangeStart) {
301
+ ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c));
302
+ } else if (c === rangeStart) {
303
+ ranges.push(braceEscape(c));
304
+ }
305
+ rangeStart = "";
306
+ i++;
307
+ continue;
308
+ }
309
+ if (glob.startsWith("-]", i + 1)) {
310
+ ranges.push(braceEscape(c + "-"));
311
+ i += 2;
312
+ continue;
313
+ }
314
+ if (glob.startsWith("-", i + 1)) {
315
+ rangeStart = c;
316
+ i += 2;
317
+ continue;
318
+ }
319
+ ranges.push(braceEscape(c));
320
+ i++;
321
+ }
322
+ if (endPos < i) {
323
+ return ["", false, 0, false];
324
+ }
325
+ if (!ranges.length && !negs.length) {
326
+ return ["$.", false, glob.length - pos, true];
327
+ }
328
+ if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) {
329
+ const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
330
+ return [regexpEscape(r), false, endPos - pos, false];
331
+ }
332
+ const sranges = "[" + (negate ? "^" : "") + rangesToString(ranges) + "]";
333
+ const snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]";
334
+ const comb = ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs;
335
+ return [comb, uflag, endPos - pos, true];
336
+ };
337
+
338
+ // ../../node_modules/.pnpm/minimatch@10.0.3/node_modules/minimatch/dist/esm/unescape.js
339
+ var unescape = (s, { windowsPathsNoEscape = false } = {}) => {
340
+ return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
341
+ };
342
+
343
+ // ../../node_modules/.pnpm/minimatch@10.0.3/node_modules/minimatch/dist/esm/ast.js
344
+ var types = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]);
345
+ var isExtglobType = (c) => types.has(c);
346
+ var startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
347
+ var startNoDot = "(?!\\.)";
348
+ var addPatternStart = /* @__PURE__ */ new Set(["[", "."]);
349
+ var justDots = /* @__PURE__ */ new Set(["..", "."]);
350
+ var reSpecials = new Set("().*{}+?[]^$\\!");
351
+ var regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
352
+ var qmark = "[^/]";
353
+ var star = qmark + "*?";
354
+ var starNoEmpty = qmark + "+?";
355
+ var AST = class _AST {
356
+ type;
357
+ #root;
358
+ #hasMagic;
359
+ #uflag = false;
360
+ #parts = [];
361
+ #parent;
362
+ #parentIndex;
363
+ #negs;
364
+ #filledNegs = false;
365
+ #options;
366
+ #toString;
367
+ // set to true if it's an extglob with no children
368
+ // (which really means one child of '')
369
+ #emptyExt = false;
370
+ constructor(type, parent, options = {}) {
371
+ this.type = type;
372
+ if (type)
373
+ this.#hasMagic = true;
374
+ this.#parent = parent;
375
+ this.#root = this.#parent ? this.#parent.#root : this;
376
+ this.#options = this.#root === this ? options : this.#root.#options;
377
+ this.#negs = this.#root === this ? [] : this.#root.#negs;
378
+ if (type === "!" && !this.#root.#filledNegs)
379
+ this.#negs.push(this);
380
+ this.#parentIndex = this.#parent ? this.#parent.#parts.length : 0;
381
+ }
382
+ get hasMagic() {
383
+ if (this.#hasMagic !== void 0)
384
+ return this.#hasMagic;
385
+ for (const p of this.#parts) {
386
+ if (typeof p === "string")
387
+ continue;
388
+ if (p.type || p.hasMagic)
389
+ return this.#hasMagic = true;
390
+ }
391
+ return this.#hasMagic;
392
+ }
393
+ // reconstructs the pattern
394
+ toString() {
395
+ if (this.#toString !== void 0)
396
+ return this.#toString;
397
+ if (!this.type) {
398
+ return this.#toString = this.#parts.map((p) => String(p)).join("");
399
+ } else {
400
+ return this.#toString = this.type + "(" + this.#parts.map((p) => String(p)).join("|") + ")";
401
+ }
402
+ }
403
+ #fillNegs() {
404
+ if (this !== this.#root)
405
+ throw new Error("should only call on root");
406
+ if (this.#filledNegs)
407
+ return this;
408
+ this.toString();
409
+ this.#filledNegs = true;
410
+ let n;
411
+ while (n = this.#negs.pop()) {
412
+ if (n.type !== "!")
413
+ continue;
414
+ let p = n;
415
+ let pp = p.#parent;
416
+ while (pp) {
417
+ for (let i = p.#parentIndex + 1; !pp.type && i < pp.#parts.length; i++) {
418
+ for (const part of n.#parts) {
419
+ if (typeof part === "string") {
420
+ throw new Error("string part in extglob AST??");
421
+ }
422
+ part.copyIn(pp.#parts[i]);
423
+ }
424
+ }
425
+ p = pp;
426
+ pp = p.#parent;
427
+ }
428
+ }
429
+ return this;
430
+ }
431
+ push(...parts) {
432
+ for (const p of parts) {
433
+ if (p === "")
434
+ continue;
435
+ if (typeof p !== "string" && !(p instanceof _AST && p.#parent === this)) {
436
+ throw new Error("invalid part: " + p);
437
+ }
438
+ this.#parts.push(p);
439
+ }
440
+ }
441
+ toJSON() {
442
+ const ret = this.type === null ? this.#parts.slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...this.#parts.map((p) => p.toJSON())];
443
+ if (this.isStart() && !this.type)
444
+ ret.unshift([]);
445
+ if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && this.#parent?.type === "!")) {
446
+ ret.push({});
447
+ }
448
+ return ret;
449
+ }
450
+ isStart() {
451
+ if (this.#root === this)
452
+ return true;
453
+ if (!this.#parent?.isStart())
454
+ return false;
455
+ if (this.#parentIndex === 0)
456
+ return true;
457
+ const p = this.#parent;
458
+ for (let i = 0; i < this.#parentIndex; i++) {
459
+ const pp = p.#parts[i];
460
+ if (!(pp instanceof _AST && pp.type === "!")) {
461
+ return false;
462
+ }
463
+ }
464
+ return true;
465
+ }
466
+ isEnd() {
467
+ if (this.#root === this)
468
+ return true;
469
+ if (this.#parent?.type === "!")
470
+ return true;
471
+ if (!this.#parent?.isEnd())
472
+ return false;
473
+ if (!this.type)
474
+ return this.#parent?.isEnd();
475
+ const pl = this.#parent ? this.#parent.#parts.length : 0;
476
+ return this.#parentIndex === pl - 1;
477
+ }
478
+ copyIn(part) {
479
+ if (typeof part === "string")
480
+ this.push(part);
481
+ else
482
+ this.push(part.clone(this));
483
+ }
484
+ clone(parent) {
485
+ const c = new _AST(this.type, parent);
486
+ for (const p of this.#parts) {
487
+ c.copyIn(p);
488
+ }
489
+ return c;
490
+ }
491
+ static #parseAST(str, ast, pos, opt) {
492
+ let escaping = false;
493
+ let inBrace = false;
494
+ let braceStart = -1;
495
+ let braceNeg = false;
496
+ if (ast.type === null) {
497
+ let i2 = pos;
498
+ let acc2 = "";
499
+ while (i2 < str.length) {
500
+ const c = str.charAt(i2++);
501
+ if (escaping || c === "\\") {
502
+ escaping = !escaping;
503
+ acc2 += c;
504
+ continue;
505
+ }
506
+ if (inBrace) {
507
+ if (i2 === braceStart + 1) {
508
+ if (c === "^" || c === "!") {
509
+ braceNeg = true;
510
+ }
511
+ } else if (c === "]" && !(i2 === braceStart + 2 && braceNeg)) {
512
+ inBrace = false;
513
+ }
514
+ acc2 += c;
515
+ continue;
516
+ } else if (c === "[") {
517
+ inBrace = true;
518
+ braceStart = i2;
519
+ braceNeg = false;
520
+ acc2 += c;
521
+ continue;
522
+ }
523
+ if (!opt.noext && isExtglobType(c) && str.charAt(i2) === "(") {
524
+ ast.push(acc2);
525
+ acc2 = "";
526
+ const ext2 = new _AST(c, ast);
527
+ i2 = _AST.#parseAST(str, ext2, i2, opt);
528
+ ast.push(ext2);
529
+ continue;
530
+ }
531
+ acc2 += c;
532
+ }
533
+ ast.push(acc2);
534
+ return i2;
535
+ }
536
+ let i = pos + 1;
537
+ let part = new _AST(null, ast);
538
+ const parts = [];
539
+ let acc = "";
540
+ while (i < str.length) {
541
+ const c = str.charAt(i++);
542
+ if (escaping || c === "\\") {
543
+ escaping = !escaping;
544
+ acc += c;
545
+ continue;
546
+ }
547
+ if (inBrace) {
548
+ if (i === braceStart + 1) {
549
+ if (c === "^" || c === "!") {
550
+ braceNeg = true;
551
+ }
552
+ } else if (c === "]" && !(i === braceStart + 2 && braceNeg)) {
553
+ inBrace = false;
554
+ }
555
+ acc += c;
556
+ continue;
557
+ } else if (c === "[") {
558
+ inBrace = true;
559
+ braceStart = i;
560
+ braceNeg = false;
561
+ acc += c;
562
+ continue;
563
+ }
564
+ if (isExtglobType(c) && str.charAt(i) === "(") {
565
+ part.push(acc);
566
+ acc = "";
567
+ const ext2 = new _AST(c, part);
568
+ part.push(ext2);
569
+ i = _AST.#parseAST(str, ext2, i, opt);
570
+ continue;
571
+ }
572
+ if (c === "|") {
573
+ part.push(acc);
574
+ acc = "";
575
+ parts.push(part);
576
+ part = new _AST(null, ast);
577
+ continue;
578
+ }
579
+ if (c === ")") {
580
+ if (acc === "" && ast.#parts.length === 0) {
581
+ ast.#emptyExt = true;
582
+ }
583
+ part.push(acc);
584
+ acc = "";
585
+ ast.push(...parts, part);
586
+ return i;
587
+ }
588
+ acc += c;
589
+ }
590
+ ast.type = null;
591
+ ast.#hasMagic = void 0;
592
+ ast.#parts = [str.substring(pos - 1)];
593
+ return i;
594
+ }
595
+ static fromGlob(pattern, options = {}) {
596
+ const ast = new _AST(null, void 0, options);
597
+ _AST.#parseAST(pattern, ast, 0, options);
598
+ return ast;
599
+ }
600
+ // returns the regular expression if there's magic, or the unescaped
601
+ // string if not.
602
+ toMMPattern() {
603
+ if (this !== this.#root)
604
+ return this.#root.toMMPattern();
605
+ const glob = this.toString();
606
+ const [re, body, hasMagic, uflag] = this.toRegExpSource();
607
+ const anyMagic = hasMagic || this.#hasMagic || this.#options.nocase && !this.#options.nocaseMagicOnly && glob.toUpperCase() !== glob.toLowerCase();
608
+ if (!anyMagic) {
609
+ return body;
610
+ }
611
+ const flags = (this.#options.nocase ? "i" : "") + (uflag ? "u" : "");
612
+ return Object.assign(new RegExp(`^${re}$`, flags), {
613
+ _src: re,
614
+ _glob: glob
615
+ });
616
+ }
617
+ get options() {
618
+ return this.#options;
619
+ }
620
+ // returns the string match, the regexp source, whether there's magic
621
+ // in the regexp (so a regular expression is required) and whether or
622
+ // not the uflag is needed for the regular expression (for posix classes)
623
+ // TODO: instead of injecting the start/end at this point, just return
624
+ // the BODY of the regexp, along with the start/end portions suitable
625
+ // for binding the start/end in either a joined full-path makeRe context
626
+ // (where we bind to (^|/), or a standalone matchPart context (where
627
+ // we bind to ^, and not /). Otherwise slashes get duped!
628
+ //
629
+ // In part-matching mode, the start is:
630
+ // - if not isStart: nothing
631
+ // - if traversal possible, but not allowed: ^(?!\.\.?$)
632
+ // - if dots allowed or not possible: ^
633
+ // - if dots possible and not allowed: ^(?!\.)
634
+ // end is:
635
+ // - if not isEnd(): nothing
636
+ // - else: $
637
+ //
638
+ // In full-path matching mode, we put the slash at the START of the
639
+ // pattern, so start is:
640
+ // - if first pattern: same as part-matching mode
641
+ // - if not isStart(): nothing
642
+ // - if traversal possible, but not allowed: /(?!\.\.?(?:$|/))
643
+ // - if dots allowed or not possible: /
644
+ // - if dots possible and not allowed: /(?!\.)
645
+ // end is:
646
+ // - if last pattern, same as part-matching mode
647
+ // - else nothing
648
+ //
649
+ // Always put the (?:$|/) on negated tails, though, because that has to be
650
+ // there to bind the end of the negated pattern portion, and it's easier to
651
+ // just stick it in now rather than try to inject it later in the middle of
652
+ // the pattern.
653
+ //
654
+ // We can just always return the same end, and leave it up to the caller
655
+ // to know whether it's going to be used joined or in parts.
656
+ // And, if the start is adjusted slightly, can do the same there:
657
+ // - if not isStart: nothing
658
+ // - if traversal possible, but not allowed: (?:/|^)(?!\.\.?$)
659
+ // - if dots allowed or not possible: (?:/|^)
660
+ // - if dots possible and not allowed: (?:/|^)(?!\.)
661
+ //
662
+ // But it's better to have a simpler binding without a conditional, for
663
+ // performance, so probably better to return both start options.
664
+ //
665
+ // Then the caller just ignores the end if it's not the first pattern,
666
+ // and the start always gets applied.
667
+ //
668
+ // But that's always going to be $ if it's the ending pattern, or nothing,
669
+ // so the caller can just attach $ at the end of the pattern when building.
670
+ //
671
+ // So the todo is:
672
+ // - better detect what kind of start is needed
673
+ // - return both flavors of starting pattern
674
+ // - attach $ at the end of the pattern when creating the actual RegExp
675
+ //
676
+ // Ah, but wait, no, that all only applies to the root when the first pattern
677
+ // is not an extglob. If the first pattern IS an extglob, then we need all
678
+ // that dot prevention biz to live in the extglob portions, because eg
679
+ // +(*|.x*) can match .xy but not .yx.
680
+ //
681
+ // So, return the two flavors if it's #root and the first child is not an
682
+ // AST, otherwise leave it to the child AST to handle it, and there,
683
+ // use the (?:^|/) style of start binding.
684
+ //
685
+ // Even simplified further:
686
+ // - Since the start for a join is eg /(?!\.) and the start for a part
687
+ // is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
688
+ // or start or whatever) and prepend ^ or / at the Regexp construction.
689
+ toRegExpSource(allowDot) {
690
+ const dot = allowDot ?? !!this.#options.dot;
691
+ if (this.#root === this)
692
+ this.#fillNegs();
693
+ if (!this.type) {
694
+ const noEmpty = this.isStart() && this.isEnd();
695
+ const src = this.#parts.map((p) => {
696
+ const [re, _, hasMagic, uflag] = typeof p === "string" ? _AST.#parseGlob(p, this.#hasMagic, noEmpty) : p.toRegExpSource(allowDot);
697
+ this.#hasMagic = this.#hasMagic || hasMagic;
698
+ this.#uflag = this.#uflag || uflag;
699
+ return re;
700
+ }).join("");
701
+ let start2 = "";
702
+ if (this.isStart()) {
703
+ if (typeof this.#parts[0] === "string") {
704
+ const dotTravAllowed = this.#parts.length === 1 && justDots.has(this.#parts[0]);
705
+ if (!dotTravAllowed) {
706
+ const aps = addPatternStart;
707
+ const needNoTrav = (
708
+ // dots are allowed, and the pattern starts with [ or .
709
+ dot && aps.has(src.charAt(0)) || // the pattern starts with \., and then [ or .
710
+ src.startsWith("\\.") && aps.has(src.charAt(2)) || // the pattern starts with \.\., and then [ or .
711
+ src.startsWith("\\.\\.") && aps.has(src.charAt(4))
712
+ );
713
+ const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
714
+ start2 = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : "";
715
+ }
716
+ }
717
+ }
718
+ let end = "";
719
+ if (this.isEnd() && this.#root.#filledNegs && this.#parent?.type === "!") {
720
+ end = "(?:$|\\/)";
721
+ }
722
+ const final2 = start2 + src + end;
723
+ return [
724
+ final2,
725
+ unescape(src),
726
+ this.#hasMagic = !!this.#hasMagic,
727
+ this.#uflag
728
+ ];
729
+ }
730
+ const repeated = this.type === "*" || this.type === "+";
731
+ const start = this.type === "!" ? "(?:(?!(?:" : "(?:";
732
+ let body = this.#partsToRegExp(dot);
733
+ if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
734
+ const s = this.toString();
735
+ this.#parts = [s];
736
+ this.type = null;
737
+ this.#hasMagic = void 0;
738
+ return [s, unescape(this.toString()), false, false];
739
+ }
740
+ let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ? "" : this.#partsToRegExp(true);
741
+ if (bodyDotAllowed === body) {
742
+ bodyDotAllowed = "";
743
+ }
744
+ if (bodyDotAllowed) {
745
+ body = `(?:${body})(?:${bodyDotAllowed})*?`;
746
+ }
747
+ let final = "";
748
+ if (this.type === "!" && this.#emptyExt) {
749
+ final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty;
750
+ } else {
751
+ const close = this.type === "!" ? (
752
+ // !() must match something,but !(x) can match ''
753
+ "))" + (this.isStart() && !dot && !allowDot ? startNoDot : "") + star + ")"
754
+ ) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? `)?` : `)${this.type}`;
755
+ final = start + body + close;
756
+ }
757
+ return [
758
+ final,
759
+ unescape(body),
760
+ this.#hasMagic = !!this.#hasMagic,
761
+ this.#uflag
762
+ ];
763
+ }
764
+ #partsToRegExp(dot) {
765
+ return this.#parts.map((p) => {
766
+ if (typeof p === "string") {
767
+ throw new Error("string type in extglob ast??");
768
+ }
769
+ const [re, _, _hasMagic, uflag] = p.toRegExpSource(dot);
770
+ this.#uflag = this.#uflag || uflag;
771
+ return re;
772
+ }).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
773
+ }
774
+ static #parseGlob(glob, hasMagic, noEmpty = false) {
775
+ let escaping = false;
776
+ let re = "";
777
+ let uflag = false;
778
+ for (let i = 0; i < glob.length; i++) {
779
+ const c = glob.charAt(i);
780
+ if (escaping) {
781
+ escaping = false;
782
+ re += (reSpecials.has(c) ? "\\" : "") + c;
783
+ continue;
784
+ }
785
+ if (c === "\\") {
786
+ if (i === glob.length - 1) {
787
+ re += "\\\\";
788
+ } else {
789
+ escaping = true;
790
+ }
791
+ continue;
792
+ }
793
+ if (c === "[") {
794
+ const [src, needUflag, consumed, magic] = parseClass(glob, i);
795
+ if (consumed) {
796
+ re += src;
797
+ uflag = uflag || needUflag;
798
+ i += consumed - 1;
799
+ hasMagic = hasMagic || magic;
800
+ continue;
801
+ }
802
+ }
803
+ if (c === "*") {
804
+ if (noEmpty && glob === "*")
805
+ re += starNoEmpty;
806
+ else
807
+ re += star;
808
+ hasMagic = true;
809
+ continue;
810
+ }
811
+ if (c === "?") {
812
+ re += qmark;
813
+ hasMagic = true;
814
+ continue;
815
+ }
816
+ re += regExpEscape(c);
817
+ }
818
+ return [re, unescape(glob), !!hasMagic, uflag];
819
+ }
820
+ };
821
+
822
+ // ../../node_modules/.pnpm/minimatch@10.0.3/node_modules/minimatch/dist/esm/escape.js
823
+ var escape = (s, { windowsPathsNoEscape = false } = {}) => {
824
+ return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
825
+ };
826
+
827
+ // ../../node_modules/.pnpm/minimatch@10.0.3/node_modules/minimatch/dist/esm/index.js
828
+ var minimatch = (p, pattern, options = {}) => {
829
+ assertValidPattern(pattern);
830
+ if (!options.nocomment && pattern.charAt(0) === "#") {
831
+ return false;
832
+ }
833
+ return new Minimatch(pattern, options).match(p);
834
+ };
835
+ var starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/;
836
+ var starDotExtTest = (ext2) => (f) => !f.startsWith(".") && f.endsWith(ext2);
837
+ var starDotExtTestDot = (ext2) => (f) => f.endsWith(ext2);
838
+ var starDotExtTestNocase = (ext2) => {
839
+ ext2 = ext2.toLowerCase();
840
+ return (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext2);
841
+ };
842
+ var starDotExtTestNocaseDot = (ext2) => {
843
+ ext2 = ext2.toLowerCase();
844
+ return (f) => f.toLowerCase().endsWith(ext2);
845
+ };
846
+ var starDotStarRE = /^\*+\.\*+$/;
847
+ var starDotStarTest = (f) => !f.startsWith(".") && f.includes(".");
848
+ var starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes(".");
849
+ var dotStarRE = /^\.\*+$/;
850
+ var dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith(".");
851
+ var starRE = /^\*+$/;
852
+ var starTest = (f) => f.length !== 0 && !f.startsWith(".");
853
+ var starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..";
854
+ var qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
855
+ var qmarksTestNocase = ([$0, ext2 = ""]) => {
856
+ const noext = qmarksTestNoExt([$0]);
857
+ if (!ext2)
858
+ return noext;
859
+ ext2 = ext2.toLowerCase();
860
+ return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
861
+ };
862
+ var qmarksTestNocaseDot = ([$0, ext2 = ""]) => {
863
+ const noext = qmarksTestNoExtDot([$0]);
864
+ if (!ext2)
865
+ return noext;
866
+ ext2 = ext2.toLowerCase();
867
+ return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
868
+ };
869
+ var qmarksTestDot = ([$0, ext2 = ""]) => {
870
+ const noext = qmarksTestNoExtDot([$0]);
871
+ return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
872
+ };
873
+ var qmarksTest = ([$0, ext2 = ""]) => {
874
+ const noext = qmarksTestNoExt([$0]);
875
+ return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
876
+ };
877
+ var qmarksTestNoExt = ([$0]) => {
878
+ const len = $0.length;
879
+ return (f) => f.length === len && !f.startsWith(".");
880
+ };
881
+ var qmarksTestNoExtDot = ([$0]) => {
882
+ const len = $0.length;
883
+ return (f) => f.length === len && f !== "." && f !== "..";
884
+ };
885
+ var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
886
+ var path = {
887
+ win32: { sep: "\\" },
888
+ posix: { sep: "/" }
889
+ };
890
+ var sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
891
+ minimatch.sep = sep;
892
+ var GLOBSTAR = /* @__PURE__ */ Symbol("globstar **");
893
+ minimatch.GLOBSTAR = GLOBSTAR;
894
+ var qmark2 = "[^/]";
895
+ var star2 = qmark2 + "*?";
896
+ var twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
897
+ var twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
898
+ var filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
899
+ minimatch.filter = filter;
900
+ var ext = (a, b = {}) => Object.assign({}, a, b);
901
+ var defaults = (def) => {
902
+ if (!def || typeof def !== "object" || !Object.keys(def).length) {
903
+ return minimatch;
904
+ }
905
+ const orig = minimatch;
906
+ const m = (p, pattern, options = {}) => orig(p, pattern, ext(def, options));
907
+ return Object.assign(m, {
908
+ Minimatch: class Minimatch extends orig.Minimatch {
909
+ constructor(pattern, options = {}) {
910
+ super(pattern, ext(def, options));
911
+ }
912
+ static defaults(options) {
913
+ return orig.defaults(ext(def, options)).Minimatch;
914
+ }
915
+ },
916
+ AST: class AST extends orig.AST {
917
+ /* c8 ignore start */
918
+ constructor(type, parent, options = {}) {
919
+ super(type, parent, ext(def, options));
920
+ }
921
+ /* c8 ignore stop */
922
+ static fromGlob(pattern, options = {}) {
923
+ return orig.AST.fromGlob(pattern, ext(def, options));
924
+ }
925
+ },
926
+ unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
927
+ escape: (s, options = {}) => orig.escape(s, ext(def, options)),
928
+ filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
929
+ defaults: (options) => orig.defaults(ext(def, options)),
930
+ makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
931
+ braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
932
+ match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
933
+ sep: orig.sep,
934
+ GLOBSTAR
935
+ });
936
+ };
937
+ minimatch.defaults = defaults;
938
+ var braceExpand = (pattern, options = {}) => {
939
+ assertValidPattern(pattern);
940
+ if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
941
+ return [pattern];
942
+ }
943
+ return expand(pattern);
944
+ };
945
+ minimatch.braceExpand = braceExpand;
946
+ var makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
947
+ minimatch.makeRe = makeRe;
948
+ var match = (list, pattern, options = {}) => {
949
+ const mm = new Minimatch(pattern, options);
950
+ list = list.filter((f) => mm.match(f));
951
+ if (mm.options.nonull && !list.length) {
952
+ list.push(pattern);
953
+ }
954
+ return list;
955
+ };
956
+ minimatch.match = match;
957
+ var globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
958
+ var regExpEscape2 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
959
+ var Minimatch = class {
960
+ options;
961
+ set;
962
+ pattern;
963
+ windowsPathsNoEscape;
964
+ nonegate;
965
+ negate;
966
+ comment;
967
+ empty;
968
+ preserveMultipleSlashes;
969
+ partial;
970
+ globSet;
971
+ globParts;
972
+ nocase;
973
+ isWindows;
974
+ platform;
975
+ windowsNoMagicRoot;
976
+ regexp;
977
+ constructor(pattern, options = {}) {
978
+ assertValidPattern(pattern);
979
+ options = options || {};
980
+ this.options = options;
981
+ this.pattern = pattern;
982
+ this.platform = options.platform || defaultPlatform;
983
+ this.isWindows = this.platform === "win32";
984
+ this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options.allowWindowsEscape === false;
985
+ if (this.windowsPathsNoEscape) {
986
+ this.pattern = this.pattern.replace(/\\/g, "/");
987
+ }
988
+ this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
989
+ this.regexp = null;
990
+ this.negate = false;
991
+ this.nonegate = !!options.nonegate;
992
+ this.comment = false;
993
+ this.empty = false;
994
+ this.partial = !!options.partial;
995
+ this.nocase = !!this.options.nocase;
996
+ this.windowsNoMagicRoot = options.windowsNoMagicRoot !== void 0 ? options.windowsNoMagicRoot : !!(this.isWindows && this.nocase);
997
+ this.globSet = [];
998
+ this.globParts = [];
999
+ this.set = [];
1000
+ this.make();
1001
+ }
1002
+ hasMagic() {
1003
+ if (this.options.magicalBraces && this.set.length > 1) {
1004
+ return true;
1005
+ }
1006
+ for (const pattern of this.set) {
1007
+ for (const part of pattern) {
1008
+ if (typeof part !== "string")
1009
+ return true;
1010
+ }
1011
+ }
1012
+ return false;
1013
+ }
1014
+ debug(..._) {
1015
+ }
1016
+ make() {
1017
+ const pattern = this.pattern;
1018
+ const options = this.options;
1019
+ if (!options.nocomment && pattern.charAt(0) === "#") {
1020
+ this.comment = true;
1021
+ return;
1022
+ }
1023
+ if (!pattern) {
1024
+ this.empty = true;
1025
+ return;
1026
+ }
1027
+ this.parseNegate();
1028
+ this.globSet = [...new Set(this.braceExpand())];
1029
+ if (options.debug) {
1030
+ this.debug = (...args) => console.error(...args);
1031
+ }
1032
+ this.debug(this.pattern, this.globSet);
1033
+ const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
1034
+ this.globParts = this.preprocess(rawGlobParts);
1035
+ this.debug(this.pattern, this.globParts);
1036
+ let set = this.globParts.map((s, _, __) => {
1037
+ if (this.isWindows && this.windowsNoMagicRoot) {
1038
+ const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
1039
+ const isDrive = /^[a-z]:/i.test(s[0]);
1040
+ if (isUNC) {
1041
+ return [...s.slice(0, 4), ...s.slice(4).map((ss) => this.parse(ss))];
1042
+ } else if (isDrive) {
1043
+ return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
1044
+ }
1045
+ }
1046
+ return s.map((ss) => this.parse(ss));
1047
+ });
1048
+ this.debug(this.pattern, set);
1049
+ this.set = set.filter((s) => s.indexOf(false) === -1);
1050
+ if (this.isWindows) {
1051
+ for (let i = 0; i < this.set.length; i++) {
1052
+ const p = this.set[i];
1053
+ if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && typeof p[3] === "string" && /^[a-z]:$/i.test(p[3])) {
1054
+ p[2] = "?";
1055
+ }
1056
+ }
1057
+ }
1058
+ this.debug(this.pattern, this.set);
1059
+ }
1060
+ // various transforms to equivalent pattern sets that are
1061
+ // faster to process in a filesystem walk. The goal is to
1062
+ // eliminate what we can, and push all ** patterns as far
1063
+ // to the right as possible, even if it increases the number
1064
+ // of patterns that we have to process.
1065
+ preprocess(globParts) {
1066
+ if (this.options.noglobstar) {
1067
+ for (let i = 0; i < globParts.length; i++) {
1068
+ for (let j = 0; j < globParts[i].length; j++) {
1069
+ if (globParts[i][j] === "**") {
1070
+ globParts[i][j] = "*";
1071
+ }
1072
+ }
1073
+ }
1074
+ }
1075
+ const { optimizationLevel = 1 } = this.options;
1076
+ if (optimizationLevel >= 2) {
1077
+ globParts = this.firstPhasePreProcess(globParts);
1078
+ globParts = this.secondPhasePreProcess(globParts);
1079
+ } else if (optimizationLevel >= 1) {
1080
+ globParts = this.levelOneOptimize(globParts);
1081
+ } else {
1082
+ globParts = this.adjascentGlobstarOptimize(globParts);
1083
+ }
1084
+ return globParts;
1085
+ }
1086
+ // just get rid of adjascent ** portions
1087
+ adjascentGlobstarOptimize(globParts) {
1088
+ return globParts.map((parts) => {
1089
+ let gs = -1;
1090
+ while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
1091
+ let i = gs;
1092
+ while (parts[i + 1] === "**") {
1093
+ i++;
1094
+ }
1095
+ if (i !== gs) {
1096
+ parts.splice(gs, i - gs);
1097
+ }
1098
+ }
1099
+ return parts;
1100
+ });
1101
+ }
1102
+ // get rid of adjascent ** and resolve .. portions
1103
+ levelOneOptimize(globParts) {
1104
+ return globParts.map((parts) => {
1105
+ parts = parts.reduce((set, part) => {
1106
+ const prev = set[set.length - 1];
1107
+ if (part === "**" && prev === "**") {
1108
+ return set;
1109
+ }
1110
+ if (part === "..") {
1111
+ if (prev && prev !== ".." && prev !== "." && prev !== "**") {
1112
+ set.pop();
1113
+ return set;
1114
+ }
1115
+ }
1116
+ set.push(part);
1117
+ return set;
1118
+ }, []);
1119
+ return parts.length === 0 ? [""] : parts;
1120
+ });
1121
+ }
1122
+ levelTwoFileOptimize(parts) {
1123
+ if (!Array.isArray(parts)) {
1124
+ parts = this.slashSplit(parts);
1125
+ }
1126
+ let didSomething = false;
1127
+ do {
1128
+ didSomething = false;
1129
+ if (!this.preserveMultipleSlashes) {
1130
+ for (let i = 1; i < parts.length - 1; i++) {
1131
+ const p = parts[i];
1132
+ if (i === 1 && p === "" && parts[0] === "")
1133
+ continue;
1134
+ if (p === "." || p === "") {
1135
+ didSomething = true;
1136
+ parts.splice(i, 1);
1137
+ i--;
1138
+ }
1139
+ }
1140
+ if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
1141
+ didSomething = true;
1142
+ parts.pop();
1143
+ }
1144
+ }
1145
+ let dd = 0;
1146
+ while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
1147
+ const p = parts[dd - 1];
1148
+ if (p && p !== "." && p !== ".." && p !== "**") {
1149
+ didSomething = true;
1150
+ parts.splice(dd - 1, 2);
1151
+ dd -= 2;
1152
+ }
1153
+ }
1154
+ } while (didSomething);
1155
+ return parts.length === 0 ? [""] : parts;
1156
+ }
1157
+ // First phase: single-pattern processing
1158
+ // <pre> is 1 or more portions
1159
+ // <rest> is 1 or more portions
1160
+ // <p> is any portion other than ., .., '', or **
1161
+ // <e> is . or ''
1162
+ //
1163
+ // **/.. is *brutal* for filesystem walking performance, because
1164
+ // it effectively resets the recursive walk each time it occurs,
1165
+ // and ** cannot be reduced out by a .. pattern part like a regexp
1166
+ // or most strings (other than .., ., and '') can be.
1167
+ //
1168
+ // <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
1169
+ // <pre>/<e>/<rest> -> <pre>/<rest>
1170
+ // <pre>/<p>/../<rest> -> <pre>/<rest>
1171
+ // **/**/<rest> -> **/<rest>
1172
+ //
1173
+ // **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
1174
+ // this WOULD be allowed if ** did follow symlinks, or * didn't
1175
+ firstPhasePreProcess(globParts) {
1176
+ let didSomething = false;
1177
+ do {
1178
+ didSomething = false;
1179
+ for (let parts of globParts) {
1180
+ let gs = -1;
1181
+ while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
1182
+ let gss = gs;
1183
+ while (parts[gss + 1] === "**") {
1184
+ gss++;
1185
+ }
1186
+ if (gss > gs) {
1187
+ parts.splice(gs + 1, gss - gs);
1188
+ }
1189
+ let next = parts[gs + 1];
1190
+ const p = parts[gs + 2];
1191
+ const p2 = parts[gs + 3];
1192
+ if (next !== "..")
1193
+ continue;
1194
+ if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") {
1195
+ continue;
1196
+ }
1197
+ didSomething = true;
1198
+ parts.splice(gs, 1);
1199
+ const other = parts.slice(0);
1200
+ other[gs] = "**";
1201
+ globParts.push(other);
1202
+ gs--;
1203
+ }
1204
+ if (!this.preserveMultipleSlashes) {
1205
+ for (let i = 1; i < parts.length - 1; i++) {
1206
+ const p = parts[i];
1207
+ if (i === 1 && p === "" && parts[0] === "")
1208
+ continue;
1209
+ if (p === "." || p === "") {
1210
+ didSomething = true;
1211
+ parts.splice(i, 1);
1212
+ i--;
1213
+ }
1214
+ }
1215
+ if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
1216
+ didSomething = true;
1217
+ parts.pop();
1218
+ }
1219
+ }
1220
+ let dd = 0;
1221
+ while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
1222
+ const p = parts[dd - 1];
1223
+ if (p && p !== "." && p !== ".." && p !== "**") {
1224
+ didSomething = true;
1225
+ const needDot = dd === 1 && parts[dd + 1] === "**";
1226
+ const splin = needDot ? ["."] : [];
1227
+ parts.splice(dd - 1, 2, ...splin);
1228
+ if (parts.length === 0)
1229
+ parts.push("");
1230
+ dd -= 2;
1231
+ }
1232
+ }
1233
+ }
1234
+ } while (didSomething);
1235
+ return globParts;
1236
+ }
1237
+ // second phase: multi-pattern dedupes
1238
+ // {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
1239
+ // {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
1240
+ // {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest>
1241
+ //
1242
+ // {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
1243
+ // ^-- not valid because ** doens't follow symlinks
1244
+ secondPhasePreProcess(globParts) {
1245
+ for (let i = 0; i < globParts.length - 1; i++) {
1246
+ for (let j = i + 1; j < globParts.length; j++) {
1247
+ const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
1248
+ if (matched) {
1249
+ globParts[i] = [];
1250
+ globParts[j] = matched;
1251
+ break;
1252
+ }
1253
+ }
1254
+ }
1255
+ return globParts.filter((gs) => gs.length);
1256
+ }
1257
+ partsMatch(a, b, emptyGSMatch = false) {
1258
+ let ai = 0;
1259
+ let bi = 0;
1260
+ let result = [];
1261
+ let which = "";
1262
+ while (ai < a.length && bi < b.length) {
1263
+ if (a[ai] === b[bi]) {
1264
+ result.push(which === "b" ? b[bi] : a[ai]);
1265
+ ai++;
1266
+ bi++;
1267
+ } else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1]) {
1268
+ result.push(a[ai]);
1269
+ ai++;
1270
+ } else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1]) {
1271
+ result.push(b[bi]);
1272
+ bi++;
1273
+ } else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
1274
+ if (which === "b")
1275
+ return false;
1276
+ which = "a";
1277
+ result.push(a[ai]);
1278
+ ai++;
1279
+ bi++;
1280
+ } else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
1281
+ if (which === "a")
1282
+ return false;
1283
+ which = "b";
1284
+ result.push(b[bi]);
1285
+ ai++;
1286
+ bi++;
1287
+ } else {
1288
+ return false;
1289
+ }
1290
+ }
1291
+ return a.length === b.length && result;
1292
+ }
1293
+ parseNegate() {
1294
+ if (this.nonegate)
1295
+ return;
1296
+ const pattern = this.pattern;
1297
+ let negate = false;
1298
+ let negateOffset = 0;
1299
+ for (let i = 0; i < pattern.length && pattern.charAt(i) === "!"; i++) {
1300
+ negate = !negate;
1301
+ negateOffset++;
1302
+ }
1303
+ if (negateOffset)
1304
+ this.pattern = pattern.slice(negateOffset);
1305
+ this.negate = negate;
1306
+ }
1307
+ // set partial to true to test if, for example,
1308
+ // "/a/b" matches the start of "/*/b/*/d"
1309
+ // Partial means, if you run out of file before you run
1310
+ // out of pattern, then that's fine, as long as all
1311
+ // the parts match.
1312
+ matchOne(file, pattern, partial = false) {
1313
+ const options = this.options;
1314
+ if (this.isWindows) {
1315
+ const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
1316
+ const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
1317
+ const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
1318
+ const patternUNC = !patternDrive && pattern[0] === "" && pattern[1] === "" && pattern[2] === "?" && typeof pattern[3] === "string" && /^[a-z]:$/i.test(pattern[3]);
1319
+ const fdi = fileUNC ? 3 : fileDrive ? 0 : void 0;
1320
+ const pdi = patternUNC ? 3 : patternDrive ? 0 : void 0;
1321
+ if (typeof fdi === "number" && typeof pdi === "number") {
1322
+ const [fd, pd] = [file[fdi], pattern[pdi]];
1323
+ if (fd.toLowerCase() === pd.toLowerCase()) {
1324
+ pattern[pdi] = fd;
1325
+ if (pdi > fdi) {
1326
+ pattern = pattern.slice(pdi);
1327
+ } else if (fdi > pdi) {
1328
+ file = file.slice(fdi);
1329
+ }
1330
+ }
1331
+ }
1332
+ }
1333
+ const { optimizationLevel = 1 } = this.options;
1334
+ if (optimizationLevel >= 2) {
1335
+ file = this.levelTwoFileOptimize(file);
1336
+ }
1337
+ this.debug("matchOne", this, { file, pattern });
1338
+ this.debug("matchOne", file.length, pattern.length);
1339
+ for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
1340
+ this.debug("matchOne loop");
1341
+ var p = pattern[pi];
1342
+ var f = file[fi];
1343
+ this.debug(pattern, p, f);
1344
+ if (p === false) {
1345
+ return false;
1346
+ }
1347
+ if (p === GLOBSTAR) {
1348
+ this.debug("GLOBSTAR", [pattern, p, f]);
1349
+ var fr = fi;
1350
+ var pr = pi + 1;
1351
+ if (pr === pl) {
1352
+ this.debug("** at the end");
1353
+ for (; fi < fl; fi++) {
1354
+ if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".")
1355
+ return false;
1356
+ }
1357
+ return true;
1358
+ }
1359
+ while (fr < fl) {
1360
+ var swallowee = file[fr];
1361
+ this.debug("\nglobstar while", file, fr, pattern, pr, swallowee);
1362
+ if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
1363
+ this.debug("globstar found match!", fr, fl, swallowee);
1364
+ return true;
1365
+ } else {
1366
+ if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
1367
+ this.debug("dot detected!", file, fr, pattern, pr);
1368
+ break;
1369
+ }
1370
+ this.debug("globstar swallow a segment, and continue");
1371
+ fr++;
1372
+ }
1373
+ }
1374
+ if (partial) {
1375
+ this.debug("\n>>> no match, partial?", file, fr, pattern, pr);
1376
+ if (fr === fl) {
1377
+ return true;
1378
+ }
1379
+ }
1380
+ return false;
1381
+ }
1382
+ let hit;
1383
+ if (typeof p === "string") {
1384
+ hit = f === p;
1385
+ this.debug("string match", p, f, hit);
1386
+ } else {
1387
+ hit = p.test(f);
1388
+ this.debug("pattern match", p, f, hit);
1389
+ }
1390
+ if (!hit)
1391
+ return false;
1392
+ }
1393
+ if (fi === fl && pi === pl) {
1394
+ return true;
1395
+ } else if (fi === fl) {
1396
+ return partial;
1397
+ } else if (pi === pl) {
1398
+ return fi === fl - 1 && file[fi] === "";
1399
+ } else {
1400
+ throw new Error("wtf?");
1401
+ }
1402
+ }
1403
+ braceExpand() {
1404
+ return braceExpand(this.pattern, this.options);
1405
+ }
1406
+ parse(pattern) {
1407
+ assertValidPattern(pattern);
1408
+ const options = this.options;
1409
+ if (pattern === "**")
1410
+ return GLOBSTAR;
1411
+ if (pattern === "")
1412
+ return "";
1413
+ let m;
1414
+ let fastTest = null;
1415
+ if (m = pattern.match(starRE)) {
1416
+ fastTest = options.dot ? starTestDot : starTest;
1417
+ } else if (m = pattern.match(starDotExtRE)) {
1418
+ fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]);
1419
+ } else if (m = pattern.match(qmarksRE)) {
1420
+ fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m);
1421
+ } else if (m = pattern.match(starDotStarRE)) {
1422
+ fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
1423
+ } else if (m = pattern.match(dotStarRE)) {
1424
+ fastTest = dotStarTest;
1425
+ }
1426
+ const re = AST.fromGlob(pattern, this.options).toMMPattern();
1427
+ if (fastTest && typeof re === "object") {
1428
+ Reflect.defineProperty(re, "test", { value: fastTest });
1429
+ }
1430
+ return re;
1431
+ }
1432
+ makeRe() {
1433
+ if (this.regexp || this.regexp === false)
1434
+ return this.regexp;
1435
+ const set = this.set;
1436
+ if (!set.length) {
1437
+ this.regexp = false;
1438
+ return this.regexp;
1439
+ }
1440
+ const options = this.options;
1441
+ const twoStar = options.noglobstar ? star2 : options.dot ? twoStarDot : twoStarNoDot;
1442
+ const flags = new Set(options.nocase ? ["i"] : []);
1443
+ let re = set.map((pattern) => {
1444
+ const pp = pattern.map((p) => {
1445
+ if (p instanceof RegExp) {
1446
+ for (const f of p.flags.split(""))
1447
+ flags.add(f);
1448
+ }
1449
+ return typeof p === "string" ? regExpEscape2(p) : p === GLOBSTAR ? GLOBSTAR : p._src;
1450
+ });
1451
+ pp.forEach((p, i) => {
1452
+ const next = pp[i + 1];
1453
+ const prev = pp[i - 1];
1454
+ if (p !== GLOBSTAR || prev === GLOBSTAR) {
1455
+ return;
1456
+ }
1457
+ if (prev === void 0) {
1458
+ if (next !== void 0 && next !== GLOBSTAR) {
1459
+ pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
1460
+ } else {
1461
+ pp[i] = twoStar;
1462
+ }
1463
+ } else if (next === void 0) {
1464
+ pp[i - 1] = prev + "(?:\\/|" + twoStar + ")?";
1465
+ } else if (next !== GLOBSTAR) {
1466
+ pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
1467
+ pp[i + 1] = GLOBSTAR;
1468
+ }
1469
+ });
1470
+ return pp.filter((p) => p !== GLOBSTAR).join("/");
1471
+ }).join("|");
1472
+ const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
1473
+ re = "^" + open + re + close + "$";
1474
+ if (this.negate)
1475
+ re = "^(?!" + re + ").+$";
1476
+ try {
1477
+ this.regexp = new RegExp(re, [...flags].join(""));
1478
+ } catch (ex) {
1479
+ this.regexp = false;
1480
+ }
1481
+ return this.regexp;
1482
+ }
1483
+ slashSplit(p) {
1484
+ if (this.preserveMultipleSlashes) {
1485
+ return p.split("/");
1486
+ } else if (this.isWindows && /^\/\/[^\/]+/.test(p)) {
1487
+ return ["", ...p.split(/\/+/)];
1488
+ } else {
1489
+ return p.split(/\/+/);
1490
+ }
1491
+ }
1492
+ match(f, partial = this.partial) {
1493
+ this.debug("match", f, this.pattern);
1494
+ if (this.comment) {
1495
+ return false;
1496
+ }
1497
+ if (this.empty) {
1498
+ return f === "";
1499
+ }
1500
+ if (f === "/" && partial) {
1501
+ return true;
1502
+ }
1503
+ const options = this.options;
1504
+ if (this.isWindows) {
1505
+ f = f.split("\\").join("/");
1506
+ }
1507
+ const ff = this.slashSplit(f);
1508
+ this.debug(this.pattern, "split", ff);
1509
+ const set = this.set;
1510
+ this.debug(this.pattern, "set", set);
1511
+ let filename = ff[ff.length - 1];
1512
+ if (!filename) {
1513
+ for (let i = ff.length - 2; !filename && i >= 0; i--) {
1514
+ filename = ff[i];
1515
+ }
1516
+ }
1517
+ for (let i = 0; i < set.length; i++) {
1518
+ const pattern = set[i];
1519
+ let file = ff;
1520
+ if (options.matchBase && pattern.length === 1) {
1521
+ file = [filename];
1522
+ }
1523
+ const hit = this.matchOne(file, pattern, partial);
1524
+ if (hit) {
1525
+ if (options.flipNegate) {
1526
+ return true;
1527
+ }
1528
+ return !this.negate;
1529
+ }
1530
+ }
1531
+ if (options.flipNegate) {
1532
+ return false;
1533
+ }
1534
+ return this.negate;
1535
+ }
1536
+ static defaults(def) {
1537
+ return minimatch.defaults(def).Minimatch;
1538
+ }
1539
+ };
1540
+ minimatch.AST = AST;
1541
+ minimatch.Minimatch = Minimatch;
1542
+ minimatch.escape = escape;
1543
+ minimatch.unescape = unescape;
1544
+
1545
+ // ../agent/dist/chunk-KTNYN62L.js
1546
+ var Glob;
1547
+ ((Glob2) => {
1548
+ async function scan(context, pattern, options = {}) {
1549
+ return context.fs.glob(pattern, {
1550
+ cwd: options.cwd,
1551
+ absolute: options.absolute,
1552
+ dot: options.dot,
1553
+ follow: options.symlink ?? false,
1554
+ nodir: options.include !== "all"
1555
+ });
1556
+ }
1557
+ Glob2.scan = scan;
1558
+ function match2(pattern, filepath) {
1559
+ return minimatch(filepath, pattern, { dot: true });
1560
+ }
1561
+ Glob2.match = match2;
1562
+ })(Glob || (Glob = {}));
1563
+
1564
+ export {
1565
+ Glob
1566
+ };