lido-player 0.0.2-alpha-49 → 0.0.2-alpha-43-dev

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 (159) hide show
  1. package/dist/cjs/{index-fe562525.js → index-6a69c33a.js} +36 -3
  2. package/dist/cjs/index.cjs.js +2 -2
  3. package/dist/cjs/{lido-avatar_19.cjs.entry.js → lido-avatar_21.cjs.entry.js} +431 -180
  4. package/dist/cjs/lido-player.cjs.js +2 -2
  5. package/dist/cjs/loader.cjs.js +2 -2
  6. package/dist/cjs/{utils-96ce5641.js → utils-079a5e7d.js} +1032 -165
  7. package/dist/collection/collection-manifest.json +2 -0
  8. package/dist/collection/components/calculator/lido-calculator.css +87 -0
  9. package/dist/collection/components/calculator/lido-calculator.js +321 -0
  10. package/dist/collection/components/cell/lido-cell.js +1 -1
  11. package/dist/collection/components/column/lido-col.js +1 -1
  12. package/dist/collection/components/container/lido-container.js +20 -1
  13. package/dist/collection/components/flashCard/lido-flash-card.js +1 -1
  14. package/dist/collection/components/float/lido-float.js +1 -1
  15. package/dist/collection/components/home/lido-home.js +9 -29
  16. package/dist/collection/components/keyboard/lido-keyboard.js +2 -2
  17. package/dist/collection/components/mathMatrix/lido-math-matrix.css +10 -2
  18. package/dist/collection/components/mathMatrix/lido-math-matrix.js +226 -20
  19. package/dist/collection/components/position/lido-pos.js +1 -1
  20. package/dist/collection/components/random/lido-random.js +1 -1
  21. package/dist/collection/components/row/lido-row.js +1 -1
  22. package/dist/collection/components/scale/lido-balance.css +114 -0
  23. package/dist/collection/components/scale/lido-balance.js +549 -0
  24. package/dist/collection/components/shape/lido-shape.js +1 -1
  25. package/dist/collection/components/slideFill/lido-slide-fill.js +1 -1
  26. package/dist/collection/components/text/lido-text.js +1 -1
  27. package/dist/collection/components/trace/lido-trace.js +49 -128
  28. package/dist/collection/components/wrap/lido-wrap.js +1 -1
  29. package/dist/collection/css/animation.css +21 -0
  30. package/dist/collection/css/index.css +45 -0
  31. package/dist/collection/stories/Templates/Fill-Up/fill-up.stories.js +24 -25
  32. package/dist/collection/stories/Templates/RocketGame/rocketGame.stories.js +0 -3
  33. package/dist/collection/stories/Templates/balancing/balancing.stories.js +67 -0
  34. package/dist/collection/stories/Templates/checker-block/checkerBlock.stories.js +156 -0
  35. package/dist/collection/stories/Templates/checkerBlock/checkerBlock.stories.js +49 -0
  36. package/dist/collection/stories/Templates/fillAnswer/fill-answer.stories.js +66 -0
  37. package/dist/collection/stories/Templates/foodJar/food-jar.stories.js +65 -0
  38. package/dist/collection/stories/Templates/matchBox/matchBox.stories.js +105 -0
  39. package/dist/collection/stories/Templates/matchBox/matchBox2.stories.js +92 -0
  40. package/dist/collection/stories/Templates/matchingCard/matching-card.stories.js +47 -0
  41. package/dist/collection/stories/Templates/multiplyBeeds/multiplyBeeds.stories.js +59 -0
  42. package/dist/collection/stories/Templates/nimbleTable/nimbleTable.stories.js +93 -0
  43. package/dist/collection/stories/Templates/numberBoardTwo/numberBoardTwo.stories.js +100 -0
  44. package/dist/collection/stories/Templates/numberPair/numberPair.stories.js +212 -0
  45. package/dist/collection/stories/Templates/order-tractor/order-tractor-ascending-order.stories.js +6 -7
  46. package/dist/collection/stories/Templates/order-tractor/order-tractor.stories.js +6 -7
  47. package/dist/collection/stories/Templates/questionBoard/questionBoard.stories.js +158 -0
  48. package/dist/collection/stories/Templates/sequenceBox/sequenceBox1.stories.js +102 -0
  49. package/dist/collection/stories/Templates/sequenceBox/sequenceBox2.stories.js +94 -0
  50. package/dist/collection/stories/Templates/shapePair/shape-pair.stories.js +184 -0
  51. package/dist/collection/stories/Templates/shapeTractor/shape-tractor.stories.js +213 -0
  52. package/dist/collection/stories/Templates/sumTogether/sumTogether.stories.js +109 -0
  53. package/dist/collection/stories/Templates/total/total.stories.js +59 -0
  54. package/dist/collection/stories/Templates/writeNumber/writeNumber.stories.js +96 -0
  55. package/dist/collection/stories/Templates/writeSet/writeSet.stories.js +55 -0
  56. package/dist/collection/stories/Templates/writeWord/writeWord.stories.js +5 -6
  57. package/dist/collection/utils/utils.js +439 -81
  58. package/dist/collection/utils/utilsHandlers/clickHandler.js +21 -25
  59. package/dist/collection/utils/utilsHandlers/dragDropHandler.js +95 -42
  60. package/dist/collection/utils/utilsHandlers/lidoBalanceHandler.js +67 -0
  61. package/dist/collection/utils/utilsHandlers/lidoCalculatorHandler.js +94 -0
  62. package/dist/collection/utils/utilsHandlers/matrixHandler.js +298 -0
  63. package/dist/collection/utils/utilsHandlers/slideHandler.js +4 -2
  64. package/dist/collection/utils/utilsHandlers/sortHandler.js +21 -12
  65. package/dist/components/index.js +1 -1
  66. package/dist/components/lido-avatar.js +1 -1
  67. package/dist/components/lido-balance.d.ts +11 -0
  68. package/dist/components/lido-balance.js +6 -0
  69. package/dist/components/lido-calculator.d.ts +11 -0
  70. package/dist/components/lido-calculator.js +6 -0
  71. package/dist/components/lido-cell.js +1 -1
  72. package/dist/components/lido-col.js +1 -1
  73. package/dist/components/lido-container.js +1 -1
  74. package/dist/components/lido-flash-card.js +1 -1
  75. package/dist/components/lido-float.js +1 -1
  76. package/dist/components/lido-home.js +1 -1
  77. package/dist/components/lido-image.js +1 -1
  78. package/dist/components/lido-keyboard.js +1 -1
  79. package/dist/components/lido-math-matrix.js +1 -1
  80. package/dist/components/lido-pos.js +1 -1
  81. package/dist/components/lido-random.js +1 -1
  82. package/dist/components/lido-root.js +32 -20
  83. package/dist/components/lido-row.js +1 -1
  84. package/dist/components/lido-shape.js +1 -1
  85. package/dist/components/lido-slide-fill.js +1 -1
  86. package/dist/components/lido-text.js +1 -1
  87. package/dist/components/lido-trace.js +1 -1
  88. package/dist/components/lido-wrap.js +1 -1
  89. package/dist/components/p-08d0deab.js +254 -0
  90. package/dist/components/{p-b5b6ad27.js → p-15971ede.js} +1 -1
  91. package/dist/components/{p-0bf92c7f.js → p-1fbdb431.js} +2 -2
  92. package/dist/components/{p-b43ce4e1.js → p-29bdd953.js} +2 -2
  93. package/dist/components/{p-b8af26e6.js → p-322acda6.js} +40 -48
  94. package/dist/components/{p-51943db6.js → p-3f406017.js} +2 -2
  95. package/dist/components/p-44808985.js +186 -0
  96. package/dist/components/{p-4cabbf28.js → p-52844fa4.js} +2 -2
  97. package/dist/components/{p-4882df37.js → p-73e31a86.js} +2 -2
  98. package/dist/components/{p-af54a485.js → p-74849cdd.js} +4 -4
  99. package/dist/components/{p-9c56f378.js → p-7f7e5672.js} +2 -2
  100. package/dist/components/{p-4dbae73b.js → p-835b973d.js} +2 -2
  101. package/dist/components/{p-b55af747.js → p-90465904.js} +50 -129
  102. package/dist/components/{p-cae021c6.js → p-904711c8.js} +2 -2
  103. package/dist/components/{p-e735dce9.js → p-9be56729.js} +5 -3
  104. package/dist/components/{p-cac6c8bf.js → p-afbc196f.js} +2 -2
  105. package/dist/components/{p-cfa2aec8.js → p-bed94c37.js} +1047 -164
  106. package/dist/components/{p-7f11a624.js → p-cbac3cbc.js} +1 -1
  107. package/dist/components/{p-61d97438.js → p-d37ab4dc.js} +2 -2
  108. package/dist/components/p-e36ddcc1.js +166 -0
  109. package/dist/components/{p-03e4cafe.js → p-e4e42677.js} +2 -2
  110. package/dist/esm/{index-f47852d4.js → index-170e58c7.js} +36 -4
  111. package/dist/esm/index.js +2 -2
  112. package/dist/esm/{lido-avatar_19.entry.js → lido-avatar_21.entry.js} +430 -181
  113. package/dist/esm/lido-player.js +3 -3
  114. package/dist/esm/loader.js +3 -3
  115. package/dist/esm/{utils-9ce243d8.js → utils-5df09162.js} +1031 -164
  116. package/dist/lido-player/index.esm.js +1 -1
  117. package/dist/lido-player/lido-player.css +1 -1
  118. package/dist/lido-player/lido-player.esm.js +1 -1
  119. package/dist/lido-player/p-137c99ce.js +2 -0
  120. package/dist/lido-player/p-7556e652.js +9 -0
  121. package/dist/lido-player/p-eb956325.entry.js +1 -0
  122. package/dist/types/components/calculator/lido-calculator.d.ts +40 -0
  123. package/dist/types/components/container/lido-container.d.ts +4 -0
  124. package/dist/types/components/home/lido-home.d.ts +0 -1
  125. package/dist/types/components/mathMatrix/lido-math-matrix.d.ts +24 -4
  126. package/dist/types/components/scale/lido-balance.d.ts +160 -0
  127. package/dist/types/components/trace/lido-trace.d.ts +0 -1
  128. package/dist/types/components.d.ts +342 -14
  129. package/dist/types/stories/Templates/balancing/balancing.stories.d.ts +4 -0
  130. package/dist/types/stories/Templates/checker-block/checkerBlock.stories.d.ts +4 -0
  131. package/dist/types/stories/Templates/checkerBlock/checkerBlock.stories.d.ts +4 -0
  132. package/dist/types/stories/Templates/fillAnswer/fill-answer.stories.d.ts +4 -0
  133. package/dist/types/stories/Templates/foodJar/food-jar.stories.d.ts +4 -0
  134. package/dist/types/stories/Templates/matchBox/matchBox.stories.d.ts +4 -0
  135. package/dist/types/stories/Templates/matchBox/matchBox2.stories.d.ts +4 -0
  136. package/dist/types/stories/Templates/matchingCard/matching-card.stories.d.ts +4 -0
  137. package/dist/types/stories/Templates/multiplyBeeds/multiplyBeeds.stories.d.ts +9 -0
  138. package/dist/types/stories/Templates/nimbleTable/nimbleTable.stories.d.ts +4 -0
  139. package/dist/types/stories/Templates/numberBoardTwo/numberBoardTwo.stories.d.ts +4 -0
  140. package/dist/types/stories/Templates/numberPair/numberPair.stories.d.ts +4 -0
  141. package/dist/types/stories/Templates/questionBoard/questionBoard.stories.d.ts +15 -0
  142. package/dist/types/stories/Templates/sequenceBox/sequenceBox1.stories.d.ts +11 -0
  143. package/dist/types/stories/Templates/sequenceBox/sequenceBox2.stories.d.ts +11 -0
  144. package/dist/types/stories/Templates/shapePair/shape-pair.stories.d.ts +4 -0
  145. package/dist/types/stories/Templates/shapeTractor/shape-tractor.stories.d.ts +12 -0
  146. package/dist/types/stories/Templates/sumTogether/sumTogether.stories.d.ts +11 -0
  147. package/dist/types/stories/Templates/total/total.stories.d.ts +4 -0
  148. package/dist/types/stories/Templates/writeNumber/writeNumber.stories.d.ts +13 -0
  149. package/dist/types/stories/Templates/writeSet/writeSet.stories.d.ts +4 -0
  150. package/dist/types/utils/utils.d.ts +8 -2
  151. package/dist/types/utils/utilsHandlers/dragDropHandler.d.ts +4 -0
  152. package/dist/types/utils/utilsHandlers/lidoBalanceHandler.d.ts +2 -0
  153. package/dist/types/utils/utilsHandlers/lidoCalculatorHandler.d.ts +1 -0
  154. package/dist/types/utils/utilsHandlers/matrixHandler.d.ts +1 -0
  155. package/package.json +1 -1
  156. package/dist/components/p-a8ab771b.js +0 -160
  157. package/dist/lido-player/p-90212aa9.js +0 -9
  158. package/dist/lido-player/p-d3911ee1.entry.js +0 -1
  159. package/dist/lido-player/p-ddf627b0.js +0 -2
