opfs-worker 2.1.1 → 2.1.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.
Files changed (100) hide show
  1. package/README.md +21 -20
  2. package/dist/BaseOPFS-Bu7FZtCb.cjs +2 -0
  3. package/dist/BaseOPFS-Bu7FZtCb.cjs.map +1 -0
  4. package/dist/{BaseOPFS-BusBkyJX.js → BaseOPFS-C3NE4BKr.js} +790 -548
  5. package/dist/BaseOPFS-C3NE4BKr.js.map +1 -0
  6. package/dist/OPFSAsync-C0RsxCX5.cjs +2 -0
  7. package/dist/OPFSAsync-C0RsxCX5.cjs.map +1 -0
  8. package/dist/{OPFSAsync-CO44W23e.js → OPFSAsync-aeLUdIqd.js} +19 -19
  9. package/dist/OPFSAsync-aeLUdIqd.js.map +1 -0
  10. package/dist/{OPFSFacade-hrNXCn6w.cjs → OPFSFacade-BJv2yuWU.cjs} +2 -2
  11. package/dist/{OPFSFacade-hrNXCn6w.cjs.map → OPFSFacade-BJv2yuWU.cjs.map} +1 -1
  12. package/dist/{OPFSFacade-CEaSqTut.js → OPFSFacade-DiogtQoq.js} +2 -2
  13. package/dist/{OPFSFacade-CEaSqTut.js.map → OPFSFacade-DiogtQoq.js.map} +1 -1
  14. package/dist/OPFSSync-3qlSBYmz.cjs +2 -0
  15. package/dist/OPFSSync-3qlSBYmz.cjs.map +1 -0
  16. package/dist/{OPFSSync-D7obTsl3.js → OPFSSync-CvSOswhW.js} +57 -57
  17. package/dist/OPFSSync-CvSOswhW.js.map +1 -0
  18. package/dist/assets/dedicated.worker-Bqqr9UBA.js.map +1 -0
  19. package/dist/core/BaseOPFS.d.ts +23 -3
  20. package/dist/core/BaseOPFS.d.ts.map +1 -1
  21. package/dist/core/OPFSAsync.d.ts.map +1 -1
  22. package/dist/core/OPFSSync.d.ts.map +1 -1
  23. package/dist/createOPFSAsync-B611B63X.js +10 -0
  24. package/dist/{createOPFSAsync-DdhJYoC0.js.map → createOPFSAsync-B611B63X.js.map} +1 -1
  25. package/dist/createOPFSAsync-BATjJg8k.cjs +2 -0
  26. package/dist/{createOPFSAsync-DyWpvmL-.cjs.map → createOPFSAsync-BATjJg8k.cjs.map} +1 -1
  27. package/dist/{createOPFSDedicated-BwTc0NV5.js → createOPFSDedicated-DgudPTB8.js} +1086 -817
  28. package/dist/createOPFSDedicated-DgudPTB8.js.map +1 -0
  29. package/dist/{createOPFSDedicated-CEeRexom.cjs → createOPFSDedicated-EmIwluQo.cjs} +1037 -797
  30. package/dist/createOPFSDedicated-EmIwluQo.cjs.map +1 -0
  31. package/dist/{createOPFSShared-BSFWsoLe.js → createOPFSShared-BWYln8jJ.js} +2 -2
  32. package/dist/{createOPFSShared-BSFWsoLe.js.map → createOPFSShared-BWYln8jJ.js.map} +1 -1
  33. package/dist/{createOPFSShared-BoCft_BS.cjs → createOPFSShared-DPJpCd7z.cjs} +2 -2
  34. package/dist/{createOPFSShared-BoCft_BS.cjs.map → createOPFSShared-DPJpCd7z.cjs.map} +1 -1
  35. package/dist/dedicated.worker.js +1034 -794
  36. package/dist/dedicated.worker.js.map +1 -1
  37. package/dist/facade/createOPFSDedicated.d.ts +4 -2
  38. package/dist/facade/createOPFSDedicated.d.ts.map +1 -1
  39. package/dist/index.async.cjs +1 -1
  40. package/dist/index.async.js +33 -32
  41. package/dist/index.cjs +1 -1
  42. package/dist/index.d.ts +1 -5
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +44 -43
  45. package/dist/index.pure.cjs +1 -1
  46. package/dist/index.pure.js +38 -37
  47. package/dist/index.sharedworker.cjs +1 -1
  48. package/dist/index.sharedworker.js +34 -33
  49. package/dist/index.sync.cjs +1 -1
  50. package/dist/index.sync.d.ts +2 -0
  51. package/dist/index.sync.d.ts.map +1 -1
  52. package/dist/index.sync.js +34 -32
  53. package/dist/shared.worker.js +1056 -820
  54. package/dist/shared.worker.js.map +1 -1
  55. package/dist/types.d.ts +5 -5
  56. package/dist/types.d.ts.map +1 -1
  57. package/dist/utils/helpers.d.ts +13 -3
  58. package/dist/utils/helpers.d.ts.map +1 -1
  59. package/dist/worker/createDedicatedWorker.d.ts +8 -3
  60. package/dist/worker/createDedicatedWorker.d.ts.map +1 -1
  61. package/docs/README.md +18 -0
  62. package/docs/api/README.md +221 -0
  63. package/docs/{file-descriptors.md → api/file-descriptors.md} +13 -13
  64. package/docs/guides/async.md +2 -2
  65. package/docs/guides/dedicated.md +6 -4
  66. package/docs/guides/hashing.md +1 -1
  67. package/docs/guides/pure.md +1 -1
  68. package/docs/guides/sharedworker.md +1 -1
  69. package/docs/guides/streaming.md +2 -2
  70. package/docs/migration.md +8 -9
  71. package/docs/types.md +4 -4
  72. package/package.json +10 -9
  73. package/src/core/BaseOPFS.ts +46 -4
  74. package/src/core/OPFSAsync.ts +4 -5
  75. package/src/core/OPFSSync.ts +6 -7
  76. package/src/facade/createOPFSDedicated.ts +4 -2
  77. package/src/index.sync.ts +2 -0
  78. package/src/index.ts +1 -5
  79. package/src/types.ts +5 -3
  80. package/src/utils/helpers.ts +32 -6
  81. package/src/worker/createDedicatedWorker.ts +85 -7
  82. package/src/worker/dedicated.worker.ts +12 -1
  83. package/dist/BaseOPFS-BusBkyJX.js.map +0 -1
  84. package/dist/BaseOPFS-CYwrD7-q.cjs +0 -4
  85. package/dist/BaseOPFS-CYwrD7-q.cjs.map +0 -1
  86. package/dist/OPFSAsync-B2dR-2VR.cjs +0 -2
  87. package/dist/OPFSAsync-B2dR-2VR.cjs.map +0 -1
  88. package/dist/OPFSAsync-CO44W23e.js.map +0 -1
  89. package/dist/OPFSSync-BPrNtvFS.cjs +0 -2
  90. package/dist/OPFSSync-BPrNtvFS.cjs.map +0 -1
  91. package/dist/OPFSSync-D7obTsl3.js.map +0 -1
  92. package/dist/assets/dedicated.worker-DW6UqFo0.js.map +0 -1
  93. package/dist/createOPFSAsync-DdhJYoC0.js +0 -10
  94. package/dist/createOPFSAsync-DyWpvmL-.cjs +0 -2
  95. package/dist/createOPFSDedicated-BwTc0NV5.js.map +0 -1
  96. package/dist/createOPFSDedicated-CEeRexom.cjs.map +0 -1
  97. package/docs/api/backend.md +0 -36
  98. package/docs/api/create.md +0 -82
  99. package/docs/api/facade.md +0 -53
  100. package/docs/choosing-a-mode.md +0 -41
@@ -1,5 +1,5 @@
1
1
  var N = /* @__PURE__ */ ((s) => (s.Added = "added", s.Changed = "changed", s.Removed = "removed", s))(N || {});
