@jaak.ai/stamps 2.0.0-beta.3 → 2.0.0-dev.18

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 (36) hide show
  1. package/README.md +19 -104
  2. package/dist/cjs/{index-BfhtOB0D.js → index-DGM9-FNg.js} +2 -5
  3. package/dist/cjs/index-DGM9-FNg.js.map +1 -0
  4. package/dist/cjs/jaak-stamps-webcomponent.cjs.js +2 -2
  5. package/dist/cjs/jaak-stamps.cjs.entry.js +39 -732
  6. package/dist/cjs/jaak-stamps.cjs.entry.js.map +1 -1
  7. package/dist/cjs/jaak-stamps.entry.cjs.js.map +1 -1
  8. package/dist/cjs/loader.cjs.js +2 -2
  9. package/dist/collection/components/my-component/my-component.css +7 -237
  10. package/dist/collection/components/my-component/my-component.js +38 -855
  11. package/dist/collection/components/my-component/my-component.js.map +1 -1
  12. package/dist/components/index.js +0 -3
  13. package/dist/components/index.js.map +1 -1
  14. package/dist/components/jaak-stamps.js +39 -743
  15. package/dist/components/jaak-stamps.js.map +1 -1
  16. package/dist/esm/{index-BP1Q4KOg.js → index-DqoVMnc7.js} +2 -5
  17. package/dist/esm/index-DqoVMnc7.js.map +1 -0
  18. package/dist/esm/jaak-stamps-webcomponent.js +3 -3
  19. package/dist/esm/jaak-stamps.entry.js +39 -732
  20. package/dist/esm/jaak-stamps.entry.js.map +1 -1
  21. package/dist/esm/loader.js +3 -3
  22. package/dist/jaak-stamps-webcomponent/jaak-stamps-webcomponent.esm.js +1 -1
  23. package/dist/jaak-stamps-webcomponent/jaak-stamps.entry.esm.js.map +1 -1
  24. package/dist/jaak-stamps-webcomponent/p-4688150a.entry.js +2 -0
  25. package/dist/jaak-stamps-webcomponent/p-4688150a.entry.js.map +1 -0
  26. package/dist/jaak-stamps-webcomponent/p-DqoVMnc7.js +3 -0
  27. package/dist/jaak-stamps-webcomponent/p-DqoVMnc7.js.map +1 -0
  28. package/dist/types/components/my-component/my-component.d.ts +2 -54
  29. package/dist/types/components.d.ts +0 -34
  30. package/package.json +1 -1
  31. package/dist/cjs/index-BfhtOB0D.js.map +0 -1
  32. package/dist/esm/index-BP1Q4KOg.js.map +0 -1
  33. package/dist/jaak-stamps-webcomponent/p-14eb13d8.entry.js +0 -2
  34. package/dist/jaak-stamps-webcomponent/p-14eb13d8.entry.js.map +0 -1
  35. package/dist/jaak-stamps-webcomponent/p-BP1Q4KOg.js +0 -3
  36. package/dist/jaak-stamps-webcomponent/p-BP1Q4KOg.js.map +0 -1