@@ -1,8 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const index$1 = require('./index-fe562525.js');
3
+ const index$1 = require('./index-6a69c33a.js');
4
4
 
5
- const DragSelectedMapKey = 'lidoDragSelectedMap';
6
5
  const DragMapKey = 'lidoDragMap';
7
6
  const SelectedValuesKey = 'lidoSelectedValues';
8
7
  const ActivityScoreKey = 'lidoActivityScore';
@@ -16,7 +15,6 @@ const GameExitKey = 'lidoGameExit';
16
15
  const ElementDropKey = 'lidoElementDrop';
17
16
  const ElementClickKey = 'lidoElementClick';
18
17
  const DropLength = 'dropLength';
19
- const DropHasDrag = 'dropHasDrag';
20
18
  const DropToAttr = 'drop-to';
21
19
  const DropTimeAttr = 'drop-time';
22
20
  const LidoContainer = 'lido-container';
@@ -161,6 +159,88 @@ function stopHighlightForSpeakingElement(element) {
161
159
  // element.style.border = '';
162
160
  }
163
161
 
162
+ function updateBalanceOnDrop(dragElement, dropElement) {
163
+ const balanceEl = document.querySelector('lido-balance');
164
+ if (!balanceEl)
165
+ return;
166
+ const leftDrag = Array.from(document.querySelectorAll('[drop-to^="lefthandle"]'));
167
+ const rightDrag = Array.from(document.querySelectorAll('[drop-to^="righthandle"]'));
168
+ balanceEl.leftVal = calculateValue(leftDrag, balanceEl.operation);
169
+ balanceEl.rightVal = calculateValue(rightDrag, balanceEl.operation);
170
+ console.log("leftpan:", balanceEl.leftVal, "rightpan:", balanceEl.rightVal);
171
+ if (balanceEl.updateTilt) {
172
+ balanceEl.updateTilt(balanceEl.leftVal, balanceEl.rightVal);
173
+ }
174
+ }
175
+ function calculateValue(elements, operation) {
176
+ if (elements.length === 0)
177
+ return 0;
178
+ if (operation === "count") {
179
+ return elements.length;
180
+ }
181
+ const ADD = ["add", "+"];
182
+ const SUBTRACT = ["subtract", "-"];
183
+ const MULTIPLY = ["multiply", "*"];
184
+ const DIVIDE = ["divide", "/"];
185
+ const expr = elements
186
+ .map(el => el.getAttribute("value") || "0")
187
+ .join(ADD.includes(operation) ? " + " :
188
+ SUBTRACT.includes(operation) ? " - " :
189
+ MULTIPLY.includes(operation) ? " * " :
190
+ DIVIDE.includes(operation) ? " / " : " + ");
191
+ try {
192
+ const res = equationCheck(expr);
193
+ if (typeof res === "number") {
194
+ return res;
195
+ }
196
+ else if (typeof res === "boolean") {
197
+ return res ? 1 : 0;
198
+ }
199
+ else {
200
+ return parseFloat(expr) || 0;
201
+ }
202
+ }
203
+ catch (e) {
204
+ console.warn("invalid exp", expr);
205
+ return 0;
206
+ }
207
+ }
208
+ function balanceResult(container, objectiveString) {
209
+ var _a, _b, _c, _d, _e, _f;
210
+ const additionalCheck = container.getAttribute('equationCheck');
211
+ if (!additionalCheck)
212
+ return false;
213
+ const balanceEl = document.querySelector('lido-balance');
214
+ if (!balanceEl)
215
+ return false;
216
+ const leftVal = Number((_c = (_a = balanceEl.leftVal) !== null && _a !== void 0 ? _a : (_b = balanceEl.dataset) === null || _b === void 0 ? void 0 : _b.leftVal) !== null && _c !== void 0 ? _c : 0);
217
+ const rightVal = Number((_f = (_d = balanceEl.rightVal) !== null && _d !== void 0 ? _d : (_e = balanceEl.dataset) === null || _e === void 0 ? void 0 : _e.rightVal) !== null && _f !== void 0 ? _f : 0);
218
+ const hasLeft = !isNaN(leftVal) && leftVal !== 0;
219
+ const hasRight = !isNaN(rightVal) && rightVal !== 0;
220
+ if (!hasLeft || !hasRight) {
221
+ return false;
222
+ }
223
+ const symbol = leftVal > rightVal ? '>' : leftVal < rightVal ? '<' : '=';
224
+ const res = objectiveString === symbol;
225
+ console.log("Result:", res);
226
+ return res;
227
+ }
228
+
229
+ function buildDropHasDragFromDOM() {
230
+ const dropHasDrag = {};
231
+ const dropElements = document.querySelectorAll("[type='drop']");
232
+ dropElements.forEach(drop => {
233
+ const tabIndex = drop.getAttribute("tab-index") || drop.id;
234
+ const assignedDrag = document.querySelector(`[${DropToAttr}="${drop.id}"]`);
235
+ const isFull = !!assignedDrag;
236
+ drop.setAttribute("is-full", String(isFull));
237
+ dropHasDrag[tabIndex] = {
238
+ drop: drop.id,
239
+ isFull
240
+ };
241
+ });
242
+ return dropHasDrag;
243
+ }
164
244
  // Function to get the scale of an element
