@sekyro/web 0.1.0-rc.31 → 0.1.0-rc.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +1 -0
  3. package/dist/{capture-session-doc-2LIRRKFX.js → capture-session-doc-FAMDLRRZ.js} +1 -1
  4. package/dist/{capture-session-v3-XtBrXpoW.d.cts → capture-session-v3-BS2Rl4Kp.d.cts} +1 -1
  5. package/dist/{capture-session-v3-Fbj-X2Ij.d.ts → capture-session-v3-CYh0Jmyf.d.ts} +1 -1
  6. package/dist/{challenge-frame-YAQJ5YMB.js → challenge-frame-YBTLAQ5G.js} +1 -1
  7. package/dist/{chunk-TN4JWBFJ.js → chunk-65YTEYLU.js} +1 -1
  8. package/dist/chunk-B5H5ED6O.js +1 -0
  9. package/dist/{chunk-GXL6ZD4I.js → chunk-C4WK5D33.js} +1 -1
  10. package/dist/{chunk-3K3A7O7J.js → chunk-G2BD6INN.js} +1 -1
  11. package/dist/{chunk-SUANHBF4.js → chunk-HFRU66NW.js} +1 -1
  12. package/dist/{chunk-XFDWFJLY.js → chunk-IUNPV67T.js} +1 -1
  13. package/dist/chunk-MJKHDXCU.js +1 -0
  14. package/dist/{chunk-MD4YXLPK.js → chunk-NO22WG7R.js} +1 -1
  15. package/dist/{chunk-6Z4MIKGF.js → chunk-W6Y2335Q.js} +1 -1
  16. package/dist/chunk-YDG77RHN.js +1 -0
  17. package/dist/{chunk-2MX4J26D.js → chunk-YL2B72KC.js} +2 -2
  18. package/dist/chunk-ZVD6VHM2.js +1 -0
  19. package/dist/client/index.cjs +1 -1
  20. package/dist/client/index.d.cts +3 -3
  21. package/dist/client/index.d.ts +3 -3
  22. package/dist/client/index.js +1 -1
  23. package/dist/core/index.cjs +1 -1
  24. package/dist/core/index.d.cts +3 -3
  25. package/dist/core/index.d.ts +3 -3
  26. package/dist/core/index.js +1 -1
  27. package/dist/create-document-capture-WFTNVMCE.js +1 -0
  28. package/dist/{create-verification-lXGU3ac4.d.cts → create-verification-BAoA5Z9o.d.cts} +10 -5
  29. package/dist/{create-verification-RdG6qv51.d.ts → create-verification-C1Svvmup.d.ts} +10 -5
  30. package/dist/{detector-scanic-KMAVOHGF.js → detector-scanic-S4PB2RNW.js} +1 -1
  31. package/dist/{icao-gate-Cp1C4IEZ.d.ts → icao-gate-BBStoG81.d.ts} +11 -3
  32. package/dist/{icao-gate-DVNkPclI.d.cts → icao-gate-C731iewN.d.cts} +11 -3
  33. package/dist/{icao-policy-CcrwfsVr.d.ts → icao-policy-Dy5Z1vSp.d.ts} +2 -2
  34. package/dist/{icao-policy-c2Ykm9r2.d.cts → icao-policy-R7Jk5qF_.d.cts} +2 -2
  35. package/dist/index.cjs +2 -2
  36. package/dist/index.d.cts +7 -7
  37. package/dist/index.d.ts +7 -7
  38. package/dist/index.js +1 -1
  39. package/dist/internal/index.cjs +2 -2
  40. package/dist/internal/index.d.cts +6 -6
  41. package/dist/internal/index.d.ts +6 -6
  42. package/dist/internal/index.js +1 -1
  43. package/dist/{plan-runner-T2ZTSBI4.js → plan-runner-LSQTIO6L.js} +1 -1
  44. package/dist/{types-B47mZ5TT.d.cts → types-BjzuJVOc.d.cts} +5 -2
  45. package/dist/{types-B47mZ5TT.d.ts → types-BjzuJVOc.d.ts} +5 -2
  46. package/package.json +1 -1
  47. package/sbom.cdx.json +19 -19
  48. package/dist/chunk-6ERQTXMY.js +0 -1
  49. package/dist/chunk-CMXN4SOZ.js +0 -1
  50. package/dist/chunk-OUC57KMS.js +0 -1
  51. package/dist/chunk-R3JMNYW5.js +0 -1
  52. package/dist/create-document-capture-X35M4UAK.js +0 -1
