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,5 +1,5 @@
1
1
  const NAMESPACE = 'lido-player';
2
- const BUILD = /* lido-player */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: true, cmpDidRender: false, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: true, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: false, constructableCSS: true, cssAnnotations: true, devTools: false, disconnectedCallback: true, element: false, event: false, experimentalScopedSlotChanges: false, experimentalSlotFixes: false, formAssociated: false, hasRenderFn: true, hostListener: false, hostListenerTarget: false, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: false, hotModuleReplacement: false, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, hydratedSelectorName: "hydrated", invisiblePrehydration: true, isDebug: false, isDev: false, isTesting: false, lazyLoad: false, lifecycle: true, lifecycleDOMEvents: false, member: true, method: false, mode: false, observeAttribute: true, profile: false, prop: true, propBoolean: true, propMutable: true, propNumber: true, propString: true, reflect: true, scoped: false, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: false, slot: true, slotChildNodesFix: false, slotRelocation: true, state: true, style: true, svg: false, taskQueue: true, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: false, vdomKey: true, vdomListener: true, vdomPropOrAttr: true, vdomRef: true, vdomRender: true, vdomStyle: true, vdomText: true, vdomXlink: true, watchCallback: true };
2
+ const BUILD = /* lido-player */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: true, cmpDidRender: false, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: true, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: false, constructableCSS: true, cssAnnotations: true, devTools: false, disconnectedCallback: true, element: false, event: true, experimentalScopedSlotChanges: false, experimentalSlotFixes: false, formAssociated: false, hasRenderFn: true, hostListener: false, hostListenerTarget: false, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: false, hotModuleReplacement: false, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, hydratedSelectorName: "hydrated", invisiblePrehydration: true, isDebug: false, isDev: false, isTesting: false, lazyLoad: false, lifecycle: true, lifecycleDOMEvents: false, member: true, method: true, mode: false, observeAttribute: true, profile: false, prop: true, propBoolean: true, propMutable: true, propNumber: true, propString: true, reflect: true, scoped: false, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: false, slot: true, slotChildNodesFix: false, slotRelocation: true, state: true, style: true, svg: false, taskQueue: true, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: false, vdomKey: true, vdomListener: true, vdomPropOrAttr: true, vdomRef: true, vdomRender: true, vdomStyle: true, vdomText: true, vdomXlink: true, watchCallback: true };
3
3
 
4
4
  /*
5
5
  Stencil Client Platform v4.20.0 | MIT Licensed | https://stenciljs.com
@@ -258,6 +258,22 @@ var parsePropertyValue = (propValue, propType) => {
258
258
  }
259
259
  return propValue;
260
260
  };
261
+ var getElement = (ref) => ref;
262
+
263
+ // src/runtime/event-emitter.ts
264
+ var createEvent = (ref, name, flags) => {
265
+ const elm = getElement(ref);
266
+ return {
267
+ emit: (detail) => {
268
+ return emitEvent(elm, name, {
269
+ bubbles: !!(flags & 4 /* Bubbles */),
270
+ composed: !!(flags & 2 /* Composed */),
271
+ cancelable: !!(flags & 1 /* Cancellable */),
272
+ detail
273
+ });
274
+ }
275
+ };
276
+ };
261
277
  var emitEvent = (elm, name, opts) => {
262
278
  const ev = plt$1.ce(name, opts);
263
279
  elm.dispatchEvent(ev);
@@ -1324,7 +1340,6 @@ var setNonce = (nonce) => plt$1.$nonce$ = nonce;
1324
1340
  // src/runtime/platform-options.ts
1325
1341
  var setPlatformOptions = (opts) => Object.assign(plt$1, opts);
1326
1342
 
1327
- const DragSelectedMapKey = 'lidoDragSelectedMap';
1328
1343
  const DragMapKey = 'lidoDragMap';
1329
1344
  const SelectedValuesKey = 'lidoSelectedValues';
1330
1345
  const ActivityScoreKey = 'lidoActivityScore';
@@ -1338,7 +1353,6 @@ const GameExitKey = 'lidoGameExit';
1338
1353
  const ElementDropKey = 'lidoElementDrop';
1339
1354
  const ElementClickKey = 'lidoElementClick';
1340
1355
  const DropLength = 'dropLength';
1341
- const DropHasDrag = 'dropHasDrag';
1342
1356
  const DropToAttr = 'drop-to';
1343
1357
  const DropTimeAttr = 'drop-time';
1344
1358
  const LidoContainer = 'lido-container';
@@ -1557,6 +1571,88 @@ function stopHighlightForSpeakingElement(element) {
1557
1571
  // element.style.border = '';
1558
1572
  }
1559
1573
 
1574
+ function updateBalanceOnDrop(dragElement, dropElement) {
1575
+ const balanceEl = document.querySelector('lido-balance');
1576
+ if (!balanceEl)
1577
+ return;
1578
+ const leftDrag = Array.from(document.querySelectorAll('[drop-to^="lefthandle"]'));
1579
+ const rightDrag = Array.from(document.querySelectorAll('[drop-to^="righthandle"]'));
1580
+ balanceEl.leftVal = calculateValue(leftDrag, balanceEl.operation);
1581
+ balanceEl.rightVal = calculateValue(rightDrag, balanceEl.operation);
1582
+ console.log("leftpan:", balanceEl.leftVal, "rightpan:", balanceEl.rightVal);
1583
+ if (balanceEl.updateTilt) {
1584
+ balanceEl.updateTilt(balanceEl.leftVal, balanceEl.rightVal);
1585
+ }
1586
+ }
1587
+ function calculateValue(elements, operation) {
1588
+ if (elements.length === 0)
1589
+ return 0;
1590
+ if (operation === "count") {
1591
+ return elements.length;
1592
+ }
1593
+ const ADD = ["add", "+"];
1594
+ const SUBTRACT = ["subtract", "-"];
1595
+ const MULTIPLY = ["multiply", "*"];
1596
+ const DIVIDE = ["divide", "/"];
1597
+ const expr = elements
1598
+ .map(el => el.getAttribute("value") || "0")
1599
+ .join(ADD.includes(operation) ? " + " :
1600
+ SUBTRACT.includes(operation) ? " - " :
1601
+ MULTIPLY.includes(operation) ? " * " :
1602
+ DIVIDE.includes(operation) ? " / " : " + ");
1603
+ try {
1604
+ const res = equationCheck(expr);
1605
+ if (typeof res === "number") {
1606
+ return res;
1607
+ }
1608
+ else if (typeof res === "boolean") {
1609
+ return res ? 1 : 0;
1610
+ }
1611
+ else {
1612
+ return parseFloat(expr) || 0;
1613
+ }
1614
+ }
1615
+ catch (e) {
1616
+ console.warn("invalid exp", expr);
1617
+ return 0;
1618
+ }
1619
+ }
1620
+ function balanceResult(container, objectiveString) {
1621
+ var _a, _b, _c, _d, _e, _f;
1622
+ const additionalCheck = container.getAttribute('equationCheck');
1623
+ if (!additionalCheck)
1624
+ return false;
1625
+ const balanceEl = document.querySelector('lido-balance');
1626
+ if (!balanceEl)
1627
+ return false;
1628
+ 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);
1629
+ 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);
1630
+ const hasLeft = !isNaN(leftVal) && leftVal !== 0;
1631
+ const hasRight = !isNaN(rightVal) && rightVal !== 0;
1632
+ if (!hasLeft || !hasRight) {
1633
+ return false;
1634
+ }
1635
+ const symbol = leftVal > rightVal ? '>' : leftVal < rightVal ? '<' : '=';
1636
+ const res = objectiveString === symbol;
1637
+ console.log("Result:", res);
1638
+ return res;
1639
+ }
1640
+
1641
+ function buildDropHasDragFromDOM() {
1642
+ const dropHasDrag = {};
1643
+ const dropElements = document.querySelectorAll("[type='drop']");
1644
+ dropElements.forEach(drop => {
1645
+ const tabIndex = drop.getAttribute("tab-index") || drop.id;
1646
+ const assignedDrag = document.querySelector(`[${DropToAttr}="${drop.id}"]`);
1647
+ const isFull = !!assignedDrag;
1648
+ drop.setAttribute("is-full", String(isFull));
1649
+ dropHasDrag[tabIndex] = {
1650
+ drop: drop.id,
1651
+ isFull
1652
+ };
1653
+ });
1654
+ return dropHasDrag;
1655
+ }
1560
1656
  // Function to get the scale of an element