165
245
  const getElementScale$1 = (el) => {
166
246
  el.style.animation = 'unset';
@@ -211,7 +291,7 @@ function enableDraggingWithScaling(element) {
211
291
  isDragging = false;
212
292
  return;
213
293
  }
214
- AudioPlayer.getI().stop();
294
+ // AudioPlayer.getI().stop();
215
295
  removeHighlight(element);
216
296
  isDragging = true;
217
297
  isClicked = true;
@@ -315,7 +395,6 @@ function enableDraggingWithScaling(element) {
315
395
  // Start observing the element
316
396
  observer.observe(container, observerConfig);
317
397
  const onMove = (event) => {
318
- console.log("moved");
319
398
  if (!isDragging)
320
399
  return;
321
400
  if (isDraggingDisabled) {
@@ -324,7 +403,7 @@ function enableDraggingWithScaling(element) {
324
403
  }
325
404
  isClicked = false;
326
405
  element.style.transition = 'none';
327
- const containerScale = calculateScale();
406
+ const containerScale = getElementScale$1(container);
328
407
  let dx = 0;
329
408
  let dy = 0;
330
409
  if (event instanceof MouseEvent) {
@@ -346,7 +425,7 @@ function enableDraggingWithScaling(element) {
346
425
  // Reset styles for all elements
347
426
  allElements.forEach(otherElement => {
348
427
  var _a;
349
- const dropObject = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
428
+ const dropObject = buildDragSelectedMapFromDOM();
350
429
  const storedTabIndexes = Object.keys(dropObject).map(Number);
351
430
  if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
352
431
  if (!(((_a = element.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
@@ -404,7 +483,7 @@ function enableDraggingWithScaling(element) {
404
483
  allElements.forEach(otherElement => {
405
484
  allElements.forEach(otherElement => {
406
485
  var _a;
407
- const dropObject = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
486
+ const dropObject = buildDragSelectedMapFromDOM();
408
487
  const storedTabIndexes = Object.keys(dropObject).map(Number);
409
488
  if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
410
489
  if (!(((_a = element.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
@@ -568,14 +647,18 @@ function handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedV
568
647
  let prevDropItem = Object.values(dropHasDrag).find(item => document.getElementById(item.drop) === currentDrop);
569
648
  if (prevDropItem) {
570
649
  prevDropItem.isFull = false;
571
- localStorage.setItem(DropHasDrag, JSON.stringify(dropHasDrag));
650
+ // container.setAttribute(DropHasDrag, JSON.stringify(dropHasDrag));
651
+ const dropEl = document.getElementById(prevDropItem.drop);
652
+ if (dropEl) {
653
+ dropEl.removeAttribute('is-full');
654
+ }
572
655
  }
573
656
  dragToDropMap.delete(dragElement);
574
657
  }
575
658
  if (selectedValueData) {
576
659
  let selectedValue = JSON.parse(selectedValueData);
577
660
  selectedValue = selectedValue.filter(value => value != dragElement['value']);
578
- localStorage.setItem(SelectedValuesKey, JSON.stringify(selectedValue));
661
+ container.setAttribute(SelectedValuesKey, JSON.stringify(selectedValue));
579
662
  }
580
663
  if (dragSelectedData) {
581
664
  let dragSelected = JSON.parse(dragSelectedData);
@@ -583,14 +666,15 @@ function handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedV
583
666
  if (dragPreDropElement) {
584
667
  delete dragSelected[dragPreDropElement.getAttribute('tab-index')];
585
668
  }
586
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragSelected));
669
+ // container.setAttribute(DragSelectedMapKey, JSON.stringify(dragSelected));
587
670
  dragElement.removeAttribute(DropToAttr);
588
671
  updateDropBorder(currentDrop);
672
+ updateBalanceOnDrop();
589
673
  }
590
674
  const allElements = document.querySelectorAll("[type='drop']");
591
675
  allElements.forEach(otherElement => {
592
676
  var _a;
593
- const dropObject = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
677
+ const dropObject = buildDragSelectedMapFromDOM();
594
678
  const storedTabIndexes = Object.keys(dropObject).map(Number);
595
679
  if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
596
680
  if (!(((_a = otherElement.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
@@ -615,20 +699,22 @@ function handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedV
615
699
  });
616
700
  handleShowCheck();
617
701
  }
702
+ const tempVanishedValues = [];
618
703
  async function onElementDropComplete(dragElement, dropElement) {
619
- var _a, _b, _c, _d, _e;
620
- const selectedValueData = localStorage.getItem(SelectedValuesKey) || '';
621
- const dragSelectedData = localStorage.getItem(DragSelectedMapKey);
622
- localStorage.getItem(DragMapKey);
623
- console.log("dragggedddd elem", { value: dragElement.getAttribute("value") });
624
- let dropHasDrag = JSON.parse(localStorage.getItem(DropHasDrag) || ' {}');
704
+ var _a, _b, _c, _d, _e, _f, _g, _h;
625
705
  const container = document.getElementById(LidoContainer);
706
+ const selectedValueData = (_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : "[]";
707
+ const dragSelectedData = JSON.stringify(buildDragSelectedMapFromDOM());
708
+ const dropSelectedDataobject = buildDragSelectedMapFromDOM();
709
+ JSON.stringify(dropSelectedDataobject);
710
+ console.log("dragggedddd elem", { value: dragElement.getAttribute("value") });
711
+ let dropHasDrag = buildDropHasDragFromDOM();
626
712
  if (!dropElement) {
627
713
  handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData);
628
714
  return;
629
715
  }
630
716
  const dropTabIndex = dropElement.getAttribute('tab-index');
631
- if ((_a = dropHasDrag[dropTabIndex]) === null || _a === void 0 ? void 0 : _a.isFull) {
717
+ if ((_b = dropHasDrag[dropTabIndex]) === null || _b === void 0 ? void 0 : _b.isFull) {
632
718
  handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData);
633
719
  return;
634
720
  }
@@ -640,9 +726,10 @@ async function onElementDropComplete(dragElement, dropElement) {
640
726
  handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData);
641
727
  return;
642
728
  }
729
+ // let isCorrect = dropElement.getAttribute('value').toLowerCase().includes(dragElement.getAttribute('value').toLowerCase());
643
730
  let isCorrect;
644
- const dragValue = ((_b = dragElement.getAttribute('value')) === null || _b === void 0 ? void 0 : _b.trim()) || "";
645
- const dropValue = ((_c = dropElement.getAttribute('value')) === null || _c === void 0 ? void 0 : _c.trim()) || "";
731
+ const dragValue = ((_c = dragElement.getAttribute('value')) === null || _c === void 0 ? void 0 : _c.trim()) || "";
732
+ const dropValue = ((_d = dropElement.getAttribute('value')) === null || _d === void 0 ? void 0 : _d.trim()) || "";
646
733
  if (Number(dragValue)) {
647
734
  const dragNum = Number(dragValue);
648
735
  //array of numbers
@@ -656,8 +743,7 @@ async function onElementDropComplete(dragElement, dropElement) {
656
743
  }
657
744
  }
658
745
  else {
659
- //strings
660
- isCorrect = dropValue.toLowerCase().includes(dragValue.toLowerCase());
746
+ isCorrect = dropElement.getAttribute('value').toLowerCase().includes(dragElement.getAttribute('value').toLowerCase());
661
747
  }
662
748
  if (!isCorrect) {
663
749
  dragElement.style.transition = 'transform 0.5s ease';
@@ -672,7 +758,7 @@ async function onElementDropComplete(dragElement, dropElement) {
672
758
  // delete stored[oldDropIndex];
673
759
  // localStorage.setItem(localStorageKey, JSON.stringify(stored));
674
760
  // }
675
- // handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData, dropSelectedData);
761
+ handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData);
676
762
  }, 500);
677
763
  if (dragElement['type'] === 'option') {
678
764
  const childs = Array.from(container.querySelectorAll(`[value="${dragElement['value']}"]`));
@@ -691,6 +777,7 @@ async function onElementDropComplete(dragElement, dropElement) {
691
777
  if (checkdropAttr && checkdropAttr.toLowerCase() === DropMode.EnableAnimation.toLowerCase()) {
692
778
  container.style.pointerEvents = "none";
693
779
  setTimeout(() => {
780
+ var _a, _b, _c;
694
781
  const div = document.createElement('div');
695
782
  container.append(div);
696
783
  div.classList.add('after-drop-popup-container');
@@ -699,6 +786,11 @@ async function onElementDropComplete(dragElement, dropElement) {
699
786
  const allDragElements = container.querySelectorAll('[type="drag"]');
700
787
  const dragParents = Array.from(allDragElements).map(el => el.parentElement);
701
788
  const allSameParent = dragParents.every(parent => parent === dragElement.parentElement);
789
+ JSON.parse((_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]');
790
+ const vanishedValue = (_b = dragElement.getAttribute('value')) !== null && _b !== void 0 ? _b : (_c = dragElement.textContent) === null || _c === void 0 ? void 0 : _c.trim();
791
+ if (vanishedValue) {
792
+ tempVanishedValues.push(vanishedValue);
793
+ }
702
794
  // Remove from old parents
703
795
  if (allSameParent) {
704
796
  dragElement.remove();
@@ -722,6 +814,16 @@ async function onElementDropComplete(dragElement, dropElement) {
722
814
  setTimeout(() => {
723
815
  div.remove();
724
816
  container.style.pointerEvents = 'auto';
817
+ const objective = container.getAttribute('objective');
818
+ if (objective && tempVanishedValues.map(v => v.trim()).sort().join(',') === objective.split(',').map(v => v.trim()).sort().join(',')) {
819
+ (async () => {
820
+ isCorrect = true;
821
+ const onCorrect = (container === null || container === void 0 ? void 0 : container.getAttribute('onCorrect')) || '';
822
+ await executeActions(onCorrect, container);
823
+ window.dispatchEvent(new CustomEvent(NextContainerKey));
824
+ tempVanishedValues.length = 0;
825
+ })();
826
+ }
725
827
  }, 800); // match animation duration
726
828
  }, 2000); // stay for 2 seconds
727
829
  }, 250);
@@ -729,6 +831,12 @@ async function onElementDropComplete(dragElement, dropElement) {
729
831
  }
730
832
  }
731
833
  if (dropElement) {
834
+ let selectedValues = JSON.parse((_e = container.getAttribute(SelectedValuesKey)) !== null && _e !== void 0 ? _e : "[]");
835
+ const dragValue = dragElement.getAttribute('value');
836
+ if (dragValue && !selectedValues.includes(dragValue)) {
837
+ selectedValues.push(dragValue);
838
+ }
839
+ container.setAttribute(SelectedValuesKey, JSON.stringify(selectedValues));
732
840
  if (dropElement.getAttribute('drop-attr') === 'stretch') {
733
841
  if (!dropElement.hasAttribute('data-original-width')) {
734
842
  const computedStyle = window.getComputedStyle(dropElement);
@@ -737,15 +845,16 @@ async function onElementDropComplete(dragElement, dropElement) {
737
845
  const dragWidth = dragElement.offsetWidth;
738
846
  dropElement.style.width = `${dragWidth}px`;
739
847
  }
740
- if (!(((_d = dropElement.getAttribute('dropAttr')) === null || _d === void 0 ? void 0 : _d.toLowerCase()) === DropMode.Diagonal) && (dropElement.getAttribute('minDrops') === '1' || !dropElement.getAttribute('minDrops'))) {
848
+ if (!(((_f = dropElement.getAttribute('dropAttr')) === null || _f === void 0 ? void 0 : _f.toLowerCase()) === DropMode.Diagonal) && (dropElement.getAttribute('minDrops') === '1' || !dropElement.getAttribute('minDrops'))) {
741
849
  const isisFull = Object.values(dropHasDrag).find(item => document.getElementById(item.drop) === dropElement);
742
850
  if (isisFull) {
743
851
  isisFull.isFull = true;
852
+ dropElement.setAttribute('is-full', 'true');
744
853
  }
745
854
  else {
746
855
  console.warn('No matching drop item found for', dropElement);
747
856
  }
748
- localStorage.setItem(DropHasDrag, JSON.stringify(dropHasDrag));
857
+ // container.setAttribute(DropHasDrag, JSON.stringify(dropHasDrag));
749
858
  if (dragSelectedData) {
750
859
  let dragSelected = JSON.parse(dragSelectedData);
751
860
  for (const key in dragSelected) {
@@ -758,7 +867,7 @@ async function onElementDropComplete(dragElement, dropElement) {
758
867
  }
759
868
  }
760
869
  }
761
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragSelected));
870
+ // container.setAttribute(DragSelectedMapKey, JSON.stringify(dragSelected));
762
871
  }
763
872
  dragElement.classList.add('dropped');
764
873
  if (dragElement) {
@@ -771,7 +880,7 @@ async function onElementDropComplete(dragElement, dropElement) {
771
880
  dragElement.setAttribute(DropTimeAttr, new Date().getTime().toString());
772
881
  }
773
882
  // Check for overlaps and highlight only the most overlapping element
774
- if (dropElement && !((_e = dropHasDrag[dropTabIndex]) === null || _e === void 0 ? void 0 : _e.isFull)) {
883
+ if (dropElement && !((_g = dropHasDrag[dropTabIndex]) === null || _g === void 0 ? void 0 : _g.isFull)) {
775
884
  let mostOverlappedElement = findMostoverlappedElement$1(dragElement, 'drag');
776
885
  const isAllowOnlyOneDrop = dropElement.getAttribute('is-allow-only-one-drop') === 'true' || '';
777
886
  if (mostOverlappedElement && isAllowOnlyOneDrop) {
@@ -780,7 +889,7 @@ async function onElementDropComplete(dragElement, dropElement) {
780
889
  const allElements = document.querySelectorAll("[type='drop']");
781
890
  allElements.forEach(otherElement => {
782
891
  var _a;
783
- const dropObject = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
892
+ const dropObject = buildDragSelectedMapFromDOM();
784
893
  const storedTabIndexes = Object.keys(dropObject).map(Number);
785
894
  if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
786
895
  if (!(((_a = otherElement.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
@@ -812,13 +921,14 @@ async function onElementDropComplete(dragElement, dropElement) {
812
921
  handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData);
813
922
  return;
814
923
  }
924
+ updateBalanceOnDrop();
815
925
  if (dragSelectedData) {
816
926
  let currentDrop = dragToDropMap.get(dragElement);
817
927
  if (currentDrop) {
818
928
  let prevDropItem = Object.values(dropHasDrag).find(item => document.getElementById(item.drop) === currentDrop);
819
929
  if (prevDropItem) {
820
930
  prevDropItem.isFull = false;
821
- localStorage.setItem(DropHasDrag, JSON.stringify(dropHasDrag));
931
+ // container.setAttribute(DropHasDrag, JSON.stringify(dropHasDrag));
822
932
  reduceSizeToOriginal();
823
933
  }
824
934
  }
@@ -831,9 +941,9 @@ async function onElementDropComplete(dragElement, dropElement) {
831
941
  // }
832
942
  // localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragSelected));
833
943
  }
834
- let dropLength = JSON.parse(localStorage.getItem(DropLength)) || 0;
944
+ let dropLength = parseInt((_h = container.getAttribute(DropLength)) !== null && _h !== void 0 ? _h : '0');
835
945
  dropLength += 1;
836
- localStorage.setItem(DropLength, JSON.stringify(dropLength));
946
+ container.setAttribute(DropLength, String(dropLength));
837
947
  if (dropLength === countPatternWords(dropElement['value'])) {
838
948
  const isisFull = Object.values(dropHasDrag).find(item => document.getElementById(item.drop) === dropElement);
839
949
  if (isisFull) {
@@ -842,9 +952,10 @@ async function onElementDropComplete(dragElement, dropElement) {
842
952
  else {
843
953
  console.warn('No matching drop item found for', dropElement);
844
954
  }
845
- localStorage.setItem(DropHasDrag, JSON.stringify(dropHasDrag));
955
+ // memoryStorage[DropHasDrag] = dropHasDrag;
956
+ // container.setAttribute(DropHasDrag, JSON.stringify(dropHasDrag));
846
957
  dropLength = 0;
847
- localStorage.setItem(DropLength, JSON.stringify(dropLength));
958
+ container.setAttribute(DropLength, String(dropLength));
848
959
  }
849
960
  dragToDropMap.set(dragElement, dropElement);
850
961
  // Add pulse and highlight effect for a successful match
@@ -852,9 +963,9 @@ async function onElementDropComplete(dragElement, dropElement) {
852
963
  dispatchElementDropEvent(dragElement, dropElement, isCorrect);
853
964
  storingEachActivityScore(isCorrect);
854
965
  dragElement.style.opacity = '1';
966
+ await onActivityComplete(dragElement, dropElement);
855
967
  const allDropElements = document.querySelectorAll('.drop-element');
856
968
  allDropElements.forEach(el => updateDropBorder(el));
857
- await onActivityComplete(dragElement, dropElement);
858
969
  }
859
970
  function updateDropBorder(element) {
860
971
  if (!element || !element.classList.contains('drop-element'))
@@ -873,7 +984,9 @@ function updateDropBorder(element) {
873
984
  element.classList.remove('empty');
874
985
  }
875
986
  else {
876
- element.classList.add('empty');
987
+ if (!element.classList.contains('math-matrix')) {
988
+ element.classList.add('empty');
989
+ }
877
990
  element.classList.remove('filled');
878
991
  }
879
992
  }
@@ -881,15 +994,12 @@ function handleDropElement(element) {
881
994
  // let nextIndex = Object.keys(dropHas).length; // Get next index
882
995
  // dropHas[nextIndex] = { drop: element, isFull: false };
883
996
  element.classList.add('drop-element');
884
- let dropHas = JSON.parse(localStorage.getItem(DropHasDrag) || '{}');
885
- const tabIndex = element.getAttribute('tab-index');
886
- if (typeof dropHas !== 'object' || dropHas === null) {
887
- dropHas = {};
888
- }
889
- if (!dropHas[tabIndex]) {
890
- dropHas[tabIndex] = { drop: element.id, isFull: false };
891
- localStorage.setItem(DropHasDrag, JSON.stringify(dropHas));
892
- }
997
+ buildDragSelectedMapFromDOM();
998
+ element.getAttribute('tab-index');
999
+ // if (!dropHas[tabIndex]) {
1000
+ // dropHas[tabIndex] = { drop: element.id, isFull: false };
1001
+ // // localStorage.setItem(DropHasDrag, JSON.stringify(dropHas));
1002
+ // }
893
1003
  element.onclick = () => {
894
1004
  onClickDropOrDragElement(element, 'drop');
895
1005
  };
@@ -956,7 +1066,7 @@ async function onClickDropOrDragElement(element, type) {
956
1066
  const dragToDropMap = new Map();
957
1067
  async function onClickDragElement(element) {
958
1068
  AudioPlayer.getI().stop();
959
- const dropElements = JSON.parse(localStorage.getItem(DropHasDrag) || '{}');
1069
+ const dropElements = buildDropHasDragFromDOM();
960
1070
  const dragEl = element;
961
1071
  if (!dragEl) {
962
1072
  console.error('Element not found');
@@ -1002,9 +1112,12 @@ const appendingDragElementsInDrop = () => {
1002
1112
  });
1003
1113
  });
1004
1114
  };
1115
+ const container = document.getElementById(LidoContainer);
1005
1116
  const reduceSizeToOriginal = () => {
1006
1117
  const dropItems = document.querySelectorAll("[type='drop']");
1007
- let dropHasDrag = JSON.parse(localStorage.getItem(DropHasDrag) || ' {}');
1118
+ let dropHasDrag = buildDragSelectedMapFromDOM();
1119
+ if (!dropItems || !container)
1120
+ return;
1008
1121
  if (!dropHasDrag || !dropItems)
1009
1122
  return;
1010
1123
  dropItems.forEach(dropElement => {
@@ -1013,6 +1126,7 @@ const reduceSizeToOriginal = () => {
1013
1126
  const tabIndex = drop.getAttribute('tab-index');
1014
1127
  if (((_a = drop === null || drop === void 0 ? void 0 : drop.getAttribute('drop-attr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Stretch && dropHasDrag[tabIndex].isFull === false) {
1015
1128
  const originalWidth = drop.getAttribute('data-original-width');
1129
+ dropElement.removeAttribute('is-full');
1016
1130
  if (originalWidth) {
1017
1131
  drop.style.width = originalWidth;
1018
1132
  drop.removeAttribute('data-original-width');
@@ -1203,7 +1317,7 @@ function enableReorderDrag(element) {
1203
1317
  isClicked = false;
1204
1318
  event.preventDefault();
1205
1319
  const containerRect = container.getBoundingClientRect();
1206
- const containerScale = calculateScale();
1320
+ const containerScale = getElementScale(container);
1207
1321
  const newLeft = (point.clientX - containerRect.left - offsetXInElement) / containerScale;
1208
1322
  const newTop = (point.clientY - containerRect.top - offsetYInElement) / containerScale;
1209
1323
  element.style.left = `${newLeft}px`;
@@ -1270,16 +1384,18 @@ function enableReorderDrag(element) {
1270
1384
  else {
1271
1385
  if (element.parentElement['type'] !== 'category') {
1272
1386
  executeActions('this.alignMatch=true', divEl, element);
1273
- divEl.replaceWith(element);
1387
+ setTimeout(() => {
1388
+ divEl.replaceWith(element);
1389
+ }, 500);
1274
1390
  }
1275
1391
  else {
1276
1392
  const categoryElement = element.parentElement;
1277
- const dragValues = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
1393
+ const dragValues = buildDragSelectedMapFromDOM();
1278
1394
  const tabKey = categoryElement.getAttribute('tab-index');
1279
1395
  const targetValue = element['value'];
1280
1396
  if (dragValues[tabKey]) {
1281
1397
  dragValues[tabKey] = dragValues[tabKey].filter((el) => el !== targetValue);
1282
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragValues));
1398
+ // localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragValues));
1283
1399
  }
1284
1400
  optionArea.scrollTo({
1285
1401
  top: optionArea.scrollHeight,
@@ -1287,6 +1403,7 @@ function enableReorderDrag(element) {
1287
1403
  });
1288
1404
  optionArea.appendChild(element);
1289
1405
  element.classList.remove('dropped');
1406
+ element.removeAttribute('drop-to');
1290
1407
  if (dummy) {
1291
1408
  dummy.remove();
1292
1409
  }
@@ -1325,12 +1442,12 @@ function enableReorderDrag(element) {
1325
1442
  category = categoryArr[0];
1326
1443
  }
1327
1444
  if (element.parentElement.getAttribute('type') === 'category') {
1328
- const dragValues = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
1445
+ const dragValues = buildDragSelectedMapFromDOM();
1329
1446
  const tabKey = category.getAttribute('tab-index');
1330
1447
  const targetValue = element['value'];
1331
1448
  if (dragValues[tabKey]) {
1332
1449
  dragValues[tabKey] = dragValues[tabKey].filter((el) => el !== targetValue);
1333
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragValues));
1450
+ // localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragValues));
1334
1451
  }
1335
1452
  const dummy = createDummyElement(element);
1336
1453
  optionArea.appendChild(dummy);
@@ -1344,6 +1461,7 @@ function enableReorderDrag(element) {
1344
1461
  resetElementStyles(element);
1345
1462
  dummy.replaceWith(element);
1346
1463
  element.classList.remove('dropped');
1464
+ element.removeAttribute('drop-to');
1347
1465
  }, 100);
1348
1466
  return;
1349
1467
  }
@@ -1492,13 +1610,15 @@ function moveWithAnimation(target, overlapped) {
1492
1610
  }
1493
1611
  // Drop Completed
1494
1612
  const wordDropComplete = (block, element) => {
1613
+ var _a;
1614
+ console.log("worddrop");
1495
1615
  const container = document.getElementById(LidoContainer);
1496
1616
  const objective = container.getAttribute('objective');
1497
1617
  const objectiveArray = objective.split(',');
1498
- let wordArray = JSON.parse(localStorage.getItem(SelectedValuesKey)) || [];
1618
+ let wordArray = JSON.parse((_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]');
1499
1619
  const wordBlock = block.children;
1500
1620
  wordArray = Array.from(wordBlock).map(child => child.getAttribute('value'));
1501
- localStorage.setItem(SelectedValuesKey, JSON.stringify(wordArray));
1621
+ container.setAttribute(SelectedValuesKey, JSON.stringify(wordArray));
1502
1622
  const elementIndex = wordArray.indexOf(element['value']);
1503
1623
  if (elementIndex >= 0) {
1504
1624
  const res = matchStringPattern(element['value'], [objectiveArray[elementIndex].trim()]);
@@ -1513,7 +1633,7 @@ const wordDropComplete = (block, element) => {
1513
1633
  };
1514
1634
  async function onDropToCategory(dragElement, categoryElement) {
1515
1635
  dragElement.classList.add('dropped');
1516
- let dragSelected = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
1636
+ let dragSelected = buildDragSelectedMapFromDOM();
1517
1637
  let elementArr = dragSelected[categoryElement.getAttribute('tab-index')];
1518
1638
  if (Array.isArray(elementArr)) {
1519
1639
  if (elementArr.includes(dragElement['value']))
@@ -1525,7 +1645,10 @@ async function onDropToCategory(dragElement, categoryElement) {
1525
1645
  dragSelected[key].splice(index, 1);
1526
1646
  }
1527
1647
  }
1528
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragSelected));
1648
+ if (categoryElement === null || categoryElement === void 0 ? void 0 : categoryElement.id) {
1649
+ dragElement.setAttribute(DropToAttr, categoryElement.id);
1650
+ }
1651
+ // localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragSelected));
1529
1652
  await onActivityComplete(dragElement, categoryElement);
1530
1653
  }
1531
1654
 
@@ -1744,13 +1867,15 @@ function slidingWithScaling(element) {
1744
1867
  });
1745
1868
  }
1746
1869
  const slideCompleted = (slideElement) => {
1747
- const slideArr = JSON.parse(localStorage.getItem(SelectedValuesKey)) || [];
1870
+ var _a;
1871
+ const container = document.getElementById(LidoContainer);
1872
+ const slideArr = JSON.parse((_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]');
1748
1873
  const allSlideElements = document.querySelectorAll("[type='slide']");
1749
1874
  let index = 0;
1750
1875
  allSlideElements.forEach(item => {
1751
1876
  slideArr[index++] = item['value'];
1752
1877
  });
1753
- localStorage.setItem(SelectedValuesKey, JSON.stringify(slideArr));
1878
+ container.setAttribute(SelectedValuesKey, JSON.stringify(slideArr));
1754
1879
  const objectiveString = document.getElementById(LidoContainer)['objective'];
1755
1880
  const objectiveArray = objectiveString.split(',');
1756
1881
  const elementIndex = slideArr.indexOf(slideElement['value']);
@@ -3012,6 +3137,7 @@ function addClickListenerForClickType(element) {
3012
3137
  return;
3013
3138
  }
3014
3139
  const onClick = async () => {
3140
+ var _a;
3015
3141
  const lido_buttons = element.getAttribute('id');
3016
3142
  if (lido_buttons === 'lido-arrow-left' || lido_buttons === 'lido-arrow-right') {
3017
3143
  return;
@@ -3028,24 +3154,15 @@ function addClickListenerForClickType(element) {
3028
3154
  }
3029
3155
  if (container['objective'].length === 0)
3030
3156
  return;
3031
- // element.style.border = '2px solid yellow';
3032
- // element.style.boxShadow = '0px 0px 10px rgba(255, 255, 0, 0.7)';
3033
- // element.style.transition = 'transform 0.2s ease, border 0.5s ease';
3034
- // element.style.transform = 'scale(1.1)';
3035
- // element.style.transform = 'scale(1)';
3036
- // element.style.border = '';
3037
- // element.style.boxShadow = '';
3038
3157
  const isActivated = element.classList.contains('lido-element-selected');
3039
- let selectedValue = JSON.parse(localStorage.getItem(SelectedValuesKey)) || [];
3158
+ let selectedValue = JSON.parse((_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]');
3040
3159
  if (objective.length === 1) {
3041
- localStorage.setItem(SelectedValuesKey, JSON.stringify([element['value']]));
3160
+ container.setAttribute(SelectedValuesKey, JSON.stringify([element['value']]));
3042
3161
  const isCorrect = objective.includes(element['value']);
3043
3162
  dispatchClickEvent(element, isCorrect);
3044
3163
  if (isCorrect) {
3045
3164
  const onCorrect = element.getAttribute('onCorrect');
3046
- if (!(element.id && element.id.startsWith('key-button'))) {
3047
- element.style.pointerEvents = 'none';
3048
- }
3165
+ // element.style.pointerEvents = 'none';
3049
3166
  await executeActions(onCorrect, element);
3050
3167
  }
3051
3168
  else {
@@ -3053,7 +3170,11 @@ function addClickListenerForClickType(element) {
3053
3170
  await executeActions(onInCorrect, element);
3054
3171
  // showWrongAnswerAnimation([element]);
3055
3172
  }
3056
- storingEachActivityScore(isCorrect);
3173
+ // const calciEl=document.querySelector('#lidoCalculator') as any;
3174
+ const isInsideCalculator = element.closest('#lidoCalculator') !== null;
3175
+ if (!isInsideCalculator) {
3176
+ storingEachActivityScore(isCorrect);
3177
+ }
3057
3178
  handleShowCheck();
3058
3179
  return;
3059
3180
  }
@@ -3064,8 +3185,8 @@ function addClickListenerForClickType(element) {
3064
3185
  element.classList.remove('lido-element-selected');
3065
3186
  executeActions(element.getAttribute('onEntry'), element);
3066
3187
  selectedValue = selectedValue.filter(item => item != element['value']);
3067
- localStorage.setItem(SelectedValuesKey, JSON.stringify(selectedValue));
3068
- let multiOptionScore = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
3188
+ container.setAttribute(SelectedValuesKey, JSON.stringify([element['value']]));
3189
+ let multiOptionScore = buildDragSelectedMapFromDOM();
3069
3190
  const valueToRemove = element['value'];
3070
3191
  const keyToRemove = Object.keys(multiOptionScore).find(key => multiOptionScore[key].includes(valueToRemove));
3071
3192
  if (keyToRemove) {
@@ -3073,10 +3194,9 @@ function addClickListenerForClickType(element) {
3073
3194
  if (multiOptionScore[keyToRemove].length === 0) {
3074
3195
  delete multiOptionScore[keyToRemove];
3075
3196
  }
3076
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(multiOptionScore));
3077
3197
  const sortedKeys = Object.keys(multiOptionScore).sort((a, b) => parseInt(a) - parseInt(b));
3078
3198
  const sortedValues = sortedKeys.reduce((acc, key) => acc.concat(multiOptionScore[key]), []);
3079
- localStorage.setItem(SelectedValuesKey, JSON.stringify(sortedValues));
3199
+ container.setAttribute(SelectedValuesKey, JSON.stringify(sortedValues));
3080
3200
  }
3081
3201
  if (showCheck && selectedValue.length === 0) {
3082
3202
  checkButton.classList.add('lido-disable-check-button');
@@ -3087,20 +3207,18 @@ function addClickListenerForClickType(element) {
3087
3207
  element.classList.add('lido-element-selected');
3088
3208
  const valueToFind = element['value'];
3089
3209
  const key = Object.keys(objective).find(key => objective[key] === valueToFind);
3090
- let multiOptionScore = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
3210
+ let multiOptionScore = buildDragSelectedMapFromDOM();
3091
3211
  if (!key) {
3092
3212
  multiOptionScore[objective.length + selectedValue.length] = [valueToFind];
3093
3213
  }
3094
3214
  else {
3095
3215
  multiOptionScore[key] = [valueToFind];
3096
3216
  }
3097
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(multiOptionScore));
3098
3217
  const sortedKeys = Object.keys(multiOptionScore).sort((a, b) => parseInt(a) - parseInt(b));
3099
3218
  const sortedValues = sortedKeys.reduce((acc, key) => acc.concat(multiOptionScore[key]), []);
3100
- localStorage.setItem(SelectedValuesKey, JSON.stringify(sortedValues));
3219
+ container.setAttribute(SelectedValuesKey, JSON.stringify(sortedValues));
3101
3220
  const isCorrect = objective.includes(element['value']);
3102
3221
  dispatchClickEvent(element, isCorrect);
3103
- AudioPlayer.getI().stop();
3104
3222
  if (isCorrect) {
3105
3223
  const onCorrect = element.getAttribute('onCorrect');
3106
3224
  await executeActions(onCorrect, element);
@@ -3112,8 +3230,11 @@ function addClickListenerForClickType(element) {
3112
3230
  }
3113
3231
  storingEachActivityScore(isCorrect);
3114
3232
  }
3115
- if (!showCheck && countPatternWords(objective) === countPatternWords(selectedValue)) {
3116
- validateObjectiveStatus();
3233
+ const isInsideCalculator = element.closest('#lidoCalculator') !== null;
3234
+ if (!isInsideCalculator) {
3235
+ if (!showCheck && countPatternWords(objective) === countPatternWords(selectedValue)) {
3236
+ validateObjectiveStatus();
3237
+ }
3117
3238
  }
3118
3239
  };
3119
3240
  element.addEventListener('click', onClick);
@@ -67931,7 +68052,431 @@ function calculateFill(input, currentFill = 0) {
67931
68052
  return Math.max(0, Math.min(100, value));
67932
68053
  }
67933
68054
 
68055
+ // Helper to animate and remove the active equation cell
68056
+ const animationToRemoveEquationSolvedCellForNimbleTable = (activeCell, allCalculateTypes) => {
68057
+ return new Promise((resolve) => {
68058
+ const keyframes = `
68059
+ @keyframes widthDecrease {
68060
+ 0% {
68061
+ background-color: ${activeCell.style.backgroundColor};
68062
+ height: ${activeCell.style.height};
68063
+ margin: ${activeCell.style.margin};
68064
+ ${activeCell.innerHTML = ""}
68065
+ }
68066
+ 100% { background-color: transparent; height: 0px; margin: 0px; }
68067
+ }`;
68068
+ const styleSheet = document.styleSheets[0];
68069
+ styleSheet.insertRule(keyframes, styleSheet.cssRules.length);
68070
+ activeCell.style.animation = `widthDecrease 0.1s`;
68071
+ activeCell.addEventListener('animationend', () => {
68072
+ activeCell.style.height = '0px';
68073
+ activeCell.style.margin = '0px';
68074
+ activeCell.style.backgroundColor = 'transparent';
68075
+ activeCell.remove();
68076
+ // Trigger next container if last cell
68077
+ if (allCalculateTypes.length === 1) {
68078
+ setTimeout(() => triggerNextContainer(), 2000);
68079
+ }
68080
+ resolve();
68081
+ });
68082
+ });
68083
+ };
68084
+ // Function: checks and animates equation when correct
68085
+ const checkEquationOfActiveCell = async (container) => {
68086
+ var _a;
68087
+ const calculatorValue = (_a = container.querySelector("#lidoCalculator")) === null || _a === void 0 ? void 0 : _a.getAttribute("value");
68088
+ const allCalculateTypes = document.querySelectorAll("[type='calculate']");
68089
+ const activeCell = allCalculateTypes[0];
68090
+ const activeCellValue = Number(activeCell["value"]);
68091
+ const calculteValue = Number(calculatorValue);
68092
+ if (!activeCell || calculteValue !== activeCellValue)
68093
+ return;
68094
+ const equation = activeCell["string"];
68095
+ // Replace equation after a short delay
68096
+ //await new Promise(r => setTimeout(r, 200));
68097
+ activeCell.innerHTML = equation.replaceAll("?", calculteValue);
68098
+ const element2 = container.querySelector("#dummy112");
68099
+ element2.innerHTML = activeCell.innerHTML;
68100
+ // Animate and clean up
68101
+ await animationToRemoveEquationSolvedCellForNimbleTable(activeCell, allCalculateTypes);
68102
+ };
68103
+ // Function: handles equation check when clicked on OK
68104
+ let score = 0;
68105
+ const handleSolvedEquationSubmissionAndScoreUpdate = async () => {
68106
+ var _a;
68107
+ const container = document.getElementById('lido-container');
68108
+ const calculatorValue = (_a = container.querySelector("#lidoCalculator")) === null || _a === void 0 ? void 0 : _a.getAttribute("value");
68109
+ const allCalculateTypes = document.querySelectorAll("[type='calculate']");
68110
+ const activeCell = allCalculateTypes[0];
68111
+ const isContinueOnCorrect = container.getAttribute("is-continue-on-correct") === "true";
68112
+ const activeCellValue = Number(activeCell["value"]);
68113
+ const calculteValue = Number(calculatorValue);
68114
+ const element1 = container.querySelector("#dummy111");
68115
+ const element2 = container.querySelector("#dummy112");
68116
+ // PRACTICE MODE (continue only if correct)
68117
+ if (isContinueOnCorrect) {
68118
+ if (element2.innerHTML.length > 0 && activeCellValue === calculteValue) {
68119
+ element1.innerHTML = element2.innerHTML;
68120
+ }
68121
+ await checkEquationOfActiveCell(container);
68122
+ }
68123
+ // TEST MODE (store all, animate regardless of correctness)
68124
+ else {
68125
+ if (calculatorValue.length > 0) {
68126
+ if (calculatorValue === activeCell["value"]) {
68127
+ score++;
68128
+ console.log("SCOREEEE", score);
68129
+ }
68130
+ else {
68131
+ if (score > 0) {
68132
+ score--;
68133
+ }
68134
+ console.log("SCOREEEE", score);
68135
+ }
68136
+ if (element2.innerHTML.length > 0) {
68137
+ element1.innerHTML = element2.innerHTML;
68138
+ }
68139
+ const equation = activeCell["string"];
68140
+ // Replace value visually
68141
+ activeCell.innerHTML = equation.replaceAll("?", calculteValue);
68142
+ element2.innerHTML = activeCell.innerHTML;
68143
+ // Animate
68144
+ await animationToRemoveEquationSolvedCellForNimbleTable(activeCell, allCalculateTypes);
68145
+ }
68146
+ }
68147
+ };
68148
+
68149
+ function handlingMatrix(element) {
68150
+ const container = document.querySelector(LidoContainer);
68151
+ if (!container)
68152
+ return;
68153
+ const defualtMatrix = element;
68154
+ adjustSizeForSlots(container, defualtMatrix);
68155
+ splitSlots(container, defualtMatrix);
68156
+ }
68157
+ const splitSlots = (container, defualtMatrix) => {
68158
+ const defualtElements = defualtMatrix.querySelectorAll('.slot');
68159
+ const allDropMatrixes = container.querySelectorAll('lido-math-matrix[type="drop"]');
68160
+ const allDragMatrixes = container.querySelectorAll('lido-math-matrix[type="drag"]');
68161
+ let slot = 1;
68162
+ for (let i = 0; i < allDropMatrixes.length; i++) {
68163
+ const el = allDropMatrixes[i];
68164
+ const rowCount = el.getAttribute('rows') ? parseInt(el.getAttribute('rows')) : 1;
68165
+ const colCount = el.getAttribute('cols') ? parseInt(el.getAttribute('cols')) : 1;
68166
+ if (rowCount === 1 || colCount === 1) {
68167
+ if (rowCount === colCount) {
68168
+ const numbers = Array.from({ length: 100 }, (_, i) => i + 1)
68169
+ .sort(() => Math.random() - 0.5) // Shuffle
68170
+ .slice(0, 10); // Take first 10 unique numbers
68171
+ allDropMatrixes.forEach((item, index) => {
68172
+ const dropElement = item;
68173
+ const dropPosition = defualtElements[numbers[index]];
68174
+ // Safeguard if index > available numbers
68175
+ if (!dropPosition)
68176
+ return;
68177
+ postioningDropElement(dropElement, dropPosition);
68178
+ const dragElement = allDragMatrixes[index];
68179
+ dragElement.setAttribute('text', (numbers[index] + 1).toString());
68180
+ });
68181
+ // return;
68182
+ }
68183
+ if (rowCount === 2 && colCount === 1) {
68184
+ const pairs = generateDoubleSquares(10);
68185
+ console.log('pairs double : ', pairs);
68186
+ allDropMatrixes.forEach((item, index) => {
68187
+ const dropElement = item;
68188
+ const dropPosition = defualtElements[pairs[index][0] - 1];
68189
+ postioningDropElement(dropElement, dropPosition);
68190
+ });
68191
+ allDragMatrixes.forEach((item, index) => {
68192
+ const dragElement = item;
68193
+ dragElement.setAttribute('text', pairs[index].toString());
68194
+ });
68195
+ break;
68196
+ }
68197
+ if (rowCount === 5) {
68198
+ const dropPositionElements = generateHalfHorizontalStripes(i);
68199
+ const dropPosition = defualtElements[dropPositionElements[0] - 1];
68200
+ const dragElement = allDragMatrixes[i];
68201
+ dragElement.setAttribute('text', dropPositionElements.toString());
68202
+ postioningDropElement(el, dropPosition);
68203
+ }
68204
+ if (rowCount === 10) {
68205
+ const dropPosition = defualtElements[slot];
68206
+ const dragElement = allDragMatrixes[i];
68207
+ dragElement.setAttribute('text', Array.from({ length: 10 }, (_, i) => slot + 1 + i * 10).toString());
68208
+ postioningDropElement(el, dropPosition);
68209
+ slot = slot + 2;
68210
+ }
68211
+ else if (colCount === 10) {
68212
+ const dropPosition = defualtElements[10 + (slot - 1)];
68213
+ const dragElement = allDragMatrixes[i];
68214
+ dragElement.setAttribute('text', Array.from({ length: 10 }, (_, i) => i + 10 + slot).toString());
68215
+ postioningDropElement(el, dropPosition);
68216
+ slot = slot + 20;
68217
+ }
68218
+ }
68219
+ else if (rowCount === 3 || colCount === 3) {
68220
+ const slotCell = generateSlotsFromDrops(container);
68221
+ const cellNumbers = Object.keys(slotCell).map(key => slotCell[key].cells);
68222
+ allDragMatrixes.forEach((matrix, index) => {
68223
+ const dragElement = matrix;
68224
+ // let dragTextAttr = dragElement.getAttribute('text');
68225
+ if (dragElement) {
68226
+ dragElement.setAttribute('text', cellNumbers[index].toString());
68227
+ }
68228
+ });
68229
+ allDropMatrixes.forEach((matrix, index) => {
68230
+ const dropElement = matrix;
68231
+ const dropPosition = defualtElements[slotCell[`slot-${index + 1}`].cells[0] - 1];
68232
+ postioningDropElement(dropElement, dropPosition);
68233
+ });
68234
+ break; // stops the loop immediately
68235
+ }
68236
+ else if (rowCount === 2 || colCount === 2) {
68237
+ if (rowCount === colCount) {
68238
+ const pairs = generate2by2Squares(10);
68239
+ allDropMatrixes.forEach((item, index) => {
68240
+ const dropElement = item;
68241
+ const dropPosition = defualtElements[pairs[index][0] - 1];
68242
+ postioningDropElement(dropElement, dropPosition);
68243
+ });
68244
+ allDragMatrixes.forEach((item, index) => {
68245
+ const dragElement = item;
68246
+ dragElement.setAttribute('text', pairs[index].toString());
68247
+ });
68248
+ break;
68249
+ }
68250
+ }
68251
+ }
68252
+ };
68253
+ function generateSlotsFromDrops(container) {
68254
+ const gridSize = 10;
68255
+ let availableCells = Array.from({ length: 100 }, (_, i) => i + 1);
68256
+ const occupied = new Set();
68257
+ const slots = {};
68258
+ let generated = 0;
68259
+ const getCell = (row, col) => row * gridSize + col + 1;
68260
+ // Get all <lido-math-matrix type="drop">
68261
+ const allDropMatrixes = container.querySelectorAll('lido-math-matrix[type="drop"]');
68262
+ for (const matrix of Array.from(allDropMatrixes)) {
68263
+ const width = parseInt(matrix.getAttribute('cols') || '1');
68264
+ const height = parseInt(matrix.getAttribute('rows') || '1');
68265
+ const possiblePositions = [];
68266
+ // generate all possible top-left positions
68267
+ for (let row = 0; row <= gridSize - height; row++) {
68268
+ for (let col = 0; col <= gridSize - width; col++) {
68269
+ const cells = [];
68270
+ let canPlace = true;
68271
+ for (let r = 0; r < height; r++) {
68272
+ for (let c = 0; c < width; c++) {
68273
+ const cell = getCell(row + r, col + c);
68274
+ if (occupied.has(cell)) {
68275
+ canPlace = false;
68276
+ break;
68277
+ }
68278
+ cells.push(cell);
68279
+ }
68280
+ if (!canPlace)
68281
+ break;
68282
+ }
68283
+ if (canPlace)
68284
+ possiblePositions.push(cells);
68285
+ }
68286
+ }
68287
+ if (possiblePositions.length === 0) {
68288
+ console.warn(`No space left for matrix ${generated + 1}`);
68289
+ continue;
68290
+ }
68291
+ // Pick a random valid position
68292
+ const randomCells = possiblePositions[Math.floor(Math.random() * possiblePositions.length)];
68293
+ // Mark as occupied & remove from available
68294
+ randomCells.forEach(c => {
68295
+ occupied.add(c);
68296
+ availableCells = availableCells.filter(x => x !== c);
68297
+ });
68298
+ generated++;
68299
+ slots[`slot-${generated}`] = { cells: randomCells, width, height };
68300
+ }
68301
+ return slots;
68302
+ }
68303
+ const postioningDropElement = (dropElement, dropPosition) => {
68304
+ const container = document.getElementById(LidoContainer);
68305
+ const containerScale = getElementScale$1(container);
68306
+ dropElement.style.transform = 'translate(0,0)';
68307
+ const posRect = dropPosition.getBoundingClientRect();
68308
+ const dropRect = dropElement.getBoundingClientRect();
68309
+ const posCenterX = posRect.left + posRect.width / 2;
68310
+ const posCenterY = posRect.top + posRect.height / 2;
68311
+ const dropCenterX = dropRect.left + dropRect.width / 2;
68312
+ const dropCenterY = dropRect.top + dropRect.height / 2;
68313
+ const scaledLeft = (posCenterX - dropCenterX) / containerScale;
68314
+ const scaledTop = (posCenterY - dropCenterY) / containerScale;
68315
+ const rowCount = dropElement.getAttribute('rows') ? parseInt(dropElement.getAttribute('rows')) : 1;
68316
+ const colCount = dropElement.getAttribute('cols') ? parseInt(dropElement.getAttribute('cols')) : 1;
68317
+ const elementWidth = parseInt(dropPosition.style.width);
68318
+ if (rowCount === 1 || colCount === 1) {
68319
+ if (rowCount === colCount) {
68320
+ dropElement.style.transform = `translate(${scaledLeft}px, ${scaledTop}px)`;
68321
+ return;
68322
+ }
68323
+ else if (rowCount > colCount) {
68324
+ if (rowCount === 10) {
68325
+ dropElement.style.transform = `translate(${scaledLeft + (elementWidth * 4 + elementWidth / 2)}px, ${scaledTop}px)`;
68326
+ }
68327
+ else if (rowCount === 5) {
68328
+ dropElement.style.transform = `translate(${scaledLeft + elementWidth * 2}px, ${scaledTop}px)`;
68329
+ }
68330
+ else if (rowCount === 2) {
68331
+ dropElement.style.transform = `translate(${scaledLeft + elementWidth / 2}px, ${scaledTop}px)`;
68332
+ }
68333
+ }
68334
+ else if (rowCount < colCount) {
68335
+ if (colCount === 10) {
68336
+ dropElement.style.transform = `translate(${scaledLeft}px, ${scaledTop + elementWidth * 4 + elementWidth * 0.2 + elementWidth / 2}px)`;
68337
+ }
68338
+ else if (colCount === 5) {
68339
+ dropElement.style.transform = `translate(${scaledLeft}px, ${scaledTop + elementWidth * 2 + elementWidth * 0.0921}px)`;
68340
+ }
68341
+ }
68342
+ return;
68343
+ }
68344
+ if (rowCount === colCount) {
68345
+ if (rowCount === 2) {
68346
+ dropElement.style.transform = `translate(${scaledLeft + elementWidth / 2}px, ${scaledTop + elementWidth / 2 + 4}px)`;
68347
+ return;
68348
+ }
68349
+ dropElement.style.transform = `translate(${scaledLeft + elementWidth}px, ${scaledTop + elementWidth + 4}px)`;
68350
+ return;
68351
+ }
68352
+ if (rowCount === 3) {
68353
+ if (colCount === 2) {
68354
+ dropElement.style.transform = `translate(${scaledLeft + elementWidth}px, ${scaledTop + elementWidth / 2 + 4}px)`;
68355
+ return;
68356
+ }
68357
+ else if (colCount === 1) {
68358
+ dropElement.style.transform = `translate(${scaledLeft + elementWidth}px, ${scaledTop}px)`;
68359
+ return;
68360
+ }
68361
+ }
68362
+ if (rowCount === 2) {
68363
+ if (colCount === 3) {
68364
+ dropElement.style.transform = `translate(${scaledLeft + elementWidth / 2}px, ${scaledTop + elementWidth + 4}px)`;
68365
+ return;
68366
+ }
68367
+ else if (colCount === 1) {
68368
+ dropElement.style.transform = `translate(${scaledLeft + elementWidth / 2}px, ${scaledTop}px)`;
68369
+ return;
68370
+ }
68371
+ }
68372
+ };
68373
+ const adjustSizeForSlots = (container, defualtMatrix) => {
68374
+ const defualtElement = defualtMatrix.querySelector('.slot');
68375
+ const width = defualtElement.style.width;
68376
+ const allDropMatrixes = container.querySelectorAll('lido-math-matrix[type="drop"]');
68377
+ const allDragMatrixes = container.querySelectorAll('lido-math-matrix[type="drag"]');
68378
+ allDragMatrixes.forEach(item => {
68379
+ const el = item;
68380
+ Array.from(el.querySelectorAll('.slot')).forEach(slot => {
68381
+ const slotEl = slot;
68382
+ slotEl.parentElement.style.width = width;
68383
+ slotEl.style.width = width;
68384
+ slotEl.style.height = width;
68385
+ });
68386
+ });
68387
+ allDropMatrixes.forEach(item => {
68388
+ const el = item;
68389
+ Array.from(el.querySelectorAll('.slot')).forEach(slot => {
68390
+ const slotEl = slot;
68391
+ slotEl.parentElement.style.width = width;
68392
+ slotEl.style.width = width;
68393
+ slotEl.style.height = width;
68394
+ });
68395
+ });
68396
+ };
68397
+ function generateHalfHorizontalStripes(index) {
68398
+ const numbers = Array.from({ length: 10 }, (_, i) => index + 1 + i * 10);
68399
+ const randomPlace = Math.floor(Math.random() * 6);
68400
+ const startSlot = numbers[randomPlace];
68401
+ console.log('kedachuruchu', Array.from({ length: 5 }, (_, i) => startSlot + i * 10));
68402
+ return Array.from({ length: 5 }, (_, i) => startSlot + i * 10);
68403
+ }
68404
+ function generate2by2Squares(count = 16) {
68405
+ const gridSize = 10;
68406
+ const squares = [];
68407
+ const usedCells = new Set();
68408
+ function getCell(row, col) {
68409
+ return (row - 1) * gridSize + col;
68410
+ }
68411
+ while (squares.length < count) {
68412
+ const row = Math.floor(Math.random() * (gridSize - 1)) + 1; // 1–9
68413
+ const col = Math.floor(Math.random() * (gridSize - 1)) + 1; // 1–9
68414
+ const square = [getCell(row, col), getCell(row, col + 1), getCell(row + 1, col), getCell(row + 1, col + 1)];
68415
+ // Skip if overlapping with previous
68416
+ if (square.some(cell => usedCells.has(cell)))
68417
+ continue;
68418
+ // Mark cells as used
68419
+ square.forEach(cell => usedCells.add(cell));
68420
+ squares.push(square);
68421
+ }
68422
+ return squares;
68423
+ }
68424
+ function generateDoubleSquares(count = 16) {
68425
+ const gridSize = 10;
68426
+ const pairs = [];
68427
+ const usedCells = new Set();
68428
+ function getCell(row, col) {
68429
+ return (row - 1) * gridSize + col;
68430
+ }
68431
+ while (pairs.length < count) {
68432
+ const row = Math.floor(Math.random() * (gridSize - 1)) + 1; // 1–9
68433
+ const col = Math.floor(Math.random() * gridSize) + 1; // 1–10
68434
+ const top = getCell(row, col);
68435
+ const bottom = getCell(row + 1, col);
68436
+ // Skip if already used
68437
+ if (usedCells.has(top) || usedCells.has(bottom))
68438
+ continue;
68439
+ pairs.push([top, bottom]);
68440
+ usedCells.add(top);
68441
+ usedCells.add(bottom);
68442
+ }
68443
+ return pairs;
68444
+ }
68445
+
67934
68446
  const gameScore = new GameScore();
68447
+ function buildDragSelectedMapFromDOM() {
68448
+ const map = {};
68449
+ const draggedEls = document.querySelectorAll(`[${DropToAttr}]`);
68450
+ draggedEls.forEach(dragEl => {
68451
+ var _a, _b, _c;
68452
+ const to = dragEl.getAttribute(DropToAttr);
68453
+ if (!to)
68454
+ return;
68455
+ const dropEl = document.getElementById(to);
68456
+ if (!dropEl)
68457
+ return;
68458
+ const tabIndex = (_a = dropEl.getAttribute('tab-index')) !== null && _a !== void 0 ? _a : to;
68459
+ if (!map[tabIndex])
68460
+ map[tabIndex] = [];
68461
+ const value = (_c = (_b = dragEl.getAttribute('value')) !== null && _b !== void 0 ? _b : dragEl.value) !== null && _c !== void 0 ? _c : '';
68462
+ map[tabIndex].push(value);
68463
+ });
68464
+ return map;
68465
+ }
68466
+ function getSortedValuesArrayFromMap(map) {
68467
+ const sortedKeys = Object.keys(map).sort((a, b) => parseInt(a) - parseInt(b));
68468
+ const sortedValues = sortedKeys.reduce((acc, key) => {
68469
+ const values = map[key];
68470
+ if (values.length > 1) {
68471
+ acc.push(`(${values.join('|')})`);
68472
+ }
68473
+ else {
68474
+ acc.push(values[0]);
68475
+ }
68476
+ return acc;
68477
+ }, []);
68478
+ return sortedValues;
68479
+ }
67935
68480
  function format(first, middle, last) {
67936
68481
  return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');
67937
68482
  }
@@ -67976,12 +68521,16 @@ const initEventsForElement = async (element, type) => {
67976
68521
  enableOptionArea(element);
67977
68522
  break;
67978
68523
  }
68524
+ case 'checkerBlock': {
68525
+ handlingMatrix(element);
68526
+ break;
68527
+ }
67979
68528
  }
67980
68529
  onTouchListenerForOnTouch(element);
67981
68530
  };
67982
68531
  // Function to execute actions parsed from the onMatch string
67983
68532
  const executeActions = async (actionsString, thisElement, element) => {
67984
- var _a;
68533
+ var _a, _b, _c, _d, _e, _f, _g;
67985
68534
  const actions = parseActions(actionsString);
67986
68535
  for (let i = 0; i < actions.length; i++) {
67987
68536
  const action = actions[i];
@@ -67995,13 +68544,25 @@ const executeActions = async (actionsString, thisElement, element) => {
67995
68544
  targetElement.style.transform = currentTransform !== 'none' ? `${currentTransform} ${action.value}` : action.value;
67996
68545
  break;
67997
68546
  }
68547
+ case 'revealImageValue': {
68548
+ if (targetElement) {
68549
+ revealImageValue(targetElement); // call your function here
68550
+ }
68551
+ break;
68552
+ }
68553
+ case 'scrollCellAfterEquationSolved': {
68554
+ if (targetElement) {
68555
+ handleSolvedEquationSubmissionAndScoreUpdate();
68556
+ }
68557
+ break;
68558
+ }
67998
68559
  case 'alignMatch': {
67999
68560
  const dropElement = targetElement;
68000
68561
  const dragElement = element;
68001
68562
  const container = document.getElementById(LidoContainer);
68002
68563
  const containerScale = getElementScale$1(container);
68003
68564
  dragElement.style.transform = 'translate(0,0)';
68004
- console.log('logg alinmatch');
68565
+ console.log("logg alinmatch");
68005
68566
  const dropRect = dropElement.getBoundingClientRect();
68006
68567
  const dragRect = dragElement.getBoundingClientRect();
68007
68568
  const dropCenterX = dropRect.left + dropRect.width / 2;
@@ -68087,10 +68648,76 @@ const executeActions = async (actionsString, thisElement, element) => {
68087
68648
  }
68088
68649
  break;
68089
68650
  }
68651
+ case 'highlightStarsAndDisapper': {
68652
+ const value = action.value;
68653
+ if (value && targetElement) {
68654
+ console.log('highlightStar action triggered');
68655
+ console.log('Target Element:', targetElement);
68656
+ await HighlightStarsOneByOne(targetElement, value);
68657
+ }
68658
+ break;
68659
+ }
68660
+ case 'boxAnimationOneByOne': {
68661
+ const value = action.value;
68662
+ if (value && targetElement) {
68663
+ await animateBoxCells(targetElement, value);
68664
+ }
68665
+ break;
68666
+ }
68667
+ case 'questionBoxAnimate': {
68668
+ const value = action.value;
68669
+ if (value && targetElement) {
68670
+ await questionBoxAnimation(targetElement, value);
68671
+ }
68672
+ break;
68673
+ }
68090
68674
  case 'slideAnimation': {
68091
68675
  slideAnimation();
68092
68676
  break;
68093
68677
  }
68678
+ case 'showBalanceSymbol': {
68679
+ const balanceEl = document.querySelector('lido-balance');
68680
+ if (!balanceEl)
68681
+ break;
68682
+ const leftVal = Number((_b = balanceEl.leftVal) !== null && _b !== void 0 ? _b : Number((_d = (_c = balanceEl.dataset) === null || _c === void 0 ? void 0 : _c.leftVal) !== null && _d !== void 0 ? _d : 0));
68683
+ const rightVal = Number((_e = balanceEl.rightVal) !== null && _e !== void 0 ? _e : Number((_g = (_f = balanceEl.dataset) === null || _f === void 0 ? void 0 : _f.rightVal) !== null && _g !== void 0 ? _g : 0));
68684
+ const symbol = leftVal > rightVal ? '>' : leftVal < rightVal ? '<' : '=';
68685
+ balanceEl.balanceSymbol = symbol;
68686
+ balanceEl.dataset.balanceSymbol = symbol;
68687
+ if (balanceEl.revealSymbol) {
68688
+ await balanceEl.revealSymbol();
68689
+ }
68690
+ else {
68691
+ balanceEl.showSymbol = true;
68692
+ }
68693
+ break;
68694
+ }
68695
+ case 'hideBalanceSymbol': {
68696
+ const balanceEl = document.querySelector('lido-balance');
68697
+ if (!balanceEl)
68698
+ break;
68699
+ if (balanceEl.hideSymbol) {
68700
+ await balanceEl.hideSymbol();
68701
+ }
68702
+ else {
68703
+ balanceEl.showSymbol = false;
68704
+ }
68705
+ break;
68706
+ }
68707
+ case 'sumTogetherAnimation': {
68708
+ const value = action.value;
68709
+ if (value) {
68710
+ SumTogetherAnimation(targetElement, value);
68711
+ }
68712
+ break;
68713
+ }
68714
+ case 'addText': {
68715
+ const value = action.value;
68716
+ if (value) {
68717
+ targetElement.textContent += value;
68718
+ }
68719
+ break;
68720
+ }
68094
68721
  default: {
68095
68722
  targetElement.style[action.action] = action.value;
68096
68723
  break;
@@ -68188,6 +68815,9 @@ const matchStringPattern = (pattern, arr) => {
68188
68815
  const patternGroups = pattern.split(',').map(group => group.trim());
68189
68816
  let arrIndex = 0;
68190
68817
  let options = new Set();
68818
+ if (patternGroups.length == 0) { // If pattern is empty
68819
+ return true;
68820
+ }
68191
68821
  if (patternGroups.length > 0) {
68192
68822
  if (arr.length === 0)
68193
68823
  return false; // If pattern is not empty but user provided array is empty, return false
@@ -68272,38 +68902,36 @@ const calculateScore = () => {
68272
68902
  gameScore.wrongMoves = 0;
68273
68903
  };
68274
68904
  async function onActivityComplete(dragElement, dropElement) {
68275
- var _a, _b;
68905
+ var _a;
68276
68906
  const container = document.getElementById(LidoContainer);
68277
68907
  if (!container)
68278
68908
  return;
68279
68909
  await executeActions("this.alignMatch='true'", dropElement, dragElement);
68280
- let dragScore = JSON.parse((_a = localStorage.getItem(DragSelectedMapKey)) !== null && _a !== void 0 ? _a : '{}');
68281
- const tabindex = dropElement.getAttribute('tab-index');
68282
- if (!dragScore[tabindex]) {
68283
- dragScore[tabindex] = [];
68910
+ if (dragElement && dropElement) {
68911
+ const isCorrect = dropElement['value'].toLowerCase().includes(dragElement['value'].toLowerCase());
68912
+ if (isCorrect) {
68913
+ const onCorrect = dropElement.getAttribute('onCorrect');
68914
+ if (onCorrect) {
68915
+ await executeActions(onCorrect, dropElement, dragElement);
68916
+ }
68917
+ }
68918
+ else {
68919
+ const onInCorrect = dropElement.getAttribute('onInCorrect');
68920
+ await executeActions(onInCorrect, dropElement, dragElement);
68921
+ }
68284
68922
  }
68285
- dragScore[tabindex].push(dragElement['value']);
68286
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragScore));
68923
+ let dragScore = buildDragSelectedMapFromDOM();
68924
+ const sortedValues = getSortedValuesArrayFromMap(dragScore);
68925
+ container.setAttribute(SelectedValuesKey, JSON.stringify(sortedValues));
68287
68926
  //localStorage
68288
- let drag = JSON.parse((_b = localStorage.getItem(DragMapKey)) !== null && _b !== void 0 ? _b : '{}');
68927
+ let drag = JSON.parse((_a = localStorage.getItem(DragMapKey)) !== null && _a !== void 0 ? _a : '{}');
68289
68928
  const index = dropElement.getAttribute('tab-index');
68290
68929
  if (!drag[index]) {
68291
68930
  drag[index] = [];
68292
68931
  }
68293
68932
  drag[index].push(dragElement.id);
68294
68933
  // localStorage.setItem(DragMapKey, JSON.stringify(drag));
68295
- const sortedKeys = Object.keys(dragScore).sort((a, b) => parseInt(a) - parseInt(b));
68296
- const sortedValues = sortedKeys.reduce((acc, key) => {
68297
- const values = dragScore[key];
68298
- if (values.length > 1) {
68299
- acc.push(`(${values.join('|')})`);
68300
- }
68301
- else {
68302
- acc.push(values[0]);
68303
- }
68304
- return acc;
68305
- }, []);
68306
- localStorage.setItem(SelectedValuesKey, JSON.stringify(sortedValues));
68934
+ Object.keys(dragScore).sort((a, b) => parseInt(a) - parseInt(b));
68307
68935
  if (dragElement && dropElement) {
68308
68936
  const isCorrect = dropElement['value'].toLowerCase().includes(dragElement['value'].toLowerCase());
68309
68937
  if (isCorrect) {
@@ -68320,8 +68948,7 @@ async function onActivityComplete(dragElement, dropElement) {
68320
68948
  const allElements = document.querySelectorAll("[type='drop']");
68321
68949
  allElements.forEach(otherElement => {
68322
68950
  var _a;
68323
- const dropObject = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
68324
- const storedTabIndexes = Object.keys(dropObject).map(Number);
68951
+ const storedTabIndexes = Object.keys(dragScore).map(Number);
68325
68952
  if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
68326
68953
  if (!(((_a = otherElement.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
68327
68954
  if (otherElement.tagName.toLowerCase() === 'lido-text') {
@@ -68373,81 +69000,101 @@ const handleShowCheck = () => {
68373
69000
  var _a, _b;
68374
69001
  const container = document.getElementById(LidoContainer);
68375
69002
  const objectiveString = container['objective'];
68376
- const selectValues = (_a = localStorage.getItem(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '';
69003
+ const selectValues = (_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '';
68377
69004
  const checkButton = document.querySelector('#lido-checkButton');
68378
- if (!selectValues || countPatternWords(selectValues) !== countPatternWords(objectiveString)) {
69005
+ if (!selectValues || countPatternWords(selectValues) < countPatternWords(objectiveString)) {
68379
69006
  executeActions("this.addClass='lido-disable-check-button'", checkButton);
68380
69007
  return;
68381
69008
  }
68382
69009
  const showCheck = container.getAttribute('show-check') == 'true';
68383
69010
  if (showCheck) {
68384
69011
  (_b = checkButton === null || checkButton === void 0 ? void 0 : checkButton.classList) === null || _b === void 0 ? void 0 : _b.remove('lido-disable-check-button');
69012
+ const balanceEl = document.querySelector('lido-balance');
69013
+ if (balanceEl) {
69014
+ if (!checkButton.hasAttribute('data-balance-listener')) {
69015
+ checkButton.addEventListener('click', async function onClick() {
69016
+ if (balanceResult && res) {
69017
+ await executeActions("this.showBalanceSymbol='true'", checkButton);
69018
+ checkButton.removeEventListener('click', onClick);
69019
+ }
69020
+ });
69021
+ checkButton.setAttribute('data-balance-listener', 'true');
69022
+ }
69023
+ }
68385
69024
  }
68386
69025
  else {
68387
69026
  validateObjectiveStatus();
68388
69027
  }
68389
69028
  };
68390
- const body = document.body;
69029
+ let res;
68391
69030
  const validateObjectiveStatus = async () => {
68392
- var _a;
69031
+ var _a, _b;
68393
69032
  const container = document.getElementById(LidoContainer);
68394
69033
  if (!container)
68395
69034
  return;
68396
69035
  const objectiveString = container['objective'];
69036
+ const additionalCheck = container.getAttribute('equationCheck');
69037
+ console.log('🚀 ~ validateObjectiveStatus ~ additionalCheck:', additionalCheck);
69038
+ let equationGiven = false;
68397
69039
  if (objectiveString == null || objectiveString.length === 0) {
68398
- const onCorrect = container.getAttribute('onCorrect');
68399
- if (onCorrect) {
68400
- await executeActions(onCorrect, container);
69040
+ if (additionalCheck) {
69041
+ equationGiven = true;
69042
+ }
69043
+ if (!equationGiven) {
69044
+ const onCorrect = container.getAttribute('onCorrect');
69045
+ if (onCorrect) {
69046
+ await executeActions(onCorrect, container);
69047
+ }
69048
+ storeActivityScore(100);
69049
+ storingEachActivityScore(true);
69050
+ triggerNextContainer();
69051
+ return;
68401
69052
  }
68402
- storeActivityScore(100);
68403
- storingEachActivityScore(true);
68404
- triggerNextContainer();
68405
- return;
68406
69053
  }
68407
- else {
68408
- const objectiveArray = (_a = JSON.parse(localStorage.getItem(SelectedValuesKey))) !== null && _a !== void 0 ? _a : [];
68409
- let res;
68410
- const additionalCheck = container.getAttribute('equationCheck');
68411
- if (!!additionalCheck) {
69054
+ const objectiveArray = (_b = JSON.parse((_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]')) !== null && _b !== void 0 ? _b : [];
69055
+ if (!!additionalCheck) {
69056
+ const balanceEl = document.querySelector('lido-balance');
69057
+ if (!balanceEl) {
68412
69058
  res = equationCheck(additionalCheck);
68413
- console.log('🚀 ~ handleShowCheck ~ res:', res);
68414
69059
  }
68415
69060
  else {
68416
- res = matchStringPattern(objectiveString, objectiveArray);
69061
+ res = balanceResult(container, objectiveString);
68417
69062
  }
68418
- if (res) {
68419
- const attach = container.getAttribute('appendToDropOnCompletion');
68420
- body.style.pointerEvents = 'none';
68421
- const onCorrect = container.getAttribute('onCorrect');
68422
- if (onCorrect) {
68423
- if (attach === 'true') {
68424
- appendingDragElementsInDrop();
68425
- }
68426
- await executeActions(onCorrect, container);
68427
- }
68428
- if (container.getAttribute('dropAttr') === 'EnableAnimation') {
68429
- setTimeout(() => {
68430
- triggerNextContainer();
68431
- }, 2000);
69063
+ console.log('🚀 ~ handleShowCheck ~ res:', res);
69064
+ }
69065
+ else {
69066
+ res = matchStringPattern(objectiveString, objectiveArray);
69067
+ }
69068
+ if (res) {
69069
+ const attach = container.getAttribute('appendToDropOnCompletion');
69070
+ const onCorrect = container.getAttribute('onCorrect');
69071
+ if (onCorrect) {
69072
+ if (attach === 'true') {
69073
+ appendingDragElementsInDrop();
68432
69074
  }
68433
- else {
69075
+ await executeActions(onCorrect, container);
69076
+ }
69077
+ if (container.getAttribute('dropAttr') === 'EnableAnimation') {
69078
+ setTimeout(() => {
68434
69079
  triggerNextContainer();
68435
- }
68436
- await calculateScore();
69080
+ }, 2000);
68437
69081
  }
68438
69082
  else {
68439
- const onInCorrect = container.getAttribute('onInCorrect');
68440
- await executeActions(onInCorrect, container);
68441
- const isContinueOnCorrect = container.getAttribute('is-continue-on-correct') === 'true';
68442
- if (!isContinueOnCorrect) {
68443
- triggerNextContainer();
68444
- await calculateScore();
68445
- }
69083
+ triggerNextContainer();
69084
+ }
69085
+ await calculateScore();
69086
+ }
69087
+ else {
69088
+ const onInCorrect = container.getAttribute('onInCorrect');
69089
+ await executeActions(onInCorrect, container);
69090
+ const isContinueOnCorrect = container.getAttribute('is-continue-on-correct') === 'true';
69091
+ if (!isContinueOnCorrect) {
69092
+ triggerNextContainer();
69093
+ await calculateScore();
68446
69094
  }
68447
69095
  }
68448
69096
  };
68449
69097
  const triggerNextContainer = () => {
68450
- body.style.pointerEvents = 'auto';
68451
69098
  AudioPlayer.getI().stop();
68452
69099
  // const event = new CustomEvent('nextContainer');
68453
69100
  console.log('🚀 ~ triggerNextContainer ~ event:', event);
@@ -68462,16 +69109,16 @@ const triggerPrevcontainer = () => {
68462
69109
  function convertUrlToRelative(url) {
68463
69110
  const container = document.getElementById(LidoContainer);
68464
69111
  const baseUrl = container.getAttribute('baseUrl');
68465
- if ((url === null || url === void 0 ? void 0 : url.startsWith('http')) || (url === null || url === void 0 ? void 0 : url.startsWith('blob')) || (url === null || url === void 0 ? void 0 : url.startsWith('data'))) {
69112
+ if ((url === null || url === void 0 ? void 0 : url.startsWith('http')) || (url === null || url === void 0 ? void 0 : url.startsWith('blob'))) {
68466
69113
  return url;
68467
69114
  }
68468
- if (baseUrl) {
68469
- const newUrl = url.startsWith('/') ? url.slice(1) : url;
68470
- if (newUrl.startsWith(baseUrl.replace(/^\/+|\/+$/g, '')))
68471
- return newUrl;
68472
- return baseUrl.endsWith('/') ? baseUrl + newUrl : `${baseUrl}/${newUrl}`;
69115
+ else if (baseUrl) {
69116
+ const newUrl = !url.startsWith('/') ? url : url.substring(1);
69117
+ return baseUrl + (baseUrl.endsWith('/') ? newUrl : '/' + newUrl);
69118
+ }
69119
+ else {
69120
+ return index$1.getAssetPath(url);
68473
69121
  }
68474
- return index$1.getAssetPath(url);
68475
69122
  }
68476
69123
  /**
68477
69124
  * Asynchronously speaks the given text using the browser's text-to-speech API.
@@ -68660,7 +69307,10 @@ const equationCheck = (additionalCheck) => {
68660
69307
  });
68661
69308
  // 3. Join the modified parts back into one string
68662
69309
  const resultString = modifiedParts.join('');
69310
+ console.log('🚀 ~ equationCheck ~ resultString:', resultString);
69311
+ // 4. Evaluate the final string as a mathematical expression
68663
69312
  const finalRes = evaluate(resultString);
69313
+ console.log('🚀 ~ equationCheck ~ finalRes:', finalRes);
68664
69314
  return finalRes;
68665
69315
  };
68666
69316
  const getElementsForQueries = (query) => {
@@ -68728,13 +69378,6 @@ const attachSpeakIcon = async (element) => {
68728
69378
  }
68729
69379
  element.appendChild(speakIconElement);
68730
69380
  };
68731
- const clearLocalStorage = () => {
68732
- localStorage.removeItem(DragSelectedMapKey);
68733
- localStorage.removeItem(DragMapKey);
68734
- localStorage.removeItem(SelectedValuesKey);
68735
- localStorage.removeItem(DropHasDrag);
68736
- localStorage.removeItem(DropLength);
68737
- };
68738
69381
  /**
68739
69382
  * Applies a delay to the element's visibility based on `delayVisible`.
68740
69383
  */
@@ -68820,6 +69463,230 @@ function generateUUIDFallback() {
68820
69463
  return v.toString(16);
68821
69464
  });
68822
69465
  }
69466
+ const revealImageValue = (imageEl) => {
69467
+ if (!imageEl)
69468
+ return;
69469
+ const value = imageEl.getAttribute('value');
69470
+ if (!value)
69471
+ return;
69472
+ let valueElement = imageEl.querySelector('.lido-display-hiddenvalue');
69473
+ if (!valueElement) {
69474
+ valueElement = document.createElement('div');
69475
+ valueElement.classList.add('lido-display-hiddenvalue');
69476
+ imageEl.style.position = 'relative';
69477
+ imageEl.appendChild(valueElement);
69478
+ }
69479
+ valueElement.innerText = value;
69480
+ };
69481
+ const setImageBackground = (el, color) => {
69482
+ if (!el)
69483
+ return;
69484
+ el.classList.add('lido-image-colorize');
69485
+ const img = el.querySelector('img');
69486
+ if (img) {
69487
+ // use same image as mask
69488
+ el.style.setProperty('--mask-url', `url(${img.src})`);
69489
+ }
69490
+ if (color === 'red') {
69491
+ el.style.setProperty('--tint-color', '#ff0000');
69492
+ }
69493
+ else if (color === 'green') {
69494
+ el.style.setProperty('--tint-color', '#00c853');
69495
+ }
69496
+ else {
69497
+ el.style.removeProperty('--tint-color');
69498
+ el.style.removeProperty('--mask-url');
69499
+ }
69500
+ };
69501
+ const HighlightStarsOneByOne = async (element, value) => {
69502
+ if (!element)
69503
+ return;
69504
+ if (!value)
69505
+ return;
69506
+ // Dynamically find the parent row of stars
69507
+ const stars = Array.from(element.children);
69508
+ console.log('starRow', stars);
69509
+ for (const star of stars) {
69510
+ // Highlight the star
69511
+ star.classList.add('lido-glow');
69512
+ // Play star sound
69513
+ await AudioPlayer.getI().play(star);
69514
+ // Fade out the star (disappear)
69515
+ star.style.opacity = '0';
69516
+ star.style.visibility = 'hidden';
69517
+ await new Promise(resolve => setTimeout(resolve, 300)); // Wait for fade-out to complete
69518
+ // Remove the highlight
69519
+ star.classList.remove('lido-glow');
69520
+ }
69521
+ };
69522
+ const animateBoxCells = async (element, value) => {
69523
+ if (!element)
69524
+ return;
69525
+ if (!value)
69526
+ return;
69527
+ // Select all cells with the attribute type="box"
69528
+ const boxCells = Array.from(element.children);
69529
+ console.log('boxCells', boxCells);
69530
+ if (!boxCells)
69531
+ return;
69532
+ boxCells.forEach(cell => {
69533
+ // Reset any previous styles
69534
+ cell.style.visibility = 'hidden';
69535
+ });
69536
+ // Animate each cell one by one
69537
+ for (const cell of boxCells) {
69538
+ cell.style.visibility = 'visible';
69539
+ cell.style.opacity = '1';
69540
+ // Apply the "come from top" animation
69541
+ cell.classList.add('lido-box-highlight');
69542
+ // Delay for each cell to come one after another
69543
+ await new Promise(resolve => setTimeout(resolve, 600)); // Adjust delay as needed
69544
+ cell.classList.remove('lido-box-highlight');
69545
+ }
69546
+ // After all cells have come down, apply the bounce animation
69547
+ for (const cell of boxCells) {
69548
+ // play the text child inside cell
69549
+ await AudioPlayer.getI().play(cell);
69550
+ }
69551
+ };
69552
+ const questionBoxAnimation = async (element, value) => {
69553
+ if (!element)
69554
+ return;
69555
+ if (!value)
69556
+ return;
69557
+ // Select all drag elements and drop elements
69558
+ const dragElements = Array.from(element.querySelectorAll("[type='drag']"));
69559
+ // Ensure all drag childrens which is dropped disappear
69560
+ dragElements.forEach(dragElement => {
69561
+ if (dragElement.hasAttribute('drop-to')) {
69562
+ dragElement.style.transition = 'opacity 0.5s ease';
69563
+ dragElement.style.opacity = '0'; // Fade out
69564
+ setTimeout(() => {
69565
+ dragElement.remove(); // Remove from view after fade-out
69566
+ }, 500);
69567
+ }
69568
+ });
69569
+ // Reveal all drop childrens which is hidden
69570
+ const dropElements = Array.from(element.querySelectorAll("[type='drop']"));
69571
+ let check = false;
69572
+ dropElements.forEach(dropEl => {
69573
+ const dropVal = dropEl.getAttribute("value");
69574
+ if (dropVal && dropEl.innerText.trim() === "?") {
69575
+ dropEl.innerText = dropVal;
69576
+ if (dropElements.length > 1 && check == false) {
69577
+ if (window.innerWidth > window.innerHeight) {
69578
+ dropEl.style.marginRight = "-45px";
69579
+ }
69580
+ else {
69581
+ dropEl.style.marginRight = "-65px";
69582
+ }
69583
+ check = true;
69584
+ }
69585
+ }
69586
+ });
69587
+ };
69588
+ const SumTogetherAnimation = async (element, value) => {
69589
+ if (!element)
69590
+ return;
69591
+ if (!value)
69592
+ return;
69593
+ const container = document.getElementById(LidoContainer);
69594
+ if (!container)
69595
+ return;
69596
+ // Expecting structure: [_, TopRow, questionRow, optionRow, ...]
69597
+ const TopRow = Array.from(element.children)[1];
69598
+ const questionRow = Array.from(element.children)[2];
69599
+ const optionRow = Array.from(element.children)[3];
69600
+ if (!TopRow || !questionRow || !optionRow)
69601
+ return;
69602
+ const topRowChildren = Array.from(TopRow.children);
69603
+ const questionRowChildren = Array.from(questionRow.children);
69604
+ const firstNumberEl = questionRowChildren[0];
69605
+ const signElement = questionRowChildren[1];
69606
+ const secondNumberEl = questionRowChildren[2];
69607
+ const equalElement = questionRowChildren[3];
69608
+ const answerElement = questionRowChildren[4];
69609
+ // helper functions
69610
+ const showElement = (el) => {
69611
+ if (!el)
69612
+ return;
69613
+ el.style.visibility = 'visible';
69614
+ el.style.display = '';
69615
+ el.style.opacity = '1';
69616
+ };
69617
+ const readNumber = (el) => {
69618
+ if (!el)
69619
+ return 0;
69620
+ const v = (el.getAttribute && (el.getAttribute('value') || el.getAttribute('string'))) || el.textContent || '';
69621
+ return parseInt(String(v).trim(), 10) || 0;
69622
+ };
69623
+ const elementAppearance = async (flag) => {
69624
+ if (flag) {
69625
+ if (firstNumberEl) {
69626
+ await new Promise(r => setTimeout(r, 200));
69627
+ showElement(firstNumberEl);
69628
+ }
69629
+ if (signElement) {
69630
+ await new Promise(r => setTimeout(r, 200));
69631
+ showElement(signElement);
69632
+ }
69633
+ }
69634
+ else {
69635
+ if (secondNumberEl) {
69636
+ await new Promise(r => setTimeout(r, 200));
69637
+ showElement(secondNumberEl);
69638
+ }
69639
+ if (equalElement) {
69640
+ await new Promise(r => setTimeout(r, 300));
69641
+ showElement(equalElement);
69642
+ }
69643
+ if (optionRow) {
69644
+ await new Promise(r => setTimeout(r, 300));
69645
+ showElement(optionRow);
69646
+ }
69647
+ if (answerElement) {
69648
+ await new Promise(r => setTimeout(r, 200));
69649
+ showElement(answerElement);
69650
+ }
69651
+ }
69652
+ };
69653
+ const number1 = readNumber(firstNumberEl);
69654
+ const number2 = readNumber(secondNumberEl);
69655
+ const sign = ((signElement && ((signElement.getAttribute('string') || signElement.textContent) || '')).toString().trim() === '+') ? '+' : '-';
69656
+ if (sign === '-') {
69657
+ // '-' flow: reveal one by one then change bgColor of last B to red
69658
+ for (let i = 0; i < topRowChildren.length; i++) {
69659
+ await new Promise(resolve => setTimeout(resolve, 75));
69660
+ showElement(topRowChildren[i]);
69661
+ }
69662
+ elementAppearance(true);
69663
+ await new Promise(r => setTimeout(r, 500));
69664
+ for (let k = 0; k < Math.min(number2, topRowChildren.length); k++) {
69665
+ const idx = topRowChildren.length - 1 - k;
69666
+ setImageBackground(topRowChildren[idx], 'red');
69667
+ await new Promise(r => setTimeout(r, 200));
69668
+ }
69669
+ elementAppearance(false);
69670
+ }
69671
+ else {
69672
+ // '+' flow: hide all, then showElement first A, then showElement next B in green
69673
+ for (let i = 0; i < Math.min(number1, topRowChildren.length); i++) {
69674
+ await new Promise(resolve => setTimeout(resolve, 120));
69675
+ showElement(topRowChildren[i]);
69676
+ }
69677
+ elementAppearance(true);
69678
+ await new Promise(r => setTimeout(r, 500));
69679
+ for (let j = 0; j < Math.min(number2, Math.max(0, topRowChildren.length - number1)); j++) {
69680
+ const idx = number1 + j;
69681
+ if (topRowChildren[idx]) {
69682
+ showElement(topRowChildren[idx]);
69683
+ setImageBackground(topRowChildren[idx], 'green');
69684
+ }
69685
+ await new Promise(r => setTimeout(r, 80));
69686
+ }
69687
+ elementAppearance(false);
69688
+ }
69689
+ };
68823
69690
 
68824
69691
  exports.ActivityScoreKey = ActivityScoreKey;
68825
69692
  exports.AudioPlayer = AudioPlayer;
@@ -68830,12 +69697,12 @@ exports.RiveService = RiveService;
68830
69697
  exports.SelectedValuesKey = SelectedValuesKey;
68831
69698
  exports.attachSpeakIcon = attachSpeakIcon;
68832
69699
  exports.calculateScale = calculateScale;
68833
- exports.clearLocalStorage = clearLocalStorage;
68834
69700
  exports.commonjsGlobal = commonjsGlobal;
68835
69701
  exports.convertUrlToRelative = convertUrlToRelative;
68836
69702
  exports.dispatchActivityChangeEvent = dispatchActivityChangeEvent;
68837
69703
  exports.dispatchGameCompletedEvent = dispatchGameCompletedEvent;
68838
69704
  exports.dispatchGameExitEvent = dispatchGameExitEvent;
69705
+ exports.equationCheck = equationCheck;
68839
69706
  exports.executeActions = executeActions;
68840
69707
  exports.exitUrl = exitUrl;
68841
69708
  exports.fingerUrl = fingerUrl;
@@ -68848,7 +69715,6 @@ exports.handleElementClick = handleElementClick;
68848
69715
  exports.handleFloatElementPosition = handleFloatElementPosition;
68849
69716
  exports.handlingChildElements = handlingChildElements;
68850
69717
  exports.initEventsForElement = initEventsForElement;
68851
- exports.matchStringPattern = matchStringPattern;
68852
69718
  exports.nextUrl = nextUrl;
68853
69719
  exports.parseProp = parseProp;
68854
69720
  exports.prevUrl = prevUrl;
@@ -68860,3 +69726,4 @@ exports.storingEachActivityScore = storingEachActivityScore;
68860
69726
  exports.tinyColor = tinyColor;
68861
69727
  exports.triggerNextContainer = triggerNextContainer;
68862
69728
  exports.triggerPrevcontainer = triggerPrevcontainer;
69729
+ exports.validateObjectiveStatus = validateObjectiveStatus;