@@ -1 +1 @@
1
- import{d as re,h as Re,i as ve,j as Le,l as Te}from"./chunk-G6LKLN4U.js";import{a as ne,e as Ce,g as xe}from"./chunk-R3JMNYW5.js";import{m as j}from"./chunk-6ERQTXMY.js";import{a as we,g as ke}from"./chunk-7QZWBDI5.js";import{k as te}from"./chunk-CPUECYAJ.js";function _e(e,t){let n=new Set(e.flatMap(r=>r.sides.filter(i=>i[t]!==null).map(i=>i.side)));return n.size===1?[...n][0]:null}function ot(e){let t=Ce.find(r=>r.docType===e),n=t.mrz==="none"?null:t.mrz==="td3"?"single":"verso";return{sides:t.sides,format:xe(e),mrz:t.mrz==="none"?"none":"required",mrzSide:n,barcodeSide:null,portraitSide:t.portraitSide}}function Pe(e,t){if(t.length===0)return ot(e);let n=t.some(s=>s.sides.length>1),r=new Set(t.map(s=>s.format)),i=r.size===1?[...r][0]:"card",c=t.filter(s=>s.sides.some(p=>p.mrz!==null)).length,u=t.find(s=>s.sides.length>1===n)?.sides.find(s=>s.portrait)?.side;return{sides:n?["recto","verso"]:["single"],format:i,mrz:c===t.length?"required":c===0?"none":"optional",mrzSide:_e(t,"mrz"),barcodeSide:_e(t,"barcode"),portraitSide:u??(n?"recto":"single")}}function Ee(e,t){if(e===void 0)return[];let n=e.toUpperCase();return Object.prototype.hasOwnProperty.call(ne,n)?ne[n]?.[t]??[]:[]}async function Oe(e,t,n){return await e(t)?n:n==="recto"?"verso":"recto"}var at={low:{maxLongEdge:1920,payloadTargetBytes:7e5,qMin:.7,qMax:.92},mid:{maxLongEdge:2240,payloadTargetBytes:12e5,qMin:.7,qMax:.92},good:{maxLongEdge:2560,payloadTargetBytes:16e5,qMin:.7,qMax:.92}};function it(e){let{deviceMemory:t,effectiveType:n,saveData:r,downlinkMbps:i,sourceLongEdge:c}=e,u=r===!0||n==="slow-2g"||n==="2g"||i!=null&&i>0&&i<1,s=t!=null&&t<=2,p=n==="4g"||i!=null&&i>=5,d=t!=null&&t>=6,M;u||s?M="low":p&&d?M="good":M="mid";let f=at[M],_=c&&c>0?Math.min(f.maxLongEdge,c):f.maxLongEdge;return{tier:M,...f,maxLongEdge:_}}function Ae(e){let t={};try{let n=navigator;typeof n.deviceMemory=="number"&&(t.deviceMemory=n.deviceMemory);let r=n.connection;r&&(t.effectiveType=r.effectiveType,t.saveData=r.saveData,t.downlinkMbps=r.downlink)}catch{}return typeof e=="number"&&e>0&&(t.sourceLongEdge=e),it(t)}function st(e,t,n){let r=Math.min(1,Math.max(0,(e-.28)/.21999999999999997)),i=(t+n)/2;return Math.max(t,n-r*(n-i))}function ut(e,t,n){let r=Math.max(e,t),i=r>0?Math.min(1,n/r):1;return{width:Math.max(1,Math.round(e*i)),height:Math.max(1,Math.round(t*i))}}async function ct(e,t){let n=t.startQ,r=await e(n);for(let i=0;i<4&&!(r.size<=t.budgetBytes||n<=t.qMin);i++)n=Math.max(t.qMin,n-.08),r=await e(n);return{blob:r,quality:n}}async function Be(e,t,n,r,i){if(t<=0||n<=0)return null;let{width:c,height:u}=ut(t,n,r.maxLongEdge),s=document.createElement("canvas");s.width=c,s.height=u;let p=s.getContext("2d");if(!p)return null;p.drawImage(e,0,0,c,u);let d=k=>new Promise((S,x)=>{s.toBlob(l=>l?S(l):x(new Error("canvas toBlob returned null")),"image/jpeg",k)}),M=st(i,r.qMin,r.qMax),{blob:f,quality:_}=await ct(d,{startQ:M,qMin:r.qMin,budgetBytes:r.payloadTargetBytes}).finally(()=>{s.width=0,s.height=0});if(f.size>5242880)throw new Error("encoded document exceeds the 5242880-byte media cap");return{blob:f,quality:_,width:c,height:u}}async function oe(e){let t=Ae(Math.max(e.width,e.height)),n=await Be(e,e.width,e.height,t,.5);if(n===null)throw new Error("canvas encode unavailable");return{blob:n.blob,width:n.width,height:n.height}}async function Et(e){let t=await createImageBitmap(e);try{return await oe(t)}finally{t.close()}}var At=250,Bt=.6,It=1800,Ft=6e3,Wt=2e3,Ie=.16;function ie(e,t){return{layout:e,phase:"framing",captured:{},pending:[],lastCaptureAt:t,lastReportAt:t,manualShutter:!1,restPhase:"framing",readSides:[],needFlip:!1,flipped:!1,flipTimeoutSpent:!1,timeoutCapture:!1,lastShotByTimeout:!1}}var Fe=e=>e==="recto"?"verso":"recto",We=e=>e.phase==="framing"||e.phase==="locking"||e.phase==="flipCue"||e.phase==="reaskRecto",se=e=>(e.captured.recto!==void 0?1:0)+(e.captured.verso!==void 0?1:0)+e.pending.length;function ae(e,t){return e.lastCaptureAt>=0&&e.lastReportAt>=0?e:{...e,lastCaptureAt:e.lastCaptureAt<0?t:e.lastCaptureAt,lastReportAt:e.lastReportAt<0?t:e.lastReportAt}}function lt(e,t,n){if(e.phase==="result")return{...e,lastReportAt:n};let r=!t.present||e.captureArea!==void 0&&t.areaFrac<.6*e.captureArea,{flipped:i,awaySince:c}=e;r&&(c=c??n),c!==void 0&&n-c>=250&&(i=!0),r||(c=void 0);let u=e.flipTimeoutSpent&&!(i&&!e.flipped),s={...e,lastReportAt:n,flipped:i,awaySince:c,flipTimeoutSpent:u,lastArea:t.areaFrac};if(!We(e))return s;if(e.needFlip&&!i){if(!t.ready)return{...s,phase:e.restPhase,goodSince:void 0};let p=e.lastShot!==void 0&&e.pending.includes(e.lastShot);if(u||p)return{...s,goodSince:void 0,phase:e.restPhase};let d=e.goodSince??n;return n-d>=1800?{...s,goodSince:d,phase:"capturing",flipTimeoutSpent:!0,timeoutCapture:!0}:{...s,goodSince:d,phase:e.restPhase}}return t.ready?{...s,phase:"capturing",goodSince:e.goodSince??n}:{...s,goodSince:void 0,phase:t.locking?"locking":e.restPhase}}function dt(e,t){if(!We(e)||e.manualShutter)return e;let n=t-e.lastReportAt>=2e3,r=t-e.lastCaptureAt>=6e3;return n||r?{...e,manualShutter:!0}:e}function mt(e,t,n){let r=e.layout==="singlePage",i=r?{recto:t}:e.captured,c=r?[]:[...e.pending,t],u={...e,captured:i,pending:c,lastShot:t,lastCaptureAt:n,lastReportAt:-1,manualShutter:!1,goodSince:void 0,notice:void 0,awaySince:void 0,flipped:!1,lastShotByTimeout:e.timeoutCapture,timeoutCapture:!1,captureArea:e.lastArea};return r||se({captured:i,pending:c})>=2?{...u,phase:"reading",restPhase:"framing",current:void 0,needFlip:!1}:{...u,phase:"flipCue",restPhase:"flipCue",current:void 0,needFlip:!0}}function ze(e,t,n){return e.pending.includes(t)?{...e,pending:e.pending.filter(r=>r!==t),lastShot:e.lastShot===t?void 0:e.lastShot,phase:e.phase==="capturing"?e.phase:"flipCue",restPhase:"flipCue",current:Fe(n),needFlip:!0,flipTimeoutSpent:!0,goodSince:void 0,manualShutter:!0,notice:"same_face",lastCaptureAt:-1,lastReportAt:-1}:e}function pt(e,t,n){if(!e.pending.includes(t))return e;if(e.captured[n]!==void 0)return ze(e,t,n);let r=e.pending.filter(p=>p!==t),i={...e,pending:r,captured:{...e.captured,[n]:t}};if(se(i)!==1||e.layout==="singlePage")return i;let c=Fe(n),u=c==="recto"&&e.restPhase==="reaskRecto"?"reaskRecto":"flipCue",s=e.phase==="flipCue"||e.phase==="reaskRecto"||e.phase==="framing";return{...i,restPhase:u,current:c,phase:s?u:e.phase}}function ft(e,t){let n=t.id??e.captured[t.side],r={...e.captured};(t.id===void 0||r[t.side]===t.id)&&delete r[t.side];let i=e.pending.filter(d=>d!==n),c=e.layout==="twoSided"&&se({captured:r,pending:i})>0,u=e.lastShotByTimeout||n===e.lastShot!==e.flipped,s=c&&!u,p=s?t.side==="recto"?"reaskRecto":"flipCue":"framing";return{...e,captured:r,pending:i,readSides:e.readSides.filter(d=>d!==t.side),lastShot:e.lastShot===n?void 0:e.lastShot,notice:t.issue,goodSince:void 0,manualShutter:!1,phase:p,restPhase:p,current:t.side,needFlip:s,flipped:!1,flipTimeoutSpent:!1,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1}}function Ue(e,t){switch(t.type){case"report":return lt(ae(e,t.at),t.report,t.at);case"tick":return dt(ae(e,t.at),t.at);case"captured":return mt(ae(e,t.at),t.id,t.at);case"captureFailed":return{...e,phase:e.restPhase,goodSince:void 0,lastCaptureAt:t.at,manualShutter:!0,timeoutCapture:!1};case"classified":return pt(e,t.id,t.side);case"duplicate":return ze(e,t.id,t.side);case"readOk":{let n=e.readSides.includes(t.side)?e.readSides:[...e.readSides,t.side],r=["recto","verso"].filter(c=>e.captured[c]!==void 0),i=e.phase==="reading"&&e.pending.length===0&&r.every(c=>n.includes(c));return{...e,readSides:n,flipTimeoutSpent:!1,phase:i?"result":e.phase}}case"readFailed":return ft(e,t);case"clockRestart":return e.lastCaptureAt<0&&e.lastReportAt<0&&e.awaySince===void 0?e:{...e,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1};case"retake":return{...ie(e.layout,-1),lastCaptureAt:-1,lastReportAt:-1};default:return e}}function gt(e,t,n=!1){let r=e(t);return r===null?"recto":!n||r.y+r.height/2>=t.height/2?"verso":"recto"}async function ht(e,t=!1){let{detectMrzBand:n}=await import("./mrz-band-VYHOTDHY.js");return gt(n,e,t)}async function ue(e,t=480,n,r=n!=null){let i=n??{x:0,y:0,width:e.width,height:e.height},c=Math.max(1,Math.round(i.height/i.width*t)),u=document.createElement("canvas");u.width=t,u.height=c;try{let s=u.getContext("2d");return s===null?"recto":(s.drawImage(e,i.x,i.y,i.width,i.height,0,0,t,c),await ht(s.getImageData(0,0,t,c),r))}finally{u.width=0,u.height=0}}async function Ut(e,t=480){try{let n=await createImageBitmap(e),r=Math.max(1,Math.round(n.height/n.width*t)),i=document.createElement("canvas");i.width=t,i.height=r;let c=i.getContext("2d");return c===null?(n.close(),null):(c.drawImage(n,0,0,t,r),n.close(),c.getImageData(0,0,t,r))}catch{return null}}var ce=(e,t,n)=>Math.min(n,Math.max(t,Math.round(e))),$=e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4;async function Ne(e,t,n,r){let i=r.decode??(p=>createImageBitmap(p)),c=async()=>e.stillRead(await i(t),r.region??[0,0,1,1],r.detectorLimit),u;try{u=await c()}catch{try{await new Promise(p=>setTimeout(p,r.retryMs??300)),u=await c()}catch{return null}}let s=u.mrzBox;return s===void 0?null:{engine:r.engine,source:"live_mrz",format:n.format,lineCount:ce(n.lineCount,2,3),checkDigitsValid:!0,stillConfirmed:u.valid&&u.digest===n.digest,band:[$(s[0]),$(s[1]),$(Math.min(s[2],1-s[0])),$(Math.min(s[3],1-s[1]))],digest:n.digest,framesToValid:ce(n.framesToValid,1,1e3),msToValid:ce(n.msToValid,0,12e4)}}function Gt(e){let t=null;return e?.then(n=>{t=n}),()=>t}var bt=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]),yt=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,7,1,5,0,6,64,11,11]);function Ge(e,t=globalThis){let n=t.WebAssembly?.validate;if(typeof n!="function")return{ok:!1,reason:"simd"};try{if(!n.call(t.WebAssembly,bt)||!n.call(t.WebAssembly,yt))return{ok:!1,reason:"simd"}}catch{return{ok:!1,reason:"simd"}}if(typeof t.Worker!="function")return{ok:!1,reason:"worker"};if(typeof t.createImageBitmap!="function")return{ok:!1,reason:"bitmap"};let r=t.navigator?.deviceMemory;return typeof r=="number"&&r<e.minDeviceMemoryGb?{ok:!1,reason:"memory"}:{ok:!0}}function qe(e=globalThis){let t=e.navigator?.connection;return t?.saveData===!0||["slow-2g","2g","3g"].includes(t?.effectiveType??"")}var E=class extends Error{constructor(t){super(t),this.name="OcrEngineError",this.code=t}};function He(){let e=t=>(t.close(),Promise.reject(new E("unsupported")));return{ready:Promise.resolve("unsupported"),busy:!1,bandRead:e,stillRead:e,layoutRead:e,dispose:()=>{}}}function Xe(e){let t;try{if(e.createWorker)t=e.createWorker();else if(e.workerUrl!==void 0)t=new Worker(e.workerUrl,{type:"module",name:"sekyro-ocr"});else return He()}catch{return He()}let n=new Map,r=0,i=!1,c=!1,u=!1;t.addEventListener("message",l=>{let h=l.data,R=n.get(h.id);R&&(n.delete(h.id),R.resolve(h))});let s=()=>{for(let l of n.values())l.reject(new E("error"));n.clear(),d()};t.addEventListener("error",s),t.addEventListener("messageerror",s);function p(l,h=[]){if(i)return Promise.reject(new E("disposed"));let R=++r;return new Promise((B,A)=>{n.set(R,{resolve:B,reject:A});try{t.postMessage({...l,id:R},h)}catch{n.delete(R),A(new E("error"))}})}function d(){if(!i){i=!0;try{t.postMessage({id:++r,kind:"dispose"})}catch{}t.terminate();for(let l of n.values())l.reject(new E("disposed"));n.clear()}}let M=(async()=>{let l=await p({kind:"init",baseUrl:e.baseUrl,salt:e.salt,detectorLimit:e.tuning.detectorLimit,maxDownloadMs:e.tuning.maxDownloadMs});if(l.kind==="failed")return l.reason;if(l.kind!=="ready")return"error";let h=await p({kind:"warmup"});return h.kind!=="ready"?"error":{warmupMs:h.warmupMs,downloadMs:l.downloadMs,cached:l.cached}})().catch(()=>"error"),f,_=new Promise(l=>{f=setTimeout(()=>l("timeout"),e.tuning.loadTimeoutMs)}),k=Promise.race([M,_]).then(l=>(clearTimeout(f),typeof l=="string"?d():u=!0,i&&typeof l!="string"?"error":l));(e.page===void 0?globalThis.addEventListener?globalThis:null:e.page)?.addEventListener("pagehide",d,{once:!0});async function x(l,h,R){if(i)throw h.close(),new E("disposed");if(!u)throw h.close(),new E("not_ready");if(c)throw h.close(),new E("busy");c=!0;let B;try{let A=new Promise((X,W)=>{B=setTimeout(()=>{W(new E("timeout")),d()},e.tuning.readTimeoutMs??1e4)}),O=await Promise.race([p(l,[h]),A]);if(O.kind===R){let{id:X,...W}=O;return W}throw new E(O.kind==="error"?O.code:O.kind==="failed"?O.reason:"error")}finally{clearTimeout(B),c=!1}}return{ready:k,get busy(){return c},bandRead:(l,h=e.tuning.detectorLimit)=>x({kind:"band",bitmap:l,detectorLimit:h},l,"band"),stillRead:(l,h,R=e.tuning.detectorLimit)=>x({kind:"still",bitmap:l,region:h,detectorLimit:R},l,"band"),layoutRead:(l,h)=>x({kind:"layout",bitmap:l,detectorLimit:h},l,"layout"),dispose:d}}var H="sekyro-ocr-1",le=e=>e!==null&&typeof e=="object"?e:{},T=(e,t,n,r)=>typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=n?e:r,Ye=(e,t)=>typeof e=="boolean"?e:t,Ve=e=>{let t=typeof e=="string"?/^sekyro-ocr-(\d{1,4})$/.exec(e):null;return t?Number(t[1]):Number.POSITIVE_INFINITY};function Qe(e,t={}){let n=le(e),r=le(n.liveMrz),i=le(n.frontLock),c=Ve(t.engine??H),u=t.mode==="off",s=l=>l.enabled===!0?l.arm==="live"?"live":"control":null,p=s(r),d=s(i),M=(l,h)=>!u&&h==="live"&&Ve(l.minEngine??H)<=c,f=Le,_=M(r,p)?{detectorLimit:T(r.detectorLimit,320,1600,f.detectorLimit),bandMaxWidthPx:T(r.bandMaxWidthPx,320,4096,f.bandMaxWidthPx),minBandWidthPx:T(r.minBandWidthPx,0,4096,f.minBandWidthPx),bandTop:T(r.bandTop,0,.95,f.bandTop),minIntervalMs:T(r.minIntervalMs,0,5e3,f.minIntervalMs),stableReads:Math.round(T(r.stableReads,1,10,f.stableReads)),profileReads:Math.round(T(r.profileReads,1,100,f.profileReads)),maxReadMs:T(r.maxReadMs,50,6e4,f.maxReadMs),searchTimeoutMs:T(r.searchTimeoutMs,1e3,12e4,f.searchTimeoutMs),hint:Ye(r.hint,!0),stillConfirm:Ye(r.stillConfirm,!0)}:null,k=ve,S=(l,h,R)=>T(i[l],h,R,k[l]),x=M(i,d)?{minLines:Math.round(S("minLines",1,50)),fillMin:S("fillMin",0,1),fillMax:S("fillMax",0,2),offsetMax:S("offsetMax",0,1),steadyFillDelta:S("steadyFillDelta",0,1),steadyOffsetDelta:S("steadyOffsetDelta",0,1),layoutShiftMax:S("layoutShiftMax",0,1),lineCountDelta:Math.round(S("lineCountDelta",0,50)),lockMs:S("lockMs",0,3e4),steadyMs:S("steadyMs",0,3e4),minFrames:Math.round(S("minFrames",1,100)),minIntervalMs:S("minIntervalMs",0,5e3),maxWidthPx:S("maxWidthPx",160,2048),detectorLimit:S("detectorLimit",320,1600),searchTimeoutMs:S("searchTimeoutMs",1e3,12e4)}:null;return{enabled:_!==null||x!==null,liveMrz:_,textLock:x,liveMrzArm:p,frontLockArm:d,load:{detectorLimit:_?.detectorLimit??x?.detectorLimit??f.detectorLimit,loadTimeoutMs:T(r.loadTimeoutMs,1e3,12e4,2e4),maxDownloadMs:T(r.maxDownloadMs,1e3,12e4,2e4),minDeviceMemoryGb:T(r.minDeviceMemoryGb,0,64,2)},reportSampleRate:T(r.reportSampleRate,0,1,1)}}function Ke(e,t){return e.enabled?!(t.probe??Ge)({minDeviceMemoryGb:e.load.minDeviceMemoryGb}).ok||(t.slow??qe)()?{ok:!1,reason:"unsupported"}:{ok:!0,engine:Xe({baseUrl:t.baseUrl,salt:t.salt,tuning:{detectorLimit:e.load.detectorLimit,maxDownloadMs:e.load.maxDownloadMs,loadTimeoutMs:e.load.loadTimeoutMs},...t.workerUrl!==void 0?{workerUrl:t.workerUrl}:{},...t.createWorker!==void 0?{createWorker:t.createWorker}:{},...t.page!==void 0?{page:t.page}:{}})}:{ok:!1,reason:"off"}}function St(e=typeof navigator<"u"?navigator.userAgent:""){return/SamsungBrowser\//.test(e)?"samsung":/Firefox\/|FxiOS\//.test(e)?"firefox":/Chrome\/|CriOS\/|Chromium\//.test(e)&&!/Edg\/|OPR\//.test(e)?"chrome":/Safari\//.test(e)&&/Version\/|Mobile\//.test(e)&&!/Chrome\/|CriOS\//.test(e)?"safari":"other"}var F=e=>e===void 0||!Number.isFinite(e)?void 0:Math.min(6e5,Math.max(0,Math.round(e))),de=(e,t,n)=>e===void 0||!Number.isFinite(e)?void 0:Math.min(n,Math.max(t,Math.round(e)));function je(e){let t=e.assist??null,n=e.load!==null&&e.load!==void 0&&typeof e.load=="object"?e.load:null,r=typeof e.load=="string"?e.load:null,i=t!==null?t.outcome:r==="unsupported"||r==="download"||r==="integrity"?r:r==="error"||r==="timeout"?"error":"off",c={kind:"live_mrz",platform:"web",engine:e.engine??H,arm:e.arm,capture:e.capture,outcome:i,reads:de(t?.reads??0,0,1e4)??0,browser:e.browser??St()},u=(s,p)=>{p!==void 0&&(c[s]=p)};return u("format",t?.format),u("framesToValid",de(t?.framesToValid,1,1e4)),u("msToValid",F(t?.msToValid)),u("framesToLock",de(t?.framesToLock,1,1e4)),u("msToLock",F(t?.msToLock)),u("msToCapture",F(e.msToCapture)),u("readP50Ms",F(t?.readP50Ms)),u("readP90Ms",F(t?.readP90Ms)),u("deviceClass",t?.deviceClass),n!==null&&(u("warmupMs",F(n.warmupMs)),u("downloadMs",F(n.downloadMs)),u("cached",n.cached)),u("stillConfirmed",e.stillConfirmed),u("typeMismatch",e.typeMismatch),c}function me(e,t){return e===void 0?!1:t==="passport"?e!=="TD3":e==="TD3"}var Mt=2;async function Dt(e){let t=await import("./capture-session-doc-2LIRRKFX.js");return new t.CaptureSessionDoc(e)}function wt(e){return{topLeft:{x:e.x,y:e.y},topRight:{x:e.x+e.width,y:e.y},bottomRight:{x:e.x+e.width,y:e.y+e.height},bottomLeft:{x:e.x,y:e.y+e.height}}}function kt(e,t,n){let r=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft],i=0;for(let c=0;c<r.length;c+=1){let u=r[c],s=r[(c+1)%r.length];i+=u.x*s.y-s.x*u.y}return t>0&&n>0?Math.abs(i)/2/(t*n):0}function ln(){import("./capture-session-doc-2LIRRKFX.js").then(e=>e.warmDocDetector()).catch(()=>{})}function dn(e){return Ct(e,{}).handle}function Ct(e,t){let n=we(),r=ke({enabled:e.keepScreenAwake!==!1}),i=t.decode??(o=>createImageBitmap(o)),c=t.blurRefuseSharpnessMax??.16,u=t.now??(()=>performance.now()),s=Pe(e.documentType,t.catalogCapture===!0?Ee(e.issuer,e.documentType):[]),p=s.sides.length===1||e.side==="single",d=ie(p?"singlePage":"twoSided",u());if(!p&&(e.side==="recto"||e.side==="verso")){let o=e.side==="recto"?"verso":"recto";d={...d,captured:{[o]:"server"},readSides:[o],current:e.side,phase:"flipCue",restPhase:"flipCue"}}let M="idle",f=null,_=null,k=!0,S=0,x=0,l=!1,h=!1,R="",B=null,A,O=null,X=[],W=s.mrz==="none",$e=s.barcodeSide==="recto"||s.barcodeSide==="verso"?s.barcodeSide:null,N=W&&!p?t.barcode?.side??$e:null,pe=e.barcodeAssetBaseUrl??t.barcode?.assetBaseUrl,fe=null,ge=()=>N===null||pe===void 0||t.barcode?.seen!==void 0?Promise.resolve(null):(fe??(fe=import("./barcode-detect-C5IOXMKI.js").then(o=>o.loadBarcodeDetect(pe)).catch(()=>null)),fe),Je=async(o,a)=>{if(N===null)return null;let m=N==="recto"?"verso":"recto";try{let g=t.barcode?.seen;if(g!==void 0)return await g(o)?N:m;let[L,D]=await Promise.all([ge(),a()]);if(L===null||D===null)return null;let w=Math.min(1600,D.width),y=document.createElement("canvas");y.width=w,y.height=Math.max(1,Math.round(D.height/D.width*w));try{let b=y.getContext("2d");return b===null?null:(b.drawImage(D,0,0,y.width,y.height),await Oe(L,b.getImageData(0,0,y.width,y.height),N))}finally{y.width=0,y.height=0}}catch{return null}},C=t.webOcr!==void 0&&!W?Qe(t.webOcr.captureDocument,{mode:e.liveMrz?.mode??"auto"}):null,G=null,z=C===null||!C.enabled?"off":null,Y=null,V=null,he=new WeakMap,J="";if(C!==null&&C.enabled&&t.webOcr!==void 0){let o=t.webOcr,a=Ke(C,{baseUrl:e.liveMrz?.assetBaseUrl??o.baseUrl,salt:o.salt,...e.liveMrz?.workerUrl!==void 0?{workerUrl:e.liveMrz.workerUrl}:{},...o.createWorker!==void 0?{createWorker:o.createWorker}:{}});if(a.ok){G=a.engine;let m=new Te({textLock:C.textLock,liveMrz:C.liveMrz});Y=m;let g=a.engine;g.ready.then(L=>{z=L,typeof L!="string"&&k&&m.setEngine(g)})}else z=a.reason}let U=o=>{let a=JSON.stringify(o);a!==J&&(J=a,n.emit("mrz",o))},be=(o,a)=>{let m=t.webOcr?.reports;if(m===void 0||C===null||o===void 0)return;let g=o.format==="ID-3"||o.side==="single"?"single":o.side==="verso"?"verso":"recto",L=g!=="recto"?C.liveMrzArm??C.frontLockArm:C.frontLockArm;if(L===null||Math.random()>=C.reportSampleRate)return;let D=o.via==="live_mrz"?V:null,w=()=>{let y=D?.value??null;m([je({arm:L,capture:g,assist:o.ocr??null,load:L==="control"?"off":z,...o.msToCapture!==void 0?{msToCapture:o.msToCapture}:{},...y!==null&&y.stillConfirmed!==void 0?{stillConfirmed:y.stillConfirmed}:{},...a!==void 0?{typeMismatch:me(a.format,s.format==="ID-3"?"passport":"card")}:{}})])};D!==null&&D.value===null?Promise.race([D.promise,new Promise(y=>setTimeout(y,3e3))]).then(w):w()},I=o=>{!k||o===M||(M=o,r.setActive(o==="starting"||o==="scanning"),n.emit("state",o))},Ze=(o,a)=>a===void 0?null:p?"single":o.captured.recto===a?"recto":o.captured.verso===a?"verso":null,et=o=>({phase:o.phase,captured:p?o.captured.recto!==void 0?["single"]:[]:["recto","verso"].filter(a=>o.captured[a]!==void 0),expected:p?null:o.current??null,notice:o.notice??null,lastShot:Ze(o,o.lastShot),manualShutter:o.manualShutter,torchAvailable:f?.torchAvailable()??!1,torch:h}),ye=()=>{let o=f;o!==null&&o.captureNow().catch(()=>v({type:"captureFailed",at:u()}))};function v(o){if(!k)return;let a=d;d=Ue(d,o),d.phase==="capturing"&&a.phase!=="capturing"&&Promise.resolve().then(ye),d.phase==="result"&&a.phase!=="result"&&(I("done"),Se());let m=et(d),g=JSON.stringify(m);g!==R&&(R=g,n.emit("scan",m))}function Se(){O!==null&&clearInterval(O),O=null;for(let o of X.splice(0))o();f?.destroy(),f=null,r.setActive(!1)}let Me=()=>f?.captureReport?.(),Z=!1,De=(o,a)=>{if(!(o===void 0||t.onFaceReport===void 0))try{t.onFaceReport(o,a)}catch{}},Q=o=>{J="",!(f===null||d.phase==="reading"||d.phase==="result")&&(Z=!1,f.rearm(p?"single":d.current??o))},tt=async(o,a,m,g)=>{if(V=null,g!==void 0&&G!==null&&C?.liveMrz?.hint===!0){let b={promise:Ne(G,o,g,{engine:H,detectorLimit:C.liveMrz.detectorLimit}).catch(()=>null),value:null};b.promise.then(P=>{b.value=P}),V=b}g!==void 0&&me(g.format,s.format==="ID-3"?"passport":"card")&&U({state:"mismatch",format:g.format});let L=Me();De(L,"captured"),Z=!0,be(L,g);let D=m===void 0?B:m===null?null:{quad:wt(m),frameWidth:0,frameHeight:0,inStill:!0},w={decoded:null},y=()=>(w.decoded??(w.decoded=Promise.resolve().then(()=>i(o)).catch(()=>null)),w.decoded);try{await nt(o,a,D,y,V)}finally{w.decoded!==null&&(await w.decoded)?.close()}},nt=async(o,a,m,g,L)=>{let D=`shot-${S+=1}`;if(v({type:"captured",id:D,at:u()}),e.haptics!==!1)try{globalThis.navigator?.vibrate?.(30)}catch{}if(!l&&c>0){let b=await(t.measureSharpness!==void 0?t.measureSharpness(o,m):g().then(P=>P===null?-1:Re(P,re(m?.quad??null,m?.inStill===!0?P:{width:m?.frameWidth??0,height:m?.frameHeight??0},P)))).catch(()=>-1);if(!k)return;if(Number.isFinite(b)&&b>=0&&b<c){l=!0;let P=p?"recto":d.current??(d.captured.recto===void 0?"recto":"verso");v({type:"readFailed",side:P,id:D,issue:"blurry"}),Q(P);return}}l=!1;let w;if(p)w="single";else{let b=d.current,q=(t.classify===void 0?await Je(o,g):null)??await(t.classify!==void 0?t.classify(o):g().then(K=>K===null?b??"recto":m?.inStill===!0?ue(K,480,null,!0):ue(K,480,re(m?.quad??null,{width:m?.frameWidth??0,height:m?.frameHeight??0},K)))).catch(()=>b??"recto");if(!k)return;if(d.captured[q]!==void 0&&x<Mt){x+=1,v({type:"duplicate",id:D,side:q}),Q(q==="recto"?"verso":"recto");return}w=d.captured[q]!==void 0&&b!==void 0?b:q,x=0,v({type:"classified",id:D,side:w})}let y=w==="verso"?"verso":"recto";try{let b=t.encode!==void 0?await t.encode(o):await g().then(P=>{if(P===null)throw new Error("the still could not be decoded");return oe(P)});if(!k)return;L!==null&&he.set(b.blob,L),n.emit("captured",{image:b.blob,side:w,documentType:e.documentType,...e.issuer!==void 0?{issuer:e.issuer}:{},width:b.width,height:b.height,previewDataUrl:a}),t.deferRead!==!0&&v({type:"readOk",side:y})}catch(b){v({type:"readFailed",side:y,id:D,issue:"technical"}),n.emit("error",j("generic",!0,{phase:"keyframes",name:te(b)}))}Q(y==="recto"?"verso":"recto")},rt=o=>{X.push(o.on("statechange",({state:a})=>{a==="preflight"||a==="acquiring"?I("starting"):a==="positioning"?I("scanning"):a==="captured"?I("captured"):a==="error"&&I("error")}),o.on("feedback",({key:a,reticle:m})=>n.emit("feedback",{key:a,reticle:m})),o.on("checks",a=>{n.emit("gate",{progress:a.p,quad:a.quad,frameWidth:a.frameWidth,frameHeight:a.frameHeight,...a.guide!==void 0?{guide:{detected:a.guide.detected,fill:a.guide.fill,offsetX:a.guide.offsetX??0,offsetY:a.guide.offsetY??0}}:{}});let m=a.ocr?.mrz;m!==void 0&&(m.state==="fallback"?U({state:"fallback",reason:m.reason}):m.state==="valid"?U({state:"valid",format:m.format}):m.state==="reading"?U({state:"reading",...m.format?{format:m.format}:{},...m.coach?{coach:m.coach}:{}}):U({state:"searching"}));let g=a.quad===null?0:kt(a.quad,a.frameWidth,a.frameHeight);B=a.quad===null?null:{quad:a.quad,frameWidth:a.frameWidth,frameHeight:a.frameHeight},v({type:"report",report:{present:a.quad!==null&&a.plausible||a.guide?.detected===!0,ready:a.ready===!0,locking:a.p>=.5,areaFrac:g},at:u()})}),o.on("error",({kind:a,retryable:m,detail:g})=>n.emit("error",j(a,m,g))),o.on("artifacts",a=>{tt(a.keyframe,a.previewDataUrl,a.docRegion,a.liveMrz)}))},ee=()=>(_??(_=(async()=>{if(k){if(ge(),f===null){let o;try{o=await(t.createEngine??Dt)({...t.engineOptions??{},...A!==void 0?{guide:A}:{},video:e.video,format:s.format,side:p?"single":e.side??"recto",autoCapture:!1,...Y!==null?{ocr:Y}:{}})}catch(m){I("error"),n.emit("error",j("models",!0,{phase:"models",name:te(m)}));return}if(!k){o.destroy();return}f=o,rt(o);let a=t.tickMs??500;a>0&&(O=setInterval(()=>v({type:"tick",at:u()}),a))}v({type:"clockRestart"}),C!==null&&C.liveMrzArm==="live"&&(z==="unsupported"||z==="off")&&U({state:"fallback",reason:z}),await f.start()}})().finally(()=>{_=null})),_);return{handle:{get state(){return M},on:(o,a)=>n.on(o,a),start:ee,retry:()=>{if(f===null&&d.phase==="result"){v({type:"retake"}),x=0,l=!1,ee();return}if(f!==null&&M!=="error"){v({type:"retake"}),x=0,l=!1,f.rearm(p?"single":void 0);return}ee()},setSide:o=>{p||o==="single"||(d.current!==o&&(d={...d,current:o}),v({type:"clockRestart"}),d.phase!=="reading"&&d.phase!=="result"&&f?.rearm(o))},shutter:ye,focusAt:(o,a)=>{f?.focusAt?.(o,a)},setGuide:o=>{A=o,f?.setGuide?.(o)},setTorch:o=>{h=o,f?.setTorch(o),v({type:"tick",at:u()})},destroy:()=>{if(k&&f!==null&&M!=="done"){let o=Me();!Z&&o!==void 0&&o.ticks>0&&De(o,"abandoned"),be(o,void 0)}k=!1,Se(),Y?.setEngine(null),G?.dispose(),G=null,n.clear()}},setFlowState:o=>{(d.phase==="reading"||d.phase==="result")&&I(o==="done"&&d.phase!=="result"?"scanning":o)},settle:(o,a)=>{let m=o==="verso"?"verso":"recto";v(a.ok?{type:"readOk",side:m}:{type:"readFailed",side:m,issue:a.issue}),a.ok||Q(m)},takeDeviceRead:o=>he.get(o.image)?.value??null}}export{Et as a,At as b,Bt as c,It as d,Ft as e,Wt as f,Ie as g,ie as h,Ue as i,gt as j,ht as k,Ut as l,Ne as m,Gt as n,H as o,Qe as p,Ke as q,St as r,je as s,me as t,Mt as u,ln as v,dn as w,Ct as x};
1
+ import{d as re,h as Re,i as ve,j as Le,l as Te}from"./chunk-G6LKLN4U.js";import{a as ne,e as Ce,g as xe}from"./chunk-MJKHDXCU.js";import{m as j}from"./chunk-B5H5ED6O.js";import{a as we,g as ke}from"./chunk-7QZWBDI5.js";import{k as te}from"./chunk-CPUECYAJ.js";function _e(e,t){let n=new Set(e.flatMap(r=>r.sides.filter(i=>i[t]!==null).map(i=>i.side)));return n.size===1?[...n][0]:null}function ot(e){let t=Ce.find(r=>r.docType===e),n=t.mrz==="none"?null:t.mrz==="td3"?"single":"verso";return{sides:t.sides,format:xe(e),mrz:t.mrz==="none"?"none":"required",mrzSide:n,barcodeSide:null,portraitSide:t.portraitSide}}function Pe(e,t){if(t.length===0)return ot(e);let n=t.some(s=>s.sides.length>1),r=new Set(t.map(s=>s.format)),i=r.size===1?[...r][0]:"card",c=t.filter(s=>s.sides.some(p=>p.mrz!==null)).length,u=t.find(s=>s.sides.length>1===n)?.sides.find(s=>s.portrait)?.side;return{sides:n?["recto","verso"]:["single"],format:i,mrz:c===t.length?"required":c===0?"none":"optional",mrzSide:_e(t,"mrz"),barcodeSide:_e(t,"barcode"),portraitSide:u??(n?"recto":"single")}}function Ee(e,t){if(e===void 0)return[];let n=e.toUpperCase();return Object.prototype.hasOwnProperty.call(ne,n)?ne[n]?.[t]??[]:[]}async function Oe(e,t,n){return await e(t)?n:n==="recto"?"verso":"recto"}var at={low:{maxLongEdge:1920,payloadTargetBytes:7e5,qMin:.7,qMax:.92},mid:{maxLongEdge:2240,payloadTargetBytes:12e5,qMin:.7,qMax:.92},good:{maxLongEdge:2560,payloadTargetBytes:16e5,qMin:.7,qMax:.92}};function it(e){let{deviceMemory:t,effectiveType:n,saveData:r,downlinkMbps:i,sourceLongEdge:c}=e,u=r===!0||n==="slow-2g"||n==="2g"||i!=null&&i>0&&i<1,s=t!=null&&t<=2,p=n==="4g"||i!=null&&i>=5,d=t!=null&&t>=6,M;u||s?M="low":p&&d?M="good":M="mid";let f=at[M],_=c&&c>0?Math.min(f.maxLongEdge,c):f.maxLongEdge;return{tier:M,...f,maxLongEdge:_}}function Ae(e){let t={};try{let n=navigator;typeof n.deviceMemory=="number"&&(t.deviceMemory=n.deviceMemory);let r=n.connection;r&&(t.effectiveType=r.effectiveType,t.saveData=r.saveData,t.downlinkMbps=r.downlink)}catch{}return typeof e=="number"&&e>0&&(t.sourceLongEdge=e),it(t)}function st(e,t,n){let r=Math.min(1,Math.max(0,(e-.28)/.21999999999999997)),i=(t+n)/2;return Math.max(t,n-r*(n-i))}function ut(e,t,n){let r=Math.max(e,t),i=r>0?Math.min(1,n/r):1;return{width:Math.max(1,Math.round(e*i)),height:Math.max(1,Math.round(t*i))}}async function ct(e,t){let n=t.startQ,r=await e(n);for(let i=0;i<4&&!(r.size<=t.budgetBytes||n<=t.qMin);i++)n=Math.max(t.qMin,n-.08),r=await e(n);return{blob:r,quality:n}}async function Be(e,t,n,r,i){if(t<=0||n<=0)return null;let{width:c,height:u}=ut(t,n,r.maxLongEdge),s=document.createElement("canvas");s.width=c,s.height=u;let p=s.getContext("2d");if(!p)return null;p.drawImage(e,0,0,c,u);let d=k=>new Promise((S,x)=>{s.toBlob(l=>l?S(l):x(new Error("canvas toBlob returned null")),"image/jpeg",k)}),M=st(i,r.qMin,r.qMax),{blob:f,quality:_}=await ct(d,{startQ:M,qMin:r.qMin,budgetBytes:r.payloadTargetBytes}).finally(()=>{s.width=0,s.height=0});if(f.size>5242880)throw new Error("encoded document exceeds the 5242880-byte media cap");return{blob:f,quality:_,width:c,height:u}}async function oe(e){let t=Ae(Math.max(e.width,e.height)),n=await Be(e,e.width,e.height,t,.5);if(n===null)throw new Error("canvas encode unavailable");return{blob:n.blob,width:n.width,height:n.height}}async function Et(e){let t=await createImageBitmap(e);try{return await oe(t)}finally{t.close()}}var At=250,Bt=.6,It=1800,Ft=6e3,Wt=2e3,Ie=.16;function ie(e,t){return{layout:e,phase:"framing",captured:{},pending:[],lastCaptureAt:t,lastReportAt:t,manualShutter:!1,restPhase:"framing",readSides:[],needFlip:!1,flipped:!1,flipTimeoutSpent:!1,timeoutCapture:!1,lastShotByTimeout:!1}}var Fe=e=>e==="recto"?"verso":"recto",We=e=>e.phase==="framing"||e.phase==="locking"||e.phase==="flipCue"||e.phase==="reaskRecto",se=e=>(e.captured.recto!==void 0?1:0)+(e.captured.verso!==void 0?1:0)+e.pending.length;function ae(e,t){return e.lastCaptureAt>=0&&e.lastReportAt>=0?e:{...e,lastCaptureAt:e.lastCaptureAt<0?t:e.lastCaptureAt,lastReportAt:e.lastReportAt<0?t:e.lastReportAt}}function lt(e,t,n){if(e.phase==="result")return{...e,lastReportAt:n};let r=!t.present||e.captureArea!==void 0&&t.areaFrac<.6*e.captureArea,{flipped:i,awaySince:c}=e;r&&(c=c??n),c!==void 0&&n-c>=250&&(i=!0),r||(c=void 0);let u=e.flipTimeoutSpent&&!(i&&!e.flipped),s={...e,lastReportAt:n,flipped:i,awaySince:c,flipTimeoutSpent:u,lastArea:t.areaFrac};if(!We(e))return s;if(e.needFlip&&!i){if(!t.ready)return{...s,phase:e.restPhase,goodSince:void 0};let p=e.lastShot!==void 0&&e.pending.includes(e.lastShot);if(u||p)return{...s,goodSince:void 0,phase:e.restPhase};let d=e.goodSince??n;return n-d>=1800?{...s,goodSince:d,phase:"capturing",flipTimeoutSpent:!0,timeoutCapture:!0}:{...s,goodSince:d,phase:e.restPhase}}return t.ready?{...s,phase:"capturing",goodSince:e.goodSince??n}:{...s,goodSince:void 0,phase:t.locking?"locking":e.restPhase}}function dt(e,t){if(!We(e)||e.manualShutter)return e;let n=t-e.lastReportAt>=2e3,r=t-e.lastCaptureAt>=6e3;return n||r?{...e,manualShutter:!0}:e}function mt(e,t,n){let r=e.layout==="singlePage",i=r?{recto:t}:e.captured,c=r?[]:[...e.pending,t],u={...e,captured:i,pending:c,lastShot:t,lastCaptureAt:n,lastReportAt:-1,manualShutter:!1,goodSince:void 0,notice:void 0,awaySince:void 0,flipped:!1,lastShotByTimeout:e.timeoutCapture,timeoutCapture:!1,captureArea:e.lastArea};return r||se({captured:i,pending:c})>=2?{...u,phase:"reading",restPhase:"framing",current:void 0,needFlip:!1}:{...u,phase:"flipCue",restPhase:"flipCue",current:void 0,needFlip:!0}}function ze(e,t,n){return e.pending.includes(t)?{...e,pending:e.pending.filter(r=>r!==t),lastShot:e.lastShot===t?void 0:e.lastShot,phase:e.phase==="capturing"?e.phase:"flipCue",restPhase:"flipCue",current:Fe(n),needFlip:!0,flipTimeoutSpent:!0,goodSince:void 0,manualShutter:!0,notice:"same_face",lastCaptureAt:-1,lastReportAt:-1}:e}function pt(e,t,n){if(!e.pending.includes(t))return e;if(e.captured[n]!==void 0)return ze(e,t,n);let r=e.pending.filter(p=>p!==t),i={...e,pending:r,captured:{...e.captured,[n]:t}};if(se(i)!==1||e.layout==="singlePage")return i;let c=Fe(n),u=c==="recto"&&e.restPhase==="reaskRecto"?"reaskRecto":"flipCue",s=e.phase==="flipCue"||e.phase==="reaskRecto"||e.phase==="framing";return{...i,restPhase:u,current:c,phase:s?u:e.phase}}function ft(e,t){let n=t.id??e.captured[t.side],r={...e.captured};(t.id===void 0||r[t.side]===t.id)&&delete r[t.side];let i=e.pending.filter(d=>d!==n),c=e.layout==="twoSided"&&se({captured:r,pending:i})>0,u=e.lastShotByTimeout||n===e.lastShot!==e.flipped,s=c&&!u,p=s?t.side==="recto"?"reaskRecto":"flipCue":"framing";return{...e,captured:r,pending:i,readSides:e.readSides.filter(d=>d!==t.side),lastShot:e.lastShot===n?void 0:e.lastShot,notice:t.issue,goodSince:void 0,manualShutter:!1,phase:p,restPhase:p,current:t.side,needFlip:s,flipped:!1,flipTimeoutSpent:!1,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1}}function Ue(e,t){switch(t.type){case"report":return lt(ae(e,t.at),t.report,t.at);case"tick":return dt(ae(e,t.at),t.at);case"captured":return mt(ae(e,t.at),t.id,t.at);case"captureFailed":return{...e,phase:e.restPhase,goodSince:void 0,lastCaptureAt:t.at,manualShutter:!0,timeoutCapture:!1};case"classified":return pt(e,t.id,t.side);case"duplicate":return ze(e,t.id,t.side);case"readOk":{let n=e.readSides.includes(t.side)?e.readSides:[...e.readSides,t.side],r=["recto","verso"].filter(c=>e.captured[c]!==void 0),i=e.phase==="reading"&&e.pending.length===0&&r.every(c=>n.includes(c));return{...e,readSides:n,flipTimeoutSpent:!1,phase:i?"result":e.phase}}case"readFailed":return ft(e,t);case"clockRestart":return e.lastCaptureAt<0&&e.lastReportAt<0&&e.awaySince===void 0?e:{...e,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1};case"retake":return{...ie(e.layout,-1),lastCaptureAt:-1,lastReportAt:-1};default:return e}}function gt(e,t,n=!1){let r=e(t);return r===null?"recto":!n||r.y+r.height/2>=t.height/2?"verso":"recto"}async function ht(e,t=!1){let{detectMrzBand:n}=await import("./mrz-band-VYHOTDHY.js");return gt(n,e,t)}async function ue(e,t=480,n,r=n!=null){let i=n??{x:0,y:0,width:e.width,height:e.height},c=Math.max(1,Math.round(i.height/i.width*t)),u=document.createElement("canvas");u.width=t,u.height=c;try{let s=u.getContext("2d");return s===null?"recto":(s.drawImage(e,i.x,i.y,i.width,i.height,0,0,t,c),await ht(s.getImageData(0,0,t,c),r))}finally{u.width=0,u.height=0}}async function Ut(e,t=480){try{let n=await createImageBitmap(e),r=Math.max(1,Math.round(n.height/n.width*t)),i=document.createElement("canvas");i.width=t,i.height=r;let c=i.getContext("2d");return c===null?(n.close(),null):(c.drawImage(n,0,0,t,r),n.close(),c.getImageData(0,0,t,r))}catch{return null}}var ce=(e,t,n)=>Math.min(n,Math.max(t,Math.round(e))),$=e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4;async function Ne(e,t,n,r){let i=r.decode??(p=>createImageBitmap(p)),c=async()=>e.stillRead(await i(t),r.region??[0,0,1,1],r.detectorLimit),u;try{u=await c()}catch{try{await new Promise(p=>setTimeout(p,r.retryMs??300)),u=await c()}catch{return null}}let s=u.mrzBox;return s===void 0?null:{engine:r.engine,source:"live_mrz",format:n.format,lineCount:ce(n.lineCount,2,3),checkDigitsValid:!0,stillConfirmed:u.valid&&u.digest===n.digest,band:[$(s[0]),$(s[1]),$(Math.min(s[2],1-s[0])),$(Math.min(s[3],1-s[1]))],digest:n.digest,framesToValid:ce(n.framesToValid,1,1e3),msToValid:ce(n.msToValid,0,12e4)}}function Gt(e){let t=null;return e?.then(n=>{t=n}),()=>t}var bt=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]),yt=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,7,1,5,0,6,64,11,11]);function Ge(e,t=globalThis){let n=t.WebAssembly?.validate;if(typeof n!="function")return{ok:!1,reason:"simd"};try{if(!n.call(t.WebAssembly,bt)||!n.call(t.WebAssembly,yt))return{ok:!1,reason:"simd"}}catch{return{ok:!1,reason:"simd"}}if(typeof t.Worker!="function")return{ok:!1,reason:"worker"};if(typeof t.createImageBitmap!="function")return{ok:!1,reason:"bitmap"};let r=t.navigator?.deviceMemory;return typeof r=="number"&&r<e.minDeviceMemoryGb?{ok:!1,reason:"memory"}:{ok:!0}}function qe(e=globalThis){let t=e.navigator?.connection;return t?.saveData===!0||["slow-2g","2g","3g"].includes(t?.effectiveType??"")}var E=class extends Error{constructor(t){super(t),this.name="OcrEngineError",this.code=t}};function He(){let e=t=>(t.close(),Promise.reject(new E("unsupported")));return{ready:Promise.resolve("unsupported"),busy:!1,bandRead:e,stillRead:e,layoutRead:e,dispose:()=>{}}}function Xe(e){let t;try{if(e.createWorker)t=e.createWorker();else if(e.workerUrl!==void 0)t=new Worker(e.workerUrl,{type:"module",name:"sekyro-ocr"});else return He()}catch{return He()}let n=new Map,r=0,i=!1,c=!1,u=!1;t.addEventListener("message",l=>{let h=l.data,R=n.get(h.id);R&&(n.delete(h.id),R.resolve(h))});let s=()=>{for(let l of n.values())l.reject(new E("error"));n.clear(),d()};t.addEventListener("error",s),t.addEventListener("messageerror",s);function p(l,h=[]){if(i)return Promise.reject(new E("disposed"));let R=++r;return new Promise((B,A)=>{n.set(R,{resolve:B,reject:A});try{t.postMessage({...l,id:R},h)}catch{n.delete(R),A(new E("error"))}})}function d(){if(!i){i=!0;try{t.postMessage({id:++r,kind:"dispose"})}catch{}t.terminate();for(let l of n.values())l.reject(new E("disposed"));n.clear()}}let M=(async()=>{let l=await p({kind:"init",baseUrl:e.baseUrl,salt:e.salt,detectorLimit:e.tuning.detectorLimit,maxDownloadMs:e.tuning.maxDownloadMs});if(l.kind==="failed")return l.reason;if(l.kind!=="ready")return"error";let h=await p({kind:"warmup"});return h.kind!=="ready"?"error":{warmupMs:h.warmupMs,downloadMs:l.downloadMs,cached:l.cached}})().catch(()=>"error"),f,_=new Promise(l=>{f=setTimeout(()=>l("timeout"),e.tuning.loadTimeoutMs)}),k=Promise.race([M,_]).then(l=>(clearTimeout(f),typeof l=="string"?d():u=!0,i&&typeof l!="string"?"error":l));(e.page===void 0?globalThis.addEventListener?globalThis:null:e.page)?.addEventListener("pagehide",d,{once:!0});async function x(l,h,R){if(i)throw h.close(),new E("disposed");if(!u)throw h.close(),new E("not_ready");if(c)throw h.close(),new E("busy");c=!0;let B;try{let A=new Promise((X,W)=>{B=setTimeout(()=>{W(new E("timeout")),d()},e.tuning.readTimeoutMs??1e4)}),O=await Promise.race([p(l,[h]),A]);if(O.kind===R){let{id:X,...W}=O;return W}throw new E(O.kind==="error"?O.code:O.kind==="failed"?O.reason:"error")}finally{clearTimeout(B),c=!1}}return{ready:k,get busy(){return c},bandRead:(l,h=e.tuning.detectorLimit)=>x({kind:"band",bitmap:l,detectorLimit:h},l,"band"),stillRead:(l,h,R=e.tuning.detectorLimit)=>x({kind:"still",bitmap:l,region:h,detectorLimit:R},l,"band"),layoutRead:(l,h)=>x({kind:"layout",bitmap:l,detectorLimit:h},l,"layout"),dispose:d}}var H="sekyro-ocr-1",le=e=>e!==null&&typeof e=="object"?e:{},T=(e,t,n,r)=>typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=n?e:r,Ye=(e,t)=>typeof e=="boolean"?e:t,Ve=e=>{let t=typeof e=="string"?/^sekyro-ocr-(\d{1,4})$/.exec(e):null;return t?Number(t[1]):Number.POSITIVE_INFINITY};function Qe(e,t={}){let n=le(e),r=le(n.liveMrz),i=le(n.frontLock),c=Ve(t.engine??H),u=t.mode==="off",s=l=>l.enabled===!0?l.arm==="live"?"live":"control":null,p=s(r),d=s(i),M=(l,h)=>!u&&h==="live"&&Ve(l.minEngine??H)<=c,f=Le,_=M(r,p)?{detectorLimit:T(r.detectorLimit,320,1600,f.detectorLimit),bandMaxWidthPx:T(r.bandMaxWidthPx,320,4096,f.bandMaxWidthPx),minBandWidthPx:T(r.minBandWidthPx,0,4096,f.minBandWidthPx),bandTop:T(r.bandTop,0,.95,f.bandTop),minIntervalMs:T(r.minIntervalMs,0,5e3,f.minIntervalMs),stableReads:Math.round(T(r.stableReads,1,10,f.stableReads)),profileReads:Math.round(T(r.profileReads,1,100,f.profileReads)),maxReadMs:T(r.maxReadMs,50,6e4,f.maxReadMs),searchTimeoutMs:T(r.searchTimeoutMs,1e3,12e4,f.searchTimeoutMs),hint:Ye(r.hint,!0),stillConfirm:Ye(r.stillConfirm,!0)}:null,k=ve,S=(l,h,R)=>T(i[l],h,R,k[l]),x=M(i,d)?{minLines:Math.round(S("minLines",1,50)),fillMin:S("fillMin",0,1),fillMax:S("fillMax",0,2),offsetMax:S("offsetMax",0,1),steadyFillDelta:S("steadyFillDelta",0,1),steadyOffsetDelta:S("steadyOffsetDelta",0,1),layoutShiftMax:S("layoutShiftMax",0,1),lineCountDelta:Math.round(S("lineCountDelta",0,50)),lockMs:S("lockMs",0,3e4),steadyMs:S("steadyMs",0,3e4),minFrames:Math.round(S("minFrames",1,100)),minIntervalMs:S("minIntervalMs",0,5e3),maxWidthPx:S("maxWidthPx",160,2048),detectorLimit:S("detectorLimit",320,1600),searchTimeoutMs:S("searchTimeoutMs",1e3,12e4)}:null;return{enabled:_!==null||x!==null,liveMrz:_,textLock:x,liveMrzArm:p,frontLockArm:d,load:{detectorLimit:_?.detectorLimit??x?.detectorLimit??f.detectorLimit,loadTimeoutMs:T(r.loadTimeoutMs,1e3,12e4,2e4),maxDownloadMs:T(r.maxDownloadMs,1e3,12e4,2e4),minDeviceMemoryGb:T(r.minDeviceMemoryGb,0,64,2)},reportSampleRate:T(r.reportSampleRate,0,1,1)}}function Ke(e,t){return e.enabled?!(t.probe??Ge)({minDeviceMemoryGb:e.load.minDeviceMemoryGb}).ok||(t.slow??qe)()?{ok:!1,reason:"unsupported"}:{ok:!0,engine:Xe({baseUrl:t.baseUrl,salt:t.salt,tuning:{detectorLimit:e.load.detectorLimit,maxDownloadMs:e.load.maxDownloadMs,loadTimeoutMs:e.load.loadTimeoutMs},...t.workerUrl!==void 0?{workerUrl:t.workerUrl}:{},...t.createWorker!==void 0?{createWorker:t.createWorker}:{},...t.page!==void 0?{page:t.page}:{}})}:{ok:!1,reason:"off"}}function St(e=typeof navigator<"u"?navigator.userAgent:""){return/SamsungBrowser\//.test(e)?"samsung":/Firefox\/|FxiOS\//.test(e)?"firefox":/Chrome\/|CriOS\/|Chromium\//.test(e)&&!/Edg\/|OPR\//.test(e)?"chrome":/Safari\//.test(e)&&/Version\/|Mobile\//.test(e)&&!/Chrome\/|CriOS\//.test(e)?"safari":"other"}var F=e=>e===void 0||!Number.isFinite(e)?void 0:Math.min(6e5,Math.max(0,Math.round(e))),de=(e,t,n)=>e===void 0||!Number.isFinite(e)?void 0:Math.min(n,Math.max(t,Math.round(e)));function je(e){let t=e.assist??null,n=e.load!==null&&e.load!==void 0&&typeof e.load=="object"?e.load:null,r=typeof e.load=="string"?e.load:null,i=t!==null?t.outcome:r==="unsupported"||r==="download"||r==="integrity"?r:r==="error"||r==="timeout"?"error":"off",c={kind:"live_mrz",platform:"web",engine:e.engine??H,arm:e.arm,capture:e.capture,outcome:i,reads:de(t?.reads??0,0,1e4)??0,browser:e.browser??St()},u=(s,p)=>{p!==void 0&&(c[s]=p)};return u("format",t?.format),u("framesToValid",de(t?.framesToValid,1,1e4)),u("msToValid",F(t?.msToValid)),u("framesToLock",de(t?.framesToLock,1,1e4)),u("msToLock",F(t?.msToLock)),u("msToCapture",F(e.msToCapture)),u("readP50Ms",F(t?.readP50Ms)),u("readP90Ms",F(t?.readP90Ms)),u("deviceClass",t?.deviceClass),n!==null&&(u("warmupMs",F(n.warmupMs)),u("downloadMs",F(n.downloadMs)),u("cached",n.cached)),u("stillConfirmed",e.stillConfirmed),u("typeMismatch",e.typeMismatch),c}function me(e,t){return e===void 0?!1:t==="passport"?e!=="TD3":e==="TD3"}var Mt=2;async function Dt(e){let t=await import("./capture-session-doc-FAMDLRRZ.js");return new t.CaptureSessionDoc(e)}function wt(e){return{topLeft:{x:e.x,y:e.y},topRight:{x:e.x+e.width,y:e.y},bottomRight:{x:e.x+e.width,y:e.y+e.height},bottomLeft:{x:e.x,y:e.y+e.height}}}function kt(e,t,n){let r=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft],i=0;for(let c=0;c<r.length;c+=1){let u=r[c],s=r[(c+1)%r.length];i+=u.x*s.y-s.x*u.y}return t>0&&n>0?Math.abs(i)/2/(t*n):0}function ln(){import("./capture-session-doc-FAMDLRRZ.js").then(e=>e.warmDocDetector()).catch(()=>{})}function dn(e){return Ct(e,{}).handle}function Ct(e,t){let n=we(),r=ke({enabled:e.keepScreenAwake!==!1}),i=t.decode??(o=>createImageBitmap(o)),c=t.blurRefuseSharpnessMax??.16,u=t.now??(()=>performance.now()),s=Pe(e.documentType,t.catalogCapture===!0?Ee(e.issuer,e.documentType):[]),p=s.sides.length===1||e.side==="single",d=ie(p?"singlePage":"twoSided",u());if(!p&&(e.side==="recto"||e.side==="verso")){let o=e.side==="recto"?"verso":"recto";d={...d,captured:{[o]:"server"},readSides:[o],current:e.side,phase:"flipCue",restPhase:"flipCue"}}let M="idle",f=null,_=null,k=!0,S=0,x=0,l=!1,h=!1,R="",B=null,A,O=null,X=[],W=s.mrz==="none",$e=s.barcodeSide==="recto"||s.barcodeSide==="verso"?s.barcodeSide:null,N=W&&!p?t.barcode?.side??$e:null,pe=e.barcodeAssetBaseUrl??t.barcode?.assetBaseUrl,fe=null,ge=()=>N===null||pe===void 0||t.barcode?.seen!==void 0?Promise.resolve(null):(fe??(fe=import("./barcode-detect-C5IOXMKI.js").then(o=>o.loadBarcodeDetect(pe)).catch(()=>null)),fe),Je=async(o,a)=>{if(N===null)return null;let m=N==="recto"?"verso":"recto";try{let g=t.barcode?.seen;if(g!==void 0)return await g(o)?N:m;let[L,D]=await Promise.all([ge(),a()]);if(L===null||D===null)return null;let w=Math.min(1600,D.width),y=document.createElement("canvas");y.width=w,y.height=Math.max(1,Math.round(D.height/D.width*w));try{let b=y.getContext("2d");return b===null?null:(b.drawImage(D,0,0,y.width,y.height),await Oe(L,b.getImageData(0,0,y.width,y.height),N))}finally{y.width=0,y.height=0}}catch{return null}},C=t.webOcr!==void 0&&!W?Qe(t.webOcr.captureDocument,{mode:e.liveMrz?.mode??"auto"}):null,G=null,z=C===null||!C.enabled?"off":null,Y=null,V=null,he=new WeakMap,J="";if(C!==null&&C.enabled&&t.webOcr!==void 0){let o=t.webOcr,a=Ke(C,{baseUrl:e.liveMrz?.assetBaseUrl??o.baseUrl,salt:o.salt,...e.liveMrz?.workerUrl!==void 0?{workerUrl:e.liveMrz.workerUrl}:{},...o.createWorker!==void 0?{createWorker:o.createWorker}:{}});if(a.ok){G=a.engine;let m=new Te({textLock:C.textLock,liveMrz:C.liveMrz});Y=m;let g=a.engine;g.ready.then(L=>{z=L,typeof L!="string"&&k&&m.setEngine(g)})}else z=a.reason}let U=o=>{let a=JSON.stringify(o);a!==J&&(J=a,n.emit("mrz",o))},be=(o,a)=>{let m=t.webOcr?.reports;if(m===void 0||C===null||o===void 0)return;let g=o.format==="ID-3"||o.side==="single"?"single":o.side==="verso"?"verso":"recto",L=g!=="recto"?C.liveMrzArm??C.frontLockArm:C.frontLockArm;if(L===null||Math.random()>=C.reportSampleRate)return;let D=o.via==="live_mrz"?V:null,w=()=>{let y=D?.value??null;m([je({arm:L,capture:g,assist:o.ocr??null,load:L==="control"?"off":z,...o.msToCapture!==void 0?{msToCapture:o.msToCapture}:{},...y!==null&&y.stillConfirmed!==void 0?{stillConfirmed:y.stillConfirmed}:{},...a!==void 0?{typeMismatch:me(a.format,s.format==="ID-3"?"passport":"card")}:{}})])};D!==null&&D.value===null?Promise.race([D.promise,new Promise(y=>setTimeout(y,3e3))]).then(w):w()},I=o=>{!k||o===M||(M=o,r.setActive(o==="starting"||o==="scanning"),n.emit("state",o))},Ze=(o,a)=>a===void 0?null:p?"single":o.captured.recto===a?"recto":o.captured.verso===a?"verso":null,et=o=>({phase:o.phase,captured:p?o.captured.recto!==void 0?["single"]:[]:["recto","verso"].filter(a=>o.captured[a]!==void 0),expected:p?null:o.current??null,notice:o.notice??null,lastShot:Ze(o,o.lastShot),manualShutter:o.manualShutter,torchAvailable:f?.torchAvailable()??!1,torch:h}),ye=()=>{let o=f;o!==null&&o.captureNow().catch(()=>v({type:"captureFailed",at:u()}))};function v(o){if(!k)return;let a=d;d=Ue(d,o),d.phase==="capturing"&&a.phase!=="capturing"&&Promise.resolve().then(ye),d.phase==="result"&&a.phase!=="result"&&(I("done"),Se());let m=et(d),g=JSON.stringify(m);g!==R&&(R=g,n.emit("scan",m))}function Se(){O!==null&&clearInterval(O),O=null;for(let o of X.splice(0))o();f?.destroy(),f=null,r.setActive(!1)}let Me=()=>f?.captureReport?.(),Z=!1,De=(o,a)=>{if(!(o===void 0||t.onFaceReport===void 0))try{t.onFaceReport(o,a)}catch{}},Q=o=>{J="",!(f===null||d.phase==="reading"||d.phase==="result")&&(Z=!1,f.rearm(p?"single":d.current??o))},tt=async(o,a,m,g)=>{if(V=null,g!==void 0&&G!==null&&C?.liveMrz?.hint===!0){let b={promise:Ne(G,o,g,{engine:H,detectorLimit:C.liveMrz.detectorLimit}).catch(()=>null),value:null};b.promise.then(P=>{b.value=P}),V=b}g!==void 0&&me(g.format,s.format==="ID-3"?"passport":"card")&&U({state:"mismatch",format:g.format});let L=Me();De(L,"captured"),Z=!0,be(L,g);let D=m===void 0?B:m===null?null:{quad:wt(m),frameWidth:0,frameHeight:0,inStill:!0},w={decoded:null},y=()=>(w.decoded??(w.decoded=Promise.resolve().then(()=>i(o)).catch(()=>null)),w.decoded);try{await nt(o,a,D,y,V)}finally{w.decoded!==null&&(await w.decoded)?.close()}},nt=async(o,a,m,g,L)=>{let D=`shot-${S+=1}`;if(v({type:"captured",id:D,at:u()}),e.haptics!==!1)try{globalThis.navigator?.vibrate?.(30)}catch{}if(!l&&c>0){let b=await(t.measureSharpness!==void 0?t.measureSharpness(o,m):g().then(P=>P===null?-1:Re(P,re(m?.quad??null,m?.inStill===!0?P:{width:m?.frameWidth??0,height:m?.frameHeight??0},P)))).catch(()=>-1);if(!k)return;if(Number.isFinite(b)&&b>=0&&b<c){l=!0;let P=p?"recto":d.current??(d.captured.recto===void 0?"recto":"verso");v({type:"readFailed",side:P,id:D,issue:"blurry"}),Q(P);return}}l=!1;let w;if(p)w="single";else{let b=d.current,q=(t.classify===void 0?await Je(o,g):null)??await(t.classify!==void 0?t.classify(o):g().then(K=>K===null?b??"recto":m?.inStill===!0?ue(K,480,null,!0):ue(K,480,re(m?.quad??null,{width:m?.frameWidth??0,height:m?.frameHeight??0},K)))).catch(()=>b??"recto");if(!k)return;if(d.captured[q]!==void 0&&x<Mt){x+=1,v({type:"duplicate",id:D,side:q}),Q(q==="recto"?"verso":"recto");return}w=d.captured[q]!==void 0&&b!==void 0?b:q,x=0,v({type:"classified",id:D,side:w})}let y=w==="verso"?"verso":"recto";try{let b=t.encode!==void 0?await t.encode(o):await g().then(P=>{if(P===null)throw new Error("the still could not be decoded");return oe(P)});if(!k)return;L!==null&&he.set(b.blob,L),n.emit("captured",{image:b.blob,side:w,documentType:e.documentType,...e.issuer!==void 0?{issuer:e.issuer}:{},width:b.width,height:b.height,previewDataUrl:a}),t.deferRead!==!0&&v({type:"readOk",side:y})}catch(b){v({type:"readFailed",side:y,id:D,issue:"technical"}),n.emit("error",j("generic",!0,{phase:"keyframes",name:te(b)}))}Q(y==="recto"?"verso":"recto")},rt=o=>{X.push(o.on("statechange",({state:a})=>{a==="preflight"||a==="acquiring"?I("starting"):a==="positioning"?I("scanning"):a==="captured"?I("captured"):a==="error"&&I("error")}),o.on("feedback",({key:a,reticle:m})=>n.emit("feedback",{key:a,reticle:m})),o.on("checks",a=>{n.emit("gate",{progress:a.p,quad:a.quad,frameWidth:a.frameWidth,frameHeight:a.frameHeight,...a.guide!==void 0?{guide:{detected:a.guide.detected,fill:a.guide.fill,offsetX:a.guide.offsetX??0,offsetY:a.guide.offsetY??0}}:{}});let m=a.ocr?.mrz;m!==void 0&&(m.state==="fallback"?U({state:"fallback",reason:m.reason}):m.state==="valid"?U({state:"valid",format:m.format}):m.state==="reading"?U({state:"reading",...m.format?{format:m.format}:{},...m.coach?{coach:m.coach}:{}}):U({state:"searching"}));let g=a.quad===null?0:kt(a.quad,a.frameWidth,a.frameHeight);B=a.quad===null?null:{quad:a.quad,frameWidth:a.frameWidth,frameHeight:a.frameHeight},v({type:"report",report:{present:a.quad!==null&&a.plausible||a.guide?.detected===!0,ready:a.ready===!0,locking:a.p>=.5,areaFrac:g},at:u()})}),o.on("error",({kind:a,retryable:m,detail:g})=>n.emit("error",j(a,m,g))),o.on("artifacts",a=>{tt(a.keyframe,a.previewDataUrl,a.docRegion,a.liveMrz)}))},ee=()=>(_??(_=(async()=>{if(k){if(ge(),f===null){let o;try{o=await(t.createEngine??Dt)({...t.engineOptions??{},...A!==void 0?{guide:A}:{},video:e.video,format:s.format,side:p?"single":e.side??"recto",autoCapture:!1,...Y!==null?{ocr:Y}:{}})}catch(m){I("error"),n.emit("error",j("models",!0,{phase:"models",name:te(m)}));return}if(!k){o.destroy();return}f=o,rt(o);let a=t.tickMs??500;a>0&&(O=setInterval(()=>v({type:"tick",at:u()}),a))}v({type:"clockRestart"}),C!==null&&C.liveMrzArm==="live"&&(z==="unsupported"||z==="off")&&U({state:"fallback",reason:z}),await f.start()}})().finally(()=>{_=null})),_);return{handle:{get state(){return M},on:(o,a)=>n.on(o,a),start:ee,retry:()=>{if(f===null&&d.phase==="result"){v({type:"retake"}),x=0,l=!1,ee();return}if(f!==null&&M!=="error"){v({type:"retake"}),x=0,l=!1,f.rearm(p?"single":void 0);return}ee()},setSide:o=>{p||o==="single"||(d.current!==o&&(d={...d,current:o}),v({type:"clockRestart"}),d.phase!=="reading"&&d.phase!=="result"&&f?.rearm(o))},shutter:ye,focusAt:(o,a)=>{f?.focusAt?.(o,a)},setGuide:o=>{A=o,f?.setGuide?.(o)},setTorch:o=>{h=o,f?.setTorch(o),v({type:"tick",at:u()})},destroy:()=>{if(k&&f!==null&&M!=="done"){let o=Me();!Z&&o!==void 0&&o.ticks>0&&De(o,"abandoned"),be(o,void 0)}k=!1,Se(),Y?.setEngine(null),G?.dispose(),G=null,n.clear()}},setFlowState:o=>{(d.phase==="reading"||d.phase==="result")&&I(o==="done"&&d.phase!=="result"?"scanning":o)},settle:(o,a)=>{let m=o==="verso"?"verso":"recto";v(a.ok?{type:"readOk",side:m}:{type:"readFailed",side:m,issue:a.issue}),a.ok||Q(m)},takeDeviceRead:o=>he.get(o.image)?.value??null}}export{Et as a,At as b,Bt as c,It as d,Ft as e,Wt as f,Ie as g,ie as h,Ue as i,gt as j,ht as k,Ut as l,Ne as m,Gt as n,H as o,Qe as p,Ke as q,St as r,je as s,me as t,Mt as u,ln as v,dn as w,Ct as x};
@@ -0,0 +1 @@
1
+ import{c as f}from"./chunk-TSA6GHUG.js";import{a as _,c as m}from"./chunk-NO22WG7R.js";var w=["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","native_app_required"];function q(n){return w.includes(n)}var u=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 b(n,e,s=Math.random){let t=(n??e)*1e3,o=Math.min(Math.max(t,500),2e4),i=Math.round(o*(1+(s()*2-1)*.25));return Math.min(Math.max(i,500),2e4)}var R=6e4,g=4,P=3e4,E=9e5,I=200,M=5,C=400,A=new Set(["server_busy","request_timeout"]),v=20,O=60,N=600,H=2;function l(n){return(n.split(";")[0]??"").trim()}var x={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},U=`@sekyro/web/${_}`,D=U,T=class{constructor(e){this.sessionId=null;this.bootstrap=null;this.captureNonces=[];this.captureFetch=null;this.reportedIssues=new Map;this.issueReports=0;this.issuesPausedUntil=0;this.apiOrigin=e.apiOrigin.replace(/\/+$/,""),this.sessionToken=e.sessionToken;let s=e.fetch;this.fetchImpl=(t,o)=>(s??globalThis.fetch).call(globalThis,t,o),this.requestTimeoutMs=e.requestTimeoutMs??P,this.retryAttempts=e.inProgressRetry?.attempts??M,this.retryDelayMs=e.inProgressRetry?.delayMs??C,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 testerGate(e){return this.api("POST","/hosted/tester-gate",{body:{input:e}})}async reportCaptureIssue(e){let s=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,o=typeof e.attempt=="number"&&Number.isInteger(e.attempt)&&e.attempt>=0&&e.attempt<=1e3?e.attempt:void 0,i=e.check==="attestation"?o??"":"",a=[e.check,i,e.kind,s,e.phase??"",t??""].join("|"),d=this.reportedIssues.get(a);if(d!==void 0)return d;if(Date.now()<this.issuesPausedUntil||this.issueReports>=v)return;let r={check:e.check,kind:e.kind,...s!==""?{name:s}:{},...e.phase!==void 0?{phase:e.phase}:{},...t!==void 0?{engineKind:t}:{},...o!==void 0?{attempt:o}:{},...e.formFactor!==void 0?{formFactor:e.formFactor}:{},...typeof e.detail=="string"&&/^\d{1,10}$/.test(e.detail)?{detail:e.detail}:{},...k(e.challengeMs)?{challengeMs:e.challengeMs}:{},...k(e.readyMs)?{readyMs:e.readyMs}:{},...e.inApp===!0?{inApp:!0}:{}};this.issueReports+=1;let p=this.api("POST","/hosted/capture-issue",{body:r,empty:!0}).catch(c=>{if(c instanceof u&&c.status===429){let y=Math.min(Math.max(c.retryAfterSeconds??O,0),N);this.issuesPausedUntil=Math.max(this.issuesPausedUntil,Date.now()+y*1e3);return}(!(c instanceof u)||c.status===0||c.status>=500)&&this.reportedIssues.delete(a)});return this.reportedIssues.set(a,p),p}async choose(e,s){let t=await this.api("POST","/hosted/choice",{body:{nodeId:e,option:s},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,s,t,o={}){let i=await this.ensureSessionId(),a={kind:e,contentType:l(s),contentLength:t,...o.source==="upload"?{source:"upload"}:{}};return this.api("POST",`/sessions/${i}/media`,{body:a})}armCapture(e=2){this.fillCaptureNonces(e)}async presignCapture(e,s,t,o={}){let i=await this.ensureSessionId(),a=await this.takeCaptureNonce(),d=a===void 0?void 0:{nonce:a,...o.engine!==void 0?{engine:o.engine.slice(0,32)}:{},...o.durationMs!==void 0&&Number.isFinite(o.durationMs)?{captureMs:Math.min(36e5,Math.max(0,Math.round(o.durationMs)))}:{}},r={kind:e,contentType:l(s),contentLength:t,capture:d};return this.api("POST",`/sessions/${i}/media`,{body:r})}async takeCaptureNonce(){let e=()=>{let s=Date.now();return this.captureNonces=this.captureNonces.filter(t=>t.expiresAt-R>s),this.captureNonces.shift()?.nonce};for(let s=0;s<2;s++){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 s=await this.ensureSessionId(),t=await this.api("POST",`/sessions/${s}/media/capture-nonces`,{body:{count:Math.min(g,Math.max(1,e))}}),o=Date.now()+Math.max(0,t.expiresIn)*1e3;for(let i of Array.isArray(t.nonces)?t.nonces:[])typeof i=="string"&&i.length>0&&this.captureNonces.push({nonce:i,expiresAt:o});this.captureNonces=this.captureNonces.slice(-g)}catch{}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(e,s,t){let o;try{o=await this.fetchImpl(e,{method:"PUT",headers:{"content-type":l(t)},body:s,signal:AbortSignal.timeout(E)})}catch(i){throw h(i)}if(!o.ok){let i=(await o.text().catch(()=>"")).slice(0,I);throw new u({status:o.status,code:"upload_failed",message:`media upload failed (HTTP ${o.status})${i?`: ${i}`:""}`})}}async completeMedia(e){let s=await this.ensureSessionId();return this.api("POST",`/sessions/${s}/media/complete`,{body:{key:e}})}async submitCheck(e,s,t={}){let o=await this.ensureSessionId(),i={input:s,forceOutcome:t.forceOutcome};return this.api("POST",`/sessions/${o}/checks/${e}`,{body:i,idempotencyKey:t.idempotencyKey,...t.browserCheckToken!==void 0?{browserCheckToken:t.browserCheckToken}:{},busyRetry:t.idempotencyKey!==void 0})}async uploadAndSubmit(e,s,t,o={}){let i=l(s.contentType),a=await this.presign(s.kind,i,s.blob.size);await this.uploadToSpaces(a.uploadUrl,s.blob,i);let d=await this.completeMedia(a.key),r={...t,[x[e]]:d.key};return this.submitCheck(e,r,o)}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,s,t={}){let o=e==="GET"||t.busyRetry===!0,i=`${this.apiOrigin}/api/v2${s}`,a={"x-session-token":this.sessionToken,"x-sekyro-sdk":D};t.body!==void 0&&(a["content-type"]="application/json"),t.idempotencyKey!==void 0&&(a["x-idempotency-key"]=t.idempotencyKey),t.browserCheckToken!==void 0&&(a["sekyro-browser-check"]=t.browserCheckToken);try{let d=m.timezone();d!==void 0&&(a["sekyro-client-timezone"]=d)}catch{}a["sekyro-client-form-factor"]=f();try{let d=await m.deviceHeader();d!==void 0&&(a["sekyro-client-device"]=d)}catch{}for(let d=0;;d++){let r;try{r=await this.fetchImpl(i,{method:e,headers:a,...t.body!==void 0?{body:JSON.stringify(t.body)}:{},cache:"no-store",signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(c){throw h(c)}if(r.ok){if(t.empty===!0)return;if(t.blob===!0)try{return await r.blob()}catch(y){throw h(y)}let c;try{c=await r.json()}catch{throw new u({status:r.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${r.status})`})}return K(c)}let p=await V(r);if(p.code==="idempotency_in_progress"&&d<this.retryAttempts){this.retryDelayMs>0&&await S(this.retryDelayMs);continue}if(o&&p.status===503&&A.has(p.code)){o=!1,await S(b(p.retryAfterSeconds,H,this.random));continue}throw p}}};function k(n){return typeof n=="number"&&Number.isInteger(n)&&n>=0&&n<=6e5}function h(n){if((typeof n=="object"&&n!==null?n.name:void 0)==="TimeoutError")return new u({status:0,code:"timeout",message:"request timed out"});let s=n instanceof Error?n.message:String(n);return new u({status:0,code:"network_error",message:`network request failed: ${s}`})}function K(n){return n!==null&&typeof n=="object"&&"success"in n&&"data"in n?n.data:n}async function V(n){let e="unknown_error",s=`request failed (HTTP ${n.status})`,t=Number.NaN,o;try{let d=await n.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&&(s=r.message),typeof r.retryAfterSeconds=="number"&&(t=r.retryAfterSeconds),Array.isArray(r.details?.issues)?o=r.details:Array.isArray(r.details?.errors)&&(o={...r.details,issues:[]})}}catch{}let i=n.headers.get("retry-after"),a=i===null?Math.floor(t):Number.parseInt(i,10);return new u({status:n.status,code:e,message:s,...Number.isFinite(a)&&a>=0?{retryAfterSeconds:a}:{},details:o})}function S(n){return new Promise(e=>setTimeout(e,n))}function z(n){let e=n?.portrait,s=e?.icao,t=e?.purpose==="id_document";return s==null?t?{policy:"reject",profile:"id_document"}:null:{policy:s.policy==="alert"?"alert":"reject",profile:t||s.profile==="id_document"?"id_document":"selfie"}}function X(n){return{...n.baselineEyeOpenness!==void 0?{baselineEyeOpenness:n.baselineEyeOpenness}:{},...n.baselineEyeOpennessLeft!==void 0&&n.baselineEyeOpennessRight!==void 0?{baselineEyeOpennessLeft:n.baselineEyeOpennessLeft,baselineEyeOpennessRight:n.baselineEyeOpennessRight}:{},criteria:n.verdict??{},...n.backgroundCheck!==void 0?{backgroundCheck:n.backgroundCheck}:{}}}export{w as a,q as b,u as c,b as d,l as e,U as f,T as g,z as h,X as i};
@@ -1,3 +1,3 @@
1
- import{B as ft,C as mt,D as ht,E as yt,a as ot,b as rt,c as it,d as Z,e as J,f as re,g as st,h as K,i as at,j as I,k as j,l as T,m as D,n as U,o as X,p as ut,q as z,r as ie,s as ct,t as dt,u as lt,v as pt}from"./chunk-SUANHBF4.js";import{n as et}from"./chunk-6ERQTXMY.js";import{a as ze}from"./chunk-7QZWBDI5.js";import{c as G,e as tt,g as nt,h as se}from"./chunk-OUC57KMS.js";import{c as Je,d as _e}from"./chunk-TSA6GHUG.js";import{b as Xe}from"./chunk-MD4YXLPK.js";function ae(e){return e.idNumberBound??e.nniBound}function ee(e){return e===void 0?void 0:e.idNumberFromDocument??e.nniFromDocument}function gt(e){let t=e.idNumberMasked??e.nniMasked;return typeof t=="string"&&t!==""?t:void 0}var Jt="https://api.sekyro.ai",Xt=5e3,zt=24e4,en=9e4,tn=25*6e4,nn=20*6e4,on=3,rn=3e3,sn=1500,an=10;function St(e){return e instanceof Error&&e.name==="ChallengeError"&&e.code||"challenge_failed"}var _t=new Set(["aborted","embedder_opaque","site_key_rejected"]);function un(e){return new Promise(t=>setTimeout(t,e))}function cn(){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 wo(e){return dn(e,{})}function dn(e,t){let n=e.apiOrigin??Jt,i=e.autoRetry??!0,r=e.rearm??"auto",u=t.client??new nt({apiOrigin:n,sessionToken:e.clientToken,fetch:e.fetch}),a=new Proxy(u,{get(o,s){if(s==="submitCheck")return Ut;let c=Reflect.get(o,s,o);return typeof c=="function"?c.bind(o):c}}),d=t.sleep??un,h=t.uuid??cn,_=t.getChallengeToken??((o,s)=>import("./challenge-frame-YAQJ5YMB.js").then(c=>c.executeChallenge({frameUrl:o.url,siteKey:o.siteKey,action:"liveness",subject:s.subject,signal:s.signal}))),S=ze(),P=null,g=null,m=!1,M=new AbortController,y=null,ce=null,te=null,ne=()=>te??ct(y),Re=()=>dt(ie(y),ne()),O=o=>{y=o,!I(o)&&(Be(nn)||Lt(o))&&Se(o),S.emit("view",o),P?.onView(o)},A=()=>y!==null?Promise.resolve(y):(ce??(ce=a.getSession().then(o=>(O(o),o)).finally(()=>{ce=null})),ce),E=async()=>{let o=await a.getSession();return O(o),o},de=async(o,s)=>{o.plan!==void 0?O(o):await E()},le=null,Ie=async o=>{let s=await A();if(o||!s.consentRecorded){let c=await a.recordConsent(e.locale);c.plan!==void 0?O(c):y!==null&&O({...y,consentRecorded:!0})}oe()&&Se(s)},N=o=>o?.force===!0?Ie(!0):(le??(le=Ie(!1).finally(()=>{le=null})),le),pe={client:a,ensureConsent:o=>N(o),sleep:d,uuid:h,...t.random!==void 0?{random:t.random}:{},onBusy:o=>{m||S.emit("busy",o)}},Me=!1,Oe=null,fe=o=>{if(o.status==="verified"||o.status==="not_verified"||o.status==="review"){if(Me)return;Me=!0}Oe=JSON.stringify(o),S.emit("result",o)},Nt=o=>{Oe!==JSON.stringify(o)&&fe(o)},Ee=async o=>{let s=y;o&&(s=await E().catch(()=>y));let c=s===null?null:K(s);return c!==null&&!m&&S.emit("method",c),c!==null},ve=null,Te=!1,Ve=!1,Ne=()=>mt(pe,(o,s)=>o.submitCheck("population_registry",{},{idempotencyKey:s})),Fe=o=>ae(o)===!0||ee(T(o,"population_registry"))===!0,Ft=async()=>{try{let o=await A();if(I(o)||K(o)!==null||j(o)?.checkType!=="population_registry")return;if(!Fe(o)&&ee(T(o,"population_registry"))===void 0&&(o=await E()),!Fe(o)){Ve=!0;return}await N(),await de(await Ne(),"population_registry");let s=y===null?void 0:T(y,"population_registry");if(s?.state==="input_required"&&s.reason==="registry_unavailable"&&re(s)>0){if(await d(Xt),m)return;await de(await Ne(),"population_registry")}}catch(o){if(o instanceof G&&(o.code==="check_not_active"||o.code==="step_not_on_path")){await E().catch(()=>{});return}Te=!0;return}y!==null&&I(y)&&fe(X(y,{autoRetry:i}))},He=()=>(ve??(ve=Ft()),ve),v=t.now??Date.now,q=null,Y,me,Ht=0,he=(o,s)=>`${o.url}
1
+ import{B as ft,C as mt,D as ht,E as yt,a as ot,b as rt,c as it,d as Z,e as J,f as re,g as st,h as K,i as at,j as I,k as j,l as T,m as D,n as U,o as X,p as ut,q as z,r as ie,s as ct,t as dt,u as lt,v as pt}from"./chunk-HFRU66NW.js";import{n as et}from"./chunk-B5H5ED6O.js";import{a as ze}from"./chunk-7QZWBDI5.js";import{c as G,e as tt,g as nt,h as se}from"./chunk-YDG77RHN.js";import{c as Je,d as _e}from"./chunk-TSA6GHUG.js";import{b as Xe}from"./chunk-NO22WG7R.js";function ae(e){return e.idNumberBound??e.nniBound}function ee(e){return e===void 0?void 0:e.idNumberFromDocument??e.nniFromDocument}function gt(e){let t=e.idNumberMasked??e.nniMasked;return typeof t=="string"&&t!==""?t:void 0}var Jt="https://api.sekyro.ai",Xt=5e3,zt=24e4,en=9e4,tn=25*6e4,nn=20*6e4,on=3,rn=3e3,sn=1500,an=10;function St(e){return e instanceof Error&&e.name==="ChallengeError"&&e.code||"challenge_failed"}var _t=new Set(["aborted","embedder_opaque","site_key_rejected"]);function un(e){return new Promise(t=>setTimeout(t,e))}function cn(){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 wo(e){return dn(e,{})}function dn(e,t){let n=e.apiOrigin??Jt,i=e.autoRetry??!0,r=e.rearm??"auto",u=t.client??new nt({apiOrigin:n,sessionToken:e.clientToken,fetch:e.fetch}),a=new Proxy(u,{get(o,s){if(s==="submitCheck")return Ut;let c=Reflect.get(o,s,o);return typeof c=="function"?c.bind(o):c}}),d=t.sleep??un,h=t.uuid??cn,_=t.getChallengeToken??((o,s)=>import("./challenge-frame-YBTLAQ5G.js").then(c=>c.executeChallenge({frameUrl:o.url,siteKey:o.siteKey,action:"liveness",subject:s.subject,signal:s.signal}))),S=ze(),P=null,g=null,m=!1,M=new AbortController,y=null,ce=null,te=null,ne=()=>te??ct(y),Re=()=>dt(ie(y),ne()),O=o=>{y=o,!I(o)&&(Be(nn)||Lt(o))&&Se(o),S.emit("view",o),P?.onView(o)},A=()=>y!==null?Promise.resolve(y):(ce??(ce=a.getSession().then(o=>(O(o),o)).finally(()=>{ce=null})),ce),E=async()=>{let o=await a.getSession();return O(o),o},de=async(o,s)=>{o.plan!==void 0?O(o):await E()},le=null,Ie=async o=>{let s=await A();if(o||!s.consentRecorded){let c=await a.recordConsent(e.locale);c.plan!==void 0?O(c):y!==null&&O({...y,consentRecorded:!0})}oe()&&Se(s)},N=o=>o?.force===!0?Ie(!0):(le??(le=Ie(!1).finally(()=>{le=null})),le),pe={client:a,ensureConsent:o=>N(o),sleep:d,uuid:h,...t.random!==void 0?{random:t.random}:{},onBusy:o=>{m||S.emit("busy",o)}},Me=!1,Oe=null,fe=o=>{if(o.status==="verified"||o.status==="not_verified"||o.status==="review"){if(Me)return;Me=!0}Oe=JSON.stringify(o),S.emit("result",o)},Nt=o=>{Oe!==JSON.stringify(o)&&fe(o)},Ee=async o=>{let s=y;o&&(s=await E().catch(()=>y));let c=s===null?null:K(s);return c!==null&&!m&&S.emit("method",c),c!==null},ve=null,Te=!1,Ve=!1,Ne=()=>mt(pe,(o,s)=>o.submitCheck("population_registry",{},{idempotencyKey:s})),Fe=o=>ae(o)===!0||ee(T(o,"population_registry"))===!0,Ft=async()=>{try{let o=await A();if(I(o)||K(o)!==null||j(o)?.checkType!=="population_registry")return;if(!Fe(o)&&ee(T(o,"population_registry"))===void 0&&(o=await E()),!Fe(o)){Ve=!0;return}await N(),await de(await Ne(),"population_registry");let s=y===null?void 0:T(y,"population_registry");if(s?.state==="input_required"&&s.reason==="registry_unavailable"&&re(s)>0){if(await d(Xt),m)return;await de(await Ne(),"population_registry")}}catch(o){if(o instanceof G&&(o.code==="check_not_active"||o.code==="step_not_on_path")){await E().catch(()=>{});return}Te=!0;return}y!==null&&I(y)&&fe(X(y,{autoRetry:i}))},He=()=>(ve??(ve=Ft()),ve),v=t.now??Date.now,q=null,Y,me,Ht=0,he=(o,s)=>`${o.url}
2
2
  ${o.siteKey}
3
- ${s}`,Le=0,ye,ge=(o,s)=>{Le+=1;let c=v(),f=_(o,{signal:M.signal,subject:s}),p={key:he(o,s),at:c,token:f};return f.then(()=>{p.issuedAt=v(),me=void 0},k=>{let C=St(k);if(p.failed=C,m||C==="aborted")return;me=C;let{detail:w,readyMs:l}=k;W({check:"attestation",kind:"unavailable",engineKind:C,attempt:Ht++,challengeMs:v()-c,readyMs:l,detail:w,inApp:Xe()})}),f.catch(()=>{}),p},De=(o,s)=>o!==null&&o.key===s&&(o.issuedAt===void 0||v()-o.issuedAt<zt),Se=(o,s={})=>{let c=o?.challenge??null;if(o===null||c===null||m)return;let f=D(o.sessionId),p=q;(s.replaceFailed===!0&&p?.failed!==void 0&&!_t.has(p.failed)||!De(p,he(c,f)))&&(q=ge(c,f))},Ue=async(o,s)=>{let c=he(o,s),f=q;q=null;let p=De(f,c)?f:ge(o,s),k=p===f?0:1,C,w=new Promise(l=>{C=setTimeout(()=>l("late"),en)});try{for(;;){let l=await Promise.race([p.token.then(x=>({token:x}),x=>({error:St(x)})),w]);if(l==="late")return!m&&q===null&&(q=p),{error:me??"timeout"};if("token"in l)return ye=Math.max(0,Math.round((p.issuedAt??v())-p.at)),l;if(m||_t.has(l.error)||k>=on||k>0&&await Promise.race([d(rn*k),w])==="late")return l;if(m)return{error:"aborted"};k+=1,p=ge(o,s)}}finally{clearTimeout(C)}},H=null,Lt=o=>J(o).some(s=>(s.checkType==="phone_otp"||s.checkType==="email_otp")&&s.state!=="passed"&&s.state!=="skipped"),Be=o=>H===null||v()-H>=o,oe=()=>Be(tn),Dt=o=>{let s=o.attestation;return typeof s?.turnstileToken=="string"&&s.turnstileToken.length>0},qe=new Map,Ge=async()=>{let o=await A(),s=o.challenge;if(s==null||o.simulation!==void 0)return;let c=await Ue(s,D(o.sessionId));if(!("token"in c))throw new G({status:400,code:"attestation_invalid",message:`browser check: ${c.error}`});return c.token},Ut=async(o,s,c={})=>{let f=s;if("attestation"in f)try{let l=await u.submitCheck(o,s,c);return Dt(f)&&(H=v()),l}catch(l){throw l instanceof G&&l.code==="attestation_invalid"&&(H=null),l}let p=(o==="phone_otp"||o==="email_otp")&&f.action!=="verify",k=c.idempotencyKey,C=k!==void 0?qe.get(k):void 0;C===void 0&&(p||oe())&&(C=await Ge(),k!==void 0&&C!==void 0&&qe.set(k,C));let w=(l,x)=>l!==void 0?{...x,browserCheckToken:l}:x;try{let l=await u.submitCheck(o,s,w(C,c));return C!==void 0&&(H=v()),l}catch(l){if(!(l instanceof G)||l.code!=="attestation_invalid"||(H=null,C!==void 0))throw l;let x=await Ge(),L=k!==void 0?{...c,idempotencyKey:h()}:c,F=await u.submitCheck(o,s,w(x,L));return x!==void 0&&(H=v()),F}},Ke=async(o={})=>{if(Y=void 0,o.always!==!0&&!oe())return{};let s=await A(),c=s.challenge;if(c==null)return{};let f=await Ue(c,D(s.sessionId));if("token"in f)return{channel:"hosted_web",turnstileToken:f.token};if(Y=f.error,s.simulation!==void 0)return{channel:"hosted_web"};throw new ft(f.error)},Bt=()=>Y,qt=()=>({checks:Math.min(50,Le),...ye!==void 0?{challengeMs:Math.min(6e5,ye)}:{}}),W=o=>{if(m)return;let s=a.reportCaptureIssue;if(s===void 0)return;let c=o.formFactor;try{c??(c=Je())}catch{}try{Promise.resolve(s.call(a,{...o,...c!==void 0?{formFactor:c}:{}})).catch(()=>{})}catch{}},R=null,$=null,je=new WeakMap,Ye=Promise.resolve(),Q=0,Gt=async()=>{let o=await A();for(let s=0;s<an&&!m&&!I(o)&&j(o)===void 0&&J(o).some(c=>c.state==="processing")&&(await d(sn),!m);s+=1)o=await E();return o},Kt=async(o,s,c)=>{let{capture:f}=o,p=()=>m,k=()=>o.alive&&o.attempt===c,C=l=>{k()&&f.setFlowState(l)},w=l=>{if(!p()&&(l.status==="unavailable"&&l.reasonCode!==void 0&&!ot(l.reasonCode)&&W({check:"liveness",kind:"unavailable",phase:"upload",engineKind:l.reasonCode,attempt:Math.max(0,o.issues.value)}),fe(l),!!k())){if(l.status==="retry"&&r==="auto"){f.handle.retry();return}f.setFlowState("done")}};if(s.degraded==="NO_RECORDER"){let l=y?.sessionId??(await A().catch(()=>null))?.sessionId??"";w(U(l,"no_recorder"));return}C("uploading");try{if(await He(),p())return;let l=await A(),x;if(!I(l)&&K(l)!==null){await Ee(!1),w(U(l.sessionId,"method_required"));return}if(!I(l)){if(j(l)?.checkType==="population_registry"){w(U(l.sessionId,Ve?"nni_unbound":Te?"network":"registry_unavailable"));return}if(await N(),p())return;x=y??l;let L=await ht({...pe,artifacts:s,getAttestation:Ke,attestationError:Bt,attestationFacts:qt,clipKeys:{get:()=>je.get(s)??null,set:F=>{je.set(s,F)}},getView:()=>y??l,refreshView:E,applySubmit:de,onPhase:C,isCancelled:p,onKeyframePromoted:F=>{g=F}});if(p())return;if(L.kind==="unavailable"){L.reason==="attestation"&&($={bound:o,artifacts:s});let F=U(l.sessionId,L.reason),Ze=L.reason==="attestation"?Y:void 0;w(Ze!==void 0?{...F,attestationError:Ze}:F);return}if(L.kind==="resync"&&await E(),y!==null&&K(y)!==null){await Ee(!1),w(U(l.sessionId,"method_required"));return}l=await Gt()}w(X(l,{autoRetry:i,previous:x}))}catch{if(p())return;w(U(y?.sessionId??"","network"))}},We=(o,s)=>{let c=o.attempt;Q>0&&o.alive&&o.capture.setFlowState("uploading"),Q+=1,Ye=Ye.then(()=>Kt(o,s,c)).finally(()=>{Q-=1,Q===0&&P?.onChainIdle()}).catch(()=>{})},$e=o=>{R?.capture.handle.destroy(),R!==null&&(R.alive=!1);let s=et(o,P?.captureInternals?.(o)??t.capture,()=>y?.capture?.liveness?.keyframe?.rank===!0,Re,()=>y?.capture?.liveness?.screenRamp,{session:()=>ie(y),onModeChange:p=>{te=p}}),c={capture:s,alive:!0,attempt:0,issues:it()};R=c,s.handle.on("error",p=>{W(rt("liveness",p,c.issues.value))}),s.handle.on("state",p=>{if(c.issues.note(p),p==="starting"){c.attempt+=1,$?.bound===c&&($=null),oe()&&Se(y,{replaceFailed:!0});let k=y===null?void 0:j(y)?.checkType;(k==="liveness"||k==="face_match")&&N().catch(()=>{})}}),s.handle.on("captured",p=>{Promise.resolve().then(()=>We(c,p))});let f=s.handle;return{get state(){return f.state},get captureMode(){return f.captureMode},get facingMode(){return f.facingMode},on:(p,k)=>f.on(p,k),start:async p=>{if(y===null&&await A().catch(()=>{}),!!c.alive)return f.start(p)},retry:()=>{let p=$;if(p!==null&&p.bound===c&&c.alive){$=null,We(c,p.artifacts);return}f.retry()},switchCamera:()=>f.switchCamera(),canSwitchCaptureMode:()=>f.canSwitchCaptureMode(),setCaptureMode:p=>f.setCaptureMode(p),destroy:()=>{c.alive=!1,R===c&&(R=null),f.destroy()}}},jt=async()=>{if(m)return null;try{let o=await A();return m?null:K(o)}catch{return null}},Yt=async()=>{if(m)return"self";try{let o=await A();if(m)return"self";let s=ie(o);return s==="choice"?ne()??s:s}catch{return"self"}},Wt=async()=>{if(m)return!1;try{let o=await A();return m||I(o)||_e()?!1:z(o,j(o))==="phone"||z(o,T(o,"liveness"))==="phone"}catch{return!1}},$t=async()=>{if(m)return!1;try{let o=await A();return!m&&o.returning===!0}catch{return!1}},Qt=async o=>{let s=(await A()).plan?.choice,c=s?.options.find(p=>Z[p.service]===o);if(!c)throw new RangeError(`method ${String(o)} is not offered`);let f=await a.choose(s.nodeId,c.id);m||O(f)},Qe=null,Zt=()=>(Qe??(Qe=import("./plan-runner-T2ZTSBI4.js").then(o=>{let s=o.createPlanRunner({runtime:pe,currentView:()=>y,cameraMode:Re,captureModeSwitch:{pick:ne,choose:c=>{te=c}},ensureView:A,refreshView:E,ensureConsent:()=>N(),liveness:$e,stopLiveness:()=>{R!==null&&(R.alive=!1,R.capture.handle.destroy(),R=null)},chainBusy:()=>Q>0,destroyed:()=>m,sleep:d,isMobile:_e,now:t.now??Date.now,keptFaceKey:()=>g,setView:O,baseCapture:t.capture,emitStep:c=>{m||S.emit("step",c)},emitResult:Nt,reportCaptureIssue:W,documentInternals:t.document,portraitInternals:t.portrait,livePhotoInternals:t.livePhoto,uploadInternals:t.upload,pageCameraInternals:t.pageCamera});return P=s,s})),Qe);return{consent:()=>N(),startRegistry:He,methodChoice:jt,selectMethod:Qt,reportCameraUnavailable:async o=>{await N();let s=a.reportCameraUnavailable;if(s===void 0)throw new TypeError("this client cannot report a missing camera");let c=await s.call(a,o).catch(f=>{if(f instanceof G&&f.code==="check_out_of_order")return a.getSession();throw f});m||O(c)},reportCaptureIssue:W,testerGate:async o=>{let s=a.testerGate;if(s===void 0)throw new TypeError("this client cannot run the tester gate");let c=o.clip,f=tt(o.clipMime??"");if(c===void 0||!pt.includes(f))throw new TypeError("the capture has no clip");await N();let p=await lt(a,"clip",f,c.size,{engine:o.engine,durationMs:o.clipMs});await a.uploadToSpaces(p.uploadUrl,c,f);let{key:k}=await a.completeMedia(p.key),C=await Ke({always:!0}),w=await s.call(a,{clipKey:k,attestation:C,captureChannel:o.captureChannel,capture:{...yt(o),attestationError:Y}}),{bound:l,...x}=w;return m||(x.plan!==void 0?O(x):await E()),{bound:l===!0}},mobileRequired:Wt,captureMode:Yt,chooseCaptureMode:o=>{te=o},get captureChoice(){return ne()},returning:$t,liveness:$e,run:async()=>{if(m)throw new Error("verification destroyed");return(await Zt()).run()},currentStep:()=>P?.current()??null,voiceClips:async()=>{if(m)return null;try{let o=await A();return m?null:o.voice??null}catch{return null}},on:(o,s)=>S.on(o,s),destroy:()=>{m=!0,M.abort(),P?.destroy(),R!==null&&(R.alive=!1,R.capture.handle.destroy(),R=null),S.clear()}}}var kt=["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 ln=["carte_identite","passport","residence_permit","drivers_license"],pn=["carte_identite","passport","residence_permit"];function fn(e,t){let n=e.byIssuer?.[t]??e.default;return ln.filter(i=>n==="*"?pn.includes(i):n.includes(i))}function Ro(e,t=kt){return[...new Set([...t,...Object.keys(e.byIssuer??{})])].filter(i=>fn(e,i).length>0).sort()}function Ct(e){if(e.acceptedDocuments)return e.acceptedDocuments;let t=e.acceptedDocumentTypes?.length?[...e.acceptedDocumentTypes]:["carte_identite","passport"];return{default:[],byIssuer:{MR:t}}}function Io(e){return/^[A-Z]{2}$/.test(e)?String.fromCodePoint(...[...e].map(t=>127462+t.charCodeAt(0)-65)):""}var b={fullNameMin:2,fullName:200,email:254,occupation:120,shortText:120,longText:1e3,addressLine:120,addressLines:4,city:80,postcode:16,number:1e12,dateMin:"1900-01-01",dateMax:"2100-12-31"},mn=new Set(["full_name","birth_date","email","phone","address","country","occupation"]),hn=new Set(["short_text","long_text","single_choice","multiple_choice","yes_no","date","number"]),yn=new Set(["ar","fa","he","ur"]);function bt(e){return yn.has(e.split("-")[0]?.toLowerCase()??"")?"rtl":"ltr"}function wt(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.locale!="string"||!Array.isArray(t.questions)||t.questions.length===0)return null;let n=t.consents??[];if(!Array.isArray(n))return null;for(let r of t.questions)if(!gn(r))return null;for(let r of n)if(!Sn(r))return null;let i={locale:t.locale,questions:t.questions,consents:n};return typeof t.title=="string"&&t.title.trim()!==""&&(i.title=t.title),typeof t.intro=="string"&&t.intro.trim()!==""&&(i.intro=t.intro),typeof t.prefill=="object"&&t.prefill!==null&&!Array.isArray(t.prefill)&&(i.prefill=t.prefill),i}function gn(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.id!="string"||typeof t.required!="boolean"?!1:t.kind==="field"?typeof t.field=="string"&&mn.has(t.field):t.kind!=="custom"||typeof t.type!="string"||!hn.has(t.type)||typeof t.label!="string"?!1:t.type==="single_choice"||t.type==="multiple_choice"?Array.isArray(t.choices)&&t.choices.length>=2&&t.choices.every(n=>typeof n=="object"&&n!==null&&typeof n.value=="string"&&typeof n.label=="string"):!0}function Sn(e){if(typeof e!="object"||e===null)return!1;let t=e;if(typeof t.id!="string"||typeof t.required!="boolean"||typeof t.text!="string")return!1;if(t.link===void 0)return!0;let n=t.link;return typeof n=="object"&&n!==null&&typeof n.url=="string"&&/^https:\/\//.test(n.url)&&typeof n.label=="string"}var _n=/^(\d{4})-(\d{2})-(\d{2})$/;function kn(e){if(typeof e!="string")return!1;let t=_n.exec(e);return t===null?!1:new Date(Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3]))).toISOString().slice(0,10)===e&&e>=b.dateMin&&e<=b.dateMax}function Cn(e){return typeof e=="number"&&Number.isFinite(e)&&Math.abs(e)<b.number&&Math.round(e*100)/100===e}function At(e){for(let t of e.matchAll(/\d[\d -]{11,}\d/g)){let n=t[0].replace(/[ -]/g,"");if(n.length>=13&&n.length<=19&&bn(n))return!0}return!1}function bn(e){let t=0;for(let n=0;n<e.length;n++){let i=Number(e[e.length-1-n]);n%2===1&&(i*=2,i>9&&(i-=9)),t+=i}return t%10===0}var wn=/^[^\s@]+@[^\s@.]+(\.[^\s@.]+)+$/,An=/^\+[1-9]\d{6,14}$/,xt=/^[A-Z]{2}$/,xn=e=>e===void 0||typeof e=="string"&&e.trim()===""||Array.isArray(e)&&e.length===0;function Pn(e=Date.now()){return new Date(e).toISOString().slice(0,10)}function Oo(e,t,n=Pn()){let i=[];for(let r of e.questions){let u=t.answers[r.id];if(xn(u)){r.required&&i.push({id:r.id,code:"required"});continue}let a=r.kind==="field"?Rn(r.field,u,n):Mn(r,u,n);a!==null&&i.push({id:r.id,...a})}for(let r of e.consents)r.required&&t.consents[r.id]!==!0&&i.push({id:r.id,code:"consent_required"});return i}function ue(e,t,n=1){if(typeof e!="string")return{code:"required"};let i=e.trim();return[...i].length>t?{code:"too_long",params:{max:t}}:[...i].length<n?{code:"too_short",params:{min:n}}:At(i)?{code:"card_number"}:null}function Pt(e,t,n={}){return kn(e)?n.period==="past"&&e>=t?{code:"date_not_past"}:n.period==="future"&&e<=t?{code:"date_not_future"}:n.min!==void 0&&e<n.min?{code:"date_too_early",params:{date:n.min}}:n.max!==void 0&&e>n.max?{code:"date_too_late",params:{date:n.max}}:null:{code:"date_invalid"}}function Rn(e,t,n){switch(e){case"full_name":return ue(t,b.fullName,b.fullNameMin);case"occupation":return ue(t,b.occupation);case"birth_date":return Pt(t,n,{period:"past"});case"email":return typeof t=="string"&&t.trim().length<=b.email&&wn.test(t.trim())?null:{code:"email_invalid"};case"phone":return typeof t=="string"&&An.test(t)?null:{code:"phone_invalid"};case"country":return typeof t=="string"&&xt.test(t)?null:{code:"choice_invalid"};case"address":return In(t)?null:{code:"address_invalid"};default:return null}}function In(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e,n=Array.isArray(t.lines)?t.lines.filter(i=>typeof i=="string"&&i.trim()!==""):[];return typeof t.country=="string"&&xt.test(t.country)&&typeof t.city=="string"&&t.city.trim()!==""&&t.city.trim().length<=b.city&&n.length>=1&&n.length<=b.addressLines&&n.every(i=>i.trim().length<=b.addressLine&&!At(i))&&(t.postcode===void 0||typeof t.postcode=="string"&&t.postcode.trim().length<=b.postcode)}function Mn(e,t,n){let i=new Set((e.choices??[]).map(r=>r.value));switch(e.type){case"short_text":return ue(t,b.shortText);case"long_text":return ue(t,b.longText);case"single_choice":return typeof t=="string"&&i.has(t)?null:{code:"choice_invalid"};case"multiple_choice":return Array.isArray(t)&&t.length>0&&new Set(t).size===t.length&&t.every(r=>i.has(r))?null:{code:"choice_invalid"};case"yes_no":return typeof t=="boolean"?null:{code:"choice_invalid"};case"date":{let r=e.options??{};return Pt(t,n,{...typeof r.min=="string"?{min:r.min}:{},...typeof r.max=="string"?{max:r.max}:{},...r.period==="past"||r.period==="future"?{period:r.period}:{}})}case"number":{if(typeof t!="number"||!Number.isFinite(t)||Math.abs(t)>=b.number)return{code:"number_invalid"};let r=e.options??{};return r.integer===!0&&!Number.isInteger(t)?{code:"number_not_integer"}:Cn(t)?typeof r.min=="number"&&t<r.min?{code:"number_too_small",params:{min:r.min}}:typeof r.max=="number"&&t>r.max?{code:"number_too_large",params:{max:r.max}}:null:{code:"number_decimals"}}default:return null}}var Eo={full_name:b.fullName,occupation:b.occupation,email:b.email,short_text:b.shortText,long_text:b.longText};var Rt=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",missing_nni:"missing_id_number",registry_needs_nni_source:"registry_needs_id_number_source"}),On=new Map(Object.entries(Rt)),To=new Map(Object.entries(Rt).map(([e,t])=>[t,e]));function It(e){return On.get(e)??e}var qo=["national_number","document_photo","national_eid"],En=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","proof_of_address","form"]),vn=new Set(["supplied_identity","aml_screening","face_dedup","age_estimation"]),Ce=["document","population_registry","national_eid"],be=["phone_otp","email_otp"],Et={identity_method:Ce,contact:be},Tn=["population_registry","document"],we="platform_unsupported",Vn=new Set(["prefilled","user_entered","prefilled_or_entered"]),Nn={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",poa:"documents",form:"form"};function V(e){return e.section??Nn[e.checkType]??null}function Fn(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 Ae(e){let t=e.plan,n=t?.choice;if(t===void 0||n===void 0||n.locked||t.current===null||t.current===n.nodeId||I(e))return null;let i=Et[n.kind]??[...Ce,...be],r=n.options.flatMap(d=>d.available===!1||!i.includes(d.service)?[]:[d.nationalEid!=null?{id:d.id,service:d.service,nationalEid:d.nationalEid}:{id:d.id,service:d.service}]),u=t.steps.find(d=>d.id===t.current)?.service,a=n.selected??r.find(d=>d.service===u)?.id??null;return r.some(d=>d.id!==a)?{nodeId:n.nodeId,kind:n.kind,current:a,options:r}:null}function vt(e){return e==null?[]:e.options.filter(t=>t.id!==e.current)}function Hn(e){let t=e.simulation;if(typeof t!="object"||t===null)return;let{otpCode:n,skipCapture:i}=t;if(typeof n!="string"||n===""||typeof i!="boolean")return;let r=ut(e);return r!==void 0?{otpCode:n,skipCapture:i,reason:r}:{otpCode:n,skipCapture:i}}function Ln(e){let t=(e.plan?.sections??[]).map(a=>({id:a.id,state:a.state})),n={sessionId:D(e.sessionId),orgName:e.orgName,sandbox:e.sandbox===!0,returning:e.returning===!0,consentRecorded:e.consentRecorded,expiresAt:e.expiresAt,sections:t.map(a=>a.id),progress:t,purpose:e.purpose??"identity"};e.branding!==void 0&&(n.branding=e.branding),e.cameraUnavailableHandled===!0&&(n.cameraUnavailableHandled=!0);let i=Hn(e);i!==void 0&&(n.simulation=i);let r=e.testerGate;r?.offered===!0&&typeof r.attemptsLeft=="number"&&r.attemptsLeft>0&&(n.testerGate={attemptsLeft:r.attemptsLeft});let u=Ae(e);return u!==null&&(n.switchable=u),n}function Dn(e){let t={attemptsRemaining:re(e),attemptsExhausted:e.attempts.used>=e.attempts.max};return e.reason!==void 0&&(t.reason=e.reason),e.retakeHint!==void 0&&(t.retakeHint=e.retakeHint),t}var Tt={phone_otp:"phone",email_otp:"email"};function Un(e,t){let n=Fn(e,[t==="phone_otp"?"email_otp":"phone_otp"]);return n===void 0?void 0:Tt[n.option.service]}function Bn(e,t,n,i){let r=t.checkType==="email_otp",u=(r?t.emailOtp:t.otp)??{},a=r?t.emailOtp?.emailSource:t.otp?.numberSource,d=a!==void 0&&Vn.has(a)?a:r?"prefilled_or_entered":"user_entered",h=typeof u.sentToMasked=="string"&&u.sentToMasked.length>0,_=u.prefilled===!0,S=Un(e,r?"email_otp":"phone_otp"),P={key:t.checkType,context:n,section:V(t),phase:h?"verify":"send",canSwitch:S!==void 0,...i},g=r?{kind:"email_otp",...P,emailSource:d,needsEmail:d!=="prefilled"&&!_}:{kind:"phone_otp",...P,numberSource:d,needsPhone:d!=="prefilled"&&!_,channels:(t.otp?.channels??[]).filter(m=>m==="whatsapp"||m==="sms")};if(S!==void 0&&(g.switchChannel=S),_&&(g.prefilled=!0),h&&(g.sentToMasked=u.sentToMasked),!r&&t.otp?.channel!==void 0&&(g.channel=t.otp.channel),!r&&Array.isArray(t.phoneCountries)&&(g.phoneCountries=t.phoneCountries.filter(m=>typeof m=="string"&&/^[A-Z]{2}$/.test(m))),!r&&Array.isArray(t.phoneRules)){let m=g.phoneCountries??[];g.phoneRules=t.phoneRules.flatMap(M=>{let y=Kn(M);return y!==void 0&&m.includes(y.code)?[y]:[]})}return!r&&t.phoneInternational===!0&&(g.phoneInternational=!0),u.expiresAt!==void 0&&(g.codeExpiresAt=u.expiresAt),u.resendAvailableAt!==void 0&&(g.resendAvailableAt=u.resendAvailableAt),g}var qn=/^[\d[\]\-|()?:^]{1,64}$/;function Gn(e){try{return typeof e=="string"&&qn.test(e)&&new RegExp(e)!==null}catch{return!1}}var Mt=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=15;function Kn(e){let{code:t,dial:n,trunk:i,lengths:r,formats:u}=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(Mt))return;let a={code:t,dial:n,lengths:[...r].sort((d,h)=>d-h)};if(i!==void 0&&(a.trunk=i),u!==void 0){if(!(Array.isArray(u)&&u.length<=8&&u.every(h=>Gn(h?.leading)&&Array.isArray(h.groups)&&h.groups.every(Mt)&&r.includes(h.groups.reduce((_,S)=>_+S,0)))))return;a.formats=u.map(h=>({leading:h.leading,groups:[...h.groups]}))}return a}function jn(e,t,n,i){let r=ae(e)===!0?"bound":ee(t)===!0?"document":"typed",u=r==="typed"&&t.state==="input_required"&&t.reason!==void 0&&It(t.reason)==="id_number_recheck",a=vt(Ae(e)),d=!i.attemptsExhausted&&a.length===1&&a[0]?.service==="document";return{kind:"registry",key:"registry",context:n,section:V(t),state:t.state==="input_required"?"input_required":"pending",source:r,recheck:u,canUseDocument:d,...i}}function Yn(e,t,n,i,r){let u=[...t.acceptedSides??[]],a={kind:"document",key:"document",context:n,section:V(t),side:u.includes("recto")?"verso":"recto",acceptedSides:u,documents:Ct(e),photo:Pe(xe(e.documents),r),...i};return e.detectedCountry!==void 0&&(a.detectedCountry=e.detectedCountry),Qn(e)&&(a.ageStepUp=!0),a}function xe(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 Pe(e,t){return t?{...e,cameraOnPhone:!0}:e}var Wn=10*1024*1024;function $n(e,t,n,i,r){let u=e.proofOfAddress,a=u?.pdf?.maxBytes,d=u?.phase==="holder_letter"?"holder_letter":"document";return{kind:"proof_of_address",key:"proof_of_address",context:n,section:V(t),phase:d,rule:u?.rule??{country:null,countryFrom:"global",source:"preset_global",kinds:[]},nameMatch:u?.nameMatch??"exact_person",photo:Pe(xe(u),r),maxPages:3,pdf:{maxBytes:typeof a=="number"&&a>0?a:Wn,maxPages:3},licenceAddressAccepted:d==="document"&&u?.licenceAddressAccepted===!0,...i}}function Qn(e){let t=J(e).find(i=>i.checkType==="age_estimation"),n=t?.reason;return t?.state==="failed"&&(n==="age_uncertain"||n==="age_unavailable")}function Zn(e){let t=T(e,"liveness");return t?.state==="passed"||t?.state==="review"}function Ot(e,t,n,i,r,u=!1){let a=t.icao?.report,d=e.portrait,h=r==="capture"?d?.pendingFix??null:null;h!==null&&(r="review");let _=Vt(e);return{kind:"portrait",key:`portrait:${r}`,context:n,section:V(t),phase:r,report:Array.isArray(a)?a:null,review:t.state==="review",tuning:e.capture?.icao??null,tuningVersion:e.capture?.tuningVersion??null,icao:se(e),retakeOnly:r==="capture"&&t.state==="input_required"&&_===void 0&&e.capture?.livePhoto?.oneCapture===!0&&Zn(e),photo:Pe(xe(d,r==="capture"),u&&r==="capture"),pendingFix:h,..._!==void 0?{captureMode:_}:{},...d?.reuse?.pending===!0?{reuse:!0}:{},...i}}function Vt(e){let t=e.portrait?.captureMode;return t==="self"||t==="assisted"||t==="choice"?t:void 0}var ke={minLongSidePx:1280,jpegQuality:.95};function Jn(e,t){let n=e.capture?.livePhoto;if(n?.oneCapture!==!0)return null;let i=T(e,"portrait_icao"),r=n.still??ke;return{icao:t==="liveness"&&se(e)!==null&&Vt(e)===void 0&&i!==void 0&&i.state==="pending"&&i.reason===void 0,still:{minLongSidePx:r.minLongSidePx??ke.minLongSidePx,jpegQuality:r.jpegQuality??ke.jpegQuality}}}function Xn(e,t,n,i){let r=t.eid,u=V(t);if(r===void 0||r.challenge!=="app_code")return{kind:"unsupported",key:"unsupported:eid_auth",context:n,section:u,checkType:"eid_auth",reason:"update_required"};let a=vt(Ae(e)),d=a.length===1&&Tn.includes(a[0]?.service??"")?a[0]:void 0,h=d===void 0?void 0:Z[d.service],_=h!==void 0,S={kind:"eid",key:"eid",context:n,section:u,provider:r.provider,providerName:r.providerName,country:r.country,challenge:"app_code",phase:r.awaiting==="code"?"code":"identifier",identifierBound:r.identifierBound===!0,canUseCamera:_,afterPass:r.afterPass==="continue"?"continue":"end",...i};return _&&(S.cameraMethod=h),r.expiresAt!==void 0&&(S.codeExpiresAt=r.expiresAt),r.resendAvailableAt!==void 0&&(S.resendAvailableAt=r.resendAvailableAt),r.resendsRemaining!==void 0&&(S.resendsRemaining=r.resendsRemaining),r.codeAttemptsRemaining!==void 0&&(S.codeAttemptsRemaining=r.codeAttemptsRemaining),S}function zn(e,t){if(t.checkType!=="face_match"||t.reason!==void 0)return null;let n=T(e,"portrait_icao");return n!==void 0&&(n.state==="passed"||n.state==="review")?n:null}var eo={rejected:"rejected",inconclusive:"inconclusive",unavailable:"unavailable",abandoned:"expired",not_opened:"expired",cancelled:"expired",superseded:"expired",policy:"policy"};function to(e){return e.reasonCode===we?"platform_unsupported":e.status==="review_pending"?"review":e.status==="verified"?"verified":e.reasonCode==="device_cooldown"?"cooldown":e.reasonCode==="starter_credit_claimed"?"policy":(e.status==="not_verified"&&e.reason!==void 0?eo[e.reason]:void 0)??"rejected"}function no(e,t){let n=to(e),i=n==="platform_unsupported"?{sessionId:D(e.sessionId),status:"unavailable",reasonCode:we}:X(e,{autoRetry:!1}),r={kind:"result",key:"result",context:t,section:null,display:n,result:i};return e.status==="not_verified"&&e.reason!==void 0&&(r.reason=e.reason),e.reasonCode!==void 0&&(r.reasonCode=e.reasonCode),e.status==="not_verified"&&e.step!==void 0&&(r.step=e.step),e.retryAfter!==void 0&&(r.retryAfter=e.retryAfter),r}function oo(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 a of ro){let d=i[a];typeof d=="string"&&d!==""&&(r[a]=d)}let u=gt(i);return u!==void 0&&(r.idNumberMasked=u,r.nniMasked=u),r}var ro=["fullName","birthDate","birthYear","nationality","documentType","documentNumberMasked","expiryDate","retakeTarget"];function B(e,t,n,i){return{kind:"unsupported",key:`unsupported:${n}`,context:e,section:t,checkType:n,reason:i}}function io(e){return e.kind==="contact"?"contact":(e.kind==="identity_method","identity")}function so(e,t){let n=Et[e.kind]??[...Ce,...be],i=io(e),r=e.options.flatMap(a=>{if(a.available===!1||!n.includes(a.service))return[];let d={id:a.id,service:a.service};a.nationalEid!=null&&(d.nationalEid=a.nationalEid);let h=(a.channels??[]).filter(_=>_==="whatsapp"||_==="sms");return a.service==="phone_otp"&&h.length>0&&(d.channels=h),[d]});if(r.length===0){let a=e.options.length>0&&e.options.every(d=>d.service==="nfc");return B(t,i,"choice",a?"platform_unsupported":"update_required")}let u={nodeId:e.nodeId,kind:e.kind,selected:e.selected,options:r};if(e.kind==="identity_method"){let a={kind:"method",key:"method",context:t,section:i,options:r.map(h=>Z[h.service]),choice:u},d=r.find(h=>h.nationalEid!==void 0)?.nationalEid;return d!==void 0&&(a.nationalEid=d),a}return e.kind==="contact"?{kind:"contact_choice",key:"contact_choice",context:t,section:i,options:r.map(a=>Tt[a.service]),selected:null,locked:!1,choice:u}:{kind:"choice",key:`choice:${e.nodeId}`,context:t,section:i,choice:u}}function ao(e,t,n,i){let r=e.nativeApp,u=typeof r=="object"&&r!==null?r:{},a={sekyroApp:u.sekyroApp===!0};return typeof u.link=="string"&&u.link!==""&&(a.link=u.link),a.sekyroApp&&typeof u.sekyroAppLink=="string"&&u.sekyroAppLink.startsWith("sekyro://")&&(a.sekyroAppLink=u.sekyroAppLink),{kind:"native_app_required",key:`native_app_required:${i}`,context:t,section:n,checkType:i,nativeApp:a}}function Go(e,t={}){let n=Ln(e);if(I(e)||e.reasonCode===we)return no(e,n);let i=e.plan;if(i===void 0||!Array.isArray(i.sections))return B(n,null,"plan","update_required");let r=st(e);if(r!==null)return so(r,n);let u=i.current===null?void 0:i.steps.find(g=>g.id===i.current),a=g=>{let m={kind:"processing",key:"processing",context:n,section:g!==void 0?V(g):i.sections.find(M=>M.state==="current")?.id??null,stalled:!1};return typeof g?.service=="string"&&g.service!==""&&(m.service=g.service),m};if(i.current===null)return a(i.steps.find(g=>g.state==="processing"));if(u===void 0)return B(n,null,"step","update_required");if(!En.has(u.service))return u.interaction==="server"?a(u):B(n,V(u),u.service,"update_required");if(vn.has(u.service)||!at(u))return a(u);let d=u,h=Dn(d),_=d.checkType,S=V(d);if(d.requiresNativeApp===!0)return ao(e,n,S,_);let P=t.isMobile===!1?z(e,d):null;if(P==="phone")return{kind:"mobile_required",key:"mobile_required",context:n,section:S,checkType:_};switch(_){case"phone_otp":case"email_otp":return Bn(e,d,n,h);case"population_registry":return jn(e,d,n,h);case"eid_auth":return Xn(e,d,n,h);case"doc_ocr":return Yn(e,d,n,h,P==="upload_or_phone");case"identity_confirm":return oo(e,n,S)??a(d);case"portrait_icao":return Ot(e,d,n,h,"capture",P==="upload_or_phone");case"liveness":case"face_match":{let g=zn(e,d);if(g!==null)return Ot(e,g,n,h,"match");let m=d.requiresMobile===!0,M=se(e);return{kind:"liveness",key:"biometric",context:n,section:S,mode:_==="face_match"?"selfie":"liveness",requiresMobile:m,instructions:M===null?"standard":"icao",icao:M,livePhoto:Jn(e,_),...h}}case"poa":return $n(e,d,n,h,P==="upload_or_phone");case"form":{let g=wt(d.form);return g===null?B(n,S,_,"update_required"):{kind:"form",key:"form",context:n,section:S,form:g,dir:bt(g.locale),...h}}case"nfc_chip":return B(n,S,_,"platform_unsupported");default:return B(n,S,_,"update_required")}}export{Jt as a,Xt as b,sn as c,an as d,cn as e,wo as f,dn as g,kt as h,ln as i,fn as j,Ro as k,Ct as l,Io as m,b as n,bt as o,kn as p,Cn as q,At as r,Pn as s,Oo as t,qo as u,we as v,V as w,Ae as x,vt as y,zn as z,Go as A};
3
+ ${s}`,Le=0,ye,ge=(o,s)=>{Le+=1;let c=v(),f=_(o,{signal:M.signal,subject:s}),p={key:he(o,s),at:c,token:f};return f.then(()=>{p.issuedAt=v(),me=void 0},k=>{let C=St(k);if(p.failed=C,m||C==="aborted")return;me=C;let{detail:w,readyMs:l}=k;W({check:"attestation",kind:"unavailable",engineKind:C,attempt:Ht++,challengeMs:v()-c,readyMs:l,detail:w,inApp:Xe()})}),f.catch(()=>{}),p},De=(o,s)=>o!==null&&o.key===s&&(o.issuedAt===void 0||v()-o.issuedAt<zt),Se=(o,s={})=>{let c=o?.challenge??null;if(o===null||c===null||m)return;let f=D(o.sessionId),p=q;(s.replaceFailed===!0&&p?.failed!==void 0&&!_t.has(p.failed)||!De(p,he(c,f)))&&(q=ge(c,f))},Ue=async(o,s)=>{let c=he(o,s),f=q;q=null;let p=De(f,c)?f:ge(o,s),k=p===f?0:1,C,w=new Promise(l=>{C=setTimeout(()=>l("late"),en)});try{for(;;){let l=await Promise.race([p.token.then(x=>({token:x}),x=>({error:St(x)})),w]);if(l==="late")return!m&&q===null&&(q=p),{error:me??"timeout"};if("token"in l)return ye=Math.max(0,Math.round((p.issuedAt??v())-p.at)),l;if(m||_t.has(l.error)||k>=on||k>0&&await Promise.race([d(rn*k),w])==="late")return l;if(m)return{error:"aborted"};k+=1,p=ge(o,s)}}finally{clearTimeout(C)}},H=null,Lt=o=>J(o).some(s=>(s.checkType==="phone_otp"||s.checkType==="email_otp")&&s.state!=="passed"&&s.state!=="skipped"),Be=o=>H===null||v()-H>=o,oe=()=>Be(tn),Dt=o=>{let s=o.attestation;return typeof s?.turnstileToken=="string"&&s.turnstileToken.length>0},qe=new Map,Ge=async()=>{let o=await A(),s=o.challenge;if(s==null||o.simulation!==void 0)return;let c=await Ue(s,D(o.sessionId));if(!("token"in c))throw new G({status:400,code:"attestation_invalid",message:`browser check: ${c.error}`});return c.token},Ut=async(o,s,c={})=>{let f=s;if("attestation"in f)try{let l=await u.submitCheck(o,s,c);return Dt(f)&&(H=v()),l}catch(l){throw l instanceof G&&l.code==="attestation_invalid"&&(H=null),l}let p=(o==="phone_otp"||o==="email_otp")&&f.action!=="verify",k=c.idempotencyKey,C=k!==void 0?qe.get(k):void 0;C===void 0&&(p||oe())&&(C=await Ge(),k!==void 0&&C!==void 0&&qe.set(k,C));let w=(l,x)=>l!==void 0?{...x,browserCheckToken:l}:x;try{let l=await u.submitCheck(o,s,w(C,c));return C!==void 0&&(H=v()),l}catch(l){if(!(l instanceof G)||l.code!=="attestation_invalid"||(H=null,C!==void 0))throw l;let x=await Ge(),L=k!==void 0?{...c,idempotencyKey:h()}:c,F=await u.submitCheck(o,s,w(x,L));return x!==void 0&&(H=v()),F}},Ke=async(o={})=>{if(Y=void 0,o.always!==!0&&!oe())return{};let s=await A(),c=s.challenge;if(c==null)return{};let f=await Ue(c,D(s.sessionId));if("token"in f)return{channel:"hosted_web",turnstileToken:f.token};if(Y=f.error,s.simulation!==void 0)return{channel:"hosted_web"};throw new ft(f.error)},Bt=()=>Y,qt=()=>({checks:Math.min(50,Le),...ye!==void 0?{challengeMs:Math.min(6e5,ye)}:{}}),W=o=>{if(m)return;let s=a.reportCaptureIssue;if(s===void 0)return;let c=o.formFactor;try{c??(c=Je())}catch{}try{Promise.resolve(s.call(a,{...o,...c!==void 0?{formFactor:c}:{}})).catch(()=>{})}catch{}},R=null,$=null,je=new WeakMap,Ye=Promise.resolve(),Q=0,Gt=async()=>{let o=await A();for(let s=0;s<an&&!m&&!I(o)&&j(o)===void 0&&J(o).some(c=>c.state==="processing")&&(await d(sn),!m);s+=1)o=await E();return o},Kt=async(o,s,c)=>{let{capture:f}=o,p=()=>m,k=()=>o.alive&&o.attempt===c,C=l=>{k()&&f.setFlowState(l)},w=l=>{if(!p()&&(l.status==="unavailable"&&l.reasonCode!==void 0&&!ot(l.reasonCode)&&W({check:"liveness",kind:"unavailable",phase:"upload",engineKind:l.reasonCode,attempt:Math.max(0,o.issues.value)}),fe(l),!!k())){if(l.status==="retry"&&r==="auto"){f.handle.retry();return}f.setFlowState("done")}};if(s.degraded==="NO_RECORDER"){let l=y?.sessionId??(await A().catch(()=>null))?.sessionId??"";w(U(l,"no_recorder"));return}C("uploading");try{if(await He(),p())return;let l=await A(),x;if(!I(l)&&K(l)!==null){await Ee(!1),w(U(l.sessionId,"method_required"));return}if(!I(l)){if(j(l)?.checkType==="population_registry"){w(U(l.sessionId,Ve?"nni_unbound":Te?"network":"registry_unavailable"));return}if(await N(),p())return;x=y??l;let L=await ht({...pe,artifacts:s,getAttestation:Ke,attestationError:Bt,attestationFacts:qt,clipKeys:{get:()=>je.get(s)??null,set:F=>{je.set(s,F)}},getView:()=>y??l,refreshView:E,applySubmit:de,onPhase:C,isCancelled:p,onKeyframePromoted:F=>{g=F}});if(p())return;if(L.kind==="unavailable"){L.reason==="attestation"&&($={bound:o,artifacts:s});let F=U(l.sessionId,L.reason),Ze=L.reason==="attestation"?Y:void 0;w(Ze!==void 0?{...F,attestationError:Ze}:F);return}if(L.kind==="resync"&&await E(),y!==null&&K(y)!==null){await Ee(!1),w(U(l.sessionId,"method_required"));return}l=await Gt()}w(X(l,{autoRetry:i,previous:x}))}catch{if(p())return;w(U(y?.sessionId??"","network"))}},We=(o,s)=>{let c=o.attempt;Q>0&&o.alive&&o.capture.setFlowState("uploading"),Q+=1,Ye=Ye.then(()=>Kt(o,s,c)).finally(()=>{Q-=1,Q===0&&P?.onChainIdle()}).catch(()=>{})},$e=o=>{R?.capture.handle.destroy(),R!==null&&(R.alive=!1);let s=et(o,P?.captureInternals?.(o)??t.capture,()=>y?.capture?.liveness?.keyframe?.rank===!0,Re,()=>y?.capture?.liveness?.screenRamp,{session:()=>ie(y),onModeChange:p=>{te=p}}),c={capture:s,alive:!0,attempt:0,issues:it()};R=c,s.handle.on("error",p=>{W(rt("liveness",p,c.issues.value))}),s.handle.on("state",p=>{if(c.issues.note(p),p==="starting"){c.attempt+=1,$?.bound===c&&($=null),oe()&&Se(y,{replaceFailed:!0});let k=y===null?void 0:j(y)?.checkType;(k==="liveness"||k==="face_match")&&N().catch(()=>{})}}),s.handle.on("captured",p=>{Promise.resolve().then(()=>We(c,p))});let f=s.handle;return{get state(){return f.state},get captureMode(){return f.captureMode},get facingMode(){return f.facingMode},on:(p,k)=>f.on(p,k),start:async p=>{if(y===null&&await A().catch(()=>{}),!!c.alive)return f.start(p)},retry:()=>{let p=$;if(p!==null&&p.bound===c&&c.alive){$=null,We(c,p.artifacts);return}f.retry()},switchCamera:()=>f.switchCamera(),canSwitchCaptureMode:()=>f.canSwitchCaptureMode(),setCaptureMode:p=>f.setCaptureMode(p),destroy:()=>{c.alive=!1,R===c&&(R=null),f.destroy()}}},jt=async()=>{if(m)return null;try{let o=await A();return m?null:K(o)}catch{return null}},Yt=async()=>{if(m)return"self";try{let o=await A();if(m)return"self";let s=ie(o);return s==="choice"?ne()??s:s}catch{return"self"}},Wt=async()=>{if(m)return!1;try{let o=await A();return m||I(o)||_e()?!1:z(o,j(o))==="phone"||z(o,T(o,"liveness"))==="phone"}catch{return!1}},$t=async()=>{if(m)return!1;try{let o=await A();return!m&&o.returning===!0}catch{return!1}},Qt=async o=>{let s=(await A()).plan?.choice,c=s?.options.find(p=>Z[p.service]===o);if(!c)throw new RangeError(`method ${String(o)} is not offered`);let f=await a.choose(s.nodeId,c.id);m||O(f)},Qe=null,Zt=()=>(Qe??(Qe=import("./plan-runner-LSQTIO6L.js").then(o=>{let s=o.createPlanRunner({runtime:pe,currentView:()=>y,cameraMode:Re,captureModeSwitch:{pick:ne,choose:c=>{te=c}},ensureView:A,refreshView:E,ensureConsent:()=>N(),liveness:$e,stopLiveness:()=>{R!==null&&(R.alive=!1,R.capture.handle.destroy(),R=null)},chainBusy:()=>Q>0,destroyed:()=>m,sleep:d,isMobile:_e,now:t.now??Date.now,keptFaceKey:()=>g,setView:O,baseCapture:t.capture,emitStep:c=>{m||S.emit("step",c)},emitResult:Nt,reportCaptureIssue:W,documentInternals:t.document,portraitInternals:t.portrait,livePhotoInternals:t.livePhoto,uploadInternals:t.upload,pageCameraInternals:t.pageCamera});return P=s,s})),Qe);return{consent:()=>N(),startRegistry:He,methodChoice:jt,selectMethod:Qt,reportCameraUnavailable:async o=>{await N();let s=a.reportCameraUnavailable;if(s===void 0)throw new TypeError("this client cannot report a missing camera");let c=await s.call(a,o).catch(f=>{if(f instanceof G&&f.code==="check_out_of_order")return a.getSession();throw f});m||O(c)},reportCaptureIssue:W,testerGate:async o=>{let s=a.testerGate;if(s===void 0)throw new TypeError("this client cannot run the tester gate");let c=o.clip,f=tt(o.clipMime??"");if(c===void 0||!pt.includes(f))throw new TypeError("the capture has no clip");await N();let p=await lt(a,"clip",f,c.size,{engine:o.engine,durationMs:o.clipMs});await a.uploadToSpaces(p.uploadUrl,c,f);let{key:k}=await a.completeMedia(p.key),C=await Ke({always:!0}),w=await s.call(a,{clipKey:k,attestation:C,captureChannel:o.captureChannel,capture:{...yt(o),attestationError:Y}}),{bound:l,...x}=w;return m||(x.plan!==void 0?O(x):await E()),{bound:l===!0}},mobileRequired:Wt,captureMode:Yt,chooseCaptureMode:o=>{te=o},get captureChoice(){return ne()},returning:$t,liveness:$e,run:async()=>{if(m)throw new Error("verification destroyed");return(await Zt()).run()},currentStep:()=>P?.current()??null,voiceClips:async()=>{if(m)return null;try{let o=await A();return m?null:o.voice??null}catch{return null}},on:(o,s)=>S.on(o,s),destroy:()=>{m=!0,M.abort(),P?.destroy(),R!==null&&(R.alive=!1,R.capture.handle.destroy(),R=null),S.clear()}}}var kt=["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 ln=["carte_identite","passport","residence_permit","drivers_license"],pn=["carte_identite","passport","residence_permit"];function fn(e,t){let n=e.byIssuer?.[t]??e.default;return ln.filter(i=>n==="*"?pn.includes(i):n.includes(i))}function Ro(e,t=kt){return[...new Set([...t,...Object.keys(e.byIssuer??{})])].filter(i=>fn(e,i).length>0).sort()}function Ct(e){if(e.acceptedDocuments)return e.acceptedDocuments;let t=e.acceptedDocumentTypes?.length?[...e.acceptedDocumentTypes]:["carte_identite","passport"];return{default:[],byIssuer:{MR:t}}}function Io(e){return/^[A-Z]{2}$/.test(e)?String.fromCodePoint(...[...e].map(t=>127462+t.charCodeAt(0)-65)):""}var b={fullNameMin:2,fullName:200,email:254,occupation:120,shortText:120,longText:1e3,addressLine:120,addressLines:4,city:80,postcode:16,number:1e12,dateMin:"1900-01-01",dateMax:"2100-12-31"},mn=new Set(["full_name","birth_date","email","phone","address","country","occupation"]),hn=new Set(["short_text","long_text","single_choice","multiple_choice","yes_no","date","number"]),yn=new Set(["ar","fa","he","ur"]);function bt(e){return yn.has(e.split("-")[0]?.toLowerCase()??"")?"rtl":"ltr"}function wt(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.locale!="string"||!Array.isArray(t.questions)||t.questions.length===0)return null;let n=t.consents??[];if(!Array.isArray(n))return null;for(let r of t.questions)if(!gn(r))return null;for(let r of n)if(!Sn(r))return null;let i={locale:t.locale,questions:t.questions,consents:n};return typeof t.title=="string"&&t.title.trim()!==""&&(i.title=t.title),typeof t.intro=="string"&&t.intro.trim()!==""&&(i.intro=t.intro),typeof t.prefill=="object"&&t.prefill!==null&&!Array.isArray(t.prefill)&&(i.prefill=t.prefill),i}function gn(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.id!="string"||typeof t.required!="boolean"?!1:t.kind==="field"?typeof t.field=="string"&&mn.has(t.field):t.kind!=="custom"||typeof t.type!="string"||!hn.has(t.type)||typeof t.label!="string"?!1:t.type==="single_choice"||t.type==="multiple_choice"?Array.isArray(t.choices)&&t.choices.length>=2&&t.choices.every(n=>typeof n=="object"&&n!==null&&typeof n.value=="string"&&typeof n.label=="string"):!0}function Sn(e){if(typeof e!="object"||e===null)return!1;let t=e;if(typeof t.id!="string"||typeof t.required!="boolean"||typeof t.text!="string")return!1;if(t.link===void 0)return!0;let n=t.link;return typeof n=="object"&&n!==null&&typeof n.url=="string"&&/^https:\/\//.test(n.url)&&typeof n.label=="string"}var _n=/^(\d{4})-(\d{2})-(\d{2})$/;function kn(e){if(typeof e!="string")return!1;let t=_n.exec(e);return t===null?!1:new Date(Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3]))).toISOString().slice(0,10)===e&&e>=b.dateMin&&e<=b.dateMax}function Cn(e){return typeof e=="number"&&Number.isFinite(e)&&Math.abs(e)<b.number&&Math.round(e*100)/100===e}function At(e){for(let t of e.matchAll(/\d[\d -]{11,}\d/g)){let n=t[0].replace(/[ -]/g,"");if(n.length>=13&&n.length<=19&&bn(n))return!0}return!1}function bn(e){let t=0;for(let n=0;n<e.length;n++){let i=Number(e[e.length-1-n]);n%2===1&&(i*=2,i>9&&(i-=9)),t+=i}return t%10===0}var wn=/^[^\s@]+@[^\s@.]+(\.[^\s@.]+)+$/,An=/^\+[1-9]\d{6,14}$/,xt=/^[A-Z]{2}$/,xn=e=>e===void 0||typeof e=="string"&&e.trim()===""||Array.isArray(e)&&e.length===0;function Pn(e=Date.now()){return new Date(e).toISOString().slice(0,10)}function Oo(e,t,n=Pn()){let i=[];for(let r of e.questions){let u=t.answers[r.id];if(xn(u)){r.required&&i.push({id:r.id,code:"required"});continue}let a=r.kind==="field"?Rn(r.field,u,n):Mn(r,u,n);a!==null&&i.push({id:r.id,...a})}for(let r of e.consents)r.required&&t.consents[r.id]!==!0&&i.push({id:r.id,code:"consent_required"});return i}function ue(e,t,n=1){if(typeof e!="string")return{code:"required"};let i=e.trim();return[...i].length>t?{code:"too_long",params:{max:t}}:[...i].length<n?{code:"too_short",params:{min:n}}:At(i)?{code:"card_number"}:null}function Pt(e,t,n={}){return kn(e)?n.period==="past"&&e>=t?{code:"date_not_past"}:n.period==="future"&&e<=t?{code:"date_not_future"}:n.min!==void 0&&e<n.min?{code:"date_too_early",params:{date:n.min}}:n.max!==void 0&&e>n.max?{code:"date_too_late",params:{date:n.max}}:null:{code:"date_invalid"}}function Rn(e,t,n){switch(e){case"full_name":return ue(t,b.fullName,b.fullNameMin);case"occupation":return ue(t,b.occupation);case"birth_date":return Pt(t,n,{period:"past"});case"email":return typeof t=="string"&&t.trim().length<=b.email&&wn.test(t.trim())?null:{code:"email_invalid"};case"phone":return typeof t=="string"&&An.test(t)?null:{code:"phone_invalid"};case"country":return typeof t=="string"&&xt.test(t)?null:{code:"choice_invalid"};case"address":return In(t)?null:{code:"address_invalid"};default:return null}}function In(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e,n=Array.isArray(t.lines)?t.lines.filter(i=>typeof i=="string"&&i.trim()!==""):[];return typeof t.country=="string"&&xt.test(t.country)&&typeof t.city=="string"&&t.city.trim()!==""&&t.city.trim().length<=b.city&&n.length>=1&&n.length<=b.addressLines&&n.every(i=>i.trim().length<=b.addressLine&&!At(i))&&(t.postcode===void 0||typeof t.postcode=="string"&&t.postcode.trim().length<=b.postcode)}function Mn(e,t,n){let i=new Set((e.choices??[]).map(r=>r.value));switch(e.type){case"short_text":return ue(t,b.shortText);case"long_text":return ue(t,b.longText);case"single_choice":return typeof t=="string"&&i.has(t)?null:{code:"choice_invalid"};case"multiple_choice":return Array.isArray(t)&&t.length>0&&new Set(t).size===t.length&&t.every(r=>i.has(r))?null:{code:"choice_invalid"};case"yes_no":return typeof t=="boolean"?null:{code:"choice_invalid"};case"date":{let r=e.options??{};return Pt(t,n,{...typeof r.min=="string"?{min:r.min}:{},...typeof r.max=="string"?{max:r.max}:{},...r.period==="past"||r.period==="future"?{period:r.period}:{}})}case"number":{if(typeof t!="number"||!Number.isFinite(t)||Math.abs(t)>=b.number)return{code:"number_invalid"};let r=e.options??{};return r.integer===!0&&!Number.isInteger(t)?{code:"number_not_integer"}:Cn(t)?typeof r.min=="number"&&t<r.min?{code:"number_too_small",params:{min:r.min}}:typeof r.max=="number"&&t>r.max?{code:"number_too_large",params:{max:r.max}}:null:{code:"number_decimals"}}default:return null}}var Eo={full_name:b.fullName,occupation:b.occupation,email:b.email,short_text:b.shortText,long_text:b.longText};var Rt=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",missing_nni:"missing_id_number",registry_needs_nni_source:"registry_needs_id_number_source"}),On=new Map(Object.entries(Rt)),To=new Map(Object.entries(Rt).map(([e,t])=>[t,e]));function It(e){return On.get(e)??e}var qo=["national_number","document_photo","national_eid"],En=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","proof_of_address","form"]),vn=new Set(["supplied_identity","aml_screening","face_dedup","age_estimation"]),Ce=["document","population_registry","national_eid"],be=["phone_otp","email_otp"],Et={identity_method:Ce,contact:be},Tn=["population_registry","document"],we="platform_unsupported",Vn=new Set(["prefilled","user_entered","prefilled_or_entered"]),Nn={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",poa:"documents",form:"form"};function V(e){return e.section??Nn[e.checkType]??null}function Fn(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 Ae(e){let t=e.plan,n=t?.choice;if(t===void 0||n===void 0||n.locked||t.current===null||t.current===n.nodeId||I(e))return null;let i=Et[n.kind]??[...Ce,...be],r=n.options.flatMap(d=>d.available===!1||!i.includes(d.service)?[]:[d.nationalEid!=null?{id:d.id,service:d.service,nationalEid:d.nationalEid}:{id:d.id,service:d.service}]),u=t.steps.find(d=>d.id===t.current)?.service,a=n.selected??r.find(d=>d.service===u)?.id??null;return r.some(d=>d.id!==a)?{nodeId:n.nodeId,kind:n.kind,current:a,options:r}:null}function vt(e){return e==null?[]:e.options.filter(t=>t.id!==e.current)}function Hn(e){let t=e.simulation;if(typeof t!="object"||t===null)return;let{otpCode:n,skipCapture:i}=t;if(typeof n!="string"||n===""||typeof i!="boolean")return;let r=ut(e);return r!==void 0?{otpCode:n,skipCapture:i,reason:r}:{otpCode:n,skipCapture:i}}function Ln(e){let t=(e.plan?.sections??[]).map(a=>({id:a.id,state:a.state})),n={sessionId:D(e.sessionId),orgName:e.orgName,sandbox:e.sandbox===!0,returning:e.returning===!0,consentRecorded:e.consentRecorded,expiresAt:e.expiresAt,sections:t.map(a=>a.id),progress:t,purpose:e.purpose??"identity"};e.branding!==void 0&&(n.branding=e.branding),e.cameraUnavailableHandled===!0&&(n.cameraUnavailableHandled=!0);let i=Hn(e);i!==void 0&&(n.simulation=i);let r=e.testerGate;r?.offered===!0&&typeof r.attemptsLeft=="number"&&r.attemptsLeft>0&&(n.testerGate={attemptsLeft:r.attemptsLeft});let u=Ae(e);return u!==null&&(n.switchable=u),n}function Dn(e){let t={attemptsRemaining:re(e),attemptsExhausted:e.attempts.used>=e.attempts.max};return e.reason!==void 0&&(t.reason=e.reason),e.retakeHint!==void 0&&(t.retakeHint=e.retakeHint),t}var Tt={phone_otp:"phone",email_otp:"email"};function Un(e,t){let n=Fn(e,[t==="phone_otp"?"email_otp":"phone_otp"]);return n===void 0?void 0:Tt[n.option.service]}function Bn(e,t,n,i){let r=t.checkType==="email_otp",u=(r?t.emailOtp:t.otp)??{},a=r?t.emailOtp?.emailSource:t.otp?.numberSource,d=a!==void 0&&Vn.has(a)?a:r?"prefilled_or_entered":"user_entered",h=typeof u.sentToMasked=="string"&&u.sentToMasked.length>0,_=u.prefilled===!0,S=Un(e,r?"email_otp":"phone_otp"),P={key:t.checkType,context:n,section:V(t),phase:h?"verify":"send",canSwitch:S!==void 0,...i},g=r?{kind:"email_otp",...P,emailSource:d,needsEmail:d!=="prefilled"&&!_}:{kind:"phone_otp",...P,numberSource:d,needsPhone:d!=="prefilled"&&!_,channels:(t.otp?.channels??[]).filter(m=>m==="whatsapp"||m==="sms")};if(S!==void 0&&(g.switchChannel=S),_&&(g.prefilled=!0),h&&(g.sentToMasked=u.sentToMasked),!r&&t.otp?.channel!==void 0&&(g.channel=t.otp.channel),!r&&Array.isArray(t.phoneCountries)&&(g.phoneCountries=t.phoneCountries.filter(m=>typeof m=="string"&&/^[A-Z]{2}$/.test(m))),!r&&Array.isArray(t.phoneRules)){let m=g.phoneCountries??[];g.phoneRules=t.phoneRules.flatMap(M=>{let y=Kn(M);return y!==void 0&&m.includes(y.code)?[y]:[]})}return!r&&t.phoneInternational===!0&&(g.phoneInternational=!0),u.expiresAt!==void 0&&(g.codeExpiresAt=u.expiresAt),u.resendAvailableAt!==void 0&&(g.resendAvailableAt=u.resendAvailableAt),g}var qn=/^[\d[\]\-|()?:^]{1,64}$/;function Gn(e){try{return typeof e=="string"&&qn.test(e)&&new RegExp(e)!==null}catch{return!1}}var Mt=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=15;function Kn(e){let{code:t,dial:n,trunk:i,lengths:r,formats:u}=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(Mt))return;let a={code:t,dial:n,lengths:[...r].sort((d,h)=>d-h)};if(i!==void 0&&(a.trunk=i),u!==void 0){if(!(Array.isArray(u)&&u.length<=8&&u.every(h=>Gn(h?.leading)&&Array.isArray(h.groups)&&h.groups.every(Mt)&&r.includes(h.groups.reduce((_,S)=>_+S,0)))))return;a.formats=u.map(h=>({leading:h.leading,groups:[...h.groups]}))}return a}function jn(e,t,n,i){let r=ae(e)===!0?"bound":ee(t)===!0?"document":"typed",u=r==="typed"&&t.state==="input_required"&&t.reason!==void 0&&It(t.reason)==="id_number_recheck",a=vt(Ae(e)),d=!i.attemptsExhausted&&a.length===1&&a[0]?.service==="document";return{kind:"registry",key:"registry",context:n,section:V(t),state:t.state==="input_required"?"input_required":"pending",source:r,recheck:u,canUseDocument:d,...i}}function Yn(e,t,n,i,r){let u=[...t.acceptedSides??[]],a={kind:"document",key:"document",context:n,section:V(t),side:u.includes("recto")?"verso":"recto",acceptedSides:u,documents:Ct(e),photo:Pe(xe(e.documents),r),...i};return e.detectedCountry!==void 0&&(a.detectedCountry=e.detectedCountry),Qn(e)&&(a.ageStepUp=!0),a}function xe(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 Pe(e,t){return t?{...e,cameraOnPhone:!0}:e}var Wn=10*1024*1024;function $n(e,t,n,i,r){let u=e.proofOfAddress,a=u?.pdf?.maxBytes,d=u?.phase==="holder_letter"?"holder_letter":"document";return{kind:"proof_of_address",key:"proof_of_address",context:n,section:V(t),phase:d,rule:u?.rule??{country:null,countryFrom:"global",source:"preset_global",kinds:[]},nameMatch:u?.nameMatch??"exact_person",photo:Pe(xe(u),r),maxPages:3,pdf:{maxBytes:typeof a=="number"&&a>0?a:Wn,maxPages:3},licenceAddressAccepted:d==="document"&&u?.licenceAddressAccepted===!0,...i}}function Qn(e){let t=J(e).find(i=>i.checkType==="age_estimation"),n=t?.reason;return t?.state==="failed"&&(n==="age_uncertain"||n==="age_unavailable")}function Zn(e){let t=T(e,"liveness");return t?.state==="passed"||t?.state==="review"}function Ot(e,t,n,i,r,u=!1){let a=t.icao?.report,d=e.portrait,h=r==="capture"?d?.pendingFix??null:null;h!==null&&(r="review");let _=Vt(e);return{kind:"portrait",key:`portrait:${r}`,context:n,section:V(t),phase:r,report:Array.isArray(a)?a:null,review:t.state==="review",tuning:e.capture?.icao??null,tuningVersion:e.capture?.tuningVersion??null,icao:se(e),retakeOnly:r==="capture"&&t.state==="input_required"&&_===void 0&&e.capture?.livePhoto?.oneCapture===!0&&Zn(e),photo:Pe(xe(d,r==="capture"),u&&r==="capture"),pendingFix:h,..._!==void 0?{captureMode:_}:{},...d?.reuse?.pending===!0?{reuse:!0}:{},...i}}function Vt(e){let t=e.portrait?.captureMode;return t==="self"||t==="assisted"||t==="choice"?t:void 0}var ke={minLongSidePx:1280,jpegQuality:.95};function Jn(e,t){let n=e.capture?.livePhoto;if(n?.oneCapture!==!0)return null;let i=T(e,"portrait_icao"),r=n.still??ke;return{icao:t==="liveness"&&se(e)!==null&&Vt(e)===void 0&&i!==void 0&&i.state==="pending"&&i.reason===void 0,still:{minLongSidePx:r.minLongSidePx??ke.minLongSidePx,jpegQuality:r.jpegQuality??ke.jpegQuality}}}function Xn(e,t,n,i){let r=t.eid,u=V(t);if(r===void 0||r.challenge!=="app_code")return{kind:"unsupported",key:"unsupported:eid_auth",context:n,section:u,checkType:"eid_auth",reason:"update_required"};let a=vt(Ae(e)),d=a.length===1&&Tn.includes(a[0]?.service??"")?a[0]:void 0,h=d===void 0?void 0:Z[d.service],_=h!==void 0,S={kind:"eid",key:"eid",context:n,section:u,provider:r.provider,providerName:r.providerName,country:r.country,challenge:"app_code",phase:r.awaiting==="code"?"code":"identifier",identifierBound:r.identifierBound===!0,canUseCamera:_,afterPass:r.afterPass==="continue"?"continue":"end",...i};return _&&(S.cameraMethod=h),r.expiresAt!==void 0&&(S.codeExpiresAt=r.expiresAt),r.resendAvailableAt!==void 0&&(S.resendAvailableAt=r.resendAvailableAt),r.resendsRemaining!==void 0&&(S.resendsRemaining=r.resendsRemaining),r.codeAttemptsRemaining!==void 0&&(S.codeAttemptsRemaining=r.codeAttemptsRemaining),S}function zn(e,t){if(t.checkType!=="face_match"||t.reason!==void 0)return null;let n=T(e,"portrait_icao");return n!==void 0&&(n.state==="passed"||n.state==="review")?n:null}var eo={rejected:"rejected",inconclusive:"inconclusive",unavailable:"unavailable",abandoned:"expired",not_opened:"expired",cancelled:"expired",superseded:"expired",policy:"policy"};function to(e){return e.reasonCode===we?"platform_unsupported":e.status==="review_pending"?"review":e.status==="verified"?"verified":e.reasonCode==="device_cooldown"?"cooldown":e.reasonCode==="starter_credit_claimed"?"policy":(e.status==="not_verified"&&e.reason!==void 0?eo[e.reason]:void 0)??"rejected"}function no(e,t){let n=to(e),i=n==="platform_unsupported"?{sessionId:D(e.sessionId),status:"unavailable",reasonCode:we}:X(e,{autoRetry:!1}),r={kind:"result",key:"result",context:t,section:null,display:n,result:i};return e.status==="not_verified"&&e.reason!==void 0&&(r.reason=e.reason),e.reasonCode!==void 0&&(r.reasonCode=e.reasonCode),e.status==="not_verified"&&e.step!==void 0&&(r.step=e.step),e.retryAfter!==void 0&&(r.retryAfter=e.retryAfter),r}function oo(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 a of ro){let d=i[a];typeof d=="string"&&d!==""&&(r[a]=d)}let u=gt(i);return u!==void 0&&(r.idNumberMasked=u,r.nniMasked=u),r}var ro=["fullName","birthDate","birthYear","nationality","documentType","documentNumberMasked","expiryDate","retakeTarget"];function B(e,t,n,i){return{kind:"unsupported",key:`unsupported:${n}`,context:e,section:t,checkType:n,reason:i}}function io(e){return e.kind==="contact"?"contact":(e.kind==="identity_method","identity")}function so(e,t){let n=Et[e.kind]??[...Ce,...be],i=io(e),r=e.options.flatMap(a=>{if(a.available===!1||!n.includes(a.service))return[];let d={id:a.id,service:a.service};a.nationalEid!=null&&(d.nationalEid=a.nationalEid);let h=(a.channels??[]).filter(_=>_==="whatsapp"||_==="sms");return a.service==="phone_otp"&&h.length>0&&(d.channels=h),[d]});if(r.length===0){let a=e.options.length>0&&e.options.every(d=>d.service==="nfc");return B(t,i,"choice",a?"platform_unsupported":"update_required")}let u={nodeId:e.nodeId,kind:e.kind,selected:e.selected,options:r};if(e.kind==="identity_method"){let a={kind:"method",key:"method",context:t,section:i,options:r.map(h=>Z[h.service]),choice:u},d=r.find(h=>h.nationalEid!==void 0)?.nationalEid;return d!==void 0&&(a.nationalEid=d),a}return e.kind==="contact"?{kind:"contact_choice",key:"contact_choice",context:t,section:i,options:r.map(a=>Tt[a.service]),selected:null,locked:!1,choice:u}:{kind:"choice",key:`choice:${e.nodeId}`,context:t,section:i,choice:u}}function ao(e,t,n,i){let r=e.nativeApp,u=typeof r=="object"&&r!==null?r:{},a={sekyroApp:u.sekyroApp===!0};return typeof u.link=="string"&&u.link!==""&&(a.link=u.link),a.sekyroApp&&typeof u.sekyroAppLink=="string"&&u.sekyroAppLink.startsWith("sekyro://")&&(a.sekyroAppLink=u.sekyroAppLink),{kind:"native_app_required",key:`native_app_required:${i}`,context:t,section:n,checkType:i,nativeApp:a}}function Go(e,t={}){let n=Ln(e);if(I(e)||e.reasonCode===we)return no(e,n);let i=e.plan;if(i===void 0||!Array.isArray(i.sections))return B(n,null,"plan","update_required");let r=st(e);if(r!==null)return so(r,n);let u=i.current===null?void 0:i.steps.find(g=>g.id===i.current),a=g=>{let m={kind:"processing",key:"processing",context:n,section:g!==void 0?V(g):i.sections.find(M=>M.state==="current")?.id??null,stalled:!1};return typeof g?.service=="string"&&g.service!==""&&(m.service=g.service),m};if(i.current===null)return a(i.steps.find(g=>g.state==="processing"));if(u===void 0)return B(n,null,"step","update_required");if(!En.has(u.service))return u.interaction==="server"?a(u):B(n,V(u),u.service,"update_required");if(vn.has(u.service)||!at(u))return a(u);let d=u,h=Dn(d),_=d.checkType,S=V(d);if(d.requiresNativeApp===!0)return ao(e,n,S,_);let P=t.isMobile===!1?z(e,d):null;if(P==="phone")return{kind:"mobile_required",key:"mobile_required",context:n,section:S,checkType:_};switch(_){case"phone_otp":case"email_otp":return Bn(e,d,n,h);case"population_registry":return jn(e,d,n,h);case"eid_auth":return Xn(e,d,n,h);case"doc_ocr":return Yn(e,d,n,h,P==="upload_or_phone");case"identity_confirm":return oo(e,n,S)??a(d);case"portrait_icao":return Ot(e,d,n,h,"capture",P==="upload_or_phone");case"liveness":case"face_match":{let g=zn(e,d);if(g!==null)return Ot(e,g,n,h,"match");let m=d.requiresMobile===!0,M=se(e);return{kind:"liveness",key:"biometric",context:n,section:S,mode:_==="face_match"?"selfie":"liveness",requiresMobile:m,instructions:M===null?"standard":"icao",icao:M,livePhoto:Jn(e,_),...h}}case"poa":return $n(e,d,n,h,P==="upload_or_phone");case"form":{let g=wt(d.form);return g===null?B(n,S,_,"update_required"):{kind:"form",key:"form",context:n,section:S,form:g,dir:bt(g.locale),...h}}case"nfc_chip":return B(n,S,_,"platform_unsupported");default:return B(n,S,_,"update_required")}}export{Jt as a,Xt as b,sn as c,an as d,cn as e,wo as f,dn as g,kt as h,ln as i,fn as j,Ro as k,Ct as l,Io as m,b as n,bt as o,kn as p,Cn as q,At as r,Pn as s,Oo as t,qo as u,we as v,V as w,Ae as x,vt as y,zn as z,Go as A};
@@ -0,0 +1 @@
1
+ var b=new Set(["challenge_frame_blocked","challenge_script_blocked","site_key_rejected","challenge_failed","timeout","embedder_opaque"]),i=class extends Error{constructor(n,t){super(`Sekyro challenge failed: ${n}${t!==void 0?` (${t})`:""}`),this.name="ChallengeError",this.code=n,t!==void 0&&(this.detail=t)}},_=3e4,E=12e4,p="sekyro.challenge.",v="position:fixed;width:1px;height:1px;inset-block-start:0;inset-inline-start:0;opacity:0;pointer-events:none;border:0",c=null,g=Promise.resolve();function F(){u(),g=Promise.resolve(),m=!1}function d(){return new i("aborted")}function C(){let e=globalThis.crypto;return e!==void 0&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function h(e){return new URL(e,document.baseURI).origin}function u(){let e=c;if(e!==null){c=null,window.removeEventListener("message",e.listener),e.iframe.remove();for(let n of e.waiters.values())n.reject(new i("challenge_frame_blocked"));e.waiters.clear()}}function k(e,n){if(n.source!==e.iframe.contentWindow||n.origin!==e.origin)return;let t=n.data;if(typeof t!="object"||t===null)return;let r=t;if(typeof r.type!="string"||!r.type.startsWith(p)||r.v!==1)return;if(r.type==="sekyro.challenge.ready"){e.readyMs??(e.readyMs=Date.now()-e.insertedAt),e.isReady=!0,e.onReady?.();return}if(typeof r.id!="string")return;let a=e.waiters.get(r.id);if(a!==void 0){if(r.type==="sekyro.challenge.token"&&typeof r.token=="string"&&r.token!=="")e.waiters.delete(r.id),a.resolve(r.token);else if(r.type==="sekyro.challenge.error"){e.waiters.delete(r.id);let o=typeof r.code=="string"&&b.has(r.code)?r.code:"challenge_failed",s=typeof r.detail=="string"||typeof r.detail=="number"?String(r.detail).slice(0,32):void 0;a.reject(new i(o==="challenge_failed"&&s==="200100"?"clock_wrong":o,s))}}}function M(e){if(c!==null&&c.url===e)return c;u();let n=document.createElement("iframe");n.setAttribute("title","Security check"),n.setAttribute("aria-hidden","true"),n.setAttribute("tabindex","-1"),n.setAttribute("referrerpolicy","no-referrer"),n.setAttribute("style",v);let t={url:e,origin:h(e),iframe:n,isReady:!1,insertedAt:Date.now(),onReady:null,waiters:new Map,listener:r=>k(t,r)};return window.addEventListener("message",t.listener),n.src=e,document.body.appendChild(n),c=t,t}function A(e,n,t){return e.isReady?Promise.resolve():new Promise((r,a)=>{let o=()=>{clearTimeout(l),t?.removeEventListener("abort",s),e.onReady=null},s=()=>{o(),a(d())},l=setTimeout(()=>{o(),a(new i("challenge_frame_blocked"))},n);t?.addEventListener("abort",s,{once:!0}),e.onReady=()=>{o(),r()}})}async function y(e){if(e.signal?.aborted)throw d();let n=M(e.frameUrl);try{return await x(n,e)}catch(t){throw t instanceof i&&n.readyMs!==void 0&&(t.readyMs??(t.readyMs=n.readyMs)),t}}async function x(e,n){let t=n.signal;await A(e,n.readyTimeoutMs??_,t);let r=e.iframe.contentWindow;if(r===null)throw new i("challenge_frame_blocked");let a=n.timeoutMs??E,o=C(),s,l;try{return await new Promise((w,f)=>{e.waiters.set(o,{resolve:w,reject:f}),s=setTimeout(()=>f(new i("timeout")),a),t!==void 0&&(l=()=>f(d()),t.addEventListener("abort",l,{once:!0})),r.postMessage({type:"sekyro.challenge.request",v:1,id:o,siteKey:n.siteKey,action:n.action,subject:n.subject},e.origin)})}finally{clearTimeout(s),t!==void 0&&l!==void 0&&t.removeEventListener("abort",l),e.waiters.delete(o)}}var m=!1;function R(e,n){if(m)return;let t;if(n==="challenge_frame_blocked"){let r=e;try{r=h(e)}catch{}t=`Sekyro: the security check frame could not load. Allow \`frame-src ${r}\` in your Content-Security-Policy.`}else if(n==="embedder_opaque")t="Sekyro: the security check needs a page with an origin. Do not run the SDK in a sandboxed or data: document.";else return;m=!0,console.warn(t)}async function S(e){if(globalThis.origin==="null")throw new i("embedder_opaque");if(e.signal?.aborted)throw d();try{return await y(e)}catch(n){if(u(),e.signal?.aborted||n instanceof i&&n.code==="aborted")throw d();if(n instanceof i&&n.code==="timeout")throw n;try{return await y(e)}catch(t){throw u(),e.signal?.aborted?d():t instanceof i?t:new i("challenge_failed")}}}function T(e){let n=()=>S(e).catch(r=>{throw r instanceof i&&R(e.frameUrl,r.code),r}),t=g.then(n,n);return g=t.catch(()=>{}),t}export{i as a,_ as b,E as c,F as d,T as e};
@@ -1 +1 @@
1
- "use strict";var g=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var X=Object.prototype.hasOwnProperty;var b=(t,e)=>()=>(t&&(e=t(t=0)),e);var M=(t,e)=>{for(var n in e)g(t,n,{get:e[n],enumerable:!0})},J=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of z(e))!X.call(t,o)&&o!==n&&g(t,o,{get:()=>e[o],enumerable:!(r=j(e,o))||r.enumerable});return t};var Q=t=>J(g({},"__esModule",{value:!0}),t);var v=b(()=>{"use strict"});function _(t,e){return new Promise(n=>{let r=setTimeout(()=>n(void 0),e),o=i=>{clearTimeout(r),n(i)};try{t().then(o,()=>o(void 0))}catch{o(void 0)}})}async function R(t){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(JSON.stringify(t)));return Array.from(new Uint8Array(e).subarray(0,8),n=>n.toString(16).padStart(2,"0")).join("")}var E=b(()=>{"use strict";v()});var H={};M(H,{computePrint:()=>fe,readHints:()=>O});function A(t,e){if(typeof t!="string")return;let n=t.trim();return n.length>0&&n.length<=e?n:void 0}async function O(){let t=navigator.userAgentData;if(typeof t?.getHighEntropyValues!="function")return;let e=await _(()=>t.getHighEntropyValues(["model","platformVersion"]),se);if(e==null)return;let n=A(e.model,ce),r=A(e.platformVersion,de),o={...n!==void 0?{model:n}:{},...r!==void 0?{platformVersion:r}:{}};return Object.keys(o).length>0?o:void 0}async function pe(){let[t,e]=await Promise.all([new x.Thumbmark({stabilize:["private","iframe"],exclude:["permissions","webrtc","speech"],logging:!1,collect_beacon:!1,timeout:oe}).get(),O()]),n=t?.thumbmark;if(typeof n!="string"||n.length<ue||n.length>le)return;let r={};for(let o of re){let i=t.components?.[o];i==null||i.timeout==="true"||(r[o]=await R(i))}return{hash:n,c:r,...e!==void 0?{hints:e}:{}}}function me(){return new Promise(t=>{typeof globalThis.requestIdleCallback=="function"?globalThis.requestIdleCallback(()=>t(),{timeout:ae}):t()})}async function fe(t){return t()||(await me(),t())?"busy":_(pe,ie)}var x,re,oe,ie,se,ae,ce,de,ue,le,N=b(()=>{"use strict";x=require("@thumbmarkjs/thumbmarkjs");E();re=["canvas","webgl","audio","fonts","hardware","screen","system","locales","math","plugins"],oe=2e3,ie=4e3,se=1e3,ae=2e3,ce=64,de=32,ue=8,le=128});var He={};M(He,{HostedApiError:()=>u,HostedClient:()=>h,KNOWN_CODES:()=>P,SEKYRO_SDK_HEADER:()=>C,icaoPolicyOf:()=>$,isInAppBrowser:()=>y,isKnownCode:()=>L,portraitIcaoGate:()=>G,stripMimeParams:()=>p});module.exports=Q(He);var Z=600;function I(){if(typeof window>"u"||typeof navigator>"u")return"desktop";let t=navigator.userAgentData,e=t?.mobile||/Android|i(Pad)?OS/.test(String(t?.platform)),n=String(navigator.userAgent??"");if(/iPhone|iPod/i.test(n))return"phone";if(/iPad/i.test(n))return"tablet";if(/Android/i.test(n))return/Mobile/i.test(n)?"phone":"tablet";if(/BlackBerry|IEMobile|Opera Mini/i.test(n))return"phone";if(!e){if(Number(navigator.maxTouchPoints??0)<=1)return"desktop";if(/Macintosh/.test(n))return"tablet";if(/Windows NT|CrOS/.test(n)||!te())return"desktop"}let r=ee();return r>0&&r<Z?"phone":"tablet"}function ee(){try{let t=window.screen,e=Number(t?.width??0),n=Number(t?.height??0);return e>0&&n>0?Math.min(e,n):0}catch{return 0}}function te(){try{return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}catch{return!1}}var f="0.1.0-rc.31";var ne=/FBAN|FBAV|FB_IAB|FBIOS|MessengerForiOS|Instagram|WhatsApp|musical_ly|BytedanceWebview|TikTok|Snapchat|\bLine\/|LinkedInApp|Pinterest|MicroMessenger|; wv\)/i;function y(t){let e=t??(typeof navigator>"u"?"":String(navigator.userAgent??""));return ne.test(e)}var V="sekyro.did",ye=1e4,he=()=>globalThis.process?.versions?.node,D;function F(){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,n=>n.toString(16).padStart(2,"0")).join("")}}catch{}}function ge(){try{let t=localStorage.getItem(V);if(t)return t;let e=F();return e!==void 0&&localStorage.setItem(V,e),e}catch{return D??(D=F()),D}}async function be(){let t=globalThis.crypto?.subtle;if(!t)return"";let e=navigator,n=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]),r=await t.digest("SHA-256",new TextEncoder().encode(n));return Array.from(new Uint8Array(r),o=>o.toString(16).padStart(2,"0")).join("").slice(0,32)}function _e(){try{let t=Number(navigator.maxTouchPoints);return Number.isFinite(t)&&t>=0?{touch:Math.min(64,Math.trunc(t))}:{}}catch{return{}}}function Te(t){let e=new TextEncoder().encode(t),n="";for(let r of e)n+=String.fromCharCode(r);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function we(t){let e,n,r,o,i,a,d=()=>a?.readyState==="live",s=()=>{i!==void 0||!globalThis.crypto?.subtle||he()||d()||(i=Promise.race([Promise.resolve().then(()=>(N(),H)),new Promise(c=>setTimeout(c,ye))]).then(c=>c?.computePrint(d)).then(c=>{c==="busy"?i=void 0:o=c}).catch(()=>{}))};return{timezone(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone?.slice(0,64)||void 0}catch{return}},noteCameraLabel(c){c&&(e=c.slice(0,128))},noteCamera(c){n=c},noteCameraTrack(c){a=c},async deviceHeader(){try{r??(r=be().catch(()=>""));let c=[];navigator.webdriver&&c.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&c.push("headless");let l=await r,m=ge(),Y={v:1,platform:"web",sdk:t.sdk.slice(0,64),caps:["session_proof"],ids:[...m?[{kind:"web_local",value:m.slice(0,128)}]:[],...l?[{kind:"web_fp",value:l}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},..._e(),...e?{cameraLabel:e}:{},...c.length?{signals:c}:{},...o?{print:{v:2,...o,...n?{camera:n}:{}}}:{},...y()?{inApp:!0}:{}},W=Te(JSON.stringify(Y));return s(),W}catch{return}},printReady(){return i??Promise.resolve()}}}var T=Symbol.for("sekyro.web.clientContext"),w=globalThis,S=w[T]??(w[T]=we({sdk:`@sekyro/web@${f}`}));var P=["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","native_app_required"];function L(t){return P.includes(t)}var u=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 K(t,e,n=Math.random){let r=(t??e)*1e3,o=Math.min(Math.max(r,500),2e4),i=Math.round(o*(1+(n()*2-1)*.25));return Math.min(Math.max(i,500),2e4)}var Se=6e4,U=4,Pe=3e4,ke=9e5,Ce=200,Me=5,Ie=400,ve=new Set(["server_busy","request_timeout"]),Re=2;function p(t){return(t.split(";")[0]??"").trim()}var Ee={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},C=`@sekyro/web/${f}`,Ae=C,h=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=(r,o)=>(n??globalThis.fetch).call(globalThis,r,o),this.requestTimeoutMs=e.requestTimeoutMs??Pe,this.retryAttempts=e.inProgressRetry?.attempts??Me,this.retryDelayMs=e.inProgressRetry?.delayMs??Ie,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 testerGate(e){return this.api("POST","/hosted/tester-gate",{body:{input:e}})}async reportCaptureIssue(e){let n=typeof e.name=="string"?e.name.replace(/[^A-Za-z]/g,"").slice(0,40):"",r=typeof e.engineKind=="string"&&/^[a-z_]{1,32}$/.test(e.engineKind)?e.engineKind:void 0,o=typeof e.attempt=="number"&&Number.isInteger(e.attempt)&&e.attempt>=0&&e.attempt<=1e3?e.attempt:void 0,i=[e.check,o??"",e.kind,n,e.phase??""].join("|"),a=this.reportedIssues.get(i);if(a!==void 0)return a;let d={check:e.check,kind:e.kind,...n!==""?{name:n}:{},...e.phase!==void 0?{phase:e.phase}:{},...r!==void 0?{engineKind:r}:{},...o!==void 0?{attempt:o}:{},...e.formFactor!==void 0?{formFactor:e.formFactor}:{},...typeof e.detail=="string"&&/^\d{1,10}$/.test(e.detail)?{detail:e.detail}:{},...B(e.challengeMs)?{challengeMs:e.challengeMs}:{},...B(e.readyMs)?{readyMs:e.readyMs}:{},...e.inApp===!0?{inApp:!0}:{}},s=this.api("POST","/hosted/capture-issue",{body:d,empty:!0}).catch(()=>{this.reportedIssues.delete(i)});return this.reportedIssues.set(i,s),s}async choose(e,n){let r=await this.api("POST","/hosted/choice",{body:{nodeId:e,option:n},busyRetry:!0});return this.sessionId=r.sessionId,r}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,r,o={}){let i=await this.ensureSessionId(),a={kind:e,contentType:p(n),contentLength:r,...o.source==="upload"?{source:"upload"}:{}};return this.api("POST",`/sessions/${i}/media`,{body:a})}armCapture(e=2){this.fillCaptureNonces(e)}async presignCapture(e,n,r,o={}){let i=await this.ensureSessionId(),a=await this.takeCaptureNonce(),d=a===void 0?void 0:{nonce:a,...o.engine!==void 0?{engine:o.engine.slice(0,32)}:{},...o.durationMs!==void 0&&Number.isFinite(o.durationMs)?{captureMs:Math.min(36e5,Math.max(0,Math.round(o.durationMs)))}:{}},s={kind:e,contentType:p(n),contentLength:r,capture:d};return this.api("POST",`/sessions/${i}/media`,{body:s})}async takeCaptureNonce(){let e=()=>{let n=Date.now();return this.captureNonces=this.captureNonces.filter(r=>r.expiresAt-Se>n),this.captureNonces.shift()?.nonce};for(let n=0;n<2;n++){let r=e();if(r!==void 0)return r;await this.fillCaptureNonces(1)}return e()}fillCaptureNonces(e){return this.captureFetch??(this.captureFetch=(async()=>{try{let n=await this.ensureSessionId(),r=await this.api("POST",`/sessions/${n}/media/capture-nonces`,{body:{count:Math.min(U,Math.max(1,e))}}),o=Date.now()+Math.max(0,r.expiresIn)*1e3;for(let i of Array.isArray(r.nonces)?r.nonces:[])typeof i=="string"&&i.length>0&&this.captureNonces.push({nonce:i,expiresAt:o});this.captureNonces=this.captureNonces.slice(-U)}catch{}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(e,n,r){let o;try{o=await this.fetchImpl(e,{method:"PUT",headers:{"content-type":p(r)},body:n,signal:AbortSignal.timeout(ke)})}catch(i){throw k(i)}if(!o.ok){let i=(await o.text().catch(()=>"")).slice(0,Ce);throw new u({status:o.status,code:"upload_failed",message:`media upload failed (HTTP ${o.status})${i?`: ${i}`:""}`})}}async completeMedia(e){let n=await this.ensureSessionId();return this.api("POST",`/sessions/${n}/media/complete`,{body:{key:e}})}async submitCheck(e,n,r={}){let o=await this.ensureSessionId(),i={input:n,forceOutcome:r.forceOutcome};return this.api("POST",`/sessions/${o}/checks/${e}`,{body:i,idempotencyKey:r.idempotencyKey,...r.browserCheckToken!==void 0?{browserCheckToken:r.browserCheckToken}:{},busyRetry:r.idempotencyKey!==void 0})}async uploadAndSubmit(e,n,r,o={}){let i=p(n.contentType),a=await this.presign(n.kind,i,n.blob.size);await this.uploadToSpaces(a.uploadUrl,n.blob,i);let d=await this.completeMedia(a.key),s={...r,[Ee[e]]:d.key};return this.submitCheck(e,s,o)}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,r={}){let o=e==="GET"||r.busyRetry===!0,i=`${this.apiOrigin}/api/v2${n}`,a={"x-session-token":this.sessionToken,"x-sekyro-sdk":Ae};r.body!==void 0&&(a["content-type"]="application/json"),r.idempotencyKey!==void 0&&(a["x-idempotency-key"]=r.idempotencyKey),r.browserCheckToken!==void 0&&(a["sekyro-browser-check"]=r.browserCheckToken);try{let d=S.timezone();d!==void 0&&(a["sekyro-client-timezone"]=d)}catch{}a["sekyro-client-form-factor"]=I();try{let d=await S.deviceHeader();d!==void 0&&(a["sekyro-client-device"]=d)}catch{}for(let d=0;;d++){let s;try{s=await this.fetchImpl(i,{method:e,headers:a,...r.body!==void 0?{body:JSON.stringify(r.body)}:{},cache:"no-store",signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(l){throw k(l)}if(s.ok){if(r.empty===!0)return;if(r.blob===!0)try{return await s.blob()}catch(m){throw k(m)}let l;try{l=await s.json()}catch{throw new u({status:s.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${s.status})`})}return xe(l)}let c=await Oe(s);if(c.code==="idempotency_in_progress"&&d<this.retryAttempts){this.retryDelayMs>0&&await q(this.retryDelayMs);continue}if(o&&c.status===503&&ve.has(c.code)){o=!1,await q(K(c.retryAfterSeconds,Re,this.random));continue}throw c}}};function B(t){return typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<=6e5}function k(t){if((typeof t=="object"&&t!==null?t.name:void 0)==="TimeoutError")return new u({status:0,code:"timeout",message:"request timed out"});let n=t instanceof Error?t.message:String(t);return new u({status:0,code:"network_error",message:`network request failed: ${n}`})}function xe(t){return t!==null&&typeof t=="object"&&"success"in t&&"data"in t?t.data:t}async function Oe(t){let e="unknown_error",n=`request failed (HTTP ${t.status})`,r=Number.NaN,o;try{let d=await t.json();if(d!==null&&typeof d=="object"){let s=d;typeof s.code=="string"&&s.code.length>0&&(e=s.code),typeof s.message=="string"&&s.message.length>0&&(n=s.message),typeof s.retryAfterSeconds=="number"&&(r=s.retryAfterSeconds),Array.isArray(s.details?.issues)?o=s.details:Array.isArray(s.details?.errors)&&(o={...s.details,issues:[]})}}catch{}let i=t.headers.get("retry-after"),a=i===null?Math.floor(r):Number.parseInt(i,10);return new u({status:t.status,code:e,message:n,...Number.isFinite(a)&&a>=0?{retryAfterSeconds:a}:{},details:o})}function q(t){return new Promise(e=>setTimeout(e,t))}function $(t){let e=t?.portrait,n=e?.icao,r=e?.purpose==="id_document";return n==null?r?{policy:"reject",profile:"id_document"}:null:{policy:n.policy==="alert"?"alert":"reject",profile:r||n.profile==="id_document"?"id_document":"selfie"}}function G(t){return{...t.baselineEyeOpenness!==void 0?{baselineEyeOpenness:t.baselineEyeOpenness}:{},...t.baselineEyeOpennessLeft!==void 0&&t.baselineEyeOpennessRight!==void 0?{baselineEyeOpennessLeft:t.baselineEyeOpennessLeft,baselineEyeOpennessRight:t.baselineEyeOpennessRight}:{},criteria:t.verdict??{},...t.backgroundCheck!==void 0?{backgroundCheck:t.backgroundCheck}:{}}}0&&(module.exports={HostedApiError,HostedClient,KNOWN_CODES,SEKYRO_SDK_HEADER,icaoPolicyOf,isInAppBrowser,isKnownCode,portraitIcaoGate,stripMimeParams});
1
+ "use strict";var g=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var X=Object.prototype.hasOwnProperty;var b=(t,e)=>()=>(t&&(e=t(t=0)),e);var M=(t,e)=>{for(var n in e)g(t,n,{get:e[n],enumerable:!0})},J=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of z(e))!X.call(t,i)&&i!==n&&g(t,i,{get:()=>e[i],enumerable:!(o=j(e,i))||o.enumerable});return t};var Q=t=>J(g({},"__esModule",{value:!0}),t);var R=b(()=>{"use strict"});function _(t,e){return new Promise(n=>{let o=setTimeout(()=>n(void 0),e),i=r=>{clearTimeout(o),n(r)};try{t().then(i,()=>i(void 0))}catch{i(void 0)}})}async function v(t){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(JSON.stringify(t)));return Array.from(new Uint8Array(e).subarray(0,8),n=>n.toString(16).padStart(2,"0")).join("")}var E=b(()=>{"use strict";R()});var H={};M(H,{computePrint:()=>fe,readHints:()=>O});function A(t,e){if(typeof t!="string")return;let n=t.trim();return n.length>0&&n.length<=e?n:void 0}async function O(){let t=navigator.userAgentData;if(typeof t?.getHighEntropyValues!="function")return;let e=await _(()=>t.getHighEntropyValues(["model","platformVersion"]),se);if(e==null)return;let n=A(e.model,ce),o=A(e.platformVersion,de),i={...n!==void 0?{model:n}:{},...o!==void 0?{platformVersion:o}:{}};return Object.keys(i).length>0?i:void 0}async function pe(){let[t,e]=await Promise.all([new x.Thumbmark({stabilize:["private","iframe"],exclude:["permissions","webrtc","speech"],logging:!1,collect_beacon:!1,timeout:ie}).get(),O()]),n=t?.thumbmark;if(typeof n!="string"||n.length<ue||n.length>le)return;let o={};for(let i of oe){let r=t.components?.[i];r==null||r.timeout==="true"||(o[i]=await v(r))}return{hash:n,c:o,...e!==void 0?{hints:e}:{}}}function me(){return new Promise(t=>{typeof globalThis.requestIdleCallback=="function"?globalThis.requestIdleCallback(()=>t(),{timeout:ae}):t()})}async function fe(t){return t()||(await me(),t())?"busy":_(pe,re)}var x,oe,ie,re,se,ae,ce,de,ue,le,N=b(()=>{"use strict";x=require("@thumbmarkjs/thumbmarkjs");E();oe=["canvas","webgl","audio","fonts","hardware","screen","system","locales","math","plugins"],ie=2e3,re=4e3,se=1e3,ae=2e3,ce=64,de=32,ue=8,le=128});var De={};M(De,{HostedApiError:()=>l,HostedClient:()=>h,KNOWN_CODES:()=>P,SEKYRO_SDK_HEADER:()=>C,icaoPolicyOf:()=>$,isInAppBrowser:()=>y,isKnownCode:()=>L,portraitIcaoGate:()=>G,stripMimeParams:()=>m});module.exports=Q(De);var Z=600;function I(){if(typeof window>"u"||typeof navigator>"u")return"desktop";let t=navigator.userAgentData,e=t?.mobile||/Android|i(Pad)?OS/.test(String(t?.platform)),n=String(navigator.userAgent??"");if(/iPhone|iPod/i.test(n))return"phone";if(/iPad/i.test(n))return"tablet";if(/Android/i.test(n))return/Mobile/i.test(n)?"phone":"tablet";if(/BlackBerry|IEMobile|Opera Mini/i.test(n))return"phone";if(!e){if(Number(navigator.maxTouchPoints??0)<=1)return"desktop";if(/Macintosh/.test(n))return"tablet";if(/Windows NT|CrOS/.test(n)||!te())return"desktop"}let o=ee();return o>0&&o<Z?"phone":"tablet"}function ee(){try{let t=window.screen,e=Number(t?.width??0),n=Number(t?.height??0);return e>0&&n>0?Math.min(e,n):0}catch{return 0}}function te(){try{return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}catch{return!1}}var f="0.1.0-rc.33";var ne=/FBAN|FBAV|FB_IAB|FBIOS|MessengerForiOS|Instagram|WhatsApp|musical_ly|BytedanceWebview|TikTok|Snapchat|\bLine\/|LinkedInApp|Pinterest|MicroMessenger|; wv\)/i;function y(t){let e=t??(typeof navigator>"u"?"":String(navigator.userAgent??""));return ne.test(e)}var V="sekyro.did",ye=1e4,he=()=>globalThis.process?.versions?.node,D;function F(){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,n=>n.toString(16).padStart(2,"0")).join("")}}catch{}}function ge(){try{let t=localStorage.getItem(V);if(t)return t;let e=F();return e!==void 0&&localStorage.setItem(V,e),e}catch{return D??(D=F()),D}}async function be(){let t=globalThis.crypto?.subtle;if(!t)return"";let e=navigator,n=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]),o=await t.digest("SHA-256",new TextEncoder().encode(n));return Array.from(new Uint8Array(o),i=>i.toString(16).padStart(2,"0")).join("").slice(0,32)}function _e(){try{let t=Number(navigator.maxTouchPoints);return Number.isFinite(t)&&t>=0?{touch:Math.min(64,Math.trunc(t))}:{}}catch{return{}}}function Se(t){let e=new TextEncoder().encode(t),n="";for(let o of e)n+=String.fromCharCode(o);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Te(t){let e,n,o,i,r,c,d=()=>c?.readyState==="live",s=()=>{r!==void 0||!globalThis.crypto?.subtle||he()||d()||(r=Promise.race([Promise.resolve().then(()=>(N(),H)),new Promise(a=>setTimeout(a,ye))]).then(a=>a?.computePrint(d)).then(a=>{a==="busy"?r=void 0:i=a}).catch(()=>{}))};return{timezone(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone?.slice(0,64)||void 0}catch{return}},noteCameraLabel(a){a&&(e=a.slice(0,128))},noteCamera(a){n=a},noteCameraTrack(a){c=a},async deviceHeader(){try{o??(o=be().catch(()=>""));let a=[];navigator.webdriver&&a.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&a.push("headless");let u=await o,p=ge(),Y={v:1,platform:"web",sdk:t.sdk.slice(0,64),caps:["session_proof"],ids:[...p?[{kind:"web_local",value:p.slice(0,128)}]:[],...u?[{kind:"web_fp",value:u}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},..._e(),...e?{cameraLabel:e}:{},...a.length?{signals:a}:{},...i?{print:{v:2,...i,...n?{camera:n}:{}}}:{},...y()?{inApp:!0}:{}},W=Se(JSON.stringify(Y));return s(),W}catch{return}},printReady(){return r??Promise.resolve()}}}var S=Symbol.for("sekyro.web.clientContext"),T=globalThis,w=T[S]??(T[S]=Te({sdk:`@sekyro/web@${f}`}));var P=["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","native_app_required"];function L(t){return P.includes(t)}var l=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 U(t,e,n=Math.random){let o=(t??e)*1e3,i=Math.min(Math.max(o,500),2e4),r=Math.round(i*(1+(n()*2-1)*.25));return Math.min(Math.max(r,500),2e4)}var we=6e4,K=4,Pe=3e4,ke=9e5,Ce=200,Me=5,Ie=400,Re=new Set(["server_busy","request_timeout"]),ve=20,Ee=60,Ae=600,xe=2;function m(t){return(t.split(";")[0]??"").trim()}var Oe={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},C=`@sekyro/web/${f}`,He=C,h=class{constructor(e){this.sessionId=null;this.bootstrap=null;this.captureNonces=[];this.captureFetch=null;this.reportedIssues=new Map;this.issueReports=0;this.issuesPausedUntil=0;this.apiOrigin=e.apiOrigin.replace(/\/+$/,""),this.sessionToken=e.sessionToken;let n=e.fetch;this.fetchImpl=(o,i)=>(n??globalThis.fetch).call(globalThis,o,i),this.requestTimeoutMs=e.requestTimeoutMs??Pe,this.retryAttempts=e.inProgressRetry?.attempts??Me,this.retryDelayMs=e.inProgressRetry?.delayMs??Ie,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 testerGate(e){return this.api("POST","/hosted/tester-gate",{body:{input:e}})}async reportCaptureIssue(e){let n=typeof e.name=="string"?e.name.replace(/[^A-Za-z]/g,"").slice(0,40):"",o=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,r=e.check==="attestation"?i??"":"",c=[e.check,r,e.kind,n,e.phase??"",o??""].join("|"),d=this.reportedIssues.get(c);if(d!==void 0)return d;if(Date.now()<this.issuesPausedUntil||this.issueReports>=ve)return;let s={check:e.check,kind:e.kind,...n!==""?{name:n}:{},...e.phase!==void 0?{phase:e.phase}:{},...o!==void 0?{engineKind:o}:{},...i!==void 0?{attempt:i}:{},...e.formFactor!==void 0?{formFactor:e.formFactor}:{},...typeof e.detail=="string"&&/^\d{1,10}$/.test(e.detail)?{detail:e.detail}:{},...B(e.challengeMs)?{challengeMs:e.challengeMs}:{},...B(e.readyMs)?{readyMs:e.readyMs}:{},...e.inApp===!0?{inApp:!0}:{}};this.issueReports+=1;let a=this.api("POST","/hosted/capture-issue",{body:s,empty:!0}).catch(u=>{if(u instanceof l&&u.status===429){let p=Math.min(Math.max(u.retryAfterSeconds??Ee,0),Ae);this.issuesPausedUntil=Math.max(this.issuesPausedUntil,Date.now()+p*1e3);return}(!(u instanceof l)||u.status===0||u.status>=500)&&this.reportedIssues.delete(c)});return this.reportedIssues.set(c,a),a}async choose(e,n){let o=await this.api("POST","/hosted/choice",{body:{nodeId:e,option:n},busyRetry:!0});return this.sessionId=o.sessionId,o}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,o,i={}){let r=await this.ensureSessionId(),c={kind:e,contentType:m(n),contentLength:o,...i.source==="upload"?{source:"upload"}:{}};return this.api("POST",`/sessions/${r}/media`,{body:c})}armCapture(e=2){this.fillCaptureNonces(e)}async presignCapture(e,n,o,i={}){let r=await this.ensureSessionId(),c=await this.takeCaptureNonce(),d=c===void 0?void 0:{nonce:c,...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)))}:{}},s={kind:e,contentType:m(n),contentLength:o,capture:d};return this.api("POST",`/sessions/${r}/media`,{body:s})}async takeCaptureNonce(){let e=()=>{let n=Date.now();return this.captureNonces=this.captureNonces.filter(o=>o.expiresAt-we>n),this.captureNonces.shift()?.nonce};for(let n=0;n<2;n++){let o=e();if(o!==void 0)return o;await this.fillCaptureNonces(1)}return e()}fillCaptureNonces(e){return this.captureFetch??(this.captureFetch=(async()=>{try{let n=await this.ensureSessionId(),o=await this.api("POST",`/sessions/${n}/media/capture-nonces`,{body:{count:Math.min(K,Math.max(1,e))}}),i=Date.now()+Math.max(0,o.expiresIn)*1e3;for(let r of Array.isArray(o.nonces)?o.nonces:[])typeof r=="string"&&r.length>0&&this.captureNonces.push({nonce:r,expiresAt:i});this.captureNonces=this.captureNonces.slice(-K)}catch{}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(e,n,o){let i;try{i=await this.fetchImpl(e,{method:"PUT",headers:{"content-type":m(o)},body:n,signal:AbortSignal.timeout(ke)})}catch(r){throw k(r)}if(!i.ok){let r=(await i.text().catch(()=>"")).slice(0,Ce);throw new l({status:i.status,code:"upload_failed",message:`media upload failed (HTTP ${i.status})${r?`: ${r}`:""}`})}}async completeMedia(e){let n=await this.ensureSessionId();return this.api("POST",`/sessions/${n}/media/complete`,{body:{key:e}})}async submitCheck(e,n,o={}){let i=await this.ensureSessionId(),r={input:n,forceOutcome:o.forceOutcome};return this.api("POST",`/sessions/${i}/checks/${e}`,{body:r,idempotencyKey:o.idempotencyKey,...o.browserCheckToken!==void 0?{browserCheckToken:o.browserCheckToken}:{},busyRetry:o.idempotencyKey!==void 0})}async uploadAndSubmit(e,n,o,i={}){let r=m(n.contentType),c=await this.presign(n.kind,r,n.blob.size);await this.uploadToSpaces(c.uploadUrl,n.blob,r);let d=await this.completeMedia(c.key),s={...o,[Oe[e]]:d.key};return this.submitCheck(e,s,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,o={}){let i=e==="GET"||o.busyRetry===!0,r=`${this.apiOrigin}/api/v2${n}`,c={"x-session-token":this.sessionToken,"x-sekyro-sdk":He};o.body!==void 0&&(c["content-type"]="application/json"),o.idempotencyKey!==void 0&&(c["x-idempotency-key"]=o.idempotencyKey),o.browserCheckToken!==void 0&&(c["sekyro-browser-check"]=o.browserCheckToken);try{let d=w.timezone();d!==void 0&&(c["sekyro-client-timezone"]=d)}catch{}c["sekyro-client-form-factor"]=I();try{let d=await w.deviceHeader();d!==void 0&&(c["sekyro-client-device"]=d)}catch{}for(let d=0;;d++){let s;try{s=await this.fetchImpl(r,{method:e,headers:c,...o.body!==void 0?{body:JSON.stringify(o.body)}:{},cache:"no-store",signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(u){throw k(u)}if(s.ok){if(o.empty===!0)return;if(o.blob===!0)try{return await s.blob()}catch(p){throw k(p)}let u;try{u=await s.json()}catch{throw new l({status:s.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${s.status})`})}return Ne(u)}let a=await Ve(s);if(a.code==="idempotency_in_progress"&&d<this.retryAttempts){this.retryDelayMs>0&&await q(this.retryDelayMs);continue}if(i&&a.status===503&&Re.has(a.code)){i=!1,await q(U(a.retryAfterSeconds,xe,this.random));continue}throw a}}};function B(t){return typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<=6e5}function k(t){if((typeof t=="object"&&t!==null?t.name:void 0)==="TimeoutError")return new l({status:0,code:"timeout",message:"request timed out"});let n=t instanceof Error?t.message:String(t);return new l({status:0,code:"network_error",message:`network request failed: ${n}`})}function Ne(t){return t!==null&&typeof t=="object"&&"success"in t&&"data"in t?t.data:t}async function Ve(t){let e="unknown_error",n=`request failed (HTTP ${t.status})`,o=Number.NaN,i;try{let d=await t.json();if(d!==null&&typeof d=="object"){let s=d;typeof s.code=="string"&&s.code.length>0&&(e=s.code),typeof s.message=="string"&&s.message.length>0&&(n=s.message),typeof s.retryAfterSeconds=="number"&&(o=s.retryAfterSeconds),Array.isArray(s.details?.issues)?i=s.details:Array.isArray(s.details?.errors)&&(i={...s.details,issues:[]})}}catch{}let r=t.headers.get("retry-after"),c=r===null?Math.floor(o):Number.parseInt(r,10);return new l({status:t.status,code:e,message:n,...Number.isFinite(c)&&c>=0?{retryAfterSeconds:c}:{},details:i})}function q(t){return new Promise(e=>setTimeout(e,t))}function $(t){let e=t?.portrait,n=e?.icao,o=e?.purpose==="id_document";return n==null?o?{policy:"reject",profile:"id_document"}:null:{policy:n.policy==="alert"?"alert":"reject",profile:o||n.profile==="id_document"?"id_document":"selfie"}}function G(t){return{...t.baselineEyeOpenness!==void 0?{baselineEyeOpenness:t.baselineEyeOpenness}:{},...t.baselineEyeOpennessLeft!==void 0&&t.baselineEyeOpennessRight!==void 0?{baselineEyeOpennessLeft:t.baselineEyeOpennessLeft,baselineEyeOpennessRight:t.baselineEyeOpennessRight}:{},criteria:t.verdict??{},...t.backgroundCheck!==void 0?{backgroundCheck:t.backgroundCheck}:{}}}0&&(module.exports={HostedApiError,HostedClient,KNOWN_CODES,SEKYRO_SDK_HEADER,icaoPolicyOf,isInAppBrowser,isKnownCode,portraitIcaoGate,stripMimeParams});
@@ -1,6 +1,6 @@
1
- export { H as HostedClient, a as HostedClientOptions, M as MediaCheckType, S as SEKYRO_SDK_HEADER, b as SubmitOptions, U as UploadMedia, s as stripMimeParams } from '../icao-gate-DVNkPclI.cjs';
2
- export { H as HostedApiError, a as HostedErrorDetails, b as HostedErrorIssue, K as KNOWN_CODES, c as KnownCode, i as icaoPolicyOf, d as isKnownCode, p as portraitIcaoGate } from '../icao-policy-c2Ykm9r2.cjs';
3
- export { A as AcceptedDocumentType, a as AttestationInput, C as CaptureContext, b as CaptureMode, c as CaptureNoncesResult, d as CaptureProof, e as CheckInputByType, f as CheckReason, g as CheckState, h as CheckType, i as ClosedBy, j as CompleteMediaResult, k as ConsentLocale, l as ContactChannel, D as DecisionReason, m as DocDeviceRead, n as DocOcrInput, o as DocReason, p as DocSide, E as EidAfterPass, q as EidAuthInput, r as EidReason, s as EmailOtpInput, t as EmailOtpReason, F as FaceMatchInput, u as FaceMatchReason, v as FormAddressValue, w as FormAnswerValue, x as FormChoiceView, y as FormConsentView, z as FormCustomQuestionView, B as FormFieldName, G as FormFieldQuestionView, H as FormInput, I as FormIssueCode, J as FormLocale, K as FormQuestionOptions, L as FormQuestionType, M as FormQuestionView, N as HostedAcceptedDocuments, O as HostedCaptureTuning, P as HostedChallengeView, Q as HostedConsentView, R as HostedDocumentCaptureTuning, S as HostedDocumentScanTuning, T as HostedDocumentsView, U as HostedEidView, V as HostedEmailOtpView, W as HostedFlowRef, X as HostedFormView, Y as HostedIcaoPolicy, Z as HostedIntegrity, _ as HostedLivePhotoTuning, $ as HostedNativeAppView, a0 as HostedNativeCaptureTuning, a1 as HostedOcrTuning, a2 as HostedOtpView, a3 as HostedPlanView, a4 as HostedPoaRuleKindView, a5 as HostedPoaRuleView, a6 as HostedPortraitPendingFix, a7 as HostedPortraitView, a8 as HostedProofOfAddressView, a9 as HostedSessionView, aa as HostedSimulationView, ab as HostedStepView, ac as HostedTesterGateView, ad as HostedVoiceLocale, ae as HostedVoiceView, af as IcaoCriterion, ag as IcaoReportEntry, ah as IdentityConfirmDecision, ai as IdentityMethod, aj as IdentitySummarySource, ak as IdentitySummaryView, al as LivenessCaptureInput, am as LivenessInput, an as LivenessReason, ao as MatchReason, ap as MediaKind, aq as MethodChoiceView, ar as NationalEidOption, as as NfcChipReason, at as NfcStepView, au as OtpChoiceView, av as PhoneCountryRule, aw as PhoneFormat, ax as PhoneOtpInput, ay as PhoneOtpReason, az as PhotoSource, aA as PhotoSourcePick, aB as PlanAttempts, aC as PlanChoiceKind, aD as PlanChoiceOption, aE as PlanChoiceView, aF as PlanSectionView, aG as PlanStepView, aH as PoaImagesInput, aI as PoaInput, aJ as PoaKind, aK as PoaLicenceInput, aL as PoaNameMatchMode, aM as PoaPdfInput, aN as PoaReason, aO as PoaRuleSource, aP as PopulationInput, aQ as PopulationReason, aR as PortraitFix, aS as PortraitFixReviewInput, aT as PortraitIcaoInput, aU as PortraitIcaoReason, aV as PortraitOutputFormat, aW as PresignRequest, aX as PresignUploadResult, aY as RecordConsentResult, aZ as ResolvedCaptureMode, a_ as SandboxSimulatedReason, a$ as SandboxSimulation, b0 as SessionDecidingStep, b1 as SessionFailureReason, b2 as SessionReason, b3 as SessionStatus, b4 as SessionStepView, b5 as SessionView, b6 as SimulatedCaptureInput, b7 as StepResult, b8 as StepSection, b9 as SubmitCheckBody, ba as TesterGateInput, bb as TesterGateResponse, bc as VerificationAssurance, bd as VerificationLevel } from '../types-B47mZ5TT.cjs';
1
+ export { H as HostedClient, a as HostedClientOptions, M as MediaCheckType, S as SEKYRO_SDK_HEADER, b as SubmitOptions, U as UploadMedia, s as stripMimeParams } from '../icao-gate-C731iewN.cjs';
2
+ export { H as HostedApiError, a as HostedErrorDetails, b as HostedErrorIssue, K as KNOWN_CODES, c as KnownCode, i as icaoPolicyOf, d as isKnownCode, p as portraitIcaoGate } from '../icao-policy-R7Jk5qF_.cjs';
3
+ export { A as AcceptedDocumentType, a as AttestationInput, C as CaptureContext, b as CaptureMode, c as CaptureNoncesResult, d as CaptureProof, e as CheckInputByType, f as CheckReason, g as CheckState, h as CheckType, i as ClosedBy, j as CompleteMediaResult, k as ConsentLocale, l as ContactChannel, D as DecisionReason, m as DocDeviceRead, n as DocOcrInput, o as DocReason, p as DocSide, E as EidAfterPass, q as EidAuthInput, r as EidReason, s as EmailOtpInput, t as EmailOtpReason, F as FaceMatchInput, u as FaceMatchReason, v as FormAddressValue, w as FormAnswerValue, x as FormChoiceView, y as FormConsentView, z as FormCustomQuestionView, B as FormFieldName, G as FormFieldQuestionView, H as FormInput, I as FormIssueCode, J as FormLocale, K as FormQuestionOptions, L as FormQuestionType, M as FormQuestionView, N as HostedAcceptedDocuments, O as HostedCaptureTuning, P as HostedChallengeView, Q as HostedConsentView, R as HostedDocumentCaptureTuning, S as HostedDocumentScanTuning, T as HostedDocumentsView, U as HostedEidView, V as HostedEmailOtpView, W as HostedFlowRef, X as HostedFormView, Y as HostedIcaoPolicy, Z as HostedIntegrity, _ as HostedLivePhotoTuning, $ as HostedNativeAppView, a0 as HostedNativeCaptureTuning, a1 as HostedOcrTuning, a2 as HostedOtpView, a3 as HostedPlanView, a4 as HostedPoaRuleKindView, a5 as HostedPoaRuleView, a6 as HostedPortraitPendingFix, a7 as HostedPortraitView, a8 as HostedProofOfAddressView, a9 as HostedSessionView, aa as HostedSimulationView, ab as HostedStepView, ac as HostedTesterGateView, ad as HostedVoiceLocale, ae as HostedVoiceView, af as IcaoCriterion, ag as IcaoReportEntry, ah as IdentityConfirmDecision, ai as IdentityMethod, aj as IdentitySummarySource, ak as IdentitySummaryView, al as LivenessCaptureInput, am as LivenessInput, an as LivenessReason, ao as MatchReason, ap as MediaKind, aq as MethodChoiceView, ar as NationalEidOption, as as NfcChipReason, at as NfcStepView, au as OtpChoiceView, av as PhoneCountryRule, aw as PhoneFormat, ax as PhoneOtpInput, ay as PhoneOtpReason, az as PhotoSource, aA as PhotoSourcePick, aB as PlanAttempts, aC as PlanChoiceKind, aD as PlanChoiceOption, aE as PlanChoiceView, aF as PlanSectionView, aG as PlanStepView, aH as PoaImagesInput, aI as PoaInput, aJ as PoaKind, aK as PoaLicenceInput, aL as PoaNameMatchMode, aM as PoaPdfInput, aN as PoaReason, aO as PoaRuleSource, aP as PopulationInput, aQ as PopulationReason, aR as PortraitFix, aS as PortraitFixReviewInput, aT as PortraitIcaoInput, aU as PortraitIcaoReason, aV as PortraitOutputFormat, aW as PresignRequest, aX as PresignUploadResult, aY as RecordConsentResult, aZ as ResolvedCaptureMode, a_ as SandboxSimulatedReason, a$ as SandboxSimulation, b0 as SessionDecidingStep, b1 as SessionFailureReason, b2 as SessionReason, b3 as SessionStatus, b4 as SessionStepView, b5 as SessionView, b6 as SimulatedCaptureInput, b7 as StepResult, b8 as StepSection, b9 as SubmitCheckBody, ba as TesterGateInput, bb as TesterGateResponse, bc as VerificationAssurance, bd as VerificationLevel } from '../types-BjzuJVOc.cjs';
4
4
 
5
5
  /** The page runs inside an app's WebView (WhatsApp, Instagram, Facebook, TikTok, Snapchat, LINE, LinkedIn, WeChat, an Android WebView…). */
6
6
  declare function isInAppBrowser(userAgent?: string): boolean;
@@ -1,6 +1,6 @@
1
- export { H as HostedClient, a as HostedClientOptions, M as MediaCheckType, S as SEKYRO_SDK_HEADER, b as SubmitOptions, U as UploadMedia, s as stripMimeParams } from '../icao-gate-Cp1C4IEZ.js';
2
- export { H as HostedApiError, a as HostedErrorDetails, b as HostedErrorIssue, K as KNOWN_CODES, c as KnownCode, i as icaoPolicyOf, d as isKnownCode, p as portraitIcaoGate } from '../icao-policy-CcrwfsVr.js';
3
- export { A as AcceptedDocumentType, a as AttestationInput, C as CaptureContext, b as CaptureMode, c as CaptureNoncesResult, d as CaptureProof, e as CheckInputByType, f as CheckReason, g as CheckState, h as CheckType, i as ClosedBy, j as CompleteMediaResult, k as ConsentLocale, l as ContactChannel, D as DecisionReason, m as DocDeviceRead, n as DocOcrInput, o as DocReason, p as DocSide, E as EidAfterPass, q as EidAuthInput, r as EidReason, s as EmailOtpInput, t as EmailOtpReason, F as FaceMatchInput, u as FaceMatchReason, v as FormAddressValue, w as FormAnswerValue, x as FormChoiceView, y as FormConsentView, z as FormCustomQuestionView, B as FormFieldName, G as FormFieldQuestionView, H as FormInput, I as FormIssueCode, J as FormLocale, K as FormQuestionOptions, L as FormQuestionType, M as FormQuestionView, N as HostedAcceptedDocuments, O as HostedCaptureTuning, P as HostedChallengeView, Q as HostedConsentView, R as HostedDocumentCaptureTuning, S as HostedDocumentScanTuning, T as HostedDocumentsView, U as HostedEidView, V as HostedEmailOtpView, W as HostedFlowRef, X as HostedFormView, Y as HostedIcaoPolicy, Z as HostedIntegrity, _ as HostedLivePhotoTuning, $ as HostedNativeAppView, a0 as HostedNativeCaptureTuning, a1 as HostedOcrTuning, a2 as HostedOtpView, a3 as HostedPlanView, a4 as HostedPoaRuleKindView, a5 as HostedPoaRuleView, a6 as HostedPortraitPendingFix, a7 as HostedPortraitView, a8 as HostedProofOfAddressView, a9 as HostedSessionView, aa as HostedSimulationView, ab as HostedStepView, ac as HostedTesterGateView, ad as HostedVoiceLocale, ae as HostedVoiceView, af as IcaoCriterion, ag as IcaoReportEntry, ah as IdentityConfirmDecision, ai as IdentityMethod, aj as IdentitySummarySource, ak as IdentitySummaryView, al as LivenessCaptureInput, am as LivenessInput, an as LivenessReason, ao as MatchReason, ap as MediaKind, aq as MethodChoiceView, ar as NationalEidOption, as as NfcChipReason, at as NfcStepView, au as OtpChoiceView, av as PhoneCountryRule, aw as PhoneFormat, ax as PhoneOtpInput, ay as PhoneOtpReason, az as PhotoSource, aA as PhotoSourcePick, aB as PlanAttempts, aC as PlanChoiceKind, aD as PlanChoiceOption, aE as PlanChoiceView, aF as PlanSectionView, aG as PlanStepView, aH as PoaImagesInput, aI as PoaInput, aJ as PoaKind, aK as PoaLicenceInput, aL as PoaNameMatchMode, aM as PoaPdfInput, aN as PoaReason, aO as PoaRuleSource, aP as PopulationInput, aQ as PopulationReason, aR as PortraitFix, aS as PortraitFixReviewInput, aT as PortraitIcaoInput, aU as PortraitIcaoReason, aV as PortraitOutputFormat, aW as PresignRequest, aX as PresignUploadResult, aY as RecordConsentResult, aZ as ResolvedCaptureMode, a_ as SandboxSimulatedReason, a$ as SandboxSimulation, b0 as SessionDecidingStep, b1 as SessionFailureReason, b2 as SessionReason, b3 as SessionStatus, b4 as SessionStepView, b5 as SessionView, b6 as SimulatedCaptureInput, b7 as StepResult, b8 as StepSection, b9 as SubmitCheckBody, ba as TesterGateInput, bb as TesterGateResponse, bc as VerificationAssurance, bd as VerificationLevel } from '../types-B47mZ5TT.js';
1
+ export { H as HostedClient, a as HostedClientOptions, M as MediaCheckType, S as SEKYRO_SDK_HEADER, b as SubmitOptions, U as UploadMedia, s as stripMimeParams } from '../icao-gate-BBStoG81.js';
2
+ export { H as HostedApiError, a as HostedErrorDetails, b as HostedErrorIssue, K as KNOWN_CODES, c as KnownCode, i as icaoPolicyOf, d as isKnownCode, p as portraitIcaoGate } from '../icao-policy-Dy5Z1vSp.js';
3
+ export { A as AcceptedDocumentType, a as AttestationInput, C as CaptureContext, b as CaptureMode, c as CaptureNoncesResult, d as CaptureProof, e as CheckInputByType, f as CheckReason, g as CheckState, h as CheckType, i as ClosedBy, j as CompleteMediaResult, k as ConsentLocale, l as ContactChannel, D as DecisionReason, m as DocDeviceRead, n as DocOcrInput, o as DocReason, p as DocSide, E as EidAfterPass, q as EidAuthInput, r as EidReason, s as EmailOtpInput, t as EmailOtpReason, F as FaceMatchInput, u as FaceMatchReason, v as FormAddressValue, w as FormAnswerValue, x as FormChoiceView, y as FormConsentView, z as FormCustomQuestionView, B as FormFieldName, G as FormFieldQuestionView, H as FormInput, I as FormIssueCode, J as FormLocale, K as FormQuestionOptions, L as FormQuestionType, M as FormQuestionView, N as HostedAcceptedDocuments, O as HostedCaptureTuning, P as HostedChallengeView, Q as HostedConsentView, R as HostedDocumentCaptureTuning, S as HostedDocumentScanTuning, T as HostedDocumentsView, U as HostedEidView, V as HostedEmailOtpView, W as HostedFlowRef, X as HostedFormView, Y as HostedIcaoPolicy, Z as HostedIntegrity, _ as HostedLivePhotoTuning, $ as HostedNativeAppView, a0 as HostedNativeCaptureTuning, a1 as HostedOcrTuning, a2 as HostedOtpView, a3 as HostedPlanView, a4 as HostedPoaRuleKindView, a5 as HostedPoaRuleView, a6 as HostedPortraitPendingFix, a7 as HostedPortraitView, a8 as HostedProofOfAddressView, a9 as HostedSessionView, aa as HostedSimulationView, ab as HostedStepView, ac as HostedTesterGateView, ad as HostedVoiceLocale, ae as HostedVoiceView, af as IcaoCriterion, ag as IcaoReportEntry, ah as IdentityConfirmDecision, ai as IdentityMethod, aj as IdentitySummarySource, ak as IdentitySummaryView, al as LivenessCaptureInput, am as LivenessInput, an as LivenessReason, ao as MatchReason, ap as MediaKind, aq as MethodChoiceView, ar as NationalEidOption, as as NfcChipReason, at as NfcStepView, au as OtpChoiceView, av as PhoneCountryRule, aw as PhoneFormat, ax as PhoneOtpInput, ay as PhoneOtpReason, az as PhotoSource, aA as PhotoSourcePick, aB as PlanAttempts, aC as PlanChoiceKind, aD as PlanChoiceOption, aE as PlanChoiceView, aF as PlanSectionView, aG as PlanStepView, aH as PoaImagesInput, aI as PoaInput, aJ as PoaKind, aK as PoaLicenceInput, aL as PoaNameMatchMode, aM as PoaPdfInput, aN as PoaReason, aO as PoaRuleSource, aP as PopulationInput, aQ as PopulationReason, aR as PortraitFix, aS as PortraitFixReviewInput, aT as PortraitIcaoInput, aU as PortraitIcaoReason, aV as PortraitOutputFormat, aW as PresignRequest, aX as PresignUploadResult, aY as RecordConsentResult, aZ as ResolvedCaptureMode, a_ as SandboxSimulatedReason, a$ as SandboxSimulation, b0 as SessionDecidingStep, b1 as SessionFailureReason, b2 as SessionReason, b3 as SessionStatus, b4 as SessionStepView, b5 as SessionView, b6 as SimulatedCaptureInput, b7 as StepResult, b8 as StepSection, b9 as SubmitCheckBody, ba as TesterGateInput, bb as TesterGateResponse, bc as VerificationAssurance, bd as VerificationLevel } from '../types-BjzuJVOc.js';
4
4
 
5
5
  /** The page runs inside an app's WebView (WhatsApp, Instagram, Facebook, TikTok, Snapchat, LINE, LinkedIn, WeChat, an Android WebView…). */
6
6
  declare function isInAppBrowser(userAgent?: string): boolean;
@@ -1 +1 @@
1
- import{a as o,b as t,c as i,e as n,f as s,g as a,h as r,i as p}from"../chunk-OUC57KMS.js";import"../chunk-TSA6GHUG.js";import{b as e}from"../chunk-MD4YXLPK.js";export{i as HostedApiError,a as HostedClient,o as KNOWN_CODES,s as SEKYRO_SDK_HEADER,r as icaoPolicyOf,e as isInAppBrowser,t as isKnownCode,p as portraitIcaoGate,n as stripMimeParams};
1
+ import{a as o,b as t,c as i,e as n,f as s,g as a,h as r,i as p}from"../chunk-YDG77RHN.js";import"../chunk-TSA6GHUG.js";import{b as e}from"../chunk-NO22WG7R.js";export{i as HostedApiError,a as HostedClient,o as KNOWN_CODES,s as SEKYRO_SDK_HEADER,r as icaoPolicyOf,e as isInAppBrowser,t as isKnownCode,p as portraitIcaoGate,n as stripMimeParams};