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