1561
1657
  const getElementScale$1 = (el) => {
1562
1658
  el.style.animation = 'unset';
@@ -1607,7 +1703,7 @@ function enableDraggingWithScaling(element) {
1607
1703
  isDragging = false;
1608
1704
  return;
1609
1705
  }
1610
- AudioPlayer.getI().stop();
1706
+ // AudioPlayer.getI().stop();
1611
1707
  removeHighlight(element);
1612
1708
  isDragging = true;
1613
1709
  isClicked = true;
@@ -1711,7 +1807,6 @@ function enableDraggingWithScaling(element) {
1711
1807
  // Start observing the element
1712
1808
  observer.observe(container, observerConfig);
1713
1809
  const onMove = (event) => {
1714
- console.log("moved");
1715
1810
  if (!isDragging)
1716
1811
  return;
1717
1812
  if (isDraggingDisabled) {
@@ -1720,7 +1815,7 @@ function enableDraggingWithScaling(element) {
1720
1815
  }
1721
1816
  isClicked = false;
1722
1817
  element.style.transition = 'none';
1723
- const containerScale = calculateScale();
1818
+ const containerScale = getElementScale$1(container);
1724
1819
  let dx = 0;
1725
1820
  let dy = 0;
1726
1821
  if (event instanceof MouseEvent) {
@@ -1742,7 +1837,7 @@ function enableDraggingWithScaling(element) {
1742
1837
  // Reset styles for all elements
1743
1838
  allElements.forEach(otherElement => {
1744
1839
  var _a;
1745
- const dropObject = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
1840
+ const dropObject = buildDragSelectedMapFromDOM();
1746
1841
  const storedTabIndexes = Object.keys(dropObject).map(Number);
1747
1842
  if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
1748
1843
  if (!(((_a = element.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
@@ -1800,7 +1895,7 @@ function enableDraggingWithScaling(element) {
1800
1895
  allElements.forEach(otherElement => {
1801
1896
  allElements.forEach(otherElement => {
1802
1897
  var _a;
1803
- const dropObject = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
1898
+ const dropObject = buildDragSelectedMapFromDOM();
1804
1899
  const storedTabIndexes = Object.keys(dropObject).map(Number);
1805
1900
  if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
1806
1901
  if (!(((_a = element.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
@@ -1964,14 +2059,18 @@ function handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedV
1964
2059
  let prevDropItem = Object.values(dropHasDrag).find(item => document.getElementById(item.drop) === currentDrop);
1965
2060
  if (prevDropItem) {
1966
2061
  prevDropItem.isFull = false;
1967
- localStorage.setItem(DropHasDrag, JSON.stringify(dropHasDrag));
2062
+ // container.setAttribute(DropHasDrag, JSON.stringify(dropHasDrag));
2063
+ const dropEl = document.getElementById(prevDropItem.drop);
2064
+ if (dropEl) {
2065
+ dropEl.removeAttribute('is-full');
2066
+ }
1968
2067
  }
1969
2068
  dragToDropMap.delete(dragElement);
1970
2069
  }
1971
2070
  if (selectedValueData) {
1972
2071
  let selectedValue = JSON.parse(selectedValueData);
1973
2072
  selectedValue = selectedValue.filter(value => value != dragElement['value']);
1974
- localStorage.setItem(SelectedValuesKey, JSON.stringify(selectedValue));
2073
+ container.setAttribute(SelectedValuesKey, JSON.stringify(selectedValue));
1975
2074
  }
1976
2075
  if (dragSelectedData) {
1977
2076
  let dragSelected = JSON.parse(dragSelectedData);
@@ -1979,14 +2078,15 @@ function handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedV
1979
2078
  if (dragPreDropElement) {
1980
2079
  delete dragSelected[dragPreDropElement.getAttribute('tab-index')];
1981
2080
  }
1982
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragSelected));
2081
+ // container.setAttribute(DragSelectedMapKey, JSON.stringify(dragSelected));
1983
2082
  dragElement.removeAttribute(DropToAttr);
1984
2083
  updateDropBorder(currentDrop);
2084
+ updateBalanceOnDrop();
1985
2085
  }
1986
2086
  const allElements = document.querySelectorAll("[type='drop']");
1987
2087
  allElements.forEach(otherElement => {
1988
2088
  var _a;
1989
- const dropObject = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
2089
+ const dropObject = buildDragSelectedMapFromDOM();
1990
2090
  const storedTabIndexes = Object.keys(dropObject).map(Number);
1991
2091
  if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
1992
2092
  if (!(((_a = otherElement.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
@@ -2011,20 +2111,22 @@ function handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedV
2011
2111
  });
2012
2112
  handleShowCheck();
2013
2113
  }
2114
+ const tempVanishedValues = [];
2014
2115
  async function onElementDropComplete(dragElement, dropElement) {
2015
- var _a, _b, _c, _d, _e;
2016
- const selectedValueData = localStorage.getItem(SelectedValuesKey) || '';
2017
- const dragSelectedData = localStorage.getItem(DragSelectedMapKey);
2018
- localStorage.getItem(DragMapKey);
2019
- console.log("dragggedddd elem", { value: dragElement.getAttribute("value") });
2020
- let dropHasDrag = JSON.parse(localStorage.getItem(DropHasDrag) || ' {}');
2116
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2021
2117
  const container = document.getElementById(LidoContainer);
2118
+ const selectedValueData = (_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : "[]";
2119
+ const dragSelectedData = JSON.stringify(buildDragSelectedMapFromDOM());
2120
+ const dropSelectedDataobject = buildDragSelectedMapFromDOM();
2121
+ JSON.stringify(dropSelectedDataobject);
2122
+ console.log("dragggedddd elem", { value: dragElement.getAttribute("value") });
2123
+ let dropHasDrag = buildDropHasDragFromDOM();
2022
2124
  if (!dropElement) {
2023
2125
  handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData);
2024
2126
  return;
2025
2127
  }
2026
2128
  const dropTabIndex = dropElement.getAttribute('tab-index');
2027
- if ((_a = dropHasDrag[dropTabIndex]) === null || _a === void 0 ? void 0 : _a.isFull) {
2129
+ if ((_b = dropHasDrag[dropTabIndex]) === null || _b === void 0 ? void 0 : _b.isFull) {
2028
2130
  handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData);
2029
2131
  return;
2030
2132
  }
@@ -2036,9 +2138,10 @@ async function onElementDropComplete(dragElement, dropElement) {
2036
2138
  handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData);
2037
2139
  return;
2038
2140
  }
2141
+ // let isCorrect = dropElement.getAttribute('value').toLowerCase().includes(dragElement.getAttribute('value').toLowerCase());
2039
2142
  let isCorrect;
2040
- const dragValue = ((_b = dragElement.getAttribute('value')) === null || _b === void 0 ? void 0 : _b.trim()) || "";
2041
- const dropValue = ((_c = dropElement.getAttribute('value')) === null || _c === void 0 ? void 0 : _c.trim()) || "";
2143
+ const dragValue = ((_c = dragElement.getAttribute('value')) === null || _c === void 0 ? void 0 : _c.trim()) || "";
2144
+ const dropValue = ((_d = dropElement.getAttribute('value')) === null || _d === void 0 ? void 0 : _d.trim()) || "";
2042
2145
  if (Number(dragValue)) {
2043
2146
  const dragNum = Number(dragValue);
2044
2147
  //array of numbers
@@ -2052,8 +2155,7 @@ async function onElementDropComplete(dragElement, dropElement) {
2052
2155
  }
2053
2156
  }
2054
2157
  else {
2055
- //strings
2056
- isCorrect = dropValue.toLowerCase().includes(dragValue.toLowerCase());
2158
+ isCorrect = dropElement.getAttribute('value').toLowerCase().includes(dragElement.getAttribute('value').toLowerCase());
2057
2159
  }
2058
2160
  if (!isCorrect) {
2059
2161
  dragElement.style.transition = 'transform 0.5s ease';
@@ -2068,7 +2170,7 @@ async function onElementDropComplete(dragElement, dropElement) {
2068
2170
  // delete stored[oldDropIndex];
2069
2171
  // localStorage.setItem(localStorageKey, JSON.stringify(stored));
2070
2172
  // }
2071
- // handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData, dropSelectedData);
2173
+ handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData);
2072
2174
  }, 500);
2073
2175
  if (dragElement['type'] === 'option') {
2074
2176
  const childs = Array.from(container.querySelectorAll(`[value="${dragElement['value']}"]`));
@@ -2087,6 +2189,7 @@ async function onElementDropComplete(dragElement, dropElement) {
2087
2189
  if (checkdropAttr && checkdropAttr.toLowerCase() === DropMode.EnableAnimation.toLowerCase()) {
2088
2190
  container.style.pointerEvents = "none";
2089
2191
  setTimeout(() => {
2192
+ var _a, _b, _c;
2090
2193
  const div = document.createElement('div');
2091
2194
  container.append(div);
2092
2195
  div.classList.add('after-drop-popup-container');
@@ -2095,6 +2198,11 @@ async function onElementDropComplete(dragElement, dropElement) {
2095
2198
  const allDragElements = container.querySelectorAll('[type="drag"]');
2096
2199
  const dragParents = Array.from(allDragElements).map(el => el.parentElement);
2097
2200
  const allSameParent = dragParents.every(parent => parent === dragElement.parentElement);
2201
+ JSON.parse((_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]');
2202
+ const vanishedValue = (_b = dragElement.getAttribute('value')) !== null && _b !== void 0 ? _b : (_c = dragElement.textContent) === null || _c === void 0 ? void 0 : _c.trim();
2203
+ if (vanishedValue) {
2204
+ tempVanishedValues.push(vanishedValue);
2205
+ }
2098
2206
  // Remove from old parents
2099
2207
  if (allSameParent) {
2100
2208
  dragElement.remove();
@@ -2118,6 +2226,16 @@ async function onElementDropComplete(dragElement, dropElement) {
2118
2226
  setTimeout(() => {
2119
2227
  div.remove();
2120
2228
  container.style.pointerEvents = 'auto';
2229
+ const objective = container.getAttribute('objective');
2230
+ if (objective && tempVanishedValues.map(v => v.trim()).sort().join(',') === objective.split(',').map(v => v.trim()).sort().join(',')) {
2231
+ (async () => {
2232
+ isCorrect = true;
2233
+ const onCorrect = (container === null || container === void 0 ? void 0 : container.getAttribute('onCorrect')) || '';
2234
+ await executeActions(onCorrect, container);
2235
+ window.dispatchEvent(new CustomEvent(NextContainerKey));
2236
+ tempVanishedValues.length = 0;
2237
+ })();
2238
+ }
2121
2239
  }, 800); // match animation duration
2122
2240
  }, 2000); // stay for 2 seconds
2123
2241
  }, 250);
@@ -2125,6 +2243,12 @@ async function onElementDropComplete(dragElement, dropElement) {
2125
2243
  }
2126
2244
  }
2127
2245
  if (dropElement) {
2246
+ let selectedValues = JSON.parse((_e = container.getAttribute(SelectedValuesKey)) !== null && _e !== void 0 ? _e : "[]");
2247
+ const dragValue = dragElement.getAttribute('value');
2248
+ if (dragValue && !selectedValues.includes(dragValue)) {
2249
+ selectedValues.push(dragValue);
2250
+ }
2251
+ container.setAttribute(SelectedValuesKey, JSON.stringify(selectedValues));
2128
2252
  if (dropElement.getAttribute('drop-attr') === 'stretch') {
2129
2253
  if (!dropElement.hasAttribute('data-original-width')) {
2130
2254
  const computedStyle = window.getComputedStyle(dropElement);
@@ -2133,15 +2257,16 @@ async function onElementDropComplete(dragElement, dropElement) {
2133
2257
  const dragWidth = dragElement.offsetWidth;
2134
2258
  dropElement.style.width = `${dragWidth}px`;
2135
2259
  }
2136
- if (!(((_d = dropElement.getAttribute('dropAttr')) === null || _d === void 0 ? void 0 : _d.toLowerCase()) === DropMode.Diagonal) && (dropElement.getAttribute('minDrops') === '1' || !dropElement.getAttribute('minDrops'))) {
2260
+ if (!(((_f = dropElement.getAttribute('dropAttr')) === null || _f === void 0 ? void 0 : _f.toLowerCase()) === DropMode.Diagonal) && (dropElement.getAttribute('minDrops') === '1' || !dropElement.getAttribute('minDrops'))) {
2137
2261
  const isisFull = Object.values(dropHasDrag).find(item => document.getElementById(item.drop) === dropElement);
2138
2262
  if (isisFull) {
2139
2263
  isisFull.isFull = true;
2264
+ dropElement.setAttribute('is-full', 'true');
2140
2265
  }
2141
2266
  else {
2142
2267
  console.warn('No matching drop item found for', dropElement);
2143
2268
  }
2144
- localStorage.setItem(DropHasDrag, JSON.stringify(dropHasDrag));
2269
+ // container.setAttribute(DropHasDrag, JSON.stringify(dropHasDrag));
2145
2270
  if (dragSelectedData) {
2146
2271
  let dragSelected = JSON.parse(dragSelectedData);
2147
2272
  for (const key in dragSelected) {
@@ -2154,7 +2279,7 @@ async function onElementDropComplete(dragElement, dropElement) {
2154
2279
  }
2155
2280
  }
2156
2281
  }
2157
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragSelected));
2282
+ // container.setAttribute(DragSelectedMapKey, JSON.stringify(dragSelected));
2158
2283
  }
2159
2284
  dragElement.classList.add('dropped');
2160
2285
  if (dragElement) {
@@ -2167,7 +2292,7 @@ async function onElementDropComplete(dragElement, dropElement) {
2167
2292
  dragElement.setAttribute(DropTimeAttr, new Date().getTime().toString());
2168
2293
  }
2169
2294
  // Check for overlaps and highlight only the most overlapping element
2170
- if (dropElement && !((_e = dropHasDrag[dropTabIndex]) === null || _e === void 0 ? void 0 : _e.isFull)) {
2295
+ if (dropElement && !((_g = dropHasDrag[dropTabIndex]) === null || _g === void 0 ? void 0 : _g.isFull)) {
2171
2296
  let mostOverlappedElement = findMostoverlappedElement$1(dragElement, 'drag');
2172
2297
  const isAllowOnlyOneDrop = dropElement.getAttribute('is-allow-only-one-drop') === 'true' || '';
2173
2298
  if (mostOverlappedElement && isAllowOnlyOneDrop) {
@@ -2176,7 +2301,7 @@ async function onElementDropComplete(dragElement, dropElement) {
2176
2301
  const allElements = document.querySelectorAll("[type='drop']");
2177
2302
  allElements.forEach(otherElement => {
2178
2303
  var _a;
2179
- const dropObject = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
2304
+ const dropObject = buildDragSelectedMapFromDOM();
2180
2305
  const storedTabIndexes = Object.keys(dropObject).map(Number);
2181
2306
  if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
2182
2307
  if (!(((_a = otherElement.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
@@ -2208,13 +2333,14 @@ async function onElementDropComplete(dragElement, dropElement) {
2208
2333
  handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData);
2209
2334
  return;
2210
2335
  }
2336
+ updateBalanceOnDrop();
2211
2337
  if (dragSelectedData) {
2212
2338
  let currentDrop = dragToDropMap.get(dragElement);
2213
2339
  if (currentDrop) {
2214
2340
  let prevDropItem = Object.values(dropHasDrag).find(item => document.getElementById(item.drop) === currentDrop);
2215
2341
  if (prevDropItem) {
2216
2342
  prevDropItem.isFull = false;
2217
- localStorage.setItem(DropHasDrag, JSON.stringify(dropHasDrag));
2343
+ // container.setAttribute(DropHasDrag, JSON.stringify(dropHasDrag));
2218
2344
  reduceSizeToOriginal();
2219
2345
  }
2220
2346
  }
@@ -2227,9 +2353,9 @@ async function onElementDropComplete(dragElement, dropElement) {
2227
2353
  // }
2228
2354
  // localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragSelected));
2229
2355
  }
2230
- let dropLength = JSON.parse(localStorage.getItem(DropLength)) || 0;
2356
+ let dropLength = parseInt((_h = container.getAttribute(DropLength)) !== null && _h !== void 0 ? _h : '0');
2231
2357
  dropLength += 1;
2232
- localStorage.setItem(DropLength, JSON.stringify(dropLength));
2358
+ container.setAttribute(DropLength, String(dropLength));
2233
2359
  if (dropLength === countPatternWords(dropElement['value'])) {
2234
2360
  const isisFull = Object.values(dropHasDrag).find(item => document.getElementById(item.drop) === dropElement);
2235
2361
  if (isisFull) {
@@ -2238,9 +2364,10 @@ async function onElementDropComplete(dragElement, dropElement) {
2238
2364
  else {
2239
2365
  console.warn('No matching drop item found for', dropElement);
2240
2366
  }
2241
- localStorage.setItem(DropHasDrag, JSON.stringify(dropHasDrag));
2367
+ // memoryStorage[DropHasDrag] = dropHasDrag;
2368
+ // container.setAttribute(DropHasDrag, JSON.stringify(dropHasDrag));
2242
2369
  dropLength = 0;
2243
- localStorage.setItem(DropLength, JSON.stringify(dropLength));
2370
+ container.setAttribute(DropLength, String(dropLength));
2244
2371
  }
2245
2372
  dragToDropMap.set(dragElement, dropElement);
2246
2373
  // Add pulse and highlight effect for a successful match
@@ -2248,9 +2375,9 @@ async function onElementDropComplete(dragElement, dropElement) {
2248
2375
  dispatchElementDropEvent(dragElement, dropElement, isCorrect);
2249
2376
  storingEachActivityScore(isCorrect);
2250
2377
  dragElement.style.opacity = '1';
2378
+ await onActivityComplete(dragElement, dropElement);
2251
2379
  const allDropElements = document.querySelectorAll('.drop-element');
2252
2380
  allDropElements.forEach(el => updateDropBorder(el));
2253
- await onActivityComplete(dragElement, dropElement);
2254
2381
  }
2255
2382
  function updateDropBorder(element) {
2256
2383
  if (!element || !element.classList.contains('drop-element'))
@@ -2269,7 +2396,9 @@ function updateDropBorder(element) {
2269
2396
  element.classList.remove('empty');
2270
2397
  }
2271
2398
  else {
2272
- element.classList.add('empty');
2399
+ if (!element.classList.contains('math-matrix')) {
2400
+ element.classList.add('empty');
2401
+ }
2273
2402
  element.classList.remove('filled');
2274
2403
  }
2275
2404
  }
@@ -2277,15 +2406,12 @@ function handleDropElement(element) {
2277
2406
  // let nextIndex = Object.keys(dropHas).length; // Get next index
2278
2407
  // dropHas[nextIndex] = { drop: element, isFull: false };
2279
2408
  element.classList.add('drop-element');
2280
- let dropHas = JSON.parse(localStorage.getItem(DropHasDrag) || '{}');
2281
- const tabIndex = element.getAttribute('tab-index');
2282
- if (typeof dropHas !== 'object' || dropHas === null) {
2283
- dropHas = {};
2284
- }
2285
- if (!dropHas[tabIndex]) {
2286
- dropHas[tabIndex] = { drop: element.id, isFull: false };
2287
- localStorage.setItem(DropHasDrag, JSON.stringify(dropHas));
2288
- }
2409
+ buildDragSelectedMapFromDOM();
2410
+ element.getAttribute('tab-index');
2411
+ // if (!dropHas[tabIndex]) {
2412
+ // dropHas[tabIndex] = { drop: element.id, isFull: false };
2413
+ // // localStorage.setItem(DropHasDrag, JSON.stringify(dropHas));
2414
+ // }
2289
2415
  element.onclick = () => {
2290
2416
  onClickDropOrDragElement(element, 'drop');
2291
2417
  };
@@ -2352,7 +2478,7 @@ async function onClickDropOrDragElement(element, type) {
2352
2478
  const dragToDropMap = new Map();
2353
2479
  async function onClickDragElement(element) {
2354
2480
  AudioPlayer.getI().stop();
2355
- const dropElements = JSON.parse(localStorage.getItem(DropHasDrag) || '{}');
2481
+ const dropElements = buildDropHasDragFromDOM();
2356
2482
  const dragEl = element;
2357
2483
  if (!dragEl) {
2358
2484
  console.error('Element not found');
@@ -2398,9 +2524,12 @@ const appendingDragElementsInDrop = () => {
2398
2524
  });
2399
2525
  });
2400
2526
  };
2527
+ const container = document.getElementById(LidoContainer);
2401
2528
  const reduceSizeToOriginal = () => {
2402
2529
  const dropItems = document.querySelectorAll("[type='drop']");
2403
- let dropHasDrag = JSON.parse(localStorage.getItem(DropHasDrag) || ' {}');
2530
+ let dropHasDrag = buildDragSelectedMapFromDOM();
2531
+ if (!dropItems || !container)
2532
+ return;
2404
2533
  if (!dropHasDrag || !dropItems)
2405
2534
  return;
2406
2535
  dropItems.forEach(dropElement => {
@@ -2409,6 +2538,7 @@ const reduceSizeToOriginal = () => {
2409
2538
  const tabIndex = drop.getAttribute('tab-index');
2410
2539
  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) {
2411
2540
  const originalWidth = drop.getAttribute('data-original-width');
2541
+ dropElement.removeAttribute('is-full');
2412
2542
  if (originalWidth) {
2413
2543
  drop.style.width = originalWidth;
2414
2544
  drop.removeAttribute('data-original-width');
@@ -2599,7 +2729,7 @@ function enableReorderDrag(element) {
2599
2729
  isClicked = false;
2600
2730
  event.preventDefault();
2601
2731
  const containerRect = container.getBoundingClientRect();
2602
- const containerScale = calculateScale();
2732
+ const containerScale = getElementScale(container);
2603
2733
  const newLeft = (point.clientX - containerRect.left - offsetXInElement) / containerScale;
2604
2734
  const newTop = (point.clientY - containerRect.top - offsetYInElement) / containerScale;
2605
2735
  element.style.left = `${newLeft}px`;
@@ -2666,16 +2796,18 @@ function enableReorderDrag(element) {
2666
2796
  else {
2667
2797
  if (element.parentElement['type'] !== 'category') {
2668
2798
  executeActions('this.alignMatch=true', divEl, element);
2669
- divEl.replaceWith(element);
2799
+ setTimeout(() => {
2800
+ divEl.replaceWith(element);
2801
+ }, 500);
2670
2802
  }
2671
2803
  else {
2672
2804
  const categoryElement = element.parentElement;
2673
- const dragValues = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
2805
+ const dragValues = buildDragSelectedMapFromDOM();
2674
2806
  const tabKey = categoryElement.getAttribute('tab-index');
2675
2807
  const targetValue = element['value'];
2676
2808
  if (dragValues[tabKey]) {
2677
2809
  dragValues[tabKey] = dragValues[tabKey].filter((el) => el !== targetValue);
2678
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragValues));
2810
+ // localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragValues));
2679
2811
  }
2680
2812
  optionArea.scrollTo({
2681
2813
  top: optionArea.scrollHeight,
@@ -2683,6 +2815,7 @@ function enableReorderDrag(element) {
2683
2815
  });
2684
2816
  optionArea.appendChild(element);
2685
2817
  element.classList.remove('dropped');
2818
+ element.removeAttribute('drop-to');
2686
2819
  if (dummy) {
2687
2820
  dummy.remove();
2688
2821
  }
@@ -2721,12 +2854,12 @@ function enableReorderDrag(element) {
2721
2854
  category = categoryArr[0];
2722
2855
  }
2723
2856
  if (element.parentElement.getAttribute('type') === 'category') {
2724
- const dragValues = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
2857
+ const dragValues = buildDragSelectedMapFromDOM();
2725
2858
  const tabKey = category.getAttribute('tab-index');
2726
2859
  const targetValue = element['value'];
2727
2860
  if (dragValues[tabKey]) {
2728
2861
  dragValues[tabKey] = dragValues[tabKey].filter((el) => el !== targetValue);
2729
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragValues));
2862
+ // localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragValues));
2730
2863
  }
2731
2864
  const dummy = createDummyElement(element);
2732
2865
  optionArea.appendChild(dummy);
@@ -2740,6 +2873,7 @@ function enableReorderDrag(element) {
2740
2873
  resetElementStyles(element);
2741
2874
  dummy.replaceWith(element);
2742
2875
  element.classList.remove('dropped');
2876
+ element.removeAttribute('drop-to');
2743
2877
  }, 100);
2744
2878
  return;
2745
2879
  }
@@ -2888,13 +3022,15 @@ function moveWithAnimation(target, overlapped) {
2888
3022
  }
2889
3023
  // Drop Completed
2890
3024
  const wordDropComplete = (block, element) => {
3025
+ var _a;
3026
+ console.log("worddrop");
2891
3027
  const container = document.getElementById(LidoContainer);
2892
3028
  const objective = container.getAttribute('objective');
2893
3029
  const objectiveArray = objective.split(',');
2894
- let wordArray = JSON.parse(localStorage.getItem(SelectedValuesKey)) || [];
3030
+ let wordArray = JSON.parse((_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]');
2895
3031
  const wordBlock = block.children;
2896
3032
  wordArray = Array.from(wordBlock).map(child => child.getAttribute('value'));
2897
- localStorage.setItem(SelectedValuesKey, JSON.stringify(wordArray));
3033
+ container.setAttribute(SelectedValuesKey, JSON.stringify(wordArray));
2898
3034
  const elementIndex = wordArray.indexOf(element['value']);
2899
3035
  if (elementIndex >= 0) {
2900
3036
  const res = matchStringPattern(element['value'], [objectiveArray[elementIndex].trim()]);
@@ -2909,7 +3045,7 @@ const wordDropComplete = (block, element) => {
2909
3045
  };
2910
3046
  async function onDropToCategory(dragElement, categoryElement) {
2911
3047
  dragElement.classList.add('dropped');
2912
- let dragSelected = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
3048
+ let dragSelected = buildDragSelectedMapFromDOM();
2913
3049
  let elementArr = dragSelected[categoryElement.getAttribute('tab-index')];
2914
3050
  if (Array.isArray(elementArr)) {
2915
3051
  if (elementArr.includes(dragElement['value']))
@@ -2921,7 +3057,10 @@ async function onDropToCategory(dragElement, categoryElement) {
2921
3057
  dragSelected[key].splice(index, 1);
2922
3058
  }
2923
3059
  }
2924
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragSelected));
3060
+ if (categoryElement === null || categoryElement === void 0 ? void 0 : categoryElement.id) {
3061
+ dragElement.setAttribute(DropToAttr, categoryElement.id);
3062
+ }
3063
+ // localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragSelected));
2925
3064
  await onActivityComplete(dragElement, categoryElement);
2926
3065
  }
2927
3066
 
@@ -3140,13 +3279,15 @@ function slidingWithScaling(element) {
3140
3279
  });
3141
3280
  }
3142
3281
  const slideCompleted = (slideElement) => {
3143
- const slideArr = JSON.parse(localStorage.getItem(SelectedValuesKey)) || [];
3282
+ var _a;
3283
+ const container = document.getElementById(LidoContainer);
3284
+ const slideArr = JSON.parse((_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]');
3144
3285
  const allSlideElements = document.querySelectorAll("[type='slide']");
3145
3286
  let index = 0;
3146
3287
  allSlideElements.forEach(item => {
3147
3288
  slideArr[index++] = item['value'];
3148
3289
  });
3149
- localStorage.setItem(SelectedValuesKey, JSON.stringify(slideArr));
3290
+ container.setAttribute(SelectedValuesKey, JSON.stringify(slideArr));
3150
3291
  const objectiveString = document.getElementById(LidoContainer)['objective'];
3151
3292
  const objectiveArray = objectiveString.split(',');
3152
3293
  const elementIndex = slideArr.indexOf(slideElement['value']);
@@ -4408,6 +4549,7 @@ function addClickListenerForClickType(element) {
4408
4549
  return;
4409
4550
  }
4410
4551
  const onClick = async () => {
4552
+ var _a;
4411
4553
  const lido_buttons = element.getAttribute('id');
4412
4554
  if (lido_buttons === 'lido-arrow-left' || lido_buttons === 'lido-arrow-right') {
4413
4555
  return;
@@ -4424,24 +4566,15 @@ function addClickListenerForClickType(element) {
4424
4566
  }
4425
4567
  if (container['objective'].length === 0)
4426
4568
  return;
4427
- // element.style.border = '2px solid yellow';
4428
- // element.style.boxShadow = '0px 0px 10px rgba(255, 255, 0, 0.7)';
4429
- // element.style.transition = 'transform 0.2s ease, border 0.5s ease';
4430
- // element.style.transform = 'scale(1.1)';
4431
- // element.style.transform = 'scale(1)';
4432
- // element.style.border = '';
4433
- // element.style.boxShadow = '';
4434
4569
  const isActivated = element.classList.contains('lido-element-selected');
4435
- let selectedValue = JSON.parse(localStorage.getItem(SelectedValuesKey)) || [];
4570
+ let selectedValue = JSON.parse((_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]');
4436
4571
  if (objective.length === 1) {
4437
- localStorage.setItem(SelectedValuesKey, JSON.stringify([element['value']]));
4572
+ container.setAttribute(SelectedValuesKey, JSON.stringify([element['value']]));
4438
4573
  const isCorrect = objective.includes(element['value']);
4439
4574
  dispatchClickEvent(element, isCorrect);
4440
4575
  if (isCorrect) {
4441
4576
  const onCorrect = element.getAttribute('onCorrect');
4442
- if (!(element.id && element.id.startsWith('key-button'))) {
4443
- element.style.pointerEvents = 'none';
4444
- }
4577
+ // element.style.pointerEvents = 'none';
4445
4578
  await executeActions(onCorrect, element);
4446
4579
  }
4447
4580
  else {
@@ -4449,7 +4582,11 @@ function addClickListenerForClickType(element) {
4449
4582
  await executeActions(onInCorrect, element);
4450
4583
  // showWrongAnswerAnimation([element]);
4451
4584
  }
4452
- storingEachActivityScore(isCorrect);
4585
+ // const calciEl=document.querySelector('#lidoCalculator') as any;
4586
+ const isInsideCalculator = element.closest('#lidoCalculator') !== null;
4587
+ if (!isInsideCalculator) {
4588
+ storingEachActivityScore(isCorrect);
4589
+ }
4453
4590
  handleShowCheck();
4454
4591
  return;
4455
4592
  }
@@ -4460,8 +4597,8 @@ function addClickListenerForClickType(element) {
4460
4597
  element.classList.remove('lido-element-selected');
4461
4598
  executeActions(element.getAttribute('onEntry'), element);
4462
4599
  selectedValue = selectedValue.filter(item => item != element['value']);
4463
- localStorage.setItem(SelectedValuesKey, JSON.stringify(selectedValue));
4464
- let multiOptionScore = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
4600
+ container.setAttribute(SelectedValuesKey, JSON.stringify([element['value']]));
4601
+ let multiOptionScore = buildDragSelectedMapFromDOM();
4465
4602
  const valueToRemove = element['value'];
4466
4603
  const keyToRemove = Object.keys(multiOptionScore).find(key => multiOptionScore[key].includes(valueToRemove));
4467
4604
  if (keyToRemove) {
@@ -4469,10 +4606,9 @@ function addClickListenerForClickType(element) {
4469
4606
  if (multiOptionScore[keyToRemove].length === 0) {
4470
4607
  delete multiOptionScore[keyToRemove];
4471
4608
  }
4472
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(multiOptionScore));
4473
4609
  const sortedKeys = Object.keys(multiOptionScore).sort((a, b) => parseInt(a) - parseInt(b));
4474
4610
  const sortedValues = sortedKeys.reduce((acc, key) => acc.concat(multiOptionScore[key]), []);
4475
- localStorage.setItem(SelectedValuesKey, JSON.stringify(sortedValues));
4611
+ container.setAttribute(SelectedValuesKey, JSON.stringify(sortedValues));
4476
4612
  }
4477
4613
  if (showCheck && selectedValue.length === 0) {
4478
4614
  checkButton.classList.add('lido-disable-check-button');
@@ -4483,20 +4619,18 @@ function addClickListenerForClickType(element) {
4483
4619
  element.classList.add('lido-element-selected');
4484
4620
  const valueToFind = element['value'];
4485
4621
  const key = Object.keys(objective).find(key => objective[key] === valueToFind);
4486
- let multiOptionScore = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
4622
+ let multiOptionScore = buildDragSelectedMapFromDOM();
4487
4623
  if (!key) {
4488
4624
  multiOptionScore[objective.length + selectedValue.length] = [valueToFind];
4489
4625
  }
4490
4626
  else {
4491
4627
  multiOptionScore[key] = [valueToFind];
4492
4628
  }
4493
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(multiOptionScore));
4494
4629
  const sortedKeys = Object.keys(multiOptionScore).sort((a, b) => parseInt(a) - parseInt(b));
4495
4630
  const sortedValues = sortedKeys.reduce((acc, key) => acc.concat(multiOptionScore[key]), []);
4496
- localStorage.setItem(SelectedValuesKey, JSON.stringify(sortedValues));
4631
+ container.setAttribute(SelectedValuesKey, JSON.stringify(sortedValues));
4497
4632
  const isCorrect = objective.includes(element['value']);
4498
4633
  dispatchClickEvent(element, isCorrect);
4499
- AudioPlayer.getI().stop();
4500
4634
  if (isCorrect) {
4501
4635
  const onCorrect = element.getAttribute('onCorrect');
4502
4636
  await executeActions(onCorrect, element);
@@ -4508,8 +4642,11 @@ function addClickListenerForClickType(element) {
4508
4642
  }
4509
4643
  storingEachActivityScore(isCorrect);
4510
4644
  }
4511
- if (!showCheck && countPatternWords(objective) === countPatternWords(selectedValue)) {
4512
- validateObjectiveStatus();
4645
+ const isInsideCalculator = element.closest('#lidoCalculator') !== null;
4646
+ if (!isInsideCalculator) {
4647
+ if (!showCheck && countPatternWords(objective) === countPatternWords(selectedValue)) {
4648
+ validateObjectiveStatus();
4649
+ }
4513
4650
  }
4514
4651
  };
4515
4652
  element.addEventListener('click', onClick);
@@ -69327,7 +69464,431 @@ function calculateFill(input, currentFill = 0) {
69327
69464
  return Math.max(0, Math.min(100, value));
69328
69465
  }
69329
69466
 
69467
+ // Helper to animate and remove the active equation cell
69468
+ const animationToRemoveEquationSolvedCellForNimbleTable = (activeCell, allCalculateTypes) => {
69469
+ return new Promise((resolve) => {
69470
+ const keyframes = `
69471
+ @keyframes widthDecrease {
69472
+ 0% {
69473
+ background-color: ${activeCell.style.backgroundColor};
69474
+ height: ${activeCell.style.height};
69475
+ margin: ${activeCell.style.margin};
69476
+ ${activeCell.innerHTML = ""}
69477
+ }
69478
+ 100% { background-color: transparent; height: 0px; margin: 0px; }
69479
+ }`;
69480
+ const styleSheet = document.styleSheets[0];
69481
+ styleSheet.insertRule(keyframes, styleSheet.cssRules.length);
69482
+ activeCell.style.animation = `widthDecrease 0.1s`;
69483
+ activeCell.addEventListener('animationend', () => {
69484
+ activeCell.style.height = '0px';
69485
+ activeCell.style.margin = '0px';
69486
+ activeCell.style.backgroundColor = 'transparent';
69487
+ activeCell.remove();
69488
+ // Trigger next container if last cell
69489
+ if (allCalculateTypes.length === 1) {
69490
+ setTimeout(() => triggerNextContainer(), 2000);
69491
+ }
69492
+ resolve();
69493
+ });
69494
+ });
69495
+ };
69496
+ // Function: checks and animates equation when correct
69497
+ const checkEquationOfActiveCell = async (container) => {
69498
+ var _a;
69499
+ const calculatorValue = (_a = container.querySelector("#lidoCalculator")) === null || _a === void 0 ? void 0 : _a.getAttribute("value");
69500
+ const allCalculateTypes = document.querySelectorAll("[type='calculate']");
69501
+ const activeCell = allCalculateTypes[0];
69502
+ const activeCellValue = Number(activeCell["value"]);
69503
+ const calculteValue = Number(calculatorValue);
69504
+ if (!activeCell || calculteValue !== activeCellValue)
69505
+ return;
69506
+ const equation = activeCell["string"];
69507
+ // Replace equation after a short delay
69508
+ //await new Promise(r => setTimeout(r, 200));
69509
+ activeCell.innerHTML = equation.replaceAll("?", calculteValue);
69510
+ const element2 = container.querySelector("#dummy112");
69511
+ element2.innerHTML = activeCell.innerHTML;
69512
+ // Animate and clean up
69513
+ await animationToRemoveEquationSolvedCellForNimbleTable(activeCell, allCalculateTypes);
69514
+ };
69515
+ // Function: handles equation check when clicked on OK
69516
+ let score = 0;
69517
+ const handleSolvedEquationSubmissionAndScoreUpdate = async () => {
69518
+ var _a;
69519
+ const container = document.getElementById('lido-container');
69520
+ const calculatorValue = (_a = container.querySelector("#lidoCalculator")) === null || _a === void 0 ? void 0 : _a.getAttribute("value");
69521
+ const allCalculateTypes = document.querySelectorAll("[type='calculate']");
69522
+ const activeCell = allCalculateTypes[0];
69523
+ const isContinueOnCorrect = container.getAttribute("is-continue-on-correct") === "true";
69524
+ const activeCellValue = Number(activeCell["value"]);
69525
+ const calculteValue = Number(calculatorValue);
69526
+ const element1 = container.querySelector("#dummy111");
69527
+ const element2 = container.querySelector("#dummy112");
69528
+ // PRACTICE MODE (continue only if correct)
69529
+ if (isContinueOnCorrect) {
69530
+ if (element2.innerHTML.length > 0 && activeCellValue === calculteValue) {
69531
+ element1.innerHTML = element2.innerHTML;
69532
+ }
69533
+ await checkEquationOfActiveCell(container);
69534
+ }
69535
+ // TEST MODE (store all, animate regardless of correctness)
69536
+ else {
69537
+ if (calculatorValue.length > 0) {
69538
+ if (calculatorValue === activeCell["value"]) {
69539
+ score++;
69540
+ console.log("SCOREEEE", score);
69541
+ }
69542
+ else {
69543
+ if (score > 0) {
69544
+ score--;
69545
+ }
69546
+ console.log("SCOREEEE", score);
69547
+ }
69548
+ if (element2.innerHTML.length > 0) {
69549
+ element1.innerHTML = element2.innerHTML;
69550
+ }
69551
+ const equation = activeCell["string"];
69552
+ // Replace value visually
69553
+ activeCell.innerHTML = equation.replaceAll("?", calculteValue);
69554
+ element2.innerHTML = activeCell.innerHTML;
69555
+ // Animate
69556
+ await animationToRemoveEquationSolvedCellForNimbleTable(activeCell, allCalculateTypes);
69557
+ }
69558
+ }
69559
+ };
69560
+
69561
+ function handlingMatrix(element) {
69562
+ const container = document.querySelector(LidoContainer);
69563
+ if (!container)
69564
+ return;
69565
+ const defualtMatrix = element;
69566
+ adjustSizeForSlots(container, defualtMatrix);
69567
+ splitSlots(container, defualtMatrix);
69568
+ }
69569
+ const splitSlots = (container, defualtMatrix) => {
69570
+ const defualtElements = defualtMatrix.querySelectorAll('.slot');
69571
+ const allDropMatrixes = container.querySelectorAll('lido-math-matrix[type="drop"]');
69572
+ const allDragMatrixes = container.querySelectorAll('lido-math-matrix[type="drag"]');
69573
+ let slot = 1;
69574
+ for (let i = 0; i < allDropMatrixes.length; i++) {
69575
+ const el = allDropMatrixes[i];
69576
+ const rowCount = el.getAttribute('rows') ? parseInt(el.getAttribute('rows')) : 1;
69577
+ const colCount = el.getAttribute('cols') ? parseInt(el.getAttribute('cols')) : 1;
69578
+ if (rowCount === 1 || colCount === 1) {
69579
+ if (rowCount === colCount) {
69580
+ const numbers = Array.from({ length: 100 }, (_, i) => i + 1)
69581
+ .sort(() => Math.random() - 0.5) // Shuffle
69582
+ .slice(0, 10); // Take first 10 unique numbers
69583
+ allDropMatrixes.forEach((item, index) => {
69584
+ const dropElement = item;
69585
+ const dropPosition = defualtElements[numbers[index]];
69586
+ // Safeguard if index > available numbers
69587
+ if (!dropPosition)
69588
+ return;
69589
+ postioningDropElement(dropElement, dropPosition);
69590
+ const dragElement = allDragMatrixes[index];
69591
+ dragElement.setAttribute('text', (numbers[index] + 1).toString());
69592
+ });
69593
+ // return;
69594
+ }
69595
+ if (rowCount === 2 && colCount === 1) {
69596
+ const pairs = generateDoubleSquares(10);
69597
+ console.log('pairs double : ', pairs);
69598
+ allDropMatrixes.forEach((item, index) => {
69599
+ const dropElement = item;
69600
+ const dropPosition = defualtElements[pairs[index][0] - 1];
69601
+ postioningDropElement(dropElement, dropPosition);
69602
+ });
69603
+ allDragMatrixes.forEach((item, index) => {
69604
+ const dragElement = item;
69605
+ dragElement.setAttribute('text', pairs[index].toString());
69606
+ });
69607
+ break;
69608
+ }
69609
+ if (rowCount === 5) {
69610
+ const dropPositionElements = generateHalfHorizontalStripes(i);
69611
+ const dropPosition = defualtElements[dropPositionElements[0] - 1];
69612
+ const dragElement = allDragMatrixes[i];
69613
+ dragElement.setAttribute('text', dropPositionElements.toString());
69614
+ postioningDropElement(el, dropPosition);
69615
+ }
69616
+ if (rowCount === 10) {
69617
+ const dropPosition = defualtElements[slot];
69618
+ const dragElement = allDragMatrixes[i];
69619
+ dragElement.setAttribute('text', Array.from({ length: 10 }, (_, i) => slot + 1 + i * 10).toString());
69620
+ postioningDropElement(el, dropPosition);
69621
+ slot = slot + 2;
69622
+ }
69623
+ else if (colCount === 10) {
69624
+ const dropPosition = defualtElements[10 + (slot - 1)];
69625
+ const dragElement = allDragMatrixes[i];
69626
+ dragElement.setAttribute('text', Array.from({ length: 10 }, (_, i) => i + 10 + slot).toString());
69627
+ postioningDropElement(el, dropPosition);
69628
+ slot = slot + 20;
69629
+ }
69630
+ }
69631
+ else if (rowCount === 3 || colCount === 3) {
69632
+ const slotCell = generateSlotsFromDrops(container);
69633
+ const cellNumbers = Object.keys(slotCell).map(key => slotCell[key].cells);
69634
+ allDragMatrixes.forEach((matrix, index) => {
69635
+ const dragElement = matrix;
69636
+ // let dragTextAttr = dragElement.getAttribute('text');
69637
+ if (dragElement) {
69638
+ dragElement.setAttribute('text', cellNumbers[index].toString());
69639
+ }
69640
+ });
69641
+ allDropMatrixes.forEach((matrix, index) => {
69642
+ const dropElement = matrix;
69643
+ const dropPosition = defualtElements[slotCell[`slot-${index + 1}`].cells[0] - 1];
69644
+ postioningDropElement(dropElement, dropPosition);
69645
+ });
69646
+ break; // stops the loop immediately
69647
+ }
69648
+ else if (rowCount === 2 || colCount === 2) {
69649
+ if (rowCount === colCount) {
69650
+ const pairs = generate2by2Squares(10);
69651
+ allDropMatrixes.forEach((item, index) => {
69652
+ const dropElement = item;
69653
+ const dropPosition = defualtElements[pairs[index][0] - 1];
69654
+ postioningDropElement(dropElement, dropPosition);
69655
+ });
69656
+ allDragMatrixes.forEach((item, index) => {
69657
+ const dragElement = item;
69658
+ dragElement.setAttribute('text', pairs[index].toString());
69659
+ });
69660
+ break;
69661
+ }
69662
+ }
69663
+ }
69664
+ };
69665
+ function generateSlotsFromDrops(container) {
69666
+ const gridSize = 10;
69667
+ let availableCells = Array.from({ length: 100 }, (_, i) => i + 1);
69668
+ const occupied = new Set();
69669
+ const slots = {};
69670
+ let generated = 0;
69671
+ const getCell = (row, col) => row * gridSize + col + 1;
69672
+ // Get all <lido-math-matrix type="drop">
69673
+ const allDropMatrixes = container.querySelectorAll('lido-math-matrix[type="drop"]');
69674
+ for (const matrix of Array.from(allDropMatrixes)) {
69675
+ const width = parseInt(matrix.getAttribute('cols') || '1');
69676
+ const height = parseInt(matrix.getAttribute('rows') || '1');
69677
+ const possiblePositions = [];
69678
+ // generate all possible top-left positions
69679
+ for (let row = 0; row <= gridSize - height; row++) {
69680
+ for (let col = 0; col <= gridSize - width; col++) {
69681
+ const cells = [];
69682
+ let canPlace = true;
69683
+ for (let r = 0; r < height; r++) {
69684
+ for (let c = 0; c < width; c++) {
69685
+ const cell = getCell(row + r, col + c);
69686
+ if (occupied.has(cell)) {
69687
+ canPlace = false;
69688
+ break;
69689
+ }
69690
+ cells.push(cell);
69691
+ }
69692
+ if (!canPlace)
69693
+ break;
69694
+ }
69695
+ if (canPlace)
69696
+ possiblePositions.push(cells);
69697
+ }
69698
+ }
69699
+ if (possiblePositions.length === 0) {
69700
+ console.warn(`No space left for matrix ${generated + 1}`);
69701
+ continue;
69702
+ }
69703
+ // Pick a random valid position
69704
+ const randomCells = possiblePositions[Math.floor(Math.random() * possiblePositions.length)];
69705
+ // Mark as occupied & remove from available
69706
+ randomCells.forEach(c => {
69707
+ occupied.add(c);
69708
+ availableCells = availableCells.filter(x => x !== c);
69709
+ });
69710
+ generated++;
69711
+ slots[`slot-${generated}`] = { cells: randomCells, width, height };
69712
+ }
69713
+ return slots;
69714
+ }
69715
+ const postioningDropElement = (dropElement, dropPosition) => {
69716
+ const container = document.getElementById(LidoContainer);
69717
+ const containerScale = getElementScale$1(container);
69718
+ dropElement.style.transform = 'translate(0,0)';
69719
+ const posRect = dropPosition.getBoundingClientRect();
69720
+ const dropRect = dropElement.getBoundingClientRect();
69721
+ const posCenterX = posRect.left + posRect.width / 2;
69722
+ const posCenterY = posRect.top + posRect.height / 2;
69723
+ const dropCenterX = dropRect.left + dropRect.width / 2;
69724
+ const dropCenterY = dropRect.top + dropRect.height / 2;
69725
+ const scaledLeft = (posCenterX - dropCenterX) / containerScale;
69726
+ const scaledTop = (posCenterY - dropCenterY) / containerScale;
69727
+ const rowCount = dropElement.getAttribute('rows') ? parseInt(dropElement.getAttribute('rows')) : 1;
69728
+ const colCount = dropElement.getAttribute('cols') ? parseInt(dropElement.getAttribute('cols')) : 1;
69729
+ const elementWidth = parseInt(dropPosition.style.width);
69730
+ if (rowCount === 1 || colCount === 1) {
69731
+ if (rowCount === colCount) {
69732
+ dropElement.style.transform = `translate(${scaledLeft}px, ${scaledTop}px)`;
69733
+ return;
69734
+ }
69735
+ else if (rowCount > colCount) {
69736
+ if (rowCount === 10) {
69737
+ dropElement.style.transform = `translate(${scaledLeft + (elementWidth * 4 + elementWidth / 2)}px, ${scaledTop}px)`;
69738
+ }
69739
+ else if (rowCount === 5) {
69740
+ dropElement.style.transform = `translate(${scaledLeft + elementWidth * 2}px, ${scaledTop}px)`;
69741
+ }
69742
+ else if (rowCount === 2) {
69743
+ dropElement.style.transform = `translate(${scaledLeft + elementWidth / 2}px, ${scaledTop}px)`;
69744
+ }
69745
+ }
69746
+ else if (rowCount < colCount) {
69747
+ if (colCount === 10) {
69748
+ dropElement.style.transform = `translate(${scaledLeft}px, ${scaledTop + elementWidth * 4 + elementWidth * 0.2 + elementWidth / 2}px)`;
69749
+ }
69750
+ else if (colCount === 5) {
69751
+ dropElement.style.transform = `translate(${scaledLeft}px, ${scaledTop + elementWidth * 2 + elementWidth * 0.0921}px)`;
69752
+ }
69753
+ }
69754
+ return;
69755
+ }
69756
+ if (rowCount === colCount) {
69757
+ if (rowCount === 2) {
69758
+ dropElement.style.transform = `translate(${scaledLeft + elementWidth / 2}px, ${scaledTop + elementWidth / 2 + 4}px)`;
69759
+ return;
69760
+ }
69761
+ dropElement.style.transform = `translate(${scaledLeft + elementWidth}px, ${scaledTop + elementWidth + 4}px)`;
69762
+ return;
69763
+ }
69764
+ if (rowCount === 3) {
69765
+ if (colCount === 2) {
69766
+ dropElement.style.transform = `translate(${scaledLeft + elementWidth}px, ${scaledTop + elementWidth / 2 + 4}px)`;
69767
+ return;
69768
+ }
69769
+ else if (colCount === 1) {
69770
+ dropElement.style.transform = `translate(${scaledLeft + elementWidth}px, ${scaledTop}px)`;
69771
+ return;
69772
+ }
69773
+ }
69774
+ if (rowCount === 2) {
69775
+ if (colCount === 3) {
69776
+ dropElement.style.transform = `translate(${scaledLeft + elementWidth / 2}px, ${scaledTop + elementWidth + 4}px)`;
69777
+ return;
69778
+ }
69779
+ else if (colCount === 1) {
69780
+ dropElement.style.transform = `translate(${scaledLeft + elementWidth / 2}px, ${scaledTop}px)`;
69781
+ return;
69782
+ }
69783
+ }
69784
+ };
69785
+ const adjustSizeForSlots = (container, defualtMatrix) => {
69786
+ const defualtElement = defualtMatrix.querySelector('.slot');
69787
+ const width = defualtElement.style.width;
69788
+ const allDropMatrixes = container.querySelectorAll('lido-math-matrix[type="drop"]');
69789
+ const allDragMatrixes = container.querySelectorAll('lido-math-matrix[type="drag"]');
69790
+ allDragMatrixes.forEach(item => {
69791
+ const el = item;
69792
+ Array.from(el.querySelectorAll('.slot')).forEach(slot => {
69793
+ const slotEl = slot;
69794
+ slotEl.parentElement.style.width = width;
69795
+ slotEl.style.width = width;
69796
+ slotEl.style.height = width;
69797
+ });
69798
+ });
69799
+ allDropMatrixes.forEach(item => {
69800
+ const el = item;
69801
+ Array.from(el.querySelectorAll('.slot')).forEach(slot => {
69802
+ const slotEl = slot;
69803
+ slotEl.parentElement.style.width = width;
69804
+ slotEl.style.width = width;
69805
+ slotEl.style.height = width;
69806
+ });
69807
+ });
69808
+ };
69809
+ function generateHalfHorizontalStripes(index) {
69810
+ const numbers = Array.from({ length: 10 }, (_, i) => index + 1 + i * 10);
69811
+ const randomPlace = Math.floor(Math.random() * 6);
69812
+ const startSlot = numbers[randomPlace];
69813
+ console.log('kedachuruchu', Array.from({ length: 5 }, (_, i) => startSlot + i * 10));
69814
+ return Array.from({ length: 5 }, (_, i) => startSlot + i * 10);
69815
+ }
69816
+ function generate2by2Squares(count = 16) {
69817
+ const gridSize = 10;
69818
+ const squares = [];
69819
+ const usedCells = new Set();
69820
+ function getCell(row, col) {
69821
+ return (row - 1) * gridSize + col;
69822
+ }
69823
+ while (squares.length < count) {
69824
+ const row = Math.floor(Math.random() * (gridSize - 1)) + 1; // 1–9
69825
+ const col = Math.floor(Math.random() * (gridSize - 1)) + 1; // 1–9
69826
+ const square = [getCell(row, col), getCell(row, col + 1), getCell(row + 1, col), getCell(row + 1, col + 1)];
69827
+ // Skip if overlapping with previous
69828
+ if (square.some(cell => usedCells.has(cell)))
69829
+ continue;
69830
+ // Mark cells as used
69831
+ square.forEach(cell => usedCells.add(cell));
69832
+ squares.push(square);
69833
+ }
69834
+ return squares;
69835
+ }
69836
+ function generateDoubleSquares(count = 16) {
69837
+ const gridSize = 10;
69838
+ const pairs = [];
69839
+ const usedCells = new Set();
69840
+ function getCell(row, col) {
69841
+ return (row - 1) * gridSize + col;
69842
+ }
69843
+ while (pairs.length < count) {
69844
+ const row = Math.floor(Math.random() * (gridSize - 1)) + 1; // 1–9
69845
+ const col = Math.floor(Math.random() * gridSize) + 1; // 1–10
69846
+ const top = getCell(row, col);
69847
+ const bottom = getCell(row + 1, col);
69848
+ // Skip if already used
69849
+ if (usedCells.has(top) || usedCells.has(bottom))
69850
+ continue;
69851
+ pairs.push([top, bottom]);
69852
+ usedCells.add(top);
69853
+ usedCells.add(bottom);
69854
+ }
69855
+ return pairs;
69856
+ }
69857
+
69330
69858
  const gameScore = new GameScore();
69859
+ function buildDragSelectedMapFromDOM() {
69860
+ const map = {};
69861
+ const draggedEls = document.querySelectorAll(`[${DropToAttr}]`);
69862
+ draggedEls.forEach(dragEl => {
69863
+ var _a, _b, _c;
69864
+ const to = dragEl.getAttribute(DropToAttr);
69865
+ if (!to)
69866
+ return;
69867
+ const dropEl = document.getElementById(to);
69868
+ if (!dropEl)
69869
+ return;
69870
+ const tabIndex = (_a = dropEl.getAttribute('tab-index')) !== null && _a !== void 0 ? _a : to;
69871
+ if (!map[tabIndex])
69872
+ map[tabIndex] = [];
69873
+ const value = (_c = (_b = dragEl.getAttribute('value')) !== null && _b !== void 0 ? _b : dragEl.value) !== null && _c !== void 0 ? _c : '';
69874
+ map[tabIndex].push(value);
69875
+ });
69876
+ return map;
69877
+ }
69878
+ function getSortedValuesArrayFromMap(map) {
69879
+ const sortedKeys = Object.keys(map).sort((a, b) => parseInt(a) - parseInt(b));
69880
+ const sortedValues = sortedKeys.reduce((acc, key) => {
69881
+ const values = map[key];
69882
+ if (values.length > 1) {
69883
+ acc.push(`(${values.join('|')})`);
69884
+ }
69885
+ else {
69886
+ acc.push(values[0]);
69887
+ }
69888
+ return acc;
69889
+ }, []);
69890
+ return sortedValues;
69891
+ }
69331
69892
  function format(first, middle, last) {
69332
69893
  return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');
69333
69894
  }
@@ -69372,12 +69933,16 @@ const initEventsForElement = async (element, type) => {
69372
69933
  enableOptionArea(element);
69373
69934
  break;
69374
69935
  }
69936
+ case 'checkerBlock': {
69937
+ handlingMatrix(element);
69938
+ break;
69939
+ }
69375
69940
  }
69376
69941
  onTouchListenerForOnTouch(element);
69377
69942
  };
69378
69943
  // Function to execute actions parsed from the onMatch string
69379
69944
  const executeActions = async (actionsString, thisElement, element) => {
69380
- var _a;
69945
+ var _a, _b, _c, _d, _e, _f, _g;
69381
69946
  const actions = parseActions(actionsString);
69382
69947
  for (let i = 0; i < actions.length; i++) {
69383
69948
  const action = actions[i];
@@ -69391,13 +69956,25 @@ const executeActions = async (actionsString, thisElement, element) => {
69391
69956
  targetElement.style.transform = currentTransform !== 'none' ? `${currentTransform} ${action.value}` : action.value;
69392
69957
  break;
69393
69958
  }
69959
+ case 'revealImageValue': {
69960
+ if (targetElement) {
69961
+ revealImageValue(targetElement); // call your function here
69962
+ }
69963
+ break;
69964
+ }
69965
+ case 'scrollCellAfterEquationSolved': {
69966
+ if (targetElement) {
69967
+ handleSolvedEquationSubmissionAndScoreUpdate();
69968
+ }
69969
+ break;
69970
+ }
69394
69971
  case 'alignMatch': {
69395
69972
  const dropElement = targetElement;
69396
69973
  const dragElement = element;
69397
69974
  const container = document.getElementById(LidoContainer);
69398
69975
  const containerScale = getElementScale$1(container);
69399
69976
  dragElement.style.transform = 'translate(0,0)';
69400
- console.log('logg alinmatch');
69977
+ console.log("logg alinmatch");
69401
69978
  const dropRect = dropElement.getBoundingClientRect();
69402
69979
  const dragRect = dragElement.getBoundingClientRect();
69403
69980
  const dropCenterX = dropRect.left + dropRect.width / 2;
@@ -69483,10 +70060,76 @@ const executeActions = async (actionsString, thisElement, element) => {
69483
70060
  }
69484
70061
  break;
69485
70062
  }
70063
+ case 'highlightStarsAndDisapper': {
70064
+ const value = action.value;
70065
+ if (value && targetElement) {
70066
+ console.log('highlightStar action triggered');
70067
+ console.log('Target Element:', targetElement);
70068
+ await HighlightStarsOneByOne(targetElement, value);
70069
+ }
70070
+ break;
70071
+ }
70072
+ case 'boxAnimationOneByOne': {
70073
+ const value = action.value;
70074
+ if (value && targetElement) {
70075
+ await animateBoxCells(targetElement, value);
70076
+ }
70077
+ break;
70078
+ }
70079
+ case 'questionBoxAnimate': {
70080
+ const value = action.value;
70081
+ if (value && targetElement) {
70082
+ await questionBoxAnimation(targetElement, value);
70083
+ }
70084
+ break;
70085
+ }
69486
70086
  case 'slideAnimation': {
69487
70087
  slideAnimation();
69488
70088
  break;
69489
70089
  }
70090
+ case 'showBalanceSymbol': {
70091
+ const balanceEl = document.querySelector('lido-balance');
70092
+ if (!balanceEl)
70093
+ break;
70094
+ 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));
70095
+ 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));
70096
+ const symbol = leftVal > rightVal ? '>' : leftVal < rightVal ? '<' : '=';
70097
+ balanceEl.balanceSymbol = symbol;
70098
+ balanceEl.dataset.balanceSymbol = symbol;
70099
+ if (balanceEl.revealSymbol) {
70100
+ await balanceEl.revealSymbol();
70101
+ }
70102
+ else {
70103
+ balanceEl.showSymbol = true;
70104
+ }
70105
+ break;
70106
+ }
70107
+ case 'hideBalanceSymbol': {
70108
+ const balanceEl = document.querySelector('lido-balance');
70109
+ if (!balanceEl)
70110
+ break;
70111
+ if (balanceEl.hideSymbol) {
70112
+ await balanceEl.hideSymbol();
70113
+ }
70114
+ else {
70115
+ balanceEl.showSymbol = false;
70116
+ }
70117
+ break;
70118
+ }
70119
+ case 'sumTogetherAnimation': {
70120
+ const value = action.value;
70121
+ if (value) {
70122
+ SumTogetherAnimation(targetElement, value);
70123
+ }
70124
+ break;
70125
+ }
70126
+ case 'addText': {
70127
+ const value = action.value;
70128
+ if (value) {
70129
+ targetElement.textContent += value;
70130
+ }
70131
+ break;
70132
+ }
69490
70133
  default: {
69491
70134
  targetElement.style[action.action] = action.value;
69492
70135
  break;
@@ -69584,6 +70227,9 @@ const matchStringPattern = (pattern, arr) => {
69584
70227
  const patternGroups = pattern.split(',').map(group => group.trim());
69585
70228
  let arrIndex = 0;
69586
70229
  let options = new Set();
70230
+ if (patternGroups.length == 0) { // If pattern is empty
70231
+ return true;
70232
+ }
69587
70233
  if (patternGroups.length > 0) {
69588
70234
  if (arr.length === 0)
69589
70235
  return false; // If pattern is not empty but user provided array is empty, return false
@@ -69668,38 +70314,36 @@ const calculateScore = () => {
69668
70314
  gameScore.wrongMoves = 0;
69669
70315
  };
69670
70316
  async function onActivityComplete(dragElement, dropElement) {
69671
- var _a, _b;
70317
+ var _a;
69672
70318
  const container = document.getElementById(LidoContainer);
69673
70319
  if (!container)
69674
70320
  return;
69675
70321
  await executeActions("this.alignMatch='true'", dropElement, dragElement);
69676
- let dragScore = JSON.parse((_a = localStorage.getItem(DragSelectedMapKey)) !== null && _a !== void 0 ? _a : '{}');
69677
- const tabindex = dropElement.getAttribute('tab-index');
69678
- if (!dragScore[tabindex]) {
69679
- dragScore[tabindex] = [];
70322
+ if (dragElement && dropElement) {
70323
+ const isCorrect = dropElement['value'].toLowerCase().includes(dragElement['value'].toLowerCase());
70324
+ if (isCorrect) {
70325
+ const onCorrect = dropElement.getAttribute('onCorrect');
70326
+ if (onCorrect) {
70327
+ await executeActions(onCorrect, dropElement, dragElement);
70328
+ }
70329
+ }
70330
+ else {
70331
+ const onInCorrect = dropElement.getAttribute('onInCorrect');
70332
+ await executeActions(onInCorrect, dropElement, dragElement);
70333
+ }
69680
70334
  }
69681
- dragScore[tabindex].push(dragElement['value']);
69682
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragScore));
70335
+ let dragScore = buildDragSelectedMapFromDOM();
70336
+ const sortedValues = getSortedValuesArrayFromMap(dragScore);
70337
+ container.setAttribute(SelectedValuesKey, JSON.stringify(sortedValues));
69683
70338
  //localStorage
69684
- let drag = JSON.parse((_b = localStorage.getItem(DragMapKey)) !== null && _b !== void 0 ? _b : '{}');
70339
+ let drag = JSON.parse((_a = localStorage.getItem(DragMapKey)) !== null && _a !== void 0 ? _a : '{}');
69685
70340
  const index = dropElement.getAttribute('tab-index');
69686
70341
  if (!drag[index]) {
69687
70342
  drag[index] = [];
69688
70343
  }
69689
70344
  drag[index].push(dragElement.id);
69690
70345
  // localStorage.setItem(DragMapKey, JSON.stringify(drag));
69691
- const sortedKeys = Object.keys(dragScore).sort((a, b) => parseInt(a) - parseInt(b));
69692
- const sortedValues = sortedKeys.reduce((acc, key) => {
69693
- const values = dragScore[key];
69694
- if (values.length > 1) {
69695
- acc.push(`(${values.join('|')})`);
69696
- }
69697
- else {
69698
- acc.push(values[0]);
69699
- }
69700
- return acc;
69701
- }, []);
69702
- localStorage.setItem(SelectedValuesKey, JSON.stringify(sortedValues));
70346
+ Object.keys(dragScore).sort((a, b) => parseInt(a) - parseInt(b));
69703
70347
  if (dragElement && dropElement) {
69704
70348
  const isCorrect = dropElement['value'].toLowerCase().includes(dragElement['value'].toLowerCase());
69705
70349
  if (isCorrect) {
@@ -69716,8 +70360,7 @@ async function onActivityComplete(dragElement, dropElement) {
69716
70360
  const allElements = document.querySelectorAll("[type='drop']");
69717
70361
  allElements.forEach(otherElement => {
69718
70362
  var _a;
69719
- const dropObject = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
69720
- const storedTabIndexes = Object.keys(dropObject).map(Number);
70363
+ const storedTabIndexes = Object.keys(dragScore).map(Number);
69721
70364
  if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
69722
70365
  if (!(((_a = otherElement.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
69723
70366
  if (otherElement.tagName.toLowerCase() === 'lido-text') {
@@ -69769,81 +70412,101 @@ const handleShowCheck = () => {
69769
70412
  var _a, _b;
69770
70413
  const container = document.getElementById(LidoContainer);
69771
70414
  const objectiveString = container['objective'];
69772
- const selectValues = (_a = localStorage.getItem(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '';
70415
+ const selectValues = (_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '';
69773
70416
  const checkButton = document.querySelector('#lido-checkButton');
69774
- if (!selectValues || countPatternWords(selectValues) !== countPatternWords(objectiveString)) {
70417
+ if (!selectValues || countPatternWords(selectValues) < countPatternWords(objectiveString)) {
69775
70418
  executeActions("this.addClass='lido-disable-check-button'", checkButton);
69776
70419
  return;
69777
70420
  }
69778
70421
  const showCheck = container.getAttribute('show-check') == 'true';
69779
70422
  if (showCheck) {
69780
70423
  (_b = checkButton === null || checkButton === void 0 ? void 0 : checkButton.classList) === null || _b === void 0 ? void 0 : _b.remove('lido-disable-check-button');
70424
+ const balanceEl = document.querySelector('lido-balance');
70425
+ if (balanceEl) {
70426
+ if (!checkButton.hasAttribute('data-balance-listener')) {
70427
+ checkButton.addEventListener('click', async function onClick() {
70428
+ if (balanceResult && res) {
70429
+ await executeActions("this.showBalanceSymbol='true'", checkButton);
70430
+ checkButton.removeEventListener('click', onClick);
70431
+ }
70432
+ });
70433
+ checkButton.setAttribute('data-balance-listener', 'true');
70434
+ }
70435
+ }
69781
70436
  }
69782
70437
  else {
69783
70438
  validateObjectiveStatus();
69784
70439
  }
69785
70440
  };
69786
- const body = document.body;
70441
+ let res;
69787
70442
  const validateObjectiveStatus = async () => {
69788
- var _a;
70443
+ var _a, _b;
69789
70444
  const container = document.getElementById(LidoContainer);
69790
70445
  if (!container)
69791
70446
  return;
69792
70447
  const objectiveString = container['objective'];
70448
+ const additionalCheck = container.getAttribute('equationCheck');
70449
+ console.log('🚀 ~ validateObjectiveStatus ~ additionalCheck:', additionalCheck);
70450
+ let equationGiven = false;
69793
70451
  if (objectiveString == null || objectiveString.length === 0) {
69794
- const onCorrect = container.getAttribute('onCorrect');
69795
- if (onCorrect) {
69796
- await executeActions(onCorrect, container);
70452
+ if (additionalCheck) {
70453
+ equationGiven = true;
70454
+ }
70455
+ if (!equationGiven) {
70456
+ const onCorrect = container.getAttribute('onCorrect');
70457
+ if (onCorrect) {
70458
+ await executeActions(onCorrect, container);
70459
+ }
70460
+ storeActivityScore(100);
70461
+ storingEachActivityScore(true);
70462
+ triggerNextContainer();
70463
+ return;
69797
70464
  }
69798
- storeActivityScore(100);
69799
- storingEachActivityScore(true);
69800
- triggerNextContainer();
69801
- return;
69802
70465
  }
69803
- else {
69804
- const objectiveArray = (_a = JSON.parse(localStorage.getItem(SelectedValuesKey))) !== null && _a !== void 0 ? _a : [];
69805
- let res;
69806
- const additionalCheck = container.getAttribute('equationCheck');
69807
- if (!!additionalCheck) {
70466
+ const objectiveArray = (_b = JSON.parse((_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]')) !== null && _b !== void 0 ? _b : [];
70467
+ if (!!additionalCheck) {
70468
+ const balanceEl = document.querySelector('lido-balance');
70469
+ if (!balanceEl) {
69808
70470
  res = equationCheck(additionalCheck);
69809
- console.log('🚀 ~ handleShowCheck ~ res:', res);
69810
70471
  }
69811
70472
  else {
69812
- res = matchStringPattern(objectiveString, objectiveArray);
70473
+ res = balanceResult(container, objectiveString);
69813
70474
  }
69814
- if (res) {
69815
- const attach = container.getAttribute('appendToDropOnCompletion');
69816
- body.style.pointerEvents = 'none';
69817
- const onCorrect = container.getAttribute('onCorrect');
69818
- if (onCorrect) {
69819
- if (attach === 'true') {
69820
- appendingDragElementsInDrop();
69821
- }
69822
- await executeActions(onCorrect, container);
69823
- }
69824
- if (container.getAttribute('dropAttr') === 'EnableAnimation') {
69825
- setTimeout(() => {
69826
- triggerNextContainer();
69827
- }, 2000);
70475
+ console.log('🚀 ~ handleShowCheck ~ res:', res);
70476
+ }
70477
+ else {
70478
+ res = matchStringPattern(objectiveString, objectiveArray);
70479
+ }
70480
+ if (res) {
70481
+ const attach = container.getAttribute('appendToDropOnCompletion');
70482
+ const onCorrect = container.getAttribute('onCorrect');
70483
+ if (onCorrect) {
70484
+ if (attach === 'true') {
70485
+ appendingDragElementsInDrop();
69828
70486
  }
69829
- else {
70487
+ await executeActions(onCorrect, container);
70488
+ }
70489
+ if (container.getAttribute('dropAttr') === 'EnableAnimation') {
70490
+ setTimeout(() => {
69830
70491
  triggerNextContainer();
69831
- }
69832
- await calculateScore();
70492
+ }, 2000);
69833
70493
  }
69834
70494
  else {
69835
- const onInCorrect = container.getAttribute('onInCorrect');
69836
- await executeActions(onInCorrect, container);
69837
- const isContinueOnCorrect = container.getAttribute('is-continue-on-correct') === 'true';
69838
- if (!isContinueOnCorrect) {
69839
- triggerNextContainer();
69840
- await calculateScore();
69841
- }
70495
+ triggerNextContainer();
70496
+ }
70497
+ await calculateScore();
70498
+ }
70499
+ else {
70500
+ const onInCorrect = container.getAttribute('onInCorrect');
70501
+ await executeActions(onInCorrect, container);
70502
+ const isContinueOnCorrect = container.getAttribute('is-continue-on-correct') === 'true';
70503
+ if (!isContinueOnCorrect) {
70504
+ triggerNextContainer();
70505
+ await calculateScore();
69842
70506
  }
69843
70507
  }
69844
70508
  };
69845
70509
  const triggerNextContainer = () => {
69846
- body.style.pointerEvents = 'auto';
69847
70510
  AudioPlayer.getI().stop();
69848
70511
  // const event = new CustomEvent('nextContainer');
69849
70512
  console.log('🚀 ~ triggerNextContainer ~ event:', event);
@@ -69858,16 +70521,16 @@ const triggerPrevcontainer = () => {
69858
70521
  function convertUrlToRelative(url) {
69859
70522
  const container = document.getElementById(LidoContainer);
69860
70523
  const baseUrl = container.getAttribute('baseUrl');
69861
- 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'))) {
70524
+ if ((url === null || url === void 0 ? void 0 : url.startsWith('http')) || (url === null || url === void 0 ? void 0 : url.startsWith('blob'))) {
69862
70525
  return url;
69863
70526
  }
69864
- if (baseUrl) {
69865
- const newUrl = url.startsWith('/') ? url.slice(1) : url;
69866
- if (newUrl.startsWith(baseUrl.replace(/^\/+|\/+$/g, '')))
69867
- return newUrl;
69868
- return baseUrl.endsWith('/') ? baseUrl + newUrl : `${baseUrl}/${newUrl}`;
70527
+ else if (baseUrl) {
70528
+ const newUrl = !url.startsWith('/') ? url : url.substring(1);
70529
+ return baseUrl + (baseUrl.endsWith('/') ? newUrl : '/' + newUrl);
70530
+ }
70531
+ else {
70532
+ return getAssetPath(url);
69869
70533
  }
69870
- return getAssetPath(url);
69871
70534
  }
69872
70535
  /**
69873
70536
  * Asynchronously speaks the given text using the browser's text-to-speech API.
@@ -70056,7 +70719,10 @@ const equationCheck = (additionalCheck) => {
70056
70719
  });
70057
70720
  // 3. Join the modified parts back into one string
70058
70721
  const resultString = modifiedParts.join('');
70722
+ console.log('🚀 ~ equationCheck ~ resultString:', resultString);
70723
+ // 4. Evaluate the final string as a mathematical expression
70059
70724
  const finalRes = evaluate(resultString);
70725
+ console.log('🚀 ~ equationCheck ~ finalRes:', finalRes);
70060
70726
  return finalRes;
70061
70727
  };
70062
70728
  const getElementsForQueries = (query) => {
@@ -70124,13 +70790,6 @@ const attachSpeakIcon = async (element) => {
70124
70790
  }
70125
70791
  element.appendChild(speakIconElement);
70126
70792
  };
70127
- const clearLocalStorage = () => {
70128
- localStorage.removeItem(DragSelectedMapKey);
70129
- localStorage.removeItem(DragMapKey);
70130
- localStorage.removeItem(SelectedValuesKey);
70131
- localStorage.removeItem(DropHasDrag);
70132
- localStorage.removeItem(DropLength);
70133
- };
70134
70793
  /**
70135
70794
  * Applies a delay to the element's visibility based on `delayVisible`.
70136
70795
  */
@@ -70216,5 +70875,229 @@ function generateUUIDFallback() {
70216
70875
  return v.toString(16);
70217
70876
  });
70218
70877
  }
70878
+ const revealImageValue = (imageEl) => {
70879
+ if (!imageEl)
70880
+ return;
70881
+ const value = imageEl.getAttribute('value');
70882
+ if (!value)
70883
+ return;
70884
+ let valueElement = imageEl.querySelector('.lido-display-hiddenvalue');
70885
+ if (!valueElement) {
70886
+ valueElement = document.createElement('div');
70887
+ valueElement.classList.add('lido-display-hiddenvalue');
70888
+ imageEl.style.position = 'relative';
70889
+ imageEl.appendChild(valueElement);
70890
+ }
70891
+ valueElement.innerText = value;
70892
+ };
70893
+ const setImageBackground = (el, color) => {
70894
+ if (!el)
70895
+ return;
70896
+ el.classList.add('lido-image-colorize');
70897
+ const img = el.querySelector('img');
70898
+ if (img) {
70899
+ // use same image as mask
70900
+ el.style.setProperty('--mask-url', `url(${img.src})`);
70901
+ }
70902
+ if (color === 'red') {
70903
+ el.style.setProperty('--tint-color', '#ff0000');
70904
+ }
70905
+ else if (color === 'green') {
70906
+ el.style.setProperty('--tint-color', '#00c853');
70907
+ }
70908
+ else {
70909
+ el.style.removeProperty('--tint-color');
70910
+ el.style.removeProperty('--mask-url');
70911
+ }
70912
+ };
70913
+ const HighlightStarsOneByOne = async (element, value) => {
70914
+ if (!element)
70915
+ return;
70916
+ if (!value)
70917
+ return;
70918
+ // Dynamically find the parent row of stars
70919
+ const stars = Array.from(element.children);
70920
+ console.log('starRow', stars);
70921
+ for (const star of stars) {
70922
+ // Highlight the star
70923
+ star.classList.add('lido-glow');
70924
+ // Play star sound
70925
+ await AudioPlayer.getI().play(star);
70926
+ // Fade out the star (disappear)
70927
+ star.style.opacity = '0';
70928
+ star.style.visibility = 'hidden';
70929
+ await new Promise(resolve => setTimeout(resolve, 300)); // Wait for fade-out to complete
70930
+ // Remove the highlight
70931
+ star.classList.remove('lido-glow');
70932
+ }
70933
+ };
70934
+ const animateBoxCells = async (element, value) => {
70935
+ if (!element)
70936
+ return;
70937
+ if (!value)
70938
+ return;
70939
+ // Select all cells with the attribute type="box"
70940
+ const boxCells = Array.from(element.children);
70941
+ console.log('boxCells', boxCells);
70942
+ if (!boxCells)
70943
+ return;
70944
+ boxCells.forEach(cell => {
70945
+ // Reset any previous styles
70946
+ cell.style.visibility = 'hidden';
70947
+ });
70948
+ // Animate each cell one by one
70949
+ for (const cell of boxCells) {
70950
+ cell.style.visibility = 'visible';
70951
+ cell.style.opacity = '1';
70952
+ // Apply the "come from top" animation
70953
+ cell.classList.add('lido-box-highlight');
70954
+ // Delay for each cell to come one after another
70955
+ await new Promise(resolve => setTimeout(resolve, 600)); // Adjust delay as needed
70956
+ cell.classList.remove('lido-box-highlight');
70957
+ }
70958
+ // After all cells have come down, apply the bounce animation
70959
+ for (const cell of boxCells) {
70960
+ // play the text child inside cell
70961
+ await AudioPlayer.getI().play(cell);
70962
+ }
70963
+ };
70964
+ const questionBoxAnimation = async (element, value) => {
70965
+ if (!element)
70966
+ return;
70967
+ if (!value)
70968
+ return;
70969
+ // Select all drag elements and drop elements
70970
+ const dragElements = Array.from(element.querySelectorAll("[type='drag']"));
70971
+ // Ensure all drag childrens which is dropped disappear
70972
+ dragElements.forEach(dragElement => {
70973
+ if (dragElement.hasAttribute('drop-to')) {
70974
+ dragElement.style.transition = 'opacity 0.5s ease';
70975
+ dragElement.style.opacity = '0'; // Fade out
70976
+ setTimeout(() => {
70977
+ dragElement.remove(); // Remove from view after fade-out
70978
+ }, 500);
70979
+ }
70980
+ });
70981
+ // Reveal all drop childrens which is hidden
70982
+ const dropElements = Array.from(element.querySelectorAll("[type='drop']"));
70983
+ let check = false;
70984
+ dropElements.forEach(dropEl => {
70985
+ const dropVal = dropEl.getAttribute("value");
70986
+ if (dropVal && dropEl.innerText.trim() === "?") {
70987
+ dropEl.innerText = dropVal;
70988
+ if (dropElements.length > 1 && check == false) {
70989
+ if (window.innerWidth > window.innerHeight) {
70990
+ dropEl.style.marginRight = "-45px";
70991
+ }
70992
+ else {
70993
+ dropEl.style.marginRight = "-65px";
70994
+ }
70995
+ check = true;
70996
+ }
70997
+ }
70998
+ });
70999
+ };
71000
+ const SumTogetherAnimation = async (element, value) => {
71001
+ if (!element)
71002
+ return;
71003
+ if (!value)
71004
+ return;
71005
+ const container = document.getElementById(LidoContainer);
71006
+ if (!container)
71007
+ return;
71008
+ // Expecting structure: [_, TopRow, questionRow, optionRow, ...]
71009
+ const TopRow = Array.from(element.children)[1];
71010
+ const questionRow = Array.from(element.children)[2];
71011
+ const optionRow = Array.from(element.children)[3];
71012
+ if (!TopRow || !questionRow || !optionRow)
71013
+ return;
71014
+ const topRowChildren = Array.from(TopRow.children);
71015
+ const questionRowChildren = Array.from(questionRow.children);
71016
+ const firstNumberEl = questionRowChildren[0];
71017
+ const signElement = questionRowChildren[1];
71018
+ const secondNumberEl = questionRowChildren[2];
71019
+ const equalElement = questionRowChildren[3];
71020
+ const answerElement = questionRowChildren[4];
71021
+ // helper functions
71022
+ const showElement = (el) => {
71023
+ if (!el)
71024
+ return;
71025
+ el.style.visibility = 'visible';
71026
+ el.style.display = '';
71027
+ el.style.opacity = '1';
71028
+ };
71029
+ const readNumber = (el) => {
71030
+ if (!el)
71031
+ return 0;
71032
+ const v = (el.getAttribute && (el.getAttribute('value') || el.getAttribute('string'))) || el.textContent || '';
71033
+ return parseInt(String(v).trim(), 10) || 0;
71034
+ };
71035
+ const elementAppearance = async (flag) => {
71036
+ if (flag) {
71037
+ if (firstNumberEl) {
71038
+ await new Promise(r => setTimeout(r, 200));
71039
+ showElement(firstNumberEl);
71040
+ }
71041
+ if (signElement) {
71042
+ await new Promise(r => setTimeout(r, 200));
71043
+ showElement(signElement);
71044
+ }
71045
+ }
71046
+ else {
71047
+ if (secondNumberEl) {
71048
+ await new Promise(r => setTimeout(r, 200));
71049
+ showElement(secondNumberEl);
71050
+ }
71051
+ if (equalElement) {
71052
+ await new Promise(r => setTimeout(r, 300));
71053
+ showElement(equalElement);
71054
+ }
71055
+ if (optionRow) {
71056
+ await new Promise(r => setTimeout(r, 300));
71057
+ showElement(optionRow);
71058
+ }
71059
+ if (answerElement) {
71060
+ await new Promise(r => setTimeout(r, 200));
71061
+ showElement(answerElement);
71062
+ }
71063
+ }
71064
+ };
71065
+ const number1 = readNumber(firstNumberEl);
71066
+ const number2 = readNumber(secondNumberEl);
71067
+ const sign = ((signElement && ((signElement.getAttribute('string') || signElement.textContent) || '')).toString().trim() === '+') ? '+' : '-';
71068
+ if (sign === '-') {
71069
+ // '-' flow: reveal one by one then change bgColor of last B to red
71070
+ for (let i = 0; i < topRowChildren.length; i++) {
71071
+ await new Promise(resolve => setTimeout(resolve, 75));
71072
+ showElement(topRowChildren[i]);
71073
+ }
71074
+ elementAppearance(true);
71075
+ await new Promise(r => setTimeout(r, 500));
71076
+ for (let k = 0; k < Math.min(number2, topRowChildren.length); k++) {
71077
+ const idx = topRowChildren.length - 1 - k;
71078
+ setImageBackground(topRowChildren[idx], 'red');
71079
+ await new Promise(r => setTimeout(r, 200));
71080
+ }
71081
+ elementAppearance(false);
71082
+ }
71083
+ else {
71084
+ // '+' flow: hide all, then showElement first A, then showElement next B in green
71085
+ for (let i = 0; i < Math.min(number1, topRowChildren.length); i++) {
71086
+ await new Promise(resolve => setTimeout(resolve, 120));
71087
+ showElement(topRowChildren[i]);
71088
+ }
71089
+ elementAppearance(true);
71090
+ await new Promise(r => setTimeout(r, 500));
71091
+ for (let j = 0; j < Math.min(number2, Math.max(0, topRowChildren.length - number1)); j++) {
71092
+ const idx = number1 + j;
71093
+ if (topRowChildren[idx]) {
71094
+ showElement(topRowChildren[idx]);
71095
+ setImageBackground(topRowChildren[idx], 'green');
71096
+ }
71097
+ await new Promise(r => setTimeout(r, 80));
71098
+ }
71099
+ elementAppearance(false);
71100
+ }
71101
+ };
70219
71102
 
70220
- export { ActivityScoreKey as A, nextUrl as B, speakUrl as C, getCancelBtnPopup as D, matchStringPattern as E, triggerNextContainer as F, triggerPrevcontainer as G, H, executeActions as I, setCancelBtnPopup as J, getDefaultExportFromCjs as K, LidoContainer as L, tinyColor as M, NextContainerKey as N, storingEachActivityScore as O, PrevContainerKey as P, DropAction as Q, RiveService as R, SelectedValuesKey as S, fraction as T, TraceMode as U, speakIcon as V, fingerUrl as W, setNonce as a, setPlatformOptions as b, commonjsGlobal as c, setVisibilityWithDelay as d, convertUrlToRelative as e, format as f, getAssetPath$1 as g, h, initEventsForElement as i, Host as j, handlingChildElements as k, attachSpeakIcon as l, parseProp as m, calculateScale as n, handleFloatElementPosition as o, proxyCustomElement as p, handleElementClick as q, clearLocalStorage as r, setAssetPath as s, dispatchActivityChangeEvent as t, dispatchGameCompletedEvent as u, dispatchGameExitEvent as v, AudioPlayer as w, generateUUIDFallback as x, exitUrl as y, prevUrl as z };
71103
+ export { ActivityScoreKey as A, generateUUIDFallback as B, exitUrl as C, prevUrl as D, nextUrl as E, speakUrl as F, getCancelBtnPopup as G, H, triggerPrevcontainer as I, setCancelBtnPopup as J, getDefaultExportFromCjs as K, LidoContainer as L, tinyColor as M, NextContainerKey as N, triggerNextContainer as O, PrevContainerKey as P, DropAction as Q, RiveService as R, SelectedValuesKey as S, validateObjectiveStatus as T, fraction as U, TraceMode as V, speakIcon as W, fingerUrl as X, setNonce as a, setPlatformOptions as b, commonjsGlobal as c, setVisibilityWithDelay as d, convertUrlToRelative as e, format as f, getAssetPath$1 as g, h, initEventsForElement as i, Host as j, parseProp as k, createEvent as l, equationCheck as m, storingEachActivityScore as n, executeActions as o, proxyCustomElement as p, handlingChildElements as q, attachSpeakIcon as r, setAssetPath as s, calculateScale as t, handleFloatElementPosition as u, handleElementClick as v, dispatchActivityChangeEvent as w, dispatchGameCompletedEvent as x, dispatchGameExitEvent as y, AudioPlayer as z };