lido-player 0.0.2-alpha-51-dev → 0.0.2-alpha-53-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 (143) hide show
  1. package/dist/cjs/index.cjs.js +1 -1
  2. package/dist/cjs/lido-avatar_22.cjs.entry.js +199 -73
  3. package/dist/cjs/lido-player.cjs.js +1 -1
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/cjs/{utils-dc02d753.js → utils-3c1ce74e.js} +236 -101
  6. package/dist/collection/components/avatar/lido-avatar.js +1 -1
  7. package/dist/collection/components/canvas/lido-canvas.css +5 -8
  8. package/dist/collection/components/canvas/lido-canvas.js +2 -2
  9. package/dist/collection/components/cell/lido-cell.js +1 -1
  10. package/dist/collection/components/column/lido-col.js +1 -1
  11. package/dist/collection/components/container/lido-container.js +24 -2
  12. package/dist/collection/components/flashCard/lido-flash-card.js +1 -1
  13. package/dist/collection/components/home/lido-home.css +4 -0
  14. package/dist/collection/components/home/lido-home.js +27 -3
  15. package/dist/collection/components/mathMatrix/lido-math-matrix.js +14 -14
  16. package/dist/collection/components/position/lido-pos.js +1 -1
  17. package/dist/collection/components/random/lido-random.js +1 -1
  18. package/dist/collection/components/row/lido-row.js +1 -1
  19. package/dist/collection/components/shape/lido-shape.js +1 -1
  20. package/dist/collection/components/trace/lido-trace.js +122 -47
  21. package/dist/collection/components/wrap/lido-wrap.js +1 -1
  22. package/dist/collection/stories/Templates/Fill-Up/fill-up.stories.js +26 -25
  23. package/dist/collection/stories/Templates/LetterPairing/LetterPairing.stories.js +3 -1
  24. package/dist/collection/stories/Templates/RocketGame/rocketGame.stories.js +1 -1
  25. package/dist/collection/stories/Templates/arrangeLetters/arrangeLetters.stories.js +1 -1
  26. package/dist/collection/stories/Templates/balancing/balancing.stories.js +1 -1
  27. package/dist/collection/stories/Templates/blender/blender.stories.js +100 -0
  28. package/dist/collection/stories/Templates/bubbleType/bubbleType.stories.js +1 -1
  29. package/dist/collection/stories/Templates/calculator/calculator.stories.js +6 -2
  30. package/dist/collection/stories/Templates/checker-block/checkerBlock.stories.js +1 -1
  31. package/dist/collection/stories/Templates/checkerBlock/checkerBlock.stories.js +1 -1
  32. package/dist/collection/stories/Templates/create-sentence/createSentence.stories.js +1 -1
  33. package/dist/collection/stories/Templates/fillAnswer/fill-answer.stories.js +3 -2
  34. package/dist/collection/stories/Templates/fillBlank/fill-blank.stories.js +1 -1
  35. package/dist/collection/stories/Templates/foodJar/food-jar.stories.js +3 -1
  36. package/dist/collection/stories/Templates/grid/grid.stories.js +5 -1
  37. package/dist/collection/stories/Templates/gridGame/grid-game.stories.js +1 -1
  38. package/dist/collection/stories/Templates/jumpSentence/jumpSentence.stories.js +4 -2
  39. package/dist/collection/stories/Templates/letterboard/letterboard.stories.js +1 -1
  40. package/dist/collection/stories/Templates/matchingCard/matching-card.stories.js +3 -1
  41. package/dist/collection/stories/Templates/multipleOption/mcqWithQuestionImage.stories.js +4 -2
  42. package/dist/collection/stories/Templates/multipleOption/multiple-option.stories.js +1 -1
  43. package/dist/collection/stories/Templates/multiplyBeeds/multiplyBeeds.stories.js +1 -1
  44. package/dist/collection/stories/Templates/nimbleTable/nimbleTable.stories.js +1 -1
  45. package/dist/collection/stories/Templates/numberBoard/numberBoard.stories.js +1 -1
  46. package/dist/collection/stories/Templates/numberBoardTwo/numberBoardTwo.stories.js +6 -4
  47. package/dist/collection/stories/Templates/numberPair/numberPair.stories.js +1 -1
  48. package/dist/collection/stories/Templates/openwindow/openwindow.stories.js +2 -2
  49. package/dist/collection/stories/Templates/openwindow/openwindow2.stories.js +2 -2
  50. package/dist/collection/stories/Templates/order-tractor/order-tractor-ascending-order.stories.js +14 -13
  51. package/dist/collection/stories/Templates/order-tractor/order-tractor.stories.js +14 -13
  52. package/dist/collection/stories/Templates/phonic-tractor/phonic-tractor.stories.js +1 -1
  53. package/dist/collection/stories/Templates/picturemeaning/pictureMeaningCocos.stories.js +5 -1
  54. package/dist/collection/stories/Templates/questionBoard/questionBoard.stories.js +1 -1
  55. package/dist/collection/stories/Templates/quizLiteracy/quizLiteracy.stories.js +1 -1
  56. package/dist/collection/stories/Templates/quizLiteracy/quizLiteracyImageWithText.stories.js +1 -1
  57. package/dist/collection/stories/Templates/quizLiteracy/quizLiteracyImageWord.stories.js +1 -1
  58. package/dist/collection/stories/Templates/reorder/reorder.stories.js +3 -1
  59. package/dist/collection/stories/Templates/rowBlocks/rowBlocks.stories.js +2 -2
  60. package/dist/collection/stories/Templates/sequenceBox/sequenceBox1.stories.js +6 -6
  61. package/dist/collection/stories/Templates/sequenceBox/sequenceBox2.stories.js +7 -6
  62. package/dist/collection/stories/Templates/shapePair/shape-pair.stories.js +1 -1
  63. package/dist/collection/stories/Templates/shapeTractor/shape-tractor.stories.js +25 -21
  64. package/dist/collection/stories/Templates/spellDoor/spellDoor.stories.js +1 -1
  65. package/dist/collection/stories/Templates/sumTogether/sumTogether.stories.js +8 -6
  66. package/dist/collection/stories/Templates/total/total.stories.js +1 -1
  67. package/dist/collection/stories/Templates/writeCard/writeCard.stories.js +1 -1
  68. package/dist/collection/stories/Templates/writeLetter/writeLetter.stories.js +2 -2
  69. package/dist/collection/stories/Templates/writeNumber/writeNumber.stories.js +6 -6
  70. package/dist/collection/stories/Templates/writeSet/writeSet.stories.js +1 -1
  71. package/dist/collection/stories/Templates/writeWord/writeWord.stories.js +7 -6
  72. package/dist/collection/utils/utils.js +155 -27
  73. package/dist/collection/utils/utilsHandlers/animationHandler.js +38 -0
  74. package/dist/collection/utils/utilsHandlers/clickHandler.js +5 -1
  75. package/dist/collection/utils/utilsHandlers/dragDropHandler.js +29 -64
  76. package/dist/collection/utils/utilsHandlers/slideHandler.js +7 -6
  77. package/dist/collection/utils/utilsHandlers/sortHandler.js +3 -5
  78. package/dist/components/index.js +1 -1
  79. package/dist/components/lido-avatar.js +1 -1
  80. package/dist/components/lido-balance.js +1 -1
  81. package/dist/components/lido-calculator.js +1 -1
  82. package/dist/components/lido-canvas.js +2 -2
  83. package/dist/components/lido-cell.js +1 -1
  84. package/dist/components/lido-col.js +1 -1
  85. package/dist/components/lido-container.js +1 -1
  86. package/dist/components/lido-flash-card.js +1 -1
  87. package/dist/components/lido-float.js +1 -1
  88. package/dist/components/lido-home.js +1 -1
  89. package/dist/components/lido-image.js +1 -1
  90. package/dist/components/lido-keyboard.js +1 -1
  91. package/dist/components/lido-math-matrix.js +1 -1
  92. package/dist/components/lido-pos.js +1 -1
  93. package/dist/components/lido-random.js +1 -1
  94. package/dist/components/lido-root.js +23 -23
  95. package/dist/components/lido-row.js +1 -1
  96. package/dist/components/lido-shape.js +1 -1
  97. package/dist/components/lido-slide-fill.js +1 -1
  98. package/dist/components/lido-text.js +1 -1
  99. package/dist/components/lido-trace.js +1 -1
  100. package/dist/components/lido-wrap.js +1 -1
  101. package/dist/components/{p-56c8f3da.js → p-004adc43.js} +3 -3
  102. package/dist/components/{p-c8815e84.js → p-057fb7b8.js} +48 -24
  103. package/dist/components/{p-bb907e43.js → p-0733b277.js} +2 -2
  104. package/dist/components/{p-6ba0f1af.js → p-09b3b152.js} +1 -1
  105. package/dist/components/{p-74b90a9c.js → p-23549651.js} +8 -8
  106. package/dist/components/{p-d7693f47.js → p-3e8ae1c5.js} +123 -48
  107. package/dist/components/{p-6be6c5eb.js → p-3f0e4436.js} +2 -2
  108. package/dist/components/{p-d0131159.js → p-511377d2.js} +236 -102
  109. package/dist/components/{p-a8724f06.js → p-561908ec.js} +2 -2
  110. package/dist/components/{p-1c84cf65.js → p-567983a9.js} +13 -7
  111. package/dist/components/{p-b89371ac.js → p-6beee44b.js} +1 -1
  112. package/dist/components/{p-1f3c2783.js → p-71ded596.js} +2 -2
  113. package/dist/components/{p-0fbeb3a1.js → p-73e3f0f4.js} +12 -6
  114. package/dist/components/{p-b7efadad.js → p-875c1411.js} +2 -2
  115. package/dist/components/{p-4fd6b588.js → p-8774f517.js} +2 -2
  116. package/dist/components/{p-04e904b5.js → p-90f7dd48.js} +1 -1
  117. package/dist/components/{p-caa05d1e.js → p-92b9ae9e.js} +2 -2
  118. package/dist/components/{p-e9548986.js → p-9ea1a67d.js} +26 -4
  119. package/dist/components/{p-bef96764.js → p-b3e67e7f.js} +2 -2
  120. package/dist/components/{p-988477ad.js → p-cca545f9.js} +2 -2
  121. package/dist/components/{p-d3f7d561.js → p-d2fe2bb6.js} +2 -2
  122. package/dist/components/{p-12432f23.js → p-d568d595.js} +1 -1
  123. package/dist/components/{p-62d2a5b3.js → p-df1af62c.js} +2 -2
  124. package/dist/esm/index.js +1 -1
  125. package/dist/esm/lido-avatar_22.entry.js +199 -73
  126. package/dist/esm/lido-player.js +1 -1
  127. package/dist/esm/loader.js +1 -1
  128. package/dist/esm/{utils-b5eb2360.js → utils-eefe4a1c.js} +236 -102
  129. package/dist/lido-player/index.esm.js +1 -1
  130. package/dist/lido-player/lido-player.esm.js +1 -1
  131. package/dist/lido-player/p-4d9ad047.entry.js +1 -0
  132. package/dist/lido-player/{p-9fd87d44.js → p-589fc3b8.js} +2 -2
  133. package/dist/types/components/canvas/lido-canvas.d.ts +1 -1
  134. package/dist/types/components/container/lido-container.d.ts +1 -0
  135. package/dist/types/components/home/lido-home.d.ts +1 -0
  136. package/dist/types/components/mathMatrix/lido-math-matrix.d.ts +0 -1
  137. package/dist/types/components/trace/lido-trace.d.ts +1 -0
  138. package/dist/types/components.d.ts +0 -6
  139. package/dist/types/stories/Templates/blender/blender.stories.d.ts +4 -0
  140. package/dist/types/utils/utils.d.ts +1 -1
  141. package/dist/types/utils/utilsHandlers/animationHandler.d.ts +1 -0
  142. package/package.json +1 -1
  143. package/dist/lido-player/p-e1a9c26f.entry.js +0 -1
