@konoui/mjimage 0.0.56 → 0.0.57

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.js CHANGED
@@ -15,7 +15,7 @@ const Tn = "MS Gothic, sans-serif", ft = {
15
15
  S: "s",
16
16
  Z: "z",
17
17
  BACK: "_"
18
- }, y = {
18
+ }, g = {
19
19
  TSUMO: "t",
20
20
  RON: "v",
21
21
  DORA: "d",
@@ -154,8 +154,8 @@ class Ns {
154
154
  const le = (n, t) => {
155
155
  if (n.t == t.t) {
156
156
  if (C(n) && C(t)) {
157
- if (n.has(y.RED)) return -1;
158
- if (t.has(y.RED)) return 1;
157
+ if (n.has(g.RED)) return -1;
158
+ if (t.has(g.RED)) return 1;
159
159
  }
160
160
  return n.n - t.n;
161
161
  }
@@ -169,20 +169,20 @@ const le = (n, t) => {
169
169
  return e[n.t] - e[t.t];
170
170
  }, vs = (n, t) => {
171
171
  const e = {
172
- [y.HORIZONTAL]: 1,
173
- [y.TSUMO]: 2,
174
- [y.RON]: 3,
175
- [y.DORA]: 4,
176
- [y.COLOR_GRAYSCALE]: 5,
177
- [y.RED]: 6
172
+ [g.HORIZONTAL]: 1,
173
+ [g.TSUMO]: 2,
174
+ [g.RON]: 3,
175
+ [g.DORA]: 4,
176
+ [g.COLOR_GRAYSCALE]: 5,
177
+ [g.RED]: 6
178
178
  };
179
179
  return e[n] - e[t];
180
180
  }, Ts = (n) => {
181
181
  const t = [];
182
182
  n.forEach((s, r) => {
183
- s.has(y.HORIZONTAL) && t.push(r);
183
+ s.has(g.HORIZONTAL) && t.push(r);
184
184
  });
185
- const e = n.filter((s) => !s.has(y.HORIZONTAL)).sort(le);
185
+ const e = n.filter((s) => !s.has(g.HORIZONTAL)).sort(le);
186
186
  return t.forEach((s) => {
187
187
  e.splice(s, 0, n[s]);
188
188
  }), e;
@@ -331,7 +331,7 @@ class x extends T {
331
331
  if (e.length < t.length) {
332
332
  if (C(s)) {
333
333
  const r = new w(s.t, 5);
334
- super([r.clone({ add: y.RED }), r, r, r], b.AN_KAN);
334
+ super([r.clone({ add: g.RED }), r, r, r], b.AN_KAN);
335
335
  return;
336
336
  }
337
337
  super([s, s, s, s], b.AN_KAN);
@@ -340,7 +340,7 @@ class x extends T {
340
340
  super(t, b.AN_KAN);
341
341
  }
342
342
  get tilesWithBack() {
343
- const t = this.tiles[0].clone({ remove: y.RED }), e = C(t) ? t.clone({ add: y.RED }) : t;
343
+ const t = this.tiles[0].clone({ remove: g.RED }), e = C(t) ? t.clone({ add: g.RED }) : t;
344
344
  return [new w(p.BACK, 0), e, t, new w(p.BACK, 0)];
345
345
  }
346
346
  static from(t) {
@@ -369,8 +369,8 @@ class K extends T {
369
369
  return T.deserialize({ tiles: t, type: b.SHO_KAN });
370
370
  }
371
371
  static fromPon(t, e) {
372
- const s = t.tiles.findIndex((i) => i.has(y.HORIZONTAL)), r = [...t.tiles];
373
- return r.splice(s, 0, e.clone({ add: y.HORIZONTAL })), new K(r);
372
+ const s = t.tiles.findIndex((i) => i.has(g.HORIZONTAL)), r = [...t.tiles];
373
+ return r.splice(s, 0, e.clone({ add: g.HORIZONTAL })), new K(r);
374
374
  }
375
375
  toString() {
376
376
  return gt(this.tiles);
@@ -545,9 +545,9 @@ class B {
545
545
  function nn(n) {
546
546
  if (n.length === 0) return b.UNKNOWN;
547
547
  if (n.length === 1)
548
- return n[0].has(y.DORA) ? b.IMAGE_DORA : n[0].has(y.TSUMO) ? b.TSUMO : b.HAND;
549
- const t = n.every((i) => i.equals(n[0])), e = n.filter((i) => i.has(y.HORIZONTAL)).length, s = n.filter(
550
- (i) => i.has(y.TSUMO) || i.has(y.DORA)
548
+ return n[0].has(g.DORA) ? b.IMAGE_DORA : n[0].has(g.TSUMO) ? b.TSUMO : b.HAND;
549
+ const t = n.every((i) => i.equals(n[0])), e = n.filter((i) => i.has(g.HORIZONTAL)).length, s = n.filter(
550
+ (i) => i.has(g.TSUMO) || i.has(g.DORA)
551
551
  ).length, r = n.filter((i) => i.t == p.BACK).length;
552
552
  if (s > 0) return b.UNKNOWN;
553
553
  if (e == 0 && r == 0) return b.HAND;
@@ -571,7 +571,7 @@ function Os(n) {
571
571
  function ks(n, t) {
572
572
  return n.map((e) => {
573
573
  const s = new w(t, e.n, e.ops);
574
- return s.isNum() && s.n == 0 ? s.clone({ n: 5, add: y.RED }) : s;
574
+ return s.isNum() && s.n == 0 ? s.clone({ n: 5, add: g.RED }) : s;
575
575
  });
576
576
  }
577
577
  function sn(n, t) {
@@ -591,7 +591,7 @@ function Cn(n) {
591
591
  return [t, e];
592
592
  }
593
593
  function Cs(n) {
594
- const t = Object.values(y);
594
+ const t = Object.values(g);
595
595
  if (!t.includes(n.char)) return [new w(p.BACK, 0), !1];
596
596
  const e = [];
597
597
  for (let s = 0; s < 4; s++) {
@@ -602,10 +602,10 @@ function Cs(n) {
602
602
  if (!o) break;
603
603
  for (const c of e) n.readChar();
604
604
  const a = new w(p.BACK, i, e);
605
- if (a.has(y.RED) && a.n != 5)
606
- throw new Error(`found ${y.RED} but number is not 5: ${i}`);
607
- if (a.has(y.DORA) && a.has(y.TSUMO))
608
- throw new Error(`unable to specify both ${y.DORA} and ${y.TSUMO}`);
605
+ if (a.has(g.RED) && a.n != 5)
606
+ throw new Error(`found ${g.RED} but number is not 5: ${i}`);
607
+ if (a.has(g.DORA) && a.has(g.TSUMO))
608
+ throw new Error(`unable to specify both ${g.DORA} and ${g.TSUMO}`);
609
609
  return [a, !0];
610
610
  }
611
611
  }
@@ -1422,8 +1422,8 @@ const Sr = function(n) {
1422
1422
  const l = a.rawTagName;
1423
1423
  let u = a.tagExp, h = a.attrExpPresent, d = a.closeIndex;
1424
1424
  this.options.transformTagName && (c = this.options.transformTagName(c)), e && s && e.tagname !== "!xml" && (s = this.saveTextToParentTag(s, e, r, !1));
1425
- const g = e;
1426
- g && this.options.unpairedTags.indexOf(g.tagname) !== -1 && (e = this.tagsNodeStack.pop(), r = r.substring(0, r.lastIndexOf("."))), c !== t.tagname && (r += r ? "." + c : c);
1425
+ const y = e;
1426
+ y && this.options.unpairedTags.indexOf(y.tagname) !== -1 && (e = this.tagsNodeStack.pop(), r = r.substring(0, r.lastIndexOf("."))), c !== t.tagname && (r += r ? "." + c : c);
1427
1427
  const f = i;
1428
1428
  if (this.isItStopNode(this.options.stopNodes, r, c)) {
1429
1429
  let m = "";
@@ -1704,8 +1704,8 @@ function Hn(n, t, e, s) {
1704
1704
  }
1705
1705
  let u = s;
1706
1706
  u !== "" && (u += t.indentBy);
1707
- const h = hn(a[":@"], t), d = s + `<${c}${h}`, g = Hn(a[c], t, l, u);
1708
- t.unpairedTags.indexOf(c) !== -1 ? t.suppressUnpairedNode ? r += d + ">" : r += d + "/>" : (!g || g.length === 0) && t.suppressEmptyNode ? r += d + "/>" : g && g.endsWith(">") ? r += d + `>${g}${s}</${c}>` : (r += d + ">", g && s !== "" && (g.includes("/>") || g.includes("</")) ? r += s + t.indentBy + g + s : r += g, r += `</${c}>`), i = !0;
1707
+ const h = hn(a[":@"], t), d = s + `<${c}${h}`, y = Hn(a[c], t, l, u);
1708
+ t.unpairedTags.indexOf(c) !== -1 ? t.suppressUnpairedNode ? r += d + ">" : r += d + "/>" : (!y || y.length === 0) && t.suppressEmptyNode ? r += d + "/>" : y && y.endsWith(">") ? r += d + `>${y}${s}</${c}>` : (r += d + ">", y && s !== "" && (y.includes("/>") || y.includes("</")) ? r += s + t.indentBy + y + s : r += y, r += `</${c}>`), i = !0;
1709
1709
  }
1710
1710
  return r;
1711
1711
  }
@@ -2131,8 +2131,8 @@ const j = (n, t) => {
2131
2131
  }, 0);
2132
2132
  return { width: n.tiles.reduce((a, c) => a + W(c, t).width, 0), height: i };
2133
2133
  }, W = (n, t) => {
2134
- const e = parseFloat((ft.HEIGHT * t).toPrecision(5)), s = parseFloat((ft.WIDTH * t).toPrecision(5)), r = n.has(y.HORIZONTAL) ? { width: e, height: s, baseWidth: s, baseHeight: e } : { width: s, height: e, w: s, baseWidth: s, baseHeight: e };
2135
- return (n.has(y.TSUMO) || n.has(y.DORA)) && (r.width += s * ft.TEXT_SCALE), r;
2134
+ const e = parseFloat((ft.HEIGHT * t).toPrecision(5)), s = parseFloat((ft.WIDTH * t).toPrecision(5)), r = n.has(g.HORIZONTAL) ? { width: e, height: s, baseWidth: s, baseHeight: e } : { width: s, height: e, w: s, baseWidth: s, baseHeight: e };
2135
+ return (n.has(g.TSUMO) || n.has(g.DORA)) && (r.width += s * ft.TEXT_SCALE), r;
2136
2136
  };
2137
2137
  class Tt {
2138
2138
  constructor(t = {}) {
@@ -2151,7 +2151,7 @@ class Tt {
2151
2151
  // image wrapper
2152
2152
  image(t) {
2153
2153
  let e = new Wn().load(this.buildURL(t));
2154
- return this.svgSprite && (e = new ze().use(Tt.buildID(t))), t instanceof w && t.has(y.COLOR_GRAYSCALE) && e.css({ filter: "contrast(65%)" }), e;
2154
+ return this.svgSprite && (e = new ze().use(Tt.buildID(t))), t instanceof w && t.has(g.COLOR_GRAYSCALE) && e.css({ filter: "contrast(65%)" }), e;
2155
2155
  }
2156
2156
  createImage(t, e, s) {
2157
2157
  const r = W(t, this.scale);
@@ -2176,7 +2176,7 @@ class Tt {
2176
2176
  static buildID(t) {
2177
2177
  if (t == 100 || t == 1e3)
2178
2178
  return t == 100 ? "stick100" : "stick1000";
2179
- const e = t.t == p.BACK || t.has(y.RED) ? 0 : t.n;
2179
+ const e = t.t == p.BACK || t.has(g.RED) ? 0 : t.n;
2180
2180
  return `${t.t}${e}`;
2181
2181
  }
2182
2182
  buildURL(t) {
@@ -2193,30 +2193,30 @@ class Ln extends Tt {
2193
2193
  const s = e instanceof x ? e.tilesWithBack : e.tiles, r = new v();
2194
2194
  let i = 0;
2195
2195
  for (const o of s) {
2196
- const a = W(o, this.scale), c = o.has(y.HORIZONTAL) ? this.createRotate90Image.bind(this) : this.createImage.bind(this), l = o.has(y.HORIZONTAL) ? this.getDiffTileHeightWidth(o) : 0, u = c(o, i, l);
2196
+ const a = W(o, this.scale), c = o.has(g.HORIZONTAL) ? this.createRotate90Image.bind(this) : this.createImage.bind(this), l = o.has(g.HORIZONTAL) ? this.getDiffTileHeightWidth(o) : 0, u = c(o, i, l);
2197
2197
  r.add(u), i += a.width;
2198
2198
  }
2199
2199
  return r;
2200
2200
  }
2201
2201
  createBlockPonChiKan(e) {
2202
- const s = e.tiles.findIndex((o) => o.has(y.HORIZONTAL));
2202
+ const s = e.tiles.findIndex((o) => o.has(g.HORIZONTAL));
2203
2203
  let r = 0;
2204
2204
  const i = new v();
2205
2205
  if (e.type == b.SHO_KAN) {
2206
2206
  let o = s;
2207
2207
  for (let a = 0; a < e.tiles.length; a++)
2208
- e.tiles[a].has(y.HORIZONTAL) && (o = a);
2208
+ e.tiles[a].has(g.HORIZONTAL) && (o = a);
2209
2209
  for (let a = 0; a < e.tiles.length; a++) {
2210
2210
  const c = W(e.tiles[a], this.scale);
2211
2211
  if (a == o) continue;
2212
2212
  if (a == s) {
2213
- const h = e.tiles[s], d = e.tiles[o], g = W(h, this.scale), f = this.createRotate90Image(h, 0, 0, !0), m = this.createRotate90Image(
2213
+ const h = e.tiles[s], d = e.tiles[o], y = W(h, this.scale), f = this.createRotate90Image(h, 0, 0, !0), m = this.createRotate90Image(
2214
2214
  d,
2215
2215
  0,
2216
- g.height,
2216
+ y.height,
2217
2217
  !0
2218
2218
  );
2219
- i.add(new v().translate(r, 0).add(f).add(m)), r += g.width;
2219
+ i.add(new v().translate(r, 0).add(f).add(m)), r += y.width;
2220
2220
  continue;
2221
2221
  }
2222
2222
  const l = c.width * 2 - c.height, u = this.createImage(e.tiles[a], r, l);
@@ -2273,12 +2273,12 @@ const Yr = (n, t) => {
2273
2273
  return { ...i, e: o };
2274
2274
  },
2275
2275
  [b.IMAGE_DORA]: function(r) {
2276
- r = (t == null ? void 0 : t.doraText) == !1 ? new Dt([r.tiles[0].clone({ remove: y.DORA })]) : r;
2276
+ r = (t == null ? void 0 : t.doraText) == !1 ? new Dt([r.tiles[0].clone({ remove: g.DORA })]) : r;
2277
2277
  const i = j(r, e), o = new v(), a = (t == null ? void 0 : t.doraText) === !1 ? n.createImage(r.tiles[0], 0, 0) : n.createTextImage(r.tiles[0], 0, 0, "(ドラ)");
2278
2278
  return o.add(a), { ...i, e: o };
2279
2279
  },
2280
2280
  [b.TSUMO]: function(r) {
2281
- r = (t == null ? void 0 : t.tsumoText) == !1 ? new Dt([r.tiles[0].clone({ remove: y.TSUMO })]) : r;
2281
+ r = (t == null ? void 0 : t.tsumoText) == !1 ? new Dt([r.tiles[0].clone({ remove: g.TSUMO })]) : r;
2282
2282
  const i = j(r, e), o = new v(), a = (t == null ? void 0 : t.tsumoText) === !1 ? n.createImage(r.tiles[0], 0, 0) : n.createTextImage(r.tiles[0], 0, 0, "(ツモ)");
2283
2283
  return o.add(a), { ...i, e: o };
2284
2284
  },
@@ -2303,7 +2303,7 @@ const Yr = (n, t) => {
2303
2303
  throw new Error("isolated is unsupported");
2304
2304
  },
2305
2305
  [b.UNKNOWN]: function(r) {
2306
- if (r.tiles.some((a) => a.has(y.TSUMO) || a.has(y.DORA)))
2306
+ if (r.tiles.some((a) => a.has(g.TSUMO) || a.has(g.DORA)))
2307
2307
  throw new Error("found an unknown block with operator tiles");
2308
2308
  const i = j(r, e), o = n.createBlockHandDiscard(r);
2309
2309
  return { ...i, e: o };
@@ -2314,14 +2314,14 @@ const Yr = (n, t) => {
2314
2314
  let r = 0, i = 0;
2315
2315
  const o = [];
2316
2316
  for (const h of t) {
2317
- const d = s[h.type], g = d(h);
2318
- i += g.width, r = g.height > r ? g.height : r, o.push(g);
2317
+ const d = s[h.type], y = d(h);
2318
+ i += y.width, r = y.height > r ? y.height : r, o.push(y);
2319
2319
  }
2320
2320
  const a = r, c = i + (t.length - 1) * n.blockMargin, l = new v();
2321
2321
  let u = 0;
2322
2322
  for (const h of o) {
2323
- const d = a - h.height, g = new v().translate(u, d);
2324
- g.add(h.e), l.add(g), u += h.width + n.blockMargin;
2323
+ const d = a - h.height, y = new v().translate(u, d);
2324
+ y.add(h.e), l.add(y), u += h.width + n.blockMargin;
2325
2325
  }
2326
2326
  return { e: l, width: c, height: a };
2327
2327
  }, Xo = (n, t, e = {}, s = {
@@ -2395,14 +2395,14 @@ const Yr = (n, t) => {
2395
2395
  }, ti = (n, t, e) => {
2396
2396
  const s = t.font, r = t.textWidth, i = t.textHeight, o = e.sticks.dead, a = e.sticks.reach, c = en.WIDTH * n.scale, l = en.HEIGHT * n.scale;
2397
2397
  let u = r * 3, h = i;
2398
- const d = (c + n.tileWidth + r - u) / 2, g = new Nt().plain(e.round).font(s).x(d).y(0);
2398
+ const d = (c + n.tileWidth + r - u) / 2, y = new Nt().plain(e.round).font(s).x(d).y(0);
2399
2399
  h += 25 * n.scale;
2400
2400
  const f = n.tileHeight, m = new v().size(c, f).translate(0, h), A = { family: s.family, size: s.size * 0.7 }, S = n.createStick(1e3).size(c, l).x(0).y(0), O = new Nt().plain(a.toString()).font(A).dx(c).dy(l), R = n.createStick(100).size(c, l).x(0).y(l + l), mt = new Nt().plain(o.toString()).font(A).dx(c).dy(l * 3);
2401
2401
  m.add(S), m.add(O), m.add(R), m.add(mt);
2402
2402
  const wt = n.createImage(e.doras[0], 0, 0).x(c + r).y(0);
2403
2403
  m.add(wt);
2404
2404
  const bt = new v();
2405
- return bt.add(g), bt.add(g), bt.add(m), {
2405
+ return bt.add(y), bt.add(y), bt.add(m), {
2406
2406
  e: bt,
2407
2407
  width: c + n.tileWidth + r,
2408
2408
  height: h + n.tileHeight
@@ -2422,11 +2422,11 @@ const Yr = (n, t) => {
2422
2422
  ), d = L(i.e, i.width, i.height, 180).translate(
2423
2423
  (c - i.width) / 2,
2424
2424
  0
2425
- ), g = L(o.e, o.width, o.height, 90).translate(
2425
+ ), y = L(o.e, o.width, o.height, 90).translate(
2426
2426
  0,
2427
2427
  (c - o.width) / 2
2428
2428
  ), f = new v().size(c, l);
2429
- return f.add(u), f.add(h), f.add(d), f.add(g), { e: new v().add(f), width: c, height: l };
2429
+ return f.add(u), f.add(h), f.add(d), f.add(y), { e: new v().add(f), width: c, height: l };
2430
2430
  }, ni = (n) => {
2431
2431
  const t = Object.values(Pe), e = t.indexOf(n);
2432
2432
  return [...t.slice(e), ...t.slice(0, e)];
@@ -2443,7 +2443,7 @@ const Yr = (n, t) => {
2443
2443
  width: i + a * tn.toString().length,
2444
2444
  height: o
2445
2445
  };
2446
- }, [u, h, d, g] = ni(
2446
+ }, [u, h, d, y] = ni(
2447
2447
  e.frontPlace
2448
2448
  ), f = e.scores, A = l(u, f.front, {
2449
2449
  x: s / 2,
@@ -2467,7 +2467,7 @@ const Yr = (n, t) => {
2467
2467
  s / 2 - R.width,
2468
2468
  -R.height
2469
2469
  );
2470
- let wt = l(g, f.left, {
2470
+ let wt = l(y, f.left, {
2471
2471
  "dominant-baseline": "ideographic",
2472
2472
  "text-anchor": "middle"
2473
2473
  });
@@ -2479,12 +2479,12 @@ const Yr = (n, t) => {
2479
2479
  }, ri = (n, t) => {
2480
2480
  const e = jt(t.front, n), s = jt(t.right, n), r = jt(t.opposite, n), i = jt(t.left, n), o = [e.height, s.height, r.height, i.height].reduce(
2481
2481
  (O, R) => Math.max(O, R)
2482
- ), a = n.tileWidth * 5 + n.tileHeight * 1, c = o, l = a + o * 2 + n.blockMargin, u = l, h = new v().size(l, u), d = l / 2 - a / 2, g = u / 2 - a / 2, f = L(e.e, a, c, 0).translate(
2482
+ ), a = n.tileWidth * 5 + n.tileHeight * 1, c = o, l = a + o * 2 + n.blockMargin, u = l, h = new v().size(l, u), d = l / 2 - a / 2, y = u / 2 - a / 2, f = L(e.e, a, c, 0).translate(
2483
2483
  d,
2484
2484
  u - c
2485
2485
  ), m = L(s.e, a, c, 270).translate(
2486
2486
  l - c,
2487
- g
2487
+ y
2488
2488
  ), A = L(
2489
2489
  r.e,
2490
2490
  a,
@@ -2492,7 +2492,7 @@ const Yr = (n, t) => {
2492
2492
  180
2493
2493
  ).translate(d, 0), S = L(i.e, a, c, 90).translate(
2494
2494
  0,
2495
- g
2495
+ y
2496
2496
  );
2497
2497
  return h.add(f), h.add(m), h.add(A), h.add(S), { e: new v().add(h), width: l, height: u };
2498
2498
  }, ii = (n, t, e, s, r) => {
@@ -3004,21 +3004,23 @@ class je {
3004
3004
  const t = [];
3005
3005
  for (const [e, s] of z()) {
3006
3006
  let r = this.get(e, s);
3007
- e != p.Z && s == 5 && this.get(e, 0) > 0 && (r -= this.get(e, 0), t.push(new w(e, s, [y.RED])));
3007
+ e != p.Z && s == 5 && this.get(e, 0) > 0 && (r -= this.get(e, 0), t.push(new w(e, s, [g.RED])));
3008
3008
  for (let i = 0; i < r; i++)
3009
3009
  t.push(new w(e, s));
3010
3010
  }
3011
3011
  if (this.drawn != null) {
3012
- const e = this.drawn, s = t.findIndex((r) => r.equals(e));
3012
+ const e = this.drawn, s = t.findIndex(
3013
+ (r) => r.equals(e) && e.has(g.RED) == r.has(g.RED)
3014
+ );
3013
3015
  N(
3014
3016
  s >= 0,
3015
3017
  `hand has drawn: ${this.drawn} but no tile in hands: ${t.join("")}`
3016
- ), t[s] = t[s].clone({ add: y.TSUMO });
3018
+ ), t[s] = t[s].clone({ add: g.TSUMO });
3017
3019
  }
3018
3020
  return t;
3019
3021
  }
3020
3022
  toString() {
3021
- const t = this.called.length > 0 ? `${lt}${this.called.join(lt)}` : "", e = this.drawn ? `${lt}${this.drawn.toString()}` : "", s = this.hands.filter((i) => !i.has(y.TSUMO));
3023
+ const t = this.called.length > 0 ? `${lt}${this.called.join(lt)}` : "", e = this.drawn ? `${lt}${this.drawn.toString()}` : "", s = this.hands.filter((i) => !i.has(g.TSUMO));
3022
3024
  return `${new Dt(s).toString()}${e}${t}`;
3023
3025
  }
3024
3026
  get called() {
@@ -3044,29 +3046,29 @@ class je {
3044
3046
  inc(t) {
3045
3047
  const e = [];
3046
3048
  for (const s of t) {
3047
- if (s.t != p.BACK && this.get(s.t, s.n) >= 4 || s.has(y.RED) && this.get(s.t, 0) > 0)
3049
+ if (s.t != p.BACK && this.get(s.t, s.n) >= 4 || s.has(g.RED) && this.get(s.t, 0) > 0)
3048
3050
  throw this.dec(e), new Error(`unable to increase ${s} in ${this.toString()}`);
3049
- e.push(s), s.t == p.BACK ? this.data[s.t][1] += 1 : (this.data[s.t][s.n] += 1, s.has(y.RED) && (this.data[s.t][0] += 1));
3051
+ e.push(s), s.t == p.BACK ? this.data[s.t][1] += 1 : (this.data[s.t][s.n] += 1, s.has(g.RED) && (this.data[s.t][0] += 1));
3050
3052
  }
3051
3053
  return e;
3052
3054
  }
3053
3055
  dec(t) {
3054
3056
  const e = [];
3055
3057
  for (const s of t) {
3056
- if (this.get(s.t, s.n) < 1 || s.has(y.RED) && this.get(s.t, 0) <= 0)
3058
+ if (this.get(s.t, s.n) < 1 || s.has(g.RED) && this.get(s.t, 0) <= 0)
3057
3059
  throw this.inc(e), new Error(
3058
3060
  `unable to decrease ${s.toString()} in ${this.toString()}`
3059
3061
  );
3060
- if (e.push(s), s.t == p.BACK ? this.data[s.t][1] -= 1 : (this.data[s.t][s.n] -= 1, s.has(y.RED) && (this.data[s.t][0] -= 1)), C(s) && this.get(s.t, 5) == 0 && this.get(s.t, 0) > 0) {
3062
+ if (e.push(s), s.t == p.BACK ? this.data[s.t][1] -= 1 : (this.data[s.t][s.n] -= 1, s.has(g.RED) && (this.data[s.t][0] -= 1)), C(s) && this.get(s.t, 5) == 0 && this.get(s.t, 0) > 0) {
3061
3063
  this.data[s.t][0] = 0;
3062
- const r = e.pop().clone({ add: y.RED });
3064
+ const r = e.pop().clone({ add: g.RED });
3063
3065
  e.push(r);
3064
3066
  }
3065
3067
  }
3066
3068
  return e;
3067
3069
  }
3068
3070
  draw(t) {
3069
- const e = t.clone({ add: y.TSUMO });
3071
+ const e = t.clone({ add: g.TSUMO });
3070
3072
  this.inc([e]), this.data.tsumo = e;
3071
3073
  }
3072
3074
  discard(t) {
@@ -3078,7 +3080,7 @@ class je {
3078
3080
  this.data.reached = !0;
3079
3081
  }
3080
3082
  call(t) {
3081
- const e = t.tiles.filter((s) => !s.has(y.HORIZONTAL));
3083
+ const e = t.tiles.filter((s) => !s.has(g.HORIZONTAL));
3082
3084
  if (e.length != t.tiles.length - 1)
3083
3085
  throw new Error(`removal: ${e} block: ${t}`);
3084
3086
  this.dec(e), this.data.called = [...this.called, t], this.data.tsumo = null;
@@ -3095,7 +3097,7 @@ class je {
3095
3097
  );
3096
3098
  if (e == -1) throw new Error(`unable to find ${t.tiles[0]}`);
3097
3099
  let s = t.tiles[0];
3098
- s = C(s) ? s.clone({ remove: y.RED }) : s, this.dec([s]), this.data.called = [
3100
+ s = C(s) ? s.clone({ remove: g.RED }) : s, this.dec([s]), this.data.called = [
3099
3101
  ...this.called.slice(0, e),
3100
3102
  ...this.called.slice(e + 1),
3101
3103
  t
@@ -3142,18 +3144,18 @@ class he {
3142
3144
  fourSetsOnePair() {
3143
3145
  const t = (s) => {
3144
3146
  const r = [0, 0, 0];
3145
- for (const [d, g] of z({ filterBy: [p.Z] }))
3146
- this.hand.get(d, g) >= 3 ? r[0]++ : this.hand.get(d, g) == 2 ? r[1]++ : this.hand.get(d, g) == 1 && r[2]++;
3147
+ for (const [d, y] of z({ filterBy: [p.Z] }))
3148
+ this.hand.get(d, y) >= 3 ? r[0]++ : this.hand.get(d, y) == 2 ? r[1]++ : this.hand.get(d, y) == 1 && r[2]++;
3147
3149
  const i = [0, 0, 0], o = this.hand.get(p.BACK, 0), a = o % 3;
3148
3150
  i[0] = Math.floor(o / 3), a == 2 ? i[1] = 1 : a == 1 && (i[2] = 1);
3149
3151
  let c = 13;
3150
3152
  const l = this.patternNumType(p.M), u = this.patternNumType(p.P), h = this.patternNumType(p.S);
3151
3153
  for (const d of [l.patternA, l.patternB])
3152
- for (const g of [u.patternA, u.patternB])
3154
+ for (const y of [u.patternA, u.patternB])
3153
3155
  for (const f of [h.patternA, h.patternB]) {
3154
3156
  const m = [this.hand.called.length, 0, 0];
3155
3157
  for (let S = 0; S < 3; S++)
3156
- m[S] += d[S] + g[S] + f[S] + r[S] + i[S];
3158
+ m[S] += d[S] + y[S] + f[S] + r[S] + i[S];
3157
3159
  const A = this.calcCommon(m[0], m[1], m[2], s);
3158
3160
  A < c && (c = A);
3159
3161
  }
@@ -3216,14 +3218,14 @@ class Ai {
3216
3218
  }
3217
3219
  markDrawn(t, e) {
3218
3220
  if (t.length == 0) return [];
3219
- const s = this.hand.drawn != null || e.has(y.TSUMO) ? y.TSUMO : y.RON, r = [];
3221
+ const s = this.hand.drawn != null || e.has(g.TSUMO) ? g.TSUMO : g.RON, r = [];
3220
3222
  for (let o = 0; o < t.length; o++) {
3221
3223
  const a = t[o], c = {};
3222
3224
  for (let l = 0; l < a.length; l++) {
3223
3225
  const u = a[l];
3224
3226
  if (u.isCalled()) continue;
3225
3227
  const h = u.tiles.findIndex(
3226
- (g) => g.equals(e) && e.has(y.RED) == g.has(y.RED)
3228
+ (y) => y.equals(e) && e.has(g.RED) == y.has(g.RED)
3227
3229
  );
3228
3230
  if (h < 0) continue;
3229
3231
  const d = Fn(u);
@@ -3422,7 +3424,7 @@ class fn {
3422
3424
  }
3423
3425
  a > 13 && a < 26 && (c = 8e3), this.cfg.roundUp8000 && (o == 30 && a == 4 || o == 60 && a == 3) && (c = 2e3);
3424
3426
  const l = e[r].hand.some(
3425
- (f) => f.tiles.some((m) => m.has(y.TSUMO))
3427
+ (f) => f.tiles.some((m) => m.has(g.TSUMO))
3426
3428
  ), u = this.cfg.orig.myWind, h = u == E.E, d = H(0);
3427
3429
  if (l) {
3428
3430
  const f = this.cfg.sticks.dead * 100;
@@ -3519,12 +3521,12 @@ class fn {
3519
3521
  return this.cfg.reached == 1 ? [{ name: "立直", double: 1 }] : this.cfg.reached == 2 ? [{ name: "ダブル立直", double: 2 }] : [];
3520
3522
  }
3521
3523
  dB1(t) {
3522
- return this.minus() != 0 ? [] : (this.hand.drawn == null, t.some((s) => s.tiles.some((r) => r.has(y.TSUMO))) ? [{ name: "門前清自摸和", double: 1 }] : []);
3524
+ return this.minus() != 0 ? [] : (this.hand.drawn == null, t.some((s) => s.tiles.some((r) => r.has(g.TSUMO))) ? [{ name: "門前清自摸和", double: 1 }] : []);
3523
3525
  }
3524
3526
  dC1(t) {
3525
3527
  if (this.minus() != 0) return [];
3526
3528
  const e = "平和", s = this.calcFu(t);
3527
- return s == 20 ? [{ name: e, double: 1 }] : !t.some((r) => r.tiles.some((i) => i.has(y.TSUMO))) && s == 30 ? [{ name: e, double: 1 }] : [];
3529
+ return s == 20 ? [{ name: e, double: 1 }] : !t.some((r) => r.tiles.some((i) => i.has(g.TSUMO))) && s == 30 ? [{ name: e, double: 1 }] : [];
3528
3530
  }
3529
3531
  dD1(t) {
3530
3532
  return t.some(
@@ -3563,7 +3565,7 @@ class fn {
3563
3565
  for (const a of o.tiles) {
3564
3566
  for (const c of this.cfg.doras) a.equals(c) && e++;
3565
3567
  for (const c of this.cfg.blindDoras) a.equals(c) && s++;
3566
- a.has(y.RED) && r++;
3568
+ a.has(g.RED) && r++;
3567
3569
  }
3568
3570
  const i = [];
3569
3571
  return e > 0 && i.push({ name: "ドラ", double: e }), r > 0 && i.push({ name: "赤ドラ", double: r }), this.hand.reached && s > 0 && i.push({ name: "裏ドラ", double: s }), i;
@@ -3595,7 +3597,7 @@ class fn {
3595
3597
  ) ? [{ name: "対々和", double: 2 }] : [];
3596
3598
  }
3597
3599
  dD2(t) {
3598
- return this.minus() != 0 ? [] : t.filter((s) => (s instanceof x || s instanceof F) && !s.tiles.some((r) => r.has(y.RON))).length >= 3 ? [{ name: "三暗刻", double: 2 }] : [];
3600
+ return this.minus() != 0 ? [] : t.filter((s) => (s instanceof x || s instanceof F) && !s.tiles.some((r) => r.has(g.RON))).length >= 3 ? [{ name: "三暗刻", double: 2 }] : [];
3599
3601
  }
3600
3602
  dE2(t) {
3601
3603
  return t.filter(
@@ -3675,7 +3677,7 @@ class fn {
3675
3677
  }
3676
3678
  dA13(t) {
3677
3679
  return t.length != 13 ? [] : t.some(
3678
- (s) => s instanceof P && s.tiles.some((r) => r.has(y.TSUMO) || r.has(y.RON))
3680
+ (s) => s instanceof P && s.tiles.some((r) => r.has(g.TSUMO) || r.has(g.RON))
3679
3681
  ) ? [{ name: "国士無双13面待ち", double: 26 }] : [{ name: "国士無双", double: 13 }];
3680
3682
  }
3681
3683
  dB13(t) {
@@ -3683,9 +3685,9 @@ class fn {
3683
3685
  }
3684
3686
  dC13(t) {
3685
3687
  return t.length == 7 ? [] : t.every(
3686
- (r) => r instanceof x || r instanceof F && !r.tiles.some((i) => i.has(y.RON)) || r instanceof P
3688
+ (r) => r instanceof x || r instanceof F && !r.tiles.some((i) => i.has(g.RON)) || r instanceof P
3687
3689
  ) ? t.some(
3688
- (r) => r instanceof P && r.tiles.every((i) => i.has(y.TSUMO) || i.has(y.RON))
3690
+ (r) => r instanceof P && r.tiles.every((i) => i.has(g.TSUMO) || i.has(g.RON))
3689
3691
  ) ? [{ name: "四暗刻単騎待ち", double: 26 }] : [{ name: "四暗刻", double: 13 }] : [];
3690
3692
  }
3691
3693
  dD13(t) {
@@ -3730,15 +3732,15 @@ class fn {
3730
3732
  const r = this.cfg.myWind.n, i = this.cfg.roundWind.n;
3731
3733
  if (t.length == 7) return 25;
3732
3734
  const o = t.find(
3733
- (f) => f.tiles.some((m) => m.has(y.TSUMO) || m.has(y.RON))
3734
- ), a = this.minus() == 1, c = o.tiles.some((f) => f.has(y.TSUMO)), l = (f, m) => {
3735
+ (f) => f.tiles.some((m) => m.has(g.TSUMO) || m.has(g.RON))
3736
+ ), a = this.minus() == 1, c = o.tiles.some((f) => f.has(g.TSUMO)), l = (f, m) => {
3735
3737
  const A = f.tiles[0];
3736
3738
  return A.t == p.Z && [5, 6, 7].includes(A.n) || A.t == p.Z && [r, i].includes(A.n) || V.includes(A.n) ? m * 2 : m;
3737
3739
  };
3738
3740
  for (const f of t)
3739
3741
  switch (!0) {
3740
3742
  case f instanceof F:
3741
- const m = f.tiles.some((A) => A.has(y.RON)) ? 2 : 4;
3743
+ const m = f.tiles.some((A) => A.has(g.RON)) ? 2 : 4;
3742
3744
  s += l(f, m);
3743
3745
  break;
3744
3746
  case f instanceof X:
@@ -3754,13 +3756,13 @@ class fn {
3754
3756
  s += ((f) => {
3755
3757
  if (f instanceof F) return 0;
3756
3758
  if (f instanceof P) return 2;
3757
- const m = f.tiles, A = m.findIndex((S) => S.has(y.TSUMO) || S.has(y.RON));
3759
+ const m = f.tiles, A = m.findIndex((S) => S.has(g.TSUMO) || S.has(g.RON));
3758
3760
  return A == 1 || A == 0 && m[2].n == 9 || A == 2 && m[0].n == 1 ? 2 : 0;
3759
3761
  })(o);
3760
3762
  const d = t.find((f) => f instanceof P).tiles[0];
3761
3763
  d.t == p.Z && ([5, 6, 7].includes(d.n) && (s += 2), d.n == i && (s += 2), d.n == r && (s += 2));
3762
- let g = !1;
3763
- return !a && s == 20 && (g = !0), c && !g && (s += 2), !c && !a && (s += 10), !c && !a && s == 30 && (g = !0), a && s == 20 && (s = 30), s;
3764
+ let y = !1;
3765
+ return !a && s == 20 && (y = !0), c && !y && (s += 2), !c && !a && (s += 10), !c && !a && s == 30 && (y = !0), a && s == 20 && (s = 30), s;
3764
3766
  }
3765
3767
  }
3766
3768
  const Fn = (n) => n.tiles.reduce((t, e) => `${t}${e.n}${e.t}`, ""), pn = (n) => {
@@ -3792,7 +3794,7 @@ class Lt {
3792
3794
  for (const o of e) {
3793
3795
  const a = t.dec([o]), c = Lt.candidateTiles(t, s);
3794
3796
  t.inc(a);
3795
- const l = s != null && s.arrangeRed && o.has(y.RED) ? o.clone({ removeAll: !0 }) : o.has(y.RED) ? o.clone({ removeAll: !0, add: y.RED }) : o.clone({ removeAll: !0 });
3797
+ const l = s != null && s.arrangeRed && o.has(g.RED) ? o.clone({ removeAll: !0 }) : o.has(g.RED) ? o.clone({ removeAll: !0, add: g.RED }) : o.clone({ removeAll: !0 });
3796
3798
  c.shanten < i ? (r.clear(), r.set(l.toString(), {
3797
3799
  shanten: c.shanten,
3798
3800
  candidates: c.candidates,
@@ -3997,7 +3999,7 @@ class Oi {
3997
3999
  throw new Error(
3998
4000
  `[counter] cannot decrease ${e.toString()} due to zero`
3999
4001
  );
4000
- this.c[e.t][e.n] -= 1, e.has(y.RED) && (this.c[e.t][0] -= 1);
4002
+ this.c[e.t][e.n] -= 1, e.has(g.RED) && (this.c[e.t][0] -= 1);
4001
4003
  }
4002
4004
  }
4003
4005
  }
@@ -4249,10 +4251,10 @@ function zi(n, t) {
4249
4251
  clock: a,
4250
4252
  logger: c
4251
4253
  } = t, l = {
4252
- schedule: (d, g, f, m, A = Math.random().toString(36).slice(2)) => {
4254
+ schedule: (d, y, f, m, A = Math.random().toString(36).slice(2)) => {
4253
4255
  const S = {
4254
4256
  source: d,
4255
- target: g,
4257
+ target: y,
4256
4258
  event: f,
4257
4259
  delay: m,
4258
4260
  id: A,
@@ -4260,65 +4262,65 @@ function zi(n, t) {
4260
4262
  }, O = _n(d, A);
4261
4263
  h._snapshot._scheduledEvents[O] = S;
4262
4264
  const R = a.setTimeout(() => {
4263
- delete o[O], delete h._snapshot._scheduledEvents[O], h._relay(d, g, f);
4265
+ delete o[O], delete h._snapshot._scheduledEvents[O], h._relay(d, y, f);
4264
4266
  }, m);
4265
4267
  o[O] = R;
4266
4268
  },
4267
- cancel: (d, g) => {
4268
- const f = _n(d, g), m = o[f];
4269
+ cancel: (d, y) => {
4270
+ const f = _n(d, y), m = o[f];
4269
4271
  delete o[f], delete h._snapshot._scheduledEvents[f], m !== void 0 && a.clearTimeout(m);
4270
4272
  },
4271
4273
  cancelAll: (d) => {
4272
- for (const g in h._snapshot._scheduledEvents) {
4273
- const f = h._snapshot._scheduledEvents[g];
4274
+ for (const y in h._snapshot._scheduledEvents) {
4275
+ const f = h._snapshot._scheduledEvents[y];
4274
4276
  f.source === d && l.cancel(d, f.id);
4275
4277
  }
4276
4278
  }
4277
4279
  }, u = (d) => {
4278
4280
  if (!i.size)
4279
4281
  return;
4280
- const g = {
4282
+ const y = {
4281
4283
  ...d,
4282
4284
  rootId: n.sessionId
4283
4285
  };
4284
4286
  i.forEach((f) => {
4285
4287
  var m;
4286
- return (m = f.next) == null ? void 0 : m.call(f, g);
4288
+ return (m = f.next) == null ? void 0 : m.call(f, y);
4287
4289
  });
4288
4290
  }, h = {
4289
4291
  _snapshot: {
4290
4292
  _scheduledEvents: ((t == null ? void 0 : t.snapshot) && t.snapshot.scheduler) ?? {}
4291
4293
  },
4292
4294
  _bookId: () => `x:${Li++}`,
4293
- _register: (d, g) => (e.set(d, g), d),
4295
+ _register: (d, y) => (e.set(d, y), d),
4294
4296
  _unregister: (d) => {
4295
4297
  e.delete(d.sessionId);
4296
- const g = r.get(d);
4297
- g !== void 0 && (s.delete(g), r.delete(d));
4298
+ const y = r.get(d);
4299
+ y !== void 0 && (s.delete(y), r.delete(d));
4298
4300
  },
4299
4301
  get: (d) => s.get(d),
4300
- _set: (d, g) => {
4302
+ _set: (d, y) => {
4301
4303
  const f = s.get(d);
4302
- if (f && f !== g)
4304
+ if (f && f !== y)
4303
4305
  throw new Error(`Actor with system ID '${d}' already exists.`);
4304
- s.set(d, g), r.set(g, d);
4306
+ s.set(d, y), r.set(y, d);
4305
4307
  },
4306
4308
  inspect: (d) => {
4307
- const g = Me(d);
4308
- return i.add(g), {
4309
+ const y = Me(d);
4310
+ return i.add(y), {
4309
4311
  unsubscribe() {
4310
- i.delete(g);
4312
+ i.delete(y);
4311
4313
  }
4312
4314
  };
4313
4315
  },
4314
4316
  _sendInspectionEvent: u,
4315
- _relay: (d, g, f) => {
4317
+ _relay: (d, y, f) => {
4316
4318
  h._sendInspectionEvent({
4317
4319
  type: "@xstate.event",
4318
4320
  sourceRef: d,
4319
- actorRef: g,
4321
+ actorRef: y,
4320
4322
  event: f
4321
- }), g._send(f);
4323
+ }), y._send(f);
4322
4324
  },
4323
4325
  scheduler: l,
4324
4326
  getSnapshot: () => ({
@@ -4329,14 +4331,14 @@ function zi(n, t) {
4329
4331
  start: () => {
4330
4332
  const d = h._snapshot._scheduledEvents;
4331
4333
  h._snapshot._scheduledEvents = {};
4332
- for (const g in d) {
4334
+ for (const y in d) {
4333
4335
  const {
4334
4336
  source: f,
4335
4337
  target: m,
4336
4338
  event: A,
4337
4339
  delay: S,
4338
4340
  id: O
4339
- } = d[g];
4341
+ } = d[y];
4340
4342
  l.schedule(f, m, A, S, O);
4341
4343
  }
4342
4344
  },
@@ -4398,10 +4400,10 @@ class Ui {
4398
4400
  h._stop();
4399
4401
  },
4400
4402
  emit: (h) => {
4401
- const d = this.eventListeners.get(h.type), g = this.eventListeners.get("*");
4402
- if (!d && !g)
4403
+ const d = this.eventListeners.get(h.type), y = this.eventListeners.get("*");
4404
+ if (!d && !y)
4403
4405
  return;
4404
- const f = [...d ? d.values() : [], ...g ? g.values() : []];
4406
+ const f = [...d ? d.values() : [], ...y ? y.values() : []];
4405
4407
  for (const m of f)
4406
4408
  m(h);
4407
4409
  },
@@ -4416,11 +4418,11 @@ class Ui {
4416
4418
  }
4417
4419
  }), !h.exec)
4418
4420
  return;
4419
- const g = be;
4421
+ const y = be;
4420
4422
  try {
4421
4423
  be = !0, h.exec(h.info, h.params);
4422
4424
  } finally {
4423
- be = g;
4425
+ be = y;
4424
4426
  }
4425
4427
  };
4426
4428
  this._processingStatus === $.Running ? d() : this._deferred.push(d);
@@ -5298,20 +5300,20 @@ function fo(n, t, e, s, r, i, o, a) {
5298
5300
  const l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set();
5299
5301
  po(s, o, u, l), a && u.add(n.machine.root);
5300
5302
  const h = /* @__PURE__ */ new Set();
5301
- for (const d of [...l].sort((g, f) => g.order - f.order)) {
5303
+ for (const d of [...l].sort((y, f) => y.order - f.order)) {
5302
5304
  r.add(d);
5303
- const g = [];
5304
- g.push(...d.entry);
5305
+ const y = [];
5306
+ y.push(...d.entry);
5305
5307
  for (const f of d.invoke)
5306
- g.push(Xi(f.src, {
5308
+ y.push(Xi(f.src, {
5307
5309
  ...f,
5308
5310
  syncSnapshot: !!f.onSnapshot
5309
5311
  }));
5310
5312
  if (u.has(d)) {
5311
5313
  const f = d.initial.actions;
5312
- g.push(...f);
5314
+ y.push(...f);
5313
5315
  }
5314
- if (c = Mt(c, t, e, g, i, d.invoke.map((f) => f.id)), d.type === "final") {
5316
+ if (c = Mt(c, t, e, y, i, d.invoke.map((f) => f.id)), d.type === "final") {
5315
5317
  const f = d.parent;
5316
5318
  let m = (f == null ? void 0 : f.type) === "parallel" ? f : f == null ? void 0 : f.parent, A = m || d;
5317
5319
  for ((f == null ? void 0 : f.type) === "compound" && i.push(Ce(f.id, d.output !== void 0 ? Re(d.output, c.context, t, e.self) : void 0)); (m == null ? void 0 : m.type) === "parallel" && !h.has(m) && Je(r, m); )
@@ -5381,10 +5383,10 @@ function go(n, t, e, s, r, i, o, a) {
5381
5383
  let u;
5382
5384
  for (const h of l)
5383
5385
  for (const d of ao(h)) {
5384
- let g;
5385
- d.history === "deep" ? g = (f) => Ve(f) && et(f, h) : g = (f) => f.parent === h, u ?? (u = {
5386
+ let y;
5387
+ d.history === "deep" ? y = (f) => Ve(f) && et(f, h) : y = (f) => f.parent === h, u ?? (u = {
5386
5388
  ...i
5387
- }), u[d.id] = Array.from(r).filter(g);
5389
+ }), u[d.id] = Array.from(r).filter(y);
5388
5390
  }
5389
5391
  for (const h of l)
5390
5392
  c = Mt(c, t, e, [...h.exit, ...h.invoke.map((d) => rs(d.id))], o, void 0), r.delete(h);
@@ -5422,7 +5424,7 @@ function fs(n, t, e, s, r, i) {
5422
5424
  });
5423
5425
  continue;
5424
5426
  }
5425
- const g = u, [f, m, A] = g.resolve(
5427
+ const y = u, [f, m, A] = y.resolve(
5426
5428
  e,
5427
5429
  a,
5428
5430
  h,
@@ -5431,11 +5433,11 @@ function fs(n, t, e, s, r, i) {
5431
5433
  // this holds all params
5432
5434
  r
5433
5435
  );
5434
- a = f, "retryResolve" in g && (i == null || i.push([g, m])), "execute" in g && e.actionExecutor({
5435
- type: g.type,
5436
+ a = f, "retryResolve" in y && (i == null || i.push([y, m])), "execute" in y && e.actionExecutor({
5437
+ type: y.type,
5436
5438
  info: h,
5437
5439
  params: m,
5438
- exec: g.execute.bind(null, e, m)
5440
+ exec: y.execute.bind(null, e, m)
5439
5441
  }), A && (a = fs(a, t, e, A, r, i));
5440
5442
  }
5441
5443
  return a;
@@ -5596,10 +5598,10 @@ function vo(n, t) {
5596
5598
  getMeta: u,
5597
5599
  toJSON: h,
5598
5600
  ...d
5599
- } = n, g = {};
5601
+ } = n, y = {};
5600
5602
  for (const m in i) {
5601
5603
  const A = i[m];
5602
- g[m] = {
5604
+ y[m] = {
5603
5605
  snapshot: A.getPersistedSnapshot(t),
5604
5606
  src: A.src,
5605
5607
  systemId: A._systemId,
@@ -5609,7 +5611,7 @@ function vo(n, t) {
5609
5611
  return {
5610
5612
  ...d,
5611
5613
  context: ps(o),
5612
- children: g
5614
+ children: y
5613
5615
  };
5614
5616
  }
5615
5617
  function ps(n) {
@@ -6059,7 +6061,7 @@ class Qe {
6059
6061
  const l = r[c], u = l.snapshot, h = l.src, d = typeof h == "string" ? Fe(this, h) : h;
6060
6062
  if (!d)
6061
6063
  return;
6062
- const g = kt(d, {
6064
+ const y = kt(d, {
6063
6065
  id: c,
6064
6066
  parent: e.self,
6065
6067
  syncSnapshot: l.syncSnapshot,
@@ -6067,7 +6069,7 @@ class Qe {
6067
6069
  src: h,
6068
6070
  systemId: l.systemId
6069
6071
  });
6070
- s[c] = g;
6072
+ s[c] = y;
6071
6073
  });
6072
6074
  const i = qt({
6073
6075
  ...t,
@@ -6466,7 +6468,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6466
6468
  t.controller.emit(a), t.controller.pollReplies(o, [r]);
6467
6469
  },
6468
6470
  notify_choice_after_discarded: ({ context: t, event: e }) => {
6469
- const s = t.genEventID(), r = t.controller.river.lastTile, i = r.t.clone({ add: y.HORIZONTAL });
6471
+ const s = t.genEventID(), r = t.controller.river.lastTile, i = r.t.clone({ add: g.HORIZONTAL });
6470
6472
  for (const o of Object.values(E)) {
6471
6473
  const a = {
6472
6474
  id: s,
@@ -6515,7 +6517,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6515
6517
  t.controller.emit(c), t.controller.pollReplies(r, [i]);
6516
6518
  },
6517
6519
  notify_choice_for_reach_acceptance: ({ context: t, event: e }) => {
6518
- const s = t.genEventID(), r = t.controller.river.lastTile, i = r.t.clone({ add: y.HORIZONTAL });
6520
+ const s = t.genEventID(), r = t.controller.river.lastTile, i = r.t.clone({ add: g.HORIZONTAL });
6519
6521
  for (const o of Object.values(E)) {
6520
6522
  const a = {
6521
6523
  id: s,
@@ -6541,11 +6543,11 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6541
6543
  e.type == "SHO_KAN" || e.type == "AN_KAN",
6542
6544
  `unexpected event ${e.type}`
6543
6545
  );
6544
- const s = t.genEventID(), r = e.block.tiles[0].clone({ remove: y.HORIZONTAL });
6546
+ const s = t.genEventID(), r = e.block.tiles[0].clone({ remove: g.HORIZONTAL });
6545
6547
  for (const i of Object.values(E)) {
6546
6548
  const o = t.controller.doWin(
6547
6549
  i,
6548
- e.block.tiles[0].clone({ remove: y.HORIZONTAL }),
6550
+ e.block.tiles[0].clone({ remove: g.HORIZONTAL }),
6549
6551
  {
6550
6552
  discardedBy: e.iam,
6551
6553
  quadWin: !0,
@@ -6606,7 +6608,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6606
6608
  const a = t.currentWind;
6607
6609
  t.controller.hand(a).reached || (t.missingMap[a] = !1);
6608
6610
  for (const c of Object.values(E)) {
6609
- let l = new w(p.BACK, 0, [y.TSUMO]);
6611
+ let l = new w(p.BACK, 0, [g.TSUMO]);
6610
6612
  c == a && (l = o);
6611
6613
  const u = {
6612
6614
  id: r,
@@ -6655,7 +6657,7 @@ CHI/PON の場合は鳴ける組み合わせの一覧`
6655
6657
  },
6656
6658
  notify_reach: ({ context: t, event: e }) => {
6657
6659
  N(e.type == "REACH", `unexpected event ${e.type}`);
6658
- const s = t.genEventID(), r = e.iam, i = e.tile.clone({ add: y.HORIZONTAL });
6660
+ const s = t.genEventID(), r = e.iam, i = e.tile.clone({ add: g.HORIZONTAL });
6659
6661
  t.oneShotMap[r] = !0;
6660
6662
  for (const o of Object.values(E)) {
6661
6663
  const a = {
@@ -6875,7 +6877,7 @@ class vt {
6875
6877
  for (let r = 0; r < 4; r++)
6876
6878
  for (let i of s) {
6877
6879
  let o = new w(e, i);
6878
- e != p.Z && r == 3 && i == 5 && (o = o.clone({ add: y.RED })), this.walls.drawable.push(o.toString());
6880
+ e != p.Z && r == 3 && i == 5 && (o = o.clone({ add: g.RED })), this.walls.drawable.push(o.toString());
6879
6881
  }
6880
6882
  }
6881
6883
  Vn(this.walls.drawable);
@@ -6935,7 +6937,7 @@ class fe {
6935
6937
  let s = this.hand(t).reached ? 1 : void 0;
6936
6938
  if (s) {
6937
6939
  const r = this.river.discards(t);
6938
- s = r.length == 0 || r.length == 1 && r[0].t.has(y.HORIZONTAL) ? 2 : 1;
6940
+ s = r.length == 0 || r.length == 1 && r[0].t.has(g.HORIZONTAL) ? 2 : 1;
6939
6941
  }
6940
6942
  return {
6941
6943
  doraMarkers: this.observer.doraMarkers,
@@ -7055,7 +7057,7 @@ class fe {
7055
7057
  const l = o.choices[i.type];
7056
7058
  N(l, `${i.type} choice is none`), this.actor.send({
7057
7059
  type: i.type,
7058
- tile: w.from(l[0]).clone({ remove: y.TSUMO }),
7060
+ tile: w.from(l[0]).clone({ remove: g.TSUMO }),
7059
7061
  iam: a
7060
7062
  });
7061
7063
  break;
@@ -7207,20 +7209,20 @@ class fe {
7207
7209
  const r = this.hand(t);
7208
7210
  if (r.reached || r.hands.length < 3 || r.get(s.t, s.n) < 2) return !1;
7209
7211
  const i = s.clone({ removeAll: !0 }), o = rn(t, e, b.PON), a = [], c = new X([i, i, i]).clone({
7210
- replace: { idx: o, tile: s.clone({ add: y.HORIZONTAL }) }
7212
+ replace: { idx: o, tile: s.clone({ add: g.HORIZONTAL }) }
7211
7213
  });
7212
7214
  let l = c;
7213
- C(s) && s.has(y.RED) && (l = c.clone({
7215
+ C(s) && s.has(g.RED) && (l = c.clone({
7214
7216
  replace: {
7215
7217
  idx: o,
7216
7218
  tile: i.clone({
7217
- add: [y.RED, y.HORIZONTAL]
7219
+ add: [g.RED, g.HORIZONTAL]
7218
7220
  })
7219
7221
  }
7220
7222
  }));
7221
7223
  const u = o % 2 + 1;
7222
7224
  if (C(s) && r.get(s.t, 0) > 0 && (l = c.clone({
7223
- replace: { idx: u, tile: i.clone({ add: y.RED }) }
7225
+ replace: { idx: u, tile: i.clone({ add: g.RED }) }
7224
7226
  })), a.push(l), C(i) && r.get(i.t, 5) == 3) {
7225
7227
  const h = c.clone({
7226
7228
  replace: { idx: u, tile: i }
@@ -7234,8 +7236,8 @@ class fe {
7234
7236
  const r = this.hand(t);
7235
7237
  if (r.reached || r.hands.length < 3) return !1;
7236
7238
  const i = s.clone({
7237
- remove: y.TSUMO,
7238
- add: [y.HORIZONTAL]
7239
+ remove: g.TSUMO,
7240
+ add: [g.HORIZONTAL]
7239
7241
  }), o = [];
7240
7242
  i.n - 2 >= 1 && r.get(s.t, i.n - 2) > 0 && r.get(s.t, i.n - 1) > 0 && o.push(
7241
7243
  new J([
@@ -7257,12 +7259,12 @@ class fe {
7257
7259
  ])
7258
7260
  );
7259
7261
  for (let d = 0; d < o.length; d++) {
7260
- const g = o[d], f = this.cannotDiscardTile(g), m = [];
7262
+ const y = o[d], f = this.cannotDiscardTile(y), m = [];
7261
7263
  for (const O of f) {
7262
7264
  const R = r.get(O.t, O.n);
7263
- for (let mt = 0; mt < R; mt++) m.push(O.clone({ remove: y.RED }));
7265
+ for (let mt = 0; mt < R; mt++) m.push(O.clone({ remove: g.RED }));
7264
7266
  }
7265
- const A = r.dec([...m, g.tiles[1], g.tiles[2]]), S = r.hands.length == 0;
7267
+ const A = r.dec([...m, y.tiles[1], y.tiles[2]]), S = r.hands.length == 0;
7266
7268
  r.inc(A), S && o.splice(d, 1);
7267
7269
  }
7268
7270
  if (o.length == 0) return !1;
@@ -7274,10 +7276,10 @@ class fe {
7274
7276
  (s) => C(s.tiles[1]) || C(s.tiles[2])
7275
7277
  ).map((s) => {
7276
7278
  if (C(s.tiles[1])) {
7277
- const r = s.tiles[1].clone({ add: y.RED });
7279
+ const r = s.tiles[1].clone({ add: g.RED });
7278
7280
  return s.clone({ replace: { idx: 1, tile: r } });
7279
7281
  } else if (C(s.tiles[2])) {
7280
- const r = s.tiles[2].clone({ add: y.RED });
7282
+ const r = s.tiles[2].clone({ add: g.RED });
7281
7283
  return s.clone({ replace: { idx: 2, tile: r } });
7282
7284
  }
7283
7285
  }).filter((s) => s != null);
@@ -7310,12 +7312,12 @@ class fe {
7310
7312
  for (const [r, i] of z())
7311
7313
  if (e.get(r, i) == 4) {
7312
7314
  const o = new w(r, i), a = [o, o, o, o];
7313
- C(o) && (a[1] = o.clone({ add: y.RED })), s.push(new x(a));
7315
+ C(o) && (a[1] = o.clone({ add: g.RED })), s.push(new x(a));
7314
7316
  }
7315
7317
  if (s.length == 0) return !1;
7316
7318
  for (const r of s)
7317
7319
  N(
7318
- r.tiles.filter((i) => i.has(y.HORIZONTAL)).length == 0,
7320
+ r.tiles.filter((i) => i.has(g.HORIZONTAL)).length == 0,
7319
7321
  `h op ${r.toString()}`
7320
7322
  );
7321
7323
  return s;
@@ -7329,17 +7331,17 @@ class fe {
7329
7331
  for (const i of s) {
7330
7332
  const o = i.tiles[0].clone({
7331
7333
  removeAll: !0,
7332
- add: y.HORIZONTAL
7334
+ add: g.HORIZONTAL
7333
7335
  });
7334
7336
  if (e.get(o.t, o.n) == 1) {
7335
- const a = C(o) && e.get(o.t, 0) > 0 ? o.clone({ add: y.RED }) : o;
7337
+ const a = C(o) && e.get(o.t, 0) > 0 ? o.clone({ add: g.RED }) : o;
7336
7338
  r.push(new K([...i.tiles, a]));
7337
7339
  }
7338
7340
  }
7339
7341
  if (r.length == 0) return !1;
7340
7342
  for (const i of r)
7341
7343
  N(
7342
- i.tiles.filter((o) => o.has(y.HORIZONTAL)).length == 2,
7344
+ i.tiles.filter((o) => o.has(g.HORIZONTAL)).length == 2,
7343
7345
  `h op ${i.toString()}`
7344
7346
  );
7345
7347
  return r;
@@ -7351,27 +7353,27 @@ class fe {
7351
7353
  if (r.get(i.t, i.n) != 3) return !1;
7352
7354
  const o = rn(t, e, b.DAI_KAN);
7353
7355
  let a = new Y([i, i, i, i]).clone({
7354
- replace: { idx: o, tile: i.clone({ add: y.HORIZONTAL }) }
7356
+ replace: { idx: o, tile: i.clone({ add: g.HORIZONTAL }) }
7355
7357
  });
7356
- if (C(s) && s.has(y.RED))
7358
+ if (C(s) && s.has(g.RED))
7357
7359
  a = a.clone({
7358
7360
  replace: {
7359
7361
  idx: o,
7360
- tile: i.clone({ add: [y.HORIZONTAL, y.RED] })
7362
+ tile: i.clone({ add: [g.HORIZONTAL, g.RED] })
7361
7363
  }
7362
7364
  });
7363
- else if (C(s) && !s.has(y.RED)) {
7365
+ else if (C(s) && !s.has(g.RED)) {
7364
7366
  N(
7365
7367
  r.get(s.t, 0) > 0,
7366
7368
  `hand does not have red tile: ${r.toString()}`
7367
7369
  );
7368
7370
  const c = o % 3 + 1;
7369
7371
  a = a.clone({
7370
- replace: { idx: c, tile: i.clone({ add: y.RED }) }
7372
+ replace: { idx: c, tile: i.clone({ add: g.RED }) }
7371
7373
  });
7372
7374
  }
7373
7375
  return N(
7374
- a.tiles.filter((c) => c.has(y.HORIZONTAL)).length == 1,
7376
+ a.tiles.filter((c) => c.has(g.HORIZONTAL)).length == 1,
7375
7377
  `h op ${a.toString()}`
7376
7378
  ), a;
7377
7379
  }
@@ -7462,17 +7464,17 @@ class gs {
7462
7464
  case "CHI":
7463
7465
  case "DAI_KAN": {
7464
7466
  const r = T.deserialize(t.block);
7465
- this.hands[t.iam].call(r), this.river.markCalled(), t.iam != t.wind && this.counter.dec(...r.tiles.filter((i) => !i.has(y.HORIZONTAL)));
7467
+ this.hands[t.iam].call(r), this.river.markCalled(), t.iam != t.wind && this.counter.dec(...r.tiles.filter((i) => !i.has(g.HORIZONTAL)));
7466
7468
  break;
7467
7469
  }
7468
7470
  case "SHO_KAN": {
7469
7471
  const r = K.from(t.block.tiles);
7470
- this.hands[t.iam].kan(r), t.iam != t.wind && this.counter.dec(r.tiles.filter((i) => i.has(y.HORIZONTAL))[0]);
7472
+ this.hands[t.iam].kan(r), t.iam != t.wind && this.counter.dec(r.tiles.filter((i) => i.has(g.HORIZONTAL))[0]);
7471
7473
  break;
7472
7474
  }
7473
7475
  case "AN_KAN": {
7474
7476
  const r = x.from(t.block.tiles);
7475
- this.hands[t.iam].kan(r), t.iam != t.wind && this.counter.dec(...r.tiles.filter((i) => !i.has(y.HORIZONTAL)));
7477
+ this.hands[t.iam].kan(r), t.iam != t.wind && this.counter.dec(...r.tiles.filter((i) => !i.has(g.HORIZONTAL)));
7476
7478
  break;
7477
7479
  }
7478
7480
  case "REACH": {
@@ -7677,7 +7679,7 @@ class Qo {
7677
7679
  }
7678
7680
  }
7679
7681
  const ta = (n) => {
7680
- const [t, e] = Zt(), [s, r] = Zt(), [i, o] = Zt(), [a, c] = Zt(), l = ["player-1", "player-2", "player-3", "player-4"], u = n == null ? void 0 : n.playerInjection, h = (u == null ? void 0 : u.p1) ?? Jt, d = (u == null ? void 0 : u.p2) ?? Jt, g = (u == null ? void 0 : u.p3) ?? Jt, f = (u == null ? void 0 : u.p4) ?? Jt, m = new h(l[0], e), A = new d(l[1], r), S = new g(l[2], o), O = new f(l[3], c), R = [
7682
+ const [t, e] = Zt(), [s, r] = Zt(), [i, o] = Zt(), [a, c] = Zt(), l = ["player-1", "player-2", "player-3", "player-4"], u = n == null ? void 0 : n.playerInjection, h = (u == null ? void 0 : u.p1) ?? Jt, d = (u == null ? void 0 : u.p2) ?? Jt, y = (u == null ? void 0 : u.p3) ?? Jt, f = (u == null ? void 0 : u.p4) ?? Jt, m = new h(l[0], e), A = new d(l[1], r), S = new y(l[2], o), O = new f(l[3], c), R = [
7681
7683
  { handler: t, id: l[0] },
7682
7684
  { handler: s, id: l[1] },
7683
7685
  { handler: i, id: l[2] },
@@ -7734,7 +7736,7 @@ class ce {
7734
7736
  {
7735
7737
  const o = t.get(r);
7736
7738
  i += o * ot(r, s);
7737
- const a = t.get(new w(r.t, r.n + 1)), c = t.get(new w(r.t, r.n + 2)), l = t.get(new w(r.t, r.n - 1)), u = t.get(new w(r.t, r.n - 2)), h = r.n - 2 > 0 ? Math.min(l, u) : 0, d = r.n + 2 <= 9 ? Math.min(a, c) : 0, g = r.n - 1 >= 1 && r.n + 1 <= 9 ? Math.min(a, l) : 0, f = Math.max(h, g), m = Math.max(g, d);
7739
+ const a = t.get(new w(r.t, r.n + 1)), c = t.get(new w(r.t, r.n + 2)), l = t.get(new w(r.t, r.n - 1)), u = t.get(new w(r.t, r.n - 2)), h = r.n - 2 > 0 ? Math.min(l, u) : 0, d = r.n + 2 <= 9 ? Math.min(a, c) : 0, y = r.n - 1 >= 1 && r.n + 1 <= 9 ? Math.min(a, l) : 0, f = Math.max(h, y), m = Math.max(y, d);
7738
7740
  return i += o * ot(r, s), i += h * ot(new w(r.t, r.n - 2), s), i += d * ot(new w(r.t, r.n + 2), s), i += f * ot(new w(r.t, r.n - 1), s), i += m * ot(new w(r.t, r.n + 1), s), r.n == 0, i;
7739
7741
  }
7740
7742
  }
@@ -7814,7 +7816,7 @@ export {
7814
7816
  Go as MyUse,
7815
7817
  V as N19,
7816
7818
  Kt as NZ,
7817
- y as OP,
7819
+ g as OP,
7818
7820
  Bo as Observer,
7819
7821
  B as Parser,
7820
7822
  re as PlaceManager,