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