esexts 1.3.4 → 1.4.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/esexts.js CHANGED
@@ -1,942 +1,748 @@
1
- const l = Object.defineProperties, s = { enumerable: !1, configurable: !0, writable: !0 };
2
- function p() {
1
+ const u = (t, e) => Object.defineProperties(t, Object.fromEntries(Object.keys(e).map((n) => [n, { value: e[n], enumerable: !1, configurable: !0, writable: !0 }])));
2
+ function d() {
3
3
  return {
4
- new: {
5
- value: function(...t) {
6
- return new this(...t);
7
- },
8
- ...s
4
+ new: function(...t) {
5
+ return new this(...t);
9
6
  }
10
7
  };
11
8
  }
12
- function v(...t) {
9
+ function p(...t) {
13
10
  const e = {};
14
11
  for (const n of t) {
15
12
  const [r, i] = Array.isArray(n) ? n : [n, n];
16
- e[i] = {
17
- value: function(...u) {
18
- return this[r](...u), this;
19
- },
20
- ...s
13
+ e[i] = function(...s) {
14
+ return this[r](...s), this;
21
15
  };
22
16
  }
23
17
  return e;
24
18
  }
25
- function x(...t) {
19
+ function F(...t) {
26
20
  const e = {};
27
21
  for (const n of t) {
28
22
  const [r, i] = Array.isArray(n) ? n : [n, n];
29
- e[i] = {
30
- value: function(...u) {
31
- return this[r](...u), u[0];
32
- },
33
- ...s
23
+ e[i] = function(...s) {
24
+ return this[r](...s), s[0];
34
25
  };
35
26
  }
36
27
  return e;
37
28
  }
38
- function m(...t) {
29
+ function b(...t) {
39
30
  const e = {};
40
31
  for (const n of t) {
41
32
  const [r, i] = Array.isArray(n) ? n : [n, n];
42
- e[i] = {
43
- value: function(...u) {
44
- return this[r](...u), u;
45
- },
46
- ...s
33
+ e[i] = function(...s) {
34
+ return this[r](...s), s;
47
35
  };
48
36
  }
49
37
  return e;
50
38
  }
51
- function d(...t) {
39
+ function m(...t) {
52
40
  const e = {};
53
41
  for (const n of t) {
54
42
  const [r, i] = Array.isArray(n) ? n : [n, n];
55
- e[i] = {
56
- value: function() {
57
- return this[r];
58
- },
59
- ...s
43
+ e[i] = function() {
44
+ return this[r];
60
45
  };
61
46
  }
62
47
  return e;
63
48
  }
64
- function b(...t) {
49
+ function A(...t) {
65
50
  const e = {};
66
51
  for (const n of t) {
67
52
  const [r, i] = Array.isArray(n) ? n : [n, n];
68
- e[i] = {
69
- value: function(...u) {
70
- return [...this[r](...u)];
71
- },
72
- ...s
53
+ e[i] = function(...s) {
54
+ return [...this[r](...s)];
73
55
  };
74
56
  }
75
57
  return e;
76
58
  }
77
- function O(t, ...e) {
59
+ function I(t, ...e) {
78
60
  const n = {};
79
61
  for (const r of e) {
80
- const [i, u] = Array.isArray(r) ? r : [r, r];
81
- n[u] = {
82
- value: t[i],
83
- ...s
84
- };
62
+ const [i, s] = Array.isArray(r) ? r : [r, r];
63
+ n[s] = t[i];
85
64
  }
86
65
  return n;
87
66
  }
88
- function A(t, ...e) {
67
+ function x(t, ...e) {
89
68
  const n = {};
90
69
  for (const r of e) {
91
- const [i, u] = Array.isArray(r) ? r : [r, r];
92
- n[u] = {
93
- value: function(...o) {
94
- return t[i](this, ...o);
95
- },
96
- ...s
70
+ const [i, s] = Array.isArray(r) ? r : [r, r];
71
+ n[s] = function(...o) {
72
+ return t[i](this, ...o);
97
73
  };
98
74
  }
99
75
  return n;
100
76
  }
101
- function M(t, ...e) {
77
+ function j(t, ...e) {
102
78
  const n = {};
103
79
  for (const r of e) {
104
- const [i, u] = Array.isArray(r) ? r : [r, r];
105
- n[u] = {
106
- value: function(...o) {
107
- return t[i](this, ...o), this;
108
- },
109
- ...s
80
+ const [i, s] = Array.isArray(r) ? r : [r, r];
81
+ n[s] = function(...o) {
82
+ return t[i](this, ...o), this;
110
83
  };
111
84
  }
112
85
  return n;
113
86
  }
114
- function w(t = { array: !1 }) {
87
+ function M(t = { array: !1 }) {
115
88
  return function(e = {}, ...n) {
116
- const r = (i, u) => {
117
- const o = Object.prototype.toString.call(i), f = Object.prototype.toString.call(u);
118
- if (o !== f)
119
- return u;
89
+ const r = (i, s) => {
90
+ const o = Object.prototype.toString.call(i), l = Object.prototype.toString.call(s);
91
+ if (o !== l)
92
+ return s;
120
93
  if (o === "[object Array]")
121
- return t.array ? i.concat(...u) : u;
94
+ return t.array ? i.concat(...s) : s;
122
95
  if (o === "[object Object]") {
123
- for (const c in u)
124
- i[c] = r(i[c], u[c]);
96
+ for (const f in s)
97
+ i[f] = r(i[f], s[f]);
125
98
  return i;
126
99
  } else
127
- return u;
100
+ return s;
128
101
  };
129
102
  for (const i of n)
130
103
  e = r(e, i);
131
104
  return e;
132
105
  };
133
106
  }
134
- const D = w({ array: !1 }), F = w({ array: !0 });
135
- l(Object, {
136
- isObject: {
137
- value: function(t) {
138
- return Object.prototype.toString.call(t) === "[object Object]";
139
- },
140
- ...s
141
- },
142
- merge0: {
143
- value: function(...t) {
144
- return D(this, ...t);
145
- },
146
- ...s
147
- },
148
- concat0: {
149
- value: function(...t) {
150
- return F(this, ...t);
151
- },
152
- ...s
107
+ const D = M({ array: !1 }), O = M({ array: !0 });
108
+ u(Object, {
109
+ isObject: function(t) {
110
+ return Object.prototype.toString.call(t) === "[object Object]";
111
+ },
112
+ merge0: function(...t) {
113
+ return D(this, ...t);
114
+ },
115
+ concat0: function(...t) {
116
+ return O(this, ...t);
153
117
  }
154
118
  });
155
- l(Object.prototype, {
156
- clone0: {
157
- value: function() {
158
- return JSON.parse(JSON.stringify(this));
159
- },
160
- ...s
161
- },
162
- length0: {
163
- value: function() {
164
- return Object.keys(this).length;
165
- },
166
- ...s
167
- },
168
- ...A(Object, ["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
169
- merge0: {
170
- value: function(...t) {
171
- return D(this, ...t);
172
- },
173
- ...s
174
- },
175
- concat0: {
176
- value: function(...t) {
177
- return F(this, ...t);
178
- },
179
- ...s
180
- },
181
- map0: {
182
- value: function(t = (n, r, i) => [n, r], e = 0) {
183
- return Object.entries(this).map(([n, r]) => t(n, r, e++));
184
- },
185
- ...s
186
- },
187
- pick0: {
188
- value: function(...t) {
189
- const e = {};
190
- for (const n of t)
191
- e[n] = this[n];
192
- return e;
193
- },
194
- ...s
195
- },
196
- omit0: {
197
- value: function(...t) {
198
- const e = {}, n = new Set(t);
199
- for (const r in this)
200
- n.has(r) || (e[r] = this[r]);
201
- return e;
202
- },
203
- ...s
204
- },
205
- attr0: {
206
- value: function(t, ...e) {
207
- return typeof this != "object" ? this : typeof t == "function" ? t(this, ...e) : this[t];
208
- },
209
- ...s
210
- },
211
- toArray0: {
212
- value: function() {
213
- return Array.isArray(this) ? this : [this];
214
- },
215
- ...s
216
- },
217
- ...M(console, ["debug", "debug0"], ["log", "log0"], ["info", "info0"], ["warn", "warn0"], ["error", "error0"], ["dir", "dir0"]),
119
+ u(Object.prototype, {
120
+ clone0: function() {
121
+ return JSON.parse(JSON.stringify(this));
122
+ },
123
+ length0: function() {
124
+ return Object.keys(this).length;
125
+ },
126
+ ...x(Object, ["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
127
+ merge0: function(...t) {
128
+ return D(this, ...t);
129
+ },
130
+ concat0: function(...t) {
131
+ return O(this, ...t);
132
+ },
133
+ map0: function(t = (n, r, i) => [n, r], e = 0) {
134
+ return Object.entries(this).map(([n, r]) => t(n, r, e++));
135
+ },
136
+ pick0: function(...t) {
137
+ const e = {};
138
+ for (const n of t)
139
+ e[n] = this[n];
140
+ return e;
141
+ },
142
+ omit0: function(...t) {
143
+ const e = {}, n = new Set(t);
144
+ for (const r in this)
145
+ n.has(r) || (e[r] = this[r]);
146
+ return e;
147
+ },
148
+ attr0: function(t, ...e) {
149
+ return typeof this != "object" ? this : typeof t == "function" ? t(this, ...e) : this[t];
150
+ },
151
+ toArray0: function() {
152
+ return Array.isArray(this) ? this : [this];
153
+ },
154
+ ...j(console, ["debug", "debug0"], ["log", "log0"], ["info", "info0"], ["warn", "warn0"], ["error", "error0"], ["dir", "dir0"]),
218
155
  // ====== Tree ======
219
- getParents0: {
220
- value: function(t = !1, e = -1, n = "parent") {
221
- const r = t ? [this] : [];
222
- let i = this[n];
223
- for (; i && e-- != 0; )
224
- r.push(i), i = i[n];
225
- return r;
226
- },
227
- ...s
228
- },
229
- getChildrens0: {
230
- value: function(t = !1, e = -1, n = "children") {
231
- const r = [], i = (u, o, f) => {
232
- if (o && r.push(u), !(f == 0 || !u[n] || u[n].length == 0))
233
- for (const c of u[n])
234
- i(c, !0, f - 1);
235
- };
236
- return i(this, t, e), r;
237
- },
238
- ...s
239
- },
240
- treeFind0: {
241
- value: function(t, e = !0, n = -1, r = "children") {
242
- if (e && t(this))
243
- return this;
244
- if (n == 0 || !this[r] || this[r].length == 0)
245
- return null;
246
- for (const i of this[r]) {
247
- const u = i.treeFind0(t, !0, n - 1, r);
248
- if (u !== null)
249
- return u;
250
- }
156
+ getParents0: function(t = !1, e = -1, n = "parent") {
157
+ const r = t ? [this] : [];
158
+ let i = this[n];
159
+ for (; i && e-- != 0; )
160
+ r.push(i), i = i[n];
161
+ return r;
162
+ },
163
+ getChildrens0: function(t = !1, e = -1, n = "children") {
164
+ const r = [], i = (s, o, l) => {
165
+ if (o && r.push(s), !(l == 0 || !s[n] || s[n].length == 0))
166
+ for (const f of s[n])
167
+ i(f, !0, l - 1);
168
+ };
169
+ return i(this, t, e), r;
170
+ },
171
+ treeFind0: function(t, e = !0, n = -1, r = "children") {
172
+ if (e && t(this))
173
+ return this;
174
+ if (n == 0 || !this[r] || this[r].length == 0)
251
175
  return null;
252
- },
253
- ...s
254
- },
255
- treeEach0: {
256
- value: function(t, e = !0, n = -1, r = "children") {
257
- if (e && t(this), !(n == 0 || !this[r] || this[r].length == 0)) {
258
- for (const i of this[r])
259
- i.treeEach0(t, !0, n - 1, r);
260
- return this;
261
- }
262
- },
263
- ...s
264
- },
265
- treeMap0: {
266
- value: function(t, e = !0, n = -1, r = "children", i = null) {
267
- const u = e ? t(this) : this, o = [];
268
- if (n == 0 || !this[r] || this[r].length == 0)
269
- return u;
270
- for (const f of this[r])
271
- o.push(f.treeMap0(t, !0, n - 1, r, i));
272
- return u[r] = o, u;
273
- },
274
- ...s
176
+ for (const i of this[r]) {
177
+ const s = i.treeFind0(t, !0, n - 1, r);
178
+ if (s !== null)
179
+ return s;
180
+ }
181
+ return null;
182
+ },
183
+ treeEach0: function(t, e = !0, n = -1, r = "children") {
184
+ if (e && t(this), !(n == 0 || !this[r] || this[r].length == 0)) {
185
+ for (const i of this[r])
186
+ i.treeEach0(t, !0, n - 1, r);
187
+ return this;
188
+ }
189
+ },
190
+ treeMap0: function(t, e = !0, n = -1, r = "children", i = null) {
191
+ const s = e ? t(this) : this, o = [];
192
+ if (n == 0 || !this[r] || this[r].length == 0)
193
+ return s;
194
+ for (const l of this[r])
195
+ o.push(l.treeMap0(t, !0, n - 1, r, i));
196
+ return s[r] = o, s;
275
197
  }
276
198
  });
277
- l(Number.prototype, {
278
- ...A(Math, "ceil", "floor", "trunc", "abs", "max", "min"),
279
- baseConvert: {
280
- value: function(t = 64) {
281
- let e = "", n = this, r = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";
282
- for (; n > 0; )
283
- e = r.at(n % t) + e, n = Math.floor(n / t);
284
- return e || "0";
285
- },
286
- ...s
287
- },
288
- round: {
289
- value: function(t = 0) {
290
- return t == 0 ? Math.round(this) : Math.round(this * 10 ** t) / 10 ** t;
291
- },
292
- ...s
293
- },
294
- toFixed0: {
295
- value: function(...t) {
296
- return +this.toFixed(...t);
297
- },
298
- ...s
299
- },
300
- toDate: {
301
- value: function() {
302
- return Date.new(this);
303
- },
304
- ...s
199
+ u(Number.prototype, {
200
+ ...x(Math, "ceil", "floor", "trunc", "abs", "max", "min"),
201
+ baseConvert: function(t = 64) {
202
+ let e = "", n = this, r = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";
203
+ for (; n > 0; )
204
+ e = r.at(n % t) + e, n = Math.floor(n / t);
205
+ return e || "0";
206
+ },
207
+ round: function(t = 0) {
208
+ return t == 0 ? Math.round(this) : Math.round(this * 10 ** t) / 10 ** t;
209
+ },
210
+ toFixed0: function(...t) {
211
+ return +this.toFixed(...t);
212
+ },
213
+ toDate: function() {
214
+ return Date.new(this);
305
215
  }
306
216
  });
307
- l(BigInt.prototype, {
308
- toJSON: {
309
- value: function() {
310
- return this < BigInt(Number.MIN_SAFE_INTEGER) || this > BigInt(Number.MAX_SAFE_INTEGER) ? this.toString() : Number(this);
311
- },
312
- ...s
217
+ u(BigInt.prototype, {
218
+ toJSON: function() {
219
+ return this < BigInt(Number.MIN_SAFE_INTEGER) || this > BigInt(Number.MAX_SAFE_INTEGER) ? this.toString() : Number(this);
313
220
  }
314
221
  });
315
- l(String.prototype, {
316
- ...d(["length", "length0"]),
317
- substring0: {
318
- value: function(t = 0, e = this.length) {
319
- return t = t >= 0 ? t : this.length + t, e = e >= 0 ? e : this.length + e, this.substring(t, e);
320
- },
321
- ...s
322
- },
323
- substr0: {
324
- value: function(t = 0, e = this.length) {
325
- return t = t >= 0 ? t : this.length + t, e = t + e, this.substring(t, e);
326
- },
327
- ...s
328
- },
329
- split0: {
330
- value: function(t = ",", e = -1) {
331
- const n = this ? this.split(t) : [];
332
- return e === -1 ? n : n.push0(n.splice(e - 1).join(t));
333
- },
334
- ...s
335
- },
336
- splitNumber: {
337
- value: function(t = ",") {
338
- return this.split0(t).map((e) => +e);
339
- },
340
- ...s
341
- },
342
- splitSegment: {
343
- value: function(t = 1) {
344
- const e = [];
345
- for (let n = 0; n < this.length; n += t)
346
- e.push(this.substring(n, n + t));
347
- return e;
348
- },
349
- ...s
350
- },
351
- sprintf: {
352
- value: function(...t) {
353
- let [e, ...n] = this.split(/%[sd]/);
354
- for (let r = 0; r < n.length; r++)
355
- e += t[r] + n[r];
356
- return e;
357
- },
358
- ...s
359
- },
360
- subOf: {
361
- value: function(t, e, n = 0, r = 0) {
362
- for (let o = 0; o < n && r != -1; o++, r++)
363
- r = this.indexOf(t, r);
364
- let i = this.indexOf(t, r), u = this.indexOf(e, i);
365
- return i == -1 || u == -1 ? "" : (i += t.length, this.substring(i, u));
366
- },
367
- ...s
368
- },
369
- lastSubOf: {
370
- value: function(t, e, n = 0, r = 1 / 0) {
371
- for (let o = 0; o < n && r != -1; o++, r--)
372
- r = this.lastIndexOf(t, r);
373
- let i = this.lastIndexOf(t, r), u = this.indexOf(e, i);
374
- return i == -1 || u == -1 ? "" : (i += t.length, this.substring(i, u));
375
- },
376
- ...s
377
- },
378
- camel2under: {
379
- value: function() {
380
- return this.substr(0, 1) + this.substr(1).replace(/([A-Z])/g, (t, e) => "_" + e.toLowerCase());
381
- },
382
- ...s
383
- },
384
- under2camel: {
385
- value: function() {
386
- return this.replace(/_([a-z])/g, (t, e) => e.toUpperCase());
387
- },
388
- ...s
389
- },
390
- camel2pascal: {
391
- value: function() {
392
- return this.substr(0, 1).toUpperCase() + this.substr(1);
393
- },
394
- ...s
395
- },
396
- pascal2camel: {
397
- value: function() {
398
- return this.substr(0, 1).toLowerCase() + this.substr(1);
399
- },
400
- ...s
401
- },
402
- under2kebab: {
403
- value: function() {
404
- return this.replace(/_/g, "-");
405
- },
406
- ...s
407
- },
408
- kebab2under: {
409
- value: function() {
410
- return this.replace(/-/g, "_");
411
- },
412
- ...s
413
- },
414
- baseConvert: {
415
- value: function(t = 64) {
416
- let e = 0, n = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";
417
- for (let r = 0; r < this.length; r++)
418
- e = e * t + n.indexOf(this.at(r));
419
- return e;
420
- },
421
- ...s
422
- },
423
- toFixed0: {
424
- value: function(...t) {
425
- return +(+this).toFixed(...t);
426
- },
427
- ...s
428
- },
429
- toDate: {
430
- value: function() {
431
- return Date.new(this);
432
- },
433
- ...s
434
- },
435
- hex2bytes: {
436
- value: function() {
437
- const t = [];
438
- for (let e = 0; e < this.length; e += 2)
439
- t.push(Number.parseInt(this.substring(e, e + 2), 16));
440
- return t;
441
- },
442
- ...s
443
- },
444
- string2bytes: {
445
- value: function() {
446
- if (typeof TextEncoder < "u")
447
- return Array.from(new TextEncoder().encode(this));
448
- const t = [], e = encodeURIComponent(this);
449
- for (let n = 0; n < e.length; )
450
- t.push(e.charAt(n) == "%" ? Number.parseInt(e.substring(n + 1, n += 3), 16) : e.charCodeAt(n++));
451
- return t;
452
- },
453
- ...s
454
- },
455
- base64decode: {
456
- value: function(t) {
457
- const e = [], n = {}, r = t === !0 ? "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
458
- for (let u = 0; u < r.length; u++)
459
- n[r.charAt(u)] = u;
460
- const i = this.charAt(this.length - 1) != "=" ? this.length : this.charAt(this.length - 2) != "=" ? this.length - 1 : this.length - 2;
461
- for (let u = 3; u < i; u += 4) {
462
- const o = (n[this.charAt(u - 3)] << 18) + (n[this.charAt(u - 2)] << 12) + (n[this.charAt(u - 1)] << 6) + n[this.charAt(u)];
463
- e.push((o & 16711680) >> 16, (o & 65280) >> 8, o & 255);
464
- }
465
- if (i % 4 == 3) {
466
- const u = (n[this.charAt(i - 3)] << 18) + (n[this.charAt(i - 2)] << 12) + (n[this.charAt(i - 1)] << 6);
467
- e.push((u & 16711680) >> 16, (u & 65280) >> 8);
468
- } else if (i % 4 == 2) {
469
- const u = (n[this.charAt(i - 2)] << 18) + (n[this.charAt(i - 1)] << 12);
470
- e.push((u & 16711680) >> 16);
471
- }
472
- return e;
473
- },
474
- ...s
222
+ u(String.prototype, {
223
+ ...m(["length", "length0"]),
224
+ substring0: function(t = 0, e = this.length) {
225
+ return t = t >= 0 ? t : this.length + t, e = e >= 0 ? e : this.length + e, this.substring(t, e);
226
+ },
227
+ substr0: function(t = 0, e = this.length) {
228
+ return t = t >= 0 ? t : this.length + t, e = t + e, this.substring(t, e);
229
+ },
230
+ split0: function(t = ",", e = -1) {
231
+ const n = this ? this.split(t) : [];
232
+ return e === -1 ? n : n.push0(n.splice(e - 1).join(t));
233
+ },
234
+ splitNumber: function(t = ",") {
235
+ return this.split0(t).map((e) => +e);
236
+ },
237
+ splitSegment: function(t = 1) {
238
+ const e = [];
239
+ for (let n = 0; n < this.length; n += t)
240
+ e.push(this.substring(n, n + t));
241
+ return e;
242
+ },
243
+ sprintf: function(...t) {
244
+ let [e, ...n] = this.split(/%[sd]/);
245
+ for (let r = 0; r < n.length; r++)
246
+ e += t[r] + n[r];
247
+ return e;
248
+ },
249
+ subOf: function(t, e, n = 0, r = 0) {
250
+ for (let o = 0; o < n && r != -1; o++, r++)
251
+ r = this.indexOf(t, r);
252
+ let i = this.indexOf(t, r), s = this.indexOf(e, i);
253
+ return i == -1 || s == -1 ? "" : (i += t.length, this.substring(i, s));
254
+ },
255
+ lastSubOf: function(t, e, n = 0, r = 1 / 0) {
256
+ for (let o = 0; o < n && r != -1; o++, r--)
257
+ r = this.lastIndexOf(t, r);
258
+ let i = this.lastIndexOf(t, r), s = this.indexOf(e, i);
259
+ return i == -1 || s == -1 ? "" : (i += t.length, this.substring(i, s));
260
+ },
261
+ camel2under: function() {
262
+ return this.substr(0, 1) + this.substr(1).replace(/([A-Z])/g, (t, e) => "_" + e.toLowerCase());
263
+ },
264
+ under2camel: function() {
265
+ return this.replace(/_([a-z])/g, (t, e) => e.toUpperCase());
266
+ },
267
+ camel2pascal: function() {
268
+ return this.substr(0, 1).toUpperCase() + this.substr(1);
269
+ },
270
+ pascal2camel: function() {
271
+ return this.substr(0, 1).toLowerCase() + this.substr(1);
272
+ },
273
+ under2kebab: function() {
274
+ return this.replace(/_/g, "-");
275
+ },
276
+ kebab2under: function() {
277
+ return this.replace(/-/g, "_");
278
+ },
279
+ baseConvert: function(t = 64) {
280
+ let e = 0, n = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";
281
+ for (let r = 0; r < this.length; r++)
282
+ e = e * t + n.indexOf(this.at(r));
283
+ return e;
284
+ },
285
+ toFixed0: function(...t) {
286
+ return +(+this).toFixed(...t);
287
+ },
288
+ toDate: function() {
289
+ return Date.new(this);
290
+ },
291
+ hex2bytes: function() {
292
+ const t = [];
293
+ for (let e = 0; e < this.length; e += 2)
294
+ t.push(Number.parseInt(this.substring(e, e + 2), 16));
295
+ return t;
296
+ },
297
+ string2bytes: function() {
298
+ if (typeof TextEncoder < "u")
299
+ return Array.from(new TextEncoder().encode(this));
300
+ const t = [], e = encodeURIComponent(this);
301
+ for (let n = 0; n < e.length; )
302
+ t.push(e.charAt(n) == "%" ? Number.parseInt(e.substring(n + 1, n += 3), 16) : e.charCodeAt(n++));
303
+ return t;
304
+ },
305
+ base64decode: function(t) {
306
+ const e = [], n = {}, r = t === !0 ? "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
307
+ for (let s = 0; s < r.length; s++)
308
+ n[r.charAt(s)] = s;
309
+ const i = this.charAt(this.length - 1) != "=" ? this.length : this.charAt(this.length - 2) != "=" ? this.length - 1 : this.length - 2;
310
+ for (let s = 3; s < i; s += 4) {
311
+ const o = (n[this.charAt(s - 3)] << 18) + (n[this.charAt(s - 2)] << 12) + (n[this.charAt(s - 1)] << 6) + n[this.charAt(s)];
312
+ e.push((o & 16711680) >> 16, (o & 65280) >> 8, o & 255);
313
+ }
314
+ if (i % 4 == 3) {
315
+ const s = (n[this.charAt(i - 3)] << 18) + (n[this.charAt(i - 2)] << 12) + (n[this.charAt(i - 1)] << 6);
316
+ e.push((s & 16711680) >> 16, (s & 65280) >> 8);
317
+ } else if (i % 4 == 2) {
318
+ const s = (n[this.charAt(i - 2)] << 18) + (n[this.charAt(i - 1)] << 12);
319
+ e.push((s & 16711680) >> 16);
320
+ }
321
+ return e;
475
322
  }
476
323
  });
477
- typeof Iterator < "u" && l(Iterator.prototype, {
478
- toArray: {
479
- value: function() {
480
- return Array.from(this);
481
- },
482
- ...s
324
+ typeof Iterator < "u" && u(Iterator.prototype, {
325
+ toArray: function() {
326
+ return Array.from(this);
483
327
  }
484
328
  });
485
- l(Array, {
486
- ...p()
329
+ u(Array, {
330
+ ...d()
487
331
  });
488
- l(Array.prototype, {
489
- ...d(["length", "length0"]),
490
- ...b(["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
491
- ...v(["push", "push0"], ["pop", "pop0"], ["shift", "shift0"], ["unshift", "unshift0"]),
492
- ...x(["push", "push1"], ["unshift", "unshift1"]),
493
- ...m(["push", "push3"], ["unshift", "unshift3"]),
494
- first0: {
495
- value: function(t = null) {
496
- return this.length ? this[0] : t;
497
- },
498
- ...s
499
- },
500
- last0: {
501
- value: function(t = null) {
502
- return this.length ? this[this.length - 1] : t;
503
- },
504
- ...s
505
- },
506
- find0: {
507
- value: function(t, e = null) {
508
- return this.find(t) ?? e;
509
- },
510
- ...s
511
- },
512
- equals0: {
513
- value: function(t) {
514
- return this.length === t.length && (this === t || this.length === 0 || this.every((e, n) => e === t[n]));
515
- },
516
- ...s
517
- },
518
- unique0: {
519
- value: function(t = (e) => e) {
520
- const e = /* @__PURE__ */ new Set();
521
- return this.filter((n) => e.has(t(n)) ? !1 : !!e.add(t(n)));
522
- },
523
- ...s
524
- },
525
- ...v(["forEach", "each0"]),
526
- toObject: {
527
- value: function(t = (e, n) => [n, e]) {
528
- return Object.fromEntries(this.map(t));
529
- },
530
- ...s
531
- },
532
- toMap: {
533
- value: function(t = (e, n) => [n, e]) {
534
- return new Map(this.map(t));
535
- },
536
- ...s
537
- },
538
- toSet: {
539
- value: function(t = (e) => e) {
540
- return new Set(this.map(t));
541
- },
542
- ...s
543
- },
544
- toGroup: {
545
- value: function(t = (e) => [e.id, e]) {
546
- const e = {};
547
- for (const n of this) {
548
- const [r, i] = t(n);
549
- r in e || (e[r] = []), e[r].push(i);
550
- }
551
- return e;
552
- },
553
- ...s
554
- },
555
- toMerge: {
556
- value: function(t = (r) => r.id, e = (r) => ({ ...r, children: [] }), n = (r, i) => r.children.push(i)) {
557
- const r = [];
558
- for (const i of this)
559
- n(r.find((u) => t(u) == t(i)) ?? r.push1(e(i)), i);
560
- return r;
561
- },
562
- ...s
563
- },
564
- bytes2hex: {
565
- value: function() {
566
- let t = "";
567
- for (let e = 0; e < this.length; e++)
568
- t += (this[e] < 16 ? "0" : "") + this[e].toString(16);
569
- return t;
570
- },
571
- ...s
572
- },
573
- bytes2string: {
574
- value: function() {
575
- if (typeof TextDecoder < "u")
576
- return new TextDecoder().decode(new Uint8Array(this));
577
- let t = "";
578
- for (let e = 0; e < this.length; e++)
579
- t += "%" + (this[e] < 16 ? "0" : "") + this[e].toString(16);
580
- return decodeURIComponent(t);
581
- },
582
- ...s
583
- },
584
- base64encode: {
585
- value: function(t = !1, e = !0) {
586
- let n = "", r = t === !0 ? "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
587
- for (let i = 2; i < this.length; i += 3) {
588
- const u = (this[i - 2] << 16) + (this[i - 1] << 8) + this[i];
589
- n += r.charAt((u & 16515072) >> 18) + r.charAt((u & 258048) >> 12) + r.charAt((u & 4032) >> 6) + r.charAt(u & 63);
590
- }
591
- if (this.length % 3 == 2) {
592
- const i = (this[this.length - 2] << 16) + (this[this.length - 1] << 8);
593
- n += r.charAt((i & 16515072) >> 18) + r.charAt((i & 258048) >> 12) + r.charAt((i & 4032) >> 6) + (e === !1 ? "" : "=");
594
- } else if (this.length % 3 == 1) {
595
- const i = this[this.length - 1] << 16;
596
- n += r.charAt((i & 16515072) >> 18) + r.charAt((i & 258048) >> 12) + (e === !1 ? "" : "==");
597
- }
598
- return n;
599
- },
600
- ...s
601
- },
602
- toUint8Array: {
603
- value: function() {
604
- return new Uint8Array(this);
605
- },
606
- ...s
332
+ u(Array.prototype, {
333
+ ...m(["length", "length0"]),
334
+ ...A(["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
335
+ ...p(["push", "push0"], ["pop", "pop0"], ["shift", "shift0"], ["unshift", "unshift0"]),
336
+ ...F(["push", "push1"], ["unshift", "unshift1"]),
337
+ ...b(["push", "push3"], ["unshift", "unshift3"]),
338
+ first0: function(t = null) {
339
+ return this.length ? this[0] : t;
340
+ },
341
+ last0: function(t = null) {
342
+ return this.length ? this[this.length - 1] : t;
343
+ },
344
+ find0: function(t, e = null) {
345
+ return this.find(t) ?? e;
346
+ },
347
+ equals0: function(t) {
348
+ return this.length === t.length && (this === t || this.length === 0 || this.every((e, n) => e === t[n]));
349
+ },
350
+ unique0: function(t = (e) => e) {
351
+ const e = /* @__PURE__ */ new Set();
352
+ return this.filter((n) => e.has(t(n)) ? !1 : !!e.add(t(n)));
353
+ },
354
+ ...p(["forEach", "each0"]),
355
+ toObject: function(t = (e, n) => [n, e]) {
356
+ return Object.fromEntries(this.map(t));
357
+ },
358
+ toMap: function(t = (e, n) => [n, e]) {
359
+ return new Map(this.map(t));
360
+ },
361
+ toSet: function(t = (e) => e) {
362
+ return new Set(this.map(t));
363
+ },
364
+ toGroup: function(t = (e) => [e.id, e]) {
365
+ const e = {};
366
+ for (const n of this) {
367
+ const [r, i] = t(n);
368
+ r in e || (e[r] = []), e[r].push(i);
369
+ }
370
+ return e;
371
+ },
372
+ toMerge: function(t = (r) => r.id, e = (r) => ({ ...r, children: [] }), n = (r, i) => r.children.push(i)) {
373
+ const r = [];
374
+ for (const i of this)
375
+ n(r.find((s) => t(s) == t(i)) ?? r.push1(e(i)), i);
376
+ return r;
377
+ },
378
+ bytes2hex: function() {
379
+ let t = "";
380
+ for (let e = 0; e < this.length; e++)
381
+ t += (this[e] < 16 ? "0" : "") + this[e].toString(16);
382
+ return t;
383
+ },
384
+ bytes2string: function() {
385
+ if (typeof TextDecoder < "u")
386
+ return new TextDecoder().decode(new Uint8Array(this));
387
+ let t = "";
388
+ for (let e = 0; e < this.length; e++)
389
+ t += "%" + (this[e] < 16 ? "0" : "") + this[e].toString(16);
390
+ return decodeURIComponent(t);
391
+ },
392
+ base64encode: function(t = !1, e = !0) {
393
+ let n = "", r = t === !0 ? "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
394
+ for (let i = 2; i < this.length; i += 3) {
395
+ const s = (this[i - 2] << 16) + (this[i - 1] << 8) + this[i];
396
+ n += r.charAt((s & 16515072) >> 18) + r.charAt((s & 258048) >> 12) + r.charAt((s & 4032) >> 6) + r.charAt(s & 63);
397
+ }
398
+ if (this.length % 3 == 2) {
399
+ const i = (this[this.length - 2] << 16) + (this[this.length - 1] << 8);
400
+ n += r.charAt((i & 16515072) >> 18) + r.charAt((i & 258048) >> 12) + r.charAt((i & 4032) >> 6) + (e === !1 ? "" : "=");
401
+ } else if (this.length % 3 == 1) {
402
+ const i = this[this.length - 1] << 16;
403
+ n += r.charAt((i & 16515072) >> 18) + r.charAt((i & 258048) >> 12) + (e === !1 ? "" : "==");
404
+ }
405
+ return n;
406
+ },
407
+ toUint8Array: function() {
408
+ return new Uint8Array(this);
607
409
  },
608
410
  // ====== Relational ======
609
- assoc: {
610
- value: function(t, e, n = {}) {
611
- const r = this.unique0((u) => u[t]), i = r.length == 0 ? {} : typeof n == "function" ? n(r) : n;
612
- return this.each0((u) => u[e] = i[u[t]] ?? null);
613
- },
614
- ...s
411
+ assoc: function(t, e, n = {}) {
412
+ const r = this.unique0((s) => s[t]), i = r.length == 0 ? {} : typeof n == "function" ? n(r) : n;
413
+ return this.each0((s) => s[e] = i[s[t]] ?? null);
615
414
  },
616
415
  // ====== Tree ======
617
- toTree: {
618
- value: function(t = {}) {
619
- const { id: e = "id", pid: n = "pid", level: r = "level", root: i = "root", parent: u = "parent", children: o = "children", empty: f = null, hasRoot: c = !0 } = t, y = this.toObject((a) => [a[e], a]), g = this.toGroup((a) => [a[n], a]), h = this.length && c ? this.find((a) => a[n] === 0) : { [e]: 0, [n]: -1, [i]: null, [u]: null, [o]: g[0] };
620
- l(h, { [i]: { value: h, enumerable: !1, configurable: !0, writable: !0 } });
621
- for (const a of this)
622
- l(a, {
623
- [i]: { value: h, enumerable: !1, configurable: !0, writable: !0 },
624
- [u]: { value: y[a[n]], enumerable: !1, configurable: !0, writable: !0 }
625
- }), a[o] = g[a[e]] || f;
626
- return h.treeEach0((a) => a[r] = a[u] ? a[u][r] + 1 : 0, -1, o), h;
627
- },
628
- ...s
629
- },
630
- tree2tree: {
631
- value: function(t = {}, e = null, n = null) {
632
- var g;
633
- const { id: r = "id", pid: i = "pid", level: u = "level", root: o = "root", parent: f = "parent", children: c = "children", empty: y = null } = t;
634
- e = e || { [r]: 0, [i]: -1, [u]: 0, [o]: null, [f]: null, [c]: this }, n = n || e;
635
- for (const h of this)
636
- l(h, {
637
- [o]: { value: e, enumerable: !1, configurable: !0, writable: !0 },
638
- [f]: { value: n, enumerable: !1, configurable: !0, writable: !0 }
639
- }), h[i] = n[r], h[u] = n[u] + 1, h[c] = h[c] && h[c].length ? h[c] : y, (g = h[c]) == null || g.tree2tree(t, e, h);
640
- return e;
641
- },
642
- ...s
643
- },
644
- treeFind0: {
645
- value: function(t, e = !0, n = -1, r = "children") {
646
- for (const i of this) {
647
- const u = i.treeFind0(t, e, n, r);
648
- if (u !== null)
649
- return u;
650
- }
651
- return null;
652
- },
653
- ...s
416
+ toTree: function(t = {}) {
417
+ const { id: e = "id", pid: n = "pid", level: r = "level", root: i = "root", parent: s = "parent", children: o = "children", empty: l = null, hasRoot: f = !0 } = t, y = this.toObject((h) => [h[e], h]), g = this.toGroup((h) => [h[n], h]), a = this.length && f ? this.find((h) => h[n] === 0) : { [e]: 0, [n]: -1, [i]: null, [s]: null, [o]: g[0] };
418
+ u(a, { [i]: { value: a, enumerable: !1, configurable: !0, writable: !0 } });
419
+ for (const h of this)
420
+ u(h, {
421
+ [i]: { value: a, enumerable: !1, configurable: !0, writable: !0 },
422
+ [s]: { value: y[h[n]], enumerable: !1, configurable: !0, writable: !0 }
423
+ }), h[o] = g[h[e]] || l;
424
+ return a.treeEach0((h) => h[r] = h[s] ? h[s][r] + 1 : 0, -1, o), a;
425
+ },
426
+ tree2tree: function(t = {}, e = null, n = null) {
427
+ var g;
428
+ const { id: r = "id", pid: i = "pid", level: s = "level", root: o = "root", parent: l = "parent", children: f = "children", empty: y = null } = t;
429
+ e = e || { [r]: 0, [i]: -1, [s]: 0, [o]: null, [l]: null, [f]: this }, n = n || e;
430
+ for (const a of this)
431
+ u(a, {
432
+ [o]: { value: e, enumerable: !1, configurable: !0, writable: !0 },
433
+ [l]: { value: n, enumerable: !1, configurable: !0, writable: !0 }
434
+ }), a[i] = n[r], a[s] = n[s] + 1, a[f] = a[f] && a[f].length ? a[f] : y, (g = a[f]) == null || g.tree2tree(t, e, a);
435
+ return e;
654
436
  },
655
- treeEach0: {
656
- value: function(t, e = !0, n = -1, r = "children") {
657
- for (const i of this)
658
- i.treeEach0(t, e, n, r);
659
- return this;
660
- },
661
- ...s
662
- },
663
- treeMap0: {
664
- value: function(t, e = !0, n = -1, r = "children", i = null) {
665
- return this.map((u) => u.treeMap0(t, e, n, r, i));
666
- },
667
- ...s
437
+ treeFind0: function(t, e = !0, n = -1, r = "children") {
438
+ for (const i of this) {
439
+ const s = i.treeFind0(t, e, n, r);
440
+ if (s !== null)
441
+ return s;
442
+ }
443
+ return null;
444
+ },
445
+ treeEach0: function(t, e = !0, n = -1, r = "children") {
446
+ for (const i of this)
447
+ i.treeEach0(t, e, n, r);
448
+ return this;
449
+ },
450
+ treeMap0: function(t, e = !0, n = -1, r = "children", i = null) {
451
+ return this.map((s) => s.treeMap0(t, e, n, r, i));
668
452
  }
669
453
  });
670
- l(ArrayBuffer.prototype, {
671
- toUint8Array: {
672
- value: function() {
673
- return new Uint8Array(this);
674
- },
675
- ...s
454
+ u(ArrayBuffer.prototype, {
455
+ toUint8Array: function() {
456
+ return new Uint8Array(this);
676
457
  }
677
458
  });
678
- l(Uint8Array.prototype, {
679
- ...O(Array.prototype, "bytes2hex", "bytes2string", "base64encode"),
680
- toArray: {
681
- value: function() {
682
- return new Array(...this);
683
- },
684
- ...s
459
+ u(Uint8Array.prototype, {
460
+ ...I(Array.prototype, "bytes2hex", "bytes2string", "base64encode"),
461
+ toArray: function() {
462
+ return new Array(...this);
685
463
  }
686
464
  });
687
- l(Map, {
688
- ...p()
465
+ u(Map, {
466
+ ...d()
689
467
  });
690
- l(Map.prototype, {
691
- ...d(["size", "length0"]),
692
- ...b(["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
693
- ...v(["set", "set0"], ["delete", "delete0"]),
694
- ...m(["set", "set3"]),
695
- get0: {
696
- value: function(t, e = null) {
697
- return this.has(t) ? this.get(t) : e;
698
- },
699
- ...s
700
- },
701
- get1: {
702
- value: function(t, e, ...n) {
703
- return this.has(t) ? this.get(t) : this.set3(t, e(t, ...n))[1];
704
- },
705
- ...s
706
- },
707
- getAsync1: {
708
- value: async function(t, e, ...n) {
709
- return this.has(t) ? this.get(t) : this.set3(t, await e(t, ...n))[1];
710
- },
711
- ...s
712
- },
713
- toObject: {
714
- value: function() {
715
- return Object.fromEntries(this);
716
- },
717
- ...s
718
- },
719
- toArray: {
720
- value: function() {
721
- return [...this];
722
- },
723
- ...s
724
- },
725
- toJSON: {
726
- value: function() {
727
- return [...this];
728
- },
729
- ...s
468
+ u(Map.prototype, {
469
+ ...m(["size", "length0"]),
470
+ ...A(["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
471
+ ...p(["set", "set0"], ["delete", "delete0"]),
472
+ ...b(["set", "set3"]),
473
+ get0: function(t, e = null) {
474
+ return this.has(t) ? this.get(t) : e;
475
+ },
476
+ get1: function(t, e, ...n) {
477
+ return this.has(t) ? this.get(t) : this.set3(t, e(t, ...n))[1];
478
+ },
479
+ getAsync1: async function(t, e, ...n) {
480
+ return this.has(t) ? this.get(t) : this.set3(t, await e(t, ...n))[1];
481
+ },
482
+ toObject: function() {
483
+ return Object.fromEntries(this);
484
+ },
485
+ toArray: function() {
486
+ return [...this];
487
+ },
488
+ toJSON: function() {
489
+ return [...this];
730
490
  }
731
491
  });
732
- l(Set, {
733
- ...p()
492
+ u(Set, {
493
+ ...d()
734
494
  });
735
- l(Set.prototype, {
736
- ...d(["size", "length0"]),
737
- ...b(["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
738
- ...v(["add", "add0"], ["delete", "delete0"]),
739
- ...m(["add", "add3"]),
740
- toArray: {
741
- value: function() {
742
- return [...this];
743
- },
744
- ...s
745
- },
746
- toJSON: {
747
- value: function() {
748
- return [...this];
749
- },
750
- ...s
495
+ u(Set.prototype, {
496
+ ...m(["size", "length0"]),
497
+ ...A(["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
498
+ ...p(["add", "add0"], ["delete", "delete0"]),
499
+ ...b(["add", "add3"]),
500
+ toArray: function() {
501
+ return [...this];
502
+ },
503
+ toJSON: function() {
504
+ return [...this];
751
505
  }
752
506
  });
753
- l(Date, {
754
- new: {
755
- value: function(...t) {
756
- return t.length != 1 ? new Date(...t) : Number.isNaN(+t[0]) ? new Date(t[0].includes("T") ? t[0] : t[0].replace(/-/g, "/")) : new Date(t[0] > 25e8 ? t[0] : t[0] * 1e3);
757
- },
758
- ...s
759
- },
760
- format: {
761
- value: function(t = "y-m-d h:i:s") {
762
- return (/* @__PURE__ */ new Date()).format(t);
763
- },
764
- ...s
765
- },
766
- unix: {
767
- value: function() {
768
- return this.now() / 1e3 | 0;
769
- },
770
- ...s
771
- },
772
- fromUnix: {
773
- value: function(t = 0) {
774
- return new Date((t || 0) * 1e3);
775
- },
776
- ...s
777
- },
778
- expr: {
779
- value: function(t = {}) {
780
- return (/* @__PURE__ */ new Date()).expr(t);
781
- },
782
- ...s
783
- },
784
- toDayRange: {
785
- value: function() {
786
- const t = /* @__PURE__ */ new Date(), e = t.getFullYear(), n = t.getMonth(), r = t.getDate(), i = new Date(e, n, r).getTime() / 1e3 | 0;
787
- return [i, i + 86400 - 1];
788
- },
789
- ...s
790
- },
791
- toWeekRange: {
792
- value: function() {
793
- let t = /* @__PURE__ */ new Date();
794
- for (; t.getDay() != 1; )
795
- t = new Date(t.getTime() - 86400);
796
- const e = t.getFullYear(), n = t.getMonth(), r = t.getDate(), i = new Date(e, n, r).getTime() / 1e3 | 0;
797
- return [i, i + 86400 * 7 - 1];
798
- },
799
- ...s
800
- },
801
- toMonthRange: {
802
- value: function() {
803
- const t = /* @__PURE__ */ new Date(), e = t.getFullYear(), n = t.getMonth(), r = new Date(e, n, 1).getTime() / 1e3 | 0, i = new Date(e, n + 1, 0, 23, 59, 59).getTime() / 1e3 | 0;
804
- return [r, i];
805
- },
806
- ...s
807
- },
808
- toYearRange: {
809
- value: function() {
810
- const e = (/* @__PURE__ */ new Date()).getFullYear(), n = new Date(e, 1, 1).getTime() / 1e3 | 0, r = new Date(e + 1, 1, 0, 23, 59, 59).getTime() / 1e3 | 0;
811
- return [n, r];
812
- },
813
- ...s
507
+ u(Date, {
508
+ new: function(...t) {
509
+ return t.length != 1 ? new Date(...t) : Number.isNaN(+t[0]) ? new Date(t[0].includes("T") ? t[0] : t[0].replace(/-/g, "/")) : new Date(t[0] > 25e8 ? t[0] : t[0] * 1e3);
510
+ },
511
+ format: function(t = "y-m-d h:i:s") {
512
+ return (/* @__PURE__ */ new Date()).format(t);
513
+ },
514
+ unix: function() {
515
+ return this.now() / 1e3 | 0;
516
+ },
517
+ fromUnix: function(t = 0) {
518
+ return new Date((t || 0) * 1e3);
519
+ },
520
+ expr: function(t = {}) {
521
+ return (/* @__PURE__ */ new Date()).expr(t);
522
+ },
523
+ toDayRange: function() {
524
+ const t = /* @__PURE__ */ new Date(), e = t.getFullYear(), n = t.getMonth(), r = t.getDate(), i = new Date(e, n, r).getTime() / 1e3 | 0;
525
+ return [i, i + 86400 - 1];
526
+ },
527
+ toWeekRange: function() {
528
+ let t = /* @__PURE__ */ new Date();
529
+ for (; t.getDay() != 1; )
530
+ t = new Date(t.getTime() - 86400);
531
+ const e = t.getFullYear(), n = t.getMonth(), r = t.getDate(), i = new Date(e, n, r).getTime() / 1e3 | 0;
532
+ return [i, i + 86400 * 7 - 1];
533
+ },
534
+ toMonthRange: function() {
535
+ const t = /* @__PURE__ */ new Date(), e = t.getFullYear(), n = t.getMonth(), r = new Date(e, n, 1).getTime() / 1e3 | 0, i = new Date(e, n + 1, 0, 23, 59, 59).getTime() / 1e3 | 0;
536
+ return [r, i];
537
+ },
538
+ toYearRange: function() {
539
+ const e = (/* @__PURE__ */ new Date()).getFullYear(), n = new Date(e, 1, 1).getTime() / 1e3 | 0, r = new Date(e + 1, 1, 0, 23, 59, 59).getTime() / 1e3 | 0;
540
+ return [n, r];
814
541
  }
815
542
  });
816
- l(Date.prototype, {
817
- format: {
818
- value: function(t = "y-m-d h:i:s") {
819
- if (this.getTime() === 0)
820
- return "-";
821
- const e = {
822
- y: this.getFullYear(),
823
- m: this.getMonth() + 1,
824
- d: this.getDate(),
825
- h: this.getHours(),
826
- i: this.getMinutes(),
827
- s: this.getSeconds(),
828
- l: this.getMilliseconds(),
829
- e: this.getMonthDay()
830
- };
831
- return t.replace(/([ymdhisle])/ig, (n, r) => r >= "A" && r <= "Z" ? e[r.toLowerCase()] : e[r].toString().padStart(r === "l" ? 3 : 2, "0"));
832
- },
833
- ...s
834
- },
835
- unix: {
836
- value: function() {
837
- return this.getTime() / 1e3 | 0;
838
- },
839
- ...s
840
- },
841
- isLeapYear: {
842
- value: function() {
843
- return this.getFullYear() % 4 === 0 && this.getFullYear() % 400 !== 0;
844
- },
845
- ...s
846
- },
847
- getMonthDay: {
848
- value: function() {
849
- return [31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][this.getMonth()] || (this.isLeapYear() ? 29 : 28);
850
- },
851
- ...s
852
- },
853
- expr: {
854
- value: function({ y: t = 0, m: e = 0, d: n = 0, h: r = 0, i = 0, s: u = 0 }) {
855
- const o = new Date(this.getFullYear() + t, this.getMonth() + e + 1, 0);
856
- return new Date(this.getFullYear() + t, this.getMonth() + e, Math.min(o.getDate(), this.getDate()) + n, this.getHours() + r, this.getMinutes() + i, this.getSeconds() + u);
857
- },
858
- ...s
859
- },
860
- begin: {
861
- value: function(t = 3) {
862
- return new Date(...[this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()].slice(0, t), ...[this.getFullYear(), 0, 1, 0, 0, 0].slice(t));
863
- },
864
- ...s
865
- },
866
- end: {
867
- value: function(t = 3) {
868
- return new Date(...[this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()].slice(0, t), ...[this.getFullYear(), 11, t < 2 ? 31 : this.getMonthDay(), 23, 59, 59].slice(t));
869
- },
870
- ...s
871
- },
872
- week: {
873
- value: function(t, e = 1) {
874
- let n = new Date(this.getTime());
875
- for (; n.getDay() !== t; )
876
- n = new Date(n.getTime() + 864e5 * e);
877
- return n;
878
- },
879
- ...s
880
- },
881
- toJSON: {
882
- value: function() {
883
- return this.getTime();
884
- },
885
- ...s
543
+ u(Date.prototype, {
544
+ format: function(t = "y-m-d h:i:s") {
545
+ if (this.getTime() === 0)
546
+ return "-";
547
+ const e = {
548
+ y: this.getFullYear(),
549
+ m: this.getMonth() + 1,
550
+ d: this.getDate(),
551
+ h: this.getHours(),
552
+ i: this.getMinutes(),
553
+ s: this.getSeconds(),
554
+ l: this.getMilliseconds(),
555
+ e: this.getMonthDay()
556
+ };
557
+ return t.replace(/([ymdhisle])/ig, (n, r) => r >= "A" && r <= "Z" ? e[r.toLowerCase()] : e[r].toString().padStart(r === "l" ? 3 : 2, "0"));
558
+ },
559
+ unix: function() {
560
+ return this.getTime() / 1e3 | 0;
561
+ },
562
+ isLeapYear: function() {
563
+ return this.getFullYear() % 4 === 0 && this.getFullYear() % 400 !== 0;
564
+ },
565
+ getMonthDay: function() {
566
+ return [31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][this.getMonth()] || (this.isLeapYear() ? 29 : 28);
567
+ },
568
+ expr: function({ y: t = 0, m: e = 0, d: n = 0, h: r = 0, i = 0, s = 0 }) {
569
+ const o = new Date(this.getFullYear() + t, this.getMonth() + e + 1, 0);
570
+ return new Date(this.getFullYear() + t, this.getMonth() + e, Math.min(o.getDate(), this.getDate()) + n, this.getHours() + r, this.getMinutes() + i, this.getSeconds() + s);
571
+ },
572
+ begin: function(t = 3) {
573
+ return new Date(...[this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()].slice(0, t), ...[this.getFullYear(), 0, 1, 0, 0, 0].slice(t));
574
+ },
575
+ end: function(t = 3) {
576
+ return new Date(...[this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()].slice(0, t), ...[this.getFullYear(), 11, t < 2 ? 31 : this.getMonthDay(), 23, 59, 59].slice(t));
577
+ },
578
+ week: function(t, e = 1) {
579
+ let n = new Date(this.getTime());
580
+ for (; n.getDay() !== t; )
581
+ n = new Date(n.getTime() + 864e5 * e);
582
+ return n;
583
+ },
584
+ toJSON: function() {
585
+ return this.getTime();
886
586
  }
887
587
  });
888
- l(RegExp, {
889
- ...p()
588
+ u(RegExp, {
589
+ ...d()
890
590
  });
891
- l(RegExp.prototype, {
892
- toJSON: {
893
- value: function() {
894
- return this.toString();
895
- },
896
- ...s
591
+ u(RegExp.prototype, {
592
+ toJSON: function() {
593
+ return this.toString();
897
594
  }
898
595
  });
899
- typeof Promise.withResolvers > "u" && l(Promise, {
900
- withResolvers: {
901
- value: function() {
902
- let t = null, e = null;
903
- return { promise: new this((r, i) => {
904
- t = r, e = i;
905
- }), resolve: t, reject: e };
906
- },
907
- ...s
596
+ typeof Promise.withResolvers > "u" && u(Promise, {
597
+ withResolvers: function() {
598
+ let t = null, e = null;
599
+ return { promise: new this((r, i) => {
600
+ t = r, e = i;
601
+ }), resolve: t, reject: e };
908
602
  }
909
603
  });
910
- l(Promise, {
911
- channel: {
912
- value: function() {
913
- let t = null, e = null;
914
- return [new this((r, i) => {
915
- t = r, e = i;
916
- }), t, e];
917
- },
918
- ...s
604
+ u(Promise, {
605
+ channel: function() {
606
+ let t = null, e = null;
607
+ return [new this((r, i) => {
608
+ t = r, e = i;
609
+ }), t, e];
919
610
  }
920
611
  });
921
- l(Promise.prototype, {
922
- tryCatch: {
923
- value: function() {
924
- return new Promise((t) => this.then((e) => t([e, null])).catch((e) => t([null, e])));
925
- },
926
- ...s
612
+ u(Promise.prototype, {
613
+ tryCatch: function() {
614
+ return new Promise((t) => this.then((e) => t([e, null])).catch((e) => t([null, e])));
927
615
  }
928
616
  });
929
- l(JSON, {
930
- parse0: {
931
- value: function(t, e = null) {
932
- try {
933
- if (typeof t != "string")
934
- throw new Error("not string");
935
- return JSON.parse(t);
936
- } catch {
937
- return e;
938
- }
939
- },
940
- ...s
617
+ u(JSON, {
618
+ parse0: function(t, e = null) {
619
+ try {
620
+ if (typeof t != "string")
621
+ throw new Error("not string");
622
+ return JSON.parse(t);
623
+ } catch {
624
+ return e;
625
+ }
626
+ }
627
+ });
628
+ let c = "", E = 0, S = 0, w = 0;
629
+ u(Math, {
630
+ prefix: function(t = null) {
631
+ return c = t ?? c;
632
+ },
633
+ cookieSet: function(t, e, n = { Path: "/" }) {
634
+ let r = `${encodeURIComponent(t)}=${encodeURIComponent(e)}`;
635
+ r += n.Expires ? `; Expires=${n.Expires.toGMTString()}` : "", r += n.MaxAge ? `; Max-Age=${n.MaxAge}` : "", r += n.Domain ? `; Domain=${n.Domain}` : "", r += n.Path ? `; Path=${n.Path}` : "", r += n.SameSite ? `; SameSite=${n.SameSite}` : "", r += n.Partitioned ? "; Partitioned" : "", r += n.HttpOnly ? "; HttpOnly" : "", r += n.Secure ? "; Secure" : "", document.cookie = r;
636
+ },
637
+ cookieGet: function(t = null) {
638
+ const e = document.cookie == "" ? {} : Object.fromEntries(document.cookie.split("; ").map((n) => n.split("=").map(decodeURIComponent)));
639
+ return t ? e[t] : e;
640
+ },
641
+ cookieRemove: function(t) {
642
+ document.cookie = `${t}=; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/`;
643
+ },
644
+ cookieClear: function(...t) {
645
+ const e = Math.cookieGet();
646
+ for (const n in e)
647
+ t.includes(n) || Math.cookieRemove(n);
648
+ },
649
+ localSet: function(t, e) {
650
+ return localStorage.setItem(c + t, JSON.stringify(e)) || e;
651
+ },
652
+ localGet: function(t, e = null) {
653
+ try {
654
+ return c + t in localStorage ? JSON.parse(localStorage.getItem(c + t)) : e;
655
+ } catch {
656
+ return e;
657
+ }
658
+ },
659
+ localSetString: function(t, e) {
660
+ return localStorage.setItem(c + t, e) || e;
661
+ },
662
+ localGetString: function(t, e = "") {
663
+ return c + t in localStorage ? localStorage.getItem(c + t) : e;
664
+ },
665
+ localRemove: function(...t) {
666
+ for (const e of t)
667
+ localStorage.removeItem(c + e);
668
+ },
669
+ localClear: function(...t) {
670
+ for (let e = 0; e < localStorage.length; e++) {
671
+ const n = localStorage.key(e);
672
+ !n.startsWith(c) || t.includes(n.substring(c.length)) || localStorage.removeItem(n);
673
+ }
674
+ },
675
+ sessionSet: function(t, e) {
676
+ return sessionStorage.setItem(c + t, JSON.stringify(e)) || e;
677
+ },
678
+ sessionGet: function(t, e = null) {
679
+ try {
680
+ return c + t in sessionStorage ? JSON.parse(sessionStorage.getItem(c + t)) : e;
681
+ } catch {
682
+ return e;
683
+ }
684
+ },
685
+ sessionSetString: function(t, e) {
686
+ return sessionStorage.setItem(c + t, e) || e;
687
+ },
688
+ sessionGetString: function(t, e = "") {
689
+ return c + t in sessionStorage ? sessionStorage.getItem(c + t) : e;
690
+ },
691
+ sessionRemove: function(...t) {
692
+ for (const e of t)
693
+ sessionStorage.removeItem(c + e);
694
+ },
695
+ sessionClear: function(...t) {
696
+ for (let e = 0; e < sessionStorage.length; e++) {
697
+ const n = sessionStorage.key(e);
698
+ !n.startsWith(c) || t.includes(n.substring(c.length)) || sessionStorage.removeItem(n);
699
+ }
700
+ },
701
+ randstr: function(t = 16, e = 0, n = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", r = "~!@#$%^&*()_+`{}|[]\\:\";'<>,.?/") {
702
+ if (t < e)
703
+ throw new Error("randstr: len < slen");
704
+ const i = [];
705
+ for (let s = 0; s < t; s++)
706
+ i.push(n.charAt(Math.random() * n.length | 0));
707
+ for (let s = /* @__PURE__ */ new Set(), o = 0, l = 0; l < e; l++) {
708
+ do
709
+ o = Math.random() * t | 0;
710
+ while (s.has(o));
711
+ s.set(o, !0), i[o] = r.charAt(Math.random() * r.length | 0);
712
+ }
713
+ return i.join("");
714
+ },
715
+ randint: function(t = 0, e = Number.MAX_SAFE_INTEGER) {
716
+ return Math.floor(Math.random() * (e - t) + t);
717
+ },
718
+ incrid: function() {
719
+ return ++E;
720
+ },
721
+ incrstr: function() {
722
+ return "" + Math.incrid();
723
+ },
724
+ uniqid: function(t = Date.now()) {
725
+ return t === w ? t * 2048 + ++S % 2048 : (w = t) * 2048 + (S = 0) % 2048;
726
+ },
727
+ uniqstr: function() {
728
+ return "" + Math.uniqid();
729
+ },
730
+ filesize: function(t, e = 2) {
731
+ const n = ["B", "KB", "MB", "GB", "TB", "PB"];
732
+ let r = Math.log(t) / Math.log(1024) | 0;
733
+ return r = r < n.length ? r : n.length - 1, (t / Math.pow(1024, r)).toFixed(e) - 0 + n[r];
734
+ },
735
+ sleep: function(t) {
736
+ return new Promise((e) => setTimeout(e, t));
737
+ },
738
+ useTemplate: function(t) {
739
+ let e = null;
740
+ const n = { setup(i, { slots: s }) {
741
+ return e = s.default, () => {
742
+ };
743
+ }, name: t + "Template" }, r = { setup(i, { attrs: s }) {
744
+ return () => e == null ? void 0 : e(s);
745
+ }, name: t };
746
+ return { [n.name]: n, [r.name]: r };
941
747
  }
942
748
  });