@ztimson/utils 0.8.2 → 0.10.0

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.mjs DELETED
@@ -1,620 +0,0 @@
1
- var H = Object.defineProperty;
2
- var W = (n, e, t) => e in n ? H(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var l = (n, e, t) => (W(n, typeof e != "symbol" ? e + "" : e, t), t);
4
- function q(n, e = !1) {
5
- if (n == null)
6
- throw new Error("Cannot clean a NULL value");
7
- return Array.isArray(n) ? n = n.filter((t) => t != null) : Object.entries(n).forEach(([t, r]) => {
8
- (e && r === void 0 || !e && r == null) && delete n[t];
9
- }), n;
10
- }
11
- function rt(n) {
12
- return JSON.parse(JSON.stringify(n));
13
- }
14
- function C(n, e, t) {
15
- if (!(n == null || !e))
16
- return e.split(/[.[\]]/g).filter((r) => r.length).reduce((r, o, s, i) => {
17
- if ((o[0] == '"' || o[0] == "'") && (o = o.slice(1, -1)), !(r != null && r.hasOwnProperty(o))) {
18
- if (t == null)
19
- return;
20
- r[o] = {};
21
- }
22
- return t !== void 0 && s == i.length - 1 ? r[o] = t : r[o];
23
- }, n);
24
- }
25
- function F(n, e, t = {}) {
26
- if (typeof n == "object" && !Array.isArray(n)) {
27
- for (const r of Object.keys(n)) {
28
- const o = e ? e + "." + r : r;
29
- typeof n[r] == "object" ? F(n[r], o, t) : t[o] = n[r];
30
- }
31
- return t;
32
- }
33
- }
34
- function $(n, e, t = !1) {
35
- if (n == null)
36
- return t;
37
- if (Array.isArray(e))
38
- return e.findIndex((o, s) => !$(n[s], e[s], t)) == -1;
39
- const r = typeof e;
40
- return r != typeof n ? !1 : r == "object" ? Object.keys(e).find((o) => !$(n[o], e[o], t)) == null : r == "function" ? n.toString() == e.toString() : n == e;
41
- }
42
- function R(n, e) {
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) => R(n[s], e[s]));
45
- }
46
- function ot(n, e) {
47
- e.forEach((t) => {
48
- Object.getOwnPropertyNames(t.prototype).forEach((r) => {
49
- Object.defineProperty(
50
- n.prototype,
51
- r,
52
- Object.getOwnPropertyDescriptor(t.prototype, r) || /* @__PURE__ */ Object.create(null)
53
- );
54
- });
55
- });
56
- }
57
- function st(n, e) {
58
- let t = [];
59
- return JSON.parse(JSON.stringify(n, (r, o) => {
60
- if (typeof o == "object" && o !== null) {
61
- if (t.includes(o))
62
- return;
63
- t.push(o);
64
- }
65
- return o;
66
- }, e));
67
- }
68
- function it(n, e) {
69
- return n.indexOf(e) === -1 && n.push(e), n;
70
- }
71
- function ct(n, e) {
72
- return z([
73
- ...n.filter((t) => !e.includes((r) => R(t, r))),
74
- ...e.filter((t) => !n.includes((r) => R(t, r)))
75
- ]);
76
- }
77
- function ut(n) {
78
- return function(e, t) {
79
- const r = C(e, n), o = C(t, n);
80
- return typeof r != "string" || typeof o != "string" ? 1 : r.toLowerCase().localeCompare(o.toLowerCase());
81
- };
82
- }
83
- function v(n, e = []) {
84
- return n.forEach((t) => Array.isArray(t) ? v(t, e) : e.push(t)), e;
85
- }
86
- function at(n, e = !1) {
87
- return function(t, r) {
88
- const o = C(t, n), s = C(r, n);
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
- };
91
- }
92
- function ht(n, e) {
93
- return (t) => R(t[n], e);
94
- }
95
- function z(n) {
96
- for (let e = n.length - 1; e >= 0; e--)
97
- n.slice(0, e).find((t) => R(t, n[e])) && n.splice(e, 1);
98
- return n;
99
- }
100
- function lt(n) {
101
- return Array.isArray(n) ? n : [n];
102
- }
103
- class A extends Array {
104
- get size() {
105
- return this.length;
106
- }
107
- constructor(e = []) {
108
- super(), e != null && e.forEach && e.forEach((t) => this.add(t));
109
- }
110
- add(e) {
111
- this.has(e) || this.push(e);
112
- }
113
- delete(e) {
114
- const t = this.indexOf(e);
115
- t != -1 && this.slice(t, 1);
116
- }
117
- difference(e) {
118
- return new A(this.reduce((t, r) => (e.has(r) || t.push(r), t), []));
119
- }
120
- has(e) {
121
- return this.indexOf(e) != -1;
122
- }
123
- intersection(e) {
124
- return new A(this.reduce((t, r) => (e.has(r) && t.push(r), t), []));
125
- }
126
- isDisjointFrom(e) {
127
- return this.intersection(e).size == 0;
128
- }
129
- isSubsetOf(e) {
130
- return this.findIndex((t) => !e.has(t)) == -1;
131
- }
132
- isSuperset(e) {
133
- return e.findIndex((t) => !this.has(t)) == -1;
134
- }
135
- symmetricDifference(e) {
136
- return new A([...this.difference(e), ...e.difference(this)]);
137
- }
138
- union(e) {
139
- return new A([...this, ...e]);
140
- }
141
- }
142
- class T {
143
- constructor() {
144
- l(this, "listeners", {});
145
- }
146
- static emit(e, ...t) {
147
- (this.listeners["*"] || []).forEach((r) => r(e, ...t)), (this.listeners[e.toString()] || []).forEach((r) => r(...t));
148
- }
149
- static off(e, t) {
150
- const r = e.toString();
151
- this.listeners[r] = (this.listeners[r] || []).filter((o) => o === t);
152
- }
153
- static on(e, t) {
154
- var o;
155
- const r = e.toString();
156
- return this.listeners[r] || (this.listeners[r] = []), (o = this.listeners[r]) == null || o.push(t), () => this.off(e, t);
157
- }
158
- static once(e, t) {
159
- return new Promise((r) => {
160
- const o = this.on(e, (...s) => {
161
- r(s.length == 1 ? s[0] : s), t && t(...s), o();
162
- });
163
- });
164
- }
165
- emit(e, ...t) {
166
- (this.listeners["*"] || []).forEach((r) => r(e, ...t)), (this.listeners[e] || []).forEach((r) => r(...t));
167
- }
168
- off(e, t) {
169
- this.listeners[e] = (this.listeners[e] || []).filter((r) => r === t);
170
- }
171
- on(e, t) {
172
- var r;
173
- return this.listeners[e] || (this.listeners[e] = []), (r = this.listeners[e]) == null || r.push(t), () => this.off(e, t);
174
- }
175
- once(e, t) {
176
- return new Promise((r) => {
177
- const o = this.on(e, (...s) => {
178
- r(s.length == 1 ? s[0] : s), t && t(...s), o();
179
- });
180
- });
181
- }
182
- }
183
- l(T, "listeners", {});
184
- function J(n, e) {
185
- const t = document.createElement("a");
186
- t.href = n, t.download = e, document.body.appendChild(t), t.click(), document.body.removeChild(t);
187
- }
188
- function ft(n, e) {
189
- const t = new T();
190
- return fetch(n).then((r) => {
191
- var w;
192
- if (!r.ok)
193
- return t.emit("failed", new Error(r.statusText));
194
- const o = r.headers.get("Content-Length") || "0", s = parseInt(o, 10);
195
- let i = [], d = 0;
196
- const g = (w = r.body) == null ? void 0 : w.getReader();
197
- g == null || g.read().then(function x(k) {
198
- if (k.done) {
199
- const m = new Blob(i);
200
- if (e) {
201
- const D = URL.createObjectURL(m);
202
- J(D, e), URL.revokeObjectURL(D);
203
- }
204
- t.emit("complete", m);
205
- } else {
206
- const m = k.value;
207
- i.push(m), d += m.length, t.emit("progress", d / s), g.read().then(x);
208
- }
209
- });
210
- }).catch((r) => t.emit("failed", r)), t;
211
- }
212
- const p = class p {
213
- constructor(e = {}) {
214
- l(this, "interceptors", {});
215
- l(this, "headers", {});
216
- this.opts = e, this.headers = e.headers || {}, e.interceptors && e.interceptors.forEach((t) => p.addInterceptor(t));
217
- }
218
- static addInterceptor(e) {
219
- const t = Object.keys(p.interceptors).length.toString();
220
- return p.interceptors[t] = e, () => {
221
- p.interceptors[t] = null;
222
- };
223
- }
224
- addInterceptor(e) {
225
- const t = Object.keys(this.interceptors).length.toString();
226
- return this.interceptors[t] = e, () => {
227
- this.interceptors[t] = null;
228
- };
229
- }
230
- async request(e = {}) {
231
- var o, s;
232
- if (!this.opts.url && !e.url)
233
- throw new Error("URL needs to be set");
234
- const t = ((o = e.url) != null && o.startsWith("http") ? e.url : (this.opts.url || "") + (e.url || "")).replace(/([^:]\/)\/+/g, "$1"), r = q({
235
- "Content-Type": e.body && !(e.body instanceof FormData) ? "application/json" : void 0,
236
- ...p.headers,
237
- ...this.headers,
238
- ...e.headers
239
- });
240
- return fetch(t, {
241
- headers: r,
242
- method: e.method || (e.body ? "POST" : "GET"),
243
- body: (s = r["Content-Type"]) != null && s.startsWith("application/json") && e.body ? JSON.stringify(e.body) : e.body
244
- }).then(async (i) => {
245
- var d, g;
246
- for (let w of [...Object.values(p.interceptors), ...Object.values(this.interceptors)])
247
- await new Promise((x) => w(i, () => x()));
248
- if (!i.ok)
249
- throw new Error(i.statusText);
250
- return !e.skipConverting && ((d = i.headers.get("Content-Type")) != null && d.startsWith("application/json")) ? await i.json() : !e.skipConverting && ((g = i.headers.get("Content-Type")) != null && g.startsWith("text/plain")) ? await i.text() : i;
251
- });
252
- }
253
- };
254
- l(p, "interceptors", {}), l(p, "headers", {});
255
- let S = p;
256
- S.addInterceptor((n, e) => {
257
- if (n.status == 200)
258
- return e();
259
- throw n.status == 400 ? new j(n.statusText) : n.status == 401 ? new U(n.statusText) : n.status == 403 ? new M(n.statusText) : n.status == 404 ? new P(n.statusText) : n.status == 500 ? new Y(n.statusText) : new E(n.statusText, n.status);
260
- });
261
- class E extends Error {
262
- constructor(t, r) {
263
- super(t);
264
- l(this, "_code");
265
- r != null && (this._code = r);
266
- }
267
- get code() {
268
- return this._code || this.constructor.code;
269
- }
270
- set code(t) {
271
- this._code = t;
272
- }
273
- static from(t) {
274
- const r = Number(t.statusCode) ?? Number(t.code), o = new this(t.message || t.toString());
275
- return Object.assign(o, {
276
- stack: t.stack,
277
- ...t,
278
- code: r ?? void 0
279
- });
280
- }
281
- static instanceof(t) {
282
- return t.constructor.code != null;
283
- }
284
- toString() {
285
- return this.message || super.toString();
286
- }
287
- }
288
- l(E, "code", 500);
289
- class j extends E {
290
- constructor(e = "Bad Request") {
291
- super(e);
292
- }
293
- static instanceof(e) {
294
- return e.constructor.code == this.code;
295
- }
296
- }
297
- l(j, "code", 400);
298
- class U extends E {
299
- constructor(e = "Unauthorized") {
300
- super(e);
301
- }
302
- static instanceof(e) {
303
- return e.constructor.code == this.code;
304
- }
305
- }
306
- l(U, "code", 401);
307
- class M extends E {
308
- constructor(e = "Forbidden") {
309
- super(e);
310
- }
311
- static instanceof(e) {
312
- return e.constructor.code == this.code;
313
- }
314
- }
315
- l(M, "code", 403);
316
- class P extends E {
317
- constructor(e = "Not Found") {
318
- super(e);
319
- }
320
- static instanceof(e) {
321
- return e.constructor.code == this.code;
322
- }
323
- }
324
- l(P, "code", 404);
325
- class Y extends E {
326
- constructor(e = "Internal Server Error") {
327
- super(e);
328
- }
329
- static instanceof(e) {
330
- return e.constructor.code == this.code;
331
- }
332
- }
333
- l(Y, "code", 500);
334
- const B = {
335
- CLEAR: "\x1B[0m",
336
- BRIGHT: "\x1B[1m",
337
- DIM: "\x1B[2m",
338
- UNDERSCORE: "\x1B[4m",
339
- BLINK: "\x1B[5m",
340
- REVERSE: "\x1B[7m",
341
- HIDDEN: "\x1B[8m"
342
- }, O = {
343
- BLACK: "\x1B[30m",
344
- RED: "\x1B[31m",
345
- GREEN: "\x1B[32m",
346
- YELLOW: "\x1B[33m",
347
- BLUE: "\x1B[34m",
348
- MAGENTA: "\x1B[35m",
349
- CYAN: "\x1B[36m",
350
- LIGHT_GREY: "\x1B[37m",
351
- GREY: "\x1B[90m",
352
- LIGHT_RED: "\x1B[91m",
353
- LIGHT_GREEN: "\x1B[92m",
354
- LIGHT_YELLOW: "\x1B[93m",
355
- LIGHT_BLUE: "\x1B[94m",
356
- LIGHT_MAGENTA: "\x1B[95m",
357
- LIGHT_CYAN: "\x1B[96m",
358
- WHITE: "\x1B[97m"
359
- }, dt = {
360
- BLACK: "\x1B[40m",
361
- RED: "\x1B[41m",
362
- GREEN: "\x1B[42m",
363
- YELLOW: "\x1B[43m",
364
- BLUE: "\x1B[44m",
365
- MAGENTA: "\x1B[45m",
366
- CYAN: "\x1B[46m",
367
- WHITE: "\x1B[47m",
368
- GREY: "\x1B[100m"
369
- };
370
- var K = /* @__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))(K || {});
371
- const f = class f extends T {
372
- constructor(e) {
373
- super(), this.namespace = e;
374
- }
375
- pad(e, t, r, o = !1) {
376
- const s = e.toString(), i = t - s.length;
377
- if (i <= 0)
378
- return s;
379
- const d = Array(~~(i / r.length)).fill(r).join("");
380
- return o ? s + d : d + s;
381
- }
382
- format(...e) {
383
- const t = /* @__PURE__ */ new Date();
384
- return `${`${t.getFullYear()}-${t.getMonth() + 1}-${t.getDate()} ${this.pad(t.getHours().toString(), 2, "0")}:${this.pad(t.getMinutes().toString(), 2, "0")}:${this.pad(t.getSeconds().toString(), 2, "0")}.${this.pad(t.getMilliseconds().toString(), 3, "0", !0)}`}${this.namespace ? ` [${this.namespace}]` : ""} ${e.join(" ")}`;
385
- }
386
- debug(...e) {
387
- if (f.LOG_LEVEL < 4)
388
- return;
389
- const t = this.format(...e);
390
- f.emit(4, t), console.debug(O.LIGHT_GREY + t + B.CLEAR);
391
- }
392
- log(...e) {
393
- if (f.LOG_LEVEL < 3)
394
- return;
395
- const t = this.format(...e);
396
- f.emit(3, t), console.log(B.CLEAR + t);
397
- }
398
- info(...e) {
399
- if (f.LOG_LEVEL < 2)
400
- return;
401
- const t = this.format(...e);
402
- f.emit(2, t), console.info(O.BLUE + t + B.CLEAR);
403
- }
404
- warn(...e) {
405
- if (f.LOG_LEVEL < 1)
406
- return;
407
- const t = this.format(...e);
408
- f.emit(1, t), console.warn(O.YELLOW + t + B.CLEAR);
409
- }
410
- error(...e) {
411
- if (f.LOG_LEVEL < 0)
412
- return;
413
- const t = this.format(...e);
414
- f.emit(0, t), console.error(O.RED + t + B.CLEAR);
415
- }
416
- };
417
- l(f, "LOG_LEVEL", 4);
418
- let G = f;
419
- function gt(n, e) {
420
- return n.length - n.replaceAll(e, "").length;
421
- }
422
- function pt(n) {
423
- return Array(n).fill(null).map(() => Math.round(Math.random() * 15).toString(16)).join("");
424
- }
425
- const b = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", I = "0123456789", N = "~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/", V = b + I + N;
426
- function yt(n) {
427
- const e = /(\+?1)?.*?(\d{3}).*?(\d{3}).*?(\d{4})/g.exec(n);
428
- if (!e)
429
- throw new Error(`Number cannot be parsed: ${n}`);
430
- return `${e[1] ?? ""} (${e[2]}) ${e[3]}-${e[4]}`.trim();
431
- }
432
- function Et(n, e, t) {
433
- return `${n.slice(0, t)}${e}${n.slice(t + 1)}`;
434
- }
435
- function wt(n, e, t, r = !0) {
436
- const o = n.toString(), s = e - o.length;
437
- if (s <= 0)
438
- return o;
439
- const i = Array(~~(s / t.length)).fill(t).join("");
440
- return r ? i + o : o + i;
441
- }
442
- function xt(n, e = V) {
443
- return Array(n).fill(null).map(() => {
444
- const t = ~~(Math.random() * e.length);
445
- return e[t];
446
- }).join("");
447
- }
448
- function mt(n, e = !1, t = !1, r = !1) {
449
- if (!e && !t && !r)
450
- throw new Error("Must enable at least one: letters, numbers, symbols");
451
- return Array(n).fill(null).map(() => {
452
- let o;
453
- do {
454
- const s = ~~(Math.random() * 3);
455
- e && s == 0 ? o = b[~~(Math.random() * b.length)] : t && s == 1 ? o = I[~~(Math.random() * I.length)] : r && s == 2 && (o = N[~~(Math.random() * N.length)]);
456
- } while (!o);
457
- return o;
458
- }).join("");
459
- }
460
- function Bt(n, e) {
461
- if (typeof e == "string" && (e = new RegExp(e, "g")), !e.global)
462
- throw new TypeError("Regular expression must be global.");
463
- let t = [], r;
464
- for (; (r = e.exec(n)) !== null; )
465
- t.push(r);
466
- return t;
467
- }
468
- function Z(n) {
469
- var e = Q(_(tt(X(n), 8 * n.length)));
470
- return e.toLowerCase();
471
- }
472
- function Q(n) {
473
- for (var e, t = "0123456789ABCDEF", r = "", o = 0; o < n.length; o++)
474
- e = n.charCodeAt(o), r += t.charAt(e >>> 4 & 15) + t.charAt(15 & e);
475
- return r;
476
- }
477
- function X(n) {
478
- for (var e = Array(n.length >> 2), t = 0; t < e.length; t++)
479
- e[t] = 0;
480
- for (t = 0; t < 8 * n.length; t += 8)
481
- e[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32;
482
- return e;
483
- }
484
- function _(n) {
485
- for (var e = "", t = 0; t < 32 * n.length; t += 8)
486
- e += String.fromCharCode(n[t >> 5] >>> t % 32 & 255);
487
- return e;
488
- }
489
- function tt(n, e) {
490
- n[e >> 5] |= 128 << e % 32, n[14 + (e + 64 >>> 9 << 4)] = e;
491
- for (var t = 1732584193, r = -271733879, o = -1732584194, s = 271733878, i = 0; i < n.length; i += 16) {
492
- var d = t, g = r, w = o, x = s;
493
- r = h(r = h(r = h(r = h(r = a(r = a(r = a(r = a(r = u(r = u(r = u(r = u(r = c(r = c(r = c(r = c(r, o = c(o, s = c(s, t = c(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 = c(o, s = c(s, t = c(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 = c(o, s = c(s, t = c(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 = c(o, s = c(s, t = c(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 = u(o, s = u(s, t = u(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 = u(o, s = u(s, t = u(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 = u(o, s = u(s, t = u(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 = u(o, s = u(s, t = u(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 = a(o, s = a(s, t = a(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 = a(o, s = a(s, t = a(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 = a(o, s = a(s, t = a(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 = a(o, s = a(s, t = a(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, d), r = y(r, g), o = y(o, w), s = y(s, x);
494
- }
495
- return Array(t, r, o, s);
496
- }
497
- function L(n, e, t, r, o, s) {
498
- return y(et(y(y(e, n), y(r, s)), o), t);
499
- }
500
- function c(n, e, t, r, o, s, i) {
501
- return L(e & t | ~e & r, n, e, o, s, i);
502
- }
503
- function u(n, e, t, r, o, s, i) {
504
- return L(e & r | t & ~r, n, e, o, s, i);
505
- }
506
- function a(n, e, t, r, o, s, i) {
507
- return L(e ^ t ^ r, n, e, o, s, i);
508
- }
509
- function h(n, e, t, r, o, s, i) {
510
- return L(t ^ (e | ~r), n, e, o, s, i);
511
- }
512
- function y(n, e) {
513
- var t = (65535 & n) + (65535 & e);
514
- return (n >> 16) + (e >> 16) + (t >> 16) << 16 | 65535 & t;
515
- }
516
- function et(n, e) {
517
- return n << e | n >>> 32 - e;
518
- }
519
- function At(n) {
520
- return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(n);
521
- }
522
- function Rt(n) {
523
- return Object.entries(n).map(
524
- ([e, t]) => encodeURIComponent(e) + "=" + encodeURIComponent(t)
525
- ).join("&");
526
- }
527
- function Ot(n, e = "mp") {
528
- return n ? `https://www.gravatar.com/avatar/${Z(n)}?d=${e}` : "";
529
- }
530
- function Ct(n) {
531
- const e = new RegExp(
532
- "(?:(?<protocol>[\\w\\d]+)\\:\\/\\/)?(?:(?<user>.+)\\@)?(?<host>(?<domain>[^:\\/\\?#@\\n]+)(?:\\:(?<port>\\d*))?)(?<path>\\/.*?)?(?:\\?(?<query>.*?))?(?:#(?<fragment>.*?))?$",
533
- "gm"
534
- ).exec(n), t = (e == null ? void 0 : e.groups) ?? {}, r = t.domain.split(".");
535
- 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) {
536
- const o = t.query.split("&"), s = {};
537
- o.forEach((i) => {
538
- const [d, g] = i.split("=");
539
- s[d] = g;
540
- }), t.query = s;
541
- }
542
- return t;
543
- }
544
- function Tt(n) {
545
- return (n instanceof Date ? n.getTime() : n) - (/* @__PURE__ */ new Date()).getTime();
546
- }
547
- function Lt(n) {
548
- return new Promise((e) => setTimeout(e, n));
549
- }
550
- function St(n) {
551
- const e = n instanceof Date ? n : new Date(n);
552
- return new Intl.DateTimeFormat("en-us", {
553
- weekday: "long",
554
- month: "short",
555
- day: "numeric",
556
- hour: "numeric",
557
- minute: "numeric",
558
- hour12: !0
559
- }).format(e);
560
- }
561
- function bt(n, e) {
562
- const t = new XMLHttpRequest(), r = new T(), o = new FormData();
563
- return (Array.isArray(n) ? n : [n]).forEach((s) => o.append("file", s)), t.upload.addEventListener("progress", (s) => {
564
- s.lengthComputable && r.emit("progress", s.loaded / s.total);
565
- }), t.onreadystatechange = () => {
566
- t.readyState === 4 && (t.status >= 200 && t.status < 300 ? r.emit("complete") : r.emit("failed", new Error(t.responseText)));
567
- }, t.open("POST", e, !0), t.send(o), r;
568
- }
569
- export {
570
- A as ASet,
571
- j as BadRequestError,
572
- dt as CliBackground,
573
- B as CliEffects,
574
- O as CliForeground,
575
- E as CustomError,
576
- M as ForbiddenError,
577
- Y as InternalServerError,
578
- K as LOG_LEVEL,
579
- G as Logger,
580
- P as NotFoundError,
581
- T as TypedEmitter,
582
- U as UnauthorizedError,
583
- S as XHR,
584
- it as addUnique,
585
- ct as arrayDiff,
586
- ut as caseInsensitiveSort,
587
- q as clean,
588
- gt as countChars,
589
- pt as createHex,
590
- rt as deepCopy,
591
- C as dotNotation,
592
- J as download,
593
- ft as downloadProgress,
594
- ht as findByProp,
595
- v as flattenArr,
596
- F as flattenObj,
597
- Rt as formEncode,
598
- St as formatDate,
599
- yt as formatPhoneNumber,
600
- Ot as gravatar,
601
- $ as includes,
602
- Et as insertAt,
603
- R as isEqual,
604
- lt as makeArray,
605
- z as makeUnique,
606
- Bt as matchAll,
607
- Z as md5,
608
- ot as mixin,
609
- wt as pad,
610
- xt as randomString,
611
- mt as randomStringBuilder,
612
- st as sanitizedJSON,
613
- Lt as sleep,
614
- at as sortByProp,
615
- Tt as timeUntil,
616
- bt as uploadProgress,
617
- Ct as urlParser,
618
- At as validateEmail
619
- };
620
- //# sourceMappingURL=utils.mjs.map