@minicode-dev/chat 0.1.15 → 0.1.17

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.
Files changed (58) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +2 -0
  3. package/dist/chunks/{BattleshipGameCard-8H-sBCsv.js → BattleshipGameCard-DwNzgH5G.js} +199 -199
  4. package/dist/chunks/{BattleshipGameCard-8H-sBCsv.js.map → BattleshipGameCard-DwNzgH5G.js.map} +1 -1
  5. package/dist/chunks/{BattleshipPrototype-CmQd5AUO.js → BattleshipPrototype-CSQxQJt5.js} +52 -52
  6. package/dist/chunks/{BattleshipPrototype-CmQd5AUO.js.map → BattleshipPrototype-CSQxQJt5.js.map} +1 -1
  7. package/dist/chunks/{ChatContext-CVW58bzC.js → ChatContext-D5rqvt5D.js} +2 -2
  8. package/dist/chunks/{ChatContext-CVW58bzC.js.map → ChatContext-D5rqvt5D.js.map} +1 -1
  9. package/dist/chunks/RacingLiveGameCard-_wvhDRlG.js +1873 -0
  10. package/dist/chunks/RacingLiveGameCard-_wvhDRlG.js.map +1 -0
  11. package/dist/chunks/{TanksGameCard-DnCufSH6.js → TanksGameCard-B-gtDYYg.js} +137 -137
  12. package/dist/chunks/{TanksGameCard-DnCufSH6.js.map → TanksGameCard-B-gtDYYg.js.map} +1 -1
  13. package/dist/chunks/{TanksLiveGameCard-D_27Jomp.js → TanksLiveGameCard-DXgd1J2Y.js} +392 -392
  14. package/dist/chunks/{TanksLiveGameCard-D_27Jomp.js.map → TanksLiveGameCard-DXgd1J2Y.js.map} +1 -1
  15. package/dist/chunks/{avalancheScene3d-CIE2WKQn.js → avalancheScene3d-CNbQyGUd.js} +2 -2
  16. package/dist/chunks/{avalancheScene3d-CIE2WKQn.js.map → avalancheScene3d-CNbQyGUd.js.map} +1 -1
  17. package/dist/chunks/{connect4Sounds-BqEHULjv.js → connect4Sounds-3a6h7gUC.js} +8 -8
  18. package/dist/chunks/{connect4Sounds-BqEHULjv.js.map → connect4Sounds-3a6h7gUC.js.map} +1 -1
  19. package/dist/chunks/createLiveScene-jrzyQogh.js +756 -0
  20. package/dist/chunks/{createLiveScene-MTGRv8rx.js.map → createLiveScene-jrzyQogh.js.map} +1 -1
  21. package/dist/chunks/createRaceScene-C-aw0dlX.js +291 -0
  22. package/dist/chunks/createRaceScene-C-aw0dlX.js.map +1 -0
  23. package/dist/chunks/{createTankScene-yhX6la27.js → createTankScene-6asWHKFf.js} +123 -125
  24. package/dist/chunks/{createTankScene-yhX6la27.js.map → createTankScene-6asWHKFf.js.map} +1 -1
  25. package/dist/chunks/fx-BNJvJYOu.js +871 -0
  26. package/dist/chunks/fx-BNJvJYOu.js.map +1 -0
  27. package/dist/chunks/{games-Bl_8raG6.js → games-D_9SiSBT.js} +708 -697
  28. package/dist/chunks/games-D_9SiSBT.js.map +1 -0
  29. package/dist/chunks/tank-DIn6Jyt8.js +605 -0
  30. package/dist/chunks/tank-DIn6Jyt8.js.map +1 -0
  31. package/dist/chunks/{tanks-live-BcKmrhnV.js → tanks-live-BRhYW4MG.js} +36 -36
  32. package/dist/chunks/{tanks-live-BcKmrhnV.js.map → tanks-live-BRhYW4MG.js.map} +1 -1
  33. package/dist/chunks/{tanksSounds-DTnidbiq.js → tanksSounds-tYPzje61.js} +4 -4
  34. package/dist/chunks/{tanksSounds-DTnidbiq.js.map → tanksSounds-tYPzje61.js.map} +1 -1
  35. package/dist/chunks/track-C1TWWT19.js +557 -0
  36. package/dist/chunks/track-C1TWWT19.js.map +1 -0
  37. package/dist/index.js +4236 -4020
  38. package/dist/index.js.map +1 -1
  39. package/dist/styles.css +1 -1
  40. package/index.d.ts +3 -1
  41. package/package.json +1 -1
  42. package/dist/chunks/RacingLiveGameCard-8j9QLnxW.js +0 -1654
  43. package/dist/chunks/RacingLiveGameCard-8j9QLnxW.js.map +0 -1
  44. package/dist/chunks/createLiveScene-MTGRv8rx.js +0 -758
  45. package/dist/chunks/createRaceScene-BiEtQsVs.js +0 -306
  46. package/dist/chunks/createRaceScene-BiEtQsVs.js.map +0 -1
  47. package/dist/chunks/decor-CyyCnmct.js +0 -418
  48. package/dist/chunks/decor-CyyCnmct.js.map +0 -1
  49. package/dist/chunks/fx-1ZwzmPWj.js +0 -458
  50. package/dist/chunks/fx-1ZwzmPWj.js.map +0 -1
  51. package/dist/chunks/games-Bl_8raG6.js.map +0 -1
  52. package/dist/chunks/rolldown-runtime-CGnMp29N.js +0 -10
  53. package/dist/chunks/tank-DjEQ4FXF.js +0 -553
  54. package/dist/chunks/tank-DjEQ4FXF.js.map +0 -1
  55. package/dist/chunks/track-BcnnpnAm.js +0 -259
  56. package/dist/chunks/track-BcnnpnAm.js.map +0 -1
  57. package/dist/chunks/util-DwI9bfS7.js +0 -57
  58. package/dist/chunks/util-DwI9bfS7.js.map +0 -1
@@ -1,9 +1,9 @@
1
- import { i as e, o as t, r as n, t as r } from "./track-BcnnpnAm.js";
2
- import { a as i, c as a, i as o, n as s, r as c, s as l, t as u } from "./board-DXKuIZ1I.js";
3
- import { createStore as d } from "zustand/vanilla";
4
- import { useStore as f } from "zustand";
1
+ import { c as e, f as t, l as n, s as r, t as i, u as a } from "./track-C1TWWT19.js";
2
+ import { a as o, c as s, i as c, n as l, r as u, s as d, t as f } from "./board-DXKuIZ1I.js";
3
+ import { createStore as p } from "zustand/vanilla";
4
+ import { useStore as m } from "zustand";
5
5
  // src/core/ids/randomUuid.js
