@jaak.ai/stamps 1.0.0 → 2.0.0-beta.2

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 (162) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +531 -457
  3. package/dist/cjs/index-DGM9-FNg.js +1402 -0
  4. package/dist/cjs/index-DGM9-FNg.js.map +1 -0
  5. package/dist/cjs/index.cjs.js +3 -0
  6. package/dist/cjs/index.cjs.js.map +1 -0
  7. package/dist/cjs/jaak-stamps-webcomponent.cjs.js +27 -0
  8. package/dist/cjs/jaak-stamps-webcomponent.cjs.js.map +1 -0
  9. package/dist/cjs/jaak-stamps.cjs.entry.js +1060 -0
  10. package/dist/cjs/jaak-stamps.cjs.entry.js.map +1 -0
  11. package/dist/cjs/jaak-stamps.entry.cjs.js.map +1 -0
  12. package/dist/cjs/loader.cjs.js +8 -15
  13. package/dist/cjs/loader.cjs.js.map +1 -0
  14. package/dist/collection/collection-manifest.json +3 -22
  15. package/dist/collection/components/my-component/my-component.css +530 -0
  16. package/dist/collection/components/my-component/my-component.js +1357 -0
  17. package/dist/collection/components/my-component/my-component.js.map +1 -0
  18. package/dist/collection/index.js +2 -1
  19. package/dist/collection/index.js.map +1 -0
  20. package/dist/collection/utils/utils.js +4 -0
  21. package/dist/collection/utils/utils.js.map +1 -0
  22. package/dist/components/index.d.ts +33 -0
  23. package/dist/components/index.js +1195 -0
  24. package/dist/components/index.js.map +1 -0
  25. package/dist/components/jaak-stamps.d.ts +11 -0
  26. package/dist/components/jaak-stamps.js +1109 -0
  27. package/dist/components/jaak-stamps.js.map +1 -0
  28. package/dist/esm/index-DqoVMnc7.js +1393 -0
  29. package/dist/esm/index-DqoVMnc7.js.map +1 -0
  30. package/dist/esm/index.js +3 -0
  31. package/dist/esm/index.js.map +1 -0
  32. package/dist/esm/jaak-stamps-webcomponent.js +23 -0
  33. package/dist/esm/jaak-stamps-webcomponent.js.map +1 -0
  34. package/dist/esm/jaak-stamps.entry.js +1058 -0
  35. package/dist/esm/jaak-stamps.entry.js.map +1 -0
  36. package/dist/esm/loader.js +9 -14
  37. package/dist/esm/loader.js.map +1 -0
  38. package/dist/jaak-stamps-webcomponent/index.esm.js +2 -0
  39. package/dist/jaak-stamps-webcomponent/index.esm.js.map +1 -0
  40. package/dist/jaak-stamps-webcomponent/jaak-stamps-webcomponent.esm.js +2 -0
  41. package/dist/jaak-stamps-webcomponent/jaak-stamps-webcomponent.esm.js.map +1 -0
  42. package/dist/jaak-stamps-webcomponent/jaak-stamps.entry.esm.js.map +1 -0
  43. package/dist/jaak-stamps-webcomponent/loader.esm.js.map +1 -0
  44. package/dist/jaak-stamps-webcomponent/p-DqoVMnc7.js +3 -0
  45. package/dist/jaak-stamps-webcomponent/p-DqoVMnc7.js.map +1 -0
  46. package/dist/jaak-stamps-webcomponent/p-f1172b06.entry.js +2 -0
  47. package/dist/jaak-stamps-webcomponent/p-f1172b06.entry.js.map +1 -0
  48. package/dist/types/components/my-component/my-component.d.ts +131 -0
  49. package/dist/types/components.d.ts +62 -1370
  50. package/dist/types/index.d.ts +10 -1
  51. package/dist/types/stencil-public-runtime.d.ts +93 -28
  52. package/dist/types/utils/utils.d.ts +1 -0
  53. package/loader/cdn.js +1 -3
  54. package/loader/index.cjs.js +1 -3
  55. package/loader/index.d.ts +5 -2
  56. package/loader/index.es2017.js +1 -3
  57. package/loader/index.js +1 -3
  58. package/package.json +22 -26
  59. package/dist/cjs/document-detector_19.cjs.entry.js +0 -8630
  60. package/dist/cjs/index-5e4e5e7d.js +0 -1685
  61. package/dist/cjs/mb-tooltip.cjs.entry.js +0 -26
  62. package/dist/cjs/stamps.cjs.js +0 -23
  63. package/dist/collection/components/document-detector/document-detector.css +0 -156
  64. package/dist/collection/components/document-detector/document-detector.js +0 -504
  65. package/dist/collection/components/shared/mb-api-process-status/mb-api-process-status.css +0 -360
  66. package/dist/collection/components/shared/mb-api-process-status/mb-api-process-status.js +0 -124
  67. package/dist/collection/components/shared/mb-button/mb-button.css +0 -95
  68. package/dist/collection/components/shared/mb-button/mb-button.js +0 -201
  69. package/dist/collection/components/shared/mb-button-classic/mb-button-classic.css +0 -100
  70. package/dist/collection/components/shared/mb-button-classic/mb-button-classic.js +0 -130
  71. package/dist/collection/components/shared/mb-camera-experience/mb-camera-experience.css +0 -740
  72. package/dist/collection/components/shared/mb-camera-experience/mb-camera-experience.js +0 -827
  73. package/dist/collection/components/shared/mb-camera-experience/mb-camera-experience.utils.js +0 -55
  74. package/dist/collection/components/shared/mb-camera-selection/mb-camera-selection.css +0 -124
  75. package/dist/collection/components/shared/mb-camera-selection/mb-camera-selection.js +0 -194
  76. package/dist/collection/components/shared/mb-camera-toolbar/mb-camera-toolbar.css +0 -80
  77. package/dist/collection/components/shared/mb-camera-toolbar/mb-camera-toolbar.js +0 -275
  78. package/dist/collection/components/shared/mb-completed/mb-completed.css +0 -17
  79. package/dist/collection/components/shared/mb-completed/mb-completed.js +0 -48
  80. package/dist/collection/components/shared/mb-component/mb-component.css +0 -321
  81. package/dist/collection/components/shared/mb-component/mb-component.js +0 -2294
  82. package/dist/collection/components/shared/mb-component/mb-component.utils.js +0 -14
  83. package/dist/collection/components/shared/mb-container/mb-container.css +0 -7
  84. package/dist/collection/components/shared/mb-container/mb-container.js +0 -23
  85. package/dist/collection/components/shared/mb-feedback/mb-feedback.css +0 -36
  86. package/dist/collection/components/shared/mb-feedback/mb-feedback.js +0 -91
  87. package/dist/collection/components/shared/mb-feedback/mb-feedback.utils.js +0 -11
  88. package/dist/collection/components/shared/mb-help/mb-help.css +0 -191
  89. package/dist/collection/components/shared/mb-help/mb-help.js +0 -409
  90. package/dist/collection/components/shared/mb-help/mb-help.model.js +0 -5
  91. package/dist/collection/components/shared/mb-image-box/mb-image-box.css +0 -78
  92. package/dist/collection/components/shared/mb-image-box/mb-image-box.js +0 -150
  93. package/dist/collection/components/shared/mb-modal/mb-modal.css +0 -106
  94. package/dist/collection/components/shared/mb-modal/mb-modal.js +0 -239
  95. package/dist/collection/components/shared/mb-overlay/mb-overlay.css +0 -46
  96. package/dist/collection/components/shared/mb-overlay/mb-overlay.js +0 -76
  97. package/dist/collection/components/shared/mb-progress-tracker/mb-progress-tracker.css +0 -24
  98. package/dist/collection/components/shared/mb-progress-tracker/mb-progress-tracker.js +0 -80
  99. package/dist/collection/components/shared/mb-screen/mb-screen.css +0 -19
  100. package/dist/collection/components/shared/mb-screen/mb-screen.js +0 -48
  101. package/dist/collection/components/shared/mb-spinner/mb-spinner.css +0 -30
  102. package/dist/collection/components/shared/mb-spinner/mb-spinner.js +0 -67
  103. package/dist/collection/components/shared/mb-tooltip/mb-tooltip.css +0 -62
  104. package/dist/collection/components/shared/mb-tooltip/mb-tooltip.js +0 -150
  105. package/dist/collection/components/shared/mb-tooltip-advanced/mb-tooltip-advanced.css +0 -91
  106. package/dist/collection/components/shared/mb-tooltip-advanced/mb-tooltip-advanced.js +0 -96
  107. package/dist/collection/utils/data-structures.js +0 -189
  108. package/dist/collection/utils/device.helpers.js +0 -37
  109. package/dist/collection/utils/error-structures.js +0 -47
  110. package/dist/collection/utils/generic.helpers.js +0 -82
  111. package/dist/collection/utils/sdk.service.js +0 -943
  112. package/dist/collection/utils/state-lifter.js +0 -3
  113. package/dist/collection/utils/status.document-detector.js +0 -15
  114. package/dist/collection/utils/translation.service.js +0 -97
  115. package/dist/esm/document-detector_19.entry.js +0 -8608
  116. package/dist/esm/index-dc740acb.js +0 -1656
  117. package/dist/esm/mb-tooltip.entry.js +0 -22
  118. package/dist/esm/polyfills/core-js.js +0 -11
  119. package/dist/esm/polyfills/css-shim.js +0 -1
  120. package/dist/esm/polyfills/dom.js +0 -79
  121. package/dist/esm/polyfills/es5-html-element.js +0 -1
  122. package/dist/esm/polyfills/index.js +0 -34
  123. package/dist/esm/polyfills/system.js +0 -6
  124. package/dist/esm/stamps.js +0 -18
  125. package/dist/stamps/index.esm.js +0 -0
  126. package/dist/stamps/p-7f07a434.js +0 -2
  127. package/dist/stamps/p-ae1d9117.entry.js +0 -9
  128. package/dist/stamps/p-ec3f5972.entry.js +0 -1
  129. package/dist/stamps/stamps.esm.js +0 -1
  130. package/dist/types/components/document-detector/document-detector.d.ts +0 -103
  131. package/dist/types/components/shared/mb-api-process-status/mb-api-process-status.d.ts +0 -30
  132. package/dist/types/components/shared/mb-button/mb-button.d.ts +0 -41
  133. package/dist/types/components/shared/mb-button-classic/mb-button-classic.d.ts +0 -27
  134. package/dist/types/components/shared/mb-camera-experience/mb-camera-experience.d.ts +0 -141
  135. package/dist/types/components/shared/mb-camera-experience/mb-camera-experience.utils.d.ts +0 -3
  136. package/dist/types/components/shared/mb-camera-selection/mb-camera-selection.d.ts +0 -33
  137. package/dist/types/components/shared/mb-camera-toolbar/mb-camera-toolbar.d.ts +0 -54
  138. package/dist/types/components/shared/mb-completed/mb-completed.d.ts +0 -12
  139. package/dist/types/components/shared/mb-component/mb-component.d.ts +0 -310
  140. package/dist/types/components/shared/mb-component/mb-component.utils.d.ts +0 -3
  141. package/dist/types/components/shared/mb-container/mb-container.d.ts +0 -8
  142. package/dist/types/components/shared/mb-feedback/mb-feedback.d.ts +0 -19
  143. package/dist/types/components/shared/mb-feedback/mb-feedback.utils.d.ts +0 -2
  144. package/dist/types/components/shared/mb-help/mb-help.d.ts +0 -66
  145. package/dist/types/components/shared/mb-help/mb-help.model.d.ts +0 -9
  146. package/dist/types/components/shared/mb-image-box/mb-image-box.d.ts +0 -35
  147. package/dist/types/components/shared/mb-modal/mb-modal.d.ts +0 -53
  148. package/dist/types/components/shared/mb-overlay/mb-overlay.d.ts +0 -17
  149. package/dist/types/components/shared/mb-progress-tracker/mb-progress-tracker.d.ts +0 -19
  150. package/dist/types/components/shared/mb-screen/mb-screen.d.ts +0 -12
  151. package/dist/types/components/shared/mb-spinner/mb-spinner.d.ts +0 -16
  152. package/dist/types/components/shared/mb-tooltip/mb-tooltip.d.ts +0 -10
  153. package/dist/types/components/shared/mb-tooltip-advanced/mb-tooltip-advanced.d.ts +0 -7
  154. package/dist/types/utils/data-structures.d.ts +0 -264
  155. package/dist/types/utils/device.helpers.d.ts +0 -7
  156. package/dist/types/utils/error-structures.d.ts +0 -44
  157. package/dist/types/utils/generic.helpers.d.ts +0 -21
  158. package/dist/types/utils/sdk.service.d.ts +0 -52
  159. package/dist/types/utils/state-lifter.d.ts +0 -3
  160. package/dist/types/utils/status.document-detector.d.ts +0 -14
  161. package/dist/types/utils/translation.service.d.ts +0 -77
  162. package/loader/package.json +0 -11
