opfs-worker 1.2.4 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,19 +1,19 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("comlink"),e=require("./helpers-ppMRzIAJ.cjs"),l=`/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("comlink"),e=require("./helpers-CIiblZ8d.cjs"),l=`/**
2
2
  * @license
3
3
  * Copyright 2019 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- const gt = Symbol("Comlink.proxy"), Mt = Symbol("Comlink.endpoint"), It = Symbol("Comlink.releaseProxy"), V = Symbol("Comlink.finalizer"), H = Symbol("Comlink.thrown"), wt = (s) => typeof s == "object" && s !== null || typeof s == "function", Pt = {
7
- canHandle: (s) => wt(s) && s[gt],
6
+ const bt = Symbol("Comlink.proxy"), Ht = Symbol("Comlink.endpoint"), Wt = Symbol("Comlink.releaseProxy"), J = Symbol("Comlink.finalizer"), U = Symbol("Comlink.thrown"), Ot = (s) => typeof s == "object" && s !== null || typeof s == "function", jt = {
7
+ canHandle: (s) => Ot(s) && s[bt],
8
8
  serialize(s) {
9
9
  const { port1: t, port2: e } = new MessageChannel();
10
- return Q(s, t), [e, [e]];
10
+ return ot(s, t), [e, [e]];
11
11
  },
12
12
  deserialize(s) {
13
- return s.start(), Lt(s);
13
+ return s.start(), Gt(s);
14
14
  }
15
- }, Tt = {
16
- canHandle: (s) => wt(s) && H in s,
15
+ }, _t = {
16
+ canHandle: (s) => Ot(s) && U in s,
17
17
  serialize({ value: s }) {
18
18
  let t;
19
19
  return s instanceof Error ? t = {
@@ -28,25 +28,25 @@ const gt = Symbol("Comlink.proxy"), Mt = Symbol("Comlink.endpoint"), It = Symbol
28
28
  deserialize(s) {
29
29
  throw s.isError ? Object.assign(new Error(s.value.message), s.value) : s.value;
30
30
  }
31
- }, mt = /* @__PURE__ */ new Map([
32
- ["proxy", Pt],
33
- ["throw", Tt]
31
+ }, Dt = /* @__PURE__ */ new Map([
32
+ ["proxy", jt],
33
+ ["throw", _t]
34
34
  ]);
35
- function Rt(s, t) {
35
+ function Ut(s, t) {
36
36
  for (const e of s)
37
37
  if (t === e || e === "*" || e instanceof RegExp && e.test(t))
38
38
  return !0;
39
39
  return !1;
40
40
  }
41
- function Q(s, t = globalThis, e = ["*"]) {
42
- t.addEventListener("message", function n(i) {
43
- if (!i || !i.data)
41
+ function ot(s, t = globalThis, e = ["*"]) {
42
+ t.addEventListener("message", function n(r) {
43
+ if (!r || !r.data)
44
44
  return;
45
- if (!Rt(e, i.origin)) {
46
- console.warn(\`Invalid origin '\${i.origin}' for comlink proxy\`);
45
+ if (!Ut(e, r.origin)) {
46
+ console.warn(\`Invalid origin '\${r.origin}' for comlink proxy\`);
47
47
  return;
48
48
  }
49
- const { id: r, type: o, path: a } = Object.assign({ path: [] }, i.data), l = (i.data.argumentList || []).map(N);
49
+ const { id: i, type: o, path: a } = Object.assign({ path: [] }, r.data), l = (r.data.argumentList || []).map(C);
50
50
  let h;
51
51
  try {
52
52
  const c = a.slice(0, -1).reduce((u, d) => u[d], s), f = a.reduce((u, d) => u[d], s);
@@ -55,7 +55,7 @@ function Q(s, t = globalThis, e = ["*"]) {
55
55
  h = f;
56
56
  break;
57
57
  case "SET":
58
- c[a.slice(-1)[0]] = N(i.data.value), h = !0;
58
+ c[a.slice(-1)[0]] = C(r.data.value), h = !0;
59
59
  break;
60
60
  case "APPLY":
61
61
  h = f.apply(c, l);
@@ -63,13 +63,13 @@ function Q(s, t = globalThis, e = ["*"]) {
63
63
  case "CONSTRUCT":
64
64
  {
65
65
  const u = new f(...l);
66
- h = _t(u);
66
+ h = Zt(u);
67
67
  }
68
68
  break;
69
69
  case "ENDPOINT":
70
70
  {
71
71
  const { port1: u, port2: d } = new MessageChannel();
72
- Q(s, d), h = W(u, [u]);
72
+ ot(s, d), h = B(u, [u]);
73
73
  }
74
74
  break;
75
75
  case "RELEASE":
@@ -79,145 +79,145 @@ function Q(s, t = globalThis, e = ["*"]) {
79
79
  return;
80
80
  }
81
81
  } catch (c) {
82
- h = { value: c, [H]: 0 };
82
+ h = { value: c, [U]: 0 };
83
83
  }
84
- Promise.resolve(h).catch((c) => ({ value: c, [H]: 0 })).then((c) => {
85
- const [f, u] = B(c);
86
- t.postMessage(Object.assign(Object.assign({}, f), { id: r }), u), o === "RELEASE" && (t.removeEventListener("message", n), yt(t), V in s && typeof s[V] == "function" && s[V]());
84
+ Promise.resolve(h).catch((c) => ({ value: c, [U]: 0 })).then((c) => {
85
+ const [f, u] = Y(c);
86
+ t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u), o === "RELEASE" && (t.removeEventListener("message", n), vt(t), J in s && typeof s[J] == "function" && s[J]());
87
87
  }).catch((c) => {
88
- const [f, u] = B({
88
+ const [f, u] = Y({
89
89
  value: new TypeError("Unserializable return value"),
90
- [H]: 0
90
+ [U]: 0
91
91
  });
92
- t.postMessage(Object.assign(Object.assign({}, f), { id: r }), u);
92
+ t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u);
93
93
  });
94
94
  }), t.start && t.start();
95
95
  }
96
- function kt(s) {
96
+ function Bt(s) {
97
97
  return s.constructor.name === "MessagePort";
98
98
  }
99
- function yt(s) {
100
- kt(s) && s.close();
99
+ function vt(s) {
100
+ Bt(s) && s.close();
101
101
  }
102
- function Lt(s, t) {
102
+ function Gt(s, t) {
103
103
  const e = /* @__PURE__ */ new Map();
104
- return s.addEventListener("message", function(i) {
105
- const { data: r } = i;
106
- if (!r || !r.id)
104
+ return s.addEventListener("message", function(r) {
105
+ const { data: i } = r;
106
+ if (!i || !i.id)
107
107
  return;
108
- const o = e.get(r.id);
108
+ const o = e.get(i.id);
109
109
  if (o)
110
110
  try {
111
- o(r);
111
+ o(i);
112
112
  } finally {
113
- e.delete(r.id);
113
+ e.delete(i.id);
114
114
  }
115
- }), J(s, e, [], t);
115
+ }), nt(s, e, [], t);
116
116
  }
117
- function k(s) {
117
+ function W(s) {
118
118
  if (s)
119
119
  throw new Error("Proxy has been released and is not useable");
120
120
  }
121
- function Et(s) {
122
- return D(s, /* @__PURE__ */ new Map(), {
121
+ function At(s) {
122
+ return $(s, /* @__PURE__ */ new Map(), {
123
123
  type: "RELEASE"
124
124
  }).then(() => {
125
- yt(s);
125
+ vt(s);
126
126
  });
127
127
  }
128
- const j = /* @__PURE__ */ new WeakMap(), U = "FinalizationRegistry" in globalThis && new FinalizationRegistry((s) => {
129
- const t = (j.get(s) || 0) - 1;
130
- j.set(s, t), t === 0 && Et(s);
128
+ const q = /* @__PURE__ */ new WeakMap(), V = "FinalizationRegistry" in globalThis && new FinalizationRegistry((s) => {
129
+ const t = (q.get(s) || 0) - 1;
130
+ q.set(s, t), t === 0 && At(s);
131
131
  });
132
- function zt(s, t) {
133
- const e = (j.get(t) || 0) + 1;
134
- j.set(t, e), U && U.register(s, t, s);
132
+ function qt(s, t) {
133
+ const e = (q.get(t) || 0) + 1;
134
+ q.set(t, e), V && V.register(s, t, s);
135
135
  }
136
- function Ht(s) {
137
- U && U.unregister(s);
136
+ function Vt(s) {
137
+ V && V.unregister(s);
138
138
  }
139
- function J(s, t, e = [], n = function() {
139
+ function nt(s, t, e = [], n = function() {
140
140
  }) {
141
- let i = !1;
142
- const r = new Proxy(n, {
141
+ let r = !1;
142
+ const i = new Proxy(n, {
143
143
  get(o, a) {
144
- if (k(i), a === It)
144
+ if (W(r), a === Wt)
145
145
  return () => {
146
- Ht(r), Et(s), t.clear(), i = !0;
146
+ Vt(i), At(s), t.clear(), r = !0;
147
147
  };
148
148
  if (a === "then") {
149
149
  if (e.length === 0)
150
- return { then: () => r };
151
- const l = D(s, t, {
150
+ return { then: () => i };
151
+ const l = $(s, t, {
152
152
  type: "GET",
153
153
  path: e.map((h) => h.toString())
154
- }).then(N);
154
+ }).then(C);
155
155
  return l.then.bind(l);
156
156
  }
157
- return J(s, t, [...e, a]);
157
+ return nt(s, t, [...e, a]);
158
158
  },
159
159
  set(o, a, l) {
160
- k(i);
161
- const [h, c] = B(l);
162
- return D(s, t, {
160
+ W(r);
161
+ const [h, c] = Y(l);
162
+ return $(s, t, {
163
163
  type: "SET",
164
164
  path: [...e, a].map((f) => f.toString()),
165
165
  value: h
166
- }, c).then(N);
166
+ }, c).then(C);
167
167
  },
168
168
  apply(o, a, l) {
169
- k(i);
169
+ W(r);
170
170
  const h = e[e.length - 1];
171
- if (h === Mt)
172
- return D(s, t, {
171
+ if (h === Ht)
172
+ return $(s, t, {
173
173
  type: "ENDPOINT"
174
- }).then(N);
174
+ }).then(C);
175
175
  if (h === "bind")
176
- return J(s, t, e.slice(0, -1));
177
- const [c, f] = nt(l);
178
- return D(s, t, {
176
+ return nt(s, t, e.slice(0, -1));
177
+ const [c, f] = ht(l);
178
+ return $(s, t, {
179
179
  type: "APPLY",
180
180
  path: e.map((u) => u.toString()),
181
181
  argumentList: c
182
- }, f).then(N);
182
+ }, f).then(C);
183
183
  },
184
184
  construct(o, a) {
185
- k(i);
186
- const [l, h] = nt(a);
187
- return D(s, t, {
185
+ W(r);
186
+ const [l, h] = ht(a);
187
+ return $(s, t, {
188
188
  type: "CONSTRUCT",
189
189
  path: e.map((c) => c.toString()),
190
190
  argumentList: l
191
- }, h).then(N);
191
+ }, h).then(C);
192
192
  }
193
193
  });
194
- return zt(r, s), r;
194
+ return qt(i, s), i;
195
195
  }
196
- function Wt(s) {
196
+ function Yt(s) {
197
197
  return Array.prototype.concat.apply([], s);
198
198
  }
199
- function nt(s) {
200
- const t = s.map(B);
201
- return [t.map((e) => e[0]), Wt(t.map((e) => e[1]))];
199
+ function ht(s) {
200
+ const t = s.map(Y);
201
+ return [t.map((e) => e[0]), Yt(t.map((e) => e[1]))];
202
202
  }
203
- const St = /* @__PURE__ */ new WeakMap();
204
- function W(s, t) {
205
- return St.set(s, t), s;
203
+ const Nt = /* @__PURE__ */ new WeakMap();
204
+ function B(s, t) {
205
+ return Nt.set(s, t), s;
206
206
  }
207
- function _t(s) {
208
- return Object.assign(s, { [gt]: !0 });
207
+ function Zt(s) {
208
+ return Object.assign(s, { [bt]: !0 });
209
209
  }
210
- function B(s) {
211
- for (const [t, e] of mt)
210
+ function Y(s) {
211
+ for (const [t, e] of Dt)
212
212
  if (e.canHandle(s)) {
213
- const [n, i] = e.serialize(s);
213
+ const [n, r] = e.serialize(s);
214
214
  return [
215
215
  {
216
216
  type: "HANDLER",
217
217
  name: t,
218
218
  value: n
219
219
  },
220
- i
220
+ r
221
221
  ];
222
222
  }
223
223
  return [
@@ -225,178 +225,290 @@ function B(s) {
225
225
  type: "RAW",
226
226
  value: s
227
227
  },
228
- St.get(s) || []
228
+ Nt.get(s) || []
229
229
  ];
230
230
  }
231
- function N(s) {
231
+ function C(s) {
232
232
  switch (s.type) {
233
233
  case "HANDLER":
234
- return mt.get(s.name).deserialize(s.value);
234
+ return Dt.get(s.name).deserialize(s.value);
235
235
  case "RAW":
236
236
  return s.value;
237
237
  }
238
238
  }
239
- function D(s, t, e, n) {
240
- return new Promise((i) => {
241
- const r = jt();
242
- t.set(r, i), s.start && s.start(), s.postMessage(Object.assign({ id: r }, e), n);
239
+ function $(s, t, e, n) {
240
+ return new Promise((r) => {
241
+ const i = Xt();
242
+ t.set(i, r), s.start && s.start(), s.postMessage(Object.assign({ id: i }, e), n);
243
243
  });
244
244
  }
245
- function jt() {
245
+ function Xt() {
246
246
  return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
247
247
  }
248
- var A = /* @__PURE__ */ ((s) => (s.Added = "added", s.Changed = "changed", s.Removed = "removed", s))(A || {});
249
- class p extends Error {
250
- constructor(t, e, n, i) {
251
- super(t, { cause: i }), this.code = e, this.path = n, this.name = "OPFSError";
248
+ var D = /* @__PURE__ */ ((s) => (s.Added = "added", s.Changed = "changed", s.Removed = "removed", s))(D || {});
249
+ const Jt = {
250
+ ENOENT: -2,
251
+ // No such file or directory
252
+ EISDIR: -21,
253
+ // Is a directory
254
+ ENOTDIR: -20,
255
+ // Not a directory
256
+ EACCES: -13,
257
+ // Permission denied
258
+ EEXIST: -17,
259
+ // File exists
260
+ ENOTEMPTY: -39,
261
+ // Directory not empty
262
+ EINVAL: -22,
263
+ // Invalid argument
264
+ EIO: -5,
265
+ // I/O error
266
+ ENOSPC: -28,
267
+ // No space left on device
268
+ EBUSY: -16,
269
+ // Device or resource busy
270
+ EINTR: -4,
271
+ // Interrupted system call
272
+ ENOTSUP: -95,
273
+ // Operation not supported
274
+ ERANGE: -34,
275
+ // Result too large
276
+ EBADF: -9,
277
+ // Bad file descriptor
278
+ EROOT: -1
279
+ // Custom: Cannot remove root directory
280
+ };
281
+ class w extends Error {
282
+ errno;
283
+ syscall;
284
+ path;
285
+ constructor(t, e, n, r, i) {
286
+ super(t, { cause: i }), this.name = e, this.errno = Jt[e] || -1, this.path = n, this.syscall = r;
252
287
  }
253
288
  }
254
- class Ut extends p {
289
+ class Qt extends w {
255
290
  constructor(t) {
256
- super("OPFS is not supported in this browser", "OPFS_NOT_SUPPORTED", void 0, t);
291
+ super("OPFS is not supported in this browser", "ENOTSUP", void 0, void 0, t);
292
+ }
293
+ }
294
+ class Kt extends w {
295
+ constructor(t, e, n) {
296
+ super(t, "INVALID_PATH", e, "access", n);
297
+ }
298
+ }
299
+ class F extends w {
300
+ constructor(t, e, n) {
301
+ const r = {
302
+ file: \`File not found: \${e}\`,
303
+ directory: \`Directory not found: \${e}\`,
304
+ source: \`Source does not exist: \${e}\`
305
+ };
306
+ super(r[t], "ENOENT", e, "access", n);
257
307
  }
258
308
  }
259
- class Bt extends p {
309
+ class te extends w {
260
310
  constructor(t, e, n) {
261
- super(t, "INVALID_PATH", e, n);
311
+ super(\`Permission denied for \${e} on: \${t}\`, "EACCES", t, e, n);
262
312
  }
263
313
  }
264
- class it extends p {
314
+ class ee extends w {
315
+ constructor(t, e, n) {
316
+ super(t, "ENOSPC", e, "write", n);
317
+ }
318
+ }
319
+ class se extends w {
265
320
  constructor(t, e) {
266
- super(\`File not found: \${t}\`, "FILE_NOT_FOUND", t, e);
321
+ super(\`File is busy: \${t}\`, "EBUSY", t, "open", e);
322
+ }
323
+ }
324
+ class z extends w {
325
+ constructor(t, e, n) {
326
+ const r = t === "directory" ? \`Is a directory: \${e}\` : \`Not a directory: \${e}\`, i = t === "directory" ? "EISDIR" : "ENOTDIR";
327
+ super(r, i, e, "access", n);
267
328
  }
268
329
  }
269
- function L(s, t, e, n) {
270
- const i = \`\${s.toUpperCase()}_FAILED\`;
271
- return new p(\`Failed to \${s} file descriptor: \${t}\`, i, e, n);
330
+ class N extends w {
331
+ constructor(t, e, n, r) {
332
+ const i = {
333
+ argument: "EINVAL",
334
+ format: "INVALID_FORMAT",
335
+ descriptor: "EBADF",
336
+ overflow: "ERANGE"
337
+ };
338
+ super(e, i[t], n, "validate", r);
339
+ }
272
340
  }
273
- function Gt(s, t) {
274
- const e = t?.path;
341
+ class ne extends w {
342
+ constructor(t, e) {
343
+ super(\`Operation aborted: \${t}\`, "EINTR", t, "interrupt", e);
344
+ }
345
+ }
346
+ class ut extends w {
347
+ constructor(t, e, n) {
348
+ super(t, "EIO", e, "io", n);
349
+ }
350
+ }
351
+ class Ct extends w {
352
+ constructor(t, e) {
353
+ super(\`Operation not supported: \${t}\`, "ENOTSUP", t, "operation", e);
354
+ }
355
+ }
356
+ class rt extends w {
357
+ constructor(t, e, n) {
358
+ const r = {
359
+ RM_FAILED: \`Failed to remove entry: \${e}\`,
360
+ ENOTEMPTY: \`Directory not empty: \${e}. Use recursive option to force removal.\`,
361
+ EROOT: "Cannot remove root directory"
362
+ };
363
+ super(r[t] || \`Directory operation failed: \${e}\`, t, e, "unlink", n);
364
+ }
365
+ }
366
+ class re extends w {
367
+ constructor(t, e) {
368
+ super("Failed to initialize OPFS", "INIT_FAILED", t, "init", e);
369
+ }
370
+ }
371
+ class Q extends w {
372
+ constructor(t, e, n) {
373
+ super(\`Failed to \${t}: \${e}\`, \`\${t.toUpperCase()}_FAILED\`, e, t, n);
374
+ }
375
+ }
376
+ class K extends w {
377
+ constructor(t, e) {
378
+ super(\`Destination already exists: \${t}\`, "EEXIST", t, "open", e);
379
+ }
380
+ }
381
+ function j(s, t, e, n) {
382
+ const r = \`\${s.toUpperCase()}_FAILED\`;
383
+ return new w(\`Failed to \${s} file descriptor: \${t}\`, r, e, s, n);
384
+ }
385
+ function A(s, t) {
386
+ const e = t?.path, n = t?.isDirectory;
275
387
  switch (s.name) {
276
388
  case "InvalidStateError":
277
- return new p(\`File is busy: \${e || "unknown"}\`, "EBUSY", e, s);
389
+ return new se(e || "unknown", s);
278
390
  case "QuotaExceededError":
279
- return new p(\`No space left on device: \${e || "unknown"}\`, "ENOSPC", e, s);
391
+ return new ee(\`No space left on device: \${e || "unknown"}\`, e, s);
280
392
  case "NotFoundError":
281
- return new p(\`No such file or directory: \${e || "unknown"}\`, "ENOENT", e, s);
393
+ return new F("file", e, s);
282
394
  case "TypeMismatchError":
283
- return new p(\`Is a directory: \${e || "unknown"}\`, "EISDIR", e, s);
395
+ return n !== void 0 ? n ? new z("directory", e || "unknown", s) : new z("file", e || "unknown", s) : new N("argument", \`Type mismatch: \${e || "unknown"}\`, e, s);
284
396
  case "NotAllowedError":
285
397
  case "SecurityError":
286
- return new p(\`Permission denied: \${e || "unknown"}\`, "EACCES", e, s);
398
+ return new te(e, "unknown", s);
287
399
  case "InvalidModificationError":
288
- return new p(\`Invalid modification: \${e || "unknown"}\`, "EINVAL", e, s);
400
+ return new N("argument", \`Invalid modification: \${e || "unknown"}\`, e, s);
289
401
  case "AbortError":
290
- return new p(\`Operation aborted: \${e || "unknown"}\`, "EINTR", e, s);
402
+ return new ne(e || "unknown", s);
291
403
  case "OperationError":
292
- return new p(\`Operation failed: \${e || "unknown"}\`, "EIO", e, s);
404
+ return new ut(\`Operation failed: \${e || "unknown"}\`, e, s);
293
405
  case "TypeError":
294
- return new p(\`Operation not supported: \${e || "unknown"}\`, "ENOTSUP", e, s);
406
+ return new Ct(e || "unknown", s);
295
407
  default:
296
- return new p(\`I/O error: \${e || "unknown"}\`, "EIO", e, s);
408
+ return new ut(\`I/O error: \${e || "unknown"}\`, e, s);
297
409
  }
298
410
  }
299
- const xt = (s, t, e) => {
300
- const n = s instanceof RegExp ? rt(s, e) : s, i = t instanceof RegExp ? rt(t, e) : t, r = n !== null && i != null && qt(n, i, e);
301
- return r && {
302
- start: r[0],
303
- end: r[1],
304
- pre: e.slice(0, r[0]),
305
- body: e.slice(r[0] + n.length, r[1]),
306
- post: e.slice(r[1] + i.length)
411
+ const Ft = (s, t, e) => {
412
+ const n = s instanceof RegExp ? ft(s, e) : s, r = t instanceof RegExp ? ft(t, e) : t, i = n !== null && r != null && ie(n, r, e);
413
+ return i && {
414
+ start: i[0],
415
+ end: i[1],
416
+ pre: e.slice(0, i[0]),
417
+ body: e.slice(i[0] + n.length, i[1]),
418
+ post: e.slice(i[1] + r.length)
307
419
  };
308
- }, rt = (s, t) => {
420
+ }, ft = (s, t) => {
309
421
  const e = t.match(s);
310
422
  return e ? e[0] : null;
311
- }, qt = (s, t, e) => {
312
- let n, i, r, o, a, l = e.indexOf(s), h = e.indexOf(t, l + 1), c = l;
423
+ }, ie = (s, t, e) => {
424
+ let n, r, i, o, a, l = e.indexOf(s), h = e.indexOf(t, l + 1), c = l;
313
425
  if (l >= 0 && h > 0) {
314
426
  if (s === t)
315
427
  return [l, h];
316
- for (n = [], r = e.length; c >= 0 && !a; ) {
428
+ for (n = [], i = e.length; c >= 0 && !a; ) {
317
429
  if (c === l)
318
430
  n.push(c), l = e.indexOf(s, c + 1);
319
431
  else if (n.length === 1) {
320
432
  const f = n.pop();
321
433
  f !== void 0 && (a = [f, h]);
322
434
  } else
323
- i = n.pop(), i !== void 0 && i < r && (r = i, o = h), h = e.indexOf(t, c + 1);
435
+ r = n.pop(), r !== void 0 && r < i && (i = r, o = h), h = e.indexOf(t, c + 1);
324
436
  c = l < h && l >= 0 ? l : h;
325
437
  }
326
- n.length && o !== void 0 && (a = [r, o]);
438
+ n.length && o !== void 0 && (a = [i, o]);
327
439
  }
328
440
  return a;
329
- }, bt = "\\0SLASH" + Math.random() + "\\0", vt = "\\0OPEN" + Math.random() + "\\0", tt = "\\0CLOSE" + Math.random() + "\\0", At = "\\0COMMA" + Math.random() + "\\0", Ft = "\\0PERIOD" + Math.random() + "\\0", Vt = new RegExp(bt, "g"), Xt = new RegExp(vt, "g"), Yt = new RegExp(tt, "g"), Zt = new RegExp(At, "g"), Jt = new RegExp(Ft, "g"), Kt = /\\\\\\\\/g, Qt = /\\\\{/g, te = /\\\\}/g, ee = /\\\\,/g, se = /\\\\./g;
330
- function X(s) {
441
+ }, $t = "\\0SLASH" + Math.random() + "\\0", Mt = "\\0OPEN" + Math.random() + "\\0", at = "\\0CLOSE" + Math.random() + "\\0", Pt = "\\0COMMA" + Math.random() + "\\0", Tt = "\\0PERIOD" + Math.random() + "\\0", oe = new RegExp($t, "g"), ae = new RegExp(Mt, "g"), ce = new RegExp(at, "g"), le = new RegExp(Pt, "g"), he = new RegExp(Tt, "g"), ue = /\\\\\\\\/g, fe = /\\\\{/g, de = /\\\\}/g, pe = /\\\\,/g, ge = /\\\\./g;
442
+ function tt(s) {
331
443
  return isNaN(s) ? s.charCodeAt(0) : parseInt(s, 10);
332
444
  }
333
- function ne(s) {
334
- return s.replace(Kt, bt).replace(Qt, vt).replace(te, tt).replace(ee, At).replace(se, Ft);
445
+ function we(s) {
446
+ return s.replace(ue, $t).replace(fe, Mt).replace(de, at).replace(pe, Pt).replace(ge, Tt);
335
447
  }
336
- function ie(s) {
337
- return s.replace(Vt, "\\\\").replace(Xt, "{").replace(Yt, "}").replace(Zt, ",").replace(Jt, ".");
448
+ function me(s) {
449
+ return s.replace(oe, "\\\\").replace(ae, "{").replace(ce, "}").replace(le, ",").replace(he, ".");
338
450
  }
339
- function Nt(s) {
451
+ function Rt(s) {
340
452
  if (!s)
341
453
  return [""];
342
- const t = [], e = xt("{", "}", s);
454
+ const t = [], e = Ft("{", "}", s);
343
455
  if (!e)
344
456
  return s.split(",");
345
- const { pre: n, body: i, post: r } = e, o = n.split(",");
346
- o[o.length - 1] += "{" + i + "}";
347
- const a = Nt(r);
348
- return r.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
457
+ const { pre: n, body: r, post: i } = e, o = n.split(",");
458
+ o[o.length - 1] += "{" + r + "}";
459
+ const a = Rt(i);
460
+ return i.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
349
461
  }
350
- function re(s) {
351
- return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), I(ne(s), !0).map(ie)) : [];
462
+ function ye(s) {
463
+ return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), I(we(s), !0).map(me)) : [];
352
464
  }
353
- function oe(s) {
465
+ function Ee(s) {
354
466
  return "{" + s + "}";
355
467
  }
356
- function ae(s) {
468
+ function Se(s) {
357
469
  return /^-?0\\d/.test(s);
358
470
  }
359
- function ce(s, t) {
471
+ function xe(s, t) {
360
472
  return s <= t;
361
473
  }
362
- function le(s, t) {
474
+ function be(s, t) {
363
475
  return s >= t;
364
476
  }
365
477
  function I(s, t) {
366
- const e = [], n = xt("{", "}", s);
478
+ const e = [], n = Ft("{", "}", s);
367
479
  if (!n)
368
480
  return [s];
369
- const i = n.pre, r = n.post.length ? I(n.post, !1) : [""];
481
+ const r = n.pre, i = n.post.length ? I(n.post, !1) : [""];
370
482
  if (/\\$$/.test(n.pre))
371
- for (let o = 0; o < r.length; o++) {
372
- const a = i + "{" + n.body + "}" + r[o];
483
+ for (let o = 0; o < i.length; o++) {
484
+ const a = r + "{" + n.body + "}" + i[o];
373
485
  e.push(a);
374
486
  }
375
487
  else {
376
488
  const o = /^-?\\d+\\.\\.-?\\d+(?:\\.\\.-?\\d+)?$/.test(n.body), a = /^[a-zA-Z]\\.\\.[a-zA-Z](?:\\.\\.-?\\d+)?$/.test(n.body), l = o || a, h = n.body.indexOf(",") >= 0;
377
489
  if (!l && !h)
378
- return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + tt + n.post, I(s)) : [s];
490
+ return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + at + n.post, I(s)) : [s];
379
491
  let c;
380
492
  if (l)
381
493
  c = n.body.split(/\\.\\./);
382
- else if (c = Nt(n.body), c.length === 1 && c[0] !== void 0 && (c = I(c[0], !1).map(oe), c.length === 1))
383
- return r.map((u) => n.pre + c[0] + u);
494
+ else if (c = Rt(n.body), c.length === 1 && c[0] !== void 0 && (c = I(c[0], !1).map(Ee), c.length === 1))
495
+ return i.map((u) => n.pre + c[0] + u);
384
496
  let f;
385
497
  if (l && c[0] !== void 0 && c[1] !== void 0) {
386
- const u = X(c[0]), d = X(c[1]), w = Math.max(c[0].length, c[1].length);
387
- let g = c.length === 3 && c[2] !== void 0 ? Math.abs(X(c[2])) : 1, S = ce;
388
- d < u && (g *= -1, S = le);
389
- const $ = c.some(ae);
498
+ const u = tt(c[0]), d = tt(c[1]), g = Math.max(c[0].length, c[1].length);
499
+ let p = c.length === 3 && c[2] !== void 0 ? Math.abs(tt(c[2])) : 1, S = xe;
500
+ d < u && (p *= -1, S = be);
501
+ const P = c.some(Se);
390
502
  f = [];
391
- for (let x = u; S(x, d); x += g) {
503
+ for (let x = u; S(x, d); x += p) {
392
504
  let m;
393
505
  if (a)
394
506
  m = String.fromCharCode(x), m === "\\\\" && (m = "");
395
- else if (m = String(x), $) {
396
- const C = w - m.length;
397
- if (C > 0) {
398
- const R = new Array(C + 1).join("0");
399
- x < 0 ? m = "-" + R + m.slice(1) : m = R + m;
507
+ else if (m = String(x), P) {
508
+ const T = g - m.length;
509
+ if (T > 0) {
510
+ const H = new Array(T + 1).join("0");
511
+ x < 0 ? m = "-" + H + m.slice(1) : m = H + m;
400
512
  }
401
513
  }
402
514
  f.push(m);
@@ -407,19 +519,19 @@ function I(s, t) {
407
519
  f.push.apply(f, I(c[u], !1));
408
520
  }
409
521
  for (let u = 0; u < f.length; u++)
410
- for (let d = 0; d < r.length; d++) {
411
- const w = i + f[u] + r[d];
412
- (!t || l || w) && e.push(w);
522
+ for (let d = 0; d < i.length; d++) {
523
+ const g = r + f[u] + i[d];
524
+ (!t || l || g) && e.push(g);
413
525
  }
414
526
  }
415
527
  return e;
416
528
  }
417
- const he = 1024 * 64, G = (s) => {
529
+ const Oe = 1024 * 64, Z = (s) => {
418
530
  if (typeof s != "string")
419
531
  throw new TypeError("invalid pattern");
420
- if (s.length > he)
532
+ if (s.length > Oe)
421
533
  throw new TypeError("pattern is too long");
422
- }, ue = {
534
+ }, De = {
423
535
  "[:alnum:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}", !0],
424
536
  "[:alpha:]": ["\\\\p{L}\\\\p{Nl}", !0],
425
537
  "[:ascii:]": ["\\\\x00-\\\\x7f", !1],
@@ -434,77 +546,77 @@ const he = 1024 * 64, G = (s) => {
434
546
  "[:upper:]": ["\\\\p{Lu}", !0],
435
547
  "[:word:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}\\\\p{Pc}", !0],
436
548
  "[:xdigit:]": ["A-Fa-f0-9", !1]
437
- }, M = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), fe = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), ot = (s) => s.join(""), de = (s, t) => {
549
+ }, R = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), ve = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), dt = (s) => s.join(""), Ae = (s, t) => {
438
550
  const e = t;
439
551
  if (s.charAt(e) !== "[")
440
552
  throw new Error("not in a brace expression");
441
- const n = [], i = [];
442
- let r = e + 1, o = !1, a = !1, l = !1, h = !1, c = e, f = "";
443
- t: for (; r < s.length; ) {
444
- const g = s.charAt(r);
445
- if ((g === "!" || g === "^") && r === e + 1) {
446
- h = !0, r++;
553
+ const n = [], r = [];
554
+ let i = e + 1, o = !1, a = !1, l = !1, h = !1, c = e, f = "";
555
+ t: for (; i < s.length; ) {
556
+ const p = s.charAt(i);
557
+ if ((p === "!" || p === "^") && i === e + 1) {
558
+ h = !0, i++;
447
559
  continue;
448
560
  }
449
- if (g === "]" && o && !l) {
450
- c = r + 1;
561
+ if (p === "]" && o && !l) {
562
+ c = i + 1;
451
563
  break;
452
564
  }
453
- if (o = !0, g === "\\\\" && !l) {
454
- l = !0, r++;
565
+ if (o = !0, p === "\\\\" && !l) {
566
+ l = !0, i++;
455
567
  continue;
456
568
  }
457
- if (g === "[" && !l) {
458
- for (const [S, [F, $, x]] of Object.entries(ue))
459
- if (s.startsWith(S, r)) {
569
+ if (p === "[" && !l) {
570
+ for (const [S, [v, P, x]] of Object.entries(De))
571
+ if (s.startsWith(S, i)) {
460
572
  if (f)
461
573
  return ["$.", !1, s.length - e, !0];
462
- r += S.length, x ? i.push(F) : n.push(F), a = a || $;
574
+ i += S.length, x ? r.push(v) : n.push(v), a = a || P;
463
575
  continue t;
464
576
  }
465
577
  }
466
578
  if (l = !1, f) {
467
- g > f ? n.push(M(f) + "-" + M(g)) : g === f && n.push(M(g)), f = "", r++;
579
+ p > f ? n.push(R(f) + "-" + R(p)) : p === f && n.push(R(p)), f = "", i++;
468
580
  continue;
469
581
  }
470
- if (s.startsWith("-]", r + 1)) {
471
- n.push(M(g + "-")), r += 2;
582
+ if (s.startsWith("-]", i + 1)) {
583
+ n.push(R(p + "-")), i += 2;
472
584
  continue;
473
585
  }
474
- if (s.startsWith("-", r + 1)) {
475
- f = g, r += 2;
586
+ if (s.startsWith("-", i + 1)) {
587
+ f = p, i += 2;
476
588
  continue;
477
589
  }
478
- n.push(M(g)), r++;
590
+ n.push(R(p)), i++;
479
591
  }
480
- if (c < r)
592
+ if (c < i)
481
593
  return ["", !1, 0, !1];
482
- if (!n.length && !i.length)
594
+ if (!n.length && !r.length)
483
595
  return ["$.", !1, s.length - e, !0];
484
- if (i.length === 0 && n.length === 1 && /^\\\\?.$/.test(n[0]) && !h) {
485
- const g = n[0].length === 2 ? n[0].slice(-1) : n[0];
486
- return [fe(g), !1, c - e, !1];
596
+ if (r.length === 0 && n.length === 1 && /^\\\\?.$/.test(n[0]) && !h) {
597
+ const p = n[0].length === 2 ? n[0].slice(-1) : n[0];
598
+ return [ve(p), !1, c - e, !1];
487
599
  }
488
- const u = "[" + (h ? "^" : "") + ot(n) + "]", d = "[" + (h ? "" : "^") + ot(i) + "]";
489
- return [n.length && i.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a, c - e, !0];
490
- }, P = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\\[([^\\/\\\\])\\]/g, "$1") : s.replace(/((?!\\\\).|^)\\[([^\\/\\\\])\\]/g, "$1$2").replace(/\\\\([^\\/])/g, "$1"), pe = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), at = (s) => pe.has(s), ge = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", z = "(?!\\\\.)", we = /* @__PURE__ */ new Set(["[", "."]), me = /* @__PURE__ */ new Set(["..", "."]), ye = new Set("().*{}+?[]^$\\\\!"), Ee = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), et = "[^/]", ct = et + "*?", lt = et + "+?";
600
+ const u = "[" + (h ? "^" : "") + dt(n) + "]", d = "[" + (h ? "" : "^") + dt(r) + "]";
601
+ return [n.length && r.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a, c - e, !0];
602
+ }, k = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\\[([^\\/\\\\])\\]/g, "$1") : s.replace(/((?!\\\\).|^)\\[([^\\/\\\\])\\]/g, "$1$2").replace(/\\\\([^\\/])/g, "$1"), Ne = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), pt = (s) => Ne.has(s), Ce = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", _ = "(?!\\\\.)", Fe = /* @__PURE__ */ new Set(["[", "."]), $e = /* @__PURE__ */ new Set(["..", "."]), Me = new Set("().*{}+?[]^$\\\\!"), Pe = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), ct = "[^/]", gt = ct + "*?", wt = ct + "+?";
491
603
  class E {
492
604
  type;
493
605
  #s;
494
606
  #n;
495
- #r = !1;
607
+ #i = !1;
496
608
  #t = [];
497
609
  #e;
498
610
  #o;
499
611
  #c;
500
612
  #a = !1;
501
- #i;
613
+ #r;
502
614
  #l;
503
615
  // set to true if it's an extglob with no children
504
616
  // (which really means one child of '')
505
617
  #u = !1;
506
618
  constructor(t, e, n = {}) {
507
- 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.#c = this.#s === this ? [] : this.#s.#c, t === "!" && !this.#s.#a && this.#c.push(this), this.#o = this.#e ? this.#e.#t.length : 0;
619
+ 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;
508
620
  }
509
621
  get hasMagic() {
510
622
  if (this.#n !== void 0)
@@ -530,11 +642,11 @@ class E {
530
642
  continue;
531
643
  let e = t, n = e.#e;
532
644
  for (; n; ) {
533
- for (let i = e.#o + 1; !n.type && i < n.#t.length; i++)
534
- for (const r of t.#t) {
535
- if (typeof r == "string")
645
+ for (let r = e.#o + 1; !n.type && r < n.#t.length; r++)
646
+ for (const i of t.#t) {
647
+ if (typeof i == "string")
536
648
  throw new Error("string part in extglob AST??");
537
- r.copyIn(n.#t[i]);
649
+ i.copyIn(n.#t[r]);
538
650
  }
539
651
  e = n, n = e.#e;
540
652
  }
@@ -587,40 +699,40 @@ class E {
587
699
  e.copyIn(n);
588
700
  return e;
589
701
  }
590
- static #h(t, e, n, i) {
591
- let r = !1, o = !1, a = -1, l = !1;
702
+ static #h(t, e, n, r) {
703
+ let i = !1, o = !1, a = -1, l = !1;
592
704
  if (e.type === null) {
593
- let d = n, w = "";
705
+ let d = n, g = "";
594
706
  for (; d < t.length; ) {
595
- const g = t.charAt(d++);
596
- if (r || g === "\\\\") {
597
- r = !r, w += g;
707
+ const p = t.charAt(d++);
708
+ if (i || p === "\\\\") {
709
+ i = !i, g += p;
598
710
  continue;
599
711
  }
600
712
  if (o) {
601
- d === a + 1 ? (g === "^" || g === "!") && (l = !0) : g === "]" && !(d === a + 2 && l) && (o = !1), w += g;
713
+ d === a + 1 ? (p === "^" || p === "!") && (l = !0) : p === "]" && !(d === a + 2 && l) && (o = !1), g += p;
602
714
  continue;
603
- } else if (g === "[") {
604
- o = !0, a = d, l = !1, w += g;
715
+ } else if (p === "[") {
716
+ o = !0, a = d, l = !1, g += p;
605
717
  continue;
606
718
  }
607
- if (!i.noext && at(g) && t.charAt(d) === "(") {
608
- e.push(w), w = "";
609
- const S = new E(g, e);
610
- d = E.#h(t, S, d, i), e.push(S);
719
+ if (!r.noext && pt(p) && t.charAt(d) === "(") {
720
+ e.push(g), g = "";
721
+ const S = new E(p, e);
722
+ d = E.#h(t, S, d, r), e.push(S);
611
723
  continue;
612
724
  }
613
- w += g;
725
+ g += p;
614
726
  }
615
- return e.push(w), d;
727
+ return e.push(g), d;
616
728
  }
617
729
  let h = n + 1, c = new E(null, e);
618
730
  const f = [];
619
731
  let u = "";
620
732
  for (; h < t.length; ) {
621
733
  const d = t.charAt(h++);
622
- if (r || d === "\\\\") {
623
- r = !r, u += d;
734
+ if (i || d === "\\\\") {
735
+ i = !i, u += d;
624
736
  continue;
625
737
  }
626
738
  if (o) {
@@ -630,10 +742,10 @@ class E {
630
742
  o = !0, a = h, l = !1, u += d;
631
743
  continue;
632
744
  }
633
- if (at(d) && t.charAt(h) === "(") {
745
+ if (pt(d) && t.charAt(h) === "(") {
634
746
  c.push(u), u = "";
635
- const w = new E(d, c);
636
- c.push(w), h = E.#h(t, w, h, i);
747
+ const g = new E(d, c);
748
+ c.push(g), h = E.#h(t, g, h, r);
637
749
  continue;
638
750
  }
639
751
  if (d === "|") {
@@ -655,17 +767,17 @@ class E {
655
767
  toMMPattern() {
656
768
  if (this !== this.#s)
657
769
  return this.#s.toMMPattern();
658
- const t = this.toString(), [e, n, i, r] = this.toRegExpSource();
659
- if (!(i || this.#n || this.#i.nocase && !this.#i.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
770
+ const t = this.toString(), [e, n, r, i] = this.toRegExpSource();
771
+ if (!(r || this.#n || this.#r.nocase && !this.#r.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
660
772
  return n;
661
- const a = (this.#i.nocase ? "i" : "") + (r ? "u" : "");
773
+ const a = (this.#r.nocase ? "i" : "") + (i ? "u" : "");
662
774
  return Object.assign(new RegExp(\`^\${e}$\`, a), {
663
775
  _src: e,
664
776
  _glob: t
665
777
  });
666
778
  }
667
779
  get options() {
668
- return this.#i;
780
+ return this.#r;
669
781
  }
670
782
  // returns the string match, the regexp source, whether there's magic
671
783
  // in the regexp (so a regular expression is required) and whether or
@@ -737,168 +849,168 @@ class E {
737
849
  // is ^(?!\\.), we can just prepend (?!\\.) to the pattern (either root
738
850
  // or start or whatever) and prepend ^ or / at the Regexp construction.
739
851
  toRegExpSource(t) {
740
- const e = t ?? !!this.#i.dot;
852
+ const e = t ?? !!this.#r.dot;
741
853
  if (this.#s === this && this.#d(), !this.type) {
742
854
  const l = this.isStart() && this.isEnd(), h = this.#t.map((d) => {
743
- const [w, g, S, F] = typeof d == "string" ? E.#p(d, this.#n, l) : d.toRegExpSource(t);
744
- return this.#n = this.#n || S, this.#r = this.#r || F, w;
855
+ const [g, p, S, v] = typeof d == "string" ? E.#p(d, this.#n, l) : d.toRegExpSource(t);
856
+ return this.#n = this.#n || S, this.#i = this.#i || v, g;
745
857
  }).join("");
746
858
  let c = "";
747
- if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && me.has(this.#t[0]))) {
748
- const w = we, g = (
859
+ if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && $e.has(this.#t[0]))) {
860
+ const g = Fe, p = (
749
861
  // dots are allowed, and the pattern starts with [ or .
750
- e && w.has(h.charAt(0)) || // the pattern starts with \\., and then [ or .
751
- h.startsWith("\\\\.") && w.has(h.charAt(2)) || // the pattern starts with \\.\\., and then [ or .
752
- h.startsWith("\\\\.\\\\.") && w.has(h.charAt(4))
753
- ), S = !e && !t && w.has(h.charAt(0));
754
- c = g ? ge : S ? z : "";
862
+ e && g.has(h.charAt(0)) || // the pattern starts with \\., and then [ or .
863
+ h.startsWith("\\\\.") && g.has(h.charAt(2)) || // the pattern starts with \\.\\., and then [ or .
864
+ h.startsWith("\\\\.\\\\.") && g.has(h.charAt(4))
865
+ ), S = !e && !t && g.has(h.charAt(0));
866
+ c = p ? Ce : S ? _ : "";
755
867
  }
756
868
  let f = "";
757
869
  return this.isEnd() && this.#s.#a && this.#e?.type === "!" && (f = "(?:$|\\\\/)"), [
758
870
  c + h + f,
759
- P(h),
871
+ k(h),
760
872
  this.#n = !!this.#n,
761
- this.#r
873
+ this.#i
762
874
  ];
763
875
  }
764
- const n = this.type === "*" || this.type === "+", i = this.type === "!" ? "(?:(?!(?:" : "(?:";
765
- let r = this.#f(e);
766
- if (this.isStart() && this.isEnd() && !r && this.type !== "!") {
876
+ const n = this.type === "*" || this.type === "+", r = this.type === "!" ? "(?:(?!(?:" : "(?:";
877
+ let i = this.#f(e);
878
+ if (this.isStart() && this.isEnd() && !i && this.type !== "!") {
767
879
  const l = this.toString();
768
- return this.#t = [l], this.type = null, this.#n = void 0, [l, P(this.toString()), !1, !1];
880
+ return this.#t = [l], this.type = null, this.#n = void 0, [l, k(this.toString()), !1, !1];
769
881
  }
770
- let o = !n || t || e || !z ? "" : this.#f(!0);
771
- o === r && (o = ""), o && (r = \`(?:\${r})(?:\${o})*?\`);
882
+ let o = !n || t || e || !_ ? "" : this.#f(!0);
883
+ o === i && (o = ""), o && (i = \`(?:\${i})(?:\${o})*?\`);
772
884
  let a = "";
773
885
  if (this.type === "!" && this.#u)
774
- a = (this.isStart() && !e ? z : "") + lt;
886
+ a = (this.isStart() && !e ? _ : "") + wt;
775
887
  else {
776
888
  const l = this.type === "!" ? (
777
889
  // !() must match something,but !(x) can match ''
778
- "))" + (this.isStart() && !e && !t ? z : "") + ct + ")"
890
+ "))" + (this.isStart() && !e && !t ? _ : "") + gt + ")"
779
891
  ) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : \`)\${this.type}\`;
780
- a = i + r + l;
892
+ a = r + i + l;
781
893
  }
782
894
  return [
783
895
  a,
784
- P(r),
896
+ k(i),
785
897
  this.#n = !!this.#n,
786
- this.#r
898
+ this.#i
787
899
  ];
788
900
  }
789
901
  #f(t) {
790
902
  return this.#t.map((e) => {
791
903
  if (typeof e == "string")
792
904
  throw new Error("string type in extglob ast??");
793
- const [n, i, r, o] = e.toRegExpSource(t);
794
- return this.#r = this.#r || o, n;
905
+ const [n, r, i, o] = e.toRegExpSource(t);
906
+ return this.#i = this.#i || o, n;
795
907
  }).filter((e) => !(this.isStart() && this.isEnd()) || !!e).join("|");
796
908
  }
797
909
  static #p(t, e, n = !1) {
798
- let i = !1, r = "", o = !1;
910
+ let r = !1, i = "", o = !1;
799
911
  for (let a = 0; a < t.length; a++) {
800
912
  const l = t.charAt(a);
801
- if (i) {
802
- i = !1, r += (ye.has(l) ? "\\\\" : "") + l;
913
+ if (r) {
914
+ r = !1, i += (Me.has(l) ? "\\\\" : "") + l;
803
915
  continue;
804
916
  }
805
917
  if (l === "\\\\") {
806
- a === t.length - 1 ? r += "\\\\\\\\" : i = !0;
918
+ a === t.length - 1 ? i += "\\\\\\\\" : r = !0;
807
919
  continue;
808
920
  }
809
921
  if (l === "[") {
810
- const [h, c, f, u] = de(t, a);
922
+ const [h, c, f, u] = Ae(t, a);
811
923
  if (f) {
812
- r += h, o = o || c, a += f - 1, e = e || u;
924
+ i += h, o = o || c, a += f - 1, e = e || u;
813
925
  continue;
814
926
  }
815
927
  }
816
928
  if (l === "*") {
817
- n && t === "*" ? r += lt : r += ct, e = !0;
929
+ n && t === "*" ? i += wt : i += gt, e = !0;
818
930
  continue;
819
931
  }
820
932
  if (l === "?") {
821
- r += et, e = !0;
933
+ i += ct, e = !0;
822
934
  continue;
823
935
  }
824
- r += Ee(l);
936
+ i += Pe(l);
825
937
  }
826
- return [r, P(t), !!e, o];
938
+ return [i, k(t), !!e, o];
827
939
  }
828
940
  }
829
- const Se = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\]]/g, "[$&]") : s.replace(/[?*()[\\]\\\\]/g, "\\\\$&"), y = (s, t, e = {}) => (G(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new q(t, e).match(s)), xe = /^\\*+([^+@!?\\*\\[\\(]*)$/, be = (s) => (t) => !t.startsWith(".") && t.endsWith(s), ve = (s) => (t) => t.endsWith(s), Ae = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), Fe = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), Ne = /^\\*+\\.\\*+$/, De = (s) => !s.startsWith(".") && s.includes("."), Oe = (s) => s !== "." && s !== ".." && s.includes("."), $e = /^\\.\\*+$/, Ce = (s) => s !== "." && s !== ".." && s.startsWith("."), Me = /^\\*+$/, Ie = (s) => s.length !== 0 && !s.startsWith("."), Pe = (s) => s.length !== 0 && s !== "." && s !== "..", Te = /^\\?+([^+@!?\\*\\[\\(]*)?$/, Re = ([s, t = ""]) => {
830
- const e = Dt([s]);
941
+ const Te = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\]]/g, "[$&]") : s.replace(/[?*()[\\]\\\\]/g, "\\\\$&"), y = (s, t, e = {}) => (Z(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new X(t, e).match(s)), Re = /^\\*+([^+@!?\\*\\[\\(]*)$/, Ie = (s) => (t) => !t.startsWith(".") && t.endsWith(s), ke = (s) => (t) => t.endsWith(s), Le = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), ze = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), He = /^\\*+\\.\\*+$/, We = (s) => !s.startsWith(".") && s.includes("."), je = (s) => s !== "." && s !== ".." && s.includes("."), _e = /^\\.\\*+$/, Ue = (s) => s !== "." && s !== ".." && s.startsWith("."), Be = /^\\*+$/, Ge = (s) => s.length !== 0 && !s.startsWith("."), qe = (s) => s.length !== 0 && s !== "." && s !== "..", Ve = /^\\?+([^+@!?\\*\\[\\(]*)?$/, Ye = ([s, t = ""]) => {
942
+ const e = It([s]);
831
943
  return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
832
- }, ke = ([s, t = ""]) => {
833
- const e = Ot([s]);
944
+ }, Ze = ([s, t = ""]) => {
945
+ const e = kt([s]);
834
946
  return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
835
- }, Le = ([s, t = ""]) => {
836
- const e = Ot([s]);
947
+ }, Xe = ([s, t = ""]) => {
948
+ const e = kt([s]);
837
949
  return t ? (n) => e(n) && n.endsWith(t) : e;
838
- }, ze = ([s, t = ""]) => {
839
- const e = Dt([s]);
950
+ }, Je = ([s, t = ""]) => {
951
+ const e = It([s]);
840
952
  return t ? (n) => e(n) && n.endsWith(t) : e;
841
- }, Dt = ([s]) => {
953
+ }, It = ([s]) => {
842
954
  const t = s.length;
843
955
  return (e) => e.length === t && !e.startsWith(".");
844
- }, Ot = ([s]) => {
956
+ }, kt = ([s]) => {
845
957
  const t = s.length;
846
958
  return (e) => e.length === t && e !== "." && e !== "..";
847
- }, $t = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", ht = {
959
+ }, Lt = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", mt = {
848
960
  win32: { sep: "\\\\" },
849
961
  posix: { sep: "/" }
850
- }, He = $t === "win32" ? ht.win32.sep : ht.posix.sep;
851
- y.sep = He;
852
- const v = Symbol("globstar **");
853
- y.GLOBSTAR = v;
854
- const We = "[^/]", _e = We + "*?", je = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", Ue = "(?:(?!(?:\\\\/|^)\\\\.).)*?", Be = (s, t = {}) => (e) => y(e, s, t);
855
- y.filter = Be;
856
- const b = (s, t = {}) => Object.assign({}, s, t), Ge = (s) => {
962
+ }, Qe = Lt === "win32" ? mt.win32.sep : mt.posix.sep;
963
+ y.sep = Qe;
964
+ const O = Symbol("globstar **");
965
+ y.GLOBSTAR = O;
966
+ const Ke = "[^/]", ts = Ke + "*?", es = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", ss = "(?:(?!(?:\\\\/|^)\\\\.).)*?", ns = (s, t = {}) => (e) => y(e, s, t);
967
+ y.filter = ns;
968
+ const b = (s, t = {}) => Object.assign({}, s, t), rs = (s) => {
857
969
  if (!s || typeof s != "object" || !Object.keys(s).length)
858
970
  return y;
859
971
  const t = y;
860
- return Object.assign((n, i, r = {}) => t(n, i, b(s, r)), {
972
+ return Object.assign((n, r, i = {}) => t(n, r, b(s, i)), {
861
973
  Minimatch: class extends t.Minimatch {
862
- constructor(i, r = {}) {
863
- super(i, b(s, r));
974
+ constructor(r, i = {}) {
975
+ super(r, b(s, i));
864
976
  }
865
- static defaults(i) {
866
- return t.defaults(b(s, i)).Minimatch;
977
+ static defaults(r) {
978
+ return t.defaults(b(s, r)).Minimatch;
867
979
  }
868
980
  },
869
981
  AST: class extends t.AST {
870
982
  /* c8 ignore start */
871
- constructor(i, r, o = {}) {
872
- super(i, r, b(s, o));
983
+ constructor(r, i, o = {}) {
984
+ super(r, i, b(s, o));
873
985
  }
874
986
  /* c8 ignore stop */
875
- static fromGlob(i, r = {}) {
876
- return t.AST.fromGlob(i, b(s, r));
987
+ static fromGlob(r, i = {}) {
988
+ return t.AST.fromGlob(r, b(s, i));
877
989
  }
878
990
  },
879
- unescape: (n, i = {}) => t.unescape(n, b(s, i)),
880
- escape: (n, i = {}) => t.escape(n, b(s, i)),
881
- filter: (n, i = {}) => t.filter(n, b(s, i)),
991
+ unescape: (n, r = {}) => t.unescape(n, b(s, r)),
992
+ escape: (n, r = {}) => t.escape(n, b(s, r)),
993
+ filter: (n, r = {}) => t.filter(n, b(s, r)),
882
994
  defaults: (n) => t.defaults(b(s, n)),
883
- makeRe: (n, i = {}) => t.makeRe(n, b(s, i)),
884
- braceExpand: (n, i = {}) => t.braceExpand(n, b(s, i)),
885
- match: (n, i, r = {}) => t.match(n, i, b(s, r)),
995
+ makeRe: (n, r = {}) => t.makeRe(n, b(s, r)),
996
+ braceExpand: (n, r = {}) => t.braceExpand(n, b(s, r)),
997
+ match: (n, r, i = {}) => t.match(n, r, b(s, i)),
886
998
  sep: t.sep,
887
- GLOBSTAR: v
999
+ GLOBSTAR: O
888
1000
  });
889
1001
  };
890
- y.defaults = Ge;
891
- const Ct = (s, t = {}) => (G(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : re(s));
892
- y.braceExpand = Ct;
893
- const qe = (s, t = {}) => new q(s, t).makeRe();
894
- y.makeRe = qe;
895
- const Ve = (s, t, e = {}) => {
896
- const n = new q(t, e);
897
- return s = s.filter((i) => n.match(i)), n.options.nonull && !s.length && s.push(t), s;
1002
+ y.defaults = rs;
1003
+ const zt = (s, t = {}) => (Z(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : ye(s));
1004
+ y.braceExpand = zt;
1005
+ const is = (s, t = {}) => new X(s, t).makeRe();
1006
+ y.makeRe = is;
1007
+ const os = (s, t, e = {}) => {
1008
+ const n = new X(t, e);
1009
+ return s = s.filter((r) => n.match(r)), n.options.nonull && !s.length && s.push(t), s;
898
1010
  };
899
- y.match = Ve;
900
- const ut = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, Xe = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
901
- class q {
1011
+ y.match = os;
1012
+ const yt = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, as = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
1013
+ class X {
902
1014
  options;
903
1015
  set;
904
1016
  pattern;
@@ -917,7 +1029,7 @@ class q {
917
1029
  windowsNoMagicRoot;
918
1030
  regexp;
919
1031
  constructor(t, e = {}) {
920
- G(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || $t, 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();
1032
+ Z(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || Lt, 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();
921
1033
  }
922
1034
  hasMagic() {
923
1035
  if (this.options.magicalBraces && this.set.length > 1)
@@ -940,23 +1052,23 @@ class q {
940
1052
  this.empty = !0;
941
1053
  return;
942
1054
  }
943
- this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...r) => console.error(...r)), this.debug(this.pattern, this.globSet);
944
- const n = this.globSet.map((r) => this.slashSplit(r));
1055
+ this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...i) => console.error(...i)), this.debug(this.pattern, this.globSet);
1056
+ const n = this.globSet.map((i) => this.slashSplit(i));
945
1057
  this.globParts = this.preprocess(n), this.debug(this.pattern, this.globParts);
946
- let i = this.globParts.map((r, o, a) => {
1058
+ let r = this.globParts.map((i, o, a) => {
947
1059
  if (this.isWindows && this.windowsNoMagicRoot) {
948
- const l = r[0] === "" && r[1] === "" && (r[2] === "?" || !ut.test(r[2])) && !ut.test(r[3]), h = /^[a-z]:/i.test(r[0]);
1060
+ const l = i[0] === "" && i[1] === "" && (i[2] === "?" || !yt.test(i[2])) && !yt.test(i[3]), h = /^[a-z]:/i.test(i[0]);
949
1061
  if (l)
950
- return [...r.slice(0, 4), ...r.slice(4).map((c) => this.parse(c))];
1062
+ return [...i.slice(0, 4), ...i.slice(4).map((c) => this.parse(c))];
951
1063
  if (h)
952
- return [r[0], ...r.slice(1).map((c) => this.parse(c))];
1064
+ return [i[0], ...i.slice(1).map((c) => this.parse(c))];
953
1065
  }
954
- return r.map((l) => this.parse(l));
1066
+ return i.map((l) => this.parse(l));
955
1067
  });
956
- if (this.debug(this.pattern, i), this.set = i.filter((r) => r.indexOf(!1) === -1), this.isWindows)
957
- for (let r = 0; r < this.set.length; r++) {
958
- const o = this.set[r];
959
- o[0] === "" && o[1] === "" && this.globParts[r][2] === "?" && typeof o[3] == "string" && /^[a-z]:$/i.test(o[3]) && (o[2] = "?");
1068
+ if (this.debug(this.pattern, r), this.set = r.filter((i) => i.indexOf(!1) === -1), this.isWindows)
1069
+ for (let i = 0; i < this.set.length; i++) {
1070
+ const o = this.set[i];
1071
+ o[0] === "" && o[1] === "" && this.globParts[i][2] === "?" && typeof o[3] == "string" && /^[a-z]:$/i.test(o[3]) && (o[2] = "?");
960
1072
  }
961
1073
  this.debug(this.pattern, this.set);
962
1074
  }
@@ -968,8 +1080,8 @@ class q {
968
1080
  preprocess(t) {
969
1081
  if (this.options.noglobstar)
970
1082
  for (let n = 0; n < t.length; n++)
971
- for (let i = 0; i < t[n].length; i++)
972
- t[n][i] === "**" && (t[n][i] = "*");
1083
+ for (let r = 0; r < t[n].length; r++)
1084
+ t[n][r] === "**" && (t[n][r] = "*");
973
1085
  const { optimizationLevel: e = 1 } = this.options;
974
1086
  return e >= 2 ? (t = this.firstPhasePreProcess(t), t = this.secondPhasePreProcess(t)) : e >= 1 ? t = this.levelOneOptimize(t) : t = this.adjascentGlobstarOptimize(t), t;
975
1087
  }
@@ -978,19 +1090,19 @@ class q {
978
1090
  return t.map((e) => {
979
1091
  let n = -1;
980
1092
  for (; (n = e.indexOf("**", n + 1)) !== -1; ) {
981
- let i = n;
982
- for (; e[i + 1] === "**"; )
983
- i++;
984
- i !== n && e.splice(n, i - n);
1093
+ let r = n;
1094
+ for (; e[r + 1] === "**"; )
1095
+ r++;
1096
+ r !== n && e.splice(n, r - n);
985
1097
  }
986
1098
  return e;
987
1099
  });
988
1100
  }
989
1101
  // get rid of adjascent ** and resolve .. portions
990
1102
  levelOneOptimize(t) {
991
- return t.map((e) => (e = e.reduce((n, i) => {
992
- const r = n[n.length - 1];
993
- return i === "**" && r === "**" ? n : i === ".." && r && r !== ".." && r !== "." && r !== "**" ? (n.pop(), n) : (n.push(i), n);
1103
+ return t.map((e) => (e = e.reduce((n, r) => {
1104
+ const i = n[n.length - 1];
1105
+ return r === "**" && i === "**" ? n : r === ".." && i && i !== ".." && i !== "." && i !== "**" ? (n.pop(), n) : (n.push(r), n);
994
1106
  }, []), e.length === 0 ? [""] : e));
995
1107
  }
996
1108
  levelTwoFileOptimize(t) {
@@ -998,16 +1110,16 @@ class q {
998
1110
  let e = !1;
999
1111
  do {
1000
1112
  if (e = !1, !this.preserveMultipleSlashes) {
1001
- for (let i = 1; i < t.length - 1; i++) {
1002
- const r = t[i];
1003
- i === 1 && r === "" && t[0] === "" || (r === "." || r === "") && (e = !0, t.splice(i, 1), i--);
1113
+ for (let r = 1; r < t.length - 1; r++) {
1114
+ const i = t[r];
1115
+ r === 1 && i === "" && t[0] === "" || (i === "." || i === "") && (e = !0, t.splice(r, 1), r--);
1004
1116
  }
1005
1117
  t[0] === "." && t.length === 2 && (t[1] === "." || t[1] === "") && (e = !0, t.pop());
1006
1118
  }
1007
1119
  let n = 0;
1008
1120
  for (; (n = t.indexOf("..", n + 1)) !== -1; ) {
1009
- const i = t[n - 1];
1010
- i && i !== "." && i !== ".." && i !== "**" && (e = !0, t.splice(n - 1, 2), n -= 2);
1121
+ const r = t[n - 1];
1122
+ r && r !== "." && r !== ".." && r !== "**" && (e = !0, t.splice(n - 1, 2), n -= 2);
1011
1123
  }
1012
1124
  } while (e);
1013
1125
  return t.length === 0 ? [""] : t;
@@ -1035,19 +1147,19 @@ class q {
1035
1147
  do {
1036
1148
  e = !1;
1037
1149
  for (let n of t) {
1038
- let i = -1;
1039
- for (; (i = n.indexOf("**", i + 1)) !== -1; ) {
1040
- let o = i;
1150
+ let r = -1;
1151
+ for (; (r = n.indexOf("**", r + 1)) !== -1; ) {
1152
+ let o = r;
1041
1153
  for (; n[o + 1] === "**"; )
1042
1154
  o++;
1043
- o > i && n.splice(i + 1, o - i);
1044
- let a = n[i + 1];
1045
- const l = n[i + 2], h = n[i + 3];
1155
+ o > r && n.splice(r + 1, o - r);
1156
+ let a = n[r + 1];
1157
+ const l = n[r + 2], h = n[r + 3];
1046
1158
  if (a !== ".." || !l || l === "." || l === ".." || !h || h === "." || h === "..")
1047
1159
  continue;
1048
- e = !0, n.splice(i, 1);
1160
+ e = !0, n.splice(r, 1);
1049
1161
  const c = n.slice(0);
1050
- c[i] = "**", t.push(c), i--;
1162
+ c[r] = "**", t.push(c), r--;
1051
1163
  }
1052
1164
  if (!this.preserveMultipleSlashes) {
1053
1165
  for (let o = 1; o < n.length - 1; o++) {
@@ -1056,13 +1168,13 @@ class q {
1056
1168
  }
1057
1169
  n[0] === "." && n.length === 2 && (n[1] === "." || n[1] === "") && (e = !0, n.pop());
1058
1170
  }
1059
- let r = 0;
1060
- for (; (r = n.indexOf("..", r + 1)) !== -1; ) {
1061
- const o = n[r - 1];
1171
+ let i = 0;
1172
+ for (; (i = n.indexOf("..", i + 1)) !== -1; ) {
1173
+ const o = n[i - 1];
1062
1174
  if (o && o !== "." && o !== ".." && o !== "**") {
1063
1175
  e = !0;
1064
- const l = r === 1 && n[r + 1] === "**" ? ["."] : [];
1065
- n.splice(r - 1, 2, ...l), n.length === 0 && n.push(""), r -= 2;
1176
+ const l = i === 1 && n[i + 1] === "**" ? ["."] : [];
1177
+ n.splice(i - 1, 2, ...l), n.length === 0 && n.push(""), i -= 2;
1066
1178
  }
1067
1179
  }
1068
1180
  }
@@ -1079,31 +1191,31 @@ class q {
1079
1191
  secondPhasePreProcess(t) {
1080
1192
  for (let e = 0; e < t.length - 1; e++)
1081
1193
  for (let n = e + 1; n < t.length; n++) {
1082
- const i = this.partsMatch(t[e], t[n], !this.preserveMultipleSlashes);
1083
- if (i) {
1084
- t[e] = [], t[n] = i;
1194
+ const r = this.partsMatch(t[e], t[n], !this.preserveMultipleSlashes);
1195
+ if (r) {
1196
+ t[e] = [], t[n] = r;
1085
1197
  break;
1086
1198
  }
1087
1199
  }
1088
1200
  return t.filter((e) => e.length);
1089
1201
  }
1090
1202
  partsMatch(t, e, n = !1) {
1091
- let i = 0, r = 0, o = [], a = "";
1092
- for (; i < t.length && r < e.length; )
1093
- if (t[i] === e[r])
1094
- o.push(a === "b" ? e[r] : t[i]), i++, r++;
1095
- else if (n && t[i] === "**" && e[r] === t[i + 1])
1096
- o.push(t[i]), i++;
1097
- else if (n && e[r] === "**" && t[i] === e[r + 1])
1098
- o.push(e[r]), r++;
1099
- else if (t[i] === "*" && e[r] && (this.options.dot || !e[r].startsWith(".")) && e[r] !== "**") {
1203
+ let r = 0, i = 0, o = [], a = "";
1204
+ for (; r < t.length && i < e.length; )
1205
+ if (t[r] === e[i])
1206
+ o.push(a === "b" ? e[i] : t[r]), r++, i++;
1207
+ else if (n && t[r] === "**" && e[i] === t[r + 1])
1208
+ o.push(t[r]), r++;
1209
+ else if (n && e[i] === "**" && t[r] === e[i + 1])
1210
+ o.push(e[i]), i++;
1211
+ else if (t[r] === "*" && e[i] && (this.options.dot || !e[i].startsWith(".")) && e[i] !== "**") {
1100
1212
  if (a === "b")
1101
1213
  return !1;
1102
- a = "a", o.push(t[i]), i++, r++;
1103
- } else if (e[r] === "*" && t[i] && (this.options.dot || !t[i].startsWith(".")) && t[i] !== "**") {
1214
+ a = "a", o.push(t[r]), r++, i++;
1215
+ } else if (e[i] === "*" && t[r] && (this.options.dot || !t[r].startsWith(".")) && t[r] !== "**") {
1104
1216
  if (a === "a")
1105
1217
  return !1;
1106
- a = "b", o.push(e[r]), i++, r++;
1218
+ a = "b", o.push(e[i]), r++, i++;
1107
1219
  } else
1108
1220
  return !1;
1109
1221
  return t.length === e.length && o;
@@ -1113,7 +1225,7 @@ class q {
1113
1225
  return;
1114
1226
  const t = this.pattern;
1115
1227
  let e = !1, n = 0;
1116
- for (let i = 0; i < t.length && t.charAt(i) === "!"; i++)
1228
+ for (let r = 0; r < t.length && t.charAt(r) === "!"; r++)
1117
1229
  e = !e, n++;
1118
1230
  n && (this.pattern = t.slice(n)), this.negate = e;
1119
1231
  }
@@ -1123,36 +1235,36 @@ class q {
1123
1235
  // out of pattern, then that's fine, as long as all
1124
1236
  // the parts match.
1125
1237
  matchOne(t, e, n = !1) {
1126
- const i = this.options;
1238
+ const r = this.options;
1127
1239
  if (this.isWindows) {
1128
- const g = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), S = !g && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), F = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), $ = !F && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : g ? 0 : void 0, m = $ ? 3 : F ? 0 : void 0;
1240
+ 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]), v = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), P = !v && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : p ? 0 : void 0, m = P ? 3 : v ? 0 : void 0;
1129
1241
  if (typeof x == "number" && typeof m == "number") {
1130
- const [C, R] = [t[x], e[m]];
1131
- C.toLowerCase() === R.toLowerCase() && (e[m] = C, m > x ? e = e.slice(m) : x > m && (t = t.slice(x)));
1242
+ const [T, H] = [t[x], e[m]];
1243
+ T.toLowerCase() === H.toLowerCase() && (e[m] = T, m > x ? e = e.slice(m) : x > m && (t = t.slice(x)));
1132
1244
  }
1133
1245
  }
1134
- const { optimizationLevel: r = 1 } = this.options;
1135
- r >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.length);
1246
+ const { optimizationLevel: i = 1 } = this.options;
1247
+ i >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.length);
1136
1248
  for (var o = 0, a = 0, l = t.length, h = e.length; o < l && a < h; o++, a++) {
1137
1249
  this.debug("matchOne loop");
1138
1250
  var c = e[a], f = t[o];
1139
1251
  if (this.debug(e, c, f), c === !1)
1140
1252
  return !1;
1141
- if (c === v) {
1253
+ if (c === O) {
1142
1254
  this.debug("GLOBSTAR", [e, c, f]);
1143
1255
  var u = o, d = a + 1;
1144
1256
  if (d === h) {
1145
1257
  for (this.debug("** at the end"); o < l; o++)
1146
- if (t[o] === "." || t[o] === ".." || !i.dot && t[o].charAt(0) === ".")
1258
+ if (t[o] === "." || t[o] === ".." || !r.dot && t[o].charAt(0) === ".")
1147
1259
  return !1;
1148
1260
  return !0;
1149
1261
  }
1150
1262
  for (; u < l; ) {
1151
- var w = t[u];
1263
+ var g = t[u];
1152
1264
  if (this.debug(\`
1153
- globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
1154
- return this.debug("globstar found match!", u, l, w), !0;
1155
- if (w === "." || w === ".." || !i.dot && w.charAt(0) === ".") {
1265
+ globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
1266
+ return this.debug("globstar found match!", u, l, g), !0;
1267
+ if (g === "." || g === ".." || !r.dot && g.charAt(0) === ".") {
1156
1268
  this.debug("dot detected!", t, u, e, d);
1157
1269
  break;
1158
1270
  }
@@ -1161,8 +1273,8 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
1161
1273
  return !!(n && (this.debug(\`
1162
1274
  >>> no match, partial?\`, t, u, e, d), u === l));
1163
1275
  }
1164
- let g;
1165
- if (typeof c == "string" ? (g = f === c, this.debug("string match", c, f, g)) : (g = c.test(f), this.debug("pattern match", c, f, g)), !g)
1276
+ let p;
1277
+ if (typeof c == "string" ? (p = f === c, this.debug("string match", c, f, p)) : (p = c.test(f), this.debug("pattern match", c, f, p)), !p)
1166
1278
  return !1;
1167
1279
  }
1168
1280
  if (o === l && a === h)
@@ -1174,19 +1286,19 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
1174
1286
  throw new Error("wtf?");
1175
1287
  }
1176
1288
  braceExpand() {
1177
- return Ct(this.pattern, this.options);
1289
+ return zt(this.pattern, this.options);
1178
1290
  }
1179
1291
  parse(t) {
1180
- G(t);
1292
+ Z(t);
1181
1293
  const e = this.options;
1182
1294
  if (t === "**")
1183
- return v;
1295
+ return O;
1184
1296
  if (t === "")
1185
1297
  return "";
1186
- let n, i = null;
1187
- (n = t.match(Me)) ? i = e.dot ? Pe : Ie : (n = t.match(xe)) ? i = (e.nocase ? e.dot ? Fe : Ae : e.dot ? ve : be)(n[1]) : (n = t.match(Te)) ? i = (e.nocase ? e.dot ? ke : Re : e.dot ? Le : ze)(n) : (n = t.match(Ne)) ? i = e.dot ? Oe : De : (n = t.match($e)) && (i = Ce);
1188
- const r = E.fromGlob(t, this.options).toMMPattern();
1189
- return i && typeof r == "object" && Reflect.defineProperty(r, "test", { value: i }), r;
1298
+ let n, r = null;
1299
+ (n = t.match(Be)) ? r = e.dot ? qe : Ge : (n = t.match(Re)) ? r = (e.nocase ? e.dot ? ze : Le : e.dot ? ke : Ie)(n[1]) : (n = t.match(Ve)) ? r = (e.nocase ? e.dot ? Ze : Ye : e.dot ? Xe : Je)(n) : (n = t.match(He)) ? r = e.dot ? je : We : (n = t.match(_e)) && (r = Ue);
1300
+ const i = E.fromGlob(t, this.options).toMMPattern();
1301
+ return r && typeof i == "object" && Reflect.defineProperty(i, "test", { value: r }), i;
1190
1302
  }
1191
1303
  makeRe() {
1192
1304
  if (this.regexp || this.regexp === !1)
@@ -1194,23 +1306,23 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
1194
1306
  const t = this.set;
1195
1307
  if (!t.length)
1196
1308
  return this.regexp = !1, this.regexp;
1197
- const e = this.options, n = e.noglobstar ? _e : e.dot ? je : Ue, i = new Set(e.nocase ? ["i"] : []);
1198
- let r = t.map((l) => {
1309
+ const e = this.options, n = e.noglobstar ? ts : e.dot ? es : ss, r = new Set(e.nocase ? ["i"] : []);
1310
+ let i = t.map((l) => {
1199
1311
  const h = l.map((c) => {
1200
1312
  if (c instanceof RegExp)
1201
1313
  for (const f of c.flags.split(""))
1202
- i.add(f);
1203
- return typeof c == "string" ? Xe(c) : c === v ? v : c._src;
1314
+ r.add(f);
1315
+ return typeof c == "string" ? as(c) : c === O ? O : c._src;
1204
1316
  });
1205
1317
  return h.forEach((c, f) => {
1206
1318
  const u = h[f + 1], d = h[f - 1];
1207
- c !== v || d === v || (d === void 0 ? u !== void 0 && u !== v ? h[f + 1] = "(?:\\\\/|" + n + "\\\\/)?" + u : h[f] = n : u === void 0 ? h[f - 1] = d + "(?:\\\\/|" + n + ")?" : u !== v && (h[f - 1] = d + "(?:\\\\/|\\\\/" + n + "\\\\/)" + u, h[f + 1] = v));
1208
- }), h.filter((c) => c !== v).join("/");
1319
+ c !== O || d === O || (d === void 0 ? u !== void 0 && u !== O ? h[f + 1] = "(?:\\\\/|" + n + "\\\\/)?" + u : h[f] = n : u === void 0 ? h[f - 1] = d + "(?:\\\\/|" + n + ")?" : u !== O && (h[f - 1] = d + "(?:\\\\/|\\\\/" + n + "\\\\/)" + u, h[f + 1] = O));
1320
+ }), h.filter((c) => c !== O).join("/");
1209
1321
  }).join("|");
1210
1322
  const [o, a] = t.length > 1 ? ["(?:", ")"] : ["", ""];
1211
- r = "^" + o + r + a + "$", this.negate && (r = "^(?!" + r + ").+$");
1323
+ i = "^" + o + i + a + "$", this.negate && (i = "^(?!" + i + ").+$");
1212
1324
  try {
1213
- this.regexp = new RegExp(r, [...i].join(""));
1325
+ this.regexp = new RegExp(i, [...r].join(""));
1214
1326
  } catch {
1215
1327
  this.regexp = !1;
1216
1328
  }
@@ -1228,17 +1340,17 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
1228
1340
  return !0;
1229
1341
  const n = this.options;
1230
1342
  this.isWindows && (t = t.split("\\\\").join("/"));
1231
- const i = this.slashSplit(t);
1232
- this.debug(this.pattern, "split", i);
1233
- const r = this.set;
1234
- this.debug(this.pattern, "set", r);
1235
- let o = i[i.length - 1];
1343
+ const r = this.slashSplit(t);
1344
+ this.debug(this.pattern, "split", r);
1345
+ const i = this.set;
1346
+ this.debug(this.pattern, "set", i);
1347
+ let o = r[r.length - 1];
1236
1348
  if (!o)
1237
- for (let a = i.length - 2; !o && a >= 0; a--)
1238
- o = i[a];
1239
- for (let a = 0; a < r.length; a++) {
1240
- const l = r[a];
1241
- let h = i;
1349
+ for (let a = r.length - 2; !o && a >= 0; a--)
1350
+ o = r[a];
1351
+ for (let a = 0; a < i.length; a++) {
1352
+ const l = i[a];
1353
+ let h = r;
1242
1354
  if (n.matchBase && l.length === 1 && (h = [o]), this.matchOne(h, l, e))
1243
1355
  return n.flipNegate ? !0 : !this.negate;
1244
1356
  }
@@ -1249,109 +1361,109 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
1249
1361
  }
1250
1362
  }
1251
1363
  y.AST = E;
1252
- y.Minimatch = q;
1253
- y.escape = Se;
1254
- y.unescape = P;
1255
- function Ye() {
1364
+ y.Minimatch = X;
1365
+ y.escape = Te;
1366
+ y.unescape = k;
1367
+ function cs() {
1256
1368
  if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
1257
- throw new Ut();
1369
+ throw new Qt();
1258
1370
  }
1259
- async function T(s, t, e) {
1371
+ async function L(s, t, e) {
1260
1372
  return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${s.replace(/\\/+/g, "/")}\`, { mode: t }, e) : e();
1261
1373
  }
1262
- function O(s) {
1374
+ function M(s) {
1263
1375
  return Array.isArray(s) ? s : (s.startsWith("~/") ? s.slice(2) : s).split("/").filter(Boolean);
1264
1376
  }
1265
- function st(s) {
1377
+ function lt(s) {
1266
1378
  return typeof s == "string" ? s ?? "/" : \`/\${s.join("/")}\`;
1267
1379
  }
1268
- function K(s) {
1269
- const t = O(s);
1380
+ function it(s) {
1381
+ const t = M(s);
1270
1382
  return t[t.length - 1] || "";
1271
1383
  }
1272
- function Y(s) {
1273
- const t = O(s);
1274
- return t.pop(), st(t);
1384
+ function et(s) {
1385
+ const t = M(s);
1386
+ return t.pop(), lt(t);
1275
1387
  }
1276
- function _(s) {
1388
+ function G(s) {
1277
1389
  return !s || s === "/" ? "/" : s.startsWith("~/") ? \`/\${s.slice(2)}\` : s.startsWith("/") ? s : \`/\${s}\`;
1278
1390
  }
1279
- function Ze(s, t = !1) {
1391
+ function ls(s, t = !1) {
1280
1392
  return s = s.replace(/\\/$/, ""), t && !s.includes("*") ? \`\${s}/**\` : s;
1281
1393
  }
1282
- function Z(s, t) {
1394
+ function st(s, t) {
1283
1395
  return y(s, t, {
1284
1396
  dot: !0,
1285
1397
  matchBase: !0
1286
1398
  });
1287
1399
  }
1288
- function ft(s) {
1289
- const t = _(s), e = O(t), n = [];
1290
- for (const i of e)
1291
- if (!(i === "." || i === ""))
1292
- if (i === "..") {
1400
+ function Et(s) {
1401
+ const t = G(s), e = M(t), n = [];
1402
+ for (const r of e)
1403
+ if (!(r === "." || r === ""))
1404
+ if (r === "..") {
1293
1405
  if (n.length === 0)
1294
1406
  continue;
1295
1407
  n.pop();
1296
1408
  } else
1297
- n.push(i);
1298
- return st(n);
1409
+ n.push(r);
1410
+ return lt(n);
1299
1411
  }
1300
- async function Je(s, t = "SHA-1", e = 50 * 1024 * 1024) {
1412
+ async function hs(s, t = "SHA-1", e = 50 * 1024 * 1024) {
1301
1413
  if (s instanceof File && (s = await s.arrayBuffer()), s.byteLength > e)
1302
1414
  throw new Error(\`File size \${s.byteLength} bytes exceeds maximum allowed size \${e} bytes\`);
1303
- const n = new Uint8Array(s), i = await crypto.subtle.digest(t, n);
1304
- return Array.from(new Uint8Array(i)).map((o) => o.toString(16).padStart(2, "0")).join("");
1415
+ const n = new Uint8Array(s), r = await crypto.subtle.digest(t, n);
1416
+ return Array.from(new Uint8Array(r)).map((o) => o.toString(16).padStart(2, "0")).join("");
1305
1417
  }
1306
- async function Ke(s) {
1418
+ async function us(s) {
1307
1419
  const t = await s.arrayBuffer();
1308
1420
  return new Uint8Array(t);
1309
1421
  }
1310
- async function Qe(s, t, e = {}) {
1311
- const n = K(t);
1312
- return T(t, "exclusive", async () => {
1313
- const i = e.recursive ?? !1, r = e.force ?? !1;
1422
+ async function fs(s, t, e = {}) {
1423
+ const n = it(t);
1424
+ return L(t, "exclusive", async () => {
1425
+ const r = e.recursive ?? !1, i = e.force ?? !1;
1314
1426
  try {
1315
- await s.removeEntry(n, { recursive: i });
1427
+ await s.removeEntry(n, { recursive: r });
1316
1428
  } catch (o) {
1317
1429
  if (o.name === "NotFoundError") {
1318
- if (!r)
1319
- throw new p(\`No such file or directory: \${t}\`, "ENOENT", void 0, o);
1320
- } else throw o.name === "InvalidModificationError" ? new p(\`Directory not empty: \${t}. Use recursive option to force removal.\`, "ENOTEMPTY", void 0, o) : o.name === "TypeMismatchError" && !i ? new p(\`Cannot remove directory without recursive option: \${t}\`, "EISDIR", void 0, o) : new p(\`Failed to remove entry: \${t}\`, "RM_FAILED", void 0, o);
1430
+ if (!i)
1431
+ throw new F("file", t, o);
1432
+ } else throw o.name === "InvalidModificationError" ? new rt("ENOTEMPTY", t, o) : o.name === "TypeMismatchError" && !r ? new z("directory", t, o) : new rt("RM_FAILED", t, o);
1321
1433
  }
1322
1434
  });
1323
1435
  }
1324
- function dt(s, t, e, n) {
1436
+ function St(s, t, e, n) {
1325
1437
  if (!Number.isInteger(t) || !Number.isInteger(e))
1326
- throw new p("Invalid offset or length", "EINVAL");
1438
+ throw new N("argument", "Invalid offset or length");
1327
1439
  if (t < 0 || e < 0)
1328
- throw new p("Negative offset or length not allowed", "EINVAL");
1440
+ throw new N("argument", "Negative offset or length not allowed");
1329
1441
  if (t + e > s)
1330
- throw new p("Operation would overflow buffer", "ERANGE");
1442
+ throw new N("overflow", "Operation would overflow buffer");
1331
1443
  if (n != null && (!Number.isInteger(n) || n < 0))
1332
- throw new p("Invalid position", "EINVAL");
1444
+ throw new N("argument", "Invalid position");
1333
1445
  }
1334
- function pt(s, t, e) {
1446
+ function xt(s, t, e) {
1335
1447
  try {
1336
1448
  t.flush(), t.close();
1337
1449
  } catch (n) {
1338
1450
  console.warn(\`Warning: Failed to properly close file descriptor \${s} (\${e}):\`, n);
1339
1451
  }
1340
1452
  }
1341
- function ts(s, t, e) {
1453
+ function ds(s, t, e) {
1342
1454
  if (s >= e)
1343
1455
  return { isEOF: !0, actualLength: 0 };
1344
1456
  const n = Math.min(t, e - s);
1345
1457
  return n <= 0 ? { isEOF: !0, actualLength: 0 } : { isEOF: !1, actualLength: n };
1346
1458
  }
1347
- async function es(s, t) {
1459
+ async function ps(s, t) {
1348
1460
  try {
1349
1461
  return await s.createSyncAccessHandle();
1350
1462
  } catch (e) {
1351
- throw Gt(e, { path: t });
1463
+ throw A(e, { path: t, isDirectory: !1 });
1352
1464
  }
1353
1465
  }
1354
- class ss {
1466
+ class gs {
1355
1467
  /** Root directory handle for the file system */
1356
1468
  root;
1357
1469
  /** Map of watched paths and options */
@@ -1379,7 +1491,7 @@ class ss {
1379
1491
  _getFileDescriptor(t) {
1380
1492
  const e = this.openFiles.get(t);
1381
1493
  if (!e)
1382
- throw new p(\`Invalid file descriptor: \${t}\`, "EBADF");
1494
+ throw new N("descriptor", \`Invalid file descriptor: \${t}\`);
1383
1495
  return e;
1384
1496
  }
1385
1497
  /**
@@ -1395,25 +1507,25 @@ class ss {
1395
1507
  if (!this.options.broadcastChannel)
1396
1508
  return;
1397
1509
  const e = t.path;
1398
- if (![...this.watchers.values()].some((r) => Z(e, r.pattern) && r.include.some((o) => o && Z(e, o)) && !r.exclude.some((o) => o && Z(e, o))))
1510
+ if (![...this.watchers.values()].some((i) => st(e, i.pattern) && i.include.some((o) => o && st(e, o)) && !i.exclude.some((o) => o && st(e, o))))
1399
1511
  return;
1400
- let i;
1512
+ let r;
1401
1513
  if (this.options.hashAlgorithm)
1402
1514
  try {
1403
- i = (await this.stat(e)).hash;
1515
+ r = (await this.stat(e)).hash;
1404
1516
  } catch {
1405
1517
  }
1406
1518
  try {
1407
1519
  this.broadcastChannel || (this.broadcastChannel = new BroadcastChannel(this.options.broadcastChannel));
1408
- const r = {
1520
+ const i = {
1409
1521
  namespace: this.options.namespace,
1410
1522
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1411
1523
  ...t,
1412
- ...i && { hash: i }
1524
+ ...r && { hash: r }
1413
1525
  };
1414
- this.broadcastChannel.postMessage(r);
1415
- } catch (r) {
1416
- console.warn("Failed to send event via BroadcastChannel:", r);
1526
+ this.broadcastChannel.postMessage(i);
1527
+ } catch (i) {
1528
+ console.warn("Failed to send event via BroadcastChannel:", i);
1417
1529
  }
1418
1530
  }
1419
1531
  /**
@@ -1427,7 +1539,7 @@ class ss {
1427
1539
  * @throws {OPFSError} If OPFS is not supported in the current browser
1428
1540
  */
1429
1541
  constructor(t) {
1430
- Ye(), t && this.setOptions(t);
1542
+ cs(), t && this.setOptions(t);
1431
1543
  }
1432
1544
  /**
1433
1545
  * Initialize the file system within a given directory
@@ -1454,10 +1566,10 @@ class ss {
1454
1566
  const t = this.options.root;
1455
1567
  return this.mountingPromise && await this.mountingPromise, this.mountingPromise = new Promise(async (e, n) => {
1456
1568
  try {
1457
- const i = await navigator.storage.getDirectory();
1458
- this.root = t === "/" ? i : await this.getDirectoryHandle(t, !0, i), e(!0);
1459
- } catch (i) {
1460
- n(new p("Failed to initialize OPFS", "INIT_FAILED", t, i));
1569
+ const r = await navigator.storage.getDirectory();
1570
+ this.root = t === "/" ? r : await this.getDirectoryHandle(t, !0, r), e(!0);
1571
+ } catch (r) {
1572
+ n(new re(t, r));
1461
1573
  } finally {
1462
1574
  this.mountingPromise = null;
1463
1575
  }
@@ -1474,7 +1586,7 @@ class ss {
1474
1586
  * @param options.broadcastChannel - Custom name for the broadcast channel
1475
1587
  */
1476
1588
  async setOptions(t) {
1477
- 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.root), this.options.namespace || (this.options.namespace = \`opfs-worker:\${this.options.root}\`), await this.mount());
1589
+ 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 = G(t.root), this.options.namespace || (this.options.namespace = \`opfs-worker:\${this.options.root}\`), await this.mount());
1478
1590
  }
1479
1591
  /**
1480
1592
  * Get a directory handle from a path
@@ -1495,11 +1607,11 @@ class ss {
1495
1607
  * \`\`\`
1496
1608
  */
1497
1609
  async getDirectoryHandle(t, e = !1, n = this.root) {
1498
- const i = Array.isArray(t) ? t : O(t);
1499
- let r = n;
1500
- for (const o of i)
1501
- r = await r.getDirectoryHandle(o, { create: e });
1502
- return r;
1610
+ const r = Array.isArray(t) ? t : M(t);
1611
+ let i = n;
1612
+ for (const o of r)
1613
+ i = await i.getDirectoryHandle(o, { create: e });
1614
+ return i;
1503
1615
  }
1504
1616
  /**
1505
1617
  * Get a file handle from a path
@@ -1521,11 +1633,11 @@ class ss {
1521
1633
  * \`\`\`
1522
1634
  */
1523
1635
  async getFileHandle(t, e = !1, n = this.root) {
1524
- const i = O(t);
1525
- if (i.length === 0)
1526
- throw new Bt("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
1527
- const r = i.pop();
1528
- return (await this.getDirectoryHandle(i, e, n)).getFileHandle(r, { create: e });
1636
+ const r = M(t);
1637
+ if (r.length === 0)
1638
+ throw new Kt("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
1639
+ const i = r.pop();
1640
+ return (await this.getDirectoryHandle(r, e, n)).getFileHandle(i, { create: e });
1529
1641
  }
1530
1642
  /**
1531
1643
  * Get a complete index of all files and directories in the file system
@@ -1548,9 +1660,9 @@ class ss {
1548
1660
  */
1549
1661
  async index() {
1550
1662
  const t = /* @__PURE__ */ new Map(), e = async (n) => {
1551
- const i = await this.readDir(n);
1552
- for (const r of i) {
1553
- const o = \`\${n === "/" ? "" : n}/\${r.name}\`;
1663
+ const r = await this.readDir(n);
1664
+ for (const i of r) {
1665
+ const o = \`\${n === "/" ? "" : n}/\${i.name}\`;
1554
1666
  try {
1555
1667
  const a = await this.stat(o);
1556
1668
  t.set(o, a), a.isDirectory && await e(o);
@@ -1590,17 +1702,17 @@ class ss {
1590
1702
  async readFile(t) {
1591
1703
  await this.mount();
1592
1704
  try {
1593
- return await T(t, "shared", async () => {
1705
+ return await L(t, "shared", async () => {
1594
1706
  const e = await this.open(t);
1595
1707
  try {
1596
- const { size: n } = await this.fstat(e), i = new Uint8Array(n);
1597
- return n > 0 && await this.read(e, i, 0, n, 0), W(i, [i.buffer]);
1708
+ const { size: n } = await this.fstat(e), r = new Uint8Array(n);
1709
+ return n > 0 && await this.read(e, r, 0, n, 0), B(r, [r.buffer]);
1598
1710
  } finally {
1599
1711
  await this.close(e);
1600
1712
  }
1601
1713
  });
1602
1714
  } catch (e) {
1603
- throw new it(t, e);
1715
+ throw new F("file", t, e);
1604
1716
  }
1605
1717
  }
1606
1718
  /**
@@ -1628,14 +1740,14 @@ class ss {
1628
1740
  async writeFile(t, e) {
1629
1741
  await this.mount();
1630
1742
  const n = e instanceof Uint8Array ? e : new Uint8Array(e);
1631
- await T(t, "exclusive", async () => {
1632
- const i = await this.exists(t), r = await this.open(t, { create: !0, truncate: !0 });
1743
+ await L(t, "exclusive", async () => {
1744
+ const r = await this.exists(t), i = await this.open(t, { create: !0, truncate: !0 });
1633
1745
  try {
1634
- await this.write(r, n, 0, n.length, null, !1), await this.fsync(r);
1746
+ await this.write(i, n, 0, n.length, null, !1), await this.fsync(i);
1635
1747
  } finally {
1636
- await this.close(r);
1748
+ await this.close(i);
1637
1749
  }
1638
- await this.notifyChange({ path: t, type: i ? A.Changed : A.Added, isDirectory: !1 });
1750
+ await this.notifyChange({ path: t, type: r ? D.Changed : D.Added, isDirectory: !1 });
1639
1751
  });
1640
1752
  }
1641
1753
  /**
@@ -1663,15 +1775,15 @@ class ss {
1663
1775
  async appendFile(t, e) {
1664
1776
  await this.mount();
1665
1777
  const n = e instanceof Uint8Array ? e : new Uint8Array(e);
1666
- await T(t, "exclusive", async () => {
1667
- const i = await this.open(t, { create: !0 });
1778
+ await L(t, "exclusive", async () => {
1779
+ const r = await this.open(t, { create: !0 });
1668
1780
  try {
1669
- const { size: r } = await this.fstat(i);
1670
- await this.write(i, n, 0, n.length, r, !1), await this.fsync(i);
1781
+ const { size: i } = await this.fstat(r);
1782
+ await this.write(r, n, 0, n.length, i, !1), await this.fsync(r);
1671
1783
  } finally {
1672
- await this.close(i);
1784
+ await this.close(r);
1673
1785
  }
1674
- await this.notifyChange({ path: t, type: A.Changed, isDirectory: !1 });
1786
+ await this.notifyChange({ path: t, type: D.Changed, isDirectory: !1 });
1675
1787
  });
1676
1788
  }
1677
1789
  /**
@@ -1697,22 +1809,17 @@ class ss {
1697
1809
  */
1698
1810
  async mkdir(t, e) {
1699
1811
  await this.mount();
1700
- const n = e?.recursive ?? !1, i = O(t);
1701
- let r = this.root;
1702
- for (let o = 0; o < i.length; o++) {
1703
- const a = i[o];
1812
+ const n = e?.recursive ?? !1, r = M(t);
1813
+ let i = this.root;
1814
+ for (let o = 0; o < r.length; o++) {
1815
+ const a = r[o];
1704
1816
  try {
1705
- r = await r.getDirectoryHandle(a, { create: n || o === i.length - 1 });
1817
+ i = await i.getDirectoryHandle(a, { create: n || o === r.length - 1 });
1706
1818
  } catch (l) {
1707
- throw l.name === "NotFoundError" ? new p(
1708
- \`Parent directory does not exist: \${st(i.slice(0, o + 1))}\`,
1709
- "ENOENT",
1710
- void 0,
1711
- l
1712
- ) : l.name === "TypeMismatchError" ? new p(\`Path segment is not a directory: \${a}\`, "ENOTDIR", void 0, l) : new p("Failed to create directory", "MKDIR_FAILED", void 0, l);
1819
+ throw l.name === "NotFoundError" ? new F("directory", lt(r.slice(0, o + 1)), l) : l.name === "TypeMismatchError" ? new z("file", a, l) : new Q("create directory", a, l);
1713
1820
  }
1714
1821
  }
1715
- await this.notifyChange({ path: t, type: A.Added, isDirectory: !0 });
1822
+ await this.notifyChange({ path: t, type: D.Added, isDirectory: !0 });
1716
1823
  }
1717
1824
  /**
1718
1825
  * Get file or directory statistics
@@ -1746,9 +1853,11 @@ class ss {
1746
1853
  isFile: !1,
1747
1854
  isDirectory: !0
1748
1855
  };
1749
- const e = K(t), n = await this.getDirectoryHandle(Y(t), !1), i = this.options.hashAlgorithm;
1856
+ const e = it(t);
1857
+ let n;
1750
1858
  try {
1751
- const o = await (await n.getFileHandle(e, { create: !1 })).getFile(), a = {
1859
+ n = await this.getDirectoryHandle(et(t), !1);
1860
+ const r = this.options.hashAlgorithm, o = await (await n.getFileHandle(e, { create: !1 })).getFile(), a = {
1752
1861
  kind: "file",
1753
1862
  size: o.size,
1754
1863
  mtime: new Date(o.lastModified).toISOString(),
@@ -1756,19 +1865,21 @@ class ss {
1756
1865
  isFile: !0,
1757
1866
  isDirectory: !1
1758
1867
  };
1759
- if (i === "etag")
1868
+ if (r === "etag")
1760
1869
  a.hash = \`\${o.lastModified.toString(36)}-\${o.size.toString(36)}\`;
1761
- else if (typeof i == "string")
1870
+ else if (typeof r == "string")
1762
1871
  try {
1763
- const l = await Je(o, i, this.options.maxFileSize);
1872
+ const l = await hs(o, r, this.options.maxFileSize);
1764
1873
  a.hash = l;
1765
1874
  } catch (l) {
1766
1875
  console.warn(\`Failed to calculate hash for \${t}:\`, l);
1767
1876
  }
1768
1877
  return a;
1769
1878
  } catch (r) {
1770
- if (r.name !== "TypeMismatchError" && r.name !== "NotFoundError")
1771
- throw new p("Failed to stat (file)", "STAT_FAILED", void 0, r);
1879
+ if (r.name === "NotFoundError")
1880
+ throw new F("file", t, r);
1881
+ if (r.name !== "TypeMismatchError")
1882
+ throw new Q("stat", t, r);
1772
1883
  }
1773
1884
  try {
1774
1885
  return await n.getDirectoryHandle(e, { create: !1 }), {
@@ -1780,7 +1891,7 @@ class ss {
1780
1891
  isDirectory: !0
1781
1892
  };
1782
1893
  } catch (r) {
1783
- throw r.name === "NotFoundError" ? new p(\`No such file or directory: \${t}\`, "ENOENT", void 0, r) : new p("Failed to stat (directory)", "STAT_FAILED", void 0, r);
1894
+ throw new Q("stat", t, r);
1784
1895
  }
1785
1896
  }
1786
1897
  /**
@@ -1804,11 +1915,11 @@ class ss {
1804
1915
  async readDir(t) {
1805
1916
  await this.mount();
1806
1917
  const e = await this.getDirectoryHandle(t, !1), n = [];
1807
- for await (const [i, r] of e.entries()) {
1808
- const o = r.kind === "file";
1918
+ for await (const [r, i] of e.entries()) {
1919
+ const o = i.kind === "file";
1809
1920
  n.push({
1810
- name: i,
1811
- kind: r.kind,
1921
+ name: r,
1922
+ kind: i.kind,
1812
1923
  isFile: o,
1813
1924
  isDirectory: !o
1814
1925
  });
@@ -1832,26 +1943,26 @@ class ss {
1832
1943
  async exists(t) {
1833
1944
  if (await this.mount(), t === "/")
1834
1945
  return !0;
1835
- const e = K(t);
1946
+ const e = it(t);
1836
1947
  let n = null;
1837
1948
  try {
1838
- n = await this.getDirectoryHandle(Y(t), !1);
1839
- } catch (i) {
1840
- if (n = null, i.name !== "NotFoundError" && i.name !== "TypeMismatchError")
1841
- throw i;
1949
+ n = await this.getDirectoryHandle(et(t), !1);
1950
+ } catch (r) {
1951
+ if (n = null, r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
1952
+ throw r;
1842
1953
  }
1843
1954
  if (!n || !e)
1844
1955
  return !1;
1845
1956
  try {
1846
1957
  return await n.getFileHandle(e, { create: !1 }), !0;
1847
- } catch (i) {
1848
- if (i.name !== "NotFoundError" && i.name !== "TypeMismatchError")
1849
- throw i;
1958
+ } catch (r) {
1959
+ if (r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
1960
+ throw r;
1850
1961
  try {
1851
1962
  return await n.getDirectoryHandle(e, { create: !1 }), !0;
1852
- } catch (r) {
1853
- if (r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
1854
- throw r;
1963
+ } catch (i) {
1964
+ if (i.name !== "NotFoundError" && i.name !== "TypeMismatchError")
1965
+ throw i;
1855
1966
  return !1;
1856
1967
  }
1857
1968
  }
@@ -1880,12 +1991,12 @@ class ss {
1880
1991
  try {
1881
1992
  const e = await this.readDir(t);
1882
1993
  for (const n of e) {
1883
- const i = \`\${t === "/" ? "" : t}/\${n.name}\`;
1884
- await this.remove(i, { recursive: !0 });
1994
+ const r = \`\${t === "/" ? "" : t}/\${n.name}\`;
1995
+ await this.remove(r, { recursive: !0 });
1885
1996
  }
1886
- await this.notifyChange({ path: t, type: A.Changed, isDirectory: !0 });
1997
+ await this.notifyChange({ path: t, type: D.Changed, isDirectory: !0 });
1887
1998
  } catch (e) {
1888
- throw e instanceof p ? e : new p(\`Failed to clear directory: \${t}\`, "CLEAR_FAILED", void 0, e);
1999
+ throw e instanceof w ? e : A(e, { path: t, isDirectory: !0 });
1889
2000
  }
1890
2001
  }
1891
2002
  /**
@@ -1914,9 +2025,9 @@ class ss {
1914
2025
  */
1915
2026
  async remove(t, e) {
1916
2027
  if (await this.mount(), t === "/")
1917
- throw new p("Cannot remove root directory", "EROOT");
1918
- const { recursive: n = !1, force: i = !1 } = e || {}, r = await this.getDirectoryHandle(Y(t), !1), o = await this.stat(t);
1919
- await Qe(r, t, { recursive: n, force: i }), await this.notifyChange({ path: t, type: A.Removed, isDirectory: o.isDirectory });
2028
+ throw new rt("EROOT", t);
2029
+ const { recursive: n = !1, force: r = !1 } = e || {}, i = await this.getDirectoryHandle(et(t), !1), o = await this.stat(t);
2030
+ await fs(i, t, { recursive: n, force: r }), await this.notifyChange({ path: t, type: D.Removed, isDirectory: o.isDirectory });
1920
2031
  }
1921
2032
  /**
1922
2033
  * Resolve a path to an absolute path
@@ -1939,12 +2050,12 @@ class ss {
1939
2050
  async realpath(t) {
1940
2051
  await this.mount();
1941
2052
  try {
1942
- const e = ft(t);
2053
+ const e = Et(t);
1943
2054
  if (!await this.exists(e))
1944
- throw new it(e);
2055
+ throw new F("file", e);
1945
2056
  return e;
1946
2057
  } catch (e) {
1947
- throw e instanceof p ? e : new p(\`Failed to resolve path: \${t}\`, "REALPATH_FAILED", void 0, e);
2058
+ throw e instanceof w ? e : A(e, { path: t });
1948
2059
  }
1949
2060
  }
1950
2061
  /**
@@ -1972,12 +2083,12 @@ class ss {
1972
2083
  async rename(t, e, n) {
1973
2084
  await this.mount();
1974
2085
  try {
1975
- const i = n?.overwrite ?? !1, r = await this.stat(t);
1976
- if (await this.exists(e) && !i)
1977
- throw new p(\`Destination already exists: \${e}\`, "EEXIST", void 0);
1978
- await this.copy(t, e, { recursive: !0, overwrite: i }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type: A.Removed, isDirectory: r.isDirectory }), await this.notifyChange({ path: e, type: A.Added, isDirectory: r.isDirectory });
1979
- } catch (i) {
1980
- throw i instanceof p ? i : new p(\`Failed to rename from \${t} to \${e}\`, "RENAME_FAILED", void 0, i);
2086
+ const r = n?.overwrite ?? !1, i = await this.stat(t);
2087
+ if (await this.exists(e) && !r)
2088
+ throw new K(e);
2089
+ await this.copy(t, e, { recursive: !0, overwrite: r }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type: D.Removed, isDirectory: i.isDirectory }), await this.notifyChange({ path: e, type: D.Added, isDirectory: i.isDirectory });
2090
+ } catch (r) {
2091
+ throw r instanceof w ? r : A(r, { path: t });
1981
2092
  }
1982
2093
  }
1983
2094
  /**
@@ -2008,26 +2119,26 @@ class ss {
2008
2119
  async copy(t, e, n) {
2009
2120
  await this.mount();
2010
2121
  try {
2011
- const i = n?.recursive ?? !1, r = n?.overwrite ?? !0;
2122
+ const r = n?.recursive ?? !1, i = n?.overwrite ?? !0;
2012
2123
  if (!await this.exists(t))
2013
- throw new p(\`Source does not exist: \${t}\`, "ENOENT", void 0);
2014
- if (await this.exists(e) && !r)
2015
- throw new p(\`Destination already exists: \${e}\`, "EEXIST", void 0);
2124
+ throw new F("source", t);
2125
+ if (await this.exists(e) && !i)
2126
+ throw new K(e);
2016
2127
  if ((await this.stat(t)).isFile) {
2017
2128
  const h = await this.readFile(t);
2018
2129
  await this.writeFile(e, h);
2019
2130
  } else {
2020
- if (!i)
2021
- throw new p(\`Cannot copy directory without recursive option: \${t}\`, "EISDIR", void 0);
2131
+ if (!r)
2132
+ throw new z("directory", t);
2022
2133
  await this.mkdir(e, { recursive: !0 });
2023
2134
  const h = await this.readDir(t);
2024
2135
  for (const c of h) {
2025
2136
  const f = \`\${t}/\${c.name}\`, u = \`\${e}/\${c.name}\`;
2026
- await this.copy(f, u, { recursive: !0, overwrite: r });
2137
+ await this.copy(f, u, { recursive: !0, overwrite: i });
2027
2138
  }
2028
2139
  }
2029
- } catch (i) {
2030
- throw i instanceof p ? i : new p(\`Failed to copy from \${t} to \${e}\`, "CP_FAILED", void 0, i);
2140
+ } catch (r) {
2141
+ throw r instanceof w ? r : A(r, { path: t });
2031
2142
  }
2032
2143
  }
2033
2144
  /**
@@ -2057,9 +2168,9 @@ class ss {
2057
2168
  */
2058
2169
  async watch(t, e) {
2059
2170
  if (!this.options.broadcastChannel)
2060
- throw new p("This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.", "ENOENT");
2171
+ throw new Ct("This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.");
2061
2172
  const n = {
2062
- pattern: Ze(t, e?.recursive ?? !0),
2173
+ pattern: ls(t, e?.recursive ?? !0),
2063
2174
  include: Array.isArray(e?.include) ? e.include : [e?.include ?? "**"],
2064
2175
  exclude: Array.isArray(e?.exclude) ? e.exclude : [e?.exclude ?? ""]
2065
2176
  };
@@ -2100,15 +2211,15 @@ class ss {
2100
2211
  */
2101
2212
  async open(t, e) {
2102
2213
  await this.mount();
2103
- const { create: n = !1, exclusive: i = !1, truncate: r = !1 } = e || {}, o = _(ft(t));
2214
+ const { create: n = !1, exclusive: r = !1, truncate: i = !1 } = e || {}, o = G(Et(t));
2104
2215
  try {
2105
- return n && i ? await T(o, "exclusive", async () => {
2216
+ return n && r ? await L(o, "exclusive", async () => {
2106
2217
  if (await this.exists(o))
2107
- throw new p(\`File already exists: \${o}\`, "EEXIST", o);
2108
- return this._openFile(o, n, r);
2109
- }) : await this._openFile(o, n, r);
2218
+ throw new K(o);
2219
+ return this._openFile(o, n, i);
2220
+ }) : await this._openFile(o, n, i);
2110
2221
  } catch (a) {
2111
- throw a instanceof p ? a : new p(\`Failed to open file: \${o}\`, "OPEN_FAILED", o, a);
2222
+ throw a instanceof w ? a : A(a, { path: o, isDirectory: !1 });
2112
2223
  }
2113
2224
  }
2114
2225
  /**
@@ -2116,19 +2227,19 @@ class ss {
2116
2227
  * @private
2117
2228
  */
2118
2229
  async _openFile(t, e, n) {
2119
- const i = await this.getFileHandle(t, e);
2230
+ const r = await this.getFileHandle(t, e);
2120
2231
  try {
2121
- await i.getFile();
2232
+ await r.getFile();
2122
2233
  } catch (a) {
2123
- throw a.name === "TypeMismatchError" ? new p(\`Is a directory: \${t}\`, "EISDIR", t) : a;
2234
+ throw A(a, { path: t, isDirectory: !0 });
2124
2235
  }
2125
- const r = await es(i, t);
2126
- n && (r.truncate(0), r.flush());
2236
+ const i = await ps(r, t);
2237
+ n && (i.truncate(0), i.flush());
2127
2238
  const o = this.nextFd++;
2128
2239
  return this.openFiles.set(o, {
2129
2240
  path: t,
2130
- fileHandle: i,
2131
- syncHandle: r,
2241
+ fileHandle: r,
2242
+ syncHandle: i,
2132
2243
  position: 0
2133
2244
  }), o;
2134
2245
  }
@@ -2148,7 +2259,7 @@ class ss {
2148
2259
  */
2149
2260
  async close(t) {
2150
2261
  const e = this._getFileDescriptor(t);
2151
- pt(t, e.syncHandle, e.path), this.openFiles.delete(t);
2262
+ xt(t, e.syncHandle, e.path), this.openFiles.delete(t);
2152
2263
  }
2153
2264
  /**
2154
2265
  * Read data from a file descriptor
@@ -2174,17 +2285,17 @@ class ss {
2174
2285
  * await fs.close(fd);
2175
2286
  * \`\`\`
2176
2287
  */
2177
- async read(t, e, n, i, r) {
2288
+ async read(t, e, n, r, i) {
2178
2289
  const o = this._getFileDescriptor(t);
2179
- dt(e.length, n, i, r);
2290
+ St(e.length, n, r, i);
2180
2291
  try {
2181
- const a = r ?? o.position, l = o.syncHandle.getSize(), { isEOF: h, actualLength: c } = ts(a, i, l);
2292
+ const a = i ?? o.position, l = o.syncHandle.getSize(), { isEOF: h, actualLength: c } = ds(a, r, l);
2182
2293
  if (h)
2183
- return W({ bytesRead: 0, buffer: e }, [e.buffer]);
2294
+ return B({ bytesRead: 0, buffer: e }, [e.buffer]);
2184
2295
  const f = e.subarray(n, n + c), u = o.syncHandle.read(f, { at: a });
2185
- return r == null && (o.position = a + u), W({ bytesRead: u, buffer: e }, [e.buffer]);
2296
+ return i == null && (o.position = a + u), B({ bytesRead: u, buffer: e }, [e.buffer]);
2186
2297
  } catch (a) {
2187
- throw L("read", t, o.path, a);
2298
+ throw j("read", t, o.path, a);
2188
2299
  }
2189
2300
  }
2190
2301
  /**
@@ -2208,14 +2319,14 @@ class ss {
2208
2319
  * await fs.close(fd);
2209
2320
  * \`\`\`
2210
2321
  */
2211
- async write(t, e, n = 0, i, r, o = !0) {
2212
- const a = this._getFileDescriptor(t), l = i ?? e.length - n;
2213
- dt(e.length, n, l, r);
2322
+ async write(t, e, n = 0, r, i, o = !0) {
2323
+ const a = this._getFileDescriptor(t), l = r ?? e.length - n;
2324
+ St(e.length, n, l, i);
2214
2325
  try {
2215
- const h = r ?? a.position, c = e.subarray(n, n + l), f = a.syncHandle.write(c, { at: h });
2216
- return (r == null || r === a.position) && (a.position = h + f), o && await this.notifyChange({ path: a.path, type: A.Changed, isDirectory: !1 }), f;
2326
+ const h = i ?? a.position, c = e.subarray(n, n + l), f = a.syncHandle.write(c, { at: h });
2327
+ return (i == null || i === a.position) && (a.position = h + f), o && await this.notifyChange({ path: a.path, type: D.Changed, isDirectory: !1 }), f;
2217
2328
  } catch (h) {
2218
- throw L("write", t, a.path, h);
2329
+ throw j("write", t, a.path, h);
2219
2330
  }
2220
2331
  }
2221
2332
  /**
@@ -2259,11 +2370,11 @@ class ss {
2259
2370
  async ftruncate(t, e = 0) {
2260
2371
  const n = this._getFileDescriptor(t);
2261
2372
  if (e < 0 || !Number.isInteger(e))
2262
- throw new p("Invalid size", "EINVAL");
2373
+ throw new N("argument", "Invalid size");
2263
2374
  try {
2264
- n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type: A.Changed, isDirectory: !1 });
2265
- } catch (i) {
2266
- throw L("truncate", t, n.path, i);
2375
+ n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type: D.Changed, isDirectory: !1 });
2376
+ } catch (r) {
2377
+ throw j("truncate", t, n.path, r);
2267
2378
  }
2268
2379
  }
2269
2380
  /**
@@ -2285,7 +2396,7 @@ class ss {
2285
2396
  try {
2286
2397
  e.syncHandle.flush();
2287
2398
  } catch (n) {
2288
- throw L("sync", t, e.path, n);
2399
+ throw j("sync", t, e.path, n);
2289
2400
  }
2290
2401
  }
2291
2402
  /**
@@ -2297,7 +2408,7 @@ class ss {
2297
2408
  dispose() {
2298
2409
  this.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.watchers.clear();
2299
2410
  for (const [t, e] of this.openFiles)
2300
- pt(t, e.syncHandle, e.path);
2411
+ xt(t, e.syncHandle, e.path);
2301
2412
  this.openFiles.clear(), this.nextFd = 1;
2302
2413
  }
2303
2414
  /**
@@ -2332,16 +2443,16 @@ class ss {
2332
2443
  await this.mount();
2333
2444
  try {
2334
2445
  for (const [e, n] of t) {
2335
- const i = _(e);
2336
- let r;
2337
- n instanceof Blob ? r = await Ke(n) : typeof n == "string" ? r = new TextEncoder().encode(n) : r = n, await this.writeFile(i, r);
2446
+ const r = G(e);
2447
+ let i;
2448
+ n instanceof Blob ? i = await us(n) : typeof n == "string" ? i = new TextEncoder().encode(n) : i = n, await this.writeFile(r, i);
2338
2449
  }
2339
2450
  } catch (e) {
2340
- throw e instanceof p ? e : new p("Failed to sync file system", "SYNC_FAILED", void 0, e);
2451
+ throw e instanceof w ? e : A(e);
2341
2452
  }
2342
2453
  }
2343
2454
  }
2344
- typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" && Q(new ss());
2345
- //# sourceMappingURL=worker-Dy3EFYv_.js.map
2346
- `,c=typeof self<"u"&&self.Blob&&new Blob(["URL.revokeObjectURL(import.meta.url);",l],{type:"text/javascript;charset=utf-8"});function u(o){let n;try{if(n=c&&(self.URL||self.webkitURL).createObjectURL(c),!n)throw"";const t=new Worker(n,{type:"module",name:o?.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(n)}),t}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(l),{type:"module",name:o?.name})}}function a(o){return o instanceof URL?o.pathname:o}class f{#n;promises=this;constructor(n){this.#n=d.wrap(new u),n&&(n.broadcastChannel&&n.broadcastChannel instanceof BroadcastChannel&&(n.broadcastChannel=n.broadcastChannel.name),this.setOptions(n))}watch(n,t){const r=a(n);return this.#n.watch(r,t),()=>this.unwatch(r)}unwatch(n){const t=a(n);this.#n.unwatch(t)}async setOptions(n){return this.#n.setOptions(n)}async index(){return this.#n.index()}async readFile(n,t){const r=a(n);let i;typeof t=="string"?i=t:t&&typeof t=="object"&&(i=t.encoding);const s=await this.#n.readFile(r);return i||(i=e.isBinaryFileExtension(r)?"binary":"utf-8"),i==="binary"?s:e.decodeBuffer(s,i)}async writeFile(n,t,r){const i=a(n);let s;typeof r=="string"?s=r:r&&typeof r=="object"&&(s=r.encoding),s||(s=typeof t!="string"||e.isBinaryFileExtension(i)?"binary":"utf-8");const h=typeof t=="string"?e.encodeString(t,s):t instanceof Uint8Array?t:new Uint8Array(t);return this.#n.writeFile(i,h)}async appendFile(n,t,r){const i=a(n);r||(r=typeof t!="string"||e.isBinaryFileExtension(i)?"binary":"utf-8");const s=typeof t=="string"?e.encodeString(t,r):t instanceof Uint8Array?t:new Uint8Array(t);return this.#n.appendFile(i,s)}async mkdir(n,t){const r=a(n);let i;return typeof t=="number"?i={recursive:!1}:i=t,this.#n.mkdir(r,i)}async stat(n){const t=a(n);return this.#n.stat(t)}async readDir(n){const t=a(n);return this.#n.readDir(t)}async exists(n){const t=a(n);return this.#n.exists(t)}async clear(n){const t=n?a(n):void 0;return this.#n.clear(t)}async remove(n,t){const r=a(n);return this.#n.remove(r,t)}async unlink(n){return this.remove(n)}async rm(n,t){return this.remove(n,t)}async rmdir(n){return this.remove(n)}async readdir(n,t){return this.readDir(n)}async lstat(n){return this.stat(n)}async chmod(n,t){return Promise.resolve()}async realpath(n){const t=a(n);return this.#n.realpath(t)}async rename(n,t,r){const i=a(n),s=a(t);return this.#n.rename(i,s,r)}async copy(n,t,r){const i=a(n),s=a(t);return this.#n.copy(i,s,r)}async open(n,t){const r=a(n);return this.#n.open(r,t)}async close(n){return this.#n.close(n)}async read(n,t,r,i,s){const{bytesRead:h,buffer:p}=await this.#n.read(n,new Uint8Array(i),0,i,s);return h>0&&t.set(p.subarray(0,h),r),{bytesRead:h,buffer:t}}async write(n,t,r,i,s,h){return this.#n.write(n,t,r,i,s,h)}async fstat(n){return this.#n.fstat(n)}async ftruncate(n,t){return this.#n.ftruncate(n,t)}async fsync(n){return this.#n.fsync(n)}dispose(){this.#n.dispose()}async createIndex(n){const t=n.map(([r,i])=>[a(r),i]);return this.#n.createIndex(t)}async readText(n,t="utf-8"){const r=a(n),i=await this.#n.readFile(r);return e.decodeBuffer(i,t)}async writeText(n,t,r="utf-8"){const i=a(n),s=e.encodeString(t,r);return this.#n.writeFile(i,s)}async appendText(n,t,r="utf-8"){const i=a(n),s=e.encodeString(t,r);return this.#n.appendFile(i,s)}}function m(o){return new f(o)}exports.BINARY_FILE_EXTENSIONS=e.BINARY_FILE_EXTENSIONS;exports.DirectoryNotFoundError=e.DirectoryNotFoundError;exports.FileNotFoundError=e.FileNotFoundError;exports.OPFSError=e.OPFSError;exports.OPFSNotMountedError=e.OPFSNotMountedError;exports.OPFSNotSupportedError=e.OPFSNotSupportedError;exports.PathError=e.PathError;exports.PermissionError=e.PermissionError;exports.StorageError=e.StorageError;exports.TimeoutError=e.TimeoutError;exports.WatchEventType=e.WatchEventType;exports.basename=e.basename;exports.buffersEqual=e.buffersEqual;exports.calculateFileHash=e.calculateFileHash;exports.calculateReadLength=e.calculateReadLength;exports.checkOPFSSupport=e.checkOPFSSupport;exports.convertBlobToUint8Array=e.convertBlobToUint8Array;exports.createBuffer=e.createBuffer;exports.createFDError=e.createFDError;exports.createSyncHandleSafe=e.createSyncHandleSafe;exports.decodeBuffer=e.decodeBuffer;exports.dirname=e.dirname;exports.encodeString=e.encodeString;exports.extname=e.extname;exports.isBinaryFileExtension=e.isBinaryFileExtension;exports.isPathExcluded=e.isPathExcluded;exports.joinPath=e.joinPath;exports.mapDomError=e.mapDomError;exports.matchMinimatch=e.matchMinimatch;exports.normalizeMinimatch=e.normalizeMinimatch;exports.normalizePath=e.normalizePath;exports.removeEntry=e.removeEntry;exports.resolvePath=e.resolvePath;exports.safeCloseSyncHandle=e.safeCloseSyncHandle;exports.splitPath=e.splitPath;exports.validateReadWriteArgs=e.validateReadWriteArgs;exports.withLock=e.withLock;exports.OPFSFileSystem=f;exports.createWorker=m;
2455
+ typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" && ot(new gs());
2456
+ //# sourceMappingURL=worker-BeJaVyBV.js.map
2457
+ `,h=typeof self<"u"&&self.Blob&&new Blob(["URL.revokeObjectURL(import.meta.url);",l],{type:"text/javascript;charset=utf-8"});function u(o){let n;try{if(n=h&&(self.URL||self.webkitURL).createObjectURL(h),!n)throw"";const t=new Worker(n,{type:"module",name:o?.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(n)}),t}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(l),{type:"module",name:o?.name})}}function a(o){return o instanceof URL?o.pathname:o}class p{#n;promises=this;constructor(n){this.#n=d.wrap(new u),n&&(n.broadcastChannel&&n.broadcastChannel instanceof BroadcastChannel&&(n.broadcastChannel=n.broadcastChannel.name),this.setOptions(n))}watch(n,t){const r=a(n);return this.#n.watch(r,t),()=>this.unwatch(r)}unwatch(n){const t=a(n);this.#n.unwatch(t)}async setOptions(n){return this.#n.setOptions(n)}async index(){return this.#n.index()}async readFile(n,t){const r=a(n);let s;typeof t=="string"?s=t:t&&typeof t=="object"&&(s=t.encoding);const i=await this.#n.readFile(r);return s||(s=e.isBinaryFileExtension(r)?"binary":"utf-8"),s==="binary"?i:e.decodeBuffer(i,s)}async writeFile(n,t,r){const s=a(n);let i;typeof r=="string"?i=r:r&&typeof r=="object"&&(i=r.encoding),i||(i=typeof t!="string"||e.isBinaryFileExtension(s)?"binary":"utf-8");const c=typeof t=="string"?e.encodeString(t,i):t instanceof Uint8Array?t:new Uint8Array(t);return this.#n.writeFile(s,c)}async appendFile(n,t,r){const s=a(n);r||(r=typeof t!="string"||e.isBinaryFileExtension(s)?"binary":"utf-8");const i=typeof t=="string"?e.encodeString(t,r):t instanceof Uint8Array?t:new Uint8Array(t);return this.#n.appendFile(s,i)}async mkdir(n,t){const r=a(n);let s;return typeof t=="number"?s={recursive:!1}:s=t,this.#n.mkdir(r,s)}async stat(n){const t=a(n);return this.#n.stat(t)}async readDir(n){const t=a(n);return this.#n.readDir(t)}async exists(n){const t=a(n);return this.#n.exists(t)}async clear(n){const t=n?a(n):void 0;return this.#n.clear(t)}async remove(n,t){const r=a(n);return this.#n.remove(r,t)}async unlink(n){return this.remove(n)}async rm(n,t){return this.remove(n,t)}async rmdir(n){return this.remove(n)}async readdir(n,t){return this.readDir(n)}async lstat(n){return this.stat(n)}async chmod(n,t){return Promise.resolve()}async realpath(n){const t=a(n);return this.#n.realpath(t)}async rename(n,t,r){const s=a(n),i=a(t);return this.#n.rename(s,i,r)}async copy(n,t,r){const s=a(n),i=a(t);return this.#n.copy(s,i,r)}async open(n,t){const r=a(n);return this.#n.open(r,t)}async close(n){return this.#n.close(n)}async read(n,t,r,s,i){const{bytesRead:c,buffer:f}=await this.#n.read(n,new Uint8Array(s),0,s,i);return c>0&&t.set(f.subarray(0,c),r),{bytesRead:c,buffer:t}}async write(n,t,r,s,i,c){return this.#n.write(n,t,r,s,i,c)}async fstat(n){return this.#n.fstat(n)}async ftruncate(n,t){return this.#n.ftruncate(n,t)}async fsync(n){return this.#n.fsync(n)}dispose(){this.#n.dispose()}async createIndex(n){const t=n.map(([r,s])=>[a(r),s]);return this.#n.createIndex(t)}async readText(n,t="utf-8"){const r=a(n),s=await this.#n.readFile(r);return e.decodeBuffer(s,t)}async writeText(n,t,r="utf-8"){const s=a(n),i=e.encodeString(t,r);return this.#n.writeFile(s,i)}async appendText(n,t,r="utf-8"){const s=a(n),i=e.encodeString(t,r);return this.#n.appendFile(s,i)}}function m(o){return new p(o)}exports.AlreadyExistsError=e.AlreadyExistsError;exports.BINARY_FILE_EXTENSIONS=e.BINARY_FILE_EXTENSIONS;exports.DirectoryOperationError=e.DirectoryOperationError;exports.ExistenceError=e.ExistenceError;exports.FileBusyError=e.FileBusyError;exports.FileSystemOperationError=e.FileSystemOperationError;exports.FileTypeError=e.FileTypeError;exports.IOError=e.IOError;exports.InitializationFailedError=e.InitializationFailedError;exports.OPFSError=e.OPFSError;exports.OPFSNotSupportedError=e.OPFSNotSupportedError;exports.OperationAbortedError=e.OperationAbortedError;exports.OperationNotSupportedError=e.OperationNotSupportedError;exports.PathError=e.PathError;exports.PermissionError=e.PermissionError;exports.StorageError=e.StorageError;exports.ValidationError=e.ValidationError;exports.WatchEventType=e.WatchEventType;exports.basename=e.basename;exports.buffersEqual=e.buffersEqual;exports.calculateFileHash=e.calculateFileHash;exports.calculateReadLength=e.calculateReadLength;exports.checkOPFSSupport=e.checkOPFSSupport;exports.convertBlobToUint8Array=e.convertBlobToUint8Array;exports.createBuffer=e.createBuffer;exports.createFDError=e.createFDError;exports.createSyncHandleSafe=e.createSyncHandleSafe;exports.decodeBuffer=e.decodeBuffer;exports.dirname=e.dirname;exports.encodeString=e.encodeString;exports.extname=e.extname;exports.isBinaryFileExtension=e.isBinaryFileExtension;exports.isPathExcluded=e.isPathExcluded;exports.joinPath=e.joinPath;exports.mapDomError=e.mapDomError;exports.matchMinimatch=e.matchMinimatch;exports.normalizeMinimatch=e.normalizeMinimatch;exports.normalizePath=e.normalizePath;exports.removeEntry=e.removeEntry;exports.resolvePath=e.resolvePath;exports.safeCloseSyncHandle=e.safeCloseSyncHandle;exports.splitPath=e.splitPath;exports.validateReadWriteArgs=e.validateReadWriteArgs;exports.withLock=e.withLock;exports.OPFSFileSystem=p;exports.createWorker=m;
2347
2458
  //# sourceMappingURL=index.cjs.map