@voltom.io/sdk 1.0.6 → 1.0.7

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 (41) hide show
  1. package/dist/assets/locales/ar.json +34 -2
  2. package/dist/assets/locales/ch.json +34 -2
  3. package/dist/assets/locales/de.json +34 -2
  4. package/dist/assets/locales/en.json +34 -2
  5. package/dist/assets/locales/es.json +34 -2
  6. package/dist/assets/locales/fr.json +34 -2
  7. package/dist/assets/locales/it.json +34 -2
  8. package/dist/assets/locales/ja.json +34 -2
  9. package/dist/assets/locales/pt.json +34 -2
  10. package/dist/assets/locales/ru.json +34 -2
  11. package/dist/assets/locales/zh.json +34 -2
  12. package/dist/sdk/PoseSilhouette-D2pGu7Lh.js +2 -0
  13. package/dist/sdk/PoseSuccess-R_8JYo--.js +2 -0
  14. package/dist/sdk/errors.d.ts +121 -0
  15. package/dist/sdk/facegate.d.ts +24 -18
  16. package/dist/sdk/facegate.dist.js +5 -5
  17. package/dist/sdk/facegate.js +1 -1
  18. package/dist/sdk/facekey.browser-VlDa2K-w.js +2 -0
  19. package/dist/sdk/facekey.d.ts +18 -8
  20. package/dist/sdk/facekey.dist.js +6 -6
  21. package/dist/sdk/facekey.js +1 -1
  22. package/dist/sdk/presentation-COhoAxj3.js +8 -0
  23. package/dist/sdk/presentation-ye0KVm6U.js +2 -0
  24. package/dist/sdk/requests-DW8zDX51.js +65 -0
  25. package/dist/sdk/verify.d.ts +37 -18
  26. package/dist/sdk/verify.dist.js +18 -18
  27. package/dist/sdk/verify.js +1 -1
  28. package/dist/sdk/view-CF_YOVly.js +3 -0
  29. package/dist/sdk/view-Cb4XCb-z.js +3 -0
  30. package/dist/sdk/view-DcbwHph_.js +2 -0
  31. package/package.json +4 -3
  32. package/dist/sdk/PoseSilhouette-V9BxuMwo.js +0 -2
  33. package/dist/sdk/PoseSuccess-DDx23oJD.js +0 -2
  34. package/dist/sdk/eyeLevelCamera-aDRPs63K.js +0 -65
  35. package/dist/sdk/facekey.browser-bs8vp3ON.js +0 -2
  36. package/dist/sdk/media-Cejmtltt.js +0 -2
  37. package/dist/sdk/presentation-B4P1537m.js +0 -2
  38. package/dist/sdk/presentation-Cg1Ec60l.js +0 -8
  39. package/dist/sdk/view-DTvcOVnH.js +0 -3
  40. package/dist/sdk/view-ObOGpVdZ.js +0 -3
  41. package/dist/sdk/view-iMF-mWfw.js +0 -2
@@ -1,2 +1,2 @@
1
1
  /*! Copyright (c) 2026 VOLTOM. All rights reserved. Proprietary software. See LICENSE at https://voltom.io/license. */
