@sekyro/elements 0.1.0-rc.3 → 0.1.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/cdn/chunks/{capture-session-doc-WZMI5XPE-AZDHR6MQ.js → capture-session-doc-FRBI7OKF-AIBTLOVK.js} +1 -1
- package/dist/cdn/chunks/{chunk-POHYEXNR.js → chunk-5ZNWYB3D.js} +1 -1
- package/dist/cdn/chunks/{chunk-MJEQ5ANO.js → chunk-AKUFZTNC.js} +1 -1
- package/dist/cdn/chunks/{chunk-CXQO6QMQ.js → chunk-AN2KDTP4.js} +1 -1
- package/dist/cdn/chunks/{chunk-UNQ3QO4U.js → chunk-AOM2HJGY.js} +1 -1
- package/dist/cdn/chunks/{chunk-2T6RLTDQ.js → chunk-COQQVNNG.js} +1 -1
- package/dist/cdn/chunks/{chunk-TKJVGZWP.js → chunk-FYPP4Q7V.js} +2 -2
- package/dist/cdn/chunks/{chunk-ZMHEKDRM.js → chunk-G2RZQTCT.js} +1 -1
- package/dist/cdn/chunks/{chunk-434MMEWK.js → chunk-GIGTK355.js} +1 -1
- package/dist/cdn/chunks/{chunk-7MV4CI4L.js → chunk-H5GXVL63.js} +1 -1
- package/dist/cdn/chunks/{chunk-SGUCIULX.js → chunk-HMNCXTZQ.js} +2 -2
- package/dist/cdn/chunks/{chunk-ZYZPLDA2.js → chunk-KLODCY6G.js} +1 -1
- package/dist/cdn/chunks/{chunk-6BRQUKUP.js → chunk-RPCMWL2U.js} +1 -1
- package/dist/cdn/chunks/{chunk-RKH7O2P5.js → chunk-UGP2ZH7W.js} +1 -1
- package/dist/cdn/chunks/{chunk-FV4TIWHC.js → chunk-X4MIUKLT.js} +1 -1
- package/dist/cdn/chunks/{create-document-capture-OXPLKHOF-GVCM77EK.js → create-document-capture-2YBCDEUB-GYUIXEAL.js} +1 -1
- package/dist/cdn/chunks/{document-capture-view-UL3ISHNS-WZLR5RSQ.js → document-capture-view-UL3ISHNS-E6AP35NA.js} +1 -1
- package/dist/cdn/chunks/{eid-view-FKFEF42L-2OQYMKAB.js → eid-view-FKFEF42L-4OPACR2A.js} +1 -1
- package/dist/cdn/chunks/{email-otp-view-NRZCAJJ4-BJNXOVUF.js → email-otp-view-NRZCAJJ4-UFM2YDCD.js} +1 -1
- package/dist/cdn/chunks/{flow-views-N7LBFI55-27RU7EZG.js → flow-views-N7LBFI55-36234BJJ.js} +1 -1
- package/dist/cdn/chunks/{plan-runner-EP26JU6A-LU7KJ6JU.js → plan-runner-KQM7I4MR-HEXIU27Q.js} +1 -1
- package/dist/cdn/chunks/{portrait-capture-view-6KZGPAJU-2O54W4SR.js → portrait-capture-view-6KZGPAJU-CFUUPI5B.js} +1 -1
- package/dist/cdn/chunks/{portrait-review-view-TBSABVSX-5SVU25AE.js → portrait-review-view-TBSABVSX-J5ZCIFSX.js} +1 -1
- package/dist/cdn/chunks/{proof-of-address-view-3GG3XEQK-CPQ2AQEQ.js → proof-of-address-view-3GG3XEQK-7DFCRBNZ.js} +1 -1
- package/dist/cdn/define.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/package.json +2 -2
- package/sbom.cdx.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as H,c as q}from"./chunk-434MMEWK.js";import{b as z}from"./chunk-CW56KMMH.js";import{a as r}from"./chunk-4FHWXBOB.js";var g,y=(g=class extends Error{constructor(t){super(t.message),this.name="HostedApiError",this.status=t.status,this.code=t.code,t.retryAfterSeconds!==void 0&&(this.retryAfterSeconds=t.retryAfterSeconds),t.details&&(this.details=t.details)}},r(g,"c"),g);function N(e,t,n=Math.random){let i=(e??t)*1e3,a=Math.min(Math.max(i,500),2e4),s=Math.round(a*(1+(n()*2-1)*.25));return Math.min(Math.max(s,500),2e4)}r(N,"_");var Y=6e4,D=4,ee=3e4,te=9e5,ne=200,ie=5,ae=400,re=new Set(["server_busy","request_timeout"]),se=2;function v(e){return(e.split(";")[0]??"").trim()}r(v,"l");var oe={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},ce=`@sekyro/web/${H}`,de=ce,k,Ue=(k=class{constructor(t){this.sessionId=null,this.bootstrap=null,this.captureNonces=[],this.captureFetch=null,this.reportedIssues=new Map,this.apiOrigin=t.apiOrigin.replace(/\/+$/,""),this.sessionToken=t.sessionToken;let n=t.fetch;this.fetchImpl=(i,a)=>(n??globalThis.fetch).call(globalThis,i,a),this.requestTimeoutMs=t.requestTimeoutMs??ee,this.retryAttempts=t.inProgressRetry?.attempts??ie,this.retryDelayMs=t.inProgressRetry?.delayMs??ae,this.random=t.random??Math.random}async getSession(){let t=await this.api("GET","/hosted/session");return this.sessionId=t.sessionId,t}async recordConsent(t){return this.api("POST","/hosted/consent",{body:{locale:t},busyRetry:!0})}async reportCameraUnavailable(t){return this.api("POST","/hosted/camera-unavailable",{body:{cause:t}})}async testerGate(t){return this.api("POST","/hosted/tester-gate",{body:{input:t}})}async reportCaptureIssue(t){let n=typeof t.name=="string"?t.name.replace(/[^A-Za-z]/g,"").slice(0,40):"",i=typeof t.engineKind=="string"&&/^[a-z_]{1,32}$/.test(t.engineKind)?t.engineKind:void 0,a=typeof t.attempt=="number"&&Number.isInteger(t.attempt)&&t.attempt>=0&&t.attempt<=1e3?t.attempt:void 0,s=[t.check,a??"",t.kind,n,t.phase??""].join("|"),c=this.reportedIssues.get(s);if(c!==void 0)return c;let d={check:t.check,kind:t.kind,...n!==""?{name:n}:{},...t.phase!==void 0?{phase:t.phase}:{},...i!==void 0?{engineKind:i}:{},...a!==void 0?{attempt:a}:{},...t.formFactor!==void 0?{formFactor:t.formFactor}:{}},o=this.api("POST","/hosted/capture-issue",{body:d,empty:!0}).catch(()=>{this.reportedIssues.delete(s)});return this.reportedIssues.set(s,o),o}async choose(t,n){let i=await this.api("POST","/hosted/choice",{body:{nodeId:t,option:n},busyRetry:!0});return this.sessionId=i.sessionId,i}async confirmIdentity(t){return this.api("POST","/hosted/identity/confirm",{body:{decision:t}})}async identityPortrait(){return this.api("GET","/hosted/identity/portrait",{blob:!0})}async presign(t,n,i,a={}){let s=await this.ensureSessionId(),c={kind:t,contentType:v(n),contentLength:i,...a.source==="upload"?{source:"upload"}:{}};return this.api("POST",`/sessions/${s}/media`,{body:c})}armCapture(t=2){this.fillCaptureNonces(t)}async presignCapture(t,n,i,a={}){let s=await this.ensureSessionId(),c=await this.takeCaptureNonce(),d=c===void 0?void 0:{nonce:c,...a.engine!==void 0?{engine:a.engine.slice(0,32)}:{},...a.durationMs!==void 0&&Number.isFinite(a.durationMs)?{captureMs:Math.min(36e5,Math.max(0,Math.round(a.durationMs)))}:{}},o={kind:t,contentType:v(n),contentLength:i,capture:d};return this.api("POST",`/sessions/${s}/media`,{body:o})}async takeCaptureNonce(){let t=r(()=>{let n=Date.now();return this.captureNonces=this.captureNonces.filter(i=>i.expiresAt-Y>n),this.captureNonces.shift()?.nonce},"e");for(let n=0;n<2;n++){let i=t();if(i!==void 0)return i;await this.fillCaptureNonces(1)}return t()}fillCaptureNonces(t){return this.captureFetch??(this.captureFetch=(async()=>{try{let n=await this.ensureSessionId(),i=await this.api("POST",`/sessions/${n}/media/capture-nonces`,{body:{count:Math.min(D,Math.max(1,t))}}),a=Date.now()+Math.max(0,i.expiresIn)*1e3;for(let s of Array.isArray(i.nonces)?i.nonces:[])typeof s=="string"&&s.length>0&&this.captureNonces.push({nonce:s,expiresAt:a});this.captureNonces=this.captureNonces.slice(-D)}catch{}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(t,n,i){let a;try{a=await this.fetchImpl(t,{method:"PUT",headers:{"content-type":v(i)},body:n,signal:AbortSignal.timeout(te)})}catch(s){throw x(s)}if(!a.ok){let s=(await a.text().catch(()=>"")).slice(0,ne);throw new y({status:a.status,code:"upload_failed",message:`media upload failed (HTTP ${a.status})${s?`: ${s}`:""}`})}}async completeMedia(t){let n=await this.ensureSessionId();return this.api("POST",`/sessions/${n}/media/complete`,{body:{key:t}})}async submitCheck(t,n,i={}){let a=await this.ensureSessionId(),s={input:n,forceOutcome:i.forceOutcome};return this.api("POST",`/sessions/${a}/checks/${t}`,{body:s,idempotencyKey:i.idempotencyKey,busyRetry:i.idempotencyKey!==void 0})}async uploadAndSubmit(t,n,i,a={}){let s=v(n.contentType),c=await this.presign(n.kind,s,n.blob.size);await this.uploadToSpaces(c.uploadUrl,n.blob,s);let d=await this.completeMedia(c.key),o={...i,[oe[t]]:d.key};return this.submitCheck(t,o,a)}async ensureSessionId(){return this.sessionId!==null?this.sessionId:(this.bootstrap??(this.bootstrap=this.getSession().finally(()=>{this.bootstrap=null})),(await this.bootstrap).sessionId)}async api(t,n,i={}){let a=t==="GET"||i.busyRetry===!0,s=`${this.apiOrigin}/api/v2${n}`,c={"x-session-token":this.sessionToken,"x-sekyro-sdk":de};i.body!==void 0&&(c["content-type"]="application/json"),i.idempotencyKey!==void 0&&(c["x-idempotency-key"]=i.idempotencyKey);try{let d=q.timezone();d!==void 0&&(c["sekyro-client-timezone"]=d)}catch{}c["sekyro-client-form-factor"]=z();try{let d=await q.deviceHeader();d!==void 0&&(c["sekyro-client-device"]=d)}catch{}for(let d=0;;d++){let o;try{o=await this.fetchImpl(s,{method:t,headers:c,...i.body!==void 0?{body:JSON.stringify(i.body)}:{},cache:"no-store",signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(f){throw x(f)}if(o.ok){if(i.empty===!0)return;if(i.blob===!0)try{return await o.blob()}catch(l){throw x(l)}let f;try{f=await o.json()}catch{throw new y({status:o.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${o.status})`})}return ue(f)}let u=await le(o);if(u.code==="idempotency_in_progress"&&d<this.retryAttempts){this.retryDelayMs>0&&await L(this.retryDelayMs);continue}if(a&&u.status===503&&re.has(u.code)){a=!1,await L(N(u.retryAfterSeconds,se,this.random));continue}throw u}}},r(k,"g"),k);function x(e){if((typeof e=="object"&&e!==null?e.name:void 0)==="TimeoutError")return new y({status:0,code:"timeout",message:"request timed out"});let t=e instanceof Error?e.message:String(e);return new y({status:0,code:"network_error",message:`network request failed: ${t}`})}r(x,"m");function ue(e){return e!==null&&typeof e=="object"&&"success"in e&&"data"in e?e.data:e}r(ue,"H");async function le(e){let t="unknown_error",n=`request failed (HTTP ${e.status})`,i=Number.NaN,a;try{let d=await e.json();if(d!==null&&typeof d=="object"){let o=d;typeof o.code=="string"&&o.code.length>0&&(t=o.code),typeof o.message=="string"&&o.message.length>0&&(n=o.message),typeof o.retryAfterSeconds=="number"&&(i=o.retryAfterSeconds),Array.isArray(o.details?.issues)&&(a=o.details)}}catch{}let s=e.headers.get("retry-after"),c=s===null?Math.floor(i):Number.parseInt(s,10);return new y({status:e.status,code:t,message:n,...Number.isFinite(c)&&c>=0?{retryAfterSeconds:c}:{},details:a})}r(le,"x");function L(e){return new Promise(t=>setTimeout(t,e))}r(L,"T");function Ge(e){let t=e?.portrait,n=t?.icao,i=t?.purpose==="id_document";return n==null?i?{policy:"reject",profile:"id_document"}:null:{policy:n.policy==="alert"?"alert":"reject",profile:i||n.profile==="id_document"?"id_document":"selfie"}}r(Ge,"L");function Ve(e){return{...e.baselineEyeOpenness!==void 0?{baselineEyeOpenness:e.baselineEyeOpenness}:{},...e.baselineEyeOpennessLeft!==void 0&&e.baselineEyeOpennessRight!==void 0?{baselineEyeOpennessLeft:e.baselineEyeOpennessLeft,baselineEyeOpennessRight:e.baselineEyeOpennessRight}:{},criteria:e.verdict??{},...e.backgroundCheck!==void 0?{backgroundCheck:e.backgroundCheck}:{}}}r(Ve,"j");var pe=new Set(["nni_unbound","id_number_unbound","method_required","mobile_required","portrait_required"]);function Qe(e){return pe.has(e)}r(Qe,"_e");function We(e,t,n){let i=t.detail;return{check:e,kind:t.kind,...i?.name!==void 0?{name:i.name}:{},...i?.phase!==void 0?{phase:i.phase}:{},...i?.engineKind!==void 0?{engineKind:i.engineKind}:{},attempt:Math.max(0,Math.min(1e3,n))}}r(We,"ge");function Xe(){let e=-1,t="";return{note(n){n==="starting"&&t!=="starting"&&(e+=1),t=n},newHandle(){t=""},noteError(){e<0&&(e=0)},get value(){return e}}}r(Xe,"Ce");var he={document:"document_photo",nfc:"document_chip",population_registry:"national_number",national_eid:"national_eid"};function m(e){return e.plan?.steps??[]}r(m,"p");function $(e){return Math.max(0,e.attempts.max-e.attempts.used)}r($,"V");function fe(e){let t=e.plan?.choice;return t!==void 0&&e.plan?.current===t.nodeId?t:null}r(fe,"j");function Ye(e){let t=fe(e);if(t?.kind!=="identity_method")return null;let n=t.options.map(a=>he[a.service]).filter(a=>a!==void 0),i=t.options.find(a=>a.nationalEid)?.nationalEid;return i?{available:!0,selected:null,options:n,nationalEid:i}:{available:!0,selected:null,options:n}}r(Ye,"ke");var me=new Set(["liveness","face_match"]);function R(e){return e!==void 0&&(e.state==="pending"||e.state==="input_required")}r(R,"_");function ye(e){return e.status!=="created"&&e.status!=="in_progress"}r(ye,"I");function V(e){let t=e.plan?.current,n=t==null?void 0:m(e).find(i=>i.id===t);return R(n)?n:void 0}r(V,"x");function O(e,t){return m(e).find(n=>n.checkType===t)}r(O,"h");function E(e){let t=m(e),n=t.findIndex(i=>i.checkType==="liveness");return t.find((i,a)=>a>n&&i.checkType==="face_match")}r(E,"S");function _e(e,t){let n=O(t,"liveness")?.state,i=E(t)?.state;return(E(e)?.state??"pending")==="pending"&&(n==="passed"||n==="review")&&i!==void 0&&i!=="pending"&&i!=="skipped"}r(_e,"T");function U(e,t){let n=new Map(m(e).map(i=>[i.id,i.state]));return m(t).filter(i=>i.checkType==="face_match"&&(n.get(i.id)??"pending")==="pending"&&i.state!=="pending"&&i.state!=="skipped").map(i=>i.id)}r(U,"M");var ve=/^[0-9a-f]{24}$/i;function T(e){return ve.test(e)?`ses_${e}`:e}r(T,"g");function C(e,t){let n=T(e);return t===void 0?{sessionId:n,status:"unavailable"}:{sessionId:n,status:"unavailable",reasonCode:t}}r(C,"R");function B(e,t,n){let i=T(e);return n===void 0?{sessionId:i,status:t}:{sessionId:i,status:t,reasonCode:n}}r(B,"O");function et(e,t){let n=T(e.sessionId);switch(e.status){case"created":case"in_progress":return Se(e,t);case"verified":return A(e,{sessionId:n,status:"verified"});case"review_pending":return A(e,B(n,"review",J(e,"review")));case"not_verified":return A(e,ke(e));default:return A(e,{sessionId:n,status:"not_verified"})}}r(et,"Re");var ge=new Set([0,1,2,3]);function A(e,t){return ge.has(e.level)&&(t.level=e.level),typeof e.assurance=="string"&&e.assurance.length>0&&(t.assurance=e.assurance),t}r(A,"v");function ke(e){let t={sessionId:T(e.sessionId),status:"not_verified"};return e.reason!==void 0&&(t.reason=e.reason),e.reasonCode!==void 0&&(t.reasonCode=e.reasonCode),e.reasonCode==="device_cooldown"&&e.retryAfter!==void 0&&(t.retryAfter=e.retryAfter),t}r(ke,"X");function be(e){return e==="rejected"?"rejected":e==="unavailable"?"unavailable":"inconclusive"}r(be,"J");function we(e,t){if(t===void 0)return!1;let n=m(t).find(i=>i.id===e.id);return n!==void 0&&n.attempts.used===e.attempts.used}r(we,"Q");function Se(e,t){let n=T(e.sessionId),i=m(e).find(s=>me.has(s.checkType)&&s.state==="input_required"&&s.reason!==void 0);if(i?.reason==="mobile_required")return C(n,"mobile_required");if(i?.reason!==void 0){if(i.result==="unavailable")return C(n,i.reason);let s=t.autoRetry&&($(i)>0||we(i,t.previous))?{sessionId:n,status:"retry",reasonCode:i.reason,attemptsRemaining:$(i)}:{sessionId:n,status:"not_verified",reason:be(i.result),reasonCode:i.reason,attemptsRemaining:$(i)};return i.retakeHint!==void 0&&(s.retakeHint=i.retakeHint),s}let a=V(e);return a===void 0&&m(e).some(s=>s.state==="review")?B(n,"review",J(e,"review")):a?.checkType==="portrait_icao"?C(n,"portrait_required"):C(n)}r(Se,"Z");function J(e,t){return m(e).find(n=>n.state===t&&n.reason!==void 0)?.reason}r(J,"L");function Z(e,t,n,i,a){return e.presignCapture!==void 0?e.presignCapture(t,n,i,a):e.presign(t,n,i)}r(Z,"K");function Q(e){return{engine:e?.engine,durationMs:e?.clipMs}}r(Q,"N");var Ie=["video/webm","video/mp4"],G="image/jpeg",Me=2,Te=1e3,Ce=1e4,Ae=3,Ee=10,Oe=3,Pe=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),qe=new Set(["session_not_active","check_not_found","check_already_finalized","check_out_of_order","identity_confirm_required","check_not_active","step_not_on_path"]),b,j=(b=class extends Error{constructor(){super("verification destroyed"),this.name="FlowCancelledError"}},r(b,"C"),b);function xe(e){let t=E(e);return O(e,"portrait_icao")?.state!=="pending"&&(t!==void 0?R(t):e.capture?.livePhoto?.oneCapture===!0)}r(xe,"de");var w,F=(w=class extends Error{constructor(t){super(t),this.name="AttestationError"}},r(w,"w"),w);async function W(e,t,n={}){let i=e.uuid(),a=!1,s=!1,c=0,d=0;for(;;)try{return await t(e.client,i)}catch(o){if(o instanceof F){if(s)throw o;s=!0,n.onAttestationInvalid?.(),i=e.uuid();continue}if(!(o instanceof y))throw o;if(o.code==="consent_required"&&!a){a=!0,await e.ensureConsent({force:!0}),i=e.uuid();continue}if(o.code==="attestation_invalid"&&!s){s=!0,n.onAttestationInvalid?.(),i=e.uuid();continue}if(o.code==="inference_unavailable"&&d<Ae){d+=1;let u=N(o.retryAfterSeconds,Ee,e.random??Math.random);e.onBusy?.({attempt:d,retryAfterSeconds:u/1e3}),await e.sleep(u),n.onAttestationInvalid?.(),i=e.uuid();continue}if(Pe.has(o.code)&&c<Me){c+=1;let u=o.retryAfterSeconds!==void 0?o.retryAfterSeconds*1e3:void 0;await e.sleep(u!==void 0?Math.min(u,Ce):Te);continue}throw o}}r(W,"q");var Ne=new Set(["passed","review","processing","skipped"]);async function tt(e){let{artifacts:t}=e,n=t.clip,i=v(t.clipMime??"");if(t.degraded==="NO_RECORDER"||n===void 0||!Ie.includes(i))return{kind:"unavailable",reason:"no_recorder"};e.client.armCapture?.(2);let a=$e(e,t.keyframe),s=Ke(e,n,i,a),c=Re(e,a),d=!1,o=new Set,u=!0,f=0;for(;;){if(e.isCancelled())return{kind:"cancelled"};let l=e.getView();if(ye(l))return{kind:"settled"};let p=V(l),M=p?.checkType,P=M==="liveness"&&!d?"liveness":M==="face_match"&&!o.has(p?.id)&&o.size<2&&u?"face_match":null;if(P===null)return{kind:"settled"};if(P==="liveness"&&t.captureChannel==="desktop")return{kind:"unavailable",reason:"mobile_required"};try{if(P==="liveness"){d=!0;let h=await s();if(e.isCancelled())return{kind:"cancelled"};_e(l,h)&&o.add(E(h)?.id);for(let X of U(l,h))o.add(X);await e.applySubmit(h,"liveness");let _=O(e.getView(),"liveness")?.state;u=_===void 0||Ne.has(_)}else{o.add(p?.id);let h=await c();if(e.isCancelled())return{kind:"cancelled"};for(let _ of U(l,h))o.add(_);await e.applySubmit(h,"face_match")}}catch(h){if(e.isCancelled()||h instanceof j)return{kind:"cancelled"};let _=ze(h);if(_.kind!=="resync"||f>=Oe)return _;f+=1,await e.refreshView()}}}r(tt,"Me");function $e(e,t){let n=null,i=null,a=r(()=>n!==null?Promise.resolve(n):(i??(i=(async()=>{let s=await Z(e.client,"image",G,t.size,Q(e.artifacts));return await e.client.uploadToSpaces(s.uploadUrl,t,G),n=(await e.client.completeMedia(s.key)).key,e.onKeyframePromoted?.(n),n})().finally(()=>{i=null})),i),"o");return{ensure:a,attempt:r(()=>a().catch(()=>null),"attempt"),current:r(()=>n,"current")}}r($e,"le");function Ke(e,t,n,i){let a=null,s,c=null,d=0,o;return()=>W(e,async(u,f)=>{if(a===null||s===void 0){if(e.isCancelled())throw new j;s===void 0&&!xe(e.getView())&&(s=null),e.onPhase("uploading");let[l,p]=await Promise.all([a!==null?Promise.resolve(a):(async()=>{let M=await Z(u,"clip",n,t.size,Q(e.artifacts));return await u.uploadToSpaces(M.uploadUrl,t,n),(await u.completeMedia(M.key)).key})(),s!==void 0?Promise.resolve(s===null?null:s.imageKey):i.attempt()]);a=l,s===void 0&&(s=p===null?null:{imageKey:p})}if(c===null){let l=performance.now();try{c=await e.getAttestation(),o=e.attestationError?.()}catch(p){throw new F(p instanceof Error?p.message:String(p))}d=Math.round(performance.now()-l)}return e.onPhase("checking"),u.submitCheck("liveness",{clipKey:a,attestation:c,captureChannel:e.artifacts.captureChannel,capture:{...je(e.artifacts),attestationMs:d,attestationError:o},...s!==null?{faceMatch:s}:{}},{idempotencyKey:f})},{onAttestationInvalid:r(()=>{c=null},"onAttestationInvalid")})}r(Ke,"fe");function Re(e,t){return()=>W(e,async(n,i)=>{if(t.current()===null){if(e.isCancelled())throw new j;e.onPhase("uploading")}let a=await t.ensure();return e.onPhase("checking"),n.submitCheck("face_match",{imageKey:a},{idempotencyKey:i})})}r(Re,"pe");function je(e){let t={width:e.width,height:e.height};for(let n of Fe)e[n]!==void 0&&(t[n]=e[n]);return t}r(je,"me");var Fe=["engine","facingMode","mode","formFactor","clipMs","clipFrames","fps","clipRetakes","codec","cameraReadyMs","faceAcquireMs","captureMs","screenRamp","provenance"];function ze(e){if(e instanceof F)return{kind:"unavailable",reason:"attestation"};if(e instanceof y){if(e.code==="attestation_invalid")return{kind:"unavailable",reason:"attestation"};if(e.code==="inference_unavailable")return{kind:"unavailable",reason:"inference_unavailable"};if(e.code==="mobile_required")return{kind:"unavailable",reason:"mobile_required"};if(qe.has(e.code))return{kind:"resync"}}return{kind:"unavailable",reason:"network"}}r(ze,"ye");var S,nt=(S=class extends Error{constructor(t,n){super(`invalid ${t} (${n})`),this.name="InvalidInputError",this.field=t,this.kind=n}},r(S,"B"),S),I,it=(I=class extends Error{constructor(t,n){super(`invalid ${t} (${n})`),this.name="OtpInputError",this.field=t,this.kind=n}},r(I,"U"),I);function K(e){return e?.source==="upload"?null:e?.source==="choice"&&e.sourcePick!=="camera"?"upload_or_phone":"phone"}r(K,"E");function at(e,t){if(t===void 0||!R(t)||t.requiresMobile!==!0)return null;switch(t.checkType){case"liveness":return"phone";case"face_match":{if(t.reason!==void 0)return"phone";let n=O(e,"portrait_icao");return n?.state==="passed"||n?.state==="review"?null:"phone"}case"doc_ocr":return K(e.documents);case"poa":return K(e.proofOfAddress);case"portrait_icao":{let n=e.portrait;return n?.pendingFix!==void 0||n?.reuse?.pending===!0?null:K(n)}default:return null}}r(at,"Ie");function He(e){let t=e?.capture,n=t?.mode;return n==="assisted"||n==="self"||n==="choice"?n:t?.cameraSwitch===!0?"assisted":"self"}r(He,"Se");function rt(e){let t=e?.capture?.pick;return He(e)==="choice"&&(t==="self"||t==="assisted")?t:null}r(rt,"Oe");function st(e,t,n=null){return e==="choice"?t??n??"self":e}r(st,"Le");export{y as a,v as b,Ue as c,Ge as d,Ve as e,Qe as f,We as g,Xe as h,he as i,m as j,$ as k,fe as l,Ye as m,R as n,ye as o,V as p,O as q,T as r,C as s,et as t,Z as u,Ie as v,W as w,tt as x,je as y,nt as z,it as A,at as B,He as C,rt as D,st as E};
|
|
1
|
+
import{a as H,c as q}from"./chunk-GIGTK355.js";import{b as z}from"./chunk-CW56KMMH.js";import{a as r}from"./chunk-4FHWXBOB.js";var g,y=(g=class extends Error{constructor(t){super(t.message),this.name="HostedApiError",this.status=t.status,this.code=t.code,t.retryAfterSeconds!==void 0&&(this.retryAfterSeconds=t.retryAfterSeconds),t.details&&(this.details=t.details)}},r(g,"c"),g);function N(e,t,n=Math.random){let i=(e??t)*1e3,a=Math.min(Math.max(i,500),2e4),s=Math.round(a*(1+(n()*2-1)*.25));return Math.min(Math.max(s,500),2e4)}r(N,"_");var Y=6e4,D=4,ee=3e4,te=9e5,ne=200,ie=5,ae=400,re=new Set(["server_busy","request_timeout"]),se=2;function v(e){return(e.split(";")[0]??"").trim()}r(v,"l");var oe={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},ce=`@sekyro/web/${H}`,de=ce,k,Ue=(k=class{constructor(t){this.sessionId=null,this.bootstrap=null,this.captureNonces=[],this.captureFetch=null,this.reportedIssues=new Map,this.apiOrigin=t.apiOrigin.replace(/\/+$/,""),this.sessionToken=t.sessionToken;let n=t.fetch;this.fetchImpl=(i,a)=>(n??globalThis.fetch).call(globalThis,i,a),this.requestTimeoutMs=t.requestTimeoutMs??ee,this.retryAttempts=t.inProgressRetry?.attempts??ie,this.retryDelayMs=t.inProgressRetry?.delayMs??ae,this.random=t.random??Math.random}async getSession(){let t=await this.api("GET","/hosted/session");return this.sessionId=t.sessionId,t}async recordConsent(t){return this.api("POST","/hosted/consent",{body:{locale:t},busyRetry:!0})}async reportCameraUnavailable(t){return this.api("POST","/hosted/camera-unavailable",{body:{cause:t}})}async testerGate(t){return this.api("POST","/hosted/tester-gate",{body:{input:t}})}async reportCaptureIssue(t){let n=typeof t.name=="string"?t.name.replace(/[^A-Za-z]/g,"").slice(0,40):"",i=typeof t.engineKind=="string"&&/^[a-z_]{1,32}$/.test(t.engineKind)?t.engineKind:void 0,a=typeof t.attempt=="number"&&Number.isInteger(t.attempt)&&t.attempt>=0&&t.attempt<=1e3?t.attempt:void 0,s=[t.check,a??"",t.kind,n,t.phase??""].join("|"),c=this.reportedIssues.get(s);if(c!==void 0)return c;let d={check:t.check,kind:t.kind,...n!==""?{name:n}:{},...t.phase!==void 0?{phase:t.phase}:{},...i!==void 0?{engineKind:i}:{},...a!==void 0?{attempt:a}:{},...t.formFactor!==void 0?{formFactor:t.formFactor}:{}},o=this.api("POST","/hosted/capture-issue",{body:d,empty:!0}).catch(()=>{this.reportedIssues.delete(s)});return this.reportedIssues.set(s,o),o}async choose(t,n){let i=await this.api("POST","/hosted/choice",{body:{nodeId:t,option:n},busyRetry:!0});return this.sessionId=i.sessionId,i}async confirmIdentity(t){return this.api("POST","/hosted/identity/confirm",{body:{decision:t}})}async identityPortrait(){return this.api("GET","/hosted/identity/portrait",{blob:!0})}async presign(t,n,i,a={}){let s=await this.ensureSessionId(),c={kind:t,contentType:v(n),contentLength:i,...a.source==="upload"?{source:"upload"}:{}};return this.api("POST",`/sessions/${s}/media`,{body:c})}armCapture(t=2){this.fillCaptureNonces(t)}async presignCapture(t,n,i,a={}){let s=await this.ensureSessionId(),c=await this.takeCaptureNonce(),d=c===void 0?void 0:{nonce:c,...a.engine!==void 0?{engine:a.engine.slice(0,32)}:{},...a.durationMs!==void 0&&Number.isFinite(a.durationMs)?{captureMs:Math.min(36e5,Math.max(0,Math.round(a.durationMs)))}:{}},o={kind:t,contentType:v(n),contentLength:i,capture:d};return this.api("POST",`/sessions/${s}/media`,{body:o})}async takeCaptureNonce(){let t=r(()=>{let n=Date.now();return this.captureNonces=this.captureNonces.filter(i=>i.expiresAt-Y>n),this.captureNonces.shift()?.nonce},"e");for(let n=0;n<2;n++){let i=t();if(i!==void 0)return i;await this.fillCaptureNonces(1)}return t()}fillCaptureNonces(t){return this.captureFetch??(this.captureFetch=(async()=>{try{let n=await this.ensureSessionId(),i=await this.api("POST",`/sessions/${n}/media/capture-nonces`,{body:{count:Math.min(D,Math.max(1,t))}}),a=Date.now()+Math.max(0,i.expiresIn)*1e3;for(let s of Array.isArray(i.nonces)?i.nonces:[])typeof s=="string"&&s.length>0&&this.captureNonces.push({nonce:s,expiresAt:a});this.captureNonces=this.captureNonces.slice(-D)}catch{}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(t,n,i){let a;try{a=await this.fetchImpl(t,{method:"PUT",headers:{"content-type":v(i)},body:n,signal:AbortSignal.timeout(te)})}catch(s){throw x(s)}if(!a.ok){let s=(await a.text().catch(()=>"")).slice(0,ne);throw new y({status:a.status,code:"upload_failed",message:`media upload failed (HTTP ${a.status})${s?`: ${s}`:""}`})}}async completeMedia(t){let n=await this.ensureSessionId();return this.api("POST",`/sessions/${n}/media/complete`,{body:{key:t}})}async submitCheck(t,n,i={}){let a=await this.ensureSessionId(),s={input:n,forceOutcome:i.forceOutcome};return this.api("POST",`/sessions/${a}/checks/${t}`,{body:s,idempotencyKey:i.idempotencyKey,busyRetry:i.idempotencyKey!==void 0})}async uploadAndSubmit(t,n,i,a={}){let s=v(n.contentType),c=await this.presign(n.kind,s,n.blob.size);await this.uploadToSpaces(c.uploadUrl,n.blob,s);let d=await this.completeMedia(c.key),o={...i,[oe[t]]:d.key};return this.submitCheck(t,o,a)}async ensureSessionId(){return this.sessionId!==null?this.sessionId:(this.bootstrap??(this.bootstrap=this.getSession().finally(()=>{this.bootstrap=null})),(await this.bootstrap).sessionId)}async api(t,n,i={}){let a=t==="GET"||i.busyRetry===!0,s=`${this.apiOrigin}/api/v2${n}`,c={"x-session-token":this.sessionToken,"x-sekyro-sdk":de};i.body!==void 0&&(c["content-type"]="application/json"),i.idempotencyKey!==void 0&&(c["x-idempotency-key"]=i.idempotencyKey);try{let d=q.timezone();d!==void 0&&(c["sekyro-client-timezone"]=d)}catch{}c["sekyro-client-form-factor"]=z();try{let d=await q.deviceHeader();d!==void 0&&(c["sekyro-client-device"]=d)}catch{}for(let d=0;;d++){let o;try{o=await this.fetchImpl(s,{method:t,headers:c,...i.body!==void 0?{body:JSON.stringify(i.body)}:{},cache:"no-store",signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(f){throw x(f)}if(o.ok){if(i.empty===!0)return;if(i.blob===!0)try{return await o.blob()}catch(l){throw x(l)}let f;try{f=await o.json()}catch{throw new y({status:o.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${o.status})`})}return ue(f)}let u=await le(o);if(u.code==="idempotency_in_progress"&&d<this.retryAttempts){this.retryDelayMs>0&&await L(this.retryDelayMs);continue}if(a&&u.status===503&&re.has(u.code)){a=!1,await L(N(u.retryAfterSeconds,se,this.random));continue}throw u}}},r(k,"g"),k);function x(e){if((typeof e=="object"&&e!==null?e.name:void 0)==="TimeoutError")return new y({status:0,code:"timeout",message:"request timed out"});let t=e instanceof Error?e.message:String(e);return new y({status:0,code:"network_error",message:`network request failed: ${t}`})}r(x,"m");function ue(e){return e!==null&&typeof e=="object"&&"success"in e&&"data"in e?e.data:e}r(ue,"H");async function le(e){let t="unknown_error",n=`request failed (HTTP ${e.status})`,i=Number.NaN,a;try{let d=await e.json();if(d!==null&&typeof d=="object"){let o=d;typeof o.code=="string"&&o.code.length>0&&(t=o.code),typeof o.message=="string"&&o.message.length>0&&(n=o.message),typeof o.retryAfterSeconds=="number"&&(i=o.retryAfterSeconds),Array.isArray(o.details?.issues)&&(a=o.details)}}catch{}let s=e.headers.get("retry-after"),c=s===null?Math.floor(i):Number.parseInt(s,10);return new y({status:e.status,code:t,message:n,...Number.isFinite(c)&&c>=0?{retryAfterSeconds:c}:{},details:a})}r(le,"x");function L(e){return new Promise(t=>setTimeout(t,e))}r(L,"T");function Ge(e){let t=e?.portrait,n=t?.icao,i=t?.purpose==="id_document";return n==null?i?{policy:"reject",profile:"id_document"}:null:{policy:n.policy==="alert"?"alert":"reject",profile:i||n.profile==="id_document"?"id_document":"selfie"}}r(Ge,"L");function Ve(e){return{...e.baselineEyeOpenness!==void 0?{baselineEyeOpenness:e.baselineEyeOpenness}:{},...e.baselineEyeOpennessLeft!==void 0&&e.baselineEyeOpennessRight!==void 0?{baselineEyeOpennessLeft:e.baselineEyeOpennessLeft,baselineEyeOpennessRight:e.baselineEyeOpennessRight}:{},criteria:e.verdict??{},...e.backgroundCheck!==void 0?{backgroundCheck:e.backgroundCheck}:{}}}r(Ve,"j");var pe=new Set(["nni_unbound","id_number_unbound","method_required","mobile_required","portrait_required"]);function Qe(e){return pe.has(e)}r(Qe,"_e");function We(e,t,n){let i=t.detail;return{check:e,kind:t.kind,...i?.name!==void 0?{name:i.name}:{},...i?.phase!==void 0?{phase:i.phase}:{},...i?.engineKind!==void 0?{engineKind:i.engineKind}:{},attempt:Math.max(0,Math.min(1e3,n))}}r(We,"ge");function Xe(){let e=-1,t="";return{note(n){n==="starting"&&t!=="starting"&&(e+=1),t=n},newHandle(){t=""},noteError(){e<0&&(e=0)},get value(){return e}}}r(Xe,"Ce");var he={document:"document_photo",nfc:"document_chip",population_registry:"national_number",national_eid:"national_eid"};function m(e){return e.plan?.steps??[]}r(m,"p");function $(e){return Math.max(0,e.attempts.max-e.attempts.used)}r($,"V");function fe(e){let t=e.plan?.choice;return t!==void 0&&e.plan?.current===t.nodeId?t:null}r(fe,"j");function Ye(e){let t=fe(e);if(t?.kind!=="identity_method")return null;let n=t.options.map(a=>he[a.service]).filter(a=>a!==void 0),i=t.options.find(a=>a.nationalEid)?.nationalEid;return i?{available:!0,selected:null,options:n,nationalEid:i}:{available:!0,selected:null,options:n}}r(Ye,"ke");var me=new Set(["liveness","face_match"]);function R(e){return e!==void 0&&(e.state==="pending"||e.state==="input_required")}r(R,"_");function ye(e){return e.status!=="created"&&e.status!=="in_progress"}r(ye,"I");function V(e){let t=e.plan?.current,n=t==null?void 0:m(e).find(i=>i.id===t);return R(n)?n:void 0}r(V,"x");function O(e,t){return m(e).find(n=>n.checkType===t)}r(O,"h");function E(e){let t=m(e),n=t.findIndex(i=>i.checkType==="liveness");return t.find((i,a)=>a>n&&i.checkType==="face_match")}r(E,"S");function _e(e,t){let n=O(t,"liveness")?.state,i=E(t)?.state;return(E(e)?.state??"pending")==="pending"&&(n==="passed"||n==="review")&&i!==void 0&&i!=="pending"&&i!=="skipped"}r(_e,"T");function U(e,t){let n=new Map(m(e).map(i=>[i.id,i.state]));return m(t).filter(i=>i.checkType==="face_match"&&(n.get(i.id)??"pending")==="pending"&&i.state!=="pending"&&i.state!=="skipped").map(i=>i.id)}r(U,"M");var ve=/^[0-9a-f]{24}$/i;function T(e){return ve.test(e)?`ses_${e}`:e}r(T,"g");function C(e,t){let n=T(e);return t===void 0?{sessionId:n,status:"unavailable"}:{sessionId:n,status:"unavailable",reasonCode:t}}r(C,"R");function B(e,t,n){let i=T(e);return n===void 0?{sessionId:i,status:t}:{sessionId:i,status:t,reasonCode:n}}r(B,"O");function et(e,t){let n=T(e.sessionId);switch(e.status){case"created":case"in_progress":return Se(e,t);case"verified":return A(e,{sessionId:n,status:"verified"});case"review_pending":return A(e,B(n,"review",J(e,"review")));case"not_verified":return A(e,ke(e));default:return A(e,{sessionId:n,status:"not_verified"})}}r(et,"Re");var ge=new Set([0,1,2,3]);function A(e,t){return ge.has(e.level)&&(t.level=e.level),typeof e.assurance=="string"&&e.assurance.length>0&&(t.assurance=e.assurance),t}r(A,"v");function ke(e){let t={sessionId:T(e.sessionId),status:"not_verified"};return e.reason!==void 0&&(t.reason=e.reason),e.reasonCode!==void 0&&(t.reasonCode=e.reasonCode),e.reasonCode==="device_cooldown"&&e.retryAfter!==void 0&&(t.retryAfter=e.retryAfter),t}r(ke,"X");function be(e){return e==="rejected"?"rejected":e==="unavailable"?"unavailable":"inconclusive"}r(be,"J");function we(e,t){if(t===void 0)return!1;let n=m(t).find(i=>i.id===e.id);return n!==void 0&&n.attempts.used===e.attempts.used}r(we,"Q");function Se(e,t){let n=T(e.sessionId),i=m(e).find(s=>me.has(s.checkType)&&s.state==="input_required"&&s.reason!==void 0);if(i?.reason==="mobile_required")return C(n,"mobile_required");if(i?.reason!==void 0){if(i.result==="unavailable")return C(n,i.reason);let s=t.autoRetry&&($(i)>0||we(i,t.previous))?{sessionId:n,status:"retry",reasonCode:i.reason,attemptsRemaining:$(i)}:{sessionId:n,status:"not_verified",reason:be(i.result),reasonCode:i.reason,attemptsRemaining:$(i)};return i.retakeHint!==void 0&&(s.retakeHint=i.retakeHint),s}let a=V(e);return a===void 0&&m(e).some(s=>s.state==="review")?B(n,"review",J(e,"review")):a?.checkType==="portrait_icao"?C(n,"portrait_required"):C(n)}r(Se,"Z");function J(e,t){return m(e).find(n=>n.state===t&&n.reason!==void 0)?.reason}r(J,"L");function Z(e,t,n,i,a){return e.presignCapture!==void 0?e.presignCapture(t,n,i,a):e.presign(t,n,i)}r(Z,"K");function Q(e){return{engine:e?.engine,durationMs:e?.clipMs}}r(Q,"N");var Ie=["video/webm","video/mp4"],G="image/jpeg",Me=2,Te=1e3,Ce=1e4,Ae=3,Ee=10,Oe=3,Pe=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),qe=new Set(["session_not_active","check_not_found","check_already_finalized","check_out_of_order","identity_confirm_required","check_not_active","step_not_on_path"]),b,j=(b=class extends Error{constructor(){super("verification destroyed"),this.name="FlowCancelledError"}},r(b,"C"),b);function xe(e){let t=E(e);return O(e,"portrait_icao")?.state!=="pending"&&(t!==void 0?R(t):e.capture?.livePhoto?.oneCapture===!0)}r(xe,"de");var w,F=(w=class extends Error{constructor(t){super(t),this.name="AttestationError"}},r(w,"w"),w);async function W(e,t,n={}){let i=e.uuid(),a=!1,s=!1,c=0,d=0;for(;;)try{return await t(e.client,i)}catch(o){if(o instanceof F){if(s)throw o;s=!0,n.onAttestationInvalid?.(),i=e.uuid();continue}if(!(o instanceof y))throw o;if(o.code==="consent_required"&&!a){a=!0,await e.ensureConsent({force:!0}),i=e.uuid();continue}if(o.code==="attestation_invalid"&&!s){s=!0,n.onAttestationInvalid?.(),i=e.uuid();continue}if(o.code==="inference_unavailable"&&d<Ae){d+=1;let u=N(o.retryAfterSeconds,Ee,e.random??Math.random);e.onBusy?.({attempt:d,retryAfterSeconds:u/1e3}),await e.sleep(u),n.onAttestationInvalid?.(),i=e.uuid();continue}if(Pe.has(o.code)&&c<Me){c+=1;let u=o.retryAfterSeconds!==void 0?o.retryAfterSeconds*1e3:void 0;await e.sleep(u!==void 0?Math.min(u,Ce):Te);continue}throw o}}r(W,"q");var Ne=new Set(["passed","review","processing","skipped"]);async function tt(e){let{artifacts:t}=e,n=t.clip,i=v(t.clipMime??"");if(t.degraded==="NO_RECORDER"||n===void 0||!Ie.includes(i))return{kind:"unavailable",reason:"no_recorder"};e.client.armCapture?.(2);let a=$e(e,t.keyframe),s=Ke(e,n,i,a),c=Re(e,a),d=!1,o=new Set,u=!0,f=0;for(;;){if(e.isCancelled())return{kind:"cancelled"};let l=e.getView();if(ye(l))return{kind:"settled"};let p=V(l),M=p?.checkType,P=M==="liveness"&&!d?"liveness":M==="face_match"&&!o.has(p?.id)&&o.size<2&&u?"face_match":null;if(P===null)return{kind:"settled"};if(P==="liveness"&&t.captureChannel==="desktop")return{kind:"unavailable",reason:"mobile_required"};try{if(P==="liveness"){d=!0;let h=await s();if(e.isCancelled())return{kind:"cancelled"};_e(l,h)&&o.add(E(h)?.id);for(let X of U(l,h))o.add(X);await e.applySubmit(h,"liveness");let _=O(e.getView(),"liveness")?.state;u=_===void 0||Ne.has(_)}else{o.add(p?.id);let h=await c();if(e.isCancelled())return{kind:"cancelled"};for(let _ of U(l,h))o.add(_);await e.applySubmit(h,"face_match")}}catch(h){if(e.isCancelled()||h instanceof j)return{kind:"cancelled"};let _=ze(h);if(_.kind!=="resync"||f>=Oe)return _;f+=1,await e.refreshView()}}}r(tt,"Me");function $e(e,t){let n=null,i=null,a=r(()=>n!==null?Promise.resolve(n):(i??(i=(async()=>{let s=await Z(e.client,"image",G,t.size,Q(e.artifacts));return await e.client.uploadToSpaces(s.uploadUrl,t,G),n=(await e.client.completeMedia(s.key)).key,e.onKeyframePromoted?.(n),n})().finally(()=>{i=null})),i),"o");return{ensure:a,attempt:r(()=>a().catch(()=>null),"attempt"),current:r(()=>n,"current")}}r($e,"le");function Ke(e,t,n,i){let a=null,s,c=null,d=0,o;return()=>W(e,async(u,f)=>{if(a===null||s===void 0){if(e.isCancelled())throw new j;s===void 0&&!xe(e.getView())&&(s=null),e.onPhase("uploading");let[l,p]=await Promise.all([a!==null?Promise.resolve(a):(async()=>{let M=await Z(u,"clip",n,t.size,Q(e.artifacts));return await u.uploadToSpaces(M.uploadUrl,t,n),(await u.completeMedia(M.key)).key})(),s!==void 0?Promise.resolve(s===null?null:s.imageKey):i.attempt()]);a=l,s===void 0&&(s=p===null?null:{imageKey:p})}if(c===null){let l=performance.now();try{c=await e.getAttestation(),o=e.attestationError?.()}catch(p){throw new F(p instanceof Error?p.message:String(p))}d=Math.round(performance.now()-l)}return e.onPhase("checking"),u.submitCheck("liveness",{clipKey:a,attestation:c,captureChannel:e.artifacts.captureChannel,capture:{...je(e.artifacts),attestationMs:d,attestationError:o},...s!==null?{faceMatch:s}:{}},{idempotencyKey:f})},{onAttestationInvalid:r(()=>{c=null},"onAttestationInvalid")})}r(Ke,"fe");function Re(e,t){return()=>W(e,async(n,i)=>{if(t.current()===null){if(e.isCancelled())throw new j;e.onPhase("uploading")}let a=await t.ensure();return e.onPhase("checking"),n.submitCheck("face_match",{imageKey:a},{idempotencyKey:i})})}r(Re,"pe");function je(e){let t={width:e.width,height:e.height};for(let n of Fe)e[n]!==void 0&&(t[n]=e[n]);return t}r(je,"me");var Fe=["engine","facingMode","mode","formFactor","clipMs","clipFrames","fps","clipRetakes","codec","cameraReadyMs","faceAcquireMs","captureMs","screenRamp","provenance"];function ze(e){if(e instanceof F)return{kind:"unavailable",reason:"attestation"};if(e instanceof y){if(e.code==="attestation_invalid")return{kind:"unavailable",reason:"attestation"};if(e.code==="inference_unavailable")return{kind:"unavailable",reason:"inference_unavailable"};if(e.code==="mobile_required")return{kind:"unavailable",reason:"mobile_required"};if(qe.has(e.code))return{kind:"resync"}}return{kind:"unavailable",reason:"network"}}r(ze,"ye");var S,nt=(S=class extends Error{constructor(t,n){super(`invalid ${t} (${n})`),this.name="InvalidInputError",this.field=t,this.kind=n}},r(S,"B"),S),I,it=(I=class extends Error{constructor(t,n){super(`invalid ${t} (${n})`),this.name="OtpInputError",this.field=t,this.kind=n}},r(I,"U"),I);function K(e){return e?.source==="upload"?null:e?.source==="choice"&&e.sourcePick!=="camera"?"upload_or_phone":"phone"}r(K,"E");function at(e,t){if(t===void 0||!R(t)||t.requiresMobile!==!0)return null;switch(t.checkType){case"liveness":return"phone";case"face_match":{if(t.reason!==void 0)return"phone";let n=O(e,"portrait_icao");return n?.state==="passed"||n?.state==="review"?null:"phone"}case"doc_ocr":return K(e.documents);case"poa":return K(e.proofOfAddress);case"portrait_icao":{let n=e.portrait;return n?.pendingFix!==void 0||n?.reuse?.pending===!0?null:K(n)}default:return null}}r(at,"Ie");function He(e){let t=e?.capture,n=t?.mode;return n==="assisted"||n==="self"||n==="choice"?n:t?.cameraSwitch===!0?"assisted":"self"}r(He,"Se");function rt(e){let t=e?.capture?.pick;return He(e)==="choice"&&(t==="self"||t==="assisted")?t:null}r(rt,"Oe");function st(e,t,n=null){return e==="choice"?t??n??"self":e}r(st,"Le");export{y as a,v as b,Ue as c,Ge as d,Ve as e,Qe as f,We as g,Xe as h,he as i,m as j,$ as k,fe as l,Ye as m,R as n,ye as o,V as p,O as q,T as r,C as s,et as t,Z as u,Ie as v,W as w,tt as x,je as y,nt as z,it as A,at as B,He as C,rt as D,st as E};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as te,b as fe,c as ge,d as ve,f as ye}from"./chunk-2FETDQV5.js";import{c as we,d as Me}from"./chunk-EWTKC2C2.js";import{e as Y}from"./chunk-7MV4CI4L.js";import{e as me,j as he}from"./chunk-CW56KMMH.js";import{g as ee}from"./chunk-JS2IXPNL.js";import{a as n}from"./chunk-4FHWXBOB.js";var qe={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 Be(e){let{deviceMemory:t,effectiveType:r,saveData:i,downlinkMbps:l,sourceLongEdge:u}=e,s=i===!0||r==="slow-2g"||r==="2g"||l!=null&&l>0&&l<1,d=t!=null&&t<=2,c=r==="4g"||l!=null&&l>=5,v=t!=null&&t>=6,f;s||d?f="low":c&&v?f="good":f="mid";let y=qe[f],M=u&&u>0?Math.min(y.maxLongEdge,u):y.maxLongEdge;return{tier:f,...y,maxLongEdge:M}}n(Be,"Ve");function ze(e){let t={};try{let r=navigator;typeof r.deviceMemory=="number"&&(t.deviceMemory=r.deviceMemory);let i=r.connection;i&&(t.effectiveType=i.effectiveType,t.saveData=i.saveData,t.downlinkMbps=i.downlink)}catch{}return typeof e=="number"&&e>0&&(t.sourceLongEdge=e),Be(t)}n(ze,"we");function Ie(e,t,r){let i=Math.min(1,Math.max(0,(e-.28)/.21999999999999997)),l=(t+r)/2;return Math.max(t,r-i*(r-l))}n(Ie,"Ye");function Oe(e,t,r){let i=Math.max(e,t),l=i>0?Math.min(1,r/i):1;return{width:Math.max(1,Math.round(e*l)),height:Math.max(1,Math.round(t*l))}}n(Oe,"Qe");async function Ue(e,t){let r=t.startQ,i=await e(r);for(let l=0;l<4&&!(i.size<=t.budgetBytes||r<=t.qMin);l++)r=Math.max(t.qMin,r-.08),i=await e(r);return{blob:i,quality:r}}n(Ue,"Ke");async function Ne(e,t,r,i,l){if(t<=0||r<=0)return null;let{width:u,height:s}=Oe(t,r,i.maxLongEdge),d=document.createElement("canvas");d.width=u,d.height=s;let c=d.getContext("2d");if(!c)return null;c.drawImage(e,0,0,u,s);let v=n(q=>new Promise((g,m)=>{d.toBlob(h=>h?g(h):m(new Error("canvas toBlob returned null")),"image/jpeg",q)}),"f"),f=Ie(l,i.qMin,i.qMax),{blob:y,quality:M}=await Ue(v,{startQ:f,qMin:i.qMin,budgetBytes:i.payloadTargetBytes}).finally(()=>{d.width=0,d.height=0});if(y.size>5242880)throw new Error("encoded document exceeds the 5242880-byte media cap");return{blob:y,quality:M,width:u,height:s}}n(Ne,"Ce");async function Ve(e){let t=ze(Math.max(e.width,e.height)),r=await Ne(e,e.width,e.height,t,.5);if(r===null)throw new Error("canvas encode unavailable");return{blob:r.blob,width:r.width,height:r.height}}n(Ve,"ee");function Ce(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}}n(Ce,"ne");var Re=n(e=>e==="recto"?"verso":"recto","xe"),Ae=n(e=>e.phase==="framing"||e.phase==="locking"||e.phase==="flipCue"||e.phase==="reaskRecto","ve"),oe=n(e=>(e.captured.recto!==void 0?1:0)+(e.captured.verso!==void 0?1:0)+e.pending.length,"re");function re(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}}n(re,"te");function je(e,t,r){if(e.phase==="result")return{...e,lastReportAt:r};let i=!t.present||e.captureArea!==void 0&&t.areaFrac<.6*e.captureArea,{flipped:l,awaySince:u}=e;i&&(u=u??r),u!==void 0&&r-u>=250&&(l=!0),i||(u=void 0);let s=e.flipTimeoutSpent&&!(l&&!e.flipped),d={...e,lastReportAt:r,flipped:l,awaySince:u,flipTimeoutSpent:s,lastArea:t.areaFrac};if(!Ae(e))return d;if(e.needFlip&&!l){if(!t.ready)return{...d,phase:e.restPhase,goodSince:void 0};let c=e.lastShot!==void 0&&e.pending.includes(e.lastShot);if(s||c)return{...d,goodSince:void 0,phase:e.restPhase};let v=e.goodSince??r;return r-v>=1800?{...d,goodSince:v,phase:"capturing",flipTimeoutSpent:!0,timeoutCapture:!0}:{...d,goodSince:v,phase:e.restPhase}}return t.ready?{...d,phase:"capturing",goodSince:e.goodSince??r}:{...d,goodSince:void 0,phase:t.locking?"locking":e.restPhase}}n(je,"je");function He(e,t){if(!Ae(e)||e.manualShutter)return e;let r=t-e.lastReportAt>=2e3,i=t-e.lastCaptureAt>=6e3;return r||i?{...e,manualShutter:!0}:e}n(He,"$e");function Ge(e,t,r){let i=e.layout==="singlePage",l=i?{recto:t}:e.captured,u=i?[]:[...e.pending,t],s={...e,captured:l,pending:u,lastShot:t,lastCaptureAt:r,lastReportAt:-1,manualShutter:!1,goodSince:void 0,notice:void 0,awaySince:void 0,flipped:!1,lastShotByTimeout:e.timeoutCapture,timeoutCapture:!1,captureArea:e.lastArea};return i||oe({captured:l,pending:u})>=2?{...s,phase:"reading",restPhase:"framing",current:void 0,needFlip:!1}:{...s,phase:"flipCue",restPhase:"flipCue",current:void 0,needFlip:!0}}n(Ge,"Je");function Le(e,t,r){return e.pending.includes(t)?{...e,pending:e.pending.filter(i=>i!==t),lastShot:e.lastShot===t?void 0:e.lastShot,phase:e.phase==="capturing"?e.phase:"flipCue",restPhase:"flipCue",current:Re(r),needFlip:!0,flipTimeoutSpent:!0,goodSince:void 0,manualShutter:!0,notice:"same_face",lastCaptureAt:-1,lastReportAt:-1}:e}n(Le,"Le");function _e(e,t,r){if(!e.pending.includes(t))return e;if(e.captured[r]!==void 0)return Le(e,t,r);let i=e.pending.filter(c=>c!==t),l={...e,pending:i,captured:{...e.captured,[r]:t}};if(oe(l)!==1||e.layout==="singlePage")return l;let u=Re(r),s=u==="recto"&&e.restPhase==="reaskRecto"?"reaskRecto":"flipCue",d=e.phase==="flipCue"||e.phase==="reaskRecto"||e.phase==="framing";return{...l,restPhase:s,current:u,phase:d?s:e.phase}}n(_e,"Ze");function Qe(e,t){let r=t.id??e.captured[t.side],i={...e.captured};(t.id===void 0||i[t.side]===t.id)&&delete i[t.side];let l=e.pending.filter(v=>v!==r),u=e.layout==="twoSided"&&oe({captured:i,pending:l})>0,s=e.lastShotByTimeout||r===e.lastShot!==e.flipped,d=u&&!s,c=d?t.side==="recto"?"reaskRecto":"flipCue":"framing";return{...e,captured:i,pending:l,readSides:e.readSides.filter(v=>v!==t.side),lastShot:e.lastShot===r?void 0:e.lastShot,notice:t.issue,goodSince:void 0,manualShutter:!1,phase:c,restPhase:c,current:t.side,needFlip:d,flipped:!1,flipTimeoutSpent:!1,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1}}n(Qe,"et");function Ye(e,t){switch(t.type){case"report":return je(re(e,t.at),t.report,t.at);case"tick":return He(re(e,t.at),t.at);case"captured":return Ge(re(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 _e(e,t.id,t.side);case"duplicate":return Le(e,t.id,t.side);case"readOk":{let r=e.readSides.includes(t.side)?e.readSides:[...e.readSides,t.side],i=["recto","verso"].filter(u=>e.captured[u]!==void 0),l=e.phase==="reading"&&e.pending.length===0&&i.every(u=>r.includes(u));return{...e,readSides:r,flipTimeoutSpent:!1,phase:l?"result":e.phase}}case"readFailed":return Qe(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{...Ce(e.layout,-1),lastCaptureAt:-1,lastReportAt:-1};default:return e}}n(Ye,"Te");function Je(e,t,r=!1){let i=e(t);return i===null?"recto":!r||i.y+i.height/2>=t.height/2?"verso":"recto"}n(Je,"tt");async function $e(e,t=!1){let{detectMrzBand:r}=await import("./mrz-band-VYHOTDHY-VEZ2J5IL.js");return Je(r,e,t)}n($e,"nt");async function be(e,t=480,r,i=r!=null){let l=r??{x:0,y:0,width:e.width,height:e.height},u=Math.max(1,Math.round(l.height/l.width*t)),s=document.createElement("canvas");s.width=t,s.height=u;try{let d=s.getContext("2d");return d===null?"recto":(d.drawImage(e,l.x,l.y,l.width,l.height,0,0,t,u),await $e(d.getImageData(0,0,t,u),i))}finally{s.width=0,s.height=0}}n(be,"oe");var ae=n((e,t,r)=>Math.min(r,Math.max(t,Math.round(e))),"ae"),J=n(e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4,"Y");async function Ke(e,t,r,i){let l=i.decode??(c=>createImageBitmap(c)),u=n(async()=>e.stillRead(await l(t),i.region??[0,0,1,1],i.detectorLimit),"c"),s;try{s=await u()}catch{try{await new Promise(c=>setTimeout(c,i.retryMs??300)),s=await u()}catch{return null}}let d=s.mrzBox;return d===void 0?null:{engine:i.engine,source:"live_mrz",format:r.format,lineCount:ae(r.lineCount,2,3),checkDigitsValid:!0,stillConfirmed:s.valid&&s.digest===r.digest,band:[J(d[0]),J(d[1]),J(Math.min(d[2],1-d[0])),J(Math.min(d[3],1-d[1]))],digest:r.digest,framesToValid:ae(r.framesToValid,1,1e3),msToValid:ae(r.msToValid,0,12e4)}}n(Ke,"_e");var Ze=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]),Xe=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 et(e,t=globalThis){let r=t.WebAssembly?.validate;if(typeof r!="function")return{ok:!1,reason:"simd"};try{if(!r.call(t.WebAssembly,Ze)||!r.call(t.WebAssembly,Xe))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 i=t.navigator?.deviceMemory;return typeof i=="number"&&i<e.minDeviceMemoryGb?{ok:!1,reason:"memory"}:{ok:!0}}n(et,"Ee");function tt(e=globalThis){let t=e.navigator?.connection;return t?.saveData===!0||["slow-2g","2g","3g"].includes(t?.effectiveType??"")}n(tt,"Oe");var U,E=(U=class extends Error{constructor(t){super(t),this.name="OcrEngineError",this.code=t}},n(U,"_"),U);function ke(){let e=n(t=>(t.close(),Promise.reject(new E("unsupported"))),"e");return{ready:Promise.resolve("unsupported"),busy:!1,bandRead:e,stillRead:e,layoutRead:e,dispose:n(()=>{},"dispose")}}n(ke,"Pe");function rt(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 ke()}catch{return ke()}let r=new Map,i=0,l=!1,u=!1,s=!1;t.addEventListener("message",m=>{let h=m.data,S=r.get(h.id);S&&(r.delete(h.id),S.resolve(h))});let d=n(()=>{for(let m of r.values())m.reject(new E("error"));r.clear(),v()},"u");t.addEventListener("error",d),t.addEventListener("messageerror",d);function c(m,h=[]){if(l)return Promise.reject(new E("disposed"));let S=++i;return new Promise((W,F)=>{r.set(S,{resolve:W,reject:F});try{t.postMessage({...m,id:S},h)}catch{r.delete(S),F(new E("error"))}})}n(c,"l");function v(){if(!l){l=!0;try{t.postMessage({id:++i,kind:"dispose"})}catch{}t.terminate();for(let m of r.values())m.reject(new E("disposed"));r.clear()}}n(v,"f");let f=(async()=>{let m=await c({kind:"init",baseUrl:e.baseUrl,salt:e.salt,detectorLimit:e.tuning.detectorLimit,maxDownloadMs:e.tuning.maxDownloadMs});if(m.kind==="failed")return m.reason;if(m.kind!=="ready")return"error";let h=await c({kind:"warmup"});return h.kind!=="ready"?"error":{warmupMs:h.warmupMs,downloadMs:m.downloadMs,cached:m.cached}})().catch(()=>"error"),y,M=new Promise(m=>{y=setTimeout(()=>m("timeout"),e.tuning.loadTimeoutMs)}),q=Promise.race([f,M]).then(m=>(clearTimeout(y),typeof m=="string"?v():s=!0,l&&typeof m!="string"?"error":m));(e.page===void 0?globalThis.addEventListener?globalThis:null:e.page)?.addEventListener("pagehide",v,{once:!0});async function g(m,h,S){if(l)throw h.close(),new E("disposed");if(!s)throw h.close(),new E("not_ready");if(u)throw h.close(),new E("busy");u=!0;let W;try{let F=new Promise((j,N)=>{W=setTimeout(()=>{N(new E("timeout")),v()},e.tuning.readTimeoutMs??1e4)}),P=await Promise.race([c(m,[h]),F]);if(P.kind===S){let{id:j,...N}=P;return N}throw new E(P.kind==="error"?P.code:P.kind==="failed"?P.reason:"error")}finally{clearTimeout(W),u=!1}}return n(g,"w"),{ready:q,get busy(){return u},bandRead:n((m,h=e.tuning.detectorLimit)=>g({kind:"band",bitmap:m,detectorLimit:h},m,"band"),"bandRead"),stillRead:n((m,h,S=e.tuning.detectorLimit)=>g({kind:"still",bitmap:m,region:h,detectorLimit:S},m,"band"),"stillRead"),layoutRead:n((m,h)=>g({kind:"layout",bitmap:m,detectorLimit:h},m,"layout"),"layoutRead"),dispose:v}}n(rt,"Ae");var $="sekyro-ocr-1",ie=n(e=>e!==null&&typeof e=="object"?e:{},"ie"),R=n((e,t,r,i)=>typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=r?e:i,"v"),Se=n((e,t)=>typeof e=="boolean"?e:t,"Be"),xe=n(e=>{let t=typeof e=="string"?/^sekyro-ocr-(\d{1,4})$/.exec(e):null;return t?Number(t[1]):Number.POSITIVE_INFINITY},"Ie");function at(e,t={}){let r=ie(e),i=ie(r.liveMrz),l=ie(r.frontLock),u=xe(t.engine??$),s=t.mode==="off",d=n(h=>h.enabled===!0?h.arm==="live"?"live":"control":null,"u"),c=d(i),v=d(l),f=n((h,S)=>!s&&S==="live"&&xe(h.minEngine??$)<=u,"p"),y=ve,M=f(i,c)?{detectorLimit:R(i.detectorLimit,320,1600,y.detectorLimit),bandMaxWidthPx:R(i.bandMaxWidthPx,320,4096,y.bandMaxWidthPx),minBandWidthPx:R(i.minBandWidthPx,0,4096,y.minBandWidthPx),bandTop:R(i.bandTop,0,.95,y.bandTop),minIntervalMs:R(i.minIntervalMs,0,5e3,y.minIntervalMs),stableReads:Math.round(R(i.stableReads,1,10,y.stableReads)),profileReads:Math.round(R(i.profileReads,1,100,y.profileReads)),maxReadMs:R(i.maxReadMs,50,6e4,y.maxReadMs),searchTimeoutMs:R(i.searchTimeoutMs,1e3,12e4,y.searchTimeoutMs),hint:Se(i.hint,!0),stillConfirm:Se(i.stillConfirm,!0)}:null,q=ge,g=n((h,S,W)=>R(l[h],S,W,q[h]),"h"),m=f(l,v)?{minLines:Math.round(g("minLines",1,50)),fillMin:g("fillMin",0,1),fillMax:g("fillMax",0,2),offsetMax:g("offsetMax",0,1),steadyFillDelta:g("steadyFillDelta",0,1),steadyOffsetDelta:g("steadyOffsetDelta",0,1),layoutShiftMax:g("layoutShiftMax",0,1),lineCountDelta:Math.round(g("lineCountDelta",0,50)),lockMs:g("lockMs",0,3e4),steadyMs:g("steadyMs",0,3e4),minFrames:Math.round(g("minFrames",1,100)),minIntervalMs:g("minIntervalMs",0,5e3),maxWidthPx:g("maxWidthPx",160,2048),detectorLimit:g("detectorLimit",320,1600),searchTimeoutMs:g("searchTimeoutMs",1e3,12e4)}:null;return{enabled:M!==null||m!==null,liveMrz:M,textLock:m,liveMrzArm:c,frontLockArm:v,load:{detectorLimit:M?.detectorLimit??m?.detectorLimit??y.detectorLimit,loadTimeoutMs:R(i.loadTimeoutMs,1e3,12e4,2e4),maxDownloadMs:R(i.maxDownloadMs,1e3,12e4,2e4),minDeviceMemoryGb:R(i.minDeviceMemoryGb,0,64,2)},reportSampleRate:R(i.reportSampleRate,0,1,1)}}n(at,"We");function it(e,t){return e.enabled?!(t.probe??et)({minDeviceMemoryGb:e.load.minDeviceMemoryGb}).ok||(t.slow??tt)()?{ok:!1,reason:"unsupported"}:{ok:!0,engine:rt({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"}}n(it,"Fe");function nt(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"}n(nt,"at");var z=n(e=>e===void 0||!Number.isFinite(e)?void 0:Math.min(6e5,Math.max(0,Math.round(e))),"W"),ne=n((e,t,r)=>e===void 0||!Number.isFinite(e)?void 0:Math.min(r,Math.max(t,Math.round(e))),"se");function ot(e){let t=e.assist??null,r=e.load!==null&&e.load!==void 0&&typeof e.load=="object"?e.load:null,i=typeof e.load=="string"?e.load:null,l=t!==null?t.outcome:i==="unsupported"||i==="download"||i==="integrity"?i:i==="error"||i==="timeout"?"error":"off",u={kind:"live_mrz",platform:"web",engine:e.engine??$,arm:e.arm,capture:e.capture,outcome:l,reads:ne(t?.reads??0,0,1e4)??0,browser:e.browser??nt()},s=n((d,c)=>{c!==void 0&&(u[d]=c)},"s");return s("format",t?.format),s("framesToValid",ne(t?.framesToValid,1,1e4)),s("msToValid",z(t?.msToValid)),s("framesToLock",ne(t?.framesToLock,1,1e4)),s("msToLock",z(t?.msToLock)),s("msToCapture",z(e.msToCapture)),s("readP50Ms",z(t?.readP50Ms)),s("readP90Ms",z(t?.readP90Ms)),s("deviceClass",t?.deviceClass),r!==null&&(s("warmupMs",z(r.warmupMs)),s("downloadMs",z(r.downloadMs)),s("cached",r.cached)),s("stillConfirmed",e.stillConfirmed),s("typeMismatch",e.typeMismatch),u}n(ot,"ze");function Te(e,t){return e===void 0?!1:t==="passport"?e!=="TD3":e==="TD3"}n(Te,"ue");var lt=2;async function st(e){let t=await import("./capture-session-doc-WZMI5XPE-AZDHR6MQ.js");return new t.CaptureSessionDoc(e)}n(st,"st");function dt(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}}}n(dt,"ut");function ut(e,t,r){let i=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft],l=0;for(let u=0;u<i.length;u+=1){let s=i[u],d=i[(u+1)%i.length];l+=s.x*d.y-d.x*s.y}return t>0&&r>0?Math.abs(l)/2/(t*r):0}n(ut,"ct");function vt(){import("./capture-session-doc-WZMI5XPE-AZDHR6MQ.js").then(e=>e.warmDocDetector()).catch(()=>{})}n(vt,"Ht");function yt(e){return ct(e,{}).handle}n(yt,"Xt");function ct(e,t){let r=me(),i=he({enabled:e.keepScreenAwake!==!1}),l=t.decode??(a=>createImageBitmap(a)),u=t.blurRefuseSharpnessMax??.16,s=t.now??(()=>performance.now()),d=e.documentType==="passport"||e.side==="single",c=Ce(d?"singlePage":"twoSided",s());if(!d&&(e.side==="recto"||e.side==="verso")){let a=e.side==="recto"?"verso":"recto";c={...c,captured:{[a]:"server"},readSides:[a],current:e.side,phase:"flipCue",restPhase:"flipCue"}}let v="idle",f=null,y=null,M=!0,q=0,g=0,m=!1,h=!1,S="",W=null,F,P=null,j=[],N=we.find(a=>a.docType===e.documentType)?.mrz==="none",x=t.webOcr!==void 0&&!N?at(t.webOcr.captureDocument,{mode:e.liveMrz?.mode??"auto"}):null,V=null,I=x===null||!x.enabled?"off":null,H=null,G=null,le=new WeakMap,K="";if(x!==null&&x.enabled&&t.webOcr!==void 0){let a=t.webOcr,o=it(x,{baseUrl:e.liveMrz?.assetBaseUrl??a.baseUrl,salt:a.salt,...e.liveMrz?.workerUrl!==void 0?{workerUrl:e.liveMrz.workerUrl}:{},...a.createWorker!==void 0?{createWorker:a.createWorker}:{}});if(o.ok){V=o.engine;let p=new ye({textLock:x.textLock,liveMrz:x.liveMrz});H=p;let w=o.engine;w.ready.then(A=>{I=A,typeof A!="string"&&M&&p.setEngine(w)})}else I=o.reason}let O=n(a=>{let o=JSON.stringify(a);o!==K&&(K=o,r.emit("mrz",a))},"z"),se=n((a,o)=>{let p=t.webOcr?.reports;if(p===void 0||x===null||a===void 0)return;let w=a.format==="ID-3"||a.side==="single"?"single":a.side==="verso"?"verso":"recto",A=w!=="recto"?x.liveMrzArm??x.frontLockArm:x.frontLockArm;if(A===null||Math.random()>=x.reportSampleRate)return;let L=a.via==="live_mrz"?G:null,C=n(()=>{let D=L?.value??null;p([ot({arm:A,capture:w,assist:a.ocr??null,load:A==="control"?"off":I,...a.msToCapture!==void 0?{msToCapture:a.msToCapture}:{},...D!==null&&D.stillConfirmed!==void 0?{stillConfirmed:D.stillConfirmed}:{},...o!==void 0?{typeMismatch:Te(o.format,e.documentType==="passport"?"passport":"card")}:{}})])},"x");L!==null&&L.value===null?Promise.race([L.promise,new Promise(D=>setTimeout(D,3e3))]).then(C):C()},"le"),B=n(a=>{!M||a===v||(v=a,i.setActive(a==="starting"||a==="scanning"),r.emit("state",a))},"I"),Pe=n((a,o)=>o===void 0?null:d?"single":a.captured.recto===o?"recto":a.captured.verso===o?"verso":null,"Ne"),De=n(a=>({phase:a.phase,captured:d?a.captured.recto!==void 0?["single"]:[]:["recto","verso"].filter(o=>a.captured[o]!==void 0),expected:d?null:a.current??null,notice:a.notice??null,lastShot:Pe(a,a.lastShot),manualShutter:a.manualShutter,torchAvailable:f?.torchAvailable()??!1,torch:h}),"Ue"),de=n(()=>{let a=f;a!==null&&a.captureNow().catch(()=>T({type:"captureFailed",at:s()}))},"de");function T(a){if(!M)return;let o=c;c=Ye(c,a),c.phase==="capturing"&&o.phase!=="capturing"&&Promise.resolve().then(de),c.phase==="result"&&o.phase!=="result"&&(B("done"),ue());let p=De(c),w=JSON.stringify(p);w!==S&&(S=w,r.emit("scan",p))}n(T,"R");function ue(){P!==null&&clearInterval(P),P=null;for(let a of j.splice(0))a();f?.destroy(),f=null,i.setActive(!1)}n(ue,"me");let ce=n(()=>f?.captureReport?.(),"pe"),Z=!1,pe=n((a,o)=>{if(!(a===void 0||t.onFaceReport===void 0))try{t.onFaceReport(a,o)}catch{}},"fe"),_=n(a=>{K="",!(f===null||c.phase==="reading"||c.phase==="result")&&(Z=!1,f.rearm(d?"single":c.current??a))},"H"),Ee=n(async(a,o,p,w)=>{if(G=null,w!==void 0&&V!==null&&x?.liveMrz?.hint===!0){let b={promise:Ke(V,a,w,{engine:$,detectorLimit:x.liveMrz.detectorLimit}).catch(()=>null),value:null};b.promise.then(k=>{b.value=k}),G=b}w!==void 0&&Te(w.format,e.documentType==="passport"?"passport":"card")&&O({state:"mismatch",format:w.format});let A=ce();pe(A,"captured"),Z=!0,se(A,w);let L=p===void 0?W:p===null?null:{quad:dt(p),frameWidth:0,frameHeight:0,inStill:!0},C={decoded:null},D=n(()=>(C.decoded??(C.decoded=Promise.resolve().then(()=>l(a)).catch(()=>null)),C.decoded),"E");try{await We(a,o,L,D,G)}finally{C.decoded!==null&&(await C.decoded)?.close()}},"Ge"),We=n(async(a,o,p,w,A)=>{let L=`shot-${q+=1}`;if(T({type:"captured",id:L,at:s()}),e.haptics!==!1)try{globalThis.navigator?.vibrate?.(30)}catch{}if(!m&&u>0){let b=await(t.measureSharpness!==void 0?t.measureSharpness(a,p):w().then(k=>k===null?-1:fe(k,te(p?.quad??null,p?.inStill===!0?k:{width:p?.frameWidth??0,height:p?.frameHeight??0},k)))).catch(()=>-1);if(!M)return;if(Number.isFinite(b)&&b>=0&&b<u){m=!0;let k=d?"recto":c.current??(c.captured.recto===void 0?"recto":"verso");T({type:"readFailed",side:k,id:L,issue:"blurry"}),_(k);return}}m=!1;let C;if(d)C="single";else{let b=c.current,k=await(t.classify!==void 0?t.classify(a):w().then(Q=>Q===null?b??"recto":p?.inStill===!0?be(Q,480,null,!0):be(Q,480,te(p?.quad??null,{width:p?.frameWidth??0,height:p?.frameHeight??0},Q)))).catch(()=>b??"recto");if(!M)return;if(c.captured[k]!==void 0&&g<lt){g+=1,T({type:"duplicate",id:L,side:k}),_(k==="recto"?"verso":"recto");return}C=c.captured[k]!==void 0&&b!==void 0?b:k,g=0,T({type:"classified",id:L,side:C})}let D=C==="verso"?"verso":"recto";try{let b=t.encode!==void 0?await t.encode(a):await w().then(k=>{if(k===null)throw new Error("the still could not be decoded");return Ve(k)});if(!M)return;A!==null&&le.set(b.blob,A),r.emit("captured",{image:b.blob,side:C,documentType:e.documentType,...e.issuer!==void 0?{issuer:e.issuer}:{},width:b.width,height:b.height,previewDataUrl:o}),t.deferRead!==!0&&T({type:"readOk",side:D})}catch(b){T({type:"readFailed",side:D,id:L,issue:"technical"}),r.emit("error",Y("generic",!0,{phase:"keyframes",name:ee(b)}))}_(D==="recto"?"verso":"recto")},"qe"),Fe=n(a=>{j.push(a.on("statechange",({state:o})=>{o==="preflight"||o==="acquiring"?B("starting"):o==="positioning"?B("scanning"):o==="captured"?B("captured"):o==="error"&&B("error")}),a.on("feedback",({key:o,reticle:p})=>r.emit("feedback",{key:o,reticle:p})),a.on("checks",o=>{r.emit("gate",{progress:o.p,quad:o.quad,frameWidth:o.frameWidth,frameHeight:o.frameHeight,...o.guide!==void 0?{guide:{detected:o.guide.detected,fill:o.guide.fill,offsetX:o.guide.offsetX??0,offsetY:o.guide.offsetY??0}}:{}});let p=o.ocr?.mrz;p!==void 0&&(p.state==="fallback"?O({state:"fallback",reason:p.reason}):p.state==="valid"?O({state:"valid",format:p.format}):p.state==="reading"?O({state:"reading",...p.format?{format:p.format}:{},...p.coach?{coach:p.coach}:{}}):O({state:"searching"}));let w=o.quad===null?0:ut(o.quad,o.frameWidth,o.frameHeight);W=o.quad===null?null:{quad:o.quad,frameWidth:o.frameWidth,frameHeight:o.frameHeight},T({type:"report",report:{present:o.quad!==null&&o.plausible||o.guide?.detected===!0,ready:o.ready===!0,locking:o.p>=.5,areaFrac:w},at:s()})}),a.on("error",({kind:o,retryable:p,detail:w})=>r.emit("error",Y(o,p,w))),a.on("artifacts",o=>{Ee(o.keyframe,o.previewDataUrl,o.docRegion,o.liveMrz)}))},"He"),X=n(()=>(y??(y=(async()=>{if(M){if(f===null){let a;try{a=await(t.createEngine??st)({...t.engineOptions??{},...F!==void 0?{guide:F}:{},video:e.video,format:Me(e.documentType),side:d?"single":e.side??"recto",autoCapture:!1,...H!==null?{ocr:H}:{}})}catch(p){B("error"),r.emit("error",Y("models",!0,{phase:"models",name:ee(p)}));return}if(!M){a.destroy();return}f=a,Fe(a);let o=t.tickMs??500;o>0&&(P=setInterval(()=>T({type:"tick",at:s()}),o))}T({type:"clockRestart"}),x!==null&&x.liveMrzArm==="live"&&(I==="unsupported"||I==="off")&&O({state:"fallback",reason:I}),await f.start()}})().finally(()=>{y=null})),y),"$");return{handle:{get state(){return v},on:n((a,o)=>r.on(a,o),"on"),start:X,retry:n(()=>{if(f===null&&c.phase==="result"){T({type:"retake"}),g=0,m=!1,X();return}if(f!==null&&v!=="error"){T({type:"retake"}),g=0,m=!1,f.rearm(d?"single":void 0);return}X()},"retry"),setSide:n(a=>{d||a==="single"||(c.current!==a&&(c={...c,current:a}),T({type:"clockRestart"}),c.phase!=="reading"&&c.phase!=="result"&&f?.rearm(a))},"setSide"),shutter:de,focusAt:n((a,o)=>{f?.focusAt?.(a,o)},"focusAt"),setGuide:n(a=>{F=a,f?.setGuide?.(a)},"setGuide"),setTorch:n(a=>{h=a,f?.setTorch(a),T({type:"tick",at:s()})},"setTorch"),destroy:n(()=>{if(M&&f!==null&&v!=="done"){let a=ce();!Z&&a!==void 0&&a.ticks>0&&pe(a,"abandoned"),se(a,void 0)}M=!1,ue(),H?.setEngine(null),V?.dispose(),V=null,r.clear()},"destroy")},setFlowState:n(a=>{(c.phase==="reading"||c.phase==="result")&&B(a==="done"&&c.phase!=="result"?"scanning":a)},"setFlowState"),settle:n((a,o)=>{let p=a==="verso"?"verso":"recto";T(o.ok?{type:"readOk",side:p}:{type:"readFailed",side:p,issue:o.issue}),o.ok||_(p)},"settle"),takeDeviceRead:n(a=>le.get(a.image)?.value??null,"takeDeviceRead")}}n(ct,"lt");export{lt as a,vt as b,yt as c,ct as d};
|
|
1
|
+
import{a as te,b as fe,c as ge,d as ve,f as ye}from"./chunk-2FETDQV5.js";import{c as we,d as Me}from"./chunk-EWTKC2C2.js";import{e as Y}from"./chunk-H5GXVL63.js";import{e as me,j as he}from"./chunk-CW56KMMH.js";import{g as ee}from"./chunk-JS2IXPNL.js";import{a as n}from"./chunk-4FHWXBOB.js";var qe={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 Be(e){let{deviceMemory:t,effectiveType:r,saveData:i,downlinkMbps:l,sourceLongEdge:u}=e,s=i===!0||r==="slow-2g"||r==="2g"||l!=null&&l>0&&l<1,d=t!=null&&t<=2,c=r==="4g"||l!=null&&l>=5,v=t!=null&&t>=6,f;s||d?f="low":c&&v?f="good":f="mid";let y=qe[f],M=u&&u>0?Math.min(y.maxLongEdge,u):y.maxLongEdge;return{tier:f,...y,maxLongEdge:M}}n(Be,"Ve");function ze(e){let t={};try{let r=navigator;typeof r.deviceMemory=="number"&&(t.deviceMemory=r.deviceMemory);let i=r.connection;i&&(t.effectiveType=i.effectiveType,t.saveData=i.saveData,t.downlinkMbps=i.downlink)}catch{}return typeof e=="number"&&e>0&&(t.sourceLongEdge=e),Be(t)}n(ze,"we");function Ie(e,t,r){let i=Math.min(1,Math.max(0,(e-.28)/.21999999999999997)),l=(t+r)/2;return Math.max(t,r-i*(r-l))}n(Ie,"Ye");function Oe(e,t,r){let i=Math.max(e,t),l=i>0?Math.min(1,r/i):1;return{width:Math.max(1,Math.round(e*l)),height:Math.max(1,Math.round(t*l))}}n(Oe,"Qe");async function Ue(e,t){let r=t.startQ,i=await e(r);for(let l=0;l<4&&!(i.size<=t.budgetBytes||r<=t.qMin);l++)r=Math.max(t.qMin,r-.08),i=await e(r);return{blob:i,quality:r}}n(Ue,"Ke");async function Ne(e,t,r,i,l){if(t<=0||r<=0)return null;let{width:u,height:s}=Oe(t,r,i.maxLongEdge),d=document.createElement("canvas");d.width=u,d.height=s;let c=d.getContext("2d");if(!c)return null;c.drawImage(e,0,0,u,s);let v=n(q=>new Promise((g,m)=>{d.toBlob(h=>h?g(h):m(new Error("canvas toBlob returned null")),"image/jpeg",q)}),"f"),f=Ie(l,i.qMin,i.qMax),{blob:y,quality:M}=await Ue(v,{startQ:f,qMin:i.qMin,budgetBytes:i.payloadTargetBytes}).finally(()=>{d.width=0,d.height=0});if(y.size>5242880)throw new Error("encoded document exceeds the 5242880-byte media cap");return{blob:y,quality:M,width:u,height:s}}n(Ne,"Ce");async function Ve(e){let t=ze(Math.max(e.width,e.height)),r=await Ne(e,e.width,e.height,t,.5);if(r===null)throw new Error("canvas encode unavailable");return{blob:r.blob,width:r.width,height:r.height}}n(Ve,"ee");function Ce(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}}n(Ce,"ne");var Re=n(e=>e==="recto"?"verso":"recto","xe"),Ae=n(e=>e.phase==="framing"||e.phase==="locking"||e.phase==="flipCue"||e.phase==="reaskRecto","ve"),oe=n(e=>(e.captured.recto!==void 0?1:0)+(e.captured.verso!==void 0?1:0)+e.pending.length,"re");function re(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}}n(re,"te");function je(e,t,r){if(e.phase==="result")return{...e,lastReportAt:r};let i=!t.present||e.captureArea!==void 0&&t.areaFrac<.6*e.captureArea,{flipped:l,awaySince:u}=e;i&&(u=u??r),u!==void 0&&r-u>=250&&(l=!0),i||(u=void 0);let s=e.flipTimeoutSpent&&!(l&&!e.flipped),d={...e,lastReportAt:r,flipped:l,awaySince:u,flipTimeoutSpent:s,lastArea:t.areaFrac};if(!Ae(e))return d;if(e.needFlip&&!l){if(!t.ready)return{...d,phase:e.restPhase,goodSince:void 0};let c=e.lastShot!==void 0&&e.pending.includes(e.lastShot);if(s||c)return{...d,goodSince:void 0,phase:e.restPhase};let v=e.goodSince??r;return r-v>=1800?{...d,goodSince:v,phase:"capturing",flipTimeoutSpent:!0,timeoutCapture:!0}:{...d,goodSince:v,phase:e.restPhase}}return t.ready?{...d,phase:"capturing",goodSince:e.goodSince??r}:{...d,goodSince:void 0,phase:t.locking?"locking":e.restPhase}}n(je,"je");function He(e,t){if(!Ae(e)||e.manualShutter)return e;let r=t-e.lastReportAt>=2e3,i=t-e.lastCaptureAt>=6e3;return r||i?{...e,manualShutter:!0}:e}n(He,"$e");function Ge(e,t,r){let i=e.layout==="singlePage",l=i?{recto:t}:e.captured,u=i?[]:[...e.pending,t],s={...e,captured:l,pending:u,lastShot:t,lastCaptureAt:r,lastReportAt:-1,manualShutter:!1,goodSince:void 0,notice:void 0,awaySince:void 0,flipped:!1,lastShotByTimeout:e.timeoutCapture,timeoutCapture:!1,captureArea:e.lastArea};return i||oe({captured:l,pending:u})>=2?{...s,phase:"reading",restPhase:"framing",current:void 0,needFlip:!1}:{...s,phase:"flipCue",restPhase:"flipCue",current:void 0,needFlip:!0}}n(Ge,"Je");function Le(e,t,r){return e.pending.includes(t)?{...e,pending:e.pending.filter(i=>i!==t),lastShot:e.lastShot===t?void 0:e.lastShot,phase:e.phase==="capturing"?e.phase:"flipCue",restPhase:"flipCue",current:Re(r),needFlip:!0,flipTimeoutSpent:!0,goodSince:void 0,manualShutter:!0,notice:"same_face",lastCaptureAt:-1,lastReportAt:-1}:e}n(Le,"Le");function _e(e,t,r){if(!e.pending.includes(t))return e;if(e.captured[r]!==void 0)return Le(e,t,r);let i=e.pending.filter(c=>c!==t),l={...e,pending:i,captured:{...e.captured,[r]:t}};if(oe(l)!==1||e.layout==="singlePage")return l;let u=Re(r),s=u==="recto"&&e.restPhase==="reaskRecto"?"reaskRecto":"flipCue",d=e.phase==="flipCue"||e.phase==="reaskRecto"||e.phase==="framing";return{...l,restPhase:s,current:u,phase:d?s:e.phase}}n(_e,"Ze");function Qe(e,t){let r=t.id??e.captured[t.side],i={...e.captured};(t.id===void 0||i[t.side]===t.id)&&delete i[t.side];let l=e.pending.filter(v=>v!==r),u=e.layout==="twoSided"&&oe({captured:i,pending:l})>0,s=e.lastShotByTimeout||r===e.lastShot!==e.flipped,d=u&&!s,c=d?t.side==="recto"?"reaskRecto":"flipCue":"framing";return{...e,captured:i,pending:l,readSides:e.readSides.filter(v=>v!==t.side),lastShot:e.lastShot===r?void 0:e.lastShot,notice:t.issue,goodSince:void 0,manualShutter:!1,phase:c,restPhase:c,current:t.side,needFlip:d,flipped:!1,flipTimeoutSpent:!1,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1}}n(Qe,"et");function Ye(e,t){switch(t.type){case"report":return je(re(e,t.at),t.report,t.at);case"tick":return He(re(e,t.at),t.at);case"captured":return Ge(re(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 _e(e,t.id,t.side);case"duplicate":return Le(e,t.id,t.side);case"readOk":{let r=e.readSides.includes(t.side)?e.readSides:[...e.readSides,t.side],i=["recto","verso"].filter(u=>e.captured[u]!==void 0),l=e.phase==="reading"&&e.pending.length===0&&i.every(u=>r.includes(u));return{...e,readSides:r,flipTimeoutSpent:!1,phase:l?"result":e.phase}}case"readFailed":return Qe(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{...Ce(e.layout,-1),lastCaptureAt:-1,lastReportAt:-1};default:return e}}n(Ye,"Te");function Je(e,t,r=!1){let i=e(t);return i===null?"recto":!r||i.y+i.height/2>=t.height/2?"verso":"recto"}n(Je,"tt");async function $e(e,t=!1){let{detectMrzBand:r}=await import("./mrz-band-VYHOTDHY-VEZ2J5IL.js");return Je(r,e,t)}n($e,"nt");async function be(e,t=480,r,i=r!=null){let l=r??{x:0,y:0,width:e.width,height:e.height},u=Math.max(1,Math.round(l.height/l.width*t)),s=document.createElement("canvas");s.width=t,s.height=u;try{let d=s.getContext("2d");return d===null?"recto":(d.drawImage(e,l.x,l.y,l.width,l.height,0,0,t,u),await $e(d.getImageData(0,0,t,u),i))}finally{s.width=0,s.height=0}}n(be,"oe");var ae=n((e,t,r)=>Math.min(r,Math.max(t,Math.round(e))),"ae"),J=n(e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4,"Y");async function Ke(e,t,r,i){let l=i.decode??(c=>createImageBitmap(c)),u=n(async()=>e.stillRead(await l(t),i.region??[0,0,1,1],i.detectorLimit),"c"),s;try{s=await u()}catch{try{await new Promise(c=>setTimeout(c,i.retryMs??300)),s=await u()}catch{return null}}let d=s.mrzBox;return d===void 0?null:{engine:i.engine,source:"live_mrz",format:r.format,lineCount:ae(r.lineCount,2,3),checkDigitsValid:!0,stillConfirmed:s.valid&&s.digest===r.digest,band:[J(d[0]),J(d[1]),J(Math.min(d[2],1-d[0])),J(Math.min(d[3],1-d[1]))],digest:r.digest,framesToValid:ae(r.framesToValid,1,1e3),msToValid:ae(r.msToValid,0,12e4)}}n(Ke,"_e");var Ze=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]),Xe=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 et(e,t=globalThis){let r=t.WebAssembly?.validate;if(typeof r!="function")return{ok:!1,reason:"simd"};try{if(!r.call(t.WebAssembly,Ze)||!r.call(t.WebAssembly,Xe))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 i=t.navigator?.deviceMemory;return typeof i=="number"&&i<e.minDeviceMemoryGb?{ok:!1,reason:"memory"}:{ok:!0}}n(et,"Ee");function tt(e=globalThis){let t=e.navigator?.connection;return t?.saveData===!0||["slow-2g","2g","3g"].includes(t?.effectiveType??"")}n(tt,"Oe");var U,E=(U=class extends Error{constructor(t){super(t),this.name="OcrEngineError",this.code=t}},n(U,"_"),U);function ke(){let e=n(t=>(t.close(),Promise.reject(new E("unsupported"))),"e");return{ready:Promise.resolve("unsupported"),busy:!1,bandRead:e,stillRead:e,layoutRead:e,dispose:n(()=>{},"dispose")}}n(ke,"Pe");function rt(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 ke()}catch{return ke()}let r=new Map,i=0,l=!1,u=!1,s=!1;t.addEventListener("message",m=>{let h=m.data,S=r.get(h.id);S&&(r.delete(h.id),S.resolve(h))});let d=n(()=>{for(let m of r.values())m.reject(new E("error"));r.clear(),v()},"u");t.addEventListener("error",d),t.addEventListener("messageerror",d);function c(m,h=[]){if(l)return Promise.reject(new E("disposed"));let S=++i;return new Promise((W,F)=>{r.set(S,{resolve:W,reject:F});try{t.postMessage({...m,id:S},h)}catch{r.delete(S),F(new E("error"))}})}n(c,"l");function v(){if(!l){l=!0;try{t.postMessage({id:++i,kind:"dispose"})}catch{}t.terminate();for(let m of r.values())m.reject(new E("disposed"));r.clear()}}n(v,"f");let f=(async()=>{let m=await c({kind:"init",baseUrl:e.baseUrl,salt:e.salt,detectorLimit:e.tuning.detectorLimit,maxDownloadMs:e.tuning.maxDownloadMs});if(m.kind==="failed")return m.reason;if(m.kind!=="ready")return"error";let h=await c({kind:"warmup"});return h.kind!=="ready"?"error":{warmupMs:h.warmupMs,downloadMs:m.downloadMs,cached:m.cached}})().catch(()=>"error"),y,M=new Promise(m=>{y=setTimeout(()=>m("timeout"),e.tuning.loadTimeoutMs)}),q=Promise.race([f,M]).then(m=>(clearTimeout(y),typeof m=="string"?v():s=!0,l&&typeof m!="string"?"error":m));(e.page===void 0?globalThis.addEventListener?globalThis:null:e.page)?.addEventListener("pagehide",v,{once:!0});async function g(m,h,S){if(l)throw h.close(),new E("disposed");if(!s)throw h.close(),new E("not_ready");if(u)throw h.close(),new E("busy");u=!0;let W;try{let F=new Promise((j,N)=>{W=setTimeout(()=>{N(new E("timeout")),v()},e.tuning.readTimeoutMs??1e4)}),P=await Promise.race([c(m,[h]),F]);if(P.kind===S){let{id:j,...N}=P;return N}throw new E(P.kind==="error"?P.code:P.kind==="failed"?P.reason:"error")}finally{clearTimeout(W),u=!1}}return n(g,"w"),{ready:q,get busy(){return u},bandRead:n((m,h=e.tuning.detectorLimit)=>g({kind:"band",bitmap:m,detectorLimit:h},m,"band"),"bandRead"),stillRead:n((m,h,S=e.tuning.detectorLimit)=>g({kind:"still",bitmap:m,region:h,detectorLimit:S},m,"band"),"stillRead"),layoutRead:n((m,h)=>g({kind:"layout",bitmap:m,detectorLimit:h},m,"layout"),"layoutRead"),dispose:v}}n(rt,"Ae");var $="sekyro-ocr-1",ie=n(e=>e!==null&&typeof e=="object"?e:{},"ie"),R=n((e,t,r,i)=>typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=r?e:i,"v"),Se=n((e,t)=>typeof e=="boolean"?e:t,"Be"),xe=n(e=>{let t=typeof e=="string"?/^sekyro-ocr-(\d{1,4})$/.exec(e):null;return t?Number(t[1]):Number.POSITIVE_INFINITY},"Ie");function at(e,t={}){let r=ie(e),i=ie(r.liveMrz),l=ie(r.frontLock),u=xe(t.engine??$),s=t.mode==="off",d=n(h=>h.enabled===!0?h.arm==="live"?"live":"control":null,"u"),c=d(i),v=d(l),f=n((h,S)=>!s&&S==="live"&&xe(h.minEngine??$)<=u,"p"),y=ve,M=f(i,c)?{detectorLimit:R(i.detectorLimit,320,1600,y.detectorLimit),bandMaxWidthPx:R(i.bandMaxWidthPx,320,4096,y.bandMaxWidthPx),minBandWidthPx:R(i.minBandWidthPx,0,4096,y.minBandWidthPx),bandTop:R(i.bandTop,0,.95,y.bandTop),minIntervalMs:R(i.minIntervalMs,0,5e3,y.minIntervalMs),stableReads:Math.round(R(i.stableReads,1,10,y.stableReads)),profileReads:Math.round(R(i.profileReads,1,100,y.profileReads)),maxReadMs:R(i.maxReadMs,50,6e4,y.maxReadMs),searchTimeoutMs:R(i.searchTimeoutMs,1e3,12e4,y.searchTimeoutMs),hint:Se(i.hint,!0),stillConfirm:Se(i.stillConfirm,!0)}:null,q=ge,g=n((h,S,W)=>R(l[h],S,W,q[h]),"h"),m=f(l,v)?{minLines:Math.round(g("minLines",1,50)),fillMin:g("fillMin",0,1),fillMax:g("fillMax",0,2),offsetMax:g("offsetMax",0,1),steadyFillDelta:g("steadyFillDelta",0,1),steadyOffsetDelta:g("steadyOffsetDelta",0,1),layoutShiftMax:g("layoutShiftMax",0,1),lineCountDelta:Math.round(g("lineCountDelta",0,50)),lockMs:g("lockMs",0,3e4),steadyMs:g("steadyMs",0,3e4),minFrames:Math.round(g("minFrames",1,100)),minIntervalMs:g("minIntervalMs",0,5e3),maxWidthPx:g("maxWidthPx",160,2048),detectorLimit:g("detectorLimit",320,1600),searchTimeoutMs:g("searchTimeoutMs",1e3,12e4)}:null;return{enabled:M!==null||m!==null,liveMrz:M,textLock:m,liveMrzArm:c,frontLockArm:v,load:{detectorLimit:M?.detectorLimit??m?.detectorLimit??y.detectorLimit,loadTimeoutMs:R(i.loadTimeoutMs,1e3,12e4,2e4),maxDownloadMs:R(i.maxDownloadMs,1e3,12e4,2e4),minDeviceMemoryGb:R(i.minDeviceMemoryGb,0,64,2)},reportSampleRate:R(i.reportSampleRate,0,1,1)}}n(at,"We");function it(e,t){return e.enabled?!(t.probe??et)({minDeviceMemoryGb:e.load.minDeviceMemoryGb}).ok||(t.slow??tt)()?{ok:!1,reason:"unsupported"}:{ok:!0,engine:rt({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"}}n(it,"Fe");function nt(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"}n(nt,"at");var z=n(e=>e===void 0||!Number.isFinite(e)?void 0:Math.min(6e5,Math.max(0,Math.round(e))),"W"),ne=n((e,t,r)=>e===void 0||!Number.isFinite(e)?void 0:Math.min(r,Math.max(t,Math.round(e))),"se");function ot(e){let t=e.assist??null,r=e.load!==null&&e.load!==void 0&&typeof e.load=="object"?e.load:null,i=typeof e.load=="string"?e.load:null,l=t!==null?t.outcome:i==="unsupported"||i==="download"||i==="integrity"?i:i==="error"||i==="timeout"?"error":"off",u={kind:"live_mrz",platform:"web",engine:e.engine??$,arm:e.arm,capture:e.capture,outcome:l,reads:ne(t?.reads??0,0,1e4)??0,browser:e.browser??nt()},s=n((d,c)=>{c!==void 0&&(u[d]=c)},"s");return s("format",t?.format),s("framesToValid",ne(t?.framesToValid,1,1e4)),s("msToValid",z(t?.msToValid)),s("framesToLock",ne(t?.framesToLock,1,1e4)),s("msToLock",z(t?.msToLock)),s("msToCapture",z(e.msToCapture)),s("readP50Ms",z(t?.readP50Ms)),s("readP90Ms",z(t?.readP90Ms)),s("deviceClass",t?.deviceClass),r!==null&&(s("warmupMs",z(r.warmupMs)),s("downloadMs",z(r.downloadMs)),s("cached",r.cached)),s("stillConfirmed",e.stillConfirmed),s("typeMismatch",e.typeMismatch),u}n(ot,"ze");function Te(e,t){return e===void 0?!1:t==="passport"?e!=="TD3":e==="TD3"}n(Te,"ue");var lt=2;async function st(e){let t=await import("./capture-session-doc-FRBI7OKF-AIBTLOVK.js");return new t.CaptureSessionDoc(e)}n(st,"st");function dt(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}}}n(dt,"ut");function ut(e,t,r){let i=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft],l=0;for(let u=0;u<i.length;u+=1){let s=i[u],d=i[(u+1)%i.length];l+=s.x*d.y-d.x*s.y}return t>0&&r>0?Math.abs(l)/2/(t*r):0}n(ut,"ct");function vt(){import("./capture-session-doc-FRBI7OKF-AIBTLOVK.js").then(e=>e.warmDocDetector()).catch(()=>{})}n(vt,"Ht");function yt(e){return ct(e,{}).handle}n(yt,"Xt");function ct(e,t){let r=me(),i=he({enabled:e.keepScreenAwake!==!1}),l=t.decode??(a=>createImageBitmap(a)),u=t.blurRefuseSharpnessMax??.16,s=t.now??(()=>performance.now()),d=e.documentType==="passport"||e.side==="single",c=Ce(d?"singlePage":"twoSided",s());if(!d&&(e.side==="recto"||e.side==="verso")){let a=e.side==="recto"?"verso":"recto";c={...c,captured:{[a]:"server"},readSides:[a],current:e.side,phase:"flipCue",restPhase:"flipCue"}}let v="idle",f=null,y=null,M=!0,q=0,g=0,m=!1,h=!1,S="",W=null,F,P=null,j=[],N=we.find(a=>a.docType===e.documentType)?.mrz==="none",x=t.webOcr!==void 0&&!N?at(t.webOcr.captureDocument,{mode:e.liveMrz?.mode??"auto"}):null,V=null,I=x===null||!x.enabled?"off":null,H=null,G=null,le=new WeakMap,K="";if(x!==null&&x.enabled&&t.webOcr!==void 0){let a=t.webOcr,o=it(x,{baseUrl:e.liveMrz?.assetBaseUrl??a.baseUrl,salt:a.salt,...e.liveMrz?.workerUrl!==void 0?{workerUrl:e.liveMrz.workerUrl}:{},...a.createWorker!==void 0?{createWorker:a.createWorker}:{}});if(o.ok){V=o.engine;let p=new ye({textLock:x.textLock,liveMrz:x.liveMrz});H=p;let w=o.engine;w.ready.then(A=>{I=A,typeof A!="string"&&M&&p.setEngine(w)})}else I=o.reason}let O=n(a=>{let o=JSON.stringify(a);o!==K&&(K=o,r.emit("mrz",a))},"z"),se=n((a,o)=>{let p=t.webOcr?.reports;if(p===void 0||x===null||a===void 0)return;let w=a.format==="ID-3"||a.side==="single"?"single":a.side==="verso"?"verso":"recto",A=w!=="recto"?x.liveMrzArm??x.frontLockArm:x.frontLockArm;if(A===null||Math.random()>=x.reportSampleRate)return;let L=a.via==="live_mrz"?G:null,C=n(()=>{let D=L?.value??null;p([ot({arm:A,capture:w,assist:a.ocr??null,load:A==="control"?"off":I,...a.msToCapture!==void 0?{msToCapture:a.msToCapture}:{},...D!==null&&D.stillConfirmed!==void 0?{stillConfirmed:D.stillConfirmed}:{},...o!==void 0?{typeMismatch:Te(o.format,e.documentType==="passport"?"passport":"card")}:{}})])},"x");L!==null&&L.value===null?Promise.race([L.promise,new Promise(D=>setTimeout(D,3e3))]).then(C):C()},"le"),B=n(a=>{!M||a===v||(v=a,i.setActive(a==="starting"||a==="scanning"),r.emit("state",a))},"I"),Pe=n((a,o)=>o===void 0?null:d?"single":a.captured.recto===o?"recto":a.captured.verso===o?"verso":null,"Ne"),De=n(a=>({phase:a.phase,captured:d?a.captured.recto!==void 0?["single"]:[]:["recto","verso"].filter(o=>a.captured[o]!==void 0),expected:d?null:a.current??null,notice:a.notice??null,lastShot:Pe(a,a.lastShot),manualShutter:a.manualShutter,torchAvailable:f?.torchAvailable()??!1,torch:h}),"Ue"),de=n(()=>{let a=f;a!==null&&a.captureNow().catch(()=>T({type:"captureFailed",at:s()}))},"de");function T(a){if(!M)return;let o=c;c=Ye(c,a),c.phase==="capturing"&&o.phase!=="capturing"&&Promise.resolve().then(de),c.phase==="result"&&o.phase!=="result"&&(B("done"),ue());let p=De(c),w=JSON.stringify(p);w!==S&&(S=w,r.emit("scan",p))}n(T,"R");function ue(){P!==null&&clearInterval(P),P=null;for(let a of j.splice(0))a();f?.destroy(),f=null,i.setActive(!1)}n(ue,"me");let ce=n(()=>f?.captureReport?.(),"pe"),Z=!1,pe=n((a,o)=>{if(!(a===void 0||t.onFaceReport===void 0))try{t.onFaceReport(a,o)}catch{}},"fe"),_=n(a=>{K="",!(f===null||c.phase==="reading"||c.phase==="result")&&(Z=!1,f.rearm(d?"single":c.current??a))},"H"),Ee=n(async(a,o,p,w)=>{if(G=null,w!==void 0&&V!==null&&x?.liveMrz?.hint===!0){let b={promise:Ke(V,a,w,{engine:$,detectorLimit:x.liveMrz.detectorLimit}).catch(()=>null),value:null};b.promise.then(k=>{b.value=k}),G=b}w!==void 0&&Te(w.format,e.documentType==="passport"?"passport":"card")&&O({state:"mismatch",format:w.format});let A=ce();pe(A,"captured"),Z=!0,se(A,w);let L=p===void 0?W:p===null?null:{quad:dt(p),frameWidth:0,frameHeight:0,inStill:!0},C={decoded:null},D=n(()=>(C.decoded??(C.decoded=Promise.resolve().then(()=>l(a)).catch(()=>null)),C.decoded),"E");try{await We(a,o,L,D,G)}finally{C.decoded!==null&&(await C.decoded)?.close()}},"Ge"),We=n(async(a,o,p,w,A)=>{let L=`shot-${q+=1}`;if(T({type:"captured",id:L,at:s()}),e.haptics!==!1)try{globalThis.navigator?.vibrate?.(30)}catch{}if(!m&&u>0){let b=await(t.measureSharpness!==void 0?t.measureSharpness(a,p):w().then(k=>k===null?-1:fe(k,te(p?.quad??null,p?.inStill===!0?k:{width:p?.frameWidth??0,height:p?.frameHeight??0},k)))).catch(()=>-1);if(!M)return;if(Number.isFinite(b)&&b>=0&&b<u){m=!0;let k=d?"recto":c.current??(c.captured.recto===void 0?"recto":"verso");T({type:"readFailed",side:k,id:L,issue:"blurry"}),_(k);return}}m=!1;let C;if(d)C="single";else{let b=c.current,k=await(t.classify!==void 0?t.classify(a):w().then(Q=>Q===null?b??"recto":p?.inStill===!0?be(Q,480,null,!0):be(Q,480,te(p?.quad??null,{width:p?.frameWidth??0,height:p?.frameHeight??0},Q)))).catch(()=>b??"recto");if(!M)return;if(c.captured[k]!==void 0&&g<lt){g+=1,T({type:"duplicate",id:L,side:k}),_(k==="recto"?"verso":"recto");return}C=c.captured[k]!==void 0&&b!==void 0?b:k,g=0,T({type:"classified",id:L,side:C})}let D=C==="verso"?"verso":"recto";try{let b=t.encode!==void 0?await t.encode(a):await w().then(k=>{if(k===null)throw new Error("the still could not be decoded");return Ve(k)});if(!M)return;A!==null&&le.set(b.blob,A),r.emit("captured",{image:b.blob,side:C,documentType:e.documentType,...e.issuer!==void 0?{issuer:e.issuer}:{},width:b.width,height:b.height,previewDataUrl:o}),t.deferRead!==!0&&T({type:"readOk",side:D})}catch(b){T({type:"readFailed",side:D,id:L,issue:"technical"}),r.emit("error",Y("generic",!0,{phase:"keyframes",name:ee(b)}))}_(D==="recto"?"verso":"recto")},"qe"),Fe=n(a=>{j.push(a.on("statechange",({state:o})=>{o==="preflight"||o==="acquiring"?B("starting"):o==="positioning"?B("scanning"):o==="captured"?B("captured"):o==="error"&&B("error")}),a.on("feedback",({key:o,reticle:p})=>r.emit("feedback",{key:o,reticle:p})),a.on("checks",o=>{r.emit("gate",{progress:o.p,quad:o.quad,frameWidth:o.frameWidth,frameHeight:o.frameHeight,...o.guide!==void 0?{guide:{detected:o.guide.detected,fill:o.guide.fill,offsetX:o.guide.offsetX??0,offsetY:o.guide.offsetY??0}}:{}});let p=o.ocr?.mrz;p!==void 0&&(p.state==="fallback"?O({state:"fallback",reason:p.reason}):p.state==="valid"?O({state:"valid",format:p.format}):p.state==="reading"?O({state:"reading",...p.format?{format:p.format}:{},...p.coach?{coach:p.coach}:{}}):O({state:"searching"}));let w=o.quad===null?0:ut(o.quad,o.frameWidth,o.frameHeight);W=o.quad===null?null:{quad:o.quad,frameWidth:o.frameWidth,frameHeight:o.frameHeight},T({type:"report",report:{present:o.quad!==null&&o.plausible||o.guide?.detected===!0,ready:o.ready===!0,locking:o.p>=.5,areaFrac:w},at:s()})}),a.on("error",({kind:o,retryable:p,detail:w})=>r.emit("error",Y(o,p,w))),a.on("artifacts",o=>{Ee(o.keyframe,o.previewDataUrl,o.docRegion,o.liveMrz)}))},"He"),X=n(()=>(y??(y=(async()=>{if(M){if(f===null){let a;try{a=await(t.createEngine??st)({...t.engineOptions??{},...F!==void 0?{guide:F}:{},video:e.video,format:Me(e.documentType),side:d?"single":e.side??"recto",autoCapture:!1,...H!==null?{ocr:H}:{}})}catch(p){B("error"),r.emit("error",Y("models",!0,{phase:"models",name:ee(p)}));return}if(!M){a.destroy();return}f=a,Fe(a);let o=t.tickMs??500;o>0&&(P=setInterval(()=>T({type:"tick",at:s()}),o))}T({type:"clockRestart"}),x!==null&&x.liveMrzArm==="live"&&(I==="unsupported"||I==="off")&&O({state:"fallback",reason:I}),await f.start()}})().finally(()=>{y=null})),y),"$");return{handle:{get state(){return v},on:n((a,o)=>r.on(a,o),"on"),start:X,retry:n(()=>{if(f===null&&c.phase==="result"){T({type:"retake"}),g=0,m=!1,X();return}if(f!==null&&v!=="error"){T({type:"retake"}),g=0,m=!1,f.rearm(d?"single":void 0);return}X()},"retry"),setSide:n(a=>{d||a==="single"||(c.current!==a&&(c={...c,current:a}),T({type:"clockRestart"}),c.phase!=="reading"&&c.phase!=="result"&&f?.rearm(a))},"setSide"),shutter:de,focusAt:n((a,o)=>{f?.focusAt?.(a,o)},"focusAt"),setGuide:n(a=>{F=a,f?.setGuide?.(a)},"setGuide"),setTorch:n(a=>{h=a,f?.setTorch(a),T({type:"tick",at:s()})},"setTorch"),destroy:n(()=>{if(M&&f!==null&&v!=="done"){let a=ce();!Z&&a!==void 0&&a.ticks>0&&pe(a,"abandoned"),se(a,void 0)}M=!1,ue(),H?.setEngine(null),V?.dispose(),V=null,r.clear()},"destroy")},setFlowState:n(a=>{(c.phase==="reading"||c.phase==="result")&&B(a==="done"&&c.phase!=="result"?"scanning":a)},"setFlowState"),settle:n((a,o)=>{let p=a==="verso"?"verso":"recto";T(o.ok?{type:"readOk",side:p}:{type:"readFailed",side:p,issue:o.issue}),o.ok||_(p)},"settle"),takeDeviceRead:n(a=>le.get(a.image)?.value??null,"takeDeviceRead")}}n(ct,"lt");export{lt as a,vt as b,yt as c,ct as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as v}from"./chunk-
|
|
1
|
+
import{d as v}from"./chunk-HMNCXTZQ.js";import{a as y,b as C}from"./chunk-SIPFHN7E.js";import{a as d}from"./chunk-5QL6W6FW.js";import{a,c as p}from"./chunk-4FHWXBOB.js";var r=p(y(),1),o=p(C(),1),m=p(y(),1);function w(t,e,i){let[n,c]=(0,r.useState)(!1),s=(0,r.useRef)(i);return s.current=i,(0,r.useEffect)(()=>{t&&(c(!0),s.current())},[t,e]),[n,()=>c(!1)]}a(w,"I");d(w,"useWrongCode");function x({id:t,value:e,onChange:i,length:n=6,describedBy:c,invalid:s}){let[k,f]=(0,r.useState)(!1),[h,N]=(0,r.useState)(0);(0,r.useEffect)(()=>{s&&N(l=>l+1)},[s]);let g=(0,r.useRef)(null);(0,r.useEffect)(()=>{let l=setTimeout(()=>g.current?.focus({preventScroll:!0}),350);return()=>clearTimeout(l)},[]);let b=e.length<n?e.length:-1;return(0,o.jsxs)("div",{className:"sekyro-otp-boxes",dir:"ltr",children:[(0,o.jsx)("div",{className:`sekyro-otp-row${h>0?" is-shaking":""}`,"aria-hidden":"true",children:Array.from({length:n},(l,u)=>(0,o.jsx)("span",{className:`sekyro-otp-box${u<e.length?" is-filled":""}${k&&u===b?" is-current":""}${s?" is-invalid":""}`,children:e[u]!==void 0?(0,o.jsx)("span",{className:"sekyro-otp-digit",children:e[u]},e[u]):null},u))},h),(0,o.jsx)("input",{ref:g,id:t,className:"sekyro-input sekyro-input--code",dir:"ltr",inputMode:"numeric",autoComplete:"one-time-code",value:e,"aria-describedby":c,"aria-invalid":s||void 0,onFocus:a(()=>f(!0),"onFocus"),onBlur:a(()=>f(!1),"onBlur"),onChange:a(l=>i(v(l.target.value).replace(/\D/g,"").slice(0,n)),"onChange")})]})}a(x,"S");d(x,"CodeInput");function I(t){let[e,i]=(0,m.useState)(()=>Date.now());return(0,m.useEffect)(()=>{if(!t)return;let n=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(n)},[t]),e}a(I,"B");d(I,"useNow");export{w as a,x as b,I as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as g}from"./chunk-LA2MA2UQ.js";import{K as b,a as k,b as y,c as x}from"./chunk-SIPFHN7E.js";import{a as n}from"./chunk-5QL6W6FW.js";import{a as c,c as f}from"./chunk-4FHWXBOB.js";var l=f(k(),1),t=f(k(),1),w=f(k(),1),r=f(y(),1),e=f(y(),1);var i,C=(i=class extends w.Component{constructor(){super(...arguments),this.state={failed:!1}}static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?this.props.fallback:this.props.children}},c(i,"c"),i);n(C,"LoadBoundary");var j=C,F={load:n(()=>import("./flow-views-N7LBFI55-
|
|
1
|
+
import{a as g}from"./chunk-LA2MA2UQ.js";import{K as b,a as k,b as y,c as x}from"./chunk-SIPFHN7E.js";import{a as n}from"./chunk-5QL6W6FW.js";import{a as c,c as f}from"./chunk-4FHWXBOB.js";var l=f(k(),1),t=f(k(),1),w=f(k(),1),r=f(y(),1),e=f(y(),1);var i,C=(i=class extends w.Component{constructor(){super(...arguments),this.state={failed:!1}}static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?this.props.fallback:this.props.children}},c(i,"c"),i);n(C,"LoadBoundary");var j=C,F={load:n(()=>import("./flow-views-N7LBFI55-36234BJJ.js"),"load")};function S({view:s,i18n:a,quiet:o,...m}){let[d,h]=(0,t.useState)(0),u=(0,t.useMemo)(()=>(0,t.lazy)(()=>F.load().then(v=>({default:v[s]}))),[s,d]),p=(0,r.jsxs)(b,{tone:"danger",children:[(0,r.jsx)("span",{children:a.t("errors.network_error")}),(0,r.jsx)(x,{kind:"secondary",onClick:c(()=>h(v=>v+1),"onClick"),children:a.t("common.retry")})]});return(0,r.jsx)(j,{fallback:p,children:(0,r.jsx)(t.Suspense,{fallback:o===!0?null:(0,r.jsx)("p",{role:"status","aria-busy":"true",className:"sekyro-text-muted",children:a.t("common.loading")}),children:(0,r.jsx)(u,{...m,i18n:a})})},d)}c(S,"k");n(S,"Flow");var B=(0,l.createContext)(void 0);function H({i18n:s,lead:a,refresh:o,actions:m}){let d=(0,l.useContext)(B),[h,u]=(0,l.useState)(!1);if(d!==void 0)return(0,e.jsx)(S,{view:"HandoffView",i18n:s,url:d,lead:a,...o!==void 0?{refresh:o}:{},footer:m});let p=n(()=>{o!==void 0&&(u(!0),o().catch(()=>{}).finally(()=>u(!1)))},"again");return(0,e.jsx)(g,{tone:"brand",icon:"smartphone",title:s.t("handoff.title"),testId:"sekyro-phone-handoff",actions:(0,e.jsxs)(e.Fragment,{children:[m,o!==void 0?(0,e.jsx)(x,{kind:"secondary",full:!0,disabled:h,onClick:p,children:s.t("common.refresh")}):null]}),children:(0,e.jsx)("p",{children:a})})}c(H,"K");n(H,"PhoneHandoff");export{j as a,S as b,B as c,H as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as t,b as r,c as m,d as o}from"./chunk-
|
|
1
|
+
import{a as t,b as r,c as m,d as o}from"./chunk-RPCMWL2U.js";import"./chunk-2FETDQV5.js";import"./chunk-EWTKC2C2.js";import"./chunk-H5GXVL63.js";import"./chunk-GIGTK355.js";import"./chunk-P7K7ELYZ.js";import"./chunk-CW56KMMH.js";import"./chunk-JS2IXPNL.js";import"./chunk-4FHWXBOB.js";export{t as SAME_FACE_MAX_DROPS,m as createDocumentCapture,o as createDocumentCaptureInternal,r as warmDocumentCapture};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{a as Ge}from"./chunk-H22YHQ6V.js";import{a as Oe,b as Ee,c as Ve}from"./chunk-5K4YQOZN.js";import{a as Be}from"./chunk-YRTHQZAW.js";import"./chunk-QOZB3DLY.js";import{d as Ie}from"./chunk-FV4TIWHC.js";import"./chunk-LA2MA2UQ.js";import{E as De,F as Ae,G as Re,I as Ue,K as pe,L as me,a as ct,b as dt,c as E,o as He,q as Pe,v as Y,w as ue,y as he}from"./chunk-SIPFHN7E.js";import{a as h}from"./chunk-5QL6W6FW.js";import{a as c,c as Me}from"./chunk-4FHWXBOB.js";var i=Me(ct(),1),e=Me(dt(),1);var ut={image:'<path d="M2 12C2 7.29 2 4.93 3.46 3.46C4.93 2 7.29 2 12 2C16.71 2 19.07 2 20.54 3.46C22 4.93 22 7.29 22 12C22 16.71 22 19.07 20.54 20.54C19.07 22 16.71 22 12 22C7.29 22 4.93 22 3.46 20.54C2 19.07 2 16.71 2 12Z" stroke="currentColor"/><path d="M14 8A2 2 0 1 0 18 8A2 2 0 1 0 14 8Z" stroke="currentColor"/><path d="M2 12.5L3.75 10.97C4.66 10.17 6.04 10.22 6.89 11.07L11.18 15.36C11.87 16.05 12.95 16.14 13.75 15.58L14.04 15.37C15.19 14.57 16.74 14.66 17.78 15.6L21 18.5" stroke="currentColor" stroke-linecap="round"/>',flashlight:'<path d="M9 11.66V19C9 19.93 9 20.4 9.15 20.77C9.36 21.26 9.74 21.64 10.23 21.85C10.6 22 11.07 22 12 22C12.93 22 13.4 22 13.77 21.85C14.26 21.64 14.64 21.26 14.85 20.77C15 20.4 15 19.93 15 19V11.66C15 10.84 15 10.43 15.15 10.06C15.3 9.7 15.59 9.41 16.17 8.83L16.17 8.83L19.41 5.59C19.7 5.3 19.85 5.15 19.92 4.97C20 4.78 20 4.58 20 4.17V4C20 3.06 20 2.59 19.71 2.29C19.41 2 18.94 2 18 2H6C5.06 2 4.59 2 4.29 2.29C4 2.59 4 3.06 4 4V4.17C4 4.58 4 4.78 4.08 4.97C4.15 5.15 4.3 5.3 4.59 5.59L7.83 8.83C8.41 9.41 8.7 9.7 8.85 10.06C9 10.43 9 10.84 9 11.66Z" stroke="currentColor" stroke-linecap="round"/><path d="M15 10H9" stroke="currentColor" stroke-linecap="round"/><path d="M12 13V15" stroke="currentColor" stroke-linecap="round"/><path d="M4.5 5H19.5" stroke="currentColor" stroke-linecap="round"/>'},ht={"dcv3.mrz.searching":"ضع صفحة جواز السفر كاملة داخل الإطار","dcv3.mrz.showMrzSide":"اعرض الوجه الذي يحتوي على سطرين أو ثلاثة أسطر من الحروف","dcv3.mrz.reading":"جارٍ قراءة الوثيقة… ثبّتها","dcv3.mrz.moveCloser":"اقترب حتى تملأ أسطر الحروف الإطار","dcv3.mrz.turnSideways":"أدر هاتفك أفقيًا لقراءة أسطر الحروف","dcv3.mrz.glare":"أمِل الوثيقة لإزالة الانعكاس","dcv3.mrz.holdStill":"لا تتحرك","dcv3.mrz.valid":"تمت قراءة الوثيقة. جارٍ التقاط الصورة","dcv3.mrz.looksLikePassport":"يبدو أن هذا جواز سفر","dcv3.mrz.looksLikeCard":"يبدو أن هذه بطاقة تعريف أو بطاقة إقامة"},ee={"dcv3.mrz.searching":"Fit the whole passport page in the frame","dcv3.mrz.showMrzSide":"Show the side with the two or three lines of characters","dcv3.mrz.reading":"Reading the document… hold it steady","dcv3.mrz.moveCloser":"Move closer so the lines of characters fill the frame","dcv3.mrz.turnSideways":"Turn your phone sideways to read the lines of characters","dcv3.mrz.glare":"Tilt the document to remove the reflection","dcv3.mrz.holdStill":"Hold still","dcv3.mrz.valid":"Document read. Taking the photo","dcv3.mrz.looksLikePassport":"This looks like a passport","dcv3.mrz.looksLikeCard":"This looks like an identity card or residence permit"},pt={"dcv3.mrz.searching":"Cadrez toute la page du passeport","dcv3.mrz.showMrzSide":"Montrez la face avec les deux ou trois lignes de caractères","dcv3.mrz.reading":"Lecture du document… tenez-le immobile","dcv3.mrz.moveCloser":"Rapprochez-vous pour que les lignes de caractères remplissent le cadre","dcv3.mrz.turnSideways":"Tournez votre téléphone à l’horizontale pour lire les lignes de caractères","dcv3.mrz.glare":"Inclinez le document pour supprimer le reflet","dcv3.mrz.holdStill":"Ne bougez plus","dcv3.mrz.valid":"Document lu. Prise de la photo","dcv3.mrz.looksLikePassport":"Ceci ressemble à un passeport","dcv3.mrz.looksLikeCard":"Ceci ressemble à une carte d’identité ou un titre de séjour"},mt={"doc.uploadInstead":"رفع صورة بدلًا من ذلك","doc.uploadTitle":"ارفع صورة لوثيقتك","doc.uploadHint":"صورة واضحة للوثيقة كاملة، ملتقطة بكاميرا.","doc.uploadUnsupported":"اختر صورة للوثيقة بصيغة JPEG أو PNG أو HEIC.","doc.uploadFailed":"تعذّر إرسال هذه الصورة. أعد المحاولة.","doc.source.title":"كيف تريد إضافة وثيقتك؟","doc.source.description":"التقط صورة بالكاميرا، أو ارفع صورة للوثيقة من هذا الجهاز.","doc.source.camera":"التقاط صورة","doc.source.upload":"رفع صورة"},te={"doc.uploadInstead":"Upload a photo instead","doc.uploadTitle":"Upload a photo of your document","doc.uploadHint":"A clear photo of the whole document, taken with a camera.","doc.uploadUnsupported":"Choose a JPEG, PNG or HEIC photo of the document.","doc.uploadFailed":"We could not send this photo. Try again.","doc.source.title":"How do you want to add your document?","doc.source.description":"Take a photo with the camera, or upload a photo of the document from this device.","doc.source.camera":"Take a photo","doc.source.upload":"Upload a photo"},vt={"doc.uploadInstead":"Téléverser une photo à la place","doc.uploadTitle":"Téléversez une photo de votre document","doc.uploadHint":"Une photo nette du document entier, prise avec un appareil photo.","doc.uploadUnsupported":"Choisissez une photo JPEG, PNG ou HEIC du document.","doc.uploadFailed":"Nous n'avons pas pu envoyer cette photo. Réessayez.","doc.source.title":"Comment voulez-vous ajouter votre document ?","doc.source.description":"Prenez une photo avec la caméra, ou importez une photo du document depuis cet appareil.","doc.source.camera":"Prendre une photo","doc.source.upload":"Importer une photo"},ft={"native.doc.introTitle":"سنلتقط صورة لوثيقتك","native.doc.introLead":"ستُفتح كاميرا هاتفك، وتُلتقط الصورة تلقائيًا بمجرد أن تكون الوثيقة داخل الإطار.","native.doc.tip.flat":"ضع الوثيقة مسطحة على سطح داكن.","native.doc.tip.glare":"تجنّب انعكاسات المصابيح أو الشمس.","native.doc.tip.frame":"أبقِ الوثيقة كاملة داخل الإطار.","native.doc.openCamera":"افتح الكاميرا","native.doc.changeDocument":"تغيير الوثيقة","native.scan.closer":"اقترب قليلًا","native.scan.farther":"ابتعد قليلًا","native.scan.glare":"أمِل البطاقة قليلًا","native.scan.dark":"الإضاءة ضعيفة. شغّل المصباح.","native.scan.blurry":"الصورة غير واضحة. ثبّت الهاتف.","native.scan.holdStill":"لا تتحرك","native.scan.reading":"جارٍ التحقق من وثيقتك…","native.scan.putDown":"يمكنك وضع وثيقتك جانبًا.","native.scan.retry":"لنحاول مرة أخرى"},ae={"native.doc.introTitle":"Photograph your document","native.doc.introLead":"Your phone's camera will open. The photo is taken by itself as soon as the document is well framed.","native.doc.tip.flat":"Lay the document flat on a dark surface.","native.doc.tip.glare":"Avoid glare from lamps or sunlight.","native.doc.tip.frame":"Keep the whole document in the frame.","native.doc.openCamera":"Open the camera","native.doc.changeDocument":"Change document","native.scan.closer":"Move a little closer","native.scan.farther":"Move back a little","native.scan.glare":"Tilt the card a little","native.scan.dark":"Too dark. Turn on the light.","native.scan.blurry":"Blurry image. Hold the phone still.","native.scan.holdStill":"Hold still","native.scan.reading":"Checking your document…","native.scan.putDown":"You can put your document down.","native.scan.retry":"Let's try that again"},kt={"native.doc.introTitle":"Photographiez votre pièce","native.doc.introLead":"La caméra de votre téléphone va s'ouvrir. La photo est prise automatiquement dès que la pièce est bien cadrée.","native.doc.tip.flat":"Posez la pièce à plat, sur une surface sombre.","native.doc.tip.glare":"Évitez les reflets de lampe ou de soleil.","native.doc.tip.frame":"Gardez toute la pièce dans le cadre.","native.doc.openCamera":"Ouvrir la caméra","native.doc.changeDocument":"Changer de document","native.scan.closer":"Approchez un peu","native.scan.farther":"Reculez un peu","native.scan.glare":"Inclinez un peu la carte","native.scan.dark":"Trop sombre. Allumez la lampe.","native.scan.blurry":"Image floue. Tenez le téléphone immobile.","native.scan.holdStill":"Ne bougez plus","native.scan.reading":"Vérification de votre document…","native.scan.putDown":"Vous pouvez poser votre pièce.","native.scan.retry":"Réessayons"},gt=["locking","capturing"],W,Ye=(W=class{constructor(){this.shown={hint:null,locking:!1,card:null,manualShutter:!1},this.candidate=null,this.candidateSince=0,this.hintShownAt=0,this.lockLostAt=null,this.detectedSince=null,this.lostSince=null,this.shutterSince=null}present(t,n){return this.presentHint(t,n),this.presentLock(t,n),this.presentCard(t,n),this.shutterSince=t.manualShutter?this.shutterSince??n:null,this.shown={...this.shown,manualShutter:this.shutterSince!==null&&n-this.shutterSince>=1e3},this.shown}presentHint(t,n){let o=t.phase==="framing"&&!(t.hint==="blurry"&&t.card===null)?t.hint:null;if(t.phase!=="framing"){this.shown={...this.shown,hint:null},this.candidate=null;return}if(o!==this.candidate&&(this.candidate=o,this.candidateSince=n),o===this.shown.hint)return;let r=n-this.candidateSince>=(o===null?0:350),f=this.shown.hint===null||n-this.hintShownAt>=1200;r&&f&&(this.shown={...this.shown,hint:o},this.hintShownAt=n)}presentLock(t,n){if(gt.includes(t.phase)){this.shown={...this.shown,locking:!0},this.lockLostAt=null;return}if(this.shown.locking){if(t.phase!=="framing"){this.shown={...this.shown,locking:!1},this.lockLostAt=null;return}this.lockLostAt??(this.lockLostAt=n),n-this.lockLostAt>=300&&(this.shown={...this.shown,locking:!1},this.lockLostAt=null)}}presentCard(t,n){let o=t.card;if(o===null||t.phase!=="framing"){if(t.phase!=="framing"){this.shown={...this.shown,card:null},this.detectedSince=null,this.lostSince=null;return}this.detectedSince=null,this.lostSince??(this.lostSince=n),n-this.lostSince>=300&&(this.shown={...this.shown,card:null});return}if(this.lostSince=null,this.detectedSince??(this.detectedSince=n),n-this.detectedSince<250)return;let r=this.shown.card;if(r===null){this.shown={...this.shown,card:{...o}};return}let f=.35;this.shown={...this.shown,card:{fill:r.fill+(o.fill-r.fill)*f,offsetX:r.offsetX+(o.offsetX-r.offsetX)*f,offsetY:r.offsetY+(o.offsetY-r.offsetY)*f}}}},c(W,"fe"),W);h(Ye,"ScanPresenter");var yt=Ye,wt={en:ae,fr:kt,ar:ft,es:ae,pt:ae,de:ae},Ct=450,fe=h(a=>t=>Be(a.strings[t]??wt[a.locale][t]??""),"useScanCopy");function j({name:a}){return(0,e.jsx)("svg",{className:"sekyro-glyph",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",focusable:"false",dangerouslySetInnerHTML:{__html:ut[a]}})}c(j,"ae");h(j,"ScanGlyph");var bt={en:ee,fr:pt,ar:ht,es:ee,pt:ee,de:ee},zt={en:te,fr:vt,ar:mt,es:te,pt:te,de:te},St="image/jpeg,image/png,image/heic,image/heif";function V(a){let t=a.strings,n=h(o=>t[o]??zt[a.locale][o],"text");return{t:h(o=>n(o)??"","t")}}c(V,"F");h(V,"uploadCopy");function We(a,t){return a===null||a.state==="fallback"||a.state==="mismatch"?null:a.state==="searching"?t?"dcv3.mrz.searching":"dcv3.mrz.showMrzSide":a.state==="valid"?"dcv3.mrz.valid":a.coach!==void 0?`dcv3.mrz.${a.coach}`:"dcv3.mrz.reading"}c(We,"vt");h(We,"mrzInstruction");var Nt={document_type_mismatch:"doc.reason_document_type_mismatch",document_number_invalid:"doc.reason_document_number_invalid",provider_unavailable:"doc.reason_provider_unavailable"};function ne(a){if(a.reason==="unreadable")return"doc.reason_unreadable";let t=a.reason!==void 0?Nt[a.reason]:void 0;return t!==void 0?t:a.reason==="tester_document_mismatch"?"reasons.tester_document_mismatch":a.reason!==void 0&&a.reason!=="side_missing"?Pe(a.reason):null}c(ne,"ve");h(ne,"reasonOf");var xt=new Set(["document_type_not_accepted","tester_document_mismatch","document_type_mismatch","provider_unavailable"]);function $t({step:a,i18n:t,liveMrz:n,ageLead:o,...r}){let[f,g]=(0,i.useState)(!1),y=(0,i.useRef)(-1),[v,k]=(0,i.useState)("idle"),w=(0,i.useRef)(null),x=typeof a.uploadDocument=="function",b=x?a.photo?.source??"camera":"camera",L=x&&b!=="camera"&&a.photo?.uploadOffered===!0,[C,B]=(0,i.useState)(null),M=b==="upload"?"upload":b==="choice"?C??a.photo?.pick??"source":"camera",H=v==="sending"?void 0:()=>w.current?.click(),m=h(async P=>{let q=P.currentTarget.files?.[0];if(P.currentTarget.value="",q!==void 0){g(!1),k("sending");try{await a.uploadDocument(q),k("idle")}catch(F){k(F instanceof TypeError&&F.message==="unsupported_file"?"unsupported":"failed")}}},"onFile"),Q=L?(0,e.jsx)("input",{ref:w,type:"file",accept:St,hidden:!0,"data-testid":"sekyro-doc-upload","aria-label":V(t).t("doc.uploadTitle"),onChange:c(P=>{m(P)},"onChange")}):null,z=V(t),X=a.photo?.cameraOnPhone===!0;return M==="camera"&&X?(0,e.jsx)(Ie,{i18n:t,lead:t.t("handoff.lead.document"),refresh:a.refresh,actions:(0,e.jsx)(E,{kind:"ghost",full:!0,onClick:c(()=>B("upload"),"onClick"),children:z.t("doc.source.upload")})}):M==="source"?(0,e.jsx)(Ge,{testId:"sekyro-doc-source",title:z.t("doc.source.title"),lead:z.t("doc.source.description"),cameraLabel:X?t.t("capture.source.phone"):z.t("doc.source.camera"),onPhone:X,uploadLabel:z.t("doc.source.upload"),notice:(0,e.jsx)(oe,{step:a,i18n:t}),onCamera:c(()=>B("camera"),"onCamera"),onUpload:c(()=>B("upload"),"onUpload")}):M==="upload"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(je,{step:a,i18n:t,ageLead:o===!0,upload:v,offered:L,onPick:c(()=>w.current?.click(),"onPick"),...b==="choice"?{onCamera:h(()=>B("camera"),"onCamera")}:{},...r}),Q]}):(0,e.jsxs)(e.Fragment,{children:[f?(0,e.jsx)(Qe,{step:a,i18n:t,attempts:y,...n!==void 0?{liveMrz:n}:{},...L&&H!==void 0?{onUpload:H}:{},onClose:c(()=>g(!1),"onClose")}):(0,e.jsx)(Fe,{step:a,i18n:t,ageLead:o===!0,onOpen:c(()=>g(!0),"onOpen"),upload:v,...L&&H!==void 0?{onUpload:H}:{},...r}),Q]})}c($t,"dn");h($t,"DocumentCaptureView");function ke({passport:a}){let t=Math.round(228/(a?1.42:1.586));return(0,e.jsxs)("svg",{className:"sekyro-mark sekyro-mark--card",viewBox:`-12 -12 252 ${t+24}`,"aria-hidden":"true",focusable:"false",children:[(0,e.jsx)("defs",{children:(0,e.jsx)("clipPath",{id:"sekyro-card-clip",children:(0,e.jsx)("rect",{width:228,height:t,rx:"12.5"})})}),(0,e.jsx)("rect",{className:"sekyro-mark__card",width:228,height:t,rx:"12.5"}),(0,e.jsx)("rect",{className:"sekyro-mark__photo",x:"17",y:"17",width:"55",height:t*.52,rx:"6"}),[0,1,2].map(n=>(0,e.jsx)("rect",{className:"sekyro-mark__text",x:"88",y:23+n*t*.12,width:100-n*20,height:"6",rx:"3"},n)),[0,1].map(n=>(0,e.jsx)("rect",{className:"sekyro-mark__text",x:"17",y:t*.74+n*9,width:194,height:"4",rx:"2"},n)),(0,e.jsx)("g",{clipPath:"url(#sekyro-card-clip)",children:(0,e.jsx)("g",{className:"sekyro-mark__read",style:{"--sekyro-read-w":"228px"},children:(0,e.jsx)("rect",{x:"-1",width:"2",height:t,className:"sekyro-mark__beam"})})}),(0,e.jsx)("path",{className:"sekyro-mark__brackets",d:Xe(-10,-10,248,t+20,16,30)})]})}c(ke,"qe");h(ke,"ScanMark");function Xe(a,t,n,o,r,f){let g=Math.min(r,f*.6);return[[a,t,1,1],[a+n,t,-1,1],[a,t+o,1,-1],[a+n,t+o,-1,-1]].map(([y,v,k,w])=>`M${y} ${v+w*f}V${v+w*g}Q${y} ${v} ${y+k*g} ${v}H${y+k*f}`).join("")}c(Xe,"bt");h(Xe,"brackets");function Fe({step:a,i18n:t,ageLead:n,onOpen:o,onChangeCountry:r,onChangeDocument:f,upload:g,onUpload:y}){let v=fe(t),k=V(t),w=a.documentType==="passport",x=ne(a),b=g==="sending",L=(0,i.useContext)(Ae)?.busy===!0;return(0,e.jsxs)("section",{className:"sekyro-step","data-testid":"sekyro-document",children:[(0,e.jsx)(ke,{passport:w}),(0,e.jsx)(ue,{title:v("native.doc.introTitle"),lead:n?t.t("doc.ageStepUp"):v("native.doc.introLead")}),(0,e.jsx)(oe,{step:a,i18n:t}),a.reason!==void 0&&xt.has(a.reason)?null:(0,e.jsxs)("ul",{className:"sekyro-tiprows",children:[(0,e.jsxs)("li",{children:[(0,e.jsx)(Y,{name:w?"passport":"card"}),v("native.doc.tip.flat")]}),(0,e.jsxs)("li",{children:[(0,e.jsx)(Y,{name:"light"}),v("native.doc.tip.glare")]}),(0,e.jsxs)("li",{children:[(0,e.jsx)(j,{name:"image"}),v("native.doc.tip.frame")]})]}),(0,e.jsx)(ge,{i18n:t,...f!==void 0?{onChangeDocument:f}:{},...r!==void 0?{onChangeCountry:r}:{}}),(0,e.jsx)(ye,{i18n:t,upload:g}),b?(0,e.jsx)("p",{className:"sekyro-text-muted",role:"status",children:t.t("doc.uploading")}):y!==void 0?(0,e.jsx)("p",{className:"sekyro-text-muted",children:k.t("doc.uploadHint")}):null,(0,e.jsxs)(he,{children:[(0,e.jsxs)(E,{full:!0,onClick:o,disabled:b||L,children:[(0,e.jsx)(Y,{name:"camera"}),v("native.doc.openCamera")]}),y!==void 0?(0,e.jsxs)(E,{full:!0,kind:"ghost",onClick:y,children:[(0,e.jsx)(j,{name:"image"}),k.t("doc.uploadInstead")]}):null]})]})}c(Fe,"wt");h(Fe,"DocumentIntro");function oe({step:a,i18n:t}){let n=ne(a);return n===null?null:(0,e.jsxs)(pe,{tone:"warning",children:[(0,e.jsx)("span",{children:t.t(n)}),(0,e.jsx)("span",{children:me(t,a.attemptsRemaining,a.attemptsExhausted)})]})}c(oe,"ye");h(oe,"ReasonNotice");function ge({i18n:a,onChangeCountry:t,onChangeDocument:n}){let o=fe(a);return n===void 0&&t===void 0?null:(0,e.jsxs)("div",{className:"sekyro-links",children:[n!==void 0?(0,e.jsx)("button",{type:"button",className:"sekyro-link",onClick:n,children:o("native.doc.changeDocument")}):null,t!==void 0?(0,e.jsx)("button",{type:"button",className:"sekyro-link",onClick:t,children:a.t("native.doc.changeCountry")}):null]})}c(ge,"Je");h(ge,"ChangeLinks");function ye({i18n:a,upload:t}){return t!=="unsupported"&&t!=="failed"?null:(0,e.jsx)(pe,{tone:"warning",children:(0,e.jsx)("span",{children:V(a).t(t==="unsupported"?"doc.uploadUnsupported":"doc.uploadFailed")})})}c(ye,"et");h(ye,"UploadNotice");function je({step:a,i18n:t,ageLead:n,upload:o,offered:r,onPick:f,onCamera:g,onChangeCountry:y,onChangeDocument:v}){let k=V(t),w=o==="sending";return(0,e.jsxs)("section",{className:"sekyro-step","data-testid":"sekyro-doc-upload-screen",children:[(0,e.jsx)(ke,{passport:a.documentType==="passport"}),(0,e.jsx)(ue,{title:k.t("doc.uploadTitle"),lead:n?t.t("doc.ageStepUp"):k.t("doc.uploadHint")}),n?(0,e.jsx)("p",{className:"sekyro-text-muted",children:k.t("doc.uploadHint")}):null,(0,e.jsx)(oe,{step:a,i18n:t}),(0,e.jsx)(ge,{i18n:t,...v!==void 0?{onChangeDocument:v}:{},...y!==void 0?{onChangeCountry:y}:{}}),(0,e.jsx)(ye,{i18n:t,upload:o}),w?(0,e.jsx)("p",{className:"sekyro-text-muted",role:"status",children:t.t("doc.uploading")}):null,(0,e.jsxs)(he,{children:[(0,e.jsxs)(E,{full:!0,onClick:f,disabled:w||!r||a.attemptsExhausted,children:[(0,e.jsx)(j,{name:"image"}),k.t("doc.source.upload")]}),g!==void 0?(0,e.jsxs)(E,{full:!0,kind:"ghost",onClick:g,disabled:w,children:[(0,e.jsx)(Y,{name:"camera"}),k.t("doc.source.camera")]}):null]})]})}c(je,"Ct");h(je,"DocumentUploadScreen");function ve(a,t,n){let o=a*.88,r=o/n;return{x:(a-o)/2,y:t*.42-r/2,w:o,h:r}}c(ve,"Qe");h(ve,"guideRect");var _t={too_far:"native.scan.closer",too_close:"native.scan.farther",focus_far:"native.scan.farther",glare:"native.scan.glare",too_bright:"native.scan.glare",too_dark:"native.scan.dark",blurry:"native.scan.blurry"},Lt=h(()=>typeof window<"u"&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,"reduceMotion");function Qe({step:a,i18n:t,liveMrz:n,onClose:o,attempts:r,onUpload:f}){let g=fe(t),y=(0,i.useContext)(Oe),v=(0,i.useRef)(y);v.current=y;let k=(0,i.useRef)(null),w=(0,i.useRef)(null),x=(0,i.useRef)(null),[b,L]=(0,i.useState)("idle"),[C,B]=(0,i.useState)(null),[M,H]=(0,i.useState)(null),[m,Q]=(0,i.useState)({w:0,h:0}),[z,X]=(0,i.useState)({hint:null,locking:!1,card:null,manualShutter:!1}),[P,q]=(0,i.useState)({}),[F,Ke]=(0,i.useState)(null),[we,et]=(0,i.useState)(null),[Ce,be]=(0,i.useState)(0),[ze,Se]=(0,i.useState)(null),[Z,Ne]=(0,i.useState)(null),D=a.documentType==="passport",J=D?1.42:1.586;De(!0),(0,i.useLayoutEffect)(()=>{let s=k.current;if(s===null)return;let u=h(()=>Q({w:s.clientWidth,h:s.clientHeight}),"measure");if(u(),typeof ResizeObserver>"u")return;let d=new ResizeObserver(u);return d.observe(s),()=>d.disconnect()},[]);let l=ve(m.w,m.h,J);(0,i.useEffect)(()=>{m.w===0||m.h===0||x.current?.setGuide?.({viewAspect:m.w/m.h,rect:{x:l.x/m.w,y:l.y/m.h,width:l.w/m.w,height:l.h/m.h}})},[m.w,m.h,l.x,l.y,l.w,l.h]),(0,i.useEffect)(()=>{let s=w.current;if(s===null)return;let u=a.capture({video:s,...n!==void 0?{liveMrz:n}:{}});x.current=u;let d=k.current;if(d!==null&&d.clientWidth>0&&d.clientHeight>0){let p=ve(d.clientWidth,d.clientHeight,J);u.setGuide?.({viewAspect:d.clientWidth/d.clientHeight,rect:{x:p.x/d.clientWidth,y:p.y/d.clientHeight,width:p.w/d.clientWidth,height:p.h/d.clientHeight}})}let T=new yt,N={scan:null,feedback:null,gate:null},R=h(p=>{N={...N,...p};let _=N.gate?.guide,st={phase:N.scan?.phase??"framing",hint:N.feedback?.reticle==="coaching"?N.feedback.key:null,card:_?.detected?{fill:_.fill,offsetX:_.offsetX,offsetY:_.offsetY}:null,manualShutter:N.scan?.manualShutter??!1},U=T.present(st,performance.now());X(O=>O.hint===U.hint&&O.locking===U.locking&&O.manualShutter===U.manualShutter&&O.card?.fill===U.card?.fill&&O.card?.offsetX===U.card?.offsetX&&O.card?.offsetY===U.card?.offsetY?O:U)},"present"),it=[u.on("state",L),u.on("feedback",p=>R({feedback:p})),u.on("gate",p=>R({gate:p})),u.on("scan",p=>{B(p),R({scan:p})}),u.on("captured",p=>{q(_=>({..._,[qe(p.side,D,_)]:p.previewDataUrl})),Ke(p.previewDataUrl),et(Je(s))}),u.on("error",p=>{H(p);let _=v.current;_!==null&&Ve(_,Ee("document",p,Math.max(0,r.current)))}),u.on("mrz",p=>{p.state==="mismatch"?Ne(p.format??null):Se(p)})];return r.current+=1,u.start().catch(()=>{}),()=>{for(let p of it)p();u.destroy(),x.current=null}},[a.issuer,a.documentType]);let $=C?.phase??"framing",A=$==="reading"||$==="result",re=$==="flipCue"||$==="reaskRecto",I=z.locking,xe=C?.captured.length??0;(0,i.useEffect)(()=>{I&&be(s=>s+1)},[I]),(0,i.useEffect)(()=>{xe>0&&be(s=>s+1)},[xe]);let tt=C?.expected??null;(0,i.useEffect)(()=>{Se(null)},[tt]),(0,i.useEffect)(()=>{if(Z===null)return;let s=setTimeout(()=>Ne(null),2e3);return()=>clearTimeout(s)},[Z]);let $e=re||A||a.documentType==="drivers_license"?null:We(ze,D),le=Z!==null?Z==="TD3"?"dcv3.mrz.looksLikePassport":"dcv3.mrz.looksLikeCard":$e,at=le===null?null:t.strings[le]??bt[t.locale][le],ie=ne(a),_e=z.hint===null?null:_t[z.hint]??`dcv2.${z.hint}`,nt=_e??($==="flipCue"?C?.notice==="same_face"?"doc.sameFace":"doc.flip":$==="reaskRecto"?"doc.reaskRecto":A?"native.scan.reading":$==="locking"||$==="capturing"||I?"native.scan.holdStill":C?.notice==="reread"?ie??"doc.reread":C?.notice==="technical"?"native.scan.retry":C?.notice==="blurry"?"native.scan.blurry":ie??(D?"doc.showPage":"doc.showSide")),se=at??g(nt),G=z.card,S=l;if(!I&&G!==null&&G.fill>=.45&&G.fill<=1.25&&!Lt()){let s=l.w*G.fill,u=s/J,d=l.x+l.w/2+l.w*Math.max(-.25,Math.min(.25,G.offsetX)),T=l.y+l.h/2+l.h*Math.max(-.25,Math.min(.25,G.offsetY));S={x:d-s/2,y:T-u/2,w:s,h:u}}let K=l.w*.045,ce=28,Le=Math.min(K,ce*.6),ot=[[S.x,S.y,1,1],[S.x+S.w,S.y,-1,1],[S.x,S.y+S.h,1,-1],[S.x+S.w,S.y+S.h,-1,-1]],rt=I?"is-locked":z.hint!==null?"is-coaching":"",lt=D?[{side:"single",label:"doc.progressPage"}]:[{side:"recto",label:"doc.progressFront"},{side:"verso",label:"doc.progressBack"}],Te=l.y+l.h+48,de={insetInlineStart:l.x,insetBlockStart:l.y,inlineSize:l.w,blockSize:l.h,borderRadius:K};return(0,e.jsx)("section",{className:"sekyro-lm","aria-label":se,"data-testid":"sekyro-document",children:(0,e.jsxs)("div",{ref:k,className:`sekyro-lm-stage${A?" is-reading":""}${re?" is-flip":""}`,style:{"--sekyro-guide-w":`${l.w}px`},children:[(0,e.jsx)("video",{ref:w,className:"sekyro-lm-video",playsInline:!0,muted:!0,autoPlay:!0,"aria-hidden":"true",onPointerUp:c(s=>{let u=s.currentTarget,d=u.getBoundingClientRect(),T=Math.max(d.width/(u.videoWidth||1),d.height/(u.videoHeight||1)),N=u.videoWidth*T,R=u.videoHeight*T;N>0&&R>0&&x.current?.focusAt((s.clientX-d.left+(N-d.width)/2)/N,(s.clientY-d.top+(R-d.height)/2)/R)},"onPointerUp")}),m.w>0?(0,e.jsxs)(e.Fragment,{children:[A&&we!==null?(0,e.jsx)("img",{className:"sekyro-lm-scene",src:we,alt:""}):null,A&&F!==null?(0,e.jsx)("img",{className:"sekyro-lm-frozen",src:F,alt:"",style:de}):null,(0,e.jsxs)("svg",{className:"sekyro-lm-overlay",viewBox:`0 0 ${m.w} ${m.h}`,"aria-hidden":"true",focusable:"false",children:[(0,e.jsxs)("defs",{children:[(0,e.jsxs)("linearGradient",{id:"sekyro-lm-top",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,e.jsx)("stop",{offset:"0",className:"sekyro-lm-ink",stopOpacity:"0.85"}),(0,e.jsx)("stop",{offset:"1",className:"sekyro-lm-ink",stopOpacity:"0"})]}),(0,e.jsxs)("linearGradient",{id:"sekyro-lm-bottom",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,e.jsx)("stop",{offset:"0",className:"sekyro-lm-ink",stopOpacity:"0"}),(0,e.jsx)("stop",{offset:"1",className:"sekyro-lm-ink",stopOpacity:"0.9"})]})]}),(0,e.jsx)("path",{className:"sekyro-lm-scrim",fillRule:"evenodd",d:`M0 0H${m.w}V${m.h}H0Z${Ze(l,K)}`}),(0,e.jsx)("rect",{width:m.w,height:Math.max(0,l.y),fill:"url(#sekyro-lm-top)"}),(0,e.jsx)("rect",{y:l.y+l.h,width:m.w,height:Math.max(0,m.h-l.y-l.h),fill:"url(#sekyro-lm-bottom)"}),(0,e.jsx)("g",{className:`sekyro-lm-brackets ${rt}`,children:ot.map(([s,u,d,T],N)=>(0,e.jsx)("path",{style:{transform:`translate(${s}px, ${u}px) scale(${d}, ${T})`},d:`M0 ${ce}V${Le}Q0 0 ${Le} 0H${ce}`},N))}),I?(0,e.jsx)("rect",{className:"sekyro-lm-trace",x:l.x,y:l.y,width:l.w,height:l.h,rx:K,pathLength:"1",style:{animationDuration:`${Ct}ms`}}):null]}),(0,e.jsx)("div",{className:"sekyro-lm-slot",style:de,"aria-hidden":"true",children:A?(0,e.jsx)("span",{className:"sekyro-lm-read is-repeating"}):Ce>0?(0,e.jsx)("span",{className:"sekyro-lm-read"},Ce):null})]}):null,$e!==null?(0,e.jsx)("div",{className:"sekyro-lm-slot",style:de,"aria-hidden":"true",children:(0,e.jsx)("span",{"data-testid":"sekyro-mrz-strip",className:`sekyro-lm-mrz${D?" is-page":""}${ze?.state==="valid"?" is-valid":""}`})}):null,(0,e.jsxs)("div",{className:"sekyro-lm-instruction",style:{insetBlockStart:l.y-64},children:[(0,e.jsx)("div",{role:"status","aria-live":"polite",children:(0,e.jsx)(Ue,{swapKey:se,className:"sekyro-lm-line",children:se})}),ie!==null&&$==="framing"&&_e===null?(0,e.jsx)("p",{className:"sekyro-lm-attempts",children:me(t,a.attemptsRemaining,a.attemptsExhausted)}):null]}),A?(0,e.jsxs)("p",{className:"sekyro-lm-under sekyro-lm-note",style:{insetBlockStart:Te-12},children:[(0,e.jsx)("span",{className:"sekyro-lm-spinner","aria-hidden":"true"}),g("native.scan.putDown")]}):re?(0,e.jsx)("div",{className:`sekyro-lm-under sekyro-lm-flip${$==="reaskRecto"?" is-toFront":""}`,style:{insetBlockStart:Te-20},"data-testid":"sekyro-flip-cue","aria-hidden":"true",children:(0,e.jsxs)("span",{className:"sekyro-lm-flip-card",style:{aspectRatio:String(J)},children:[(0,e.jsx)("span",{className:"sekyro-lm-flip-front"}),(0,e.jsx)("span",{className:"sekyro-lm-flip-back"})]})}):null,(0,e.jsxs)("div",{className:"sekyro-lm-controls",children:[(0,e.jsxs)("div",{className:"sekyro-lm-bar",children:[(0,e.jsx)("button",{type:"button",className:"sekyro-glass","aria-label":t.t("native.close"),onClick:o,children:(0,e.jsx)(Y,{name:"close"})}),C?.torchAvailable?(0,e.jsx)("button",{type:"button",className:`sekyro-glass${C.torch?" is-on":""}`,"aria-label":t.t("doc.torchOn"),"aria-pressed":C.torch,onClick:c(()=>x.current?.setTorch(!C.torch),"onClick"),children:(0,e.jsx)(j,{name:"flashlight"})}):null]}),M!==null?(0,e.jsxs)("div",{className:"sekyro-lm-error",role:"alert",children:[(0,e.jsx)("p",{children:t.t("doc.cameraBlocked")}),(0,e.jsx)("p",{children:t.t(M.kind==="permission"?"doc.cameraBlockedHint":He(M.kind))}),(0,e.jsx)(E,{onClick:c(()=>{H(null),r.current+=1,x.current?.retry()},"onClick"),children:t.t("doc.retryCamera")})]}):null,z.manualShutter?(0,e.jsx)("button",{type:"button",className:"sekyro-shutter","aria-label":t.t("doc.shutter"),onClick:c(()=>x.current?.shutter(),"onClick")}):null,(0,e.jsx)("ol",{className:"sekyro-lm-tray",children:lt.map(({side:s,label:u})=>{let d=C?.captured.includes(s)??!1;return(0,e.jsxs)("li",{className:d?"is-done":void 0,"aria-current":!d&&(D||C?.expected===s)?"step":void 0,children:[d?(0,e.jsxs)("span",{className:"sekyro-lm-thumb",children:[P[s]!==void 0?(0,e.jsx)("img",{src:P[s],alt:""}):null,(0,e.jsx)("svg",{className:"sekyro-lm-check",viewBox:"0 0 18 18","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M5 9.2l2.6 2.6L13 6.4"})})]}):null,g(u)]},s)})}),f!==void 0?(0,e.jsx)("button",{type:"button",className:"sekyro-lm-upload",onClick:f,children:V(t).t("doc.uploadInstead")}):null,b==="uploading"||b==="checking"?null:(0,e.jsx)(Re,{onStop:o})]}),b==="uploading"||b==="checking"?(0,e.jsx)("span",{className:"sekyro-visually-hidden",role:"status",children:b==="uploading"?t.t("doc.uploading"):g("native.scan.reading")}):null]})})}c(Qe,"_t");h(Qe,"LumiereScan");function qe(a,t,n){return t?"single":a==="recto"||a==="verso"?a:n.recto===void 0?"recto":"verso"}c(qe,"Lt");h(qe,"slotOf");function Ze({x:a,y:t,w:n,h:o},r){return`M${a+r} ${t}H${a+n-r}Q${a+n} ${t} ${a+n} ${t+r}V${t+o-r}Q${a+n} ${t+o} ${a+n-r} ${t+o}H${a+r}Q${a} ${t+o} ${a} ${t+o-r}V${t+r}Q${a} ${t} ${a+r} ${t}Z`}c(Ze,"zt");h(Ze,"roundedRect");function Je(a){let t=Math.round(a.videoWidth/4),n=Math.round(a.videoHeight/4);if(t===0||n===0||typeof document>"u")return null;try{let o=document.createElement("canvas");o.width=t,o.height=n;let r=o.getContext("2d");return r===null?null:(r.drawImage(a,0,0,t,n),o.toDataURL("image/jpeg",.7))}catch{return null}}c(Je,"xt");h(Je,"sceneSnapshot");export{$t as DocumentCaptureView,Ct as LOCK_TRACE_MS,St as UPLOAD_ACCEPT,ve as guideRect,We as mrzInstruction,qe as slotOf};
|
|
1
|
+
"use client";import{a as Ge}from"./chunk-H22YHQ6V.js";import{a as Oe,b as Ee,c as Ve}from"./chunk-5K4YQOZN.js";import{a as Be}from"./chunk-YRTHQZAW.js";import"./chunk-QOZB3DLY.js";import{d as Ie}from"./chunk-X4MIUKLT.js";import"./chunk-LA2MA2UQ.js";import{E as De,F as Ae,G as Re,I as Ue,K as pe,L as me,a as ct,b as dt,c as E,o as He,q as Pe,v as Y,w as ue,y as he}from"./chunk-SIPFHN7E.js";import{a as h}from"./chunk-5QL6W6FW.js";import{a as c,c as Me}from"./chunk-4FHWXBOB.js";var i=Me(ct(),1),e=Me(dt(),1);var ut={image:'<path d="M2 12C2 7.29 2 4.93 3.46 3.46C4.93 2 7.29 2 12 2C16.71 2 19.07 2 20.54 3.46C22 4.93 22 7.29 22 12C22 16.71 22 19.07 20.54 20.54C19.07 22 16.71 22 12 22C7.29 22 4.93 22 3.46 20.54C2 19.07 2 16.71 2 12Z" stroke="currentColor"/><path d="M14 8A2 2 0 1 0 18 8A2 2 0 1 0 14 8Z" stroke="currentColor"/><path d="M2 12.5L3.75 10.97C4.66 10.17 6.04 10.22 6.89 11.07L11.18 15.36C11.87 16.05 12.95 16.14 13.75 15.58L14.04 15.37C15.19 14.57 16.74 14.66 17.78 15.6L21 18.5" stroke="currentColor" stroke-linecap="round"/>',flashlight:'<path d="M9 11.66V19C9 19.93 9 20.4 9.15 20.77C9.36 21.26 9.74 21.64 10.23 21.85C10.6 22 11.07 22 12 22C12.93 22 13.4 22 13.77 21.85C14.26 21.64 14.64 21.26 14.85 20.77C15 20.4 15 19.93 15 19V11.66C15 10.84 15 10.43 15.15 10.06C15.3 9.7 15.59 9.41 16.17 8.83L16.17 8.83L19.41 5.59C19.7 5.3 19.85 5.15 19.92 4.97C20 4.78 20 4.58 20 4.17V4C20 3.06 20 2.59 19.71 2.29C19.41 2 18.94 2 18 2H6C5.06 2 4.59 2 4.29 2.29C4 2.59 4 3.06 4 4V4.17C4 4.58 4 4.78 4.08 4.97C4.15 5.15 4.3 5.3 4.59 5.59L7.83 8.83C8.41 9.41 8.7 9.7 8.85 10.06C9 10.43 9 10.84 9 11.66Z" stroke="currentColor" stroke-linecap="round"/><path d="M15 10H9" stroke="currentColor" stroke-linecap="round"/><path d="M12 13V15" stroke="currentColor" stroke-linecap="round"/><path d="M4.5 5H19.5" stroke="currentColor" stroke-linecap="round"/>'},ht={"dcv3.mrz.searching":"ضع صفحة جواز السفر كاملة داخل الإطار","dcv3.mrz.showMrzSide":"اعرض الوجه الذي يحتوي على سطرين أو ثلاثة أسطر من الحروف","dcv3.mrz.reading":"جارٍ قراءة الوثيقة… ثبّتها","dcv3.mrz.moveCloser":"اقترب حتى تملأ أسطر الحروف الإطار","dcv3.mrz.turnSideways":"أدر هاتفك أفقيًا لقراءة أسطر الحروف","dcv3.mrz.glare":"أمِل الوثيقة لإزالة الانعكاس","dcv3.mrz.holdStill":"لا تتحرك","dcv3.mrz.valid":"تمت قراءة الوثيقة. جارٍ التقاط الصورة","dcv3.mrz.looksLikePassport":"يبدو أن هذا جواز سفر","dcv3.mrz.looksLikeCard":"يبدو أن هذه بطاقة تعريف أو بطاقة إقامة"},ee={"dcv3.mrz.searching":"Fit the whole passport page in the frame","dcv3.mrz.showMrzSide":"Show the side with the two or three lines of characters","dcv3.mrz.reading":"Reading the document… hold it steady","dcv3.mrz.moveCloser":"Move closer so the lines of characters fill the frame","dcv3.mrz.turnSideways":"Turn your phone sideways to read the lines of characters","dcv3.mrz.glare":"Tilt the document to remove the reflection","dcv3.mrz.holdStill":"Hold still","dcv3.mrz.valid":"Document read. Taking the photo","dcv3.mrz.looksLikePassport":"This looks like a passport","dcv3.mrz.looksLikeCard":"This looks like an identity card or residence permit"},pt={"dcv3.mrz.searching":"Cadrez toute la page du passeport","dcv3.mrz.showMrzSide":"Montrez la face avec les deux ou trois lignes de caractères","dcv3.mrz.reading":"Lecture du document… tenez-le immobile","dcv3.mrz.moveCloser":"Rapprochez-vous pour que les lignes de caractères remplissent le cadre","dcv3.mrz.turnSideways":"Tournez votre téléphone à l’horizontale pour lire les lignes de caractères","dcv3.mrz.glare":"Inclinez le document pour supprimer le reflet","dcv3.mrz.holdStill":"Ne bougez plus","dcv3.mrz.valid":"Document lu. Prise de la photo","dcv3.mrz.looksLikePassport":"Ceci ressemble à un passeport","dcv3.mrz.looksLikeCard":"Ceci ressemble à une carte d’identité ou un titre de séjour"},mt={"doc.uploadInstead":"رفع صورة بدلًا من ذلك","doc.uploadTitle":"ارفع صورة لوثيقتك","doc.uploadHint":"صورة واضحة للوثيقة كاملة، ملتقطة بكاميرا.","doc.uploadUnsupported":"اختر صورة للوثيقة بصيغة JPEG أو PNG أو HEIC.","doc.uploadFailed":"تعذّر إرسال هذه الصورة. أعد المحاولة.","doc.source.title":"كيف تريد إضافة وثيقتك؟","doc.source.description":"التقط صورة بالكاميرا، أو ارفع صورة للوثيقة من هذا الجهاز.","doc.source.camera":"التقاط صورة","doc.source.upload":"رفع صورة"},te={"doc.uploadInstead":"Upload a photo instead","doc.uploadTitle":"Upload a photo of your document","doc.uploadHint":"A clear photo of the whole document, taken with a camera.","doc.uploadUnsupported":"Choose a JPEG, PNG or HEIC photo of the document.","doc.uploadFailed":"We could not send this photo. Try again.","doc.source.title":"How do you want to add your document?","doc.source.description":"Take a photo with the camera, or upload a photo of the document from this device.","doc.source.camera":"Take a photo","doc.source.upload":"Upload a photo"},vt={"doc.uploadInstead":"Téléverser une photo à la place","doc.uploadTitle":"Téléversez une photo de votre document","doc.uploadHint":"Une photo nette du document entier, prise avec un appareil photo.","doc.uploadUnsupported":"Choisissez une photo JPEG, PNG ou HEIC du document.","doc.uploadFailed":"Nous n'avons pas pu envoyer cette photo. Réessayez.","doc.source.title":"Comment voulez-vous ajouter votre document ?","doc.source.description":"Prenez une photo avec la caméra, ou importez une photo du document depuis cet appareil.","doc.source.camera":"Prendre une photo","doc.source.upload":"Importer une photo"},ft={"native.doc.introTitle":"سنلتقط صورة لوثيقتك","native.doc.introLead":"ستُفتح كاميرا هاتفك، وتُلتقط الصورة تلقائيًا بمجرد أن تكون الوثيقة داخل الإطار.","native.doc.tip.flat":"ضع الوثيقة مسطحة على سطح داكن.","native.doc.tip.glare":"تجنّب انعكاسات المصابيح أو الشمس.","native.doc.tip.frame":"أبقِ الوثيقة كاملة داخل الإطار.","native.doc.openCamera":"افتح الكاميرا","native.doc.changeDocument":"تغيير الوثيقة","native.scan.closer":"اقترب قليلًا","native.scan.farther":"ابتعد قليلًا","native.scan.glare":"أمِل البطاقة قليلًا","native.scan.dark":"الإضاءة ضعيفة. شغّل المصباح.","native.scan.blurry":"الصورة غير واضحة. ثبّت الهاتف.","native.scan.holdStill":"لا تتحرك","native.scan.reading":"جارٍ التحقق من وثيقتك…","native.scan.putDown":"يمكنك وضع وثيقتك جانبًا.","native.scan.retry":"لنحاول مرة أخرى"},ae={"native.doc.introTitle":"Photograph your document","native.doc.introLead":"Your phone's camera will open. The photo is taken by itself as soon as the document is well framed.","native.doc.tip.flat":"Lay the document flat on a dark surface.","native.doc.tip.glare":"Avoid glare from lamps or sunlight.","native.doc.tip.frame":"Keep the whole document in the frame.","native.doc.openCamera":"Open the camera","native.doc.changeDocument":"Change document","native.scan.closer":"Move a little closer","native.scan.farther":"Move back a little","native.scan.glare":"Tilt the card a little","native.scan.dark":"Too dark. Turn on the light.","native.scan.blurry":"Blurry image. Hold the phone still.","native.scan.holdStill":"Hold still","native.scan.reading":"Checking your document…","native.scan.putDown":"You can put your document down.","native.scan.retry":"Let's try that again"},kt={"native.doc.introTitle":"Photographiez votre pièce","native.doc.introLead":"La caméra de votre téléphone va s'ouvrir. La photo est prise automatiquement dès que la pièce est bien cadrée.","native.doc.tip.flat":"Posez la pièce à plat, sur une surface sombre.","native.doc.tip.glare":"Évitez les reflets de lampe ou de soleil.","native.doc.tip.frame":"Gardez toute la pièce dans le cadre.","native.doc.openCamera":"Ouvrir la caméra","native.doc.changeDocument":"Changer de document","native.scan.closer":"Approchez un peu","native.scan.farther":"Reculez un peu","native.scan.glare":"Inclinez un peu la carte","native.scan.dark":"Trop sombre. Allumez la lampe.","native.scan.blurry":"Image floue. Tenez le téléphone immobile.","native.scan.holdStill":"Ne bougez plus","native.scan.reading":"Vérification de votre document…","native.scan.putDown":"Vous pouvez poser votre pièce.","native.scan.retry":"Réessayons"},gt=["locking","capturing"],W,Ye=(W=class{constructor(){this.shown={hint:null,locking:!1,card:null,manualShutter:!1},this.candidate=null,this.candidateSince=0,this.hintShownAt=0,this.lockLostAt=null,this.detectedSince=null,this.lostSince=null,this.shutterSince=null}present(t,n){return this.presentHint(t,n),this.presentLock(t,n),this.presentCard(t,n),this.shutterSince=t.manualShutter?this.shutterSince??n:null,this.shown={...this.shown,manualShutter:this.shutterSince!==null&&n-this.shutterSince>=1e3},this.shown}presentHint(t,n){let o=t.phase==="framing"&&!(t.hint==="blurry"&&t.card===null)?t.hint:null;if(t.phase!=="framing"){this.shown={...this.shown,hint:null},this.candidate=null;return}if(o!==this.candidate&&(this.candidate=o,this.candidateSince=n),o===this.shown.hint)return;let r=n-this.candidateSince>=(o===null?0:350),f=this.shown.hint===null||n-this.hintShownAt>=1200;r&&f&&(this.shown={...this.shown,hint:o},this.hintShownAt=n)}presentLock(t,n){if(gt.includes(t.phase)){this.shown={...this.shown,locking:!0},this.lockLostAt=null;return}if(this.shown.locking){if(t.phase!=="framing"){this.shown={...this.shown,locking:!1},this.lockLostAt=null;return}this.lockLostAt??(this.lockLostAt=n),n-this.lockLostAt>=300&&(this.shown={...this.shown,locking:!1},this.lockLostAt=null)}}presentCard(t,n){let o=t.card;if(o===null||t.phase!=="framing"){if(t.phase!=="framing"){this.shown={...this.shown,card:null},this.detectedSince=null,this.lostSince=null;return}this.detectedSince=null,this.lostSince??(this.lostSince=n),n-this.lostSince>=300&&(this.shown={...this.shown,card:null});return}if(this.lostSince=null,this.detectedSince??(this.detectedSince=n),n-this.detectedSince<250)return;let r=this.shown.card;if(r===null){this.shown={...this.shown,card:{...o}};return}let f=.35;this.shown={...this.shown,card:{fill:r.fill+(o.fill-r.fill)*f,offsetX:r.offsetX+(o.offsetX-r.offsetX)*f,offsetY:r.offsetY+(o.offsetY-r.offsetY)*f}}}},c(W,"fe"),W);h(Ye,"ScanPresenter");var yt=Ye,wt={en:ae,fr:kt,ar:ft,es:ae,pt:ae,de:ae},Ct=450,fe=h(a=>t=>Be(a.strings[t]??wt[a.locale][t]??""),"useScanCopy");function j({name:a}){return(0,e.jsx)("svg",{className:"sekyro-glyph",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",focusable:"false",dangerouslySetInnerHTML:{__html:ut[a]}})}c(j,"ae");h(j,"ScanGlyph");var bt={en:ee,fr:pt,ar:ht,es:ee,pt:ee,de:ee},zt={en:te,fr:vt,ar:mt,es:te,pt:te,de:te},St="image/jpeg,image/png,image/heic,image/heif";function V(a){let t=a.strings,n=h(o=>t[o]??zt[a.locale][o],"text");return{t:h(o=>n(o)??"","t")}}c(V,"F");h(V,"uploadCopy");function We(a,t){return a===null||a.state==="fallback"||a.state==="mismatch"?null:a.state==="searching"?t?"dcv3.mrz.searching":"dcv3.mrz.showMrzSide":a.state==="valid"?"dcv3.mrz.valid":a.coach!==void 0?`dcv3.mrz.${a.coach}`:"dcv3.mrz.reading"}c(We,"vt");h(We,"mrzInstruction");var Nt={document_type_mismatch:"doc.reason_document_type_mismatch",document_number_invalid:"doc.reason_document_number_invalid",provider_unavailable:"doc.reason_provider_unavailable"};function ne(a){if(a.reason==="unreadable")return"doc.reason_unreadable";let t=a.reason!==void 0?Nt[a.reason]:void 0;return t!==void 0?t:a.reason==="tester_document_mismatch"?"reasons.tester_document_mismatch":a.reason!==void 0&&a.reason!=="side_missing"?Pe(a.reason):null}c(ne,"ve");h(ne,"reasonOf");var xt=new Set(["document_type_not_accepted","tester_document_mismatch","document_type_mismatch","provider_unavailable"]);function $t({step:a,i18n:t,liveMrz:n,ageLead:o,...r}){let[f,g]=(0,i.useState)(!1),y=(0,i.useRef)(-1),[v,k]=(0,i.useState)("idle"),w=(0,i.useRef)(null),x=typeof a.uploadDocument=="function",b=x?a.photo?.source??"camera":"camera",L=x&&b!=="camera"&&a.photo?.uploadOffered===!0,[C,B]=(0,i.useState)(null),M=b==="upload"?"upload":b==="choice"?C??a.photo?.pick??"source":"camera",H=v==="sending"?void 0:()=>w.current?.click(),m=h(async P=>{let q=P.currentTarget.files?.[0];if(P.currentTarget.value="",q!==void 0){g(!1),k("sending");try{await a.uploadDocument(q),k("idle")}catch(F){k(F instanceof TypeError&&F.message==="unsupported_file"?"unsupported":"failed")}}},"onFile"),Q=L?(0,e.jsx)("input",{ref:w,type:"file",accept:St,hidden:!0,"data-testid":"sekyro-doc-upload","aria-label":V(t).t("doc.uploadTitle"),onChange:c(P=>{m(P)},"onChange")}):null,z=V(t),X=a.photo?.cameraOnPhone===!0;return M==="camera"&&X?(0,e.jsx)(Ie,{i18n:t,lead:t.t("handoff.lead.document"),refresh:a.refresh,actions:(0,e.jsx)(E,{kind:"ghost",full:!0,onClick:c(()=>B("upload"),"onClick"),children:z.t("doc.source.upload")})}):M==="source"?(0,e.jsx)(Ge,{testId:"sekyro-doc-source",title:z.t("doc.source.title"),lead:z.t("doc.source.description"),cameraLabel:X?t.t("capture.source.phone"):z.t("doc.source.camera"),onPhone:X,uploadLabel:z.t("doc.source.upload"),notice:(0,e.jsx)(oe,{step:a,i18n:t}),onCamera:c(()=>B("camera"),"onCamera"),onUpload:c(()=>B("upload"),"onUpload")}):M==="upload"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(je,{step:a,i18n:t,ageLead:o===!0,upload:v,offered:L,onPick:c(()=>w.current?.click(),"onPick"),...b==="choice"?{onCamera:h(()=>B("camera"),"onCamera")}:{},...r}),Q]}):(0,e.jsxs)(e.Fragment,{children:[f?(0,e.jsx)(Qe,{step:a,i18n:t,attempts:y,...n!==void 0?{liveMrz:n}:{},...L&&H!==void 0?{onUpload:H}:{},onClose:c(()=>g(!1),"onClose")}):(0,e.jsx)(Fe,{step:a,i18n:t,ageLead:o===!0,onOpen:c(()=>g(!0),"onOpen"),upload:v,...L&&H!==void 0?{onUpload:H}:{},...r}),Q]})}c($t,"dn");h($t,"DocumentCaptureView");function ke({passport:a}){let t=Math.round(228/(a?1.42:1.586));return(0,e.jsxs)("svg",{className:"sekyro-mark sekyro-mark--card",viewBox:`-12 -12 252 ${t+24}`,"aria-hidden":"true",focusable:"false",children:[(0,e.jsx)("defs",{children:(0,e.jsx)("clipPath",{id:"sekyro-card-clip",children:(0,e.jsx)("rect",{width:228,height:t,rx:"12.5"})})}),(0,e.jsx)("rect",{className:"sekyro-mark__card",width:228,height:t,rx:"12.5"}),(0,e.jsx)("rect",{className:"sekyro-mark__photo",x:"17",y:"17",width:"55",height:t*.52,rx:"6"}),[0,1,2].map(n=>(0,e.jsx)("rect",{className:"sekyro-mark__text",x:"88",y:23+n*t*.12,width:100-n*20,height:"6",rx:"3"},n)),[0,1].map(n=>(0,e.jsx)("rect",{className:"sekyro-mark__text",x:"17",y:t*.74+n*9,width:194,height:"4",rx:"2"},n)),(0,e.jsx)("g",{clipPath:"url(#sekyro-card-clip)",children:(0,e.jsx)("g",{className:"sekyro-mark__read",style:{"--sekyro-read-w":"228px"},children:(0,e.jsx)("rect",{x:"-1",width:"2",height:t,className:"sekyro-mark__beam"})})}),(0,e.jsx)("path",{className:"sekyro-mark__brackets",d:Xe(-10,-10,248,t+20,16,30)})]})}c(ke,"qe");h(ke,"ScanMark");function Xe(a,t,n,o,r,f){let g=Math.min(r,f*.6);return[[a,t,1,1],[a+n,t,-1,1],[a,t+o,1,-1],[a+n,t+o,-1,-1]].map(([y,v,k,w])=>`M${y} ${v+w*f}V${v+w*g}Q${y} ${v} ${y+k*g} ${v}H${y+k*f}`).join("")}c(Xe,"bt");h(Xe,"brackets");function Fe({step:a,i18n:t,ageLead:n,onOpen:o,onChangeCountry:r,onChangeDocument:f,upload:g,onUpload:y}){let v=fe(t),k=V(t),w=a.documentType==="passport",x=ne(a),b=g==="sending",L=(0,i.useContext)(Ae)?.busy===!0;return(0,e.jsxs)("section",{className:"sekyro-step","data-testid":"sekyro-document",children:[(0,e.jsx)(ke,{passport:w}),(0,e.jsx)(ue,{title:v("native.doc.introTitle"),lead:n?t.t("doc.ageStepUp"):v("native.doc.introLead")}),(0,e.jsx)(oe,{step:a,i18n:t}),a.reason!==void 0&&xt.has(a.reason)?null:(0,e.jsxs)("ul",{className:"sekyro-tiprows",children:[(0,e.jsxs)("li",{children:[(0,e.jsx)(Y,{name:w?"passport":"card"}),v("native.doc.tip.flat")]}),(0,e.jsxs)("li",{children:[(0,e.jsx)(Y,{name:"light"}),v("native.doc.tip.glare")]}),(0,e.jsxs)("li",{children:[(0,e.jsx)(j,{name:"image"}),v("native.doc.tip.frame")]})]}),(0,e.jsx)(ge,{i18n:t,...f!==void 0?{onChangeDocument:f}:{},...r!==void 0?{onChangeCountry:r}:{}}),(0,e.jsx)(ye,{i18n:t,upload:g}),b?(0,e.jsx)("p",{className:"sekyro-text-muted",role:"status",children:t.t("doc.uploading")}):y!==void 0?(0,e.jsx)("p",{className:"sekyro-text-muted",children:k.t("doc.uploadHint")}):null,(0,e.jsxs)(he,{children:[(0,e.jsxs)(E,{full:!0,onClick:o,disabled:b||L,children:[(0,e.jsx)(Y,{name:"camera"}),v("native.doc.openCamera")]}),y!==void 0?(0,e.jsxs)(E,{full:!0,kind:"ghost",onClick:y,children:[(0,e.jsx)(j,{name:"image"}),k.t("doc.uploadInstead")]}):null]})]})}c(Fe,"wt");h(Fe,"DocumentIntro");function oe({step:a,i18n:t}){let n=ne(a);return n===null?null:(0,e.jsxs)(pe,{tone:"warning",children:[(0,e.jsx)("span",{children:t.t(n)}),(0,e.jsx)("span",{children:me(t,a.attemptsRemaining,a.attemptsExhausted)})]})}c(oe,"ye");h(oe,"ReasonNotice");function ge({i18n:a,onChangeCountry:t,onChangeDocument:n}){let o=fe(a);return n===void 0&&t===void 0?null:(0,e.jsxs)("div",{className:"sekyro-links",children:[n!==void 0?(0,e.jsx)("button",{type:"button",className:"sekyro-link",onClick:n,children:o("native.doc.changeDocument")}):null,t!==void 0?(0,e.jsx)("button",{type:"button",className:"sekyro-link",onClick:t,children:a.t("native.doc.changeCountry")}):null]})}c(ge,"Je");h(ge,"ChangeLinks");function ye({i18n:a,upload:t}){return t!=="unsupported"&&t!=="failed"?null:(0,e.jsx)(pe,{tone:"warning",children:(0,e.jsx)("span",{children:V(a).t(t==="unsupported"?"doc.uploadUnsupported":"doc.uploadFailed")})})}c(ye,"et");h(ye,"UploadNotice");function je({step:a,i18n:t,ageLead:n,upload:o,offered:r,onPick:f,onCamera:g,onChangeCountry:y,onChangeDocument:v}){let k=V(t),w=o==="sending";return(0,e.jsxs)("section",{className:"sekyro-step","data-testid":"sekyro-doc-upload-screen",children:[(0,e.jsx)(ke,{passport:a.documentType==="passport"}),(0,e.jsx)(ue,{title:k.t("doc.uploadTitle"),lead:n?t.t("doc.ageStepUp"):k.t("doc.uploadHint")}),n?(0,e.jsx)("p",{className:"sekyro-text-muted",children:k.t("doc.uploadHint")}):null,(0,e.jsx)(oe,{step:a,i18n:t}),(0,e.jsx)(ge,{i18n:t,...v!==void 0?{onChangeDocument:v}:{},...y!==void 0?{onChangeCountry:y}:{}}),(0,e.jsx)(ye,{i18n:t,upload:o}),w?(0,e.jsx)("p",{className:"sekyro-text-muted",role:"status",children:t.t("doc.uploading")}):null,(0,e.jsxs)(he,{children:[(0,e.jsxs)(E,{full:!0,onClick:f,disabled:w||!r||a.attemptsExhausted,children:[(0,e.jsx)(j,{name:"image"}),k.t("doc.source.upload")]}),g!==void 0?(0,e.jsxs)(E,{full:!0,kind:"ghost",onClick:g,disabled:w,children:[(0,e.jsx)(Y,{name:"camera"}),k.t("doc.source.camera")]}):null]})]})}c(je,"Ct");h(je,"DocumentUploadScreen");function ve(a,t,n){let o=a*.88,r=o/n;return{x:(a-o)/2,y:t*.42-r/2,w:o,h:r}}c(ve,"Qe");h(ve,"guideRect");var _t={too_far:"native.scan.closer",too_close:"native.scan.farther",focus_far:"native.scan.farther",glare:"native.scan.glare",too_bright:"native.scan.glare",too_dark:"native.scan.dark",blurry:"native.scan.blurry"},Lt=h(()=>typeof window<"u"&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,"reduceMotion");function Qe({step:a,i18n:t,liveMrz:n,onClose:o,attempts:r,onUpload:f}){let g=fe(t),y=(0,i.useContext)(Oe),v=(0,i.useRef)(y);v.current=y;let k=(0,i.useRef)(null),w=(0,i.useRef)(null),x=(0,i.useRef)(null),[b,L]=(0,i.useState)("idle"),[C,B]=(0,i.useState)(null),[M,H]=(0,i.useState)(null),[m,Q]=(0,i.useState)({w:0,h:0}),[z,X]=(0,i.useState)({hint:null,locking:!1,card:null,manualShutter:!1}),[P,q]=(0,i.useState)({}),[F,Ke]=(0,i.useState)(null),[we,et]=(0,i.useState)(null),[Ce,be]=(0,i.useState)(0),[ze,Se]=(0,i.useState)(null),[Z,Ne]=(0,i.useState)(null),D=a.documentType==="passport",J=D?1.42:1.586;De(!0),(0,i.useLayoutEffect)(()=>{let s=k.current;if(s===null)return;let u=h(()=>Q({w:s.clientWidth,h:s.clientHeight}),"measure");if(u(),typeof ResizeObserver>"u")return;let d=new ResizeObserver(u);return d.observe(s),()=>d.disconnect()},[]);let l=ve(m.w,m.h,J);(0,i.useEffect)(()=>{m.w===0||m.h===0||x.current?.setGuide?.({viewAspect:m.w/m.h,rect:{x:l.x/m.w,y:l.y/m.h,width:l.w/m.w,height:l.h/m.h}})},[m.w,m.h,l.x,l.y,l.w,l.h]),(0,i.useEffect)(()=>{let s=w.current;if(s===null)return;let u=a.capture({video:s,...n!==void 0?{liveMrz:n}:{}});x.current=u;let d=k.current;if(d!==null&&d.clientWidth>0&&d.clientHeight>0){let p=ve(d.clientWidth,d.clientHeight,J);u.setGuide?.({viewAspect:d.clientWidth/d.clientHeight,rect:{x:p.x/d.clientWidth,y:p.y/d.clientHeight,width:p.w/d.clientWidth,height:p.h/d.clientHeight}})}let T=new yt,N={scan:null,feedback:null,gate:null},R=h(p=>{N={...N,...p};let _=N.gate?.guide,st={phase:N.scan?.phase??"framing",hint:N.feedback?.reticle==="coaching"?N.feedback.key:null,card:_?.detected?{fill:_.fill,offsetX:_.offsetX,offsetY:_.offsetY}:null,manualShutter:N.scan?.manualShutter??!1},U=T.present(st,performance.now());X(O=>O.hint===U.hint&&O.locking===U.locking&&O.manualShutter===U.manualShutter&&O.card?.fill===U.card?.fill&&O.card?.offsetX===U.card?.offsetX&&O.card?.offsetY===U.card?.offsetY?O:U)},"present"),it=[u.on("state",L),u.on("feedback",p=>R({feedback:p})),u.on("gate",p=>R({gate:p})),u.on("scan",p=>{B(p),R({scan:p})}),u.on("captured",p=>{q(_=>({..._,[qe(p.side,D,_)]:p.previewDataUrl})),Ke(p.previewDataUrl),et(Je(s))}),u.on("error",p=>{H(p);let _=v.current;_!==null&&Ve(_,Ee("document",p,Math.max(0,r.current)))}),u.on("mrz",p=>{p.state==="mismatch"?Ne(p.format??null):Se(p)})];return r.current+=1,u.start().catch(()=>{}),()=>{for(let p of it)p();u.destroy(),x.current=null}},[a.issuer,a.documentType]);let $=C?.phase??"framing",A=$==="reading"||$==="result",re=$==="flipCue"||$==="reaskRecto",I=z.locking,xe=C?.captured.length??0;(0,i.useEffect)(()=>{I&&be(s=>s+1)},[I]),(0,i.useEffect)(()=>{xe>0&&be(s=>s+1)},[xe]);let tt=C?.expected??null;(0,i.useEffect)(()=>{Se(null)},[tt]),(0,i.useEffect)(()=>{if(Z===null)return;let s=setTimeout(()=>Ne(null),2e3);return()=>clearTimeout(s)},[Z]);let $e=re||A||a.documentType==="drivers_license"?null:We(ze,D),le=Z!==null?Z==="TD3"?"dcv3.mrz.looksLikePassport":"dcv3.mrz.looksLikeCard":$e,at=le===null?null:t.strings[le]??bt[t.locale][le],ie=ne(a),_e=z.hint===null?null:_t[z.hint]??`dcv2.${z.hint}`,nt=_e??($==="flipCue"?C?.notice==="same_face"?"doc.sameFace":"doc.flip":$==="reaskRecto"?"doc.reaskRecto":A?"native.scan.reading":$==="locking"||$==="capturing"||I?"native.scan.holdStill":C?.notice==="reread"?ie??"doc.reread":C?.notice==="technical"?"native.scan.retry":C?.notice==="blurry"?"native.scan.blurry":ie??(D?"doc.showPage":"doc.showSide")),se=at??g(nt),G=z.card,S=l;if(!I&&G!==null&&G.fill>=.45&&G.fill<=1.25&&!Lt()){let s=l.w*G.fill,u=s/J,d=l.x+l.w/2+l.w*Math.max(-.25,Math.min(.25,G.offsetX)),T=l.y+l.h/2+l.h*Math.max(-.25,Math.min(.25,G.offsetY));S={x:d-s/2,y:T-u/2,w:s,h:u}}let K=l.w*.045,ce=28,Le=Math.min(K,ce*.6),ot=[[S.x,S.y,1,1],[S.x+S.w,S.y,-1,1],[S.x,S.y+S.h,1,-1],[S.x+S.w,S.y+S.h,-1,-1]],rt=I?"is-locked":z.hint!==null?"is-coaching":"",lt=D?[{side:"single",label:"doc.progressPage"}]:[{side:"recto",label:"doc.progressFront"},{side:"verso",label:"doc.progressBack"}],Te=l.y+l.h+48,de={insetInlineStart:l.x,insetBlockStart:l.y,inlineSize:l.w,blockSize:l.h,borderRadius:K};return(0,e.jsx)("section",{className:"sekyro-lm","aria-label":se,"data-testid":"sekyro-document",children:(0,e.jsxs)("div",{ref:k,className:`sekyro-lm-stage${A?" is-reading":""}${re?" is-flip":""}`,style:{"--sekyro-guide-w":`${l.w}px`},children:[(0,e.jsx)("video",{ref:w,className:"sekyro-lm-video",playsInline:!0,muted:!0,autoPlay:!0,"aria-hidden":"true",onPointerUp:c(s=>{let u=s.currentTarget,d=u.getBoundingClientRect(),T=Math.max(d.width/(u.videoWidth||1),d.height/(u.videoHeight||1)),N=u.videoWidth*T,R=u.videoHeight*T;N>0&&R>0&&x.current?.focusAt((s.clientX-d.left+(N-d.width)/2)/N,(s.clientY-d.top+(R-d.height)/2)/R)},"onPointerUp")}),m.w>0?(0,e.jsxs)(e.Fragment,{children:[A&&we!==null?(0,e.jsx)("img",{className:"sekyro-lm-scene",src:we,alt:""}):null,A&&F!==null?(0,e.jsx)("img",{className:"sekyro-lm-frozen",src:F,alt:"",style:de}):null,(0,e.jsxs)("svg",{className:"sekyro-lm-overlay",viewBox:`0 0 ${m.w} ${m.h}`,"aria-hidden":"true",focusable:"false",children:[(0,e.jsxs)("defs",{children:[(0,e.jsxs)("linearGradient",{id:"sekyro-lm-top",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,e.jsx)("stop",{offset:"0",className:"sekyro-lm-ink",stopOpacity:"0.85"}),(0,e.jsx)("stop",{offset:"1",className:"sekyro-lm-ink",stopOpacity:"0"})]}),(0,e.jsxs)("linearGradient",{id:"sekyro-lm-bottom",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,e.jsx)("stop",{offset:"0",className:"sekyro-lm-ink",stopOpacity:"0"}),(0,e.jsx)("stop",{offset:"1",className:"sekyro-lm-ink",stopOpacity:"0.9"})]})]}),(0,e.jsx)("path",{className:"sekyro-lm-scrim",fillRule:"evenodd",d:`M0 0H${m.w}V${m.h}H0Z${Ze(l,K)}`}),(0,e.jsx)("rect",{width:m.w,height:Math.max(0,l.y),fill:"url(#sekyro-lm-top)"}),(0,e.jsx)("rect",{y:l.y+l.h,width:m.w,height:Math.max(0,m.h-l.y-l.h),fill:"url(#sekyro-lm-bottom)"}),(0,e.jsx)("g",{className:`sekyro-lm-brackets ${rt}`,children:ot.map(([s,u,d,T],N)=>(0,e.jsx)("path",{style:{transform:`translate(${s}px, ${u}px) scale(${d}, ${T})`},d:`M0 ${ce}V${Le}Q0 0 ${Le} 0H${ce}`},N))}),I?(0,e.jsx)("rect",{className:"sekyro-lm-trace",x:l.x,y:l.y,width:l.w,height:l.h,rx:K,pathLength:"1",style:{animationDuration:`${Ct}ms`}}):null]}),(0,e.jsx)("div",{className:"sekyro-lm-slot",style:de,"aria-hidden":"true",children:A?(0,e.jsx)("span",{className:"sekyro-lm-read is-repeating"}):Ce>0?(0,e.jsx)("span",{className:"sekyro-lm-read"},Ce):null})]}):null,$e!==null?(0,e.jsx)("div",{className:"sekyro-lm-slot",style:de,"aria-hidden":"true",children:(0,e.jsx)("span",{"data-testid":"sekyro-mrz-strip",className:`sekyro-lm-mrz${D?" is-page":""}${ze?.state==="valid"?" is-valid":""}`})}):null,(0,e.jsxs)("div",{className:"sekyro-lm-instruction",style:{insetBlockStart:l.y-64},children:[(0,e.jsx)("div",{role:"status","aria-live":"polite",children:(0,e.jsx)(Ue,{swapKey:se,className:"sekyro-lm-line",children:se})}),ie!==null&&$==="framing"&&_e===null?(0,e.jsx)("p",{className:"sekyro-lm-attempts",children:me(t,a.attemptsRemaining,a.attemptsExhausted)}):null]}),A?(0,e.jsxs)("p",{className:"sekyro-lm-under sekyro-lm-note",style:{insetBlockStart:Te-12},children:[(0,e.jsx)("span",{className:"sekyro-lm-spinner","aria-hidden":"true"}),g("native.scan.putDown")]}):re?(0,e.jsx)("div",{className:`sekyro-lm-under sekyro-lm-flip${$==="reaskRecto"?" is-toFront":""}`,style:{insetBlockStart:Te-20},"data-testid":"sekyro-flip-cue","aria-hidden":"true",children:(0,e.jsxs)("span",{className:"sekyro-lm-flip-card",style:{aspectRatio:String(J)},children:[(0,e.jsx)("span",{className:"sekyro-lm-flip-front"}),(0,e.jsx)("span",{className:"sekyro-lm-flip-back"})]})}):null,(0,e.jsxs)("div",{className:"sekyro-lm-controls",children:[(0,e.jsxs)("div",{className:"sekyro-lm-bar",children:[(0,e.jsx)("button",{type:"button",className:"sekyro-glass","aria-label":t.t("native.close"),onClick:o,children:(0,e.jsx)(Y,{name:"close"})}),C?.torchAvailable?(0,e.jsx)("button",{type:"button",className:`sekyro-glass${C.torch?" is-on":""}`,"aria-label":t.t("doc.torchOn"),"aria-pressed":C.torch,onClick:c(()=>x.current?.setTorch(!C.torch),"onClick"),children:(0,e.jsx)(j,{name:"flashlight"})}):null]}),M!==null?(0,e.jsxs)("div",{className:"sekyro-lm-error",role:"alert",children:[(0,e.jsx)("p",{children:t.t("doc.cameraBlocked")}),(0,e.jsx)("p",{children:t.t(M.kind==="permission"?"doc.cameraBlockedHint":He(M.kind))}),(0,e.jsx)(E,{onClick:c(()=>{H(null),r.current+=1,x.current?.retry()},"onClick"),children:t.t("doc.retryCamera")})]}):null,z.manualShutter?(0,e.jsx)("button",{type:"button",className:"sekyro-shutter","aria-label":t.t("doc.shutter"),onClick:c(()=>x.current?.shutter(),"onClick")}):null,(0,e.jsx)("ol",{className:"sekyro-lm-tray",children:lt.map(({side:s,label:u})=>{let d=C?.captured.includes(s)??!1;return(0,e.jsxs)("li",{className:d?"is-done":void 0,"aria-current":!d&&(D||C?.expected===s)?"step":void 0,children:[d?(0,e.jsxs)("span",{className:"sekyro-lm-thumb",children:[P[s]!==void 0?(0,e.jsx)("img",{src:P[s],alt:""}):null,(0,e.jsx)("svg",{className:"sekyro-lm-check",viewBox:"0 0 18 18","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M5 9.2l2.6 2.6L13 6.4"})})]}):null,g(u)]},s)})}),f!==void 0?(0,e.jsx)("button",{type:"button",className:"sekyro-lm-upload",onClick:f,children:V(t).t("doc.uploadInstead")}):null,b==="uploading"||b==="checking"?null:(0,e.jsx)(Re,{onStop:o})]}),b==="uploading"||b==="checking"?(0,e.jsx)("span",{className:"sekyro-visually-hidden",role:"status",children:b==="uploading"?t.t("doc.uploading"):g("native.scan.reading")}):null]})})}c(Qe,"_t");h(Qe,"LumiereScan");function qe(a,t,n){return t?"single":a==="recto"||a==="verso"?a:n.recto===void 0?"recto":"verso"}c(qe,"Lt");h(qe,"slotOf");function Ze({x:a,y:t,w:n,h:o},r){return`M${a+r} ${t}H${a+n-r}Q${a+n} ${t} ${a+n} ${t+r}V${t+o-r}Q${a+n} ${t+o} ${a+n-r} ${t+o}H${a+r}Q${a} ${t+o} ${a} ${t+o-r}V${t+r}Q${a} ${t} ${a+r} ${t}Z`}c(Ze,"zt");h(Ze,"roundedRect");function Je(a){let t=Math.round(a.videoWidth/4),n=Math.round(a.videoHeight/4);if(t===0||n===0||typeof document>"u")return null;try{let o=document.createElement("canvas");o.width=t,o.height=n;let r=o.getContext("2d");return r===null?null:(r.drawImage(a,0,0,t,n),o.toDataURL("image/jpeg",.7))}catch{return null}}c(Je,"xt");h(Je,"sceneSnapshot");export{$t as DocumentCaptureView,Ct as LOCK_TRACE_MS,St as UPLOAD_ACCEPT,ve as guideRect,We as mrzInstruction,qe as slotOf};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{a as O,b as v,c as W}from"./chunk-YVQ6LFN4.js";import{a as q,b as J,c as K}from"./chunk-
|
|
1
|
+
"use client";import{a as O,b as v,c as W}from"./chunk-YVQ6LFN4.js";import{a as q,b as J,c as K}from"./chunk-UGP2ZH7W.js";import{a as z}from"./chunk-AKUFZTNC.js";import{c as T,d as A}from"./chunk-HMNCXTZQ.js";import{a as w}from"./chunk-YRTHQZAW.js";import"./chunk-QOZB3DLY.js";import{H as j,K as E,a as oe,b as ce,c as N,t as U,y as R}from"./chunk-SIPFHN7E.js";import"./chunk-KLODCY6G.js";import"./chunk-H5GXVL63.js";import"./chunk-GIGTK355.js";import"./chunk-P7K7ELYZ.js";import{a as o}from"./chunk-5QL6W6FW.js";import"./chunk-CW56KMMH.js";import"./chunk-JS2IXPNL.js";import{a as u,c as P}from"./chunk-4FHWXBOB.js";var a=P(oe(),1),i=P(ce(),1);var Q={en:v,fr:W,ar:O,es:v,pt:v,de:v},C=6,pe=new Set(["eid_identifier_invalid","eid_code_invalid","eid_locked","eid_not_enrolled"]),X=o((e,d)=>{if(e===void 0)return 0;let h=Date.parse(e)-d;return Number.isFinite(h)?Math.max(0,Math.ceil(h/1e3)):0},"secondsUntil"),me=o(e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`,"mmss");function ue({step:e,i18n:d,className:h,onError:Y}){let I=d.strings,r=o((n,t)=>w(I[n]??Q[d.locale][n]??"",t),"t"),B=o((n,t)=>{let le=new Intl.PluralRules(d.locale).select(t),L=`${n}.${le}`,te=I[L]??Q[d.locale][L]??r(`${n}.other`);return w(te,{count:new Intl.NumberFormat(d.locale).format(t)})},"plural"),y=o(n=>e.providerName?r(`eid.${n}`,{provider:e.providerName}):r(`eid.${n}Generic`),"named"),[S,Z]=(0,a.useState)(""),[f,_]=(0,a.useState)(""),[c,D]=(0,a.useState)(!1),[b,p]=(0,a.useState)(null),s=e.phase==="code",F=K(s),l=(0,a.useId)(),ee=U(),[ie,ne]=q(e.reason==="eid_code_invalid",e.codeAttemptsRemaining??0,()=>_("")),m=o(async n=>{D(!0),p(null);try{await n()}catch(t){p(z(t,d.strings)),Y?.(t)}finally{D(!1)}},"run"),M=(0,a.useRef)(!1);(0,a.useEffect)(()=>{!e.identifierBound||s||e.reason!==void 0||M.current||(M.current=!0,m(()=>e.start()))},[e.identifierBound,s,e.reason]),(0,a.useEffect)(()=>{(e.reason==="eid_code_invalid"||e.codeExpiresAt!==void 0)&&_("")},[e.reason,e.codeExpiresAt,e.codeAttemptsRemaining]);let H=(0,a.useRef)(s);(0,a.useEffect)(()=>{s&&!H.current&&document.getElementById(`${l}-code`)?.focus(),H.current=s},[s,l]);let k=e.reason==="eid_locked",V=X(e.codeExpiresAt,F),x=s&&e.codeExpiresAt!==void 0&&V===0,$=X(e.resendAvailableAt,F),G=e.resendsRemaining===0||e.reason==="eid_resend_limit",re=o(n=>{if(n.preventDefault(),s){f.length===C&&!k&&m(()=>e.verify(f));return}if(e.identifierBound){m(()=>e.start());return}let t=A(S);if(e.country==="MR"){if(!/^\d{10}$/.test(t))return p("population.invalid");if(!T(t))return p("population.reason_nni_invalid")}m(()=>e.start(t))},"onSubmit"),g=e.reason?.startsWith("eid_")?e.reason:void 0,ae=(0,i.jsxs)(i.Fragment,{children:[g!==void 0?(0,i.jsxs)(E,{tone:pe.has(g)?"danger":"warning",children:[(0,i.jsx)("span",{children:r(`reasons.${g}`)}),g==="eid_code_invalid"&&e.codeAttemptsRemaining!==void 0?(0,i.jsx)("span",{children:B("eid.codeAttemptsRemaining",e.codeAttemptsRemaining)}):null,e.canUseCamera?(0,i.jsx)(N,{kind:"secondary",disabled:c,onClick:u(()=>{m(()=>e.useCamera())},"onClick"),children:r("eid.useCamera")}):null]}):null,b!==null?(0,i.jsx)(E,{tone:"danger",children:(0,i.jsx)("span",{children:d.t(b)})}):null]}),[de,se]=s?[y("codeTitle"),y("codeHelp")]:[y("identifierTitle"),y(e.identifierBound?"boundDescription":"identifierDescription")];return(0,i.jsxs)("form",{className:`sekyro-step sekyro-otp${h?` ${h}`:""}`,"aria-labelledby":l,onSubmit:re,noValidate:!0,"data-testid":"sekyro-eid",children:[(0,i.jsxs)("div",{className:"sekyro-heading",children:[(0,i.jsx)("h2",{id:l,ref:ee,tabIndex:-1,className:"sekyro-text-body",children:de}),(0,i.jsx)("p",{className:"sekyro-text-muted",children:s&&e.context.simulation!==void 0?(0,i.jsx)(j,{template:d.t("sandbox.otpHint"),code:e.context.simulation.otpCode}):se}),e.afterPass==="continue"?(0,i.jsx)("p",{className:"sekyro-text-muted","data-testid":"sekyro-eid-continue",children:e.providerName?r("eid.continueHint",{provider:e.providerName}):r("eid.continueHintGeneric")}):null]}),ae,s?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"sekyro-field",children:[(0,i.jsx)("label",{className:"sekyro-label",htmlFor:`${l}-code`,children:r("eid.codeLabel")}),k?(0,i.jsx)("input",{id:`${l}-code`,className:"sekyro-input sekyro-input--number",dir:"ltr",value:f,disabled:!0,readOnly:!0}):(0,i.jsx)(J,{id:`${l}-code`,value:f,length:C,invalid:ie,onChange:u(n=>{p(null),n!==""&&ne(),_(n)},"onChange")}),e.codeExpiresAt!==void 0?(0,i.jsx)("span",{className:`sekyro-help sekyro-otp-expiry${x?" is-danger":""}`,children:x?r("eid.expired"):r("eid.expiresIn",{time:me(V)})}):null]}),(0,i.jsx)("span",{className:"sekyro-visually-hidden",role:"status","aria-live":"polite",children:x?r("eid.expired"):""}),(0,i.jsxs)(R,{children:[(0,i.jsx)(N,{type:"submit",full:!0,disabled:c||f.length!==C||k,"aria-busy":c||void 0,children:r("eid.verify")}),(0,i.jsx)("div",{className:"sekyro-resend-row",children:G?(0,i.jsx)("p",{className:"sekyro-resend is-waiting",children:r("eid.noResendsLeft")}):(0,i.jsx)("button",{type:"button",className:"sekyro-link sekyro-resend",disabled:c||$>0||k,onClick:u(()=>{m(()=>e.resend())},"onClick"),children:$>0?r("eid.resendIn",{seconds:$}):r("eid.resend")})}),!G&&e.resendsRemaining!==void 0?(0,i.jsx)("p",{className:"sekyro-help sekyro-center",children:B("eid.resendsRemaining",e.resendsRemaining)}):null]})]}):(0,i.jsxs)(i.Fragment,{children:[e.identifierBound?null:(0,i.jsxs)("div",{className:"sekyro-field",children:[(0,i.jsx)("label",{className:"sekyro-label",htmlFor:`${l}-nni`,children:d.t("population.label")}),(0,i.jsx)("input",{id:`${l}-nni`,className:"sekyro-input sekyro-input--number",dir:"ltr",inputMode:"numeric",autoComplete:"off",placeholder:d.t("population.placeholder"),value:S,"aria-describedby":`${l}-nni-help`,"aria-invalid":b==="population.invalid"||b==="population.reason_nni_invalid"||void 0,onChange:u(n=>{p(null),Z(A(n.target.value).replace(/\D/g,"").slice(0,10))},"onChange")}),(0,i.jsx)("span",{id:`${l}-nni-help`,className:"sekyro-help",children:d.t("population.helper")})]}),(0,i.jsx)(R,{children:(0,i.jsx)(N,{type:"submit",full:!0,disabled:c,"aria-busy":c||void 0,children:r("eid.start")})})]})]})}u(ue,"Ae");o(ue,"EidView");export{ue as EidView};
|
package/dist/cdn/chunks/{email-otp-view-NRZCAJJ4-BJNXOVUF.js → email-otp-view-NRZCAJJ4-UFM2YDCD.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{a as J,b as K,c as Q}from"./chunk-RKH7O2P5.js";import{a as B}from"./chunk-MJEQ5ANO.js";import"./chunk-SGUCIULX.js";import{a as G}from"./chunk-YRTHQZAW.js";import"./chunk-QOZB3DLY.js";import{A as j,H as U,K as y,L as Y,a as me,b as pe,c as x,w as P,y as T}from"./chunk-SIPFHN7E.js";import{A as F}from"./chunk-ZYZPLDA2.js";import"./chunk-7MV4CI4L.js";import"./chunk-434MMEWK.js";import"./chunk-P7K7ELYZ.js";import{a as r}from"./chunk-5QL6W6FW.js";import"./chunk-CW56KMMH.js";import"./chunk-JS2IXPNL.js";import{a as p,c as W}from"./chunk-4FHWXBOB.js";var s=W(me(),1),e=W(pe(),1);var ce={"emailOtp.reason_otp_daily_cap_reached":"لا يمكننا إرسال رمز إلى بريدك الإلكتروني اليوم. اختر طريقة أخرى للتحقق إن كانت متاحة، أو حاول مرة أخرى لاحقًا.","emailOtp.reason_payment_method_required":"طريقة التحقق هذه غير متاحة حاليًا. اختر طريقة أخرى للتحقق إن كانت متاحة.","emailOtp.reason_spend_cap_reached":"طريقة التحقق هذه غير متاحة حاليًا. اختر طريقة أخرى للتحقق إن كانت متاحة.","emailOtp.reason_insufficient_balance":"طريقة التحقق هذه غير متاحة حاليًا. اختر طريقة أخرى للتحقق إن كانت متاحة.","emailOtp.reason_account_verification_required":"طريقة التحقق هذه غير متاحة حاليًا. اختر طريقة أخرى للتحقق إن كانت متاحة.","emailOtp.sendTitle":"تحقّق من بريدك الإلكتروني","emailOtp.sendDescription":"سنرسل إليك عبر البريد الإلكتروني رمزًا يُستخدم مرة واحدة لتأكيد أن هذا العنوان يخصّك","emailOtp.prefilledNotice":"سنرسل رمز تحقّق إلى بريدك الإلكتروني المسجّل.","emailOtp.emailLabel":"البريد الإلكتروني","emailOtp.emailHelper":"سنرسل رمزًا يُستخدم مرة واحدة إلى هذا العنوان","emailOtp.emailPlaceholder":"عنوان بريدك الإلكتروني","emailOtp.emailInvalid":"أدخل عنوان بريد إلكتروني صالحًا","emailOtp.send":"أرسل لي رمزًا عبر البريد الإلكتروني","emailOtp.verifyTitle":"أدخل الرمز","emailOtp.verifyDescription":"أدخل الرمز المكوّن من 6 أرقام الذي أرسلناه إلى بريدك الإلكتروني لإتمام التحقّق من عنوانك","emailOtp.sentTo":"أرسلنا رمزًا مكوّنًا من 6 أرقام إلى {email}","emailOtp.codeLabel":"رمز التحقّق","emailOtp.codeHelper":"أدخل الرمز المكوّن من 6 أرقام الوارد في الرسالة","emailOtp.verify":"تحقّق من الرمز","emailOtp.resend":"إعادة إرسال الرمز","emailOtp.resendIn":"إعادة إرسال الرمز خلال {seconds} ثانية","emailOtp.expiresIn":"ينتهي الرمز خلال {time}","emailOtp.expired":"انتهت صلاحية الرمز. أعد إرسال رمز جديد","emailOtp.reason_otp_mismatch":"الرمز غير صحيح. تحقّق منه وأعد إدخاله","emailOtp.reason_otp_expired":"انتهت صلاحية الرمز. أعد إرسال رمز جديد للمتابعة","emailOtp.reason_otp_send_failed":"تعذّر إرسال الرسالة. أعد المحاولة لاحقًا. إذا تكرر ذلك، فتواصل مع الجهة التي طلبت منك التحقق.","emailOtp.reason_otp_rate_limited":"طُلبت رموز كثيرة لهذا العنوان. أعد المحاولة لاحقًا أو أدخل عنوانًا آخر.","emailOtp.reason_email_invalid":"لا يمكننا الإرسال إلى هذا العنوان. تحقّق منه أو أدخل عنوانًا آخر","emailOtp.reason_email_disposable":"استخدم بريدًا إلكترونيًا دائمًا، وليس عنوانًا مؤقتًا","emailOtp.changeEmail":"تغيير البريد الإلكتروني","emailOtp.backToCode":"العودة إلى الرمز","emailOtp.reason_otp_resend_limit":"لا يمكنك طلب رموز أخرى. أدخل آخر رمز وصلك"},b={"emailOtp.reason_otp_daily_cap_reached":"We can't email you a code today. Choose another way to verify if one is offered, or try again later.","emailOtp.reason_payment_method_required":"This verification method is not available right now. Choose another way to verify if one is offered.","emailOtp.reason_spend_cap_reached":"This verification method is not available right now. Choose another way to verify if one is offered.","emailOtp.reason_insufficient_balance":"This verification method is not available right now. Choose another way to verify if one is offered.","emailOtp.reason_account_verification_required":"This verification method is not available right now. Choose another way to verify if one is offered.","emailOtp.sendTitle":"Verify your email address","emailOtp.sendDescription":"We'll email you a one-time code to confirm this address is yours","emailOtp.prefilledNotice":"We'll send a verification code to your registered email address.","emailOtp.emailLabel":"Email address","emailOtp.emailHelper":"We'll send a one-time code to this address","emailOtp.emailPlaceholder":"Your email address","emailOtp.emailInvalid":"Enter a valid email address","emailOtp.send":"Email me a code","emailOtp.verifyTitle":"Enter the code","emailOtp.verifyDescription":"Type the 6-digit code we emailed you to finish verifying your address","emailOtp.sentTo":"We sent a 6-digit code to {email}","emailOtp.codeLabel":"Verification code","emailOtp.codeHelper":"Enter the 6-digit code from the email","emailOtp.verify":"Verify code","emailOtp.resend":"Resend code","emailOtp.resendIn":"Resend code in {seconds}s","emailOtp.expiresIn":"Code expires in {time}","emailOtp.expired":"That code has expired. Resend a new one","emailOtp.reason_otp_mismatch":"That code was incorrect. Check it and enter it again","emailOtp.reason_otp_expired":"That code has expired. Resend a new code to continue","emailOtp.reason_otp_send_failed":"We couldn't send the email. Try again later. If it keeps happening, contact the organization that asked you to verify.","emailOtp.reason_otp_rate_limited":"Too many codes were requested for this address. Try again later, or enter another address.","emailOtp.reason_email_invalid":"We can't send to this address. Check it or enter another one","emailOtp.reason_email_disposable":"Use a permanent email address, not a temporary one","emailOtp.changeEmail":"Change email","emailOtp.backToCode":"Back to code","emailOtp.reason_otp_resend_limit":"You can't get more codes. Enter the last code you received"},ue={"emailOtp.reason_otp_daily_cap_reached":"Nous ne pouvons pas vous envoyer de code par e-mail aujourd'hui. Choisissez une autre méthode si elle est proposée, ou réessayez plus tard.","emailOtp.reason_payment_method_required":"Cette méthode de vérification n'est pas disponible pour le moment. Choisissez une autre méthode si elle est proposée.","emailOtp.reason_spend_cap_reached":"Cette méthode de vérification n'est pas disponible pour le moment. Choisissez une autre méthode si elle est proposée.","emailOtp.reason_insufficient_balance":"Cette méthode de vérification n'est pas disponible pour le moment. Choisissez une autre méthode si elle est proposée.","emailOtp.reason_account_verification_required":"Cette méthode de vérification n'est pas disponible pour le moment. Choisissez une autre méthode si elle est proposée.","emailOtp.sendTitle":"Vérifiez votre e-mail","emailOtp.sendDescription":"Nous vous enverrons par e-mail un code à usage unique pour confirmer que cette adresse vous appartient","emailOtp.prefilledNotice":"Nous enverrons un code de vérification à votre adresse e-mail enregistrée.","emailOtp.emailLabel":"Adresse e-mail","emailOtp.emailHelper":"Nous enverrons un code à usage unique à cette adresse","emailOtp.emailPlaceholder":"Votre adresse e-mail","emailOtp.emailInvalid":"Saisissez une adresse e-mail valide","emailOtp.send":"M'envoyer un code par e-mail","emailOtp.verifyTitle":"Saisissez le code","emailOtp.verifyDescription":"Saisissez le code à 6 chiffres que nous vous avons envoyé par e-mail pour finaliser la vérification de votre adresse","emailOtp.sentTo":"Nous avons envoyé un code à 6 chiffres à {email}","emailOtp.codeLabel":"Code de vérification","emailOtp.codeHelper":"Saisissez le code à 6 chiffres reçu par e-mail","emailOtp.verify":"Vérifier le code","emailOtp.resend":"Renvoyer le code","emailOtp.resendIn":"Renvoyer le code dans {seconds} s","emailOtp.expiresIn":"Le code expire dans {time}","emailOtp.expired":"Ce code a expiré. Renvoyez-en un nouveau","emailOtp.reason_otp_mismatch":"Ce code est incorrect. Vérifiez-le et saisissez-le à nouveau","emailOtp.reason_otp_expired":"Ce code a expiré. Renvoyez un nouveau code pour continuer","emailOtp.reason_otp_send_failed":"Nous n'avons pas pu envoyer l'e-mail. Réessayez plus tard. Si le problème continue, contactez l'organisation qui vous a demandé de vous vérifier.","emailOtp.reason_otp_rate_limited":"Trop de codes ont été demandés pour cette adresse. Réessayez plus tard ou saisissez une autre adresse.","emailOtp.reason_email_invalid":"Nous ne pouvons pas envoyer à cette adresse. Vérifiez-la ou saisissez-en une autre","emailOtp.reason_email_disposable":"Utilisez une adresse e-mail permanente, pas une adresse temporaire","emailOtp.changeEmail":"Changer d'adresse e-mail","emailOtp.backToCode":"Retour au code","emailOtp.reason_otp_resend_limit":"Vous ne pouvez plus demander de code. Saisissez le dernier code reçu"},he={en:b,fr:ue,ar:ce,es:b,pt:b,de:b},X=r((a,n,h)=>{if(a===void 0)return 0;let _=Date.parse(a)-n;return Number.isFinite(_)?Math.min(h,Math.max(0,Math.ceil(_/1e3))):0},"secondsUntil"),_e=600,Oe=60,fe=r(a=>`${Math.floor(a/60)}:${String(a%60).padStart(2,"0")}`,"mmss"),Z=new Set(["otp_expired","otp_send_failed","otp_rate_limited","otp_resend_limit","email_invalid","email_disposable","otp_daily_cap_reached","payment_method_required","spend_cap_reached","insufficient_balance","account_verification_required"]);function ve({step:a,i18n:n,className:h,defaultEmail:_="",onError:ee}){let i=r((t,o)=>G(n.strings[t]??he[n.locale][t],o),"t"),[N,ae]=(0,s.useState)(_),[O,z]=(0,s.useState)(""),[l,E]=(0,s.useState)(!1),[w,q]=(0,s.useState)(null),[g,c]=(0,s.useState)(!1),[I,ie]=(0,s.useState)(null),u=(0,s.useRef)(null),f=a.phase==="verify",m=f&&!g,R=Q(f),d=(0,s.useId)(),[te,se]=J(a.reason==="otp_mismatch",a.attemptsRemaining,()=>z("")),V=f?a.codeExpiresAt??"sent":null;(0,s.useEffect)(()=>{V!==null&&(c(!1),u.current!==null&&!Z.has(a.reason??"")&&ie(u.current),u.current=null)},[V]);let S=r(async t=>{E(!0),q(null);try{await t()}catch(o){q(o instanceof F&&o.field==="email"?i("emailOtp.emailInvalid"):n.t(B(o,n.strings))),ee?.(o)}finally{E(!1)}},"run"),$=r(t=>{let o=a.needsEmail?t?I:N.trim():null;u.current=o,S(async()=>{try{await a.send(o!==null?{email:o}:{})}catch(de){throw u.current=null,de}})},"send"),D=r(t=>{S(()=>a.verify(t))},"submitCode"),oe=r(t=>{t.preventDefault(),m?D(O):$(!1)},"onSubmit"),k=X(a.codeExpiresAt,R,_e),C=X(a.resendAvailableAt,R,Oe),v=m&&a.codeExpiresAt!==void 0&&k===0,L=a.needsEmail&&!a.attemptsExhausted,H=f&&(a.codeExpiresAt===void 0||k>0),A=m&&L?()=>c(!0):g&&H?()=>c(!1):null;j(A===null?null:l?()=>{}:A);let[le,re]=i("emailOtp.sentTo").split("{email}"),M=a.context.simulation?.otpCode,ne=a.reason==="otp_mismatch"?(0,e.jsxs)(y,{tone:"danger",children:[(0,e.jsx)("span",{children:i("emailOtp.reason_otp_mismatch")}),(0,e.jsx)("span",{children:Y(n,a.attemptsRemaining,a.attemptsExhausted)})]}):a.reason!==void 0&&Z.has(a.reason)?(0,e.jsx)(y,{tone:"warning",children:(0,e.jsx)("span",{children:i(`emailOtp.reason_${a.reason}`)})}):null;return(0,e.jsxs)("form",{className:`sekyro-step sekyro-otp${h?` ${h}`:""}`,"aria-labelledby":d,onSubmit:oe,noValidate:!0,children:[(0,e.jsx)(P,{id:d,title:i(m?"emailOtp.verifyTitle":"emailOtp.sendTitle"),lead:m&&M!==void 0?(0,e.jsx)(U,{template:n.t("sandbox.otpHint"),code:M}):m?(0,e.jsxs)(e.Fragment,{children:[le,(0,e.jsx)("bdi",{dir:"ltr",className:"sekyro-mono",children:I??a.sentToMasked}),re]}):i("emailOtp.sendDescription")}),ne,w!==null?(0,e.jsx)(y,{tone:"danger",children:(0,e.jsx)("span",{children:w})}):null,m?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"sekyro-field",children:[(0,e.jsx)("label",{className:"sekyro-label",htmlFor:`${d}-code`,children:i("emailOtp.codeLabel")}),(0,e.jsx)(K,{id:`${d}-code`,value:O,invalid:te,onChange:p(t=>{t!==""&&se(),z(t),t.length===6&&O.length!==6&&!l&&!a.attemptsExhausted&&D(t)},"onChange")}),(0,e.jsx)("span",{className:`sekyro-help sekyro-otp-expiry${v?" is-danger":""}`,"aria-hidden":!v||void 0,children:v?i("emailOtp.expired"):i("emailOtp.expiresIn",{time:fe(k)})})]}),(0,e.jsx)("span",{className:"sekyro-visually-hidden",role:"status","aria-live":"polite",children:v?i("emailOtp.expired"):""}),(0,e.jsxs)(T,{children:[(0,e.jsx)(x,{type:"submit",full:!0,disabled:l||O.length!==6,"aria-busy":l||void 0,children:i("emailOtp.verify")}),(0,e.jsxs)("div",{className:"sekyro-resend-row",children:[(0,e.jsx)("button",{type:"button",className:"sekyro-link sekyro-resend",disabled:l||C>0,onClick:p(()=>$(!0),"onClick"),children:C>0?i("emailOtp.resendIn",{seconds:C}):i("emailOtp.resend")}),L?(0,e.jsx)("button",{type:"button",className:"sekyro-link sekyro-resend",disabled:l,onClick:p(()=>c(!0),"onClick"),"data-testid":"sekyro-otp-change",children:i("emailOtp.changeEmail")}):null]})]})]}):(0,e.jsxs)(e.Fragment,{children:[a.needsEmail?(0,e.jsxs)("div",{className:"sekyro-field",children:[(0,e.jsx)("label",{className:"sekyro-label",htmlFor:`${d}-email`,children:i("emailOtp.emailLabel")}),(0,e.jsx)("input",{id:`${d}-email`,className:"sekyro-input",type:"email",dir:"ltr",inputMode:"email",autoComplete:"email",autoCapitalize:"none",spellCheck:!1,placeholder:i("emailOtp.emailPlaceholder"),value:N,"aria-describedby":`${d}-email-help`,onChange:p(t=>ae(t.target.value),"onChange")}),(0,e.jsx)("span",{id:`${d}-email-help`,className:"sekyro-help",children:i("emailOtp.emailHelper")})]}):(0,e.jsx)("p",{className:"sekyro-text-muted",children:i("emailOtp.prefilledNotice")}),(0,e.jsxs)(T,{children:[(0,e.jsx)(x,{type:"submit",full:!0,disabled:l,"aria-busy":l||void 0,children:i("emailOtp.send")}),g&&H?(0,e.jsx)("button",{type:"button",className:"sekyro-link sekyro-resend",disabled:l,onClick:p(()=>c(!1),"onClick"),"data-testid":"sekyro-otp-back-to-code",children:i("emailOtp.backToCode")}):null]})]})]})}p(ve,"Ve");r(ve,"EmailOtpView");export{ve as EmailOtpView};
|
|
1
|
+
"use client";import{a as J,b as K,c as Q}from"./chunk-UGP2ZH7W.js";import{a as B}from"./chunk-AKUFZTNC.js";import"./chunk-HMNCXTZQ.js";import{a as G}from"./chunk-YRTHQZAW.js";import"./chunk-QOZB3DLY.js";import{A as j,H as U,K as y,L as Y,a as me,b as pe,c as x,w as P,y as T}from"./chunk-SIPFHN7E.js";import{A as F}from"./chunk-KLODCY6G.js";import"./chunk-H5GXVL63.js";import"./chunk-GIGTK355.js";import"./chunk-P7K7ELYZ.js";import{a as r}from"./chunk-5QL6W6FW.js";import"./chunk-CW56KMMH.js";import"./chunk-JS2IXPNL.js";import{a as p,c as W}from"./chunk-4FHWXBOB.js";var s=W(me(),1),e=W(pe(),1);var ce={"emailOtp.reason_otp_daily_cap_reached":"لا يمكننا إرسال رمز إلى بريدك الإلكتروني اليوم. اختر طريقة أخرى للتحقق إن كانت متاحة، أو حاول مرة أخرى لاحقًا.","emailOtp.reason_payment_method_required":"طريقة التحقق هذه غير متاحة حاليًا. اختر طريقة أخرى للتحقق إن كانت متاحة.","emailOtp.reason_spend_cap_reached":"طريقة التحقق هذه غير متاحة حاليًا. اختر طريقة أخرى للتحقق إن كانت متاحة.","emailOtp.reason_insufficient_balance":"طريقة التحقق هذه غير متاحة حاليًا. اختر طريقة أخرى للتحقق إن كانت متاحة.","emailOtp.reason_account_verification_required":"طريقة التحقق هذه غير متاحة حاليًا. اختر طريقة أخرى للتحقق إن كانت متاحة.","emailOtp.sendTitle":"تحقّق من بريدك الإلكتروني","emailOtp.sendDescription":"سنرسل إليك عبر البريد الإلكتروني رمزًا يُستخدم مرة واحدة لتأكيد أن هذا العنوان يخصّك","emailOtp.prefilledNotice":"سنرسل رمز تحقّق إلى بريدك الإلكتروني المسجّل.","emailOtp.emailLabel":"البريد الإلكتروني","emailOtp.emailHelper":"سنرسل رمزًا يُستخدم مرة واحدة إلى هذا العنوان","emailOtp.emailPlaceholder":"عنوان بريدك الإلكتروني","emailOtp.emailInvalid":"أدخل عنوان بريد إلكتروني صالحًا","emailOtp.send":"أرسل لي رمزًا عبر البريد الإلكتروني","emailOtp.verifyTitle":"أدخل الرمز","emailOtp.verifyDescription":"أدخل الرمز المكوّن من 6 أرقام الذي أرسلناه إلى بريدك الإلكتروني لإتمام التحقّق من عنوانك","emailOtp.sentTo":"أرسلنا رمزًا مكوّنًا من 6 أرقام إلى {email}","emailOtp.codeLabel":"رمز التحقّق","emailOtp.codeHelper":"أدخل الرمز المكوّن من 6 أرقام الوارد في الرسالة","emailOtp.verify":"تحقّق من الرمز","emailOtp.resend":"إعادة إرسال الرمز","emailOtp.resendIn":"إعادة إرسال الرمز خلال {seconds} ثانية","emailOtp.expiresIn":"ينتهي الرمز خلال {time}","emailOtp.expired":"انتهت صلاحية الرمز. أعد إرسال رمز جديد","emailOtp.reason_otp_mismatch":"الرمز غير صحيح. تحقّق منه وأعد إدخاله","emailOtp.reason_otp_expired":"انتهت صلاحية الرمز. أعد إرسال رمز جديد للمتابعة","emailOtp.reason_otp_send_failed":"تعذّر إرسال الرسالة. أعد المحاولة لاحقًا. إذا تكرر ذلك، فتواصل مع الجهة التي طلبت منك التحقق.","emailOtp.reason_otp_rate_limited":"طُلبت رموز كثيرة لهذا العنوان. أعد المحاولة لاحقًا أو أدخل عنوانًا آخر.","emailOtp.reason_email_invalid":"لا يمكننا الإرسال إلى هذا العنوان. تحقّق منه أو أدخل عنوانًا آخر","emailOtp.reason_email_disposable":"استخدم بريدًا إلكترونيًا دائمًا، وليس عنوانًا مؤقتًا","emailOtp.changeEmail":"تغيير البريد الإلكتروني","emailOtp.backToCode":"العودة إلى الرمز","emailOtp.reason_otp_resend_limit":"لا يمكنك طلب رموز أخرى. أدخل آخر رمز وصلك"},b={"emailOtp.reason_otp_daily_cap_reached":"We can't email you a code today. Choose another way to verify if one is offered, or try again later.","emailOtp.reason_payment_method_required":"This verification method is not available right now. Choose another way to verify if one is offered.","emailOtp.reason_spend_cap_reached":"This verification method is not available right now. Choose another way to verify if one is offered.","emailOtp.reason_insufficient_balance":"This verification method is not available right now. Choose another way to verify if one is offered.","emailOtp.reason_account_verification_required":"This verification method is not available right now. Choose another way to verify if one is offered.","emailOtp.sendTitle":"Verify your email address","emailOtp.sendDescription":"We'll email you a one-time code to confirm this address is yours","emailOtp.prefilledNotice":"We'll send a verification code to your registered email address.","emailOtp.emailLabel":"Email address","emailOtp.emailHelper":"We'll send a one-time code to this address","emailOtp.emailPlaceholder":"Your email address","emailOtp.emailInvalid":"Enter a valid email address","emailOtp.send":"Email me a code","emailOtp.verifyTitle":"Enter the code","emailOtp.verifyDescription":"Type the 6-digit code we emailed you to finish verifying your address","emailOtp.sentTo":"We sent a 6-digit code to {email}","emailOtp.codeLabel":"Verification code","emailOtp.codeHelper":"Enter the 6-digit code from the email","emailOtp.verify":"Verify code","emailOtp.resend":"Resend code","emailOtp.resendIn":"Resend code in {seconds}s","emailOtp.expiresIn":"Code expires in {time}","emailOtp.expired":"That code has expired. Resend a new one","emailOtp.reason_otp_mismatch":"That code was incorrect. Check it and enter it again","emailOtp.reason_otp_expired":"That code has expired. Resend a new code to continue","emailOtp.reason_otp_send_failed":"We couldn't send the email. Try again later. If it keeps happening, contact the organization that asked you to verify.","emailOtp.reason_otp_rate_limited":"Too many codes were requested for this address. Try again later, or enter another address.","emailOtp.reason_email_invalid":"We can't send to this address. Check it or enter another one","emailOtp.reason_email_disposable":"Use a permanent email address, not a temporary one","emailOtp.changeEmail":"Change email","emailOtp.backToCode":"Back to code","emailOtp.reason_otp_resend_limit":"You can't get more codes. Enter the last code you received"},ue={"emailOtp.reason_otp_daily_cap_reached":"Nous ne pouvons pas vous envoyer de code par e-mail aujourd'hui. Choisissez une autre méthode si elle est proposée, ou réessayez plus tard.","emailOtp.reason_payment_method_required":"Cette méthode de vérification n'est pas disponible pour le moment. Choisissez une autre méthode si elle est proposée.","emailOtp.reason_spend_cap_reached":"Cette méthode de vérification n'est pas disponible pour le moment. Choisissez une autre méthode si elle est proposée.","emailOtp.reason_insufficient_balance":"Cette méthode de vérification n'est pas disponible pour le moment. Choisissez une autre méthode si elle est proposée.","emailOtp.reason_account_verification_required":"Cette méthode de vérification n'est pas disponible pour le moment. Choisissez une autre méthode si elle est proposée.","emailOtp.sendTitle":"Vérifiez votre e-mail","emailOtp.sendDescription":"Nous vous enverrons par e-mail un code à usage unique pour confirmer que cette adresse vous appartient","emailOtp.prefilledNotice":"Nous enverrons un code de vérification à votre adresse e-mail enregistrée.","emailOtp.emailLabel":"Adresse e-mail","emailOtp.emailHelper":"Nous enverrons un code à usage unique à cette adresse","emailOtp.emailPlaceholder":"Votre adresse e-mail","emailOtp.emailInvalid":"Saisissez une adresse e-mail valide","emailOtp.send":"M'envoyer un code par e-mail","emailOtp.verifyTitle":"Saisissez le code","emailOtp.verifyDescription":"Saisissez le code à 6 chiffres que nous vous avons envoyé par e-mail pour finaliser la vérification de votre adresse","emailOtp.sentTo":"Nous avons envoyé un code à 6 chiffres à {email}","emailOtp.codeLabel":"Code de vérification","emailOtp.codeHelper":"Saisissez le code à 6 chiffres reçu par e-mail","emailOtp.verify":"Vérifier le code","emailOtp.resend":"Renvoyer le code","emailOtp.resendIn":"Renvoyer le code dans {seconds} s","emailOtp.expiresIn":"Le code expire dans {time}","emailOtp.expired":"Ce code a expiré. Renvoyez-en un nouveau","emailOtp.reason_otp_mismatch":"Ce code est incorrect. Vérifiez-le et saisissez-le à nouveau","emailOtp.reason_otp_expired":"Ce code a expiré. Renvoyez un nouveau code pour continuer","emailOtp.reason_otp_send_failed":"Nous n'avons pas pu envoyer l'e-mail. Réessayez plus tard. Si le problème continue, contactez l'organisation qui vous a demandé de vous vérifier.","emailOtp.reason_otp_rate_limited":"Trop de codes ont été demandés pour cette adresse. Réessayez plus tard ou saisissez une autre adresse.","emailOtp.reason_email_invalid":"Nous ne pouvons pas envoyer à cette adresse. Vérifiez-la ou saisissez-en une autre","emailOtp.reason_email_disposable":"Utilisez une adresse e-mail permanente, pas une adresse temporaire","emailOtp.changeEmail":"Changer d'adresse e-mail","emailOtp.backToCode":"Retour au code","emailOtp.reason_otp_resend_limit":"Vous ne pouvez plus demander de code. Saisissez le dernier code reçu"},he={en:b,fr:ue,ar:ce,es:b,pt:b,de:b},X=r((a,n,h)=>{if(a===void 0)return 0;let _=Date.parse(a)-n;return Number.isFinite(_)?Math.min(h,Math.max(0,Math.ceil(_/1e3))):0},"secondsUntil"),_e=600,Oe=60,fe=r(a=>`${Math.floor(a/60)}:${String(a%60).padStart(2,"0")}`,"mmss"),Z=new Set(["otp_expired","otp_send_failed","otp_rate_limited","otp_resend_limit","email_invalid","email_disposable","otp_daily_cap_reached","payment_method_required","spend_cap_reached","insufficient_balance","account_verification_required"]);function ve({step:a,i18n:n,className:h,defaultEmail:_="",onError:ee}){let i=r((t,o)=>G(n.strings[t]??he[n.locale][t],o),"t"),[N,ae]=(0,s.useState)(_),[O,z]=(0,s.useState)(""),[l,E]=(0,s.useState)(!1),[w,q]=(0,s.useState)(null),[g,c]=(0,s.useState)(!1),[I,ie]=(0,s.useState)(null),u=(0,s.useRef)(null),f=a.phase==="verify",m=f&&!g,R=Q(f),d=(0,s.useId)(),[te,se]=J(a.reason==="otp_mismatch",a.attemptsRemaining,()=>z("")),V=f?a.codeExpiresAt??"sent":null;(0,s.useEffect)(()=>{V!==null&&(c(!1),u.current!==null&&!Z.has(a.reason??"")&&ie(u.current),u.current=null)},[V]);let S=r(async t=>{E(!0),q(null);try{await t()}catch(o){q(o instanceof F&&o.field==="email"?i("emailOtp.emailInvalid"):n.t(B(o,n.strings))),ee?.(o)}finally{E(!1)}},"run"),$=r(t=>{let o=a.needsEmail?t?I:N.trim():null;u.current=o,S(async()=>{try{await a.send(o!==null?{email:o}:{})}catch(de){throw u.current=null,de}})},"send"),D=r(t=>{S(()=>a.verify(t))},"submitCode"),oe=r(t=>{t.preventDefault(),m?D(O):$(!1)},"onSubmit"),k=X(a.codeExpiresAt,R,_e),C=X(a.resendAvailableAt,R,Oe),v=m&&a.codeExpiresAt!==void 0&&k===0,L=a.needsEmail&&!a.attemptsExhausted,H=f&&(a.codeExpiresAt===void 0||k>0),A=m&&L?()=>c(!0):g&&H?()=>c(!1):null;j(A===null?null:l?()=>{}:A);let[le,re]=i("emailOtp.sentTo").split("{email}"),M=a.context.simulation?.otpCode,ne=a.reason==="otp_mismatch"?(0,e.jsxs)(y,{tone:"danger",children:[(0,e.jsx)("span",{children:i("emailOtp.reason_otp_mismatch")}),(0,e.jsx)("span",{children:Y(n,a.attemptsRemaining,a.attemptsExhausted)})]}):a.reason!==void 0&&Z.has(a.reason)?(0,e.jsx)(y,{tone:"warning",children:(0,e.jsx)("span",{children:i(`emailOtp.reason_${a.reason}`)})}):null;return(0,e.jsxs)("form",{className:`sekyro-step sekyro-otp${h?` ${h}`:""}`,"aria-labelledby":d,onSubmit:oe,noValidate:!0,children:[(0,e.jsx)(P,{id:d,title:i(m?"emailOtp.verifyTitle":"emailOtp.sendTitle"),lead:m&&M!==void 0?(0,e.jsx)(U,{template:n.t("sandbox.otpHint"),code:M}):m?(0,e.jsxs)(e.Fragment,{children:[le,(0,e.jsx)("bdi",{dir:"ltr",className:"sekyro-mono",children:I??a.sentToMasked}),re]}):i("emailOtp.sendDescription")}),ne,w!==null?(0,e.jsx)(y,{tone:"danger",children:(0,e.jsx)("span",{children:w})}):null,m?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"sekyro-field",children:[(0,e.jsx)("label",{className:"sekyro-label",htmlFor:`${d}-code`,children:i("emailOtp.codeLabel")}),(0,e.jsx)(K,{id:`${d}-code`,value:O,invalid:te,onChange:p(t=>{t!==""&&se(),z(t),t.length===6&&O.length!==6&&!l&&!a.attemptsExhausted&&D(t)},"onChange")}),(0,e.jsx)("span",{className:`sekyro-help sekyro-otp-expiry${v?" is-danger":""}`,"aria-hidden":!v||void 0,children:v?i("emailOtp.expired"):i("emailOtp.expiresIn",{time:fe(k)})})]}),(0,e.jsx)("span",{className:"sekyro-visually-hidden",role:"status","aria-live":"polite",children:v?i("emailOtp.expired"):""}),(0,e.jsxs)(T,{children:[(0,e.jsx)(x,{type:"submit",full:!0,disabled:l||O.length!==6,"aria-busy":l||void 0,children:i("emailOtp.verify")}),(0,e.jsxs)("div",{className:"sekyro-resend-row",children:[(0,e.jsx)("button",{type:"button",className:"sekyro-link sekyro-resend",disabled:l||C>0,onClick:p(()=>$(!0),"onClick"),children:C>0?i("emailOtp.resendIn",{seconds:C}):i("emailOtp.resend")}),L?(0,e.jsx)("button",{type:"button",className:"sekyro-link sekyro-resend",disabled:l,onClick:p(()=>c(!0),"onClick"),"data-testid":"sekyro-otp-change",children:i("emailOtp.changeEmail")}):null]})]})]}):(0,e.jsxs)(e.Fragment,{children:[a.needsEmail?(0,e.jsxs)("div",{className:"sekyro-field",children:[(0,e.jsx)("label",{className:"sekyro-label",htmlFor:`${d}-email`,children:i("emailOtp.emailLabel")}),(0,e.jsx)("input",{id:`${d}-email`,className:"sekyro-input",type:"email",dir:"ltr",inputMode:"email",autoComplete:"email",autoCapitalize:"none",spellCheck:!1,placeholder:i("emailOtp.emailPlaceholder"),value:N,"aria-describedby":`${d}-email-help`,onChange:p(t=>ae(t.target.value),"onChange")}),(0,e.jsx)("span",{id:`${d}-email-help`,className:"sekyro-help",children:i("emailOtp.emailHelper")})]}):(0,e.jsx)("p",{className:"sekyro-text-muted",children:i("emailOtp.prefilledNotice")}),(0,e.jsxs)(T,{children:[(0,e.jsx)(x,{type:"submit",full:!0,disabled:l,"aria-busy":l||void 0,children:i("emailOtp.send")}),g&&H?(0,e.jsx)("button",{type:"button",className:"sekyro-link sekyro-resend",disabled:l,onClick:p(()=>c(!1),"onClick"),"data-testid":"sekyro-otp-back-to-code",children:i("emailOtp.backToCode")}):null]})]})]})}p(ve,"Ve");r(ve,"EmailOtpView");export{ve as EmailOtpView};
|