opfs-worker 1.3.0 → 1.3.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.
@@ -0,0 +1,1423 @@
1
+ const lt = {
2
+ ENOENT: -2,
3
+ // No such file or directory
4
+ EISDIR: -21,
5
+ // Is a directory
6
+ ENOTDIR: -20,
7
+ // Not a directory
8
+ EACCES: -13,
9
+ // Permission denied
10
+ EEXIST: -17,
11
+ // File exists
12
+ ENOTEMPTY: -39,
13
+ // Directory not empty
14
+ EINVAL: -22,
15
+ // Invalid argument
16
+ EIO: -5,
17
+ // I/O error
18
+ ENOSPC: -28,
19
+ // No space left on device
20
+ EBUSY: -16,
21
+ // Device or resource busy
22
+ EINTR: -4,
23
+ // Interrupted system call
24
+ ENOTSUP: -95,
25
+ // Operation not supported
26
+ ERANGE: -34,
27
+ // Result too large
28
+ EBADF: -9,
29
+ // Bad file descriptor
30
+ EROOT: -1
31
+ // Custom: Cannot remove root directory
32
+ };
33
+ class y extends Error {
34
+ errno;
35
+ syscall;
36
+ path;
37
+ constructor(t, e, n, r, i) {
38
+ super(t, { cause: i }), this.name = e, this.errno = lt[e] || -1, this.path = n, this.syscall = r;
39
+ }
40
+ }
41
+ class ht extends y {
42
+ constructor(t) {
43
+ super("OPFS is not supported in this browser", "ENOTSUP", void 0, void 0, t);
44
+ }
45
+ }
46
+ class Te extends y {
47
+ constructor(t, e, n) {
48
+ super(t, "INVALID_PATH", e, "access", n);
49
+ }
50
+ }
51
+ class Z extends y {
52
+ constructor(t, e, n) {
53
+ const r = {
54
+ file: `File not found: ${e}`,
55
+ directory: `Directory not found: ${e}`,
56
+ source: `Source does not exist: ${e}`
57
+ };
58
+ super(r[t], "ENOENT", e, "access", n);
59
+ }
60
+ }
61
+ class ut extends y {
62
+ constructor(t, e, n) {
63
+ super(`Permission denied for ${e} on: ${t}`, "EACCES", t, e, n);
64
+ }
65
+ }
66
+ class ft extends y {
67
+ constructor(t, e, n) {
68
+ super(t, "ENOSPC", e, "write", n);
69
+ }
70
+ }
71
+ class pt extends y {
72
+ constructor(t, e) {
73
+ super(`File is busy: ${t}`, "EBUSY", t, "open", e);
74
+ }
75
+ }
76
+ class k extends y {
77
+ constructor(t, e, n) {
78
+ const r = t === "directory" ? `Is a directory: ${e}` : `Not a directory: ${e}`, i = t === "directory" ? "EISDIR" : "ENOTDIR";
79
+ super(r, i, e, "access", n);
80
+ }
81
+ }
82
+ class b extends y {
83
+ constructor(t, e, n, r) {
84
+ const i = {
85
+ argument: "EINVAL",
86
+ format: "INVALID_FORMAT",
87
+ descriptor: "EBADF",
88
+ overflow: "ERANGE"
89
+ };
90
+ super(e, i[t], n, "validate", r);
91
+ }
92
+ }
93
+ class dt extends y {
94
+ constructor(t, e) {
95
+ super(`Operation aborted: ${t}`, "EINTR", t, "interrupt", e);
96
+ }
97
+ }
98
+ class U extends y {
99
+ constructor(t, e, n) {
100
+ super(t, "EIO", e, "io", n);
101
+ }
102
+ }
103
+ class gt extends y {
104
+ constructor(t, e) {
105
+ super(`Operation not supported: ${t}`, "ENOTSUP", t, "operation", e);
106
+ }
107
+ }
108
+ class z extends y {
109
+ constructor(t, e, n) {
110
+ const r = {
111
+ RM_FAILED: `Failed to remove entry: ${e}`,
112
+ ENOTEMPTY: `Directory not empty: ${e}. Use recursive option to force removal.`,
113
+ EROOT: "Cannot remove root directory"
114
+ };
115
+ super(r[t] || `Directory operation failed: ${e}`, t, e, "unlink", n);
116
+ }
117
+ }
118
+ class Me extends y {
119
+ constructor(t, e) {
120
+ super("Failed to initialize OPFS", "INIT_FAILED", t, "init", e);
121
+ }
122
+ }
123
+ class Re extends y {
124
+ constructor(t, e, n) {
125
+ super(`Failed to ${t}: ${e}`, `${t.toUpperCase()}_FAILED`, e, t, n);
126
+ }
127
+ }
128
+ class Ce extends y {
129
+ constructor(t, e) {
130
+ super(`Destination already exists: ${t}`, "EEXIST", t, "open", e);
131
+ }
132
+ }
133
+ function Pe(s, t, e, n) {
134
+ const r = `${s.toUpperCase()}_FAILED`;
135
+ return new y(`Failed to ${s} file descriptor: ${t}`, r, e, s, n);
136
+ }
137
+ function mt(s, t) {
138
+ const e = t?.path, n = t?.isDirectory;
139
+ switch (s.name) {
140
+ case "InvalidStateError":
141
+ return new pt(e || "unknown", s);
142
+ case "QuotaExceededError":
143
+ return new ft(`No space left on device: ${e || "unknown"}`, e, s);
144
+ case "NotFoundError":
145
+ return new Z("file", e, s);
146
+ case "TypeMismatchError":
147
+ return n !== void 0 ? n ? new k("directory", e || "unknown", s) : new k("file", e || "unknown", s) : new b("argument", `Type mismatch: ${e || "unknown"}`, e, s);
148
+ case "NotAllowedError":
149
+ case "SecurityError":
150
+ return new ut(e, "unknown", s);
151
+ case "InvalidModificationError":
152
+ return new b("argument", `Invalid modification: ${e || "unknown"}`, e, s);
153
+ case "AbortError":
154
+ return new dt(e || "unknown", s);
155
+ case "OperationError":
156
+ return new U(`Operation failed: ${e || "unknown"}`, e, s);
157
+ case "TypeError":
158
+ return new gt(e || "unknown", s);
159
+ default:
160
+ return new U(`I/O error: ${e || "unknown"}`, e, s);
161
+ }
162
+ }
163
+ const wt = [
164
+ // Images
165
+ ".jpg",
166
+ ".jpeg",
167
+ ".png",
168
+ ".gif",
169
+ ".bmp",
170
+ ".webp",
171
+ ".ico",
172
+ ".tiff",
173
+ ".tga",
174
+ // Audio
175
+ ".mp3",
176
+ ".wav",
177
+ ".ogg",
178
+ ".flac",
179
+ ".aac",
180
+ ".wma",
181
+ ".m4a",
182
+ // Video
183
+ ".mp4",
184
+ ".avi",
185
+ ".mov",
186
+ ".wmv",
187
+ ".flv",
188
+ ".webm",
189
+ ".mkv",
190
+ ".m4v",
191
+ // Documents
192
+ ".pdf",
193
+ ".doc",
194
+ ".docx",
195
+ ".xls",
196
+ ".xlsx",
197
+ ".ppt",
198
+ ".pptx",
199
+ // Archives
200
+ ".zip",
201
+ ".rar",
202
+ ".7z",
203
+ ".tar",
204
+ ".gz",
205
+ ".bz2",
206
+ // Executables
207
+ ".exe",
208
+ ".dll",
209
+ ".so",
210
+ ".dylib",
211
+ // Other binary formats
212
+ ".dat",
213
+ ".db",
214
+ ".sqlite",
215
+ ".bin",
216
+ ".obj",
217
+ ".fbx",
218
+ ".3ds"
219
+ ];
220
+ function Ie(s) {
221
+ const t = s.lastIndexOf(".");
222
+ if (t <= 0)
223
+ return !0;
224
+ const e = s.slice(t).toLowerCase();
225
+ return wt.includes(e);
226
+ }
227
+ function yt(s, t = "utf-8") {
228
+ switch (t) {
229
+ case "utf8":
230
+ case "utf-8":
231
+ return new TextEncoder().encode(s);
232
+ case "utf16le":
233
+ case "utf-16le":
234
+ case "ucs2":
235
+ case "ucs-2":
236
+ return Et(s);
237
+ case "ascii":
238
+ return Ot(s);
239
+ case "latin1":
240
+ return St(s);
241
+ case "binary":
242
+ return Uint8Array.from(s, (e) => e.charCodeAt(0));
243
+ case "base64":
244
+ return Uint8Array.from(atob(s), (e) => e.charCodeAt(0));
245
+ case "hex":
246
+ if (!/^[\da-f]+$/i.test(s) || s.length % 2 !== 0)
247
+ throw new b("format", "Invalid hex string");
248
+ return Uint8Array.from(s.match(/.{1,2}/g).map((e) => parseInt(e, 16)));
249
+ default:
250
+ return console.warn("Encoding not supported, falling back to UTF-8"), new TextEncoder().encode(s);
251
+ }
252
+ }
253
+ function De(s, t = "utf-8") {
254
+ switch (t) {
255
+ case "utf8":
256
+ case "utf-8":
257
+ return new TextDecoder().decode(s);
258
+ case "utf16le":
259
+ case "utf-16le":
260
+ case "ucs2":
261
+ case "ucs-2":
262
+ return xt(s);
263
+ case "latin1":
264
+ return String.fromCharCode(...s);
265
+ case "ascii":
266
+ return String.fromCharCode(...s.map((e) => e & 127));
267
+ case "base64":
268
+ return btoa(String.fromCharCode(...s));
269
+ case "hex":
270
+ return Array.from(s).map((e) => e.toString(16).padStart(2, "0")).join("");
271
+ default:
272
+ return console.warn("Unsupported encoding, falling back to UTF-8"), new TextDecoder().decode(s);
273
+ }
274
+ }
275
+ function Et(s) {
276
+ const t = new Uint8Array(s.length * 2);
277
+ for (let e = 0; e < s.length; e++) {
278
+ const n = s.charCodeAt(e);
279
+ t[e * 2] = n & 255, t[e * 2 + 1] = n >> 8;
280
+ }
281
+ return t;
282
+ }
283
+ function xt(s) {
284
+ s.length % 2 !== 0 && (console.warn("Invalid UTF-16LE buffer length, truncating last byte"), s = s.slice(0, s.length - 1));
285
+ const t = new Uint16Array(s.buffer, s.byteOffset, s.byteLength / 2);
286
+ return String.fromCharCode(...t);
287
+ }
288
+ function St(s) {
289
+ const t = new Uint8Array(s.length);
290
+ for (let e = 0; e < s.length; e++)
291
+ t[e] = s.charCodeAt(e) & 255;
292
+ return t;
293
+ }
294
+ function Ot(s) {
295
+ const t = new Uint8Array(s.length);
296
+ for (let e = 0; e < s.length; e++)
297
+ t[e] = s.charCodeAt(e) & 127;
298
+ return t;
299
+ }
300
+ var At = /* @__PURE__ */ ((s) => (s.Added = "added", s.Changed = "changed", s.Removed = "removed", s))(At || {});
301
+ const J = (s, t, e) => {
302
+ const n = s instanceof RegExp ? B(s, e) : s, r = t instanceof RegExp ? B(t, e) : t, i = n !== null && r != null && Nt(n, r, e);
303
+ return i && {
304
+ start: i[0],
305
+ end: i[1],
306
+ pre: e.slice(0, i[0]),
307
+ body: e.slice(i[0] + n.length, i[1]),
308
+ post: e.slice(i[1] + r.length)
309
+ };
310
+ }, B = (s, t) => {
311
+ const e = t.match(s);
312
+ return e ? e[0] : null;
313
+ }, Nt = (s, t, e) => {
314
+ let n, r, i, o, a, l = e.indexOf(s), h = e.indexOf(t, l + 1), c = l;
315
+ if (l >= 0 && h > 0) {
316
+ if (s === t)
317
+ return [l, h];
318
+ for (n = [], i = e.length; c >= 0 && !a; ) {
319
+ if (c === l)
320
+ n.push(c), l = e.indexOf(s, c + 1);
321
+ else if (n.length === 1) {
322
+ const p = n.pop();
323
+ p !== void 0 && (a = [p, h]);
324
+ } else
325
+ r = n.pop(), r !== void 0 && r < i && (i = r, o = h), h = e.indexOf(t, c + 1);
326
+ c = l < h && l >= 0 ? l : h;
327
+ }
328
+ n.length && o !== void 0 && (a = [i, o]);
329
+ }
330
+ return a;
331
+ }, X = "\0SLASH" + Math.random() + "\0", K = "\0OPEN" + Math.random() + "\0", F = "\0CLOSE" + Math.random() + "\0", Q = "\0COMMA" + Math.random() + "\0", tt = "\0PERIOD" + Math.random() + "\0", bt = new RegExp(X, "g"), vt = new RegExp(K, "g"), $t = new RegExp(F, "g"), Tt = new RegExp(Q, "g"), Mt = new RegExp(tt, "g"), Rt = /\\\\/g, Ct = /\\{/g, Pt = /\\}/g, It = /\\,/g, Dt = /\\./g;
332
+ function L(s) {
333
+ return isNaN(s) ? s.charCodeAt(0) : parseInt(s, 10);
334
+ }
335
+ function Lt(s) {
336
+ return s.replace(Rt, X).replace(Ct, K).replace(Pt, F).replace(It, Q).replace(Dt, tt);
337
+ }
338
+ function kt(s) {
339
+ return s.replace(bt, "\\").replace(vt, "{").replace($t, "}").replace(Tt, ",").replace(Mt, ".");
340
+ }
341
+ function et(s) {
342
+ if (!s)
343
+ return [""];
344
+ const t = [], e = J("{", "}", s);
345
+ if (!e)
346
+ return s.split(",");
347
+ const { pre: n, body: r, post: i } = e, o = n.split(",");
348
+ o[o.length - 1] += "{" + r + "}";
349
+ const a = et(i);
350
+ return i.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
351
+ }
352
+ function Ft(s) {
353
+ return s ? (s.slice(0, 2) === "{}" && (s = "\\{\\}" + s.slice(2)), M(Lt(s), !0).map(kt)) : [];
354
+ }
355
+ function jt(s) {
356
+ return "{" + s + "}";
357
+ }
358
+ function Wt(s) {
359
+ return /^-?0\d/.test(s);
360
+ }
361
+ function Ut(s, t) {
362
+ return s <= t;
363
+ }
364
+ function zt(s, t) {
365
+ return s >= t;
366
+ }
367
+ function M(s, t) {
368
+ const e = [], n = J("{", "}", s);
369
+ if (!n)
370
+ return [s];
371
+ const r = n.pre, i = n.post.length ? M(n.post, !1) : [""];
372
+ if (/\$$/.test(n.pre))
373
+ for (let o = 0; o < i.length; o++) {
374
+ const a = r + "{" + n.body + "}" + i[o];
375
+ e.push(a);
376
+ }
377
+ else {
378
+ const o = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body), a = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body), l = o || a, h = n.body.indexOf(",") >= 0;
379
+ if (!l && !h)
380
+ return n.post.match(/,(?!,).*\}/) ? (s = n.pre + "{" + n.body + F + n.post, M(s)) : [s];
381
+ let c;
382
+ if (l)
383
+ c = n.body.split(/\.\./);
384
+ else if (c = et(n.body), c.length === 1 && c[0] !== void 0 && (c = M(c[0], !1).map(jt), c.length === 1))
385
+ return i.map((f) => n.pre + c[0] + f);
386
+ let p;
387
+ if (l && c[0] !== void 0 && c[1] !== void 0) {
388
+ const f = L(c[0]), u = L(c[1]), g = Math.max(c[0].length, c[1].length);
389
+ let d = c.length === 3 && c[2] !== void 0 ? Math.abs(L(c[2])) : 1, x = Ut;
390
+ u < f && (d *= -1, x = zt);
391
+ const v = c.some(Wt);
392
+ p = [];
393
+ for (let S = f; x(S, u); S += d) {
394
+ let m;
395
+ if (a)
396
+ m = String.fromCharCode(S), m === "\\" && (m = "");
397
+ else if (m = String(S), v) {
398
+ const $ = g - m.length;
399
+ if ($ > 0) {
400
+ const C = new Array($ + 1).join("0");
401
+ S < 0 ? m = "-" + C + m.slice(1) : m = C + m;
402
+ }
403
+ }
404
+ p.push(m);
405
+ }
406
+ } else {
407
+ p = [];
408
+ for (let f = 0; f < c.length; f++)
409
+ p.push.apply(p, M(c[f], !1));
410
+ }
411
+ for (let f = 0; f < p.length; f++)
412
+ for (let u = 0; u < i.length; u++) {
413
+ const g = r + p[f] + i[u];
414
+ (!t || l || g) && e.push(g);
415
+ }
416
+ }
417
+ return e;
418
+ }
419
+ const Bt = 1024 * 64, I = (s) => {
420
+ if (typeof s != "string")
421
+ throw new TypeError("invalid pattern");
422
+ if (s.length > Bt)
423
+ throw new TypeError("pattern is too long");
424
+ }, _t = {
425
+ "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", !0],
426
+ "[:alpha:]": ["\\p{L}\\p{Nl}", !0],
427
+ "[:ascii:]": ["\\x00-\\x7f", !1],
428
+ "[:blank:]": ["\\p{Zs}\\t", !0],
429
+ "[:cntrl:]": ["\\p{Cc}", !0],
430
+ "[:digit:]": ["\\p{Nd}", !0],
431
+ "[:graph:]": ["\\p{Z}\\p{C}", !0, !0],
432
+ "[:lower:]": ["\\p{Ll}", !0],
433
+ "[:print:]": ["\\p{C}", !0],
434
+ "[:punct:]": ["\\p{P}", !0],
435
+ "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", !0],
436
+ "[:upper:]": ["\\p{Lu}", !0],
437
+ "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", !0],
438
+ "[:xdigit:]": ["A-Fa-f0-9", !1]
439
+ }, T = (s) => s.replace(/[[\]\\-]/g, "\\$&"), qt = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), _ = (s) => s.join(""), Gt = (s, t) => {
440
+ const e = t;
441
+ if (s.charAt(e) !== "[")
442
+ throw new Error("not in a brace expression");
443
+ const n = [], r = [];
444
+ let i = e + 1, o = !1, a = !1, l = !1, h = !1, c = e, p = "";
445
+ t: for (; i < s.length; ) {
446
+ const d = s.charAt(i);
447
+ if ((d === "!" || d === "^") && i === e + 1) {
448
+ h = !0, i++;
449
+ continue;
450
+ }
451
+ if (d === "]" && o && !l) {
452
+ c = i + 1;
453
+ break;
454
+ }
455
+ if (o = !0, d === "\\" && !l) {
456
+ l = !0, i++;
457
+ continue;
458
+ }
459
+ if (d === "[" && !l) {
460
+ for (const [x, [N, v, S]] of Object.entries(_t))
461
+ if (s.startsWith(x, i)) {
462
+ if (p)
463
+ return ["$.", !1, s.length - e, !0];
464
+ i += x.length, S ? r.push(N) : n.push(N), a = a || v;
465
+ continue t;
466
+ }
467
+ }
468
+ if (l = !1, p) {
469
+ d > p ? n.push(T(p) + "-" + T(d)) : d === p && n.push(T(d)), p = "", i++;
470
+ continue;
471
+ }
472
+ if (s.startsWith("-]", i + 1)) {
473
+ n.push(T(d + "-")), i += 2;
474
+ continue;
475
+ }
476
+ if (s.startsWith("-", i + 1)) {
477
+ p = d, i += 2;
478
+ continue;
479
+ }
480
+ n.push(T(d)), i++;
481
+ }
482
+ if (c < i)
483
+ return ["", !1, 0, !1];
484
+ if (!n.length && !r.length)
485
+ return ["$.", !1, s.length - e, !0];
486
+ if (r.length === 0 && n.length === 1 && /^\\?.$/.test(n[0]) && !h) {
487
+ const d = n[0].length === 2 ? n[0].slice(-1) : n[0];
488
+ return [qt(d), !1, c - e, !1];
489
+ }
490
+ const f = "[" + (h ? "^" : "") + _(n) + "]", u = "[" + (h ? "" : "^") + _(r) + "]";
491
+ return [n.length && r.length ? "(" + f + "|" + u + ")" : n.length ? f : u, a, c - e, !0];
492
+ }, R = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1"), Ht = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), q = (s) => Ht.has(s), Vt = "(?!(?:^|/)\\.\\.?(?:$|/))", P = "(?!\\.)", Yt = /* @__PURE__ */ new Set(["[", "."]), Zt = /* @__PURE__ */ new Set(["..", "."]), Jt = new Set("().*{}+?[]^$\\!"), Xt = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), j = "[^/]", G = j + "*?", H = j + "+?";
493
+ class E {
494
+ type;
495
+ #s;
496
+ #n;
497
+ #i = !1;
498
+ #t = [];
499
+ #e;
500
+ #o;
501
+ #a;
502
+ #c = !1;
503
+ #r;
504
+ #l;
505
+ // set to true if it's an extglob with no children
506
+ // (which really means one child of '')
507
+ #u = !1;
508
+ constructor(t, e, n = {}) {
509
+ this.type = t, t && (this.#n = !0), this.#e = e, this.#s = this.#e ? this.#e.#s : this, this.#r = this.#s === this ? n : this.#s.#r, this.#a = this.#s === this ? [] : this.#s.#a, t === "!" && !this.#s.#c && this.#a.push(this), this.#o = this.#e ? this.#e.#t.length : 0;
510
+ }
511
+ get hasMagic() {
512
+ if (this.#n !== void 0)
513
+ return this.#n;
514
+ for (const t of this.#t)
515
+ if (typeof t != "string" && (t.type || t.hasMagic))
516
+ return this.#n = !0;
517
+ return this.#n;
518
+ }
519
+ // reconstructs the pattern
520
+ toString() {
521
+ return this.#l !== void 0 ? this.#l : this.type ? this.#l = this.type + "(" + this.#t.map((t) => String(t)).join("|") + ")" : this.#l = this.#t.map((t) => String(t)).join("");
522
+ }
523
+ #p() {
524
+ if (this !== this.#s)
525
+ throw new Error("should only call on root");
526
+ if (this.#c)
527
+ return this;
528
+ this.toString(), this.#c = !0;
529
+ let t;
530
+ for (; t = this.#a.pop(); ) {
531
+ if (t.type !== "!")
532
+ continue;
533
+ let e = t, n = e.#e;
534
+ for (; n; ) {
535
+ for (let r = e.#o + 1; !n.type && r < n.#t.length; r++)
536
+ for (const i of t.#t) {
537
+ if (typeof i == "string")
538
+ throw new Error("string part in extglob AST??");
539
+ i.copyIn(n.#t[r]);
540
+ }
541
+ e = n, n = e.#e;
542
+ }
543
+ }
544
+ return this;
545
+ }
546
+ push(...t) {
547
+ for (const e of t)
548
+ if (e !== "") {
549
+ if (typeof e != "string" && !(e instanceof E && e.#e === this))
550
+ throw new Error("invalid part: " + e);
551
+ this.#t.push(e);
552
+ }
553
+ }
554
+ toJSON() {
555
+ const t = this.type === null ? this.#t.slice().map((e) => typeof e == "string" ? e : e.toJSON()) : [this.type, ...this.#t.map((e) => e.toJSON())];
556
+ return this.isStart() && !this.type && t.unshift([]), this.isEnd() && (this === this.#s || this.#s.#c && this.#e?.type === "!") && t.push({}), t;
557
+ }
558
+ isStart() {
559
+ if (this.#s === this)
560
+ return !0;
561
+ if (!this.#e?.isStart())
562
+ return !1;
563
+ if (this.#o === 0)
564
+ return !0;
565
+ const t = this.#e;
566
+ for (let e = 0; e < this.#o; e++) {
567
+ const n = t.#t[e];
568
+ if (!(n instanceof E && n.type === "!"))
569
+ return !1;
570
+ }
571
+ return !0;
572
+ }
573
+ isEnd() {
574
+ if (this.#s === this || this.#e?.type === "!")
575
+ return !0;
576
+ if (!this.#e?.isEnd())
577
+ return !1;
578
+ if (!this.type)
579
+ return this.#e?.isEnd();
580
+ const t = this.#e ? this.#e.#t.length : 0;
581
+ return this.#o === t - 1;
582
+ }
583
+ copyIn(t) {
584
+ typeof t == "string" ? this.push(t) : this.push(t.clone(this));
585
+ }
586
+ clone(t) {
587
+ const e = new E(this.type, t);
588
+ for (const n of this.#t)
589
+ e.copyIn(n);
590
+ return e;
591
+ }
592
+ static #h(t, e, n, r) {
593
+ let i = !1, o = !1, a = -1, l = !1;
594
+ if (e.type === null) {
595
+ let u = n, g = "";
596
+ for (; u < t.length; ) {
597
+ const d = t.charAt(u++);
598
+ if (i || d === "\\") {
599
+ i = !i, g += d;
600
+ continue;
601
+ }
602
+ if (o) {
603
+ u === a + 1 ? (d === "^" || d === "!") && (l = !0) : d === "]" && !(u === a + 2 && l) && (o = !1), g += d;
604
+ continue;
605
+ } else if (d === "[") {
606
+ o = !0, a = u, l = !1, g += d;
607
+ continue;
608
+ }
609
+ if (!r.noext && q(d) && t.charAt(u) === "(") {
610
+ e.push(g), g = "";
611
+ const x = new E(d, e);
612
+ u = E.#h(t, x, u, r), e.push(x);
613
+ continue;
614
+ }
615
+ g += d;
616
+ }
617
+ return e.push(g), u;
618
+ }
619
+ let h = n + 1, c = new E(null, e);
620
+ const p = [];
621
+ let f = "";
622
+ for (; h < t.length; ) {
623
+ const u = t.charAt(h++);
624
+ if (i || u === "\\") {
625
+ i = !i, f += u;
626
+ continue;
627
+ }
628
+ if (o) {
629
+ h === a + 1 ? (u === "^" || u === "!") && (l = !0) : u === "]" && !(h === a + 2 && l) && (o = !1), f += u;
630
+ continue;
631
+ } else if (u === "[") {
632
+ o = !0, a = h, l = !1, f += u;
633
+ continue;
634
+ }
635
+ if (q(u) && t.charAt(h) === "(") {
636
+ c.push(f), f = "";
637
+ const g = new E(u, c);
638
+ c.push(g), h = E.#h(t, g, h, r);
639
+ continue;
640
+ }
641
+ if (u === "|") {
642
+ c.push(f), f = "", p.push(c), c = new E(null, e);
643
+ continue;
644
+ }
645
+ if (u === ")")
646
+ return f === "" && e.#t.length === 0 && (e.#u = !0), c.push(f), f = "", e.push(...p, c), h;
647
+ f += u;
648
+ }
649
+ return e.type = null, e.#n = void 0, e.#t = [t.substring(n - 1)], h;
650
+ }
651
+ static fromGlob(t, e = {}) {
652
+ const n = new E(null, void 0, e);
653
+ return E.#h(t, n, 0, e), n;
654
+ }
655
+ // returns the regular expression if there's magic, or the unescaped
656
+ // string if not.
657
+ toMMPattern() {
658
+ if (this !== this.#s)
659
+ return this.#s.toMMPattern();
660
+ const t = this.toString(), [e, n, r, i] = this.toRegExpSource();
661
+ if (!(r || this.#n || this.#r.nocase && !this.#r.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
662
+ return n;
663
+ const a = (this.#r.nocase ? "i" : "") + (i ? "u" : "");
664
+ return Object.assign(new RegExp(`^${e}$`, a), {
665
+ _src: e,
666
+ _glob: t
667
+ });
668
+ }
669
+ get options() {
670
+ return this.#r;
671
+ }
672
+ // returns the string match, the regexp source, whether there's magic
673
+ // in the regexp (so a regular expression is required) and whether or
674
+ // not the uflag is needed for the regular expression (for posix classes)
675
+ // TODO: instead of injecting the start/end at this point, just return
676
+ // the BODY of the regexp, along with the start/end portions suitable
677
+ // for binding the start/end in either a joined full-path makeRe context
678
+ // (where we bind to (^|/), or a standalone matchPart context (where
679
+ // we bind to ^, and not /). Otherwise slashes get duped!
680
+ //
681
+ // In part-matching mode, the start is:
682
+ // - if not isStart: nothing
683
+ // - if traversal possible, but not allowed: ^(?!\.\.?$)
684
+ // - if dots allowed or not possible: ^
685
+ // - if dots possible and not allowed: ^(?!\.)
686
+ // end is:
687
+ // - if not isEnd(): nothing
688
+ // - else: $
689
+ //
690
+ // In full-path matching mode, we put the slash at the START of the
691
+ // pattern, so start is:
692
+ // - if first pattern: same as part-matching mode
693
+ // - if not isStart(): nothing
694
+ // - if traversal possible, but not allowed: /(?!\.\.?(?:$|/))
695
+ // - if dots allowed or not possible: /
696
+ // - if dots possible and not allowed: /(?!\.)
697
+ // end is:
698
+ // - if last pattern, same as part-matching mode
699
+ // - else nothing
700
+ //
701
+ // Always put the (?:$|/) on negated tails, though, because that has to be
702
+ // there to bind the end of the negated pattern portion, and it's easier to
703
+ // just stick it in now rather than try to inject it later in the middle of
704
+ // the pattern.
705
+ //
706
+ // We can just always return the same end, and leave it up to the caller
707
+ // to know whether it's going to be used joined or in parts.
708
+ // And, if the start is adjusted slightly, can do the same there:
709
+ // - if not isStart: nothing
710
+ // - if traversal possible, but not allowed: (?:/|^)(?!\.\.?$)
711
+ // - if dots allowed or not possible: (?:/|^)
712
+ // - if dots possible and not allowed: (?:/|^)(?!\.)
713
+ //
714
+ // But it's better to have a simpler binding without a conditional, for
715
+ // performance, so probably better to return both start options.
716
+ //
717
+ // Then the caller just ignores the end if it's not the first pattern,
718
+ // and the start always gets applied.
719
+ //
720
+ // But that's always going to be $ if it's the ending pattern, or nothing,
721
+ // so the caller can just attach $ at the end of the pattern when building.
722
+ //
723
+ // So the todo is:
724
+ // - better detect what kind of start is needed
725
+ // - return both flavors of starting pattern
726
+ // - attach $ at the end of the pattern when creating the actual RegExp
727
+ //
728
+ // Ah, but wait, no, that all only applies to the root when the first pattern
729
+ // is not an extglob. If the first pattern IS an extglob, then we need all
730
+ // that dot prevention biz to live in the extglob portions, because eg
731
+ // +(*|.x*) can match .xy but not .yx.
732
+ //
733
+ // So, return the two flavors if it's #root and the first child is not an
734
+ // AST, otherwise leave it to the child AST to handle it, and there,
735
+ // use the (?:^|/) style of start binding.
736
+ //
737
+ // Even simplified further:
738
+ // - Since the start for a join is eg /(?!\.) and the start for a part
739
+ // is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
740
+ // or start or whatever) and prepend ^ or / at the Regexp construction.
741
+ toRegExpSource(t) {
742
+ const e = t ?? !!this.#r.dot;
743
+ if (this.#s === this && this.#p(), !this.type) {
744
+ const l = this.isStart() && this.isEnd(), h = this.#t.map((u) => {
745
+ const [g, d, x, N] = typeof u == "string" ? E.#d(u, this.#n, l) : u.toRegExpSource(t);
746
+ return this.#n = this.#n || x, this.#i = this.#i || N, g;
747
+ }).join("");
748
+ let c = "";
749
+ if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && Zt.has(this.#t[0]))) {
750
+ const g = Yt, d = (
751
+ // dots are allowed, and the pattern starts with [ or .
752
+ e && g.has(h.charAt(0)) || // the pattern starts with \., and then [ or .
753
+ h.startsWith("\\.") && g.has(h.charAt(2)) || // the pattern starts with \.\., and then [ or .
754
+ h.startsWith("\\.\\.") && g.has(h.charAt(4))
755
+ ), x = !e && !t && g.has(h.charAt(0));
756
+ c = d ? Vt : x ? P : "";
757
+ }
758
+ let p = "";
759
+ return this.isEnd() && this.#s.#c && this.#e?.type === "!" && (p = "(?:$|\\/)"), [
760
+ c + h + p,
761
+ R(h),
762
+ this.#n = !!this.#n,
763
+ this.#i
764
+ ];
765
+ }
766
+ const n = this.type === "*" || this.type === "+", r = this.type === "!" ? "(?:(?!(?:" : "(?:";
767
+ let i = this.#f(e);
768
+ if (this.isStart() && this.isEnd() && !i && this.type !== "!") {
769
+ const l = this.toString();
770
+ return this.#t = [l], this.type = null, this.#n = void 0, [l, R(this.toString()), !1, !1];
771
+ }
772
+ let o = !n || t || e || !P ? "" : this.#f(!0);
773
+ o === i && (o = ""), o && (i = `(?:${i})(?:${o})*?`);
774
+ let a = "";
775
+ if (this.type === "!" && this.#u)
776
+ a = (this.isStart() && !e ? P : "") + H;
777
+ else {
778
+ const l = this.type === "!" ? (
779
+ // !() must match something,but !(x) can match ''
780
+ "))" + (this.isStart() && !e && !t ? P : "") + G + ")"
781
+ ) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : `)${this.type}`;
782
+ a = r + i + l;
783
+ }
784
+ return [
785
+ a,
786
+ R(i),
787
+ this.#n = !!this.#n,
788
+ this.#i
789
+ ];
790
+ }
791
+ #f(t) {
792
+ return this.#t.map((e) => {
793
+ if (typeof e == "string")
794
+ throw new Error("string type in extglob ast??");
795
+ const [n, r, i, o] = e.toRegExpSource(t);
796
+ return this.#i = this.#i || o, n;
797
+ }).filter((e) => !(this.isStart() && this.isEnd()) || !!e).join("|");
798
+ }
799
+ static #d(t, e, n = !1) {
800
+ let r = !1, i = "", o = !1;
801
+ for (let a = 0; a < t.length; a++) {
802
+ const l = t.charAt(a);
803
+ if (r) {
804
+ r = !1, i += (Jt.has(l) ? "\\" : "") + l;
805
+ continue;
806
+ }
807
+ if (l === "\\") {
808
+ a === t.length - 1 ? i += "\\\\" : r = !0;
809
+ continue;
810
+ }
811
+ if (l === "[") {
812
+ const [h, c, p, f] = Gt(t, a);
813
+ if (p) {
814
+ i += h, o = o || c, a += p - 1, e = e || f;
815
+ continue;
816
+ }
817
+ }
818
+ if (l === "*") {
819
+ n && t === "*" ? i += H : i += G, e = !0;
820
+ continue;
821
+ }
822
+ if (l === "?") {
823
+ i += j, e = !0;
824
+ continue;
825
+ }
826
+ i += Xt(l);
827
+ }
828
+ return [i, R(t), !!e, o];
829
+ }
830
+ }
831
+ const Kt = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&"), w = (s, t, e = {}) => (I(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new D(t, e).match(s)), Qt = /^\*+([^+@!?\*\[\(]*)$/, te = (s) => (t) => !t.startsWith(".") && t.endsWith(s), ee = (s) => (t) => t.endsWith(s), se = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), ne = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), re = /^\*+\.\*+$/, ie = (s) => !s.startsWith(".") && s.includes("."), oe = (s) => s !== "." && s !== ".." && s.includes("."), ce = /^\.\*+$/, ae = (s) => s !== "." && s !== ".." && s.startsWith("."), le = /^\*+$/, he = (s) => s.length !== 0 && !s.startsWith("."), ue = (s) => s.length !== 0 && s !== "." && s !== "..", fe = /^\?+([^+@!?\*\[\(]*)?$/, pe = ([s, t = ""]) => {
832
+ const e = st([s]);
833
+ return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
834
+ }, de = ([s, t = ""]) => {
835
+ const e = nt([s]);
836
+ return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
837
+ }, ge = ([s, t = ""]) => {
838
+ const e = nt([s]);
839
+ return t ? (n) => e(n) && n.endsWith(t) : e;
840
+ }, me = ([s, t = ""]) => {
841
+ const e = st([s]);
842
+ return t ? (n) => e(n) && n.endsWith(t) : e;
843
+ }, st = ([s]) => {
844
+ const t = s.length;
845
+ return (e) => e.length === t && !e.startsWith(".");
846
+ }, nt = ([s]) => {
847
+ const t = s.length;
848
+ return (e) => e.length === t && e !== "." && e !== "..";
849
+ }, rt = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", V = {
850
+ win32: { sep: "\\" },
851
+ posix: { sep: "/" }
852
+ }, we = rt === "win32" ? V.win32.sep : V.posix.sep;
853
+ w.sep = we;
854
+ const A = Symbol("globstar **");
855
+ w.GLOBSTAR = A;
856
+ const ye = "[^/]", Ee = ye + "*?", xe = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?", Se = "(?:(?!(?:\\/|^)\\.).)*?", Oe = (s, t = {}) => (e) => w(e, s, t);
857
+ w.filter = Oe;
858
+ const O = (s, t = {}) => Object.assign({}, s, t), Ae = (s) => {
859
+ if (!s || typeof s != "object" || !Object.keys(s).length)
860
+ return w;
861
+ const t = w;
862
+ return Object.assign((n, r, i = {}) => t(n, r, O(s, i)), {
863
+ Minimatch: class extends t.Minimatch {
864
+ constructor(r, i = {}) {
865
+ super(r, O(s, i));
866
+ }
867
+ static defaults(r) {
868
+ return t.defaults(O(s, r)).Minimatch;
869
+ }
870
+ },
871
+ AST: class extends t.AST {
872
+ /* c8 ignore start */
873
+ constructor(r, i, o = {}) {
874
+ super(r, i, O(s, o));
875
+ }
876
+ /* c8 ignore stop */
877
+ static fromGlob(r, i = {}) {
878
+ return t.AST.fromGlob(r, O(s, i));
879
+ }
880
+ },
881
+ unescape: (n, r = {}) => t.unescape(n, O(s, r)),
882
+ escape: (n, r = {}) => t.escape(n, O(s, r)),
883
+ filter: (n, r = {}) => t.filter(n, O(s, r)),
884
+ defaults: (n) => t.defaults(O(s, n)),
885
+ makeRe: (n, r = {}) => t.makeRe(n, O(s, r)),
886
+ braceExpand: (n, r = {}) => t.braceExpand(n, O(s, r)),
887
+ match: (n, r, i = {}) => t.match(n, r, O(s, i)),
888
+ sep: t.sep,
889
+ GLOBSTAR: A
890
+ });
891
+ };
892
+ w.defaults = Ae;
893
+ const it = (s, t = {}) => (I(s), t.nobrace || !/\{(?:(?!\{).)*\}/.test(s) ? [s] : Ft(s));
894
+ w.braceExpand = it;
895
+ const Ne = (s, t = {}) => new D(s, t).makeRe();
896
+ w.makeRe = Ne;
897
+ const be = (s, t, e = {}) => {
898
+ const n = new D(t, e);
899
+ return s = s.filter((r) => n.match(r)), n.options.nonull && !s.length && s.push(t), s;
900
+ };
901
+ w.match = be;
902
+ const Y = /[?*]|[+@!]\(.*?\)|\[|\]/, ve = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
903
+ class D {
904
+ options;
905
+ set;
906
+ pattern;
907
+ windowsPathsNoEscape;
908
+ nonegate;
909
+ negate;
910
+ comment;
911
+ empty;
912
+ preserveMultipleSlashes;
913
+ partial;
914
+ globSet;
915
+ globParts;
916
+ nocase;
917
+ isWindows;
918
+ platform;
919
+ windowsNoMagicRoot;
920
+ regexp;
921
+ constructor(t, e = {}) {
922
+ I(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || rt, this.isWindows = this.platform === "win32", this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === !1, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\/g, "/")), this.preserveMultipleSlashes = !!e.preserveMultipleSlashes, this.regexp = null, this.negate = !1, this.nonegate = !!e.nonegate, this.comment = !1, this.empty = !1, this.partial = !!e.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot = e.windowsNoMagicRoot !== void 0 ? e.windowsNoMagicRoot : !!(this.isWindows && this.nocase), this.globSet = [], this.globParts = [], this.set = [], this.make();
923
+ }
924
+ hasMagic() {
925
+ if (this.options.magicalBraces && this.set.length > 1)
926
+ return !0;
927
+ for (const t of this.set)
928
+ for (const e of t)
929
+ if (typeof e != "string")
930
+ return !0;
931
+ return !1;
932
+ }
933
+ debug(...t) {
934
+ }
935
+ make() {
936
+ const t = this.pattern, e = this.options;
937
+ if (!e.nocomment && t.charAt(0) === "#") {
938
+ this.comment = !0;
939
+ return;
940
+ }
941
+ if (!t) {
942
+ this.empty = !0;
943
+ return;
944
+ }
945
+ this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...i) => console.error(...i)), this.debug(this.pattern, this.globSet);
946
+ const n = this.globSet.map((i) => this.slashSplit(i));
947
+ this.globParts = this.preprocess(n), this.debug(this.pattern, this.globParts);
948
+ let r = this.globParts.map((i, o, a) => {
949
+ if (this.isWindows && this.windowsNoMagicRoot) {
950
+ const l = i[0] === "" && i[1] === "" && (i[2] === "?" || !Y.test(i[2])) && !Y.test(i[3]), h = /^[a-z]:/i.test(i[0]);
951
+ if (l)
952
+ return [...i.slice(0, 4), ...i.slice(4).map((c) => this.parse(c))];
953
+ if (h)
954
+ return [i[0], ...i.slice(1).map((c) => this.parse(c))];
955
+ }
956
+ return i.map((l) => this.parse(l));
957
+ });
958
+ if (this.debug(this.pattern, r), this.set = r.filter((i) => i.indexOf(!1) === -1), this.isWindows)
959
+ for (let i = 0; i < this.set.length; i++) {
960
+ const o = this.set[i];
961
+ o[0] === "" && o[1] === "" && this.globParts[i][2] === "?" && typeof o[3] == "string" && /^[a-z]:$/i.test(o[3]) && (o[2] = "?");
962
+ }
963
+ this.debug(this.pattern, this.set);
964
+ }
965
+ // various transforms to equivalent pattern sets that are
966
+ // faster to process in a filesystem walk. The goal is to
967
+ // eliminate what we can, and push all ** patterns as far
968
+ // to the right as possible, even if it increases the number
969
+ // of patterns that we have to process.
970
+ preprocess(t) {
971
+ if (this.options.noglobstar)
972
+ for (let n = 0; n < t.length; n++)
973
+ for (let r = 0; r < t[n].length; r++)
974
+ t[n][r] === "**" && (t[n][r] = "*");
975
+ const { optimizationLevel: e = 1 } = this.options;
976
+ return e >= 2 ? (t = this.firstPhasePreProcess(t), t = this.secondPhasePreProcess(t)) : e >= 1 ? t = this.levelOneOptimize(t) : t = this.adjascentGlobstarOptimize(t), t;
977
+ }
978
+ // just get rid of adjascent ** portions
979
+ adjascentGlobstarOptimize(t) {
980
+ return t.map((e) => {
981
+ let n = -1;
982
+ for (; (n = e.indexOf("**", n + 1)) !== -1; ) {
983
+ let r = n;
984
+ for (; e[r + 1] === "**"; )
985
+ r++;
986
+ r !== n && e.splice(n, r - n);
987
+ }
988
+ return e;
989
+ });
990
+ }
991
+ // get rid of adjascent ** and resolve .. portions
992
+ levelOneOptimize(t) {
993
+ return t.map((e) => (e = e.reduce((n, r) => {
994
+ const i = n[n.length - 1];
995
+ return r === "**" && i === "**" ? n : r === ".." && i && i !== ".." && i !== "." && i !== "**" ? (n.pop(), n) : (n.push(r), n);
996
+ }, []), e.length === 0 ? [""] : e));
997
+ }
998
+ levelTwoFileOptimize(t) {
999
+ Array.isArray(t) || (t = this.slashSplit(t));
1000
+ let e = !1;
1001
+ do {
1002
+ if (e = !1, !this.preserveMultipleSlashes) {
1003
+ for (let r = 1; r < t.length - 1; r++) {
1004
+ const i = t[r];
1005
+ r === 1 && i === "" && t[0] === "" || (i === "." || i === "") && (e = !0, t.splice(r, 1), r--);
1006
+ }
1007
+ t[0] === "." && t.length === 2 && (t[1] === "." || t[1] === "") && (e = !0, t.pop());
1008
+ }
1009
+ let n = 0;
1010
+ for (; (n = t.indexOf("..", n + 1)) !== -1; ) {
1011
+ const r = t[n - 1];
1012
+ r && r !== "." && r !== ".." && r !== "**" && (e = !0, t.splice(n - 1, 2), n -= 2);
1013
+ }
1014
+ } while (e);
1015
+ return t.length === 0 ? [""] : t;
1016
+ }
1017
+ // First phase: single-pattern processing
1018
+ // <pre> is 1 or more portions
1019
+ // <rest> is 1 or more portions
1020
+ // <p> is any portion other than ., .., '', or **
1021
+ // <e> is . or ''
1022
+ //
1023
+ // **/.. is *brutal* for filesystem walking performance, because
1024
+ // it effectively resets the recursive walk each time it occurs,
1025
+ // and ** cannot be reduced out by a .. pattern part like a regexp
1026
+ // or most strings (other than .., ., and '') can be.
1027
+ //
1028
+ // <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
1029
+ // <pre>/<e>/<rest> -> <pre>/<rest>
1030
+ // <pre>/<p>/../<rest> -> <pre>/<rest>
1031
+ // **/**/<rest> -> **/<rest>
1032
+ //
1033
+ // **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
1034
+ // this WOULD be allowed if ** did follow symlinks, or * didn't
1035
+ firstPhasePreProcess(t) {
1036
+ let e = !1;
1037
+ do {
1038
+ e = !1;
1039
+ for (let n of t) {
1040
+ let r = -1;
1041
+ for (; (r = n.indexOf("**", r + 1)) !== -1; ) {
1042
+ let o = r;
1043
+ for (; n[o + 1] === "**"; )
1044
+ o++;
1045
+ o > r && n.splice(r + 1, o - r);
1046
+ let a = n[r + 1];
1047
+ const l = n[r + 2], h = n[r + 3];
1048
+ if (a !== ".." || !l || l === "." || l === ".." || !h || h === "." || h === "..")
1049
+ continue;
1050
+ e = !0, n.splice(r, 1);
1051
+ const c = n.slice(0);
1052
+ c[r] = "**", t.push(c), r--;
1053
+ }
1054
+ if (!this.preserveMultipleSlashes) {
1055
+ for (let o = 1; o < n.length - 1; o++) {
1056
+ const a = n[o];
1057
+ o === 1 && a === "" && n[0] === "" || (a === "." || a === "") && (e = !0, n.splice(o, 1), o--);
1058
+ }
1059
+ n[0] === "." && n.length === 2 && (n[1] === "." || n[1] === "") && (e = !0, n.pop());
1060
+ }
1061
+ let i = 0;
1062
+ for (; (i = n.indexOf("..", i + 1)) !== -1; ) {
1063
+ const o = n[i - 1];
1064
+ if (o && o !== "." && o !== ".." && o !== "**") {
1065
+ e = !0;
1066
+ const l = i === 1 && n[i + 1] === "**" ? ["."] : [];
1067
+ n.splice(i - 1, 2, ...l), n.length === 0 && n.push(""), i -= 2;
1068
+ }
1069
+ }
1070
+ }
1071
+ } while (e);
1072
+ return t;
1073
+ }
1074
+ // second phase: multi-pattern dedupes
1075
+ // {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
1076
+ // {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
1077
+ // {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest>
1078
+ //
1079
+ // {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
1080
+ // ^-- not valid because ** doens't follow symlinks
1081
+ secondPhasePreProcess(t) {
1082
+ for (let e = 0; e < t.length - 1; e++)
1083
+ for (let n = e + 1; n < t.length; n++) {
1084
+ const r = this.partsMatch(t[e], t[n], !this.preserveMultipleSlashes);
1085
+ if (r) {
1086
+ t[e] = [], t[n] = r;
1087
+ break;
1088
+ }
1089
+ }
1090
+ return t.filter((e) => e.length);
1091
+ }
1092
+ partsMatch(t, e, n = !1) {
1093
+ let r = 0, i = 0, o = [], a = "";
1094
+ for (; r < t.length && i < e.length; )
1095
+ if (t[r] === e[i])
1096
+ o.push(a === "b" ? e[i] : t[r]), r++, i++;
1097
+ else if (n && t[r] === "**" && e[i] === t[r + 1])
1098
+ o.push(t[r]), r++;
1099
+ else if (n && e[i] === "**" && t[r] === e[i + 1])
1100
+ o.push(e[i]), i++;
1101
+ else if (t[r] === "*" && e[i] && (this.options.dot || !e[i].startsWith(".")) && e[i] !== "**") {
1102
+ if (a === "b")
1103
+ return !1;
1104
+ a = "a", o.push(t[r]), r++, i++;
1105
+ } else if (e[i] === "*" && t[r] && (this.options.dot || !t[r].startsWith(".")) && t[r] !== "**") {
1106
+ if (a === "a")
1107
+ return !1;
1108
+ a = "b", o.push(e[i]), r++, i++;
1109
+ } else
1110
+ return !1;
1111
+ return t.length === e.length && o;
1112
+ }
1113
+ parseNegate() {
1114
+ if (this.nonegate)
1115
+ return;
1116
+ const t = this.pattern;
1117
+ let e = !1, n = 0;
1118
+ for (let r = 0; r < t.length && t.charAt(r) === "!"; r++)
1119
+ e = !e, n++;
1120
+ n && (this.pattern = t.slice(n)), this.negate = e;
1121
+ }
1122
+ // set partial to true to test if, for example,
1123
+ // "/a/b" matches the start of "/*/b/*/d"
1124
+ // Partial means, if you run out of file before you run
1125
+ // out of pattern, then that's fine, as long as all
1126
+ // the parts match.
1127
+ matchOne(t, e, n = !1) {
1128
+ const r = this.options;
1129
+ if (this.isWindows) {
1130
+ const d = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), x = !d && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), N = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), v = !N && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), S = x ? 3 : d ? 0 : void 0, m = v ? 3 : N ? 0 : void 0;
1131
+ if (typeof S == "number" && typeof m == "number") {
1132
+ const [$, C] = [t[S], e[m]];
1133
+ $.toLowerCase() === C.toLowerCase() && (e[m] = $, m > S ? e = e.slice(m) : S > m && (t = t.slice(S)));
1134
+ }
1135
+ }
1136
+ const { optimizationLevel: i = 1 } = this.options;
1137
+ i >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.length);
1138
+ for (var o = 0, a = 0, l = t.length, h = e.length; o < l && a < h; o++, a++) {
1139
+ this.debug("matchOne loop");
1140
+ var c = e[a], p = t[o];
1141
+ if (this.debug(e, c, p), c === !1)
1142
+ return !1;
1143
+ if (c === A) {
1144
+ this.debug("GLOBSTAR", [e, c, p]);
1145
+ var f = o, u = a + 1;
1146
+ if (u === h) {
1147
+ for (this.debug("** at the end"); o < l; o++)
1148
+ if (t[o] === "." || t[o] === ".." || !r.dot && t[o].charAt(0) === ".")
1149
+ return !1;
1150
+ return !0;
1151
+ }
1152
+ for (; f < l; ) {
1153
+ var g = t[f];
1154
+ if (this.debug(`
1155
+ globstar while`, t, f, e, u, g), this.matchOne(t.slice(f), e.slice(u), n))
1156
+ return this.debug("globstar found match!", f, l, g), !0;
1157
+ if (g === "." || g === ".." || !r.dot && g.charAt(0) === ".") {
1158
+ this.debug("dot detected!", t, f, e, u);
1159
+ break;
1160
+ }
1161
+ this.debug("globstar swallow a segment, and continue"), f++;
1162
+ }
1163
+ return !!(n && (this.debug(`
1164
+ >>> no match, partial?`, t, f, e, u), f === l));
1165
+ }
1166
+ let d;
1167
+ if (typeof c == "string" ? (d = p === c, this.debug("string match", c, p, d)) : (d = c.test(p), this.debug("pattern match", c, p, d)), !d)
1168
+ return !1;
1169
+ }
1170
+ if (o === l && a === h)
1171
+ return !0;
1172
+ if (o === l)
1173
+ return n;
1174
+ if (a === h)
1175
+ return o === l - 1 && t[o] === "";
1176
+ throw new Error("wtf?");
1177
+ }
1178
+ braceExpand() {
1179
+ return it(this.pattern, this.options);
1180
+ }
1181
+ parse(t) {
1182
+ I(t);
1183
+ const e = this.options;
1184
+ if (t === "**")
1185
+ return A;
1186
+ if (t === "")
1187
+ return "";
1188
+ let n, r = null;
1189
+ (n = t.match(le)) ? r = e.dot ? ue : he : (n = t.match(Qt)) ? r = (e.nocase ? e.dot ? ne : se : e.dot ? ee : te)(n[1]) : (n = t.match(fe)) ? r = (e.nocase ? e.dot ? de : pe : e.dot ? ge : me)(n) : (n = t.match(re)) ? r = e.dot ? oe : ie : (n = t.match(ce)) && (r = ae);
1190
+ const i = E.fromGlob(t, this.options).toMMPattern();
1191
+ return r && typeof i == "object" && Reflect.defineProperty(i, "test", { value: r }), i;
1192
+ }
1193
+ makeRe() {
1194
+ if (this.regexp || this.regexp === !1)
1195
+ return this.regexp;
1196
+ const t = this.set;
1197
+ if (!t.length)
1198
+ return this.regexp = !1, this.regexp;
1199
+ const e = this.options, n = e.noglobstar ? Ee : e.dot ? xe : Se, r = new Set(e.nocase ? ["i"] : []);
1200
+ let i = t.map((l) => {
1201
+ const h = l.map((c) => {
1202
+ if (c instanceof RegExp)
1203
+ for (const p of c.flags.split(""))
1204
+ r.add(p);
1205
+ return typeof c == "string" ? ve(c) : c === A ? A : c._src;
1206
+ });
1207
+ return h.forEach((c, p) => {
1208
+ const f = h[p + 1], u = h[p - 1];
1209
+ c !== A || u === A || (u === void 0 ? f !== void 0 && f !== A ? h[p + 1] = "(?:\\/|" + n + "\\/)?" + f : h[p] = n : f === void 0 ? h[p - 1] = u + "(?:\\/|" + n + ")?" : f !== A && (h[p - 1] = u + "(?:\\/|\\/" + n + "\\/)" + f, h[p + 1] = A));
1210
+ }), h.filter((c) => c !== A).join("/");
1211
+ }).join("|");
1212
+ const [o, a] = t.length > 1 ? ["(?:", ")"] : ["", ""];
1213
+ i = "^" + o + i + a + "$", this.negate && (i = "^(?!" + i + ").+$");
1214
+ try {
1215
+ this.regexp = new RegExp(i, [...r].join(""));
1216
+ } catch {
1217
+ this.regexp = !1;
1218
+ }
1219
+ return this.regexp;
1220
+ }
1221
+ slashSplit(t) {
1222
+ return this.preserveMultipleSlashes ? t.split("/") : this.isWindows && /^\/\/[^\/]+/.test(t) ? ["", ...t.split(/\/+/)] : t.split(/\/+/);
1223
+ }
1224
+ match(t, e = this.partial) {
1225
+ if (this.debug("match", t, this.pattern), this.comment)
1226
+ return !1;
1227
+ if (this.empty)
1228
+ return t === "";
1229
+ if (t === "/" && e)
1230
+ return !0;
1231
+ const n = this.options;
1232
+ this.isWindows && (t = t.split("\\").join("/"));
1233
+ const r = this.slashSplit(t);
1234
+ this.debug(this.pattern, "split", r);
1235
+ const i = this.set;
1236
+ this.debug(this.pattern, "set", i);
1237
+ let o = r[r.length - 1];
1238
+ if (!o)
1239
+ for (let a = r.length - 2; !o && a >= 0; a--)
1240
+ o = r[a];
1241
+ for (let a = 0; a < i.length; a++) {
1242
+ const l = i[a];
1243
+ let h = r;
1244
+ if (n.matchBase && l.length === 1 && (h = [o]), this.matchOne(h, l, e))
1245
+ return n.flipNegate ? !0 : !this.negate;
1246
+ }
1247
+ return n.flipNegate ? !1 : this.negate;
1248
+ }
1249
+ static defaults(t) {
1250
+ return w.defaults(t).Minimatch;
1251
+ }
1252
+ }
1253
+ w.AST = E;
1254
+ w.Minimatch = D;
1255
+ w.escape = Kt;
1256
+ w.unescape = R;
1257
+ function Fe() {
1258
+ if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
1259
+ throw new ht();
1260
+ }
1261
+ async function $e(s, t, e) {
1262
+ return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(`opfs:${s.replace(/\/+/g, "/")}`, { mode: t }, e) : e();
1263
+ }
1264
+ function W(s) {
1265
+ return Array.isArray(s) ? s : (s.startsWith("~/") ? s.slice(2) : s).split("/").filter(Boolean);
1266
+ }
1267
+ function ot(s) {
1268
+ return typeof s == "string" ? s ?? "/" : `/${s.join("/")}`;
1269
+ }
1270
+ function ct(s) {
1271
+ const t = W(s);
1272
+ return t[t.length - 1] || "";
1273
+ }
1274
+ function je(s) {
1275
+ const t = W(s);
1276
+ return t.pop(), ot(t);
1277
+ }
1278
+ function at(s) {
1279
+ return !s || s === "/" ? "/" : s.startsWith("~/") ? `/${s.slice(2)}` : s.startsWith("/") ? s : `/${s}`;
1280
+ }
1281
+ function We(s, t = !1) {
1282
+ return s = s.replace(/\/$/, ""), t && !s.includes("*") ? `${s}/**` : s;
1283
+ }
1284
+ function Ue(s, t) {
1285
+ return w(s, t, {
1286
+ dot: !0,
1287
+ matchBase: !0
1288
+ });
1289
+ }
1290
+ function ze(s, t) {
1291
+ if (!t || Array.isArray(t) && t.length === 0)
1292
+ return !1;
1293
+ const e = at(s);
1294
+ return (Array.isArray(t) ? t : [t]).some((r) => w(e, r, { dot: !0 }));
1295
+ }
1296
+ function Be(s) {
1297
+ const t = at(s), e = W(t), n = [];
1298
+ for (const r of e)
1299
+ if (!(r === "." || r === ""))
1300
+ if (r === "..") {
1301
+ if (n.length === 0)
1302
+ continue;
1303
+ n.pop();
1304
+ } else
1305
+ n.push(r);
1306
+ return ot(n);
1307
+ }
1308
+ function _e(s) {
1309
+ const t = ct(s), e = t.lastIndexOf(".");
1310
+ return e <= 0 || e === t.length - 1 ? "" : t.slice(e);
1311
+ }
1312
+ function qe(s, t = "utf-8") {
1313
+ return typeof s == "string" ? yt(s, t) : s instanceof Uint8Array ? s : new Uint8Array(s);
1314
+ }
1315
+ async function Ge(s, t = "SHA-1", e = 50 * 1024 * 1024) {
1316
+ if (s instanceof File && (s = await s.arrayBuffer()), s.byteLength > e)
1317
+ throw new Error(`File size ${s.byteLength} bytes exceeds maximum allowed size ${e} bytes`);
1318
+ const n = new Uint8Array(s), r = await crypto.subtle.digest(t, n);
1319
+ return Array.from(new Uint8Array(r)).map((o) => o.toString(16).padStart(2, "0")).join("");
1320
+ }
1321
+ function He(s, t) {
1322
+ if (s.length !== t.length)
1323
+ return !1;
1324
+ for (let e = 0; e < s.length; e++)
1325
+ if (s[e] !== t[e])
1326
+ return !1;
1327
+ return !0;
1328
+ }
1329
+ async function Ve(s) {
1330
+ const t = await s.arrayBuffer();
1331
+ return new Uint8Array(t);
1332
+ }
1333
+ async function Ye(s, t, e = {}) {
1334
+ const n = ct(t);
1335
+ return $e(t, "exclusive", async () => {
1336
+ const r = e.recursive ?? !1, i = e.force ?? !1;
1337
+ try {
1338
+ await s.removeEntry(n, { recursive: r });
1339
+ } catch (o) {
1340
+ if (o.name === "NotFoundError") {
1341
+ if (!i)
1342
+ throw new Z("file", t, o);
1343
+ } else throw o.name === "InvalidModificationError" ? new z("ENOTEMPTY", t, o) : o.name === "TypeMismatchError" && !r ? new k("directory", t, o) : new z("RM_FAILED", t, o);
1344
+ }
1345
+ });
1346
+ }
1347
+ function Ze(s, t, e, n) {
1348
+ if (!Number.isInteger(t) || !Number.isInteger(e))
1349
+ throw new b("argument", "Invalid offset or length");
1350
+ if (t < 0 || e < 0)
1351
+ throw new b("argument", "Negative offset or length not allowed");
1352
+ if (t + e > s)
1353
+ throw new b("overflow", "Operation would overflow buffer");
1354
+ if (n != null && (!Number.isInteger(n) || n < 0))
1355
+ throw new b("argument", "Invalid position");
1356
+ }
1357
+ function Je(s, t, e) {
1358
+ try {
1359
+ t.flush(), t.close();
1360
+ } catch (n) {
1361
+ console.warn(`Warning: Failed to properly close file descriptor ${s} (${e}):`, n);
1362
+ }
1363
+ }
1364
+ function Xe(s, t, e) {
1365
+ if (s >= e)
1366
+ return { isEOF: !0, actualLength: 0 };
1367
+ const n = Math.min(t, e - s);
1368
+ return n <= 0 ? { isEOF: !0, actualLength: 0 } : { isEOF: !1, actualLength: n };
1369
+ }
1370
+ async function Ke(s, t) {
1371
+ try {
1372
+ return await s.createSyncAccessHandle();
1373
+ } catch (e) {
1374
+ throw mt(e, { path: t, isDirectory: !1 });
1375
+ }
1376
+ }
1377
+ export {
1378
+ Ce as A,
1379
+ He as B,
1380
+ Ve as C,
1381
+ z as D,
1382
+ Z as E,
1383
+ pt as F,
1384
+ Ye as G,
1385
+ Ze as H,
1386
+ U as I,
1387
+ Je as J,
1388
+ Xe as K,
1389
+ Ke as L,
1390
+ wt as M,
1391
+ y as O,
1392
+ Te as P,
1393
+ ft as S,
1394
+ b as V,
1395
+ At as W,
1396
+ ht as a,
1397
+ ut as b,
1398
+ k as c,
1399
+ De as d,
1400
+ yt as e,
1401
+ dt as f,
1402
+ gt as g,
1403
+ Me as h,
1404
+ Ie as i,
1405
+ Re as j,
1406
+ Pe as k,
1407
+ Fe as l,
1408
+ mt as m,
1409
+ ot as n,
1410
+ ct as o,
1411
+ je as p,
1412
+ at as q,
1413
+ We as r,
1414
+ W as s,
1415
+ Ue as t,
1416
+ ze as u,
1417
+ Be as v,
1418
+ $e as w,
1419
+ _e as x,
1420
+ qe as y,
1421
+ Ge as z
1422
+ };
1423
+ //# sourceMappingURL=helpers-CKOebsbw.js.map