speakid-build-a-sentence 1.0.24 → 1.0.26
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as a, jsxs as x } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
2
|
+
import { useState as c, useCallback as ge, useRef as oe, useEffect as V, useMemo as sn, Component as dn } from "react";
|
|
3
3
|
const an = `
|
|
4
4
|
@keyframes spin {
|
|
5
5
|
from { transform: rotate(0deg); }
|
|
@@ -173,50 +173,50 @@ const Te = {
|
|
|
173
173
|
// ===== Анимационные стили =====
|
|
174
174
|
...Te
|
|
175
175
|
}, ln = () => {
|
|
176
|
-
const [u, s] =
|
|
177
|
-
const
|
|
178
|
-
H.trim() ||
|
|
176
|
+
const [u, s] = c([]), S = ge((H, I, f) => {
|
|
177
|
+
const b = [];
|
|
178
|
+
H.trim() || b.push({
|
|
179
179
|
type: "empty",
|
|
180
180
|
message: "Sentence cannot be empty"
|
|
181
|
-
}), H.length > 41 &&
|
|
181
|
+
}), H.length > 41 && b.push({
|
|
182
182
|
type: "length",
|
|
183
183
|
message: `Sentence is too long (${H.length}/41 characters)`
|
|
184
|
-
}), H && !/^[a-zA-Z0-9\s.,!?;:'"-]*$/.test(H) &&
|
|
184
|
+
}), H && !/^[a-zA-Z0-9\s.,!?;:'"-]*$/.test(H) && b.push({
|
|
185
185
|
type: "characters",
|
|
186
186
|
message: "Only Latin characters, numbers, spaces and punctuation are allowed"
|
|
187
187
|
});
|
|
188
|
-
const
|
|
189
|
-
return
|
|
188
|
+
const W = f.findIndex((C, K) => K !== I && C.toLowerCase().trim() === H.toLowerCase().trim());
|
|
189
|
+
return W !== -1 && b.push({
|
|
190
190
|
type: "duplicate",
|
|
191
|
-
message: `Duplicate sentence (same as sentence ${
|
|
192
|
-
}), s(
|
|
193
|
-
isValid:
|
|
194
|
-
errors:
|
|
191
|
+
message: `Duplicate sentence (same as sentence ${W + 1})`
|
|
192
|
+
}), s(b), {
|
|
193
|
+
isValid: b.length === 0,
|
|
194
|
+
errors: b
|
|
195
195
|
};
|
|
196
196
|
}, []), se = ge((H) => {
|
|
197
197
|
const I = [];
|
|
198
|
-
return H.forEach((f,
|
|
199
|
-
const
|
|
200
|
-
I.push(...
|
|
201
|
-
...
|
|
202
|
-
message: `Sentence ${
|
|
198
|
+
return H.forEach((f, b) => {
|
|
199
|
+
const y = S(f, b, H);
|
|
200
|
+
I.push(...y.errors.map((W) => ({
|
|
201
|
+
...W,
|
|
202
|
+
message: `Sentence ${b + 1}: ${W.message}`
|
|
203
203
|
})));
|
|
204
204
|
}), {
|
|
205
205
|
isValid: I.length === 0,
|
|
206
206
|
errors: I
|
|
207
207
|
};
|
|
208
|
-
}, [
|
|
208
|
+
}, [S]), de = ge(() => {
|
|
209
209
|
s([]);
|
|
210
210
|
}, []);
|
|
211
211
|
return {
|
|
212
212
|
errors: u,
|
|
213
|
-
validateSentence:
|
|
213
|
+
validateSentence: S,
|
|
214
214
|
validateAllSentences: se,
|
|
215
215
|
clearErrors: de
|
|
216
216
|
};
|
|
217
|
-
}, cn = (u, s,
|
|
218
|
-
|
|
219
|
-
},
|
|
217
|
+
}, cn = (u, s, S) => s && S ? `${u} word "${s}" ${S}` : s ? `${u} word "${s}"` : u, hn = (u, s, S = ["Enter", " "]) => {
|
|
218
|
+
S.includes(u.key) && (u.preventDefault(), s());
|
|
219
|
+
}, L = (u) => {
|
|
220
220
|
const s = document.createElement("div");
|
|
221
221
|
s.setAttribute("aria-live", "polite"), s.setAttribute("aria-atomic", "true"), s.style.position = "absolute", s.style.left = "-10000px", s.style.width = "1px", s.style.height = "1px", s.style.overflow = "hidden", document.body.appendChild(s), s.textContent = u, setTimeout(() => {
|
|
222
222
|
document.body.removeChild(s);
|
|
@@ -254,7 +254,7 @@ const Te = {
|
|
|
254
254
|
s && s.remove(), document.head.appendChild(u);
|
|
255
255
|
}, gn = (u) => [...u].sort(() => Math.random() - 0.5);
|
|
256
256
|
function yn(u = {}) {
|
|
257
|
-
const { logoUrl: s, showLogo:
|
|
257
|
+
const { logoUrl: s, showLogo: S = !0 } = u, se = oe(null), { validateAllSentences: de, errors: H } = ln(), I = () => !!(d || window.innerWidth < 768 || window.innerWidth >= 768 && window.innerWidth < 1300), f = () => d || window.innerWidth < 768 || window.innerWidth >= 320 && window.innerWidth <= 932 && window.innerHeight >= 390 && window.innerHeight <= 932, b = (e = "medium") => {
|
|
258
258
|
if (!f())
|
|
259
259
|
return {
|
|
260
260
|
padding: "12px 24px",
|
|
@@ -282,15 +282,15 @@ function yn(u = {}) {
|
|
|
282
282
|
};
|
|
283
283
|
}
|
|
284
284
|
};
|
|
285
|
-
|
|
285
|
+
V(() => (pn(), () => {
|
|
286
286
|
document.documentElement.style.overflow = "", document.body.style.overflow = "";
|
|
287
287
|
const e = document.getElementById("magic-sentence-reset");
|
|
288
288
|
e && e.remove();
|
|
289
289
|
}), []);
|
|
290
|
-
const [
|
|
290
|
+
const [y, W] = c("select"), [C, K] = c(null), [ue, we] = c(null), [T, Z] = c([]), [D, fe] = c(0), [ae, me] = c([]), [k, le] = c([]), [B, xe] = c(20), [U, M] = c(0), [un, ye] = c(null), [A, z] = c(null), [l, _] = c(!1), [be, ce] = c(!1), [he, De] = c(
|
|
291
291
|
Number(localStorage.getItem("magicSentenceBest")) || 0
|
|
292
|
-
),
|
|
293
|
-
|
|
292
|
+
), J = oe(null), Re = oe(null), We = oe(0), [m, E] = c({ list: null, id: null, side: null }), [d, ze] = c(!1), [Ee, Q] = c(1), [Se, ee] = c(null), [Pe, Be] = c(!1), [$, Le] = c(!1), [O, Me] = c(!1), [N, Ae] = c(!1), [G, $e] = c(!1), [X, Oe] = c(!1), [j, Ne] = c(!1), [F, Ge] = c(!1), [q, Xe] = c(!1), [wn, je] = c(!1), [fn, Fe] = c(!1);
|
|
293
|
+
V(() => {
|
|
294
294
|
const e = () => {
|
|
295
295
|
const t = window.innerWidth, n = window.innerHeight, i = t < 768 || t === 926 && n === 428 || t === 932 && n === 430, r = n < 700, p = t / n > 1.8, w = t === 768 && n === 1024, o = t === 1024 && n === 768, h = t === 820 && n === 1180, R = t === 1180 && n === 820, v = t === 540 && n === 720, re = t === 720 && n === 540, He = t === 1024 && n === 1366, Ie = t === 1366 && n === 1024, Ce = t >= 1200 && n >= 600 && !i;
|
|
296
296
|
Be(Ce), Le(w), Me(o), Ae(h), $e(R), Oe(v), Ne(re), Ge(He), Xe(Ie), Fe(p);
|
|
@@ -312,15 +312,15 @@ function yn(u = {}) {
|
|
|
312
312
|
return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
313
313
|
}, []);
|
|
314
314
|
const ne = (e, t, n, i) => {
|
|
315
|
-
if (
|
|
315
|
+
if (l) return;
|
|
316
316
|
let r = [...ae], p = [...k];
|
|
317
317
|
const w = e === "bank" ? r : p, o = t === "bank" ? r : p, h = w.findIndex((re) => re.id === n);
|
|
318
318
|
if (h === -1) return;
|
|
319
319
|
const [R] = w.splice(h, 1);
|
|
320
320
|
let v = i;
|
|
321
321
|
e === t && v !== null && v !== void 0 && v > h && (v = v - 1), v == null || v < 0 || v > o.length ? o.push(R) : o.splice(v, 0, R), e === "bank" ? r = w : p = w, t === "bank" ? r = o : p = o, me(r), le(p);
|
|
322
|
-
},
|
|
323
|
-
if (e.preventDefault(),
|
|
322
|
+
}, Y = (e, t, n) => {
|
|
323
|
+
if (e.preventDefault(), l) {
|
|
324
324
|
E({ list: null, id: null, side: null });
|
|
325
325
|
return;
|
|
326
326
|
}
|
|
@@ -340,9 +340,9 @@ function yn(u = {}) {
|
|
|
340
340
|
E({ list: null, id: null, side: null });
|
|
341
341
|
}
|
|
342
342
|
}, qe = (e) => {
|
|
343
|
-
K(e), Re.current = e, Z(Array(e).fill("")),
|
|
343
|
+
K(e), Re.current = e, Z(Array(e).fill("")), W("time");
|
|
344
344
|
}, Ve = (e) => {
|
|
345
|
-
we(e),
|
|
345
|
+
we(e), W("type");
|
|
346
346
|
}, Ue = (e, t) => {
|
|
347
347
|
if (t.length > 41 || t && !/^[a-zA-Z0-9\s.,!?;:'"-]*$/.test(t))
|
|
348
348
|
return;
|
|
@@ -350,15 +350,18 @@ function yn(u = {}) {
|
|
|
350
350
|
i[e] = t, Z(i);
|
|
351
351
|
const r = de(i);
|
|
352
352
|
r.isValid || console.warn("Validation errors:", r.errors);
|
|
353
|
-
}, Je = (e) => e.trim().replace(/\s+/g, " "), ke = (e) =>
|
|
354
|
-
|
|
353
|
+
}, Je = (e) => e.trim().replace(/\s+/g, " "), ke = (e) => {
|
|
354
|
+
const t = window.innerWidth >= 768 && window.innerWidth < 1300;
|
|
355
|
+
return e <= 3 ? t ? 18 : 20 : e <= 5 ? t ? 16 : 18 : e <= 7 ? t ? 14 : 16 : e <= 9 ? t ? 12 : 14 : e <= 12 ? t ? 10 : 12 : t ? 9 : 10;
|
|
356
|
+
}, Ye = () => {
|
|
357
|
+
T.some((t) => t.trim().length === 0) || (Z((t) => t.map((n) => Je(n))), M(0), fe(0), We.current = 0, ye(null), W("getready"));
|
|
355
358
|
};
|
|
356
|
-
|
|
357
|
-
if (
|
|
359
|
+
V(() => {
|
|
360
|
+
if (y === "getready") {
|
|
358
361
|
const e = setTimeout(() => te(0), 3e3);
|
|
359
362
|
return () => clearTimeout(e);
|
|
360
363
|
}
|
|
361
|
-
}, [
|
|
364
|
+
}, [y]);
|
|
362
365
|
const te = (e) => {
|
|
363
366
|
const t = T[e];
|
|
364
367
|
if (!t) return;
|
|
@@ -368,46 +371,41 @@ function yn(u = {}) {
|
|
|
368
371
|
id: `${Date.now()}-${e}-${p}-${Math.random().toString(36).slice(2)}`,
|
|
369
372
|
text: r
|
|
370
373
|
}));
|
|
371
|
-
me(i), le([]), fe(e),
|
|
374
|
+
me(i), le([]), fe(e), We.current = e, xe(ue || 20), z(null), _(!1), ce(!1), W("play");
|
|
372
375
|
};
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
z(null);
|
|
382
|
-
return;
|
|
383
|
-
}
|
|
384
|
-
const t = e.trim().split(/\s+/), n = k.map((o) => o.text), i = t.filter((o) => !n.includes(o)).length, r = n.filter((o) => !t.includes(o)).length, p = t.filter((o, h) => n.includes(o) ? n[h] !== o : !1).length, w = i + r + p;
|
|
385
|
-
w === 0 ? (z("correct"), be || (ce(!0), L((o) => o + 1)), P("correct"), B("Correct! Well done!")) : w === 1 ? (z("almost"), L((o) => o + 0.5), P("half"), B("Almost correct! Just one mistake.")) : (z("wrong"), P("wrong"), B("Not quite right. Keep trying!"));
|
|
376
|
+
V(() => (y === "play" && !l && (J.current !== null && window.clearTimeout(J.current), B > 0 ? J.current = window.setTimeout(() => xe((e) => e - 1), 1e3) : _(!0)), () => {
|
|
377
|
+
J.current !== null && window.clearTimeout(J.current);
|
|
378
|
+
}), [y, B, l]), V(() => {
|
|
379
|
+
if (y === "play" && l && B === 0) {
|
|
380
|
+
const e = T[D];
|
|
381
|
+
if (!e) {
|
|
382
|
+
z(null);
|
|
383
|
+
return;
|
|
386
384
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
}
|
|
390
|
-
}, [
|
|
385
|
+
const t = e.trim().split(/\s+/), n = k.map((o) => o.text), i = t.filter((o) => !n.includes(o)).length, r = n.filter((o) => !t.includes(o)).length, p = t.filter((o, h) => n.includes(o) ? n[h] !== o : !1).length, w = i + r + p;
|
|
386
|
+
w === 0 ? (z("correct"), be || (ce(!0), M((o) => o + 1)), P("correct"), L("Correct! Well done!")) : w === 1 ? (z("almost"), M((o) => o + 0.5), P("half"), L("Almost correct! Just one mistake.")) : (z("wrong"), P("wrong"), L("Not quite right. Keep trying!"));
|
|
387
|
+
}
|
|
388
|
+
}, [y, l, B, T, D, k, be]);
|
|
391
389
|
const Ke = (e = !0) => {
|
|
392
390
|
if (e) {
|
|
393
|
-
if (
|
|
394
|
-
D + 1 < (C || 0) ? te(D + 1) : (
|
|
391
|
+
if (l) {
|
|
392
|
+
D + 1 < (C || 0) ? te(D + 1) : (W("results"), setTimeout(() => ie(), 600));
|
|
395
393
|
return;
|
|
396
394
|
}
|
|
397
395
|
const t = T[D];
|
|
398
396
|
if (!t) {
|
|
399
|
-
D + 1 < (C || 0) ? te(D + 1) : (
|
|
397
|
+
D + 1 < (C || 0) ? te(D + 1) : (W("results"), setTimeout(() => ie(), 600));
|
|
400
398
|
return;
|
|
401
399
|
}
|
|
402
400
|
const n = t.trim().split(/\s+/), i = k.map((h) => h.text), r = n.filter((h) => !i.includes(h)).length, p = i.filter((h) => !n.includes(h)).length, w = n.filter((h, R) => i.includes(h) ? i[R] !== h : !1).length, o = r + p + w;
|
|
403
|
-
o === 0 ? (
|
|
404
|
-
|
|
401
|
+
o === 0 ? (M((h) => h + 1), z("correct"), ce(!0), P("correct"), L("Correct! Well done!")) : o === 1 ? (M((h) => h + 0.5), z("almost"), P("half"), L("Almost correct! Just one mistake.")) : (z("wrong"), P("wrong"), L("Not quite right. Keep trying!")), D + 1 < (C || 0) ? setTimeout(() => te(D + 1), 800) : setTimeout(() => {
|
|
402
|
+
W("results"), setTimeout(() => ie(), 600);
|
|
405
403
|
}, 800);
|
|
406
404
|
}
|
|
407
405
|
};
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}, [
|
|
406
|
+
V(() => {
|
|
407
|
+
y === "results" && U > he && (De(U), localStorage.setItem("magicSentenceBest", String(U)));
|
|
408
|
+
}, [y, U, he]);
|
|
411
409
|
const P = (e) => {
|
|
412
410
|
const t = new (window.AudioContext || window.webkitAudioContext)(), n = t.createOscillator(), i = t.createGain();
|
|
413
411
|
switch (n.connect(i), i.connect(t.destination), e) {
|
|
@@ -457,7 +455,7 @@ function yn(u = {}) {
|
|
|
457
455
|
onClick: () => qe(e),
|
|
458
456
|
style: {
|
|
459
457
|
...g.gmButton,
|
|
460
|
-
...
|
|
458
|
+
...b("medium")
|
|
461
459
|
},
|
|
462
460
|
children: [
|
|
463
461
|
e,
|
|
@@ -479,7 +477,7 @@ function yn(u = {}) {
|
|
|
479
477
|
onClick: () => Ve(e),
|
|
480
478
|
style: {
|
|
481
479
|
...g.gmButton,
|
|
482
|
-
...
|
|
480
|
+
...b("medium")
|
|
483
481
|
},
|
|
484
482
|
children: [
|
|
485
483
|
e,
|
|
@@ -535,7 +533,7 @@ function yn(u = {}) {
|
|
|
535
533
|
marginTop: 30,
|
|
536
534
|
background: T.some((e) => e.trim().length === 0) ? "#ccc" : "#ec4c44",
|
|
537
535
|
cursor: T.some((e) => e.trim().length === 0) ? "not-allowed" : "pointer",
|
|
538
|
-
...
|
|
536
|
+
...b("large")
|
|
539
537
|
},
|
|
540
538
|
children: "PLAY"
|
|
541
539
|
}
|
|
@@ -556,7 +554,7 @@ function yn(u = {}) {
|
|
|
556
554
|
"/",
|
|
557
555
|
C,
|
|
558
556
|
" — ",
|
|
559
|
-
|
|
557
|
+
l ? "TIME'S UP!" : `Time: ${B}s`
|
|
560
558
|
] }),
|
|
561
559
|
/* @__PURE__ */ a(
|
|
562
560
|
"div",
|
|
@@ -574,8 +572,8 @@ function yn(u = {}) {
|
|
|
574
572
|
{
|
|
575
573
|
style: {
|
|
576
574
|
height: "100%",
|
|
577
|
-
width: `${
|
|
578
|
-
background:
|
|
575
|
+
width: `${B / (ue || 20) * 100}%`,
|
|
576
|
+
background: B <= 5 ? "#ec4c44" : "#4caf50",
|
|
579
577
|
transition: "width 1s linear"
|
|
580
578
|
}
|
|
581
579
|
}
|
|
@@ -586,7 +584,7 @@ function yn(u = {}) {
|
|
|
586
584
|
"div",
|
|
587
585
|
{
|
|
588
586
|
onDragOver: (e) => e.preventDefault(),
|
|
589
|
-
onDrop: (e) =>
|
|
587
|
+
onDrop: (e) => Y(e, "bank", null),
|
|
590
588
|
style: {
|
|
591
589
|
display: "flex",
|
|
592
590
|
flexWrap: I() ? "wrap" : "nowrap",
|
|
@@ -600,49 +598,50 @@ function yn(u = {}) {
|
|
|
600
598
|
children: ae.map((e, t) => /* @__PURE__ */ a(
|
|
601
599
|
"div",
|
|
602
600
|
{
|
|
603
|
-
draggable: !
|
|
601
|
+
draggable: !l,
|
|
604
602
|
role: "button",
|
|
605
|
-
tabIndex:
|
|
606
|
-
"aria-label":
|
|
603
|
+
tabIndex: l ? -1 : 0,
|
|
604
|
+
"aria-label": l ? `Word: ${e.text} (time expired)` : cn("Drag word", e.text, "to build sentence"),
|
|
607
605
|
onDragStart: (n) => {
|
|
608
|
-
if (
|
|
606
|
+
if (l) {
|
|
609
607
|
n.preventDefault();
|
|
610
608
|
return;
|
|
611
609
|
}
|
|
612
610
|
n.dataTransfer.setData(
|
|
613
611
|
"application/x-token",
|
|
614
612
|
JSON.stringify({ from: "bank", id: e.id })
|
|
615
|
-
), n.dataTransfer.setData("text/plain", e.id),
|
|
613
|
+
), n.dataTransfer.setData("text/plain", e.id), L(`Dragging word: ${e.text}`);
|
|
616
614
|
},
|
|
617
615
|
onKeyDown: (n) => {
|
|
618
|
-
|
|
616
|
+
l || hn(n, () => ne("bank", "selected", e.id, null));
|
|
619
617
|
},
|
|
620
618
|
onDragOver: (n) => n.preventDefault(),
|
|
621
619
|
onDrop: (n) => {
|
|
622
620
|
const i = n.currentTarget.getBoundingClientRect(), r = i.left + i.width / 2, p = n.clientX > r ? t + 1 : t;
|
|
623
|
-
E({ list: null, id: null, side: null }), n.stopPropagation(),
|
|
621
|
+
E({ list: null, id: null, side: null }), n.stopPropagation(), Y(n, "bank", p);
|
|
624
622
|
},
|
|
625
623
|
onDragEnter: (n) => {
|
|
626
|
-
if (
|
|
624
|
+
if (l) return;
|
|
627
625
|
const i = n.currentTarget.getBoundingClientRect(), r = i.left + i.width / 2;
|
|
628
626
|
E({ list: "bank", id: e.id, side: n.clientX > r ? "right" : "left" });
|
|
629
627
|
},
|
|
630
628
|
onDragLeave: () => E({ list: null, id: null, side: null }),
|
|
631
629
|
onClick: () => {
|
|
632
|
-
|
|
630
|
+
l || ne("bank", "selected", e.id, null);
|
|
633
631
|
},
|
|
634
632
|
style: {
|
|
635
633
|
padding: d || window.innerWidth < 768 ? "6px 10px" : "10px 16px",
|
|
636
634
|
borderRadius: d || window.innerWidth < 768 ? "6px" : "10px",
|
|
637
635
|
border: "1px solid #ccc",
|
|
638
|
-
background:
|
|
639
|
-
cursor:
|
|
640
|
-
fontSize: d || window.innerWidth < 768 ? "12px" : "18px",
|
|
636
|
+
background: l ? "#f0f0f0" : "#f9f9f9",
|
|
637
|
+
cursor: l ? "not-allowed" : m.list === "bank" && m.id === e.id ? "grabbing" : "grab",
|
|
638
|
+
fontSize: d || window.innerWidth < 768 ? "12px" : window.innerWidth >= 768 && window.innerWidth < 1300 ? "14px" : "18px",
|
|
639
|
+
// Полный размер только для Pro и больших экранов
|
|
641
640
|
...m.list === "bank" && m.id === e.id && m.side === "left" ? { borderLeft: "3px solid #3b82f6" } : {},
|
|
642
641
|
...m.list === "bank" && m.id === e.id && m.side === "right" ? { borderRight: "3px solid #3b82f6" } : {},
|
|
643
642
|
flexShrink: 0,
|
|
644
643
|
flexBasis: "auto",
|
|
645
|
-
opacity:
|
|
644
|
+
opacity: l ? 0.6 : 1,
|
|
646
645
|
transition: "opacity 0.3s ease, transform 0.2s ease",
|
|
647
646
|
...m.list === "bank" && m.id === e.id ? {
|
|
648
647
|
transform: "scale(1.05)",
|
|
@@ -662,14 +661,14 @@ function yn(u = {}) {
|
|
|
662
661
|
onDrop: (e) => {
|
|
663
662
|
const t = e.currentTarget.getBoundingClientRect(), n = Array.from(e.currentTarget.children);
|
|
664
663
|
if (n.length === 0) {
|
|
665
|
-
|
|
664
|
+
Y(e, "selected", 0);
|
|
666
665
|
return;
|
|
667
666
|
}
|
|
668
667
|
let i = k.length, r = 1 / 0;
|
|
669
668
|
n.forEach((p, w) => {
|
|
670
669
|
const o = p.getBoundingClientRect(), h = o.left + o.width / 2, R = Math.abs(e.clientX - h);
|
|
671
670
|
R < r && (r = R, i = e.clientX < h ? w : w + 1);
|
|
672
|
-
}), e.clientX > t.right - 30 && (i = k.length), e.clientX < t.left + 30 && (i = 0),
|
|
671
|
+
}), e.clientX > t.right - 30 && (i = k.length), e.clientX < t.left + 30 && (i = 0), Y(e, "selected", i);
|
|
673
672
|
},
|
|
674
673
|
style: {
|
|
675
674
|
minHeight: d || window.innerWidth < 768 ? "50px" : "70px",
|
|
@@ -679,7 +678,7 @@ function yn(u = {}) {
|
|
|
679
678
|
// Убираем ограничение максимальной ширины
|
|
680
679
|
minWidth: "245px",
|
|
681
680
|
// Минимальная ширина для растягивания
|
|
682
|
-
border:
|
|
681
|
+
border: A === "correct" ? "2px dashed #4caf50" : A === "almost" ? "2px dashed #ff9800" : A === "wrong" ? "2px dashed #f44336" : "2px dashed #ccc",
|
|
683
682
|
borderRadius: d || window.innerWidth < 768 ? "8px" : "12px",
|
|
684
683
|
padding: d || window.innerWidth < 768 ? "8px" : "12px",
|
|
685
684
|
display: "flex",
|
|
@@ -687,16 +686,16 @@ function yn(u = {}) {
|
|
|
687
686
|
alignItems: "center",
|
|
688
687
|
justifyContent: "center",
|
|
689
688
|
fontSize: `${ke(k.length)}px`,
|
|
690
|
-
background:
|
|
689
|
+
background: A === "correct" ? "#e8f5e8" : A === "almost" ? "#fff3e0" : A === "wrong" ? "#ffebee" : "#fafafa",
|
|
691
690
|
overflowX: I() ? "hidden" : "auto",
|
|
692
691
|
whiteSpace: I() ? "normal" : "nowrap"
|
|
693
692
|
},
|
|
694
693
|
children: k.map((e, t) => /* @__PURE__ */ a(
|
|
695
694
|
"span",
|
|
696
695
|
{
|
|
697
|
-
draggable: !
|
|
696
|
+
draggable: !l,
|
|
698
697
|
onDragStart: (n) => {
|
|
699
|
-
if (
|
|
698
|
+
if (l) {
|
|
700
699
|
n.preventDefault();
|
|
701
700
|
return;
|
|
702
701
|
}
|
|
@@ -708,27 +707,27 @@ function yn(u = {}) {
|
|
|
708
707
|
onDragOver: (n) => n.preventDefault(),
|
|
709
708
|
onDrop: (n) => {
|
|
710
709
|
const i = n.currentTarget.getBoundingClientRect(), r = i.left + i.width / 2, p = i.width * 0.25, w = n.clientX < r - p ? t : n.clientX > r + p || n.clientX > r ? t + 1 : t;
|
|
711
|
-
E({ list: null, id: null, side: null }), n.stopPropagation(),
|
|
710
|
+
E({ list: null, id: null, side: null }), n.stopPropagation(), Y(n, "selected", w);
|
|
712
711
|
},
|
|
713
712
|
onDragEnter: (n) => {
|
|
714
|
-
if (
|
|
713
|
+
if (l) return;
|
|
715
714
|
const i = n.currentTarget.getBoundingClientRect(), r = i.left + i.width / 2;
|
|
716
715
|
E({ list: "selected", id: e.id, side: n.clientX > r ? "right" : "left" });
|
|
717
716
|
},
|
|
718
717
|
onDragLeave: () => E({ list: null, id: null, side: null }),
|
|
719
718
|
onClick: () => {
|
|
720
|
-
|
|
719
|
+
l || ne("selected", "bank", e.id, null);
|
|
721
720
|
},
|
|
722
|
-
title:
|
|
721
|
+
title: l ? "Time expired" : "Click to remove back to bank",
|
|
723
722
|
style: {
|
|
724
723
|
padding: f() ? "4px 6px" : "6px 10px",
|
|
725
724
|
margin: f() ? "2px" : "4px",
|
|
726
725
|
borderRadius: f() ? "4px" : "8px",
|
|
727
|
-
background:
|
|
728
|
-
border:
|
|
726
|
+
background: l ? "#f0f0f0" : "#ffe9e7",
|
|
727
|
+
border: l ? "1px solid #ccc" : "1px solid #ec4c44",
|
|
729
728
|
...m.list === "selected" && m.id === e.id && m.side === "left" ? { borderLeft: "3px solid #3b82f6" } : {},
|
|
730
729
|
...m.list === "selected" && m.id === e.id && m.side === "right" ? { borderRight: "3px solid #3b82f6" } : {},
|
|
731
|
-
cursor:
|
|
730
|
+
cursor: l ? "not-allowed" : m.list === "selected" && m.id === e.id ? "grabbing" : "grab",
|
|
732
731
|
userSelect: "none",
|
|
733
732
|
fontSize: `${ke(k.length)}px`,
|
|
734
733
|
// Адаптивный размер шрифта для слов
|
|
@@ -736,7 +735,7 @@ function yn(u = {}) {
|
|
|
736
735
|
// Более плотный шрифт
|
|
737
736
|
whiteSpace: "nowrap",
|
|
738
737
|
// Запрещаем перенос слов
|
|
739
|
-
opacity:
|
|
738
|
+
opacity: l ? 0.6 : 1,
|
|
740
739
|
transition: "opacity 0.3s ease, transform 0.2s ease",
|
|
741
740
|
...m.list === "selected" && m.id === e.id ? {
|
|
742
741
|
transform: "scale(1.05)",
|
|
@@ -753,16 +752,16 @@ function yn(u = {}) {
|
|
|
753
752
|
"button",
|
|
754
753
|
{
|
|
755
754
|
onClick: () => Ke(!0),
|
|
756
|
-
disabled: !
|
|
755
|
+
disabled: !l && k.length === 0,
|
|
757
756
|
style: {
|
|
758
757
|
marginTop: f() ? "15px" : "30px",
|
|
759
758
|
fontSize: f() ? "14px" : "20px",
|
|
760
759
|
padding: f() ? "6px 12px" : "10px 24px",
|
|
761
760
|
borderRadius: f() ? "8px" : "12px",
|
|
762
|
-
background:
|
|
761
|
+
background: l || k.length > 0 ? "#ec4c44" : "#ccc",
|
|
763
762
|
color: "white",
|
|
764
763
|
border: "none",
|
|
765
|
-
cursor:
|
|
764
|
+
cursor: l || k.length > 0 ? "pointer" : "not-allowed"
|
|
766
765
|
},
|
|
767
766
|
children: "NEXT"
|
|
768
767
|
}
|
|
@@ -770,26 +769,26 @@ function yn(u = {}) {
|
|
|
770
769
|
] }), tn = () => /* @__PURE__ */ x("div", { style: g.gmCenterScreen, children: [
|
|
771
770
|
/* @__PURE__ */ a("h1", { style: {
|
|
772
771
|
...g.gmHeadline1,
|
|
773
|
-
marginTop: (d && window.innerWidth > window.innerHeight || window.innerWidth === 896 && window.innerHeight === 414 || window.innerWidth === 844 && window.innerHeight === 390 || window.innerWidth === 926 && window.innerHeight === 428 || window.innerWidth === 932 && window.innerHeight === 430 ||
|
|
774
|
-
marginBottom: d && window.innerWidth > window.innerHeight || window.innerWidth === 896 && window.innerHeight === 414 || window.innerWidth === 844 && window.innerHeight === 390 || window.innerWidth === 926 && window.innerHeight === 428 || window.innerWidth === 932 && window.innerHeight === 430 ||
|
|
772
|
+
marginTop: (d && window.innerWidth > window.innerHeight || window.innerWidth === 896 && window.innerHeight === 414 || window.innerWidth === 844 && window.innerHeight === 390 || window.innerWidth === 926 && window.innerHeight === 428 || window.innerWidth === 932 && window.innerHeight === 430 || $ || O || N || G || X || j || F || q, "0px"),
|
|
773
|
+
marginBottom: d && window.innerWidth > window.innerHeight || window.innerWidth === 896 && window.innerHeight === 414 || window.innerWidth === 844 && window.innerHeight === 390 || window.innerWidth === 926 && window.innerHeight === 428 || window.innerWidth === 932 && window.innerHeight === 430 || $ || O || N || G || X || j || F || q ? "2px" : "10px",
|
|
775
774
|
fontSize: d && window.innerWidth <= 375 && window.innerHeight <= 667 || window.innerWidth === 896 && window.innerHeight === 414 || window.innerWidth === 844 && window.innerHeight === 390 || window.innerWidth === 926 && window.innerHeight === 428 || window.innerWidth === 932 && window.innerHeight === 430 ? "32px" : "clamp(28px, 4vw, 40px)"
|
|
776
775
|
}, children: "Game Over 🎯" }),
|
|
777
776
|
/* @__PURE__ */ x("h2", { style: {
|
|
778
777
|
...g.gmHeadline2,
|
|
779
|
-
marginTop: (d && window.innerWidth > window.innerHeight || window.innerWidth === 896 && window.innerHeight === 414 || window.innerWidth === 844 && window.innerHeight === 390 || window.innerWidth === 926 && window.innerHeight === 428 || window.innerWidth === 932 && window.innerHeight === 430 ||
|
|
780
|
-
marginBottom: d && window.innerWidth > window.innerHeight || window.innerWidth === 896 && window.innerHeight === 414 || window.innerWidth === 844 && window.innerHeight === 390 || window.innerWidth === 926 && window.innerHeight === 428 || window.innerWidth === 932 && window.innerHeight === 430 ||
|
|
778
|
+
marginTop: (d && window.innerWidth > window.innerHeight || window.innerWidth === 896 && window.innerHeight === 414 || window.innerWidth === 844 && window.innerHeight === 390 || window.innerWidth === 926 && window.innerHeight === 428 || window.innerWidth === 932 && window.innerHeight === 430 || $ || O || N || G || X || j || F || q, "0px"),
|
|
779
|
+
marginBottom: d && window.innerWidth > window.innerHeight || window.innerWidth === 896 && window.innerHeight === 414 || window.innerWidth === 844 && window.innerHeight === 390 || window.innerWidth === 926 && window.innerHeight === 428 || window.innerWidth === 932 && window.innerHeight === 430 || $ || O || N || G || X || j || F || q ? "2px" : "16px",
|
|
781
780
|
fontSize: d && window.innerWidth <= 375 && window.innerHeight <= 667 || window.innerWidth === 896 && window.innerHeight === 414 || window.innerWidth === 844 && window.innerHeight === 390 || window.innerWidth === 926 && window.innerHeight === 428 || window.innerWidth === 932 && window.innerHeight === 430 ? "18px" : "24px"
|
|
782
781
|
}, children: [
|
|
783
782
|
"Your score: ",
|
|
784
|
-
|
|
783
|
+
U,
|
|
785
784
|
" out of ",
|
|
786
785
|
C
|
|
787
786
|
] }),
|
|
788
787
|
/* @__PURE__ */ x("p", { style: {
|
|
789
788
|
...g.gmBodyM,
|
|
790
789
|
color: "#10b981",
|
|
791
|
-
marginTop: d && window.innerWidth > window.innerHeight || window.innerWidth === 896 && window.innerHeight === 414 || window.innerWidth === 844 && window.innerHeight === 390 || window.innerWidth === 926 && window.innerHeight === 428 || window.innerWidth === 932 && window.innerHeight === 430 ||
|
|
792
|
-
marginBottom: d && window.innerWidth > window.innerHeight || window.innerWidth === 896 && window.innerHeight === 414 || window.innerWidth === 844 && window.innerHeight === 390 || window.innerWidth === 926 && window.innerHeight === 428 || window.innerWidth === 932 && window.innerHeight === 430 ||
|
|
790
|
+
marginTop: d && window.innerWidth > window.innerHeight || window.innerWidth === 896 && window.innerHeight === 414 || window.innerWidth === 844 && window.innerHeight === 390 || window.innerWidth === 926 && window.innerHeight === 428 || window.innerWidth === 932 && window.innerHeight === 430 || $ || O || N || G || X || j || F || q ? "0px" : "12px",
|
|
791
|
+
marginBottom: d && window.innerWidth > window.innerHeight || window.innerWidth === 896 && window.innerHeight === 414 || window.innerWidth === 844 && window.innerHeight === 390 || window.innerWidth === 926 && window.innerHeight === 428 || window.innerWidth === 932 && window.innerHeight === 430 || $ || O || N || G || X || j || F || q ? "2px" : "16px",
|
|
793
792
|
fontSize: d && window.innerWidth <= 375 && window.innerHeight <= 667 || window.innerWidth === 896 && window.innerHeight === 414 || window.innerWidth === 844 && window.innerHeight === 390 || window.innerWidth === 926 && window.innerHeight === 428 || window.innerWidth === 932 && window.innerHeight === 430 ? "14px" : "16px"
|
|
794
793
|
}, children: [
|
|
795
794
|
"Best score: ",
|
|
@@ -805,12 +804,12 @@ function yn(u = {}) {
|
|
|
805
804
|
{
|
|
806
805
|
onClick: () => {
|
|
807
806
|
ie(), P("start"), setTimeout(() => {
|
|
808
|
-
|
|
807
|
+
W("getready"), ye(null), _(!1);
|
|
809
808
|
}, 800);
|
|
810
809
|
},
|
|
811
810
|
style: {
|
|
812
811
|
...g.gmButton,
|
|
813
|
-
...
|
|
812
|
+
...b("medium")
|
|
814
813
|
},
|
|
815
814
|
children: "🔁 Play again"
|
|
816
815
|
}
|
|
@@ -819,17 +818,17 @@ function yn(u = {}) {
|
|
|
819
818
|
"button",
|
|
820
819
|
{
|
|
821
820
|
onClick: () => {
|
|
822
|
-
P("click"),
|
|
821
|
+
P("click"), W("select"), K(null), we(null), Z([]), M(0), le([]), _(!1);
|
|
823
822
|
},
|
|
824
823
|
style: {
|
|
825
824
|
...g.gmButton,
|
|
826
|
-
...
|
|
825
|
+
...b("medium")
|
|
827
826
|
},
|
|
828
827
|
children: "⬅️ Exit"
|
|
829
828
|
}
|
|
830
829
|
)
|
|
831
830
|
] })
|
|
832
|
-
] }), ve = !d &&
|
|
831
|
+
] }), ve = !d && S, rn = sn(
|
|
833
832
|
() => {
|
|
834
833
|
if (d && window.innerWidth > window.innerHeight || window.innerHeight < 700 || !ve)
|
|
835
834
|
return null;
|
|
@@ -881,8 +880,8 @@ function yn(u = {}) {
|
|
|
881
880
|
"div",
|
|
882
881
|
{
|
|
883
882
|
style: {
|
|
884
|
-
width: d ? "100%" :
|
|
885
|
-
height: d ? "100%" :
|
|
883
|
+
width: d ? "100%" : Se || 1e3,
|
|
884
|
+
height: d ? "100%" : Se || 1e3,
|
|
886
885
|
display: "flex",
|
|
887
886
|
justifyContent: "center",
|
|
888
887
|
alignItems: "center",
|
|
@@ -909,12 +908,12 @@ function yn(u = {}) {
|
|
|
909
908
|
},
|
|
910
909
|
children: /* @__PURE__ */ x("div", { id: "magic-sentence-root", children: [
|
|
911
910
|
rn,
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
911
|
+
y === "select" ? Ze() : null,
|
|
912
|
+
y === "time" ? _e() : null,
|
|
913
|
+
y === "type" ? Qe() : null,
|
|
914
|
+
y === "getready" ? en() : null,
|
|
915
|
+
y === "play" ? nn() : null,
|
|
916
|
+
y === "results" ? tn() : null
|
|
918
917
|
] })
|
|
919
918
|
}
|
|
920
919
|
)
|
|
@@ -933,10 +932,10 @@ class bn extends dn {
|
|
|
933
932
|
error: s
|
|
934
933
|
};
|
|
935
934
|
}
|
|
936
|
-
componentDidCatch(s,
|
|
937
|
-
console.error("Game Error:", s,
|
|
935
|
+
componentDidCatch(s, S) {
|
|
936
|
+
console.error("Game Error:", s, S), this.setState({
|
|
938
937
|
error: s,
|
|
939
|
-
errorInfo:
|
|
938
|
+
errorInfo: S
|
|
940
939
|
});
|
|
941
940
|
}
|
|
942
941
|
handleReset = () => {
|
|
@@ -996,7 +995,7 @@ class bn extends dn {
|
|
|
996
995
|
export {
|
|
997
996
|
bn as ErrorBoundary,
|
|
998
997
|
yn as Game,
|
|
999
|
-
|
|
998
|
+
L as announceToScreenReader,
|
|
1000
999
|
cn as createAriaLabel,
|
|
1001
1000
|
yn as default,
|
|
1002
1001
|
hn as handleKeyDown,
|