@konoui/mjimage 0.6.0 → 0.7.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 +1 -3
- package/dist/index.d.ts +1 -3
- package/dist/index.js +706 -706
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Nn = "MS Gothic, sans-serif", gt = {
|
|
2
2
|
WIDTH: 66,
|
|
3
3
|
HEIGHT: 90,
|
|
4
4
|
TEXT_SCALE: 0.8,
|
|
@@ -6,7 +6,7 @@ const Tn = "MS Gothic, sans-serif", gt = {
|
|
|
6
6
|
}, Qe = {
|
|
7
7
|
WIDTH: 125,
|
|
8
8
|
HEIGHT: 27.5
|
|
9
|
-
}, ws = { BASE: 40 }, ut = ",",
|
|
9
|
+
}, ws = { BASE: 40 }, ut = ",", p = {
|
|
10
10
|
M: "m",
|
|
11
11
|
P: "p",
|
|
12
12
|
S: "s",
|
|
@@ -57,12 +57,12 @@ const Tn = "MS Gothic, sans-serif", gt = {
|
|
|
57
57
|
N2: "4z2",
|
|
58
58
|
N3: "4z3",
|
|
59
59
|
N4: "4z4"
|
|
60
|
-
},
|
|
60
|
+
}, Be = {
|
|
61
61
|
[_.E]: "東",
|
|
62
62
|
[_.S]: "南",
|
|
63
63
|
[_.W]: "西",
|
|
64
64
|
[_.N]: "北"
|
|
65
|
-
},
|
|
65
|
+
}, Tn = {
|
|
66
66
|
[O.E1]: "東1局",
|
|
67
67
|
[O.E2]: "東2局",
|
|
68
68
|
[O.E3]: "東3局",
|
|
@@ -111,7 +111,7 @@ class Po {
|
|
|
111
111
|
};
|
|
112
112
|
measureTableFontContext = (t) => {
|
|
113
113
|
const e = this.measureFontContext(
|
|
114
|
-
|
|
114
|
+
Nn,
|
|
115
115
|
ws.BASE * t
|
|
116
116
|
);
|
|
117
117
|
return e.textHeight = e.textWidth, e.numHeight = e.numWidth, e;
|
|
@@ -156,7 +156,7 @@ const fe = (s, t) => {
|
|
|
156
156
|
}
|
|
157
157
|
return s.n - t.n;
|
|
158
158
|
}
|
|
159
|
-
const e = [
|
|
159
|
+
const e = [p.M, p.P, p.S, p.Z, p.BACK];
|
|
160
160
|
return e.indexOf(s.t) - e.indexOf(t.t);
|
|
161
161
|
}, _s = (s, t) => {
|
|
162
162
|
const e = [
|
|
@@ -182,10 +182,10 @@ function k(s) {
|
|
|
182
182
|
return s.isNum() && s.n == 5;
|
|
183
183
|
}
|
|
184
184
|
function bs(s) {
|
|
185
|
-
for (const t of Object.values(
|
|
185
|
+
for (const t of Object.values(p))
|
|
186
186
|
if (t == s)
|
|
187
187
|
return [t, !0];
|
|
188
|
-
return [
|
|
188
|
+
return [p.BACK, !1];
|
|
189
189
|
}
|
|
190
190
|
class y {
|
|
191
191
|
constructor(t, e, n = []) {
|
|
@@ -195,7 +195,7 @@ class y {
|
|
|
195
195
|
* 一つの牌を表す文字列から牌を返す。
|
|
196
196
|
*/
|
|
197
197
|
static from(t) {
|
|
198
|
-
const e = new
|
|
198
|
+
const e = new K(t).tiles();
|
|
199
199
|
if (e.length != 1) throw new Error(`input is not a single tile ${t}`);
|
|
200
200
|
return e[0];
|
|
201
201
|
}
|
|
@@ -203,7 +203,7 @@ class y {
|
|
|
203
203
|
* 文字列の牌を返す。
|
|
204
204
|
*/
|
|
205
205
|
toString() {
|
|
206
|
-
return this.t ===
|
|
206
|
+
return this.t === p.BACK ? this.t : `${[...this.ops].sort(_s).join("")}${this.n}${this.t}`;
|
|
207
207
|
}
|
|
208
208
|
toJSON() {
|
|
209
209
|
return this.toString();
|
|
@@ -225,19 +225,20 @@ class y {
|
|
|
225
225
|
}
|
|
226
226
|
/**
|
|
227
227
|
* 数牌である場合 true を返す。
|
|
228
|
+
* false の場合、字牌もしくは裏牌のどちらかとなる。
|
|
228
229
|
*/
|
|
229
230
|
isNum() {
|
|
230
|
-
return this.t ==
|
|
231
|
+
return this.t == p.M || this.t == p.P || this.t == p.S;
|
|
231
232
|
}
|
|
232
233
|
/**
|
|
233
234
|
* 同じ牌の場合 true を返す。
|
|
234
235
|
* オペレーターの比較判定は行わない。
|
|
235
236
|
*/
|
|
236
237
|
equals(t) {
|
|
237
|
-
return t.t ==
|
|
238
|
+
return t.t == p.BACK && this.t == p.BACK ? !0 : this.t == t.t && this.n == t.n;
|
|
238
239
|
}
|
|
239
240
|
}
|
|
240
|
-
class
|
|
241
|
+
class T {
|
|
241
242
|
_tiles;
|
|
242
243
|
_type;
|
|
243
244
|
constructor(t, e) {
|
|
@@ -254,7 +255,7 @@ class I {
|
|
|
254
255
|
* 文字列からブロックを生成する。
|
|
255
256
|
*/
|
|
256
257
|
static from(t) {
|
|
257
|
-
const e = new
|
|
258
|
+
const e = new K(t).parse();
|
|
258
259
|
if (e.length != 1) throw new Error(`block must be 1: ${t}`);
|
|
259
260
|
return e[0];
|
|
260
261
|
}
|
|
@@ -262,7 +263,7 @@ class I {
|
|
|
262
263
|
* シリアライズされた情報をデシリアライズしブロックを返す。
|
|
263
264
|
*/
|
|
264
265
|
static deserialize(t) {
|
|
265
|
-
const e =
|
|
266
|
+
const e = T.from(t.tiles), n = e.type;
|
|
266
267
|
if (!(t.type == w.PAIR || t.type == w.ISOLATED || t.type == w.THREE || t.type == w.RUN) && n != t.type)
|
|
267
268
|
throw new Error(
|
|
268
269
|
`input type is ${t.type} but got is ${n}: ${t.tiles}`
|
|
@@ -326,45 +327,45 @@ class I {
|
|
|
326
327
|
const yt = (s) => {
|
|
327
328
|
let t = "";
|
|
328
329
|
for (const e of s) {
|
|
329
|
-
if (e.t ==
|
|
330
|
+
if (e.t == p.BACK) return s.join("");
|
|
330
331
|
t += e.toString().slice(0, -1);
|
|
331
332
|
}
|
|
332
333
|
return `${t}${s[0].t}`;
|
|
333
|
-
},
|
|
334
|
+
}, We = (s) => {
|
|
334
335
|
if (s.length == 0) return "";
|
|
335
336
|
let t = s[0].t, e = "";
|
|
336
337
|
for (const i of s) {
|
|
337
|
-
const r = i.t, o = r ==
|
|
338
|
-
r != t && t !=
|
|
338
|
+
const r = i.t, o = r == p.BACK ? i.toString() : i.toString().slice(0, -1);
|
|
339
|
+
r != t && t != p.BACK && (e += t), t = r, e += o;
|
|
339
340
|
}
|
|
340
341
|
const n = s.at(-1);
|
|
341
|
-
return n.t !=
|
|
342
|
+
return n.t != p.BACK && (e += n.t), e;
|
|
342
343
|
};
|
|
343
|
-
class
|
|
344
|
+
class q extends T {
|
|
344
345
|
constructor(t) {
|
|
345
346
|
super(t, w.CHI);
|
|
346
347
|
}
|
|
347
348
|
static from(t) {
|
|
348
|
-
return
|
|
349
|
+
return T.deserialize({ tiles: t, type: w.CHI });
|
|
349
350
|
}
|
|
350
351
|
toString() {
|
|
351
352
|
return yt(this.tiles);
|
|
352
353
|
}
|
|
353
354
|
}
|
|
354
|
-
class
|
|
355
|
+
class U extends T {
|
|
355
356
|
constructor(t) {
|
|
356
357
|
super(t, w.PON);
|
|
357
358
|
}
|
|
358
359
|
static from(t) {
|
|
359
|
-
return
|
|
360
|
+
return T.deserialize({ tiles: t, type: w.PON });
|
|
360
361
|
}
|
|
361
362
|
toString() {
|
|
362
363
|
return yt(this.tiles);
|
|
363
364
|
}
|
|
364
365
|
}
|
|
365
|
-
class
|
|
366
|
+
class C extends T {
|
|
366
367
|
constructor(t) {
|
|
367
|
-
const e = t.filter((i) => i.t !=
|
|
368
|
+
const e = t.filter((i) => i.t != p.BACK), n = e[0];
|
|
368
369
|
if (e.length < t.length) {
|
|
369
370
|
if (k(n)) {
|
|
370
371
|
const i = new y(n.t, 5);
|
|
@@ -387,45 +388,45 @@ class x extends I {
|
|
|
387
388
|
*/
|
|
388
389
|
get tilesWithBack() {
|
|
389
390
|
const t = this.tiles[0].clone({ remove: m.RED }), e = k(t) ? t.clone({ add: m.RED }) : t;
|
|
390
|
-
return [new y(
|
|
391
|
+
return [new y(p.BACK, 0), e, t, new y(p.BACK, 0)];
|
|
391
392
|
}
|
|
392
393
|
static from(t) {
|
|
393
|
-
return
|
|
394
|
+
return T.deserialize({ tiles: t, type: w.AN_KAN });
|
|
394
395
|
}
|
|
395
396
|
toString() {
|
|
396
|
-
return
|
|
397
|
+
return We(this.tilesWithBack);
|
|
397
398
|
}
|
|
398
399
|
}
|
|
399
|
-
class
|
|
400
|
+
class Z extends T {
|
|
400
401
|
constructor(t) {
|
|
401
402
|
super(t, w.DAI_KAN);
|
|
402
403
|
}
|
|
403
404
|
static from(t) {
|
|
404
|
-
return
|
|
405
|
+
return T.deserialize({ tiles: t, type: w.DAI_KAN });
|
|
405
406
|
}
|
|
406
407
|
toString() {
|
|
407
408
|
return yt(this.tiles);
|
|
408
409
|
}
|
|
409
410
|
}
|
|
410
|
-
class
|
|
411
|
+
class W extends T {
|
|
411
412
|
constructor(t) {
|
|
412
413
|
super(t, w.SHO_KAN);
|
|
413
414
|
}
|
|
414
415
|
static from(t) {
|
|
415
|
-
return
|
|
416
|
+
return T.deserialize({ tiles: t, type: w.SHO_KAN });
|
|
416
417
|
}
|
|
417
418
|
/**
|
|
418
419
|
* ポンしたブロックから小明槓を生成する。
|
|
419
420
|
*/
|
|
420
421
|
static fromPon(t, e) {
|
|
421
422
|
const n = t.tiles.findIndex((r) => r.has(m.HORIZONTAL)), i = [...t.tiles];
|
|
422
|
-
return i.splice(n, 0, e.clone({ add: m.HORIZONTAL })), new
|
|
423
|
+
return i.splice(n, 0, e.clone({ add: m.HORIZONTAL })), new W(i);
|
|
423
424
|
}
|
|
424
425
|
toString() {
|
|
425
426
|
return yt(this.tiles);
|
|
426
427
|
}
|
|
427
428
|
}
|
|
428
|
-
class
|
|
429
|
+
class R extends T {
|
|
429
430
|
constructor(t, e) {
|
|
430
431
|
super([t, e], w.PAIR);
|
|
431
432
|
}
|
|
@@ -433,37 +434,37 @@ class D extends I {
|
|
|
433
434
|
return yt(this.tiles);
|
|
434
435
|
}
|
|
435
436
|
static from(t) {
|
|
436
|
-
return
|
|
437
|
+
return T.deserialize({ tiles: t, type: w.PAIR });
|
|
437
438
|
}
|
|
438
439
|
}
|
|
439
|
-
class
|
|
440
|
+
class L extends T {
|
|
440
441
|
constructor(t) {
|
|
441
442
|
super(t, w.THREE);
|
|
442
443
|
}
|
|
443
444
|
static from(t) {
|
|
444
|
-
return
|
|
445
|
+
return T.deserialize({ tiles: t, type: w.THREE });
|
|
445
446
|
}
|
|
446
447
|
toString() {
|
|
447
448
|
return yt(this.tiles);
|
|
448
449
|
}
|
|
449
450
|
}
|
|
450
|
-
class dt extends
|
|
451
|
+
class dt extends T {
|
|
451
452
|
constructor(t) {
|
|
452
453
|
super(t, w.RUN);
|
|
453
454
|
}
|
|
454
455
|
static from(t) {
|
|
455
|
-
return
|
|
456
|
+
return T.deserialize({ tiles: t, type: w.RUN });
|
|
456
457
|
}
|
|
457
458
|
toString() {
|
|
458
459
|
return yt(this.tiles);
|
|
459
460
|
}
|
|
460
461
|
}
|
|
461
|
-
class vn extends
|
|
462
|
+
class vn extends T {
|
|
462
463
|
constructor(t) {
|
|
463
464
|
super([t], w.ISOLATED);
|
|
464
465
|
}
|
|
465
466
|
static from(t) {
|
|
466
|
-
return
|
|
467
|
+
return T.deserialize({
|
|
467
468
|
tiles: t,
|
|
468
469
|
type: w.ISOLATED
|
|
469
470
|
});
|
|
@@ -472,43 +473,43 @@ class vn extends I {
|
|
|
472
473
|
return this.tiles[0].toString();
|
|
473
474
|
}
|
|
474
475
|
}
|
|
475
|
-
class Ut extends
|
|
476
|
+
class Ut extends T {
|
|
476
477
|
constructor(t) {
|
|
477
478
|
super(t, w.HAND);
|
|
478
479
|
}
|
|
479
480
|
static from(t) {
|
|
480
|
-
return
|
|
481
|
+
return T.deserialize({ tiles: t, type: w.HAND });
|
|
481
482
|
}
|
|
482
483
|
toString() {
|
|
483
|
-
return
|
|
484
|
+
return We(this.tiles);
|
|
484
485
|
}
|
|
485
486
|
}
|
|
486
|
-
class Sn extends
|
|
487
|
+
class Sn extends T {
|
|
487
488
|
constructor(t, e) {
|
|
488
489
|
super(t, e);
|
|
489
490
|
}
|
|
490
491
|
toString() {
|
|
491
|
-
return this.is(w.IMAGE_DISCARD) ? this.tiles.join("") :
|
|
492
|
+
return this.is(w.IMAGE_DISCARD) ? this.tiles.join("") : We(this.tiles);
|
|
492
493
|
}
|
|
493
494
|
}
|
|
494
495
|
const ne = (s, t) => {
|
|
495
496
|
switch (t) {
|
|
496
497
|
case w.CHI:
|
|
497
|
-
return new
|
|
498
|
+
return new q([s[0], s[1], s[2]]);
|
|
498
499
|
case w.PON:
|
|
499
|
-
return new
|
|
500
|
+
return new U([s[0], s[1], s[2]]);
|
|
500
501
|
case w.AN_KAN:
|
|
501
|
-
return new
|
|
502
|
+
return new C(s);
|
|
502
503
|
case w.DAI_KAN:
|
|
503
|
-
return new
|
|
504
|
+
return new Z(s);
|
|
504
505
|
case w.SHO_KAN:
|
|
505
|
-
return new
|
|
506
|
+
return new W(s);
|
|
506
507
|
case w.THREE:
|
|
507
|
-
return new
|
|
508
|
+
return new L(s);
|
|
508
509
|
case w.RUN:
|
|
509
510
|
return new dt(s);
|
|
510
511
|
case w.PAIR:
|
|
511
|
-
return new
|
|
512
|
+
return new R(s[0], s[1]);
|
|
512
513
|
case w.ISOLATED:
|
|
513
514
|
return new vn(s[0]);
|
|
514
515
|
case w.HAND:
|
|
@@ -517,7 +518,7 @@ const ne = (s, t) => {
|
|
|
517
518
|
return new Sn(s, t);
|
|
518
519
|
}
|
|
519
520
|
};
|
|
520
|
-
class
|
|
521
|
+
class K {
|
|
521
522
|
constructor(t) {
|
|
522
523
|
this.input = t, this.input = t.replace(/\s/g, "");
|
|
523
524
|
}
|
|
@@ -552,14 +553,14 @@ class W {
|
|
|
552
553
|
}
|
|
553
554
|
const [r, o] = en(i, n);
|
|
554
555
|
if (o) {
|
|
555
|
-
if (r ==
|
|
556
|
+
if (r == p.BACK) {
|
|
556
557
|
e.push(new y(r, 0)), t.readChar();
|
|
557
558
|
continue;
|
|
558
559
|
}
|
|
559
|
-
e.push(...
|
|
560
|
+
e.push(...Ns(n, r)), n = [], t.readChar();
|
|
560
561
|
continue;
|
|
561
562
|
} else {
|
|
562
|
-
const [a, c] =
|
|
563
|
+
const [a, c] = Ts(t);
|
|
563
564
|
if (c) {
|
|
564
565
|
n.push(a), t.readChar();
|
|
565
566
|
continue;
|
|
@@ -596,7 +597,7 @@ class W {
|
|
|
596
597
|
if (t.length == 0) return;
|
|
597
598
|
if (t.length > this.maxInputLength)
|
|
598
599
|
throw new Error(`exceeded maximum input length(${t.length})`);
|
|
599
|
-
const e = t.charAt(t.length - 1), [n, i] = en(e, [new y(
|
|
600
|
+
const e = t.charAt(t.length - 1), [n, i] = en(e, [new y(p.BACK, 1)]);
|
|
600
601
|
if (!i)
|
|
601
602
|
throw new Error(
|
|
602
603
|
`last character: ${e} is not type value: ${t}`
|
|
@@ -609,11 +610,11 @@ function tn(s) {
|
|
|
609
610
|
return s[0].has(m.DORA) ? w.IMAGE_DORA : s[0].has(m.TSUMO) ? w.TSUMO : w.HAND;
|
|
610
611
|
const t = s.every((r) => r.equals(s[0])), e = s.filter((r) => r.has(m.HORIZONTAL)).length, n = s.filter(
|
|
611
612
|
(r) => r.has(m.TSUMO) || r.has(m.DORA)
|
|
612
|
-
).length, i = s.filter((r) => r.t ==
|
|
613
|
+
).length, i = s.filter((r) => r.t == p.BACK).length;
|
|
613
614
|
if (n > 0) return w.UNKNOWN;
|
|
614
615
|
if (e == 0 && i == 0) return w.HAND;
|
|
615
616
|
if (s.length === 3 && i === 0)
|
|
616
|
-
return t ? w.PON : e == 1 &&
|
|
617
|
+
return t ? w.PON : e == 1 && Is(s) ? w.CHI : w.IMAGE_DISCARD;
|
|
617
618
|
if (s.length == 4 && i == 2) return w.AN_KAN;
|
|
618
619
|
if (s.length == 4 && t) {
|
|
619
620
|
if (e == 1) return w.DAI_KAN;
|
|
@@ -621,7 +622,7 @@ function tn(s) {
|
|
|
621
622
|
}
|
|
622
623
|
return e == 1 || n == 0 ? w.IMAGE_DISCARD : w.UNKNOWN;
|
|
623
624
|
}
|
|
624
|
-
function
|
|
625
|
+
function Is(s) {
|
|
625
626
|
const t = [...s].sort(fe);
|
|
626
627
|
if (t.some((n) => t[0].t != n.t)) return !1;
|
|
627
628
|
const e = t.map((n) => n.n);
|
|
@@ -629,7 +630,7 @@ function Ns(s) {
|
|
|
629
630
|
if (e[n] != e[n + 1] - 1) return !1;
|
|
630
631
|
return !0;
|
|
631
632
|
}
|
|
632
|
-
function
|
|
633
|
+
function Ns(s, t) {
|
|
633
634
|
return s.map((e) => {
|
|
634
635
|
const n = new y(t, e.n, e.ops);
|
|
635
636
|
return n.isNum() && n.n == 0 ? n.clone({ n: 5, add: m.RED }) : n;
|
|
@@ -643,17 +644,17 @@ function en(s, t) {
|
|
|
643
644
|
const o = t[r];
|
|
644
645
|
s === "d" && (t[r].n = o.n + 4);
|
|
645
646
|
}
|
|
646
|
-
return [
|
|
647
|
+
return [p.Z, !0];
|
|
647
648
|
}
|
|
648
|
-
return [
|
|
649
|
+
return [p.BACK, !1];
|
|
649
650
|
}
|
|
650
651
|
function On(s) {
|
|
651
652
|
const t = Number(s), e = 0 <= t && t <= 9;
|
|
652
653
|
return [t, e];
|
|
653
654
|
}
|
|
654
|
-
function
|
|
655
|
+
function Ts(s) {
|
|
655
656
|
const t = Object.values(m);
|
|
656
|
-
if (!t.includes(s.char)) return [new y(
|
|
657
|
+
if (!t.includes(s.char)) return [new y(p.BACK, 0), !1];
|
|
657
658
|
const e = [];
|
|
658
659
|
for (let n = 0; n < 4; n++) {
|
|
659
660
|
const i = s.peekCharN(n);
|
|
@@ -662,7 +663,7 @@ function Is(s) {
|
|
|
662
663
|
const [r, o] = On(i);
|
|
663
664
|
if (!o) break;
|
|
664
665
|
for (const c of e) s.readChar();
|
|
665
|
-
const a = new y(
|
|
666
|
+
const a = new y(p.BACK, r, e);
|
|
666
667
|
if (a.has(m.RED) && a.n != 5)
|
|
667
668
|
throw new Error(`found ${m.RED} but number is not 5: ${r}`);
|
|
668
669
|
if (a.has(m.DORA) && a.has(m.TSUMO))
|
|
@@ -670,9 +671,9 @@ function Is(s) {
|
|
|
670
671
|
return [a, !0];
|
|
671
672
|
}
|
|
672
673
|
}
|
|
673
|
-
return [new y(
|
|
674
|
+
return [new y(p.BACK, 0), !1];
|
|
674
675
|
}
|
|
675
|
-
function
|
|
676
|
+
function B(s, t = !1) {
|
|
676
677
|
const e = {
|
|
677
678
|
[_.E]: s,
|
|
678
679
|
[_.S]: s,
|
|
@@ -685,14 +686,14 @@ function P(s, t = !1) {
|
|
|
685
686
|
}
|
|
686
687
|
const te = (s) => {
|
|
687
688
|
let t = s.substring(0, 2), e = Number(s.substring(2, 3));
|
|
688
|
-
return e == 4 ? (e = 1, t =
|
|
689
|
-
},
|
|
689
|
+
return e == 4 ? (e = 1, t = Tt(t)) : e++, `${t}${e}`;
|
|
690
|
+
}, Bo = (s) => te(te(te(s))), Tt = (s) => {
|
|
690
691
|
let t = Number(s.toString()[0]);
|
|
691
|
-
return t = t % 4 + 1, `${t}${
|
|
692
|
-
},
|
|
692
|
+
return t = t % 4 + 1, `${t}${p.Z}`;
|
|
693
|
+
}, De = (s) => {
|
|
693
694
|
let t = Number(s.toString()[0]);
|
|
694
695
|
const e = [1, 4, 3, 2], n = e.indexOf(t);
|
|
695
|
-
return `${e[(n + 1) % e.length]}${
|
|
696
|
+
return `${e[(n + 1) % e.length]}${p.Z}`;
|
|
696
697
|
}, nn = (s, t, e) => {
|
|
697
698
|
const n = Math.abs(Number(s[0]) - Number(t[0]));
|
|
698
699
|
return b(n == 1 || n == 2 || n == 3), e == w.PON ? n == 3 ? 0 : n == 2 ? 1 : 2 : n == 3 ? 0 : n == 1 ? 3 : 2;
|
|
@@ -700,7 +701,7 @@ const te = (s) => {
|
|
|
700
701
|
function sn(s) {
|
|
701
702
|
return typeof s > "u";
|
|
702
703
|
}
|
|
703
|
-
function
|
|
704
|
+
function Ie(s, t = 0) {
|
|
704
705
|
return {
|
|
705
706
|
a: 1,
|
|
706
707
|
c: 0,
|
|
@@ -747,9 +748,9 @@ function Cs(s, t, e) {
|
|
|
747
748
|
f: 0
|
|
748
749
|
};
|
|
749
750
|
return sn(t) || sn(e) ? r : Ke([
|
|
750
|
-
|
|
751
|
+
Ie(t, e),
|
|
751
752
|
r,
|
|
752
|
-
|
|
753
|
+
Ie(-t, -e)
|
|
753
754
|
]);
|
|
754
755
|
}
|
|
755
756
|
function Rs(s, t = void 0, e = void 0) {
|
|
@@ -779,16 +780,16 @@ const pe = function(s) {
|
|
|
779
780
|
const t = Ps.exec(s);
|
|
780
781
|
return !(t === null || typeof t > "u");
|
|
781
782
|
};
|
|
782
|
-
function
|
|
783
|
+
function Bs(s) {
|
|
783
784
|
return typeof s < "u";
|
|
784
785
|
}
|
|
785
|
-
const
|
|
786
|
+
const Ws = {
|
|
786
787
|
allowBooleanAttributes: !1,
|
|
787
788
|
//A tag can have attributes without any value
|
|
788
789
|
unpairedTags: []
|
|
789
790
|
};
|
|
790
|
-
function
|
|
791
|
-
t = Object.assign({},
|
|
791
|
+
function Ds(s, t) {
|
|
792
|
+
t = Object.assign({}, Ws, t);
|
|
792
793
|
const e = [];
|
|
793
794
|
let n = !1, i = !1;
|
|
794
795
|
s[0] === "\uFEFF" && (s = s.substr(1));
|
|
@@ -809,11 +810,11 @@ function Ws(s, t) {
|
|
|
809
810
|
c += s[r];
|
|
810
811
|
if (c = c.trim(), c[c.length - 1] === "/" && (c = c.substring(0, c.length - 1), r--), !Gs(c)) {
|
|
811
812
|
let h;
|
|
812
|
-
return c.trim().length === 0 ? h = "Invalid space after '<'." : h = "Tag '" + c + "' is an invalid name.", S("InvalidTag", h,
|
|
813
|
+
return c.trim().length === 0 ? h = "Invalid space after '<'." : h = "Tag '" + c + "' is an invalid name.", S("InvalidTag", h, $(s, r));
|
|
813
814
|
}
|
|
814
815
|
const l = zs(s, r);
|
|
815
816
|
if (l === !1)
|
|
816
|
-
return S("InvalidAttr", "Attributes for '" + c + "' have open quote.",
|
|
817
|
+
return S("InvalidAttr", "Attributes for '" + c + "' have open quote.", $(s, r));
|
|
817
818
|
let u = l.value;
|
|
818
819
|
if (r = l.index, u[u.length - 1] === "/") {
|
|
819
820
|
const h = r - u.length;
|
|
@@ -822,32 +823,32 @@ function Ws(s, t) {
|
|
|
822
823
|
if (d === !0)
|
|
823
824
|
n = !0;
|
|
824
825
|
else
|
|
825
|
-
return S(d.err.code, d.err.msg,
|
|
826
|
+
return S(d.err.code, d.err.msg, $(s, h + d.err.line));
|
|
826
827
|
} else if (a)
|
|
827
828
|
if (l.tagClosed) {
|
|
828
829
|
if (u.trim().length > 0)
|
|
829
|
-
return S("InvalidTag", "Closing tag '" + c + "' can't have attributes or invalid starting.",
|
|
830
|
+
return S("InvalidTag", "Closing tag '" + c + "' can't have attributes or invalid starting.", $(s, o));
|
|
830
831
|
if (e.length === 0)
|
|
831
|
-
return S("InvalidTag", "Closing tag '" + c + "' has not been opened.",
|
|
832
|
+
return S("InvalidTag", "Closing tag '" + c + "' has not been opened.", $(s, o));
|
|
832
833
|
{
|
|
833
834
|
const h = e.pop();
|
|
834
835
|
if (c !== h.tagName) {
|
|
835
|
-
let d =
|
|
836
|
+
let d = $(s, h.tagStartPos);
|
|
836
837
|
return S(
|
|
837
838
|
"InvalidTag",
|
|
838
839
|
"Expected closing tag '" + h.tagName + "' (opened in line " + d.line + ", col " + d.col + ") instead of closing tag '" + c + "'.",
|
|
839
|
-
|
|
840
|
+
$(s, o)
|
|
840
841
|
);
|
|
841
842
|
}
|
|
842
843
|
e.length == 0 && (i = !0);
|
|
843
844
|
}
|
|
844
|
-
} else return S("InvalidTag", "Closing tag '" + c + "' doesn't have proper closing.",
|
|
845
|
+
} else return S("InvalidTag", "Closing tag '" + c + "' doesn't have proper closing.", $(s, r));
|
|
845
846
|
else {
|
|
846
847
|
const h = cn(u, t);
|
|
847
848
|
if (h !== !0)
|
|
848
|
-
return S(h.err.code, h.err.msg,
|
|
849
|
+
return S(h.err.code, h.err.msg, $(s, r - u.length + h.err.line));
|
|
849
850
|
if (i === !0)
|
|
850
|
-
return S("InvalidXml", "Multiple possible root nodes found.",
|
|
851
|
+
return S("InvalidXml", "Multiple possible root nodes found.", $(s, r));
|
|
851
852
|
t.unpairedTags.indexOf(c) !== -1 || e.push({ tagName: c, tagStartPos: o }), n = !0;
|
|
852
853
|
}
|
|
853
854
|
for (r++; r < s.length; r++)
|
|
@@ -862,20 +863,20 @@ function Ws(s, t) {
|
|
|
862
863
|
else if (s[r] === "&") {
|
|
863
864
|
const h = Fs(s, r);
|
|
864
865
|
if (h == -1)
|
|
865
|
-
return S("InvalidChar", "char '&' is not expected.",
|
|
866
|
+
return S("InvalidChar", "char '&' is not expected.", $(s, r));
|
|
866
867
|
r = h;
|
|
867
868
|
} else if (i === !0 && !rn(s[r]))
|
|
868
|
-
return S("InvalidXml", "Extra text at the end",
|
|
869
|
+
return S("InvalidXml", "Extra text at the end", $(s, r));
|
|
869
870
|
s[r] === "<" && r--;
|
|
870
871
|
}
|
|
871
872
|
} else {
|
|
872
873
|
if (rn(s[r]))
|
|
873
874
|
continue;
|
|
874
|
-
return S("InvalidChar", "char '" + s[r] + "' is not expected.",
|
|
875
|
+
return S("InvalidChar", "char '" + s[r] + "' is not expected.", $(s, r));
|
|
875
876
|
}
|
|
876
877
|
if (n) {
|
|
877
878
|
if (e.length == 1)
|
|
878
|
-
return S("InvalidTag", "Unclosed tag '" + e[0].tagName + "'.",
|
|
879
|
+
return S("InvalidTag", "Unclosed tag '" + e[0].tagName + "'.", $(s, e[0].tagStartPos));
|
|
879
880
|
if (e.length > 0)
|
|
880
881
|
return S("InvalidXml", "Invalid '" + JSON.stringify(e.map((r) => r.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
|
|
881
882
|
} else return S("InvalidXml", "Start tag expected.", 1);
|
|
@@ -891,7 +892,7 @@ function on(s, t) {
|
|
|
891
892
|
if (s[t] == "?" || s[t] == " ") {
|
|
892
893
|
const n = s.substr(e, t - e);
|
|
893
894
|
if (t > 5 && n === "xml")
|
|
894
|
-
return S("InvalidXml", "XML declaration allowed only at the start of the document.",
|
|
895
|
+
return S("InvalidXml", "XML declaration allowed only at the start of the document.", $(s, t));
|
|
895
896
|
if (s[t] == "?" && s[t + 1] == ">") {
|
|
896
897
|
t++;
|
|
897
898
|
break;
|
|
@@ -946,18 +947,18 @@ function cn(s, t) {
|
|
|
946
947
|
const e = Cn(s, Us), n = {};
|
|
947
948
|
for (let i = 0; i < e.length; i++) {
|
|
948
949
|
if (e[i][1].length === 0)
|
|
949
|
-
return S("InvalidAttr", "Attribute '" + e[i][2] + "' has no space in starting.",
|
|
950
|
+
return S("InvalidAttr", "Attribute '" + e[i][2] + "' has no space in starting.", Bt(e[i]));
|
|
950
951
|
if (e[i][3] !== void 0 && e[i][4] === void 0)
|
|
951
|
-
return S("InvalidAttr", "Attribute '" + e[i][2] + "' is without value.",
|
|
952
|
+
return S("InvalidAttr", "Attribute '" + e[i][2] + "' is without value.", Bt(e[i]));
|
|
952
953
|
if (e[i][3] === void 0 && !t.allowBooleanAttributes)
|
|
953
|
-
return S("InvalidAttr", "boolean attribute '" + e[i][2] + "' is not allowed.",
|
|
954
|
+
return S("InvalidAttr", "boolean attribute '" + e[i][2] + "' is not allowed.", Bt(e[i]));
|
|
954
955
|
const r = e[i][2];
|
|
955
|
-
if (!
|
|
956
|
-
return S("InvalidAttr", "Attribute '" + r + "' is an invalid name.",
|
|
956
|
+
if (!Ys(r))
|
|
957
|
+
return S("InvalidAttr", "Attribute '" + r + "' is an invalid name.", Bt(e[i]));
|
|
957
958
|
if (!n.hasOwnProperty(r))
|
|
958
959
|
n[r] = 1;
|
|
959
960
|
else
|
|
960
|
-
return S("InvalidAttr", "Attribute '" + r + "' is repeated.",
|
|
961
|
+
return S("InvalidAttr", "Attribute '" + r + "' is repeated.", Bt(e[i]));
|
|
961
962
|
}
|
|
962
963
|
return !0;
|
|
963
964
|
}
|
|
@@ -995,13 +996,13 @@ function S(s, t, e) {
|
|
|
995
996
|
}
|
|
996
997
|
};
|
|
997
998
|
}
|
|
998
|
-
function
|
|
999
|
+
function Ys(s) {
|
|
999
1000
|
return pe(s);
|
|
1000
1001
|
}
|
|
1001
1002
|
function Gs(s) {
|
|
1002
1003
|
return pe(s);
|
|
1003
1004
|
}
|
|
1004
|
-
function
|
|
1005
|
+
function $(s, t) {
|
|
1005
1006
|
const e = s.substring(0, t).split(/\r?\n/);
|
|
1006
1007
|
return {
|
|
1007
1008
|
line: e.length,
|
|
@@ -1009,10 +1010,10 @@ function M(s, t) {
|
|
|
1009
1010
|
col: e[e.length - 1].length + 1
|
|
1010
1011
|
};
|
|
1011
1012
|
}
|
|
1012
|
-
function
|
|
1013
|
+
function Bt(s) {
|
|
1013
1014
|
return s.startIndex + s[1].length;
|
|
1014
1015
|
}
|
|
1015
|
-
const
|
|
1016
|
+
const Zs = {
|
|
1016
1017
|
preserveOrder: !1,
|
|
1017
1018
|
attributeNamePrefix: "@_",
|
|
1018
1019
|
attributesGroupName: !1,
|
|
@@ -1057,7 +1058,7 @@ const Ys = {
|
|
|
1057
1058
|
// skipEmptyListItem: false
|
|
1058
1059
|
captureMetaData: !1
|
|
1059
1060
|
}, Vs = function(s) {
|
|
1060
|
-
return Object.assign({},
|
|
1061
|
+
return Object.assign({}, Zs, s);
|
|
1061
1062
|
};
|
|
1062
1063
|
let se;
|
|
1063
1064
|
typeof Symbol != "function" ? se = "@@xmlMetadata" : se = Symbol("XML Node Metadata");
|
|
@@ -1118,11 +1119,11 @@ class Js {
|
|
|
1118
1119
|
return { entities: n, i: e };
|
|
1119
1120
|
}
|
|
1120
1121
|
readEntityExp(t, e) {
|
|
1121
|
-
e =
|
|
1122
|
+
e = H(t, e);
|
|
1122
1123
|
let n = "";
|
|
1123
1124
|
for (; e < t.length && !/\s/.test(t[e]) && t[e] !== '"' && t[e] !== "'"; )
|
|
1124
1125
|
n += t[e], e++;
|
|
1125
|
-
if (
|
|
1126
|
+
if (Wt(n), e = H(t, e), !this.suppressValidationErr) {
|
|
1126
1127
|
if (t.substring(e, e + 6).toUpperCase() === "SYSTEM")
|
|
1127
1128
|
throw new Error("External entities are not supported");
|
|
1128
1129
|
if (t[e] === "%")
|
|
@@ -1132,18 +1133,18 @@ class Js {
|
|
|
1132
1133
|
return [e, i] = this.readIdentifierVal(t, e, "entity"), e--, [n, i, e];
|
|
1133
1134
|
}
|
|
1134
1135
|
readNotationExp(t, e) {
|
|
1135
|
-
e =
|
|
1136
|
+
e = H(t, e);
|
|
1136
1137
|
let n = "";
|
|
1137
1138
|
for (; e < t.length && !/\s/.test(t[e]); )
|
|
1138
1139
|
n += t[e], e++;
|
|
1139
|
-
!this.suppressValidationErr &&
|
|
1140
|
+
!this.suppressValidationErr && Wt(n), e = H(t, e);
|
|
1140
1141
|
const i = t.substring(e, e + 6).toUpperCase();
|
|
1141
1142
|
if (!this.suppressValidationErr && i !== "SYSTEM" && i !== "PUBLIC")
|
|
1142
1143
|
throw new Error(`Expected SYSTEM or PUBLIC, found "${i}"`);
|
|
1143
|
-
e += i.length, e =
|
|
1144
|
+
e += i.length, e = H(t, e);
|
|
1144
1145
|
let r = null, o = null;
|
|
1145
1146
|
if (i === "PUBLIC")
|
|
1146
|
-
[e, r] = this.readIdentifierVal(t, e, "publicIdentifier"), e =
|
|
1147
|
+
[e, r] = this.readIdentifierVal(t, e, "publicIdentifier"), e = H(t, e), (t[e] === '"' || t[e] === "'") && ([e, o] = this.readIdentifierVal(t, e, "systemIdentifier"));
|
|
1147
1148
|
else if (i === "SYSTEM" && ([e, o] = this.readIdentifierVal(t, e, "systemIdentifier"), !this.suppressValidationErr && !o))
|
|
1148
1149
|
throw new Error("Missing mandatory system identifier for SYSTEM notation");
|
|
1149
1150
|
return { notationName: n, publicIdentifier: r, systemIdentifier: o, index: --e };
|
|
@@ -1160,13 +1161,13 @@ class Js {
|
|
|
1160
1161
|
return e++, [e, i];
|
|
1161
1162
|
}
|
|
1162
1163
|
readElementExp(t, e) {
|
|
1163
|
-
e =
|
|
1164
|
+
e = H(t, e);
|
|
1164
1165
|
let n = "";
|
|
1165
1166
|
for (; e < t.length && !/\s/.test(t[e]); )
|
|
1166
1167
|
n += t[e], e++;
|
|
1167
1168
|
if (!this.suppressValidationErr && !pe(n))
|
|
1168
1169
|
throw new Error(`Invalid element name: "${n}"`);
|
|
1169
|
-
e =
|
|
1170
|
+
e = H(t, e);
|
|
1170
1171
|
let i = "";
|
|
1171
1172
|
if (t[e] === "E" && rt(t, "MPTY", e)) e += 4;
|
|
1172
1173
|
else if (t[e] === "A" && rt(t, "NY", e)) e += 2;
|
|
@@ -1184,20 +1185,20 @@ class Js {
|
|
|
1184
1185
|
};
|
|
1185
1186
|
}
|
|
1186
1187
|
readAttlistExp(t, e) {
|
|
1187
|
-
e =
|
|
1188
|
+
e = H(t, e);
|
|
1188
1189
|
let n = "";
|
|
1189
1190
|
for (; e < t.length && !/\s/.test(t[e]); )
|
|
1190
1191
|
n += t[e], e++;
|
|
1191
|
-
|
|
1192
|
+
Wt(n), e = H(t, e);
|
|
1192
1193
|
let i = "";
|
|
1193
1194
|
for (; e < t.length && !/\s/.test(t[e]); )
|
|
1194
1195
|
i += t[e], e++;
|
|
1195
|
-
if (!
|
|
1196
|
+
if (!Wt(i))
|
|
1196
1197
|
throw new Error(`Invalid attribute name: "${i}"`);
|
|
1197
|
-
e =
|
|
1198
|
+
e = H(t, e);
|
|
1198
1199
|
let r = "";
|
|
1199
1200
|
if (t.substring(e, e + 8).toUpperCase() === "NOTATION") {
|
|
1200
|
-
if (r = "NOTATION", e += 8, e =
|
|
1201
|
+
if (r = "NOTATION", e += 8, e = H(t, e), t[e] !== "(")
|
|
1201
1202
|
throw new Error(`Expected '(', found "${t[e]}"`);
|
|
1202
1203
|
e++;
|
|
1203
1204
|
let a = [];
|
|
@@ -1205,9 +1206,9 @@ class Js {
|
|
|
1205
1206
|
let c = "";
|
|
1206
1207
|
for (; e < t.length && t[e] !== "|" && t[e] !== ")"; )
|
|
1207
1208
|
c += t[e], e++;
|
|
1208
|
-
if (c = c.trim(), !
|
|
1209
|
+
if (c = c.trim(), !Wt(c))
|
|
1209
1210
|
throw new Error(`Invalid notation name: "${c}"`);
|
|
1210
|
-
a.push(c), t[e] === "|" && (e++, e =
|
|
1211
|
+
a.push(c), t[e] === "|" && (e++, e = H(t, e));
|
|
1211
1212
|
}
|
|
1212
1213
|
if (t[e] !== ")")
|
|
1213
1214
|
throw new Error("Unterminated list of notations");
|
|
@@ -1219,7 +1220,7 @@ class Js {
|
|
|
1219
1220
|
if (!this.suppressValidationErr && !a.includes(r.toUpperCase()))
|
|
1220
1221
|
throw new Error(`Invalid attribute type: "${r}"`);
|
|
1221
1222
|
}
|
|
1222
|
-
e =
|
|
1223
|
+
e = H(t, e);
|
|
1223
1224
|
let o = "";
|
|
1224
1225
|
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"), {
|
|
1225
1226
|
elementName: n,
|
|
@@ -1230,7 +1231,7 @@ class Js {
|
|
|
1230
1231
|
};
|
|
1231
1232
|
}
|
|
1232
1233
|
}
|
|
1233
|
-
const
|
|
1234
|
+
const H = (s, t) => {
|
|
1234
1235
|
for (; t < s.length && /\s/.test(s[t]); )
|
|
1235
1236
|
t++;
|
|
1236
1237
|
return t;
|
|
@@ -1240,7 +1241,7 @@ function rt(s, t, e) {
|
|
|
1240
1241
|
if (t[n] !== s[e + n + 1]) return !1;
|
|
1241
1242
|
return !0;
|
|
1242
1243
|
}
|
|
1243
|
-
function
|
|
1244
|
+
function Wt(s) {
|
|
1244
1245
|
if (pe(s))
|
|
1245
1246
|
return s;
|
|
1246
1247
|
throw new Error(`Invalid entity name ${s}`);
|
|
@@ -1357,7 +1358,7 @@ function ai(s, t, e, n, i, r, o) {
|
|
|
1357
1358
|
if (s !== void 0 && (this.options.trimValues && !n && (s = s.trim()), s.length > 0)) {
|
|
1358
1359
|
o || (s = this.replaceEntitiesValue(s));
|
|
1359
1360
|
const a = this.options.tagValueProcessor(t, s, e, i, r);
|
|
1360
|
-
return a == null ? s : typeof a != typeof s || a !== s ? a : this.options.trimValues ?
|
|
1361
|
+
return a == null ? s : typeof a != typeof s || a !== s ? a : this.options.trimValues ? Te(s, this.options.parseTagValue, this.options.numberParseOptions) : s.trim() === s ? Te(s, this.options.parseTagValue, this.options.numberParseOptions) : s;
|
|
1361
1362
|
}
|
|
1362
1363
|
}
|
|
1363
1364
|
function ci(s) {
|
|
@@ -1382,7 +1383,7 @@ function hi(s, t, e) {
|
|
|
1382
1383
|
if (this.options.transformAttributeName && (l = this.options.transformAttributeName(l)), l === "__proto__" && (l = "#__proto__"), c !== void 0) {
|
|
1383
1384
|
this.options.trimValues && (c = c.trim()), c = this.replaceEntitiesValue(c);
|
|
1384
1385
|
const u = this.options.attributeValueProcessor(a, c, t);
|
|
1385
|
-
u == null ? r[l] = c : typeof u != typeof c || u !== c ? r[l] = u : r[l] =
|
|
1386
|
+
u == null ? r[l] = c : typeof u != typeof c || u !== c ? r[l] = u : r[l] = Te(
|
|
1386
1387
|
c,
|
|
1387
1388
|
this.options.parseAttributeValue,
|
|
1388
1389
|
this.options.numberParseOptions
|
|
@@ -1420,7 +1421,7 @@ const ui = function(s) {
|
|
|
1420
1421
|
let h = 0;
|
|
1421
1422
|
u && this.options.unpairedTags.indexOf(u) !== -1 ? (h = i.lastIndexOf(".", i.lastIndexOf(".") - 1), this.tagsNodeStack.pop()) : h = i.lastIndexOf("."), i = i.substring(0, h), e = this.tagsNodeStack.pop(), n = "", o = c;
|
|
1422
1423
|
} else if (s[o + 1] === "?") {
|
|
1423
|
-
let c =
|
|
1424
|
+
let c = Ne(s, o, !1, "?>");
|
|
1424
1425
|
if (!c) throw new Error("Pi Tag is not closed.");
|
|
1425
1426
|
if (n = this.saveTextToParentTag(n, e, i), !(this.options.ignoreDeclaration && c.tagName === "?xml" || this.options.ignorePiTags)) {
|
|
1426
1427
|
const l = new lt(c.tagName);
|
|
@@ -1443,12 +1444,12 @@ const ui = function(s) {
|
|
|
1443
1444
|
let u = this.parseTextData(l, e.tagname, i, !0, !1, !0, !0);
|
|
1444
1445
|
u == null && (u = ""), this.options.cdataPropName ? e.add(this.options.cdataPropName, [{ [this.options.textNodeName]: l }]) : e.add(this.options.textNodeName, u), o = c + 2;
|
|
1445
1446
|
} else {
|
|
1446
|
-
let c =
|
|
1447
|
+
let c = Ne(s, o, this.options.removeNSPrefix), l = c.tagName;
|
|
1447
1448
|
const u = c.rawTagName;
|
|
1448
1449
|
let h = c.tagExp, d = c.attrExpPresent, g = c.closeIndex;
|
|
1449
1450
|
this.options.transformTagName && (l = this.options.transformTagName(l)), e && n && e.tagname !== "!xml" && (n = this.saveTextToParentTag(n, e, i, !1));
|
|
1450
|
-
const
|
|
1451
|
-
|
|
1451
|
+
const f = e;
|
|
1452
|
+
f && this.options.unpairedTags.indexOf(f.tagname) !== -1 && (e = this.tagsNodeStack.pop(), i = i.substring(0, i.lastIndexOf("."))), l !== t.tagname && (i += i ? "." + l : l);
|
|
1452
1453
|
const E = o;
|
|
1453
1454
|
if (this.isItStopNode(this.options.stopNodes, i, l)) {
|
|
1454
1455
|
let A = "";
|
|
@@ -1461,8 +1462,8 @@ const ui = function(s) {
|
|
|
1461
1462
|
if (!v) throw new Error(`Unexpected end of ${u}`);
|
|
1462
1463
|
o = v.i, A = v.tagContent;
|
|
1463
1464
|
}
|
|
1464
|
-
const
|
|
1465
|
-
l !== h && d && (
|
|
1465
|
+
const I = new lt(l);
|
|
1466
|
+
l !== h && d && (I[":@"] = this.buildAttributesMap(h, i, l)), A && (A = this.parseTextData(A, l, i, !0, d, !0, !0)), i = i.substr(0, i.lastIndexOf(".")), I.add(this.options.textNodeName, A), this.addChild(e, I, i, E);
|
|
1466
1467
|
} else {
|
|
1467
1468
|
if (h.length > 0 && h.lastIndexOf("/") === h.length - 1) {
|
|
1468
1469
|
l[l.length - 1] === "/" ? (l = l.substr(0, l.length - 1), i = i.substr(0, i.length - 1), h = l) : h = h.substr(0, h.length - 1), this.options.transformTagName && (l = this.options.transformTagName(l));
|
|
@@ -1551,7 +1552,7 @@ function ft(s, t, e, n) {
|
|
|
1551
1552
|
throw new Error(n);
|
|
1552
1553
|
return i + t.length - 1;
|
|
1553
1554
|
}
|
|
1554
|
-
function
|
|
1555
|
+
function Ne(s, t, e, n = ">") {
|
|
1555
1556
|
const i = mi(s, t + 1, n);
|
|
1556
1557
|
if (!i) return;
|
|
1557
1558
|
let r = i.data;
|
|
@@ -1591,16 +1592,16 @@ function yi(s, t, e) {
|
|
|
1591
1592
|
else if (s.substr(e + 1, 2) === "![")
|
|
1592
1593
|
e = ft(s, "]]>", e, "StopNode is not closed.") - 2;
|
|
1593
1594
|
else {
|
|
1594
|
-
const r =
|
|
1595
|
+
const r = Ne(s, e, ">");
|
|
1595
1596
|
r && ((r && r.tagName) === t && r.tagExp[r.tagExp.length - 1] !== "/" && i++, e = r.closeIndex);
|
|
1596
1597
|
}
|
|
1597
1598
|
}
|
|
1598
|
-
function
|
|
1599
|
+
function Te(s, t, e) {
|
|
1599
1600
|
if (t && typeof s == "string") {
|
|
1600
1601
|
const n = s.trim();
|
|
1601
1602
|
return n === "true" ? !0 : n === "false" ? !1 : ti(s, e);
|
|
1602
1603
|
} else
|
|
1603
|
-
return
|
|
1604
|
+
return Bs(s) ? s : "";
|
|
1604
1605
|
}
|
|
1605
1606
|
const we = lt.getMetaDataSymbol();
|
|
1606
1607
|
function wi(s, t) {
|
|
@@ -1662,7 +1663,7 @@ class bi {
|
|
|
1662
1663
|
throw new Error("XML data is accepted in String or Bytes[] form.");
|
|
1663
1664
|
if (e) {
|
|
1664
1665
|
e === !0 && (e = {});
|
|
1665
|
-
const r =
|
|
1666
|
+
const r = Ds(t, e);
|
|
1666
1667
|
if (r !== !0)
|
|
1667
1668
|
throw Error(`${r.err.msg}:${r.err.line}:${r.err.col}`);
|
|
1668
1669
|
}
|
|
@@ -1699,21 +1700,21 @@ class bi {
|
|
|
1699
1700
|
return lt.getMetaDataSymbol();
|
|
1700
1701
|
}
|
|
1701
1702
|
}
|
|
1702
|
-
const
|
|
1703
|
+
const Ii = `
|
|
1703
1704
|
`;
|
|
1704
|
-
function
|
|
1705
|
+
function Ni(s, t) {
|
|
1705
1706
|
let e = "";
|
|
1706
|
-
return t.format && t.indentBy.length > 0 && (e =
|
|
1707
|
+
return t.format && t.indentBy.length > 0 && (e = Ii), xn(s, t, "", e);
|
|
1707
1708
|
}
|
|
1708
1709
|
function xn(s, t, e, n) {
|
|
1709
1710
|
let i = "", r = !1;
|
|
1710
1711
|
for (let o = 0; o < s.length; o++) {
|
|
1711
|
-
const a = s[o], c =
|
|
1712
|
+
const a = s[o], c = Ti(a);
|
|
1712
1713
|
if (c === void 0) continue;
|
|
1713
1714
|
let l = "";
|
|
1714
1715
|
if (e.length === 0 ? l = c : l = `${e}.${c}`, c === t.textNodeName) {
|
|
1715
|
-
let
|
|
1716
|
-
vi(l, t) || (
|
|
1716
|
+
let f = a[c];
|
|
1717
|
+
vi(l, t) || (f = t.tagValueProcessor(c, f), f = $n(f, t)), r && (i += n), i += f, r = !1;
|
|
1717
1718
|
continue;
|
|
1718
1719
|
} else if (c === t.cdataPropName) {
|
|
1719
1720
|
r && (i += n), i += `<![CDATA[${a[c][0][t.textNodeName]}]]>`, r = !1;
|
|
@@ -1722,9 +1723,9 @@ function xn(s, t, e, n) {
|
|
|
1722
1723
|
i += n + `<!--${a[c][0][t.textNodeName]}-->`, r = !0;
|
|
1723
1724
|
continue;
|
|
1724
1725
|
} else if (c[0] === "?") {
|
|
1725
|
-
const
|
|
1726
|
+
const f = ln(a[":@"], t), E = c === "?xml" ? "" : n;
|
|
1726
1727
|
let A = a[c][0][t.textNodeName];
|
|
1727
|
-
A = A.length !== 0 ? " " + A : "", i += E + `<${c}${A}${
|
|
1728
|
+
A = A.length !== 0 ? " " + A : "", i += E + `<${c}${A}${f}?>`, r = !0;
|
|
1728
1729
|
continue;
|
|
1729
1730
|
}
|
|
1730
1731
|
let u = n;
|
|
@@ -1734,7 +1735,7 @@ function xn(s, t, e, n) {
|
|
|
1734
1735
|
}
|
|
1735
1736
|
return i;
|
|
1736
1737
|
}
|
|
1737
|
-
function
|
|
1738
|
+
function Ti(s) {
|
|
1738
1739
|
const t = Object.keys(s);
|
|
1739
1740
|
for (let e = 0; e < t.length; e++) {
|
|
1740
1741
|
const n = t[e];
|
|
@@ -1811,7 +1812,7 @@ function st(s) {
|
|
|
1811
1812
|
}, this.tagEndChar = ">", this.newLine = "");
|
|
1812
1813
|
}
|
|
1813
1814
|
st.prototype.build = function(s) {
|
|
1814
|
-
return this.options.preserveOrder ?
|
|
1815
|
+
return this.options.preserveOrder ? Ni(s, this.options) : (Array.isArray(s) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (s = {
|
|
1815
1816
|
[this.options.arrayNodeName]: s
|
|
1816
1817
|
}), this.j2x(s, 0, []).val);
|
|
1817
1818
|
};
|
|
@@ -1938,8 +1939,8 @@ class wt {
|
|
|
1938
1939
|
left(...t) {
|
|
1939
1940
|
return `<${[
|
|
1940
1941
|
this.type,
|
|
1941
|
-
|
|
1942
|
-
|
|
1942
|
+
Wn(this.attrs),
|
|
1943
|
+
Bi(this.styles),
|
|
1943
1944
|
...t
|
|
1944
1945
|
].filter((e) => e != "").join(" ")}>`;
|
|
1945
1946
|
}
|
|
@@ -2015,7 +2016,7 @@ class vt extends wt {
|
|
|
2015
2016
|
return this._text;
|
|
2016
2017
|
}
|
|
2017
2018
|
}
|
|
2018
|
-
let
|
|
2019
|
+
let Bn = class extends wt {
|
|
2019
2020
|
raw;
|
|
2020
2021
|
constructor(t) {
|
|
2021
2022
|
super("symbol"), this.raw = t;
|
|
@@ -2027,7 +2028,7 @@ let Dn = class extends wt {
|
|
|
2027
2028
|
return this.raw;
|
|
2028
2029
|
}
|
|
2029
2030
|
};
|
|
2030
|
-
class
|
|
2031
|
+
class N extends wt {
|
|
2031
2032
|
children = [];
|
|
2032
2033
|
rotateMatrix;
|
|
2033
2034
|
translateMatrix;
|
|
@@ -2041,7 +2042,7 @@ class T extends wt {
|
|
|
2041
2042
|
return this.rotateMatrix = Rs(t, e, n), this;
|
|
2042
2043
|
}
|
|
2043
2044
|
translate(t, e) {
|
|
2044
|
-
return this.translateMatrix =
|
|
2045
|
+
return this.translateMatrix = Ie(t, e), this;
|
|
2045
2046
|
}
|
|
2046
2047
|
center() {
|
|
2047
2048
|
return this.children.map((t) => t.toString()).join("");
|
|
@@ -2055,7 +2056,7 @@ class T extends wt {
|
|
|
2055
2056
|
each(t, e) {
|
|
2056
2057
|
for (let n = 0; n < this.children.length; n++) {
|
|
2057
2058
|
const i = this.children[n];
|
|
2058
|
-
i instanceof
|
|
2059
|
+
i instanceof N && e && i.each(t, !0), t(n, this.children);
|
|
2059
2060
|
}
|
|
2060
2061
|
}
|
|
2061
2062
|
}
|
|
@@ -2080,7 +2081,7 @@ class Mi extends wt {
|
|
|
2080
2081
|
return `<${[
|
|
2081
2082
|
this.type,
|
|
2082
2083
|
...Ri,
|
|
2083
|
-
|
|
2084
|
+
Wn(this.attrs),
|
|
2084
2085
|
Hi(this.viewBox)
|
|
2085
2086
|
].filter((e) => e != "").join(" ")}>`;
|
|
2086
2087
|
}
|
|
@@ -2088,7 +2089,7 @@ class Mi extends wt {
|
|
|
2088
2089
|
return this.viewBox = { x: t, y: e, width: n, height: i }, this;
|
|
2089
2090
|
}
|
|
2090
2091
|
importSymbol(t) {
|
|
2091
|
-
for (const e of
|
|
2092
|
+
for (const e of Wi(t))
|
|
2092
2093
|
this.add(e);
|
|
2093
2094
|
return this;
|
|
2094
2095
|
}
|
|
@@ -2107,14 +2108,14 @@ class Mi extends wt {
|
|
|
2107
2108
|
each(t, e) {
|
|
2108
2109
|
for (let n = 0; n < this.children.length; n++) {
|
|
2109
2110
|
const i = this.children[n];
|
|
2110
|
-
i instanceof
|
|
2111
|
+
i instanceof N && e && i.each(t, !0), t(n, this.children);
|
|
2111
2112
|
}
|
|
2112
2113
|
}
|
|
2113
2114
|
}
|
|
2114
2115
|
function xi() {
|
|
2115
2116
|
return new Mi();
|
|
2116
2117
|
}
|
|
2117
|
-
const
|
|
2118
|
+
const Do = xi, Ko = N, Lo = Hn, zo = Le, Uo = Pn, jo = vt;
|
|
2118
2119
|
function $i(s) {
|
|
2119
2120
|
return s.replace(/[A-Z]/g, (t) => "-" + t.toLowerCase());
|
|
2120
2121
|
}
|
|
@@ -2124,34 +2125,34 @@ function Hi(s) {
|
|
|
2124
2125
|
function Pi(s) {
|
|
2125
2126
|
return s == null ? "" : `transform="${Ms(s)}"`;
|
|
2126
2127
|
}
|
|
2127
|
-
function
|
|
2128
|
+
function Wn(s) {
|
|
2128
2129
|
return Object.entries(s).filter(([t, e]) => e !== void 0).map(([t, e]) => `${$i(t)}="${e}"`).join(" ");
|
|
2129
2130
|
}
|
|
2130
|
-
function
|
|
2131
|
+
function Bi(s) {
|
|
2131
2132
|
const t = Object.entries(s).map(([e, n]) => `${e}: ${n};`).join(" ");
|
|
2132
2133
|
return t != "" ? `style="${t}"` : "";
|
|
2133
2134
|
}
|
|
2134
|
-
function*
|
|
2135
|
+
function* Wi(s) {
|
|
2135
2136
|
const t = new bi({ ignoreAttributes: !1 }), e = new st({
|
|
2136
2137
|
ignoreAttributes: !1
|
|
2137
2138
|
}), n = t.parse(s);
|
|
2138
2139
|
for (const i of n.svg.symbol) {
|
|
2139
|
-
const r = e.build(i), o = new
|
|
2140
|
+
const r = e.build(i), o = new Bn(r);
|
|
2140
2141
|
for (const [a, c] of Object.entries(i))
|
|
2141
2142
|
a.startsWith("@_") && (o.attrs[a.substring(2)] = c);
|
|
2142
2143
|
yield o;
|
|
2143
2144
|
}
|
|
2144
2145
|
}
|
|
2145
|
-
const
|
|
2146
|
-
const e =
|
|
2146
|
+
const Y = (s, t) => {
|
|
2147
|
+
const e = D(s.tiles[0], t), n = e.baseHeight, i = e.baseWidth;
|
|
2147
2148
|
if (s.is(w.SHO_KAN))
|
|
2148
2149
|
return { width: i * 2 + n, height: Math.max(i * 2, n) };
|
|
2149
2150
|
const r = s.tiles.reduce((a, c) => {
|
|
2150
|
-
const l =
|
|
2151
|
+
const l = D(c, t).height;
|
|
2151
2152
|
return l > a ? l : a;
|
|
2152
2153
|
}, 0);
|
|
2153
|
-
return { width: s.tiles.reduce((a, c) => a +
|
|
2154
|
-
},
|
|
2154
|
+
return { width: s.tiles.reduce((a, c) => a + D(c, t).width, 0), height: r };
|
|
2155
|
+
}, D = (s, t) => {
|
|
2155
2156
|
const e = parseFloat((gt.HEIGHT * t).toPrecision(5)), n = parseFloat((gt.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 };
|
|
2156
2157
|
return (s.has(m.TSUMO) || s.has(m.DORA)) && (i.width += n * gt.TEXT_SCALE), i;
|
|
2157
2158
|
};
|
|
@@ -2167,7 +2168,7 @@ class Ot {
|
|
|
2167
2168
|
}
|
|
2168
2169
|
// 横向き牌を縦向き牌と水平に揃えるためのY座標オフセットを計算
|
|
2169
2170
|
getHorizontalTileYOffset(t) {
|
|
2170
|
-
const e =
|
|
2171
|
+
const e = D(t, this.scale);
|
|
2171
2172
|
return (e.baseHeight - e.baseWidth) / 2;
|
|
2172
2173
|
}
|
|
2173
2174
|
// image wrapper
|
|
@@ -2176,20 +2177,20 @@ class Ot {
|
|
|
2176
2177
|
return this.svgSprite && (e = new Le().use(Ot.buildID(t))), t instanceof y && t.has(m.COLOR_GRAYSCALE) && e.css({ filter: "contrast(65%)" }), e;
|
|
2177
2178
|
}
|
|
2178
2179
|
createImage(t, e, n) {
|
|
2179
|
-
const i =
|
|
2180
|
+
const i = D(t, this.scale);
|
|
2180
2181
|
return this.image(t).dx(e).dy(n).size(i.baseWidth, i.baseHeight);
|
|
2181
2182
|
}
|
|
2182
2183
|
createTextImage(t, e, n, i) {
|
|
2183
|
-
const r = this.createImage(t, e, n), o =
|
|
2184
|
+
const r = this.createImage(t, e, n), o = D(t, this.scale), a = o.baseHeight * 0.2, c = o.baseWidth, l = o.baseHeight, u = new vt().plain(i);
|
|
2184
2185
|
u.size(o.baseWidth, o.baseHeight).font({
|
|
2185
|
-
family:
|
|
2186
|
+
family: Nn,
|
|
2186
2187
|
size: a
|
|
2187
2188
|
}).dx(c).dy(l);
|
|
2188
|
-
const h = new
|
|
2189
|
+
const h = new N();
|
|
2189
2190
|
return h.add(r).add(u).translate(e, n), h;
|
|
2190
2191
|
}
|
|
2191
2192
|
createRotate90Image(t, e, n, i = !1) {
|
|
2192
|
-
const r = this.createImage(t, 0, 0), o =
|
|
2193
|
+
const r = this.createImage(t, 0, 0), o = D(t, this.scale), a = o.baseWidth / 2, c = o.baseHeight / 2, l = e + this.getHorizontalTileYOffset(t), u = i ? n - this.getHorizontalTileYOffset(t) : n, h = new N();
|
|
2193
2194
|
return h.add(r).translate(l, u).rotate(90, a, c), h;
|
|
2194
2195
|
}
|
|
2195
2196
|
createStick(t) {
|
|
@@ -2198,7 +2199,7 @@ class Ot {
|
|
|
2198
2199
|
static buildID(t) {
|
|
2199
2200
|
if (t == 100 || t == 1e3)
|
|
2200
2201
|
return t == 100 ? "stick100" : "stick1000";
|
|
2201
|
-
const e = t.t ==
|
|
2202
|
+
const e = t.t == p.BACK || t.has(m.RED) ? 0 : t.n;
|
|
2202
2203
|
return `${t.t}${e}`;
|
|
2203
2204
|
}
|
|
2204
2205
|
buildURL(t) {
|
|
@@ -2206,13 +2207,13 @@ class Ot {
|
|
|
2206
2207
|
return this.imageHostUrl != "" ? `${this.imageHostUrl}${e}` : e;
|
|
2207
2208
|
}
|
|
2208
2209
|
}
|
|
2209
|
-
class
|
|
2210
|
+
class Dn extends Ot {
|
|
2210
2211
|
blockMargin = gt.WIDTH * gt.BLOCK_MARGIN_SCALE * this.scale;
|
|
2211
2212
|
createBlockHandDiscard(t) {
|
|
2212
|
-
const e = t instanceof
|
|
2213
|
+
const e = t instanceof C ? t.tilesWithBack : t.tiles, n = new N();
|
|
2213
2214
|
let i = 0;
|
|
2214
2215
|
for (const r of e) {
|
|
2215
|
-
const o =
|
|
2216
|
+
const o = D(r, this.scale), a = r.has(m.HORIZONTAL) ? this.createRotate90Image.bind(this) : this.createImage.bind(this), c = r.has(m.HORIZONTAL) ? this.getHorizontalTileYOffset(r) : 0, l = a(r, i, c);
|
|
2216
2217
|
n.add(l), i += o.width;
|
|
2217
2218
|
}
|
|
2218
2219
|
return n;
|
|
@@ -2220,22 +2221,22 @@ class Wn extends Ot {
|
|
|
2220
2221
|
createBlockPonChiKan(t) {
|
|
2221
2222
|
const e = t.tiles.findIndex((r) => r.has(m.HORIZONTAL));
|
|
2222
2223
|
let n = 0;
|
|
2223
|
-
const i = new
|
|
2224
|
+
const i = new N();
|
|
2224
2225
|
if (t.type == w.SHO_KAN) {
|
|
2225
2226
|
let r = e;
|
|
2226
2227
|
for (let o = 0; o < t.tiles.length; o++)
|
|
2227
2228
|
t.tiles[o].has(m.HORIZONTAL) && (r = o);
|
|
2228
2229
|
for (let o = 0; o < t.tiles.length; o++) {
|
|
2229
|
-
const a =
|
|
2230
|
+
const a = D(t.tiles[o], this.scale);
|
|
2230
2231
|
if (o == r) continue;
|
|
2231
2232
|
if (o == e) {
|
|
2232
|
-
const u = t.tiles[e], h = t.tiles[r], d =
|
|
2233
|
+
const u = t.tiles[e], h = t.tiles[r], d = D(u, this.scale), g = this.createRotate90Image(u, 0, 0, !0), f = this.createRotate90Image(
|
|
2233
2234
|
h,
|
|
2234
2235
|
0,
|
|
2235
2236
|
d.height,
|
|
2236
2237
|
!0
|
|
2237
2238
|
);
|
|
2238
|
-
i.add(new
|
|
2239
|
+
i.add(new N().translate(n, 0).add(g).add(f)), n += d.width;
|
|
2239
2240
|
continue;
|
|
2240
2241
|
}
|
|
2241
2242
|
const c = a.width * 2 - a.height, l = this.createImage(t.tiles[o], n, c);
|
|
@@ -2249,64 +2250,64 @@ class Wn extends Ot {
|
|
|
2249
2250
|
n,
|
|
2250
2251
|
this.getHorizontalTileYOffset(r)
|
|
2251
2252
|
);
|
|
2252
|
-
n +=
|
|
2253
|
+
n += D(r, this.scale).width, i.add(o);
|
|
2253
2254
|
for (let a = 0; a < t.tiles.length; a++) {
|
|
2254
2255
|
if (a == e) continue;
|
|
2255
|
-
const c = t.tiles[a], l =
|
|
2256
|
+
const c = t.tiles[a], l = D(c, this.scale), u = this.createImage(c, n, 0);
|
|
2256
2257
|
n += l.width, i.add(u);
|
|
2257
2258
|
}
|
|
2258
2259
|
return i;
|
|
2259
2260
|
}
|
|
2260
2261
|
for (let r = 0; r < t.tiles.length; r++) {
|
|
2261
|
-
const o = r == e ? this.createRotate90Image.bind(this) : this.createImage.bind(this), a = t.tiles[r], c = r == e ? this.getHorizontalTileYOffset(a) : 0, l =
|
|
2262
|
+
const o = r == e ? this.createRotate90Image.bind(this) : this.createImage.bind(this), a = t.tiles[r], c = r == e ? this.getHorizontalTileYOffset(a) : 0, l = D(a, this.scale), u = o(a, n, c);
|
|
2262
2263
|
n += l.width, i.add(u);
|
|
2263
2264
|
}
|
|
2264
2265
|
return i;
|
|
2265
2266
|
}
|
|
2266
2267
|
}
|
|
2267
|
-
const
|
|
2268
|
+
const Di = (s, t) => {
|
|
2268
2269
|
const e = s.scale;
|
|
2269
2270
|
return {
|
|
2270
2271
|
[w.CHI]: function(i) {
|
|
2271
|
-
const r =
|
|
2272
|
+
const r = Y(i, e), o = s.createBlockPonChiKan(i);
|
|
2272
2273
|
return { ...r, e: o };
|
|
2273
2274
|
},
|
|
2274
2275
|
[w.PON]: function(i) {
|
|
2275
|
-
const r =
|
|
2276
|
+
const r = Y(i, e), o = s.createBlockPonChiKan(i);
|
|
2276
2277
|
return { ...r, e: o };
|
|
2277
2278
|
},
|
|
2278
2279
|
[w.DAI_KAN]: function(i) {
|
|
2279
|
-
const r =
|
|
2280
|
+
const r = Y(i, e), o = s.createBlockPonChiKan(i);
|
|
2280
2281
|
return { ...r, e: o };
|
|
2281
2282
|
},
|
|
2282
2283
|
[w.SHO_KAN]: function(i) {
|
|
2283
|
-
const r =
|
|
2284
|
+
const r = Y(i, e), o = s.createBlockPonChiKan(i);
|
|
2284
2285
|
return { ...r, e: o };
|
|
2285
2286
|
},
|
|
2286
2287
|
[w.AN_KAN]: function(i) {
|
|
2287
2288
|
b(
|
|
2288
|
-
i instanceof
|
|
2289
|
+
i instanceof C,
|
|
2289
2290
|
`block type is not ankan: ${i.type}`
|
|
2290
2291
|
);
|
|
2291
|
-
const r =
|
|
2292
|
+
const r = Y(i, e), o = s.createBlockHandDiscard(i);
|
|
2292
2293
|
return { ...r, e: o };
|
|
2293
2294
|
},
|
|
2294
2295
|
[w.IMAGE_DORA]: function(i) {
|
|
2295
2296
|
i = t?.doraText == !1 ? new Ut([i.tiles[0].clone({ remove: m.DORA })]) : i;
|
|
2296
|
-
const r =
|
|
2297
|
+
const r = Y(i, e), o = new N(), a = t?.doraText === !1 ? s.createImage(i.tiles[0], 0, 0) : s.createTextImage(i.tiles[0], 0, 0, "(ドラ)");
|
|
2297
2298
|
return o.add(a), { ...r, e: o };
|
|
2298
2299
|
},
|
|
2299
2300
|
[w.TSUMO]: function(i) {
|
|
2300
2301
|
i = t?.tsumoText == !1 ? new Ut([i.tiles[0].clone({ remove: m.TSUMO })]) : i;
|
|
2301
|
-
const r =
|
|
2302
|
+
const r = Y(i, e), o = new N(), a = t?.tsumoText === !1 ? s.createImage(i.tiles[0], 0, 0) : s.createTextImage(i.tiles[0], 0, 0, "(ツモ)");
|
|
2302
2303
|
return o.add(a), { ...r, e: o };
|
|
2303
2304
|
},
|
|
2304
2305
|
[w.HAND]: function(i) {
|
|
2305
|
-
const r =
|
|
2306
|
+
const r = Y(i, e), o = s.createBlockHandDiscard(i);
|
|
2306
2307
|
return { ...r, e: o };
|
|
2307
2308
|
},
|
|
2308
2309
|
[w.IMAGE_DISCARD]: function(i) {
|
|
2309
|
-
const r =
|
|
2310
|
+
const r = Y(i, e), o = s.createBlockHandDiscard(i);
|
|
2310
2311
|
return { ...r, e: o };
|
|
2311
2312
|
},
|
|
2312
2313
|
[w.THREE]: function(i) {
|
|
@@ -2324,22 +2325,22 @@ const Wi = (s, t) => {
|
|
|
2324
2325
|
[w.UNKNOWN]: function(i) {
|
|
2325
2326
|
if (i.tiles.some((a) => a.has(m.TSUMO) || a.has(m.DORA)))
|
|
2326
2327
|
throw new Error("found an unknown block with operator tiles");
|
|
2327
|
-
const r =
|
|
2328
|
+
const r = Y(i, e), o = s.createBlockHandDiscard(i);
|
|
2328
2329
|
return { ...r, e: o };
|
|
2329
2330
|
}
|
|
2330
2331
|
};
|
|
2331
2332
|
}, Kt = (s, t, e) => {
|
|
2332
|
-
const n =
|
|
2333
|
+
const n = Di(s, e);
|
|
2333
2334
|
let i = 0, r = 0;
|
|
2334
2335
|
const o = [];
|
|
2335
2336
|
for (const h of t) {
|
|
2336
2337
|
const d = n[h.type], g = d(h);
|
|
2337
2338
|
r += g.width, i = g.height > i ? g.height : i, o.push(g);
|
|
2338
2339
|
}
|
|
2339
|
-
const a = i, c = r + (t.length - 1) * s.blockMargin, l = new
|
|
2340
|
+
const a = i, c = r + (t.length - 1) * s.blockMargin, l = new N();
|
|
2340
2341
|
let u = 0;
|
|
2341
2342
|
for (const h of o) {
|
|
2342
|
-
const d = a - h.height, g = new
|
|
2343
|
+
const d = a - h.height, g = new N().translate(u, d);
|
|
2343
2344
|
g.add(h.e), l.add(g), u += h.width + s.blockMargin;
|
|
2344
2345
|
}
|
|
2345
2346
|
return { e: l, width: c, height: a };
|
|
@@ -2348,12 +2349,12 @@ const Wi = (s, t) => {
|
|
|
2348
2349
|
doraText: !0,
|
|
2349
2350
|
tsumoText: !0
|
|
2350
2351
|
}) => {
|
|
2351
|
-
const i = new
|
|
2352
|
+
const i = new Dn(e), r = Kt(i, t, n);
|
|
2352
2353
|
n.responsive || s.size(r.width, r.height), s.viewbox(0, 0, r.width, r.height), s.add(r.e);
|
|
2353
2354
|
}, Kn = () => {
|
|
2354
2355
|
const s = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], t = [];
|
|
2355
|
-
for (const e of Object.values(
|
|
2356
|
-
if (e ==
|
|
2356
|
+
for (const e of Object.values(p)) {
|
|
2357
|
+
if (e == p.BACK) {
|
|
2357
2358
|
t.push(Ot.buildID(new y(e, 0)));
|
|
2358
2359
|
continue;
|
|
2359
2360
|
}
|
|
@@ -2371,11 +2372,11 @@ const Wi = (s, t) => {
|
|
|
2371
2372
|
t.includes(a) && e.push(a);
|
|
2372
2373
|
}
|
|
2373
2374
|
}, !0), e;
|
|
2374
|
-
},
|
|
2375
|
+
}, Yo = (s) => {
|
|
2375
2376
|
const t = Kn(), e = Ki(s);
|
|
2376
2377
|
s.each((n, i) => {
|
|
2377
2378
|
const r = i[n];
|
|
2378
|
-
r instanceof
|
|
2379
|
+
r instanceof Bn && (t.includes(r.id()) && e.includes(r.id()) || r.remove());
|
|
2379
2380
|
}, !0);
|
|
2380
2381
|
}, Li = (s) => {
|
|
2381
2382
|
const e = [];
|
|
@@ -2384,23 +2385,23 @@ const Wi = (s, t) => {
|
|
|
2384
2385
|
e.push(i);
|
|
2385
2386
|
}
|
|
2386
2387
|
return e;
|
|
2387
|
-
},
|
|
2388
|
-
const o = new
|
|
2388
|
+
}, j = (s, t, e, n, i = 0, r = 0) => {
|
|
2389
|
+
const o = new N().add(s);
|
|
2389
2390
|
if (n == 90) {
|
|
2390
2391
|
const a = i, c = r - e;
|
|
2391
|
-
return o.rotate(n, 0, e).translate(a, c), new
|
|
2392
|
+
return o.rotate(n, 0, e).translate(a, c), new N().add(o);
|
|
2392
2393
|
}
|
|
2393
2394
|
if (n == 180) {
|
|
2394
2395
|
const a = i + t, c = r - e;
|
|
2395
|
-
return o.rotate(n, 0, e).translate(a, c), new
|
|
2396
|
+
return o.rotate(n, 0, e).translate(a, c), new N().add(o);
|
|
2396
2397
|
}
|
|
2397
2398
|
if (n == 270) {
|
|
2398
2399
|
const a = i + e, c = r + (t - e);
|
|
2399
|
-
return o.rotate(n, 0, e).translate(a, c), new
|
|
2400
|
+
return o.rotate(n, 0, e).translate(a, c), new N().add(o);
|
|
2400
2401
|
}
|
|
2401
|
-
return new
|
|
2402
|
+
return new N().add(o);
|
|
2402
2403
|
}, Gt = (s, t) => {
|
|
2403
|
-
const e = new
|
|
2404
|
+
const e = new N(), n = Li(s);
|
|
2404
2405
|
for (let i = 0; i < n.length; i++) {
|
|
2405
2406
|
let r = n[i], o = i * t.tileHeight;
|
|
2406
2407
|
const a = t.createBlockHandDiscard(new Sn(r, w.IMAGE_DISCARD)).translate(0, o);
|
|
@@ -2416,11 +2417,11 @@ const Wi = (s, t) => {
|
|
|
2416
2417
|
let u = i * 3, h = r;
|
|
2417
2418
|
const d = (c + s.tileWidth + i - u) / 2, g = new vt().plain(e.round).font(n).x(d).y(0);
|
|
2418
2419
|
h += 25 * s.scale;
|
|
2419
|
-
const
|
|
2420
|
-
E.add(
|
|
2420
|
+
const f = s.tileHeight, E = new N().size(c, f).translate(0, h), A = { family: n.family, size: n.size * 0.7 }, I = s.createStick(1e3).size(c, l).x(0).y(0), v = new vt().plain(a.toString()).font(A).dx(c).dy(l), x = s.createStick(100).size(c, l).x(0).y(l + l), Et = new vt().plain(o.toString()).font(A).dx(c).dy(l * 3);
|
|
2421
|
+
E.add(I), E.add(v), E.add(x), E.add(Et);
|
|
2421
2422
|
const _t = s.createImage(e.doras[0], 0, 0).x(c + i).y(0);
|
|
2422
2423
|
E.add(_t);
|
|
2423
|
-
const At = new
|
|
2424
|
+
const At = new N();
|
|
2424
2425
|
return At.add(g), At.add(g), At.add(E), {
|
|
2425
2426
|
e: At,
|
|
2426
2427
|
width: c + s.tileWidth + i,
|
|
@@ -2432,22 +2433,22 @@ const Wi = (s, t) => {
|
|
|
2432
2433
|
), c = Math.max(
|
|
2433
2434
|
e + s.tileHeight * 2 + s.blockMargin * 2,
|
|
2434
2435
|
a + s.tileWidth * 2 + s.blockMargin
|
|
2435
|
-
), l = c, u =
|
|
2436
|
+
), l = c, u = j(n.e, n.width, n.height, 0).translate(
|
|
2436
2437
|
(c - n.width) / 2,
|
|
2437
2438
|
l - n.height
|
|
2438
|
-
), h =
|
|
2439
|
+
), h = j(i.e, i.width, i.height, 270).translate(
|
|
2439
2440
|
c - i.height,
|
|
2440
2441
|
(c - i.width) / 2
|
|
2441
|
-
), d =
|
|
2442
|
+
), d = j(r.e, r.width, r.height, 180).translate(
|
|
2442
2443
|
(c - r.width) / 2,
|
|
2443
2444
|
0
|
|
2444
|
-
), g =
|
|
2445
|
+
), g = j(o.e, o.width, o.height, 90).translate(
|
|
2445
2446
|
0,
|
|
2446
2447
|
(c - o.width) / 2
|
|
2447
|
-
),
|
|
2448
|
-
return
|
|
2448
|
+
), f = new N().size(c, l);
|
|
2449
|
+
return f.add(u), f.add(h), f.add(d), f.add(g), { e: new N().add(f), width: c, height: l };
|
|
2449
2450
|
}, ji = (s) => {
|
|
2450
|
-
const t = Object.values(
|
|
2451
|
+
const t = Object.values(Be), e = t.indexOf(s);
|
|
2451
2452
|
return [...t.slice(e), ...t.slice(0, e)];
|
|
2452
2453
|
}, Fi = (s, t, e) => {
|
|
2453
2454
|
const n = s.tileWidth * 5 + s.tileHeight * 1, i = t.font, r = t.textWidth, o = t.textHeight, a = t.numWidth, c = zi(s, t, e);
|
|
@@ -2458,64 +2459,64 @@ const Wi = (s, t) => {
|
|
|
2458
2459
|
const l = (ps, qe, gs) => {
|
|
2459
2460
|
const ms = `${ps} ${qe}`, ys = new vt().plain(ms).font(i).attr(gs);
|
|
2460
2461
|
return {
|
|
2461
|
-
e: new
|
|
2462
|
+
e: new N().add(ys),
|
|
2462
2463
|
width: r + a * qe.toString().length,
|
|
2463
2464
|
height: o
|
|
2464
2465
|
};
|
|
2465
2466
|
}, [u, h, d, g] = ji(
|
|
2466
2467
|
e.frontPlace
|
|
2467
|
-
),
|
|
2468
|
+
), f = e.scores, A = l(u, f.front, {
|
|
2468
2469
|
x: n / 2,
|
|
2469
2470
|
y: n,
|
|
2470
2471
|
"dominant-baseline": "text-after-edge",
|
|
2471
2472
|
"text-anchor": "middle"
|
|
2472
2473
|
}).e;
|
|
2473
|
-
let
|
|
2474
|
+
let I = l(h, f.right, {
|
|
2474
2475
|
"dominant-baseline": "text-after-edge",
|
|
2475
2476
|
"text-anchor": "middle"
|
|
2476
2477
|
});
|
|
2477
|
-
const v =
|
|
2478
|
+
const v = j(I.e, I.width, I.height, 270).translate(
|
|
2478
2479
|
n,
|
|
2479
|
-
n / 2 -
|
|
2480
|
+
n / 2 - I.width
|
|
2480
2481
|
);
|
|
2481
|
-
let
|
|
2482
|
+
let x = l(d, f.opposite, {
|
|
2482
2483
|
"text-anchor": "middle",
|
|
2483
2484
|
"dominant-baseline": "text-after-edge"
|
|
2484
2485
|
});
|
|
2485
|
-
const Et =
|
|
2486
|
-
n / 2 -
|
|
2487
|
-
-
|
|
2486
|
+
const Et = j(x.e, x.width, x.height, 180).translate(
|
|
2487
|
+
n / 2 - x.width,
|
|
2488
|
+
-x.height
|
|
2488
2489
|
);
|
|
2489
|
-
let _t = l(g,
|
|
2490
|
+
let _t = l(g, f.left, {
|
|
2490
2491
|
"dominant-baseline": "ideographic",
|
|
2491
2492
|
"text-anchor": "middle"
|
|
2492
2493
|
});
|
|
2493
|
-
const At =
|
|
2494
|
+
const At = j(_t.e, _t.width, _t.height, 90).translate(
|
|
2494
2495
|
-_t.height,
|
|
2495
2496
|
n / 2
|
|
2496
|
-
), it = new
|
|
2497
|
+
), it = new N(), fs = new Pn().size(n, n).x(0).y(0).fill("none").stroke("#000000");
|
|
2497
2498
|
return it.add(fs), it.add(c.e), it.add(A), it.add(v), it.add(Et), it.add(At), { e: it, width: n, height: n };
|
|
2498
|
-
},
|
|
2499
|
+
}, Yi = (s, t) => {
|
|
2499
2500
|
const e = Gt(t.front, s), n = Gt(t.right, s), i = Gt(t.opposite, s), r = Gt(t.left, s), o = [e.height, n.height, i.height, r.height].reduce(
|
|
2500
|
-
(v,
|
|
2501
|
-
), a = s.tileWidth * 5 + s.tileHeight * 1, c = o, l = a + o * 2 + s.blockMargin, u = l, h = new
|
|
2501
|
+
(v, x) => Math.max(v, x)
|
|
2502
|
+
), a = s.tileWidth * 5 + s.tileHeight * 1, c = o, l = a + o * 2 + s.blockMargin, u = l, h = new N().size(l, u), d = l / 2 - a / 2, g = u / 2 - a / 2, f = j(e.e, a, c, 0).translate(
|
|
2502
2503
|
d,
|
|
2503
2504
|
u - c
|
|
2504
|
-
), E =
|
|
2505
|
+
), E = j(n.e, a, c, 270).translate(
|
|
2505
2506
|
l - c,
|
|
2506
2507
|
g
|
|
2507
|
-
), A =
|
|
2508
|
+
), A = j(
|
|
2508
2509
|
i.e,
|
|
2509
2510
|
a,
|
|
2510
2511
|
c,
|
|
2511
2512
|
180
|
|
2512
|
-
).translate(d, 0),
|
|
2513
|
+
).translate(d, 0), I = j(r.e, a, c, 90).translate(
|
|
2513
2514
|
0,
|
|
2514
2515
|
g
|
|
2515
2516
|
);
|
|
2516
|
-
return h.add(
|
|
2517
|
+
return h.add(f), h.add(E), h.add(A), h.add(I), { e: new N().add(h), width: l, height: u };
|
|
2517
2518
|
}, Gi = (s, t, e, n, i) => {
|
|
2518
|
-
const r = new
|
|
2519
|
+
const r = new N(), o = Yi(s, n), a = Ui(s, e, o.height), c = Fi(s, t, i);
|
|
2519
2520
|
return o.e.translate(
|
|
2520
2521
|
(a.width - o.width) / 2,
|
|
2521
2522
|
(a.height - o.height) / 2
|
|
@@ -2524,7 +2525,7 @@ const Wi = (s, t) => {
|
|
|
2524
2525
|
(a.height - c.height) / 2
|
|
2525
2526
|
), r.add(a.e), r.add(o.e), r.add(c.e), { e: r, width: a.width, height: a.height };
|
|
2526
2527
|
}, Go = (s, t, e = {}, n, i = { responsive: !1 }) => {
|
|
2527
|
-
const r = new
|
|
2528
|
+
const r = new Dn(e), o = n, { discards: a, hands: c, scoreBoard: l } = or(t), u = Gi(r, o, c, a, l);
|
|
2528
2529
|
i.responsive || s.size(u.width, u.height), s.viewbox(0, 0, u.width, u.height), s.add(u.e);
|
|
2529
2530
|
};
|
|
2530
2531
|
var Ee;
|
|
@@ -2537,10 +2538,10 @@ function Ln(s) {
|
|
|
2537
2538
|
abortPipeEarly: s?.abortPipeEarly ?? Ee?.abortPipeEarly
|
|
2538
2539
|
};
|
|
2539
2540
|
}
|
|
2540
|
-
var
|
|
2541
|
+
var Zi;
|
|
2541
2542
|
// @__NO_SIDE_EFFECTS__
|
|
2542
2543
|
function Vi(s) {
|
|
2543
|
-
return
|
|
2544
|
+
return Zi?.get(s);
|
|
2544
2545
|
}
|
|
2545
2546
|
var Ji;
|
|
2546
2547
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -2664,11 +2665,11 @@ function ie(s) {
|
|
|
2664
2665
|
};
|
|
2665
2666
|
}
|
|
2666
2667
|
// @__NO_SIDE_EFFECTS__
|
|
2667
|
-
function
|
|
2668
|
+
function z(s, t) {
|
|
2668
2669
|
return {
|
|
2669
2670
|
kind: "schema",
|
|
2670
2671
|
type: "optional",
|
|
2671
|
-
reference:
|
|
2672
|
+
reference: z,
|
|
2672
2673
|
expects: `(${s.expects} | undefined)`,
|
|
2673
2674
|
async: !1,
|
|
2674
2675
|
wrapped: s,
|
|
@@ -2832,45 +2833,45 @@ function nr(s, t, e) {
|
|
|
2832
2833
|
issues: n.issues
|
|
2833
2834
|
};
|
|
2834
2835
|
}
|
|
2835
|
-
const
|
|
2836
|
+
const Zt = /* @__PURE__ */ z(
|
|
2836
2837
|
/* @__PURE__ */ Ct({
|
|
2837
|
-
discard: /* @__PURE__ */
|
|
2838
|
-
hand: /* @__PURE__ */
|
|
2839
|
-
score: /* @__PURE__ */
|
|
2838
|
+
discard: /* @__PURE__ */ z(/* @__PURE__ */ re(), ""),
|
|
2839
|
+
hand: /* @__PURE__ */ z(/* @__PURE__ */ re(), ""),
|
|
2840
|
+
score: /* @__PURE__ */ z(/* @__PURE__ */ ie(), 25e3)
|
|
2840
2841
|
}),
|
|
2841
2842
|
{ discard: "", hand: "", score: 25e3 }
|
|
2842
2843
|
), sr = /* @__PURE__ */ Ct({
|
|
2843
|
-
[_.E]:
|
|
2844
|
-
[_.S]:
|
|
2845
|
-
[_.W]:
|
|
2846
|
-
[_.N]:
|
|
2844
|
+
[_.E]: Zt,
|
|
2845
|
+
[_.S]: Zt,
|
|
2846
|
+
[_.W]: Zt,
|
|
2847
|
+
[_.N]: Zt
|
|
2847
2848
|
}), ot = {
|
|
2848
2849
|
round: O.E1,
|
|
2849
2850
|
sticks: { reach: 0, dead: 0 },
|
|
2850
2851
|
doras: _.S,
|
|
2851
2852
|
front: _.E
|
|
2852
|
-
}, ir = /* @__PURE__ */
|
|
2853
|
+
}, ir = /* @__PURE__ */ z(
|
|
2853
2854
|
/* @__PURE__ */ Ct({
|
|
2854
|
-
round: /* @__PURE__ */
|
|
2855
|
-
/* @__PURE__ */ Oe(Object.keys(
|
|
2855
|
+
round: /* @__PURE__ */ z(
|
|
2856
|
+
/* @__PURE__ */ Oe(Object.keys(Tn)),
|
|
2856
2857
|
ot.round
|
|
2857
2858
|
),
|
|
2858
|
-
sticks: /* @__PURE__ */
|
|
2859
|
+
sticks: /* @__PURE__ */ z(
|
|
2859
2860
|
/* @__PURE__ */ Ct({
|
|
2860
|
-
reach: /* @__PURE__ */
|
|
2861
|
+
reach: /* @__PURE__ */ z(
|
|
2861
2862
|
/* @__PURE__ */ hn(/* @__PURE__ */ ie(), /* @__PURE__ */ Se(0, ""), /* @__PURE__ */ ve(9, "")),
|
|
2862
2863
|
ot.sticks.reach
|
|
2863
2864
|
),
|
|
2864
|
-
dead: /* @__PURE__ */
|
|
2865
|
+
dead: /* @__PURE__ */ z(
|
|
2865
2866
|
/* @__PURE__ */ hn(/* @__PURE__ */ ie(), /* @__PURE__ */ Se(0, ""), /* @__PURE__ */ ve(9, "")),
|
|
2866
2867
|
ot.sticks.dead
|
|
2867
2868
|
)
|
|
2868
2869
|
}),
|
|
2869
2870
|
ot.sticks
|
|
2870
2871
|
),
|
|
2871
|
-
doras: /* @__PURE__ */
|
|
2872
|
-
front: /* @__PURE__ */
|
|
2873
|
-
/* @__PURE__ */ Oe(Object.keys(
|
|
2872
|
+
doras: /* @__PURE__ */ z(/* @__PURE__ */ re(), ot.doras),
|
|
2873
|
+
front: /* @__PURE__ */ z(
|
|
2874
|
+
/* @__PURE__ */ Oe(Object.keys(Be)),
|
|
2874
2875
|
ot.front
|
|
2875
2876
|
)
|
|
2876
2877
|
}),
|
|
@@ -2911,14 +2912,14 @@ const Yt = /* @__PURE__ */ K(
|
|
|
2911
2912
|
}
|
|
2912
2913
|
}
|
|
2913
2914
|
return r;
|
|
2914
|
-
},
|
|
2915
|
+
}, V = (s, t) => s.replace(t, "").replace(":", "").trim(), lr = (s) => {
|
|
2915
2916
|
const t = "hand", e = "discard", n = "score", i = {};
|
|
2916
2917
|
let r = 0;
|
|
2917
2918
|
for (; r < s.length; r++) {
|
|
2918
2919
|
const o = s[r];
|
|
2919
|
-
if (o.startsWith(t)) i.hand =
|
|
2920
|
-
else if (o.startsWith(e)) i.discard =
|
|
2921
|
-
else if (o.startsWith(n)) i.score = Number(
|
|
2920
|
+
if (o.startsWith(t)) i.hand = V(o, t);
|
|
2921
|
+
else if (o.startsWith(e)) i.discard = V(o, e);
|
|
2922
|
+
else if (o.startsWith(n)) i.score = Number(V(o, n));
|
|
2922
2923
|
else break;
|
|
2923
2924
|
}
|
|
2924
2925
|
return [i, r];
|
|
@@ -2928,34 +2929,34 @@ const Yt = /* @__PURE__ */ K(
|
|
|
2928
2929
|
for (; c < s.length; c++) {
|
|
2929
2930
|
const l = s[c];
|
|
2930
2931
|
if (l.startsWith(t))
|
|
2931
|
-
a.doras =
|
|
2932
|
+
a.doras = V(l, t);
|
|
2932
2933
|
else if (l.startsWith(e))
|
|
2933
|
-
a.round =
|
|
2934
|
+
a.round = V(l, e);
|
|
2934
2935
|
else if (l.startsWith(n))
|
|
2935
|
-
a.front =
|
|
2936
|
+
a.front = V(l, n);
|
|
2936
2937
|
else if (l.startsWith(i)) {
|
|
2937
2938
|
a.sticks = {};
|
|
2938
2939
|
const u = s[c + 1] ?? "", h = s[c + 2] ?? "";
|
|
2939
|
-
u.startsWith(r) && (a.sticks.reach = Number(
|
|
2940
|
+
u.startsWith(r) && (a.sticks.reach = Number(V(u, r))), u.startsWith(o) && (a.sticks.dead = Number(V(u, o))), h.startsWith(r) && (a.sticks.reach = Number(V(h, r))), h.startsWith(o) && (a.sticks.dead = Number(V(h, o))), a.sticks.dead != null && c++, a.sticks.reach != null && c++;
|
|
2940
2941
|
} else break;
|
|
2941
2942
|
}
|
|
2942
2943
|
return [a, c];
|
|
2943
2944
|
}, ur = (s) => {
|
|
2944
2945
|
const t = s.board.front, e = dr(t), n = (a) => s[a].discard.replace(/\r?\n/g, ""), i = {
|
|
2945
|
-
front: new
|
|
2946
|
-
right: new
|
|
2947
|
-
opposite: new
|
|
2948
|
-
left: new
|
|
2946
|
+
front: new K(n(e.front)).tiles(),
|
|
2947
|
+
right: new K(n(e.right)).tiles(),
|
|
2948
|
+
opposite: new K(n(e.opposite)).tiles(),
|
|
2949
|
+
left: new K(n(e.left)).tiles()
|
|
2949
2950
|
}, r = {
|
|
2950
|
-
front: new
|
|
2951
|
-
right: new
|
|
2952
|
-
opposite: new
|
|
2953
|
-
left: new
|
|
2951
|
+
front: new K(s[e.front].hand).parse(),
|
|
2952
|
+
right: new K(s[e.right].hand).parse(),
|
|
2953
|
+
opposite: new K(s[e.opposite].hand).parse(),
|
|
2954
|
+
left: new K(s[e.left].hand).parse()
|
|
2954
2955
|
}, o = {
|
|
2955
|
-
round:
|
|
2956
|
-
frontPlace:
|
|
2956
|
+
round: Tn[s.board.round],
|
|
2957
|
+
frontPlace: Be[t],
|
|
2957
2958
|
sticks: s.board.sticks,
|
|
2958
|
-
doras: new
|
|
2959
|
+
doras: new K(s.board.doras).tiles(),
|
|
2959
2960
|
scores: {
|
|
2960
2961
|
front: s[e.front].score,
|
|
2961
2962
|
right: s[e.right].score,
|
|
@@ -2966,15 +2967,15 @@ const Yt = /* @__PURE__ */ K(
|
|
|
2966
2967
|
return { discards: i, hands: r, scoreBoard: o };
|
|
2967
2968
|
}, dr = (s) => ({
|
|
2968
2969
|
front: s,
|
|
2969
|
-
right:
|
|
2970
|
-
opposite:
|
|
2971
|
-
left:
|
|
2970
|
+
right: Tt(s),
|
|
2971
|
+
opposite: Tt(Tt(s)),
|
|
2972
|
+
left: De(s)
|
|
2972
2973
|
});
|
|
2973
|
-
function*
|
|
2974
|
-
const t = s?.filterBy && s.filterBy.length > 0 ? s?.filterBy : Object.values(
|
|
2974
|
+
function* F(s) {
|
|
2975
|
+
const t = s?.filterBy && s.filterBy.length > 0 ? s?.filterBy : Object.values(p);
|
|
2975
2976
|
for (const e of t) {
|
|
2976
|
-
if (s?.skipBack && e ==
|
|
2977
|
-
const n = e ==
|
|
2977
|
+
if (s?.skipBack && e == p.BACK) continue;
|
|
2978
|
+
const n = e == p.Z ? 7 : e == p.BACK ? 1 : 9;
|
|
2978
2979
|
for (let i = 1; i <= n; i++)
|
|
2979
2980
|
yield [e, i];
|
|
2980
2981
|
}
|
|
@@ -2983,18 +2984,18 @@ class ze {
|
|
|
2983
2984
|
data;
|
|
2984
2985
|
constructor(t, e = !1) {
|
|
2985
2986
|
this.data = {
|
|
2986
|
-
[
|
|
2987
|
-
[
|
|
2988
|
-
[
|
|
2989
|
-
[
|
|
2990
|
-
[
|
|
2987
|
+
[p.M]: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
2988
|
+
[p.P]: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
2989
|
+
[p.S]: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
2990
|
+
[p.Z]: [0, 0, 0, 0, 0, 0, 0, 0],
|
|
2991
|
+
[p.BACK]: ["untouchable", 0],
|
|
2991
2992
|
called: [],
|
|
2992
2993
|
reached: !1,
|
|
2993
2994
|
tsumo: null
|
|
2994
2995
|
}, this.init(t, e);
|
|
2995
2996
|
}
|
|
2996
2997
|
init(t, e) {
|
|
2997
|
-
const n = Array.isArray(t) ? t : new
|
|
2998
|
+
const n = Array.isArray(t) ? t : new K(t).parse();
|
|
2998
2999
|
for (const i of n) {
|
|
2999
3000
|
if (i.isCalled()) {
|
|
3000
3001
|
this.data.called = [...this.called, i];
|
|
@@ -3006,7 +3007,7 @@ class ze {
|
|
|
3006
3007
|
} else if (i.is(w.HAND)) {
|
|
3007
3008
|
this.inc(i.tiles);
|
|
3008
3009
|
continue;
|
|
3009
|
-
} else if (!Array.isArray(t) && t.split("").every((r) => r ===
|
|
3010
|
+
} else if (!Array.isArray(t) && t.split("").every((r) => r === p.BACK)) {
|
|
3010
3011
|
this.inc(i.tiles);
|
|
3011
3012
|
continue;
|
|
3012
3013
|
} else if (e) {
|
|
@@ -3021,9 +3022,9 @@ class ze {
|
|
|
3021
3022
|
*/
|
|
3022
3023
|
get hands() {
|
|
3023
3024
|
const t = [];
|
|
3024
|
-
for (const [e, n] of
|
|
3025
|
+
for (const [e, n] of F()) {
|
|
3025
3026
|
let i = this.get(e, n);
|
|
3026
|
-
e !=
|
|
3027
|
+
e != p.Z && n == 5 && this.get(e, 0) > 0 && (i -= this.get(e, 0), t.push(new y(e, n, [m.RED])));
|
|
3027
3028
|
for (let r = 0; r < i; r++)
|
|
3028
3029
|
t.push(new y(e, n));
|
|
3029
3030
|
}
|
|
@@ -3033,7 +3034,9 @@ class ze {
|
|
|
3033
3034
|
);
|
|
3034
3035
|
b(
|
|
3035
3036
|
n >= 0,
|
|
3036
|
-
`
|
|
3037
|
+
`drawn tile exists: ${this.drawn} but no tile in hand: ${t.join(
|
|
3038
|
+
""
|
|
3039
|
+
)}`
|
|
3037
3040
|
), t[n] = t[n].clone({ add: m.TSUMO });
|
|
3038
3041
|
}
|
|
3039
3042
|
return t;
|
|
@@ -3067,14 +3070,14 @@ class ze {
|
|
|
3067
3070
|
* 面前かどうかを返す。
|
|
3068
3071
|
*/
|
|
3069
3072
|
get menzen() {
|
|
3070
|
-
return !this.called.some((t) => !(t instanceof
|
|
3073
|
+
return !this.called.some((t) => !(t instanceof C));
|
|
3071
3074
|
}
|
|
3072
3075
|
/**
|
|
3073
3076
|
* 手牌において、指定した牌の種類の合計枚数を返す
|
|
3074
3077
|
*/
|
|
3075
3078
|
sum(t) {
|
|
3076
3079
|
let e = 0;
|
|
3077
|
-
for (const [n, i] of
|
|
3080
|
+
for (const [n, i] of F({ filterBy: [t] })) e += this.get(n, i);
|
|
3078
3081
|
return e;
|
|
3079
3082
|
}
|
|
3080
3083
|
/**
|
|
@@ -3082,7 +3085,7 @@ class ze {
|
|
|
3082
3085
|
* 赤のみを取得する場合は n に 0 を指定する。
|
|
3083
3086
|
*/
|
|
3084
3087
|
get(t, e) {
|
|
3085
|
-
return t ==
|
|
3088
|
+
return t == p.BACK ? this.data[t][1] : this.data[t][e];
|
|
3086
3089
|
}
|
|
3087
3090
|
/**
|
|
3088
3091
|
* 指定した牌を手牌に加える。draw に比べプリミティブな操作となる。
|
|
@@ -3090,13 +3093,13 @@ class ze {
|
|
|
3090
3093
|
inc(t) {
|
|
3091
3094
|
const e = [];
|
|
3092
3095
|
for (const n of t) {
|
|
3093
|
-
const i = n.t !=
|
|
3096
|
+
const i = n.t != p.BACK && this.get(n.t, n.n) >= 4, r = n.has(m.RED) && this.get(n.t, 0) > 0;
|
|
3094
3097
|
if (i || r) {
|
|
3095
3098
|
this.dec(e);
|
|
3096
3099
|
const o = i ? `tile ${n} exists more than 4 times` : `red tile ${n} appears more than 1 times`;
|
|
3097
|
-
throw new Error(`invalid hand: ${o} in ${this.toString()}`);
|
|
3100
|
+
throw new Error(`invalid hand: ${o} in hand: ${this.toString()}`);
|
|
3098
3101
|
}
|
|
3099
|
-
e.push(n), n.t ==
|
|
3102
|
+
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));
|
|
3100
3103
|
}
|
|
3101
3104
|
return e;
|
|
3102
3105
|
}
|
|
@@ -3109,10 +3112,10 @@ class ze {
|
|
|
3109
3112
|
const i = this.get(n.t, n.n) < 1, r = n.has(m.RED) && this.get(n.t, 0) <= 0;
|
|
3110
3113
|
if (i || r) {
|
|
3111
3114
|
this.inc(e);
|
|
3112
|
-
const o = i ? `tile ${n} is not
|
|
3113
|
-
throw new Error(`invalid hand: ${o} in ${this.toString()}`);
|
|
3115
|
+
const o = i ? `tile ${n} is not` : `red tile ${n} is not`;
|
|
3116
|
+
throw new Error(`invalid hand: ${o} in hand: ${this.toString()}`);
|
|
3114
3117
|
}
|
|
3115
|
-
if (e.push(n), n.t ==
|
|
3118
|
+
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)), k(n) && this.get(n.t, 5) == 0 && this.get(n.t, 0) > 0) {
|
|
3116
3119
|
this.data[n.t][0] = 0;
|
|
3117
3120
|
const o = e.pop().clone({ add: m.RED });
|
|
3118
3121
|
e.push(o);
|
|
@@ -3147,23 +3150,25 @@ class ze {
|
|
|
3147
3150
|
call(t) {
|
|
3148
3151
|
const e = t.tiles.filter((n) => !n.has(m.HORIZONTAL));
|
|
3149
3152
|
if (e.length != t.tiles.length - 1)
|
|
3150
|
-
throw new Error(`removal: ${e} block: ${t}`);
|
|
3153
|
+
throw new Error(`invalid block: removal tiles: ${e}, block: ${t}`);
|
|
3151
3154
|
this.dec(e), this.data.called = [...this.called, t], this.data.tsumo = null;
|
|
3152
3155
|
}
|
|
3153
3156
|
/**
|
|
3154
3157
|
* ツモした牌を指定したブロックでカンする。鳴く牌はブロック内で表現する。
|
|
3155
3158
|
*/
|
|
3156
3159
|
kan(t) {
|
|
3157
|
-
if (t instanceof
|
|
3160
|
+
if (t instanceof C) {
|
|
3158
3161
|
this.dec(t.tiles), this.data.called = [...this.called, t], this.data.tsumo = null;
|
|
3159
3162
|
return;
|
|
3160
3163
|
}
|
|
3161
|
-
if (t instanceof
|
|
3164
|
+
if (t instanceof W) {
|
|
3162
3165
|
const e = this.data.called.findIndex(
|
|
3163
3166
|
(i) => i.is(w.PON) && i.tiles[0].equals(t.tiles[0])
|
|
3164
|
-
// FIXME handle which tile is called
|
|
3165
3167
|
);
|
|
3166
|
-
if (e == -1)
|
|
3168
|
+
if (e == -1)
|
|
3169
|
+
throw new Error(
|
|
3170
|
+
`unable to find pon block ${t.tiles[0]} for shokan: ${t}`
|
|
3171
|
+
);
|
|
3167
3172
|
let n = t.tiles[0];
|
|
3168
3173
|
n = k(n) ? n.clone({ remove: m.RED }) : n, this.dec([n]), this.data.called = [
|
|
3169
3174
|
...this.called.slice(0, e),
|
|
@@ -3198,9 +3203,9 @@ class ge {
|
|
|
3198
3203
|
* 七対子のシャンテン数を返す。
|
|
3199
3204
|
*/
|
|
3200
3205
|
sevenPairs() {
|
|
3201
|
-
if (this.hand.called.length > 0) return
|
|
3206
|
+
if (this.hand.called.length > 0) return Number.POSITIVE_INFINITY;
|
|
3202
3207
|
let t = 0, e = 0;
|
|
3203
|
-
for (const [n, i] of
|
|
3208
|
+
for (const [n, i] of F({ skipBack: !0 }))
|
|
3204
3209
|
this.hand.get(n, i) == 2 && t++, this.hand.get(n, i) == 1 && e++;
|
|
3205
3210
|
return t > 7 && (t = 7), t + e >= 7 && (e = 7 - t), 13 - 2 * t - e;
|
|
3206
3211
|
}
|
|
@@ -3208,11 +3213,11 @@ class ge {
|
|
|
3208
3213
|
* 国士無双のシャンテン数を返す。
|
|
3209
3214
|
*/
|
|
3210
3215
|
thirteenOrphans() {
|
|
3211
|
-
if (this.hand.called.length > 0) return
|
|
3216
|
+
if (this.hand.called.length > 0) return Number.POSITIVE_INFINITY;
|
|
3212
3217
|
let t = 0, e = 0;
|
|
3213
|
-
for (const n of Object.values(
|
|
3214
|
-
if (n ==
|
|
3215
|
-
const i = n ==
|
|
3218
|
+
for (const n of Object.values(p)) {
|
|
3219
|
+
if (n == p.BACK) continue;
|
|
3220
|
+
const i = n == p.Z ? jt : X;
|
|
3216
3221
|
for (const r of i)
|
|
3217
3222
|
this.hand.get(n, r) >= 1 && t++, this.hand.get(n, r) >= 2 && e++;
|
|
3218
3223
|
}
|
|
@@ -3224,25 +3229,25 @@ class ge {
|
|
|
3224
3229
|
standardType() {
|
|
3225
3230
|
const t = (n) => {
|
|
3226
3231
|
const i = [0, 0, 0];
|
|
3227
|
-
for (const [d, g] of
|
|
3232
|
+
for (const [d, g] of F({ filterBy: [p.Z] }))
|
|
3228
3233
|
this.hand.get(d, g) >= 3 ? i[0]++ : this.hand.get(d, g) == 2 ? i[1]++ : this.hand.get(d, g) == 1 && i[2]++;
|
|
3229
|
-
const r = [0, 0, 0], o = this.hand.get(
|
|
3234
|
+
const r = [0, 0, 0], o = this.hand.get(p.BACK, 0), a = o % 3;
|
|
3230
3235
|
r[0] = Math.floor(o / 3), a == 2 ? r[1] = 1 : a == 1 && (r[2] = 1);
|
|
3231
3236
|
let c = 13;
|
|
3232
|
-
const l = this.calcNumberTilePatterns(
|
|
3237
|
+
const l = this.calcNumberTilePatterns(p.M), u = this.calcNumberTilePatterns(p.P), h = this.calcNumberTilePatterns(p.S);
|
|
3233
3238
|
for (const d of [l.patternA, l.patternB])
|
|
3234
3239
|
for (const g of [u.patternA, u.patternB])
|
|
3235
|
-
for (const
|
|
3240
|
+
for (const f of [h.patternA, h.patternB]) {
|
|
3236
3241
|
const E = [this.hand.called.length, 0, 0];
|
|
3237
|
-
for (let
|
|
3238
|
-
E[
|
|
3239
|
-
const A = this.
|
|
3242
|
+
for (let I = 0; I < 3; I++)
|
|
3243
|
+
E[I] += d[I] + g[I] + f[I] + i[I] + r[I];
|
|
3244
|
+
const A = this.getStandardTypeShanten(E[0], E[1], E[2], n);
|
|
3240
3245
|
A < c && (c = A);
|
|
3241
3246
|
}
|
|
3242
3247
|
return c;
|
|
3243
3248
|
};
|
|
3244
3249
|
let e = t(!1);
|
|
3245
|
-
for (const [n, i] of
|
|
3250
|
+
for (const [n, i] of F())
|
|
3246
3251
|
if (this.hand.get(n, i) >= 2) {
|
|
3247
3252
|
const r = this.hand.dec(new Array(2).fill(new y(n, i))), o = t(!0);
|
|
3248
3253
|
this.hand.inc(r), o < e && (e = o);
|
|
@@ -3268,14 +3273,14 @@ class ge {
|
|
|
3268
3273
|
}
|
|
3269
3274
|
groupRemainingTiles(t) {
|
|
3270
3275
|
let e = 0, n = 0, i = 0;
|
|
3271
|
-
for (const [r, o] of
|
|
3276
|
+
for (const [r, o] of F({ filterBy: [t] }))
|
|
3272
3277
|
i += this.hand.get(r, o), o <= 7 && this.hand.get(r, o + 1) == 0 && this.hand.get(r, o + 2) == 0 && (e += i >> 1, n += i % 2, i = 0);
|
|
3273
3278
|
return e += i >> 1, n += i % 2, {
|
|
3274
3279
|
patternA: [0, e, n],
|
|
3275
3280
|
patternB: [0, e, n]
|
|
3276
3281
|
};
|
|
3277
3282
|
}
|
|
3278
|
-
|
|
3283
|
+
getStandardTypeShanten(t, e, n, i) {
|
|
3279
3284
|
let r = i ? 4 : 5;
|
|
3280
3285
|
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;
|
|
3281
3286
|
}
|
|
@@ -3304,11 +3309,7 @@ class fr {
|
|
|
3304
3309
|
* あがりの形になりうる手牌の構成の配列に対して、最後のあがり牌を考慮したあがりの形になりうる手牌の構成の配列を返す。
|
|
3305
3310
|
*/
|
|
3306
3311
|
markedHands(t, e) {
|
|
3307
|
-
|
|
3308
|
-
const n = [];
|
|
3309
|
-
for (let i = 0; i < t.length; i++)
|
|
3310
|
-
n.push(...this.markedHand(t[i], e));
|
|
3311
|
-
return n;
|
|
3312
|
+
return t.length == 0 ? [] : t.map((n) => this.markedHand(n, e)).flat();
|
|
3312
3313
|
}
|
|
3313
3314
|
/**
|
|
3314
3315
|
* あがりの形になりうる手牌の構成に対して、最後のあがり牌を考慮したあがりの形になりうる手牌の構成の配列を返す。
|
|
@@ -3346,15 +3347,13 @@ class fr {
|
|
|
3346
3347
|
sevenPairs() {
|
|
3347
3348
|
if (this.hand.called.length > 0) return [];
|
|
3348
3349
|
const t = [];
|
|
3349
|
-
for (const [e, n] of
|
|
3350
|
+
for (const [e, n] of F({ skipBack: !0 })) {
|
|
3350
3351
|
const i = this.hand.get(e, n);
|
|
3351
|
-
if (i
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
return [];
|
|
3357
|
-
}
|
|
3352
|
+
if (i != 0)
|
|
3353
|
+
if (i == 2) {
|
|
3354
|
+
const r = this.hand.dec(new Array(2).fill(new y(e, n)));
|
|
3355
|
+
t.push(new R(r[0], r[1])), this.hand.inc(r);
|
|
3356
|
+
} else return [];
|
|
3358
3357
|
}
|
|
3359
3358
|
return [t];
|
|
3360
3359
|
}
|
|
@@ -3365,14 +3364,14 @@ class fr {
|
|
|
3365
3364
|
thirteenOrphans() {
|
|
3366
3365
|
const t = [];
|
|
3367
3366
|
let e = !1;
|
|
3368
|
-
for (const n of Object.values(
|
|
3369
|
-
if (n ==
|
|
3370
|
-
const i = n ==
|
|
3367
|
+
for (const n of Object.values(p)) {
|
|
3368
|
+
if (n == p.BACK) continue;
|
|
3369
|
+
const i = n == p.Z ? jt : X;
|
|
3371
3370
|
for (let r of i)
|
|
3372
3371
|
if (this.hand.get(n, r) == 1)
|
|
3373
3372
|
t.push(new vn(new y(n, r)));
|
|
3374
3373
|
else if (this.hand.get(n, r) == 2 && e == !1)
|
|
3375
|
-
t.unshift(new
|
|
3374
|
+
t.unshift(new R(new y(n, r), new y(n, r))), e = !0;
|
|
3376
3375
|
else return [];
|
|
3377
3376
|
}
|
|
3378
3377
|
return [t];
|
|
@@ -3383,8 +3382,8 @@ class fr {
|
|
|
3383
3382
|
*/
|
|
3384
3383
|
nineGates() {
|
|
3385
3384
|
const t = (e, n, i) => i.includes(this.hand.get(e, n));
|
|
3386
|
-
for (const e of Object.values(
|
|
3387
|
-
if (e ==
|
|
3385
|
+
for (const e of Object.values(p)) {
|
|
3386
|
+
if (e == p.BACK || e == p.Z) continue;
|
|
3388
3387
|
const n = t(e, 1, [3, 4]) && t(e, 9, [3, 4]) && t(e, 2, [1, 2]) && t(e, 3, [1, 2]) && t(e, 4, [1, 2]) && t(e, 5, [1, 2]) && t(e, 6, [1, 2]) && t(e, 7, [1, 2]) && t(e, 8, [1, 2]), i = this.hand.sum(e) == 14;
|
|
3389
3388
|
if (n && i)
|
|
3390
3389
|
return [[new Ut(this.hand.hands)]];
|
|
@@ -3397,20 +3396,20 @@ class fr {
|
|
|
3397
3396
|
*/
|
|
3398
3397
|
standardType() {
|
|
3399
3398
|
let t = [];
|
|
3400
|
-
for (const [e, n] of
|
|
3399
|
+
for (const [e, n] of F())
|
|
3401
3400
|
if (this.hand.get(e, n) >= 2) {
|
|
3402
3401
|
const i = new Array(2).fill(new y(e, n));
|
|
3403
3402
|
n == 5 && this.hand.get(e, 0) > 0 && this.hand.get(e, n) >= 3 && (i[1] = new y(e, n, [m.RED]));
|
|
3404
|
-
const r = this.hand.dec(i), o = this.calcAllBlockCombinations().filter((a) => a.length == 4).map((a) => (a.unshift(new
|
|
3403
|
+
const r = this.hand.dec(i), o = this.calcAllBlockCombinations().filter((a) => a.length == 4).map((a) => (a.unshift(new R(r[0], r[1])), a));
|
|
3405
3404
|
t = [...t, ...o], this.hand.inc(r);
|
|
3406
3405
|
}
|
|
3407
3406
|
return t;
|
|
3408
3407
|
}
|
|
3409
3408
|
calcAllBlockCombinations() {
|
|
3410
3409
|
return [
|
|
3411
|
-
this.addRedPatterns(
|
|
3412
|
-
this.addRedPatterns(
|
|
3413
|
-
this.addRedPatterns(
|
|
3410
|
+
this.addRedPatterns(p.M, this.handleNumType(p.M)),
|
|
3411
|
+
this.addRedPatterns(p.P, this.handleNumType(p.P)),
|
|
3412
|
+
this.addRedPatterns(p.S, this.handleNumType(p.S)),
|
|
3414
3413
|
this.handleZ(),
|
|
3415
3414
|
this.handleBack(),
|
|
3416
3415
|
[this.hand.called.concat()]
|
|
@@ -3421,18 +3420,18 @@ class fr {
|
|
|
3421
3420
|
}
|
|
3422
3421
|
// handle back tiles as same unknown tiles, Not joker tile.
|
|
3423
3422
|
handleBack() {
|
|
3424
|
-
const t =
|
|
3423
|
+
const t = p.BACK, e = this.hand.get(t, 0);
|
|
3425
3424
|
if (e < 3) return [];
|
|
3426
|
-
const n = new y(t, 0), i = Array(Math.floor(e / 3)).fill(new
|
|
3425
|
+
const n = new y(t, 0), i = Array(Math.floor(e / 3)).fill(new L([n, n, n]));
|
|
3427
3426
|
return i.length == 0 ? [] : [i];
|
|
3428
3427
|
}
|
|
3429
3428
|
handleZ() {
|
|
3430
3429
|
const t = [];
|
|
3431
|
-
for (const [e, n] of
|
|
3430
|
+
for (const [e, n] of F({ filterBy: [p.Z] })) {
|
|
3432
3431
|
if (this.hand.get(e, n) == 0) continue;
|
|
3433
3432
|
if (this.hand.get(e, n) != 3) return [];
|
|
3434
3433
|
const i = new y(e, n);
|
|
3435
|
-
t.push(new
|
|
3434
|
+
t.push(new L([i, i, i]));
|
|
3436
3435
|
}
|
|
3437
3436
|
return t.length == 0 ? [] : [t];
|
|
3438
3437
|
}
|
|
@@ -3444,7 +3443,7 @@ class fr {
|
|
|
3444
3443
|
let o = null;
|
|
3445
3444
|
const a = {};
|
|
3446
3445
|
for (let l = 0; l < e.length; l++) {
|
|
3447
|
-
const u = e[l], h = u.tiles.findIndex((
|
|
3446
|
+
const u = e[l], h = u.tiles.findIndex((f) => k(f) && !f.has(m.RED)), d = u.tiles.findIndex((f) => k(f) && f.has(m.RED));
|
|
3448
3447
|
if (d > -1 && (o = [l, d]), d > -1 && h > -1 || h < 0) continue;
|
|
3449
3448
|
const g = Lt(u);
|
|
3450
3449
|
a[g] || (a[g] = !0, r.push([l, h]));
|
|
@@ -3468,13 +3467,7 @@ class fr {
|
|
|
3468
3467
|
*/
|
|
3469
3468
|
// TODO similar to markDrawn
|
|
3470
3469
|
addRedPatterns(t, e) {
|
|
3471
|
-
|
|
3472
|
-
const n = [];
|
|
3473
|
-
for (let i = 0; i < e.length; i++) {
|
|
3474
|
-
const r = e[i];
|
|
3475
|
-
n.push(...this.addRedPattern(t, r));
|
|
3476
|
-
}
|
|
3477
|
-
return n;
|
|
3470
|
+
return this.hand.get(t, 0) > 0 && this.hand.get(t, 5) >= 2 ? e.map((n) => this.addRedPattern(t, n)).flat() : e;
|
|
3478
3471
|
}
|
|
3479
3472
|
handleNumType(t, e = 1) {
|
|
3480
3473
|
if (e > 9) return [];
|
|
@@ -3497,23 +3490,23 @@ class fr {
|
|
|
3497
3490
|
let r = this.handleNumType(t, e);
|
|
3498
3491
|
this.hand.inc(i), r.length == 0 && (r = [[]]);
|
|
3499
3492
|
for (const o of r)
|
|
3500
|
-
o.unshift(new
|
|
3493
|
+
o.unshift(new L([i[0], i[1], i[2]])), n.push(o);
|
|
3501
3494
|
}
|
|
3502
3495
|
return n;
|
|
3503
3496
|
}
|
|
3504
3497
|
}
|
|
3505
|
-
const jt = [1, 2, 3, 4, 5, 6, 7],
|
|
3498
|
+
const jt = [1, 2, 3, 4, 5, 6, 7], X = [1, 9], Vt = (s) => {
|
|
3506
3499
|
const t = s.boardContext;
|
|
3507
3500
|
return {
|
|
3508
3501
|
...s,
|
|
3509
|
-
hand: s.hand.map(
|
|
3502
|
+
hand: s.hand.map(T.deserialize),
|
|
3510
3503
|
boardContext: {
|
|
3511
3504
|
...t,
|
|
3512
3505
|
doraIndicators: t.doraIndicators.map(y.from),
|
|
3513
3506
|
hiddenDoraIndicators: t.hiddenDoraIndicators?.map(y.from)
|
|
3514
3507
|
}
|
|
3515
3508
|
};
|
|
3516
|
-
}, ke = (s) => JSON.parse(JSON.stringify(s)),
|
|
3509
|
+
}, ke = (s) => JSON.parse(JSON.stringify(s)), M = {
|
|
3517
3510
|
MANGAN: 2e3,
|
|
3518
3511
|
HANEMAN: 3e3,
|
|
3519
3512
|
DOUBLE: 4e3,
|
|
@@ -3523,18 +3516,18 @@ const jt = [1, 2, 3, 4, 5, 6, 7], V = [1, 9], Vt = (s) => {
|
|
|
3523
3516
|
DEAD_STICK: 300,
|
|
3524
3517
|
REACH_STICK: 1e3
|
|
3525
3518
|
}, pr = [
|
|
3526
|
-
{ minHan: 26, points:
|
|
3527
|
-
{ minHan: 13, points:
|
|
3528
|
-
{ minHan: 11, points:
|
|
3529
|
-
{ minHan: 8, points:
|
|
3530
|
-
{ minHan: 6, points:
|
|
3531
|
-
{ minHan: 5, points:
|
|
3519
|
+
{ minHan: 26, points: M.DOUBLE_YAKUMAN },
|
|
3520
|
+
{ minHan: 13, points: M.YAKUMAN },
|
|
3521
|
+
{ minHan: 11, points: M.TRIPLE },
|
|
3522
|
+
{ minHan: 8, points: M.DOUBLE },
|
|
3523
|
+
{ minHan: 6, points: M.HANEMAN },
|
|
3524
|
+
{ minHan: 5, points: M.MANGAN }
|
|
3532
3525
|
], gr = {
|
|
3533
|
-
[
|
|
3534
|
-
[
|
|
3535
|
-
[
|
|
3536
|
-
[
|
|
3537
|
-
},
|
|
3526
|
+
[M.MANGAN]: "満貫",
|
|
3527
|
+
[M.HANEMAN]: "跳満",
|
|
3528
|
+
[M.DOUBLE]: "倍満",
|
|
3529
|
+
[M.TRIPLE]: "三倍満"
|
|
3530
|
+
}, J = {
|
|
3538
3531
|
PARENT_RON: 6,
|
|
3539
3532
|
CHILD_RON: 4,
|
|
3540
3533
|
PARENT_TSUMO: 2,
|
|
@@ -3553,11 +3546,11 @@ function mr(s) {
|
|
|
3553
3546
|
}
|
|
3554
3547
|
function yr(s, t, e) {
|
|
3555
3548
|
if (t)
|
|
3556
|
-
return e ? `${Q(s *
|
|
3557
|
-
s *
|
|
3549
|
+
return e ? `${Q(s * J.PARENT_TSUMO)}` : `${Q(s * J.CHILD_TUMO_FROM_CHILD)}-${Q(
|
|
3550
|
+
s * J.CHILD_TUMO_FROM_PARENT
|
|
3558
3551
|
)}`;
|
|
3559
3552
|
{
|
|
3560
|
-
const n = e ?
|
|
3553
|
+
const n = e ? J.PARENT_RON : J.CHILD_RON;
|
|
3561
3554
|
return `${Q(s * n)}`;
|
|
3562
3555
|
}
|
|
3563
3556
|
}
|
|
@@ -3597,7 +3590,9 @@ class un {
|
|
|
3597
3590
|
i.isParent,
|
|
3598
3591
|
i.myWind,
|
|
3599
3592
|
this.cfg.orig.ronWind
|
|
3600
|
-
), o = r[i.myWind]
|
|
3593
|
+
), o = r[i.myWind];
|
|
3594
|
+
this.addStickPoints(r, i.myWind, this.cfg.orig.ronWind);
|
|
3595
|
+
const a = mr({
|
|
3601
3596
|
base: i.base,
|
|
3602
3597
|
fu: i.fu,
|
|
3603
3598
|
han: i.han,
|
|
@@ -3608,6 +3603,8 @@ class un {
|
|
|
3608
3603
|
});
|
|
3609
3604
|
return {
|
|
3610
3605
|
...n,
|
|
3606
|
+
fu: i.fu,
|
|
3607
|
+
// ceiled value
|
|
3611
3608
|
deltas: r,
|
|
3612
3609
|
points: r[i.myWind],
|
|
3613
3610
|
basePoints: o,
|
|
@@ -3692,7 +3689,7 @@ class un {
|
|
|
3692
3689
|
calculateScore(t) {
|
|
3693
3690
|
const { han: e } = t, n = t.fu !== 25 ? Q(t.fu, 10) : 25, i = t.isYakuman ?? !1;
|
|
3694
3691
|
let r = this.getBasePoints(e, n), o = !1;
|
|
3695
|
-
e >= 13 && e < 26 && !this.hasYakuman(t.yakus) && (r = this.cfg.disableCountableYakuman ?
|
|
3692
|
+
e >= 13 && e < 26 && !this.hasYakuman(t.yakus) && (r = this.cfg.disableCountableYakuman ? M.TRIPLE : M.YAKUMAN, o = !this.cfg.disableCountableYakuman), this.cfg.enableRoundUpMangan && this.isRoundUpMangan(n, e) && (r = M.MANGAN);
|
|
3696
3693
|
const a = this.isTsumoWin(t.hand), c = this.cfg.orig.myWind, l = c === _.E;
|
|
3697
3694
|
return {
|
|
3698
3695
|
base: r,
|
|
@@ -3718,37 +3715,39 @@ class un {
|
|
|
3718
3715
|
* Wind をキーとした点数移動の構成を返す
|
|
3719
3716
|
*/
|
|
3720
3717
|
calculateDeltas(t, e, n, i, r) {
|
|
3721
|
-
const o =
|
|
3722
|
-
return e ? this.calculateTsumoDeltas(o, t, n, i) : this.calculateRonDeltas(o, t, n, i, r)
|
|
3718
|
+
const o = B(0);
|
|
3719
|
+
return e ? this.calculateTsumoDeltas(o, t, n, i) : (b(r != null, "tumo is false but ron wind is null"), this.calculateRonDeltas(o, t, n, i, r)), o;
|
|
3723
3720
|
}
|
|
3724
3721
|
calculateRonDeltas(t, e, n, i, r) {
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
const o = n ? Y.PARENT_RON : Y.CHILD_RON, a = Q(e * o), c = this.cfg.sticks.dead * C.DEAD_STICK, l = a + c;
|
|
3728
|
-
t[i] += l, t[r] -= l;
|
|
3722
|
+
const o = n ? J.PARENT_RON : J.CHILD_RON, a = Q(e * o);
|
|
3723
|
+
t[i] += a, t[r] -= a;
|
|
3729
3724
|
}
|
|
3730
3725
|
calculateTsumoDeltas(t, e, n, i) {
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
t[_.E] += i * 3 + n * 3, t[_.S] -= i + n, t[_.W] -= i + n, t[_.N] -= i + n;
|
|
3737
|
-
}
|
|
3738
|
-
calculateChildTsumoDeltas(t, e, n, i) {
|
|
3726
|
+
if (n) {
|
|
3727
|
+
const r = Q(e * J.PARENT_TSUMO);
|
|
3728
|
+
t[_.E] += r * 3, t[_.S] -= r, t[_.W] -= r, t[_.N] -= r;
|
|
3729
|
+
return;
|
|
3730
|
+
}
|
|
3739
3731
|
for (const r of Object.values(_)) {
|
|
3740
|
-
if (r ==
|
|
3741
|
-
const o = r == _.E ?
|
|
3742
|
-
t[r] -= a
|
|
3732
|
+
if (r == i) continue;
|
|
3733
|
+
const o = r == _.E ? J.CHILD_TUMO_FROM_PARENT : J.CHILD_TUMO_FROM_CHILD, a = Q(e * o);
|
|
3734
|
+
t[r] -= a, t[i] += a;
|
|
3743
3735
|
}
|
|
3744
3736
|
}
|
|
3745
|
-
addStickPoints(t, e) {
|
|
3746
|
-
t[e] +=
|
|
3737
|
+
addStickPoints(t, e, n) {
|
|
3738
|
+
t[e] += M.REACH_STICK * this.cfg.sticks.reach;
|
|
3739
|
+
const i = M.DEAD_STICK * this.cfg.sticks.dead;
|
|
3740
|
+
if (n != null) {
|
|
3741
|
+
t[e] += i, t[n] -= i;
|
|
3742
|
+
return;
|
|
3743
|
+
}
|
|
3744
|
+
for (const r of Object.values(_))
|
|
3745
|
+
r == e ? t[r] += i : t[r] -= i / 3;
|
|
3747
3746
|
}
|
|
3748
3747
|
getBasePoints(t, e) {
|
|
3749
3748
|
for (const { minHan: n, points: i } of pr)
|
|
3750
3749
|
if (t >= n) return i;
|
|
3751
|
-
return Math.min(e * 2 ** (t + 2),
|
|
3750
|
+
return Math.min(e * 2 ** (t + 2), M.MANGAN);
|
|
3752
3751
|
}
|
|
3753
3752
|
minus() {
|
|
3754
3753
|
return this.hand.menzen ? 0 : 1;
|
|
@@ -3757,7 +3756,7 @@ class un {
|
|
|
3757
3756
|
return this.cfg.reached == 1 ? [{ name: "立直", han: 1 }] : this.cfg.reached == 2 ? [{ name: "ダブル立直", han: 2 }] : [];
|
|
3758
3757
|
}
|
|
3759
3758
|
dB1(t) {
|
|
3760
|
-
return this.minus() != 0 ? [] :
|
|
3759
|
+
return this.hand.drawn == null, this.minus() != 0 ? [] : t.some((n) => n.tiles.some((i) => i.has(m.TSUMO))) ? [{ name: "門前清自摸和", han: 1 }] : [];
|
|
3761
3760
|
}
|
|
3762
3761
|
dC1(t) {
|
|
3763
3762
|
if (this.minus() != 0) return [];
|
|
@@ -3766,7 +3765,7 @@ class un {
|
|
|
3766
3765
|
}
|
|
3767
3766
|
dD1(t) {
|
|
3768
3767
|
return t.some(
|
|
3769
|
-
(n) => n.tiles.some((i) => i.t ==
|
|
3768
|
+
(n) => n.tiles.some((i) => i.t == p.Z || X.includes(i.n))
|
|
3770
3769
|
) ? [] : [{ name: "断么九", han: 1 }];
|
|
3771
3770
|
}
|
|
3772
3771
|
dE1(t) {
|
|
@@ -3775,9 +3774,9 @@ class un {
|
|
|
3775
3774
|
dF1(t) {
|
|
3776
3775
|
const e = [];
|
|
3777
3776
|
return t.forEach((n) => {
|
|
3778
|
-
if (n instanceof
|
|
3777
|
+
if (n instanceof R) return;
|
|
3779
3778
|
const i = n.tiles[0];
|
|
3780
|
-
i.t ==
|
|
3779
|
+
i.t == p.Z && (i.equals(this.cfg.myWind) && e.push({ name: "自風", han: 1 }), i.equals(this.cfg.roundWind) ? e.push({ name: "場風", han: 1 }) : i.n == 5 ? e.push({ name: "白", han: 1 }) : i.n == 6 ? e.push({ name: "發", han: 1 }) : i.n == 7 && e.push({ name: "中", han: 1 }));
|
|
3781
3780
|
}), e;
|
|
3782
3781
|
}
|
|
3783
3782
|
dG1(t) {
|
|
@@ -3810,12 +3809,10 @@ class un {
|
|
|
3810
3809
|
return t.length == 7 ? [{ name: "七対子", han: 2 }] : [];
|
|
3811
3810
|
}
|
|
3812
3811
|
dB2(t) {
|
|
3813
|
-
const e = (n) => n instanceof dt || n instanceof
|
|
3812
|
+
const e = (n) => n instanceof dt || n instanceof q;
|
|
3814
3813
|
for (const n of t) {
|
|
3815
|
-
if (!e(n)) continue;
|
|
3816
|
-
const i = at(n)
|
|
3817
|
-
if (i.t == f.Z) continue;
|
|
3818
|
-
const r = [f.M, f.P, f.S].filter((c) => c != i.t), o = t.some((c) => {
|
|
3814
|
+
if (!e(n) || n.tiles[0].t == p.Z) continue;
|
|
3815
|
+
const i = at(n), r = [p.M, p.P, p.S].filter((c) => c != i.t), o = t.some((c) => {
|
|
3819
3816
|
const l = new y(r[0], i.n);
|
|
3820
3817
|
return e(c) && l.equals(at(c));
|
|
3821
3818
|
}), a = t.some((c) => {
|
|
@@ -3828,24 +3825,24 @@ class un {
|
|
|
3828
3825
|
}
|
|
3829
3826
|
dC2(t) {
|
|
3830
3827
|
return t.length == 7 ? [] : t.every(
|
|
3831
|
-
(n) => n instanceof
|
|
3828
|
+
(n) => n instanceof C || n instanceof W || n instanceof Z || n instanceof L || n instanceof U || n instanceof R
|
|
3832
3829
|
) ? [{ name: "対々和", han: 2 }] : [];
|
|
3833
3830
|
}
|
|
3834
3831
|
dD2(t) {
|
|
3835
|
-
return t.filter((n) => (n instanceof
|
|
3832
|
+
return t.filter((n) => (n instanceof C || n instanceof L) && !n.tiles.some((i) => i.has(m.RON))).length >= 3 ? [{ name: "三暗刻", han: 2 }] : [];
|
|
3836
3833
|
}
|
|
3837
3834
|
dE2(t) {
|
|
3838
3835
|
return t.filter(
|
|
3839
|
-
(n) => n instanceof
|
|
3836
|
+
(n) => n instanceof C || n instanceof W || n instanceof Z
|
|
3840
3837
|
).length >= 3 ? [{ name: "三槓子", han: 2 }] : [];
|
|
3841
3838
|
}
|
|
3842
3839
|
dF2(t) {
|
|
3843
|
-
const e = (n) => n instanceof
|
|
3840
|
+
const e = (n) => n instanceof C || n instanceof W || n instanceof Z || n instanceof L || n instanceof U;
|
|
3844
3841
|
for (const n of t) {
|
|
3845
3842
|
if (!e(n)) continue;
|
|
3846
3843
|
const i = at(n);
|
|
3847
|
-
if (i.t ==
|
|
3848
|
-
const r = [
|
|
3844
|
+
if (i.t == p.Z) continue;
|
|
3845
|
+
const r = [p.M, p.P, p.S].filter((c) => c != i.t), o = t.some((c) => {
|
|
3849
3846
|
const l = new y(r[0], i.n);
|
|
3850
3847
|
return e(c) && l.equals(at(c));
|
|
3851
3848
|
}), a = t.some((c) => {
|
|
@@ -3859,31 +3856,31 @@ class un {
|
|
|
3859
3856
|
dG2(t) {
|
|
3860
3857
|
return t.length == 7 ? [] : t.filter((n) => {
|
|
3861
3858
|
const i = n.tiles[0];
|
|
3862
|
-
return i.t ==
|
|
3859
|
+
return i.t == p.Z && [5, 6, 7].includes(i.n);
|
|
3863
3860
|
}).length == 3 ? [{ name: "小三元", han: 2 }] : [];
|
|
3864
3861
|
}
|
|
3865
3862
|
dH2(t) {
|
|
3866
3863
|
return t.every((n) => {
|
|
3867
|
-
const i = n.tiles[0].t ==
|
|
3868
|
-
return n
|
|
3864
|
+
const i = n.tiles[0], r = i.t == p.Z ? jt : X;
|
|
3865
|
+
return (n instanceof C || n instanceof W || n instanceof Z || n instanceof L || n instanceof U || n instanceof R) && r.includes(i.n);
|
|
3869
3866
|
}) ? [{ name: "混老頭", han: 2 }] : [];
|
|
3870
3867
|
}
|
|
3871
3868
|
dI2(t) {
|
|
3872
|
-
return t.length == 7 ? [] : t.some((n) => n instanceof dt || n instanceof
|
|
3873
|
-
const i = n.tiles[0].t ==
|
|
3869
|
+
return t.length == 7 ? [] : t.some((n) => n instanceof dt || n instanceof q) ? t.some((n) => n.tiles[0].t == p.Z) ? t.every((n) => {
|
|
3870
|
+
const i = n.tiles[0].t == p.Z ? jt : X;
|
|
3874
3871
|
return n.tiles.some((r) => i.includes(r.n));
|
|
3875
3872
|
}) ? [{ name: "混全帯么九", han: 2 - this.minus() }] : [] : [] : [];
|
|
3876
3873
|
}
|
|
3877
3874
|
dJ2(t) {
|
|
3878
3875
|
const e = {
|
|
3879
3876
|
// 123m, 456m, 789m
|
|
3880
|
-
[
|
|
3881
|
-
[
|
|
3882
|
-
[
|
|
3877
|
+
[p.M]: [0, 0, 0],
|
|
3878
|
+
[p.S]: [0, 0, 0],
|
|
3879
|
+
[p.P]: [0, 0, 0]
|
|
3883
3880
|
};
|
|
3884
3881
|
for (const n of t) {
|
|
3885
3882
|
const i = at(n);
|
|
3886
|
-
i.t !=
|
|
3883
|
+
i.t != p.BACK && i.t != p.Z && (n instanceof dt || n instanceof q) && (i.n == 1 ? e[i.t][0]++ : i.n == 4 ? e[i.t][1]++ : i.n == 7 && e[i.t][2]++);
|
|
3887
3884
|
}
|
|
3888
3885
|
for (const n of Object.values(e))
|
|
3889
3886
|
if (n[0] > 0 && n[1] > 0 && n[2] > 0)
|
|
@@ -3891,28 +3888,28 @@ class un {
|
|
|
3891
3888
|
return [];
|
|
3892
3889
|
}
|
|
3893
3890
|
dA3(t) {
|
|
3894
|
-
if (!t.some((n) => n.tiles[0].t ==
|
|
3895
|
-
for (const n of Object.values(
|
|
3896
|
-
if (t.every((r) => r.tiles[0].t ==
|
|
3891
|
+
if (!t.some((n) => n.tiles[0].t == p.Z)) return [];
|
|
3892
|
+
for (const n of Object.values(p))
|
|
3893
|
+
if (t.every((r) => r.tiles[0].t == p.Z || r.tiles[0].t == n)) return [{ name: "混一色", han: 3 - this.minus() }];
|
|
3897
3894
|
return [];
|
|
3898
3895
|
}
|
|
3899
3896
|
dB3(t) {
|
|
3900
|
-
return t.length == 7 ? [] : t.some((n) => n instanceof dt || n instanceof
|
|
3897
|
+
return t.length == 7 ? [] : t.some((n) => n instanceof dt || n instanceof q) ? t.some((n) => n.tiles[0].t == p.Z) ? [] : t.every((n) => n.tiles.some((i) => X.includes(i.n))) ? [{ name: "純全帯么九色", han: 3 - this.minus() }] : [] : [];
|
|
3901
3898
|
}
|
|
3902
3899
|
dC3(t) {
|
|
3903
3900
|
return this.minus() != 0 ? [] : dn(t) == 2 ? [{ name: "ニ盃口", han: 3 }] : [];
|
|
3904
3901
|
}
|
|
3905
3902
|
dA6(t) {
|
|
3906
|
-
if (t.some((e) => e.tiles[0].t ==
|
|
3907
|
-
for (const e of Object.values(
|
|
3908
|
-
if (e ==
|
|
3903
|
+
if (t.some((e) => e.tiles[0].t == p.Z)) return [];
|
|
3904
|
+
for (const e of Object.values(p)) {
|
|
3905
|
+
if (e == p.Z) continue;
|
|
3909
3906
|
if (t.every((i) => i.tiles[0].t == e)) return [{ name: "清一色", han: 6 - this.minus() }];
|
|
3910
3907
|
}
|
|
3911
3908
|
return [];
|
|
3912
3909
|
}
|
|
3913
3910
|
dA13(t) {
|
|
3914
3911
|
return t.length != 13 ? [] : t.some(
|
|
3915
|
-
(n) => n instanceof
|
|
3912
|
+
(n) => n instanceof R && n.tiles.some((i) => i.has(m.TSUMO) || i.has(m.RON))
|
|
3916
3913
|
) ? [{ name: "国士無双13面待ち", han: 26, isYakuman: !0 }] : [{ name: "国士無双", han: 13, isYakuman: !0 }];
|
|
3917
3914
|
}
|
|
3918
3915
|
dB13(t) {
|
|
@@ -3920,39 +3917,42 @@ class un {
|
|
|
3920
3917
|
}
|
|
3921
3918
|
dC13(t) {
|
|
3922
3919
|
return t.length == 7 ? [] : t.every(
|
|
3923
|
-
(i) => i instanceof
|
|
3920
|
+
(i) => i instanceof C || i instanceof L && i.tiles.every((r) => !r.has(m.RON)) || i instanceof R
|
|
3924
3921
|
) ? t.some(
|
|
3925
|
-
(i) => i instanceof
|
|
3922
|
+
(i) => i instanceof R && i.tiles.some((r) => r.has(m.TSUMO) || r.has(m.RON))
|
|
3926
3923
|
) ? [{ name: "四暗刻単騎待ち", han: 26, isYakuman: !0 }] : [{ name: "四暗刻", han: 13, isYakuman: !0 }] : [];
|
|
3927
3924
|
}
|
|
3928
3925
|
dD13(t) {
|
|
3929
3926
|
if (t.length == 13) return [];
|
|
3930
3927
|
const e = [5, 6, 7];
|
|
3931
3928
|
return t.filter(
|
|
3932
|
-
(i) => !(i instanceof
|
|
3929
|
+
(i) => !(i instanceof R) && i.tiles.some((r) => r.t == p.Z && e.includes(r.n))
|
|
3933
3930
|
).length == 3 ? [{ name: "大三元", han: 13, isYakuman: !0 }] : [];
|
|
3934
3931
|
}
|
|
3935
3932
|
dE13(t) {
|
|
3936
|
-
return t.every((n) => n.tiles[0].t ==
|
|
3933
|
+
return t.every((n) => n.tiles[0].t == p.Z) ? [{ name: "字一色", han: 13, isYakuman: !0 }] : [];
|
|
3937
3934
|
}
|
|
3938
3935
|
dF13(t) {
|
|
3939
3936
|
return t.every(
|
|
3940
|
-
(n) => n
|
|
3937
|
+
(n) => (n instanceof C || n instanceof W || n instanceof Z || n instanceof L || n instanceof U || n instanceof R) && X.includes(n.tiles[0].n)
|
|
3941
3938
|
) ? [{ name: "清老頭", han: 13, isYakuman: !0 }] : [];
|
|
3942
3939
|
}
|
|
3943
3940
|
dG13(t) {
|
|
3944
|
-
return t.
|
|
3945
|
-
(n) => n instanceof
|
|
3946
|
-
)
|
|
3941
|
+
return t.length == 7 ? [] : t.every(
|
|
3942
|
+
(n) => n instanceof C || n instanceof W || n instanceof Z || n instanceof R
|
|
3943
|
+
) ? [{ name: "四槓子", han: 13, isYakuman: !0 }] : [];
|
|
3947
3944
|
}
|
|
3948
3945
|
dH13(t) {
|
|
3949
3946
|
if (t.length == 13) return [];
|
|
3950
3947
|
if (t.length == 7) return [];
|
|
3951
3948
|
const e = [1, 2, 3, 4];
|
|
3952
|
-
return t.filter((r) =>
|
|
3949
|
+
return t.filter((r) => {
|
|
3950
|
+
const o = r.tiles[0];
|
|
3951
|
+
return o.t == p.Z && e.includes(o.n);
|
|
3952
|
+
}).length == 4 ? t.find((r) => r instanceof R).tiles.some((r) => r.t == p.Z && e.includes(r.n)) ? [{ name: "小四喜", han: 13, isYakuman: !0 }] : [{ name: "大四喜", han: 13, isYakuman: !0 }] : [];
|
|
3953
3953
|
}
|
|
3954
3954
|
dI13(t) {
|
|
3955
|
-
const e = (n) => !!(n.equals(new y(
|
|
3955
|
+
const e = (n) => !!(n.equals(new y(p.Z, 6)) || n.t == p.S && [2, 3, 4, 6, 8].includes(n.n));
|
|
3956
3956
|
return t.every((n) => n.tiles.every((i) => e(i))) ? [{ name: "緑一色", han: 13, isYakuman: !0 }] : [];
|
|
3957
3957
|
}
|
|
3958
3958
|
// TODO 天和・地和
|
|
@@ -3966,41 +3966,41 @@ class un {
|
|
|
3966
3966
|
* 手牌の構成から符を計算する
|
|
3967
3967
|
*/
|
|
3968
3968
|
calcFu(t) {
|
|
3969
|
-
let n = 20;
|
|
3970
|
-
const i = this.cfg.myWind.n, r = this.cfg.roundWind.n;
|
|
3971
3969
|
if (t.length == 7) return 25;
|
|
3972
|
-
const
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3970
|
+
const e = 20;
|
|
3971
|
+
let n = e;
|
|
3972
|
+
const i = this.cfg.myWind.n, r = this.cfg.roundWind.n, o = t.find(
|
|
3973
|
+
(f) => f.tiles.some((E) => E.has(m.TSUMO) || E.has(m.RON))
|
|
3974
|
+
), a = this.minus() == 1, c = o.tiles.some((f) => f.has(m.TSUMO)), l = (f, E) => {
|
|
3975
|
+
const A = f.tiles[0];
|
|
3976
|
+
return A.t == p.Z || X.includes(A.n) ? E * 2 : E;
|
|
3977
3977
|
};
|
|
3978
|
-
for (const
|
|
3978
|
+
for (const f of t)
|
|
3979
3979
|
switch (!0) {
|
|
3980
|
-
case
|
|
3981
|
-
const E =
|
|
3982
|
-
n += l(
|
|
3980
|
+
case f instanceof L:
|
|
3981
|
+
const E = f.tiles.some((A) => A.has(m.RON)) ? 2 : 4;
|
|
3982
|
+
n += l(f, E);
|
|
3983
3983
|
break;
|
|
3984
|
-
case
|
|
3985
|
-
n += l(
|
|
3984
|
+
case f instanceof U:
|
|
3985
|
+
n += l(f, 2);
|
|
3986
3986
|
break;
|
|
3987
|
-
case (
|
|
3988
|
-
n += l(
|
|
3987
|
+
case (f instanceof Z || f instanceof W):
|
|
3988
|
+
n += l(f, 8);
|
|
3989
3989
|
break;
|
|
3990
|
-
case
|
|
3991
|
-
n += l(
|
|
3990
|
+
case f instanceof C:
|
|
3991
|
+
n += l(f, 16);
|
|
3992
3992
|
break;
|
|
3993
3993
|
}
|
|
3994
|
-
n += ((
|
|
3995
|
-
if (
|
|
3996
|
-
if (
|
|
3997
|
-
const E =
|
|
3994
|
+
n += ((f) => {
|
|
3995
|
+
if (f instanceof L) return 0;
|
|
3996
|
+
if (f instanceof R) return 2;
|
|
3997
|
+
const E = f.tiles, A = E.findIndex((I) => I.has(m.TSUMO) || I.has(m.RON));
|
|
3998
3998
|
return A == 1 || A == 0 && E[2].n == 9 || A == 2 && E[0].n == 1 ? 2 : 0;
|
|
3999
3999
|
})(o);
|
|
4000
|
-
const d = t.find((
|
|
4001
|
-
d.t ==
|
|
4000
|
+
const d = t.find((f) => f instanceof R).tiles[0];
|
|
4001
|
+
d.t == p.Z && ([5, 6, 7].includes(d.n) && (n += 2), (d.n == r || d.n == i) && (n += 2));
|
|
4002
4002
|
let g = !1;
|
|
4003
|
-
return !a && n ==
|
|
4003
|
+
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;
|
|
4004
4004
|
}
|
|
4005
4005
|
}
|
|
4006
4006
|
const Lt = (s) => s.tiles.reduce((t, e) => `${t}${e.n}${e.t}`, ""), dn = (s) => {
|
|
@@ -4016,7 +4016,7 @@ const Lt = (s) => s.tiles.reduce((t, e) => `${t}${e.n}${e.t}`, ""), dn = (s) =>
|
|
|
4016
4016
|
return e;
|
|
4017
4017
|
}, at = (s) => [...s.tiles].sort(fe)[0], fn = (s) => {
|
|
4018
4018
|
const t = s.n, e = s.t;
|
|
4019
|
-
if (e ==
|
|
4019
|
+
if (e == p.Z) {
|
|
4020
4020
|
if (t == 4) return new y(e, 1);
|
|
4021
4021
|
if (t == 7) return new y(e, 5);
|
|
4022
4022
|
}
|
|
@@ -4028,9 +4028,9 @@ class Ft {
|
|
|
4028
4028
|
* choices は、通常なら hand.hands を指定する。ただし、リーチしている場合は打牌が限られているので choices で制限する。
|
|
4029
4029
|
*/
|
|
4030
4030
|
static calcEffectiveTiles(t, e, n) {
|
|
4031
|
-
|
|
4031
|
+
if (e.length == 0) throw new Error("choices to discard is zero");
|
|
4032
4032
|
const i = /* @__PURE__ */ new Map();
|
|
4033
|
-
let r =
|
|
4033
|
+
let r = Number.POSITIVE_INFINITY;
|
|
4034
4034
|
for (const o of e) {
|
|
4035
4035
|
const a = t.dec([o]), c = Ft.getEffectiveTiles(t, n);
|
|
4036
4036
|
t.inc(a);
|
|
@@ -4052,9 +4052,9 @@ class Ft {
|
|
|
4052
4052
|
* シャンテン数は有効牌を引いた場合の値となる。多くの場合、現在のシャンテン数 -1 となる。
|
|
4053
4053
|
*/
|
|
4054
4054
|
static getEffectiveTiles(t, e) {
|
|
4055
|
-
let n =
|
|
4055
|
+
let n = Number.POSITIVE_INFINITY, i = [];
|
|
4056
4056
|
const r = new ge(t);
|
|
4057
|
-
for (const [o, a] of
|
|
4057
|
+
for (const [o, a] of F({
|
|
4058
4058
|
skipBack: !0,
|
|
4059
4059
|
filterBy: e?.typeFilter
|
|
4060
4060
|
})) {
|
|
@@ -4174,7 +4174,7 @@ class oe {
|
|
|
4174
4174
|
}
|
|
4175
4175
|
class ae {
|
|
4176
4176
|
playerToWind = {};
|
|
4177
|
-
windToPlayer =
|
|
4177
|
+
windToPlayer = B("");
|
|
4178
4178
|
round;
|
|
4179
4179
|
sticks;
|
|
4180
4180
|
constructor(t, e) {
|
|
@@ -4184,7 +4184,7 @@ class ae {
|
|
|
4184
4184
|
}
|
|
4185
4185
|
update() {
|
|
4186
4186
|
for (let t in this.playerToWind) {
|
|
4187
|
-
const e =
|
|
4187
|
+
const e = De(this.playerToWind[t]);
|
|
4188
4188
|
this.playerToWind[t] = e, this.windToPlayer[e] = t;
|
|
4189
4189
|
}
|
|
4190
4190
|
}
|
|
@@ -4224,19 +4224,19 @@ function Fn(s) {
|
|
|
4224
4224
|
}
|
|
4225
4225
|
return s;
|
|
4226
4226
|
}
|
|
4227
|
-
class
|
|
4227
|
+
class Ir {
|
|
4228
4228
|
constructor(t = !1) {
|
|
4229
4229
|
this.disable = t, this.c = this.initial();
|
|
4230
4230
|
}
|
|
4231
4231
|
c;
|
|
4232
|
-
safeTileMap =
|
|
4232
|
+
safeTileMap = B({}, !0);
|
|
4233
4233
|
get(t) {
|
|
4234
|
-
return t.t ==
|
|
4234
|
+
return t.t == p.BACK ? 0 : this.c[t.t][t.n];
|
|
4235
4235
|
}
|
|
4236
4236
|
dec(...t) {
|
|
4237
4237
|
if (!this.disable) {
|
|
4238
4238
|
for (let e of t)
|
|
4239
|
-
if (e.t !=
|
|
4239
|
+
if (e.t != p.BACK) {
|
|
4240
4240
|
if (this.get(e) <= 0)
|
|
4241
4241
|
throw new Error(
|
|
4242
4242
|
`[counter] cannot decrease ${e.toString()} due to zero`
|
|
@@ -4259,14 +4259,14 @@ class Nr {
|
|
|
4259
4259
|
}
|
|
4260
4260
|
initial() {
|
|
4261
4261
|
return {
|
|
4262
|
-
[
|
|
4263
|
-
[
|
|
4264
|
-
[
|
|
4265
|
-
[
|
|
4262
|
+
[p.M]: [1, 4, 4, 4, 4, 4, 4, 4, 4, 4],
|
|
4263
|
+
[p.S]: [1, 4, 4, 4, 4, 4, 4, 4, 4, 4],
|
|
4264
|
+
[p.P]: [1, 4, 4, 4, 4, 4, 4, 4, 4, 4],
|
|
4265
|
+
[p.Z]: [0, 4, 4, 4, 4, 4, 4, 4]
|
|
4266
4266
|
};
|
|
4267
4267
|
}
|
|
4268
4268
|
}
|
|
4269
|
-
class
|
|
4269
|
+
class Yn {
|
|
4270
4270
|
m = [];
|
|
4271
4271
|
constructor() {
|
|
4272
4272
|
}
|
|
@@ -4295,7 +4295,7 @@ class Zn {
|
|
|
4295
4295
|
return !0;
|
|
4296
4296
|
}
|
|
4297
4297
|
}
|
|
4298
|
-
function
|
|
4298
|
+
function Nr() {
|
|
4299
4299
|
if (typeof globalThis < "u")
|
|
4300
4300
|
return globalThis;
|
|
4301
4301
|
if (typeof self < "u")
|
|
@@ -4305,15 +4305,15 @@ function Tr() {
|
|
|
4305
4305
|
if (typeof global < "u")
|
|
4306
4306
|
return global;
|
|
4307
4307
|
}
|
|
4308
|
-
function
|
|
4309
|
-
const s =
|
|
4308
|
+
function Tr() {
|
|
4309
|
+
const s = Nr();
|
|
4310
4310
|
if (s.__xstate__)
|
|
4311
4311
|
return s.__xstate__;
|
|
4312
4312
|
}
|
|
4313
4313
|
const vr = (s) => {
|
|
4314
4314
|
if (typeof window > "u")
|
|
4315
4315
|
return;
|
|
4316
|
-
const t =
|
|
4316
|
+
const t = Tr();
|
|
4317
4317
|
t && t.register(s);
|
|
4318
4318
|
};
|
|
4319
4319
|
class pn {
|
|
@@ -4345,7 +4345,7 @@ class pn {
|
|
|
4345
4345
|
this._last = null;
|
|
4346
4346
|
}
|
|
4347
4347
|
}
|
|
4348
|
-
const Gn = ".", Sr = "",
|
|
4348
|
+
const Gn = ".", Sr = "", Zn = "", Or = "#", kr = "*", Vn = "xstate.init", Re = "xstate.stop";
|
|
4349
4349
|
function Cr(s, t) {
|
|
4350
4350
|
return {
|
|
4351
4351
|
type: `xstate.after.${s}.${t}`
|
|
@@ -4377,7 +4377,7 @@ function Jn(s) {
|
|
|
4377
4377
|
input: s
|
|
4378
4378
|
};
|
|
4379
4379
|
}
|
|
4380
|
-
function
|
|
4380
|
+
function G(s) {
|
|
4381
4381
|
setTimeout(() => {
|
|
4382
4382
|
throw s;
|
|
4383
4383
|
});
|
|
@@ -4456,7 +4456,7 @@ function Qn(s) {
|
|
|
4456
4456
|
function Hr(s) {
|
|
4457
4457
|
return s.type.startsWith("xstate.error.actor");
|
|
4458
4458
|
}
|
|
4459
|
-
function
|
|
4459
|
+
function It(s) {
|
|
4460
4460
|
return qn(s).map((t) => typeof t > "u" || typeof t == "string" ? {
|
|
4461
4461
|
target: t
|
|
4462
4462
|
} : t);
|
|
@@ -4487,34 +4487,34 @@ function wn(s, t) {
|
|
|
4487
4487
|
return `${s.sessionId}.${t}`;
|
|
4488
4488
|
}
|
|
4489
4489
|
let Pr = 0;
|
|
4490
|
-
function
|
|
4490
|
+
function Br(s, t) {
|
|
4491
4491
|
const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new Set(), o = {}, {
|
|
4492
4492
|
clock: a,
|
|
4493
4493
|
logger: c
|
|
4494
4494
|
} = t, l = {
|
|
4495
|
-
schedule: (d, g,
|
|
4496
|
-
const
|
|
4495
|
+
schedule: (d, g, f, E, A = Math.random().toString(36).slice(2)) => {
|
|
4496
|
+
const I = {
|
|
4497
4497
|
source: d,
|
|
4498
4498
|
target: g,
|
|
4499
|
-
event:
|
|
4499
|
+
event: f,
|
|
4500
4500
|
delay: E,
|
|
4501
4501
|
id: A,
|
|
4502
4502
|
startedAt: Date.now()
|
|
4503
4503
|
}, v = wn(d, A);
|
|
4504
|
-
h._snapshot._scheduledEvents[v] =
|
|
4505
|
-
const
|
|
4506
|
-
delete o[v], delete h._snapshot._scheduledEvents[v], h._relay(d, g,
|
|
4504
|
+
h._snapshot._scheduledEvents[v] = I;
|
|
4505
|
+
const x = a.setTimeout(() => {
|
|
4506
|
+
delete o[v], delete h._snapshot._scheduledEvents[v], h._relay(d, g, f);
|
|
4507
4507
|
}, E);
|
|
4508
|
-
o[v] =
|
|
4508
|
+
o[v] = x;
|
|
4509
4509
|
},
|
|
4510
4510
|
cancel: (d, g) => {
|
|
4511
|
-
const
|
|
4512
|
-
delete o[
|
|
4511
|
+
const f = wn(d, g), E = o[f];
|
|
4512
|
+
delete o[f], delete h._snapshot._scheduledEvents[f], E !== void 0 && a.clearTimeout(E);
|
|
4513
4513
|
},
|
|
4514
4514
|
cancelAll: (d) => {
|
|
4515
4515
|
for (const g in h._snapshot._scheduledEvents) {
|
|
4516
|
-
const
|
|
4517
|
-
|
|
4516
|
+
const f = h._snapshot._scheduledEvents[g];
|
|
4517
|
+
f.source === d && l.cancel(d, f.id);
|
|
4518
4518
|
}
|
|
4519
4519
|
}
|
|
4520
4520
|
}, u = (d) => {
|
|
@@ -4524,7 +4524,7 @@ function Dr(s, t) {
|
|
|
4524
4524
|
...d,
|
|
4525
4525
|
rootId: s.sessionId
|
|
4526
4526
|
};
|
|
4527
|
-
r.forEach((
|
|
4527
|
+
r.forEach((f) => f.next?.(g));
|
|
4528
4528
|
}, h = {
|
|
4529
4529
|
_snapshot: {
|
|
4530
4530
|
_scheduledEvents: (t?.snapshot && t.snapshot.scheduler) ?? {}
|
|
@@ -4539,8 +4539,8 @@ function Dr(s, t) {
|
|
|
4539
4539
|
get: (d) => n.get(d),
|
|
4540
4540
|
getAll: () => Object.fromEntries(n.entries()),
|
|
4541
4541
|
_set: (d, g) => {
|
|
4542
|
-
const
|
|
4543
|
-
if (
|
|
4542
|
+
const f = n.get(d);
|
|
4543
|
+
if (f && f !== g)
|
|
4544
4544
|
throw new Error(`Actor with system ID '${d}' already exists.`);
|
|
4545
4545
|
n.set(d, g), i.set(g, d);
|
|
4546
4546
|
},
|
|
@@ -4553,13 +4553,13 @@ function Dr(s, t) {
|
|
|
4553
4553
|
};
|
|
4554
4554
|
},
|
|
4555
4555
|
_sendInspectionEvent: u,
|
|
4556
|
-
_relay: (d, g,
|
|
4556
|
+
_relay: (d, g, f) => {
|
|
4557
4557
|
h._sendInspectionEvent({
|
|
4558
4558
|
type: "@xstate.event",
|
|
4559
4559
|
sourceRef: d,
|
|
4560
4560
|
actorRef: g,
|
|
4561
|
-
event:
|
|
4562
|
-
}), g._send(
|
|
4561
|
+
event: f
|
|
4562
|
+
}), g._send(f);
|
|
4563
4563
|
},
|
|
4564
4564
|
scheduler: l,
|
|
4565
4565
|
getSnapshot: () => ({
|
|
@@ -4572,13 +4572,13 @@ function Dr(s, t) {
|
|
|
4572
4572
|
h._snapshot._scheduledEvents = {};
|
|
4573
4573
|
for (const g in d) {
|
|
4574
4574
|
const {
|
|
4575
|
-
source:
|
|
4575
|
+
source: f,
|
|
4576
4576
|
target: E,
|
|
4577
4577
|
event: A,
|
|
4578
|
-
delay:
|
|
4578
|
+
delay: I,
|
|
4579
4579
|
id: v
|
|
4580
4580
|
} = d[g];
|
|
4581
|
-
l.schedule(
|
|
4581
|
+
l.schedule(f, E, A, I, v);
|
|
4582
4582
|
}
|
|
4583
4583
|
},
|
|
4584
4584
|
_clock: a,
|
|
@@ -4588,10 +4588,10 @@ function Dr(s, t) {
|
|
|
4588
4588
|
}
|
|
4589
4589
|
let _e = !1;
|
|
4590
4590
|
const Fe = 1;
|
|
4591
|
-
let
|
|
4591
|
+
let P = /* @__PURE__ */ (function(s) {
|
|
4592
4592
|
return s[s.NotStarted = 0] = "NotStarted", s[s.Running = 1] = "Running", s[s.Stopped = 2] = "Stopped", s;
|
|
4593
4593
|
})({});
|
|
4594
|
-
const
|
|
4594
|
+
const Wr = {
|
|
4595
4595
|
clock: {
|
|
4596
4596
|
setTimeout: (s, t) => setTimeout(s, t),
|
|
4597
4597
|
clearTimeout: (s) => clearTimeout(s)
|
|
@@ -4599,7 +4599,7 @@ const Br = {
|
|
|
4599
4599
|
logger: console.log.bind(console),
|
|
4600
4600
|
devTools: !1
|
|
4601
4601
|
};
|
|
4602
|
-
class
|
|
4602
|
+
class Dr {
|
|
4603
4603
|
/**
|
|
4604
4604
|
* Creates a new actor instance for the given logic with the provided options,
|
|
4605
4605
|
* if any.
|
|
@@ -4608,9 +4608,9 @@ class Wr {
|
|
|
4608
4608
|
* @param options Actor options
|
|
4609
4609
|
*/
|
|
4610
4610
|
constructor(t, e) {
|
|
4611
|
-
this.logic = t, this._snapshot = void 0, this.clock = void 0, this.options = void 0, this.id = void 0, this.mailbox = new pn(this._process.bind(this)), this.observers = /* @__PURE__ */ new Set(), this.eventListeners = /* @__PURE__ */ new Map(), this.logger = void 0, this._processingStatus =
|
|
4611
|
+
this.logic = t, this._snapshot = void 0, this.clock = void 0, this.options = void 0, this.id = void 0, this.mailbox = new pn(this._process.bind(this)), this.observers = /* @__PURE__ */ new Set(), this.eventListeners = /* @__PURE__ */ new Map(), this.logger = void 0, this._processingStatus = P.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 = [];
|
|
4612
4612
|
const n = {
|
|
4613
|
-
...
|
|
4613
|
+
...Wr,
|
|
4614
4614
|
...e
|
|
4615
4615
|
}, {
|
|
4616
4616
|
clock: i,
|
|
@@ -4621,7 +4621,7 @@ class Wr {
|
|
|
4621
4621
|
systemId: l,
|
|
4622
4622
|
inspect: u
|
|
4623
4623
|
} = n;
|
|
4624
|
-
this.system = o ? o.system :
|
|
4624
|
+
this.system = o ? o.system : Br(this, {
|
|
4625
4625
|
clock: i,
|
|
4626
4626
|
logger: r
|
|
4627
4627
|
}), u && !o && this.system.inspect($e(u)), 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 = {
|
|
@@ -4642,12 +4642,12 @@ class Wr {
|
|
|
4642
4642
|
const d = this.eventListeners.get(h.type), g = this.eventListeners.get("*");
|
|
4643
4643
|
if (!d && !g)
|
|
4644
4644
|
return;
|
|
4645
|
-
const
|
|
4646
|
-
for (const E of
|
|
4645
|
+
const f = [...d ? d.values() : [], ...g ? g.values() : []];
|
|
4646
|
+
for (const E of f)
|
|
4647
4647
|
try {
|
|
4648
4648
|
E(h);
|
|
4649
4649
|
} catch (A) {
|
|
4650
|
-
|
|
4650
|
+
G(A);
|
|
4651
4651
|
}
|
|
4652
4652
|
},
|
|
4653
4653
|
actionExecutor: (h) => {
|
|
@@ -4668,7 +4668,7 @@ class Wr {
|
|
|
4668
4668
|
_e = g;
|
|
4669
4669
|
}
|
|
4670
4670
|
};
|
|
4671
|
-
this._processingStatus ===
|
|
4671
|
+
this._processingStatus === P.Running ? d() : this._deferred.push(d);
|
|
4672
4672
|
}
|
|
4673
4673
|
}, this.send = this.send.bind(this), this.system._sendInspectionEvent({
|
|
4674
4674
|
type: "@xstate.actor",
|
|
@@ -4705,7 +4705,7 @@ class Wr {
|
|
|
4705
4705
|
try {
|
|
4706
4706
|
i.next?.(t);
|
|
4707
4707
|
} catch (r) {
|
|
4708
|
-
|
|
4708
|
+
G(r);
|
|
4709
4709
|
}
|
|
4710
4710
|
break;
|
|
4711
4711
|
case "done":
|
|
@@ -4713,7 +4713,7 @@ class Wr {
|
|
|
4713
4713
|
try {
|
|
4714
4714
|
i.next?.(t);
|
|
4715
4715
|
} catch (r) {
|
|
4716
|
-
|
|
4716
|
+
G(r);
|
|
4717
4717
|
}
|
|
4718
4718
|
this._stopProcedure(), this._complete(), this._doneEvent = Rr(this.id, this._snapshot.output), this._parent && this.system._relay(this, this._parent, this._doneEvent);
|
|
4719
4719
|
break;
|
|
@@ -4789,7 +4789,7 @@ class Wr {
|
|
|
4789
4789
|
*/
|
|
4790
4790
|
subscribe(t, e, n) {
|
|
4791
4791
|
const i = $e(t, e, n);
|
|
4792
|
-
if (this._processingStatus !==
|
|
4792
|
+
if (this._processingStatus !== P.Stopped)
|
|
4793
4793
|
this.observers.add(i);
|
|
4794
4794
|
else
|
|
4795
4795
|
switch (this._snapshot.status) {
|
|
@@ -4797,18 +4797,18 @@ class Wr {
|
|
|
4797
4797
|
try {
|
|
4798
4798
|
i.complete?.();
|
|
4799
4799
|
} catch (r) {
|
|
4800
|
-
|
|
4800
|
+
G(r);
|
|
4801
4801
|
}
|
|
4802
4802
|
break;
|
|
4803
4803
|
case "error": {
|
|
4804
4804
|
const r = this._snapshot.error;
|
|
4805
4805
|
if (!i.error)
|
|
4806
|
-
|
|
4806
|
+
G(r);
|
|
4807
4807
|
else
|
|
4808
4808
|
try {
|
|
4809
4809
|
i.error(r);
|
|
4810
4810
|
} catch (o) {
|
|
4811
|
-
|
|
4811
|
+
G(o);
|
|
4812
4812
|
}
|
|
4813
4813
|
break;
|
|
4814
4814
|
}
|
|
@@ -4831,7 +4831,7 @@ class Wr {
|
|
|
4831
4831
|
}
|
|
4832
4832
|
/** Starts the Actor from the initial state */
|
|
4833
4833
|
start() {
|
|
4834
|
-
if (this._processingStatus ===
|
|
4834
|
+
if (this._processingStatus === P.Running)
|
|
4835
4835
|
return this;
|
|
4836
4836
|
this._syncSnapshot && this.subscribe({
|
|
4837
4837
|
next: (n) => {
|
|
@@ -4842,7 +4842,7 @@ class Wr {
|
|
|
4842
4842
|
},
|
|
4843
4843
|
error: () => {
|
|
4844
4844
|
}
|
|
4845
|
-
}), this.system._register(this.sessionId, this), this.systemId && this.system._set(this.systemId, this), this._processingStatus =
|
|
4845
|
+
}), this.system._register(this.sessionId, this), this.systemId && this.system._set(this.systemId, this), this._processingStatus = P.Running;
|
|
4846
4846
|
const t = Jn(this.options.input);
|
|
4847
4847
|
switch (this.system._sendInspectionEvent({
|
|
4848
4848
|
type: "@xstate.event",
|
|
@@ -4890,7 +4890,7 @@ class Wr {
|
|
|
4890
4890
|
this.update(e, t), t.type === Re && (this._stopProcedure(), this._complete());
|
|
4891
4891
|
}
|
|
4892
4892
|
_stop() {
|
|
4893
|
-
return this._processingStatus ===
|
|
4893
|
+
return this._processingStatus === P.Stopped ? this : (this.mailbox.clear(), this._processingStatus === P.NotStarted ? (this._processingStatus = P.Stopped, this) : (this.mailbox.enqueue({
|
|
4894
4894
|
type: Re
|
|
4895
4895
|
}), this));
|
|
4896
4896
|
}
|
|
@@ -4905,13 +4905,13 @@ class Wr {
|
|
|
4905
4905
|
try {
|
|
4906
4906
|
t.complete?.();
|
|
4907
4907
|
} catch (e) {
|
|
4908
|
-
|
|
4908
|
+
G(e);
|
|
4909
4909
|
}
|
|
4910
4910
|
this.observers.clear();
|
|
4911
4911
|
}
|
|
4912
4912
|
_reportError(t) {
|
|
4913
4913
|
if (!this.observers.size) {
|
|
4914
|
-
this._parent ||
|
|
4914
|
+
this._parent || G(t);
|
|
4915
4915
|
return;
|
|
4916
4916
|
}
|
|
4917
4917
|
let e = !1;
|
|
@@ -4921,10 +4921,10 @@ class Wr {
|
|
|
4921
4921
|
try {
|
|
4922
4922
|
i?.(t);
|
|
4923
4923
|
} catch (r) {
|
|
4924
|
-
|
|
4924
|
+
G(r);
|
|
4925
4925
|
}
|
|
4926
4926
|
}
|
|
4927
|
-
this.observers.clear(), e &&
|
|
4927
|
+
this.observers.clear(), e && G(t);
|
|
4928
4928
|
}
|
|
4929
4929
|
_error(t) {
|
|
4930
4930
|
this._stopProcedure(), this._reportError(t), this._parent && this.system._relay(this, this._parent, Mr(this.id, t));
|
|
@@ -4935,11 +4935,11 @@ class Wr {
|
|
|
4935
4935
|
// right now, they are being stopped within the machine's transition
|
|
4936
4936
|
// but that could throw and leave us with "orphaned" active actors
|
|
4937
4937
|
_stopProcedure() {
|
|
4938
|
-
return this._processingStatus !==
|
|
4938
|
+
return this._processingStatus !== P.Running ? this : (this.system.scheduler.cancelAll(this), this.mailbox.clear(), this.mailbox = new pn(this._process.bind(this)), this._processingStatus = P.Stopped, this.system._unregister(this), this);
|
|
4939
4939
|
}
|
|
4940
4940
|
/** @internal */
|
|
4941
4941
|
_send(t) {
|
|
4942
|
-
this._processingStatus !==
|
|
4942
|
+
this._processingStatus !== P.Stopped && this.mailbox.enqueue(t);
|
|
4943
4943
|
}
|
|
4944
4944
|
/**
|
|
4945
4945
|
* Sends an event to the running Actor to trigger a transition.
|
|
@@ -4999,7 +4999,7 @@ class Wr {
|
|
|
4999
4999
|
}
|
|
5000
5000
|
}
|
|
5001
5001
|
function Rt(s, ...[t]) {
|
|
5002
|
-
return new
|
|
5002
|
+
return new Dr(s, t);
|
|
5003
5003
|
}
|
|
5004
5004
|
function Kr(s, t, e, n, {
|
|
5005
5005
|
sendId: i
|
|
@@ -5056,7 +5056,7 @@ function jr(s, {
|
|
|
5056
5056
|
actorRef: t
|
|
5057
5057
|
}) {
|
|
5058
5058
|
t && s.defer(() => {
|
|
5059
|
-
t._processingStatus !==
|
|
5059
|
+
t._processingStatus !== P.Stopped && t.start();
|
|
5060
5060
|
});
|
|
5061
5061
|
}
|
|
5062
5062
|
function Fr(...[s, {
|
|
@@ -5069,7 +5069,7 @@ function Fr(...[s, {
|
|
|
5069
5069
|
}
|
|
5070
5070
|
return r.type = "xstate.spawnChild", r.id = t, r.systemId = e, r.src = s, r.input = n, r.syncSnapshot = i, r.resolve = Ur, r.execute = jr, r;
|
|
5071
5071
|
}
|
|
5072
|
-
function
|
|
5072
|
+
function Yr(s, t, e, n, {
|
|
5073
5073
|
actorRef: i
|
|
5074
5074
|
}) {
|
|
5075
5075
|
const r = typeof i == "function" ? i(e, n) : i, o = typeof r == "string" ? t.children[r] : r;
|
|
@@ -5082,7 +5082,7 @@ function Zr(s, t, e, n, {
|
|
|
5082
5082
|
}
|
|
5083
5083
|
function Gr(s, t) {
|
|
5084
5084
|
if (t) {
|
|
5085
|
-
if (s.system._unregister(t), t._processingStatus !==
|
|
5085
|
+
if (s.system._unregister(t), t._processingStatus !== P.Running) {
|
|
5086
5086
|
s.stopChild(t);
|
|
5087
5087
|
return;
|
|
5088
5088
|
}
|
|
@@ -5094,16 +5094,16 @@ function Gr(s, t) {
|
|
|
5094
5094
|
function es(s) {
|
|
5095
5095
|
function t(e, n) {
|
|
5096
5096
|
}
|
|
5097
|
-
return t.type = "xstate.stopChild", t.actorRef = s, t.resolve =
|
|
5097
|
+
return t.type = "xstate.stopChild", t.actorRef = s, t.resolve = Yr, t.execute = Gr, t;
|
|
5098
5098
|
}
|
|
5099
|
-
function
|
|
5099
|
+
function Ye(s, t, e, n) {
|
|
5100
5100
|
const {
|
|
5101
5101
|
machine: i
|
|
5102
5102
|
} = n, r = typeof s == "function", o = r ? s : i.implementations.guards[typeof s == "string" ? s : s.type];
|
|
5103
5103
|
if (!r && !o)
|
|
5104
5104
|
throw new Error(`Guard '${typeof s == "string" ? s : s.type}' is not implemented.'.`);
|
|
5105
5105
|
if (typeof o != "function")
|
|
5106
|
-
return
|
|
5106
|
+
return Ye(o, t, e, n);
|
|
5107
5107
|
const a = {
|
|
5108
5108
|
context: t,
|
|
5109
5109
|
event: e
|
|
@@ -5122,7 +5122,7 @@ const Ge = (s) => s.type === "atomic" || s.type === "final";
|
|
|
5122
5122
|
function Mt(s) {
|
|
5123
5123
|
return Object.values(s.states).filter((t) => t.type !== "history");
|
|
5124
5124
|
}
|
|
5125
|
-
function
|
|
5125
|
+
function Yt(s, t) {
|
|
5126
5126
|
const e = [];
|
|
5127
5127
|
if (t === s)
|
|
5128
5128
|
return e;
|
|
@@ -5178,11 +5178,11 @@ function is(s, t) {
|
|
|
5178
5178
|
const e = ce(t);
|
|
5179
5179
|
return ns(s, ss(e));
|
|
5180
5180
|
}
|
|
5181
|
-
function
|
|
5182
|
-
return t.type === "compound" ? Mt(t).some((e) => e.type === "final" && s.has(e)) : t.type === "parallel" ? Mt(t).every((e) =>
|
|
5181
|
+
function Ze(s, t) {
|
|
5182
|
+
return t.type === "compound" ? Mt(t).some((e) => e.type === "final" && s.has(e)) : t.type === "parallel" ? Mt(t).every((e) => Ze(s, e)) : t.type === "final";
|
|
5183
5183
|
}
|
|
5184
5184
|
const me = (s) => s[0] === Or;
|
|
5185
|
-
function
|
|
5185
|
+
function Zr(s, t) {
|
|
5186
5186
|
return s.transitions.get(t) || [...s.transitions.keys()].filter((n) => {
|
|
5187
5187
|
if (n === kr)
|
|
5188
5188
|
return !0;
|
|
@@ -5205,7 +5205,7 @@ function Vr(s) {
|
|
|
5205
5205
|
return [];
|
|
5206
5206
|
const e = (i) => {
|
|
5207
5207
|
const r = Cr(i, s.id), o = r.type;
|
|
5208
|
-
return s.entry.push(
|
|
5208
|
+
return s.entry.push(No(r, {
|
|
5209
5209
|
id: o,
|
|
5210
5210
|
delay: i
|
|
5211
5211
|
})), s.exit.push(zr(o)), o;
|
|
@@ -5250,27 +5250,27 @@ function Jr(s) {
|
|
|
5250
5250
|
const t = /* @__PURE__ */ new Map();
|
|
5251
5251
|
if (s.config.on)
|
|
5252
5252
|
for (const e of Object.keys(s.config.on)) {
|
|
5253
|
-
if (e ===
|
|
5253
|
+
if (e === Zn)
|
|
5254
5254
|
throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');
|
|
5255
5255
|
const n = s.config.on[e];
|
|
5256
|
-
t.set(e,
|
|
5256
|
+
t.set(e, It(n).map((i) => ht(s, e, i)));
|
|
5257
5257
|
}
|
|
5258
5258
|
if (s.config.onDone) {
|
|
5259
5259
|
const e = `xstate.done.state.${s.id}`;
|
|
5260
|
-
t.set(e,
|
|
5260
|
+
t.set(e, It(s.config.onDone).map((n) => ht(s, e, n)));
|
|
5261
5261
|
}
|
|
5262
5262
|
for (const e of s.invoke) {
|
|
5263
5263
|
if (e.onDone) {
|
|
5264
5264
|
const n = `xstate.done.actor.${e.id}`;
|
|
5265
|
-
t.set(n,
|
|
5265
|
+
t.set(n, It(e.onDone).map((i) => ht(s, n, i)));
|
|
5266
5266
|
}
|
|
5267
5267
|
if (e.onError) {
|
|
5268
5268
|
const n = `xstate.error.actor.${e.id}`;
|
|
5269
|
-
t.set(n,
|
|
5269
|
+
t.set(n, It(e.onError).map((i) => ht(s, n, i)));
|
|
5270
5270
|
}
|
|
5271
5271
|
if (e.onSnapshot) {
|
|
5272
5272
|
const n = `xstate.snapshot.${e.id}`;
|
|
5273
|
-
t.set(n,
|
|
5273
|
+
t.set(n, It(e.onSnapshot).map((i) => ht(s, n, i)));
|
|
5274
5274
|
}
|
|
5275
5275
|
}
|
|
5276
5276
|
for (const e of s.after) {
|
|
@@ -5334,7 +5334,7 @@ function pt(s) {
|
|
|
5334
5334
|
function En(s) {
|
|
5335
5335
|
const t = os(s);
|
|
5336
5336
|
for (const e of t)
|
|
5337
|
-
for (const n of
|
|
5337
|
+
for (const n of Yt(e, s))
|
|
5338
5338
|
t.add(n);
|
|
5339
5339
|
return t;
|
|
5340
5340
|
}
|
|
@@ -5457,7 +5457,7 @@ function as(s, t, e) {
|
|
|
5457
5457
|
}
|
|
5458
5458
|
function io(s) {
|
|
5459
5459
|
const [t, ...e] = s;
|
|
5460
|
-
for (const n of
|
|
5460
|
+
for (const n of Yt(t, void 0))
|
|
5461
5461
|
if (e.every((i) => nt(i, n)))
|
|
5462
5462
|
return n;
|
|
5463
5463
|
}
|
|
@@ -5538,23 +5538,23 @@ function ao(s, t, e, n, i, r, o, a) {
|
|
|
5538
5538
|
const l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set();
|
|
5539
5539
|
co(n, o, u, l), a && u.add(s.machine.root);
|
|
5540
5540
|
const h = /* @__PURE__ */ new Set();
|
|
5541
|
-
for (const d of [...l].sort((g,
|
|
5541
|
+
for (const d of [...l].sort((g, f) => g.order - f.order)) {
|
|
5542
5542
|
i.add(d);
|
|
5543
5543
|
const g = [];
|
|
5544
5544
|
g.push(...d.entry);
|
|
5545
|
-
for (const
|
|
5546
|
-
g.push(Fr(
|
|
5547
|
-
...
|
|
5548
|
-
syncSnapshot: !!
|
|
5545
|
+
for (const f of d.invoke)
|
|
5546
|
+
g.push(Fr(f.src, {
|
|
5547
|
+
...f,
|
|
5548
|
+
syncSnapshot: !!f.onSnapshot
|
|
5549
5549
|
}));
|
|
5550
5550
|
if (u.has(d)) {
|
|
5551
|
-
const
|
|
5552
|
-
g.push(...
|
|
5551
|
+
const f = d.initial.actions;
|
|
5552
|
+
g.push(...f);
|
|
5553
5553
|
}
|
|
5554
|
-
if (c = $t(c, t, e, g, r, d.invoke.map((
|
|
5555
|
-
const
|
|
5556
|
-
let E =
|
|
5557
|
-
for (
|
|
5554
|
+
if (c = $t(c, t, e, g, r, d.invoke.map((f) => f.id)), d.type === "final") {
|
|
5555
|
+
const f = d.parent;
|
|
5556
|
+
let E = f?.type === "parallel" ? f : f?.parent, A = E || d;
|
|
5557
|
+
for (f?.type === "compound" && r.push(Me(f.id, d.output !== void 0 ? xe(d.output, c.context, t, e.self) : void 0)); E?.type === "parallel" && !h.has(E) && Ze(i, E); )
|
|
5558
5558
|
h.add(E), r.push(Me(E.id)), A = E, E = E.parent;
|
|
5559
5559
|
if (E)
|
|
5560
5560
|
continue;
|
|
@@ -5574,44 +5574,44 @@ function co(s, t, e, n) {
|
|
|
5574
5574
|
(i.source !== a || // we know that the domain can't lie within the source
|
|
5575
5575
|
// if it's different than the source then it's outside of it and it means that the target has to be entered as well
|
|
5576
5576
|
i.source !== r || // reentering transitions always enter the target, even if it's the source itself
|
|
5577
|
-
i.reenter) && (n.add(a), e.add(a)),
|
|
5577
|
+
i.reenter) && (n.add(a), e.add(a)), Nt(a, t, e, n);
|
|
5578
5578
|
const o = Je(i, t);
|
|
5579
5579
|
for (const a of o) {
|
|
5580
|
-
const c =
|
|
5580
|
+
const c = Yt(a, r);
|
|
5581
5581
|
r?.type === "parallel" && c.push(r), ls(n, t, e, c, !i.source.parent && i.reenter ? void 0 : r);
|
|
5582
5582
|
}
|
|
5583
5583
|
}
|
|
5584
5584
|
}
|
|
5585
|
-
function
|
|
5585
|
+
function Nt(s, t, e, n) {
|
|
5586
5586
|
if (pt(s))
|
|
5587
5587
|
if (t[s.id]) {
|
|
5588
5588
|
const i = t[s.id];
|
|
5589
5589
|
for (const r of i)
|
|
5590
|
-
n.add(r),
|
|
5590
|
+
n.add(r), Nt(r, t, e, n);
|
|
5591
5591
|
for (const r of i)
|
|
5592
5592
|
Ae(r, s.parent, n, t, e);
|
|
5593
5593
|
} else {
|
|
5594
5594
|
const i = rs(s);
|
|
5595
5595
|
for (const r of i.target)
|
|
5596
|
-
n.add(r), i === s.parent?.initial && e.add(s.parent),
|
|
5596
|
+
n.add(r), i === s.parent?.initial && e.add(s.parent), Nt(r, t, e, n);
|
|
5597
5597
|
for (const r of i.target)
|
|
5598
5598
|
Ae(r, s.parent, n, t, e);
|
|
5599
5599
|
}
|
|
5600
5600
|
else if (s.type === "compound") {
|
|
5601
5601
|
const [i] = s.initial.target;
|
|
5602
|
-
pt(i) || (n.add(i), e.add(i)),
|
|
5602
|
+
pt(i) || (n.add(i), e.add(i)), Nt(i, t, e, n), Ae(i, s, n, t, e);
|
|
5603
5603
|
} else if (s.type === "parallel")
|
|
5604
5604
|
for (const i of Mt(s).filter((r) => !pt(r)))
|
|
5605
|
-
[...n].some((r) => nt(r, i)) || (pt(i) || (n.add(i), e.add(i)),
|
|
5605
|
+
[...n].some((r) => nt(r, i)) || (pt(i) || (n.add(i), e.add(i)), Nt(i, t, e, n));
|
|
5606
5606
|
}
|
|
5607
5607
|
function ls(s, t, e, n, i) {
|
|
5608
5608
|
for (const r of n)
|
|
5609
5609
|
if ((!i || nt(r, i)) && s.add(r), r.type === "parallel")
|
|
5610
5610
|
for (const o of Mt(r).filter((a) => !pt(a)))
|
|
5611
|
-
[...s].some((a) => nt(a, o)) || (s.add(o),
|
|
5611
|
+
[...s].some((a) => nt(a, o)) || (s.add(o), Nt(o, t, e, s));
|
|
5612
5612
|
}
|
|
5613
5613
|
function Ae(s, t, e, n, i) {
|
|
5614
|
-
ls(e, n, i,
|
|
5614
|
+
ls(e, n, i, Yt(s, t));
|
|
5615
5615
|
}
|
|
5616
5616
|
function lo(s, t, e, n, i, r, o, a) {
|
|
5617
5617
|
let c = s;
|
|
@@ -5621,7 +5621,7 @@ function lo(s, t, e, n, i, r, o, a) {
|
|
|
5621
5621
|
for (const h of l)
|
|
5622
5622
|
for (const d of no(h)) {
|
|
5623
5623
|
let g;
|
|
5624
|
-
d.history === "deep" ? g = (
|
|
5624
|
+
d.history === "deep" ? g = (f) => Ge(f) && nt(f, h) : g = (f) => f.parent === h, u ??= {
|
|
5625
5625
|
...r
|
|
5626
5626
|
}, u[d.id] = Array.from(i).filter(g);
|
|
5627
5627
|
}
|
|
@@ -5661,7 +5661,7 @@ function hs(s, t, e, n, i, r) {
|
|
|
5661
5661
|
});
|
|
5662
5662
|
continue;
|
|
5663
5663
|
}
|
|
5664
|
-
const g = u, [
|
|
5664
|
+
const g = u, [f, E, A] = g.resolve(
|
|
5665
5665
|
e,
|
|
5666
5666
|
a,
|
|
5667
5667
|
h,
|
|
@@ -5670,7 +5670,7 @@ function hs(s, t, e, n, i, r) {
|
|
|
5670
5670
|
// this holds all params
|
|
5671
5671
|
i
|
|
5672
5672
|
);
|
|
5673
|
-
a =
|
|
5673
|
+
a = f, "retryResolve" in g && r?.push([g, E]), "execute" in g && e.actionExecutor({
|
|
5674
5674
|
type: g.type,
|
|
5675
5675
|
info: h,
|
|
5676
5676
|
params: E,
|
|
@@ -5753,10 +5753,10 @@ function An(s, t) {
|
|
|
5753
5753
|
function uo(s, t) {
|
|
5754
5754
|
const e = /* @__PURE__ */ new Set(), n = s._nodes.filter(Ge);
|
|
5755
5755
|
for (const i of n)
|
|
5756
|
-
t: for (const r of [i].concat(
|
|
5756
|
+
t: for (const r of [i].concat(Yt(i, void 0)))
|
|
5757
5757
|
if (r.always) {
|
|
5758
5758
|
for (const o of r.always)
|
|
5759
|
-
if (o.guard === void 0 ||
|
|
5759
|
+
if (o.guard === void 0 || Ye(o.guard, s.context, t, s)) {
|
|
5760
5760
|
e.add(o);
|
|
5761
5761
|
break t;
|
|
5762
5762
|
}
|
|
@@ -5911,7 +5911,7 @@ function bo(s, t, e, n, {
|
|
|
5911
5911
|
delay: u
|
|
5912
5912
|
}, void 0];
|
|
5913
5913
|
}
|
|
5914
|
-
function
|
|
5914
|
+
function Io(s, t) {
|
|
5915
5915
|
const {
|
|
5916
5916
|
event: e,
|
|
5917
5917
|
delay: n,
|
|
@@ -5925,12 +5925,12 @@ function No(s, t) {
|
|
|
5925
5925
|
return;
|
|
5926
5926
|
}
|
|
5927
5927
|
}
|
|
5928
|
-
function
|
|
5928
|
+
function No(s, t) {
|
|
5929
5929
|
function e(n, i) {
|
|
5930
5930
|
}
|
|
5931
|
-
return e.type = "xstate.raise", e.event = s, e.id = t?.id, e.delay = t?.delay, e.resolve = bo, e.execute =
|
|
5931
|
+
return e.type = "xstate.raise", e.event = s, e.id = t?.id, e.delay = t?.delay, e.resolve = bo, e.execute = Io, e;
|
|
5932
5932
|
}
|
|
5933
|
-
function
|
|
5933
|
+
function To(s, {
|
|
5934
5934
|
machine: t,
|
|
5935
5935
|
context: e
|
|
5936
5936
|
}, n, i) {
|
|
@@ -5965,7 +5965,7 @@ function Io(s, {
|
|
|
5965
5965
|
return (o, a) => {
|
|
5966
5966
|
const c = r(o, a);
|
|
5967
5967
|
return i[c.id] = c, s.defer(() => {
|
|
5968
|
-
c._processingStatus !==
|
|
5968
|
+
c._processingStatus !== P.Stopped && c.start();
|
|
5969
5969
|
}), c;
|
|
5970
5970
|
};
|
|
5971
5971
|
}
|
|
@@ -5977,7 +5977,7 @@ function vo(s, t, e, n, {
|
|
|
5977
5977
|
const r = {}, o = {
|
|
5978
5978
|
context: t.context,
|
|
5979
5979
|
event: e.event,
|
|
5980
|
-
spawn:
|
|
5980
|
+
spawn: To(s, t, e.event, r),
|
|
5981
5981
|
self: s.self,
|
|
5982
5982
|
system: s.system
|
|
5983
5983
|
};
|
|
@@ -6010,7 +6010,7 @@ function bt(s, t, e) {
|
|
|
6010
6010
|
[t]: e()
|
|
6011
6011
|
}, bn.set(s, n)), n[t];
|
|
6012
6012
|
}
|
|
6013
|
-
const Oo = {},
|
|
6013
|
+
const Oo = {}, Dt = (s) => typeof s == "string" ? {
|
|
6014
6014
|
type: s
|
|
6015
6015
|
} : typeof s == "function" ? "resolve" in s ? {
|
|
6016
6016
|
type: s.type
|
|
@@ -6029,7 +6029,7 @@ class ue {
|
|
|
6029
6029
|
}
|
|
6030
6030
|
/** @internal */
|
|
6031
6031
|
_initialize() {
|
|
6032
|
-
this.transitions = Jr(this), this.config.always && (this.always =
|
|
6032
|
+
this.transitions = Jr(this), this.config.always && (this.always = It(this.config.always).map((t) => ht(this, Zn, t))), Object.keys(this.states).forEach((t) => {
|
|
6033
6033
|
this.states[t]._initialize();
|
|
6034
6034
|
});
|
|
6035
6035
|
}
|
|
@@ -6043,13 +6043,13 @@ class ue {
|
|
|
6043
6043
|
initial: this.initial ? {
|
|
6044
6044
|
target: this.initial.target,
|
|
6045
6045
|
source: this,
|
|
6046
|
-
actions: this.initial.actions.map(
|
|
6046
|
+
actions: this.initial.actions.map(Dt),
|
|
6047
6047
|
eventType: null,
|
|
6048
6048
|
reenter: !1,
|
|
6049
6049
|
toJSON: () => ({
|
|
6050
6050
|
target: this.initial.target.map((t) => `#${t.id}`),
|
|
6051
6051
|
source: `#${this.id}`,
|
|
6052
|
-
actions: this.initial.actions.map(
|
|
6052
|
+
actions: this.initial.actions.map(Dt),
|
|
6053
6053
|
eventType: null
|
|
6054
6054
|
})
|
|
6055
6055
|
} : void 0,
|
|
@@ -6058,10 +6058,10 @@ class ue {
|
|
|
6058
6058
|
on: this.on,
|
|
6059
6059
|
transitions: [...this.transitions.values()].flat().map((t) => ({
|
|
6060
6060
|
...t,
|
|
6061
|
-
actions: t.actions.map(
|
|
6061
|
+
actions: t.actions.map(Dt)
|
|
6062
6062
|
})),
|
|
6063
|
-
entry: this.entry.map(
|
|
6064
|
-
exit: this.exit.map(
|
|
6063
|
+
entry: this.entry.map(Dt),
|
|
6064
|
+
exit: this.exit.map(Dt),
|
|
6065
6065
|
meta: this.meta,
|
|
6066
6066
|
order: this.order || -1,
|
|
6067
6067
|
output: this.output,
|
|
@@ -6116,14 +6116,14 @@ class ue {
|
|
|
6116
6116
|
next(t, e) {
|
|
6117
6117
|
const n = e.type, i = [];
|
|
6118
6118
|
let r;
|
|
6119
|
-
const o = bt(this, `candidates-${n}`, () =>
|
|
6119
|
+
const o = bt(this, `candidates-${n}`, () => Zr(this, n));
|
|
6120
6120
|
for (const a of o) {
|
|
6121
6121
|
const {
|
|
6122
6122
|
guard: c
|
|
6123
6123
|
} = a, l = t.context;
|
|
6124
6124
|
let u = !1;
|
|
6125
6125
|
try {
|
|
6126
|
-
u = !c ||
|
|
6126
|
+
u = !c || Ye(c, l, e, t);
|
|
6127
6127
|
} catch (h) {
|
|
6128
6128
|
const d = typeof c == "string" ? c : typeof c == "object" ? c.type : void 0;
|
|
6129
6129
|
throw new Error(`Unable to evaluate guard ${d ? `'${d}' ` : ""}in transition for event '${n}' in state node '${this.id}':
|
|
@@ -6214,7 +6214,7 @@ class Xe {
|
|
|
6214
6214
|
_nodes: [...n],
|
|
6215
6215
|
context: t.context || {},
|
|
6216
6216
|
children: {},
|
|
6217
|
-
status:
|
|
6217
|
+
status: Ze(n, this.root) ? "done" : t.status || "active",
|
|
6218
6218
|
output: t.output,
|
|
6219
6219
|
error: t.error,
|
|
6220
6220
|
historyValue: t.historyValue
|
|
@@ -6307,7 +6307,7 @@ class Xe {
|
|
|
6307
6307
|
restoreSnapshot(t, e) {
|
|
6308
6308
|
const n = {}, i = t.children;
|
|
6309
6309
|
Object.keys(i).forEach((h) => {
|
|
6310
|
-
const d = i[h], g = d.snapshot,
|
|
6310
|
+
const d = i[h], g = d.snapshot, f = d.src, E = typeof f == "string" ? je(this, f) : f;
|
|
6311
6311
|
if (!E)
|
|
6312
6312
|
return;
|
|
6313
6313
|
const A = Rt(E, {
|
|
@@ -6315,7 +6315,7 @@ class Xe {
|
|
|
6315
6315
|
parent: e.self,
|
|
6316
6316
|
syncSnapshot: d.syncSnapshot,
|
|
6317
6317
|
snapshot: g,
|
|
6318
|
-
src:
|
|
6318
|
+
src: f,
|
|
6319
6319
|
systemId: d.systemId
|
|
6320
6320
|
});
|
|
6321
6321
|
n[h] = A;
|
|
@@ -6332,11 +6332,11 @@ class Xe {
|
|
|
6332
6332
|
if (!d || typeof d != "object")
|
|
6333
6333
|
return {};
|
|
6334
6334
|
const g = {};
|
|
6335
|
-
for (const
|
|
6336
|
-
const E = d[
|
|
6335
|
+
for (const f in d) {
|
|
6336
|
+
const E = d[f];
|
|
6337
6337
|
for (const A of E) {
|
|
6338
|
-
const
|
|
6339
|
-
|
|
6338
|
+
const I = r(h, A);
|
|
6339
|
+
I && (g[f] ??= [], g[f].push(I));
|
|
6340
6340
|
}
|
|
6341
6341
|
}
|
|
6342
6342
|
return g;
|
|
@@ -6351,13 +6351,13 @@ class Xe {
|
|
|
6351
6351
|
if (!l.has(h)) {
|
|
6352
6352
|
l.add(h);
|
|
6353
6353
|
for (const g in h) {
|
|
6354
|
-
const
|
|
6355
|
-
if (
|
|
6356
|
-
if ("xstate$$type" in
|
|
6357
|
-
h[g] = d[
|
|
6354
|
+
const f = h[g];
|
|
6355
|
+
if (f && typeof f == "object") {
|
|
6356
|
+
if ("xstate$$type" in f && f.xstate$$type === Fe) {
|
|
6357
|
+
h[g] = d[f.id];
|
|
6358
6358
|
continue;
|
|
6359
6359
|
}
|
|
6360
|
-
u(
|
|
6360
|
+
u(f, d);
|
|
6361
6361
|
}
|
|
6362
6362
|
}
|
|
6363
6363
|
}
|
|
@@ -6372,14 +6372,14 @@ const Xt = (s) => s === !1 ? !1 : s.map((t) => t.serialize()), Ro = (s) => s ===
|
|
|
6372
6372
|
tile: t.tile.toString(),
|
|
6373
6373
|
effectiveTiles: t.effectiveTiles.map((e) => e.toString()),
|
|
6374
6374
|
shanten: t.shanten
|
|
6375
|
-
})), qt = (s) => s === !1 ? !1 : ke(s),
|
|
6375
|
+
})), qt = (s) => s === !1 ? !1 : ke(s), In = (s) => Co(
|
|
6376
6376
|
{
|
|
6377
6377
|
id: "Untitled",
|
|
6378
6378
|
initial: "distribute",
|
|
6379
6379
|
context: {
|
|
6380
6380
|
currentWind: _.E,
|
|
6381
|
-
oneShotMap:
|
|
6382
|
-
missingMap:
|
|
6381
|
+
oneShotMap: B(!1),
|
|
6382
|
+
missingMap: B(!1),
|
|
6383
6383
|
controller: s,
|
|
6384
6384
|
genEventID: xo()
|
|
6385
6385
|
},
|
|
@@ -6693,12 +6693,12 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6693
6693
|
actions: {
|
|
6694
6694
|
updateNextWind: ({ context: t, event: e }) => {
|
|
6695
6695
|
const n = t.currentWind;
|
|
6696
|
-
t.currentWind =
|
|
6696
|
+
t.currentWind = Tt(n);
|
|
6697
6697
|
},
|
|
6698
6698
|
notify_distribution: ({ context: t, event: e }) => {
|
|
6699
6699
|
const n = t.genEventID(), i = t.controller.initialHands();
|
|
6700
6700
|
for (const r of Object.values(_)) {
|
|
6701
|
-
const o =
|
|
6701
|
+
const o = B("_____________");
|
|
6702
6702
|
o[r] = i[r].toString();
|
|
6703
6703
|
const a = {
|
|
6704
6704
|
id: n,
|
|
@@ -6776,7 +6776,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6776
6776
|
const i = t.genEventID(), r = t.currentWind;
|
|
6777
6777
|
let o = t.controller.doDiscard(r);
|
|
6778
6778
|
const a = t.controller.hand(t.currentWind).called.at(-1);
|
|
6779
|
-
(a instanceof
|
|
6779
|
+
(a instanceof q || a instanceof U) && (o = t.controller.doDiscard(r, a));
|
|
6780
6780
|
const c = {
|
|
6781
6781
|
id: i,
|
|
6782
6782
|
type: "CHOICE_AFTER_CALLED",
|
|
@@ -6879,7 +6879,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6879
6879
|
const a = t.currentWind;
|
|
6880
6880
|
t.controller.hand(a).reached || (t.missingMap[a] = !1);
|
|
6881
6881
|
for (const c of Object.values(_)) {
|
|
6882
|
-
let l = new y(
|
|
6882
|
+
let l = new y(p.BACK, 0, [m.TSUMO]);
|
|
6883
6883
|
c == a && (l = o);
|
|
6884
6884
|
const u = {
|
|
6885
6885
|
id: i,
|
|
@@ -6981,7 +6981,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6981
6981
|
t.oneShotMap[t.currentWind] = !1;
|
|
6982
6982
|
},
|
|
6983
6983
|
notify_end: ({ context: t, event: e }) => {
|
|
6984
|
-
const n = t.genEventID(), i =
|
|
6984
|
+
const n = t.genEventID(), i = B("");
|
|
6985
6985
|
if (e.type == "DRAWN_GAME_BY_NINE_ORPHANS") {
|
|
6986
6986
|
i[e.iam] = t.controller.hand(e.iam).toString();
|
|
6987
6987
|
for (const r of Object.values(_)) {
|
|
@@ -6993,7 +6993,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
6993
6993
|
shouldContinue: !0,
|
|
6994
6994
|
sticks: t.controller.placeManager.sticks,
|
|
6995
6995
|
scores: t.controller.scoreManager.summary,
|
|
6996
|
-
deltas:
|
|
6996
|
+
deltas: B(0),
|
|
6997
6997
|
hands: i
|
|
6998
6998
|
};
|
|
6999
6999
|
t.controller.emit(o);
|
|
@@ -7029,8 +7029,8 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
7029
7029
|
shouldContinue: !0,
|
|
7030
7030
|
sticks: t.controller.placeManager.sticks,
|
|
7031
7031
|
scores: t.controller.scoreManager.summary,
|
|
7032
|
-
deltas:
|
|
7033
|
-
hands:
|
|
7032
|
+
deltas: B(0),
|
|
7033
|
+
hands: B("")
|
|
7034
7034
|
};
|
|
7035
7035
|
t.controller.emit(a);
|
|
7036
7036
|
}
|
|
@@ -7043,7 +7043,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
|
|
|
7043
7043
|
const u = t.controller.hand(l);
|
|
7044
7044
|
new ge(u).calc() == 0 && (r.push(l), i[l] = u.toString());
|
|
7045
7045
|
}
|
|
7046
|
-
const o = r.length == 0 || r.length == 4, a =
|
|
7046
|
+
const o = r.length == 0 || r.length == 4, a = B(0);
|
|
7047
7047
|
for (const l of Object.values(_))
|
|
7048
7048
|
r.includes(l) ? a[l] += o ? 0 : 3e3 / r.length : a[l] -= o ? 0 : 3e3 / (4 - r.length);
|
|
7049
7049
|
const c = r.length == 4 || a[_.E] > 0;
|
|
@@ -7129,7 +7129,7 @@ class St {
|
|
|
7129
7129
|
return this.walls.drawable.length > 0;
|
|
7130
7130
|
}
|
|
7131
7131
|
initialHands() {
|
|
7132
|
-
const t =
|
|
7132
|
+
const t = B("");
|
|
7133
7133
|
for (let e = 0; e < 3; e++)
|
|
7134
7134
|
for (const n of Object.values(_))
|
|
7135
7135
|
for (let i = 0; i < 4; i++)
|
|
@@ -7142,13 +7142,13 @@ class St {
|
|
|
7142
7142
|
this.walls = St.clone(t);
|
|
7143
7143
|
return;
|
|
7144
7144
|
} else {
|
|
7145
|
-
for (let e of Object.values(
|
|
7146
|
-
if (e ==
|
|
7147
|
-
const n = e ==
|
|
7145
|
+
for (let e of Object.values(p)) {
|
|
7146
|
+
if (e == p.BACK) continue;
|
|
7147
|
+
const n = e == p.Z ? [1, 2, 3, 4, 5, 6, 7] : [1, 2, 3, 4, 5, 6, 7, 8, 9];
|
|
7148
7148
|
for (let i = 0; i < 4; i++)
|
|
7149
7149
|
for (let r of n) {
|
|
7150
7150
|
let o = new y(e, r);
|
|
7151
|
-
e !=
|
|
7151
|
+
e != p.Z && i == 3 && r == 5 && (o = o.clone({ add: m.RED })), this.walls.drawable.push(o.toString());
|
|
7152
7152
|
}
|
|
7153
7153
|
}
|
|
7154
7154
|
Fn(this.walls.drawable);
|
|
@@ -7178,7 +7178,7 @@ class St {
|
|
|
7178
7178
|
class ye {
|
|
7179
7179
|
wall = new St();
|
|
7180
7180
|
playerIDs;
|
|
7181
|
-
actor = Rt(
|
|
7181
|
+
actor = Rt(In(this), {});
|
|
7182
7182
|
observer;
|
|
7183
7183
|
handlers = {};
|
|
7184
7184
|
mailBox = {};
|
|
@@ -7283,7 +7283,7 @@ class ye {
|
|
|
7283
7283
|
b(o.choices.DAI_KAN, "daikan choice is none"), this.actor.send({
|
|
7284
7284
|
type: r.type,
|
|
7285
7285
|
iam: o.wind,
|
|
7286
|
-
block:
|
|
7286
|
+
block: Z.from(o.choices.DAI_KAN.tiles)
|
|
7287
7287
|
});
|
|
7288
7288
|
break;
|
|
7289
7289
|
case "CHI":
|
|
@@ -7293,7 +7293,7 @@ class ye {
|
|
|
7293
7293
|
r.events.length == 1,
|
|
7294
7294
|
`found more than one selected: ${JSON.stringify(r, null, 2)}`
|
|
7295
7295
|
);
|
|
7296
|
-
const c =
|
|
7296
|
+
const c = U.deserialize(a[0]);
|
|
7297
7297
|
this.actor.send({
|
|
7298
7298
|
type: r.type,
|
|
7299
7299
|
iam: o.wind,
|
|
@@ -7336,7 +7336,7 @@ class ye {
|
|
|
7336
7336
|
const u = o.choices[r.type];
|
|
7337
7337
|
b(u, `${r.type} choice is none`), this.actor.send({
|
|
7338
7338
|
type: r.type,
|
|
7339
|
-
block:
|
|
7339
|
+
block: C.from(u[0].tiles),
|
|
7340
7340
|
iam: a
|
|
7341
7341
|
});
|
|
7342
7342
|
break;
|
|
@@ -7345,7 +7345,7 @@ class ye {
|
|
|
7345
7345
|
const u = o.choices[r.type];
|
|
7346
7346
|
b(u, `${r.type} choice is none`), this.actor.send({
|
|
7347
7347
|
type: r.type,
|
|
7348
|
-
block:
|
|
7348
|
+
block: W.from(u[0].tiles),
|
|
7349
7349
|
iam: a
|
|
7350
7350
|
});
|
|
7351
7351
|
break;
|
|
@@ -7444,7 +7444,7 @@ class ye {
|
|
|
7444
7444
|
);
|
|
7445
7445
|
}
|
|
7446
7446
|
startGame() {
|
|
7447
|
-
for (; console.debug(`start========${this.placeManager.round}=============`), this.start(), this.wall = new St(), this.observer.applied = {}, this.mailBox = {}, this.actor = Rt(
|
|
7447
|
+
for (; console.debug(`start========${this.placeManager.round}=============`), this.start(), this.wall = new St(), this.observer.applied = {}, this.mailBox = {}, this.actor = Rt(In(this)), !this.placeManager.is(O.W1); )
|
|
7448
7448
|
;
|
|
7449
7449
|
}
|
|
7450
7450
|
finalResult(t, e) {
|
|
@@ -7479,7 +7479,7 @@ class ye {
|
|
|
7479
7479
|
if (n == null || t == e) return !1;
|
|
7480
7480
|
const i = this.hand(t);
|
|
7481
7481
|
if (i.reached || i.hands.length < 3 || i.get(n.t, n.n) < 2) return !1;
|
|
7482
|
-
const r = n.clone({ removeAll: !0 }), o = nn(t, e, w.PON), a = [], c = new
|
|
7482
|
+
const r = n.clone({ removeAll: !0 }), o = nn(t, e, w.PON), a = [], c = new U([r, r, r]).clone({
|
|
7483
7483
|
replace: { idx: o, tile: n.clone({ add: m.HORIZONTAL }) }
|
|
7484
7484
|
});
|
|
7485
7485
|
let l = c;
|
|
@@ -7503,7 +7503,7 @@ class ye {
|
|
|
7503
7503
|
return a;
|
|
7504
7504
|
}
|
|
7505
7505
|
doChi(t, e, n) {
|
|
7506
|
-
if (n == null || !n.isNum() ||
|
|
7506
|
+
if (n == null || !n.isNum() || Tt(e) != t) return !1;
|
|
7507
7507
|
const i = this.hand(t);
|
|
7508
7508
|
if (i.reached || i.hands.length < 3) return !1;
|
|
7509
7509
|
const r = n.clone({
|
|
@@ -7511,32 +7511,32 @@ class ye {
|
|
|
7511
7511
|
add: [m.HORIZONTAL]
|
|
7512
7512
|
}), o = [];
|
|
7513
7513
|
r.n - 2 >= 1 && i.get(n.t, r.n - 2) > 0 && i.get(n.t, r.n - 1) > 0 && o.push(
|
|
7514
|
-
new
|
|
7514
|
+
new q([
|
|
7515
7515
|
r,
|
|
7516
7516
|
new y(n.t, r.n - 1),
|
|
7517
7517
|
new y(n.t, r.n - 2)
|
|
7518
7518
|
])
|
|
7519
7519
|
), r.n + 2 <= 9 && i.get(n.t, r.n + 1) > 0 && i.get(n.t, r.n + 2) > 0 && o.push(
|
|
7520
|
-
new
|
|
7520
|
+
new q([
|
|
7521
7521
|
r,
|
|
7522
7522
|
new y(n.t, r.n + 1),
|
|
7523
7523
|
new y(n.t, r.n + 2)
|
|
7524
7524
|
])
|
|
7525
7525
|
), r.n - 1 >= 1 && r.n + 1 <= 9 && i.get(n.t, r.n - 1) > 0 && i.get(n.t, r.n + 1) > 0 && o.push(
|
|
7526
|
-
new
|
|
7526
|
+
new q([
|
|
7527
7527
|
r,
|
|
7528
7528
|
new y(n.t, r.n - 1),
|
|
7529
7529
|
new y(n.t, r.n + 1)
|
|
7530
7530
|
])
|
|
7531
7531
|
);
|
|
7532
7532
|
for (let d = 0; d < o.length; d++) {
|
|
7533
|
-
const g = o[d],
|
|
7534
|
-
for (const v of
|
|
7535
|
-
const
|
|
7536
|
-
for (let Et = 0; Et <
|
|
7533
|
+
const g = o[d], f = this.cannotDiscardTile(g), E = [];
|
|
7534
|
+
for (const v of f) {
|
|
7535
|
+
const x = i.get(v.t, v.n);
|
|
7536
|
+
for (let Et = 0; Et < x; Et++) E.push(v.clone({ remove: m.RED }));
|
|
7537
7537
|
}
|
|
7538
|
-
const A = i.dec([...E, g.tiles[1], g.tiles[2]]),
|
|
7539
|
-
i.inc(A),
|
|
7538
|
+
const A = i.dec([...E, g.tiles[1], g.tiles[2]]), I = i.hands.length == 0;
|
|
7539
|
+
i.inc(A), I && o.splice(d, 1);
|
|
7540
7540
|
}
|
|
7541
7541
|
if (o.length == 0) return !1;
|
|
7542
7542
|
const h = i.get(n.t, 0) > 0 ? this.redPattern(o) : [];
|
|
@@ -7563,7 +7563,7 @@ class ye {
|
|
|
7563
7563
|
if (this.hand(t).reached) return [this.hand(t).drawn];
|
|
7564
7564
|
const n = this.hand(t).hands;
|
|
7565
7565
|
if (e == null) return n;
|
|
7566
|
-
if (e instanceof
|
|
7566
|
+
if (e instanceof U)
|
|
7567
7567
|
return n.filter((o) => !o.equals(e.tiles[0]));
|
|
7568
7568
|
const i = this.cannotDiscardTile(e), r = n.filter((o) => !i.some((a) => o.equals(a)));
|
|
7569
7569
|
return b(
|
|
@@ -7580,10 +7580,10 @@ class ye {
|
|
|
7580
7580
|
doAnKan(t) {
|
|
7581
7581
|
const e = this.hand(t), n = [];
|
|
7582
7582
|
if (e.reached) return !1;
|
|
7583
|
-
for (const [i, r] of
|
|
7583
|
+
for (const [i, r] of F())
|
|
7584
7584
|
if (e.get(i, r) == 4) {
|
|
7585
7585
|
const o = new y(i, r), a = [o, o, o, o];
|
|
7586
|
-
k(o) && (a[1] = o.clone({ add: m.RED })), n.push(new
|
|
7586
|
+
k(o) && (a[1] = o.clone({ add: m.RED })), n.push(new C(a));
|
|
7587
7587
|
}
|
|
7588
7588
|
if (n.length == 0) return !1;
|
|
7589
7589
|
for (const i of n)
|
|
@@ -7596,7 +7596,7 @@ class ye {
|
|
|
7596
7596
|
doShoKan(t) {
|
|
7597
7597
|
const e = this.hand(t);
|
|
7598
7598
|
if (e.reached) return !1;
|
|
7599
|
-
const n = e.called.filter((r) => r instanceof
|
|
7599
|
+
const n = e.called.filter((r) => r instanceof U);
|
|
7600
7600
|
if (n.length == 0) return !1;
|
|
7601
7601
|
const i = [];
|
|
7602
7602
|
for (const r of n) {
|
|
@@ -7606,7 +7606,7 @@ class ye {
|
|
|
7606
7606
|
});
|
|
7607
7607
|
if (e.get(o.t, o.n) == 1) {
|
|
7608
7608
|
const a = k(o) && e.get(o.t, 0) > 0 ? o.clone({ add: m.RED }) : o;
|
|
7609
|
-
i.push(new
|
|
7609
|
+
i.push(new W([...r.tiles, a]));
|
|
7610
7610
|
}
|
|
7611
7611
|
}
|
|
7612
7612
|
if (i.length == 0) return !1;
|
|
@@ -7623,7 +7623,7 @@ class ye {
|
|
|
7623
7623
|
const r = n.clone({ removeAll: !0 });
|
|
7624
7624
|
if (i.get(r.t, r.n) != 3) return !1;
|
|
7625
7625
|
const o = nn(t, e, w.DAI_KAN);
|
|
7626
|
-
let a = new
|
|
7626
|
+
let a = new Z([r, r, r, r]).clone({
|
|
7627
7627
|
replace: { idx: o, tile: r.clone({ add: m.HORIZONTAL }) }
|
|
7628
7628
|
});
|
|
7629
7629
|
if (k(n) && n.has(m.RED))
|
|
@@ -7652,9 +7652,9 @@ class ye {
|
|
|
7652
7652
|
if (this.river.discards(t).length != 0) return !1;
|
|
7653
7653
|
const e = this.hand(t);
|
|
7654
7654
|
let n = 0;
|
|
7655
|
-
for (const i of Object.values(
|
|
7656
|
-
if (i ==
|
|
7657
|
-
const r = i ==
|
|
7655
|
+
for (const i of Object.values(p)) {
|
|
7656
|
+
if (i == p.BACK) continue;
|
|
7657
|
+
const r = i == p.Z ? jt : X;
|
|
7658
7658
|
for (const o of r)
|
|
7659
7659
|
e.get(i, o) > 0 && n++;
|
|
7660
7660
|
}
|
|
@@ -7666,29 +7666,29 @@ class ye {
|
|
|
7666
7666
|
}
|
|
7667
7667
|
class Ht extends ze {
|
|
7668
7668
|
isBackHand() {
|
|
7669
|
-
for (const t of Object.values(
|
|
7670
|
-
if (t !=
|
|
7669
|
+
for (const t of Object.values(p))
|
|
7670
|
+
if (t != p.BACK && this.sum(t) > 0)
|
|
7671
7671
|
return !1;
|
|
7672
|
-
return this.sum(
|
|
7672
|
+
return this.sum(p.BACK) > 0;
|
|
7673
7673
|
}
|
|
7674
7674
|
clone() {
|
|
7675
7675
|
const t = new Ht(this.toString());
|
|
7676
7676
|
return t.data.reached = this.data.reached, t;
|
|
7677
7677
|
}
|
|
7678
7678
|
dec(t) {
|
|
7679
|
-
return this.isBackHand() ? (super.dec(t.map(() => new y(
|
|
7679
|
+
return this.isBackHand() ? (super.dec(t.map(() => new y(p.BACK, 0))), [...t]) : super.dec(t);
|
|
7680
7680
|
}
|
|
7681
7681
|
}
|
|
7682
7682
|
class ds {
|
|
7683
7683
|
id;
|
|
7684
|
-
river = new
|
|
7684
|
+
river = new Yn();
|
|
7685
7685
|
placeManager = new ae({});
|
|
7686
7686
|
// empty for init
|
|
7687
7687
|
scoreManager = new oe({});
|
|
7688
7688
|
// empty for init
|
|
7689
|
-
hands =
|
|
7689
|
+
hands = B(new Ht(""));
|
|
7690
7690
|
// empty for init
|
|
7691
|
-
counter = new
|
|
7691
|
+
counter = new Ir();
|
|
7692
7692
|
doraIndicators = [];
|
|
7693
7693
|
// empty for init
|
|
7694
7694
|
eventHandler;
|
|
@@ -7734,17 +7734,17 @@ class ds {
|
|
|
7734
7734
|
case "PON":
|
|
7735
7735
|
case "CHI":
|
|
7736
7736
|
case "DAI_KAN": {
|
|
7737
|
-
const i =
|
|
7737
|
+
const i = T.deserialize(t.block);
|
|
7738
7738
|
this.hands[t.iam].call(i), this.river.markCalled(), t.iam != t.wind && this.counter.dec(...i.tiles.filter((r) => !r.has(m.HORIZONTAL)));
|
|
7739
7739
|
break;
|
|
7740
7740
|
}
|
|
7741
7741
|
case "SHO_KAN": {
|
|
7742
|
-
const i =
|
|
7742
|
+
const i = W.from(t.block.tiles);
|
|
7743
7743
|
this.hands[t.iam].kan(i), t.iam != t.wind && this.counter.dec(i.tiles.filter((r) => r.has(m.HORIZONTAL))[0]);
|
|
7744
7744
|
break;
|
|
7745
7745
|
}
|
|
7746
7746
|
case "AN_KAN": {
|
|
7747
|
-
const i =
|
|
7747
|
+
const i = C.from(t.block.tiles);
|
|
7748
7748
|
this.hands[t.iam].kan(i), t.iam != t.wind && this.counter.dec(...i.tiles.filter((r) => !r.has(m.HORIZONTAL)));
|
|
7749
7749
|
break;
|
|
7750
7750
|
}
|
|
@@ -7798,7 +7798,7 @@ class ds {
|
|
|
7798
7798
|
class $o extends ds {
|
|
7799
7799
|
applied = {};
|
|
7800
7800
|
constructor(t) {
|
|
7801
|
-
super("observer", t), this.counter.disable = !0, this.hands =
|
|
7801
|
+
super("observer", t), this.counter.disable = !0, this.hands = B(new Ht("_____________"));
|
|
7802
7802
|
}
|
|
7803
7803
|
setHands(t) {
|
|
7804
7804
|
this.hands[t.wind] = new Ht(t.hands[t.wind]);
|
|
@@ -7808,7 +7808,7 @@ class $o extends ds {
|
|
|
7808
7808
|
case "DISTRIBUTE":
|
|
7809
7809
|
let e = !0;
|
|
7810
7810
|
for (const n of Object.values(_))
|
|
7811
|
-
e &&= this.hand(n).get(
|
|
7811
|
+
e &&= this.hand(n).get(p.BACK, 0) == 0;
|
|
7812
7812
|
if (!e) break;
|
|
7813
7813
|
console.debug(
|
|
7814
7814
|
"DISTRIBUTE:",
|
|
@@ -7866,7 +7866,7 @@ class $o extends ds {
|
|
|
7866
7866
|
case "END_GAME":
|
|
7867
7867
|
for (const n of Object.values(_))
|
|
7868
7868
|
console.debug(
|
|
7869
|
-
`${this.placeManager.playerID(n)}(${
|
|
7869
|
+
`${this.placeManager.playerID(n)}(${De(n)})`,
|
|
7870
7870
|
`end hand: ${this.hand(n).toString()}`
|
|
7871
7871
|
);
|
|
7872
7872
|
console.debug(
|
|
@@ -7880,7 +7880,7 @@ class $o extends ds {
|
|
|
7880
7880
|
}
|
|
7881
7881
|
}
|
|
7882
7882
|
class Qt extends ds {
|
|
7883
|
-
river = new
|
|
7883
|
+
river = new Yn();
|
|
7884
7884
|
doras = [];
|
|
7885
7885
|
constructor(t, e) {
|
|
7886
7886
|
super(t, e), this.eventHandler.on((n) => this.handleEvent(n));
|
|
@@ -7930,7 +7930,7 @@ class Qt extends ds {
|
|
|
7930
7930
|
}
|
|
7931
7931
|
}
|
|
7932
7932
|
}
|
|
7933
|
-
class
|
|
7933
|
+
class Zo {
|
|
7934
7934
|
index = 0;
|
|
7935
7935
|
histories = [];
|
|
7936
7936
|
constructor(t) {
|
|
@@ -7951,20 +7951,20 @@ class Yo {
|
|
|
7951
7951
|
}
|
|
7952
7952
|
}
|
|
7953
7953
|
const Vo = (s) => {
|
|
7954
|
-
const [t, e] = Jt(), [n, i] = Jt(), [r, o] = Jt(), [a, c] = Jt(), l = ["player-1", "player-2", "player-3", "player-4"], u = s?.playerInjection, h = u?.p1 ?? Qt, d = u?.p2 ?? Qt, g = u?.p3 ?? Qt,
|
|
7954
|
+
const [t, e] = Jt(), [n, i] = Jt(), [r, o] = Jt(), [a, c] = Jt(), l = ["player-1", "player-2", "player-3", "player-4"], u = s?.playerInjection, h = u?.p1 ?? Qt, d = u?.p2 ?? Qt, g = u?.p3 ?? Qt, f = u?.p4 ?? Qt, E = new h(l[0], e), A = new d(l[1], i), I = new g(l[2], o), v = new f(l[3], c), x = [
|
|
7955
7955
|
{ handler: t, id: l[0] },
|
|
7956
7956
|
{ handler: n, id: l[1] },
|
|
7957
7957
|
{ handler: r, id: l[2] },
|
|
7958
7958
|
{ handler: a, id: l[3] }
|
|
7959
7959
|
];
|
|
7960
7960
|
return {
|
|
7961
|
-
c: new ye(
|
|
7961
|
+
c: new ye(x, {
|
|
7962
7962
|
debug: s?.debug,
|
|
7963
7963
|
shuffle: s?.shuffle
|
|
7964
7964
|
}),
|
|
7965
7965
|
p1: E,
|
|
7966
7966
|
p2: A,
|
|
7967
|
-
p3:
|
|
7967
|
+
p3: I,
|
|
7968
7968
|
p4: v
|
|
7969
7969
|
};
|
|
7970
7970
|
}, ct = (s, t) => {
|
|
@@ -8006,13 +8006,13 @@ class de {
|
|
|
8006
8006
|
static calcPriority(t, e, n) {
|
|
8007
8007
|
const i = e.tile;
|
|
8008
8008
|
let r = 0;
|
|
8009
|
-
if (i.t ==
|
|
8009
|
+
if (i.t == p.Z)
|
|
8010
8010
|
return r = t.get(i), (i.n == 5 || i.n == 6 || i.n == 7) && (r *= 2), r * ct(i, n);
|
|
8011
8011
|
{
|
|
8012
8012
|
const o = t.get(i);
|
|
8013
8013
|
r += o * ct(i, n);
|
|
8014
|
-
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)), u = t.get(new y(i.t, i.n - 2)), h = i.n - 2 > 0 ? Math.min(l, u) : 0, d = i.n + 2 <= 9 ? Math.min(a, c) : 0, g = i.n - 1 >= 1 && i.n + 1 <= 9 ? Math.min(a, l) : 0,
|
|
8015
|
-
return r += o * ct(i, n), r += h * ct(new y(i.t, i.n - 2), n), r += d * ct(new y(i.t, i.n + 2), n), r +=
|
|
8014
|
+
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)), u = t.get(new y(i.t, i.n - 2)), h = i.n - 2 > 0 ? Math.min(l, u) : 0, d = 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), E = Math.max(g, d);
|
|
8015
|
+
return r += o * ct(i, n), r += h * ct(new y(i.t, i.n - 2), n), r += d * ct(new y(i.t, i.n + 2), n), r += f * ct(new y(i.t, i.n - 1), n), r += E * ct(new y(i.t, i.n + 1), n), i.n == 0, r;
|
|
8016
8016
|
}
|
|
8017
8017
|
}
|
|
8018
8018
|
}
|
|
@@ -8036,7 +8036,7 @@ class zt {
|
|
|
8036
8036
|
return i;
|
|
8037
8037
|
}
|
|
8038
8038
|
static rankZ(t, e, n) {
|
|
8039
|
-
if (n.t !=
|
|
8039
|
+
if (n.t != p.Z) throw new Error(`expected TYPE.Z but ${n.toString()}`);
|
|
8040
8040
|
if (t.isSafeTile(n.t, n.n, e)) return 0;
|
|
8041
8041
|
const i = t.get(n);
|
|
8042
8042
|
return Math.min(i, 3);
|
|
@@ -8058,90 +8058,90 @@ export {
|
|
|
8058
8058
|
Ht as ActorHand,
|
|
8059
8059
|
w as BLOCK,
|
|
8060
8060
|
ds as BaseActor,
|
|
8061
|
-
|
|
8062
|
-
|
|
8061
|
+
T as Block,
|
|
8062
|
+
C as BlockAnKan,
|
|
8063
8063
|
fr as BlockCalculator,
|
|
8064
|
-
|
|
8065
|
-
|
|
8064
|
+
q as BlockChi,
|
|
8065
|
+
Z as BlockDaiKan,
|
|
8066
8066
|
Ut as BlockHand,
|
|
8067
8067
|
vn as BlockIsolated,
|
|
8068
8068
|
Sn as BlockOther,
|
|
8069
|
-
|
|
8070
|
-
|
|
8069
|
+
R as BlockPair,
|
|
8070
|
+
U as BlockPon,
|
|
8071
8071
|
dt as BlockRun,
|
|
8072
|
-
|
|
8073
|
-
|
|
8072
|
+
W as BlockShoKan,
|
|
8073
|
+
L as BlockThree,
|
|
8074
8074
|
ye as Controller,
|
|
8075
|
-
|
|
8075
|
+
Ir as Counter,
|
|
8076
8076
|
Ft as Efficiency,
|
|
8077
|
-
|
|
8078
|
-
|
|
8077
|
+
Nn as FONT_FAMILY,
|
|
8078
|
+
N as G,
|
|
8079
8079
|
ze as Hand,
|
|
8080
8080
|
ut as INPUT_SEPARATOR,
|
|
8081
8081
|
Hn as Image,
|
|
8082
|
-
|
|
8082
|
+
Dn as ImageHelper,
|
|
8083
8083
|
wt as Mark,
|
|
8084
8084
|
Po as MeasureText,
|
|
8085
8085
|
Ko as MyG,
|
|
8086
8086
|
Lo as MyImage,
|
|
8087
8087
|
Uo as MyRect,
|
|
8088
|
-
|
|
8088
|
+
Do as MySVG,
|
|
8089
8089
|
jo as MyText,
|
|
8090
8090
|
zo as MyUse,
|
|
8091
|
-
|
|
8091
|
+
X as N19,
|
|
8092
8092
|
jt as NZ,
|
|
8093
8093
|
m as OP,
|
|
8094
8094
|
$o as Observer,
|
|
8095
|
-
|
|
8095
|
+
K as Parser,
|
|
8096
8096
|
ae as PlaceManager,
|
|
8097
8097
|
Qt as Player,
|
|
8098
8098
|
de as PlayerEfficiency,
|
|
8099
8099
|
un as PointCalculator,
|
|
8100
8100
|
O as ROUND,
|
|
8101
|
-
|
|
8101
|
+
Tn as ROUND_MAP,
|
|
8102
8102
|
Pn as Rect,
|
|
8103
|
-
|
|
8103
|
+
Zo as Replayer,
|
|
8104
8104
|
zt as RiskRank,
|
|
8105
|
-
|
|
8105
|
+
Yn as River,
|
|
8106
8106
|
Qe as STICK_CONTEXT,
|
|
8107
8107
|
xi as SVG,
|
|
8108
8108
|
oe as ScoreManager,
|
|
8109
8109
|
ge as ShantenCalculator,
|
|
8110
8110
|
Mi as Svg,
|
|
8111
|
-
|
|
8111
|
+
Bn as Symbol,
|
|
8112
8112
|
ws as TABLE_CONTEXT,
|
|
8113
8113
|
gt as TILE_CONTEXT,
|
|
8114
|
-
|
|
8114
|
+
p as TYPE,
|
|
8115
8115
|
vt as Text,
|
|
8116
8116
|
y as Tile,
|
|
8117
8117
|
Le as Use,
|
|
8118
8118
|
_ as WIND,
|
|
8119
|
-
|
|
8119
|
+
Be as WIND_MAP,
|
|
8120
8120
|
St as Wall,
|
|
8121
8121
|
fe as compareTiles,
|
|
8122
8122
|
ur as convertInput,
|
|
8123
|
-
|
|
8123
|
+
In as createControllerMachine,
|
|
8124
8124
|
br as createEventEmitter,
|
|
8125
8125
|
Jt as createEventPipe,
|
|
8126
8126
|
Kt as createHand,
|
|
8127
8127
|
Vo as createLocalGame,
|
|
8128
8128
|
Gi as createTable,
|
|
8129
|
-
|
|
8129
|
+
B as createWindMap,
|
|
8130
8130
|
Vt as deserializeWinResult,
|
|
8131
8131
|
Fo as drawBlocks,
|
|
8132
8132
|
Go as drawTable,
|
|
8133
|
-
|
|
8133
|
+
F as forHand,
|
|
8134
8134
|
nn as getCallBlockIndex,
|
|
8135
8135
|
mr as getPointDescription,
|
|
8136
8136
|
xo as incrementalIDGenerator,
|
|
8137
8137
|
k as is5Tile,
|
|
8138
8138
|
te as nextRound,
|
|
8139
|
-
|
|
8140
|
-
|
|
8139
|
+
Tt as nextWind,
|
|
8140
|
+
Yo as optimizeSVG,
|
|
8141
8141
|
or as parse,
|
|
8142
8142
|
ar as parseTableInput,
|
|
8143
|
-
|
|
8144
|
-
|
|
8143
|
+
Bo as prevRound,
|
|
8144
|
+
De as prevWind,
|
|
8145
8145
|
wr as prioritizeDiscardedEvents,
|
|
8146
8146
|
Er as prioritizeDrawnEvents,
|
|
8147
8147
|
ke as serializeWinResult,
|