@sekyro/web 0.1.0-rc.21 → 0.1.0-rc.22
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.
- package/CHANGELOG.md +45 -0
- package/README.md +12 -11
- package/dist/camera-trait-V4UAOPIQ.js +1 -0
- package/dist/{capture-constraints-B5omafmk.d.cts → capture-constraints-CVqpMNGA.d.cts} +7 -3
- package/dist/{capture-constraints-B5omafmk.d.ts → capture-constraints-CVqpMNGA.d.ts} +7 -3
- package/dist/{capture-session-doc-XBZGXWOP.js → capture-session-doc-YDUKUN3P.js} +1 -1
- package/dist/{capture-session-v3-26FgzBIl.d.cts → capture-session-v3-CkcuPKSD.d.ts} +90 -13
- package/dist/{capture-session-v3-ZO0QOeQH.d.ts → capture-session-v3-TJL-0Muv.d.cts} +90 -13
- package/dist/chunk-2KTSNAVR.js +1 -0
- package/dist/chunk-2LDOXGY3.js +1 -0
- package/dist/chunk-32ELI5BZ.js +1 -0
- package/dist/chunk-7QZWBDI5.js +1 -0
- package/dist/chunk-7XT5YDSC.js +1 -0
- package/dist/chunk-BATJN3VQ.js +1 -0
- package/dist/chunk-CPUECYAJ.js +1 -0
- package/dist/chunk-FSSMUAKC.js +1 -0
- package/dist/{chunk-QYYJLXKA.js → chunk-HYGINGDC.js} +1 -1
- package/dist/chunk-LJYMZQY2.js +1 -0
- package/dist/chunk-PZYVSLPG.js +1 -0
- package/dist/chunk-RALQBQPT.js +1 -0
- package/dist/chunk-SX7TUC3V.js +1 -0
- package/dist/chunk-TJUM65FN.js +1 -0
- package/dist/chunk-TSA6GHUG.js +1 -0
- package/dist/chunk-VWGKUQ3C.js +1 -0
- package/dist/chunk-Z2BIZYZQ.js +1 -0
- package/dist/chunk-Z5D7SZUW.js +1 -0
- package/dist/client/index.cjs +1 -1
- package/dist/client/index.d.cts +3 -3
- package/dist/client/index.d.ts +3 -3
- package/dist/client/index.js +1 -1
- package/dist/clip-inspect-DLJXVKV6.js +1 -0
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.d.cts +5 -5
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +1 -1
- package/dist/core/v3/detect-worker.cjs +1 -1
- package/dist/core/v3/detect-worker.d.cts +1 -1
- package/dist/core/v3/detect-worker.d.ts +1 -1
- package/dist/core/v3/detect-worker.js +1 -1
- package/dist/create-document-capture-K6EHRCWN.js +1 -0
- package/dist/create-portrait-capture-5VGYZUOK.js +1 -0
- package/dist/{create-verification-KlHIU4Fy.d.ts → create-verification-DnyHCSu6.d.cts} +175 -80
- package/dist/{create-verification-CXhXxknV.d.cts → create-verification-DoISHOqL.d.ts} +175 -80
- package/dist/{detect-worker-DclNxkZT.d.cts → detect-worker-CHqsPJoM.d.cts} +19 -2
- package/dist/{detect-worker-DclNxkZT.d.ts → detect-worker-CHqsPJoM.d.ts} +19 -2
- package/dist/{icao-gate-DvzOzHq6.d.cts → icao-gate-BFlSZYCZ.d.cts} +1 -1
- package/dist/{icao-gate-DI8VePWd.d.ts → icao-gate-lZ_fHE7k.d.ts} +1 -1
- package/dist/{icao-policy-DztbA50-.d.ts → icao-policy-BOcutYdD.d.ts} +2 -2
- package/dist/{icao-policy-MRB8NMAu.d.cts → icao-policy-JZH0UdmD.d.cts} +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +11 -15
- package/dist/index.d.ts +11 -15
- package/dist/index.js +1 -1
- package/dist/internal/index.cjs +1 -1
- package/dist/internal/index.d.cts +49 -34
- package/dist/internal/index.d.ts +49 -34
- package/dist/internal/index.js +1 -1
- package/dist/plan-runner-3ZMV7SFQ.js +1 -0
- package/dist/popup/index.cjs +1 -1
- package/dist/popup/index.d.cts +2 -2
- package/dist/popup/index.d.ts +2 -2
- package/dist/popup/index.js +1 -1
- package/dist/{print-AYSCRSZB.js → print-SEWS3VHQ.js} +1 -1
- package/dist/{turnstile-FATNZ4AG.js → turnstile-2J3LUHCG.js} +1 -1
- package/dist/{types-C_XP92JQ.d.cts → types-DwfyBTte.d.cts} +129 -74
- package/dist/{types-C_XP92JQ.d.ts → types-DwfyBTte.d.ts} +129 -74
- package/package.json +1 -1
- package/sbom.cdx.json +10 -10
- package/dist/camera-trait-45MJTW4K.js +0 -1
- package/dist/chunk-234OZEDB.js +0 -1
- package/dist/chunk-7Q4YPMAF.js +0 -1
- package/dist/chunk-B2X33ZW2.js +0 -1
- package/dist/chunk-CQ7SKLMC.js +0 -1
- package/dist/chunk-FUHDOEBP.js +0 -1
- package/dist/chunk-GT2ZLGF7.js +0 -1
- package/dist/chunk-H3HVCWLF.js +0 -1
- package/dist/chunk-O5WKNZ2C.js +0 -1
- package/dist/chunk-OKWG3PVH.js +0 -1
- package/dist/chunk-P3H3D33O.js +0 -1
- package/dist/chunk-P6UP4UQY.js +0 -1
- package/dist/chunk-SNACCYTL.js +0 -1
- package/dist/chunk-TQB3URP2.js +0 -1
- package/dist/chunk-VIAT4DEA.js +0 -1
- package/dist/chunk-ZADZTM3M.js +0 -1
- package/dist/chunk-ZNIZACXD.js +0 -1
- package/dist/create-document-capture-23R2F47A.js +0 -1
- package/dist/create-portrait-capture-AGFHECK7.js +0 -1
- package/dist/plan-runner-NUWONT7F.js +0 -1
package/dist/chunk-B2X33ZW2.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as f,c as y}from"./chunk-VIAT4DEA.js";var S=["session_token_invalid","session_token_required","session_token_session_mismatch","session_not_found","rate_limit_exceeded","consent_required","session_not_active","check_not_found","check_already_finalized","check_out_of_order","check_type_unsupported","force_outcome_forbidden","attestation_invalid","platform_unregistered","app_attest_invalid","too_many_challenges","inference_unavailable","mobile_required","nni_locked","document_nni_mismatch","media_content_type_not_allowed","media_too_large","media_key_invalid","media_key_forbidden","media_not_found","media_unreadable","media_session_invalid","idempotency_key_collision","idempotency_in_progress","idempotency_key_required","validation_error","internal_error","unknown_error","upload_failed","network_error","timeout","nfc_outcome_not_accepted","identity_confirm_required","identity_confirm_locked","choice_not_found","choice_locked","choice_option_unavailable","step_not_on_path","check_not_active","sekyro_app_not_allowed","sekyro_app_unverified","id_number_locked","document_id_number_mismatch","simulated_capture_forbidden"];function x(s){return S.includes(s)}var c=class extends Error{constructor(e){super(e.message),this.name="HostedApiError",this.status=e.status,this.code=e.code,e.retryAfterSeconds!==void 0&&(this.retryAfterSeconds=e.retryAfterSeconds),e.details&&(this.details=e.details)}};function _(s,e,n=Math.random){let t=(s??e)*1e3,i=Math.min(Math.max(t,500),2e4),o=Math.round(i*(1+(n()*2-1)*.25));return Math.min(Math.max(o,500),2e4)}var w=6e4,h=4,k=3e4,R=9e5,I=200,E=5,P=400,M=new Set(["server_busy","request_timeout"]),C=2;function l(s){return(s.split(";")[0]??"").trim()}var A={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},v=`@sekyro/web/${f}`,O=v,b=class{constructor(e){this.sessionId=null;this.bootstrap=null;this.captureNonces=[];this.captureFetch=null;this.reportedIssues=new Map;this.apiOrigin=e.apiOrigin.replace(/\/+$/,""),this.sessionToken=e.sessionToken;let n=e.fetch;this.fetchImpl=(t,i)=>(n??globalThis.fetch).call(globalThis,t,i),this.requestTimeoutMs=e.requestTimeoutMs??k,this.retryAttempts=e.inProgressRetry?.attempts??E,this.retryDelayMs=e.inProgressRetry?.delayMs??P,this.random=e.random??Math.random}async getSession(){let e=await this.api("GET","/hosted/session");return this.sessionId=e.sessionId,e}async recordConsent(e){return this.api("POST","/hosted/consent",{body:{locale:e},busyRetry:!0})}async reportCameraUnavailable(e){return this.api("POST","/hosted/camera-unavailable",{body:{cause:e}})}async reportCaptureIssue(e){let n=typeof e.name=="string"?e.name.replace(/[^A-Za-z]/g,"").slice(0,40):"",t=typeof e.engineKind=="string"&&/^[a-z_]{1,32}$/.test(e.engineKind)?e.engineKind:void 0,i=typeof e.attempt=="number"&&Number.isInteger(e.attempt)&&e.attempt>=0&&e.attempt<=1e3?e.attempt:void 0,o=[e.check,i??"",e.kind,n,e.phase??""].join("|"),a=this.reportedIssues.get(o);if(a!==void 0)return a;let d={check:e.check,kind:e.kind,...n!==""?{name:n}:{},...e.phase!==void 0?{phase:e.phase}:{},...t!==void 0?{engineKind:t}:{},...i!==void 0?{attempt:i}:{},...e.formFactor!==void 0?{formFactor:e.formFactor}:{}},r=this.api("POST","/hosted/capture-issue",{body:d,empty:!0}).catch(()=>{this.reportedIssues.delete(o)});return this.reportedIssues.set(o,r),r}async choose(e,n){let t=await this.api("POST","/hosted/choice",{body:{nodeId:e,option:n},busyRetry:!0});return this.sessionId=t.sessionId,t}async confirmIdentity(e){return this.api("POST","/hosted/identity/confirm",{body:{decision:e}})}async identityPortrait(){return this.api("GET","/hosted/identity/portrait",{blob:!0})}async presign(e,n,t,i={}){let o=await this.ensureSessionId(),a={kind:e,contentType:l(n),contentLength:t,...i.source==="upload"?{source:"upload"}:{}};return this.api("POST",`/sessions/${o}/media`,{body:a})}armCapture(e=2){this.fillCaptureNonces(e)}async presignCapture(e,n,t,i={}){let o=await this.ensureSessionId(),a=await this.takeCaptureNonce(),d=a===void 0?void 0:{nonce:a,...i.engine!==void 0?{engine:i.engine.slice(0,32)}:{},...i.durationMs!==void 0&&Number.isFinite(i.durationMs)?{captureMs:Math.min(36e5,Math.max(0,Math.round(i.durationMs)))}:{}},r={kind:e,contentType:l(n),contentLength:t,capture:d};return this.api("POST",`/sessions/${o}/media`,{body:r})}async takeCaptureNonce(){let e=()=>{let n=Date.now();return this.captureNonces=this.captureNonces.filter(t=>t.expiresAt-w>n),this.captureNonces.shift()?.nonce};for(let n=0;n<2;n++){let t=e();if(t!==void 0)return t;await this.fillCaptureNonces(1)}return e()}fillCaptureNonces(e){return this.captureFetch??(this.captureFetch=(async()=>{try{let n=await this.ensureSessionId(),t=await this.api("POST",`/sessions/${n}/media/capture-nonces`,{body:{count:Math.min(h,Math.max(1,e))}}),i=Date.now()+Math.max(0,t.expiresIn)*1e3;for(let o of Array.isArray(t.nonces)?t.nonces:[])typeof o=="string"&&o.length>0&&this.captureNonces.push({nonce:o,expiresAt:i});this.captureNonces=this.captureNonces.slice(-h)}catch{}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(e,n,t){let i;try{i=await this.fetchImpl(e,{method:"PUT",headers:{"content-type":l(t)},body:n,signal:AbortSignal.timeout(R)})}catch(o){throw m(o)}if(!i.ok){let o=(await i.text().catch(()=>"")).slice(0,I);throw new c({status:i.status,code:"upload_failed",message:`media upload failed (HTTP ${i.status})${o?`: ${o}`:""}`})}}async completeMedia(e){let n=await this.ensureSessionId();return this.api("POST",`/sessions/${n}/media/complete`,{body:{key:e}})}async submitCheck(e,n,t={}){let i=await this.ensureSessionId(),o={input:n,forceOutcome:t.forceOutcome};return this.api("POST",`/sessions/${i}/checks/${e}`,{body:o,idempotencyKey:t.idempotencyKey,busyRetry:t.idempotencyKey!==void 0})}async uploadAndSubmit(e,n,t,i={}){let o=l(n.contentType),a=await this.presign(n.kind,o,n.blob.size);await this.uploadToSpaces(a.uploadUrl,n.blob,o);let d=await this.completeMedia(a.key),r={...t,[A[e]]:d.key};return this.submitCheck(e,r,i)}async ensureSessionId(){return this.sessionId!==null?this.sessionId:(this.bootstrap??(this.bootstrap=this.getSession().finally(()=>{this.bootstrap=null})),(await this.bootstrap).sessionId)}async api(e,n,t={}){let i=e==="GET"||t.busyRetry===!0,o=`${this.apiOrigin}/api/v2${n}`,a={"x-session-token":this.sessionToken,"x-sekyro-sdk":O};t.body!==void 0&&(a["content-type"]="application/json"),t.idempotencyKey!==void 0&&(a["x-idempotency-key"]=t.idempotencyKey);try{let d=y.timezone();d!==void 0&&(a["sekyro-client-timezone"]=d)}catch{}try{let d=await y.deviceHeader();d!==void 0&&(a["sekyro-client-device"]=d)}catch{}for(let d=0;;d++){let r;try{r=await this.fetchImpl(o,{method:e,headers:a,...t.body!==void 0?{body:JSON.stringify(t.body)}:{},cache:"no-store",signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(p){throw m(p)}if(r.ok){if(t.empty===!0)return;if(t.blob===!0)try{return await r.blob()}catch(T){throw m(T)}let p;try{p=await r.json()}catch{throw new c({status:r.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${r.status})`})}return N(p)}let u=await H(r);if(u.code==="idempotency_in_progress"&&d<this.retryAttempts){this.retryDelayMs>0&&await g(this.retryDelayMs);continue}if(i&&u.status===503&&M.has(u.code)){i=!1,await g(_(u.retryAfterSeconds,C,this.random));continue}throw u}}};function m(s){if((typeof s=="object"&&s!==null?s.name:void 0)==="TimeoutError")return new c({status:0,code:"timeout",message:"request timed out"});let n=s instanceof Error?s.message:String(s);return new c({status:0,code:"network_error",message:`network request failed: ${n}`})}function N(s){return s!==null&&typeof s=="object"&&"success"in s&&"data"in s?s.data:s}async function H(s){let e="unknown_error",n=`request failed (HTTP ${s.status})`,t=Number.NaN,i;try{let d=await s.json();if(d!==null&&typeof d=="object"){let r=d;typeof r.code=="string"&&r.code.length>0&&(e=r.code),typeof r.message=="string"&&r.message.length>0&&(n=r.message),typeof r.retryAfterSeconds=="number"&&(t=r.retryAfterSeconds),Array.isArray(r.details?.issues)&&(i=r.details)}}catch{}let o=s.headers.get("retry-after"),a=o===null?Math.floor(t):Number.parseInt(o,10);return new c({status:s.status,code:e,message:n,...Number.isFinite(a)&&a>=0?{retryAfterSeconds:a}:{},details:i})}function g(s){return new Promise(e=>setTimeout(e,s))}function F(s){let e=s?.portrait,n=e?.icao,t=e?.purpose==="id_document";return n==null?t?{policy:"reject",profile:"id_document"}:null:{policy:n.policy==="alert"?"alert":"reject",profile:t||n.profile==="id_document"?"id_document":"selfie"}}function L(s){return{...s.baselineEyeOpenness!==void 0?{baselineEyeOpenness:s.baselineEyeOpenness}:{},...s.baselineEyeOpennessLeft!==void 0&&s.baselineEyeOpennessRight!==void 0?{baselineEyeOpennessLeft:s.baselineEyeOpennessLeft,baselineEyeOpennessRight:s.baselineEyeOpennessRight}:{},criteria:s.verdict??{},...s.backgroundCheck!==void 0?{backgroundCheck:s.backgroundCheck}:{}}}export{S as a,x as b,c,_ as d,l as e,v as f,b as g,F as h,L as i};
|
package/dist/chunk-CQ7SKLMC.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var m=["video/mp4;codecs=avc1.42E01E,mp4a.40.2","video/mp4;codecs=avc1.42E01E","video/mp4","video/webm;codecs=vp9,opus","video/webm;codecs=vp9","video/webm;codecs=vp8,opus","video/webm;codecs=vp8","video/webm"];function S(){let e=globalThis.MediaRecorder;return!e||typeof e.isTypeSupported!="function"?"":m.find(r=>e.isTypeSupported(r))??""}var l="video/webm";function f(e){if(e instanceof TypeError)return"insecure";switch(e?.name??""){case"NotAllowedError":case"PermissionDeniedError":return"permission";case"NotFoundError":case"DevicesNotFoundError":return"notfound";case"NotReadableError":case"TrackStartError":return"inuse";case"OverconstrainedError":case"ConstraintNotSatisfiedError":return"overconstrained";default:return"generic"}}function b(){let e=globalThis;if(typeof e.window<"u"&&e.window.isSecureContext===!1)return"INSECURE_CONTEXT";let r=e.navigator?.mediaDevices;return!r||typeof r.getUserMedia!="function"?"UNSUPPORTED":"OK"}function v(){let e=globalThis.MediaRecorder;return typeof e<"u"&&typeof e.isTypeSupported=="function"}var E=8*1024*1024;function T(e){return e.size>E}function u(e){let r=(e||"").toLowerCase();return r.startsWith("image/jpeg")?"jpg":r.startsWith("video/mp4")?"mp4":(r.startsWith("video/webm"),"webm")}function k(e){let{token:r,clip:n,keyframe:o}=e,c=e.ts??Date.now(),p=n.type||l,d=o.type||"image/jpeg",t=new FormData;return t.append("token",r),t.append("clip",new File([n],`liveness-${c}.${u(p)}`,{type:p})),t.append("keyframe",new File([o],`keyframe-${c}.${u(d)}`,{type:d})),t}var w=40;function y(e){if(e===null||typeof e!="object"&&typeof e!="function")return;let r;try{r=e.name}catch{return}return g(r)}function g(e){if(typeof e!="string")return;let r=e.replace(/[^A-Za-z]/g,"").slice(0,w);return r===""?void 0:r}function C(e){let r=f(e);if(r!=="generic")return r;switch(y(e)){case"AbortError":return"inuse";case"SecurityError":return"permission";default:return r}}var i=Symbol.for("sekyro.web.cameraStreams"),a=globalThis,s=a[i]??(a[i]=new Set);function N(e){try{s.add(e)}catch{}}function R(e){let r=0;for(let n of[...s])if(n!==e){s.delete(n);try{for(let o of n.getTracks())o.readyState!=="ended"&&(o.stop(),r+=1)}catch{}}return r}export{m as a,S as b,l as c,f as d,b as e,v as f,E as g,T as h,u as i,k as j,y as k,g as l,C as m,N as n,R as o};
|
package/dist/chunk-FUHDOEBP.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function c(t,n){return{video:{width:{ideal:1280,max:1280},height:{ideal:720,max:720},facingMode:n,frameRate:{ideal:24,max:30}},audio:!1}}var o=600;function r(){if(typeof window>"u"||typeof navigator>"u")return"desktop";let t=String(navigator.userAgent??"");if(/iPhone|iPod/i.test(t))return"phone";if(/iPad/i.test(t))return"tablet";if(/Android/i.test(t))return/Mobile/i.test(t)?"phone":"tablet";if(/BlackBerry|IEMobile|Opera Mini/i.test(t))return"phone";if(Number(navigator.maxTouchPoints??0)<=1)return"desktop";if(/Macintosh/.test(t))return"tablet";if(!a())return"desktop";let e=i();return e>0&&e<o?"phone":"tablet"}function s(){return r()!=="desktop"}function i(){try{let t=window.screen,n=Number(t?.width??0),e=Number(t?.height??0);return n>0&&e>0?Math.min(n,e):0}catch{return 0}}function u(t){try{let e=t?.getVideoTracks?.()[0]?.getSettings?.().facingMode;return e==="user"||e==="environment"?e:null}catch{return null}}function a(){try{return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}catch{return!1}}var d=.45,f=.9,h=.4;export{c as a,o as b,r as c,s as d,u as e,d as f,f as g,h};
|
package/dist/chunk-GT2ZLGF7.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function y(){let e=new Map;return{on(i,n){let t=e.get(i);t===void 0&&(t=new Set,e.set(i,t));let r=n;return t.add(r),()=>{t?.delete(r)}},emit(i,n){let t=e.get(i);if(t!==void 0)for(let r of[...t])r(n)},count(i){return e.get(i)?.size??0},clear(){e.clear()}}}async function f(){try{return typeof navigator>"u"||typeof navigator.permissions?.query!="function"?null:await navigator.permissions.query({name:"camera"})}catch{return null}}function u(e){return e==="granted"||e==="prompt"||e==="denied"?e:"unknown"}async function g(){let e=await f();return e===null?"unknown":u(e.state)}function h(e){let i=!1,n=null,t=()=>{!i&&n!==null&&e(u(n.state))};return f().then(r=>{i||(n=r,e(r===null?"unknown":u(r.state)),r?.addEventListener?.("change",t))}),()=>{i=!0,n?.removeEventListener?.("change",t)}}async function b(){if(typeof navigator>"u")return!1;let e=String(navigator.userAgent??"");if(/Android|iPhone|iPad|iPod/i.test(e)||/Macintosh/.test(e)&&(navigator.maxTouchPoints??0)>1)return!0;try{return(await navigator.mediaDevices?.enumerateDevices?.()??[]).filter(n=>n.kind==="videoinput").length>=2}catch{return!1}}function v(){if(typeof navigator>"u"||!("wakeLock"in navigator))return null;let e=navigator.wakeLock;return typeof e?.request=="function"?e:null}function m(){return typeof document>"u"||document.visibilityState==="visible"}function p(e){try{e.release().catch(()=>{})}catch{}}function S(e={}){if(e.enabled===!1)return{setActive:()=>{}};let i=!1,n=null,t=!1,r=!1,l=()=>{if(!i||t||n!==null&&!n.released)return;let o=v();if(o===null||!m())return;let a;try{a=o.request("screen")}catch{return}t=!0,a.then(s=>{if(t=!1,!i){p(s);return}n=s,s.addEventListener?.("release",()=>{n===s&&(n=null)})},()=>{t=!1})},c=()=>{m()&&l()},d=o=>{typeof document>"u"||o===r||(r=o,o?document.addEventListener("visibilitychange",c):document.removeEventListener("visibilitychange",c))};return{setActive:o=>{if(i=o,o){if(v()===null)return;d(!0),l();return}if(d(!1),n!==null){let a=n;n=null,p(a)}}}}export{y as a,g as b,h as c,b as d,S as e};
|
package/dist/chunk-H3HVCWLF.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as v,d as V,e as A}from"./chunk-B2X33ZW2.js";var j=new Set(["nni_unbound","id_number_unbound","method_required","mobile_required","portrait_required"]);function we(e){return j.has(e)}function be(e,n,t){let i=n.detail;return{check:e,kind:n.kind,...i?.name!==void 0?{name:i.name}:{},...i?.phase!==void 0?{phase:i.phase}:{},...i?.engineKind!==void 0?{engineKind:i.engineKind}:{},attempt:Math.max(0,Math.min(1e3,t))}}function ke(){let e=-1,n="";return{note(t){t==="starting"&&n!=="starting"&&(e+=1),n=t},newHandle(){n=""},noteError(){e<0&&(e=0)},get value(){return e}}}var H=Object.freeze({nni_invalid:"id_number_invalid",nni_not_found:"registry_record_not_found",nni_recheck:"id_number_recheck",document_nni_mismatch:"document_id_number_mismatch",nni_locked:"id_number_locked",nni_unbound:"id_number_unbound",sandbox_nni_not_seeded:"sandbox_id_number_not_seeded",missing_nni:"missing_id_number",registry_needs_nni_source:"registry_needs_id_number_source"}),I=new Map(Object.entries(H)),$=new Map(Object.entries(H).map(([e,n])=>[n,e]));function ve(e){return I.get(e)??e}function z(e){let n=I.get(e)??$.get(e);return n===void 0?[e]:[e,n]}function T(e){let n=[];for(let t of e)for(let i of z(t))n.includes(i)||n.push(i);return n}var W=new Set(T(["no_face","media_unreadable","clip_too_short","no_face_source","side_missing","unreadable","registry_unavailable","otp_mismatch","otp_expired","otp_send_failed","document_type_not_accepted","age_unverifiable","nationality_unreadable","liveness_inconclusive","match_inconclusive","document_authenticity","probe_not_from_liveness","capture_back_camera","capture_not_upright","chip_read_failed","chip_access_denied","chip_parse_failed","icao_pose","icao_eyes","icao_mouth","icao_occlusion","icao_lighting","icao_background","icao_resolution","portrait_not_from_liveness","nni_recheck","device_integrity_failed","eid_identifier_invalid","eid_code_invalid","eid_code_expired","eid_unavailable","eid_resend_too_soon"])),X={document:"document_photo",nfc:"document_chip",population_registry:"national_number",national_eid:"national_eid"};function p(e){return e.plan?.steps??[]}function O(e){return Math.max(0,e.attempts.max-e.attempts.used)}function G(e){let n=e.plan?.choice;return n!==void 0&&e.plan?.current===n.nodeId?n:null}function Me(e){let n=G(e);if(n?.kind!=="identity_method")return null;let t=n.options.map(o=>X[o.service]).filter(o=>o!==void 0),i=n.options.find(o=>o.nationalEid)?.nationalEid;return i?{available:!0,selected:null,options:t,nationalEid:i}:{available:!0,selected:null,options:t}}var J=new Set(["liveness","face_match"]);function x(e){return e!==void 0&&(e.state==="pending"||e.state==="input_required")}function L(e){return e.status!=="created"&&e.status!=="in_progress"}function E(e){let n=e.plan?.current,t=n==null?void 0:p(e).find(i=>i.id===n);return x(t)?t:void 0}function y(e,n){return p(e).find(t=>t.checkType===n)}function g(e){let n=p(e),t=n.findIndex(i=>i.checkType==="liveness");return n.find((i,o)=>o>t&&i.checkType==="face_match")}function N(e,n){let t=y(n,"liveness")?.state,i=g(n)?.state;return(g(e)?.state??"pending")==="pending"&&(t==="passed"||t==="review")&&i!==void 0&&i!=="pending"&&i!=="skipped"}function M(e,n){let t=new Map(p(e).map(i=>[i.id,i.state]));return p(n).filter(i=>i.checkType==="face_match"&&(t.get(i.id)??"pending")==="pending"&&i.state!=="pending"&&i.state!=="skipped").map(i=>i.id)}var Q=/^[0-9a-f]{24}$/i;function b(e){return Q.test(e)?`ses_${e}`:e}function w(e,n){let t=b(e);return n===void 0?{sessionId:t,status:"unavailable"}:{sessionId:t,status:"unavailable",reason:n}}function _(e,n,t){let i=b(e);return t===void 0?{sessionId:i,status:n}:{sessionId:i,status:n,reason:t}}function Pe(e,n){let{sessionId:t}=e;switch(e.status){case"completed":case"failed":case"review_pending":return ee(e,ne(e));case"expired":return w(t);case"created":case"in_progress":break;default:{let i=e.status;throw new Error(`mapSessionResult: unhandled status ${i}`)}}return ie(e,n)}var Z=new Set([0,1,2,3]);function ee(e,n){return Z.has(e.level)&&(n.level=e.level),typeof e.assurance=="string"&&e.assurance.length>0&&(n.assurance=e.assurance),n}function ne(e){let n=b(e.sessionId);switch(e.status){case"completed":return e.outcome==="approved"?{sessionId:n,status:"approved"}:e.outcome==="review"?_(n,"review",h(e,"review")):_(n,"rejected",h(e,"failed"));case"failed":{let t=_(n,"rejected",e.failureReason??h(e,"failed"));return e.failureReason==="device_cooldown"&&e.retryAfter!==void 0&&(t.retryAfter=e.retryAfter),t}default:return _(n,"review",h(e,"review"))}}function te(e,n){if(n===void 0)return!1;let t=p(n).find(i=>i.id===e.id);return t!==void 0&&t.attempts.used===e.attempts.used}function ie(e,n){let t=b(e.sessionId),i=p(e).find(s=>J.has(s.checkType)&&s.state==="input_required"&&s.reason!==void 0);if(i?.reason==="mobile_required")return w(t,"mobile_required");if(i?.reason!==void 0){let s=n.autoRetry&&O(i)>0&&(W.has(i.reason)||te(i,n.previous)),d={sessionId:t,status:s?"retry":"rejected",reason:i.reason,attemptsRemaining:O(i)};return i.retakeHint!==void 0&&(d.retakeHint=i.retakeHint),d}let o=E(e);return o===void 0&&p(e).some(s=>s.state==="review")?_(t,"review",h(e,"review")):o?.checkType==="portrait_icao"?w(t,"portrait_required"):w(t)}function h(e,n){let t=p(e).filter(i=>i.state===n&&i.reason!==void 0);return t[n==="failed"?t.length-1:0]?.reason}function K(e,n,t,i,o){return e.presignCapture!==void 0?e.presignCapture(n,t,i,o):e.presign(n,t,i)}function q(e){return{engine:e?.engine,durationMs:e?.clipMs}}var oe=["video/webm","video/mp4"],F="image/jpeg",se=2,re=1e3,ae=1e4,de=3,ue=10,ce=3,le=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),pe=new Set(["session_not_active","check_not_found","check_already_finalized","check_out_of_order","identity_confirm_required","check_not_active","step_not_on_path"]),S=class extends Error{constructor(){super("verification destroyed"),this.name="FlowCancelledError"}};function fe(e){let n=g(e);return y(e,"portrait_icao")?.state!=="pending"&&(n!==void 0?x(n):e.capture?.livePhoto?.oneCapture===!0)}var R=class extends Error{constructor(n){super(n),this.name="AttestationError"}};async function D(e,n,t={}){let i=e.uuid(),o=!1,s=!1,d=0,u=0;for(;;)try{return await n(e.client,i)}catch(r){if(r instanceof R){if(s)throw r;s=!0,t.onAttestationInvalid?.(),i=e.uuid();continue}if(!(r instanceof v))throw r;if(r.code==="consent_required"&&!o){o=!0,await e.ensureConsent({force:!0}),i=e.uuid();continue}if(r.code==="attestation_invalid"&&!s){s=!0,t.onAttestationInvalid?.(),i=e.uuid();continue}if(r.code==="inference_unavailable"&&u<de){u+=1;let a=V(r.retryAfterSeconds,ue,e.random??Math.random);e.onBusy?.({attempt:u,retryAfterSeconds:a/1e3}),await e.sleep(a),t.onAttestationInvalid?.(),i=e.uuid();continue}if(le.has(r.code)&&d<se){d+=1;let a=r.retryAfterSeconds!==void 0?r.retryAfterSeconds*1e3:void 0;await e.sleep(a!==void 0?Math.min(a,ae):re);continue}throw r}}var me=new Set(["passed","review","processing","skipped"]);async function Oe(e){let{artifacts:n}=e,t=n.clip,i=A(n.clipMime??"");if(n.degraded==="NO_RECORDER"||t===void 0||!oe.includes(i))return{kind:"unavailable",reason:"no_recorder"};e.client.armCapture?.(2);let o=_e(e,n.keyframe),s=he(e,t,i,o),d=ge(e,o),u=!1,r=new Set,a=!0,m=0;for(;;){if(e.isCancelled())return{kind:"cancelled"};let l=e.getView();if(L(l))return{kind:"settled"};let k=E(l),P=k?.checkType,C=P==="liveness"&&!u?"liveness":P==="face_match"&&!r.has(k?.id)&&r.size<2&&a?"face_match":null;if(C===null)return{kind:"settled"};if(C==="liveness"&&n.captureChannel==="desktop"&&y(l,"liveness")?.requiresMobile===!0)return{kind:"unavailable",reason:"mobile_required"};try{if(C==="liveness"){u=!0;let c=await s();if(e.isCancelled())return{kind:"cancelled"};N(l,c)&&r.add(g(c)?.id);for(let B of M(l,c))r.add(B);await e.applySubmit(c,"liveness");let f=y(e.getView(),"liveness")?.state;a=f===void 0||me.has(f)}else{r.add(k?.id);let c=await d();if(e.isCancelled())return{kind:"cancelled"};for(let f of M(l,c))r.add(f);await e.applySubmit(c,"face_match")}}catch(c){if(e.isCancelled()||c instanceof S)return{kind:"cancelled"};let f=Re(c);if(f.kind!=="resync"||m>=ce)return f;m+=1,await e.refreshView()}}}function _e(e,n){let t=null,i=null,o=()=>t!==null?Promise.resolve(t):(i??(i=(async()=>{let s=await K(e.client,"image",F,n.size,q(e.artifacts));return await e.client.uploadToSpaces(s.uploadUrl,n,F),t=(await e.client.completeMedia(s.key)).key,e.onKeyframePromoted?.(t),t})().finally(()=>{i=null})),i);return{ensure:o,attempt:()=>o().catch(()=>null),current:()=>t}}function he(e,n,t,i){let o=null,s,d=null;return()=>D(e,async(u,r)=>{if(o===null||s===void 0){if(e.isCancelled())throw new S;s===void 0&&!fe(e.getView())&&(s=null),e.onPhase("uploading");let[a,m]=await Promise.all([o!==null?Promise.resolve(o):(async()=>{let l=await K(u,"clip",t,n.size,q(e.artifacts));return await u.uploadToSpaces(l.uploadUrl,n,t),(await u.completeMedia(l.key)).key})(),s!==void 0?Promise.resolve(s===null?null:s.imageKey):i.attempt()]);o=a,s===void 0&&(s=m===null?null:{imageKey:m})}if(d===null)try{d=await e.getAttestation()}catch(a){throw new R(a instanceof Error?a.message:String(a))}return e.onPhase("checking"),u.submitCheck("liveness",{clipKey:o,attestation:d,captureChannel:e.artifacts.captureChannel,capture:ye(e.artifacts),...s!==null?{faceMatch:s}:{}},{idempotencyKey:r})},{onAttestationInvalid:()=>{d=null}})}function ge(e,n){return()=>D(e,async(t,i)=>{if(n.current()===null){if(e.isCancelled())throw new S;e.onPhase("uploading")}let o=await n.ensure();return e.onPhase("checking"),t.submitCheck("face_match",{imageKey:o},{idempotencyKey:i})})}function ye(e){let n={width:e.width,height:e.height};for(let t of Se)e[t]!==void 0&&(n[t]=e[t]);return n}var Se=["engine","facingMode","mode","formFactor","clipMs","cameraReadyMs","faceAcquireMs","captureMs","screenRamp","provenance"];function Re(e){if(e instanceof R)return{kind:"unavailable",reason:"attestation"};if(e instanceof v){if(e.code==="attestation_invalid")return{kind:"unavailable",reason:"attestation"};if(e.code==="inference_unavailable")return{kind:"unavailable",reason:"inference_unavailable"};if(e.code==="mobile_required")return{kind:"unavailable",reason:"mobile_required"};if(pe.has(e.code))return{kind:"resync"}}return{kind:"unavailable",reason:"network"}}var U=class extends Error{constructor(n,t){super(`invalid ${n} (${t})`),this.name="InvalidInputError",this.field=n,this.kind=t}},Y=class extends Error{constructor(n,t){super(`invalid ${n} (${t})`),this.name="OtpInputError",this.field=n,this.kind=t}};function Fe(e){let n=e?.capture,t=n?.mode;return t==="assisted"||t==="self"||t==="choice"?t:n?.cameraSwitch===!0?"assisted":"self"}function Ke(e,n){return e==="choice"?n??"self":e}export{we as a,be as b,ke as c,Fe as d,Ke as e,ve as f,W as g,X as h,p as i,O as j,G as k,Me as l,x as m,L as n,E as o,y as p,b as q,w as r,Pe as s,K as t,oe as u,se as v,re as w,de as x,ue as y,R as z,D as A,Oe as B,U as C,Y as D};
|
package/dist/chunk-O5WKNZ2C.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var f="https://challenges.cloudflare.com/turnstile/v0/api.js",g=3e4;function p(){return window.turnstile}var o=null;function w(){o=null}function E(){return o??(o=new Promise((s,t)=>{let r=p();if(r){s(r);return}let e=document.createElement("script");e.src=f,e.async=!0,e.onload=()=>{let n=p();n?s(n):(o=null,t(new Error("Turnstile script loaded but exposed no API")))},e.onerror=()=>{o=null,e.remove(),t(new Error("Turnstile script failed to load"))},document.head.appendChild(e)})),o}function d(){return new Error("Turnstile challenge aborted")}async function x(s,t={}){let r=t.timeoutMs??3e4,e=t.signal;if(e?.aborted)throw d();let n=await E();if(e?.aborted)throw d();let a=document.createElement("div");document.body.appendChild(a);let i,c,u;try{return await new Promise((m,l)=>{if(c=setTimeout(()=>l(new Error(`Turnstile challenge timed out (${r} ms)`)),r),e!==void 0&&(u=()=>l(d()),e.addEventListener("abort",u,{once:!0})),i=n.render(a,{sitekey:s,execution:"execute",appearance:"execute",callback:m,"error-callback":T=>{l(new Error(`Turnstile challenge failed${T?` (${T})`:""}`))}}),i===void 0){l(new Error("Turnstile render returned no widget id"));return}n.execute(i)})}finally{if(clearTimeout(c),e!==void 0&&u!==void 0&&e.removeEventListener("abort",u),i!==void 0)try{n.remove(i)}catch{}a.remove()}}export{f as a,g as b,w as c,E as d,x as e};
|
package/dist/chunk-OKWG3PVH.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var v=1e4,u=class t{constructor(e,i){this.tier="blaze";this.inner=e,i!==void 0&&(this.fallbackReason=i)}static async create(e,i){let o=await import("@mediapipe/tasks-vision"),n=await o.FilesetResolver.forVisionTasks(e),r=await o.FaceDetector.createFromOptions(n,{baseOptions:{modelAssetPath:`${e}/blaze_face_short_range.tflite`,delegate:"CPU"},runningMode:"IMAGE"});return new t(r,i)}async detect(e,i,o){let n;try{n=this.inner.detect(e).detections}catch{return null}let r=O(n);if(r?.boundingBox===void 0)return null;let a=g(e),s=w(r.keypoints,a),c=r.keypoints?.[2],b={box:{x:r.boundingBox.originX,y:r.boundingBox.originY,width:r.boundingBox.width,height:r.boundingBox.height},...s!==void 0?{eyes:s}:{},...c!==void 0?{nose:{x:c.x*a.width,y:c.y*a.height}}:{},score:r.categories[0]?.score??0};return l(b,e,i,o)}destroy(){try{this.inner.close()}catch{}}};function O(t){let e,i=-1;for(let o of t){let n=o.categories[0]?.score??0;n>i&&(e=o,i=n)}return e}function w(t,e){let i=t?.[0],o=t?.[1];if(i===void 0||o===void 0)return;let n=s=>({x:s.x*e.width,y:s.y*e.height}),[r,a]=[n(i),n(o)];return r.x<=a.x?{left:r,right:a}:{left:a,right:r}}function R(){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(2,2);let t=document.createElement("canvas");return t.width=2,t.height=2,t}async function x(){let t=globalThis.FaceDetector;if(typeof t!="function")return{ok:!1,reason:"unsupported"};try{let e=new t({fastMode:!0,maxDetectedFaces:1});return await e.detect(R()),{ok:!0,instance:e}}catch(e){return{ok:!1,reason:`smoke_failed:${e instanceof Error?e.message:String(e)}`}}}var m=class{constructor(e,i){this.tier="native";this.inner=e,i!==void 0&&(this.fallbackReason=i)}async detect(e,i,o){let n;try{n=await this.inner.detect(e)}catch{return null}let r=n[0];if(r===void 0)return null;let a=T(r.landmarks),s={box:{x:r.boundingBox.x,y:r.boundingBox.y,width:r.boundingBox.width,height:r.boundingBox.height},...a!==void 0?{eyes:a}:{},score:1};return l(s,e,i,o)}destroy(){}};function T(t){if(t===void 0)return;let e=t.filter(n=>n.type==="eye").map(n=>n.locations[0]).filter(n=>n!==void 0),[i,o]=e;if(!(i===void 0||o===void 0))return i.x<=o.x?{left:i,right:o}:{left:o,right:i}}var F="/models-v3",I=["native","blaze"],y=class extends Error{constructor(e){super(`no detector tier available (${e})`),this.name="DetectorLadderError",this.fallbackReason=e}};function g(t){let e=t;if(typeof e.videoWidth=="number"&&e.videoWidth>0)return{width:e.videoWidth,height:e.videoHeight??0};if(typeof e.naturalWidth=="number"&&e.naturalWidth>0)return{width:e.naturalWidth,height:e.naturalHeight??0};let i=typeof e.width=="number"?e.width:0,o=typeof e.height=="number"?e.height:0;return{width:i,height:o}}function l(t,e,i,o){let n=g(e),r=n.width>0?i/n.width:1,a=n.height>0?o/n.height:1,s=c=>({x:c.x*r,y:c.y*a});return{box:{x:t.box.x*r,y:t.box.y*a,width:t.box.width*r,height:t.box.height*a},...t.eyes!==void 0?{eyes:{left:s(t.eyes.left),right:s(t.eyes.right)}}:{},...t.nose!==void 0?{nose:s(t.nose)}:{},score:t.score}}function E(t){return t instanceof Error?t.message:String(t)}async function k(t){let e=t.preferred??I,i=[];for(let o of e){if(o==="native"){let n=await x();if(n.ok)return new m(n.instance,h(i));i.push(`native:${n.reason}`);continue}try{return await S(u.create(t.v3AssetBaseUrl??F,h(i)),t.blazeInitTimeoutMs??v)}catch(n){i.push(n instanceof f?"blaze:blaze_init_timeout":`blaze:${E(n)}`)}}throw new y(h(i)??"no_tier_available")}function h(t){return t.length>0?t.join("; "):void 0}var f=class extends Error{};function S(t,e){return new Promise((i,o)=>{let n=setTimeout(()=>{o(new f(`init exceeded ${e}ms`)),t.then(r=>r.destroy(),()=>{})},e);t.then(r=>{clearTimeout(n),i(r)},r=>{clearTimeout(n),o(r)})})}var d=1;function A(){return typeof OffscreenCanvas=="function"&&typeof createImageBitmap=="function"&&typeof Worker=="function"}function M(t,e={}){let i=e.createDetector??k,o=null;t.onmessage=n=>{let r=n.data;if(r.v!==d){r.bitmap?.close?.();return}if(r.type==="init"){i(r.options).then(a=>{o=a;let s={v:d,type:"ready",tier:a.tier,...a.fallbackReason!==void 0?{fallbackReason:a.fallbackReason}:{}};t.postMessage(s)});return}if(r.type==="detect"){let a=s=>{let c={v:d,type:"result",id:r.id,observation:s};t.postMessage(c),r.bitmap.close?.()};if(o===null){a(null);return}o.detect(r.bitmap,r.streamWidth,r.streamHeight).then(a,()=>a(null))}}}typeof self<"u"&&typeof self.importScripts=="function"&&M(self);var D=class t{constructor(e,i){this.pending=new Map;this.nextId=1;this.worker=e,this.tier=i.tier,i.fallbackReason!==void 0&&(this.fallbackReason=i.fallbackReason),e.addEventListener("message",o=>{let n=o.data;if(n.v!==d||n.type!=="result")return;let r=this.pending.get(n.id);this.pending.delete(n.id),r?.(n.observation)})}static create(e,i,o=1e4){return new Promise((n,r)=>{let a=setTimeout(()=>{e.removeEventListener("message",s),e.terminate(),r(new Error(`worker detector not ready within ${o}ms`))},o),s=b=>{let p=b.data;p.v!==d||p.type!=="ready"||(clearTimeout(a),e.removeEventListener("message",s),n(new t(e,p)))};e.addEventListener("message",s);let c={v:d,type:"init",options:i};e.postMessage(c)})}async detect(e,i,o){let n;try{typeof ImageBitmap<"u"&&e instanceof ImageBitmap?n=e:typeof createImageBitmap=="function"?n=await createImageBitmap(e):n=e}catch{return null}let r=this.nextId;return this.nextId+=1,new Promise(a=>{this.pending.set(r,a);let s={v:d,type:"detect",id:r,bitmap:n,streamWidth:i,streamHeight:o};this.worker.postMessage(s,[n])})}destroy(){for(let e of this.pending.values())e(null);this.pending.clear(),this.worker.terminate()}};export{F as a,I as b,y as c,g as d,l as e,k as f,d as g,A as h,M as i,D as j};
|
package/dist/chunk-P3H3D33O.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as Z,d as j,e as J}from"./chunk-GT2ZLGF7.js";import{w as Q}from"./chunk-7Q4YPMAF.js";import{c as q}from"./chunk-FUHDOEBP.js";import{f as G,l as N}from"./chunk-CQ7SKLMC.js";import{a as $,f as v}from"./chunk-OKWG3PVH.js";var se=12e4,X=13e4,oe=3e3,ie=1200,P=Symbol.for("@sekyro/web.preload.v1");function p(){let e=globalThis;return e[P]??(e[P]=new Map),e[P]}function g(e){let t=(e??$).replace(/\/+$/,"");return t===""?"/":t}function Y(e){let t=p(),r=t.get(e);return r===void 0&&(r={status:"idle",promise:null,scheduled:null,detectorPromise:null,detector:null,listeners:new Set},t.set(e,r)),r}function A(e,t){if(e.status!==t){e.status=t;for(let r of[...e.listeners])r(t)}}var T=e=>v({preferred:["blaze"],v3AssetBaseUrl:e,blazeInitTimeoutMs:se}),x=T;function Se(e){x=e??T}function Ce(){for(let e of p().values())e.detector?.destroy();p().clear(),x=T}function ae(){return typeof window<"u"&&typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function"}function ce(){return navigator.connection?.saveData===!0}function de(e){let t=window;if(typeof t.requestIdleCallback=="function"){let s=t.requestIdleCallback(e,{timeout:oe});return()=>t.cancelIdleCallback?.(s)}let r=setTimeout(e,ie);return()=>clearTimeout(r)}function ue(e,t){let r,s=new Promise(o=>{r=o}),u=!1,f=()=>{},d={promise:s,settle:o=>{u||(u=!0,f(),e.scheduled===d&&(e.scheduled=null),r(o))}};return e.scheduled=d,f=de(()=>{u||d.settle(I(e,t))}),s}function I(e,t){if((e.status==="loading"||e.status==="ready")&&e.promise!==null)return e.promise;A(e,"loading");let r=new Promise(o=>o(x(t)));e.detectorPromise=r;let s,u=new Promise((o,h)=>{s=setTimeout(()=>{r.then(S=>S.destroy(),()=>{}),h(new Error(`detector preload exceeded ${X} ms`))},X)}),d=Promise.race([r,u]).then(o=>e.detectorPromise!==r?(o.destroy(),e.status):(e.detector=o,A(e,"ready"),"ready"),o=>(e.detectorPromise===r&&(e.detectorPromise=null,e.detector=null,A(e,"failed"),console.warn("[@sekyro/web] face-detector preload failed:",o)),e.status)).finally(()=>clearTimeout(s));return e.promise=d,e.scheduled?.settle(d),d}function Le(e={}){if(!ae())return Promise.resolve("idle");let t=g(e.assetBaseUrl),r=Y(t);return e.respectSaveData===!0&&ce()?Promise.resolve(r.status):(r.status==="loading"||r.status==="ready")&&r.promise!==null?r.promise:e.idle===!0?r.scheduled?.promise??ue(r,t):I(r,t)}function Ee(e){return p().get(g(e))?.status??"idle"}function ye(e,t){let r=Y(g(t));return r.listeners.add(e),()=>{r.listeners.delete(e)}}function be(e){let t=p().get(g(e));t!==void 0&&(t.scheduled?.settle("idle"),t.detector?.destroy(),t.detector=null,t.detectorPromise=null,t.promise=null,A(t,"idle"))}function le(e){return{get tier(){return e.tier},get fallbackReason(){return e.fallbackReason},detect:(...t)=>e.detect(...t),destroy:()=>{}}}function ee(e){let t=g(e),r=p().get(t);if(!(r===void 0||r.detector===null&&r.detectorPromise===null&&r.scheduled===null))return async()=>{r.scheduled!==null&&I(r,t);let s=r.promise;for(;r.detector===null&&s!==null&&(await s,r.promise!==s);)s=r.promise;return r.detector!==null?le(r.detector):v({v3AssetBaseUrl:t})}}function fe(e){switch(e){case"fcv3.no_face":case"fcv3.center_face":case"fcv3.straighten":return"center";case"fcv3.come_closer":return"closer";case"fcv3.move_back":return"farther";case"fcv3.more_light":case"fcv3.too_bright":return"light";case"fcv3.hold_still":case"fcv3.steady_camera":return"still";case"fcv3.hold_upright":return"upright";default:return null}}function pe(e){switch(e){case"preflight":case"acquiring":return"starting";case"positioning":return"gating";default:return e}}function te(e){switch(e){case"permission":case"notfound":case"inuse":case"insecure":case"unsupported":return e;default:{let t=e;return"generic"}}}function me(e,t,r){if(r===void 0)return{kind:te(e),retryable:t};let s=N(r.name);return{kind:te(e),retryable:t,detail:{...s!==void 0?{name:s}:{},phase:r.phase,engineKind:e}}}function ve(e,t={},r,s=()=>"self",u=()=>{}){let f=t.now??(()=>performance.now()),d=t.canChooseFacing??j,o="user",h=!1,S=n=>(n==="environment"&&!h&&(h=!0,console.warn('[@sekyro/web] facing "environment" ignored: this capture is a self capture (the person films themselves), which uses the front camera only. The back camera is for assisted capture, set in the flow.')),"user"),D=!1,m=s(),c=Z(),H=!G(),U=t.engineOptions,re=U?.createDetector===void 0&&U?.createWorker===void 0?{createDetector:()=>{let n=ee(e.assetBaseUrl);return n!==void 0?n():v({v3AssetBaseUrl:e.assetBaseUrl})}}:{},B={video:e.video,mode:H?"photo":"clip",rankKeyframes:r,facingMode:void 0,v3AssetBaseUrl:e.assetBaseUrl,screenRamp:()=>m==="self"&&c.count("ramp")>0?u():void 0,...t.engineOptions??{},...re},i=t.createEngine?.(B)??new Q(B),C="idle",L=null,E=0,k=!1,M="full",y=null,b=null,_=0,F=0,K=()=>{e.video.videoWidth>0&&e.video.videoHeight>0&&(_=e.video.videoWidth,F=e.video.videoHeight)},V=J({enabled:e.keepScreenAwake!==!1}),z=n=>{C=n,V.setActive(n==="starting"||n==="gating"||n==="recording"),c.emit("state",n)},O=()=>c.emit("gate",{progress:E,hint:L,faceDetected:k}),W=()=>{let n=i.animations??"full";n!==M&&(M=n,c.emit("profile",{animations:M}))},ne=[i.on("statechange",({state:n})=>{let a=pe(n);a==="starting"&&C!=="starting"&&(L=null,E=0,k=!1,y=null,b=null,_=0,F=0),z(a),W(),a==="recording"&&(K(),y=f(),L="hold",E=1,O())}),i.on("checks",n=>{K(),E=n.progress,k=n.factors.presence>0,O(),W()}),i.on("guidance",({key:n})=>{L=fe(n),O()}),i.on("frozen",({previewDataUrl:n})=>{b=f(),c.emit("frozen",{previewDataUrl:n})}),i.on("ramp",n=>c.emit("ramp",n)),i.on("artifacts",n=>{let a=q(),l=y!==null&&b!==null?Math.max(0,Math.round(b-y)):void 0;c.emit("captured",{keyframe:n.keyframe,...n.clip!==void 0?{clip:n.clip}:{},...n.clipMimeType!==void 0?{clipMime:n.clipMimeType}:{},width:e.video.videoWidth||_,height:e.video.videoHeight||F,...l!==void 0?{clipMs:l}:{},captureChannel:a==="desktop"?"desktop":"mobile",formFactor:a,...H?{degraded:"NO_RECORDER"}:{},engine:"v3",facingMode:i.facingMode,mode:m,...n.timing,...n.screenRamp!==void 0?{screenRamp:n.screenRamp}:{},...n.provenance!==void 0?{provenance:n.provenance}:{}})}),i.on("error",({kind:n,retryable:a,detail:l})=>{c.emit("error",me(n,a,l))})];return{handle:{get state(){return C},get captureMode(){return s()},get facingMode(){return i.facingMode??o},on:(n,a)=>c.on(n,a),start:n=>{if(m=s(),m==="self")return S(e.facing),S(n?.facing),D=!0,o="user",i.start({facingMode:"user"});let a=!D;D=!0;let l=n?.facing??(a?e.facing:void 0),R=w=>(o=w,i.start({facingMode:w}));return l!==void 0?R(l):a?d().then(w=>R(w?"environment":"user"),()=>R("user")):i.start({})},retry:()=>i.retry(),switchCamera:()=>s()!=="assisted"?!1:(m="assisted",o=o==="user"?"environment":"user",i.switchCamera(),!0),destroy:()=>{for(let n of ne)n();V.setActive(!1),i.destroy(),c.clear()}},setFlowState:n=>{C!==n&&z(n)}}}function Te(e){return ve(e).handle}export{se as a,X as b,Se as c,Ce as d,Le as e,Ee as f,ye as g,be as h,ee as i,fe as j,pe as k,te as l,me as m,ve as n,Te as o};
|
package/dist/chunk-P6UP4UQY.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as Jt}from"./chunk-SMKCBUJL.js";import{a as et,b as $t,c as te,e as dt,f as ee}from"./chunk-MXWLCDFX.js";import{d as Yt,h as Zt,k as qt}from"./chunk-G6LKLN4U.js";import{b as Xt,c as jt}from"./chunk-TDLIXFDT.js";import{b as Ht,c as Kt}from"./chunk-POIQGEZM.js";import{k as Nt,m as Qt,n as Ut,o as Wt}from"./chunk-CQ7SKLMC.js";import{b as ut,c as ht,d as j,e as Vt}from"./chunk-FPXL63KZ.js";import{d as Bt}from"./chunk-VIAT4DEA.js";var it=Object.freeze({sensing:{key:"sensing",reticle:"searching",minDurationMs:900},too_far:{key:"too_far",reticle:"coaching",minDurationMs:1400},too_close:{key:"too_close",reticle:"coaching",minDurationMs:1400},edge_clipped:{key:"edge_clipped",reticle:"coaching",minDurationMs:1400},wrong_shape:{key:"wrong_shape",reticle:"coaching",minDurationMs:1400},tilted:{key:"tilted",reticle:"coaching",minDurationMs:1400},too_dark:{key:"too_dark",reticle:"coaching",minDurationMs:1400},too_bright:{key:"too_bright",reticle:"coaching",minDurationMs:1400},blurry:{key:"blurry",reticle:"coaching",minDurationMs:1400},focus_far:{key:"focus_far",reticle:"coaching",minDurationMs:1600},glare:{key:"glare",reticle:"coaching",minDurationMs:1400},hold_still:{key:"hold_still",reticle:"locking",minDurationMs:900},processing:{key:"processing",reticle:"processing",minDurationMs:800},side_captured:{key:"side_captured",reticle:"flip",minDurationMs:2600},captured:{key:"captured",reticle:"done",minDurationMs:800}});function ie(i){return i.framing==="no_document"?"sensing":i.framing==="too_far"?"too_far":i.framing==="too_close"?"too_close":i.framing==="edge_clipped"?"edge_clipped":i.framing==="wrong_shape"?"wrong_shape":i.framing==="tilted"?"tilted":i.lighting==="too_dark"?"too_dark":i.lighting==="too_bright"?"too_bright":i.glare==="glare"?"glare":i.blur==="blurry"?"blurry":"hold_still"}var nt=class{constructor(t=2600,e=.35){this.windowMs=t;this.decayPerSecond=e;this.votes=[];this.current=it.sensing;this.currentSinceMs=null}reset(){this.votes=[],this.current=it.sensing,this.currentSinceMs=null}force(t,e){return this.votes=[],this.current=it[t],this.currentSinceMs=e,this.current}tick(t,e){if(this.currentSinceMs===null&&(this.currentSinceMs=e),this.votes.push({key:t,atMs:e}),this.votes=this.votes.filter(r=>e-r.atMs<=this.windowMs),e-this.currentSinceMs<this.current.minDurationMs)return this.current;let n=new Map;for(let r of this.votes){let c=(e-r.atMs)/1e3,a=this.decayPerSecond**c;n.set(r.key,(n.get(r.key)??0)+a)}let o=this.current.key,s=-1;for(let[r,c]of n)c>s&&(s=c,o=r);return o!==this.current.key&&(this.current=it[o],this.currentSinceMs=e),this.current}};var Ke=Object.freeze({MAX_AREA_FRAC:.92,TILT_MAX_SIDE_RATIO:1.3,GLARE_MAX_SPECULAR_FRAC:.025});function oe(i){let{data:t,width:e,height:n}=i,o=e*n;if(o===0)return 0;let s=0;for(let r=0;r<o;r++){let c=r*4;.299*(t[c]??0)+.587*(t[c+1]??0)+.114*(t[c+2]??0)>=252&&s++}return s/o}function Ve(i){let t=(a,l)=>Math.hypot(l.x-a.x,l.y-a.y),e=t(i.topLeft,i.topRight),n=t(i.bottomLeft,i.bottomRight),o=t(i.topLeft,i.bottomLeft),s=t(i.topRight,i.bottomRight),r=Math.max(e,n)/Math.max(1e-6,Math.min(e,n)),c=Math.max(o,s)/Math.max(1e-6,Math.min(o,s));return Math.max(r,c)}function se(i){let t={...$t,...i.thresholds},e=Ke,{quad:n,frameWidth:o,frameHeight:s,measures:r}=i,c=i.format==="ID-3",a="ok";if(n===null)a="no_document";else if(c){let m=dt(n),h=o>0?m.width/o:0,f=m.height>0?m.width/m.height:0;h<t.ID3_BAND_MIN_WIDTH_FRAC?a="too_far":ne(n,o,s,t.EDGE_CLIP_MARGIN_PX)?a="edge_clipped":(f<t.ID3_BAND_ASPECT_MIN||f>t.ID3_BAND_ASPECT_MAX)&&(a="wrong_shape")}else{let m=te(n,o,s),h=dt(n),f=Math.max(h.width,h.height)/Math.max(1e-6,Math.min(h.width,h.height));m<t.MIN_AREA_FRAC?a="too_far":m>e.MAX_AREA_FRAC?a="too_close":ne(n,o,s,t.EDGE_CLIP_MARGIN_PX)?a="edge_clipped":jt(i.format,f)?Ve(n)>e.TILT_MAX_SIDE_RATIO&&(a="tilted"):a="wrong_shape"}let l=r.exposure>=t.GUIDE_EXPOSURE?"ok":r.meanLuma<(ut[0]+ut[1])/2?"too_dark":"too_bright",u=r.sharpness>=t.GUIDE_SHARPNESS?"ok":"blurry",d=r.specularFraction>=e.GLARE_MAX_SPECULAR_FRAC?"glare":"ok";return{framing:a,lighting:l,blur:u,glare:d,acceptable:a==="ok"&&l==="ok"&&u==="ok"&&d==="ok"}}function ne(i,t,e,n){return[i.topLeft,i.topRight,i.bottomRight,i.bottomLeft].some(s=>s.x<=n||s.y<=n||s.x>=t-n||s.y>=e-n)}var ae=Object.freeze({width:1920,height:1080}),Xe=Object.freeze({width:3840,height:2160}),re=4096,je=2560,ce=640,ot=.15,Y=Object.freeze({side:.2,above:.9,below:.3});function E(i){let t=[i.topLeft.x,i.topRight.x,i.bottomRight.x,i.bottomLeft.x],e=[i.topLeft.y,i.topRight.y,i.bottomRight.y,i.bottomLeft.y],n=Math.min(...t),o=Math.min(...e);return{x:n,y:o,width:Math.max(...t)-n,height:Math.max(...e)-o}}function le(i,t){let e=Math.max(0,Math.floor(i.x)),n=Math.max(0,Math.floor(i.y)),o=Math.min(t.width,Math.ceil(i.x+i.width)),s=Math.min(t.height,Math.ceil(i.y+i.height));return o-e<16||s-n<16?null:{x:e,y:n,width:o-e,height:s-n}}function Ye(i,t,e){if(i===null||t.width<=0||t.height<=0)return null;let n=E(i);if(n.width<=0||n.height<=0)return null;let o=e==="ID-3"?{x:n.x-n.width*Y.side,y:n.y-n.width*Y.above,width:n.width*(1+2*Y.side),height:n.height+n.width*(Y.above+Y.below)}:{x:n.x-n.width*ot,y:n.y-n.height*ot,width:n.width*(1+2*ot),height:n.height*(1+2*ot)};return le(o,t)}function mt(i,t,e){let n=Math.max(i,t);return n>0?Math.min(1,e/n):1}function ft(i,t,e,n,o=je){let s=t.width>0?e.width/t.width:1,r=t.height>0?e.height/t.height:1,c=i===null?null:{topLeft:{x:i.topLeft.x*s,y:i.topLeft.y*r},topRight:{x:i.topRight.x*s,y:i.topRight.y*r},bottomRight:{x:i.bottomRight.x*s,y:i.bottomRight.y*r},bottomLeft:{x:i.bottomLeft.x*s,y:i.bottomLeft.y*r}},a=Ye(c,e,n)??{x:0,y:0,width:e.width,height:e.height},l=mt(a.width,a.height,o),u=Math.max(1,Math.round(a.width*l)),d=Math.max(1,Math.round(a.height*l)),m=null;if(c!==null){let h=E(c);m=le({x:(h.x-a.x)*l,y:(h.y-a.y)*l,width:h.width*l,height:h.height*l},{width:u,height:d})}return{crop:a,width:u,height:d,docRegion:m}}function ue(i,t,e,n=Xe){if(e==="LOW")return null;let o=i?.width?.max,s=i?.height?.max;if(typeof o!="number"||typeof s!="number"||o<=0||s<=0)return null;let r=Math.max(o,s),c=Math.min(o,s),a=Math.min(r,Math.max(n.width,n.height)),l=Math.min(c,Math.min(n.width,n.height));return a<=Math.max(t.width,t.height)?null:{width:{ideal:a},height:{ideal:l}}}function he(i){let t={},e=i?.imageWidth,n=i?.imageHeight;if(typeof e?.max=="number"&&e.max>0){let o=typeof n?.max=="number"&&n.max>0?e.max/n.max:1.3333333333333333,s=o>=1?re:re*o,r=Math.min(e.max,Math.floor(s)),c=typeof e.step=="number"&&e.step>0?e.step:1,a=typeof e.min=="number"?e.min:0;r=Math.max(a,a+Math.floor((r-a)/c)*c),t.imageWidth=r}return i?.fillLightMode?.includes("off")===!0&&(t.fillLightMode="off"),t}function de(i,t){if(i.width<=0||i.height<=0||t.width<=0||t.height<=0)return!1;let e=i.width>i.height,n=t.width>t.height;return e!==n&&i.width!==i.height&&t.width!==t.height?!1:Math.max(i.width,i.height)>=1.2*Math.max(t.width,t.height)}function me(i,t,e,n){if(e===null)return!1;let o=E(i),s=E(e);if(t.width<=0||n.width<=0)return!1;let r=o.width/t.width,c=s.width/n.width;return c>0&&r>=.6*c&&r<=1.25*c}var fe=3500,Ze=.92;function ge(){let i=globalThis.ImageCapture;return typeof i=="function"?i:null}function Je(i){return/AppleWebKit\//.test(i)&&!/(Chrome|Chromium|Edg|OPR)\//.test(i)}function be(i,t=typeof navigator>"u"?"":navigator.userAgent){return ge()!==null&&!Je(t)&&i!=null&&i.kind==="video"&&i.readyState==="live"}function pe(i,t){return new Promise((e,n)=>{let o=setTimeout(()=>n(new Error("takePhoto timed out")),t);i.then(s=>{clearTimeout(o),e(s)},s=>{clearTimeout(o),n(s)})})}function pt(i,t){let e=document.createElement("canvas");return e.width=i,e.height=t,e}function qe(i,t){return new Promise((e,n)=>{i.toBlob(o=>o?e(o):n(new Error("toBlob failed")),"image/jpeg",t)})}async function ye(i,t,e,n,o){let s=pt(e,n),r=pt(1,1);try{let c=s.getContext("2d");if(c===null)throw new Error("2d context unavailable");c.imageSmoothingQuality="high",c.drawImage(i,t.x,t.y,t.width,t.height,0,0,e,n);let a=await qe(s,Ze),l=o===null?null:Yt({topLeft:{x:o.x,y:o.y},topRight:{x:o.x+o.width,y:o.y},bottomRight:{x:o.x+o.width,y:o.y+o.height},bottomLeft:{x:o.x,y:o.y+o.height}},{width:e,height:n},{width:e,height:n}),u=Zt(s,l),d=mt(e,n,ce);return r.width=Math.max(1,Math.round(e*d)),r.height=Math.max(1,Math.round(n*d)),r.getContext("2d")?.drawImage(s,0,0,r.width,r.height),{blob:a,previewDataUrl:r.toDataURL("image/jpeg",.85),sharpness:u}}finally{s.width=0,s.height=0,r.width=0,r.height=0}}function $e(i,t){let e=Math.min(1,t/i.width),n=pt(Math.max(1,Math.round(i.width*e)),Math.max(1,Math.round(i.height*e)));try{let o=n.getContext("2d",{willReadFrequently:!0});return o===null?null:(o.imageSmoothingQuality="high",o.drawImage(i,0,0,n.width,n.height),o.getImageData(0,0,n.width,n.height))}finally{n.width=0,n.height=0}}async function Me(i,t,e,n){let o={width:Math.max(1,i.videoWidth),height:Math.max(1,i.videoHeight)},s=ft(t,e,o,n);return{...await ye(i,s.crop,s.width,s.height,s.docRegion),docRegion:s.docRegion,source:"video",width:s.width,height:s.height}}async function ke(i,t,e,n,o){let s=ge();if(s===null)return null;let r=null;try{let c=new s(o.track),a=await pe(c.getPhotoCapabilities?.()??Promise.resolve({}),fe).catch(()=>({})),l=await pe(c.takePhoto(he(a)),fe);r=await createImageBitmap(l);let u={width:i.videoWidth,height:i.videoHeight};if(!de(r,u))return null;let d=$e(r,o.detectWidth),m=null;d!==null&&t!==null&&(m=await o.detect(d).catch(()=>null));let h=d??{width:r.width,height:r.height};m!==null&&!me(m,h,t,e)&&(m=null);let f=ft(m,h,r,n);return{...await ye(r,f.crop,f.width,f.height,f.docRegion),docRegion:f.docRegion,source:"photo",width:f.width,height:f.height}}catch{return null}finally{r?.close()}}var st=Object.freeze({width:3840,height:2160,lensSelection:!0,continuousFocus:!0,refocusBeforePhotoMs:350,zoomMax:2,zoomNoFocusInfo:1.5,zoomMinSourcePx:2160,fillDistanceM:Object.freeze({id1:.11,id3:.15}),focusMarginFrac:.2,stillSharpnessMin:.16,stillRefusalsMax:2,focusFarFillFrac:.45,noDocFarHintMs:1500,zoomFallbackMs:8e3}),S=(i,t,e)=>typeof i=="number"&&Number.isFinite(i)&&i>=t&&i<=e?i:void 0;function Ti(i){let t=st,e=i!==null&&typeof i=="object"?i:{},n=e.fillDistanceM!==null&&typeof e.fillDistanceM=="object"?e.fillDistanceM:{},o=(s,r)=>typeof s=="boolean"?s:r;return{width:S(e.width,640,7680)??t.width,height:S(e.height,480,4320)??t.height,lensSelection:o(e.lensSelection,t.lensSelection),continuousFocus:o(e.continuousFocus,t.continuousFocus),refocusBeforePhotoMs:S(e.refocusBeforePhotoMs,0,2e3)??t.refocusBeforePhotoMs,zoomMax:S(e.zoomMax,1,5)??t.zoomMax,zoomNoFocusInfo:S(e.zoomNoFocusInfo,1,5)??t.zoomNoFocusInfo,zoomMinSourcePx:S(e.zoomMinSourcePx,0,8e3)??t.zoomMinSourcePx,fillDistanceM:{id1:S(n.id1,.03,1)??t.fillDistanceM.id1,id3:S(n.id3,.03,1)??t.fillDistanceM.id3},focusMarginFrac:S(e.focusMarginFrac,0,2)??t.focusMarginFrac,stillSharpnessMin:S(e.stillSharpnessMin,0,10)??t.stillSharpnessMin,stillRefusalsMax:S(e.stillRefusalsMax,0,10)??t.stillRefusalsMax,focusFarFillFrac:S(e.focusFarFillFrac,0,1)??t.focusFarFillFrac,noDocFarHintMs:S(e.noDocFarHintMs,0,6e4)??t.noDocFarHintMs,zoomFallbackMs:S(e.zoomFallbackMs,0,12e4)??t.zoomFallbackMs}}function ti(i){let t=i.toLowerCase();return t===""?"unknown":/front|facing front|user|selfie|face ?time/.test(t)?"front":/ultra|0\.5x|wide angle/.test(t)?"ultra":/tele|zoom|periscope|[2-9]x/.test(t)?"tele":/depth|tof|infrared|\bir\b|truedepth|lidar|macro|monochrome|mono\b/.test(t)?"depth":/dual|triple/.test(t)?"virtual":/back|rear|environment|facing back|arrière|خلفية/.test(t)?"main":"unknown"}function ei(i){let t=/camera2?\s*(\d+)/i.exec(i);return t?Number(t[1]):Number.POSITIVE_INFINITY}function ii(i){let t={main:0,virtual:1,ultra:9,tele:9,depth:9,front:9,unknown:9};return i.filter(e=>(e.kind===void 0||e.kind==="videoinput")&&e.deviceId!=="").map((e,n)=>({id:e.deviceId,kind:ti(e.label),index:ei(e.label),i:n})).filter(e=>t[e.kind]<9).sort((e,n)=>t[e.kind]-t[n.kind]||e.index-n.index||e.i-n.i).map(e=>e.id)}var gt="sekyro.doc.camera";function ni(){try{let i=globalThis.localStorage?.getItem(gt);return typeof i=="string"&&i!==""?i:null}catch{return null}}function xe(i){try{i===null?globalThis.localStorage?.removeItem(gt):globalThis.localStorage?.setItem(gt,i)}catch{}}var rt=(i,t)=>Array.isArray(i?.focusMode)&&i.focusMode.includes(t);function yt(i,t,e){if(!rt(i,"single-shot"))return null;let n=o=>Math.min(1,Math.max(0,Number.isFinite(o)?o:.5));return{focusMode:"single-shot",pointsOfInterest:[{x:n(t),y:n(e)}]}}function _i(i,t,e,n){if(!Number.isFinite(i)||!Number.isFinite(t)||e.width<=0||e.height<=0||n.width<=0||n.height<=0)return null;let o=Math.max(e.width/n.width,e.height/n.height),s=n.width*o,r=n.height*o,c=(i-e.left+(s-e.width)/2)/s,a=(t-e.top+(r-e.height)/2)/r;return{x:Math.min(1,Math.max(0,c)),y:Math.min(1,Math.max(0,a))}}function we(i,t,e,n=st){let o=i?.zoom?.min,s=i?.zoom?.max;if(typeof s!="number"||s<=1)return 1;let r=e==="ID-3"?n.fillDistanceM.id3:n.fillDistanceM.id1,c=i?.focusDistance?.min,a;if(typeof c=="number"&&c>0&&c<1){if(a=c*(1+n.focusMarginFrac)/r,a<=1.05)return 1}else{if(Math.min(t.width,t.height)<n.zoomMinSourcePx)return 1;a=n.zoomNoFocusInfo}let l=Math.min(a,n.zoomMax,s);typeof o=="number"&&(l=Math.max(l,o));let u=i?.zoom?.step;return typeof u=="number"&&u>0&&(l=Math.round(l/u)*u),l>1.01?Number(l.toFixed(2)):1}function bt(i){try{return i.getVideoTracks?.()[0]}catch{return}}function De(i){if(i!==null)for(let t of i.getTracks())t.stop()}function oi(i){try{let t=bt(i)?.getCapabilities?.();return!Array.isArray(t?.focusMode)||t.focusMode.includes("continuous")}catch{return!0}}var si=3;async function ve(i){let t=s=>({audio:!1,video:{...s,width:{ideal:i.base.width},height:{ideal:i.base.height}}}),e=s=>i.getUserMedia(t({deviceId:{exact:s}})),n=()=>i.getUserMedia(t({facingMode:{ideal:"environment"}}));if(i.lensSelection){let s=ni();if(s!==null)try{return{stream:await e(s),lens:"stored"}}catch{xe(null)}}let o=await n();if(!i.lensSelection||i.enumerateDevices===void 0)return{stream:o,lens:"default"};try{let s=ii(await i.enumerateDevices()).slice(0,si);if(s.length===0)return{stream:o,lens:"default"};let r=null;for(let c of s){let a=o!==null?bt(o)?.getSettings?.().deviceId:void 0;if(o===null||a!==c){De(o),o=null;try{o=await e(c)}catch{continue}}if(r??(r=c),oi(o))return xe(c),{stream:o,lens:"selected"}}if(o!==null&&r!==null&&bt(o)?.getSettings?.().deviceId===r)return{stream:o,lens:"selected"};if(De(o),o=null,r!==null)try{return{stream:await e(r),lens:"selected"}}catch{}return{stream:await n(),lens:"default"}}catch{return{stream:o??await n(),lens:"default"}}}var Z=Object.freeze({brightness:0,glare:0,cardGlare:0,sharpness:0,fill:0,shape:0,content:0,offsetX:0,offsetY:0,edgeConfidence:0,box:null}),L=i=>Math.min(1,Math.max(0,i));function Te(i,t,e,n=.06){let o=Math.max(i.width/e,i.height),s=o*e,r=(i.width-s)/2,c=(i.height-o)/2,a=L((t.x-t.width*n-r)/s),l=L((t.y-t.height*n-c)/o),u=L((t.x+t.width*(1+n)-r)/s),d=L((t.y+t.height*(1+n)-c)/o);return{x:a,y:l,width:u-a,height:d-l}}function _e(i,t,e={}){let n=e.edgePeakFrac??0,{width:o,height:s,data:r}=i;if(o<=0||s<=0)return Z;let c=L(t.x),a=L(t.y),l={x:c,y:a,width:Math.max(0,L(t.x+t.width)-c),height:Math.max(0,L(t.y+t.height)-a)};if(l.width<=0||l.height<=0)return Z;let u=l.x*o,d=l.y*s,m=(l.x+l.width)*o,h=(l.y+l.height)*s,f=(m-u)*.15,g=(h-d)*.15,y=(p,b,R)=>Math.min(R,Math.max(b,p)),x=y(Math.floor(u-f),0,o-1),w=y(Math.floor(d-g),0,s-1),I=y(Math.ceil(m+f),x+1,o),v=y(Math.ceil(h+g),w+1,s),D=Math.max(1,Math.ceil(Math.max(I-x,v-w)/320)),M=Math.floor((I-x+D-1)/D),T=Math.floor((v-w+D-1)/D);if(M<3||T<3)return Z;let k=new Int32Array(M*T);for(let p=0;p<T;p++){let b=w+p*D;for(let R=0;R<M;R++){let F=(b*o+x+R*D)*4;k[p*M+R]=(r[F]??0)*77+(r[F+1]??0)*150+(r[F+2]??0)*29>>8}}let C=(p,b)=>(p-b-.5)/D,_=C(u,x),A=C(m,x),B=C(d,w),U=C(h,w),kt=(m-u)/D,xt=(h-d)/D,Dt=y(Math.ceil(_),0,M-1),Ie=y(Math.floor(A),Dt,M-1),wt=y(Math.ceil(B),0,T-1),Oe=y(Math.floor(U),wt,T-1),vt=0,St=0,W=0,Tt=0,_t=0,H=0;for(let p=wt;p<=Oe;p++)for(let b=Dt;b<=Ie;b++){let R=k[p*M+b];if(vt+=R,R>=248&&St++,W++,b>=1&&b<M-1&&p>=1&&p<T-1){let F=k[p*M+b-1]+k[p*M+b+1]+k[(p-1)*M+b]+k[(p+1)*M+b]-4*R;Tt+=F,_t+=F*F,H++}}let Pe=W>0?vt/W:0,Rt=W>0?St/W:0,Ft=H>0?Tt/H:0,Ge=H>0?Math.max(0,_t/H-Ft*Ft):0,K=new Float64Array(M),V=new Float64Array(T);for(let p=0;p<T;p++)for(let b=1;b<M-1;b++)K[b]=K[b]+Math.abs(k[p*M+b+1]-k[p*M+b-1]);for(let p=1;p<T-1;p++)for(let b=0;b<M;b++)V[p]=V[p]+Math.abs(k[(p+1)*M+b]-k[(p-1)*M+b]);let O=at(K,!0,_,n),P=at(K,!1,A,n),G=at(V,!0,B,n),z=at(V,!1,U,n),Ct=(P.position-O.position)/kt,At=(z.position-G.position)/xt,ze=At>0?Ct/At:0,Ne=((O.position+P.position)/2-(_+A)/2)/kt,Qe=((G.position+z.position)/2-(B+U)/2)/xt,Et=Se(K),Lt=Se(V),Be=Et<=0||Lt<=0?0:Math.min(Math.min(O.value,P.value)/Et,Math.min(G.value,z.value)/Lt),$=(p,b)=>b+(p+.5)*D,It=Rt,Ot=0;{let p=(P.position-O.position)*.06,b=(z.position-G.position)*.06,R=y(Math.ceil(O.position+p),0,M-1),F=y(Math.floor(P.position-p),0,M-1),Ue=y(Math.ceil(G.position+b),0,T-1),Pt=y(Math.floor(z.position-b),0,T-1),Gt=0,tt=0,zt=0;for(let N=Ue;N<=Pt;N++)for(let Q=R;Q<=F;Q++){tt++;let X=k[N*M+Q];X>=248&&Gt++;let We=Q+2<=F?k[N*M+Q+2]:X,He=N+2<=Pt?k[(N+2)*M+Q]:X;(Math.abs(We-X)>=24||Math.abs(He-X)>=24)&&zt++}tt>=16&&(It=Gt/tt,Ot=zt/tt)}return{brightness:Pe,glare:Rt,cardGlare:It,sharpness:Ge,fill:Ct,shape:ze,content:Ot,offsetX:Ne,offsetY:Qe,edgeConfidence:Be,box:{left:$(O.position,x),right:$(P.position,x),top:$(G.position,w),bottom:$(z.position,w)}}}function at(i,t,e,n){let o=i.length,s=Math.max(1,Math.floor(o*.45)),r=t?1:Math.max(1,o-1-s),c=t?Math.min(o-2,s):o-2,a=r;for(let h=r;h<=c;h++)i[h]>i[a]&&(a=h);if(n>0&&n<1){let h=i[a]*n,f=a,g=Math.abs(a-e);for(let y=r;y<=c;y++){let x=i[y];if(x<h||x<(i[y-1]??0)||x<(i[y+1]??0))continue;let w=Math.abs(y-e);w<g&&(f=y,g=w)}a=f}let l=a>0?i[a-1]:0,u=i[a],d=a<o-1?i[a+1]:0,m=l+u+d;return{position:m>0?a+(d-l)/m:a,value:u}}function Se(i){if(i.length<3)return 0;let t=0;for(let e=1;e<i.length-1;e++)t+=i[e];return t/(i.length-2)}function Re(i){let t=i.box;return t===null||t.right-t.left<4||t.bottom-t.top<4?null:{topLeft:{x:t.left,y:t.top},topRight:{x:t.right,y:t.top},bottomRight:{x:t.right,y:t.bottom},bottomLeft:{x:t.left,y:t.bottom}}}var J=Object.freeze({fillMin:.82,fillMax:1.06,offsetMax:.06,glareMax:.025,sharpnessMin:180,edgeConfidenceMin:1.6,darkBrightness:70,lockMs:450,steadyMs:900,steadyFillMin:.45,steadyFillMax:1.3,steadyFillDelta:.06,steadyOffsetDelta:.04,steadyRefMs:100,edgePeakFrac:.4,shapeTolerance:.2,contentMin:.1});function Fi(i){let t=i!==null&&typeof i=="object"?i:{},e={...J};for(let n of Object.keys(J)){let o=t[n];typeof o=="number"&&Number.isFinite(o)&&o>=0&&o<=1e6&&(e[n]=o)}return e}var ct=class{constructor(t=J){this.t=t;this.goodSince=null;this.steadySince=null;this.last=null}reset(){this.goodSince=null,this.steadySince=null,this.last=null}tick(t,e){let n=this.t,o=n.shapeTolerance<=0||Math.abs(t.shape-1)<=n.shapeTolerance,s=t.edgeConfidence>=n.edgeConfidenceMin&&o&&t.content>=n.contentMin,r=t.fill>=n.fillMin&&t.fill<=n.fillMax,c=Math.abs(t.offsetX)<=n.offsetMax&&Math.abs(t.offsetY)<=n.offsetMax,a=t.cardGlare<=n.glareMax,l=t.sharpness>=n.sharpnessMin,u=this.last;this.last={fill:t.fill,offsetX:t.offsetX,offsetY:t.offsetY,at:e};let d=u!==null&&n.steadyRefMs>0?Math.min(3,Math.max(1,(e-u.at)/n.steadyRefMs)):1,m=s&&a&&l&&t.fill>=n.steadyFillMin&&t.fill<=n.steadyFillMax&&u!==null&&Math.abs(t.fill-u.fill)<=n.steadyFillDelta*d&&Math.abs(t.offsetX-u.offsetX)<=n.steadyOffsetDelta*d&&Math.abs(t.offsetY-u.offsetY)<=n.steadyOffsetDelta*d,h=s&&r&&c&&a&&l,f;if(s?a?t.fill<n.fillMin?f="too_small":t.fill>n.fillMax?f="too_big":l?c?f="locking":f="off_center":f="blurry":f="glare":f="no_card",h){if(m&&(this.steadySince??(this.steadySince=e)),this.goodSince??(this.goodSince=e),e-this.goodSince>=n.lockMs)return{detected:s,ready:!0,via:"good",blocker:"locking"};let g=this.steadySince!==null&&e-this.steadySince>=n.steadyMs;return{detected:s,ready:g,via:g?"steady":null,blocker:"locking"}}if(this.goodSince=null,m){this.steadySince??(this.steadySince=e);let g=e-this.steadySince>=n.steadyMs;return{detected:s,ready:g,via:g?"steady":null,blocker:g?"locking":"steadying"}}return this.steadySince=null,{detected:s,ready:!1,via:null,blocker:f}}};var q=null;async function ri(i){return q===null&&(q=(await import("./detector-scanic-YCDNLCGV.js")).detectQuad),q(i)}async function ai(i){let t=Jt(i);return t===null?null:{topLeft:{x:t.x,y:t.y},topRight:{x:t.x+t.width,y:t.y},bottomRight:{x:t.x+t.width,y:t.y+t.height},bottomLeft:{x:t.x,y:t.y+t.height}}}function Vi(){q===null&&import("./detector-scanic-YCDNLCGV.js").then(i=>{q=i.detectQuad}).catch(()=>{})}var Fe=4e3,ci=2,Ce=3,li=Object.freeze({LOW:3,MID:5,HIGH:6}),Mt=Object.freeze({manualShutterMs:6e3,detectedNoLockMs:1950});function Xi(i){let t=i!==null&&typeof i=="object"?i:{},e=(n,o,s)=>typeof n=="number"&&Number.isFinite(n)&&n>=o&&n<=s?n:void 0;return{manualShutterMs:e(t.manualShutterMs,1e3,6e4)??Mt.manualShutterMs,detectedNoLockMs:e(t.steadyMs,300,3e4)!==void 0?t.steadyMs+(e(t.lockMs,0,1e4)??450):Mt.detectedNoLockMs}}var Ae=class i{constructor(t){this.torchOn=!1;this.stillRefusals=0;this.zoom=1;this.positioningSince=null;this.detectedSince=null;this.lastSeenAt=null;this.lastGuideQuad=null;this.lastOcrReady=null;this.shutterOffered=!1;this.stats=i.freshStats();this.handlers=new Map;this.stream=null;this.timer=null;this.state="idle";this.lastGuidance=null;this.attempt=0;this.capturing=!1;this.feedback=new nt;this.lastFeedbackKey=null;this.lastQuad=null;this.lastDetect=null;this.frameWatch=null;this.reopened=!1;this.lit=!1;this.blackTicks=0;this.offEnded=null;this.opts=t,this.gate=new ee(t.format??"ID-1",t.thresholds);let e=t.deviceClass??Kt(Ht());this.deviceClass=e,this.camera=t.camera??st,this.shutterTuning=t.shutter??Mt,this.guideTuning=t.guideLock??J,this.guideLock=new ct(this.guideTuning),this.cadenceMs=1e3/li[e]}on(t,e){let n=this.handlers.get(t);return n||(n=new Set,this.handlers.set(t,n)),n.add(e),()=>n?.delete(e)}emit(t,e){for(let n of[...this.handlers.get(t)??[]])n(e)}async start(){let t=this.state==="error"?this.resumePlayback():null,e=++this.attempt;if(this.clearFrameWatch(),this.gate.reset(),this.resetSide(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.lit=!1,this.blackTicks=0,t!==null&&await t&&e===this.attempt){this.setState("positioning"),this.scheduleTick(e),this.watchFrames(e);return}if(e===this.attempt){this.releaseStream(),Wt(),this.setState("preflight");try{let n=this.opts.getUserMedia??(r=>navigator.mediaDevices.getUserMedia(r));this.setState("acquiring");let o=this.opts.enumerateDevices??(this.opts.getUserMedia===void 0&&typeof navigator<"u"&&navigator.mediaDevices?.enumerateDevices?()=>navigator.mediaDevices.enumerateDevices():void 0),s=await ve({getUserMedia:n,...o!==void 0?{enumerateDevices:o}:{},lensSelection:this.camera.lensSelection,base:ae});if(e!==this.attempt){for(let r of s.stream.getTracks())r.stop();return}if(this.stream=s.stream,Bt(this.stream),Ut(this.stream),this.watchEnded(e),this.opts.upgradeResolution!==!1&&await this.upgradeResolution(),e!==this.attempt||(await this.applyFocusAndZoom(),e!==this.attempt)||(this.opts.video.srcObject=this.stream,await this.opts.video.play().catch(()=>{}),e!==this.attempt))return;this.setState("positioning"),this.scheduleTick(e),this.watchFrames(e)}catch(n){if(e!==this.attempt)return;let o=Qt(n),s=Nt(n);this.setState("error"),this.emit("error",{kind:o,retryable:!0,detail:s===void 0?{phase:"acquiring"}:{phase:"acquiring",name:s}})}}}resumePlayback(){let t=this.opts.video,e=this.videoTrack();if(this.stream===null||e===null||e.readyState!=="live"||t.srcObject!==this.stream)return null;try{return Promise.resolve(t.play()).then(()=>this.framesNow(),()=>!1)}catch{return null}}framesNow(){let t=this.opts.video;return this.opts.hasFrames!==void 0?this.opts.hasFrames(t):!t.paused&&t.readyState>=2&&t.videoWidth>0}watchFrames(t){let e=this.opts.firstFrameMs??Fe;e<=0||(this.clearFrameWatch(),this.frameWatch=setTimeout(()=>{if(this.frameWatch=null,!(t!==this.attempt||this.state!=="positioning")){if(this.framesNow()&&this.blackTicks<Ce){this.reopened=!1;return}this.cameraDead(t)}},e))}clearFrameWatch(){this.frameWatch!==null&&clearTimeout(this.frameWatch),this.frameWatch=null}watchEnded(t){this.offEnded?.(),this.offEnded=null;let e=this.videoTrack();if(e===null||typeof e.addEventListener!="function")return;let n=()=>{t===this.attempt&&(this.state==="positioning"||this.state==="acquiring")&&this.cameraDead(t)};e.addEventListener("ended",n),this.offEnded=()=>e.removeEventListener?.("ended",n)}cameraDead(t){if(t!==this.attempt)return;let e=this.videoTrack(),n=e!==null&&e.readyState==="live"&&!e.muted&&this.opts.video.paused&&!this.framesNow();if(!n&&!this.reopened){this.reopened=!0,this.start();return}this.attempt+=1,this.timer!==null&&(this.opts.clearTimer??clearTimeout)(this.timer),this.timer=null,this.clearFrameWatch(),n||this.releaseStream(),this.reopened=!1,this.setState("error"),this.emit("error",{kind:"generic",retryable:!0,detail:{phase:"acquiring"}})}releaseStream(){if(this.offEnded?.(),this.offEnded=null,this.stream)for(let t of this.stream.getTracks())t.stop();this.stream=null,this.opts.video.srcObject!==null&&this.opts.video.srcObject!==void 0&&(this.opts.video.srcObject=null)}rearm(t){t!==void 0&&(this.opts.side=t),this.gate.reset(),this.resetSide(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.stillRefusals=0,this.state==="captured"&&(this.setState("positioning"),this.scheduleTick(this.attempt))}async captureNow(){if(this.state!=="positioning"||this.capturing)return;let t=this.opts.video,e=this.lastDetect?.width??Math.max(1,t.videoWidth),n=this.lastDetect?.height??Math.max(1,t.videoHeight),o=this.lastQuad??this.lastGuideQuad??{topLeft:{x:0,y:0},topRight:{x:e,y:0},bottomRight:{x:e,y:n},bottomLeft:{x:0,y:n}},s=(this.opts.now??(()=>performance.now()))(),r=this.feedback.force("processing",s);this.lastFeedbackKey=r.key,this.emit("feedback",r),await this.fire(this.attempt,this.lastOcrReady!==null?this.lastOcrReady.quad:o,{width:e,height:n,tickSharpness:this.lastDetect?.tickSharpness??0},this.lastOcrReady?.via??"manual")}captureReport(){let t=this.stats;return{...this.opts.side!==void 0?{side:this.opts.side}:{},format:this.opts.format??"ID-1",deviceClass:this.deviceClass,video:{width:this.opts.video.videoWidth||0,height:this.opts.video.videoHeight||0},zoom:this.zoom,...t.zoomFallbackAtMs!==void 0?{zoomFallbackAtMs:t.zoomFallbackAtMs}:{},...t.msToCapture!==void 0?{msToCapture:t.msToCapture}:{},...t.via!==void 0?{via:t.via}:{},...t.shutterAtMs!==void 0?{shutterAtMs:t.shutterAtMs}:{},...t.shutterReason!==void 0?{shutterReason:t.shutterReason}:{},ticks:t.ticks,quadFraming:{...t.quadFraming},qualityBlockers:{...t.qualityBlockers},guideBlockers:{...t.guideBlockers},stillRefusals:t.stillRefusals,...this.ocrReport()}}ocrReport(){let t=this.opts.ocr;if(t===void 0)return{};let e=(this.opts.format??"ID-1")==="ID-3"||this.opts.side==="single"?"single":this.opts.side==="verso"?"verso":"recto",n=t.report(e,this.stats.via,(this.opts.now??(()=>performance.now()))());return n===null?{}:{ocr:n}}static freshStats(){return{ticks:0,quadFraming:{},qualityBlockers:{},guideBlockers:{},stillRefusals:0}}setGuide(t){t===void 0?delete this.opts.guide:this.opts.guide=t,this.guideLock.reset()}guideRegion(t){let e=t.width/Math.max(1,t.height),n=this.opts.guide;if(n!==void 0&&n.viewAspect>0){let c={width:n.viewAspect,height:1},a={x:n.rect.x*n.viewAspect,y:n.rect.y,width:n.rect.width*n.viewAspect,height:n.rect.height};return Te(c,a,e,0)}let o=Xt(this.opts.format??"ID-1").center,s=.86,r=s*e/o;return r>.84&&(r=.84,s=r*o/e),{x:(1-s)/2,y:(1-r)/2,width:s,height:r}}resetSide(){this.positioningSince=null,this.detectedSince=null,this.lastSeenAt=null,this.guideLock.reset(),this.lastGuideQuad=null,this.lastOcrReady=null,this.opts.ocr?.reset(),this.stats=i.freshStats(),this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1}))}withdrawShutter(){this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1}))}zoomFallback(t){let e=this.videoTrack();if(e===null||this.zoom<=1)return;let n=this.focusCaps(),o=typeof n?.zoom?.min=="number"?Math.max(n.zoom.min,1):1;this.zoom=o,this.stats.zoomFallbackAtMs=Math.round(t-(this.positioningSince??t)),this.guideLock.reset(),this.gate.reset(),e.applyConstraints({advanced:[{zoom:o}]}).catch(()=>{})}offerShutter(t,e){this.shutterOffered||(this.shutterOffered=!0,this.stats.shutterAtMs=Math.round(e-(this.positioningSince??e)),this.stats.shutterReason=t,this.emit("shutter",{available:!0,reason:t}))}torchAvailable(){try{return this.stream?.getVideoTracks?.()[0]?.getCapabilities?.()?.torch===!0}catch{return!1}}async setTorch(t){this.torchOn=t;try{await this.stream?.getVideoTracks?.()[0]?.applyConstraints({advanced:[{torch:t}]})}catch{}}destroy(){if(this.attempt+=1,this.timer!==null&&(this.opts.clearTimer??clearTimeout)(this.timer),this.timer=null,this.clearFrameWatch(),this.offEnded?.(),this.offEnded=null,this.stream)for(let t of this.stream.getTracks())t.stop();this.stream=null,this.opts.video.srcObject=null}async upgradeResolution(){try{let t=this.stream?.getVideoTracks?.()[0];if(t===void 0)return;let e=t.getSettings?.()??{},n=ue(t.getCapabilities?.(),{width:e.width??0,height:e.height??0},this.deviceClass,{width:this.camera.width,height:this.camera.height});n!==null&&await t.applyConstraints(n)}catch{}}focusCaps(){try{return this.videoTrack()?.getCapabilities?.()??null}catch{return null}}async applyFocusAndZoom(){let t=this.videoTrack();if(t===null)return;let e=this.focusCaps();this.camera.continuousFocus&&rt(e,"continuous")&&await t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{});let n={width:0,height:0};try{let s=t.getSettings?.()??{};n={width:s.width??0,height:s.height??0}}catch{}let o=we(e,n,this.opts.format??"ID-1",this.camera);if(o>1)try{await t.applyConstraints({advanced:[{zoom:o}]}),this.zoom=o}catch{this.zoom=1}}async focusAt(t,e){let n=this.videoTrack(),o=yt(this.focusCaps(),t,e);if(!(n===null||o===null))try{await n.applyConstraints({advanced:[o]}),(this.opts.setTimer??setTimeout)(()=>{this.restoreContinuous()},1500)}catch{}}async restoreContinuous(){let t=this.videoTrack();t===null||!this.camera.continuousFocus||!rt(this.focusCaps(),"continuous")||await t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{})}async refocusOn(t,e){let n=this.camera.refocusBeforePhotoMs,o=this.videoTrack();if(n<=0||o===null||e.width<=0||e.height<=0)return;let s=E(t),r=yt(this.focusCaps(),(s.x+s.width/2)/e.width,(s.y+s.height/2)/e.height);if(r!==null)try{await o.applyConstraints({advanced:[r]});let c=this.opts.setTimer??setTimeout;await new Promise(a=>{c(()=>a(),n)})}catch{}}videoTrack(){try{return this.stream?.getVideoTracks?.()[0]??null}catch{return null}}async takeStill(t,e,n){if(this.opts.captureStill!==void 0)return this.opts.captureStill(this.opts.video,t,e);let o=this.opts.format??"ID-1",s=this.videoTrack();if(n&&this.opts.photoCapture!==!1&&this.deviceClass!=="LOW"&&!this.torchOn&&s!==null&&be(s)){await this.refocusOn(t,e);let r=await ke(this.opts.video,t,e,o,{track:s,detect:this.detector(),detectWidth:et});if(this.restoreContinuous(),r!==null)return r}return Me(this.opts.video,t,e,o)}detector(){return this.opts.detect??((this.opts.format??"ID-1")==="ID-3"?ai:ri)}setState(t){this.state=t,this.emit("statechange",{state:t})}scheduleTick(t){let e=this.opts.setTimer??setTimeout;this.timer=e(()=>{this.tick(t)},this.cadenceMs)}async tick(t){if(t!==this.attempt||this.state!=="positioning"||this.capturing)return;let e=this.opts.now??(()=>performance.now()),n=this.opts.grabDetectFrame??Le,o=this.detector(),s=n(this.opts.video,et);if(s===null){this.scheduleTick(t);return}if(!this.lit){if(ht(s)>ci)this.lit=!0,this.blackTicks=0;else if(++this.blackTicks>=Ce&&this.frameWatch===null&&(this.opts.firstFrameMs??Fe)>0){this.cameraDead(t);return}}let r=null;try{r=await o(s)}catch{r=null}if(t!==this.attempt)return;let c=r!==null?lt(s,r):s,a=e(),l={sharpness:j(c),exposure:Vt(c),meanLuma:ht(c),specularFraction:oe(c)},u=se({format:this.opts.format??"ID-1",quad:r,frameWidth:s.width,frameHeight:s.height,measures:l,...this.opts.thresholds!==void 0?{thresholds:this.opts.thresholds}:{}}),d=this.gate.tick({timestampMs:a,quad:r,quality:l,frameWidth:s.width,frameHeight:s.height}),h=(this.opts.format??"ID-1")!=="ID-3"?_e(s,this.guideRegion(s),{edgePeakFrac:this.guideTuning.edgePeakFrac}):Z,f=this.guideLock.tick(h,a);this.lastGuideQuad=f.detected?Re(h):null;let g=this.capturing?null:this.ocrTick(s,r,h,f.detected,u,a);this.positioningSince??(this.positioningSince=a);let y=this.stats;if(y.ticks+=1,y.quadFraming[u.framing]=(y.quadFraming[u.framing]??0)+1,u.framing==="ok"&&!d.ready){let _=u.lighting!=="ok"?u.lighting:u.glare!=="ok"?"glare":u.blur!=="ok"?"blurry":"steadying";y.qualityBlockers[_]=(y.qualityBlockers[_]??0)+1}y.guideBlockers[f.blocker]=(y.guideBlockers[f.blocker]??0)+1,r!==null||f.detected?(this.detectedSince??(this.detectedSince=a),this.lastSeenAt=a):this.detectedSince=null,this.lastSeenAt!==null&&a-this.lastSeenAt<=gi?a-this.positioningSince>=this.shutterTuning.manualShutterMs?this.offerShutter("timeout",a):g?.suspendQuality!==!0&&this.detectedSince!==null&&a-this.detectedSince>=this.shutterTuning.detectedNoLockMs&&this.offerShutter("detected_no_lock",a):this.withdrawShutter();let I=a-(this.lastSeenAt??this.positioningSince);this.zoom>1&&this.camera.zoomFallbackMs>0&&I>=this.camera.zoomFallbackMs&&this.zoomFallback(a),this.emit("checks",{engine:"docv1",p:d.p,plausible:d.plausible,stableTicks:d.stableTicks,quad:d.quad,frameWidth:s.width,frameHeight:s.height,analysis:u,ready:g?.suspendQuality!==!0&&(d.ready&&r!==null||f.ready&&this.lastGuideQuad!==null)||this.lastOcrReady!==null,guide:{detected:f.detected,blocker:f.blocker,fill:h.fill,shape:h.shape,content:h.content,offsetX:h.offsetX,offsetY:h.offsetY},...g!==null&&g.mode!=="off"?{ocr:{mode:g.mode,...g.mrz?{mrz:g.mrz}:{},...g.lock?{lock:g.lock}:{}}}:g?.mrz?{ocr:{mode:g.mode,mrz:g.mrz}}:{}}),this.lastQuad=d.plausible?r:null,this.lastDetect={width:s.width,height:s.height,tickSharpness:l.sharpness};let v=ie(u);u.framing!=="ok"&&f.detected&&(v=pi(f.blocker,h.brightness<this.guideTuning.darkBrightness)),v==="blurry"&&r!==null&&hi(r,s,this.opts.format??"ID-1")>=this.camera.focusFarFillFrac&&(v="focus_far"),v==="sensing"&&this.zoom>1&&this.camera.noDocFarHintMs>0&&I>=this.camera.noDocFarHintMs&&(v="focus_far");let D=this.feedback.tick(v,a);if(D.key!==this.lastFeedbackKey&&(this.lastFeedbackKey=D.key,this.emit("feedback",D)),d.guidanceKey!==this.lastGuidance&&(this.lastGuidance=d.guidanceKey,this.emit("guidance",{key:d.guidanceKey})),this.capturing)return;let M=g?.suspendQuality!==!0,T=M&&d.ready&&r!==null,k=M&&f.ready&&this.lastGuideQuad!==null,C=this.lastOcrReady;if(C!==null&&this.opts.autoCapture!==!1){let _=this.feedback.force("processing",a);this.lastFeedbackKey=_.key,this.emit("feedback",_);let A=j(lt(s,C.quad));await this.fire(t,C.quad,{width:s.width,height:s.height,tickSharpness:A},C.via);return}if((T||k)&&this.opts.autoCapture!==!1){let _=this.feedback.force("processing",a);this.lastFeedbackKey=_.key,this.emit("feedback",_);let A=k?this.lastGuideQuad:r,B=k?f.via==="steady"?"guide_steady":"guide_good":"quad",U=k?j(lt(s,A)):l.sharpness;await this.fire(t,A,{width:s.width,height:s.height,tickSharpness:U},B);return}this.scheduleTick(t)}async fire(t,e,n,o){this.capturing=!0;let s=this.opts.grabDetectFrame??Le,r=this.opts.setTimer??setTimeout,c={width:n.width,height:n.height};try{let a={still:await this.takeStill(e,c,!0),sharpness:n.tickSharpness};if(t!==this.attempt)return;let l=a.still.source==="photo"?0:di;for(let m=0;m<l;m++){if(await new Promise(g=>{r(()=>g(),mi)}),t!==this.attempt)return;let h=s(this.opts.video,et);if(h===null)continue;let f=j(lt(h,e));if(f>a.sharpness*fi){let g=await this.takeStill(e,c,!1);if(t!==this.attempt)return;a={still:g,sharpness:f}}}if(t!==this.attempt)return;let u=a.still.sharpness;if(this.opts.autoCapture!==!1&&o!=="manual"&&typeof u=="number"&&u>=0&&u<this.camera.stillSharpnessMin&&this.stillRefusals<this.camera.stillRefusalsMax){this.stillRefusals+=1,this.stats.stillRefusals+=1,this.guideLock.reset(),this.lastOcrReady=null,(o==="text_lock"||o==="live_mrz")&&this.opts.ocr?.rearmFace();let m=(this.opts.now??(()=>performance.now()))(),h=this.feedback.force("focus_far",m);this.lastFeedbackKey=h.key,this.emit("feedback",h),this.capturing=!1,this.gate.reset(),this.scheduleTick(t);return}this.stillRefusals=0;let d=(this.opts.now??(()=>performance.now()))();this.stats.via=o,this.stats.msToCapture=Math.round(d-(this.positioningSince??d)),this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1})),this.setState("captured"),this.emit("artifacts",{keyframe:a.still.blob,previewDataUrl:a.still.previewDataUrl,...this.opts.side!==void 0?{side:this.opts.side}:{},...a.still.docRegion!==void 0?{docRegion:a.still.docRegion}:{},...(()=>{let m=o==="live_mrz"?this.opts.ocr?.liveCapture():null;return m?{liveMrz:m}:{}})()})}catch{if(t!==this.attempt)return;this.capturing=!1,this.gate.reset(),this.guideLock.reset(),this.lastOcrReady=null,(o==="text_lock"||o==="live_mrz")&&this.opts.ocr?.rearmFace(),this.scheduleTick(t)}}ocrTick(t,e,n,o,s,r){let c=this.opts.ocr,a=this.opts.video;if(c===void 0||!c.hasEngine)return this.lastOcrReady=null,null;let l=a.videoWidth,u=a.videoHeight;if(l<=0||u<=0||t.width<=0||t.height<=0)return null;let m=(this.opts.format??"ID-1")==="ID-3",h=this.guideRegion(t),f={x:h.x*l,y:h.y*u,w:h.width*l,h:h.height*u},g=l/t.width,y=u/t.height,x;m&&e!==null?x=ui(E(e),g,y,l,u):x=qt(f,c.bandTop,u);let w=m?s.glare==="ok":n.cardGlare<=this.guideTuning.glareMax,I=m?s.blur==="ok":n.sharpness>=this.guideTuning.sharpnessMin,v=c.tick({atMs:r,video:a,mrzFace:m||this.opts.side==="verso"||this.opts.side==="single",present:m||e!==null||o,card:f,band:x,portrait:u>l,glareOk:w,sharpOk:I});if(v.ready&&v.via!==void 0){let D=m?e??Ee(h,t):this.lastGuideQuad??Ee(h,t);this.lastOcrReady={quad:D,via:v.via}}else this.lastOcrReady=null;return v}};function ui(i,t,e,n,o){let s=Math.min(n,i.width*1.06*t),r=Math.min(o,Math.max(i.height*1.6*e,s/5)),c=(i.y+i.height/2)*e,a=Math.max(0,Math.min(n-s,(i.x-i.width*.03)*t)),l=Math.max(0,Math.min(o-r,c-r/2));return{x:a,y:l,w:s,h:r}}function Ee(i,t){let e=i.x*t.width,n=i.y*t.height,o=(i.x+i.width)*t.width,s=(i.y+i.height)*t.height;return{topLeft:{x:e,y:n},topRight:{x:o,y:n},bottomRight:{x:o,y:s},bottomLeft:{x:e,y:s}}}function hi(i,t,e){let n=E(i);return t.width<=0||t.height<=0?0:e==="ID-3"?n.width/t.width:n.width*n.height/(t.width*t.height)}var di=2,mi=260,fi=1.08;function Le(i,t){let e=i.videoWidth,n=i.videoHeight;if(e===0||n===0)return null;let o=Math.min(1,t/e),s=Math.round(e*o),r=Math.round(n*o),c=document.createElement("canvas");c.width=s,c.height=r;let a=c.getContext("2d",{willReadFrequently:!0});return a===null?null:(e/Math.max(1,s)>4&&(a.imageSmoothingQuality="high"),a.drawImage(i,0,0,s,r),a.getImageData(0,0,s,r))}function lt(i,t){let e=[t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x],n=[t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y],o=Math.max(0,Math.floor(Math.min(...e))),s=Math.max(0,Math.floor(Math.min(...n))),r=Math.min(i.width,Math.ceil(Math.max(...e))),c=Math.min(i.height,Math.ceil(Math.max(...n))),a=Math.max(1,r-o),l=Math.max(1,c-s),u=new Uint8ClampedArray(a*l*4);for(let d=0;d<l;d++){let m=((s+d)*i.width+o)*4;u.set(i.data.subarray(m,m+a*4),d*a*4)}return{data:u,width:a,height:l,colorSpace:i.colorSpace}}function pi(i,t){return i==="glare"?"glare":i==="too_small"?"too_far":i==="too_big"?"too_close":t?"too_dark":i==="blurry"?"blurry":i==="off_center"?"edge_clipped":i==="no_card"?"sensing":"hold_still"}var gi=1200;export{it as a,ie as b,nt as c,Ke as d,oe as e,Ve as f,se as g,st as h,Ti as i,ti as j,ii as k,gt as l,ni as m,xe as n,rt as o,yt as p,_i as q,we as r,oi as s,si as t,ve as u,Z as v,Te as w,_e as x,Re as y,J as z,Fi as A,ct as B,Vi as C,Fe as D,ci as E,Ce as F,li as G,Mt as H,Xi as I,Ae as J,ui as K,di as L,mi as M};
|
package/dist/chunk-SNACCYTL.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var v=["session.completed","session.failed","session.review_pending","session.expired","session.cancelled"],u=new Set([0,1,2,3]),a="sekyro-verify",E="width=480,height=720,noopener=false",f=new Set(v);function y(e){if(e===null||typeof e!="object")return!1;let n=e;return n.source==="sekyro"&&n.version===1&&typeof n.sessionId=="string"&&typeof n.event=="string"&&f.has(n.event)}function S(e){let n=new URL(e.hostedUrl).origin,t=window.open(e.hostedUrl,a,E);if(!t)return{error:"popup_blocked"};let r=o=>{if(o.source!==t||o.origin!==n||!y(o.data))return;let{source:p,version:d,event:c,sessionId:l,level:s}=o.data,i={source:p,version:d,event:c,sessionId:l};u.has(s)&&(i.level=s),e.onEvent(i)};return window.addEventListener("message",r),{close(){window.removeEventListener("message",r),t.close()}}}function k(e,n){return n.mode==="redirect"?(window.location.assign(e),{close(){}}):S({hostedUrl:e,onEvent:n.onEvent??(()=>{})})}export{v as a,S as b,k as c};
|
package/dist/chunk-TQB3URP2.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var u=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo"],l=[/^(front|back|rear)( [a-z ]+)? camera$/i,/^camera2? ?\d+, facing (front|back|external)/i,/facetime/i,/\b(integrated|built-in|builtin) (web)?cam(era)?\b/i,/\b(hd )?web ?cam\b/i,/\([0-9a-f]{4}:[0-9a-f]{4}\)\s*$/i];function c(n){let e=(n??"").trim().toLowerCase();return e.length===0?"unknown":u.some(t=>e.includes(t))?"known_virtual":l.some(t=>t.test(e))?"platform":"unknown"}var d=1e3;function m(n,e){return new Promise(t=>{let a=setTimeout(()=>t(void 0),e),r=s=>{clearTimeout(a),t(s)};try{n().then(r,()=>r(void 0))}catch{r(void 0)}})}async function f(n){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(JSON.stringify(n)));return Array.from(new Uint8Array(e).subarray(0,8),t=>t.toString(16).padStart(2,"0")).join("")}var i=n=>Array.isArray(n)?[...n].sort():null,o=n=>{let e=n;return e==null?null:[e.min??null,e.max??null]};function p(n){try{return n.getSettings?.().facingMode==="environment"}catch{return!1}}async function g(n){try{if(n.readyState==="ended"||p(n))return;let e={};try{e=n.getCapabilities?.()??{}}catch{}let t=await m(()=>navigator.mediaDevices.enumerateDevices(),d);return await f([o(e.width),o(e.height),o(e.frameRate),i(e.facingMode),i(e.focusMode),i(e.exposureMode),c(n.label),t?.filter(a=>a.kind==="videoinput").length??null])}catch{return}}async function v(n,e){let t=await g(n);t&&e.noteCamera(t)}export{m as a,f as b,g as c,v as d};
|
package/dist/chunk-VIAT4DEA.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var m="0.1.0-rc.21";var T=/FBAN|FBAV|FB_IAB|FBIOS|MessengerForiOS|Instagram|WhatsApp|musical_ly|BytedanceWebview|TikTok|Snapchat|\bLine\/|LinkedInApp|Pinterest|MicroMessenger|; wv\)/i;function p(t){let e=t??(typeof navigator>"u"?"":String(navigator.userAgent??""));return T.test(e)}var y="sekyro.did",I=1e4,v=()=>globalThis.process?.versions?.node,h;function b(){let t=globalThis.crypto;try{if(typeof t?.randomUUID=="function")return t.randomUUID()}catch{}try{if(typeof t?.getRandomValues=="function"){let e=t.getRandomValues(new Uint8Array(16));return Array.from(e,r=>r.toString(16).padStart(2,"0")).join("")}}catch{}}function w(){try{let t=localStorage.getItem(y);if(t)return t;let e=b();return e!==void 0&&localStorage.setItem(y,e),e}catch{return h??(h=b()),h}}async function P(){let t=globalThis.crypto?.subtle;if(!t)return"";let e=navigator,r=JSON.stringify([e.userAgent,e.platform,e.hardwareConcurrency??null,e.deviceMemory??null,e.maxTouchPoints??0,screen.width,screen.height,screen.colorDepth,globalThis.devicePixelRatio??1,Intl.DateTimeFormat().resolvedOptions().timeZone,e.languages?.join(",")??e.language]),i=await t.digest("SHA-256",new TextEncoder().encode(r));return Array.from(new Uint8Array(i),o=>o.toString(16).padStart(2,"0")).join("").slice(0,32)}function k(t){let e=new TextEncoder().encode(t),r="";for(let i of e)r+=String.fromCharCode(i);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function x(t){let e,r,i,o,a,l,u=()=>l?.readyState==="live",_=()=>{a!==void 0||!globalThis.crypto?.subtle||v()||u()||(a=Promise.race([import("./print-AYSCRSZB.js"),new Promise(n=>setTimeout(n,I))]).then(n=>n?.computePrint(u)).then(n=>{n==="busy"?a=void 0:o=n}).catch(()=>{}))};return{timezone(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone?.slice(0,64)||void 0}catch{return}},noteCameraLabel(n){n&&(e=n.slice(0,128))},noteCamera(n){r=n},noteCameraTrack(n){l=n},async deviceHeader(){try{i??(i=P().catch(()=>""));let n=[];navigator.webdriver&&n.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&n.push("headless");let g=await i,f=w(),S={v:1,platform:"web",sdk:t.sdk.slice(0,64),ids:[...f?[{kind:"web_local",value:f.slice(0,128)}]:[],...g?[{kind:"web_fp",value:g}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},...e?{cameraLabel:e}:{},...n.length?{signals:n}:{},...o?{print:{v:2,...o,...r?{camera:r}:{}}}:{},...p()?{inApp:!0}:{}},C=k(JSON.stringify(S));return _(),C}catch{return}},printReady(){return a??Promise.resolve()}}}var s=Symbol.for("sekyro.web.clientContext"),c=globalThis,d=c[s]??(c[s]=x({sdk:`@sekyro/web@${m}`}));function N(t){try{let e=t.getVideoTracks?.()[0];if(e){if(d.noteCameraLabel(e.label),d.noteCameraTrack(e),v())return;import("./camera-trait-45MJTW4K.js").then(r=>r.noteCameraTrait(e,d)).catch(()=>{})}}catch{}}export{m as a,p as b,d as c,N as d};
|
package/dist/chunk-ZADZTM3M.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as Ee,B as Te,a as Re,b as Ie,c as Ae,d as ee,e as we,f as Oe,h as H,i as D,j as G,k as Me,l as E,m as K,n as b,o as q,p as x,q as te,r as O,s as N}from"./chunk-H3HVCWLF.js";import{n as xe}from"./chunk-P3H3D33O.js";import{a as be}from"./chunk-GT2ZLGF7.js";import{c as Pe,d as X}from"./chunk-FUHDOEBP.js";import{c as z,g as ve,h as Y}from"./chunk-B2X33ZW2.js";function Z(e){return e.idNumberBound??e.nniBound}function L(e){return e===void 0?void 0:e.idNumberFromDocument??e.nniFromDocument}function Ve(e){let t=e.idNumberMasked??e.nniMasked;return typeof t=="string"&&t!==""?t:void 0}var it="https://api.sekyro.ai",rt=5e3,st=1500,at=10;function ut(e){return new Promise(t=>setTimeout(t,e))}function ct(){let e=globalThis.crypto;if(e!==void 0&&typeof e.randomUUID=="function")return e.randomUUID();let t=new Uint8Array(16);if(e!==void 0&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let i=0;i<16;i+=1)t[i]=Math.floor(Math.random()*256);t[6]=(t[6]??0)&15|64,t[8]=(t[8]??0)&63|128;let n=[...t].map(i=>i.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function Qt(e){return dt(e,{})}function dt(e,t){let n=e.apiOrigin??it,i=e.autoRetry??!0,r=e.rearm??"auto",s=t.client??new ve({apiOrigin:n,sessionToken:e.clientToken,fetch:e.fetch}),c=t.sleep??ut,a=t.uuid??ct,l=t.getTurnstileToken??((o,u)=>import("./turnstile-FATNZ4AG.js").then(p=>p.executeTurnstile(o,u))),f=be(),m=null,g=null,d=!1,k=new AbortController,h=null,A=null,U=null,se=()=>we(ee(h),U),v=o=>{h=o,f.emit("view",o),m?.onView(o)},_=()=>h!==null?Promise.resolve(h):(A??(A=s.getSession().then(o=>(v(o),o)).finally(()=>{A=null})),A),R=async()=>{let o=await s.getSession();return v(o),o},W=async(o,u)=>{o.plan!==void 0?v(o):await R()},$=null,ae=async o=>{let u=await _();if(!o&&u.consentRecorded)return;let p=await s.recordConsent(e.locale);p.plan!==void 0?v(p):h!==null&&v({...h,consentRecorded:!0})},M=o=>o?.force===!0?ae(!0):($??($=ae(!1).finally(()=>{$=null})),$),j={client:s,ensureConsent:o=>M(o),sleep:c,uuid:a,...t.random!==void 0?{random:t.random}:{},onBusy:o=>{d||f.emit("busy",o)}},ue=!1,ce=null,J=o=>{if(o.status==="approved"||o.status==="rejected"||o.status==="review"){if(ue)return;ue=!0}ce=JSON.stringify(o),f.emit("result",o)},Ye=o=>{ce!==JSON.stringify(o)&&J(o)},de=async o=>{let u=h;o&&(u=await R().catch(()=>h));let p=u===null?null:E(u);return p!==null&&!d&&f.emit("method",p),p!==null},le=null,pe=!1,fe=!1,me=()=>Ee(j,(o,u)=>o.submitCheck("population_registry",{},{idempotencyKey:u})),he=o=>Z(o)===!0||L(x(o,"population_registry"))===!0,Ze=async()=>{try{let o=await _();if(b(o)||E(o)!==null||q(o)?.checkType!=="population_registry")return;if(!he(o)&&L(x(o,"population_registry"))===void 0&&(o=await R()),!he(o)){fe=!0;return}await M(),await W(await me(),"population_registry");let u=h===null?void 0:x(h,"population_registry");if(u?.state==="input_required"&&u.reason==="registry_unavailable"&&G(u)>0){if(await c(rt),d)return;await W(await me(),"population_registry")}}catch(o){if(o instanceof z&&(o.code==="check_not_active"||o.code==="step_not_on_path")){await R().catch(()=>{});return}pe=!0;return}h!==null&&b(h)&&J(N(h,{autoRetry:i}))},Se=()=>(le??(le=Ze()),le),We=async()=>{let u=(await _()).turnstileSiteKey;return u===null?{sandbox:!0}:{channel:"hosted_web",siteKey:u,turnstileToken:await l(u,{signal:k.signal})}},F=o=>{if(d)return;let u=s.reportCaptureIssue;if(u===void 0)return;let p=o.formFactor;try{p??(p=Pe())}catch{}try{Promise.resolve(u.call(s,{...o,...p!==void 0?{formFactor:p}:{}})).catch(()=>{})}catch{}},P=null,ye=Promise.resolve(),V=0,$e=async()=>{let o=await _();for(let u=0;u<at&&!d&&!b(o)&&q(o)===void 0&&D(o).some(p=>p.state==="processing")&&(await c(st),!d);u+=1)o=await R();return o},je=async(o,u,p)=>{let{capture:C}=o,y=()=>d,B=()=>o.alive&&o.attempt===p,ke=S=>{B()&&C.setFlowState(S)},w=S=>{if(!y()&&(S.status==="unavailable"&&S.reason!==void 0&&!Re(S.reason)&&F({check:"liveness",kind:"unavailable",phase:"upload",engineKind:S.reason,attempt:Math.max(0,o.issues.value)}),J(S),!!B())){if(S.status==="retry"&&r==="auto"){C.handle.retry();return}C.setFlowState("done")}};if(u.degraded==="NO_RECORDER"){let S=h?.sessionId??(await _().catch(()=>null))?.sessionId??"";w(O(S,"no_recorder"));return}ke("uploading");try{if(await Se(),y())return;let S=await _(),_e;if(!b(S)&&E(S)!==null){await de(!1),w(O(S.sessionId,"method_required"));return}if(!b(S)){if(q(S)?.checkType==="population_registry"){w(O(S.sessionId,fe?"nni_unbound":pe?"network":"registry_unavailable"));return}if(await M(),y())return;_e=h??S;let Q=await Te({...j,artifacts:u,getAttestation:We,getView:()=>h??S,refreshView:R,applySubmit:W,onPhase:ke,isCancelled:y,onKeyframePromoted:ot=>{g=ot}});if(y())return;if(Q.kind==="unavailable"){w(O(S.sessionId,Q.reason));return}if(Q.kind==="resync"&&await R(),h!==null&&E(h)!==null){await de(!1),w(O(S.sessionId,"method_required"));return}S=await $e()}w(N(S,{autoRetry:i,previous:_e}))}catch{if(y())return;w(O(h?.sessionId??"","network"))}},Je=(o,u)=>{let p=o.attempt;V>0&&o.alive&&o.capture.setFlowState("uploading"),V+=1,ye=ye.then(()=>je(o,u,p)).finally(()=>{V-=1,V===0&&m?.onChainIdle()}).catch(()=>{})},ge=o=>{P?.capture.handle.destroy(),P!==null&&(P.alive=!1);let u=xe(o,m?.captureInternals?.(o)??t.capture,()=>h?.capture?.liveness?.keyframe?.rank===!0,se,()=>h?.capture?.liveness?.screenRamp),p={capture:u,alive:!0,attempt:0,issues:Ae()};P=p,u.handle.on("error",y=>{F(Ie("liveness",y,p.issues.value))}),u.handle.on("state",y=>{p.issues.note(y),y==="starting"&&(p.attempt+=1)}),u.handle.on("captured",y=>{Promise.resolve().then(()=>Je(p,y))});let C=u.handle;return{get state(){return C.state},get captureMode(){return C.captureMode},get facingMode(){return C.facingMode},on:(y,B)=>C.on(y,B),start:async y=>{if(h===null&&await _().catch(()=>{}),!!p.alive)return C.start(y)},retry:()=>C.retry(),switchCamera:()=>C.switchCamera(),destroy:()=>{p.alive=!1,P===p&&(P=null),C.destroy()}}},Qe=async()=>{if(d)return null;try{let o=await _();return d?null:E(o)}catch{return null}},Xe=async()=>{if(d)return"self";try{let o=await _();if(d)return"self";let u=ee(o);return u==="choice"?U??u:u}catch{return"self"}},ze=async()=>{if(d)return!1;try{let o=await _();if(d||b(o))return!1;let u=x(o,"liveness");return K(u)&&u?.requiresMobile===!0&&!X()}catch{return!1}},et=async()=>{if(d)return!1;try{let o=await _();return!d&&o.returning===!0}catch{return!1}},tt=async o=>{let u=(await _()).plan?.choice,p=u?.options.find(y=>H[y.service]===o);if(!p)throw new RangeError(`method ${String(o)} is not offered`);let C=await s.choose(u.nodeId,p.id);d||v(C)},Ce=null,nt=()=>(Ce??(Ce=import("./plan-runner-NUWONT7F.js").then(o=>{let u=o.createPlanRunner({runtime:j,currentView:()=>h,cameraMode:se,ensureView:_,refreshView:R,ensureConsent:()=>M(),liveness:ge,stopLiveness:()=>{P!==null&&(P.alive=!1,P.capture.handle.destroy(),P=null)},chainBusy:()=>V>0,destroyed:()=>d,sleep:c,isMobile:X,now:t.now??Date.now,keptFaceKey:()=>g,setView:v,baseCapture:t.capture,emitStep:p=>{d||f.emit("step",p)},emitResult:Ye,reportCaptureIssue:F,documentInternals:t.document,portraitInternals:t.portrait,livePhotoInternals:t.livePhoto,uploadInternals:t.upload});return m=u,u})),Ce);return{consent:()=>M(),startRegistry:Se,methodChoice:Qe,selectMethod:tt,reportCameraUnavailable:async o=>{await M();let u=s.reportCameraUnavailable;if(u===void 0)throw new TypeError("this client cannot report a missing camera");let p=await u.call(s,o).catch(C=>{if(C instanceof z&&C.code==="check_out_of_order")return s.getSession();throw C});d||v(p)},reportCaptureIssue:F,mobileRequired:ze,captureMode:Xe,chooseCaptureMode:o=>{U=o},get captureChoice(){return U},returning:et,liveness:ge,run:async()=>{if(d)throw new Error("verification destroyed");return(await nt()).run()},currentStep:()=>m?.current()??null,voiceClips:async()=>{if(d)return null;try{let o=await _();return d?null:o.voice??null}catch{return null}},on:(o,u)=>f.on(o,u),destroy:()=>{d=!0,k.abort(),m?.destroy(),P!==null&&(P.alive=!1,P.capture.handle.destroy(),P=null),f.clear()}}}var He=["AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","XK","YE","YT","ZA","ZM","ZW"];var lt=["carte_identite","passport","residence_permit"];function pt(e,t){let n=e.byIssuer?.[t]??e.default;return lt.filter(i=>n==="*"||n.includes(i))}function tn(e,t=He){return[...new Set([...t,...Object.keys(e.byIssuer??{})])].filter(i=>pt(e,i).length>0).sort()}function De(e){if(e.acceptedDocuments)return e.acceptedDocuments;let t=e.acceptedDocumentTypes?.length?[...e.acceptedDocumentTypes]:["carte_identite","passport"];return{default:[],byIssuer:{MR:t}}}function nn(e){return/^[A-Z]{2}$/.test(e)?String.fromCodePoint(...[...e].map(t=>127462+t.charCodeAt(0)-65)):""}var dn=["national_number","document_photo","national_eid"],ft=new Set(["phone_otp","email_otp","national_eid","document","nfc","population_registry","supplied_identity","summary_confirm","liveness","portrait","face_match","aml_screening","face_dedup","age_estimation"]),mt=new Set(["supplied_identity","aml_screening","face_dedup","age_estimation"]),oe=["document","population_registry","national_eid"],ie=["phone_otp","email_otp"],Ue={identity_method:oe,contact:ie},ht=["population_registry","document"],Fe="platform_unsupported",St=new Set(["prefilled","user_entered","prefilled_or_entered"]),yt={phone_otp:"contact",email_otp:"contact",eid_auth:"identity",doc_ocr:"identity",nfc_chip:"identity",population_registry:"identity",liveness:"live_photo",portrait_icao:"live_photo",face_match:"live_photo"};function I(e){return e.section??yt[e.checkType]??null}function gt(e,t){let n=e.plan?.choice;if(n===void 0||n.locked)return;let i=n.options.find(r=>r.id!==n.selected&&r.available!==!1&&t.includes(r.service));return i===void 0?void 0:{nodeId:n.nodeId,option:i}}function re(e){let t=e.plan,n=t?.choice;if(t===void 0||n===void 0||n.locked||t.current===null||t.current===n.nodeId||b(e))return null;let i=Ue[n.kind]??[...oe,...ie],r=n.options.flatMap(a=>a.available===!1||!i.includes(a.service)?[]:[a.nationalEid!=null?{id:a.id,service:a.service,nationalEid:a.nationalEid}:{id:a.id,service:a.service}]),s=t.steps.find(a=>a.id===t.current)?.service,c=n.selected??r.find(a=>a.service===s)?.id??null;return r.some(a=>a.id!==c)?{nodeId:n.nodeId,kind:n.kind,current:c,options:r}:null}function Be(e){return e==null?[]:e.options.filter(t=>t.id!==e.current)}function Ct(e){let t=e.simulation;if(typeof t!="object"||t===null)return;let{otpCode:n,skipCapture:i}=t;return typeof n=="string"&&n!==""&&typeof i=="boolean"?{otpCode:n,skipCapture:i}:void 0}function kt(e){let t=(e.plan?.sections??[]).map(s=>({id:s.id,state:s.state})),n={sessionId:te(e.sessionId),orgName:e.orgName,returning:e.returning===!0,consentRecorded:e.consentRecorded,expiresAt:e.expiresAt,sections:t.map(s=>s.id),progress:t,purpose:e.purpose??"identity"};e.branding!==void 0&&(n.branding=e.branding),e.cameraUnavailableHandled===!0&&(n.cameraUnavailableHandled=!0);let i=Ct(e);i!==void 0&&(n.simulation=i);let r=re(e);return r!==null&&(n.switchable=r),n}function _t(e){let t={attemptsRemaining:G(e),attemptsExhausted:e.attemptsExhausted===!0};return e.reason!==void 0&&(t.reason=e.reason),e.retakeHint!==void 0&&(t.retakeHint=e.retakeHint),t}var Ge={phone_otp:"phone",email_otp:"email"};function Pt(e,t){let n=gt(e,[t==="phone_otp"?"email_otp":"phone_otp"]);return n===void 0?void 0:Ge[n.option.service]}function bt(e,t,n,i){let r=t.checkType==="email_otp",s=(r?t.emailOtp:t.otp)??{},c=r?t.emailOtp?.emailSource:t.otp?.numberSource,a=c!==void 0&&St.has(c)?c:r?"prefilled_or_entered":"user_entered",l=typeof s.sentToMasked=="string"&&s.sentToMasked.length>0,f=s.prefilled===!0,m=Pt(e,r?"email_otp":"phone_otp"),g={key:t.checkType,context:n,section:I(t),phase:l?"verify":"send",canSwitch:m!==void 0,...i},d=r?{kind:"email_otp",...g,emailSource:a,needsEmail:a!=="prefilled"&&!f}:{kind:"phone_otp",...g,numberSource:a,needsPhone:a!=="prefilled"&&!f,channels:(t.otp?.channels??[]).filter(k=>k==="whatsapp"||k==="sms")};if(m!==void 0&&(d.switchChannel=m),f&&(d.prefilled=!0),l&&(d.sentToMasked=s.sentToMasked),!r&&t.otp?.channel!==void 0&&(d.channel=t.otp.channel),!r&&Array.isArray(t.phoneCountries)&&(d.phoneCountries=t.phoneCountries.filter(k=>typeof k=="string"&&/^[A-Z]{2}$/.test(k))),!r&&Array.isArray(t.phoneRules)){let k=d.phoneCountries??[];d.phoneRules=t.phoneRules.flatMap(h=>{let A=Rt(h);return A!==void 0&&k.includes(A.code)?[A]:[]})}return!r&&t.phoneInternational===!0&&(d.phoneInternational=!0),s.expiresAt!==void 0&&(d.codeExpiresAt=s.expiresAt),s.resendAvailableAt!==void 0&&(d.resendAvailableAt=s.resendAvailableAt),d}var xt=/^[\d[\]\-|()?:^]{1,64}$/;function vt(e){try{return typeof e=="string"&&xt.test(e)&&new RegExp(e)!==null}catch{return!1}}var Ne=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=15;function Rt(e){let{code:t,dial:n,trunk:i,lengths:r,formats:s}=e??{};if(typeof t!="string"||typeof n!="string"||!/^\d{1,3}$/.test(n)||i!==void 0&&(typeof i!="string"||!/^\d{1,3}$/.test(i))||!Array.isArray(r)||r.length===0||!r.every(Ne))return;let c={code:t,dial:n,lengths:[...r].sort((a,l)=>a-l)};if(i!==void 0&&(c.trunk=i),s!==void 0){if(!(Array.isArray(s)&&s.length<=8&&s.every(l=>vt(l?.leading)&&Array.isArray(l.groups)&&l.groups.every(Ne)&&r.includes(l.groups.reduce((f,m)=>f+m,0)))))return;c.formats=s.map(l=>({leading:l.leading,groups:[...l.groups]}))}return c}function It(e,t,n,i){let r=Z(e)===!0?"bound":L(t)===!0?"document":"typed",s=r==="typed"&&t.state==="input_required"&&t.reason!==void 0&&Oe(t.reason)==="id_number_recheck",c=Be(re(e)),a=!i.attemptsExhausted&&c.length===1&&c[0]?.service==="document";return{kind:"registry",key:"registry",context:n,section:I(t),state:t.state==="input_required"?"input_required":"pending",source:r,recheck:s,canUseDocument:a,...i}}function At(e,t,n,i){let r=[...t.acceptedSides??[]],s={kind:"document",key:"document",context:n,section:I(t),side:r.includes("recto")?"verso":"recto",acceptedSides:r,documents:De(e),photo:Ke(e.documents),...i};return e.detectedCountry!==void 0&&(s.detectedCountry=e.detectedCountry),wt(e)&&(s.ageStepUp=!0),s}function Ke(e,t=!0){let n=e?.source==="upload"||e?.source==="choice"?e.source:"camera",i=e?.sourcePick==="camera"||e?.sourcePick==="upload"?e.sourcePick:null;return{source:n,pick:i,uploadOffered:t&&e?.uploadOffered===!0}}function wt(e){let t=D(e).find(i=>i.checkType==="age_estimation"),n=t?.reason;return t?.state==="failed"&&(n==="age_uncertain"||n==="age_unavailable")}function Ot(e){let t=x(e,"liveness");return t?.state==="passed"||t?.state==="review"}function Le(e,t,n,i,r){let s=t.icao?.report,c=e.portrait,a=r==="capture"?c?.pendingFix??null:null;a!==null&&(r="review");let l=qe(e);return{kind:"portrait",key:`portrait:${r}`,context:n,section:I(t),phase:r,report:Array.isArray(s)?s:null,review:t.state==="review",tuning:e.capture?.icao??null,tuningVersion:e.capture?.tuningVersion??null,icao:Y(e),retakeOnly:r==="capture"&&t.state==="input_required"&&l===void 0&&e.capture?.livePhoto?.oneCapture===!0&&Ot(e),photo:Ke(c,r==="capture"),pendingFix:a,...l!==void 0?{captureMode:l}:{},...c?.reuse?.pending===!0?{reuse:!0}:{},...i}}function qe(e){let t=e.portrait?.captureMode;return t==="self"||t==="assisted"||t==="choice"?t:void 0}var ne={minLongSidePx:1280,jpegQuality:.95};function Mt(e,t){let n=e.capture?.livePhoto;if(n?.oneCapture!==!0)return null;let i=x(e,"portrait_icao"),r=n.still??ne;return{icao:t==="liveness"&&Y(e)!==null&&qe(e)===void 0&&i!==void 0&&i.state==="pending"&&i.reason===void 0,still:{minLongSidePx:r.minLongSidePx??ne.minLongSidePx,jpegQuality:r.jpegQuality??ne.jpegQuality}}}function Et(e,t,n,i){let r=t.eid,s=I(t);if(r===void 0||r.challenge!=="app_code")return{kind:"unsupported",key:"unsupported:eid_auth",context:n,section:s,checkType:"eid_auth",reason:"update_required"};let c=Be(re(e)),a=c.length===1&&ht.includes(c[0]?.service??"")?c[0]:void 0,l=a===void 0?void 0:H[a.service],f=l!==void 0,m={kind:"eid",key:"eid",context:n,section:s,provider:r.provider,providerName:r.providerName,country:r.country,challenge:"app_code",phase:r.awaiting==="code"?"code":"identifier",identifierBound:r.identifierBound===!0,canUseCamera:f,afterPass:r.afterPass==="continue"?"continue":"end",...i};return f&&(m.cameraMethod=l),r.expiresAt!==void 0&&(m.codeExpiresAt=r.expiresAt),r.resendAvailableAt!==void 0&&(m.resendAvailableAt=r.resendAvailableAt),r.resendsRemaining!==void 0&&(m.resendsRemaining=r.resendsRemaining),r.codeAttemptsRemaining!==void 0&&(m.codeAttemptsRemaining=r.codeAttemptsRemaining),m}function Tt(e,t){if(t.checkType!=="face_match"||t.reason!==void 0)return null;let n=x(e,"portrait_icao");return n!==void 0&&(n.state==="passed"||n.state==="review")?n:null}function Vt(e){return D(e).filter(t=>t.state==="failed").pop()?.attemptsExhausted===!0}function Ht(e,t){let n=e.failureReason,i;n===Fe?i="platform_unsupported":e.status==="expired"?i="expired":e.status==="review_pending"?i="review":e.status==="completed"&&e.outcome==="approved"?i="approved":e.status==="completed"&&e.outcome==="review"?i="review":n==="device_cooldown"?i="cooldown":n!==void 0?i="policy_stop":Vt(e)?i="attempts_exhausted":i="rejected";let r=i==="platform_unsupported"?{sessionId:te(e.sessionId),status:"unavailable"}:N(e,{autoRetry:!1}),s={kind:"result",key:"result",context:t,section:null,display:i,result:r};return n!==void 0&&(s.failureReason=n),e.retryAfter!==void 0&&(s.retryAfter=e.retryAfter),s}function Dt(e,t,n){let i=e.identitySummary;if(i==null)return null;let r={kind:"identity_summary",key:"identity_summary",context:t,section:n??"identity",summaryKind:i.kind==="partial"?"partial":i.kind??"full",source:i.source,portraitAvailable:i.portrait?.available===!0,retakeAvailable:i.retakeAvailable===!0};for(let c of Nt){let a=i[c];typeof a=="string"&&a!==""&&(r[c]=a)}let s=Ve(i);return s!==void 0&&(r.idNumberMasked=s,r.nniMasked=s),r}var Nt=["fullName","birthDate","birthYear","nationality","documentType","documentNumberMasked","expiryDate","retakeTarget"];function T(e,t,n,i){return{kind:"unsupported",key:`unsupported:${n}`,context:e,section:t,checkType:n,reason:i}}function Lt(e){return e.kind==="contact"?"contact":(e.kind==="identity_method","identity")}function Ut(e,t){let n=Ue[e.kind]??[...oe,...ie],i=Lt(e),r=e.options.flatMap(c=>{if(c.available===!1||!n.includes(c.service))return[];let a={id:c.id,service:c.service};c.nationalEid!=null&&(a.nationalEid=c.nationalEid);let l=(c.channels??[]).filter(f=>f==="whatsapp"||f==="sms");return c.service==="phone_otp"&&l.length>0&&(a.channels=l),[a]});if(r.length===0){let c=e.options.length>0&&e.options.every(a=>a.service==="nfc");return T(t,i,"choice",c?"platform_unsupported":"update_required")}let s={nodeId:e.nodeId,kind:e.kind,selected:e.selected,options:r};if(e.kind==="identity_method"){let c={kind:"method",key:"method",context:t,section:i,options:r.map(l=>H[l.service]),choice:s},a=r.find(l=>l.nationalEid!==void 0)?.nationalEid;return a!==void 0&&(c.nationalEid=a),c}return e.kind==="contact"?{kind:"contact_choice",key:"contact_choice",context:t,section:i,options:r.map(c=>Ge[c.service]),selected:null,locked:!1,choice:s}:{kind:"choice",key:`choice:${e.nodeId}`,context:t,section:i,choice:s}}function ln(e,t={}){let n=kt(e);if(b(e)||e.failureReason===Fe)return Ht(e,n);let i=e.plan;if(i===void 0||!Array.isArray(i.sections))return T(n,null,"plan","update_required");let r=Me(e);if(r!==null)return Ut(r,n);let s=i.current===null?void 0:i.steps.find(g=>g.id===i.current),c=g=>{let d={kind:"processing",key:"processing",context:n,section:g!==void 0?I(g):i.sections.find(k=>k.state==="current")?.id??null,stalled:!1};return typeof g?.service=="string"&&g.service!==""&&(d.service=g.service),d};if(i.current===null)return c(i.steps.find(g=>g.state==="processing"));if(s===void 0)return T(n,null,"step","update_required");if(!ft.has(s.service))return s.interaction==="server"?c(s):T(n,I(s),s.service,"update_required");if(mt.has(s.service)||!K(s))return c(s);let a=s,l=_t(a),f=a.checkType,m=I(a);switch(f){case"phone_otp":case"email_otp":return bt(e,a,n,l);case"population_registry":return It(e,a,n,l);case"eid_auth":return Et(e,a,n,l);case"doc_ocr":return At(e,a,n,l);case"identity_confirm":return Dt(e,n,m)??c(a);case"portrait_icao":return Le(e,a,n,l,"capture");case"liveness":case"face_match":{let g=Tt(e,a);if(g!==null)return Le(e,g,n,l,"match");let d=a.requiresMobile===!0,k=Y(e);return d&&t.isMobile===!1?{kind:"mobile_required",key:"mobile_required",context:n,section:m,checkType:f}:{kind:"liveness",key:"biometric",context:n,section:m,mode:f==="face_match"?"selfie":"liveness",requiresMobile:d,instructions:k===null?"standard":"icao",icao:k,livePhoto:Mt(e,f),...l}}case"nfc_chip":return T(n,m,f,"platform_unsupported");default:return T(n,m,f,"update_required")}}export{it as a,rt as b,st as c,at as d,ct as e,Qt as f,dt as g,He as h,lt as i,pt as j,tn as k,De as l,nn as m,dn as n,Fe as o,I as p,re as q,Be as r,Tt as s,ln as t};
|
package/dist/chunk-ZNIZACXD.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as G,e as ae,g as oe,m as ie}from"./chunk-53POX7U4.js";import{b as ce}from"./chunk-33KKMPJ5.js";import{a as se,d as ue}from"./chunk-CJHMFPL6.js";import{a as le}from"./chunk-RI3E7GBN.js";import{a as te,d as ne,e as re}from"./chunk-GT2ZLGF7.js";import{e as $}from"./chunk-FUHDOEBP.js";import{k as N,m as Z,n as ee}from"./chunk-CQ7SKLMC.js";var be=250,we=180,ve=96;function de(n){let{data:e,width:t,height:r}=n,a=new Uint8Array(t*r);for(let o=0,c=0;o<a.length;o+=1,c+=4)a[o]=Math.round(.299*(e[c]??0)+.587*(e[c+1]??0)+.114*(e[c+2]??0));return{data:a,width:t,height:r}}function V(n,e){return{x0:Math.max(0,Math.floor(n.x)),y0:Math.max(0,Math.floor(n.y)),x1:Math.min(e.width,Math.ceil(n.x+n.width)),y1:Math.min(e.height,Math.ceil(n.y+n.height))}}function T(n,e,t){let r=V(e,n),a=t===void 0?null:V(t,n),o=0,c=0,u=0,m=0;for(let s=r.y0;s<r.y1;s+=1)for(let x=r.x0;x<r.x1;x+=1){if(a!==null&&x>=a.x0&&x<a.x1&&s>=a.y0&&s<a.y1)continue;let M=n.data[s*n.width+x];o+=1,c+=M,u+=M*M,M>=be&&(m+=1)}if(o===0)return{mean:0,sd:0,clipped:0,count:0};let d=c/o;return{mean:d,sd:Math.sqrt(Math.max(0,u/o-d*d)),clipped:m/o,count:o}}function me(n){let{box:e}=n,r=(n.leftEye.y+n.rightEye.y)/2-.1*e.height,a=e.y+.85*e.height;return{x:e.x+.15*e.width,y:r,width:.7*e.width,height:Math.max(1,a-r)}}function Ce(n,e){let t=me(e),r=T(n,t);if(r.count===0)return null;let a=Math.min(Math.max(e.nose.x,t.x+1),t.x+t.width-1),o=T(n,{x:t.x,y:t.y,width:a-t.x,height:t.height}),c=T(n,{x:a,y:t.y,width:t.x+t.width-a,height:t.height}),u=c.mean>0?o.mean/c.mean:o.mean>0?Number.POSITIVE_INFINITY:1;return{faceLuma:r.mean,halfRatio:u,clipped:r.clipped}}function Pe(n,e){let t=0,r=0;for(let a of[e.leftEyeBox,e.rightEyeBox]){let o=a.width*.15,c=a.height*.5,u=T(n,{x:a.x-o,y:a.y-c,width:a.width+2*o,height:a.height+2*c});t+=u.count,r+=u.clipped*u.count}return t===0?null:r/t}function ke(n,e){let t=ae(e),{box:r}=e,a={x:r.x-.2*r.width,y:t.y,width:1.4*r.width,height:r.y+r.height-t.y},o=0,c=0,u=0;for(let d of[t.x,t.x+.8*t.width]){let s=T(n,{x:d,y:t.y+.04*t.height,width:.2*t.width,height:.25*t.height},a);o+=s.count,c+=s.mean*s.count,u+=(s.sd*s.sd+s.mean*s.mean)*s.count}if(o===0)return null;let m=c/o;return{luma:m,sd:Math.sqrt(Math.max(0,u/o-m*m)),count:o}}function Me(n,e){let t=V(me(e),n),r=Math.max(1,Math.floor(Math.max(t.x1-t.x0,t.y1-t.y0)/ve)),a=(d,s)=>n.data[s*n.width+d],o=0,c=0,u=0;for(let d=t.y0+r;d<t.y1-r;d+=r)for(let s=t.x0+r;s<t.x1-r;s+=r){let x=a(s,d-r)+a(s-r,d)+a(s+r,d)+a(s,d+r)-4*a(s,d);o+=1,c+=x,u+=x*x}if(o===0)return null;let m=c/o;return Math.min(1,Math.max(0,u/o-m*m)/we)}function he(n,e){return{lighting:Ce(n,e),eyeSpecular:Pe(n,e),background:ke(n,e),sharpness:Me(n,e)}}var Se="/models-v3",Le=640,Fe=.92;function K(n){return{width:n.videoWidth||0,height:n.videoHeight||0}}function W(n,e){if(typeof document<"u"){let t=document.createElement("canvas");return t.width=n,t.height=e,t}return typeof OffscreenCanvas=="function"?new OffscreenCanvas(n,e):null}function Te(){let n=null;return(e,t)=>{let{width:r,height:a}=K(e);if(r===0||a===0)return null;let o=t===null?1:Math.min(1,t/Math.max(r,a)),c=Math.round(r*o),u=Math.round(a*o),m;t===null?m=W(c,u):((n===null||n.width!==c||n.height!==u)&&(n=W(c,u)),m=n);let d=m?.getContext("2d",{willReadFrequently:!0});if(m==null||d==null)return null;d.drawImage(e,0,0,c,u);let s=null;try{s=d.getImageData(0,0,c,u)}catch{s=null}return{source:m,width:c,height:u,pixels:s}}}async function Ee(n,e,t,r){let a=Math.round(t*e.width/e.height),o=W(a,t),c=o?.getContext("2d");if(o==null||c==null)throw new Error("canvas unavailable");return c.fillStyle="#fff",c.fillRect(0,0,a,t),c.drawImage(n.source,e.x,e.y,e.width,e.height,0,0,a,t),"convertToBlob"in o?o.convertToBlob({type:"image/jpeg",quality:r}):new Promise((u,m)=>{o.toBlob(d=>d===null?m(new Error("encode failed")):u(d),"image/jpeg",r)})}var Y=class extends Error{};function Ie(n,e,t){return new Promise((r,a)=>{let o=setTimeout(()=>{a(new Y(`init exceeded ${e}ms`)),n.then(t,()=>{})},e);n.then(c=>{clearTimeout(o),r(c)},c=>{clearTimeout(o),a(c)})})}function Re(n){let e=Z(n),t=e==="overconstrained"?"generic":e,r=N(n);return{kind:t,retryable:t!=="insecure"&&t!=="unsupported",detail:{...r!==void 0?{name:r}:{},phase:"acquiring",engineKind:e}}}function Ge(n,e,t,r){let a=n.length===1?n[0]:void 0,o=a===void 0?null:G(a.landmarks,t,r),c=null;if(a!==void 0&&e.pixels!==null){let u=G(a.landmarks,e.width,e.height),m=de(e.pixels);u!==null&&(c=he(m,u))}return{frameWidth:t,frameHeight:r,faces:n.length,geometry:o,matrix:a?.matrix??null,blendshapes:a?.blendshapes??null,stats:c}}function Je(n,e={},t=()=>"self"){let r=ce(n.tuning,n.tuningVersion),a=te(),o=e.now??(()=>performance.now()),c=e.setTimer??((i,l)=>setTimeout(i,l)),u=e.clearTimer??(i=>clearTimeout(i)),m=e.grabFrame??Te(),d=e.encodeRegion??Ee,s=e.getUserMedia??(i=>navigator.mediaDevices.getUserMedia(i)),x=e.createLandmarker??ue,M=n.assetBaseUrl??Se,j=re({enabled:n.keepScreenAwake!==!1}),S=ie(r,{policy:n.policy??"reject"}),w=n.video,z=le({tuning:r.backgroundCheck,assetBaseUrl:M,...e.createSegmenter!==void 0?{createSegmenter:e.createSegmenter}:{},now:o}),h="idle",C=null,b=null,E=null,B=!1,g=!1,p=0,J=0,O=[],v="user",A=!1,fe=e.canChooseFacing??ne,L=i=>{h===i||g||(h=i,j.setActive(i==="starting"||i==="gating"),a.emit("state",i))},U=()=>{E!==null&&u(E),E=null},I=()=>{U();for(let i of C?.getTracks()??[])i.stop();C=null;try{w.srcObject=null}catch{}},H=i=>{I(),L("error"),a.emit("error",i)},Q=()=>{let i=Math.max(o(),J+1);return J=i,i},ge=async i=>{let l=m(w,null),{width:P,height:k}=l??K(w);if(l===null||b===null){S.reset();return}let f=b.detect(l.source,Q()),y=(f.length===1?f:O.length===1?O:[])[0],F=y===void 0?null:G(y.landmarks,P,k);if(F===null){S.reset();return}let R=oe(F,P,k,{margin:r.cropMargin,minWidth:r.resolution.minWidth,minHeight:r.resolution.minHeight}),q=Math.max(r.resolution.minHeight,R.height),xe=await d(l,R,q,Fe);if(g||i!==p)return;let X={image:xe,width:Math.round(q*R.width/R.height),height:q,gate:S.summary()};r.tuningVersion!==null&&(X.tuningVersion=r.tuningVersion),U(),L("captured"),a.emit("captured",X)},_=async i=>{if(!(g||i!==p||h!=="gating"||b===null)){if(!B){B=!0;try{let l=m(w,Le);if(l!==null){let{width:P,height:k}=K(w),f=b.detect(l.source,Q());O=f;let y=Ge(f,l,P||l.width,k||l.height);y.geometry!==null&&r.background.required&&(y.backgroundCheck=z.measure(l,y.geometry.box,P||l.width,k||l.height));let F=S.push(y,o());if(g||i!==p||(a.emit("gate",F),F.ready&&(await ge(i),h!=="gating")))return}}catch{}finally{B=!1}}!g&&i===p&&h==="gating"&&(E=c(()=>{_(i)},1e3/r.cadenceHz))}},pe=()=>Ie(x(M),2e4,i=>i.close()),ye=async i=>{if(t()!=="assisted")return"user";let l=i??(A?void 0:n.facing);if(l!==void 0)return l;if(A)return v;try{return await fe()?"environment":"user"}catch{return"user"}},D=async i=>{if(g||h==="starting"||h==="gating")return;p+=1;let l=p;S.reset(),L("starting");let P=await ye(i?.facing);if(g||l!==p)return;if(C!==null&&P!==v&&I(),v=P,A=!0,C===null&&e.getUserMedia===void 0&&(typeof navigator>"u"||typeof navigator.mediaDevices?.getUserMedia!="function")){let f=typeof window<"u"&&window.isSecureContext===!1?"insecure":"unsupported";H({kind:f,retryable:!1,detail:{phase:"preflight",engineKind:f}});return}let k=b!==null?Promise.resolve(b):pe();k.catch(()=>{});try{if(C===null){let f=await s({video:{facingMode:v,width:{ideal:r.camera.width},height:{ideal:r.camera.height}},audio:!1});if(g||l!==p){for(let y of f.getTracks())y.stop();return}C=f,ee(f),v=$(f)??v,w.srcObject=C,w.muted=!0,w.playsInline=!0,await w.play().catch(()=>{})}}catch(f){!g&&l===p&&H(Re(f));return}try{b=await k}catch(f){if(!g&&l===p){let y=N(f);H({kind:"generic",retryable:!0,detail:{...y!==void 0?{name:y}:{},phase:"models",engineKind:"models"}})}return}g||l!==p||(L("gating"),_(l))};return{handle:{get state(){return h},get captureMode(){return t()},get facingMode(){return v},on:(i,l)=>a.on(i,l),start:D,retry:()=>{if(!g){if(C!==null&&b!==null&&h!=="error"){p+=1;let i=p;U(),S.reset(),L("gating"),_(i);return}h="idle",D()}},switchCamera:()=>{if(g||t()!=="assisted"||h!=="idle"&&h!=="starting"&&h!=="gating"&&h!=="error")return!1;let i=v==="user"?"environment":"user";return p+=1,I(),v=i,h="idle",D({facing:i}),!0},destroy:()=>{g||(p+=1,I(),j.setActive(!1),g=!0,b?.close(),b=null,z.close(),a.clear())}},gateScores:()=>S.scores(),setFlowState:i=>{(h==="captured"||h==="uploading"||h==="checking"||h==="done"&&i==="done")&&L(i)}}}function Qe(){import("@mediapipe/tasks-vision").catch(()=>{})}export{be as a,we as b,de as c,T as d,Ce as e,Pe as f,ke as g,Me as h,he as i,Le as j,Fe as k,Te as l,Ge as m,Je as n,Qe as o};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as a,v as b,w as c,x as d}from"./chunk-QYYJLXKA.js";import"./chunk-G6LKLN4U.js";import"./chunk-TDLIXFDT.js";import"./chunk-P3H3D33O.js";import"./chunk-GT2ZLGF7.js";import"./chunk-7Q4YPMAF.js";import"./chunk-FUHDOEBP.js";import"./chunk-POIQGEZM.js";import"./chunk-CQ7SKLMC.js";import"./chunk-FPXL63KZ.js";import"./chunk-VIAT4DEA.js";import"./chunk-OKWG3PVH.js";import"./chunk-DK5YPBDQ.js";export{a as SAME_FACE_MAX_DROPS,c as createDocumentCapture,d as createDocumentCaptureInternal,b as warmDocumentCapture};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as a,k as b,l as c,m as d,n as e,o as f}from"./chunk-ZNIZACXD.js";import"./chunk-53POX7U4.js";import"./chunk-33KKMPJ5.js";import"./chunk-CJHMFPL6.js";import"./chunk-RI3E7GBN.js";import"./chunk-GI3UFGRQ.js";import"./chunk-GT2ZLGF7.js";import"./chunk-FUHDOEBP.js";import"./chunk-CQ7SKLMC.js";export{a as ANALYSIS_LONG_EDGE,b as PORTRAIT_JPEG_QUALITY,e as createPortraitCaptureInternal,c as defaultGrabber,d as observe,f as warmPortraitCapture};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{e as W}from"./chunk-A3FUGHAH.js";import{a as z,b as K,e as Q,f as J,g as R,j as q}from"./chunk-234OZEDB.js";import{n as $}from"./chunk-ZNIZACXD.js";import"./chunk-53POX7U4.js";import"./chunk-33KKMPJ5.js";import"./chunk-CJHMFPL6.js";import"./chunk-RI3E7GBN.js";import"./chunk-GI3UFGRQ.js";import{A as G,I as H,i as B}from"./chunk-P6UP4UQY.js";import"./chunk-SMKCBUJL.js";import"./chunk-MXWLCDFX.js";import{x as j}from"./chunk-QYYJLXKA.js";import"./chunk-G6LKLN4U.js";import"./chunk-TDLIXFDT.js";import{b as L,c as F,d as U,e as A,t as V}from"./chunk-H3HVCWLF.js";import"./chunk-P3H3D33O.js";import"./chunk-GT2ZLGF7.js";import"./chunk-7Q4YPMAF.js";import"./chunk-FUHDOEBP.js";import"./chunk-POIQGEZM.js";import"./chunk-CQ7SKLMC.js";import"./chunk-FPXL63KZ.js";import{c as b,i as N}from"./chunk-B2X33ZW2.js";import{a as E}from"./chunk-VIAT4DEA.js";import"./chunk-OKWG3PVH.js";import"./chunk-DFTCAWMP.js";import"./chunk-DK5YPBDQ.js";var ee=2e4,te=new Set(["media_type_unsupported","media_type_mismatch"]),X=new Set(["document_upload_not_allowed","portrait_source_not_allowed","uploaded_media_not_allowed"]);function Y(t){let s=null,p=Promise.resolve(),c=!1,f=null,M=null,m=!1,D=null,g=!1,C=!1,v=()=>{s?.controller.handle.destroy(),s=null},h=()=>{let e=t.currentView(),n=e===null?null:R(e,{isMobile:t.isMobile()});return n?.kind==="portrait"?n:null},I=()=>{if(t.destroyed())return"self";let e=t.currentView(),n=e===null?void 0:J(e);return n==="self"||n==="assisted"?n:t.cameraMode?.()??A(n??U(e),null)},S=async(e,n)=>{if(t.destroyed())return;let u=I();n.setFlowState("uploading"),c=!1;let i=null;try{await t.runner().submit("portrait_icao",async(o,y)=>{if(i===null){let w=await V(o,"image","image/jpeg",e.image.size,{engine:"portrait"});await o.uploadToSpaces(w.uploadUrl,e.image,"image/jpeg"),i=(await o.completeMedia(w.key)).key}n.setFlowState("checking");let d={media:{portrait:i},gate:N(e.gate),...e.tuningVersion!==void 0?{tuningVersion:e.tuningVersion}:{},source:"camera",capture:{mode:u}};return o.submitCheck("portrait_icao",d,{idempotencyKey:y})})}catch(o){c=!0,o instanceof b&&X.has(o.code)&&await t.refreshView?.().catch(()=>{})}if(n.setFlowState("done"),t.destroyed())return;let r=h();(r===null||r.phase!=="capture")&&s?.controller===n&&v(),t.runner().republish()},x=e=>t.runner().submit("face_match",(n,u)=>n.submitCheck("face_match",t.runner().faceProbeSkipped()?{simulatedCapture:!0}:{},{idempotencyKey:u})).then(()=>{},()=>{c=!0,e()}),P=null,O=async e=>{let n=h();if(n===null||n.phase!=="capture"||!n.photo.uploadOffered)throw new RangeError("upload_not_offered");let{prepareUploadFile:u}=await import("./upload-file-UYXOHCRG.js"),i=await u(e,t.uploadInternals);if(t.destroyed())return;v(),c=!1;let r=null;try{await t.runner().submit("portrait_icao",async(o,y)=>{if(r===null){let w=await o.presign("image",i.contentType,i.blob.size,{source:"upload"});await o.uploadToSpaces(w.uploadUrl,i.blob,i.contentType),r=(await o.completeMedia(w.key)).key}let d={media:{portrait:r},source:"upload"};return o.submitCheck("portrait_icao",d,{idempotencyKey:y})})}catch(o){throw o instanceof b&&te.has(o.code)?new TypeError("unsupported_file"):(o instanceof b&&X.has(o.code)&&await t.refreshView?.().catch(()=>{}),o)}},k=null,_=e=>{if(k!==null)return k;let n=h();if(n===null||n.phase!=="review")return Promise.reject(new RangeError("no_pending_fix"));let u={fixReview:{accept:e}},i=t.runner().submit("portrait_icao",(r,o)=>r.submitCheck("portrait_icao",u,{idempotencyKey:o})).catch(async r=>{throw r instanceof b&&r.code==="portrait_no_pending_fix"&&await t.refreshView?.().catch(()=>{}),r}).finally(()=>{k=null});return k=i,i},a=e=>{let n=()=>O(e),u=(P===null?n():P.then(n,n)).finally(()=>{P===u&&(P=null)});return P=u,u};return{bind:(e,n)=>{if(e.phase==="review")return v(),{...e,uploadFailed:c,resubmit:()=>Promise.resolve(),capture:()=>{throw new Error("the adjusted photo waits for confirmFix()")},uploadPortrait:()=>Promise.reject(new RangeError("upload_not_offered")),confirmFix:_};if(e.phase==="match")return v(),f!==e.attemptsRemaining&&!c&&(f=e.attemptsRemaining,x(n)),{...e,uploadFailed:c,resubmit:()=>(c=!1,f=e.attemptsRemaining,n(),x(n)),capture:()=>{throw new Error("the portrait was already accepted")},uploadPortrait:()=>Promise.reject(new RangeError("upload_not_offered")),confirmFix:_};if(f=null,e.reuse===!0&&e.phase==="capture")return v(),!g&&D!==e.attemptsRemaining&&(D=e.attemptsRemaining,g=!0,t.runner().submit("portrait_icao",(i,r)=>i.submitCheck("portrait_icao",{},{idempotencyKey:r})).then(()=>{C=!1},()=>{C=!0}).finally(()=>{g=!1,n()})),{kind:"processing",key:"processing",context:e.context,section:e.section,stalled:C&&!g,refresh:()=>(C=!1,D=null,n(),Promise.resolve())};let u=t.keptPortraitInput?.()??null;return u!==null&&(m||u!==M&&e.report===null&&e.reason===void 0&&!e.retakeOnly)?(m||(M=u,m=!0,t.runner().submit("portrait_icao",(i,r)=>i.submitCheck("portrait_icao",u,{idempotencyKey:r})).catch(()=>{}).finally(()=>{m=!1,n()})),{kind:"processing",key:"processing",context:e.context,section:e.section,stalled:!1,refresh:()=>Promise.resolve()}):{...e,uploadFailed:c,resubmit:()=>Promise.resolve(),capture:i=>{if(s!==null&&s.video===i.video)return s.controller.handle;v(),c=!1;let r=$({video:i.video,tuning:e.tuning,tuningVersion:e.tuningVersion,...e.icao!=null?{policy:e.icao.policy}:{},...i.keepScreenAwake!==void 0?{keepScreenAwake:i.keepScreenAwake}:{},...i.assetBaseUrl!==void 0?{assetBaseUrl:i.assetBaseUrl}:{}},t.internals,I);s={video:i.video,controller:r},r.handle.on("error",d=>{t.reportCaptureIssue?.(L("portrait",d,0))});let o=!1,y=(d,w)=>{let T=r.gateScores();T!==null&&t.reportGate?.({kind:"portrait_gate",platform:"web",outcome:d,...w!==null?{failing:w}:{},...T})};return r.handle.on("gate",d=>{!o&&!d.ready&&(r.gateScores()?.elapsedMs??0)>=ee&&(o=!0,y("stuck",d.failing))}),r.handle.on("captured",d=>{y("captured",null),o=!1,p=p.then(()=>S(d,r)).catch(()=>{})}),r.handle},uploadPortrait:a,confirmFix:_}},destroy:v}}function Z(t){let s=t;if(typeof s.apiOrigin!="string"||typeof s.sessionToken!="string")return;let p=`${s.apiOrigin}/api/v2/hosted/capture-reports`,c=s.sessionToken;return f=>{try{fetch(p,{method:"POST",headers:{"content-type":"application/json","x-session-token":c,"x-sekyro-sdk":`@sekyro/web/${E}`},body:JSON.stringify({reports:f}),keepalive:!0}).catch(()=>{})}catch{}}}function ne(t){let s=t.apiOrigin;return W("sdk",typeof s=="string"&&/staging|sandbox|localhost/.test(s)?"sandbox":"live")}function Se(t){let s=null,p=null,c=null,f=F(),M=Promise.resolve(),m=()=>{c?.flow.handle.destroy(),c=null},D=async(a,l)=>{if(t.destroyed())return;l.setFlowState("uploading");let e=null,n,u=!1,i=t.currentView()?.documents!==void 0;try{await s.submit("doc_ocr",async(d,w)=>{if(e===null){let T=await V(d,"image","image/jpeg",a.image.size,{engine:"document"});await d.uploadToSpaces(T.uploadUrl,a.image,"image/jpeg"),e=(await d.completeMedia(T.key)).key}return l.setFlowState("checking"),n===void 0&&(n=l.takeDeviceRead(a)),d.submitCheck("doc_ocr",{imageKey:e,side:a.side,...n!==null?{deviceRead:n}:{},...i?{source:"camera"}:{}},{idempotencyKey:w})})}catch{u=!0}finally{l.setFlowState("done")}if(t.destroyed())return;if(u){l.settle(a.side,{ok:!1,issue:"technical"});return}let r=t.currentView(),o=r===null?null:R(r,{isMobile:t.isMobile()});if(o?.kind!=="document"){l.settle(a.side,{ok:!0}),c?.flow===l?m():l.handle.destroy();return}if(o.reason==="document_type_not_accepted"){p=null,c?.flow===l&&m(),s.republish();return}a.side==="single"||o.acceptedSides.includes(a.side)||o.reason==="side_missing"?(l.settle(a.side,{ok:!0}),p?.documentType!=="passport"&&l.handle.setSide(o.side)):l.settle(a.side,{ok:!1,issue:"reread"})},g=null,C=async a=>{let l=t.currentView(),e=l===null?null:R(l,{isMobile:t.isMobile()});if(l===null||e?.kind!=="document")throw new RangeError("upload_not_offered");if(!e.photo.uploadOffered)throw new RangeError("upload_not_offered");let n=p?.documentType==="passport"?"single":e.side,{prepareUploadFile:u}=await import("./upload-file-UYXOHCRG.js"),i=await u(a,t.uploadInternals);if(t.destroyed())return;m();let r=null;try{await s.submit("doc_ocr",async(o,y)=>{if(r===null){let d=await o.presign("image",i.contentType,i.blob.size,{source:"upload"});await o.uploadToSpaces(d.uploadUrl,i.blob,i.contentType),r=(await o.completeMedia(d.key)).key}return o.submitCheck("doc_ocr",{imageKey:r,side:n,source:"upload"},{idempotencyKey:y})})}catch(o){throw o instanceof b&&(o.code==="media_type_unsupported"||o.code==="media_type_mismatch")?new TypeError("unsupported_file"):(o instanceof b&&(o.code==="document_upload_not_allowed"||o.code==="uploaded_media_not_allowed")&&await t.refreshView().catch(()=>{}),o)}},v=(a,l)=>({...a,uploadDocument:e=>{let n=()=>C(e),u=(g===null?n():g.then(n,n)).finally(()=>{g===u&&(g=null)});return g=u,u},issuer:p?.issuer??null,documentType:p?.documentType??null,captureSide:p===null?null:p.documentType==="passport"?"single":a.side,selectDocument:(e,n)=>{if(!K(a.documents).includes(e)||!z(a.documents,e).includes(n))throw new RangeError(`${n} from ${e} is not accepted`);(p?.issuer!==e||p.documentType!==n)&&m(),p={issuer:e,documentType:n},l()},capture:e=>{if(p===null)throw new Error("selectDocument() first");if(c!==null&&c.video===e.video)return c.flow.handle;m();let n=p,u=n.documentType==="passport"?"single":a.acceptedSides.length>0?a.side:void 0,i=j({video:e.video,documentType:n.documentType,issuer:n.issuer,...u!==void 0?{side:u}:{},...e.keepScreenAwake!==void 0?{keepScreenAwake:e.keepScreenAwake}:{},...e.liveMrz!==void 0?{liveMrz:e.liveMrz}:{}},{...t.documentInternals??{},...(()=>{let r=t.currentView()?.capture?.document,o=t.documentInternals?.blurRefuseSharpnessMax??r?.scan?.blurRefuseSharpnessMax;return{engineOptions:{camera:B(r?.camera),shutter:H(r?.scan),guideLock:G(r?.guide),...t.documentInternals?.engineOptions??{}},...typeof o=="number"&&Number.isFinite(o)&&o>=0&&o<=1?{blurRefuseSharpnessMax:o}:{}}})(),deferRead:!0,...(()=>{let r=t.currentView();if(r===null||t.documentInternals?.webOcr!==void 0)return{};let o=Z(t.runtime.client);return{webOcr:{captureDocument:r.capture?.document,salt:r.sessionId,baseUrl:ne(t.runtime.client),...o!==void 0?{reports:o}:{}}}})()});return c={video:e.video,flow:i},f.newHandle(),i.handle.on("state",r=>f.note(r)),i.handle.on("error",r=>{f.noteError(),t.reportCaptureIssue?.(L("document",r,f.value))}),i.handle.on("captured",r=>{M=M.then(()=>D(r,i)).catch(()=>{})}),i.handle}}),h=null,I=null,S=new Set,x=t.runtime.client;t.runtime.client=new Proxy(x,{get(a,l){if(l==="submitCheck")return(I??a).submitCheck.bind(I??a);let e=Reflect.get(a,l);return typeof e=="function"?e.bind(a):e}});let P=()=>{h?.destroy(),h=null,I=null},O=a=>{let l=t.currentView(),e=l===null?null:R(l,{isMobile:t.isMobile()});if(l===null||e?.kind!=="liveness"||e.livePhoto?.icao!==!0)return;if(h===null){let r=Q({tuning:l.capture?.icao??null,tuningVersion:l.capture?.tuningVersion??null,...e.icao!=null?{policy:e.icao.policy}:{},still:e.livePhoto.still,...a.assetBaseUrl!==void 0?{assetBaseUrl:a.assetBaseUrl}:{}},t.livePhotoInternals);h=r,I=r.decorate(x),r.onGate(o=>{for(let y of S)y(o)})}let n=h,u=t.baseCapture??{},i=u.engineOptions?.telemetry;return{...u,engineOptions:{...u.engineOptions??{},measureQuality:n.engineOptions.measureQuality,telemetry:r=>{i?.(r),n.engineOptions.telemetry(r)}}}},k=Y({keptPortraitInput:()=>h?.lastPortraitInput()??null,runner:()=>s,currentView:t.currentView,...t.cameraMode!==void 0?{cameraMode:t.cameraMode}:{},destroyed:t.destroyed,isMobile:t.isMobile,...t.portraitInternals!==void 0?{internals:t.portraitInternals}:{},...t.uploadInternals!==void 0?{uploadInternals:t.uploadInternals}:{},refreshView:()=>t.refreshView(),...t.reportCaptureIssue!==void 0?{reportCaptureIssue:t.reportCaptureIssue}:{},reportGate:a=>Z(t.runtime.client)?.([a])}),_=q({...t,bindDocument:v,bindPortrait:k.bind,stopCameras:()=>{m(),k.destroy(),P(),t.stopLiveness?.()},onLivePhoto:a=>(S.add(a),()=>S.delete(a))});return s=_,{..._,captureInternals:O,destroy:()=>{m(),k.destroy(),P(),S.clear()}}}export{Se as createPlanRunner,Z as reportSink,ne as sdkAssetBase};
|