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,4 +1,4 @@
1
- import { ActivityScoreKey, DragSelectedMapKey, DragMapKey, SelectedValuesKey, DropMode, DropToAttr, DropTimeAttr, LidoContainer, DropAction, DropHasDrag, DropLength, } from "./constants";
1
+ import { ActivityScoreKey, DragMapKey, SelectedValuesKey, DropMode, DropToAttr, DropTimeAttr, LidoContainer, DropAction, } from "./constants";
2
2
  import { dispatchActivityEndEvent, dispatchLessonEndEvent, dispatchNextContainerEvent, dispatchPrevContainerEvent } from "./customEvents";
3
3
  import GameScore from "./constants";
4
4
  import { RiveService } from "./rive-service";
@@ -11,7 +11,43 @@ import { addClickListenerForClickType, onTouchListenerForOnTouch } from "./utils
11
11
  import { evaluate, isArray } from "mathjs";
12
12
  import { fillSlideHandle } from "./utilsHandlers/floatHandler";
13
13
  import { stopHighlightForSpeakingElement } from "./utilsHandlers/highlightHandler";
14
+ import { handleSolvedEquationSubmissionAndScoreUpdate } from "./utilsHandlers/lidoCalculatorHandler";
15
+ import { handlingMatrix } from "./utilsHandlers/matrixHandler";
16
+ import { balanceResult } from "./utilsHandlers/lidoBalanceHandler";
14
17
  const gameScore = new GameScore();
18
+ export function buildDragSelectedMapFromDOM() {
19
+ const map = {};
20
+ const draggedEls = document.querySelectorAll(`[${DropToAttr}]`);
21
+ draggedEls.forEach(dragEl => {
22
+ var _a, _b, _c;
23
+ const to = dragEl.getAttribute(DropToAttr);
24
+ if (!to)
25
+ return;
26
+ const dropEl = document.getElementById(to);
27
+ if (!dropEl)
28
+ return;
29
+ const tabIndex = (_a = dropEl.getAttribute('tab-index')) !== null && _a !== void 0 ? _a : to;
30
+ if (!map[tabIndex])
31
+ map[tabIndex] = [];
32
+ const value = (_c = (_b = dragEl.getAttribute('value')) !== null && _b !== void 0 ? _b : dragEl.value) !== null && _c !== void 0 ? _c : '';
33
+ map[tabIndex].push(value);
34
+ });
35
+ return map;
36
+ }
37
+ export function getSortedValuesArrayFromMap(map) {
38
+ const sortedKeys = Object.keys(map).sort((a, b) => parseInt(a) - parseInt(b));
39
+ const sortedValues = sortedKeys.reduce((acc, key) => {
40
+ const values = map[key];
41
+ if (values.length > 1) {
42
+ acc.push(`(${values.join('|')})`);
43
+ }
44
+ else {
45
+ acc.push(values[0]);
46
+ }
47
+ return acc;
48
+ }, []);
49
+ return sortedValues;
50
+ }
15
51
  export function format(first, middle, last) {
16
52
  return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');
17
53
  }
@@ -56,6 +92,10 @@ export const initEventsForElement = async (element, type) => {
56
92
  enableOptionArea(element);
57
93
  break;
58
94
  }
95
+ case 'checkerBlock': {
96
+ handlingMatrix(element);
97
+ break;
98
+ }
59
99
  default:
60
100
  break;
61
101
  }
@@ -63,7 +103,7 @@ export const initEventsForElement = async (element, type) => {
63
103
  };
64
104
  // Function to execute actions parsed from the onMatch string
