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