@ztimson/utils 0.10.2 → 0.10.4
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/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.mjs +170 -175
- package/dist/utils.mjs.map +1 -1
- package/package.json +1 -1
package/dist/utils.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var c = (n, e, t) => (
|
|
4
|
-
function
|
|
1
|
+
var k = Object.defineProperty;
|
|
2
|
+
var G = (n, e, t) => e in n ? k(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var c = (n, e, t) => (G(n, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
function j(n, e = !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((t) => t != null) : Object.entries(n).forEach(([t, r]) => {
|
|
8
8
|
(e && r === void 0 || !e && r == null) && delete n[t];
|
|
9
9
|
}), n;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function tt(n) {
|
|
12
12
|
return JSON.parse(JSON.stringify(n));
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function S(n, e, t) {
|
|
15
15
|
if (!(n == null || !e))
|
|
16
16
|
return e.split(/[.[\]]/g).filter((r) => r.length).reduce((r, o, s, i) => {
|
|
17
17
|
if ((o[0] == '"' || o[0] == "'") && (o = o.slice(1, -1)), !(r != null && r.hasOwnProperty(o))) {
|
|
@@ -22,28 +22,28 @@ function A(n, e, t) {
|
|
|
22
22
|
return t !== void 0 && s == i.length - 1 ? r[o] = t : r[o];
|
|
23
23
|
}, n);
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function M(n, e, t = {}) {
|
|
26
26
|
if (typeof n == "object" && !Array.isArray(n)) {
|
|
27
27
|
for (const r of Object.keys(n)) {
|
|
28
28
|
const o = e ? e + "." + r : r;
|
|
29
|
-
typeof n[r] == "object" ?
|
|
29
|
+
typeof n[r] == "object" ? M(n[r], o, t) : t[o] = n[r];
|
|
30
30
|
}
|
|
31
31
|
return t;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function L(n, e, t = !1) {
|
|
35
35
|
if (n == null)
|
|
36
36
|
return t;
|
|
37
37
|
if (Array.isArray(e))
|
|
38
|
-
return e.findIndex((o, s) => !
|
|
38
|
+
return e.findIndex((o, s) => !L(n[s], e[s], t)) == -1;
|
|
39
39
|
const r = typeof e;
|
|
40
|
-
return r != typeof n ? !1 : r == "object" ? Object.keys(e).find((o) => !
|
|
40
|
+
return r != typeof n ? !1 : r == "object" ? Object.keys(e).find((o) => !L(n[o], e[o], t)) == null : r == "function" ? n.toString() == e.toString() : n == e;
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function B(n, e) {
|
|
43
43
|
const t = typeof n, r = typeof e;
|
|
44
|
-
return t != "object" || n == null || r != "object" || e == null ? t == "function" && r == "function" ? n.toString() == e.toString() : n === e : Object.keys(n).length != Object.keys(e).length ? !1 : Object.keys(n).every((s) =>
|
|
44
|
+
return t != "object" || n == null || r != "object" || e == null ? t == "function" && r == "function" ? n.toString() == e.toString() : n === e : Object.keys(n).length != Object.keys(e).length ? !1 : Object.keys(n).every((s) => B(n[s], e[s]));
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function et(n, e) {
|
|
47
47
|
e.forEach((t) => {
|
|
48
48
|
Object.getOwnPropertyNames(t.prototype).forEach((r) => {
|
|
49
49
|
Object.defineProperty(
|
|
@@ -54,7 +54,7 @@ function tt(n, e) {
|
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function nt(n, e) {
|
|
58
58
|
let t = [];
|
|
59
59
|
return JSON.parse(JSON.stringify(n, (r, o) => {
|
|
60
60
|
if (typeof o == "object" && o !== null) {
|
|
@@ -65,42 +65,42 @@ function et(n, e) {
|
|
|
65
65
|
return o;
|
|
66
66
|
}, e));
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function rt(n, e) {
|
|
69
69
|
return n.indexOf(e) === -1 && n.push(e), n;
|
|
70
70
|
}
|
|
71
|
-
function
|
|
72
|
-
return
|
|
73
|
-
...n.filter((t) => !e.includes((r) =>
|
|
74
|
-
...e.filter((t) => !n.includes((r) =>
|
|
71
|
+
function ot(n, e) {
|
|
72
|
+
return U([
|
|
73
|
+
...n.filter((t) => !e.includes((r) => B(t, r))),
|
|
74
|
+
...e.filter((t) => !n.includes((r) => B(t, r)))
|
|
75
75
|
]);
|
|
76
76
|
}
|
|
77
|
-
function
|
|
77
|
+
function st(n) {
|
|
78
78
|
return function(e, t) {
|
|
79
|
-
const r =
|
|
79
|
+
const r = S(e, n), o = S(t, n);
|
|
80
80
|
return typeof r != "string" || typeof o != "string" ? 1 : r.toLowerCase().localeCompare(o.toLowerCase());
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
function
|
|
84
|
-
return n.forEach((t) => Array.isArray(t) ?
|
|
83
|
+
function P(n, e = []) {
|
|
84
|
+
return n.forEach((t) => Array.isArray(t) ? P(t, e) : e.push(t)), e;
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function it(n, e = !1) {
|
|
87
87
|
return function(t, r) {
|
|
88
|
-
const o =
|
|
88
|
+
const o = S(t, n), s = S(r, n);
|
|
89
89
|
return typeof o == "number" && typeof s == "number" ? (e ? -1 : 1) * (o - s) : o > s ? e ? -1 : 1 : o < s ? e ? 1 : -1 : 0;
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
|
-
function
|
|
93
|
-
return (t) =>
|
|
92
|
+
function ct(n, e) {
|
|
93
|
+
return (t) => B(t[n], e);
|
|
94
94
|
}
|
|
95
|
-
function
|
|
95
|
+
function U(n) {
|
|
96
96
|
for (let e = n.length - 1; e >= 0; e--)
|
|
97
|
-
n.slice(0, e).find((t) =>
|
|
97
|
+
n.slice(0, e).find((t) => B(t, n[e])) && n.splice(e, 1);
|
|
98
98
|
return n;
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function ut(n) {
|
|
101
101
|
return Array.isArray(n) ? n : [n];
|
|
102
102
|
}
|
|
103
|
-
class
|
|
103
|
+
class w extends Array {
|
|
104
104
|
get size() {
|
|
105
105
|
return this.length;
|
|
106
106
|
}
|
|
@@ -115,13 +115,13 @@ class m extends Array {
|
|
|
115
115
|
t != -1 && this.slice(t, 1);
|
|
116
116
|
}
|
|
117
117
|
difference(e) {
|
|
118
|
-
return new
|
|
118
|
+
return new w(this.reduce((t, r) => (e.has(r) || t.push(r), t), []));
|
|
119
119
|
}
|
|
120
120
|
has(e) {
|
|
121
121
|
return this.indexOf(e) != -1;
|
|
122
122
|
}
|
|
123
123
|
intersection(e) {
|
|
124
|
-
return new
|
|
124
|
+
return new w(this.reduce((t, r) => (e.has(r) && t.push(r), t), []));
|
|
125
125
|
}
|
|
126
126
|
isDisjointFrom(e) {
|
|
127
127
|
return this.intersection(e).size == 0;
|
|
@@ -133,17 +133,17 @@ class m extends Array {
|
|
|
133
133
|
return e.findIndex((t) => !this.has(t)) == -1;
|
|
134
134
|
}
|
|
135
135
|
symmetricDifference(e) {
|
|
136
|
-
return new
|
|
136
|
+
return new w([...this.difference(e), ...e.difference(this)]);
|
|
137
137
|
}
|
|
138
138
|
union(e) {
|
|
139
|
-
return new
|
|
139
|
+
return new w([...this, ...e]);
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
function
|
|
142
|
+
function at(n, e) {
|
|
143
143
|
const t = document.createElement("a");
|
|
144
144
|
t.href = n, t.download = e, document.body.appendChild(t), t.click(), document.body.removeChild(t);
|
|
145
145
|
}
|
|
146
|
-
class
|
|
146
|
+
class D {
|
|
147
147
|
constructor() {
|
|
148
148
|
c(this, "listeners", {});
|
|
149
149
|
}
|
|
@@ -184,8 +184,8 @@ class $ {
|
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
-
c(
|
|
188
|
-
class
|
|
187
|
+
c(D, "listeners", {});
|
|
188
|
+
class m extends Error {
|
|
189
189
|
constructor(t, r) {
|
|
190
190
|
super(t);
|
|
191
191
|
c(this, "_code");
|
|
@@ -212,8 +212,8 @@ class E extends Error {
|
|
|
212
212
|
return this.message || super.toString();
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
c(
|
|
216
|
-
class
|
|
215
|
+
c(m, "code", 500);
|
|
216
|
+
class Y extends m {
|
|
217
217
|
constructor(e = "Bad Request") {
|
|
218
218
|
super(e);
|
|
219
219
|
}
|
|
@@ -221,8 +221,8 @@ class D extends E {
|
|
|
221
221
|
return e.constructor.code == this.code;
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
|
-
c(
|
|
225
|
-
class
|
|
224
|
+
c(Y, "code", 400);
|
|
225
|
+
class H extends m {
|
|
226
226
|
constructor(e = "Unauthorized") {
|
|
227
227
|
super(e);
|
|
228
228
|
}
|
|
@@ -230,8 +230,8 @@ class k extends E {
|
|
|
230
230
|
return e.constructor.code == this.code;
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
|
-
c(
|
|
234
|
-
class
|
|
233
|
+
c(H, "code", 401);
|
|
234
|
+
class W extends m {
|
|
235
235
|
constructor(e = "Forbidden") {
|
|
236
236
|
super(e);
|
|
237
237
|
}
|
|
@@ -239,8 +239,8 @@ class G extends E {
|
|
|
239
239
|
return e.constructor.code == this.code;
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
-
c(
|
|
243
|
-
class
|
|
242
|
+
c(W, "code", 403);
|
|
243
|
+
class F extends m {
|
|
244
244
|
constructor(e = "Not Found") {
|
|
245
245
|
super(e);
|
|
246
246
|
}
|
|
@@ -248,8 +248,8 @@ class j extends E {
|
|
|
248
248
|
return e.constructor.code == this.code;
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
|
-
c(
|
|
252
|
-
class
|
|
251
|
+
c(F, "code", 404);
|
|
252
|
+
class q extends m {
|
|
253
253
|
constructor(e = "Internal Server Error") {
|
|
254
254
|
super(e);
|
|
255
255
|
}
|
|
@@ -257,8 +257,8 @@ class M extends E {
|
|
|
257
257
|
return e.constructor.code == this.code;
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
|
-
c(
|
|
261
|
-
const
|
|
260
|
+
c(q, "code", 500);
|
|
261
|
+
const x = {
|
|
262
262
|
CLEAR: "\x1B[0m",
|
|
263
263
|
BRIGHT: "\x1B[1m",
|
|
264
264
|
DIM: "\x1B[2m",
|
|
@@ -266,7 +266,7 @@ const w = {
|
|
|
266
266
|
BLINK: "\x1B[5m",
|
|
267
267
|
REVERSE: "\x1B[7m",
|
|
268
268
|
HIDDEN: "\x1B[8m"
|
|
269
|
-
},
|
|
269
|
+
}, O = {
|
|
270
270
|
BLACK: "\x1B[30m",
|
|
271
271
|
RED: "\x1B[31m",
|
|
272
272
|
GREEN: "\x1B[32m",
|
|
@@ -283,7 +283,7 @@ const w = {
|
|
|
283
283
|
LIGHT_MAGENTA: "\x1B[95m",
|
|
284
284
|
LIGHT_CYAN: "\x1B[96m",
|
|
285
285
|
WHITE: "\x1B[97m"
|
|
286
|
-
},
|
|
286
|
+
}, lt = {
|
|
287
287
|
BLACK: "\x1B[40m",
|
|
288
288
|
RED: "\x1B[41m",
|
|
289
289
|
GREEN: "\x1B[42m",
|
|
@@ -294,8 +294,8 @@ const w = {
|
|
|
294
294
|
WHITE: "\x1B[47m",
|
|
295
295
|
GREY: "\x1B[100m"
|
|
296
296
|
};
|
|
297
|
-
var
|
|
298
|
-
const f = class f extends
|
|
297
|
+
var v = /* @__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))(v || {});
|
|
298
|
+
const f = class f extends D {
|
|
299
299
|
constructor(e) {
|
|
300
300
|
super(), this.namespace = e;
|
|
301
301
|
}
|
|
@@ -303,8 +303,8 @@ const f = class f extends $ {
|
|
|
303
303
|
const s = e.toString(), i = t - s.length;
|
|
304
304
|
if (i <= 0)
|
|
305
305
|
return s;
|
|
306
|
-
const
|
|
307
|
-
return o ? s +
|
|
306
|
+
const p = Array(~~(i / r.length)).fill(r).join("");
|
|
307
|
+
return o ? s + p : p + s;
|
|
308
308
|
}
|
|
309
309
|
format(...e) {
|
|
310
310
|
const t = /* @__PURE__ */ new Date();
|
|
@@ -314,90 +314,90 @@ const f = class f extends $ {
|
|
|
314
314
|
if (f.LOG_LEVEL < 4)
|
|
315
315
|
return;
|
|
316
316
|
const t = this.format(...e);
|
|
317
|
-
f.emit(4, t), console.debug(
|
|
317
|
+
f.emit(4, t), console.debug(O.LIGHT_GREY + t + x.CLEAR);
|
|
318
318
|
}
|
|
319
319
|
log(...e) {
|
|
320
320
|
if (f.LOG_LEVEL < 3)
|
|
321
321
|
return;
|
|
322
322
|
const t = this.format(...e);
|
|
323
|
-
f.emit(3, t), console.log(
|
|
323
|
+
f.emit(3, t), console.log(x.CLEAR + t);
|
|
324
324
|
}
|
|
325
325
|
info(...e) {
|
|
326
326
|
if (f.LOG_LEVEL < 2)
|
|
327
327
|
return;
|
|
328
328
|
const t = this.format(...e);
|
|
329
|
-
f.emit(2, t), console.info(
|
|
329
|
+
f.emit(2, t), console.info(O.BLUE + t + x.CLEAR);
|
|
330
330
|
}
|
|
331
331
|
warn(...e) {
|
|
332
332
|
if (f.LOG_LEVEL < 1)
|
|
333
333
|
return;
|
|
334
334
|
const t = this.format(...e);
|
|
335
|
-
f.emit(1, t), console.warn(
|
|
335
|
+
f.emit(1, t), console.warn(O.YELLOW + t + x.CLEAR);
|
|
336
336
|
}
|
|
337
337
|
error(...e) {
|
|
338
338
|
if (f.LOG_LEVEL < 0)
|
|
339
339
|
return;
|
|
340
340
|
const t = this.format(...e);
|
|
341
|
-
f.emit(0, t), console.error(
|
|
341
|
+
f.emit(0, t), console.error(O.RED + t + x.CLEAR);
|
|
342
342
|
}
|
|
343
343
|
};
|
|
344
344
|
c(f, "LOG_LEVEL", 4);
|
|
345
|
-
let
|
|
345
|
+
let I = f;
|
|
346
346
|
function ht(n) {
|
|
347
|
-
const e = (
|
|
347
|
+
const e = (p, d) => d < 1e-7 ? p : e(d, ~~(p % d)), t = n.toString().length - 2;
|
|
348
348
|
let r = Math.pow(10, t), o = n * r;
|
|
349
349
|
const s = e(o, r);
|
|
350
350
|
o = ~~(o / s), r = ~~(r / s);
|
|
351
351
|
const i = ~~(o / r);
|
|
352
352
|
return o -= i * r, `${i ? i + " " : ""}${~~o}/${~~r}`;
|
|
353
353
|
}
|
|
354
|
-
function
|
|
354
|
+
function ft(n) {
|
|
355
355
|
let e = n.split(" ");
|
|
356
356
|
const t = e.length == 2 ? Number(e[0]) : 0;
|
|
357
357
|
return e = e.pop().split("/"), t + Number(e[0]) / Number(e[1]);
|
|
358
358
|
}
|
|
359
|
-
function
|
|
359
|
+
function dt(n, e) {
|
|
360
360
|
return n.length - n.replaceAll(e, "").length;
|
|
361
361
|
}
|
|
362
|
-
function
|
|
362
|
+
function pt(n) {
|
|
363
363
|
return Array(n).fill(null).map(() => Math.round(Math.random() * 15).toString(16)).join("");
|
|
364
364
|
}
|
|
365
|
-
const
|
|
365
|
+
const N = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", b = "0123456789", T = "~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/", z = N + b + T;
|
|
366
366
|
function gt(n) {
|
|
367
367
|
const e = /(\+?1)?.*?(\d{3}).*?(\d{3}).*?(\d{4})/g.exec(n);
|
|
368
368
|
if (!e)
|
|
369
369
|
throw new Error(`Number cannot be parsed: ${n}`);
|
|
370
370
|
return `${e[1] ?? ""} (${e[2]}) ${e[3]}-${e[4]}`.trim();
|
|
371
371
|
}
|
|
372
|
-
function
|
|
372
|
+
function yt(n, e, t) {
|
|
373
373
|
return `${n.slice(0, t)}${e}${n.slice(t + 1)}`;
|
|
374
374
|
}
|
|
375
|
-
function
|
|
375
|
+
function Et(n, e, t, r = !0) {
|
|
376
376
|
const o = n.toString(), s = e - o.length;
|
|
377
377
|
if (s <= 0)
|
|
378
378
|
return o;
|
|
379
379
|
const i = Array(~~(s / t.length)).fill(t).join("");
|
|
380
380
|
return r ? i + o : o + i;
|
|
381
381
|
}
|
|
382
|
-
function
|
|
382
|
+
function mt(n, e = z) {
|
|
383
383
|
return Array(n).fill(null).map(() => {
|
|
384
384
|
const t = ~~(Math.random() * e.length);
|
|
385
385
|
return e[t];
|
|
386
386
|
}).join("");
|
|
387
387
|
}
|
|
388
|
-
function
|
|
388
|
+
function xt(n, e = !1, t = !1, r = !1) {
|
|
389
389
|
if (!e && !t && !r)
|
|
390
390
|
throw new Error("Must enable at least one: letters, numbers, symbols");
|
|
391
391
|
return Array(n).fill(null).map(() => {
|
|
392
392
|
let o;
|
|
393
393
|
do {
|
|
394
394
|
const s = ~~(Math.random() * 3);
|
|
395
|
-
e && s == 0 ? o =
|
|
395
|
+
e && s == 0 ? o = N[~~(Math.random() * N.length)] : t && s == 1 ? o = b[~~(Math.random() * b.length)] : r && s == 2 && (o = T[~~(Math.random() * T.length)]);
|
|
396
396
|
} while (!o);
|
|
397
397
|
return o;
|
|
398
398
|
}).join("");
|
|
399
399
|
}
|
|
400
|
-
function
|
|
400
|
+
function wt(n, e) {
|
|
401
401
|
if (typeof e == "string" && (e = new RegExp(e, "g")), !e.global)
|
|
402
402
|
throw new TypeError("Regular expression must be global.");
|
|
403
403
|
let t = [], r;
|
|
@@ -405,69 +405,69 @@ function mt(n, e) {
|
|
|
405
405
|
t.push(r);
|
|
406
406
|
return t;
|
|
407
407
|
}
|
|
408
|
-
function
|
|
409
|
-
var e =
|
|
408
|
+
function J(n) {
|
|
409
|
+
var e = K(Z(Q(V(n), 8 * n.length)));
|
|
410
410
|
return e.toLowerCase();
|
|
411
411
|
}
|
|
412
|
-
function
|
|
412
|
+
function K(n) {
|
|
413
413
|
for (var e, t = "0123456789ABCDEF", r = "", o = 0; o < n.length; o++)
|
|
414
414
|
e = n.charCodeAt(o), r += t.charAt(e >>> 4 & 15) + t.charAt(15 & e);
|
|
415
415
|
return r;
|
|
416
416
|
}
|
|
417
|
-
function
|
|
417
|
+
function V(n) {
|
|
418
418
|
for (var e = Array(n.length >> 2), t = 0; t < e.length; t++)
|
|
419
419
|
e[t] = 0;
|
|
420
420
|
for (t = 0; t < 8 * n.length; t += 8)
|
|
421
421
|
e[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32;
|
|
422
422
|
return e;
|
|
423
423
|
}
|
|
424
|
-
function
|
|
424
|
+
function Z(n) {
|
|
425
425
|
for (var e = "", t = 0; t < 32 * n.length; t += 8)
|
|
426
426
|
e += String.fromCharCode(n[t >> 5] >>> t % 32 & 255);
|
|
427
427
|
return e;
|
|
428
428
|
}
|
|
429
|
-
function
|
|
429
|
+
function Q(n, e) {
|
|
430
430
|
n[e >> 5] |= 128 << e % 32, n[14 + (e + 64 >>> 9 << 4)] = e;
|
|
431
431
|
for (var t = 1732584193, r = -271733879, o = -1732584194, s = 271733878, i = 0; i < n.length; i += 16) {
|
|
432
|
-
var
|
|
433
|
-
r =
|
|
432
|
+
var p = t, d = r, A = o, E = s;
|
|
433
|
+
r = h(r = h(r = h(r = h(r = l(r = l(r = l(r = l(r = a(r = a(r = a(r = a(r = u(r = u(r = u(r = u(r, o = u(o, s = u(s, t = u(t, r, o, s, n[i + 0], 7, -680876936), r, o, n[i + 1], 12, -389564586), t, r, n[i + 2], 17, 606105819), s, t, n[i + 3], 22, -1044525330), o = u(o, s = u(s, t = u(t, r, o, s, n[i + 4], 7, -176418897), r, o, n[i + 5], 12, 1200080426), t, r, n[i + 6], 17, -1473231341), s, t, n[i + 7], 22, -45705983), o = u(o, s = u(s, t = u(t, r, o, s, n[i + 8], 7, 1770035416), r, o, n[i + 9], 12, -1958414417), t, r, n[i + 10], 17, -42063), s, t, n[i + 11], 22, -1990404162), o = u(o, s = u(s, t = u(t, r, o, s, n[i + 12], 7, 1804603682), r, o, n[i + 13], 12, -40341101), t, r, n[i + 14], 17, -1502002290), s, t, n[i + 15], 22, 1236535329), o = a(o, s = a(s, t = a(t, r, o, s, n[i + 1], 5, -165796510), r, o, n[i + 6], 9, -1069501632), t, r, n[i + 11], 14, 643717713), s, t, n[i + 0], 20, -373897302), o = a(o, s = a(s, t = a(t, r, o, s, n[i + 5], 5, -701558691), r, o, n[i + 10], 9, 38016083), t, r, n[i + 15], 14, -660478335), s, t, n[i + 4], 20, -405537848), o = a(o, s = a(s, t = a(t, r, o, s, n[i + 9], 5, 568446438), r, o, n[i + 14], 9, -1019803690), t, r, n[i + 3], 14, -187363961), s, t, n[i + 8], 20, 1163531501), o = a(o, s = a(s, t = a(t, r, o, s, n[i + 13], 5, -1444681467), r, o, n[i + 2], 9, -51403784), t, r, n[i + 7], 14, 1735328473), s, t, n[i + 12], 20, -1926607734), o = l(o, s = l(s, t = l(t, r, o, s, n[i + 5], 4, -378558), r, o, n[i + 8], 11, -2022574463), t, r, n[i + 11], 16, 1839030562), s, t, n[i + 14], 23, -35309556), o = l(o, s = l(s, t = l(t, r, o, s, n[i + 1], 4, -1530992060), r, o, n[i + 4], 11, 1272893353), t, r, n[i + 7], 16, -155497632), s, t, n[i + 10], 23, -1094730640), o = l(o, s = l(s, t = l(t, r, o, s, n[i + 13], 4, 681279174), r, o, n[i + 0], 11, -358537222), t, r, n[i + 3], 16, -722521979), s, t, n[i + 6], 23, 76029189), o = l(o, s = l(s, t = l(t, r, o, s, n[i + 9], 4, -640364487), r, o, n[i + 12], 11, -421815835), t, r, n[i + 15], 16, 530742520), s, t, n[i + 2], 23, -995338651), o = h(o, s = h(s, t = h(t, r, o, s, n[i + 0], 6, -198630844), r, o, n[i + 7], 10, 1126891415), t, r, n[i + 14], 15, -1416354905), s, t, n[i + 5], 21, -57434055), o = h(o, s = h(s, t = h(t, r, o, s, n[i + 12], 6, 1700485571), r, o, n[i + 3], 10, -1894986606), t, r, n[i + 10], 15, -1051523), s, t, n[i + 1], 21, -2054922799), o = h(o, s = h(s, t = h(t, r, o, s, n[i + 8], 6, 1873313359), r, o, n[i + 15], 10, -30611744), t, r, n[i + 6], 15, -1560198380), s, t, n[i + 13], 21, 1309151649), o = h(o, s = h(s, t = h(t, r, o, s, n[i + 4], 6, -145523070), r, o, n[i + 11], 10, -1120210379), t, r, n[i + 2], 15, 718787259), s, t, n[i + 9], 21, -343485551), t = y(t, p), r = y(r, d), o = y(o, A), s = y(s, E);
|
|
434
434
|
}
|
|
435
435
|
return Array(t, r, o, s);
|
|
436
436
|
}
|
|
437
|
-
function
|
|
438
|
-
return y(
|
|
437
|
+
function R(n, e, t, r, o, s) {
|
|
438
|
+
return y(X(y(y(e, n), y(r, s)), o), t);
|
|
439
439
|
}
|
|
440
440
|
function u(n, e, t, r, o, s, i) {
|
|
441
|
-
return
|
|
441
|
+
return R(e & t | ~e & r, n, e, o, s, i);
|
|
442
442
|
}
|
|
443
443
|
function a(n, e, t, r, o, s, i) {
|
|
444
|
-
return
|
|
445
|
-
}
|
|
446
|
-
function h(n, e, t, r, o, s, i) {
|
|
447
|
-
return S(e ^ t ^ r, n, e, o, s, i);
|
|
444
|
+
return R(e & r | t & ~r, n, e, o, s, i);
|
|
448
445
|
}
|
|
449
446
|
function l(n, e, t, r, o, s, i) {
|
|
450
|
-
return
|
|
447
|
+
return R(e ^ t ^ r, n, e, o, s, i);
|
|
448
|
+
}
|
|
449
|
+
function h(n, e, t, r, o, s, i) {
|
|
450
|
+
return R(t ^ (e | ~r), n, e, o, s, i);
|
|
451
451
|
}
|
|
452
452
|
function y(n, e) {
|
|
453
453
|
var t = (65535 & n) + (65535 & e);
|
|
454
454
|
return (n >> 16) + (e >> 16) + (t >> 16) << 16 | 65535 & t;
|
|
455
455
|
}
|
|
456
|
-
function
|
|
456
|
+
function X(n, e) {
|
|
457
457
|
return n << e | n >>> 32 - e;
|
|
458
458
|
}
|
|
459
|
-
function
|
|
459
|
+
function Bt(n) {
|
|
460
460
|
return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(n);
|
|
461
461
|
}
|
|
462
|
-
function
|
|
462
|
+
function At(n) {
|
|
463
463
|
return Object.entries(n).map(
|
|
464
464
|
([e, t]) => encodeURIComponent(e) + "=" + encodeURIComponent(t)
|
|
465
465
|
).join("&");
|
|
466
466
|
}
|
|
467
|
-
function
|
|
468
|
-
return n ? `https://www.gravatar.com/avatar/${
|
|
467
|
+
function Ct(n, e = "mp") {
|
|
468
|
+
return n ? `https://www.gravatar.com/avatar/${J(n)}?d=${e}` : "";
|
|
469
469
|
}
|
|
470
|
-
function
|
|
470
|
+
function Ot(n) {
|
|
471
471
|
const e = new RegExp(
|
|
472
472
|
"(?:(?<protocol>[\\w\\d]+)\\:\\/\\/)?(?:(?<user>.+)\\@)?(?<host>(?<domain>[^:\\/\\?#@\\n]+)(?:\\:(?<port>\\d*))?)(?<path>\\/.*?)?(?:\\?(?<query>.*?))?(?:#(?<fragment>.*?))?$",
|
|
473
473
|
"gm"
|
|
@@ -475,13 +475,13 @@ function St(n) {
|
|
|
475
475
|
if (t.port != null && (t.port = Number(t.port)), r.length > 2 && (t.domain = r.splice(-2, 2).join("."), t.subdomain = r.join(".")), t.query) {
|
|
476
476
|
const o = t.query.split("&"), s = {};
|
|
477
477
|
o.forEach((i) => {
|
|
478
|
-
const [
|
|
479
|
-
s[
|
|
478
|
+
const [p, d] = i.split("=");
|
|
479
|
+
s[p] = d;
|
|
480
480
|
}), t.query = s;
|
|
481
481
|
}
|
|
482
482
|
return t;
|
|
483
483
|
}
|
|
484
|
-
class
|
|
484
|
+
class St extends Promise {
|
|
485
485
|
constructor(t) {
|
|
486
486
|
super((r, o) => t(
|
|
487
487
|
(s) => r(s),
|
|
@@ -501,13 +501,13 @@ class Ct extends Promise {
|
|
|
501
501
|
return this.listeners.push(t), this;
|
|
502
502
|
}
|
|
503
503
|
}
|
|
504
|
-
function
|
|
504
|
+
function Rt(n) {
|
|
505
505
|
return (n instanceof Date ? n.getTime() : n) - (/* @__PURE__ */ new Date()).getTime();
|
|
506
506
|
}
|
|
507
|
-
function
|
|
507
|
+
function Nt(n) {
|
|
508
508
|
return new Promise((e) => setTimeout(e, n));
|
|
509
509
|
}
|
|
510
|
-
function
|
|
510
|
+
function bt(n) {
|
|
511
511
|
const e = n instanceof Date ? n : new Date(n);
|
|
512
512
|
return new Intl.DateTimeFormat("en-us", {
|
|
513
513
|
weekday: "long",
|
|
@@ -518,16 +518,16 @@ function Nt(n) {
|
|
|
518
518
|
hour12: !0
|
|
519
519
|
}).format(e);
|
|
520
520
|
}
|
|
521
|
-
const
|
|
521
|
+
const g = class g {
|
|
522
522
|
constructor(e = {}) {
|
|
523
523
|
c(this, "interceptors", {});
|
|
524
524
|
c(this, "headers", {});
|
|
525
|
-
this.opts = e, this.headers = e.headers || {}, e.interceptors && e.interceptors.forEach((t) =>
|
|
525
|
+
this.opts = e, this.headers = e.headers || {}, e.interceptors && e.interceptors.forEach((t) => g.addInterceptor(t));
|
|
526
526
|
}
|
|
527
527
|
static addInterceptor(e) {
|
|
528
|
-
const t = Object.keys(
|
|
529
|
-
return
|
|
530
|
-
|
|
528
|
+
const t = Object.keys(g.interceptors).length.toString();
|
|
529
|
+
return g.interceptors[t] = e, () => {
|
|
530
|
+
g.interceptors[t] = null;
|
|
531
531
|
};
|
|
532
532
|
}
|
|
533
533
|
addInterceptor(e) {
|
|
@@ -540,9 +540,9 @@ const p = class p {
|
|
|
540
540
|
var o, s;
|
|
541
541
|
if (!this.opts.url && !e.url)
|
|
542
542
|
throw new Error("URL needs to be set");
|
|
543
|
-
const t = ((o = e.url) != null && o.startsWith("http") ? e.url : (this.opts.url || "") + (e.url || "")).replace(/([^:]\/)\/+/g, "$1"), r =
|
|
543
|
+
const t = ((o = e.url) != null && o.startsWith("http") ? e.url : (this.opts.url || "") + (e.url || "")).replace(/([^:]\/)\/+/g, "$1"), r = j({
|
|
544
544
|
"Content-Type": e.body && !(e.body instanceof FormData) ? "application/json" : void 0,
|
|
545
|
-
...
|
|
545
|
+
...g.headers,
|
|
546
546
|
...this.headers,
|
|
547
547
|
...e.headers
|
|
548
548
|
});
|
|
@@ -551,76 +551,71 @@ const p = class p {
|
|
|
551
551
|
method: e.method || (e.body ? "POST" : "GET"),
|
|
552
552
|
body: (s = r["Content-Type"]) != null && s.startsWith("application/json") && e.body ? JSON.stringify(e.body) : e.body
|
|
553
553
|
}).then(async (i) => {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
554
|
+
for (let E of [...Object.values(g.interceptors), ...Object.values(this.interceptors)])
|
|
555
|
+
await new Promise((C) => E(i, () => C()));
|
|
556
|
+
const d = await (async () => {
|
|
557
|
+
var E, C;
|
|
558
|
+
return !e.skipConverting && ((E = i.headers.get("Content-Type")) != null && E.startsWith("application/json")) ? await i.json() : !e.skipConverting && ((C = i.headers.get("Content-Type")) != null && C.startsWith("text/plain")) ? await i.text() : i;
|
|
559
|
+
})();
|
|
560
|
+
if (i.ok)
|
|
561
|
+
return d;
|
|
562
|
+
const A = i.statusText || (typeof d == "string" ? d : null);
|
|
563
|
+
throw A ? new Error(A) : d;
|
|
560
564
|
});
|
|
561
565
|
}
|
|
562
566
|
};
|
|
563
|
-
c(
|
|
564
|
-
let
|
|
565
|
-
b.addInterceptor((n, e) => {
|
|
566
|
-
const t = (r) => {
|
|
567
|
-
var o, s;
|
|
568
|
-
return ((o = r.error) == null ? void 0 : o.message) || ((s = r.reason) == null ? void 0 : s.message) || r.message || r.statusText || r.toString();
|
|
569
|
-
};
|
|
570
|
-
if (n.status == 200)
|
|
571
|
-
return e();
|
|
572
|
-
throw n.status == 400 ? new D(t(n)) : n.status == 401 ? new k(t(n)) : n.status == 403 ? new G(t(n)) : n.status == 404 ? new j(t(n)) : n.status == 500 ? new M(t(n)) : new E(t(n), n.status);
|
|
573
|
-
});
|
|
567
|
+
c(g, "interceptors", {}), c(g, "headers", {});
|
|
568
|
+
let $ = g;
|
|
574
569
|
export {
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
570
|
+
w as ASet,
|
|
571
|
+
Y as BadRequestError,
|
|
572
|
+
lt as CliBackground,
|
|
573
|
+
x as CliEffects,
|
|
574
|
+
O as CliForeground,
|
|
575
|
+
m as CustomError,
|
|
576
|
+
W as ForbiddenError,
|
|
577
|
+
q as InternalServerError,
|
|
578
|
+
v as LOG_LEVEL,
|
|
579
|
+
I as Logger,
|
|
580
|
+
F as NotFoundError,
|
|
581
|
+
St as PromiseProgress,
|
|
582
|
+
D as TypedEmitter,
|
|
583
|
+
H as UnauthorizedError,
|
|
584
|
+
$ as XHR,
|
|
585
|
+
rt as addUnique,
|
|
586
|
+
ot as arrayDiff,
|
|
587
|
+
st as caseInsensitiveSort,
|
|
588
|
+
j as clean,
|
|
589
|
+
dt as countChars,
|
|
590
|
+
pt as createHex,
|
|
596
591
|
ht as dec2Frac,
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
592
|
+
tt as deepCopy,
|
|
593
|
+
S as dotNotation,
|
|
594
|
+
at as download,
|
|
595
|
+
ct as findByProp,
|
|
596
|
+
P as flattenArr,
|
|
597
|
+
M as flattenObj,
|
|
598
|
+
At as formEncode,
|
|
599
|
+
bt as formatDate,
|
|
605
600
|
gt as formatPhoneNumber,
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
601
|
+
ft as fracToDec,
|
|
602
|
+
Ct as gravatar,
|
|
603
|
+
L as includes,
|
|
604
|
+
yt as insertAt,
|
|
605
|
+
B as isEqual,
|
|
606
|
+
ut as makeArray,
|
|
607
|
+
U as makeUnique,
|
|
608
|
+
wt as matchAll,
|
|
609
|
+
J as md5,
|
|
610
|
+
et as mixin,
|
|
611
|
+
Et as pad,
|
|
612
|
+
mt as randomString,
|
|
613
|
+
xt as randomStringBuilder,
|
|
614
|
+
nt as sanitizedJSON,
|
|
615
|
+
Nt as sleep,
|
|
616
|
+
it as sortByProp,
|
|
617
|
+
Rt as timeUntil,
|
|
618
|
+
Ot as urlParser,
|
|
619
|
+
Bt as validateEmail
|
|
625
620
|
};
|
|
626
621
|
//# sourceMappingURL=utils.mjs.map
|