jc-structure 0.2.15 → 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.
@@ -1,4 +1,4 @@
1
- class G {
1
+ class X {
2
2
  items = [];
3
3
  head = 0;
4
4
  tail = 0;
@@ -28,7 +28,7 @@ class G {
28
28
  return this.isEmpty() ? "Queue: (0) []" : `Queue: (${this.size()}) [${this.front()} ...]`;
29
29
  }
30
30
  }
31
- class B {
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 _ {
159
159
  return this.isEmpty() ? "Stack: (0) []" : `Stack: (${this.size()}) [ ${this.peek()} ...]`;
160
160
  }
161
161
  }
162
- class X {
162
+ class W {
163
163
  stack = [];
164
164
  minStack = [];
165
165
  push(t) {
@@ -188,13 +188,13 @@ class X {
188
188
  return this.isEmpty() ? "Stack: (0) []" : `Stack: (${this.size()}) [ ${this.peek()} ...]`;
189
189
  }
190
190
  }
191
- function T(h, t) {
192
- return h === t ? 0 : h < t ? -1 : 1;
191
+ function D(o, t) {
192
+ return o === t ? 0 : o < t ? -1 : 1;
193
193
  }
194
194
  class E {
195
195
  heap = [];
196
196
  compareFn;
197
- constructor(t = 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 F extends E {
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 F extends E {
245
245
  E.swap(this.heap, e, t), t = e, e = E.getParentIndex(t);
246
246
  }
247
247
  }
248
- class j extends F {
249
- constructor(t = (e, s) => T(s, e)) {
248
+ class J extends H {
249
+ constructor(t = (e, s) => D(s, e)) {
250
250
  super(t);
251
251
  }
252
252
  }
253
- function U(h) {
254
- return { value: h };
253
+ function V(o) {
254
+ return { value: o };
255
255
  }
256
- class Q {
256
+ class Y {
257
257
  capacity;
258
258
  length = 0;
259
259
  head = null;
@@ -283,15 +283,15 @@ class Q {
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 = U(e), this.length++, this.prepend(s), this.trimCache(), this.lookup.set(t, s), this.reverseLookup);
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 N {
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 W {
294
+ class Z {
295
295
  count = 0;
296
296
  head = null;
297
297
  tail = null;
@@ -350,7 +350,7 @@ class W {
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 N(t);
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 W {
374
374
  return this.count++, !0;
375
375
  }
376
376
  push(t) {
377
- const e = new N(t);
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 W {
439
439
  return t;
440
440
  }
441
441
  }
442
- class H {
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 C(h, t = { emptyString: !1, zeroNumber: !1 }) {
450
- return h == null ? !(t.emptyString && h === "" || t.zeroNumber && h === 0) : !1;
449
+ function $(o, t = { emptyString: !1, zeroNumber: !1 }) {
450
+ return o == null ? !(t.emptyString && o === "" || t.zeroNumber && o === 0) : !1;
451
451
  }
452
- class V {
452
+ class B {
453
453
  table = [];
454
454
  constructor() {
455
455
  }
@@ -460,15 +460,15 @@ class V {
460
460
  return -1;
461
461
  }
462
462
  set(t, e) {
463
- if (C(t))
463
+ if ($(t))
464
464
  throw new Error("key is required");
465
- if (C(e))
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 H(t, e);
471
+ const s = new G(t, e);
472
472
  this.table.push(s);
473
473
  }
474
474
  }
@@ -519,12 +519,12 @@ class V {
519
519
  return t = t.slice(0, -1), t;
520
520
  }
521
521
  }
522
- class J {
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 V();
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 S {
607
+ class M {
608
608
  _matrix;
609
609
  static zero(t, e) {
610
- return new S(
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 S(this._matrix.map((e) => e.map((s) => s * t)));
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 S(
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 S(
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 = S.zero(this.row, t.col);
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++)
@@ -733,12 +733,12 @@ class y {
733
733
  }
734
734
  static getIntersection(t, e, s = y.EPSILON) {
735
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, f = e.p1.y, l = e.p2.x, o = e.p2.y, p = (r - n) * (f - o) - (i - a) * (c - l);
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
737
  if (Math.abs(p) < s) return null;
738
- const m = ((r - c) * (f - o) - (i - f) * (c - l)) / p, x = -((r - n) * (i - f) - (i - a) * (r - c)) / p;
739
- if (m >= 0 && m <= 1 && x >= 0 && x <= 1) {
740
- const P = r + m * (n - r), q = i + m * (a - i);
741
- return new u(P, q);
738
+ const m = ((r - c) * (d - h) - (i - d) * (c - l)) / p, I = -((r - n) * (i - d) - (i - a) * (r - c)) / p;
739
+ if (m >= 0 && m <= 1 && I >= 0 && I <= 1) {
740
+ const R = r + m * (n - r), q = i + m * (a - i);
741
+ return new u(R, q);
742
742
  }
743
743
  return null;
744
744
  }
@@ -746,13 +746,13 @@ class y {
746
746
  return y.getIntersection(t, e) !== null;
747
747
  }
748
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, f = n * n + a * a;
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
750
  let l = -1;
751
- f > s && (l = c / f);
752
- let o, p;
753
- l < 0 ? (o = t.p1.x, p = t.p1.y) : l > 1 ? (o = t.p2.x, p = t.p2.y) : (o = t.p1.x + l * n, p = t.p1.y + l * a);
754
- const m = e.x - o, x = e.y - p;
755
- return Math.hypot(m + x);
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;
755
+ return Math.hypot(m + I);
756
756
  }
757
757
  p1;
758
758
  p2;
@@ -787,31 +787,31 @@ class y {
787
787
  return this.p2;
788
788
  }
789
789
  }
790
- class L {
790
+ class N {
791
791
  static EPSILON = 1e-10;
792
792
  name;
793
793
  constructor(t) {
794
794
  this.name = t;
795
795
  }
796
796
  }
797
- class d extends L {
797
+ class g extends N {
798
798
  static isValid(t, e, s) {
799
799
  return t <= 0 || e <= 0 || s <= 0 ? !1 : t + e > s && t + s > e && e + s > t;
800
800
  }
801
801
  static area(t, e, s) {
802
- if (!d.isValid(t, e, s))
802
+ if (!g.isValid(t, e, s))
803
803
  throw new Error("Invalid triangle");
804
804
  const r = (t + e + s) / 2;
805
805
  return Math.sqrt(r * (r - t) * (r - e) * (r - s));
806
806
  }
807
807
  static getType(t, e, s) {
808
- if (!d.isValid(t, e, s))
808
+ if (!g.isValid(t, e, s))
809
809
  throw new Error("Invalid triangle sides");
810
- const r = [t, e, s].sort((c, f) => c - f), [i, n, a] = r;
811
- return Math.abs(i - n) < d.EPSILON && Math.abs(n - a) < d.EPSILON ? "equilateral" : Math.abs(i - n) < d.EPSILON || Math.abs(n - a) < d.EPSILON ? "isosceles" : "scalene";
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";
812
812
  }
813
813
  static getAngles(t, e, s) {
814
- if (!d.isValid(t, e, s))
814
+ if (!g.isValid(t, e, s))
815
815
  throw new Error("Invalid triangle sides");
816
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;
817
817
  return [r, i, n];
@@ -827,7 +827,7 @@ class d extends L {
827
827
  areCollinear() {
828
828
  return Math.abs(
829
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)
830
- ) < L.EPSILON;
830
+ ) < N.EPSILON;
831
831
  }
832
832
  get side() {
833
833
  return [
@@ -837,19 +837,19 @@ class d extends L {
837
837
  ];
838
838
  }
839
839
  perimeter() {
840
- return d.isValid(this.side[0], this.side[1], this.side[2]), this.side.reduce((t, e) => t + e, 0);
840
+ return g.isValid(this.side[0], this.side[1], this.side[2]), this.side.reduce((t, e) => t + e, 0);
841
841
  }
842
842
  area() {
843
843
  const [t, e, s] = this.side;
844
- return d.area(t, e, s);
844
+ return g.area(t, e, s);
845
845
  }
846
846
  get type() {
847
847
  const [t, e, s] = this.side;
848
- return d.getType(t, e, s);
848
+ return g.getType(t, e, s);
849
849
  }
850
850
  get angles() {
851
851
  const [t, e, s] = this.side;
852
- return d.getAngles(t, e, s);
852
+ return g.getAngles(t, e, s);
853
853
  }
854
854
  get centroid() {
855
855
  return new u(
@@ -863,29 +863,29 @@ class d extends L {
863
863
  }
864
864
  get circumcenter() {
865
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));
866
- if (Math.abs(t) < d.EPSILON)
866
+ if (Math.abs(t) < g.EPSILON)
867
867
  throw new Error("Cannot calculate circumcenter for collinear points");
868
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;
869
869
  return new u(e, s);
870
870
  }
871
871
  containsPoint(t) {
872
- const e = d.area(
872
+ const e = g.area(
873
873
  u.distance(t, this.p1),
874
874
  u.distance(t, this.p2),
875
875
  u.distance(this.p1, this.p2)
876
- ), s = d.area(
876
+ ), s = g.area(
877
877
  u.distance(t, this.p2),
878
878
  u.distance(t, this.p3),
879
879
  u.distance(this.p2, this.p3)
880
- ), r = d.area(
880
+ ), r = g.area(
881
881
  u.distance(t, this.p3),
882
882
  u.distance(t, this.p1),
883
883
  u.distance(this.p3, this.p1)
884
884
  );
885
- return Math.abs(e + s + r - this.area()) < d.EPSILON;
885
+ return Math.abs(e + s + r - this.area()) < g.EPSILON;
886
886
  }
887
887
  }
888
- class Y {
888
+ class tt {
889
889
  static sleep(t) {
890
890
  return new Promise((e) => setTimeout(e, t));
891
891
  }
@@ -909,7 +909,7 @@ class Y {
909
909
  return t.prototype.constructor = s, s;
910
910
  }
911
911
  }
912
- class Z {
912
+ class et {
913
913
  static groupBy(t, e) {
914
914
  if (!e)
915
915
  throw new Error("generateKey is required");
@@ -955,23 +955,23 @@ class Z {
955
955
  return e;
956
956
  }
957
957
  }
958
- function R(h) {
959
- return h !== null && (typeof h == "object" || typeof h == "function");
958
+ function P(o) {
959
+ return o !== null && (typeof o == "object" || typeof o == "function");
960
960
  }
961
- class K {
961
+ class st {
962
962
  map = /* @__PURE__ */ new Map();
963
963
  weakMap = /* @__PURE__ */ new WeakMap();
964
964
  set(t, e) {
965
- R(t) ? this.weakMap.set(t, e) : this.map.set(t, e);
965
+ P(t) ? this.weakMap.set(t, e) : this.map.set(t, e);
966
966
  }
967
967
  get(t) {
968
- return R(t) ? this.weakMap.get(t) : this.map.get(t);
968
+ return P(t) ? this.weakMap.get(t) : this.map.get(t);
969
969
  }
970
970
  has(t) {
971
- return R(t) ? this.weakMap.has(t) : this.map.has(t);
971
+ return P(t) ? this.weakMap.has(t) : this.map.has(t);
972
972
  }
973
973
  }
974
- class tt {
974
+ class rt {
975
975
  static jsonClone(t) {
976
976
  try {
977
977
  return JSON.parse(JSON.stringify(t));
@@ -1041,41 +1041,41 @@ class tt {
1041
1041
  return r;
1042
1042
  }
1043
1043
  }
1044
- const $ = {
1044
+ const T = {
1045
1045
  date: "yyyy-MM-dd",
1046
1046
  datetime: "yyyy-MM-dd HH:mm:ss",
1047
1047
  time: "HH:mm:ss",
1048
1048
  iso: "yyyy-MM-ddTHH:mm:ss.SSS"
1049
1049
  };
1050
- class v {
1050
+ class A {
1051
1051
  static defaultOptions = {
1052
1052
  paddingZero: !1,
1053
1053
  locale: "en-US"
1054
1054
  };
1055
1055
  static setDefaultOptions(t) {
1056
- v.defaultOptions = { ...v.defaultOptions, ...t };
1056
+ A.defaultOptions = { ...A.defaultOptions, ...t };
1057
1057
  }
1058
1058
  static format(t, e, s = {}) {
1059
- const r = { ...v.defaultOptions, ...s }, i = v.getDateInfo(t, r);
1060
- return v.normalizeFormatter(e)(i);
1059
+ const r = { ...A.defaultOptions, ...s }, i = A.getDateInfo(t, r);
1060
+ return A.normalizeFormatter(e)(i);
1061
1061
  }
1062
1062
  // 获取日期信息
1063
1063
  static getDateInfo(t, e) {
1064
- const s = (o, p = 2) => e.paddingZero ? o.toString().padStart(p, "0") : o.toString(), r = t.getFullYear(), i = t.getMonth() + 1, n = t.getDate(), a = t.getHours(), c = t.getMinutes(), f = t.getSeconds(), l = t.getMilliseconds();
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();
1065
1065
  return {
1066
1066
  year: r,
1067
1067
  month: i,
1068
1068
  day: n,
1069
1069
  hour: a,
1070
1070
  minute: c,
1071
- second: f,
1071
+ second: d,
1072
1072
  millisecond: l,
1073
1073
  yyyy: s(r, 4),
1074
1074
  MM: s(i),
1075
1075
  dd: s(n),
1076
1076
  HH: s(a),
1077
1077
  mm: s(c),
1078
- ss: s(f)
1078
+ ss: s(d)
1079
1079
  };
1080
1080
  }
1081
1081
  static normalizeFormatter(t) {
@@ -1083,7 +1083,7 @@ class v {
1083
1083
  return t;
1084
1084
  if (typeof t != "string")
1085
1085
  throw new Error("Formatter must be a string or function");
1086
- t in $ && (t = $[t]);
1086
+ t in T && (t = T[t]);
1087
1087
  const e = {
1088
1088
  yyyy: "yyyy",
1089
1089
  MM: "MM",
@@ -1108,7 +1108,7 @@ class v {
1108
1108
  return c > 0 ? s > 0 ? `${c}天后` : `${c}天前` : a > 0 ? s > 0 ? `${a}小时后` : `${a}小时前` : n > 0 ? s > 0 ? `${n}分钟后` : `${n}分钟前` : s > 0 ? "刚刚" : "";
1109
1109
  }
1110
1110
  }
1111
- class z {
1111
+ class F {
1112
1112
  lights;
1113
1113
  currentIndex;
1114
1114
  switchTime;
@@ -1118,7 +1118,7 @@ class z {
1118
1118
  { color: "green", latest: 10 },
1119
1119
  { color: "yellow", latest: 3 }
1120
1120
  ];
1121
- constructor(t = z.DEFAULT_LIGHTS) {
1121
+ constructor(t = F.DEFAULT_LIGHTS) {
1122
1122
  this.lights = t, this.currentIndex = 0, this.switchTime = Date.now();
1123
1123
  }
1124
1124
  render(t) {
@@ -1143,7 +1143,7 @@ class z {
1143
1143
  };
1144
1144
  }
1145
1145
  }
1146
- class et {
1146
+ class it {
1147
1147
  static escape(t) {
1148
1148
  return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1149
1149
  }
@@ -1157,7 +1157,7 @@ class et {
1157
1157
  static domain = /^(?:https?:\/\/)?(?:[^\/]+)/i;
1158
1158
  static email = /^\w+([-+.]\w+)*@\w+([-.]\w+)*.\w+([-.]\w+)*$/;
1159
1159
  }
1160
- class st {
1160
+ class nt {
1161
1161
  static ROMAN_MAP = /* @__PURE__ */ new Map([
1162
1162
  ["M", 1e3],
1163
1163
  ["CM", 900],
@@ -1208,7 +1208,7 @@ class st {
1208
1208
  return e;
1209
1209
  }
1210
1210
  }
1211
- class g {
1211
+ class f {
1212
1212
  static ensurePositiveInteger(t, e = 0) {
1213
1213
  if (!Number.isInteger(t) || t <= e)
1214
1214
  throw new Error(
@@ -1222,19 +1222,19 @@ class g {
1222
1222
  throw new RangeError(`n must be in the range of ${s} to ${r}`);
1223
1223
  }
1224
1224
  static consecutiveSum(t) {
1225
- return g.handleNumRange(t, !0, 0, 1e8), t * (t + 1) / 2;
1225
+ return f.handleNumRange(t, !0, 0, 1e8), t * (t + 1) / 2;
1226
1226
  }
1227
1227
  static consecutiveSquaresSum(t) {
1228
- return g.handleNumRange(t, !0, 0, 1e6), t * (t + 1) * (2 * t + 1) / 6;
1228
+ return f.handleNumRange(t, !0, 0, 1e6), t * (t + 1) * (2 * t + 1) / 6;
1229
1229
  }
1230
1230
  static consecutivecubesSum(t) {
1231
- return g.handleNumRange(t, !0, 0, 1e4), t * (t + 1) * (2 * t + 1) * (3 * t * t + 3 * t - 1) / 30;
1231
+ return f.handleNumRange(t, !0, 0, 1e4), t * (t + 1) * (2 * t + 1) * (3 * t * t + 3 * t - 1) / 30;
1232
1232
  }
1233
1233
  static clamp(t, e, s) {
1234
1234
  return s == null ? Math.min(t, e) : Math.min(Math.max(t, e), s);
1235
1235
  }
1236
1236
  static factorial(t) {
1237
- if (g.handleNumRange(t, !0, 0, 1e3), t < 2)
1237
+ if (f.handleNumRange(t, !0, 0, 1e3), t < 2)
1238
1238
  return 1;
1239
1239
  let e = 1;
1240
1240
  for (let s = 2; s <= t; s++)
@@ -1242,10 +1242,10 @@ class g {
1242
1242
  return e;
1243
1243
  }
1244
1244
  static fibonacci(t, e = 1, s = 1) {
1245
- return g.handleNumRange(t, !0, 0, 1e3), t < 2 ? s : this.fibonacci(t - 1, s, s + e);
1245
+ return f.handleNumRange(t, !0, 0, 1e3), t < 2 ? s : this.fibonacci(t - 1, s, s + e);
1246
1246
  }
1247
1247
  static fibonacciIterative(t) {
1248
- if (g.handleNumRange(t, !0, 0, 1e3), t < 2) return t;
1248
+ if (f.handleNumRange(t, !0, 0, 1e3), t < 2) return t;
1249
1249
  let e = 0, s = 1;
1250
1250
  for (let r = 2; r <= t; r++)
1251
1251
  [e, s] = [s, (e + s) % 1000000007];
@@ -1255,13 +1255,13 @@ class g {
1255
1255
  return Math.abs(t - e) < s;
1256
1256
  }
1257
1257
  static fastPower(t, e) {
1258
- if (g.handleNumRange(e, !0, 0, 10), g.handleNumRange(t, !1, 0, 1e3), t === 0) return 0;
1258
+ if (f.handleNumRange(e, !0, 0, 10), f.handleNumRange(t, !1, 0, 1e3), t === 0) return 0;
1259
1259
  if (e === 0) return 1;
1260
1260
  const s = this.fastPower(t, e >> 1);
1261
1261
  return e % 2 === 0 ? s * s : s * s * t;
1262
1262
  }
1263
1263
  static fastSqrt(t) {
1264
- if (g.handleNumRange(t, !1, 0, 1e8), typeof BigInt > "u")
1264
+ if (f.handleNumRange(t, !1, 0, 1e8), typeof BigInt > "u")
1265
1265
  return Math.sqrt(t);
1266
1266
  const e = 0.5 * t, s = new ArrayBuffer(8);
1267
1267
  new Float64Array(s)[0] = t;
@@ -1277,22 +1277,19 @@ class g {
1277
1277
  return [];
1278
1278
  if (e < 0 || !Number.isInteger(e))
1279
1279
  throw new Error("Precision must be a non-negative integer");
1280
- const s = t.reduce((o, p) => o + p, 0);
1280
+ const s = t.reduce((h, p) => h + p, 0);
1281
1281
  if (s === 0)
1282
1282
  return t.map(() => "0%");
1283
- const i = 100 * Math.pow(10, e), n = t.map((o) => o / s * i), a = n.map((o) => Math.floor(o)), c = n.map((o, p) => o - a[p]);
1284
- let f = a.reduce((o, p) => o + p, 0), l = i - f;
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
1285
  for (; l > 0; ) {
1286
- let o = -1, p = -1;
1286
+ let h = -1, p = -1;
1287
1287
  for (let m = 0; m < c.length; m++)
1288
- c[m] > p && (p = c[m], o = m);
1289
- if (o === -1) break;
1290
- a[o]++, c[o] = 0, l--;
1288
+ c[m] > p && (p = c[m], h = m);
1289
+ if (h === -1) break;
1290
+ a[h]++, c[h] = 0, l--;
1291
1291
  }
1292
- return a.map((o) => `${(o / i * 100).toFixed(e)}%`);
1293
- }
1294
- static gcd(t, e) {
1295
- return e === 0 ? t : this.gcd(e, t % e);
1292
+ return a.map((h) => `${(h / i * 100).toFixed(e)}%`);
1296
1293
  }
1297
1294
  static isValidPositiveInteger(t) {
1298
1295
  return Number.isInteger(t) && t > 0 && t <= Number.MAX_SAFE_INTEGER;
@@ -1304,7 +1301,7 @@ class g {
1304
1301
  return t % 2 === 1 || t % 2 === -1;
1305
1302
  }
1306
1303
  static isPrime(t) {
1307
- if (g.ensurePositiveInteger(t, 1), t == 2 || t == 3 || t == 5 || t == 7)
1304
+ if (f.ensurePositiveInteger(t, 1), t == 2 || t == 3 || t == 5 || t == 7)
1308
1305
  return !0;
1309
1306
  if (t % 2 === 0 || t % 3 === 0 || t % 5 === 0 || t % 7 === 0)
1310
1307
  return !1;
@@ -1354,6 +1351,9 @@ class g {
1354
1351
  );
1355
1352
  return e <= t && t < s;
1356
1353
  }
1354
+ static gcd(t, e) {
1355
+ return e === 0 ? t : f.gcd(e, t % e);
1356
+ }
1357
1357
  static lcm(t, e) {
1358
1358
  return t * e / this.gcd(t, e);
1359
1359
  }
@@ -1386,15 +1386,19 @@ class g {
1386
1386
  static getPythagoreanTriple(t) {
1387
1387
  if (t <= 0 || !Number.isInteger(t))
1388
1388
  throw new Error("n must be a positive integer");
1389
- if (g.isOdd(t)) {
1389
+ if (f.isOdd(t)) {
1390
1390
  const s = t * t;
1391
1391
  return [t, (s - 1) / 2, (s + 1) / 2];
1392
1392
  }
1393
1393
  const e = t / 2;
1394
1394
  return [t, e * e - 1, e * e + 1];
1395
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
+ }
1396
1400
  }
1397
- class rt {
1401
+ class at {
1398
1402
  static READ = 1;
1399
1403
  static WRITE = 2;
1400
1404
  static SHARE = 4;
@@ -1413,7 +1417,7 @@ class rt {
1413
1417
  return t ^ e;
1414
1418
  }
1415
1419
  }
1416
- class M {
1420
+ class S {
1417
1421
  static frequencyStatistics(t) {
1418
1422
  return [...t].reduce(
1419
1423
  (e, s) => (e[s] = (e[s] || 0) + 1, e),
@@ -1482,7 +1486,7 @@ class M {
1482
1486
  return e;
1483
1487
  }
1484
1488
  static pointAt(t, e) {
1485
- if (e >= M.pointLength(t)) return;
1489
+ if (e >= S.pointLength(t)) return;
1486
1490
  let s = 0;
1487
1491
  for (let r = 0, i = t.length; r < i; ) {
1488
1492
  const n = t.codePointAt(r);
@@ -1492,10 +1496,10 @@ class M {
1492
1496
  r += n > 65535 ? 2 : 1, s++;
1493
1497
  }
1494
1498
  }
1495
- static sliceByPoint(t, e, s = M.pointLength(t)) {
1499
+ static sliceByPoint(t, e, s = S.pointLength(t)) {
1496
1500
  let r = "";
1497
1501
  for (let i = e; i < s; i++)
1498
- r += M.pointAt(t, i);
1502
+ r += S.pointAt(t, i);
1499
1503
  return r;
1500
1504
  }
1501
1505
  static capitalize(t) {
@@ -1508,7 +1512,7 @@ class M {
1508
1512
  return t.length <= e ? t : t.slice(0, e - s.length) + s;
1509
1513
  }
1510
1514
  static isPalindrome(t) {
1511
- return t.toLowerCase().replace(/[^a-z0-9]/g, "") === M.reverse(t);
1515
+ return t.toLowerCase().replace(/[^a-z0-9]/g, "") === S.reverse(t);
1512
1516
  }
1513
1517
  static count(t, e) {
1514
1518
  const s = e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -1521,7 +1525,7 @@ class M {
1521
1525
  return t.replace(/[A-Z]/g, (e) => `_${e.toLowerCase()}`);
1522
1526
  }
1523
1527
  }
1524
- class it {
1528
+ class ot {
1525
1529
  static isValidHex(t) {
1526
1530
  return /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(t);
1527
1531
  }
@@ -1529,28 +1533,130 @@ class it {
1529
1533
  return /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.test(t);
1530
1534
  }
1531
1535
  }
1532
- class A {
1533
- static basePriunt(t, e = {}) {
1534
- const { title: s = "", color: r = "#909399", fontSize: i = "16px" } = e, n = s ? `background-color:${r};border:1px solid ${r};border-radius:3px 0 0 3px;padding:5px;color:#fff;font-size:${i};font-weight:bold;line-height:1.5;` : "", a = `border:1px solid ${r};color:${r};font-size:${i};padding:5px;border-radius:0 3px 3px 0;padding-right:30px;line-height:1.5;`;
1535
- console.log(`%c ${s} %c ${t}`, n, a);
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
+ );
1536
1583
  }
1537
- static success(t) {
1538
- return A.basePriunt(t, { title: "success", color: "#67C23A" });
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);
1539
1587
  }
1540
- static error(t) {
1541
- return A.basePriunt(t, { title: "error", color: "#F56C6C" });
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);
1542
1644
  }
1543
- static warning(t) {
1544
- return A.basePriunt(t, { title: "warning", color: "#E6A23C" });
1645
+ static timeEnd(t) {
1646
+ this.shouldLog() && console.timeEnd(t);
1545
1647
  }
1546
- static normal(t) {
1547
- return A.basePriunt(t, { title: "normal", color: "#909399" });
1648
+ static group(t, e = !1) {
1649
+ this.shouldLog() && (e ? console.groupCollapsed(t) : console.group(t));
1548
1650
  }
1549
- static primary(t) {
1550
- return A.basePriunt(t, { title: "primary", color: "#409EFF" });
1651
+ static groupEnd() {
1652
+ this.shouldLog() && console.groupEnd();
1551
1653
  }
1654
+ static clear() {
1655
+ this.shouldLog() && console.clear();
1656
+ }
1657
+ //#endregion
1552
1658
  }
1553
- const I = {
1659
+ const v = {
1554
1660
  AUTH_UNAUTHORIZED: "未授权事件",
1555
1661
  AUTH_LOGIN_SUCCESS: "登录成功事件",
1556
1662
  AUTH_LOGOUT: "注销事件",
@@ -1567,7 +1673,7 @@ class b {
1567
1673
  listeners = {};
1568
1674
  debugMode;
1569
1675
  constructor(t = !1) {
1570
- this.debugMode = t, Object.keys(I).forEach(
1676
+ this.debugMode = t, Object.keys(v).forEach(
1571
1677
  (e) => {
1572
1678
  this.listeners[e] = /* @__PURE__ */ new Set();
1573
1679
  }
@@ -1577,22 +1683,22 @@ class b {
1577
1683
  return b.instance || (b.instance = new b(t)), b.instance;
1578
1684
  }
1579
1685
  on(t, e) {
1580
- this.debugLog(`添加事件监听: ${I[t]}`), this.listeners[t].add(e);
1686
+ this.debugLog(`添加事件监听: ${v[t]}`), this.listeners[t].add(e);
1581
1687
  }
1582
1688
  emit(t, e) {
1583
- this.debugLog(`触发事件: ${I[t]}`, e), this.listeners[t].forEach((s) => {
1689
+ this.debugLog(`触发事件: ${v[t]}`, e), this.listeners[t].forEach((s) => {
1584
1690
  try {
1585
1691
  s(e);
1586
1692
  } catch (r) {
1587
- console.error(`事件 ${I[t]} 处理出错:`, r);
1693
+ console.error(`事件 ${v[t]} 处理出错:`, r);
1588
1694
  }
1589
1695
  });
1590
1696
  }
1591
1697
  off(t, e) {
1592
- this.debugLog(`移除事件监听: ${I[t]}`), this.listeners[t].delete(e);
1698
+ this.debugLog(`移除事件监听: ${v[t]}`), this.listeners[t].delete(e);
1593
1699
  }
1594
1700
  once(t, e) {
1595
- this.debugLog(`添加一次性事件监听: ${I[t]}`);
1701
+ this.debugLog(`添加一次性事件监听: ${v[t]}`);
1596
1702
  const s = (r) => {
1597
1703
  e(r), this.off(t, s);
1598
1704
  };
@@ -1715,7 +1821,7 @@ class k {
1715
1821
  return e.pop() ?? 0;
1716
1822
  }
1717
1823
  }
1718
- class D {
1824
+ class U {
1719
1825
  static isMatchingPair(t, e) {
1720
1826
  return t === "(" && e === ")" || t === "{" && e === "}" || t === "[" && e === "]";
1721
1827
  }
@@ -1745,59 +1851,59 @@ class D {
1745
1851
  return e.isEmpty();
1746
1852
  }
1747
1853
  static findPath(t, e, s) {
1748
- const r = t.length, i = t[0].length, n = D.arr_2d_init(r, i, !1), a = new O(), c = [
1854
+ const r = t.length, i = t[0].length, n = U.arr_2d_init(r, i, !1), a = new O(), c = [
1749
1855
  [-1, 0],
1750
1856
  [0, 1],
1751
1857
  [1, 0],
1752
1858
  [0, -1]
1753
1859
  ];
1754
- function f(l, o) {
1755
- if (l < 0 || l >= r || o < 0 || o >= i || t[l][o] === 1 || n[l][o])
1860
+ function d(l, h) {
1861
+ if (l < 0 || l >= r || h < 0 || h >= i || t[l][h] === 1 || n[l][h])
1756
1862
  return !1;
1757
- if (t[l][o] === 2)
1758
- return a.push([l, o]), !0;
1759
- n[l][o] = !0, a.push([l, o]);
1863
+ if (t[l][h] === 2)
1864
+ return a.push([l, h]), !0;
1865
+ n[l][h] = !0, a.push([l, h]);
1760
1866
  for (const [p, m] of c) {
1761
- const x = l + p, P = o + m;
1762
- if (f(x, P))
1867
+ const I = l + p, R = h + m;
1868
+ if (d(I, R))
1763
1869
  return !0;
1764
1870
  }
1765
1871
  return a.pop(), !1;
1766
1872
  }
1767
- return f(e, s), a;
1873
+ return d(e, s), a;
1768
1874
  }
1769
1875
  }
1770
1876
  export {
1771
- Z as Arr,
1772
- G as ArrQueue,
1877
+ et as Arr,
1878
+ X as ArrQueue,
1773
1879
  O as ArrStack,
1774
- rt as BitPerm,
1775
- it as Color,
1776
- v as DateEx,
1777
- V as Dictionary,
1880
+ at as BitPerm,
1881
+ ot as Color,
1882
+ A as DateEx,
1883
+ B as Dictionary,
1778
1884
  b as Emitter,
1779
1885
  k as Expression,
1780
- Y as Func,
1781
- J as Graph,
1782
- Q as LRU,
1886
+ tt as Func,
1887
+ K as Graph,
1888
+ Y as LRU,
1783
1889
  y as Line,
1784
- W as LinkedList,
1785
- A as Log,
1786
- S as Matrix,
1787
- j as MaxHeap,
1788
- K as MemoizeMap,
1789
- F as MinHeap,
1790
- X as MinStack,
1791
- g as Num,
1792
- tt as Obj,
1793
- B as ObjQueue,
1794
- _ as ObjStack,
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,
1795
1901
  u as Point,
1796
- et as Reg,
1797
- st as Roman,
1798
- D as StackApplication,
1799
- M as Str,
1800
- z as TrafficLight,
1801
- d as Triangle,
1902
+ it as Reg,
1903
+ nt as Roman,
1904
+ U as StackApplication,
1905
+ S as Str,
1906
+ F as TrafficLight,
1907
+ g as Triangle,
1802
1908
  w as Vector
1803
1909
  };
@@ -1,2 +1,8 @@
1
- (function(o,P){typeof exports=="object"&&typeof module<"u"?P(exports):typeof define=="function"&&define.amd?define(["exports"],P):(o=typeof globalThis<"u"?globalThis:o||self,P(o["jc-structure"]={}))})(this,(function(o){"use strict";class P{items=[];head=0;tail=0;dequeue(){if(this.isEmpty())return;const t=this.items[this.head];return this.head++,t}enqueue(...t){for(const e of t)Array.isArray(e)?(this.items.push(...e),this.tail+=e.length):(this.items.push(e),this.tail++);return this}front(){return this.isEmpty()?void 0:this.items[this.head]}isEmpty(){return this.head===this.tail}size(){return this.tail-this.head}cleanup(){this.items=[],this.head=0,this.tail=0}toString(){return this.isEmpty()?"Queue: (0) []":`Queue: (${this.size()}) [${this.front()} ...]`}}class V{items={};count=0;lowestCount=0;constructor(){}dequeue(){if(this.isEmpty())return;const t=this.items[this.lowestCount];return delete this.items[this.lowestCount],this.lowestCount++,t}enqueue(...t){if(t.length===0)return this;if(t.length===1){const e=t[0];return Array.isArray(e)?this.batchEnqueue(e):this.enqueueItem(e)}for(const e of t)Array.isArray(e)?this.batchEnqueue(e):this.enqueueItem(e);return this}batchEnqueue(t){return t.filter(s=>this.isValidItem(s)).forEach(s=>{this.isValidItem(s)&&(this.items[this.count]=s,this.count++)}),this}enqueueItem(t){if(!this.isValidItem(t))throw new Error("Invalid item");return this.items[this.count]=t,this.count++,this}isValidItem(t){return t!=null}front(){return this.isEmpty()?void 0:this.items[this.lowestCount]}isEmpty(){return this.size()===0}size(){return this.count-this.lowestCount}cleanup(){this.items={},this.count=0,this.lowestCount=0}toString(){return this.isEmpty()?"Queue: (0) []":`Queue: (${this.size()}) [${this.front()} ...]`}}class R{_arr;constructor(){this._arr=[]}isEmpty(){return this._arr.length===0}cleanup(){this._arr=[]}size(){return this._arr.length}toString(){return this.isEmpty()?"Stack: (0) []":`Stack: (${this.size()}) [${this.peek()}, ...]`}pop(){return this._arr.pop()}push(...t){for(const e of t)Array.isArray(e)?this._arr.push(...e):this._arr.push(e);return this}peek(){return this._arr[this._arr.length-1]}}class G{items={};count=0;constructor(){}pop(){if(this.isEmpty())return;this.count--;const t=this.items[this.count];return delete this.items[this.count],t}push(...t){if(t.length===0)return this;if(t.length===1){const e=t[0];return Array.isArray(e)?this.addItems(e):this.addItem(e)}for(const e of t)Array.isArray(e)?this.addItems(e):this.addItem(e);return this}addItem(t){if(!this.isValidItem(t))throw new Error("Invalid item: item cannot be null or undefined");return this.items[this.count]=t,this.count++,this}addItems(t){return t.filter(s=>this.isValidItem(s)).forEach(s=>{this.items[this.count]=s,this.count++}),this}isValidItem(t){return t!=null}peek(){return this.isEmpty()?void 0:this.items[this.count-1]}isEmpty(){return this.count===0}size(){return this.count}cleanup(){this.items={},this.count=0}toString(){return this.isEmpty()?"Stack: (0) []":`Stack: (${this.size()}) [ ${this.peek()} ...]`}}class B{stack=[];minStack=[];push(t){this.stack.push(t),(this.minStack.length===0||t<=this.minStack[this.minStack.length-1])&&this.minStack.push(t)}pop(){const t=this.stack.pop();return t===this.minStack[this.minStack.length-1]&&this.minStack.pop(),t}peek(){return this.stack[this.stack.length-1]}getMin(){return this.minStack[this.minStack.length-1]}isEmpty(){return this.size()===0}size(){return this.stack.length}clear(){this.stack=[],this.minStack=[]}toString(){return this.isEmpty()?"Stack: (0) []":`Stack: (${this.size()}) [ ${this.peek()} ...]`}}function $(c,t){return c===t?0:c<t?-1:1}class I{heap=[];compareFn;constructor(t=$){this.compareFn=t}static getLeftIndex(t){return 2*t+1}static getRightIndex(t){return 2*t+2}static getParentIndex(t){return t===0?void 0:Math.floor((t-1)/2)}static swap(t,e,s){[t[e],t[s]]=[t[s],t[e]]}find(){return this.isEmpty()?void 0:this.heap[0]}size(){return this.heap.length}isEmpty(){return this.size()===0}cleanup(){this.heap=[]}toString(){return this.heap.toString()}}class z extends I{insert(t){return t?!1:(this.heap.push(t),this.siftUp(this.heap.length-1),!0)}extract(){if(this.isEmpty())return;if(this.heap.length===1)return this.heap.shift();const t=this.heap[0];return this.heap[0]=this.heap.pop(),this.siftDown(0),t}siftUp(t){let e=t,s=I.getLeftIndex(e),r=I.getRightIndex(e),i=this.size();s<i&&this.compareFn(this.heap[e],this.heap[s])===-1&&(e=s),r<i&&this.compareFn(this.heap[e],this.heap[r])===1&&(e=r),e!==t&&(I.swap(this.heap,t,e),this.siftUp(e))}siftDown(t){let e=I.getParentIndex(t);for(;t>0&&e&&this.compareFn(this.heap[e],this.heap[t])===1;)I.swap(this.heap,e,t),t=e,e=I.getParentIndex(t)}}class _ extends z{constructor(t=(e,s)=>$(s,e)){super(t)}}function j(c){return{value:c}}class Q{capacity;length=0;head=null;tail=null;lookup=new Map;reverseLookup=new Map;constructor(t=10){this.capacity=t}prepend(t){this.head?(t.next=this.head,this.head.prev=t,this.head=t):this.head=this.tail=t}detach(t){t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),this.head===t&&(this.head=this.head.next||null),this.tail===t&&(this.tail=this.tail.prev||null),t.next=void 0,t.prev=void 0}trimCache(){if(this.length<=this.capacity)return;const t=this.tail;this.detach(t);const e=this.reverseLookup.get(t);this.lookup.delete(e),this.reverseLookup.delete(t),this.length--}get(t){const e=this.lookup.get(t);if(e)return this.detach(e),this.prepend(e),e.value}update(t,e){let s=this.lookup.get(t);s?(this.detach(s),this.prepend(s),s.value=e):(s=j(e),this.length++,this.prepend(s),this.trimCache(),this.lookup.set(t,s),this.reverseLookup)}}class D{constructor(t,e=null,s=null){this.value=t,this.next=e,this.prev=s}}class X{count=0;head=null;tail=null;constructor(t){t&&t.forEach(e=>this.push(e))}[Symbol.iterator](){let t=this.head;return{next(){if(t){const e=t.value;return t=t.next,{value:e,done:!1}}return{value:void 0,done:!0}}}}equals(t,e){if(t===e)return!0;if(t==null||e==null)return!1;if(typeof t=="object"&&typeof e=="object"){if(t.equals&&typeof t.equals=="function")return t.equals(e);const s=Object.keys(t),r=Object.keys(e);return s.length!==r.length?!1:s.every(i=>t[i]===e[i])}return!1}indexOf(t){let e=this.head,s=0;for(;e;){if(this.equals(e.value,t))return s;s++,e=e.next}return-1}getElementAt(t){if(t<0||t>=this.count)return null;if(t>this.count/2){let s=this.tail,r=this.count-1;for(;r>t&&s;)s=s.prev,r--;return s}let e=this.head;for(let s=0;s<t&&e;s++)e=e.next;return e}getValueAt(t){return this.getElementAt(t)?.value}insert(t,e){if(e<0||e>this.count)throw new Error(`Index out of bounds: ${e}`);const s=new D(t);if(e===0)s.next=this.head,this.head&&(this.head.prev=s),this.head=s,this.count===0&&(this.tail=s);else if(e===this.count)s.prev=this.tail,this.tail&&(this.tail.next=s),this.tail=s;else{let r;if(e<this.count/2){r=this.head;for(let i=0;i<e-1&&r;i++)r=r.next}else{r=this.tail;for(let i=this.count-1;i>e-1&&r;i--)r=r.prev}if(r){const i=r.next;s.prev=r,s.next=i,r.next=s,i&&(i.prev=s)}}return this.count++,!0}push(t){const e=new D(t);this.head?this.tail&&(this.tail.next=e,e.prev=this.tail,this.tail=e):(this.head=e,this.tail=e),this.count++}remove(t){let e=this.head,s=this.tail,r=0,i=this.count-1;for(;e&&s;){if(this.equals(e.value,t))return this.removeAt(r);if(this.equals(s.value,t))return this.removeAt(i);if(e=e.next,s=s.prev,r++,i--,r>i)break}return null}removeAt(t){if(t<0||t>=this.count)return null;let e;if(t===0)e=this.head,e&&(this.head=e.next,this.head&&(this.head.prev=null),this.count===1&&(this.tail=null));else if(t===this.count-1)e=this.tail,e&&(this.tail=e.prev,this.tail&&(this.tail.next=null),this.count===1&&(this.head=null));else{if(t<this.count/2){e=this.head;for(let s=0;s<t&&e;s++)e=e.next}else{e=this.tail;for(let s=this.count-1;s>t&&e;s--)e=e.prev}if(e){const s=e.prev,r=e.next;s&&(s.next=r),r&&(r.prev=s)}}return this.count--,e?.value||null}isEmpty(){return this.count===0}size(){return this.count}cleanup(){this.head=null,this.tail=null,this.count=0}toString(){if(this.isEmpty())return"";let t="",e=this.head;for(;e;)t+=JSON.stringify(e.value),e.next&&(t+=","),e=e.next;return t}toArray(){const t=[];let e=this.head;for(;e;)t.push(e.value),e=e.next;return t}}class W{key;value;constructor(t,e){this.key=t,this.value=e}}function q(c,t={emptyString:!1,zeroNumber:!1}){return c==null?!(t.emptyString&&c===""||t.zeroNumber&&c===0):!1}class F{table=[];constructor(){}getItemIndex(t){for(let e=0,s=this.table.length;e<s;e++)if(this.table[e].key===t)return e;return-1}set(t,e){if(q(t))throw new Error("key is required");if(q(e))throw new Error("value is required");if(this.has(t)){let s=this.getItemIndex(t);this.table[s].value=e}else{const s=new W(t,e);this.table.push(s)}}remove(t){if(this.has(t)){let e=this.getItemIndex(t);return this.table.splice(e,1)[0]}}has(t){return this.getItemIndex(t)!==-1}get(t){if(this.has(t)){let e=this.getItemIndex(t);return this.table[e]}}keys(){return this.table.map(t=>t.key)}values(){return this.table.map(t=>t.value)}keyValues(){return this.table.map(t=>[t.key,t.value])}forEach(t){for(let e=0,s=this.size();e<s;e++){let r=this.table[e];if(!t(r.key,r.value))break}}isEmpty(){return!this.size()}size(){return this.table.length}cleanup(){this.table=[]}toString(){let t="";for(let e=0,s=this.table.length;e<s;e++)t+=this.table[e].toString(),t+=",";return t=t.slice(0,-1),t}}class J{isDirected;vertices;adjList;constructor(t=!1){this.isDirected=t,this.vertices=[],this.adjList=new F}addVertex(t){this.vertices.includes(t)||(this.vertices.push(t),this.adjList.set(t,[]))}addEdge(t,e){this.adjList.get(t)||this.addVertex(t),this.adjList.get(e)||this.addVertex(e),this.adjList.get(t)?.value.indexOf(e)===-1&&this.adjList.get(t)?.value.push(e),this.isDirected||this.adjList.get(e)?.value.indexOf(t)===-1&&this.adjList.get(e)?.value.push(t)}getVertices(){return this.vertices}getAdjacencyList(){return this.adjList}toString(){let t="";for(let e=0;e<this.vertices.length;e++)t+=this.vertices[e]+"-->",t+=this.adjList.get(this.vertices[e])?.toString()||"",t+=`
2
- `;return t}}class E{_data;static zero(t){return new E(...Array(t).fill(0))}constructor(...t){this._data=t}get dimension(){return this._data.length}get norm(){return Math.hypot(...this._data)}getItem(t){return this._data[t]}normalize(){const t=this.norm;if(t===0)throw new Error("Cannot normalize a zero vector");const e=this._data.map(s=>s/t);return new E(...e)}add(t){if(this.dimension!==t.dimension)throw new Error("Vectors must have the same dimension to add");const e=this._data.map((s,r)=>s+t._data[r]);return new E(...e)}sub(t){if(this.dimension!==t.dimension)throw new Error("Vectors must have the same dimension to subtract");const e=this._data.map((s,r)=>s-t._data[r]);return new E(...e)}mul(t){return new E(...this._data.map(e=>e*t))}dot(t){if(this.dimension!==t.dimension)throw new Error("Vectors must have the same dimension to dot product");return this._data.reduce((e,s,r)=>e+s*t._data[r],0)}pos(){return this.mul(1)}neg(){return this.mul(-1)}}class x{_matrix;static zero(t,e){return new x(Array.from({length:t},()=>Array.from({length:e},()=>0)))}static rotate(t){const e=t.length;for(let s=0;s<(e+1)/2;s++)for(let r=s;r<e/2;r++){const i=t[e-1-r][s];t[e-1-r][s]=t[e-1-s][e-1-r],t[e-1-s][e-1-r]=t[r][e-1-s],t[r][e-1-s]=t[s][r],t[s][r]=i}return t}constructor(t){this._matrix=t}get shape(){return[this._matrix.length,this._matrix[0].length]}get row(){return this.shape[0]}get col(){return this.shape[1]}get size(){return this.row*this.col}rowVector(t){return new E(...this._matrix[t])}colVector(t){return new E(...this._matrix.map(e=>e[t]))}getItem(t){return this._matrix[t[0]][t[1]]}setItem(t,e){return this._matrix[t[0]][t[1]]=e,this}mul(t){return new x(this._matrix.map(e=>e.map(s=>s*t)))}div(t){return this.mul(1/t)}add(t){if(this.row!==t.row||this.col!==t.col)throw new Error("Matrix dimensions do not match");return new x(this._matrix.map((e,s)=>e.map((r,i)=>r+t.getItem([s,i]))))}sub(t){return this.add(t.neg())}pos(){return this.mul(1)}neg(){return this.mul(-1)}mulVector(t){if(this.col!==t.dimension)throw new Error("Matrix dimensions do not match");return new x(this._matrix.map(e=>e.map((s,r)=>s*t.getItem(r))))}mulMatrix(t){if(this.col!==t.row)throw new Error("Matrix dimensions do not match");const e=x.zero(this.row,t.col);for(let s=0;s<this.row;s++){const r=this.rowVector(s);for(let i=0;i<this.col;i++)e.setItem([s,i],r.dot(t.colVector(i)))}return e}}class l{static distance(t,e){return Math.hypot(e.x-t.x,e.y-t.y)}x;y;constructor(t,e){this.x=t,this.y=e}distanceTo(t){return l.distance(this,t)}static linearInterpolation(t,e,s){if(s<0||s>1)throw new Error("Parameter t must be in the range [0, 1]");const r=t.x*(1-s)+e.x*s,i=t.y*(1-s)+e.y*s;return new l(r,i)}static quadraticBezierInterpolation(t,e,s,r){if(r<0||r>1)throw new Error("Parameter t must be in the range [0, 1]");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;return new l(i,n)}static cubicBezierInterpolation(t,e,s,r,i){if(i<0||i>1)throw new Error("Parameter t must be in the range [0, 1]");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;return new l(n,a)}}class w{static EPSILON=1e-10;static sloped(t,e=w.EPSILON){const s=t.p2.x-t.p1.x,r=t.p2.y-t.p1.y;return Math.abs(s)<e?Math.abs(r)<e?0:null:r/s}static isParallel(t,e,s=w.EPSILON){const r=w.sloped(t),i=w.sloped(e);return r===null&&i===null?!0:r===null||i===null?!1:Math.abs(r-i)<s}static getIntersection(t,e,s=w.EPSILON){if(w.isParallel(t,e))return null;const r=t.p1.x,i=t.p1.y,n=t.p2.x,a=t.p2.y,u=e.p1.x,m=e.p1.y,p=e.p2.x,h=e.p2.y,f=(r-n)*(m-h)-(i-a)*(u-p);if(Math.abs(f)<s)return null;const g=((r-u)*(m-h)-(i-m)*(u-p))/f,O=-((r-n)*(i-m)-(i-a)*(r-u))/f;if(g>=0&&g<=1&&O>=0&&O<=1){const T=r+g*(n-r),nt=i+g*(a-i);return new l(T,nt)}return null}static isIntersecting(t,e){return w.getIntersection(t,e)!==null}static distanceToPoint(t,e,s=w.EPSILON){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,u=r*n+i*a,m=n*n+a*a;let p=-1;m>s&&(p=u/m);let h,f;p<0?(h=t.p1.x,f=t.p1.y):p>1?(h=t.p2.x,f=t.p2.y):(h=t.p1.x+p*n,f=t.p1.y+p*a);const g=e.x-h,O=e.y-f;return Math.hypot(g+O)}p1;p2;constructor(t,e){this.p1=t,this.p2=e}get length(){const t=this.p2.x-this.p1.x,e=this.p2.y-this.p1.y;return Math.sqrt(t*t+e*e)}get midpoint(){const t=(this.p1.x+this.p2.x)/2,e=(this.p1.y+this.p2.y)/2;return new l(t,e)}get angle(){return Math.atan2(this.p2.y-this.p1.y,this.p2.x-this.p1.x)}containsPoint(t,e=w.EPSILON){const s=(t.x-this.p1.x)*(this.p2.y-this.p1.y)-(t.y-this.p1.y)*(this.p2.x-this.p1.x);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}get direction(){const t=this.length;if(t<w.EPSILON)return new l(0,0);const e=(this.p2.x-this.p1.x)/t,s=(this.p2.y-this.p1.y)/t;return new l(e,s)}get start(){return this.p1}get end(){return this.p2}}class H{static EPSILON=1e-10;name;constructor(t){this.name=t}}class d extends H{static isValid(t,e,s){return t<=0||e<=0||s<=0?!1:t+e>s&&t+s>e&&e+s>t}static area(t,e,s){if(!d.isValid(t,e,s))throw new Error("Invalid triangle");const r=(t+e+s)/2;return Math.sqrt(r*(r-t)*(r-e)*(r-s))}static getType(t,e,s){if(!d.isValid(t,e,s))throw new Error("Invalid triangle sides");const r=[t,e,s].sort((u,m)=>u-m),[i,n,a]=r;return Math.abs(i-n)<d.EPSILON&&Math.abs(n-a)<d.EPSILON?"equilateral":Math.abs(i-n)<d.EPSILON||Math.abs(n-a)<d.EPSILON?"isosceles":"scalene"}static getAngles(t,e,s){if(!d.isValid(t,e,s))throw new Error("Invalid triangle sides");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;return[r,i,n]}p1;p2;p3;constructor(t,e,s,r="triangle"){if(super(r),this.p1=t,this.p2=e,this.p3=s,this.areCollinear())throw new Error("Points are collinear, cannot form a triangle")}areCollinear(){return Math.abs((this.p2.x-this.p1.x)*(this.p3.y-this.p1.y)-(this.p3.x-this.p1.x)*(this.p2.y-this.p1.y))<H.EPSILON}get side(){return[l.distance(this.p1,this.p2),l.distance(this.p2,this.p3),l.distance(this.p3,this.p1)]}perimeter(){return d.isValid(this.side[0],this.side[1],this.side[2]),this.side.reduce((t,e)=>t+e,0)}area(){const[t,e,s]=this.side;return d.area(t,e,s)}get type(){const[t,e,s]=this.side;return d.getType(t,e,s)}get angles(){const[t,e,s]=this.side;return d.getAngles(t,e,s)}get centroid(){return new l((this.p1.x+this.p2.x+this.p3.x)/3,(this.p1.y+this.p2.y+this.p3.y)/3)}get incenter(){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;return new l(i,n)}get circumcenter(){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));if(Math.abs(t)<d.EPSILON)throw new Error("Cannot calculate circumcenter for collinear points");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;return new l(e,s)}containsPoint(t){const e=d.area(l.distance(t,this.p1),l.distance(t,this.p2),l.distance(this.p1,this.p2)),s=d.area(l.distance(t,this.p2),l.distance(t,this.p3),l.distance(this.p2,this.p3)),r=d.area(l.distance(t,this.p3),l.distance(t,this.p1),l.distance(this.p3,this.p1));return Math.abs(e+s+r-this.area())<d.EPSILON}}class Y{static sleep(t){return new Promise(e=>setTimeout(e,t))}static binarySearchTemplate(t,e,s){let r=-1,i=t.length,n;for(;i-r>1;)n=i-(i-r)>>1,s(t[n],e)?i=n:r=n;return i}static singleton(t){let e;const s=new Proxy(t,{construct(r,i,n){return e||(e=Reflect.construct(r,i,n)),e}});return t.prototype.constructor=s,s}}class Z{static groupBy(t,e){if(!e)throw new Error("generateKey is required");const s=typeof e=="string"?i=>i[e]:e,r=new Map;for(const[i,n]of t.entries())try{const a=s(n,i,t);if(a==null){console.warn("Invalid key generated for item:",n);continue}const u=r.get(a)??[];u.push(n),r.set(a,u)}catch(a){console.error("Error generating key for item:",n,a)}return Object.fromEntries(r)}static LIS(t){if(!t.length)return[];const e=[[t[0]]];for(let r=1,i=t.length;r<i;r++){const n=t[r];s(n)}function s(r){for(let i=e.length-1;i>=0;i--){const n=e[i],a=n[e[i].length-1];if(a<r){e[i+1]=[...n,r];break}else a>r&&i===0&&(e[i]=[r])}}return e[e.length-1]}static LCP(t){if(!t.length)return"";let e=t[0];for(let s=1;s<t.length;s++)for(;!t[s].startsWith(e);)if(e=e.slice(0,-1),e==="")return"";return e}}function N(c){return c!==null&&(typeof c=="object"||typeof c=="function")}class K{map=new Map;weakMap=new WeakMap;set(t,e){N(t)?this.weakMap.set(t,e):this.map.set(t,e)}get(t){return N(t)?this.weakMap.get(t):this.map.get(t)}has(t){return N(t)?this.weakMap.has(t):this.map.has(t)}}class tt{static jsonClone(t){try{return JSON.parse(JSON.stringify(t))}catch{throw new Error("Object is not JSON cloneable")}}static structureClone(t){return structuredClone(t)}static deepClone(t,e=new WeakMap){if(t==null||typeof t!="object")return t;if(e.has(t))return e.get(t);if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp)return new RegExp(t.source,t.flags);if(t instanceof Map){const n=new Map;e.set(t,n);for(const[a,u]of t)n.set(this.deepClone(a,e),this.deepClone(u,e));return n}if(t instanceof Set){const n=new Set;e.set(t,n);for(const a of t)n.add(this.deepClone(a,e));return n}if(Array.isArray(t)){const n=new Array(t.length);e.set(t,n);for(let a=0,u=t.length;a<u;a++)n[a]=this.deepClone(t[a],e);return n}if(t instanceof ArrayBuffer)return t.slice(0);const s=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];for(const n of s)if(t instanceof n)return new n(t);if(typeof t=="function")return new Proxy(t,{apply(n,a,u){return n.apply(a,u)},get(n,a){if(a in n)return n[a]}});const r=Object.create(Object.getPrototypeOf(t));e.set(t,r);const i=Object.getOwnPropertyDescriptors(t);for(const[n,a]of Object.entries(i))a.value!==void 0&&(a.value=this.deepClone(a.value,e)),Object.defineProperty(r,n,a);return r}}const U={date:"yyyy-MM-dd",datetime:"yyyy-MM-dd HH:mm:ss",time:"HH:mm:ss",iso:"yyyy-MM-ddTHH:mm:ss.SSS"};class S{static defaultOptions={paddingZero:!1,locale:"en-US"};static setDefaultOptions(t){S.defaultOptions={...S.defaultOptions,...t}}static format(t,e,s={}){const r={...S.defaultOptions,...s},i=S.getDateInfo(t,r);return S.normalizeFormatter(e)(i)}static getDateInfo(t,e){const s=(h,f=2)=>e.paddingZero?h.toString().padStart(f,"0"):h.toString(),r=t.getFullYear(),i=t.getMonth()+1,n=t.getDate(),a=t.getHours(),u=t.getMinutes(),m=t.getSeconds(),p=t.getMilliseconds();return{year:r,month:i,day:n,hour:a,minute:u,second:m,millisecond:p,yyyy:s(r,4),MM:s(i),dd:s(n),HH:s(a),mm:s(u),ss:s(m)}}static normalizeFormatter(t){if(typeof t=="function")return t;if(typeof t!="string")throw new Error("Formatter must be a string or function");t in U&&(t=U[t]);const e={yyyy:"yyyy",MM:"MM",dd:"dd",HH:"HH",mm:"mm",ss:"ss",SSS:"SSS"};return s=>{let r=t;for(const[i,n]of Object.entries(e))r=r.replace(new RegExp(i,"g"),String(s[n]||""));return r}}static formatRelative(t,e=new Date){const s=t.getTime()-e.getTime(),r=Math.abs(s),i=Math.floor(r/1e3),n=Math.floor(i/60),a=Math.floor(n/60),u=Math.floor(a/24);return u>0?s>0?`${u}天后`:`${u}天前`:a>0?s>0?`${a}小时后`:`${a}小时前`:n>0?s>0?`${n}分钟后`:`${n}分钟前`:s>0?"刚刚":""}}class L{lights;currentIndex;switchTime;static DEFAULT_LIGHTS=[{color:"red",latest:7},{color:"yellow",latest:3},{color:"green",latest:10},{color:"yellow",latest:3}];constructor(t=L.DEFAULT_LIGHTS){this.lights=t,this.currentIndex=0,this.switchTime=Date.now()}render(t){requestAnimationFrame(this.render.bind(this,t));const e=this.getCurrentLight();t(e)}get current(){return this.lights[this.currentIndex]}get disTime(){return Date.now()-this.switchTime}update(){for(;!(this.disTime<this.current.latest);)this.switchTime+=this.current.latest*1e3,this.currentIndex=(this.currentIndex+1)%this.lights.length}getCurrentLight(){return this.update(),{color:this.current.color,remain:this.current.latest-this.disTime}}}class et{static escape(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}static telephone={loose:/\D?(\d[0-9-]{6,}\d)\D?/g};static consecutiveChars=/(.)\1+/g;static chineseChar=/[\u4e00-\u9fa5]/g;static domain=/^(?:https?:\/\/)?(?:[^\/]+)/i;static email=/^\w+([-+.]\w+)*@\w+([-.]\w+)*.\w+([-.]\w+)*$/}class st{static ROMAN_MAP=new Map([["M",1e3],["CM",900],["D",500],["CD",400],["C",100],["XC",90],["L",50],["XL",40],["X",10],["IX",9],["V",5],["IV",4],["I",1]]);static toInteger(t){if(t.length===0)throw new Error("Input cannot be empty");const e=new Set(["I","V","X","L","C","D","M"]);for(const n of t)if(!e.has(n))throw new Error(`Invalid Roman numeral character: ${n}`);let s=0,r=0;for(;r<t.length;){const n=t.slice(r,r+2);if(this.ROMAN_MAP.has(n))s+=this.ROMAN_MAP.get(n),r+=2;else{const a=t[r],u=this.ROMAN_MAP.get(a);if(!u)throw new Error(`Invalid Roman numeral sequence at position ${r}`);s+=u,r+=1}}if(this.toRoman(s)!==t)throw new Error("Invalid Roman numeral sequence");return s}static toRoman(t){if(t<=0||t>=4e3)throw new Error("Number must be between 1 and 3999");if(!Number.isInteger(t))throw new Error("Number must be an integer");let e="";for(const[s,r]of this.ROMAN_MAP)for(;t>=r;)e+=s,t-=r;return e}}class y{static ensurePositiveInteger(t,e=0){if(!Number.isInteger(t)||t<=e)throw new Error(`n must be a positive integer and greater than ${e}`)}static handleNumRange(t,e=!1,s=Number.MIN_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER){if(e&&!Number.isInteger(t))throw new Error("n must be an integer");if(t<s||t>=r)throw new RangeError(`n must be in the range of ${s} to ${r}`)}static consecutiveSum(t){return y.handleNumRange(t,!0,0,1e8),t*(t+1)/2}static consecutiveSquaresSum(t){return y.handleNumRange(t,!0,0,1e6),t*(t+1)*(2*t+1)/6}static consecutivecubesSum(t){return y.handleNumRange(t,!0,0,1e4),t*(t+1)*(2*t+1)*(3*t*t+3*t-1)/30}static clamp(t,e,s){return s==null?Math.min(t,e):Math.min(Math.max(t,e),s)}static factorial(t){if(y.handleNumRange(t,!0,0,1e3),t<2)return 1;let e=1;for(let s=2;s<=t;s++)e*=s;return e}static fibonacci(t,e=1,s=1){return y.handleNumRange(t,!0,0,1e3),t<2?s:this.fibonacci(t-1,s,s+e)}static fibonacciIterative(t){if(y.handleNumRange(t,!0,0,1e3),t<2)return t;let e=0,s=1;for(let r=2;r<=t;r++)[e,s]=[s,(e+s)%1000000007];return s}static floatEqual(t,e,s=1e-6){return Math.abs(t-e)<s}static fastPower(t,e){if(y.handleNumRange(e,!0,0,10),y.handleNumRange(t,!1,0,1e3),t===0)return 0;if(e===0)return 1;const s=this.fastPower(t,e>>1);return e%2===0?s*s:s*s*t}static fastSqrt(t){if(y.handleNumRange(t,!1,0,1e8),typeof BigInt>"u")return Math.sqrt(t);const e=.5*t,s=new ArrayBuffer(8);new Float64Array(s)[0]=t;let r=new BigInt64Array(s)[0];r=0x1ff7a3bea91d9b1bn+(r>>1n);const i=new ArrayBuffer(8);new BigInt64Array(i)[0]=r;let n=new Float64Array(i)[0];return n=n*.5+e/n,n=n*.5+e/n,n=n*.5+e/n,n}static getPercentWithPrecision(t,e=2){if(!Array.isArray(t)||t.length===0)return[];if(e<0||!Number.isInteger(e))throw new Error("Precision must be a non-negative integer");const s=t.reduce((h,f)=>h+f,0);if(s===0)return t.map(()=>"0%");const i=100*Math.pow(10,e),n=t.map(h=>h/s*i),a=n.map(h=>Math.floor(h)),u=n.map((h,f)=>h-a[f]);let m=a.reduce((h,f)=>h+f,0),p=i-m;for(;p>0;){let h=-1,f=-1;for(let g=0;g<u.length;g++)u[g]>f&&(f=u[g],h=g);if(h===-1)break;a[h]++,u[h]=0,p--}return a.map(h=>`${(h/i*100).toFixed(e)}%`)}static gcd(t,e){return e===0?t:this.gcd(e,t%e)}static isValidPositiveInteger(t){return Number.isInteger(t)&&t>0&&t<=Number.MAX_SAFE_INTEGER}static isPowerOfTwo(t){return t>0&&(t&t-1)===0}static isOdd(t){return t%2===1||t%2===-1}static isPrime(t){if(y.ensurePositiveInteger(t,1),t==2||t==3||t==5||t==7)return!0;if(t%2===0||t%3===0||t%5===0||t%7===0)return!1;for(let e=7;e<=Math.sqrt(t);e+=2)if(t%e===0)return!1;return!0}static isPalindrome(t){if(t<0||t%10===0&&t!==0)return!1;let e=0,s=t;for(;t>0;){const r=t%10;e=e*10+r,t=Math.floor(t/10)}return s===e}static isArmstrong(t){const e=t.toString(),s=e.length;let r=0;for(let i=0;i<s;i++)r+=Math.pow(parseInt(e[i]),s);return r===t}static isHappy(t){const e=new Set;for(;t!==1;){if(e.has(t))return!1;e.add(t),t=(t+"").split("").reduce((s,r)=>s+Number(r)*Number(r),0)}return!0}static isPerfect(t){let e=0;for(let s=1;s<t;s++)t%s===0&&(e+=s);return e===t}static isSameSign(t,e){return t>=0&&e>=0||t<=0&&e<=0}static isRange(t,e,s){if(s==null&&(s=e,e=0),e>=s)throw new Error("The maximum value must be greater than the minimum value");return e<=t&&t<s}static lcm(t,e){return t*e/this.gcd(t,e)}static middle(t,e){return e-(e-t>>1)}static random(t,e){if(e==null&&(e=t,t=0),t>=e)throw new Error("The maximum value must be greater than the minimum value");return Math.random()*(e-t)+t}static randomInt(t,e){return Math.floor(this.random(t,e))}static round(t,e=0){if(!Number.isInteger(e))throw new Error("precision must be an integer");const s=Math.pow(10,e);return Math.round(t*s)/s}static scale(t,e,s){if(e[0]>=e[1]||s[0]>=s[1])throw new Error("Invalid range");t=this.clamp(t,e[0],e[1]);const r=e[1]-e[0];return(t-e[0])*((s[1]-s[0])/r)+s[0]}static getPythagoreanTriple(t){if(t<=0||!Number.isInteger(t))throw new Error("n must be a positive integer");if(y.isOdd(t)){const s=t*t;return[t,(s-1)/2,(s+1)/2]}const e=t/2;return[t,e*e-1,e*e+1]}}class rt{static READ=1;static WRITE=2;static SHARE=4;static DELETE=8;static CREATE=16;static include(t,e){return(t&e)===e}static add(t,e){return t|e}static remove(t,e){return t&~e}static toggle(t,e){return t^e}}class A{static frequencyStatistics(t){return[...t].reduce((e,s)=>(e[s]=(e[s]||0)+1,e),{})}static isValidBracket(t){const e=[],s={"(":")","[":"]","{":"}"},r=new Set(Object.values(s));for(const i of t)if(i in s)e.push(s[i]);else if(r.has(i)&&i!==e.pop())return!1;return e.length===0}static random(t=8){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let s="";for(let r=0;r<t;r++)s+=e.charAt(Math.floor(Math.random()*e.length));return s}static template(t,e){return t.replace(/\${(\w+)}/g,(s,r)=>e[r]||"")}static escapeHtml(t){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&apos;"," ":"&nbsp;","±":"&plusmn;","×":"&times;","÷":"&divide;","≠":"&ne;","≤":"&le;","≥":"&ge;"},s=new RegExp(`[${Object.keys(e).join("")}]`,"g");return t.replace(s,r=>e[r])}static isEmail(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}static isUrl(t){try{return new URL(t),!0}catch{return!1}}static pointLength(t){let e=0;for(let s=0,r=t.length;s<r;){const i=t.codePointAt(s);s+=i>65535?2:1,e++}return e}static pointAt(t,e){if(e>=A.pointLength(t))return;let s=0;for(let r=0,i=t.length;r<i;){const n=t.codePointAt(r);if(!n)return;if(s===e)return String.fromCodePoint(n);r+=n>65535?2:1,s++}}static sliceByPoint(t,e,s=A.pointLength(t)){let r="";for(let i=e;i<s;i++)r+=A.pointAt(t,i);return r}static capitalize(t){return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}static reverse(t){return t.split("").reverse().join("")}static truncate(t,e,s="..."){return t.length<=e?t:t.slice(0,e-s.length)+s}static isPalindrome(t){return t.toLowerCase().replace(/[^a-z0-9]/g,"")===A.reverse(t)}static count(t,e){const s=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return(t.match(new RegExp(s,"g"))||[]).length}static toCamelCase(t){return t.replace(/_([a-z])/g,(e,s)=>s.toUpperCase())}static toSnakeCase(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}}class it{static isValidHex(t){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(t)}static isValidRGB(t){return/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.test(t)}}class M{static basePriunt(t,e={}){const{title:s="",color:r="#909399",fontSize:i="16px"}=e,n=s?`background-color:${r};border:1px solid ${r};border-radius:3px 0 0 3px;padding:5px;color:#fff;font-size:${i};font-weight:bold;line-height:1.5;`:"",a=`border:1px solid ${r};color:${r};font-size:${i};padding:5px;border-radius:0 3px 3px 0;padding-right:30px;line-height:1.5;`;console.log(`%c ${s} %c ${t}`,n,a)}static success(t){return M.basePriunt(t,{title:"success",color:"#67C23A"})}static error(t){return M.basePriunt(t,{title:"error",color:"#F56C6C"})}static warning(t){return M.basePriunt(t,{title:"warning",color:"#E6A23C"})}static normal(t){return M.basePriunt(t,{title:"normal",color:"#909399"})}static primary(t){return M.basePriunt(t,{title:"primary",color:"#409EFF"})}}const v={AUTH_UNAUTHORIZED:"未授权事件",AUTH_LOGIN_SUCCESS:"登录成功事件",AUTH_LOGOUT:"注销事件",AUTH_TOKEN_EXPIRED:"令牌过期事件",REQUEST_ERROR:"请求错误事件",REQUEST_TIMEOUT:"请求超时事件",REQUEST_NETWORK_ERROR:"网络错误事件",UI_SHOW_LOADING:"显示加载事件",UI_HIDE_LOADING:"隐藏加载事件",UI_SHOW_MESSAGE:"显示消息事件"};class b{static instance=null;listeners={};debugMode;constructor(t=!1){this.debugMode=t,Object.keys(v).forEach(e=>{this.listeners[e]=new Set})}static getInstance(t){return b.instance||(b.instance=new b(t)),b.instance}on(t,e){this.debugLog(`添加事件监听: ${v[t]}`),this.listeners[t].add(e)}emit(t,e){this.debugLog(`触发事件: ${v[t]}`,e),this.listeners[t].forEach(s=>{try{s(e)}catch(r){console.error(`事件 ${v[t]} 处理出错:`,r)}})}off(t,e){this.debugLog(`移除事件监听: ${v[t]}`),this.listeners[t].delete(e)}once(t,e){this.debugLog(`添加一次性事件监听: ${v[t]}`);const s=r=>{e(r),this.off(t,s)};this.on(t,s)}clear(){this.debugLog("清除所有事件监听器"),Object.values(this.listeners).forEach(t=>t.clear())}getListenerCount(t){return this.listeners[t].size}debugLog(t,e){this.debugMode&&console.log(`[EventEmitter] ${t}`,e||"")}}class k{static OPERATORS=new Set(["+","-","*","/"]);static VALID_CHARS_REG=/^[0-9+\-*/().\s]+$/;static PRIORITY_MAP=new Map([["+",1],["-",1],["*",2],["/",2],["(",0],[")",0]]);static getPriority(t){return this.PRIORITY_MAP.get(t)??0}static validateExpression(t){if(!t)throw new Error("Expression cannot be empty");if(!this.VALID_CHARS_REG.test(t))throw new Error("Expression contains invalid characters")}static processClosingParenthesis(t,e){for(;!t.isEmpty();){if(t.peek()==="("){t.pop();break}const r=t.pop();r&&e.push(r)}}static processOperator(t,e,s){for(;!e.isEmpty();){const r=e.peek();if(!r||r==="(")break;if(this.getPriority(t)<=this.getPriority(r)){const i=e.pop();i&&s.push(i)}else break}e.push(t)}static applyOperator(t,e,s){switch(s){case"+":return t+e;case"-":return t-e;case"*":return t*e;case"/":if(e===0)throw new Error("Division by zero");return t/e;default:throw new Error("Invalid operator")}}static FLOAT_NUM_REG=/^-?\d*\.?\d+$/;static EXPRESSION_REG=new RegExp("(?<!\\d)-?\\d*\\.?\\d+|[+\\-*/()]","g");static toArr(t){this.validateExpression(t);const e=t.match(k.EXPRESSION_REG);if(!e)throw new Error("Invalid expression format");return e.filter(s=>s.trim()!=="").map(s=>{if(this.FLOAT_NUM_REG.test(s)||this.OPERATORS.has(s)||s==="("||s===")")return s;throw new Error(`Invalid token: ${s}`)})}static infixToPostfix(t){if(!t?.trim())throw new Error("Expression cannot be empty");const e=new R,s=this.toArr(t);console.log(s);const r=[];for(const i of s)this.FLOAT_NUM_REG.test(i)?r.push(i):i==="("?e.push(i):i===")"?this.processClosingParenthesis(e,r):this.OPERATORS.has(i)&&this.processOperator(i,e,r);for(;!e.isEmpty();){const i=e.pop();i&&i!=="("&&r.push(i)}return{postfix:r.join(" "),postfixArr:r}}static evaluatePostfix(t){if(!t.length)throw new Error("Postfix expression cannot be empty");typeof t=="string"&&(t=k.toArr(t));const e=new R;for(const s of t)if(this.FLOAT_NUM_REG.test(s))e.push(parseFloat(s));else if(this.OPERATORS.has(s)){const r=e.pop(),i=e.pop();if(i===void 0||r===void 0)throw new Error("Invalid postfix expression");e.push(this.applyOperator(i,r,s))}return e.pop()??0}}class C{static isMatchingPair(t,e){return t==="("&&e===")"||t==="{"&&e==="}"||t==="["&&e==="]"}static arr_2d_init(t,e,s=!1){return typeof s=="boolean"?Array.from({length:t},()=>Array(e).fill(s)):Array.from({length:t},()=>Array(e).fill(s))}static isvalidBrackets(t){const e=new R;for(let s=0,r=t.length;s<r;s++){const i=t[s];if(["{","[","("].includes(i))e.push(i);else if(["}","]",")"].includes(i)){if(e.isEmpty())return!1;const n=e.pop();if(!n||!this.isMatchingPair(n,i))return!1}}return e.isEmpty()}static findPath(t,e,s){const r=t.length,i=t[0].length,n=C.arr_2d_init(r,i,!1),a=new R,u=[[-1,0],[0,1],[1,0],[0,-1]];function m(p,h){if(p<0||p>=r||h<0||h>=i||t[p][h]===1||n[p][h])return!1;if(t[p][h]===2)return a.push([p,h]),!0;n[p][h]=!0,a.push([p,h]);for(const[f,g]of u){const O=p+f,T=h+g;if(m(O,T))return!0}return a.pop(),!1}return m(e,s),a}}o.Arr=Z,o.ArrQueue=P,o.ArrStack=R,o.BitPerm=rt,o.Color=it,o.DateEx=S,o.Dictionary=F,o.Emitter=b,o.Expression=k,o.Func=Y,o.Graph=J,o.LRU=Q,o.Line=w,o.LinkedList=X,o.Log=M,o.Matrix=x,o.MaxHeap=_,o.MemoizeMap=K,o.MinHeap=z,o.MinStack=B,o.Num=y,o.Obj=tt,o.ObjQueue=V,o.ObjStack=G,o.Point=l,o.Reg=et,o.Roman=st,o.StackApplication=C,o.Str=A,o.TrafficLight=L,o.Triangle=d,o.Vector=E,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(h,R){typeof exports=="object"&&typeof module<"u"?R(exports):typeof define=="function"&&define.amd?define(["exports"],R):(h=typeof globalThis<"u"?globalThis:h||self,R(h["jc-structure"]={}))})(this,(function(h){"use strict";class R{items=[];head=0;tail=0;dequeue(){if(this.isEmpty())return;const t=this.items[this.head];return this.head++,t}enqueue(...t){for(const e of t)Array.isArray(e)?(this.items.push(...e),this.tail+=e.length):(this.items.push(e),this.tail++);return this}front(){return this.isEmpty()?void 0:this.items[this.head]}isEmpty(){return this.head===this.tail}size(){return this.tail-this.head}cleanup(){this.items=[],this.head=0,this.tail=0}toString(){return this.isEmpty()?"Queue: (0) []":`Queue: (${this.size()}) [${this.front()} ...]`}}class B{items={};count=0;lowestCount=0;constructor(){}dequeue(){if(this.isEmpty())return;const t=this.items[this.lowestCount];return delete this.items[this.lowestCount],this.lowestCount++,t}enqueue(...t){if(t.length===0)return this;if(t.length===1){const e=t[0];return Array.isArray(e)?this.batchEnqueue(e):this.enqueueItem(e)}for(const e of t)Array.isArray(e)?this.batchEnqueue(e):this.enqueueItem(e);return this}batchEnqueue(t){return t.filter(r=>this.isValidItem(r)).forEach(r=>{this.isValidItem(r)&&(this.items[this.count]=r,this.count++)}),this}enqueueItem(t){if(!this.isValidItem(t))throw new Error("Invalid item");return this.items[this.count]=t,this.count++,this}isValidItem(t){return t!=null}front(){return this.isEmpty()?void 0:this.items[this.lowestCount]}isEmpty(){return this.size()===0}size(){return this.count-this.lowestCount}cleanup(){this.items={},this.count=0,this.lowestCount=0}toString(){return this.isEmpty()?"Queue: (0) []":`Queue: (${this.size()}) [${this.front()} ...]`}}class L{_arr;constructor(){this._arr=[]}isEmpty(){return this._arr.length===0}cleanup(){this._arr=[]}size(){return this._arr.length}toString(){return this.isEmpty()?"Stack: (0) []":`Stack: (${this.size()}) [${this.peek()}, ...]`}pop(){return this._arr.pop()}push(...t){for(const e of t)Array.isArray(e)?this._arr.push(...e):this._arr.push(e);return this}peek(){return this._arr[this._arr.length-1]}}class j{items={};count=0;constructor(){}pop(){if(this.isEmpty())return;this.count--;const t=this.items[this.count];return delete this.items[this.count],t}push(...t){if(t.length===0)return this;if(t.length===1){const e=t[0];return Array.isArray(e)?this.addItems(e):this.addItem(e)}for(const e of t)Array.isArray(e)?this.addItems(e):this.addItem(e);return this}addItem(t){if(!this.isValidItem(t))throw new Error("Invalid item: item cannot be null or undefined");return this.items[this.count]=t,this.count++,this}addItems(t){return t.filter(r=>this.isValidItem(r)).forEach(r=>{this.items[this.count]=r,this.count++}),this}isValidItem(t){return t!=null}peek(){return this.isEmpty()?void 0:this.items[this.count-1]}isEmpty(){return this.count===0}size(){return this.count}cleanup(){this.items={},this.count=0}toString(){return this.isEmpty()?"Stack: (0) []":`Stack: (${this.size()}) [ ${this.peek()} ...]`}}class Q{stack=[];minStack=[];push(t){this.stack.push(t),(this.minStack.length===0||t<=this.minStack[this.minStack.length-1])&&this.minStack.push(t)}pop(){const t=this.stack.pop();return t===this.minStack[this.minStack.length-1]&&this.minStack.pop(),t}peek(){return this.stack[this.stack.length-1]}getMin(){return this.minStack[this.minStack.length-1]}isEmpty(){return this.size()===0}size(){return this.stack.length}clear(){this.stack=[],this.minStack=[]}toString(){return this.isEmpty()?"Stack: (0) []":`Stack: (${this.size()}) [ ${this.peek()} ...]`}}function z(o,t){return o===t?0:o<t?-1:1}class M{heap=[];compareFn;constructor(t=z){this.compareFn=t}static getLeftIndex(t){return 2*t+1}static getRightIndex(t){return 2*t+2}static getParentIndex(t){return t===0?void 0:Math.floor((t-1)/2)}static swap(t,e,r){[t[e],t[r]]=[t[r],t[e]]}find(){return this.isEmpty()?void 0:this.heap[0]}size(){return this.heap.length}isEmpty(){return this.size()===0}cleanup(){this.heap=[]}toString(){return this.heap.toString()}}class D extends M{insert(t){return t?!1:(this.heap.push(t),this.siftUp(this.heap.length-1),!0)}extract(){if(this.isEmpty())return;if(this.heap.length===1)return this.heap.shift();const t=this.heap[0];return this.heap[0]=this.heap.pop(),this.siftDown(0),t}siftUp(t){let e=t,r=M.getLeftIndex(e),s=M.getRightIndex(e),i=this.size();r<i&&this.compareFn(this.heap[e],this.heap[r])===-1&&(e=r),s<i&&this.compareFn(this.heap[e],this.heap[s])===1&&(e=s),e!==t&&(M.swap(this.heap,t,e),this.siftUp(e))}siftDown(t){let e=M.getParentIndex(t);for(;t>0&&e&&this.compareFn(this.heap[e],this.heap[t])===1;)M.swap(this.heap,e,t),t=e,e=M.getParentIndex(t)}}class _ extends D{constructor(t=(e,r)=>z(r,e)){super(t)}}function X(o){return{value:o}}class W{capacity;length=0;head=null;tail=null;lookup=new Map;reverseLookup=new Map;constructor(t=10){this.capacity=t}prepend(t){this.head?(t.next=this.head,this.head.prev=t,this.head=t):this.head=this.tail=t}detach(t){t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),this.head===t&&(this.head=this.head.next||null),this.tail===t&&(this.tail=this.tail.prev||null),t.next=void 0,t.prev=void 0}trimCache(){if(this.length<=this.capacity)return;const t=this.tail;this.detach(t);const e=this.reverseLookup.get(t);this.lookup.delete(e),this.reverseLookup.delete(t),this.length--}get(t){const e=this.lookup.get(t);if(e)return this.detach(e),this.prepend(e),e.value}update(t,e){let r=this.lookup.get(t);r?(this.detach(r),this.prepend(r),r.value=e):(r=X(e),this.length++,this.prepend(r),this.trimCache(),this.lookup.set(t,r),this.reverseLookup)}}class F{constructor(t,e=null,r=null){this.value=t,this.next=e,this.prev=r}}class J{count=0;head=null;tail=null;constructor(t){t&&t.forEach(e=>this.push(e))}[Symbol.iterator](){let t=this.head;return{next(){if(t){const e=t.value;return t=t.next,{value:e,done:!1}}return{value:void 0,done:!0}}}}equals(t,e){if(t===e)return!0;if(t==null||e==null)return!1;if(typeof t=="object"&&typeof e=="object"){if(t.equals&&typeof t.equals=="function")return t.equals(e);const r=Object.keys(t),s=Object.keys(e);return r.length!==s.length?!1:r.every(i=>t[i]===e[i])}return!1}indexOf(t){let e=this.head,r=0;for(;e;){if(this.equals(e.value,t))return r;r++,e=e.next}return-1}getElementAt(t){if(t<0||t>=this.count)return null;if(t>this.count/2){let r=this.tail,s=this.count-1;for(;s>t&&r;)r=r.prev,s--;return r}let e=this.head;for(let r=0;r<t&&e;r++)e=e.next;return e}getValueAt(t){return this.getElementAt(t)?.value}insert(t,e){if(e<0||e>this.count)throw new Error(`Index out of bounds: ${e}`);const r=new F(t);if(e===0)r.next=this.head,this.head&&(this.head.prev=r),this.head=r,this.count===0&&(this.tail=r);else if(e===this.count)r.prev=this.tail,this.tail&&(this.tail.next=r),this.tail=r;else{let s;if(e<this.count/2){s=this.head;for(let i=0;i<e-1&&s;i++)s=s.next}else{s=this.tail;for(let i=this.count-1;i>e-1&&s;i--)s=s.prev}if(s){const i=s.next;r.prev=s,r.next=i,s.next=r,i&&(i.prev=r)}}return this.count++,!0}push(t){const e=new F(t);this.head?this.tail&&(this.tail.next=e,e.prev=this.tail,this.tail=e):(this.head=e,this.tail=e),this.count++}remove(t){let e=this.head,r=this.tail,s=0,i=this.count-1;for(;e&&r;){if(this.equals(e.value,t))return this.removeAt(s);if(this.equals(r.value,t))return this.removeAt(i);if(e=e.next,r=r.prev,s++,i--,s>i)break}return null}removeAt(t){if(t<0||t>=this.count)return null;let e;if(t===0)e=this.head,e&&(this.head=e.next,this.head&&(this.head.prev=null),this.count===1&&(this.tail=null));else if(t===this.count-1)e=this.tail,e&&(this.tail=e.prev,this.tail&&(this.tail.next=null),this.count===1&&(this.head=null));else{if(t<this.count/2){e=this.head;for(let r=0;r<t&&e;r++)e=e.next}else{e=this.tail;for(let r=this.count-1;r>t&&e;r--)e=e.prev}if(e){const r=e.prev,s=e.next;r&&(r.next=s),s&&(s.prev=r)}}return this.count--,e?.value||null}isEmpty(){return this.count===0}size(){return this.count}cleanup(){this.head=null,this.tail=null,this.count=0}toString(){if(this.isEmpty())return"";let t="",e=this.head;for(;e;)t+=JSON.stringify(e.value),e.next&&(t+=","),e=e.next;return t}toArray(){const t=[];let e=this.head;for(;e;)t.push(e.value),e=e.next;return t}}class Y{key;value;constructor(t,e){this.key=t,this.value=e}}function U(o,t={emptyString:!1,zeroNumber:!1}){return o==null?!(t.emptyString&&o===""||t.zeroNumber&&o===0):!1}class q{table=[];constructor(){}getItemIndex(t){for(let e=0,r=this.table.length;e<r;e++)if(this.table[e].key===t)return e;return-1}set(t,e){if(U(t))throw new Error("key is required");if(U(e))throw new Error("value is required");if(this.has(t)){let r=this.getItemIndex(t);this.table[r].value=e}else{const r=new Y(t,e);this.table.push(r)}}remove(t){if(this.has(t)){let e=this.getItemIndex(t);return this.table.splice(e,1)[0]}}has(t){return this.getItemIndex(t)!==-1}get(t){if(this.has(t)){let e=this.getItemIndex(t);return this.table[e]}}keys(){return this.table.map(t=>t.key)}values(){return this.table.map(t=>t.value)}keyValues(){return this.table.map(t=>[t.key,t.value])}forEach(t){for(let e=0,r=this.size();e<r;e++){let s=this.table[e];if(!t(s.key,s.value))break}}isEmpty(){return!this.size()}size(){return this.table.length}cleanup(){this.table=[]}toString(){let t="";for(let e=0,r=this.table.length;e<r;e++)t+=this.table[e].toString(),t+=",";return t=t.slice(0,-1),t}}class Z{isDirected;vertices;adjList;constructor(t=!1){this.isDirected=t,this.vertices=[],this.adjList=new q}addVertex(t){this.vertices.includes(t)||(this.vertices.push(t),this.adjList.set(t,[]))}addEdge(t,e){this.adjList.get(t)||this.addVertex(t),this.adjList.get(e)||this.addVertex(e),this.adjList.get(t)?.value.indexOf(e)===-1&&this.adjList.get(t)?.value.push(e),this.isDirected||this.adjList.get(e)?.value.indexOf(t)===-1&&this.adjList.get(e)?.value.push(t)}getVertices(){return this.vertices}getAdjacencyList(){return this.adjList}toString(){let t="";for(let e=0;e<this.vertices.length;e++)t+=this.vertices[e]+"-->",t+=this.adjList.get(this.vertices[e])?.toString()||"",t+=`
2
+ `;return t}}class E{_data;static zero(t){return new E(...Array(t).fill(0))}constructor(...t){this._data=t}get dimension(){return this._data.length}get norm(){return Math.hypot(...this._data)}getItem(t){return this._data[t]}normalize(){const t=this.norm;if(t===0)throw new Error("Cannot normalize a zero vector");const e=this._data.map(r=>r/t);return new E(...e)}add(t){if(this.dimension!==t.dimension)throw new Error("Vectors must have the same dimension to add");const e=this._data.map((r,s)=>r+t._data[s]);return new E(...e)}sub(t){if(this.dimension!==t.dimension)throw new Error("Vectors must have the same dimension to subtract");const e=this._data.map((r,s)=>r-t._data[s]);return new E(...e)}mul(t){return new E(...this._data.map(e=>e*t))}dot(t){if(this.dimension!==t.dimension)throw new Error("Vectors must have the same dimension to dot product");return this._data.reduce((e,r,s)=>e+r*t._data[s],0)}pos(){return this.mul(1)}neg(){return this.mul(-1)}}class x{_matrix;static zero(t,e){return new x(Array.from({length:t},()=>Array.from({length:e},()=>0)))}static rotate(t){const e=t.length;for(let r=0;r<(e+1)/2;r++)for(let s=r;s<e/2;s++){const i=t[e-1-s][r];t[e-1-s][r]=t[e-1-r][e-1-s],t[e-1-r][e-1-s]=t[s][e-1-r],t[s][e-1-r]=t[r][s],t[r][s]=i}return t}constructor(t){this._matrix=t}get shape(){return[this._matrix.length,this._matrix[0].length]}get row(){return this.shape[0]}get col(){return this.shape[1]}get size(){return this.row*this.col}rowVector(t){return new E(...this._matrix[t])}colVector(t){return new E(...this._matrix.map(e=>e[t]))}getItem(t){return this._matrix[t[0]][t[1]]}setItem(t,e){return this._matrix[t[0]][t[1]]=e,this}mul(t){return new x(this._matrix.map(e=>e.map(r=>r*t)))}div(t){return this.mul(1/t)}add(t){if(this.row!==t.row||this.col!==t.col)throw new Error("Matrix dimensions do not match");return new x(this._matrix.map((e,r)=>e.map((s,i)=>s+t.getItem([r,i]))))}sub(t){return this.add(t.neg())}pos(){return this.mul(1)}neg(){return this.mul(-1)}mulVector(t){if(this.col!==t.dimension)throw new Error("Matrix dimensions do not match");return new x(this._matrix.map(e=>e.map((r,s)=>r*t.getItem(s))))}mulMatrix(t){if(this.col!==t.row)throw new Error("Matrix dimensions do not match");const e=x.zero(this.row,t.col);for(let r=0;r<this.row;r++){const s=this.rowVector(r);for(let i=0;i<this.col;i++)e.setItem([r,i],s.dot(t.colVector(i)))}return e}}class l{static distance(t,e){return Math.hypot(e.x-t.x,e.y-t.y)}x;y;constructor(t,e){this.x=t,this.y=e}distanceTo(t){return l.distance(this,t)}static linearInterpolation(t,e,r){if(r<0||r>1)throw new Error("Parameter t must be in the range [0, 1]");const s=t.x*(1-r)+e.x*r,i=t.y*(1-r)+e.y*r;return new l(s,i)}static quadraticBezierInterpolation(t,e,r,s){if(s<0||s>1)throw new Error("Parameter t must be in the range [0, 1]");const i=(1-s)*(1-s)*t.x+2*(1-s)*s*e.x+s*s*r.x,n=(1-s)*(1-s)*t.y+2*(1-s)*s*e.y+s*s*r.y;return new l(i,n)}static cubicBezierInterpolation(t,e,r,s,i){if(i<0||i>1)throw new Error("Parameter t must be in the range [0, 1]");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)*r.x+Math.pow(i,3)*s.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)*r.y+Math.pow(i,3)*s.y;return new l(n,a)}}class w{static EPSILON=1e-10;static sloped(t,e=w.EPSILON){const r=t.p2.x-t.p1.x,s=t.p2.y-t.p1.y;return Math.abs(r)<e?Math.abs(s)<e?0:null:s/r}static isParallel(t,e,r=w.EPSILON){const s=w.sloped(t),i=w.sloped(e);return s===null&&i===null?!0:s===null||i===null?!1:Math.abs(s-i)<r}static getIntersection(t,e,r=w.EPSILON){if(w.isParallel(t,e))return null;const s=t.p1.x,i=t.p1.y,n=t.p2.x,a=t.p2.y,u=e.p1.x,m=e.p1.y,p=e.p2.x,c=e.p2.y,f=(s-n)*(m-c)-(i-a)*(u-p);if(Math.abs(f)<r)return null;const y=((s-u)*(m-c)-(i-m)*(u-p))/f,O=-((s-n)*(i-m)-(i-a)*(s-u))/f;if(y>=0&&y<=1&&O>=0&&O<=1){const T=s+y*(n-s),ht=i+y*(a-i);return new l(T,ht)}return null}static isIntersecting(t,e){return w.getIntersection(t,e)!==null}static distanceToPoint(t,e,r=w.EPSILON){const s=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,u=s*n+i*a,m=n*n+a*a;let p=-1;m>r&&(p=u/m);let c,f;p<0?(c=t.p1.x,f=t.p1.y):p>1?(c=t.p2.x,f=t.p2.y):(c=t.p1.x+p*n,f=t.p1.y+p*a);const y=e.x-c,O=e.y-f;return Math.hypot(y+O)}p1;p2;constructor(t,e){this.p1=t,this.p2=e}get length(){const t=this.p2.x-this.p1.x,e=this.p2.y-this.p1.y;return Math.sqrt(t*t+e*e)}get midpoint(){const t=(this.p1.x+this.p2.x)/2,e=(this.p1.y+this.p2.y)/2;return new l(t,e)}get angle(){return Math.atan2(this.p2.y-this.p1.y,this.p2.x-this.p1.x)}containsPoint(t,e=w.EPSILON){const r=(t.x-this.p1.x)*(this.p2.y-this.p1.y)-(t.y-this.p1.y)*(this.p2.x-this.p1.x);return Math.abs(r)>e?!1:(t.x-this.p1.x)*(t.x-this.p2.x)+(t.y-this.p1.y)*(t.y-this.p2.y)<=e}get direction(){const t=this.length;if(t<w.EPSILON)return new l(0,0);const e=(this.p2.x-this.p1.x)/t,r=(this.p2.y-this.p1.y)/t;return new l(e,r)}get start(){return this.p1}get end(){return this.p2}}class H{static EPSILON=1e-10;name;constructor(t){this.name=t}}class g extends H{static isValid(t,e,r){return t<=0||e<=0||r<=0?!1:t+e>r&&t+r>e&&e+r>t}static area(t,e,r){if(!g.isValid(t,e,r))throw new Error("Invalid triangle");const s=(t+e+r)/2;return Math.sqrt(s*(s-t)*(s-e)*(s-r))}static getType(t,e,r){if(!g.isValid(t,e,r))throw new Error("Invalid triangle sides");const s=[t,e,r].sort((u,m)=>u-m),[i,n,a]=s;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"}static getAngles(t,e,r){if(!g.isValid(t,e,r))throw new Error("Invalid triangle sides");const s=Math.acos((e*e+r*r-t*t)/(2*e*r)),i=Math.acos((t*t+r*r-e*e)/(2*t*r)),n=Math.PI-s-i;return[s,i,n]}p1;p2;p3;constructor(t,e,r,s="triangle"){if(super(s),this.p1=t,this.p2=e,this.p3=r,this.areCollinear())throw new Error("Points are collinear, cannot form a triangle")}areCollinear(){return Math.abs((this.p2.x-this.p1.x)*(this.p3.y-this.p1.y)-(this.p3.x-this.p1.x)*(this.p2.y-this.p1.y))<H.EPSILON}get side(){return[l.distance(this.p1,this.p2),l.distance(this.p2,this.p3),l.distance(this.p3,this.p1)]}perimeter(){return g.isValid(this.side[0],this.side[1],this.side[2]),this.side.reduce((t,e)=>t+e,0)}area(){const[t,e,r]=this.side;return g.area(t,e,r)}get type(){const[t,e,r]=this.side;return g.getType(t,e,r)}get angles(){const[t,e,r]=this.side;return g.getAngles(t,e,r)}get centroid(){return new l((this.p1.x+this.p2.x+this.p3.x)/3,(this.p1.y+this.p2.y+this.p3.y)/3)}get incenter(){const[t,e,r]=this.side,s=this.perimeter()/2,i=(t*this.p1.x+e*this.p2.x+r*this.p3.x)/s,n=(t*this.p1.y+e*this.p2.y+r*this.p3.y)/s;return new l(i,n)}get circumcenter(){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));if(Math.abs(t)<g.EPSILON)throw new Error("Cannot calculate circumcenter for collinear points");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,r=((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;return new l(e,r)}containsPoint(t){const e=g.area(l.distance(t,this.p1),l.distance(t,this.p2),l.distance(this.p1,this.p2)),r=g.area(l.distance(t,this.p2),l.distance(t,this.p3),l.distance(this.p2,this.p3)),s=g.area(l.distance(t,this.p3),l.distance(t,this.p1),l.distance(this.p3,this.p1));return Math.abs(e+r+s-this.area())<g.EPSILON}}class K{static sleep(t){return new Promise(e=>setTimeout(e,t))}static binarySearchTemplate(t,e,r){let s=-1,i=t.length,n;for(;i-s>1;)n=i-(i-s)>>1,r(t[n],e)?i=n:s=n;return i}static singleton(t){let e;const r=new Proxy(t,{construct(s,i,n){return e||(e=Reflect.construct(s,i,n)),e}});return t.prototype.constructor=r,r}}class tt{static groupBy(t,e){if(!e)throw new Error("generateKey is required");const r=typeof e=="string"?i=>i[e]:e,s=new Map;for(const[i,n]of t.entries())try{const a=r(n,i,t);if(a==null){console.warn("Invalid key generated for item:",n);continue}const u=s.get(a)??[];u.push(n),s.set(a,u)}catch(a){console.error("Error generating key for item:",n,a)}return Object.fromEntries(s)}static LIS(t){if(!t.length)return[];const e=[[t[0]]];for(let s=1,i=t.length;s<i;s++){const n=t[s];r(n)}function r(s){for(let i=e.length-1;i>=0;i--){const n=e[i],a=n[e[i].length-1];if(a<s){e[i+1]=[...n,s];break}else a>s&&i===0&&(e[i]=[s])}}return e[e.length-1]}static LCP(t){if(!t.length)return"";let e=t[0];for(let r=1;r<t.length;r++)for(;!t[r].startsWith(e);)if(e=e.slice(0,-1),e==="")return"";return e}}function k(o){return o!==null&&(typeof o=="object"||typeof o=="function")}class et{map=new Map;weakMap=new WeakMap;set(t,e){k(t)?this.weakMap.set(t,e):this.map.set(t,e)}get(t){return k(t)?this.weakMap.get(t):this.map.get(t)}has(t){return k(t)?this.weakMap.has(t):this.map.has(t)}}class rt{static jsonClone(t){try{return JSON.parse(JSON.stringify(t))}catch{throw new Error("Object is not JSON cloneable")}}static structureClone(t){return structuredClone(t)}static deepClone(t,e=new WeakMap){if(t==null||typeof t!="object")return t;if(e.has(t))return e.get(t);if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp)return new RegExp(t.source,t.flags);if(t instanceof Map){const n=new Map;e.set(t,n);for(const[a,u]of t)n.set(this.deepClone(a,e),this.deepClone(u,e));return n}if(t instanceof Set){const n=new Set;e.set(t,n);for(const a of t)n.add(this.deepClone(a,e));return n}if(Array.isArray(t)){const n=new Array(t.length);e.set(t,n);for(let a=0,u=t.length;a<u;a++)n[a]=this.deepClone(t[a],e);return n}if(t instanceof ArrayBuffer)return t.slice(0);const r=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];for(const n of r)if(t instanceof n)return new n(t);if(typeof t=="function")return new Proxy(t,{apply(n,a,u){return n.apply(a,u)},get(n,a){if(a in n)return n[a]}});const s=Object.create(Object.getPrototypeOf(t));e.set(t,s);const i=Object.getOwnPropertyDescriptors(t);for(const[n,a]of Object.entries(i))a.value!==void 0&&(a.value=this.deepClone(a.value,e)),Object.defineProperty(s,n,a);return s}}const V={date:"yyyy-MM-dd",datetime:"yyyy-MM-dd HH:mm:ss",time:"HH:mm:ss",iso:"yyyy-MM-ddTHH:mm:ss.SSS"};class v{static defaultOptions={paddingZero:!1,locale:"en-US"};static setDefaultOptions(t){v.defaultOptions={...v.defaultOptions,...t}}static format(t,e,r={}){const s={...v.defaultOptions,...r},i=v.getDateInfo(t,s);return v.normalizeFormatter(e)(i)}static getDateInfo(t,e){const r=(c,f=2)=>e.paddingZero?c.toString().padStart(f,"0"):c.toString(),s=t.getFullYear(),i=t.getMonth()+1,n=t.getDate(),a=t.getHours(),u=t.getMinutes(),m=t.getSeconds(),p=t.getMilliseconds();return{year:s,month:i,day:n,hour:a,minute:u,second:m,millisecond:p,yyyy:r(s,4),MM:r(i),dd:r(n),HH:r(a),mm:r(u),ss:r(m)}}static normalizeFormatter(t){if(typeof t=="function")return t;if(typeof t!="string")throw new Error("Formatter must be a string or function");t in V&&(t=V[t]);const e={yyyy:"yyyy",MM:"MM",dd:"dd",HH:"HH",mm:"mm",ss:"ss",SSS:"SSS"};return r=>{let s=t;for(const[i,n]of Object.entries(e))s=s.replace(new RegExp(i,"g"),String(r[n]||""));return s}}static formatRelative(t,e=new Date){const r=t.getTime()-e.getTime(),s=Math.abs(r),i=Math.floor(s/1e3),n=Math.floor(i/60),a=Math.floor(n/60),u=Math.floor(a/24);return u>0?r>0?`${u}天后`:`${u}天前`:a>0?r>0?`${a}小时后`:`${a}小时前`:n>0?r>0?`${n}分钟后`:`${n}分钟前`:r>0?"刚刚":""}}class C{lights;currentIndex;switchTime;static DEFAULT_LIGHTS=[{color:"red",latest:7},{color:"yellow",latest:3},{color:"green",latest:10},{color:"yellow",latest:3}];constructor(t=C.DEFAULT_LIGHTS){this.lights=t,this.currentIndex=0,this.switchTime=Date.now()}render(t){requestAnimationFrame(this.render.bind(this,t));const e=this.getCurrentLight();t(e)}get current(){return this.lights[this.currentIndex]}get disTime(){return Date.now()-this.switchTime}update(){for(;!(this.disTime<this.current.latest);)this.switchTime+=this.current.latest*1e3,this.currentIndex=(this.currentIndex+1)%this.lights.length}getCurrentLight(){return this.update(),{color:this.current.color,remain:this.current.latest-this.disTime}}}class st{static escape(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}static telephone={loose:/\D?(\d[0-9-]{6,}\d)\D?/g};static consecutiveChars=/(.)\1+/g;static chineseChar=/[\u4e00-\u9fa5]/g;static domain=/^(?:https?:\/\/)?(?:[^\/]+)/i;static email=/^\w+([-+.]\w+)*@\w+([-.]\w+)*.\w+([-.]\w+)*$/}class it{static ROMAN_MAP=new Map([["M",1e3],["CM",900],["D",500],["CD",400],["C",100],["XC",90],["L",50],["XL",40],["X",10],["IX",9],["V",5],["IV",4],["I",1]]);static toInteger(t){if(t.length===0)throw new Error("Input cannot be empty");const e=new Set(["I","V","X","L","C","D","M"]);for(const n of t)if(!e.has(n))throw new Error(`Invalid Roman numeral character: ${n}`);let r=0,s=0;for(;s<t.length;){const n=t.slice(s,s+2);if(this.ROMAN_MAP.has(n))r+=this.ROMAN_MAP.get(n),s+=2;else{const a=t[s],u=this.ROMAN_MAP.get(a);if(!u)throw new Error(`Invalid Roman numeral sequence at position ${s}`);r+=u,s+=1}}if(this.toRoman(r)!==t)throw new Error("Invalid Roman numeral sequence");return r}static toRoman(t){if(t<=0||t>=4e3)throw new Error("Number must be between 1 and 3999");if(!Number.isInteger(t))throw new Error("Number must be an integer");let e="";for(const[r,s]of this.ROMAN_MAP)for(;t>=s;)e+=r,t-=s;return e}}class d{static ensurePositiveInteger(t,e=0){if(!Number.isInteger(t)||t<=e)throw new Error(`n must be a positive integer and greater than ${e}`)}static handleNumRange(t,e=!1,r=Number.MIN_SAFE_INTEGER,s=Number.MAX_SAFE_INTEGER){if(e&&!Number.isInteger(t))throw new Error("n must be an integer");if(t<r||t>=s)throw new RangeError(`n must be in the range of ${r} to ${s}`)}static consecutiveSum(t){return d.handleNumRange(t,!0,0,1e8),t*(t+1)/2}static consecutiveSquaresSum(t){return d.handleNumRange(t,!0,0,1e6),t*(t+1)*(2*t+1)/6}static consecutivecubesSum(t){return d.handleNumRange(t,!0,0,1e4),t*(t+1)*(2*t+1)*(3*t*t+3*t-1)/30}static clamp(t,e,r){return r==null?Math.min(t,e):Math.min(Math.max(t,e),r)}static factorial(t){if(d.handleNumRange(t,!0,0,1e3),t<2)return 1;let e=1;for(let r=2;r<=t;r++)e*=r;return e}static fibonacci(t,e=1,r=1){return d.handleNumRange(t,!0,0,1e3),t<2?r:this.fibonacci(t-1,r,r+e)}static fibonacciIterative(t){if(d.handleNumRange(t,!0,0,1e3),t<2)return t;let e=0,r=1;for(let s=2;s<=t;s++)[e,r]=[r,(e+r)%1000000007];return r}static floatEqual(t,e,r=1e-6){return Math.abs(t-e)<r}static fastPower(t,e){if(d.handleNumRange(e,!0,0,10),d.handleNumRange(t,!1,0,1e3),t===0)return 0;if(e===0)return 1;const r=this.fastPower(t,e>>1);return e%2===0?r*r:r*r*t}static fastSqrt(t){if(d.handleNumRange(t,!1,0,1e8),typeof BigInt>"u")return Math.sqrt(t);const e=.5*t,r=new ArrayBuffer(8);new Float64Array(r)[0]=t;let s=new BigInt64Array(r)[0];s=0x1ff7a3bea91d9b1bn+(s>>1n);const i=new ArrayBuffer(8);new BigInt64Array(i)[0]=s;let n=new Float64Array(i)[0];return n=n*.5+e/n,n=n*.5+e/n,n=n*.5+e/n,n}static getPercentWithPrecision(t,e=2){if(!Array.isArray(t)||t.length===0)return[];if(e<0||!Number.isInteger(e))throw new Error("Precision must be a non-negative integer");const r=t.reduce((c,f)=>c+f,0);if(r===0)return t.map(()=>"0%");const i=100*Math.pow(10,e),n=t.map(c=>c/r*i),a=n.map(c=>Math.floor(c)),u=n.map((c,f)=>c-a[f]);let m=a.reduce((c,f)=>c+f,0),p=i-m;for(;p>0;){let c=-1,f=-1;for(let y=0;y<u.length;y++)u[y]>f&&(f=u[y],c=y);if(c===-1)break;a[c]++,u[c]=0,p--}return a.map(c=>`${(c/i*100).toFixed(e)}%`)}static isValidPositiveInteger(t){return Number.isInteger(t)&&t>0&&t<=Number.MAX_SAFE_INTEGER}static isPowerOfTwo(t){return t>0&&(t&t-1)===0}static isOdd(t){return t%2===1||t%2===-1}static isPrime(t){if(d.ensurePositiveInteger(t,1),t==2||t==3||t==5||t==7)return!0;if(t%2===0||t%3===0||t%5===0||t%7===0)return!1;for(let e=7;e<=Math.sqrt(t);e+=2)if(t%e===0)return!1;return!0}static isPalindrome(t){if(t<0||t%10===0&&t!==0)return!1;let e=0,r=t;for(;t>0;){const s=t%10;e=e*10+s,t=Math.floor(t/10)}return r===e}static isArmstrong(t){const e=t.toString(),r=e.length;let s=0;for(let i=0;i<r;i++)s+=Math.pow(parseInt(e[i]),r);return s===t}static isHappy(t){const e=new Set;for(;t!==1;){if(e.has(t))return!1;e.add(t),t=(t+"").split("").reduce((r,s)=>r+Number(s)*Number(s),0)}return!0}static isPerfect(t){let e=0;for(let r=1;r<t;r++)t%r===0&&(e+=r);return e===t}static isSameSign(t,e){return t>=0&&e>=0||t<=0&&e<=0}static isRange(t,e,r){if(r==null&&(r=e,e=0),e>=r)throw new Error("The maximum value must be greater than the minimum value");return e<=t&&t<r}static gcd(t,e){return e===0?t:d.gcd(e,t%e)}static lcm(t,e){return t*e/this.gcd(t,e)}static middle(t,e){return e-(e-t>>1)}static random(t,e){if(e==null&&(e=t,t=0),t>=e)throw new Error("The maximum value must be greater than the minimum value");return Math.random()*(e-t)+t}static randomInt(t,e){return Math.floor(this.random(t,e))}static round(t,e=0){if(!Number.isInteger(e))throw new Error("precision must be an integer");const r=Math.pow(10,e);return Math.round(t*r)/r}static scale(t,e,r){if(e[0]>=e[1]||r[0]>=r[1])throw new Error("Invalid range");t=this.clamp(t,e[0],e[1]);const s=e[1]-e[0];return(t-e[0])*((r[1]-r[0])/s)+r[0]}static getPythagoreanTriple(t){if(t<=0||!Number.isInteger(t))throw new Error("n must be a positive integer");if(d.isOdd(t)){const r=t*t;return[t,(r-1)/2,(r+1)/2]}const e=t/2;return[t,e*e-1,e*e+1]}static exclusionPrinciple(t,e,r,s){const i=Math.floor(t/e)+Math.floor(t/r)+Math.floor(t/s),n=Math.floor(t/d.lcm(e,r))+Math.floor(t/d.lcm(e,s))+Math.floor(t/d.lcm(r,s)),a=Math.floor(t/d.lcm(d.lcm(e,r),s));return i-n+a}}class nt{static READ=1;static WRITE=2;static SHARE=4;static DELETE=8;static CREATE=16;static include(t,e){return(t&e)===e}static add(t,e){return t|e}static remove(t,e){return t&~e}static toggle(t,e){return t^e}}class S{static frequencyStatistics(t){return[...t].reduce((e,r)=>(e[r]=(e[r]||0)+1,e),{})}static isValidBracket(t){const e=[],r={"(":")","[":"]","{":"}"},s=new Set(Object.values(r));for(const i of t)if(i in r)e.push(r[i]);else if(s.has(i)&&i!==e.pop())return!1;return e.length===0}static random(t=8){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let r="";for(let s=0;s<t;s++)r+=e.charAt(Math.floor(Math.random()*e.length));return r}static template(t,e){return t.replace(/\${(\w+)}/g,(r,s)=>e[s]||"")}static escapeHtml(t){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&apos;"," ":"&nbsp;","±":"&plusmn;","×":"&times;","÷":"&divide;","≠":"&ne;","≤":"&le;","≥":"&ge;"},r=new RegExp(`[${Object.keys(e).join("")}]`,"g");return t.replace(r,s=>e[s])}static isEmail(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}static isUrl(t){try{return new URL(t),!0}catch{return!1}}static pointLength(t){let e=0;for(let r=0,s=t.length;r<s;){const i=t.codePointAt(r);r+=i>65535?2:1,e++}return e}static pointAt(t,e){if(e>=S.pointLength(t))return;let r=0;for(let s=0,i=t.length;s<i;){const n=t.codePointAt(s);if(!n)return;if(r===e)return String.fromCodePoint(n);s+=n>65535?2:1,r++}}static sliceByPoint(t,e,r=S.pointLength(t)){let s="";for(let i=e;i<r;i++)s+=S.pointAt(t,i);return s}static capitalize(t){return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}static reverse(t){return t.split("").reverse().join("")}static truncate(t,e,r="..."){return t.length<=e?t:t.slice(0,e-r.length)+r}static isPalindrome(t){return t.toLowerCase().replace(/[^a-z0-9]/g,"")===S.reverse(t)}static count(t,e){const r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return(t.match(new RegExp(r,"g"))||[]).length}static toCamelCase(t){return t.replace(/_([a-z])/g,(e,r)=>r.toUpperCase())}static toSnakeCase(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}}class at{static isValidHex(t){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(t)}static isValidRGB(t){return/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.test(t)}}const N=o=>o==null||o==="",ot={success:{background:"#67C23A",border:"#67C23A",color:"#fff"},error:{background:"#F56C6C",border:"#F56C6C",color:"#fff"},warning:{background:"#E6A23C",border:"#E6A23C",color:"#fff"},info:{background:"#909399",border:"#909399",color:"#fff"}},G={enable:!0,showTimestamp:!0,maxLogLength:30};class I{static config=G;static shouldLog(){return this.config.enable&&!0}static formatMessage(t){return t.length>this.config.maxLogLength?`${t.substring(0,this.config.maxLogLength)}...`:t}static getTimestamp(){return this.config.showTimestamp?`[${new Date().toLocaleTimeString()}] `:""}static prettyPrint(t,e,r){if(!this.shouldLog())return;const s=ot[r],i=this.getTimestamp(),n=this.formatMessage(t),a=this.formatMessage(e);console.log(`%c${i} ${n} %c ${a} %c`,`background:${s.background};border:1px solid ${s.border}; padding: 1px; border-radius: 2px 0 0 2px; color: ${s.color};`,`border:1px solid ${s.border}; padding: 1px; border-radius: 0 2px 2px 0; color: ${s.border};`,"background:transparent")}static handleLevel(t,e,r){const s=N(e)?r:t,i=N(e)?t:e;return I.prettyPrint(s,i,r)}static configure(t){this.config={...G,...t}}static success(t,e=""){I.handleLevel(t,e,"success")}static error(t,e=""){this.handleLevel(t,e,"error")}static warning(t,e=""){I.handleLevel(t,e,"warning")}static info(t,e=""){I.handleLevel(t,e,"info")}static table(t){!this.shouldLog()||!Array.isArray(t)||t.length===0||console.table(t)}static async picture(t,e=1){if(!(!this.shouldLog()||N(t)))return new Promise((r,s)=>{const i=new Image;i.crossOrigin="anonymous",i.onerror=()=>{I.error("Image Load Error",`Failed to load image: ${t}`),s(new Error(`Failed to load image: ${t}`))},i.onload=()=>{try{const n=document.createElement("canvas"),a=n.getContext("2d");if(!a)throw new Error("Failed to get canvas context");n.width=i.width,n.height=i.height,a.fillStyle="red",a.fillRect(0,0,n.width,n.height),a.drawImage(i,0,0);const u=n.toDataURL("image/png");console.log("%c sup?",`font-size:1px;
3
+ padding:${Math.floor(i.height*e/2)}px ${Math.floor(i.width*e/2)}px;
4
+ background:url(${u}) no-repeat;
5
+ background-size:${i.width*e}px ${i.height*e}px;
6
+ line-height:${i.height*e}px;
7
+ color:transparent;
8
+ `),r()}catch(n){I.error("Image Processing Error",n instanceof Error?n.message:String(n)),s(n)}},i.src=t})}static time(t){this.shouldLog()&&console.time(t)}static timeEnd(t){this.shouldLog()&&console.timeEnd(t)}static group(t,e=!1){this.shouldLog()&&(e?console.groupCollapsed(t):console.group(t))}static groupEnd(){this.shouldLog()&&console.groupEnd()}static clear(){this.shouldLog()&&console.clear()}}const A={AUTH_UNAUTHORIZED:"未授权事件",AUTH_LOGIN_SUCCESS:"登录成功事件",AUTH_LOGOUT:"注销事件",AUTH_TOKEN_EXPIRED:"令牌过期事件",REQUEST_ERROR:"请求错误事件",REQUEST_TIMEOUT:"请求超时事件",REQUEST_NETWORK_ERROR:"网络错误事件",UI_SHOW_LOADING:"显示加载事件",UI_HIDE_LOADING:"隐藏加载事件",UI_SHOW_MESSAGE:"显示消息事件"};class b{static instance=null;listeners={};debugMode;constructor(t=!1){this.debugMode=t,Object.keys(A).forEach(e=>{this.listeners[e]=new Set})}static getInstance(t){return b.instance||(b.instance=new b(t)),b.instance}on(t,e){this.debugLog(`添加事件监听: ${A[t]}`),this.listeners[t].add(e)}emit(t,e){this.debugLog(`触发事件: ${A[t]}`,e),this.listeners[t].forEach(r=>{try{r(e)}catch(s){console.error(`事件 ${A[t]} 处理出错:`,s)}})}off(t,e){this.debugLog(`移除事件监听: ${A[t]}`),this.listeners[t].delete(e)}once(t,e){this.debugLog(`添加一次性事件监听: ${A[t]}`);const r=s=>{e(s),this.off(t,r)};this.on(t,r)}clear(){this.debugLog("清除所有事件监听器"),Object.values(this.listeners).forEach(t=>t.clear())}getListenerCount(t){return this.listeners[t].size}debugLog(t,e){this.debugMode&&console.log(`[EventEmitter] ${t}`,e||"")}}class P{static OPERATORS=new Set(["+","-","*","/"]);static VALID_CHARS_REG=/^[0-9+\-*/().\s]+$/;static PRIORITY_MAP=new Map([["+",1],["-",1],["*",2],["/",2],["(",0],[")",0]]);static getPriority(t){return this.PRIORITY_MAP.get(t)??0}static validateExpression(t){if(!t)throw new Error("Expression cannot be empty");if(!this.VALID_CHARS_REG.test(t))throw new Error("Expression contains invalid characters")}static processClosingParenthesis(t,e){for(;!t.isEmpty();){if(t.peek()==="("){t.pop();break}const s=t.pop();s&&e.push(s)}}static processOperator(t,e,r){for(;!e.isEmpty();){const s=e.peek();if(!s||s==="(")break;if(this.getPriority(t)<=this.getPriority(s)){const i=e.pop();i&&r.push(i)}else break}e.push(t)}static applyOperator(t,e,r){switch(r){case"+":return t+e;case"-":return t-e;case"*":return t*e;case"/":if(e===0)throw new Error("Division by zero");return t/e;default:throw new Error("Invalid operator")}}static FLOAT_NUM_REG=/^-?\d*\.?\d+$/;static EXPRESSION_REG=new RegExp("(?<!\\d)-?\\d*\\.?\\d+|[+\\-*/()]","g");static toArr(t){this.validateExpression(t);const e=t.match(P.EXPRESSION_REG);if(!e)throw new Error("Invalid expression format");return e.filter(r=>r.trim()!=="").map(r=>{if(this.FLOAT_NUM_REG.test(r)||this.OPERATORS.has(r)||r==="("||r===")")return r;throw new Error(`Invalid token: ${r}`)})}static infixToPostfix(t){if(!t?.trim())throw new Error("Expression cannot be empty");const e=new L,r=this.toArr(t);console.log(r);const s=[];for(const i of r)this.FLOAT_NUM_REG.test(i)?s.push(i):i==="("?e.push(i):i===")"?this.processClosingParenthesis(e,s):this.OPERATORS.has(i)&&this.processOperator(i,e,s);for(;!e.isEmpty();){const i=e.pop();i&&i!=="("&&s.push(i)}return{postfix:s.join(" "),postfixArr:s}}static evaluatePostfix(t){if(!t.length)throw new Error("Postfix expression cannot be empty");typeof t=="string"&&(t=P.toArr(t));const e=new L;for(const r of t)if(this.FLOAT_NUM_REG.test(r))e.push(parseFloat(r));else if(this.OPERATORS.has(r)){const s=e.pop(),i=e.pop();if(i===void 0||s===void 0)throw new Error("Invalid postfix expression");e.push(this.applyOperator(i,s,r))}return e.pop()??0}}class ${static isMatchingPair(t,e){return t==="("&&e===")"||t==="{"&&e==="}"||t==="["&&e==="]"}static arr_2d_init(t,e,r=!1){return typeof r=="boolean"?Array.from({length:t},()=>Array(e).fill(r)):Array.from({length:t},()=>Array(e).fill(r))}static isvalidBrackets(t){const e=new L;for(let r=0,s=t.length;r<s;r++){const i=t[r];if(["{","[","("].includes(i))e.push(i);else if(["}","]",")"].includes(i)){if(e.isEmpty())return!1;const n=e.pop();if(!n||!this.isMatchingPair(n,i))return!1}}return e.isEmpty()}static findPath(t,e,r){const s=t.length,i=t[0].length,n=$.arr_2d_init(s,i,!1),a=new L,u=[[-1,0],[0,1],[1,0],[0,-1]];function m(p,c){if(p<0||p>=s||c<0||c>=i||t[p][c]===1||n[p][c])return!1;if(t[p][c]===2)return a.push([p,c]),!0;n[p][c]=!0,a.push([p,c]);for(const[f,y]of u){const O=p+f,T=c+y;if(m(O,T))return!0}return a.pop(),!1}return m(e,r),a}}h.Arr=tt,h.ArrQueue=R,h.ArrStack=L,h.BitPerm=nt,h.Color=at,h.DateEx=v,h.Dictionary=q,h.Emitter=b,h.Expression=P,h.Func=K,h.Graph=Z,h.LRU=W,h.Line=w,h.LinkedList=J,h.Log=I,h.Matrix=x,h.MaxHeap=_,h.MemoizeMap=et,h.MinHeap=D,h.MinStack=Q,h.Num=d,h.Obj=rt,h.ObjQueue=B,h.ObjStack=j,h.Point=l,h.Reg=st,h.Roman=it,h.StackApplication=$,h.Str=S,h.TrafficLight=C,h.Triangle=g,h.Vector=E,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}));
package/index.d.ts CHANGED
@@ -626,6 +626,21 @@ declare module "jc-structure" {
626
626
  * @param n 正整数
627
627
  */
628
628
  getPythagoreanTriple(n: number): [number, number, number];
629
+ /**
630
+ * #### 计算在1到x的范围内,能被a、b、c中至少一个数整除的整数个数
631
+ * - 采用容斥原理,计算在1到x的范围内,能被a、b、c中至少一个数整除的整数个数
632
+ * - 奇加偶减
633
+ * @param x
634
+ * @param a
635
+ * @param b
636
+ * @param c
637
+ */
638
+ static exclusionPrinciple(
639
+ x: number,
640
+ a: number,
641
+ b: number,
642
+ c: number
643
+ ): number;
629
644
  }
630
645
  var Num: NumConstructor;
631
646
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jc-structure",
3
3
  "private": false,
4
- "version": "0.2.15",
4
+ "version": "0.2.16",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",