2
- import{$ as e,E as t,M as n,Q as r,U as i,_ as a,a as o,i as s,q as c}from"./eyeLevelCamera-aDRPs63K.js";import{O as l,S as u,_ as d,a as f,c as p,f as m,g as h,h as g,i as _,k as v,l as y,m as b,n as x,p as S,r as C,s as w,t as T,u as E}from"./media-Cejmtltt.js";import{_ as D,a as O,b as k,d as A,f as ee,g as te,h as j,i as ne,l as M,m as N,n as re,o as ie,p as P,t as F,u as ae,v as I,x as L,y as oe}from"./presentation-Cg1Ec60l.js";var{analyzeDocumentFrame:R,hasValidDocumentSideData:z,validateDocumentBack:B}=j,se=({view:e,display:t,isActive:n,notifyCapturesChanged:r,getVerifyHardOptions:i})=>{let a=e.ref,o=async()=>{t.success.value=!0,await g({milliseconds:400}),t.success.value=!1},s=async({frame:s,session:c,state:l,options:u})=>{let d=performance.now(),f=!!l.captures.documentFront,p=u.requiredDocumentStableFrames,m=null,h=null;try{m=await R({frame:s,prepareForMatch:f||l.documentStableFrames+1>=u.requiredDocumentStableFrames,options:{...i({configuration:u}),alignment:l.matchOptions.alignment,requiresFace:!f}});let{orientation:e,detection:d,face:g}=m;if(!n({flow:`document`,session:c,state:l}))return!1;let v=f?B({current:m,front:l.documentFrontSignature}):null;h=f?k({front:l.documentFrontSignature,current:m.signature}):null;let y=l.document?{...l.document,ocr:l.document.document_front}:void 0,b=z({analysis:m,isBack:f,front:y}),S=(f?v?.valid===!0:m.valid)&&b,C=e?e.rotation:null;C!==l.documentOrientation&&(l.documentStableFrames=0),l.documentOrientation=C,l.documentStableFrames=S?l.documentStableFrames+1:0,u.showDocumentOverlay?await M({documentFaceBoxColor:u.documentFaceBoxColor,documentFaceMeshColor:u.documentFaceMeshColor,documentBoxColor:u.documentBoxColor,element:a.mesh,detection:d,face:g,height:s.height,ocrLines:u.showTextOverlay?m.text.lines:[],ocrToSource:u.showTextOverlay?m.documentToSource:null,overlayColor:u.documentOverlayColor,textColor:u.textColor,width:s.width}):x({element:a.mesh});let w=U({analysis:m,dataValid:b,isBack:f,minFaceAreaRatio:u.minDocumentFaceAreaRatio,rejectionReasons:v?v.reasons:m.failureReasons,valid:S,stable:l.documentStableFrames>=p});if(t.feedback.value={flow:`document`,...w},l.documentStableFrames<p)return!1;let T=await _({frame:s});return n({flow:`document`,session:c,state:l})?f?(V({analysis:m,isBack:!0,state:l}),l.captures.documentBack=T,r({state:l}),await o(),!0):!m.embeddings||!m.images?!1:(V({analysis:m,isBack:!1,state:l}),l.documentFaceEmbeddings=m.embeddings,l.documentFrontSignature=m.signature,l.preparedCaptures.documentFront=m.images,l.captures.documentFront=T,r({state:l}),await o(),!0):!1}finally{m&&n({flow:`document`,session:c,state:l})&&e.collectDocumentDebug({analysis:m,sideComparison:h,isBack:f,processingTimeMilliseconds:performance.now()-d,state:l})}};return{runDocumentLoop:async({session:e,state:r,options:i})=>{for(;n({flow:`document`,session:e,state:r});){if(await E({video:a.video}),!n({flow:`document`,session:e,state:r}))return;let o=await createImageBitmap(a.video);try{let n=await y({frame:o});try{if(await s({frame:n,session:e,state:r,options:i})){r.flow=null,t.debug.value=[];return}}finally{n.close()}}finally{o.close()}}}}},V=({analysis:e,isBack:t,state:r})=>{if(!e.ocr)throw Error(h.CAPTURES_INCOMPLETE);let i={ocr:e.ocr,codes:e.codes};if(t){if(!r.document)throw Error(h.CAPTURES_INCOMPLETE);let t=n({classification:r.document,front:{ocr:r.document.document_front,codes:r.document.codes},back:i});r.document={...r.document,...t,document_back:e.ocr}}else{if(!e.documentKind)throw Error(h.DOCUMENT_NOT_RECOGNIZED);let t={document:e.documentKind,europeanDrivingLicense:e.europeanDrivingLicense,identity:e.identity},a=n({classification:t,front:i});r.identity=e.identity,r.document={...t,...a,document_front:e.ocr,document_back:null}}r.documentCodes=r.document.codes},H=({rejection:e})=>e===`coverage_low`?`DOCUMENT_BOX_TOO_SMALL`:e===`coverage_high`?`DOCUMENT_BOX_TOO_LARGE`:e===`edge_proximity`?`DOCUMENT_BOX_NEAR_EDGE`:e===`opposite_edges`?`DOCUMENT_BOX_TOUCHES_EDGES`:e===`aspect_ratio`?`DOCUMENT_NOT_SUPPORTED`:`DOCUMENT_SHAPE_INVALID`,U=({analysis:e,dataValid:t,isBack:n,minFaceAreaRatio:r,rejectionReasons:i,valid:a,stable:o})=>{let s=`front`;n?s=`back`:e.documentKind===`passport`&&(s=`passport`);let c=Object.keys(e.documentAnalysis.diagnostics.rejected)[0];return c?{target:s,code:H({rejection:c})}:e.detection?e.documentAnalysis.isBlurry?{target:s,code:`DOCUMENT_BLURRY`}:n&&i.includes(h.DOCUMENT_BACK_CONTAINS_FACE)?{target:s,code:`DOCUMENT_BACK_HAS_FACE`}:n&&i.includes(h.DOCUMENT_BACK_NOT_DISTINCT)?{target:s,code:`DOCUMENT_BACK_SAME_AS_FRONT`}:!n&&!e.face?{target:s,code:`DOCUMENT_FRONT_FACE_NOT_DETECTED`}:!n&&!e.faceContained?{target:s,code:`DOCUMENT_FRONT_FACE_NOT_CONTAINED`}:!n&&!e.alignment.faceAreaValid&&e.alignment.faceAreaRatio<r?{target:s,code:`DOCUMENT_FRONT_FACE_TOO_SMALL`}:!n&&(!e.alignment.faceAreaValid||!e.alignment.faceDimensionsValid)?{target:s,code:`DOCUMENT_FRONT_FACE_SIZE_INVALID`}:!n&&(!e.alignment.textParallel||e.alignment.textSide===`unknown`||e.alignment.faceAdjacentTextLineCount<2)?{target:s,code:`DOCUMENT_FRONT_LAYOUT_INVALID`}:!e.text.text||e.text.lines.length<2?{target:s,code:`DOCUMENT_TEXT_NOT_READABLE`}:!n&&!e.documentKind?{target:s,code:`DOCUMENT_NOT_RECOGNIZED`}:t?a?o?{target:s,code:null}:{target:s,code:`DOCUMENT_STABILITY_REQUIRED`}:{target:s,code:`DOCUMENT_VALIDATION_FAILED`}:{target:s,code:`DOCUMENT_CODE_NOT_READABLE`}:{target:s,code:`DOCUMENT_NOT_DETECTED`}},W=`https://api.voltom.io`,G=({apiUrl:e})=>{let t=e??W;return t.endsWith(`/`)?t.slice(0,-1):t},K=async({apiUrl:e,path:t,method:n=`POST`,body:r,clientKey:i,fallback:a=h.INVALID_SERVICE_RESPONSE,signal:o})=>{let s={};i&&(s.authorization=`Bearer ${i}`),r&&(s[`content-type`]=`application/json`);let c;try{c=await fetch(`${G({apiUrl:e})}${t}`,{method:n,headers:s,body:r,signal:o})}catch(e){throw o?.aborted?Error(h.VERIFICATION_CANCELLED,{cause:e}):Error(h.NETWORK_ERROR,{cause:e})}if(c.status===413)throw Error(h.REQUEST_TOO_LARGE);let l;try{l=await c.json()}catch(e){throw Error(c.status>=500?h.SERVICE_UNAVAILABLE:a,{cause:e})}if(!c.ok){let e=typeof l==`object`&&l&&`code`in l&&typeof l.code==`string`?l.code:c.status>=500?h.SERVICE_UNAVAILABLE:a;throw Error(e)}return l},q=async({clientKey:e,apiUrl:t,signal:n})=>{await K({apiUrl:t,path:`/auth/me`,method:`GET`,clientKey:e,fallback:h.INVALID_CLIENT_KEY,signal:n})},J=({apiUrl:e})=>{if(typeof navigator<`u`&&typeof navigator.sendBeacon==`function`)try{navigator.sendBeacon(`${G({apiUrl:e})}/script-loads`)}catch{return}},ce=async({clientKey:e,apiUrl:t,endpoint:n,documentBack:r,documentFront:i,faces:a=[],options:o,picture:s,poses:c=[],sourceIds:l=[],threshold:u,token:d,signal:p})=>{if(!e)throw Error(h.CLIENT_KEY_REQUIRED);let m=JSON.stringify({token:d,documentFront:i?await f({image:i}):void 0,documentBack:r?await f({image:r}):void 0,picture:s?await f({image:s}):void 0,faces:await Promise.all(a.map(e=>f({image:e}))),options:o,poses:c.map(e=>A[e]),source_ids:l,threshold:u});return p?.throwIfAborted(),await K({apiUrl:t,path:n,body:m,clientKey:e,signal:p})},{loadDocumentBoxDetector:le,detectDocumentOrientation:ue}=P,{detectPictureFaces:Y,loadFaceDetector:de}=N,{loadFaceMatch:fe,warmupFaceMatch:pe}=D,{loadTextDetector:X}=I,me={"/verify/human":`human`,"/verify/document":`document`,"/verify/id":`match_id`,"/verify/picture":`match_picture`},Z=({options:e,view:n,display:a})=>{let l=n.ref,u=[...ee],f=({language:e})=>e??S(),m=()=>({identity:null,flow:null,session:0,faceSequence:[...u],faceCaptureConfiguration:null,documentCaptureConfiguration:null,poseIndex:0,poseStableFrames:0,documentStableFrames:0,documentOrientation:null,documentFaceEmbeddings:null,documentFrontSignature:null,documentCodes:[],matchOptions:{alignment:e.alignment,threshold:e.threshold},captures:{},preparedCaptures:{},faceEmbeddings:{},previousPoseBackgroundSignature:null,neutralPose:null,guidanceCodeState:o(),correctiveState:s(),faceMatchOptions:null,hardHumanVerificationId:null,hardDocumentVerificationId:null,cameraActive:!1,cameraSize:a.cameraSize,cameraFacingMode:a.cameraFacingMode}),g=({active:e,state:t})=>{t.cameraActive!==e&&(t.cameraActive=e,l.root.dispatchEvent(new CustomEvent(`voltom:camera-change`,{detail:{active:e}})))},_=({state:e})=>{p({video:l.video}),g({active:!1,state:e}),e.cameraSize.value=null,e.cameraFacingMode.value=null,a.feedback.value=null,a.guidance.value=null,a.corrective.value=null,a.success.value=!1},v=({state:e})=>({identity:e.identity,document:e.document,captures:{...e.captures},documentCodes:[...e.documentCodes],preparedCaptures:{...e.preparedCaptures}}),y=({state:e})=>{let t=v({state:e});l.root.dispatchEvent(new CustomEvent(`voltom:captures-change`,{detail:t}))},b=({state:t,options:n=e})=>{t.faceSequence=N({options:n}),t.poseIndex=0,t.poseStableFrames=0;let r=t.preparedCaptures.documentFront;t.preparedCaptures=r?{documentFront:r}:{},t.faceEmbeddings={},t.previousPoseBackgroundSignature=null,t.neutralPose=null,t.guidanceCodeState=o(),t.correctiveState=s(),a.corrective.value=null,t.faceMatchOptions=null,t.hardHumanVerificationId=null,t.faceCaptureConfiguration=null;let{documentFront:i,documentBack:c}=t.captures;t.captures={...i?{documentFront:i}:{},...c?{documentBack:c}:{}}},C=({state:e})=>{e.documentStableFrames=0,e.documentOrientation=null,e.documentFaceEmbeddings=null,e.documentFrontSignature=null,e.identity=null,e.documentCodes=[],delete e.document,e.hardDocumentVerificationId=null,e.documentCaptureConfiguration=null,delete e.preparedCaptures.documentFront;let t={...e.captures};delete t.documentFront,delete t.documentBack,e.captures=t},T=({state:e})=>{e.session+=1,e.flow=null,_({state:e}),x({element:l.mesh}),a.debug.value=[]},E=({state:e})=>{T({state:e}),y({state:e}),a.error.value=null},k=({state:e})=>{let t=l.video.videoWidth,n=l.video.videoHeight;t&&n&&(e.cameraSize.value={width:t,height:n})},A=async({facingMode:e,state:t})=>{_({state:t});let n=t.session,r=await w({facingMode:e,video:l.video});if(t.session!==n)throw p({video:l.video}),Z();t.cameraFacingMode.value=r,k({state:t}),g({active:!0,state:t})},j=({flow:e,session:t,state:n})=>n.flow===e&&n.session===t,M=({state:e})=>e.faceSequence[e.poseIndex]??`faceStraight`,N=({options:e})=>ie({poses:e.poses,randomize:e.randomizeFaceSequence??!1}),F=({options:e})=>JSON.stringify({requireEyeLevelCamera:e.requireEyeLevelCamera,poses:e.poses,randomizeFaceSequence:e.randomizeFaceSequence,faceDetector:e.faceDetector,alignment:e.alignment,threshold:e.threshold,language:e.language,maxPitch:e.maxPitch,minPitch:e.minPitch,maxYaw:e.maxYaw,minYaw:e.minYaw,maxRoll:e.maxRoll,requiredFaceStableFrames:e.requiredFaceStableFrames}),I=({options:e})=>JSON.stringify({ocrEngine:e.ocrEngine,language:e.language,minDocumentFaceAreaRatio:e.minDocumentFaceAreaRatio,maxDocumentFaceAreaRatio:e.maxDocumentFaceAreaRatio,minDocumentFaceWidthRatio:e.minDocumentFaceWidthRatio,maxDocumentFaceWidthRatio:e.maxDocumentFaceWidthRatio,minDocumentFaceHeightRatio:e.minDocumentFaceHeightRatio,maxDocumentFaceHeightRatio:e.maxDocumentFaceHeightRatio,minDocumentBoxRatio:e.minDocumentBoxRatio,maxDocumentTextAngleDifference:e.maxDocumentTextAngleDifference,requiredDocumentStableFrames:e.requiredDocumentStableFrames}),R=({state:e,options:t})=>e.faceCaptureConfiguration===F({options:t})&&O({captures:e.captures,state:e}),z=({state:e,options:t})=>{let n=e.document,r=n!==void 0&&n.document!==`passport`,i=!(!e.captures.documentFront||r&&!e.captures.documentBack),a=e.documentCaptureConfiguration===I({options:t});return!!(n?.valid&&i&&a)},B=({configuration:e})=>{let n=Object.fromEntries(Object.keys(t).map(t=>[t,e[t]]));return n.language=f({language:e.language}),n},V=async({configuration:e,endpoint:t,state:n,picture:r,sourceIds:i=[],signal:a})=>{let o=O({captures:n.captures,state:n})?ne({captures:n.captures,state:n}):null,s=me[t]??t,c=e.authorize?await e.authorize({action:s}):void 0;return await ce({clientKey:e.clientKey,apiUrl:e.apiUrl,endpoint:t,token:c?.token,documentBack:r?void 0:n.captures.documentBack,documentFront:r?void 0:n.captures.documentFront,faces:o?.faces,options:B({configuration:e}),picture:r,poses:o?.poses,sourceIds:i,threshold:e.threshold,signal:a})},H={options:e,view:n,display:a,isActive:j,notifyCapturesChanged:y,getVerifyHardOptions:B},{runFaceLoop:U}=re(H),{runDocumentLoop:W}=se(H),G=async({state:e,options:t})=>{T({state:e}),b({state:e,options:t}),a.progress.value={completed:0,total:e.faceSequence.length},e.faceCaptureConfiguration=F({options:t}),e.matchOptions={alignment:t.alignment,threshold:t.threshold},e.faceMatchOptions={...e.matchOptions},y({state:e});let n=e.session;e.flow=`face`;try{if(a.feedback.value={flow:`face`,pose:M({state:e}),code:null},await A({facingMode:`user`,state:e}),a.feedback.value={flow:`face`,pose:M({state:e}),code:null},await U({session:n,state:e,options:t}),e.session!==n)throw Z();if(!O({captures:e.captures,state:e}))throw Error(h.CAPTURES_INCOMPLETE);let r={...e.captures};return _({state:e}),x({element:l.mesh}),r}finally{e.session===n&&(a.feedback.value=null)}},K=async({state:t,options:n=e})=>{T({state:t}),C({state:t}),t.documentCaptureConfiguration=I({options:n}),t.matchOptions={alignment:n.alignment,threshold:n.threshold},y({state:t});let r=t.session;t.flow=`document`;try{if(!j({flow:`document`,session:r,state:t})||(await A({facingMode:`environment`,state:t}),a.feedback.value={flow:`document`,code:null,target:`front`},await W({session:r,state:t,options:n}),t.session!==r))throw Z();if(!t.captures.documentFront||!t.document)throw Error(h.CAPTURES_INCOMPLETE);if(t.document.document!==`passport`&&(t.documentStableFrames=0,t.documentOrientation=null,t.flow=`document`,a.feedback.value={flow:`document`,code:null,target:`back`},await W({session:r,state:t,options:n}),t.session!==r))throw Z();if(!t.document.valid)throw Error(h.DOCUMENT_VALIDATION_FAILED);let e={...t.captures};return _({state:t}),x({element:l.mesh}),e}finally{t.session===r&&(a.feedback.value=null,x({element:l.mesh}))}},q=async()=>{let t=e.capabilities.some(e=>e===`verifyDocument`||e===`matchID`),n=[le(),de({faceDetector:e.faceDetector}),fe(),...t?[te(),X({engine:`tiny`,language:`latin`}),X({engine:e.ocrEngine,language:f({language:e.language})}),oe()]:[],...e.showFaceOverlay||e.showDocumentOverlay?[ae()]:[]];await Promise.all(n);let r=document.createElement(`canvas`);r.width=640,r.height=480;let i=await createImageBitmap(r);try{let e=[Y(i),P.detectDocumentBox(i),pe()];t&&e.push(ue({frame:i,boundingRect:{x:0,y:0,width:i.width,height:i.height}})),await Promise.all(e)}finally{i.close()}},J=async()=>{let t=e.capabilities.some(e=>e===`verifyDocument`||e===`matchID`),n=[`dd.ort`,i[e.faceDetector],`fl.ort`,`fe.ort`,`fmu.ort`,`ort-wasm-simd-threaded.mjs`,`ort-wasm-simd-threaded.wasm`,...t?[`do.ort`,`zxing-wasm/reader/index.js`,`zxing-wasm/share.js`,`zxing-wasm/reader/zxing_reader.wasm`]:[],...e.showFaceOverlay||e.showDocumentOverlay?[`faceMeshLines.json`]:[]],r=[c({filenames:n})];t&&(r.push(c({filenames:L({language:`latin`,engine:`tiny`})})),r.push(c({filenames:L({language:f({language:e.language}),engine:e.ocrEngine})}))),await Promise.all(r)},Z=()=>new DOMException(h.VERIFICATION_CANCELLED,`AbortError`);return{createState:m,stop:E,syncCameraSize:k,captureResult:v,resetFaceFlow:b,resetDocumentFlow:C,hasCompatibleFaceCaptures:R,hasCompatibleDocumentCapture:z,notifyCapturesChanged:y,startFaceFlow:G,startDocumentFlow:K,startPictureFlow:async({picture:e,state:t,options:n,signal:r})=>{a.error.value=null,r?.throwIfAborted();let i=await D.imageBitmap({blob:e});try{let e=await Y(i,{forMatch:!0});if(r?.throwIfAborted(),!e.length)throw Error(h.NO_USABLE_CANDIDATES)}finally{i.close()}let o=t.faceCaptureConfiguration===F({options:n});R({state:t,options:n})&&o||await G({state:t,options:n}),r?.throwIfAborted();let s=await D.imageBitmap({blob:e});try{let[e]=await Y(s,{forMatch:!0});r?.throwIfAborted();let i=e?D.prepareFace({alignment:n.alignment,face:e,frame:s}):null,a=i?await D.preparedFaceArtifacts({face:i}):null;r?.throwIfAborted(),a&&(t.preparedCaptures.picture=a.images)}finally{s.close()}y({state:t})},submitHardVerification:V,initializeModels:q,preloadModels:J,showError:({error:e,state:t})=>{d({error:e})!==h.VERIFICATION_CANCELLED&&T({state:t}),r(()=>{a.activity.value=null,d({error:e})===h.VERIFICATION_CANCELLED?a.retry.value=null:a.error.value=e})}}},Q,he=async()=>{try{Q??=import(v({filename:`pdf/pdf.mjs`}));let e=await Q;return e.GlobalWorkerOptions.workerSrc=v({filename:`pdf/pdf.worker.mjs`}),e}catch{throw Q=void 0,Error(h.PDF_LOAD_FAILED)}},ge=async({blob:e,signal:t})=>{if(new TextDecoder().decode(await e.slice(0,5).arrayBuffer())!==`%PDF-`)return null;if(e.size>1e7)throw Error(h.REQUEST_TOO_LARGE);t.throwIfAborted();let n=await he();t.throwIfAborted();let r=new Uint8Array(await e.arrayBuffer()),i=n.getDocument({data:r,cMapUrl:v({filename:`pdf/cmaps/`}),cMapPacked:!0,standardFontDataUrl:v({filename:`pdf/standard_fonts/`}),wasmUrl:v({filename:`pdf/wasm/`})}),a=()=>{i.destroy()};t.addEventListener(`abort`,a,{once:!0});let o;try{let e=await i.promise;t.throwIfAborted();let n=await e.getPage(1),r=n.getViewport({scale:1}),a=n.getViewport({scale:Math.min(1,1200/Math.max(r.width,r.height))}),s=window.document.createElement(`canvas`);s.width=Math.ceil(a.width),s.height=Math.ceil(a.height),await n.render({canvas:s,viewport:a,background:`white`}).promise,t.throwIfAborted(),o=await createImageBitmap(s),s.width=0,s.height=0;let c=await N.detectPictureFaces(o,{forMatch:!0});t.throwIfAborted();let l=c[0];if(!l)throw Error(h.NO_USABLE_CANDIDATES);let u=l.boundingRect,d=Math.max(0,Math.floor(u.x-u.width*.25)),f=Math.max(0,Math.floor(u.y-u.height*.25)),p=Math.min(o.width-d,Math.ceil(u.width*1.5)),m=Math.min(o.height-f,Math.ceil(u.height*1.5)),g=new OffscreenCanvas(p,m),_=g.getContext(`2d`);if(!_)throw Error(h.IMAGE_PROCESSING_FAILED);_.drawImage(o,d,f,p,m,0,0,p,m);let v=await g.convertToBlob({type:`image/jpeg`,quality:.95});return t.throwIfAborted(),v}catch(e){throw t.throwIfAborted(),e instanceof Error&&Object.values(h).includes(e.message)?e:e instanceof Error&&e.name===`PasswordException`?Error(h.PDF_PASSWORD_REQUIRED):Error(h.INVALID_PDF)}finally{t.removeEventListener(`abort`,a),o?.close(),await i.destroy()}},$={...t,faceDetector:`standard`,apiUrl:`https://api.voltom.io`,language:void 0,clientKey:``,threshold:a,randomizeFaceSequence:!1,requireEyeLevelCamera:!0,requiredFaceStableFrames:2,requiredDocumentStableFrames:2,showFaceOverlay:!1,showDocumentOverlay:!1,showTextOverlay:!1,faceOverlayColor:`transparent`,faceMeshColor:`#38efb0`,documentOverlayColor:`transparent`,documentBoxColor:`#22d3ee`,documentFaceBoxColor:`#22d3ee`,documentFaceMeshColor:`#38efb0`,textColor:`#22d3ee`,debug:!1,capabilities:[`verifyHuman`,`verifyDocument`,`matchID`,`matchPicture`]},_e=class{options;view;root;useUi;videoElement;resizeListener;display=F();translator;flows;state;lastPicture;preparation=null;preloading=null;preparationController=null;prepared=!1;disposed=!1;operationController=null;subscriptions=new Set;uiAttached=!1;notifyStatus({status:e}){this.root.dispatchEvent(new CustomEvent(`voltom:${e}`))}showSpinner({message:e=this.translator.translate(`checkingFaceMatch`)}={}){this.display.activity.value={message:e}}hideSpinner(){this.display.activity.value=null}async runWithSpinner({task:e,message:t}){this.showSpinner({message:t});try{return await e()}finally{this.hideSpinner()}}constructor(e){let{root:t,video:n,ui:r,prepare:i=!0,...a}=e,o=r??!!t;if(o&&!t||!o&&!n)throw Error(h.INVALID_OPTIONS);if(!a.clientKey)throw Error(h.CLIENT_KEY_REQUIRED);this.options=Object.freeze({...$,...a,requireEyeLevelCamera:a.requireEyeLevelCamera??!0,capabilities:Object.freeze([...a.capabilities??$.capabilities]),poses:Array.isArray(a.poses)?Object.freeze([...a.poses]):a.poses}),this.root=t??document.createElement(`div`),this.useUi=o,this.videoElement=n??document.createElement(`video`),this.translator=m({language:this.options.language}),this.view={ref:{root:this.root,camera:document.createElement(`div`),video:this.videoElement,mesh:document.createElement(`canvas`)},collectFaceDebug:()=>{},collectDocumentDebug:()=>{}},this.flows=Z({options:this.options,view:this.view,display:this.display}),this.lastPicture=null,this.state=this.flows.createState(),this.resizeListener=()=>this.flows.syncCameraSize({state:this.state}),this.videoElement.addEventListener(`resize`,this.resizeListener),i&&this.prepare().catch(e=>console.error(e))}async preload(){if(this.disposed)throw Error(h.SDK_NOT_READY);if(this.preloading)return this.preloading;let e=(async()=>{await b({language:this.options.language}),await this.flows.preloadModels()})();this.preloading=e;try{if(await e,this.disposed)throw Error(h.SDK_NOT_READY)}catch(t){throw this.preloading===e&&(this.preloading=null),t}}async prepare(){if(this.disposed)throw Error(h.SDK_NOT_READY);if(this.preparation)return this.preparation;let e=new AbortController;this.preparationController=e;let t=(async()=>{await this.preload(),await this.attachUi(),await this.runWithSpinner({task:async()=>{if(await q({clientKey:this.options.clientKey,apiUrl:this.options.apiUrl,signal:e.signal}),await J({apiUrl:this.options.apiUrl}),await this.flows.initializeModels(),e.signal.throwIfAborted(),this.disposed)throw Error(h.SDK_NOT_READY)},message:this.translator.translate(`preparingModels`)})})();this.preparation=t;try{await t,this.prepared=!0,this.preparationController===e&&(this.preparationController=null)}catch(n){throw this.preparation===t&&(this.preparation=null),this.preparationController===e&&(this.preparationController=null),n}}async attachUi(){if(!this.useUi||this.uiAttached)return;let{createVerificationView:e}=await import(`./view-ObOGpVdZ.js`);if(this.disposed)throw Error(h.SDK_NOT_READY);let t=e({root:this.root,options:this.options,display:this.display});this.videoElement.removeEventListener(`resize`,this.resizeListener),Object.assign(this.view.ref,t.ref),this.view.collectFaceDebug=t.collectFaceDebug,this.view.collectDocumentDebug=t.collectDocumentDebug,this.videoElement=this.view.ref.video,this.videoElement.addEventListener(`resize`,this.resizeListener),this.uiAttached=!0}async submitHardVerification(e){let t=e.endpoint===`/verify/document`?this.translator.translate(`checkingDocument`):void 0;return await this.runWithSpinner({task:()=>this.flows.submitHardVerification({...e,signal:e.signal??this.operationController?.signal}),message:t})}async caniuse(){return await T()}async runOperation({retry:e,task:t,onError:n,capability:i,settings:a}){if(this.disposed)throw Error(h.SDK_NOT_READY);if(await this.prepare(),!this.options.capabilities.includes(i))throw Error(h.SDK_CAPABILITY_NOT_CONFIGURED);if(this.operationController)throw Error(h.INVALID_OPTIONS);let{signal:o,...s}=a,c=Object.freeze({...this.options,...s,poses:Array.isArray(s.poses)?Object.freeze([...s.poses]):s.poses??this.options.poses}),l=new AbortController;this.operationController=l;let u=()=>l.abort();o?.addEventListener(`abort`,u,{once:!0}),o?.aborted&&u(),l.signal.addEventListener(`abort`,()=>this.flows.stop({state:this.state}),{once:!0}),this.notifyStatus({status:`in-progress`}),r(()=>{this.display.retry.value=e,this.display.error.value=null,this.display.debugEnabled.value=c.debug,c.debug||(this.display.debug.value=[])});try{return l.signal.throwIfAborted(),await t({options:c,signal:l.signal})}catch(e){let t=l.signal.aborted?Error(h.VERIFICATION_CANCELLED,{cause:e}):e;throw n&&await n({error:t,options:c,signal:l.signal}),this.disposed||this.flows.showError({error:t,state:this.state}),t}finally{this.notifyStatus({status:`ready`}),o?.removeEventListener(`abort`,u),this.display.debugEnabled.value=this.options.debug,this.operationController===l&&(this.operationController=null)}}async verifyHuman(e={}){return await this.verifyCapture({flow:`human`,...e})}async verifyDocument(e={}){return await this.verifyCapture({flow:`document`,...e})}async verifyCapture({flow:e,...t}){let n=({options:t})=>{e===`human`?this.flows.resetFaceFlow({state:this.state,options:t}):this.flows.resetDocumentFlow({state:this.state}),this.flows.notifyCapturesChanged({state:this.state})};return await this.runOperation({capability:e===`human`?`verifyHuman`:`verifyDocument`,settings:t,retry:()=>this.verifyCapture({flow:e,...t,signal:void 0}),onError:async({error:t,options:r})=>{(e===`human`?this.state.faceCaptureConfiguration!==null:this.state.documentCaptureConfiguration!==null)&&d({error:t})!==h.VERIFICATION_CANCELLED&&n({options:r})},task:async({options:t,signal:r})=>{r.throwIfAborted(),await(e===`human`?this.flows.startFaceFlow:this.flows.startDocumentFlow)({state:this.state,options:t}),r.throwIfAborted();let i=await this.submitHardVerification({configuration:t,endpoint:`/verify/${e}`,state:this.state}),a=e===`human`?`hardHumanVerificationId`:`hardDocumentVerificationId`;return this.state[a]=i.resultId,i.outcome!==`pass`||i.matched!==!0?(this.state[a]=null,n({options:t}),i):(this.display.retry.value=null,i)}})}async ensureHumanVerification({options:e,signal:t}){if(t?.throwIfAborted(),this.flows.hasCompatibleFaceCaptures({state:this.state,options:e})||await this.flows.startFaceFlow({state:this.state,options:e}),t?.throwIfAborted(),this.state.hardHumanVerificationId)return null;let n=await this.submitHardVerification({configuration:e,endpoint:`/verify/human`,state:this.state}),r=n.outcome===`pass`&&n.matched===!0;return this.state.hardHumanVerificationId=r?n.resultId:null,r?null:n}async matchID(e={}){return await this.runOperation({capability:`matchID`,settings:e,retry:()=>this.matchID({...e,signal:void 0}),task:async({options:e,signal:t})=>{t.throwIfAborted();let n=await this.ensureHumanVerification({options:e,signal:t});if(n)return n;if(t.throwIfAborted(),this.flows.hasCompatibleDocumentCapture({state:this.state,options:e})||await this.flows.startDocumentFlow({state:this.state,options:e}),!this.state.hardDocumentVerificationId){t.throwIfAborted();let n=await this.submitHardVerification({configuration:e,endpoint:`/verify/document`,state:this.state});if(this.state.hardDocumentVerificationId=n.resultId,n.outcome!==`pass`||n.matched!==!0)return this.state.hardDocumentVerificationId=null,n}let r=await this.submitHardVerification({configuration:e,endpoint:`/verify/id`,state:this.state,sourceIds:[this.state.hardHumanVerificationId,this.state.hardDocumentVerificationId]});return r.outcome!==`pass`||r.matched!==!0||(this.display.retry.value=null),r}})}async matchPicture(e,t={}){return this.lastPicture=e,await this.runOperation({capability:`matchPicture`,settings:t,retry:async()=>{this.lastPicture&&await this.matchPicture(this.lastPicture,{...t,signal:void 0})},task:async({options:t,signal:n})=>{n.throwIfAborted();let r=await ge({blob:e,signal:n})??await C({blob:e});if(n.throwIfAborted(),!this.state.hardHumanVerificationId){let e=await this.ensureHumanVerification({options:t,signal:n});if(e)return e}await this.flows.startPictureFlow({picture:r,state:this.state,options:t,signal:n}),n.throwIfAborted();let i=await this.submitHardVerification({configuration:t,endpoint:`/verify/picture`,state:this.state,picture:r,sourceIds:[this.state.hardHumanVerificationId]});return i.outcome!==`pass`||i.matched!==!0||(this.display.retry.value=null),i}})}stop(){this.operationController?.abort(new DOMException(h.VERIFICATION_CANCELLED,`AbortError`)),this.flows.stop({state:this.state}),this.display.retry.value=null,this.notifyStatus({status:`ready`})}dispose(){if(!this.disposed){this.disposed=!0,this.preparationController?.abort(),this.stop();for(let e of this.subscriptions)e();this.subscriptions.clear(),this.videoElement.removeEventListener(`resize`,this.resizeListener),u(null,this.root),this.state.captures={},this.state.preparedCaptures={},this.state.faceEmbeddings={},this.state.documentCodes=[],this.state.identity=null,this.state.hardHumanVerificationId=null,this.state.hardDocumentVerificationId=null,this.state.faceCaptureConfiguration=null,this.state.documentCaptureConfiguration=null,delete this.state.document,this.lastPicture=null}}forgetHuman(){if(this.disposed)throw Error(h.SDK_NOT_READY);this.flows.resetFaceFlow({state:this.state}),this.display.error.value=null,this.flows.notifyCapturesChanged({state:this.state})}forgetDocument(){if(this.disposed)throw Error(h.SDK_NOT_READY);this.flows.resetDocumentFlow({state:this.state}),this.display.error.value=null,this.flows.notifyCapturesChanged({state:this.state})}getState(){return{activity:this.display.activity.value,error:this.display.error.value,retryAvailable:this.display.retry.value!==null,feedback:this.display.feedback.value,debug:this.display.debug.value}}subscribe(t){if(this.disposed)throw Error(h.SDK_NOT_READY);let n=e(()=>t(this.getState()));return this.subscriptions.add(n),()=>{n(),this.subscriptions.delete(n)}}};l({moduleUrl:import.meta.url});var ve=_e;export{ve as default};
2
+ import{At as e,B as t,Bt as n,Ct as r,Et as i,F as a,Ft as o,Gt as s,Ht as c,It as l,Kt as u,L as d,Lt as f,Mt as p,N as m,Nt as h,Ot as g,P as _,Pt as v,S as y,St as b,T as x,U as S,Ut as C,Vt as w,Wt as ee,_t as T,a as E,at as D,ct as O,dt as k,et as te,ft as A,gt as ne,h as re,ht as j,jt as M,kt as N,lt as P,m as ie,mt as ae,o as oe,ot as se,pt as F,qt as ce,st as I,t as L,ut as R,vt as z,wt as B,xt as le,yt as ue,zt as V}from"./requests-DW8zDX51.js";import{C as H,S as de,_ as fe,a as U,b as pe,d as me,f as he,g as ge,h as W,i as _e,l as ve,m as G,n as ye,o as K,p as be,t as xe,u as Se,v as Ce,x as we,y as q}from"./presentation-COhoAxj3.js";var{analyzeDocumentFrame:Te,hasValidDocumentSideData:Ee,validateDocumentBack:De}=ge,Oe=({view:e,display:t,isActive:n,notifyCapturesChanged:r,getVerifyOptions:i})=>{let a=e.ref,o=async()=>{t.success.value=!0,await B({milliseconds:400}),t.success.value=!1},s=async({frame:s,session:c,state:l,options:u})=>{let d=performance.now(),f=!!l.captures.documentFront,p=u.requiredDocumentStableFrames,m=null,h=null;try{m=await Te({frame:s,prepareForMatch:f||l.documentStableFrames+1>=u.requiredDocumentStableFrames,options:{...i({configuration:u}),alignment:l.matchOptions.alignment,requiresFace:!f}});let{orientation:e,detection:d,face:g}=m;if(!n({flow:`document`,session:c,state:l}))return!1;let _=f?De({current:m,front:l.documentFrontSignature}):null;h=f?de({front:l.documentFrontSignature,current:m.signature}):null;let v=l.document?{...l.document,ocr:l.document.document_front}:void 0,y=Ee({analysis:m,isBack:f,front:v}),b=(f?_?.valid===!0:m.valid)&&y,x=e?e.rotation:null;x!==l.documentOrientation&&(l.documentStableFrames=0),l.documentOrientation=x,l.documentStableFrames=b?l.documentStableFrames+1:0,u.showDocumentOverlay?await ve({documentFaceBoxColor:u.documentFaceBoxColor,documentFaceMeshColor:u.documentFaceMeshColor,documentBoxColor:u.documentBoxColor,element:a.mesh,detection:d,face:g,height:s.height,ocrLines:u.showTextOverlay?m.text.lines:[],ocrToSource:u.showTextOverlay?m.documentToSource:null,overlayColor:u.documentOverlayColor,textColor:u.textColor,width:s.width}):A({element:a.mesh});let S=je({analysis:m,dataValid:y,isBack:f,minFaceAreaRatio:u.minDocumentFaceAreaRatio,rejectionReasons:_?_.reasons:m.failureReasons,valid:b,stable:l.documentStableFrames>=p});if(t.feedback.value={flow:`document`,...S},l.documentStableFrames<p)return!1;let C=await ae({frame:s});return n({flow:`document`,session:c,state:l})?f?(ke({analysis:m,isBack:!0,state:l}),l.captures.documentBack=C,r({state:l}),await o(),!0):!m.embeddings||!m.images?!1:(ke({analysis:m,isBack:!1,state:l}),l.documentFaceEmbeddings=m.embeddings,l.documentFrontSignature=m.signature,l.preparedCaptures.documentFront=m.images,l.captures.documentFront=C,r({state:l}),await o(),!0):!1}finally{m&&n({flow:`document`,session:c,state:l})&&e.collectDocumentDebug({analysis:m,sideComparison:h,isBack:f,processingTimeMilliseconds:performance.now()-d,state:l})}};return{runDocumentLoop:async({session:e,state:r,options:i})=>{for(;n({flow:`document`,session:e,state:r});){if(await ue({video:a.video}),!n({flow:`document`,session:e,state:r}))return;let o=await createImageBitmap(a.video);try{let n=await z({frame:o});try{if(await s({frame:n,session:e,state:r,options:i})){r.flow=null,t.debug.value=[];return}}finally{n.close()}}finally{o.close()}}}}},ke=({analysis:e,isBack:t,state:n})=>{if(!e.ocr)throw c({code:C.CAPTURES_INCOMPLETE});let r={ocr:e.ocr,codes:e.codes};if(t){if(!n.document)throw c({code:C.CAPTURES_INCOMPLETE});let t=S({classification:n.document,front:{ocr:n.document.document_front,codes:n.document.codes},back:r});n.document={...n.document,...t,document_back:e.ocr}}else{if(!e.documentKind)throw c({code:C.DOCUMENT_NOT_RECOGNIZED});let t={document:e.documentKind,europeanDrivingLicense:e.europeanDrivingLicense,identity:e.identity},i=S({classification:t,front:r});n.identity=e.identity,n.document={...t,...i,document_front:e.ocr,document_back:null}}n.documentCodes=n.document.codes},Ae=({rejection:e})=>e===`coverage_low`?`DOCUMENT_BOX_TOO_SMALL`:e===`coverage_high`?`DOCUMENT_BOX_TOO_LARGE`:e===`edge_proximity`?`DOCUMENT_BOX_NEAR_EDGE`:e===`opposite_edges`?`DOCUMENT_BOX_TOUCHES_EDGES`:e===`aspect_ratio`?`DOCUMENT_NOT_SUPPORTED`:`DOCUMENT_SHAPE_INVALID`,je=({analysis:e,dataValid:t,isBack:n,minFaceAreaRatio:r,rejectionReasons:i,valid:a,stable:o})=>{let s=`front`;n?s=`back`:e.documentKind===`passport`&&(s=`passport`);let c=Object.keys(e.documentAnalysis.diagnostics.rejected)[0];return c?{target:s,code:Ae({rejection:c})}:e.detection?e.documentAnalysis.isBlurry?{target:s,code:`DOCUMENT_BLURRY`}:n&&i.includes(C.DOCUMENT_BACK_CONTAINS_FACE)?{target:s,code:`DOCUMENT_BACK_HAS_FACE`}:n&&i.includes(C.DOCUMENT_BACK_NOT_DISTINCT)?{target:s,code:`DOCUMENT_BACK_SAME_AS_FRONT`}:!n&&!e.face?{target:s,code:`DOCUMENT_FRONT_FACE_NOT_DETECTED`}:!n&&!e.faceContained?{target:s,code:`DOCUMENT_FRONT_FACE_NOT_CONTAINED`}:!n&&!e.alignment.faceAreaValid&&e.alignment.faceAreaRatio<r?{target:s,code:`DOCUMENT_FRONT_FACE_TOO_SMALL`}:!n&&(!e.alignment.faceAreaValid||!e.alignment.faceDimensionsValid)?{target:s,code:`DOCUMENT_FRONT_FACE_SIZE_INVALID`}:!n&&(!e.alignment.textParallel||e.alignment.textSide===`unknown`||e.alignment.faceAdjacentTextLineCount<2)?{target:s,code:`DOCUMENT_FRONT_LAYOUT_INVALID`}:!e.text.text||e.text.lines.length<2?{target:s,code:`DOCUMENT_TEXT_NOT_READABLE`}:!n&&!e.documentKind?{target:s,code:`DOCUMENT_NOT_RECOGNIZED`}:t?a?o?{target:s,code:null}:{target:s,code:`DOCUMENT_STABILITY_REQUIRED`}:{target:s,code:`DOCUMENT_VALIDATION_FAILED`}:{target:s,code:`DOCUMENT_CODE_NOT_READABLE`}:{target:s,code:`DOCUMENT_NOT_DETECTED`}},J=e({offset:!0}).nullable(),Y=M([`verify_face`,`verify_document`,`match_id`,`match_reference`]),X=o({id:V(),user_id:V().nullable(),ip:f().nullable(),origin:f().nullable(),user_agent:f().nullable(),language:f().nullable(),timezone:f().nullable(),country:f().nullable(),region:f().nullable(),city:f().nullable(),action:Y,source_ids:p(V()),document_code:f().nullable(),outcome:_.nullable(),match:h().nullable(),feedback_match:h().nullable(),feedback_reason:f().nullable(),feedback_created_at:J,score:v().nullable(),threshold:v().nullable(),token_hash:f(),expires_at:e({offset:!0}),consumed_at:J,resolved_at:J,started_at:e({offset:!0}),completed_at:J,execution_ms:v().nullable(),error:f().nullable(),created_at:e({offset:!0}),updated_at:e({offset:!0})}).meta({id:`Verification`}),Me=X.omit({created_at:!0,updated_at:!0,timezone:!0,country:!0,region:!0,city:!0,feedback_match:!0,feedback_reason:!0,feedback_created_at:!0}).partial({outcome:!0,origin:!0,language:!0,completed_at:!0,consumed_at:!0,resolved_at:!0,document_code:!0,match:!0,score:!0,threshold:!0,execution_ms:!0,error:!0,source_ids:!0}),Ne=o({id:V().meta({param:{in:`path`,name:`id`}})}),Pe={action:Y,intentInput:o({action:Y}),intent:m.extend({action:Y}),row:X,rowInsert:Me,id:Ne,list:p(X),captures:l(f(),a).meta({id:`VerificationCaptures`}),update:Ne.extend({match:h(),reason:f().min(10).max(2e3)}),public:o({resultId:V(),action:Y,outcome:_.nullable(),matched:h().nullable(),score:v().nullable(),threshold:v().nullable(),reason:N.nullable(),documentCode:f().nullable(),identity:t.nullable(),completedAt:J,createdAt:e({offset:!0})})},Fe=async({clientKey:e,apiUrl:t,signal:n})=>{await L({apiUrl:t,path:`/auth/me`,method:`GET`,clientKey:e,signal:n})},Ie=({apiUrl:e})=>{if(typeof navigator<`u`&&typeof navigator.sendBeacon==`function`)try{navigator.sendBeacon(`${O({url:e??`https://api.voltom.io`})}/script-loads`)}catch{return}},Le=async({clientKey:e,apiUrl:t,endpoint:n,documentBack:r,documentFront:i,faces:a=[],options:o,picture:s,poseReference:l,poseReferences:u,poses:d=[],sourceIds:f=[],threshold:p,token:m,signal:h})=>{if(!e)throw c({code:C.CLIENT_KEY_REQUIRED});let g=JSON.stringify({token:m,documentFront:i?await j({image:i}):void 0,documentBack:r?await j({image:r}):void 0,reference:s?await j({image:s}):void 0,poseReference:l?await j({image:l}):void 0,poseReferences:u?await Promise.all(u.map(e=>Promise.all(e.map(e=>j({image:e}))))):void 0,faces:await Promise.all(a.map(e=>j({image:e}))),options:o,poses:d.map(e=>me[e]),source_ids:f,threshold:p});h?.throwIfAborted();let _=await L({apiUrl:t,path:n,body:g,clientKey:e,signal:h}),v=Pe.public.safeParse(_);if(!v.success)throw c({code:C.INVALID_SERVICE_RESPONSE,cause:_});let y=v.data,{outcome:b,matched:x}=y;if(b===null||x===null)throw c({code:C.INVALID_SERVICE_RESPONSE,cause:_});if(b===`error`)throw c({code:y.reason??C.INTERNAL_ERROR,resultId:y.resultId,cause:y});if(y.outcome===`pass`!==y.matched||y.outcome===`pass`&&y.reason!==null)throw c({code:C.INVALID_SERVICE_RESPONSE,cause:y});return{...y,outcome:b,matched:x}},{loadDocumentBoxDetector:Re,detectDocumentOrientation:ze}=G,{detectPictureFaces:Z,loadFaceDetector:Be}=W,{loadFaceMatch:Ve,warmupFaceMatch:He}=q,{loadFaceLiveness:Ue}=fe,{loadTextDetector:We}=pe,Ge={"/verify/face":`verify_face`,"/verify/document":`verify_document`,"/match/id":`match_id`,"/match/reference":`match_reference`},Ke=({options:e,view:t,display:n,events:r})=>{let i=t.ref,a=[...be],o=({language:e})=>e??b(),s=()=>({reference:null,faceReference:null,identity:null,flow:null,session:0,faceSequence:[...a],poseIndex:0,poseStableFrames:0,documentStableFrames:0,documentOrientation:null,documentFaceEmbeddings:null,documentFrontSignature:null,documentCodes:[],matchOptions:{alignment:e.alignment,threshold:e.threshold},captures:{},preparedCaptures:{},faceEmbeddings:{},previousPoseBackgroundSignature:null,neutralPose:null,guidanceCodeState:oe(),correctiveState:E(),faceVerificationId:null,documentVerificationId:null,cameraActive:!1,cameraSize:n.cameraSize,cameraFacingMode:n.cameraFacingMode}),l=({active:e,state:t})=>{t.cameraActive!==e&&(t.cameraActive=e,r.dispatchEvent(new CustomEvent(`voltom:camera-change`,{detail:{active:e}})))},f=({state:e})=>{T({video:i.video}),l({active:!1,state:e}),e.cameraSize.value=null,e.cameraFacingMode.value=null,n.feedback.value=null,n.guidance.value=null,n.corrective.value=null,n.success.value=!1},p=({state:e})=>({identity:e.identity,document:e.document,captures:{...e.captures,...e.reference?{reference:e.reference.picture??e.reference.portrait}:{}},documentCodes:[...e.documentCodes],preparedCaptures:{...e.preparedCaptures}}),m=({state:e})=>{let t=p({state:e});r.dispatchEvent(new CustomEvent(`voltom:captures-change`,{detail:t}))},h=({state:t,options:r=e})=>{t.faceReference=t.reference,t.faceSequence=t.faceReference?[`faceStraight`,...(t.faceReference.poseGroups??[null]).map(()=>`faceReference`)]:j({options:r}),t.poseIndex=0,t.poseStableFrames=0;let{documentFront:i,documentBack:a,reference:o}=t.preparedCaptures;t.preparedCaptures={...i?{documentFront:i}:{},...a?{documentBack:a}:{},...o?{reference:o}:{}},t.faceEmbeddings={},t.previousPoseBackgroundSignature=null,t.neutralPose=null,t.guidanceCodeState=oe(),t.correctiveState=E(),n.corrective.value=null,t.faceVerificationId=null;let{documentFront:s,documentBack:c}=t.captures;t.captures={...s?{documentFront:s}:{},...c?{documentBack:c}:{}}},_=({state:e})=>{e.documentStableFrames=0,e.documentOrientation=null,e.documentFaceEmbeddings=null,e.documentFrontSignature=null,e.identity=null,e.documentCodes=[],delete e.document,e.documentVerificationId=null,delete e.preparedCaptures.documentFront;let t={...e.captures};delete t.documentFront,delete t.documentBack,e.captures=t},v=({state:e})=>{e.session+=1,e.flow=null,f({state:e}),A({element:i.mesh}),n.debug.value=[]},x=({state:e})=>{v({state:e}),m({state:e}),n.error.value=null},S=({state:e})=>{let t=i.video.videoWidth,n=i.video.videoHeight;t&&n&&(e.cameraSize.value={width:t,height:n})},D=async({facingMode:e,state:t})=>{f({state:t});let n=t.session,r=await ne({facingMode:e,video:i.video});if(t.session!==n)throw T({video:i.video}),z();t.cameraFacingMode.value=r,S({state:t}),l({active:!0,state:t})},O=({flow:e,session:t,state:n})=>n.flow===e&&n.session===t,k=({state:e})=>e.faceSequence[e.poseIndex]??`faceStraight`,j=({options:e})=>K({poses:e.poses,randomize:e.randomizeFaceSequence??!1}),M=({configuration:e})=>{let t=Object.fromEntries(Object.keys(d).map(t=>[t,e[t]]));return t.language=o({language:e.language}),t},N=async({configuration:e,endpoint:t,state:n,picture:r,sourceIds:i=[],signal:a})=>{let o=U({captures:n.captures,state:n})?_e({captures:n.captures,state:n}):null,s=Ge[t]??t,l=e.authorize,u=l?await ie({task:()=>l({action:s})}):void 0;return u!==void 0&&re({intent:u,action:s}),a?.throwIfAborted(),await Le({clientKey:e.clientKey,apiUrl:e.apiUrl,endpoint:t,token:u?.token,documentBack:r?void 0:n.captures.documentBack,documentFront:r?void 0:n.captures.documentFront,faces:o?.faces,options:M({configuration:e}),picture:r,poseReference:n.faceReference?.poseGroups?void 0:n.faceReference?.portrait,poseReferences:n.faceReference?.poseGroups?.map(e=>e.candidateIndices.map(e=>{let t=n.faceReference?.candidates?.[e];if(!t)throw c({code:C.NO_USABLE_CANDIDATES});return t.portrait})),poses:o?.poses,sourceIds:i,threshold:e.threshold,signal:a})},P={options:e,view:t,display:n,isActive:O,notifyCapturesChanged:m,getVerifyOptions:M},{runFaceLoop:se}=ye(P),{runDocumentLoop:F}=Oe(P),ce=async({state:e,options:t})=>{n.stage.value=`face`,v({state:e}),h({state:e,options:t}),n.progress.value={completed:0,total:e.faceSequence.length},e.matchOptions={alignment:t.alignment,threshold:t.threshold},m({state:e});let r=e.session;e.flow=`face`;try{if(n.feedback.value={flow:`face`,pose:k({state:e}),code:null},await D({facingMode:`user`,state:e}),n.feedback.value={flow:`face`,pose:k({state:e}),code:null},await se({session:r,state:e,options:t}),e.session!==r)throw z();if(!U({captures:e.captures,state:e}))throw c({code:C.CAPTURES_INCOMPLETE});let a={...e.captures};return f({state:e}),A({element:i.mesh}),a}finally{e.session===r&&(n.feedback.value=null)}},I=async({state:t,options:r=e})=>{n.stage.value=`document`,v({state:t}),_({state:t}),t.matchOptions={alignment:r.alignment,threshold:r.threshold},m({state:t});let a=t.session;t.flow=`document`;try{if(!O({flow:`document`,session:a,state:t})||(await D({facingMode:`environment`,state:t}),n.feedback.value={flow:`document`,code:null,target:`front`},await F({session:a,state:t,options:r}),t.session!==a))throw z();if(!t.captures.documentFront||!t.document)throw c({code:C.CAPTURES_INCOMPLETE});if(t.document.document!==`passport`&&(t.documentStableFrames=0,t.documentOrientation=null,t.flow=`document`,n.feedback.value={flow:`document`,code:null,target:`back`},await F({session:a,state:t,options:r}),t.session!==a))throw z();if(!t.document.valid)throw c({code:C.DOCUMENT_VALIDATION_FAILED});let e={...t.captures};return f({state:t}),A({element:i.mesh}),e}finally{t.session===a&&(n.feedback.value=null,A({element:i.mesh}))}},L=async()=>{let t=e.capabilities.some(e=>e===`acquireDocument`||e===`matchID`),n=e.capabilities.some(e=>e===`acquireFace`||e===`matchID`||e===`matchReference`),r=[Re(),Be({faceDetector:e.faceDetector}),Ve(),...n?[Ue()]:[],...t?[Ce(),We({engine:`tiny`,language:`latin`}),We({engine:e.ocrEngine,language:o({language:e.language})}),we()]:[],...e.showFaceOverlay||e.showDocumentOverlay?[Se()]:[]];await Promise.all(r);let i=document.createElement(`canvas`);i.width=640,i.height=480;let a=await createImageBitmap(i);try{let e=[Z(a),G.detectDocumentBox(a),He()];t&&e.push(ze({frame:a,boundingRect:{x:0,y:0,width:a.width,height:a.height}})),await Promise.all(e)}finally{a.close()}},R=async()=>{let t=e.capabilities.some(e=>e===`acquireDocument`||e===`matchID`),n=e.capabilities.some(e=>e===`acquireFace`||e===`matchID`||e===`matchReference`),r=[`dd.ort`,te[e.faceDetector],`fl.ort`,`fe.ort`,...n?[`flv.ort`,`flw.ort`]:[],`fmu.ort`,`ort-wasm-simd-threaded.mjs`,`ort-wasm-simd-threaded.wasm`,...t?[`do.ort`,`zxing-wasm/reader/index.js`,`zxing-wasm/share.js`,`zxing-wasm/reader/zxing_reader.wasm`]:[],...e.showFaceOverlay||e.showDocumentOverlay?[`faceMeshLines.json`]:[]],i=[g({filenames:r})];t&&(i.push(g({filenames:H({language:`latin`,engine:`tiny`})})),i.push(g({filenames:H({language:o({language:e.language}),engine:e.ocrEngine})}))),await Promise.all(i)},z=()=>c({code:C.OPERATION_CANCELLED}),B=async({frame:e,face:t,options:n})=>{let r=t.boundingRect,i=Math.max(0,Math.floor(r.x-r.width*.25)),a=Math.max(0,Math.floor(r.y-r.height*.25)),o=Math.min(e.width-i,Math.ceil(r.width*1.5)),s=Math.min(e.height-a,Math.ceil(r.height*1.5)),c=await createImageBitmap(e,i,a,o,s);try{let e=await Z(c,{forMatch:!0}),t=e=>Math.hypot(e.boundingRect.x+e.boundingRect.width/2-(r.x+r.width/2-i),e.boundingRect.y+e.boundingRect.height/2-(r.y+r.height/2-a)),[o]=e.sort((e,n)=>t(e)-t(n));if(!o)return null;let s=q.prepareFace({alignment:n.alignment,face:o,frame:c}),l=s?await q.preparedFaceArtifacts({face:s}):null;return l?{portrait:await ae({frame:c}),pose:{yaw:o.yaw,pitch:o.pitch,roll:o.roll},images:l.images}:null}finally{c.close()}};return{createState:s,stop:x,syncCameraSize:S,captureResult:p,resetFaceFlow:h,resetDocumentFlow:_,notifyCapturesChanged:m,startFaceFlow:ce,startDocumentFlow:I,prepareReference:async({picture:e,digest:t,state:n,options:r,signal:i,multipleFaces:a=!1})=>{let o=await q.imageBitmap({blob:e});try{let s=await Z(o,{forMatch:!0}),l=[];for(let e of a?s:s.slice(0,1)){i.throwIfAborted();let t=await B({frame:o,face:e,options:r});t&&l.push(t)}i.throwIfAborted();let u=l[0];if(!u)throw c({code:C.NO_USABLE_CANDIDATES});let d=a?y({poses:l.map(e=>e.pose)}):void 0;if(d&&d.length+1>he.length)throw c({code:C.INVALID_POSES});return n.preparedCaptures.reference=u.images,{digest:t,portrait:u.portrait,pose:u.pose,...a?{picture:e,candidates:l.map(({portrait:e,pose:t})=>({portrait:e,pose:t})),poseGroups:d}:{}}}finally{o.close()}},validatePoses:({poses:e})=>{K({poses:e,randomize:!1})},submitVerification:N,initializeModels:L,preloadModels:R,showError:({error:e,state:t})=>{let r=ee({error:e});r===C.FACE_SPOOF_DETECTED&&h({state:t}),r!==C.OPERATION_CANCELLED&&v({state:t}),u(()=>{n.activity.value=null,r===C.OPERATION_CANCELLED?n.retry.value=null:n.error.value=w({error:e})})}}},Q,qe=async()=>{try{Q??=import(i({filename:`pdf/pdf.mjs`}));let e=await Q;return e.GlobalWorkerOptions.workerSrc=i({filename:`pdf/pdf.worker.mjs`}),e}catch{throw Q=void 0,c({code:C.PDF_LOAD_FAILED})}},Je=async({blob:e,signal:t})=>{if(new TextDecoder().decode(await e.slice(0,5).arrayBuffer())!==`%PDF-`)return null;if(e.size>1e7)throw c({code:C.REQUEST_TOO_LARGE});t.throwIfAborted();let r=await qe();t.throwIfAborted();let a=new Uint8Array(await e.arrayBuffer()),o=r.getDocument({data:a,cMapUrl:i({filename:`pdf/cmaps/`}),cMapPacked:!0,standardFontDataUrl:i({filename:`pdf/standard_fonts/`}),wasmUrl:i({filename:`pdf/wasm/`})}),s=()=>{o.destroy()};t.addEventListener(`abort`,s,{once:!0});let l;try{let e=await o.promise;t.throwIfAborted();let n=await e.getPage(1),r=n.getViewport({scale:1}),i=n.getViewport({scale:Math.min(1,1200/Math.max(r.width,r.height))}),a=window.document.createElement(`canvas`);a.width=Math.ceil(i.width),a.height=Math.ceil(i.height),await n.render({canvas:a,viewport:i,background:`white`}).promise,t.throwIfAborted(),l=await createImageBitmap(a),a.width=0,a.height=0;let s=await W.detectPictureFaces(l,{forMatch:!0});t.throwIfAborted();let u=s[0];if(!u)throw c({code:C.NO_USABLE_CANDIDATES});let d=u.boundingRect,f=Math.max(0,Math.floor(d.x-d.width*.25)),p=Math.max(0,Math.floor(d.y-d.height*.25)),m=Math.min(l.width-f,Math.ceil(d.width*1.5)),h=Math.min(l.height-p,Math.ceil(d.height*1.5)),g=new OffscreenCanvas(m,h),_=g.getContext(`2d`);if(!_)throw c({code:C.IMAGE_PROCESSING_FAILED});_.drawImage(l,f,p,m,h,0,0,m,h);let v=await g.convertToBlob({type:`image/jpeg`,quality:.95});return t.throwIfAborted(),v}catch(e){throw t.throwIfAborted(),n(e)?e:e instanceof Error&&e.name===`PasswordException`?c({code:C.PDF_PASSWORD_REQUIRED}):c({code:C.INVALID_PDF})}finally{t.removeEventListener(`abort`,s),l?.close(),await o.destroy()}},$={...d,faceDetector:`standard`,language:void 0,clientKey:``,threshold:x,randomizeFaceSequence:!1,requireEyeLevelCamera:!0,requiredFaceStableFrames:2,requiredDocumentStableFrames:2,showFaceOverlay:!1,showDocumentOverlay:!1,showTextOverlay:!1,faceOverlayColor:`transparent`,faceMeshColor:`#38efb0`,documentOverlayColor:`transparent`,documentBoxColor:`#22d3ee`,documentFaceBoxColor:`#22d3ee`,documentFaceMeshColor:`#38efb0`,textColor:`#22d3ee`,debug:D.debug,capabilities:[`acquireFace`,`acquireDocument`,`acquireReference`,`matchID`,`matchReference`]},Ye=class{static Errors=C;static isSdkError=n;options;view;root;useUi;videoElement;resizeListener;display=xe();events=new EventTarget;translator;flows;state;preparation=null;preloading=null;preparationController=null;prepared=!1;disposed=!1;operationController=null;subscriptions=new Set;uiAttached=!1;notifyStatus({status:e}){this.events.dispatchEvent(new CustomEvent(`voltom:${e}`))}showSpinner({message:e=this.translator.translate(`checkingFaceMatch`)}={}){this.display.activity.value={message:e}}hideSpinner(){this.display.activity.value=null}async runWithSpinner({task:e,message:t}){this.showSpinner({message:t});try{return await e()}finally{this.hideSpinner()}}constructor(e){if(P({options:e,capabilities:[`acquireFace`,`acquireDocument`,`acquireReference`,`matchID`,`matchReference`],authorizeRequired:!1}),`root`in e)throw c({code:C.INVALID_OPTIONS});let{video:t,ui:n=!0,prepare:r=D.prepare,...i}=e;if(!n&&!t)throw c({code:C.INVALID_OPTIONS});if(!i.clientKey)throw c({code:C.CLIENT_KEY_REQUIRED});this.options=Object.freeze({...$,...I(i),...se(i),requireEyeLevelCamera:i.requireEyeLevelCamera??!0,capabilities:Object.freeze([...i.capabilities??$.capabilities]),poses:Array.isArray(i.poses)?Object.freeze([...i.poses]):i.poses}),this.root=document.createElement(`div`),this.useUi=n,this.videoElement=t??document.createElement(`video`),this.translator=le({language:this.options.language}),this.view={ref:{root:this.root,camera:document.createElement(`div`),video:this.videoElement,mesh:document.createElement(`canvas`)},collectFaceDebug:()=>{},collectDocumentDebug:()=>{},open:()=>{},close:()=>{},dispose:()=>{}},this.flows=Ke({options:this.options,view:this.view,display:this.display,events:this.events}),this.state=this.flows.createState(),this.resizeListener=()=>this.flows.syncCameraSize({state:this.state}),this.videoElement.addEventListener(`resize`,this.resizeListener),r&&this.prepare().catch(e=>console.error(e))}async preload(){try{await this.preloadInternal()}catch(e){throw w({error:e,fallback:C.MODEL_LOAD_FAILED})}}async preloadInternal(){if(this.disposed)throw c({code:C.SDK_DISPOSED});if(this.preloading)return this.preloading;let e=(async()=>{await r({language:this.options.language}),await this.flows.preloadModels()})();this.preloading=e;try{if(await e,this.disposed)throw c({code:C.SDK_DISPOSED})}catch(t){throw this.preloading===e&&(this.preloading=null),w({error:t,fallback:C.MODEL_LOAD_FAILED})}}async prepare(){try{await this.prepareInternal()}catch(e){throw w({error:e,fallback:C.MODEL_LOAD_FAILED})}}async prepareInternal(){if(this.disposed)throw c({code:C.SDK_DISPOSED});if(this.preparation)return this.preparation;let e=new AbortController;this.preparationController=e;let t=(async()=>{await this.preload(),await this.attachUi(),await this.runWithSpinner({task:async()=>{if(await Fe({clientKey:this.options.clientKey,apiUrl:this.options.apiUrl,signal:e.signal}),await Ie({apiUrl:this.options.apiUrl}),await this.flows.initializeModels(),e.signal.throwIfAborted(),this.disposed)throw c({code:C.SDK_DISPOSED})},message:this.translator.translate(`preparingModels`)})})();this.preparation=t;try{await t,this.prepared=!0,this.preparationController===e&&(this.preparationController=null)}catch(n){throw this.preparation===t&&(this.preparation=null),this.preparationController===e&&(this.preparationController=null),w({error:n,fallback:C.MODEL_LOAD_FAILED})}}async attachUi(){if(!this.useUi||this.uiAttached)return;let{createVerificationView:e}=await import(`./view-CF_YOVly.js`);if(this.disposed)throw c({code:C.SDK_DISPOSED});if(this.uiAttached)return;let t=e({root:this.root,options:this.options,display:this.display,onStop:()=>this.stop()});this.videoElement.removeEventListener(`resize`,this.resizeListener),Object.assign(this.view.ref,t.ref),this.view.collectFaceDebug=t.collectFaceDebug,this.view.collectDocumentDebug=t.collectDocumentDebug,this.view.open=t.open,this.view.close=t.close,this.view.dispose=t.dispose,this.videoElement=this.view.ref.video,this.videoElement.addEventListener(`resize`,this.resizeListener),this.uiAttached=!0}async submitVerification(e){let t=e.endpoint===`/verify/document`?this.translator.translate(`checkingDocument`):void 0;return await this.runWithSpinner({task:()=>this.flows.submitVerification({...e,signal:e.signal??this.operationController?.signal}),message:t})}async caniuse(){return await k()}async runOperation({retry:e,task:t,onError:n,capability:r,requiresUi:i=!0}){if(this.disposed)throw c({code:C.SDK_DISPOSED});if(!this.options.capabilities.includes(r))throw c({code:C.SDK_CAPABILITY_NOT_CONFIGURED});if(this.operationController)throw c({code:C.OPERATION_IN_PROGRESS});let a=Object.freeze({...this.options}),o=new AbortController;this.operationController=o,o.signal.addEventListener(`abort`,()=>this.flows.stop({state:this.state}),{once:!0}),this.notifyStatus({status:`in-progress`}),u(()=>{this.display.reference.value=!!this.state.reference||r===`acquireReference`||r===`matchReference`,this.display.stage.value=`face`,r===`acquireDocument`&&(this.display.stage.value=`document`),(r===`acquireReference`||r===`matchReference`)&&(this.display.stage.value=`reference`),this.display.retry.value=e,this.display.error.value=null,this.display.debugEnabled.value=a.debug,a.debug||(this.display.debug.value=[])});try{return await this.attachUi(),o.signal.throwIfAborted(),i&&this.view.open(),o.signal.throwIfAborted(),await s({operation:this.prepare(),signal:o.signal}),o.signal.throwIfAborted(),await t({options:a,signal:o.signal})}catch(e){let t=w({error:e,signal:o.signal});throw n&&await n({error:t,options:a,signal:o.signal}),this.disposed||this.flows.showError({error:t,state:this.state}),t}finally{this.view.close(),this.notifyStatus({status:`ready`}),this.display.debugEnabled.value=this.options.debug,this.operationController===o&&(this.operationController=null)}}setDebug({enabled:e}){if(this.disposed)throw c({code:C.SDK_DISPOSED});if(typeof e!=`boolean`)throw c({code:C.INVALID_OPTIONS});this.options=Object.freeze({...this.options,debug:e}),this.display.debugEnabled.value=e,e||(this.display.debug.value=[])}configure(e){if(this.disposed)throw c({code:C.SDK_DISPOSED});R({options:e});let t=[`poses`,`randomizeFaceSequence`,`showFaceOverlay`,`showDocumentOverlay`,`showTextOverlay`,`debug`];for(let[n,r]of Object.entries(e))if(!t.includes(n)||n!==`poses`&&r!==void 0&&typeof r!=`boolean`)throw c({code:C.INVALID_OPTIONS});if(e.poses!==void 0){if(e.poses!==`all`&&!Array.isArray(e.poses))throw c({code:C.INVALID_OPTIONS});this.flows.validatePoses({poses:e.poses})}this.options=Object.freeze({...this.options,...I(e),poses:Array.isArray(e.poses)?Object.freeze([...e.poses]):e.poses??this.options.poses})}async acquireFace(){return await this.acquireCapture({flow:`face`})}async acquireDocument(){return await this.acquireCapture({flow:`document`})}async acquireCapture({flow:e}){return await this.runOperation({capability:e===`face`?`acquireFace`:`acquireDocument`,retry:()=>this.acquireCapture({flow:e}),onError:async({error:t,options:n})=>{ee({error:t})!==C.OPERATION_CANCELLED&&(e===`face`?this.flows.resetFaceFlow({state:this.state,options:n}):this.flows.resetDocumentFlow({state:this.state}),this.flows.notifyCapturesChanged({state:this.state}))},task:async({options:t,signal:n})=>{await(e===`face`?this.flows.startFaceFlow:this.flows.startDocumentFlow)({state:this.state,options:t}),n.throwIfAborted();let r=await this.verifyAcquisition({flow:e,options:t});return r.matched&&(this.display.retry.value=null),r}})}async verifyAcquisition({flow:e,options:t}){let n=await this.submitVerification({configuration:t,endpoint:`/verify/${e}`,state:this.state}),r=e===`face`?`faceVerificationId`:`documentVerificationId`;return this.state[r]=n.matched?n.resultId:null,n.matched||(e===`face`?this.flows.resetFaceFlow({state:this.state,options:t}):this.flows.resetDocumentFlow({state:this.state}),this.flows.notifyCapturesChanged({state:this.state})),n}async ensureFaceVerification({options:e,signal:t}){if(t.throwIfAborted(),this.state.faceVerificationId)return null;await this.flows.startFaceFlow({state:this.state,options:e}),t.throwIfAborted();let n=await this.verifyAcquisition({flow:`face`,options:e});return n.matched?null:n}async prepareReference({file:e,options:t,signal:n}){if(this.display.stage.value=`reference`,!(e instanceof Blob))throw this.clearReference(),c({code:C.INVALID_OPTIONS});if(e.size>1e7)throw this.clearReference(),c({code:C.REQUEST_TOO_LARGE});let r=await e.arrayBuffer();n.throwIfAborted();let i=await crypto.subtle.digest(`SHA-256`,r),a=Array.from(new Uint8Array(i),e=>e.toString(16).padStart(2,`0`)).join(``);if(n.throwIfAborted(),this.state.reference?.digest===a)return this.state.reference;this.clearReference();let o=await Je({blob:e,signal:n}),s=o??await F({blob:e}),l=await this.flows.prepareReference({picture:s,digest:a,state:this.state,options:t,signal:n,multipleFaces:o===null});return n.throwIfAborted(),this.state.reference=l,this.flows.resetFaceFlow({state:this.state,options:t}),this.flows.notifyCapturesChanged({state:this.state}),l}async acquireReference(e){return await this.runOperation({capability:`acquireReference`,retry:()=>this.acquireReference(e),task:async({options:t,signal:n})=>{let r=await this.runWithSpinner({task:()=>this.prepareReference({file:e,options:t,signal:n}),message:this.translator.translate(`preparingReference`)});return this.display.retry.value=null,r}})}async matchID(){return await this.runOperation({capability:`matchID`,retry:()=>this.matchID(),requiresUi:!this.state.faceVerificationId||!this.state.documentVerificationId,task:async({options:e,signal:t})=>{let n=await this.ensureFaceVerification({options:e,signal:t});if(n)return n;if(!this.state.documentVerificationId){await this.flows.startDocumentFlow({state:this.state,options:e}),t.throwIfAborted();let n=await this.verifyAcquisition({flow:`document`,options:e});if(!n.matched)return n}t.throwIfAborted(),this.display.stage.value=`matching`;let r=await this.submitVerification({configuration:e,endpoint:`/match/id`,state:this.state,sourceIds:[this.state.faceVerificationId,this.state.documentVerificationId]});return r.matched&&(this.display.retry.value=null),r}})}async matchReference(e){return await this.runOperation({capability:`matchReference`,retry:()=>this.matchReference(e),requiresUi:!this.state.faceVerificationId,task:async({options:t,signal:n})=>{let r=await this.runWithSpinner({task:()=>this.prepareReference({file:e,options:t,signal:n}),message:this.translator.translate(`preparingReference`)}),i=await this.ensureFaceVerification({options:t,signal:n});if(i)return i;n.throwIfAborted(),this.display.stage.value=`matching`;let a=await this.submitVerification({configuration:t,endpoint:`/match/reference`,state:this.state,picture:r.picture??r.portrait,sourceIds:[this.state.faceVerificationId]});return a.matched&&(this.display.retry.value=null),a}})}clearReference(){this.state.reference=null,this.display.feedback.value=null,delete this.state.preparedCaptures.reference,this.flows.notifyCapturesChanged({state:this.state})}forgetReference(){if(this.disposed)throw c({code:C.SDK_DISPOSED});if(this.operationController)throw c({code:C.OPERATION_IN_PROGRESS});this.clearReference(),this.display.error.value=null}stop(){this.operationController?.abort(c({code:C.OPERATION_CANCELLED})),this.flows.stop({state:this.state}),this.display.retry.value=null,this.view.close(),this.notifyStatus({status:`ready`})}dispose(){if(!this.disposed){this.disposed=!0,this.preparationController?.abort(),this.stop();for(let e of this.subscriptions)e();this.subscriptions.clear(),this.videoElement.removeEventListener(`resize`,this.resizeListener),this.view.dispose(),this.state.captures={},this.state.preparedCaptures={},this.state.faceEmbeddings={},this.state.documentCodes=[],this.state.identity=null,this.state.faceVerificationId=null,this.state.documentVerificationId=null,delete this.state.document,this.clearReference(),this.state.faceReference=null}}forgetFace(){if(this.disposed)throw c({code:C.SDK_DISPOSED});if(this.operationController)throw c({code:C.OPERATION_IN_PROGRESS});this.flows.resetFaceFlow({state:this.state}),this.display.error.value=null,this.flows.notifyCapturesChanged({state:this.state})}forgetDocument(){if(this.disposed)throw c({code:C.SDK_DISPOSED});if(this.operationController)throw c({code:C.OPERATION_IN_PROGRESS});this.flows.resetDocumentFlow({state:this.state}),this.display.error.value=null,this.flows.notifyCapturesChanged({state:this.state})}getState(){return{activity:this.display.activity.value,error:this.display.error.value,retryAvailable:this.display.retry.value!==null,feedback:this.display.feedback.value,debug:this.display.debug.value}}subscribe(e){if(this.disposed)throw c({code:C.SDK_DISPOSED});let t=ce(()=>e(this.getState()));return this.subscriptions.add(t),()=>{t(),this.subscriptions.delete(t)}}};export{C as Errors,Ye as default,n as isSdkError};
@@ -0,0 +1,3 @@
1
+ /*! Copyright (c) 2026 VOLTOM. All rights reserved. Proprietary software. See LICENSE at https://voltom.io/license. */
2
+ import{$t as e,Ht as t,O as n,Q as r,Qt as i,St as a,Ut as o,Zt as s,_t as c,bt as l,l as u,xt as d}from"./requests-DW8zDX51.js";import{a as f,i as p,n as m,r as h,t as g}from"./PoseSuccess-R_8JYo--.js";import"./PoseSilhouette-D2pGu7Lh.js";import{c as _,r as v,s as y}from"./presentation-COhoAxj3.js";var b=`/*! tailwindcss v4.3.4 | MIT License | https://tailwindcss.com */
3
+ @layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:block))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-border-style:solid;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-font-weight:initial;--tw-outline-style:solid;--tw-leading:initial}}}[data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light dark;--theme-canvas:var(--lightningcss-light,#fafafa)var(--lightningcss-dark,#0b0b0b);--theme-surface:var(--lightningcss-light,#fff)var(--lightningcss-dark,#202020);--theme-surface-subtle:var(--lightningcss-light,#f5f5f5)var(--lightningcss-dark,#2c2c2c);--theme-text:var(--lightningcss-light,#121212)var(--lightningcss-dark,#f7f7f7);--theme-text-muted:var(--lightningcss-light,#626262)var(--lightningcss-dark,#a3a3a3);--theme-text-inverse:var(--lightningcss-light,#fafafa)var(--lightningcss-dark,#0b0b0b);--theme-border:var(--lightningcss-light,#bfbfbf)var(--lightningcss-dark,#606060);--theme-primary:var(--lightningcss-light,#121212)var(--lightningcss-dark,#f7f7f7);--theme-primary-hover:var(--lightningcss-light,#262626)var(--lightningcss-dark,#e5e5e5);--theme-primary-active:var(--lightningcss-light,#404040)var(--lightningcss-dark,#d4d4d4);--theme-focus:var(--lightningcss-light,#525252)var(--lightningcss-dark,#d4d4d4);--theme-cocoa:var(--lightningcss-light,#6b4423)var(--lightningcss-dark,#d29a63);--theme-mint:var(--lightningcss-light,#116b4c)var(--lightningcss-dark,#38efb0);--theme-cyan:var(--lightningcss-light,#0e7490)var(--lightningcss-dark,#22d3ee);--theme-violet:var(--lightningcss-light,#5b21b6)var(--lightningcss-dark,#b69cff);--theme-berry:var(--lightningcss-light,#a21caf)var(--lightningcss-dark,#e879f9);--theme-danger:var(--lightningcss-light,#b42318)var(--lightningcss-dark,#ff6b6b);--theme-danger-surface:var(--lightningcss-light,#fee2e2)var(--lightningcss-dark,#451a19);--theme-success:var(--lightningcss-light,#087443)var(--lightningcss-dark,#4ade80);--theme-success-surface:var(--lightningcss-light,#e7f6ee)var(--lightningcss-dark,#123c2b);--theme-warning:var(--lightningcss-light,#a16207)var(--lightningcss-dark,#ffc93c);--theme-warning-surface:var(--lightningcss-light,#fef3c7)var(--lightningcss-dark,#422006)}@media (prefers-color-scheme:dark){[data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root]{--lightningcss-light: ;--lightningcss-dark:initial}}:is(.dark,[data-theme=dark]) :is([data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root]){--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark}:is(.light,[data-theme=light]) :is([data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root]){--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light}:is([data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root])[data-theme=dark]{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark}:is([data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root])[data-theme=light]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light}[data-pose-silhouette],[data-pose-arrow]{display:block;overflow:visible}[data-pose-arrow]{pointer-events:none;fill:none;width:64px;height:64px;stroke:var(--theme-mint);stroke-width:7px;stroke-linecap:round;stroke-linejoin:round;position:absolute;bottom:4%;left:50%;transform:translate(-50%)}[data-pose-arrow] [data-pose-solid]{fill:var(--theme-mint);stroke:none}[data-pose-silhouette] [data-pose-head]{fill:none;stroke:var(--theme-border);stroke-width:1.5px;stroke-dasharray:5 5}[data-pose-silhouette] [data-pose-eye]{fill:var(--theme-text-muted);stroke:none}[data-pose-silhouette] [data-pose-mouth],[data-pose-silhouette] [data-pose-eye-closed],[data-pose-motion]{fill:none;stroke:var(--theme-cyan);stroke-width:2.5px;stroke-linecap:round;stroke-linejoin:round}[data-pose-motion]{stroke-dasharray:6 6;animation:.9s linear infinite pose-motion}[data-pose-arrowhead]{fill:var(--theme-cyan);stroke:none}[data-pose-arrow] [data-pose-motion]{stroke:var(--theme-mint);stroke-width:8px;stroke-dasharray:none;animation:none}[data-pose-arrow] [data-pose-arrowhead]{fill:var(--theme-mint)}[data-pose-arrow] [data-pose-smile]{fill:none;stroke:var(--theme-mint);stroke-width:8px;stroke-linecap:round}[data-pose-progress][data-variant=bar]{gap:4px;width:100%;display:flex}[data-pose-progress][data-variant=bar] [data-pose-progress-step]{background:var(--theme-border);border-radius:9999px;flex:1;height:4px;transition:background .2s}[data-pose-progress][data-variant=bar] [data-pose-progress-step][data-complete]{background:var(--theme-mint)}[data-pose-progress][data-variant=ring]{display:block;overflow:visible}[data-pose-progress][data-variant=ring] [data-pose-progress-step]{fill:none;stroke:var(--theme-border);stroke-width:2px;stroke-linecap:round;transition:stroke .3s}[data-pose-progress][data-variant=ring] [data-pose-progress-step][data-complete]{stroke:var(--theme-mint)}[data-pose-success]{opacity:0;pointer-events:none}[data-pose-success] circle{fill:var(--theme-success-surface);stroke:var(--theme-mint);stroke-width:2px}[data-pose-success] path{fill:none;stroke:var(--theme-mint);stroke-width:5px;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:1;stroke-dashoffset:1px}[data-pose-success][data-visible]{animation:.42s ease-out both pose-success-appear}[data-pose-success][data-visible] path{animation:.24s ease-out 60ms both pose-success-draw}@keyframes pose-motion{to{stroke-dashoffset:-12px}}@keyframes pose-success-appear{0%{opacity:0;transform:scale(.85)}to{opacity:1;transform:scale(1)}}@keyframes pose-success-draw{to{stroke-dashoffset:0}}@media (prefers-reduced-motion:reduce){[data-pose-motion]{animation:none}[data-pose-success][data-visible]{opacity:1}[data-pose-success][data-visible] path{stroke-dashoffset:0}}@layer components{[data-voltom-dialog]{border-style:var(--tw-border-style);background-color:var(--theme-surface);width:100%;max-width:none;height:100dvh;max-height:none;color:var(--theme-text);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;padding:max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));border-width:0;margin:0;font-family:Inter,ui-sans-serif,system-ui,sans-serif;position:fixed;inset:0;overflow-y:auto}[data-voltom-dialog][open]{flex-direction:column;align-items:center;gap:2rem;display:flex}[data-voltom-dialog]::backdrop{background:var(--theme-canvas)}[data-voltom-stage]{flex-direction:column;flex:1;justify-content:center;align-items:center;gap:1.5rem;width:100%;display:flex;position:relative}[data-voltom-camera]{aspect-ratio:1;flex-shrink:0;width:min(60vw,240px,38dvh);position:relative}[data-voltom-camera]>video,[data-voltom-mesh]{object-fit:cover;border-radius:2147483647px;width:100%;height:100%;position:absolute;inset:0}[data-voltom-camera]>video{background-color:var(--theme-surface-subtle)}[data-voltom-mesh]{pointer-events:none}[data-voltom-camera][data-mirrored]>video,[data-voltom-camera][data-mirrored] [data-voltom-mesh]{--tw-scale-x:calc(100% * -1);scale:var(--tw-scale-x) var(--tw-scale-y)}[data-voltom-ring-wrap]{pointer-events:none;position:absolute;inset:-.875rem}[data-voltom-ring-wrap] [data-pose-progress]{width:100%;height:100%;overflow:visible}[data-voltom-camera]>[data-pose-success]{pointer-events:none;z-index:10;width:7rem;height:7rem;margin:auto;position:absolute;inset:0}[data-voltom-instructions]{max-width:var(--container-lg,32rem);text-align:center;font-size:1rem;line-height:var(--tw-leading,var(--text-base--line-height,calc(1.5 / 1)));--tw-font-weight:var(--font-weight-semibold,600);font-weight:var(--font-weight-semibold,600)}[data-voltom-instructions] p{flex-direction:column;gap:.5rem;margin:0;display:flex}[data-voltom-challengeReason]{font-size:.875rem;line-height:var(--tw-leading,var(--text-sm--line-height,calc(1.25 / .875)));--tw-font-weight:var(--font-weight-normal,400);font-weight:var(--font-weight-normal,400);color:var(--theme-text-muted)}[data-voltom-spinner]{flex-direction:column;align-items:center;gap:1rem;display:flex}[data-voltom-spinner]:before{content:"";width:2rem;height:2rem;animation:var(--animate-spin,spin 1s linear infinite);border-style:var(--tw-border-style);border-width:2px;border-color:var(--theme-border);border-top-color:var(--theme-cyan);border-radius:2147483647px}@media (prefers-reduced-motion:reduce){[data-voltom-spinner]:before{animation:none}}[data-voltom-camera]>[data-voltom-spinner]{z-index:20;background-color:var(--theme-canvas);flex-direction:column;justify-content:center;align-items:center;gap:.75rem;display:flex;position:absolute;inset:0}@supports (color:color-mix(in lab, red, red)){[data-voltom-camera]>[data-voltom-spinner]{background-color:color-mix(in oklab, var(--theme-canvas) 70%, transparent)}}[data-voltom-camera]>[data-voltom-spinner]{text-align:center;font-size:.875rem;line-height:var(--tw-leading,var(--text-sm--line-height,calc(1.25 / .875)));--tw-font-weight:var(--font-weight-semibold,600);font-weight:var(--font-weight-semibold,600);color:var(--theme-text);padding-inline:1rem}[data-voltom-dialog][data-mode=face] [data-voltom-camera]>[data-voltom-spinner]{border-radius:2147483647px}[data-voltom-dialog][data-mode=document] [data-voltom-camera]>[data-voltom-spinner]{border-radius:.375rem}[data-voltom-cancel]{cursor:pointer;border-style:var(--tw-border-style);border-width:1px;border-color:var(--theme-border);background-color:var(--theme-surface);font-size:.875rem;line-height:var(--tw-leading,var(--text-sm--line-height,calc(1.25 / .875)));color:var(--theme-text);border-radius:.375rem;padding-block:.75rem;padding-inline:1.5rem}@media (hover:hover){[data-voltom-cancel]:hover{background-color:var(--theme-surface-subtle)}}[data-voltom-cancel]:focus-visible{outline-style:var(--tw-outline-style);outline-offset:4px;outline-width:2px;outline-color:var(--theme-focus)}[data-voltom-error]{color:var(--theme-danger)}[data-voltom-dialog][data-mode=document] [data-voltom-stage]{min-height:0;max-width:var(--container-4xl,56rem)}[data-voltom-dialog][data-mode=document] [data-voltom-camera]{border-style:var(--tw-border-style);--tw-border-style:dashed;border-style:dashed;border-width:2px;border-color:var(--theme-border);aspect-ratio:1.586;border-radius:.375rem;width:min(88vw,420px,82.472dvh);overflow:hidden}[data-voltom-dialog][data-mode=document] video,[data-voltom-dialog][data-mode=document] [data-voltom-mesh]{object-fit:cover;border-radius:0}[data-voltom-debug]{pointer-events:none;z-index:20;border-style:var(--tw-border-style);border-width:1px;border-color:var(--theme-border);background-color:var(--theme-surface);border-radius:.375rem;width:200px;position:fixed;top:.5rem;left:.5rem}@supports (color:color-mix(in lab, red, red)){[data-voltom-debug]{background-color:color-mix(in oklab, var(--theme-surface) 90%, transparent)}}[data-voltom-debug]{font-family:var(--font-mono,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);--tw-leading:calc(.25rem * 4);color:var(--theme-text-muted);padding-block:.25rem;padding-inline:.5rem;font-size:10px;line-height:1rem}[data-voltom-debug] [data-valid=true]{color:var(--theme-mint)}[data-voltom-debug] [data-valid=false]{color:var(--theme-danger)}[data-voltom-root] [hidden],[data-voltom-root] .hidden{display:none}}@media (width<=639px){[data-voltom-dialog][data-mode=document]{padding:max(12px, env(safe-area-inset-top)) 0 max(0px, env(safe-area-inset-bottom));gap:12px}[data-voltom-dialog][data-mode=document] [data-voltom-camera]{aspect-ratio:1/1.586;width:min(94vw,63.0517dvh - 138.714px)}}@media (width<=600px){[data-voltom-dialog][data-mode=face] [data-voltom-camera]{width:min(82vw,325px)}}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}`,x=new Set([`FACE_NOT_DETECTED`,`FACE_IN_POLYGON`,`FACE_TOO_SMALL`,`FACE_CENTER_MOVE_LEFT`,`FACE_CENTER_MOVE_RIGHT`,`FACE_CENTER_MOVE_UP`,`FACE_CENTER_MOVE_DOWN`,`FACE_CAMERA_ALIGNMENT_REQUIRED`]),S=({className:t,display:n,elements:r,options:i,onStop:a})=>{let{translate:o,translateError:s}=d({language:i.language}),c=n.feedback.value,l=n.activity.value,v=l&&l!==`matching`?l.message:``,S=l===`matching`?o(`checkingFaceMatch`):v,C=n.error.value,w=n.cameraSize.value,T=c&&c.flow===`face`?c.pose:void 0,E=c&&c.flow===`face`?c.code:null,D=E&&x.has(E)?E:null,O=n.guidance.value,k=O&&O.pose===T?O.referencePose:void 0,A=n.progress.value,j=n.corrective.value,M=T?u({pose:T,corrective:j}):null,N=o(`lookStraight`),P=``;if(M&&(N=o(M.primary),P=M.corrective?o(M.corrective):``),D&&(N=o(_({code:D})),P=``),c&&c.flow===`document`){let e=o(y({target:c.target}));N=(c.code&&c.code!==`DOCUMENT_NOT_DETECTED`?o(_({code:c.code})):``)||e}let F=n.stage.value,I=F===`document`,L=F===`reference`,R=n.reference.value?[`acquireReference`,`acquireHuman`]:[`acquireHuman`,`acquireDocument`,`matchId`],z=0;I&&(z=1),F===`matching`&&(z=R.length-1),n.reference.value&&!L&&(z=1);let B=!!l&&!L&&F!==`matching`;return f(e,{children:[f(`style`,{"data-voltom-styles":``,children:b}),f(`dialog`,{className:t,ref:r.dialog,"data-voltom-dialog":``,"data-mode":F,"aria-label":o(R[z]),"aria-describedby":`voltom-instructions`,onCancel:e=>{e.preventDefault(),e.stopPropagation(),a()},children:[f(`div`,{"data-voltom-stage":``,children:[f(`div`,{ref:r.camera,"data-voltom-camera":``,"data-mirrored":n.cameraFacingMode.value===`user`?``:void 0,style:{"--voltom-camera-ratio":w?`${w.width} / ${w.height}`:void 0},hidden:L||F===`matching`,children:[f(`video`,{ref:r.video,"data-voltom-video":``,playsInline:!0,muted:!0,autoPlay:!0,"aria-label":o(`cameraPreview`)}),f(`canvas`,{ref:r.mesh,"data-voltom-mesh":``}),!I&&f(`div`,{"data-voltom-ring-wrap":``,children:f(m,{completed:A.completed,total:A.total,label:o(`faceCaptureProgress`),variant:`ring`})}),!(F!==`face`||!T||D||l||C||n.success.value)&&f(h,{pose:T,referencePose:k}),f(g,{visible:n.success.value}),B&&f(`div`,{"data-voltom-spinner":``,"data-voltom-spinner-overlay":``,"aria-hidden":`true`})]}),f(`div`,{"data-voltom-instructions":``,id:`voltom-instructions`,role:`status`,"aria-live":`polite`,children:[B&&f(`p`,{children:S}),!!l&&!B&&f(`div`,{"data-voltom-spinner":``,"aria-label":S,children:S}),!(l||C)&&f(`p`,{children:[f(`span`,{children:N}),!!P&&f(`span`,{"data-voltom-challengeReason":``,children:P})]}),!!C&&f(`p`,{"data-voltom-error":``,children:s({error:C})})]}),f(`button`,{type:`button`,"data-voltom-cancel":``,onClick:a,autoFocus:!0,children:o(`cancel`)})]}),f(p,{kind:`voltom`,entries:n.debug.value})]})]})},C=({root:e,options:u,display:d,onStop:p})=>{let m=({language:e})=>e??a(),h=({state:e})=>e.faceSequence[e.poseIndex]??`faceStraight`,g=0,_=({entries:e,state:t})=>{if(!d.debugEnabled.value||!t.flow)return;let n=performance.now();n-g<100||(g=n,d.debug.value=e)},y=()=>d.cameraSize.value?`${d.cameraSize.value.width}x${d.cameraSize.value.height}`:`—`,b=()=>{let e=r(),t=e.threading.startsWith(`multi`)?`multi`:`single`;return[{label:`Inference`,value:e.inference},{label:`Threading`,value:t}]},x=({face:e,faceInPolygon:t,processingTimeMilliseconds:r,state:i})=>{let a=e?e.pitch:null,o=e?e.yaw:null,s=e?e.roll:null,c=e?v({face:e,name:`mouthSmileLeft`}):0,l=e?v({face:e,name:`mouthSmileRight`}):0,f=e?v({face:e,name:`eyeBlinkLeft`}):0,p=e?v({face:e,name:`eyeBlinkRight`}):0,g=a!==null&&a>=u.minPitch&&a<=u.maxPitch,x=o!==null&&o>=u.minYaw&&o<=u.maxYaw,S=h({state:i}),C=s!==null&&(S===`faceTiltLeft`?s>u.maxRoll:S===`faceTiltRight`?s<-u.maxRoll:Math.abs(s)<=u.maxRoll),w=e=>e===null?`—`:e.toFixed(2),T=(e,t)=>`${e.toFixed(2)}|${t.toFixed(2)}`;_({state:i,entries:[{label:`Flow`,value:`FACE`},...b(),{label:`Face`,valid:!!e&&!t,value:e?t?`In polygon`:`Yes`:`No`},{label:`Pitch`,valid:g,value:w(a)},{label:`Yaw`,valid:x,value:w(o)},{label:`Roll`,valid:C,value:w(s)},{label:`Smile`,valid:c>=.5&&l>=.5,value:T(c,l)},{label:`Wink left`,valid:Math.round((f-p)*100)/100>=n,value:T(f,p)},{label:`Stable frames`,valid:i.poseStableFrames>0,value:`${i.poseStableFrames}/${u.requiredFaceStableFrames}`},{label:`Language`,value:m({language:u.language})},{label:`Camera`,value:y()},{label:`Facing mode`,value:d.cameraFacingMode.value??`—`},{label:`Frame time`,value:`${r.toFixed(0)} ms`}]})},C=({analysis:e,sideComparison:t,isBack:n,processingTimeMilliseconds:r,state:i})=>{let{orientation:a,alignment:o,documentKind:s,face:c,faceContained:l,detection:f}=e,{diagnostics:p,isBlurry:h,sharpness:g}=e.documentAnalysis,v=e.text.text,x={label:`Stable frames`,valid:i.documentStableFrames>0,value:`${i.documentStableFrames}/${u.requiredDocumentStableFrames}`},S=p?Object.keys(p.rejected)[0]:void 0,C=[{label:`Sharpness`,valid:h===null?void 0:!h,value:g===null?`—`:String(Math.round(g))},{label:`Rectangle`,valid:f?!0:!S&&void 0,value:f?`yes`:S??`no`},{label:`Orientation`,value:a?`${a.rotation}°`:`—`}],w=[{label:`Text`,valid:!!v,value:v?`yes`:`no`},{label:`Document type`,value:s??``},{label:`Distinct from front`,valid:t?.distinct,value:t?t.distinct?`yes`:`no`:`—`}],T=[{label:`Face`,valid:!!c,value:c?`yes`:`no`},{label:`Face contained`,valid:l,value:l?`yes`:`no`},{label:`Face area`,valid:o.faceAreaValid,value:`${(o.faceAreaRatio*100).toFixed(2)}%`},{label:`Face size`,valid:o.faceDimensionsValid,value:o.faceDimensionsValid?`yes`:`no`},{label:`Text`,valid:!!v,value:v?`yes`:`no`},{label:`Text parallel`,valid:o.textParallel,value:o.textParallel?`yes`:`no`},{label:`Text beside face`,valid:o.faceAdjacentTextLineCount>=2,value:String(o.faceAdjacentTextLineCount)},{label:`Document type`,value:s??``}];_({state:i,entries:[{label:`Flow`,value:n?`DOCUMENT BACK`:`DOCUMENT FRONT`},...b(),...C,...n?w:T,x,{label:`Language`,value:m({language:u.language})},{label:`Camera`,value:y()},{label:`Facing mode`,value:d.cameraFacingMode.value??`—`},{label:`Frame time`,value:`${r.toFixed(0)} ms`}]})},w={dialog:s(),camera:s(),video:s(),mesh:s()};if(e.replaceChildren(),e.dataset.voltomRoot=``,l({element:e,theme:u.theme}),i(f(S,{display:d,elements:w,options:u,onStop:p}),e),!w.camera.current||!w.video.current||!w.mesh.current)throw t({code:o.UI_ELEMENT_NOT_FOUND});let T={root:e,camera:w.camera.current,video:w.video.current,mesh:w.mesh.current},E=null,D=``,O=()=>{let t=w.dialog.current;if(t&&!t.open){E=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow,document.body.style.overflow=`hidden`,document.body.append(e);try{t.showModal()}catch(t){throw e.remove(),document.body.style.overflow=D,t}}},k=()=>{let t=w.dialog.current;t?.open&&(c({video:T.video}),t.close(),e.remove(),document.body.style.overflow=D,E?.isConnected&&E.focus(),E=null)};return{ref:T,collectFaceDebug:x,collectDocumentDebug:C,open:O,close:k,dispose:()=>{k(),i(null,e),e.remove()}}};export{C as createVerificationView};
@@ -0,0 +1,3 @@
1
+ /*! Copyright (c) 2026 VOLTOM. All rights reserved. Proprietary software. See LICENSE at https://voltom.io/license. */
2
+ import{$t as e,Ht as t,Qt as n,Ut as r,Yt as i,Zt as a,_t as o,bt as s,j as c,k as l,n as u,u as d,xt as f}from"./requests-DW8zDX51.js";import{a as p,i as m,n as h,r as g,t as _}from"./PoseSuccess-R_8JYo--.js";import"./PoseSilhouette-D2pGu7Lh.js";import"./presentation-ye0KVm6U.js";var v=`/*! tailwindcss v4.3.4 | MIT License | https://tailwindcss.com */
3
+ [data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light dark;--theme-canvas:var(--lightningcss-light,#fafafa)var(--lightningcss-dark,#0b0b0b);--theme-surface:var(--lightningcss-light,#fff)var(--lightningcss-dark,#202020);--theme-surface-subtle:var(--lightningcss-light,#f5f5f5)var(--lightningcss-dark,#2c2c2c);--theme-text:var(--lightningcss-light,#121212)var(--lightningcss-dark,#f7f7f7);--theme-text-muted:var(--lightningcss-light,#626262)var(--lightningcss-dark,#a3a3a3);--theme-text-inverse:var(--lightningcss-light,#fafafa)var(--lightningcss-dark,#0b0b0b);--theme-border:var(--lightningcss-light,#bfbfbf)var(--lightningcss-dark,#606060);--theme-primary:var(--lightningcss-light,#121212)var(--lightningcss-dark,#f7f7f7);--theme-primary-hover:var(--lightningcss-light,#262626)var(--lightningcss-dark,#e5e5e5);--theme-primary-active:var(--lightningcss-light,#404040)var(--lightningcss-dark,#d4d4d4);--theme-focus:var(--lightningcss-light,#525252)var(--lightningcss-dark,#d4d4d4);--theme-cocoa:var(--lightningcss-light,#6b4423)var(--lightningcss-dark,#d29a63);--theme-mint:var(--lightningcss-light,#116b4c)var(--lightningcss-dark,#38efb0);--theme-cyan:var(--lightningcss-light,#0e7490)var(--lightningcss-dark,#22d3ee);--theme-violet:var(--lightningcss-light,#5b21b6)var(--lightningcss-dark,#b69cff);--theme-berry:var(--lightningcss-light,#a21caf)var(--lightningcss-dark,#e879f9);--theme-danger:var(--lightningcss-light,#b42318)var(--lightningcss-dark,#ff6b6b);--theme-danger-surface:var(--lightningcss-light,#fee2e2)var(--lightningcss-dark,#451a19);--theme-success:var(--lightningcss-light,#087443)var(--lightningcss-dark,#4ade80);--theme-success-surface:var(--lightningcss-light,#e7f6ee)var(--lightningcss-dark,#123c2b);--theme-warning:var(--lightningcss-light,#a16207)var(--lightningcss-dark,#ffc93c);--theme-warning-surface:var(--lightningcss-light,#fef3c7)var(--lightningcss-dark,#422006)}@media (prefers-color-scheme:dark){[data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root]{--lightningcss-light: ;--lightningcss-dark:initial}}:is(.dark,[data-theme=dark]) :is([data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root]){--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark}:is(.light,[data-theme=light]) :is([data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root]){--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light}:is([data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root])[data-theme=dark]{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark}:is([data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root])[data-theme=light]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light}[data-pose-silhouette],[data-pose-arrow]{display:block;overflow:visible}[data-pose-arrow]{pointer-events:none;fill:none;width:64px;height:64px;stroke:var(--theme-mint);stroke-width:7px;stroke-linecap:round;stroke-linejoin:round;position:absolute;bottom:4%;left:50%;transform:translate(-50%)}[data-pose-arrow] [data-pose-solid]{fill:var(--theme-mint);stroke:none}[data-pose-silhouette] [data-pose-head]{fill:none;stroke:var(--theme-border);stroke-width:1.5px;stroke-dasharray:5 5}[data-pose-silhouette] [data-pose-eye]{fill:var(--theme-text-muted);stroke:none}[data-pose-silhouette] [data-pose-mouth],[data-pose-silhouette] [data-pose-eye-closed],[data-pose-motion]{fill:none;stroke:var(--theme-cyan);stroke-width:2.5px;stroke-linecap:round;stroke-linejoin:round}[data-pose-motion]{stroke-dasharray:6 6;animation:.9s linear infinite pose-motion}[data-pose-arrowhead]{fill:var(--theme-cyan);stroke:none}[data-pose-arrow] [data-pose-motion]{stroke:var(--theme-mint);stroke-width:8px;stroke-dasharray:none;animation:none}[data-pose-arrow] [data-pose-arrowhead]{fill:var(--theme-mint)}[data-pose-arrow] [data-pose-smile]{fill:none;stroke:var(--theme-mint);stroke-width:8px;stroke-linecap:round}[data-pose-progress][data-variant=bar]{gap:4px;width:100%;display:flex}[data-pose-progress][data-variant=bar] [data-pose-progress-step]{background:var(--theme-border);border-radius:9999px;flex:1;height:4px;transition:background .2s}[data-pose-progress][data-variant=bar] [data-pose-progress-step][data-complete]{background:var(--theme-mint)}[data-pose-progress][data-variant=ring]{display:block;overflow:visible}[data-pose-progress][data-variant=ring] [data-pose-progress-step]{fill:none;stroke:var(--theme-border);stroke-width:2px;stroke-linecap:round;transition:stroke .3s}[data-pose-progress][data-variant=ring] [data-pose-progress-step][data-complete]{stroke:var(--theme-mint)}[data-pose-success]{opacity:0;pointer-events:none}[data-pose-success] circle{fill:var(--theme-success-surface);stroke:var(--theme-mint);stroke-width:2px}[data-pose-success] path{fill:none;stroke:var(--theme-mint);stroke-width:5px;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:1;stroke-dashoffset:1px}[data-pose-success][data-visible]{animation:.42s ease-out both pose-success-appear}[data-pose-success][data-visible] path{animation:.24s ease-out 60ms both pose-success-draw}@keyframes pose-motion{to{stroke-dashoffset:-12px}}@keyframes pose-success-appear{0%{opacity:0;transform:scale(.85)}to{opacity:1;transform:scale(1)}}@keyframes pose-success-draw{to{stroke-dashoffset:0}}@media (prefers-reduced-motion:reduce){[data-pose-motion]{animation:none}[data-pose-success][data-visible]{opacity:1}[data-pose-success][data-visible] path{stroke-dashoffset:0}}[data-facekey-dialog]{box-sizing:border-box;width:100%;max-width:none;height:100dvh;max-height:none;padding:max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));background:var(--theme-surface);color:var(--theme-text);border:0;margin:0;font-family:ui-sans-serif,system-ui,sans-serif;position:fixed;inset:0;overflow-y:auto}[data-facekey-dialog]::backdrop{background:var(--theme-text)}@supports (color:color-mix(in lab, red, red)){[data-facekey-dialog]::backdrop{background:color-mix(in srgb, var(--theme-text) 40%, transparent)}}[data-facekey-dialog][open]{flex-direction:column;justify-content:center;align-items:center;gap:24px;display:flex}[data-facekey-dialog] [data-facekey-title]{letter-spacing:-.7px;margin:0;font-size:28px;font-weight:600}[data-facekey-dialog] [data-facekey-camera]{aspect-ratio:1;flex-shrink:0;width:min(60vw,240px,38dvh);position:relative}[data-facekey-dialog] [data-facekey-camera] video{object-fit:cover;background:var(--theme-surface-subtle);border-radius:2147483647px;width:100%;height:100%}[data-facekey-dialog] [data-facekey-camera][data-mirrored] video{transform:scaleX(-1)}[data-facekey-dialog] [data-facekey-camera]>[data-pose-progress]{width:calc(100% + 28px);height:calc(100% + 28px);position:absolute;inset:-14px;overflow:visible}[data-facekey-dialog] [data-facekey-debug]{top:max(8px, env(safe-area-inset-top));z-index:1;border:1px solid var(--theme-border);background:var(--theme-surface);border-radius:.375rem;width:min(220px,100% - 16px);padding:8px 10px;position:fixed;left:8px}@supports (color:color-mix(in lab, red, red)){[data-facekey-dialog] [data-facekey-debug]{background:color-mix(in srgb, var(--theme-surface) 75%, transparent)}}[data-facekey-dialog] [data-facekey-debug]{color:var(--theme-text-muted);pointer-events:none;box-shadow:0 4px 14px var(--theme-border);font:10px/1.4 ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace}@supports (color:color-mix(in lab, red, red)){[data-facekey-dialog] [data-facekey-debug]{box-shadow:0 4px 14px color-mix(in srgb, var(--theme-border) 35%, transparent)}}[data-facekey-dialog] [data-facekey-debug]{-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px)}[data-facekey-dialog] [data-facekey-debug].hidden{display:none}[data-facekey-dialog] [data-facekey-debug] [data-valid=true]{color:var(--theme-mint)}[data-facekey-dialog] [data-facekey-debug] [data-valid=false]{color:var(--theme-danger)}@media (width>=640px){[data-facekey-dialog] [data-facekey-debug]{font-size:12px}}[data-facekey-dialog] [data-facekey-camera]>[data-pose-success]{z-index:2;transform-origin:50%;width:112px;height:112px;margin:auto;position:absolute;inset:0}[data-facekey-dialog][data-state=processing] [data-pose-progress]{animation:1s ease-in-out infinite alternate facekey-pulse}[data-facekey-dialog][data-state=failure] [data-pose-progress] [data-pose-progress-step],[data-facekey-dialog] [data-facekey-camera][data-feedback=mismatch] [data-pose-progress] [data-pose-progress-step]{stroke:var(--theme-danger)}[data-facekey-dialog] [data-facekey-camera][data-shake]{animation:.42s ease-in-out facekey-shake}[data-facekey-dialog] [data-facekey-camera][data-feedback=match] video{opacity:.35}[data-facekey-dialog] [data-facekey-status]{text-align:center;flex-direction:column;align-items:center;max-width:320px;min-height:48px;margin:0;font-size:21px;line-height:1.4;display:flex}[data-facekey-dialog] [data-facekey-status-reason]{color:var(--theme-warning);font-size:16px;font-weight:600}[data-facekey-dialog] [data-facekey-cancel]{border:1px solid var(--theme-mint);color:var(--theme-mint);font:inherit;background:0 0;border-radius:.375rem;padding:12px 20px;font-size:16px}[data-facekey-dialog] [data-facekey-cancel]:focus-visible{outline:2px solid var(--theme-focus);outline-offset:2px}@keyframes facekey-shake{0%,to{transform:translate(0)}15%,45%{transform:translate(-12px)}30%,60%{transform:translate(12px)}75%{transform:translate(-6px)}90%{transform:translate(4px)}}@keyframes facekey-pulse{to{opacity:.35}}@media (width<=600px){[data-facekey-dialog] [data-facekey-camera]{width:min(82vw,325px)}}@media (prefers-reduced-motion:reduce){[data-facekey-dialog] *,[data-facekey-dialog] :before,[data-facekey-dialog] :after{transition:none;animation:none}}`,y=({value:e})=>e===null?`—`:e.toFixed(2),b=({className:n,display:a,dialogRef:s,videoRef:l,options:y,onStop:b})=>{let{translate:x,translateError:S}=f({language:y.language});i(()=>{let e=s.current,n=l.current;if(!e||!n)throw t({code:r.UI_ELEMENT_NOT_FOUND});let i=document.activeElement instanceof HTMLElement?document.activeElement:null,a=document.body.style.overflow;return document.body.style.overflow=`hidden`,e.showModal(),()=>{o({video:n}),e.open&&e.close(),document.body.style.overflow=a,i&&i.focus()}},[]);let C=a.phase.value,w=a.operation.value,{completed:T,total:E}=a.progress.value,D=a.feedback.value,O;D&&(O=D.matched?`match`:`mismatch`);let k=a.instruction.value,A=a.guidance.value,j=x(`preparingCamera`),M=``;if(C===`processing`&&(j=x(`checkingFace`)),C===`success`&&(j=x(`done`)),C===`failure`){let e=a.error.value;j=e===null?x(`faceNotRecognized`):S({error:e})}if(C===`capturing`){let e={FACE_NOT_DETECTED:x(`faceNotFound`),FACE_IN_POLYGON:x(`faceInPolygon`),FACE_TOO_SMALL:x(`faceTooSmall`),FACE_NOT_CENTERED:x(`faceNotCentered`),FACE_CAMERA_ALIGNMENT_REQUIRED:x(u())},t=a.corrective.value;k?.framing?j=e[k.framing]??j:k?.retry?j=k.retry:A&&(j=x(d({pose:A.pose,code:A.code}).primary),M=t?x(t):``)}let N=[...a.debug.value],P=a.match.value;if(N.length&&P){let e=P.reason??`unavailable`;P.score!==null&&(e=`${P.score.toFixed(4)} / ${c}`),P.reference&&(e=`Reference`),N.push({label:`Similarity`,valid:P.accepted,value:e})}return p(e,{children:[p(`style`,{"data-facekey-styles":``,children:v}),p(`dialog`,{className:n,ref:s,"data-facekey-dialog":``,"data-state":C,"aria-labelledby":`facekey-title`,"aria-describedby":`facekey-status`,onCancel:e=>{e.preventDefault(),b()},children:[p(`h2`,{id:`facekey-title`,"data-facekey-title":``,children:x(w===`enroll`?`setUpFaceKey`:`unlockWithFaceKey`)}),p(`div`,{"data-facekey-camera":``,"data-mirrored":a.facingMode.value===`user`?``:void 0,"data-feedback":O,"data-shake":D&&!D.matched&&D.animating&&a.failures.value%3==0?``:void 0,children:[p(`video`,{ref:l,playsInline:!0,muted:!0,autoPlay:!0,"aria-label":x(`cameraPreview`)}),p(h,{completed:T,label:x(`faceCaptureProgress`),total:E,variant:`ring`}),p(_,{visible:!!D?.matched}),!(C!==`capturing`||!A||k?.framing||D?.matched)&&p(g,{pose:A.pose}),p(m,{kind:`facekey`,entries:N})]}),p(`p`,{id:`facekey-status`,"data-facekey-status":``,role:`status`,"aria-live":`polite`,children:[p(`span`,{children:j}),!!M&&p(`span`,{"data-facekey-status-reason":``,children:M})]}),p(`button`,{type:`button`,"data-facekey-cancel":``,autoFocus:!0,onClick:b,children:x(`cancel`)})]})]})},x=({options:e,display:i,events:o,onStop:c})=>{let u=a(),d=a(),f=null,m=0;return{get dialog(){return u.current},requiredVideo:()=>{if(!d.current)throw t({code:r.UI_ELEMENT_NOT_FOUND});return d.current},open:()=>{if(f)throw t({code:r.UI_ELEMENT_NOT_FOUND});f=document.createElement(`div`),f.dataset.facekeyRoot=``,s({element:f,theme:e.theme}),document.body.append(f),m=0,n(p(b,{display:i,dialogRef:u,videoRef:d,options:e,onStop:c}),f),o.dispatchEvent(new CustomEvent(`facekey:open`,{detail:u.current}))},close:()=>{f&&(n(null,f),f.remove(),f=null,o.dispatchEvent(new Event(`facekey:close`)))},collectCaptureDebug:({centered:e,face:t,faceInPolygon:n,faces:r,force:a=!1,frame:o,framing:s,operation:c,pose:d,poseRejection:f,reason:p,stable:h})=>{let g=t?t.boundingRect.height/Math.min(o.width,o.height):null,_=t?.blendshapes.mouthSmileLeft??null,v=t?.blendshapes.mouthSmileRight??null,b=!(!t||f),x=[{label:`Flow`,value:c.toUpperCase()},{label:`Pose`,value:d},{label:`Faces`,valid:r.length===1,value:String(r.length)},{label:`Human`,valid:!!t&&!n,value:t?n?`In polygon`:`Yes`:`No face`},{label:`Height`,valid:!s,value:g===null?`—`:`${(g*100).toFixed(0)}% / ${l*100}%`},{label:`Centered`,valid:e,value:e?`Yes`:`No`},{label:`Pitch`,value:y({value:t?.pitch??null})},{label:`Yaw`,value:y({value:t?.yaw??null})},{label:`Roll`,value:y({value:t?.roll??null})},{label:`Pose valid`,valid:b,value:f??`Yes`}];d===`faceSmile`&&x.push({label:`Smile`,valid:_!==null&&v!==null&&_>=.5&&v>=.5,value:`${y({value:_})}|${y({value:v})}`}),x.push({label:`Stable`,valid:h>0,value:`${h}/3`}),p&&x.push({label:`Reason`,valid:!1,value:p});let S=performance.now();!i.debugEnabled.value||!u.current?.open||!a&&S-m<100||(m=S,i.debug.value=x)}}};export{x as createFaceKeyView};
@@ -0,0 +1,2 @@
1
+ /*! Copyright (c) 2026 VOLTOM. All rights reserved. Proprietary software. See LICENSE at https://voltom.io/license. */
2
+ import{Ht as e,Qt as t,Ut as n,Yt as r,Zt as i,_t as a,bt as o,xt as s}from"./requests-DW8zDX51.js";import{a as c,i as l,n as u,r as d,t as f}from"./PoseSuccess-R_8JYo--.js";var p=`[data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light dark;--theme-canvas:var(--lightningcss-light,#fafafa)var(--lightningcss-dark,#0b0b0b);--theme-surface:var(--lightningcss-light,#fff)var(--lightningcss-dark,#202020);--theme-surface-subtle:var(--lightningcss-light,#f5f5f5)var(--lightningcss-dark,#2c2c2c);--theme-text:var(--lightningcss-light,#121212)var(--lightningcss-dark,#f7f7f7);--theme-text-muted:var(--lightningcss-light,#626262)var(--lightningcss-dark,#a3a3a3);--theme-text-inverse:var(--lightningcss-light,#fafafa)var(--lightningcss-dark,#0b0b0b);--theme-border:var(--lightningcss-light,#bfbfbf)var(--lightningcss-dark,#606060);--theme-primary:var(--lightningcss-light,#121212)var(--lightningcss-dark,#f7f7f7);--theme-primary-hover:var(--lightningcss-light,#262626)var(--lightningcss-dark,#e5e5e5);--theme-primary-active:var(--lightningcss-light,#404040)var(--lightningcss-dark,#d4d4d4);--theme-focus:var(--lightningcss-light,#525252)var(--lightningcss-dark,#d4d4d4);--theme-cocoa:var(--lightningcss-light,#6b4423)var(--lightningcss-dark,#d29a63);--theme-mint:var(--lightningcss-light,#116b4c)var(--lightningcss-dark,#38efb0);--theme-cyan:var(--lightningcss-light,#0e7490)var(--lightningcss-dark,#22d3ee);--theme-violet:var(--lightningcss-light,#5b21b6)var(--lightningcss-dark,#b69cff);--theme-berry:var(--lightningcss-light,#a21caf)var(--lightningcss-dark,#e879f9);--theme-danger:var(--lightningcss-light,#b42318)var(--lightningcss-dark,#ff6b6b);--theme-danger-surface:var(--lightningcss-light,#fee2e2)var(--lightningcss-dark,#451a19);--theme-success:var(--lightningcss-light,#087443)var(--lightningcss-dark,#4ade80);--theme-success-surface:var(--lightningcss-light,#e7f6ee)var(--lightningcss-dark,#123c2b);--theme-warning:var(--lightningcss-light,#a16207)var(--lightningcss-dark,#ffc93c);--theme-warning-surface:var(--lightningcss-light,#fef3c7)var(--lightningcss-dark,#422006)}@media (prefers-color-scheme:dark){[data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root]{--lightningcss-light: ;--lightningcss-dark:initial}}:is(.dark,[data-theme=dark]) :is([data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root]){--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark}:is(.light,[data-theme=light]) :is([data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root]){--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light}:is([data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root])[data-theme=dark]{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark}:is([data-voltom-demo],[data-voltom-root],[data-facekey-root],[data-facegate-root])[data-theme=light]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light}[data-pose-silhouette],[data-pose-arrow]{display:block;overflow:visible}[data-pose-arrow]{pointer-events:none;fill:none;width:64px;height:64px;stroke:var(--theme-mint);stroke-width:7px;stroke-linecap:round;stroke-linejoin:round;position:absolute;bottom:4%;left:50%;transform:translate(-50%)}[data-pose-arrow] [data-pose-solid]{fill:var(--theme-mint);stroke:none}[data-pose-silhouette] [data-pose-head]{fill:none;stroke:var(--theme-border);stroke-width:1.5px;stroke-dasharray:5 5}[data-pose-silhouette] [data-pose-eye]{fill:var(--theme-text-muted);stroke:none}[data-pose-silhouette] [data-pose-mouth],[data-pose-silhouette] [data-pose-eye-closed],[data-pose-motion]{fill:none;stroke:var(--theme-cyan);stroke-width:2.5px;stroke-linecap:round;stroke-linejoin:round}[data-pose-motion]{stroke-dasharray:6 6;animation:.9s linear infinite pose-motion}[data-pose-arrowhead]{fill:var(--theme-cyan);stroke:none}[data-pose-arrow] [data-pose-motion]{stroke:var(--theme-mint);stroke-width:8px;stroke-dasharray:none;animation:none}[data-pose-arrow] [data-pose-arrowhead]{fill:var(--theme-mint)}[data-pose-arrow] [data-pose-smile]{fill:none;stroke:var(--theme-mint);stroke-width:8px;stroke-linecap:round}[data-pose-progress][data-variant=bar]{gap:4px;width:100%;display:flex}[data-pose-progress][data-variant=bar] [data-pose-progress-step]{background:var(--theme-border);border-radius:9999px;flex:1;height:4px;transition:background .2s}[data-pose-progress][data-variant=bar] [data-pose-progress-step][data-complete]{background:var(--theme-mint)}[data-pose-progress][data-variant=ring]{display:block;overflow:visible}[data-pose-progress][data-variant=ring] [data-pose-progress-step]{fill:none;stroke:var(--theme-border);stroke-width:2px;stroke-linecap:round;transition:stroke .3s}[data-pose-progress][data-variant=ring] [data-pose-progress-step][data-complete]{stroke:var(--theme-mint)}[data-pose-success]{opacity:0;pointer-events:none}[data-pose-success] circle{fill:var(--theme-success-surface);stroke:var(--theme-mint);stroke-width:2px}[data-pose-success] path{fill:none;stroke:var(--theme-mint);stroke-width:5px;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:1;stroke-dashoffset:1px}[data-pose-success][data-visible]{animation:.42s ease-out both pose-success-appear}[data-pose-success][data-visible] path{animation:.24s ease-out 60ms both pose-success-draw}@keyframes pose-motion{to{stroke-dashoffset:-12px}}@keyframes pose-success-appear{0%{opacity:0;transform:scale(.85)}to{opacity:1;transform:scale(1)}}@keyframes pose-success-draw{to{stroke-dashoffset:0}}@media (prefers-reduced-motion:reduce){[data-pose-motion]{animation:none}[data-pose-success][data-visible]{opacity:1}[data-pose-success][data-visible] path{stroke-dashoffset:0}}[data-facegate-gate]{z-index:60;background:color-mix(in srgb, var(--theme-canvas) 84%, transparent);-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);place-items:center;padding:24px;font-family:ui-sans-serif,system-ui,sans-serif;display:grid;position:fixed;inset:0}[data-facegate-gate] .facegate-stage{place-items:center;display:grid;position:relative}[data-facegate-gate] .facegate-camera{aspect-ratio:1;flex-shrink:0;width:min(60vw,240px,38dvh);position:relative}[data-facegate-gate] .facegate-camera video{object-fit:cover;background:var(--theme-surface-subtle);border-radius:999px;width:100%;height:100%}[data-facegate-gate] .facegate-camera[data-mirrored] video{transform:scaleX(-1)}[data-facegate-gate] .facegate-camera>[data-pose-progress]{width:calc(100% + 28px);height:calc(100% + 28px);position:absolute;inset:-14px;overflow:visible}[data-facegate-gate] .facegate-camera>[data-pose-success]{z-index:2;transform-origin:50%;width:112px;height:112px;margin:auto;position:absolute;inset:0}[data-facegate-gate] .facegate-camera[data-shake]{animation:.48s both facegate-shake}[data-facegate-gate] .facegate-spinner-host{z-index:3;background:color-mix(in srgb, var(--theme-canvas) 70%, transparent);border-radius:999px;place-items:center;display:grid;position:absolute;inset:0}[data-facegate-gate] .facegate-spinner{width:40px;height:40px;color:var(--theme-text);animation:.9s linear infinite facegate-spin}[data-facegate-gate] .facegate-prompt{width:min(80vw,300px);color:var(--theme-text);text-align:center;margin:0;font-size:17px;font-weight:600;position:absolute;top:calc(100% + 30px);left:50%;transform:translate(-50%)}[data-facegate-gate][data-result=pass] [data-pose-progress-step]{stroke:var(--theme-mint)}[data-facegate-gate][data-result=reject] [data-pose-progress-step]{stroke:var(--theme-danger)}@keyframes facegate-shake{0%,to{transform:translate(0)rotate(0)}20%{transform:translate(-6px)rotate(-6deg)}40%{transform:translate(6px)rotate(6deg)}60%{transform:translate(-5px)rotate(-4deg)}80%{transform:translate(5px)rotate(4deg)}}@keyframes facegate-spin{to{transform:rotate(360deg)}}@media (width<=600px){[data-facegate-gate] .facegate-camera{width:min(82vw,300px)}}@media (prefers-reduced-motion:reduce){[data-facegate-gate] .facegate-camera[data-shake],[data-facegate-gate] .facegate-spinner{animation:none}}[data-facegate-debug]{top:max(8px, env(safe-area-inset-top));z-index:1;border:1px solid var(--theme-border);background:color-mix(in srgb, var(--theme-surface) 75%, transparent);width:min(220px,100% - 16px);color:var(--theme-text-muted);pointer-events:none;border-radius:8px;padding:8px 10px;font:10px/1.4 ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;position:fixed;left:8px}[data-facegate-debug].hidden{display:none}[data-facegate-debug] [data-valid=true]{color:var(--theme-mint)}[data-facegate-debug] [data-valid=false]{color:var(--theme-danger)}`,m=()=>c(`svg`,{className:`facegate-spinner`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:c(`path`,{d:`M12 3a9 9 0 1 0 9 9`})}),h=({display:t,videoRef:i,options:a,onCancel:o})=>{let{translate:h}=s({language:a.language});r(()=>{if(!i.current)throw e({code:n.UI_ELEMENT_NOT_FOUND});let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=t}},[]);let g=t.outcome.value,_=t.phase.value===`checking`,v=t.completed.value,y=t.total.value,b=g===`fail`||g===`error`,x=t.pose.value;return c(`div`,{className:`facegate-gate`,"data-facegate-gate":``,"data-result":g===`pass`?`pass`:g?`reject`:``,onClick:e=>{e.target===e.currentTarget&&o()},children:[c(`style`,{"data-facegate-styles":``,children:p}),c(l,{kind:`facegate`,entries:t.debugEnabled.value?[{label:`Phase`,value:t.phase.value},{label:`Progress`,value:`${t.completed.value}/${t.total.value}`},...t.debug.value]:[]}),c(`div`,{className:`facegate-stage`,role:`dialog`,"aria-modal":`true`,"aria-label":`Liveness check`,children:[c(`div`,{className:`facegate-camera`,"data-mirrored":``,"data-shake":b?``:void 0,children:[c(`video`,{ref:i,autoPlay:!0,muted:!0,playsInline:!0,"aria-label":h(`cameraPreview`)}),c(u,{completed:v,label:h(`faceCaptureProgress`),total:y,variant:`ring`}),c(f,{visible:g===`pass`}),!(t.phase.value!==`capturing`||g||!x||t.framing.value)&&c(d,{pose:x}),_?c(`div`,{className:`facegate-spinner-host`,children:c(m,{})}):null]}),g?null:c(`p`,{className:`facegate-prompt`,role:`status`,"aria-live":`polite`,children:t.prompt.value})]})]})},g=({options:r,display:s,onCancel:l})=>{let u=i(),d=null,f=0;return{get video(){return u.current},collectCaptureDebug:({inspected:e,pose:t,stable:n})=>{let r=performance.now();if(!s.debugEnabled.value||!d||r-f<100)return;f=r;let i=e.alignment;s.debug.value=[{label:`Pose`,value:t},{label:`Pitch`,value:i?i.pitch.toFixed(2):`—`},{label:`Yaw`,value:i?i.yaw.toFixed(2):`—`},{label:`Roll`,value:i?i.roll.toFixed(2):`—`},{label:`Ready`,valid:e.ready,value:String(e.ready)},{label:`Reason`,value:e.ready?`—`:e.code??e.prompt},{label:`Stable`,value:`${n}/3`}]},requiredVideo:()=>{if(!u.current)throw e({code:n.UI_ELEMENT_NOT_FOUND});return u.current},open:()=>{d||(f=0,d=document.createElement(`div`),d.dataset.facegateRoot=``,o({element:d,theme:r.theme}),document.body.append(d),t(c(h,{display:s,videoRef:u,options:r,onCancel:l}),d))},close:()=>{if(!d)return;let e=u.current;e&&a({video:e}),t(null,d),d.remove(),d=null}}};export{g as createFaceGateView};
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@voltom.io/sdk",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "files": [
6
6
  "LICENSE",
7
7
  "dist/assets/locales/*.json",
8
8
  "dist/sdk/*.js",
9
+ "dist/sdk/errors.d.ts",
9
10
  "dist/sdk/verify.d.ts",
10
11
  "dist/sdk/facekey.d.ts",
11
12
  "dist/sdk/facegate.d.ts",
@@ -50,7 +51,7 @@
50
51
  "access": "public"
51
52
  },
52
53
  "dependencies": {
53
- "@fastify/static": "^10.1.9",
54
+ "@fastify/static": "^10.1.10",
54
55
  "@preact/signals": "^2.11.4",
55
56
  "fastify": "^5.12.8",
56
57
  "pdfjs-dist": "^6.5.438",
@@ -61,7 +62,7 @@
61
62
  "@typescript/typescript6": "^6.0.2",
62
63
  "rollup-plugin-visualizer": "^7.1.2",
63
64
  "tailwindcss": "^4.3.4",
64
- "vite": "^8.3.5",
65
+ "vite": "^8.3.6",
65
66
  "vite-plugin-compression2": "^2.5.3",
66
67
  "vite-plugin-dts": "^5.1.2"
67
68
  },
@@ -1,2 +0,0 @@
1
- /*! Copyright (c) 2026 VOLTOM. All rights reserved. Proprietary software. See LICENSE at https://voltom.io/license. */
2
- import{r as e}from"./PoseSuccess-DDx23oJD.js";var t=({className:t,entries:n,kind:r})=>e(`div`,{className:n.length?t:`hidden`,[`data-${r}-debug`]:``,children:n.map(({label:t,valid:n,value:r})=>e(`div`,{children:[e(`span`,{children:[t,`: `]}),e(`span`,{"data-valid":n===void 0?void 0:String(n),children:r})]},t))}),n={faceLeft:`M 78 50 L 22 50`,faceRight:`M 22 50 L 78 50`,faceUp:`M 50 78 L 50 22`,faceDown:`M 50 22 L 50 78`,faceTiltLeft:`M 68 26 Q 44 34 32 62`,faceTiltRight:`M 32 26 Q 56 34 68 62`},r=()=>e(`defs`,{children:e(`marker`,{id:`pose-arrowhead`,markerWidth:`6`,markerHeight:`6`,refX:`4.4`,refY:`3`,orient:`auto`,children:e(`path`,{"data-pose-arrowhead":``,d:`M0,0 L6,3 L0,6 Z`})})}),i=({pose:t})=>{let r=n[t];return r?e(`path`,{"data-pose-motion":``,d:r,"marker-end":`url(#pose-arrowhead)`}):null},a=({pose:t})=>t===`faceSmile`?e(`path`,{"data-pose-smile":``,d:`M 15 45 A 35 35 0 0 0 85 45`}):null,o=({className:t,pose:n})=>e(`svg`,{className:t,"data-pose-arrow":``,"data-pose":n,viewBox:`0 0 100 100`,"aria-hidden":`true`,children:[e(r,{}),e(i,{pose:n}),e(a,{pose:n})]});export{t as n,o as t};
@@ -1,2 +0,0 @@
1
- /*! Copyright (c) 2026 VOLTOM. All rights reserved. Proprietary software. See LICENSE at https://voltom.io/license. */
2
- import{T as e}from"./media-Cejmtltt.js";var t=Symbol.for(`pv`),n=0;Array.isArray;function r(r,i,a,o,s,c){i||={};var l,u,d=i;if(`ref`in d&&typeof r!=`function`)for(u in d={},i)u==`ref`?l=i[u]:d[u]=i[u];var f={type:r,props:d,key:a,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:t,__v:--n,__i:-1,__u:0};return(s||c)&&(f.__source=s,f.__self=c),e.vnode&&e.vnode(f),f}var i=100,a=2,o=({total:e})=>i/e-(e===1?0:a),s=({arc:e,index:t,total:n})=>({dasharray:`${e} ${i-e}`,offset:`${-t*i/n}`}),c=({className:e,completed:t,label:n,total:a,variant:c=`bar`})=>{if(c===`ring`){let c=o({total:a});return r(`svg`,{className:e,"data-pose-progress":``,"data-variant":`ring`,viewBox:`0 0 100 100`,role:`progressbar`,"aria-label":n,"aria-valuemin":0,"aria-valuemax":a,"aria-valuenow":t,children:r(`g`,{transform:`rotate(-90 50 50)`,children:Array.from({length:a},(e,n)=>{let{dasharray:o,offset:l}=s({arc:c,index:n,total:a});return r(`circle`,{cx:`50`,cy:`50`,r:`50`,pathLength:i,ref:e=>{e&&(e.setAttribute(`stroke-dasharray`,o),e.setAttribute(`stroke-dashoffset`,l))},"data-pose-progress-step":``,"data-complete":n<t?``:void 0},n)})})})}return r(`div`,{className:e,"data-pose-progress":``,"data-variant":`bar`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":a,"aria-valuenow":t,children:Array.from({length:a},(e,n)=>r(`span`,{"data-pose-progress-step":``,"data-complete":n<t?``:void 0},n))})},l=({className:e,visible:t})=>r(`svg`,{className:e,"data-pose-success":``,"data-visible":t?``:void 0,viewBox:`0 0 100 100`,"aria-hidden":`true`,children:[r(`circle`,{cx:`50`,cy:`50`,r:`44`}),r(`path`,{d:`M29 51 43 65 72 36`,pathLength:`1`})]});export{c as n,r,l as t};