@@ -1,6 +1,6 @@
1
- import { r as registerInstance, c as createEvent, a as getElement, h } from './index-BP1Q4KOg.js';
1
+ import { r as registerInstance, c as createEvent, a as getElement, h } from './index-DqoVMnc7.js';
2
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)}.camera-controls{position:absolute;top:16px;right:16px;z-index:25;display:flex;gap:8px;pointer-events:auto}.flip-camera-button{height:40px;padding:0 16px;border:none;border-radius:8px;background:rgba(0, 0, 0, 0.6);backdrop-filter:blur(12px);color:#ffffff;font-size:12px;font-weight:500;cursor:pointer;transition:all 0.2s ease;display:flex;align-items:center;justify-content:center;border:1px solid rgba(255, 255, 255, 0.1);white-space:nowrap;min-width:fit-content}.camera-selector-button{height:40px;padding:0 16px;border:none;border-radius:8px;background:rgba(0, 0, 0, 0.6);backdrop-filter:blur(12px);color:#ffffff;font-size:12px;font-weight:500;cursor:pointer;transition:all 0.2s ease;display:flex;align-items:center;justify-content:center;border:1px solid rgba(255, 255, 255, 0.1);white-space:nowrap;min-width:fit-content}.flip-camera-button:hover,.camera-selector-button:hover{background:rgba(0, 0, 0, 0.8);border-color:rgba(255, 255, 255, 0.2);transform:translateY(-1px)}.flip-camera-button:active,.camera-selector-button:active{transform:translateY(0);background:rgba(0, 0, 0, 0.9)}.camera-selector-dropdown{position:absolute;top:56px;right:16px;z-index:30;background:rgba(0, 0, 0, 0.85);backdrop-filter:blur(20px);border-radius:12px;min-width:260px;max-width:300px;border:1px solid rgba(255, 255, 255, 0.1);overflow:hidden;pointer-events:auto;animation:slideInFromTop 0.3s ease-out}@keyframes slideInFromTop{0%{opacity:0;transform:translateY(-8px) scale(0.95)}100%{opacity:1;transform:translateY(0) scale(1)}}.camera-selector-header{display:flex;justify-content:space-between;align-items:center;padding:12px 16px;border-bottom:1px solid rgba(255, 255, 255, 0.1)}.camera-selector-header span{font-weight:500;color:#ffffff;font-size:13px;opacity:0.9}.close-selector{width:20px;height:20px;border:none;background:none;color:rgba(255, 255, 255, 0.7);font-size:16px;cursor:pointer;display:flex;align-items:center;justify-content:center;border-radius:4px;transition:all 0.2s ease}.close-selector:hover{background:rgba(255, 255, 255, 0.1);color:#ffffff}.camera-list{padding:4px 0;max-height:240px;overflow-y:auto}.camera-option{width:100%;padding:10px 16px;border:none;background:none;text-align:left;cursor:pointer;transition:all 0.2s ease;display:flex;justify-content:space-between;align-items:center;color:rgba(255, 255, 255, 0.9)}.camera-option:hover{background:rgba(255, 255, 255, 0.08)}.camera-option.selected{background:rgba(255, 255, 255, 0.12);color:#ffffff}.camera-label{font-size:13px;flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-right:8px;font-weight:400}.selected-indicator{font-size:14px;color:#ffffff;opacity:0.9}.device-info{padding:8px 16px;border-top:1px solid rgba(255, 255, 255, 0.1);background:rgba(255, 255, 255, 0.05)}.device-info small{color:rgba(255, 255, 255, 0.6);font-size:11px;text-transform:capitalize;font-weight:400}@media (max-width: 480px){.camera-controls{top:12px;right:12px;gap:6px}.flip-camera-button{height:36px;padding:0 12px;font-size:11px;border-radius:6px}.camera-selector-button{height:36px;padding:0 12px;font-size:11px;border-radius:6px}.camera-selector-dropdown{right:12px;top:48px;min-width:240px;max-width:calc(100vw - 24px)}.camera-selector-header{padding:10px 14px}.camera-option{padding:8px 14px}.device-info{padding:6px 14px}}.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)}}";
3
+ const myComponentCss = ":host{display:block;font-family:system-ui, -apple-system, sans-serif;color:#1a1a1a}.detector-container{display:flex;flex-direction:column;align-items:center}h1{font-size:24px;font-weight:500;color:#333;margin:0 0 24px 0}.video-container{position:relative;width:100%;max-width:640px;aspect-ratio:1;background:#fff;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:50%;left:50%;transform:translate(-50%, -50%);width:88%;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
4
 
5
5
  const JaakStamps = class {
6
6
  constructor(hostRef) {
@@ -11,10 +11,6 @@ const JaakStamps = class {
11
11
  get el() { return getElement(this); }
12
12
  debug = false;
13
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
- preferredCamera = 'auto'; // Define qué cámara usar: 'auto' (automático según dispositivo), 'front' (frontal), 'back' (trasera)
18
14
  captureCompleted;
19
15
  isReady;
20
16
  isVideoActive = false;
@@ -39,11 +35,6 @@ const JaakStamps = class {
39
35
  isDetectionPaused = false;
40
36
  isLoading = false;
41
37
  isModelPreloaded = false;
42
- isMaskReady = false;
43
- availableCameras = [];
44
- selectedCameraId = null;
45
- showCameraSelector = false;
46
- isMultipleCamerasAvailable = false;
47
38
  videoRef;
48
39
  canvasRef;
49
40
  session;
@@ -52,11 +43,6 @@ const JaakStamps = class {
52
43
  animationId;
53
44
  hasScreenshotTaken = false;
54
45
  lastDetectedBox;
55
- mobileNetSession;
56
- mobileNetClassMap;
57
- // Camera management properties
58
- deviceType = 'desktop';
59
- preferredCameraFacing = null;
60
46
  // Performance optimization properties
61
47
  frameSkipCounter = 0;
62
48
  FRAME_SKIP = 2; // Process every 3rd frame (reduces CPU by ~66%)
@@ -69,37 +55,16 @@ const JaakStamps = class {
69
55
  preprocessCtx;
70
56
  captureCanvas;
71
57
  captureCtx;
72
- MODEL_PATH = "https://storage.googleapis.com/jaak-static/web/component/stamps/ddmyp-v1.onnx";
73
- MOBILENET_MODEL_PATH = "https://storage.googleapis.com/jaak-static/web/component/stamps/cdmmp-v1.onnx";
74
- MOBILENET_CLASSES_PATH = "https://storage.googleapis.com/jaak-static/web/component/stamps/cdmmp-v1.json";
58
+ MODEL_PATH = "https://storage.googleapis.com/jaak-static/web/component/stamps/detector-nano.onnx";
75
59
  INPUT_SIZE = 320;
76
60
  CONFIDENCE_THRESHOLD = 0.6;
77
- // ISO/IEC 7810 ID-1 standard dimensions (85.60mm x 53.98mm)
78
- ID1_ASPECT_RATIO = 85.60 / 53.98; // 1.5863320574...
61
+ MASK_WIDTH = 280;
62
+ MASK_HEIGHT = 176;
79
63
  debugLog(...args) {
80
64
  if (this.debug) {
81
65
  console.log(...args);
82
66
  }
83
67
  }
84
- validateMaskSize() {
85
- if (this.maskSize < 50 || this.maskSize > 100) {
86
- console.warn(`maskSize debe estar entre 50 y 100. Valor actual: ${this.maskSize}. Usando valor por defecto: 90`);
87
- this.maskSize = 90;
88
- }
89
- }
90
- validateCropMargin() {
91
- if (this.cropMargin < 0 || this.cropMargin > 100) {
92
- console.warn(`cropMargin debe estar entre 0 y 100. Valor actual: ${this.cropMargin}. Usando valor por defecto: 0`);
93
- this.cropMargin = 0;
94
- }
95
- }
96
- validatePreferredCamera() {
97
- const validOptions = ['auto', 'front', 'back'];
98
- if (!validOptions.includes(this.preferredCamera)) {
99
- console.warn(`preferredCamera debe ser uno de: ${validOptions.join(', ')}. Valor actual: ${this.preferredCamera}. Usando valor por defecto: 'auto'`);
100
- this.preferredCamera = 'auto';
101
- }
102
- }
103
68
  emitReadyEvent() {
104
69
  const isDocumentReady = !!window.ort && this.isModelPreloaded;
105
70
  this.isReady.emit(isDocumentReady);
@@ -112,267 +77,7 @@ const JaakStamps = class {
112
77
  const settings = videoTrack.getSettings();
113
78
  return settings.facingMode === 'environment';
114
79
  }
115
- async detectDeviceTypeAndCameras() {
116
- // Detect device type
117
- const userAgent = navigator.userAgent;
118
- const isMobile = /Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent);
119
- const isTablet = /iPad|Android/i.test(userAgent) && window.innerWidth >= 768;
120
- if (isTablet) {
121
- this.deviceType = 'tablet';
122
- }
123
- else if (isMobile) {
124
- this.deviceType = 'mobile';
125
- }
126
- else {
127
- this.deviceType = 'desktop';
128
- }
129
- this.debugLog('📱 Device type detected:', this.deviceType);
130
- // Enumerate available cameras
131
- await this.enumerateAndDetectCameras();
132
- // Load user preference
133
- this.loadCameraPreference();
134
- }
135
- async enumerateAndDetectCameras() {
136
- try {
137
- // First, check if we have permission to enumerate devices
138
- const permissionStatus = await this.checkCameraPermission();
139
- if (permissionStatus === 'denied') {
140
- this.debugLog('❌ Camera permission denied');
141
- this.statusMessage = "Permiso de cámara denegado";
142
- this.statusColor = "#ff6b6b";
143
- return;
144
- }
145
- // Request minimal permission to get device labels
146
- if (permissionStatus === 'prompt') {
147
- const tempStream = await navigator.mediaDevices.getUserMedia({ video: true });
148
- tempStream.getTracks().forEach(track => track.stop());
149
- }
150
- // Now enumerate devices with labels
151
- const devices = await navigator.mediaDevices.enumerateDevices();
152
- this.availableCameras = devices.filter(device => device.kind === 'videoinput');
153
- this.isMultipleCamerasAvailable = this.availableCameras.length > 1;
154
- this.debugLog('📹 Available cameras:', {
155
- count: this.availableCameras.length,
156
- isMultipleCamerasAvailable: this.isMultipleCamerasAvailable,
157
- cameras: this.availableCameras.map(cam => ({
158
- id: cam.deviceId,
159
- label: cam.label || 'Unknown Camera'
160
- }))
161
- });
162
- // Set initial camera preference based on device type
163
- this.setInitialCameraPreference();
164
- }
165
- catch (error) {
166
- this.debugLog('❌ Error enumerating cameras:', error);
167
- this.handleCameraPermissionError(error);
168
- }
169
- }
170
- async checkCameraPermission() {
171
- try {
172
- if (!navigator.permissions) {
173
- return 'prompt'; // Assume we need to prompt on older browsers
174
- }
175
- const permission = await navigator.permissions.query({ name: 'camera' });
176
- return permission.state;
177
- }
178
- catch (error) {
179
- this.debugLog('⚠️ Could not check camera permission:', error);
180
- return 'prompt';
181
- }
182
- }
183
- handleCameraPermissionError(error) {
184
- if (error.name === 'NotAllowedError') {
185
- this.statusMessage = "Permiso de cámara denegado. Active el permiso en configuración.";
186
- this.statusColor = "#ff6b6b";
187
- this.availableCameras = [];
188
- this.isMultipleCamerasAvailable = false;
189
- }
190
- else if (error.name === 'NotFoundError') {
191
- this.statusMessage = "No se encontraron cámaras disponibles.";
192
- this.statusColor = "#ff6b6b";
193
- this.availableCameras = [];
194
- this.isMultipleCamerasAvailable = false;
195
- }
196
- else if (error.name === 'NotReadableError') {
197
- this.statusMessage = "Cámara en uso por otra aplicación.";
198
- this.statusColor = "#ff6b6b";
199
- this.availableCameras = [];
200
- this.isMultipleCamerasAvailable = false;
201
- }
202
- else {
203
- this.statusMessage = "Error al acceder a las cámaras.";
204
- this.statusColor = "#ff6b6b";
205
- this.availableCameras = [];
206
- this.isMultipleCamerasAvailable = false;
207
- }
208
- }
209
- setInitialCameraPreference() {
210
- if (this.availableCameras.length === 0)
211
- return;
212
- // Apply user preference for camera selection
213
- if (this.preferredCamera === 'front') {
214
- // User explicitly wants front camera
215
- this.preferredCameraFacing = 'user';
216
- const frontCamera = this.availableCameras.find(camera => camera.label.toLowerCase().includes('front') ||
217
- camera.label.toLowerCase().includes('user') ||
218
- camera.label.toLowerCase().includes('selfie') ||
219
- !camera.label.toLowerCase().includes('back') && !camera.label.toLowerCase().includes('rear'));
220
- if (frontCamera) {
221
- this.selectedCameraId = frontCamera.deviceId;
222
- this.debugLog('👤 User selected front camera:', frontCamera.label);
223
- }
224
- else {
225
- this.selectedCameraId = this.availableCameras[0].deviceId;
226
- this.debugLog('⚠️ Front camera not found, using first available:', this.availableCameras[0].label);
227
- }
228
- }
229
- else if (this.preferredCamera === 'back') {
230
- // User explicitly wants back camera
231
- this.preferredCameraFacing = 'environment';
232
- const backCamera = this.availableCameras.find(camera => camera.label.toLowerCase().includes('back') ||
233
- camera.label.toLowerCase().includes('rear') ||
234
- camera.label.toLowerCase().includes('environment'));
235
- if (backCamera) {
236
- this.selectedCameraId = backCamera.deviceId;
237
- this.debugLog('📷 User selected back camera:', backCamera.label);
238
- }
239
- else {
240
- this.selectedCameraId = this.availableCameras[0].deviceId;
241
- this.debugLog('⚠️ Back camera not found, using first available:', this.availableCameras[0].label);
242
- }
243
- }
244
- else {
245
- // Auto mode - use device type to determine best camera
246
- if (this.deviceType === 'mobile' || this.deviceType === 'tablet') {
247
- // For mobile/tablet, prefer rear camera for document scanning
248
- this.preferredCameraFacing = 'environment';
249
- const rearCamera = this.availableCameras.find(camera => camera.label.toLowerCase().includes('back') ||
250
- camera.label.toLowerCase().includes('rear') ||
251
- camera.label.toLowerCase().includes('environment'));
252
- if (rearCamera) {
253
- this.selectedCameraId = rearCamera.deviceId;
254
- this.debugLog('📱 Auto-selected rear camera for mobile:', rearCamera.label);
255
- }
256
- else {
257
- this.selectedCameraId = this.availableCameras[0].deviceId;
258
- this.debugLog('📱 Rear camera not found, using first available:', this.availableCameras[0].label);
259
- }
260
- }
261
- else {
262
- // For desktop, use first available camera (usually the only one)
263
- this.selectedCameraId = this.availableCameras[0].deviceId;
264
- this.debugLog('💻 Auto-selected desktop camera:', this.availableCameras[0].label);
265
- }
266
- }
267
- }
268
- loadCameraPreference() {
269
- try {
270
- const saved = localStorage.getItem('jaak-stamps-camera-preference');
271
- if (saved) {
272
- const preference = JSON.parse(saved);
273
- // Validate that the saved camera is still available
274
- const isStillAvailable = this.availableCameras.some(camera => camera.deviceId === preference.cameraId);
275
- if (isStillAvailable) {
276
- this.selectedCameraId = preference.cameraId;
277
- this.preferredCameraFacing = preference.facing;
278
- this.debugLog('💾 Loaded camera preference:', preference);
279
- }
280
- }
281
- }
282
- catch (error) {
283
- this.debugLog('⚠️ Error loading camera preference:', error);
284
- }
285
- }
286
- saveCameraPreference() {
287
- try {
288
- const preference = {
289
- cameraId: this.selectedCameraId,
290
- facing: this.preferredCameraFacing,
291
- timestamp: Date.now()
292
- };
293
- localStorage.setItem('jaak-stamps-camera-preference', JSON.stringify(preference));
294
- this.debugLog('💾 Saved camera preference:', preference);
295
- }
296
- catch (error) {
297
- this.debugLog('⚠️ Error saving camera preference:', error);
298
- }
299
- }
300
- async switchCamera(cameraId) {
301
- if (!this.isVideoActive || this.selectedCameraId === cameraId)
302
- return;
303
- try {
304
- // Check if the selected camera is still available
305
- const selectedCamera = this.availableCameras.find(cam => cam.deviceId === cameraId);
306
- if (!selectedCamera) {
307
- this.debugLog('❌ Selected camera not found, re-enumerating...');
308
- await this.enumerateAndDetectCameras();
309
- return;
310
- }
311
- // Show loading state
312
- this.statusMessage = "Cambiando cámara...";
313
- this.statusColor = "#007bff";
314
- // Stop current stream
315
- if (this.videoStream) {
316
- this.videoStream.getTracks().forEach(track => track.stop());
317
- }
318
- // Update selected camera
319
- this.selectedCameraId = cameraId;
320
- // Update facing mode preference
321
- const isRearCamera = selectedCamera.label.toLowerCase().includes('back') ||
322
- selectedCamera.label.toLowerCase().includes('rear') ||
323
- selectedCamera.label.toLowerCase().includes('environment');
324
- this.preferredCameraFacing = isRearCamera ? 'environment' : 'user';
325
- // Save preference
326
- this.saveCameraPreference();
327
- // Setup new camera with error handling
328
- await this.setupCameraWithRetry();
329
- this.debugLog('🔄 Switched to camera:', selectedCamera.label);
330
- }
331
- catch (error) {
332
- this.debugLog('❌ Error switching camera:', error);
333
- this.handleCameraPermissionError(error);
334
- }
335
- }
336
- async setupCameraWithRetry(maxRetries = 3) {
337
- for (let attempt = 1; attempt <= maxRetries; attempt++) {
338
- try {
339
- await this.setupCamera();
340
- return; // Success
341
- }
342
- catch (error) {
343
- this.debugLog(`❌ Camera setup attempt ${attempt} failed:`, error);
344
- if (attempt === maxRetries) {
345
- // Last attempt failed, handle the error
346
- this.handleCameraPermissionError(error);
347
- throw error;
348
- }
349
- // Wait before retrying
350
- await new Promise(resolve => setTimeout(resolve, 500 * attempt));
351
- }
352
- }
353
- }
354
- toggleCameraSelector() {
355
- this.showCameraSelector = !this.showCameraSelector;
356
- this.debugLog('📹 Camera selector toggled:', {
357
- showCameraSelector: this.showCameraSelector,
358
- isMultipleCamerasAvailable: this.isMultipleCamerasAvailable,
359
- availableCameras: this.availableCameras.length,
360
- isVideoActive: this.isVideoActive
361
- });
362
- }
363
- async flipCamera() {
364
- if (!this.isMultipleCamerasAvailable)
365
- return;
366
- const currentIndex = this.availableCameras.findIndex(camera => camera.deviceId === this.selectedCameraId);
367
- const nextIndex = (currentIndex + 1) % this.availableCameras.length;
368
- const nextCamera = this.availableCameras[nextIndex];
369
- await this.switchCamera(nextCamera.deviceId);
370
- }
371
80
  async componentDidLoad() {
372
- this.validateMaskSize();
373
- this.validateCropMargin();
374
- this.validatePreferredCamera();
375
- await this.detectDeviceTypeAndCameras();
376
81
  if (!window.ort) {
377
82
  const script = document.createElement('script');
378
83
  script.src = 'https://cdn.jsdelivr.net/npm/onnxruntime-web/dist/ort.min.js';
@@ -388,92 +93,6 @@ const JaakStamps = class {
388
93
  }
389
94
  // Initialize canvas pool for better performance
390
95
  this.initializeCanvasPool();
391
- this.setupResizeObserver();
392
- }
393
- setupResizeObserver() {
394
- if ('ResizeObserver' in window && this.canvasRef) {
395
- const resizeObserver = new ResizeObserver(() => {
396
- this.handleResize();
397
- });
398
- resizeObserver.observe(this.canvasRef.parentElement);
399
- }
400
- }
401
- handleResize() {
402
- if (this.canvasRef) {
403
- const container = this.canvasRef.parentElement;
404
- const rect = container.getBoundingClientRect();
405
- // Set canvas size to match container
406
- this.canvasRef.width = rect.width;
407
- this.canvasRef.height = rect.height;
408
- // Update mask positioning based on container and video dimensions
409
- this.updateMaskDimensions(rect);
410
- this.debugLog('📐 Canvas resized:', { width: rect.width, height: rect.height });
411
- }
412
- }
413
- updateMaskDimensions(containerRect) {
414
- if (!this.videoRef)
415
- return;
416
- const videoWidth = this.videoRef.videoWidth;
417
- const videoHeight = this.videoRef.videoHeight;
418
- if (videoWidth === 0 || videoHeight === 0)
419
- return;
420
- // Calculate video aspect ratio and container aspect ratio
421
- const videoAspectRatio = videoWidth / videoHeight;
422
- const containerAspectRatio = containerRect.width / containerRect.height;
423
- // Determine how video fits in container (letterboxed or pillarboxed)
424
- let displayedVideoWidth, displayedVideoHeight;
425
- let videoOffsetX = 0, videoOffsetY = 0;
426
- if (videoAspectRatio > containerAspectRatio) {
427
- // Video is wider - letterboxed (black bars top/bottom)
428
- displayedVideoWidth = containerRect.width;
429
- displayedVideoHeight = containerRect.width / videoAspectRatio;
430
- videoOffsetY = (containerRect.height - displayedVideoHeight) / 2;
431
- }
432
- else {
433
- // Video is taller - pillarboxed (black bars left/right)
434
- displayedVideoHeight = containerRect.height;
435
- displayedVideoWidth = containerRect.height * videoAspectRatio;
436
- videoOffsetX = (containerRect.width - displayedVideoWidth) / 2;
437
- }
438
- // Calculate maximum possible mask size while preserving exact ID-1 aspect ratio
439
- // Determine the limiting dimension based on video orientation and ID-1 proportions
440
- // Calculate what would be the max width if limited by video height
441
- const maxWidthByHeight = displayedVideoHeight * this.ID1_ASPECT_RATIO;
442
- let maskWidthInVideo, maskHeightInVideo;
443
- const sizeRatio = this.maskSize / 100;
444
- if (maxWidthByHeight <= displayedVideoWidth) {
445
- // Video height is the limiting factor
446
- maskHeightInVideo = displayedVideoHeight * sizeRatio;
447
- maskWidthInVideo = maskHeightInVideo * this.ID1_ASPECT_RATIO;
448
- }
449
- else {
450
- // Video width is the limiting factor
451
- maskWidthInVideo = displayedVideoWidth * sizeRatio;
452
- maskHeightInVideo = maskWidthInVideo / this.ID1_ASPECT_RATIO;
453
- }
454
- // Convert to percentages of the container
455
- const maskWidthPercent = (maskWidthInVideo / containerRect.width) * 100;
456
- const maskHeightPercent = (maskHeightInVideo / containerRect.height) * 100;
457
- // Calculate the center position of the displayed video area
458
- const videoCenterX = videoOffsetX + (displayedVideoWidth / 2);
459
- const videoCenterY = videoOffsetY + (displayedVideoHeight / 2);
460
- // Convert to percentages of the container
461
- const videoCenterXPercent = (videoCenterX / containerRect.width) * 100;
462
- const videoCenterYPercent = (videoCenterY / containerRect.height) * 100;
463
- // Update CSS custom properties for mask sizing and positioning
464
- this.el.style.setProperty('--mask-width', `${maskWidthPercent}%`);
465
- this.el.style.setProperty('--mask-height', `${maskHeightPercent}%`);
466
- this.el.style.setProperty('--mask-center-x', `${videoCenterXPercent}%`);
467
- this.el.style.setProperty('--mask-center-y', `${videoCenterYPercent}%`);
468
- // Mark mask as ready now that dimensions are calculated
469
- this.isMaskReady = true;
470
- this.debugLog('🎯 Mask dimensions updated:', {
471
- video: { width: videoWidth, height: videoHeight },
472
- displayed: { width: displayedVideoWidth, height: displayedVideoHeight },
473
- mask: { widthPercent: maskWidthPercent, heightPercent: maskHeightPercent },
474
- center: { x: videoCenterXPercent, y: videoCenterYPercent },
475
- offset: { x: videoOffsetX, y: videoOffsetY }
476
- });
477
96
  }
478
97
  initializeCanvasPool() {
479
98
  // Preprocess canvas - reused for every inference
@@ -542,29 +161,25 @@ const JaakStamps = class {
542
161
  }
543
162
  try {
544
163
  this.isLoading = true;
545
- this.statusMessage = "Precargando modelos...";
164
+ this.statusMessage = "Precargando modelo de detección...";
546
165
  this.statusColor = "#007bff";
547
166
  const modelPath = this.MODEL_PATH;
548
- this.debugLog('🤖 Preloading detection model:', modelPath);
167
+ this.debugLog('🤖 Preloading model:', modelPath);
549
168
  // Configure ONNX Runtime with device-specific optimizations
550
169
  const sessionOptions = this.getSessionOptions();
551
170
  this.session = await window.ort.InferenceSession.create(modelPath, sessionOptions);
552
- // Preload MobileNet model and classes only if classification is enabled
553
- if (this.useDocumentClassification) {
554
- await this.loadMobileNetModel();
555
- }
556
171
  this.isModelPreloaded = true;
557
172
  this.isLoading = false;
558
- this.statusMessage = "Modelos precargados. Listo para comenzar detección";
173
+ this.statusMessage = "Modelo precargado. Listo para comenzar detección";
559
174
  this.statusColor = "#28a745";
560
175
  this.emitReadyEvent();
561
- this.debugLog('✅ Models preloaded successfully');
562
- return { success: true, message: 'Models preloaded successfully' };
176
+ this.debugLog('✅ Model preloaded successfully');
177
+ return { success: true, message: 'Model preloaded successfully' };
563
178
  }
564
179
  catch (error) {
565
- this.debugLog('❌ Error preloading models:', error);
180
+ this.debugLog('❌ Error preloading model:', error);
566
181
  this.isLoading = false;
567
- this.statusMessage = "Error al precargar los modelos";
182
+ this.statusMessage = "Error al precargar el modelo";
568
183
  this.statusColor = "#ff6b6b";
569
184
  return { success: false, error: error.message };
570
185
  }
@@ -574,109 +189,6 @@ const JaakStamps = class {
574
189
  this.completeProcess(true);
575
190
  }
576
191
  }
577
- async getCameraInfo() {
578
- return {
579
- availableCameras: this.availableCameras.map(camera => ({
580
- id: camera.deviceId,
581
- label: camera.label || 'Unknown Camera',
582
- selected: camera.deviceId === this.selectedCameraId
583
- })),
584
- selectedCameraId: this.selectedCameraId,
585
- deviceType: this.deviceType,
586
- isMultipleCamerasAvailable: this.isMultipleCamerasAvailable,
587
- preferredFacing: this.preferredCameraFacing,
588
- userPreferredCamera: this.preferredCamera
589
- };
590
- }
591
- async setPreferredCamera(camera) {
592
- this.preferredCamera = camera;
593
- this.debugLog('🎯 Camera preference changed to:', camera);
594
- // Re-detect and apply new camera preference
595
- await this.enumerateAndDetectCameras();
596
- // If video is active, switch to the new preferred camera
597
- if (this.isVideoActive && this.selectedCameraId) {
598
- await this.switchCamera(this.selectedCameraId);
599
- }
600
- return {
601
- success: true,
602
- selectedCamera: this.selectedCameraId,
603
- availableCameras: this.availableCameras.length
604
- };
605
- }
606
- async loadMobileNetModel() {
607
- try {
608
- this.debugLog('🤖 Loading MobileNet model...');
609
- // Load class map
610
- const classResponse = await fetch(this.MOBILENET_CLASSES_PATH);
611
- if (!classResponse.ok) {
612
- throw new Error(`Failed to load class map: ${this.MOBILENET_CLASSES_PATH}`);
613
- }
614
- this.mobileNetClassMap = await classResponse.json();
615
- this.debugLog('📋 MobileNet classes loaded:', this.mobileNetClassMap);
616
- // Load model
617
- const sessionOptions = this.getSessionOptions();
618
- this.mobileNetSession = await window.ort.InferenceSession.create(this.MOBILENET_MODEL_PATH, sessionOptions);
619
- this.debugLog('✅ MobileNet model loaded successfully');
620
- }
621
- catch (error) {
622
- this.debugLog('❌ Error loading MobileNet model:', error);
623
- throw error;
624
- }
625
- }
626
- preprocessMobileNet(canvas) {
627
- // Create a temporary canvas for MobileNet preprocessing (224x224)
628
- const tempCanvas = document.createElement('canvas');
629
- tempCanvas.width = 224;
630
- tempCanvas.height = 224;
631
- const tempCtx = tempCanvas.getContext('2d');
632
- // Draw the cropped image onto the 224x224 canvas
633
- tempCtx.drawImage(canvas, 0, 0, 224, 224);
634
- // Get image data and preprocess for MobileNet
635
- const imageData = tempCtx.getImageData(0, 0, 224, 224);
636
- const data = imageData.data;
637
- const hw = 224 * 224;
638
- const arr = new Float32Array(3 * hw);
639
- // Normalize pixels: (pixel/255 - 0.5) / 0.5 = (pixel - 127.5) / 127.5
640
- for (let i = 0; i < hw; i++) {
641
- arr[i] = (data[i * 4 + 0] / 255 - 0.5) / 0.5; // R
642
- arr[hw + i] = (data[i * 4 + 1] / 255 - 0.5) / 0.5; // G
643
- arr[2 * hw + i] = (data[i * 4 + 2] / 255 - 0.5) / 0.5; // B
644
- }
645
- return new window.ort.Tensor('float32', arr, [1, 3, 224, 224]);
646
- }
647
- async classifyDocument(canvas) {
648
- if (!this.mobileNetSession || !this.mobileNetClassMap) {
649
- this.debugLog('⚠️ MobileNet model not loaded');
650
- return null;
651
- }
652
- try {
653
- this.debugLog('🔍 Classifying document...');
654
- // Preprocess image for MobileNet
655
- const inputTensor = this.preprocessMobileNet(canvas);
656
- // Run inference
657
- const feeds = { input: inputTensor };
658
- const results = await this.mobileNetSession.run(feeds);
659
- const output = results[Object.keys(results)[0]].data;
660
- // Find the class with highest confidence
661
- const maxIdx = output.reduce((bestIdx, val, idx, arr) => val > arr[bestIdx] ? idx : bestIdx, 0);
662
- const confidence = output[maxIdx];
663
- const className = this.mobileNetClassMap[maxIdx.toString()] || "unknown";
664
- this.debugLog('📄 Document classification result:', {
665
- class: className,
666
- confidence: confidence.toFixed(3),
667
- classIndex: maxIdx
668
- });
669
- return {
670
- class: className,
671
- confidence: confidence,
672
- classIndex: maxIdx
673
- };
674
- }
675
- catch (error) {
676
- this.debugLog('❌ Error classifying document:', error);
677
- return null;
678
- }
679
- }
680
192
  cleanup() {
681
193
  if (this.animationId) {
682
194
  cancelAnimationFrame(this.animationId);
@@ -704,102 +216,22 @@ const JaakStamps = class {
704
216
  this.captureCtx = undefined;
705
217
  this.captureCanvas = undefined;
706
218
  }
707
- // Disposed ONNX sessions
219
+ // Disposed ONNX session
708
220
  if (this.session) {
709
221
  this.session.release?.();
710
222
  this.session = undefined;
711
223
  }
712
- if (this.mobileNetSession) {
713
- this.mobileNetSession.release?.();
714
- this.mobileNetSession = undefined;
715
- }
716
- this.mobileNetClassMap = undefined;
717
224
  this.isModelPreloaded = false;
718
225
  this.debugLog('🧹 Canvas pool cleaned up');
719
226
  }
720
- async getMaxResolution() {
721
- try {
722
- // Build constraints with selected camera if available
723
- const videoConstraints = {};
724
- if (this.selectedCameraId) {
725
- videoConstraints.deviceId = { exact: this.selectedCameraId };
726
- }
727
- else if (this.preferredCameraFacing) {
728
- videoConstraints.facingMode = this.preferredCameraFacing;
729
- }
730
- else {
731
- videoConstraints.facingMode = "environment";
732
- }
733
- // Get temporary stream to access capabilities
734
- const tempStream = await navigator.mediaDevices.getUserMedia({
735
- video: videoConstraints
736
- });
737
- const videoTrack = tempStream.getVideoTracks()[0];
738
- const capabilities = videoTrack.getCapabilities();
739
- // Detener el stream temporal
740
- tempStream.getTracks().forEach(track => track.stop());
741
- // Build constraints with resolution optimized for tablets
742
- const constraints = {};
743
- // Set camera selection constraints
744
- if (this.selectedCameraId) {
745
- constraints.deviceId = { exact: this.selectedCameraId };
746
- }
747
- else if (this.preferredCameraFacing) {
748
- constraints.facingMode = this.preferredCameraFacing;
749
- }
750
- else {
751
- constraints.facingMode = "environment";
752
- }
753
- if (capabilities.width && capabilities.height) {
754
- // Limitar resolución máxima para tablets para evitar problemas de rendimiento
755
- const maxWidth = Math.min(capabilities.width.max, 1920);
756
- const maxHeight = Math.min(capabilities.height.max, 1080);
757
- // Para tablets, usar resolución moderada en lugar de máxima
758
- const isTablet = /iPad|Android/i.test(navigator.userAgent) && window.innerWidth >= 768;
759
- if (isTablet) {
760
- constraints.width = { ideal: Math.min(maxWidth, 1280) };
761
- constraints.height = { ideal: Math.min(maxHeight, 720) };
762
- }
763
- else {
764
- constraints.width = { ideal: maxWidth };
765
- constraints.height = { ideal: maxHeight };
766
- }
767
- this.debugLog('📐 Resolution capabilities:', {
768
- maxWidth: capabilities.width.max,
769
- maxHeight: capabilities.height.max,
770
- selectedWidth: constraints.width.ideal,
771
- selectedHeight: constraints.height.ideal,
772
- isTablet
773
- });
774
- }
775
- return constraints;
776
- }
777
- catch (err) {
778
- this.debugLog('⚠️ Could not get capabilities, using fallback');
779
- // Optimized fallback for tablets
780
- const isTablet = /iPad|Android/i.test(navigator.userAgent) && window.innerWidth >= 768;
781
- const fallbackConstraints = {
782
- width: { ideal: isTablet ? 1280 : 1920 },
783
- height: { ideal: isTablet ? 720 : 1080 }
784
- };
785
- // Add camera selection to fallback
786
- if (this.selectedCameraId) {
787
- fallbackConstraints.deviceId = { exact: this.selectedCameraId };
788
- }
789
- else if (this.preferredCameraFacing) {
790
- fallbackConstraints.facingMode = this.preferredCameraFacing;
791
- }
792
- else {
793
- fallbackConstraints.facingMode = "environment";
794
- }
795
- return fallbackConstraints;
796
- }
797
- }
798
227
  async setupCamera() {
799
228
  try {
800
- const constraints = await this.getMaxResolution();
801
229
  const stream = await navigator.mediaDevices.getUserMedia({
802
- video: constraints,
230
+ video: {
231
+ width: { exact: 640 },
232
+ height: { exact: 640 },
233
+ facingMode: "environment"
234
+ },
803
235
  audio: false
804
236
  });
805
237
  if (this.videoRef) {
@@ -814,12 +246,6 @@ const JaakStamps = class {
814
246
  this.videoRef.onloadedmetadata = async () => {
815
247
  await this.videoRef.play();
816
248
  this.isVideoActive = true;
817
- // Update mask dimensions once video is loaded
818
- if (this.canvasRef) {
819
- const container = this.canvasRef.parentElement;
820
- const rect = container.getBoundingClientRect();
821
- this.updateMaskDimensions(rect);
822
- }
823
249
  resolve();
824
250
  };
825
251
  });
@@ -827,7 +253,8 @@ const JaakStamps = class {
827
253
  }
828
254
  catch (err) {
829
255
  this.debugLog("❌ No se pudo acceder a la cámara:", err);
830
- this.handleCameraPermissionError(err);
256
+ this.statusMessage = "Error: No se pudo acceder a la cámara.";
257
+ this.statusColor = "#ff6b6b";
831
258
  }
832
259
  }
833
260
  preprocess(video) {
@@ -872,22 +299,18 @@ const JaakStamps = class {
872
299
  // Check if model is already preloaded
873
300
  if (!this.session) {
874
301
  this.isLoading = true;
875
- this.statusMessage = "Cargando modelos...";
302
+ this.statusMessage = "Cargando modelo de detección...";
876
303
  this.statusColor = "#007bff";
877
304
  const modelPath = this.MODEL_PATH;
878
- this.debugLog('🤖 Loading detection model:', modelPath);
305
+ this.debugLog('🤖 Loading model:', modelPath);
879
306
  const sessionOptions = this.getSessionOptions();
880
307
  this.session = await window.ort.InferenceSession.create(modelPath, sessionOptions);
881
- // Load MobileNet model if classification is enabled and not already loaded
882
- if (this.useDocumentClassification && !this.mobileNetSession) {
883
- await this.loadMobileNetModel();
884
- }
885
308
  this.isModelPreloaded = true;
886
309
  this.emitReadyEvent();
887
310
  }
888
311
  else {
889
- this.debugLog('🚀 Using preloaded models');
890
- this.statusMessage = "Usando modelos precargados...";
312
+ this.debugLog('🚀 Using preloaded model');
313
+ this.statusMessage = "Usando modelo precargado...";
891
314
  this.statusColor = "#007bff";
892
315
  }
893
316
  this.statusMessage = "Configurando cámara...";
@@ -1000,58 +423,13 @@ const JaakStamps = class {
1000
423
  return isCentered && isGoodSize;
1001
424
  }
1002
425
  checkSideAlignment(box) {
1003
- if (!this.videoRef)
1004
- return { top: false, right: false, bottom: false, left: false };
1005
- // Get video dimensions to calculate actual mask boundaries in model space
1006
- const videoWidth = this.videoRef.videoWidth;
1007
- const videoHeight = this.videoRef.videoHeight;
1008
- if (videoWidth === 0 || videoHeight === 0) {
1009
- return { top: false, right: false, bottom: false, left: false };
1010
- }
1011
- // Calculate video aspect ratio
1012
- const videoAspectRatio = videoWidth / videoHeight;
1013
- // The model sees video stretched to 320x320, but we need to calculate where
1014
- // the mask should be in this distorted space to match the visual mask
1015
- // In the visual display, we calculate mask size based on the limiting dimension
1016
- // We need to replicate this logic but account for the distortion in model space
1017
- // Calculate the "display" dimensions (what the visual mask calculations use)
1018
- const containerAspectRatio = 1; // Assume square container for simplicity
1019
- let displayedVideoWidth, displayedVideoHeight;
1020
- if (videoAspectRatio > containerAspectRatio) {
1021
- // Video is wider - letterboxed in display
1022
- displayedVideoWidth = this.INPUT_SIZE;
1023
- displayedVideoHeight = this.INPUT_SIZE / videoAspectRatio;
1024
- }
1025
- else {
1026
- // Video is taller - pillarboxed in display
1027
- displayedVideoHeight = this.INPUT_SIZE;
1028
- displayedVideoWidth = this.INPUT_SIZE * videoAspectRatio;
1029
- }
1030
- // Calculate mask dimensions using the same logic as updateMaskDimensions
1031
- const maxWidthByHeight = displayedVideoHeight * this.ID1_ASPECT_RATIO;
1032
- let visualMaskWidth, visualMaskHeight;
1033
- const sizeRatio = this.maskSize / 100;
1034
- if (maxWidthByHeight <= displayedVideoWidth) {
1035
- // Video height is the limiting factor
1036
- visualMaskHeight = displayedVideoHeight * sizeRatio;
1037
- visualMaskWidth = visualMaskHeight * this.ID1_ASPECT_RATIO;
1038
- }
1039
- else {
1040
- // Video width is the limiting factor
1041
- visualMaskWidth = displayedVideoWidth * sizeRatio;
1042
- visualMaskHeight = visualMaskWidth / this.ID1_ASPECT_RATIO;
1043
- }
1044
- // Now map these visual mask dimensions to the distorted model space
1045
- // The model stretches video to 320x320, so we need to apply the inverse transformation
1046
- const modelMaskWidth = visualMaskWidth * (this.INPUT_SIZE / displayedVideoWidth);
1047
- const modelMaskHeight = visualMaskHeight * (this.INPUT_SIZE / displayedVideoHeight);
1048
- // Calculate mask boundaries in model coordinate system (always centered in 320x320)
426
+ // Obtener las coordenadas del marco de referencia (máscara)
1049
427
  const maskCenterX = this.INPUT_SIZE / 2;
1050
428
  const maskCenterY = this.INPUT_SIZE / 2;
1051
- const maskLeft = maskCenterX - (modelMaskWidth / 2);
1052
- const maskRight = maskCenterX + (modelMaskWidth / 2);
1053
- const maskTop = maskCenterY - (modelMaskHeight / 2);
1054
- const maskBottom = maskCenterY + (modelMaskHeight / 2);
429
+ const maskLeft = maskCenterX - (this.MASK_WIDTH / 2);
430
+ const maskRight = maskCenterX + (this.MASK_WIDTH / 2);
431
+ const maskTop = maskCenterY - (this.MASK_HEIGHT / 2);
432
+ const maskBottom = maskCenterY + (this.MASK_HEIGHT / 2);
1055
433
  // Obtener las coordenadas del documento detectado
1056
434
  let docLeft = box.x;
1057
435
  let docRight = box.x + box.w;
@@ -1106,9 +484,7 @@ const JaakStamps = class {
1106
484
  corners?.forEach(corner => corner.classList.add('perfect-match'));
1107
485
  if (!this.hasScreenshotTaken) {
1108
486
  this.lastDetectedBox = bestBox;
1109
- this.takeScreenshot().catch(error => {
1110
- this.debugLog('❌ Error taking screenshot:', error);
1111
- });
487
+ this.takeScreenshot();
1112
488
  this.hasScreenshotTaken = true;
1113
489
  // Reset para permitir segunda captura
1114
490
  setTimeout(() => {
@@ -1150,48 +526,15 @@ const JaakStamps = class {
1150
526
  }
1151
527
  }
1152
528
  drawDetections(ctx, boxes) {
1153
- if (!this.videoRef)
1154
- return;
1155
- // Get video and container dimensions
1156
- const videoWidth = this.videoRef.videoWidth;
1157
- const videoHeight = this.videoRef.videoHeight;
1158
- const containerWidth = this.canvasRef.width;
1159
- const containerHeight = this.canvasRef.height;
1160
- if (videoWidth === 0 || videoHeight === 0)
1161
- return;
1162
- // Calculate video aspect ratio and container aspect ratio
1163
- const videoAspectRatio = videoWidth / videoHeight;
1164
- const containerAspectRatio = containerWidth / containerHeight;
1165
- // Determine how video fits in container (same logic as updateMaskDimensions)
1166
- let displayedVideoWidth, displayedVideoHeight;
1167
- let videoOffsetX = 0, videoOffsetY = 0;
1168
- if (videoAspectRatio > containerAspectRatio) {
1169
- // Video is wider - letterboxed (black bars top/bottom)
1170
- displayedVideoWidth = containerWidth;
1171
- displayedVideoHeight = containerWidth / videoAspectRatio;
1172
- videoOffsetY = (containerHeight - displayedVideoHeight) / 2;
1173
- }
1174
- else {
1175
- // Video is taller - pillarboxed (black bars left/right)
1176
- displayedVideoHeight = containerHeight;
1177
- displayedVideoWidth = containerHeight * videoAspectRatio;
1178
- videoOffsetX = (containerWidth - displayedVideoWidth) / 2;
1179
- }
1180
- // Scale factor from model coordinates (320x320) to displayed video area
1181
- const scaleX = displayedVideoWidth / this.INPUT_SIZE;
1182
- const scaleY = displayedVideoHeight / this.INPUT_SIZE;
529
+ // Scale factor to convert from model coordinates (320x320) to canvas coordinates (640x640)
530
+ const scale = this.canvasRef.width / this.INPUT_SIZE;
1183
531
  boxes.forEach(det => {
1184
- // Convert model coordinates to displayed video coordinates
1185
- const x = det.x * scaleX + videoOffsetX;
1186
- const y = det.y * scaleY + videoOffsetY;
1187
- const w = det.w * scaleX;
1188
- const h = det.h * scaleY;
1189
532
  ctx.strokeStyle = "#32406C";
1190
533
  ctx.lineWidth = 2;
1191
- ctx.strokeRect(x, y, w, h);
534
+ ctx.strokeRect(det.x * scale, det.y * scale, det.w * scale, det.h * scale);
1192
535
  });
1193
536
  }
1194
- async takeScreenshot() {
537
+ takeScreenshot() {
1195
538
  if (!this.videoRef || !this.lastDetectedBox)
1196
539
  return;
1197
540
  // Activar animación
@@ -1207,10 +550,10 @@ const JaakStamps = class {
1207
550
  // Calcular las coordenadas de recorte basadas en la detección
1208
551
  const scaleX = this.videoRef.videoWidth / this.INPUT_SIZE;
1209
552
  const scaleY = this.videoRef.videoHeight / this.INPUT_SIZE;
1210
- const cropX = Math.max(0, (this.lastDetectedBox.x * scaleX) - this.cropMargin);
1211
- const cropY = Math.max(0, (this.lastDetectedBox.y * scaleY) - this.cropMargin);
1212
- const cropWidth = Math.min((this.lastDetectedBox.w * scaleX) + (2 * this.cropMargin), this.videoRef.videoWidth - cropX);
1213
- const cropHeight = Math.min((this.lastDetectedBox.h * scaleY) + (2 * this.cropMargin), this.videoRef.videoHeight - cropY);
553
+ const cropX = Math.max(0, this.lastDetectedBox.x * scaleX);
554
+ const cropY = Math.max(0, this.lastDetectedBox.y * scaleY);
555
+ const cropWidth = Math.min(this.lastDetectedBox.w * scaleX, this.videoRef.videoWidth - cropX);
556
+ const cropHeight = Math.min(this.lastDetectedBox.h * scaleY, this.videoRef.videoHeight - cropY);
1214
557
  // OPTIMIZATION: Create temporary canvas only for cropped version
1215
558
  // (We reuse main capture canvas for full frame)
1216
559
  const croppedCanvas = document.createElement('canvas');
@@ -1225,29 +568,6 @@ const JaakStamps = class {
1225
568
  // Captura del frente usando canvas reutilizado
1226
569
  this.capturedFullFrame = this.captureCanvas.toDataURL('image/png');
1227
570
  this.capturedCroppedId = croppedCanvas.toDataURL('image/png');
1228
- // Check if document classification is enabled
1229
- if (this.useDocumentClassification) {
1230
- // Load MobileNet model if not loaded yet (lazy loading)
1231
- if (!this.mobileNetSession) {
1232
- try {
1233
- await this.loadMobileNetModel();
1234
- }
1235
- catch (error) {
1236
- this.debugLog('⚠️ Failed to load classification model, continuing without classification:', error);
1237
- }
1238
- }
1239
- // Classify the cropped document if model is available
1240
- if (this.mobileNetSession) {
1241
- const classification = await this.classifyDocument(croppedCanvas);
1242
- if (classification && classification.class === 'passport') {
1243
- // If it's a passport, skip back capture since passports don't have a back side
1244
- this.debugLog('📄 Passport detected - skipping back capture');
1245
- this.completeProcess(true);
1246
- return;
1247
- }
1248
- }
1249
- }
1250
- // For other IDs, continue with normal flow (back capture)
1251
571
  this.captureStep = 'back';
1252
572
  this.statusMessage = "Voltee la identificación y muestre la parte trasera";
1253
573
  this.statusColor = "#007bff";
@@ -1377,20 +697,7 @@ const JaakStamps = class {
1377
697
  this.cleanup();
1378
698
  }
1379
699
  render() {
1380
- return (h("div", { key: 'b90673f523dbf112786eb7184f56415055765c0c', class: "detector-container" }, h("div", { key: '925c5c886e9af53b460281244958e722de670a70', class: "video-container" }, h("video", { key: '4a0074e33a81b4694c6c99e3ece256c1ac8fe1d5', ref: el => this.videoRef = el, autoplay: true, muted: true, playsinline: true, class: this.shouldMirrorVideo ? 'mirror' : '', style: { display: this.isVideoActive ? 'block' : 'none' } }), h("canvas", { key: 'a7b7f3b35c0535c11f6a4a155502dbe016f590b7', ref: el => this.canvasRef = el, class: this.shouldMirrorVideo ? 'mirror' : '' }), this.isMaskReady && (h("div", { key: '695b6a2f97e29b0b9c5b9d43682a951caff376a1', class: "overlay-mask" }, h("div", { key: '768875c39d5917c6a04306037d03d9e1aed114bd', class: "card-outline" }, h("div", { key: 'a56536deb7b8c99145d1bef6fee84e5801798644', class: "side side-top" }), h("div", { key: 'df413058c7e787f9c8a95a429a4f7186de07f5f6', class: "side side-right" }), h("div", { key: '37e074e3d4c914457f97720f9ab1f1ac2c70c4f1', class: "side side-bottom" }), h("div", { key: '772d3d40925c75ba5d39e2e7dd6405f7cc88d292', class: "side side-left" }), h("div", { key: 'd4e624782b3f4b4b8dbb8286b3acf003e433928c', class: "corner corner-tl" }), h("div", { key: '63f0ccfbbe3c1d413ca6912f36cab4afa6334bb2', class: "corner corner-tr" }), h("div", { key: '20012a50fe3d98ddfa669f5283a871c757522797', class: "corner corner-bl" }), h("div", { key: '9d82646bd08a6ca2b8c5782629fc68fd93cf1287', class: "corner corner-br" }), !this.showFlipAnimation && !this.showSuccessAnimation && (h("div", { key: '79fcbdb52e434a45aa6f2748d6d84500beb2e844', class: "guide-text" }, this.statusMessage))), this.captureStep === 'back' && !this.showFlipAnimation && !this.showSuccessAnimation && (h("button", { key: '16e587d645e2489a3410fe80bfc014738f08f02f', class: "skip-button", onClick: () => this.skipBackCapture(), type: "button" }, "Saltar reverso")), this.isVideoActive && (h("div", { key: 'd46d6881a9e1b63bdd849f5a8c6e96a2caefdefb', class: "camera-controls" }, this.isMultipleCamerasAvailable && (h("button", { key: 'afb4b44d691471f8af6e894e061aecb6c82259da', class: "flip-camera-button", onClick: () => this.flipCamera(), type: "button", title: "Cambiar c\u00E1mara" }, "Girar c\u00E1mara")), h("button", { key: '4e0680c2da9e6cc70b5880e8f5db9830c080acf9', class: "camera-selector-button", onClick: () => this.toggleCameraSelector(), type: "button", title: "Seleccionar c\u00E1mara" }, "C\u00E1maras"), this.debug && (h("div", { key: 'fc59922452a216273f742d3158559f6b2a1da43e', style: {
1381
- position: 'absolute',
1382
- top: '50px',
1383
- right: '0',
1384
- background: 'rgba(0,0,0,0.8)',
1385
- color: 'white',
1386
- padding: '8px',
1387
- fontSize: '10px',
1388
- borderRadius: '4px',
1389
- whiteSpace: 'nowrap'
1390
- } }, "C\u00E1maras: ", this.availableCameras.length, h("br", { key: '8f112283d1e0518a395dc6d94e1caa46fee0a86b' }), "M\u00FAltiples: ", this.isMultipleCamerasAvailable ? 'Sí' : 'No', h("br", { key: 'aacfd3ee868ee5d0819ce5ef693e3ef384867332' }), "Selector: ", this.showCameraSelector ? 'Visible' : 'Oculto', h("br", { key: '9927df7f56583c7388cee25e13526efc7e032eb1' }), "Video: ", this.isVideoActive ? 'Activo' : 'Inactivo')))), this.showCameraSelector && this.availableCameras.length > 0 && (h("div", { key: 'c2914bf7f3175b8f0ddab977abbdefe3022d7d29', class: "camera-selector-dropdown" }, h("div", { key: '0b5397e77ff33944f3620d78b1ab41275dffd7ac', class: "camera-selector-header" }, h("span", { key: '78f0fb8e34a0cf2d16138522a98cbdb9eefd671f' }, "Seleccionar C\u00E1mara"), h("button", { key: '0d4ea7b191d61d1d9b9c35462ce336148be73fcb', class: "close-selector", onClick: () => this.toggleCameraSelector(), type: "button" }, "\u00D7")), h("div", { key: 'c16c7a106493ef7633a4cd35b06a4f45327a2e23', class: "camera-list" }, this.availableCameras.map((camera) => (h("button", { key: camera.deviceId, class: `camera-option ${this.selectedCameraId === camera.deviceId ? 'selected' : ''}`, onClick: () => {
1391
- this.switchCamera(camera.deviceId);
1392
- this.toggleCameraSelector();
1393
- }, type: "button" }, h("span", { class: "camera-label" }, camera.label || `Cámara ${this.availableCameras.indexOf(camera) + 1}`), this.selectedCameraId === camera.deviceId && (h("span", { class: "selected-indicator" }, "\u2713")))))), h("div", { key: '11d6f980c3995a8414da5f7e6921f963ca72aed4', class: "device-info" }, h("small", { key: '78f5ff030f9e6e5021234a246599eb459b05d9f7' }, "Dispositivo: ", this.deviceType)))))), this.isCapturing && (h("div", { key: 'ef7d32491d8bdb94b2d6456420c2ddbc80f03d81', class: "capture-animation" })), this.showFlipAnimation && (h("div", { key: 'cfb5868ee75a9d1d1604c52f6fce1241090e4ac2', class: "flip-animation" }, h("div", { key: '1b41035e63f88434aba6699d4e68e06bea2c1529', class: "id-card-icon" }), h("div", { key: '4e83af9d0d39ce37b7448c4a0783b60b42b858e2', class: "flip-text" }, "\u00A1Voltea tu identificaci\u00F3n!"))), this.showSuccessAnimation && (h("div", { key: 'c7911e8be74b0fc7d7d18d7dcb52374645ca5f12', class: "success-animation" }, h("div", { key: '18e5ea5cfa3eb35fe3b99c12e6fab8e27e09e85e', class: "check-icon" }), h("div", { key: '490d8fcd6540c3b4fdc95f7fb5e6f6697722c9ac', class: "success-text" }, "\u00A1Proceso completado!"))), this.isLoading && (h("div", { key: 'f7fbfec6be2d8e0dc4e522b85b7d67897575cf0e', class: "loading-overlay" }, h("div", { key: '8282b92f19da6a9c7d22a64a0929b2b4d67c46be', class: "loading-spinner" }), h("div", { key: '7880b689297eb9d80a9b0023ba7933148fd8710a', class: "loading-text" }, this.statusMessage))), h("div", { key: '887c951fb03097171d9bd466fe24e36d11a49954', class: "watermark" }, h("img", { key: '314c9c172a4c6795c825741ea6f02b0e1186e93d', src: "https://storage.googleapis.com/jaak-static/commons/powered-by-jaak.png", alt: "Powered by Jaak" })))));
700
+ return (h("div", { key: '788a458497c2303875f8accea1e0cc579379ff94', class: "detector-container" }, h("div", { key: 'ed491d2fb8399f7236ab492a100932518455be79', class: "video-container" }, h("video", { key: '8187f838c75776432dc48db4cd9bfe4ee350830d', ref: el => this.videoRef = el, width: "640", height: "640", autoplay: true, muted: true, playsinline: true, class: this.shouldMirrorVideo ? 'mirror' : '', style: { display: this.isVideoActive ? 'block' : 'none' } }), h("canvas", { key: '8cc31c45881d4f23c56c5ed246c9e59e30e0a782', ref: el => this.canvasRef = el, width: "640", height: "640", class: this.shouldMirrorVideo ? 'mirror' : '' }), h("div", { key: '54441a535098860601a7ef4f1b31a0d2a40a911b', class: "overlay-mask" }, h("div", { key: 'f9272bcb85c849e3b3170a0062c43e64359f112d', class: "card-outline" }, h("div", { key: '8a260667206ce2fecac262f2b5e81d0ebdccbb3c', class: "side side-top" }), h("div", { key: 'c9c0d25087aa8332027815829fc7bbd937f0596b', class: "side side-right" }), h("div", { key: '39394f06936ff01a525c83343ec05e6161611899', class: "side side-bottom" }), h("div", { key: '11799336a4b6f72d6042c02206626d947422ef0f', class: "side side-left" }), h("div", { key: '93d5636f85514d3fff76415ed806e6845c6e7fe3', class: "corner corner-tl" }), h("div", { key: '3bfc09f919744d1d04dcb0c08fb923879dc217c9', class: "corner corner-tr" }), h("div", { key: '6d9fa1395a606960597bed65301679dcd12fc8bb', class: "corner corner-bl" }), h("div", { key: '4819402bd891c4a8d581e1e10449850b3a580e96', class: "corner corner-br" }), !this.showFlipAnimation && !this.showSuccessAnimation && (h("div", { key: '26a57343cfccea003c3edc65c5c53ac97b16de53', class: "guide-text" }, this.statusMessage))), this.captureStep === 'back' && !this.showFlipAnimation && !this.showSuccessAnimation && (h("button", { key: '641d63e9f9e76fa81b2f770a1036b337f54a2c23', class: "skip-button", onClick: () => this.skipBackCapture(), type: "button" }, "Saltar reverso"))), this.isCapturing && (h("div", { key: 'e7ab12f7ad092d233e19de5bc7a3e424b6bc70c3', class: "capture-animation" })), this.showFlipAnimation && (h("div", { key: 'dddbe58a92172e9ab1e7002a3b4310d8e552926f', class: "flip-animation" }, h("div", { key: 'c2f49ee888573d873d67e8d4871bb6b1d8f2bc8d', class: "id-card-icon" }), h("div", { key: '6e71e7a9a3a85bb4f9252955ea220e64a25ae479', class: "flip-text" }, "\u00A1Voltea tu identificaci\u00F3n!"))), this.showSuccessAnimation && (h("div", { key: 'c9d8fd42711764ea197c7d13ef3d90e34b559e64', class: "success-animation" }, h("div", { key: '50dd978c2c501b53591346d75dac018006f42992', class: "check-icon" }), h("div", { key: 'ad25bc5811d435ceb7a1e9791cd3fc5dbd5c5227', class: "success-text" }, "\u00A1Proceso completado!"))), this.isLoading && (h("div", { key: '9ac52c0754d165f8141989b17398a89b21790976', class: "loading-overlay" }, h("div", { key: 'ccffac3b53db3ac4beddbf43ee8cff693e29fd73', class: "loading-spinner" }), h("div", { key: '708c4aad55e18be3fc77fe3f169430475dce7ee1', class: "loading-text" }, this.statusMessage))), h("div", { key: 'e0addbcea4b176772de10a608c6de4242da2a7f3', class: "watermark" }, h("img", { key: 'd3d2a989a01e2a64a100ccdc43a027f969d4b8b1', src: "https://storage.googleapis.com/jaak-static/commons/powered-by-jaak.png", alt: "Powered by Jaak" })))));
1394
701
  }
1395
702
  };
1396
703
  JaakStamps.style = myComponentCss;