@ztimson/utils 0.15.6 → 0.16.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,23 +1,23 @@
1
- var et = Object.defineProperty;
2
- var nt = (n, t, e) => t in n ? et(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
- var i = (n, t, e) => (nt(n, typeof t != "symbol" ? t + "" : t, e), e);
4
- function rt(n, t = !1) {
1
+ var nt = Object.defineProperty;
2
+ var rt = (n, t, e) => t in n ? nt(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
+ var i = (n, t, e) => (rt(n, typeof t != "symbol" ? t + "" : t, e), e);
4
+ function ot(n, t = !1) {
5
5
  if (n == null)
6
6
  throw new Error("Cannot clean a NULL value");
7
7
  return Array.isArray(n) ? n = n.filter((e) => e != null) : Object.entries(n).forEach(([e, r]) => {
8
8
  (t && r === void 0 || !t && r == null) && delete n[e];
9
9
  }), n;
10
10
  }
11
- function mt(n) {
12
- return JSON.parse(JSON.stringify(n));
11
+ function xt(n) {
12
+ return structuredClone(n);
13
13
  }
14
- function ot(n, ...t) {
14
+ function st(n, ...t) {
15
15
  return t.forEach((e) => {
16
16
  for (const r in e)
17
- e[r] && typeof e[r] == "object" && !Array.isArray(e[r]) ? (n[r] || (n[r] = {}), ot(n[r], e[r])) : n[r] = e[r];
17
+ e[r] && typeof e[r] == "object" && !Array.isArray(e[r]) ? (n[r] || (n[r] = {}), st(n[r], e[r])) : n[r] = e[r];
18
18
  }), n;
19
19
  }
20
- function S(n, t, e) {
20
+ function x(n, t, e) {
21
21
  if (!(n == null || !t))
22
22
  return t.split(/[.[\]]/g).filter((r) => r.length).reduce((r, o, s, c) => {
23
23
  if ((o[0] == '"' || o[0] == "'") && (o = o.slice(1, -1)), !(r != null && r.hasOwnProperty(o))) {
@@ -28,16 +28,21 @@ function S(n, t, e) {
28
28
  return e !== void 0 && s == c.length - 1 ? r[o] = e : r[o];
29
29
  }, n);
30
30
  }
31
- function st(n, t, e = {}) {
31
+ function Bt(n) {
32
+ return Object.entries(n).map(
33
+ ([t, e]) => encodeURIComponent(t) + "=" + encodeURIComponent(e)
34
+ ).join("&");
35
+ }
36
+ function F(n, t, e = {}) {
32
37
  if (typeof n == "object" && !Array.isArray(n)) {
33
38
  for (const r of Object.keys(n)) {
34
39
  const o = t ? t + "." + r : r;
35
- typeof n[r] == "object" ? st(n[r], o, e) : e[o] = n[r];
40
+ typeof n[r] == "object" ? F(n[r], o, e) : e[o] = n[r];
36
41
  }
37
42
  return e;
38
43
  }
39
44
  }
40
- function xt(n) {
45
+ function St(n) {
41
46
  const t = new FormData();
42
47
  return Object.entries(n).forEach(([e, r]) => t.append(e, r)), t;
43
48
  }
@@ -53,7 +58,7 @@ function b(n, t) {
53
58
  const e = typeof n, r = typeof t;
54
59
  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((s) => b(n[s], t[s]));
55
60
  }
56
- function Bt(n, t) {
61
+ function At(n, t) {
57
62
  t.forEach((e) => {
58
63
  Object.getOwnPropertyNames(e.prototype).forEach((r) => {
59
64
  Object.defineProperty(
@@ -71,21 +76,16 @@ function U(n) {
71
76
  return n;
72
77
  }
73
78
  }
74
- function At(n, t) {
79
+ function bt(n, t) {
75
80
  let e = [];
76
- return JSON.parse(JSON.stringify(n, (r, o) => {
81
+ return JSON.stringify(n, (r, o) => {
77
82
  if (typeof o == "object" && o !== null) {
78
83
  if (e.includes(o))
79
84
  return;
80
85
  e.push(o);
81
86
  }
82
87
  return o;
83
- }, t));
84
- }
85
- function bt(n) {
86
- return Object.entries(n).map(
87
- ([t, e]) => encodeURIComponent(t) + "=" + encodeURIComponent(e)
88
- ).join("&");
88
+ }, t);
89
89
  }
90
90
  function Rt(n, t) {
91
91
  return n.indexOf(t) === -1 && n.push(t), n;
@@ -96,30 +96,30 @@ function Ot(n, t) {
96
96
  ...t.filter((e) => !n.includes((r) => b(e, r)))
97
97
  ]);
98
98
  }
99
- function Lt(n) {
99
+ function $t(n) {
100
100
  return function(t, e) {
101
- const r = S(t, n), o = S(e, n);
101
+ const r = x(t, n), o = x(e, n);
102
102
  return typeof r != "string" || typeof o != "string" ? 1 : r.toLowerCase().localeCompare(o.toLowerCase());
103
103
  };
104
104
  }
105
+ function Lt(n, t) {
106
+ return (e) => b(x(e, n), t);
107
+ }
105
108
  function ct(n, t = []) {
106
109
  return n.forEach((e) => Array.isArray(e) ? ct(e, t) : t.push(e)), t;
107
110
  }
108
- function St(n, t = !1) {
111
+ function Ct(n, t = !1) {
109
112
  return function(e, r) {
110
- const o = S(e, n), s = S(r, n);
113
+ const o = x(e, n), s = x(r, n);
111
114
  return typeof o == "number" && typeof s == "number" ? (t ? -1 : 1) * (o - s) : o > s ? t ? -1 : 1 : o < s ? t ? 1 : -1 : 0;
112
115
  };
113
116
  }
114
- function Ct(n, t) {
115
- return (e) => b(e[n], t);
116
- }
117
117
  function it(n) {
118
118
  for (let t = n.length - 1; t >= 0; t--)
119
119
  n.slice(0, t).find((e) => b(e, n[t])) && n.splice(t, 1);
120
120
  return n;
121
121
  }
122
- function Nt(n) {
122
+ function ut(n) {
123
123
  return Array.isArray(n) ? n : [n];
124
124
  }
125
125
  class A extends Array {
@@ -214,6 +214,19 @@ class A extends Array {
214
214
  return new A([...this, ...t]);
215
215
  }
216
216
  }
217
+ function Nt(n, t = !0) {
218
+ const e = n.reduce((r, o) => (Object.keys(t ? F(o) : o).forEach((s) => {
219
+ r.includes(s) || r.push(s);
220
+ }), r), []);
221
+ return [
222
+ e.join(","),
223
+ ...n.map((r) => e.map((o) => {
224
+ const s = x(r, o), c = typeof s;
225
+ return c == "string" && s.includes(",") ? `"${s}"` : c == "object" ? `"${JSON.stringify(s)}"` : s;
226
+ }).join(","))
227
+ ].join(`
228
+ `);
229
+ }
217
230
  class m extends Promise {
218
231
  constructor(e) {
219
232
  super((r, o) => e(
@@ -251,14 +264,15 @@ class m extends Promise {
251
264
  return this.from(super.finally(e));
252
265
  }
253
266
  }
254
- function at(n, t) {
255
- const e = document.createElement("a");
256
- e.href = n, e.download = t, document.body.appendChild(e), e.click(), document.body.removeChild(e);
257
- }
258
267
  function Tt(n, t) {
268
+ n instanceof Blob || (n = new Blob(ut(n)));
259
269
  const e = URL.createObjectURL(n);
260
270
  at(e, t), URL.revokeObjectURL(e);
261
271
  }
272
+ function at(n, t) {
273
+ const e = document.createElement("a");
274
+ e.href = n, e.download = t || n.split("/").pop(), document.body.appendChild(e), e.click(), document.body.removeChild(e);
275
+ }
262
276
  function It(n = {}) {
263
277
  return new Promise((t) => {
264
278
  const e = document.createElement("input");
@@ -267,13 +281,18 @@ function It(n = {}) {
267
281
  }, document.body.appendChild(e), e.click();
268
282
  });
269
283
  }
270
- function $t(n) {
284
+ function Mt(n, t = /* @__PURE__ */ new Date()) {
285
+ (typeof t == "number" || typeof t == "string") && (t = new Date(t));
286
+ 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")}`;
287
+ return n ? n.replace("{{TIMESTAMP}}", e) : e;
288
+ }
289
+ function Dt(n) {
271
290
  return new m((t, e, r) => {
272
291
  const o = new XMLHttpRequest(), s = new FormData();
273
292
  n.files.forEach((c) => s.append("file", c)), o.withCredentials = !!n.withCredentials, o.upload.addEventListener("progress", (c) => c.lengthComputable ? r(c.loaded / c.total) : null), o.addEventListener("loadend", () => t(U(o.responseText))), o.addEventListener("error", () => e(U(o.responseText))), o.addEventListener("timeout", () => e({ error: "Request timed out" })), o.open("POST", n.url), Object.entries(n.headers || {}).forEach(([c, y]) => o.setRequestHeader(c, y)), o.send(s);
274
293
  });
275
294
  }
276
- class F {
295
+ class v {
277
296
  constructor() {
278
297
  i(this, "listeners", {});
279
298
  }
@@ -314,7 +333,7 @@ class F {
314
333
  });
315
334
  }
316
335
  }
317
- i(F, "listeners", {});
336
+ i(v, "listeners", {});
318
337
  class p extends Error {
319
338
  constructor(e, r) {
320
339
  super(e);
@@ -343,7 +362,7 @@ class p extends Error {
343
362
  }
344
363
  }
345
364
  i(p, "code", 500);
346
- class v extends p {
365
+ class Y extends p {
347
366
  constructor(t = "Bad Request") {
348
367
  super(t);
349
368
  }
@@ -351,8 +370,8 @@ class v extends p {
351
370
  return t.constructor.code == this.code;
352
371
  }
353
372
  }
354
- i(v, "code", 400);
355
- class Y extends p {
373
+ i(Y, "code", 400);
374
+ class H extends p {
356
375
  constructor(t = "Unauthorized") {
357
376
  super(t);
358
377
  }
@@ -360,8 +379,8 @@ class Y extends p {
360
379
  return t.constructor.code == this.code;
361
380
  }
362
381
  }
363
- i(Y, "code", 401);
364
- class H extends p {
382
+ i(H, "code", 401);
383
+ class W extends p {
365
384
  constructor(t = "Payment Required") {
366
385
  super(t);
367
386
  }
@@ -369,8 +388,8 @@ class H extends p {
369
388
  return t.constructor.code == this.code;
370
389
  }
371
390
  }
372
- i(H, "code", 402);
373
- class W extends p {
391
+ i(W, "code", 402);
392
+ class z extends p {
374
393
  constructor(t = "Forbidden") {
375
394
  super(t);
376
395
  }
@@ -378,8 +397,8 @@ class W extends p {
378
397
  return t.constructor.code == this.code;
379
398
  }
380
399
  }
381
- i(W, "code", 403);
382
- class z extends p {
400
+ i(z, "code", 403);
401
+ class J extends p {
383
402
  constructor(t = "Not Found") {
384
403
  super(t);
385
404
  }
@@ -387,8 +406,8 @@ class z extends p {
387
406
  return t.constructor.code == this.code;
388
407
  }
389
408
  }
390
- i(z, "code", 404);
391
- class J extends p {
409
+ i(J, "code", 404);
410
+ class K extends p {
392
411
  constructor(t = "Method Not Allowed") {
393
412
  super(t);
394
413
  }
@@ -396,8 +415,8 @@ class J extends p {
396
415
  return t.constructor.code == this.code;
397
416
  }
398
417
  }
399
- i(J, "code", 405);
400
- class K extends p {
418
+ i(K, "code", 405);
419
+ class Z extends p {
401
420
  constructor(t = "Not Acceptable") {
402
421
  super(t);
403
422
  }
@@ -405,8 +424,8 @@ class K extends p {
405
424
  return t.constructor.code == this.code;
406
425
  }
407
426
  }
408
- i(K, "code", 406);
409
- class Z extends p {
427
+ i(Z, "code", 406);
428
+ class V extends p {
410
429
  constructor(t = "Internal Server Error") {
411
430
  super(t);
412
431
  }
@@ -414,8 +433,8 @@ class Z extends p {
414
433
  return t.constructor.code == this.code;
415
434
  }
416
435
  }
417
- i(Z, "code", 500);
418
- class V extends p {
436
+ i(V, "code", 500);
437
+ class X extends p {
419
438
  constructor(t = "Not Implemented") {
420
439
  super(t);
421
440
  }
@@ -423,8 +442,8 @@ class V extends p {
423
442
  return t.constructor.code == this.code;
424
443
  }
425
444
  }
426
- i(V, "code", 501);
427
- class X extends p {
445
+ i(X, "code", 501);
446
+ class Q extends p {
428
447
  constructor(t = "Bad Gateway") {
429
448
  super(t);
430
449
  }
@@ -432,8 +451,8 @@ class X extends p {
432
451
  return t.constructor.code == this.code;
433
452
  }
434
453
  }
435
- i(X, "code", 502);
436
- class Q extends p {
454
+ i(Q, "code", 502);
455
+ class _ extends p {
437
456
  constructor(t = "Service Unavailable") {
438
457
  super(t);
439
458
  }
@@ -441,8 +460,8 @@ class Q extends p {
441
460
  return t.constructor.code == this.code;
442
461
  }
443
462
  }
444
- i(Q, "code", 503);
445
- class _ extends p {
463
+ i(_, "code", 503);
464
+ class tt extends p {
446
465
  constructor(t = "Gateway Timeout") {
447
466
  super(t);
448
467
  }
@@ -450,35 +469,35 @@ class _ extends p {
450
469
  return t.constructor.code == this.code;
451
470
  }
452
471
  }
453
- i(_, "code", 504);
454
- function Dt(n, t) {
472
+ i(tt, "code", 504);
473
+ function jt(n, t) {
455
474
  if (n >= 200 && n < 300)
456
475
  return null;
457
476
  switch (n) {
458
477
  case 400:
459
- return new v(t);
460
- case 401:
461
478
  return new Y(t);
462
- case 402:
479
+ case 401:
463
480
  return new H(t);
464
- case 403:
481
+ case 402:
465
482
  return new W(t);
466
- case 404:
483
+ case 403:
467
484
  return new z(t);
468
- case 405:
485
+ case 404:
469
486
  return new J(t);
470
- case 406:
487
+ case 405:
471
488
  return new K(t);
472
- case 500:
489
+ case 406:
473
490
  return new Z(t);
474
- case 501:
491
+ case 500:
475
492
  return new V(t);
476
- case 502:
493
+ case 501:
477
494
  return new X(t);
478
- case 503:
495
+ case 502:
479
496
  return new Q(t);
480
- case 504:
497
+ case 503:
481
498
  return new _(t);
499
+ case 504:
500
+ return new tt(t);
482
501
  default:
483
502
  return new p(t, n);
484
503
  }
@@ -511,7 +530,7 @@ const w = class w {
511
530
  const s = Array.isArray(t.query) ? t.query : Object.keys(t.query).map((c) => ({ key: c, value: t.query[c] }));
512
531
  e += (e.includes("?") ? "&" : "?") + s.map((c) => `${c.key}=${c.value}`).join("&");
513
532
  }
514
- const r = rt({
533
+ const r = ot({
515
534
  "Content-Type": t.body ? t.body instanceof FormData ? "multipart/form-data" : "application/json" : void 0,
516
535
  ...w.headers,
517
536
  ...this.headers,
@@ -522,36 +541,36 @@ const w = class w {
522
541
  headers: r,
523
542
  method: t.method || (t.body ? "POST" : "GET"),
524
543
  body: t.body
525
- }).then(async (a) => {
526
- var M, j;
527
- for (let u of [...Object.values(w.interceptors), ...Object.values(this.interceptors)])
528
- await new Promise((O) => u(a, () => O()));
529
- const R = a.headers.get("Content-Length"), N = R ? parseInt(R, 10) : 0;
530
- let k = 0;
531
- const T = (M = a.body) == null ? void 0 : M.getReader(), tt = new ReadableStream({
532
- start(u) {
544
+ }).then(async (u) => {
545
+ var j, k;
546
+ for (let a of [...Object.values(w.interceptors), ...Object.values(this.interceptors)])
547
+ await new Promise((O) => a(u, () => O()));
548
+ const R = u.headers.get("Content-Length"), C = R ? parseInt(R, 10) : 0;
549
+ let D = 0;
550
+ const N = (j = u.body) == null ? void 0 : j.getReader(), et = new ReadableStream({
551
+ start(a) {
533
552
  function O() {
534
- T == null || T.read().then((x) => {
535
- if (x.done)
536
- return u.close();
537
- k += x.value.byteLength, y(k / N), u.enqueue(x.value), O();
538
- }).catch((x) => u.error(x));
553
+ N == null || N.read().then((B) => {
554
+ if (B.done)
555
+ return a.close();
556
+ D += B.value.byteLength, y(D / C), a.enqueue(B.value), O();
557
+ }).catch((B) => a.error(B));
539
558
  }
540
559
  O();
541
560
  }
542
561
  });
543
- if (a.data = new Response(tt), t.decode == null || t.decode) {
544
- const u = (j = a.headers.get("Content-Type")) == null ? void 0 : j.toLowerCase();
545
- u != null && u.includes("form") ? a.data = await a.data.formData() : u != null && u.includes("json") ? a.data = await a.data.json() : u != null && u.includes("text") ? a.data = await a.data.text() : u != null && u.includes("application") && (a.data = await a.data.blob());
562
+ if (u.data = new Response(et), t.decode == null || t.decode) {
563
+ const a = (k = u.headers.get("Content-Type")) == null ? void 0 : k.toLowerCase();
564
+ a != null && a.includes("form") ? u.data = await u.data.formData() : a != null && a.includes("json") ? u.data = await u.data.json() : a != null && a.includes("text") ? u.data = await u.data.text() : a != null && a.includes("application") && (u.data = await u.data.blob());
546
565
  }
547
- a.ok ? s(a) : c(a);
566
+ u.ok ? s(u) : c(u);
548
567
  });
549
568
  });
550
569
  }
551
570
  };
552
571
  i(w, "interceptors", {}), i(w, "headers", {});
553
572
  let q = w;
554
- const B = {
573
+ const S = {
555
574
  CLEAR: "\x1B[0m",
556
575
  BRIGHT: "\x1B[1m",
557
576
  DIM: "\x1B[2m",
@@ -559,7 +578,7 @@ const B = {
559
578
  BLINK: "\x1B[5m",
560
579
  REVERSE: "\x1B[7m",
561
580
  HIDDEN: "\x1B[8m"
562
- }, L = {
581
+ }, $ = {
563
582
  BLACK: "\x1B[30m",
564
583
  RED: "\x1B[31m",
565
584
  GREEN: "\x1B[32m",
@@ -587,8 +606,8 @@ const B = {
587
606
  WHITE: "\x1B[47m",
588
607
  GREY: "\x1B[100m"
589
608
  };
590
- var ut = /* @__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))(ut || {});
591
- const g = class g extends F {
609
+ var lt = /* @__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))(lt || {});
610
+ const g = class g extends v {
592
611
  constructor(t) {
593
612
  super(), this.namespace = t;
594
613
  }
@@ -607,61 +626,55 @@ const g = class g extends F {
607
626
  if (g.LOG_LEVEL < 4)
608
627
  return;
609
628
  const e = this.format(...t);
610
- g.emit(4, e), console.debug(L.LIGHT_GREY + e + B.CLEAR);
629
+ g.emit(4, e), console.debug($.LIGHT_GREY + e + S.CLEAR);
611
630
  }
612
631
  log(...t) {
613
632
  if (g.LOG_LEVEL < 3)
614
633
  return;
615
634
  const e = this.format(...t);
616
- g.emit(3, e), console.log(B.CLEAR + e);
635
+ g.emit(3, e), console.log(S.CLEAR + e);
617
636
  }
618
637
  info(...t) {
619
638
  if (g.LOG_LEVEL < 2)
620
639
  return;
621
640
  const e = this.format(...t);
622
- g.emit(2, e), console.info(L.BLUE + e + B.CLEAR);
641
+ g.emit(2, e), console.info($.BLUE + e + S.CLEAR);
623
642
  }
624
643
  warn(...t) {
625
644
  if (g.LOG_LEVEL < 1)
626
645
  return;
627
646
  const e = this.format(...t);
628
- g.emit(1, e), console.warn(L.YELLOW + e + B.CLEAR);
647
+ g.emit(1, e), console.warn($.YELLOW + e + S.CLEAR);
629
648
  }
630
649
  error(...t) {
631
650
  if (g.LOG_LEVEL < 0)
632
651
  return;
633
652
  const e = this.format(...t);
634
- g.emit(0, e), console.error(L.RED + e + B.CLEAR);
653
+ g.emit(0, e), console.error($.RED + e + S.CLEAR);
635
654
  }
636
655
  };
637
656
  i(g, "LOG_LEVEL", 4);
638
657
  let P = g;
639
- function Mt(n) {
640
- const t = (y, a) => a < 1e-7 ? y : t(a, ~~(y % a)), e = n.toString().length - 2;
658
+ function Gt(n) {
659
+ const t = (y, u) => u < 1e-7 ? y : t(u, ~~(y % u)), e = n.toString().length - 2;
641
660
  let r = Math.pow(10, e), o = n * r;
642
661
  const s = t(o, r);
643
662
  o = ~~(o / s), r = ~~(r / s);
644
663
  const c = ~~(o / r);
645
664
  return o -= c * r, `${c ? c + " " : ""}${~~o}/${~~r}`;
646
665
  }
647
- function jt(n) {
666
+ function Ut(n) {
648
667
  let t = n.split(" ");
649
668
  const e = t.length == 2 ? Number(t[0]) : 0;
650
669
  return t = t.pop().split("/"), e + Number(t[0]) / Number(t[1]);
651
670
  }
652
- function Gt(n, t) {
653
- return n.length - n.replaceAll(t, "").length;
654
- }
655
- function Ut(n) {
656
- return Array(n).fill(null).map(() => Math.round(Math.random() * 15).toString(16)).join("");
657
- }
671
+ const T = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", I = "0123456789", M = "~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/", ft = T + I + M;
658
672
  function qt(n, t = 2) {
659
673
  if (n === 0)
660
674
  return "0 Bytes";
661
675
  const e = 1024, r = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], o = Math.floor(Math.log(n) / Math.log(e));
662
676
  return parseFloat((n / Math.pow(e, o)).toFixed(t)) + " " + r[o];
663
677
  }
664
- const I = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", $ = "0123456789", D = "~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/", lt = I + $ + D;
665
678
  function Pt(n) {
666
679
  const t = /(\+?1)?.*?(\d{3}).*?(\d{3}).*?(\d{4})/g.exec(n);
667
680
  if (!t)
@@ -671,32 +684,31 @@ function Pt(n) {
671
684
  function Ft(n, t, e) {
672
685
  return `${n.slice(0, e)}${t}${n.slice(e + 1)}`;
673
686
  }
674
- function vt(n, t, e, r = !0) {
675
- const o = n.toString(), s = t - o.length;
676
- if (s <= 0)
677
- return o;
678
- const c = Array(~~(s / e.length)).fill(e).join("");
679
- return r ? c + o : o + c;
687
+ function vt(n, t, e = " ", r = !0) {
688
+ return r ? n.toString().padStart(t, e) : n.toString().padEnd(t, e);
689
+ }
690
+ function Yt(n) {
691
+ return Array(n).fill(null).map(() => Math.round(Math.random() * 15).toString(16)).join("");
680
692
  }
681
- function Yt(n, t = lt) {
693
+ function Ht(n, t = ft) {
682
694
  return Array(n).fill(null).map(() => {
683
695
  const e = ~~(Math.random() * t.length);
684
696
  return t[e];
685
697
  }).join("");
686
698
  }
687
- function Ht(n, t = !1, e = !1, r = !1) {
699
+ function Wt(n, t = !1, e = !1, r = !1) {
688
700
  if (!t && !e && !r)
689
701
  throw new Error("Must enable at least one: letters, numbers, symbols");
690
702
  return Array(n).fill(null).map(() => {
691
703
  let o;
692
704
  do {
693
705
  const s = ~~(Math.random() * 3);
694
- t && s == 0 ? o = I[~~(Math.random() * I.length)] : e && s == 1 ? o = $[~~(Math.random() * $.length)] : r && s == 2 && (o = D[~~(Math.random() * D.length)]);
706
+ t && s == 0 ? o = T[~~(Math.random() * T.length)] : e && s == 1 ? o = I[~~(Math.random() * I.length)] : r && s == 2 && (o = M[~~(Math.random() * M.length)]);
695
707
  } while (!o);
696
708
  return o;
697
709
  }).join("");
698
710
  }
699
- function Wt(n, t) {
711
+ function zt(n, t) {
700
712
  if (typeof t == "string" && (t = new RegExp(t, "g")), !t.global)
701
713
  throw new TypeError("Regular expression must be global.");
702
714
  let e = [], r;
@@ -704,164 +716,163 @@ function Wt(n, t) {
704
716
  e.push(r);
705
717
  return e;
706
718
  }
719
+ function Jt(n) {
720
+ const t = new RegExp(
721
+ "(?:(?<protocol>[\\w\\d]+)\\:\\/\\/)?(?:(?<user>.+)\\@)?(?<host>(?<domain>[^:\\/\\?#@\\n]+)(?:\\:(?<port>\\d*))?)(?<path>\\/.*?)?(?:\\?(?<query>.*?))?(?:#(?<fragment>.*?))?$",
722
+ "gm"
723
+ ).exec(n), e = (t == null ? void 0 : t.groups) ?? {}, r = e.domain.split(".");
724
+ 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) {
725
+ const o = e.query.split("&"), s = {};
726
+ o.forEach((c) => {
727
+ const [y, u] = c.split("=");
728
+ s[y] = u;
729
+ }), e.query = s;
730
+ }
731
+ return e;
732
+ }
707
733
  function ht(n) {
708
- var t = ft(pt(yt(dt(n), 8 * n.length)));
734
+ var t = dt(yt(gt(pt(n), 8 * n.length)));
709
735
  return t.toLowerCase();
710
736
  }
711
- function ft(n) {
737
+ function dt(n) {
712
738
  for (var t, e = "0123456789ABCDEF", r = "", o = 0; o < n.length; o++)
713
739
  t = n.charCodeAt(o), r += e.charAt(t >>> 4 & 15) + e.charAt(15 & t);
714
740
  return r;
715
741
  }
716
- function dt(n) {
742
+ function pt(n) {
717
743
  for (var t = Array(n.length >> 2), e = 0; e < t.length; e++)
718
744
  t[e] = 0;
719
745
  for (e = 0; e < 8 * n.length; e += 8)
720
746
  t[e >> 5] |= (255 & n.charCodeAt(e / 8)) << e % 32;
721
747
  return t;
722
748
  }
723
- function pt(n) {
749
+ function yt(n) {
724
750
  for (var t = "", e = 0; e < 32 * n.length; e += 8)
725
751
  t += String.fromCharCode(n[e >> 5] >>> e % 32 & 255);
726
752
  return t;
727
753
  }
728
- function yt(n, t) {
754
+ function gt(n, t) {
729
755
  n[t >> 5] |= 128 << t % 32, n[14 + (t + 64 >>> 9 << 4)] = t;
730
756
  for (var e = 1732584193, r = -271733879, o = -1732584194, s = 271733878, c = 0; c < n.length; c += 16) {
731
- var y = e, a = r, R = o, N = s;
732
- r = d(r = d(r = d(r = d(r = f(r = f(r = f(r = f(r = h(r = h(r = h(r = h(r = l(r = l(r = l(r = l(r, o = l(o, s = l(s, e = l(e, r, o, s, n[c + 0], 7, -680876936), r, o, n[c + 1], 12, -389564586), e, r, n[c + 2], 17, 606105819), s, e, n[c + 3], 22, -1044525330), o = l(o, s = l(s, e = l(e, r, o, s, n[c + 4], 7, -176418897), r, o, n[c + 5], 12, 1200080426), e, r, n[c + 6], 17, -1473231341), s, e, n[c + 7], 22, -45705983), o = l(o, s = l(s, e = l(e, r, o, s, n[c + 8], 7, 1770035416), r, o, n[c + 9], 12, -1958414417), e, r, n[c + 10], 17, -42063), s, e, n[c + 11], 22, -1990404162), o = l(o, s = l(s, e = l(e, r, o, s, n[c + 12], 7, 1804603682), r, o, n[c + 13], 12, -40341101), e, r, n[c + 14], 17, -1502002290), s, e, n[c + 15], 22, 1236535329), o = h(o, s = h(s, e = h(e, r, o, s, n[c + 1], 5, -165796510), r, o, n[c + 6], 9, -1069501632), e, r, n[c + 11], 14, 643717713), s, e, n[c + 0], 20, -373897302), o = h(o, s = h(s, e = h(e, r, o, s, n[c + 5], 5, -701558691), r, o, n[c + 10], 9, 38016083), e, r, n[c + 15], 14, -660478335), s, e, n[c + 4], 20, -405537848), o = h(o, s = h(s, e = h(e, r, o, s, n[c + 9], 5, 568446438), r, o, n[c + 14], 9, -1019803690), e, r, n[c + 3], 14, -187363961), s, e, n[c + 8], 20, 1163531501), o = h(o, s = h(s, e = h(e, r, o, s, n[c + 13], 5, -1444681467), r, o, n[c + 2], 9, -51403784), e, r, n[c + 7], 14, 1735328473), s, e, n[c + 12], 20, -1926607734), o = f(o, s = f(s, e = f(e, r, o, s, n[c + 5], 4, -378558), r, o, n[c + 8], 11, -2022574463), e, r, n[c + 11], 16, 1839030562), s, e, n[c + 14], 23, -35309556), o = f(o, s = f(s, e = f(e, r, o, s, n[c + 1], 4, -1530992060), r, o, n[c + 4], 11, 1272893353), e, r, n[c + 7], 16, -155497632), s, e, n[c + 10], 23, -1094730640), o = f(o, s = f(s, e = f(e, r, o, s, n[c + 13], 4, 681279174), r, o, n[c + 0], 11, -358537222), e, r, n[c + 3], 16, -722521979), s, e, n[c + 6], 23, 76029189), o = f(o, s = f(s, e = f(e, r, o, s, n[c + 9], 4, -640364487), r, o, n[c + 12], 11, -421815835), e, r, n[c + 15], 16, 530742520), s, e, n[c + 2], 23, -995338651), o = d(o, s = d(s, e = d(e, r, o, s, n[c + 0], 6, -198630844), r, o, n[c + 7], 10, 1126891415), e, r, n[c + 14], 15, -1416354905), s, e, n[c + 5], 21, -57434055), o = d(o, s = d(s, e = d(e, r, o, s, n[c + 12], 6, 1700485571), r, o, n[c + 3], 10, -1894986606), e, r, n[c + 10], 15, -1051523), s, e, n[c + 1], 21, -2054922799), o = d(o, s = d(s, e = d(e, r, o, s, n[c + 8], 6, 1873313359), r, o, n[c + 15], 10, -30611744), e, r, n[c + 6], 15, -1560198380), s, e, n[c + 13], 21, 1309151649), o = d(o, s = d(s, e = d(e, r, o, s, n[c + 4], 6, -145523070), r, o, n[c + 11], 10, -1120210379), e, r, n[c + 2], 15, 718787259), s, e, n[c + 9], 21, -343485551), e = E(e, y), r = E(r, a), o = E(o, R), s = E(s, N);
757
+ var y = e, u = r, R = o, C = s;
758
+ 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 = l(r = l(r = l(r = l(r, o = l(o, s = l(s, e = l(e, r, o, s, n[c + 0], 7, -680876936), r, o, n[c + 1], 12, -389564586), e, r, n[c + 2], 17, 606105819), s, e, n[c + 3], 22, -1044525330), o = l(o, s = l(s, e = l(e, r, o, s, n[c + 4], 7, -176418897), r, o, n[c + 5], 12, 1200080426), e, r, n[c + 6], 17, -1473231341), s, e, n[c + 7], 22, -45705983), o = l(o, s = l(s, e = l(e, r, o, s, n[c + 8], 7, 1770035416), r, o, n[c + 9], 12, -1958414417), e, r, n[c + 10], 17, -42063), s, e, n[c + 11], 22, -1990404162), o = l(o, s = l(s, e = l(e, r, o, s, n[c + 12], 7, 1804603682), r, o, n[c + 13], 12, -40341101), e, r, n[c + 14], 17, -1502002290), s, e, n[c + 15], 22, 1236535329), o = f(o, s = f(s, e = f(e, r, o, s, n[c + 1], 5, -165796510), r, o, n[c + 6], 9, -1069501632), e, r, n[c + 11], 14, 643717713), s, e, n[c + 0], 20, -373897302), o = f(o, s = f(s, e = f(e, r, o, s, n[c + 5], 5, -701558691), r, o, n[c + 10], 9, 38016083), e, r, n[c + 15], 14, -660478335), s, e, n[c + 4], 20, -405537848), o = f(o, s = f(s, e = f(e, r, o, s, n[c + 9], 5, 568446438), r, o, n[c + 14], 9, -1019803690), e, r, n[c + 3], 14, -187363961), s, e, n[c + 8], 20, 1163531501), o = f(o, s = f(s, e = f(e, r, o, s, n[c + 13], 5, -1444681467), r, o, n[c + 2], 9, -51403784), e, r, n[c + 7], 14, 1735328473), s, e, n[c + 12], 20, -1926607734), o = h(o, s = h(s, e = h(e, r, o, s, n[c + 5], 4, -378558), r, o, n[c + 8], 11, -2022574463), e, r, n[c + 11], 16, 1839030562), s, e, n[c + 14], 23, -35309556), o = h(o, s = h(s, e = h(e, r, o, s, n[c + 1], 4, -1530992060), r, o, n[c + 4], 11, 1272893353), e, r, n[c + 7], 16, -155497632), s, e, n[c + 10], 23, -1094730640), o = h(o, s = h(s, e = h(e, r, o, s, n[c + 13], 4, 681279174), r, o, n[c + 0], 11, -358537222), e, r, n[c + 3], 16, -722521979), s, e, n[c + 6], 23, 76029189), o = h(o, s = h(s, e = h(e, r, o, s, n[c + 9], 4, -640364487), r, o, n[c + 12], 11, -421815835), e, r, n[c + 15], 16, 530742520), s, e, n[c + 2], 23, -995338651), o = d(o, s = d(s, e = d(e, r, o, s, n[c + 0], 6, -198630844), r, o, n[c + 7], 10, 1126891415), e, r, n[c + 14], 15, -1416354905), s, e, n[c + 5], 21, -57434055), o = d(o, s = d(s, e = d(e, r, o, s, n[c + 12], 6, 1700485571), r, o, n[c + 3], 10, -1894986606), e, r, n[c + 10], 15, -1051523), s, e, n[c + 1], 21, -2054922799), o = d(o, s = d(s, e = d(e, r, o, s, n[c + 8], 6, 1873313359), r, o, n[c + 15], 10, -30611744), e, r, n[c + 6], 15, -1560198380), s, e, n[c + 13], 21, 1309151649), o = d(o, s = d(s, e = d(e, r, o, s, n[c + 4], 6, -145523070), r, o, n[c + 11], 10, -1120210379), e, r, n[c + 2], 15, 718787259), s, e, n[c + 9], 21, -343485551), e = E(e, y), r = E(r, u), o = E(o, R), s = E(s, C);
733
759
  }
734
760
  return Array(e, r, o, s);
735
761
  }
736
- function C(n, t, e, r, o, s) {
737
- return E(gt(E(E(t, n), E(r, s)), o), e);
762
+ function L(n, t, e, r, o, s) {
763
+ return E(wt(E(E(t, n), E(r, s)), o), e);
738
764
  }
739
765
  function l(n, t, e, r, o, s, c) {
740
- return C(t & e | ~t & r, n, t, o, s, c);
741
- }
742
- function h(n, t, e, r, o, s, c) {
743
- return C(t & r | e & ~r, n, t, o, s, c);
766
+ return L(t & e | ~t & r, n, t, o, s, c);
744
767
  }
745
768
  function f(n, t, e, r, o, s, c) {
746
- return C(t ^ e ^ r, n, t, o, s, c);
769
+ return L(t & r | e & ~r, n, t, o, s, c);
770
+ }
771
+ function h(n, t, e, r, o, s, c) {
772
+ return L(t ^ e ^ r, n, t, o, s, c);
747
773
  }
748
774
  function d(n, t, e, r, o, s, c) {
749
- return C(e ^ (t | ~r), n, t, o, s, c);
775
+ return L(e ^ (t | ~r), n, t, o, s, c);
750
776
  }
751
777
  function E(n, t) {
752
778
  var e = (65535 & n) + (65535 & t);
753
779
  return (n >> 16) + (t >> 16) + (e >> 16) << 16 | 65535 & e;
754
780
  }
755
- function gt(n, t) {
781
+ function wt(n, t) {
756
782
  return n << t | n >>> 32 - t;
757
783
  }
758
- function zt(n) {
784
+ function Kt(n) {
759
785
  return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(n);
760
786
  }
761
- function Jt(n, t = "mp") {
787
+ function Zt(n, t = "mp") {
762
788
  return n ? `https://www.gravatar.com/avatar/${ht(n)}?d=${t}` : "";
763
789
  }
764
- function Kt(n) {
765
- const t = new RegExp(
766
- "(?:(?<protocol>[\\w\\d]+)\\:\\/\\/)?(?:(?<user>.+)\\@)?(?<host>(?<domain>[^:\\/\\?#@\\n]+)(?:\\:(?<port>\\d*))?)(?<path>\\/.*?)?(?:\\?(?<query>.*?))?(?:#(?<fragment>.*?))?$",
767
- "gm"
768
- ).exec(n), e = (t == null ? void 0 : t.groups) ?? {}, r = e.domain.split(".");
769
- 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) {
770
- const o = e.query.split("&"), s = {};
771
- o.forEach((c) => {
772
- const [y, a] = c.split("=");
773
- s[y] = a;
774
- }), e.query = s;
775
- }
776
- return e;
790
+ function Vt(n) {
791
+ (typeof n == "number" || typeof n == "string") && (n = new Date(n));
792
+ let t = n.getHours(), e = "AM";
793
+ 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}`;
777
794
  }
778
- function Zt(n) {
779
- const t = n instanceof Date ? n : new Date(n);
780
- return new Intl.DateTimeFormat("en-us", {
781
- weekday: "long",
782
- month: "short",
783
- day: "numeric",
784
- hour: "numeric",
785
- minute: "numeric",
786
- hour12: !0
787
- }).format(t);
788
- }
789
- function wt(n) {
795
+ function Et(n) {
790
796
  return new Promise((t) => setTimeout(t, n));
791
797
  }
792
- async function Vt(n, t = 100) {
798
+ async function Xt(n, t = 100) {
793
799
  for (; n(); )
794
- await wt(t);
800
+ await Et(t);
795
801
  }
796
- function Xt(n) {
802
+ function Qt(n) {
797
803
  return (n instanceof Date ? n.getTime() : n) - (/* @__PURE__ */ new Date()).getTime();
798
804
  }
805
+ function _t() {
806
+ return Object.keys({});
807
+ }
799
808
  export {
800
809
  A as ASet,
801
- X as BadGatewayError,
802
- v as BadRequestError,
810
+ Q as BadGatewayError,
811
+ Y as BadRequestError,
803
812
  kt as CliBackground,
804
- B as CliEffects,
805
- L as CliForeground,
813
+ S as CliEffects,
814
+ $ as CliForeground,
806
815
  p as CustomError,
807
- W as ForbiddenError,
808
- _ as GatewayTimeoutError,
816
+ z as ForbiddenError,
817
+ tt as GatewayTimeoutError,
809
818
  q as Http,
810
- Z as InternalServerError,
819
+ V as InternalServerError,
811
820
  U as JSONAttemptParse,
812
- At as JSONSanitized,
813
- ut as LOG_LEVEL,
821
+ bt as JSONSanitize,
822
+ lt as LOG_LEVEL,
814
823
  P as Logger,
815
- J as MethodNotAllowedError,
816
- K as NotAcceptableError,
817
- z as NotFoundError,
818
- V as NotImplementedError,
819
- H as PaymentRequiredError,
824
+ K as MethodNotAllowedError,
825
+ Z as NotAcceptableError,
826
+ J as NotFoundError,
827
+ X as NotImplementedError,
828
+ W as PaymentRequiredError,
820
829
  m as PromiseProgress,
821
- Q as ServiceUnavailableError,
822
- F as TypedEmitter,
823
- Y as UnauthorizedError,
830
+ _ as ServiceUnavailableError,
831
+ v as TypedEmitter,
832
+ H as UnauthorizedError,
824
833
  Rt as addUnique,
825
834
  Ot as arrayDiff,
826
- Lt as caseInsensitiveSort,
827
- rt as clean,
828
- Gt as countChars,
829
- Ut as createHex,
830
- Mt as dec2Frac,
831
- mt as deepCopy,
832
- ot as deepMerge,
833
- S as dotNotation,
834
- at as download,
835
- Tt as downloadBlob,
836
- Dt as errorFromCode,
835
+ $t as caseInsensitiveSort,
836
+ ot as clean,
837
+ Nt as csv,
838
+ Gt as dec2Frac,
839
+ xt as deepCopy,
840
+ st as deepMerge,
841
+ x as dotNotation,
842
+ Tt as downloadFile,
843
+ at as downloadUrl,
844
+ Bt as encodeQuery,
845
+ jt as errorFromCode,
837
846
  It as fileBrowser,
838
- Ct as findByProp,
847
+ Lt as findByProp,
839
848
  ct as flattenArr,
840
- st as flattenObj,
841
- xt as formData,
849
+ F as flattenObj,
850
+ St as formData,
842
851
  qt as formatBytes,
843
- Zt as formatDate,
852
+ Vt as formatDate,
844
853
  Pt as formatPhoneNumber,
845
- jt as fracToDec,
846
- Jt as gravatar,
854
+ Ut as fracToDec,
855
+ Zt as gravatar,
847
856
  G as includes,
848
857
  Ft as insertAt,
849
858
  b as isEqual,
850
- Nt as makeArray,
859
+ ut as makeArray,
851
860
  it as makeUnique,
852
- Wt as matchAll,
861
+ zt as matchAll,
853
862
  ht as md5,
854
- Bt as mixin,
863
+ At as mixin,
855
864
  vt as pad,
856
- Yt as randomString,
857
- Ht as randomStringBuilder,
858
- wt as sleep,
859
- Vt as sleepUntil,
860
- St as sortByProp,
861
- Xt as timeUntil,
862
- $t as uploadWithProgress,
863
- bt as urlEncode,
864
- Kt as urlParser,
865
- zt as validateEmail
865
+ Jt as parseUrl,
866
+ Yt as randomHex,
867
+ Ht as randomString,
868
+ Wt as randomStringBuilder,
869
+ Et as sleep,
870
+ Xt as sleepUntil,
871
+ Ct as sortByProp,
872
+ Qt as timeUntil,
873
+ Mt as timestampFilename,
874
+ _t as tyoeKeys,
875
+ Dt as uploadWithProgress,
876
+ Kt as validateEmail
866
877
  };
867
878
  //# sourceMappingURL=index.mjs.map