@@ -0,0 +1,1058 @@
1
+ import { r as registerInstance, c as createEvent, a as getElement, h } from './index-DqoVMnc7.js';
2
+
3
+ const myComponentCss = ":host{display:block;width:100%;height:100%;font-family:system-ui, -apple-system, sans-serif;color:#1a1a1a}.detector-container{display:flex;flex-direction:column;align-items:center;width:100%;height:100%}h1{font-size:24px;font-weight:500;color:#333;margin:0 0 24px 0}.video-container{position:relative;width:100%;height:100%;background:#333;border:1px solid #e0e0e0;border-radius:8px;overflow:hidden}video,canvas{position:absolute;width:100%;height:100%;border-radius:8px}video.mirror,canvas.mirror{transform:rotateY(180deg)}canvas{z-index:1}video{z-index:0}.status{margin-top:16px;font-size:12px;color:#666}.overlay-mask{position:absolute;top:0;left:0;width:100%;height:100%;z-index:10;display:block;pointer-events:none}.card-outline{position:absolute;top:var(--mask-center-y, 50%);left:var(--mask-center-x, 50%);transform:translate(-50%, -50%);width:var(--mask-width, 88%);height:var(--mask-height, 55%);border:none;border-radius:4px;background:transparent;box-shadow:0 0 0 9999px rgba(0, 0, 0, 0.7);opacity:0.8}.card-outline.perfect-match{box-shadow:0 0 0 9999px rgba(0, 0, 0, 0.7)}.side{position:absolute;background:#999;transition:background-color 0.3s ease}.side.aligned{background:#28a745}.side-top{top:0;left:0;width:100%;height:3px}.side-right{top:0;right:0;width:3px;height:100%}.side-bottom{bottom:0;left:0;width:100%;height:3px}.side-left{top:0;left:0;width:3px;height:100%}.corner{position:absolute;width:20px;height:20px;border:2px solid #999;z-index:12}.corner-tl{top:-10px;left:-10px;border-right:none;border-bottom:none}.corner-tr{top:-10px;right:-10px;border-left:none;border-bottom:none}.corner-bl{bottom:-10px;left:-10px;border-right:none;border-top:none}.corner-br{bottom:-10px;right:-10px;border-left:none;border-top:none}.corner.perfect-match{border-color:#28a745}.guide-text{position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);color:#fff;font-size:14px;font-weight:600;text-align:center;white-space:normal;background:rgba(128, 128, 128, 0.8);padding:12px 20px;border-radius:20px;max-width:300px;z-index:20}.capture-animation{position:absolute;top:0;left:0;width:100%;height:100%;background:#fff;opacity:0;z-index:30;pointer-events:none;animation:captureFlash 0.6s ease-out}@keyframes captureFlash{0%{opacity:0}15%{opacity:0.8}30%{opacity:0}45%{opacity:0.4}60%{opacity:0}100%{opacity:0}}.card-outline.capturing{animation:pulseGreen 0.6s ease-out}@keyframes pulseGreen{0%{border-color:#28a745;box-shadow:0 0 0 9999px rgba(0, 0, 0, 0.7), 0 0 0 4px rgba(40, 167, 69, 0)}50%{border-color:#28a745;box-shadow:0 0 0 9999px rgba(0, 0, 0, 0.7), 0 0 0 8px rgba(40, 167, 69, 0.6)}100%{border-color:#28a745;box-shadow:0 0 0 9999px rgba(0, 0, 0, 0.7), 0 0 0 4px rgba(40, 167, 69, 0)}}.flip-animation{position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);z-index:35;pointer-events:none;opacity:0;animation:showFlipInstruction 3s ease-in-out;display:flex;flex-direction:column;align-items:center;justify-content:center}.id-card-icon{width:80px;height:50px;background:linear-gradient(135deg, #6c757d 0%, #495057 100%);border-radius:8px;position:relative;animation:flipCard 2s ease-in-out infinite;box-shadow:0 4px 12px rgba(0, 0, 0, 0.3)}.id-card-icon::before{content:'';position:absolute;top:8px;left:8px;width:16px;height:12px;background:rgba(255, 255, 255, 0.9);border-radius:2px}.id-card-icon::after{content:'';position:absolute;top:25px;left:8px;width:64px;height:3px;background:rgba(255, 255, 255, 0.7);border-radius:1px;box-shadow:0 6px 0 rgba(255, 255, 255, 0.7), 0 12px 0 rgba(255, 255, 255, 0.7)}.flip-text{margin-top:12px;color:#fff;font-size:14px;font-weight:600;text-align:center;background:rgba(128, 128, 128, 0.8);padding:12px 20px;border-radius:20px;max-width:300px}@keyframes showFlipInstruction{0%{opacity:0;transform:translate(-50%, -50%) scale(0.8)}15%{opacity:1;transform:translate(-50%, -50%) scale(1)}85%{opacity:1;transform:translate(-50%, -50%) scale(1)}100%{opacity:0;transform:translate(-50%, -50%) scale(0.8)}}@keyframes flipCard{0%{transform:rotateY(0deg)}50%{transform:rotateY(180deg)}100%{transform:rotateY(360deg)}}.success-animation{position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);z-index:35;pointer-events:none;opacity:0;animation:showSuccessMessage 3s ease-in-out;display:flex;flex-direction:column;align-items:center;justify-content:center}.check-icon{width:80px;height:80px;background:linear-gradient(135deg, #6c757d 0%, #495057 100%);border-radius:50%;position:relative;animation:bounceSuccess 0.6s ease-out;box-shadow:0 4px 16px rgba(108, 117, 125, 0.4);display:flex;align-items:center;justify-content:center}.check-icon::before{content:'';position:absolute;width:20px;height:35px;border:4px solid #fff;border-top:none;border-left:none;transform:rotate(45deg);animation:drawCheck 0.4s ease-out 0.2s both}.success-text{margin-top:16px;color:#fff;font-size:14px;font-weight:600;text-align:center;background:rgba(128, 128, 128, 0.8);padding:12px 20px;border-radius:20px;max-width:300px;animation:fadeInUp 0.5s ease-out 0.4s both}@keyframes showSuccessMessage{0%{opacity:0;transform:translate(-50%, -50%) scale(0.5)}15%{opacity:1;transform:translate(-50%, -50%) scale(1)}85%{opacity:1;transform:translate(-50%, -50%) scale(1)}100%{opacity:0;transform:translate(-50%, -50%) scale(0.9)}}@keyframes bounceSuccess{0%{transform:scale(0)}50%{transform:scale(1.1)}100%{transform:scale(1)}}@keyframes drawCheck{0%{width:0;height:0}50%{width:20px;height:0}100%{width:20px;height:35px}}@keyframes fadeInUp{0%{opacity:0;transform:translateY(20px)}100%{opacity:1;transform:translateY(0)}}.skip-button{position:absolute;bottom:20px;left:50%;transform:translateX(-50%);z-index:25;pointer-events:auto;background:#fff;color:#333;border:none;border-radius:25px;padding:12px 24px;font-size:14px;font-weight:600;cursor:pointer;transition:all 0.3s ease}.skip-button:hover{background:#f8f9fa}.skip-button:active{background:#e9ecef;transform:translateX(-50%) translateY(0)}.watermark{position:absolute;bottom:12px;right:12px;z-index:15;pointer-events:none;opacity:0.7}.watermark img{height:24px;width:auto;filter:drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3))}.loading-overlay{position:absolute;top:0;left:0;width:100%;height:100%;background:rgba(0, 0, 0, 0.8);display:flex;flex-direction:column;align-items:center;justify-content:center;z-index:30;border-radius:20px}.loading-spinner{width:60px;height:60px;border:4px solid rgba(255, 255, 255, 0.2);border-top:4px solid #007bff;border-radius:50%;animation:spin 1s linear infinite;margin-bottom:20px}.loading-text{color:white;font-size:16px;font-weight:500;text-align:center;opacity:0.9}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}";
4
+
5
+ const JaakStamps = class {
6
+ constructor(hostRef) {
7
+ registerInstance(this, hostRef);
8
+ this.captureCompleted = createEvent(this, "captureCompleted");
9
+ this.isReady = createEvent(this, "isReady");
10
+ }
11
+ get el() { return getElement(this); }
12
+ debug = false;
13
+ alignmentTolerance = 10; // Tolerancia en píxeles para considerar un lado alineado (escalado para 320x320)
14
+ maskSize = 90; // Porcentaje del video que ocupará la máscara (default 90%)
15
+ cropMargin = 0; // Margen en píxeles para el recorte del documento (default 0)
16
+ useDocumentClassification = false; // Habilita la clasificación automática de documentos para determinar si solicitar reverso
17
+ captureCompleted;
18
+ isReady;
19
+ isVideoActive = false;
20
+ statusMessage = 'Presione el botón para activar la cámara';
21
+ statusColor = '#aaa';
22
+ bestScore = 0;
23
+ capturedFullFrame = null;
24
+ capturedCroppedId = null;
25
+ capturedBackFullFrame = null;
26
+ capturedBackCroppedId = null;
27
+ captureStep = 'front';
28
+ isCapturing = false;
29
+ showFlipAnimation = false;
30
+ showSuccessAnimation = false;
31
+ shouldMirrorVideo = true;
32
+ sideAlignment = {
33
+ top: false,
34
+ right: false,
35
+ bottom: false,
36
+ left: false
37
+ };
38
+ isDetectionPaused = false;
39
+ isLoading = false;
40
+ isModelPreloaded = false;
41
+ isMaskReady = false;
42
+ videoRef;
43
+ canvasRef;
44
+ session;
45
+ startTime;
46
+ videoStream;
47
+ animationId;
48
+ hasScreenshotTaken = false;
49
+ lastDetectedBox;
50
+ mobileNetSession;
51
+ mobileNetClassMap;
52
+ // Performance optimization properties
53
+ frameSkipCounter = 0;
54
+ FRAME_SKIP = 2; // Process every 3rd frame (reduces CPU by ~66%)
55
+ consecutiveFailures = 0;
56
+ MAX_FAILURES = 30; // 0.5 seconds without detection
57
+ lastInferenceTime = 0;
58
+ MIN_INFERENCE_INTERVAL = 50; // Minimum 50ms between inferences
59
+ // Canvas pooling for memory optimization
60
+ preprocessCanvas;
61
+ preprocessCtx;
62
+ captureCanvas;
63
+ captureCtx;
64
+ MODEL_PATH = "https://storage.googleapis.com/jaak-static/web/component/stamps/ddmyp-v1.onnx";
65
+ MOBILENET_MODEL_PATH = "https://storage.googleapis.com/jaak-static/web/component/stamps/cdmmp-v1.onnx";
66
+ MOBILENET_CLASSES_PATH = "https://storage.googleapis.com/jaak-static/web/component/stamps/cdmmp-v1.json";
67
+ INPUT_SIZE = 320;
68
+ CONFIDENCE_THRESHOLD = 0.6;
69
+ // ISO/IEC 7810 ID-1 standard dimensions (85.60mm x 53.98mm)
70
+ ID1_ASPECT_RATIO = 85.60 / 53.98; // 1.5863320574...
71
+ debugLog(...args) {
72
+ if (this.debug) {
73
+ console.log(...args);
74
+ }
75
+ }
76
+ validateMaskSize() {
77
+ if (this.maskSize < 50 || this.maskSize > 100) {
78
+ console.warn(`maskSize debe estar entre 50 y 100. Valor actual: ${this.maskSize}. Usando valor por defecto: 90`);
79
+ this.maskSize = 90;
80
+ }
81
+ }
82
+ validateCropMargin() {
83
+ if (this.cropMargin < 0 || this.cropMargin > 100) {
84
+ console.warn(`cropMargin debe estar entre 0 y 100. Valor actual: ${this.cropMargin}. Usando valor por defecto: 0`);
85
+ this.cropMargin = 0;
86
+ }
87
+ }
88
+ emitReadyEvent() {
89
+ const isDocumentReady = !!window.ort && this.isModelPreloaded;
90
+ this.isReady.emit(isDocumentReady);
91
+ this.debugLog('🟢 isReady event emitted:', isDocumentReady);
92
+ }
93
+ isRearCamera(stream) {
94
+ const videoTrack = stream.getVideoTracks()[0];
95
+ if (!videoTrack)
96
+ return false;
97
+ const settings = videoTrack.getSettings();
98
+ return settings.facingMode === 'environment';
99
+ }
100
+ async componentDidLoad() {
101
+ this.validateMaskSize();
102
+ this.validateCropMargin();
103
+ if (!window.ort) {
104
+ const script = document.createElement('script');
105
+ script.src = 'https://cdn.jsdelivr.net/npm/onnxruntime-web/dist/ort.min.js';
106
+ document.head.appendChild(script);
107
+ // Wait for ONNX runtime to load before emitting ready event
108
+ script.onload = () => {
109
+ this.emitReadyEvent();
110
+ };
111
+ }
112
+ else {
113
+ // ONNX runtime already loaded
114
+ this.emitReadyEvent();
115
+ }
116
+ // Initialize canvas pool for better performance
117
+ this.initializeCanvasPool();
118
+ this.setupResizeObserver();
119
+ }
120
+ setupResizeObserver() {
121
+ if ('ResizeObserver' in window && this.canvasRef) {
122
+ const resizeObserver = new ResizeObserver(() => {
123
+ this.handleResize();
124
+ });
125
+ resizeObserver.observe(this.canvasRef.parentElement);
126
+ }
127
+ }
128
+ handleResize() {
129
+ if (this.canvasRef) {
130
+ const container = this.canvasRef.parentElement;
131
+ const rect = container.getBoundingClientRect();
132
+ // Set canvas size to match container
133
+ this.canvasRef.width = rect.width;
134
+ this.canvasRef.height = rect.height;
135
+ // Update mask positioning based on container and video dimensions
136
+ this.updateMaskDimensions(rect);
137
+ this.debugLog('📐 Canvas resized:', { width: rect.width, height: rect.height });
138
+ }
139
+ }
140
+ updateMaskDimensions(containerRect) {
141
+ if (!this.videoRef)
142
+ return;
143
+ const videoWidth = this.videoRef.videoWidth;
144
+ const videoHeight = this.videoRef.videoHeight;
145
+ if (videoWidth === 0 || videoHeight === 0)
146
+ return;
147
+ // Calculate video aspect ratio and container aspect ratio
148
+ const videoAspectRatio = videoWidth / videoHeight;
149
+ const containerAspectRatio = containerRect.width / containerRect.height;
150
+ // Determine how video fits in container (letterboxed or pillarboxed)
151
+ let displayedVideoWidth, displayedVideoHeight;
152
+ let videoOffsetX = 0, videoOffsetY = 0;
153
+ if (videoAspectRatio > containerAspectRatio) {
154
+ // Video is wider - letterboxed (black bars top/bottom)
155
+ displayedVideoWidth = containerRect.width;
156
+ displayedVideoHeight = containerRect.width / videoAspectRatio;
157
+ videoOffsetY = (containerRect.height - displayedVideoHeight) / 2;
158
+ }
159
+ else {
160
+ // Video is taller - pillarboxed (black bars left/right)
161
+ displayedVideoHeight = containerRect.height;
162
+ displayedVideoWidth = containerRect.height * videoAspectRatio;
163
+ videoOffsetX = (containerRect.width - displayedVideoWidth) / 2;
164
+ }
165
+ // Calculate maximum possible mask size while preserving exact ID-1 aspect ratio
166
+ // Determine the limiting dimension based on video orientation and ID-1 proportions
167
+ // Calculate what would be the max width if limited by video height
168
+ const maxWidthByHeight = displayedVideoHeight * this.ID1_ASPECT_RATIO;
169
+ let maskWidthInVideo, maskHeightInVideo;
170
+ const sizeRatio = this.maskSize / 100;
171
+ if (maxWidthByHeight <= displayedVideoWidth) {
172
+ // Video height is the limiting factor
173
+ maskHeightInVideo = displayedVideoHeight * sizeRatio;
174
+ maskWidthInVideo = maskHeightInVideo * this.ID1_ASPECT_RATIO;
175
+ }
176
+ else {
177
+ // Video width is the limiting factor
178
+ maskWidthInVideo = displayedVideoWidth * sizeRatio;
179
+ maskHeightInVideo = maskWidthInVideo / this.ID1_ASPECT_RATIO;
180
+ }
181
+ // Convert to percentages of the container
182
+ const maskWidthPercent = (maskWidthInVideo / containerRect.width) * 100;
183
+ const maskHeightPercent = (maskHeightInVideo / containerRect.height) * 100;
184
+ // Calculate the center position of the displayed video area
185
+ const videoCenterX = videoOffsetX + (displayedVideoWidth / 2);
186
+ const videoCenterY = videoOffsetY + (displayedVideoHeight / 2);
187
+ // Convert to percentages of the container
188
+ const videoCenterXPercent = (videoCenterX / containerRect.width) * 100;
189
+ const videoCenterYPercent = (videoCenterY / containerRect.height) * 100;
190
+ // Update CSS custom properties for mask sizing and positioning
191
+ this.el.style.setProperty('--mask-width', `${maskWidthPercent}%`);
192
+ this.el.style.setProperty('--mask-height', `${maskHeightPercent}%`);
193
+ this.el.style.setProperty('--mask-center-x', `${videoCenterXPercent}%`);
194
+ this.el.style.setProperty('--mask-center-y', `${videoCenterYPercent}%`);
195
+ // Mark mask as ready now that dimensions are calculated
196
+ this.isMaskReady = true;
197
+ this.debugLog('🎯 Mask dimensions updated:', {
198
+ video: { width: videoWidth, height: videoHeight },
199
+ displayed: { width: displayedVideoWidth, height: displayedVideoHeight },
200
+ mask: { widthPercent: maskWidthPercent, heightPercent: maskHeightPercent },
201
+ center: { x: videoCenterXPercent, y: videoCenterYPercent },
202
+ offset: { x: videoOffsetX, y: videoOffsetY }
203
+ });
204
+ }
205
+ initializeCanvasPool() {
206
+ // Preprocess canvas - reused for every inference
207
+ this.preprocessCanvas = document.createElement('canvas');
208
+ this.preprocessCanvas.width = this.INPUT_SIZE;
209
+ this.preprocessCanvas.height = this.INPUT_SIZE;
210
+ this.preprocessCtx = this.preprocessCanvas.getContext('2d', {
211
+ alpha: false, // No transparency needed
212
+ willReadFrequently: true // Optimize for frequent getImageData calls
213
+ });
214
+ // Capture canvas - reused for screenshots
215
+ this.captureCanvas = document.createElement('canvas');
216
+ this.captureCtx = this.captureCanvas.getContext('2d', {
217
+ alpha: false
218
+ });
219
+ this.debugLog('🎨 Canvas pool initialized for performance');
220
+ }
221
+ disconnectedCallback() {
222
+ this.cleanup();
223
+ }
224
+ async getCapturedImages() {
225
+ if (this.captureStep !== 'completed') {
226
+ throw new Error('El proceso de captura no ha sido completado');
227
+ }
228
+ return {
229
+ front: {
230
+ fullFrame: this.capturedFullFrame,
231
+ cropped: this.capturedCroppedId
232
+ },
233
+ back: {
234
+ fullFrame: this.capturedBackFullFrame,
235
+ cropped: this.capturedBackCroppedId
236
+ },
237
+ metadata: {
238
+ hasBackCapture: !!(this.capturedBackFullFrame && this.capturedBackCroppedId),
239
+ totalImages: (this.capturedBackFullFrame && this.capturedBackCroppedId) ? 4 : 2
240
+ }
241
+ };
242
+ }
243
+ async isProcessCompleted() {
244
+ return this.captureStep === 'completed';
245
+ }
246
+ async startCapture() {
247
+ await this.startDetection();
248
+ }
249
+ async stopCapture() {
250
+ this.exitSession();
251
+ }
252
+ async resetCapture() {
253
+ this.resetDetection();
254
+ }
255
+ async getStatus() {
256
+ return {
257
+ isVideoActive: this.isVideoActive,
258
+ captureStep: this.captureStep,
259
+ statusMessage: this.statusMessage,
260
+ hasImages: !!(this.capturedFullFrame || this.capturedBackFullFrame),
261
+ isProcessCompleted: this.captureStep === 'completed',
262
+ isModelPreloaded: this.isModelPreloaded
263
+ };
264
+ }
265
+ async preloadModel() {
266
+ if (this.isModelPreloaded || this.session) {
267
+ this.debugLog('🚀 Model already preloaded or session exists');
268
+ return { success: true, message: 'Model already loaded' };
269
+ }
270
+ try {
271
+ this.isLoading = true;
272
+ this.statusMessage = "Precargando modelos...";
273
+ this.statusColor = "#007bff";
274
+ const modelPath = this.MODEL_PATH;
275
+ this.debugLog('🤖 Preloading detection model:', modelPath);
276
+ // Configure ONNX Runtime with device-specific optimizations
277
+ const sessionOptions = this.getSessionOptions();
278
+ this.session = await window.ort.InferenceSession.create(modelPath, sessionOptions);
279
+ // Preload MobileNet model and classes only if classification is enabled
280
+ if (this.useDocumentClassification) {
281
+ await this.loadMobileNetModel();
282
+ }
283
+ this.isModelPreloaded = true;
284
+ this.isLoading = false;
285
+ this.statusMessage = "Modelos precargados. Listo para comenzar detección";
286
+ this.statusColor = "#28a745";
287
+ this.emitReadyEvent();
288
+ this.debugLog('✅ Models preloaded successfully');
289
+ return { success: true, message: 'Models preloaded successfully' };
290
+ }
291
+ catch (error) {
292
+ this.debugLog('❌ Error preloading models:', error);
293
+ this.isLoading = false;
294
+ this.statusMessage = "Error al precargar los modelos";
295
+ this.statusColor = "#ff6b6b";
296
+ return { success: false, error: error.message };
297
+ }
298
+ }
299
+ async skipBackCapture() {
300
+ if (this.captureStep === 'back' && this.capturedFullFrame) {
301
+ this.completeProcess(true);
302
+ }
303
+ }
304
+ async loadMobileNetModel() {
305
+ try {
306
+ this.debugLog('🤖 Loading MobileNet model...');
307
+ // Load class map
308
+ const classResponse = await fetch(this.MOBILENET_CLASSES_PATH);
309
+ if (!classResponse.ok) {
310
+ throw new Error(`Failed to load class map: ${this.MOBILENET_CLASSES_PATH}`);
311
+ }
312
+ this.mobileNetClassMap = await classResponse.json();
313
+ this.debugLog('📋 MobileNet classes loaded:', this.mobileNetClassMap);
314
+ // Load model
315
+ const sessionOptions = this.getSessionOptions();
316
+ this.mobileNetSession = await window.ort.InferenceSession.create(this.MOBILENET_MODEL_PATH, sessionOptions);
317
+ this.debugLog('✅ MobileNet model loaded successfully');
318
+ }
319
+ catch (error) {
320
+ this.debugLog('❌ Error loading MobileNet model:', error);
321
+ throw error;
322
+ }
323
+ }
324
+ preprocessMobileNet(canvas) {
325
+ // Create a temporary canvas for MobileNet preprocessing (224x224)
326
+ const tempCanvas = document.createElement('canvas');
327
+ tempCanvas.width = 224;
328
+ tempCanvas.height = 224;
329
+ const tempCtx = tempCanvas.getContext('2d');
330
+ // Draw the cropped image onto the 224x224 canvas
331
+ tempCtx.drawImage(canvas, 0, 0, 224, 224);
332
+ // Get image data and preprocess for MobileNet
333
+ const imageData = tempCtx.getImageData(0, 0, 224, 224);
334
+ const data = imageData.data;
335
+ const hw = 224 * 224;
336
+ const arr = new Float32Array(3 * hw);
337
+ // Normalize pixels: (pixel/255 - 0.5) / 0.5 = (pixel - 127.5) / 127.5
338
+ for (let i = 0; i < hw; i++) {
339
+ arr[i] = (data[i * 4 + 0] / 255 - 0.5) / 0.5; // R
340
+ arr[hw + i] = (data[i * 4 + 1] / 255 - 0.5) / 0.5; // G
341
+ arr[2 * hw + i] = (data[i * 4 + 2] / 255 - 0.5) / 0.5; // B
342
+ }
343
+ return new window.ort.Tensor('float32', arr, [1, 3, 224, 224]);
344
+ }
345
+ async classifyDocument(canvas) {
346
+ if (!this.mobileNetSession || !this.mobileNetClassMap) {
347
+ this.debugLog('⚠️ MobileNet model not loaded');
348
+ return null;
349
+ }
350
+ try {
351
+ this.debugLog('🔍 Classifying document...');
352
+ // Preprocess image for MobileNet
353
+ const inputTensor = this.preprocessMobileNet(canvas);
354
+ // Run inference
355
+ const feeds = { input: inputTensor };
356
+ const results = await this.mobileNetSession.run(feeds);
357
+ const output = results[Object.keys(results)[0]].data;
358
+ // Find the class with highest confidence
359
+ const maxIdx = output.reduce((bestIdx, val, idx, arr) => val > arr[bestIdx] ? idx : bestIdx, 0);
360
+ const confidence = output[maxIdx];
361
+ const className = this.mobileNetClassMap[maxIdx.toString()] || "unknown";
362
+ this.debugLog('📄 Document classification result:', {
363
+ class: className,
364
+ confidence: confidence.toFixed(3),
365
+ classIndex: maxIdx
366
+ });
367
+ return {
368
+ class: className,
369
+ confidence: confidence,
370
+ classIndex: maxIdx
371
+ };
372
+ }
373
+ catch (error) {
374
+ this.debugLog('❌ Error classifying document:', error);
375
+ return null;
376
+ }
377
+ }
378
+ cleanup() {
379
+ if (this.animationId) {
380
+ cancelAnimationFrame(this.animationId);
381
+ }
382
+ if (this.videoStream) {
383
+ this.videoStream.getTracks().forEach(track => track.stop());
384
+ }
385
+ // Limpiar canvas en cleanup general
386
+ if (this.canvasRef) {
387
+ const ctx = this.canvasRef.getContext("2d");
388
+ if (ctx) {
389
+ ctx.clearRect(0, 0, this.canvasRef.width, this.canvasRef.height);
390
+ }
391
+ }
392
+ // OPTIMIZATION: Clean up canvas pool
393
+ this.cleanupCanvasPool();
394
+ }
395
+ cleanupCanvasPool() {
396
+ // Release canvas references for garbage collection
397
+ if (this.preprocessCanvas) {
398
+ this.preprocessCtx = undefined;
399
+ this.preprocessCanvas = undefined;
400
+ }
401
+ if (this.captureCanvas) {
402
+ this.captureCtx = undefined;
403
+ this.captureCanvas = undefined;
404
+ }
405
+ // Disposed ONNX sessions
406
+ if (this.session) {
407
+ this.session.release?.();
408
+ this.session = undefined;
409
+ }
410
+ if (this.mobileNetSession) {
411
+ this.mobileNetSession.release?.();
412
+ this.mobileNetSession = undefined;
413
+ }
414
+ this.mobileNetClassMap = undefined;
415
+ this.isModelPreloaded = false;
416
+ this.debugLog('🧹 Canvas pool cleaned up');
417
+ }
418
+ async getMaxResolution() {
419
+ try {
420
+ // Primero obtén un stream básico para acceder a las capacidades
421
+ const tempStream = await navigator.mediaDevices.getUserMedia({
422
+ video: { facingMode: "environment" }
423
+ });
424
+ const videoTrack = tempStream.getVideoTracks()[0];
425
+ const capabilities = videoTrack.getCapabilities();
426
+ // Detener el stream temporal
427
+ tempStream.getTracks().forEach(track => track.stop());
428
+ // Construir restricciones con resolución optimizada para tablets
429
+ const constraints = {
430
+ facingMode: "environment"
431
+ };
432
+ if (capabilities.width && capabilities.height) {
433
+ // Limitar resolución máxima para tablets para evitar problemas de rendimiento
434
+ const maxWidth = Math.min(capabilities.width.max, 1920);
435
+ const maxHeight = Math.min(capabilities.height.max, 1080);
436
+ // Para tablets, usar resolución moderada en lugar de máxima
437
+ const isTablet = /iPad|Android/i.test(navigator.userAgent) && window.innerWidth >= 768;
438
+ if (isTablet) {
439
+ constraints.width = { ideal: Math.min(maxWidth, 1280) };
440
+ constraints.height = { ideal: Math.min(maxHeight, 720) };
441
+ }
442
+ else {
443
+ constraints.width = { ideal: maxWidth };
444
+ constraints.height = { ideal: maxHeight };
445
+ }
446
+ this.debugLog('📐 Resolution capabilities:', {
447
+ maxWidth: capabilities.width.max,
448
+ maxHeight: capabilities.height.max,
449
+ selectedWidth: constraints.width.ideal,
450
+ selectedHeight: constraints.height.ideal,
451
+ isTablet
452
+ });
453
+ }
454
+ return constraints;
455
+ }
456
+ catch (err) {
457
+ this.debugLog('⚠️ Could not get capabilities, using fallback');
458
+ // Fallback optimizado para tablets
459
+ const isTablet = /iPad|Android/i.test(navigator.userAgent) && window.innerWidth >= 768;
460
+ return {
461
+ facingMode: "environment",
462
+ width: { ideal: isTablet ? 1280 : 1920 },
463
+ height: { ideal: isTablet ? 720 : 1080 }
464
+ };
465
+ }
466
+ }
467
+ async setupCamera() {
468
+ try {
469
+ const constraints = await this.getMaxResolution();
470
+ const stream = await navigator.mediaDevices.getUserMedia({
471
+ video: constraints,
472
+ audio: false
473
+ });
474
+ if (this.videoRef) {
475
+ this.videoRef.srcObject = stream;
476
+ this.videoStream = stream;
477
+ // Determine if video should be mirrored
478
+ const isRear = this.isRearCamera(stream);
479
+ this.shouldMirrorVideo = !isRear;
480
+ this.debugLog('📹 Rear camera:', isRear);
481
+ this.debugLog('🪞 Should mirror video:', this.shouldMirrorVideo);
482
+ return new Promise((resolve) => {
483
+ this.videoRef.onloadedmetadata = async () => {
484
+ await this.videoRef.play();
485
+ this.isVideoActive = true;
486
+ // Update mask dimensions once video is loaded
487
+ if (this.canvasRef) {
488
+ const container = this.canvasRef.parentElement;
489
+ const rect = container.getBoundingClientRect();
490
+ this.updateMaskDimensions(rect);
491
+ }
492
+ resolve();
493
+ };
494
+ });
495
+ }
496
+ }
497
+ catch (err) {
498
+ this.debugLog("❌ No se pudo acceder a la cámara:", err);
499
+ this.statusMessage = "Error: No se pudo acceder a la cámara.";
500
+ this.statusColor = "#ff6b6b";
501
+ }
502
+ }
503
+ preprocess(video) {
504
+ // OPTIMIZATION: Reuse canvas instead of creating new ones
505
+ if (!this.preprocessCanvas || !this.preprocessCtx) {
506
+ this.initializeCanvasPool();
507
+ }
508
+ // Clear and redraw on reused canvas
509
+ this.preprocessCtx.clearRect(0, 0, this.INPUT_SIZE, this.INPUT_SIZE);
510
+ this.preprocessCtx.drawImage(video, 0, 0, this.INPUT_SIZE, this.INPUT_SIZE);
511
+ const imageData = this.preprocessCtx.getImageData(0, 0, this.INPUT_SIZE, this.INPUT_SIZE);
512
+ const [R, G, B] = [[], [], []];
513
+ const { data } = imageData;
514
+ // Optimized pixel processing
515
+ for (let i = 0; i < data.length; i += 4) {
516
+ R.push(data[i] / 255);
517
+ G.push(data[i + 1] / 255);
518
+ B.push(data[i + 2] / 255);
519
+ }
520
+ const transposedData = new Float32Array(R.concat(G, B));
521
+ return new window.ort.Tensor("float32", transposedData, [1, 3, this.INPUT_SIZE, this.INPUT_SIZE]);
522
+ }
523
+ getSessionOptions() {
524
+ return {
525
+ executionProviders: [
526
+ // Try WebGL first for GPU acceleration, fallback to WASM
527
+ 'webgl',
528
+ 'wasm'
529
+ ],
530
+ graphOptimizationLevel: 'all', // Maximum optimization
531
+ logSeverityLevel: this.debug ? 2 : 4, // Reduce logging overhead in production
532
+ logVerbosityLevel: 0,
533
+ enableCpuMemArena: true,
534
+ enableMemPattern: true,
535
+ executionMode: 'parallel',
536
+ interOpNumThreads: 2,
537
+ intraOpNumThreads: 2,
538
+ };
539
+ }
540
+ async startDetection() {
541
+ try {
542
+ // Check if model is already preloaded
543
+ if (!this.session) {
544
+ this.isLoading = true;
545
+ this.statusMessage = "Cargando modelos...";
546
+ this.statusColor = "#007bff";
547
+ const modelPath = this.MODEL_PATH;
548
+ this.debugLog('🤖 Loading detection model:', modelPath);
549
+ const sessionOptions = this.getSessionOptions();
550
+ this.session = await window.ort.InferenceSession.create(modelPath, sessionOptions);
551
+ // Load MobileNet model if classification is enabled and not already loaded
552
+ if (this.useDocumentClassification && !this.mobileNetSession) {
553
+ await this.loadMobileNetModel();
554
+ }
555
+ this.isModelPreloaded = true;
556
+ this.emitReadyEvent();
557
+ }
558
+ else {
559
+ this.debugLog('🚀 Using preloaded models');
560
+ this.statusMessage = "Usando modelos precargados...";
561
+ this.statusColor = "#007bff";
562
+ }
563
+ this.statusMessage = "Configurando cámara...";
564
+ await this.setupCamera();
565
+ this.startTime = Date.now();
566
+ this.isLoading = false;
567
+ this.detectFrame();
568
+ }
569
+ catch (err) {
570
+ this.debugLog("Error al inicializar:", err);
571
+ this.statusMessage = "Error al inicializar el detector";
572
+ this.statusColor = "#ff6b6b";
573
+ this.isLoading = false;
574
+ }
575
+ }
576
+ async detectFrame() {
577
+ try {
578
+ if (!this.videoRef || !this.canvasRef || !this.session)
579
+ return;
580
+ // Pausar detección si está marcado como pausado
581
+ if (this.isDetectionPaused) {
582
+ // Solo continuar el bucle sin procesar detección
583
+ if (this.captureStep !== 'completed') {
584
+ this.animationId = requestAnimationFrame(() => this.detectFrame());
585
+ }
586
+ return;
587
+ }
588
+ // OPTIMIZATION 1: Frame skipping for performance
589
+ this.frameSkipCounter++;
590
+ if (this.frameSkipCounter <= this.FRAME_SKIP) {
591
+ if (this.captureStep !== 'completed') {
592
+ this.animationId = requestAnimationFrame(() => this.detectFrame());
593
+ }
594
+ return;
595
+ }
596
+ this.frameSkipCounter = 0;
597
+ // OPTIMIZATION 2: Throttle inference based on time
598
+ const currentTime = Date.now();
599
+ if (currentTime - this.lastInferenceTime < this.MIN_INFERENCE_INTERVAL) {
600
+ if (this.captureStep !== 'completed') {
601
+ this.animationId = requestAnimationFrame(() => this.detectFrame());
602
+ }
603
+ return;
604
+ }
605
+ this.lastInferenceTime = currentTime;
606
+ const ctx = this.canvasRef.getContext("2d");
607
+ const inputTensor = this.preprocess(this.videoRef);
608
+ const feeds = { [this.session.inputNames[0]]: inputTensor };
609
+ const results = await this.session.run(feeds);
610
+ const output = results[this.session.outputNames[0]].data;
611
+ const finalBoxes = [];
612
+ for (let i = 0; i < output.length; i += 6) {
613
+ const [x1, y1, x2, y2, score, classId] = output.slice(i, i + 6);
614
+ if (score > this.CONFIDENCE_THRESHOLD) {
615
+ finalBoxes.push({ x: x1, y: y1, w: x2 - x1, h: y2 - y1, score, classId });
616
+ if (this.startTime && Date.now() - this.startTime < 5000) {
617
+ const currentBox = { x: x1, y: y1, w: x2 - x1, h: y2 - y1, score };
618
+ const isWellPositioned = this.isCardInFrame(currentBox);
619
+ const effectiveScore = isWellPositioned ? score * 1.2 : score;
620
+ if (effectiveScore > this.bestScore) {
621
+ this.bestScore = effectiveScore;
622
+ }
623
+ }
624
+ }
625
+ }
626
+ // OPTIMIZATION 3: Adaptive frame rate based on detection success
627
+ if (finalBoxes.length === 0) {
628
+ this.consecutiveFailures++;
629
+ }
630
+ else {
631
+ this.consecutiveFailures = 0;
632
+ }
633
+ ctx.clearRect(0, 0, this.canvasRef.width, this.canvasRef.height);
634
+ if (this.debug) {
635
+ this.drawDetections(ctx, finalBoxes);
636
+ }
637
+ this.updateGuidanceStatus(finalBoxes);
638
+ this.updateMaskColor(finalBoxes);
639
+ // Solo continuar si no hemos completado el proceso
640
+ if (this.captureStep !== 'completed') {
641
+ // OPTIMIZATION 4: Reduce frame rate when no detection for better battery life
642
+ if (this.consecutiveFailures > this.MAX_FAILURES) {
643
+ // Reduce to ~5fps when no detection for 0.5 seconds
644
+ setTimeout(() => this.detectFrame(), 200);
645
+ }
646
+ else {
647
+ this.animationId = requestAnimationFrame(() => this.detectFrame());
648
+ }
649
+ }
650
+ }
651
+ catch (e) {
652
+ this.debugLog("Error en inferencia:", e);
653
+ // Solo continuar si no hemos completado el proceso
654
+ if (this.captureStep !== 'completed') {
655
+ // On error, wait longer before retrying
656
+ setTimeout(() => this.detectFrame(), 100);
657
+ }
658
+ }
659
+ }
660
+ isCardInFrame(box) {
661
+ const cardCenterX = box.x + box.w / 2;
662
+ const cardCenterY = box.y + box.h / 2;
663
+ const frameCenterX = this.INPUT_SIZE / 2;
664
+ const frameCenterY = this.INPUT_SIZE / 2;
665
+ const toleranceX = 40;
666
+ const toleranceY = 30;
667
+ const isCentered = Math.abs(cardCenterX - frameCenterX) < toleranceX &&
668
+ Math.abs(cardCenterY - frameCenterY) < toleranceY;
669
+ const isGoodSize = box.w > 150 && box.w < 300 && box.h > 90 && box.h < 200;
670
+ return isCentered && isGoodSize;
671
+ }
672
+ checkSideAlignment(box) {
673
+ if (!this.videoRef)
674
+ return { top: false, right: false, bottom: false, left: false };
675
+ // Get video dimensions to calculate actual mask boundaries in model space
676
+ const videoWidth = this.videoRef.videoWidth;
677
+ const videoHeight = this.videoRef.videoHeight;
678
+ if (videoWidth === 0 || videoHeight === 0) {
679
+ return { top: false, right: false, bottom: false, left: false };
680
+ }
681
+ // Calculate video aspect ratio
682
+ const videoAspectRatio = videoWidth / videoHeight;
683
+ // The model sees video stretched to 320x320, but we need to calculate where
684
+ // the mask should be in this distorted space to match the visual mask
685
+ // In the visual display, we calculate mask size based on the limiting dimension
686
+ // We need to replicate this logic but account for the distortion in model space
687
+ // Calculate the "display" dimensions (what the visual mask calculations use)
688
+ const containerAspectRatio = 1; // Assume square container for simplicity
689
+ let displayedVideoWidth, displayedVideoHeight;
690
+ if (videoAspectRatio > containerAspectRatio) {
691
+ // Video is wider - letterboxed in display
692
+ displayedVideoWidth = this.INPUT_SIZE;
693
+ displayedVideoHeight = this.INPUT_SIZE / videoAspectRatio;
694
+ }
695
+ else {
696
+ // Video is taller - pillarboxed in display
697
+ displayedVideoHeight = this.INPUT_SIZE;
698
+ displayedVideoWidth = this.INPUT_SIZE * videoAspectRatio;
699
+ }
700
+ // Calculate mask dimensions using the same logic as updateMaskDimensions
701
+ const maxWidthByHeight = displayedVideoHeight * this.ID1_ASPECT_RATIO;
702
+ let visualMaskWidth, visualMaskHeight;
703
+ const sizeRatio = this.maskSize / 100;
704
+ if (maxWidthByHeight <= displayedVideoWidth) {
705
+ // Video height is the limiting factor
706
+ visualMaskHeight = displayedVideoHeight * sizeRatio;
707
+ visualMaskWidth = visualMaskHeight * this.ID1_ASPECT_RATIO;
708
+ }
709
+ else {
710
+ // Video width is the limiting factor
711
+ visualMaskWidth = displayedVideoWidth * sizeRatio;
712
+ visualMaskHeight = visualMaskWidth / this.ID1_ASPECT_RATIO;
713
+ }
714
+ // Now map these visual mask dimensions to the distorted model space
715
+ // The model stretches video to 320x320, so we need to apply the inverse transformation
716
+ const modelMaskWidth = visualMaskWidth * (this.INPUT_SIZE / displayedVideoWidth);
717
+ const modelMaskHeight = visualMaskHeight * (this.INPUT_SIZE / displayedVideoHeight);
718
+ // Calculate mask boundaries in model coordinate system (always centered in 320x320)
719
+ const maskCenterX = this.INPUT_SIZE / 2;
720
+ const maskCenterY = this.INPUT_SIZE / 2;
721
+ const maskLeft = maskCenterX - (modelMaskWidth / 2);
722
+ const maskRight = maskCenterX + (modelMaskWidth / 2);
723
+ const maskTop = maskCenterY - (modelMaskHeight / 2);
724
+ const maskBottom = maskCenterY + (modelMaskHeight / 2);
725
+ // Obtener las coordenadas del documento detectado
726
+ let docLeft = box.x;
727
+ let docRight = box.x + box.w;
728
+ const docTop = box.y;
729
+ const docBottom = box.y + box.h;
730
+ // Si el video está en modo mirror, invertir las coordenadas horizontales
731
+ if (this.shouldMirrorVideo) {
732
+ const originalDocLeft = docLeft;
733
+ const originalDocRight = docRight;
734
+ docLeft = this.INPUT_SIZE - originalDocRight;
735
+ docRight = this.INPUT_SIZE - originalDocLeft;
736
+ }
737
+ // Tolerancia para considerar que un lado está alineado (en píxeles)
738
+ const tolerance = this.alignmentTolerance;
739
+ return {
740
+ top: Math.abs(docTop - maskTop) <= tolerance,
741
+ right: Math.abs(docRight - maskRight) <= tolerance,
742
+ bottom: Math.abs(docBottom - maskBottom) <= tolerance,
743
+ left: Math.abs(docLeft - maskLeft) <= tolerance
744
+ };
745
+ }
746
+ areAllSidesAligned(alignment) {
747
+ return alignment.top && alignment.right && alignment.bottom && alignment.left;
748
+ }
749
+ updateMaskColor(boxes) {
750
+ const cardOutline = this.el.shadowRoot?.querySelector('.card-outline');
751
+ const corners = this.el.shadowRoot?.querySelectorAll('.corner');
752
+ const topSide = this.el.shadowRoot?.querySelector('.side-top');
753
+ const rightSide = this.el.shadowRoot?.querySelector('.side-right');
754
+ const bottomSide = this.el.shadowRoot?.querySelector('.side-bottom');
755
+ const leftSide = this.el.shadowRoot?.querySelector('.side-left');
756
+ let bestBox = null;
757
+ let currentAlignment = { top: false, right: false, bottom: false, left: false };
758
+ if (boxes.length > 0) {
759
+ bestBox = boxes.reduce((best, current) => current.score > best.score ? current : best);
760
+ currentAlignment = this.checkSideAlignment(bestBox);
761
+ this.sideAlignment = currentAlignment;
762
+ }
763
+ else {
764
+ // Reset alignment when no detection
765
+ this.sideAlignment = { top: false, right: false, bottom: false, left: false };
766
+ }
767
+ // Actualizar colores de cada lado individualmente
768
+ topSide?.classList.toggle('aligned', currentAlignment.top);
769
+ rightSide?.classList.toggle('aligned', currentAlignment.right);
770
+ bottomSide?.classList.toggle('aligned', currentAlignment.bottom);
771
+ leftSide?.classList.toggle('aligned', currentAlignment.left);
772
+ // Verificar si todos los lados están alineados
773
+ const allSidesAligned = this.areAllSidesAligned(currentAlignment);
774
+ if (allSidesAligned && bestBox) {
775
+ cardOutline?.classList.add('perfect-match');
776
+ corners?.forEach(corner => corner.classList.add('perfect-match'));
777
+ if (!this.hasScreenshotTaken) {
778
+ this.lastDetectedBox = bestBox;
779
+ this.takeScreenshot().catch(error => {
780
+ this.debugLog('❌ Error taking screenshot:', error);
781
+ });
782
+ this.hasScreenshotTaken = true;
783
+ // Reset para permitir segunda captura
784
+ setTimeout(() => {
785
+ this.hasScreenshotTaken = false;
786
+ }, 2000);
787
+ }
788
+ }
789
+ else {
790
+ cardOutline?.classList.remove('perfect-match');
791
+ corners?.forEach(corner => corner.classList.remove('perfect-match'));
792
+ }
793
+ }
794
+ updateGuidanceStatus(boxes) {
795
+ if (boxes.length === 0) {
796
+ this.statusMessage = "Posicione la identificación dentro del marco";
797
+ this.statusColor = "#ff6b6b";
798
+ }
799
+ else {
800
+ const bestBox = boxes.reduce((best, current) => current.score > best.score ? current : best);
801
+ const alignment = this.checkSideAlignment(bestBox);
802
+ const alignedSides = [alignment.top, alignment.right, alignment.bottom, alignment.left].filter(Boolean).length;
803
+ const allSidesAligned = this.areAllSidesAligned(alignment);
804
+ if (allSidesAligned) {
805
+ this.statusMessage = "Identificación perfectamente alineada. Mantenga inmóvil";
806
+ this.statusColor = "#00ff00";
807
+ }
808
+ else if (alignedSides > 0) {
809
+ this.statusMessage = `Alinee los lados restantes (${alignedSides}/4 lados correctos)`;
810
+ this.statusColor = "#ffb366";
811
+ }
812
+ else if (bestBox.w < 150) {
813
+ this.statusMessage = "Identificación detectada. Acerque al marco";
814
+ this.statusColor = "#ffb366";
815
+ }
816
+ else {
817
+ this.statusMessage = "Identificación detectada. Alinee con el marco";
818
+ this.statusColor = "#ffb366";
819
+ }
820
+ }
821
+ }
822
+ drawDetections(ctx, boxes) {
823
+ if (!this.videoRef)
824
+ return;
825
+ // Get video and container dimensions
826
+ const videoWidth = this.videoRef.videoWidth;
827
+ const videoHeight = this.videoRef.videoHeight;
828
+ const containerWidth = this.canvasRef.width;
829
+ const containerHeight = this.canvasRef.height;
830
+ if (videoWidth === 0 || videoHeight === 0)
831
+ return;
832
+ // Calculate video aspect ratio and container aspect ratio
833
+ const videoAspectRatio = videoWidth / videoHeight;
834
+ const containerAspectRatio = containerWidth / containerHeight;
835
+ // Determine how video fits in container (same logic as updateMaskDimensions)
836
+ let displayedVideoWidth, displayedVideoHeight;
837
+ let videoOffsetX = 0, videoOffsetY = 0;
838
+ if (videoAspectRatio > containerAspectRatio) {
839
+ // Video is wider - letterboxed (black bars top/bottom)
840
+ displayedVideoWidth = containerWidth;
841
+ displayedVideoHeight = containerWidth / videoAspectRatio;
842
+ videoOffsetY = (containerHeight - displayedVideoHeight) / 2;
843
+ }
844
+ else {
845
+ // Video is taller - pillarboxed (black bars left/right)
846
+ displayedVideoHeight = containerHeight;
847
+ displayedVideoWidth = containerHeight * videoAspectRatio;
848
+ videoOffsetX = (containerWidth - displayedVideoWidth) / 2;
849
+ }
850
+ // Scale factor from model coordinates (320x320) to displayed video area
851
+ const scaleX = displayedVideoWidth / this.INPUT_SIZE;
852
+ const scaleY = displayedVideoHeight / this.INPUT_SIZE;
853
+ boxes.forEach(det => {
854
+ // Convert model coordinates to displayed video coordinates
855
+ const x = det.x * scaleX + videoOffsetX;
856
+ const y = det.y * scaleY + videoOffsetY;
857
+ const w = det.w * scaleX;
858
+ const h = det.h * scaleY;
859
+ ctx.strokeStyle = "#32406C";
860
+ ctx.lineWidth = 2;
861
+ ctx.strokeRect(x, y, w, h);
862
+ });
863
+ }
864
+ async takeScreenshot() {
865
+ if (!this.videoRef || !this.lastDetectedBox)
866
+ return;
867
+ // Activar animación
868
+ this.triggerCaptureAnimation();
869
+ // OPTIMIZATION: Reuse capture canvas for full frame
870
+ if (!this.captureCanvas || !this.captureCtx) {
871
+ this.initializeCanvasPool();
872
+ }
873
+ // Resize reused canvas for full frame
874
+ this.captureCanvas.width = this.videoRef.videoWidth;
875
+ this.captureCanvas.height = this.videoRef.videoHeight;
876
+ this.captureCtx.drawImage(this.videoRef, 0, 0, this.captureCanvas.width, this.captureCanvas.height);
877
+ // Calcular las coordenadas de recorte basadas en la detección
878
+ const scaleX = this.videoRef.videoWidth / this.INPUT_SIZE;
879
+ const scaleY = this.videoRef.videoHeight / this.INPUT_SIZE;
880
+ const cropX = Math.max(0, (this.lastDetectedBox.x * scaleX) - this.cropMargin);
881
+ const cropY = Math.max(0, (this.lastDetectedBox.y * scaleY) - this.cropMargin);
882
+ const cropWidth = Math.min((this.lastDetectedBox.w * scaleX) + (2 * this.cropMargin), this.videoRef.videoWidth - cropX);
883
+ const cropHeight = Math.min((this.lastDetectedBox.h * scaleY) + (2 * this.cropMargin), this.videoRef.videoHeight - cropY);
884
+ // OPTIMIZATION: Create temporary canvas only for cropped version
885
+ // (We reuse main capture canvas for full frame)
886
+ const croppedCanvas = document.createElement('canvas');
887
+ croppedCanvas.width = cropWidth;
888
+ croppedCanvas.height = cropHeight;
889
+ const croppedCtx = croppedCanvas.getContext('2d', { alpha: false });
890
+ // Recortar la identificación del frame completo
891
+ croppedCtx.drawImage(this.videoRef, cropX, cropY, cropWidth, cropHeight, // Área de origen
892
+ 0, 0, cropWidth, cropHeight // Área de destino
893
+ );
894
+ if (this.captureStep === 'front') {
895
+ // Captura del frente usando canvas reutilizado
896
+ this.capturedFullFrame = this.captureCanvas.toDataURL('image/png');
897
+ this.capturedCroppedId = croppedCanvas.toDataURL('image/png');
898
+ // Check if document classification is enabled
899
+ if (this.useDocumentClassification) {
900
+ // Load MobileNet model if not loaded yet (lazy loading)
901
+ if (!this.mobileNetSession) {
902
+ try {
903
+ await this.loadMobileNetModel();
904
+ }
905
+ catch (error) {
906
+ this.debugLog('⚠️ Failed to load classification model, continuing without classification:', error);
907
+ }
908
+ }
909
+ // Classify the cropped document if model is available
910
+ if (this.mobileNetSession) {
911
+ const classification = await this.classifyDocument(croppedCanvas);
912
+ if (classification && classification.class === 'passport') {
913
+ // If it's a passport, skip back capture since passports don't have a back side
914
+ this.debugLog('📄 Passport detected - skipping back capture');
915
+ this.completeProcess(true);
916
+ return;
917
+ }
918
+ }
919
+ }
920
+ // For other IDs, continue with normal flow (back capture)
921
+ this.captureStep = 'back';
922
+ this.statusMessage = "Voltee la identificación y muestre la parte trasera";
923
+ this.statusColor = "#007bff";
924
+ // Pausar detección durante la animación de giro
925
+ this.isDetectionPaused = true;
926
+ // Mostrar animación de giro después de la captura
927
+ setTimeout(() => {
928
+ this.showFlipAnimation = true;
929
+ setTimeout(() => {
930
+ this.showFlipAnimation = false;
931
+ // Reanudar detección después de que termine la animación
932
+ this.isDetectionPaused = false;
933
+ }, 3000);
934
+ }, 800);
935
+ this.debugLog('📸 FRENTE capturado. Esperando trasera...');
936
+ }
937
+ else if (this.captureStep === 'back') {
938
+ // Captura de la trasera usando canvas reutilizado
939
+ this.capturedBackFullFrame = this.captureCanvas.toDataURL('image/png');
940
+ this.capturedBackCroppedId = croppedCanvas.toDataURL('image/png');
941
+ this.completeProcess(false);
942
+ this.debugLog('📸 TRASERA capturada. Proceso completado. Detector detenido. Imágenes emitidas.');
943
+ }
944
+ }
945
+ triggerCaptureAnimation() {
946
+ this.isCapturing = true;
947
+ // Agregar clase de animación al marco
948
+ const cardOutline = this.el.shadowRoot?.querySelector('.card-outline');
949
+ cardOutline?.classList.add('capturing');
950
+ // Limpiar animación después de que termine
951
+ setTimeout(() => {
952
+ this.isCapturing = false;
953
+ cardOutline?.classList.remove('capturing');
954
+ }, 600);
955
+ }
956
+ stopDetection() {
957
+ if (this.animationId) {
958
+ cancelAnimationFrame(this.animationId);
959
+ this.animationId = undefined;
960
+ }
961
+ // Limpiar canvas para eliminar cualquier detección visual residual
962
+ if (this.canvasRef) {
963
+ const ctx = this.canvasRef.getContext("2d");
964
+ ctx.clearRect(0, 0, this.canvasRef.width, this.canvasRef.height);
965
+ }
966
+ this.debugLog('🛑 Detector de identificación detenido');
967
+ }
968
+ resetDetection() {
969
+ this.bestScore = 0;
970
+ this.startTime = Date.now();
971
+ this.statusMessage = "Sistema reiniciado. Posicione la identificación";
972
+ this.statusColor = "#aaa";
973
+ this.hasScreenshotTaken = false;
974
+ this.capturedFullFrame = null;
975
+ this.capturedCroppedId = null;
976
+ this.capturedBackFullFrame = null;
977
+ this.capturedBackCroppedId = null;
978
+ this.captureStep = 'front';
979
+ this.isCapturing = false;
980
+ this.showFlipAnimation = false;
981
+ this.showSuccessAnimation = false;
982
+ this.isDetectionPaused = false;
983
+ this.isLoading = false;
984
+ this.lastDetectedBox = undefined;
985
+ this.isModelPreloaded = false;
986
+ // Reset performance counters
987
+ this.frameSkipCounter = 0;
988
+ this.consecutiveFailures = 0;
989
+ this.lastInferenceTime = 0;
990
+ if (this.canvasRef) {
991
+ const ctx = this.canvasRef.getContext("2d");
992
+ ctx.clearRect(0, 0, this.canvasRef.width, this.canvasRef.height);
993
+ }
994
+ // Reiniciar el detector si estaba funcionando
995
+ if (this.isVideoActive && this.session) {
996
+ this.detectFrame();
997
+ }
998
+ }
999
+ completeProcess(skippedBack = false) {
1000
+ this.captureStep = 'completed';
1001
+ this.statusMessage = skippedBack ?
1002
+ "Proceso completado (solo frente capturado)" :
1003
+ "Proceso de captura completado exitosamente";
1004
+ this.statusColor = "#28a745";
1005
+ // Detener el detector
1006
+ this.stopDetection();
1007
+ // Emitir evento con las imágenes capturadas
1008
+ const capturedImages = {
1009
+ front: {
1010
+ fullFrame: this.capturedFullFrame,
1011
+ cropped: this.capturedCroppedId
1012
+ },
1013
+ back: {
1014
+ fullFrame: this.capturedBackFullFrame,
1015
+ cropped: this.capturedBackCroppedId
1016
+ },
1017
+ timestamp: new Date().toISOString(),
1018
+ metadata: {
1019
+ totalImages: skippedBack ? 2 : 4,
1020
+ processCompleted: true,
1021
+ backCaptureSkipped: skippedBack
1022
+ }
1023
+ };
1024
+ this.captureCompleted.emit(capturedImages);
1025
+ // Mostrar animación de éxito después de la captura
1026
+ setTimeout(() => {
1027
+ this.showSuccessAnimation = true;
1028
+ setTimeout(() => {
1029
+ this.showSuccessAnimation = false;
1030
+ }, 3000);
1031
+ }, 800);
1032
+ }
1033
+ exitSession() {
1034
+ if (this.videoStream) {
1035
+ this.videoStream.getTracks().forEach(track => track.stop());
1036
+ this.videoStream = undefined;
1037
+ this.isVideoActive = false;
1038
+ this.statusMessage = "Sesión finalizada.";
1039
+ this.statusColor = "#aaa";
1040
+ }
1041
+ this.isLoading = false;
1042
+ // Limpiar canvas al finalizar sesión
1043
+ if (this.canvasRef) {
1044
+ const ctx = this.canvasRef.getContext("2d");
1045
+ ctx.clearRect(0, 0, this.canvasRef.width, this.canvasRef.height);
1046
+ }
1047
+ this.cleanup();
1048
+ }
1049
+ render() {
1050
+ return (h("div", { key: '42591479495df221b101555198a23288d7d765b0', class: "detector-container" }, h("div", { key: '2b9ab48572aa2fb5542b8a8dc1b70a0f2a6eca89', class: "video-container" }, h("video", { key: 'b9e84f2eb67fa6f7f158e19b90871a1eebee624b', ref: el => this.videoRef = el, autoplay: true, muted: true, playsinline: true, class: this.shouldMirrorVideo ? 'mirror' : '', style: { display: this.isVideoActive ? 'block' : 'none' } }), h("canvas", { key: 'a82fc4826e220e696799b07b3510456f174a6628', ref: el => this.canvasRef = el, class: this.shouldMirrorVideo ? 'mirror' : '' }), this.isMaskReady && (h("div", { key: '9b3b838f99030e3dfa760fa0dd7c89ff24f26ed9', class: "overlay-mask" }, h("div", { key: 'f6a3b1ac2f12c1fb081f6b5eb853e627040396f4', class: "card-outline" }, h("div", { key: '6626259249ac5e0fd6ba665ab802af1ac2f9fc17', class: "side side-top" }), h("div", { key: '7a3195c96b2406b40b122f4267c2a251614cdede', class: "side side-right" }), h("div", { key: 'ece78305cfb083ada1d44de1d7d5226730879cc3', class: "side side-bottom" }), h("div", { key: '107468c583bbb01dd46c36c096e49be8e0b574ba', class: "side side-left" }), h("div", { key: 'c590f13b80c5e37c0ac0c68cfc2e2904b4345ebc', class: "corner corner-tl" }), h("div", { key: 'ab1e5aab179068ad1bc7b58ef3628d9618a877a8', class: "corner corner-tr" }), h("div", { key: '3a1db6cf1105bd3a2dfe7d4b998e79f6e40625ec', class: "corner corner-bl" }), h("div", { key: '5f9bc4e4557e5539335894160dccbaa2a6d6ac2d', class: "corner corner-br" }), !this.showFlipAnimation && !this.showSuccessAnimation && (h("div", { key: '8226d6721b0ae800f935e978a93113bd3b99656a', class: "guide-text" }, this.statusMessage))), this.captureStep === 'back' && !this.showFlipAnimation && !this.showSuccessAnimation && (h("button", { key: '16cec7ca4a80ba0db1ace768826da17063eddb3e', class: "skip-button", onClick: () => this.skipBackCapture(), type: "button" }, "Saltar reverso")))), this.isCapturing && (h("div", { key: 'bfdca0059eb50d37a77e8e43ef963ba7ed953edf', class: "capture-animation" })), this.showFlipAnimation && (h("div", { key: 'a1ad4b4f884d7d9f6090f148ddd6df19250073dd', class: "flip-animation" }, h("div", { key: 'e159ce385824dc049a6e9409d3747105c6f0a08e', class: "id-card-icon" }), h("div", { key: '6fcff650a3c7fdb16f8d327750e06055b9a93d0d', class: "flip-text" }, "\u00A1Voltea tu identificaci\u00F3n!"))), this.showSuccessAnimation && (h("div", { key: 'c4b76ecb19c65969676e5156689c2c0b1c9a584e', class: "success-animation" }, h("div", { key: '12203a8fe7ee878089b3dda1d1142cde5489eed0', class: "check-icon" }), h("div", { key: 'a2d41c8944873d33106994b8d56c3ee1ee1ae9fc', class: "success-text" }, "\u00A1Proceso completado!"))), this.isLoading && (h("div", { key: 'a155cd999fa40c35fa7b391cde7c1026edb250a7', class: "loading-overlay" }, h("div", { key: 'ccba76c5d4a472158c28bc564ba95bd65829b58d', class: "loading-spinner" }), h("div", { key: '23168f9bdcf4e993539288ff5703acaed13bb16a', class: "loading-text" }, this.statusMessage))), h("div", { key: '0107b82ad19726c1bab131e17892a46b04e08cfd', class: "watermark" }, h("img", { key: 'ad8831a6f77fa61805f22e3a27f5c5619ac1cc0e', src: "https://storage.googleapis.com/jaak-static/commons/powered-by-jaak.png", alt: "Powered by Jaak" })))));
1051
+ }
1052
+ };
1053
+ JaakStamps.style = myComponentCss;
1054
+
1055
+ export { JaakStamps as jaak_stamps };
1056
+ //# sourceMappingURL=jaak-stamps.entry.js.map
1057
+
1058
+ //# sourceMappingURL=jaak-stamps.entry.js.map