@js-gamifications/word-search-react 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,699 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ WordSearchBoard: () => WordSearchBoard
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+
27
+ // src/wordSearchBoard.tsx
28
+ var import_word_search_core = require("@js-gamifications/word-search-core");
29
+ var import_react = require("react");
30
+ var import_jsx_runtime = require("react/jsx-runtime");
31
+ function playSound(frequency, duration) {
32
+ const audioContext = new (window.AudioContext || window.webkitAudioContext)();
33
+ const oscillator = audioContext.createOscillator();
34
+ const gainNode = audioContext.createGain();
35
+ oscillator.connect(gainNode);
36
+ gainNode.connect(audioContext.destination);
37
+ oscillator.frequency.value = frequency;
38
+ oscillator.type = "sine";
39
+ gainNode.gain.setValueAtTime(0.3, audioContext.currentTime);
40
+ gainNode.gain.exponentialRampToValueAtTime(0.01, audioContext.currentTime + duration);
41
+ oscillator.start(audioContext.currentTime);
42
+ oscillator.stop(audioContext.currentTime + duration);
43
+ }
44
+ function playSuccessSound() {
45
+ playSound(800, 0.15);
46
+ setTimeout(() => {
47
+ playSound(1e3, 0.15);
48
+ }, 150);
49
+ }
50
+ function playWinnerSound() {
51
+ playSound(523.25, 0.2);
52
+ setTimeout(() => {
53
+ playSound(659.25, 0.2);
54
+ }, 220);
55
+ setTimeout(() => {
56
+ playSound(783.99, 0.4);
57
+ }, 440);
58
+ }
59
+ var TRANSLATIONS = {
60
+ ES: {
61
+ title: "B\xFAsqueda de Palabras",
62
+ found: "encontradas",
63
+ instructions: "Haz clic y arrastra sobre las letras para seleccionar una palabra.",
64
+ clearProgress: "Reiniciar",
65
+ newPuzzle: "Nuevo Juego",
66
+ words: "Palabras",
67
+ allWordsFound: "Todas las palabras encontradas",
68
+ squareText: "El tablero se muestra en un contenedor cuadrado para un seguimiento m\xE1s f\xE1cil.",
69
+ timer: "Tiempo",
70
+ completionTitle: "Puzzle completado",
71
+ completionMessage: "Excelente trabajo, encontraste todas las palabras.",
72
+ completionTime: "Tiempo total",
73
+ completionWords: "Palabras encontradas",
74
+ completionGrid: "Tamanio de tablero",
75
+ completionDiagonal: "Diagonal habilitada",
76
+ completionAt: "Completado a las",
77
+ yes: "Si",
78
+ no: "No"
79
+ },
80
+ EN: {
81
+ title: "Word Search",
82
+ found: "found",
83
+ instructions: "Hold click and drag over letters to select a word.",
84
+ clearProgress: "Clear Progress",
85
+ newPuzzle: "New Puzzle",
86
+ words: "Words",
87
+ allWordsFound: "All words found",
88
+ squareText: "Board is rendered in a square container for easier tracking.",
89
+ timer: "Time",
90
+ completionTitle: "Puzzle Completed",
91
+ completionMessage: "Great job, you found every word.",
92
+ completionTime: "Total time",
93
+ completionWords: "Words found",
94
+ completionGrid: "Grid size",
95
+ completionDiagonal: "Diagonal enabled",
96
+ completionAt: "Completed at",
97
+ yes: "Yes",
98
+ no: "No"
99
+ },
100
+ AR: {
101
+ title: "\u0627\u0644\u0628\u062D\u062B \u0639\u0646 \u0627\u0644\u0643\u0644\u0645\u0627\u062A",
102
+ found: "\u0645\u0648\u062C\u0648\u062F\u0629",
103
+ instructions: "\u0627\u0636\u063A\u0637 \u0648\u0627\u0633\u062D\u0628 \u0641\u0648\u0642 \u0627\u0644\u062D\u0631\u0648\u0641 \u0644\u062A\u062D\u062F\u064A\u062F \u0643\u0644\u0645\u0629",
104
+ clearProgress: "\u0645\u0633\u062D \u0627\u0644\u062A\u0642\u062F\u0645",
105
+ newPuzzle: "\u0644\u0639\u0628\u0629 \u062C\u062F\u064A\u062F\u0629",
106
+ words: "\u0627\u0644\u0643\u0644\u0645\u0627\u062A",
107
+ allWordsFound: "\u062A\u0645 \u0627\u0644\u0639\u062B\u0648\u0631 \u0639\u0644\u0649 \u062C\u0645\u064A\u0639 \u0627\u0644\u0643\u0644\u0645\u0627\u062A",
108
+ squareText: "\u064A\u062A\u0645 \u062A\u0642\u062F\u064A\u0645 \u0627\u0644\u0644\u0648\u062D\u0629 \u0641\u064A \u062D\u0627\u0648\u064A\u0629 \u0645\u0631\u0628\u0639\u0629 \u0644\u062A\u062A\u0628\u0639 \u0623\u0633\u0647\u0644",
109
+ timer: "\u0627\u0644\u0648\u0642\u062A",
110
+ completionTitle: "\u0627\u0643\u062A\u0645\u0644 \u0627\u0644\u0644\u063A\u0632",
111
+ completionMessage: "\u0639\u0645\u0644 \u0631\u0627\u0626\u0639\u060C \u0644\u0642\u062F \u0639\u062B\u0631\u062A \u0639\u0644\u0649 \u062C\u0645\u064A\u0639 \u0627\u0644\u0643\u0644\u0645\u0627\u062A",
112
+ completionTime: "\u0627\u0644\u0648\u0642\u062A \u0627\u0644\u0643\u0644\u064A",
113
+ completionWords: "\u0627\u0644\u0643\u0644\u0645\u0627\u062A \u0627\u0644\u062A\u064A \u062A\u0645 \u0627\u0644\u0639\u062B\u0648\u0631 \u0639\u0644\u064A\u0647\u0627",
114
+ completionGrid: "\u062D\u062C\u0645 \u0627\u0644\u0634\u0628\u0643\u0629",
115
+ completionDiagonal: "\u0627\u0644\u0642\u0637\u0631\u064A \u0645\u0641\u0639\u0644",
116
+ completionAt: "\u0627\u0643\u062A\u0645\u0644 \u0641\u064A",
117
+ yes: "\u0646\u0639\u0645",
118
+ no: "\u0644\u0627"
119
+ }
120
+ };
121
+ function toCellKey(cell) {
122
+ return `${cell.row}:${cell.col}`;
123
+ }
124
+ function normalizeWord(word) {
125
+ return word.trim().toUpperCase().replace(/\s+/g, "");
126
+ }
127
+ function buildPath(start, end) {
128
+ const rowDiff = end.row - start.row;
129
+ const colDiff = end.col - start.col;
130
+ const absRowDiff = Math.abs(rowDiff);
131
+ const absColDiff = Math.abs(colDiff);
132
+ const isHorizontal = rowDiff === 0;
133
+ const isVertical = colDiff === 0;
134
+ const isDiagonal = absRowDiff === absColDiff;
135
+ if (!isHorizontal && !isVertical && !isDiagonal) {
136
+ return [start];
137
+ }
138
+ const rowStep = rowDiff === 0 ? 0 : rowDiff / absRowDiff;
139
+ const colStep = colDiff === 0 ? 0 : colDiff / absColDiff;
140
+ const steps = Math.max(absRowDiff, absColDiff);
141
+ return Array.from({ length: steps + 1 }, (_, index) => ({
142
+ row: start.row + rowStep * index,
143
+ col: start.col + colStep * index
144
+ }));
145
+ }
146
+ function toPathFromPlacement(placement) {
147
+ return Array.from({ length: placement.word.length }, (_, index) => ({
148
+ row: placement.startRow + placement.deltaRow * index,
149
+ col: placement.startCol + placement.deltaCol * index
150
+ }));
151
+ }
152
+ function matchesPlacement(path, placement) {
153
+ if (path.length !== placement.word.length) {
154
+ return false;
155
+ }
156
+ const expectedForward = toPathFromPlacement(placement);
157
+ const forwardMatch = expectedForward.every((expectedCell, index) => {
158
+ const selected = path[index];
159
+ return selected?.row === expectedCell.row && selected?.col === expectedCell.col;
160
+ });
161
+ if (forwardMatch) {
162
+ return true;
163
+ }
164
+ return expectedForward.every((expectedCell, index) => {
165
+ const selected = path[path.length - 1 - index];
166
+ return selected?.row === expectedCell.row && selected?.col === expectedCell.col;
167
+ });
168
+ }
169
+ function WordSearchBoard(props) {
170
+ const [puzzleSeed, setPuzzleSeed] = (0, import_react.useState)(0);
171
+ const [language, setLanguage] = (0, import_react.useState)("EN");
172
+ const [elapsedSeconds, setElapsedSeconds] = (0, import_react.useState)(0);
173
+ const [showCelebration, setShowCelebration] = (0, import_react.useState)(false);
174
+ const [completionReport, setCompletionReport] = (0, import_react.useState)(null);
175
+ const t = TRANSLATIONS[language];
176
+ const puzzle = (0, import_react.useMemo)(() => {
177
+ const options = {
178
+ rows: props.rows,
179
+ cols: props.cols,
180
+ words: props.words
181
+ };
182
+ if (props.allowDiagonal !== void 0) {
183
+ Object.assign(options, { allowDiagonal: props.allowDiagonal });
184
+ }
185
+ const generated = (0, import_word_search_core.createWordSearch)(options);
186
+ props.onGenerated?.(generated);
187
+ return generated;
188
+ }, [props.rows, props.cols, props.words, props.allowDiagonal, props.onGenerated, puzzleSeed]);
189
+ const normalizedInputWords = (0, import_react.useMemo)(
190
+ () => props.words.map(normalizeWord).filter(Boolean),
191
+ [props.words]
192
+ );
193
+ const [foundWords, setFoundWords] = (0, import_react.useState)(/* @__PURE__ */ new Set());
194
+ const [isDragging, setIsDragging] = (0, import_react.useState)(false);
195
+ const [dragStart, setDragStart] = (0, import_react.useState)(null);
196
+ const [dragCurrent, setDragCurrent] = (0, import_react.useState)(null);
197
+ (0, import_react.useEffect)(() => {
198
+ setFoundWords(/* @__PURE__ */ new Set());
199
+ setIsDragging(false);
200
+ setDragStart(null);
201
+ setDragCurrent(null);
202
+ setElapsedSeconds(0);
203
+ setShowCelebration(false);
204
+ setCompletionReport(null);
205
+ }, [puzzle]);
206
+ (0, import_react.useEffect)(() => {
207
+ const interval = setInterval(() => {
208
+ setElapsedSeconds((previous) => previous + 1);
209
+ }, 1e3);
210
+ return () => {
211
+ clearInterval(interval);
212
+ };
213
+ }, []);
214
+ const formatTime = (seconds) => {
215
+ const hours = Math.floor(seconds / 3600);
216
+ const minutes = Math.floor(seconds % 3600 / 60);
217
+ const secs = seconds % 60;
218
+ if (hours > 0) {
219
+ return `${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}:${String(secs).padStart(2, "0")}`;
220
+ }
221
+ return `${String(minutes).padStart(2, "0")}:${String(secs).padStart(2, "0")}`;
222
+ };
223
+ const currentPath = (0, import_react.useMemo)(() => {
224
+ if (!dragStart || !dragCurrent) {
225
+ return [];
226
+ }
227
+ return buildPath(dragStart, dragCurrent);
228
+ }, [dragStart, dragCurrent]);
229
+ const foundPlacements = (0, import_react.useMemo)(
230
+ () => puzzle.placements.filter((placement) => foundWords.has(placement.word)),
231
+ [puzzle.placements, foundWords]
232
+ );
233
+ const foundCellKeys = (0, import_react.useMemo)(() => {
234
+ const result = /* @__PURE__ */ new Set();
235
+ for (const placement of foundPlacements) {
236
+ for (const cell of toPathFromPlacement(placement)) {
237
+ result.add(toCellKey(cell));
238
+ }
239
+ }
240
+ return result;
241
+ }, [foundPlacements]);
242
+ const currentPathKeys = (0, import_react.useMemo)(() => {
243
+ const result = /* @__PURE__ */ new Set();
244
+ for (const cell of currentPath) {
245
+ result.add(toCellKey(cell));
246
+ }
247
+ return result;
248
+ }, [currentPath]);
249
+ const pendingWords = (0, import_react.useMemo)(
250
+ () => normalizedInputWords.filter((word) => !foundWords.has(word)),
251
+ [normalizedInputWords, foundWords]
252
+ );
253
+ const completeSelection = () => {
254
+ if (!dragStart || !dragCurrent) {
255
+ setIsDragging(false);
256
+ setDragStart(null);
257
+ setDragCurrent(null);
258
+ return;
259
+ }
260
+ const path = buildPath(dragStart, dragCurrent);
261
+ const match = puzzle.placements.find((placement) => matchesPlacement(path, placement));
262
+ if (match) {
263
+ setFoundWords((previous) => {
264
+ const next = new Set(previous);
265
+ next.add(match.word);
266
+ playSuccessSound();
267
+ if (next.size === normalizedInputWords.length) {
268
+ const report = {
269
+ elapsedSeconds,
270
+ foundWords: next.size,
271
+ totalWords: normalizedInputWords.length,
272
+ rows: props.rows,
273
+ cols: props.cols,
274
+ allowDiagonal: props.allowDiagonal ?? true,
275
+ completedAt: (/* @__PURE__ */ new Date()).toISOString()
276
+ };
277
+ setTimeout(() => {
278
+ playWinnerSound();
279
+ setShowCelebration(true);
280
+ setCompletionReport(report);
281
+ props.onCompleted?.(report);
282
+ setTimeout(() => {
283
+ setShowCelebration(false);
284
+ }, 3e3);
285
+ }, 100);
286
+ }
287
+ return next;
288
+ });
289
+ }
290
+ setIsDragging(false);
291
+ setDragStart(null);
292
+ setDragCurrent(null);
293
+ };
294
+ (0, import_react.useEffect)(() => {
295
+ if (!isDragging) {
296
+ return;
297
+ }
298
+ const handleMouseUp = () => {
299
+ completeSelection();
300
+ };
301
+ window.addEventListener("mouseup", handleMouseUp);
302
+ return () => {
303
+ window.removeEventListener("mouseup", handleMouseUp);
304
+ };
305
+ }, [isDragging, dragStart, dragCurrent, puzzle.placements]);
306
+ const startSelection = (row, col) => {
307
+ setIsDragging(true);
308
+ setDragStart({ row, col });
309
+ setDragCurrent({ row, col });
310
+ };
311
+ const moveSelection = (row, col) => {
312
+ if (!isDragging) {
313
+ return;
314
+ }
315
+ setDragCurrent({ row, col });
316
+ };
317
+ const finishSelection = () => {
318
+ if (!isDragging) {
319
+ return;
320
+ }
321
+ completeSelection();
322
+ };
323
+ const resetProgress = () => {
324
+ setFoundWords(/* @__PURE__ */ new Set());
325
+ setIsDragging(false);
326
+ setDragStart(null);
327
+ setDragCurrent(null);
328
+ };
329
+ const generateNewPuzzle = () => {
330
+ resetProgress();
331
+ setPuzzleSeed((previous) => previous + 1);
332
+ };
333
+ const boardSize = (0, import_react.useMemo)(() => {
334
+ const maxDimension = Math.max(props.rows, props.cols);
335
+ return Math.min(560, Math.max(280, maxDimension * 38));
336
+ }, [props.rows, props.cols]);
337
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
338
+ "div",
339
+ {
340
+ className: props.className,
341
+ style: {
342
+ width: "100%",
343
+ borderRadius: "16px",
344
+ border: "1px solid #e4e4e7",
345
+ background: "linear-gradient(180deg, rgba(255, 255, 255, 1) 0%, rgba(248, 250, 252, 1) 100%)",
346
+ boxShadow: "0 10px 30px rgba(15, 23, 42, 0.06)",
347
+ padding: "16px",
348
+ position: "relative",
349
+ overflow: "hidden"
350
+ },
351
+ children: [
352
+ showCelebration && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
353
+ "div",
354
+ {
355
+ style: {
356
+ position: "absolute",
357
+ inset: 0,
358
+ pointerEvents: "none",
359
+ zIndex: 20,
360
+ borderRadius: "inherit"
361
+ },
362
+ children: [
363
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
364
+ "div",
365
+ {
366
+ style: {
367
+ position: "absolute",
368
+ inset: 0,
369
+ background: "linear-gradient(45deg, rgba(34, 197, 94, 0.3) 0%, rgba(34, 197, 94, 0) 100%)",
370
+ animation: "pulse 0.6s ease-out"
371
+ }
372
+ }
373
+ ),
374
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("style", { children: `
375
+ @keyframes pulse {
376
+ 0% { opacity: 1; }
377
+ 100% { opacity: 0; }
378
+ }
379
+ @keyframes bounce {
380
+ 0%, 100% { transform: scale(1); }
381
+ 50% { transform: scale(1.1); }
382
+ }
383
+ ` }),
384
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
385
+ "div",
386
+ {
387
+ style: {
388
+ position: "absolute",
389
+ top: "50%",
390
+ left: "50%",
391
+ transform: "translate(-50%, -50%)",
392
+ fontSize: "48px",
393
+ fontWeight: "bold",
394
+ color: "#22c55e",
395
+ animation: "bounce 0.6s ease-out",
396
+ textShadow: "0 4px 12px rgba(34, 197, 94, 0.4)"
397
+ },
398
+ children: "\u{1F389}"
399
+ }
400
+ )
401
+ ]
402
+ }
403
+ ),
404
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
405
+ "div",
406
+ {
407
+ style: {
408
+ display: "flex",
409
+ justifyContent: "space-between",
410
+ alignItems: "center",
411
+ marginBottom: "12px",
412
+ gap: "10px",
413
+ flexWrap: "wrap"
414
+ },
415
+ children: [
416
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
417
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { style: { fontSize: "16px", color: "#111827" }, children: t.title }),
418
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
419
+ "span",
420
+ {
421
+ style: {
422
+ fontSize: "12px",
423
+ color: "#374151",
424
+ background: "#f3f4f6",
425
+ padding: "4px 8px",
426
+ borderRadius: "999px"
427
+ },
428
+ children: [
429
+ foundWords.size,
430
+ "/",
431
+ normalizedInputWords.length,
432
+ " ",
433
+ t.found
434
+ ]
435
+ }
436
+ ),
437
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
438
+ "span",
439
+ {
440
+ style: {
441
+ fontSize: "12px",
442
+ color: "#374151",
443
+ background: "#f3f4f6",
444
+ padding: "4px 8px",
445
+ borderRadius: "999px"
446
+ },
447
+ children: [
448
+ t.timer,
449
+ ": ",
450
+ formatTime(elapsedSeconds)
451
+ ]
452
+ }
453
+ )
454
+ ] }),
455
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { fontSize: "12px", color: "#6b7280" }, children: t.instructions })
456
+ ]
457
+ }
458
+ ),
459
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
460
+ "div",
461
+ {
462
+ style: {
463
+ display: "flex",
464
+ justifyContent: "space-between",
465
+ alignItems: "center",
466
+ gap: "8px",
467
+ marginBottom: "12px",
468
+ flexWrap: "wrap"
469
+ },
470
+ children: [
471
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
472
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { style: { fontSize: "12px", color: "#6b7280", marginRight: "6px" }, children: "Language:" }),
473
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
474
+ "select",
475
+ {
476
+ value: language,
477
+ onChange: (event) => setLanguage(event.target.value),
478
+ style: {
479
+ fontSize: "12px",
480
+ padding: "4px 8px",
481
+ borderRadius: "6px",
482
+ border: "1px solid #d4d4d8",
483
+ background: "#ffffff",
484
+ cursor: "pointer"
485
+ },
486
+ children: [
487
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "EN", children: "English" }),
488
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "ES", children: "Espa\xF1ol" }),
489
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "AR", children: "\u0627\u0644\u0639\u0631\u0628\u064A\u0629" })
490
+ ]
491
+ }
492
+ )
493
+ ] }),
494
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", gap: "8px", alignItems: "center" }, children: [
495
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
496
+ "button",
497
+ {
498
+ type: "button",
499
+ onClick: resetProgress,
500
+ style: {
501
+ border: "1px solid #d4d4d8",
502
+ background: "#ffffff",
503
+ color: "#374151",
504
+ borderRadius: "8px",
505
+ fontSize: "12px",
506
+ padding: "6px 10px",
507
+ cursor: "pointer"
508
+ },
509
+ children: t.clearProgress
510
+ }
511
+ ),
512
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
513
+ "button",
514
+ {
515
+ type: "button",
516
+ onClick: generateNewPuzzle,
517
+ style: {
518
+ border: "1px solid #0ea5e9",
519
+ background: "#0ea5e9",
520
+ color: "#ffffff",
521
+ borderRadius: "4px",
522
+ fontSize: "12px",
523
+ padding: "6px 10px",
524
+ cursor: "pointer"
525
+ },
526
+ children: t.newPuzzle
527
+ }
528
+ )
529
+ ] })
530
+ ]
531
+ }
532
+ ),
533
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { width: "100%", display: "flex", justifyContent: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
534
+ "div",
535
+ {
536
+ style: {
537
+ width: `min(100%, ${boardSize}px)`,
538
+ aspectRatio: "1 / 1",
539
+ display: "grid",
540
+ gridTemplateColumns: `repeat(${props.cols}, minmax(0, 1fr))`,
541
+ gridTemplateRows: `repeat(${props.rows}, minmax(0, 1fr))`,
542
+ gap: "1px",
543
+ userSelect: "none",
544
+ touchAction: "none"
545
+ },
546
+ onMouseLeave: finishSelection,
547
+ children: puzzle.grid.flatMap(
548
+ (row, rowIndex) => row.map((cell, colIndex) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
549
+ "button",
550
+ {
551
+ type: "button",
552
+ onMouseDown: () => startSelection(rowIndex, colIndex),
553
+ onMouseEnter: () => moveSelection(rowIndex, colIndex),
554
+ onMouseUp: finishSelection,
555
+ style: {
556
+ display: "inline-flex",
557
+ width: "100%",
558
+ height: "100%",
559
+ minWidth: 0,
560
+ alignItems: "center",
561
+ justifyContent: "center",
562
+ border: "1px solid #d4d4d8",
563
+ borderRadius: "8px",
564
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace",
565
+ fontWeight: 700,
566
+ fontSize: "clamp(12px, 1.8vw, 16px)",
567
+ color: "#111827",
568
+ background: foundCellKeys.has(toCellKey({ row: rowIndex, col: colIndex })) ? "#bae6fd" : currentPathKeys.has(toCellKey({ row: rowIndex, col: colIndex })) ? "#e0f2fe" : "#ffffff",
569
+ cursor: "pointer",
570
+ transition: "background 120ms ease, transform 120ms ease"
571
+ },
572
+ children: cell
573
+ },
574
+ `${rowIndex}-${colIndex}`
575
+ ))
576
+ )
577
+ }
578
+ ) }),
579
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
580
+ "div",
581
+ {
582
+ style: {
583
+ marginTop: "14px",
584
+ display: "grid",
585
+ gridTemplateColumns: "1fr",
586
+ gap: "8px"
587
+ },
588
+ children: [
589
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { fontSize: "12px", color: "#6b7280" }, children: t.words }),
590
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap" }, children: normalizedInputWords.map((word) => {
591
+ const found = foundWords.has(word);
592
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
593
+ "span",
594
+ {
595
+ style: {
596
+ display: "inline-flex",
597
+ alignItems: "center",
598
+ padding: "6px 10px",
599
+ borderRadius: "999px",
600
+ border: found ? "1px solid #22c55e" : "1px solid #d4d4d8",
601
+ background: found ? "#dcfce7" : "#fafafa",
602
+ color: found ? "#166534" : "#3f3f46",
603
+ fontSize: "12px",
604
+ fontWeight: 600,
605
+ letterSpacing: "0.04em",
606
+ textDecoration: found ? "line-through" : "none",
607
+ textDecorationThickness: found ? "2px" : void 0,
608
+ textDecorationColor: found ? "#166534" : void 0
609
+ },
610
+ children: word
611
+ },
612
+ word
613
+ );
614
+ }) }),
615
+ pendingWords.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { fontSize: "12px", color: "#16a34a", fontWeight: 600 }, children: t.allWordsFound }) : null
616
+ ]
617
+ }
618
+ ),
619
+ completionReport ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
620
+ "div",
621
+ {
622
+ style: {
623
+ marginTop: "14px",
624
+ border: "1px solid #86efac",
625
+ background: "linear-gradient(180deg, #f0fdf4 0%, #dcfce7 100%)",
626
+ borderRadius: "12px",
627
+ padding: "12px"
628
+ },
629
+ children: [
630
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { fontSize: "14px", fontWeight: 700, color: "#166534", marginBottom: "4px" }, children: t.completionTitle }),
631
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { fontSize: "12px", color: "#166534", marginBottom: "10px" }, children: t.completionMessage }),
632
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
633
+ "div",
634
+ {
635
+ style: {
636
+ display: "grid",
637
+ gridTemplateColumns: "repeat(auto-fit, minmax(180px, 1fr))",
638
+ gap: "8px"
639
+ },
640
+ children: [
641
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { fontSize: "12px", color: "#14532d" }, children: [
642
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("strong", { children: [
643
+ t.completionTime,
644
+ ":"
645
+ ] }),
646
+ " ",
647
+ formatTime(completionReport.elapsedSeconds)
648
+ ] }),
649
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { fontSize: "12px", color: "#14532d" }, children: [
650
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("strong", { children: [
651
+ t.completionWords,
652
+ ":"
653
+ ] }),
654
+ " ",
655
+ completionReport.foundWords,
656
+ "/",
657
+ completionReport.totalWords
658
+ ] }),
659
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { fontSize: "12px", color: "#14532d" }, children: [
660
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("strong", { children: [
661
+ t.completionGrid,
662
+ ":"
663
+ ] }),
664
+ " ",
665
+ completionReport.rows,
666
+ "x",
667
+ completionReport.cols
668
+ ] }),
669
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { fontSize: "12px", color: "#14532d" }, children: [
670
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("strong", { children: [
671
+ t.completionDiagonal,
672
+ ":"
673
+ ] }),
674
+ " ",
675
+ completionReport.allowDiagonal ? t.yes : t.no
676
+ ] }),
677
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { fontSize: "12px", color: "#14532d" }, children: [
678
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("strong", { children: [
679
+ t.completionAt,
680
+ ":"
681
+ ] }),
682
+ " ",
683
+ new Date(completionReport.completedAt).toLocaleTimeString()
684
+ ] })
685
+ ]
686
+ }
687
+ )
688
+ ]
689
+ }
690
+ ) : null
691
+ ]
692
+ }
693
+ );
694
+ }
695
+ // Annotate the CommonJS export names for ESM import in node:
696
+ 0 && (module.exports = {
697
+ WordSearchBoard
698
+ });
699
+ //# sourceMappingURL=index.js.map