jc-structure 0.2.14 → 0.2.16
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/jc-structure.js +351 -188
- package/dist/jc-structure.umd.cjs +8 -2
- package/index.d.ts +99 -0
- package/package.json +3 -5
- package/types/global.d.ts +18 -0
package/dist/jc-structure.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class X {
|
|
2
2
|
items = [];
|
|
3
3
|
head = 0;
|
|
4
4
|
tail = 0;
|
|
@@ -28,7 +28,7 @@ class V {
|
|
|
28
28
|
return this.isEmpty() ? "Queue: (0) []" : `Queue: (${this.size()}) [${this.front()} ...]`;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
class
|
|
31
|
+
class Q {
|
|
32
32
|
items = {};
|
|
33
33
|
count = 0;
|
|
34
34
|
lowestCount = 0;
|
|
@@ -108,7 +108,7 @@ class O {
|
|
|
108
108
|
return this._arr[this._arr.length - 1];
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
class
|
|
111
|
+
class j {
|
|
112
112
|
items = {};
|
|
113
113
|
count = 0;
|
|
114
114
|
constructor() {
|
|
@@ -159,7 +159,7 @@ class G {
|
|
|
159
159
|
return this.isEmpty() ? "Stack: (0) []" : `Stack: (${this.size()}) [ ${this.peek()} ...]`;
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
class
|
|
162
|
+
class W {
|
|
163
163
|
stack = [];
|
|
164
164
|
minStack = [];
|
|
165
165
|
push(t) {
|
|
@@ -188,13 +188,13 @@ class B {
|
|
|
188
188
|
return this.isEmpty() ? "Stack: (0) []" : `Stack: (${this.size()}) [ ${this.peek()} ...]`;
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
-
function
|
|
191
|
+
function D(o, t) {
|
|
192
192
|
return o === t ? 0 : o < t ? -1 : 1;
|
|
193
193
|
}
|
|
194
194
|
class E {
|
|
195
195
|
heap = [];
|
|
196
196
|
compareFn;
|
|
197
|
-
constructor(t =
|
|
197
|
+
constructor(t = D) {
|
|
198
198
|
this.compareFn = t;
|
|
199
199
|
}
|
|
200
200
|
static getLeftIndex(t) {
|
|
@@ -225,7 +225,7 @@ class E {
|
|
|
225
225
|
return this.heap.toString();
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
class
|
|
228
|
+
class H extends E {
|
|
229
229
|
insert(t) {
|
|
230
230
|
return t ? !1 : (this.heap.push(t), this.siftUp(this.heap.length - 1), !0);
|
|
231
231
|
}
|
|
@@ -245,15 +245,15 @@ class q extends E {
|
|
|
245
245
|
E.swap(this.heap, e, t), t = e, e = E.getParentIndex(t);
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
|
-
class
|
|
249
|
-
constructor(t = (e, s) =>
|
|
248
|
+
class J extends H {
|
|
249
|
+
constructor(t = (e, s) => D(s, e)) {
|
|
250
250
|
super(t);
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
|
-
function
|
|
253
|
+
function V(o) {
|
|
254
254
|
return { value: o };
|
|
255
255
|
}
|
|
256
|
-
class
|
|
256
|
+
class Y {
|
|
257
257
|
capacity;
|
|
258
258
|
length = 0;
|
|
259
259
|
head = null;
|
|
@@ -283,15 +283,15 @@ class j {
|
|
|
283
283
|
}
|
|
284
284
|
update(t, e) {
|
|
285
285
|
let s = this.lookup.get(t);
|
|
286
|
-
s ? (this.detach(s), this.prepend(s), s.value = e) : (s =
|
|
286
|
+
s ? (this.detach(s), this.prepend(s), s.value = e) : (s = V(e), this.length++, this.prepend(s), this.trimCache(), this.lookup.set(t, s), this.reverseLookup);
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
|
-
class
|
|
289
|
+
class C {
|
|
290
290
|
constructor(t, e = null, s = null) {
|
|
291
291
|
this.value = t, this.next = e, this.prev = s;
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
|
-
class
|
|
294
|
+
class Z {
|
|
295
295
|
count = 0;
|
|
296
296
|
head = null;
|
|
297
297
|
tail = null;
|
|
@@ -350,7 +350,7 @@ class Q {
|
|
|
350
350
|
insert(t, e) {
|
|
351
351
|
if (e < 0 || e > this.count)
|
|
352
352
|
throw new Error(`Index out of bounds: ${e}`);
|
|
353
|
-
const s = new
|
|
353
|
+
const s = new C(t);
|
|
354
354
|
if (e === 0)
|
|
355
355
|
s.next = this.head, this.head && (this.head.prev = s), this.head = s, this.count === 0 && (this.tail = s);
|
|
356
356
|
else if (e === this.count)
|
|
@@ -374,7 +374,7 @@ class Q {
|
|
|
374
374
|
return this.count++, !0;
|
|
375
375
|
}
|
|
376
376
|
push(t) {
|
|
377
|
-
const e = new
|
|
377
|
+
const e = new C(t);
|
|
378
378
|
this.head ? this.tail && (this.tail.next = e, e.prev = this.tail, this.tail = e) : (this.head = e, this.tail = e), this.count++;
|
|
379
379
|
}
|
|
380
380
|
remove(t) {
|
|
@@ -439,17 +439,17 @@ class Q {
|
|
|
439
439
|
return t;
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
|
-
class
|
|
442
|
+
class G {
|
|
443
443
|
key;
|
|
444
444
|
value;
|
|
445
445
|
constructor(t, e) {
|
|
446
446
|
this.key = t, this.value = e;
|
|
447
447
|
}
|
|
448
448
|
}
|
|
449
|
-
function
|
|
449
|
+
function $(o, t = { emptyString: !1, zeroNumber: !1 }) {
|
|
450
450
|
return o == null ? !(t.emptyString && o === "" || t.zeroNumber && o === 0) : !1;
|
|
451
451
|
}
|
|
452
|
-
class
|
|
452
|
+
class B {
|
|
453
453
|
table = [];
|
|
454
454
|
constructor() {
|
|
455
455
|
}
|
|
@@ -460,15 +460,15 @@ class F {
|
|
|
460
460
|
return -1;
|
|
461
461
|
}
|
|
462
462
|
set(t, e) {
|
|
463
|
-
if (
|
|
463
|
+
if ($(t))
|
|
464
464
|
throw new Error("key is required");
|
|
465
|
-
if (
|
|
465
|
+
if ($(e))
|
|
466
466
|
throw new Error("value is required");
|
|
467
467
|
if (this.has(t)) {
|
|
468
468
|
let s = this.getItemIndex(t);
|
|
469
469
|
this.table[s].value = e;
|
|
470
470
|
} else {
|
|
471
|
-
const s = new
|
|
471
|
+
const s = new G(t, e);
|
|
472
472
|
this.table.push(s);
|
|
473
473
|
}
|
|
474
474
|
}
|
|
@@ -519,12 +519,12 @@ class F {
|
|
|
519
519
|
return t = t.slice(0, -1), t;
|
|
520
520
|
}
|
|
521
521
|
}
|
|
522
|
-
class
|
|
522
|
+
class K {
|
|
523
523
|
isDirected;
|
|
524
524
|
vertices;
|
|
525
525
|
adjList;
|
|
526
526
|
constructor(t = !1) {
|
|
527
|
-
this.isDirected = t, this.vertices = [], this.adjList = new
|
|
527
|
+
this.isDirected = t, this.vertices = [], this.adjList = new B();
|
|
528
528
|
}
|
|
529
529
|
addVertex(t) {
|
|
530
530
|
this.vertices.includes(t) || (this.vertices.push(t), this.adjList.set(t, []));
|
|
@@ -604,10 +604,10 @@ class w {
|
|
|
604
604
|
return this.mul(-1);
|
|
605
605
|
}
|
|
606
606
|
}
|
|
607
|
-
class
|
|
607
|
+
class M {
|
|
608
608
|
_matrix;
|
|
609
609
|
static zero(t, e) {
|
|
610
|
-
return new
|
|
610
|
+
return new M(
|
|
611
611
|
Array.from({ length: t }, () => Array.from({ length: e }, () => 0))
|
|
612
612
|
);
|
|
613
613
|
}
|
|
@@ -648,7 +648,7 @@ class S {
|
|
|
648
648
|
return this._matrix[t[0]][t[1]] = e, this;
|
|
649
649
|
}
|
|
650
650
|
mul(t) {
|
|
651
|
-
return new
|
|
651
|
+
return new M(this._matrix.map((e) => e.map((s) => s * t)));
|
|
652
652
|
}
|
|
653
653
|
div(t) {
|
|
654
654
|
return this.mul(1 / t);
|
|
@@ -656,7 +656,7 @@ class S {
|
|
|
656
656
|
add(t) {
|
|
657
657
|
if (this.row !== t.row || this.col !== t.col)
|
|
658
658
|
throw new Error("Matrix dimensions do not match");
|
|
659
|
-
return new
|
|
659
|
+
return new M(
|
|
660
660
|
this._matrix.map(
|
|
661
661
|
(e, s) => e.map((r, i) => r + t.getItem([s, i]))
|
|
662
662
|
)
|
|
@@ -674,14 +674,14 @@ class S {
|
|
|
674
674
|
mulVector(t) {
|
|
675
675
|
if (this.col !== t.dimension)
|
|
676
676
|
throw new Error("Matrix dimensions do not match");
|
|
677
|
-
return new
|
|
677
|
+
return new M(
|
|
678
678
|
this._matrix.map((e) => e.map((s, r) => s * t.getItem(r)))
|
|
679
679
|
);
|
|
680
680
|
}
|
|
681
681
|
mulMatrix(t) {
|
|
682
682
|
if (this.col !== t.row)
|
|
683
683
|
throw new Error("Matrix dimensions do not match");
|
|
684
|
-
const e =
|
|
684
|
+
const e = M.zero(this.row, t.col);
|
|
685
685
|
for (let s = 0; s < this.row; s++) {
|
|
686
686
|
const r = this.rowVector(s);
|
|
687
687
|
for (let i = 0; i < this.col; i++)
|
|
@@ -690,7 +690,7 @@ class S {
|
|
|
690
690
|
return e;
|
|
691
691
|
}
|
|
692
692
|
}
|
|
693
|
-
class
|
|
693
|
+
class u {
|
|
694
694
|
static distance(t, e) {
|
|
695
695
|
return Math.hypot(e.x - t.x, e.y - t.y);
|
|
696
696
|
}
|
|
@@ -700,40 +700,58 @@ class p {
|
|
|
700
700
|
this.x = t, this.y = e;
|
|
701
701
|
}
|
|
702
702
|
distanceTo(t) {
|
|
703
|
-
return
|
|
703
|
+
return u.distance(this, t);
|
|
704
|
+
}
|
|
705
|
+
static linearInterpolation(t, e, s) {
|
|
706
|
+
if (s < 0 || s > 1)
|
|
707
|
+
throw new Error("Parameter t must be in the range [0, 1]");
|
|
708
|
+
const r = t.x * (1 - s) + e.x * s, i = t.y * (1 - s) + e.y * s;
|
|
709
|
+
return new u(r, i);
|
|
710
|
+
}
|
|
711
|
+
static quadraticBezierInterpolation(t, e, s, r) {
|
|
712
|
+
if (r < 0 || r > 1)
|
|
713
|
+
throw new Error("Parameter t must be in the range [0, 1]");
|
|
714
|
+
const i = (1 - r) * (1 - r) * t.x + 2 * (1 - r) * r * e.x + r * r * s.x, n = (1 - r) * (1 - r) * t.y + 2 * (1 - r) * r * e.y + r * r * s.y;
|
|
715
|
+
return new u(i, n);
|
|
716
|
+
}
|
|
717
|
+
static cubicBezierInterpolation(t, e, s, r, i) {
|
|
718
|
+
if (i < 0 || i > 1)
|
|
719
|
+
throw new Error("Parameter t must be in the range [0, 1]");
|
|
720
|
+
const n = Math.pow(1 - i, 3) * t.x + 3 * Math.pow(1 - i, 2) * i * e.x + 3 * (1 - i) * Math.pow(i, 2) * s.x + Math.pow(i, 3) * r.x, a = Math.pow(1 - i, 3) * t.y + 3 * Math.pow(1 - i, 2) * i * e.y + 3 * (1 - i) * Math.pow(i, 2) * s.y + Math.pow(i, 3) * r.y;
|
|
721
|
+
return new u(n, a);
|
|
704
722
|
}
|
|
705
723
|
}
|
|
706
|
-
class
|
|
724
|
+
class y {
|
|
707
725
|
static EPSILON = 1e-10;
|
|
708
|
-
static sloped(t, e =
|
|
726
|
+
static sloped(t, e = y.EPSILON) {
|
|
709
727
|
const s = t.p2.x - t.p1.x, r = t.p2.y - t.p1.y;
|
|
710
728
|
return Math.abs(s) < e ? Math.abs(r) < e ? 0 : null : r / s;
|
|
711
729
|
}
|
|
712
|
-
static isParallel(t, e, s =
|
|
713
|
-
const r =
|
|
730
|
+
static isParallel(t, e, s = y.EPSILON) {
|
|
731
|
+
const r = y.sloped(t), i = y.sloped(e);
|
|
714
732
|
return r === null && i === null ? !0 : r === null || i === null ? !1 : Math.abs(r - i) < s;
|
|
715
733
|
}
|
|
716
|
-
static getIntersection(t, e, s =
|
|
717
|
-
if (
|
|
718
|
-
const r = t.p1.x, i = t.p1.y, n = t.p2.x, a = t.p2.y, c = e.p1.x,
|
|
719
|
-
if (Math.abs(
|
|
720
|
-
const m = ((r - c) * (
|
|
734
|
+
static getIntersection(t, e, s = y.EPSILON) {
|
|
735
|
+
if (y.isParallel(t, e)) return null;
|
|
736
|
+
const r = t.p1.x, i = t.p1.y, n = t.p2.x, a = t.p2.y, c = e.p1.x, d = e.p1.y, l = e.p2.x, h = e.p2.y, p = (r - n) * (d - h) - (i - a) * (c - l);
|
|
737
|
+
if (Math.abs(p) < s) return null;
|
|
738
|
+
const m = ((r - c) * (d - h) - (i - d) * (c - l)) / p, I = -((r - n) * (i - d) - (i - a) * (r - c)) / p;
|
|
721
739
|
if (m >= 0 && m <= 1 && I >= 0 && I <= 1) {
|
|
722
|
-
const R = r + m * (n - r),
|
|
723
|
-
return new
|
|
740
|
+
const R = r + m * (n - r), q = i + m * (a - i);
|
|
741
|
+
return new u(R, q);
|
|
724
742
|
}
|
|
725
743
|
return null;
|
|
726
744
|
}
|
|
727
745
|
static isIntersecting(t, e) {
|
|
728
|
-
return
|
|
729
|
-
}
|
|
730
|
-
static distanceToPoint(t, e, s =
|
|
731
|
-
const r = e.x - t.p1.x, i = e.y - t.p1.y, n = t.p2.x - t.p1.x, a = t.p2.y - t.p1.y, c = r * n + i * a,
|
|
732
|
-
let
|
|
733
|
-
|
|
734
|
-
let h,
|
|
735
|
-
|
|
736
|
-
const m = e.x - h, I = e.y -
|
|
746
|
+
return y.getIntersection(t, e) !== null;
|
|
747
|
+
}
|
|
748
|
+
static distanceToPoint(t, e, s = y.EPSILON) {
|
|
749
|
+
const r = e.x - t.p1.x, i = e.y - t.p1.y, n = t.p2.x - t.p1.x, a = t.p2.y - t.p1.y, c = r * n + i * a, d = n * n + a * a;
|
|
750
|
+
let l = -1;
|
|
751
|
+
d > s && (l = c / d);
|
|
752
|
+
let h, p;
|
|
753
|
+
l < 0 ? (h = t.p1.x, p = t.p1.y) : l > 1 ? (h = t.p2.x, p = t.p2.y) : (h = t.p1.x + l * n, p = t.p1.y + l * a);
|
|
754
|
+
const m = e.x - h, I = e.y - p;
|
|
737
755
|
return Math.hypot(m + I);
|
|
738
756
|
}
|
|
739
757
|
p1;
|
|
@@ -747,20 +765,20 @@ class g {
|
|
|
747
765
|
}
|
|
748
766
|
get midpoint() {
|
|
749
767
|
const t = (this.p1.x + this.p2.x) / 2, e = (this.p1.y + this.p2.y) / 2;
|
|
750
|
-
return new
|
|
768
|
+
return new u(t, e);
|
|
751
769
|
}
|
|
752
770
|
get angle() {
|
|
753
771
|
return Math.atan2(this.p2.y - this.p1.y, this.p2.x - this.p1.x);
|
|
754
772
|
}
|
|
755
|
-
containsPoint(t, e =
|
|
773
|
+
containsPoint(t, e = y.EPSILON) {
|
|
756
774
|
const s = (t.x - this.p1.x) * (this.p2.y - this.p1.y) - (t.y - this.p1.y) * (this.p2.x - this.p1.x);
|
|
757
775
|
return Math.abs(s) > e ? !1 : (t.x - this.p1.x) * (t.x - this.p2.x) + (t.y - this.p1.y) * (t.y - this.p2.y) <= e;
|
|
758
776
|
}
|
|
759
777
|
get direction() {
|
|
760
778
|
const t = this.length;
|
|
761
|
-
if (t <
|
|
779
|
+
if (t < y.EPSILON) return new u(0, 0);
|
|
762
780
|
const e = (this.p2.x - this.p1.x) / t, s = (this.p2.y - this.p1.y) / t;
|
|
763
|
-
return new
|
|
781
|
+
return new u(e, s);
|
|
764
782
|
}
|
|
765
783
|
get start() {
|
|
766
784
|
return this.p1;
|
|
@@ -769,31 +787,31 @@ class g {
|
|
|
769
787
|
return this.p2;
|
|
770
788
|
}
|
|
771
789
|
}
|
|
772
|
-
class
|
|
790
|
+
class N {
|
|
773
791
|
static EPSILON = 1e-10;
|
|
774
792
|
name;
|
|
775
793
|
constructor(t) {
|
|
776
794
|
this.name = t;
|
|
777
795
|
}
|
|
778
796
|
}
|
|
779
|
-
class
|
|
797
|
+
class g extends N {
|
|
780
798
|
static isValid(t, e, s) {
|
|
781
799
|
return t <= 0 || e <= 0 || s <= 0 ? !1 : t + e > s && t + s > e && e + s > t;
|
|
782
800
|
}
|
|
783
801
|
static area(t, e, s) {
|
|
784
|
-
if (!
|
|
802
|
+
if (!g.isValid(t, e, s))
|
|
785
803
|
throw new Error("Invalid triangle");
|
|
786
804
|
const r = (t + e + s) / 2;
|
|
787
805
|
return Math.sqrt(r * (r - t) * (r - e) * (r - s));
|
|
788
806
|
}
|
|
789
807
|
static getType(t, e, s) {
|
|
790
|
-
if (!
|
|
808
|
+
if (!g.isValid(t, e, s))
|
|
791
809
|
throw new Error("Invalid triangle sides");
|
|
792
|
-
const r = [t, e, s].sort((c,
|
|
793
|
-
return Math.abs(i - n) <
|
|
810
|
+
const r = [t, e, s].sort((c, d) => c - d), [i, n, a] = r;
|
|
811
|
+
return Math.abs(i - n) < g.EPSILON && Math.abs(n - a) < g.EPSILON ? "equilateral" : Math.abs(i - n) < g.EPSILON || Math.abs(n - a) < g.EPSILON ? "isosceles" : "scalene";
|
|
794
812
|
}
|
|
795
813
|
static getAngles(t, e, s) {
|
|
796
|
-
if (!
|
|
814
|
+
if (!g.isValid(t, e, s))
|
|
797
815
|
throw new Error("Invalid triangle sides");
|
|
798
816
|
const r = Math.acos((e * e + s * s - t * t) / (2 * e * s)), i = Math.acos((t * t + s * s - e * e) / (2 * t * s)), n = Math.PI - r - i;
|
|
799
817
|
return [r, i, n];
|
|
@@ -809,65 +827,65 @@ class d extends L {
|
|
|
809
827
|
areCollinear() {
|
|
810
828
|
return Math.abs(
|
|
811
829
|
(this.p2.x - this.p1.x) * (this.p3.y - this.p1.y) - (this.p3.x - this.p1.x) * (this.p2.y - this.p1.y)
|
|
812
|
-
) <
|
|
830
|
+
) < N.EPSILON;
|
|
813
831
|
}
|
|
814
832
|
get side() {
|
|
815
833
|
return [
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
834
|
+
u.distance(this.p1, this.p2),
|
|
835
|
+
u.distance(this.p2, this.p3),
|
|
836
|
+
u.distance(this.p3, this.p1)
|
|
819
837
|
];
|
|
820
838
|
}
|
|
821
839
|
perimeter() {
|
|
822
|
-
return
|
|
840
|
+
return g.isValid(this.side[0], this.side[1], this.side[2]), this.side.reduce((t, e) => t + e, 0);
|
|
823
841
|
}
|
|
824
842
|
area() {
|
|
825
843
|
const [t, e, s] = this.side;
|
|
826
|
-
return
|
|
844
|
+
return g.area(t, e, s);
|
|
827
845
|
}
|
|
828
846
|
get type() {
|
|
829
847
|
const [t, e, s] = this.side;
|
|
830
|
-
return
|
|
848
|
+
return g.getType(t, e, s);
|
|
831
849
|
}
|
|
832
850
|
get angles() {
|
|
833
851
|
const [t, e, s] = this.side;
|
|
834
|
-
return
|
|
852
|
+
return g.getAngles(t, e, s);
|
|
835
853
|
}
|
|
836
854
|
get centroid() {
|
|
837
|
-
return new
|
|
855
|
+
return new u(
|
|
838
856
|
(this.p1.x + this.p2.x + this.p3.x) / 3,
|
|
839
857
|
(this.p1.y + this.p2.y + this.p3.y) / 3
|
|
840
858
|
);
|
|
841
859
|
}
|
|
842
860
|
get incenter() {
|
|
843
861
|
const [t, e, s] = this.side, r = this.perimeter() / 2, i = (t * this.p1.x + e * this.p2.x + s * this.p3.x) / r, n = (t * this.p1.y + e * this.p2.y + s * this.p3.y) / r;
|
|
844
|
-
return new
|
|
862
|
+
return new u(i, n);
|
|
845
863
|
}
|
|
846
864
|
get circumcenter() {
|
|
847
865
|
const t = 2 * (this.p1.x * (this.p2.y - this.p3.y) + this.p2.x * (this.p3.y - this.p1.y) + this.p3.x * (this.p1.y - this.p2.y));
|
|
848
|
-
if (Math.abs(t) <
|
|
866
|
+
if (Math.abs(t) < g.EPSILON)
|
|
849
867
|
throw new Error("Cannot calculate circumcenter for collinear points");
|
|
850
868
|
const e = ((this.p1.x * this.p1.x + this.p1.y * this.p1.y) * (this.p2.y - this.p3.y) + (this.p2.x * this.p2.x + this.p2.y * this.p2.y) * (this.p3.y - this.p1.y) + (this.p3.x * this.p3.x + this.p3.y * this.p3.y) * (this.p1.y - this.p2.y)) / t, s = ((this.p1.x * this.p1.x + this.p1.y * this.p1.y) * (this.p3.x - this.p2.x) + (this.p2.x * this.p2.x + this.p2.y * this.p2.y) * (this.p1.x - this.p3.x) + (this.p3.x * this.p3.x + this.p3.y * this.p3.y) * (this.p2.x - this.p1.x)) / t;
|
|
851
|
-
return new
|
|
869
|
+
return new u(e, s);
|
|
852
870
|
}
|
|
853
871
|
containsPoint(t) {
|
|
854
|
-
const e =
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
), s =
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
), r =
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
872
|
+
const e = g.area(
|
|
873
|
+
u.distance(t, this.p1),
|
|
874
|
+
u.distance(t, this.p2),
|
|
875
|
+
u.distance(this.p1, this.p2)
|
|
876
|
+
), s = g.area(
|
|
877
|
+
u.distance(t, this.p2),
|
|
878
|
+
u.distance(t, this.p3),
|
|
879
|
+
u.distance(this.p2, this.p3)
|
|
880
|
+
), r = g.area(
|
|
881
|
+
u.distance(t, this.p3),
|
|
882
|
+
u.distance(t, this.p1),
|
|
883
|
+
u.distance(this.p3, this.p1)
|
|
866
884
|
);
|
|
867
|
-
return Math.abs(e + s + r - this.area()) <
|
|
885
|
+
return Math.abs(e + s + r - this.area()) < g.EPSILON;
|
|
868
886
|
}
|
|
869
887
|
}
|
|
870
|
-
class
|
|
888
|
+
class tt {
|
|
871
889
|
static sleep(t) {
|
|
872
890
|
return new Promise((e) => setTimeout(e, t));
|
|
873
891
|
}
|
|
@@ -891,7 +909,7 @@ class J {
|
|
|
891
909
|
return t.prototype.constructor = s, s;
|
|
892
910
|
}
|
|
893
911
|
}
|
|
894
|
-
class
|
|
912
|
+
class et {
|
|
895
913
|
static groupBy(t, e) {
|
|
896
914
|
if (!e)
|
|
897
915
|
throw new Error("generateKey is required");
|
|
@@ -940,7 +958,7 @@ class Y {
|
|
|
940
958
|
function P(o) {
|
|
941
959
|
return o !== null && (typeof o == "object" || typeof o == "function");
|
|
942
960
|
}
|
|
943
|
-
class
|
|
961
|
+
class st {
|
|
944
962
|
map = /* @__PURE__ */ new Map();
|
|
945
963
|
weakMap = /* @__PURE__ */ new WeakMap();
|
|
946
964
|
set(t, e) {
|
|
@@ -953,7 +971,7 @@ class Z {
|
|
|
953
971
|
return P(t) ? this.weakMap.has(t) : this.map.has(t);
|
|
954
972
|
}
|
|
955
973
|
}
|
|
956
|
-
class
|
|
974
|
+
class rt {
|
|
957
975
|
static jsonClone(t) {
|
|
958
976
|
try {
|
|
959
977
|
return JSON.parse(JSON.stringify(t));
|
|
@@ -1023,41 +1041,41 @@ class K {
|
|
|
1023
1041
|
return r;
|
|
1024
1042
|
}
|
|
1025
1043
|
}
|
|
1026
|
-
const
|
|
1044
|
+
const T = {
|
|
1027
1045
|
date: "yyyy-MM-dd",
|
|
1028
1046
|
datetime: "yyyy-MM-dd HH:mm:ss",
|
|
1029
1047
|
time: "HH:mm:ss",
|
|
1030
1048
|
iso: "yyyy-MM-ddTHH:mm:ss.SSS"
|
|
1031
1049
|
};
|
|
1032
|
-
class
|
|
1050
|
+
class A {
|
|
1033
1051
|
static defaultOptions = {
|
|
1034
1052
|
paddingZero: !1,
|
|
1035
1053
|
locale: "en-US"
|
|
1036
1054
|
};
|
|
1037
1055
|
static setDefaultOptions(t) {
|
|
1038
|
-
|
|
1056
|
+
A.defaultOptions = { ...A.defaultOptions, ...t };
|
|
1039
1057
|
}
|
|
1040
1058
|
static format(t, e, s = {}) {
|
|
1041
|
-
const r = { ...
|
|
1042
|
-
return
|
|
1059
|
+
const r = { ...A.defaultOptions, ...s }, i = A.getDateInfo(t, r);
|
|
1060
|
+
return A.normalizeFormatter(e)(i);
|
|
1043
1061
|
}
|
|
1044
1062
|
// 获取日期信息
|
|
1045
1063
|
static getDateInfo(t, e) {
|
|
1046
|
-
const s = (h,
|
|
1064
|
+
const s = (h, p = 2) => e.paddingZero ? h.toString().padStart(p, "0") : h.toString(), r = t.getFullYear(), i = t.getMonth() + 1, n = t.getDate(), a = t.getHours(), c = t.getMinutes(), d = t.getSeconds(), l = t.getMilliseconds();
|
|
1047
1065
|
return {
|
|
1048
1066
|
year: r,
|
|
1049
1067
|
month: i,
|
|
1050
1068
|
day: n,
|
|
1051
1069
|
hour: a,
|
|
1052
1070
|
minute: c,
|
|
1053
|
-
second:
|
|
1054
|
-
millisecond:
|
|
1071
|
+
second: d,
|
|
1072
|
+
millisecond: l,
|
|
1055
1073
|
yyyy: s(r, 4),
|
|
1056
1074
|
MM: s(i),
|
|
1057
1075
|
dd: s(n),
|
|
1058
1076
|
HH: s(a),
|
|
1059
1077
|
mm: s(c),
|
|
1060
|
-
ss: s(
|
|
1078
|
+
ss: s(d)
|
|
1061
1079
|
};
|
|
1062
1080
|
}
|
|
1063
1081
|
static normalizeFormatter(t) {
|
|
@@ -1065,7 +1083,7 @@ class v {
|
|
|
1065
1083
|
return t;
|
|
1066
1084
|
if (typeof t != "string")
|
|
1067
1085
|
throw new Error("Formatter must be a string or function");
|
|
1068
|
-
t in
|
|
1086
|
+
t in T && (t = T[t]);
|
|
1069
1087
|
const e = {
|
|
1070
1088
|
yyyy: "yyyy",
|
|
1071
1089
|
MM: "MM",
|
|
@@ -1090,7 +1108,7 @@ class v {
|
|
|
1090
1108
|
return c > 0 ? s > 0 ? `${c}天后` : `${c}天前` : a > 0 ? s > 0 ? `${a}小时后` : `${a}小时前` : n > 0 ? s > 0 ? `${n}分钟后` : `${n}分钟前` : s > 0 ? "刚刚" : "";
|
|
1091
1109
|
}
|
|
1092
1110
|
}
|
|
1093
|
-
class
|
|
1111
|
+
class F {
|
|
1094
1112
|
lights;
|
|
1095
1113
|
currentIndex;
|
|
1096
1114
|
switchTime;
|
|
@@ -1100,7 +1118,7 @@ class $ {
|
|
|
1100
1118
|
{ color: "green", latest: 10 },
|
|
1101
1119
|
{ color: "yellow", latest: 3 }
|
|
1102
1120
|
];
|
|
1103
|
-
constructor(t =
|
|
1121
|
+
constructor(t = F.DEFAULT_LIGHTS) {
|
|
1104
1122
|
this.lights = t, this.currentIndex = 0, this.switchTime = Date.now();
|
|
1105
1123
|
}
|
|
1106
1124
|
render(t) {
|
|
@@ -1125,12 +1143,21 @@ class $ {
|
|
|
1125
1143
|
};
|
|
1126
1144
|
}
|
|
1127
1145
|
}
|
|
1128
|
-
class
|
|
1146
|
+
class it {
|
|
1129
1147
|
static escape(t) {
|
|
1130
1148
|
return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1131
1149
|
}
|
|
1150
|
+
static telephone = {
|
|
1151
|
+
loose: /\D?(\d[0-9-]{6,}\d)\D?/g
|
|
1152
|
+
};
|
|
1153
|
+
static consecutiveChars = /(.)\1+/g;
|
|
1154
|
+
// 匹配连续字符
|
|
1155
|
+
static chineseChar = /[\u4e00-\u9fa5]/g;
|
|
1156
|
+
// 匹配中文字符
|
|
1157
|
+
static domain = /^(?:https?:\/\/)?(?:[^\/]+)/i;
|
|
1158
|
+
static email = /^\w+([-+.]\w+)*@\w+([-.]\w+)*.\w+([-.]\w+)*$/;
|
|
1132
1159
|
}
|
|
1133
|
-
class
|
|
1160
|
+
class nt {
|
|
1134
1161
|
static ROMAN_MAP = /* @__PURE__ */ new Map([
|
|
1135
1162
|
["M", 1e3],
|
|
1136
1163
|
["CM", 900],
|
|
@@ -1181,7 +1208,13 @@ class et {
|
|
|
1181
1208
|
return e;
|
|
1182
1209
|
}
|
|
1183
1210
|
}
|
|
1184
|
-
class
|
|
1211
|
+
class f {
|
|
1212
|
+
static ensurePositiveInteger(t, e = 0) {
|
|
1213
|
+
if (!Number.isInteger(t) || t <= e)
|
|
1214
|
+
throw new Error(
|
|
1215
|
+
`n must be a positive integer and greater than ${e}`
|
|
1216
|
+
);
|
|
1217
|
+
}
|
|
1185
1218
|
static handleNumRange(t, e = !1, s = Number.MIN_SAFE_INTEGER, r = Number.MAX_SAFE_INTEGER) {
|
|
1186
1219
|
if (e && !Number.isInteger(t))
|
|
1187
1220
|
throw new Error("n must be an integer");
|
|
@@ -1189,19 +1222,19 @@ class y {
|
|
|
1189
1222
|
throw new RangeError(`n must be in the range of ${s} to ${r}`);
|
|
1190
1223
|
}
|
|
1191
1224
|
static consecutiveSum(t) {
|
|
1192
|
-
return
|
|
1225
|
+
return f.handleNumRange(t, !0, 0, 1e8), t * (t + 1) / 2;
|
|
1193
1226
|
}
|
|
1194
1227
|
static consecutiveSquaresSum(t) {
|
|
1195
|
-
return
|
|
1228
|
+
return f.handleNumRange(t, !0, 0, 1e6), t * (t + 1) * (2 * t + 1) / 6;
|
|
1196
1229
|
}
|
|
1197
1230
|
static consecutivecubesSum(t) {
|
|
1198
|
-
return
|
|
1231
|
+
return f.handleNumRange(t, !0, 0, 1e4), t * (t + 1) * (2 * t + 1) * (3 * t * t + 3 * t - 1) / 30;
|
|
1199
1232
|
}
|
|
1200
1233
|
static clamp(t, e, s) {
|
|
1201
1234
|
return s == null ? Math.min(t, e) : Math.min(Math.max(t, e), s);
|
|
1202
1235
|
}
|
|
1203
1236
|
static factorial(t) {
|
|
1204
|
-
if (
|
|
1237
|
+
if (f.handleNumRange(t, !0, 0, 1e3), t < 2)
|
|
1205
1238
|
return 1;
|
|
1206
1239
|
let e = 1;
|
|
1207
1240
|
for (let s = 2; s <= t; s++)
|
|
@@ -1209,10 +1242,10 @@ class y {
|
|
|
1209
1242
|
return e;
|
|
1210
1243
|
}
|
|
1211
1244
|
static fibonacci(t, e = 1, s = 1) {
|
|
1212
|
-
return
|
|
1245
|
+
return f.handleNumRange(t, !0, 0, 1e3), t < 2 ? s : this.fibonacci(t - 1, s, s + e);
|
|
1213
1246
|
}
|
|
1214
1247
|
static fibonacciIterative(t) {
|
|
1215
|
-
if (
|
|
1248
|
+
if (f.handleNumRange(t, !0, 0, 1e3), t < 2) return t;
|
|
1216
1249
|
let e = 0, s = 1;
|
|
1217
1250
|
for (let r = 2; r <= t; r++)
|
|
1218
1251
|
[e, s] = [s, (e + s) % 1000000007];
|
|
@@ -1222,13 +1255,13 @@ class y {
|
|
|
1222
1255
|
return Math.abs(t - e) < s;
|
|
1223
1256
|
}
|
|
1224
1257
|
static fastPower(t, e) {
|
|
1225
|
-
if (
|
|
1258
|
+
if (f.handleNumRange(e, !0, 0, 10), f.handleNumRange(t, !1, 0, 1e3), t === 0) return 0;
|
|
1226
1259
|
if (e === 0) return 1;
|
|
1227
1260
|
const s = this.fastPower(t, e >> 1);
|
|
1228
1261
|
return e % 2 === 0 ? s * s : s * s * t;
|
|
1229
1262
|
}
|
|
1230
1263
|
static fastSqrt(t) {
|
|
1231
|
-
if (
|
|
1264
|
+
if (f.handleNumRange(t, !1, 0, 1e8), typeof BigInt > "u")
|
|
1232
1265
|
return Math.sqrt(t);
|
|
1233
1266
|
const e = 0.5 * t, s = new ArrayBuffer(8);
|
|
1234
1267
|
new Float64Array(s)[0] = t;
|
|
@@ -1244,23 +1277,20 @@ class y {
|
|
|
1244
1277
|
return [];
|
|
1245
1278
|
if (e < 0 || !Number.isInteger(e))
|
|
1246
1279
|
throw new Error("Precision must be a non-negative integer");
|
|
1247
|
-
const s = t.reduce((h,
|
|
1280
|
+
const s = t.reduce((h, p) => h + p, 0);
|
|
1248
1281
|
if (s === 0)
|
|
1249
1282
|
return t.map(() => "0%");
|
|
1250
|
-
const i = 100 * Math.pow(10, e), n = t.map((h) => h / s * i), a = n.map((h) => Math.floor(h)), c = n.map((h,
|
|
1251
|
-
let
|
|
1252
|
-
for (;
|
|
1253
|
-
let h = -1,
|
|
1283
|
+
const i = 100 * Math.pow(10, e), n = t.map((h) => h / s * i), a = n.map((h) => Math.floor(h)), c = n.map((h, p) => h - a[p]);
|
|
1284
|
+
let d = a.reduce((h, p) => h + p, 0), l = i - d;
|
|
1285
|
+
for (; l > 0; ) {
|
|
1286
|
+
let h = -1, p = -1;
|
|
1254
1287
|
for (let m = 0; m < c.length; m++)
|
|
1255
|
-
c[m] >
|
|
1288
|
+
c[m] > p && (p = c[m], h = m);
|
|
1256
1289
|
if (h === -1) break;
|
|
1257
|
-
a[h]++, c[h] = 0,
|
|
1290
|
+
a[h]++, c[h] = 0, l--;
|
|
1258
1291
|
}
|
|
1259
1292
|
return a.map((h) => `${(h / i * 100).toFixed(e)}%`);
|
|
1260
1293
|
}
|
|
1261
|
-
static gcd(t, e) {
|
|
1262
|
-
return e === 0 ? t : this.gcd(e, t % e);
|
|
1263
|
-
}
|
|
1264
1294
|
static isValidPositiveInteger(t) {
|
|
1265
1295
|
return Number.isInteger(t) && t > 0 && t <= Number.MAX_SAFE_INTEGER;
|
|
1266
1296
|
}
|
|
@@ -1271,9 +1301,11 @@ class y {
|
|
|
1271
1301
|
return t % 2 === 1 || t % 2 === -1;
|
|
1272
1302
|
}
|
|
1273
1303
|
static isPrime(t) {
|
|
1274
|
-
if (t
|
|
1304
|
+
if (f.ensurePositiveInteger(t, 1), t == 2 || t == 3 || t == 5 || t == 7)
|
|
1305
|
+
return !0;
|
|
1306
|
+
if (t % 2 === 0 || t % 3 === 0 || t % 5 === 0 || t % 7 === 0)
|
|
1275
1307
|
return !1;
|
|
1276
|
-
for (let e =
|
|
1308
|
+
for (let e = 7; e <= Math.sqrt(t); e += 2)
|
|
1277
1309
|
if (t % e === 0)
|
|
1278
1310
|
return !1;
|
|
1279
1311
|
return !0;
|
|
@@ -1319,6 +1351,9 @@ class y {
|
|
|
1319
1351
|
);
|
|
1320
1352
|
return e <= t && t < s;
|
|
1321
1353
|
}
|
|
1354
|
+
static gcd(t, e) {
|
|
1355
|
+
return e === 0 ? t : f.gcd(e, t % e);
|
|
1356
|
+
}
|
|
1322
1357
|
static lcm(t, e) {
|
|
1323
1358
|
return t * e / this.gcd(t, e);
|
|
1324
1359
|
}
|
|
@@ -1351,15 +1386,19 @@ class y {
|
|
|
1351
1386
|
static getPythagoreanTriple(t) {
|
|
1352
1387
|
if (t <= 0 || !Number.isInteger(t))
|
|
1353
1388
|
throw new Error("n must be a positive integer");
|
|
1354
|
-
if (
|
|
1389
|
+
if (f.isOdd(t)) {
|
|
1355
1390
|
const s = t * t;
|
|
1356
1391
|
return [t, (s - 1) / 2, (s + 1) / 2];
|
|
1357
1392
|
}
|
|
1358
1393
|
const e = t / 2;
|
|
1359
1394
|
return [t, e * e - 1, e * e + 1];
|
|
1360
1395
|
}
|
|
1396
|
+
static exclusionPrinciple(t, e, s, r) {
|
|
1397
|
+
const i = Math.floor(t / e) + Math.floor(t / s) + Math.floor(t / r), n = Math.floor(t / f.lcm(e, s)) + Math.floor(t / f.lcm(e, r)) + Math.floor(t / f.lcm(s, r)), a = Math.floor(t / f.lcm(f.lcm(e, s), r));
|
|
1398
|
+
return i - n + a;
|
|
1399
|
+
}
|
|
1361
1400
|
}
|
|
1362
|
-
class
|
|
1401
|
+
class at {
|
|
1363
1402
|
static READ = 1;
|
|
1364
1403
|
static WRITE = 2;
|
|
1365
1404
|
static SHARE = 4;
|
|
@@ -1378,7 +1417,7 @@ class st {
|
|
|
1378
1417
|
return t ^ e;
|
|
1379
1418
|
}
|
|
1380
1419
|
}
|
|
1381
|
-
class
|
|
1420
|
+
class S {
|
|
1382
1421
|
static frequencyStatistics(t) {
|
|
1383
1422
|
return [...t].reduce(
|
|
1384
1423
|
(e, s) => (e[s] = (e[s] || 0) + 1, e),
|
|
@@ -1447,7 +1486,7 @@ class A {
|
|
|
1447
1486
|
return e;
|
|
1448
1487
|
}
|
|
1449
1488
|
static pointAt(t, e) {
|
|
1450
|
-
if (e >=
|
|
1489
|
+
if (e >= S.pointLength(t)) return;
|
|
1451
1490
|
let s = 0;
|
|
1452
1491
|
for (let r = 0, i = t.length; r < i; ) {
|
|
1453
1492
|
const n = t.codePointAt(r);
|
|
@@ -1457,10 +1496,10 @@ class A {
|
|
|
1457
1496
|
r += n > 65535 ? 2 : 1, s++;
|
|
1458
1497
|
}
|
|
1459
1498
|
}
|
|
1460
|
-
static sliceByPoint(t, e, s =
|
|
1499
|
+
static sliceByPoint(t, e, s = S.pointLength(t)) {
|
|
1461
1500
|
let r = "";
|
|
1462
1501
|
for (let i = e; i < s; i++)
|
|
1463
|
-
r +=
|
|
1502
|
+
r += S.pointAt(t, i);
|
|
1464
1503
|
return r;
|
|
1465
1504
|
}
|
|
1466
1505
|
static capitalize(t) {
|
|
@@ -1470,10 +1509,10 @@ class A {
|
|
|
1470
1509
|
return t.split("").reverse().join("");
|
|
1471
1510
|
}
|
|
1472
1511
|
static truncate(t, e, s = "...") {
|
|
1473
|
-
return t.length <= e ?
|
|
1512
|
+
return t.length <= e ? t : t.slice(0, e - s.length) + s;
|
|
1474
1513
|
}
|
|
1475
1514
|
static isPalindrome(t) {
|
|
1476
|
-
return t.toLowerCase().replace(/[^a-z0-9]/g, "") ===
|
|
1515
|
+
return t.toLowerCase().replace(/[^a-z0-9]/g, "") === S.reverse(t);
|
|
1477
1516
|
}
|
|
1478
1517
|
static count(t, e) {
|
|
1479
1518
|
const s = e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -1486,7 +1525,7 @@ class A {
|
|
|
1486
1525
|
return t.replace(/[A-Z]/g, (e) => `_${e.toLowerCase()}`);
|
|
1487
1526
|
}
|
|
1488
1527
|
}
|
|
1489
|
-
class
|
|
1528
|
+
class ot {
|
|
1490
1529
|
static isValidHex(t) {
|
|
1491
1530
|
return /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(t);
|
|
1492
1531
|
}
|
|
@@ -1494,7 +1533,130 @@ class rt {
|
|
|
1494
1533
|
return /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.test(t);
|
|
1495
1534
|
}
|
|
1496
1535
|
}
|
|
1497
|
-
const
|
|
1536
|
+
const L = (o) => o == null || o === "", _ = {
|
|
1537
|
+
success: {
|
|
1538
|
+
background: "#67C23A",
|
|
1539
|
+
border: "#67C23A",
|
|
1540
|
+
color: "#fff"
|
|
1541
|
+
},
|
|
1542
|
+
error: {
|
|
1543
|
+
background: "#F56C6C",
|
|
1544
|
+
border: "#F56C6C",
|
|
1545
|
+
color: "#fff"
|
|
1546
|
+
},
|
|
1547
|
+
warning: {
|
|
1548
|
+
background: "#E6A23C",
|
|
1549
|
+
border: "#E6A23C",
|
|
1550
|
+
color: "#fff"
|
|
1551
|
+
},
|
|
1552
|
+
info: {
|
|
1553
|
+
background: "#909399",
|
|
1554
|
+
border: "#909399",
|
|
1555
|
+
color: "#fff"
|
|
1556
|
+
}
|
|
1557
|
+
}, z = {
|
|
1558
|
+
enable: !0,
|
|
1559
|
+
showTimestamp: !0,
|
|
1560
|
+
maxLogLength: 30
|
|
1561
|
+
};
|
|
1562
|
+
class x {
|
|
1563
|
+
//#region private static methods
|
|
1564
|
+
static config = z;
|
|
1565
|
+
static shouldLog() {
|
|
1566
|
+
return this.config.enable && !0;
|
|
1567
|
+
}
|
|
1568
|
+
static formatMessage(t) {
|
|
1569
|
+
return t.length > this.config.maxLogLength ? `${t.substring(0, this.config.maxLogLength)}...` : t;
|
|
1570
|
+
}
|
|
1571
|
+
static getTimestamp() {
|
|
1572
|
+
return this.config.showTimestamp ? `[${(/* @__PURE__ */ new Date()).toLocaleTimeString()}] ` : "";
|
|
1573
|
+
}
|
|
1574
|
+
static prettyPrint(t, e, s) {
|
|
1575
|
+
if (!this.shouldLog()) return;
|
|
1576
|
+
const r = _[s], i = this.getTimestamp(), n = this.formatMessage(t), a = this.formatMessage(e);
|
|
1577
|
+
console.log(
|
|
1578
|
+
`%c${i} ${n} %c ${a} %c`,
|
|
1579
|
+
`background:${r.background};border:1px solid ${r.border}; padding: 1px; border-radius: 2px 0 0 2px; color: ${r.color};`,
|
|
1580
|
+
`border:1px solid ${r.border}; padding: 1px; border-radius: 0 2px 2px 0; color: ${r.border};`,
|
|
1581
|
+
"background:transparent"
|
|
1582
|
+
);
|
|
1583
|
+
}
|
|
1584
|
+
static handleLevel(t, e, s) {
|
|
1585
|
+
const r = L(e) ? s : t, i = L(e) ? t : e;
|
|
1586
|
+
return x.prettyPrint(r, i, s);
|
|
1587
|
+
}
|
|
1588
|
+
//#endregion
|
|
1589
|
+
//#region public static methods
|
|
1590
|
+
static configure(t) {
|
|
1591
|
+
this.config = { ...z, ...t };
|
|
1592
|
+
}
|
|
1593
|
+
static success(t, e = "") {
|
|
1594
|
+
x.handleLevel(t, e, "success");
|
|
1595
|
+
}
|
|
1596
|
+
static error(t, e = "") {
|
|
1597
|
+
this.handleLevel(t, e, "error");
|
|
1598
|
+
}
|
|
1599
|
+
static warning(t, e = "") {
|
|
1600
|
+
x.handleLevel(t, e, "warning");
|
|
1601
|
+
}
|
|
1602
|
+
static info(t, e = "") {
|
|
1603
|
+
x.handleLevel(t, e, "info");
|
|
1604
|
+
}
|
|
1605
|
+
static table(t) {
|
|
1606
|
+
!this.shouldLog() || !Array.isArray(t) || t.length === 0 || console.table(t);
|
|
1607
|
+
}
|
|
1608
|
+
static async picture(t, e = 1) {
|
|
1609
|
+
if (!(!this.shouldLog() || L(t)))
|
|
1610
|
+
return new Promise((s, r) => {
|
|
1611
|
+
const i = new Image();
|
|
1612
|
+
i.crossOrigin = "anonymous", i.onerror = () => {
|
|
1613
|
+
x.error("Image Load Error", `Failed to load image: ${t}`), r(new Error(`Failed to load image: ${t}`));
|
|
1614
|
+
}, i.onload = () => {
|
|
1615
|
+
try {
|
|
1616
|
+
const n = document.createElement("canvas"), a = n.getContext("2d");
|
|
1617
|
+
if (!a)
|
|
1618
|
+
throw new Error("Failed to get canvas context");
|
|
1619
|
+
n.width = i.width, n.height = i.height, a.fillStyle = "red", a.fillRect(0, 0, n.width, n.height), a.drawImage(i, 0, 0);
|
|
1620
|
+
const c = n.toDataURL("image/png");
|
|
1621
|
+
console.log(
|
|
1622
|
+
"%c sup?",
|
|
1623
|
+
`font-size:1px;
|
|
1624
|
+
padding:${Math.floor(i.height * e / 2)}px ${Math.floor(
|
|
1625
|
+
i.width * e / 2
|
|
1626
|
+
)}px;
|
|
1627
|
+
background:url(${c}) no-repeat;
|
|
1628
|
+
background-size:${i.width * e}px ${i.height * e}px;
|
|
1629
|
+
line-height:${i.height * e}px;
|
|
1630
|
+
color:transparent;
|
|
1631
|
+
`
|
|
1632
|
+
), s();
|
|
1633
|
+
} catch (n) {
|
|
1634
|
+
x.error(
|
|
1635
|
+
"Image Processing Error",
|
|
1636
|
+
n instanceof Error ? n.message : String(n)
|
|
1637
|
+
), r(n);
|
|
1638
|
+
}
|
|
1639
|
+
}, i.src = t;
|
|
1640
|
+
});
|
|
1641
|
+
}
|
|
1642
|
+
static time(t) {
|
|
1643
|
+
this.shouldLog() && console.time(t);
|
|
1644
|
+
}
|
|
1645
|
+
static timeEnd(t) {
|
|
1646
|
+
this.shouldLog() && console.timeEnd(t);
|
|
1647
|
+
}
|
|
1648
|
+
static group(t, e = !1) {
|
|
1649
|
+
this.shouldLog() && (e ? console.groupCollapsed(t) : console.group(t));
|
|
1650
|
+
}
|
|
1651
|
+
static groupEnd() {
|
|
1652
|
+
this.shouldLog() && console.groupEnd();
|
|
1653
|
+
}
|
|
1654
|
+
static clear() {
|
|
1655
|
+
this.shouldLog() && console.clear();
|
|
1656
|
+
}
|
|
1657
|
+
//#endregion
|
|
1658
|
+
}
|
|
1659
|
+
const v = {
|
|
1498
1660
|
AUTH_UNAUTHORIZED: "未授权事件",
|
|
1499
1661
|
AUTH_LOGIN_SUCCESS: "登录成功事件",
|
|
1500
1662
|
AUTH_LOGOUT: "注销事件",
|
|
@@ -1506,37 +1668,37 @@ const x = {
|
|
|
1506
1668
|
UI_HIDE_LOADING: "隐藏加载事件",
|
|
1507
1669
|
UI_SHOW_MESSAGE: "显示消息事件"
|
|
1508
1670
|
};
|
|
1509
|
-
class
|
|
1671
|
+
class b {
|
|
1510
1672
|
static instance = null;
|
|
1511
1673
|
listeners = {};
|
|
1512
1674
|
debugMode;
|
|
1513
1675
|
constructor(t = !1) {
|
|
1514
|
-
this.debugMode = t, Object.keys(
|
|
1676
|
+
this.debugMode = t, Object.keys(v).forEach(
|
|
1515
1677
|
(e) => {
|
|
1516
1678
|
this.listeners[e] = /* @__PURE__ */ new Set();
|
|
1517
1679
|
}
|
|
1518
1680
|
);
|
|
1519
1681
|
}
|
|
1520
1682
|
static getInstance(t) {
|
|
1521
|
-
return
|
|
1683
|
+
return b.instance || (b.instance = new b(t)), b.instance;
|
|
1522
1684
|
}
|
|
1523
1685
|
on(t, e) {
|
|
1524
|
-
this.debugLog(`添加事件监听: ${
|
|
1686
|
+
this.debugLog(`添加事件监听: ${v[t]}`), this.listeners[t].add(e);
|
|
1525
1687
|
}
|
|
1526
1688
|
emit(t, e) {
|
|
1527
|
-
this.debugLog(`触发事件: ${
|
|
1689
|
+
this.debugLog(`触发事件: ${v[t]}`, e), this.listeners[t].forEach((s) => {
|
|
1528
1690
|
try {
|
|
1529
1691
|
s(e);
|
|
1530
1692
|
} catch (r) {
|
|
1531
|
-
console.error(`事件 ${
|
|
1693
|
+
console.error(`事件 ${v[t]} 处理出错:`, r);
|
|
1532
1694
|
}
|
|
1533
1695
|
});
|
|
1534
1696
|
}
|
|
1535
1697
|
off(t, e) {
|
|
1536
|
-
this.debugLog(`移除事件监听: ${
|
|
1698
|
+
this.debugLog(`移除事件监听: ${v[t]}`), this.listeners[t].delete(e);
|
|
1537
1699
|
}
|
|
1538
1700
|
once(t, e) {
|
|
1539
|
-
this.debugLog(`添加一次性事件监听: ${
|
|
1701
|
+
this.debugLog(`添加一次性事件监听: ${v[t]}`);
|
|
1540
1702
|
const s = (r) => {
|
|
1541
1703
|
e(r), this.off(t, s);
|
|
1542
1704
|
};
|
|
@@ -1552,7 +1714,7 @@ class M {
|
|
|
1552
1714
|
this.debugMode && console.log(`[EventEmitter] ${t}`, e || "");
|
|
1553
1715
|
}
|
|
1554
1716
|
}
|
|
1555
|
-
class
|
|
1717
|
+
class k {
|
|
1556
1718
|
//#region private static members
|
|
1557
1719
|
static OPERATORS = /* @__PURE__ */ new Set(["+", "-", "*", "/"]);
|
|
1558
1720
|
static VALID_CHARS_REG = /^[0-9+\-*/().\s]+$/;
|
|
@@ -1616,7 +1778,7 @@ class b {
|
|
|
1616
1778
|
static EXPRESSION_REG = new RegExp("(?<!\\d)-?\\d*\\.?\\d+|[+\\-*/()]", "g");
|
|
1617
1779
|
static toArr(t) {
|
|
1618
1780
|
this.validateExpression(t);
|
|
1619
|
-
const e = t.match(
|
|
1781
|
+
const e = t.match(k.EXPRESSION_REG);
|
|
1620
1782
|
if (!e)
|
|
1621
1783
|
throw new Error("Invalid expression format");
|
|
1622
1784
|
return e.filter((s) => s.trim() !== "").map((s) => {
|
|
@@ -1645,7 +1807,7 @@ class b {
|
|
|
1645
1807
|
static evaluatePostfix(t) {
|
|
1646
1808
|
if (!t.length)
|
|
1647
1809
|
throw new Error("Postfix expression cannot be empty");
|
|
1648
|
-
typeof t == "string" && (t =
|
|
1810
|
+
typeof t == "string" && (t = k.toArr(t));
|
|
1649
1811
|
const e = new O();
|
|
1650
1812
|
for (const s of t)
|
|
1651
1813
|
if (this.FLOAT_NUM_REG.test(s))
|
|
@@ -1659,7 +1821,7 @@ class b {
|
|
|
1659
1821
|
return e.pop() ?? 0;
|
|
1660
1822
|
}
|
|
1661
1823
|
}
|
|
1662
|
-
class
|
|
1824
|
+
class U {
|
|
1663
1825
|
static isMatchingPair(t, e) {
|
|
1664
1826
|
return t === "(" && e === ")" || t === "{" && e === "}" || t === "[" && e === "]";
|
|
1665
1827
|
}
|
|
@@ -1689,58 +1851,59 @@ class z {
|
|
|
1689
1851
|
return e.isEmpty();
|
|
1690
1852
|
}
|
|
1691
1853
|
static findPath(t, e, s) {
|
|
1692
|
-
const r = t.length, i = t[0].length, n =
|
|
1854
|
+
const r = t.length, i = t[0].length, n = U.arr_2d_init(r, i, !1), a = new O(), c = [
|
|
1693
1855
|
[-1, 0],
|
|
1694
1856
|
[0, 1],
|
|
1695
1857
|
[1, 0],
|
|
1696
1858
|
[0, -1]
|
|
1697
1859
|
];
|
|
1698
|
-
function
|
|
1699
|
-
if (
|
|
1860
|
+
function d(l, h) {
|
|
1861
|
+
if (l < 0 || l >= r || h < 0 || h >= i || t[l][h] === 1 || n[l][h])
|
|
1700
1862
|
return !1;
|
|
1701
|
-
if (t[
|
|
1702
|
-
return a.push([
|
|
1703
|
-
n[
|
|
1704
|
-
for (const [
|
|
1705
|
-
const I =
|
|
1706
|
-
if (
|
|
1863
|
+
if (t[l][h] === 2)
|
|
1864
|
+
return a.push([l, h]), !0;
|
|
1865
|
+
n[l][h] = !0, a.push([l, h]);
|
|
1866
|
+
for (const [p, m] of c) {
|
|
1867
|
+
const I = l + p, R = h + m;
|
|
1868
|
+
if (d(I, R))
|
|
1707
1869
|
return !0;
|
|
1708
1870
|
}
|
|
1709
1871
|
return a.pop(), !1;
|
|
1710
1872
|
}
|
|
1711
|
-
return
|
|
1873
|
+
return d(e, s), a;
|
|
1712
1874
|
}
|
|
1713
1875
|
}
|
|
1714
1876
|
export {
|
|
1715
|
-
|
|
1716
|
-
|
|
1877
|
+
et as Arr,
|
|
1878
|
+
X as ArrQueue,
|
|
1717
1879
|
O as ArrStack,
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1880
|
+
at as BitPerm,
|
|
1881
|
+
ot as Color,
|
|
1882
|
+
A as DateEx,
|
|
1883
|
+
B as Dictionary,
|
|
1884
|
+
b as Emitter,
|
|
1885
|
+
k as Expression,
|
|
1886
|
+
tt as Func,
|
|
1887
|
+
K as Graph,
|
|
1888
|
+
Y as LRU,
|
|
1889
|
+
y as Line,
|
|
1890
|
+
Z as LinkedList,
|
|
1891
|
+
x as Log,
|
|
1892
|
+
M as Matrix,
|
|
1893
|
+
J as MaxHeap,
|
|
1894
|
+
st as MemoizeMap,
|
|
1895
|
+
H as MinHeap,
|
|
1896
|
+
W as MinStack,
|
|
1897
|
+
f as Num,
|
|
1898
|
+
rt as Obj,
|
|
1899
|
+
Q as ObjQueue,
|
|
1900
|
+
j as ObjStack,
|
|
1901
|
+
u as Point,
|
|
1902
|
+
it as Reg,
|
|
1903
|
+
nt as Roman,
|
|
1904
|
+
U as StackApplication,
|
|
1905
|
+
S as Str,
|
|
1906
|
+
F as TrafficLight,
|
|
1907
|
+
g as Triangle,
|
|
1745
1908
|
w as Vector
|
|
1746
1909
|
};
|