@sekyro/react 0.1.0-rc.19 → 0.1.0-rc.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +53 -0
  3. package/dist/{chunk-PESMIB3E.js → chunk-4X65DTPB.js} +1 -1
  4. package/dist/{chunk-ONYT4GJ4.js → chunk-6QYD5HOU.js} +1 -1
  5. package/dist/{chunk-OFPS67YV.js → chunk-A4ZCLFYN.js} +1 -1
  6. package/dist/chunk-AYFSJOAV.js +2 -0
  7. package/dist/chunk-B4OAK5EF.js +2 -0
  8. package/dist/{chunk-YZ5ZR6UR.js → chunk-EDIXRMTS.js} +1 -1
  9. package/dist/{chunk-HVH6GGI4.js → chunk-FQDXB2B2.js} +1 -1
  10. package/dist/{chunk-MX5SNIDY.js → chunk-HRNF3WQA.js} +1 -1
  11. package/dist/{chunk-TLMGY7AK.js → chunk-IAZ5UH2B.js} +1 -1
  12. package/dist/{chunk-7Z4LVT2A.js → chunk-RKO3RGGA.js} +1 -1
  13. package/dist/{chunk-TWZZGFO5.js → chunk-RO2EITOC.js} +1 -1
  14. package/dist/{chunk-MM5EYC7B.js → chunk-VIJSKEOY.js} +1 -1
  15. package/dist/{chunk-DIE7UVV7.js → chunk-WL77LOB3.js} +1 -1
  16. package/dist/{document-capture-view-DMRIMB3Z.js → document-capture-view-GLJFNXMU.js} +1 -1
  17. package/dist/{eid-view-DZBYRACA.js → eid-view-UDHNSVSK.js} +1 -1
  18. package/dist/{email-otp-view-GW2VEEPW.js → email-otp-view-E64VQ4LK.js} +1 -1
  19. package/dist/flow-views-WOIS3NTS.js +2 -0
  20. package/dist/index.cjs +1 -1
  21. package/dist/index.js +1 -1
  22. package/dist/overlay-de-5KYN4JFO.js +2 -0
  23. package/dist/overlay-es-6CAERCCN.js +2 -0
  24. package/dist/overlay-pt-UBGXJ3C3.js +2 -0
  25. package/dist/{portrait-capture-view-TL5ZZNZF.js → portrait-capture-view-OF6YACVY.js} +1 -1
  26. package/dist/portrait-review-view-YPIJQTA7.js +2 -0
  27. package/dist/verification/index.cjs +1 -1
  28. package/dist/verification/index.d.cts +17 -0
  29. package/dist/verification/index.d.ts +17 -0
  30. package/dist/verification/index.js +1 -1
  31. package/dist/verification.css +5 -1
  32. package/package.json +3 -2
  33. package/sbom.cdx.json +4 -4
  34. package/dist/chunk-64KUMWHB.js +0 -2
  35. package/dist/chunk-E7PG3JL4.js +0 -2
  36. package/dist/flow-views-T3Y6QDXH.js +0 -2
  37. package/dist/overlay-de-C7OXK65Q.js +0 -2
  38. package/dist/overlay-es-WGFBBRYI.js +0 -2
  39. package/dist/overlay-pt-EJEA6RF7.js +0 -2
  40. package/dist/portrait-review-view-W7DDLF64.js +0 -2
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{a as on,c as an}from"./chunk-YZ5ZR6UR.js";import{b as sn,c as We}from"./chunk-7MMT5M4E.js";import{a as tn,b as nn,c as rn,d as z}from"./chunk-TLMGY7AK.js";import{a as F,k as Zt,l as Wt,n as Qt,o as Jt,p as Xt,q as en,r as q,s as Qe}from"./chunk-ONYT4GJ4.js";import{a as n}from"./chunk-2KED7D2Q.js";import{useId as vr}from"react";import{Fragment as hr,jsx as M,jsxs as ee}from"react/jsx-runtime";function te({className:e,children:t}){return M("svg",{"aria-hidden":"true",focusable:"false",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",className:e??"sekyro-icon sekyro-icon--sm",children:t})}n(te,"Svg");var yt="M4 7.5h2.2l1.4-1.9h8.8l1.4 1.9H20a1.6 1.6 0 0 1 1.6 1.6v8.3A1.6 1.6 0 0 1 20 19H4a1.6 1.6 0 0 1-1.6-1.6V9.1A1.6 1.6 0 0 1 4 7.5Z";function cn(e){return ee(te,{...e,children:[M("circle",{cx:"12",cy:"12",r:"4"}),M("path",{d:"M12 2.5v2M12 19.5v2M2.5 12h2M19.5 12h2M5.3 5.3l1.4 1.4M17.3 17.3l1.4 1.4M5.3 18.7l1.4-1.4M17.3 6.7l1.4-1.4"})]})}n(cn,"SunIcon");function ln(e){return ee(te,{...e,children:[M("circle",{cx:"12",cy:"12",r:"9"}),M("path",{d:"M9 10h.01M15 10h.01M8.8 14.6a4.2 4.2 0 0 0 6.4 0"})]})}n(ln,"FaceUncoveredIcon");function un(e){return ee(te,{...e,children:[M("rect",{x:"7",y:"2.5",width:"10",height:"19",rx:"2"}),M("path",{d:"M10.5 18.5h3M2.5 9.5h2.5M19 9.5h2.5"}),M("circle",{cx:"12",cy:"9.5",r:"1.6"})]})}n(un,"PhoneEyeLevelIcon");function dn(e){return ee(te,{...e,children:[M("path",{d:"M2.5 12S6 5.5 12 5.5 21.5 12 21.5 12 18 18.5 12 18.5 2.5 12 2.5 12Z"}),M("circle",{cx:"12",cy:"12",r:"2.8"})]})}n(dn,"LookStraightIcon");function pn(e){return ee(te,{...e,children:[M("path",{d:yt}),M("path",{d:"M9 13l2 2 4-4"})]})}n(pn,"CameraCheckIcon");function fn(e){return ee(te,{...e,children:[M("path",{d:yt}),M("path",{d:"M10.2 11.2a1.9 1.9 0 1 1 2.6 1.8c-.5.2-.8.6-.8 1.1v.3M12 16.4h.01"})]})}n(fn,"CameraAskIcon");function mn(e){return ee(te,{...e,children:[M("path",{d:yt}),M("path",{d:"M3 3l18 18"})]})}n(mn,"CameraBlockedIcon");function Ve({off:e,className:t}){return ee(te,{className:t,children:[M("path",{d:"M4.5 9.5v5H8l4 3.5v-12L8 9.5H4.5Z"}),e?M("path",{d:"M4 4l16 16"}):ee(hr,{children:[M("path",{d:"M15.5 9.7a3.6 3.6 0 0 1 0 4.6"}),M("path",{d:"M18 7.6a6.6 6.6 0 0 1 0 8.8"})]})]})}n(Ve,"SpeakerIcon");function yn(e){return M(te,{...e,children:M("path",{d:"M5 12.5l4.5 4.5L19 7.5"})})}n(yn,"CheckIcon");function gn(e){return ee(te,{className:e.className??"sekyro-spinner",children:[M("circle",{cx:"12",cy:"12",r:"9",opacity:"0.25"}),M("path",{d:"M21 12a9 9 0 0 0-9-9"})]})}n(gn,"SpinnerIcon");import{jsx as pe,jsxs as hn}from"react/jsx-runtime";var Je=["light","uncover","eyeLevel","straight"],Cr={light:{key:"capture.tips.light",icon:n(()=>pe(cn,{}),"icon")},uncover:{key:"capture.tips.uncover",icon:n(()=>pe(ln,{}),"icon")},eyeLevel:{key:"capture.tips.eyeLevel",icon:n(()=>pe(un,{}),"icon")},straight:{key:"capture.tips.straight",icon:n(()=>pe(dn,{}),"icon")}};function vn({tips:e}){let t=z(),o=vr();return e.length===0?null:hn("section",{className:"sekyro-tips","aria-labelledby":o,"data-testid":"sekyro-tips",children:[pe("p",{className:"sekyro-tips__title",id:o,children:t("capture.tips.title")}),pe("ul",{className:"sekyro-tips__list",children:e.map(r=>{let s=typeof r=="string"?Cr[r]:void 0,c=typeof r=="string"?r:r.id,i=s!==void 0?s.icon():typeof r=="string"?void 0:r.icon,u=s!==void 0?t(s.key):typeof r=="string"?r:r.text;return hn("li",{className:"sekyro-tips__item",children:[i!=null?pe("span",{className:"sekyro-tips__icon","aria-hidden":"true",children:i}):null,pe("span",{children:u})]},c)})})]})}n(vn,"TipList");import{useEffect as Cn,useId as kr,useRef as br,useState as Sr}from"react";import{jsx as W,jsxs as Xe}from"react/jsx-runtime";var Rr=220;function kn({title:e,description:t,options:o,busy:r,error:s,focus:c,testId:i,look:u="cards",marked:k,onChoose:b}){let y=kr(),w=Qe(),[S,d]=Sr(null),C=br(null);Cn(()=>{s!==null&&d(null)},[s]),Cn(()=>()=>{C.current!==null&&clearTimeout(C.current)},[]);let v=n(l=>{r||S!==null||(d(l),C.current=setTimeout(()=>{C.current=null,d(null),b(l)},Rr))},"choose");return Xe("section",{className:"sekyro-stack sekyro-stack--4 sekyro-choice","aria-labelledby":y,"data-testid":i,children:[Xe("div",{className:u==="cards"?"sekyro-heading":"sekyro-stack sekyro-stack--1",children:[W("h2",{id:y,ref:c?w:void 0,tabIndex:-1,className:"sekyro-text-body",children:e}),t!==void 0&&t!==""?W("p",{className:"sekyro-text-muted",children:t}):null]}),s!==null?W(q,{tone:"danger",children:W("span",{children:s})}):null,u==="buttons"?W("div",{className:"sekyro-stack sekyro-stack--3",children:o.map((l,L)=>W(F,{kind:L===0?"primary":"ghost",full:!0,disabled:r,"aria-busy":r||void 0,onClick:()=>b(l.id),children:l.label},l.id))}):W("div",{className:"sekyro-choices",children:o.map(l=>Xe("button",{type:"button",className:"sekyro-card","aria-pressed":(S??k)===l.id,"aria-busy":r||void 0,disabled:r||S!==null&&S!==l.id,onClick:()=>v(l.id),children:[l.glyph!==void 0?W("span",{className:"sekyro-card__tile",children:l.glyph}):null,Xe("span",{className:"sekyro-card__body",children:[W("span",{className:"sekyro-card__title",children:l.label}),l.sub!==void 0?W("span",{className:"sekyro-card__sub",children:l.sub}):null]}),W("span",{className:"sekyro-radio","aria-hidden":"true"})]},l.id))})]})}n(kn,"ChoiceScreen");var et=["fcv3.no_face","fcv3.come_closer","fcv3.move_back","fcv3.center_face","fcv3.straighten","fcv3.more_light","fcv3.too_bright","fcv3.hold_still","fcv3.steady_camera","fcv3.hold_upright","fcv3.one_face","capture.tips.summary"];function he(e){return e!==null&&et.includes(e)}n(he,"isVoiceKey");import{useCallback as re,useEffect as ve,useLayoutEffect as Lr,useMemo as _r,useRef as we,useState as Oe}from"react";var Vr=n((e,t)=>Object.prototype.hasOwnProperty.call(e,t),"own");function Me(e,t,o){let r;try{if(typeof e=="function")r=e(t,o);else{let s=e[o];r=s!=null&&Vr(s,t)?s[t]:null}}catch{return null}return typeof r=="string"&&r!==""?r:null}n(Me,"resolveClip");var Mr="UklGRiQAAABXQVZFZm10IBAAAAABAAEAESsAACJWAAACABAAZGF0YQAAAAA=",Rn={ar:"ar-SA",fr:"fr-FR",en:"en-US",es:"es-ES",pt:"pt-BR",de:"de-DE"};function ne(){return typeof window<"u"&&"speechSynthesis"in window?window.speechSynthesis:null}n(ne,"synth");function wr(){return ne()!==null&&typeof SpeechSynthesisUtterance=="function"}n(wr,"speechAvailable");function bn(e){return(e.split(/[-_]/)[0]??e).toLowerCase()}n(bn,"baseLang");function Vn(e,t){let o=n(s=>s.replace(/_/g,"-").toLowerCase(),"norm"),r=bn(t);return e.find(s=>o(s.lang)===o(t))??e.find(s=>bn(s.lang)===r)}n(Vn,"pickVoice");function Mn(e){if(!wr())return!1;let t=[];try{t=ne()?.getVoices()??[]}catch{return!0}return t.length===0||Vn(t,e)!==void 0}n(Mn,"speechUsable");function wn(e){let t=ne();return t===null||typeof t.addEventListener!="function"?()=>{}:(t.addEventListener("voiceschanged",e),()=>t.removeEventListener?.("voiceschanged",e))}n(wn,"subscribeVoices");function Ke(e){try{let t=typeof location<"u"?location.href:"http://localhost/",o=new URL(e,t);return`clip:${o.origin}${o.pathname}`}catch{return`clip:${e}`}}n(Ke,"clipIdentity");function Sn(e){e.pause(),e.removeAttribute("src"),e.load()}n(Sn,"release");function Ln(){let e=null,t=null,o=0,r=null,s=[],c=new Map,i=n(()=>{s=ne()?.getVoices()??[]},"loadVoices"),u=!1,k=n(()=>{let d=ne();u||d===null||(u=!0,i(),d.addEventListener?.("voiceschanged",i))},"bindVoices"),b=n(()=>(e??(e=new Audio),e),"element"),y=n((d,C,v)=>{let l=ne();if(l!==null&&d!==""&&typeof SpeechSynthesisUtterance=="function"){k();let L=Vn(s,C);if(s.length===0||L!==void 0){l.cancel();let g=new SpeechSynthesisUtterance(d);g.lang=C,L!==void 0&&(g.voice=L),g.rate=.95,v!==void 0&&(g.onend=g.onerror=v),l.speak(g);return}}v?.()},"speak"),w=n(()=>{o+=1,r=null,e!==null&&(e.pause(),e.currentTime=0),ne()?.cancel()},"stop"),S=n(d=>{for(let C of d){let v=Ke(C);if(c.has(v))continue;let l=new Audio;l.preload="auto",l.src=C,c.set(v,l)}},"warmClips");return{say(d){let C=d.url!==null?Ke(d.url):`tts:${d.lang}:${d.text}`;if(C===r)return;r=C,o+=1;let v=o,l=d.onEnd,L=l!==void 0?()=>{v===o&&l()}:void 0;if(ne()?.cancel(),d.url!==null){let g=b();g.pause(),g.muted=!1,g.src=d.url,g.currentTime=0,g.onended=L??null,g.play()?.catch(V=>{v===o&&V?.name!=="AbortError"&&(d.speech?y(d.text,d.lang,L):L?.())});return}d.speech?y(d.text,d.lang,L):L?.()},unlock({lang:d,speech:C,prefetch:v}){let l=b();if(t===null&&typeof Blob=="function"&&typeof URL.createObjectURL=="function"){let V=Uint8Array.from(atob(Mr),E=>E.charCodeAt(0));t=URL.createObjectURL(new Blob([V],{type:"audio/wav"}))}let L=l.paused===!1&&t!==null&&l.src!==t;t!==null&&!L&&(l.muted=!0,l.onended=null,l.src=t,l.play()?.catch(()=>{}));let g=ne();if(C&&g!==null&&typeof SpeechSynthesisUtterance=="function"){k();let V=new SpeechSynthesisUtterance(" ");V.volume=0,V.lang=d,g.speak(V)}S(v??[])},prefetch:S,stop:w,dispose(){w(),u&&ne()?.removeEventListener?.("voiceschanged",i),u=!1,t!==null&&URL.revokeObjectURL(t),t=null,e!==null&&Sn(e),e=null;for(let d of c.values())Sn(d);c.clear()}}}n(Ln,"createVoicePlayer");var _n="sekyro.voiceGuidance";function xn(e){try{if(typeof window>"u")return null;let t=window.localStorage.getItem(e);return t==="1"?!0:t==="0"?!1:null}catch{return null}}n(xn,"readVoicePreference");function In(e,t){try{if(typeof window>"u")return;window.localStorage.setItem(e,t?"1":"0")}catch{}}n(In,"writeVoicePreference");var Ue="capture.tips.summary",xr=typeof window<"u"?Lr:ve,Ir=Object.freeze({});function gt(e,t){let o=new Set,r=[];for(let s of et){let c=s===Ue?null:Me(e,s,t);c===null||o.has(Ke(c))||(o.add(Ke(c)),r.push(c))}return r}n(gt,"resolvedClipUrls");function ht({locale:e,defaultClips:t,options:o}){let r=o===!1,s=r?{}:o??{},c=s.storageKey===void 0?_n:s.storageKey,[i,u]=Oe(s.defaultEnabled??!0),k=we(i),[b,y]=Oe(!1),[w,S]=Oe("none"),[d,C]=Oe(!1),v=we(!1),[l,L]=Oe(0),g=we(null),V=re(()=>(g.current??(g.current=Ln()),g.current),[]),E=Rn[e],T=s.speechFallback,p=T===void 0||T===!0?!0:T===!1?!1:T.includes(e),U=s.clips??t??Ir,H=we(!1),se=we(U);xr(()=>{se.current=U,k.current=i}),ve(()=>{if(r||c===null)return;let h=xn(c);h!==null&&(k.current=h,u(h))},[r,c]),ve(()=>{if(!(r||!p))return wn(()=>L(h=>h+1))},[r,p]);let a=s.clips;ve(()=>{if(r)return;let h=p&&Mn(E);y(gt(U,e).length>0||h),S(a!==void 0&&Me(a,Ue,e)!==null?"partner":Me(U,Ue,e)!==null||h?"default":"none")},[r,U,a,e,p,E,l]),ve(()=>{if(r||!i||!H.current)return;let h=gt(U,e);h.length>0&&V().prefetch(h)},[r,i,U,e,V]),ve(()=>()=>{g.current?.dispose(),g.current=null,H.current=!1},[]);let A=re(h=>{r||(H.current=!0,V().unlock({lang:E,speech:p,...h?{prefetch:gt(se.current,e)}:{}}))},[r,V,E,p,e]),_=re(()=>A(k.current),[A]),B=re(()=>{v.current=!1,C(!1)},[]),N=re(()=>{B(),g.current?.stop()},[B]),ie=re(()=>{v.current&&N()},[N]),ae=re((h,me)=>{if(r)return;if(v.current){N();return}let ce=V();ce.stop(),v.current=!0,C(!0);let x=me?.clip===!1?null:Me(se.current,Ue,e);ce.say({url:x,text:h,lang:E,speech:p,onEnd:B})},[r,N,V,e,E,p,B]),P=re(h=>{r||(h?A(!0):N(),c!==null&&In(c,h),k.current=h,u(h))},[r,A,N,c]),K=re(()=>P(!k.current),[P]),fe=re((h,me)=>{if(r||!i)return;v.current&&B();let ce=Me(se.current,h,e);V().say({url:ce,text:me,lang:E,speech:p})},[r,i,e,V,E,p,B]);return _r(()=>({supported:!r&&b,enabled:!r&&i,setEnabled:P,toggle:K,unlock:_,speakKey:fe,stop:N,summary:r?"none":w,summaryPlaying:d,toggleSummary:ae,stopSummary:ie}),[r,b,i,P,K,_,fe,N,w,d,ae,ie])}n(ht,"useVoiceGuidance");function vt(e,t,o,r){let{speakKey:s,stop:c,enabled:i}=e,u=we(!1);ve(()=>{if(!r||!i){u.current&&c(),u.current=!1;return}u.current=!0,he(t)&&t!==Ue&&o!==""&&s(t,o)},[r,i,t,o,s,c])}n(vt,"useSpeakGuidance");import{isValidElement as io,useCallback as st,useContext as ao,useEffect as oe,useMemo as xe,useRef as ke,useState as sr}from"react";import{useEffect as Er,useRef as Nr}from"react";import{jsx as He,jsxs as Nn}from"react/jsx-runtime";function Pn(e){switch(e){case"multiple_faces":return"one_face";case"capture_back_camera":return"front_camera";case"capture_front_camera":return"back_camera";case"capture_not_upright":return"upright";case"media_unreadable":case"clip_too_short":return"recording";case"device_integrity_failed":return"device";default:return"face"}}n(Pn,"retryCoachingOf");var En={face:{title:"capture.retryCoaching.title",tips:["capture.retryCoaching.light","capture.retryCoaching.eyeLevel","capture.retryCoaching.head"]},one_face:{title:"capture.retryTips.title",tips:["capture.retryOneFace.alone","capture.retryOneFace.screens"]},front_camera:{title:"capture.retryTips.title",tips:["capture.retryFrontCamera.screenSide"]},back_camera:{title:"capture.retryTips.title",tips:["capture.retryBackCamera.backSide","capture.retryBackCamera.circle"]},upright:{title:"capture.retryTips.title",tips:["capture.retryUpright.vertical","capture.retryUpright.untilEnd"]},recording:{title:"capture.retryTips.title",tips:["capture.retryRecording.cameraOn","capture.retryRecording.stay","capture.retryRecording.network"]},device:{title:"capture.retryTips.title",tips:["capture.retryDevice.screenRecording","capture.retryDevice.phone"]}};function An({showCoaching:e,coaching:t="face",attemptsText:o,showRetake:r,onRetake:s}){let c=z(),i=Nr(null);return Er(()=>{r&&i.current?.focus()},[r]),!e&&!r?null:Nn("div",{className:"sekyro-stack sekyro-stack--3","data-testid":"sekyro-captured-panel",children:[e?Nn("div",{className:"sekyro-stack sekyro-stack--1",children:[He("p",{className:"sekyro-text-body",children:c(En[t].title)}),He("ul",{className:"sekyro-coaching",children:En[t].tips.map(u=>He("li",{children:c(u)},u))}),o!==null?He("p",{className:"sekyro-text-muted","data-testid":"sekyro-attempts-remaining",children:o}):null]}):null,r?He(F,{ref:i,className:"sekyro-btn--start",onClick:s,children:c("capture.recordAgain")}):null]})}n(An,"CapturedPanel");function tt(){try{return process.env.NODE_ENV!=="production"}catch{return!1}}n(tt,"isDevBuild");import{createContext as Pr}from"react";var Tn=Pr(null);import{useCallback as Hn,useEffect as Bn,useRef as Le}from"react";import{useEffect as Ar,useState as Tr}from"react";import{jsx as Be,jsxs as Kr}from"react/jsx-runtime";function Kn({state:e}){let t=z(),[o,r]=Tr(!1);Ar(()=>{e!=="unknown"&&r(!0)},[e]);let s=e==="granted"?Be(pn,{}):e==="denied"?Be(mn,{}):Be(fn,{});return Kr("div",{role:o?"status":void 0,className:`sekyro-permission sekyro-permission--${e}`,"data-testid":"sekyro-permission","data-state":e,children:[Be("span",{className:"sekyro-permission__icon","aria-hidden":"true",children:s}),Be("span",{children:t(`capture.permission.${e}`)})]})}n(Kn,"PermissionRow");import{jsx as nt,jsxs as On}from"react/jsx-runtime";function Un({voice:e}){let t=z();if(!e.supported)return null;let o=e.enabled;return On("button",{type:"button",role:"switch","aria-checked":o,className:"sekyro-switch","data-testid":"sekyro-voice-switch",onClick:()=>e.toggle(),children:[On("span",{className:"sekyro-switch__label",children:[nt(Ve,{off:!o}),t("capture.voiceGuidance")]}),nt("span",{className:"sekyro-switch__track","aria-hidden":"true",children:nt("span",{className:"sekyro-switch__thumb",children:o?nt(yn,{className:"sekyro-switch__check"}):null})})]})}n(Un,"VoiceSwitch");import{Fragment as Ur,jsx as D,jsxs as _e}from"react/jsx-runtime";function Gn({assets:e,onRetryAssets:t,permission:o,captureMode:r="self",voice:s,tips:c,summary:i,startLabel:u,startDisabled:k,onStart:b}){let y=z(),w=Le(i?.stop);w.current=i?.stop,Bn(()=>()=>w.current?.(),[]);let S=Le(null),d=Le(null),C=Le(null),v=Le(e),l=Le(!1);Bn(()=>{let U=v.current;if(v.current=e,U===e)return;let H=l.current;e!=="loading"&&(l.current=!1),Or(S.current)&&(e==="failed"?C.current?.focus():H&&d.current?.focus())},[e]);let L=Hn(()=>{l.current=!0,t()},[t]),g=e==="loading",V=g||k,E=Hn(()=>{V||(w.current?.(),b())},[V,b]),T;return e==="failed"?T=_e(q,{tone:"danger",testId:"sekyro-assets-error",children:[D("p",{className:"sekyro-text-body",children:y("fcv2.err.models")}),D(F,{kind:"ghost",ref:C,className:"sekyro-btn--start",onClick:L,"data-testid":"sekyro-assets-retry",children:y("common.retry")})]}):T=_e("div",{className:"sekyro-stack sekyro-stack--1",children:[D(F,{ref:d,full:!0,"data-testid":"sekyro-start","aria-disabled":V?"true":void 0,"aria-busy":g?"true":void 0,onClick:E,children:g?_e(Ur,{children:[D(gn,{}),y("capture.preparing.title")]}):u??y("capture.start")}),g?D("p",{className:"sekyro-text-muted",children:y("capture.preparing.hint")}):null]}),_e("div",{ref:S,className:"sekyro-stack sekyro-stack--4","data-testid":"sekyro-intro","data-assets":e,children:[r==="assisted"?_e("div",{className:"sekyro-stack sekyro-stack--1","data-testid":"sekyro-assisted-intro",children:[D("h2",{className:"sekyro-text-body",children:y("capture.assisted.title")}),D("p",{className:"sekyro-text-muted",children:y("capture.assisted.lead")})]}):null,c!==!1?D(vn,{tips:c}):null,i!==void 0?_e(F,{kind:"ghost",className:"sekyro-btn--start",onClick:i.toggle,"data-testid":"sekyro-tips-listen",children:[D(Ve,{off:!1}),y(i.playing?"capture.tips.stop":"capture.tips.listen")]}):null,D(Kn,{state:o}),D(Un,{voice:s}),D("p",{className:"sekyro-text-muted",children:y("capture.securityNote")}),T,D("p",{role:"status",className:"sekyro-visually-hidden","data-testid":"sekyro-intro-status",children:e==="loading"?y("capture.preparing.title"):e==="ready"?y("capture.ready"):""})]})}n(Gn,"PreCaptureScreen");function Or(e){if(typeof document>"u")return!1;let t=document.activeElement;return t===null||t===document.body||e!==null&&e.contains(t)}n(Or,"focusIsOurs");import{subscribeCameraPermission as Hr}from"@sekyro/web";import{useEffect as Br,useState as Gr}from"react";function Fn(){let[e,t]=Gr({state:"unknown",settled:!1});return Br(()=>Hr(o=>t({state:o,settled:!0})),[]),{permission:e.state,permissionSettled:e.settled}}n(Fn,"useCameraStatus");import{useCallback as Fr,useEffect as Ct,useState as kt}from"react";function qn(e){return jn(e,"mobileRequired")}n(qn,"useMobileRequired");function Dn(e){return jn(e,"returning").required}n(Dn,"useReturning");function jn(e,t){let[o,r]=kt({required:!1,settled:e===void 0});return Ct(()=>{let s=e?.[t];if(e===void 0||typeof s!="function"){r({required:!1,settled:!0});return}let c=!0;return r({required:!1,settled:!1}),Promise.resolve().then(()=>s.call(e)).then(i=>{c&&r({required:i===!0,settled:!0})},()=>{c&&r({required:!1,settled:!0})}),()=>{c=!1}},[e,t]),o}n(jn,"useFlag");function $n(e){let t=n(()=>e?.captureChoice??null,"initialChoice"),[o,r]=kt(()=>({session:"self",choice:t(),settled:e===void 0}));Ct(()=>{let i=e?.captureMode,u=e?.captureChoice??null;if(e===void 0||typeof i!="function"){r({session:"self",choice:u,settled:!0});return}let k=!0;return r({session:"self",choice:u,settled:!1}),Promise.resolve().then(()=>i.call(e)).then(b=>{let y=e.captureChoice??null;k&&r({session:y!==null&&b===y?"choice":b==="assisted"||b==="choice"?b:"self",choice:y,settled:!0})},()=>{k&&r({session:"self",choice:null,settled:!0})}),()=>{k=!1}},[e]);let s=Fr(i=>{e?.chooseCaptureMode?.(i),r(u=>({...u,choice:i}))},[e]);return{mode:o.session==="choice"?o.choice??"self":o.session==="assisted"?"assisted":"self",session:o.session,choice:o.choice,settled:o.settled,choose:s}}n($n,"useCaptureMode");function zn(e){let[t,o]=kt(!1);return Ct(()=>{if(o(!1),e===void 0)return;let r=e.on("busy",()=>o(!0)),s=e.on("result",()=>o(!1));return()=>{r(),s()}},[e]),t}n(zn,"useBusy");import{getLivenessAssetsStatus as qr,preloadLivenessAssets as Dr,subscribeLivenessAssets as jr}from"@sekyro/web";import{useCallback as bt,useEffect as Yn,useRef as Zn,useState as $r,useSyncExternalStore as zr}from"react";var Yr=n(()=>"idle","serverSnapshot");function Wn(e){return Dr(e!==void 0?{assetBaseUrl:e}:{})}n(Wn,"preload");function Qn(e,t=!0){let o=zr(bt(w=>jr(w,e),[e]),()=>qr(e),Yr),[r,s]=$r(null),c=Zn(!1),i=bt(()=>{Wn(e).then(w=>{c.current&&w==="idle"&&s({base:e})})},[e]);Yn(()=>(c.current=!0,i(),()=>{c.current=!1}),[i]);let u=Zn(null);Yn(()=>{if(o!=="idle"){u.current={base:e};return}!t||u.current===null||u.current.base!==e||(u.current=null,i())},[o,e,i,t]);let k=bt(()=>{Wn(e)},[e]);return{gate:r!==null&&r.base===e&&o==="idle"||o==="ready"?"ready":o==="failed"?"failed":"loading",retry:k}}n(Qn,"useLivenessAssets");import{createLivenessCapture as Zr}from"@sekyro/web";import{useCallback as rt,useEffect as Wr,useRef as Ce,useState as j}from"react";var Jn={progress:0,hint:null,faceDetected:!1};function Xn(e){let{videoRef:t,assetBaseUrl:o}=e,s=Ce(e.verification).current,c=Ce(!1);e.verification!==s&&!c.current&&tt()&&(c.current=!0,console.warn("[@sekyro/react] <LivenessCapture>: the `verification` prop changed identity after mount. The first instance stays bound (the camera is not rebuilt); create the verification once (useMemo / useState / outside render) instead of on every render."));let i=Ce(null),[u,k]=j("idle"),[b,y]=j(Jn),[w,S]=j(!1),[d,C]=j(!1),[v,l]=j(null),[L,g]=j(!1),[V,E]=j(null),[T,p]=j(null),[U,H]=j(null),[se,a]=j(null),[A,_]=j(null),[B,N]=j(!1),ie=Ce(null),ae=Ce("idle"),P=Ce(-1),[K,fe]=j(0),h=Ce(e);h.current=e,Wr(()=>{let Y=t.current;if(Y===null)return;let Q={video:Y,...o!==void 0?{assetBaseUrl:o}:{}},I=s!==void 0?s.liveness(Q):Zr(Q);i.current=I;let Ne=n(()=>_(I.facingMode??null),"readFacing");Ne();let Ge=[I.on("state",m=>{m==="mode_switch"?N(!0):m!=="starting"&&m!=="gating"&&N(!1),m==="starting"?(ae.current!=="starting"&&(P.current+=1,fe(Math.max(0,P.current))),p(null),H(null),y(Jn),C(!1),S(!1),l(null),E(null),ie.current=null):m==="gating"&&ae.current==="recording"&&(C(!1),S(!1),l(null),ie.current=null),ae.current=m,Ne(),k(m),h.current.onStateChange?.(m)}),I.on("gate",m=>{let J=ie.current;ie.current=m.progress,S(J!==null&&m.progress<J-.001&&m.progress>0&&m.progress<1),m.progress>=1&&C(!0),y(m)}),I.on("frozen",({previewDataUrl:m})=>l(m)),I.on("profile",({animations:m})=>g(m==="reduced")),I.on("ramp",({colour:m})=>E(m)),I.on("captured",m=>{p(m),a(null),h.current.onCaptured?.(m)}),I.on("error",m=>{H(m);let J=s?.reportCaptureIssue;J!==void 0&&We(ye=>J.call(s,ye),sn("liveness",m,Math.max(0,P.current))),h.current.onError?.(m)}),s?.on("result",m=>{a(m),h.current.onResult?.(m)})];return()=>{for(let m of Ge)m?.();i.current=null,I.destroy()}},[s,t,o]);let me=rt(()=>{i.current?.start()},[]),ce=rt(()=>{i.current?.retry()},[]),x=rt(async()=>{let Y=i.current;return Y===null||typeof Y.canSwitchCaptureMode!="function"?!1:await Y.canSwitchCaptureMode().catch(()=>!1)===!0},[]),Ee=rt(async Y=>{let Q=i.current;if(Q===null||typeof Q.setCaptureMode!="function")return!1;let I=await Q.setCaptureMode(Y).catch(()=>!1)===!0;return I&&_(Q.facingMode??null),I},[]);return{state:u,gate:b,draining:w,gateLocked:d,frozenPreview:v,reduceMotion:L,rampColour:V,artifacts:T,error:U,result:se,facingMode:A,start:me,retry:ce,canSwitchCaptureMode:x,setCaptureMode:Ee,modeRestarted:B,attempt:K}}n(Xn,"useLivenessHandle");import{useCallback as Qr,useEffect as Jr,useState as ot}from"react";var Xr=new Set(["national_number"]);function er(e){if(e==null||!e.available||e.selected!==null)return null;let t=e.options.filter(o=>Xr.has(o));return t.length>0?{...e,options:t}:null}n(er,"pending");function tr(e){let[t,o]=ot(null),[r,s]=ot(e===void 0),[c,i]=ot(!1),[u,k]=ot(!1);Jr(()=>{if(o(null),e===void 0){s(!0);return}let S=!0,d=e.methodChoice;typeof d=="function"?(s(!1),Promise.resolve().then(()=>d.call(e)).then(v=>{S&&o(er(v))},()=>{}).finally(()=>{S&&s(!0)})):s(!0);let C=e.on("method",v=>o(er(v)));return()=>{S=!1,C()}},[e]);let b=Qr(async S=>{if(e===void 0)return!1;i(!0),k(!1);try{return await e.selectMethod(S),o(null),!0}catch{return k(!0),!1}finally{i(!1)}},[e]),y=t!==null&&t.options.length===1?t.options[0]:null;return{choice:t,auto:y==="national_number"&&!u?y:null,settled:r,busy:c,failed:u,select:b}}n(tr,"useMethodChoice");import{useEffect as eo,useMemo as to,useState as no}from"react";var ro=["ar","fr","en"];function oo(e){if(typeof e!="string")return!1;try{let t=new URL(e);return t.protocol==="https:"||t.protocol==="http:"&&/^(localhost|127\.0\.0\.1)$/.test(t.hostname)}catch{return!1}}n(oo,"isClipUrl");function so(e){let t=e.clips;if(typeof t!="object"||t===null)return null;let o={};for(let r of ro){let s=t[r];if(!(typeof s!="object"||s===null))for(let[c,i]of Object.entries(s))!he(c)||!oo(i)||((o[r]??(o[r]={}))[c]=i)}return Object.keys(o).length>0?o:null}n(so,"toVoiceClipMap");function nr(e){let[t,o]=no(null);eo(()=>{if(o(null),e===void 0)return;let s=!0,c=n(u=>{if(!s)return;let k=typeof u=="object"&&u!==null&&typeof u.setId=="string"?u:null;o(b=>b?.setId===k?.setId?b:k)},"take");try{typeof e.voiceClips=="function"&&Promise.resolve(e.voiceClips()).then(c,()=>c(null))}catch{c(null)}let i=e.on("view",u=>c(u.voice));return()=>{s=!1,i()}},[e]);let r=to(()=>t!==null?so(t):null,[t]);return e===void 0?null:r}n(nr,"useServerVoiceClips");import{jsx as rr}from"react/jsx-runtime";function or({voice:e}){let t=z();return rr(F,{kind:"chip","aria-pressed":e.enabled,"aria-label":t("capture.voiceGuidance"),"data-testid":"sekyro-voice-toggle",onClick:()=>e.toggle(),children:rr(Ve,{off:!e.enabled,className:"sekyro-icon"})})}n(or,"VoiceChip");import{Fragment as ir,jsx as R,jsxs as Ie}from"react/jsx-runtime";var co=new Set(["abandoned","not_opened","cancelled","superseded"]),lo=800;function uo(e){return e===void 0||e!==!1&&e.length===Je.length&&Je.every(t=>e.includes(t))}n(uo,"isDefaultTips");function po(e){if(e.type==="keydown"&&e.key==="Escape")return!1;let t=globalThis.navigator?.userActivation;return t===void 0?!(e.type==="pointerup"&&e.pointerType==="touch"):t.isActive}n(po,"carriesActivation");function fo(e){return typeof e=="object"&&e!==null&&!io(e)&&"tone"in e&&"text"in e}n(fo,"isNoticeObject");var mo=new Set(["nni_unbound","id_number_unbound","method_required","mobile_required","portrait_required"]);function yo(e){return e==="starting"||e==="gating"||e==="recording"||e==="mode_switch"}n(yo,"isCapturing");function go(e){return e==="captured"||e==="uploading"||e==="checking"}n(go,"isPostCapture");function _i({verification:e,locale:t,dir:o,strings:r,slots:s,autoStart:c=!1,notice:i,startDisabled:u=!1,startLabel:k,tips:b,tipsSummary:y,coach:w,voice:S,onGuidance:d,onCaptured:C,onResult:v,onError:l,onStateChange:L,assetBaseUrl:g,className:V}){let E=nn(t),T=xe(()=>tn(t,r),[t,r,E]),p=xe(()=>f=>T[f]??"",[T]),U=o??(t==="ar"?"rtl":"ltr"),H=ke(null),se=ao(Tn),a=Xn({verification:e,videoRef:H,assetBaseUrl:g,onCaptured:C,onResult:v,onError:l,onStateChange:L}),A=Qn(g,a.state==="idle"&&a.error===null),_=tr(e),B=_.choice!==null,N=qn(e),ie=Dn(e),ae=zn(e),P=Fn(),K=$n(e),fe=K.session==="choice",h=K.mode==="assisted",me=S!==!1&&S?.clips===void 0,ce=nr(me?e:void 0),x=ht({locale:t,defaultClips:ce,options:S}),Ee=h?"environment":"user",Y=K.settled,Q=ke(null),I=ke(!1),Ne=ke(x.unlock);Ne.current=x.unlock,oe(()=>{let f=Q.current;if(f===null)return;let $=["pointerup","touchend","click","keydown"],de=n(()=>{for(let Te of $)f.removeEventListener(Te,Re,!0)},"disarm");function Re(Te){if(I.current){de();return}po(Te)&&(I.current=!0,de(),Ne.current())}n(Re,"onGesture");for(let Te of $)f.addEventListener(Te,Re,{capture:!0,passive:!0});return de},[]);let Ge=st(()=>{I.current||(I.current=!0,x.unlock()),a.start()},[x.unlock,a.start]),m=st(()=>a.start(),[a.start]),J=ke(!1),ye=a.state==="idle"&&a.error===null,St=!B&&!N.required&&(c===!0||c==="when-permitted"&&P.permission==="granted"),Rt=St&&_.settled&&N.settled&&Y,ar=c==="when-permitted"&&!P.permissionSettled&&!J.current,Vt=St&&ye&&!J.current,it=(ar||Vt||!Y)&&A.gate==="ready"?"loading":A.gate;oe(()=>{!Rt||!ye||A.gate!=="ready"||J.current||(J.current=!0,m())},[Rt,ye,A.gate,m]);let cr=ye&&!B&&!N.required&&!(Vt&&A.gate==="ready"),[Mt,wt]=sr(!1),{canSwitchCaptureMode:Lt,setCaptureMode:_t}=a;oe(()=>{if(!K.settled||!fe){wt(!1);return}let f=!0;return Lt().then($=>{f&&wt($)}),()=>{f=!1}},[K.settled,fe,Lt]);let{choose:xt}=K,be=h?"self":"assisted",lr=st(async()=>{await _t(be)&&xt(be)},[_t,xt,be]),It=a.state!=="idle"&&a.facingMode!==null?a.facingMode:Ee;oe(()=>{let f=H.current?.style;It==="user"?f?.removeProperty("transform"):f&&(f.transform="none")},[It]);let Fe=xe(()=>a.artifacts!==null&&typeof URL.createObjectURL=="function"?URL.createObjectURL(a.artifacts.keyframe):null,[a.artifacts]);oe(()=>{if(Fe!==null)return()=>URL.revokeObjectURL(Fe)},[Fe]);let Et=a.frozenPreview??Fe,Se=e!==void 0,O=yo(a.state),le=go(a.state),qe=O||le,Z=a.result,Nt=a.state==="done"&&Z!==null,at=a.state==="recording"&&a.frozenPreview!==null,De=se!==null,Pt=Mt&&O&&!at?{to:be,label:p(be==="assisted"?"capture.modeSwitch.toAssisted":"capture.modeSwitch.toSelf"),description:p(be==="assisted"?"capture.modeSwitch.toAssistedLabel":"capture.modeSwitch.toSelfLabel"),onSwitch:n(()=>{lr()},"onSwitch")}:null,je=a.modeRestarted&&O?p("capture.modeSwitch.restarted"):null,Pe=le||at,At=le?"checking":at?"frozen":a.state==="recording"?"recording":a.gateLocked||a.gate.progress>=1?"locked":a.gate.faceDetected?"aligning":"seeking",$e=O?a.gate.hint:null,ze=a.state==="starting"?"capture.preparing.title":$e===null?null:$e==="center"&&!a.gate.faceDetected?"fcv3.no_face":Zt($e),[ur,Tt]=sr(null);oe(()=>{if(ze!=="fcv3.no_face"){Tt(ze);return}if(!O)return;let f=setTimeout(()=>Tt(ze),lo);return()=>clearTimeout(f)},[ze,O]);let ct=O&&typeof w=="string"&&w!=="",Kt=h&&O?p("capture.assisted.stage"):null,ge=O&&!ct?ur:null,lt=ct?w:ge===null?"":p(ge);vt(x,ge,lt,O);let Ot=ke(d);Ot.current=d,oe(()=>{if(he(ge))try{Ot.current?.(ge)}catch(f){console.error("[@sekyro/react] onGuidance threw:",f)}},[ge]);let Ae=xe(()=>({supported:x.supported,enabled:x.enabled,setEnabled:x.setEnabled,toggle:x.toggle}),[x.supported,x.enabled,x.setEnabled,x.toggle]),ut=s?.voicePrompt,Ut=ut!==void 0,Ht=S===void 0,Bt=ke(!1);oe(()=>{!Ut||!Ht||Bt.current||!tt()||(Bt.current=!0,console.warn("[@sekyro/react] <LivenessCapture>: `slots.voicePrompt` is set and `voice` is undefined, so the component speaks the guidance itself. If your slot plays audio, pass voice={false} or the person hears every hint twice; pass voice={{}} to keep the built-in voice and silence this warning."))},[Ut,Ht]);let dr=ut!==void 0?(f,$,de)=>ut(f,$,de,Ae):x.supported?()=>R(or,{voice:Ae}):void 0,{summary:dt,summaryPlaying:Gt,toggleSummary:Ft,stopSummary:qt}=x,Ye=y!==void 0&&y!=="",Dt=Ye?y:p("capture.tips.summary"),jt=Ye?dt!=="none":dt==="partner"||dt==="default"&&uo(b),pr=xe(()=>jt?{playing:Gt,toggle:n(()=>Ft(Dt,{clip:!Ye}),"toggle"),stop:qt}:void 0,[jt,Gt,Ft,Dt,qt,Ye]),fr=xe(()=>({assets:it,retryAssets:A.retry,permission:P.permission,permissionSettled:P.permissionSettled,captureMode:K.mode,facing:Ee,voice:Ae}),[it,A.retry,P.permission,P.permissionSettled,K.mode,Ee,Ae]),mr=fo(i)?R(q,{tone:i.tone,testId:"sekyro-host-notice",children:R("span",{children:i.text})}):i??null,X=Z!==null&&Z.status==="retry"?Z:null,G=Nt&&Z.status==="unavailable"&&!B&&Z.reasonCode!=="portrait_required"?Z:null,ue=Nt&&(Z.status==="verified"||Z.status==="not_verified"||Z.status==="review")?Z:null,pt=n((f,$)=>{if(f===void 0)return null;if(f==="device_cooldown"){let Re=Xt(t,$);if(Re!==null)return p(Re.key).replace("{time}",Re.time)}let de=Jt(f);return de===null?null:p(de)},"reasonText"),ft=n(f=>{let $=f.retakeHint===void 0?null:Wt(f.retakeHint);return $===null?pt(f.reasonCode):p($)},"retryText"),$t=ue===null?null:pt(ue.reasonCode,ue.retryAfter)??(ue.status==="not_verified"&&ue.reason!==void 0&&co.has(ue.reason)?p("errors.session_expired"):null),yr=G!==null&&G.reasonCode!==void 0&&G.reasonCode!=="nni_unbound"&&G.reasonCode!=="id_number_unbound"&&G.reasonCode!=="method_required"&&G.reasonCode!=="mobile_required"&&!(G.reasonCode==="no_recorder"&&a.artifacts?.degraded==="NO_RECORDER"),Ze=G?.reasonCode,zt=a.attempt;oe(()=>{G===null||Ze===void 0||e?.reportCaptureIssue===void 0||mo.has(Ze)||We(f=>e.reportCaptureIssue?.(f),{check:"liveness",kind:"unavailable",phase:"upload",engineKind:Ze,attempt:Math.min(1e3,zt)})},[G,Ze,zt,e]);let Yt=Qe(),gr=B&&_.auto===null&&!O&&!le&&a.error===null,mt=st(async f=>{await _.select(f)&&a.state==="done"&&a.retry()},[_.select,a.state,a.retry]);return oe(()=>{_.auto!==null&&!_.busy&&!O&&!le&&mt(_.auto)},[_.auto,_.busy,O,le,mt]),R(rn,{value:p,children:Ie("div",{ref:Q,className:V===void 0?"sekyro-capture":`sekyro-capture ${V}`,dir:U,lang:t,"data-testid":"sekyro-liveness-capture","data-state":a.state,children:[s?.header,X!==null&&ft(X)!==null&&!(De&&qe)?R(q,{tone:"warning",role:"status",testId:"sekyro-retry-notice",children:R("span",{children:ft(X)})}):null,je!==null&&!De?R(q,{tone:"info",role:"status",testId:"sekyro-mode-switch-status",children:R("span",{children:je})}):null,ae&&le&&!De?R(q,{tone:"info",role:"status",testId:"sekyro-busy-notice",children:R("span",{children:p("capture.busy")})}):null,N.required&&ye?R(q,{tone:"info",role:"status",testId:"sekyro-mobile-required",children:R("span",{children:p("reasons.mobile_required")})}):null,a.error!==null?s?.errorPanel!==void 0?s.errorPanel(a.error,a.retry):Ie(q,{tone:"danger",testId:"sekyro-error-notice",children:[R("span",{children:p(Qt(a.error))}),a.error.retryable?R(F,{ref:Yt,kind:"ghost",className:"sekyro-btn--start",onClick:a.retry,children:p("common.retry")}):null]}):null,G!==null?Ie(q,{tone:"danger",testId:"sekyro-unavailable-notice",children:[R("span",{children:pt(G.reasonCode)??p(G.reasonCode===void 0?"errors.session_expired":"errors.network_error")}),yr?R(F,{ref:Yt,kind:"ghost",className:"sekyro-btn--start",onClick:a.retry,children:p("capture.recordAgain")}):null]}):null,$t!==null&&ue!==null?R(q,{tone:ue.status==="not_verified"?"danger":"info",testId:"sekyro-result-notice",children:R("span",{children:$t})}):null,R("div",{className:qe?void 0:"sekyro-hidden","data-capture-live":qe?"":void 0,children:De?se({videoRef:H,guidance:Pe&&Se?p("capture.checking"):lt,coached:ct&&!(Pe&&Se),note:Pe?Se?p(ae?"capture.busy":"capture.checkingHint"):null:je??(X!==null?ft(X):Kt),settled:Pe&&Se,progress:a.gate.progress,phase:At,still:Pe?Et:null,live:qe,modeSwitch:Pt,...Mt?{status:je}:{},ramp:a.rampColour===null?null:{colour:a.rampColour}}):R(on,{videoRef:H,guidanceText:lt,guidanceHint:$e,guidanceKey:ge,progress:a.gate.progress,phase:At,draining:a.draining,stillUrl:Et,showChecking:Se,operatorText:Kt,voicePrompt:dr,overlay:f=>Ie(ir,{children:[s?.stageOverlay?.(f),R(an,{colour:a.rampColour})]}),reduceMotion:a.reduceMotion,modeSwitch:Pt})}),gr&&_.choice!==null?R(kn,{title:p("method.title"),description:p("method.description"),options:_.choice.options.map(f=>({id:f,label:p(`method.${f}`)})),busy:_.busy,error:_.failed?p("errors.network_error"):null,focus:a.state==="done",testId:"sekyro-method",look:"buttons",onChoose:f=>{mt(f)}}):null,cr?Ie(ir,{children:[ie&&s?.header===void 0&&s?.intro===void 0?Ie("div",{className:"sekyro-stack sekyro-stack--1",children:[R("h2",{className:"sekyro-text-body",children:p("returning.title")}),R("p",{className:"sekyro-text-muted",children:p("returning.description")})]}):null,mr,s?.intro!==void 0?s.intro(Ge,fr):R(Gn,{assets:it,onRetryAssets:A.retry,permission:P.permission,captureMode:K.mode,voice:Ae,tips:b??Je,summary:pr,startLabel:k,startDisabled:u,onStart:Ge})]}):null,R(An,{showCoaching:X!==null,coaching:Pn(X?.reasonCode),attemptsText:X?.attemptsRemaining!==void 0?en(T,t,X.attemptsRemaining):null,showRetake:X!==null&&!O&&!le||!Se&&a.state==="captured",onRetake:a.retry}),s?.footer]})})}n(_i,"LivenessCapture");export{Pn as a,En as b,tt as c,Tn as d,Je as e,kn as f,$n as g,et as h,lo as i,_i as j};
2
+ import{a as on,c as an}from"./chunk-EDIXRMTS.js";import{b as sn,c as We}from"./chunk-7MMT5M4E.js";import{a as tn,b as nn,c as rn,d as z}from"./chunk-IAZ5UH2B.js";import{a as F,k as Zt,l as Wt,n as Qt,o as Jt,p as Xt,q as en,r as q,s as Qe}from"./chunk-6QYD5HOU.js";import{a as n}from"./chunk-2KED7D2Q.js";import{useId as vr}from"react";import{Fragment as hr,jsx as M,jsxs as ee}from"react/jsx-runtime";function te({className:e,children:t}){return M("svg",{"aria-hidden":"true",focusable:"false",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",className:e??"sekyro-icon sekyro-icon--sm",children:t})}n(te,"Svg");var yt="M4 7.5h2.2l1.4-1.9h8.8l1.4 1.9H20a1.6 1.6 0 0 1 1.6 1.6v8.3A1.6 1.6 0 0 1 20 19H4a1.6 1.6 0 0 1-1.6-1.6V9.1A1.6 1.6 0 0 1 4 7.5Z";function cn(e){return ee(te,{...e,children:[M("circle",{cx:"12",cy:"12",r:"4"}),M("path",{d:"M12 2.5v2M12 19.5v2M2.5 12h2M19.5 12h2M5.3 5.3l1.4 1.4M17.3 17.3l1.4 1.4M5.3 18.7l1.4-1.4M17.3 6.7l1.4-1.4"})]})}n(cn,"SunIcon");function ln(e){return ee(te,{...e,children:[M("circle",{cx:"12",cy:"12",r:"9"}),M("path",{d:"M9 10h.01M15 10h.01M8.8 14.6a4.2 4.2 0 0 0 6.4 0"})]})}n(ln,"FaceUncoveredIcon");function un(e){return ee(te,{...e,children:[M("rect",{x:"7",y:"2.5",width:"10",height:"19",rx:"2"}),M("path",{d:"M10.5 18.5h3M2.5 9.5h2.5M19 9.5h2.5"}),M("circle",{cx:"12",cy:"9.5",r:"1.6"})]})}n(un,"PhoneEyeLevelIcon");function dn(e){return ee(te,{...e,children:[M("path",{d:"M2.5 12S6 5.5 12 5.5 21.5 12 21.5 12 18 18.5 12 18.5 2.5 12 2.5 12Z"}),M("circle",{cx:"12",cy:"12",r:"2.8"})]})}n(dn,"LookStraightIcon");function pn(e){return ee(te,{...e,children:[M("path",{d:yt}),M("path",{d:"M9 13l2 2 4-4"})]})}n(pn,"CameraCheckIcon");function fn(e){return ee(te,{...e,children:[M("path",{d:yt}),M("path",{d:"M10.2 11.2a1.9 1.9 0 1 1 2.6 1.8c-.5.2-.8.6-.8 1.1v.3M12 16.4h.01"})]})}n(fn,"CameraAskIcon");function mn(e){return ee(te,{...e,children:[M("path",{d:yt}),M("path",{d:"M3 3l18 18"})]})}n(mn,"CameraBlockedIcon");function Ve({off:e,className:t}){return ee(te,{className:t,children:[M("path",{d:"M4.5 9.5v5H8l4 3.5v-12L8 9.5H4.5Z"}),e?M("path",{d:"M4 4l16 16"}):ee(hr,{children:[M("path",{d:"M15.5 9.7a3.6 3.6 0 0 1 0 4.6"}),M("path",{d:"M18 7.6a6.6 6.6 0 0 1 0 8.8"})]})]})}n(Ve,"SpeakerIcon");function yn(e){return M(te,{...e,children:M("path",{d:"M5 12.5l4.5 4.5L19 7.5"})})}n(yn,"CheckIcon");function gn(e){return ee(te,{className:e.className??"sekyro-spinner",children:[M("circle",{cx:"12",cy:"12",r:"9",opacity:"0.25"}),M("path",{d:"M21 12a9 9 0 0 0-9-9"})]})}n(gn,"SpinnerIcon");import{jsx as pe,jsxs as hn}from"react/jsx-runtime";var Je=["light","uncover","eyeLevel","straight"],Cr={light:{key:"capture.tips.light",icon:n(()=>pe(cn,{}),"icon")},uncover:{key:"capture.tips.uncover",icon:n(()=>pe(ln,{}),"icon")},eyeLevel:{key:"capture.tips.eyeLevel",icon:n(()=>pe(un,{}),"icon")},straight:{key:"capture.tips.straight",icon:n(()=>pe(dn,{}),"icon")}};function vn({tips:e}){let t=z(),o=vr();return e.length===0?null:hn("section",{className:"sekyro-tips","aria-labelledby":o,"data-testid":"sekyro-tips",children:[pe("p",{className:"sekyro-tips__title",id:o,children:t("capture.tips.title")}),pe("ul",{className:"sekyro-tips__list",children:e.map(r=>{let s=typeof r=="string"?Cr[r]:void 0,c=typeof r=="string"?r:r.id,i=s!==void 0?s.icon():typeof r=="string"?void 0:r.icon,u=s!==void 0?t(s.key):typeof r=="string"?r:r.text;return hn("li",{className:"sekyro-tips__item",children:[i!=null?pe("span",{className:"sekyro-tips__icon","aria-hidden":"true",children:i}):null,pe("span",{children:u})]},c)})})]})}n(vn,"TipList");import{useEffect as Cn,useId as kr,useRef as br,useState as Sr}from"react";import{jsx as W,jsxs as Xe}from"react/jsx-runtime";var Rr=220;function kn({title:e,description:t,options:o,busy:r,error:s,focus:c,testId:i,look:u="cards",marked:k,onChoose:b}){let y=kr(),w=Qe(),[S,d]=Sr(null),C=br(null);Cn(()=>{s!==null&&d(null)},[s]),Cn(()=>()=>{C.current!==null&&clearTimeout(C.current)},[]);let v=n(l=>{r||S!==null||(d(l),C.current=setTimeout(()=>{C.current=null,d(null),b(l)},Rr))},"choose");return Xe("section",{className:"sekyro-stack sekyro-stack--4 sekyro-choice","aria-labelledby":y,"data-testid":i,children:[Xe("div",{className:u==="cards"?"sekyro-heading":"sekyro-stack sekyro-stack--1",children:[W("h2",{id:y,ref:c?w:void 0,tabIndex:-1,className:"sekyro-text-body",children:e}),t!==void 0&&t!==""?W("p",{className:"sekyro-text-muted",children:t}):null]}),s!==null?W(q,{tone:"danger",children:W("span",{children:s})}):null,u==="buttons"?W("div",{className:"sekyro-stack sekyro-stack--3",children:o.map((l,L)=>W(F,{kind:L===0?"primary":"ghost",full:!0,disabled:r,"aria-busy":r||void 0,onClick:()=>b(l.id),children:l.label},l.id))}):W("div",{className:"sekyro-choices",children:o.map(l=>Xe("button",{type:"button",className:"sekyro-card","aria-pressed":(S??k)===l.id,"aria-busy":r||void 0,disabled:r||S!==null&&S!==l.id,onClick:()=>v(l.id),children:[l.glyph!==void 0?W("span",{className:"sekyro-card__tile",children:l.glyph}):null,Xe("span",{className:"sekyro-card__body",children:[W("span",{className:"sekyro-card__title",children:l.label}),l.sub!==void 0?W("span",{className:"sekyro-card__sub",children:l.sub}):null]}),W("span",{className:"sekyro-radio","aria-hidden":"true"})]},l.id))})]})}n(kn,"ChoiceScreen");var et=["fcv3.no_face","fcv3.come_closer","fcv3.move_back","fcv3.center_face","fcv3.straighten","fcv3.more_light","fcv3.too_bright","fcv3.hold_still","fcv3.steady_camera","fcv3.hold_upright","fcv3.one_face","capture.tips.summary"];function he(e){return e!==null&&et.includes(e)}n(he,"isVoiceKey");import{useCallback as re,useEffect as ve,useLayoutEffect as Lr,useMemo as _r,useRef as we,useState as Oe}from"react";var Vr=n((e,t)=>Object.prototype.hasOwnProperty.call(e,t),"own");function Me(e,t,o){let r;try{if(typeof e=="function")r=e(t,o);else{let s=e[o];r=s!=null&&Vr(s,t)?s[t]:null}}catch{return null}return typeof r=="string"&&r!==""?r:null}n(Me,"resolveClip");var Mr="UklGRiQAAABXQVZFZm10IBAAAAABAAEAESsAACJWAAACABAAZGF0YQAAAAA=",Rn={ar:"ar-SA",fr:"fr-FR",en:"en-US",es:"es-ES",pt:"pt-BR",de:"de-DE"};function ne(){return typeof window<"u"&&"speechSynthesis"in window?window.speechSynthesis:null}n(ne,"synth");function wr(){return ne()!==null&&typeof SpeechSynthesisUtterance=="function"}n(wr,"speechAvailable");function bn(e){return(e.split(/[-_]/)[0]??e).toLowerCase()}n(bn,"baseLang");function Vn(e,t){let o=n(s=>s.replace(/_/g,"-").toLowerCase(),"norm"),r=bn(t);return e.find(s=>o(s.lang)===o(t))??e.find(s=>bn(s.lang)===r)}n(Vn,"pickVoice");function Mn(e){if(!wr())return!1;let t=[];try{t=ne()?.getVoices()??[]}catch{return!0}return t.length===0||Vn(t,e)!==void 0}n(Mn,"speechUsable");function wn(e){let t=ne();return t===null||typeof t.addEventListener!="function"?()=>{}:(t.addEventListener("voiceschanged",e),()=>t.removeEventListener?.("voiceschanged",e))}n(wn,"subscribeVoices");function Ke(e){try{let t=typeof location<"u"?location.href:"http://localhost/",o=new URL(e,t);return`clip:${o.origin}${o.pathname}`}catch{return`clip:${e}`}}n(Ke,"clipIdentity");function Sn(e){e.pause(),e.removeAttribute("src"),e.load()}n(Sn,"release");function Ln(){let e=null,t=null,o=0,r=null,s=[],c=new Map,i=n(()=>{s=ne()?.getVoices()??[]},"loadVoices"),u=!1,k=n(()=>{let d=ne();u||d===null||(u=!0,i(),d.addEventListener?.("voiceschanged",i))},"bindVoices"),b=n(()=>(e??(e=new Audio),e),"element"),y=n((d,C,v)=>{let l=ne();if(l!==null&&d!==""&&typeof SpeechSynthesisUtterance=="function"){k();let L=Vn(s,C);if(s.length===0||L!==void 0){l.cancel();let g=new SpeechSynthesisUtterance(d);g.lang=C,L!==void 0&&(g.voice=L),g.rate=.95,v!==void 0&&(g.onend=g.onerror=v),l.speak(g);return}}v?.()},"speak"),w=n(()=>{o+=1,r=null,e!==null&&(e.pause(),e.currentTime=0),ne()?.cancel()},"stop"),S=n(d=>{for(let C of d){let v=Ke(C);if(c.has(v))continue;let l=new Audio;l.preload="auto",l.src=C,c.set(v,l)}},"warmClips");return{say(d){let C=d.url!==null?Ke(d.url):`tts:${d.lang}:${d.text}`;if(C===r)return;r=C,o+=1;let v=o,l=d.onEnd,L=l!==void 0?()=>{v===o&&l()}:void 0;if(ne()?.cancel(),d.url!==null){let g=b();g.pause(),g.muted=!1,g.src=d.url,g.currentTime=0,g.onended=L??null,g.play()?.catch(V=>{v===o&&V?.name!=="AbortError"&&(d.speech?y(d.text,d.lang,L):L?.())});return}d.speech?y(d.text,d.lang,L):L?.()},unlock({lang:d,speech:C,prefetch:v}){let l=b();if(t===null&&typeof Blob=="function"&&typeof URL.createObjectURL=="function"){let V=Uint8Array.from(atob(Mr),E=>E.charCodeAt(0));t=URL.createObjectURL(new Blob([V],{type:"audio/wav"}))}let L=l.paused===!1&&t!==null&&l.src!==t;t!==null&&!L&&(l.muted=!0,l.onended=null,l.src=t,l.play()?.catch(()=>{}));let g=ne();if(C&&g!==null&&typeof SpeechSynthesisUtterance=="function"){k();let V=new SpeechSynthesisUtterance(" ");V.volume=0,V.lang=d,g.speak(V)}S(v??[])},prefetch:S,stop:w,dispose(){w(),u&&ne()?.removeEventListener?.("voiceschanged",i),u=!1,t!==null&&URL.revokeObjectURL(t),t=null,e!==null&&Sn(e),e=null;for(let d of c.values())Sn(d);c.clear()}}}n(Ln,"createVoicePlayer");var _n="sekyro.voiceGuidance";function xn(e){try{if(typeof window>"u")return null;let t=window.localStorage.getItem(e);return t==="1"?!0:t==="0"?!1:null}catch{return null}}n(xn,"readVoicePreference");function In(e,t){try{if(typeof window>"u")return;window.localStorage.setItem(e,t?"1":"0")}catch{}}n(In,"writeVoicePreference");var Ue="capture.tips.summary",xr=typeof window<"u"?Lr:ve,Ir=Object.freeze({});function gt(e,t){let o=new Set,r=[];for(let s of et){let c=s===Ue?null:Me(e,s,t);c===null||o.has(Ke(c))||(o.add(Ke(c)),r.push(c))}return r}n(gt,"resolvedClipUrls");function ht({locale:e,defaultClips:t,options:o}){let r=o===!1,s=r?{}:o??{},c=s.storageKey===void 0?_n:s.storageKey,[i,u]=Oe(s.defaultEnabled??!0),k=we(i),[b,y]=Oe(!1),[w,S]=Oe("none"),[d,C]=Oe(!1),v=we(!1),[l,L]=Oe(0),g=we(null),V=re(()=>(g.current??(g.current=Ln()),g.current),[]),E=Rn[e],T=s.speechFallback,p=T===void 0||T===!0?!0:T===!1?!1:T.includes(e),U=s.clips??t??Ir,H=we(!1),se=we(U);xr(()=>{se.current=U,k.current=i}),ve(()=>{if(r||c===null)return;let h=xn(c);h!==null&&(k.current=h,u(h))},[r,c]),ve(()=>{if(!(r||!p))return wn(()=>L(h=>h+1))},[r,p]);let a=s.clips;ve(()=>{if(r)return;let h=p&&Mn(E);y(gt(U,e).length>0||h),S(a!==void 0&&Me(a,Ue,e)!==null?"partner":Me(U,Ue,e)!==null||h?"default":"none")},[r,U,a,e,p,E,l]),ve(()=>{if(r||!i||!H.current)return;let h=gt(U,e);h.length>0&&V().prefetch(h)},[r,i,U,e,V]),ve(()=>()=>{g.current?.dispose(),g.current=null,H.current=!1},[]);let A=re(h=>{r||(H.current=!0,V().unlock({lang:E,speech:p,...h?{prefetch:gt(se.current,e)}:{}}))},[r,V,E,p,e]),_=re(()=>A(k.current),[A]),B=re(()=>{v.current=!1,C(!1)},[]),N=re(()=>{B(),g.current?.stop()},[B]),ie=re(()=>{v.current&&N()},[N]),ae=re((h,me)=>{if(r)return;if(v.current){N();return}let ce=V();ce.stop(),v.current=!0,C(!0);let x=me?.clip===!1?null:Me(se.current,Ue,e);ce.say({url:x,text:h,lang:E,speech:p,onEnd:B})},[r,N,V,e,E,p,B]),P=re(h=>{r||(h?A(!0):N(),c!==null&&In(c,h),k.current=h,u(h))},[r,A,N,c]),K=re(()=>P(!k.current),[P]),fe=re((h,me)=>{if(r||!i)return;v.current&&B();let ce=Me(se.current,h,e);V().say({url:ce,text:me,lang:E,speech:p})},[r,i,e,V,E,p,B]);return _r(()=>({supported:!r&&b,enabled:!r&&i,setEnabled:P,toggle:K,unlock:_,speakKey:fe,stop:N,summary:r?"none":w,summaryPlaying:d,toggleSummary:ae,stopSummary:ie}),[r,b,i,P,K,_,fe,N,w,d,ae,ie])}n(ht,"useVoiceGuidance");function vt(e,t,o,r){let{speakKey:s,stop:c,enabled:i}=e,u=we(!1);ve(()=>{if(!r||!i){u.current&&c(),u.current=!1;return}u.current=!0,he(t)&&t!==Ue&&o!==""&&s(t,o)},[r,i,t,o,s,c])}n(vt,"useSpeakGuidance");import{isValidElement as io,useCallback as st,useContext as ao,useEffect as oe,useMemo as xe,useRef as ke,useState as sr}from"react";import{useEffect as Er,useRef as Nr}from"react";import{jsx as He,jsxs as Nn}from"react/jsx-runtime";function Pn(e){switch(e){case"multiple_faces":return"one_face";case"capture_back_camera":return"front_camera";case"capture_front_camera":return"back_camera";case"capture_not_upright":return"upright";case"media_unreadable":case"clip_too_short":return"recording";case"device_integrity_failed":return"device";default:return"face"}}n(Pn,"retryCoachingOf");var En={face:{title:"capture.retryCoaching.title",tips:["capture.retryCoaching.light","capture.retryCoaching.eyeLevel","capture.retryCoaching.head"]},one_face:{title:"capture.retryTips.title",tips:["capture.retryOneFace.alone","capture.retryOneFace.screens"]},front_camera:{title:"capture.retryTips.title",tips:["capture.retryFrontCamera.screenSide"]},back_camera:{title:"capture.retryTips.title",tips:["capture.retryBackCamera.backSide","capture.retryBackCamera.circle"]},upright:{title:"capture.retryTips.title",tips:["capture.retryUpright.vertical","capture.retryUpright.untilEnd"]},recording:{title:"capture.retryTips.title",tips:["capture.retryRecording.cameraOn","capture.retryRecording.stay","capture.retryRecording.network"]},device:{title:"capture.retryTips.title",tips:["capture.retryDevice.screenRecording","capture.retryDevice.phone"]}};function An({showCoaching:e,coaching:t="face",attemptsText:o,showRetake:r,onRetake:s}){let c=z(),i=Nr(null);return Er(()=>{r&&i.current?.focus()},[r]),!e&&!r?null:Nn("div",{className:"sekyro-stack sekyro-stack--3","data-testid":"sekyro-captured-panel",children:[e?Nn("div",{className:"sekyro-stack sekyro-stack--1",children:[He("p",{className:"sekyro-text-body",children:c(En[t].title)}),He("ul",{className:"sekyro-coaching",children:En[t].tips.map(u=>He("li",{children:c(u)},u))}),o!==null?He("p",{className:"sekyro-text-muted","data-testid":"sekyro-attempts-remaining",children:o}):null]}):null,r?He(F,{ref:i,className:"sekyro-btn--start",onClick:s,children:c("capture.recordAgain")}):null]})}n(An,"CapturedPanel");function tt(){try{return process.env.NODE_ENV!=="production"}catch{return!1}}n(tt,"isDevBuild");import{createContext as Pr}from"react";var Tn=Pr(null);import{useCallback as Hn,useEffect as Bn,useRef as Le}from"react";import{useEffect as Ar,useState as Tr}from"react";import{jsx as Be,jsxs as Kr}from"react/jsx-runtime";function Kn({state:e}){let t=z(),[o,r]=Tr(!1);Ar(()=>{e!=="unknown"&&r(!0)},[e]);let s=e==="granted"?Be(pn,{}):e==="denied"?Be(mn,{}):Be(fn,{});return Kr("div",{role:o?"status":void 0,className:`sekyro-permission sekyro-permission--${e}`,"data-testid":"sekyro-permission","data-state":e,children:[Be("span",{className:"sekyro-permission__icon","aria-hidden":"true",children:s}),Be("span",{children:t(`capture.permission.${e}`)})]})}n(Kn,"PermissionRow");import{jsx as nt,jsxs as On}from"react/jsx-runtime";function Un({voice:e}){let t=z();if(!e.supported)return null;let o=e.enabled;return On("button",{type:"button",role:"switch","aria-checked":o,className:"sekyro-switch","data-testid":"sekyro-voice-switch",onClick:()=>e.toggle(),children:[On("span",{className:"sekyro-switch__label",children:[nt(Ve,{off:!o}),t("capture.voiceGuidance")]}),nt("span",{className:"sekyro-switch__track","aria-hidden":"true",children:nt("span",{className:"sekyro-switch__thumb",children:o?nt(yn,{className:"sekyro-switch__check"}):null})})]})}n(Un,"VoiceSwitch");import{Fragment as Ur,jsx as D,jsxs as _e}from"react/jsx-runtime";function Gn({assets:e,onRetryAssets:t,permission:o,captureMode:r="self",voice:s,tips:c,summary:i,startLabel:u,startDisabled:k,onStart:b}){let y=z(),w=Le(i?.stop);w.current=i?.stop,Bn(()=>()=>w.current?.(),[]);let S=Le(null),d=Le(null),C=Le(null),v=Le(e),l=Le(!1);Bn(()=>{let U=v.current;if(v.current=e,U===e)return;let H=l.current;e!=="loading"&&(l.current=!1),Or(S.current)&&(e==="failed"?C.current?.focus():H&&d.current?.focus())},[e]);let L=Hn(()=>{l.current=!0,t()},[t]),g=e==="loading",V=g||k,E=Hn(()=>{V||(w.current?.(),b())},[V,b]),T;return e==="failed"?T=_e(q,{tone:"danger",testId:"sekyro-assets-error",children:[D("p",{className:"sekyro-text-body",children:y("fcv2.err.models")}),D(F,{kind:"ghost",ref:C,className:"sekyro-btn--start",onClick:L,"data-testid":"sekyro-assets-retry",children:y("common.retry")})]}):T=_e("div",{className:"sekyro-stack sekyro-stack--1",children:[D(F,{ref:d,full:!0,"data-testid":"sekyro-start","aria-disabled":V?"true":void 0,"aria-busy":g?"true":void 0,onClick:E,children:g?_e(Ur,{children:[D(gn,{}),y("capture.preparing.title")]}):u??y("capture.start")}),g?D("p",{className:"sekyro-text-muted",children:y("capture.preparing.hint")}):null]}),_e("div",{ref:S,className:"sekyro-stack sekyro-stack--4","data-testid":"sekyro-intro","data-assets":e,children:[r==="assisted"?_e("div",{className:"sekyro-stack sekyro-stack--1","data-testid":"sekyro-assisted-intro",children:[D("h2",{className:"sekyro-text-body",children:y("capture.assisted.title")}),D("p",{className:"sekyro-text-muted",children:y("capture.assisted.lead")})]}):null,c!==!1?D(vn,{tips:c}):null,i!==void 0?_e(F,{kind:"ghost",className:"sekyro-btn--start",onClick:i.toggle,"data-testid":"sekyro-tips-listen",children:[D(Ve,{off:!1}),y(i.playing?"capture.tips.stop":"capture.tips.listen")]}):null,D(Kn,{state:o}),D(Un,{voice:s}),D("p",{className:"sekyro-text-muted",children:y("capture.securityNote")}),T,D("p",{role:"status",className:"sekyro-visually-hidden","data-testid":"sekyro-intro-status",children:e==="loading"?y("capture.preparing.title"):e==="ready"?y("capture.ready"):""})]})}n(Gn,"PreCaptureScreen");function Or(e){if(typeof document>"u")return!1;let t=document.activeElement;return t===null||t===document.body||e!==null&&e.contains(t)}n(Or,"focusIsOurs");import{subscribeCameraPermission as Hr}from"@sekyro/web";import{useEffect as Br,useState as Gr}from"react";function Fn(){let[e,t]=Gr({state:"unknown",settled:!1});return Br(()=>Hr(o=>t({state:o,settled:!0})),[]),{permission:e.state,permissionSettled:e.settled}}n(Fn,"useCameraStatus");import{useCallback as Fr,useEffect as Ct,useState as kt}from"react";function qn(e){return jn(e,"mobileRequired")}n(qn,"useMobileRequired");function Dn(e){return jn(e,"returning").required}n(Dn,"useReturning");function jn(e,t){let[o,r]=kt({required:!1,settled:e===void 0});return Ct(()=>{let s=e?.[t];if(e===void 0||typeof s!="function"){r({required:!1,settled:!0});return}let c=!0;return r({required:!1,settled:!1}),Promise.resolve().then(()=>s.call(e)).then(i=>{c&&r({required:i===!0,settled:!0})},()=>{c&&r({required:!1,settled:!0})}),()=>{c=!1}},[e,t]),o}n(jn,"useFlag");function $n(e){let t=n(()=>e?.captureChoice??null,"initialChoice"),[o,r]=kt(()=>({session:"self",choice:t(),settled:e===void 0}));Ct(()=>{let i=e?.captureMode,u=e?.captureChoice??null;if(e===void 0||typeof i!="function"){r({session:"self",choice:u,settled:!0});return}let k=!0;return r({session:"self",choice:u,settled:!1}),Promise.resolve().then(()=>i.call(e)).then(b=>{let y=e.captureChoice??null;k&&r({session:y!==null&&b===y?"choice":b==="assisted"||b==="choice"?b:"self",choice:y,settled:!0})},()=>{k&&r({session:"self",choice:null,settled:!0})}),()=>{k=!1}},[e]);let s=Fr(i=>{e?.chooseCaptureMode?.(i),r(u=>({...u,choice:i}))},[e]);return{mode:o.session==="choice"?o.choice??"self":o.session==="assisted"?"assisted":"self",session:o.session,choice:o.choice,settled:o.settled,choose:s}}n($n,"useCaptureMode");function zn(e){let[t,o]=kt(!1);return Ct(()=>{if(o(!1),e===void 0)return;let r=e.on("busy",()=>o(!0)),s=e.on("result",()=>o(!1));return()=>{r(),s()}},[e]),t}n(zn,"useBusy");import{getLivenessAssetsStatus as qr,preloadLivenessAssets as Dr,subscribeLivenessAssets as jr}from"@sekyro/web";import{useCallback as bt,useEffect as Yn,useRef as Zn,useState as $r,useSyncExternalStore as zr}from"react";var Yr=n(()=>"idle","serverSnapshot");function Wn(e){return Dr(e!==void 0?{assetBaseUrl:e}:{})}n(Wn,"preload");function Qn(e,t=!0){let o=zr(bt(w=>jr(w,e),[e]),()=>qr(e),Yr),[r,s]=$r(null),c=Zn(!1),i=bt(()=>{Wn(e).then(w=>{c.current&&w==="idle"&&s({base:e})})},[e]);Yn(()=>(c.current=!0,i(),()=>{c.current=!1}),[i]);let u=Zn(null);Yn(()=>{if(o!=="idle"){u.current={base:e};return}!t||u.current===null||u.current.base!==e||(u.current=null,i())},[o,e,i,t]);let k=bt(()=>{Wn(e)},[e]);return{gate:r!==null&&r.base===e&&o==="idle"||o==="ready"?"ready":o==="failed"?"failed":"loading",retry:k}}n(Qn,"useLivenessAssets");import{createLivenessCapture as Zr}from"@sekyro/web";import{useCallback as rt,useEffect as Wr,useRef as Ce,useState as j}from"react";var Jn={progress:0,hint:null,faceDetected:!1};function Xn(e){let{videoRef:t,assetBaseUrl:o}=e,s=Ce(e.verification).current,c=Ce(!1);e.verification!==s&&!c.current&&tt()&&(c.current=!0,console.warn("[@sekyro/react] <LivenessCapture>: the `verification` prop changed identity after mount. The first instance stays bound (the camera is not rebuilt); create the verification once (useMemo / useState / outside render) instead of on every render."));let i=Ce(null),[u,k]=j("idle"),[b,y]=j(Jn),[w,S]=j(!1),[d,C]=j(!1),[v,l]=j(null),[L,g]=j(!1),[V,E]=j(null),[T,p]=j(null),[U,H]=j(null),[se,a]=j(null),[A,_]=j(null),[B,N]=j(!1),ie=Ce(null),ae=Ce("idle"),P=Ce(-1),[K,fe]=j(0),h=Ce(e);h.current=e,Wr(()=>{let Y=t.current;if(Y===null)return;let Q={video:Y,...o!==void 0?{assetBaseUrl:o}:{}},I=s!==void 0?s.liveness(Q):Zr(Q);i.current=I;let Ne=n(()=>_(I.facingMode??null),"readFacing");Ne();let Ge=[I.on("state",m=>{m==="mode_switch"?N(!0):m!=="starting"&&m!=="gating"&&N(!1),m==="starting"?(ae.current!=="starting"&&(P.current+=1,fe(Math.max(0,P.current))),p(null),H(null),y(Jn),C(!1),S(!1),l(null),E(null),ie.current=null):m==="gating"&&ae.current==="recording"&&(C(!1),S(!1),l(null),ie.current=null),ae.current=m,Ne(),k(m),h.current.onStateChange?.(m)}),I.on("gate",m=>{let J=ie.current;ie.current=m.progress,S(J!==null&&m.progress<J-.001&&m.progress>0&&m.progress<1),m.progress>=1&&C(!0),y(m)}),I.on("frozen",({previewDataUrl:m})=>l(m)),I.on("profile",({animations:m})=>g(m==="reduced")),I.on("ramp",({colour:m})=>E(m)),I.on("captured",m=>{p(m),a(null),h.current.onCaptured?.(m)}),I.on("error",m=>{H(m);let J=s?.reportCaptureIssue;J!==void 0&&We(ye=>J.call(s,ye),sn("liveness",m,Math.max(0,P.current))),h.current.onError?.(m)}),s?.on("result",m=>{a(m),h.current.onResult?.(m)})];return()=>{for(let m of Ge)m?.();i.current=null,I.destroy()}},[s,t,o]);let me=rt(()=>{i.current?.start()},[]),ce=rt(()=>{i.current?.retry()},[]),x=rt(async()=>{let Y=i.current;return Y===null||typeof Y.canSwitchCaptureMode!="function"?!1:await Y.canSwitchCaptureMode().catch(()=>!1)===!0},[]),Ee=rt(async Y=>{let Q=i.current;if(Q===null||typeof Q.setCaptureMode!="function")return!1;let I=await Q.setCaptureMode(Y).catch(()=>!1)===!0;return I&&_(Q.facingMode??null),I},[]);return{state:u,gate:b,draining:w,gateLocked:d,frozenPreview:v,reduceMotion:L,rampColour:V,artifacts:T,error:U,result:se,facingMode:A,start:me,retry:ce,canSwitchCaptureMode:x,setCaptureMode:Ee,modeRestarted:B,attempt:K}}n(Xn,"useLivenessHandle");import{useCallback as Qr,useEffect as Jr,useState as ot}from"react";var Xr=new Set(["national_number"]);function er(e){if(e==null||!e.available||e.selected!==null)return null;let t=e.options.filter(o=>Xr.has(o));return t.length>0?{...e,options:t}:null}n(er,"pending");function tr(e){let[t,o]=ot(null),[r,s]=ot(e===void 0),[c,i]=ot(!1),[u,k]=ot(!1);Jr(()=>{if(o(null),e===void 0){s(!0);return}let S=!0,d=e.methodChoice;typeof d=="function"?(s(!1),Promise.resolve().then(()=>d.call(e)).then(v=>{S&&o(er(v))},()=>{}).finally(()=>{S&&s(!0)})):s(!0);let C=e.on("method",v=>o(er(v)));return()=>{S=!1,C()}},[e]);let b=Qr(async S=>{if(e===void 0)return!1;i(!0),k(!1);try{return await e.selectMethod(S),o(null),!0}catch{return k(!0),!1}finally{i(!1)}},[e]),y=t!==null&&t.options.length===1?t.options[0]:null;return{choice:t,auto:y==="national_number"&&!u?y:null,settled:r,busy:c,failed:u,select:b}}n(tr,"useMethodChoice");import{useEffect as eo,useMemo as to,useState as no}from"react";var ro=["ar","fr","en"];function oo(e){if(typeof e!="string")return!1;try{let t=new URL(e);return t.protocol==="https:"||t.protocol==="http:"&&/^(localhost|127\.0\.0\.1)$/.test(t.hostname)}catch{return!1}}n(oo,"isClipUrl");function so(e){let t=e.clips;if(typeof t!="object"||t===null)return null;let o={};for(let r of ro){let s=t[r];if(!(typeof s!="object"||s===null))for(let[c,i]of Object.entries(s))!he(c)||!oo(i)||((o[r]??(o[r]={}))[c]=i)}return Object.keys(o).length>0?o:null}n(so,"toVoiceClipMap");function nr(e){let[t,o]=no(null);eo(()=>{if(o(null),e===void 0)return;let s=!0,c=n(u=>{if(!s)return;let k=typeof u=="object"&&u!==null&&typeof u.setId=="string"?u:null;o(b=>b?.setId===k?.setId?b:k)},"take");try{typeof e.voiceClips=="function"&&Promise.resolve(e.voiceClips()).then(c,()=>c(null))}catch{c(null)}let i=e.on("view",u=>c(u.voice));return()=>{s=!1,i()}},[e]);let r=to(()=>t!==null?so(t):null,[t]);return e===void 0?null:r}n(nr,"useServerVoiceClips");import{jsx as rr}from"react/jsx-runtime";function or({voice:e}){let t=z();return rr(F,{kind:"chip","aria-pressed":e.enabled,"aria-label":t("capture.voiceGuidance"),"data-testid":"sekyro-voice-toggle",onClick:()=>e.toggle(),children:rr(Ve,{off:!e.enabled,className:"sekyro-icon"})})}n(or,"VoiceChip");import{Fragment as ir,jsx as R,jsxs as Ie}from"react/jsx-runtime";var co=new Set(["abandoned","not_opened","cancelled","superseded"]),lo=800;function uo(e){return e===void 0||e!==!1&&e.length===Je.length&&Je.every(t=>e.includes(t))}n(uo,"isDefaultTips");function po(e){if(e.type==="keydown"&&e.key==="Escape")return!1;let t=globalThis.navigator?.userActivation;return t===void 0?!(e.type==="pointerup"&&e.pointerType==="touch"):t.isActive}n(po,"carriesActivation");function fo(e){return typeof e=="object"&&e!==null&&!io(e)&&"tone"in e&&"text"in e}n(fo,"isNoticeObject");var mo=new Set(["nni_unbound","id_number_unbound","method_required","mobile_required","portrait_required"]);function yo(e){return e==="starting"||e==="gating"||e==="recording"||e==="mode_switch"}n(yo,"isCapturing");function go(e){return e==="captured"||e==="uploading"||e==="checking"}n(go,"isPostCapture");function _i({verification:e,locale:t,dir:o,strings:r,slots:s,autoStart:c=!1,notice:i,startDisabled:u=!1,startLabel:k,tips:b,tipsSummary:y,coach:w,voice:S,onGuidance:d,onCaptured:C,onResult:v,onError:l,onStateChange:L,assetBaseUrl:g,className:V}){let E=nn(t),T=xe(()=>tn(t,r),[t,r,E]),p=xe(()=>f=>T[f]??"",[T]),U=o??(t==="ar"?"rtl":"ltr"),H=ke(null),se=ao(Tn),a=Xn({verification:e,videoRef:H,assetBaseUrl:g,onCaptured:C,onResult:v,onError:l,onStateChange:L}),A=Qn(g,a.state==="idle"&&a.error===null),_=tr(e),B=_.choice!==null,N=qn(e),ie=Dn(e),ae=zn(e),P=Fn(),K=$n(e),fe=K.session==="choice",h=K.mode==="assisted",me=S!==!1&&S?.clips===void 0,ce=nr(me?e:void 0),x=ht({locale:t,defaultClips:ce,options:S}),Ee=h?"environment":"user",Y=K.settled,Q=ke(null),I=ke(!1),Ne=ke(x.unlock);Ne.current=x.unlock,oe(()=>{let f=Q.current;if(f===null)return;let $=["pointerup","touchend","click","keydown"],de=n(()=>{for(let Te of $)f.removeEventListener(Te,Re,!0)},"disarm");function Re(Te){if(I.current){de();return}po(Te)&&(I.current=!0,de(),Ne.current())}n(Re,"onGesture");for(let Te of $)f.addEventListener(Te,Re,{capture:!0,passive:!0});return de},[]);let Ge=st(()=>{I.current||(I.current=!0,x.unlock()),a.start()},[x.unlock,a.start]),m=st(()=>a.start(),[a.start]),J=ke(!1),ye=a.state==="idle"&&a.error===null,St=!B&&!N.required&&(c===!0||c==="when-permitted"&&P.permission==="granted"),Rt=St&&_.settled&&N.settled&&Y,ar=c==="when-permitted"&&!P.permissionSettled&&!J.current,Vt=St&&ye&&!J.current,it=(ar||Vt||!Y)&&A.gate==="ready"?"loading":A.gate;oe(()=>{!Rt||!ye||A.gate!=="ready"||J.current||(J.current=!0,m())},[Rt,ye,A.gate,m]);let cr=ye&&!B&&!N.required&&!(Vt&&A.gate==="ready"),[Mt,wt]=sr(!1),{canSwitchCaptureMode:Lt,setCaptureMode:_t}=a;oe(()=>{if(!K.settled||!fe){wt(!1);return}let f=!0;return Lt().then($=>{f&&wt($)}),()=>{f=!1}},[K.settled,fe,Lt]);let{choose:xt}=K,be=h?"self":"assisted",lr=st(async()=>{await _t(be)&&xt(be)},[_t,xt,be]),It=a.state!=="idle"&&a.facingMode!==null?a.facingMode:Ee;oe(()=>{let f=H.current?.style;It==="user"?f?.removeProperty("transform"):f&&(f.transform="none")},[It]);let Fe=xe(()=>a.artifacts!==null&&typeof URL.createObjectURL=="function"?URL.createObjectURL(a.artifacts.keyframe):null,[a.artifacts]);oe(()=>{if(Fe!==null)return()=>URL.revokeObjectURL(Fe)},[Fe]);let Et=a.frozenPreview??Fe,Se=e!==void 0,O=yo(a.state),le=go(a.state),qe=O||le,Z=a.result,Nt=a.state==="done"&&Z!==null,at=a.state==="recording"&&a.frozenPreview!==null,De=se!==null,Pt=Mt&&O&&!at?{to:be,label:p(be==="assisted"?"capture.modeSwitch.toAssisted":"capture.modeSwitch.toSelf"),description:p(be==="assisted"?"capture.modeSwitch.toAssistedLabel":"capture.modeSwitch.toSelfLabel"),onSwitch:n(()=>{lr()},"onSwitch")}:null,je=a.modeRestarted&&O?p("capture.modeSwitch.restarted"):null,Pe=le||at,At=le?"checking":at?"frozen":a.state==="recording"?"recording":a.gateLocked||a.gate.progress>=1?"locked":a.gate.faceDetected?"aligning":"seeking",$e=O?a.gate.hint:null,ze=a.state==="starting"?"capture.preparing.title":$e===null?null:$e==="center"&&!a.gate.faceDetected?"fcv3.no_face":Zt($e),[ur,Tt]=sr(null);oe(()=>{if(ze!=="fcv3.no_face"){Tt(ze);return}if(!O)return;let f=setTimeout(()=>Tt(ze),lo);return()=>clearTimeout(f)},[ze,O]);let ct=O&&typeof w=="string"&&w!=="",Kt=h&&O?p("capture.assisted.stage"):null,ge=O&&!ct?ur:null,lt=ct?w:ge===null?"":p(ge);vt(x,ge,lt,O);let Ot=ke(d);Ot.current=d,oe(()=>{if(he(ge))try{Ot.current?.(ge)}catch(f){console.error("[@sekyro/react] onGuidance threw:",f)}},[ge]);let Ae=xe(()=>({supported:x.supported,enabled:x.enabled,setEnabled:x.setEnabled,toggle:x.toggle}),[x.supported,x.enabled,x.setEnabled,x.toggle]),ut=s?.voicePrompt,Ut=ut!==void 0,Ht=S===void 0,Bt=ke(!1);oe(()=>{!Ut||!Ht||Bt.current||!tt()||(Bt.current=!0,console.warn("[@sekyro/react] <LivenessCapture>: `slots.voicePrompt` is set and `voice` is undefined, so the component speaks the guidance itself. If your slot plays audio, pass voice={false} or the person hears every hint twice; pass voice={{}} to keep the built-in voice and silence this warning."))},[Ut,Ht]);let dr=ut!==void 0?(f,$,de)=>ut(f,$,de,Ae):x.supported?()=>R(or,{voice:Ae}):void 0,{summary:dt,summaryPlaying:Gt,toggleSummary:Ft,stopSummary:qt}=x,Ye=y!==void 0&&y!=="",Dt=Ye?y:p("capture.tips.summary"),jt=Ye?dt!=="none":dt==="partner"||dt==="default"&&uo(b),pr=xe(()=>jt?{playing:Gt,toggle:n(()=>Ft(Dt,{clip:!Ye}),"toggle"),stop:qt}:void 0,[jt,Gt,Ft,Dt,qt,Ye]),fr=xe(()=>({assets:it,retryAssets:A.retry,permission:P.permission,permissionSettled:P.permissionSettled,captureMode:K.mode,facing:Ee,voice:Ae}),[it,A.retry,P.permission,P.permissionSettled,K.mode,Ee,Ae]),mr=fo(i)?R(q,{tone:i.tone,testId:"sekyro-host-notice",children:R("span",{children:i.text})}):i??null,X=Z!==null&&Z.status==="retry"?Z:null,G=Nt&&Z.status==="unavailable"&&!B&&Z.reasonCode!=="portrait_required"?Z:null,ue=Nt&&(Z.status==="verified"||Z.status==="not_verified"||Z.status==="review")?Z:null,pt=n((f,$)=>{if(f===void 0)return null;if(f==="device_cooldown"){let Re=Xt(t,$);if(Re!==null)return p(Re.key).replace("{time}",Re.time)}let de=Jt(f);return de===null?null:p(de)},"reasonText"),ft=n(f=>{let $=f.retakeHint===void 0?null:Wt(f.retakeHint);return $===null?pt(f.reasonCode):p($)},"retryText"),$t=ue===null?null:pt(ue.reasonCode,ue.retryAfter)??(ue.status==="not_verified"&&ue.reason!==void 0&&co.has(ue.reason)?p("errors.session_expired"):null),yr=G!==null&&G.reasonCode!==void 0&&G.reasonCode!=="nni_unbound"&&G.reasonCode!=="id_number_unbound"&&G.reasonCode!=="method_required"&&G.reasonCode!=="mobile_required"&&!(G.reasonCode==="no_recorder"&&a.artifacts?.degraded==="NO_RECORDER"),Ze=G?.reasonCode,zt=a.attempt;oe(()=>{G===null||Ze===void 0||e?.reportCaptureIssue===void 0||mo.has(Ze)||We(f=>e.reportCaptureIssue?.(f),{check:"liveness",kind:"unavailable",phase:"upload",engineKind:Ze,attempt:Math.min(1e3,zt)})},[G,Ze,zt,e]);let Yt=Qe(),gr=B&&_.auto===null&&!O&&!le&&a.error===null,mt=st(async f=>{await _.select(f)&&a.state==="done"&&a.retry()},[_.select,a.state,a.retry]);return oe(()=>{_.auto!==null&&!_.busy&&!O&&!le&&mt(_.auto)},[_.auto,_.busy,O,le,mt]),R(rn,{value:p,children:Ie("div",{ref:Q,className:V===void 0?"sekyro-capture":`sekyro-capture ${V}`,dir:U,lang:t,"data-testid":"sekyro-liveness-capture","data-state":a.state,children:[s?.header,X!==null&&ft(X)!==null&&!(De&&qe)?R(q,{tone:"warning",role:"status",testId:"sekyro-retry-notice",children:R("span",{children:ft(X)})}):null,je!==null&&!De?R(q,{tone:"info",role:"status",testId:"sekyro-mode-switch-status",children:R("span",{children:je})}):null,ae&&le&&!De?R(q,{tone:"info",role:"status",testId:"sekyro-busy-notice",children:R("span",{children:p("capture.busy")})}):null,N.required&&ye?R(q,{tone:"info",role:"status",testId:"sekyro-mobile-required",children:R("span",{children:p("reasons.mobile_required")})}):null,a.error!==null?s?.errorPanel!==void 0?s.errorPanel(a.error,a.retry):Ie(q,{tone:"danger",testId:"sekyro-error-notice",children:[R("span",{children:p(Qt(a.error))}),a.error.retryable?R(F,{ref:Yt,kind:"ghost",className:"sekyro-btn--start",onClick:a.retry,children:p("common.retry")}):null]}):null,G!==null?Ie(q,{tone:"danger",testId:"sekyro-unavailable-notice",children:[R("span",{children:pt(G.reasonCode)??p(G.reasonCode===void 0?"errors.session_expired":"errors.network_error")}),yr?R(F,{ref:Yt,kind:"ghost",className:"sekyro-btn--start",onClick:a.retry,children:p("capture.recordAgain")}):null]}):null,$t!==null&&ue!==null?R(q,{tone:ue.status==="not_verified"?"danger":"info",testId:"sekyro-result-notice",children:R("span",{children:$t})}):null,R("div",{className:qe?void 0:"sekyro-hidden","data-capture-live":qe?"":void 0,children:De?se({videoRef:H,guidance:Pe&&Se?p("capture.checking"):lt,coached:ct&&!(Pe&&Se),note:Pe?Se?p(ae?"capture.busy":"capture.checkingHint"):null:je??(X!==null?ft(X):Kt),settled:Pe&&Se,progress:a.gate.progress,phase:At,still:Pe?Et:null,live:qe,modeSwitch:Pt,...Mt?{status:je}:{},ramp:a.rampColour===null?null:{colour:a.rampColour}}):R(on,{videoRef:H,guidanceText:lt,guidanceHint:$e,guidanceKey:ge,progress:a.gate.progress,phase:At,draining:a.draining,stillUrl:Et,showChecking:Se,operatorText:Kt,voicePrompt:dr,overlay:f=>Ie(ir,{children:[s?.stageOverlay?.(f),R(an,{colour:a.rampColour})]}),reduceMotion:a.reduceMotion,modeSwitch:Pt})}),gr&&_.choice!==null?R(kn,{title:p("method.title"),description:p("method.description"),options:_.choice.options.map(f=>({id:f,label:p(`method.${f}`)})),busy:_.busy,error:_.failed?p("errors.network_error"):null,focus:a.state==="done",testId:"sekyro-method",look:"buttons",onChoose:f=>{mt(f)}}):null,cr?Ie(ir,{children:[ie&&s?.header===void 0&&s?.intro===void 0?Ie("div",{className:"sekyro-stack sekyro-stack--1",children:[R("h2",{className:"sekyro-text-body",children:p("returning.title")}),R("p",{className:"sekyro-text-muted",children:p("returning.description")})]}):null,mr,s?.intro!==void 0?s.intro(Ge,fr):R(Gn,{assets:it,onRetryAssets:A.retry,permission:P.permission,captureMode:K.mode,voice:Ae,tips:b??Je,summary:pr,startLabel:k,startDisabled:u,onStart:Ge})]}):null,R(An,{showCoaching:X!==null,coaching:Pn(X?.reasonCode),attemptsText:X?.attemptsRemaining!==void 0?en(T,t,X.attemptsRemaining):null,showRetake:X!==null&&!O&&!le||!Se&&a.state==="captured",onRetake:a.retry}),s?.footer]})})}n(_i,"LivenessCapture");export{Pn as a,En as b,tt as c,Tn as d,Je as e,kn as f,$n as g,et as h,lo as i,_i as j};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{a as n,b as r,d as c}from"./chunk-TWZZGFO5.js";import{a as t}from"./chunk-ONYT4GJ4.js";import{a as i}from"./chunk-2KED7D2Q.js";import{jsx as e,jsxs as a}from"react/jsx-runtime";function k({title:s,lead:l,cameraLabel:p,uploadLabel:d,notice:m,testId:o,onCamera:u,onUpload:f,onPhone:g=!1}){return a("section",{className:"sekyro-step","data-testid":o,children:[e(r,{title:s,lead:l}),m,a(c,{children:[a(t,{full:!0,onClick:u,"data-testid":`${o}-camera`,children:[e(n,{name:g?"smartphone":"camera"}),p]}),e(t,{full:!0,kind:"ghost",onClick:f,"data-testid":`${o}-upload`,children:d})]})]})}i(k,"PhotoSourceView");export{k as a};
2
+ import{a as n,b as r,d as c}from"./chunk-RO2EITOC.js";import{a as t}from"./chunk-6QYD5HOU.js";import{a as i}from"./chunk-2KED7D2Q.js";import{jsx as e,jsxs as a}from"react/jsx-runtime";function k({title:s,lead:l,cameraLabel:p,uploadLabel:d,notice:m,testId:o,onCamera:u,onUpload:f,onPhone:g=!1}){return a("section",{className:"sekyro-step","data-testid":o,children:[e(r,{title:s,lead:l}),m,a(c,{children:[a(t,{full:!0,onClick:u,"data-testid":`${o}-camera`,children:[e(n,{name:g?"smartphone":"camera"}),p]}),e(t,{full:!0,kind:"ghost",onClick:f,"data-testid":`${o}-upload`,children:d})]})]})}i(k,"PhotoSourceView");export{k as a};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{a as Ve}from"./chunk-DIE7UVV7.js";import{d as Ke}from"./chunk-MX5SNIDY.js";import"./chunk-7Z4LVT2A.js";import{a as $e,b as Re,c as Ue}from"./chunk-7MMT5M4E.js";import{d as Ee}from"./chunk-E7PG3JL4.js";import{a as B,b as ue,d as pe,j as Ie,k as Pe,l as Oe,n as Ae,p as me,q as he}from"./chunk-TWZZGFO5.js";import"./chunk-TLMGY7AK.js";import{a as O,m as _e,o as He}from"./chunk-ONYT4GJ4.js";import{a as d}from"./chunk-2KED7D2Q.js";import{useContext as Ze,useEffect as G,useLayoutEffect as pt,useRef as Y,useState as b}from"react";var Be={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"/>'};var Ge={"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":"يبدو أن هذه بطاقة تعريف أو بطاقة إقامة"};var j={"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"};var Ye={"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"};var Fe={"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":"رفع صورة"};var Q={"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"};var We={"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"};var Xe={"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":"لنحاول مرة أخرى"};var Z={"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"};var je={"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"};var ut=["locking","capturing"],fe=class fe{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(e,o){return this.presentHint(e,o),this.presentLock(e,o),this.presentCard(e,o),this.shutterSince=e.manualShutter?this.shutterSince??o:null,this.shown={...this.shown,manualShutter:this.shutterSince!==null&&o-this.shutterSince>=1e3},this.shown}presentHint(e,o){let a=e.phase==="framing"&&!(e.hint==="blurry"&&e.card===null)?e.hint:null;if(e.phase!=="framing"){this.shown={...this.shown,hint:null},this.candidate=null;return}if(a!==this.candidate&&(this.candidate=a,this.candidateSince=o),a===this.shown.hint)return;let r=o-this.candidateSince>=(a===null?0:350),g=this.shown.hint===null||o-this.hintShownAt>=1200;r&&g&&(this.shown={...this.shown,hint:a},this.hintShownAt=o)}presentLock(e,o){if(ut.includes(e.phase)){this.shown={...this.shown,locking:!0},this.lockLostAt=null;return}if(this.shown.locking){if(e.phase!=="framing"){this.shown={...this.shown,locking:!1},this.lockLostAt=null;return}this.lockLostAt??(this.lockLostAt=o),o-this.lockLostAt>=300&&(this.shown={...this.shown,locking:!1},this.lockLostAt=null)}}presentCard(e,o){let a=e.card;if(a===null||e.phase!=="framing"){if(e.phase!=="framing"){this.shown={...this.shown,card:null},this.detectedSince=null,this.lostSince=null;return}this.detectedSince=null,this.lostSince??(this.lostSince=o),o-this.lostSince>=300&&(this.shown={...this.shown,card:null});return}if(this.lostSince=null,this.detectedSince??(this.detectedSince=o),o-this.detectedSince<250)return;let r=this.shown.card;if(r===null){this.shown={...this.shown,card:{...a}};return}let g=.35;this.shown={...this.shown,card:{fill:r.fill+(a.fill-r.fill)*g,offsetX:r.offsetX+(a.offsetX-r.offsetX)*g,offsetY:r.offsetY+(a.offsetY-r.offsetY)*g}}}};d(fe,"ScanPresenter");var oe=fe;import{Fragment as ge,jsx as n,jsxs as i}from"react/jsx-runtime";var mt={en:Z,fr:je,ar:Xe,es:Z,pt:Z,de:Z},ht=450,Se=d(t=>e=>Ee(t.strings[e]??mt[t.locale][e]??""),"useScanCopy");function ae({name:t}){return n("svg",{className:"sekyro-glyph",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",focusable:"false",dangerouslySetInnerHTML:{__html:Be[t]}})}d(ae,"ScanGlyph");var ft={en:j,fr:Ye,ar:Ge,es:j,pt:j,de:j},gt={en:Q,fr:We,ar:Fe,es:Q,pt:Q,de:Q},St="image/jpeg,image/png,image/heic,image/heif";function F(t){let e=t.strings,o=d(a=>e[a]??gt[t.locale][a],"text");return{t:d(a=>o(a)??"","t")}}d(F,"uploadCopy");function vt(t,e){return t===null||t.state==="fallback"||t.state==="mismatch"?null:t.state==="searching"?e?"dcv3.mrz.searching":"dcv3.mrz.showMrzSide":t.state==="valid"?"dcv3.mrz.valid":t.coach!==void 0?`dcv3.mrz.${t.coach}`:"dcv3.mrz.reading"}d(vt,"mrzInstruction");function ve(t){return t.reason==="unreadable"?"doc.reason_unreadable":t.reason==="tester_document_mismatch"?"reasons.tester_document_mismatch":t.reason!==void 0&&t.reason!=="side_missing"?He(t.reason):null}d(ve,"reasonOf");var yt=new Set(["document_type_not_accepted","tester_document_mismatch"]);function ln({step:t,i18n:e,liveMrz:o,ageLead:a,...r}){let[g,S]=b(!1),L=Y(-1),[h,f]=b("idle"),v=Y(null),k=typeof t.uploadDocument=="function",w=k?t.photo?.source??"camera":"camera",T=k&&w!=="camera"&&t.photo?.uploadOffered===!0,[y,A]=b(null),_=w==="upload"?"upload":w==="choice"?y??t.photo?.pick??"source":"camera",H=h==="sending"?void 0:()=>v.current?.click(),m=d(async $=>{let J=$.currentTarget.files?.[0];if($.currentTarget.value="",J!==void 0){S(!1),f("sending");try{await t.uploadDocument(J),f("idle")}catch(X){f(X instanceof TypeError&&X.message==="unsupported_file"?"unsupported":"failed")}}},"onFile"),q=T?n("input",{ref:v,type:"file",accept:St,hidden:!0,"data-testid":"sekyro-doc-upload","aria-label":F(e).t("doc.uploadTitle"),onChange:$=>{m($)}}):null,C=F(e),W=t.photo?.cameraOnPhone===!0;return _==="camera"&&W?n(Ke,{i18n:e,lead:e.t("handoff.lead.document"),refresh:t.refresh,actions:n(O,{kind:"ghost",full:!0,onClick:()=>A("upload"),children:C.t("doc.source.upload")})}):_==="source"?n(Ve,{testId:"sekyro-doc-source",title:C.t("doc.source.title"),lead:C.t("doc.source.description"),cameraLabel:W?e.t("capture.source.phone"):C.t("doc.source.camera"),onPhone:W,uploadLabel:C.t("doc.source.upload"),notice:n(ye,{step:t,i18n:e}),onCamera:()=>A("camera"),onUpload:()=>A("upload")}):_==="upload"?i(ge,{children:[n(wt,{step:t,i18n:e,ageLead:a===!0,upload:h,offered:T,onPick:()=>v.current?.click(),...w==="choice"?{onCamera:d(()=>A("camera"),"onCamera")}:{},...r}),q]}):i(ge,{children:[g?n(Nt,{step:t,i18n:e,attempts:L,...o!==void 0?{liveMrz:o}:{},...T&&H!==void 0?{onUpload:H}:{},onClose:()=>S(!1)}):n(bt,{step:t,i18n:e,ageLead:a===!0,onOpen:()=>S(!0),upload:h,...T&&H!==void 0?{onUpload:H}:{},...r}),q]})}d(ln,"DocumentCaptureView");function qe({passport:t}){let o=Math.round(228/(t?1.42:1.586));return i("svg",{className:"sekyro-mark sekyro-mark--card",viewBox:`-12 -12 252 ${o+24}`,"aria-hidden":"true",focusable:"false",children:[n("defs",{children:n("clipPath",{id:"sekyro-card-clip",children:n("rect",{width:228,height:o,rx:"12.5"})})}),n("rect",{className:"sekyro-mark__card",width:228,height:o,rx:"12.5"}),n("rect",{className:"sekyro-mark__photo",x:"17",y:"17",width:"55",height:o*.52,rx:"6"}),[0,1,2].map(a=>n("rect",{className:"sekyro-mark__text",x:"88",y:23+a*o*.12,width:100-a*20,height:"6",rx:"3"},a)),[0,1].map(a=>n("rect",{className:"sekyro-mark__text",x:"17",y:o*.74+a*9,width:194,height:"4",rx:"2"},a)),n("g",{clipPath:"url(#sekyro-card-clip)",children:n("g",{className:"sekyro-mark__read",style:{"--sekyro-read-w":"228px"},children:n("rect",{x:"-1",width:"2",height:o,className:"sekyro-mark__beam"})})}),n("path",{className:"sekyro-mark__brackets",d:kt(-10,-10,248,o+20,16,30)})]})}d(qe,"ScanMark");function kt(t,e,o,a,r,g){let S=Math.min(r,g*.6);return[[t,e,1,1],[t+o,e,-1,1],[t,e+a,1,-1],[t+o,e+a,-1,-1]].map(([h,f,v,k])=>`M${h} ${f+k*g}V${f+k*S}Q${h} ${f} ${h+v*S} ${f}H${h+v*g}`).join("")}d(kt,"brackets");function bt({step:t,i18n:e,ageLead:o,onOpen:a,onChangeCountry:r,onChangeDocument:g,upload:S,onUpload:L}){let h=Se(e),f=F(e),v=t.documentType==="passport",k=ve(t),w=S==="sending",T=Ze(Pe)?.busy===!0;return i("section",{className:"sekyro-step","data-testid":"sekyro-document",children:[n(qe,{passport:v}),n(ue,{title:h("native.doc.introTitle"),lead:o?e.t("doc.ageStepUp"):h("native.doc.introLead")}),n(ye,{step:t,i18n:e}),t.reason!==void 0&&yt.has(t.reason)?null:i("ul",{className:"sekyro-tiprows",children:[i("li",{children:[n(B,{name:v?"passport":"card"}),h("native.doc.tip.flat")]}),i("li",{children:[n(B,{name:"light"}),h("native.doc.tip.glare")]}),i("li",{children:[n(ae,{name:"image"}),h("native.doc.tip.frame")]})]}),n(Je,{i18n:e,...g!==void 0?{onChangeDocument:g}:{},...r!==void 0?{onChangeCountry:r}:{}}),n(et,{i18n:e,upload:S}),w?n("p",{className:"sekyro-text-muted",role:"status",children:e.t("doc.uploading")}):L!==void 0?n("p",{className:"sekyro-text-muted",children:f.t("doc.uploadHint")}):null,i(pe,{children:[i(O,{full:!0,onClick:a,disabled:w||T,children:[n(B,{name:"camera"}),h("native.doc.openCamera")]}),L!==void 0?i(O,{full:!0,kind:"ghost",onClick:L,children:[n(ae,{name:"image"}),f.t("doc.uploadInstead")]}):null]})]})}d(bt,"DocumentIntro");function ye({step:t,i18n:e}){let o=ve(t);return o===null?null:i(me,{tone:"warning",children:[n("span",{children:e.t(o)}),n("span",{children:he(e,t.attemptsRemaining,t.attemptsExhausted)})]})}d(ye,"ReasonNotice");function Je({i18n:t,onChangeCountry:e,onChangeDocument:o}){let a=Se(t);return o===void 0&&e===void 0?null:i("div",{className:"sekyro-links",children:[o!==void 0?n("button",{type:"button",className:"sekyro-link",onClick:o,children:a("native.doc.changeDocument")}):null,e!==void 0?n("button",{type:"button",className:"sekyro-link",onClick:e,children:t.t("native.doc.changeCountry")}):null]})}d(Je,"ChangeLinks");function et({i18n:t,upload:e}){return e!=="unsupported"&&e!=="failed"?null:n(me,{tone:"warning",children:n("span",{children:F(t).t(e==="unsupported"?"doc.uploadUnsupported":"doc.uploadFailed")})})}d(et,"UploadNotice");function wt({step:t,i18n:e,ageLead:o,upload:a,offered:r,onPick:g,onCamera:S,onChangeCountry:L,onChangeDocument:h}){let f=F(e),v=a==="sending";return i("section",{className:"sekyro-step","data-testid":"sekyro-doc-upload-screen",children:[n(qe,{passport:t.documentType==="passport"}),n(ue,{title:f.t("doc.uploadTitle"),lead:o?e.t("doc.ageStepUp"):f.t("doc.uploadHint")}),o?n("p",{className:"sekyro-text-muted",children:f.t("doc.uploadHint")}):null,n(ye,{step:t,i18n:e}),n(Je,{i18n:e,...h!==void 0?{onChangeDocument:h}:{},...L!==void 0?{onChangeCountry:L}:{}}),n(et,{i18n:e,upload:a}),v?n("p",{className:"sekyro-text-muted",role:"status",children:e.t("doc.uploading")}):null,i(pe,{children:[i(O,{full:!0,onClick:g,disabled:v||!r||t.attemptsExhausted,children:[n(ae,{name:"image"}),f.t("doc.source.upload")]}),S!==void 0?i(O,{full:!0,kind:"ghost",onClick:S,disabled:v,children:[n(B,{name:"camera"}),f.t("doc.source.camera")]}):null]})]})}d(wt,"DocumentUploadScreen");function Qe(t,e,o){let a=t*.88,r=a/o;return{x:(t-a)/2,y:e*.42-r/2,w:a,h:r}}d(Qe,"guideRect");var Ct={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"},Dt=d(()=>typeof window<"u"&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,"reduceMotion");function Nt({step:t,i18n:e,liveMrz:o,onClose:a,attempts:r,onUpload:g}){let S=Se(e),L=Ze($e),h=Y(L);h.current=L;let f=Y(null),v=Y(null),k=Y(null),[w,T]=b("idle"),[y,A]=b(null),[_,H]=b(null),[m,q]=b({w:0,h:0}),[C,W]=b({hint:null,locking:!1,card:null,manualShutter:!1}),[$,J]=b({}),[X,tt]=b(null),[ke,nt]=b(null),[be,we]=b(0),[Ce,De]=b(null),[ee,Ne]=b(null),R=t.documentType==="passport",te=R?1.42:1.586;Ie(!0),pt(()=>{let c=f.current;if(c===null)return;let u=d(()=>q({w:c.clientWidth,h:c.clientHeight}),"measure");if(u(),typeof ResizeObserver>"u")return;let l=new ResizeObserver(u);return l.observe(c),()=>l.disconnect()},[]);let s=Qe(m.w,m.h,te);G(()=>{m.w===0||m.h===0||k.current?.setGuide?.({viewAspect:m.w/m.h,rect:{x:s.x/m.w,y:s.y/m.h,width:s.w/m.w,height:s.h/m.h}})},[m.w,m.h,s.x,s.y,s.w,s.h]),G(()=>{let c=v.current;if(c===null)return;let u=t.capture({video:c,...o!==void 0?{liveMrz:o}:{}});k.current=u;let l=f.current;if(l!==null&&l.clientWidth>0&&l.clientHeight>0){let p=Qe(l.clientWidth,l.clientHeight,te);u.setGuide?.({viewAspect:l.clientWidth/l.clientHeight,rect:{x:p.x/l.clientWidth,y:p.y/l.clientHeight,width:p.w/l.clientWidth,height:p.h/l.clientHeight}})}let M=new oe,N={scan:null,feedback:null,gate:null},E=d(p=>{N={...N,...p};let x=N.gate?.guide,dt={phase:N.scan?.phase??"framing",hint:N.feedback?.reticle==="coaching"?N.feedback.key:null,card:x?.detected?{fill:x.fill,offsetX:x.offsetX,offsetY:x.offsetY}:null,manualShutter:N.scan?.manualShutter??!1},I=M.present(dt,performance.now());W(P=>P.hint===I.hint&&P.locking===I.locking&&P.manualShutter===I.manualShutter&&P.card?.fill===I.card?.fill&&P.card?.offsetX===I.card?.offsetX&&P.card?.offsetY===I.card?.offsetY?P:I)},"present"),lt=[u.on("state",T),u.on("feedback",p=>E({feedback:p})),u.on("gate",p=>E({gate:p})),u.on("scan",p=>{A(p),E({scan:p})}),u.on("captured",p=>{J(x=>({...x,[Lt(p.side,R,x)]:p.previewDataUrl})),tt(p.previewDataUrl),nt(xt(c))}),u.on("error",p=>{H(p);let x=h.current;x!==null&&Ue(x,Re("document",p,Math.max(0,r.current)))}),u.on("mrz",p=>{p.state==="mismatch"?Ne(p.format??null):De(p)})];return r.current+=1,u.start().catch(()=>{}),()=>{for(let p of lt)p();u.destroy(),k.current=null}},[t.issuer,t.documentType]);let z=y?.phase??"framing",U=z==="reading"||z==="result",re=z==="flipCue"||z==="reaskRecto",K=C.locking,Le=y?.captured.length??0;G(()=>{K&&we(c=>c+1)},[K]),G(()=>{Le>0&&we(c=>c+1)},[Le]);let ot=y?.expected??null;G(()=>{De(null)},[ot]),G(()=>{if(ee===null)return;let c=setTimeout(()=>Ne(null),2e3);return()=>clearTimeout(c)},[ee]);let ze=re||U?null:vt(Ce,R),se=ee!==null?ee==="TD3"?"dcv3.mrz.looksLikePassport":"dcv3.mrz.looksLikeCard":ze,at=se===null?null:e.strings[se]??ft[e.locale][se],ie=ve(t),xe=C.hint===null?null:Ct[C.hint]??`dcv2.${C.hint}`,rt=xe??(z==="flipCue"?y?.notice==="same_face"?"doc.sameFace":"doc.flip":z==="reaskRecto"?"doc.reaskRecto":U?"native.scan.reading":z==="locking"||z==="capturing"||K?"native.scan.holdStill":y?.notice==="reread"?ie??"doc.reread":y?.notice==="technical"?"native.scan.retry":y?.notice==="blurry"?"native.scan.blurry":ie??(R?"doc.showPage":"doc.showSide")),ce=at??S(rt),V=C.card,D=s;if(!K&&V!==null&&V.fill>=.45&&V.fill<=1.25&&!Dt()){let c=s.w*V.fill,u=c/te,l=s.x+s.w/2+s.w*Math.max(-.25,Math.min(.25,V.offsetX)),M=s.y+s.h/2+s.h*Math.max(-.25,Math.min(.25,V.offsetY));D={x:l-c/2,y:M-u/2,w:c,h:u}}let ne=s.w*.045,le=28,Te=Math.min(ne,le*.6),st=[[D.x,D.y,1,1],[D.x+D.w,D.y,-1,1],[D.x,D.y+D.h,1,-1],[D.x+D.w,D.y+D.h,-1,-1]],it=K?"is-locked":C.hint!==null?"is-coaching":"",ct=R?[{side:"single",label:"doc.progressPage"}]:[{side:"recto",label:"doc.progressFront"},{side:"verso",label:"doc.progressBack"}],Me=s.y+s.h+48,de={insetInlineStart:s.x,insetBlockStart:s.y,inlineSize:s.w,blockSize:s.h,borderRadius:ne};return n("section",{className:"sekyro-lm","aria-label":ce,"data-testid":"sekyro-document",children:i("div",{ref:f,className:`sekyro-lm-stage${U?" is-reading":""}${re?" is-flip":""}`,style:{"--sekyro-guide-w":`${s.w}px`},children:[n("video",{ref:v,className:"sekyro-lm-video",playsInline:!0,muted:!0,autoPlay:!0,"aria-hidden":"true",onPointerUp:c=>{let u=c.currentTarget,l=u.getBoundingClientRect(),M=Math.max(l.width/(u.videoWidth||1),l.height/(u.videoHeight||1)),N=u.videoWidth*M,E=u.videoHeight*M;N>0&&E>0&&k.current?.focusAt((c.clientX-l.left+(N-l.width)/2)/N,(c.clientY-l.top+(E-l.height)/2)/E)}}),m.w>0?i(ge,{children:[U&&ke!==null?n("img",{className:"sekyro-lm-scene",src:ke,alt:""}):null,U&&X!==null?n("img",{className:"sekyro-lm-frozen",src:X,alt:"",style:de}):null,i("svg",{className:"sekyro-lm-overlay",viewBox:`0 0 ${m.w} ${m.h}`,"aria-hidden":"true",focusable:"false",children:[i("defs",{children:[i("linearGradient",{id:"sekyro-lm-top",x1:"0",y1:"0",x2:"0",y2:"1",children:[n("stop",{offset:"0",className:"sekyro-lm-ink",stopOpacity:"0.85"}),n("stop",{offset:"1",className:"sekyro-lm-ink",stopOpacity:"0"})]}),i("linearGradient",{id:"sekyro-lm-bottom",x1:"0",y1:"0",x2:"0",y2:"1",children:[n("stop",{offset:"0",className:"sekyro-lm-ink",stopOpacity:"0"}),n("stop",{offset:"1",className:"sekyro-lm-ink",stopOpacity:"0.9"})]})]}),n("path",{className:"sekyro-lm-scrim",fillRule:"evenodd",d:`M0 0H${m.w}V${m.h}H0Z${zt(s,ne)}`}),n("rect",{width:m.w,height:Math.max(0,s.y),fill:"url(#sekyro-lm-top)"}),n("rect",{y:s.y+s.h,width:m.w,height:Math.max(0,m.h-s.y-s.h),fill:"url(#sekyro-lm-bottom)"}),n("g",{className:`sekyro-lm-brackets ${it}`,children:st.map(([c,u,l,M],N)=>n("path",{style:{transform:`translate(${c}px, ${u}px) scale(${l}, ${M})`},d:`M0 ${le}V${Te}Q0 0 ${Te} 0H${le}`},N))}),K?n("rect",{className:"sekyro-lm-trace",x:s.x,y:s.y,width:s.w,height:s.h,rx:ne,pathLength:"1",style:{animationDuration:`${ht}ms`}}):null]}),n("div",{className:"sekyro-lm-slot",style:de,"aria-hidden":"true",children:U?n("span",{className:"sekyro-lm-read is-repeating"}):be>0?n("span",{className:"sekyro-lm-read"},be):null})]}):null,ze!==null?n("div",{className:"sekyro-lm-slot",style:de,"aria-hidden":"true",children:n("span",{"data-testid":"sekyro-mrz-strip",className:`sekyro-lm-mrz${R?" is-page":""}${Ce?.state==="valid"?" is-valid":""}`})}):null,i("div",{className:"sekyro-lm-instruction",style:{insetBlockStart:s.y-64},children:[n("div",{role:"status","aria-live":"polite",children:n(Ae,{swapKey:ce,className:"sekyro-lm-line",children:ce})}),ie!==null&&z==="framing"&&xe===null?n("p",{className:"sekyro-lm-attempts",children:he(e,t.attemptsRemaining,t.attemptsExhausted)}):null]}),U?i("p",{className:"sekyro-lm-under sekyro-lm-note",style:{insetBlockStart:Me-12},children:[n("span",{className:"sekyro-lm-spinner","aria-hidden":"true"}),S("native.scan.putDown")]}):re?n("div",{className:`sekyro-lm-under sekyro-lm-flip${z==="reaskRecto"?" is-toFront":""}`,style:{insetBlockStart:Me-20},"data-testid":"sekyro-flip-cue","aria-hidden":"true",children:i("span",{className:"sekyro-lm-flip-card",style:{aspectRatio:String(te)},children:[n("span",{className:"sekyro-lm-flip-front"}),n("span",{className:"sekyro-lm-flip-back"})]})}):null,i("div",{className:"sekyro-lm-controls",children:[i("div",{className:"sekyro-lm-bar",children:[n("button",{type:"button",className:"sekyro-glass","aria-label":e.t("native.close"),onClick:a,children:n(B,{name:"close"})}),y?.torchAvailable?n("button",{type:"button",className:`sekyro-glass${y.torch?" is-on":""}`,"aria-label":e.t("doc.torchOn"),"aria-pressed":y.torch,onClick:()=>k.current?.setTorch(!y.torch),children:n(ae,{name:"flashlight"})}):null]}),_!==null?i("div",{className:"sekyro-lm-error",role:"alert",children:[n("p",{children:e.t("doc.cameraBlocked")}),n("p",{children:e.t(_.kind==="permission"?"doc.cameraBlockedHint":_e(_.kind))}),n(O,{onClick:()=>{H(null),r.current+=1,k.current?.retry()},children:e.t("doc.retryCamera")})]}):null,C.manualShutter?n("button",{type:"button",className:"sekyro-shutter","aria-label":e.t("doc.shutter"),onClick:()=>k.current?.shutter()}):null,n("ol",{className:"sekyro-lm-tray",children:ct.map(({side:c,label:u})=>{let l=y?.captured.includes(c)??!1;return i("li",{className:l?"is-done":void 0,"aria-current":!l&&(R||y?.expected===c)?"step":void 0,children:[l?i("span",{className:"sekyro-lm-thumb",children:[$[c]!==void 0?n("img",{src:$[c],alt:""}):null,n("svg",{className:"sekyro-lm-check",viewBox:"0 0 18 18","aria-hidden":"true",children:n("path",{d:"M5 9.2l2.6 2.6L13 6.4"})})]}):null,S(u)]},c)})}),g!==void 0?n("button",{type:"button",className:"sekyro-lm-upload",onClick:g,children:F(e).t("doc.uploadInstead")}):null,w==="uploading"||w==="checking"?null:n(Oe,{onStop:a})]}),w==="uploading"||w==="checking"?n("span",{className:"sekyro-visually-hidden",role:"status",children:w==="uploading"?e.t("doc.uploading"):S("native.scan.reading")}):null]})})}d(Nt,"LumiereScan");function Lt(t,e,o){return e?"single":t==="recto"||t==="verso"?t:o.recto===void 0?"recto":"verso"}d(Lt,"slotOf");function zt({x:t,y:e,w:o,h:a},r){return`M${t+r} ${e}H${t+o-r}Q${t+o} ${e} ${t+o} ${e+r}V${e+a-r}Q${t+o} ${e+a} ${t+o-r} ${e+a}H${t+r}Q${t} ${e+a} ${t} ${e+a-r}V${e+r}Q${t} ${e} ${t+r} ${e}Z`}d(zt,"roundedRect");function xt(t){let e=Math.round(t.videoWidth/4),o=Math.round(t.videoHeight/4);if(e===0||o===0||typeof document>"u")return null;try{let a=document.createElement("canvas");a.width=e,a.height=o;let r=a.getContext("2d");return r===null?null:(r.drawImage(t,0,0,e,o),a.toDataURL("image/jpeg",.7))}catch{return null}}d(xt,"sceneSnapshot");export{ln as DocumentCaptureView,ht as LOCK_TRACE_MS,St as UPLOAD_ACCEPT,Qe as guideRect,vt as mrzInstruction,Lt as slotOf};
2
+ import{a as Ve}from"./chunk-WL77LOB3.js";import{d as Ke}from"./chunk-HRNF3WQA.js";import"./chunk-RKO3RGGA.js";import{a as $e,b as Re,c as Ue}from"./chunk-7MMT5M4E.js";import{d as Ee}from"./chunk-B4OAK5EF.js";import{a as B,b as ue,d as pe,j as Ie,k as Pe,l as Oe,n as Ae,p as me,q as he}from"./chunk-RO2EITOC.js";import"./chunk-IAZ5UH2B.js";import{a as O,m as _e,o as He}from"./chunk-6QYD5HOU.js";import{a as d}from"./chunk-2KED7D2Q.js";import{useContext as Ze,useEffect as G,useLayoutEffect as pt,useRef as Y,useState as b}from"react";var Be={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"/>'};var Ge={"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":"يبدو أن هذه بطاقة تعريف أو بطاقة إقامة"};var j={"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"};var Ye={"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"};var Fe={"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":"رفع صورة"};var Q={"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"};var We={"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"};var Xe={"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":"لنحاول مرة أخرى"};var Z={"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"};var je={"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"};var ut=["locking","capturing"],fe=class fe{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(e,o){return this.presentHint(e,o),this.presentLock(e,o),this.presentCard(e,o),this.shutterSince=e.manualShutter?this.shutterSince??o:null,this.shown={...this.shown,manualShutter:this.shutterSince!==null&&o-this.shutterSince>=1e3},this.shown}presentHint(e,o){let a=e.phase==="framing"&&!(e.hint==="blurry"&&e.card===null)?e.hint:null;if(e.phase!=="framing"){this.shown={...this.shown,hint:null},this.candidate=null;return}if(a!==this.candidate&&(this.candidate=a,this.candidateSince=o),a===this.shown.hint)return;let r=o-this.candidateSince>=(a===null?0:350),g=this.shown.hint===null||o-this.hintShownAt>=1200;r&&g&&(this.shown={...this.shown,hint:a},this.hintShownAt=o)}presentLock(e,o){if(ut.includes(e.phase)){this.shown={...this.shown,locking:!0},this.lockLostAt=null;return}if(this.shown.locking){if(e.phase!=="framing"){this.shown={...this.shown,locking:!1},this.lockLostAt=null;return}this.lockLostAt??(this.lockLostAt=o),o-this.lockLostAt>=300&&(this.shown={...this.shown,locking:!1},this.lockLostAt=null)}}presentCard(e,o){let a=e.card;if(a===null||e.phase!=="framing"){if(e.phase!=="framing"){this.shown={...this.shown,card:null},this.detectedSince=null,this.lostSince=null;return}this.detectedSince=null,this.lostSince??(this.lostSince=o),o-this.lostSince>=300&&(this.shown={...this.shown,card:null});return}if(this.lostSince=null,this.detectedSince??(this.detectedSince=o),o-this.detectedSince<250)return;let r=this.shown.card;if(r===null){this.shown={...this.shown,card:{...a}};return}let g=.35;this.shown={...this.shown,card:{fill:r.fill+(a.fill-r.fill)*g,offsetX:r.offsetX+(a.offsetX-r.offsetX)*g,offsetY:r.offsetY+(a.offsetY-r.offsetY)*g}}}};d(fe,"ScanPresenter");var oe=fe;import{Fragment as ge,jsx as n,jsxs as i}from"react/jsx-runtime";var mt={en:Z,fr:je,ar:Xe,es:Z,pt:Z,de:Z},ht=450,Se=d(t=>e=>Ee(t.strings[e]??mt[t.locale][e]??""),"useScanCopy");function ae({name:t}){return n("svg",{className:"sekyro-glyph",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",focusable:"false",dangerouslySetInnerHTML:{__html:Be[t]}})}d(ae,"ScanGlyph");var ft={en:j,fr:Ye,ar:Ge,es:j,pt:j,de:j},gt={en:Q,fr:We,ar:Fe,es:Q,pt:Q,de:Q},St="image/jpeg,image/png,image/heic,image/heif";function F(t){let e=t.strings,o=d(a=>e[a]??gt[t.locale][a],"text");return{t:d(a=>o(a)??"","t")}}d(F,"uploadCopy");function vt(t,e){return t===null||t.state==="fallback"||t.state==="mismatch"?null:t.state==="searching"?e?"dcv3.mrz.searching":"dcv3.mrz.showMrzSide":t.state==="valid"?"dcv3.mrz.valid":t.coach!==void 0?`dcv3.mrz.${t.coach}`:"dcv3.mrz.reading"}d(vt,"mrzInstruction");function ve(t){return t.reason==="unreadable"?"doc.reason_unreadable":t.reason==="tester_document_mismatch"?"reasons.tester_document_mismatch":t.reason!==void 0&&t.reason!=="side_missing"?He(t.reason):null}d(ve,"reasonOf");var yt=new Set(["document_type_not_accepted","tester_document_mismatch"]);function ln({step:t,i18n:e,liveMrz:o,ageLead:a,...r}){let[g,S]=b(!1),L=Y(-1),[h,f]=b("idle"),v=Y(null),k=typeof t.uploadDocument=="function",w=k?t.photo?.source??"camera":"camera",T=k&&w!=="camera"&&t.photo?.uploadOffered===!0,[y,A]=b(null),_=w==="upload"?"upload":w==="choice"?y??t.photo?.pick??"source":"camera",H=h==="sending"?void 0:()=>v.current?.click(),m=d(async $=>{let J=$.currentTarget.files?.[0];if($.currentTarget.value="",J!==void 0){S(!1),f("sending");try{await t.uploadDocument(J),f("idle")}catch(X){f(X instanceof TypeError&&X.message==="unsupported_file"?"unsupported":"failed")}}},"onFile"),q=T?n("input",{ref:v,type:"file",accept:St,hidden:!0,"data-testid":"sekyro-doc-upload","aria-label":F(e).t("doc.uploadTitle"),onChange:$=>{m($)}}):null,C=F(e),W=t.photo?.cameraOnPhone===!0;return _==="camera"&&W?n(Ke,{i18n:e,lead:e.t("handoff.lead.document"),refresh:t.refresh,actions:n(O,{kind:"ghost",full:!0,onClick:()=>A("upload"),children:C.t("doc.source.upload")})}):_==="source"?n(Ve,{testId:"sekyro-doc-source",title:C.t("doc.source.title"),lead:C.t("doc.source.description"),cameraLabel:W?e.t("capture.source.phone"):C.t("doc.source.camera"),onPhone:W,uploadLabel:C.t("doc.source.upload"),notice:n(ye,{step:t,i18n:e}),onCamera:()=>A("camera"),onUpload:()=>A("upload")}):_==="upload"?i(ge,{children:[n(wt,{step:t,i18n:e,ageLead:a===!0,upload:h,offered:T,onPick:()=>v.current?.click(),...w==="choice"?{onCamera:d(()=>A("camera"),"onCamera")}:{},...r}),q]}):i(ge,{children:[g?n(Nt,{step:t,i18n:e,attempts:L,...o!==void 0?{liveMrz:o}:{},...T&&H!==void 0?{onUpload:H}:{},onClose:()=>S(!1)}):n(bt,{step:t,i18n:e,ageLead:a===!0,onOpen:()=>S(!0),upload:h,...T&&H!==void 0?{onUpload:H}:{},...r}),q]})}d(ln,"DocumentCaptureView");function qe({passport:t}){let o=Math.round(228/(t?1.42:1.586));return i("svg",{className:"sekyro-mark sekyro-mark--card",viewBox:`-12 -12 252 ${o+24}`,"aria-hidden":"true",focusable:"false",children:[n("defs",{children:n("clipPath",{id:"sekyro-card-clip",children:n("rect",{width:228,height:o,rx:"12.5"})})}),n("rect",{className:"sekyro-mark__card",width:228,height:o,rx:"12.5"}),n("rect",{className:"sekyro-mark__photo",x:"17",y:"17",width:"55",height:o*.52,rx:"6"}),[0,1,2].map(a=>n("rect",{className:"sekyro-mark__text",x:"88",y:23+a*o*.12,width:100-a*20,height:"6",rx:"3"},a)),[0,1].map(a=>n("rect",{className:"sekyro-mark__text",x:"17",y:o*.74+a*9,width:194,height:"4",rx:"2"},a)),n("g",{clipPath:"url(#sekyro-card-clip)",children:n("g",{className:"sekyro-mark__read",style:{"--sekyro-read-w":"228px"},children:n("rect",{x:"-1",width:"2",height:o,className:"sekyro-mark__beam"})})}),n("path",{className:"sekyro-mark__brackets",d:kt(-10,-10,248,o+20,16,30)})]})}d(qe,"ScanMark");function kt(t,e,o,a,r,g){let S=Math.min(r,g*.6);return[[t,e,1,1],[t+o,e,-1,1],[t,e+a,1,-1],[t+o,e+a,-1,-1]].map(([h,f,v,k])=>`M${h} ${f+k*g}V${f+k*S}Q${h} ${f} ${h+v*S} ${f}H${h+v*g}`).join("")}d(kt,"brackets");function bt({step:t,i18n:e,ageLead:o,onOpen:a,onChangeCountry:r,onChangeDocument:g,upload:S,onUpload:L}){let h=Se(e),f=F(e),v=t.documentType==="passport",k=ve(t),w=S==="sending",T=Ze(Pe)?.busy===!0;return i("section",{className:"sekyro-step","data-testid":"sekyro-document",children:[n(qe,{passport:v}),n(ue,{title:h("native.doc.introTitle"),lead:o?e.t("doc.ageStepUp"):h("native.doc.introLead")}),n(ye,{step:t,i18n:e}),t.reason!==void 0&&yt.has(t.reason)?null:i("ul",{className:"sekyro-tiprows",children:[i("li",{children:[n(B,{name:v?"passport":"card"}),h("native.doc.tip.flat")]}),i("li",{children:[n(B,{name:"light"}),h("native.doc.tip.glare")]}),i("li",{children:[n(ae,{name:"image"}),h("native.doc.tip.frame")]})]}),n(Je,{i18n:e,...g!==void 0?{onChangeDocument:g}:{},...r!==void 0?{onChangeCountry:r}:{}}),n(et,{i18n:e,upload:S}),w?n("p",{className:"sekyro-text-muted",role:"status",children:e.t("doc.uploading")}):L!==void 0?n("p",{className:"sekyro-text-muted",children:f.t("doc.uploadHint")}):null,i(pe,{children:[i(O,{full:!0,onClick:a,disabled:w||T,children:[n(B,{name:"camera"}),h("native.doc.openCamera")]}),L!==void 0?i(O,{full:!0,kind:"ghost",onClick:L,children:[n(ae,{name:"image"}),f.t("doc.uploadInstead")]}):null]})]})}d(bt,"DocumentIntro");function ye({step:t,i18n:e}){let o=ve(t);return o===null?null:i(me,{tone:"warning",children:[n("span",{children:e.t(o)}),n("span",{children:he(e,t.attemptsRemaining,t.attemptsExhausted)})]})}d(ye,"ReasonNotice");function Je({i18n:t,onChangeCountry:e,onChangeDocument:o}){let a=Se(t);return o===void 0&&e===void 0?null:i("div",{className:"sekyro-links",children:[o!==void 0?n("button",{type:"button",className:"sekyro-link",onClick:o,children:a("native.doc.changeDocument")}):null,e!==void 0?n("button",{type:"button",className:"sekyro-link",onClick:e,children:t.t("native.doc.changeCountry")}):null]})}d(Je,"ChangeLinks");function et({i18n:t,upload:e}){return e!=="unsupported"&&e!=="failed"?null:n(me,{tone:"warning",children:n("span",{children:F(t).t(e==="unsupported"?"doc.uploadUnsupported":"doc.uploadFailed")})})}d(et,"UploadNotice");function wt({step:t,i18n:e,ageLead:o,upload:a,offered:r,onPick:g,onCamera:S,onChangeCountry:L,onChangeDocument:h}){let f=F(e),v=a==="sending";return i("section",{className:"sekyro-step","data-testid":"sekyro-doc-upload-screen",children:[n(qe,{passport:t.documentType==="passport"}),n(ue,{title:f.t("doc.uploadTitle"),lead:o?e.t("doc.ageStepUp"):f.t("doc.uploadHint")}),o?n("p",{className:"sekyro-text-muted",children:f.t("doc.uploadHint")}):null,n(ye,{step:t,i18n:e}),n(Je,{i18n:e,...h!==void 0?{onChangeDocument:h}:{},...L!==void 0?{onChangeCountry:L}:{}}),n(et,{i18n:e,upload:a}),v?n("p",{className:"sekyro-text-muted",role:"status",children:e.t("doc.uploading")}):null,i(pe,{children:[i(O,{full:!0,onClick:g,disabled:v||!r||t.attemptsExhausted,children:[n(ae,{name:"image"}),f.t("doc.source.upload")]}),S!==void 0?i(O,{full:!0,kind:"ghost",onClick:S,disabled:v,children:[n(B,{name:"camera"}),f.t("doc.source.camera")]}):null]})]})}d(wt,"DocumentUploadScreen");function Qe(t,e,o){let a=t*.88,r=a/o;return{x:(t-a)/2,y:e*.42-r/2,w:a,h:r}}d(Qe,"guideRect");var Ct={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"},Dt=d(()=>typeof window<"u"&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,"reduceMotion");function Nt({step:t,i18n:e,liveMrz:o,onClose:a,attempts:r,onUpload:g}){let S=Se(e),L=Ze($e),h=Y(L);h.current=L;let f=Y(null),v=Y(null),k=Y(null),[w,T]=b("idle"),[y,A]=b(null),[_,H]=b(null),[m,q]=b({w:0,h:0}),[C,W]=b({hint:null,locking:!1,card:null,manualShutter:!1}),[$,J]=b({}),[X,tt]=b(null),[ke,nt]=b(null),[be,we]=b(0),[Ce,De]=b(null),[ee,Ne]=b(null),R=t.documentType==="passport",te=R?1.42:1.586;Ie(!0),pt(()=>{let c=f.current;if(c===null)return;let u=d(()=>q({w:c.clientWidth,h:c.clientHeight}),"measure");if(u(),typeof ResizeObserver>"u")return;let l=new ResizeObserver(u);return l.observe(c),()=>l.disconnect()},[]);let s=Qe(m.w,m.h,te);G(()=>{m.w===0||m.h===0||k.current?.setGuide?.({viewAspect:m.w/m.h,rect:{x:s.x/m.w,y:s.y/m.h,width:s.w/m.w,height:s.h/m.h}})},[m.w,m.h,s.x,s.y,s.w,s.h]),G(()=>{let c=v.current;if(c===null)return;let u=t.capture({video:c,...o!==void 0?{liveMrz:o}:{}});k.current=u;let l=f.current;if(l!==null&&l.clientWidth>0&&l.clientHeight>0){let p=Qe(l.clientWidth,l.clientHeight,te);u.setGuide?.({viewAspect:l.clientWidth/l.clientHeight,rect:{x:p.x/l.clientWidth,y:p.y/l.clientHeight,width:p.w/l.clientWidth,height:p.h/l.clientHeight}})}let M=new oe,N={scan:null,feedback:null,gate:null},E=d(p=>{N={...N,...p};let x=N.gate?.guide,dt={phase:N.scan?.phase??"framing",hint:N.feedback?.reticle==="coaching"?N.feedback.key:null,card:x?.detected?{fill:x.fill,offsetX:x.offsetX,offsetY:x.offsetY}:null,manualShutter:N.scan?.manualShutter??!1},I=M.present(dt,performance.now());W(P=>P.hint===I.hint&&P.locking===I.locking&&P.manualShutter===I.manualShutter&&P.card?.fill===I.card?.fill&&P.card?.offsetX===I.card?.offsetX&&P.card?.offsetY===I.card?.offsetY?P:I)},"present"),lt=[u.on("state",T),u.on("feedback",p=>E({feedback:p})),u.on("gate",p=>E({gate:p})),u.on("scan",p=>{A(p),E({scan:p})}),u.on("captured",p=>{J(x=>({...x,[Lt(p.side,R,x)]:p.previewDataUrl})),tt(p.previewDataUrl),nt(xt(c))}),u.on("error",p=>{H(p);let x=h.current;x!==null&&Ue(x,Re("document",p,Math.max(0,r.current)))}),u.on("mrz",p=>{p.state==="mismatch"?Ne(p.format??null):De(p)})];return r.current+=1,u.start().catch(()=>{}),()=>{for(let p of lt)p();u.destroy(),k.current=null}},[t.issuer,t.documentType]);let z=y?.phase??"framing",U=z==="reading"||z==="result",re=z==="flipCue"||z==="reaskRecto",K=C.locking,Le=y?.captured.length??0;G(()=>{K&&we(c=>c+1)},[K]),G(()=>{Le>0&&we(c=>c+1)},[Le]);let ot=y?.expected??null;G(()=>{De(null)},[ot]),G(()=>{if(ee===null)return;let c=setTimeout(()=>Ne(null),2e3);return()=>clearTimeout(c)},[ee]);let ze=re||U?null:vt(Ce,R),se=ee!==null?ee==="TD3"?"dcv3.mrz.looksLikePassport":"dcv3.mrz.looksLikeCard":ze,at=se===null?null:e.strings[se]??ft[e.locale][se],ie=ve(t),xe=C.hint===null?null:Ct[C.hint]??`dcv2.${C.hint}`,rt=xe??(z==="flipCue"?y?.notice==="same_face"?"doc.sameFace":"doc.flip":z==="reaskRecto"?"doc.reaskRecto":U?"native.scan.reading":z==="locking"||z==="capturing"||K?"native.scan.holdStill":y?.notice==="reread"?ie??"doc.reread":y?.notice==="technical"?"native.scan.retry":y?.notice==="blurry"?"native.scan.blurry":ie??(R?"doc.showPage":"doc.showSide")),ce=at??S(rt),V=C.card,D=s;if(!K&&V!==null&&V.fill>=.45&&V.fill<=1.25&&!Dt()){let c=s.w*V.fill,u=c/te,l=s.x+s.w/2+s.w*Math.max(-.25,Math.min(.25,V.offsetX)),M=s.y+s.h/2+s.h*Math.max(-.25,Math.min(.25,V.offsetY));D={x:l-c/2,y:M-u/2,w:c,h:u}}let ne=s.w*.045,le=28,Te=Math.min(ne,le*.6),st=[[D.x,D.y,1,1],[D.x+D.w,D.y,-1,1],[D.x,D.y+D.h,1,-1],[D.x+D.w,D.y+D.h,-1,-1]],it=K?"is-locked":C.hint!==null?"is-coaching":"",ct=R?[{side:"single",label:"doc.progressPage"}]:[{side:"recto",label:"doc.progressFront"},{side:"verso",label:"doc.progressBack"}],Me=s.y+s.h+48,de={insetInlineStart:s.x,insetBlockStart:s.y,inlineSize:s.w,blockSize:s.h,borderRadius:ne};return n("section",{className:"sekyro-lm","aria-label":ce,"data-testid":"sekyro-document",children:i("div",{ref:f,className:`sekyro-lm-stage${U?" is-reading":""}${re?" is-flip":""}`,style:{"--sekyro-guide-w":`${s.w}px`},children:[n("video",{ref:v,className:"sekyro-lm-video",playsInline:!0,muted:!0,autoPlay:!0,"aria-hidden":"true",onPointerUp:c=>{let u=c.currentTarget,l=u.getBoundingClientRect(),M=Math.max(l.width/(u.videoWidth||1),l.height/(u.videoHeight||1)),N=u.videoWidth*M,E=u.videoHeight*M;N>0&&E>0&&k.current?.focusAt((c.clientX-l.left+(N-l.width)/2)/N,(c.clientY-l.top+(E-l.height)/2)/E)}}),m.w>0?i(ge,{children:[U&&ke!==null?n("img",{className:"sekyro-lm-scene",src:ke,alt:""}):null,U&&X!==null?n("img",{className:"sekyro-lm-frozen",src:X,alt:"",style:de}):null,i("svg",{className:"sekyro-lm-overlay",viewBox:`0 0 ${m.w} ${m.h}`,"aria-hidden":"true",focusable:"false",children:[i("defs",{children:[i("linearGradient",{id:"sekyro-lm-top",x1:"0",y1:"0",x2:"0",y2:"1",children:[n("stop",{offset:"0",className:"sekyro-lm-ink",stopOpacity:"0.85"}),n("stop",{offset:"1",className:"sekyro-lm-ink",stopOpacity:"0"})]}),i("linearGradient",{id:"sekyro-lm-bottom",x1:"0",y1:"0",x2:"0",y2:"1",children:[n("stop",{offset:"0",className:"sekyro-lm-ink",stopOpacity:"0"}),n("stop",{offset:"1",className:"sekyro-lm-ink",stopOpacity:"0.9"})]})]}),n("path",{className:"sekyro-lm-scrim",fillRule:"evenodd",d:`M0 0H${m.w}V${m.h}H0Z${zt(s,ne)}`}),n("rect",{width:m.w,height:Math.max(0,s.y),fill:"url(#sekyro-lm-top)"}),n("rect",{y:s.y+s.h,width:m.w,height:Math.max(0,m.h-s.y-s.h),fill:"url(#sekyro-lm-bottom)"}),n("g",{className:`sekyro-lm-brackets ${it}`,children:st.map(([c,u,l,M],N)=>n("path",{style:{transform:`translate(${c}px, ${u}px) scale(${l}, ${M})`},d:`M0 ${le}V${Te}Q0 0 ${Te} 0H${le}`},N))}),K?n("rect",{className:"sekyro-lm-trace",x:s.x,y:s.y,width:s.w,height:s.h,rx:ne,pathLength:"1",style:{animationDuration:`${ht}ms`}}):null]}),n("div",{className:"sekyro-lm-slot",style:de,"aria-hidden":"true",children:U?n("span",{className:"sekyro-lm-read is-repeating"}):be>0?n("span",{className:"sekyro-lm-read"},be):null})]}):null,ze!==null?n("div",{className:"sekyro-lm-slot",style:de,"aria-hidden":"true",children:n("span",{"data-testid":"sekyro-mrz-strip",className:`sekyro-lm-mrz${R?" is-page":""}${Ce?.state==="valid"?" is-valid":""}`})}):null,i("div",{className:"sekyro-lm-instruction",style:{insetBlockStart:s.y-64},children:[n("div",{role:"status","aria-live":"polite",children:n(Ae,{swapKey:ce,className:"sekyro-lm-line",children:ce})}),ie!==null&&z==="framing"&&xe===null?n("p",{className:"sekyro-lm-attempts",children:he(e,t.attemptsRemaining,t.attemptsExhausted)}):null]}),U?i("p",{className:"sekyro-lm-under sekyro-lm-note",style:{insetBlockStart:Me-12},children:[n("span",{className:"sekyro-lm-spinner","aria-hidden":"true"}),S("native.scan.putDown")]}):re?n("div",{className:`sekyro-lm-under sekyro-lm-flip${z==="reaskRecto"?" is-toFront":""}`,style:{insetBlockStart:Me-20},"data-testid":"sekyro-flip-cue","aria-hidden":"true",children:i("span",{className:"sekyro-lm-flip-card",style:{aspectRatio:String(te)},children:[n("span",{className:"sekyro-lm-flip-front"}),n("span",{className:"sekyro-lm-flip-back"})]})}):null,i("div",{className:"sekyro-lm-controls",children:[i("div",{className:"sekyro-lm-bar",children:[n("button",{type:"button",className:"sekyro-glass","aria-label":e.t("native.close"),onClick:a,children:n(B,{name:"close"})}),y?.torchAvailable?n("button",{type:"button",className:`sekyro-glass${y.torch?" is-on":""}`,"aria-label":e.t("doc.torchOn"),"aria-pressed":y.torch,onClick:()=>k.current?.setTorch(!y.torch),children:n(ae,{name:"flashlight"})}):null]}),_!==null?i("div",{className:"sekyro-lm-error",role:"alert",children:[n("p",{children:e.t("doc.cameraBlocked")}),n("p",{children:e.t(_.kind==="permission"?"doc.cameraBlockedHint":_e(_.kind))}),n(O,{onClick:()=>{H(null),r.current+=1,k.current?.retry()},children:e.t("doc.retryCamera")})]}):null,C.manualShutter?n("button",{type:"button",className:"sekyro-shutter","aria-label":e.t("doc.shutter"),onClick:()=>k.current?.shutter()}):null,n("ol",{className:"sekyro-lm-tray",children:ct.map(({side:c,label:u})=>{let l=y?.captured.includes(c)??!1;return i("li",{className:l?"is-done":void 0,"aria-current":!l&&(R||y?.expected===c)?"step":void 0,children:[l?i("span",{className:"sekyro-lm-thumb",children:[$[c]!==void 0?n("img",{src:$[c],alt:""}):null,n("svg",{className:"sekyro-lm-check",viewBox:"0 0 18 18","aria-hidden":"true",children:n("path",{d:"M5 9.2l2.6 2.6L13 6.4"})})]}):null,S(u)]},c)})}),g!==void 0?n("button",{type:"button",className:"sekyro-lm-upload",onClick:g,children:F(e).t("doc.uploadInstead")}):null,w==="uploading"||w==="checking"?null:n(Oe,{onStop:a})]}),w==="uploading"||w==="checking"?n("span",{className:"sekyro-visually-hidden",role:"status",children:w==="uploading"?e.t("doc.uploading"):S("native.scan.reading")}):null]})})}d(Nt,"LumiereScan");function Lt(t,e,o){return e?"single":t==="recto"||t==="verso"?t:o.recto===void 0?"recto":"verso"}d(Lt,"slotOf");function zt({x:t,y:e,w:o,h:a},r){return`M${t+r} ${e}H${t+o-r}Q${t+o} ${e} ${t+o} ${e+r}V${e+a-r}Q${t+o} ${e+a} ${t+o-r} ${e+a}H${t+r}Q${t} ${e+a} ${t} ${e+a-r}V${e+r}Q${t} ${e} ${t+r} ${e}Z`}d(zt,"roundedRect");function xt(t){let e=Math.round(t.videoWidth/4),o=Math.round(t.videoHeight/4);if(e===0||o===0||typeof document>"u")return null;try{let a=document.createElement("canvas");a.width=e,a.height=o;let r=a.getContext("2d");return r===null?null:(r.drawImage(t,0,0,e,o),a.toDataURL("image/jpeg",.7))}catch{return null}}d(xt,"sceneSnapshot");export{ln as DocumentCaptureView,ht as LOCK_TRACE_MS,St as UPLOAD_ACCEPT,Qe as guideRect,vt as mrzInstruction,Lt as slotOf};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{a as O,b as K,c as z}from"./chunk-GUTF3SPK.js";import{a as Y,b as y,c as q}from"./chunk-55NNQK5P.js";import{a as U}from"./chunk-VRDPGOXM.js";import{d as $}from"./chunk-E7PG3JL4.js";import{d as x,m as W,p as A}from"./chunk-TWZZGFO5.js";import"./chunk-TLMGY7AK.js";import{a as N,s as G}from"./chunk-ONYT4GJ4.js";import{a}from"./chunk-2KED7D2Q.js";import{isValidNni as ce,normalizeNni as J}from"@sekyro/web";import{useEffect as R,useId as ue,useRef as Q,useState as S}from"react";import{Fragment as w,jsx as n,jsxs as l}from"react/jsx-runtime";var X={en:y,fr:q,ar:Y,es:y,pt:y,de:y},C=6,me=new Set(["eid_identifier_invalid","eid_code_invalid","eid_locked","eid_not_enrolled"]),Z=a((e,t)=>{if(e===void 0)return 0;let p=Date.parse(e)-t;return Number.isFinite(p)?Math.max(0,Math.ceil(p/1e3)):0},"secondsUntil"),pe=a(e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`,"mmss");function Ae({step:e,i18n:t,className:p,onError:j}){let B=t.strings,o=a((i,s)=>$(B[i]??X[t.locale][i]??"",s),"t"),P=a((i,s)=>{let ae=new Intl.PluralRules(t.locale).select(s),V=`${i}.${ae}`,le=B[V]??X[t.locale][V]??o(`${i}.other`);return $(le,{count:new Intl.NumberFormat(t.locale).format(s)})},"plural"),v=a(i=>e.providerName?o(`eid.${i}`,{provider:e.providerName}):o(`eid.${i}Generic`),"named"),[I,ee]=S(""),[f,h]=S(""),[c,D]=S(!1),[g,u]=S(null),r=e.phase==="code",F=z(r),d=ue(),ne=G(),[ie,oe]=O(e.reason==="eid_code_invalid",e.codeAttemptsRemaining??0,()=>h("")),m=a(async i=>{D(!0),u(null);try{await i()}catch(s){u(U(s,t.strings)),j?.(s)}finally{D(!1)}},"run"),T=Q(!1);R(()=>{!e.identifierBound||r||e.reason!==void 0||T.current||(T.current=!0,m(()=>e.start()))},[e.identifierBound,r,e.reason]),R(()=>{(e.reason==="eid_code_invalid"||e.codeExpiresAt!==void 0)&&h("")},[e.reason,e.codeExpiresAt,e.codeAttemptsRemaining]);let H=Q(r);R(()=>{r&&!H.current&&document.getElementById(`${d}-code`)?.focus(),H.current=r},[r,d]);let b=e.reason==="eid_locked",M=Z(e.codeExpiresAt,F),E=r&&e.codeExpiresAt!==void 0&&M===0,_=Z(e.resendAvailableAt,F),L=e.resendsRemaining===0||e.reason==="eid_resend_limit",te=a(i=>{if(i.preventDefault(),r){f.length===C&&!b&&m(()=>e.verify(f));return}if(e.identifierBound){m(()=>e.start());return}let s=J(I);if(e.country==="MR"){if(!/^\d{10}$/.test(s))return u("population.invalid");if(!ce(s))return u("population.reason_nni_invalid")}m(()=>e.start(s))},"onSubmit"),k=e.reason?.startsWith("eid_")?e.reason:void 0,re=l(w,{children:[k!==void 0?l(A,{tone:me.has(k)?"danger":"warning",children:[n("span",{children:o(`reasons.${k}`)}),k==="eid_code_invalid"&&e.codeAttemptsRemaining!==void 0?n("span",{children:P("eid.codeAttemptsRemaining",e.codeAttemptsRemaining)}):null,e.canUseCamera?n(N,{kind:"secondary",disabled:c,onClick:()=>{m(()=>e.useCamera())},children:o("eid.useCamera")}):null]}):null,g!==null?n(A,{tone:"danger",children:n("span",{children:t.t(g)})}):null]}),[de,se]=r?[v("codeTitle"),v("codeHelp")]:[v("identifierTitle"),v(e.identifierBound?"boundDescription":"identifierDescription")];return l("form",{className:`sekyro-step sekyro-otp${p?` ${p}`:""}`,"aria-labelledby":d,onSubmit:te,noValidate:!0,"data-testid":"sekyro-eid",children:[l("div",{className:"sekyro-heading",children:[n("h2",{id:d,ref:ne,tabIndex:-1,className:"sekyro-text-body",children:de}),n("p",{className:"sekyro-text-muted",children:r&&e.context.simulation!==void 0?n(W,{template:t.t("sandbox.otpHint"),code:e.context.simulation.otpCode}):se}),e.afterPass==="continue"?n("p",{className:"sekyro-text-muted","data-testid":"sekyro-eid-continue",children:e.providerName?o("eid.continueHint",{provider:e.providerName}):o("eid.continueHintGeneric")}):null]}),re,r?l(w,{children:[l("div",{className:"sekyro-field",children:[n("label",{className:"sekyro-label",htmlFor:`${d}-code`,children:o("eid.codeLabel")}),b?n("input",{id:`${d}-code`,className:"sekyro-input sekyro-input--number",dir:"ltr",value:f,disabled:!0,readOnly:!0}):n(K,{id:`${d}-code`,value:f,length:C,invalid:ie,onChange:i=>{u(null),i!==""&&oe(),h(i)}}),e.codeExpiresAt!==void 0?n("span",{className:`sekyro-help sekyro-otp-expiry${E?" is-danger":""}`,children:E?o("eid.expired"):o("eid.expiresIn",{time:pe(M)})}):null]}),n("span",{className:"sekyro-visually-hidden",role:"status","aria-live":"polite",children:E?o("eid.expired"):""}),l(x,{children:[n(N,{type:"submit",full:!0,disabled:c||f.length!==C||b,"aria-busy":c||void 0,children:o("eid.verify")}),n("div",{className:"sekyro-resend-row",children:L?n("p",{className:"sekyro-resend is-waiting",children:o("eid.noResendsLeft")}):n("button",{type:"button",className:"sekyro-link sekyro-resend",disabled:c||_>0||b,onClick:()=>{m(()=>e.resend())},children:_>0?o("eid.resendIn",{seconds:_}):o("eid.resend")})}),!L&&e.resendsRemaining!==void 0?n("p",{className:"sekyro-help sekyro-center",children:P("eid.resendsRemaining",e.resendsRemaining)}):null]})]}):l(w,{children:[e.identifierBound?null:l("div",{className:"sekyro-field",children:[n("label",{className:"sekyro-label",htmlFor:`${d}-nni`,children:t.t("population.label")}),n("input",{id:`${d}-nni`,className:"sekyro-input sekyro-input--number",dir:"ltr",inputMode:"numeric",autoComplete:"off",placeholder:t.t("population.placeholder"),value:I,"aria-describedby":`${d}-nni-help`,"aria-invalid":g==="population.invalid"||g==="population.reason_nni_invalid"||void 0,onChange:i=>{u(null),ee(J(i.target.value).replace(/\D/g,"").slice(0,10))}}),n("span",{id:`${d}-nni-help`,className:"sekyro-help",children:t.t("population.helper")})]}),n(x,{children:n(N,{type:"submit",full:!0,disabled:c,"aria-busy":c||void 0,children:o("eid.start")})})]})]})}a(Ae,"EidView");export{Ae as EidView};
2
+ import{a as O,b as K,c as z}from"./chunk-GUTF3SPK.js";import{a as Y,b as y,c as q}from"./chunk-55NNQK5P.js";import{a as U}from"./chunk-VRDPGOXM.js";import{d as $}from"./chunk-B4OAK5EF.js";import{d as x,m as W,p as A}from"./chunk-RO2EITOC.js";import"./chunk-IAZ5UH2B.js";import{a as N,s as G}from"./chunk-6QYD5HOU.js";import{a}from"./chunk-2KED7D2Q.js";import{isValidNni as ce,normalizeNni as J}from"@sekyro/web";import{useEffect as R,useId as ue,useRef as Q,useState as S}from"react";import{Fragment as w,jsx as n,jsxs as l}from"react/jsx-runtime";var X={en:y,fr:q,ar:Y,es:y,pt:y,de:y},C=6,me=new Set(["eid_identifier_invalid","eid_code_invalid","eid_locked","eid_not_enrolled"]),Z=a((e,t)=>{if(e===void 0)return 0;let p=Date.parse(e)-t;return Number.isFinite(p)?Math.max(0,Math.ceil(p/1e3)):0},"secondsUntil"),pe=a(e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`,"mmss");function Ae({step:e,i18n:t,className:p,onError:j}){let B=t.strings,o=a((i,s)=>$(B[i]??X[t.locale][i]??"",s),"t"),P=a((i,s)=>{let ae=new Intl.PluralRules(t.locale).select(s),V=`${i}.${ae}`,le=B[V]??X[t.locale][V]??o(`${i}.other`);return $(le,{count:new Intl.NumberFormat(t.locale).format(s)})},"plural"),v=a(i=>e.providerName?o(`eid.${i}`,{provider:e.providerName}):o(`eid.${i}Generic`),"named"),[I,ee]=S(""),[f,h]=S(""),[c,D]=S(!1),[g,u]=S(null),r=e.phase==="code",F=z(r),d=ue(),ne=G(),[ie,oe]=O(e.reason==="eid_code_invalid",e.codeAttemptsRemaining??0,()=>h("")),m=a(async i=>{D(!0),u(null);try{await i()}catch(s){u(U(s,t.strings)),j?.(s)}finally{D(!1)}},"run"),T=Q(!1);R(()=>{!e.identifierBound||r||e.reason!==void 0||T.current||(T.current=!0,m(()=>e.start()))},[e.identifierBound,r,e.reason]),R(()=>{(e.reason==="eid_code_invalid"||e.codeExpiresAt!==void 0)&&h("")},[e.reason,e.codeExpiresAt,e.codeAttemptsRemaining]);let H=Q(r);R(()=>{r&&!H.current&&document.getElementById(`${d}-code`)?.focus(),H.current=r},[r,d]);let b=e.reason==="eid_locked",M=Z(e.codeExpiresAt,F),E=r&&e.codeExpiresAt!==void 0&&M===0,_=Z(e.resendAvailableAt,F),L=e.resendsRemaining===0||e.reason==="eid_resend_limit",te=a(i=>{if(i.preventDefault(),r){f.length===C&&!b&&m(()=>e.verify(f));return}if(e.identifierBound){m(()=>e.start());return}let s=J(I);if(e.country==="MR"){if(!/^\d{10}$/.test(s))return u("population.invalid");if(!ce(s))return u("population.reason_nni_invalid")}m(()=>e.start(s))},"onSubmit"),k=e.reason?.startsWith("eid_")?e.reason:void 0,re=l(w,{children:[k!==void 0?l(A,{tone:me.has(k)?"danger":"warning",children:[n("span",{children:o(`reasons.${k}`)}),k==="eid_code_invalid"&&e.codeAttemptsRemaining!==void 0?n("span",{children:P("eid.codeAttemptsRemaining",e.codeAttemptsRemaining)}):null,e.canUseCamera?n(N,{kind:"secondary",disabled:c,onClick:()=>{m(()=>e.useCamera())},children:o("eid.useCamera")}):null]}):null,g!==null?n(A,{tone:"danger",children:n("span",{children:t.t(g)})}):null]}),[de,se]=r?[v("codeTitle"),v("codeHelp")]:[v("identifierTitle"),v(e.identifierBound?"boundDescription":"identifierDescription")];return l("form",{className:`sekyro-step sekyro-otp${p?` ${p}`:""}`,"aria-labelledby":d,onSubmit:te,noValidate:!0,"data-testid":"sekyro-eid",children:[l("div",{className:"sekyro-heading",children:[n("h2",{id:d,ref:ne,tabIndex:-1,className:"sekyro-text-body",children:de}),n("p",{className:"sekyro-text-muted",children:r&&e.context.simulation!==void 0?n(W,{template:t.t("sandbox.otpHint"),code:e.context.simulation.otpCode}):se}),e.afterPass==="continue"?n("p",{className:"sekyro-text-muted","data-testid":"sekyro-eid-continue",children:e.providerName?o("eid.continueHint",{provider:e.providerName}):o("eid.continueHintGeneric")}):null]}),re,r?l(w,{children:[l("div",{className:"sekyro-field",children:[n("label",{className:"sekyro-label",htmlFor:`${d}-code`,children:o("eid.codeLabel")}),b?n("input",{id:`${d}-code`,className:"sekyro-input sekyro-input--number",dir:"ltr",value:f,disabled:!0,readOnly:!0}):n(K,{id:`${d}-code`,value:f,length:C,invalid:ie,onChange:i=>{u(null),i!==""&&oe(),h(i)}}),e.codeExpiresAt!==void 0?n("span",{className:`sekyro-help sekyro-otp-expiry${E?" is-danger":""}`,children:E?o("eid.expired"):o("eid.expiresIn",{time:pe(M)})}):null]}),n("span",{className:"sekyro-visually-hidden",role:"status","aria-live":"polite",children:E?o("eid.expired"):""}),l(x,{children:[n(N,{type:"submit",full:!0,disabled:c||f.length!==C||b,"aria-busy":c||void 0,children:o("eid.verify")}),n("div",{className:"sekyro-resend-row",children:L?n("p",{className:"sekyro-resend is-waiting",children:o("eid.noResendsLeft")}):n("button",{type:"button",className:"sekyro-link sekyro-resend",disabled:c||_>0||b,onClick:()=>{m(()=>e.resend())},children:_>0?o("eid.resendIn",{seconds:_}):o("eid.resend")})}),!L&&e.resendsRemaining!==void 0?n("p",{className:"sekyro-help sekyro-center",children:P("eid.resendsRemaining",e.resendsRemaining)}):null]})]}):l(w,{children:[e.identifierBound?null:l("div",{className:"sekyro-field",children:[n("label",{className:"sekyro-label",htmlFor:`${d}-nni`,children:t.t("population.label")}),n("input",{id:`${d}-nni`,className:"sekyro-input sekyro-input--number",dir:"ltr",inputMode:"numeric",autoComplete:"off",placeholder:t.t("population.placeholder"),value:I,"aria-describedby":`${d}-nni-help`,"aria-invalid":g==="population.invalid"||g==="population.reason_nni_invalid"||void 0,onChange:i=>{u(null),ee(J(i.target.value).replace(/\D/g,"").slice(0,10))}}),n("span",{id:`${d}-nni-help`,className:"sekyro-help",children:t.t("population.helper")})]}),n(x,{children:n(N,{type:"submit",full:!0,disabled:c,"aria-busy":c||void 0,children:o("eid.start")})})]})]})}a(Ae,"EidView");export{Ae as EidView};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{a as F,b as q,c as J}from"./chunk-GUTF3SPK.js";import{a as U}from"./chunk-VRDPGOXM.js";import{d as B}from"./chunk-E7PG3JL4.js";import{b as Y,d as N,f as K,m as G,p as b,q as j}from"./chunk-TWZZGFO5.js";import"./chunk-TLMGY7AK.js";import{a as k}from"./chunk-ONYT4GJ4.js";import{a as l}from"./chunk-2KED7D2Q.js";import{OtpInputError as pe}from"@sekyro/web";import{useEffect as ce,useId as ue,useRef as Oe,useState as p}from"react";var Q={"emailOtp.reason_otp_daily_cap_reached":"لا يمكننا إرسال رمز إلى بريدك الإلكتروني اليوم. اختر طريقة أخرى للتحقق إن كانت متاحة، أو حاول مرة أخرى لاحقًا.","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":"لا يمكنك طلب رموز أخرى. أدخل آخر رمز وصلك"};var O={"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.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 in a moment","emailOtp.reason_otp_rate_limited":"Too many codes requested. Wait a moment, then try again","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"};var X={"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.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 dans un instant","emailOtp.reason_otp_rate_limited":"Trop de codes demandés. Patientez un instant, puis réessayez","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"};import{Fragment as C,jsx as a,jsxs as o}from"react/jsx-runtime";var fe={en:O,fr:X,ar:Q,es:O,pt:O,de:O},Z=l((e,r,f)=>{if(e===void 0)return 0;let y=Date.parse(e)-r;return Number.isFinite(y)?Math.min(f,Math.max(0,Math.ceil(y/1e3))):0},"secondsUntil"),ye=600,_e=60,ve=l(e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`,"mmss"),ee=new Set(["otp_expired","otp_send_failed","otp_rate_limited","otp_resend_limit","email_invalid","email_disposable","otp_daily_cap_reached"]);function Ae({step:e,i18n:r,className:f,defaultEmail:y="",onError:ae}){let i=l((t,s)=>B(r.strings[t]??fe[r.locale][t],s),"t"),[x,ie]=p(y),[_,T]=p(""),[n,z]=p(!1),[w,I]=p(null),[g,c]=p(!1),[R,te]=p(null),u=Oe(null),v=e.phase==="verify",d=v&&!g,V=J(v),m=ue(),[se,oe]=F(e.reason==="otp_mismatch",e.attemptsRemaining,()=>T("")),A=v?e.codeExpiresAt??"sent":null;ce(()=>{A!==null&&(c(!1),u.current!==null&&!ee.has(e.reason??"")&&te(u.current),u.current=null)},[A]);let L=l(async t=>{z(!0),I(null);try{await t()}catch(s){I(s instanceof pe&&s.field==="email"?i("emailOtp.emailInvalid"):r.t(U(s,r.strings))),ae?.(s)}finally{z(!1)}},"run"),D=l(t=>{let s=e.needsEmail?t?R:x.trim():null;u.current=s,L(async()=>{try{await e.send(s!==null?{email:s}:{})}catch(de){throw u.current=null,de}})},"send"),$=l(t=>{L(()=>e.verify(t))},"submitCode"),ne=l(t=>{t.preventDefault(),d?$(_):D(!1)},"onSubmit"),S=Z(e.codeExpiresAt,V,ye),E=Z(e.resendAvailableAt,V,_e),h=d&&e.codeExpiresAt!==void 0&&S===0,P=e.needsEmail&&!e.attemptsExhausted,W=v&&(e.codeExpiresAt===void 0||S>0),H=d&&P?()=>c(!0):g&&W?()=>c(!1):null;K(H===null?null:n?()=>{}:H);let[le,re]=i("emailOtp.sentTo").split("{email}"),M=e.context.simulation?.otpCode,me=e.reason==="otp_mismatch"?o(b,{tone:"danger",children:[a("span",{children:i("emailOtp.reason_otp_mismatch")}),a("span",{children:j(r,e.attemptsRemaining,e.attemptsExhausted)})]}):e.reason!==void 0&&ee.has(e.reason)?a(b,{tone:"warning",children:a("span",{children:i(`emailOtp.reason_${e.reason}`)})}):null;return o("form",{className:`sekyro-step sekyro-otp${f?` ${f}`:""}`,"aria-labelledby":m,onSubmit:ne,noValidate:!0,children:[a(Y,{id:m,title:i(d?"emailOtp.verifyTitle":"emailOtp.sendTitle"),lead:d&&M!==void 0?a(G,{template:r.t("sandbox.otpHint"),code:M}):d?o(C,{children:[le,a("bdi",{dir:"ltr",className:"sekyro-mono",children:R??e.sentToMasked}),re]}):i("emailOtp.sendDescription")}),me,w!==null?a(b,{tone:"danger",children:a("span",{children:w})}):null,d?o(C,{children:[o("div",{className:"sekyro-field",children:[a("label",{className:"sekyro-label",htmlFor:`${m}-code`,children:i("emailOtp.codeLabel")}),a(q,{id:`${m}-code`,value:_,invalid:se,onChange:t=>{t!==""&&oe(),T(t),t.length===6&&_.length!==6&&!n&&!e.attemptsExhausted&&$(t)}}),a("span",{className:`sekyro-help sekyro-otp-expiry${h?" is-danger":""}`,"aria-hidden":!h||void 0,children:h?i("emailOtp.expired"):i("emailOtp.expiresIn",{time:ve(S)})})]}),a("span",{className:"sekyro-visually-hidden",role:"status","aria-live":"polite",children:h?i("emailOtp.expired"):""}),o(N,{children:[a(k,{type:"submit",full:!0,disabled:n||_.length!==6,"aria-busy":n||void 0,children:i("emailOtp.verify")}),o("div",{className:"sekyro-resend-row",children:[a("button",{type:"button",className:"sekyro-link sekyro-resend",disabled:n||E>0,onClick:()=>D(!0),children:E>0?i("emailOtp.resendIn",{seconds:E}):i("emailOtp.resend")}),P?a("button",{type:"button",className:"sekyro-link sekyro-resend",disabled:n,onClick:()=>c(!0),"data-testid":"sekyro-otp-change",children:i("emailOtp.changeEmail")}):null]})]})]}):o(C,{children:[e.needsEmail?o("div",{className:"sekyro-field",children:[a("label",{className:"sekyro-label",htmlFor:`${m}-email`,children:i("emailOtp.emailLabel")}),a("input",{id:`${m}-email`,className:"sekyro-input",type:"email",dir:"ltr",inputMode:"email",autoComplete:"email",autoCapitalize:"none",spellCheck:!1,placeholder:i("emailOtp.emailPlaceholder"),value:x,"aria-describedby":`${m}-email-help`,onChange:t=>ie(t.target.value)}),a("span",{id:`${m}-email-help`,className:"sekyro-help",children:i("emailOtp.emailHelper")})]}):a("p",{className:"sekyro-text-muted",children:i("emailOtp.prefilledNotice")}),o(N,{children:[a(k,{type:"submit",full:!0,disabled:n,"aria-busy":n||void 0,children:i("emailOtp.send")}),g&&W?a("button",{type:"button",className:"sekyro-link sekyro-resend",disabled:n,onClick:()=>c(!1),"data-testid":"sekyro-otp-back-to-code",children:i("emailOtp.backToCode")}):null]})]})]})}l(Ae,"EmailOtpView");export{Ae as EmailOtpView};
2
+ import{a as F,b as q,c as J}from"./chunk-GUTF3SPK.js";import{a as U}from"./chunk-VRDPGOXM.js";import{d as B}from"./chunk-B4OAK5EF.js";import{b as Y,d as N,f as K,m as G,p as b,q as j}from"./chunk-RO2EITOC.js";import"./chunk-IAZ5UH2B.js";import{a as k}from"./chunk-6QYD5HOU.js";import{a as l}from"./chunk-2KED7D2Q.js";import{OtpInputError as pe}from"@sekyro/web";import{useEffect as ce,useId as ue,useRef as Oe,useState as p}from"react";var Q={"emailOtp.reason_otp_daily_cap_reached":"لا يمكننا إرسال رمز إلى بريدك الإلكتروني اليوم. اختر طريقة أخرى للتحقق إن كانت متاحة، أو حاول مرة أخرى لاحقًا.","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":"لا يمكنك طلب رموز أخرى. أدخل آخر رمز وصلك"};var O={"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.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 in a moment","emailOtp.reason_otp_rate_limited":"Too many codes requested. Wait a moment, then try again","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"};var X={"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.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 dans un instant","emailOtp.reason_otp_rate_limited":"Trop de codes demandés. Patientez un instant, puis réessayez","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"};import{Fragment as C,jsx as a,jsxs as o}from"react/jsx-runtime";var fe={en:O,fr:X,ar:Q,es:O,pt:O,de:O},Z=l((e,r,f)=>{if(e===void 0)return 0;let y=Date.parse(e)-r;return Number.isFinite(y)?Math.min(f,Math.max(0,Math.ceil(y/1e3))):0},"secondsUntil"),ye=600,_e=60,ve=l(e=>`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`,"mmss"),ee=new Set(["otp_expired","otp_send_failed","otp_rate_limited","otp_resend_limit","email_invalid","email_disposable","otp_daily_cap_reached"]);function Ae({step:e,i18n:r,className:f,defaultEmail:y="",onError:ae}){let i=l((t,s)=>B(r.strings[t]??fe[r.locale][t],s),"t"),[x,ie]=p(y),[_,T]=p(""),[n,z]=p(!1),[w,I]=p(null),[g,c]=p(!1),[R,te]=p(null),u=Oe(null),v=e.phase==="verify",d=v&&!g,V=J(v),m=ue(),[se,oe]=F(e.reason==="otp_mismatch",e.attemptsRemaining,()=>T("")),A=v?e.codeExpiresAt??"sent":null;ce(()=>{A!==null&&(c(!1),u.current!==null&&!ee.has(e.reason??"")&&te(u.current),u.current=null)},[A]);let L=l(async t=>{z(!0),I(null);try{await t()}catch(s){I(s instanceof pe&&s.field==="email"?i("emailOtp.emailInvalid"):r.t(U(s,r.strings))),ae?.(s)}finally{z(!1)}},"run"),D=l(t=>{let s=e.needsEmail?t?R:x.trim():null;u.current=s,L(async()=>{try{await e.send(s!==null?{email:s}:{})}catch(de){throw u.current=null,de}})},"send"),$=l(t=>{L(()=>e.verify(t))},"submitCode"),ne=l(t=>{t.preventDefault(),d?$(_):D(!1)},"onSubmit"),S=Z(e.codeExpiresAt,V,ye),E=Z(e.resendAvailableAt,V,_e),h=d&&e.codeExpiresAt!==void 0&&S===0,P=e.needsEmail&&!e.attemptsExhausted,W=v&&(e.codeExpiresAt===void 0||S>0),H=d&&P?()=>c(!0):g&&W?()=>c(!1):null;K(H===null?null:n?()=>{}:H);let[le,re]=i("emailOtp.sentTo").split("{email}"),M=e.context.simulation?.otpCode,me=e.reason==="otp_mismatch"?o(b,{tone:"danger",children:[a("span",{children:i("emailOtp.reason_otp_mismatch")}),a("span",{children:j(r,e.attemptsRemaining,e.attemptsExhausted)})]}):e.reason!==void 0&&ee.has(e.reason)?a(b,{tone:"warning",children:a("span",{children:i(`emailOtp.reason_${e.reason}`)})}):null;return o("form",{className:`sekyro-step sekyro-otp${f?` ${f}`:""}`,"aria-labelledby":m,onSubmit:ne,noValidate:!0,children:[a(Y,{id:m,title:i(d?"emailOtp.verifyTitle":"emailOtp.sendTitle"),lead:d&&M!==void 0?a(G,{template:r.t("sandbox.otpHint"),code:M}):d?o(C,{children:[le,a("bdi",{dir:"ltr",className:"sekyro-mono",children:R??e.sentToMasked}),re]}):i("emailOtp.sendDescription")}),me,w!==null?a(b,{tone:"danger",children:a("span",{children:w})}):null,d?o(C,{children:[o("div",{className:"sekyro-field",children:[a("label",{className:"sekyro-label",htmlFor:`${m}-code`,children:i("emailOtp.codeLabel")}),a(q,{id:`${m}-code`,value:_,invalid:se,onChange:t=>{t!==""&&oe(),T(t),t.length===6&&_.length!==6&&!n&&!e.attemptsExhausted&&$(t)}}),a("span",{className:`sekyro-help sekyro-otp-expiry${h?" is-danger":""}`,"aria-hidden":!h||void 0,children:h?i("emailOtp.expired"):i("emailOtp.expiresIn",{time:ve(S)})})]}),a("span",{className:"sekyro-visually-hidden",role:"status","aria-live":"polite",children:h?i("emailOtp.expired"):""}),o(N,{children:[a(k,{type:"submit",full:!0,disabled:n||_.length!==6,"aria-busy":n||void 0,children:i("emailOtp.verify")}),o("div",{className:"sekyro-resend-row",children:[a("button",{type:"button",className:"sekyro-link sekyro-resend",disabled:n||E>0,onClick:()=>D(!0),children:E>0?i("emailOtp.resendIn",{seconds:E}):i("emailOtp.resend")}),P?a("button",{type:"button",className:"sekyro-link sekyro-resend",disabled:n,onClick:()=>c(!0),"data-testid":"sekyro-otp-change",children:i("emailOtp.changeEmail")}):null]})]})]}):o(C,{children:[e.needsEmail?o("div",{className:"sekyro-field",children:[a("label",{className:"sekyro-label",htmlFor:`${m}-email`,children:i("emailOtp.emailLabel")}),a("input",{id:`${m}-email`,className:"sekyro-input",type:"email",dir:"ltr",inputMode:"email",autoComplete:"email",autoCapitalize:"none",spellCheck:!1,placeholder:i("emailOtp.emailPlaceholder"),value:x,"aria-describedby":`${m}-email-help`,onChange:t=>ie(t.target.value)}),a("span",{id:`${m}-email-help`,className:"sekyro-help",children:i("emailOtp.emailHelper")})]}):a("p",{className:"sekyro-text-muted",children:i("emailOtp.prefilledNotice")}),o(N,{children:[a(k,{type:"submit",full:!0,disabled:n,"aria-busy":n||void 0,children:i("emailOtp.send")}),g&&W?a("button",{type:"button",className:"sekyro-link sekyro-resend",disabled:n,onClick:()=>c(!1),"data-testid":"sekyro-otp-back-to-code",children:i("emailOtp.backToCode")}):null]})]})]})}l(Ae,"EmailOtpView");export{Ae as EmailOtpView};