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