esexts 2.0.3 → 2.0.5

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
@@ -18,29 +18,29 @@ function m(...t) {
18
18
  }
19
19
  return e;
20
20
  }
21
- function l(t, e, n, ...r) {
22
- const i = {}, o = (s, u, h) => (u !== null && s.splice(u >= 0 ? u : s.length + u + 1, 0, h), s);
23
- for (const s of r) {
24
- const [u, h] = Array.isArray(s) ? s : [s, "$" + s + n.toString().replaceAll("-", "_")];
21
+ function f(t, e, n, ...r) {
22
+ const i = {}, s = (o, u, h) => (u !== null && o.splice(u >= 0 ? u : o.length + u + 1, 0, h), o);
23
+ for (const o of r) {
24
+ const [u, h] = Array.isArray(o) ? o : [o, "$" + o + n.toString().replaceAll("-", "_")];
25
25
  if (n === "")
26
26
  i[h] = function(...a) {
27
- return t[u].apply(this, o(a, e, this));
27
+ return t[u].apply(this, s(a, e, this));
28
28
  };
29
29
  else if (n === "t")
30
30
  i[h] = function(...a) {
31
- return t[u].apply(this, o(a, e, this)), this;
31
+ return t[u].apply(this, s(a, e, this)), this;
32
32
  };
33
33
  else if (n === "a")
34
34
  i[h] = function(...a) {
35
- return t[u].apply(this, o(a, e, this)), a;
35
+ return t[u].apply(this, s(a, e, this)), a;
36
36
  };
37
37
  else if (n >= 0)
38
38
  i[h] = function(...a) {
39
- return t[u].apply(this, o(a, e, this)), a[n];
39
+ return t[u].apply(this, s(a, e, this)), a[n];
40
40
  };
41
41
  else if (n < 0)
42
42
  i[h] = function(...a) {
43
- return t[u].apply(this, o(a, e, this)), a[a.length + n];
43
+ return t[u].apply(this, s(a, e, this)), a[a.length + n];
44
44
  };
45
45
  else
46
46
  throw Error("unreachable");
@@ -50,34 +50,34 @@ function l(t, e, n, ...r) {
50
50
  function $(t, ...e) {
51
51
  const n = {};
52
52
  for (const r of e) {
53
- const [i, o] = Array.isArray(r) ? r : [r, "$" + r];
54
- n[o] = function(...s) {
55
- return [...t[i].apply(this, s)];
53
+ const [i, s] = Array.isArray(r) ? r : [r, "$" + r];
54
+ n[s] = function(...o) {
55
+ return [...t[i].apply(this, o)];
56
56
  };
57
57
  }
58
58
  return n;
59
59
  }
60
- function A(t = { array: !1 }) {
60
+ function b(t = { array: !1 }) {
61
61
  return function(e = {}, ...n) {
62
- const r = (i, o) => {
63
- const s = Object.prototype.toString.call(i), u = Object.prototype.toString.call(o);
64
- if (s !== u)
65
- return o;
66
- if (s === "[object Array]")
67
- return t.array ? i.concat(...o) : o;
68
- if (s === "[object Object]") {
69
- for (const h in o)
70
- i[h] = r(i[h], o[h]);
62
+ const r = (i, s) => {
63
+ const o = Object.prototype.toString.call(i), u = Object.prototype.toString.call(s);
64
+ if (o !== u)
65
+ return s;
66
+ if (o === "[object Array]")
67
+ return t.array ? i.concat(...s) : s;
68
+ if (o === "[object Object]") {
69
+ for (const h in s)
70
+ i[h] = r(i[h], s[h]);
71
71
  return i;
72
72
  } else
73
- return o;
73
+ return s;
74
74
  };
75
75
  for (const i of n)
76
76
  e = r(e, i);
77
77
  return e;
78
78
  };
79
79
  }
80
- const x = A({ array: !1 }), M = A({ array: !0 });
80
+ const x = b({ array: !1 }), S = b({ array: !0 });
81
81
  c(Object, {
82
82
  ...g(),
83
83
  isObject: function(t) {
@@ -87,7 +87,7 @@ c(Object, {
87
87
  return x(this, ...t);
88
88
  },
89
89
  concat: function(...t) {
90
- return M(this, ...t);
90
+ return S(this, ...t);
91
91
  }
92
92
  });
93
93
  c(Object.prototype, {
@@ -97,13 +97,13 @@ c(Object.prototype, {
97
97
  $length: function() {
98
98
  return Object.keys(this).length;
99
99
  },
100
- ...l(Object, 0, "", "entries", "keys", "values", "assign"),
101
- ...l(JSON, 0, "", "stringify"),
100
+ ...f(Object, 0, "", "entries", "keys", "values", "assign"),
101
+ ...f(JSON, 0, "", "stringify"),
102
102
  $merge: function(...t) {
103
103
  return x(this, ...t);
104
104
  },
105
105
  $concat: function(...t) {
106
- return M(this, ...t);
106
+ return S(this, ...t);
107
107
  },
108
108
  $empty: function() {
109
109
  return Object.keys(this).length == 0;
@@ -132,13 +132,13 @@ c(Object.prototype, {
132
132
  $pipe: function(t, ...e) {
133
133
  return t(this, ...e);
134
134
  },
135
- $handle: function(t, ...e) {
135
+ $tee: function(t, ...e) {
136
136
  return t(this, ...e), this;
137
137
  },
138
138
  $toArray: function() {
139
139
  return Array.isArray(this) ? this : [this];
140
140
  },
141
- ...l(console, -1, "t", ["debug", "$debug"], ["log", "$log"], ["info", "$info"], ["warn", "$warn"], ["error", "$error"], ["dir", "$dir"]),
141
+ ...f(console, -1, "t", ["debug", "$debug"], ["log", "$log"], ["info", "$info"], ["warn", "$warn"], ["error", "$error"], ["dir", "$dir"]),
142
142
  $debugger: function(...t) {
143
143
  console.debug(this, ...t);
144
144
  debugger;
@@ -153,9 +153,9 @@ c(Object.prototype, {
153
153
  return r;
154
154
  },
155
155
  $getChildrens: function(t = !1, e = -1, n = "children") {
156
- const r = [], i = (o, s, u) => {
157
- if (s && r.push(o), !(u == 0 || !o[n] || o[n].length == 0))
158
- for (const h of o[n])
156
+ const r = [], i = (s, o, u) => {
157
+ if (o && r.push(s), !(u == 0 || !s[n] || s[n].length == 0))
158
+ for (const h of s[n])
159
159
  i(h, !0, u - 1);
160
160
  };
161
161
  return i(this, t, e), r;
@@ -166,9 +166,9 @@ c(Object.prototype, {
166
166
  if (n == 0 || !this[r] || this[r].length == 0)
167
167
  return null;
168
168
  for (const i of this[r]) {
169
- const o = i.$tree$find(t, !0, n - 1, r);
170
- if (o !== null)
171
- return o;
169
+ const s = i.$tree$find(t, !0, n - 1, r);
170
+ if (s !== null)
171
+ return s;
172
172
  }
173
173
  return null;
174
174
  },
@@ -180,16 +180,16 @@ c(Object.prototype, {
180
180
  }
181
181
  },
182
182
  $tree$map: function(t, e = !0, n = -1, r = "children", i = null) {
183
- const o = e ? t(this) : this, s = [];
183
+ const s = e ? t(this) : this, o = [];
184
184
  if (n == 0 || !this[r] || this[r].length == 0)
185
- return o;
185
+ return s;
186
186
  for (const u of this[r])
187
- s.push(u.$tree$map(t, !0, n - 1, r, i));
188
- return o[r] = s, o;
187
+ o.push(u.$tree$map(t, !0, n - 1, r, i));
188
+ return s[r] = o, s;
189
189
  }
190
190
  });
191
191
  c(Number.prototype, {
192
- ...l(Math, 0, "", ["ceil", "ceil"], ["floor", "floor"], ["trunc", "trunc"], ["abs", "abs"], ["max", "max"], ["min", "min"]),
192
+ ...f(Math, 0, "", ["ceil", "ceil"], ["floor", "floor"], ["trunc", "trunc"], ["abs", "abs"], ["max", "max"], ["min", "min"]),
193
193
  fixed: function(t = 0) {
194
194
  return +this.toFixed(t);
195
195
  },
@@ -216,10 +216,10 @@ c(Number.prototype, {
216
216
  },
217
217
  unit: function(t, e = 0) {
218
218
  let n = this, r = "";
219
- for (const [i, o] of Object.entries(t)) {
220
- if (r = i, o === 0 || n < o)
219
+ for (const [i, s] of Object.entries(t)) {
220
+ if (r = i, s === 0 || n < s)
221
221
  break;
222
- n = n / o;
222
+ n = n / s;
223
223
  }
224
224
  return e < 0 ? +n.toFixed(0 - e) + r : n.toFixed(e) + r;
225
225
  },
@@ -231,7 +231,7 @@ c(Number.prototype, {
231
231
  break;
232
232
  } else
233
233
  r.push([n % size, unit]), n = Math.floor(n / size);
234
- return e ? r : r.reverse().map(([i, o]) => i + o).join("");
234
+ return e ? r : r.reverse().map(([i, s]) => i + s).join("");
235
235
  },
236
236
  toDate: function() {
237
237
  return Date.new(this);
@@ -271,16 +271,16 @@ c(String.prototype, {
271
271
  return e;
272
272
  },
273
273
  subOf: function(t, e, n = 0, r = 0) {
274
- for (let s = 0; s < n && r != -1; s++, r++)
274
+ for (let o = 0; o < n && r != -1; o++, r++)
275
275
  r = this.indexOf(t, r);
276
- let i = this.indexOf(t, r), o = this.indexOf(e, i);
277
- return i == -1 || o == -1 ? "" : (i += t.length, this.substring(i, o));
276
+ let i = this.indexOf(t, r), s = this.indexOf(e, i);
277
+ return i == -1 || s == -1 ? "" : (i += t.length, this.substring(i, s));
278
278
  },
279
279
  lastSubOf: function(t, e, n = 0, r = 1 / 0) {
280
- for (let s = 0; s < n && r != -1; s++, r--)
280
+ for (let o = 0; o < n && r != -1; o++, r--)
281
281
  r = this.lastIndexOf(t, r);
282
- let i = this.lastIndexOf(t, r), o = this.indexOf(e, i);
283
- return i == -1 || o == -1 ? "" : (i += t.length, this.substring(i, o));
282
+ let i = this.lastIndexOf(t, r), s = this.indexOf(e, i);
283
+ return i == -1 || s == -1 ? "" : (i += t.length, this.substring(i, s));
284
284
  },
285
285
  camel2under: function() {
286
286
  return this.substr(0, 1) + this.substr(1).replace(/([A-Z])/g, (t, e) => "_" + e.toLowerCase());
@@ -335,7 +335,7 @@ c(Array, {
335
335
  ...g(),
336
336
  // ====== from pinojs ======
337
337
  range: function(...t) {
338
- let e = [], n = 0, r = 0, i = 1, o = typeof t[t.length - 1] == "boolean" ? t.pop() : !0, s = typeof t[t.length - 1] == "function" ? t.pop() : (u, h, a) => u;
338
+ let e = [], n = 0, r = 0, i = 1, s = typeof t[t.length - 1] == "boolean" ? t.pop() : !0, o = typeof t[t.length - 1] == "function" ? t.pop() : (u, h, a) => u;
339
339
  switch (t.length) {
340
340
  case 1:
341
341
  [r] = t;
@@ -352,17 +352,17 @@ c(Array, {
352
352
  if (i == 0)
353
353
  throw new Error("step cannot be 0!");
354
354
  for (let u = 0, h = 0, a = Math.abs(r - n), p = Math.abs(i), d = n <= r ? 1 : -1; h < a; h += p)
355
- e.push(o ? s(n + h * d, u++, e) : s());
355
+ e.push(s ? o(n + h * d, u++, e) : o());
356
356
  return e;
357
357
  }
358
358
  });
359
359
  c(Array.prototype, {
360
360
  ...m("length"),
361
361
  ...$(Array.prototype, "entries", "keys", "values"),
362
- ...l(Array.prototype, null, "", "map"),
363
- ...l(Array.prototype, null, "t", ["push", "$push"], ["pop", "$pop"], ["shift", "$shift"], ["unshift", "$unshift"], ["splice", "$splice"]),
364
- ...l(Array.prototype, null, "a", "push", "unshift"),
365
- ...l(Array.prototype, null, 0, "push", "unshift"),
362
+ ...f(Array.prototype, null, "", "map"),
363
+ ...f(Array.prototype, null, "t", ["push", "$push"], ["pop", "$pop"], ["shift", "$shift"], ["unshift", "$unshift"], ["splice", "$splice"]),
364
+ ...f(Array.prototype, null, "a", "push", "unshift"),
365
+ ...f(Array.prototype, null, 0, "push", "unshift"),
366
366
  $empty: function() {
367
367
  return this.length == 0;
368
368
  },
@@ -382,7 +382,7 @@ c(Array.prototype, {
382
382
  const e = /* @__PURE__ */ new Set();
383
383
  return this.filter((n) => e.has(t(n)) ? !1 : !!e.add(t(n)));
384
384
  },
385
- ...l(Array.prototype, null, "t", ["forEach", "each"]),
385
+ ...f(Array.prototype, null, "t", ["forEach", "each"]),
386
386
  each$async: async function(t) {
387
387
  for (let e = 0; e < this.length; e++)
388
388
  await t(this[e], e, this);
@@ -403,16 +403,17 @@ c(Array.prototype, {
403
403
  return this;
404
404
  },
405
405
  // ====== collection ======
406
- intersect: function(t) {
407
- const e = new Set(t);
408
- return [...new Set(this)].filter((n) => e.has(n));
409
- },
410
406
  union: function(t) {
411
- return [.../* @__PURE__ */ new Set([...this, ...t])];
407
+ return Set.new(this).union(Set.new(t)).toArray();
408
+ },
409
+ intersection: function(t) {
410
+ return Set.new(this).intersection(Set.new(t)).toArray();
411
+ },
412
+ difference: function(t) {
413
+ return Set.new(this).difference(Set.new(t)).toArray();
412
414
  },
413
- diff: function(t) {
414
- const e = new Set(t);
415
- return [...new Set(this)].filter((n) => !e.has(n));
415
+ symmetricDifference: function(t) {
416
+ return Set.new(this).symmetricDifference(Set.new(t)).toArray();
416
417
  },
417
418
  // ====== convert ======
418
419
  toMap: function(t = (e, n) => [n, e]) {
@@ -437,29 +438,29 @@ c(Array.prototype, {
437
438
  },
438
439
  // ====== Relational ======
439
440
  assoc: function(t, e, n = {}) {
440
- const r = this.unique$((o) => o[t]), i = r.length == 0 ? {} : typeof n == "function" ? n(r) : n;
441
- return this.each$((o) => o[e] = i[o[t]] ?? null);
441
+ const r = this.unique$((s) => s[t]), i = r.length == 0 ? {} : typeof n == "function" ? n(r) : n;
442
+ return this.each$((s) => s[e] = i[s[t]] ?? null);
442
443
  },
443
444
  // ====== Tree ======
444
445
  toTree: function(t = {}) {
445
- const { id: e = "id", pid: n = "pid", level: r = "level", root: i = "root", parent: o = "parent", children: s = "children", empty: u = null, hasRoot: h = !0 } = t, a = this.reduce((f, y) => f.$attr(y[e], y), {}), p = this.reduce((f, y) => (f.$attr(y[n], [], !1).$attr(y[n]).$push(y), f), {}), d = this.length && h ? this.find((f) => f[n] === 0) : { [e]: 0, [n]: -1, [i]: null, [o]: null, [s]: p[0] };
446
+ const { id: e = "id", pid: n = "pid", level: r = "level", root: i = "root", parent: s = "parent", children: o = "children", empty: u = null, hasRoot: h = !0 } = t, a = this.reduce((l, y) => l.$attr(y[e], y), {}), p = this.reduce((l, y) => (l.$attr(y[n], [], !1).$attr(y[n]).$push(y), l), {}), d = this.length && h ? this.find((l) => l[n] === 0) : { [e]: 0, [n]: -1, [i]: null, [s]: null, [o]: p[0] };
446
447
  c(d, { [i]: d });
447
- for (const f of this)
448
- c(f, { [i]: d, [o]: a[f[n]] }), f[s] = p[f[e]] || u;
449
- return d.$tree$each((f) => f[r] = f[o] ? f[o][r] + 1 : 0, -1, s), d;
448
+ for (const l of this)
449
+ c(l, { [i]: d, [s]: a[l[n]] }), l[o] = p[l[e]] || u;
450
+ return d.$tree$each((l) => l[r] = l[s] ? l[s][r] + 1 : 0, -1, o), d;
450
451
  },
451
452
  $tree2tree: function(t = {}, e = null, n = null) {
452
- const { id: r = "id", pid: i = "pid", level: o = "level", root: s = "root", parent: u = "parent", children: h = "children", empty: a = null } = t;
453
- e = e || { [r]: 0, [i]: -1, [o]: 0, [s]: null, [u]: null, [h]: this }, n = n || e;
453
+ const { id: r = "id", pid: i = "pid", level: s = "level", root: o = "root", parent: u = "parent", children: h = "children", empty: a = null } = t;
454
+ e = e || { [r]: 0, [i]: -1, [s]: 0, [o]: null, [u]: null, [h]: this }, n = n || e;
454
455
  for (const p of this)
455
- c(p, { [s]: e, [u]: n }), p[i] = n[r], p[o] = n[o] + 1, p[h] = p[h] && p[h].length ? p[h] : a, p[h]?.$tree2tree(t, e, p);
456
+ c(p, { [o]: e, [u]: n }), p[i] = n[r], p[s] = n[s] + 1, p[h] = p[h] && p[h].length ? p[h] : a, p[h]?.$tree2tree(t, e, p);
456
457
  return e;
457
458
  },
458
459
  $tree$find: function(t, e = !0, n = -1, r = "children") {
459
460
  for (const i of this) {
460
- const o = i.$tree$find(t, e, n, r);
461
- if (o !== null)
462
- return o;
461
+ const s = i.$tree$find(t, e, n, r);
462
+ if (s !== null)
463
+ return s;
463
464
  }
464
465
  return null;
465
466
  },
@@ -469,7 +470,7 @@ c(Array.prototype, {
469
470
  return this;
470
471
  },
471
472
  $tree$map: function(t, e = !0, n = -1, r = "children", i = null) {
472
- return this.map((o) => o.$tree$map(t, e, n, r, i));
473
+ return this.map((s) => s.$tree$map(t, e, n, r, i));
473
474
  }
474
475
  });
475
476
  c(Map, {
@@ -478,10 +479,10 @@ c(Map, {
478
479
  c(Map.prototype, {
479
480
  ...m(["size", "$length"]),
480
481
  ...$(Map.prototype, "entries", "keys", "values"),
481
- ...l(Map.prototype, null, "t", ["set", "$set"], ["delete", "$delete"]),
482
- ...l(Map.prototype, null, "a", "set", "delete"),
483
- ...l(Map.prototype, null, 0, "set", "delete"),
484
- ...l(Map.prototype, null, 1, "set", "delete"),
482
+ ...f(Map.prototype, null, "t", ["set", "$set"], ["delete", "$delete"]),
483
+ ...f(Map.prototype, null, "a", "set", "delete"),
484
+ ...f(Map.prototype, null, 0, "set", "delete"),
485
+ ...f(Map.prototype, null, 1, "set", "delete"),
485
486
  $getOrInsert: function(t, e = null) {
486
487
  return this.has(t) ? this.get(t) : this.$set1(t, e);
487
488
  },
@@ -504,16 +505,28 @@ c(Map.prototype, {
504
505
  return [...this];
505
506
  }
506
507
  });
507
- typeof Map.getOrInsert > "u" && (Map.prototype.getOrInsert = Map.prototype.$getOrInsert, Map.prototype.getOrInsertComputed = Map.prototype.$getOrInsertComputed);
508
+ typeof Map.prototype.getOrInsert > "u" && (Map.prototype.getOrInsert = Map.prototype.$getOrInsert, Map.prototype.getOrInsertComputed = Map.prototype.$getOrInsertComputed);
508
509
  c(Set, {
509
510
  ...g()
510
511
  });
511
512
  c(Set.prototype, {
512
513
  ...m(["size", "$length"]),
513
514
  ...$(Set.prototype, "entries", "keys", "values"),
514
- ...l(Set.prototype, null, "t", ["add", "$add"], ["delete", "$delete"]),
515
- ...l(Set.prototype, null, "a", "add", "delete"),
516
- ...l(Set.prototype, null, 0, "add", "delete"),
515
+ ...f(Set.prototype, null, "t", ["add", "$add"], ["delete", "$delete"]),
516
+ ...f(Set.prototype, null, "a", "add", "delete"),
517
+ ...f(Set.prototype, null, 0, "add", "delete"),
518
+ $union: function(t) {
519
+ return /* @__PURE__ */ new Set([...this, ...t]);
520
+ },
521
+ $intersection: function(t) {
522
+ return new Set([...this].filter((e) => t.has(e)));
523
+ },
524
+ $difference: function(t) {
525
+ return new Set([...this].filter((e) => !t.has(e)));
526
+ },
527
+ $symmetricDifference: function(t) {
528
+ return /* @__PURE__ */ new Set([...[...this].filter((e) => !t.has(e)), ...[...t].filter((e) => !this.has(e))]);
529
+ },
517
530
  toArray: function() {
518
531
  return [...this];
519
532
  },
@@ -521,6 +534,7 @@ c(Set.prototype, {
521
534
  return [...this];
522
535
  }
523
536
  });
537
+ typeof Set.prototype.union > "u" && (Set.prototype.union = Set.prototype.$union, Set.prototype.intersection = Set.prototype.$intersection, Set.prototype.difference = Set.prototype.$difference, Set.prototype.symmetricDifference = Set.prototype.$symmetricDifference);
524
538
  c(Date, {
525
539
  new: function(...t) {
526
540
  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);
@@ -582,9 +596,9 @@ c(Date.prototype, {
582
596
  getMonthDay: function() {
583
597
  return [31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][this.getMonth()] || (this.isLeapYear() ? 29 : 28);
584
598
  },
585
- expr: function({ y: t = 0, m: e = 0, d: n = 0, h: r = 0, i = 0, s: o = 0 }) {
586
- const s = new Date(this.getFullYear() + t, this.getMonth() + e + 1, 0);
587
- return new Date(this.getFullYear() + t, this.getMonth() + e, Math.min(s.getDate(), this.getDate()) + n, this.getHours() + r, this.getMinutes() + i, this.getSeconds() + o);
599
+ expr: function({ y: t = 0, m: e = 0, d: n = 0, h: r = 0, i = 0, s = 0 }) {
600
+ const o = new Date(this.getFullYear() + t, this.getMonth() + e + 1, 0);
601
+ 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);
588
602
  },
589
603
  begin: function(t = 3) {
590
604
  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));
@@ -665,19 +679,19 @@ c(Uint8Array, {
665
679
  },
666
680
  $fromBase64: function(t) {
667
681
  const e = [], n = {}, r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
668
- for (let o = 0; o < r.length; o++)
669
- n[r.charAt(o)] = o;
682
+ for (let s = 0; s < r.length; s++)
683
+ n[r.charAt(s)] = s;
670
684
  const i = t.charAt(t.length - 1) != "=" ? t.length : t.charAt(t.length - 2) != "=" ? t.length - 1 : t.length - 2;
671
- for (let o = 3; o < i; o += 4) {
672
- const s = (n[t.charAt(o - 3)] << 18) + (n[t.charAt(o - 2)] << 12) + (n[t.charAt(o - 1)] << 6) + n[t.charAt(o)];
673
- e.push((s & 16711680) >> 16, (s & 65280) >> 8, s & 255);
685
+ for (let s = 3; s < i; s += 4) {
686
+ const o = (n[t.charAt(s - 3)] << 18) + (n[t.charAt(s - 2)] << 12) + (n[t.charAt(s - 1)] << 6) + n[t.charAt(s)];
687
+ e.push((o & 16711680) >> 16, (o & 65280) >> 8, o & 255);
674
688
  }
675
689
  if (i % 4 == 3) {
676
- const o = (n[t.charAt(i - 3)] << 18) + (n[t.charAt(i - 2)] << 12) + (n[t.charAt(i - 1)] << 6);
677
- e.push((o & 16711680) >> 16, (o & 65280) >> 8);
690
+ const s = (n[t.charAt(i - 3)] << 18) + (n[t.charAt(i - 2)] << 12) + (n[t.charAt(i - 1)] << 6);
691
+ e.push((s & 16711680) >> 16, (s & 65280) >> 8);
678
692
  } else if (i % 4 == 2) {
679
- const o = (n[t.charAt(i - 2)] << 18) + (n[t.charAt(i - 1)] << 12);
680
- e.push((o & 16711680) >> 16);
693
+ const s = (n[t.charAt(i - 2)] << 18) + (n[t.charAt(i - 1)] << 12);
694
+ e.push((s & 16711680) >> 16);
681
695
  }
682
696
  return new Uint8Array(e);
683
697
  }
@@ -723,20 +737,21 @@ c(Uint8Array.prototype, {
723
737
  return new Array(...this);
724
738
  }
725
739
  });
726
- typeof Uint8Array.fromBase64 > "u" && (Uint8Array.fromHex = Uint8Array.$fromHex, Uint8Array.fromBase64 = Uint8Array.$fromBase64, Uint8Array.prototype.setFromHex = Uint8Array.prototype.$setFromHex, Uint8Array.prototype.setFromBase64 = Uint8Array.prototype.$setFromBase64, Uint8Array.prototype.toHex = Uint8Array.prototype.$toHex, Uint8Array.prototype.toBase64 = Uint8Array.prototype.$toBase64);
727
- let F = 0, w = 0, b = 0;
740
+ typeof Uint8Array.fromBase64 > "u" && (Uint8Array.fromHex = Uint8Array.$fromHex, Uint8Array.fromBase64 = Uint8Array.$fromBase64);
741
+ typeof Uint8Array.prototype.setFromHex > "u" && (Uint8Array.prototype.setFromHex = Uint8Array.prototype.$setFromHex, Uint8Array.prototype.setFromBase64 = Uint8Array.prototype.$setFromBase64, Uint8Array.prototype.toHex = Uint8Array.prototype.$toHex, Uint8Array.prototype.toBase64 = Uint8Array.prototype.$toBase64);
742
+ let D = 0, w = 0, A = 0;
728
743
  c(Math, {
729
744
  randstr: function(t = 16, e = 0, n = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", r = "~!@#$%^&*()_+`{}|[]\\:\";'<>,.?/") {
730
745
  if (t < e)
731
746
  throw new Error("randstr: len < slen");
732
747
  const i = [];
733
- for (let o = 0; o < t; o++)
748
+ for (let s = 0; s < t; s++)
734
749
  i.push(n.charAt(Math.random() * n.length | 0));
735
- for (let o = /* @__PURE__ */ new Set(), s = 0, u = 0; u < e; u++) {
750
+ for (let s = /* @__PURE__ */ new Set(), o = 0, u = 0; u < e; u++) {
736
751
  do
737
- s = Math.random() * t | 0;
738
- while (o.has(s));
739
- o.set(s, !0), i[s] = r.charAt(Math.random() * r.length | 0);
752
+ o = Math.random() * t | 0;
753
+ while (s.has(o));
754
+ s.set(o, !0), i[o] = r.charAt(Math.random() * r.length | 0);
740
755
  }
741
756
  return i.join("");
742
757
  },
@@ -744,13 +759,13 @@ c(Math, {
744
759
  return Math.floor(Math.random() * (e - t) + t);
745
760
  },
746
761
  incrid: function() {
747
- return ++F;
762
+ return ++D;
748
763
  },
749
764
  incrstr: function() {
750
765
  return "" + Math.incrid();
751
766
  },
752
767
  uniqid: function(t = Date.now()) {
753
- return t === b ? t * 2048 + ++w % 2048 : (b = t) * 2048 + (w = 0) % 2048;
768
+ return t === A ? t * 2048 + ++w % 2048 : (A = t) * 2048 + (w = 0) % 2048;
754
769
  },
755
770
  uniqstr: function() {
756
771
  return "" + Math.uniqid();
@@ -760,12 +775,48 @@ c(Math, {
760
775
  },
761
776
  useTemplate: function(t) {
762
777
  let e = null;
763
- const n = { setup(i, { slots: o }) {
764
- return e = o.default, () => {
778
+ const n = { setup(i, { slots: s }) {
779
+ return e = s.default, () => {
765
780
  };
766
- }, name: t + "Template" }, r = { setup(i, { attrs: o }) {
767
- return () => e?.(o);
781
+ }, name: t + "Template" }, r = { setup(i, { attrs: s }) {
782
+ return () => e?.(s);
768
783
  }, name: t };
769
784
  return { [n.name]: n, [r.name]: r };
770
785
  }
771
786
  });
787
+ class M extends Map {
788
+ constructor(e) {
789
+ super(), this.capacity = e;
790
+ }
791
+ get(e) {
792
+ if (!super.has(e))
793
+ return null;
794
+ const n = super.get(e);
795
+ return super.delete(e), super.set(e, n), n;
796
+ }
797
+ getOrInsert(e, n) {
798
+ super.has(e) || super.set(e, n);
799
+ const r = super.get(e);
800
+ return super.delete(e), super.set(e, r), r;
801
+ }
802
+ getOrInsertComputed(e, n) {
803
+ super.has(e) || super.set(e, n(e));
804
+ const r = super.get(e);
805
+ return super.delete(e), super.set(e, r), r;
806
+ }
807
+ async getOrInsertComputedAsync(e, n) {
808
+ super.has(e) || super.set(e, await n(e));
809
+ const r = super.get(e);
810
+ return super.delete(e), super.set(e, r), r;
811
+ }
812
+ set(e, n) {
813
+ super.has(e) && super.delete(e), super.set(e, n), super.size > this.capacity && super.delete(super.keys().next().value);
814
+ }
815
+ put(e, n) {
816
+ return this.set(e, n);
817
+ }
818
+ }
819
+ c(M, {
820
+ ...g()
821
+ });
822
+ typeof globalThis.LRU > "u" && (globalThis.LRU = M);
@@ -1 +1 @@
1
- (function(u){typeof define=="function"&&define.amd?define(u):u()})((function(){"use strict";function u(t,e){return Object.defineProperties(t,Object.fromEntries(Object.keys(e).map(n=>[n,{value:e[n],enumerable:!1,configurable:!0,writable:!0}])))}function g(){return{new:function(...t){return new this(...t)}}}function m(...t){const e={};for(const n of t){const[r,i]=Array.isArray(n)?n:[n,"$"+n];e[i]=function(){return this[r]}}return e}function l(t,e,n,...r){const i={},o=(s,h,c)=>(h!==null&&s.splice(h>=0?h:s.length+h+1,0,c),s);for(const s of r){const[h,c]=Array.isArray(s)?s:[s,"$"+s+n.toString().replaceAll("-","_")];if(n==="")i[c]=function(...a){return t[h].apply(this,o(a,e,this))};else if(n==="t")i[c]=function(...a){return t[h].apply(this,o(a,e,this)),this};else if(n==="a")i[c]=function(...a){return t[h].apply(this,o(a,e,this)),a};else if(n>=0)i[c]=function(...a){return t[h].apply(this,o(a,e,this)),a[n]};else if(n<0)i[c]=function(...a){return t[h].apply(this,o(a,e,this)),a[a.length+n]};else throw Error("unreachable")}return i}function $(t,...e){const n={};for(const r of e){const[i,o]=Array.isArray(r)?r:[r,"$"+r];n[o]=function(...s){return[...t[i].apply(this,s)]}}return n}function w(t={array:!1}){return function(e={},...n){const r=(i,o)=>{const s=Object.prototype.toString.call(i),h=Object.prototype.toString.call(o);if(s!==h)return o;if(s==="[object Array]")return t.array?i.concat(...o):o;if(s==="[object Object]"){for(const c in o)i[c]=r(i[c],o[c]);return i}else return o};for(const i of n)e=r(e,i);return e}}const b=w({array:!1}),A=w({array:!0});u(Object,{...g(),isObject:function(t){return Object.prototype.toString.call(t)==="[object Object]"},merge$:function(...t){return b(this,...t)},concat:function(...t){return A(this,...t)}}),u(Object.prototype,{$clone:function(){return JSON.parse(JSON.stringify(this))},$length:function(){return Object.keys(this).length},...l(Object,0,"","entries","keys","values","assign"),...l(JSON,0,"","stringify"),$merge:function(...t){return b(this,...t)},$concat:function(...t){return A(this,...t)},$empty:function(){return Object.keys(this).length==0},$in:function(t){return t in this},$pick:function(...t){const e={};for(const n of t)e[n]=this[n];return e},$omit:function(...t){const e={},n=new Set(t);for(const r in this)n.has(r)||(e[r]=this[r]);return e},$attr:function(...t){if(typeof this!="object")return this;const[e,n,r,i]=t;return t.length==1?this[e]:t.length==2?(this[e]=n,this):typeof r=="boolean"?(e in this===r&&(this[e]=n),this):r=="define"||r===null?Object.defineProperty(this,e,{value:n,enumerable:!1,configurable:!0,writable:!0,...i}):r==="+"?(this[e]=(this[e]??i??0)+n,this):r==="-"?(this[e]=(this[e]??i??0)-n,this):r==="*"?(this[e]=(this[e]??i??0)*n,this):r==="/"?(this[e]=(this[e]??i??0)/n,this):this},$pipe:function(t,...e){return t(this,...e)},$handle:function(t,...e){return t(this,...e),this},$toArray:function(){return Array.isArray(this)?this:[this]},...l(console,-1,"t",["debug","$debug"],["log","$log"],["info","$info"],["warn","$warn"],["error","$error"],["dir","$dir"]),$debugger:function(...t){console.debug(this,...t);debugger;return this},$getParents:function(t=!1,e=-1,n="parent"){const r=t?[this]:[];let i=this[n];for(;i&&e--!=0;)r.push(i),i=i[n];return r},$getChildrens:function(t=!1,e=-1,n="children"){const r=[],i=(o,s,h)=>{if(s&&r.push(o),!(h==0||!o[n]||o[n].length==0))for(const c of o[n])i(c,!0,h-1)};return i(this,t,e),r},$tree$find:function(t,e=!0,n=-1,r="children"){if(e&&t(this))return this;if(n==0||!this[r]||this[r].length==0)return null;for(const i of this[r]){const o=i.$tree$find(t,!0,n-1,r);if(o!==null)return o}return null},$tree$each:function(t,e=!0,n=-1,r="children"){if(e&&t(this),!(n==0||!this[r]||this[r].length==0)){for(const i of this[r])i.$tree$each(t,!0,n-1,r);return this}},$tree$map:function(t,e=!0,n=-1,r="children",i=null){const o=e?t(this):this,s=[];if(n==0||!this[r]||this[r].length==0)return o;for(const h of this[r])s.push(h.$tree$map(t,!0,n-1,r,i));return o[r]=s,o}}),u(Number.prototype,{...l(Math,0,"",["ceil","ceil"],["floor","floor"],["trunc","trunc"],["abs","abs"],["max","max"],["min","min"]),fixed:function(t=0){return+this.toFixed(t)},round:function(t=0){return Math.round(this*10**t)/10**t},add:function(t,...e){return typeof t=="function"?t(this,...e):this+t},sub:function(t,...e){return typeof t=="function"?t(this,...e):this-t},mul:function(t,...e){return typeof t=="function"?t(this,...e):this*t},div:function(t,...e){return typeof t=="function"?t(this,...e):this/t},baseConvert:function(t=64){let e="",n=this,r="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";for(;n>0;)e=r.at(n%t)+e,n=Math.floor(n/t);return e||"0"},unit:function(t,e=0){let n=this,r="";for(const[i,o]of Object.entries(t)){if(r=i,o===0||n<o)break;n=n/o}return e<0?+n.toFixed(0-e)+r:n.toFixed(e)+r},units:function(t,e=!1){let n=this,r=[];for([unit,size]of Object.entries(t))if(size==0||n<size){r.push([n,unit]);break}else r.push([n%size,unit]),n=Math.floor(n/size);return e?r:r.reverse().map(([i,o])=>i+o).join("")},toDate:function(){return Date.new(this)}}),u(BigInt.prototype,{toJSON:function(){return this>=BigInt(Number.MIN_SAFE_INTEGER)&&this<=BigInt(Number.MAX_SAFE_INTEGER)?Number(this):this.toString()}}),u(String.prototype,{...g(),...m(["length","length$"]),$substring:function(t=0,e=this.length){return t=t>=0?t:this.length+t,e=e>=0?e:this.length+e,this.substring(t,e)},$substr:function(t=0,e=this.length){return t=t>=0?t:this.length+t,e=t+e,this.substring(t,e)},$split:function(t=",",e=-1){const n=this?this.split(t):[];return e===-1?n:n.$push(n.splice(e-1).join(t))},$split$number:function(t=","){return this.$split(t).map(e=>+e)},$split$segment:function(t=1){const e=[];for(let n=0;n<this.length;n+=t)e.push(this.substring(n,n+t));return e},sprintf:function(...t){let[e,...n]=this.split(/%[sd]/);for(let r=0;r<n.length;r++)e+=t[r]+n[r];return e},subOf:function(t,e,n=0,r=0){for(let s=0;s<n&&r!=-1;s++,r++)r=this.indexOf(t,r);let i=this.indexOf(t,r),o=this.indexOf(e,i);return i==-1||o==-1?"":(i+=t.length,this.substring(i,o))},lastSubOf:function(t,e,n=0,r=1/0){for(let s=0;s<n&&r!=-1;s++,r--)r=this.lastIndexOf(t,r);let i=this.lastIndexOf(t,r),o=this.indexOf(e,i);return i==-1||o==-1?"":(i+=t.length,this.substring(i,o))},camel2under:function(){return this.substr(0,1)+this.substr(1).replace(/([A-Z])/g,(t,e)=>"_"+e.toLowerCase())},under2camel:function(){return this.replace(/_([a-z])/g,(t,e)=>e.toUpperCase())},camel2pascal:function(){return this.substr(0,1).toUpperCase()+this.substr(1)},pascal2camel:function(){return this.substr(0,1).toLowerCase()+this.substr(1)},under2kebab:function(){return this.replace(/_/g,"-")},kebab2under:function(){return this.replace(/-/g,"_")},baseConvert:function(t=64){let e=0,n="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";for(let r=0;r<this.length;r++)e=e*t+n.indexOf(this.at(r));return e},fixed:function(...t){return+(+this).toFixed(...t)},toDate:function(){return Date.new(this)},toUint8Array:function(){return new TextEncoder().encode(this)},hexencode:function(){return new TextEncoder().encode(this).toHex()},hexdecode:function(){return new TextDecoder().decode(Uint8Array.fromHex(this))},base64encode:function(){return new TextEncoder().encode(this).toBase64()},base64decode:function(){return new TextDecoder().decode(Uint8Array.fromBase64(this))}}),u(Array,{...g(),range:function(...t){let e=[],n=0,r=0,i=1,o=typeof t[t.length-1]=="boolean"?t.pop():!0,s=typeof t[t.length-1]=="function"?t.pop():(h,c,a)=>h;switch(t.length){case 1:[r]=t;break;case 2:[n,r]=t;break;case 3:[n,r,i]=t;break;default:throw new Error("the number of parameters is incorrect!")}if(i==0)throw new Error("step cannot be 0!");for(let h=0,c=0,a=Math.abs(r-n),p=Math.abs(i),d=n<=r?1:-1;c<a;c+=p)e.push(o?s(n+c*d,h++,e):s());return e}}),u(Array.prototype,{...m("length"),...$(Array.prototype,"entries","keys","values"),...l(Array.prototype,null,"","map"),...l(Array.prototype,null,"t",["push","$push"],["pop","$pop"],["shift","$shift"],["unshift","$unshift"],["splice","$splice"]),...l(Array.prototype,null,"a","push","unshift"),...l(Array.prototype,null,0,"push","unshift"),$empty:function(){return this.length==0},first:function(t=null){return this.length?this[0]:t},last:function(t=null){return this.length?this[this.length-1]:t},$find:function(t,e=null){return this.find(t)??e},equals:function(t){return this.length===t.length&&(this===t||this.length===0||this.every((e,n)=>e===t[n]))},unique:function(t=e=>e){const e=new Set;return this.filter(n=>e.has(t(n))?!1:!!e.add(t(n)))},...l(Array.prototype,null,"t",["forEach","each"]),each$async:async function(t){for(let e=0;e<this.length;e++)await t(this[e],e,this);return this},map$async:async function(t){const e=[];for(let n=0;n<this.length;n++)e.push(await t(this[n],n,this));return e},shuffle:function(t=!1){let e=this.length;for(;e;){const n=Math.random()*e--|0;[this[n],this[e]]=[this[e],this[n]]}return this},intersect:function(t){const e=new Set(t);return[...new Set(this)].filter(n=>e.has(n))},union:function(t){return[...new Set([...this,...t])]},diff:function(t){const e=new Set(t);return[...new Set(this)].filter(n=>!e.has(n))},toMap:function(t=(e,n)=>[n,e]){return new Map(this.map(t))},toSet:function(t=e=>e){return new Set(this.map(t))},toUint8Array:function(){return new Uint8Array(this)},toBase64:function(){return this.toUint8Array().toBase64()},toHex:function(){return this.toUint8Array().toHex()},decode:function(){return this.toUint8Array().decode()},assoc:function(t,e,n={}){const r=this.unique$(o=>o[t]),i=r.length==0?{}:typeof n=="function"?n(r):n;return this.each$(o=>o[e]=i[o[t]]??null)},toTree:function(t={}){const{id:e="id",pid:n="pid",level:r="level",root:i="root",parent:o="parent",children:s="children",empty:h=null,hasRoot:c=!0}=t,a=this.reduce((f,y)=>f.$attr(y[e],y),{}),p=this.reduce((f,y)=>(f.$attr(y[n],[],!1).$attr(y[n]).$push(y),f),{}),d=this.length&&c?this.find(f=>f[n]===0):{[e]:0,[n]:-1,[i]:null,[o]:null,[s]:p[0]};u(d,{[i]:d});for(const f of this)u(f,{[i]:d,[o]:a[f[n]]}),f[s]=p[f[e]]||h;return d.$tree$each(f=>f[r]=f[o]?f[o][r]+1:0,-1,s),d},$tree2tree:function(t={},e=null,n=null){const{id:r="id",pid:i="pid",level:o="level",root:s="root",parent:h="parent",children:c="children",empty:a=null}=t;e=e||{[r]:0,[i]:-1,[o]:0,[s]:null,[h]:null,[c]:this},n=n||e;for(const p of this)u(p,{[s]:e,[h]:n}),p[i]=n[r],p[o]=n[o]+1,p[c]=p[c]&&p[c].length?p[c]:a,p[c]?.$tree2tree(t,e,p);return e},$tree$find:function(t,e=!0,n=-1,r="children"){for(const i of this){const o=i.$tree$find(t,e,n,r);if(o!==null)return o}return null},$tree$each:function(t,e=!0,n=-1,r="children"){for(const i of this)i.$tree$each(t,e,n,r);return this},$tree$map:function(t,e=!0,n=-1,r="children",i=null){return this.map(o=>o.$tree$map(t,e,n,r,i))}}),u(Map,{...g()}),u(Map.prototype,{...m(["size","$length"]),...$(Map.prototype,"entries","keys","values"),...l(Map.prototype,null,"t",["set","$set"],["delete","$delete"]),...l(Map.prototype,null,"a","set","delete"),...l(Map.prototype,null,0,"set","delete"),...l(Map.prototype,null,1,"set","delete"),$getOrInsert:function(t,e=null){return this.has(t)?this.get(t):this.$set1(t,e)},$getOrInsertComputed:function(t,e){return this.has(t)?this.get(t):this.$set1(t,e(t))},$get:function(t,e=null){return this.has(t)?this.get(t):this.$set1(t,typeof e=="function"?e(t):e)},$get$async:async function(t,e=null){return this.has(t)?this.get(t):this.$set1(t,typeof e=="function"?await e(t):e)},toObject:function(){return Object.fromEntries(this)},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),typeof Map.getOrInsert>"u"&&(Map.prototype.getOrInsert=Map.prototype.$getOrInsert,Map.prototype.getOrInsertComputed=Map.prototype.$getOrInsertComputed),u(Set,{...g()}),u(Set.prototype,{...m(["size","$length"]),...$(Set.prototype,"entries","keys","values"),...l(Set.prototype,null,"t",["add","$add"],["delete","$delete"]),...l(Set.prototype,null,"a","add","delete"),...l(Set.prototype,null,0,"add","delete"),toArray:function(){return[...this]},toJSON:function(){return[...this]}}),u(Date,{new:function(...t){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)},format:function(t="y-m-d h:i:s"){return new Date().format(t)},unix:function(){return this.now()/1e3|0},fromUnix:function(t){return new Date((t??0)*1e3)},expr:function(t={}){return new Date().expr(t)},toDayRange:function(){const t=new Date,e=t.getFullYear(),n=t.getMonth(),r=t.getDate(),i=new Date(e,n,r).getTime()/1e3|0;return[i,i+86400-1]},toWeekRange:function(){let t=new Date;for(;t.getDay()!=1;)t=new Date(t.getTime()-86400);const e=t.getFullYear(),n=t.getMonth(),r=t.getDate(),i=new Date(e,n,r).getTime()/1e3|0;return[i,i+86400*7-1]},toMonthRange:function(){const t=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;return[r,i]},toYearRange:function(){const e=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;return[n,r]}}),u(Date.prototype,{format:function(t="y-m-d h:i:s"){if(this.getTime()===0)return"-";const e={y:this.getFullYear(),m:this.getMonth()+1,d:this.getDate(),h:this.getHours(),i:this.getMinutes(),s:this.getSeconds(),l:this.getMilliseconds(),e:this.getMonthDay()};return t.replace(/([ymdhisle])/ig,(n,r)=>r>="A"&&r<="Z"?e[r.toLowerCase()]:e[r].toString().padStart(r==="l"?3:2,"0"))},unix:function(){return this.getTime()/1e3|0},isLeapYear:function(){return this.getFullYear()%4===0&&this.getFullYear()%400!==0},getMonthDay:function(){return[31,0,31,30,31,30,31,31,30,31,30,31][this.getMonth()]||(this.isLeapYear()?29:28)},expr:function({y:t=0,m:e=0,d:n=0,h:r=0,i=0,s:o=0}){const s=new Date(this.getFullYear()+t,this.getMonth()+e+1,0);return new Date(this.getFullYear()+t,this.getMonth()+e,Math.min(s.getDate(),this.getDate())+n,this.getHours()+r,this.getMinutes()+i,this.getSeconds()+o)},begin:function(t=3){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))},end:function(t=3){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))},week:function(t,e=1){let n=new Date(this.getTime());for(;n.getDay()!==t;)n=new Date(n.getTime()+864e5*e);return n},toJSON:function(){return this.getTime()}}),u(RegExp,{...g()}),u(RegExp.prototype,{toJSON:function(){return this.toString()}}),u(Promise,{...g(),channel:function(){let t=null,e=null;return[new this((r,i)=>{t=r,e=i}),t,e]},$withResolvers:function(){let t=null,e=null;return{promise:new this((r,i)=>{t=r,e=i}),resolve:t,reject:e}}}),u(Promise.prototype,{tryCatch:function(){return new Promise(t=>this.then(e=>t([e,null])).catch(e=>t([null,e])))}}),typeof Promise.withResolvers>"u"&&(Promise.withResolvers=Promise.$withResolvers),u(JSON,{$parse:function(t,e=null){try{if(typeof t!="string")throw new Error("not string");return JSON.parse(t)}catch{return e}}}),typeof Iterator<"u"&&u(Iterator.prototype,{toArray:function(){return[...this]}}),u(ArrayBuffer.prototype,{toUint8Array:function(){return new Uint8Array(this)}}),u(Uint8Array,{...g(),fromString:function(t){return new TextEncoder().encode(t)},$fromHex:function(t){const e=[];for(let n=0;n<t.length;n+=2)e.push(Number.parseInt(t.substring(n,n+2),16));return new Uint8Array(e)},$fromBase64:function(t){const e=[],n={},r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let o=0;o<r.length;o++)n[r.charAt(o)]=o;const i=t.charAt(t.length-1)!="="?t.length:t.charAt(t.length-2)!="="?t.length-1:t.length-2;for(let o=3;o<i;o+=4){const s=(n[t.charAt(o-3)]<<18)+(n[t.charAt(o-2)]<<12)+(n[t.charAt(o-1)]<<6)+n[t.charAt(o)];e.push((s&16711680)>>16,(s&65280)>>8,s&255)}if(i%4==3){const o=(n[t.charAt(i-3)]<<18)+(n[t.charAt(i-2)]<<12)+(n[t.charAt(i-1)]<<6);e.push((o&16711680)>>16,(o&65280)>>8)}else if(i%4==2){const o=(n[t.charAt(i-2)]<<18)+(n[t.charAt(i-1)]<<12);e.push((o&16711680)>>16)}return new Uint8Array(e)}}),u(Uint8Array.prototype,{setFromString(t,e=0){const n=Uint8Array.fromString(t);return this.set(n,e),{read:n.length,written:n.length}},$setFromHex(t,e=0){const n=Uint8Array.fromHex(t);return this.set(n,e),{read:n.length,written:n.length}},$setFromBase64(t,e=0){const n=Uint8Array.fromBase64(t);return this.set(n,e),{read:n.length,written:n.length}},toString:function(){return new TextDecoder().decode(this)},$toHex:function(){let t="";for(let e=0;e<this.length;e++)t+=(this[e]<16?"0":"")+this[e].toString(16);return t},$toBase64:function(){let t="",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let n=2;n<this.length;n+=3){const r=(this[n-2]<<16)+(this[n-1]<<8)+this[n];t+=e.charAt((r&16515072)>>18)+e.charAt((r&258048)>>12)+e.charAt((r&4032)>>6)+e.charAt(r&63)}if(this.length%3==2){const n=(this[this.length-2]<<16)+(this[this.length-1]<<8);t+=e.charAt((n&16515072)>>18)+e.charAt((n&258048)>>12)+e.charAt((n&4032)>>6)+"="}else if(this.length%3==1){const n=this[this.length-1]<<16;t+=e.charAt((n&16515072)>>18)+e.charAt((n&258048)>>12)+"=="}return t},toArray:function(){return new Array(...this)}}),typeof Uint8Array.fromBase64>"u"&&(Uint8Array.fromHex=Uint8Array.$fromHex,Uint8Array.fromBase64=Uint8Array.$fromBase64,Uint8Array.prototype.setFromHex=Uint8Array.prototype.$setFromHex,Uint8Array.prototype.setFromBase64=Uint8Array.prototype.$setFromBase64,Uint8Array.prototype.toHex=Uint8Array.prototype.$toHex,Uint8Array.prototype.toBase64=Uint8Array.prototype.$toBase64);let F=0,x=0,M=0;u(Math,{randstr:function(t=16,e=0,n="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",r="~!@#$%^&*()_+`{}|[]\\:\";'<>,.?/"){if(t<e)throw new Error("randstr: len < slen");const i=[];for(let o=0;o<t;o++)i.push(n.charAt(Math.random()*n.length|0));for(let o=new Set,s=0,h=0;h<e;h++){do s=Math.random()*t|0;while(o.has(s));o.set(s,!0),i[s]=r.charAt(Math.random()*r.length|0)}return i.join("")},randint:function(t=0,e=Number.MAX_SAFE_INTEGER){return Math.floor(Math.random()*(e-t)+t)},incrid:function(){return++F},incrstr:function(){return""+Math.incrid()},uniqid:function(t=Date.now()){return t===M?t*2048+ ++x%2048:(M=t)*2048+(x=0)%2048},uniqstr:function(){return""+Math.uniqid()},sleep:function(t){return new Promise(e=>setTimeout(e,t))},useTemplate:function(t){let e=null;const n={setup(i,{slots:o}){return e=o.default,()=>{}},name:t+"Template"},r={setup(i,{attrs:o}){return()=>e?.(o)},name:t};return{[n.name]:n,[r.name]:r}}})}));
1
+ (function(u){typeof define=="function"&&define.amd?define(u):u()})((function(){"use strict";function u(t,e){return Object.defineProperties(t,Object.fromEntries(Object.keys(e).map(n=>[n,{value:e[n],enumerable:!1,configurable:!0,writable:!0}])))}function g(){return{new:function(...t){return new this(...t)}}}function m(...t){const e={};for(const n of t){const[r,i]=Array.isArray(n)?n:[n,"$"+n];e[i]=function(){return this[r]}}return e}function a(t,e,n,...r){const i={},s=(o,h,c)=>(h!==null&&o.splice(h>=0?h:o.length+h+1,0,c),o);for(const o of r){const[h,c]=Array.isArray(o)?o:[o,"$"+o+n.toString().replaceAll("-","_")];if(n==="")i[c]=function(...f){return t[h].apply(this,s(f,e,this))};else if(n==="t")i[c]=function(...f){return t[h].apply(this,s(f,e,this)),this};else if(n==="a")i[c]=function(...f){return t[h].apply(this,s(f,e,this)),f};else if(n>=0)i[c]=function(...f){return t[h].apply(this,s(f,e,this)),f[n]};else if(n<0)i[c]=function(...f){return t[h].apply(this,s(f,e,this)),f[f.length+n]};else throw Error("unreachable")}return i}function $(t,...e){const n={};for(const r of e){const[i,s]=Array.isArray(r)?r:[r,"$"+r];n[s]=function(...o){return[...t[i].apply(this,o)]}}return n}function w(t={array:!1}){return function(e={},...n){const r=(i,s)=>{const o=Object.prototype.toString.call(i),h=Object.prototype.toString.call(s);if(o!==h)return s;if(o==="[object Array]")return t.array?i.concat(...s):s;if(o==="[object Object]"){for(const c in s)i[c]=r(i[c],s[c]);return i}else return s};for(const i of n)e=r(e,i);return e}}const A=w({array:!1}),b=w({array:!0});u(Object,{...g(),isObject:function(t){return Object.prototype.toString.call(t)==="[object Object]"},merge$:function(...t){return A(this,...t)},concat:function(...t){return b(this,...t)}}),u(Object.prototype,{$clone:function(){return JSON.parse(JSON.stringify(this))},$length:function(){return Object.keys(this).length},...a(Object,0,"","entries","keys","values","assign"),...a(JSON,0,"","stringify"),$merge:function(...t){return A(this,...t)},$concat:function(...t){return b(this,...t)},$empty:function(){return Object.keys(this).length==0},$in:function(t){return t in this},$pick:function(...t){const e={};for(const n of t)e[n]=this[n];return e},$omit:function(...t){const e={},n=new Set(t);for(const r in this)n.has(r)||(e[r]=this[r]);return e},$attr:function(...t){if(typeof this!="object")return this;const[e,n,r,i]=t;return t.length==1?this[e]:t.length==2?(this[e]=n,this):typeof r=="boolean"?(e in this===r&&(this[e]=n),this):r=="define"||r===null?Object.defineProperty(this,e,{value:n,enumerable:!1,configurable:!0,writable:!0,...i}):r==="+"?(this[e]=(this[e]??i??0)+n,this):r==="-"?(this[e]=(this[e]??i??0)-n,this):r==="*"?(this[e]=(this[e]??i??0)*n,this):r==="/"?(this[e]=(this[e]??i??0)/n,this):this},$pipe:function(t,...e){return t(this,...e)},$tee:function(t,...e){return t(this,...e),this},$toArray:function(){return Array.isArray(this)?this:[this]},...a(console,-1,"t",["debug","$debug"],["log","$log"],["info","$info"],["warn","$warn"],["error","$error"],["dir","$dir"]),$debugger:function(...t){console.debug(this,...t);debugger;return this},$getParents:function(t=!1,e=-1,n="parent"){const r=t?[this]:[];let i=this[n];for(;i&&e--!=0;)r.push(i),i=i[n];return r},$getChildrens:function(t=!1,e=-1,n="children"){const r=[],i=(s,o,h)=>{if(o&&r.push(s),!(h==0||!s[n]||s[n].length==0))for(const c of s[n])i(c,!0,h-1)};return i(this,t,e),r},$tree$find:function(t,e=!0,n=-1,r="children"){if(e&&t(this))return this;if(n==0||!this[r]||this[r].length==0)return null;for(const i of this[r]){const s=i.$tree$find(t,!0,n-1,r);if(s!==null)return s}return null},$tree$each:function(t,e=!0,n=-1,r="children"){if(e&&t(this),!(n==0||!this[r]||this[r].length==0)){for(const i of this[r])i.$tree$each(t,!0,n-1,r);return this}},$tree$map:function(t,e=!0,n=-1,r="children",i=null){const s=e?t(this):this,o=[];if(n==0||!this[r]||this[r].length==0)return s;for(const h of this[r])o.push(h.$tree$map(t,!0,n-1,r,i));return s[r]=o,s}}),u(Number.prototype,{...a(Math,0,"",["ceil","ceil"],["floor","floor"],["trunc","trunc"],["abs","abs"],["max","max"],["min","min"]),fixed:function(t=0){return+this.toFixed(t)},round:function(t=0){return Math.round(this*10**t)/10**t},add:function(t,...e){return typeof t=="function"?t(this,...e):this+t},sub:function(t,...e){return typeof t=="function"?t(this,...e):this-t},mul:function(t,...e){return typeof t=="function"?t(this,...e):this*t},div:function(t,...e){return typeof t=="function"?t(this,...e):this/t},baseConvert:function(t=64){let e="",n=this,r="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";for(;n>0;)e=r.at(n%t)+e,n=Math.floor(n/t);return e||"0"},unit:function(t,e=0){let n=this,r="";for(const[i,s]of Object.entries(t)){if(r=i,s===0||n<s)break;n=n/s}return e<0?+n.toFixed(0-e)+r:n.toFixed(e)+r},units:function(t,e=!1){let n=this,r=[];for([unit,size]of Object.entries(t))if(size==0||n<size){r.push([n,unit]);break}else r.push([n%size,unit]),n=Math.floor(n/size);return e?r:r.reverse().map(([i,s])=>i+s).join("")},toDate:function(){return Date.new(this)}}),u(BigInt.prototype,{toJSON:function(){return this>=BigInt(Number.MIN_SAFE_INTEGER)&&this<=BigInt(Number.MAX_SAFE_INTEGER)?Number(this):this.toString()}}),u(String.prototype,{...g(),...m(["length","length$"]),$substring:function(t=0,e=this.length){return t=t>=0?t:this.length+t,e=e>=0?e:this.length+e,this.substring(t,e)},$substr:function(t=0,e=this.length){return t=t>=0?t:this.length+t,e=t+e,this.substring(t,e)},$split:function(t=",",e=-1){const n=this?this.split(t):[];return e===-1?n:n.$push(n.splice(e-1).join(t))},$split$number:function(t=","){return this.$split(t).map(e=>+e)},$split$segment:function(t=1){const e=[];for(let n=0;n<this.length;n+=t)e.push(this.substring(n,n+t));return e},sprintf:function(...t){let[e,...n]=this.split(/%[sd]/);for(let r=0;r<n.length;r++)e+=t[r]+n[r];return e},subOf:function(t,e,n=0,r=0){for(let o=0;o<n&&r!=-1;o++,r++)r=this.indexOf(t,r);let i=this.indexOf(t,r),s=this.indexOf(e,i);return i==-1||s==-1?"":(i+=t.length,this.substring(i,s))},lastSubOf:function(t,e,n=0,r=1/0){for(let o=0;o<n&&r!=-1;o++,r--)r=this.lastIndexOf(t,r);let i=this.lastIndexOf(t,r),s=this.indexOf(e,i);return i==-1||s==-1?"":(i+=t.length,this.substring(i,s))},camel2under:function(){return this.substr(0,1)+this.substr(1).replace(/([A-Z])/g,(t,e)=>"_"+e.toLowerCase())},under2camel:function(){return this.replace(/_([a-z])/g,(t,e)=>e.toUpperCase())},camel2pascal:function(){return this.substr(0,1).toUpperCase()+this.substr(1)},pascal2camel:function(){return this.substr(0,1).toLowerCase()+this.substr(1)},under2kebab:function(){return this.replace(/_/g,"-")},kebab2under:function(){return this.replace(/-/g,"_")},baseConvert:function(t=64){let e=0,n="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";for(let r=0;r<this.length;r++)e=e*t+n.indexOf(this.at(r));return e},fixed:function(...t){return+(+this).toFixed(...t)},toDate:function(){return Date.new(this)},toUint8Array:function(){return new TextEncoder().encode(this)},hexencode:function(){return new TextEncoder().encode(this).toHex()},hexdecode:function(){return new TextDecoder().decode(Uint8Array.fromHex(this))},base64encode:function(){return new TextEncoder().encode(this).toBase64()},base64decode:function(){return new TextDecoder().decode(Uint8Array.fromBase64(this))}}),u(Array,{...g(),range:function(...t){let e=[],n=0,r=0,i=1,s=typeof t[t.length-1]=="boolean"?t.pop():!0,o=typeof t[t.length-1]=="function"?t.pop():(h,c,f)=>h;switch(t.length){case 1:[r]=t;break;case 2:[n,r]=t;break;case 3:[n,r,i]=t;break;default:throw new Error("the number of parameters is incorrect!")}if(i==0)throw new Error("step cannot be 0!");for(let h=0,c=0,f=Math.abs(r-n),p=Math.abs(i),d=n<=r?1:-1;c<f;c+=p)e.push(s?o(n+c*d,h++,e):o());return e}}),u(Array.prototype,{...m("length"),...$(Array.prototype,"entries","keys","values"),...a(Array.prototype,null,"","map"),...a(Array.prototype,null,"t",["push","$push"],["pop","$pop"],["shift","$shift"],["unshift","$unshift"],["splice","$splice"]),...a(Array.prototype,null,"a","push","unshift"),...a(Array.prototype,null,0,"push","unshift"),$empty:function(){return this.length==0},first:function(t=null){return this.length?this[0]:t},last:function(t=null){return this.length?this[this.length-1]:t},$find:function(t,e=null){return this.find(t)??e},equals:function(t){return this.length===t.length&&(this===t||this.length===0||this.every((e,n)=>e===t[n]))},unique:function(t=e=>e){const e=new Set;return this.filter(n=>e.has(t(n))?!1:!!e.add(t(n)))},...a(Array.prototype,null,"t",["forEach","each"]),each$async:async function(t){for(let e=0;e<this.length;e++)await t(this[e],e,this);return this},map$async:async function(t){const e=[];for(let n=0;n<this.length;n++)e.push(await t(this[n],n,this));return e},shuffle:function(t=!1){let e=this.length;for(;e;){const n=Math.random()*e--|0;[this[n],this[e]]=[this[e],this[n]]}return this},union:function(t){return Set.new(this).union(Set.new(t)).toArray()},intersection:function(t){return Set.new(this).intersection(Set.new(t)).toArray()},difference:function(t){return Set.new(this).difference(Set.new(t)).toArray()},symmetricDifference:function(t){return Set.new(this).symmetricDifference(Set.new(t)).toArray()},toMap:function(t=(e,n)=>[n,e]){return new Map(this.map(t))},toSet:function(t=e=>e){return new Set(this.map(t))},toUint8Array:function(){return new Uint8Array(this)},toBase64:function(){return this.toUint8Array().toBase64()},toHex:function(){return this.toUint8Array().toHex()},decode:function(){return this.toUint8Array().decode()},assoc:function(t,e,n={}){const r=this.unique$(s=>s[t]),i=r.length==0?{}:typeof n=="function"?n(r):n;return this.each$(s=>s[e]=i[s[t]]??null)},toTree:function(t={}){const{id:e="id",pid:n="pid",level:r="level",root:i="root",parent:s="parent",children:o="children",empty:h=null,hasRoot:c=!0}=t,f=this.reduce((l,y)=>l.$attr(y[e],y),{}),p=this.reduce((l,y)=>(l.$attr(y[n],[],!1).$attr(y[n]).$push(y),l),{}),d=this.length&&c?this.find(l=>l[n]===0):{[e]:0,[n]:-1,[i]:null,[s]:null,[o]:p[0]};u(d,{[i]:d});for(const l of this)u(l,{[i]:d,[s]:f[l[n]]}),l[o]=p[l[e]]||h;return d.$tree$each(l=>l[r]=l[s]?l[s][r]+1:0,-1,o),d},$tree2tree:function(t={},e=null,n=null){const{id:r="id",pid:i="pid",level:s="level",root:o="root",parent:h="parent",children:c="children",empty:f=null}=t;e=e||{[r]:0,[i]:-1,[s]:0,[o]:null,[h]:null,[c]:this},n=n||e;for(const p of this)u(p,{[o]:e,[h]:n}),p[i]=n[r],p[s]=n[s]+1,p[c]=p[c]&&p[c].length?p[c]:f,p[c]?.$tree2tree(t,e,p);return e},$tree$find:function(t,e=!0,n=-1,r="children"){for(const i of this){const s=i.$tree$find(t,e,n,r);if(s!==null)return s}return null},$tree$each:function(t,e=!0,n=-1,r="children"){for(const i of this)i.$tree$each(t,e,n,r);return this},$tree$map:function(t,e=!0,n=-1,r="children",i=null){return this.map(s=>s.$tree$map(t,e,n,r,i))}}),u(Map,{...g()}),u(Map.prototype,{...m(["size","$length"]),...$(Map.prototype,"entries","keys","values"),...a(Map.prototype,null,"t",["set","$set"],["delete","$delete"]),...a(Map.prototype,null,"a","set","delete"),...a(Map.prototype,null,0,"set","delete"),...a(Map.prototype,null,1,"set","delete"),$getOrInsert:function(t,e=null){return this.has(t)?this.get(t):this.$set1(t,e)},$getOrInsertComputed:function(t,e){return this.has(t)?this.get(t):this.$set1(t,e(t))},$get:function(t,e=null){return this.has(t)?this.get(t):this.$set1(t,typeof e=="function"?e(t):e)},$get$async:async function(t,e=null){return this.has(t)?this.get(t):this.$set1(t,typeof e=="function"?await e(t):e)},toObject:function(){return Object.fromEntries(this)},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),typeof Map.prototype.getOrInsert>"u"&&(Map.prototype.getOrInsert=Map.prototype.$getOrInsert,Map.prototype.getOrInsertComputed=Map.prototype.$getOrInsertComputed),u(Set,{...g()}),u(Set.prototype,{...m(["size","$length"]),...$(Set.prototype,"entries","keys","values"),...a(Set.prototype,null,"t",["add","$add"],["delete","$delete"]),...a(Set.prototype,null,"a","add","delete"),...a(Set.prototype,null,0,"add","delete"),$union:function(t){return new Set([...this,...t])},$intersection:function(t){return new Set([...this].filter(e=>t.has(e)))},$difference:function(t){return new Set([...this].filter(e=>!t.has(e)))},$symmetricDifference:function(t){return new Set([...[...this].filter(e=>!t.has(e)),...[...t].filter(e=>!this.has(e))])},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),typeof Set.prototype.union>"u"&&(Set.prototype.union=Set.prototype.$union,Set.prototype.intersection=Set.prototype.$intersection,Set.prototype.difference=Set.prototype.$difference,Set.prototype.symmetricDifference=Set.prototype.$symmetricDifference),u(Date,{new:function(...t){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)},format:function(t="y-m-d h:i:s"){return new Date().format(t)},unix:function(){return this.now()/1e3|0},fromUnix:function(t){return new Date((t??0)*1e3)},expr:function(t={}){return new Date().expr(t)},toDayRange:function(){const t=new Date,e=t.getFullYear(),n=t.getMonth(),r=t.getDate(),i=new Date(e,n,r).getTime()/1e3|0;return[i,i+86400-1]},toWeekRange:function(){let t=new Date;for(;t.getDay()!=1;)t=new Date(t.getTime()-86400);const e=t.getFullYear(),n=t.getMonth(),r=t.getDate(),i=new Date(e,n,r).getTime()/1e3|0;return[i,i+86400*7-1]},toMonthRange:function(){const t=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;return[r,i]},toYearRange:function(){const e=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;return[n,r]}}),u(Date.prototype,{format:function(t="y-m-d h:i:s"){if(this.getTime()===0)return"-";const e={y:this.getFullYear(),m:this.getMonth()+1,d:this.getDate(),h:this.getHours(),i:this.getMinutes(),s:this.getSeconds(),l:this.getMilliseconds(),e:this.getMonthDay()};return t.replace(/([ymdhisle])/ig,(n,r)=>r>="A"&&r<="Z"?e[r.toLowerCase()]:e[r].toString().padStart(r==="l"?3:2,"0"))},unix:function(){return this.getTime()/1e3|0},isLeapYear:function(){return this.getFullYear()%4===0&&this.getFullYear()%400!==0},getMonthDay:function(){return[31,0,31,30,31,30,31,31,30,31,30,31][this.getMonth()]||(this.isLeapYear()?29:28)},expr:function({y:t=0,m:e=0,d:n=0,h:r=0,i=0,s=0}){const o=new Date(this.getFullYear()+t,this.getMonth()+e+1,0);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)},begin:function(t=3){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))},end:function(t=3){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))},week:function(t,e=1){let n=new Date(this.getTime());for(;n.getDay()!==t;)n=new Date(n.getTime()+864e5*e);return n},toJSON:function(){return this.getTime()}}),u(RegExp,{...g()}),u(RegExp.prototype,{toJSON:function(){return this.toString()}}),u(Promise,{...g(),channel:function(){let t=null,e=null;return[new this((r,i)=>{t=r,e=i}),t,e]},$withResolvers:function(){let t=null,e=null;return{promise:new this((r,i)=>{t=r,e=i}),resolve:t,reject:e}}}),u(Promise.prototype,{tryCatch:function(){return new Promise(t=>this.then(e=>t([e,null])).catch(e=>t([null,e])))}}),typeof Promise.withResolvers>"u"&&(Promise.withResolvers=Promise.$withResolvers),u(JSON,{$parse:function(t,e=null){try{if(typeof t!="string")throw new Error("not string");return JSON.parse(t)}catch{return e}}}),typeof Iterator<"u"&&u(Iterator.prototype,{toArray:function(){return[...this]}}),u(ArrayBuffer.prototype,{toUint8Array:function(){return new Uint8Array(this)}}),u(Uint8Array,{...g(),fromString:function(t){return new TextEncoder().encode(t)},$fromHex:function(t){const e=[];for(let n=0;n<t.length;n+=2)e.push(Number.parseInt(t.substring(n,n+2),16));return new Uint8Array(e)},$fromBase64:function(t){const e=[],n={},r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let s=0;s<r.length;s++)n[r.charAt(s)]=s;const i=t.charAt(t.length-1)!="="?t.length:t.charAt(t.length-2)!="="?t.length-1:t.length-2;for(let s=3;s<i;s+=4){const o=(n[t.charAt(s-3)]<<18)+(n[t.charAt(s-2)]<<12)+(n[t.charAt(s-1)]<<6)+n[t.charAt(s)];e.push((o&16711680)>>16,(o&65280)>>8,o&255)}if(i%4==3){const s=(n[t.charAt(i-3)]<<18)+(n[t.charAt(i-2)]<<12)+(n[t.charAt(i-1)]<<6);e.push((s&16711680)>>16,(s&65280)>>8)}else if(i%4==2){const s=(n[t.charAt(i-2)]<<18)+(n[t.charAt(i-1)]<<12);e.push((s&16711680)>>16)}return new Uint8Array(e)}}),u(Uint8Array.prototype,{setFromString(t,e=0){const n=Uint8Array.fromString(t);return this.set(n,e),{read:n.length,written:n.length}},$setFromHex(t,e=0){const n=Uint8Array.fromHex(t);return this.set(n,e),{read:n.length,written:n.length}},$setFromBase64(t,e=0){const n=Uint8Array.fromBase64(t);return this.set(n,e),{read:n.length,written:n.length}},toString:function(){return new TextDecoder().decode(this)},$toHex:function(){let t="";for(let e=0;e<this.length;e++)t+=(this[e]<16?"0":"")+this[e].toString(16);return t},$toBase64:function(){let t="",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let n=2;n<this.length;n+=3){const r=(this[n-2]<<16)+(this[n-1]<<8)+this[n];t+=e.charAt((r&16515072)>>18)+e.charAt((r&258048)>>12)+e.charAt((r&4032)>>6)+e.charAt(r&63)}if(this.length%3==2){const n=(this[this.length-2]<<16)+(this[this.length-1]<<8);t+=e.charAt((n&16515072)>>18)+e.charAt((n&258048)>>12)+e.charAt((n&4032)>>6)+"="}else if(this.length%3==1){const n=this[this.length-1]<<16;t+=e.charAt((n&16515072)>>18)+e.charAt((n&258048)>>12)+"=="}return t},toArray:function(){return new Array(...this)}}),typeof Uint8Array.fromBase64>"u"&&(Uint8Array.fromHex=Uint8Array.$fromHex,Uint8Array.fromBase64=Uint8Array.$fromBase64),typeof Uint8Array.prototype.setFromHex>"u"&&(Uint8Array.prototype.setFromHex=Uint8Array.prototype.$setFromHex,Uint8Array.prototype.setFromBase64=Uint8Array.prototype.$setFromBase64,Uint8Array.prototype.toHex=Uint8Array.prototype.$toHex,Uint8Array.prototype.toBase64=Uint8Array.prototype.$toBase64);let D=0,x=0,S=0;u(Math,{randstr:function(t=16,e=0,n="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",r="~!@#$%^&*()_+`{}|[]\\:\";'<>,.?/"){if(t<e)throw new Error("randstr: len < slen");const i=[];for(let s=0;s<t;s++)i.push(n.charAt(Math.random()*n.length|0));for(let s=new Set,o=0,h=0;h<e;h++){do o=Math.random()*t|0;while(s.has(o));s.set(o,!0),i[o]=r.charAt(Math.random()*r.length|0)}return i.join("")},randint:function(t=0,e=Number.MAX_SAFE_INTEGER){return Math.floor(Math.random()*(e-t)+t)},incrid:function(){return++D},incrstr:function(){return""+Math.incrid()},uniqid:function(t=Date.now()){return t===S?t*2048+ ++x%2048:(S=t)*2048+(x=0)%2048},uniqstr:function(){return""+Math.uniqid()},sleep:function(t){return new Promise(e=>setTimeout(e,t))},useTemplate:function(t){let e=null;const n={setup(i,{slots:s}){return e=s.default,()=>{}},name:t+"Template"},r={setup(i,{attrs:s}){return()=>e?.(s)},name:t};return{[n.name]:n,[r.name]:r}}});class M extends Map{constructor(e){super(),this.capacity=e}get(e){if(!super.has(e))return null;const n=super.get(e);return super.delete(e),super.set(e,n),n}getOrInsert(e,n){super.has(e)||super.set(e,n);const r=super.get(e);return super.delete(e),super.set(e,r),r}getOrInsertComputed(e,n){super.has(e)||super.set(e,n(e));const r=super.get(e);return super.delete(e),super.set(e,r),r}async getOrInsertComputedAsync(e,n){super.has(e)||super.set(e,await n(e));const r=super.get(e);return super.delete(e),super.set(e,r),r}set(e,n){super.has(e)&&super.delete(e),super.set(e,n),super.size>this.capacity&&super.delete(super.keys().next().value)}put(e,n){return this.set(e,n)}}u(M,{...g()}),typeof globalThis.LRU>"u"&&(globalThis.LRU=M)}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esexts",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "esexts",
5
5
  "author": "dotcoo <dotcoo@163.com> (http://blog.dotcoo.com)",
6
6
  "homepage": "https://github.com/dotcoo/esexts#readme",