@@ -1,4 +1,4 @@
1
- import { p as proxyCustomElement, H, V as TraceMode, e as convertUrlToRelative, d as setVisibilityWithDelay, W as speakIcon, o as executeActions, O as triggerNextContainer, L as LidoContainer, k as parseProp, h, j as Host, X as fingerUrl } from './p-d0131159.js';
1
+ import { p as proxyCustomElement, H, W as TraceMode, e as convertUrlToRelative, d as setVisibilityWithDelay, X as speakIcon, o as executeActions, J as triggerNextContainer, L as LidoContainer, k as parseProp, h, j as Host, Y as fingerUrl } from './p-511377d2.js';
2
2
 
3
3
  const lidoTraceCss = ":host{display:block;position:relative}#lido-svgContainer{display:flex;justify-content:center;align-items:center;overflow:hidden}svg{width:100%;height:100%;touch-action:none}#lido-draggableCircle{cursor:pointer;fill:#CF1565;transition:fill 0.2s, r 0.2s}.lido-blindTracing{stroke:none !important}.lido-blindFreeTrace{stroke:none !important}.lido-hovered{cursor:grab;fill:darkred}#lido-controls{position:fixed;bottom:0;left:0;right:0;display:flex;justify-content:space-between;padding:10px;background-color:#f0f0f0;border-top:1px solid #ccc}button{padding:10px;font-size:16px}@media (max-width: 600px){button{padding:8px;font-size:14px}}.lido-trace-path-green{}.lido-flow-indicator{stroke:blue;stroke-width:2;stroke-dasharray:6, 6;fill:none}.lido-trace{height:700px;width:700px;z-index:1;justify-items:center;align-content:center}.trace-animate{animation:trace-bounce 0.5s}@keyframes trace-bounce{0%{transform:scale(1)}30%{transform:scale(1.05)}60%{transform:scale(0.95)}100%{transform:scale(1)}}";