6
- function p(e = globalThis.crypto) {
6
+ function h(e = globalThis.crypto) {
7
7
  if (typeof e?.randomUUID == "function") return e.randomUUID();
8
8
  let t = /* @__PURE__ */ new Uint8Array(16);
9
9
  if (typeof e?.getRandomValues == "function") e.getRandomValues(t);
@@ -13,7 +13,7 @@ function p(e = globalThis.crypto) {
13
13
  return `${n.slice(0, 8)}-${n.slice(8, 12)}-${n.slice(12, 16)}-${n.slice(16, 20)}-${n.slice(20)}`;
14
14
  }
15
15
  // src/games/tanks-live/logic/simulation.js
16
- var m = Object.freeze({
16
+ var g = Object.freeze({
17
17
  speed: 16,
18
18
  reverse: 9,
19
19
  turn: 1.8,
@@ -22,8 +22,8 @@ var m = Object.freeze({
22
22
  reloadMs: 1500,
23
23
  shellSpeed: 60,
24
24
  damage: 25
25
- }), h = (e, t, n) => Math.max(t, Math.min(n, e)), g = (e, t) => Math.atan2(Math.sin(t - e), Math.cos(t - e));
26
- function _() {
25
+ }), _ = (e, t, n) => Math.max(t, Math.min(n, e)), v = (e, t) => Math.atan2(Math.sin(t - e), Math.cos(t - e));
26
+ function y() {
27
27
  return {
28
28
  size: 120,
29
29
  bounds: {
@@ -76,7 +76,7 @@ function _() {
76
76
  }))
77
77
  };
78
78
  }
79
- function v(e, t) {
79
+ function b(e, t) {
80
80
  return {
81
81
  id: String(e),
82
82
  x: t ? 102 : 18,
@@ -89,36 +89,36 @@ function v(e, t) {
89
89
  color: t ? "#d7463f" : "#54a34a"
90
90
  };
91
91
  }
92
- var y = Object.freeze({
92
+ var x = Object.freeze({
93
93
  radius: 6,
94
94
  damage: 20
95
- }), b = (e) => !!e && e.alive !== !1 && (e.hp === void 0 || e.hp > 0);
96
- function x(e, t, n) {
95
+ }), S = (e) => !!e && e.alive !== !1 && (e.hp === void 0 || e.hp > 0);
96
+ function ee(e, t, n) {
97
97
  let r = t - e.x, i = n - e.z, a = Math.cos(e.rot || 0), o = Math.sin(e.rot || 0);
98
98
  return [r * a + i * o, -r * o + i * a];
99
99
  }
100
- function S(e, t, n, r) {
100
+ function te(e, t, n, r) {
101
101
  if (r.shape !== "rect") return Math.hypot(e - r.x, t - r.z) < r.r + n;
102
- let [i, a] = x(r, e, t), o = r.w / 2, s = r.d / 2;
103
- return Math.hypot(i - h(i, -o, o), a - h(a, -s, s)) < n || Math.abs(i) <= o && Math.abs(a) <= s;
102
+ let [i, a] = ee(r, e, t), o = r.w / 2, s = r.d / 2;
103
+ return Math.hypot(i - _(i, -o, o), a - _(a, -s, s)) < n || Math.abs(i) <= o && Math.abs(a) <= s;
104
104
  }
105
- function ee(e, t, n, r = m.radius) {
105
+ function ne(e, t, n, r = g.radius) {
106
106
  let i = n.bounds;
107
- return e >= i.minX + r && e <= i.maxX - r && t >= i.minZ + r && t <= i.maxZ - r && !n.obstacles.some((n) => S(e, t, r, n)) && !(n.destructibles || []).some((n) => b(n) && S(e, t, r, n));
107
+ return e >= i.minX + r && e <= i.maxX - r && t >= i.minZ + r && t <= i.maxZ - r && !n.obstacles.some((n) => te(e, t, r, n)) && !(n.destructibles || []).some((n) => S(n) && te(e, t, r, n));
108
108
  }
109
- function te(e, t, n, r) {
109
+ function re(e, t, n, r) {
110
110
  if (!e.alive) return;
111
- let i = h(Number(t.throttle) || 0, -1, 1), a = h(Number(t.steer) || 0, -1, 1), o = i * (i < 0 ? m.reverse : m.speed);
112
- e.speed += h(o - e.speed, -m.acceleration * n, m.acceleration * n), e.yaw += a * m.turn * n, Number.isFinite(t.turretYaw) && (e.turretYaw = t.turretYaw);
111
+ let i = _(Number(t.throttle) || 0, -1, 1), a = _(Number(t.steer) || 0, -1, 1), o = i * (i < 0 ? g.reverse : g.speed);
112
+ e.speed += _(o - e.speed, -g.acceleration * n, g.acceleration * n), e.yaw += a * g.turn * n, Number.isFinite(t.turretYaw) && (e.turretYaw = t.turretYaw);
113
113
  let s = e.x + Math.cos(e.yaw) * e.speed * n, c = e.z + Math.sin(e.yaw) * e.speed * n;
114
- ee(s, e.z, r) ? e.x = s : e.speed = 0, ee(e.x, c, r) ? e.z = c : e.speed = 0;
114
+ ne(s, e.z, r) ? e.x = s : e.speed = 0, ne(e.x, c, r) ? e.z = c : e.speed = 0;
115
115
  }
116
- function ne(e, t, n, r, i, a, o) {
117
- let s = n - e, c = r - t, l = s * s + c * c, u = l ? h(((i - e) * s + (a - t) * c) / l, 0, 1) : 0;
116
+ function ie(e, t, n, r, i, a, o) {
117
+ let s = n - e, c = r - t, l = s * s + c * c, u = l ? _(((i - e) * s + (a - t) * c) / l, 0, 1) : 0;
118
118
  return Math.hypot(e + s * u - i, t + c * u - a) <= o ? u : null;
119
119
  }
120
- function re(e, t, n, r, i) {
121
- let [a, o] = x(i, e, t), [s, c] = x(i, n, r), l = [s - a, c - o], u = [a, o], d = [i.w / 2, i.d / 2], f = 0, p = 1;
120
+ function ae(e, t, n, r, i) {
121
+ let [a, o] = ee(i, e, t), [s, c] = ee(i, n, r), l = [s - a, c - o], u = [a, o], d = [i.w / 2, i.d / 2], f = 0, p = 1;
122
122
  for (let e = 0; e < 2; e++) {
123
123
  if (Math.abs(l[e]) < 1e-12) {
124
124
  if (Math.abs(u[e]) > d[e]) return null;
@@ -129,11 +129,11 @@ function re(e, t, n, r, i) {
129
129
  }
130
130
  return f;
131
131
  }
132
- var ie = (e, t, n, r, i) => i.shape === "rect" ? re(e, t, n, r, i) : ne(e, t, n, r, i.x, i.z, i.r);
133
- function ae(e, t, n, r) {
134
- let i = e.x + Math.cos(e.yaw) * m.shellSpeed * t, a = e.z + Math.sin(e.yaw) * m.shellSpeed * t, o = null;
132
+ var oe = (e, t, n, r, i) => i.shape === "rect" ? ae(e, t, n, r, i) : ie(e, t, n, r, i.x, i.z, i.r);
133
+ function se(e, t, n, r) {
134
+ let i = e.x + Math.cos(e.yaw) * g.shellSpeed * t, a = e.z + Math.sin(e.yaw) * g.shellSpeed * t, o = null;
135
135
  for (let t of n.obstacles) {
136
- let n = ie(e.x, e.z, i, a, t);
136
+ let n = oe(e.x, e.z, i, a, t);
137
137
  n !== null && (!o || n < o.t) && (o = t.shape === "rect" ? {
138
138
  t: n,
139
139
  kind: "obstacle",
@@ -146,8 +146,8 @@ function ae(e, t, n, r) {
146
146
  });
147
147
  }
148
148
  for (let t of n.destructibles || []) {
149
- if (!b(t)) continue;
150
- let n = ie(e.x, e.z, i, a, t);
149
+ if (!S(t)) continue;
150
+ let n = oe(e.x, e.z, i, a, t);
151
151
  n !== null && (!o || n < o.t) && (o = {
152
152
  t: n,
153
153
  kind: "destructible",
@@ -157,22 +157,22 @@ function ae(e, t, n, r) {
157
157
  }
158
158
  for (let t of r) {
159
159
  if (!t.alive || t.id === e.owner) continue;
160
- let n = ne(e.x, e.z, i, a, t.x, t.z, m.radius);
160
+ let n = ie(e.x, e.z, i, a, t.x, t.z, g.radius);
161
161
  n !== null && (!o || n < o.t) && (o = {
162
162
  t: n,
163
163
  kind: "tank",
164
164
  target: t.id
165
165
  });
166
166
  }
167
- return o ? (e.x += (i - e.x) * o.t, e.z += (a - e.z) * o.t, o) : (e.x = i, e.z = a, e.age += t, !ee(i, a, {
167
+ return o ? (e.x += (i - e.x) * o.t, e.z += (a - e.z) * o.t, o) : (e.x = i, e.z = a, e.age += t, !ne(i, a, {
168
168
  ...n,
169
169
  obstacles: [],
170
170
  destructibles: []
171
171
  }, 0) || e.age > 3 ? { kind: "terrain" } : null);
172
172
  }
173
- function oe(e, t, n = 1) {
173
+ function ce(e, t, n = 1) {
174
174
  let r = (e?.destructibles || []).find((e) => e.id === t);
175
- return b(r) ? (r.hp = Math.max(0, (r.hp ?? 1) - Math.max(0, Number(n) || 0)), r.hp === 0 && (r.alive = !1), {
175
+ return S(r) ? (r.hp = Math.max(0, (r.hp ?? 1) - Math.max(0, Number(n) || 0)), r.hp === 0 && (r.alive = !1), {
176
176
  destroyed: r.hp === 0,
177
177
  kind: r.kind,
178
178
  hp: r.hp
@@ -182,22 +182,22 @@ function oe(e, t, n = 1) {
182
182
  hp: 0
183
183
  };
184
184
  }
185
- function se(e, t, n, r = y.radius, i = y.damage) {
185
+ function le(e, t, n, r = x.radius, i = x.damage) {
186
186
  return e.filter((e) => e.alive !== !1 && Math.hypot(e.x - t, e.z - n) <= r).map((e) => ({
187
187
  id: e.id,
188
188
  dmg: i
189
189
  }));
190
190
  }
191
- function ce(e, t, n) {
191
+ function ue(e, t, n) {
192
192
  let r = (e?.destructibles || []).find((e) => e.id === t);
193
193
  if (!r) return {
194
194
  hits: [],
195
195
  chained: null
196
196
  };
197
- let i = [r], a = (e.destructibles || []).filter((e) => e !== r && e.kind === "barrel" && b(e) && Math.hypot(e.x - r.x, e.z - r.z) <= y.radius).sort((e, t) => Math.hypot(e.x - r.x, e.z - r.z) - Math.hypot(t.x - r.x, t.z - r.z))[0];
197
+ let i = [r], a = (e.destructibles || []).filter((e) => e !== r && e.kind === "barrel" && S(e) && Math.hypot(e.x - r.x, e.z - r.z) <= x.radius).sort((e, t) => Math.hypot(e.x - r.x, e.z - r.z) - Math.hypot(t.x - r.x, t.z - r.z))[0];
198
198
  a && (a.hp = 0, a.alive = !1, i.push(a));
199
199
  let o = /* @__PURE__ */ new Map();
200
- for (let e of i) for (let t of se(n, e.x, e.z)) o.set(t.id, (o.get(t.id) || 0) + t.dmg);
200
+ for (let e of i) for (let t of le(n, e.x, e.z)) o.set(t.id, (o.get(t.id) || 0) + t.dmg);
201
201
  return {
202
202
  hits: [...o].map(([e, t]) => ({
203
203
  id: e,
@@ -210,30 +210,30 @@ function ce(e, t, n) {
210
210
  } : null
211
211
  };
212
212
  }
213
- function le(e, t, n) {
214
- let r = h(n, 0, 1);
213
+ function de(e, t, n) {
214
+ let r = _(n, 0, 1);
215
215
  return {
216
216
  ...t,
217
217
  x: e.x + (t.x - e.x) * r,
218
218
  z: e.z + (t.z - e.z) * r,
219
- yaw: e.yaw + g(e.yaw, t.yaw) * r,
220
- turretYaw: e.turretYaw + g(e.turretYaw, t.turretYaw) * r
219
+ yaw: e.yaw + v(e.yaw, t.yaw) * r,
220
+ turretYaw: e.turretYaw + v(e.turretYaw, t.turretYaw) * r
221
221
  };
222
222
  }
223
223
  // src/games/tanks-live/logic/maps.js
224
- var ue = Object.freeze([
224
+ var fe = Object.freeze([
225
225
  "meadow",
226
226
  "forest",
227
227
  "desert",
228
228
  "ruins",
229
229
  "arctic",
230
230
  "random"
231
- ]), de = [
231
+ ]), pe = [
232
232
  "forest",
233
233
  "desert",
234
234
  "ruins",
235
235
  "arctic"
236
- ], C = 120, fe = C / 2, pe = 4, me = 12, he = 1.5, ge = 2, _e = () => [{
236
+ ], C = 120, me = C / 2, he = 4, ge = 12, _e = 1.5, ve = 2, ye = () => [{
237
237
  x: 18,
238
238
  z: 60,
239
239
  yaw: 0
@@ -241,7 +241,7 @@ var ue = Object.freeze([
241
241
  x: 102,
242
242
  z: 60,
243
243
  yaw: Math.PI
244
- }], ve = {
244
+ }], be = {
245
245
  crate: {
246
246
  r: 1.2,
247
247
  hp: 2
@@ -251,7 +251,7 @@ var ue = Object.freeze([
251
251
  hp: 1
252
252
  }
253
253
  };
254
- function ye(e) {
254
+ function xe(e) {
255
255
  let t = e >>> 0;
256
256
  return () => {
257
257
  t = t + 1831565813 >>> 0;
@@ -259,8 +259,8 @@ function ye(e) {
259
259
  return e = Math.imul(e ^ e >>> 15, e | 1), e ^= e + Math.imul(e ^ e >>> 7, e | 61), ((e ^ e >>> 14) >>> 0) / 4294967296;
260
260
  };
261
261
  }
262
- var w = (e) => Math.round(e * 10) / 10, T = (e, t, n) => t + e() * (n - t), be = (e, t) => t[Math.floor(e() * t.length) % t.length];
263
- function xe(e, t) {
262
+ var w = (e) => Math.round(e * 10) / 10, T = (e, t, n) => t + e() * (n - t), Se = (e, t) => t[Math.floor(e() * t.length) % t.length];
263
+ function Ce(e, t) {
264
264
  let n = e() * t.reduce((e, t) => e + t.w, 0);
265
265
  for (let e of t) if (n -= e.w, n < 0) return e;
266
266
  return t[t.length - 1];
@@ -279,9 +279,9 @@ var E = (e, t, n) => ({
279
279
  kind: e,
280
280
  w: w(T(i, ...t)),
281
281
  d: w(T(i, ...n)),
282
- rot: r ? be(i, r) : w(T(i, 0, Math.PI))
282
+ rot: r ? Se(i, r) : w(T(i, 0, Math.PI))
283
283
  })
284
- }), Se = [0, Math.PI / 2], Ce = {
284
+ }), we = [0, Math.PI / 2], Te = {
285
285
  forest: {
286
286
  count: [18, 25],
287
287
  destructibles: [2, 4],
@@ -334,11 +334,11 @@ var E = (e, t, n) => ({
334
334
  items: [
335
335
  {
336
336
  w: 4,
337
- ...D("wall", [8, 14], [1.1, 1.4], Se)
337
+ ...D("wall", [8, 14], [1.1, 1.4], we)
338
338
  },
339
339
  {
340
340
  w: 2,
341
- ...D("house", [7, 9], [6, 8], Se)
341
+ ...D("house", [7, 9], [6, 8], we)
342
342
  },
343
343
  {
344
344
  w: 2,
@@ -373,26 +373,26 @@ var E = (e, t, n) => ({
373
373
  }
374
374
  ]
375
375
  }
376
- }, we = (e) => e.shape === "rect" ? Math.hypot(e.w, e.d) / 2 : e.r, Te = (e) => ({
376
+ }, Ee = (e) => e.shape === "rect" ? Math.hypot(e.w, e.d) / 2 : e.r, De = (e) => ({
377
377
  ...e,
378
378
  x: w(C - e.x),
379
379
  z: w(C - e.z)
380
- }), Ee = (e) => e.shape !== "rect" || e.kind !== "low";
381
- function De(e) {
382
- let t = we(e);
383
- return e.x - t >= pe && e.x + t <= 116 && e.z - t >= pe && e.z + t <= 116;
380
+ }), Oe = (e) => e.shape !== "rect" || e.kind !== "low";
381
+ function ke(e) {
382
+ let t = Ee(e);
383
+ return e.x - t >= he && e.x + t <= 116 && e.z - t >= he && e.z + t <= 116;
384
384
  }
385
- function Oe(e, t, n) {
386
- let r = we(e);
387
- return !De(e) || n.some((t) => Math.hypot(e.x - t.x, e.z - t.z) - r < me) ? !1 : t.every((t) => Math.hypot(e.x - t.x, e.z - t.z) >= r + we(t) + he);
385
+ function Ae(e, t, n) {
386
+ let r = Ee(e);
387
+ return !ke(e) || n.some((t) => Math.hypot(e.x - t.x, e.z - t.z) - r < ge) ? !1 : t.every((t) => Math.hypot(e.x - t.x, e.z - t.z) >= r + Ee(t) + _e);
388
388
  }
389
- function ke(e, t, n) {
389
+ function je(e, t, n) {
390
390
  if (n.shape !== "rect") return Math.hypot(e - n.x, t - n.z) - n.r;
391
391
  let r = Math.cos(-n.rot), i = Math.sin(-n.rot), a = e - n.x, o = t - n.z, s = Math.abs(a * r - o * i) - n.w / 2, c = Math.abs(a * i + o * r) - n.d / 2;
392
392
  return Math.hypot(Math.max(s, 0), Math.max(c, 0)) + Math.min(Math.max(s, c), 0);
393
393
  }
394
- function Ae(e, t, n, r = ge) {
395
- let i = [...e.filter(Ee), ...t], a = (e, t) => e >= r && e <= C - r && t >= r && t <= C - r && i.every((n) => ke(e, t, n) >= r), o = /* @__PURE__ */ new Uint8Array(14641), [s, c] = n.map((e) => [Math.round(e.x), Math.round(e.z)]), l = [s];
394
+ function Me(e, t, n, r = ve) {
395
+ let i = [...e.filter(Oe), ...t], a = (e, t) => e >= r && e <= C - r && t >= r && t <= C - r && i.every((n) => je(e, t, n) >= r), o = /* @__PURE__ */ new Uint8Array(14641), [s, c] = n.map((e) => [Math.round(e.x), Math.round(e.z)]), l = [s];
396
396
  o[s[0] * 121 + s[1]] = 1;
397
397
  for (let e = 0; e < l.length; e++) {
398
398
  let [t, n] = l[e];
@@ -409,34 +409,34 @@ function Ae(e, t, n, r = ge) {
409
409
  }
410
410
  return !1;
411
411
  }
412
- function je(e, t, n, r, i, a = 1500) {
412
+ function Ne(e, t, n, r, i, a = 1500) {
413
413
  let o = [];
414
414
  for (let s = 0; o.length < n && s < a; s++) {
415
- let n = t(), a = we(n);
416
- n.x = w(T(e, pe + a, 116 - a)), n.z = w(T(e, pe + a, 116 - a));
417
- let s = Te(n);
418
- if (Math.hypot(n.x - s.x, n.z - s.z) < 2 * a + he) continue;
415
+ let n = t(), a = Ee(n);
416
+ n.x = w(T(e, he + a, 116 - a)), n.z = w(T(e, he + a, 116 - a));
417
+ let s = De(n);
418
+ if (Math.hypot(n.x - s.x, n.z - s.z) < 2 * a + _e) continue;
419
419
  let c = [...r, ...o];
420
- Oe(n, c, i) && Oe(s, [...c, n], i) && o.push(n, s);
420
+ Ae(n, c, i) && Ae(s, [...c, n], i) && o.push(n, s);
421
421
  }
422
422
  return o;
423
423
  }
424
- function Me(e, t, n) {
424
+ function Pe(e, t, n) {
425
425
  let [r, i] = e.count, a = r + Math.floor(t() * (i - r + 1)), o = [];
426
426
  if (a % 2) {
427
- let r = xe(t, e.items).make(t);
428
- r.x = fe, r.z = fe, Oe(r, [], n) && o.push(r);
427
+ let r = Ce(t, e.items).make(t);
428
+ r.x = me, r.z = me, Ae(r, [], n) && o.push(r);
429
429
  }
430
- o.push(...je(t, () => xe(t, e.items).make(t), a - o.length, o, n));
431
- let [s, c] = e.destructibles, l = je(t, () => {
430
+ o.push(...Ne(t, () => Ce(t, e.items).make(t), a - o.length, o, n));
431
+ let [s, c] = e.destructibles, l = Ne(t, () => {
432
432
  let e = t() < .5 ? "crate" : "barrel";
433
433
  return {
434
434
  shape: "circle",
435
435
  kind: e,
436
- ...ve[e]
436
+ ...be[e]
437
437
  };
438
438
  }, 2 * (s / 2 + Math.floor(t() * ((c - s) / 2 + 1))), o, n);
439
- for (; !Ae(o, l, n);) if (l.length > 2) l.splice(-2);
439
+ for (; !Me(o, l, n);) if (l.length > 2) l.splice(-2);
440
440
  else if (o.length > r) o.splice(-2);
441
441
  else return null;
442
442
  return o.length < r || o.length > 25 || l.length < 2 || l.length > 6 ? null : {
@@ -444,10 +444,10 @@ function Me(e, t, n) {
444
444
  destructibles: l
445
445
  };
446
446
  }
447
- function Ne(e, t, n) {
447
+ function Fe(e, t, n) {
448
448
  return Array.from({ length: n }, (n, r) => ({
449
449
  id: `c${r}`,
450
- kind: be(e, t),
450
+ kind: Se(e, t),
451
451
  x: w(T(e, 2, 118)),
452
452
  z: w(T(e, 2, 118)),
453
453
  s: w(T(e, .5, 1.5)),
@@ -455,7 +455,7 @@ function Ne(e, t, n) {
455
455
  }));
456
456
  }
457
457
  var O = (e) => (Math.round(e * 100) / 100).toFixed(2);
458
- function Pe(e) {
458
+ function Ie(e) {
459
459
  let t = [e.id, e.size];
460
460
  for (let n of [...e.obstacles || [], ...e.destructibles || []]) t.push(n.shape === "rect" ? `${n.id}:R:${n.kind}:${O(n.x)}:${O(n.z)}:${O(n.w)}:${O(n.d)}:${O(n.rot)}` : `${n.id}:C:${n.kind}:${O(n.x)}:${O(n.z)}:${O(n.r)}${n.hp == null ? "" : `:${n.hp}`}`);
461
461
  for (let n of e.spawns || []) t.push(`S:${O(n.x)}:${O(n.z)}:${O(n.yaw)}`);
@@ -463,11 +463,11 @@ function Pe(e) {
463
463
  for (let e = 0; e < n.length; e++) r ^= n.charCodeAt(e), r = Math.imul(r, 16777619) >>> 0;
464
464
  return r.toString(16).padStart(8, "0");
465
465
  }
466
- function Fe(e = "meadow", t = 0) {
466
+ function Le(e = "meadow", t = 0) {
467
467
  t = Number(t) >>> 0;
468
- let n = ue.includes(e) ? e : "meadow";
469
- n === "random" && (n = de[Math.floor(ye(t ^ 2654435769)() * de.length)]);
470
- let r = _e(), i = {
468
+ let n = fe.includes(e) ? e : "meadow";
469
+ n === "random" && (n = pe[Math.floor(xe(t ^ 2654435769)() * pe.length)]);
470
+ let r = ye(), i = {
471
471
  id: n,
472
472
  seed: t,
473
473
  size: C,
@@ -480,7 +480,7 @@ function Fe(e = "meadow", t = 0) {
480
480
  spawns: r
481
481
  }, a;
482
482
  if (n === "meadow") {
483
- let e = _();
483
+ let e = y();
484
484
  a = {
485
485
  ...i,
486
486
  obstacles: e.obstacles.map((e, t) => ({
@@ -489,15 +489,15 @@ function Fe(e = "meadow", t = 0) {
489
489
  ...e
490
490
  })),
491
491
  destructibles: [],
492
- decor: Ne(ye(t ^ 57024), [
492
+ decor: Fe(xe(t ^ 57024), [
493
493
  "grass",
494
494
  "flower",
495
495
  "pebble"
496
496
  ], 40)
497
497
  };
498
498
  } else {
499
- let e = Ce[n], o = ye(t), s = null;
500
- for (let t = 0; !s && t < 20; t++) s = Me(e, o, r);
499
+ let e = Te[n], o = xe(t), s = null;
500
+ for (let t = 0; !s && t < 20; t++) s = Pe(e, o, r);
501
501
  s || (s = {
502
502
  obstacles: [],
503
503
  destructibles: []
@@ -511,54 +511,54 @@ function Fe(e = "meadow", t = 0) {
511
511
  id: `d${t}`,
512
512
  ...e
513
513
  })),
514
- decor: Ne(ye(t ^ 57024), e.decor, 50)
514
+ decor: Fe(xe(t ^ 57024), e.decor, 50)
515
515
  };
516
516
  }
517
- return a.hash = Pe(a), a;
517
+ return a.hash = Ie(a), a;
518
518
  }
519
519
  // src/games/tanks-live/session.js
520
- var Ie = (e) => typeof e == "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e), Le = (e) => typeof e == "string" && e.length > 0 && e.length <= 256 && e.trim() === e, Re = (e) => typeof e == "object" && !!e && !Array.isArray(e), ze = (e, t) => Object.keys(e).every((e) => t.includes(e)), Be = (e) => Number.isInteger(e) && e >= 0 && e <= 4294967295, Ve = (e) => typeof e == "string" && /^[0-9a-f]{8}$/.test(e), He = Object.freeze([
520
+ var Re = (e) => typeof e == "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e), ze = (e) => typeof e == "string" && e.length > 0 && e.length <= 256 && e.trim() === e, Be = (e) => typeof e == "object" && !!e && !Array.isArray(e), Ve = (e, t) => Object.keys(e).every((e) => t.includes(e)), He = (e) => Number.isInteger(e) && e >= 0 && e <= 4294967295, Ue = (e) => typeof e == "string" && /^[0-9a-f]{8}$/.test(e), We = Object.freeze([
521
521
  1,
522
522
  3,
523
523
  5
524
- ]), Ue = Object.freeze(ue.filter((e) => e !== "random")), k = /* @__PURE__ */ new Map();
525
- function We(e, t) {
524
+ ]), Ge = Object.freeze(fe.filter((e) => e !== "random")), k = /* @__PURE__ */ new Map();
525
+ function Ke(e, t) {
526
526
  let n = `${e}:${t}`;
527
- return k.has(n) || (k.set(n, Fe(e, t).hash), k.size > 32 && k.delete(k.keys().next().value)), k.get(n);
527
+ return k.has(n) || (k.set(n, Le(e, t).hash), k.size > 32 && k.delete(k.keys().next().value)), k.get(n);
528
528
  }
529
- var Ge = [
529
+ var qe = [
530
530
  "map_id",
531
531
  "seed",
532
532
  "map_hash",
533
533
  "lives"
534
534
  ];
535
- function Ke(e) {
535
+ function Je(e) {
536
536
  let t = e?.data;
537
- if (!Re(t)) return !1;
537
+ if (!Be(t)) return !1;
538
538
  switch (e.type) {
539
- case "game_invite": return !ze(t, [
539
+ case "game_invite": return !Ve(t, [
540
540
  "opponent_id",
541
541
  "rules_version",
542
542
  "rematch_of",
543
- ...Ge
544
- ]) || !Le(t.opponent_id) || t.rematch_of !== void 0 && !Ie(t.rematch_of) ? !1 : t.rules_version === 1 ? Ge.every((e) => t[e] === void 0) : t.rules_version === 2 && Ue.includes(t.map_id) && Be(t.seed) && He.includes(t.lives) && Ve(t.map_hash) && t.map_hash === We(t.map_id, t.seed);
545
- case "game_accept": return ze(t, ["invite_event_id", "map_hash"]) && Ie(t.invite_event_id) && (t.map_hash === void 0 || Ve(t.map_hash));
546
- case "game_decline": return ze(t, ["invite_event_id"]) && Ie(t.invite_event_id);
547
- case "game_end": return ze(t, ["reason"]) && t.reason === "closed";
543
+ ...qe
544
+ ]) || !ze(t.opponent_id) || t.rematch_of !== void 0 && !Re(t.rematch_of) ? !1 : t.rules_version === 1 ? qe.every((e) => t[e] === void 0) : t.rules_version === 2 && Ge.includes(t.map_id) && He(t.seed) && We.includes(t.lives) && Ue(t.map_hash) && t.map_hash === Ke(t.map_id, t.seed);
545
+ case "game_accept": return Ve(t, ["invite_event_id", "map_hash"]) && Re(t.invite_event_id) && (t.map_hash === void 0 || Ue(t.map_hash));
546
+ case "game_decline": return Ve(t, ["invite_event_id"]) && Re(t.invite_event_id);
547
+ case "game_end": return Ve(t, ["reason"]) && t.reason === "closed";
548
548
  default: return !1;
549
549
  }
550
550
  }
551
- var qe = () => globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint32Array(1))[0];
552
- function Je({ opponentId: e, mapId: t = "random", lives: n = 3, seed: r = qe(), rematchOf: i } = {}) {
551
+ var Ye = () => globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint32Array(1))[0];
552
+ function Xe({ opponentId: e, mapId: t = "random", lives: n = 3, seed: r = Ye(), rematchOf: i } = {}) {
553
553
  let a = t === null;
554
- if (!Le(e) || i !== void 0 && !Ie(i) || !a && (!ue.includes(t) || !Be(r) || !He.includes(n))) throw TypeError("Configuración de invitación de Tanques LIVE inválida");
554
+ if (!ze(e) || i !== void 0 && !Re(i) || !a && (!fe.includes(t) || !He(r) || !We.includes(n))) throw TypeError("Configuración de invitación de Tanques LIVE inválida");
555
555
  let o = i === void 0 ? {} : { rematch_of: i };
556
556
  if (a) return {
557
557
  opponent_id: e,
558
558
  rules_version: 1,
559
559
  ...o
560
560
  };
561
- let s = Fe(t, r);
561
+ let s = Le(t, r);
562
562
  return {
563
563
  opponent_id: e,
564
564
  rules_version: 2,
@@ -569,7 +569,7 @@ function Je({ opponentId: e, mapId: t = "random", lives: n = 3, seed: r = qe(),
569
569
  ...o
570
570
  };
571
571
  }
572
- function Ye(e, t) {
572
+ function Ze(e, t) {
573
573
  let n = t.rules_version === 2 ? {
574
574
  mapId: t.map_id,
575
575
  seed: t.seed,
@@ -590,7 +590,7 @@ function Ye(e, t) {
590
590
  acceptEventId: null
591
591
  };
592
592
  }
593
- function Xe(e, t, n) {
593
+ function Qe(e, t, n) {
594
594
  return [e.hostId, e.guestId].includes(n) ? t.type === "game_end" ? ["closed", "declined"].includes(e.status) ? e : {
595
595
  ...e,
596
596
  status: "closed",
@@ -608,45 +608,54 @@ function Xe(e, t, n) {
608
608
  } : e : e;
609
609
  }
610
610
  // src/games/racing-live/session.js
611
- var Ze = (e) => typeof e == "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e), Qe = (e) => typeof e == "string" && e.length > 0 && e.length <= 256 && e.trim() === e, $e = (e) => typeof e == "object" && !!e && !Array.isArray(e), et = (e, t) => Object.keys(e).every((e) => t.includes(e)), tt = (e) => typeof e == "string" && /^racing-v1-[0-9a-f]{8}$/.test(e), nt = (e) => Number.isInteger(e) && e >= 0 && e <= 4294967295;
612
- function rt(n) {
613
- let i = n?.data;
614
- if (!$e(i)) return !1;
615
- switch (n.type) {
616
- case "game_invite": return et(i, [
611
+ var $e = (e) => typeof e == "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e), et = (e) => typeof e == "string" && e.length > 0 && e.length <= 256 && e.trim() === e, tt = (e) => typeof e == "object" && !!e && !Array.isArray(e), nt = (e, t) => Object.keys(e).every((e) => t.includes(e)), rt = (e) => typeof e == "string" && /^racing-v1-[0-9a-f]{8}$/.test(e), it = (e) => Number.isInteger(e) && e >= 0 && e <= 4294967295;
612
+ function at(e) {
613
+ let n = e?.data;
614
+ if (!tt(n)) return !1;
615
+ switch (e.type) {
616
+ case "game_invite": return nt(n, [
617
617
  "opponent_id",
618
618
  "rules_version",
619
619
  "mode",
620
620
  "map_id",
621
621
  "seed",
622
622
  "track_hash",
623
+ "track_id",
623
624
  "laps",
624
625
  "speed_class",
625
626
  "rematch_of"
626
- ]) && Qe(i.opponent_id) && i.rules_version === 1 && i.mode === "classic" && i.map_id === "neon_city" && nt(i.seed) && (i.speed_class === void 0 || t(i.speed_class) !== null) && i.laps === (t(i.speed_class)?.laps ?? e.laps) && tt(i.track_hash) && (i.rematch_of === void 0 || Ze(i.rematch_of)) && i.track_hash === r(i.map_id, i.seed, { speedClass: i.speed_class }).trackHash;
627
- case "game_accept": return et(i, ["invite_event_id", "track_hash"]) && Ze(i.invite_event_id) && tt(i.track_hash);
628
- case "game_decline": return et(i, ["invite_event_id"]) && Ze(i.invite_event_id);
629
- case "game_end": return et(i, ["reason"]) && i.reason === "closed";
627
+ ]) && et(n.opponent_id) && n.rules_version === 1 && n.mode === "classic" && n.map_id === "neon_city" && it(n.seed) && (n.speed_class === void 0 || t(n.speed_class) !== null) && (n.track_id === void 0 || r(n.track_id)) && n.laps === (t(n.speed_class)?.laps ?? a.laps) && rt(n.track_hash) && (n.rematch_of === void 0 || $e(n.rematch_of)) && n.track_hash === i(n.map_id, n.seed, {
628
+ speedClass: n.speed_class,
629
+ trackId: n.track_id
630
+ }).trackHash;
631
+ case "game_accept": return nt(n, ["invite_event_id", "track_hash"]) && $e(n.invite_event_id) && rt(n.track_hash);
632
+ case "game_decline": return nt(n, ["invite_event_id"]) && $e(n.invite_event_id);
633
+ case "game_end": return nt(n, ["reason"]) && n.reason === "closed";
630
634
  default: return !1;
631
635
  }
632
636
  }
633
- function it({ opponentId: i, seed: a = 0, rematchOf: o, speedClass: s = n } = {}) {
634
- let c = t(s);
635
- if (!Qe(i) || !nt(a) || o !== void 0 && !Ze(o) || s !== null && !c) throw TypeError("Configuración de invitación de carrera inválida");
637
+ function ot({ opponentId: r, seed: o = 0, rematchOf: s, speedClass: c = n, trackId: l } = {}) {
638
+ let u = t(c);
639
+ if (!et(r) || !it(o) || s !== void 0 && !$e(s) || c !== null && !u) throw TypeError("Configuración de invitación de carrera inválida");
640
+ let d = e(l, o);
636
641
  return {
637
- opponent_id: i,
642
+ opponent_id: r,
638
643
  rules_version: 1,
639
644
  mode: "classic",
640
645
  map_id: "neon_city",
641
- seed: a,
642
- track_hash: r("neon_city", a, { speedClass: c?.id }).trackHash,
643
- laps: c?.laps ?? e.laps,
644
- ...c ? { speed_class: c.id } : {},
645
- ...o === void 0 ? {} : { rematch_of: o }
646
+ seed: o,
647
+ track_hash: i("neon_city", o, {
648
+ speedClass: u?.id,
649
+ trackId: d
650
+ }).trackHash,
651
+ laps: u?.laps ?? a.laps,
652
+ ...d === "oval" ? {} : { track_id: d },
653
+ ...u ? { speed_class: u.id } : {},
654
+ ...s === void 0 ? {} : { rematch_of: s }
646
655
  };
647
656
  }
648
- function at(e, t) {
649
- if (!rt({
657
+ function st(e, t) {
658
+ if (!at({
650
659
  type: "game_invite",
651
660
  data: t
652
661
  })) throw TypeError("Configuración de carrera inválida");
@@ -663,7 +672,8 @@ function at(e, t) {
663
672
  trackHash: t.track_hash,
664
673
  laps: t.laps,
665
674
  rulesVersion: t.rules_version,
666
- speedClass: t.speed_class ?? null
675
+ speedClass: t.speed_class ?? null,
676
+ ...t.track_id === void 0 ? {} : { trackId: t.track_id }
667
677
  },
668
678
  rematchOf: t.rematch_of ?? null,
669
679
  pending: !1,
@@ -672,8 +682,8 @@ function at(e, t) {
672
682
  acceptEventId: null
673
683
  };
674
684
  }
675
- function ot(e, t, n) {
676
- return !e || t?.game !== "racing_live" || t.game_id !== e.gameId || ![e.hostId, e.guestId].includes(n) || !rt(t) ? e : t.type === "game_end" ? ["closed", "declined"].includes(e.status) ? e : {
685
+ function ct(e, t, n) {
686
+ return !e || t?.game !== "racing_live" || t.game_id !== e.gameId || ![e.hostId, e.guestId].includes(n) || !at(t) ? e : t.type === "game_end" ? ["closed", "declined"].includes(e.status) ? e : {
677
687
  ...e,
678
688
  status: "closed",
679
689
  closedBy: n,
@@ -691,29 +701,29 @@ function ot(e, t, n) {
691
701
  } : e;
692
702
  }
693
703
  // src/net/webrtc/rtcSignals.js
694
- var st = /* @__PURE__ */ new Set(), ct = {
704
+ var lt = /* @__PURE__ */ new Set(), ut = {
695
705
  emit(e) {
696
- st.forEach((t) => {
706
+ lt.forEach((t) => {
697
707
  try {
698
708
  t(e);
699
709
  } catch {}
700
710
  });
701
711
  },
702
712
  subscribe(e) {
703
- return st.add(e), () => st.delete(e);
713
+ return lt.add(e), () => lt.delete(e);
704
714
  }
705
- }, lt = ({ send: e, roomId: t }) => ({
715
+ }, dt = ({ send: e, roomId: t }) => ({
706
716
  send: (n) => e(t, n),
707
- subscribe: (e) => ct.subscribe((n) => {
717
+ subscribe: (e) => ut.subscribe((n) => {
708
718
  String(n.roomId) === String(t) && e(n);
709
719
  })
710
- }), ut = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i, dt = /^[0-9a-f]{16}$/, ft = /^[0-9a-f]{32}$/, pt = /^[0-9a-f]{64}$/, mt = (e) => typeof e == "object" && !!e && !Array.isArray(e), ht = (e) => typeof e == "string" && e.length > 0 && e.length <= 256 && e.trim() === e, A = (e) => typeof e == "string" && ut.test(e), j = (e, t, n) => Number.isInteger(e) && e >= t && e <= n, gt = Object.freeze([
720
+ }), ft = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i, pt = /^[0-9a-f]{16}$/, mt = /^[0-9a-f]{32}$/, ht = /^[0-9a-f]{64}$/, gt = (e) => typeof e == "object" && !!e && !Array.isArray(e), _t = (e) => typeof e == "string" && e.length > 0 && e.length <= 256 && e.trim() === e, A = (e) => typeof e == "string" && ft.test(e), j = (e, t, n) => Number.isInteger(e) && e >= t && e <= n, vt = Object.freeze([
711
721
  "standard",
712
722
  "heavy",
713
723
  "cluster"
714
- ]), _t = (e) => j(e, 1, 120), vt = (e) => j(e.move, -16, 16) && j(e.yaw, 0, 359) && j(e.pitch, 5, 80) && j(e.power, 0, 100) && j(e.ammo, 0, gt.length - 1);
715
- function yt(e) {
716
- return Array.isArray(e) ? e[0] === 1 ? e.length === 6 && vt({
724
+ ]), yt = (e) => j(e, 1, 120), bt = (e) => j(e.move, -16, 16) && j(e.yaw, 0, 359) && j(e.pitch, 5, 80) && j(e.power, 0, 100) && j(e.ammo, 0, vt.length - 1);
725
+ function xt(e) {
726
+ return Array.isArray(e) ? e[0] === 1 ? e.length === 6 && bt({
717
727
  move: e[1],
718
728
  yaw: e[2],
719
729
  pitch: e[3],
@@ -721,51 +731,51 @@ function yt(e) {
721
731
  ammo: e[5]
722
732
  }) : e[0] === 2 ? e.length === 1 : e[0] === 3 && e.length === 2 && (e[1] === 0 || e[1] === 1) : !1;
723
733
  }
724
- var bt = (e) => Array.isArray(e.log) && e.log.length <= 120 && e.log.every(yt) && A(e.head) && (e.accept_event_id === void 0 ? e.log.length === 0 && e.seed_b === void 0 && e.seed_a === void 0 : A(e.accept_event_id) && typeof e.seed_b == "string" && ft.test(e.seed_b)) && (e.seed_a === void 0 ? e.log.length === 0 : ft.test(e.seed_a) && A(e.seed_event_id));
725
- function xt(e) {
734
+ var St = (e) => Array.isArray(e.log) && e.log.length <= 120 && e.log.every(xt) && A(e.head) && (e.accept_event_id === void 0 ? e.log.length === 0 && e.seed_b === void 0 && e.seed_a === void 0 : A(e.accept_event_id) && typeof e.seed_b == "string" && mt.test(e.seed_b)) && (e.seed_a === void 0 ? e.log.length === 0 : mt.test(e.seed_a) && A(e.seed_event_id));
735
+ function Ct(e) {
726
736
  let t = e.data;
727
737
  switch (e.type) {
728
- case "game_invite": return ht(t.opponent_id) && t.rules_version === 1 && typeof t.seed_commit == "string" && pt.test(t.seed_commit) && (t.first_player_id === void 0 || ht(t.first_player_id)) && (t.rematch_of === void 0 || A(t.rematch_of));
729
- case "game_accept": return A(t.invite_event_id) && typeof t.seed_b == "string" && ft.test(t.seed_b);
738
+ case "game_invite": return _t(t.opponent_id) && t.rules_version === 1 && typeof t.seed_commit == "string" && ht.test(t.seed_commit) && (t.first_player_id === void 0 || _t(t.first_player_id)) && (t.rematch_of === void 0 || A(t.rematch_of));
739
+ case "game_accept": return A(t.invite_event_id) && typeof t.seed_b == "string" && mt.test(t.seed_b);
730
740
  case "game_decline": return A(t.invite_event_id);
731
741
  case "game_end": return t.reason === "closed";
732
- case "tk_seed": return typeof t.seed_a == "string" && ft.test(t.seed_a);
733
- case "tk_turn": return _t(t.ply) && A(t.prev_event_id) && vt(t) && typeof t.hash == "string" && dt.test(t.hash);
742
+ case "tk_seed": return typeof t.seed_a == "string" && mt.test(t.seed_a);
743
+ case "tk_turn": return yt(t.ply) && A(t.prev_event_id) && bt(t) && typeof t.hash == "string" && pt.test(t.hash);
734
744
  case "tk_skip":
735
- case "tk_resign": return _t(t.ply) && A(t.prev_event_id);
736
- case "tk_sync_request": return mt(t) && bt(t);
737
- case "tk_sync_state": return mt(t) && bt(t) && A(t.request_event_id);
745
+ case "tk_resign": return yt(t.ply) && A(t.prev_event_id);
746
+ case "tk_sync_request": return gt(t) && St(t);
747
+ case "tk_sync_state": return gt(t) && St(t) && A(t.request_event_id);
738
748
  default: return !1;
739
749
  }
740
750
  }
741
751
  // src/games/shared/protocol.js
742
- var St = "LIRA_GAME_V1:", Ct = 4096, wt = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i, Tt = (e) => typeof e == "object" && !!e && !Array.isArray(e), M = (e) => typeof e == "string" && e.length > 0 && e.length <= 256 && e.trim() === e, N = (e) => typeof e == "string" && wt.test(e), Et = (e) => Array.isArray(e) && e.length <= 42 && e.every((e) => Array.isArray(e) && e.length === 2 && Number.isInteger(e[0]) && e[0] >= 0 && e[0] < 7 && N(e[1])) && new Set(e.map((e) => e[1])).size === e.length, Dt = (e) => Et(e.moves) && e.rev === e.moves.length && (e.accept_event_id === void 0 ? e.moves.length === 0 : N(e.accept_event_id)), Ot = [
752
+ var wt = "LIRA_GAME_V1:", Tt = 4096, Et = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i, Dt = (e) => typeof e == "object" && !!e && !Array.isArray(e), M = (e) => typeof e == "string" && e.length > 0 && e.length <= 256 && e.trim() === e, N = (e) => typeof e == "string" && Et.test(e), Ot = (e) => Array.isArray(e) && e.length <= 42 && e.every((e) => Array.isArray(e) && e.length === 2 && Number.isInteger(e[0]) && e[0] >= 0 && e[0] < 7 && N(e[1])) && new Set(e.map((e) => e[1])).size === e.length, kt = (e) => Ot(e.moves) && e.rev === e.moves.length && (e.accept_event_id === void 0 ? e.moves.length === 0 : N(e.accept_event_id)), At = [
743
753
  "carrier",
744
754
  "battleship",
745
755
  "cruiser",
746
756
  "submarine",
747
757
  "destroyer"
748
- ], P = (e) => Number.isInteger(e) && e >= 0 && e < 10, kt = (e) => typeof e == "string" && /^[0-9a-f]{64}$/.test(e), At = (e) => Number.isInteger(e) && e >= 1 && e <= 200, jt = (e) => e === null || Tt(e) && Ot.includes(e.ship_id) && Array.isArray(e.cells) && e.cells.length >= 2 && e.cells.length <= 5 && e.cells.every((e) => Array.isArray(e) && e.length === 2 && P(e[0]) && P(e[1])), Mt = (e) => Array.isArray(e) && e.length === Ot.length && e.every((e) => Tt(e) && Ot.includes(e.ship_id) && P(e.row) && P(e.col) && (e.orientation === "horizontal" || e.orientation === "vertical")) && new Set(e.map((e) => e.ship_id)).size === e.length, Nt = (e, t) => Array.isArray(e) && P(e[0]) && P(e[1]) && (e.length === 2 && t || e.length === 3 && (e[2] === 0 || e[2] === 1) || e.length === 7 && e[2] === 2 && Number.isInteger(e[3]) && e[3] >= 0 && e[3] < Ot.length && P(e[4]) && P(e[5]) && (e[6] === 0 || e[6] === 1)), Pt = (e) => Array.isArray(e.commits) && e.commits.length === 2 && e.commits.every((e) => e === null || kt(e)) && Array.isArray(e.log) && e.log.length <= 200 && e.log.every((t, n) => Nt(t, n === e.log.length - 1)) && N(e.head) && (e.accept_event_id === void 0 ? e.commits.every((e) => e === null) && e.log.length === 0 : N(e.accept_event_id)) && (e.log.length === 0 || e.commits.every(Boolean));
749
- function Ft(e) {
758
+ ], P = (e) => Number.isInteger(e) && e >= 0 && e < 10, jt = (e) => typeof e == "string" && /^[0-9a-f]{64}$/.test(e), Mt = (e) => Number.isInteger(e) && e >= 1 && e <= 200, Nt = (e) => e === null || Dt(e) && At.includes(e.ship_id) && Array.isArray(e.cells) && e.cells.length >= 2 && e.cells.length <= 5 && e.cells.every((e) => Array.isArray(e) && e.length === 2 && P(e[0]) && P(e[1])), Pt = (e) => Array.isArray(e) && e.length === At.length && e.every((e) => Dt(e) && At.includes(e.ship_id) && P(e.row) && P(e.col) && (e.orientation === "horizontal" || e.orientation === "vertical")) && new Set(e.map((e) => e.ship_id)).size === e.length, Ft = (e, t) => Array.isArray(e) && P(e[0]) && P(e[1]) && (e.length === 2 && t || e.length === 3 && (e[2] === 0 || e[2] === 1) || e.length === 7 && e[2] === 2 && Number.isInteger(e[3]) && e[3] >= 0 && e[3] < At.length && P(e[4]) && P(e[5]) && (e[6] === 0 || e[6] === 1)), It = (e) => Array.isArray(e.commits) && e.commits.length === 2 && e.commits.every((e) => e === null || jt(e)) && Array.isArray(e.log) && e.log.length <= 200 && e.log.every((t, n) => Ft(t, n === e.log.length - 1)) && N(e.head) && (e.accept_event_id === void 0 ? e.commits.every((e) => e === null) && e.log.length === 0 : N(e.accept_event_id)) && (e.log.length === 0 || e.commits.every(Boolean));
759
+ function Lt(e) {
750
760
  let t = e.data;
751
761
  switch (e.type) {
752
762
  case "game_invite": return M(t.opponent_id) && t.rules_version === 1;
753
763
  case "game_accept":
754
764
  case "game_decline": return N(t.invite_event_id);
755
765
  case "game_end": return ["closed", "win"].includes(t.reason) && (t.winner_id === void 0 || M(t.winner_id));
756
- case "bs_commit": return kt(t.commitment);
757
- case "bs_fire": return At(t.ply) && P(t.row) && P(t.col) && N(t.prev_event_id);
758
- case "bs_result": return At(t.ply) && P(t.row) && P(t.col) && ["hit", "miss"].includes(t.result) && jt(t.sunk) && typeof t.defeated == "boolean" && (t.result === "hit" || t.sunk === null && !t.defeated);
759
- case "bs_reveal": return Mt(t.fleet) && typeof t.salt == "string" && /^[0-9a-f]{32}$/.test(t.salt);
760
- case "bs_sync_request": return Pt(t);
761
- case "bs_sync_state": return Pt(t) && N(t.request_event_id);
766
+ case "bs_commit": return jt(t.commitment);
767
+ case "bs_fire": return Mt(t.ply) && P(t.row) && P(t.col) && N(t.prev_event_id);
768
+ case "bs_result": return Mt(t.ply) && P(t.row) && P(t.col) && ["hit", "miss"].includes(t.result) && Nt(t.sunk) && typeof t.defeated == "boolean" && (t.result === "hit" || t.sunk === null && !t.defeated);
769
+ case "bs_reveal": return Pt(t.fleet) && typeof t.salt == "string" && /^[0-9a-f]{32}$/.test(t.salt);
770
+ case "bs_sync_request": return It(t);
771
+ case "bs_sync_state": return It(t) && N(t.request_event_id);
762
772
  default: return !1;
763
773
  }
764
774
  }
765
- function It(e) {
775
+ function Rt(e) {
766
776
  return typeof e == "string" && e.startsWith("LIRA_GAME_V1:");
767
777
  }
768
- function Lt(e) {
778
+ function zt(e) {
769
779
  let t = e.data;
770
780
  switch (e.type) {
771
781
  case "game_invite": return M(t.opponent_id) && t.rules_version === 1;
@@ -777,37 +787,37 @@ function Lt(e) {
777
787
  "win",
778
788
  "draw"
779
789
  ].includes(t.reason) && (t.winner_id === void 0 || M(t.winner_id)) && (t.final_move_event_id === void 0 || N(t.final_move_event_id)) && (t.reason !== "win" || M(t.winner_id) && N(t.final_move_event_id)) && (t.reason !== "draw" || N(t.final_move_event_id));
780
- case "game_resync_request": return Dt(t);
781
- case "game_resync_state": return Dt(t) && N(t.request_event_id);
790
+ case "game_resync_request": return kt(t);
791
+ case "game_resync_state": return kt(t) && N(t.request_event_id);
782
792
  default: return !1;
783
793
  }
784
794
  }
785
- var Rt = {
786
- connect4: Lt,
787
- battleship: Ft,
788
- tanks: xt,
789
- tanks_live: Ke,
790
- racing_live: rt
791
- }, zt = Object.freeze(Object.keys(Rt));
792
- function Bt(e) {
793
- return !Tt(e) || e.version !== 1 || !Object.hasOwn(Rt, e.game) || !N(e.game_id) || !N(e.event_id) || !Tt(e.data) ? !1 : Rt[e.game](e);
794
- }
795
- function Vt(e) {
796
- if (!It(e) || e.length > Ct) return null;
795
+ var Bt = {
796
+ connect4: zt,
797
+ battleship: Lt,
798
+ tanks: Ct,
799
+ tanks_live: Je,
800
+ racing_live: at
801
+ }, Vt = Object.freeze(Object.keys(Bt));
802
+ function Ht(e) {
803
+ return !Dt(e) || e.version !== 1 || !Object.hasOwn(Bt, e.game) || !N(e.game_id) || !N(e.event_id) || !Dt(e.data) ? !1 : Bt[e.game](e);
804
+ }
805
+ function Ut(e) {
806
+ if (!Rt(e) || e.length > Tt) return null;
797
807
  try {
798
808
  let t = JSON.parse(e.slice(13));
799
- return Bt(t) ? t : null;
809
+ return Ht(t) ? t : null;
800
810
  } catch {
801
811
  return null;
802
812
  }
803
813
  }
804
- function Ht(e) {
805
- if (!Bt(e)) throw Error("Evento de juego inválido");
806
- let t = St + JSON.stringify(e);
807
- if (t.length > Ct) throw Error("Evento de juego demasiado grande");
814
+ function Wt(e) {
815
+ if (!Ht(e)) throw Error("Evento de juego inválido");
816
+ let t = wt + JSON.stringify(e);
817
+ if (t.length > Tt) throw Error("Evento de juego demasiado grande");
808
818
  return t;
809
819
  }
810
- function F(e, { game_id: t, data: n, event_id: r = p(), game: i = "connect4" }) {
820
+ function F(e, { game_id: t, data: n, event_id: r = h(), game: i = "connect4" }) {
811
821
  let a = {
812
822
  version: 1,
813
823
  game: i,
@@ -816,22 +826,22 @@ function F(e, { game_id: t, data: n, event_id: r = p(), game: i = "connect4" })
816
826
  type: e,
817
827
  data: n
818
828
  };
819
- if (!Bt(a)) throw Error("Evento de juego inválido");
829
+ if (!Ht(a)) throw Error("Evento de juego inválido");
820
830
  return a;
821
831
  }
822
- function Ut() {
832
+ function Gt() {
823
833
  return Array.from({ length: 6 }, () => Array(7).fill(null));
824
834
  }
825
- var Wt = [
835
+ var Kt = [
826
836
  [0, 1],
827
837
  [1, 0],
828
838
  [1, 1],
829
839
  [1, -1]
830
840
  ];
831
- function Gt(e) {
841
+ function qt(e) {
832
842
  for (let t = 0; t < 6; t += 1) for (let n = 0; n < 7; n += 1) {
833
843
  let r = e[t][n];
834
- if (r != null) for (let [i, a] of Wt) {
844
+ if (r != null) for (let [i, a] of Kt) {
835
845
  let o = [];
836
846
  for (let s = 0; s < 4; s += 1) {
837
847
  let c = t + i * s, l = n + a * s;
@@ -843,40 +853,40 @@ function Gt(e) {
843
853
  }
844
854
  return [];
845
855
  }
846
- function Kt(e) {
847
- let t = Gt(e);
856
+ function Jt(e) {
857
+ let t = qt(e);
848
858
  return t.length ? e[t[0][0]][t[0][1]] : null;
849
859
  }
850
- function qt(e) {
860
+ function Yt(e) {
851
861
  return e[0].every((e) => e !== null);
852
862
  }
853
- function Jt(e, t, n) {
854
- if (!Number.isInteger(t) || t < 0 || t >= 7 || n == null || Kt(e) !== null) return null;
863
+ function Xt(e, t, n) {
864
+ if (!Number.isInteger(t) || t < 0 || t >= 7 || n == null || Jt(e) !== null) return null;
855
865
  let r = 5;
856
866
  for (; r >= 0 && e[r][t] !== null;) --r;
857
867
  if (r < 0) return null;
858
868
  let i = e.map((e) => e.slice());
859
869
  i[r][t] = n;
860
- let a = Gt(i), o = a.length ? i[a[0][0]][a[0][1]] : null;
870
+ let a = qt(i), o = a.length ? i[a[0][0]][a[0][1]] : null;
861
871
  return {
862
872
  board: i,
863
873
  row: r,
864
874
  column: t,
865
875
  winner: o,
866
- draw: o === null && qt(i),
876
+ draw: o === null && Yt(i),
867
877
  winningCells: a
868
878
  };
869
879
  }
870
880
  // src/games/battleship/logic/game.js
871
- var Yt = (e) => typeof e == "string" && e.length > 0 && e.length <= 256 && e.trim() === e;
872
- function Xt({ gameId: e, players: t, firstPlayerId: n = t?.[0] } = {}) {
873
- if (!Yt(e) || !Array.isArray(t) || t.length !== 2 || !t.every(Yt) || t[0] === t[1] || !t.includes(n)) throw TypeError("Supply a gameId, two distinct player IDs and a valid firstPlayerId.");
881
+ var Zt = (e) => typeof e == "string" && e.length > 0 && e.length <= 256 && e.trim() === e;
882
+ function Qt({ gameId: e, players: t, firstPlayerId: n = t?.[0] } = {}) {
883
+ if (!Zt(e) || !Array.isArray(t) || t.length !== 2 || !t.every(Zt) || t[0] === t[1] || !t.includes(n)) throw TypeError("Supply a gameId, two distinct player IDs and a valid firstPlayerId.");
874
884
  return {
875
885
  game: "battleship",
876
886
  rulesVersion: 1,
877
887
  gameId: e,
878
888
  players: t.slice(),
879
- boards: [s(), s()],
889
+ boards: [l(), l()],
880
890
  ready: [!1, !1],
881
891
  phase: "placement",
882
892
  turnId: null,
@@ -887,7 +897,7 @@ function Xt({ gameId: e, players: t, firstPlayerId: n = t?.[0] } = {}) {
887
897
  revision: 0
888
898
  };
889
899
  }
890
- function Zt(e, t) {
900
+ function $t(e, t) {
891
901
  if (!e || !t || typeof t != "object" || e.phase === "finished" || t.gameId !== void 0 && t.gameId !== e.gameId || t.expectedRevision !== void 0 && t.expectedRevision !== e.revision) return e;
892
902
  let n = e.players.indexOf(t.playerId);
893
903
  if (n < 0) return e;
@@ -895,16 +905,16 @@ function Zt(e, t) {
895
905
  if (e.phase === "placement") {
896
906
  if (e.ready[n]) return e;
897
907
  if (t.type === "place_ship" || t.type === "remove_ship") {
898
- let i = t.type === "place_ship" ? l(r, t) : a(r, t.shipId);
908
+ let i = t.type === "place_ship" ? d(r, t) : s(r, t.shipId);
899
909
  if (!i.ok) return e;
900
- let o = e.boards.slice();
901
- return o[n] = i.board, {
910
+ let a = e.boards.slice();
911
+ return a[n] = i.board, {
902
912
  ...e,
903
- boards: o,
913
+ boards: a,
904
914
  revision: e.revision + 1
905
915
  };
906
916
  }
907
- if (t.type === "ready" && i(r)) {
917
+ if (t.type === "ready" && o(r)) {
908
918
  let t = e.ready.slice();
909
919
  t[n] = !0;
910
920
  let r = t.every(Boolean);
@@ -919,40 +929,40 @@ function Zt(e, t) {
919
929
  return e;
920
930
  }
921
931
  if (e.phase !== "playing" || t.type !== "fire" || t.playerId !== e.turnId) return e;
922
- let o = 1 - n, s = c(e.boards[o], t);
923
- if (!s.ok) return e;
924
- let u = e.boards.slice();
925
- return u[o] = s.board, {
932
+ let i = 1 - n, a = u(e.boards[i], t);
933
+ if (!a.ok) return e;
934
+ let c = e.boards.slice();
935
+ return c[i] = a.board, {
926
936
  ...e,
927
- boards: u,
937
+ boards: c,
928
938
  revision: e.revision + 1,
929
939
  shotCount: e.shotCount + 1,
930
- phase: s.defeated ? "finished" : "playing",
931
- turnId: s.defeated ? null : e.players[o],
932
- winnerId: s.defeated ? t.playerId : null,
940
+ phase: a.defeated ? "finished" : "playing",
941
+ turnId: a.defeated ? null : e.players[i],
942
+ winnerId: a.defeated ? t.playerId : null,
933
943
  lastShot: {
934
944
  playerId: t.playerId,
935
- targetId: e.players[o],
945
+ targetId: e.players[i],
936
946
  row: t.row,
937
947
  col: t.col,
938
- result: s.result,
939
- shipId: s.shipId,
940
- sunk: s.sunk,
941
- defeated: s.defeated
948
+ result: a.result,
949
+ shipId: a.shipId,
950
+ sunk: a.sunk,
951
+ defeated: a.defeated
942
952
  }
943
953
  };
944
954
  }
945
955
  // src/games/battleship/net/session.js
946
- var Qt = u.reduce((e, t) => e + t.size, 0), $t = /^[0-9a-f]{32}$/, en = [
956
+ var en = f.reduce((e, t) => e + t.size, 0), tn = /^[0-9a-f]{32}$/, nn = [
947
957
  "won",
948
958
  "closed",
949
959
  "declined"
950
- ], I = "La partida perdió sincronización. Se intentará resincronizar.", tn = "Falta la aceptación de la partida. Ciérrala y vuelve a invitar.", nn = "El rival envió un resultado imposible para ese disparo.", rn = "Tu flota no está disponible en este dispositivo; no se pueden responder disparos.", an = () => Array.from({ length: 10 }, () => Array(10).fill(null)), on = (e, t, n, r) => e.map((e, i) => i === t ? e.map((e, t) => t === n ? r : e) : e), sn = (e) => e.reduce((e, t) => e + t.filter((e) => e === "hit").length, 0), cn = (e) => e.reduce((e, t) => e + t.filter((e) => e !== null).length, 0), ln = (e, t) => t % 2 == 1 ? e.hostId : e.guestId, un = (e, t) => t === e.hostId ? e.guestId : e.hostId, dn = (e, t) => t === e.hostId ? "hostCommitment" : "guestCommitment", L = (e, t) => ({
960
+ ], I = "La partida perdió sincronización. Se intentará resincronizar.", rn = "Falta la aceptación de la partida. Ciérrala y vuelve a invitar.", an = "El rival envió un resultado imposible para ese disparo.", on = "Tu flota no está disponible en este dispositivo; no se pueden responder disparos.", sn = () => Array.from({ length: 10 }, () => Array(10).fill(null)), cn = (e, t, n, r) => e.map((e, i) => i === t ? e.map((e, t) => t === n ? r : e) : e), ln = (e) => e.reduce((e, t) => e + t.filter((e) => e === "hit").length, 0), un = (e) => e.reduce((e, t) => e + t.filter((e) => e !== null).length, 0), dn = (e, t) => t % 2 == 1 ? e.hostId : e.guestId, fn = (e, t) => t === e.hostId ? e.guestId : e.hostId, pn = (e, t) => t === e.hostId ? "hostCommitment" : "guestCommitment", L = (e, t) => ({
951
961
  ...e,
952
962
  status: "conflict",
953
963
  error: t
954
- }), fn = (e) => `${e.row},${e.col}`, pn = (e, t) => e.row - t.row || e.col - t.col, mn = (e, t) => e.length === t.length && e.map(fn).sort().join("|") === t.map(fn).sort().join("|");
955
- function hn(e) {
964
+ }), mn = (e) => `${e.row},${e.col}`, hn = (e, t) => e.row - t.row || e.col - t.col, gn = (e, t) => e.length === t.length && e.map(mn).sort().join("|") === t.map(mn).sort().join("|");
965
+ function _n(e) {
956
966
  return {
957
967
  ...e,
958
968
  game: "battleship",
@@ -961,8 +971,8 @@ function hn(e) {
961
971
  myFleet: [],
962
972
  myReady: !1,
963
973
  opponentReady: !1,
964
- incomingShots: an(),
965
- targetShots: an(),
974
+ incomingShots: sn(),
975
+ targetShots: sn(),
966
976
  sunkEnemyShips: [],
967
977
  pendingShot: null,
968
978
  lastShot: null,
@@ -984,7 +994,7 @@ function hn(e) {
984
994
  sync: e.sync ?? null
985
995
  };
986
996
  }
987
- var gn = (e) => e?.game === "battleship" && ["invited", "placement"].includes(e.status) && !e.myReady, _n = (e) => e?.status === "active" && e.turnId === e.ownId && !e.pendingShot, vn = (e) => ({
997
+ var vn = (e) => e?.game === "battleship" && ["invited", "placement"].includes(e.status) && !e.myReady, yn = (e) => e?.status === "active" && e.turnId === e.ownId && !e.pendingShot, bn = (e) => ({
988
998
  id: e.id,
989
999
  size: e.size,
990
1000
  orientation: e.orientation,
@@ -992,33 +1002,33 @@ var gn = (e) => e?.game === "battleship" && ["invited", "placement"].includes(e.
992
1002
  row: e.row,
993
1003
  col: e.col
994
1004
  }))
995
- }), yn = (e) => ({
1005
+ }), xn = (e) => ({
996
1006
  shipId: e.id,
997
1007
  row: e.cells[0].row,
998
1008
  col: e.cells[0].col,
999
1009
  orientation: e.orientation
1000
1010
  });
1001
- function bn(e) {
1011
+ function Sn(e) {
1002
1012
  return !e || typeof e != "object" ? null : typeof e.ship_id == "string" ? {
1003
1013
  shipId: e.ship_id,
1004
1014
  row: e.row,
1005
1015
  col: e.col,
1006
1016
  orientation: e.orientation
1007
- } : typeof e.id == "string" && Array.isArray(e.cells) && e.cells.length ? yn(e) : null;
1017
+ } : typeof e.id == "string" && Array.isArray(e.cells) && e.cells.length ? xn(e) : null;
1008
1018
  }
1009
- function xn(e) {
1019
+ function Cn(e) {
1010
1020
  if (!Array.isArray(e)) return null;
1011
- let t = s();
1021
+ let t = l();
1012
1022
  for (let n of e) {
1013
- let e = bn(n), r = e && l(t, e);
1023
+ let e = Sn(n), r = e && d(t, e);
1014
1024
  if (!r?.ok) return null;
1015
1025
  t = r.board;
1016
1026
  }
1017
1027
  return t;
1018
1028
  }
1019
- function Sn(e) {
1029
+ function wn(e) {
1020
1030
  if (!Array.isArray(e)) return null;
1021
- let t = e.map(bn);
1031
+ let t = e.map(Sn);
1022
1032
  return t.some((e) => !e) ? null : t.map(({ shipId: e, row: t, col: n, orientation: r }) => ({
1023
1033
  ship_id: e,
1024
1034
  row: t,
@@ -1026,21 +1036,21 @@ function Sn(e) {
1026
1036
  orientation: r
1027
1037
  })).sort((e, t) => e.ship_id < t.ship_id ? -1 : +(e.ship_id > t.ship_id));
1028
1038
  }
1029
- function Cn(e) {
1030
- let t = xn(e);
1031
- return t && i(t) ? t.ships.map(vn) : null;
1032
- }
1033
- var wn = (e) => !!Cn(e);
1034
1039
  function Tn(e) {
1035
- let t = xn(e?.myFleet);
1036
- return t && i(t) ? {
1040
+ let t = Cn(e);
1041
+ return t && o(t) ? t.ships.map(bn) : null;
1042
+ }
1043
+ var En = (e) => !!Tn(e);
1044
+ function Dn(e) {
1045
+ let t = Cn(e?.myFleet);
1046
+ return t && o(t) ? {
1037
1047
  ...t,
1038
1048
  shots: e.incomingShots.map((e) => e.slice())
1039
1049
  } : null;
1040
1050
  }
1041
- function En(e, { shipId: t, row: n, col: r, orientation: i } = {}) {
1042
- if (!gn(e)) return e;
1043
- let a = xn(e.myFleet.filter((e) => e.id !== t)), o = a && l(a, {
1051
+ function On(e, { shipId: t, row: n, col: r, orientation: i } = {}) {
1052
+ if (!vn(e)) return e;
1053
+ let a = Cn(e.myFleet.filter((e) => e.id !== t)), o = a && d(a, {
1044
1054
  shipId: t,
1045
1055
  row: n,
1046
1056
  col: r,
@@ -1048,27 +1058,27 @@ function En(e, { shipId: t, row: n, col: r, orientation: i } = {}) {
1048
1058
  });
1049
1059
  return o?.ok ? {
1050
1060
  ...e,
1051
- myFleet: o.board.ships.map(vn)
1061
+ myFleet: o.board.ships.map(bn)
1052
1062
  } : e;
1053
1063
  }
1054
- function Dn(e, t) {
1055
- return !gn(e) || !e.myFleet.some((e) => e.id === t) ? e : {
1064
+ function kn(e, t) {
1065
+ return !vn(e) || !e.myFleet.some((e) => e.id === t) ? e : {
1056
1066
  ...e,
1057
1067
  myFleet: e.myFleet.filter((e) => e.id !== t)
1058
1068
  };
1059
1069
  }
1060
- function On(e) {
1070
+ function An(e) {
1061
1071
  let t = Math.floor(4294967296 / e) * e, n = /* @__PURE__ */ new Uint32Array(1);
1062
1072
  do
1063
1073
  globalThis.crypto.getRandomValues(n);
1064
1074
  while (n[0] >= t);
1065
1075
  return n[0] % e;
1066
1076
  }
1067
- function kn(e = On) {
1077
+ function jn(e = An) {
1068
1078
  for (let t = 0; t < 50; t += 1) {
1069
- let t = s();
1070
- for (let n of u) for (let r = 0; r < 300; r += 1) {
1071
- let r = l(t, {
1079
+ let t = l();
1080
+ for (let n of f) for (let r = 0; r < 300; r += 1) {
1081
+ let r = d(t, {
1072
1082
  shipId: n.id,
1073
1083
  row: e(10),
1074
1084
  col: e(10),
@@ -1079,33 +1089,33 @@ function kn(e = On) {
1079
1089
  break;
1080
1090
  }
1081
1091
  }
1082
- if (i(t)) return t.ships.map(vn);
1092
+ if (o(t)) return t.ships.map(bn);
1083
1093
  }
1084
1094
  throw Error("No se pudo generar una flota aleatoria.");
1085
1095
  }
1086
- var An = (e, t) => gn(e) ? {
1096
+ var Mn = (e, t) => vn(e) ? {
1087
1097
  ...e,
1088
- myFleet: kn(t)
1089
- } : e, jn = (e) => Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
1090
- function Mn() {
1098
+ myFleet: jn(t)
1099
+ } : e, Nn = (e) => Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
1100
+ function Pn() {
1091
1101
  let e = /* @__PURE__ */ new Uint8Array(16);
1092
- return globalThis.crypto.getRandomValues(e), jn(e);
1102
+ return globalThis.crypto.getRandomValues(e), Nn(e);
1093
1103
  }
1094
- function Nn(e, t) {
1095
- let n = Sn(e);
1104
+ function Fn(e, t) {
1105
+ let n = wn(e);
1096
1106
  if (!n || typeof t != "string") throw TypeError("Flota inválida");
1097
1107
  return JSON.stringify({
1098
1108
  fleet: n,
1099
1109
  salt: t
1100
1110
  });
1101
1111
  }
1102
- async function Pn(e, t) {
1103
- let n = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(Nn(e, t)));
1104
- return jn(new Uint8Array(n));
1112
+ async function In(e, t) {
1113
+ let n = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(Fn(e, t)));
1114
+ return Nn(new Uint8Array(n));
1105
1115
  }
1106
- function Fn(e, t) {
1116
+ function Ln(e, t) {
1107
1117
  if (!e || !t) return null;
1108
- let n = c(e, {
1118
+ let n = u(e, {
1109
1119
  row: t.row,
1110
1120
  col: t.col
1111
1121
  });
@@ -1123,15 +1133,15 @@ function Fn(e, t) {
1123
1133
  defeated: n.defeated
1124
1134
  };
1125
1135
  }
1126
- function In(e) {
1127
- let t = u.find((t) => t.id === e?.ship_id);
1136
+ function Rn(e) {
1137
+ let t = f.find((t) => t.id === e?.ship_id);
1128
1138
  if (!t || !Array.isArray(e.cells) || e.cells.length !== t.size) return null;
1129
1139
  let n = e.cells.map((e) => Array.isArray(e) ? {
1130
1140
  row: e[0],
1131
1141
  col: e[1]
1132
1142
  } : null);
1133
- if (n.some((e) => !o(e))) return null;
1134
- n.sort(pn);
1143
+ if (n.some((e) => !c(e))) return null;
1144
+ n.sort(hn);
1135
1145
  let r = n.every((e, t) => e.row === n[0].row && e.col === n[0].col + t), i = n.every((e, t) => e.col === n[0].col && e.row === n[0].row + t);
1136
1146
  return !r && !i ? null : {
1137
1147
  id: t.id,
@@ -1141,43 +1151,43 @@ function In(e) {
1141
1151
  sunk: !0
1142
1152
  };
1143
1153
  }
1144
- function Ln(e, t) {
1154
+ function zn(e, t) {
1145
1155
  let { row: n, col: r, result: i, sunk: a } = t, o = !!t.defeated;
1146
1156
  if (i !== "hit" && i !== "miss" || e.targetShots[n][r] !== null) return null;
1147
- let s = on(e.targetShots, n, r, i), c = sn(s), l = null;
1157
+ let s = cn(e.targetShots, n, r, i), c = ln(s), l = null;
1148
1158
  if (a) {
1149
- if (l = i === "hit" ? In(a) : null, !l || e.sunkEnemyShips.some((e) => e.id === l.id)) return null;
1150
- let t = new Set(e.sunkEnemyShips.flatMap((e) => e.cells.map(fn)));
1151
- if (!l.cells.some((e) => e.row === n && e.col === r) || l.cells.some((e) => s[e.row][e.col] !== "hit" || t.has(fn(e)))) return null;
1159
+ if (l = i === "hit" ? Rn(a) : null, !l || e.sunkEnemyShips.some((e) => e.id === l.id)) return null;
1160
+ let t = new Set(e.sunkEnemyShips.flatMap((e) => e.cells.map(mn)));
1161
+ if (!l.cells.some((e) => e.row === n && e.col === r) || l.cells.some((e) => s[e.row][e.col] !== "hit" || t.has(mn(e)))) return null;
1152
1162
  }
1153
- let d = e.sunkEnemyShips.length + +!!l;
1154
- return c > Qt || o !== (c === Qt) || o !== (d === u.length) || !o && Qt - c > 100 - cn(s) ? null : {
1163
+ let u = e.sunkEnemyShips.length + +!!l;
1164
+ return c > en || o !== (c === en) || o !== (u === f.length) || !o && en - c > 100 - un(s) ? null : {
1155
1165
  shots: s,
1156
1166
  ship: l
1157
1167
  };
1158
1168
  }
1159
- function Rn(e, t) {
1160
- let n = Fn(Tn(e), t);
1169
+ function Bn(e, t) {
1170
+ let n = Ln(Dn(e), t);
1161
1171
  if (!n || n.result !== t.result || n.defeated !== !!t.defeated || !!n.sunk != !!t.sunk) return null;
1162
- let r = n.sunk ? In(n.sunk) : null;
1163
- return r && (t.sunk.ship_id !== r.id || !mn(r.cells, t.sunk.cells.map(([e, t]) => ({
1172
+ let r = n.sunk ? Rn(n.sunk) : null;
1173
+ return r && (t.sunk.ship_id !== r.id || !gn(r.cells, t.sunk.cells.map(([e, t]) => ({
1164
1174
  row: e,
1165
1175
  col: t
1166
1176
  })))) ? null : {
1167
- shots: on(e.incomingShots, t.row, t.col, t.result),
1177
+ shots: cn(e.incomingShots, t.row, t.col, t.result),
1168
1178
  ship: r
1169
1179
  };
1170
1180
  }
1171
- function zn(e, t, n, r) {
1172
- let i = dn(e, t);
1181
+ function Vn(e, t, n, r) {
1182
+ let i = pn(e, t);
1173
1183
  if (e[i]) return e[i] === n ? e : null;
1174
1184
  let a = {
1175
1185
  ...e,
1176
1186
  [i]: n
1177
1187
  };
1178
1188
  if (t === e.ownId) {
1179
- let t = r?.commitment === n ? Cn(r.fleet) : null;
1180
- t && $t.test(r.salt ?? "") ? a = {
1189
+ let t = r?.commitment === n ? Tn(r.fleet) : null;
1190
+ t && tn.test(r.salt ?? "") ? a = {
1181
1191
  ...a,
1182
1192
  myFleet: t,
1183
1193
  mySalt: r.salt,
@@ -1187,7 +1197,7 @@ function zn(e, t, n, r) {
1187
1197
  myFleet: [],
1188
1198
  mySalt: null,
1189
1199
  myCommitment: n,
1190
- error: rn
1200
+ error: on
1191
1201
  }), a.myReady = !0;
1192
1202
  } else a.opponentReady = !0;
1193
1203
  return a.hostCommitment && a.guestCommitment && (a = {
@@ -1198,12 +1208,12 @@ function zn(e, t, n, r) {
1198
1208
  pendingShot: null
1199
1209
  }), a;
1200
1210
  }
1201
- function Bn(e, t, { row: n, col: r, ply: i }, a) {
1202
- let s = t === e.ownId ? e.targetShots : e.incomingShots;
1203
- return !o({
1211
+ function Hn(e, t, { row: n, col: r, ply: i }, a) {
1212
+ let o = t === e.ownId ? e.targetShots : e.incomingShots;
1213
+ return !c({
1204
1214
  row: n,
1205
1215
  col: r
1206
- }) || s[n][r] !== null ? null : {
1216
+ }) || o[n][r] !== null ? null : {
1207
1217
  ...e,
1208
1218
  pendingShot: {
1209
1219
  row: n,
@@ -1214,8 +1224,8 @@ function Bn(e, t, { row: n, col: r, ply: i }, a) {
1214
1224
  lastEventId: a ?? e.lastEventId
1215
1225
  };
1216
1226
  }
1217
- function Vn(e, t, n, r) {
1218
- let i = e.pendingShot, a = t === e.ownId, o = a ? Rn(e, n) : Ln(e, n);
1227
+ function Un(e, t, n, r) {
1228
+ let i = e.pendingShot, a = t === e.ownId, o = a ? Bn(e, n) : zn(e, n);
1219
1229
  if (!o) return null;
1220
1230
  let s = !!n.defeated, c = {
1221
1231
  ply: i.ply,
@@ -1245,21 +1255,21 @@ function Vn(e, t, n, r) {
1245
1255
  verification: s ? "pending" : e.verification
1246
1256
  };
1247
1257
  }
1248
- function Hn(e, t, n) {
1258
+ function Wn(e, t, n) {
1249
1259
  let { ply: r, row: i, col: a, prev_event_id: o } = t.data;
1250
- return n === ln(e, r) ? e.status === "active" ? r <= e.ply ? e : e.pendingShot ? r === e.pendingShot.ply ? e : L(e, I) : r > e.ply + 1 ? L(e, I) : n === e.turnId ? o === e.lastEventId ? Bn(e, n, {
1260
+ return n === dn(e, r) ? e.status === "active" ? r <= e.ply ? e : e.pendingShot ? r === e.pendingShot.ply ? e : L(e, I) : r > e.ply + 1 ? L(e, I) : n === e.turnId ? o === e.lastEventId ? Hn(e, n, {
1251
1261
  row: i,
1252
1262
  col: a,
1253
1263
  ply: r
1254
- }, t.event_id) ?? e : L(e, I) : e : L(e, e.status === "invited" ? tn : I) : e;
1264
+ }, t.event_id) ?? e : L(e, I) : e : L(e, e.status === "invited" ? rn : I) : e;
1255
1265
  }
1256
- function Un(e, t, n) {
1266
+ function Gn(e, t, n) {
1257
1267
  let { ply: r, row: i, col: a } = t.data;
1258
1268
  if (e.status !== "active") return e.status === "placement" ? L(e, I) : e;
1259
1269
  let o = e.pendingShot;
1260
- return o ? r === o.ply ? n === o.by ? e : i !== o.row || a !== o.col ? n === e.ownId ? e : L(e, "El rival respondió a un disparo distinto.") : Vn(e, n, t.data, t.event_id) || (n === e.ownId ? e : L(e, nn)) : r < o.ply ? e : L(e, I) : r <= e.ply ? e : L(e, I);
1270
+ return o ? r === o.ply ? n === o.by ? e : i !== o.row || a !== o.col ? n === e.ownId ? e : L(e, "El rival respondió a un disparo distinto.") : Un(e, n, t.data, t.event_id) || (n === e.ownId ? e : L(e, an)) : r < o.ply ? e : L(e, I) : r <= e.ply ? e : L(e, I);
1261
1271
  }
1262
- function Wn(e, t, n) {
1272
+ function Kn(e, t, n) {
1263
1273
  return !e.winnerId || !["won", "closed"].includes(e.status) ? e : n === e.ownId ? e.myRevealSent ? e : {
1264
1274
  ...e,
1265
1275
  myRevealSent: !0
@@ -1272,7 +1282,7 @@ function Wn(e, t, n) {
1272
1282
  verification: "pending"
1273
1283
  };
1274
1284
  }
1275
- function Gn(e, t, n, r = {}) {
1285
+ function qn(e, t, n, r = {}) {
1276
1286
  if (!e || e.game !== "battleship" || t?.game !== "battleship" || t.game_id !== e.gameId || n !== e.hostId && n !== e.guestId) return e;
1277
1287
  let i = t.data;
1278
1288
  if (t.type === "game_end") return i.reason !== "closed" || [
@@ -1285,8 +1295,8 @@ function Gn(e, t, n, r = {}) {
1285
1295
  closedBy: n,
1286
1296
  error: ""
1287
1297
  };
1288
- if (t.type === "bs_reveal") return Wn(e, i, n);
1289
- if (en.includes(e.status) || e.status === "conflict") return e;
1298
+ if (t.type === "bs_reveal") return Kn(e, i, n);
1299
+ if (nn.includes(e.status) || e.status === "conflict") return e;
1290
1300
  switch (t.type) {
1291
1301
  case "game_accept":
1292
1302
  case "game_decline": return n !== e.guestId || e.status !== "invited" || i.invite_event_id !== e.inviteEventId ? e : t.type === "game_accept" ? {
@@ -1299,32 +1309,32 @@ function Gn(e, t, n, r = {}) {
1299
1309
  status: "declined",
1300
1310
  lastEventId: t.event_id
1301
1311
  };
1302
- case "bs_commit": return e.status === "invited" ? L(e, tn) : e.status === "placement" ? zn(e, n, i.commitment, r.stored) ?? e : e;
1303
- case "bs_fire": return Hn(e, t, n);
1304
- case "bs_result": return Un(e, t, n);
1312
+ case "bs_commit": return e.status === "invited" ? L(e, rn) : e.status === "placement" ? Vn(e, n, i.commitment, r.stored) ?? e : e;
1313
+ case "bs_fire": return Wn(e, t, n);
1314
+ case "bs_result": return Gn(e, t, n);
1305
1315
  default: return e;
1306
1316
  }
1307
1317
  }
1308
- function Kn(e, t) {
1309
- let n = Xt({
1318
+ function Jn(e, t) {
1319
+ let n = Qt({
1310
1320
  gameId: String(e.gameId),
1311
1321
  players: [e.hostId, e.guestId],
1312
1322
  firstPlayerId: e.hostId
1313
1323
  });
1314
1324
  for (let e of n.players) {
1315
- for (let r of t[e]) n = Zt(n, {
1325
+ for (let r of t[e]) n = $t(n, {
1316
1326
  type: "place_ship",
1317
1327
  playerId: e,
1318
- ...yn(r)
1328
+ ...xn(r)
1319
1329
  });
1320
- n = Zt(n, {
1330
+ n = $t(n, {
1321
1331
  type: "ready",
1322
1332
  playerId: e
1323
1333
  });
1324
1334
  }
1325
1335
  if (n.phase !== "playing") return !1;
1326
1336
  for (let t of e.shots) {
1327
- let e = Zt(n, {
1337
+ let e = $t(n, {
1328
1338
  type: "fire",
1329
1339
  playerId: t.by,
1330
1340
  row: t.row,
@@ -1335,30 +1345,30 @@ function Kn(e, t) {
1335
1345
  if (r.result !== t.result || r.defeated !== t.defeated || r.sunk !== !!t.sunk) return !1;
1336
1346
  if (t.sunk) {
1337
1347
  let n = e.boards[e.players.indexOf(r.targetId)].ships.find((e) => e.id === r.shipId);
1338
- if (t.sunk.id !== r.shipId || !mn(n.cells, t.sunk.cells)) return !1;
1348
+ if (t.sunk.id !== r.shipId || !gn(n.cells, t.sunk.cells)) return !1;
1339
1349
  }
1340
1350
  n = e;
1341
1351
  }
1342
1352
  return !e.winnerId || n.winnerId === e.winnerId;
1343
1353
  }
1344
- async function qn(e, t = e?.opponentReveal) {
1354
+ async function Yn(e, t = e?.opponentReveal) {
1345
1355
  if (!e || !t) return "pending";
1346
- let n = un(e, e.ownId), r = e[dn(e, n)], i = Cn(t.fleet);
1347
- if (!r || !i || typeof t.salt != "string" || !$t.test(t.salt)) return "mismatch";
1356
+ let n = fn(e, e.ownId), r = e[pn(e, n)], i = Tn(t.fleet);
1357
+ if (!r || !i || typeof t.salt != "string" || !tn.test(t.salt)) return "mismatch";
1348
1358
  let a;
1349
1359
  try {
1350
- a = await Pn(t.fleet, t.salt);
1360
+ a = await In(t.fleet, t.salt);
1351
1361
  } catch {
1352
1362
  return "mismatch";
1353
1363
  }
1354
1364
  if (a !== r) return "mismatch";
1355
- let o = Cn(e.myFleet);
1356
- return o ? Kn(e, {
1365
+ let o = Tn(e.myFleet);
1366
+ return o ? Jn(e, {
1357
1367
  [e.ownId]: o,
1358
1368
  [n]: i
1359
1369
  }) ? "ok" : "mismatch" : "pending";
1360
1370
  }
1361
- var Jn = (e) => {
1371
+ var Xn = (e) => {
1362
1372
  if (e.result === "miss") return [
1363
1373
  e.row,
1364
1374
  e.col,
@@ -1374,19 +1384,19 @@ var Jn = (e) => {
1374
1384
  e.row,
1375
1385
  e.col,
1376
1386
  2,
1377
- u.findIndex((t) => t.id === e.sunk.id),
1387
+ f.findIndex((t) => t.id === e.sunk.id),
1378
1388
  t.row,
1379
1389
  t.col,
1380
1390
  +(e.sunk.orientation === "vertical")
1381
1391
  ];
1382
1392
  };
1383
- function Yn(e) {
1393
+ function Zn(e) {
1384
1394
  if (!e.acceptEventId) return {
1385
1395
  commits: [null, null],
1386
1396
  log: [],
1387
1397
  head: e.inviteEventId
1388
1398
  };
1389
- let t = e.shots.map(Jn);
1399
+ let t = e.shots.map(Xn);
1390
1400
  return e.pendingShot && t.push([e.pendingShot.row, e.pendingShot.col]), {
1391
1401
  accept_event_id: e.acceptEventId,
1392
1402
  commits: [e.hostCommitment ?? null, e.guestCommitment ?? null],
@@ -1394,7 +1404,7 @@ function Yn(e) {
1394
1404
  head: e.lastEventId
1395
1405
  };
1396
1406
  }
1397
- function Xn(e, t) {
1407
+ function Qn(e, t) {
1398
1408
  let n = e.accept_event_id ?? null, r = t.accept_event_id ?? null;
1399
1409
  if (n && r && n !== r) return "diverged";
1400
1410
  let i = /* @__PURE__ */ new Set();
@@ -1414,7 +1424,7 @@ function Xn(e, t) {
1414
1424
  }
1415
1425
  return a.length !== o.length && i.add(a.length < o.length ? "behind" : "ahead"), i.size === 2 ? "mixed" : i.size === 1 ? [...i][0] : a.length && e.head !== t.head ? "diverged" : "equal";
1416
1426
  }
1417
- function Zn(e, t) {
1427
+ function $n(e, t) {
1418
1428
  if ((e.log ?? []).length || (t.log ?? []).length) return null;
1419
1429
  let n = e.accept_event_id ?? t.accept_event_id;
1420
1430
  return n ? {
@@ -1424,15 +1434,15 @@ function Zn(e, t) {
1424
1434
  head: n
1425
1435
  } : null;
1426
1436
  }
1427
- function Qn(e, t, n = {}) {
1437
+ function er(e, t, n = {}) {
1428
1438
  let r = {
1429
1439
  ...e,
1430
1440
  status: "invited",
1431
1441
  turnId: null,
1432
1442
  myReady: !1,
1433
1443
  opponentReady: !1,
1434
- incomingShots: an(),
1435
- targetShots: an(),
1444
+ incomingShots: sn(),
1445
+ targetShots: sn(),
1436
1446
  sunkEnemyShips: [],
1437
1447
  pendingShot: null,
1438
1448
  lastShot: null,
@@ -1461,11 +1471,11 @@ function Qn(e, t, n = {}) {
1461
1471
  acceptEventId: t.accept_event_id,
1462
1472
  lastEventId: t.accept_event_id
1463
1473
  };
1464
- for (let [t, r] of [e.hostId, e.guestId].entries()) if (a[t] && (s = zn(s, r, a[t], n.stored), !s)) return null;
1474
+ for (let [t, r] of [e.hostId, e.guestId].entries()) if (a[t] && (s = Vn(s, r, a[t], n.stored), !s)) return null;
1465
1475
  if (i.length && s.status !== "active") return null;
1466
1476
  for (let e = 0; e < i.length; e += 1) {
1467
1477
  let t = i[e], n = e + 1;
1468
- if (s = Bn(s, ln(s, n), {
1478
+ if (s = Hn(s, dn(s, n), {
1469
1479
  row: t[0],
1470
1480
  col: t[1],
1471
1481
  ply: n
@@ -1474,9 +1484,9 @@ function Qn(e, t, n = {}) {
1474
1484
  if (e !== i.length - 1) return null;
1475
1485
  break;
1476
1486
  }
1477
- let r = un(s, s.pendingShot.by), a = null;
1487
+ let r = fn(s, s.pendingShot.by), a = null;
1478
1488
  if (t[2] === 2) {
1479
- let e = u[t[3]];
1489
+ let e = f[t[3]];
1480
1490
  if (!e) return null;
1481
1491
  let n = t[6] === 1;
1482
1492
  a = {
@@ -1484,14 +1494,14 @@ function Qn(e, t, n = {}) {
1484
1494
  cells: Array.from({ length: e.size }, (e, r) => [t[4] + (n ? r : 0), t[5] + (n ? 0 : r)])
1485
1495
  };
1486
1496
  }
1487
- let o = sn(r === s.ownId ? s.incomingShots : s.targetShots) + (t[2] === 0 ? 0 : 1);
1488
- if (s = Vn(s, r, {
1497
+ let o = ln(r === s.ownId ? s.incomingShots : s.targetShots) + (t[2] === 0 ? 0 : 1);
1498
+ if (s = Un(s, r, {
1489
1499
  ply: n,
1490
1500
  row: t[0],
1491
1501
  col: t[1],
1492
1502
  result: t[2] === 0 ? "miss" : "hit",
1493
1503
  sunk: a,
1494
- defeated: o === Qt
1504
+ defeated: o === en
1495
1505
  }, null), !s || s.status === "won" && e !== i.length - 1) return null;
1496
1506
  }
1497
1507
  return !i.length && t.head !== t.accept_event_id ? null : (s = {
@@ -1504,7 +1514,7 @@ function Qn(e, t, n = {}) {
1504
1514
  verification: e.verification
1505
1515
  }), s);
1506
1516
  }
1507
- function $n(e, t) {
1517
+ function tr(e, t) {
1508
1518
  if (!e || !t) return !1;
1509
1519
  let n = e.log?.[(t.data?.ply ?? 0) - 1];
1510
1520
  switch (t.type) {
@@ -1515,37 +1525,37 @@ function $n(e, t) {
1515
1525
  default: return !1;
1516
1526
  }
1517
1527
  }
1518
- function er(e, t) {
1528
+ function nr(e, t) {
1519
1529
  let n = { ...e };
1520
1530
  return t.acceptEventId && (n[t.acceptEventId] = !0), t.lastEventId && (n[t.lastEventId] = !0), n;
1521
1531
  }
1522
1532
  // src/games/battleship/net/fleetStorage.js
1523
- var tr = "lira:bs:", nr = 12096e5, rr = (e, t) => `${tr}${e}:${t}`, ir = () => {
1533
+ var rr = "lira:bs:", ir = 12096e5, ar = (e, t) => `${rr}${e}:${t}`, or = () => {
1524
1534
  try {
1525
1535
  return globalThis.localStorage ?? null;
1526
1536
  } catch {
1527
1537
  return null;
1528
1538
  }
1529
1539
  };
1530
- function ar(e) {
1540
+ function sr(e) {
1531
1541
  return typeof e == "object" && !!e && Array.isArray(e.fleet) && e.fleet.length === 5 && typeof e.salt == "string" && /^[0-9a-f]{32}$/.test(e.salt) && typeof e.commitment == "string" && /^[0-9a-f]{64}$/.test(e.commitment);
1532
1542
  }
1533
- function or(e) {
1543
+ function cr(e) {
1534
1544
  let t = Date.now();
1535
1545
  for (let n = e.length - 1; n >= 0; --n) {
1536
1546
  let r = e.key(n);
1537
- if (r?.startsWith(tr)) try {
1547
+ if (r?.startsWith(rr)) try {
1538
1548
  let n = JSON.parse(e.getItem(r));
1539
- ar(n) && t - n.savedAt < nr || e.removeItem(r);
1549
+ sr(n) && t - n.savedAt < ir || e.removeItem(r);
1540
1550
  } catch {
1541
1551
  e.removeItem(r);
1542
1552
  }
1543
1553
  }
1544
1554
  }
1545
- function sr(e, t, { fleet: n, salt: r, commitment: i }) {
1555
+ function lr(e, t, { fleet: n, salt: r, commitment: i }) {
1546
1556
  try {
1547
- let a = ir();
1548
- return a ? (or(a), a.setItem(rr(e, t), JSON.stringify({
1557
+ let a = or();
1558
+ return a ? (cr(a), a.setItem(ar(e, t), JSON.stringify({
1549
1559
  fleet: n,
1550
1560
  salt: r,
1551
1561
  commitment: i,
@@ -1555,10 +1565,10 @@ function sr(e, t, { fleet: n, salt: r, commitment: i }) {
1555
1565
  return !1;
1556
1566
  }
1557
1567
  }
1558
- function cr(e, t) {
1568
+ function ur(e, t) {
1559
1569
  try {
1560
- let n = JSON.parse(ir()?.getItem(rr(e, t)) ?? "null");
1561
- return ar(n) ? {
1570
+ let n = JSON.parse(or()?.getItem(ar(e, t)) ?? "null");
1571
+ return sr(n) ? {
1562
1572
  fleet: n.fleet,
1563
1573
  salt: n.salt,
1564
1574
  commitment: n.commitment
@@ -1568,11 +1578,11 @@ function cr(e, t) {
1568
1578
  }
1569
1579
  }
1570
1580
  // src/games/tanks/logic/constants.js
1571
- var R = 1e5, lr = 160 * R, z = 2 * R, ur = 20 * R;
1581
+ var R = 1e5, dr = 160 * R, z = 2 * R, fr = 20 * R;
1572
1582
  2 * R;
1573
- var dr = 1 * R;
1583
+ var pr = 1 * R;
1574
1584
  4 * R, 4 * R;
1575
- var fr = 18e4, pr = 25e4, mr = 5e4, B = 25e3, hr = 60 * R, gr = 4 * R, V = Object.freeze({
1585
+ var mr = 18e4, hr = 25e4, gr = 5e4, B = 25e3, _r = 60 * R, vr = 4 * R, V = Object.freeze({
1576
1586
  move: Object.freeze([-16, 16]),
1577
1587
  yaw: Object.freeze([0, 359]),
1578
1588
  pitch: Object.freeze([5, 80]),
@@ -1602,11 +1612,11 @@ var fr = 18e4, pr = 25e4, mr = 5e4, B = 25e3, hr = 60 * R, gr = 4 * R, V = Objec
1602
1612
  depth: 8e4,
1603
1613
  speedPct: 100
1604
1614
  })
1605
- }), _r = Object.freeze({
1615
+ }), yr = Object.freeze({
1606
1616
  radius: 4 * R,
1607
1617
  maxDmg: 15,
1608
1618
  depth: 8e4
1609
- }), vr = Object.freeze([
1619
+ }), br = Object.freeze([
1610
1620
  Object.freeze([
1611
1621
  0,
1612
1622
  0,
@@ -1632,10 +1642,10 @@ var fr = 18e4, pr = 25e4, mr = 5e4, B = 25e3, hr = 60 * R, gr = 4 * R, V = Objec
1632
1642
  0,
1633
1643
  -6e3
1634
1644
  ])
1635
- ]), yr = Object.freeze({
1645
+ ]), xr = Object.freeze({
1636
1646
  heavy: 2,
1637
1647
  cluster: 2
1638
- }), br = Object.freeze([
1648
+ }), Sr = Object.freeze([
1639
1649
  0,
1640
1650
  17452,
1641
1651
  34899,
@@ -1727,20 +1737,20 @@ var fr = 18e4, pr = 25e4, mr = 5e4, B = 25e3, hr = 60 * R, gr = 4 * R, V = Objec
1727
1737
  999391,
1728
1738
  999848,
1729
1739
  1e6
1730
- ]), xr = 1e6;
1731
- function Sr(e) {
1740
+ ]), Cr = 1e6;
1741
+ function wr(e) {
1732
1742
  let t = (e % 360 + 360) % 360;
1733
- return t <= 90 ? br[t] : t <= 180 ? br[180 - t] : t <= 270 ? -br[t - 180] : -br[360 - t];
1743
+ return t <= 90 ? Sr[t] : t <= 180 ? Sr[180 - t] : t <= 270 ? -Sr[t - 180] : -Sr[360 - t];
1734
1744
  }
1735
- function Cr(e) {
1736
- return Sr(e + 90);
1745
+ function Tr(e) {
1746
+ return wr(e + 90);
1737
1747
  }
1738
1748
  function U(e, t) {
1739
- return Math.trunc(e * t / xr);
1749
+ return Math.trunc(e * t / Cr);
1740
1750
  }
1741
1751
  // src/games/tanks/logic/rng.js
1742
- var wr = (e) => Number.isInteger(e) && e >= 0 && e <= 4294967295;
1743
- function Tr(e) {
1752
+ var Er = (e) => Number.isInteger(e) && e >= 0 && e <= 4294967295;
1753
+ function Dr(e) {
1744
1754
  let t = e >>> 0;
1745
1755
  return function() {
1746
1756
  t = t + 1831565813 >>> 0;
@@ -1751,8 +1761,8 @@ function Tr(e) {
1751
1761
  function W(e, t, n) {
1752
1762
  return t + e() % (n - t + 1);
1753
1763
  }
1754
- function Er(e, t) {
1755
- let n = Tr((e ^ Math.imul(t, 2654435761)) >>> 0);
1764
+ function Or(e, t) {
1765
+ let n = Dr((e ^ Math.imul(t, 2654435761)) >>> 0);
1756
1766
  return {
1757
1767
  x: W(n, -40, 40),
1758
1768
  z: W(n, -40, 40)
@@ -1761,10 +1771,10 @@ function Er(e, t) {
1761
1771
  // src/games/tanks/logic/terrain.js
1762
1772
  var G = (e, t, n) => e < t ? t : e > n ? n : e, K = (e, t, n, r) => e + Math.trunc((t - e) * n / r);
1763
1773
  function q(e, t, n) {
1764
- let r = G(t, 0, lr), i = G(n, 0, lr), a = Math.min(Math.trunc(r / z), 79), o = Math.min(Math.trunc(i / z), 79), s = r - a * z, c = i - o * z, l = o * 81;
1774
+ let r = G(t, 0, dr), i = G(n, 0, dr), a = Math.min(Math.trunc(r / z), 79), o = Math.min(Math.trunc(i / z), 79), s = r - a * z, c = i - o * z, l = o * 81;
1765
1775
  return K(K(e[l + a], e[l + a + 1], s, z), K(e[l + 81 + a], e[l + 81 + a + 1], s, z), c, z);
1766
1776
  }
1767
- function Dr(e, t, n, r) {
1777
+ function kr(e, t, n, r) {
1768
1778
  let i = Math.trunc(80 / t) + 1, a = [];
1769
1779
  for (let t = 0; t < i * i; t += 1) a.push(W(e, n, r) * 1e3);
1770
1780
  return {
@@ -1773,11 +1783,11 @@ function Dr(e, t, n, r) {
1773
1783
  values: a
1774
1784
  };
1775
1785
  }
1776
- function Or({ n: e, step: t, values: n }, r, i) {
1786
+ function Ar({ n: e, step: t, values: n }, r, i) {
1777
1787
  let a = Math.min(Math.trunc(r / t), e - 2), o = Math.min(Math.trunc(i / t), e - 2), s = r - a * t, c = i - o * t, l = (t, r) => n[r * e + t];
1778
1788
  return K(K(l(a, o), l(a + 1, o), s, t), K(l(a, o + 1), l(a + 1, o + 1), s, t), c, t);
1779
1789
  }
1780
- function kr(e) {
1790
+ function jr(e) {
1781
1791
  let t = new Int32Array(e.length);
1782
1792
  for (let n = 0; n < 81; n += 1) for (let r = 0; r < 81; r += 1) {
1783
1793
  let i = 0;
@@ -1786,7 +1796,7 @@ function kr(e) {
1786
1796
  }
1787
1797
  return t;
1788
1798
  }
1789
- function Ar(e, t, n, r, i) {
1799
+ function Mr(e, t, n, r, i) {
1790
1800
  let a = q(e, t, n), o = r * r, s = i * i;
1791
1801
  for (let r = 0; r < 81; r += 1) for (let c = 0; c < 81; c += 1) {
1792
1802
  let l = c * z - t, u = r * z - n;
@@ -1801,17 +1811,17 @@ function Ar(e, t, n, r, i) {
1801
1811
  }
1802
1812
  }
1803
1813
  }
1804
- var J = (e, t, n) => W(e, t, n) * (R / 2), jr = (e, t, n, r, i) => {
1814
+ var J = (e, t, n) => W(e, t, n) * (R / 2), Nr = (e, t, n, r, i) => {
1805
1815
  let a = e - n, o = t - r;
1806
1816
  return a > i || a < -i || o > i || o < -i ? !1 : a * a + o * o < i * i;
1807
- }, Mr = (e, t, n, r) => t >= e.x - e.w / 2 - r && t <= e.x + e.w / 2 + r && n >= e.z - e.d / 2 - r && n <= e.z + e.d / 2 + r;
1808
- function Nr(e) {
1809
- let t = Tr(e), n = Dr(t, 20, 0, 1200), r = Dr(t, 10, -250, 250), i = Dr(t, 4, -60, 60), a = /* @__PURE__ */ new Int32Array(6561);
1817
+ }, Pr = (e, t, n, r) => t >= e.x - e.w / 2 - r && t <= e.x + e.w / 2 + r && n >= e.z - e.d / 2 - r && n <= e.z + e.d / 2 + r;
1818
+ function Fr(e) {
1819
+ let t = Dr(e), n = kr(t, 20, 0, 1200), r = kr(t, 10, -250, 250), i = kr(t, 4, -60, 60), a = /* @__PURE__ */ new Int32Array(6561);
1810
1820
  for (let e = 0; e < 81; e += 1) for (let t = 0; t < 81; t += 1) {
1811
- let o = 3 * R + Or(n, t, e) + Or(r, t, e) + Or(i, t, e);
1812
- a[e * 81 + t] = G(o, 0, ur);
1821
+ let o = 3 * R + Ar(n, t, e) + Ar(r, t, e) + Ar(i, t, e);
1822
+ a[e * 81 + t] = G(o, 0, fr);
1813
1823
  }
1814
- a = kr(kr(a));
1824
+ a = jr(jr(a));
1815
1825
  let o = [{
1816
1826
  x: 20 * R + J(t, -4, 4),
1817
1827
  z: 80 * R + J(t, -40, 40)
@@ -1819,20 +1829,20 @@ function Nr(e) {
1819
1829
  x: 140 * R + J(t, -4, 4),
1820
1830
  z: 80 * R + J(t, -40, 40)
1821
1831
  }];
1822
- for (let e of o) Ar(a, e.x, e.z, gr, gr + 3 * R);
1832
+ for (let e of o) Mr(a, e.x, e.z, vr, vr + 3 * R);
1823
1833
  let s = [], c = W(t, 4, 6);
1824
1834
  for (let e = 0; e < 200 && s.length < c; e += 1) {
1825
1835
  let e = t() % 2 == 0 ? "rock" : "wall", n = J(t, 4, 12), r = J(t, 4, 12);
1826
1836
  e === "wall" && (n >= r ? r = 2 * R : n = 2 * R);
1827
1837
  let i = J(t, 4, 10), c = J(t, 100, 220), l = J(t, 40, 280), u = 12 * R + (n > r ? n : r);
1828
- if (o.some((e) => jr(e.x, e.z, c, l, u))) continue;
1838
+ if (o.some((e) => Nr(e.x, e.z, c, l, u))) continue;
1829
1839
  let d = {
1830
1840
  x: c,
1831
1841
  z: l,
1832
1842
  w: n,
1833
1843
  d: r
1834
1844
  };
1835
- if (s.some((e) => Mr(e, c, l, (n > r ? n : r) + 4e5))) continue;
1845
+ if (s.some((e) => Pr(e, c, l, (n > r ? n : r) + 4e5))) continue;
1836
1846
  let f = [
1837
1847
  [-1, -1],
1838
1848
  [1, -1],
@@ -1850,7 +1860,7 @@ function Nr(e) {
1850
1860
  let l = [], u = W(t, 30, 60);
1851
1861
  for (let e = 0; e < u * 10 && l.length < u; e += 1) {
1852
1862
  let e = J(t, 4, 316), n = J(t, 4, 316), r = t() % 3 == 0 ? "rock" : "tree", i = W(t, 80, 140);
1853
- o.some((t) => jr(t.x, t.z, e, n, 1e6)) || s.some((t) => Mr(t, e, n, 2e5)) || l.push({
1863
+ o.some((t) => Nr(t.x, t.z, e, n, 1e6)) || s.some((t) => Pr(t, e, n, 2e5)) || l.push({
1854
1864
  id: l.length,
1855
1865
  kind: r,
1856
1866
  x: e,
@@ -1865,7 +1875,7 @@ function Nr(e) {
1865
1875
  decor: l
1866
1876
  };
1867
1877
  }
1868
- function Pr(e, { x: t, z: n, radius: r, depth: i }) {
1878
+ function Ir(e, { x: t, z: n, radius: r, depth: i }) {
1869
1879
  let a = r * r, o = (e) => G(Math.trunc(e / z) - 1, 0, 80);
1870
1880
  for (let s = o(n - r); s <= o(n + r) + 2 && s < 81; s += 1) for (let c = o(t - r); c <= o(t + r) + 2 && c < 81; c += 1) {
1871
1881
  let o = c * z - t, l = s * z - n;
@@ -1877,29 +1887,29 @@ function Pr(e, { x: t, z: n, radius: r, depth: i }) {
1877
1887
  }
1878
1888
  return e;
1879
1889
  }
1880
- function Fr(e, t) {
1881
- return e.filter((e) => !t.some((t) => jr(t.x, t.z, e.x, e.z, t.radius)));
1890
+ function Lr(e, t) {
1891
+ return e.filter((e) => !t.some((t) => Nr(t.x, t.z, e.x, e.z, t.radius)));
1882
1892
  }
1883
1893
  // src/games/tanks/logic/ballistics.js
1884
- function Ir(e, t) {
1894
+ function Rr(e, t) {
1885
1895
  return Math.trunc((2e4 + 600 * e) * H[t].speedPct / 100);
1886
1896
  }
1887
- function Lr(e, { yaw: t, pitch: n, power: r, ammo: i }) {
1888
- let a = Cr(n), o = Sr(n), s = Cr(t), c = Sr(t), l = U(pr, a), u = Ir(r, i), d = U(u, a);
1897
+ function zr(e, { yaw: t, pitch: n, power: r, ammo: i }) {
1898
+ let a = Tr(n), o = wr(n), s = Tr(t), c = wr(t), l = U(hr, a), u = Rr(r, i), d = U(u, a);
1889
1899
  return {
1890
1900
  x: e.x + U(l, s),
1891
- y: e.y + fr + U(pr, o),
1901
+ y: e.y + mr + U(hr, o),
1892
1902
  z: e.z + U(l, c),
1893
1903
  vx: U(d, s),
1894
1904
  vy: U(u, o),
1895
1905
  vz: U(d, c)
1896
1906
  };
1897
1907
  }
1898
- function Rr(e, t, n, r, i, a, o) {
1908
+ function Br(e, t, n, r, i, a, o) {
1899
1909
  let s = e - r, c = t - i, l = n - a;
1900
1910
  return s > o || s < -o || c > o || c < -o || l > o || l < -o ? !1 : s * s + c * c + l * l < o * o;
1901
1911
  }
1902
- function zr(e, { wind: t, heights: n, tanks: r, obstacles: i, maxTicks: a = 600, split: o = !1 }) {
1912
+ function Vr(e, { wind: t, heights: n, tanks: r, obstacles: i, maxTicks: a = 600, split: o = !1 }) {
1903
1913
  let { x: s, y: c, z: l, vx: u, vy: d, vz: f } = e, p = [
1904
1914
  s,
1905
1915
  c,
@@ -1909,7 +1919,7 @@ function zr(e, { wind: t, heights: n, tanks: r, obstacles: i, maxTicks: a = 600,
1909
1919
  let a = d;
1910
1920
  u += t.x, d -= 392, f += t.z, s += u, c += d, l += f;
1911
1921
  let m = null;
1912
- for (let e of r) if (Rr(s, c, l, e.x, e.y + 1e5, e.z, 2e5)) {
1922
+ for (let e of r) if (Br(s, c, l, e.x, e.y + 1e5, e.z, 2e5)) {
1913
1923
  m = {
1914
1924
  x: s,
1915
1925
  y: c,
@@ -1920,7 +1930,7 @@ function zr(e, { wind: t, heights: n, tanks: r, obstacles: i, maxTicks: a = 600,
1920
1930
  break;
1921
1931
  }
1922
1932
  if (!m) {
1923
- let e = i.find((e) => c <= e.y + e.h && Mr(e, s, l, 0));
1933
+ let e = i.find((e) => c <= e.y + e.h && Pr(e, s, l, 0));
1924
1934
  e && (m = {
1925
1935
  x: s,
1926
1936
  y: c,
@@ -1976,7 +1986,7 @@ function zr(e, { wind: t, heights: n, tanks: r, obstacles: i, maxTicks: a = 600,
1976
1986
  }
1977
1987
  };
1978
1988
  }
1979
- var Br = (e, t, n, r) => ({
1989
+ var Hr = (e, t, n, r) => ({
1980
1990
  role: e,
1981
1991
  startTick: t,
1982
1992
  samples: n.samples,
@@ -1986,17 +1996,17 @@ var Br = (e, t, n, r) => ({
1986
1996
  maxDmg: n.impact.kind === "split" ? 0 : r.maxDmg,
1987
1997
  depth: n.impact.kind === "split" ? 0 : r.depth
1988
1998
  });
1989
- function Vr(e, t, n) {
1990
- let r = Lr(e, t);
1991
- if (t.ammo !== "cluster") return [Br("main", 0, zr(r, n), H[t.ammo])];
1992
- let i = zr(r, {
1999
+ function Ur(e, t, n) {
2000
+ let r = zr(e, t);
2001
+ if (t.ammo !== "cluster") return [Hr("main", 0, Vr(r, n), H[t.ammo])];
2002
+ let i = Vr(r, {
1993
2003
  ...n,
1994
2004
  split: !0
1995
- }), a = [Br("carrier", 0, i, _r)];
2005
+ }), a = [Hr("carrier", 0, i, yr)];
1996
2006
  if (i.impact.kind !== "split") return a;
1997
2007
  let o = (n.maxTicks ?? 600) - i.ticks;
1998
- for (let [e, t, r] of vr) {
1999
- let { x: s, y: c, z: l } = i.impact, { vx: u, vy: d, vz: f } = i.velocity, p = zr({
2008
+ for (let [e, t, r] of br) {
2009
+ let { x: s, y: c, z: l } = i.impact, { vx: u, vy: d, vz: f } = i.velocity, p = Vr({
2000
2010
  x: s,
2001
2011
  y: c,
2002
2012
  z: l,
@@ -2008,18 +2018,18 @@ function Vr(e, t, n) {
2008
2018
  maxTicks: o,
2009
2019
  split: !1
2010
2020
  });
2011
- a.push(Br("bomblet", i.ticks, p, _r));
2021
+ a.push(Hr("bomblet", i.ticks, p, yr));
2012
2022
  }
2013
2023
  return a;
2014
2024
  }
2015
- function Hr(e, t) {
2025
+ function Wr(e, t) {
2016
2026
  let n = t.map(() => 0);
2017
2027
  for (let r of e) {
2018
2028
  let { impact: e, radius: i, maxDmg: a } = r;
2019
2029
  if (e.kind === "out" || e.kind === "split") continue;
2020
2030
  let o = i * i;
2021
2031
  t.forEach((t, r) => {
2022
- let s = t.y + dr;
2032
+ let s = t.y + pr;
2023
2033
  e.kind === "tank" && e.tankId === t.id && (n[r] += 25);
2024
2034
  let c = e.x - t.x, l = e.y - s, u = e.z - t.z;
2025
2035
  if (c >= i || c <= -i || l >= i || l <= -i || u >= i || u <= -i) return;
@@ -2029,7 +2039,7 @@ function Hr(e, t) {
2029
2039
  }
2030
2040
  return n;
2031
2041
  }
2032
- function Ur(e) {
2042
+ function Gr(e) {
2033
2043
  return e.filter((e) => e.impact.kind !== "out" && e.impact.kind !== "split").map((e) => ({
2034
2044
  x: e.impact.x,
2035
2045
  z: e.impact.z,
@@ -2038,8 +2048,8 @@ function Ur(e) {
2038
2048
  }));
2039
2049
  }
2040
2050
  // src/games/tanks/logic/movement.js
2041
- function Wr(e, t, { heights: n, obstacles: r, others: i }) {
2042
- let a = t < 0 ? -1 : 1, o = (t < 0 ? -t : t) * (mr / B), s = Math.min(o, Math.trunc(e.fuel / B)), c = a * U(B, Cr(e.hullYaw)), l = a * U(B, Sr(e.hullYaw)), { x: u, z: d } = e, f = q(n, u, d), p = [{
2051
+ function Kr(e, t, { heights: n, obstacles: r, others: i }) {
2052
+ let a = t < 0 ? -1 : 1, o = (t < 0 ? -t : t) * (gr / B), s = Math.min(o, Math.trunc(e.fuel / B)), c = a * U(B, Tr(e.hullYaw)), l = a * U(B, wr(e.hullYaw)), { x: u, z: d } = e, f = q(n, u, d), p = [{
2043
2053
  x: u,
2044
2054
  y: f,
2045
2055
  z: d
@@ -2050,7 +2060,7 @@ function Wr(e, t, { heights: n, obstacles: r, others: i }) {
2050
2060
  h = "border";
2051
2061
  break;
2052
2062
  }
2053
- if (r.some((n) => Mr(n, e, t, 2e5))) {
2063
+ if (r.some((n) => Pr(n, e, t, 2e5))) {
2054
2064
  h = "obstacle";
2055
2065
  break;
2056
2066
  }
@@ -2086,14 +2096,14 @@ function Wr(e, t, { heights: n, obstacles: r, others: i }) {
2086
2096
  };
2087
2097
  }
2088
2098
  // src/games/tanks/logic/game.js
2089
- var Gr = (e) => typeof e == "string" && e.length > 0 && e.length <= 256 && e.trim() === e, Y = (e) => ({
2099
+ var qr = (e) => typeof e == "string" && e.length > 0 && e.length <= 256 && e.trim() === e, Y = (e) => ({
2090
2100
  ok: !1,
2091
2101
  reason: e
2092
- }), Kr = (e, [t, n]) => Number.isInteger(e) && e >= t && e <= n;
2093
- function qr({ gameId: e, players: t, firstPlayerId: n = t?.[0], seed: r } = {}) {
2094
- if (!Gr(e) || !Array.isArray(t) || t.length !== 2 || !t.every(Gr) || t[0] === t[1] || !t.includes(n)) throw TypeError("Supply a gameId, two distinct player IDs and a valid firstPlayerId.");
2095
- if (!wr(r)) throw TypeError("Supply an integer seed in 0..0xffffffff.");
2096
- let { heights: i, spawns: a, obstacles: o, decor: s } = Nr(r), c = t.map((e, t) => ({
2102
+ }), Jr = (e, [t, n]) => Number.isInteger(e) && e >= t && e <= n;
2103
+ function Yr({ gameId: e, players: t, firstPlayerId: n = t?.[0], seed: r } = {}) {
2104
+ if (!qr(e) || !Array.isArray(t) || t.length !== 2 || !t.every(qr) || t[0] === t[1] || !t.includes(n)) throw TypeError("Supply a gameId, two distinct player IDs and a valid firstPlayerId.");
2105
+ if (!Er(r)) throw TypeError("Supply an integer seed in 0..0xffffffff.");
2106
+ let { heights: i, spawns: a, obstacles: o, decor: s } = Fr(r), c = t.map((e, t) => ({
2097
2107
  id: e,
2098
2108
  x: a[t].x,
2099
2109
  y: q(i, a[t].x, a[t].z),
@@ -2102,8 +2112,8 @@ function qr({ gameId: e, players: t, firstPlayerId: n = t?.[0], seed: r } = {})
2102
2112
  yaw: t === 0 ? 0 : 180,
2103
2113
  pitch: 30,
2104
2114
  hp: 100,
2105
- fuel: hr,
2106
- ammo: { ...yr },
2115
+ fuel: _r,
2116
+ ammo: { ...xr },
2107
2117
  skips: 0
2108
2118
  }));
2109
2119
  return {
@@ -2129,24 +2139,24 @@ function qr({ gameId: e, players: t, firstPlayerId: n = t?.[0], seed: r } = {})
2129
2139
  revision: 0
2130
2140
  };
2131
2141
  }
2132
- function Jr(e, t) {
2142
+ function Xr(e, t) {
2133
2143
  return !e || !t || typeof t != "object" ? Y("invalid_action") : e.phase === "finished" ? Y("game_finished") : t.gameId !== void 0 && t.gameId !== e.gameId ? Y("wrong_game") : t.expectedRevision !== void 0 && t.expectedRevision !== e.revision ? Y("stale_revision") : e.players.includes(t.playerId) ? { ok: !0 } : Y("unknown_player");
2134
2144
  }
2135
- function Yr(e, t) {
2136
- let n = Jr(e, t);
2145
+ function Zr(e, t) {
2146
+ let n = Xr(e, t);
2137
2147
  if (!n.ok) return n;
2138
2148
  let r = e.players.indexOf(t.playerId);
2139
2149
  if (r !== e.turnIndex) return Y("not_your_turn");
2140
- if (!Kr(t.move, V.move)) return Y("invalid_move");
2141
- if (!Kr(t.yaw, V.yaw)) return Y("invalid_yaw");
2142
- if (!Kr(t.pitch, V.pitch)) return Y("invalid_pitch");
2143
- if (!Kr(t.power, V.power)) return Y("invalid_power");
2150
+ if (!Jr(t.move, V.move)) return Y("invalid_move");
2151
+ if (!Jr(t.yaw, V.yaw)) return Y("invalid_yaw");
2152
+ if (!Jr(t.pitch, V.pitch)) return Y("invalid_pitch");
2153
+ if (!Jr(t.power, V.power)) return Y("invalid_power");
2144
2154
  if (typeof t.ammo != "string" || !Object.hasOwn(H, t.ammo)) return Y("unknown_ammo");
2145
2155
  let i = H[t.ammo].cost;
2146
2156
  return i > 0 && e.tanks[r].ammo[t.ammo] < i ? Y("out_of_ammo") : { ok: !0 };
2147
2157
  }
2148
- function Xr(e, t, { maxTicks: n = 600 } = {}) {
2149
- let r = e.players.indexOf(t.playerId), i = e.tanks[r], a = e.tanks[1 - r], o = Er(e.seed, e.ply), s = Wr(i, t.move ?? 0, {
2158
+ function Qr(e, t, { maxTicks: n = 600 } = {}) {
2159
+ let r = e.players.indexOf(t.playerId), i = e.tanks[r], a = e.tanks[1 - r], o = Or(e.seed, e.ply), s = Kr(i, t.move ?? 0, {
2150
2160
  heights: e.heights,
2151
2161
  obstacles: e.obstacles,
2152
2162
  others: [a]
@@ -2162,13 +2172,13 @@ function Xr(e, t, { maxTicks: n = 600 } = {}) {
2162
2172
  x: e.x,
2163
2173
  y: e.y,
2164
2174
  z: e.z
2165
- }), u = Vr(c, t, {
2175
+ }), u = Ur(c, t, {
2166
2176
  wind: o,
2167
2177
  heights: e.heights,
2168
2178
  tanks: l,
2169
2179
  obstacles: e.obstacles,
2170
2180
  maxTicks: n
2171
- }), d = Hr(u, l), f = {};
2181
+ }), d = Wr(u, l), f = {};
2172
2182
  return e.players.forEach((e, t) => {
2173
2183
  f[e] = d[t];
2174
2184
  }), {
@@ -2179,11 +2189,11 @@ function Xr(e, t, { maxTicks: n = 600 } = {}) {
2179
2189
  tankAfter: c,
2180
2190
  shots: u,
2181
2191
  damage: f,
2182
- craters: Ur(u),
2192
+ craters: Gr(u),
2183
2193
  wind: o
2184
2194
  };
2185
2195
  }
2186
- function Zr(e, t, n, r) {
2196
+ function $r(e, t, n, r) {
2187
2197
  return {
2188
2198
  ...e,
2189
2199
  ...r,
@@ -2194,7 +2204,7 @@ function Zr(e, t, n, r) {
2194
2204
  revision: e.revision + 1
2195
2205
  };
2196
2206
  }
2197
- function Qr(e, t) {
2207
+ function ei(e, t) {
2198
2208
  let n = e.turnIndex, r = {
2199
2209
  playerId: t.playerId,
2200
2210
  move: t.move,
@@ -2202,12 +2212,12 @@ function Qr(e, t) {
2202
2212
  pitch: t.pitch,
2203
2213
  power: t.power,
2204
2214
  ammo: t.ammo
2205
- }, i = Xr(e, r), a = e.heights;
2215
+ }, i = Qr(e, r), a = e.heights;
2206
2216
  if (i.craters.length) {
2207
2217
  a = Int32Array.from(e.heights);
2208
- for (let e of i.craters) Pr(a, e);
2218
+ for (let e of i.craters) Ir(a, e);
2209
2219
  }
2210
- let o = i.craters.length ? Fr(e.decor, i.craters) : e.decor, s = e.tanks.map((e, t) => {
2220
+ let o = i.craters.length ? Lr(e.decor, i.craters) : e.decor, s = e.tanks.map((e, t) => {
2211
2221
  let o = t === n ? i.tankAfter : e, s = {
2212
2222
  ...e,
2213
2223
  ammo: { ...e.ammo },
@@ -2237,23 +2247,23 @@ function Qr(e, t) {
2237
2247
  ...i
2238
2248
  }
2239
2249
  }, l = s.map((e) => e.hp === 0);
2240
- if (l[0] && l[1]) return Zr(c, -1, "destroyed");
2241
- if (l[0] || l[1]) return Zr(c, +!!l[0], "destroyed");
2250
+ if (l[0] && l[1]) return $r(c, -1, "destroyed");
2251
+ if (l[0] || l[1]) return $r(c, +!!l[0], "destroyed");
2242
2252
  if (c.shots >= c.maxShots) {
2243
2253
  let [e, t] = s.map((e) => e.hp);
2244
- return Zr(c, e === t ? -1 : e > t ? 0 : 1, "max_shots");
2254
+ return $r(c, e === t ? -1 : e > t ? 0 : 1, "max_shots");
2245
2255
  }
2246
2256
  return {
2247
2257
  ...c,
2248
2258
  revision: e.revision + 1
2249
2259
  };
2250
2260
  }
2251
- function $r(e, t) {
2261
+ function ti(e, t) {
2252
2262
  if (!t || typeof t != "object") return e;
2253
- if (t.type === "turn") return Yr(e, t).ok ? Qr(e, t) : e;
2254
- if (!Jr(e, t).ok) return e;
2263
+ if (t.type === "turn") return Zr(e, t).ok ? ei(e, t) : e;
2264
+ if (!Xr(e, t).ok) return e;
2255
2265
  let n = e.players.indexOf(t.playerId);
2256
- if (t.type === "resign") return Zr(e, 1 - n, "resign");
2266
+ if (t.type === "resign") return $r(e, 1 - n, "resign");
2257
2267
  if (t.type === "skip") {
2258
2268
  if (n !== e.turnIndex || t.reason !== void 0 && t.reason !== "timeout") return e;
2259
2269
  let r = e.tanks[n].skips + 1, i = e.tanks.map((e, t) => t === n ? {
@@ -2270,22 +2280,22 @@ function $r(e, t) {
2270
2280
  playerId: t.playerId
2271
2281
  }
2272
2282
  };
2273
- return r >= 3 ? Zr(a, 1 - n, "timeout") : {
2283
+ return r >= 3 ? $r(a, 1 - n, "timeout") : {
2274
2284
  ...a,
2275
2285
  revision: e.revision + 1
2276
2286
  };
2277
2287
  }
2278
2288
  return e;
2279
2289
  }
2280
- function ei(e, t) {
2290
+ function ni(e, t) {
2281
2291
  let n = (e.lo ^ t) >>> 0, r = n * 435, i = r >>> 0, a = (r - i) / 4294967296;
2282
2292
  e.hi = Math.imul(e.hi, 435) + a + (n << 8) >>> 0, e.lo = i;
2283
2293
  }
2284
- function ti(e, t) {
2294
+ function ri(e, t) {
2285
2295
  let n = t | 0;
2286
- ei(e, n & 255), ei(e, n >>> 8 & 255), ei(e, n >>> 16 & 255), ei(e, n >>> 24 & 255);
2296
+ ni(e, n & 255), ni(e, n >>> 8 & 255), ni(e, n >>> 16 & 255), ni(e, n >>> 24 & 255);
2287
2297
  }
2288
- function ni(e) {
2298
+ function ii(e) {
2289
2299
  let t = {
2290
2300
  hi: 3421674724,
2291
2301
  lo: 2216829733
@@ -2302,11 +2312,11 @@ function ni(e) {
2302
2312
  ];
2303
2313
  for (let t of e.tanks) i.push(t.x, t.y, t.z, t.hp, t.fuel, t.ammo.heavy, t.ammo.cluster, t.skips, t.yaw, t.pitch);
2304
2314
  i.push(n, e.decor.length);
2305
- for (let e of i) ti(t, e);
2315
+ for (let e of i) ri(t, e);
2306
2316
  return t.hi.toString(16).padStart(8, "0") + t.lo.toString(16).padStart(8, "0");
2307
2317
  }
2308
2318
  // src/games/tanks/net/sha256.js
2309
- var ri = new Uint32Array([
2319
+ var ai = new Uint32Array([
2310
2320
  1116352408,
2311
2321
  1899447441,
2312
2322
  3049323471,
@@ -2372,7 +2382,7 @@ var ri = new Uint32Array([
2372
2382
  3204031479,
2373
2383
  3329325298
2374
2384
  ]), X = (e, t) => e >>> t | e << 32 - t;
2375
- function ii(e) {
2385
+ function oi(e) {
2376
2386
  let t = new TextEncoder().encode(String(e)), n = t.length, r = new Uint8Array((n + 9 >> 6) + 1 << 6);
2377
2387
  r.set(t), r[n] = 128;
2378
2388
  let i = new DataView(r.buffer);
@@ -2395,7 +2405,7 @@ function ii(e) {
2395
2405
  }
2396
2406
  let [t, n, r, s, c, l, u, d] = a;
2397
2407
  for (let e = 0; e < 64; e += 1) {
2398
- let i = d + (X(c, 6) ^ X(c, 11) ^ X(c, 25)) + (c & l ^ ~c & u) + ri[e] + o[e] >>> 0, a = (X(t, 2) ^ X(t, 13) ^ X(t, 22)) + (t & n ^ t & r ^ n & r) >>> 0;
2408
+ let i = d + (X(c, 6) ^ X(c, 11) ^ X(c, 25)) + (c & l ^ ~c & u) + ai[e] + o[e] >>> 0, a = (X(t, 2) ^ X(t, 13) ^ X(t, 22)) + (t & n ^ t & r ^ n & r) >>> 0;
2399
2409
  d = u, u = l, l = c, c = s + i >>> 0, s = r, r = n, n = t, t = i + a >>> 0;
2400
2410
  }
2401
2411
  a[0] += t, a[1] += n, a[2] += r, a[3] += s, a[4] += c, a[5] += l, a[6] += u, a[7] += d;
@@ -2403,22 +2413,22 @@ function ii(e) {
2403
2413
  return Array.from(a, (e) => e.toString(16).padStart(8, "0")).join("");
2404
2414
  }
2405
2415
  // src/games/tanks/net/session.js
2406
- var ai = "La partida perdió sincronización. Se intentará resincronizar.", oi = "Falta la aceptación de la partida. Ciérrala y vuelve a invitar.", si = "El rival reveló una semilla que no coincide con su invitación.", ci = "Los resultados del disparo no coinciden entre dispositivos.", li = [
2416
+ var si = "La partida perdió sincronización. Se intentará resincronizar.", ci = "Falta la aceptación de la partida. Ciérrala y vuelve a invitar.", li = "El rival reveló una semilla que no coincide con su invitación.", ui = "Los resultados del disparo no coinciden entre dispositivos.", di = [
2407
2417
  "won",
2408
2418
  "draw",
2409
2419
  "closed",
2410
2420
  "declined"
2411
- ], ui = (e, t) => ({
2421
+ ], fi = (e, t) => ({
2412
2422
  ...e,
2413
2423
  status: "conflict",
2414
2424
  error: t
2415
- }), di = (e) => Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
2416
- function fi() {
2425
+ }), pi = (e) => Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
2426
+ function mi() {
2417
2427
  let e = /* @__PURE__ */ new Uint8Array(16);
2418
- return globalThis.crypto.getRandomValues(e), di(e);
2428
+ return globalThis.crypto.getRandomValues(e), pi(e);
2419
2429
  }
2420
- var pi = (e) => ii(`lira-tanks-seed:${e}`), mi = (e, t) => parseInt(ii(`lira-tanks-map:${e}:${t}`).slice(0, 8), 16) >>> 0;
2421
- function hi(e, t) {
2430
+ var hi = (e) => oi(`lira-tanks-seed:${e}`), gi = (e, t) => parseInt(oi(`lira-tanks-map:${e}:${t}`).slice(0, 8), 16) >>> 0;
2431
+ function _i(e, t) {
2422
2432
  let n = t.first_player_id === e.guestId ? e.guestId : e.hostId;
2423
2433
  return {
2424
2434
  ...e,
@@ -2445,21 +2455,21 @@ function hi(e, t) {
2445
2455
  sync: e.sync ?? null
2446
2456
  };
2447
2457
  }
2448
- var Z = (e) => [e.hostId, e.guestId], gi = (e) => e.logic && e.logic.phase === "playing" ? Z(e)[e.logic.turnIndex] : null, _i = (e) => e?.status === "active" && !e.pendingEvent && gi(e) === e.ownId, vi = (e, t, n) => e === "tk_turn" ? [
2458
+ var Z = (e) => [e.hostId, e.guestId], vi = (e) => e.logic && e.logic.phase === "playing" ? Z(e)[e.logic.turnIndex] : null, yi = (e) => e?.status === "active" && !e.pendingEvent && vi(e) === e.ownId, bi = (e, t, n) => e === "tk_turn" ? [
2449
2459
  1,
2450
2460
  t.move,
2451
2461
  t.yaw,
2452
2462
  t.pitch,
2453
2463
  t.power,
2454
2464
  t.ammo
2455
- ] : e === "tk_skip" ? [2] : [3, n], yi = (e, t) => e.length === t.length && e.every((e, n) => e === t[n]);
2456
- function bi(e, t) {
2465
+ ] : e === "tk_skip" ? [2] : [3, n], xi = (e, t) => e.length === t.length && e.every((e, n) => e === t[n]);
2466
+ function Si(e, t) {
2457
2467
  let n = Z(e);
2458
2468
  if (t[0] === 3) return {
2459
2469
  type: "resign",
2460
2470
  playerId: n[t[1]]
2461
2471
  };
2462
- let r = gi(e);
2472
+ let r = vi(e);
2463
2473
  return t[0] === 2 ? {
2464
2474
  type: "skip",
2465
2475
  playerId: r,
@@ -2471,11 +2481,11 @@ function bi(e, t) {
2471
2481
  yaw: t[2],
2472
2482
  pitch: t[3],
2473
2483
  power: t[4],
2474
- ammo: gt[t[5]]
2484
+ ammo: vt[t[5]]
2475
2485
  };
2476
2486
  }
2477
- function xi(e, t, n, r) {
2478
- let i = $r(e.logic, bi(e, t));
2487
+ function Ci(e, t, n, r) {
2488
+ let i = ti(e.logic, Si(e, t));
2479
2489
  if (i === e.logic) return null;
2480
2490
  let a = i.phase === "finished";
2481
2491
  return {
@@ -2496,13 +2506,13 @@ function xi(e, t, n, r) {
2496
2506
  result: i.result ?? null
2497
2507
  };
2498
2508
  }
2499
- function Si(e, t, n) {
2500
- if (pi(t) !== e.seedCommit) return null;
2501
- let r = qr({
2509
+ function wi(e, t, n) {
2510
+ if (hi(t) !== e.seedCommit) return null;
2511
+ let r = Yr({
2502
2512
  gameId: e.gameId,
2503
2513
  players: Z(e),
2504
2514
  firstPlayerId: e.firstPlayerId,
2505
- seed: mi(t, e.seedB)
2515
+ seed: gi(t, e.seedB)
2506
2516
  });
2507
2517
  return {
2508
2518
  ...e,
@@ -2518,7 +2528,7 @@ function Si(e, t, n) {
2518
2528
  error: ""
2519
2529
  };
2520
2530
  }
2521
- function Ci(e, t, n) {
2531
+ function Ti(e, t, n) {
2522
2532
  if (![e.hostId, e.guestId].includes(n)) return e;
2523
2533
  let r = t.data;
2524
2534
  if (t.type === "game_end") return ["closed", "declined"].includes(e.status) ? e : {
@@ -2527,7 +2537,7 @@ function Ci(e, t, n) {
2527
2537
  closedBy: n,
2528
2538
  error: ""
2529
2539
  };
2530
- if (li.includes(e.status) || e.status === "conflict") return e;
2540
+ if (di.includes(e.status) || e.status === "conflict") return e;
2531
2541
  if (t.type === "game_accept" || t.type === "game_decline") return n !== e.guestId || e.status !== "invited" || r.invite_event_id !== e.inviteEventId ? e : t.type === "game_decline" ? {
2532
2542
  ...e,
2533
2543
  status: "declined",
@@ -2539,22 +2549,22 @@ function Ci(e, t, n) {
2539
2549
  acceptEventId: t.event_id,
2540
2550
  lastEventId: t.event_id
2541
2551
  };
2542
- if (t.type === "tk_seed") return n !== e.hostId || e.status !== "seeding" ? e : Si(e, r.seed_a, t.event_id) ?? ui(e, si);
2552
+ if (t.type === "tk_seed") return n !== e.hostId || e.status !== "seeding" ? e : wi(e, r.seed_a, t.event_id) ?? fi(e, li);
2543
2553
  if (![
2544
2554
  "tk_turn",
2545
2555
  "tk_skip",
2546
2556
  "tk_resign"
2547
2557
  ].includes(t.type)) return e;
2548
- if (e.status !== "active") return ui(e, oi);
2549
- let i = Z(e).indexOf(n), a = vi(t.type, r, i);
2550
- if (r.ply <= e.ply) return yi(e.log[r.ply - 1] ?? [], a) ? e : ui(e, ai);
2551
- if (r.ply > e.ply + 1 || r.prev_event_id !== e.lastEventId) return ui(e, ai);
2552
- if (t.type !== "tk_resign" && n !== gi(e)) return e;
2553
- let o = xi(e, a, t.event_id, n);
2554
- return o ? t.type === "tk_turn" && ni(o.logic) !== r.hash ? ui(e, ci) : o : e;
2555
- }
2556
- function wi(e, t) {
2557
- if (!_i(e)) return null;
2558
+ if (e.status !== "active") return fi(e, ci);
2559
+ let i = Z(e).indexOf(n), a = bi(t.type, r, i);
2560
+ if (r.ply <= e.ply) return xi(e.log[r.ply - 1] ?? [], a) ? e : fi(e, si);
2561
+ if (r.ply > e.ply + 1 || r.prev_event_id !== e.lastEventId) return fi(e, si);
2562
+ if (t.type !== "tk_resign" && n !== vi(e)) return e;
2563
+ let o = Ci(e, a, t.event_id, n);
2564
+ return o ? t.type === "tk_turn" && ii(o.logic) !== r.hash ? fi(e, ui) : o : e;
2565
+ }
2566
+ function Ei(e, t) {
2567
+ if (!yi(e)) return null;
2558
2568
  let n = {
2559
2569
  ply: e.ply + 1,
2560
2570
  prev_event_id: e.lastEventId,
@@ -2562,16 +2572,16 @@ function wi(e, t) {
2562
2572
  yaw: t.yaw,
2563
2573
  pitch: t.pitch,
2564
2574
  power: t.power,
2565
- ammo: gt.indexOf(t.ammo)
2575
+ ammo: vt.indexOf(t.ammo)
2566
2576
  };
2567
2577
  if (n.ammo < 0) return null;
2568
- let r = xi(e, vi("tk_turn", n), "local", e.ownId);
2578
+ let r = Ci(e, bi("tk_turn", n), "local", e.ownId);
2569
2579
  return r ? {
2570
2580
  ...n,
2571
- hash: ni(r.logic)
2581
+ hash: ii(r.logic)
2572
2582
  } : null;
2573
2583
  }
2574
- function Ti(e) {
2584
+ function Di(e) {
2575
2585
  let t = {
2576
2586
  log: e.log ?? [],
2577
2587
  head: e.lastEventId
@@ -2584,14 +2594,14 @@ function Ti(e) {
2584
2594
  seed_event_id: e.seedEventId
2585
2595
  }), t;
2586
2596
  }
2587
- function Ei(e, t) {
2597
+ function Oi(e, t) {
2588
2598
  if (e.accept_event_id && t.accept_event_id && e.accept_event_id !== t.accept_event_id || e.seed_a && t.seed_a && e.seed_a !== t.seed_a) return "diverged";
2589
2599
  let n = Math.min(e.log.length, t.log.length);
2590
- for (let r = 0; r < n; r += 1) if (!yi(e.log[r], t.log[r])) return "diverged";
2600
+ for (let r = 0; r < n; r += 1) if (!xi(e.log[r], t.log[r])) return "diverged";
2591
2601
  let r = (e) => (e.seed_a ? 2 : +!!e.accept_event_id) * 1e3 + e.log.length;
2592
2602
  return r(e) === r(t) ? e.log.length === t.log.length && e.head !== t.head && e.log.length > 0 ? "diverged" : "equal" : r(e) < r(t) ? "behind" : "ahead";
2593
2603
  }
2594
- function Di(e, t) {
2604
+ function ki(e, t) {
2595
2605
  let n = {
2596
2606
  ...e,
2597
2607
  status: "invited",
@@ -2621,16 +2631,16 @@ function Di(e, t) {
2621
2631
  seedB: t.seed_b,
2622
2632
  lastEventId: t.accept_event_id
2623
2633
  }, !t.seed_a) return n;
2624
- if (n = Si(n, t.seed_a, t.seed_event_id), !n) return null;
2634
+ if (n = wi(n, t.seed_a, t.seed_event_id), !n) return null;
2625
2635
  for (let e = 0; e < t.log.length; e += 1) {
2626
2636
  let r = t.log[e];
2627
- if (!yt(r)) return null;
2628
- let i = e === t.log.length - 1, a = r[0] === 3 ? Z(n)[r[1]] : gi(n);
2629
- if (n = xi(n, r, i ? t.head : `${t.seed_event_id}:${e + 1}`, a), !n) return null;
2637
+ if (!xt(r)) return null;
2638
+ let i = e === t.log.length - 1, a = r[0] === 3 ? Z(n)[r[1]] : vi(n);
2639
+ if (n = Ci(n, r, i ? t.head : `${t.seed_event_id}:${e + 1}`, a), !n) return null;
2630
2640
  }
2631
2641
  return n;
2632
2642
  }
2633
- function Oi(e, t) {
2643
+ function Ai(e, t) {
2634
2644
  if (!t) return !1;
2635
2645
  if (t.type === "tk_seed") return e.seed_a === t.data.seed_a;
2636
2646
  if (t.type === "game_accept") return e.accept_event_id === t.event_id;
@@ -2640,9 +2650,9 @@ function Oi(e, t) {
2640
2650
  "tk_resign"
2641
2651
  ].includes(t.type)) return !1;
2642
2652
  let n = e.log[t.data.ply - 1];
2643
- return !!n && n[0] === vi(t.type, t.data, 0)[0];
2653
+ return !!n && n[0] === bi(t.type, t.data, 0)[0];
2644
2654
  }
2645
- function ki(e, t) {
2655
+ function ji(e, t) {
2646
2656
  let n = { ...e };
2647
2657
  return [
2648
2658
  t.acceptEventId,
@@ -2652,7 +2662,7 @@ function ki(e, t) {
2652
2662
  e && (n[e] = !0);
2653
2663
  }), n;
2654
2664
  }
2655
- function Ai(e) {
2665
+ function Mi(e) {
2656
2666
  return {
2657
2667
  gameId: e.gameId,
2658
2668
  roomId: e.roomId,
@@ -2665,22 +2675,22 @@ function Ai(e) {
2665
2675
  inviteEventId: e.inviteEventId,
2666
2676
  createdAt: e.createdAt,
2667
2677
  status: e.status,
2668
- ...Ti(e)
2678
+ ...Di(e)
2669
2679
  };
2670
2680
  }
2671
2681
  // src/games/tanks/net/tankStorage.js
2672
- var ji = "lira:tk:", Mi = 6048e5, Ni = 20, Pi = (e, t) => `${ji}${e}:${t}`, Fi = () => {
2682
+ var Ni = "lira:tk:", Pi = 6048e5, Fi = 20, Ii = (e, t) => `${Ni}${e}:${t}`, Li = () => {
2673
2683
  try {
2674
2684
  return globalThis.localStorage ?? null;
2675
2685
  } catch {
2676
2686
  return null;
2677
2687
  }
2678
2688
  };
2679
- function Ii(e) {
2689
+ function Ri(e) {
2680
2690
  let t = [];
2681
2691
  for (let n = 0; n < e.length; n += 1) {
2682
2692
  let r = e.key(n);
2683
- if (r?.startsWith(ji)) try {
2693
+ if (r?.startsWith(Ni)) try {
2684
2694
  let n = JSON.parse(e.getItem(r));
2685
2695
  t.push({
2686
2696
  key: r,
@@ -2695,53 +2705,53 @@ function Ii(e) {
2695
2705
  }
2696
2706
  return t;
2697
2707
  }
2698
- function Li(e) {
2699
- let t = Date.now(), n = Ii(e);
2700
- n.filter(({ value: e }) => !e || !(t - e.savedAt < Mi)).forEach(({ key: t }) => e.removeItem(t));
2701
- let r = n.filter(({ value: e }) => e && t - e.savedAt < Mi).sort((e, t) => e.value.savedAt - t.value.savedAt);
2702
- r.slice(0, Math.max(0, r.length - Ni)).forEach(({ key: t }) => e.removeItem(t));
2708
+ function zi(e) {
2709
+ let t = Date.now(), n = Ri(e);
2710
+ n.filter(({ value: e }) => !e || !(t - e.savedAt < Pi)).forEach(({ key: t }) => e.removeItem(t));
2711
+ let r = n.filter(({ value: e }) => e && t - e.savedAt < Pi).sort((e, t) => e.value.savedAt - t.value.savedAt);
2712
+ r.slice(0, Math.max(0, r.length - Fi)).forEach(({ key: t }) => e.removeItem(t));
2703
2713
  }
2704
- function Ri(e, t, n) {
2714
+ function Bi(e, t, n) {
2705
2715
  try {
2706
- let r = Fi();
2716
+ let r = Li();
2707
2717
  if (!r) return !1;
2708
- let i = zi(e, t) ?? {};
2709
- return r.setItem(Pi(e, t), JSON.stringify({
2718
+ let i = Vi(e, t) ?? {};
2719
+ return r.setItem(Ii(e, t), JSON.stringify({
2710
2720
  ...i,
2711
2721
  ...n,
2712
2722
  savedAt: Date.now()
2713
- })), Li(r), !0;
2723
+ })), zi(r), !0;
2714
2724
  } catch {
2715
2725
  return !1;
2716
2726
  }
2717
2727
  }
2718
- function zi(e, t) {
2728
+ function Vi(e, t) {
2719
2729
  try {
2720
- let n = JSON.parse(Fi()?.getItem(Pi(e, t)) ?? "null");
2721
- return !n || typeof n != "object" || !(Date.now() - n.savedAt < Mi) || n.seedA !== void 0 && !/^[0-9a-f]{32}$/.test(n.seedA) ? null : n;
2730
+ let n = JSON.parse(Li()?.getItem(Ii(e, t)) ?? "null");
2731
+ return !n || typeof n != "object" || !(Date.now() - n.savedAt < Pi) || n.seedA !== void 0 && !/^[0-9a-f]{32}$/.test(n.seedA) ? null : n;
2722
2732
  } catch {
2723
2733
  return null;
2724
2734
  }
2725
2735
  }
2726
- function Bi(e) {
2736
+ function Hi(e) {
2727
2737
  try {
2728
- let t = Fi();
2729
- return t ? Ii(t).filter(({ key: t, value: n }) => t.startsWith(`${ji}${e}:`) && n?.snapshot && Date.now() - n.savedAt < Mi).map(({ value: e }) => e).sort((e, t) => t.savedAt - e.savedAt) : [];
2738
+ let t = Li();
2739
+ return t ? Ri(t).filter(({ key: t, value: n }) => t.startsWith(`${Ni}${e}:`) && n?.snapshot && Date.now() - n.savedAt < Pi).map(({ value: e }) => e).sort((e, t) => t.savedAt - e.savedAt) : [];
2730
2740
  } catch {
2731
2741
  return [];
2732
2742
  }
2733
2743
  }
2734
2744
  // src/games/shared/useChatGames.js
2735
- var Vi = zt, Q = (e) => e?.game ?? "connect4", Hi = (e) => Q(e) === "battleship", Ui = (e) => Q(e) === "tanks", Wi = (e) => ["tanks_live", "racing_live"].includes(Q(e)), Gi = 250, $ = (e) => [
2745
+ var Ui = Vt, Q = (e) => e?.game ?? "connect4", Wi = (e) => Q(e) === "battleship", Gi = (e) => Q(e) === "tanks", Ki = (e) => ["tanks_live", "racing_live"].includes(Q(e)), qi = 250, $ = (e) => [
2736
2746
  "won",
2737
2747
  "draw",
2738
2748
  "closed",
2739
2749
  "declined"
2740
- ].includes(e.status), Ki = (e, t, n) => JSON.stringify([
2750
+ ].includes(e.status), Ji = (e, t, n) => JSON.stringify([
2741
2751
  e,
2742
2752
  String(t),
2743
2753
  n
2744
- ]), qi = (e) => {
2754
+ ]), Yi = (e) => {
2745
2755
  let t = Object.keys(e).filter((t) => $(e[t]));
2746
2756
  if (t.length <= 80) return e;
2747
2757
  let n = { ...e };
@@ -2749,7 +2759,7 @@ var Vi = zt, Q = (e) => e?.game ?? "connect4", Hi = (e) => Q(e) === "battleship"
2749
2759
  delete n[e];
2750
2760
  }), n;
2751
2761
  };
2752
- function Ji(e, t, n) {
2762
+ function Xi(e, t, n) {
2753
2763
  if (![e.hostId, e.guestId].includes(n)) return e;
2754
2764
  if (t.type === "game_end" && t.data.reason === "closed") return ["closed", "declined"].includes(e.status) ? e : {
2755
2765
  ...e,
@@ -2778,7 +2788,7 @@ function Ji(e, t, n) {
2778
2788
  error: "La partida perdió sincronización. Ciérrala y envía una nueva invitación."
2779
2789
  };
2780
2790
  if (n !== e.turnId) return e;
2781
- let o = Jt(e.board, a, n);
2791
+ let o = Xt(e.board, a, n);
2782
2792
  return o ? {
2783
2793
  ...e,
2784
2794
  board: o.board,
@@ -2796,7 +2806,7 @@ function Ji(e, t, n) {
2796
2806
  turnId: n === e.hostId ? e.guestId : e.hostId
2797
2807
  } : e;
2798
2808
  }
2799
- var Yi = 8e3, Xi = {
2809
+ var Zi = 8e3, Qi = {
2800
2810
  status: "idle",
2801
2811
  requestId: null,
2802
2812
  requestedAt: 0,
@@ -2805,14 +2815,14 @@ var Yi = 8e3, Xi = {
2805
2815
  replies: [],
2806
2816
  offer: null,
2807
2817
  message: ""
2808
- }, Zi = (e) => [
2818
+ }, $i = (e) => [
2809
2819
  "game_resync_request",
2810
2820
  "game_resync_state",
2811
2821
  "bs_sync_request",
2812
2822
  "bs_sync_state",
2813
2823
  "tk_sync_request",
2814
2824
  "tk_sync_state"
2815
- ].includes(e), Qi = (e) => e.acceptEventId ? {
2825
+ ].includes(e), ea = (e) => e.acceptEventId ? {
2816
2826
  accept_event_id: e.acceptEventId,
2817
2827
  moves: e.moves ?? [],
2818
2828
  rev: (e.moves ?? []).length
@@ -2820,10 +2830,10 @@ var Yi = 8e3, Xi = {
2820
2830
  moves: [],
2821
2831
  rev: 0
2822
2832
  };
2823
- function $i(e, t, n) {
2833
+ function ta(e, t, n) {
2824
2834
  let r = {
2825
2835
  ...e,
2826
- board: Ut(),
2836
+ board: Gt(),
2827
2837
  ply: 0,
2828
2838
  turnId: e.hostId,
2829
2839
  winnerId: null,
@@ -2849,7 +2859,7 @@ function $i(e, t, n) {
2849
2859
  let [r, o] = n[t];
2850
2860
  if (a.has(o)) return null;
2851
2861
  a.add(o);
2852
- let s = t % 2 == 0 ? e.hostId : e.guestId, c = Ji(i, {
2862
+ let s = t % 2 == 0 ? e.hostId : e.guestId, c = Xi(i, {
2853
2863
  type: "game_move",
2854
2864
  event_id: o,
2855
2865
  data: {
@@ -2863,18 +2873,18 @@ function $i(e, t, n) {
2863
2873
  }
2864
2874
  return i;
2865
2875
  }
2866
- function ea(e, t) {
2876
+ function na(e, t) {
2867
2877
  if (e.acceptEventId && t.acceptEventId && e.acceptEventId !== t.acceptEventId) return "diverged";
2868
2878
  let n = Math.min(e.moves.length, t.moves.length);
2869
2879
  for (let r = 0; r < n; r += 1) if (e.moves[r][0] !== t.moves[r][0] || e.moves[r][1] !== t.moves[r][1]) return "diverged";
2870
2880
  return e.moves.length === t.moves.length ? e.acceptEventId && !t.acceptEventId ? "ahead" : !e.acceptEventId && t.acceptEventId ? "behind" : "equal" : e.moves.length < t.moves.length ? "behind" : "ahead";
2871
2881
  }
2872
- var ta = (e) => e.pendingEvent?.type === "game_move" && !e.pending ? e.pendingEvent.event_id : null, na = {
2882
+ var ra = (e) => e.pendingEvent?.type === "game_move" && !e.pending ? e.pendingEvent.event_id : null, ia = {
2873
2883
  requestType: "game_resync_request",
2874
2884
  stateType: "game_resync_state",
2875
- historyOf: Qi,
2876
- rebuild: (e, t) => $i(e, t.accept_event_id ?? null, t.moves),
2877
- compare: (e, t) => ea({
2885
+ historyOf: ea,
2886
+ rebuild: (e, t) => ta(e, t.accept_event_id ?? null, t.moves),
2887
+ compare: (e, t) => na({
2878
2888
  acceptEventId: e.acceptEventId ?? null,
2879
2889
  moves: e.moves ?? []
2880
2890
  }, {
@@ -2886,7 +2896,7 @@ var ta = (e) => e.pendingEvent?.type === "game_move" && !e.pending ? e.pendingEv
2886
2896
  moves: e.moves
2887
2897
  }),
2888
2898
  covers: (e, t) => {
2889
- let n = ta(e);
2899
+ let n = ra(e);
2890
2900
  return !!(n && t.moves?.some((e) => e[1] === n));
2891
2901
  },
2892
2902
  markSeen: (e, t) => {
@@ -2896,40 +2906,40 @@ var ta = (e) => e.pendingEvent?.type === "game_move" && !e.pending ? e.pendingEv
2896
2906
  }), n;
2897
2907
  },
2898
2908
  merge: () => null
2899
- }, ra = (e) => ({
2909
+ }, aa = (e) => ({
2900
2910
  requestType: "bs_sync_request",
2901
2911
  stateType: "bs_sync_state",
2902
- historyOf: Yn,
2903
- rebuild: (t, n) => Qn(t, n, { stored: e(t.scope, t.gameId) }),
2904
- compare: (e, t) => Xn(Yn(e), t),
2912
+ historyOf: Zn,
2913
+ rebuild: (t, n) => er(t, n, { stored: e(t.scope, t.gameId) }),
2914
+ compare: (e, t) => Qn(Zn(e), t),
2905
2915
  offerOf: (e) => ({
2906
2916
  accept_event_id: e.accept_event_id,
2907
2917
  commits: e.commits,
2908
2918
  log: e.log,
2909
2919
  head: e.head
2910
2920
  }),
2911
- covers: (e, t) => !!(e.pendingEvent && !e.pending && $n(t, e.pendingEvent)),
2912
- markSeen: er,
2913
- merge: (e, t) => Zn(Yn(e), t)
2914
- }), ia = {
2921
+ covers: (e, t) => !!(e.pendingEvent && !e.pending && tr(t, e.pendingEvent)),
2922
+ markSeen: nr,
2923
+ merge: (e, t) => $n(Zn(e), t)
2924
+ }), oa = {
2915
2925
  requestType: "tk_sync_request",
2916
2926
  stateType: "tk_sync_state",
2917
- historyOf: Ti,
2918
- rebuild: Di,
2919
- compare: (e, t) => Ei(Ti(e), t),
2927
+ historyOf: Di,
2928
+ rebuild: ki,
2929
+ compare: (e, t) => Oi(Di(e), t),
2920
2930
  offerOf: (e) => ({
2921
2931
  ...e,
2922
2932
  request_event_id: void 0
2923
2933
  }),
2924
- covers: (e, t) => !!(e.pendingEvent && !e.pending && Oi(t, e.pendingEvent)),
2925
- markSeen: ki,
2934
+ covers: (e, t) => !!(e.pendingEvent && !e.pending && Ai(t, e.pendingEvent)),
2935
+ markSeen: ji,
2926
2936
  merge: () => null
2927
- }, aa = (e) => ({
2937
+ }, sa = (e) => ({
2928
2938
  ...e,
2929
2939
  game: "connect4",
2930
2940
  turnId: e.hostId,
2931
2941
  status: "invited",
2932
- board: Ut(),
2942
+ board: Gt(),
2933
2943
  ply: 0,
2934
2944
  winnerId: null,
2935
2945
  lastMove: null,
@@ -2938,40 +2948,40 @@ var ta = (e) => e.pendingEvent?.type === "game_move" && !e.pending ? e.pendingEv
2938
2948
  pendingEvent: null,
2939
2949
  acceptEventId: null,
2940
2950
  moves: []
2941
- }), oa = (e, t, n) => F(t, {
2951
+ }), ca = (e, t, n) => F(t, {
2942
2952
  game_id: e.gameId,
2943
2953
  data: n,
2944
2954
  game: Q(e)
2945
2955
  });
2946
- function sa() {
2947
- let e = null, t = /* @__PURE__ */ new Map(), n = (e, n) => t.get(`${e}:${n}`) ?? cr(e, n), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), s = ra(n), c = /* @__PURE__ */ new Map(), l = (e, t) => c.get(`${e}:${t}`) ?? zi(e, t)?.seedA ?? null, u = {
2956
+ function la() {
2957
+ let e = null, t = /* @__PURE__ */ new Map(), n = (e, n) => t.get(`${e}:${n}`) ?? ur(e, n), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), s = aa(n), c = /* @__PURE__ */ new Map(), l = (e, t) => c.get(`${e}:${t}`) ?? Vi(e, t)?.seedA ?? null, u = {
2948
2958
  connect4: {
2949
- create: (e) => aa(e),
2950
- apply: (e, t, n) => Ji(e, t, n),
2951
- sync: na
2959
+ create: (e) => sa(e),
2960
+ apply: (e, t, n) => Xi(e, t, n),
2961
+ sync: ia
2952
2962
  },
2953
2963
  battleship: {
2954
- create: (e) => hn(e),
2955
- apply: (e, t, r, i) => Gn(e, t, r, { stored: t.type === "bs_commit" && r === i ? n(e.scope, e.gameId) : null }),
2964
+ create: (e) => _n(e),
2965
+ apply: (e, t, r, i) => qn(e, t, r, { stored: t.type === "bs_commit" && r === i ? n(e.scope, e.gameId) : null }),
2956
2966
  sync: s,
2957
2967
  after: (e, t) => t().bsScheduleEffects(e)
2958
2968
  },
2959
2969
  racing_live: {
2960
- create: (e, t) => at(e, t.data),
2961
- apply: ot
2970
+ create: (e, t) => st(e, t.data),
2971
+ apply: ct
2962
2972
  },
2963
2973
  tanks_live: {
2964
- create: (e, t) => Ye(e, t.data),
2965
- apply: Xe
2974
+ create: (e, t) => Ze(e, t.data),
2975
+ apply: Qe
2966
2976
  },
2967
2977
  tanks: {
2968
- create: (e, t) => hi(e, t.data),
2969
- apply: (e, t, n) => Ci(e, t, n),
2970
- sync: ia,
2978
+ create: (e, t) => _i(e, t.data),
2979
+ apply: (e, t, n) => Ti(e, t, n),
2980
+ sync: oa,
2971
2981
  after: (e, t) => t().tkScheduleEffects(e)
2972
2982
  }
2973
- }, f = (e) => u[Q(e)] ?? null, m = (e) => f(e)?.sync ?? na;
2974
- return d((s, d) => ({
2983
+ }, d = (e) => u[Q(e)] ?? null, f = (e) => d(e)?.sync ?? ia;
2984
+ return p((s, p) => ({
2975
2985
  games: {},
2976
2986
  configureTransport: (t) => {
2977
2987
  e = t;
@@ -2979,12 +2989,12 @@ function sa() {
2979
2989
  clear: () => {
2980
2990
  r.forEach((e) => clearTimeout(e)), r.clear(), o.forEach((e) => clearTimeout(e)), o.clear(), t.clear(), c.clear(), i.clear(), a.clear(), s({ games: {} });
2981
2991
  },
2982
- markDisconnected: (e) => s((t) => ({ games: Object.fromEntries(Object.entries(t.games).map(([t, n]) => [t, n.scope === e && !Wi(n) && !$(n) ? {
2992
+ markDisconnected: (e) => s((t) => ({ games: Object.fromEntries(Object.entries(t.games).map(([t, n]) => [t, n.scope === e && !Ki(n) && !$(n) ? {
2983
2993
  ...n,
2984
2994
  status: "conflict",
2985
2995
  error: "Conexión interrumpida. Se intentará resincronizar al reconectar.",
2986
2996
  sync: {
2987
- ...Xi,
2997
+ ...Qi,
2988
2998
  ...n.sync,
2989
2999
  status: "idle",
2990
3000
  auto: !1
@@ -2994,19 +3004,19 @@ function sa() {
2994
3004
  let i = typeof n == "object" ? n : {
2995
3005
  scope: n,
2996
3006
  currentUserId: r
2997
- }, o = i?.scope ?? e?.getScope?.(), c = String(i?.currentUserId ?? e?.getUserId?.() ?? ""), l = t.data ?? t.payload, f = l && typeof l == "object" ? {
3007
+ }, o = i?.scope ?? e?.getScope?.(), c = String(i?.currentUserId ?? e?.getUserId?.() ?? ""), l = t.data ?? t.payload, d = l && typeof l == "object" ? {
2998
3008
  ...l,
2999
3009
  ...t
3000
- } : t, p = f.message ?? f.text;
3001
- if (typeof p != "string" || !p.startsWith("LIRA_GAME_V1:")) return !1;
3002
- let m = Vt(p), h = String(f.room_id ?? ""), g = String(f.user_id ?? "");
3010
+ } : t, f = d.message ?? d.text;
3011
+ if (typeof f != "string" || !f.startsWith("LIRA_GAME_V1:")) return !1;
3012
+ let m = Ut(f), h = String(d.room_id ?? ""), g = String(d.user_id ?? "");
3003
3013
  if (!m || !o || !c || !g || !h.startsWith("private_")) return !0;
3004
3014
  let _ = h.slice(8).split("_");
3005
3015
  if (_.length !== 2 || !_.includes(c) || !_.includes(g)) return !0;
3006
- let v = Ki(o, h, m.game_id), y = d().games[v];
3016
+ let v = Ji(o, h, m.game_id), y = p().games[v];
3007
3017
  if (y && Q(y) !== m.game) return !0;
3008
- if (Zi(m.type)) return y && !y.seen[m.event_id] && d().handleResync(v, m, g, c), !0;
3009
- if (!y && m.type !== "game_invite" && m.game === "tanks" && d().restoreTanks(o, m.game_id)) return d().ingest(t, n, r);
3018
+ if ($i(m.type)) return y && !y.seen[m.event_id] && p().handleResync(v, m, g, c), !0;
3019
+ if (!y && m.type !== "game_invite" && m.game === "tanks" && p().restoreTanks(o, m.game_id)) return p().ingest(t, n, r);
3010
3020
  if (!y && m.type !== "game_invite") {
3011
3021
  let e = Date.now();
3012
3022
  for (let [t, n] of a) e - n.at > 3e4 && a.delete(t);
@@ -3017,7 +3027,7 @@ function sa() {
3017
3027
  };
3018
3028
  return t.messages.length < 8 && !t.messages.some((e) => e.eventId === m.event_id) && t.messages.push({
3019
3029
  eventId: m.event_id,
3020
- message: f
3030
+ message: d
3021
3031
  }), a.set(v, t), !0;
3022
3032
  }
3023
3033
  if (y?.seen[m.event_id]) return !0;
@@ -3035,11 +3045,11 @@ function sa() {
3035
3045
  ownId: c,
3036
3046
  hostId: g,
3037
3047
  guestId: e,
3038
- createdAt: f.timestamp ?? (/* @__PURE__ */ new Date()).toISOString(),
3048
+ createdAt: d.timestamp ?? (/* @__PURE__ */ new Date()).toISOString(),
3039
3049
  inviteEventId: m.event_id,
3040
3050
  lastEventId: m.event_id,
3041
3051
  seen: {},
3042
- sync: { ...Xi }
3052
+ sync: { ...Qi }
3043
3053
  }, m);
3044
3054
  } else y && (b = x.apply(y, m, g, c));
3045
3055
  if (!b || b === y) return !0;
@@ -3064,57 +3074,58 @@ function sa() {
3064
3074
  });
3065
3075
  });
3066
3076
  }
3067
- return { games: qi(t) };
3077
+ return { games: Yi(t) };
3068
3078
  }), b.status === "conflict" && y?.status !== "conflict" && queueMicrotask(() => {
3069
- d().requestResync(v, { auto: !0 });
3070
- }), d().afterGameChange(v), m.type === "game_invite") {
3079
+ p().requestResync(v, { auto: !0 });
3080
+ }), p().afterGameChange(v), m.type === "game_invite") {
3071
3081
  let e = a.get(v);
3072
- a.delete(v), e && Date.now() - e.at <= 3e4 && e.messages.forEach((e) => d().ingest(e.message, o, c));
3082
+ a.delete(v), e && Date.now() - e.at <= 3e4 && e.messages.forEach((e) => p().ingest(e.message, o, c));
3073
3083
  }
3074
3084
  return !0;
3075
3085
  },
3076
- invite: async ({ roomId: t, opponentId: n, gameType: r = "connect4", firstPlayerId: i, rematchOf: a, speedClass: o, mapId: s, lives: l, seed: u }) => {
3086
+ invite: async ({ roomId: t, opponentId: n, gameType: r = "connect4", firstPlayerId: i, rematchOf: a, speedClass: o, trackId: s, mapId: l, lives: u, seed: d }) => {
3077
3087
  if (!e) throw Error("Chat no disponible");
3078
- if (!Vi.includes(r)) throw Error("Juego no disponible");
3088
+ if (!Ui.includes(r)) throw Error("Juego no disponible");
3079
3089
  let f = e.getScope();
3080
3090
  if (!String(e.getUserId() ?? "") || !String(t).startsWith("private_")) throw Error("Abre un chat privado para jugar.");
3081
- if (Object.values(d().games).some((e) => e.scope === f && e.roomId === String(t) && (!$(e) || e.pendingEvent))) throw Error("Cierra la partida actual antes de invitar.");
3082
- let m = p(), h = r === "racing_live" ? it({
3091
+ if (Object.values(p().games).some((e) => e.scope === f && e.roomId === String(t) && (!$(e) || e.pendingEvent))) throw Error("Cierra la partida actual antes de invitar.");
3092
+ let m = h(), g = r === "racing_live" ? ot({
3083
3093
  opponentId: String(n),
3084
3094
  seed: parseInt(m.slice(0, 8), 16),
3085
3095
  rematchOf: a,
3086
- ...o === void 0 ? {} : { speedClass: o }
3087
- }) : r === "tanks_live" ? Je({
3096
+ ...o === void 0 ? {} : { speedClass: o },
3097
+ ...s === void 0 ? {} : { trackId: s }
3098
+ }) : r === "tanks_live" ? Xe({
3088
3099
  opponentId: String(n),
3089
3100
  rematchOf: a,
3090
- ...s === void 0 ? {} : { mapId: s },
3091
- ...l === void 0 ? {} : { lives: l },
3092
- ...u === void 0 ? {} : { seed: u }
3101
+ ...l === void 0 ? {} : { mapId: l },
3102
+ ...u === void 0 ? {} : { lives: u },
3103
+ ...d === void 0 ? {} : { seed: d }
3093
3104
  }) : {
3094
3105
  opponent_id: String(n),
3095
3106
  rules_version: 1
3096
3107
  };
3097
3108
  if (r === "tanks") {
3098
- let e = fi();
3099
- c.set(`${f}:${m}`, e), Ri(f, m, { seedA: e }), h.seed_commit = pi(e), i != null && (h.first_player_id = String(i)), a && (h.rematch_of = a);
3109
+ let e = mi();
3110
+ c.set(`${f}:${m}`, e), Bi(f, m, { seedA: e }), g.seed_commit = hi(e), i != null && (g.first_player_id = String(i)), a && (g.rematch_of = a);
3100
3111
  }
3101
- let g = F("game_invite", {
3112
+ let _ = F("game_invite", {
3102
3113
  game_id: m,
3103
- data: h,
3114
+ data: g,
3104
3115
  game: r
3105
3116
  });
3106
- return d().sendEvent(t, g);
3117
+ return p().sendEvent(t, _);
3107
3118
  },
3108
3119
  act: async (t, n, r = {}) => {
3109
- let i = d().games[t], a = String(e?.getUserId?.() ?? "");
3120
+ let i = p().games[t], a = String(e?.getUserId?.() ?? "");
3110
3121
  if (!i || i.scope !== e?.getScope?.()) throw Error("Partida no disponible");
3111
3122
  if (n !== "game_end" && (i.pending || i.pendingEvent)) throw Error("Reintenta el envío pendiente antes de continuar.");
3112
3123
  let o = r;
3113
3124
  if (n === "game_accept" || n === "game_decline") {
3114
3125
  if (i.status !== "invited" || a !== i.guestId) return;
3115
- o = { invite_event_id: i.inviteEventId }, n === "game_accept" && Ui(i) && (o.seed_b = fi()), n === "game_accept" && i.game === "racing_live" && (o.track_hash = i.raceConfig.trackHash), n === "game_accept" && i.game === "tanks_live" && i.liveConfig && (o.map_hash = i.liveConfig.mapHash);
3126
+ o = { invite_event_id: i.inviteEventId }, n === "game_accept" && Gi(i) && (o.seed_b = mi()), n === "game_accept" && i.game === "racing_live" && (o.track_hash = i.raceConfig.trackHash), n === "game_accept" && i.game === "tanks_live" && i.liveConfig && (o.map_hash = i.liveConfig.mapHash);
3116
3127
  } else if (n === "game_move") {
3117
- if (Q(i) !== "connect4" || i.status !== "active" || a !== i.turnId || !Jt(i.board, r.column, a)) return;
3128
+ if (Q(i) !== "connect4" || i.status !== "active" || a !== i.turnId || !Xt(i.board, r.column, a)) return;
3118
3129
  o = {
3119
3130
  column: r.column,
3120
3131
  ply: i.ply + 1,
@@ -3122,51 +3133,51 @@ function sa() {
3122
3133
  };
3123
3134
  } else if (n === "game_end") o = { reason: "closed" };
3124
3135
  else return;
3125
- return d().sendEvent(i.roomId, F(n, {
3136
+ return p().sendEvent(i.roomId, F(n, {
3126
3137
  game_id: i.gameId,
3127
3138
  data: o,
3128
3139
  game: Q(i)
3129
3140
  }));
3130
3141
  },
3131
3142
  bsUpdateLocal: (e, t) => {
3132
- let n = d().games[e];
3133
- if (!Hi(n)) return !1;
3143
+ let n = p().games[e];
3144
+ if (!Wi(n)) return !1;
3134
3145
  let r = t(n);
3135
3146
  return r !== n && (s((t) => t.games[e] === n ? { games: {
3136
3147
  ...t.games,
3137
3148
  [e]: r
3138
- } } : t), d().games[e] === r);
3149
+ } } : t), p().games[e] === r);
3139
3150
  },
3140
- bsPlaceShip: (e, t) => d().bsUpdateLocal(e, (e) => En(e, t)),
3141
- bsRemoveShip: (e, t) => d().bsUpdateLocal(e, (e) => Dn(e, t)),
3142
- bsRandomFleet: (e) => d().bsUpdateLocal(e, (e) => An(e)),
3151
+ bsPlaceShip: (e, t) => p().bsUpdateLocal(e, (e) => On(e, t)),
3152
+ bsRemoveShip: (e, t) => p().bsUpdateLocal(e, (e) => kn(e, t)),
3153
+ bsRandomFleet: (e) => p().bsUpdateLocal(e, (e) => Mn(e)),
3143
3154
  bsReady: async (n) => {
3144
- let r = d().games[n];
3145
- if (!Hi(r) || r.status !== "placement" || r.myReady) return;
3155
+ let r = p().games[n];
3156
+ if (!Wi(r) || r.status !== "placement" || r.myReady) return;
3146
3157
  if (r.scope !== e?.getScope?.()) throw Error("Partida no disponible");
3147
3158
  if (r.pending || r.pendingEvent) throw Error("Reintenta el envío pendiente antes de continuar.");
3148
- let i = Sn(r.myFleet);
3149
- if (!wn(i)) throw Error("Coloca los cinco barcos antes de continuar.");
3150
- let a = Mn(), o = await Pn(i, a), s = d().games[n];
3151
- if (!(!s || s.myReady || s.status !== "placement" || s.pending || s.pendingEvent || JSON.stringify(Sn(s.myFleet)) !== JSON.stringify(i))) return t.set(`${r.scope}:${r.gameId}`, {
3159
+ let i = wn(r.myFleet);
3160
+ if (!En(i)) throw Error("Coloca los cinco barcos antes de continuar.");
3161
+ let a = Pn(), o = await In(i, a), s = p().games[n];
3162
+ if (!(!s || s.myReady || s.status !== "placement" || s.pending || s.pendingEvent || JSON.stringify(wn(s.myFleet)) !== JSON.stringify(i))) return t.set(`${r.scope}:${r.gameId}`, {
3152
3163
  fleet: i,
3153
3164
  salt: a,
3154
3165
  commitment: o
3155
- }), sr(r.scope, r.gameId, {
3166
+ }), lr(r.scope, r.gameId, {
3156
3167
  fleet: i,
3157
3168
  salt: a,
3158
3169
  commitment: o
3159
- }), d().sendEvent(r.roomId, F("bs_commit", {
3170
+ }), p().sendEvent(r.roomId, F("bs_commit", {
3160
3171
  game_id: r.gameId,
3161
3172
  data: { commitment: o },
3162
3173
  game: "battleship"
3163
3174
  }));
3164
3175
  },
3165
3176
  bsFire: async (t, { row: n, col: r } = {}) => {
3166
- let i = d().games[t];
3167
- if (!Hi(i) || i.scope !== e?.getScope?.()) throw Error("Partida no disponible");
3177
+ let i = p().games[t];
3178
+ if (!Wi(i) || i.scope !== e?.getScope?.()) throw Error("Partida no disponible");
3168
3179
  if (i.pending || i.pendingEvent) throw Error("Reintenta el envío pendiente antes de continuar.");
3169
- if (_n(i) && i.targetShots[n]?.[r] === null) return d().sendEvent(i.roomId, F("bs_fire", {
3180
+ if (yn(i) && i.targetShots[n]?.[r] === null) return p().sendEvent(i.roomId, F("bs_fire", {
3170
3181
  game_id: i.gameId,
3171
3182
  data: {
3172
3183
  ply: i.ply + 1,
@@ -3179,15 +3190,15 @@ function sa() {
3179
3190
  },
3180
3191
  bsScheduleEffects: (e) => {
3181
3192
  r.has(e) || r.set(e, setTimeout(() => {
3182
- r.delete(e), d().bsRunEffects(e);
3183
- }, Gi));
3193
+ r.delete(e), p().bsRunEffects(e);
3194
+ }, qi));
3184
3195
  },
3185
3196
  bsRunEffects: (t) => {
3186
- let r = d().games[t];
3187
- if (!Hi(r) || !e || r.scope !== e.getScope?.()) return;
3197
+ let r = p().games[t];
3198
+ if (!Wi(r) || !e || r.scope !== e.getScope?.()) return;
3188
3199
  if (r.opponentReveal && r.verification === "pending" && !i.has(t)) {
3189
3200
  let e = r.opponentReveal;
3190
- i.add(t), qn(r, e).then((n) => s((r) => {
3201
+ i.add(t), Yn(r, e).then((n) => s((r) => {
3191
3202
  let i = r.games[t];
3192
3203
  return !i || i.opponentReveal !== e || i.verification === n ? r : { games: {
3193
3204
  ...r.games,
@@ -3202,14 +3213,14 @@ function sa() {
3202
3213
  }
3203
3214
  if (r.pending || r.pendingEvent) return;
3204
3215
  let a = (e, t) => {
3205
- d().sendEvent(r.roomId, F(e, {
3216
+ p().sendEvent(r.roomId, F(e, {
3206
3217
  game_id: r.gameId,
3207
3218
  data: t,
3208
3219
  game: "battleship"
3209
3220
  })).catch(() => {});
3210
3221
  };
3211
3222
  if (r.status === "active" && r.pendingShot && r.pendingShot.by !== r.ownId) {
3212
- let e = Fn(Tn(r), r.pendingShot);
3223
+ let e = Ln(Dn(r), r.pendingShot);
3213
3224
  e ? a("bs_result", e) : r.error || s((e) => ({ games: {
3214
3225
  ...e.games,
3215
3226
  [t]: {
@@ -3221,31 +3232,31 @@ function sa() {
3221
3232
  }
3222
3233
  let o = String(r.winnerId) !== String(r.ownId) || !!r.opponentReveal;
3223
3234
  if (r.winnerId && ["won", "closed"].includes(r.status) && !r.myRevealSent && o) {
3224
- let e = Sn(r.myFleet), t = r.mySalt ?? n(r.scope, r.gameId)?.salt;
3225
- wn(e) && t && a("bs_reveal", {
3235
+ let e = wn(r.myFleet), t = r.mySalt ?? n(r.scope, r.gameId)?.salt;
3236
+ En(e) && t && a("bs_reveal", {
3226
3237
  fleet: e,
3227
3238
  salt: t
3228
3239
  });
3229
3240
  }
3230
3241
  },
3231
3242
  afterGameChange: (e) => {
3232
- let t = d().games[e];
3233
- f(t)?.after?.(e, d);
3243
+ let t = p().games[e];
3244
+ d(t)?.after?.(e, p);
3234
3245
  },
3235
3246
  tkTurn: async (t, n) => {
3236
- let r = d().games[t];
3237
- if (!Ui(r) || r.scope !== e?.getScope?.()) throw Error("Partida no disponible");
3247
+ let r = p().games[t];
3248
+ if (!Gi(r) || r.scope !== e?.getScope?.()) throw Error("Partida no disponible");
3238
3249
  if (r.pending || r.pendingEvent) throw Error("Reintenta el envío pendiente antes de continuar.");
3239
- let i = wi(r, n);
3240
- if (i) return d().sendEvent(r.roomId, F("tk_turn", {
3250
+ let i = Ei(r, n);
3251
+ if (i) return p().sendEvent(r.roomId, F("tk_turn", {
3241
3252
  game_id: r.gameId,
3242
3253
  data: i,
3243
3254
  game: "tanks"
3244
3255
  }));
3245
3256
  },
3246
3257
  tkSkip: async (t) => {
3247
- let n = d().games[t];
3248
- if (Ui(n) && _i(n) && n.scope === e?.getScope?.()) return d().sendEvent(n.roomId, F("tk_skip", {
3258
+ let n = p().games[t];
3259
+ if (Gi(n) && yi(n) && n.scope === e?.getScope?.()) return p().sendEvent(n.roomId, F("tk_skip", {
3249
3260
  game_id: n.gameId,
3250
3261
  data: {
3251
3262
  ply: n.ply + 1,
@@ -3255,8 +3266,8 @@ function sa() {
3255
3266
  }));
3256
3267
  },
3257
3268
  tkResign: async (t) => {
3258
- let n = d().games[t];
3259
- if (!(!Ui(n) || n.status !== "active" || n.pending || n.pendingEvent || n.scope !== e?.getScope?.())) return d().sendEvent(n.roomId, F("tk_resign", {
3269
+ let n = p().games[t];
3270
+ if (!(!Gi(n) || n.status !== "active" || n.pending || n.pendingEvent || n.scope !== e?.getScope?.())) return p().sendEvent(n.roomId, F("tk_resign", {
3260
3271
  game_id: n.gameId,
3261
3272
  data: {
3262
3273
  ply: n.ply + 1,
@@ -3267,14 +3278,14 @@ function sa() {
3267
3278
  },
3268
3279
  tkScheduleEffects: (e) => {
3269
3280
  r.has(e) || r.set(e, setTimeout(() => {
3270
- r.delete(e), d().tkRunEffects(e);
3271
- }, Gi));
3281
+ r.delete(e), p().tkRunEffects(e);
3282
+ }, qi));
3272
3283
  },
3273
3284
  tkRunEffects: (t) => {
3274
- let n = d().games[t];
3275
- if (!Ui(n) || (Ri(n.scope, n.gameId, { snapshot: Ai(n) }), !e || n.scope !== e.getScope?.() || n.pending || n.pendingEvent) || n.status !== "seeding" || n.ownId !== n.hostId) return;
3285
+ let n = p().games[t];
3286
+ if (!Gi(n) || (Bi(n.scope, n.gameId, { snapshot: Mi(n) }), !e || n.scope !== e.getScope?.() || n.pending || n.pendingEvent) || n.status !== "seeding" || n.ownId !== n.hostId) return;
3276
3287
  let r = l(n.scope, n.gameId);
3277
- r ? d().sendEvent(n.roomId, F("tk_seed", {
3288
+ r ? p().sendEvent(n.roomId, F("tk_seed", {
3278
3289
  game_id: n.gameId,
3279
3290
  data: { seed_a: r },
3280
3291
  game: "tanks"
@@ -3288,16 +3299,16 @@ function sa() {
3288
3299
  },
3289
3300
  restoreTanks: (e, t) => {
3290
3301
  let n = !1;
3291
- return Bi(e).forEach(({ snapshot: r }) => {
3302
+ return Hi(e).forEach(({ snapshot: r }) => {
3292
3303
  if (!r || t && r.gameId !== t || [
3293
3304
  "closed",
3294
3305
  "declined",
3295
3306
  "won",
3296
3307
  "draw"
3297
3308
  ].includes(r.status)) return;
3298
- let i = Ki(e, r.roomId, r.gameId);
3299
- if (d().games[i]) return;
3300
- let a = Di(hi({
3309
+ let i = Ji(e, r.roomId, r.gameId);
3310
+ if (p().games[i]) return;
3311
+ let a = ki(_i({
3301
3312
  key: i,
3302
3313
  gameId: r.gameId,
3303
3314
  game_id: r.gameId,
@@ -3310,7 +3321,7 @@ function sa() {
3310
3321
  inviteEventId: r.inviteEventId,
3311
3322
  lastEventId: r.inviteEventId,
3312
3323
  seen: {},
3313
- sync: { ...Xi }
3324
+ sync: { ...Qi }
3314
3325
  }, {
3315
3326
  seed_commit: r.seedCommit,
3316
3327
  first_player_id: r.firstPlayerId,
@@ -3320,32 +3331,32 @@ function sa() {
3320
3331
  n = !0;
3321
3332
  let o = {
3322
3333
  ...a,
3323
- seen: ki({ [r.inviteEventId]: !0 }, a),
3334
+ seen: ji({ [r.inviteEventId]: !0 }, a),
3324
3335
  status: "conflict",
3325
3336
  error: "Partida recuperada en este dispositivo. Sincronizando con el rival…"
3326
3337
  };
3327
- s((e) => ({ games: qi({
3338
+ s((e) => ({ games: Yi({
3328
3339
  ...e.games,
3329
3340
  [i]: o
3330
3341
  }) })), queueMicrotask(() => {
3331
- d().requestResync(i, { auto: !0 });
3342
+ p().requestResync(i, { auto: !0 });
3332
3343
  });
3333
3344
  }), n;
3334
3345
  },
3335
3346
  createLiveSignaling: (t) => {
3336
- let n = d().games[t];
3347
+ let n = p().games[t];
3337
3348
  if (!["tanks_live", "racing_live"].includes(n?.game) || n.scope !== e?.getScope?.()) throw Error("Partida no disponible");
3338
3349
  let r = e;
3339
- return lt({
3350
+ return dt({
3340
3351
  roomId: n.roomId,
3341
3352
  send: (n, i) => {
3342
- if (e !== r || d().games[t]?.scope !== r.getScope()) throw Error("La sesión cambió");
3353
+ if (e !== r || p().games[t]?.scope !== r.getScope()) throw Error("La sesión cambió");
3343
3354
  return r.send(n, i);
3344
3355
  }
3345
3356
  });
3346
3357
  },
3347
3358
  liveFinish: (t, n) => {
3348
- let r = d().games[t];
3359
+ let r = p().games[t];
3349
3360
  r?.game === "tanks_live" && r.scope === e?.getScope?.() && r.status === "active" && [r.hostId, r.guestId].includes(String(n)) && s((e) => ({ games: {
3350
3361
  ...e.games,
3351
3362
  [t]: {
@@ -3356,7 +3367,7 @@ function sa() {
3356
3367
  } }));
3357
3368
  },
3358
3369
  liveRematch: (t, { newMap: n = !1, mapId: r, lives: i } = {}) => {
3359
- let a = d().games[t];
3370
+ let a = p().games[t];
3360
3371
  if (a?.game !== "tanks_live" || a.scope !== e?.getScope?.() || !$(a)) return;
3361
3372
  let o = a.liveConfig, s = n ? {
3362
3373
  mapId: r ?? "random",
@@ -3372,7 +3383,7 @@ function sa() {
3372
3383
  mapId: r,
3373
3384
  lives: i ?? o?.lives
3374
3385
  };
3375
- return s.lives === void 0 && delete s.lives, d().invite({
3386
+ return s.lives === void 0 && delete s.lives, p().invite({
3376
3387
  roomId: a.roomId,
3377
3388
  opponentId: a.ownId === a.hostId ? a.guestId : a.hostId,
3378
3389
  gameType: "tanks_live",
@@ -3382,12 +3393,12 @@ function sa() {
3382
3393
  },
3383
3394
  sendEvent: async (t, n) => {
3384
3395
  if (!e) throw Error("Chat no disponible");
3385
- let r = e, i = r.getScope(), a = String(r.getUserId() ?? ""), o = Ki(i, t, n.game_id), c = Ht(n);
3386
- if (d().ingest({
3396
+ let r = e, i = r.getScope(), a = String(r.getUserId() ?? ""), o = Ji(i, t, n.game_id), c = Wt(n);
3397
+ if (p().ingest({
3387
3398
  room_id: t,
3388
3399
  user_id: a,
3389
3400
  message: c
3390
- }, i, a), !d().games[o]?.seen[n.event_id]) throw Error("Evento de partida inválido");
3401
+ }, i, a), !p().games[o]?.seen[n.event_id]) throw Error("Evento de partida inválido");
3391
3402
  let l = (e, t = !0) => s((r) => {
3392
3403
  let i = r.games[o];
3393
3404
  return !i || t && i.pendingEvent?.event_id !== n.event_id ? r : { games: {
@@ -3407,7 +3418,7 @@ function sa() {
3407
3418
  await r.send(t, c), l({
3408
3419
  pending: !1,
3409
3420
  pendingEvent: null
3410
- }), d().afterGameChange(o);
3421
+ }), p().afterGameChange(o);
3411
3422
  } catch (e) {
3412
3423
  throw l({
3413
3424
  pending: !1,
@@ -3417,14 +3428,14 @@ function sa() {
3417
3428
  return o;
3418
3429
  },
3419
3430
  handleResync: (e, t, n, r) => {
3420
- let i = d().games[e], a = m(i), o = {
3431
+ let i = p().games[e], a = f(i), o = {
3421
3432
  ...i.seen,
3422
3433
  [t.event_id]: !0
3423
3434
  }, c = (t) => {
3424
3435
  s((n) => ({ games: {
3425
3436
  ...n.games,
3426
3437
  [e]: t
3427
- } })), d().afterGameChange(e);
3438
+ } })), p().afterGameChange(e);
3428
3439
  };
3429
3440
  if (n === r || ![i.hostId, i.guestId].includes(n) || ["closed", "declined"].includes(i.status)) {
3430
3441
  c({
@@ -3434,7 +3445,7 @@ function sa() {
3434
3445
  return;
3435
3446
  }
3436
3447
  let l = {
3437
- ...Xi,
3448
+ ...Qi,
3438
3449
  ...i.sync
3439
3450
  };
3440
3451
  if (![a.requestType, a.stateType].includes(t.type)) {
@@ -3452,8 +3463,8 @@ function sa() {
3452
3463
  });
3453
3464
  return;
3454
3465
  }
3455
- let f = a.rebuild(i, t.data);
3456
- if (!f) {
3466
+ let d = a.rebuild(i, t.data);
3467
+ if (!d) {
3457
3468
  c({
3458
3469
  ...i,
3459
3470
  seen: o,
@@ -3465,15 +3476,15 @@ function sa() {
3465
3476
  });
3466
3477
  return;
3467
3478
  }
3468
- let p = a.compare(i, t.data), h = {
3479
+ let m = a.compare(i, t.data), h = {
3469
3480
  ...l,
3470
3481
  status: "ok",
3471
3482
  offer: null,
3472
3483
  auto: !1,
3473
3484
  message: ""
3474
- }, g, _ = !u, v = !1, y = p === "mixed" ? a.merge(i, t.data) : null;
3475
- if (p === "equal" || p === "behind") g = {
3476
- ...f,
3485
+ }, g, _ = !u, v = !1, y = m === "mixed" ? a.merge(i, t.data) : null;
3486
+ if (m === "equal" || m === "behind") g = {
3487
+ ...d,
3477
3488
  sync: h
3478
3489
  }, a.covers(i, t.data) && (g = {
3479
3490
  ...g,
@@ -3492,7 +3503,7 @@ function sa() {
3492
3503
  message: "No se pudo reconstruir la partida local."
3493
3504
  }
3494
3505
  }, _ = !!e, v = !!e;
3495
- } else if (p === "ahead" || n === i.guestId) {
3506
+ } else if (m === "ahead" || n === i.guestId) {
3496
3507
  let e = a.rebuild(i, a.historyOf(i));
3497
3508
  g = e ? {
3498
3509
  ...e,
@@ -3522,7 +3533,7 @@ function sa() {
3522
3533
  };
3523
3534
  let b = Date.now(), x = g.sync.replies.filter((e) => b - e < 3e4), S = null;
3524
3535
  if (_ && x.length < 6) try {
3525
- S = oa(i, a.stateType, {
3536
+ S = ca(i, a.stateType, {
3526
3537
  ...a.historyOf(g),
3527
3538
  request_event_id: t.event_id
3528
3539
  });
@@ -3540,10 +3551,10 @@ function sa() {
3540
3551
  replies: [...x, b],
3541
3552
  outgoing: [...g.sync.outgoing, S.event_id].slice(-8)
3542
3553
  }
3543
- }), c(g), S && d().sendResync(e, S).then(() => {
3554
+ }), c(g), S && p().sendResync(e, S).then(() => {
3544
3555
  v && (s((t) => {
3545
3556
  let n = t.games[e];
3546
- return !n || !m(n).covers(n, m(n).historyOf(n)) ? t : { games: {
3557
+ return !n || !f(n).covers(n, f(n).historyOf(n)) ? t : { games: {
3547
3558
  ...t.games,
3548
3559
  [e]: {
3549
3560
  ...n,
@@ -3551,25 +3562,25 @@ function sa() {
3551
3562
  error: ""
3552
3563
  }
3553
3564
  } };
3554
- }), d().afterGameChange(e));
3565
+ }), p().afterGameChange(e));
3555
3566
  }).catch(() => {});
3556
3567
  },
3557
3568
  sendResync: async (t, n) => {
3558
- let r = d().games[t];
3569
+ let r = p().games[t];
3559
3570
  if (!e || !r || r.scope !== e.getScope?.()) throw Error("Chat no disponible");
3560
- await e.send(r.roomId, Ht(n));
3571
+ await e.send(r.roomId, Wt(n));
3561
3572
  },
3562
3573
  requestResync: async (t, { auto: n = !1 } = {}) => {
3563
- let r = d().games[t];
3564
- if (!r || Wi(r) || !e || ["closed", "declined"].includes(r.status) || r.scope !== e.getScope?.()) return;
3574
+ let r = p().games[t];
3575
+ if (!r || Ki(r) || !e || ["closed", "declined"].includes(r.status) || r.scope !== e.getScope?.()) return;
3565
3576
  let i = {
3566
- ...Xi,
3577
+ ...Qi,
3567
3578
  ...r.sync
3568
3579
  };
3569
- if (i.status === "requesting" && Date.now() - i.requestedAt < Yi || n && i.auto) return;
3580
+ if (i.status === "requesting" && Date.now() - i.requestedAt < Zi || n && i.auto) return;
3570
3581
  let a;
3571
3582
  try {
3572
- a = oa(r, m(r).requestType, m(r).historyOf(r));
3583
+ a = ca(r, f(r).requestType, f(r).historyOf(r));
3573
3584
  } catch {
3574
3585
  return;
3575
3586
  }
@@ -3611,18 +3622,18 @@ function sa() {
3611
3622
  });
3612
3623
  let l = setTimeout(() => {
3613
3624
  o.delete(l), c("El rival no respondió a la sincronización. Reintenta cuando esté conectado.");
3614
- }, Yi);
3625
+ }, Zi);
3615
3626
  o.add(l);
3616
3627
  try {
3617
- await d().sendResync(t, a);
3628
+ await p().sendResync(t, a);
3618
3629
  } catch (e) {
3619
3630
  c(e.message || "No se pudo enviar la solicitud de sincronización.");
3620
3631
  }
3621
3632
  },
3622
3633
  adoptResyncOffer: (e) => {
3623
- let t = d().games[e], n = t?.sync?.offer;
3634
+ let t = p().games[e], n = t?.sync?.offer;
3624
3635
  if (!n || t.sync.status !== "incompatible") return !1;
3625
- let r = m(t), i = r.rebuild(t, n);
3636
+ let r = f(t), i = r.rebuild(t, n);
3626
3637
  return s((n) => ({ games: {
3627
3638
  ...n.games,
3628
3639
  [e]: i ? {
@@ -3646,36 +3657,36 @@ function sa() {
3646
3657
  message: "El estado del anfitrión ya no es válido."
3647
3658
  }
3648
3659
  }
3649
- } })), i && d().afterGameChange(e), !!i;
3660
+ } })), i && p().afterGameChange(e), !!i;
3650
3661
  },
3651
3662
  resyncConflicts: (e) => {
3652
- d().restoreTanks(e), Object.values(d().games).filter((t) => t.scope === e && t.status === "conflict").forEach((e) => {
3653
- d().requestResync(e.key, { auto: !0 });
3663
+ p().restoreTanks(e), Object.values(p().games).filter((t) => t.scope === e && t.status === "conflict").forEach((e) => {
3664
+ p().requestResync(e.key, { auto: !0 });
3654
3665
  });
3655
3666
  },
3656
3667
  retry: (t) => {
3657
- let n = d().games[t];
3658
- return !n?.pendingEvent || n.pending ? Promise.resolve() : n.scope === e?.getScope?.() ? d().sendEvent(n.roomId, n.pendingEvent) : Promise.reject(/* @__PURE__ */ Error("La sesión de esta partida ya no está activa."));
3668
+ let n = p().games[t];
3669
+ return !n?.pendingEvent || n.pending ? Promise.resolve() : n.scope === e?.getScope?.() ? p().sendEvent(n.roomId, n.pendingEvent) : Promise.reject(/* @__PURE__ */ Error("La sesión de esta partida ya no está activa."));
3659
3670
  }
3660
3671
  }));
3661
3672
  }
3662
- var ca = sa(), la = (e) => f(ca, e);
3663
- Object.assign(la, {
3664
- getState: ca.getState,
3665
- setState: ca.setState,
3666
- subscribe: ca.subscribe
3673
+ var ua = la(), da = (e) => m(ua, e);
3674
+ Object.assign(da, {
3675
+ getState: ua.getState,
3676
+ setState: ua.setState,
3677
+ subscribe: ua.subscribe
3667
3678
  });
3668
3679
  // src/assets/chatAssets.js
3669
- var ua = "/sounds", da = ua, fa = (e) => String(e).replace(/\/+$/, "");
3670
- function pa(e) {
3671
- da = e == null ? ua : fa(e);
3680
+ var fa = "/sounds", pa = fa, ma = (e) => String(e).replace(/\/+$/, "");
3681
+ function ha(e) {
3682
+ pa = e == null ? fa : ma(e);
3672
3683
  }
3673
- function ma() {
3674
- return da;
3684
+ function ga() {
3685
+ return pa;
3675
3686
  }
3676
- function ha(e) {
3677
- return `${da}/${String(e).replace(/^\/+/, "")}`;
3687
+ function _a(e) {
3688
+ return `${pa}/${String(e).replace(/^\/+/, "")}`;
3678
3689
  }
3679
- export { oe as C, te as D, b as E, ee as O, v as S, le as T, ct as _, la as a, ae as b, zr as c, V as d, lr as f, lt as g, It as h, ca as i, p as k, Er as l, St as m, ma as n, _i as o, R as p, pa as r, Lr as s, ha as t, H as u, Fe as v, ce as w, _ as x, m as y };
3690
+ export { ce as C, re as D, S as E, ne as O, b as S, de as T, ut as _, da as a, se as b, Vr as c, V as d, dr as f, dt as g, Rt as h, ua as i, h as k, Or as l, wt as m, ga as n, yi as o, R as p, ha as r, zr as s, _a as t, H as u, Le as v, ue as w, y as x, g as y };
3680
3691
 
3681
- //# sourceMappingURL=games-Bl_8raG6.js.map
3692
+ //# sourceMappingURL=games-D_9SiSBT.js.map