@konoui/mjimage 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +10 -10
- package/dist/index.d.cts +87 -36
- package/dist/index.d.ts +87 -36
- package/dist/index.js +820 -790
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Sn = "MS Gothic, sans-serif", wt = {
|
|
2
2
|
WIDTH: 66,
|
|
3
3
|
HEIGHT: 90,
|
|
4
4
|
TEXT_SCALE: 0.8,
|
|
@@ -6,7 +6,7 @@ const vn = "MS Gothic, sans-serif", wt = {
|
|
|
6
6
|
}, en = {
|
|
7
7
|
WIDTH: 125,
|
|
8
8
|
HEIGHT: 27.5
|
|
9
|
-
},
|
|
9
|
+
}, Is = { BASE: 40 }, X = ",", p = {
|
|
10
10
|
/**
|
|
11
11
|
* 萬子
|
|
12
12
|
*/
|
|
@@ -27,7 +27,7 @@ const vn = "MS Gothic, sans-serif", wt = {
|
|
|
27
27
|
* 裏牌
|
|
28
28
|
*/
|
|
29
29
|
BACK: "_"
|
|
30
|
-
},
|
|
30
|
+
}, m = {
|
|
31
31
|
/**
|
|
32
32
|
* ツモ牌を表す
|
|
33
33
|
*/
|
|
@@ -148,7 +148,7 @@ const vn = "MS Gothic, sans-serif", wt = {
|
|
|
148
148
|
[_.S]: "南",
|
|
149
149
|
[_.W]: "西",
|
|
150
150
|
[_.N]: "北"
|
|
151
|
-
},
|
|
151
|
+
}, On = {
|
|
152
152
|
[k.E1]: "東1局",
|
|
153
153
|
[k.E2]: "東2局",
|
|
154
154
|
[k.E3]: "東3局",
|
|
@@ -170,7 +170,7 @@ function I(s, t) {
|
|
|
170
170
|
if (!s)
|
|
171
171
|
throw new Error(t);
|
|
172
172
|
}
|
|
173
|
-
class
|
|
173
|
+
class Go {
|
|
174
174
|
ctx = null;
|
|
175
175
|
strText;
|
|
176
176
|
numText;
|
|
@@ -197,13 +197,13 @@ class Uo {
|
|
|
197
197
|
};
|
|
198
198
|
measureTableFontContext = (t) => {
|
|
199
199
|
const e = this.measureFontContext(
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
Sn,
|
|
201
|
+
Is.BASE * t
|
|
202
202
|
);
|
|
203
203
|
return e.textHeight = e.textWidth, e.numHeight = e.numWidth, e;
|
|
204
204
|
};
|
|
205
205
|
}
|
|
206
|
-
class
|
|
206
|
+
class Ns {
|
|
207
207
|
input;
|
|
208
208
|
position;
|
|
209
209
|
nextPosition;
|
|
@@ -237,29 +237,29 @@ class Is {
|
|
|
237
237
|
const fe = (s, t) => {
|
|
238
238
|
if (s.t == t.t) {
|
|
239
239
|
if (O(s) && O(t)) {
|
|
240
|
-
if (s.has(
|
|
241
|
-
if (t.has(
|
|
240
|
+
if (s.has(m.RED)) return -1;
|
|
241
|
+
if (t.has(m.RED)) return 1;
|
|
242
242
|
}
|
|
243
243
|
return s.n - t.n;
|
|
244
244
|
}
|
|
245
245
|
const e = [p.M, p.P, p.S, p.Z, p.BACK];
|
|
246
246
|
return e.indexOf(s.t) - e.indexOf(t.t);
|
|
247
|
-
},
|
|
247
|
+
}, Ts = (s, t) => {
|
|
248
248
|
const e = [
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
249
|
+
m.HORIZONTAL,
|
|
250
|
+
m.TSUMO,
|
|
251
|
+
m.RON,
|
|
252
|
+
m.IMAGE_DORA,
|
|
253
|
+
m.COLOR_GRAYSCALE,
|
|
254
|
+
m.RED
|
|
255
255
|
];
|
|
256
256
|
return e.indexOf(s) - e.indexOf(t);
|
|
257
|
-
},
|
|
257
|
+
}, vs = (s) => {
|
|
258
258
|
const t = [];
|
|
259
259
|
s.forEach((n, i) => {
|
|
260
|
-
n.has(
|
|
260
|
+
n.has(m.HORIZONTAL) && t.push(i);
|
|
261
261
|
});
|
|
262
|
-
const e = s.filter((n) => !n.has(
|
|
262
|
+
const e = s.filter((n) => !n.has(m.HORIZONTAL)).sort(fe);
|
|
263
263
|
return t.forEach((n) => {
|
|
264
264
|
e.splice(n, 0, s[n]);
|
|
265
265
|
}), e;
|
|
@@ -267,7 +267,7 @@ const fe = (s, t) => {
|
|
|
267
267
|
function O(s) {
|
|
268
268
|
return s.isNum() && s.n == 5;
|
|
269
269
|
}
|
|
270
|
-
function
|
|
270
|
+
function Ss(s) {
|
|
271
271
|
const t = Object.values(p).find((e) => e === s);
|
|
272
272
|
return t ? [t, !0] : [p.BACK, !1];
|
|
273
273
|
}
|
|
@@ -287,7 +287,7 @@ class y {
|
|
|
287
287
|
* 文字列の牌を返す。
|
|
288
288
|
*/
|
|
289
289
|
toString() {
|
|
290
|
-
return this.t === p.BACK ? this.t : `${[...this.ops].sort(
|
|
290
|
+
return this.t === p.BACK ? this.t : `${[...this.ops].sort(Ts).join("")}${this.n}${this.t}`;
|
|
291
291
|
}
|
|
292
292
|
toJSON() {
|
|
293
293
|
return this.toString();
|
|
@@ -327,7 +327,7 @@ class T {
|
|
|
327
327
|
_type;
|
|
328
328
|
constructor(t, e) {
|
|
329
329
|
if (this._tiles = t, this._type = e, this.isCalled()) {
|
|
330
|
-
this._tiles =
|
|
330
|
+
this._tiles = vs(this._tiles);
|
|
331
331
|
return;
|
|
332
332
|
}
|
|
333
333
|
if (this._type != E.IMAGE_DISCARD) {
|
|
@@ -452,7 +452,7 @@ class R extends T {
|
|
|
452
452
|
if (e.length < t.length) {
|
|
453
453
|
if (O(n)) {
|
|
454
454
|
const i = new y(n.t, 5);
|
|
455
|
-
super([i.clone({ add:
|
|
455
|
+
super([i.clone({ add: m.RED }), i, i, i], E.AN_KAN);
|
|
456
456
|
return;
|
|
457
457
|
}
|
|
458
458
|
super([n, n, n, n], E.AN_KAN);
|
|
@@ -470,7 +470,7 @@ class R extends T {
|
|
|
470
470
|
* ブロックを構成する裏返しの牌を含む牌の配列を返す。
|
|
471
471
|
*/
|
|
472
472
|
get tilesWithBack() {
|
|
473
|
-
const t = this.tiles[0].clone({ remove:
|
|
473
|
+
const t = this.tiles[0].clone({ remove: m.RED }), e = O(t) ? t.clone({ add: m.RED }) : t;
|
|
474
474
|
return [new y(p.BACK, 0), e, t, new y(p.BACK, 0)];
|
|
475
475
|
}
|
|
476
476
|
static from(t) {
|
|
@@ -491,7 +491,7 @@ class z extends T {
|
|
|
491
491
|
return bt(this.tiles);
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
|
-
class
|
|
494
|
+
class P extends T {
|
|
495
495
|
constructor(t) {
|
|
496
496
|
super(t, E.SHO_KAN);
|
|
497
497
|
}
|
|
@@ -503,8 +503,8 @@ class H extends T {
|
|
|
503
503
|
* カカンした牌はポンした牌の前に追加される。
|
|
504
504
|
*/
|
|
505
505
|
static fromPon(t, e) {
|
|
506
|
-
const n = t.tiles.findIndex((r) => r.has(
|
|
507
|
-
return i.splice(n, 0, e.clone({ add:
|
|
506
|
+
const n = t.tiles.findIndex((r) => r.has(m.HORIZONTAL)), i = [...t.tiles];
|
|
507
|
+
return i.splice(n, 0, e.clone({ add: m.HORIZONTAL })), new P(i);
|
|
508
508
|
}
|
|
509
509
|
toString() {
|
|
510
510
|
return bt(this.tiles);
|
|
@@ -543,7 +543,7 @@ class gt extends T {
|
|
|
543
543
|
return bt(this.tiles);
|
|
544
544
|
}
|
|
545
545
|
}
|
|
546
|
-
class
|
|
546
|
+
class kn extends T {
|
|
547
547
|
constructor(t) {
|
|
548
548
|
super([t], E.ISOLATED);
|
|
549
549
|
}
|
|
@@ -579,9 +579,9 @@ class Le extends T {
|
|
|
579
579
|
const ne = (s, t) => {
|
|
580
580
|
switch (t) {
|
|
581
581
|
case E.CHI:
|
|
582
|
-
const e = s.find((i) => i.has(
|
|
582
|
+
const e = s.find((i) => i.has(m.HORIZONTAL));
|
|
583
583
|
I(e != null, `chi block does not have horizontal ops: ${s}`);
|
|
584
|
-
const n = s.filter((i) => !i.has(
|
|
584
|
+
const n = s.filter((i) => !i.has(m.HORIZONTAL));
|
|
585
585
|
return new V([e, n[0], n[1]]);
|
|
586
586
|
case E.PON:
|
|
587
587
|
return new U([s[0], s[1], s[2]]);
|
|
@@ -590,7 +590,7 @@ const ne = (s, t) => {
|
|
|
590
590
|
case E.DAI_KAN:
|
|
591
591
|
return new z(s);
|
|
592
592
|
case E.SHO_KAN:
|
|
593
|
-
return new
|
|
593
|
+
return new P(s);
|
|
594
594
|
case E.THREE:
|
|
595
595
|
return new L(s);
|
|
596
596
|
case E.RUN:
|
|
@@ -598,7 +598,7 @@ const ne = (s, t) => {
|
|
|
598
598
|
case E.PAIR:
|
|
599
599
|
return new C(s[0], s[1]);
|
|
600
600
|
case E.ISOLATED:
|
|
601
|
-
return new
|
|
601
|
+
return new kn(s[0]);
|
|
602
602
|
case E.HAND:
|
|
603
603
|
return new Tt(s);
|
|
604
604
|
default:
|
|
@@ -630,7 +630,7 @@ class D {
|
|
|
630
630
|
* セパレータ前後は一つのブロックを意味する。
|
|
631
631
|
*/
|
|
632
632
|
tileSeparators() {
|
|
633
|
-
const t = new
|
|
633
|
+
const t = new Ns(this.input), e = [];
|
|
634
634
|
let n = [];
|
|
635
635
|
for (this.validate(this.input); ; ) {
|
|
636
636
|
t.skipWhitespace();
|
|
@@ -646,15 +646,15 @@ class D {
|
|
|
646
646
|
e.push(new y(r, 0)), t.readChar();
|
|
647
647
|
continue;
|
|
648
648
|
}
|
|
649
|
-
e.push(...
|
|
649
|
+
e.push(...ks(n, r)), n = [], t.readChar();
|
|
650
650
|
continue;
|
|
651
651
|
} else {
|
|
652
|
-
const [a, c] =
|
|
652
|
+
const [a, c] = Cs(t);
|
|
653
653
|
if (c) {
|
|
654
654
|
n.push(a), t.readChar();
|
|
655
655
|
continue;
|
|
656
656
|
}
|
|
657
|
-
const [l, d] =
|
|
657
|
+
const [l, d] = Cn(i);
|
|
658
658
|
if (!d) throw new Error(`expected a number but got: ${i}`);
|
|
659
659
|
n.push({ n: l });
|
|
660
660
|
}
|
|
@@ -666,12 +666,12 @@ class D {
|
|
|
666
666
|
}
|
|
667
667
|
reconstruct(t) {
|
|
668
668
|
if (t.length > 18) return t;
|
|
669
|
-
const e = t.findIndex((a) => a instanceof y && a.has(
|
|
669
|
+
const e = t.findIndex((a) => a instanceof y && a.has(m.TSUMO));
|
|
670
670
|
if (e < 0) return t;
|
|
671
671
|
const n = t.findIndex((a) => a === X);
|
|
672
672
|
if (n > -1 && e > n) return t;
|
|
673
673
|
const i = n < 0 ? t.length : n, r = t.slice(0, i), o = r[e];
|
|
674
|
-
return r.some((a) => a instanceof y && a.has(
|
|
674
|
+
return r.some((a) => a instanceof y && a.has(m.HORIZONTAL)) ? t : [
|
|
675
675
|
...r.slice(0, e),
|
|
676
676
|
...r.slice(e + 1, i),
|
|
677
677
|
X,
|
|
@@ -708,14 +708,14 @@ class D {
|
|
|
708
708
|
function nn(s) {
|
|
709
709
|
if (s.length === 0) return E.UNKNOWN;
|
|
710
710
|
if (s.length === 1)
|
|
711
|
-
return s[0].has(
|
|
712
|
-
const t = s.every((r) => r.equals(s[0])), e = s.filter((r) => r.has(
|
|
713
|
-
(r) => r.has(
|
|
711
|
+
return s[0].has(m.IMAGE_DORA) ? E.IMAGE_DORA : s[0].has(m.TSUMO) ? E.TSUMO : E.HAND;
|
|
712
|
+
const t = s.every((r) => r.equals(s[0])), e = s.filter((r) => r.has(m.HORIZONTAL)).length, n = s.filter(
|
|
713
|
+
(r) => r.has(m.TSUMO) || r.has(m.IMAGE_DORA)
|
|
714
714
|
).length, i = s.filter((r) => r.t == p.BACK).length;
|
|
715
715
|
if (n > 0) return E.UNKNOWN;
|
|
716
716
|
if (e == 0 && i == 0) return E.HAND;
|
|
717
717
|
if (s.length === 3 && i === 0)
|
|
718
|
-
return t ? E.PON : e == 1 &&
|
|
718
|
+
return t ? E.PON : e == 1 && Os(s) ? E.CHI : E.IMAGE_DISCARD;
|
|
719
719
|
if (s.length == 4 && i == 2) return E.AN_KAN;
|
|
720
720
|
if (s.length == 4 && t) {
|
|
721
721
|
if (e == 1) return E.DAI_KAN;
|
|
@@ -723,7 +723,7 @@ function nn(s) {
|
|
|
723
723
|
}
|
|
724
724
|
return e == 1 || n == 0 ? E.IMAGE_DISCARD : E.UNKNOWN;
|
|
725
725
|
}
|
|
726
|
-
function
|
|
726
|
+
function Os(s) {
|
|
727
727
|
const t = [...s].sort(fe);
|
|
728
728
|
if (t.some((n) => t[0].t != n.t)) return !1;
|
|
729
729
|
const e = t.map((n) => n.n);
|
|
@@ -731,14 +731,14 @@ function Ss(s) {
|
|
|
731
731
|
if (e[n] != e[n + 1] - 1) return !1;
|
|
732
732
|
return !0;
|
|
733
733
|
}
|
|
734
|
-
function
|
|
734
|
+
function ks(s, t) {
|
|
735
735
|
return s.map((e) => {
|
|
736
736
|
let n = new y(t, e.n, e.ops);
|
|
737
|
-
return n.isNum() && n.n == 0 && (n = n.clone({ n: 5, add:
|
|
737
|
+
return n.isNum() && n.n == 0 && (n = n.clone({ n: 5, add: m.RED })), n;
|
|
738
738
|
});
|
|
739
739
|
}
|
|
740
740
|
function sn(s, t) {
|
|
741
|
-
const [e, n] =
|
|
741
|
+
const [e, n] = Ss(s);
|
|
742
742
|
if (n) return [e, !0];
|
|
743
743
|
if ((s === "w" || s === "d") && t.length > 0) {
|
|
744
744
|
for (let r = 0; r < t.length; r++) {
|
|
@@ -749,25 +749,25 @@ function sn(s, t) {
|
|
|
749
749
|
}
|
|
750
750
|
return [p.BACK, !1];
|
|
751
751
|
}
|
|
752
|
-
function
|
|
752
|
+
function Cn(s) {
|
|
753
753
|
const t = Number(s), e = 0 <= t && t <= 9;
|
|
754
754
|
return [t, e];
|
|
755
755
|
}
|
|
756
|
-
function
|
|
757
|
-
const t = Object.values(
|
|
756
|
+
function Cs(s) {
|
|
757
|
+
const t = Object.values(m);
|
|
758
758
|
if (!t.includes(s.char)) return [new y(p.BACK, 0), !1];
|
|
759
759
|
const e = [];
|
|
760
760
|
for (let n = 0; n < 4; n++) {
|
|
761
761
|
const i = s.peekCharN(n);
|
|
762
762
|
if (t.includes(i)) e.push(i);
|
|
763
763
|
else {
|
|
764
|
-
const [r, o] =
|
|
764
|
+
const [r, o] = Cn(i);
|
|
765
765
|
if (!o) break;
|
|
766
766
|
for (const c of e) s.readChar();
|
|
767
767
|
const a = new y(p.BACK, r, e);
|
|
768
|
-
if (a.has(
|
|
768
|
+
if (a.has(m.RED) && a.n != 5)
|
|
769
769
|
throw new Error(`red dora operator can only be used with 5, got: ${r}`);
|
|
770
|
-
if (a.has(
|
|
770
|
+
if (a.has(m.IMAGE_DORA) && a.has(m.TSUMO))
|
|
771
771
|
throw new Error("cannot specify both dora and tsumo operators");
|
|
772
772
|
return [a, !0];
|
|
773
773
|
}
|
|
@@ -785,7 +785,7 @@ function W(s) {
|
|
|
785
785
|
const te = (s) => {
|
|
786
786
|
let t = s.substring(0, 2), e = Number(s.substring(2, 3));
|
|
787
787
|
return e == 4 ? (e = 1, t = vt(t)) : e++, `${t}${e}`;
|
|
788
|
-
},
|
|
788
|
+
}, Zo = (s) => te(te(te(s))), Rs = (s) => s.substring(0, 2), vt = (s) => {
|
|
789
789
|
let t = Number(s.toString()[0]);
|
|
790
790
|
return t = t % 4 + 1, `${t}${p.Z}`;
|
|
791
791
|
}, Ke = (s) => {
|
|
@@ -832,12 +832,12 @@ function ze(...s) {
|
|
|
832
832
|
}
|
|
833
833
|
}
|
|
834
834
|
}
|
|
835
|
-
function
|
|
835
|
+
function Ms(...s) {
|
|
836
836
|
return ze(...s);
|
|
837
837
|
}
|
|
838
|
-
const { cos:
|
|
838
|
+
const { cos: xs, sin: $s, PI: Ps } = Math;
|
|
839
839
|
function Hs(s, t, e) {
|
|
840
|
-
const n =
|
|
840
|
+
const n = xs(s), i = $s(s), r = {
|
|
841
841
|
a: n,
|
|
842
842
|
c: -i,
|
|
843
843
|
e: 0,
|
|
@@ -851,17 +851,17 @@ function Hs(s, t, e) {
|
|
|
851
851
|
Ne(-t, -e)
|
|
852
852
|
]);
|
|
853
853
|
}
|
|
854
|
-
function
|
|
855
|
-
return Hs(s *
|
|
856
|
-
}
|
|
857
|
-
function Bs(s) {
|
|
858
|
-
return Ws(s);
|
|
854
|
+
function Bs(s, t = void 0, e = void 0) {
|
|
855
|
+
return Hs(s * Ps / 180, t, e);
|
|
859
856
|
}
|
|
860
857
|
function Ws(s) {
|
|
858
|
+
return Ds(s);
|
|
859
|
+
}
|
|
860
|
+
function Ds(s) {
|
|
861
861
|
return `matrix(${s.a},${s.b},${s.c},${s.d},${s.e},${s.f})`;
|
|
862
862
|
}
|
|
863
|
-
const
|
|
864
|
-
function
|
|
863
|
+
const Rn = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", Ls = Rn + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040", Ks = "[" + Rn + "][" + Ls + "]*", zs = new RegExp("^" + Ks + "$");
|
|
864
|
+
function Mn(s, t) {
|
|
865
865
|
const e = [];
|
|
866
866
|
let n = t.exec(s);
|
|
867
867
|
for (; n; ) {
|
|
@@ -875,19 +875,19 @@ function Rn(s, t) {
|
|
|
875
875
|
return e;
|
|
876
876
|
}
|
|
877
877
|
const pe = function(s) {
|
|
878
|
-
const t =
|
|
878
|
+
const t = zs.exec(s);
|
|
879
879
|
return !(t === null || typeof t > "u");
|
|
880
880
|
};
|
|
881
|
-
function
|
|
881
|
+
function Us(s) {
|
|
882
882
|
return typeof s < "u";
|
|
883
883
|
}
|
|
884
|
-
const
|
|
884
|
+
const js = {
|
|
885
885
|
allowBooleanAttributes: !1,
|
|
886
886
|
//A tag can have attributes without any value
|
|
887
887
|
unpairedTags: []
|
|
888
888
|
};
|
|
889
|
-
function
|
|
890
|
-
t = Object.assign({},
|
|
889
|
+
function Fs(s, t) {
|
|
890
|
+
t = Object.assign({}, js, t);
|
|
891
891
|
const e = [];
|
|
892
892
|
let n = !1, i = !1;
|
|
893
893
|
s[0] === "\uFEFF" && (s = s.substr(1));
|
|
@@ -906,11 +906,11 @@ function js(s, t) {
|
|
|
906
906
|
for (; r < s.length && s[r] !== ">" && s[r] !== " " && s[r] !== " " && s[r] !== `
|
|
907
907
|
` && s[r] !== "\r"; r++)
|
|
908
908
|
c += s[r];
|
|
909
|
-
if (c = c.trim(), c[c.length - 1] === "/" && (c = c.substring(0, c.length - 1), r--), !
|
|
909
|
+
if (c = c.trim(), c[c.length - 1] === "/" && (c = c.substring(0, c.length - 1), r--), !Qs(c)) {
|
|
910
910
|
let h;
|
|
911
911
|
return c.trim().length === 0 ? h = "Invalid space after '<'." : h = "Tag '" + c + "' is an invalid name.", v("InvalidTag", h, $(s, r));
|
|
912
912
|
}
|
|
913
|
-
const l =
|
|
913
|
+
const l = Ys(s, r);
|
|
914
914
|
if (l === !1)
|
|
915
915
|
return v("InvalidAttr", "Attributes for '" + c + "' have open quote.", $(s, r));
|
|
916
916
|
let d = l.value;
|
|
@@ -959,7 +959,7 @@ function js(s, t) {
|
|
|
959
959
|
} else
|
|
960
960
|
break;
|
|
961
961
|
else if (s[r] === "&") {
|
|
962
|
-
const h =
|
|
962
|
+
const h = Xs(s, r);
|
|
963
963
|
if (h == -1)
|
|
964
964
|
return v("InvalidChar", "char '&' is not expected.", $(s, r));
|
|
965
965
|
r = h;
|
|
@@ -1022,11 +1022,11 @@ function ln(s, t) {
|
|
|
1022
1022
|
}
|
|
1023
1023
|
return t;
|
|
1024
1024
|
}
|
|
1025
|
-
const
|
|
1026
|
-
function
|
|
1025
|
+
const Gs = '"', Zs = "'";
|
|
1026
|
+
function Ys(s, t) {
|
|
1027
1027
|
let e = "", n = "", i = !1;
|
|
1028
1028
|
for (; t < s.length; t++) {
|
|
1029
|
-
if (s[t] ===
|
|
1029
|
+
if (s[t] === Gs || s[t] === Zs)
|
|
1030
1030
|
n === "" ? n = s[t] : n !== s[t] || (n = "");
|
|
1031
1031
|
else if (s[t] === ">" && n === "") {
|
|
1032
1032
|
i = !0;
|
|
@@ -1040,9 +1040,9 @@ function Zs(s, t) {
|
|
|
1040
1040
|
tagClosed: i
|
|
1041
1041
|
};
|
|
1042
1042
|
}
|
|
1043
|
-
const
|
|
1043
|
+
const Vs = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
|
|
1044
1044
|
function hn(s, t) {
|
|
1045
|
-
const e =
|
|
1045
|
+
const e = Mn(s, Vs), n = {};
|
|
1046
1046
|
for (let i = 0; i < e.length; i++) {
|
|
1047
1047
|
if (e[i][1].length === 0)
|
|
1048
1048
|
return v("InvalidAttr", "Attribute '" + e[i][2] + "' has no space in starting.", Wt(e[i]));
|
|
@@ -1051,7 +1051,7 @@ function hn(s, t) {
|
|
|
1051
1051
|
if (e[i][3] === void 0 && !t.allowBooleanAttributes)
|
|
1052
1052
|
return v("InvalidAttr", "boolean attribute '" + e[i][2] + "' is not allowed.", Wt(e[i]));
|
|
1053
1053
|
const r = e[i][2];
|
|
1054
|
-
if (!
|
|
1054
|
+
if (!qs(r))
|
|
1055
1055
|
return v("InvalidAttr", "Attribute '" + r + "' is an invalid name.", Wt(e[i]));
|
|
1056
1056
|
if (!n.hasOwnProperty(r))
|
|
1057
1057
|
n[r] = 1;
|
|
@@ -1060,7 +1060,7 @@ function hn(s, t) {
|
|
|
1060
1060
|
}
|
|
1061
1061
|
return !0;
|
|
1062
1062
|
}
|
|
1063
|
-
function
|
|
1063
|
+
function Js(s, t) {
|
|
1064
1064
|
let e = /\d/;
|
|
1065
1065
|
for (s[t] === "x" && (t++, e = /[\da-fA-F]/); t < s.length; t++) {
|
|
1066
1066
|
if (s[t] === ";")
|
|
@@ -1070,11 +1070,11 @@ function Vs(s, t) {
|
|
|
1070
1070
|
}
|
|
1071
1071
|
return -1;
|
|
1072
1072
|
}
|
|
1073
|
-
function
|
|
1073
|
+
function Xs(s, t) {
|
|
1074
1074
|
if (t++, s[t] === ";")
|
|
1075
1075
|
return -1;
|
|
1076
1076
|
if (s[t] === "#")
|
|
1077
|
-
return t++,
|
|
1077
|
+
return t++, Js(s, t);
|
|
1078
1078
|
let e = 0;
|
|
1079
1079
|
for (; t < s.length; t++, e++)
|
|
1080
1080
|
if (!(s[t].match(/\w/) && e < 20)) {
|
|
@@ -1094,10 +1094,10 @@ function v(s, t, e) {
|
|
|
1094
1094
|
}
|
|
1095
1095
|
};
|
|
1096
1096
|
}
|
|
1097
|
-
function
|
|
1097
|
+
function qs(s) {
|
|
1098
1098
|
return pe(s);
|
|
1099
1099
|
}
|
|
1100
|
-
function
|
|
1100
|
+
function Qs(s) {
|
|
1101
1101
|
return pe(s);
|
|
1102
1102
|
}
|
|
1103
1103
|
function $(s, t) {
|
|
@@ -1111,7 +1111,7 @@ function $(s, t) {
|
|
|
1111
1111
|
function Wt(s) {
|
|
1112
1112
|
return s.startIndex + s[1].length;
|
|
1113
1113
|
}
|
|
1114
|
-
const
|
|
1114
|
+
const ti = {
|
|
1115
1115
|
preserveOrder: !1,
|
|
1116
1116
|
attributeNamePrefix: "@_",
|
|
1117
1117
|
attributesGroupName: !1,
|
|
@@ -1155,8 +1155,8 @@ const Qs = {
|
|
|
1155
1155
|
},
|
|
1156
1156
|
// skipEmptyListItem: false
|
|
1157
1157
|
captureMetaData: !1
|
|
1158
|
-
},
|
|
1159
|
-
return Object.assign({},
|
|
1158
|
+
}, ei = function(s) {
|
|
1159
|
+
return Object.assign({}, ti, s);
|
|
1160
1160
|
};
|
|
1161
1161
|
let se;
|
|
1162
1162
|
typeof Symbol != "function" ? se = "@@xmlMetadata" : se = /* @__PURE__ */ Symbol("XML Node Metadata");
|
|
@@ -1175,7 +1175,7 @@ class ft {
|
|
|
1175
1175
|
return se;
|
|
1176
1176
|
}
|
|
1177
1177
|
}
|
|
1178
|
-
class
|
|
1178
|
+
class ni {
|
|
1179
1179
|
constructor(t) {
|
|
1180
1180
|
this.suppressValidationErr = !t;
|
|
1181
1181
|
}
|
|
@@ -1189,10 +1189,13 @@ class ei {
|
|
|
1189
1189
|
if (r && lt(t, "!ENTITY", e)) {
|
|
1190
1190
|
e += 7;
|
|
1191
1191
|
let c, l;
|
|
1192
|
-
[c, l, e] = this.readEntityExp(t, e + 1, this.suppressValidationErr), l.indexOf("&") === -1
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1192
|
+
if ([c, l, e] = this.readEntityExp(t, e + 1, this.suppressValidationErr), l.indexOf("&") === -1) {
|
|
1193
|
+
const d = c.replace(/[.\-+*:]/g, "\\.");
|
|
1194
|
+
n[c] = {
|
|
1195
|
+
regx: RegExp(`&${d};`, "g"),
|
|
1196
|
+
val: l
|
|
1197
|
+
};
|
|
1198
|
+
}
|
|
1196
1199
|
} else if (r && lt(t, "!ELEMENT", e)) {
|
|
1197
1200
|
e += 8;
|
|
1198
1201
|
const { index: c } = this.readElementExp(t, e + 1);
|
|
@@ -1217,11 +1220,11 @@ class ei {
|
|
|
1217
1220
|
return { entities: n, i: e };
|
|
1218
1221
|
}
|
|
1219
1222
|
readEntityExp(t, e) {
|
|
1220
|
-
e =
|
|
1223
|
+
e = H(t, e);
|
|
1221
1224
|
let n = "";
|
|
1222
1225
|
for (; e < t.length && !/\s/.test(t[e]) && t[e] !== '"' && t[e] !== "'"; )
|
|
1223
1226
|
n += t[e], e++;
|
|
1224
|
-
if (Dt(n), e =
|
|
1227
|
+
if (Dt(n), e = H(t, e), !this.suppressValidationErr) {
|
|
1225
1228
|
if (t.substring(e, e + 6).toUpperCase() === "SYSTEM")
|
|
1226
1229
|
throw new Error("External entities are not supported");
|
|
1227
1230
|
if (t[e] === "%")
|
|
@@ -1231,18 +1234,18 @@ class ei {
|
|
|
1231
1234
|
return [e, i] = this.readIdentifierVal(t, e, "entity"), e--, [n, i, e];
|
|
1232
1235
|
}
|
|
1233
1236
|
readNotationExp(t, e) {
|
|
1234
|
-
e =
|
|
1237
|
+
e = H(t, e);
|
|
1235
1238
|
let n = "";
|
|
1236
1239
|
for (; e < t.length && !/\s/.test(t[e]); )
|
|
1237
1240
|
n += t[e], e++;
|
|
1238
|
-
!this.suppressValidationErr && Dt(n), e =
|
|
1241
|
+
!this.suppressValidationErr && Dt(n), e = H(t, e);
|
|
1239
1242
|
const i = t.substring(e, e + 6).toUpperCase();
|
|
1240
1243
|
if (!this.suppressValidationErr && i !== "SYSTEM" && i !== "PUBLIC")
|
|
1241
1244
|
throw new Error(`Expected SYSTEM or PUBLIC, found "${i}"`);
|
|
1242
|
-
e += i.length, e =
|
|
1245
|
+
e += i.length, e = H(t, e);
|
|
1243
1246
|
let r = null, o = null;
|
|
1244
1247
|
if (i === "PUBLIC")
|
|
1245
|
-
[e, r] = this.readIdentifierVal(t, e, "publicIdentifier"), e =
|
|
1248
|
+
[e, r] = this.readIdentifierVal(t, e, "publicIdentifier"), e = H(t, e), (t[e] === '"' || t[e] === "'") && ([e, o] = this.readIdentifierVal(t, e, "systemIdentifier"));
|
|
1246
1249
|
else if (i === "SYSTEM" && ([e, o] = this.readIdentifierVal(t, e, "systemIdentifier"), !this.suppressValidationErr && !o))
|
|
1247
1250
|
throw new Error("Missing mandatory system identifier for SYSTEM notation");
|
|
1248
1251
|
return { notationName: n, publicIdentifier: r, systemIdentifier: o, index: --e };
|
|
@@ -1259,13 +1262,13 @@ class ei {
|
|
|
1259
1262
|
return e++, [e, i];
|
|
1260
1263
|
}
|
|
1261
1264
|
readElementExp(t, e) {
|
|
1262
|
-
e =
|
|
1265
|
+
e = H(t, e);
|
|
1263
1266
|
let n = "";
|
|
1264
1267
|
for (; e < t.length && !/\s/.test(t[e]); )
|
|
1265
1268
|
n += t[e], e++;
|
|
1266
1269
|
if (!this.suppressValidationErr && !pe(n))
|
|
1267
1270
|
throw new Error(`Invalid element name: "${n}"`);
|
|
1268
|
-
e =
|
|
1271
|
+
e = H(t, e);
|
|
1269
1272
|
let i = "";
|
|
1270
1273
|
if (t[e] === "E" && lt(t, "MPTY", e)) e += 4;
|
|
1271
1274
|
else if (t[e] === "A" && lt(t, "NY", e)) e += 2;
|
|
@@ -1283,20 +1286,20 @@ class ei {
|
|
|
1283
1286
|
};
|
|
1284
1287
|
}
|
|
1285
1288
|
readAttlistExp(t, e) {
|
|
1286
|
-
e =
|
|
1289
|
+
e = H(t, e);
|
|
1287
1290
|
let n = "";
|
|
1288
1291
|
for (; e < t.length && !/\s/.test(t[e]); )
|
|
1289
1292
|
n += t[e], e++;
|
|
1290
|
-
Dt(n), e =
|
|
1293
|
+
Dt(n), e = H(t, e);
|
|
1291
1294
|
let i = "";
|
|
1292
1295
|
for (; e < t.length && !/\s/.test(t[e]); )
|
|
1293
1296
|
i += t[e], e++;
|
|
1294
1297
|
if (!Dt(i))
|
|
1295
1298
|
throw new Error(`Invalid attribute name: "${i}"`);
|
|
1296
|
-
e =
|
|
1299
|
+
e = H(t, e);
|
|
1297
1300
|
let r = "";
|
|
1298
1301
|
if (t.substring(e, e + 8).toUpperCase() === "NOTATION") {
|
|
1299
|
-
if (r = "NOTATION", e += 8, e =
|
|
1302
|
+
if (r = "NOTATION", e += 8, e = H(t, e), t[e] !== "(")
|
|
1300
1303
|
throw new Error(`Expected '(', found "${t[e]}"`);
|
|
1301
1304
|
e++;
|
|
1302
1305
|
let a = [];
|
|
@@ -1306,7 +1309,7 @@ class ei {
|
|
|
1306
1309
|
c += t[e], e++;
|
|
1307
1310
|
if (c = c.trim(), !Dt(c))
|
|
1308
1311
|
throw new Error(`Invalid notation name: "${c}"`);
|
|
1309
|
-
a.push(c), t[e] === "|" && (e++, e =
|
|
1312
|
+
a.push(c), t[e] === "|" && (e++, e = H(t, e));
|
|
1310
1313
|
}
|
|
1311
1314
|
if (t[e] !== ")")
|
|
1312
1315
|
throw new Error("Unterminated list of notations");
|
|
@@ -1318,7 +1321,7 @@ class ei {
|
|
|
1318
1321
|
if (!this.suppressValidationErr && !a.includes(r.toUpperCase()))
|
|
1319
1322
|
throw new Error(`Invalid attribute type: "${r}"`);
|
|
1320
1323
|
}
|
|
1321
|
-
e =
|
|
1324
|
+
e = H(t, e);
|
|
1322
1325
|
let o = "";
|
|
1323
1326
|
return t.substring(e, e + 8).toUpperCase() === "#REQUIRED" ? (o = "#REQUIRED", e += 8) : t.substring(e, e + 7).toUpperCase() === "#IMPLIED" ? (o = "#IMPLIED", e += 7) : [e, o] = this.readIdentifierVal(t, e, "ATTLIST"), {
|
|
1324
1327
|
elementName: n,
|
|
@@ -1329,7 +1332,7 @@ class ei {
|
|
|
1329
1332
|
};
|
|
1330
1333
|
}
|
|
1331
1334
|
}
|
|
1332
|
-
const
|
|
1335
|
+
const H = (s, t) => {
|
|
1333
1336
|
for (; t < s.length && /\s/.test(s[t]); )
|
|
1334
1337
|
t++;
|
|
1335
1338
|
return t;
|
|
@@ -1344,7 +1347,7 @@ function Dt(s) {
|
|
|
1344
1347
|
return s;
|
|
1345
1348
|
throw new Error(`Invalid entity name ${s}`);
|
|
1346
1349
|
}
|
|
1347
|
-
const
|
|
1350
|
+
const si = /^[-+]?0x[a-fA-F0-9]+$/, ii = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, ri = {
|
|
1348
1351
|
hex: !0,
|
|
1349
1352
|
// oct: false,
|
|
1350
1353
|
leadingZeros: !0,
|
|
@@ -1352,20 +1355,20 @@ const ni = /^[-+]?0x[a-fA-F0-9]+$/, si = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, i
|
|
|
1352
1355
|
eNotation: !0
|
|
1353
1356
|
//skipLike: /regex/
|
|
1354
1357
|
};
|
|
1355
|
-
function
|
|
1356
|
-
if (t = Object.assign({},
|
|
1358
|
+
function oi(s, t = {}) {
|
|
1359
|
+
if (t = Object.assign({}, ri, t), !s || typeof s != "string") return s;
|
|
1357
1360
|
let e = s.trim();
|
|
1358
1361
|
if (t.skipLike !== void 0 && t.skipLike.test(e)) return s;
|
|
1359
1362
|
if (s === "0") return 0;
|
|
1360
|
-
if (t.hex &&
|
|
1361
|
-
return
|
|
1363
|
+
if (t.hex && si.test(e))
|
|
1364
|
+
return hi(e, 16);
|
|
1362
1365
|
if (e.includes("e") || e.includes("E"))
|
|
1363
|
-
return
|
|
1366
|
+
return ci(s, e, t);
|
|
1364
1367
|
{
|
|
1365
|
-
const n =
|
|
1368
|
+
const n = ii.exec(e);
|
|
1366
1369
|
if (n) {
|
|
1367
1370
|
const i = n[1] || "", r = n[2];
|
|
1368
|
-
let o =
|
|
1371
|
+
let o = li(n[3]);
|
|
1369
1372
|
const a = i ? (
|
|
1370
1373
|
// 0., -00., 000.
|
|
1371
1374
|
s[r.length + 1] === "."
|
|
@@ -1386,10 +1389,10 @@ function ri(s, t = {}) {
|
|
|
1386
1389
|
return s;
|
|
1387
1390
|
}
|
|
1388
1391
|
}
|
|
1389
|
-
const
|
|
1390
|
-
function
|
|
1392
|
+
const ai = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;
|
|
1393
|
+
function ci(s, t, e) {
|
|
1391
1394
|
if (!e.eNotation) return s;
|
|
1392
|
-
const n = t.match(
|
|
1395
|
+
const n = t.match(ai);
|
|
1393
1396
|
if (n) {
|
|
1394
1397
|
let i = n[1] || "";
|
|
1395
1398
|
const r = n[3].indexOf("e") === -1 ? "E" : "e", o = n[2], a = i ? (
|
|
@@ -1400,23 +1403,23 @@ function ai(s, t, e) {
|
|
|
1400
1403
|
} else
|
|
1401
1404
|
return s;
|
|
1402
1405
|
}
|
|
1403
|
-
function
|
|
1406
|
+
function li(s) {
|
|
1404
1407
|
return s && s.indexOf(".") !== -1 && (s = s.replace(/0+$/, ""), s === "." ? s = "0" : s[0] === "." ? s = "0" + s : s[s.length - 1] === "." && (s = s.substring(0, s.length - 1))), s;
|
|
1405
1408
|
}
|
|
1406
|
-
function
|
|
1409
|
+
function hi(s, t) {
|
|
1407
1410
|
if (parseInt) return parseInt(s, t);
|
|
1408
1411
|
if (Number.parseInt) return Number.parseInt(s, t);
|
|
1409
1412
|
if (window && window.parseInt) return window.parseInt(s, t);
|
|
1410
1413
|
throw new Error("parseInt, Number.parseInt, window.parseInt are not supported");
|
|
1411
1414
|
}
|
|
1412
|
-
function
|
|
1415
|
+
function xn(s) {
|
|
1413
1416
|
return typeof s == "function" ? s : Array.isArray(s) ? (t) => {
|
|
1414
1417
|
for (const e of s)
|
|
1415
1418
|
if (typeof e == "string" && t === e || e instanceof RegExp && e.test(t))
|
|
1416
1419
|
return !0;
|
|
1417
1420
|
} : () => !1;
|
|
1418
1421
|
}
|
|
1419
|
-
class
|
|
1422
|
+
class di {
|
|
1420
1423
|
constructor(t) {
|
|
1421
1424
|
if (this.options = t, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = {
|
|
1422
1425
|
apos: { regex: /&(apos|#39|#x27);/g, val: "'" },
|
|
@@ -1437,9 +1440,9 @@ class hi {
|
|
|
1437
1440
|
copyright: { regex: /&(copy|#169);/g, val: "©" },
|
|
1438
1441
|
reg: { regex: /&(reg|#174);/g, val: "®" },
|
|
1439
1442
|
inr: { regex: /&(inr|#8377);/g, val: "₹" },
|
|
1440
|
-
num_dec: { regex: /&#([0-9]{1,7});/g, val: (e, n) =>
|
|
1441
|
-
num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (e, n) =>
|
|
1442
|
-
}, this.addExternalEntities =
|
|
1443
|
+
num_dec: { regex: /&#([0-9]{1,7});/g, val: (e, n) => dn(n, 10, "&#") },
|
|
1444
|
+
num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (e, n) => dn(n, 16, "&#x") }
|
|
1445
|
+
}, this.addExternalEntities = ui, this.parseXml = yi, this.parseTextData = fi, this.resolveNameSpace = pi, this.buildAttributesMap = mi, this.isItStopNode = _i, this.replaceEntitiesValue = Ei, this.readStopNodeData = Ii, this.saveTextToParentTag = bi, this.addChild = wi, this.ignoreAttributesFn = xn(this.options.ignoreAttributes), this.options.stopNodes && this.options.stopNodes.length > 0) {
|
|
1443
1446
|
this.stopNodesExact = /* @__PURE__ */ new Set(), this.stopNodesWildcard = /* @__PURE__ */ new Set();
|
|
1444
1447
|
for (let e = 0; e < this.options.stopNodes.length; e++) {
|
|
1445
1448
|
const n = this.options.stopNodes[e];
|
|
@@ -1448,24 +1451,24 @@ class hi {
|
|
|
1448
1451
|
}
|
|
1449
1452
|
}
|
|
1450
1453
|
}
|
|
1451
|
-
function
|
|
1454
|
+
function ui(s) {
|
|
1452
1455
|
const t = Object.keys(s);
|
|
1453
1456
|
for (let e = 0; e < t.length; e++) {
|
|
1454
|
-
const n = t[e];
|
|
1457
|
+
const n = t[e], i = n.replace(/[.\-+*:]/g, "\\.");
|
|
1455
1458
|
this.lastEntities[n] = {
|
|
1456
|
-
regex: new RegExp("&" +
|
|
1459
|
+
regex: new RegExp("&" + i + ";", "g"),
|
|
1457
1460
|
val: s[n]
|
|
1458
1461
|
};
|
|
1459
1462
|
}
|
|
1460
1463
|
}
|
|
1461
|
-
function
|
|
1464
|
+
function fi(s, t, e, n, i, r, o) {
|
|
1462
1465
|
if (s !== void 0 && (this.options.trimValues && !n && (s = s.trim()), s.length > 0)) {
|
|
1463
1466
|
o || (s = this.replaceEntitiesValue(s));
|
|
1464
1467
|
const a = this.options.tagValueProcessor(t, s, e, i, r);
|
|
1465
1468
|
return a == null ? s : typeof a != typeof s || a !== s ? a : this.options.trimValues ? ve(s, this.options.parseTagValue, this.options.numberParseOptions) : s.trim() === s ? ve(s, this.options.parseTagValue, this.options.numberParseOptions) : s;
|
|
1466
1469
|
}
|
|
1467
1470
|
}
|
|
1468
|
-
function
|
|
1471
|
+
function pi(s) {
|
|
1469
1472
|
if (this.options.removeNSPrefix) {
|
|
1470
1473
|
const t = s.split(":"), e = s.charAt(0) === "/" ? "/" : "";
|
|
1471
1474
|
if (t[0] === "xmlns")
|
|
@@ -1474,10 +1477,10 @@ function fi(s) {
|
|
|
1474
1477
|
}
|
|
1475
1478
|
return s;
|
|
1476
1479
|
}
|
|
1477
|
-
const
|
|
1478
|
-
function
|
|
1480
|
+
const gi = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
|
|
1481
|
+
function mi(s, t) {
|
|
1479
1482
|
if (this.options.ignoreAttributes !== !0 && typeof s == "string") {
|
|
1480
|
-
const e =
|
|
1483
|
+
const e = Mn(s, gi), n = e.length, i = {};
|
|
1481
1484
|
for (let r = 0; r < n; r++) {
|
|
1482
1485
|
const o = this.resolveNameSpace(e[r][1]);
|
|
1483
1486
|
if (this.ignoreAttributesFn(o, t))
|
|
@@ -1503,12 +1506,12 @@ function gi(s, t) {
|
|
|
1503
1506
|
return i;
|
|
1504
1507
|
}
|
|
1505
1508
|
}
|
|
1506
|
-
const
|
|
1509
|
+
const yi = function(s) {
|
|
1507
1510
|
s = s.replace(/\r\n?/g, `
|
|
1508
1511
|
`);
|
|
1509
1512
|
const t = new ft("!xml");
|
|
1510
1513
|
let e = t, n = "", i = "";
|
|
1511
|
-
const r = new
|
|
1514
|
+
const r = new ni(this.options.processEntities);
|
|
1512
1515
|
for (let o = 0; o < s.length; o++)
|
|
1513
1516
|
if (s[o] === "<")
|
|
1514
1517
|
if (s[o + 1] === "/") {
|
|
@@ -1550,7 +1553,7 @@ const mi = function(s) {
|
|
|
1550
1553
|
} else {
|
|
1551
1554
|
let c = Te(s, o, this.options.removeNSPrefix), l = c.tagName;
|
|
1552
1555
|
const d = c.rawTagName;
|
|
1553
|
-
let h = c.tagExp, u = c.attrExpPresent,
|
|
1556
|
+
let h = c.tagExp, u = c.attrExpPresent, g = c.closeIndex;
|
|
1554
1557
|
if (this.options.transformTagName) {
|
|
1555
1558
|
const b = this.options.transformTagName(l);
|
|
1556
1559
|
h === l && (h = b), l = b;
|
|
@@ -1566,7 +1569,7 @@ const mi = function(s) {
|
|
|
1566
1569
|
else if (this.options.unpairedTags.indexOf(l) !== -1)
|
|
1567
1570
|
o = c.closeIndex;
|
|
1568
1571
|
else {
|
|
1569
|
-
const S = this.readStopNodeData(s, d,
|
|
1572
|
+
const S = this.readStopNodeData(s, d, g + 1);
|
|
1570
1573
|
if (!S) throw new Error(`Unexpected end of ${d}`);
|
|
1571
1574
|
o = S.i, b = S.tagContent;
|
|
1572
1575
|
}
|
|
@@ -1587,19 +1590,19 @@ const mi = function(s) {
|
|
|
1587
1590
|
const b = new ft(l);
|
|
1588
1591
|
this.tagsNodeStack.push(e), l !== h && u && (b[":@"] = this.buildAttributesMap(h, i)), this.addChild(e, b, i, w), e = b;
|
|
1589
1592
|
}
|
|
1590
|
-
n = "", o =
|
|
1593
|
+
n = "", o = g;
|
|
1591
1594
|
}
|
|
1592
1595
|
}
|
|
1593
1596
|
else
|
|
1594
1597
|
n += s[o];
|
|
1595
1598
|
return t.child;
|
|
1596
1599
|
};
|
|
1597
|
-
function
|
|
1600
|
+
function wi(s, t, e, n) {
|
|
1598
1601
|
this.options.captureMetaData || (n = void 0);
|
|
1599
1602
|
const i = this.options.updateTag(t.tagname, e, t[":@"]);
|
|
1600
1603
|
i === !1 || (typeof i == "string" && (t.tagname = i), s.addChild(t, n));
|
|
1601
1604
|
}
|
|
1602
|
-
const
|
|
1605
|
+
const Ei = function(s) {
|
|
1603
1606
|
if (this.options.processEntities) {
|
|
1604
1607
|
for (let t in this.docTypeEntities) {
|
|
1605
1608
|
const e = this.docTypeEntities[t];
|
|
@@ -1618,7 +1621,7 @@ const wi = function(s) {
|
|
|
1618
1621
|
}
|
|
1619
1622
|
return s;
|
|
1620
1623
|
};
|
|
1621
|
-
function
|
|
1624
|
+
function bi(s, t, e, n) {
|
|
1622
1625
|
return s && (n === void 0 && (n = t.child.length === 0), s = this.parseTextData(
|
|
1623
1626
|
s,
|
|
1624
1627
|
t.tagname,
|
|
@@ -1628,10 +1631,10 @@ function Ei(s, t, e, n) {
|
|
|
1628
1631
|
n
|
|
1629
1632
|
), s !== void 0 && s !== "" && t.add(this.options.textNodeName, s), s = ""), s;
|
|
1630
1633
|
}
|
|
1631
|
-
function
|
|
1634
|
+
function _i(s, t, e, n) {
|
|
1632
1635
|
return !!(t && t.has(n) || s && s.has(e));
|
|
1633
1636
|
}
|
|
1634
|
-
function
|
|
1637
|
+
function Ai(s, t, e = ">") {
|
|
1635
1638
|
let n, i = "";
|
|
1636
1639
|
for (let r = t; r < s.length; r++) {
|
|
1637
1640
|
let o = s[r];
|
|
@@ -1662,7 +1665,7 @@ function mt(s, t, e, n) {
|
|
|
1662
1665
|
return i + t.length - 1;
|
|
1663
1666
|
}
|
|
1664
1667
|
function Te(s, t, e, n = ">") {
|
|
1665
|
-
const i =
|
|
1668
|
+
const i = Ai(s, t + 1, n);
|
|
1666
1669
|
if (!i) return;
|
|
1667
1670
|
let r = i.data;
|
|
1668
1671
|
const o = i.index, a = r.search(/\s/);
|
|
@@ -1681,7 +1684,7 @@ function Te(s, t, e, n = ">") {
|
|
|
1681
1684
|
rawTagName: d
|
|
1682
1685
|
};
|
|
1683
1686
|
}
|
|
1684
|
-
function
|
|
1687
|
+
function Ii(s, t, e) {
|
|
1685
1688
|
const n = e;
|
|
1686
1689
|
let i = 1;
|
|
1687
1690
|
for (; e < s.length; e++)
|
|
@@ -1708,19 +1711,23 @@ function Ai(s, t, e) {
|
|
|
1708
1711
|
function ve(s, t, e) {
|
|
1709
1712
|
if (t && typeof s == "string") {
|
|
1710
1713
|
const n = s.trim();
|
|
1711
|
-
return n === "true" ? !0 : n === "false" ? !1 :
|
|
1714
|
+
return n === "true" ? !0 : n === "false" ? !1 : oi(s, e);
|
|
1712
1715
|
} else
|
|
1713
|
-
return
|
|
1716
|
+
return Us(s) ? s : "";
|
|
1717
|
+
}
|
|
1718
|
+
function dn(s, t, e) {
|
|
1719
|
+
const n = Number.parseInt(s, t);
|
|
1720
|
+
return n >= 0 && n <= 1114111 ? String.fromCodePoint(n) : e + s + ";";
|
|
1714
1721
|
}
|
|
1715
1722
|
const we = ft.getMetaDataSymbol();
|
|
1716
|
-
function
|
|
1717
|
-
return
|
|
1723
|
+
function Ni(s, t) {
|
|
1724
|
+
return $n(s, t);
|
|
1718
1725
|
}
|
|
1719
|
-
function
|
|
1726
|
+
function $n(s, t, e) {
|
|
1720
1727
|
let n;
|
|
1721
1728
|
const i = {};
|
|
1722
1729
|
for (let r = 0; r < s.length; r++) {
|
|
1723
|
-
const o = s[r], a =
|
|
1730
|
+
const o = s[r], a = Ti(o);
|
|
1724
1731
|
let c = "";
|
|
1725
1732
|
if (e === void 0 ? c = a : c = e + "." + a, a === t.textNodeName)
|
|
1726
1733
|
n === void 0 ? n = o[a] : n += "" + o[a];
|
|
@@ -1728,22 +1735,22 @@ function xn(s, t, e) {
|
|
|
1728
1735
|
if (a === void 0)
|
|
1729
1736
|
continue;
|
|
1730
1737
|
if (o[a]) {
|
|
1731
|
-
let l =
|
|
1732
|
-
const d =
|
|
1733
|
-
o[we] !== void 0 && (l[we] = o[we]), o[":@"] ?
|
|
1738
|
+
let l = $n(o[a], t, c);
|
|
1739
|
+
const d = Si(l, t);
|
|
1740
|
+
o[we] !== void 0 && (l[we] = o[we]), o[":@"] ? vi(l, o[":@"], c, t) : Object.keys(l).length === 1 && l[t.textNodeName] !== void 0 && !t.alwaysCreateTextNode ? l = l[t.textNodeName] : Object.keys(l).length === 0 && (t.alwaysCreateTextNode ? l[t.textNodeName] = "" : l = ""), i[a] !== void 0 && i.hasOwnProperty(a) ? (Array.isArray(i[a]) || (i[a] = [i[a]]), i[a].push(l)) : t.isArray(a, c, d) ? i[a] = [l] : i[a] = l;
|
|
1734
1741
|
}
|
|
1735
1742
|
}
|
|
1736
1743
|
}
|
|
1737
1744
|
return typeof n == "string" ? n.length > 0 && (i[t.textNodeName] = n) : n !== void 0 && (i[t.textNodeName] = n), i;
|
|
1738
1745
|
}
|
|
1739
|
-
function
|
|
1746
|
+
function Ti(s) {
|
|
1740
1747
|
const t = Object.keys(s);
|
|
1741
1748
|
for (let e = 0; e < t.length; e++) {
|
|
1742
1749
|
const n = t[e];
|
|
1743
1750
|
if (n !== ":@") return n;
|
|
1744
1751
|
}
|
|
1745
1752
|
}
|
|
1746
|
-
function
|
|
1753
|
+
function vi(s, t, e, n) {
|
|
1747
1754
|
if (t) {
|
|
1748
1755
|
const i = Object.keys(t), r = i.length;
|
|
1749
1756
|
for (let o = 0; o < r; o++) {
|
|
@@ -1752,13 +1759,13 @@ function Ti(s, t, e, n) {
|
|
|
1752
1759
|
}
|
|
1753
1760
|
}
|
|
1754
1761
|
}
|
|
1755
|
-
function
|
|
1762
|
+
function Si(s, t) {
|
|
1756
1763
|
const { textNodeName: e } = t, n = Object.keys(s).length;
|
|
1757
1764
|
return !!(n === 0 || n === 1 && (s[e] || typeof s[e] == "boolean" || s[e] === 0));
|
|
1758
1765
|
}
|
|
1759
|
-
class
|
|
1766
|
+
class Oi {
|
|
1760
1767
|
constructor(t) {
|
|
1761
|
-
this.externalEntities = {}, this.options =
|
|
1768
|
+
this.externalEntities = {}, this.options = ei(t);
|
|
1762
1769
|
}
|
|
1763
1770
|
/**
|
|
1764
1771
|
* Parse XML dats to JS object
|
|
@@ -1772,14 +1779,14 @@ class Si {
|
|
|
1772
1779
|
throw new Error("XML data is accepted in String or Bytes[] form.");
|
|
1773
1780
|
if (e) {
|
|
1774
1781
|
e === !0 && (e = {});
|
|
1775
|
-
const r =
|
|
1782
|
+
const r = Fs(t, e);
|
|
1776
1783
|
if (r !== !0)
|
|
1777
1784
|
throw Error(`${r.err.msg}:${r.err.line}:${r.err.col}`);
|
|
1778
1785
|
}
|
|
1779
|
-
const n = new
|
|
1786
|
+
const n = new di(this.options);
|
|
1780
1787
|
n.addExternalEntities(this.externalEntities);
|
|
1781
1788
|
const i = n.parseXml(t);
|
|
1782
|
-
return this.options.preserveOrder || i === void 0 ? i :
|
|
1789
|
+
return this.options.preserveOrder || i === void 0 ? i : Ni(i, this.options);
|
|
1783
1790
|
}
|
|
1784
1791
|
/**
|
|
1785
1792
|
* Add Entity which is not by default supported by this library
|
|
@@ -1809,21 +1816,21 @@ class Si {
|
|
|
1809
1816
|
return ft.getMetaDataSymbol();
|
|
1810
1817
|
}
|
|
1811
1818
|
}
|
|
1812
|
-
const
|
|
1819
|
+
const ki = `
|
|
1813
1820
|
`;
|
|
1814
|
-
function
|
|
1821
|
+
function Ci(s, t) {
|
|
1815
1822
|
let e = "";
|
|
1816
|
-
return t.format && t.indentBy.length > 0 && (e =
|
|
1823
|
+
return t.format && t.indentBy.length > 0 && (e = ki), Pn(s, t, "", e);
|
|
1817
1824
|
}
|
|
1818
|
-
function
|
|
1825
|
+
function Pn(s, t, e, n) {
|
|
1819
1826
|
let i = "", r = !1;
|
|
1820
1827
|
for (let o = 0; o < s.length; o++) {
|
|
1821
|
-
const a = s[o], c =
|
|
1828
|
+
const a = s[o], c = Ri(a);
|
|
1822
1829
|
if (c === void 0) continue;
|
|
1823
1830
|
let l = "";
|
|
1824
1831
|
if (e.length === 0 ? l = c : l = `${e}.${c}`, c === t.textNodeName) {
|
|
1825
1832
|
let f = a[c];
|
|
1826
|
-
|
|
1833
|
+
Mi(l, t) || (f = t.tagValueProcessor(c, f), f = Hn(f, t)), r && (i += n), i += f, r = !1;
|
|
1827
1834
|
continue;
|
|
1828
1835
|
} else if (c === t.cdataPropName) {
|
|
1829
1836
|
r && (i += n), i += `<![CDATA[${a[c][0][t.textNodeName]}]]>`, r = !1;
|
|
@@ -1832,19 +1839,19 @@ function $n(s, t, e, n) {
|
|
|
1832
1839
|
i += n + `<!--${a[c][0][t.textNodeName]}-->`, r = !0;
|
|
1833
1840
|
continue;
|
|
1834
1841
|
} else if (c[0] === "?") {
|
|
1835
|
-
const f =
|
|
1842
|
+
const f = un(a[":@"], t), w = c === "?xml" ? "" : n;
|
|
1836
1843
|
let b = a[c][0][t.textNodeName];
|
|
1837
1844
|
b = b.length !== 0 ? " " + b : "", i += w + `<${c}${b}${f}?>`, r = !0;
|
|
1838
1845
|
continue;
|
|
1839
1846
|
}
|
|
1840
1847
|
let d = n;
|
|
1841
1848
|
d !== "" && (d += t.indentBy);
|
|
1842
|
-
const h =
|
|
1843
|
-
t.unpairedTags.indexOf(c) !== -1 ? t.suppressUnpairedNode ? i += u + ">" : i += u + "/>" : (!
|
|
1849
|
+
const h = un(a[":@"], t), u = n + `<${c}${h}`, g = Pn(a[c], t, l, d);
|
|
1850
|
+
t.unpairedTags.indexOf(c) !== -1 ? t.suppressUnpairedNode ? i += u + ">" : i += u + "/>" : (!g || g.length === 0) && t.suppressEmptyNode ? i += u + "/>" : g && g.endsWith(">") ? i += u + `>${g}${n}</${c}>` : (i += u + ">", g && n !== "" && (g.includes("/>") || g.includes("</")) ? i += n + t.indentBy + g + n : i += g, i += `</${c}>`), r = !0;
|
|
1844
1851
|
}
|
|
1845
1852
|
return i;
|
|
1846
1853
|
}
|
|
1847
|
-
function
|
|
1854
|
+
function Ri(s) {
|
|
1848
1855
|
const t = Object.keys(s);
|
|
1849
1856
|
for (let e = 0; e < t.length; e++) {
|
|
1850
1857
|
const n = t[e];
|
|
@@ -1852,7 +1859,7 @@ function Ci(s) {
|
|
|
1852
1859
|
return n;
|
|
1853
1860
|
}
|
|
1854
1861
|
}
|
|
1855
|
-
function
|
|
1862
|
+
function un(s, t) {
|
|
1856
1863
|
let e = "";
|
|
1857
1864
|
if (s && !t.ignoreAttributes)
|
|
1858
1865
|
for (let n in s) {
|
|
@@ -1862,7 +1869,7 @@ function dn(s, t) {
|
|
|
1862
1869
|
}
|
|
1863
1870
|
return e;
|
|
1864
1871
|
}
|
|
1865
|
-
function
|
|
1872
|
+
function Mi(s, t) {
|
|
1866
1873
|
s = s.substr(0, s.length - t.textNodeName.length - 1);
|
|
1867
1874
|
let e = s.substr(s.lastIndexOf(".") + 1);
|
|
1868
1875
|
for (let n in t.stopNodes)
|
|
@@ -1877,7 +1884,7 @@ function Hn(s, t) {
|
|
|
1877
1884
|
}
|
|
1878
1885
|
return s;
|
|
1879
1886
|
}
|
|
1880
|
-
const
|
|
1887
|
+
const xi = {
|
|
1881
1888
|
attributeNamePrefix: "@_",
|
|
1882
1889
|
attributesGroupName: !1,
|
|
1883
1890
|
textNodeName: "#text",
|
|
@@ -1912,16 +1919,16 @@ const Mi = {
|
|
|
1912
1919
|
oneListGroup: !1
|
|
1913
1920
|
};
|
|
1914
1921
|
function ot(s) {
|
|
1915
|
-
this.options = Object.assign({},
|
|
1922
|
+
this.options = Object.assign({}, xi, s), this.options.ignoreAttributes === !0 || this.options.attributesGroupName ? this.isAttribute = function() {
|
|
1916
1923
|
return !1;
|
|
1917
|
-
} : (this.ignoreAttributesFn =
|
|
1924
|
+
} : (this.ignoreAttributesFn = xn(this.options.ignoreAttributes), this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Hi), this.processTextOrObjNode = $i, this.options.format ? (this.indentate = Pi, this.tagEndChar = `>
|
|
1918
1925
|
`, this.newLine = `
|
|
1919
1926
|
`) : (this.indentate = function() {
|
|
1920
1927
|
return "";
|
|
1921
1928
|
}, this.tagEndChar = ">", this.newLine = "");
|
|
1922
1929
|
}
|
|
1923
1930
|
ot.prototype.build = function(s) {
|
|
1924
|
-
return this.options.preserveOrder ?
|
|
1931
|
+
return this.options.preserveOrder ? Ci(s, this.options) : (Array.isArray(s) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (s = {
|
|
1925
1932
|
[this.options.arrayNodeName]: s
|
|
1926
1933
|
}), this.j2x(s, 0, []).val);
|
|
1927
1934
|
};
|
|
@@ -1977,7 +1984,7 @@ ot.prototype.j2x = function(s, t, e) {
|
|
|
1977
1984
|
ot.prototype.buildAttrPairStr = function(s, t) {
|
|
1978
1985
|
return t = this.options.attributeValueProcessor(s, "" + t), t = this.replaceEntitiesValue(t), this.options.suppressBooleanAttributes && t === "true" ? " " + s : " " + s + '="' + t + '"';
|
|
1979
1986
|
};
|
|
1980
|
-
function
|
|
1987
|
+
function $i(s, t, e, n) {
|
|
1981
1988
|
const i = this.j2x(s, e + 1, n.concat(t));
|
|
1982
1989
|
return s[this.options.textNodeName] !== void 0 && Object.keys(s).length === 1 ? this.buildTextValNode(s[this.options.textNodeName], t, i.attrStr, e) : this.buildObjectNode(i.val, t, i.attrStr, e);
|
|
1983
1990
|
}
|
|
@@ -2013,7 +2020,7 @@ ot.prototype.replaceEntitiesValue = function(s) {
|
|
|
2013
2020
|
}
|
|
2014
2021
|
return s;
|
|
2015
2022
|
};
|
|
2016
|
-
function
|
|
2023
|
+
function Pi(s) {
|
|
2017
2024
|
return this.options.indentBy.repeat(s);
|
|
2018
2025
|
}
|
|
2019
2026
|
function Hi(s) {
|
|
@@ -2048,8 +2055,8 @@ class _t {
|
|
|
2048
2055
|
left(...t) {
|
|
2049
2056
|
return `<${[
|
|
2050
2057
|
this.type,
|
|
2051
|
-
|
|
2052
|
-
|
|
2058
|
+
Ln(this.attrs),
|
|
2059
|
+
Ui(this.styles),
|
|
2053
2060
|
...t
|
|
2054
2061
|
].filter((e) => e != "").join(" ")}>`;
|
|
2055
2062
|
}
|
|
@@ -2076,7 +2083,7 @@ class _t {
|
|
|
2076
2083
|
return this.toString();
|
|
2077
2084
|
}
|
|
2078
2085
|
}
|
|
2079
|
-
class
|
|
2086
|
+
class Bn extends _t {
|
|
2080
2087
|
attrs = {};
|
|
2081
2088
|
constructor(t) {
|
|
2082
2089
|
super("image"), this.attrs = { ...this.attrs, href: t };
|
|
@@ -2097,7 +2104,7 @@ class Ue extends _t {
|
|
|
2097
2104
|
return t == null ? t : `#${t}`;
|
|
2098
2105
|
}
|
|
2099
2106
|
}
|
|
2100
|
-
class
|
|
2107
|
+
class Wn extends _t {
|
|
2101
2108
|
attrs = {};
|
|
2102
2109
|
constructor() {
|
|
2103
2110
|
super("rect");
|
|
@@ -2125,7 +2132,7 @@ class St extends _t {
|
|
|
2125
2132
|
return this._text;
|
|
2126
2133
|
}
|
|
2127
2134
|
}
|
|
2128
|
-
let
|
|
2135
|
+
let Dn = class extends _t {
|
|
2129
2136
|
raw;
|
|
2130
2137
|
constructor(t) {
|
|
2131
2138
|
super("symbol"), this.raw = t;
|
|
@@ -2148,7 +2155,7 @@ class N extends _t {
|
|
|
2148
2155
|
return this.children.push(t), this;
|
|
2149
2156
|
}
|
|
2150
2157
|
rotate(t, e, n) {
|
|
2151
|
-
return this.rotateMatrix =
|
|
2158
|
+
return this.rotateMatrix = Bs(t, e, n), this;
|
|
2152
2159
|
}
|
|
2153
2160
|
translate(t, e) {
|
|
2154
2161
|
return this.translateMatrix = Ne(t, e), this;
|
|
@@ -2160,7 +2167,7 @@ class N extends _t {
|
|
|
2160
2167
|
const e = [this.translateMatrix, this.rotateMatrix].filter(
|
|
2161
2168
|
(n) => n != null
|
|
2162
2169
|
);
|
|
2163
|
-
return e.length == 0 ? super.left() : super.left(
|
|
2170
|
+
return e.length == 0 ? super.left() : super.left(zi(Ms(e)));
|
|
2164
2171
|
}
|
|
2165
2172
|
each(t, e) {
|
|
2166
2173
|
for (let n = 0; n < this.children.length; n++) {
|
|
@@ -2169,12 +2176,12 @@ class N extends _t {
|
|
|
2169
2176
|
}
|
|
2170
2177
|
}
|
|
2171
2178
|
}
|
|
2172
|
-
const
|
|
2179
|
+
const Bi = [
|
|
2173
2180
|
'xmlns="http://www.w3.org/2000/svg"',
|
|
2174
2181
|
'version="1.1"',
|
|
2175
2182
|
'xmlns:xlink="http://www.w3.org/1999/xlink"'
|
|
2176
2183
|
];
|
|
2177
|
-
class
|
|
2184
|
+
class Wi extends _t {
|
|
2178
2185
|
children = [];
|
|
2179
2186
|
constructor() {
|
|
2180
2187
|
super("svg");
|
|
@@ -2189,16 +2196,16 @@ class Bi extends _t {
|
|
|
2189
2196
|
left(...t) {
|
|
2190
2197
|
return `<${[
|
|
2191
2198
|
this.type,
|
|
2192
|
-
...
|
|
2193
|
-
|
|
2194
|
-
|
|
2199
|
+
...Bi,
|
|
2200
|
+
Ln(this.attrs),
|
|
2201
|
+
Ki(this.viewBox)
|
|
2195
2202
|
].filter((e) => e != "").join(" ")}>`;
|
|
2196
2203
|
}
|
|
2197
2204
|
viewbox(t, e, n, i) {
|
|
2198
2205
|
return this.viewBox = { x: t, y: e, width: n, height: i }, this;
|
|
2199
2206
|
}
|
|
2200
2207
|
importSymbol(t) {
|
|
2201
|
-
for (const e of
|
|
2208
|
+
for (const e of ji(t))
|
|
2202
2209
|
this.add(e);
|
|
2203
2210
|
return this;
|
|
2204
2211
|
}
|
|
@@ -2221,32 +2228,32 @@ class Bi extends _t {
|
|
|
2221
2228
|
}
|
|
2222
2229
|
}
|
|
2223
2230
|
}
|
|
2224
|
-
function
|
|
2225
|
-
return new
|
|
2231
|
+
function Di() {
|
|
2232
|
+
return new Wi();
|
|
2226
2233
|
}
|
|
2227
|
-
const
|
|
2228
|
-
function
|
|
2234
|
+
const Vo = Di, Jo = N, Xo = Bn, qo = Ue, Qo = Wn, ta = St;
|
|
2235
|
+
function Li(s) {
|
|
2229
2236
|
return s.replace(/[A-Z]/g, (t) => "-" + t.toLowerCase());
|
|
2230
2237
|
}
|
|
2231
|
-
function
|
|
2238
|
+
function Ki(s) {
|
|
2232
2239
|
return s == null ? "" : `viewBox="${s.x} ${s.y} ${s.width} ${s.height}"`;
|
|
2233
2240
|
}
|
|
2234
|
-
function
|
|
2235
|
-
return s == null ? "" : `transform="${
|
|
2241
|
+
function zi(s) {
|
|
2242
|
+
return s == null ? "" : `transform="${Ws(s)}"`;
|
|
2236
2243
|
}
|
|
2237
|
-
function
|
|
2238
|
-
return Object.entries(s).filter(([t, e]) => e !== void 0).map(([t, e]) => `${
|
|
2244
|
+
function Ln(s) {
|
|
2245
|
+
return Object.entries(s).filter(([t, e]) => e !== void 0).map(([t, e]) => `${Li(t)}="${e}"`).join(" ");
|
|
2239
2246
|
}
|
|
2240
|
-
function
|
|
2247
|
+
function Ui(s) {
|
|
2241
2248
|
const t = Object.entries(s).map(([e, n]) => `${e}: ${n};`).join(" ");
|
|
2242
2249
|
return t != "" ? `style="${t}"` : "";
|
|
2243
2250
|
}
|
|
2244
|
-
function*
|
|
2245
|
-
const t = new
|
|
2251
|
+
function* ji(s) {
|
|
2252
|
+
const t = new Oi({ ignoreAttributes: !1 }), e = new ot({
|
|
2246
2253
|
ignoreAttributes: !1
|
|
2247
2254
|
}), n = t.parse(s);
|
|
2248
2255
|
for (const i of n.svg.symbol) {
|
|
2249
|
-
const r = e.build(i), o = new
|
|
2256
|
+
const r = e.build(i), o = new Dn(r);
|
|
2250
2257
|
for (const [a, c] of Object.entries(i))
|
|
2251
2258
|
a.startsWith("@_") && (o.attrs[a.substring(2)] = c);
|
|
2252
2259
|
yield o;
|
|
@@ -2262,8 +2269,8 @@ const Ee = (s, t) => {
|
|
|
2262
2269
|
}, 0);
|
|
2263
2270
|
return { width: s.tiles.reduce((a, c) => a + J(c, t).width, 0), height: r };
|
|
2264
2271
|
}, J = (s, t) => {
|
|
2265
|
-
const e = parseFloat((wt.HEIGHT * t).toPrecision(5)), n = parseFloat((wt.WIDTH * t).toPrecision(5)), i = s.has(
|
|
2266
|
-
return (s.has(
|
|
2272
|
+
const e = parseFloat((wt.HEIGHT * t).toPrecision(5)), n = parseFloat((wt.WIDTH * t).toPrecision(5)), i = s.has(m.HORIZONTAL) ? { width: e, height: n, baseWidth: n, baseHeight: e } : { width: n, height: e, w: n, baseWidth: n, baseHeight: e };
|
|
2273
|
+
return (s.has(m.TSUMO) || s.has(m.IMAGE_DORA)) && (i.width += n * wt.TEXT_SCALE), i;
|
|
2267
2274
|
};
|
|
2268
2275
|
class kt {
|
|
2269
2276
|
tileWidth;
|
|
@@ -2282,8 +2289,8 @@ class kt {
|
|
|
2282
2289
|
}
|
|
2283
2290
|
// image wrapper
|
|
2284
2291
|
image(t) {
|
|
2285
|
-
let e = this.svgSprite ? new Ue().use(kt.buildID(t)) : new
|
|
2286
|
-
return t instanceof y && t.has(
|
|
2292
|
+
let e = this.svgSprite ? new Ue().use(kt.buildID(t)) : new Bn().load(this.buildURL(t));
|
|
2293
|
+
return t instanceof y && t.has(m.COLOR_GRAYSCALE) && e.css({ filter: "contrast(65%)" }), e;
|
|
2287
2294
|
}
|
|
2288
2295
|
createImage(t, e, n) {
|
|
2289
2296
|
const i = J(t, this.scale);
|
|
@@ -2292,7 +2299,7 @@ class kt {
|
|
|
2292
2299
|
createTextImage(t, e, n, i) {
|
|
2293
2300
|
const r = this.createImage(t, e, n), o = J(t, this.scale), a = o.baseHeight * 0.2, c = o.baseWidth, l = o.baseHeight, d = new St().plain(i);
|
|
2294
2301
|
d.size(o.baseWidth, o.baseHeight).font({
|
|
2295
|
-
family:
|
|
2302
|
+
family: Sn,
|
|
2296
2303
|
size: a
|
|
2297
2304
|
}).dx(c).dy(l);
|
|
2298
2305
|
const h = new N();
|
|
@@ -2308,7 +2315,7 @@ class kt {
|
|
|
2308
2315
|
static buildID(t) {
|
|
2309
2316
|
if (t === 100) return "stick100";
|
|
2310
2317
|
if (t === 1e3) return "stick1000";
|
|
2311
|
-
const e = t.t == p.BACK || t.has(
|
|
2318
|
+
const e = t.t == p.BACK || t.has(m.RED) ? 0 : t.n;
|
|
2312
2319
|
return `${t.t}${e}`;
|
|
2313
2320
|
}
|
|
2314
2321
|
buildURL(t) {
|
|
@@ -2316,7 +2323,7 @@ class kt {
|
|
|
2316
2323
|
return this.imageHostUrl != "" ? `${this.imageHostUrl}${e}` : e;
|
|
2317
2324
|
}
|
|
2318
2325
|
}
|
|
2319
|
-
class
|
|
2326
|
+
class Kn extends kt {
|
|
2320
2327
|
blockMargin = wt.WIDTH * wt.BLOCK_MARGIN_SCALE * this.scale;
|
|
2321
2328
|
/**
|
|
2322
2329
|
* 捨て牌のブロックから SVG 要素を作る。
|
|
@@ -2350,15 +2357,15 @@ class Ln extends kt {
|
|
|
2350
2357
|
const e = this.findHorizontalIndex(t);
|
|
2351
2358
|
let n = 0;
|
|
2352
2359
|
const i = new N(), r = t.tiles.reduce(
|
|
2353
|
-
(o, a, c) => a.has(
|
|
2360
|
+
(o, a, c) => a.has(m.HORIZONTAL) ? c : o,
|
|
2354
2361
|
e
|
|
2355
2362
|
);
|
|
2356
2363
|
for (let o = 0; o < t.tiles.length; o++) {
|
|
2357
2364
|
const a = J(t.tiles[o], this.scale);
|
|
2358
2365
|
if (o == r) continue;
|
|
2359
2366
|
if (o == e) {
|
|
2360
|
-
const d = t.tiles[e], h = t.tiles[r], u = J(d, this.scale),
|
|
2361
|
-
i.add(new N().translate(n, 0).add(
|
|
2367
|
+
const d = t.tiles[e], h = t.tiles[r], u = J(d, this.scale), g = this.createRotate90Image(d, 0, 0, !0), f = this.createRotate90Image(h, 0, u.height, !0);
|
|
2368
|
+
i.add(new N().translate(n, 0).add(g).add(f)), n += u.width;
|
|
2362
2369
|
continue;
|
|
2363
2370
|
}
|
|
2364
2371
|
const c = a.width * 2 - a.height, l = this.createImage(t.tiles[o], n, c);
|
|
@@ -2406,7 +2413,7 @@ class Ln extends kt {
|
|
|
2406
2413
|
for (const i of t) {
|
|
2407
2414
|
const r = J(i, this.scale);
|
|
2408
2415
|
let o;
|
|
2409
|
-
if (i.has(
|
|
2416
|
+
if (i.has(m.HORIZONTAL)) {
|
|
2410
2417
|
const a = this.getHorizontalTileYOffset(i);
|
|
2411
2418
|
o = this.createRotate90Image(i, e, a);
|
|
2412
2419
|
} else o = this.createImage(i, e, 0);
|
|
@@ -2415,19 +2422,19 @@ class Ln extends kt {
|
|
|
2415
2422
|
return n;
|
|
2416
2423
|
}
|
|
2417
2424
|
findHorizontalIndex(t) {
|
|
2418
|
-
const e = t.tiles.findIndex((n) => n.has(
|
|
2425
|
+
const e = t.tiles.findIndex((n) => n.has(m.HORIZONTAL));
|
|
2419
2426
|
if (e < 0)
|
|
2420
2427
|
throw new Error(`unable to find horizontal operator in block: ${t}`);
|
|
2421
2428
|
return e;
|
|
2422
2429
|
}
|
|
2423
2430
|
}
|
|
2424
|
-
function
|
|
2431
|
+
function Fi(s, t, e) {
|
|
2425
2432
|
const { enableDoraText: n, enableTsumoText: i } = e;
|
|
2426
2433
|
let r = Ee(s, t.scale), o;
|
|
2427
2434
|
if (s instanceof U) o = t.createBlockPon(s);
|
|
2428
2435
|
else if (s instanceof V) o = t.createBlockChi(s);
|
|
2429
2436
|
else if (s instanceof R) o = t.createBlockAnKan(s);
|
|
2430
|
-
else if (s instanceof
|
|
2437
|
+
else if (s instanceof P) o = t.createBlockShoKan(s);
|
|
2431
2438
|
else if (s instanceof z) o = t.createBlockDaiKan(s);
|
|
2432
2439
|
else if (s instanceof Tt) o = t.createBlockHand(s);
|
|
2433
2440
|
else if (s instanceof Le)
|
|
@@ -2436,17 +2443,17 @@ function ji(s, t, e) {
|
|
|
2436
2443
|
o = t.createBlockDiscard(s);
|
|
2437
2444
|
break;
|
|
2438
2445
|
case E.IMAGE_DORA: {
|
|
2439
|
-
const a = n == !1 ? new Tt([s.tiles[0].clone({ remove:
|
|
2446
|
+
const a = n == !1 ? new Tt([s.tiles[0].clone({ remove: m.IMAGE_DORA })]) : s;
|
|
2440
2447
|
r = Ee(a, t.scale), o = t.createBlockDora(a, n);
|
|
2441
2448
|
break;
|
|
2442
2449
|
}
|
|
2443
2450
|
case E.TSUMO: {
|
|
2444
|
-
const a = i == !1 ? new Tt([s.tiles[0].clone({ remove:
|
|
2451
|
+
const a = i == !1 ? new Tt([s.tiles[0].clone({ remove: m.TSUMO })]) : s;
|
|
2445
2452
|
r = Ee(a, t.scale), o = t.createBlockTsumo(a, i);
|
|
2446
2453
|
break;
|
|
2447
2454
|
}
|
|
2448
2455
|
default:
|
|
2449
|
-
if (s.tiles.some((a) => a.has(
|
|
2456
|
+
if (s.tiles.some((a) => a.has(m.TSUMO) || a.has(m.IMAGE_DORA)))
|
|
2450
2457
|
throw new Error(
|
|
2451
2458
|
`found an unknown block with operator tiles. block: ${s}, type: ${s.type}`
|
|
2452
2459
|
);
|
|
@@ -2458,25 +2465,25 @@ function ji(s, t, e) {
|
|
|
2458
2465
|
);
|
|
2459
2466
|
return { ...r, e: o };
|
|
2460
2467
|
}
|
|
2461
|
-
const Kt = (s, t, e =
|
|
2462
|
-
const n = t.map((d) =>
|
|
2468
|
+
const Kt = (s, t, e = zn) => {
|
|
2469
|
+
const n = t.map((d) => Fi(d, s, e)), i = n.reduce((d, h) => d + h.width, 0), o = n.reduce((d, h) => Math.max(d, h.height), 0), a = i + (t.length - 1) * s.blockMargin, c = new N();
|
|
2463
2470
|
let l = 0;
|
|
2464
2471
|
for (const d of n) {
|
|
2465
2472
|
const h = o - d.height, u = new N().translate(l, h);
|
|
2466
2473
|
u.add(d.e), c.add(u), l += d.width + s.blockMargin;
|
|
2467
2474
|
}
|
|
2468
2475
|
return { e: c, width: a, height: o };
|
|
2469
|
-
},
|
|
2476
|
+
}, zn = {
|
|
2470
2477
|
enableDoraText: !0,
|
|
2471
2478
|
enableTsumoText: !0
|
|
2472
|
-
},
|
|
2473
|
-
const i = new
|
|
2479
|
+
}, ea = (s, t, e = {}, n = zn) => {
|
|
2480
|
+
const i = new Kn(e), r = Kt(i, t, n);
|
|
2474
2481
|
n.responsive || s.size(r.width, r.height), s.viewbox(0, 0, r.width, r.height), s.add(r.e);
|
|
2475
|
-
},
|
|
2482
|
+
}, Un = () => {
|
|
2476
2483
|
const s = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
|
2477
2484
|
return Object.values(p).flatMap((t) => t === p.BACK ? [kt.buildID(new y(t, 0))] : s.map((e) => kt.buildID(new y(t, e))));
|
|
2478
|
-
},
|
|
2479
|
-
const t =
|
|
2485
|
+
}, Gi = (s) => {
|
|
2486
|
+
const t = Un(), e = [];
|
|
2480
2487
|
return s.each((n, i) => {
|
|
2481
2488
|
const r = i[n];
|
|
2482
2489
|
if (r instanceof Ue) {
|
|
@@ -2484,13 +2491,13 @@ const Kt = (s, t, e = Kn) => {
|
|
|
2484
2491
|
t.includes(a) && e.push(a);
|
|
2485
2492
|
}
|
|
2486
2493
|
}, !0), e;
|
|
2487
|
-
},
|
|
2488
|
-
const t =
|
|
2494
|
+
}, na = (s) => {
|
|
2495
|
+
const t = Un(), e = Gi(s);
|
|
2489
2496
|
s.each((n, i) => {
|
|
2490
2497
|
const r = i[n];
|
|
2491
|
-
r instanceof
|
|
2498
|
+
r instanceof Dn && (t.includes(r.id()) && e.includes(r.id()) || r.remove());
|
|
2492
2499
|
}, !0);
|
|
2493
|
-
},
|
|
2500
|
+
}, Zi = (s, t = 6) => Array.from(
|
|
2494
2501
|
{ length: Math.ceil(s.length / t) },
|
|
2495
2502
|
(e, n) => s.slice(n * t, (n + 1) * t)
|
|
2496
2503
|
), j = (s, t, e, n, i = 0, r = 0) => {
|
|
@@ -2509,7 +2516,7 @@ const Kt = (s, t, e = Kn) => {
|
|
|
2509
2516
|
}
|
|
2510
2517
|
return new N().add(o);
|
|
2511
2518
|
}, Zt = (s, t) => {
|
|
2512
|
-
const e = new N(), n =
|
|
2519
|
+
const e = new N(), n = Zi(s);
|
|
2513
2520
|
for (let i = 0; i < n.length; i++) {
|
|
2514
2521
|
const r = n[i], o = i * t.tileHeight, a = t.createBlockDiscard(new Le(r, E.IMAGE_DISCARD)).translate(0, o);
|
|
2515
2522
|
e.add(a);
|
|
@@ -2519,18 +2526,18 @@ const Kt = (s, t, e = Kn) => {
|
|
|
2519
2526
|
width: t.tileWidth * 5 + t.tileHeight * 1,
|
|
2520
2527
|
height: t.tileHeight * n.length
|
|
2521
2528
|
};
|
|
2522
|
-
},
|
|
2523
|
-
const n = t.font, i = t.textWidth, r = t.textHeight, o = e.sticks.dead, a = e.sticks.reach, c = en.WIDTH * s.scale, l = en.HEIGHT * s.scale, d = i * 3, h = r + 25 * s.scale, u = (c + s.tileWidth + i - d) / 2,
|
|
2529
|
+
}, Yi = (s, t, e) => {
|
|
2530
|
+
const n = t.font, i = t.textWidth, r = t.textHeight, o = e.sticks.dead, a = e.sticks.reach, c = en.WIDTH * s.scale, l = en.HEIGHT * s.scale, d = i * 3, h = r + 25 * s.scale, u = (c + s.tileWidth + i - d) / 2, g = new St().plain(e.round).font(n).x(u).y(0), f = s.tileHeight, w = new N().size(c, f).translate(0, h), b = { family: n.family, size: n.size * 0.7 }, A = s.createStick(1e3).size(c, l).x(0).y(0), S = new St().plain(a.toString()).font(b).dx(c).dy(l), x = s.createStick(100).size(c, l).x(0).y(l + l), at = new St().plain(o.toString()).font(b).dx(c).dy(l * 3);
|
|
2524
2531
|
w.add(A), w.add(S), w.add(x), w.add(at);
|
|
2525
|
-
const Q = s.createImage(e.
|
|
2532
|
+
const Q = s.createImage(e.doraIndicators[0], 0, 0).x(c + i).y(0);
|
|
2526
2533
|
w.add(Q);
|
|
2527
2534
|
const tt = new N();
|
|
2528
|
-
return tt.add(
|
|
2535
|
+
return tt.add(g), tt.add(w), {
|
|
2529
2536
|
e: tt,
|
|
2530
2537
|
width: c + s.tileWidth + i,
|
|
2531
2538
|
height: h + s.tileHeight
|
|
2532
2539
|
};
|
|
2533
|
-
},
|
|
2540
|
+
}, Vi = (s, t, e = 0) => {
|
|
2534
2541
|
const n = Kt(s, t.front), i = Kt(s, t.right), r = Kt(s, t.opposite), o = Kt(s, t.left), a = [n.width, i.width, r.width, o.width].reduce(
|
|
2535
2542
|
(w, b) => Math.max(w, b)
|
|
2536
2543
|
), c = Math.max(
|
|
@@ -2545,28 +2552,28 @@ const Kt = (s, t, e = Kn) => {
|
|
|
2545
2552
|
), u = j(r.e, r.width, r.height, 180).translate(
|
|
2546
2553
|
(c - r.width) / 2,
|
|
2547
2554
|
0
|
|
2548
|
-
),
|
|
2555
|
+
), g = j(o.e, o.width, o.height, 90).translate(
|
|
2549
2556
|
0,
|
|
2550
2557
|
(c - o.width) / 2
|
|
2551
2558
|
), f = new N().size(c, l);
|
|
2552
|
-
return f.add(d), f.add(h), f.add(u), f.add(
|
|
2553
|
-
},
|
|
2559
|
+
return f.add(d), f.add(h), f.add(u), f.add(g), { e: new N().add(f), width: c, height: l };
|
|
2560
|
+
}, Ji = (s) => {
|
|
2554
2561
|
const t = Object.values(We), e = t.indexOf(s);
|
|
2555
2562
|
return [...t.slice(e), ...t.slice(0, e)];
|
|
2556
|
-
},
|
|
2557
|
-
const n = s.tileWidth * 5 + s.tileHeight * 1, i = t.font, r = t.textWidth, o = t.textHeight, a = t.numWidth, c =
|
|
2563
|
+
}, Xi = (s, t, e) => {
|
|
2564
|
+
const n = s.tileWidth * 5 + s.tileHeight * 1, i = t.font, r = t.textWidth, o = t.textHeight, a = t.numWidth, c = Yi(s, t, e);
|
|
2558
2565
|
c.e.translate(
|
|
2559
2566
|
n / 2 - c.width / 2,
|
|
2560
2567
|
n / 2 - c.height / 2
|
|
2561
2568
|
);
|
|
2562
|
-
const l = (
|
|
2563
|
-
const
|
|
2569
|
+
const l = (Es, tn, bs) => {
|
|
2570
|
+
const _s = `${Es} ${tn}`, As = new St().plain(_s).font(i).attr(bs);
|
|
2564
2571
|
return {
|
|
2565
|
-
e: new N().add(
|
|
2572
|
+
e: new N().add(As),
|
|
2566
2573
|
width: r + a * tn.toString().length,
|
|
2567
2574
|
height: o
|
|
2568
2575
|
};
|
|
2569
|
-
}, [d, h, u,
|
|
2576
|
+
}, [d, h, u, g] = Ji(
|
|
2570
2577
|
e.frontPlace
|
|
2571
2578
|
), f = e.scores, b = l(d, f.front, {
|
|
2572
2579
|
x: n / 2,
|
|
@@ -2587,23 +2594,23 @@ const Kt = (s, t, e = Kn) => {
|
|
|
2587
2594
|
const at = j(x.e, x.width, x.height, 180).translate(
|
|
2588
2595
|
n / 2 - x.width,
|
|
2589
2596
|
-x.height
|
|
2590
|
-
), Q = l(
|
|
2597
|
+
), Q = l(g, f.left, {
|
|
2591
2598
|
"dominant-baseline": "ideographic",
|
|
2592
2599
|
"text-anchor": "middle"
|
|
2593
2600
|
}), tt = j(Q.e, Q.width, Q.height, 90).translate(
|
|
2594
2601
|
-Q.height,
|
|
2595
2602
|
n / 2
|
|
2596
|
-
), ct = new N(),
|
|
2597
|
-
return ct.add(
|
|
2598
|
-
},
|
|
2603
|
+
), ct = new N(), ws = new Wn().size(n, n).x(0).y(0).fill("none").stroke("#000000");
|
|
2604
|
+
return ct.add(ws), ct.add(c.e), ct.add(b), ct.add(S), ct.add(at), ct.add(tt), { e: ct, width: n, height: n };
|
|
2605
|
+
}, qi = (s, t) => {
|
|
2599
2606
|
const e = Zt(t.front, s), n = Zt(t.right, s), i = Zt(t.opposite, s), r = Zt(t.left, s), o = [e.height, n.height, i.height, r.height].reduce(
|
|
2600
2607
|
(S, x) => Math.max(S, x)
|
|
2601
|
-
), a = s.tileWidth * 5 + s.tileHeight * 1, c = o, l = a + o * 2 + s.blockMargin, d = l, h = new N().size(l, d), u = l / 2 - a / 2,
|
|
2608
|
+
), a = s.tileWidth * 5 + s.tileHeight * 1, c = o, l = a + o * 2 + s.blockMargin, d = l, h = new N().size(l, d), u = l / 2 - a / 2, g = d / 2 - a / 2, f = j(e.e, a, c, 0).translate(
|
|
2602
2609
|
u,
|
|
2603
2610
|
d - c
|
|
2604
2611
|
), w = j(n.e, a, c, 270).translate(
|
|
2605
2612
|
l - c,
|
|
2606
|
-
|
|
2613
|
+
g
|
|
2607
2614
|
), b = j(
|
|
2608
2615
|
i.e,
|
|
2609
2616
|
a,
|
|
@@ -2611,11 +2618,11 @@ const Kt = (s, t, e = Kn) => {
|
|
|
2611
2618
|
180
|
|
2612
2619
|
).translate(u, 0), A = j(r.e, a, c, 90).translate(
|
|
2613
2620
|
0,
|
|
2614
|
-
|
|
2621
|
+
g
|
|
2615
2622
|
);
|
|
2616
2623
|
return h.add(f), h.add(w), h.add(b), h.add(A), { e: new N().add(h), width: l, height: d };
|
|
2617
|
-
},
|
|
2618
|
-
const r = new N(), o =
|
|
2624
|
+
}, Qi = (s, t, e, n, i) => {
|
|
2625
|
+
const r = new N(), o = qi(s, n), a = Vi(s, e, o.height), c = Xi(s, t, i);
|
|
2619
2626
|
return o.e.translate(
|
|
2620
2627
|
(a.width - o.width) / 2,
|
|
2621
2628
|
(a.height - o.height) / 2
|
|
@@ -2623,13 +2630,13 @@ const Kt = (s, t, e = Kn) => {
|
|
|
2623
2630
|
(a.width - c.width) / 2,
|
|
2624
2631
|
(a.height - c.height) / 2
|
|
2625
2632
|
), r.add(a.e), r.add(o.e), r.add(c.e), { e: r, width: a.width, height: a.height };
|
|
2626
|
-
},
|
|
2627
|
-
const r = new
|
|
2633
|
+
}, sa = (s, t, e = {}, n, i = { responsive: !1 }) => {
|
|
2634
|
+
const r = new Kn(e), o = n, { discards: a, hands: c, scoreBoard: l } = ur(t), d = Qi(r, o, c, a, l);
|
|
2628
2635
|
i.responsive || s.size(d.width, d.height), s.viewbox(0, 0, d.width, d.height), s.add(d.e);
|
|
2629
2636
|
};
|
|
2630
2637
|
let be;
|
|
2631
2638
|
// @__NO_SIDE_EFFECTS__
|
|
2632
|
-
function
|
|
2639
|
+
function jn(s) {
|
|
2633
2640
|
return {
|
|
2634
2641
|
lang: s?.lang ?? be?.lang,
|
|
2635
2642
|
message: s?.message,
|
|
@@ -2637,20 +2644,20 @@ function Un(s) {
|
|
|
2637
2644
|
abortPipeEarly: s?.abortPipeEarly ?? be?.abortPipeEarly
|
|
2638
2645
|
};
|
|
2639
2646
|
}
|
|
2640
|
-
let
|
|
2647
|
+
let tr;
|
|
2641
2648
|
// @__NO_SIDE_EFFECTS__
|
|
2642
|
-
function
|
|
2643
|
-
return
|
|
2649
|
+
function er(s) {
|
|
2650
|
+
return tr?.get(s);
|
|
2644
2651
|
}
|
|
2645
|
-
let
|
|
2652
|
+
let nr;
|
|
2646
2653
|
// @__NO_SIDE_EFFECTS__
|
|
2647
|
-
function
|
|
2648
|
-
return
|
|
2654
|
+
function sr(s) {
|
|
2655
|
+
return nr?.get(s);
|
|
2649
2656
|
}
|
|
2650
|
-
let
|
|
2657
|
+
let ir;
|
|
2651
2658
|
// @__NO_SIDE_EFFECTS__
|
|
2652
|
-
function
|
|
2653
|
-
return
|
|
2659
|
+
function rr(s, t) {
|
|
2660
|
+
return ir?.get(s)?.get(t);
|
|
2654
2661
|
}
|
|
2655
2662
|
// @__NO_SIDE_EFFECTS__
|
|
2656
2663
|
function Ct(s) {
|
|
@@ -2671,7 +2678,7 @@ function it(s, t, e, n, i) {
|
|
|
2671
2678
|
lang: n.lang,
|
|
2672
2679
|
abortEarly: n.abortEarly,
|
|
2673
2680
|
abortPipeEarly: n.abortPipeEarly
|
|
2674
|
-
}, l = s.kind === "schema", d = i?.message ?? s.message ?? /* @__PURE__ */
|
|
2681
|
+
}, l = s.kind === "schema", d = i?.message ?? s.message ?? /* @__PURE__ */ rr(s.reference, c.lang) ?? (l ? /* @__PURE__ */ sr(c.lang) : null) ?? n.message ?? /* @__PURE__ */ er(c.lang);
|
|
2675
2682
|
d !== void 0 && (c.message = typeof d == "function" ? d(c) : d), l && (e.typed = !1), e.issues ? e.issues.push(c) : e.issues = [c];
|
|
2676
2683
|
}
|
|
2677
2684
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -2680,12 +2687,12 @@ function Bt(s) {
|
|
|
2680
2687
|
version: 1,
|
|
2681
2688
|
vendor: "valibot",
|
|
2682
2689
|
validate(t) {
|
|
2683
|
-
return s["~run"]({ value: t }, /* @__PURE__ */
|
|
2690
|
+
return s["~run"]({ value: t }, /* @__PURE__ */ jn());
|
|
2684
2691
|
}
|
|
2685
2692
|
};
|
|
2686
2693
|
}
|
|
2687
2694
|
// @__NO_SIDE_EFFECTS__
|
|
2688
|
-
function
|
|
2695
|
+
function or(s, t) {
|
|
2689
2696
|
const e = [...new Set(s)];
|
|
2690
2697
|
return e.length > 1 ? `(${e.join(` ${t} `)})` : e[0] ?? "never";
|
|
2691
2698
|
}
|
|
@@ -2720,11 +2727,11 @@ function Oe(s, t) {
|
|
|
2720
2727
|
};
|
|
2721
2728
|
}
|
|
2722
2729
|
// @__NO_SIDE_EFFECTS__
|
|
2723
|
-
function
|
|
2730
|
+
function ar(s, t, e) {
|
|
2724
2731
|
return typeof s.fallback == "function" ? s.fallback(t, e) : s.fallback;
|
|
2725
2732
|
}
|
|
2726
2733
|
// @__NO_SIDE_EFFECTS__
|
|
2727
|
-
function
|
|
2734
|
+
function Fn(s, t, e) {
|
|
2728
2735
|
return typeof s.default == "function" ? s.default(t, e) : s.default;
|
|
2729
2736
|
}
|
|
2730
2737
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -2758,7 +2765,7 @@ function K(s, t) {
|
|
|
2758
2765
|
return /* @__PURE__ */ Bt(this);
|
|
2759
2766
|
},
|
|
2760
2767
|
"~run"(e, n) {
|
|
2761
|
-
return e.value === void 0 && (this.default !== void 0 && (e.value = /* @__PURE__ */
|
|
2768
|
+
return e.value === void 0 && (this.default !== void 0 && (e.value = /* @__PURE__ */ Fn(this, e, n)), e.value === void 0) ? (e.typed = !0, e) : this.wrapped["~run"](e, n);
|
|
2762
2769
|
}
|
|
2763
2770
|
};
|
|
2764
2771
|
}
|
|
@@ -2768,7 +2775,7 @@ function ke(s, t) {
|
|
|
2768
2775
|
kind: "schema",
|
|
2769
2776
|
type: "picklist",
|
|
2770
2777
|
reference: ke,
|
|
2771
|
-
expects: /* @__PURE__ */
|
|
2778
|
+
expects: /* @__PURE__ */ or(s.map(Ct), "|"),
|
|
2772
2779
|
async: !1,
|
|
2773
2780
|
options: s,
|
|
2774
2781
|
message: t,
|
|
@@ -2800,7 +2807,7 @@ function Rt(s, t) {
|
|
|
2800
2807
|
for (const r in this.entries) {
|
|
2801
2808
|
const o = this.entries[r];
|
|
2802
2809
|
if (r in i || (o.type === "exact_optional" || o.type === "optional" || o.type === "nullish") && o.default !== void 0) {
|
|
2803
|
-
const a = r in i ? i[r] : /* @__PURE__ */
|
|
2810
|
+
const a = r in i ? i[r] : /* @__PURE__ */ Fn(o), c = o["~run"]({ value: a }, n);
|
|
2804
2811
|
if (c.issues) {
|
|
2805
2812
|
const l = {
|
|
2806
2813
|
type: "object",
|
|
@@ -2817,7 +2824,7 @@ function Rt(s, t) {
|
|
|
2817
2824
|
}
|
|
2818
2825
|
}
|
|
2819
2826
|
c.typed || (e.typed = !1), e.value[r] = c.value;
|
|
2820
|
-
} else if (o.fallback !== void 0) e.value[r] = /* @__PURE__ */
|
|
2827
|
+
} else if (o.fallback !== void 0) e.value[r] = /* @__PURE__ */ ar(o);
|
|
2821
2828
|
else if (o.type !== "exact_optional" && o.type !== "optional" && o.type !== "nullish" && (it(this, "key", e, n, {
|
|
2822
2829
|
input: void 0,
|
|
2823
2830
|
expected: `"${r}"`,
|
|
@@ -2870,7 +2877,7 @@ function re(s) {
|
|
|
2870
2877
|
};
|
|
2871
2878
|
}
|
|
2872
2879
|
// @__NO_SIDE_EFFECTS__
|
|
2873
|
-
function
|
|
2880
|
+
function fn(...s) {
|
|
2874
2881
|
return {
|
|
2875
2882
|
...s[0],
|
|
2876
2883
|
pipe: s,
|
|
@@ -2890,8 +2897,8 @@ function un(...s) {
|
|
|
2890
2897
|
};
|
|
2891
2898
|
}
|
|
2892
2899
|
// @__NO_SIDE_EFFECTS__
|
|
2893
|
-
function
|
|
2894
|
-
const n = s["~run"]({ value: t }, /* @__PURE__ */
|
|
2900
|
+
function cr(s, t, e) {
|
|
2901
|
+
const n = s["~run"]({ value: t }, /* @__PURE__ */ jn(e));
|
|
2895
2902
|
return {
|
|
2896
2903
|
typed: n.typed,
|
|
2897
2904
|
success: !n.issues,
|
|
@@ -2906,7 +2913,7 @@ const Yt = /* @__PURE__ */ K(
|
|
|
2906
2913
|
score: /* @__PURE__ */ K(/* @__PURE__ */ ie(), 25e3)
|
|
2907
2914
|
}),
|
|
2908
2915
|
{ discard: "", hand: "", score: 25e3 }
|
|
2909
|
-
),
|
|
2916
|
+
), lr = /* @__PURE__ */ Rt({
|
|
2910
2917
|
[_.E]: Yt,
|
|
2911
2918
|
[_.S]: Yt,
|
|
2912
2919
|
[_.W]: Yt,
|
|
@@ -2914,46 +2921,51 @@ const Yt = /* @__PURE__ */ K(
|
|
|
2914
2921
|
}), ht = {
|
|
2915
2922
|
round: k.E1,
|
|
2916
2923
|
sticks: { reach: 0, dead: 0 },
|
|
2917
|
-
|
|
2924
|
+
doraIndicators: _.S,
|
|
2918
2925
|
front: _.E
|
|
2919
|
-
},
|
|
2926
|
+
}, hr = /* @__PURE__ */ K(
|
|
2920
2927
|
/* @__PURE__ */ Rt({
|
|
2921
2928
|
round: /* @__PURE__ */ K(
|
|
2922
|
-
/* @__PURE__ */ ke(Object.keys(
|
|
2929
|
+
/* @__PURE__ */ ke(Object.keys(On)),
|
|
2923
2930
|
ht.round
|
|
2924
2931
|
),
|
|
2925
2932
|
sticks: /* @__PURE__ */ K(
|
|
2926
2933
|
/* @__PURE__ */ Rt({
|
|
2927
2934
|
reach: /* @__PURE__ */ K(
|
|
2928
|
-
/* @__PURE__ */
|
|
2935
|
+
/* @__PURE__ */ fn(/* @__PURE__ */ ie(), /* @__PURE__ */ Oe(0, ""), /* @__PURE__ */ Se(9, "")),
|
|
2929
2936
|
ht.sticks.reach
|
|
2930
2937
|
),
|
|
2931
2938
|
dead: /* @__PURE__ */ K(
|
|
2932
|
-
/* @__PURE__ */
|
|
2939
|
+
/* @__PURE__ */ fn(/* @__PURE__ */ ie(), /* @__PURE__ */ Oe(0, ""), /* @__PURE__ */ Se(9, "")),
|
|
2933
2940
|
ht.sticks.dead
|
|
2934
2941
|
)
|
|
2935
2942
|
}),
|
|
2936
2943
|
ht.sticks
|
|
2937
2944
|
),
|
|
2938
|
-
|
|
2945
|
+
doraIndicators: /* @__PURE__ */ K(/* @__PURE__ */ re(), ht.doraIndicators),
|
|
2939
2946
|
front: /* @__PURE__ */ K(
|
|
2940
2947
|
/* @__PURE__ */ ke(Object.keys(We)),
|
|
2941
2948
|
ht.front
|
|
2942
2949
|
)
|
|
2943
2950
|
}),
|
|
2944
2951
|
ht
|
|
2945
|
-
),
|
|
2946
|
-
...
|
|
2947
|
-
board:
|
|
2948
|
-
}),
|
|
2949
|
-
const t =
|
|
2950
|
-
return
|
|
2951
|
-
}, ur = (s) => {
|
|
2952
|
-
const t = fr(s), e = /* @__PURE__ */ ar(hr, t);
|
|
2953
|
-
if (!e.success)
|
|
2954
|
-
throw e.issues;
|
|
2955
|
-
return e.output;
|
|
2952
|
+
), dr = /* @__PURE__ */ Rt({
|
|
2953
|
+
...lr.entries,
|
|
2954
|
+
board: hr
|
|
2955
|
+
}), ur = (s) => {
|
|
2956
|
+
const t = fr(s);
|
|
2957
|
+
return wr(t);
|
|
2956
2958
|
}, fr = (s) => {
|
|
2959
|
+
const t = gr(s);
|
|
2960
|
+
return pr(t);
|
|
2961
|
+
};
|
|
2962
|
+
function pr(s) {
|
|
2963
|
+
const t = /* @__PURE__ */ cr(dr, s);
|
|
2964
|
+
if (!t.success)
|
|
2965
|
+
throw t.issues;
|
|
2966
|
+
return t.output;
|
|
2967
|
+
}
|
|
2968
|
+
const gr = (s) => {
|
|
2957
2969
|
const t = "table", e = "board", n = s.split(`
|
|
2958
2970
|
`).map((a) => a.trim()).filter((a) => a != "");
|
|
2959
2971
|
if (n.length == 0) throw new Error("empty input");
|
|
@@ -2968,15 +2980,15 @@ const Yt = /* @__PURE__ */ K(
|
|
|
2968
2980
|
const c = o.find((l) => a.startsWith(l));
|
|
2969
2981
|
if (c == null) throw new Error(`encountered unexpected line ${a}`);
|
|
2970
2982
|
if (o = o.filter((l) => !a.startsWith(l)), c == e) {
|
|
2971
|
-
const [l, d] =
|
|
2983
|
+
const [l, d] = yr([...n]);
|
|
2972
2984
|
r.board = l, n.splice(0, d);
|
|
2973
2985
|
} else {
|
|
2974
|
-
const [l, d] =
|
|
2986
|
+
const [l, d] = mr([...n]);
|
|
2975
2987
|
r[c] = l, n.splice(0, d);
|
|
2976
2988
|
}
|
|
2977
2989
|
}
|
|
2978
2990
|
return r;
|
|
2979
|
-
}, Z = (s, t) => s.replace(t, "").replace(":", "").trim(),
|
|
2991
|
+
}, Z = (s, t) => s.replace(t, "").replace(":", "").trim(), mr = (s) => {
|
|
2980
2992
|
const t = "hand", e = "discard", n = "score", i = {};
|
|
2981
2993
|
let r = 0;
|
|
2982
2994
|
for (; r < s.length; r++) {
|
|
@@ -2989,13 +3001,13 @@ const Yt = /* @__PURE__ */ K(
|
|
|
2989
3001
|
else break;
|
|
2990
3002
|
}
|
|
2991
3003
|
return [i, r];
|
|
2992
|
-
},
|
|
2993
|
-
const t = "
|
|
3004
|
+
}, yr = (s) => {
|
|
3005
|
+
const t = "dora_indicators", e = "round", n = "front", i = "sticks", r = "reach", o = "dead", a = {};
|
|
2994
3006
|
let c = 0;
|
|
2995
3007
|
for (; c < s.length; c++) {
|
|
2996
3008
|
const l = s[c];
|
|
2997
3009
|
if (l.startsWith(t))
|
|
2998
|
-
a.
|
|
3010
|
+
a.doraIndicators = Z(l, t);
|
|
2999
3011
|
else if (l.startsWith(e))
|
|
3000
3012
|
a.round = Z(l, e);
|
|
3001
3013
|
else if (l.startsWith(n))
|
|
@@ -3007,8 +3019,8 @@ const Yt = /* @__PURE__ */ K(
|
|
|
3007
3019
|
} else break;
|
|
3008
3020
|
}
|
|
3009
3021
|
return [a, c];
|
|
3010
|
-
},
|
|
3011
|
-
const t = s.board.front, e =
|
|
3022
|
+
}, wr = (s) => {
|
|
3023
|
+
const t = s.board.front, e = Er(t), n = (a) => s[a].discard.replace(/\r?\n/g, ""), i = {
|
|
3012
3024
|
front: new D(n(e.front)).tiles(),
|
|
3013
3025
|
right: new D(n(e.right)).tiles(),
|
|
3014
3026
|
opposite: new D(n(e.opposite)).tiles(),
|
|
@@ -3019,10 +3031,10 @@ const Yt = /* @__PURE__ */ K(
|
|
|
3019
3031
|
opposite: new D(s[e.opposite].hand).parse(),
|
|
3020
3032
|
left: new D(s[e.left].hand).parse()
|
|
3021
3033
|
}, o = {
|
|
3022
|
-
round:
|
|
3034
|
+
round: On[s.board.round],
|
|
3023
3035
|
frontPlace: We[t],
|
|
3024
3036
|
sticks: s.board.sticks,
|
|
3025
|
-
|
|
3037
|
+
doraIndicators: new D(s.board.doraIndicators).tiles(),
|
|
3026
3038
|
scores: {
|
|
3027
3039
|
front: s[e.front].score,
|
|
3028
3040
|
right: s[e.right].score,
|
|
@@ -3031,7 +3043,7 @@ const Yt = /* @__PURE__ */ K(
|
|
|
3031
3043
|
}
|
|
3032
3044
|
};
|
|
3033
3045
|
return { discards: i, hands: r, scoreBoard: o };
|
|
3034
|
-
},
|
|
3046
|
+
}, Er = (s) => ({
|
|
3035
3047
|
front: s,
|
|
3036
3048
|
right: vt(s),
|
|
3037
3049
|
opposite: vt(vt(s)),
|
|
@@ -3090,18 +3102,18 @@ class je {
|
|
|
3090
3102
|
const t = [];
|
|
3091
3103
|
for (const [e, n] of F()) {
|
|
3092
3104
|
let i = this.get(e, n);
|
|
3093
|
-
e != p.Z && n == 5 && this.get(e, 0) > 0 && (i -= this.get(e, 0), t.push(new y(e, n, [
|
|
3105
|
+
e != p.Z && n == 5 && this.get(e, 0) > 0 && (i -= this.get(e, 0), t.push(new y(e, n, [m.RED])));
|
|
3094
3106
|
for (let r = 0; r < i; r++)
|
|
3095
3107
|
t.push(new y(e, n));
|
|
3096
3108
|
}
|
|
3097
3109
|
if (this.drawn != null) {
|
|
3098
3110
|
const e = this.drawn, n = t.findIndex(
|
|
3099
|
-
(i) => i.equals(e) && e.has(
|
|
3111
|
+
(i) => i.equals(e) && e.has(m.RED) == i.has(m.RED)
|
|
3100
3112
|
);
|
|
3101
3113
|
I(
|
|
3102
3114
|
n >= 0,
|
|
3103
3115
|
`drawn tile ${this.drawn} not found in hand: ${t.join("")}`
|
|
3104
|
-
), t[n] = t[n].clone({ add:
|
|
3116
|
+
), t[n] = t[n].clone({ add: m.TSUMO });
|
|
3105
3117
|
}
|
|
3106
3118
|
return t;
|
|
3107
3119
|
}
|
|
@@ -3109,7 +3121,7 @@ class je {
|
|
|
3109
3121
|
* 晒された牌を含む手牌を整形した文字列で返す。
|
|
3110
3122
|
*/
|
|
3111
3123
|
toString() {
|
|
3112
|
-
const t = this.called.length > 0 ? `${X}${this.called.join(X)}` : "", e = this.drawn ? `${X}${this.drawn.toString()}` : "", n = this.hands.filter((r) => !r.has(
|
|
3124
|
+
const t = this.called.length > 0 ? `${X}${this.called.join(X)}` : "", e = this.drawn ? `${X}${this.drawn.toString()}` : "", n = this.hands.filter((r) => !r.has(m.TSUMO));
|
|
3113
3125
|
return `${new Tt(n).toString()}${e}${t}`;
|
|
3114
3126
|
}
|
|
3115
3127
|
/**
|
|
@@ -3159,13 +3171,13 @@ class je {
|
|
|
3159
3171
|
inc(t) {
|
|
3160
3172
|
const e = [];
|
|
3161
3173
|
for (const n of t) {
|
|
3162
|
-
const i = n.t != p.BACK && this.get(n.t, n.n) >= 4, r = n.has(
|
|
3174
|
+
const i = n.t != p.BACK && this.get(n.t, n.n) >= 4, r = n.has(m.RED) && this.get(n.t, 0) > 0;
|
|
3163
3175
|
if (i || r) {
|
|
3164
3176
|
this.dec(e);
|
|
3165
3177
|
const o = i ? `tile ${n} exists more than 4 times` : `red tile ${n} appears more than once`;
|
|
3166
3178
|
throw new Error(`invalid hand: ${o} in hand: ${this.toString()}`);
|
|
3167
3179
|
}
|
|
3168
|
-
e.push(n), n.t == p.BACK ? this.data[n.t][1] += 1 : (this.data[n.t][n.n] += 1, n.has(
|
|
3180
|
+
e.push(n), n.t == p.BACK ? this.data[n.t][1] += 1 : (this.data[n.t][n.n] += 1, n.has(m.RED) && (this.data[n.t][0] += 1));
|
|
3169
3181
|
}
|
|
3170
3182
|
return e;
|
|
3171
3183
|
}
|
|
@@ -3175,15 +3187,15 @@ class je {
|
|
|
3175
3187
|
dec(t) {
|
|
3176
3188
|
const e = [];
|
|
3177
3189
|
for (const n of t) {
|
|
3178
|
-
const i = this.get(n.t, n.n) < 1, r = n.has(
|
|
3190
|
+
const i = this.get(n.t, n.n) < 1, r = n.has(m.RED) && this.get(n.t, 0) <= 0;
|
|
3179
3191
|
if (i || r) {
|
|
3180
3192
|
this.inc(e);
|
|
3181
3193
|
const o = i ? `tile ${n} does not exist` : `red tile ${n} does not exist`;
|
|
3182
3194
|
throw new Error(`invalid hand: ${o} in hand: ${this.toString()}`);
|
|
3183
3195
|
}
|
|
3184
|
-
if (e.push(n), n.t == p.BACK ? this.data[n.t][1] -= 1 : (this.data[n.t][n.n] -= 1, n.has(
|
|
3196
|
+
if (e.push(n), n.t == p.BACK ? this.data[n.t][1] -= 1 : (this.data[n.t][n.n] -= 1, n.has(m.RED) && (this.data[n.t][0] -= 1)), O(n) && this.get(n.t, 5) == 0 && this.get(n.t, 0) > 0) {
|
|
3185
3197
|
this.data[n.t][0] = 0;
|
|
3186
|
-
const o = e.pop().clone({ add:
|
|
3198
|
+
const o = e.pop().clone({ add: m.RED });
|
|
3187
3199
|
e.push(o);
|
|
3188
3200
|
}
|
|
3189
3201
|
}
|
|
@@ -3193,7 +3205,7 @@ class je {
|
|
|
3193
3205
|
* ツモ牌として手牌に加える。
|
|
3194
3206
|
*/
|
|
3195
3207
|
draw(t) {
|
|
3196
|
-
const e = t.clone({ add:
|
|
3208
|
+
const e = t.clone({ add: m.TSUMO });
|
|
3197
3209
|
this.inc([e]), this.data.tsumo = e;
|
|
3198
3210
|
}
|
|
3199
3211
|
/**
|
|
@@ -3214,7 +3226,7 @@ class je {
|
|
|
3214
3226
|
* 他家の打牌を指定したブロックで鳴く。鳴く牌はブロック内で表現する。
|
|
3215
3227
|
*/
|
|
3216
3228
|
call(t) {
|
|
3217
|
-
const e = t.tiles.filter((n) => !n.has(
|
|
3229
|
+
const e = t.tiles.filter((n) => !n.has(m.HORIZONTAL));
|
|
3218
3230
|
if (e.length != t.tiles.length - 1)
|
|
3219
3231
|
throw new Error(`invalid block: removal tiles: ${e}, block: ${t}`);
|
|
3220
3232
|
this.dec(e), this.data.called = [...this.called, t], this.data.tsumo = null;
|
|
@@ -3227,7 +3239,7 @@ class je {
|
|
|
3227
3239
|
this.dec(t.tiles), this.data.called = [...this.called, t], this.data.tsumo = null;
|
|
3228
3240
|
return;
|
|
3229
3241
|
}
|
|
3230
|
-
if (t instanceof
|
|
3242
|
+
if (t instanceof P) {
|
|
3231
3243
|
const e = this.data.called.findIndex(
|
|
3232
3244
|
(i) => i.is(E.PON) && i.tiles[0].equals(t.tiles[0])
|
|
3233
3245
|
);
|
|
@@ -3236,7 +3248,7 @@ class je {
|
|
|
3236
3248
|
`cannot find pon block ${t.tiles[0]} to call shokan: ${t}`
|
|
3237
3249
|
);
|
|
3238
3250
|
let n = t.tiles[0];
|
|
3239
|
-
n = O(n) ? n.clone({ remove:
|
|
3251
|
+
n = O(n) ? n.clone({ remove: m.RED }) : n, this.dec([n]), this.data.called = [
|
|
3240
3252
|
...this.called.slice(0, e),
|
|
3241
3253
|
...this.called.slice(e + 1),
|
|
3242
3254
|
t
|
|
@@ -3295,18 +3307,18 @@ class ge {
|
|
|
3295
3307
|
standardType() {
|
|
3296
3308
|
const t = (n) => {
|
|
3297
3309
|
const i = [0, 0, 0];
|
|
3298
|
-
for (const [u,
|
|
3299
|
-
this.hand.get(u,
|
|
3310
|
+
for (const [u, g] of F({ filterBy: [p.Z] }))
|
|
3311
|
+
this.hand.get(u, g) >= 3 ? i[0]++ : this.hand.get(u, g) == 2 ? i[1]++ : this.hand.get(u, g) == 1 && i[2]++;
|
|
3300
3312
|
const r = [0, 0, 0], o = this.hand.get(p.BACK, 0), a = o % 3;
|
|
3301
3313
|
r[0] = Math.floor(o / 3), a == 2 ? r[1] = 1 : a == 1 && (r[2] = 1);
|
|
3302
3314
|
let c = 13;
|
|
3303
3315
|
const l = this.calcNumberTilePatterns(p.M), d = this.calcNumberTilePatterns(p.P), h = this.calcNumberTilePatterns(p.S);
|
|
3304
3316
|
for (const u of [l.patternA, l.patternB])
|
|
3305
|
-
for (const
|
|
3317
|
+
for (const g of [d.patternA, d.patternB])
|
|
3306
3318
|
for (const f of [h.patternA, h.patternB]) {
|
|
3307
3319
|
const w = [this.hand.called.length, 0, 0];
|
|
3308
3320
|
for (let A = 0; A < 3; A++)
|
|
3309
|
-
w[A] += u[A] +
|
|
3321
|
+
w[A] += u[A] + g[A] + f[A] + i[A] + r[A];
|
|
3310
3322
|
const b = this.getStandardTypeShanten(w[0], w[1], w[2], n);
|
|
3311
3323
|
b < c && (c = b);
|
|
3312
3324
|
}
|
|
@@ -3351,7 +3363,7 @@ class ge {
|
|
|
3351
3363
|
return t > 4 && (e += t - 4, t = 4), t + e > 4 && (n += t + e - 4, e = 4 - t), t + e + n > r && (n = r - t - e), i && e++, 13 - t * 3 - e * 2 - n;
|
|
3352
3364
|
}
|
|
3353
3365
|
}
|
|
3354
|
-
class
|
|
3366
|
+
class br {
|
|
3355
3367
|
hand;
|
|
3356
3368
|
constructor(t) {
|
|
3357
3369
|
this.hand = t;
|
|
@@ -3382,12 +3394,12 @@ class wr {
|
|
|
3382
3394
|
*/
|
|
3383
3395
|
markedHand(t, e) {
|
|
3384
3396
|
if (t.length == 0) return [];
|
|
3385
|
-
const n = this.hand.drawn != null || e.has(
|
|
3397
|
+
const n = this.hand.drawn != null || e.has(m.TSUMO) ? m.TSUMO : m.RON, i = [], r = {};
|
|
3386
3398
|
for (let a = 0; a < t.length; a++) {
|
|
3387
3399
|
const c = t[a];
|
|
3388
3400
|
if (c.isCalled()) continue;
|
|
3389
3401
|
const l = c.tiles.findIndex(
|
|
3390
|
-
(h) => h.equals(e) && e.has(
|
|
3402
|
+
(h) => h.equals(e) && e.has(m.RED) == h.has(m.RED)
|
|
3391
3403
|
);
|
|
3392
3404
|
if (l < 0) continue;
|
|
3393
3405
|
const d = zt(c);
|
|
@@ -3435,7 +3447,7 @@ class wr {
|
|
|
3435
3447
|
const i = n == p.Z ? jt : q;
|
|
3436
3448
|
for (let r of i)
|
|
3437
3449
|
if (this.hand.get(n, r) == 1)
|
|
3438
|
-
t.push(new
|
|
3450
|
+
t.push(new kn(new y(n, r)));
|
|
3439
3451
|
else if (this.hand.get(n, r) == 2 && e == !1)
|
|
3440
3452
|
t.unshift(new C(new y(n, r), new y(n, r))), e = !0;
|
|
3441
3453
|
else return [];
|
|
@@ -3465,7 +3477,7 @@ class wr {
|
|
|
3465
3477
|
for (const [e, n] of F())
|
|
3466
3478
|
if (this.hand.get(e, n) >= 2) {
|
|
3467
3479
|
const i = new Array(2).fill(new y(e, n));
|
|
3468
|
-
n == 5 && this.hand.get(e, 0) > 0 && this.hand.get(e, n) >= 3 && (i[1] = new y(e, n, [
|
|
3480
|
+
n == 5 && this.hand.get(e, 0) > 0 && this.hand.get(e, n) >= 3 && (i[1] = new y(e, n, [m.RED]));
|
|
3469
3481
|
const r = this.hand.dec(i), o = this.calcAllBlockCombinations().filter((a) => a.length == 4).map((a) => [new C(r[0], r[1]), ...a]);
|
|
3470
3482
|
t = [...t, ...o], this.hand.inc(r);
|
|
3471
3483
|
}
|
|
@@ -3505,14 +3517,14 @@ class wr {
|
|
|
3505
3517
|
* 一つの手牌の構成において、赤牌ごとの手牌(晒したブロックを含まない)の構成を生成する。
|
|
3506
3518
|
*/
|
|
3507
3519
|
addRedPattern(t, e) {
|
|
3508
|
-
const n = new y(t, 5), i = new y(t, 5, [
|
|
3520
|
+
const n = new y(t, 5), i = new y(t, 5, [m.RED]), r = [];
|
|
3509
3521
|
let o = null;
|
|
3510
3522
|
const a = {};
|
|
3511
3523
|
for (let l = 0; l < e.length; l++) {
|
|
3512
|
-
const d = e[l], h = d.tiles.findIndex((f) => O(f) && !f.has(
|
|
3524
|
+
const d = e[l], h = d.tiles.findIndex((f) => O(f) && !f.has(m.RED)), u = d.tiles.findIndex((f) => O(f) && f.has(m.RED));
|
|
3513
3525
|
if (u > -1 && (o = [l, u]), u > -1 && h > -1 || h < 0) continue;
|
|
3514
|
-
const
|
|
3515
|
-
a[
|
|
3526
|
+
const g = zt(d);
|
|
3527
|
+
a[g] || (a[g] = !0, r.push([l, h]));
|
|
3516
3528
|
}
|
|
3517
3529
|
if (o == null) return [e];
|
|
3518
3530
|
const c = [e];
|
|
@@ -3521,10 +3533,10 @@ class wr {
|
|
|
3521
3533
|
h[l] = u.clone({
|
|
3522
3534
|
replace: { idx: d, tile: i }
|
|
3523
3535
|
});
|
|
3524
|
-
const
|
|
3525
|
-
h[o[0]] =
|
|
3536
|
+
const g = h[o[0]];
|
|
3537
|
+
h[o[0]] = g.clone({
|
|
3526
3538
|
replace: { idx: o[1], tile: n }
|
|
3527
|
-
}), zt(u) != zt(
|
|
3539
|
+
}), zt(u) != zt(g) && c.push(h);
|
|
3528
3540
|
}
|
|
3529
3541
|
return c;
|
|
3530
3542
|
}
|
|
@@ -3581,14 +3593,14 @@ const jt = [1, 2, 3, 4, 5, 6, 7], q = [1, 9], Vt = (s) => {
|
|
|
3581
3593
|
DOUBLE_YAKUMAN: 16e3,
|
|
3582
3594
|
DEAD_STICK: 300,
|
|
3583
3595
|
REACH_STICK: 1e3
|
|
3584
|
-
},
|
|
3596
|
+
}, _r = [
|
|
3585
3597
|
{ minHan: 26, points: M.DOUBLE_YAKUMAN },
|
|
3586
3598
|
{ minHan: 13, points: M.YAKUMAN },
|
|
3587
3599
|
{ minHan: 11, points: M.TRIPLE },
|
|
3588
3600
|
{ minHan: 8, points: M.DOUBLE },
|
|
3589
3601
|
{ minHan: 6, points: M.HANEMAN },
|
|
3590
3602
|
{ minHan: 5, points: M.MANGAN }
|
|
3591
|
-
],
|
|
3603
|
+
], Ar = {
|
|
3592
3604
|
[M.MANGAN]: "満貫",
|
|
3593
3605
|
[M.HANEMAN]: "跳満",
|
|
3594
3606
|
[M.DOUBLE]: "倍満",
|
|
@@ -3600,17 +3612,17 @@ const jt = [1, 2, 3, 4, 5, 6, 7], q = [1, 9], Vt = (s) => {
|
|
|
3600
3612
|
CHILD_TUMO_FROM_PARENT: 2,
|
|
3601
3613
|
CHILD_TUMO_FROM_CHILD: 1
|
|
3602
3614
|
};
|
|
3603
|
-
function
|
|
3615
|
+
function Ir(s) {
|
|
3604
3616
|
if (s.isYakuman) return "役満";
|
|
3605
3617
|
if (s.isCountableYakuman) return "数え役満";
|
|
3606
|
-
const t =
|
|
3618
|
+
const t = Nr(
|
|
3607
3619
|
s.base,
|
|
3608
3620
|
s.isTsumo,
|
|
3609
3621
|
s.isParent
|
|
3610
|
-
), e =
|
|
3622
|
+
), e = Ar[s.base];
|
|
3611
3623
|
return e ? `${s.fu}符${s.han}飜 ${e}${t}` : `${s.fu}符${s.han}飜 ${t}`;
|
|
3612
3624
|
}
|
|
3613
|
-
function
|
|
3625
|
+
function Nr(s, t, e) {
|
|
3614
3626
|
if (t)
|
|
3615
3627
|
return e ? `${nt(s * Y.PARENT_TSUMO)}` : `${nt(s * Y.CHILD_TUMO_FROM_CHILD)}-${nt(
|
|
3616
3628
|
s * Y.CHILD_TUMO_FROM_PARENT
|
|
@@ -3621,15 +3633,15 @@ function Ar(s, t, e) {
|
|
|
3621
3633
|
}
|
|
3622
3634
|
}
|
|
3623
3635
|
const nt = (s, t = 100) => Math.ceil(s / t) * t;
|
|
3624
|
-
class
|
|
3636
|
+
class Gn {
|
|
3625
3637
|
hand;
|
|
3626
3638
|
cfg;
|
|
3627
3639
|
constructor(t, e) {
|
|
3628
3640
|
this.hand = t, this.cfg = {
|
|
3629
|
-
doras: e.doraIndicators.map((n) =>
|
|
3641
|
+
doras: e.doraIndicators.map((n) => gn(n)),
|
|
3630
3642
|
// convert to dora
|
|
3631
|
-
hiddenDoras: e.hiddenDoraIndicators == null ? [] : e.hiddenDoraIndicators.map((n) =>
|
|
3632
|
-
roundWind: y.from(
|
|
3643
|
+
hiddenDoras: e.hiddenDoraIndicators == null ? [] : e.hiddenDoraIndicators.map((n) => gn(n)),
|
|
3644
|
+
roundWind: y.from(Rs(e.round)),
|
|
3633
3645
|
myWind: y.from(e.myWind),
|
|
3634
3646
|
reached: e.doubleReached ? 2 : t.reached ? 1 : 0,
|
|
3635
3647
|
sticks: e.sticks ?? { dead: 0, reach: 0 },
|
|
@@ -3658,7 +3670,7 @@ class Fn {
|
|
|
3658
3670
|
this.cfg.orig.ronWind
|
|
3659
3671
|
), o = r[i.myWind];
|
|
3660
3672
|
this.addStickPoints(r, i.myWind, this.cfg.orig.ronWind);
|
|
3661
|
-
const a =
|
|
3673
|
+
const a = Ir({
|
|
3662
3674
|
base: i.base,
|
|
3663
3675
|
fu: i.fu,
|
|
3664
3676
|
han: i.han,
|
|
@@ -3773,7 +3785,7 @@ class Fn {
|
|
|
3773
3785
|
return t === 30 && e === 4 || t === 60 && e === 3;
|
|
3774
3786
|
}
|
|
3775
3787
|
isTsumoWin(t) {
|
|
3776
|
-
return t.some((e) => e.tiles.some((n) => n.has(
|
|
3788
|
+
return t.some((e) => e.tiles.some((n) => n.has(m.TSUMO)));
|
|
3777
3789
|
}
|
|
3778
3790
|
/**
|
|
3779
3791
|
* Wind をキーとした点数移動の構成を返す
|
|
@@ -3809,7 +3821,7 @@ class Fn {
|
|
|
3809
3821
|
r == e ? t[r] += i : t[r] -= i / 3;
|
|
3810
3822
|
}
|
|
3811
3823
|
getBasePoints(t, e) {
|
|
3812
|
-
for (const { minHan: n, points: i } of
|
|
3824
|
+
for (const { minHan: n, points: i } of _r)
|
|
3813
3825
|
if (t >= n) return i;
|
|
3814
3826
|
return Math.min(e * 2 ** (t + 2), M.MANGAN);
|
|
3815
3827
|
}
|
|
@@ -3820,12 +3832,12 @@ class Fn {
|
|
|
3820
3832
|
return this.cfg.reached == 1 ? [{ name: "立直", han: 1 }] : this.cfg.reached == 2 ? [{ name: "ダブル立直", han: 2 }] : [];
|
|
3821
3833
|
}
|
|
3822
3834
|
dB1(t) {
|
|
3823
|
-
return this.hand.drawn == null, this.getCalledPenalty() != 0 ? [] : t.some((n) => n.tiles.some((i) => i.has(
|
|
3835
|
+
return this.hand.drawn == null, this.getCalledPenalty() != 0 ? [] : t.some((n) => n.tiles.some((i) => i.has(m.TSUMO))) ? [{ name: "門前清自摸和", han: 1 }] : [];
|
|
3824
3836
|
}
|
|
3825
3837
|
dC1(t) {
|
|
3826
3838
|
if (this.getCalledPenalty() != 0) return [];
|
|
3827
3839
|
const e = "平和", n = this.calcFu(t);
|
|
3828
|
-
return n == 20 ? [{ name: e, han: 1 }] : !t.some((i) => i.tiles.some((r) => r.has(
|
|
3840
|
+
return n == 20 ? [{ name: e, han: 1 }] : !t.some((i) => i.tiles.some((r) => r.has(m.TSUMO))) && n == 30 ? [{ name: e, han: 1 }] : [];
|
|
3829
3841
|
}
|
|
3830
3842
|
dD1(t) {
|
|
3831
3843
|
return t.some(
|
|
@@ -3833,7 +3845,7 @@ class Fn {
|
|
|
3833
3845
|
) ? [] : [{ name: "断么九", han: 1 }];
|
|
3834
3846
|
}
|
|
3835
3847
|
dE1(t) {
|
|
3836
|
-
return this.getCalledPenalty() != 0 ? [] :
|
|
3848
|
+
return this.getCalledPenalty() != 0 ? [] : pn(t) == 1 ? [{ name: "一盃口", han: 1 }] : [];
|
|
3837
3849
|
}
|
|
3838
3850
|
dF1(t) {
|
|
3839
3851
|
const e = [];
|
|
@@ -3865,7 +3877,7 @@ class Fn {
|
|
|
3865
3877
|
), i = e.reduce(
|
|
3866
3878
|
(a, c) => a + this.cfg.hiddenDoras.filter((l) => c.equals(l)).length,
|
|
3867
3879
|
0
|
|
3868
|
-
), r = e.filter((a) => a.has(
|
|
3880
|
+
), r = e.filter((a) => a.has(m.RED)).length, o = [];
|
|
3869
3881
|
return n > 0 && o.push({ name: "ドラ", han: n }), r > 0 && o.push({ name: "赤ドラ", han: r }), this.hand.reached && i > 0 && o.push({ name: "裏ドラ", han: i }), o;
|
|
3870
3882
|
}
|
|
3871
3883
|
dA2(t) {
|
|
@@ -3889,19 +3901,19 @@ class Fn {
|
|
|
3889
3901
|
}
|
|
3890
3902
|
dC2(t) {
|
|
3891
3903
|
return t.length == 7 ? [] : t.every(
|
|
3892
|
-
(n) => n instanceof R || n instanceof
|
|
3904
|
+
(n) => n instanceof R || n instanceof P || n instanceof z || n instanceof L || n instanceof U || n instanceof C
|
|
3893
3905
|
) ? [{ name: "対々和", han: 2 }] : [];
|
|
3894
3906
|
}
|
|
3895
3907
|
dD2(t) {
|
|
3896
|
-
return t.filter((n) => (n instanceof R || n instanceof L) && !n.tiles.some((i) => i.has(
|
|
3908
|
+
return t.filter((n) => (n instanceof R || n instanceof L) && !n.tiles.some((i) => i.has(m.RON))).length >= 3 ? [{ name: "三暗刻", han: 2 }] : [];
|
|
3897
3909
|
}
|
|
3898
3910
|
dE2(t) {
|
|
3899
3911
|
return t.filter(
|
|
3900
|
-
(n) => n instanceof R || n instanceof
|
|
3912
|
+
(n) => n instanceof R || n instanceof P || n instanceof z
|
|
3901
3913
|
).length >= 3 ? [{ name: "三槓子", han: 2 }] : [];
|
|
3902
3914
|
}
|
|
3903
3915
|
dF2(t) {
|
|
3904
|
-
const e = (n) => n instanceof R || n instanceof
|
|
3916
|
+
const e = (n) => n instanceof R || n instanceof P || n instanceof z || n instanceof L || n instanceof U;
|
|
3905
3917
|
for (const n of t) {
|
|
3906
3918
|
if (!e(n)) continue;
|
|
3907
3919
|
const i = dt(n);
|
|
@@ -3926,7 +3938,7 @@ class Fn {
|
|
|
3926
3938
|
dH2(t) {
|
|
3927
3939
|
return t.every((n) => {
|
|
3928
3940
|
const i = n.tiles[0], r = i.t == p.Z ? jt : q;
|
|
3929
|
-
return (n instanceof R || n instanceof
|
|
3941
|
+
return (n instanceof R || n instanceof P || n instanceof z || n instanceof L || n instanceof U || n instanceof C) && r.includes(i.n);
|
|
3930
3942
|
}) ? [{ name: "混老頭", han: 2 }] : [];
|
|
3931
3943
|
}
|
|
3932
3944
|
dI2(t) {
|
|
@@ -3961,7 +3973,7 @@ class Fn {
|
|
|
3961
3973
|
return t.length == 7 ? [] : t.some((n) => n instanceof gt || n instanceof V) ? t.some((n) => n.tiles[0].t == p.Z) ? [] : t.every((n) => n.tiles.some((i) => q.includes(i.n))) ? [{ name: "純全帯么九色", han: 3 - this.getCalledPenalty() }] : [] : [];
|
|
3962
3974
|
}
|
|
3963
3975
|
dC3(t) {
|
|
3964
|
-
return this.getCalledPenalty() != 0 ? [] :
|
|
3976
|
+
return this.getCalledPenalty() != 0 ? [] : pn(t) == 2 ? [{ name: "ニ盃口", han: 3 }] : [];
|
|
3965
3977
|
}
|
|
3966
3978
|
dA6(t) {
|
|
3967
3979
|
if (t.some((e) => e.tiles[0].t == p.Z)) return [];
|
|
@@ -3973,7 +3985,7 @@ class Fn {
|
|
|
3973
3985
|
}
|
|
3974
3986
|
dA13(t) {
|
|
3975
3987
|
return t.length != 13 ? [] : t.some(
|
|
3976
|
-
(n) => n instanceof C && n.tiles.some((i) => i.has(
|
|
3988
|
+
(n) => n instanceof C && n.tiles.some((i) => i.has(m.TSUMO) || i.has(m.RON))
|
|
3977
3989
|
) ? [{ name: "国士無双13面待ち", han: 26, isYakuman: !0 }] : [{ name: "国士無双", han: 13, isYakuman: !0 }];
|
|
3978
3990
|
}
|
|
3979
3991
|
dB13(t) {
|
|
@@ -3981,9 +3993,9 @@ class Fn {
|
|
|
3981
3993
|
}
|
|
3982
3994
|
dC13(t) {
|
|
3983
3995
|
return t.length == 7 ? [] : t.every(
|
|
3984
|
-
(i) => i instanceof R || i instanceof L && i.tiles.every((r) => !r.has(
|
|
3996
|
+
(i) => i instanceof R || i instanceof L && i.tiles.every((r) => !r.has(m.RON)) || i instanceof C
|
|
3985
3997
|
) ? t.some(
|
|
3986
|
-
(i) => i instanceof C && i.tiles.some((r) => r.has(
|
|
3998
|
+
(i) => i instanceof C && i.tiles.some((r) => r.has(m.TSUMO) || r.has(m.RON))
|
|
3987
3999
|
) ? [{ name: "四暗刻単騎待ち", han: 26, isYakuman: !0 }] : [{ name: "四暗刻", han: 13, isYakuman: !0 }] : [];
|
|
3988
4000
|
}
|
|
3989
4001
|
dD13(t) {
|
|
@@ -3998,12 +4010,12 @@ class Fn {
|
|
|
3998
4010
|
}
|
|
3999
4011
|
dF13(t) {
|
|
4000
4012
|
return t.every(
|
|
4001
|
-
(n) => (n instanceof R || n instanceof
|
|
4013
|
+
(n) => (n instanceof R || n instanceof P || n instanceof z || n instanceof L || n instanceof U || n instanceof C) && q.includes(n.tiles[0].n)
|
|
4002
4014
|
) ? [{ name: "清老頭", han: 13, isYakuman: !0 }] : [];
|
|
4003
4015
|
}
|
|
4004
4016
|
dG13(t) {
|
|
4005
4017
|
return t.length == 7 ? [] : t.every(
|
|
4006
|
-
(n) => n instanceof R || n instanceof
|
|
4018
|
+
(n) => n instanceof R || n instanceof P || n instanceof z || n instanceof C
|
|
4007
4019
|
) ? [{ name: "四槓子", han: 13, isYakuman: !0 }] : [];
|
|
4008
4020
|
}
|
|
4009
4021
|
dH13(t) {
|
|
@@ -4034,21 +4046,21 @@ class Fn {
|
|
|
4034
4046
|
const e = 20;
|
|
4035
4047
|
let n = e;
|
|
4036
4048
|
const i = this.cfg.myWind.n, r = this.cfg.roundWind.n, o = t.find(
|
|
4037
|
-
(f) => f.tiles.some((w) => w.has(
|
|
4038
|
-
), a = this.getCalledPenalty() == 1, c = o.tiles.some((f) => f.has(
|
|
4049
|
+
(f) => f.tiles.some((w) => w.has(m.TSUMO) || w.has(m.RON))
|
|
4050
|
+
), a = this.getCalledPenalty() == 1, c = o.tiles.some((f) => f.has(m.TSUMO)), l = (f, w) => {
|
|
4039
4051
|
const b = f.tiles[0];
|
|
4040
4052
|
return b.t == p.Z || q.includes(b.n) ? w * 2 : w;
|
|
4041
4053
|
};
|
|
4042
4054
|
for (const f of t)
|
|
4043
4055
|
switch (!0) {
|
|
4044
4056
|
case f instanceof L:
|
|
4045
|
-
const w = f.tiles.some((b) => b.has(
|
|
4057
|
+
const w = f.tiles.some((b) => b.has(m.RON)) ? 2 : 4;
|
|
4046
4058
|
n += l(f, w);
|
|
4047
4059
|
break;
|
|
4048
4060
|
case f instanceof U:
|
|
4049
4061
|
n += l(f, 2);
|
|
4050
4062
|
break;
|
|
4051
|
-
case (f instanceof z || f instanceof
|
|
4063
|
+
case (f instanceof z || f instanceof P):
|
|
4052
4064
|
n += l(f, 8);
|
|
4053
4065
|
break;
|
|
4054
4066
|
case f instanceof R:
|
|
@@ -4058,22 +4070,22 @@ class Fn {
|
|
|
4058
4070
|
n += ((f) => {
|
|
4059
4071
|
if (f instanceof L) return 0;
|
|
4060
4072
|
if (f instanceof C) return 2;
|
|
4061
|
-
const w = f.tiles, b = w.findIndex((A) => A.has(
|
|
4073
|
+
const w = f.tiles, b = w.findIndex((A) => A.has(m.TSUMO) || A.has(m.RON));
|
|
4062
4074
|
return b == 1 || b == 0 && w[2].n == 9 || b == 2 && w[0].n == 1 ? 2 : 0;
|
|
4063
4075
|
})(o);
|
|
4064
4076
|
const u = t.find((f) => f instanceof C).tiles[0];
|
|
4065
4077
|
u.t == p.Z && ([5, 6, 7].includes(u.n) && (n += 2), (u.n == r || u.n == i) && (n += 2));
|
|
4066
|
-
let
|
|
4067
|
-
return !a && n == e && (
|
|
4078
|
+
let g = !1;
|
|
4079
|
+
return !a && n == e && (g = !0), c && !g && (n += 2), !c && !a && (n += 10), !c && !a && n == 30 && (g = !0), a && n == e && (n = 30), n;
|
|
4068
4080
|
}
|
|
4069
4081
|
}
|
|
4070
|
-
const zt = (s) => s.tiles.reduce((t, e) => `${t}${e.n}${e.t}`, ""),
|
|
4082
|
+
const zt = (s) => s.tiles.reduce((t, e) => `${t}${e.n}${e.t}`, ""), pn = (s) => {
|
|
4071
4083
|
const t = s.filter((e) => e instanceof gt).reduce((e, n) => {
|
|
4072
4084
|
const i = zt(n);
|
|
4073
4085
|
return e[i] = (e[i] || 0) + 1, e;
|
|
4074
4086
|
}, {});
|
|
4075
4087
|
return Object.values(t).filter((e) => e >= 2).length;
|
|
4076
|
-
}, dt = (s) => [...s.tiles].sort(fe)[0],
|
|
4088
|
+
}, dt = (s) => [...s.tiles].sort(fe)[0], gn = (s) => {
|
|
4077
4089
|
const t = s.n, e = s.t;
|
|
4078
4090
|
if (e == p.Z) {
|
|
4079
4091
|
if (t == 4) return new y(e, 1);
|
|
@@ -4093,7 +4105,7 @@ class Ft {
|
|
|
4093
4105
|
for (const o of e) {
|
|
4094
4106
|
const a = t.dec([o]), c = Ft.getEffectiveTiles(t, n);
|
|
4095
4107
|
t.inc(a);
|
|
4096
|
-
const l = n?.arrangeRed && o.has(
|
|
4108
|
+
const l = n?.arrangeRed && o.has(m.RED) ? o.clone({ removeAll: !0 }) : o.has(m.RED) ? o.clone({ removeAll: !0, add: m.RED }) : o.clone({ removeAll: !0 });
|
|
4097
4109
|
c.shanten < r ? (i.clear(), i.set(l.toString(), {
|
|
4098
4110
|
shanten: c.shanten,
|
|
4099
4111
|
effectiveTiles: c.effectiveTiles,
|
|
@@ -4144,14 +4156,14 @@ const Re = () => {
|
|
|
4144
4156
|
}
|
|
4145
4157
|
};
|
|
4146
4158
|
};
|
|
4147
|
-
function
|
|
4148
|
-
const t = ["RON", "DAI_KAN", "PON", "CHI"], e = s.map((r) => r.choices), i =
|
|
4159
|
+
function Tr(s) {
|
|
4160
|
+
const t = ["RON", "DAI_KAN", "PON", "CHI"], e = s.map((r) => r.choices), i = Zn(e, t).map((r) => s[r]);
|
|
4149
4161
|
return {
|
|
4150
4162
|
events: i,
|
|
4151
|
-
type:
|
|
4163
|
+
type: Yn(t, i[0]?.choices)
|
|
4152
4164
|
};
|
|
4153
4165
|
}
|
|
4154
|
-
function
|
|
4166
|
+
function vr(s) {
|
|
4155
4167
|
const t = [
|
|
4156
4168
|
"TSUMO",
|
|
4157
4169
|
"REACH",
|
|
@@ -4159,34 +4171,34 @@ function Nr(s) {
|
|
|
4159
4171
|
"SHO_KAN",
|
|
4160
4172
|
"DRAWN_GAME_BY_NINE_TERMINALS",
|
|
4161
4173
|
"DISCARD"
|
|
4162
|
-
], e = s.map((r) => r.choices), i =
|
|
4174
|
+
], e = s.map((r) => r.choices), i = Zn(e, t).map((r) => s[r]);
|
|
4163
4175
|
return {
|
|
4164
4176
|
events: i,
|
|
4165
|
-
type:
|
|
4177
|
+
type: Yn(t, i[0]?.choices)
|
|
4166
4178
|
};
|
|
4167
4179
|
}
|
|
4168
|
-
function
|
|
4180
|
+
function Zn(s, t) {
|
|
4169
4181
|
let e = [], n = Number.POSITIVE_INFINITY;
|
|
4170
4182
|
for (let i = 0; i < s.length; i++) {
|
|
4171
4183
|
const r = s[i];
|
|
4172
|
-
if (
|
|
4173
|
-
const o =
|
|
4184
|
+
if (Sr(r, t)) {
|
|
4185
|
+
const o = Or(t, r);
|
|
4174
4186
|
o < n ? (n = o, e = [i]) : o === n && e.push(i);
|
|
4175
4187
|
}
|
|
4176
4188
|
}
|
|
4177
4189
|
return e;
|
|
4178
4190
|
}
|
|
4179
|
-
function
|
|
4191
|
+
function Sr(s, t) {
|
|
4180
4192
|
return t.some((e) => !!s[e]);
|
|
4181
4193
|
}
|
|
4182
|
-
function
|
|
4194
|
+
function Or(s, t) {
|
|
4183
4195
|
for (let e = 0; e < s.length; e++) {
|
|
4184
4196
|
const n = s[e];
|
|
4185
4197
|
if (t[n]) return e;
|
|
4186
4198
|
}
|
|
4187
4199
|
return Number.POSITIVE_INFINITY;
|
|
4188
4200
|
}
|
|
4189
|
-
function
|
|
4201
|
+
function Yn(s, t) {
|
|
4190
4202
|
if (t == null) return !1;
|
|
4191
4203
|
for (const e of s)
|
|
4192
4204
|
if (t[e]) return e;
|
|
@@ -4201,7 +4213,7 @@ const Jt = () => {
|
|
|
4201
4213
|
on: (i) => s.on(i)
|
|
4202
4214
|
};
|
|
4203
4215
|
return [e, n];
|
|
4204
|
-
},
|
|
4216
|
+
}, kr = () => {
|
|
4205
4217
|
const s = Re();
|
|
4206
4218
|
return {
|
|
4207
4219
|
emit: (n) => {
|
|
@@ -4282,14 +4294,14 @@ class ae {
|
|
|
4282
4294
|
return this.playerToWind;
|
|
4283
4295
|
}
|
|
4284
4296
|
}
|
|
4285
|
-
function
|
|
4297
|
+
function Vn(s) {
|
|
4286
4298
|
for (let t = s.length - 1; t > 0; t--) {
|
|
4287
4299
|
const e = Math.floor(Math.random() * (t + 1));
|
|
4288
4300
|
[s[t], s[e]] = [s[e], s[t]];
|
|
4289
4301
|
}
|
|
4290
4302
|
return s;
|
|
4291
4303
|
}
|
|
4292
|
-
class
|
|
4304
|
+
class Cr {
|
|
4293
4305
|
constructor(t = !1) {
|
|
4294
4306
|
this.disabled = t, this.c = this.initial();
|
|
4295
4307
|
}
|
|
@@ -4306,7 +4318,7 @@ class Or {
|
|
|
4306
4318
|
if (e.t != p.BACK) {
|
|
4307
4319
|
if (this.get(e) <= 0)
|
|
4308
4320
|
throw new Error(`[counter] tile ${e} appears more than 4 times`);
|
|
4309
|
-
if (this.c[e.t][e.n] -= 1, e.has(
|
|
4321
|
+
if (this.c[e.t][e.n] -= 1, e.has(m.RED)) {
|
|
4310
4322
|
if (this.c[e.t][0] <= 0)
|
|
4311
4323
|
throw new Error(`[counter] red tile ${e} appears more than once`);
|
|
4312
4324
|
this.c[e.t][0] -= 1;
|
|
@@ -4341,7 +4353,7 @@ class Or {
|
|
|
4341
4353
|
};
|
|
4342
4354
|
}
|
|
4343
4355
|
}
|
|
4344
|
-
class
|
|
4356
|
+
class Jn {
|
|
4345
4357
|
all = [];
|
|
4346
4358
|
byWind = /* @__PURE__ */ new Map();
|
|
4347
4359
|
discard(t, e) {
|
|
@@ -4372,7 +4384,7 @@ class Vn {
|
|
|
4372
4384
|
this.all = [], this.byWind.clear();
|
|
4373
4385
|
}
|
|
4374
4386
|
}
|
|
4375
|
-
function
|
|
4387
|
+
function Rr() {
|
|
4376
4388
|
if (typeof globalThis < "u")
|
|
4377
4389
|
return globalThis;
|
|
4378
4390
|
if (typeof self < "u")
|
|
@@ -4382,18 +4394,18 @@ function kr() {
|
|
|
4382
4394
|
if (typeof global < "u")
|
|
4383
4395
|
return global;
|
|
4384
4396
|
}
|
|
4385
|
-
function
|
|
4386
|
-
const s =
|
|
4397
|
+
function Mr() {
|
|
4398
|
+
const s = Rr();
|
|
4387
4399
|
if (s.__xstate__)
|
|
4388
4400
|
return s.__xstate__;
|
|
4389
4401
|
}
|
|
4390
|
-
const
|
|
4402
|
+
const xr = (s) => {
|
|
4391
4403
|
if (typeof window > "u")
|
|
4392
4404
|
return;
|
|
4393
|
-
const t =
|
|
4405
|
+
const t = Mr();
|
|
4394
4406
|
t && t.register(s);
|
|
4395
4407
|
};
|
|
4396
|
-
class
|
|
4408
|
+
class mn {
|
|
4397
4409
|
constructor(t) {
|
|
4398
4410
|
this._process = t, this._active = !1, this._current = null, this._last = null;
|
|
4399
4411
|
}
|
|
@@ -4422,8 +4434,8 @@ class gn {
|
|
|
4422
4434
|
this._last = null;
|
|
4423
4435
|
}
|
|
4424
4436
|
}
|
|
4425
|
-
const
|
|
4426
|
-
function
|
|
4437
|
+
const Xn = ".", $r = "", qn = "", Pr = "#", Hr = "*", Qn = "xstate.init", Me = "xstate.stop";
|
|
4438
|
+
function Br(s, t) {
|
|
4427
4439
|
return {
|
|
4428
4440
|
type: `xstate.after.${s}.${t}`
|
|
4429
4441
|
};
|
|
@@ -4434,23 +4446,23 @@ function xe(s, t) {
|
|
|
4434
4446
|
output: t
|
|
4435
4447
|
};
|
|
4436
4448
|
}
|
|
4437
|
-
function
|
|
4449
|
+
function Wr(s, t) {
|
|
4438
4450
|
return {
|
|
4439
4451
|
type: `xstate.done.actor.${s}`,
|
|
4440
4452
|
output: t,
|
|
4441
4453
|
actorId: s
|
|
4442
4454
|
};
|
|
4443
4455
|
}
|
|
4444
|
-
function
|
|
4456
|
+
function Dr(s, t) {
|
|
4445
4457
|
return {
|
|
4446
4458
|
type: `xstate.error.actor.${s}`,
|
|
4447
4459
|
error: t,
|
|
4448
4460
|
actorId: s
|
|
4449
4461
|
};
|
|
4450
4462
|
}
|
|
4451
|
-
function
|
|
4463
|
+
function ts(s) {
|
|
4452
4464
|
return {
|
|
4453
|
-
type:
|
|
4465
|
+
type: Qn,
|
|
4454
4466
|
input: s
|
|
4455
4467
|
};
|
|
4456
4468
|
}
|
|
@@ -4459,13 +4471,13 @@ function G(s) {
|
|
|
4459
4471
|
throw s;
|
|
4460
4472
|
});
|
|
4461
4473
|
}
|
|
4462
|
-
const
|
|
4463
|
-
function
|
|
4464
|
-
const e =
|
|
4465
|
-
return typeof n == "string" ? typeof e == "string" ? n === e : !1 : typeof e == "string" ? e in n : Object.keys(e).every((i) => i in n ?
|
|
4474
|
+
const Lr = typeof Symbol == "function" && Symbol.observable || "@@observable";
|
|
4475
|
+
function es(s, t) {
|
|
4476
|
+
const e = yn(s), n = yn(t);
|
|
4477
|
+
return typeof n == "string" ? typeof e == "string" ? n === e : !1 : typeof e == "string" ? e in n : Object.keys(e).every((i) => i in n ? es(e[i], n[i]) : !1);
|
|
4466
4478
|
}
|
|
4467
4479
|
function Fe(s) {
|
|
4468
|
-
if (
|
|
4480
|
+
if (ss(s))
|
|
4469
4481
|
return s;
|
|
4470
4482
|
const t = [];
|
|
4471
4483
|
let e = "";
|
|
@@ -4484,15 +4496,15 @@ function Fe(s) {
|
|
|
4484
4496
|
}
|
|
4485
4497
|
return t.push(e), t;
|
|
4486
4498
|
}
|
|
4487
|
-
function
|
|
4488
|
-
if (
|
|
4499
|
+
function yn(s) {
|
|
4500
|
+
if (Io(s))
|
|
4489
4501
|
return s.value;
|
|
4490
4502
|
if (typeof s != "string")
|
|
4491
4503
|
return s;
|
|
4492
4504
|
const t = Fe(s);
|
|
4493
|
-
return
|
|
4505
|
+
return Kr(t);
|
|
4494
4506
|
}
|
|
4495
|
-
function
|
|
4507
|
+
function Kr(s) {
|
|
4496
4508
|
if (s.length === 1)
|
|
4497
4509
|
return s[0];
|
|
4498
4510
|
const t = {};
|
|
@@ -4506,7 +4518,7 @@ function Dr(s) {
|
|
|
4506
4518
|
}
|
|
4507
4519
|
return t;
|
|
4508
4520
|
}
|
|
4509
|
-
function
|
|
4521
|
+
function wn(s, t) {
|
|
4510
4522
|
const e = {}, n = Object.keys(s);
|
|
4511
4523
|
for (let i = 0; i < n.length; i++) {
|
|
4512
4524
|
const r = n[i];
|
|
@@ -4514,11 +4526,11 @@ function yn(s, t) {
|
|
|
4514
4526
|
}
|
|
4515
4527
|
return e;
|
|
4516
4528
|
}
|
|
4517
|
-
function
|
|
4518
|
-
return
|
|
4529
|
+
function ns(s) {
|
|
4530
|
+
return ss(s) ? s : [s];
|
|
4519
4531
|
}
|
|
4520
4532
|
function st(s) {
|
|
4521
|
-
return s === void 0 ? [] :
|
|
4533
|
+
return s === void 0 ? [] : ns(s);
|
|
4522
4534
|
}
|
|
4523
4535
|
function $e(s, t, e, n) {
|
|
4524
4536
|
return typeof s == "function" ? s({
|
|
@@ -4527,22 +4539,22 @@ function $e(s, t, e, n) {
|
|
|
4527
4539
|
self: n
|
|
4528
4540
|
}) : s;
|
|
4529
4541
|
}
|
|
4530
|
-
function
|
|
4542
|
+
function ss(s) {
|
|
4531
4543
|
return Array.isArray(s);
|
|
4532
4544
|
}
|
|
4533
|
-
function
|
|
4545
|
+
function zr(s) {
|
|
4534
4546
|
return s.type.startsWith("xstate.error.actor");
|
|
4535
4547
|
}
|
|
4536
4548
|
function It(s) {
|
|
4537
|
-
return
|
|
4549
|
+
return ns(s).map((t) => typeof t > "u" || typeof t == "string" ? {
|
|
4538
4550
|
target: t
|
|
4539
4551
|
} : t);
|
|
4540
4552
|
}
|
|
4541
|
-
function
|
|
4542
|
-
if (!(s === void 0 || s ===
|
|
4553
|
+
function is(s) {
|
|
4554
|
+
if (!(s === void 0 || s === $r))
|
|
4543
4555
|
return st(s);
|
|
4544
4556
|
}
|
|
4545
|
-
function
|
|
4557
|
+
function Pe(s, t, e) {
|
|
4546
4558
|
const n = typeof s == "object", i = n ? s : void 0;
|
|
4547
4559
|
return {
|
|
4548
4560
|
next: (n ? s.next : s)?.bind(i),
|
|
@@ -4550,7 +4562,7 @@ function He(s, t, e) {
|
|
|
4550
4562
|
complete: (n ? s.complete : e)?.bind(i)
|
|
4551
4563
|
};
|
|
4552
4564
|
}
|
|
4553
|
-
function
|
|
4565
|
+
function En(s, t) {
|
|
4554
4566
|
return `${t}.${s}`;
|
|
4555
4567
|
}
|
|
4556
4568
|
function Ge(s, t) {
|
|
@@ -4560,8 +4572,8 @@ function Ge(s, t) {
|
|
|
4560
4572
|
const [, n, i] = e, o = s.getStateNodeById(i).config.invoke;
|
|
4561
4573
|
return (Array.isArray(o) ? o[n] : o).src;
|
|
4562
4574
|
}
|
|
4563
|
-
function
|
|
4564
|
-
if (t === s || t ===
|
|
4575
|
+
function Ur(s, t) {
|
|
4576
|
+
if (t === s || t === Hr)
|
|
4565
4577
|
return !0;
|
|
4566
4578
|
if (!t.endsWith(".*"))
|
|
4567
4579
|
return !1;
|
|
@@ -4575,83 +4587,83 @@ function Kr(s, t) {
|
|
|
4575
4587
|
}
|
|
4576
4588
|
return !0;
|
|
4577
4589
|
}
|
|
4578
|
-
function
|
|
4590
|
+
function bn(s, t) {
|
|
4579
4591
|
return `${s.sessionId}.${t}`;
|
|
4580
4592
|
}
|
|
4581
|
-
let
|
|
4582
|
-
function
|
|
4593
|
+
let jr = 0;
|
|
4594
|
+
function Fr(s, t) {
|
|
4583
4595
|
const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new Set(), o = {}, {
|
|
4584
4596
|
clock: a,
|
|
4585
4597
|
logger: c
|
|
4586
4598
|
} = t, l = {
|
|
4587
|
-
schedule: (u,
|
|
4599
|
+
schedule: (u, g, f, w, b = Math.random().toString(36).slice(2)) => {
|
|
4588
4600
|
const A = {
|
|
4589
4601
|
source: u,
|
|
4590
|
-
target:
|
|
4602
|
+
target: g,
|
|
4591
4603
|
event: f,
|
|
4592
4604
|
delay: w,
|
|
4593
4605
|
id: b,
|
|
4594
4606
|
startedAt: Date.now()
|
|
4595
|
-
}, S =
|
|
4607
|
+
}, S = bn(u, b);
|
|
4596
4608
|
h._snapshot._scheduledEvents[S] = A;
|
|
4597
4609
|
const x = a.setTimeout(() => {
|
|
4598
|
-
delete o[S], delete h._snapshot._scheduledEvents[S], h._relay(u,
|
|
4610
|
+
delete o[S], delete h._snapshot._scheduledEvents[S], h._relay(u, g, f);
|
|
4599
4611
|
}, w);
|
|
4600
4612
|
o[S] = x;
|
|
4601
4613
|
},
|
|
4602
|
-
cancel: (u,
|
|
4603
|
-
const f =
|
|
4614
|
+
cancel: (u, g) => {
|
|
4615
|
+
const f = bn(u, g), w = o[f];
|
|
4604
4616
|
delete o[f], delete h._snapshot._scheduledEvents[f], w !== void 0 && a.clearTimeout(w);
|
|
4605
4617
|
},
|
|
4606
4618
|
cancelAll: (u) => {
|
|
4607
|
-
for (const
|
|
4608
|
-
const f = h._snapshot._scheduledEvents[
|
|
4619
|
+
for (const g in h._snapshot._scheduledEvents) {
|
|
4620
|
+
const f = h._snapshot._scheduledEvents[g];
|
|
4609
4621
|
f.source === u && l.cancel(u, f.id);
|
|
4610
4622
|
}
|
|
4611
4623
|
}
|
|
4612
4624
|
}, d = (u) => {
|
|
4613
4625
|
if (!r.size)
|
|
4614
4626
|
return;
|
|
4615
|
-
const
|
|
4627
|
+
const g = {
|
|
4616
4628
|
...u,
|
|
4617
4629
|
rootId: s.sessionId
|
|
4618
4630
|
};
|
|
4619
|
-
r.forEach((f) => f.next?.(
|
|
4631
|
+
r.forEach((f) => f.next?.(g));
|
|
4620
4632
|
}, h = {
|
|
4621
4633
|
_snapshot: {
|
|
4622
4634
|
_scheduledEvents: (t?.snapshot && t.snapshot.scheduler) ?? {}
|
|
4623
4635
|
},
|
|
4624
|
-
_bookId: () => `x:${
|
|
4625
|
-
_register: (u,
|
|
4636
|
+
_bookId: () => `x:${jr++}`,
|
|
4637
|
+
_register: (u, g) => (e.set(u, g), u),
|
|
4626
4638
|
_unregister: (u) => {
|
|
4627
4639
|
e.delete(u.sessionId);
|
|
4628
|
-
const
|
|
4629
|
-
|
|
4640
|
+
const g = i.get(u);
|
|
4641
|
+
g !== void 0 && (n.delete(g), i.delete(u));
|
|
4630
4642
|
},
|
|
4631
4643
|
get: (u) => n.get(u),
|
|
4632
4644
|
getAll: () => Object.fromEntries(n.entries()),
|
|
4633
|
-
_set: (u,
|
|
4645
|
+
_set: (u, g) => {
|
|
4634
4646
|
const f = n.get(u);
|
|
4635
|
-
if (f && f !==
|
|
4647
|
+
if (f && f !== g)
|
|
4636
4648
|
throw new Error(`Actor with system ID '${u}' already exists.`);
|
|
4637
|
-
n.set(u,
|
|
4649
|
+
n.set(u, g), i.set(g, u);
|
|
4638
4650
|
},
|
|
4639
4651
|
inspect: (u) => {
|
|
4640
|
-
const
|
|
4641
|
-
return r.add(
|
|
4652
|
+
const g = Pe(u);
|
|
4653
|
+
return r.add(g), {
|
|
4642
4654
|
unsubscribe() {
|
|
4643
|
-
r.delete(
|
|
4655
|
+
r.delete(g);
|
|
4644
4656
|
}
|
|
4645
4657
|
};
|
|
4646
4658
|
},
|
|
4647
4659
|
_sendInspectionEvent: d,
|
|
4648
|
-
_relay: (u,
|
|
4660
|
+
_relay: (u, g, f) => {
|
|
4649
4661
|
h._sendInspectionEvent({
|
|
4650
4662
|
type: "@xstate.event",
|
|
4651
4663
|
sourceRef: u,
|
|
4652
|
-
actorRef:
|
|
4664
|
+
actorRef: g,
|
|
4653
4665
|
event: f
|
|
4654
|
-
}),
|
|
4666
|
+
}), g._send(f);
|
|
4655
4667
|
},
|
|
4656
4668
|
scheduler: l,
|
|
4657
4669
|
getSnapshot: () => ({
|
|
@@ -4662,14 +4674,14 @@ function Ur(s, t) {
|
|
|
4662
4674
|
start: () => {
|
|
4663
4675
|
const u = h._snapshot._scheduledEvents;
|
|
4664
4676
|
h._snapshot._scheduledEvents = {};
|
|
4665
|
-
for (const
|
|
4677
|
+
for (const g in u) {
|
|
4666
4678
|
const {
|
|
4667
4679
|
source: f,
|
|
4668
4680
|
target: w,
|
|
4669
4681
|
event: b,
|
|
4670
4682
|
delay: A,
|
|
4671
4683
|
id: S
|
|
4672
|
-
} = u[
|
|
4684
|
+
} = u[g];
|
|
4673
4685
|
l.schedule(f, w, b, A, S);
|
|
4674
4686
|
}
|
|
4675
4687
|
},
|
|
@@ -4683,7 +4695,7 @@ const Ze = 1;
|
|
|
4683
4695
|
let B = /* @__PURE__ */ (function(s) {
|
|
4684
4696
|
return s[s.NotStarted = 0] = "NotStarted", s[s.Running = 1] = "Running", s[s.Stopped = 2] = "Stopped", s;
|
|
4685
4697
|
})({});
|
|
4686
|
-
const
|
|
4698
|
+
const Gr = {
|
|
4687
4699
|
clock: {
|
|
4688
4700
|
setTimeout: (s, t) => setTimeout(s, t),
|
|
4689
4701
|
clearTimeout: (s) => clearTimeout(s)
|
|
@@ -4691,7 +4703,7 @@ const jr = {
|
|
|
4691
4703
|
logger: console.log.bind(console),
|
|
4692
4704
|
devTools: !1
|
|
4693
4705
|
};
|
|
4694
|
-
class
|
|
4706
|
+
class Zr {
|
|
4695
4707
|
/**
|
|
4696
4708
|
* Creates a new actor instance for the given logic with the provided options,
|
|
4697
4709
|
* if any.
|
|
@@ -4700,9 +4712,9 @@ class Fr {
|
|
|
4700
4712
|
* @param options Actor options
|
|
4701
4713
|
*/
|
|
4702
4714
|
constructor(t, e) {
|
|
4703
|
-
this.logic = t, this._snapshot = void 0, this.clock = void 0, this.options = void 0, this.id = void 0, this.mailbox = new
|
|
4715
|
+
this.logic = t, this._snapshot = void 0, this.clock = void 0, this.options = void 0, this.id = void 0, this.mailbox = new mn(this._process.bind(this)), this.observers = /* @__PURE__ */ new Set(), this.eventListeners = /* @__PURE__ */ new Map(), this.logger = void 0, this._processingStatus = B.NotStarted, this._parent = void 0, this._syncSnapshot = void 0, this.ref = void 0, this._actorScope = void 0, this.systemId = void 0, this.sessionId = void 0, this.system = void 0, this._doneEvent = void 0, this.src = void 0, this._deferred = [];
|
|
4704
4716
|
const n = {
|
|
4705
|
-
...
|
|
4717
|
+
...Gr,
|
|
4706
4718
|
...e
|
|
4707
4719
|
}, {
|
|
4708
4720
|
clock: i,
|
|
@@ -4713,10 +4725,10 @@ class Fr {
|
|
|
4713
4725
|
systemId: l,
|
|
4714
4726
|
inspect: d
|
|
4715
4727
|
} = n;
|
|
4716
|
-
this.system = o ? o.system :
|
|
4728
|
+
this.system = o ? o.system : Fr(this, {
|
|
4717
4729
|
clock: i,
|
|
4718
4730
|
logger: r
|
|
4719
|
-
}), d && !o && this.system.inspect(
|
|
4731
|
+
}), d && !o && this.system.inspect(Pe(d)), this.sessionId = this.system._bookId(), this.id = c ?? this.sessionId, this.logger = e?.logger ?? this.system._logger, this.clock = e?.clock ?? this.system._clock, this._parent = o, this._syncSnapshot = a, this.options = n, this.src = n.src ?? t, this.ref = this, this._actorScope = {
|
|
4720
4732
|
self: this,
|
|
4721
4733
|
id: this.id,
|
|
4722
4734
|
sessionId: this.sessionId,
|
|
@@ -4731,10 +4743,10 @@ class Fr {
|
|
|
4731
4743
|
h._stop();
|
|
4732
4744
|
},
|
|
4733
4745
|
emit: (h) => {
|
|
4734
|
-
const u = this.eventListeners.get(h.type),
|
|
4735
|
-
if (!u && !
|
|
4746
|
+
const u = this.eventListeners.get(h.type), g = this.eventListeners.get("*");
|
|
4747
|
+
if (!u && !g)
|
|
4736
4748
|
return;
|
|
4737
|
-
const f = [...u ? u.values() : [], ...
|
|
4749
|
+
const f = [...u ? u.values() : [], ...g ? g.values() : []];
|
|
4738
4750
|
for (const w of f)
|
|
4739
4751
|
try {
|
|
4740
4752
|
w(h);
|
|
@@ -4753,11 +4765,11 @@ class Fr {
|
|
|
4753
4765
|
}
|
|
4754
4766
|
}), !h.exec)
|
|
4755
4767
|
return;
|
|
4756
|
-
const
|
|
4768
|
+
const g = _e;
|
|
4757
4769
|
try {
|
|
4758
4770
|
_e = !0, h.exec(h.info, h.params);
|
|
4759
4771
|
} finally {
|
|
4760
|
-
_e =
|
|
4772
|
+
_e = g;
|
|
4761
4773
|
}
|
|
4762
4774
|
};
|
|
4763
4775
|
this._processingStatus === B.Running ? u() : this._deferred.push(u);
|
|
@@ -4807,7 +4819,7 @@ class Fr {
|
|
|
4807
4819
|
} catch (r) {
|
|
4808
4820
|
G(r);
|
|
4809
4821
|
}
|
|
4810
|
-
this._stopProcedure(), this._complete(), this._doneEvent =
|
|
4822
|
+
this._stopProcedure(), this._complete(), this._doneEvent = Wr(this.id, this._snapshot.output), this._parent && this.system._relay(this, this._parent, this._doneEvent);
|
|
4811
4823
|
break;
|
|
4812
4824
|
case "error":
|
|
4813
4825
|
this._error(this._snapshot.error);
|
|
@@ -4880,7 +4892,7 @@ class Fr {
|
|
|
4880
4892
|
* the latest snapshot
|
|
4881
4893
|
*/
|
|
4882
4894
|
subscribe(t, e, n) {
|
|
4883
|
-
const i =
|
|
4895
|
+
const i = Pe(t, e, n);
|
|
4884
4896
|
if (this._processingStatus !== B.Stopped)
|
|
4885
4897
|
this.observers.add(i);
|
|
4886
4898
|
else
|
|
@@ -4935,7 +4947,7 @@ class Fr {
|
|
|
4935
4947
|
error: () => {
|
|
4936
4948
|
}
|
|
4937
4949
|
}), this.system._register(this.sessionId, this), this.systemId && this.system._set(this.systemId, this), this._processingStatus = B.Running;
|
|
4938
|
-
const t =
|
|
4950
|
+
const t = ts(this.options.input);
|
|
4939
4951
|
switch (this.system._sendInspectionEvent({
|
|
4940
4952
|
type: "@xstate.event",
|
|
4941
4953
|
sourceRef: this._parent,
|
|
@@ -5019,7 +5031,7 @@ class Fr {
|
|
|
5019
5031
|
this.observers.clear(), this.eventListeners.clear(), e && G(t);
|
|
5020
5032
|
}
|
|
5021
5033
|
_error(t) {
|
|
5022
|
-
this._stopProcedure(), this._reportError(t), this._parent && this.system._relay(this, this._parent,
|
|
5034
|
+
this._stopProcedure(), this._reportError(t), this._parent && this.system._relay(this, this._parent, Dr(this.id, t));
|
|
5023
5035
|
}
|
|
5024
5036
|
// TODO: atm children don't belong entirely to the actor so
|
|
5025
5037
|
// in a way - it's not even super aware of them
|
|
@@ -5027,7 +5039,7 @@ class Fr {
|
|
|
5027
5039
|
// right now, they are being stopped within the machine's transition
|
|
5028
5040
|
// but that could throw and leave us with "orphaned" active actors
|
|
5029
5041
|
_stopProcedure() {
|
|
5030
|
-
return this._processingStatus !== B.Running ? this : (this.system.scheduler.cancelAll(this), this.mailbox.clear(), this.mailbox = new
|
|
5042
|
+
return this._processingStatus !== B.Running ? this : (this.system.scheduler.cancelAll(this), this.mailbox.clear(), this.mailbox = new mn(this._process.bind(this)), this._processingStatus = B.Stopped, this.system._unregister(this), this);
|
|
5031
5043
|
}
|
|
5032
5044
|
/** @internal */
|
|
5033
5045
|
_send(t) {
|
|
@@ -5045,7 +5057,7 @@ class Fr {
|
|
|
5045
5057
|
const {
|
|
5046
5058
|
devTools: t
|
|
5047
5059
|
} = this.options;
|
|
5048
|
-
t && (typeof t == "function" ? t :
|
|
5060
|
+
t && (typeof t == "function" ? t : xr)(this);
|
|
5049
5061
|
}
|
|
5050
5062
|
toJSON() {
|
|
5051
5063
|
return {
|
|
@@ -5069,7 +5081,7 @@ class Fr {
|
|
|
5069
5081
|
getPersistedSnapshot(t) {
|
|
5070
5082
|
return this.logic.getPersistedSnapshot(this._snapshot, t);
|
|
5071
5083
|
}
|
|
5072
|
-
[
|
|
5084
|
+
[Lr]() {
|
|
5073
5085
|
return this;
|
|
5074
5086
|
}
|
|
5075
5087
|
/**
|
|
@@ -5091,9 +5103,9 @@ class Fr {
|
|
|
5091
5103
|
}
|
|
5092
5104
|
}
|
|
5093
5105
|
function Mt(s, ...[t]) {
|
|
5094
|
-
return new
|
|
5106
|
+
return new Zr(s, t);
|
|
5095
5107
|
}
|
|
5096
|
-
function
|
|
5108
|
+
function Yr(s, t, e, n, {
|
|
5097
5109
|
sendId: i
|
|
5098
5110
|
}) {
|
|
5099
5111
|
const r = typeof i == "function" ? i(e, n) : i;
|
|
@@ -5101,17 +5113,17 @@ function Gr(s, t, e, n, {
|
|
|
5101
5113
|
sendId: r
|
|
5102
5114
|
}, void 0];
|
|
5103
5115
|
}
|
|
5104
|
-
function
|
|
5116
|
+
function Vr(s, t) {
|
|
5105
5117
|
s.defer(() => {
|
|
5106
5118
|
s.system.scheduler.cancel(s.self, t.sendId);
|
|
5107
5119
|
});
|
|
5108
5120
|
}
|
|
5109
|
-
function
|
|
5121
|
+
function Jr(s) {
|
|
5110
5122
|
function t(e, n) {
|
|
5111
5123
|
}
|
|
5112
|
-
return t.type = "xstate.cancel", t.sendId = s, t.resolve =
|
|
5124
|
+
return t.type = "xstate.cancel", t.sendId = s, t.resolve = Yr, t.execute = Vr, t;
|
|
5113
5125
|
}
|
|
5114
|
-
function
|
|
5126
|
+
function Xr(s, t, e, n, {
|
|
5115
5127
|
id: i,
|
|
5116
5128
|
systemId: r,
|
|
5117
5129
|
src: o,
|
|
@@ -5144,14 +5156,14 @@ function Vr(s, t, e, n, {
|
|
|
5144
5156
|
input: u
|
|
5145
5157
|
}, void 0];
|
|
5146
5158
|
}
|
|
5147
|
-
function
|
|
5159
|
+
function qr(s, {
|
|
5148
5160
|
actorRef: t
|
|
5149
5161
|
}) {
|
|
5150
5162
|
t && s.defer(() => {
|
|
5151
5163
|
t._processingStatus !== B.Stopped && t.start();
|
|
5152
5164
|
});
|
|
5153
5165
|
}
|
|
5154
|
-
function
|
|
5166
|
+
function Qr(...[s, {
|
|
5155
5167
|
id: t,
|
|
5156
5168
|
systemId: e,
|
|
5157
5169
|
input: n,
|
|
@@ -5159,9 +5171,9 @@ function Xr(...[s, {
|
|
|
5159
5171
|
} = {}]) {
|
|
5160
5172
|
function r(o, a) {
|
|
5161
5173
|
}
|
|
5162
|
-
return r.type = "xstate.spawnChild", r.id = t, r.systemId = e, r.src = s, r.input = n, r.syncSnapshot = i, r.resolve =
|
|
5174
|
+
return r.type = "xstate.spawnChild", r.id = t, r.systemId = e, r.src = s, r.input = n, r.syncSnapshot = i, r.resolve = Xr, r.execute = qr, r;
|
|
5163
5175
|
}
|
|
5164
|
-
function
|
|
5176
|
+
function to(s, t, e, n, {
|
|
5165
5177
|
actorRef: i
|
|
5166
5178
|
}) {
|
|
5167
5179
|
const r = typeof i == "function" ? i(e, n) : i, o = typeof r == "string" ? t.children[r] : r;
|
|
@@ -5172,16 +5184,16 @@ function qr(s, t, e, n, {
|
|
|
5172
5184
|
children: a
|
|
5173
5185
|
}), o, void 0];
|
|
5174
5186
|
}
|
|
5175
|
-
function
|
|
5187
|
+
function rs(s, t) {
|
|
5176
5188
|
const e = t.getSnapshot();
|
|
5177
5189
|
if (e && "children" in e)
|
|
5178
5190
|
for (const n of Object.values(e.children))
|
|
5179
|
-
|
|
5191
|
+
rs(s, n);
|
|
5180
5192
|
s.system._unregister(t);
|
|
5181
5193
|
}
|
|
5182
|
-
function
|
|
5194
|
+
function eo(s, t) {
|
|
5183
5195
|
if (t) {
|
|
5184
|
-
if (
|
|
5196
|
+
if (rs(s, t), t._processingStatus !== B.Running) {
|
|
5185
5197
|
s.stopChild(t);
|
|
5186
5198
|
return;
|
|
5187
5199
|
}
|
|
@@ -5190,10 +5202,10 @@ function Qr(s, t) {
|
|
|
5190
5202
|
});
|
|
5191
5203
|
}
|
|
5192
5204
|
}
|
|
5193
|
-
function
|
|
5205
|
+
function os(s) {
|
|
5194
5206
|
function t(e, n) {
|
|
5195
5207
|
}
|
|
5196
|
-
return t.type = "xstate.stopChild", t.actorRef = s, t.resolve =
|
|
5208
|
+
return t.type = "xstate.stopChild", t.actorRef = s, t.resolve = to, t.execute = eo, t;
|
|
5197
5209
|
}
|
|
5198
5210
|
function Ye(s, t, e, n) {
|
|
5199
5211
|
const {
|
|
@@ -5217,7 +5229,9 @@ function Ye(s, t, e, n) {
|
|
|
5217
5229
|
// this holds all params
|
|
5218
5230
|
) : o(a, c);
|
|
5219
5231
|
}
|
|
5220
|
-
|
|
5232
|
+
function Ve(s) {
|
|
5233
|
+
return s.type === "atomic" || s.type === "final";
|
|
5234
|
+
}
|
|
5221
5235
|
function xt(s) {
|
|
5222
5236
|
return Object.values(s.states).filter((t) => t.type !== "history");
|
|
5223
5237
|
}
|
|
@@ -5231,14 +5245,14 @@ function Gt(s, t) {
|
|
|
5231
5245
|
return e;
|
|
5232
5246
|
}
|
|
5233
5247
|
function ce(s) {
|
|
5234
|
-
const t = new Set(s), e =
|
|
5248
|
+
const t = new Set(s), e = cs(t);
|
|
5235
5249
|
for (const n of t)
|
|
5236
5250
|
if (n.type === "compound" && (!e.get(n) || !e.get(n).length))
|
|
5237
|
-
|
|
5251
|
+
_n(n).forEach((i) => t.add(i));
|
|
5238
5252
|
else if (n.type === "parallel") {
|
|
5239
5253
|
for (const i of xt(n))
|
|
5240
5254
|
if (i.type !== "history" && !t.has(i)) {
|
|
5241
|
-
const r =
|
|
5255
|
+
const r = _n(i);
|
|
5242
5256
|
for (const o of r)
|
|
5243
5257
|
t.add(o);
|
|
5244
5258
|
}
|
|
@@ -5250,7 +5264,7 @@ function ce(s) {
|
|
|
5250
5264
|
}
|
|
5251
5265
|
return t;
|
|
5252
5266
|
}
|
|
5253
|
-
function
|
|
5267
|
+
function as(s, t) {
|
|
5254
5268
|
const e = t.get(s);
|
|
5255
5269
|
if (!e)
|
|
5256
5270
|
return {};
|
|
@@ -5264,36 +5278,36 @@ function os(s, t) {
|
|
|
5264
5278
|
}
|
|
5265
5279
|
const n = {};
|
|
5266
5280
|
for (const i of e)
|
|
5267
|
-
n[i.key] =
|
|
5281
|
+
n[i.key] = as(i, t);
|
|
5268
5282
|
return n;
|
|
5269
5283
|
}
|
|
5270
|
-
function
|
|
5284
|
+
function cs(s) {
|
|
5271
5285
|
const t = /* @__PURE__ */ new Map();
|
|
5272
5286
|
for (const e of s)
|
|
5273
5287
|
t.has(e) || t.set(e, []), e.parent && (t.has(e.parent) || t.set(e.parent, []), t.get(e.parent).push(e));
|
|
5274
5288
|
return t;
|
|
5275
5289
|
}
|
|
5276
|
-
function
|
|
5290
|
+
function ls(s, t) {
|
|
5277
5291
|
const e = ce(t);
|
|
5278
|
-
return
|
|
5292
|
+
return as(s, cs(e));
|
|
5279
5293
|
}
|
|
5280
5294
|
function Je(s, t) {
|
|
5281
5295
|
return t.type === "compound" ? xt(t).some((e) => e.type === "final" && s.has(e)) : t.type === "parallel" ? xt(t).every((e) => Je(s, e)) : t.type === "final";
|
|
5282
5296
|
}
|
|
5283
|
-
const me = (s) => s[0] ===
|
|
5284
|
-
function
|
|
5285
|
-
return s.transitions.get(t) || [...s.transitions.keys()].filter((n) =>
|
|
5297
|
+
const me = (s) => s[0] === Pr;
|
|
5298
|
+
function no(s, t) {
|
|
5299
|
+
return s.transitions.get(t) || [...s.transitions.keys()].filter((n) => Ur(t, n)).sort((n, i) => i.length - n.length).flatMap((n) => s.transitions.get(n));
|
|
5286
5300
|
}
|
|
5287
|
-
function
|
|
5301
|
+
function so(s) {
|
|
5288
5302
|
const t = s.config.after;
|
|
5289
5303
|
if (!t)
|
|
5290
5304
|
return [];
|
|
5291
5305
|
const e = (i) => {
|
|
5292
|
-
const r =
|
|
5293
|
-
return s.entry.push(
|
|
5306
|
+
const r = Br(i, s.id), o = r.type;
|
|
5307
|
+
return s.entry.push(xo(r, {
|
|
5294
5308
|
id: o,
|
|
5295
5309
|
delay: i
|
|
5296
|
-
})), s.exit.push(
|
|
5310
|
+
})), s.exit.push(Jr(o)), o;
|
|
5297
5311
|
};
|
|
5298
5312
|
return Object.keys(t).flatMap((i) => {
|
|
5299
5313
|
const r = t[i], o = typeof r == "string" ? {
|
|
@@ -5315,7 +5329,7 @@ function eo(s) {
|
|
|
5315
5329
|
});
|
|
5316
5330
|
}
|
|
5317
5331
|
function pt(s, t, e) {
|
|
5318
|
-
const n =
|
|
5332
|
+
const n = is(e.target), i = e.reenter ?? !1, r = oo(s, n), o = {
|
|
5319
5333
|
...e,
|
|
5320
5334
|
actions: st(e.actions),
|
|
5321
5335
|
guard: e.guard,
|
|
@@ -5331,11 +5345,11 @@ function pt(s, t, e) {
|
|
|
5331
5345
|
};
|
|
5332
5346
|
return o;
|
|
5333
5347
|
}
|
|
5334
|
-
function
|
|
5348
|
+
function io(s) {
|
|
5335
5349
|
const t = /* @__PURE__ */ new Map();
|
|
5336
5350
|
if (s.config.on)
|
|
5337
5351
|
for (const e of Object.keys(s.config.on)) {
|
|
5338
|
-
if (e ===
|
|
5352
|
+
if (e === qn)
|
|
5339
5353
|
throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');
|
|
5340
5354
|
const n = s.config.on[e];
|
|
5341
5355
|
t.set(e, It(n).map((i) => pt(s, e, i)));
|
|
@@ -5364,7 +5378,7 @@ function no(s) {
|
|
|
5364
5378
|
}
|
|
5365
5379
|
return t;
|
|
5366
5380
|
}
|
|
5367
|
-
function
|
|
5381
|
+
function ro(s, t) {
|
|
5368
5382
|
const e = typeof t == "string" ? s.states[t] : t ? s.states[t.target] : void 0;
|
|
5369
5383
|
if (!e && t)
|
|
5370
5384
|
throw new Error(
|
|
@@ -5385,14 +5399,14 @@ function so(s, t) {
|
|
|
5385
5399
|
};
|
|
5386
5400
|
return n;
|
|
5387
5401
|
}
|
|
5388
|
-
function
|
|
5402
|
+
function oo(s, t) {
|
|
5389
5403
|
if (t !== void 0)
|
|
5390
5404
|
return t.map((e) => {
|
|
5391
5405
|
if (typeof e != "string")
|
|
5392
5406
|
return e;
|
|
5393
5407
|
if (me(e))
|
|
5394
5408
|
return s.machine.getStateNodeById(e);
|
|
5395
|
-
const n = e[0] ===
|
|
5409
|
+
const n = e[0] === Xn;
|
|
5396
5410
|
if (n && !s.parent)
|
|
5397
5411
|
return le(s, e.slice(1));
|
|
5398
5412
|
const i = n ? s.key + e : e;
|
|
@@ -5407,8 +5421,8 @@ ${r.message}`);
|
|
|
5407
5421
|
throw new Error(`Invalid target: "${e}" is not a valid target from the root node. Did you mean ".${e}"?`);
|
|
5408
5422
|
});
|
|
5409
5423
|
}
|
|
5410
|
-
function
|
|
5411
|
-
const t =
|
|
5424
|
+
function hs(s) {
|
|
5425
|
+
const t = is(s.config.target);
|
|
5412
5426
|
return t ? {
|
|
5413
5427
|
target: t.map((e) => typeof e == "string" ? le(s.parent, e) : e)
|
|
5414
5428
|
} : s.parent.initial;
|
|
@@ -5416,14 +5430,14 @@ function ls(s) {
|
|
|
5416
5430
|
function yt(s) {
|
|
5417
5431
|
return s.type === "history";
|
|
5418
5432
|
}
|
|
5419
|
-
function
|
|
5420
|
-
const t =
|
|
5433
|
+
function _n(s) {
|
|
5434
|
+
const t = ds(s);
|
|
5421
5435
|
for (const e of t)
|
|
5422
5436
|
for (const n of Gt(e, s))
|
|
5423
5437
|
t.add(n);
|
|
5424
5438
|
return t;
|
|
5425
5439
|
}
|
|
5426
|
-
function
|
|
5440
|
+
function ds(s) {
|
|
5427
5441
|
const t = /* @__PURE__ */ new Set();
|
|
5428
5442
|
function e(n) {
|
|
5429
5443
|
if (!t.has(n)) {
|
|
@@ -5478,15 +5492,15 @@ function he(s, t) {
|
|
|
5478
5492
|
return i.concat(a);
|
|
5479
5493
|
}, []));
|
|
5480
5494
|
}
|
|
5481
|
-
function
|
|
5495
|
+
function ao(s, t, e, n) {
|
|
5482
5496
|
const r = $t(s, t).next(e, n);
|
|
5483
5497
|
return !r || !r.length ? s.next(e, n) : r;
|
|
5484
5498
|
}
|
|
5485
|
-
function
|
|
5499
|
+
function co(s, t, e, n) {
|
|
5486
5500
|
const i = Object.keys(t), r = $t(s, i[0]), o = Xe(r, t[i[0]], e, n);
|
|
5487
5501
|
return !o || !o.length ? s.next(e, n) : o;
|
|
5488
5502
|
}
|
|
5489
|
-
function
|
|
5503
|
+
function lo(s, t, e, n) {
|
|
5490
5504
|
const i = [];
|
|
5491
5505
|
for (const r of Object.keys(t)) {
|
|
5492
5506
|
const o = t[r];
|
|
@@ -5498,9 +5512,9 @@ function ao(s, t, e, n) {
|
|
|
5498
5512
|
return i.length ? i : s.next(e, n);
|
|
5499
5513
|
}
|
|
5500
5514
|
function Xe(s, t, e, n) {
|
|
5501
|
-
return typeof t == "string" ?
|
|
5515
|
+
return typeof t == "string" ? ao(s, t, e, n) : Object.keys(t).length === 1 ? co(s, t, e, n) : lo(s, t, e, n);
|
|
5502
5516
|
}
|
|
5503
|
-
function
|
|
5517
|
+
function ho(s) {
|
|
5504
5518
|
return Object.keys(s.states).map((t) => s.states[t]).filter((t) => t.type === "history");
|
|
5505
5519
|
}
|
|
5506
5520
|
function rt(s, t) {
|
|
@@ -5509,7 +5523,7 @@ function rt(s, t) {
|
|
|
5509
5523
|
e = e.parent;
|
|
5510
5524
|
return e.parent === t;
|
|
5511
5525
|
}
|
|
5512
|
-
function
|
|
5526
|
+
function uo(s, t) {
|
|
5513
5527
|
const e = new Set(s), n = new Set(t);
|
|
5514
5528
|
for (const i of e)
|
|
5515
5529
|
if (n.has(i))
|
|
@@ -5519,13 +5533,13 @@ function lo(s, t) {
|
|
|
5519
5533
|
return !0;
|
|
5520
5534
|
return !1;
|
|
5521
5535
|
}
|
|
5522
|
-
function
|
|
5536
|
+
function us(s, t, e) {
|
|
5523
5537
|
const n = /* @__PURE__ */ new Set();
|
|
5524
5538
|
for (const i of s) {
|
|
5525
5539
|
let r = !1;
|
|
5526
5540
|
const o = /* @__PURE__ */ new Set();
|
|
5527
5541
|
for (const a of n)
|
|
5528
|
-
if (
|
|
5542
|
+
if (uo(He([i], t, e), He([a], t, e)))
|
|
5529
5543
|
if (rt(i.source, a.source))
|
|
5530
5544
|
o.add(a);
|
|
5531
5545
|
else {
|
|
@@ -5540,7 +5554,7 @@ function ds(s, t, e) {
|
|
|
5540
5554
|
}
|
|
5541
5555
|
return Array.from(n);
|
|
5542
5556
|
}
|
|
5543
|
-
function
|
|
5557
|
+
function fo(s) {
|
|
5544
5558
|
const [t, ...e] = s;
|
|
5545
5559
|
for (const n of Gt(t, void 0))
|
|
5546
5560
|
if (e.every((i) => rt(i, n)))
|
|
@@ -5556,36 +5570,36 @@ function qe(s, t) {
|
|
|
5556
5570
|
for (const i of t[n.id])
|
|
5557
5571
|
e.add(i);
|
|
5558
5572
|
else
|
|
5559
|
-
for (const i of qe(
|
|
5573
|
+
for (const i of qe(hs(n), t))
|
|
5560
5574
|
e.add(i);
|
|
5561
5575
|
else
|
|
5562
5576
|
e.add(n);
|
|
5563
5577
|
return [...e];
|
|
5564
5578
|
}
|
|
5565
|
-
function
|
|
5579
|
+
function fs(s, t) {
|
|
5566
5580
|
const e = qe(s, t);
|
|
5567
5581
|
if (!e)
|
|
5568
5582
|
return;
|
|
5569
5583
|
if (!s.reenter && e.every((i) => i === s.source || rt(i, s.source)))
|
|
5570
5584
|
return s.source;
|
|
5571
|
-
const n =
|
|
5585
|
+
const n = fo(e.concat(s.source));
|
|
5572
5586
|
if (n)
|
|
5573
5587
|
return n;
|
|
5574
5588
|
if (!s.reenter)
|
|
5575
5589
|
return s.source.machine.root;
|
|
5576
5590
|
}
|
|
5577
|
-
function
|
|
5591
|
+
function He(s, t, e) {
|
|
5578
5592
|
const n = /* @__PURE__ */ new Set();
|
|
5579
5593
|
for (const i of s)
|
|
5580
5594
|
if (i.target?.length) {
|
|
5581
|
-
const r =
|
|
5595
|
+
const r = fs(i, e);
|
|
5582
5596
|
i.reenter && i.source === r && n.add(r);
|
|
5583
5597
|
for (const o of t)
|
|
5584
5598
|
rt(o, r) && n.add(o);
|
|
5585
5599
|
}
|
|
5586
5600
|
return [...n];
|
|
5587
5601
|
}
|
|
5588
|
-
function
|
|
5602
|
+
function po(s, t) {
|
|
5589
5603
|
if (s.length !== t.size)
|
|
5590
5604
|
return !1;
|
|
5591
5605
|
for (const e of s)
|
|
@@ -5593,50 +5607,69 @@ function uo(s, t) {
|
|
|
5593
5607
|
return !1;
|
|
5594
5608
|
return !0;
|
|
5595
5609
|
}
|
|
5610
|
+
function go(s, t, e, n, i) {
|
|
5611
|
+
return Be([{
|
|
5612
|
+
target: [...ds(s)],
|
|
5613
|
+
source: s,
|
|
5614
|
+
reenter: !0,
|
|
5615
|
+
actions: [],
|
|
5616
|
+
eventType: null,
|
|
5617
|
+
toJSON: null
|
|
5618
|
+
}], t, e, n, !0, i);
|
|
5619
|
+
}
|
|
5596
5620
|
function Be(s, t, e, n, i, r) {
|
|
5621
|
+
const o = [];
|
|
5597
5622
|
if (!s.length)
|
|
5598
|
-
return t;
|
|
5599
|
-
const
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
i || ([l, a] = mo(l, n, e, c, o, a, r, e.actionExecutor)), l = Ht(l, n, e, c.flatMap((h) => h.actions), r, void 0), l = po(l, n, e, c, o, r, a, i);
|
|
5604
|
-
const d = [...o];
|
|
5605
|
-
l.status === "done" && (l = Ht(l, n, e, d.sort((h, u) => u.order - h.order).flatMap((h) => h.exit), r, void 0));
|
|
5623
|
+
return [t, o];
|
|
5624
|
+
const a = e.actionExecutor;
|
|
5625
|
+
e.actionExecutor = (c) => {
|
|
5626
|
+
o.push(c), a(c);
|
|
5627
|
+
};
|
|
5606
5628
|
try {
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5629
|
+
const c = new Set(t._nodes);
|
|
5630
|
+
let l = t.historyValue;
|
|
5631
|
+
const d = us(s, c, l);
|
|
5632
|
+
let h = t;
|
|
5633
|
+
i || ([h, l] = Eo(h, n, e, d, c, l, r, e.actionExecutor)), h = Pt(h, n, e, d.flatMap((g) => g.actions), r, void 0), h = yo(h, n, e, d, c, r, l, i);
|
|
5634
|
+
const u = [...c];
|
|
5635
|
+
h.status === "done" && (h = Pt(h, n, e, u.sort((g, f) => f.order - g.order).flatMap((g) => g.exit), r, void 0));
|
|
5636
|
+
try {
|
|
5637
|
+
return l === t.historyValue && po(t._nodes, c) ? [h, o] : [Et(h, {
|
|
5638
|
+
_nodes: u,
|
|
5639
|
+
historyValue: l
|
|
5640
|
+
}), o];
|
|
5641
|
+
} catch (g) {
|
|
5642
|
+
throw g;
|
|
5643
|
+
}
|
|
5644
|
+
} finally {
|
|
5645
|
+
e.actionExecutor = a;
|
|
5613
5646
|
}
|
|
5614
5647
|
}
|
|
5615
|
-
function
|
|
5648
|
+
function mo(s, t, e, n, i) {
|
|
5616
5649
|
if (n.output === void 0)
|
|
5617
5650
|
return;
|
|
5618
5651
|
const r = xe(i.id, i.output !== void 0 && i.parent ? $e(i.output, s.context, t, e.self) : void 0);
|
|
5619
5652
|
return $e(n.output, s.context, r, e.self);
|
|
5620
5653
|
}
|
|
5621
|
-
function
|
|
5654
|
+
function yo(s, t, e, n, i, r, o, a) {
|
|
5622
5655
|
let c = s;
|
|
5623
5656
|
const l = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set();
|
|
5624
|
-
|
|
5657
|
+
wo(n, o, d, l), a && d.add(s.machine.root);
|
|
5625
5658
|
const h = /* @__PURE__ */ new Set();
|
|
5626
|
-
for (const u of [...l].sort((
|
|
5659
|
+
for (const u of [...l].sort((g, f) => g.order - f.order)) {
|
|
5627
5660
|
i.add(u);
|
|
5628
|
-
const
|
|
5629
|
-
|
|
5661
|
+
const g = [];
|
|
5662
|
+
g.push(...u.entry);
|
|
5630
5663
|
for (const f of u.invoke)
|
|
5631
|
-
|
|
5664
|
+
g.push(Qr(f.src, {
|
|
5632
5665
|
...f,
|
|
5633
5666
|
syncSnapshot: !!f.onSnapshot
|
|
5634
5667
|
}));
|
|
5635
5668
|
if (d.has(u)) {
|
|
5636
5669
|
const f = u.initial.actions;
|
|
5637
|
-
|
|
5670
|
+
g.push(...f);
|
|
5638
5671
|
}
|
|
5639
|
-
if (c =
|
|
5672
|
+
if (c = Pt(c, t, e, g, r, u.invoke.map((f) => f.id)), u.type === "final") {
|
|
5640
5673
|
const f = u.parent;
|
|
5641
5674
|
let w = f?.type === "parallel" ? f : f?.parent, b = w || u;
|
|
5642
5675
|
for (f?.type === "compound" && r.push(xe(f.id, u.output !== void 0 ? $e(u.output, c.context, t, e.self) : void 0)); w?.type === "parallel" && !h.has(w) && Je(i, w); )
|
|
@@ -5645,15 +5678,15 @@ function po(s, t, e, n, i, r, o, a) {
|
|
|
5645
5678
|
continue;
|
|
5646
5679
|
c = Et(c, {
|
|
5647
5680
|
status: "done",
|
|
5648
|
-
output:
|
|
5681
|
+
output: mo(c, t, e, c.machine.root, b)
|
|
5649
5682
|
});
|
|
5650
5683
|
}
|
|
5651
5684
|
}
|
|
5652
5685
|
return c;
|
|
5653
5686
|
}
|
|
5654
|
-
function
|
|
5687
|
+
function wo(s, t, e, n) {
|
|
5655
5688
|
for (const i of s) {
|
|
5656
|
-
const r =
|
|
5689
|
+
const r = fs(i, t);
|
|
5657
5690
|
for (const a of i.target || [])
|
|
5658
5691
|
!yt(a) && // if the target is different than the source then it will *definitely* be entered
|
|
5659
5692
|
(i.source !== a || // we know that the domain can't lie within the source
|
|
@@ -5663,7 +5696,7 @@ function go(s, t, e, n) {
|
|
|
5663
5696
|
const o = qe(i, t);
|
|
5664
5697
|
for (const a of o) {
|
|
5665
5698
|
const c = Gt(a, r);
|
|
5666
|
-
r?.type === "parallel" && c.push(r),
|
|
5699
|
+
r?.type === "parallel" && c.push(r), ps(n, t, e, c, !i.source.parent && i.reenter ? void 0 : r);
|
|
5667
5700
|
}
|
|
5668
5701
|
}
|
|
5669
5702
|
}
|
|
@@ -5676,7 +5709,7 @@ function Nt(s, t, e, n) {
|
|
|
5676
5709
|
for (const r of i)
|
|
5677
5710
|
Ae(r, s.parent, n, t, e);
|
|
5678
5711
|
} else {
|
|
5679
|
-
const i =
|
|
5712
|
+
const i = hs(s);
|
|
5680
5713
|
for (const r of i.target)
|
|
5681
5714
|
n.add(r), i === s.parent?.initial && e.add(s.parent), Nt(r, t, e, n);
|
|
5682
5715
|
for (const r of i.target)
|
|
@@ -5689,35 +5722,35 @@ function Nt(s, t, e, n) {
|
|
|
5689
5722
|
for (const i of xt(s).filter((r) => !yt(r)))
|
|
5690
5723
|
[...n].some((r) => rt(r, i)) || (yt(i) || (n.add(i), e.add(i)), Nt(i, t, e, n));
|
|
5691
5724
|
}
|
|
5692
|
-
function
|
|
5725
|
+
function ps(s, t, e, n, i) {
|
|
5693
5726
|
for (const r of n)
|
|
5694
5727
|
if ((!i || rt(r, i)) && s.add(r), r.type === "parallel")
|
|
5695
5728
|
for (const o of xt(r).filter((a) => !yt(a)))
|
|
5696
5729
|
[...s].some((a) => rt(a, o)) || (s.add(o), Nt(o, t, e, s));
|
|
5697
5730
|
}
|
|
5698
5731
|
function Ae(s, t, e, n, i) {
|
|
5699
|
-
|
|
5732
|
+
ps(e, n, i, Gt(s, t));
|
|
5700
5733
|
}
|
|
5701
|
-
function
|
|
5734
|
+
function Eo(s, t, e, n, i, r, o, a) {
|
|
5702
5735
|
let c = s;
|
|
5703
|
-
const l =
|
|
5736
|
+
const l = He(n, i, r);
|
|
5704
5737
|
l.sort((h, u) => u.order - h.order);
|
|
5705
5738
|
let d;
|
|
5706
5739
|
for (const h of l)
|
|
5707
|
-
for (const u of
|
|
5708
|
-
let
|
|
5709
|
-
u.history === "deep" ?
|
|
5740
|
+
for (const u of ho(h)) {
|
|
5741
|
+
let g;
|
|
5742
|
+
u.history === "deep" ? g = (f) => Ve(f) && rt(f, h) : g = (f) => f.parent === h, d ??= {
|
|
5710
5743
|
...r
|
|
5711
|
-
}, d[u.id] = Array.from(i).filter(
|
|
5744
|
+
}, d[u.id] = Array.from(i).filter(g);
|
|
5712
5745
|
}
|
|
5713
5746
|
for (const h of l)
|
|
5714
|
-
c =
|
|
5747
|
+
c = Pt(c, t, e, [...h.exit, ...h.invoke.map((u) => os(u.id))], o, void 0), i.delete(h);
|
|
5715
5748
|
return [c, d || r];
|
|
5716
5749
|
}
|
|
5717
|
-
function
|
|
5750
|
+
function bo(s, t) {
|
|
5718
5751
|
return s.implementations.actions[t];
|
|
5719
5752
|
}
|
|
5720
|
-
function
|
|
5753
|
+
function gs(s, t, e, n, i, r) {
|
|
5721
5754
|
const {
|
|
5722
5755
|
machine: o
|
|
5723
5756
|
} = s;
|
|
@@ -5727,7 +5760,7 @@ function ps(s, t, e, n, i, r) {
|
|
|
5727
5760
|
// the existing type of `.actions` assumes non-nullable `TExpressionAction`
|
|
5728
5761
|
// it's fine to cast this here to get a common type and lack of errors in the rest of the code
|
|
5729
5762
|
// our logic below makes sure that we call those 2 "variants" correctly
|
|
5730
|
-
|
|
5763
|
+
bo(o, typeof c == "string" ? c : c.type)
|
|
5731
5764
|
), h = {
|
|
5732
5765
|
context: a.context,
|
|
5733
5766
|
event: t,
|
|
@@ -5746,7 +5779,7 @@ function ps(s, t, e, n, i, r) {
|
|
|
5746
5779
|
});
|
|
5747
5780
|
continue;
|
|
5748
5781
|
}
|
|
5749
|
-
const
|
|
5782
|
+
const g = d, [f, w, b] = g.resolve(
|
|
5750
5783
|
e,
|
|
5751
5784
|
a,
|
|
5752
5785
|
h,
|
|
@@ -5755,17 +5788,17 @@ function ps(s, t, e, n, i, r) {
|
|
|
5755
5788
|
// this holds all params
|
|
5756
5789
|
i
|
|
5757
5790
|
);
|
|
5758
|
-
a = f, "retryResolve" in
|
|
5759
|
-
type:
|
|
5791
|
+
a = f, "retryResolve" in g && r?.push([g, w]), "execute" in g && e.actionExecutor({
|
|
5792
|
+
type: g.type,
|
|
5760
5793
|
info: h,
|
|
5761
5794
|
params: w,
|
|
5762
|
-
exec:
|
|
5763
|
-
}), b && (a =
|
|
5795
|
+
exec: g.execute.bind(null, e, w)
|
|
5796
|
+
}), b && (a = gs(a, t, e, b, i, r));
|
|
5764
5797
|
}
|
|
5765
5798
|
return a;
|
|
5766
5799
|
}
|
|
5767
|
-
function
|
|
5768
|
-
const o = r ? [] : void 0, a =
|
|
5800
|
+
function Pt(s, t, e, n, i, r) {
|
|
5801
|
+
const o = r ? [] : void 0, a = gs(s, t, e, n, {
|
|
5769
5802
|
internalQueue: i,
|
|
5770
5803
|
deferredActorIds: r
|
|
5771
5804
|
}, o);
|
|
@@ -5781,29 +5814,29 @@ function Ie(s, t, e, n) {
|
|
|
5781
5814
|
type: "@xstate.microstep",
|
|
5782
5815
|
actorRef: e.self,
|
|
5783
5816
|
event: d,
|
|
5784
|
-
snapshot: l,
|
|
5817
|
+
snapshot: l[0],
|
|
5785
5818
|
_transitions: h
|
|
5786
5819
|
}), r.push(l);
|
|
5787
5820
|
}
|
|
5788
5821
|
if (t.type === Me)
|
|
5789
|
-
return i = Et(
|
|
5822
|
+
return i = Et(An(i, t, e), {
|
|
5790
5823
|
status: "stopped"
|
|
5791
|
-
}), o(i, t, []), {
|
|
5824
|
+
}), o([i, []], t, []), {
|
|
5792
5825
|
snapshot: i,
|
|
5793
|
-
|
|
5826
|
+
microsteps: r
|
|
5794
5827
|
};
|
|
5795
5828
|
let a = t;
|
|
5796
|
-
if (a.type !==
|
|
5797
|
-
const l = a, d =
|
|
5829
|
+
if (a.type !== Qn) {
|
|
5830
|
+
const l = a, d = zr(l), h = In(l, i);
|
|
5798
5831
|
if (d && !h.length)
|
|
5799
5832
|
return i = Et(s, {
|
|
5800
5833
|
status: "error",
|
|
5801
5834
|
error: l.error
|
|
5802
|
-
}), o(i, l, []), {
|
|
5835
|
+
}), o([i, []], l, []), {
|
|
5803
5836
|
snapshot: i,
|
|
5804
|
-
|
|
5837
|
+
microsteps: r
|
|
5805
5838
|
};
|
|
5806
|
-
|
|
5839
|
+
const u = Be(
|
|
5807
5840
|
h,
|
|
5808
5841
|
s,
|
|
5809
5842
|
e,
|
|
@@ -5811,31 +5844,33 @@ function Ie(s, t, e, n) {
|
|
|
5811
5844
|
!1,
|
|
5812
5845
|
// isInitial
|
|
5813
5846
|
n
|
|
5814
|
-
)
|
|
5847
|
+
);
|
|
5848
|
+
i = u[0], o(u, l, h);
|
|
5815
5849
|
}
|
|
5816
5850
|
let c = !0;
|
|
5817
5851
|
for (; i.status === "active"; ) {
|
|
5818
|
-
let l = c ?
|
|
5852
|
+
let l = c ? _o(i, a) : [];
|
|
5819
5853
|
const d = l.length ? i : void 0;
|
|
5820
5854
|
if (!l.length) {
|
|
5821
5855
|
if (!n.length)
|
|
5822
5856
|
break;
|
|
5823
|
-
a = n.shift(), l =
|
|
5857
|
+
a = n.shift(), l = In(a, i);
|
|
5824
5858
|
}
|
|
5825
|
-
|
|
5859
|
+
const h = Be(l, i, e, a, !1, n);
|
|
5860
|
+
i = h[0], c = i !== d, o(h, a, l);
|
|
5826
5861
|
}
|
|
5827
|
-
return i.status !== "active" &&
|
|
5862
|
+
return i.status !== "active" && An(i, a, e), {
|
|
5828
5863
|
snapshot: i,
|
|
5829
|
-
|
|
5864
|
+
microsteps: r
|
|
5830
5865
|
};
|
|
5831
5866
|
}
|
|
5832
|
-
function
|
|
5833
|
-
return
|
|
5867
|
+
function An(s, t, e) {
|
|
5868
|
+
return Pt(s, t, e, Object.values(s.children).map((n) => os(n)), [], void 0);
|
|
5834
5869
|
}
|
|
5835
|
-
function
|
|
5870
|
+
function In(s, t) {
|
|
5836
5871
|
return t.machine.getTransitionData(t, s);
|
|
5837
5872
|
}
|
|
5838
|
-
function
|
|
5873
|
+
function _o(s, t) {
|
|
5839
5874
|
const e = /* @__PURE__ */ new Set(), n = s._nodes.filter(Ve);
|
|
5840
5875
|
for (const i of n)
|
|
5841
5876
|
t: for (const r of [i].concat(Gt(i, void 0)))
|
|
@@ -5846,24 +5881,24 @@ function wo(s, t) {
|
|
|
5846
5881
|
break t;
|
|
5847
5882
|
}
|
|
5848
5883
|
}
|
|
5849
|
-
return
|
|
5884
|
+
return us(Array.from(e), new Set(s._nodes), s.historyValue);
|
|
5850
5885
|
}
|
|
5851
|
-
function
|
|
5886
|
+
function Ao(s, t) {
|
|
5852
5887
|
const e = ce(he(s, t));
|
|
5853
|
-
return
|
|
5888
|
+
return ls(s, [...e]);
|
|
5854
5889
|
}
|
|
5855
|
-
function
|
|
5890
|
+
function Io(s) {
|
|
5856
5891
|
return !!s && typeof s == "object" && "machine" in s && "value" in s;
|
|
5857
5892
|
}
|
|
5858
|
-
const
|
|
5859
|
-
return
|
|
5860
|
-
},
|
|
5893
|
+
const No = function(t) {
|
|
5894
|
+
return es(t, this.value);
|
|
5895
|
+
}, To = function(t) {
|
|
5861
5896
|
return this.tags.has(t);
|
|
5862
|
-
},
|
|
5897
|
+
}, vo = function(t) {
|
|
5863
5898
|
const e = this.machine.getTransitionData(this, t);
|
|
5864
5899
|
return !!e?.length && // Check that at least one transition is not forbidden
|
|
5865
5900
|
e.some((n) => n.target !== void 0 || n.actions.length);
|
|
5866
|
-
},
|
|
5901
|
+
}, So = function() {
|
|
5867
5902
|
const {
|
|
5868
5903
|
_nodes: t,
|
|
5869
5904
|
tags: e,
|
|
@@ -5879,7 +5914,7 @@ const _o = function(t) {
|
|
|
5879
5914
|
...l,
|
|
5880
5915
|
tags: Array.from(e)
|
|
5881
5916
|
};
|
|
5882
|
-
},
|
|
5917
|
+
}, Oo = function() {
|
|
5883
5918
|
return this._nodes.reduce((t, e) => (e.meta !== void 0 && (t[e.id] = e.meta), t), {});
|
|
5884
5919
|
};
|
|
5885
5920
|
function ee(s, t) {
|
|
@@ -5890,15 +5925,15 @@ function ee(s, t) {
|
|
|
5890
5925
|
machine: t,
|
|
5891
5926
|
context: s.context,
|
|
5892
5927
|
_nodes: s._nodes,
|
|
5893
|
-
value:
|
|
5928
|
+
value: ls(t.root, s._nodes),
|
|
5894
5929
|
tags: new Set(s._nodes.flatMap((e) => e.tags)),
|
|
5895
5930
|
children: s.children,
|
|
5896
5931
|
historyValue: s.historyValue || {},
|
|
5897
|
-
matches:
|
|
5898
|
-
hasTag:
|
|
5899
|
-
can:
|
|
5900
|
-
getMeta:
|
|
5901
|
-
toJSON:
|
|
5932
|
+
matches: No,
|
|
5933
|
+
hasTag: To,
|
|
5934
|
+
can: vo,
|
|
5935
|
+
getMeta: Oo,
|
|
5936
|
+
toJSON: So
|
|
5902
5937
|
};
|
|
5903
5938
|
}
|
|
5904
5939
|
function Et(s, t = {}) {
|
|
@@ -5907,7 +5942,7 @@ function Et(s, t = {}) {
|
|
|
5907
5942
|
...t
|
|
5908
5943
|
}, s.machine);
|
|
5909
5944
|
}
|
|
5910
|
-
function
|
|
5945
|
+
function ko(s) {
|
|
5911
5946
|
if (typeof s != "object" || s === null)
|
|
5912
5947
|
return {};
|
|
5913
5948
|
const t = {};
|
|
@@ -5919,7 +5954,7 @@ function vo(s) {
|
|
|
5919
5954
|
}
|
|
5920
5955
|
return t;
|
|
5921
5956
|
}
|
|
5922
|
-
function
|
|
5957
|
+
function Co(s, t) {
|
|
5923
5958
|
const {
|
|
5924
5959
|
_nodes: e,
|
|
5925
5960
|
tags: n,
|
|
@@ -5932,10 +5967,10 @@ function So(s, t) {
|
|
|
5932
5967
|
getMeta: d,
|
|
5933
5968
|
toJSON: h,
|
|
5934
5969
|
...u
|
|
5935
|
-
} = s,
|
|
5970
|
+
} = s, g = {};
|
|
5936
5971
|
for (const w in r) {
|
|
5937
5972
|
const b = r[w];
|
|
5938
|
-
|
|
5973
|
+
g[w] = {
|
|
5939
5974
|
snapshot: b.getPersistedSnapshot(t),
|
|
5940
5975
|
src: b.src,
|
|
5941
5976
|
systemId: b.systemId,
|
|
@@ -5944,12 +5979,12 @@ function So(s, t) {
|
|
|
5944
5979
|
}
|
|
5945
5980
|
return {
|
|
5946
5981
|
...u,
|
|
5947
|
-
context:
|
|
5948
|
-
children:
|
|
5949
|
-
historyValue:
|
|
5982
|
+
context: ms(o),
|
|
5983
|
+
children: g,
|
|
5984
|
+
historyValue: ko(u.historyValue)
|
|
5950
5985
|
};
|
|
5951
5986
|
}
|
|
5952
|
-
function
|
|
5987
|
+
function ms(s) {
|
|
5953
5988
|
let t;
|
|
5954
5989
|
for (const e in s) {
|
|
5955
5990
|
const n = s[e];
|
|
@@ -5962,7 +5997,7 @@ function gs(s) {
|
|
|
5962
5997
|
id: n.id
|
|
5963
5998
|
};
|
|
5964
5999
|
else {
|
|
5965
|
-
const i =
|
|
6000
|
+
const i = ms(n);
|
|
5966
6001
|
i !== n && (t ??= Array.isArray(s) ? s.slice() : {
|
|
5967
6002
|
...s
|
|
5968
6003
|
}, t[e] = i);
|
|
@@ -5970,7 +6005,7 @@ function gs(s) {
|
|
|
5970
6005
|
}
|
|
5971
6006
|
return t ?? s;
|
|
5972
6007
|
}
|
|
5973
|
-
function
|
|
6008
|
+
function Ro(s, t, e, n, {
|
|
5974
6009
|
event: i,
|
|
5975
6010
|
id: r,
|
|
5976
6011
|
delay: o
|
|
@@ -5996,7 +6031,7 @@ function Oo(s, t, e, n, {
|
|
|
5996
6031
|
delay: d
|
|
5997
6032
|
}, void 0];
|
|
5998
6033
|
}
|
|
5999
|
-
function
|
|
6034
|
+
function Mo(s, t) {
|
|
6000
6035
|
const {
|
|
6001
6036
|
event: e,
|
|
6002
6037
|
delay: n,
|
|
@@ -6010,12 +6045,12 @@ function ko(s, t) {
|
|
|
6010
6045
|
return;
|
|
6011
6046
|
}
|
|
6012
6047
|
}
|
|
6013
|
-
function
|
|
6048
|
+
function xo(s, t) {
|
|
6014
6049
|
function e(n, i) {
|
|
6015
6050
|
}
|
|
6016
|
-
return e.type = "xstate.raise", e.event = s, e.id = t?.id, e.delay = t?.delay, e.resolve =
|
|
6051
|
+
return e.type = "xstate.raise", e.event = s, e.id = t?.id, e.delay = t?.delay, e.resolve = Ro, e.execute = Mo, e;
|
|
6017
6052
|
}
|
|
6018
|
-
function
|
|
6053
|
+
function $o(s, {
|
|
6019
6054
|
machine: t,
|
|
6020
6055
|
context: e
|
|
6021
6056
|
}, n, i) {
|
|
@@ -6054,7 +6089,7 @@ function Ro(s, {
|
|
|
6054
6089
|
}), c;
|
|
6055
6090
|
};
|
|
6056
6091
|
}
|
|
6057
|
-
function
|
|
6092
|
+
function Po(s, t, e, n, {
|
|
6058
6093
|
assignment: i
|
|
6059
6094
|
}) {
|
|
6060
6095
|
if (!t.context)
|
|
@@ -6062,7 +6097,7 @@ function Mo(s, t, e, n, {
|
|
|
6062
6097
|
const r = {}, o = {
|
|
6063
6098
|
context: t.context,
|
|
6064
6099
|
event: e.event,
|
|
6065
|
-
spawn:
|
|
6100
|
+
spawn: $o(s, t, e.event, r),
|
|
6066
6101
|
self: s.self,
|
|
6067
6102
|
system: s.system
|
|
6068
6103
|
};
|
|
@@ -6083,19 +6118,19 @@ function Mo(s, t, e, n, {
|
|
|
6083
6118
|
} : t.children
|
|
6084
6119
|
}), void 0, void 0];
|
|
6085
6120
|
}
|
|
6086
|
-
function
|
|
6121
|
+
function Ho(s) {
|
|
6087
6122
|
function t(e, n) {
|
|
6088
6123
|
}
|
|
6089
|
-
return t.type = "xstate.assign", t.assignment = s, t.resolve =
|
|
6124
|
+
return t.type = "xstate.assign", t.assignment = s, t.resolve = Po, t;
|
|
6090
6125
|
}
|
|
6091
|
-
const
|
|
6126
|
+
const Nn = /* @__PURE__ */ new WeakMap();
|
|
6092
6127
|
function At(s, t, e) {
|
|
6093
|
-
let n =
|
|
6128
|
+
let n = Nn.get(s);
|
|
6094
6129
|
return n ? t in n || (n[t] = e()) : (n = {
|
|
6095
6130
|
[t]: e()
|
|
6096
|
-
},
|
|
6131
|
+
}, Nn.set(s, n)), n[t];
|
|
6097
6132
|
}
|
|
6098
|
-
const
|
|
6133
|
+
const Bo = {}, Lt = (s) => typeof s == "string" ? {
|
|
6099
6134
|
type: s
|
|
6100
6135
|
} : typeof s == "function" ? "resolve" in s ? {
|
|
6101
6136
|
type: s.type
|
|
@@ -6104,17 +6139,17 @@ const $o = {}, Lt = (s) => typeof s == "string" ? {
|
|
|
6104
6139
|
} : s;
|
|
6105
6140
|
class de {
|
|
6106
6141
|
constructor(t, e) {
|
|
6107
|
-
if (this.config = t, this.key = void 0, this.id = void 0, this.type = void 0, this.path = void 0, this.states = void 0, this.history = void 0, this.entry = void 0, this.exit = void 0, this.parent = void 0, this.machine = void 0, this.meta = void 0, this.output = void 0, this.order = -1, this.description = void 0, this.tags = [], this.transitions = void 0, this.always = void 0, this.parent = e._parent, this.key = e._key, this.machine = e._machine, this.path = this.parent ? this.parent.path.concat(this.key) : [], this.id = this.config.id || [this.machine.id, ...this.path].join(
|
|
6142
|
+
if (this.config = t, this.key = void 0, this.id = void 0, this.type = void 0, this.path = void 0, this.states = void 0, this.history = void 0, this.entry = void 0, this.exit = void 0, this.parent = void 0, this.machine = void 0, this.meta = void 0, this.output = void 0, this.order = -1, this.description = void 0, this.tags = [], this.transitions = void 0, this.always = void 0, this.parent = e._parent, this.key = e._key, this.machine = e._machine, this.path = this.parent ? this.parent.path.concat(this.key) : [], this.id = this.config.id || [this.machine.id, ...this.path].join(Xn), this.type = this.config.type || (this.config.states && Object.keys(this.config.states).length ? "compound" : this.config.history ? "history" : "atomic"), this.description = this.config.description, this.order = this.machine.idMap.size, this.machine.idMap.set(this.id, this), this.states = this.config.states ? wn(this.config.states, (n, i) => new de(n, {
|
|
6108
6143
|
_parent: this,
|
|
6109
6144
|
_key: i,
|
|
6110
6145
|
_machine: this.machine
|
|
6111
|
-
})) :
|
|
6146
|
+
})) : Bo, this.type === "compound" && !this.config.initial)
|
|
6112
6147
|
throw new Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);
|
|
6113
6148
|
this.history = this.config.history === !0 ? "shallow" : this.config.history || !1, this.entry = st(this.config.entry).slice(), this.exit = st(this.config.exit).slice(), this.meta = this.config.meta, this.output = this.type === "final" || !this.parent ? this.config.output : void 0, this.tags = st(t.tags).slice();
|
|
6114
6149
|
}
|
|
6115
6150
|
/** @internal */
|
|
6116
6151
|
_initialize() {
|
|
6117
|
-
this.transitions =
|
|
6152
|
+
this.transitions = io(this), this.config.always && (this.always = It(this.config.always).map((t) => pt(this, qn, t))), Object.keys(this.states).forEach((t) => {
|
|
6118
6153
|
this.states[t]._initialize();
|
|
6119
6154
|
});
|
|
6120
6155
|
}
|
|
@@ -6139,7 +6174,7 @@ class de {
|
|
|
6139
6174
|
})
|
|
6140
6175
|
} : void 0,
|
|
6141
6176
|
history: this.history,
|
|
6142
|
-
states:
|
|
6177
|
+
states: wn(this.states, (t) => t.definition),
|
|
6143
6178
|
on: this.on,
|
|
6144
6179
|
transitions: [...this.transitions.values()].flat().map((t) => ({
|
|
6145
6180
|
...t,
|
|
@@ -6165,7 +6200,7 @@ class de {
|
|
|
6165
6200
|
const {
|
|
6166
6201
|
src: n,
|
|
6167
6202
|
systemId: i
|
|
6168
|
-
} = t, r = t.id ??
|
|
6203
|
+
} = t, r = t.id ?? En(this.id, e), o = typeof n == "string" ? n : `xstate.invoke.${En(this.id, e)}`;
|
|
6169
6204
|
return {
|
|
6170
6205
|
...t,
|
|
6171
6206
|
src: o,
|
|
@@ -6192,16 +6227,16 @@ class de {
|
|
|
6192
6227
|
return At(this, "on", () => [...this.transitions].flatMap(([e, n]) => n.map((i) => [e, i])).reduce((e, [n, i]) => (e[n] = e[n] || [], e[n].push(i), e), {}));
|
|
6193
6228
|
}
|
|
6194
6229
|
get after() {
|
|
6195
|
-
return At(this, "delayedTransitions", () =>
|
|
6230
|
+
return At(this, "delayedTransitions", () => so(this));
|
|
6196
6231
|
}
|
|
6197
6232
|
get initial() {
|
|
6198
|
-
return At(this, "initial", () =>
|
|
6233
|
+
return At(this, "initial", () => ro(this, this.config.initial));
|
|
6199
6234
|
}
|
|
6200
6235
|
/** @internal */
|
|
6201
6236
|
next(t, e) {
|
|
6202
6237
|
const n = e.type, i = [];
|
|
6203
6238
|
let r;
|
|
6204
|
-
const o = At(this, `candidates-${n}`, () =>
|
|
6239
|
+
const o = At(this, `candidates-${n}`, () => no(this, n));
|
|
6205
6240
|
for (const a of o) {
|
|
6206
6241
|
const {
|
|
6207
6242
|
guard: c
|
|
@@ -6247,7 +6282,7 @@ ${h.message}`);
|
|
|
6247
6282
|
return Array.from(e);
|
|
6248
6283
|
}
|
|
6249
6284
|
}
|
|
6250
|
-
const
|
|
6285
|
+
const Wo = "#";
|
|
6251
6286
|
class Qe {
|
|
6252
6287
|
constructor(t, e) {
|
|
6253
6288
|
this.config = t, this.version = void 0, this.schemas = void 0, this.implementations = void 0, this.__xstatenode = !0, this.idMap = /* @__PURE__ */ new Map(), this.root = void 0, this.id = void 0, this.states = void 0, this.events = void 0, this.id = t.id || "(machine)", this.implementations = {
|
|
@@ -6294,7 +6329,7 @@ class Qe {
|
|
|
6294
6329
|
});
|
|
6295
6330
|
}
|
|
6296
6331
|
resolveState(t) {
|
|
6297
|
-
const e =
|
|
6332
|
+
const e = Ao(this.root, t.value), n = ce(he(this.root, e));
|
|
6298
6333
|
return ee({
|
|
6299
6334
|
_nodes: [...n],
|
|
6300
6335
|
context: t.context || {},
|
|
@@ -6323,7 +6358,7 @@ class Qe {
|
|
|
6323
6358
|
* @param event The received event
|
|
6324
6359
|
*/
|
|
6325
6360
|
microstep(t, e, n) {
|
|
6326
|
-
return Ie(t, e, n, []).
|
|
6361
|
+
return Ie(t, e, n, []).microsteps.map(([i]) => i);
|
|
6327
6362
|
}
|
|
6328
6363
|
getTransitionData(t, e) {
|
|
6329
6364
|
return Xe(this.root, t.value, t, e) || [];
|
|
@@ -6331,8 +6366,10 @@ class Qe {
|
|
|
6331
6366
|
/**
|
|
6332
6367
|
* The initial state _before_ evaluating any microsteps. This "pre-initial"
|
|
6333
6368
|
* state is provided to initial actions executed in the initial state.
|
|
6369
|
+
*
|
|
6370
|
+
* @internal
|
|
6334
6371
|
*/
|
|
6335
|
-
|
|
6372
|
+
_getPreInitialState(t, e, n) {
|
|
6336
6373
|
const {
|
|
6337
6374
|
context: i
|
|
6338
6375
|
} = this.config, r = ee({
|
|
@@ -6341,7 +6378,7 @@ class Qe {
|
|
|
6341
6378
|
children: {},
|
|
6342
6379
|
status: "active"
|
|
6343
6380
|
}, this);
|
|
6344
|
-
return typeof i == "function" ?
|
|
6381
|
+
return typeof i == "function" ? Pt(r, e, t, [Ho(({
|
|
6345
6382
|
spawn: a,
|
|
6346
6383
|
event: c,
|
|
6347
6384
|
self: l
|
|
@@ -6356,15 +6393,7 @@ class Qe {
|
|
|
6356
6393
|
* `ActorRef`.
|
|
6357
6394
|
*/
|
|
6358
6395
|
getInitialSnapshot(t, e) {
|
|
6359
|
-
const n =
|
|
6360
|
-
target: [...hs(this.root)],
|
|
6361
|
-
source: this.root,
|
|
6362
|
-
reenter: !0,
|
|
6363
|
-
actions: [],
|
|
6364
|
-
eventType: null,
|
|
6365
|
-
toJSON: null
|
|
6366
|
-
// TODO: fix
|
|
6367
|
-
}], r, t, n, !0, i), {
|
|
6396
|
+
const n = ts(e), i = [], r = this._getPreInitialState(t, n, i), [o] = go(this.root, r, t, n, i), {
|
|
6368
6397
|
snapshot: a
|
|
6369
6398
|
} = Ie(o, n, t, i);
|
|
6370
6399
|
return a;
|
|
@@ -6375,7 +6404,7 @@ class Qe {
|
|
|
6375
6404
|
});
|
|
6376
6405
|
}
|
|
6377
6406
|
getStateNodeById(t) {
|
|
6378
|
-
const e = Fe(t), n = e.slice(1), i = me(e[0]) ? e[0].slice(
|
|
6407
|
+
const e = Fe(t), n = e.slice(1), i = me(e[0]) ? e[0].slice(Wo.length) : e[0], r = this.idMap.get(i);
|
|
6379
6408
|
if (!r)
|
|
6380
6409
|
throw new Error(`Child state node '#${i}' does not exist on machine '${this.id}'`);
|
|
6381
6410
|
return le(r, n);
|
|
@@ -6387,19 +6416,19 @@ class Qe {
|
|
|
6387
6416
|
return this.definition;
|
|
6388
6417
|
}
|
|
6389
6418
|
getPersistedSnapshot(t, e) {
|
|
6390
|
-
return
|
|
6419
|
+
return Co(t, e);
|
|
6391
6420
|
}
|
|
6392
6421
|
restoreSnapshot(t, e) {
|
|
6393
6422
|
const n = {}, i = t.children;
|
|
6394
6423
|
Object.keys(i).forEach((h) => {
|
|
6395
|
-
const u = i[h],
|
|
6424
|
+
const u = i[h], g = u.snapshot, f = u.src, w = typeof f == "string" ? Ge(this, f) : f;
|
|
6396
6425
|
if (!w)
|
|
6397
6426
|
return;
|
|
6398
6427
|
const b = Mt(w, {
|
|
6399
6428
|
id: h,
|
|
6400
6429
|
parent: e.self,
|
|
6401
6430
|
syncSnapshot: u.syncSnapshot,
|
|
6402
|
-
snapshot:
|
|
6431
|
+
snapshot: g,
|
|
6403
6432
|
src: f,
|
|
6404
6433
|
systemId: u.systemId
|
|
6405
6434
|
});
|
|
@@ -6416,15 +6445,15 @@ class Qe {
|
|
|
6416
6445
|
function o(h, u) {
|
|
6417
6446
|
if (!u || typeof u != "object")
|
|
6418
6447
|
return {};
|
|
6419
|
-
const
|
|
6448
|
+
const g = {};
|
|
6420
6449
|
for (const f in u) {
|
|
6421
6450
|
const w = u[f];
|
|
6422
6451
|
for (const b of w) {
|
|
6423
6452
|
const A = r(h, b);
|
|
6424
|
-
A && (
|
|
6453
|
+
A && (g[f] ??= [], g[f].push(A));
|
|
6425
6454
|
}
|
|
6426
6455
|
}
|
|
6427
|
-
return
|
|
6456
|
+
return g;
|
|
6428
6457
|
}
|
|
6429
6458
|
const a = o(this.root, t.historyValue), c = ee({
|
|
6430
6459
|
...t,
|
|
@@ -6435,11 +6464,11 @@ class Qe {
|
|
|
6435
6464
|
function d(h, u) {
|
|
6436
6465
|
if (!l.has(h)) {
|
|
6437
6466
|
l.add(h);
|
|
6438
|
-
for (const
|
|
6439
|
-
const f = h[
|
|
6467
|
+
for (const g in h) {
|
|
6468
|
+
const f = h[g];
|
|
6440
6469
|
if (f && typeof f == "object") {
|
|
6441
6470
|
if ("xstate$$type" in f && f.xstate$$type === Ze) {
|
|
6442
|
-
h[
|
|
6471
|
+
h[g] = u[f.id];
|
|
6443
6472
|
continue;
|
|
6444
6473
|
}
|
|
6445
6474
|
d(f, u);
|
|
@@ -6450,14 +6479,14 @@ class Qe {
|
|
|
6450
6479
|
return d(c.context, n), c;
|
|
6451
6480
|
}
|
|
6452
6481
|
}
|
|
6453
|
-
function
|
|
6482
|
+
function Do(s, t) {
|
|
6454
6483
|
return new Qe(s, t);
|
|
6455
6484
|
}
|
|
6456
|
-
const Xt = (s) => s === !1 ? !1 : s.map((t) => t.serialize()),
|
|
6485
|
+
const Xt = (s) => s === !1 ? !1 : s.map((t) => t.serialize()), Lo = (s) => s === !1 ? !1 : s.serialize(), Ko = (s) => s === !1 ? !1 : s.map((t) => ({
|
|
6457
6486
|
tile: t.tile.toString(),
|
|
6458
6487
|
effectiveTiles: t.effectiveTiles.map((e) => e.toString()),
|
|
6459
6488
|
shanten: t.shanten
|
|
6460
|
-
})), qt = (s) => s === !1 ? !1 : Ce(s),
|
|
6489
|
+
})), qt = (s) => s === !1 ? !1 : Ce(s), Tn = (s) => Do(
|
|
6461
6490
|
{
|
|
6462
6491
|
id: "Untitled",
|
|
6463
6492
|
initial: "distribute",
|
|
@@ -6466,7 +6495,7 @@ const Xt = (s) => s === !1 ? !1 : s.map((t) => t.serialize()), Bo = (s) => s ===
|
|
|
6466
6495
|
oneShotMap: W(() => !1),
|
|
6467
6496
|
missingMap: W(() => !1),
|
|
6468
6497
|
controller: s,
|
|
6469
|
-
genEventID:
|
|
6498
|
+
genEventID: zo()
|
|
6470
6499
|
},
|
|
6471
6500
|
states: {
|
|
6472
6501
|
distribute: {
|
|
@@ -6814,7 +6843,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6814
6843
|
replacementWin: n?.replacementWin
|
|
6815
6844
|
})
|
|
6816
6845
|
),
|
|
6817
|
-
REACH:
|
|
6846
|
+
REACH: Ko(t.controller.doReach(i)),
|
|
6818
6847
|
AN_KAN: Xt(t.controller.doAnKan(i)),
|
|
6819
6848
|
SHO_KAN: Xt(t.controller.doShoKan(i)),
|
|
6820
6849
|
DISCARD: t.controller.doDiscard(i).map((c) => c.toString()),
|
|
@@ -6824,7 +6853,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6824
6853
|
t.controller.emit(a), t.controller.pollReplies(o, [i]);
|
|
6825
6854
|
},
|
|
6826
6855
|
notify_choice_after_discarded: ({ context: t, event: e }) => {
|
|
6827
|
-
const n = t.genEventID(), i = t.controller.river.lastTile, r = i.t.clone({ add:
|
|
6856
|
+
const n = t.genEventID(), i = t.controller.river.lastTile, r = i.t.clone({ add: m.HORIZONTAL });
|
|
6828
6857
|
for (const o of Object.values(_)) {
|
|
6829
6858
|
const a = {
|
|
6830
6859
|
id: n,
|
|
@@ -6848,7 +6877,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6848
6877
|
CHI: Xt(
|
|
6849
6878
|
t.controller.doChi(o, i.w, r)
|
|
6850
6879
|
),
|
|
6851
|
-
DAI_KAN:
|
|
6880
|
+
DAI_KAN: Lo(
|
|
6852
6881
|
t.controller.doDaiKan(o, i.w, r)
|
|
6853
6882
|
)
|
|
6854
6883
|
}
|
|
@@ -6873,7 +6902,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6873
6902
|
t.controller.emit(c), t.controller.pollReplies(i, [r]);
|
|
6874
6903
|
},
|
|
6875
6904
|
notify_choice_for_reach_acceptance: ({ context: t, event: e }) => {
|
|
6876
|
-
const n = t.genEventID(), i = t.controller.river.lastTile, r = i.t.clone({ add:
|
|
6905
|
+
const n = t.genEventID(), i = t.controller.river.lastTile, r = i.t.clone({ add: m.HORIZONTAL });
|
|
6877
6906
|
for (const o of Object.values(_)) {
|
|
6878
6907
|
const a = {
|
|
6879
6908
|
id: n,
|
|
@@ -6899,11 +6928,11 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6899
6928
|
e.type == "SHO_KAN" || e.type == "AN_KAN",
|
|
6900
6929
|
`unexpected event ${e.type}`
|
|
6901
6930
|
);
|
|
6902
|
-
const n = t.genEventID(), i = e.block.tiles[0].clone({ remove:
|
|
6931
|
+
const n = t.genEventID(), i = e.block.tiles[0].clone({ remove: m.HORIZONTAL });
|
|
6903
6932
|
for (const r of Object.values(_)) {
|
|
6904
6933
|
const o = t.controller.doWin(
|
|
6905
6934
|
r,
|
|
6906
|
-
e.block.tiles[0].clone({ remove:
|
|
6935
|
+
e.block.tiles[0].clone({ remove: m.HORIZONTAL }),
|
|
6907
6936
|
{
|
|
6908
6937
|
discardedBy: e.iam,
|
|
6909
6938
|
quadWin: !0,
|
|
@@ -6961,7 +6990,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6961
6990
|
const i = t.genEventID(), r = n?.action, o = r == "kan" ? t.controller.wall.kan() : t.controller.wall.draw(), a = t.currentWind;
|
|
6962
6991
|
t.controller.hand(a).reached || (t.missingMap[a] = !1);
|
|
6963
6992
|
for (const c of Object.values(_)) {
|
|
6964
|
-
const l = c == a ? o : new y(p.BACK, 0, [
|
|
6993
|
+
const l = c == a ? o : new y(p.BACK, 0, [m.TSUMO]), d = {
|
|
6965
6994
|
id: i,
|
|
6966
6995
|
type: "DRAW",
|
|
6967
6996
|
subType: r,
|
|
@@ -7008,7 +7037,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
7008
7037
|
},
|
|
7009
7038
|
notify_reach: ({ context: t, event: e }) => {
|
|
7010
7039
|
I(e.type == "REACH", `unexpected event ${e.type}`);
|
|
7011
|
-
const n = t.genEventID(), i = e.iam, r = e.tile.clone({ add:
|
|
7040
|
+
const n = t.genEventID(), i = e.iam, r = e.tile.clone({ add: m.HORIZONTAL });
|
|
7012
7041
|
t.oneShotMap[i] = !0;
|
|
7013
7042
|
for (const o of Object.values(_)) {
|
|
7014
7043
|
const a = {
|
|
@@ -7164,7 +7193,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
7164
7193
|
delays: {}
|
|
7165
7194
|
}
|
|
7166
7195
|
);
|
|
7167
|
-
function
|
|
7196
|
+
function zo(s = 0) {
|
|
7168
7197
|
let t = s;
|
|
7169
7198
|
return () => (t++).toString();
|
|
7170
7199
|
}
|
|
@@ -7228,10 +7257,10 @@ class Ot {
|
|
|
7228
7257
|
for (let i = 0; i < 4; i++)
|
|
7229
7258
|
for (let r of n) {
|
|
7230
7259
|
let o = new y(e, r);
|
|
7231
|
-
e != p.Z && i == 3 && r == 5 && (o = o.clone({ add:
|
|
7260
|
+
e != p.Z && i == 3 && r == 5 && (o = o.clone({ add: m.RED })), this.walls.drawable.push(o.toString());
|
|
7232
7261
|
}
|
|
7233
7262
|
}
|
|
7234
|
-
|
|
7263
|
+
Vn(this.walls.drawable);
|
|
7235
7264
|
}
|
|
7236
7265
|
for (let e = 0; e < 14; e++)
|
|
7237
7266
|
this.walls.dead.push(this.walls.drawable.pop());
|
|
@@ -7258,7 +7287,7 @@ class Ot {
|
|
|
7258
7287
|
class ye {
|
|
7259
7288
|
wall = new Ot();
|
|
7260
7289
|
playerIDs;
|
|
7261
|
-
actor = Mt(
|
|
7290
|
+
actor = Mt(Tn(this), {});
|
|
7262
7291
|
observer;
|
|
7263
7292
|
handlers = {};
|
|
7264
7293
|
// TODO 同じイベント ID は同じ特定イベントの配列になるので特定イベント ID の配列の union が良さそう
|
|
@@ -7270,14 +7299,14 @@ class ye {
|
|
|
7270
7299
|
(o) => o.handler.on((a) => this.enqueue(a))
|
|
7271
7300
|
// bind
|
|
7272
7301
|
);
|
|
7273
|
-
const n =
|
|
7274
|
-
this.observer = new
|
|
7302
|
+
const n = kr();
|
|
7303
|
+
this.observer = new jo(n), this.observer.eventHandler.on(
|
|
7275
7304
|
(o) => this.observer.handleEvent(o)
|
|
7276
7305
|
// bind
|
|
7277
7306
|
);
|
|
7278
7307
|
const i = Object.fromEntries(this.playerIDs.map((o) => [o, 25e3]));
|
|
7279
7308
|
this.observer.scoreManager = new oe(i);
|
|
7280
|
-
const r = e?.shuffle == !1 ? this.playerIDs :
|
|
7309
|
+
const r = e?.shuffle == !1 ? this.playerIDs : Vn([...this.playerIDs]);
|
|
7281
7310
|
this.observer.placeManager = new ae({
|
|
7282
7311
|
[r[0]]: _.E,
|
|
7283
7312
|
[r[1]]: _.S,
|
|
@@ -7334,7 +7363,7 @@ class ye {
|
|
|
7334
7363
|
}
|
|
7335
7364
|
const i = n[0];
|
|
7336
7365
|
if (i.type == "CHOICE_AFTER_DISCARDED") {
|
|
7337
|
-
const r =
|
|
7366
|
+
const r = Tr(
|
|
7338
7367
|
n
|
|
7339
7368
|
);
|
|
7340
7369
|
if (r.events.length == 0) {
|
|
@@ -7377,7 +7406,7 @@ class ye {
|
|
|
7377
7406
|
break;
|
|
7378
7407
|
}
|
|
7379
7408
|
} else if (i.type == "CHOICE_AFTER_DRAWN") {
|
|
7380
|
-
const r =
|
|
7409
|
+
const r = vr(n);
|
|
7381
7410
|
I(
|
|
7382
7411
|
r.events.length == 1,
|
|
7383
7412
|
`found more than one selected: ${JSON.stringify(r, null, 2)}`
|
|
@@ -7404,7 +7433,7 @@ class ye {
|
|
|
7404
7433
|
const l = o.choices[r.type];
|
|
7405
7434
|
I(l, `${r.type} choice is not available`), this.actor.send({
|
|
7406
7435
|
type: r.type,
|
|
7407
|
-
tile: y.from(l[0]).clone({ remove:
|
|
7436
|
+
tile: y.from(l[0]).clone({ remove: m.TSUMO }),
|
|
7408
7437
|
iam: a
|
|
7409
7438
|
});
|
|
7410
7439
|
break;
|
|
@@ -7421,7 +7450,7 @@ class ye {
|
|
|
7421
7450
|
const d = o.choices[r.type];
|
|
7422
7451
|
I(d, `${r.type} choice is not available`), this.actor.send({
|
|
7423
7452
|
type: r.type,
|
|
7424
|
-
block:
|
|
7453
|
+
block: P.from(d[0].tiles),
|
|
7425
7454
|
iam: a
|
|
7426
7455
|
});
|
|
7427
7456
|
break;
|
|
@@ -7520,11 +7549,11 @@ class ye {
|
|
|
7520
7549
|
);
|
|
7521
7550
|
}
|
|
7522
7551
|
startGame() {
|
|
7523
|
-
for (; console.debug(`start========${this.placeManager.round}=============`), this.start(), this.wall = new Ot(), this.observer.applied = {}, this.mailBox = {}, this.actor = Mt(
|
|
7552
|
+
for (; console.debug(`start========${this.placeManager.round}=============`), this.start(), this.wall = new Ot(), this.observer.applied = {}, this.mailBox = {}, this.actor = Mt(Tn(this)), !this.placeManager.is(k.W1); )
|
|
7524
7553
|
;
|
|
7525
7554
|
}
|
|
7526
7555
|
finalResult(t, e) {
|
|
7527
|
-
const n = this.hand(e), i = n.reached ? this.wall.hiddenDoraIndicators : void 0, r = new
|
|
7556
|
+
const n = this.hand(e), i = n.reached ? this.wall.hiddenDoraIndicators : void 0, r = new Gn(n, {
|
|
7528
7557
|
...t.boardContext,
|
|
7529
7558
|
sticks: this.placeManager.sticks,
|
|
7530
7559
|
hiddenDoraIndicators: i
|
|
@@ -7542,7 +7571,7 @@ class ye {
|
|
|
7542
7571
|
o = o.clone(), c.ronWind = n.discardedBy, c.finalDiscardWin = !this.wall.canDraw, c.quadWin = n.quadWin, o.inc([e]);
|
|
7543
7572
|
} else
|
|
7544
7573
|
c.finalWallWin = !this.wall.canDraw, c.replacementWin = n?.replacementWin;
|
|
7545
|
-
return c.oneShotWin = n?.oneShot, c.doubleReached = r.length == 0 || r.length == 1 && r[0].t.has(
|
|
7574
|
+
return c.oneShotWin = n?.oneShot, c.doubleReached = r.length == 0 || r.length == 1 && r[0].t.has(m.HORIZONTAL), et.doWin(i, c, e, r);
|
|
7546
7575
|
}
|
|
7547
7576
|
doPon(t, e, n) {
|
|
7548
7577
|
if (n == null) return !1;
|
|
@@ -7594,11 +7623,11 @@ class et {
|
|
|
7594
7623
|
static doWin(t, e, n, i) {
|
|
7595
7624
|
const r = e.ronWind != null, o = r ? t.clone() : t;
|
|
7596
7625
|
r && o.inc([n]);
|
|
7597
|
-
const a = new
|
|
7626
|
+
const a = new br(o), c = new Gn(o, e), l = a.calc(n), d = c.calc(...l);
|
|
7598
7627
|
if (!d) return !1;
|
|
7599
7628
|
if (r) {
|
|
7600
7629
|
const h = Ft.getEffectiveTiles(t).effectiveTiles;
|
|
7601
|
-
if (i.some((u) => h.some((
|
|
7630
|
+
if (i.some((u) => h.some((g) => g.equals(u.t))))
|
|
7602
7631
|
return !1;
|
|
7603
7632
|
}
|
|
7604
7633
|
return d;
|
|
@@ -7606,8 +7635,8 @@ class et {
|
|
|
7606
7635
|
static doChi(t, e, n, i) {
|
|
7607
7636
|
if (!i.isNum() || vt(n) != e || t.reached || t.hands.length < 3) return !1;
|
|
7608
7637
|
const r = i.clone({
|
|
7609
|
-
remove:
|
|
7610
|
-
add: [
|
|
7638
|
+
remove: m.TSUMO,
|
|
7639
|
+
add: [m.HORIZONTAL]
|
|
7611
7640
|
}), o = [];
|
|
7612
7641
|
r.n - 2 >= 1 && t.get(i.t, r.n - 2) > 0 && t.get(i.t, r.n - 1) > 0 && o.push(
|
|
7613
7642
|
new V([
|
|
@@ -7629,10 +7658,10 @@ class et {
|
|
|
7629
7658
|
])
|
|
7630
7659
|
);
|
|
7631
7660
|
for (let f = 0; f < o.length; f++) {
|
|
7632
|
-
const w = o[f], b =
|
|
7661
|
+
const w = o[f], b = vn(w), A = [];
|
|
7633
7662
|
for (const at of b) {
|
|
7634
7663
|
const Q = t.get(at.t, at.n);
|
|
7635
|
-
for (let tt = 0; tt < Q; tt++) A.push(at.clone({ remove:
|
|
7664
|
+
for (let tt = 0; tt < Q; tt++) A.push(at.clone({ remove: m.RED }));
|
|
7636
7665
|
}
|
|
7637
7666
|
const S = t.dec([...A, w.tiles[1], w.tiles[2]]), x = t.hands.length == 0;
|
|
7638
7667
|
t.inc(S), x && o.splice(f, 1);
|
|
@@ -7646,27 +7675,27 @@ class et {
|
|
|
7646
7675
|
(f) => !O(f.tiles[1]) && !O(f.tiles[2])
|
|
7647
7676
|
), u = t.get(i.t, 0) > 0;
|
|
7648
7677
|
if (!u) return o;
|
|
7649
|
-
const
|
|
7650
|
-
return
|
|
7678
|
+
const g = u ? Uo(d) : [];
|
|
7679
|
+
return g.length > 0 && u && t.get(i.t, 5) == 1 ? [...h, ...g] : [...o, ...g];
|
|
7651
7680
|
}
|
|
7652
7681
|
static doPon(t, e, n, i) {
|
|
7653
7682
|
if (e == n || t.reached || t.hands.length < 3 || t.get(i.t, i.n) < 2) return !1;
|
|
7654
7683
|
const r = i.clone({ removeAll: !0 }), o = rn(e, n, E.PON), a = new U([r, r, r]).clone({
|
|
7655
|
-
replace: { idx: o, tile: i.clone({ add:
|
|
7684
|
+
replace: { idx: o, tile: i.clone({ add: m.HORIZONTAL }) }
|
|
7656
7685
|
});
|
|
7657
|
-
if (O(i) && i.has(
|
|
7686
|
+
if (O(i) && i.has(m.RED))
|
|
7658
7687
|
return [a.clone({
|
|
7659
7688
|
replace: {
|
|
7660
7689
|
idx: o,
|
|
7661
7690
|
tile: r.clone({
|
|
7662
|
-
add: [
|
|
7691
|
+
add: [m.RED, m.HORIZONTAL]
|
|
7663
7692
|
})
|
|
7664
7693
|
}
|
|
7665
7694
|
})];
|
|
7666
7695
|
const c = o % 2 + 1;
|
|
7667
7696
|
if (O(i) && t.get(i.t, 0) > 0) {
|
|
7668
7697
|
const l = a.clone({
|
|
7669
|
-
replace: { idx: c, tile: r.clone({ add:
|
|
7698
|
+
replace: { idx: c, tile: r.clone({ add: m.RED }) }
|
|
7670
7699
|
});
|
|
7671
7700
|
if (t.get(r.t, 5) == 3) {
|
|
7672
7701
|
const d = a.clone({
|
|
@@ -7686,7 +7715,7 @@ class et {
|
|
|
7686
7715
|
if (e == null) return n;
|
|
7687
7716
|
if (e instanceof U)
|
|
7688
7717
|
return n.filter((o) => !o.equals(e.tiles[0]));
|
|
7689
|
-
const i =
|
|
7718
|
+
const i = vn(e), r = n.filter((o) => !i.some((a) => o.equals(a)));
|
|
7690
7719
|
return I(
|
|
7691
7720
|
r.length > 0,
|
|
7692
7721
|
`[bug] no tiles to discard. hand: ${t}, forbidden tiles: ${i}, block-chi: ${e}`
|
|
@@ -7697,28 +7726,28 @@ class et {
|
|
|
7697
7726
|
const r = i.clone({ removeAll: !0 });
|
|
7698
7727
|
if (t.get(r.t, r.n) != 3) return !1;
|
|
7699
7728
|
const o = rn(e, n, E.DAI_KAN), a = new z([r, r, r, r]).clone({
|
|
7700
|
-
replace: { idx: o, tile: r.clone({ add:
|
|
7729
|
+
replace: { idx: o, tile: r.clone({ add: m.HORIZONTAL }) }
|
|
7701
7730
|
});
|
|
7702
7731
|
let c = a;
|
|
7703
|
-
if (O(i) && i.has(
|
|
7732
|
+
if (O(i) && i.has(m.RED))
|
|
7704
7733
|
c = a.clone({
|
|
7705
7734
|
replace: {
|
|
7706
7735
|
idx: o,
|
|
7707
|
-
tile: r.clone({ add: [
|
|
7736
|
+
tile: r.clone({ add: [m.HORIZONTAL, m.RED] })
|
|
7708
7737
|
}
|
|
7709
7738
|
});
|
|
7710
|
-
else if (O(i) && !i.has(
|
|
7739
|
+
else if (O(i) && !i.has(m.RED)) {
|
|
7711
7740
|
I(
|
|
7712
7741
|
t.get(i.t, 0) > 0,
|
|
7713
7742
|
`[bug] hand does not have red tile to daikan: ${t.toString()}`
|
|
7714
7743
|
);
|
|
7715
7744
|
const l = o % 3 + 1;
|
|
7716
7745
|
c = a.clone({
|
|
7717
|
-
replace: { idx: l, tile: r.clone({ add:
|
|
7746
|
+
replace: { idx: l, tile: r.clone({ add: m.RED }) }
|
|
7718
7747
|
});
|
|
7719
7748
|
}
|
|
7720
7749
|
return I(
|
|
7721
|
-
c.tiles.filter((l) => l.has(
|
|
7750
|
+
c.tiles.filter((l) => l.has(m.HORIZONTAL)).length == 1,
|
|
7722
7751
|
`[bug] daikan has unexpected horizontal operators: ${c.toString()}`
|
|
7723
7752
|
), c;
|
|
7724
7753
|
}
|
|
@@ -7728,12 +7757,12 @@ class et {
|
|
|
7728
7757
|
for (const [n, i] of F())
|
|
7729
7758
|
if (t.get(n, i) == 4) {
|
|
7730
7759
|
const r = new y(n, i), o = [r, r, r, r];
|
|
7731
|
-
O(r) && (o[1] = r.clone({ add:
|
|
7760
|
+
O(r) && (o[1] = r.clone({ add: m.RED })), e.push(new R(o));
|
|
7732
7761
|
}
|
|
7733
7762
|
if (e.length == 0) return !1;
|
|
7734
7763
|
for (const n of e)
|
|
7735
7764
|
I(
|
|
7736
|
-
n.tiles.filter((i) => i.has(
|
|
7765
|
+
n.tiles.filter((i) => i.has(m.HORIZONTAL)).length == 0,
|
|
7737
7766
|
`[bug] ankan has horizontal op: ${n.toString()}`
|
|
7738
7767
|
);
|
|
7739
7768
|
return e;
|
|
@@ -7746,38 +7775,38 @@ class et {
|
|
|
7746
7775
|
for (const i of e) {
|
|
7747
7776
|
const r = i.tiles[0].clone({
|
|
7748
7777
|
removeAll: !0,
|
|
7749
|
-
add:
|
|
7778
|
+
add: m.HORIZONTAL
|
|
7750
7779
|
});
|
|
7751
7780
|
if (t.get(r.t, r.n) == 1) {
|
|
7752
|
-
const o = O(r) && t.get(r.t, 0) > 0 ? r.clone({ add:
|
|
7753
|
-
n.push(
|
|
7781
|
+
const o = O(r) && t.get(r.t, 0) > 0 ? r.clone({ add: m.RED }) : r;
|
|
7782
|
+
n.push(P.fromPon(i, o));
|
|
7754
7783
|
}
|
|
7755
7784
|
}
|
|
7756
7785
|
if (n.length == 0) return !1;
|
|
7757
7786
|
for (const i of n)
|
|
7758
7787
|
I(
|
|
7759
|
-
i.tiles.filter((r) => r.has(
|
|
7788
|
+
i.tiles.filter((r) => r.has(m.HORIZONTAL)).length == 2,
|
|
7760
7789
|
`[bug] shokan has unexpected horizontal operators: ${i.toString()}`
|
|
7761
7790
|
);
|
|
7762
7791
|
return n;
|
|
7763
7792
|
}
|
|
7764
7793
|
}
|
|
7765
|
-
function
|
|
7794
|
+
function Uo(s) {
|
|
7766
7795
|
return s.length == 0 ? [] : s.map((t) => {
|
|
7767
7796
|
if (O(t.tiles[1])) {
|
|
7768
|
-
const e = t.tiles[1].clone({ add:
|
|
7797
|
+
const e = t.tiles[1].clone({ add: m.RED });
|
|
7769
7798
|
return t.clone({ replace: { idx: 1, tile: e } });
|
|
7770
7799
|
} else if (O(t.tiles[2])) {
|
|
7771
|
-
const e = t.tiles[2].clone({ add:
|
|
7800
|
+
const e = t.tiles[2].clone({ add: m.RED });
|
|
7772
7801
|
return t.clone({ replace: { idx: 2, tile: e } });
|
|
7773
7802
|
}
|
|
7774
7803
|
}).filter((t) => t != null);
|
|
7775
7804
|
}
|
|
7776
|
-
function
|
|
7805
|
+
function vn(s) {
|
|
7777
7806
|
const t = s.tiles[0], e = s.tiles[1].n;
|
|
7778
7807
|
return e != 1 && t.n - 2 == e ? [new y(t.t, t.n - 3), t] : e != 8 && t.n + 1 == e ? [new y(t.t, t.n + 3), t] : [t];
|
|
7779
7808
|
}
|
|
7780
|
-
class
|
|
7809
|
+
class Ht extends je {
|
|
7781
7810
|
isBackHand() {
|
|
7782
7811
|
for (const t of Object.values(p))
|
|
7783
7812
|
if (t != p.BACK && this.sum(t) > 0)
|
|
@@ -7785,23 +7814,23 @@ class Pt extends je {
|
|
|
7785
7814
|
return this.sum(p.BACK) > 0;
|
|
7786
7815
|
}
|
|
7787
7816
|
clone() {
|
|
7788
|
-
const t = new
|
|
7817
|
+
const t = new Ht(this.toString());
|
|
7789
7818
|
return t.data.reached = this.data.reached, t;
|
|
7790
7819
|
}
|
|
7791
7820
|
dec(t) {
|
|
7792
7821
|
return this.isBackHand() ? (super.dec(t.map(() => new y(p.BACK, 0))), [...t]) : super.dec(t);
|
|
7793
7822
|
}
|
|
7794
7823
|
}
|
|
7795
|
-
class
|
|
7824
|
+
class ys {
|
|
7796
7825
|
id;
|
|
7797
|
-
river = new
|
|
7826
|
+
river = new Jn();
|
|
7798
7827
|
placeManager = new ae({});
|
|
7799
7828
|
// empty for init
|
|
7800
7829
|
scoreManager = new oe({});
|
|
7801
7830
|
// empty for init
|
|
7802
|
-
hands = W(() => new
|
|
7831
|
+
hands = W(() => new Ht(""));
|
|
7803
7832
|
// empty for init
|
|
7804
|
-
counter = new
|
|
7833
|
+
counter = new Cr();
|
|
7805
7834
|
_doraIndicators = [];
|
|
7806
7835
|
// empty for init
|
|
7807
7836
|
eventHandler;
|
|
@@ -7851,17 +7880,17 @@ class ms {
|
|
|
7851
7880
|
case "CHI":
|
|
7852
7881
|
case "DAI_KAN": {
|
|
7853
7882
|
const i = T.deserialize(t.block);
|
|
7854
|
-
this.hands[t.iam].call(i), this.river.markCalled(), t.iam != t.wind && this.counter.dec(...i.tiles.filter((r) => !r.has(
|
|
7883
|
+
this.hands[t.iam].call(i), this.river.markCalled(), t.iam != t.wind && this.counter.dec(...i.tiles.filter((r) => !r.has(m.HORIZONTAL)));
|
|
7855
7884
|
break;
|
|
7856
7885
|
}
|
|
7857
7886
|
case "SHO_KAN": {
|
|
7858
|
-
const i =
|
|
7859
|
-
this.hands[t.iam].kan(i), t.iam != t.wind && this.counter.dec(i.tiles.filter((r) => r.has(
|
|
7887
|
+
const i = P.from(t.block.tiles);
|
|
7888
|
+
this.hands[t.iam].kan(i), t.iam != t.wind && this.counter.dec(i.tiles.filter((r) => r.has(m.HORIZONTAL))[0]);
|
|
7860
7889
|
break;
|
|
7861
7890
|
}
|
|
7862
7891
|
case "AN_KAN": {
|
|
7863
7892
|
const i = R.from(t.block.tiles);
|
|
7864
|
-
this.hands[t.iam].kan(i), t.iam != t.wind && this.counter.dec(...i.tiles.filter((r) => !r.has(
|
|
7893
|
+
this.hands[t.iam].kan(i), t.iam != t.wind && this.counter.dec(...i.tiles.filter((r) => !r.has(m.HORIZONTAL)));
|
|
7865
7894
|
break;
|
|
7866
7895
|
}
|
|
7867
7896
|
case "REACH": {
|
|
@@ -7911,13 +7940,13 @@ class ms {
|
|
|
7911
7940
|
}
|
|
7912
7941
|
}
|
|
7913
7942
|
}
|
|
7914
|
-
class
|
|
7943
|
+
class jo extends ys {
|
|
7915
7944
|
applied = {};
|
|
7916
7945
|
constructor(t) {
|
|
7917
|
-
super("observer", t), this.counter.disabled = !0, this.hands = W(() => new
|
|
7946
|
+
super("observer", t), this.counter.disabled = !0, this.hands = W(() => new Ht("_____________"));
|
|
7918
7947
|
}
|
|
7919
7948
|
setHands(t) {
|
|
7920
|
-
this.hands[t.wind] = new
|
|
7949
|
+
this.hands[t.wind] = new Ht(t.hands[t.wind]);
|
|
7921
7950
|
}
|
|
7922
7951
|
handleEvent(t) {
|
|
7923
7952
|
switch (super.handleEvent(t), t.type) {
|
|
@@ -7995,8 +8024,8 @@ class Ko extends ms {
|
|
|
7995
8024
|
}
|
|
7996
8025
|
}
|
|
7997
8026
|
}
|
|
7998
|
-
class Qt extends
|
|
7999
|
-
river = new
|
|
8027
|
+
class Qt extends ys {
|
|
8028
|
+
river = new Jn();
|
|
8000
8029
|
doras = [];
|
|
8001
8030
|
constructor(t, e) {
|
|
8002
8031
|
super(t, e), this.eventHandler.on((n) => this.handleEvent(n));
|
|
@@ -8006,7 +8035,7 @@ class Qt extends ms {
|
|
|
8006
8035
|
}
|
|
8007
8036
|
setHands(t) {
|
|
8008
8037
|
for (const e of Object.values(_))
|
|
8009
|
-
this.hands[e] = new
|
|
8038
|
+
this.hands[e] = new Ht(t.hands[e]);
|
|
8010
8039
|
}
|
|
8011
8040
|
handleDiscard(t) {
|
|
8012
8041
|
const e = Object.values(_).filter((l) => l == this.myWind ? !1 : this.hand(l).reached), n = new ge(this.hand(this.myWind)).calc();
|
|
@@ -8046,7 +8075,7 @@ class Qt extends ms {
|
|
|
8046
8075
|
}
|
|
8047
8076
|
}
|
|
8048
8077
|
}
|
|
8049
|
-
class
|
|
8078
|
+
class ia {
|
|
8050
8079
|
index = 0;
|
|
8051
8080
|
histories = [];
|
|
8052
8081
|
constructor(t) {
|
|
@@ -8066,8 +8095,8 @@ class ea {
|
|
|
8066
8095
|
this.start();
|
|
8067
8096
|
}
|
|
8068
8097
|
}
|
|
8069
|
-
const
|
|
8070
|
-
const [t, e] = Jt(), [n, i] = Jt(), [r, o] = Jt(), [a, c] = Jt(), l = ["player-1", "player-2", "player-3", "player-4"], d = s?.playerInjection, h = d?.p1 ?? Qt, u = d?.p2 ?? Qt,
|
|
8098
|
+
const ra = (s) => {
|
|
8099
|
+
const [t, e] = Jt(), [n, i] = Jt(), [r, o] = Jt(), [a, c] = Jt(), l = ["player-1", "player-2", "player-3", "player-4"], d = s?.playerInjection, h = d?.p1 ?? Qt, u = d?.p2 ?? Qt, g = d?.p3 ?? Qt, f = d?.p4 ?? Qt, w = new h(l[0], e), b = new u(l[1], i), A = new g(l[2], o), S = new f(l[3], c), x = [
|
|
8071
8100
|
{ handler: t, id: l[0] },
|
|
8072
8101
|
{ handler: n, id: l[1] },
|
|
8073
8102
|
{ handler: r, id: l[2] },
|
|
@@ -8127,7 +8156,7 @@ class ue {
|
|
|
8127
8156
|
{
|
|
8128
8157
|
const o = t.get(i);
|
|
8129
8158
|
r += o * ut(i, n);
|
|
8130
|
-
const a = t.get(new y(i.t, i.n + 1)), c = t.get(new y(i.t, i.n + 2)), l = t.get(new y(i.t, i.n - 1)), d = t.get(new y(i.t, i.n - 2)), h = i.n - 2 > 0 ? Math.min(l, d) : 0, u = i.n + 2 <= 9 ? Math.min(a, c) : 0,
|
|
8159
|
+
const a = t.get(new y(i.t, i.n + 1)), c = t.get(new y(i.t, i.n + 2)), l = t.get(new y(i.t, i.n - 1)), d = t.get(new y(i.t, i.n - 2)), h = i.n - 2 > 0 ? Math.min(l, d) : 0, u = i.n + 2 <= 9 ? Math.min(a, c) : 0, g = i.n - 1 >= 1 && i.n + 1 <= 9 ? Math.min(a, l) : 0, f = Math.max(h, g), w = Math.max(g, u);
|
|
8131
8160
|
return r += o * ut(i, n), r += h * ut(new y(i.t, i.n - 2), n), r += u * ut(new y(i.t, i.n + 2), n), r += f * ut(new y(i.t, i.n - 1), n), r += w * ut(new y(i.t, i.n + 1), n), i.n == 0, r;
|
|
8132
8161
|
}
|
|
8133
8162
|
}
|
|
@@ -8172,61 +8201,61 @@ class Ut {
|
|
|
8172
8201
|
}
|
|
8173
8202
|
export {
|
|
8174
8203
|
et as ActionLogic,
|
|
8175
|
-
|
|
8204
|
+
Ht as ActorHand,
|
|
8176
8205
|
E as BLOCK,
|
|
8177
|
-
|
|
8206
|
+
ys as BaseActor,
|
|
8178
8207
|
T as Block,
|
|
8179
8208
|
R as BlockAnKan,
|
|
8180
|
-
|
|
8209
|
+
br as BlockCalculator,
|
|
8181
8210
|
V as BlockChi,
|
|
8182
8211
|
z as BlockDaiKan,
|
|
8183
8212
|
Tt as BlockHand,
|
|
8184
|
-
|
|
8213
|
+
kn as BlockIsolated,
|
|
8185
8214
|
Le as BlockOther,
|
|
8186
8215
|
C as BlockPair,
|
|
8187
8216
|
U as BlockPon,
|
|
8188
8217
|
gt as BlockRun,
|
|
8189
|
-
|
|
8218
|
+
P as BlockShoKan,
|
|
8190
8219
|
L as BlockThree,
|
|
8191
8220
|
ye as Controller,
|
|
8192
|
-
|
|
8221
|
+
Cr as Counter,
|
|
8193
8222
|
Ft as Efficiency,
|
|
8194
|
-
|
|
8223
|
+
Sn as FONT_FAMILY,
|
|
8195
8224
|
N as G,
|
|
8196
8225
|
je as Hand,
|
|
8197
8226
|
X as INPUT_SEPARATOR,
|
|
8198
|
-
|
|
8199
|
-
|
|
8227
|
+
Bn as Image,
|
|
8228
|
+
Kn as ImageHelper,
|
|
8200
8229
|
_t as Mark,
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
|
|
8205
|
-
|
|
8206
|
-
|
|
8207
|
-
|
|
8230
|
+
Go as MeasureText,
|
|
8231
|
+
Jo as MyG,
|
|
8232
|
+
Xo as MyImage,
|
|
8233
|
+
Qo as MyRect,
|
|
8234
|
+
Vo as MySVG,
|
|
8235
|
+
ta as MyText,
|
|
8236
|
+
qo as MyUse,
|
|
8208
8237
|
q as N19,
|
|
8209
8238
|
jt as NZ,
|
|
8210
|
-
|
|
8211
|
-
|
|
8239
|
+
m as OP,
|
|
8240
|
+
jo as Observer,
|
|
8212
8241
|
D as Parser,
|
|
8213
8242
|
ae as PlaceManager,
|
|
8214
8243
|
Qt as Player,
|
|
8215
8244
|
ue as PlayerEfficiency,
|
|
8216
|
-
|
|
8245
|
+
Gn as PointCalculator,
|
|
8217
8246
|
k as ROUND,
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
|
|
8247
|
+
On as ROUND_MAP,
|
|
8248
|
+
Wn as Rect,
|
|
8249
|
+
ia as Replayer,
|
|
8221
8250
|
Ut as RiskRank,
|
|
8222
|
-
|
|
8251
|
+
Jn as River,
|
|
8223
8252
|
en as STICK_CONTEXT,
|
|
8224
|
-
|
|
8253
|
+
Di as SVG,
|
|
8225
8254
|
oe as ScoreManager,
|
|
8226
8255
|
ge as ShantenCalculator,
|
|
8227
|
-
|
|
8228
|
-
|
|
8229
|
-
|
|
8256
|
+
Wi as Svg,
|
|
8257
|
+
Dn as Symbol,
|
|
8258
|
+
Is as TABLE_CONTEXT,
|
|
8230
8259
|
wt as TILE_CONTEXT,
|
|
8231
8260
|
p as TYPE,
|
|
8232
8261
|
St as Text,
|
|
@@ -8235,35 +8264,36 @@ export {
|
|
|
8235
8264
|
_ as WIND,
|
|
8236
8265
|
We as WIND_MAP,
|
|
8237
8266
|
Ot as Wall,
|
|
8238
|
-
|
|
8267
|
+
vs as compareCalledTiles,
|
|
8239
8268
|
fe as compareTiles,
|
|
8240
|
-
|
|
8269
|
+
wr as convertTableInput,
|
|
8241
8270
|
Kt as createBlockHand,
|
|
8242
|
-
|
|
8243
|
-
|
|
8271
|
+
Tn as createControllerMachine,
|
|
8272
|
+
kr as createEventEmitter,
|
|
8244
8273
|
Jt as createEventPipe,
|
|
8245
|
-
|
|
8246
|
-
|
|
8274
|
+
ra as createLocalGame,
|
|
8275
|
+
Qi as createTable,
|
|
8247
8276
|
W as createWindMap,
|
|
8248
8277
|
Vt as deserializeWinResult,
|
|
8249
|
-
|
|
8250
|
-
|
|
8278
|
+
ea as drawBlocks,
|
|
8279
|
+
sa as drawTable,
|
|
8251
8280
|
F as forHand,
|
|
8252
8281
|
rn as getCallBlockIndex,
|
|
8253
|
-
|
|
8254
|
-
|
|
8282
|
+
Ir as getPointDescription,
|
|
8283
|
+
zo as incrementalIDGenerator,
|
|
8255
8284
|
O as is5Tile,
|
|
8256
8285
|
te as nextRound,
|
|
8257
8286
|
vt as nextWind,
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8287
|
+
na as optimizeSVG,
|
|
8288
|
+
ur as parse,
|
|
8289
|
+
pr as parseRawTableInput,
|
|
8290
|
+
fr as parseYamlStringInput,
|
|
8291
|
+
Zo as prevRound,
|
|
8262
8292
|
Ke as prevWind,
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8293
|
+
Tr as prioritizeDiscardedEvents,
|
|
8294
|
+
vr as prioritizeDrawnEvents,
|
|
8295
|
+
Rs as roundWind,
|
|
8266
8296
|
Ce as serializeWinResult,
|
|
8267
|
-
|
|
8268
|
-
|
|
8297
|
+
Vn as shuffle,
|
|
8298
|
+
gn as toDora
|
|
8269
8299
|
};
|