4
4
  const LidoTraceStyle0 = lidoTraceCss;
@@ -36,6 +36,7 @@ const LidoTrace = /*@__PURE__*/ proxyCustomElement(class LidoTrace extends H {
36
36
  this.fileIndex = -1;
37
37
  this.isDragging = false;
38
38
  this.activePointerId = null;
39
+ this.freeTraceUpdateCounter = 0;
39
40
  this.idleTimer = null;
40
41
  this.fingerImg = null;
41
42
  }
@@ -52,8 +53,8 @@ const LidoTrace = /*@__PURE__*/ proxyCustomElement(class LidoTrace extends H {
52
53
  circle: null,
53
54
  paths: [],
54
55
  svg: null,
55
- proximityThreshold: 100, // General proximity threshold
56
- freeTraceProximityThreshold: 50, // Reduced proximity threshold for free trace
56
+ proximityThreshold: 375, // Increased general proximity threshold (was 100)
57
+ freeTraceProximityThreshold: 350, // Increased proximity for free trace (was 50)
57
58
  rafId: null,
58
59
  pointerMoveEvent: null,
59
60
  activePointerId: null,
@@ -389,7 +390,7 @@ const LidoTrace = /*@__PURE__*/ proxyCustomElement(class LidoTrace extends H {
389
390
  }
390
391
  // Modified handlePointerMove function
391
392
  handlePointerMove(state) {
392
- var _a, _b, _c, _d;
393
+ var _a, _b, _c, _d, _e, _f;
393
394
  if (!state.isDragging)
394
395
  return;
395
396
  if (!state.circle || !state.paths || state.paths.length === 0)
@@ -401,6 +402,15 @@ const LidoTrace = /*@__PURE__*/ proxyCustomElement(class LidoTrace extends H {
401
402
  x: parseFloat(state.circle.getAttribute('cx')),
402
403
  y: parseFloat(state.circle.getAttribute('cy')),
403
404
  };
405
+ // Only update if pointer moved a minimum distance (to reduce unnecessary updates)
406
+ const MOVE_THRESHOLD = 1; // px
407
+ if (state.lastPointerPos) {
408
+ const dx = pointerPos.x - state.lastPointerPos.x;
409
+ const dy = pointerPos.y - state.lastPointerPos.y;
410
+ if (dx * dx + dy * dy < MOVE_THRESHOLD * MOVE_THRESHOLD) {
411
+ return;
412
+ }
413
+ }
404
414
  const currentPath = state.paths[state.currentPathIndex];
405
415
  if (!currentPath) {
406
416
  console.error('No valid path found at the current index');
@@ -428,48 +438,76 @@ const LidoTrace = /*@__PURE__*/ proxyCustomElement(class LidoTrace extends H {
428
438
  }
429
439
  // For free trace mode and blind free trace mode, allow free drawing only if within the reduced proximity threshold
430
440
  if (state.mode === TraceMode.FreeTrace || state.mode === TraceMode.BlindFreeTrace) {
441
+ // Throttle: Only update every 2nd event (for reducing excessive dom updates)
442
+ this.freeTraceUpdateCounter = (this.freeTraceUpdateCounter || 0) + 1;
443
+ if (this.freeTraceUpdateCounter % 2 !== 0) {
444
+ return;
445
+ }
431
446
  // Initialize the currentFreePath array if it's not created
432
447
  if (!state.currentFreePath) {
433
448
  state.currentFreePath = [];
434
449
  }
435
- // Create a new path element if it's the first trace for the current path index
450
+ // Create a new polyline element if it's the first trace for the current path index
436
451
  if (!state.currentFreePath[state.currentPathIndex]) {
437
- const newPath = document.createElementNS('http://www.w3.org/2000/svg', 'path');
438
- // newPath.setAttribute('stroke', 'green');
452
+ const newPolyline = document.createElementNS('http://www.w3.org/2000/svg', 'polyline');
439
453
  const strokeWidth = state.paths[state.currentPathIndex].style['stroke-width'] || state.paths[state.currentPathIndex].getAttribute('stroke-width');
440
- newPath.setAttribute('stroke-width', strokeWidth);
441
- newPath.setAttribute('fill', 'none');
442
- newPath.setAttribute('stroke-linecap', 'round');
443
- newPath.setAttribute('stroke', 'lightgreen');
444
- // Start the new path at the current pointer position
445
- newPath.setAttribute('d', `M${pointerPos.x},${pointerPos.y}`);
446
- (_a = state.svg) === null || _a === void 0 ? void 0 : _a.appendChild(newPath);
447
- state.currentFreePath[state.currentPathIndex] = newPath;
454
+ newPolyline.setAttribute('stroke-width', strokeWidth);
455
+ newPolyline.setAttribute('fill', 'none');
456
+ newPolyline.setAttribute('stroke-linecap', 'round');
457
+ newPolyline.setAttribute('stroke', 'lightgreen');
458
+ newPolyline.setAttribute('points', `${pointerPos.x},${pointerPos.y}`);
459
+ (_a = state.svg) === null || _a === void 0 ? void 0 : _a.appendChild(newPolyline);
460
+ state.currentFreePath[state.currentPathIndex] = newPolyline;
461
+ // Store points array for this polyline
462
+ state.currentFreePolylinePoints = state.currentFreePolylinePoints || [];
463
+ state.currentFreePolylinePoints[state.currentPathIndex] = [
464
+ { x: pointerPos.x, y: pointerPos.y }
465
+ ];
448
466
  // Reset lastPointerPos for the new path
449
467
  state.lastPointerPos = pointerPos;
468
+ // Add a points counter to limit path growth
469
+ state.freeTracePointsCount = 1;
450
470
  }
451
- // Get the previous position to draw a smooth curve
452
- const previousPos = state.lastPointerPos || pointerPos;
453
- // Create a quadratic curve from the previous point to the current point
454
- const newPathData = state.currentFreePath[state.currentPathIndex].getAttribute('d');
455
- const midPointX = (previousPos.x + pointerPos.x) / 2;
456
- const midPointY = (previousPos.y + pointerPos.y) / 2;
457
- const updatedPathData = `${newPathData} Q ${previousPos.x},${previousPos.y} ${midPointX},${midPointY}`;
458
- // Update the path's 'd' attribute with the new curve
459
- state.currentFreePath[state.currentPathIndex].setAttribute('d', updatedPathData);
471
+ // Limit the number of points in the free trace path for performance
472
+ const MAX_FREE_TRACE_POINTS = 10;
473
+ state.freeTracePointsCount = (state.freeTracePointsCount || 1) + 1;
474
+ if (state.freeTracePointsCount > MAX_FREE_TRACE_POINTS) {
475
+ // If limit reached, skip adding more points
476
+ return;
477
+ }
478
+ // Add the new point to the polyline's points array
479
+ state.currentFreePolylinePoints = state.currentFreePolylinePoints || [];
480
+ let pointsArr = state.currentFreePolylinePoints[state.currentPathIndex] || [];
481
+ pointsArr.push({ x: pointerPos.x, y: pointerPos.y });
482
+ state.currentFreePolylinePoints[state.currentPathIndex] = pointsArr;
483
+ // Update the polyline's points attribute
484
+ const pointsStr = pointsArr.map(pt => `${pt.x},${pt.y}`).join(' ');
485
+ state.currentFreePath[state.currentPathIndex].setAttribute('points', pointsStr);
460
486
  // Move the draggable circle with the freehand trace
461
487
  state.circle.setAttribute('cx', pointerPos.x.toString());
462
488
  state.circle.setAttribute('cy', pointerPos.y.toString());
463
- // Make sure the red dot (circle) is always on top
464
- (_b = state.svg) === null || _b === void 0 ? void 0 : _b.appendChild(state.circle); // This moves the circle to the last child, making it the topmost
489
+ // Only re-append if not already children list
490
+ const childNodes = (_b = state.svg) === null || _b === void 0 ? void 0 : _b.childNodes;
491
+ let circleFound = false;
492
+ for (let i = 0; i < ((childNodes === null || childNodes === void 0 ? void 0 : childNodes.length) || 0); i++) {
493
+ const child = childNodes === null || childNodes === void 0 ? void 0 : childNodes.item(i);
494
+ if (child && child.tagName === 'circle') {
495
+ circleFound = true;
496
+ break; // No need to continue once found
497
+ }
498
+ }
499
+ // If not found, append the circle
500
+ if (!circleFound && state.circle) {
501
+ (_c = state.svg) === null || _c === void 0 ? void 0 : _c.appendChild(state.circle);
502
+ }
465
503
  // Update the last pointer position
466
504
  state.lastPointerPos = pointerPos;
467
- const currentPathLength = currentPath.getTotalLength();
468
- const distanceToEnd = currentPathLength - closestPoint.length;
469
- // If close to the end of the path, move to the next path
470
- if (distanceToEnd < 5) {
505
+ // For polyline, estimate the end by number of points (not path length)
506
+ if (pointsArr.length >= MAX_FREE_TRACE_POINTS) {
471
507
  this.moveToNextPath(state);
472
508
  state.currentFreePath[state.currentPathIndex] = null; // Reset free path for next path
509
+ state.currentFreePolylinePoints[state.currentPathIndex] = [];
510
+ state.freeTracePointsCount = 0;
473
511
  }
474
512
  // this.resetIdleTimer(state); // ← keep timer alive
475
513
  return; // Exit early since we're in free trace or blind free trace mode
@@ -477,24 +515,57 @@ const LidoTrace = /*@__PURE__*/ proxyCustomElement(class LidoTrace extends H {
477
515
  // In normal modes, allow movement and drawing only within the general proximity threshold
478
516
  if (state.isDragging && closestPoint.length >= state.lastLength) {
479
517
  state.lastLength = closestPoint.length;
480
- state.circle.setAttribute('cx', closestPoint.x.toString());
481
- state.circle.setAttribute('cy', closestPoint.y.toString());
482
- // Make sure the red dot (circle) is always on top
483
- (_c = state.svg) === null || _c === void 0 ? void 0 : _c.appendChild(state.circle); // This moves the circle to the last child, making it the topmost
484
- (_d = currentPath.greenPath) === null || _d === void 0 ? void 0 : _d.setAttribute('stroke-dashoffset', (state.totalPathLength - state.lastLength).toString());
485
- }
486
- // Check if the current path is completed
487
- if (state.totalPathLength - 1 - state.lastLength < 5 && state.currentPathIndex < state.paths.length - 1) {
488
- this.moveToNextPath(state);
489
- }
490
- else if (state.totalPathLength - 1 - state.lastLength < 5 && state.currentPathIndex === state.paths.length - 1) {
491
- // this.loadAnotherSVG(state, true);
492
- this.moveToNextContainer();
518
+ // Only update the circle if it moved enough
519
+ if (Math.abs(closestPoint.x - circlePos.x) > MOVE_THRESHOLD || Math.abs(closestPoint.y - circlePos.y) > MOVE_THRESHOLD) {
520
+ state.circle.setAttribute('cx', closestPoint.x.toString());
521
+ state.circle.setAttribute('cy', closestPoint.y.toString());
522
+ }
523
+ // Only re-append if not already children list
524
+ const childNodes = (_d = state.svg) === null || _d === void 0 ? void 0 : _d.childNodes;
525
+ let circleFound = false;
526
+ for (let i = 0; i < ((childNodes === null || childNodes === void 0 ? void 0 : childNodes.length) || 0); i++) {
527
+ const child = childNodes === null || childNodes === void 0 ? void 0 : childNodes.item(i);
528
+ if (child && child.tagName === 'circle') {
529
+ circleFound = true;
530
+ break; // No need to continue once found
531
+ }
532
+ }
533
+ // If not found, append the circle
534
+ if (!circleFound && state.circle) {
535
+ (_e = state.svg) === null || _e === void 0 ? void 0 : _e.appendChild(state.circle);
536
+ }
537
+ (_f = currentPath.greenPath) === null || _f === void 0 ? void 0 : _f.setAttribute('stroke-dashoffset', (state.totalPathLength - state.lastLength).toString());
538
+ // Completion logic for closed paths: only allow completion if almost all points are traced
539
+ const COMPLETION_THRESHOLD = 0.90; // 90% of the path must be traced
540
+ let percentComplete = state.lastLength / state.totalPathLength;
541
+ let startPoint = currentPath.getPointAtLength(0);
542
+ let endPoint = currentPath.getPointAtLength(currentPath.getTotalLength());
543
+ let pathIsClosed = this.getDistanceSquared(startPoint, endPoint) < 200; // threshold for overlap
544
+ if (pathIsClosed && state.totalPathLength > 50) {
545
+ if (percentComplete >= COMPLETION_THRESHOLD) {
546
+ if (state.currentPathIndex < state.paths.length - 1) {
547
+ this.moveToNextPath(state);
548
+ }
549
+ else if (state.currentPathIndex === state.paths.length - 1) {
550
+ this.moveToNextContainer();
551
+ }
552
+ }
553
+ }
554
+ else {
555
+ // For open paths, allow completion if near the end
556
+ if (state.totalPathLength - 1 - state.lastLength < 5 && state.currentPathIndex < state.paths.length - 1) {
557
+ this.moveToNextPath(state);
558
+ }
559
+ else if (state.totalPathLength - 1 - state.lastLength < 5 && state.currentPathIndex === state.paths.length - 1) {
560
+ this.moveToNextContainer();
561
+ }
562
+ }
493
563
  }
494
564
  // this.resetIdleTimer(state); // ← keep timer alive
495
565
  }
496
566
  // Move to the next container after completing the current SVG
497
567
  async moveToNextContainer() {
568
+ this.isDragging = false;
498
569
  if (this.moving)
499
570
  return; // Prevent multiple calls
500
571
  this.moving = true; // Set moving to true to prevent re-entrance
@@ -513,9 +584,12 @@ const LidoTrace = /*@__PURE__*/ proxyCustomElement(class LidoTrace extends H {
513
584
  this.moving = false;
514
585
  return;
515
586
  }
587
+ console.log('onCorrect:', this.onCorrect);
588
+ console.log('el :', this.el);
516
589
  if (this.el && this.onCorrect) {
517
590
  await executeActions(this.onCorrect, this.el);
518
591
  }
592
+ console.log('All SVGs completed, hiding component.');
519
593
  triggerNextContainer();
520
594
  }
521
595
  // Get the pointer position relative to the SVG
@@ -533,13 +607,13 @@ const LidoTrace = /*@__PURE__*/ proxyCustomElement(class LidoTrace extends H {
533
607
  const dy = p1.y - p2.y;
534
608
  return dx * dx + dy * dy;
535
609
  }
536
- // Find the closest point on the given path to the specified point using two-pass sampling
610
+ // Find the closest point on the given path to the specified point using two-pass sampling (optimized)
537
611
  getClosestPointOnPath(pathNode, point) {
538
612
  const pathLength = pathNode.getTotalLength();
539
613
  let closestPoint = { x: 0, y: 0, length: 0 };
540
614
  let minDistanceSquared = Infinity;
541
- // First pass: coarse sampling
542
- const coarseStep = 20; // Increased step for better performance
615
+ // Optimized: Increase coarse steps for better performance
616
+ const coarseStep = 40; // was 20
543
617
  let coarseClosestPoint = { x: 0, y: 0, length: 0 };
544
618
  let coarseMinDistanceSquared = Infinity;
545
619
  for (let i = 0; i <= pathLength; i += coarseStep) {
@@ -555,7 +629,7 @@ const LidoTrace = /*@__PURE__*/ proxyCustomElement(class LidoTrace extends H {
555
629
  }
556
630
  }
557
631
  // Second pass: fine sampling around coarseClosestPoint
558
- const fineStep = 2; // Increased step to reduce computations
632
+ const fineStep = 6; // was 2
559
633
  const searchStart = Math.max(coarseClosestPoint.length - coarseStep, 0);
560
634
  const searchEnd = Math.min(coarseClosestPoint.length + coarseStep, pathLength);
561
635
  for (let i = searchStart; i <= searchEnd; i += fineStep) {
@@ -715,7 +789,7 @@ const LidoTrace = /*@__PURE__*/ proxyCustomElement(class LidoTrace extends H {
715
789
  };
716
790
  }
717
791
  render() {
718
- return (h(Host, { key: 'b562e07d98a06f422ce5b8ca1d08f9c4307a313c', class: "lido-trace", id: this.id, audio: this.audio, onCorrect: this.onCorrect, onInCorrect: this.onInCorrect, style: this.style, "aria-label": this.ariaLabel, "aria-hidden": this.ariaHidden, tabindex: this.tabIndex, "disable-speak": this.disableSpeak }, h("div", { key: 'fc2cb8355a26e5b483c24c59641bd20fa37e853b', style: this.style, id: "lido-svgContainer" })));
792
+ return (h(Host, { key: '3f12119394502b6750874aaa50f43bf42e9f63cc', class: "lido-trace", id: this.id, audio: this.audio, onCorrect: this.onCorrect, onInCorrect: this.onInCorrect, style: this.style, "aria-label": this.ariaLabel, "aria-hidden": this.ariaHidden, tabindex: this.tabIndex, "disable-speak": this.disableSpeak }, h("div", { key: '4fddd90d12251c4020006690f8c769ab452c8f6a', style: this.style, id: "lido-svgContainer" })));
719
793
  }
720
794
  static get assetsDirs() { return ["svg", "images"]; }
721
795
  get el() { return this; }
@@ -754,6 +828,7 @@ const LidoTrace = /*@__PURE__*/ proxyCustomElement(class LidoTrace extends H {
754
828
  "fileIndex": [32],
755
829
  "isDragging": [32],
756
830
  "activePointerId": [32],
831
+ "freeTraceUpdateCounter": [32],
757
832
  "idleTimer": [32],
758
833
  "fingerImg": [32]
759
834
  }, undefined, {
@@ -1,4 +1,4 @@
1
- import { p as proxyCustomElement, H, i as initEventsForElement, q as handlingChildElements, r as attachSpeakIcon, e as convertUrlToRelative, k as parseProp, h, j as Host } from './p-d0131159.js';
1
+ import { p as proxyCustomElement, H, i as initEventsForElement, q as handlingChildElements, r as attachSpeakIcon, e as convertUrlToRelative, k as parseProp, h, j as Host } from './p-511377d2.js';
2
2
 
3
3
  const lidoColCss = ".lido-col{top:var(--y, 0);left:var(--x, 0);height:var(--height, 100%);width:var(--width, 100%);background-color:var(--bgColor, #eeeeee);padding:15px;border-radius:10px;display:flex;justify-content:space-around;flex-direction:column;align-items:center}.lido-col>*{}";
4
4
  const LidoColStyle0 = lidoColCss;
@@ -80,7 +80,7 @@ const LidoCol = /*@__PURE__*/ proxyCustomElement(class LidoCol extends H {
80
80
  };
81
81
  }
82
82
  render() {
83
- return (h(Host, { key: 'fe37cc1654101a3d347e2cef52872467ae078139', id: this.id, class: "lido-col", type: this.type, "tab-index": this.tabIndex, value: this.value, style: this.style, minDrops: this.minDrops, maxDrops: this.maxDrops, "aria-label": this.ariaLabel, "aria-hidden": this.ariaHidden, audio: this.audio, onTouch: this.onTouch, onCorrect: this.onCorrect, onInCorrect: this.onInCorrect, onEntry: this.onEntry }, h("slot", { key: 'b27f20f62c30398c343d7aa472a0a211af5eed0e' })));
83
+ return (h(Host, { key: '7845d3364dd13cb42959f67610254ee892119c39', id: this.id, class: "lido-col", type: this.type, "tab-index": this.tabIndex, value: this.value, style: this.style, minDrops: this.minDrops, maxDrops: this.maxDrops, "aria-label": this.ariaLabel, "aria-hidden": this.ariaHidden, audio: this.audio, onTouch: this.onTouch, onCorrect: this.onCorrect, onInCorrect: this.onInCorrect, onEntry: this.onEntry }, h("slot", { key: '09a68a30534c5ea83d7166acd720b4b8f23f494e' })));
84
84
  }
85
85
  get el() { return this; }
86
86
  static get style() { return LidoColStyle0; }