65
105
  export const executeActions = async (actionsString, thisElement, element) => {
66
- var _a;
106
+ var _a, _b, _c, _d, _e, _f, _g;
67
107
  const actions = parseActions(actionsString);
68
108
  for (let i = 0; i < actions.length; i++) {
69
109
  const action = actions[i];
@@ -77,13 +117,25 @@ export const executeActions = async (actionsString, thisElement, element) => {
77
117
  targetElement.style.transform = currentTransform !== 'none' ? `${currentTransform} ${action.value}` : action.value;
78
118
  break;
79
119
  }
120
+ case 'revealImageValue': {
121
+ if (targetElement) {
122
+ revealImageValue(targetElement); // call your function here
123
+ }
124
+ break;
125
+ }
126
+ case 'scrollCellAfterEquationSolved': {
127
+ if (targetElement) {
128
+ handleSolvedEquationSubmissionAndScoreUpdate();
129
+ }
130
+ break;
131
+ }
80
132
  case 'alignMatch': {
81
133
  const dropElement = targetElement;
82
134
  const dragElement = element;
83
135
  const container = document.getElementById(LidoContainer);
84
136
  const containerScale = getElementScale(container);
85
137
  dragElement.style.transform = 'translate(0,0)';
86
- console.log('logg alinmatch');
138
+ console.log("logg alinmatch");
87
139
  const dropRect = dropElement.getBoundingClientRect();
88
140
  const dragRect = dragElement.getBoundingClientRect();
89
141
  const dropCenterX = dropRect.left + dropRect.width / 2;
@@ -169,10 +221,76 @@ export const executeActions = async (actionsString, thisElement, element) => {
169
221
  }
170
222
  break;
171
223
  }
224
+ case 'highlightStarsAndDisapper': {
225
+ const value = action.value;
226
+ if (value && targetElement) {
227
+ console.log('highlightStar action triggered');
228
+ console.log('Target Element:', targetElement);
229
+ await HighlightStarsOneByOne(targetElement, value);
230
+ }
231
+ break;
232
+ }
233
+ case 'boxAnimationOneByOne': {
234
+ const value = action.value;
235
+ if (value && targetElement) {
236
+ await animateBoxCells(targetElement, value);
237
+ }
238
+ break;
239
+ }
240
+ case 'questionBoxAnimate': {
241
+ const value = action.value;
242
+ if (value && targetElement) {
243
+ await questionBoxAnimation(targetElement, value);
244
+ }
245
+ break;
246
+ }
172
247
  case 'slideAnimation': {
173
248
  slideAnimation();
174
249
  break;
175
250
  }
251
+ case 'showBalanceSymbol': {
252
+ const balanceEl = document.querySelector('lido-balance');
253
+ if (!balanceEl)
254
+ break;
255
+ 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));
256
+ 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));
257
+ const symbol = leftVal > rightVal ? '>' : leftVal < rightVal ? '<' : '=';
258
+ balanceEl.balanceSymbol = symbol;
259
+ balanceEl.dataset.balanceSymbol = symbol;
260
+ if (balanceEl.revealSymbol) {
261
+ await balanceEl.revealSymbol();
262
+ }
263
+ else {
264
+ balanceEl.showSymbol = true;
265
+ }
266
+ break;
267
+ }
268
+ case 'hideBalanceSymbol': {
269
+ const balanceEl = document.querySelector('lido-balance');
270
+ if (!balanceEl)
271
+ break;
272
+ if (balanceEl.hideSymbol) {
273
+ await balanceEl.hideSymbol();
274
+ }
275
+ else {
276
+ balanceEl.showSymbol = false;
277
+ }
278
+ break;
279
+ }
280
+ case 'sumTogetherAnimation': {
281
+ const value = action.value;
282
+ if (value) {
283
+ SumTogetherAnimation(targetElement, value);
284
+ }
285
+ break;
286
+ }
287
+ case 'addText': {
288
+ const value = action.value;
289
+ if (value) {
290
+ targetElement.textContent += value;
291
+ }
292
+ break;
293
+ }
176
294
  default: {
177
295
  targetElement.style[action.action] = action.value;
178
296
  break;
@@ -270,6 +388,9 @@ export const matchStringPattern = (pattern, arr) => {
270
388
  const patternGroups = pattern.split(',').map(group => group.trim());
271
389
  let arrIndex = 0;
272
390
  let options = new Set();
391
+ if (patternGroups.length == 0) { // If pattern is empty
392
+ return true;
393
+ }
273
394
  if (patternGroups.length > 0) {
274
395
  if (arr.length === 0)
275
396
  return false; // If pattern is not empty but user provided array is empty, return false
@@ -354,20 +475,29 @@ export const calculateScore = () => {
354
475
  gameScore.wrongMoves = 0;
355
476
  };
356
477
  export async function onActivityComplete(dragElement, dropElement) {
357
- var _a, _b;
478
+ var _a;
358
479
  const container = document.getElementById(LidoContainer);
359
480
  if (!container)
360
481
  return;
361
482
  await executeActions("this.alignMatch='true'", dropElement, dragElement);
362
- let dragScore = JSON.parse((_a = localStorage.getItem(DragSelectedMapKey)) !== null && _a !== void 0 ? _a : '{}');
363
- const tabindex = dropElement.getAttribute('tab-index');
364
- if (!dragScore[tabindex]) {
365
- dragScore[tabindex] = [];
483
+ if (dragElement && dropElement) {
484
+ const isCorrect = dropElement['value'].toLowerCase().includes(dragElement['value'].toLowerCase());
485
+ if (isCorrect) {
486
+ const onCorrect = dropElement.getAttribute('onCorrect');
487
+ if (onCorrect) {
488
+ await executeActions(onCorrect, dropElement, dragElement);
489
+ }
490
+ }
491
+ else {
492
+ const onInCorrect = dropElement.getAttribute('onInCorrect');
493
+ await executeActions(onInCorrect, dropElement, dragElement);
494
+ }
366
495
  }
367
- dragScore[tabindex].push(dragElement['value']);
368
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragScore));
496
+ let dragScore = buildDragSelectedMapFromDOM();
497
+ const sortedValues = getSortedValuesArrayFromMap(dragScore);
498
+ container.setAttribute(SelectedValuesKey, JSON.stringify(sortedValues));
369
499
  //localStorage
370
- let drag = JSON.parse((_b = localStorage.getItem(DragMapKey)) !== null && _b !== void 0 ? _b : '{}');
500
+ let drag = JSON.parse((_a = localStorage.getItem(DragMapKey)) !== null && _a !== void 0 ? _a : '{}');
371
501
  const index = dropElement.getAttribute('tab-index');
372
502
  if (!drag[index]) {
373
503
  drag[index] = [];
@@ -375,17 +505,6 @@ export async function onActivityComplete(dragElement, dropElement) {
375
505
  drag[index].push(dragElement.id);
376
506
  // localStorage.setItem(DragMapKey, JSON.stringify(drag));
377
507
  const sortedKeys = Object.keys(dragScore).sort((a, b) => parseInt(a) - parseInt(b));
378
- const sortedValues = sortedKeys.reduce((acc, key) => {
379
- const values = dragScore[key];
380
- if (values.length > 1) {
381
- acc.push(`(${values.join('|')})`);
382
- }
383
- else {
384
- acc.push(values[0]);
385
- }
386
- return acc;
387
- }, []);
388
- localStorage.setItem(SelectedValuesKey, JSON.stringify(sortedValues));
389
508
  if (dragElement && dropElement) {
390
509
  const isCorrect = dropElement['value'].toLowerCase().includes(dragElement['value'].toLowerCase());
391
510
  if (isCorrect) {
@@ -402,8 +521,7 @@ export async function onActivityComplete(dragElement, dropElement) {
402
521
  const allElements = document.querySelectorAll("[type='drop']");
403
522
  allElements.forEach(otherElement => {
404
523
  var _a;
405
- const dropObject = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
406
- const storedTabIndexes = Object.keys(dropObject).map(Number);
524
+ const storedTabIndexes = Object.keys(dragScore).map(Number);
407
525
  if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
408
526
  if (!(((_a = otherElement.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
409
527
  if (otherElement.tagName.toLowerCase() === 'lido-text') {
@@ -455,81 +573,101 @@ export const handleShowCheck = () => {
455
573
  var _a, _b;
456
574
  const container = document.getElementById(LidoContainer);
457
575
  const objectiveString = container['objective'];
458
- const selectValues = (_a = localStorage.getItem(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '';
576
+ const selectValues = (_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '';
459
577
  const checkButton = document.querySelector('#lido-checkButton');
460
- if (!selectValues || countPatternWords(selectValues) !== countPatternWords(objectiveString)) {
578
+ if (!selectValues || countPatternWords(selectValues) < countPatternWords(objectiveString)) {
461
579
  executeActions("this.addClass='lido-disable-check-button'", checkButton);
462
580
  return;
463
581
  }
464
582
  const showCheck = container.getAttribute('show-check') == 'true';
465
583
  if (showCheck) {
466
584
  (_b = checkButton === null || checkButton === void 0 ? void 0 : checkButton.classList) === null || _b === void 0 ? void 0 : _b.remove('lido-disable-check-button');
585
+ const balanceEl = document.querySelector('lido-balance');
586
+ if (balanceEl) {
587
+ if (!checkButton.hasAttribute('data-balance-listener')) {
588
+ checkButton.addEventListener('click', async function onClick() {
589
+ if (balanceResult && res) {
590
+ await executeActions("this.showBalanceSymbol='true'", checkButton);
591
+ checkButton.removeEventListener('click', onClick);
592
+ }
593
+ });
594
+ checkButton.setAttribute('data-balance-listener', 'true');
595
+ }
596
+ }
467
597
  }
468
598
  else {
469
599
  validateObjectiveStatus();
470
600
  }
471
601
  };
472
- const body = document.body;
602
+ let res;
473
603
  export const validateObjectiveStatus = async () => {
474
- var _a;
604
+ var _a, _b;
475
605
  const container = document.getElementById(LidoContainer);
476
606
  if (!container)
477
607
  return;
478
608
  const objectiveString = container['objective'];
609
+ const additionalCheck = container.getAttribute('equationCheck');
610
+ console.log('🚀 ~ validateObjectiveStatus ~ additionalCheck:', additionalCheck);
611
+ let equationGiven = false;
479
612
  if (objectiveString == null || objectiveString.length === 0) {
480
- const onCorrect = container.getAttribute('onCorrect');
481
- if (onCorrect) {
482
- await executeActions(onCorrect, container);
613
+ if (additionalCheck) {
614
+ equationGiven = true;
615
+ }
616
+ if (!equationGiven) {
617
+ const onCorrect = container.getAttribute('onCorrect');
618
+ if (onCorrect) {
619
+ await executeActions(onCorrect, container);
620
+ }
621
+ storeActivityScore(100);
622
+ storingEachActivityScore(true);
623
+ triggerNextContainer();
624
+ return;
483
625
  }
484
- storeActivityScore(100);
485
- storingEachActivityScore(true);
486
- triggerNextContainer();
487
- return;
488
626
  }
489
- else {
490
- const objectiveArray = (_a = JSON.parse(localStorage.getItem(SelectedValuesKey))) !== null && _a !== void 0 ? _a : [];
491
- let res;
492
- const additionalCheck = container.getAttribute('equationCheck');
493
- if (!!additionalCheck) {
627
+ const objectiveArray = (_b = JSON.parse((_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]')) !== null && _b !== void 0 ? _b : [];
628
+ if (!!additionalCheck) {
629
+ const balanceEl = document.querySelector('lido-balance');
630
+ if (!balanceEl) {
494
631
  res = equationCheck(additionalCheck);
495
- console.log('🚀 ~ handleShowCheck ~ res:', res);
496
632
  }
497
633
  else {
498
- res = matchStringPattern(objectiveString, objectiveArray);
634
+ res = balanceResult(container, objectiveString);
499
635
  }
500
- if (res) {
501
- const attach = container.getAttribute('appendToDropOnCompletion');
502
- body.style.pointerEvents = 'none';
503
- const onCorrect = container.getAttribute('onCorrect');
504
- if (onCorrect) {
505
- if (attach === 'true') {
506
- appendingDragElementsInDrop();
507
- }
508
- await executeActions(onCorrect, container);
509
- }
510
- if (container.getAttribute('dropAttr') === 'EnableAnimation') {
511
- setTimeout(() => {
512
- triggerNextContainer();
513
- }, 2000);
636
+ console.log('🚀 ~ handleShowCheck ~ res:', res);
637
+ }
638
+ else {
639
+ res = matchStringPattern(objectiveString, objectiveArray);
640
+ }
641
+ if (res) {
642
+ const attach = container.getAttribute('appendToDropOnCompletion');
643
+ const onCorrect = container.getAttribute('onCorrect');
644
+ if (onCorrect) {
645
+ if (attach === 'true') {
646
+ appendingDragElementsInDrop();
514
647
  }
515
- else {
648
+ await executeActions(onCorrect, container);
649
+ }
650
+ if (container.getAttribute('dropAttr') === 'EnableAnimation') {
651
+ setTimeout(() => {
516
652
  triggerNextContainer();
517
- }
518
- await calculateScore();
653
+ }, 2000);
519
654
  }
520
655
  else {
521
- const onInCorrect = container.getAttribute('onInCorrect');
522
- await executeActions(onInCorrect, container);
523
- const isContinueOnCorrect = container.getAttribute('is-continue-on-correct') === 'true';
524
- if (!isContinueOnCorrect) {
525
- triggerNextContainer();
526
- await calculateScore();
527
- }
656
+ triggerNextContainer();
657
+ }
658
+ await calculateScore();
659
+ }
660
+ else {
661
+ const onInCorrect = container.getAttribute('onInCorrect');
662
+ await executeActions(onInCorrect, container);
663
+ const isContinueOnCorrect = container.getAttribute('is-continue-on-correct') === 'true';
664
+ if (!isContinueOnCorrect) {
665
+ triggerNextContainer();
666
+ await calculateScore();
528
667
  }
529
668
  }
530
669
  };
531
670
  export const triggerNextContainer = () => {
532
- body.style.pointerEvents = 'auto';
533
671
  AudioPlayer.getI().stop();
534
672
  // const event = new CustomEvent('nextContainer');
535
673
  console.log('🚀 ~ triggerNextContainer ~ event:', event);
@@ -544,16 +682,16 @@ export const triggerPrevcontainer = () => {
544
682
  export function convertUrlToRelative(url) {
545
683
  const container = document.getElementById(LidoContainer);
546
684
  const baseUrl = container.getAttribute('baseUrl');
547
- 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'))) {
685
+ if ((url === null || url === void 0 ? void 0 : url.startsWith('http')) || (url === null || url === void 0 ? void 0 : url.startsWith('blob'))) {
548
686
  return url;
549
687
  }
550
- if (baseUrl) {
551
- const newUrl = url.startsWith('/') ? url.slice(1) : url;
552
- if (newUrl.startsWith(baseUrl.replace(/^\/+|\/+$/g, '')))
553
- return newUrl;
554
- return baseUrl.endsWith('/') ? baseUrl + newUrl : `${baseUrl}/${newUrl}`;
688
+ else if (baseUrl) {
689
+ const newUrl = !url.startsWith('/') ? url : url.substring(1);
690
+ return baseUrl + (baseUrl.endsWith('/') ? newUrl : '/' + newUrl);
691
+ }
692
+ else {
693
+ return getAssetPath(url);
555
694
  }
556
- return getAssetPath(url);
557
695
  }
558
696
  /**
559
697
  * Asynchronously speaks the given text using the browser's text-to-speech API.
@@ -742,7 +880,10 @@ export const equationCheck = (additionalCheck) => {
742
880
  });
743
881
  // 3. Join the modified parts back into one string
744
882
  const resultString = modifiedParts.join('');
883
+ console.log('🚀 ~ equationCheck ~ resultString:', resultString);
884
+ // 4. Evaluate the final string as a mathematical expression
745
885
  const finalRes = evaluate(resultString);
886
+ console.log('🚀 ~ equationCheck ~ finalRes:', finalRes);
746
887
  return finalRes;
747
888
  };
748
889
  const getElementsForQueries = (query) => {
@@ -811,13 +952,6 @@ export const attachSpeakIcon = async (element) => {
811
952
  }
812
953
  element.appendChild(speakIconElement);
813
954
  };
814
- export const clearLocalStorage = () => {
815
- localStorage.removeItem(DragSelectedMapKey);
816
- localStorage.removeItem(DragMapKey);
817
- localStorage.removeItem(SelectedValuesKey);
818
- localStorage.removeItem(DropHasDrag);
819
- localStorage.removeItem(DropLength);
820
- };
821
955
  /**
822
956
  * Applies a delay to the element's visibility based on `delayVisible`.
823
957
  */
@@ -903,3 +1037,227 @@ export function generateUUIDFallback() {
903
1037
  return v.toString(16);
904
1038
  });
905
1039
  }
1040
+ export const revealImageValue = (imageEl) => {
1041
+ if (!imageEl)
1042
+ return;
1043
+ const value = imageEl.getAttribute('value');
1044
+ if (!value)
1045
+ return;
1046
+ let valueElement = imageEl.querySelector('.lido-display-hiddenvalue');
1047
+ if (!valueElement) {
1048
+ valueElement = document.createElement('div');
1049
+ valueElement.classList.add('lido-display-hiddenvalue');
1050
+ imageEl.style.position = 'relative';
1051
+ imageEl.appendChild(valueElement);
1052
+ }
1053
+ valueElement.innerText = value;
1054
+ };
1055
+ const setImageBackground = (el, color) => {
1056
+ if (!el)
1057
+ return;
1058
+ el.classList.add('lido-image-colorize');
1059
+ const img = el.querySelector('img');
1060
+ if (img) {
1061
+ // use same image as mask
1062
+ el.style.setProperty('--mask-url', `url(${img.src})`);
1063
+ }
1064
+ if (color === 'red') {
1065
+ el.style.setProperty('--tint-color', '#ff0000');
1066
+ }
1067
+ else if (color === 'green') {
1068
+ el.style.setProperty('--tint-color', '#00c853');
1069
+ }
1070
+ else {
1071
+ el.style.removeProperty('--tint-color');
1072
+ el.style.removeProperty('--mask-url');
1073
+ }
1074
+ };
1075
+ export const HighlightStarsOneByOne = async (element, value) => {
1076
+ if (!element)
1077
+ return;
1078
+ if (!value)
1079
+ return;
1080
+ // Dynamically find the parent row of stars
1081
+ const stars = Array.from(element.children);
1082
+ console.log('starRow', stars);
1083
+ for (const star of stars) {
1084
+ // Highlight the star
1085
+ star.classList.add('lido-glow');
1086
+ // Play star sound
1087
+ await AudioPlayer.getI().play(star);
1088
+ // Fade out the star (disappear)
1089
+ star.style.opacity = '0';
1090
+ star.style.visibility = 'hidden';
1091
+ await new Promise(resolve => setTimeout(resolve, 300)); // Wait for fade-out to complete
1092
+ // Remove the highlight
1093
+ star.classList.remove('lido-glow');
1094
+ }
1095
+ };
1096
+ export const animateBoxCells = async (element, value) => {
1097
+ if (!element)
1098
+ return;
1099
+ if (!value)
1100
+ return;
1101
+ // Select all cells with the attribute type="box"
1102
+ const boxCells = Array.from(element.children);
1103
+ console.log('boxCells', boxCells);
1104
+ if (!boxCells)
1105
+ return;
1106
+ boxCells.forEach(cell => {
1107
+ // Reset any previous styles
1108
+ cell.style.visibility = 'hidden';
1109
+ });
1110
+ // Animate each cell one by one
1111
+ for (const cell of boxCells) {
1112
+ cell.style.visibility = 'visible';
1113
+ cell.style.opacity = '1';
1114
+ // Apply the "come from top" animation
1115
+ cell.classList.add('lido-box-highlight');
1116
+ // Delay for each cell to come one after another
1117
+ await new Promise(resolve => setTimeout(resolve, 600)); // Adjust delay as needed
1118
+ cell.classList.remove('lido-box-highlight');
1119
+ }
1120
+ // After all cells have come down, apply the bounce animation
1121
+ for (const cell of boxCells) {
1122
+ // play the text child inside cell
1123
+ await AudioPlayer.getI().play(cell);
1124
+ }
1125
+ };
1126
+ export const questionBoxAnimation = async (element, value) => {
1127
+ if (!element)
1128
+ return;
1129
+ if (!value)
1130
+ return;
1131
+ // Select all drag elements and drop elements
1132
+ const dragElements = Array.from(element.querySelectorAll("[type='drag']"));
1133
+ // Ensure all drag childrens which is dropped disappear
1134
+ dragElements.forEach(dragElement => {
1135
+ if (dragElement.hasAttribute('drop-to')) {
1136
+ dragElement.style.transition = 'opacity 0.5s ease';
1137
+ dragElement.style.opacity = '0'; // Fade out
1138
+ setTimeout(() => {
1139
+ dragElement.remove(); // Remove from view after fade-out
1140
+ }, 500);
1141
+ }
1142
+ });
1143
+ // Reveal all drop childrens which is hidden
1144
+ const dropElements = Array.from(element.querySelectorAll("[type='drop']"));
1145
+ let check = false;
1146
+ dropElements.forEach(dropEl => {
1147
+ const dropVal = dropEl.getAttribute("value");
1148
+ if (dropVal && dropEl.innerText.trim() === "?") {
1149
+ dropEl.innerText = dropVal;
1150
+ if (dropElements.length > 1 && check == false) {
1151
+ if (window.innerWidth > window.innerHeight) {
1152
+ dropEl.style.marginRight = "-45px";
1153
+ }
1154
+ else {
1155
+ dropEl.style.marginRight = "-65px";
1156
+ }
1157
+ check = true;
1158
+ }
1159
+ }
1160
+ });
1161
+ };
1162
+ export const SumTogetherAnimation = async (element, value) => {
1163
+ if (!element)
1164
+ return;
1165
+ if (!value)
1166
+ return;
1167
+ const container = document.getElementById(LidoContainer);
1168
+ if (!container)
1169
+ return;
1170
+ // Expecting structure: [_, TopRow, questionRow, optionRow, ...]
1171
+ const TopRow = Array.from(element.children)[1];
1172
+ const questionRow = Array.from(element.children)[2];
1173
+ const optionRow = Array.from(element.children)[3];
1174
+ if (!TopRow || !questionRow || !optionRow)
1175
+ return;
1176
+ const topRowChildren = Array.from(TopRow.children);
1177
+ const questionRowChildren = Array.from(questionRow.children);
1178
+ const firstNumberEl = questionRowChildren[0];
1179
+ const signElement = questionRowChildren[1];
1180
+ const secondNumberEl = questionRowChildren[2];
1181
+ const equalElement = questionRowChildren[3];
1182
+ const answerElement = questionRowChildren[4];
1183
+ // helper functions
1184
+ const showElement = (el) => {
1185
+ if (!el)
1186
+ return;
1187
+ el.style.visibility = 'visible';
1188
+ el.style.display = '';
1189
+ el.style.opacity = '1';
1190
+ };
1191
+ const readNumber = (el) => {
1192
+ if (!el)
1193
+ return 0;
1194
+ const v = (el.getAttribute && (el.getAttribute('value') || el.getAttribute('string'))) || el.textContent || '';
1195
+ return parseInt(String(v).trim(), 10) || 0;
1196
+ };
1197
+ const elementAppearance = async (flag) => {
1198
+ if (flag) {
1199
+ if (firstNumberEl) {
1200
+ await new Promise(r => setTimeout(r, 200));
1201
+ showElement(firstNumberEl);
1202
+ }
1203
+ if (signElement) {
1204
+ await new Promise(r => setTimeout(r, 200));
1205
+ showElement(signElement);
1206
+ }
1207
+ }
1208
+ else {
1209
+ if (secondNumberEl) {
1210
+ await new Promise(r => setTimeout(r, 200));
1211
+ showElement(secondNumberEl);
1212
+ }
1213
+ if (equalElement) {
1214
+ await new Promise(r => setTimeout(r, 300));
1215
+ showElement(equalElement);
1216
+ }
1217
+ if (optionRow) {
1218
+ await new Promise(r => setTimeout(r, 300));
1219
+ showElement(optionRow);
1220
+ }
1221
+ if (answerElement) {
1222
+ await new Promise(r => setTimeout(r, 200));
1223
+ showElement(answerElement);
1224
+ }
1225
+ }
1226
+ };
1227
+ const number1 = readNumber(firstNumberEl);
1228
+ const number2 = readNumber(secondNumberEl);
1229
+ const sign = ((signElement && ((signElement.getAttribute('string') || signElement.textContent) || '')).toString().trim() === '+') ? '+' : '-';
1230
+ if (sign === '-') {
1231
+ // '-' flow: reveal one by one then change bgColor of last B to red
1232
+ for (let i = 0; i < topRowChildren.length; i++) {
1233
+ await new Promise(resolve => setTimeout(resolve, 75));
1234
+ showElement(topRowChildren[i]);
1235
+ }
1236
+ elementAppearance(true);
1237
+ await new Promise(r => setTimeout(r, 500));
1238
+ for (let k = 0; k < Math.min(number2, topRowChildren.length); k++) {
1239
+ const idx = topRowChildren.length - 1 - k;
1240
+ setImageBackground(topRowChildren[idx], 'red');
1241
+ await new Promise(r => setTimeout(r, 200));
1242
+ }
1243
+ elementAppearance(false);
1244
+ }
1245
+ else {
1246
+ // '+' flow: hide all, then showElement first A, then showElement next B in green
1247
+ for (let i = 0; i < Math.min(number1, topRowChildren.length); i++) {
1248
+ await new Promise(resolve => setTimeout(resolve, 120));
1249
+ showElement(topRowChildren[i]);
1250
+ }
1251
+ elementAppearance(true);
1252
+ await new Promise(r => setTimeout(r, 500));
1253
+ for (let j = 0; j < Math.min(number2, Math.max(0, topRowChildren.length - number1)); j++) {
1254
+ const idx = number1 + j;
1255
+ if (topRowChildren[idx]) {
1256
+ showElement(topRowChildren[idx]);
1257
+ setImageBackground(topRowChildren[idx], 'green');
1258
+ }
1259
+ await new Promise(r => setTimeout(r, 80));
1260
+ }
1261
+ elementAppearance(false);
1262
+ }
1263
+ };