2
- const wt = {
2
+ const bt = {
3
3
  ENOENT: -2,
4
4
  // No such file or directory
5
5
  EISDIR: -21,
@@ -36,20 +36,20 @@ class m extends Error {
36
36
  syscall;
37
37
  path;
38
38
  constructor(t, e, n, r, i) {
39
- super(t, { cause: i }), this.name = e, this.errno = wt[e] || -1, this.path = n, this.syscall = r;
39
+ super(t, { cause: i }), this.name = e, this.errno = bt[e] || -1, this.path = n, this.syscall = r;
40
40
  }
41
41
  }
42
- class yt extends m {
42
+ class xt extends m {
43
43
  constructor(t) {
44
44
  super("OPFS is not supported in this browser", "ENOTSUP", void 0, void 0, t);
45
45
  }
46
46
  }
47
- class Et extends m {
47
+ class At extends m {
48
48
  constructor(t, e, n) {
49
49
  super(t, "INVALID_PATH", e, "access", n);
50
50
  }
51
51
  }
52
- class k extends m {
52
+ class P extends m {
53
53
  constructor(t, e, n) {
54
54
  const r = {
55
55
  file: `File not found: ${e}`,
@@ -59,28 +59,28 @@ class k extends m {
59
59
  super(r[t], "ENOENT", e, "access", n);
60
60
  }
61
61
  }
62
- class St extends m {
62
+ class vt extends m {
63
63
  constructor(t, e, n) {
64
64
  super(`Permission denied for ${e} on: ${t}`, "EACCES", t, e, n);
65
65
  }
66
66
  }
67
- class xt extends m {
67
+ class Ot extends m {
68
68
  constructor(t, e, n) {
69
69
  super(t, "ENOSPC", e, "write", n);
70
70
  }
71
71
  }
72
- class bt extends m {
72
+ class $t extends m {
73
73
  constructor(t, e) {
74
74
  super(`File is busy: ${t}`, "EBUSY", t, "open", e);
75
75
  }
76
76
  }
77
- class q extends m {
77
+ class U extends m {
78
78
  constructor(t, e, n) {
79
79
  const r = t === "directory" ? `Is a directory: ${e}` : `Not a directory: ${e}`, i = t === "directory" ? "EISDIR" : "ENOTDIR";
80
80
  super(r, i, e, "access", n);
81
81
  }
82
82
  }
83
- class D extends m {
83
+ class $ extends m {
84
84
  constructor(t, e, n, r) {
85
85
  const i = {
86
86
  argument: "EINVAL",
@@ -91,7 +91,7 @@ class D extends m {
91
91
  super(e, i[t], n, "validate", r);
92
92
  }
93
93
  }
94
- class vt extends m {
94
+ class Nt extends m {
95
95
  constructor(t, e) {
96
96
  super(`Operation aborted: ${t}`, "EINTR", t, "interrupt", e);
97
97
  }
@@ -101,12 +101,12 @@ class J extends m {
101
101
  super(t, "EIO", e, "io", n);
102
102
  }
103
103
  }
104
- class ot extends m {
104
+ class ct extends m {
105
105
  constructor(t, e) {
106
106
  super(`Operation not supported: ${t}`, "ENOTSUP", t, "operation", e);
107
107
  }
108
108
  }
109
- class G extends m {
109
+ class H extends m {
110
110
  constructor(t, e, n) {
111
111
  const r = {
112
112
  RM_FAILED: `Failed to remove entry: ${e}`,
@@ -116,7 +116,7 @@ class G extends m {
116
116
  super(r[t] || `Directory operation failed: ${e}`, t, e, "unlink", n);
117
117
  }
118
118
  }
119
- class Ot extends m {
119
+ class Dt extends m {
120
120
  constructor(t, e) {
121
121
  super("Failed to initialize OPFS", "INIT_FAILED", t, "init", e);
122
122
  }
@@ -126,43 +126,43 @@ class j extends m {
126
126
  super(`Failed to ${t}: ${e}`, `${t.toUpperCase()}_FAILED`, e, t, n);
127
127
  }
128
128
  }
129
- class X extends m {
129
+ class Q extends m {
130
130
  constructor(t, e) {
131
131
  super(`Destination already exists: ${t}`, "EEXIST", t, "open", e);
132
132
  }
133
133
  }
134
- function He(s, t, e, n) {
134
+ function Ke(s, t, e, n) {
135
135
  const r = `${s.toUpperCase()}_FAILED`;
136
136
  return new m(`Failed to ${s} file descriptor: ${t}`, r, e, s, n);
137
137
  }
138
- function O(s, t) {
138
+ function v(s, t) {
139
139
  const e = t?.path, n = t?.isDirectory, r = t?.existenceType ?? "file", i = t?.operation;
140
140
  switch (s.name) {
141
141
  case "InvalidStateError":
142
- return new bt(e || "unknown", s);
142
+ return new $t(e || "unknown", s);
143
143
  case "QuotaExceededError":
144
- return new xt(`No space left on device: ${e || "unknown"}`, e, s);
144
+ return new Ot(`No space left on device: ${e || "unknown"}`, e, s);
145
145
  case "NotFoundError":
146
- return new k(r, e, s);
146
+ return new P(r, e, s);
147
147
  case "TypeMismatchError":
148
- return n !== void 0 ? n ? new q("directory", e || "unknown", s) : new q("file", e || "unknown", s) : new D("argument", `Type mismatch: ${e || "unknown"}`, e, s);
148
+ return n !== void 0 ? n ? new U("directory", e || "unknown", s) : new U("file", e || "unknown", s) : new $("argument", `Type mismatch: ${e || "unknown"}`, e, s);
149
149
  case "NotAllowedError":
150
150
  case "SecurityError":
151
- return new St(e, "unknown", s);
151
+ return new vt(e, "unknown", s);
152
152
  case "InvalidModificationError":
153
- return i === "remove" ? new G("ENOTEMPTY", e, s) : new D("argument", `Invalid modification: ${e || "unknown"}`, e, s);
153
+ return i === "remove" ? new H("ENOTEMPTY", e, s) : new $("argument", `Invalid modification: ${e || "unknown"}`, e, s);
154
154
  case "AbortError":
155
- return new vt(e || "unknown", s);
155
+ return new Nt(e || "unknown", s);
156
156
  case "OperationError":
157
157
  return new J(`Operation failed: ${e || "unknown"}`, e, s);
158
158
  case "TypeError":
159
- return new ot(e || "unknown", s);
159
+ return new ct(e || "unknown", s);
160
160
  default:
161
- return i === "remove" ? new G("RM_FAILED", e, s) : new J(`I/O error: ${e || "unknown"}`, e, s);
161
+ return i === "remove" ? new H("RM_FAILED", e, s) : new J(`I/O error: ${e || "unknown"}`, e, s);
162
162
  }
163
163
  }
164
- const at = (s, t, e) => {
165
- const n = s instanceof RegExp ? K(s, e) : s, r = t instanceof RegExp ? K(t, e) : t, i = n !== null && r != null && At(n, r, e);
164
+ const lt = (s, t, e) => {
165
+ const n = s instanceof RegExp ? K(s, e) : s, r = t instanceof RegExp ? K(t, e) : t, i = n !== null && r != null && Tt(n, r, e);
166
166
  return i && {
167
167
  start: i[0],
168
168
  end: i[1],
@@ -173,118 +173,151 @@ const at = (s, t, e) => {
173
173
  }, K = (s, t) => {
174
174
  const e = t.match(s);
175
175
  return e ? e[0] : null;
176
- }, At = (s, t, e) => {
177
- let n, r, i, o, c, a = e.indexOf(s), h = e.indexOf(t, a + 1), l = a;
178
- if (a >= 0 && h > 0) {
176
+ }, Tt = (s, t, e) => {
177
+ let n, r, i, o, a, c = e.indexOf(s), l = e.indexOf(t, c + 1), u = c;
178
+ if (c >= 0 && l > 0) {
179
179
  if (s === t)
180
- return [a, h];
181
- for (n = [], i = e.length; l >= 0 && !c; ) {
182
- if (l === a)
183
- n.push(l), a = e.indexOf(s, l + 1);
180
+ return [c, l];
181
+ for (n = [], i = e.length; u >= 0 && !a; ) {
182
+ if (u === c)
183
+ n.push(u), c = e.indexOf(s, u + 1);
184
184
  else if (n.length === 1) {
185
- const d = n.pop();
186
- d !== void 0 && (c = [d, h]);
185
+ const h = n.pop();
186
+ h !== void 0 && (a = [h, l]);
187
187
  } else
188
- r = n.pop(), r !== void 0 && r < i && (i = r, o = h), h = e.indexOf(t, l + 1);
189
- l = a < h && a >= 0 ? a : h;
188
+ r = n.pop(), r !== void 0 && r < i && (i = r, o = l), l = e.indexOf(t, u + 1);
189
+ u = c < l && c >= 0 ? c : l;
190
190
  }
191
- n.length && o !== void 0 && (c = [i, o]);
191
+ n.length && o !== void 0 && (a = [i, o]);
192
192
  }
193
- return c;
194
- }, ct = "\0SLASH" + Math.random() + "\0", lt = "\0OPEN" + Math.random() + "\0", V = "\0CLOSE" + Math.random() + "\0", ht = "\0COMMA" + Math.random() + "\0", ut = "\0PERIOD" + Math.random() + "\0", Dt = new RegExp(ct, "g"), Nt = new RegExp(lt, "g"), $t = new RegExp(V, "g"), Ct = new RegExp(ht, "g"), Tt = new RegExp(ut, "g"), Ft = /\\\\/g, It = /\\{/g, Mt = /\\}/g, Rt = /\\,/g, Pt = /\\./g;
195
- function U(s) {
193
+ return a;
194
+ }, ht = "\0SLASH" + Math.random() + "\0", ut = "\0OPEN" + Math.random() + "\0", X = "\0CLOSE" + Math.random() + "\0", ft = "\0COMMA" + Math.random() + "\0", pt = "\0PERIOD" + Math.random() + "\0", Ct = new RegExp(ht, "g"), Mt = new RegExp(ut, "g"), Ft = new RegExp(X, "g"), Rt = new RegExp(ft, "g"), Pt = new RegExp(pt, "g"), kt = /\\\\/g, It = /\\{/g, Lt = /\\}/g, zt = /\\,/g, jt = /\\\./g, Wt = 1e5, _t = 4e6;
195
+ function W(s) {
196
196
  return isNaN(s) ? s.charCodeAt(0) : parseInt(s, 10);
197
197
  }
198
- function kt(s) {
199
- return s.replace(Ft, ct).replace(It, lt).replace(Mt, V).replace(Rt, ht).replace(Pt, ut);
198
+ function Bt(s) {
199
+ return s.replace(kt, ht).replace(It, ut).replace(Lt, X).replace(zt, ft).replace(jt, pt);
200
200
  }
201
- function Lt(s) {
202
- return s.replace(Dt, "\\").replace(Nt, "{").replace($t, "}").replace(Ct, ",").replace(Tt, ".");
201
+ function Ut(s) {
202
+ return s.replace(Ct, "\\").replace(Mt, "{").replace(Ft, "}").replace(Rt, ",").replace(Pt, ".");
203
203
  }
204
- function ft(s) {
204
+ function dt(s) {
205
205
  if (!s)
206
206
  return [""];
207
- const t = [], e = at("{", "}", s);
207
+ const t = [], e = lt("{", "}", s);
208
208
  if (!e)
209
209
  return s.split(",");
210
210
  const { pre: n, body: r, post: i } = e, o = n.split(",");
211
211
  o[o.length - 1] += "{" + r + "}";
212
- const c = ft(i);
213
- return i.length && (o[o.length - 1] += c.shift(), o.push.apply(o, c)), t.push.apply(t, o), t;
212
+ const a = dt(i);
213
+ return i.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
214
214
  }
215
- function zt(s) {
216
- return s ? (s.slice(0, 2) === "{}" && (s = "\\{\\}" + s.slice(2)), I(kt(s), !0).map(Lt)) : [];
215
+ function Ht(s, t = {}) {
216
+ if (!s)
217
+ return [];
218
+ const { max: e = Wt, maxLength: n = _t } = t;
219
+ return s.slice(0, 2) === "{}" && (s = "\\{\\}" + s.slice(2)), G(Bt(s), e, n, !0).map(Ut);
217
220
  }
218
- function Wt(s) {
221
+ function Gt(s) {
219
222
  return "{" + s + "}";
220
223
  }
221
- function Bt(s) {
224
+ function qt(s) {
222
225
  return /^-?0\d/.test(s);
223
226
  }
224
- function jt(s, t) {
227
+ function Xt(s, t) {
225
228
  return s <= t;
226
229
  }
227
- function Ut(s, t) {
230
+ function Vt(s, t) {
228
231
  return s >= t;
229
232
  }
230
- function I(s, t) {
231
- const e = [], n = at("{", "}", s);
232
- if (!n)
233
- return [s];
234
- const r = n.pre, i = n.post.length ? I(n.post, !1) : [""];
235
- if (/\$$/.test(n.pre))
236
- for (let o = 0; o < i.length; o++) {
237
- const c = r + "{" + n.body + "}" + i[o];
238
- e.push(c);
233
+ function C(s, t, e, n, r, i) {
234
+ const o = [];
235
+ let a = 0;
236
+ for (let c = 0; c < s.length; c++)
237
+ for (let l = 0; l < e.length; l++) {
238
+ if (o.length >= n)
239
+ return o;
240
+ const u = s[c] + t + e[l];
241
+ if (!(i && !u)) {
242
+ if (a + u.length > r)
243
+ return o;
244
+ o.push(u), a += u.length;
245
+ }
239
246
  }
240
- else {
241
- const o = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body), c = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body), a = o || c, h = n.body.indexOf(",") >= 0;
242
- if (!a && !h)
243
- return n.post.match(/,(?!,).*\}/) ? (s = n.pre + "{" + n.body + V + n.post, I(s)) : [s];
244
- let l;
245
- if (a)
246
- l = n.body.split(/\.\./);
247
- else if (l = ft(n.body), l.length === 1 && l[0] !== void 0 && (l = I(l[0], !1).map(Wt), l.length === 1))
248
- return i.map((u) => n.pre + l[0] + u);
247
+ return o;
248
+ }
249
+ function Yt(s, t, e) {
250
+ const n = s.split(/\.\./), r = [];
251
+ if (n[0] === void 0 || n[1] === void 0)
252
+ return r;
253
+ const i = W(n[0]), o = W(n[1]), a = Math.max(n[0].length, n[1].length);
254
+ let c = n.length === 3 && n[2] !== void 0 ? Math.max(Math.abs(W(n[2])), 1) : 1, l = Xt;
255
+ o < i && (c *= -1, l = Vt);
256
+ const h = n.some(qt);
257
+ for (let f = i; l(f, o) && r.length < e; f += c) {
249
258
  let d;
250
- if (a && l[0] !== void 0 && l[1] !== void 0) {
251
- const u = U(l[0]), f = U(l[1]), g = Math.max(l[0].length, l[1].length);
252
- let p = l.length === 3 && l[2] !== void 0 ? Math.abs(U(l[2])) : 1, S = jt;
253
- f < u && (p *= -1, S = Ut);
254
- const C = l.some(Bt);
255
- d = [];
256
- for (let x = u; S(x, f); x += p) {
257
- let w;
258
- if (c)
259
- w = String.fromCharCode(x), w === "\\" && (w = "");
260
- else if (w = String(x), C) {
261
- const T = g - w.length;
262
- if (T > 0) {
263
- const R = new Array(T + 1).join("0");
264
- x < 0 ? w = "-" + R + w.slice(1) : w = R + w;
265
- }
266
- }
267
- d.push(w);
259
+ if (t)
260
+ d = String.fromCharCode(f), d === "\\" && (d = "");
261
+ else if (d = String(f), h) {
262
+ const g = a - d.length;
263
+ if (g > 0) {
264
+ const p = new Array(g + 1).join("0");
265
+ f < 0 ? d = "-" + p + d.slice(1) : d = p + d;
268
266
  }
269
- } else {
270
- d = [];
271
- for (let u = 0; u < l.length; u++)
272
- d.push.apply(d, I(l[u], !1));
273
267
  }
274
- for (let u = 0; u < d.length; u++)
275
- for (let f = 0; f < i.length; f++) {
276
- const g = r + d[u] + i[f];
277
- (!t || a || g) && e.push(g);
268
+ r.push(d);
269
+ }
270
+ return r;
271
+ }
272
+ function G(s, t, e, n) {
273
+ let r = [""], i = !1, o = !0;
274
+ for (; ; ) {
275
+ const a = lt("{", "}", s);
276
+ if (!a)
277
+ return C(r, s, [""], t, e, i);
278
+ const c = a.pre;
279
+ if (/\$$/.test(c)) {
280
+ if (r = C(r, c + "{" + a.body + "}", [""], t, e, i && !a.post.length), o = !1, !a.post.length)
281
+ break;
282
+ s = a.post;
283
+ continue;
284
+ }
285
+ const l = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body), u = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body), h = l || u, f = a.body.indexOf(",") >= 0;
286
+ if (!h && !f) {
287
+ if (a.post.match(/,(?!,).*\}/)) {
288
+ s = a.pre + "{" + a.body + X + a.post, n = !0;
289
+ continue;
278
290
  }
291
+ return C(r, c + "{" + a.body + "}" + a.post, [""], t, e, i);
292
+ }
293
+ o && (i = n && !h, o = !1);
294
+ let d;
295
+ if (h)
296
+ d = Yt(a.body, u, t);
297
+ else {
298
+ let g = dt(a.body);
299
+ if (g.length === 1 && g[0] !== void 0 && (g = G(g[0], t, e, !1).map(Gt), g.length === 1)) {
300
+ if (r = C(r, c + g[0], [""], t, e, i && !a.post.length), !a.post.length)
301
+ break;
302
+ s = a.post;
303
+ continue;
304
+ }
305
+ d = [];
306
+ for (let p = 0; p < g.length; p++)
307
+ d.push.apply(d, G(g[p], t, e, !1));
308
+ }
309
+ if (r = C(r, c, d, t, e, i && !a.post.length), !a.post.length)
310
+ break;
311
+ s = a.post;
279
312
  }
280
- return e;
313
+ return r;
281
314
  }
282
- const Ht = 1024 * 64, L = (s) => {
315
+ const Zt = 1024 * 64, k = (s) => {
283
316
  if (typeof s != "string")
284
317
  throw new TypeError("invalid pattern");
285
- if (s.length > Ht)
318
+ if (s.length > Zt)
286
319
  throw new TypeError("pattern is too long");
287
- }, _t = {
320
+ }, Jt = {
288
321
  "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", !0],
289
322
  "[:alpha:]": ["\\p{L}\\p{Nl}", !0],
290
323
  "[:ascii:]": ["\\x00-\\x7f", !1],
@@ -299,77 +332,138 @@ const Ht = 1024 * 64, L = (s) => {
299
332
  "[:upper:]": ["\\p{Lu}", !0],
300
333
  "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", !0],
301
334
  "[:xdigit:]": ["A-Fa-f0-9", !1]
302
- }, F = (s) => s.replace(/[[\]\\-]/g, "\\$&"), qt = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), Q = (s) => s.join(""), Gt = (s, t) => {
335
+ }, M = (s) => s.replace(/[[\]\\-]/g, "\\$&"), Qt = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), tt = (s) => s.join(""), Kt = (s, t) => {
303
336
  const e = t;
304
337
  if (s.charAt(e) !== "[")
305
338
  throw new Error("not in a brace expression");
306
339
  const n = [], r = [];
307
- let i = e + 1, o = !1, c = !1, a = !1, h = !1, l = e, d = "";
340
+ let i = e + 1, o = !1, a = !1, c = !1, l = !1, u = e, h = "";
308
341
  t: for (; i < s.length; ) {
309
342
  const p = s.charAt(i);
310
343
  if ((p === "!" || p === "^") && i === e + 1) {
311
- h = !0, i++;
344
+ l = !0, i++;
312
345
  continue;
313
346
  }
314
- if (p === "]" && o && !a) {
315
- l = i + 1;
347
+ if (p === "]" && o && !c) {
348
+ u = i + 1;
316
349
  break;
317
350
  }
318
- if (o = !0, p === "\\" && !a) {
319
- a = !0, i++;
351
+ if (o = !0, p === "\\" && !c) {
352
+ c = !0, i++;
320
353
  continue;
321
354
  }
322
- if (p === "[" && !a) {
323
- for (const [S, [A, C, x]] of Object.entries(_t))
324
- if (s.startsWith(S, i)) {
325
- if (d)
355
+ if (p === "[" && !c) {
356
+ for (const [E, [w, y, O]] of Object.entries(Jt))
357
+ if (s.startsWith(E, i)) {
358
+ if (h)
326
359
  return ["$.", !1, s.length - e, !0];
327
- i += S.length, x ? r.push(A) : n.push(A), c = c || C;
360
+ i += E.length, O ? r.push(w) : n.push(w), a = a || y;
328
361
  continue t;
329
362
  }
330
363
  }
331
- if (a = !1, d) {
332
- p > d ? n.push(F(d) + "-" + F(p)) : p === d && n.push(F(p)), d = "", i++;
364
+ if (c = !1, h) {
365
+ p > h ? n.push(M(h) + "-" + M(p)) : p === h && n.push(M(p)), h = "", i++;
333
366
  continue;
334
367
  }
335
368
  if (s.startsWith("-]", i + 1)) {
336
- n.push(F(p + "-")), i += 2;
369
+ n.push(M(p + "-")), i += 2;
337
370
  continue;
338
371
  }
339
372
  if (s.startsWith("-", i + 1)) {
340
- d = p, i += 2;
373
+ h = p, i += 2;
341
374
  continue;
342
375
  }
343
- n.push(F(p)), i++;
376
+ n.push(M(p)), i++;
344
377
  }
345
- if (l < i)
378
+ if (u < i)
346
379
  return ["", !1, 0, !1];
347
380
  if (!n.length && !r.length)
348
381
  return ["$.", !1, s.length - e, !0];
349
- if (r.length === 0 && n.length === 1 && /^\\?.$/.test(n[0]) && !h) {
382
+ if (r.length === 0 && n.length === 1 && /^\\?.$/.test(n[0]) && !l) {
350
383
  const p = n[0].length === 2 ? n[0].slice(-1) : n[0];
351
- return [qt(p), !1, l - e, !1];
352
- }
353
- const u = "[" + (h ? "^" : "") + Q(n) + "]", f = "[" + (h ? "" : "^") + Q(r) + "]";
354
- return [n.length && r.length ? "(" + u + "|" + f + ")" : n.length ? u : f, c, l - e, !0];
355
- }, M = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1"), Vt = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), tt = (s) => Vt.has(s), Yt = "(?!(?:^|/)\\.\\.?(?:$|/))", P = "(?!\\.)", Zt = /* @__PURE__ */ new Set(["[", "."]), Jt = /* @__PURE__ */ new Set(["..", "."]), Xt = new Set("().*{}+?[]^$\\!"), Kt = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), Y = "[^/]", et = Y + "*?", st = Y + "+?";
356
- class E {
384
+ return [Qt(p), !1, u - e, !1];
385
+ }
386
+ const f = "[" + (l ? "^" : "") + tt(n) + "]", d = "[" + (l ? "" : "^") + tt(r) + "]";
387
+ return [n.length && r.length ? "(" + f + "|" + d + ")" : n.length ? f : d, a, u - e, !0];
388
+ }, F = (s, { windowsPathsNoEscape: t = !1, magicalBraces: e = !0 } = {}) => e ? t ? s.replace(/\[([^/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\])\]/g, "$1$2").replace(/\\([^/])/g, "$1") : t ? s.replace(/\[([^/\\{}])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\{}])\]/g, "$1$2").replace(/\\([^/{}])/g, "$1");
389
+ var x;
390
+ const te = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), q = (s) => te.has(s), et = (s) => q(s.type), ee = /* @__PURE__ */ new Map([
391
+ ["!", ["@"]],
392
+ ["?", ["?", "@"]],
393
+ ["@", ["@"]],
394
+ ["*", ["*", "+", "?", "@"]],
395
+ ["+", ["+", "@"]]
396
+ ]), se = /* @__PURE__ */ new Map([
397
+ ["!", ["?"]],
398
+ ["@", ["?"]],
399
+ ["+", ["?", "*"]]
400
+ ]), ne = /* @__PURE__ */ new Map([
401
+ ["!", ["?", "@"]],
402
+ ["?", ["?", "@"]],
403
+ ["@", ["?", "@"]],
404
+ ["*", ["*", "+", "?", "@"]],
405
+ ["+", ["+", "@", "?", "*"]]
406
+ ]), st = /* @__PURE__ */ new Map([
407
+ ["!", /* @__PURE__ */ new Map([["!", "@"]])],
408
+ [
409
+ "?",
410
+ /* @__PURE__ */ new Map([
411
+ ["*", "*"],
412
+ ["+", "*"]
413
+ ])
414
+ ],
415
+ [
416
+ "@",
417
+ /* @__PURE__ */ new Map([
418
+ ["!", "!"],
419
+ ["?", "?"],
420
+ ["@", "@"],
421
+ ["*", "*"],
422
+ ["+", "+"]
423
+ ])
424
+ ],
425
+ [
426
+ "+",
427
+ /* @__PURE__ */ new Map([
428
+ ["?", "*"],
429
+ ["*", "*"]
430
+ ])
431
+ ]
432
+ ]), re = "(?!(?:^|/)\\.\\.?(?:$|/))", R = "(?!\\.)", ie = /* @__PURE__ */ new Set(["[", "."]), oe = /* @__PURE__ */ new Set(["..", "."]), ae = new Set("().*{}+?[]^$\\!"), ce = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), V = "[^/]", nt = V + "*?", rt = V + "+?";
433
+ let le = 0;
434
+ class Y {
357
435
  type;
358
436
  #s;
359
437
  #n;
360
- #i = !1;
438
+ #r = !1;
361
439
  #t = [];
362
440
  #e;
363
- #o;
364
- #c;
365
- #a = !1;
366
- #r;
441
+ #a;
367
442
  #l;
443
+ #c = !1;
444
+ #i;
445
+ #o;
368
446
  // set to true if it's an extglob with no children
369
447
  // (which really means one child of '')
370
- #u = !1;
448
+ #h = !1;
449
+ id = ++le;
450
+ get depth() {
451
+ return (this.#e?.depth ?? -1) + 1;
452
+ }
453
+ [/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")]() {
454
+ return {
455
+ "@@type": "AST",
456
+ id: this.id,
457
+ type: this.type,
458
+ root: this.#s.id,
459
+ parent: this.#e?.id,
460
+ depth: this.depth,
461
+ partsLength: this.#t.length,
462
+ parts: this.#t
463
+ };
464
+ }
371
465
  constructor(t, e, n = {}) {
372
- 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.#c = this.#s === this ? [] : this.#s.#c, t === "!" && !this.#s.#a && this.#c.push(this), this.#o = this.#e ? this.#e.#t.length : 0;
466
+ this.type = t, t && (this.#n = !0), this.#e = e, this.#s = this.#e ? this.#e.#s : this, this.#i = this.#s === this ? n : this.#s.#i, this.#l = this.#s === this ? [] : this.#s.#l, t === "!" && !this.#s.#c && this.#l.push(this), this.#a = this.#e ? this.#e.#t.length : 0;
373
467
  }
374
468
  get hasMagic() {
375
469
  if (this.#n !== void 0)
@@ -381,21 +475,21 @@ class E {
381
475
  }
382
476
  // reconstructs the pattern
383
477
  toString() {
384
- 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("");
478
+ return this.#o !== void 0 ? this.#o : this.type ? this.#o = this.type + "(" + this.#t.map((t) => String(t)).join("|") + ")" : this.#o = this.#t.map((t) => String(t)).join("");
385
479
  }
386
- #d() {
480
+ #w() {
387
481
  if (this !== this.#s)
388
482
  throw new Error("should only call on root");
389
- if (this.#a)
483
+ if (this.#c)
390
484
  return this;
391
- this.toString(), this.#a = !0;
485
+ this.toString(), this.#c = !0;
392
486
  let t;
393
- for (; t = this.#c.pop(); ) {
487
+ for (; t = this.#l.pop(); ) {
394
488
  if (t.type !== "!")
395
489
  continue;
396
490
  let e = t, n = e.#e;
397
491
  for (; n; ) {
398
- for (let r = e.#o + 1; !n.type && r < n.#t.length; r++)
492
+ for (let r = e.#a + 1; !n.type && r < n.#t.length; r++)
399
493
  for (const i of t.#t) {
400
494
  if (typeof i == "string")
401
495
  throw new Error("string part in extglob AST??");
@@ -409,26 +503,26 @@ class E {
409
503
  push(...t) {
410
504
  for (const e of t)
411
505
  if (e !== "") {
412
- if (typeof e != "string" && !(e instanceof E && e.#e === this))
506
+ if (typeof e != "string" && !(e instanceof x && e.#e === this))
413
507
  throw new Error("invalid part: " + e);
414
508
  this.#t.push(e);
415
509
  }
416
510
  }
417
511
  toJSON() {
418
512
  const t = this.type === null ? this.#t.slice().map((e) => typeof e == "string" ? e : e.toJSON()) : [this.type, ...this.#t.map((e) => e.toJSON())];
419
- return this.isStart() && !this.type && t.unshift([]), this.isEnd() && (this === this.#s || this.#s.#a && this.#e?.type === "!") && t.push({}), t;
513
+ return this.isStart() && !this.type && t.unshift([]), this.isEnd() && (this === this.#s || this.#s.#c && this.#e?.type === "!") && t.push({}), t;
420
514
  }
421
515
  isStart() {
422
516
  if (this.#s === this)
423
517
  return !0;
424
518
  if (!this.#e?.isStart())
425
519
  return !1;
426
- if (this.#o === 0)
520
+ if (this.#a === 0)
427
521
  return !0;
428
522
  const t = this.#e;
429
- for (let e = 0; e < this.#o; e++) {
523
+ for (let e = 0; e < this.#a; e++) {
430
524
  const n = t.#t[e];
431
- if (!(n instanceof E && n.type === "!"))
525
+ if (!(n instanceof x && n.type === "!"))
432
526
  return !1;
433
527
  }
434
528
  return !0;
@@ -441,79 +535,123 @@ class E {
441
535
  if (!this.type)
442
536
  return this.#e?.isEnd();
443
537
  const t = this.#e ? this.#e.#t.length : 0;
444
- return this.#o === t - 1;
538
+ return this.#a === t - 1;
445
539
  }
446
540
  copyIn(t) {
447
541
  typeof t == "string" ? this.push(t) : this.push(t.clone(this));
448
542
  }
449
543
  clone(t) {
450
- const e = new E(this.type, t);
544
+ const e = new x(this.type, t);
451
545
  for (const n of this.#t)
452
546
  e.copyIn(n);
453
547
  return e;
454
548
  }
455
- static #h(t, e, n, r) {
456
- let i = !1, o = !1, c = -1, a = !1;
549
+ static #u(t, e, n, r, i) {
550
+ const o = r.maxExtglobRecursion ?? 2;
551
+ let a = !1, c = !1, l = -1, u = !1;
457
552
  if (e.type === null) {
458
- let f = n, g = "";
459
- for (; f < t.length; ) {
460
- const p = t.charAt(f++);
461
- if (i || p === "\\") {
462
- i = !i, g += p;
553
+ let p = n, E = "";
554
+ for (; p < t.length; ) {
555
+ const w = t.charAt(p++);
556
+ if (a || w === "\\") {
557
+ a = !a, E += w;
463
558
  continue;
464
559
  }
465
- if (o) {
466
- f === c + 1 ? (p === "^" || p === "!") && (a = !0) : p === "]" && !(f === c + 2 && a) && (o = !1), g += p;
560
+ if (c) {
561
+ p === l + 1 ? (w === "^" || w === "!") && (u = !0) : w === "]" && !(p === l + 2 && u) && (c = !1), E += w;
467
562
  continue;
468
- } else if (p === "[") {
469
- o = !0, c = f, a = !1, g += p;
563
+ } else if (w === "[") {
564
+ c = !0, l = p, u = !1, E += w;
470
565
  continue;
471
566
  }
472
- if (!r.noext && tt(p) && t.charAt(f) === "(") {
473
- e.push(g), g = "";
474
- const S = new E(p, e);
475
- f = E.#h(t, S, f, r), e.push(S);
567
+ if (!r.noext && q(w) && t.charAt(p) === "(" && i <= o) {
568
+ e.push(E), E = "";
569
+ const O = new x(w, e);
570
+ p = x.#u(t, O, p, r, i + 1), e.push(O);
476
571
  continue;
477
572
  }
478
- g += p;
573
+ E += w;
479
574
  }
480
- return e.push(g), f;
575
+ return e.push(E), p;
481
576
  }
482
- let h = n + 1, l = new E(null, e);
577
+ let h = n + 1, f = new x(null, e);
483
578
  const d = [];
484
- let u = "";
579
+ let g = "";
485
580
  for (; h < t.length; ) {
486
- const f = t.charAt(h++);
487
- if (i || f === "\\") {
488
- i = !i, u += f;
581
+ const p = t.charAt(h++);
582
+ if (a || p === "\\") {
583
+ a = !a, g += p;
489
584
  continue;
490
585
  }
491
- if (o) {
492
- h === c + 1 ? (f === "^" || f === "!") && (a = !0) : f === "]" && !(h === c + 2 && a) && (o = !1), u += f;
586
+ if (c) {
587
+ h === l + 1 ? (p === "^" || p === "!") && (u = !0) : p === "]" && !(h === l + 2 && u) && (c = !1), g += p;
493
588
  continue;
494
- } else if (f === "[") {
495
- o = !0, c = h, a = !1, u += f;
589
+ } else if (p === "[") {
590
+ c = !0, l = h, u = !1, g += p;
496
591
  continue;
497
592
  }
498
- if (tt(f) && t.charAt(h) === "(") {
499
- l.push(u), u = "";
500
- const g = new E(f, l);
501
- l.push(g), h = E.#h(t, g, h, r);
593
+ if (!r.noext && q(p) && t.charAt(h) === "(" && /* c8 ignore start - the maxDepth is sufficient here */
594
+ (i <= o || e && e.#f(p))) {
595
+ const w = e && e.#f(p) ? 0 : 1;
596
+ f.push(g), g = "";
597
+ const y = new x(p, f);
598
+ f.push(y), h = x.#u(t, y, h, r, i + w);
502
599
  continue;
503
600
  }
504
- if (f === "|") {
505
- l.push(u), u = "", d.push(l), l = new E(null, e);
601
+ if (p === "|") {
602
+ f.push(g), g = "", d.push(f), f = new x(null, e);
506
603
  continue;
507
604
  }
508
- if (f === ")")
509
- return u === "" && e.#t.length === 0 && (e.#u = !0), l.push(u), u = "", e.push(...d, l), h;
510
- u += f;
605
+ if (p === ")")
606
+ return g === "" && e.#t.length === 0 && (e.#h = !0), f.push(g), g = "", e.push(...d, f), h;
607
+ g += p;
511
608
  }
512
609
  return e.type = null, e.#n = void 0, e.#t = [t.substring(n - 1)], h;
513
610
  }
611
+ #y(t) {
612
+ return this.#d(t, se);
613
+ }
614
+ #d(t, e = ee) {
615
+ if (!t || typeof t != "object" || t.type !== null || t.#t.length !== 1 || this.type === null)
616
+ return !1;
617
+ const n = t.#t[0];
618
+ return !n || typeof n != "object" || n.type === null ? !1 : this.#f(n.type, e);
619
+ }
620
+ #f(t, e = ne) {
621
+ return !!e.get(this.type)?.includes(t);
622
+ }
623
+ #E(t, e) {
624
+ const n = t.#t[0], r = new x(null, n, this.options);
625
+ r.#t.push(""), n.push(r), this.#g(t, e);
626
+ }
627
+ #g(t, e) {
628
+ const n = t.#t[0];
629
+ this.#t.splice(e, 1, ...n.#t);
630
+ for (const r of n.#t)
631
+ typeof r == "object" && (r.#e = this);
632
+ this.#o = void 0;
633
+ }
634
+ #S(t) {
635
+ return !!st.get(this.type)?.has(t);
636
+ }
637
+ #b(t) {
638
+ if (!t || typeof t != "object" || t.type !== null || t.#t.length !== 1 || this.type === null || this.#t.length !== 1)
639
+ return !1;
640
+ const e = t.#t[0];
641
+ return !e || typeof e != "object" || e.type === null ? !1 : this.#S(e.type);
642
+ }
643
+ #x(t) {
644
+ const e = st.get(this.type), n = t.#t[0], r = e?.get(n.type);
645
+ if (!r)
646
+ return !1;
647
+ this.#t = n.#t;
648
+ for (const i of this.#t)
649
+ typeof i == "object" && (i.#e = this);
650
+ this.type = r, this.#o = void 0, this.#h = !1;
651
+ }
514
652
  static fromGlob(t, e = {}) {
515
- const n = new E(null, void 0, e);
516
- return E.#h(t, n, 0, e), n;
653
+ const n = new x(null, void 0, e);
654
+ return x.#u(t, n, 0, e, 0), n;
517
655
  }
518
656
  // returns the regular expression if there's magic, or the unescaped
519
657
  // string if not.
@@ -521,16 +659,16 @@ class E {
521
659
  if (this !== this.#s)
522
660
  return this.#s.toMMPattern();
523
661
  const t = this.toString(), [e, n, r, i] = this.toRegExpSource();
524
- if (!(r || this.#n || this.#r.nocase && !this.#r.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
662
+ if (!(r || this.#n || this.#i.nocase && !this.#i.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
525
663
  return n;
526
- const c = (this.#r.nocase ? "i" : "") + (i ? "u" : "");
527
- return Object.assign(new RegExp(`^${e}$`, c), {
664
+ const a = (this.#i.nocase ? "i" : "") + (i ? "u" : "");
665
+ return Object.assign(new RegExp(`^${e}$`, a), {
528
666
  _src: e,
529
667
  _glob: t
530
668
  });
531
669
  }
532
670
  get options() {
533
- return this.#r;
671
+ return this.#i;
534
672
  }
535
673
  // returns the string match, the regexp source, whether there's magic
536
674
  // in the regexp (so a regular expression is required) and whether or
@@ -602,168 +740,187 @@ class E {
602
740
  // is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
603
741
  // or start or whatever) and prepend ^ or / at the Regexp construction.
604
742
  toRegExpSource(t) {
605
- const e = t ?? !!this.#r.dot;
606
- if (this.#s === this && this.#d(), !this.type) {
607
- const a = this.isStart() && this.isEnd(), h = this.#t.map((f) => {
608
- const [g, p, S, A] = typeof f == "string" ? E.#p(f, this.#n, a) : f.toRegExpSource(t);
609
- return this.#n = this.#n || S, this.#i = this.#i || A, g;
743
+ const e = t ?? !!this.#i.dot;
744
+ if (this.#s === this && (this.#p(), this.#w()), !et(this)) {
745
+ const c = this.isStart() && this.isEnd() && !this.#t.some((d) => typeof d != "string"), l = this.#t.map((d) => {
746
+ const [g, p, E, w] = typeof d == "string" ? x.#A(d, this.#n, c) : d.toRegExpSource(t);
747
+ return this.#n = this.#n || E, this.#r = this.#r || w, g;
610
748
  }).join("");
611
- let l = "";
612
- if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && Jt.has(this.#t[0]))) {
613
- const g = Zt, p = (
749
+ let u = "";
750
+ if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && oe.has(this.#t[0]))) {
751
+ const g = ie, p = (
614
752
  // dots are allowed, and the pattern starts with [ or .
615
- e && g.has(h.charAt(0)) || // the pattern starts with \., and then [ or .
616
- h.startsWith("\\.") && g.has(h.charAt(2)) || // the pattern starts with \.\., and then [ or .
617
- h.startsWith("\\.\\.") && g.has(h.charAt(4))
618
- ), S = !e && !t && g.has(h.charAt(0));
619
- l = p ? Yt : S ? P : "";
753
+ e && g.has(l.charAt(0)) || // the pattern starts with \., and then [ or .
754
+ l.startsWith("\\.") && g.has(l.charAt(2)) || // the pattern starts with \.\., and then [ or .
755
+ l.startsWith("\\.\\.") && g.has(l.charAt(4))
756
+ ), E = !e && !t && g.has(l.charAt(0));
757
+ u = p ? re : E ? R : "";
620
758
  }
621
- let d = "";
622
- return this.isEnd() && this.#s.#a && this.#e?.type === "!" && (d = "(?:$|\\/)"), [
623
- l + h + d,
624
- M(h),
759
+ let h = "";
760
+ return this.isEnd() && this.#s.#c && this.#e?.type === "!" && (h = "(?:$|\\/)"), [
761
+ u + l + h,
762
+ F(l),
625
763
  this.#n = !!this.#n,
626
- this.#i
764
+ this.#r
627
765
  ];
628
766
  }
629
767
  const n = this.type === "*" || this.type === "+", r = this.type === "!" ? "(?:(?!(?:" : "(?:";
630
- let i = this.#f(e);
768
+ let i = this.#m(e);
631
769
  if (this.isStart() && this.isEnd() && !i && this.type !== "!") {
632
- const a = this.toString();
633
- return this.#t = [a], this.type = null, this.#n = void 0, [a, M(this.toString()), !1, !1];
770
+ const c = this.toString(), l = this;
771
+ return l.#t = [c], l.type = null, l.#n = void 0, [c, F(this.toString()), !1, !1];
634
772
  }
635
- let o = !n || t || e || !P ? "" : this.#f(!0);
773
+ let o = !n || t || e || !R ? "" : this.#m(!0);
636
774
  o === i && (o = ""), o && (i = `(?:${i})(?:${o})*?`);
637
- let c = "";
638
- if (this.type === "!" && this.#u)
639
- c = (this.isStart() && !e ? P : "") + st;
775
+ let a = "";
776
+ if (this.type === "!" && this.#h)
777
+ a = (this.isStart() && !e ? R : "") + rt;
640
778
  else {
641
- const a = this.type === "!" ? (
779
+ const c = this.type === "!" ? (
642
780
  // !() must match something,but !(x) can match ''
643
- "))" + (this.isStart() && !e && !t ? P : "") + et + ")"
781
+ "))" + (this.isStart() && !e && !t ? R : "") + nt + ")"
644
782
  ) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : `)${this.type}`;
645
- c = r + i + a;
783
+ a = r + i + c;
646
784
  }
647
785
  return [
648
- c,
649
- M(i),
786
+ a,
787
+ F(i),
650
788
  this.#n = !!this.#n,
651
- this.#i
789
+ this.#r
652
790
  ];
653
791
  }
654
- #f(t) {
792
+ #p() {
793
+ if (et(this)) {
794
+ let t = 0, e = !1;
795
+ do {
796
+ e = !0;
797
+ for (let n = 0; n < this.#t.length; n++) {
798
+ const r = this.#t[n];
799
+ typeof r == "object" && (r.#p(), this.#d(r) ? (e = !1, this.#g(r, n)) : this.#y(r) ? (e = !1, this.#E(r, n)) : this.#b(r) && (e = !1, this.#x(r)));
800
+ }
801
+ } while (!e && ++t < 10);
802
+ } else
803
+ for (const t of this.#t)
804
+ typeof t == "object" && t.#p();
805
+ this.#o = void 0;
806
+ }
807
+ #m(t) {
655
808
  return this.#t.map((e) => {
656
809
  if (typeof e == "string")
657
810
  throw new Error("string type in extglob ast??");
658
811
  const [n, r, i, o] = e.toRegExpSource(t);
659
- return this.#i = this.#i || o, n;
812
+ return this.#r = this.#r || o, n;
660
813
  }).filter((e) => !(this.isStart() && this.isEnd()) || !!e).join("|");
661
814
  }
662
- static #p(t, e, n = !1) {
663
- let r = !1, i = "", o = !1;
815
+ static #A(t, e, n = !1) {
816
+ let r = !1, i = "", o = !1, a = !1;
664
817
  for (let c = 0; c < t.length; c++) {
665
- const a = t.charAt(c);
818
+ const l = t.charAt(c);
666
819
  if (r) {
667
- r = !1, i += (Xt.has(a) ? "\\" : "") + a;
820
+ r = !1, i += (ae.has(l) ? "\\" : "") + l;
668
821
  continue;
669
822
  }
670
- if (a === "\\") {
823
+ if (l === "*") {
824
+ if (a)
825
+ continue;
826
+ a = !0, i += n && /^[*]+$/.test(t) ? rt : nt, e = !0;
827
+ continue;
828
+ } else
829
+ a = !1;
830
+ if (l === "\\") {
671
831
  c === t.length - 1 ? i += "\\\\" : r = !0;
672
832
  continue;
673
833
  }
674
- if (a === "[") {
675
- const [h, l, d, u] = Gt(t, c);
676
- if (d) {
677
- i += h, o = o || l, c += d - 1, e = e || u;
834
+ if (l === "[") {
835
+ const [u, h, f, d] = Kt(t, c);
836
+ if (f) {
837
+ i += u, o = o || h, c += f - 1, e = e || d;
678
838
  continue;
679
839
  }
680
840
  }
681
- if (a === "*") {
682
- n && t === "*" ? i += st : i += et, e = !0;
841
+ if (l === "?") {
842
+ i += V, e = !0;
683
843
  continue;
684
844
  }
685
- if (a === "?") {
686
- i += Y, e = !0;
687
- continue;
688
- }
689
- i += Kt(a);
845
+ i += ce(l);
690
846
  }
691
- return [i, M(t), !!e, o];
847
+ return [i, F(t), !!e, o];
692
848
  }
693
849
  }
694
- const Qt = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&"), y = (s, t, e = {}) => (L(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new B(t, e).match(s)), te = /^\*+([^+@!?\*\[\(]*)$/, ee = (s) => (t) => !t.startsWith(".") && t.endsWith(s), se = (s) => (t) => t.endsWith(s), ne = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), re = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), ie = /^\*+\.\*+$/, oe = (s) => !s.startsWith(".") && s.includes("."), ae = (s) => s !== "." && s !== ".." && s.includes("."), ce = /^\.\*+$/, le = (s) => s !== "." && s !== ".." && s.startsWith("."), he = /^\*+$/, ue = (s) => s.length !== 0 && !s.startsWith("."), fe = (s) => s.length !== 0 && s !== "." && s !== "..", de = /^\?+([^+@!?\*\[\(]*)?$/, pe = ([s, t = ""]) => {
695
- const e = dt([s]);
850
+ x = Y;
851
+ const he = (s, { windowsPathsNoEscape: t = !1, magicalBraces: e = !1 } = {}) => e ? t ? s.replace(/[?*()[\]{}]/g, "[$&]") : s.replace(/[?*()[\]\\{}]/g, "\\$&") : t ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&"), S = (s, t, e = {}) => (k(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new L(t, e).match(s)), ue = /^\*+([^+@!?*[(]*)$/, fe = (s) => (t) => !t.startsWith(".") && t.endsWith(s), pe = (s) => (t) => t.endsWith(s), de = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), ge = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), me = /^\*+\.\*+$/, we = (s) => !s.startsWith(".") && s.includes("."), ye = (s) => s !== "." && s !== ".." && s.includes("."), Ee = /^\.\*+$/, Se = (s) => s !== "." && s !== ".." && s.startsWith("."), be = /^\*+$/, xe = (s) => s.length !== 0 && !s.startsWith("."), Ae = (s) => s.length !== 0 && s !== "." && s !== "..", ve = /^\?+([^+@!?*[(]*)?$/, Oe = ([s, t = ""]) => {
852
+ const e = gt([s]);
696
853
  return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
697
- }, ge = ([s, t = ""]) => {
698
- const e = pt([s]);
854
+ }, $e = ([s, t = ""]) => {
855
+ const e = mt([s]);
699
856
  return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
700
- }, me = ([s, t = ""]) => {
701
- const e = pt([s]);
857
+ }, Ne = ([s, t = ""]) => {
858
+ const e = mt([s]);
702
859
  return t ? (n) => e(n) && n.endsWith(t) : e;
703
- }, we = ([s, t = ""]) => {
704
- const e = dt([s]);
860
+ }, De = ([s, t = ""]) => {
861
+ const e = gt([s]);
705
862
  return t ? (n) => e(n) && n.endsWith(t) : e;
706
- }, dt = ([s]) => {
863
+ }, gt = ([s]) => {
707
864
  const t = s.length;
708
865
  return (e) => e.length === t && !e.startsWith(".");
709
- }, pt = ([s]) => {
866
+ }, mt = ([s]) => {
710
867
  const t = s.length;
711
868
  return (e) => e.length === t && e !== "." && e !== "..";
712
- }, gt = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", nt = {
869
+ }, wt = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", it = {
713
870
  win32: { sep: "\\" },
714
871
  posix: { sep: "/" }
715
- }, ye = gt === "win32" ? nt.win32.sep : nt.posix.sep;
716
- y.sep = ye;
717
- const v = Symbol("globstar **");
718
- y.GLOBSTAR = v;
719
- const Ee = "[^/]", Se = Ee + "*?", xe = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?", be = "(?:(?!(?:\\/|^)\\.).)*?", ve = (s, t = {}) => (e) => y(e, s, t);
720
- y.filter = ve;
721
- const b = (s, t = {}) => Object.assign({}, s, t), Oe = (s) => {
872
+ }, Te = wt === "win32" ? it.win32.sep : it.posix.sep;
873
+ S.sep = Te;
874
+ const b = /* @__PURE__ */ Symbol("globstar **");
875
+ S.GLOBSTAR = b;
876
+ const Ce = "[^/]", Me = Ce + "*?", Fe = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?", Re = "(?:(?!(?:\\/|^)\\.).)*?", Pe = (s, t = {}) => (e) => S(e, s, t);
877
+ S.filter = Pe;
878
+ const A = (s, t = {}) => Object.assign({}, s, t), ke = (s) => {
722
879
  if (!s || typeof s != "object" || !Object.keys(s).length)
723
- return y;
724
- const t = y;
725
- return Object.assign((n, r, i = {}) => t(n, r, b(s, i)), {
880
+ return S;
881
+ const t = S;
882
+ return Object.assign((n, r, i = {}) => t(n, r, A(s, i)), {
726
883
  Minimatch: class extends t.Minimatch {
727
884
  constructor(r, i = {}) {
728
- super(r, b(s, i));
885
+ super(r, A(s, i));
729
886
  }
730
887
  static defaults(r) {
731
- return t.defaults(b(s, r)).Minimatch;
888
+ return t.defaults(A(s, r)).Minimatch;
732
889
  }
733
890
  },
734
891
  AST: class extends t.AST {
735
892
  /* c8 ignore start */
736
893
  constructor(r, i, o = {}) {
737
- super(r, i, b(s, o));
894
+ super(r, i, A(s, o));
738
895
  }
739
896
  /* c8 ignore stop */
740
897
  static fromGlob(r, i = {}) {
741
- return t.AST.fromGlob(r, b(s, i));
898
+ return t.AST.fromGlob(r, A(s, i));
742
899
  }
743
900
  },
744
- unescape: (n, r = {}) => t.unescape(n, b(s, r)),
745
- escape: (n, r = {}) => t.escape(n, b(s, r)),
746
- filter: (n, r = {}) => t.filter(n, b(s, r)),
747
- defaults: (n) => t.defaults(b(s, n)),
748
- makeRe: (n, r = {}) => t.makeRe(n, b(s, r)),
749
- braceExpand: (n, r = {}) => t.braceExpand(n, b(s, r)),
750
- match: (n, r, i = {}) => t.match(n, r, b(s, i)),
901
+ unescape: (n, r = {}) => t.unescape(n, A(s, r)),
902
+ escape: (n, r = {}) => t.escape(n, A(s, r)),
903
+ filter: (n, r = {}) => t.filter(n, A(s, r)),
904
+ defaults: (n) => t.defaults(A(s, n)),
905
+ makeRe: (n, r = {}) => t.makeRe(n, A(s, r)),
906
+ braceExpand: (n, r = {}) => t.braceExpand(n, A(s, r)),
907
+ match: (n, r, i = {}) => t.match(n, r, A(s, i)),
751
908
  sep: t.sep,
752
- GLOBSTAR: v
909
+ GLOBSTAR: b
753
910
  });
754
911
  };
755
- y.defaults = Oe;
756
- const mt = (s, t = {}) => (L(s), t.nobrace || !/\{(?:(?!\{).)*\}/.test(s) ? [s] : zt(s));
757
- y.braceExpand = mt;
758
- const Ae = (s, t = {}) => new B(s, t).makeRe();
759
- y.makeRe = Ae;
760
- const De = (s, t, e = {}) => {
761
- const n = new B(t, e);
912
+ S.defaults = ke;
913
+ const yt = (s, t = {}) => (k(s), t.nobrace || !/\{(?:(?!\{).)*\}/.test(s) ? [s] : Ht(s, { max: t.braceExpandMax }));
914
+ S.braceExpand = yt;
915
+ const Ie = (s, t = {}) => new L(s, t).makeRe();
916
+ S.makeRe = Ie;
917
+ const Le = (s, t, e = {}) => {
918
+ const n = new L(t, e);
762
919
  return s = s.filter((r) => n.match(r)), n.options.nonull && !s.length && s.push(t), s;
763
920
  };
764
- y.match = De;
765
- const rt = /[?*]|[+@!]\(.*?\)|\[|\]/, Ne = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
766
- class B {
921
+ S.match = Le;
922
+ const ot = /[?*]|[+@!]\(.*?\)|\[|\]/, ze = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
923
+ class L {
767
924
  options;
768
925
  set;
769
926
  pattern;
@@ -780,9 +937,12 @@ class B {
780
937
  isWindows;
781
938
  platform;
782
939
  windowsNoMagicRoot;
940
+ maxGlobstarRecursion;
783
941
  regexp;
784
942
  constructor(t, e = {}) {
785
- L(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || gt, 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();
943
+ k(t), e = e || {}, this.options = e, this.maxGlobstarRecursion = e.maxGlobstarRecursion ?? 200, this.pattern = t, this.platform = e.platform || wt, this.isWindows = this.platform === "win32";
944
+ const n = "allowWindowsEscape";
945
+ this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e[n] === !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();
786
946
  }
787
947
  hasMagic() {
788
948
  if (this.options.magicalBraces && this.set.length > 1)
@@ -808,15 +968,18 @@ class B {
808
968
  this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...i) => console.error(...i)), this.debug(this.pattern, this.globSet);
809
969
  const n = this.globSet.map((i) => this.slashSplit(i));
810
970
  this.globParts = this.preprocess(n), this.debug(this.pattern, this.globParts);
811
- let r = this.globParts.map((i, o, c) => {
971
+ let r = this.globParts.map((i, o, a) => {
812
972
  if (this.isWindows && this.windowsNoMagicRoot) {
813
- const a = i[0] === "" && i[1] === "" && (i[2] === "?" || !rt.test(i[2])) && !rt.test(i[3]), h = /^[a-z]:/i.test(i[0]);
814
- if (a)
815
- return [...i.slice(0, 4), ...i.slice(4).map((l) => this.parse(l))];
816
- if (h)
817
- return [i[0], ...i.slice(1).map((l) => this.parse(l))];
973
+ const c = i[0] === "" && i[1] === "" && (i[2] === "?" || !ot.test(i[2])) && !ot.test(i[3]), l = /^[a-z]:/i.test(i[0]);
974
+ if (c)
975
+ return [
976
+ ...i.slice(0, 4),
977
+ ...i.slice(4).map((u) => this.parse(u))
978
+ ];
979
+ if (l)
980
+ return [i[0], ...i.slice(1).map((u) => this.parse(u))];
818
981
  }
819
- return i.map((a) => this.parse(a));
982
+ return i.map((c) => this.parse(c));
820
983
  });
821
984
  if (this.debug(this.pattern, r), this.set = r.filter((i) => i.indexOf(!1) === -1), this.isWindows)
822
985
  for (let i = 0; i < this.set.length; i++) {
@@ -832,9 +995,9 @@ class B {
832
995
  // of patterns that we have to process.
833
996
  preprocess(t) {
834
997
  if (this.options.noglobstar)
835
- for (let n = 0; n < t.length; n++)
836
- for (let r = 0; r < t[n].length; r++)
837
- t[n][r] === "**" && (t[n][r] = "*");
998
+ for (const n of t)
999
+ for (let r = 0; r < n.length; r++)
1000
+ n[r] === "**" && (n[r] = "*");
838
1001
  const { optimizationLevel: e = 1 } = this.options;
839
1002
  return e >= 2 ? (t = this.firstPhasePreProcess(t), t = this.secondPhasePreProcess(t)) : e >= 1 ? t = this.levelOneOptimize(t) : t = this.adjascentGlobstarOptimize(t), t;
840
1003
  }
@@ -872,7 +1035,7 @@ class B {
872
1035
  let n = 0;
873
1036
  for (; (n = t.indexOf("..", n + 1)) !== -1; ) {
874
1037
  const r = t[n - 1];
875
- r && r !== "." && r !== ".." && r !== "**" && (e = !0, t.splice(n - 1, 2), n -= 2);
1038
+ r && r !== "." && r !== ".." && r !== "**" && !(this.isWindows && /^[a-z]:$/i.test(r)) && (e = !0, t.splice(n - 1, 2), n -= 2);
876
1039
  }
877
1040
  } while (e);
878
1041
  return t.length === 0 ? [""] : t;
@@ -906,18 +1069,18 @@ class B {
906
1069
  for (; n[o + 1] === "**"; )
907
1070
  o++;
908
1071
  o > r && n.splice(r + 1, o - r);
909
- let c = n[r + 1];
910
- const a = n[r + 2], h = n[r + 3];
911
- if (c !== ".." || !a || a === "." || a === ".." || !h || h === "." || h === "..")
1072
+ let a = n[r + 1];
1073
+ const c = n[r + 2], l = n[r + 3];
1074
+ if (a !== ".." || !c || c === "." || c === ".." || !l || l === "." || l === "..")
912
1075
  continue;
913
1076
  e = !0, n.splice(r, 1);
914
- const l = n.slice(0);
915
- l[r] = "**", t.push(l), r--;
1077
+ const u = n.slice(0);
1078
+ u[r] = "**", t.push(u), r--;
916
1079
  }
917
1080
  if (!this.preserveMultipleSlashes) {
918
1081
  for (let o = 1; o < n.length - 1; o++) {
919
- const c = n[o];
920
- o === 1 && c === "" && n[0] === "" || (c === "." || c === "") && (e = !0, n.splice(o, 1), o--);
1082
+ const a = n[o];
1083
+ o === 1 && a === "" && n[0] === "" || (a === "." || a === "") && (e = !0, n.splice(o, 1), o--);
921
1084
  }
922
1085
  n[0] === "." && n.length === 2 && (n[1] === "." || n[1] === "") && (e = !0, n.pop());
923
1086
  }
@@ -926,8 +1089,8 @@ class B {
926
1089
  const o = n[i - 1];
927
1090
  if (o && o !== "." && o !== ".." && o !== "**") {
928
1091
  e = !0;
929
- const a = i === 1 && n[i + 1] === "**" ? ["."] : [];
930
- n.splice(i - 1, 2, ...a), n.length === 0 && n.push(""), i -= 2;
1092
+ const c = i === 1 && n[i + 1] === "**" ? ["."] : [];
1093
+ n.splice(i - 1, 2, ...c), n.length === 0 && n.push(""), i -= 2;
931
1094
  }
932
1095
  }
933
1096
  }
@@ -953,22 +1116,22 @@ class B {
953
1116
  return t.filter((e) => e.length);
954
1117
  }
955
1118
  partsMatch(t, e, n = !1) {
956
- let r = 0, i = 0, o = [], c = "";
1119
+ let r = 0, i = 0, o = [], a = "";
957
1120
  for (; r < t.length && i < e.length; )
958
1121
  if (t[r] === e[i])
959
- o.push(c === "b" ? e[i] : t[r]), r++, i++;
1122
+ o.push(a === "b" ? e[i] : t[r]), r++, i++;
960
1123
  else if (n && t[r] === "**" && e[i] === t[r + 1])
961
1124
  o.push(t[r]), r++;
962
1125
  else if (n && e[i] === "**" && t[r] === e[i + 1])
963
1126
  o.push(e[i]), i++;
964
1127
  else if (t[r] === "*" && e[i] && (this.options.dot || !e[i].startsWith(".")) && e[i] !== "**") {
965
- if (c === "b")
1128
+ if (a === "b")
966
1129
  return !1;
967
- c = "a", o.push(t[r]), r++, i++;
1130
+ a = "a", o.push(t[r]), r++, i++;
968
1131
  } else if (e[i] === "*" && t[r] && (this.options.dot || !t[r].startsWith(".")) && t[r] !== "**") {
969
- if (c === "a")
1132
+ if (a === "a")
970
1133
  return !1;
971
- c = "b", o.push(e[i]), r++, i++;
1134
+ a = "b", o.push(e[i]), r++, i++;
972
1135
  } else
973
1136
  return !1;
974
1137
  return t.length === e.length && o;
@@ -988,69 +1151,128 @@ class B {
988
1151
  // out of pattern, then that's fine, as long as all
989
1152
  // the parts match.
990
1153
  matchOne(t, e, n = !1) {
991
- const r = this.options;
1154
+ let r = 0, i = 0;
992
1155
  if (this.isWindows) {
993
- const p = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), S = !p && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), A = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), C = !A && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : p ? 0 : void 0, w = C ? 3 : A ? 0 : void 0;
994
- if (typeof x == "number" && typeof w == "number") {
995
- const [T, R] = [t[x], e[w]];
996
- T.toLowerCase() === R.toLowerCase() && (e[w] = T, w > x ? e = e.slice(w) : x > w && (t = t.slice(x)));
1156
+ const a = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), c = !a && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), l = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), u = !l && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), h = c ? 3 : a ? 0 : void 0, f = u ? 3 : l ? 0 : void 0;
1157
+ if (typeof h == "number" && typeof f == "number") {
1158
+ const [d, g] = [
1159
+ t[h],
1160
+ e[f]
1161
+ ];
1162
+ d.toLowerCase() === g.toLowerCase() && (e[f] = d, i = f, r = h);
997
1163
  }
998
1164
  }
999
- const { optimizationLevel: i = 1 } = this.options;
1000
- i >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.length);
1001
- for (var o = 0, c = 0, a = t.length, h = e.length; o < a && c < h; o++, c++) {
1002
- this.debug("matchOne loop");
1003
- var l = e[c], d = t[o];
1004
- if (this.debug(e, l, d), l === !1)
1165
+ const { optimizationLevel: o = 1 } = this.options;
1166
+ return o >= 2 && (t = this.levelTwoFileOptimize(t)), e.includes(b) ? this.#s(t, e, n, r, i) : this.#r(t, e, n, r, i);
1167
+ }
1168
+ #s(t, e, n, r, i) {
1169
+ const o = e.indexOf(b, i), a = e.lastIndexOf(b), [c, l, u] = n ? [
1170
+ e.slice(i, o),
1171
+ e.slice(o + 1),
1172
+ []
1173
+ ] : [
1174
+ e.slice(i, o),
1175
+ e.slice(o + 1, a),
1176
+ e.slice(a + 1)
1177
+ ];
1178
+ if (c.length) {
1179
+ const y = t.slice(r, r + c.length);
1180
+ if (!this.#r(y, c, n, 0, 0))
1005
1181
  return !1;
1006
- if (l === v) {
1007
- this.debug("GLOBSTAR", [e, l, d]);
1008
- var u = o, f = c + 1;
1009
- if (f === h) {
1010
- for (this.debug("** at the end"); o < a; o++)
1011
- if (t[o] === "." || t[o] === ".." || !r.dot && t[o].charAt(0) === ".")
1012
- return !1;
1013
- return !0;
1014
- }
1015
- for (; u < a; ) {
1016
- var g = t[u];
1017
- if (this.debug(`
1018
- globstar while`, t, u, e, f, g), this.matchOne(t.slice(u), e.slice(f), n))
1019
- return this.debug("globstar found match!", u, a, g), !0;
1020
- if (g === "." || g === ".." || !r.dot && g.charAt(0) === ".") {
1021
- this.debug("dot detected!", t, u, e, f);
1022
- break;
1023
- }
1024
- this.debug("globstar swallow a segment, and continue"), u++;
1025
- }
1026
- return !!(n && (this.debug(`
1027
- >>> no match, partial?`, t, u, e, f), u === a));
1182
+ r += c.length, i += c.length;
1183
+ }
1184
+ let h = 0;
1185
+ if (u.length) {
1186
+ if (u.length + r > t.length)
1187
+ return !1;
1188
+ let y = t.length - u.length;
1189
+ if (this.#r(t, u, n, y, 0))
1190
+ h = u.length;
1191
+ else {
1192
+ if (t[t.length - 1] !== "" || r + u.length === t.length || (y--, !this.#r(t, u, n, y, 0)))
1193
+ return !1;
1194
+ h = u.length + 1;
1195
+ }
1196
+ }
1197
+ if (!l.length) {
1198
+ let y = !!h;
1199
+ for (let O = r; O < t.length - h; O++) {
1200
+ const z = String(t[O]);
1201
+ if (y = !0, z === "." || z === ".." || !this.options.dot && z.startsWith("."))
1202
+ return !1;
1028
1203
  }
1029
- let p;
1030
- if (typeof l == "string" ? (p = d === l, this.debug("string match", l, d, p)) : (p = l.test(d), this.debug("pattern match", l, d, p)), !p)
1204
+ return n || y;
1205
+ }
1206
+ const f = [[[], 0]];
1207
+ let d = f[0], g = 0;
1208
+ const p = [0];
1209
+ for (const y of l)
1210
+ y === b ? (p.push(g), d = [[], 0], f.push(d)) : (d[0].push(y), g++);
1211
+ let E = f.length - 1;
1212
+ const w = t.length - h;
1213
+ for (const y of f)
1214
+ y[1] = w - (p[E--] + y[0].length);
1215
+ return !!this.#n(t, f, r, 0, n, 0, !!h);
1216
+ }
1217
+ // return false for "nope, not matching"
1218
+ // return null for "not matching, cannot keep trying"
1219
+ #n(t, e, n, r, i, o, a) {
1220
+ const c = e[r];
1221
+ if (!c) {
1222
+ for (let h = n; h < t.length; h++) {
1223
+ a = !0;
1224
+ const f = t[h];
1225
+ if (f === "." || f === ".." || !this.options.dot && f.startsWith("."))
1226
+ return !1;
1227
+ }
1228
+ return a;
1229
+ }
1230
+ const [l, u] = c;
1231
+ for (; n <= u; ) {
1232
+ if (this.#r(t.slice(0, n + l.length), l, i, n, 0) && o < this.maxGlobstarRecursion) {
1233
+ const d = this.#n(t, e, n + l.length, r + 1, i, o + 1, a);
1234
+ if (d !== !1)
1235
+ return d;
1236
+ }
1237
+ const f = t[n];
1238
+ if (f === "." || f === ".." || !this.options.dot && f.startsWith("."))
1239
+ return !1;
1240
+ n++;
1241
+ }
1242
+ return i || null;
1243
+ }
1244
+ #r(t, e, n, r, i) {
1245
+ let o, a, c, l;
1246
+ for (o = r, a = i, l = t.length, c = e.length; o < l && a < c; o++, a++) {
1247
+ this.debug("matchOne loop");
1248
+ let u = e[a], h = t[o];
1249
+ if (this.debug(e, u, h), u === !1 || u === b)
1250
+ return !1;
1251
+ let f;
1252
+ if (typeof u == "string" ? (f = h === u, this.debug("string match", u, h, f)) : (f = u.test(h), this.debug("pattern match", u, h, f)), !f)
1031
1253
  return !1;
1032
1254
  }
1033
- if (o === a && c === h)
1255
+ if (o === l && a === c)
1034
1256
  return !0;
1035
- if (o === a)
1257
+ if (o === l)
1036
1258
  return n;
1037
- if (c === h)
1038
- return o === a - 1 && t[o] === "";
1259
+ if (a === c)
1260
+ return o === l - 1 && t[o] === "";
1039
1261
  throw new Error("wtf?");
1040
1262
  }
1041
1263
  braceExpand() {
1042
- return mt(this.pattern, this.options);
1264
+ return yt(this.pattern, this.options);
1043
1265
  }
1044
1266
  parse(t) {
1045
- L(t);
1267
+ k(t);
1046
1268
  const e = this.options;
1047
1269
  if (t === "**")
1048
- return v;
1270
+ return b;
1049
1271
  if (t === "")
1050
1272
  return "";
1051
1273
  let n, r = null;
1052
- (n = t.match(he)) ? r = e.dot ? fe : ue : (n = t.match(te)) ? r = (e.nocase ? e.dot ? re : ne : e.dot ? se : ee)(n[1]) : (n = t.match(de)) ? r = (e.nocase ? e.dot ? ge : pe : e.dot ? me : we)(n) : (n = t.match(ie)) ? r = e.dot ? ae : oe : (n = t.match(ce)) && (r = le);
1053
- const i = E.fromGlob(t, this.options).toMMPattern();
1274
+ (n = t.match(be)) ? r = e.dot ? Ae : xe : (n = t.match(ue)) ? r = (e.nocase ? e.dot ? ge : de : e.dot ? pe : fe)(n[1]) : (n = t.match(ve)) ? r = (e.nocase ? e.dot ? $e : Oe : e.dot ? Ne : De)(n) : (n = t.match(me)) ? r = e.dot ? ye : we : (n = t.match(Ee)) && (r = Se);
1275
+ const i = Y.fromGlob(t, this.options).toMMPattern();
1054
1276
  return r && typeof i == "object" && Reflect.defineProperty(i, "test", { value: r }), i;
1055
1277
  }
1056
1278
  makeRe() {
@@ -1059,21 +1281,29 @@ globstar while`, t, u, e, f, g), this.matchOne(t.slice(u), e.slice(f), n))
1059
1281
  const t = this.set;
1060
1282
  if (!t.length)
1061
1283
  return this.regexp = !1, this.regexp;
1062
- const e = this.options, n = e.noglobstar ? Se : e.dot ? xe : be, r = new Set(e.nocase ? ["i"] : []);
1063
- let i = t.map((a) => {
1064
- const h = a.map((l) => {
1065
- if (l instanceof RegExp)
1066
- for (const d of l.flags.split(""))
1067
- r.add(d);
1068
- return typeof l == "string" ? Ne(l) : l === v ? v : l._src;
1284
+ const e = this.options, n = e.noglobstar ? Me : e.dot ? Fe : Re, r = new Set(e.nocase ? ["i"] : []);
1285
+ let i = t.map((c) => {
1286
+ const l = c.map((h) => {
1287
+ if (h instanceof RegExp)
1288
+ for (const f of h.flags.split(""))
1289
+ r.add(f);
1290
+ return typeof h == "string" ? ze(h) : h === b ? b : h._src;
1291
+ });
1292
+ l.forEach((h, f) => {
1293
+ const d = l[f + 1], g = l[f - 1];
1294
+ h !== b || g === b || (g === void 0 ? d !== void 0 && d !== b ? l[f + 1] = "(?:\\/|" + n + "\\/)?" + d : l[f] = n : d === void 0 ? l[f - 1] = g + "(?:\\/|\\/" + n + ")?" : d !== b && (l[f - 1] = g + "(?:\\/|\\/" + n + "\\/)" + d, l[f + 1] = b));
1069
1295
  });
1070
- return h.forEach((l, d) => {
1071
- const u = h[d + 1], f = h[d - 1];
1072
- l !== v || f === v || (f === void 0 ? u !== void 0 && u !== v ? h[d + 1] = "(?:\\/|" + n + "\\/)?" + u : h[d] = n : u === void 0 ? h[d - 1] = f + "(?:\\/|" + n + ")?" : u !== v && (h[d - 1] = f + "(?:\\/|\\/" + n + "\\/)" + u, h[d + 1] = v));
1073
- }), h.filter((l) => l !== v).join("/");
1296
+ const u = l.filter((h) => h !== b);
1297
+ if (this.partial && u.length >= 1) {
1298
+ const h = [];
1299
+ for (let f = 1; f <= u.length; f++)
1300
+ h.push(u.slice(0, f).join("/"));
1301
+ return "(?:" + h.join("|") + ")";
1302
+ }
1303
+ return u.join("/");
1074
1304
  }).join("|");
1075
- const [o, c] = t.length > 1 ? ["(?:", ")"] : ["", ""];
1076
- i = "^" + o + i + c + "$", this.negate && (i = "^(?!" + i + ").+$");
1305
+ const [o, a] = t.length > 1 ? ["(?:", ")"] : ["", ""];
1306
+ i = "^" + o + i + a + "$", this.partial && (i = "^(?:\\/|" + o + i.slice(1, -1) + a + ")$"), this.negate && (i = "^(?!" + i + ").+$");
1077
1307
  try {
1078
1308
  this.regexp = new RegExp(i, [...r].join(""));
1079
1309
  } catch {
@@ -1082,7 +1312,7 @@ globstar while`, t, u, e, f, g), this.matchOne(t.slice(u), e.slice(f), n))
1082
1312
  return this.regexp;
1083
1313
  }
1084
1314
  slashSplit(t) {
1085
- return this.preserveMultipleSlashes ? t.split("/") : this.isWindows && /^\/\/[^\/]+/.test(t) ? ["", ...t.split(/\/+/)] : t.split(/\/+/);
1315
+ return this.preserveMultipleSlashes ? t.split("/") : this.isWindows && /^\/\/[^/]+/.test(t) ? ["", ...t.split(/\/+/)] : t.split(/\/+/);
1086
1316
  }
1087
1317
  match(t, e = this.partial) {
1088
1318
  if (this.debug("match", t, this.pattern), this.comment)
@@ -1099,25 +1329,24 @@ globstar while`, t, u, e, f, g), this.matchOne(t.slice(u), e.slice(f), n))
1099
1329
  this.debug(this.pattern, "set", i);
1100
1330
  let o = r[r.length - 1];
1101
1331
  if (!o)
1102
- for (let c = r.length - 2; !o && c >= 0; c--)
1103
- o = r[c];
1104
- for (let c = 0; c < i.length; c++) {
1105
- const a = i[c];
1106
- let h = r;
1107
- if (n.matchBase && a.length === 1 && (h = [o]), this.matchOne(h, a, e))
1332
+ for (let a = r.length - 2; !o && a >= 0; a--)
1333
+ o = r[a];
1334
+ for (const a of i) {
1335
+ let c = r;
1336
+ if (n.matchBase && a.length === 1 && (c = [o]), this.matchOne(c, a, e))
1108
1337
  return n.flipNegate ? !0 : !this.negate;
1109
1338
  }
1110
1339
  return n.flipNegate ? !1 : this.negate;
1111
1340
  }
1112
1341
  static defaults(t) {
1113
- return y.defaults(t).Minimatch;
1342
+ return S.defaults(t).Minimatch;
1114
1343
  }
1115
1344
  }
1116
- y.AST = E;
1117
- y.Minimatch = B;
1118
- y.escape = Qt;
1119
- y.unescape = M;
1120
- const $e = [
1345
+ S.AST = Y;
1346
+ S.Minimatch = L;
1347
+ S.escape = he;
1348
+ S.unescape = F;
1349
+ const je = [
1121
1350
  // Images
1122
1351
  ".jpg",
1123
1352
  ".jpeg",
@@ -1174,14 +1403,14 @@ const $e = [
1174
1403
  ".fbx",
1175
1404
  ".3ds"
1176
1405
  ];
1177
- function Ge(s) {
1406
+ function ss(s) {
1178
1407
  const t = s.lastIndexOf(".");
1179
1408
  if (t <= 0)
1180
1409
  return !0;
1181
1410
  const e = s.slice(t).toLowerCase();
1182
- return $e.includes(e);
1411
+ return je.includes(e);
1183
1412
  }
1184
- function Ce(s, t = "utf-8") {
1413
+ function We(s, t = "utf-8") {
1185
1414
  switch (t) {
1186
1415
  case "utf8":
1187
1416
  case "utf-8":
@@ -1190,24 +1419,24 @@ function Ce(s, t = "utf-8") {
1190
1419
  case "utf-16le":
1191
1420
  case "ucs2":
1192
1421
  case "ucs-2":
1193
- return Te(s);
1422
+ return _e(s);
1194
1423
  case "ascii":
1195
- return Me(s);
1424
+ return He(s);
1196
1425
  case "latin1":
1197
- return Ie(s);
1426
+ return Ue(s);
1198
1427
  case "binary":
1199
1428
  return Uint8Array.from(s, (e) => e.charCodeAt(0));
1200
1429
  case "base64":
1201
1430
  return Uint8Array.from(atob(s), (e) => e.charCodeAt(0));
1202
1431
  case "hex":
1203
1432
  if (!/^[\da-f]+$/i.test(s) || s.length % 2 !== 0)
1204
- throw new D("format", "Invalid hex string");
1433
+ throw new $("format", "Invalid hex string");
1205
1434
  return Uint8Array.from(s.match(/.{1,2}/g).map((e) => parseInt(e, 16)));
1206
1435
  default:
1207
1436
  return console.warn("Encoding not supported, falling back to UTF-8"), new TextEncoder().encode(s);
1208
1437
  }
1209
1438
  }
1210
- function Ve(s, t = "utf-8") {
1439
+ function ns(s, t = "utf-8") {
1211
1440
  switch (t) {
1212
1441
  case "utf8":
1213
1442
  case "utf-8":
@@ -1216,7 +1445,7 @@ function Ve(s, t = "utf-8") {
1216
1445
  case "utf-16le":
1217
1446
  case "ucs2":
1218
1447
  case "ucs-2":
1219
- return Fe(s);
1448
+ return Be(s);
1220
1449
  case "latin1":
1221
1450
  return String.fromCharCode(...s);
1222
1451
  case "ascii":
@@ -1229,7 +1458,7 @@ function Ve(s, t = "utf-8") {
1229
1458
  return console.warn("Unsupported encoding, falling back to UTF-8"), new TextDecoder().decode(s);
1230
1459
  }
1231
1460
  }
1232
- function Te(s) {
1461
+ function _e(s) {
1233
1462
  const t = new Uint8Array(s.length * 2);
1234
1463
  for (let e = 0; e < s.length; e++) {
1235
1464
  const n = s.charCodeAt(e);
@@ -1237,64 +1466,72 @@ function Te(s) {
1237
1466
  }
1238
1467
  return t;
1239
1468
  }
1240
- function Fe(s) {
1469
+ function Be(s) {
1241
1470
  s.length % 2 !== 0 && (console.warn("Invalid UTF-16LE buffer length, truncating last byte"), s = s.slice(0, s.length - 1));
1242
1471
  const t = new Uint16Array(s.buffer, s.byteOffset, s.byteLength / 2);
1243
1472
  return String.fromCharCode(...t);
1244
1473
  }
1245
- function Ie(s) {
1474
+ function Ue(s) {
1246
1475
  const t = new Uint8Array(s.length);
1247
1476
  for (let e = 0; e < s.length; e++)
1248
1477
  t[e] = s.charCodeAt(e) & 255;
1249
1478
  return t;
1250
1479
  }
1251
- function Me(s) {
1480
+ function He(s) {
1252
1481
  const t = new Uint8Array(s.length);
1253
1482
  for (let e = 0; e < s.length; e++)
1254
1483
  t[e] = s.charCodeAt(e) & 127;
1255
1484
  return t;
1256
1485
  }
1257
- function Re() {
1486
+ function Ge() {
1258
1487
  if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
1259
- throw new yt();
1488
+ throw new xt();
1260
1489
  }
1261
- async function Pe(s, t) {
1262
- return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(`opfs:${s.replace(/\/+/g, "/")}`, { mode: "exclusive" }, t) : t();
1490
+ function qe(s, t) {
1491
+ const e = T(s || "/"), n = T(St(t));
1492
+ return e === "/" ? n : n === "/" ? e : `${e.replace(/\/$/, "")}${n}`;
1263
1493
  }
1264
- function $(s) {
1494
+ async function Et(s, t, e = "/") {
1495
+ if (typeof navigator < "u" && navigator.locks?.request) {
1496
+ const n = qe(e, s).replace(/\/+/g, "/");
1497
+ return navigator.locks.request(`opfs:${n}`, { mode: "exclusive" }, t);
1498
+ }
1499
+ return t();
1500
+ }
1501
+ function D(s) {
1265
1502
  return Array.isArray(s) ? s : (s.startsWith("~/") ? s.slice(2) : s).split("/").filter(Boolean);
1266
1503
  }
1267
1504
  function Z(s) {
1268
1505
  return typeof s == "string" ? s ?? "/" : `/${s.join("/")}`;
1269
1506
  }
1270
- function z(s) {
1271
- const t = $(s);
1507
+ function I(s) {
1508
+ const t = D(s);
1272
1509
  return t[t.length - 1] || "";
1273
1510
  }
1274
- function H(s) {
1275
- const t = $(s);
1511
+ function _(s) {
1512
+ const t = D(s);
1276
1513
  return t.pop(), Z(t);
1277
1514
  }
1278
- function W(s) {
1515
+ function T(s) {
1279
1516
  return !s || s === "/" ? "/" : s.startsWith("~/") ? `/${s.slice(2)}` : s.startsWith("/") ? s : `/${s}`;
1280
1517
  }
1281
- function ke(s, t = !1) {
1518
+ function Xe(s, t = !1) {
1282
1519
  return s = s.replace(/\/$/, ""), t && !s.includes("*") ? `${s}/**` : s;
1283
1520
  }
1284
- function _(s, t) {
1285
- return y(s, t, {
1521
+ function B(s, t) {
1522
+ return S(s, t, {
1286
1523
  dot: !0,
1287
1524
  matchBase: !0
1288
1525
  });
1289
1526
  }
1290
- function Ye(s, t) {
1527
+ function rs(s, t) {
1291
1528
  if (!t || Array.isArray(t) && t.length === 0)
1292
1529
  return !1;
1293
- const e = W(s);
1294
- return (Array.isArray(t) ? t : [t]).some((r) => y(e, r, { dot: !0 }));
1530
+ const e = T(s);
1531
+ return (Array.isArray(t) ? t : [t]).some((r) => S(e, r, { dot: !0 }));
1295
1532
  }
1296
- function Le(s) {
1297
- const t = W(s), e = $(t), n = [];
1533
+ function St(s) {
1534
+ const t = T(s), e = D(t), n = [];
1298
1535
  for (const r of e)
1299
1536
  if (!(r === "." || r === ""))
1300
1537
  if (r === "..") {
@@ -1305,20 +1542,20 @@ function Le(s) {
1305
1542
  n.push(r);
1306
1543
  return Z(n);
1307
1544
  }
1308
- function Ze(s) {
1309
- const t = z(s), e = t.lastIndexOf(".");
1545
+ function is(s) {
1546
+ const t = I(s), e = t.lastIndexOf(".");
1310
1547
  return e <= 0 || e === t.length - 1 ? "" : t.slice(e);
1311
1548
  }
1312
- function Je(s, t = "utf-8") {
1313
- return typeof s == "string" ? Ce(s, t) : s instanceof Uint8Array ? s : new Uint8Array(s);
1549
+ function os(s, t = "utf-8") {
1550
+ return typeof s == "string" ? We(s, t) : s instanceof Uint8Array ? s : new Uint8Array(s);
1314
1551
  }
1315
- async function ze(s, t = "SHA-1", e = 50 * 1024 * 1024) {
1552
+ async function Ve(s, t = "SHA-1", e = 50 * 1024 * 1024) {
1316
1553
  if (s instanceof File && (s = await s.arrayBuffer()), s.byteLength > e)
1317
1554
  throw new Error(`File size ${s.byteLength} bytes exceeds maximum allowed size ${e} bytes`);
1318
1555
  const n = new Uint8Array(s), r = await crypto.subtle.digest(t, n);
1319
1556
  return Array.from(new Uint8Array(r)).map((o) => o.toString(16).padStart(2, "0")).join("");
1320
1557
  }
1321
- function Xe(s, t) {
1558
+ function as(s, t) {
1322
1559
  if (s.length !== t.length)
1323
1560
  return !1;
1324
1561
  for (let e = 0; e < s.length; e++)
@@ -1326,59 +1563,59 @@ function Xe(s, t) {
1326
1563
  return !1;
1327
1564
  return !0;
1328
1565
  }
1329
- async function Ke(s) {
1566
+ async function cs(s) {
1330
1567
  const t = await s.arrayBuffer();
1331
1568
  return new Uint8Array(t);
1332
1569
  }
1333
- async function We(s, t, e = {}) {
1334
- const n = z(t);
1335
- return Pe(t, async () => {
1570
+ async function Ye(s, t, e = {}) {
1571
+ const n = I(t);
1572
+ return Et(t, async () => {
1336
1573
  const r = e.recursive ?? !1, i = e.force ?? !1;
1337
1574
  try {
1338
1575
  await s.removeEntry(n, { recursive: r });
1339
1576
  } catch (o) {
1340
1577
  if (o.name === "NotFoundError" && i)
1341
1578
  return;
1342
- const c = o.name === "TypeMismatchError" && !r;
1343
- throw O(o, {
1579
+ const a = o.name === "TypeMismatchError" && !r;
1580
+ throw v(o, {
1344
1581
  path: t,
1345
1582
  operation: "remove",
1346
- isDirectory: c
1583
+ isDirectory: a
1347
1584
  });
1348
1585
  }
1349
- });
1586
+ }, e.root ?? "/");
1350
1587
  }
1351
- function Qe(s, t, e, n) {
1588
+ function ls(s, t, e, n) {
1352
1589
  if (!Number.isInteger(t) || !Number.isInteger(e))
1353
- throw new D("argument", "Invalid offset or length");
1590
+ throw new $("argument", "Invalid offset or length");
1354
1591
  if (t < 0 || e < 0)
1355
- throw new D("argument", "Negative offset or length not allowed");
1592
+ throw new $("argument", "Negative offset or length not allowed");
1356
1593
  if (t + e > s)
1357
- throw new D("overflow", "Operation would overflow buffer");
1594
+ throw new $("overflow", "Operation would overflow buffer");
1358
1595
  if (n != null && (!Number.isInteger(n) || n < 0))
1359
- throw new D("argument", "Invalid position");
1596
+ throw new $("argument", "Invalid position");
1360
1597
  }
1361
- function ts(s, t, e) {
1598
+ function hs(s, t, e) {
1362
1599
  try {
1363
1600
  t.flush(), t.close();
1364
1601
  } catch (n) {
1365
1602
  console.warn(`Warning: Failed to properly close file descriptor ${s} (${e}):`, n);
1366
1603
  }
1367
1604
  }
1368
- function es(s, t, e) {
1605
+ function us(s, t, e) {
1369
1606
  if (s >= e)
1370
1607
  return { isEOF: !0, actualLength: 0 };
1371
1608
  const n = Math.min(t, e - s);
1372
1609
  return n <= 0 ? { isEOF: !0, actualLength: 0 } : { isEOF: !1, actualLength: n };
1373
1610
  }
1374
- async function ss(s, t) {
1611
+ async function fs(s, t) {
1375
1612
  try {
1376
1613
  return await s.createSyncAccessHandle();
1377
1614
  } catch (e) {
1378
- throw O(e, { path: t, isDirectory: !1 });
1615
+ throw v(e, { path: t, isDirectory: !1 });
1379
1616
  }
1380
1617
  }
1381
- class ns {
1618
+ class ps {
1382
1619
  /** Root directory handle for the file system */
1383
1620
  root;
1384
1621
  /** Map of watched paths and options */
@@ -1407,7 +1644,7 @@ class ns {
1407
1644
  if (!this.options.broadcastChannel)
1408
1645
  return;
1409
1646
  const e = t.path;
1410
- if (![...this.watchers.values()].some((i) => _(e, i.pattern) && i.include.some((o) => o && _(e, o)) && !i.exclude.some((o) => o && _(e, o))))
1647
+ if (![...this.watchers.values()].some((i) => B(e, i.pattern) && i.include.some((o) => o && B(e, o)) && !i.exclude.some((o) => o && B(e, o))))
1411
1648
  return;
1412
1649
  let r;
1413
1650
  if (this.options.hashAlgorithm)
@@ -1429,7 +1666,11 @@ class ns {
1429
1666
  }
1430
1667
  }
1431
1668
  constructor(t) {
1432
- Re(), t && this.setOptions(t);
1669
+ Ge(), t && this.setOptions(t);
1670
+ }
1671
+ /** Exclusive path lock keyed by absolute OPFS path (`root` + API path). */
1672
+ async withPathLock(t, e) {
1673
+ return Et(t, e, this.options.root);
1433
1674
  }
1434
1675
  /**
1435
1676
  * Initialize the file system within a given directory.
@@ -1442,7 +1683,7 @@ class ns {
1442
1683
  const r = await navigator.storage.getDirectory();
1443
1684
  this.root = t === "/" ? r : await this.getDirectoryHandle(t, !0, r), e(!0);
1444
1685
  } catch (r) {
1445
- n(new Ot(t, r));
1686
+ n(new Dt(t, r));
1446
1687
  } finally {
1447
1688
  this.mountingPromise = null;
1448
1689
  }
@@ -1459,7 +1700,7 @@ class ns {
1459
1700
  * @param options.broadcastChannel - Custom name for the broadcast channel
1460
1701
  */
1461
1702
  async setOptions(t) {
1462
- t.hashAlgorithm !== void 0 && (this.options.hashAlgorithm = t.hashAlgorithm), t.maxFileSize !== void 0 && (this.options.maxFileSize = t.maxFileSize), t.broadcastChannel !== void 0 && (this.broadcastChannel && this.options.broadcastChannel !== t.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.options.broadcastChannel = t.broadcastChannel), t.namespace && (this.options.namespace = t.namespace), t.root !== void 0 && (this.options.root = W(t.root), this.options.namespace || (this.options.namespace = `opfs-worker:${this.options.root}`), await this.mount());
1703
+ t.hashAlgorithm !== void 0 && (this.options.hashAlgorithm = t.hashAlgorithm), t.maxFileSize !== void 0 && (this.options.maxFileSize = t.maxFileSize), t.broadcastChannel !== void 0 && (this.broadcastChannel && this.options.broadcastChannel !== t.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.options.broadcastChannel = t.broadcastChannel), t.namespace && (this.options.namespace = t.namespace), t.root !== void 0 && (this.options.root = T(t.root), this.options.namespace || (this.options.namespace = `opfs-worker:${this.options.root}`), await this.mount());
1463
1704
  }
1464
1705
  /**
1465
1706
  * Get a directory handle from a path
@@ -1480,7 +1721,7 @@ class ns {
1480
1721
  * ```
1481
1722
  */
1482
1723
  async getDirectoryHandle(t, e = !1, n = this.root) {
1483
- const r = Array.isArray(t) ? t : $(t);
1724
+ const r = Array.isArray(t) ? t : D(t);
1484
1725
  let i = n;
1485
1726
  for (const o of r)
1486
1727
  i = await i.getDirectoryHandle(o, { create: e });
@@ -1506,9 +1747,9 @@ class ns {
1506
1747
  * ```
1507
1748
  */
1508
1749
  async getFileHandle(t, e = !1, n = this.root) {
1509
- const r = $(t);
1750
+ const r = D(t);
1510
1751
  if (r.length === 0)
1511
- throw new Et("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
1752
+ throw new At("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
1512
1753
  const i = r.pop();
1513
1754
  return (await this.getDirectoryHandle(r, e, n)).getFileHandle(i, { create: e });
1514
1755
  }
@@ -1537,10 +1778,10 @@ class ns {
1537
1778
  for (const i of r) {
1538
1779
  const o = `${n === "/" ? "" : n}/${i.name}`;
1539
1780
  try {
1540
- const c = await this.stat(o);
1541
- t.set(o, c), c.isDirectory && await e(o);
1542
- } catch (c) {
1543
- console.warn(`Skipping broken entry: ${o}`, c);
1781
+ const a = await this.stat(o);
1782
+ t.set(o, a), a.isDirectory && await e(o);
1783
+ } catch (a) {
1784
+ console.warn(`Skipping broken entry: ${o}`, a);
1544
1785
  }
1545
1786
  }
1546
1787
  };
@@ -1576,17 +1817,17 @@ class ns {
1576
1817
  */
1577
1818
  async mkdir(t, e) {
1578
1819
  await this.mount();
1579
- const n = e?.recursive ?? !1, r = $(t);
1820
+ const n = e?.recursive ?? !1, r = D(t);
1580
1821
  let i = this.root;
1581
1822
  for (let o = 0; o < r.length; o++) {
1582
- const c = r[o];
1823
+ const a = r[o];
1583
1824
  try {
1584
- i = await i.getDirectoryHandle(c, { create: n || o === r.length - 1 });
1585
- } catch (a) {
1586
- throw a.name === "NotFoundError" ? O(a, {
1825
+ i = await i.getDirectoryHandle(a, { create: n || o === r.length - 1 });
1826
+ } catch (c) {
1827
+ throw c.name === "NotFoundError" ? v(c, {
1587
1828
  path: Z(r.slice(0, o + 1)),
1588
1829
  existenceType: "directory"
1589
- }) : a.name === "TypeMismatchError" ? O(a, { path: c, isDirectory: !1 }) : new j("create directory", c, a);
1830
+ }) : c.name === "TypeMismatchError" ? v(c, { path: a, isDirectory: !1 }) : new j("create directory", a, c);
1590
1831
  }
1591
1832
  }
1592
1833
  await this.notifyChange({ path: t, type: N.Added, isDirectory: !0 });
@@ -1623,11 +1864,11 @@ class ns {
1623
1864
  isFile: !1,
1624
1865
  isDirectory: !0
1625
1866
  };
1626
- const e = z(t);
1867
+ const e = I(t);
1627
1868
  let n;
1628
1869
  try {
1629
- n = await this.getDirectoryHandle(H(t), !1);
1630
- const r = this.options.hashAlgorithm, o = await (await n.getFileHandle(e, { create: !1 })).getFile(), c = {
1870
+ n = await this.getDirectoryHandle(_(t), !1);
1871
+ const r = this.options.hashAlgorithm, o = await (await n.getFileHandle(e, { create: !1 })).getFile(), a = {
1631
1872
  kind: "file",
1632
1873
  size: o.size,
1633
1874
  mtime: new Date(o.lastModified).toISOString(),
@@ -1636,18 +1877,18 @@ class ns {
1636
1877
  isDirectory: !1
1637
1878
  };
1638
1879
  if (r === "etag")
1639
- c.hash = `${o.lastModified.toString(36)}-${o.size.toString(36)}`;
1880
+ a.hash = `${o.lastModified.toString(36)}-${o.size.toString(36)}`;
1640
1881
  else if (typeof r == "string")
1641
1882
  try {
1642
- const a = await ze(o, r, this.options.maxFileSize);
1643
- c.hash = a;
1644
- } catch (a) {
1645
- console.warn(`Failed to calculate hash for ${t}:`, a);
1883
+ const c = await Ve(o, r, this.options.maxFileSize);
1884
+ a.hash = c;
1885
+ } catch (c) {
1886
+ console.warn(`Failed to calculate hash for ${t}:`, c);
1646
1887
  }
1647
- return c;
1888
+ return a;
1648
1889
  } catch (r) {
1649
1890
  if (r.name === "NotFoundError")
1650
- throw new k("file", t, r);
1891
+ throw new P("file", t, r);
1651
1892
  if (r.name !== "TypeMismatchError")
1652
1893
  throw new j("stat", t, r);
1653
1894
  }
@@ -1713,10 +1954,10 @@ class ns {
1713
1954
  async exists(t) {
1714
1955
  if (await this.mount(), t === "/")
1715
1956
  return !0;
1716
- const e = z(t);
1957
+ const e = I(t);
1717
1958
  let n = null;
1718
1959
  try {
1719
- n = await this.getDirectoryHandle(H(t), !1);
1960
+ n = await this.getDirectoryHandle(_(t), !1);
1720
1961
  } catch (r) {
1721
1962
  if (n = null, r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
1722
1963
  throw r;
@@ -1766,7 +2007,7 @@ class ns {
1766
2007
  }
1767
2008
  await this.notifyChange({ path: t, type: N.Changed, isDirectory: !0 });
1768
2009
  } catch (e) {
1769
- throw e instanceof m ? e : O(e, { path: t, isDirectory: !0 });
2010
+ throw e instanceof m ? e : v(e, { path: t, isDirectory: !0 });
1770
2011
  }
1771
2012
  }
1772
2013
  /**
@@ -1795,9 +2036,9 @@ class ns {
1795
2036
  */
1796
2037
  async remove(t, e) {
1797
2038
  if (await this.mount(), t === "/")
1798
- throw new G("EROOT", t);
1799
- const { recursive: n = !1, force: r = !1 } = e || {}, i = await this.getDirectoryHandle(H(t), !1), o = await this.stat(t);
1800
- await We(i, t, { recursive: n, force: r }), await this.notifyChange({ path: t, type: N.Removed, isDirectory: o.isDirectory });
2039
+ throw new H("EROOT", t);
2040
+ const { recursive: n = !1, force: r = !1 } = e || {}, i = await this.getDirectoryHandle(_(t), !1), o = await this.stat(t);
2041
+ await Ye(i, t, { recursive: n, force: r, root: this.options.root }), await this.notifyChange({ path: t, type: N.Removed, isDirectory: o.isDirectory });
1801
2042
  }
1802
2043
  /**
1803
2044
  * Resolve a path to an absolute path
@@ -1820,12 +2061,12 @@ class ns {
1820
2061
  async realpath(t) {
1821
2062
  await this.mount();
1822
2063
  try {
1823
- const e = Le(t);
2064
+ const e = St(t);
1824
2065
  if (!await this.exists(e))
1825
- throw new k("file", e);
2066
+ throw new P("file", e);
1826
2067
  return e;
1827
2068
  } catch (e) {
1828
- throw e instanceof m ? e : O(e, { path: t });
2069
+ throw e instanceof m ? e : v(e, { path: t });
1829
2070
  }
1830
2071
  }
1831
2072
  /**
@@ -1855,10 +2096,10 @@ class ns {
1855
2096
  try {
1856
2097
  const r = n?.overwrite ?? !1, i = await this.stat(t);
1857
2098
  if (await this.exists(e) && !r)
1858
- throw new X(e);
2099
+ throw new Q(e);
1859
2100
  await this.copy(t, e, { recursive: !0, overwrite: r }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type: N.Removed, isDirectory: i.isDirectory }), await this.notifyChange({ path: e, type: N.Added, isDirectory: i.isDirectory });
1860
2101
  } catch (r) {
1861
- throw r instanceof m ? r : O(r, { path: t });
2102
+ throw r instanceof m ? r : v(r, { path: t });
1862
2103
  }
1863
2104
  }
1864
2105
  /**
@@ -1891,24 +2132,24 @@ class ns {
1891
2132
  try {
1892
2133
  const r = n?.recursive ?? !1, i = n?.overwrite ?? !0;
1893
2134
  if (!await this.exists(t))
1894
- throw new k("source", t);
2135
+ throw new P("source", t);
1895
2136
  if (await this.exists(e) && !i)
1896
- throw new X(e);
2137
+ throw new Q(e);
1897
2138
  if ((await this.stat(t)).isFile) {
1898
- const h = await this.readFile(t);
1899
- await this.writeFile(e, h);
2139
+ const l = await this.readFile(t);
2140
+ await this.writeFile(e, l);
1900
2141
  } else {
1901
2142
  if (!r)
1902
- throw new q("directory", t);
2143
+ throw new U("directory", t);
1903
2144
  await this.mkdir(e, { recursive: !0 });
1904
- const h = await this.readDir(t);
1905
- for (const l of h) {
1906
- const d = `${t}/${l.name}`, u = `${e}/${l.name}`;
1907
- await this.copy(d, u, { recursive: !0, overwrite: i });
2145
+ const l = await this.readDir(t);
2146
+ for (const u of l) {
2147
+ const h = `${t}/${u.name}`, f = `${e}/${u.name}`;
2148
+ await this.copy(h, f, { recursive: !0, overwrite: i });
1908
2149
  }
1909
2150
  }
1910
2151
  } catch (r) {
1911
- throw r instanceof m ? r : O(r, { path: t });
2152
+ throw r instanceof m ? r : v(r, { path: t });
1912
2153
  }
1913
2154
  }
1914
2155
  /**
@@ -1938,9 +2179,9 @@ class ns {
1938
2179
  */
1939
2180
  async watch(t, e) {
1940
2181
  if (!this.options.broadcastChannel)
1941
- throw new ot("This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.");
2182
+ throw new ct("This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.");
1942
2183
  const n = {
1943
- pattern: ke(t, e?.recursive ?? !0),
2184
+ pattern: Xe(t, e?.recursive ?? !0),
1944
2185
  include: Array.isArray(e?.include) ? e.include : [e?.include ?? "**"],
1945
2186
  exclude: Array.isArray(e?.exclude) ? e.exclude : [e?.exclude ?? ""]
1946
2187
  };
@@ -1975,7 +2216,7 @@ class ns {
1975
2216
  try {
1976
2217
  return await (await this.getFileHandle(t, !1)).getFile();
1977
2218
  } catch (e) {
1978
- throw e instanceof m ? e : O(e, { path: t, isDirectory: e?.name === "TypeMismatchError" });
2219
+ throw e instanceof m ? e : v(e, { path: t, isDirectory: e?.name === "TypeMismatchError" });
1979
2220
  }
1980
2221
  }
1981
2222
  /**
@@ -2003,39 +2244,39 @@ class ns {
2003
2244
  */
2004
2245
  async importFiles(t, e) {
2005
2246
  await this.mount();
2006
- const n = [...t].map(([a, h]) => [W(a), h]), r = n.length, i = n.map(([a]) => a), o = n.reduce((a, [, h]) => a + Be(h), 0);
2007
- let c = 0;
2247
+ const n = [...t].map(([c, l]) => [T(c), l]), r = n.length, i = n.map(([c]) => c), o = n.reduce((c, [, l]) => c + Ze(l), 0);
2248
+ let a = 0;
2008
2249
  try {
2009
- for (let a = 0; a < r; a++) {
2010
- const [h, l] = n[a], { stream: d, size: u } = je(l), f = c, g = await this.writeStream(
2250
+ for (let c = 0; c < r; c++) {
2251
+ const [l, u] = n[c], { stream: h, size: f } = Je(u), d = a, g = await this.writeStream(
2252
+ l,
2011
2253
  h,
2012
- d,
2013
2254
  e ? (p) => e({
2014
- path: h,
2015
- index: a,
2255
+ path: l,
2256
+ index: c,
2016
2257
  count: r,
2017
2258
  bytesWritten: p,
2018
- bytesTotal: u,
2019
- totalBytesWritten: f + p,
2259
+ bytesTotal: f,
2260
+ totalBytesWritten: d + p,
2020
2261
  totalBytes: o
2021
2262
  }) : void 0
2022
2263
  );
2023
- c += g;
2264
+ a += g;
2024
2265
  }
2025
2266
  return {
2026
2267
  paths: i,
2027
2268
  count: r,
2028
- bytesWritten: c
2269
+ bytesWritten: a
2029
2270
  };
2030
- } catch (a) {
2031
- throw a instanceof m ? a : O(a);
2271
+ } catch (c) {
2272
+ throw c instanceof m ? c : v(c);
2032
2273
  }
2033
2274
  }
2034
2275
  /**
2035
2276
  * @deprecated Use {@link importFiles} instead.
2036
2277
  */
2037
2278
  async createIndex(t) {
2038
- Ue(), await this.importFiles(t);
2279
+ Qe(), await this.importFiles(t);
2039
2280
  }
2040
2281
  /**
2041
2282
  * Dispose of resources and clean up the file system instance
@@ -2044,10 +2285,10 @@ class ns {
2044
2285
  this.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.watchers.clear();
2045
2286
  }
2046
2287
  }
2047
- function Be(s) {
2288
+ function Ze(s) {
2048
2289
  return typeof s == "string" ? new TextEncoder().encode(s).byteLength : s instanceof Blob ? s.size : s.byteLength;
2049
2290
  }
2050
- function je(s) {
2291
+ function Je(s) {
2051
2292
  if (s instanceof Blob)
2052
2293
  return { stream: s.stream(), size: s.size };
2053
2294
  const t = typeof s == "string" ? new TextEncoder().encode(s) : s;
@@ -2060,55 +2301,56 @@ function je(s) {
2060
2301
  })
2061
2302
  };
2062
2303
  }
2063
- let it = !1;
2064
- function Ue() {
2065
- it || (it = !0, console.warn("[opfs-worker] createIndex() is deprecated; use importFiles() instead"));
2304
+ let at = !1;
2305
+ function Qe() {
2306
+ at || (at = !0, console.warn("[opfs-worker] createIndex() is deprecated; use importFiles() instead"));
2066
2307
  }
2067
2308
  export {
2068
- X as A,
2069
- ns as B,
2070
- Qe as C,
2071
- G as D,
2072
- k as E,
2073
- bt as F,
2074
- ts as G,
2075
- es as H,
2309
+ Q as A,
2310
+ ps as B,
2311
+ Ye as C,
2312
+ H as D,
2313
+ P as E,
2314
+ $t as F,
2315
+ ls as G,
2316
+ hs as H,
2076
2317
  J as I,
2077
- ss as J,
2078
- $e as K,
2079
- Ge as L,
2080
- Ce as M,
2081
- Ve as N,
2318
+ us as J,
2319
+ fs as K,
2320
+ je as L,
2321
+ ss as M,
2322
+ We as N,
2082
2323
  m as O,
2083
- Et as P,
2084
- xt as S,
2085
- D as V,
2324
+ At as P,
2325
+ ns as Q,
2326
+ Ot as S,
2327
+ $ as V,
2086
2328
  N as W,
2087
- yt as a,
2088
- St as b,
2089
- q as c,
2090
- vt as d,
2091
- ot as e,
2092
- Ot as f,
2329
+ xt as a,
2330
+ vt as b,
2331
+ U as c,
2332
+ Nt as d,
2333
+ ct as e,
2334
+ Dt as f,
2093
2335
  j as g,
2094
- He as h,
2095
- Re as i,
2096
- Z as j,
2097
- z as k,
2098
- H as l,
2099
- O as m,
2100
- W as n,
2101
- ke as o,
2102
- _ as p,
2103
- Ye as q,
2104
- Le as r,
2105
- $ as s,
2106
- Ze as t,
2107
- Je as u,
2108
- ze as v,
2109
- Pe as w,
2110
- Xe as x,
2111
- Ke as y,
2112
- We as z
2336
+ Ke as h,
2337
+ Ge as i,
2338
+ qe as j,
2339
+ Z as k,
2340
+ I as l,
2341
+ v as m,
2342
+ _ as n,
2343
+ T as o,
2344
+ Xe as p,
2345
+ B as q,
2346
+ rs as r,
2347
+ D as s,
2348
+ St as t,
2349
+ is as u,
2350
+ os as v,
2351
+ Et as w,
2352
+ Ve as x,
2353
+ as as y,
2354
+ cs as z
2113
2355
  };
2114
- //# sourceMappingURL=BaseOPFS-BusBkyJX.js.map
2356
+ //# sourceMappingURL=BaseOPFS-C3NE4BKr.js.map