@minicode-dev/chat 0.1.7 → 0.1.9

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 (37) hide show
  1. package/README.md +25 -0
  2. package/dist/chunks/{BattleshipGameCard-CAWHxqJE.js → BattleshipGameCard-BFqA0cjT.js} +247 -246
  3. package/dist/chunks/{BattleshipGameCard-CAWHxqJE.js.map → BattleshipGameCard-BFqA0cjT.js.map} +1 -1
  4. package/dist/chunks/{ChatContext-CUiEAMKK.js → ChatContext-dty_KPDX.js} +2 -2
  5. package/dist/chunks/{ChatContext-CUiEAMKK.js.map → ChatContext-dty_KPDX.js.map} +1 -1
  6. package/dist/chunks/TanksGameCard-D0n-lzTs.js +1535 -0
  7. package/dist/chunks/TanksGameCard-D0n-lzTs.js.map +1 -0
  8. package/dist/chunks/TanksLiveGameCard-BmNRXP66.js +849 -0
  9. package/dist/chunks/TanksLiveGameCard-BmNRXP66.js.map +1 -0
  10. package/dist/chunks/WebRtcLab-B7xBlJy1.js +510 -0
  11. package/dist/chunks/WebRtcLab-B7xBlJy1.js.map +1 -0
  12. package/dist/chunks/{connect4Sounds-BDXQAvU1.js → connect4Sounds-BN7d_TM2.js} +654 -618
  13. package/dist/chunks/connect4Sounds-BN7d_TM2.js.map +1 -0
  14. package/dist/chunks/createLiveScene-CtYPcOPo.js +364 -0
  15. package/dist/chunks/createLiveScene-CtYPcOPo.js.map +1 -0
  16. package/dist/chunks/createPeerLink-qei05vpV.js +478 -0
  17. package/dist/chunks/createPeerLink-qei05vpV.js.map +1 -0
  18. package/dist/chunks/createTankScene-CV7Brxmt.js +685 -0
  19. package/dist/chunks/createTankScene-CV7Brxmt.js.map +1 -0
  20. package/dist/chunks/fx-BHsl4S_J.js +1470 -0
  21. package/dist/chunks/fx-BHsl4S_J.js.map +1 -0
  22. package/dist/chunks/gameStatus-Cu1Z8un9.js +69 -0
  23. package/dist/chunks/gameStatus-Cu1Z8un9.js.map +1 -0
  24. package/dist/chunks/signalFaults-Dv2YjjKy.js +36 -0
  25. package/dist/chunks/signalFaults-Dv2YjjKy.js.map +1 -0
  26. package/dist/chunks/tanksSounds-C99OD2xD.js +177 -0
  27. package/dist/chunks/tanksSounds-C99OD2xD.js.map +1 -0
  28. package/dist/index.js +1956 -1857
  29. package/dist/index.js.map +1 -1
  30. package/dist/styles.css +1 -1
  31. package/index.d.ts +61 -0
  32. package/package.json +1 -1
  33. package/dist/chunks/TanksGameCard-BEnXTz_J.js +0 -1705
  34. package/dist/chunks/TanksGameCard-BEnXTz_J.js.map +0 -1
  35. package/dist/chunks/connect4Sounds-BDXQAvU1.js.map +0 -1
  36. package/dist/chunks/createTankScene-BuliAxwR.js +0 -2150
  37. package/dist/chunks/createTankScene-BuliAxwR.js.map +0 -1
