@ztimson/utils 0.19.2 → 0.20.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.mjs CHANGED
@@ -1,22 +1,22 @@
1
- var ut = Object.defineProperty;
2
- var at = (n, t, e) => t in n ? ut(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
- var c = (n, t, e) => at(n, typeof t != "symbol" ? t + "" : t, e);
4
- function lt(n, t = !1) {
1
+ var st = Object.defineProperty;
2
+ var it = (n, t, e) => t in n ? st(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
+ var c = (n, t, e) => it(n, typeof t != "symbol" ? t + "" : t, e);
4
+ function ot(n, t = !1) {
5
5
  if (n == null) throw new Error("Cannot clean a NULL value");
6
6
  return Array.isArray(n) ? n = n.filter((e) => e != null) : Object.entries(n).forEach(([e, r]) => {
7
7
  (t && r === void 0 || !t && r == null) && delete n[e];
8
8
  }), n;
9
9
  }
10
- function Ct(n) {
10
+ function xt(n) {
11
11
  return structuredClone(n);
12
12
  }
13
- function ft(n, ...t) {
13
+ function ct(n, ...t) {
14
14
  return t.forEach((e) => {
15
15
  for (const r in e)
16
- e[r] && typeof e[r] == "object" && !Array.isArray(e[r]) ? (n[r] || (n[r] = {}), ft(n[r], e[r])) : n[r] = e[r];
16
+ e[r] && typeof e[r] == "object" && !Array.isArray(e[r]) ? (n[r] || (n[r] = {}), ct(n[r], e[r])) : n[r] = e[r];
17
17
  }), n;
18
18
  }
19
- function x(n, t, e) {
19
+ function B(n, t, e) {
20
20
  if (!(n == null || !t))
21
21
  return t.split(/[.[\]]/g).filter((r) => r.length).reduce((r, s, i, o) => {
22
22
  if ((s[0] == '"' || s[0] == "'") && (s = s.slice(1, -1)), !(r != null && r.hasOwnProperty(s))) {
@@ -26,35 +26,35 @@ function x(n, t, e) {
26
26
  return e !== void 0 && i == o.length - 1 ? r[s] = e : r[s];
27
27
  }, n);
28
28
  }
29
- function Lt(n) {
29
+ function Bt(n) {
30
30
  return Object.entries(n).map(
31
31
  ([t, e]) => encodeURIComponent(t) + "=" + encodeURIComponent(e)
32
32
  ).join("&");
33
33
  }
34
- function J(n, t, e = {}) {
34
+ function H(n, t, e = {}) {
35
35
  if (typeof n == "object" && !Array.isArray(n)) {
36
36
  for (const r of Object.keys(n)) {
37
37
  const s = t ? t + "." + r : r;
38
- typeof n[r] == "object" ? J(n[r], s, e) : e[s] = n[r];
38
+ typeof n[r] == "object" ? H(n[r], s, e) : e[s] = n[r];
39
39
  }
40
40
  return e;
41
41
  }
42
42
  }
43
- function vt(n) {
43
+ function At(n) {
44
44
  const t = new FormData();
45
45
  return Object.entries(n).forEach(([e, r]) => t.append(e, r)), t;
46
46
  }
47
- function Y(n, t, e = !1) {
47
+ function q(n, t, e = !1) {
48
48
  if (n == null) return e;
49
- if (Array.isArray(t)) return t.findIndex((s, i) => !Y(n[i], t[i], e)) == -1;
49
+ if (Array.isArray(t)) return t.findIndex((s, i) => !q(n[i], t[i], e)) == -1;
50
50
  const r = typeof t;
51
- return r != typeof n ? !1 : r == "object" ? Object.keys(t).find((s) => !Y(n[s], t[s], e)) == null : r == "function" ? n.toString() == t.toString() : n == t;
51
+ return r != typeof n ? !1 : r == "object" ? Object.keys(t).find((s) => !q(n[s], t[s], e)) == null : r == "function" ? n.toString() == t.toString() : n == t;
52
52
  }
53
- function $(n, t) {
53
+ function O(n, t) {
54
54
  const e = typeof n, r = typeof t;
55
- return e != "object" || n == null || r != "object" || t == null ? e == "function" && r == "function" ? n.toString() == t.toString() : n === t : Object.keys(n).length != Object.keys(t).length ? !1 : Object.keys(n).every((i) => $(n[i], t[i]));
55
+ return e != "object" || n == null || r != "object" || t == null ? e == "function" && r == "function" ? n.toString() == t.toString() : n === t : Object.keys(n).length != Object.keys(t).length ? !1 : Object.keys(n).every((i) => O(n[i], t[i]));
56
56
  }
57
- function Nt(n, t) {
57
+ function Rt(n, t) {
58
58
  t.forEach((e) => {
59
59
  Object.getOwnPropertyNames(e.prototype).forEach((r) => {
60
60
  Object.defineProperty(
@@ -65,14 +65,14 @@ function Nt(n, t) {
65
65
  });
66
66
  });
67
67
  }
68
- function k(n) {
68
+ function I(n) {
69
69
  try {
70
70
  return JSON.parse(n);
71
71
  } catch {
72
72
  return n;
73
73
  }
74
74
  }
75
- function It(n, t) {
75
+ function Ot(n, t) {
76
76
  let e = [];
77
77
  return JSON.stringify(n, (r, s) => {
78
78
  if (typeof s == "object" && s !== null) {
@@ -82,42 +82,42 @@ function It(n, t) {
82
82
  return s;
83
83
  }, t);
84
84
  }
85
- function Tt(n, t) {
85
+ function $t(n, t) {
86
86
  return n.indexOf(t) === -1 && n.push(t), n;
87
87
  }
88
- function Mt(n, t) {
89
- return dt([
90
- ...n.filter((e) => !t.includes((r) => $(e, r))),
91
- ...t.filter((e) => !n.includes((r) => $(e, r)))
88
+ function Ct(n, t) {
89
+ return at([
90
+ ...n.filter((e) => !t.includes((r) => O(e, r))),
91
+ ...t.filter((e) => !n.includes((r) => O(e, r)))
92
92
  ]);
93
93
  }
94
- function kt(n) {
94
+ function Lt(n) {
95
95
  return function(t, e) {
96
- const r = x(t, n), s = x(e, n);
96
+ const r = B(t, n), s = B(e, n);
97
97
  return typeof r != "string" || typeof s != "string" ? 1 : r.toLowerCase().localeCompare(s.toLowerCase());
98
98
  };
99
99
  }
100
- function Pt(n, t) {
101
- return (e) => $(x(e, n), t);
100
+ function jt(n, t) {
101
+ return (e) => O(B(e, n), t);
102
102
  }
103
- function ht(n, t = []) {
104
- return n.forEach((e) => Array.isArray(e) ? ht(e, t) : t.push(e)), t;
103
+ function ut(n, t = []) {
104
+ return n.forEach((e) => Array.isArray(e) ? ut(e, t) : t.push(e)), t;
105
105
  }
106
- function Dt(n, t = !1) {
106
+ function Nt(n, t = !1) {
107
107
  return function(e, r) {
108
- const s = x(e, n), i = x(r, n);
108
+ const s = B(e, n), i = B(r, n);
109
109
  return typeof s == "number" && typeof i == "number" ? (t ? -1 : 1) * (s - i) : s > i ? t ? -1 : 1 : s < i ? t ? 1 : -1 : 0;
110
110
  };
111
111
  }
112
- function dt(n) {
112
+ function at(n) {
113
113
  for (let t = n.length - 1; t >= 0; t--)
114
- n.slice(0, t).find((e) => $(e, n[t])) && n.splice(t, 1);
114
+ n.slice(0, t).find((e) => O(e, n[t])) && n.splice(t, 1);
115
115
  return n;
116
116
  }
117
- function b(n) {
117
+ function m(n) {
118
118
  return Array.isArray(n) ? n : [n];
119
119
  }
120
- class E extends Array {
120
+ class S extends Array {
121
121
  /** Number of elements in set */
122
122
  get size() {
123
123
  return this.length;
@@ -152,7 +152,7 @@ class E extends Array {
152
152
  * @return {ASet<T>} Different elements
153
153
  */
154
154
  difference(t) {
155
- return new E(this.filter((e) => !t.has(e)));
155
+ return new S(this.filter((e) => !t.has(e)));
156
156
  }
157
157
  /**
158
158
  * Check if set includes element
@@ -168,7 +168,7 @@ class E extends Array {
168
168
  * @return {boolean} Set of common elements
169
169
  */
170
170
  intersection(t) {
171
- return new E(this.filter((e) => t.has(e)));
171
+ return new S(this.filter((e) => t.has(e)));
172
172
  }
173
173
  /**
174
174
  * Check if this set has no elements in common with the comparison set
@@ -200,7 +200,7 @@ class E extends Array {
200
200
  * @return {ASet<T>} New set of unique elements
201
201
  */
202
202
  symmetricDifference(t) {
203
- return new E([...this.difference(t), ...t.difference(this)]);
203
+ return new S([...this.difference(t), ...t.difference(this)]);
204
204
  }
205
205
  /**
206
206
  * Create joined list of elements included in this & the comparison set
@@ -208,17 +208,17 @@ class E extends Array {
208
208
  * @return {ASet<T>} New set of both previous sets combined
209
209
  */
210
210
  union(t) {
211
- return new E([...this, ...t]);
211
+ return new S([...this, ...t]);
212
212
  }
213
213
  }
214
- class Gt {
214
+ class Tt {
215
215
  /**
216
216
  * Create new cache
217
217
  *
218
218
  * @param {keyof T} key Default property to use as primary key
219
- * @param {number} ttl Default expiry in milliseconds
219
+ * @param options
220
220
  */
221
- constructor(t, e) {
221
+ constructor(t, e = {}) {
222
222
  c(this, "store", {});
223
223
  /** Whether cache is complete */
224
224
  c(this, "complete", !1);
@@ -228,7 +228,15 @@ class Gt {
228
228
  * @return {T[]} Array of items
229
229
  */
230
230
  c(this, "values", this.all());
231
- return this.key = t, this.ttl = e, new Proxy(this, {
231
+ if (this.key = t, this.options = e, e.storageKey && !e.storage && (e.storage = localStorage), e.storageKey && e.storage) {
232
+ const r = e.storage.getItem(e.storageKey);
233
+ if (r)
234
+ try {
235
+ Object.assign(this.store, JSON.parse(r));
236
+ } catch {
237
+ }
238
+ }
239
+ return new Proxy(this, {
232
240
  get: (r, s) => s in r ? r[s] : r.store[s],
233
241
  set: (r, s, i) => (s in r ? r[s] = i : r.store[s] = i, !0)
234
242
  });
@@ -272,7 +280,7 @@ class Gt {
272
280
  * @param {K} key Item's primary key
273
281
  */
274
282
  delete(t) {
275
- delete this.store[t];
283
+ delete this.store[t], this.options.storageKey && this.options.storage && this.options.storage.setItem(this.options.storageKey, JSON.stringify(this.store));
276
284
  }
277
285
  /**
278
286
  * Return cache as an array of key-value pairs
@@ -310,29 +318,29 @@ class Gt {
310
318
  *
311
319
  * @param {K} key Key item will be cached under
312
320
  * @param {T} value Item to cache
313
- * @param {number | undefined} ttl Override default expiry
321
+ * @param {number | undefined} ttl Override default expiry in seconds
314
322
  * @return {this}
315
323
  */
316
- set(t, e, r = this.ttl) {
317
- return this.store[t] = e, r && setTimeout(() => {
324
+ set(t, e, r = this.options.ttl) {
325
+ return this.store[t] = e, this.options.storageKey && this.options.storage && this.options.storage.setItem(this.options.storageKey, JSON.stringify(this.store)), r && setTimeout(() => {
318
326
  this.complete = !1, this.delete(t);
319
- }, r), this;
327
+ }, r * 1e3), this;
320
328
  }
321
329
  }
322
- function Ut(n, t = !0) {
323
- const e = n.reduce((r, s) => (Object.keys(t ? J(s) : s).forEach((i) => {
330
+ function It(n, t = !0) {
331
+ const e = n.reduce((r, s) => (Object.keys(t ? H(s) : s).forEach((i) => {
324
332
  r.includes(i) || r.push(i);
325
333
  }), r), []);
326
334
  return [
327
335
  e.join(","),
328
336
  ...n.map((r) => e.map((s) => {
329
- const i = x(r, s), o = typeof i;
337
+ const i = B(r, s), o = typeof i;
330
338
  return o == "string" && i.includes(",") ? `"${i}"` : o == "object" ? `"${JSON.stringify(i)}"` : i;
331
339
  }).join(","))
332
340
  ].join(`
333
341
  `);
334
342
  }
335
- class O extends Promise {
343
+ class x extends Promise {
336
344
  constructor(e) {
337
345
  super((r, s) => e(
338
346
  (i) => r(i),
@@ -349,10 +357,10 @@ class O extends Promise {
349
357
  e != this._progress && (this._progress = e, this.listeners.forEach((r) => r(e)));
350
358
  }
351
359
  static from(e) {
352
- return e instanceof O ? e : new O((r, s) => e.then((...i) => r(...i)).catch((...i) => s(...i)));
360
+ return e instanceof x ? e : new x((r, s) => e.then((...i) => r(...i)).catch((...i) => s(...i)));
353
361
  }
354
362
  from(e) {
355
- const r = O.from(e);
363
+ const r = x.from(e);
356
364
  return this.onProgress((s) => r.progress = s), r;
357
365
  }
358
366
  onProgress(e) {
@@ -369,16 +377,16 @@ class O extends Promise {
369
377
  return this.from(super.finally(e));
370
378
  }
371
379
  }
372
- function qt(n, t) {
373
- n instanceof Blob || (n = new Blob(b(n)));
380
+ function Dt(n, t) {
381
+ n instanceof Blob || (n = new Blob(m(n)));
374
382
  const e = URL.createObjectURL(n);
375
- pt(e, t), URL.revokeObjectURL(e);
383
+ lt(e, t), URL.revokeObjectURL(e);
376
384
  }
377
- function pt(n, t) {
385
+ function lt(n, t) {
378
386
  const e = document.createElement("a");
379
387
  e.href = n, e.download = t || n.split("/").pop(), document.body.appendChild(e), e.click(), document.body.removeChild(e);
380
388
  }
381
- function Ft(n = {}) {
389
+ function Mt(n = {}) {
382
390
  return new Promise((t) => {
383
391
  const e = document.createElement("input");
384
392
  e.type = "file", e.accept = n.accept || "*", e.style.display = "none", e.multiple = !!n.multiple, e.onblur = e.onchange = async () => {
@@ -386,18 +394,18 @@ function Ft(n = {}) {
386
394
  }, document.body.appendChild(e), e.click();
387
395
  });
388
396
  }
389
- function Yt(n, t = /* @__PURE__ */ new Date()) {
397
+ function kt(n, t = /* @__PURE__ */ new Date()) {
390
398
  (typeof t == "number" || typeof t == "string") && (t = new Date(t));
391
399
  const e = `${t.getFullYear()}-${(t.getMonth() + 1).toString().padStart(2, "0")}-${t.getDate().toString().padStart(2, "0")}_${t.getHours().toString().padStart(2, "0")}-${t.getMinutes().toString().padStart(2, "0")}-${t.getSeconds().toString().padStart(2, "0")}`;
392
400
  return n ? n.replace("{{TIMESTAMP}}", e) : e;
393
401
  }
394
- function Ht(n) {
395
- return new O((t, e, r) => {
402
+ function Pt(n) {
403
+ return new x((t, e, r) => {
396
404
  const s = new XMLHttpRequest(), i = new FormData();
397
- n.files.forEach((o) => i.append("file", o)), s.withCredentials = !!n.withCredentials, s.upload.addEventListener("progress", (o) => o.lengthComputable ? r(o.loaded / o.total) : null), s.addEventListener("loadend", () => t(k(s.responseText))), s.addEventListener("error", () => e(k(s.responseText))), s.addEventListener("timeout", () => e({ error: "Request timed out" })), s.open("POST", n.url), Object.entries(n.headers || {}).forEach(([o, u]) => s.setRequestHeader(o, u)), s.send(i);
405
+ n.files.forEach((o) => i.append("file", o)), s.withCredentials = !!n.withCredentials, s.upload.addEventListener("progress", (o) => o.lengthComputable ? r(o.loaded / o.total) : null), s.addEventListener("loadend", () => t(I(s.responseText))), s.addEventListener("error", () => e(I(s.responseText))), s.addEventListener("timeout", () => e({ error: "Request timed out" })), s.open("POST", n.url), Object.entries(n.headers || {}).forEach(([o, a]) => s.setRequestHeader(o, a)), s.send(i);
398
406
  });
399
407
  }
400
- class z {
408
+ class K {
401
409
  constructor() {
402
410
  c(this, "listeners", {});
403
411
  }
@@ -438,8 +446,8 @@ class z {
438
446
  });
439
447
  }
440
448
  }
441
- c(z, "listeners", {});
442
- class g extends Error {
449
+ c(K, "listeners", {});
450
+ class y extends Error {
443
451
  constructor(e, r) {
444
452
  super(e);
445
453
  c(this, "_code");
@@ -466,8 +474,8 @@ class g extends Error {
466
474
  return this.message || super.toString();
467
475
  }
468
476
  }
469
- c(g, "code", 500);
470
- class K extends g {
477
+ c(y, "code", 500);
478
+ class W extends y {
471
479
  constructor(t = "Bad Request") {
472
480
  super(t);
473
481
  }
@@ -475,8 +483,8 @@ class K extends g {
475
483
  return t.constructor.code == this.code;
476
484
  }
477
485
  }
478
- c(K, "code", 400);
479
- class Z extends g {
486
+ c(W, "code", 400);
487
+ class v extends y {
480
488
  constructor(t = "Unauthorized") {
481
489
  super(t);
482
490
  }
@@ -484,8 +492,8 @@ class Z extends g {
484
492
  return t.constructor.code == this.code;
485
493
  }
486
494
  }
487
- c(Z, "code", 401);
488
- class _ extends g {
495
+ c(v, "code", 401);
496
+ class J extends y {
489
497
  constructor(t = "Payment Required") {
490
498
  super(t);
491
499
  }
@@ -493,8 +501,8 @@ class _ extends g {
493
501
  return t.constructor.code == this.code;
494
502
  }
495
503
  }
496
- c(_, "code", 402);
497
- class V extends g {
504
+ c(J, "code", 402);
505
+ class z extends y {
498
506
  constructor(t = "Forbidden") {
499
507
  super(t);
500
508
  }
@@ -502,8 +510,8 @@ class V extends g {
502
510
  return t.constructor.code == this.code;
503
511
  }
504
512
  }
505
- c(V, "code", 403);
506
- class X extends g {
513
+ c(z, "code", 403);
514
+ class Z extends y {
507
515
  constructor(t = "Not Found") {
508
516
  super(t);
509
517
  }
@@ -511,8 +519,8 @@ class X extends g {
511
519
  return t.constructor.code == this.code;
512
520
  }
513
521
  }
514
- c(X, "code", 404);
515
- class Q extends g {
522
+ c(Z, "code", 404);
523
+ class V extends y {
516
524
  constructor(t = "Method Not Allowed") {
517
525
  super(t);
518
526
  }
@@ -520,8 +528,8 @@ class Q extends g {
520
528
  return t.constructor.code == this.code;
521
529
  }
522
530
  }
523
- c(Q, "code", 405);
524
- class tt extends g {
531
+ c(V, "code", 405);
532
+ class X extends y {
525
533
  constructor(t = "Not Acceptable") {
526
534
  super(t);
527
535
  }
@@ -529,8 +537,8 @@ class tt extends g {
529
537
  return t.constructor.code == this.code;
530
538
  }
531
539
  }
532
- c(tt, "code", 406);
533
- class et extends g {
540
+ c(X, "code", 406);
541
+ class Q extends y {
534
542
  constructor(t = "Internal Server Error") {
535
543
  super(t);
536
544
  }
@@ -538,8 +546,8 @@ class et extends g {
538
546
  return t.constructor.code == this.code;
539
547
  }
540
548
  }
541
- c(et, "code", 500);
542
- class nt extends g {
549
+ c(Q, "code", 500);
550
+ class _ extends y {
543
551
  constructor(t = "Not Implemented") {
544
552
  super(t);
545
553
  }
@@ -547,8 +555,8 @@ class nt extends g {
547
555
  return t.constructor.code == this.code;
548
556
  }
549
557
  }
550
- c(nt, "code", 501);
551
- class rt extends g {
558
+ c(_, "code", 501);
559
+ class tt extends y {
552
560
  constructor(t = "Bad Gateway") {
553
561
  super(t);
554
562
  }
@@ -556,8 +564,8 @@ class rt extends g {
556
564
  return t.constructor.code == this.code;
557
565
  }
558
566
  }
559
- c(rt, "code", 502);
560
- class st extends g {
567
+ c(tt, "code", 502);
568
+ class et extends y {
561
569
  constructor(t = "Service Unavailable") {
562
570
  super(t);
563
571
  }
@@ -565,8 +573,8 @@ class st extends g {
565
573
  return t.constructor.code == this.code;
566
574
  }
567
575
  }
568
- c(st, "code", 503);
569
- class it extends g {
576
+ c(et, "code", 503);
577
+ class nt extends y {
570
578
  constructor(t = "Gateway Timeout") {
571
579
  super(t);
572
580
  }
@@ -574,49 +582,49 @@ class it extends g {
574
582
  return t.constructor.code == this.code;
575
583
  }
576
584
  }
577
- c(it, "code", 504);
578
- function Wt(n, t) {
585
+ c(nt, "code", 504);
586
+ function Gt(n, t) {
579
587
  if (n >= 200 && n < 300) return null;
580
588
  switch (n) {
581
589
  case 400:
582
- return new K(t);
590
+ return new W(t);
583
591
  case 401:
584
- return new Z(t);
592
+ return new v(t);
585
593
  case 402:
586
- return new _(t);
594
+ return new J(t);
587
595
  case 403:
588
- return new V(t);
596
+ return new z(t);
589
597
  case 404:
590
- return new X(t);
598
+ return new Z(t);
591
599
  case 405:
592
- return new Q(t);
600
+ return new V(t);
593
601
  case 406:
594
- return new tt(t);
602
+ return new X(t);
595
603
  case 500:
596
- return new et(t);
604
+ return new Q(t);
597
605
  case 501:
598
- return new nt(t);
606
+ return new _(t);
599
607
  case 502:
600
- return new rt(t);
608
+ return new tt(t);
601
609
  case 503:
602
- return new st(t);
610
+ return new et(t);
603
611
  case 504:
604
- return new it(t);
612
+ return new nt(t);
605
613
  default:
606
- return new g(t, n);
614
+ return new y(t, n);
607
615
  }
608
616
  }
609
- const m = class m {
617
+ const E = class E {
610
618
  constructor(t = {}) {
611
619
  c(this, "interceptors", {});
612
620
  c(this, "headers", {});
613
621
  c(this, "url");
614
- this.url = t.url ?? null, this.headers = t.headers || {}, t.interceptors && t.interceptors.forEach((e) => m.addInterceptor(e));
622
+ this.url = t.url ?? null, this.headers = t.headers || {}, t.interceptors && t.interceptors.forEach((e) => E.addInterceptor(e));
615
623
  }
616
624
  static addInterceptor(t) {
617
- const e = Object.keys(m.interceptors).length.toString();
618
- return m.interceptors[e] = t, () => {
619
- m.interceptors[e] = null;
625
+ const e = Object.keys(E.interceptors).length.toString();
626
+ return E.interceptors[e] = t, () => {
627
+ E.interceptors[e] = null;
620
628
  };
621
629
  }
622
630
  addInterceptor(t) {
@@ -633,52 +641,52 @@ const m = class m {
633
641
  const i = Array.isArray(t.query) ? t.query : Object.keys(t.query).map((o) => ({ key: o, value: t.query[o] }));
634
642
  e += (e.includes("?") ? "&" : "?") + i.map((o) => `${o.key}=${o.value}`).join("&");
635
643
  }
636
- const r = lt({
644
+ const r = ot({
637
645
  "Content-Type": t.body ? t.body instanceof FormData ? "multipart/form-data" : "application/json" : void 0,
638
- ...m.headers,
646
+ ...E.headers,
639
647
  ...this.headers,
640
648
  ...t.headers
641
649
  });
642
- return typeof t.body == "object" && t.body != null && r["Content-Type"] == "application/json" && (t.body = JSON.stringify(t.body)), new O((i, o, u) => {
650
+ return typeof t.body == "object" && t.body != null && r["Content-Type"] == "application/json" && (t.body = JSON.stringify(t.body)), new x((i, o, a) => {
643
651
  fetch(e, {
644
652
  headers: r,
645
653
  method: t.method || (t.body ? "POST" : "GET"),
646
654
  body: t.body
647
- }).then(async (a) => {
648
- var q, F;
649
- for (let l of [...Object.values(m.interceptors), ...Object.values(this.interceptors)])
650
- await new Promise((C) => l(a, () => C()));
651
- const R = a.headers.get("Content-Length"), T = R ? parseInt(R, 10) : 0;
652
- let U = 0;
653
- const M = (q = a.body) == null ? void 0 : q.getReader(), ct = new ReadableStream({
655
+ }).then(async (u) => {
656
+ var G, U;
657
+ for (let l of [...Object.values(E.interceptors), ...Object.values(this.interceptors)])
658
+ await new Promise((C) => l(u, () => C()));
659
+ const $ = u.headers.get("Content-Length"), N = $ ? parseInt($, 10) : 0;
660
+ let P = 0;
661
+ const T = (G = u.body) == null ? void 0 : G.getReader(), rt = new ReadableStream({
654
662
  start(l) {
655
663
  function C() {
656
- M == null || M.read().then((A) => {
664
+ T == null || T.read().then((A) => {
657
665
  if (A.done) return l.close();
658
- U += A.value.byteLength, u(U / T), l.enqueue(A.value), C();
666
+ P += A.value.byteLength, a(P / N), l.enqueue(A.value), C();
659
667
  }).catch((A) => l.error(A));
660
668
  }
661
669
  C();
662
670
  }
663
671
  });
664
- if (a.data = new Response(ct), t.decode == null || t.decode) {
665
- const l = (F = a.headers.get("Content-Type")) == null ? void 0 : F.toLowerCase();
666
- l != null && l.includes("form") ? a.data = await a.data.formData() : l != null && l.includes("json") ? a.data = await a.data.json() : l != null && l.includes("text") ? a.data = await a.data.text() : l != null && l.includes("application") && (a.data = await a.data.blob());
672
+ if (u.data = new Response(rt), t.decode == null || t.decode) {
673
+ const l = (U = u.headers.get("Content-Type")) == null ? void 0 : U.toLowerCase();
674
+ l != null && l.includes("form") ? u.data = await u.data.formData() : l != null && l.includes("json") ? u.data = await u.data.json() : l != null && l.includes("text") ? u.data = await u.data.text() : l != null && l.includes("application") && (u.data = await u.data.blob());
667
675
  }
668
- a.ok ? i(a) : o(a);
676
+ u.ok ? i(u) : o(u);
669
677
  });
670
678
  });
671
679
  }
672
680
  };
673
- c(m, "interceptors", {}), c(m, "headers", {});
674
- let H = m;
675
- function Jt(n) {
681
+ c(E, "interceptors", {}), c(E, "headers", {});
682
+ let F = E;
683
+ function Ut(n) {
676
684
  const t = n.split(".")[1].replace(/-/g, "+").replace(/_/g, "/");
677
- return k(decodeURIComponent(atob(t).split("").map(function(e) {
685
+ return I(decodeURIComponent(atob(t).split("").map(function(e) {
678
686
  return "%" + ("00" + e.charCodeAt(0).toString(16)).slice(-2);
679
687
  }).join("")));
680
688
  }
681
- const j = {
689
+ const R = {
682
690
  CLEAR: "\x1B[0m",
683
691
  BRIGHT: "\x1B[1m",
684
692
  DIM: "\x1B[2m",
@@ -703,7 +711,7 @@ const j = {
703
711
  LIGHT_MAGENTA: "\x1B[95m",
704
712
  LIGHT_CYAN: "\x1B[96m",
705
713
  WHITE: "\x1B[97m"
706
- }, zt = {
714
+ }, qt = {
707
715
  BLACK: "\x1B[40m",
708
716
  RED: "\x1B[41m",
709
717
  GREEN: "\x1B[42m",
@@ -714,16 +722,16 @@ const j = {
714
722
  WHITE: "\x1B[47m",
715
723
  GREY: "\x1B[100m"
716
724
  };
717
- var yt = /* @__PURE__ */ ((n) => (n[n.ERROR = 0] = "ERROR", n[n.WARN = 1] = "WARN", n[n.INFO = 2] = "INFO", n[n.LOG = 3] = "LOG", n[n.DEBUG = 4] = "DEBUG", n))(yt || {});
718
- const w = class w extends z {
725
+ var ft = /* @__PURE__ */ ((n) => (n[n.ERROR = 0] = "ERROR", n[n.WARN = 1] = "WARN", n[n.INFO = 2] = "INFO", n[n.LOG = 3] = "LOG", n[n.DEBUG = 4] = "DEBUG", n))(ft || {});
726
+ const w = class w extends K {
719
727
  constructor(t) {
720
728
  super(), this.namespace = t;
721
729
  }
722
730
  pad(t, e, r, s = !1) {
723
731
  const i = t.toString(), o = e - i.length;
724
732
  if (o <= 0) return i;
725
- const u = Array(~~(o / r.length)).fill(r).join("");
726
- return s ? i + u : u + i;
733
+ const a = Array(~~(o / r.length)).fill(r).join("");
734
+ return s ? i + a : a + i;
727
735
  }
728
736
  format(...t) {
729
737
  const e = /* @__PURE__ */ new Date();
@@ -732,82 +740,82 @@ const w = class w extends z {
732
740
  debug(...t) {
733
741
  if (w.LOG_LEVEL < 4) return;
734
742
  const e = this.format(...t);
735
- w.emit(4, e), console.debug(L.LIGHT_GREY + e + j.CLEAR);
743
+ w.emit(4, e), console.debug(L.LIGHT_GREY + e + R.CLEAR);
736
744
  }
737
745
  log(...t) {
738
746
  if (w.LOG_LEVEL < 3) return;
739
747
  const e = this.format(...t);
740
- w.emit(3, e), console.log(j.CLEAR + e);
748
+ w.emit(3, e), console.log(R.CLEAR + e);
741
749
  }
742
750
  info(...t) {
743
751
  if (w.LOG_LEVEL < 2) return;
744
752
  const e = this.format(...t);
745
- w.emit(2, e), console.info(L.BLUE + e + j.CLEAR);
753
+ w.emit(2, e), console.info(L.BLUE + e + R.CLEAR);
746
754
  }
747
755
  warn(...t) {
748
756
  if (w.LOG_LEVEL < 1) return;
749
757
  const e = this.format(...t);
750
- w.emit(1, e), console.warn(L.YELLOW + e + j.CLEAR);
758
+ w.emit(1, e), console.warn(L.YELLOW + e + R.CLEAR);
751
759
  }
752
760
  error(...t) {
753
761
  if (w.LOG_LEVEL < 0) return;
754
762
  const e = this.format(...t);
755
- w.emit(0, e), console.error(L.RED + e + j.CLEAR);
763
+ w.emit(0, e), console.error(L.RED + e + R.CLEAR);
756
764
  }
757
765
  };
758
766
  c(w, "LOG_LEVEL", 4);
759
- let W = w;
760
- function Kt(n) {
761
- const t = (u, a) => a < 1e-7 ? u : t(a, ~~(u % a)), e = n.toString().length - 2;
767
+ let Y = w;
768
+ function Ft(n) {
769
+ const t = (a, u) => u < 1e-7 ? a : t(u, ~~(a % u)), e = n.toString().length - 2;
762
770
  let r = Math.pow(10, e), s = n * r;
763
771
  const i = t(s, r);
764
772
  s = ~~(s / i), r = ~~(r / i);
765
773
  const o = ~~(s / r);
766
774
  return s -= o * r, `${o ? o + " " : ""}${~~s}/${~~r}`;
767
775
  }
768
- function Zt(n) {
776
+ function Yt(n) {
769
777
  let t = n.split(" ");
770
778
  const e = t.length == 2 ? Number(t[0]) : 0;
771
779
  return t = t.pop().split("/"), e + Number(t[0]) / Number(t[1]);
772
780
  }
773
- const P = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", D = "0123456789", G = "~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/", gt = P + D + G;
774
- function _t(n, t = 2) {
781
+ const D = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", M = "0123456789", k = "~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/", ht = D + M + k;
782
+ function Ht(n, t = 2) {
775
783
  if (n === 0) return "0 Bytes";
776
784
  const e = 1024, r = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], s = Math.floor(Math.log(n) / Math.log(e));
777
785
  return parseFloat((n / Math.pow(e, s)).toFixed(t)) + " " + r[s];
778
786
  }
779
- function Vt(n) {
787
+ function Kt(n) {
780
788
  const t = /(\+?1)?.*?(\d{3}).*?(\d{3}).*?(\d{4})/g.exec(n);
781
789
  if (!t) throw new Error(`Number cannot be parsed: ${n}`);
782
790
  return `${t[1] ?? ""} (${t[2]}) ${t[3]}-${t[4]}`.trim();
783
791
  }
784
- function Xt(n, t, e) {
792
+ function Wt(n, t, e) {
785
793
  return `${n.slice(0, e)}${t}${n.slice(e + 1)}`;
786
794
  }
787
- function Qt(n, t, e = " ", r = !0) {
795
+ function vt(n, t, e = " ", r = !0) {
788
796
  return r ? n.toString().padStart(t, e) : n.toString().padEnd(t, e);
789
797
  }
790
- function te(n) {
798
+ function Jt(n) {
791
799
  return Array(n).fill(null).map(() => Math.round(Math.random() * 15).toString(16)).join("");
792
800
  }
793
- function ee(n, t = gt) {
801
+ function zt(n, t = ht) {
794
802
  return Array(n).fill(null).map(() => {
795
803
  const e = ~~(Math.random() * t.length);
796
804
  return t[e];
797
805
  }).join("");
798
806
  }
799
- function ne(n, t = !1, e = !1, r = !1) {
807
+ function Zt(n, t = !1, e = !1, r = !1) {
800
808
  if (!t && !e && !r) throw new Error("Must enable at least one: letters, numbers, symbols");
801
809
  return Array(n).fill(null).map(() => {
802
810
  let s;
803
811
  do {
804
812
  const i = ~~(Math.random() * 3);
805
- t && i == 0 ? s = P[~~(Math.random() * P.length)] : e && i == 1 ? s = D[~~(Math.random() * D.length)] : r && i == 2 && (s = G[~~(Math.random() * G.length)]);
813
+ t && i == 0 ? s = D[~~(Math.random() * D.length)] : e && i == 1 ? s = M[~~(Math.random() * M.length)] : r && i == 2 && (s = k[~~(Math.random() * k.length)]);
806
814
  } while (!s);
807
815
  return s;
808
816
  }).join("");
809
817
  }
810
- function re(n, t) {
818
+ function Vt(n, t) {
811
819
  if (typeof t == "string" && (t = new RegExp(t, "g")), !t.global)
812
820
  throw new TypeError("Regular expression must be global.");
813
821
  let e = [], r;
@@ -815,7 +823,7 @@ function re(n, t) {
815
823
  e.push(r);
816
824
  return e;
817
825
  }
818
- function se(n) {
826
+ function Xt(n) {
819
827
  const t = new RegExp(
820
828
  "(?:(?<protocol>[\\w\\d]+)\\:\\/\\/)?(?:(?<user>.+)\\@)?(?<host>(?<domain>[^:\\/\\?#@\\n]+)(?:\\:(?<port>\\d*))?)(?<path>\\/.*?)?(?:\\?(?<query>.*?))?(?:#(?<fragment>.*?))?$",
821
829
  "gm"
@@ -823,82 +831,82 @@ function se(n) {
823
831
  if (e.port != null && (e.port = Number(e.port)), r.length > 2 && (e.domain = r.splice(-2, 2).join("."), e.subdomain = r.join(".")), e.query) {
824
832
  const s = e.query.split("&"), i = {};
825
833
  s.forEach((o) => {
826
- const [u, a] = o.split("=");
827
- i[u] = a;
834
+ const [a, u] = o.split("=");
835
+ i[a] = u;
828
836
  }), e.query = i;
829
837
  }
830
838
  return e;
831
839
  }
832
- function wt(n) {
833
- var t = mt(Et(St(bt(n), 8 * n.length)));
840
+ function dt(n) {
841
+ var t = pt(yt(wt(gt(n), 8 * n.length)));
834
842
  return t.toLowerCase();
835
843
  }
836
- function mt(n) {
844
+ function pt(n) {
837
845
  for (var t, e = "0123456789ABCDEF", r = "", s = 0; s < n.length; s++) t = n.charCodeAt(s), r += e.charAt(t >>> 4 & 15) + e.charAt(15 & t);
838
846
  return r;
839
847
  }
840
- function bt(n) {
848
+ function gt(n) {
841
849
  for (var t = Array(n.length >> 2), e = 0; e < t.length; e++) t[e] = 0;
842
850
  for (e = 0; e < 8 * n.length; e += 8) t[e >> 5] |= (255 & n.charCodeAt(e / 8)) << e % 32;
843
851
  return t;
844
852
  }
845
- function Et(n) {
853
+ function yt(n) {
846
854
  for (var t = "", e = 0; e < 32 * n.length; e += 8) t += String.fromCharCode(n[e >> 5] >>> e % 32 & 255);
847
855
  return t;
848
856
  }
849
- function St(n, t) {
857
+ function wt(n, t) {
850
858
  n[t >> 5] |= 128 << t % 32, n[14 + (t + 64 >>> 9 << 4)] = t;
851
859
  for (var e = 1732584193, r = -271733879, s = -1732584194, i = 271733878, o = 0; o < n.length; o += 16) {
852
- var u = e, a = r, R = s, T = i;
853
- r = p(r = p(r = p(r = p(r = d(r = d(r = d(r = d(r = h(r = h(r = h(r = h(r = f(r = f(r = f(r = f(r, s = f(s, i = f(i, e = f(e, r, s, i, n[o + 0], 7, -680876936), r, s, n[o + 1], 12, -389564586), e, r, n[o + 2], 17, 606105819), i, e, n[o + 3], 22, -1044525330), s = f(s, i = f(i, e = f(e, r, s, i, n[o + 4], 7, -176418897), r, s, n[o + 5], 12, 1200080426), e, r, n[o + 6], 17, -1473231341), i, e, n[o + 7], 22, -45705983), s = f(s, i = f(i, e = f(e, r, s, i, n[o + 8], 7, 1770035416), r, s, n[o + 9], 12, -1958414417), e, r, n[o + 10], 17, -42063), i, e, n[o + 11], 22, -1990404162), s = f(s, i = f(i, e = f(e, r, s, i, n[o + 12], 7, 1804603682), r, s, n[o + 13], 12, -40341101), e, r, n[o + 14], 17, -1502002290), i, e, n[o + 15], 22, 1236535329), s = h(s, i = h(i, e = h(e, r, s, i, n[o + 1], 5, -165796510), r, s, n[o + 6], 9, -1069501632), e, r, n[o + 11], 14, 643717713), i, e, n[o + 0], 20, -373897302), s = h(s, i = h(i, e = h(e, r, s, i, n[o + 5], 5, -701558691), r, s, n[o + 10], 9, 38016083), e, r, n[o + 15], 14, -660478335), i, e, n[o + 4], 20, -405537848), s = h(s, i = h(i, e = h(e, r, s, i, n[o + 9], 5, 568446438), r, s, n[o + 14], 9, -1019803690), e, r, n[o + 3], 14, -187363961), i, e, n[o + 8], 20, 1163531501), s = h(s, i = h(i, e = h(e, r, s, i, n[o + 13], 5, -1444681467), r, s, n[o + 2], 9, -51403784), e, r, n[o + 7], 14, 1735328473), i, e, n[o + 12], 20, -1926607734), s = d(s, i = d(i, e = d(e, r, s, i, n[o + 5], 4, -378558), r, s, n[o + 8], 11, -2022574463), e, r, n[o + 11], 16, 1839030562), i, e, n[o + 14], 23, -35309556), s = d(s, i = d(i, e = d(e, r, s, i, n[o + 1], 4, -1530992060), r, s, n[o + 4], 11, 1272893353), e, r, n[o + 7], 16, -155497632), i, e, n[o + 10], 23, -1094730640), s = d(s, i = d(i, e = d(e, r, s, i, n[o + 13], 4, 681279174), r, s, n[o + 0], 11, -358537222), e, r, n[o + 3], 16, -722521979), i, e, n[o + 6], 23, 76029189), s = d(s, i = d(i, e = d(e, r, s, i, n[o + 9], 4, -640364487), r, s, n[o + 12], 11, -421815835), e, r, n[o + 15], 16, 530742520), i, e, n[o + 2], 23, -995338651), s = p(s, i = p(i, e = p(e, r, s, i, n[o + 0], 6, -198630844), r, s, n[o + 7], 10, 1126891415), e, r, n[o + 14], 15, -1416354905), i, e, n[o + 5], 21, -57434055), s = p(s, i = p(i, e = p(e, r, s, i, n[o + 12], 6, 1700485571), r, s, n[o + 3], 10, -1894986606), e, r, n[o + 10], 15, -1051523), i, e, n[o + 1], 21, -2054922799), s = p(s, i = p(i, e = p(e, r, s, i, n[o + 8], 6, 1873313359), r, s, n[o + 15], 10, -30611744), e, r, n[o + 6], 15, -1560198380), i, e, n[o + 13], 21, 1309151649), s = p(s, i = p(i, e = p(e, r, s, i, n[o + 4], 6, -145523070), r, s, n[o + 11], 10, -1120210379), e, r, n[o + 2], 15, 718787259), i, e, n[o + 9], 21, -343485551), e = S(e, u), r = S(r, a), s = S(s, R), i = S(i, T);
860
+ var a = e, u = r, $ = s, N = i;
861
+ r = p(r = p(r = p(r = p(r = d(r = d(r = d(r = d(r = h(r = h(r = h(r = h(r = f(r = f(r = f(r = f(r, s = f(s, i = f(i, e = f(e, r, s, i, n[o + 0], 7, -680876936), r, s, n[o + 1], 12, -389564586), e, r, n[o + 2], 17, 606105819), i, e, n[o + 3], 22, -1044525330), s = f(s, i = f(i, e = f(e, r, s, i, n[o + 4], 7, -176418897), r, s, n[o + 5], 12, 1200080426), e, r, n[o + 6], 17, -1473231341), i, e, n[o + 7], 22, -45705983), s = f(s, i = f(i, e = f(e, r, s, i, n[o + 8], 7, 1770035416), r, s, n[o + 9], 12, -1958414417), e, r, n[o + 10], 17, -42063), i, e, n[o + 11], 22, -1990404162), s = f(s, i = f(i, e = f(e, r, s, i, n[o + 12], 7, 1804603682), r, s, n[o + 13], 12, -40341101), e, r, n[o + 14], 17, -1502002290), i, e, n[o + 15], 22, 1236535329), s = h(s, i = h(i, e = h(e, r, s, i, n[o + 1], 5, -165796510), r, s, n[o + 6], 9, -1069501632), e, r, n[o + 11], 14, 643717713), i, e, n[o + 0], 20, -373897302), s = h(s, i = h(i, e = h(e, r, s, i, n[o + 5], 5, -701558691), r, s, n[o + 10], 9, 38016083), e, r, n[o + 15], 14, -660478335), i, e, n[o + 4], 20, -405537848), s = h(s, i = h(i, e = h(e, r, s, i, n[o + 9], 5, 568446438), r, s, n[o + 14], 9, -1019803690), e, r, n[o + 3], 14, -187363961), i, e, n[o + 8], 20, 1163531501), s = h(s, i = h(i, e = h(e, r, s, i, n[o + 13], 5, -1444681467), r, s, n[o + 2], 9, -51403784), e, r, n[o + 7], 14, 1735328473), i, e, n[o + 12], 20, -1926607734), s = d(s, i = d(i, e = d(e, r, s, i, n[o + 5], 4, -378558), r, s, n[o + 8], 11, -2022574463), e, r, n[o + 11], 16, 1839030562), i, e, n[o + 14], 23, -35309556), s = d(s, i = d(i, e = d(e, r, s, i, n[o + 1], 4, -1530992060), r, s, n[o + 4], 11, 1272893353), e, r, n[o + 7], 16, -155497632), i, e, n[o + 10], 23, -1094730640), s = d(s, i = d(i, e = d(e, r, s, i, n[o + 13], 4, 681279174), r, s, n[o + 0], 11, -358537222), e, r, n[o + 3], 16, -722521979), i, e, n[o + 6], 23, 76029189), s = d(s, i = d(i, e = d(e, r, s, i, n[o + 9], 4, -640364487), r, s, n[o + 12], 11, -421815835), e, r, n[o + 15], 16, 530742520), i, e, n[o + 2], 23, -995338651), s = p(s, i = p(i, e = p(e, r, s, i, n[o + 0], 6, -198630844), r, s, n[o + 7], 10, 1126891415), e, r, n[o + 14], 15, -1416354905), i, e, n[o + 5], 21, -57434055), s = p(s, i = p(i, e = p(e, r, s, i, n[o + 12], 6, 1700485571), r, s, n[o + 3], 10, -1894986606), e, r, n[o + 10], 15, -1051523), i, e, n[o + 1], 21, -2054922799), s = p(s, i = p(i, e = p(e, r, s, i, n[o + 8], 6, 1873313359), r, s, n[o + 15], 10, -30611744), e, r, n[o + 6], 15, -1560198380), i, e, n[o + 13], 21, 1309151649), s = p(s, i = p(i, e = p(e, r, s, i, n[o + 4], 6, -145523070), r, s, n[o + 11], 10, -1120210379), e, r, n[o + 2], 15, 718787259), i, e, n[o + 9], 21, -343485551), e = b(e, a), r = b(r, u), s = b(s, $), i = b(i, N);
854
862
  }
855
863
  return Array(e, r, s, i);
856
864
  }
857
- function N(n, t, e, r, s, i) {
858
- return S(Ot(S(S(t, n), S(r, i)), s), e);
865
+ function j(n, t, e, r, s, i) {
866
+ return b(Et(b(b(t, n), b(r, i)), s), e);
859
867
  }
860
868
  function f(n, t, e, r, s, i, o) {
861
- return N(t & e | ~t & r, n, t, s, i, o);
869
+ return j(t & e | ~t & r, n, t, s, i, o);
862
870
  }
863
871
  function h(n, t, e, r, s, i, o) {
864
- return N(t & r | e & ~r, n, t, s, i, o);
872
+ return j(t & r | e & ~r, n, t, s, i, o);
865
873
  }
866
874
  function d(n, t, e, r, s, i, o) {
867
- return N(t ^ e ^ r, n, t, s, i, o);
875
+ return j(t ^ e ^ r, n, t, s, i, o);
868
876
  }
869
877
  function p(n, t, e, r, s, i, o) {
870
- return N(e ^ (t | ~r), n, t, s, i, o);
878
+ return j(e ^ (t | ~r), n, t, s, i, o);
871
879
  }
872
- function S(n, t) {
880
+ function b(n, t) {
873
881
  var e = (65535 & n) + (65535 & t);
874
882
  return (n >> 16) + (t >> 16) + (e >> 16) << 16 | 65535 & e;
875
883
  }
876
- function Ot(n, t) {
884
+ function Et(n, t) {
877
885
  return n << t | n >>> 32 - t;
878
886
  }
879
- function ie(n) {
887
+ function Qt(n) {
880
888
  return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(n);
881
889
  }
882
- function oe(n, t = "mp") {
883
- return n ? `https://www.gravatar.com/avatar/${wt(n)}?d=${t}` : "";
890
+ function _t(n, t = "mp") {
891
+ return n ? `https://www.gravatar.com/avatar/${dt(n)}?d=${t}` : "";
884
892
  }
885
- function ce(n) {
893
+ function te(n) {
886
894
  return n.replace(/[.*+?^${}()|\[\]\\]/g, "\\$&");
887
895
  }
888
- function ue(n, ...t) {
896
+ function ee(n, ...t) {
889
897
  const e = [];
890
898
  for (let r = 0; r < n.length || r < t.length; r++)
891
899
  n[r] && e.push(n[r]), t[r] && e.push(t[r]);
892
- return new y(e.join(""));
900
+ return new g(e.join(""));
893
901
  }
894
- function xt(n, ...t) {
902
+ function mt(n, ...t) {
895
903
  let e = [];
896
904
  for (let i = 0; i < n.length || i < t.length; i++)
897
905
  n[i] && e.push(n[i]), t[i] && e.push(t[i]);
898
906
  const [r, s] = e.join("").split(":");
899
- return y.toString(r, s == null ? void 0 : s.split(""));
907
+ return g.toString(r, s == null ? void 0 : s.split(""));
900
908
  }
901
- class y {
909
+ class g {
902
910
  constructor(t) {
903
911
  /** First directory in path */
904
912
  c(this, "module");
@@ -926,7 +934,7 @@ class y {
926
934
  if (typeof t == "object") return Object.assign(this, t);
927
935
  let [e, r, s] = t.split(":");
928
936
  s || (s = r || "*"), (e == "*" || !e && s == "*") && (e = "", s = "*");
929
- let i = e.split("/").filter((u) => !!u);
937
+ let i = e.split("/").filter((a) => !!a);
930
938
  this.module = ((o = i.splice(0, 1)[0]) == null ? void 0 : o.toLowerCase()) || "", this.fullPath = e, this.path = i.join("/"), this.name = i.pop() || "", this.methods = s.split(""), this.all = s == null ? void 0 : s.includes("*"), this.none = s == null ? void 0 : s.includes("n"), this.create = !(s != null && s.includes("n")) && ((s == null ? void 0 : s.includes("*")) || (s == null ? void 0 : s.includes("w")) || (s == null ? void 0 : s.includes("c"))), this.read = !(s != null && s.includes("n")) && ((s == null ? void 0 : s.includes("*")) || (s == null ? void 0 : s.includes("r"))), this.update = !(s != null && s.includes("n")) && ((s == null ? void 0 : s.includes("*")) || (s == null ? void 0 : s.includes("w")) || (s == null ? void 0 : s.includes("u"))), this.delete = !(s != null && s.includes("n")) && ((s == null ? void 0 : s.includes("*")) || (s == null ? void 0 : s.includes("w")) || (s == null ? void 0 : s.includes("d")));
931
939
  }
932
940
  /**
@@ -938,11 +946,11 @@ class y {
938
946
  */
939
947
  static combine(t) {
940
948
  let e = !1;
941
- const r = t.map((s) => new y(s)).toSorted((s, i) => {
942
- const o = s.fullPath.length, u = i.fullPath.length;
943
- return o < u ? 1 : o > u ? -1 : 0;
949
+ const r = t.map((s) => new g(s)).toSorted((s, i) => {
950
+ const o = s.fullPath.length, a = i.fullPath.length;
951
+ return o < a ? 1 : o > a ? -1 : 0;
944
952
  }).reduce((s, i) => (i.none && (e = !0), s ? (e || (i.all && (s.all = !0), (i.all || i.create) && (s.create = !0), (i.all || i.read) && (s.read = !0), (i.all || i.update) && (s.update = !0), (i.all || i.delete) && (s.delete = !0), s.methods = [...s.methods, ...i.methods]), s) : i), null);
945
- return r.all && (r.methods = ["*"]), r.none && (r.methods = ["n"]), r.methods = new E(r.methods), r.raw = xt`${r.fullPath}:${r.methods}`, r;
953
+ return r.all && (r.methods = ["*"]), r.none && (r.methods = ["n"]), r.methods = new S(r.methods), r.raw = mt`${r.fullPath}:${r.methods}`, r;
946
954
  }
947
955
  /**
948
956
  * Squash 2 sets of paths & return true if any overlap is found
@@ -952,13 +960,13 @@ class y {
952
960
  * @return {boolean} Whether there is any overlap
953
961
  */
954
962
  static has(t, ...e) {
955
- const r = b(e).map((i) => new y(i)), s = b(t).map((i) => new y(i));
963
+ const r = m(e).map((i) => new g(i)), s = m(t).map((i) => new g(i));
956
964
  return !!r.find((i) => {
957
965
  if (!i.fullPath && i.all) return !0;
958
- const o = s.filter((a) => i.fullPath.startsWith(a.fullPath));
966
+ const o = s.filter((u) => i.fullPath.startsWith(u.fullPath));
959
967
  if (!o.length) return !1;
960
- const u = y.combine(o);
961
- return !u.none && (u.all || new E(u.methods).intersection(new E(i.methods)).length);
968
+ const a = g.combine(o);
969
+ return !a.none && (a.all || new S(a.methods).intersection(new S(i.methods)).length);
962
970
  });
963
971
  }
964
972
  /**
@@ -969,7 +977,7 @@ class y {
969
977
  * @return {boolean} Whether there is any overlap
970
978
  */
971
979
  static hasAll(t, ...e) {
972
- return e.filter((r) => y.has(t, r)).length == e.length;
980
+ return e.filter((r) => g.has(t, r)).length == e.length;
973
981
  }
974
982
  /**
975
983
  * Same as `has` but raises an error if there is no overlap
@@ -978,7 +986,7 @@ class y {
978
986
  * @param has Target must have at least one of these path
979
987
  */
980
988
  static hasFatal(t, ...e) {
981
- if (!y.has(t, ...e)) throw new Error(`Requires one of: ${b(e).join(", ")}`);
989
+ if (!g.has(t, ...e)) throw new Error(`Requires one of: ${m(e).join(", ")}`);
982
990
  }
983
991
  /**
984
992
  * Same as `hasAll` but raises an error if the target is missing any paths
@@ -987,7 +995,7 @@ class y {
987
995
  * @param has Target must have all these paths
988
996
  */
989
997
  static hasAllFatal(t, ...e) {
990
- if (!y.hasAll(t, ...e)) throw new Error(`Requires all: ${b(e).join(", ")}`);
998
+ if (!g.hasAll(t, ...e)) throw new Error(`Requires all: ${m(e).join(", ")}`);
991
999
  }
992
1000
  /**
993
1001
  * Create event string from its components
@@ -997,8 +1005,8 @@ class y {
997
1005
  * @return {string} String representation of Event
998
1006
  */
999
1007
  static toString(t, e) {
1000
- let r = b(t).filter((s) => s != null).join("/");
1001
- return e != null && e.length && (r += `:${b(e).map((s) => s.toLowerCase()).join("")}`), r == null ? void 0 : r.trim().replaceAll(/\/{2,}/g, "/").replaceAll(/(^\/|\/$)/g, "");
1008
+ let r = m(t).filter((s) => s != null).join("/");
1009
+ return e != null && e.length && (r += `:${m(e).map((s) => s.toLowerCase()).join("")}`), r == null ? void 0 : r.trim().replaceAll(/\/{2,}/g, "/").replaceAll(/(^\/|\/$)/g, "");
1002
1010
  }
1003
1011
  /**
1004
1012
  * Create event string from its components
@@ -1006,22 +1014,22 @@ class y {
1006
1014
  * @return {string} String representation of Event
1007
1015
  */
1008
1016
  toString() {
1009
- return y.toString(this.fullPath, this.methods);
1017
+ return g.toString(this.fullPath, this.methods);
1010
1018
  }
1011
1019
  }
1012
- class ae {
1020
+ class ne {
1013
1021
  constructor() {
1014
1022
  c(this, "listeners", []);
1015
1023
  }
1016
1024
  emit(t, ...e) {
1017
- const r = new y(t);
1018
- this.listeners.filter((s) => y.has(s[0], t)).forEach(async (s) => s[1](r, ...e));
1025
+ const r = new g(t);
1026
+ this.listeners.filter((s) => g.has(s[0], t)).forEach(async (s) => s[1](r, ...e));
1019
1027
  }
1020
1028
  off(t) {
1021
1029
  this.listeners = this.listeners.filter((e) => e[1] != t);
1022
1030
  }
1023
1031
  on(t, e) {
1024
- return b(t).forEach((r) => this.listeners.push([new y(r), e])), () => this.off(e);
1032
+ return m(t).forEach((r) => this.listeners.push([new g(r), e])), () => this.off(e);
1025
1033
  }
1026
1034
  once(t, e) {
1027
1035
  return new Promise((r) => {
@@ -1034,234 +1042,98 @@ class ae {
1034
1042
  t.on("*", (e, ...r) => this.emit(e, ...r));
1035
1043
  }
1036
1044
  }
1037
- function le(n) {
1045
+ function re(n) {
1038
1046
  (typeof n == "number" || typeof n == "string") && (n = new Date(n));
1039
1047
  let t = n.getHours(), e = "AM";
1040
1048
  return t >= 12 ? (t > 12 && (t -= 12), e = "PM") : t == 0 && (t = 12), `${n.getFullYear()}-${(n.getMonth() + 1).toString().padStart(2, "0")}-${n.getDate().toString().padStart(2, "0")}, ${t}:${n.getMinutes().toString().padStart(2, "0")} ${e}`;
1041
1049
  }
1042
- function Bt(n) {
1050
+ function St(n) {
1043
1051
  return new Promise((t) => setTimeout(t, n));
1044
1052
  }
1045
- async function fe(n, t = 100) {
1046
- for (; await n(); ) await Bt(t);
1053
+ async function se(n, t = 100) {
1054
+ for (; await n(); ) await St(t);
1047
1055
  }
1048
- function he(n) {
1056
+ function ie(n) {
1049
1057
  return (n instanceof Date ? n.getTime() : n) - (/* @__PURE__ */ new Date()).getTime();
1050
1058
  }
1051
- function de() {
1059
+ function oe() {
1052
1060
  return Object.keys({});
1053
1061
  }
1054
- var v = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, At = {}, B = {};
1055
- Object.defineProperty(B, "__esModule", { value: !0 });
1056
- B.persist = B.Persist = void 0;
1057
- class ot {
1058
- /**
1059
- * @param {string} key Primary key value will be stored under
1060
- * @param {PersistOptions<T>} options Configure using {@link PersistOptions}
1061
- */
1062
- constructor(t, e = {}) {
1063
- c(this, "key");
1064
- c(this, "options");
1065
- /** Backend service to store data, must implement `Storage` interface */
1066
- c(this, "storage");
1067
- /** Listeners which should be notified on changes */
1068
- c(this, "watches", {});
1069
- /** Private value field */
1070
- c(this, "_value");
1071
- this.key = t, this.options = e, this.storage = e.storage || localStorage, this.load();
1072
- }
1073
- /** Current value or default if undefined */
1074
- get value() {
1075
- var t;
1076
- return this._value !== void 0 ? this._value : (t = this.options) == null ? void 0 : t.default;
1077
- }
1078
- /** Set value with proxy object wrapper to sync future changes */
1079
- set value(t) {
1080
- t == null || typeof t != "object" ? this._value = t : this._value = new Proxy(t, {
1081
- get: (e, r) => typeof e[r] == "function" ? (...i) => {
1082
- const o = e[r](...i);
1083
- return this.save(), o;
1084
- } : e[r],
1085
- set: (e, r, s) => (e[r] = s, this.save(), !0)
1086
- }), this.save();
1087
- }
1088
- /** Notify listeners of change */
1089
- notify(t) {
1090
- Object.values(this.watches).forEach((e) => e(t));
1091
- }
1092
- /** Delete value from storage */
1093
- clear() {
1094
- this.storage.removeItem(this.key);
1095
- }
1096
- /** Save current value to storage */
1097
- save() {
1098
- this._value === void 0 ? this.clear() : this.storage.setItem(this.key, JSON.stringify(this._value)), this.notify(this.value);
1099
- }
1100
- /** Load value from storage */
1101
- load() {
1102
- if (this.storage[this.key] != null) {
1103
- let t = JSON.parse(this.storage.getItem(this.key));
1104
- t != null && typeof t == "object" && this.options.type && (t.__proto__ = this.options.type.prototype), this.value = t;
1105
- } else
1106
- this.value = this.options.default || void 0;
1107
- }
1108
- /**
1109
- * Callback function which is run when there are changes
1110
- *
1111
- * @param {(value: T) => any} fn Callback will run on each change; it's passed the next value & it's return is ignored
1112
- * @returns {() => void} Function which will unsubscribe the watch/callback when called
1113
- */
1114
- watch(t) {
1115
- const e = Object.keys(this.watches).length;
1116
- return this.watches[e] = t, () => {
1117
- delete this.watches[e];
1118
- };
1119
- }
1120
- /**
1121
- * Return value as JSON string
1122
- *
1123
- * @returns {string} Stringified object as JSON
1124
- */
1125
- toString() {
1126
- return JSON.stringify(this.value);
1127
- }
1128
- /**
1129
- * Return current value
1130
- *
1131
- * @returns {T} Current value
1132
- */
1133
- valueOf() {
1134
- return this.value;
1135
- }
1136
- }
1137
- B.Persist = ot;
1138
- function jt(n) {
1139
- return (t, e) => {
1140
- const r = (n == null ? void 0 : n.key) || `${t.constructor.name}.${e.toString()}`, s = new ot(r, n);
1141
- Object.defineProperty(t, e, {
1142
- get: function() {
1143
- return s.value;
1144
- },
1145
- set: function(i) {
1146
- s.value = i;
1147
- }
1148
- });
1149
- };
1150
- }
1151
- B.persist = jt;
1152
- var I = {};
1153
- Object.defineProperty(I, "__esModule", { value: !0 });
1154
- I.MemoryStorage = void 0;
1155
- class $t {
1156
- get length() {
1157
- return Object.keys(this).length;
1158
- }
1159
- clear() {
1160
- Object.keys(this).forEach((t) => this.removeItem(t));
1161
- }
1162
- getItem(t) {
1163
- return this[t];
1164
- }
1165
- key(t) {
1166
- return Object.keys(this)[t];
1167
- }
1168
- removeItem(t) {
1169
- delete this[t];
1170
- }
1171
- setItem(t, e) {
1172
- this[t] = e;
1173
- }
1174
- }
1175
- I.MemoryStorage = $t;
1176
- (function(n) {
1177
- var t = v && v.__createBinding || (Object.create ? function(r, s, i, o) {
1178
- o === void 0 && (o = i);
1179
- var u = Object.getOwnPropertyDescriptor(s, i);
1180
- (!u || ("get" in u ? !s.__esModule : u.writable || u.configurable)) && (u = { enumerable: !0, get: function() {
1181
- return s[i];
1182
- } }), Object.defineProperty(r, o, u);
1183
- } : function(r, s, i, o) {
1184
- o === void 0 && (o = i), r[o] = s[i];
1185
- }), e = v && v.__exportStar || function(r, s) {
1186
- for (var i in r) i !== "default" && !Object.prototype.hasOwnProperty.call(s, i) && t(s, r, i);
1187
- };
1188
- Object.defineProperty(n, "__esModule", { value: !0 }), e(B, n), e(I, n);
1189
- })(At);
1190
1062
  export {
1191
- E as ASet,
1192
- rt as BadGatewayError,
1193
- K as BadRequestError,
1194
- Gt as Cache,
1195
- zt as CliBackground,
1196
- j as CliEffects,
1063
+ S as ASet,
1064
+ tt as BadGatewayError,
1065
+ W as BadRequestError,
1066
+ Tt as Cache,
1067
+ qt as CliBackground,
1068
+ R as CliEffects,
1197
1069
  L as CliForeground,
1198
- g as CustomError,
1199
- V as ForbiddenError,
1200
- it as GatewayTimeoutError,
1201
- H as Http,
1202
- et as InternalServerError,
1203
- k as JSONAttemptParse,
1204
- It as JSONSanitize,
1205
- yt as LOG_LEVEL,
1206
- W as Logger,
1207
- Q as MethodNotAllowedError,
1208
- tt as NotAcceptableError,
1209
- X as NotFoundError,
1210
- nt as NotImplementedError,
1211
- ue as PE,
1212
- xt as PES,
1213
- y as PathEvent,
1214
- ae as PathEventEmitter,
1215
- _ as PaymentRequiredError,
1216
- O as PromiseProgress,
1217
- st as ServiceUnavailableError,
1218
- z as TypedEmitter,
1219
- Z as UnauthorizedError,
1220
- Tt as addUnique,
1221
- Mt as arrayDiff,
1222
- kt as caseInsensitiveSort,
1223
- lt as clean,
1224
- Ut as csv,
1225
- Kt as dec2Frac,
1226
- Ct as deepCopy,
1227
- ft as deepMerge,
1228
- x as dotNotation,
1229
- qt as downloadFile,
1230
- pt as downloadUrl,
1231
- Lt as encodeQuery,
1232
- Wt as errorFromCode,
1233
- ce as escapeRegex,
1234
- Ft as fileBrowser,
1235
- Pt as findByProp,
1236
- ht as flattenArr,
1237
- J as flattenObj,
1238
- vt as formData,
1239
- _t as formatBytes,
1240
- le as formatDate,
1241
- Vt as formatPhoneNumber,
1242
- Zt as fracToDec,
1243
- oe as gravatar,
1244
- Y as includes,
1245
- Xt as insertAt,
1246
- $ as isEqual,
1247
- Jt as jwtDecode,
1248
- b as makeArray,
1249
- dt as makeUnique,
1250
- re as matchAll,
1251
- wt as md5,
1252
- Nt as mixin,
1253
- Qt as pad,
1254
- se as parseUrl,
1255
- te as randomHex,
1256
- ee as randomString,
1257
- ne as randomStringBuilder,
1258
- Bt as sleep,
1259
- fe as sleepWhile,
1260
- Dt as sortByProp,
1261
- he as timeUntil,
1262
- Yt as timestampFilename,
1263
- de as tyoeKeys,
1264
- Ht as uploadWithProgress,
1265
- ie as validateEmail
1070
+ y as CustomError,
1071
+ z as ForbiddenError,
1072
+ nt as GatewayTimeoutError,
1073
+ F as Http,
1074
+ Q as InternalServerError,
1075
+ I as JSONAttemptParse,
1076
+ Ot as JSONSanitize,
1077
+ ft as LOG_LEVEL,
1078
+ Y as Logger,
1079
+ V as MethodNotAllowedError,
1080
+ X as NotAcceptableError,
1081
+ Z as NotFoundError,
1082
+ _ as NotImplementedError,
1083
+ ee as PE,
1084
+ mt as PES,
1085
+ g as PathEvent,
1086
+ ne as PathEventEmitter,
1087
+ J as PaymentRequiredError,
1088
+ x as PromiseProgress,
1089
+ et as ServiceUnavailableError,
1090
+ K as TypedEmitter,
1091
+ v as UnauthorizedError,
1092
+ $t as addUnique,
1093
+ Ct as arrayDiff,
1094
+ Lt as caseInsensitiveSort,
1095
+ ot as clean,
1096
+ It as csv,
1097
+ Ft as dec2Frac,
1098
+ xt as deepCopy,
1099
+ ct as deepMerge,
1100
+ B as dotNotation,
1101
+ Dt as downloadFile,
1102
+ lt as downloadUrl,
1103
+ Bt as encodeQuery,
1104
+ Gt as errorFromCode,
1105
+ te as escapeRegex,
1106
+ Mt as fileBrowser,
1107
+ jt as findByProp,
1108
+ ut as flattenArr,
1109
+ H as flattenObj,
1110
+ At as formData,
1111
+ Ht as formatBytes,
1112
+ re as formatDate,
1113
+ Kt as formatPhoneNumber,
1114
+ Yt as fracToDec,
1115
+ _t as gravatar,
1116
+ q as includes,
1117
+ Wt as insertAt,
1118
+ O as isEqual,
1119
+ Ut as jwtDecode,
1120
+ m as makeArray,
1121
+ at as makeUnique,
1122
+ Vt as matchAll,
1123
+ dt as md5,
1124
+ Rt as mixin,
1125
+ vt as pad,
1126
+ Xt as parseUrl,
1127
+ Jt as randomHex,
1128
+ zt as randomString,
1129
+ Zt as randomStringBuilder,
1130
+ St as sleep,
1131
+ se as sleepWhile,
1132
+ Nt as sortByProp,
1133
+ ie as timeUntil,
1134
+ kt as timestampFilename,
1135
+ oe as tyoeKeys,
1136
+ Pt as uploadWithProgress,
1137
+ Qt as validateEmail
1266
1138
  };
1267
1139
  //# sourceMappingURL=index.mjs.map