@@ -1,1705 +0,0 @@
1
- import { A as e, C as t, D as n, E as r, O as i, T as a, a as o, h as s, j as c, k as l, m as u, o as d, s as f, t as p, v as m, w as h, y as g } from "./connect4Sounds-BDXQAvU1.js";
2
- import { i as _, o as v, t as y } from "./ChatContext-CUiEAMKK.js";
3
- import { t as b } from "./webglSupport-2WjPEPZ_.js";
4
- import { memo as x, useCallback as S, useContext as C, useEffect as w, useRef as T, useState as E, useSyncExternalStore as D } from "react";
5
- import { ChevronDown as O, Crosshair as k, Flag as A, Layers as ee, RotateCcw as j, Swords as te, Video as ne, Wind as M, X as re } from "lucide-react";
6
- import { Fragment as ie, jsx as N, jsxs as P } from "react/jsx-runtime";
7
- // src/games/tanks/logic/selectors.js
8
- var ae = 2500;
9
- function F(e) {
10
- let t = new Float32Array(e.length);
11
- for (let n = 0; n < e.length; n += 1) t[n] = e[n] / c;
12
- return t;
13
- }
14
- function oe(e) {
15
- return {
16
- x: e.x * ae / c,
17
- z: e.z * ae / c
18
- };
19
- }
20
- function I(t) {
21
- let r = new Float32Array(t.heights.length);
22
- for (let e = 0; e < r.length; e += 1) r[e] = t.heights[e] / c;
23
- return {
24
- size: e / c,
25
- grid: 81,
26
- heights: r,
27
- obstacles: t.obstacles.map((e) => ({
28
- id: e.id,
29
- kind: e.kind,
30
- x: e.x / c,
31
- z: e.z / c,
32
- y: e.y / c,
33
- w: e.w / c,
34
- d: e.d / c,
35
- h: e.h / c
36
- })),
37
- decor: t.decor.map((e) => ({
38
- id: e.id,
39
- kind: e.kind,
40
- x: e.x / c,
41
- z: e.z / c,
42
- scale: e.scale / 100
43
- })),
44
- tanks: t.tanks.map((e) => ({
45
- id: e.id,
46
- x: e.x / c,
47
- y: e.y / c,
48
- z: e.z / c,
49
- hullYaw: e.hullYaw,
50
- yaw: e.yaw,
51
- pitch: e.pitch,
52
- hp: e.hp,
53
- fuel: e.fuel / c,
54
- ammo: { ...e.ammo },
55
- alive: e.hp > 0
56
- })),
57
- wind: oe(n(t.seed, t.ply)),
58
- turnPlayerId: t.phase === "playing" ? t.players[t.turnIndex] : null
59
- };
60
- }
61
- function se(e, t, { yaw: o, pitch: s, power: c, ammo: u, maxTicks: d = 600 } = {}) {
62
- let f = e.players.indexOf(t);
63
- return f >= 0 && [
64
- [o, l.yaw],
65
- [s, l.pitch],
66
- [c, l.power]
67
- ].every(([e, [t, n]]) => Number.isInteger(e) && e >= t && e <= n) && typeof u == "string" && Object.hasOwn(i, u) ? F(r(a(e.tanks[f], {
68
- yaw: o,
69
- pitch: s,
70
- power: c,
71
- ammo: u
72
- }), {
73
- wind: n(e.seed, e.ply),
74
- heights: e.heights,
75
- tanks: e.tanks,
76
- obstacles: e.obstacles,
77
- maxTicks: d
78
- }).samples) : /* @__PURE__ */ new Float32Array();
79
- }
80
- // src/games/tanks/view.js
81
- var ce = 20, le = Object.freeze(["green", "red"]);
82
- function ue(e) {
83
- let t = I(e.logic), n = e.logic.players;
84
- return {
85
- ...t,
86
- tanks: t.tanks.map((e) => ({
87
- ...e,
88
- color: le[n.indexOf(e.id)] ?? "green"
89
- })),
90
- activeId: t.turnPlayerId
91
- };
92
- }
93
- var L = (e) => ({
94
- x: e.x / c,
95
- y: e.y / c,
96
- z: e.z / c
97
- });
98
- function de(e, t) {
99
- let n = e.logic?.lastTurn;
100
- if (!n || n.type !== "turn") return null;
101
- let r = t?.tanks ?? [];
102
- return {
103
- tankId: n.playerId,
104
- movePath: n.movePath.map(L),
105
- yaw: n.input.yaw,
106
- pitch: n.input.pitch,
107
- ammo: n.input.ammo,
108
- shots: n.shots.map((e) => ({
109
- role: e.role,
110
- startMs: e.startTick * ce,
111
- samples: F(e.samples),
112
- impact: {
113
- ...L(e.impact),
114
- kind: e.impact.kind,
115
- tankId: e.impact.tankId
116
- },
117
- radius: e.radius / c
118
- })),
119
- craters: n.craters.map((e) => ({
120
- x: e.x / c,
121
- z: e.z / c,
122
- radius: e.radius / c,
123
- depth: e.depth / c
124
- })),
125
- damage: { ...n.damage },
126
- destroyed: e.logic.tanks.filter((e) => e.hp === 0 && (r.find((t) => t.id === e.id)?.hp ?? 1) > 0).map((e) => e.id),
127
- world: ue(e)
128
- };
129
- }
130
- function fe(e, t, n) {
131
- try {
132
- return se(e.logic, t, n);
133
- } catch {
134
- return null;
135
- }
136
- }
137
- function pe(e, t) {
138
- return (Math.round(Math.atan2(t.z - e.z, t.x - e.x) * 180 / Math.PI) % 360 + 360) % 360;
139
- }
140
- var R = 60, z = 9, me = 120, B = Math.PI / 180, V = 7, H = 4.4, he = 100, U = {
141
- green: {
142
- hull: "#4f8a3c",
143
- dark: "#2f5a24",
144
- turret: "#6aa851"
145
- },
146
- red: {
147
- hull: "#b8423a",
148
- dark: "#7a2620",
149
- turret: "#d45a4f"
150
- }
151
- }, ge = {
152
- hull: "#2b2a28",
153
- dark: "#151413",
154
- turret: "#3a3835"
155
- }, W = {
156
- low: {
157
- terrain: 2,
158
- dpr: 1,
159
- particles: .5
160
- },
161
- medium: {
162
- terrain: 3,
163
- dpr: 1.5,
164
- particles: .75
165
- },
166
- high: {
167
- terrain: 4,
168
- dpr: 2,
169
- particles: 1
170
- }
171
- }, G = [
172
- [0, [
173
- 52,
174
- 96,
175
- 48
176
- ]],
177
- [.25, [
178
- 86,
179
- 130,
180
- 58
181
- ]],
182
- [.5, [
183
- 128,
184
- 134,
185
- 72
186
- ]],
187
- [.68, [
188
- 126,
189
- 100,
190
- 68
191
- ]],
192
- [.85, [
193
- 128,
194
- 124,
195
- 118
196
- ]],
197
- [1, [
198
- 190,
199
- 188,
200
- 182
201
- ]]
202
- ], K = (e, t, n) => Math.min(n, Math.max(t, e)), q = (e, t = 0) => Number.isFinite(e) ? e : t, _e = (e) => e < .5 ? 2 * e * e : 1 - (-2 * e + 2) ** 2 / 2;
203
- function ve(e, t, n, { zoom: r = 1, cx: i, cz: a, pad: o = 8, origin: s = "corner" } = {}) {
204
- let c = Math.max(1, q(n, 160)), l = c / 2, u = s === "corner" ? l : 0, d = Math.max(1, Math.min(e, t) - o * 2) / c * Math.max(1, q(r, 1)), f = (e, t) => t >= l ? u : K(q(e, u), u - l + t, u + l - t), p = f(i, e / 2 / d), m = f(a, t / 2 / d);
205
- return {
206
- scale: d,
207
- ox: e / 2 - p * d,
208
- oy: t / 2 - m * d,
209
- size: c,
210
- minX: u - l,
211
- minZ: u - l
212
- };
213
- }
214
- function J(e, t, n) {
215
- return {
216
- x: n.ox + e * n.scale,
217
- y: n.oy + t * n.scale
218
- };
219
- }
220
- function ye(e) {
221
- return {
222
- x: Math.cos(e * B),
223
- z: Math.sin(e * B)
224
- };
225
- }
226
- function Y(e) {
227
- return e * B;
228
- }
229
- function be(e, t) {
230
- let n = ((t - e) % 360 + 540) % 360 - 180;
231
- return n === -180 ? 180 : n;
232
- }
233
- function xe(e, t, n) {
234
- return e + be(e, t) * n;
235
- }
236
- function Se(e, t, n, r) {
237
- if (!e || t < 2) return 0;
238
- let i = K(q(n), 0, t - 1), a = K(q(r), 0, t - 1), o = Math.min(t - 2, Math.floor(i)), s = Math.min(t - 2, Math.floor(a)), c = i - o, l = a - s, u = s * t + o, d = e[u] * (1 - c) + e[u + 1] * c, f = e[u + t] * (1 - c) + e[u + t + 1] * c;
239
- return q(d * (1 - l) + f * l);
240
- }
241
- function Ce(e, t = 1) {
242
- let n = K(q(e), 0, 1), r = 1;
243
- for (; r < G.length - 1 && G[r][0] < n;) r += 1;
244
- let [i, a] = G[r - 1], [o, s] = G[r], c = o > i ? (n - i) / (o - i) : 0;
245
- return a.map((e, n) => K(Math.round((e + (s[n] - e) * c) * t), 0, 255));
246
- }
247
- function we(e, t, n, { size: r = 160, contourStep: i = 3 } = {}) {
248
- let a = new Uint8ClampedArray(n * n * 4);
249
- if (!e || t < 2 || n < 2) return a;
250
- let o = Infinity, s = -Infinity;
251
- for (let n = 0; n < t * t; n += 1) {
252
- let t = q(e[n]);
253
- t < o && (o = t), t > s && (s = t);
254
- }
255
- let c = s - o, l = (t - 1) / (n - 1), u = r / (t - 1), d = [
256
- -.55,
257
- .75,
258
- -.55
259
- ], f = Math.hypot(...d), p = (n, r) => Se(e, t, n, r);
260
- for (let e = 0; e < n; e += 1) for (let t = 0; t < n; t += 1) {
261
- let r = t * l, s = e * l, m = p(r, s), h = p(r - .5, s), g = p(r + .5, s), _ = p(r, s - .5), v = p(r, s + .5), y = (g - h) / u, b = (v - _) / u, x = Math.hypot(y, 1, b), S = K(.45 + .65 * ((-y * d[0] + d[1] - b * d[2]) / (x * f)), .35, 1.2), C = (h + g + _ + v - 4 * m) / u;
262
- if (S *= 1 - K(C * .6, 0, .35), i > 0 && c > i) {
263
- let e = Math.floor(m / i);
264
- (e !== Math.floor(g / i) || e !== Math.floor(v / i)) && (S *= .88);
265
- }
266
- let [w, T, E] = Ce(c > .001 ? (m - o) / c : .3, S), D = (e * n + t) * 4;
267
- a[D] = w, a[D + 1] = T, a[D + 2] = E, a[D + 3] = 255;
268
- }
269
- return a;
270
- }
271
- function Te(e) {
272
- let t = K(q(e), 0, 1), [n, r, i] = t < .5 ? [
273
- [
274
- 90,
275
- 200,
276
- 255
277
- ],
278
- [
279
- 255,
280
- 214,
281
- 90
282
- ],
283
- t * 2
284
- ] : [
285
- [
286
- 255,
287
- 214,
288
- 90
289
- ],
290
- [
291
- 255,
292
- 90,
293
- 60
294
- ],
295
- (t - .5) * 2
296
- ], a = n.map((e, t) => Math.round(e + (r[t] - e) * i));
297
- return `rgb(${a[0]},${a[1]},${a[2]})`;
298
- }
299
- function Ee(e, t) {
300
- let n = (e || []).filter((e) => e && Number.isFinite(e.x) && Number.isFinite(e.z));
301
- if (!n.length) return null;
302
- if (n.length === 1) return {
303
- x: n[0].x,
304
- y: q(n[0].y),
305
- z: n[0].z,
306
- heading: null
307
- };
308
- let r = [0];
309
- for (let e = 1; e < n.length; e += 1) r.push(r[e - 1] + Math.hypot(n[e].x - n[e - 1].x, n[e].z - n[e - 1].z));
310
- let i = r[r.length - 1], a = K(q(t), 0, 1) * i, o = 1;
311
- for (; o < n.length - 1 && r[o] < a;) o += 1;
312
- let s = n[o - 1], c = n[o], l = r[o] - r[o - 1], u = l > 0 ? K((a - r[o - 1]) / l, 0, 1) : 1, d = l > 0 ? Math.atan2(c.z - s.z, c.x - s.x) / B : null;
313
- return {
314
- x: s.x + (c.x - s.x) * u,
315
- y: q(s.y) + (q(c.y) - q(s.y)) * u,
316
- z: s.z + (c.z - s.z) * u,
317
- heading: d
318
- };
319
- }
320
- function De(e) {
321
- let t = 0;
322
- for (let n = 1; n < (e?.length || 0); n += 1) t += Math.hypot(e[n].x - e[n - 1].x, e[n].z - e[n - 1].z);
323
- return t;
324
- }
325
- function Oe(e, t) {
326
- let n = Math.floor((e?.length || 0) / 3);
327
- if (!n) return null;
328
- let r = K(q(t), 0, n - 1), i = Math.min(n - 2, Math.floor(r));
329
- if (i < 0) return {
330
- x: e[0],
331
- y: e[1],
332
- z: e[2]
333
- };
334
- let a = r - i, o = i * 3;
335
- return {
336
- x: e[o] + (e[o + 3] - e[o]) * a,
337
- y: e[o + 1] + (e[o + 4] - e[o + 1]) * a,
338
- z: e[o + 2] + (e[o + 5] - e[o + 2]) * a
339
- };
340
- }
341
- function ke(e, t = 380) {
342
- let n = 0, r = !1;
343
- return (e || []).map((e, i) => {
344
- let a = e || {}, o = Math.floor((a.samples?.length || 0) / 3), s = Number.isFinite(a.startMs) ? Math.max(0, a.startMs) : i ? n + t : 0, c = s + Math.max(0, o - 1) * 40, l = r && s > 0;
345
- return a.impact?.kind === "split" && (r = !0), n = Math.max(n, c), {
346
- shot: a,
347
- index: i,
348
- count: o,
349
- startMs: s,
350
- endMs: c,
351
- bomblet: l
352
- };
353
- });
354
- }
355
- function Ae(e) {
356
- if (!e) return null;
357
- if (Array.isArray(e)) return e.filter((e) => e && Number.isFinite(e.x) && Number.isFinite(e.z)).map((e) => ({
358
- x: e.x,
359
- y: q(e.y),
360
- z: e.z
361
- }));
362
- if (typeof e.length == "number") {
363
- let t = [];
364
- for (let n = 0; n + 2 < e.length; n += 3) t.push({
365
- x: e[n],
366
- y: e[n + 1],
367
- z: e[n + 2]
368
- });
369
- return t;
370
- }
371
- return null;
372
- }
373
- function X(e, { reducedMotion: t = !1, onEvent: n, origin: r = "corner" } = {}) {
374
- let i = typeof document < "u" ? document : null, a = typeof window < "u" ? window : null, o = i ? i.createElement("canvas") : null, s = null;
375
- if (o) {
376
- o.className = "tanks-scene-2d", o.style.cssText = "display:block;width:100%;height:100%;touch-action:none";
377
- try {
378
- e?.appendChild(o), s = o.getContext("2d");
379
- } catch {
380
- s = null;
381
- }
382
- }
383
- let c = t ? 2 : 1, l = null, u = "high", d = "overview", f = null, p = null, m = {
384
- heights: null,
385
- grid: 0,
386
- factor: 0,
387
- canvas: null
388
- }, h = [], g = [], _ = [], v = [], y = [], b = [], x = [], S = null, C = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new Set(), T = (e) => C.get(String(e)), E = /* @__PURE__ */ new Set(), D = 0, O = 0, k = 1, A = 0, ee = 0, j = !1, te = Promise.resolve(), ne = () => !!i?.hidden, M = (e, t) => {
389
- try {
390
- n?.({
391
- type: e,
392
- ...t
393
- });
394
- } catch {}
395
- }, re = () => W[u] || W.high, ie = () => {
396
- let e = q(l?.size, 160);
397
- if (d === "overview" || !l) return ve(D, O, e, { origin: r });
398
- let t = T(l.activeId) || N(l.activeId);
399
- return ve(D, O, e, {
400
- origin: r,
401
- zoom: 2,
402
- cx: t?.x,
403
- cz: t?.z
404
- });
405
- }, N = (e) => l?.tanks?.find((t) => String(t.id) === String(e)) || null, P = (e, t) => {
406
- if (!l?.heights) return 0;
407
- let n = q(l.size, 160), i = r === "corner" ? 0 : -n / 2, a = l.grid || Math.round(Math.sqrt(l.heights.length));
408
- return Se(l.heights, a, (e - i) / n * (a - 1), (t - i) / n * (a - 1));
409
- }, ae = () => E.size > 0 || g.length || _.length || v.length || y.length || b.length || !!(S && S.left > 0), F = () => {
410
- A || j || ne() || !a?.requestAnimationFrame || (A = a.requestAnimationFrame(oe));
411
- };
412
- function oe(e) {
413
- if (A = 0, j) return;
414
- let t = ee ? K(e - ee, 0, 50) : 16;
415
- ee = e, se(t), Z(), ae() && !ne() ? F() : ee = 0;
416
- }
417
- let I = (e, t) => new Promise((n) => {
418
- j ? n() : (E.add({
419
- elapsed: 0,
420
- duration: Math.max(1, e / c),
421
- step: t,
422
- resolve: n
423
- }), F());
424
- });
425
- function se(e) {
426
- E.forEach((t) => {
427
- t.elapsed += e;
428
- let n = Math.min(1, t.elapsed / t.duration);
429
- try {
430
- t.step?.(n, e);
431
- } catch {}
432
- n >= 1 && (E.delete(t), t.resolve());
433
- });
434
- let n = e / 1e3, r = l?.wind || {};
435
- if (g = g.filter((t) => (t.life -= e, t.x += t.vx * n, t.z += t.vz * n, t.vx *= .94, t.vz *= .94, t.life > 0)), y = y.filter((t) => (t.life -= e, t.x += q(r.x) * .25 * n, t.z += q(r.z) * .25 * n, t.r += 1.2 * n, t.life > 0)), _ = _.filter((t) => (t.life -= e) > 0), v = v.filter((t) => (t.life -= e) > 0), b = b.filter((t) => (t.life -= e) > 0), S?.left > 0 && (S.left -= e, S.next -= e, S.next <= 0 && !t)) {
436
- S.next = 450;
437
- let e = T(S.id) || N(S.id);
438
- e && (_.push({
439
- x: e.x,
440
- z: e.z,
441
- r0: 3,
442
- r1: 14,
443
- life: 900,
444
- max: 900,
445
- color: "255,214,90"
446
- }), ce(e.x, e.z, 8, [
447
- "#ffd65a",
448
- "#ffffff",
449
- "#7fd36b",
450
- "#ff7a5c"
451
- ], 14));
452
- }
453
- }
454
- function ce(e, t, n, r, i = 10) {
455
- let a = Math.floor(R * re().particles) - g.length;
456
- for (let o = 0; o < Math.min(n, a); o += 1) {
457
- let n = Math.random() * Math.PI * 2, a = i * (.4 + Math.random() * .8), s = 500 + Math.random() * 600;
458
- g.push({
459
- x: e,
460
- z: t,
461
- vx: Math.cos(n) * a,
462
- vz: Math.sin(n) * a,
463
- life: s,
464
- max: s,
465
- color: r[o % r.length],
466
- size: .5 + Math.random() * .8
467
- });
468
- }
469
- }
470
- function le(e, t, n, r) {
471
- let i = Math.max(2, q(n, 4));
472
- _.push({
473
- x: e,
474
- z: t,
475
- r0: i * .2,
476
- r1: i * (r ? 1.8 : 1.2),
477
- life: 700,
478
- max: 700,
479
- color: "255,190,90"
480
- }), r && _.push({
481
- x: e,
482
- z: t,
483
- r0: i * .5,
484
- r1: i * 2.6,
485
- life: 1100,
486
- max: 1100,
487
- color: "255,120,60"
488
- }), v.push({
489
- x: e,
490
- z: t,
491
- r: i * (r ? 1.6 : 1),
492
- life: 220,
493
- max: 220
494
- }), ce(e, t, r ? 30 : 16, [
495
- "#ffd27a",
496
- "#ff8a3c",
497
- "#6b5a48",
498
- "#3b332c"
499
- ], r ? 22 : 14);
500
- for (let n = 0; n < (r ? 6 : 3); n += 1) {
501
- let n = 1200 + Math.random() * 800;
502
- y.push({
503
- x: e + (Math.random() - .5) * i,
504
- z: t + (Math.random() - .5) * i,
505
- r: i * .4,
506
- life: n,
507
- max: n
508
- });
509
- }
510
- }
511
- function ue() {
512
- let e = l?.heights;
513
- if (!e || !i) return null;
514
- let t = l.grid || Math.round(Math.sqrt(e.length)), n = re().terrain;
515
- if (m.canvas && m.heights === e && m.grid === t && m.factor === n) return m.canvas;
516
- let r = Math.min(400, (t - 1) * n + 1), a = we(e, t, r, { size: q(l.size, 160) }), o = m.canvas && m.canvas.width === r ? m.canvas : i.createElement("canvas");
517
- o.width = r, o.height = r;
518
- let s = o.getContext("2d");
519
- if (!s) return null;
520
- let c = s.createImageData(r, r);
521
- return c.data.set(a), s.putImageData(c, 0, 0), m = {
522
- heights: e,
523
- grid: t,
524
- factor: n,
525
- canvas: o
526
- }, o;
527
- }
528
- function L(e, t, n, r, i) {
529
- let a = Math.min(i, n / 2, r / 2);
530
- s.beginPath(), s.moveTo(e + a, t), s.arcTo(e + n, t, e + n, t + r, a), s.arcTo(e + n, t + r, e, t + r, a), s.arcTo(e, t + r, e, t, a), s.arcTo(e, t, e + n, t, a), s.closePath();
531
- }
532
- function de(e) {
533
- (l.obstacles || []).forEach((t) => {
534
- if (!Number.isFinite(t?.x) || !Number.isFinite(t?.z)) return;
535
- let n = Math.max(2, q(t.w, 4) * e.scale), r = Math.max(2, q(t.d, 4) * e.scale), i = J(t.x, t.z, e), a = K(q(t.h, 3) * e.scale * .25, 1, 10);
536
- s.fillStyle = "rgba(0,0,0,0.35)", L(i.x - n / 2 + a, i.y - r / 2 + a, n, r, 3), s.fill(), s.fillStyle = t.kind === "wall" ? "#8d8a82" : t.kind === "crate" ? "#8a6a3e" : "#9a958a", L(i.x - n / 2, i.y - r / 2, n, r, 3), s.fill(), s.strokeStyle = "rgba(0,0,0,0.45)", s.lineWidth = 1, s.stroke();
537
- });
538
- }
539
- function fe(e) {
540
- (l.decor || []).forEach((t) => {
541
- if (!Number.isFinite(t?.x) || !Number.isFinite(t?.z)) return;
542
- let n = J(t.x, t.z, e), r = q(t.scale, 1);
543
- if (t.kind === "tree") {
544
- let t = Math.max(2, 1.6 * r * e.scale);
545
- s.fillStyle = "rgba(0,0,0,0.3)", s.beginPath(), s.arc(n.x + t * .35, n.y + t * .35, t, 0, Math.PI * 2), s.fill(), s.fillStyle = "#2f6b2a", s.beginPath(), s.arc(n.x, n.y, t, 0, Math.PI * 2), s.fill(), s.fillStyle = "rgba(140,200,110,0.35)", s.beginPath(), s.arc(n.x - t * .3, n.y - t * .3, t * .45, 0, Math.PI * 2), s.fill();
546
- } else {
547
- let t = Math.max(1.5, .8 * r * e.scale);
548
- s.fillStyle = "#7c7a74", s.beginPath(), s.arc(n.x, n.y, t, 0, Math.PI * 2), s.fill();
549
- }
550
- });
551
- }
552
- function pe(e) {
553
- h.forEach((t) => {
554
- let n = J(t.x, t.z, e), r = Math.max(2, q(t.radius, 3) * e.scale), i = s.createRadialGradient(n.x, n.y, 0, n.x, n.y, r);
555
- i.addColorStop(0, "rgba(25,20,15,0.6)"), i.addColorStop(.7, "rgba(45,35,25,0.35)"), i.addColorStop(1, "rgba(45,35,25,0)"), s.fillStyle = i, s.beginPath(), s.arc(n.x, n.y, r, 0, Math.PI * 2), s.fill();
556
- });
557
- }
558
- function B(e) {
559
- if (!p || p.length < 2) return;
560
- let t = 1, n = p.map((e) => {
561
- let n = Math.max(0, e.y - P(e.x, e.z));
562
- return t = Math.max(t, n), n;
563
- });
564
- s.save(), s.setLineDash([5, 4]), s.lineWidth = 2, s.lineCap = "round";
565
- for (let r = 1; r < p.length; r += 1) {
566
- let i = J(p[r - 1].x, p[r - 1].z, e), a = J(p[r].x, p[r].z, e);
567
- s.strokeStyle = Te(n[r] / t), s.beginPath(), s.moveTo(i.x, i.y), s.lineTo(a.x, a.y), s.stroke();
568
- }
569
- s.setLineDash([]);
570
- let r = J(p[p.length - 1].x, p[p.length - 1].z, e);
571
- s.strokeStyle = "rgba(255,255,255,0.9)", s.lineWidth = 1.5, s.beginPath(), s.arc(r.x, r.y, 5, 0, Math.PI * 2), s.stroke(), s.beginPath(), s.moveTo(r.x - 8, r.y), s.lineTo(r.x + 8, r.y), s.moveTo(r.x, r.y - 8), s.lineTo(r.x, r.y + 8), s.stroke(), s.restore();
572
- }
573
- function G(e, t) {
574
- if (!Number.isFinite(e?.x) || !Number.isFinite(e?.z)) return;
575
- let n = T(e.id) || e, r = String(e.id) === String(l.activeId), i = w.has(String(e.id)) || e.alive === !1, a = l.tanks.indexOf(e), o = i ? ge : U[e.color] || (a === 1 ? U.red : U.green), c = r && f && !T(e.id) && Number.isFinite(f.yaw) ? f.yaw : q(n.yaw, q(n.hullYaw)), u = J(n.x, n.z, t), d = Math.max(14, V * t.scale), p = Math.max(9, H * t.scale);
576
- r && !i && (s.strokeStyle = "rgba(255,255,255,0.75)", s.setLineDash([3, 3]), s.lineWidth = 1.5, s.beginPath(), s.arc(u.x, u.y, d * .85, 0, Math.PI * 2), s.stroke(), s.setLineDash([])), S && String(S.id) === String(e.id) && (s.strokeStyle = "rgba(255,214,90,0.9)", s.lineWidth = 3, s.beginPath(), s.arc(u.x, u.y, d, 0, Math.PI * 2), s.stroke()), s.save(), s.translate(u.x, u.y), s.save(), s.rotate(Y(q(n.hullYaw))), s.fillStyle = "rgba(0,0,0,0.35)", L(-d / 2 + 2, -p / 2 + 2, d, p, 3), s.fill(), s.fillStyle = o.dark, L(-d / 2, -p / 2, d, p, 3), s.fill(), s.fillStyle = o.hull, L(-d / 2 + 1, -p / 2 + p * .2, d - 2, p * .6, 2), s.fill(), s.restore(), s.rotate(Y(c)), s.strokeStyle = o.dark, s.lineWidth = Math.max(2, p * .22), s.lineCap = "round", s.beginPath(), s.moveTo(0, 0), s.lineTo(d * .85, 0), s.stroke(), s.fillStyle = o.turret, s.beginPath(), s.arc(0, 0, p * .36, 0, Math.PI * 2), s.fill(), s.strokeStyle = "rgba(0,0,0,0.5)", s.lineWidth = 1, s.stroke(), s.restore();
577
- let m = q(e.maxHp, q(l.maxHp, he)) || he, h = K(q(e.hp, m) / m, 0, 1), g = Math.max(24, d * 1.1), _ = u.y - d * .9 - 6;
578
- s.fillStyle = "rgba(0,0,0,0.6)", s.fillRect(u.x - g / 2 - 1, _ - 1, g + 2, 6), s.fillStyle = i ? "#555" : h > .5 ? "#6bd35b" : h > .25 ? "#f2c14e" : "#f05a4f", s.fillRect(u.x - g / 2, _, g * h, 4);
579
- }
580
- function Ce(e, { samples: t, f: n }) {
581
- let r = Oe(t, n);
582
- if (!r) return;
583
- let i = Math.max(0, Math.floor(n) - 18);
584
- s.lineCap = "round";
585
- let a = null;
586
- for (let r = i; r <= Math.floor(n); r += 1) {
587
- let n = Oe(t, r), o = J(n.x, n.z, e);
588
- a && (s.strokeStyle = `rgba(255,240,200,${(r - i) / 19 * .7})`, s.lineWidth = 1.5, s.beginPath(), s.moveTo(a.x, a.y), s.lineTo(o.x, o.y), s.stroke()), a = o;
589
- }
590
- let o = Math.max(0, r.y - P(r.x, r.z)), c = J(r.x, r.z, e), l = Math.min(o * .35 * e.scale, 40);
591
- s.fillStyle = "rgba(0,0,0,0.35)", s.beginPath(), s.ellipse(c.x + l, c.y + l, 3, 2, 0, 0, Math.PI * 2), s.fill(), a && (s.strokeStyle = "rgba(255,240,200,0.7)", s.beginPath(), s.moveTo(a.x, a.y), s.lineTo(c.x, c.y), s.stroke());
592
- let u = K(2.5 + o * .06, 2.5, 7);
593
- s.fillStyle = "#fff3c4", s.beginPath(), s.arc(c.x, c.y, u, 0, Math.PI * 2), s.fill(), s.strokeStyle = "#3a2a12", s.lineWidth = 1, s.stroke();
594
- }
595
- function X(e) {
596
- v.forEach((t) => {
597
- let n = J(t.x, t.z, e), r = Math.max(4, t.r * e.scale), i = s.createRadialGradient(n.x, n.y, 0, n.x, n.y, r);
598
- i.addColorStop(0, `rgba(255,250,220,${t.life / t.max})`), i.addColorStop(1, "rgba(255,160,60,0)"), s.fillStyle = i, s.beginPath(), s.arc(n.x, n.y, r, 0, Math.PI * 2), s.fill();
599
- }), y.forEach((t) => {
600
- let n = J(t.x, t.z, e);
601
- s.fillStyle = `rgba(60,58,55,${t.life / t.max * .45})`, s.beginPath(), s.arc(n.x, n.y, Math.max(2, t.r * e.scale), 0, Math.PI * 2), s.fill();
602
- }), _.forEach((t) => {
603
- let n = 1 - t.life / t.max, r = J(t.x, t.z, e);
604
- s.strokeStyle = `rgba(${t.color},${1 - n})`, s.lineWidth = 2 + (1 - n) * 2, s.beginPath(), s.arc(r.x, r.y, Math.max(1, (t.r0 + (t.r1 - t.r0) * n) * e.scale), 0, Math.PI * 2), s.stroke();
605
- }), g.forEach((t) => {
606
- let n = J(t.x, t.z, e);
607
- s.globalAlpha = K(t.life / t.max, 0, 1), s.fillStyle = t.color;
608
- let r = Math.max(1.5, t.size * e.scale);
609
- s.fillRect(n.x - r / 2, n.y - r / 2, r, r);
610
- }), s.globalAlpha = 1, s.textAlign = "center", s.font = "bold 14px system-ui, sans-serif", b.forEach((t) => {
611
- let n = 1 - t.life / t.max, r = J(t.x, t.z, e);
612
- s.globalAlpha = K(1.4 - n * 1.4, 0, 1), s.lineWidth = 3, s.strokeStyle = "rgba(0,0,0,0.7)", s.strokeText(t.text, r.x, r.y - 18 - n * 26), s.fillStyle = t.color, s.fillText(t.text, r.x, r.y - 18 - n * 26);
613
- }), s.globalAlpha = 1;
614
- }
615
- function je() {
616
- let e = l.wind || {}, t = q(e.x), n = q(e.z), r = Math.hypot(t, n), i = D - 34;
617
- if (s.fillStyle = "rgba(0,0,0,0.45)", s.beginPath(), s.arc(i, 34, 24, 0, Math.PI * 2), s.fill(), s.strokeStyle = "#e8f1ff", s.fillStyle = "#e8f1ff", s.lineWidth = 2, r > .01) {
618
- let e = K(6 + r * 2, 8, 18), a = t / r, o = n / r;
619
- s.beginPath(), s.moveTo(i - a * e, 34 - o * e), s.lineTo(i + a * e, 34 + o * e), s.stroke(), s.beginPath(), s.moveTo(i + a * (e + 4), 34 + o * (e + 4)), s.lineTo(i + a * e - o * 5, 34 + o * e + a * 5), s.lineTo(i + a * e + o * 5, 34 + o * e - a * 5), s.closePath(), s.fill();
620
- } else s.beginPath(), s.arc(i, 34, 3, 0, Math.PI * 2), s.fill();
621
- if (s.font = "11px system-ui, sans-serif", s.textAlign = "center", s.fillText(`${r.toFixed(1)} m/s`, i, 72), f && (Number.isFinite(f.pitch) || Number.isFinite(f.power))) {
622
- s.textAlign = "left";
623
- let e = [];
624
- Number.isFinite(f.pitch) && e.push(`${Math.round(f.pitch)}°`), Number.isFinite(f.power) && e.push(`${Math.round(f.power)}%`);
625
- let t = e.join(" · ");
626
- s.fillStyle = "rgba(0,0,0,0.45)", s.fillRect(8, 8, s.measureText(t).width + 12, 20), s.fillStyle = "#e8f1ff", s.fillText(t, 14, 22);
627
- }
628
- }
629
- function Z() {
630
- if (s && D && O && !j) try {
631
- if (s.setTransform(k, 0, 0, k, 0, 0), s.fillStyle = "#18211a", s.fillRect(0, 0, D, O), !l) return;
632
- let e = ie(), t = J(e.minX, e.minZ, e), n = e.size * e.scale, r = ue();
633
- r ? (s.imageSmoothingEnabled = !0, s.drawImage(r, t.x, t.y, n, n)) : (s.fillStyle = "#4c7a3e", s.fillRect(t.x, t.y, n, n)), s.strokeStyle = "rgba(0,0,0,0.5)", s.lineWidth = 1, s.strokeRect(t.x, t.y, n, n), pe(e), de(e), fe(e), B(e), (l.tanks || []).forEach((t) => G(t, e)), x.forEach((t) => Ce(e, t)), X(e), je();
634
- } catch {}
635
- }
636
- async function Me(e) {
637
- if (j || !e) return;
638
- let n = e.tankId, r = N(n), i = (e.movePath || []).filter((e) => e && Number.isFinite(e.x) && Number.isFinite(e.z)), a = r || i[0] || {
639
- x: 0,
640
- z: 0
641
- }, o = {
642
- x: a.x,
643
- y: q(a.y),
644
- z: a.z,
645
- hullYaw: q(r?.hullYaw),
646
- yaw: q(r?.yaw, q(r?.hullYaw)),
647
- pitch: q(r?.pitch)
648
- };
649
- if (C.set(String(n), o), i.length > 1 && De(i) > .05) {
650
- let e = De(i), r = 0;
651
- if (M("engine_start", { tankId: n }), await I(t ? 50 : 350), M("move_start", { tankId: n }), await I(K(e / z * 1e3, 400, 3500), (e, n) => {
652
- let a = Ee(i, _e(e));
653
- if (a && (a.heading != null && (o.yaw += be(o.hullYaw, a.heading), o.hullYaw = a.heading), o.x = a.x, o.y = a.y, o.z = a.z, r += n || 0, r > 110 && !t)) {
654
- r = 0;
655
- let e = ye(o.hullYaw);
656
- ce(a.x - e.x * 3, a.z - e.z * 3, 1, ["#8c7a5c"], 2);
657
- }
658
- }), M("move_end", { tankId: n }), j) return;
659
- }
660
- let s = q(e.yaw, o.yaw), c = Math.abs(be(o.yaw, s));
661
- if (c > 1) {
662
- let e = o.yaw;
663
- if (M("turret_start", { tankId: n }), await I(K(c / me * 1e3, 200, 1500), (t) => {
664
- o.yaw = xe(e, s, _e(t));
665
- }), M("turret_end", { tankId: n }), j) return;
666
- }
667
- o.yaw = s, o.pitch = q(e.pitch, o.pitch);
668
- let l = e.damage || {}, u = /* @__PURE__ */ new Set(), d = [...e.craters || []].filter((e) => Number.isFinite(e?.x) && Number.isFinite(e?.z)), f = ye(o.yaw), p = {
669
- x: o.x + f.x * V * .85,
670
- z: o.z + f.z * V * .85
671
- }, m = ke(e.shots).map((e) => ({
672
- ...e,
673
- state: "waiting",
674
- f: 0
675
- })), g = (e) => {
676
- e.state = "flying", e.bomblet || (M("fire", {
677
- tankId: n,
678
- shot: e.index
679
- }), v.push({
680
- x: p.x,
681
- z: p.z,
682
- r: 2.5,
683
- life: 160,
684
- max: 160
685
- }), y.push({
686
- x: p.x,
687
- z: p.z,
688
- r: 1,
689
- life: 900,
690
- max: 900
691
- }), e.count >= 2 && M("projectile_start", {
692
- tankId: n,
693
- shot: e.index
694
- }));
695
- }, _ = (e) => {
696
- e.state = "done";
697
- let { shot: t, index: n } = e, r = e.count ? Oe(t.samples, e.count - 1) : p, i = t.impact && Number.isFinite(t.impact.x) ? t.impact : {
698
- ...r,
699
- kind: "terrain"
700
- };
701
- if (M("impact", {
702
- kind: i.kind,
703
- tankId: i.tankId,
704
- shot: n
705
- }), i.kind === "split") v.push({
706
- x: i.x,
707
- z: i.z,
708
- r: 1.5,
709
- life: 140,
710
- max: 140
711
- }), ce(i.x, i.z, 4, ["#ffe9a8", "#cfcfcf"], 6);
712
- else if (i.kind !== "out") {
713
- if (le(i.x, i.z, t.radius, !1), i.kind === "tank" && i.tankId != null) {
714
- M("tank_hit", {
715
- tankId: i.tankId,
716
- shot: n
717
- });
718
- let e = l[i.tankId];
719
- if (Number.isFinite(e) && e > 0 && !u.has(String(i.tankId))) {
720
- u.add(String(i.tankId));
721
- let t = T(i.tankId) || N(i.tankId) || i;
722
- b.push({
723
- x: t.x,
724
- z: t.z,
725
- text: `-${Math.round(e)}`,
726
- color: "#ff6b5a",
727
- life: 1400,
728
- max: 1400
729
- });
730
- }
731
- }
732
- for (let e = d.length - 1; e >= 0; --e) {
733
- let t = d[e];
734
- Math.hypot(t.x - i.x, t.z - i.z) <= q(t.radius, 3) + 1.5 && h.push(...d.splice(e, 1));
735
- }
736
- }
737
- };
738
- if (m.length) {
739
- let e = Math.max(...m.map((e) => e.endMs)) + 380;
740
- if (await I(e, (t) => {
741
- let n = t * e;
742
- m.forEach((e) => {
743
- e.state === "waiting" && n >= e.startMs && g(e), e.state === "flying" && (e.f = K((n - e.startMs) / 40, 0, Math.max(0, e.count - 1)), n >= e.endMs && _(e));
744
- }), x = m.filter((e) => e.state === "flying" && e.count >= 2).map((e) => ({
745
- samples: e.shot.samples,
746
- f: e.f
747
- }));
748
- }), x = [], j) return;
749
- }
750
- h.push(...d), Object.entries(l).forEach(([e, t]) => {
751
- if (u.has(e) || !Number.isFinite(t) || t <= 0) return;
752
- let n = T(e) || N(e);
753
- n && b.push({
754
- x: n.x,
755
- z: n.z,
756
- text: `-${Math.round(t)}`,
757
- color: "#ff6b5a",
758
- life: 1400,
759
- max: 1400
760
- });
761
- });
762
- let S = e.destroyed || [];
763
- if (S.forEach((e) => {
764
- let t = T(e) || N(e);
765
- M("big_explosion", { tankId: e }), t && le(t.x, t.z, 6, !0), M("destroyed", { tankId: e }), w.add(String(e));
766
- }), S.length) {
767
- let e = 0;
768
- await I(1600, (t, n) => {
769
- e += n || 0, !(e < 140) && (e = 0, S.forEach((e) => {
770
- let t = T(e) || N(e);
771
- t && y.push({
772
- x: t.x + (Math.random() - .5) * 2,
773
- z: t.z + (Math.random() - .5) * 2,
774
- r: 1.2,
775
- life: 1600,
776
- max: 1600
777
- });
778
- }));
779
- });
780
- } else await I(500);
781
- j || (e.world && Ne(e.world, !0), C.delete(String(n)), F(), Z());
782
- }
783
- function Ne(e, t) {
784
- e && (!t && l && e.heights !== l.heights && (h = []), l = e, (e.tanks || []).forEach((e) => {
785
- e.alive !== !1 && !(Number(e.hp) <= 0) && w.delete(String(e.id));
786
- }));
787
- }
788
- function Q() {
789
- if (!o || j) return;
790
- let t = e?.getBoundingClientRect?.() || {
791
- width: e?.clientWidth || 0,
792
- height: e?.clientHeight || 0
793
- };
794
- D = Math.max(0, Math.floor(t.width)), O = Math.max(0, Math.floor(t.height)), k = Math.min(re().dpr, a?.devicePixelRatio || 1), o.width = Math.max(1, Math.round(D * k)), o.height = Math.max(1, Math.round(O * k)), Z();
795
- }
796
- let Pe = () => {
797
- ne() ? (A && a?.cancelAnimationFrame && a.cancelAnimationFrame(A), A = 0, ee = 0) : F();
798
- };
799
- i?.addEventListener("visibilitychange", Pe);
800
- let Fe = null;
801
- return a?.ResizeObserver && e ? (Fe = new a.ResizeObserver(() => Q()), Fe.observe(e)) : a?.addEventListener("resize", Q), Q(), {
802
- setWorld(e) {
803
- Ne(e, !1), Z();
804
- },
805
- setAim(e) {
806
- f = e ? {
807
- yaw: e.yaw,
808
- pitch: e.pitch,
809
- power: e.power
810
- } : null, Z();
811
- },
812
- setPreview(e) {
813
- p = Ae(e), Z();
814
- },
815
- playTurn(e) {
816
- let t = te.then(() => Me(e)).catch(() => {});
817
- return te = t, t;
818
- },
819
- setCameraMode(e) {
820
- d = e || "overview", Z();
821
- },
822
- setQuality(e) {
823
- W[e] && e !== u && (u = e, Q());
824
- },
825
- celebrate(e) {
826
- S = e == null ? null : {
827
- id: e,
828
- left: 3e3,
829
- next: 0
830
- }, S && F(), Z();
831
- },
832
- resize: Q,
833
- dispose() {
834
- if (!j) {
835
- j = !0, A && a?.cancelAnimationFrame && a.cancelAnimationFrame(A), A = 0, E.forEach((e) => e.resolve()), E.clear(), Fe?.disconnect(), a?.removeEventListener("resize", Q), i?.removeEventListener("visibilitychange", Pe), g = [], _ = [], v = [], y = [], b = [], h = [], x = [], m = {
836
- heights: null,
837
- grid: 0,
838
- factor: 0,
839
- canvas: null
840
- }, C.clear();
841
- try {
842
- o?.remove();
843
- } catch {}
844
- s = null;
845
- }
846
- }
847
- };
848
- }
849
- // src/games/tanks/sound/cues.js
850
- var je = [
851
- "engine_loop",
852
- "tracks_loop",
853
- "turret_loop"
854
- ], Z = (e) => ({
855
- name: e,
856
- action: "play"
857
- }), Me = (e) => ({
858
- name: e,
859
- action: "loop_start"
860
- }), Ne = (e) => ({
861
- name: e,
862
- action: "loop_stop"
863
- }), Q = {
864
- terrain: "terrain_impact",
865
- obstacle: "terrain_impact",
866
- ground: "terrain_impact"
867
- };
868
- function Pe(e) {
869
- switch (typeof e == "string" ? e : e?.type) {
870
- case "engine_start": return [Z("engine_start")];
871
- case "move_start": return [Me("engine_loop"), Me("tracks_loop")];
872
- case "move_end": return [Ne("tracks_loop"), Ne("engine_loop")];
873
- case "turret_start": return [Me("turret_loop")];
874
- case "turret_end": return [Ne("turret_loop")];
875
- case "fire": return [Z("cannon_fire")];
876
- case "projectile_start": return [Z("projectile_whistle")];
877
- case "impact": {
878
- let t = Q[e?.kind];
879
- return t ? [Z(t)] : [];
880
- }
881
- case "tank_hit": return [Z("tank_hit")];
882
- case "big_explosion": return [Z("big_explosion")];
883
- case "destroyed": return [Z("tank_destroyed")];
884
- default: return [];
885
- }
886
- }
887
- function Fe(e) {
888
- return e === "victory" || e === "defeat" ? [...je.map(Ne), Z(e)] : [];
889
- }
890
- // src/games/tanks/sound/tanksSounds.js
891
- var Ie = [
892
- "engine_start",
893
- "engine_loop",
894
- "tracks_loop",
895
- "turret_loop",
896
- "cannon_fire",
897
- "projectile_whistle",
898
- "terrain_impact",
899
- "tank_hit",
900
- "big_explosion",
901
- "tank_destroyed",
902
- "victory",
903
- "defeat",
904
- "turn_start",
905
- "your_turn",
906
- "timer_warning"
907
- ], Le = {
908
- engine_start: .6,
909
- engine_loop: .45,
910
- tracks_loop: .5,
911
- turret_loop: .5,
912
- cannon_fire: .8,
913
- projectile_whistle: .6,
914
- terrain_impact: .85,
915
- tank_hit: .85,
916
- big_explosion: .9,
917
- tank_destroyed: 1,
918
- victory: .8,
919
- defeat: .8,
920
- turn_start: .35,
921
- your_turn: .4,
922
- timer_warning: .35
923
- }, Re = [
924
- "engine_start",
925
- "engine_loop",
926
- "tracks_loop",
927
- "turret_loop",
928
- "cannon_fire",
929
- "projectile_whistle",
930
- "terrain_impact",
931
- "tank_hit",
932
- "big_explosion",
933
- "tank_destroyed",
934
- "victory",
935
- "defeat"
936
- ], ze = 120, Be = {
937
- engine_loop: {
938
- fadeIn: .5,
939
- fadeOut: .35
940
- },
941
- tracks_loop: {
942
- fadeIn: .12,
943
- fadeOut: .2
944
- },
945
- turret_loop: {
946
- fadeIn: .06,
947
- fadeOut: .12
948
- }
949
- }, Ve = .03, He = { tank_destroyed: {
950
- name: "big_explosion",
951
- ms: 1500
952
- } }, Ue = () => {
953
- try {
954
- return typeof Audio < "u" && new Audio().canPlayType("audio/ogg; codecs=\"vorbis\"") !== "";
955
- } catch {
956
- return !1;
957
- }
958
- }, We = {}, Ge = (e, t) => `${e}.${String(t).replace(/^\./, "")}`, Ke = !1, qe = "ogg";
959
- function Je({ extension: e = "auto", available: t = Re, files: n } = {}) {
960
- Ke = !0, qe = e === "auto" ? Ue() ? "ogg" : "mp3" : e, Ie.forEach((e) => {
961
- t.includes(e) ? We[e] = Ge(e, qe) : delete We[e];
962
- }), Object.entries(n || {}).forEach(([e, t]) => {
963
- t ? We[e] = String(t) : delete We[e];
964
- });
965
- }
966
- var $ = null;
967
- function Ye() {
968
- return Ke || Je(), $ || ($ = o({
969
- id: "tanks",
970
- baseUrl: () => g("tanks"),
971
- settingsFrom: p,
972
- sounds: We,
973
- levels: Le
974
- })), $;
975
- }
976
- var Xe = () => typeof document < "u" && document.hidden, Ze = () => _() && !Xe(), Qe = /* @__PURE__ */ new Set(), $e = () => {
977
- if (!$) return;
978
- let e = Ze();
979
- (/* @__PURE__ */ new Set([...je, ...Qe])).forEach((t) => {
980
- e && Qe.has(t) ? $.startLoop(t, {
981
- ...Be[t],
982
- trim: qe === "mp3" ? Ve : 0
983
- }) : $.stopLoop(t);
984
- });
985
- }, et = !1;
986
- function tt() {
987
- Ye().preload(), !et && (et = !0, v($e), typeof document < "u" && document.addEventListener("visibilitychange", $e));
988
- }
989
- var nt = /* @__PURE__ */ new Map(), rt = /* @__PURE__ */ new Map();
990
- function it(e, t) {
991
- rt.set(e, Math.max(rt.get(e) ?? 0, Date.now() + t));
992
- }
993
- function at(e, t) {
994
- if (Ke || Je(), Date.now() < (rt.get(e) ?? 0)) return !1;
995
- if (!Ze()) return t != null && Ye().markPlayed(e, t), !1;
996
- let n = Date.now();
997
- if (n - (nt.get(e) ?? 0) < ze) return !1;
998
- let r = Ye().play(e, t == null ? void 0 : { key: t });
999
- return r && (nt.set(e, n), He[e] && it(He[e].name, He[e].ms)), r;
1000
- }
1001
- function ot(e) {
1002
- Qe.add(e), Ye(), $e();
1003
- }
1004
- function st(e) {
1005
- Qe.delete(e), $?.stopLoop(e);
1006
- }
1007
- function ct() {
1008
- let e = [...je, ...Qe];
1009
- Qe.clear(), e.forEach((e) => $?.stopLoop(e));
1010
- }
1011
- var lt = (e, t) => e.forEach(({ name: e, action: n }) => {
1012
- n === "loop_start" ? ot(e) : n === "loop_stop" ? st(e) : at(e, t == null ? void 0 : `${t}:${e}`);
1013
- });
1014
- function ut(e, t) {
1015
- let n = e?.tankId == null ? "" : `:${e.tankId}`;
1016
- lt(Pe(e), t == null ? void 0 : `${t}${n}`);
1017
- }
1018
- function dt(e, t) {
1019
- lt(Fe(e), t);
1020
- }
1021
- // src/games/tanks/TanksGameCard.jsx
1022
- var ft = 60, pt = 6e4, mt = {
1023
- standard: "Estándar",
1024
- heavy: "Pesada",
1025
- cluster: "Racimo"
1026
- }, ht = (e, [t, n]) => Math.max(t, Math.min(n, Math.round(e))), gt = (e) => (Math.round(e) % 360 + 360) % 360, _t = () => typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
1027
- function vt() {
1028
- let e = C(y)?.transport ?? null, t = S((t) => {
1029
- let n = e?.onStatus?.(t);
1030
- return typeof n == "function" ? n : () => {};
1031
- }, [e]), n = D(t, () => e?.getStatus?.() ?? null, () => null);
1032
- return m() === "connected" || n === "connected";
1033
- }
1034
- function yt(e, ...n) {
1035
- return Promise.resolve(t.getState()[e]?.(...n)).catch((e) => {
1036
- throw e;
1037
- });
1038
- }
1039
- function bt({ sync: e, connected: t, onResync: n, onAdoptOffer: r }) {
1040
- return e?.status === "requesting" ? /* @__PURE__ */ N("div", {
1041
- className: "chat-game-sync",
1042
- role: "status",
1043
- children: "Sincronizando partida…"
1044
- }) : /* @__PURE__ */ P("div", {
1045
- className: "chat-game-sync",
1046
- role: "alert",
1047
- children: [
1048
- e?.message && /* @__PURE__ */ N("span", { children: e.message }),
1049
- e?.status === "incompatible" && e.offer && /* @__PURE__ */ N("button", {
1050
- type: "button",
1051
- className: "chat-game-action chat-game-action--primary",
1052
- disabled: !t,
1053
- onClick: r,
1054
- children: "Usar estado del anfitrión"
1055
- }),
1056
- /* @__PURE__ */ N("button", {
1057
- type: "button",
1058
- className: "chat-game-action",
1059
- disabled: !t,
1060
- onClick: n,
1061
- children: "Reintentar sincronización"
1062
- })
1063
- ]
1064
- });
1065
- }
1066
- function xt({ label: e, hp: t, color: n, active: r }) {
1067
- return /* @__PURE__ */ P("div", {
1068
- className: `tk-hp tk-hp--${n}${r ? " is-active" : ""}`,
1069
- children: [
1070
- /* @__PURE__ */ N("span", {
1071
- className: "tk-hp-label",
1072
- children: e
1073
- }),
1074
- /* @__PURE__ */ N("span", {
1075
- className: "tk-hp-track",
1076
- role: "meter",
1077
- "aria-valuemin": 0,
1078
- "aria-valuemax": 100,
1079
- "aria-valuenow": t,
1080
- "aria-label": `Vida de ${e}`,
1081
- children: /* @__PURE__ */ N("span", {
1082
- className: "tk-hp-fill",
1083
- style: { width: `${t}%` }
1084
- })
1085
- }),
1086
- /* @__PURE__ */ N("strong", { children: t })
1087
- ]
1088
- });
1089
- }
1090
- function St(e, t, n, r) {
1091
- let i = T(null), [a, o] = E("loading"), [s, c] = E(!1), l = T(r);
1092
- l.current = r;
1093
- let u = n || s;
1094
- return w(() => {
1095
- let n = e.current;
1096
- if (!t || !n) return;
1097
- let r = !1, a = null, s = {
1098
- reducedMotion: _t(),
1099
- onEvent: (e) => {
1100
- e?.type === "context_lost" ? c(!0) : l.current?.(e);
1101
- }
1102
- }, d = (e, t) => {
1103
- a = e, i.current = e, o(t);
1104
- }, f = () => {
1105
- try {
1106
- d(X(n, s), "2d");
1107
- } catch {
1108
- o("none");
1109
- }
1110
- };
1111
- return o("loading"), u || !b() ? f() : import("./createTankScene-BuliAxwR.js").then(({ createTankScene: e }) => {
1112
- if (!r) try {
1113
- d(e(n, s), "3d");
1114
- } catch {
1115
- f();
1116
- }
1117
- }).catch(() => {
1118
- r || f();
1119
- }), () => {
1120
- r = !0;
1121
- try {
1122
- a?.dispose();
1123
- } catch {}
1124
- i.current = null, ct();
1125
- };
1126
- }, [
1127
- e,
1128
- t,
1129
- u
1130
- ]), {
1131
- sceneRef: i,
1132
- mode: a,
1133
- use2d: u,
1134
- setForced2d: c
1135
- };
1136
- }
1137
- function Ct({ game: e, currentUserId: t }) {
1138
- let n = e.logic?.tanks.map((e) => e.hp) ?? [100, 100];
1139
- return /* @__PURE__ */ P("section", {
1140
- className: "chat-game-card chat-game-card--history tk-card tk-card--history",
1141
- "aria-label": "Partida de Tanques de guerra",
1142
- children: [
1143
- /* @__PURE__ */ N("header", {
1144
- className: "chat-game-header",
1145
- children: /* @__PURE__ */ P("div", {
1146
- className: "chat-game-heading",
1147
- children: [/* @__PURE__ */ N("span", {
1148
- className: "chat-game-eyebrow",
1149
- children: "MINIJUEGOS · 2 JUGADORES"
1150
- }), /* @__PURE__ */ P("h3", { children: ["Tanques de guerra ", /* @__PURE__ */ N(te, {
1151
- size: 13,
1152
- "aria-hidden": "true"
1153
- })] })]
1154
- })
1155
- }),
1156
- /* @__PURE__ */ N("p", {
1157
- className: "chat-game-status",
1158
- role: "status",
1159
- children: f(e, t)
1160
- }),
1161
- e.logic && /* @__PURE__ */ P("p", {
1162
- className: "tk-history-score",
1163
- children: [
1164
- "Verde ",
1165
- n[0],
1166
- " · Rojo ",
1167
- n[1],
1168
- " HP"
1169
- ]
1170
- })
1171
- ]
1172
- });
1173
- }
1174
- function wt({ game: e, gameKey: t, currentUserId: n, variant: r, onMinimize: a, onDismiss: o }) {
1175
- let c = vt(), p = T(null), [m, g] = E(!1), [_, v] = E(null), [y, b] = E(!1), [x, S] = E("overview"), [C, D] = E(""), [ae, F] = E(!1), [oe, I] = E(() => Date.now()), se = T("init"), ce = T(0), L = [
1176
- "active",
1177
- "won",
1178
- "draw",
1179
- "conflict",
1180
- "closed"
1181
- ].includes(e.status) && !!e.logic, { sceneRef: R, mode: z, use2d: me } = St(p, L, m, (e) => ut(e, `${se.current}:${e.type}:${ce.current += 1}`)), B = String(n ?? e.ownId), V = e.logic?.players ?? [e.hostId, e.guestId], H = V.indexOf(B), he = s(B, e.guestId), U = H >= 0, ge = u(e), W = h(e) && !y, G = (e, ...t) => {
1182
- D(""), yt(e, ...t).catch((e) => D(e?.message || "No se pudo enviar."));
1183
- };
1184
- w(() => {
1185
- tt();
1186
- }, []);
1187
- let K = T({
1188
- eventId: void 0,
1189
- logic: null,
1190
- scene: null
1191
- }), q = T(Promise.resolve());
1192
- w(() => {
1193
- let t = R.current;
1194
- if (!t || !e.logic) return;
1195
- let n = K.current, r = e.lastAction?.eventId ?? null;
1196
- if (n.scene !== t) {
1197
- K.current = {
1198
- eventId: r,
1199
- logic: e.logic,
1200
- scene: t
1201
- }, t.setWorld(ue(e));
1202
- return;
1203
- }
1204
- if (n.logic === e.logic) return;
1205
- let i = n.logic, a = r !== n.eventId && e.lastAction?.entry?.[0] === 1;
1206
- K.current = {
1207
- eventId: r,
1208
- logic: e.logic,
1209
- scene: t
1210
- };
1211
- let o = a ? de(e, i) : null, s = ue(e);
1212
- q.current = q.current.then(async () => {
1213
- if (R.current === t) {
1214
- if (!o) t.setWorld(s);
1215
- else {
1216
- se.current = r, o.destroyed.length && it("big_explosion", 15e3), b(!0), S("overview");
1217
- try {
1218
- await t.playTurn(o);
1219
- } catch {
1220
- t.setWorld(s);
1221
- }
1222
- R.current === t && b(!1);
1223
- }
1224
- }
1225
- });
1226
- }, [
1227
- e,
1228
- z,
1229
- R
1230
- ]);
1231
- let _e = T(ge);
1232
- w(() => {
1233
- !_e.current && ["won", "draw"].includes(e.status) && q.current.then(() => {
1234
- R.current?.celebrate?.(e.winnerId ?? null), U && dt(s(e.winnerId, B) ? "victory" : "defeat", `${e.gameId}:end`);
1235
- });
1236
- }, [
1237
- e.status,
1238
- e.winnerId,
1239
- e.gameId,
1240
- B,
1241
- U,
1242
- R
1243
- ]), w(() => {
1244
- if (!h(e) || !e.logic) {
1245
- v(null);
1246
- return;
1247
- }
1248
- let t = e.logic.tanks[H], n = e.logic.tanks[1 - H];
1249
- v({
1250
- move: 0,
1251
- yaw: pe(t, n),
1252
- pitch: 45,
1253
- power: 60,
1254
- ammo: "standard"
1255
- });
1256
- }, [
1257
- e.ply,
1258
- e.status,
1259
- e.pendingEvent,
1260
- H
1261
- ]), w(() => {
1262
- let t = R.current;
1263
- t && e.logic && (!_ || !W ? t.setPreview(null) : (t.setAim(_), t.setPreview(fe(e, B, _))));
1264
- }, [
1265
- _,
1266
- W,
1267
- z
1268
- ]), w(() => {
1269
- R.current?.setCameraMode?.(x);
1270
- }, [
1271
- x,
1272
- z,
1273
- R
1274
- ]);
1275
- let ve = T({
1276
- ply: -1,
1277
- at: 0
1278
- });
1279
- !y && e.status === "active" && ve.current.ply !== e.ply && (ve.current = {
1280
- ply: e.ply,
1281
- at: Date.now()
1282
- }), w(() => {
1283
- if (e.status !== "active" && e.status !== "invited") return;
1284
- let t = setInterval(() => I(Date.now()), 1e3);
1285
- return () => clearInterval(t);
1286
- }, [e.status]);
1287
- let J = Math.max(0, ft - Math.floor((oe - ve.current.at) / 1e3)), ye = T(-1);
1288
- w(() => {
1289
- !W || J > 0 || ye.current === e.ply || document.visibilityState !== "visible" || (ye.current = e.ply, G("tkSkip", t));
1290
- }, [
1291
- W,
1292
- J,
1293
- e.ply,
1294
- t
1295
- ]);
1296
- let Y = (e) => v((t) => t && {
1297
- ...t,
1298
- ...e
1299
- }), be = () => {
1300
- W && _ && c && G("tkTurn", t, _);
1301
- }, xe = T(null), Se = (e) => {
1302
- W && _ && (xe.current = {
1303
- x: e.clientX,
1304
- y: e.clientY,
1305
- yaw: _.yaw,
1306
- pitch: _.pitch
1307
- }, e.currentTarget.setPointerCapture?.(e.pointerId));
1308
- }, Ce = (e) => {
1309
- if (!xe.current) return;
1310
- let t = xe.current;
1311
- Y({
1312
- yaw: gt(t.yaw - (e.clientX - t.x) * .4),
1313
- pitch: ht(t.pitch - (e.clientY - t.y) * .25, l.pitch)
1314
- });
1315
- }, we = () => {
1316
- xe.current = null;
1317
- }, Te = (e) => {
1318
- if (!W || !_) return;
1319
- let t = e.shiftKey ? 10 : 2, n = {
1320
- ArrowLeft: () => Y({ yaw: gt(_.yaw + t) }),
1321
- ArrowRight: () => Y({ yaw: gt(_.yaw - t) }),
1322
- ArrowUp: () => Y({ pitch: ht(_.pitch + 1, l.pitch) }),
1323
- ArrowDown: () => Y({ pitch: ht(_.pitch - 1, l.pitch) }),
1324
- "+": () => Y({ power: ht(_.power + 2, l.power) }),
1325
- "=": () => Y({ power: ht(_.power + 2, l.power) }),
1326
- "-": () => Y({ power: ht(_.power - 2, l.power) }),
1327
- Enter: be,
1328
- " ": be
1329
- }[e.key];
1330
- n && (e.preventDefault(), n());
1331
- }, Ee = V[1 - H] ?? (he ? e.hostId : e.guestId), De = () => G("invite", {
1332
- roomId: e.roomId,
1333
- opponentId: Ee,
1334
- gameType: "tanks",
1335
- firstPlayerId: e.firstPlayerId === e.hostId ? e.guestId : e.hostId,
1336
- rematchOf: e.gameId
1337
- }), Oe = !c && !ge ? "Sin conexión · esperando reconexión" : e.pending ? "Enviando…" : f(e, n), ke = e.logic?.tanks ?? [], Ae = ke[H], X = e.logic ? ue(e).wind : null, je = X ? Math.hypot(X.x, X.z) : 0, Z = X ? Math.round(Math.atan2(X.z, X.x) * 180 / Math.PI) : 0, Me = e.status === "invited" && !he && Date.now() - Date.parse(e.createdAt) > pt;
1338
- return /* @__PURE__ */ P("section", {
1339
- className: `chat-game-card tk-card${W ? " chat-game-card--my-turn" : ""}${r ? ` chat-game-card--${r}` : ""}`,
1340
- "aria-label": "Partida de Tanques de guerra",
1341
- children: [
1342
- /* @__PURE__ */ P("header", {
1343
- className: "chat-game-header",
1344
- children: [
1345
- /* @__PURE__ */ P("div", {
1346
- className: "chat-game-heading",
1347
- children: [/* @__PURE__ */ N("span", {
1348
- className: "chat-game-eyebrow",
1349
- children: "MINIJUEGOS · 2 JUGADORES"
1350
- }), /* @__PURE__ */ P("h3", { children: ["Tanques de guerra ", /* @__PURE__ */ N(te, {
1351
- size: 13,
1352
- "aria-hidden": "true"
1353
- })] })]
1354
- }),
1355
- r === "panel" && /* @__PURE__ */ N(d, { manager: Ye() }),
1356
- a && /* @__PURE__ */ N("button", {
1357
- className: "chat-game-close",
1358
- type: "button",
1359
- "aria-label": "Minimizar tablero",
1360
- title: "Minimizar tablero",
1361
- onClick: a,
1362
- children: /* @__PURE__ */ N(O, {
1363
- size: 16,
1364
- "aria-hidden": "true"
1365
- })
1366
- }),
1367
- U && !ge && /* @__PURE__ */ N("button", {
1368
- className: "chat-game-close",
1369
- type: "button",
1370
- "aria-label": "Finalizar partida para ambos jugadores",
1371
- title: "Finalizar partida para ambos",
1372
- disabled: !c,
1373
- onClick: () => G("act", t, "game_end"),
1374
- children: /* @__PURE__ */ N(re, {
1375
- size: 16,
1376
- "aria-hidden": "true"
1377
- })
1378
- }),
1379
- o && /* @__PURE__ */ N("button", {
1380
- className: "chat-game-close",
1381
- type: "button",
1382
- "aria-label": "Cerrar tablero y volver al chat",
1383
- title: "Cerrar tablero",
1384
- onClick: o,
1385
- children: /* @__PURE__ */ N(re, {
1386
- size: 16,
1387
- "aria-hidden": "true"
1388
- })
1389
- })
1390
- ]
1391
- }),
1392
- /* @__PURE__ */ N("p", {
1393
- className: "chat-game-status",
1394
- role: "status",
1395
- children: Oe
1396
- }),
1397
- e.status === "invited" && /* @__PURE__ */ P("div", {
1398
- className: "tk-invite",
1399
- children: [
1400
- /* @__PURE__ */ N("p", { children: "Duelo de artillería por turnos: mueve tu tanque, apunta la torreta, elige la potencia y destruye al rival. 100 HP cada uno." }),
1401
- he && /* @__PURE__ */ P("div", {
1402
- className: "chat-game-actions",
1403
- children: [/* @__PURE__ */ N("button", {
1404
- type: "button",
1405
- className: "chat-game-action chat-game-action--primary",
1406
- disabled: !c || e.pending,
1407
- onClick: () => G("act", t, "game_accept"),
1408
- children: "Aceptar duelo"
1409
- }), /* @__PURE__ */ N("button", {
1410
- type: "button",
1411
- className: "chat-game-action",
1412
- disabled: !c || e.pending,
1413
- onClick: () => G("act", t, "game_decline"),
1414
- children: "Rechazar"
1415
- })]
1416
- }),
1417
- Me && /* @__PURE__ */ N("p", {
1418
- className: "tk-hint",
1419
- children: "¿No responde? Tu contacto puede necesitar actualizar la app para jugar a Tanques."
1420
- })
1421
- ]
1422
- }),
1423
- L && /* @__PURE__ */ P("div", {
1424
- className: "tk-stage-wrap",
1425
- children: [
1426
- /* @__PURE__ */ N("div", {
1427
- ref: p,
1428
- className: `tk-stage${W ? " is-aiming" : ""}`,
1429
- tabIndex: 0,
1430
- role: "application",
1431
- "aria-label": "Campo de batalla. Flechas para apuntar, más y menos para la potencia, Enter para disparar.",
1432
- onPointerDown: Se,
1433
- onPointerMove: Ce,
1434
- onPointerUp: we,
1435
- onPointerCancel: we,
1436
- onKeyDown: Te
1437
- }),
1438
- z === "loading" && /* @__PURE__ */ N("div", {
1439
- className: "tk-stage-note",
1440
- role: "status",
1441
- children: "Cargando campo de batalla…"
1442
- }),
1443
- z === "none" && /* @__PURE__ */ N("div", {
1444
- className: "tk-stage-note",
1445
- role: "alert",
1446
- children: "No se pudo dibujar el campo de batalla."
1447
- }),
1448
- /* @__PURE__ */ P("div", {
1449
- className: "tk-hud",
1450
- children: [
1451
- /* @__PURE__ */ N(xt, {
1452
- label: H === 0 ? "Tú" : "Verde",
1453
- hp: ke[0]?.hp ?? 100,
1454
- color: le[0],
1455
- active: e.turnId === V[0]
1456
- }),
1457
- /* @__PURE__ */ N(xt, {
1458
- label: H === 1 ? "Tú" : "Rojo",
1459
- hp: ke[1]?.hp ?? 100,
1460
- color: le[1],
1461
- active: e.turnId === V[1]
1462
- }),
1463
- /* @__PURE__ */ P("div", {
1464
- className: "tk-hud-meta",
1465
- children: [
1466
- X && /* @__PURE__ */ P("span", {
1467
- title: "Viento",
1468
- children: [
1469
- /* @__PURE__ */ N(M, {
1470
- size: 12,
1471
- "aria-hidden": "true"
1472
- }),
1473
- /* @__PURE__ */ N("i", {
1474
- className: "tk-wind-arrow",
1475
- style: { transform: `rotate(${Z}deg)` },
1476
- "aria-hidden": "true",
1477
- children: "➜"
1478
- }),
1479
- je.toFixed(1),
1480
- " m/s²"
1481
- ]
1482
- }),
1483
- e.logic && /* @__PURE__ */ P("span", { children: [
1484
- "Disparo ",
1485
- Math.min(e.logic.shots + 1, e.logic.maxShots),
1486
- "/",
1487
- e.logic.maxShots
1488
- ] }),
1489
- e.status === "active" && !y && /* @__PURE__ */ P("span", {
1490
- className: J <= 10 ? "tk-timer is-low" : "tk-timer",
1491
- children: [J, "s"]
1492
- })
1493
- ]
1494
- })
1495
- ]
1496
- }),
1497
- /* @__PURE__ */ P("div", {
1498
- className: "tk-stage-tools",
1499
- children: [/* @__PURE__ */ P("button", {
1500
- type: "button",
1501
- className: "chat-game-action",
1502
- "aria-pressed": x === "aim",
1503
- onClick: () => S(x === "aim" ? "overview" : "aim"),
1504
- title: "Cambiar cámara",
1505
- children: [/* @__PURE__ */ N(ne, {
1506
- size: 14,
1507
- "aria-hidden": "true"
1508
- }), x === "aim" ? "Vista general" : "Cámara de apuntado"]
1509
- }), z !== "loading" && /* @__PURE__ */ P("button", {
1510
- type: "button",
1511
- className: "chat-game-action",
1512
- "aria-pressed": me,
1513
- onClick: () => g(!me),
1514
- title: "Cambiar vista",
1515
- children: [/* @__PURE__ */ N(ee, {
1516
- size: 14,
1517
- "aria-hidden": "true"
1518
- }), me ? "Vista 3D" : "Vista 2D"]
1519
- })]
1520
- })
1521
- ]
1522
- }),
1523
- W && _ && Ae && /* @__PURE__ */ P("div", {
1524
- className: "tk-controls",
1525
- "aria-label": "Controles del disparo",
1526
- children: [
1527
- /* @__PURE__ */ P("label", {
1528
- className: "tk-control",
1529
- children: [/* @__PURE__ */ P("span", { children: [
1530
- "Mover ",
1531
- /* @__PURE__ */ P("strong", { children: [(_.move * .5).toFixed(1), " m"] }),
1532
- " ",
1533
- /* @__PURE__ */ P("small", { children: [
1534
- "combustible ",
1535
- Math.floor(Ae.fuel / 1e5),
1536
- " m"
1537
- ] })
1538
- ] }), /* @__PURE__ */ N("input", {
1539
- type: "range",
1540
- min: l.move[0],
1541
- max: l.move[1],
1542
- value: _.move,
1543
- onChange: (e) => Y({ move: Number(e.target.value) }),
1544
- "aria-valuetext": `${(_.move * .5).toFixed(1)} metros`
1545
- })]
1546
- }),
1547
- /* @__PURE__ */ P("label", {
1548
- className: "tk-control",
1549
- children: [/* @__PURE__ */ P("span", { children: ["Torreta ", /* @__PURE__ */ P("strong", { children: [_.yaw, "°"] })] }), /* @__PURE__ */ N("input", {
1550
- type: "range",
1551
- min: l.yaw[0],
1552
- max: l.yaw[1],
1553
- value: _.yaw,
1554
- onChange: (e) => Y({ yaw: Number(e.target.value) }),
1555
- "aria-valuetext": `${_.yaw} grados`
1556
- })]
1557
- }),
1558
- /* @__PURE__ */ P("label", {
1559
- className: "tk-control",
1560
- children: [/* @__PURE__ */ P("span", { children: ["Elevación ", /* @__PURE__ */ P("strong", { children: [_.pitch, "°"] })] }), /* @__PURE__ */ N("input", {
1561
- type: "range",
1562
- min: l.pitch[0],
1563
- max: l.pitch[1],
1564
- value: _.pitch,
1565
- onChange: (e) => Y({ pitch: Number(e.target.value) }),
1566
- "aria-valuetext": `${_.pitch} grados`
1567
- })]
1568
- }),
1569
- /* @__PURE__ */ P("label", {
1570
- className: "tk-control",
1571
- children: [/* @__PURE__ */ P("span", { children: ["Potencia ", /* @__PURE__ */ N("strong", { children: _.power })] }), /* @__PURE__ */ N("input", {
1572
- type: "range",
1573
- min: l.power[0],
1574
- max: l.power[1],
1575
- value: _.power,
1576
- onChange: (e) => Y({ power: Number(e.target.value) }),
1577
- "aria-valuetext": `Potencia ${_.power}`
1578
- })]
1579
- }),
1580
- /* @__PURE__ */ N("div", {
1581
- className: "tk-ammo",
1582
- role: "radiogroup",
1583
- "aria-label": "Munición",
1584
- children: Object.keys(i).map((e) => {
1585
- let t = i[e].cost === 0 ? "∞" : Ae.ammo[e] ?? 0;
1586
- return /* @__PURE__ */ P("button", {
1587
- type: "button",
1588
- role: "radio",
1589
- "aria-checked": _.ammo === e,
1590
- disabled: t === 0,
1591
- className: `tk-ammo-item${_.ammo === e ? " is-selected" : ""}`,
1592
- onClick: () => Y({ ammo: e }),
1593
- children: [
1594
- mt[e],
1595
- " ",
1596
- /* @__PURE__ */ N("small", { children: t })
1597
- ]
1598
- }, e);
1599
- })
1600
- }),
1601
- /* @__PURE__ */ P("button", {
1602
- type: "button",
1603
- className: "tk-fire",
1604
- disabled: !c || e.pending,
1605
- onClick: be,
1606
- children: [/* @__PURE__ */ N(k, {
1607
- size: 18,
1608
- "aria-hidden": "true"
1609
- }), "DISPARAR"]
1610
- })
1611
- ]
1612
- }),
1613
- e.status === "conflict" && /* @__PURE__ */ P(ie, { children: [e.error && /* @__PURE__ */ N("p", {
1614
- className: "chat-game-error",
1615
- role: "alert",
1616
- children: e.error
1617
- }), /* @__PURE__ */ N(bt, {
1618
- sync: e.sync,
1619
- connected: c,
1620
- onResync: () => G("requestResync", t),
1621
- onAdoptOffer: () => G("adoptResyncOffer", t)
1622
- })] }),
1623
- e.status !== "conflict" && e.error && /* @__PURE__ */ N("p", {
1624
- className: "chat-game-error",
1625
- role: "alert",
1626
- children: e.error
1627
- }),
1628
- C && /* @__PURE__ */ N("p", {
1629
- className: "chat-game-error",
1630
- role: "alert",
1631
- children: C
1632
- }),
1633
- e.pendingEvent && !e.pending && /* @__PURE__ */ N("div", {
1634
- className: "chat-game-actions",
1635
- children: /* @__PURE__ */ N("button", {
1636
- type: "button",
1637
- className: "chat-game-action chat-game-action--primary",
1638
- disabled: !c,
1639
- onClick: () => G("retry", t),
1640
- children: "Reintentar envío"
1641
- })
1642
- }),
1643
- e.status === "active" && U && /* @__PURE__ */ N("div", {
1644
- className: "chat-game-actions tk-secondary",
1645
- children: ae ? /* @__PURE__ */ P(ie, { children: [/* @__PURE__ */ N("button", {
1646
- type: "button",
1647
- className: "chat-game-action chat-game-action--danger",
1648
- onClick: () => {
1649
- F(!1), G("tkResign", t);
1650
- },
1651
- children: "Confirmar rendición"
1652
- }), /* @__PURE__ */ N("button", {
1653
- type: "button",
1654
- className: "chat-game-action",
1655
- onClick: () => F(!1),
1656
- children: "Cancelar"
1657
- })] }) : /* @__PURE__ */ P("button", {
1658
- type: "button",
1659
- className: "chat-game-action",
1660
- disabled: !c || !!e.pendingEvent,
1661
- onClick: () => F(!0),
1662
- children: [/* @__PURE__ */ N(A, {
1663
- size: 14,
1664
- "aria-hidden": "true"
1665
- }), "Rendirse"]
1666
- })
1667
- }),
1668
- [
1669
- "won",
1670
- "draw",
1671
- "closed"
1672
- ].includes(e.status) && U && /* @__PURE__ */ N("div", {
1673
- className: "chat-game-actions",
1674
- children: /* @__PURE__ */ P("button", {
1675
- type: "button",
1676
- className: "chat-game-action chat-game-action--primary",
1677
- disabled: !c,
1678
- onClick: De,
1679
- children: [/* @__PURE__ */ N(j, {
1680
- size: 14,
1681
- "aria-hidden": "true"
1682
- }), "Revancha"]
1683
- })
1684
- })
1685
- ]
1686
- });
1687
- }
1688
- function Tt({ gameKey: e, currentUserId: n, variant: r = "panel", onMinimize: i, onDismiss: a }) {
1689
- let o = t((t) => t.games[e]);
1690
- return o ? r === "history" ? /* @__PURE__ */ N(Ct, {
1691
- game: o,
1692
- currentUserId: n
1693
- }) : /* @__PURE__ */ N(wt, {
1694
- game: o,
1695
- gameKey: e,
1696
- currentUserId: n,
1697
- variant: r,
1698
- onMinimize: i,
1699
- onDismiss: a
1700
- }) : null;
1701
- }
1702
- var Et = x(Tt);
1703
- export { Et as default };
1704
-
1705
- //# sourceMappingURL=TanksGameCard-BEnXTz_J.js.map