@sekyro/elements 0.1.0-rc.29 → 0.1.0-rc.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +1 -1
- package/dist/cdn/chunks/{capture-session-doc-HGA7NCJI-PAHR5UED.js → capture-session-doc-NJKFAWHW-5ISANLWB.js} +1 -1
- package/dist/cdn/chunks/chunk-2HKOE6CN.js +25 -0
- package/dist/cdn/chunks/{chunk-S3DETOVP.js → chunk-4GDGJEJ6.js} +1 -1
- package/dist/cdn/chunks/{chunk-62ISTF5A.js → chunk-4H47RI64.js} +1 -1
- package/dist/cdn/chunks/{chunk-RPS5MI2Z.js → chunk-52X5ZO4S.js} +1 -1
- package/dist/cdn/chunks/{chunk-V2MJE7IH.js → chunk-5KTQLZKN.js} +1 -1
- package/dist/cdn/chunks/{chunk-OC5UPJL5.js → chunk-DEDYOTBZ.js} +1 -1
- package/dist/cdn/chunks/{chunk-F4XXN364.js → chunk-FOPIRIC2.js} +1 -1
- package/dist/cdn/chunks/{chunk-2CQQAB3Y.js → chunk-GORELL4J.js} +1 -1
- package/dist/cdn/chunks/{chunk-FYHEA2LI.js → chunk-GR6JK2ML.js} +1 -1
- package/dist/cdn/chunks/{chunk-TX7C4L3S.js → chunk-IAPQGT6L.js} +1 -1
- package/dist/cdn/chunks/{chunk-LVIQDNPD.js → chunk-IWRPGU4X.js} +1 -1
- package/dist/cdn/chunks/{chunk-6OAH57ZL.js → chunk-JB27ZDFD.js} +1 -1
- package/dist/cdn/chunks/{chunk-ACJWBI6P.js → chunk-JU4XNPJJ.js} +1 -1
- package/dist/cdn/chunks/{chunk-OP6NSXRA.js → chunk-KEO772AF.js} +1 -1
- package/dist/cdn/chunks/{chunk-RY47T7P4.js → chunk-KPUG7TMO.js} +2 -2
- package/dist/cdn/chunks/{chunk-45BISCD7.js → chunk-LNE2P3TV.js} +1 -1
- package/dist/cdn/chunks/chunk-RVL4N5KZ.js +1 -0
- package/dist/cdn/chunks/{chunk-IVTMNMUT.js → chunk-TBQUAM5Z.js} +1 -1
- package/dist/cdn/chunks/{chunk-I7ZZMP7U.js → chunk-W2IBE5PM.js} +1 -1
- package/dist/cdn/chunks/chunk-X6SULJS2.js +3 -0
- package/dist/cdn/chunks/{chunk-ZQRIQWIK.js → chunk-XZKF2U76.js} +1 -1
- package/dist/cdn/chunks/{create-document-capture-HHRMCAWL-7OHYRTAN.js → create-document-capture-3DB2Y3GP-SMSQUDH2.js} +1 -1
- package/dist/cdn/chunks/{document-capture-view-CFKS7K5J-YDK5DUQJ.js → document-capture-view-SCXJCJET-YFWA53XE.js} +1 -1
- package/dist/cdn/chunks/{eid-view-3G2EEGBI-C54IOJRT.js → eid-view-F75DTWPK-AE6YBJNY.js} +1 -1
- package/dist/cdn/chunks/{email-otp-view-PNB5UXJZ-FK3XWFBY.js → email-otp-view-T3NRXENJ-K6FY5XVU.js} +1 -1
- package/dist/cdn/chunks/flow-views-TVG4PFSE-2UL4L6TO.js +1 -0
- package/dist/cdn/chunks/{form-view-4HIBPKH7-QFAEVYU7.js → form-view-7NPB2AJE-TCOF3XPH.js} +1 -1
- package/dist/cdn/chunks/overlay-de-SYWE2LZE-AZG4RYMA.js +1 -0
- package/dist/cdn/chunks/overlay-es-D43QR7EF-ZODSTOP2.js +1 -0
- package/dist/cdn/chunks/overlay-pt-2YUWBZX7-UTMWWMN7.js +1 -0
- package/dist/cdn/chunks/plan-runner-432VPNQW-OBQFQCWK.js +1 -0
- package/dist/cdn/chunks/{portrait-capture-view-VGMA3DDR-TSACU3HP.js → portrait-capture-view-4HUAQUIA-G3YLZEHM.js} +1 -1
- package/dist/cdn/chunks/{portrait-review-view-UGBWX5MS-SJLTTTW5.js → portrait-review-view-VKRWP4HK-6NZPPDWZ.js} +1 -1
- package/dist/cdn/chunks/{proof-of-address-view-JOIFXMMC-3KTUEBGM.js → proof-of-address-view-BXQ4O2CU-RFNWZRUP.js} +1 -1
- package/dist/cdn/define.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/{chunk-DBP7O23Y.js → chunk-2XRKOCPR.js} +1 -1
- package/dist/chunk-3SFLN33V.js +1 -0
- package/dist/{chunk-4VZPYERM.js → chunk-4BQSPVSM.js} +2 -2
- package/dist/{chunk-YOH3GSLC.js → chunk-5MOE4EK4.js} +1 -1
- package/dist/{chunk-K2RX6MKD.js → chunk-7GCPE3LG.js} +1 -1
- package/dist/{chunk-3MS3OEXH.js → chunk-CX7T4ADY.js} +1 -1
- package/dist/{chunk-ZX3DKTKJ.js → chunk-D2KOFFZS.js} +1 -1
- package/dist/{chunk-VMIPS4GV.js → chunk-L7NFG55Y.js} +1 -1
- package/dist/{chunk-2X65ALSL.js → chunk-Q47EK3FL.js} +1 -1
- package/dist/{chunk-ONLUBR6R.js → chunk-QDHTMKLS.js} +1 -1
- package/dist/chunk-RSXZISUG.js +25 -0
- package/dist/{chunk-FCWRFBJ5.js → chunk-SCZ22CNO.js} +1 -1
- package/dist/{chunk-36B6FF7N.js → chunk-YHJQJMRS.js} +1 -1
- package/dist/{chunk-XL5ZL55K.js → chunk-ZG77WO25.js} +1 -1
- package/dist/define.cjs +5 -5
- package/dist/define.js +1 -1
- package/dist/{document-capture-view-CFKS7K5J-SAJ6PQWE.js → document-capture-view-SCXJCJET-WFZYQEU2.js} +1 -1
- package/dist/{eid-view-3G2EEGBI-LZVUJU6I.js → eid-view-F75DTWPK-QMS64USC.js} +1 -1
- package/dist/{email-otp-view-PNB5UXJZ-QTVVXYTH.js → email-otp-view-T3NRXENJ-WF5ZRHQS.js} +1 -1
- package/dist/flow-views-TVG4PFSE-OWVBXJ2R.js +1 -0
- package/dist/{form-view-4HIBPKH7-2HUEAOFF.js → form-view-7NPB2AJE-5GEBWQJ7.js} +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -1
- package/dist/overlay-de-SYWE2LZE-QIFDHKT6.js +1 -0
- package/dist/overlay-es-D43QR7EF-FZNYZGGS.js +1 -0
- package/dist/overlay-pt-2YUWBZX7-4AFNZWV2.js +1 -0
- package/dist/{portrait-capture-view-VGMA3DDR-LFQ6FAYZ.js → portrait-capture-view-4HUAQUIA-LYTXJIEX.js} +1 -1
- package/dist/{portrait-review-view-UGBWX5MS-UPYQ75SA.js → portrait-review-view-VKRWP4HK-4XFARABZ.js} +1 -1
- package/dist/{proof-of-address-view-JOIFXMMC-PQ4IIQV2.js → proof-of-address-view-BXQ4O2CU-455UQJ3O.js} +1 -1
- package/package.json +2 -2
- package/sbom.cdx.json +4 -4
- package/dist/cdn/chunks/chunk-LAEGXG2I.js +0 -3
- package/dist/cdn/chunks/chunk-LPLPMWHJ.js +0 -25
- package/dist/cdn/chunks/chunk-M36CK35T.js +0 -1
- package/dist/cdn/chunks/flow-views-6TVHTMMX-6QNRGOHC.js +0 -1
- package/dist/cdn/chunks/overlay-de-SHNL7LAI-G24N6OC4.js +0 -1
- package/dist/cdn/chunks/overlay-es-A6FGTLAH-EVEFVZOC.js +0 -1
- package/dist/cdn/chunks/overlay-pt-LTTU3QMC-AKB6BK52.js +0 -1
- package/dist/cdn/chunks/plan-runner-AUM4X5WF-XQRCBU72.js +0 -1
- package/dist/chunk-I2W7JAV3.js +0 -25
- package/dist/chunk-RKDMXMMR.js +0 -1
- package/dist/flow-views-6TVHTMMX-KNUYB6W7.js +0 -1
- package/dist/overlay-de-SHNL7LAI-UGRIY37I.js +0 -1
- package/dist/overlay-es-A6FGTLAH-4TTQSKC5.js +0 -1
- package/dist/overlay-pt-LTTU3QMC-3TI32HHQ.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Rr}from"./chunk-ZQRIQWIK.js";import{c as wt}from"./chunk-M36CK35T.js";import{b as br,d as Cr}from"./chunk-V2MJE7IH.js";import{b as Nr,c as _t}from"./chunk-FYHEA2LI.js";import{d as bt}from"./chunk-LAEGXG2I.js";import{a as gr,b as vr,c as kr,d as Me}from"./chunk-62ISTF5A.js";import{F as wr,K as Sr,L as xr,a as K,b as de,c as te,m as hr,n as Je,p as fr,q as et,r as mr,s as yr,t as Ct,u as oe,v as Ee,w as tt,y as _r}from"./chunk-LPLPMWHJ.js";import{c as cr,d as ur,e as dr,h as pr}from"./chunk-I7ZZMP7U.js";import{b as kt}from"./chunk-2CQQAB3Y.js";import{a as s}from"./chunk-5QL6W6FW.js";import{g as ir}from"./chunk-6MYG4HWP.js";import{a as l,c as U}from"./chunk-4FHWXBOB.js";var Mr=U(K(),1),y=U(de(),1),re=U(de(),1),ye=U(K(),1),$=U(de(),1),C=U(K(),1),m=U(K(),1),at=U(K(),1),fe=U(de(),1),Xr=U(K(),1),X=U(K(),1),ot=U(K(),1),we=U(de(),1),Se=U(de(),1),P=U(de(),1);var it=U(K(),1),pe=U(K(),1);var Q=U(K(),1);var E=U(K(),1),me=U(K(),1),Te=U(K(),1),Mt=U(de(),1),v=U(de(),1);function ce({className:e,children:t}){return(0,y.jsx)("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})}l(ce,"ne");s(ce,"Svg");var Et="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 Er(e){return(0,y.jsxs)(ce,{...e,children:[(0,y.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,y.jsx)("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"})]})}l(Er,"ln");s(Er,"SunIcon");function Lr(e){return(0,y.jsxs)(ce,{...e,children:[(0,y.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,y.jsx)("path",{d:"M9 10h.01M15 10h.01M8.8 14.6a4.2 4.2 0 0 0 6.4 0"})]})}l(Lr,"un");s(Lr,"FaceUncoveredIcon");function Ir(e){return(0,y.jsxs)(ce,{...e,children:[(0,y.jsx)("rect",{x:"7",y:"2.5",width:"10",height:"19",rx:"2"}),(0,y.jsx)("path",{d:"M10.5 18.5h3M2.5 9.5h2.5M19 9.5h2.5"}),(0,y.jsx)("circle",{cx:"12",cy:"9.5",r:"1.6"})]})}l(Ir,"dn");s(Ir,"PhoneEyeLevelIcon");function Ur(e){return(0,y.jsxs)(ce,{...e,children:[(0,y.jsx)("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"}),(0,y.jsx)("circle",{cx:"12",cy:"12",r:"2.8"})]})}l(Ur,"pn");s(Ur,"LookStraightIcon");function jr(e){return(0,y.jsxs)(ce,{...e,children:[(0,y.jsx)("path",{d:Et}),(0,y.jsx)("path",{d:"M9 13l2 2 4-4"})]})}l(jr,"fn");s(jr,"CameraCheckIcon");function Tr(e){return(0,y.jsxs)(ce,{...e,children:[(0,y.jsx)("path",{d:Et}),(0,y.jsx)("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"})]})}l(Tr,"mn");s(Tr,"CameraAskIcon");function Or(e){return(0,y.jsxs)(ce,{...e,children:[(0,y.jsx)("path",{d:Et}),(0,y.jsx)("path",{d:"M3 3l18 18"})]})}l(Or,"yn");s(Or,"CameraBlockedIcon");function nt({off:e,className:t}){return(0,y.jsxs)(ce,{className:t,children:[(0,y.jsx)("path",{d:"M4.5 9.5v5H8l4 3.5v-12L8 9.5H4.5Z"}),e?(0,y.jsx)("path",{d:"M4 4l16 16"}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("path",{d:"M15.5 9.7a3.6 3.6 0 0 1 0 4.6"}),(0,y.jsx)("path",{d:"M18 7.6a6.6 6.6 0 0 1 0 8.8"})]})]})}l(nt,"Ve");s(nt,"SpeakerIcon");function Pr(e){return(0,y.jsx)(ce,{...e,children:(0,y.jsx)("path",{d:"M5 12.5l4.5 4.5L19 7.5"})})}l(Pr,"gn");s(Pr,"CheckIcon");function Br(e){return(0,y.jsxs)(ce,{className:e.className??"sekyro-spinner",children:[(0,y.jsx)("circle",{cx:"12",cy:"12",r:"9",opacity:"0.25"}),(0,y.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9"})]})}l(Br,"hn");s(Br,"SpinnerIcon");var St=["light","uncover","eyeLevel","straight"],Un={light:{key:"capture.tips.light",icon:s(()=>(0,re.jsx)(Er,{}),"icon")},uncover:{key:"capture.tips.uncover",icon:s(()=>(0,re.jsx)(Lr,{}),"icon")},eyeLevel:{key:"capture.tips.eyeLevel",icon:s(()=>(0,re.jsx)(Ir,{}),"icon")},straight:{key:"capture.tips.straight",icon:s(()=>(0,re.jsx)(Ur,{}),"icon")}};function qr({tips:e}){let t=Me(),n=(0,Mr.useId)();return e.length===0?null:(0,re.jsxs)("section",{className:"sekyro-tips","aria-labelledby":n,"data-testid":"sekyro-tips",children:[(0,re.jsx)("p",{className:"sekyro-tips__title",id:n,children:t("capture.tips.title")}),(0,re.jsx)("ul",{className:"sekyro-tips__list",children:e.map(r=>{let a=typeof r=="string"?Un[r]:void 0,o=typeof r=="string"?r:r.id,c=a!==void 0?a.icon():typeof r=="string"?void 0:r.icon,d=a!==void 0?t(a.key):typeof r=="string"?r:r.text;return(0,re.jsxs)("li",{className:"sekyro-tips__item",children:[c!=null?(0,re.jsx)("span",{className:"sekyro-tips__icon","aria-hidden":"true",children:c}):null,(0,re.jsx)("span",{children:d})]},o)})})]})}l(qr,"Cn");s(qr,"TipList");var jn=220;function Vr({title:e,description:t,options:n,busy:r,error:a,focus:o,testId:c,look:d="cards",marked:S,onChoose:p}){let w=(0,ye.useId)(),N=Ct(),[j,R]=(0,ye.useState)(null),B=(0,ye.useRef)(null);(0,ye.useEffect)(()=>{a!==null&&R(null)},[a]),(0,ye.useEffect)(()=>()=>{B.current!==null&&clearTimeout(B.current)},[]);let q=s(A=>{r||j!==null||(R(A),B.current=setTimeout(()=>{B.current=null,R(null),p(A)},jn))},"choose");return(0,$.jsxs)("section",{className:"sekyro-stack sekyro-stack--4 sekyro-choice","aria-labelledby":w,"data-testid":c,children:[(0,$.jsxs)("div",{className:d==="cards"?"sekyro-heading":"sekyro-stack sekyro-stack--1",children:[(0,$.jsx)("h2",{id:w,ref:o?N:void 0,tabIndex:-1,className:"sekyro-text-body",children:e}),t!==void 0&&t!==""?(0,$.jsx)("p",{className:"sekyro-text-muted",children:t}):null]}),a!==null?(0,$.jsx)(oe,{tone:"danger",children:(0,$.jsx)("span",{children:a})}):null,d==="buttons"?(0,$.jsx)("div",{className:"sekyro-stack sekyro-stack--3",children:n.map((A,J)=>(0,$.jsx)(te,{kind:J===0?"primary":"ghost",full:!0,disabled:r,"aria-busy":r||void 0,onClick:l(()=>p(A.id),"onClick"),children:A.label},A.id))}):(0,$.jsx)("div",{className:"sekyro-choices",children:n.map(A=>(0,$.jsxs)("button",{type:"button",className:"sekyro-card","aria-pressed":(j??S)===A.id,"aria-busy":r||void 0,disabled:r||j!==null&&j!==A.id,onClick:l(()=>q(A.id),"onClick"),children:[A.glyph!==void 0?(0,$.jsx)("span",{className:"sekyro-card__tile",children:A.glyph}):null,(0,$.jsxs)("span",{className:"sekyro-card__body",children:[(0,$.jsx)("span",{className:"sekyro-card__title",children:A.label}),A.sub!==void 0?(0,$.jsx)("span",{className:"sekyro-card__sub",children:A.sub}):null]}),(0,$.jsx)("span",{className:"sekyro-radio","aria-hidden":"true"})]},A.id))})]})}l(Vr,"bn");s(Vr,"ChoiceScreen");var Dr=["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","capture.lookAtColours"];function st(e){return e!==null&&Dr.includes(e)}l(st,"he");s(st,"isVoiceKey");var Tn=s((e,t)=>Object.prototype.hasOwnProperty.call(e,t),"own");function je(e,t,n){let r;try{if(typeof e=="function")r=e(t,n);else{let a=e[n];r=a!=null&&Tn(a,t)?a[t]:null}}catch{return null}return typeof r=="string"&&r!==""?r:null}l(je,"Me");s(je,"resolveClip");var On="UklGRiQAAABXQVZFZm10IBAAAAABAAEAESsAACJWAAACABAAZGF0YQAAAAA=",Pn={ar:"ar-SA",fr:"fr-FR",en:"en-US",es:"es-ES",pt:"pt-BR",de:"de-DE"};function ie(){return typeof window<"u"&&"speechSynthesis"in window?window.speechSynthesis:null}l(ie,"re");s(ie,"synth");function Hr(){return ie()!==null&&typeof SpeechSynthesisUtterance=="function"}l(Hr,"Lr");s(Hr,"speechAvailable");function xt(e){return(e.split(/[-_]/)[0]??e).toLowerCase()}l(xt,"Sn");s(xt,"baseLang");function Lt(e,t){let n=s(a=>a.replace(/_/g,"-").toLowerCase(),"norm"),r=xt(t);return e.find(a=>n(a.lang)===n(t))??e.find(a=>xt(a.lang)===r)}l(Lt,"Mn");s(Lt,"pickVoice");function $r(e){if(!Hr())return!1;let t=[];try{t=ie()?.getVoices()??[]}catch{return!0}return t.length===0||Lt(t,e)!==void 0}l($r,"wn");s($r,"speechUsable");function Fr(e){let t=ie();return t===null||typeof t.addEventListener!="function"?()=>{}:(t.addEventListener("voiceschanged",e),()=>t.removeEventListener?.("voiceschanged",e))}l(Fr,"Ln");s(Fr,"subscribeVoices");function De(e){try{let t=typeof location<"u"?location.href:"http://localhost/",n=new URL(e,t);return`clip:${n.origin}${n.pathname}`}catch{return`clip:${e}`}}l(De,"Ke");s(De,"clipIdentity");function Nt(e){e.pause(),e.removeAttribute("src"),e.load()}l(Nt,"Rn");s(Nt,"release");function Gr(){let e=null,t=null,n=0,r=null,a=null,o=null,c=!1,d=null,S=[],p=new Map,w=s(()=>{S=ie()?.getVoices()??[]},"loadVoices"),N=!1,j=s(()=>{let h=ie();N||h===null||(N=!0,w(),h.addEventListener?.("voiceschanged",w))},"bindVoices"),R=s(()=>(e??(e=new Audio),e),"element"),B=s((h,x,_,k)=>{let u=ie();if(u!==null&&h!==""&&typeof SpeechSynthesisUtterance=="function"){j();let M=Lt(S,x);if(S.length===0||M!==void 0){u.cancel();let I=new SpeechSynthesisUtterance(h);I.lang=x,M!==void 0&&(I.voice=M),I.rate=.95,_!==void 0&&(I.onend=_),(_!==void 0||k!==void 0)&&(I.onerror=D=>{k!==void 0&&D.error==="not-allowed"?k():_?.()}),u.speak(I);return}}_?.()},"speak"),q=s(()=>{n+=1,r=null,a=o=null,e!==null&&(e.pause(),e.currentTime=0),ie()?.cancel()},"stop"),A=s(h=>{for(let x of h){let _=De(x);if(p.has(_))continue;let k=new Audio;k.preload="auto",k.src=x,p.set(_,k)}},"warmClips"),J=s((h,x,_)=>{let k={utterance:h,generation:x,end:_};d=k;let u=s(()=>x===n&&d===k,"live"),M=s(()=>{u()&&(a=k)},"block");if(ie()?.cancel(),h.url!==null){let I=R();I.pause(),I.muted=!1,I.src=h.url,I.currentTime=0,I.onended=_??null;let D=s(()=>{o===k&&(o=null)},"settled"),i=I.play();if(i===void 0)return;o=k,i.then(D,T=>{if(D(),!u())return;let O=T?.name;if(O!=="AbortError"){if(O==="NotAllowedError")return M();h.speech?B(h.text,h.lang,_,M):_?.()}});return}h.speech?B(h.text,h.lang,_,M):_?.()},"start");return{say(h){let x=h.url!==null?De(h.url):`tts:${h.lang}:${h.text}`;if(x===r)return;r=x,a=o=null,n+=1;let _=n,k=h.onEnd;J(h,_,k!==void 0?()=>{_===n&&k()}:void 0)},unlock({lang:h,speech:x,prefetch:_}){let k=a??(c?null:o);c=!0;let u=k!==null&&k.generation===n?k:null;a=o=null,u!==null&&J(u.utterance,u.generation,u.end);let M=R();if(t===null&&typeof Blob=="function"&&typeof URL.createObjectURL=="function"){let T=Uint8Array.from(atob(On),O=>O.charCodeAt(0));t=URL.createObjectURL(new Blob([T],{type:"audio/wav"}))}let I=M.paused===!1&&t!==null&&M.src!==t;t!==null&&!I&&(u===null||u.utterance.url===null)&&(M.muted=!0,M.onended=null,M.src=t,M.play()?.catch(()=>{}));let D=ie(),i=u!==null&&u.utterance.url===null;if(x&&!i&&D!==null&&typeof SpeechSynthesisUtterance=="function"){j();let T=new SpeechSynthesisUtterance(" ");T.volume=0,T.lang=h,D.speak(T)}A(_??[])},prefetch:A,stop:q,dispose(){q(),N&&ie()?.removeEventListener?.("voiceschanged",w),N=!1,t!==null&&URL.revokeObjectURL(t),t=null,e!==null&&Nt(e),e=null;for(let h of p.values())Nt(h);p.clear()}}}l(Gr,"_n");s(Gr,"createVoicePlayer");var Bn="sekyro.voiceGuidance";function Kr(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}}l(Kr,"xn");s(Kr,"readVoicePreference");function Zr(e,t){try{if(typeof window>"u")return;window.localStorage.setItem(e,t?"1":"0")}catch{}}l(Zr,"En");s(Zr,"writeVoicePreference");var Ve="capture.tips.summary",qn=typeof window<"u"?C.useLayoutEffect:C.useEffect,Vn=Object.freeze({});function rt(e,t){let n=new Set,r=[];for(let a of Dr){let o=a===Ve?null:je(e,a,t);o===null||n.has(De(o))||(n.add(De(o)),r.push(o))}return r}l(rt,"ht");s(rt,"resolvedClipUrls");function zr({locale:e,defaultClips:t,options:n}){let r=n===!1,a=r?{}:n??{},o=a.storageKey===void 0?Bn:a.storageKey,[c,d]=(0,C.useState)(a.defaultEnabled??!0),S=(0,C.useRef)(c),[p,w]=(0,C.useState)(!1),[N,j]=(0,C.useState)("none"),[R,B]=(0,C.useState)(!1),q=(0,C.useRef)(!1),[A,J]=(0,C.useState)(0),h=(0,C.useRef)(null),x=(0,C.useCallback)(()=>(h.current??(h.current=Gr()),h.current),[]),_=Pn[e],k=a.speechFallback,u=k===void 0||k===!0?!0:k===!1?!1:k.includes(e),M=a.clips??t??Vn,I=(0,C.useRef)(!1),D=(0,C.useRef)(M);qn(()=>{D.current=M,S.current=c}),(0,C.useEffect)(()=>{if(r||o===null)return;let L=Kr(o);L!==null&&(S.current=L,d(L))},[r,o]),(0,C.useEffect)(()=>{if(!(r||!u))return Fr(()=>J(L=>L+1))},[r,u]);let i=a.clips;(0,C.useEffect)(()=>{if(r)return;let L=u&&$r(_);w(rt(M,e).length>0||L),j(i!==void 0&&je(i,Ve,e)!==null?"partner":je(M,Ve,e)!==null||L?"default":"none")},[r,M,i,e,u,_,A]),(0,C.useEffect)(()=>{if(r||!c||!I.current)return;let L=rt(M,e);L.length>0&&x().prefetch(L)},[r,c,M,e,x]),(0,C.useEffect)(()=>()=>{h.current?.dispose(),h.current=null,I.current=!1},[]);let T=(0,C.useCallback)(L=>{r||(I.current=!0,x().unlock({lang:_,speech:u,...L?{prefetch:rt(D.current,e)}:{}}))},[r,x,_,u,e]),O=(0,C.useCallback)(()=>T(S.current),[T]),z=(0,C.useCallback)(()=>{q.current=!1,B(!1)},[]),H=(0,C.useCallback)(()=>{z(),h.current?.stop()},[z]),ge=(0,C.useCallback)(()=>{q.current&&H()},[H]),he=(0,C.useCallback)((L,xe)=>{if(r)return;if(q.current){H();return}let ve=x();ve.stop(),q.current=!0,B(!0);let V=xe?.clip===!1?null:je(D.current,Ve,e);ve.say({url:V,text:L,lang:_,speech:u,onEnd:z})},[r,H,x,e,_,u,z]),W=(0,C.useCallback)(L=>{r||(L?T(!0):H(),o!==null&&Zr(o,L),S.current=L,d(L))},[r,T,H,o]),Y=(0,C.useCallback)(()=>W(!S.current),[W]),ne=(0,C.useCallback)((L,xe)=>{if(r||!c)return;q.current&&z();let ve=je(D.current,L,e);x().say({url:ve,text:xe,lang:_,speech:u})},[r,c,e,x,_,u,z]);return(0,C.useMemo)(()=>({supported:!r&&p,enabled:!r&&c,setEnabled:W,toggle:Y,unlock:O,speakKey:ne,stop:H,summary:r?"none":N,summaryPlaying:R,toggleSummary:he,stopSummary:ge}),[r,p,c,W,Y,O,ne,H,N,R,he,ge])}l(zr,"vt");s(zr,"useVoiceGuidance");function Wr(e,t,n,r){let{speakKey:a,stop:o,enabled:c}=e,d=(0,C.useRef)(!1);(0,C.useEffect)(()=>{if(!r||!c){d.current&&o(),d.current=!1;return}d.current=!0,st(t)&&t!==Ve&&n!==""&&a(t,n)},[r,c,t,n,a,o])}l(Wr,"Ct");s(Wr,"useSpeakGuidance");function lt(e,t){let n=Yr(e);return n==="face"&&(t==="lighting"||e==="liveness_inconclusive")?"again":n}l(lt,"Pn");s(lt,"retryCoachingOf");function Yr(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"}}l(Yr,"Pr");s(Yr,"coachingOfReason");var He={face:{title:"capture.retryCoaching.title",tips:["capture.retryCoaching.light","capture.retryCoaching.eyeLevel","capture.retryCoaching.head"]},again:{title:"capture.retryTips.title",tips:["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 Qr({showCoaching:e,coaching:t="face",attemptsText:n,showRetake:r,onRetake:a}){let o=Me(),c=(0,at.useRef)(null);return(0,at.useEffect)(()=>{r&&c.current?.focus()},[r]),!e&&!r?null:(0,fe.jsxs)("div",{className:"sekyro-stack sekyro-stack--3","data-testid":"sekyro-captured-panel",children:[e?(0,fe.jsxs)("div",{className:"sekyro-stack sekyro-stack--1",children:[(0,fe.jsx)("p",{className:"sekyro-text-body",children:o(He[t].title)}),(0,fe.jsx)("ul",{className:"sekyro-coaching",children:He[t].tips.map(d=>(0,fe.jsx)("li",{children:o(d)},d))}),n!==null?(0,fe.jsx)("p",{className:"sekyro-text-muted","data-testid":"sekyro-attempts-remaining",children:n}):null]}):null,r?(0,fe.jsx)(te,{ref:c,className:"sekyro-btn--start",onClick:a,children:o("capture.recordAgain")}):null]})}l(Qr,"Tn");s(Qr,"CapturedPanel");function It(){try{return!1}catch{return!1}}l(It,"nt");s(It,"isDevBuild");var Dn=(0,Xr.createContext)(null);function Jr({state:e}){let t=Me(),[n,r]=(0,ot.useState)(!1);(0,ot.useEffect)(()=>{e!=="unknown"&&r(!0)},[e]);let a=e==="granted"?(0,we.jsx)(jr,{}):e==="denied"?(0,we.jsx)(Or,{}):(0,we.jsx)(Tr,{});return(0,we.jsxs)("div",{role:n?"status":void 0,className:`sekyro-permission sekyro-permission--${e}`,"data-testid":"sekyro-permission","data-state":e,children:[(0,we.jsx)("span",{className:"sekyro-permission__icon","aria-hidden":"true",children:a}),(0,we.jsx)("span",{children:t(`capture.permission.${e}`)})]})}l(Jr,"On");s(Jr,"PermissionRow");function en({voice:e}){let t=Me();if(!e.supported)return null;let n=e.enabled;return(0,Se.jsxs)("button",{type:"button",role:"switch","aria-checked":n,className:"sekyro-switch","data-testid":"sekyro-voice-switch",onClick:l(()=>e.toggle(),"onClick"),children:[(0,Se.jsxs)("span",{className:"sekyro-switch__label",children:[(0,Se.jsx)(nt,{off:!n}),t("capture.voiceGuidance")]}),(0,Se.jsx)("span",{className:"sekyro-switch__track","aria-hidden":"true",children:(0,Se.jsx)("span",{className:"sekyro-switch__thumb",children:n?(0,Se.jsx)(Pr,{className:"sekyro-switch__check"}):null})})]})}l(en,"Hn");s(en,"VoiceSwitch");function tn({assets:e,onRetryAssets:t,permission:n,captureMode:r="self",voice:a,tips:o,summary:c,startLabel:d,startDisabled:S,onStart:p}){let w=Me(),N=(0,X.useRef)(c?.stop);N.current=c?.stop,(0,X.useEffect)(()=>()=>N.current?.(),[]);let j=(0,X.useRef)(null),R=(0,X.useRef)(null),B=(0,X.useRef)(null),q=(0,X.useRef)(e),A=(0,X.useRef)(!1);(0,X.useEffect)(()=>{let u=q.current;if(q.current=e,u===e)return;let M=A.current;e!=="loading"&&(A.current=!1),rn(j.current)&&(e==="failed"?B.current?.focus():M&&R.current?.focus())},[e]);let J=(0,X.useCallback)(()=>{A.current=!0,t()},[t]),h=e==="loading",x=h||S,_=(0,X.useCallback)(()=>{x||(N.current?.(),p())},[x,p]),k;return e==="failed"?k=(0,P.jsxs)(oe,{tone:"danger",testId:"sekyro-assets-error",children:[(0,P.jsx)("p",{className:"sekyro-text-body",children:w("fcv2.err.models")}),(0,P.jsx)(te,{kind:"ghost",ref:B,className:"sekyro-btn--start",onClick:J,"data-testid":"sekyro-assets-retry",children:w("common.retry")})]}):k=(0,P.jsxs)("div",{className:"sekyro-stack sekyro-stack--1",children:[(0,P.jsx)(te,{ref:R,full:!0,"data-testid":"sekyro-start","aria-disabled":x?"true":void 0,"aria-busy":h?"true":void 0,onClick:_,children:h?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(Br,{}),w("capture.preparing.title")]}):d??w("capture.start")}),h?(0,P.jsx)("p",{className:"sekyro-text-muted",children:w("capture.preparing.hint")}):null]}),(0,P.jsxs)("div",{ref:j,className:"sekyro-stack sekyro-stack--4","data-testid":"sekyro-intro","data-assets":e,children:[r==="assisted"?(0,P.jsxs)("div",{className:"sekyro-stack sekyro-stack--1","data-testid":"sekyro-assisted-intro",children:[(0,P.jsx)("h2",{className:"sekyro-text-body",children:w("capture.assisted.title")}),(0,P.jsx)("p",{className:"sekyro-text-muted",children:w("capture.assisted.lead")})]}):null,o!==!1?(0,P.jsx)(qr,{tips:o}):null,c!==void 0?(0,P.jsxs)(te,{kind:"ghost",className:"sekyro-btn--start",onClick:c.toggle,"data-testid":"sekyro-tips-listen",children:[(0,P.jsx)(nt,{off:!1}),w(c.playing?"capture.tips.stop":"capture.tips.listen")]}):null,(0,P.jsx)(Jr,{state:n}),(0,P.jsx)(en,{voice:a}),(0,P.jsx)("p",{className:"sekyro-text-muted",children:w("capture.securityNote")}),k,(0,P.jsx)("p",{role:"status",className:"sekyro-visually-hidden","data-testid":"sekyro-intro-status",children:e==="loading"?w("capture.preparing.title"):e==="ready"?w("capture.ready"):""})]})}l(tn,"Fn");s(tn,"PreCaptureScreen");function rn(e){if(typeof document>"u")return!1;let t=document.activeElement;return t===null||t===document.body||e!==null&&e.contains(t)}l(rn,"Hr");s(rn,"focusIsOurs");function nn(){let[e,t]=(0,it.useState)({state:"unknown",settled:!1});return(0,it.useEffect)(()=>ir(n=>t({state:n,settled:!0})),[]),{permission:e.state,permissionSettled:e.settled}}l(nn,"Dn");s(nn,"useCameraStatus");function sn(e){return Ut(e,"mobileRequired")}l(sn,"qn");s(sn,"useMobileRequired");function an(e){return Ut(e,"returning").required}l(an,"jn");s(an,"useReturning");function Ut(e,t){let[n,r]=(0,pe.useState)({required:!1,settled:e===void 0});return(0,pe.useEffect)(()=>{let a=e?.[t];if(e===void 0||typeof a!="function"){r({required:!1,settled:!0});return}let o=!0;return r({required:!1,settled:!1}),Promise.resolve().then(()=>a.call(e)).then(c=>{o&&r({required:c===!0,settled:!0})},()=>{o&&r({required:!1,settled:!0})}),()=>{o=!1}},[e,t]),n}l(Ut,"Yn");s(Ut,"useFlag");function ln(e){let t=s(()=>e?.captureChoice??null,"initialChoice"),[n,r]=(0,pe.useState)(()=>({session:"self",choice:t(),settled:e===void 0}));(0,pe.useEffect)(()=>{let o=e?.captureMode,c=e?.captureChoice??null;if(e===void 0||typeof o!="function"){r({session:"self",choice:c,settled:!0});return}let d=!0;return r({session:"self",choice:c,settled:!1}),Promise.resolve().then(()=>o.call(e)).then(S=>{let p=e.captureChoice??null;d&&r({session:p!==null&&S===p?"choice":S==="assisted"||S==="choice"?S:"self",choice:p,settled:!0})},()=>{d&&r({session:"self",choice:null,settled:!0})}),()=>{d=!1}},[e]);let a=(0,pe.useCallback)(o=>{e?.chooseCaptureMode?.(o),r(c=>({...c,choice:o}))},[e]);return{mode:n.session==="choice"?n.choice??"self":n.session==="assisted"?"assisted":"self",session:n.session,choice:n.choice,settled:n.settled,choose:a}}l(ln,"$n");s(ln,"useCaptureMode");function on(e){let[t,n]=(0,pe.useState)(!1);return(0,pe.useEffect)(()=>{if(n(!1),e===void 0)return;let r=e.on("busy",()=>n(!0)),a=e.on("result",()=>n(!1));return()=>{r(),a()}},[e]),t}l(on,"zn");s(on,"useBusy");var Hn=s(()=>"idle","serverSnapshot");function Rt(e){return cr(e!==void 0?{assetBaseUrl:e}:{})}l(Rt,"Qn");s(Rt,"preload");function cn(e,t=!0){let n=(0,Q.useSyncExternalStore)((0,Q.useCallback)(p=>dr(p,e),[e]),()=>ur(e),Hn),[r,a]=(0,Q.useState)(null),o=(0,Q.useRef)(!1),c=(0,Q.useCallback)(()=>{Rt(e).then(p=>{o.current&&p==="idle"&&a({base:e})})},[e]);(0,Q.useEffect)(()=>(o.current=!0,c(),()=>{o.current=!1}),[c]);let d=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(n!=="idle"){d.current={base:e};return}!t||d.current===null||d.current.base!==e||(d.current=null,c())},[n,e,c,t]);let S=(0,Q.useCallback)(()=>{Rt(e)},[e]);return{gate:r!==null&&r.base===e&&n==="idle"||n==="ready"?"ready":n==="failed"?"failed":"loading",retry:S}}l(cn,"Jn");s(cn,"useLivenessAssets");var Ar={progress:0,hint:null,faceDetected:!1};function un(e){let{videoRef:t,assetBaseUrl:n}=e,r=(0,E.useRef)(e.verification).current,a=(0,E.useRef)(!1);e.verification!==r&&!a.current&&It()&&(a.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 o=(0,E.useRef)(null),[c,d]=(0,E.useState)("idle"),[S,p]=(0,E.useState)(Ar),[w,N]=(0,E.useState)(!1),[j,R]=(0,E.useState)(!1),[B,q]=(0,E.useState)(null),[A,J]=(0,E.useState)(!1),[h,x]=(0,E.useState)(null),[_,k]=(0,E.useState)(null),[u,M]=(0,E.useState)(null),[I,D]=(0,E.useState)(null),[i,T]=(0,E.useState)(null),[O,z]=(0,E.useState)(!1),H=(0,E.useRef)(null),ge=(0,E.useRef)("idle"),he=(0,E.useRef)(-1),[W,Y]=(0,E.useState)(0),ne=(0,E.useRef)(e);ne.current=e,(0,E.useEffect)(()=>{let ee=t.current;if(ee===null)return;let ue={video:ee,...n!==void 0?{assetBaseUrl:n}:{}},F=r!==void 0?r.liveness(ue):pr(ue);o.current=F;let Ne=s(()=>T(F.facingMode??null),"readFacing");Ne();let $e=[F.on("state",b=>{b==="mode_switch"?z(!0):b!=="starting"&&b!=="gating"&&z(!1),b==="starting"?(ge.current!=="starting"&&(he.current+=1,Y(Math.max(0,he.current))),k(null),M(null),p(Ar),R(!1),N(!1),q(null),x(null),H.current=null):b==="gating"&&ge.current==="recording"&&(R(!1),N(!1),q(null),H.current=null),ge.current=b,Ne(),d(b),ne.current.onStateChange?.(b)}),F.on("gate",b=>{let ke=H.current;H.current=b.progress,N(ke!==null&&b.progress<ke-.001&&b.progress>0&&b.progress<1),b.progress>=1&&R(!0),p(b)}),F.on("frozen",({previewDataUrl:b})=>q(b)),F.on("profile",({animations:b})=>J(b==="reduced")),F.on("ramp",({colour:b})=>x(b)),F.on("captured",b=>{k(b),D(null),ne.current.onCaptured?.(b)}),F.on("error",b=>{M(b);let ke=r?.reportCaptureIssue;ke!==void 0&&_t(Le=>ke.call(r,Le),Nr("liveness",b,Math.max(0,he.current))),ne.current.onError?.(b)}),r?.on("result",b=>{D(b),ne.current.onResult?.(b)})];return()=>{for(let b of $e)b?.();o.current=null,F.destroy()}},[r,t,n]);let L=(0,E.useCallback)(()=>{o.current?.start()},[]),xe=(0,E.useCallback)(()=>{o.current?.retry()},[]),ve=(0,E.useCallback)(async()=>{let ee=o.current;return ee===null||typeof ee.canSwitchCaptureMode!="function"?!1:await ee.canSwitchCaptureMode().catch(()=>!1)===!0},[]),V=(0,E.useCallback)(async ee=>{let ue=o.current;if(ue===null||typeof ue.setCaptureMode!="function")return!1;let F=await ue.setCaptureMode(ee).catch(()=>!1)===!0;return F&&T(ue.facingMode??null),F},[]);return{state:c,gate:S,draining:w,gateLocked:j,frozenPreview:B,reduceMotion:A,rampColour:h,artifacts:_,error:u,result:I,facingMode:i,start:L,retry:xe,canSwitchCaptureMode:ve,setCaptureMode:V,modeRestarted:O,attempt:W}}l(un,"er");s(un,"useLivenessHandle");var $n=new Set(["national_number"]);function At(e){if(e==null||!e.available||e.selected!==null)return null;let t=e.options.filter(n=>$n.has(n));return t.length>0?{...e,options:t}:null}l(At,"tr");s(At,"pending");function dn(e){let[t,n]=(0,me.useState)(null),[r,a]=(0,me.useState)(e===void 0),[o,c]=(0,me.useState)(!1),[d,S]=(0,me.useState)(!1);(0,me.useEffect)(()=>{if(n(null),e===void 0){a(!0);return}let N=!0,j=e.methodChoice;typeof j=="function"?(a(!1),Promise.resolve().then(()=>j.call(e)).then(B=>{N&&n(At(B))},()=>{}).finally(()=>{N&&a(!0)})):a(!0);let R=e.on("method",B=>n(At(B)));return()=>{N=!1,R()}},[e]);let p=(0,me.useCallback)(async N=>{if(e===void 0)return!1;c(!0),S(!1);try{return await e.selectMethod(N),n(null),!0}catch{return S(!0),!1}finally{c(!1)}},[e]),w=t!==null&&t.options.length===1?t.options[0]:null;return{choice:t,auto:w==="national_number"&&!d?w:null,settled:r,busy:o,failed:d,select:p}}l(dn,"nr");s(dn,"useMethodChoice");var Fn=["ar","fr","en"];function pn(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}}l(pn,"io");s(pn,"isClipUrl");function hn(e){let t=e.clips;if(typeof t!="object"||t===null)return null;let n={};for(let r of Fn){let a=t[r];if(!(typeof a!="object"||a===null))for(let[o,c]of Object.entries(a))!st(o)||!pn(c)||((n[r]??(n[r]={}))[o]=c)}return Object.keys(n).length>0?n:null}l(hn,"ao");s(hn,"toVoiceClipMap");function fn(e){let[t,n]=(0,Te.useState)(null);(0,Te.useEffect)(()=>{if(n(null),e===void 0)return;let a=!0,o=s(d=>{if(!a)return;let S=typeof d=="object"&&d!==null&&typeof d.setId=="string"?d:null;n(p=>p?.setId===S?.setId?p:S)},"take");try{typeof e.voiceClips=="function"&&Promise.resolve(e.voiceClips()).then(o,()=>o(null))}catch{o(null)}let c=e.on("view",d=>o(d.voice));return()=>{a=!1,c()}},[e]);let r=(0,Te.useMemo)(()=>t!==null?hn(t):null,[t]);return e===void 0?null:r}l(fn,"rr");s(fn,"useServerVoiceClips");function mn({voice:e}){let t=Me();return(0,Mt.jsx)(te,{kind:"chip","aria-pressed":e.enabled,"aria-label":t("capture.voiceGuidance"),"data-testid":"sekyro-voice-toggle",onClick:l(()=>e.toggle(),"onClick"),children:(0,Mt.jsx)(nt,{off:!e.enabled,className:"sekyro-icon"})})}l(mn,"sr");s(mn,"VoiceChip");var Gn=new Set(["abandoned","not_opened","cancelled","superseded"]),Kn=800,Zn="capture.lookAtColours";function yn(e){return e===void 0||e!==!1&&e.length===St.length&&St.every(t=>e.includes(t))}l(yn,"mo");s(yn,"isDefaultTips");function gn(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}l(gn,"yo");s(gn,"carriesActivation");function vn(e){return typeof e=="object"&&e!==null&&!(0,m.isValidElement)(e)&&"tone"in e&&"text"in e}l(vn,"go");s(vn,"isNoticeObject");var zn=new Set(["nni_unbound","id_number_unbound","method_required","mobile_required","portrait_required"]);function kn(e){return e==="starting"||e==="gating"||e==="recording"||e==="mode_switch"}l(kn,"vo");s(kn,"isCapturing");function bn(e){return e==="captured"||e==="uploading"||e==="checking"}l(bn,"Co");s(bn,"isPostCapture");function Wn({verification:e,locale:t,dir:n,strings:r,slots:a,autoStart:o=!1,notice:c,startDisabled:d=!1,startLabel:S,tips:p,tipsSummary:w,coach:N,voice:j,onGuidance:R,onCaptured:B,onResult:q,onError:A,onStateChange:J,assetBaseUrl:h,className:x}){let _=vr(t),k=(0,m.useMemo)(()=>gr(t,r),[t,r,_]),u=(0,m.useMemo)(()=>g=>k[g]??"",[k]),M=n??(t==="ar"?"rtl":"ltr"),I=(0,m.useRef)(null),D=(0,m.useContext)(Dn),i=un({verification:e,videoRef:I,assetBaseUrl:h,onCaptured:B,onResult:q,onError:A,onStateChange:J}),T=cn(h,i.state==="idle"&&i.error===null),O=dn(e),z=O.choice!==null,H=sn(e),ge=an(e),he=on(e),W=nn(),Y=ln(e),ne=Y.session==="choice",L=Y.mode==="assisted",xe=j!==!1&&j?.clips===void 0,ve=fn(xe?e:void 0),V=zr({locale:t,defaultClips:ve,options:j}),ee=L?"environment":"user",ue=Y.settled,F=(0,m.useRef)(null),Ne=(0,m.useRef)(!1),$e=(0,m.useRef)(V.unlock);$e.current=V.unlock,(0,m.useEffect)(()=>{let g=F.current;if(g===null)return;let le=["pointerup","touchend","click","keydown"],_e=s(()=>{for(let qe of le)g.removeEventListener(qe,Ae,!0)},"disarm");function Ae(qe){if(Ne.current){_e();return}gn(qe)&&(Ne.current=!0,_e(),$e.current())}l(Ae,"Re"),s(Ae,"onGesture");for(let qe of le)g.addEventListener(qe,Ae,{capture:!0,passive:!0});return _e},[]);let b=(0,m.useCallback)(()=>{Ne.current||(Ne.current=!0,V.unlock()),i.start()},[V.unlock,i.start]),ke=(0,m.useCallback)(()=>i.start(),[i.start]),Le=(0,m.useRef)(!1),Oe=i.state==="idle"&&i.error===null,Tt=!z&&!H.required&&(o===!0||o==="when-permitted"&&W.permission==="granted"),Ot=Tt&&O.settled&&H.settled&&ue,wn=o==="when-permitted"&&!W.permissionSettled&&!Le.current,Pt=Tt&&Oe&&!Le.current,ut=(wn||Pt||!ue)&&T.gate==="ready"?"loading":T.gate;(0,m.useEffect)(()=>{!Ot||!Oe||T.gate!=="ready"||Le.current||(Le.current=!0,ke())},[Ot,Oe,T.gate,ke]);let Sn=Oe&&!z&&!H.required&&!(Pt&&T.gate==="ready"),[Bt,qt]=(0,m.useState)(!1),{canSwitchCaptureMode:Vt,setCaptureMode:Dt}=i;(0,m.useEffect)(()=>{if(!Y.settled||!ne){qt(!1);return}let g=!0;return Vt().then(le=>{g&&qt(le)}),()=>{g=!1}},[Y.settled,ne,Vt]);let{choose:Ht}=Y,Ie=L?"self":"assisted",xn=(0,m.useCallback)(async()=>{await Dt(Ie)&&Ht(Ie)},[Dt,Ht,Ie]),$t=i.state!=="idle"&&i.facingMode!==null?i.facingMode:ee;(0,m.useEffect)(()=>{let g=I.current?.style;$t==="user"?g?.removeProperty("transform"):g&&(g.transform="none")},[$t]);let Fe=(0,m.useMemo)(()=>i.artifacts!==null&&typeof URL.createObjectURL=="function"?URL.createObjectURL(i.artifacts.keyframe):null,[i.artifacts]);(0,m.useEffect)(()=>{if(Fe!==null)return()=>URL.revokeObjectURL(Fe)},[Fe]);let Ft=i.frozenPreview??Fe,Ue=e!==void 0,Z=kn(i.state),be=bn(i.state),Ge=Z||be,se=i.result,Gt=i.state==="done"&&se!==null,Ke=Z&&i.rampColour!==null,dt=i.state==="recording"&&i.frozenPreview!==null&&!Ke,Ze=D!==null,Kt=Bt&&Z&&!dt?{to:Ie,label:u(Ie==="assisted"?"capture.modeSwitch.toAssisted":"capture.modeSwitch.toSelf"),description:u(Ie==="assisted"?"capture.modeSwitch.toAssistedLabel":"capture.modeSwitch.toSelfLabel"),onSwitch:s(()=>{xn()},"onSwitch")}:null,ze=i.modeRestarted&&Z?u("capture.modeSwitch.restarted"):null,Pe=be||dt,Zt=be?"checking":dt?"frozen":i.state==="recording"||Ke?"recording":i.gateLocked||i.gate.progress>=1?"locked":i.gate.faceDetected?"aligning":"seeking",We=Z?i.gate.hint:null,Ye=i.state==="starting"?"capture.preparing.title":We===null?null:We==="center"&&!i.gate.faceDetected?"fcv3.no_face":hr(We),[Nn,zt]=(0,m.useState)(null);(0,m.useEffect)(()=>{if(Ye!=="fcv3.no_face"){zt(Ye);return}if(!Z)return;let g=setTimeout(()=>zt(Ye),Kn);return()=>clearTimeout(g)},[Ye,Z]);let pt=Z&&!Ke&&typeof N=="string"&&N!=="",Wt=L&&Z?u("capture.assisted.stage"):null,Re=Z&&!pt?Ke?Zn:Nn:null,ht=pt?N:Re===null?"":u(Re);Wr(V,Re,ht,Z);let Yt=(0,m.useRef)(R);Yt.current=R,(0,m.useEffect)(()=>{if(st(Re))try{Yt.current?.(Re)}catch(g){console.error("[@sekyro/react] onGuidance threw:",g)}},[Re]);let Be=(0,m.useMemo)(()=>({supported:V.supported,enabled:V.enabled,setEnabled:V.setEnabled,toggle:V.toggle}),[V.supported,V.enabled,V.setEnabled,V.toggle]),ft=a?.voicePrompt,Qt=ft!==void 0,Xt=j===void 0,Jt=(0,m.useRef)(!1);(0,m.useEffect)(()=>{!Qt||!Xt||Jt.current||!It()||(Jt.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."))},[Qt,Xt]);let Rn=ft!==void 0?(g,le,_e)=>ft(g,le,_e,Be):V.supported?()=>(0,v.jsx)(mn,{voice:Be}):void 0,{summary:mt,summaryPlaying:er,toggleSummary:tr,stopSummary:rr}=V,Qe=w!==void 0&&w!=="",nr=Qe?w:u("capture.tips.summary"),sr=Qe?mt!=="none":mt==="partner"||mt==="default"&&yn(p),An=(0,m.useMemo)(()=>sr?{playing:er,toggle:s(()=>tr(nr,{clip:!Qe}),"toggle"),stop:rr}:void 0,[sr,er,tr,nr,rr,Qe]),Mn=(0,m.useMemo)(()=>({assets:ut,retryAssets:T.retry,permission:W.permission,permissionSettled:W.permissionSettled,captureMode:Y.mode,facing:ee,voice:Be}),[ut,T.retry,W.permission,W.permissionSettled,Y.mode,ee,Be]),En=vn(c)?(0,v.jsx)(oe,{tone:c.tone,testId:"sekyro-host-notice",children:(0,v.jsx)("span",{children:c.text})}):c??null,ae=se!==null&&se.status==="retry"?se:null,G=Gt&&se.status==="unavailable"&&!z&&se.reasonCode!=="portrait_required"?se:null,Ce=Gt&&(se.status==="verified"||se.status==="not_verified"||se.status==="review")?se:null,yt=s((g,le)=>{if(g===void 0)return null;if(g==="device_cooldown"){let Ae=mr(t,le);if(Ae!==null)return u(Ae.key).replace("{time}",Ae.time)}let _e=et(g);return _e===null?null:u(_e)},"reasonText"),gt=s(g=>{let le=g.retakeHint===void 0?null:Je(g.retakeHint);return le===null?yt(g.reasonCode):u(le)},"retryText"),ar=Ce===null?null:yt(Ce.reasonCode,Ce.retryAfter)??(Ce.status==="not_verified"&&Ce.reason!==void 0&&Gn.has(Ce.reason)?u("errors.session_expired"):null),Ln=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"&&i.artifacts?.degraded==="NO_RECORDER"),Xe=G?.reasonCode,lr=i.attempt;(0,m.useEffect)(()=>{G===null||Xe===void 0||e?.reportCaptureIssue===void 0||zn.has(Xe)||_t(g=>e.reportCaptureIssue?.(g),{check:"liveness",kind:"unavailable",phase:"upload",engineKind:Xe,attempt:Math.min(1e3,lr)})},[G,Xe,lr,e]);let or=Ct(),In=z&&O.auto===null&&!Z&&!be&&i.error===null,vt=(0,m.useCallback)(async g=>{await O.select(g)&&i.state==="done"&&i.retry()},[O.select,i.state,i.retry]);return(0,m.useEffect)(()=>{O.auto!==null&&!O.busy&&!Z&&!be&&vt(O.auto)},[O.auto,O.busy,Z,be,vt]),(0,v.jsx)(kr,{value:u,children:(0,v.jsxs)("div",{ref:F,className:x===void 0?"sekyro-capture":`sekyro-capture ${x}`,dir:M,lang:t,"data-testid":"sekyro-liveness-capture","data-state":i.state,children:[a?.header,ae!==null&>(ae)!==null&&!(Ze&&Ge)?(0,v.jsx)(oe,{tone:"warning",role:"status",testId:"sekyro-retry-notice",children:(0,v.jsx)("span",{children:gt(ae)})}):null,ze!==null&&!Ze?(0,v.jsx)(oe,{tone:"info",role:"status",testId:"sekyro-mode-switch-status",children:(0,v.jsx)("span",{children:ze})}):null,he&&be&&!Ze?(0,v.jsx)(oe,{tone:"info",role:"status",testId:"sekyro-busy-notice",children:(0,v.jsx)("span",{children:u("capture.busy")})}):null,H.required&&Oe?(0,v.jsx)(oe,{tone:"info",role:"status",testId:"sekyro-mobile-required",children:(0,v.jsx)("span",{children:u("reasons.mobile_required")})}):null,i.error!==null?a?.errorPanel!==void 0?a.errorPanel(i.error,i.retry):(0,v.jsxs)(oe,{tone:"danger",testId:"sekyro-error-notice",children:[(0,v.jsx)("span",{children:u(fr(i.error))}),i.error.retryable?(0,v.jsx)(te,{ref:or,kind:"ghost",className:"sekyro-btn--start",onClick:i.retry,children:u("common.retry")}):null]}):null,G!==null?(0,v.jsxs)(oe,{tone:"danger",testId:"sekyro-unavailable-notice",children:[(0,v.jsx)("span",{children:(G.reasonCode==="attestation"&&G.attestationError==="clock_wrong"?u("errors.device_clock"):yt(G.reasonCode))??u(G.reasonCode===void 0?"errors.session_expired":"errors.network_error")}),Ln?(0,v.jsx)(te,{ref:or,kind:"ghost",className:"sekyro-btn--start",onClick:i.retry,children:u(G.reasonCode==="attestation"?"common.retry":"capture.recordAgain")}):null]}):null,ar!==null&&Ce!==null?(0,v.jsx)(oe,{tone:Ce.status==="not_verified"?"danger":"info",testId:"sekyro-result-notice",children:(0,v.jsx)("span",{children:ar})}):null,(0,v.jsx)("div",{className:Ge?void 0:"sekyro-hidden","data-capture-live":Ge?"":void 0,children:Ze?D({videoRef:I,guidance:Pe&&Ue?u("capture.checking"):ht,coached:pt&&!(Pe&&Ue),note:Pe?Ue?u(he?"capture.busy":"capture.checkingHint"):null:ze??(ae!==null?gt(ae):Wt),settled:Pe&&Ue,progress:i.gate.progress,phase:Zt,still:Pe?Ft:null,live:Ge,modeSwitch:Kt,...Bt?{status:ze}:{},ramp:i.rampColour===null?null:{colour:i.rampColour}}):(0,v.jsx)(br,{videoRef:I,guidanceText:ht,guidanceHint:We,guidanceKey:Re,progress:i.gate.progress,phase:Zt,draining:i.draining,stillUrl:Ft,showChecking:Ue,operatorText:Wt,voicePrompt:Rn,overlay:l(g=>(0,v.jsxs)(v.Fragment,{children:[a?.stageOverlay?.(g),(0,v.jsx)(Cr,{colour:i.rampColour})]}),"overlay"),reduceMotion:i.reduceMotion,modeSwitch:Kt})}),In&&O.choice!==null?(0,v.jsx)(Vr,{title:u("method.title"),description:u("method.description"),options:O.choice.options.map(g=>({id:g,label:u(`method.${g}`)})),busy:O.busy,error:O.failed?u("errors.network_error"):null,focus:i.state==="done",testId:"sekyro-method",look:"buttons",onChoose:l(g=>{vt(g)},"onChoose")}):null,Sn?(0,v.jsxs)(v.Fragment,{children:[ge&&a?.header===void 0&&a?.intro===void 0?(0,v.jsxs)("div",{className:"sekyro-stack sekyro-stack--1",children:[(0,v.jsx)("h2",{className:"sekyro-text-body",children:u("returning.title")}),(0,v.jsx)("p",{className:"sekyro-text-muted",children:u("returning.description")})]}):null,En,a?.intro!==void 0?a.intro(b,Mn):(0,v.jsx)(tn,{assets:ut,onRetryAssets:T.retry,permission:W.permission,captureMode:Y.mode,voice:Be,tips:p??St,summary:An,startLabel:S,startDisabled:d,onStart:b})]}):null,(0,v.jsx)(Qr,{showCoaching:ae!==null,coaching:lt(ae?.reasonCode,ae?.retakeHint),attemptsText:ae?.attemptsRemaining!==void 0?yr(k,t,ae.attemptsRemaining):null,showRetake:ae!==null&&!Z&&!be||!Ue&&i.state==="captured",onRetake:i.retry}),a?.footer]})})}l(Wn,"Ei");s(Wn,"LivenessCapture");var jt=U(K(),1),ct=U(K(),1),f=U(de(),1);var Ss={document:"card",population_registry:"id",national_eid:"smartphone",phone_otp:"phone",email_otp:"email"};function Yn(e,t){switch(e.service){case"document":return t.t("method.document_photo");case"population_registry":return bt(e,t.locale)??t.t("method.nationalNumber");case"national_eid":return bt(e,t.locale)??t.t("method.nationalEid");default:return null}}l(Yn,"D");s(Yn,"identityLabel");function Qn(e,t){let[n,r]=(0,jt.useState)(!1),[a,o]=(0,jt.useState)(null);return{busy:n,error:a,run:s(c=>{r(!0),o(null),c().then(()=>r(!1),d=>{r(!1),o(e.t(Rr(d,e.strings))),t?.(d)})},"run")}}l(Qn,"W");s(Qn,"useChoiceAction");function Cn(){let e=`sekyro-face-light-${(0,ct.useId)().replace(/[^A-Za-z0-9_-]/g,"")}`;return(0,f.jsxs)("svg",{className:"sekyro-mark sekyro-mark--face",viewBox:"0 0 168 206","aria-hidden":"true",focusable:"false",children:[(0,f.jsx)("defs",{children:(0,f.jsx)("mask",{id:e,children:(0,f.jsx)("ellipse",{className:"sekyro-mark__arc",cx:"84",cy:"103",rx:"76",ry:"95",pathLength:"1",fill:"none",stroke:"#fff",strokeWidth:"16"})})}),(0,f.jsx)("ellipse",{cx:"84",cy:"103",rx:"64",ry:"83",fill:"none",className:"sekyro-mark__line"}),(0,f.jsx)("path",{className:"sekyro-mark__face",d:"M68 64v10M100 64v10M84 66v25q0 2-6 1M60 108q24 18 48 0"}),(0,f.jsx)("ellipse",{className:"sekyro-mark__ticks",cx:"84",cy:"103",rx:"76",ry:"95",pathLength:"56"}),(0,f.jsx)("ellipse",{className:"sekyro-mark__ticks sekyro-mark__ticks--light",cx:"84",cy:"103",rx:"76",ry:"95",pathLength:"56",mask:`url(#${e})`})]})}l(Cn,"B");s(Cn,"FaceMark");var Xn={glasses:"jGlasses",lighting:"light",faceCamera:"camera"};function Jn(e){if(!(e?.kind!=="liveness"||e.reason===void 0))return{reason:e.reason,...e.retakeHint!==void 0?{retakeHint:e.retakeHint}:{},attemptsRemaining:e.attemptsRemaining??0,attemptsExhausted:e.attemptsExhausted===!0}}l(Jn,"re");s(Jn,"faceIntroRetryOf");var es={"capture.retryFrontCamera.screenSide":"camera","capture.retryBackCamera.backSide":"camera","capture.retryUpright.vertical":"smartphone","capture.retryUpright.untilEnd":"smartphone","capture.retryRecording.cameraOn":"camera","capture.retryRecording.stay":"smartphone","capture.retryRecording.network":"smartphone","capture.retryDevice.screenRecording":"smartphone","capture.retryDevice.phone":"smartphone"};function ts({start:e,context:t,tips:n,tipsTitle:r,human:a=!1,returning:o=!1,notice:c,retry:d}){let S=wt(),{t:p}=S,w=d===void 0?"face":lt(d.reason,d.retakeHint),N=w==="face"?null:He[w].tips,j=(0,ct.useContext)(wr)?.busy===!0;return(0,f.jsxs)("section",{className:"sekyro-step",children:[(0,f.jsx)(Cn,{}),t.captureMode==="assisted"?(0,f.jsx)(tt,{title:p("capture.assisted.heading"),lead:p("capture.assisted.lead")}):o?(0,f.jsx)(tt,{title:p("returning.heading"),lead:p("returning.description")}):(0,f.jsx)(tt,{title:p(a?"native.face.humanIntroTitle":"native.face.introTitle"),lead:p(a?"native.face.humanIntroLead":"native.face.introLead")}),d!==void 0?(0,f.jsx)(_n,{retry:d,title:He[w].title}):null,r!==void 0&&N===null?(0,f.jsx)("p",{className:"sekyro-section-label",children:r}):null,(0,f.jsx)("ul",{className:"sekyro-tiprows",children:N!==null?N.map(R=>(0,f.jsxs)("li",{children:[(0,f.jsx)(Ee,{name:es[R]??"face"}),p(R)]},R)):n!==void 0?n.map(R=>(0,f.jsxs)("li",{children:[(0,f.jsx)(Ee,{name:Xn[R.id]??"face"}),R.text]},R.id)):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)("li",{children:[(0,f.jsx)(Ee,{name:"light"}),p("capture.tips.light")]}),(0,f.jsxs)("li",{children:[(0,f.jsx)(Ee,{name:"jGlasses"}),p("capture.tips.uncover")]}),(0,f.jsxs)("li",{children:[(0,f.jsx)(Ee,{name:"smartphone"}),p("capture.tips.eyeLevel")]})]})}),c??null,c!==void 0?null:t.assets==="failed"?(0,f.jsx)(te,{kind:"secondary",full:!0,onClick:t.retryAssets,children:p("common.retry")}):null,c!==void 0?null:(0,f.jsx)(_r,{children:(0,f.jsxs)(te,{full:!0,disabled:t.assets!=="ready"||j,"aria-busy":t.assets==="loading"||void 0,onClick:e,children:[(0,f.jsx)(Ee,{name:"camera"}),p("capture.start")]})})]})}l(ts,"ae");s(ts,"FaceIntro");var rs=new Set(["match_inconclusive","no_face_source","below_threshold"]);function _n({retry:e,title:t}){let n=wt(),r=e.retakeHint===void 0?null:Je(e.retakeHint),a=e.reason==="probe_not_from_liveness"?"capture.retrySamePerson.message":rs.has(e.reason)?"capture.retryMatch.message":et(e.reason);return(0,f.jsxs)(Sr,{tone:"warning",children:[r!==null?(0,f.jsx)("span",{children:n.t(r)}):a!==null?(0,f.jsx)("span",{children:n.t(a)}):null,r===null?(0,f.jsx)("span",{children:n.t(t)}):null,(0,f.jsx)("span",{children:xr(n,e.attemptsRemaining,e.attemptsExhausted)})]})}l(_n,"M");s(_n,"RetryNotice");function ns(e){return kt(e)}l(ns,"ce");s(ns,"isInAppBrowser");function ss(e,t){let n=t??(typeof navigator>"u"?"":String(navigator.userAgent??""));if(!/Android/i.test(n))return null;let r;try{r=new URL(e)}catch{return null}if(r.protocol!=="https:"&&r.protocol!=="http:")return null;let a=r.protocol.slice(0,-1);return`intent://${r.host}${r.pathname}${r.search}#Intent;scheme=${a};action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(e)};end`}l(ss,"pe");s(ss,"androidBrowserIntent");export{Vr as a,It as b,Dn as c,ln as d,Wn as e,Ss as f,Yn as g,Qn as h,Jn as i,ts as j,ns as k,ss as l};
|
|
1
|
+
import{a as Rr}from"./chunk-XZKF2U76.js";import{c as wt}from"./chunk-RVL4N5KZ.js";import{b as br,d as Cr}from"./chunk-5KTQLZKN.js";import{b as Nr,c as _t}from"./chunk-GR6JK2ML.js";import{d as bt}from"./chunk-X6SULJS2.js";import{a as gr,b as vr,c as kr,d as Me}from"./chunk-4H47RI64.js";import{F as wr,K as Sr,L as xr,a as K,b as de,c as te,m as hr,n as Je,p as fr,q as et,r as mr,s as yr,t as Ct,u as oe,v as Ee,w as tt,y as _r}from"./chunk-2HKOE6CN.js";import{c as cr,d as ur,e as dr,h as pr}from"./chunk-W2IBE5PM.js";import{b as kt}from"./chunk-GORELL4J.js";import{a as s}from"./chunk-5QL6W6FW.js";import{g as ir}from"./chunk-6MYG4HWP.js";import{a as l,c as U}from"./chunk-4FHWXBOB.js";var Mr=U(K(),1),y=U(de(),1),re=U(de(),1),ye=U(K(),1),$=U(de(),1),C=U(K(),1),m=U(K(),1),at=U(K(),1),fe=U(de(),1),Xr=U(K(),1),X=U(K(),1),ot=U(K(),1),we=U(de(),1),Se=U(de(),1),P=U(de(),1);var it=U(K(),1),pe=U(K(),1);var Q=U(K(),1);var E=U(K(),1),me=U(K(),1),Te=U(K(),1),Mt=U(de(),1),v=U(de(),1);function ce({className:e,children:t}){return(0,y.jsx)("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})}l(ce,"ne");s(ce,"Svg");var Et="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 Er(e){return(0,y.jsxs)(ce,{...e,children:[(0,y.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,y.jsx)("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"})]})}l(Er,"ln");s(Er,"SunIcon");function Lr(e){return(0,y.jsxs)(ce,{...e,children:[(0,y.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,y.jsx)("path",{d:"M9 10h.01M15 10h.01M8.8 14.6a4.2 4.2 0 0 0 6.4 0"})]})}l(Lr,"un");s(Lr,"FaceUncoveredIcon");function Ir(e){return(0,y.jsxs)(ce,{...e,children:[(0,y.jsx)("rect",{x:"7",y:"2.5",width:"10",height:"19",rx:"2"}),(0,y.jsx)("path",{d:"M10.5 18.5h3M2.5 9.5h2.5M19 9.5h2.5"}),(0,y.jsx)("circle",{cx:"12",cy:"9.5",r:"1.6"})]})}l(Ir,"dn");s(Ir,"PhoneEyeLevelIcon");function Ur(e){return(0,y.jsxs)(ce,{...e,children:[(0,y.jsx)("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"}),(0,y.jsx)("circle",{cx:"12",cy:"12",r:"2.8"})]})}l(Ur,"pn");s(Ur,"LookStraightIcon");function jr(e){return(0,y.jsxs)(ce,{...e,children:[(0,y.jsx)("path",{d:Et}),(0,y.jsx)("path",{d:"M9 13l2 2 4-4"})]})}l(jr,"fn");s(jr,"CameraCheckIcon");function Tr(e){return(0,y.jsxs)(ce,{...e,children:[(0,y.jsx)("path",{d:Et}),(0,y.jsx)("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"})]})}l(Tr,"mn");s(Tr,"CameraAskIcon");function Or(e){return(0,y.jsxs)(ce,{...e,children:[(0,y.jsx)("path",{d:Et}),(0,y.jsx)("path",{d:"M3 3l18 18"})]})}l(Or,"yn");s(Or,"CameraBlockedIcon");function nt({off:e,className:t}){return(0,y.jsxs)(ce,{className:t,children:[(0,y.jsx)("path",{d:"M4.5 9.5v5H8l4 3.5v-12L8 9.5H4.5Z"}),e?(0,y.jsx)("path",{d:"M4 4l16 16"}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("path",{d:"M15.5 9.7a3.6 3.6 0 0 1 0 4.6"}),(0,y.jsx)("path",{d:"M18 7.6a6.6 6.6 0 0 1 0 8.8"})]})]})}l(nt,"Ve");s(nt,"SpeakerIcon");function Pr(e){return(0,y.jsx)(ce,{...e,children:(0,y.jsx)("path",{d:"M5 12.5l4.5 4.5L19 7.5"})})}l(Pr,"gn");s(Pr,"CheckIcon");function Br(e){return(0,y.jsxs)(ce,{className:e.className??"sekyro-spinner",children:[(0,y.jsx)("circle",{cx:"12",cy:"12",r:"9",opacity:"0.25"}),(0,y.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9"})]})}l(Br,"hn");s(Br,"SpinnerIcon");var St=["light","uncover","eyeLevel","straight"],Un={light:{key:"capture.tips.light",icon:s(()=>(0,re.jsx)(Er,{}),"icon")},uncover:{key:"capture.tips.uncover",icon:s(()=>(0,re.jsx)(Lr,{}),"icon")},eyeLevel:{key:"capture.tips.eyeLevel",icon:s(()=>(0,re.jsx)(Ir,{}),"icon")},straight:{key:"capture.tips.straight",icon:s(()=>(0,re.jsx)(Ur,{}),"icon")}};function qr({tips:e}){let t=Me(),n=(0,Mr.useId)();return e.length===0?null:(0,re.jsxs)("section",{className:"sekyro-tips","aria-labelledby":n,"data-testid":"sekyro-tips",children:[(0,re.jsx)("p",{className:"sekyro-tips__title",id:n,children:t("capture.tips.title")}),(0,re.jsx)("ul",{className:"sekyro-tips__list",children:e.map(r=>{let a=typeof r=="string"?Un[r]:void 0,o=typeof r=="string"?r:r.id,c=a!==void 0?a.icon():typeof r=="string"?void 0:r.icon,d=a!==void 0?t(a.key):typeof r=="string"?r:r.text;return(0,re.jsxs)("li",{className:"sekyro-tips__item",children:[c!=null?(0,re.jsx)("span",{className:"sekyro-tips__icon","aria-hidden":"true",children:c}):null,(0,re.jsx)("span",{children:d})]},o)})})]})}l(qr,"Cn");s(qr,"TipList");var jn=220;function Vr({title:e,description:t,options:n,busy:r,error:a,focus:o,testId:c,look:d="cards",marked:S,onChoose:p}){let w=(0,ye.useId)(),N=Ct(),[j,R]=(0,ye.useState)(null),B=(0,ye.useRef)(null);(0,ye.useEffect)(()=>{a!==null&&R(null)},[a]),(0,ye.useEffect)(()=>()=>{B.current!==null&&clearTimeout(B.current)},[]);let q=s(A=>{r||j!==null||(R(A),B.current=setTimeout(()=>{B.current=null,R(null),p(A)},jn))},"choose");return(0,$.jsxs)("section",{className:"sekyro-stack sekyro-stack--4 sekyro-choice","aria-labelledby":w,"data-testid":c,children:[(0,$.jsxs)("div",{className:d==="cards"?"sekyro-heading":"sekyro-stack sekyro-stack--1",children:[(0,$.jsx)("h2",{id:w,ref:o?N:void 0,tabIndex:-1,className:"sekyro-text-body",children:e}),t!==void 0&&t!==""?(0,$.jsx)("p",{className:"sekyro-text-muted",children:t}):null]}),a!==null?(0,$.jsx)(oe,{tone:"danger",children:(0,$.jsx)("span",{children:a})}):null,d==="buttons"?(0,$.jsx)("div",{className:"sekyro-stack sekyro-stack--3",children:n.map((A,J)=>(0,$.jsx)(te,{kind:J===0?"primary":"ghost",full:!0,disabled:r,"aria-busy":r||void 0,onClick:l(()=>p(A.id),"onClick"),children:A.label},A.id))}):(0,$.jsx)("div",{className:"sekyro-choices",children:n.map(A=>(0,$.jsxs)("button",{type:"button",className:"sekyro-card","aria-pressed":(j??S)===A.id,"aria-busy":r||void 0,disabled:r||j!==null&&j!==A.id,onClick:l(()=>q(A.id),"onClick"),children:[A.glyph!==void 0?(0,$.jsx)("span",{className:"sekyro-card__tile",children:A.glyph}):null,(0,$.jsxs)("span",{className:"sekyro-card__body",children:[(0,$.jsx)("span",{className:"sekyro-card__title",children:A.label}),A.sub!==void 0?(0,$.jsx)("span",{className:"sekyro-card__sub",children:A.sub}):null]}),(0,$.jsx)("span",{className:"sekyro-radio","aria-hidden":"true"})]},A.id))})]})}l(Vr,"bn");s(Vr,"ChoiceScreen");var Dr=["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","capture.lookAtColours"];function st(e){return e!==null&&Dr.includes(e)}l(st,"he");s(st,"isVoiceKey");var Tn=s((e,t)=>Object.prototype.hasOwnProperty.call(e,t),"own");function je(e,t,n){let r;try{if(typeof e=="function")r=e(t,n);else{let a=e[n];r=a!=null&&Tn(a,t)?a[t]:null}}catch{return null}return typeof r=="string"&&r!==""?r:null}l(je,"Me");s(je,"resolveClip");var On="UklGRiQAAABXQVZFZm10IBAAAAABAAEAESsAACJWAAACABAAZGF0YQAAAAA=",Pn={ar:"ar-SA",fr:"fr-FR",en:"en-US",es:"es-ES",pt:"pt-BR",de:"de-DE"};function ie(){return typeof window<"u"&&"speechSynthesis"in window?window.speechSynthesis:null}l(ie,"re");s(ie,"synth");function Hr(){return ie()!==null&&typeof SpeechSynthesisUtterance=="function"}l(Hr,"Lr");s(Hr,"speechAvailable");function xt(e){return(e.split(/[-_]/)[0]??e).toLowerCase()}l(xt,"Sn");s(xt,"baseLang");function Lt(e,t){let n=s(a=>a.replace(/_/g,"-").toLowerCase(),"norm"),r=xt(t);return e.find(a=>n(a.lang)===n(t))??e.find(a=>xt(a.lang)===r)}l(Lt,"Mn");s(Lt,"pickVoice");function $r(e){if(!Hr())return!1;let t=[];try{t=ie()?.getVoices()??[]}catch{return!0}return t.length===0||Lt(t,e)!==void 0}l($r,"wn");s($r,"speechUsable");function Fr(e){let t=ie();return t===null||typeof t.addEventListener!="function"?()=>{}:(t.addEventListener("voiceschanged",e),()=>t.removeEventListener?.("voiceschanged",e))}l(Fr,"Ln");s(Fr,"subscribeVoices");function De(e){try{let t=typeof location<"u"?location.href:"http://localhost/",n=new URL(e,t);return`clip:${n.origin}${n.pathname}`}catch{return`clip:${e}`}}l(De,"Ke");s(De,"clipIdentity");function Nt(e){e.pause(),e.removeAttribute("src"),e.load()}l(Nt,"Rn");s(Nt,"release");function Gr(){let e=null,t=null,n=0,r=null,a=null,o=null,c=!1,d=null,S=[],p=new Map,w=s(()=>{S=ie()?.getVoices()??[]},"loadVoices"),N=!1,j=s(()=>{let h=ie();N||h===null||(N=!0,w(),h.addEventListener?.("voiceschanged",w))},"bindVoices"),R=s(()=>(e??(e=new Audio),e),"element"),B=s((h,x,_,k)=>{let u=ie();if(u!==null&&h!==""&&typeof SpeechSynthesisUtterance=="function"){j();let M=Lt(S,x);if(S.length===0||M!==void 0){u.cancel();let I=new SpeechSynthesisUtterance(h);I.lang=x,M!==void 0&&(I.voice=M),I.rate=.95,_!==void 0&&(I.onend=_),(_!==void 0||k!==void 0)&&(I.onerror=D=>{k!==void 0&&D.error==="not-allowed"?k():_?.()}),u.speak(I);return}}_?.()},"speak"),q=s(()=>{n+=1,r=null,a=o=null,e!==null&&(e.pause(),e.currentTime=0),ie()?.cancel()},"stop"),A=s(h=>{for(let x of h){let _=De(x);if(p.has(_))continue;let k=new Audio;k.preload="auto",k.src=x,p.set(_,k)}},"warmClips"),J=s((h,x,_)=>{let k={utterance:h,generation:x,end:_};d=k;let u=s(()=>x===n&&d===k,"live"),M=s(()=>{u()&&(a=k)},"block");if(ie()?.cancel(),h.url!==null){let I=R();I.pause(),I.muted=!1,I.src=h.url,I.currentTime=0,I.onended=_??null;let D=s(()=>{o===k&&(o=null)},"settled"),i=I.play();if(i===void 0)return;o=k,i.then(D,T=>{if(D(),!u())return;let O=T?.name;if(O!=="AbortError"){if(O==="NotAllowedError")return M();h.speech?B(h.text,h.lang,_,M):_?.()}});return}h.speech?B(h.text,h.lang,_,M):_?.()},"start");return{say(h){let x=h.url!==null?De(h.url):`tts:${h.lang}:${h.text}`;if(x===r)return;r=x,a=o=null,n+=1;let _=n,k=h.onEnd;J(h,_,k!==void 0?()=>{_===n&&k()}:void 0)},unlock({lang:h,speech:x,prefetch:_}){let k=a??(c?null:o);c=!0;let u=k!==null&&k.generation===n?k:null;a=o=null,u!==null&&J(u.utterance,u.generation,u.end);let M=R();if(t===null&&typeof Blob=="function"&&typeof URL.createObjectURL=="function"){let T=Uint8Array.from(atob(On),O=>O.charCodeAt(0));t=URL.createObjectURL(new Blob([T],{type:"audio/wav"}))}let I=M.paused===!1&&t!==null&&M.src!==t;t!==null&&!I&&(u===null||u.utterance.url===null)&&(M.muted=!0,M.onended=null,M.src=t,M.play()?.catch(()=>{}));let D=ie(),i=u!==null&&u.utterance.url===null;if(x&&!i&&D!==null&&typeof SpeechSynthesisUtterance=="function"){j();let T=new SpeechSynthesisUtterance(" ");T.volume=0,T.lang=h,D.speak(T)}A(_??[])},prefetch:A,stop:q,dispose(){q(),N&&ie()?.removeEventListener?.("voiceschanged",w),N=!1,t!==null&&URL.revokeObjectURL(t),t=null,e!==null&&Nt(e),e=null;for(let h of p.values())Nt(h);p.clear()}}}l(Gr,"_n");s(Gr,"createVoicePlayer");var Bn="sekyro.voiceGuidance";function Kr(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}}l(Kr,"xn");s(Kr,"readVoicePreference");function Zr(e,t){try{if(typeof window>"u")return;window.localStorage.setItem(e,t?"1":"0")}catch{}}l(Zr,"En");s(Zr,"writeVoicePreference");var Ve="capture.tips.summary",qn=typeof window<"u"?C.useLayoutEffect:C.useEffect,Vn=Object.freeze({});function rt(e,t){let n=new Set,r=[];for(let a of Dr){let o=a===Ve?null:je(e,a,t);o===null||n.has(De(o))||(n.add(De(o)),r.push(o))}return r}l(rt,"ht");s(rt,"resolvedClipUrls");function zr({locale:e,defaultClips:t,options:n}){let r=n===!1,a=r?{}:n??{},o=a.storageKey===void 0?Bn:a.storageKey,[c,d]=(0,C.useState)(a.defaultEnabled??!0),S=(0,C.useRef)(c),[p,w]=(0,C.useState)(!1),[N,j]=(0,C.useState)("none"),[R,B]=(0,C.useState)(!1),q=(0,C.useRef)(!1),[A,J]=(0,C.useState)(0),h=(0,C.useRef)(null),x=(0,C.useCallback)(()=>(h.current??(h.current=Gr()),h.current),[]),_=Pn[e],k=a.speechFallback,u=k===void 0||k===!0?!0:k===!1?!1:k.includes(e),M=a.clips??t??Vn,I=(0,C.useRef)(!1),D=(0,C.useRef)(M);qn(()=>{D.current=M,S.current=c}),(0,C.useEffect)(()=>{if(r||o===null)return;let L=Kr(o);L!==null&&(S.current=L,d(L))},[r,o]),(0,C.useEffect)(()=>{if(!(r||!u))return Fr(()=>J(L=>L+1))},[r,u]);let i=a.clips;(0,C.useEffect)(()=>{if(r)return;let L=u&&$r(_);w(rt(M,e).length>0||L),j(i!==void 0&&je(i,Ve,e)!==null?"partner":je(M,Ve,e)!==null||L?"default":"none")},[r,M,i,e,u,_,A]),(0,C.useEffect)(()=>{if(r||!c||!I.current)return;let L=rt(M,e);L.length>0&&x().prefetch(L)},[r,c,M,e,x]),(0,C.useEffect)(()=>()=>{h.current?.dispose(),h.current=null,I.current=!1},[]);let T=(0,C.useCallback)(L=>{r||(I.current=!0,x().unlock({lang:_,speech:u,...L?{prefetch:rt(D.current,e)}:{}}))},[r,x,_,u,e]),O=(0,C.useCallback)(()=>T(S.current),[T]),z=(0,C.useCallback)(()=>{q.current=!1,B(!1)},[]),H=(0,C.useCallback)(()=>{z(),h.current?.stop()},[z]),ge=(0,C.useCallback)(()=>{q.current&&H()},[H]),he=(0,C.useCallback)((L,xe)=>{if(r)return;if(q.current){H();return}let ve=x();ve.stop(),q.current=!0,B(!0);let V=xe?.clip===!1?null:je(D.current,Ve,e);ve.say({url:V,text:L,lang:_,speech:u,onEnd:z})},[r,H,x,e,_,u,z]),W=(0,C.useCallback)(L=>{r||(L?T(!0):H(),o!==null&&Zr(o,L),S.current=L,d(L))},[r,T,H,o]),Y=(0,C.useCallback)(()=>W(!S.current),[W]),ne=(0,C.useCallback)((L,xe)=>{if(r||!c)return;q.current&&z();let ve=je(D.current,L,e);x().say({url:ve,text:xe,lang:_,speech:u})},[r,c,e,x,_,u,z]);return(0,C.useMemo)(()=>({supported:!r&&p,enabled:!r&&c,setEnabled:W,toggle:Y,unlock:O,speakKey:ne,stop:H,summary:r?"none":N,summaryPlaying:R,toggleSummary:he,stopSummary:ge}),[r,p,c,W,Y,O,ne,H,N,R,he,ge])}l(zr,"vt");s(zr,"useVoiceGuidance");function Wr(e,t,n,r){let{speakKey:a,stop:o,enabled:c}=e,d=(0,C.useRef)(!1);(0,C.useEffect)(()=>{if(!r||!c){d.current&&o(),d.current=!1;return}d.current=!0,st(t)&&t!==Ve&&n!==""&&a(t,n)},[r,c,t,n,a,o])}l(Wr,"Ct");s(Wr,"useSpeakGuidance");function lt(e,t){let n=Yr(e);return n==="face"&&(t==="lighting"||e==="liveness_inconclusive")?"again":n}l(lt,"Pn");s(lt,"retryCoachingOf");function Yr(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"}}l(Yr,"Pr");s(Yr,"coachingOfReason");var He={face:{title:"capture.retryCoaching.title",tips:["capture.retryCoaching.light","capture.retryCoaching.eyeLevel","capture.retryCoaching.head"]},again:{title:"capture.retryTips.title",tips:["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 Qr({showCoaching:e,coaching:t="face",attemptsText:n,showRetake:r,onRetake:a}){let o=Me(),c=(0,at.useRef)(null);return(0,at.useEffect)(()=>{r&&c.current?.focus()},[r]),!e&&!r?null:(0,fe.jsxs)("div",{className:"sekyro-stack sekyro-stack--3","data-testid":"sekyro-captured-panel",children:[e?(0,fe.jsxs)("div",{className:"sekyro-stack sekyro-stack--1",children:[(0,fe.jsx)("p",{className:"sekyro-text-body",children:o(He[t].title)}),(0,fe.jsx)("ul",{className:"sekyro-coaching",children:He[t].tips.map(d=>(0,fe.jsx)("li",{children:o(d)},d))}),n!==null?(0,fe.jsx)("p",{className:"sekyro-text-muted","data-testid":"sekyro-attempts-remaining",children:n}):null]}):null,r?(0,fe.jsx)(te,{ref:c,className:"sekyro-btn--start",onClick:a,children:o("capture.recordAgain")}):null]})}l(Qr,"Tn");s(Qr,"CapturedPanel");function It(){try{return!1}catch{return!1}}l(It,"nt");s(It,"isDevBuild");var Dn=(0,Xr.createContext)(null);function Jr({state:e}){let t=Me(),[n,r]=(0,ot.useState)(!1);(0,ot.useEffect)(()=>{e!=="unknown"&&r(!0)},[e]);let a=e==="granted"?(0,we.jsx)(jr,{}):e==="denied"?(0,we.jsx)(Or,{}):(0,we.jsx)(Tr,{});return(0,we.jsxs)("div",{role:n?"status":void 0,className:`sekyro-permission sekyro-permission--${e}`,"data-testid":"sekyro-permission","data-state":e,children:[(0,we.jsx)("span",{className:"sekyro-permission__icon","aria-hidden":"true",children:a}),(0,we.jsx)("span",{children:t(`capture.permission.${e}`)})]})}l(Jr,"On");s(Jr,"PermissionRow");function en({voice:e}){let t=Me();if(!e.supported)return null;let n=e.enabled;return(0,Se.jsxs)("button",{type:"button",role:"switch","aria-checked":n,className:"sekyro-switch","data-testid":"sekyro-voice-switch",onClick:l(()=>e.toggle(),"onClick"),children:[(0,Se.jsxs)("span",{className:"sekyro-switch__label",children:[(0,Se.jsx)(nt,{off:!n}),t("capture.voiceGuidance")]}),(0,Se.jsx)("span",{className:"sekyro-switch__track","aria-hidden":"true",children:(0,Se.jsx)("span",{className:"sekyro-switch__thumb",children:n?(0,Se.jsx)(Pr,{className:"sekyro-switch__check"}):null})})]})}l(en,"Hn");s(en,"VoiceSwitch");function tn({assets:e,onRetryAssets:t,permission:n,captureMode:r="self",voice:a,tips:o,summary:c,startLabel:d,startDisabled:S,onStart:p}){let w=Me(),N=(0,X.useRef)(c?.stop);N.current=c?.stop,(0,X.useEffect)(()=>()=>N.current?.(),[]);let j=(0,X.useRef)(null),R=(0,X.useRef)(null),B=(0,X.useRef)(null),q=(0,X.useRef)(e),A=(0,X.useRef)(!1);(0,X.useEffect)(()=>{let u=q.current;if(q.current=e,u===e)return;let M=A.current;e!=="loading"&&(A.current=!1),rn(j.current)&&(e==="failed"?B.current?.focus():M&&R.current?.focus())},[e]);let J=(0,X.useCallback)(()=>{A.current=!0,t()},[t]),h=e==="loading",x=h||S,_=(0,X.useCallback)(()=>{x||(N.current?.(),p())},[x,p]),k;return e==="failed"?k=(0,P.jsxs)(oe,{tone:"danger",testId:"sekyro-assets-error",children:[(0,P.jsx)("p",{className:"sekyro-text-body",children:w("fcv2.err.models")}),(0,P.jsx)(te,{kind:"ghost",ref:B,className:"sekyro-btn--start",onClick:J,"data-testid":"sekyro-assets-retry",children:w("common.retry")})]}):k=(0,P.jsxs)("div",{className:"sekyro-stack sekyro-stack--1",children:[(0,P.jsx)(te,{ref:R,full:!0,"data-testid":"sekyro-start","aria-disabled":x?"true":void 0,"aria-busy":h?"true":void 0,onClick:_,children:h?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(Br,{}),w("capture.preparing.title")]}):d??w("capture.start")}),h?(0,P.jsx)("p",{className:"sekyro-text-muted",children:w("capture.preparing.hint")}):null]}),(0,P.jsxs)("div",{ref:j,className:"sekyro-stack sekyro-stack--4","data-testid":"sekyro-intro","data-assets":e,children:[r==="assisted"?(0,P.jsxs)("div",{className:"sekyro-stack sekyro-stack--1","data-testid":"sekyro-assisted-intro",children:[(0,P.jsx)("h2",{className:"sekyro-text-body",children:w("capture.assisted.title")}),(0,P.jsx)("p",{className:"sekyro-text-muted",children:w("capture.assisted.lead")})]}):null,o!==!1?(0,P.jsx)(qr,{tips:o}):null,c!==void 0?(0,P.jsxs)(te,{kind:"ghost",className:"sekyro-btn--start",onClick:c.toggle,"data-testid":"sekyro-tips-listen",children:[(0,P.jsx)(nt,{off:!1}),w(c.playing?"capture.tips.stop":"capture.tips.listen")]}):null,(0,P.jsx)(Jr,{state:n}),(0,P.jsx)(en,{voice:a}),(0,P.jsx)("p",{className:"sekyro-text-muted",children:w("capture.securityNote")}),k,(0,P.jsx)("p",{role:"status",className:"sekyro-visually-hidden","data-testid":"sekyro-intro-status",children:e==="loading"?w("capture.preparing.title"):e==="ready"?w("capture.ready"):""})]})}l(tn,"Fn");s(tn,"PreCaptureScreen");function rn(e){if(typeof document>"u")return!1;let t=document.activeElement;return t===null||t===document.body||e!==null&&e.contains(t)}l(rn,"Hr");s(rn,"focusIsOurs");function nn(){let[e,t]=(0,it.useState)({state:"unknown",settled:!1});return(0,it.useEffect)(()=>ir(n=>t({state:n,settled:!0})),[]),{permission:e.state,permissionSettled:e.settled}}l(nn,"Dn");s(nn,"useCameraStatus");function sn(e){return Ut(e,"mobileRequired")}l(sn,"qn");s(sn,"useMobileRequired");function an(e){return Ut(e,"returning").required}l(an,"jn");s(an,"useReturning");function Ut(e,t){let[n,r]=(0,pe.useState)({required:!1,settled:e===void 0});return(0,pe.useEffect)(()=>{let a=e?.[t];if(e===void 0||typeof a!="function"){r({required:!1,settled:!0});return}let o=!0;return r({required:!1,settled:!1}),Promise.resolve().then(()=>a.call(e)).then(c=>{o&&r({required:c===!0,settled:!0})},()=>{o&&r({required:!1,settled:!0})}),()=>{o=!1}},[e,t]),n}l(Ut,"Yn");s(Ut,"useFlag");function ln(e){let t=s(()=>e?.captureChoice??null,"initialChoice"),[n,r]=(0,pe.useState)(()=>({session:"self",choice:t(),settled:e===void 0}));(0,pe.useEffect)(()=>{let o=e?.captureMode,c=e?.captureChoice??null;if(e===void 0||typeof o!="function"){r({session:"self",choice:c,settled:!0});return}let d=!0;return r({session:"self",choice:c,settled:!1}),Promise.resolve().then(()=>o.call(e)).then(S=>{let p=e.captureChoice??null;d&&r({session:p!==null&&S===p?"choice":S==="assisted"||S==="choice"?S:"self",choice:p,settled:!0})},()=>{d&&r({session:"self",choice:null,settled:!0})}),()=>{d=!1}},[e]);let a=(0,pe.useCallback)(o=>{e?.chooseCaptureMode?.(o),r(c=>({...c,choice:o}))},[e]);return{mode:n.session==="choice"?n.choice??"self":n.session==="assisted"?"assisted":"self",session:n.session,choice:n.choice,settled:n.settled,choose:a}}l(ln,"$n");s(ln,"useCaptureMode");function on(e){let[t,n]=(0,pe.useState)(!1);return(0,pe.useEffect)(()=>{if(n(!1),e===void 0)return;let r=e.on("busy",()=>n(!0)),a=e.on("result",()=>n(!1));return()=>{r(),a()}},[e]),t}l(on,"zn");s(on,"useBusy");var Hn=s(()=>"idle","serverSnapshot");function Rt(e){return cr(e!==void 0?{assetBaseUrl:e}:{})}l(Rt,"Qn");s(Rt,"preload");function cn(e,t=!0){let n=(0,Q.useSyncExternalStore)((0,Q.useCallback)(p=>dr(p,e),[e]),()=>ur(e),Hn),[r,a]=(0,Q.useState)(null),o=(0,Q.useRef)(!1),c=(0,Q.useCallback)(()=>{Rt(e).then(p=>{o.current&&p==="idle"&&a({base:e})})},[e]);(0,Q.useEffect)(()=>(o.current=!0,c(),()=>{o.current=!1}),[c]);let d=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(n!=="idle"){d.current={base:e};return}!t||d.current===null||d.current.base!==e||(d.current=null,c())},[n,e,c,t]);let S=(0,Q.useCallback)(()=>{Rt(e)},[e]);return{gate:r!==null&&r.base===e&&n==="idle"||n==="ready"?"ready":n==="failed"?"failed":"loading",retry:S}}l(cn,"Jn");s(cn,"useLivenessAssets");var Ar={progress:0,hint:null,faceDetected:!1};function un(e){let{videoRef:t,assetBaseUrl:n}=e,r=(0,E.useRef)(e.verification).current,a=(0,E.useRef)(!1);e.verification!==r&&!a.current&&It()&&(a.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 o=(0,E.useRef)(null),[c,d]=(0,E.useState)("idle"),[S,p]=(0,E.useState)(Ar),[w,N]=(0,E.useState)(!1),[j,R]=(0,E.useState)(!1),[B,q]=(0,E.useState)(null),[A,J]=(0,E.useState)(!1),[h,x]=(0,E.useState)(null),[_,k]=(0,E.useState)(null),[u,M]=(0,E.useState)(null),[I,D]=(0,E.useState)(null),[i,T]=(0,E.useState)(null),[O,z]=(0,E.useState)(!1),H=(0,E.useRef)(null),ge=(0,E.useRef)("idle"),he=(0,E.useRef)(-1),[W,Y]=(0,E.useState)(0),ne=(0,E.useRef)(e);ne.current=e,(0,E.useEffect)(()=>{let ee=t.current;if(ee===null)return;let ue={video:ee,...n!==void 0?{assetBaseUrl:n}:{}},F=r!==void 0?r.liveness(ue):pr(ue);o.current=F;let Ne=s(()=>T(F.facingMode??null),"readFacing");Ne();let $e=[F.on("state",b=>{b==="mode_switch"?z(!0):b!=="starting"&&b!=="gating"&&z(!1),b==="starting"?(ge.current!=="starting"&&(he.current+=1,Y(Math.max(0,he.current))),k(null),M(null),p(Ar),R(!1),N(!1),q(null),x(null),H.current=null):b==="gating"&&ge.current==="recording"&&(R(!1),N(!1),q(null),H.current=null),ge.current=b,Ne(),d(b),ne.current.onStateChange?.(b)}),F.on("gate",b=>{let ke=H.current;H.current=b.progress,N(ke!==null&&b.progress<ke-.001&&b.progress>0&&b.progress<1),b.progress>=1&&R(!0),p(b)}),F.on("frozen",({previewDataUrl:b})=>q(b)),F.on("profile",({animations:b})=>J(b==="reduced")),F.on("ramp",({colour:b})=>x(b)),F.on("captured",b=>{k(b),D(null),ne.current.onCaptured?.(b)}),F.on("error",b=>{M(b);let ke=r?.reportCaptureIssue;ke!==void 0&&_t(Le=>ke.call(r,Le),Nr("liveness",b,Math.max(0,he.current))),ne.current.onError?.(b)}),r?.on("result",b=>{D(b),ne.current.onResult?.(b)})];return()=>{for(let b of $e)b?.();o.current=null,F.destroy()}},[r,t,n]);let L=(0,E.useCallback)(()=>{o.current?.start()},[]),xe=(0,E.useCallback)(()=>{o.current?.retry()},[]),ve=(0,E.useCallback)(async()=>{let ee=o.current;return ee===null||typeof ee.canSwitchCaptureMode!="function"?!1:await ee.canSwitchCaptureMode().catch(()=>!1)===!0},[]),V=(0,E.useCallback)(async ee=>{let ue=o.current;if(ue===null||typeof ue.setCaptureMode!="function")return!1;let F=await ue.setCaptureMode(ee).catch(()=>!1)===!0;return F&&T(ue.facingMode??null),F},[]);return{state:c,gate:S,draining:w,gateLocked:j,frozenPreview:B,reduceMotion:A,rampColour:h,artifacts:_,error:u,result:I,facingMode:i,start:L,retry:xe,canSwitchCaptureMode:ve,setCaptureMode:V,modeRestarted:O,attempt:W}}l(un,"er");s(un,"useLivenessHandle");var $n=new Set(["national_number"]);function At(e){if(e==null||!e.available||e.selected!==null)return null;let t=e.options.filter(n=>$n.has(n));return t.length>0?{...e,options:t}:null}l(At,"tr");s(At,"pending");function dn(e){let[t,n]=(0,me.useState)(null),[r,a]=(0,me.useState)(e===void 0),[o,c]=(0,me.useState)(!1),[d,S]=(0,me.useState)(!1);(0,me.useEffect)(()=>{if(n(null),e===void 0){a(!0);return}let N=!0,j=e.methodChoice;typeof j=="function"?(a(!1),Promise.resolve().then(()=>j.call(e)).then(B=>{N&&n(At(B))},()=>{}).finally(()=>{N&&a(!0)})):a(!0);let R=e.on("method",B=>n(At(B)));return()=>{N=!1,R()}},[e]);let p=(0,me.useCallback)(async N=>{if(e===void 0)return!1;c(!0),S(!1);try{return await e.selectMethod(N),n(null),!0}catch{return S(!0),!1}finally{c(!1)}},[e]),w=t!==null&&t.options.length===1?t.options[0]:null;return{choice:t,auto:w==="national_number"&&!d?w:null,settled:r,busy:o,failed:d,select:p}}l(dn,"nr");s(dn,"useMethodChoice");var Fn=["ar","fr","en"];function pn(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}}l(pn,"io");s(pn,"isClipUrl");function hn(e){let t=e.clips;if(typeof t!="object"||t===null)return null;let n={};for(let r of Fn){let a=t[r];if(!(typeof a!="object"||a===null))for(let[o,c]of Object.entries(a))!st(o)||!pn(c)||((n[r]??(n[r]={}))[o]=c)}return Object.keys(n).length>0?n:null}l(hn,"ao");s(hn,"toVoiceClipMap");function fn(e){let[t,n]=(0,Te.useState)(null);(0,Te.useEffect)(()=>{if(n(null),e===void 0)return;let a=!0,o=s(d=>{if(!a)return;let S=typeof d=="object"&&d!==null&&typeof d.setId=="string"?d:null;n(p=>p?.setId===S?.setId?p:S)},"take");try{typeof e.voiceClips=="function"&&Promise.resolve(e.voiceClips()).then(o,()=>o(null))}catch{o(null)}let c=e.on("view",d=>o(d.voice));return()=>{a=!1,c()}},[e]);let r=(0,Te.useMemo)(()=>t!==null?hn(t):null,[t]);return e===void 0?null:r}l(fn,"rr");s(fn,"useServerVoiceClips");function mn({voice:e}){let t=Me();return(0,Mt.jsx)(te,{kind:"chip","aria-pressed":e.enabled,"aria-label":t("capture.voiceGuidance"),"data-testid":"sekyro-voice-toggle",onClick:l(()=>e.toggle(),"onClick"),children:(0,Mt.jsx)(nt,{off:!e.enabled,className:"sekyro-icon"})})}l(mn,"sr");s(mn,"VoiceChip");var Gn=new Set(["abandoned","not_opened","cancelled","superseded"]),Kn=800,Zn="capture.lookAtColours";function yn(e){return e===void 0||e!==!1&&e.length===St.length&&St.every(t=>e.includes(t))}l(yn,"mo");s(yn,"isDefaultTips");function gn(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}l(gn,"yo");s(gn,"carriesActivation");function vn(e){return typeof e=="object"&&e!==null&&!(0,m.isValidElement)(e)&&"tone"in e&&"text"in e}l(vn,"go");s(vn,"isNoticeObject");var zn=new Set(["nni_unbound","id_number_unbound","method_required","mobile_required","portrait_required"]);function kn(e){return e==="starting"||e==="gating"||e==="recording"||e==="mode_switch"}l(kn,"vo");s(kn,"isCapturing");function bn(e){return e==="captured"||e==="uploading"||e==="checking"}l(bn,"Co");s(bn,"isPostCapture");function Wn({verification:e,locale:t,dir:n,strings:r,slots:a,autoStart:o=!1,notice:c,startDisabled:d=!1,startLabel:S,tips:p,tipsSummary:w,coach:N,voice:j,onGuidance:R,onCaptured:B,onResult:q,onError:A,onStateChange:J,assetBaseUrl:h,className:x}){let _=vr(t),k=(0,m.useMemo)(()=>gr(t,r),[t,r,_]),u=(0,m.useMemo)(()=>g=>k[g]??"",[k]),M=n??(t==="ar"?"rtl":"ltr"),I=(0,m.useRef)(null),D=(0,m.useContext)(Dn),i=un({verification:e,videoRef:I,assetBaseUrl:h,onCaptured:B,onResult:q,onError:A,onStateChange:J}),T=cn(h,i.state==="idle"&&i.error===null),O=dn(e),z=O.choice!==null,H=sn(e),ge=an(e),he=on(e),W=nn(),Y=ln(e),ne=Y.session==="choice",L=Y.mode==="assisted",xe=j!==!1&&j?.clips===void 0,ve=fn(xe?e:void 0),V=zr({locale:t,defaultClips:ve,options:j}),ee=L?"environment":"user",ue=Y.settled,F=(0,m.useRef)(null),Ne=(0,m.useRef)(!1),$e=(0,m.useRef)(V.unlock);$e.current=V.unlock,(0,m.useEffect)(()=>{let g=F.current;if(g===null)return;let le=["pointerup","touchend","click","keydown"],_e=s(()=>{for(let qe of le)g.removeEventListener(qe,Ae,!0)},"disarm");function Ae(qe){if(Ne.current){_e();return}gn(qe)&&(Ne.current=!0,_e(),$e.current())}l(Ae,"Re"),s(Ae,"onGesture");for(let qe of le)g.addEventListener(qe,Ae,{capture:!0,passive:!0});return _e},[]);let b=(0,m.useCallback)(()=>{Ne.current||(Ne.current=!0,V.unlock()),i.start()},[V.unlock,i.start]),ke=(0,m.useCallback)(()=>i.start(),[i.start]),Le=(0,m.useRef)(!1),Oe=i.state==="idle"&&i.error===null,Tt=!z&&!H.required&&(o===!0||o==="when-permitted"&&W.permission==="granted"),Ot=Tt&&O.settled&&H.settled&&ue,wn=o==="when-permitted"&&!W.permissionSettled&&!Le.current,Pt=Tt&&Oe&&!Le.current,ut=(wn||Pt||!ue)&&T.gate==="ready"?"loading":T.gate;(0,m.useEffect)(()=>{!Ot||!Oe||T.gate!=="ready"||Le.current||(Le.current=!0,ke())},[Ot,Oe,T.gate,ke]);let Sn=Oe&&!z&&!H.required&&!(Pt&&T.gate==="ready"),[Bt,qt]=(0,m.useState)(!1),{canSwitchCaptureMode:Vt,setCaptureMode:Dt}=i;(0,m.useEffect)(()=>{if(!Y.settled||!ne){qt(!1);return}let g=!0;return Vt().then(le=>{g&&qt(le)}),()=>{g=!1}},[Y.settled,ne,Vt]);let{choose:Ht}=Y,Ie=L?"self":"assisted",xn=(0,m.useCallback)(async()=>{await Dt(Ie)&&Ht(Ie)},[Dt,Ht,Ie]),$t=i.state!=="idle"&&i.facingMode!==null?i.facingMode:ee;(0,m.useEffect)(()=>{let g=I.current?.style;$t==="user"?g?.removeProperty("transform"):g&&(g.transform="none")},[$t]);let Fe=(0,m.useMemo)(()=>i.artifacts!==null&&typeof URL.createObjectURL=="function"?URL.createObjectURL(i.artifacts.keyframe):null,[i.artifacts]);(0,m.useEffect)(()=>{if(Fe!==null)return()=>URL.revokeObjectURL(Fe)},[Fe]);let Ft=i.frozenPreview??Fe,Ue=e!==void 0,Z=kn(i.state),be=bn(i.state),Ge=Z||be,se=i.result,Gt=i.state==="done"&&se!==null,Ke=Z&&i.rampColour!==null,dt=i.state==="recording"&&i.frozenPreview!==null&&!Ke,Ze=D!==null,Kt=Bt&&Z&&!dt?{to:Ie,label:u(Ie==="assisted"?"capture.modeSwitch.toAssisted":"capture.modeSwitch.toSelf"),description:u(Ie==="assisted"?"capture.modeSwitch.toAssistedLabel":"capture.modeSwitch.toSelfLabel"),onSwitch:s(()=>{xn()},"onSwitch")}:null,ze=i.modeRestarted&&Z?u("capture.modeSwitch.restarted"):null,Pe=be||dt,Zt=be?"checking":dt?"frozen":i.state==="recording"||Ke?"recording":i.gateLocked||i.gate.progress>=1?"locked":i.gate.faceDetected?"aligning":"seeking",We=Z?i.gate.hint:null,Ye=i.state==="starting"?"capture.preparing.title":We===null?null:We==="center"&&!i.gate.faceDetected?"fcv3.no_face":hr(We),[Nn,zt]=(0,m.useState)(null);(0,m.useEffect)(()=>{if(Ye!=="fcv3.no_face"){zt(Ye);return}if(!Z)return;let g=setTimeout(()=>zt(Ye),Kn);return()=>clearTimeout(g)},[Ye,Z]);let pt=Z&&!Ke&&typeof N=="string"&&N!=="",Wt=L&&Z?u("capture.assisted.stage"):null,Re=Z&&!pt?Ke?Zn:Nn:null,ht=pt?N:Re===null?"":u(Re);Wr(V,Re,ht,Z);let Yt=(0,m.useRef)(R);Yt.current=R,(0,m.useEffect)(()=>{if(st(Re))try{Yt.current?.(Re)}catch(g){console.error("[@sekyro/react] onGuidance threw:",g)}},[Re]);let Be=(0,m.useMemo)(()=>({supported:V.supported,enabled:V.enabled,setEnabled:V.setEnabled,toggle:V.toggle}),[V.supported,V.enabled,V.setEnabled,V.toggle]),ft=a?.voicePrompt,Qt=ft!==void 0,Xt=j===void 0,Jt=(0,m.useRef)(!1);(0,m.useEffect)(()=>{!Qt||!Xt||Jt.current||!It()||(Jt.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."))},[Qt,Xt]);let Rn=ft!==void 0?(g,le,_e)=>ft(g,le,_e,Be):V.supported?()=>(0,v.jsx)(mn,{voice:Be}):void 0,{summary:mt,summaryPlaying:er,toggleSummary:tr,stopSummary:rr}=V,Qe=w!==void 0&&w!=="",nr=Qe?w:u("capture.tips.summary"),sr=Qe?mt!=="none":mt==="partner"||mt==="default"&&yn(p),An=(0,m.useMemo)(()=>sr?{playing:er,toggle:s(()=>tr(nr,{clip:!Qe}),"toggle"),stop:rr}:void 0,[sr,er,tr,nr,rr,Qe]),Mn=(0,m.useMemo)(()=>({assets:ut,retryAssets:T.retry,permission:W.permission,permissionSettled:W.permissionSettled,captureMode:Y.mode,facing:ee,voice:Be}),[ut,T.retry,W.permission,W.permissionSettled,Y.mode,ee,Be]),En=vn(c)?(0,v.jsx)(oe,{tone:c.tone,testId:"sekyro-host-notice",children:(0,v.jsx)("span",{children:c.text})}):c??null,ae=se!==null&&se.status==="retry"?se:null,G=Gt&&se.status==="unavailable"&&!z&&se.reasonCode!=="portrait_required"?se:null,Ce=Gt&&(se.status==="verified"||se.status==="not_verified"||se.status==="review")?se:null,yt=s((g,le)=>{if(g===void 0)return null;if(g==="device_cooldown"){let Ae=mr(t,le);if(Ae!==null)return u(Ae.key).replace("{time}",Ae.time)}let _e=et(g);return _e===null?null:u(_e)},"reasonText"),gt=s(g=>{let le=g.retakeHint===void 0?null:Je(g.retakeHint);return le===null?yt(g.reasonCode):u(le)},"retryText"),ar=Ce===null?null:yt(Ce.reasonCode,Ce.retryAfter)??(Ce.status==="not_verified"&&Ce.reason!==void 0&&Gn.has(Ce.reason)?u("errors.session_expired"):null),Ln=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"&&i.artifacts?.degraded==="NO_RECORDER"),Xe=G?.reasonCode,lr=i.attempt;(0,m.useEffect)(()=>{G===null||Xe===void 0||e?.reportCaptureIssue===void 0||zn.has(Xe)||_t(g=>e.reportCaptureIssue?.(g),{check:"liveness",kind:"unavailable",phase:"upload",engineKind:Xe,attempt:Math.min(1e3,lr)})},[G,Xe,lr,e]);let or=Ct(),In=z&&O.auto===null&&!Z&&!be&&i.error===null,vt=(0,m.useCallback)(async g=>{await O.select(g)&&i.state==="done"&&i.retry()},[O.select,i.state,i.retry]);return(0,m.useEffect)(()=>{O.auto!==null&&!O.busy&&!Z&&!be&&vt(O.auto)},[O.auto,O.busy,Z,be,vt]),(0,v.jsx)(kr,{value:u,children:(0,v.jsxs)("div",{ref:F,className:x===void 0?"sekyro-capture":`sekyro-capture ${x}`,dir:M,lang:t,"data-testid":"sekyro-liveness-capture","data-state":i.state,children:[a?.header,ae!==null&>(ae)!==null&&!(Ze&&Ge)?(0,v.jsx)(oe,{tone:"warning",role:"status",testId:"sekyro-retry-notice",children:(0,v.jsx)("span",{children:gt(ae)})}):null,ze!==null&&!Ze?(0,v.jsx)(oe,{tone:"info",role:"status",testId:"sekyro-mode-switch-status",children:(0,v.jsx)("span",{children:ze})}):null,he&&be&&!Ze?(0,v.jsx)(oe,{tone:"info",role:"status",testId:"sekyro-busy-notice",children:(0,v.jsx)("span",{children:u("capture.busy")})}):null,H.required&&Oe?(0,v.jsx)(oe,{tone:"info",role:"status",testId:"sekyro-mobile-required",children:(0,v.jsx)("span",{children:u("reasons.mobile_required")})}):null,i.error!==null?a?.errorPanel!==void 0?a.errorPanel(i.error,i.retry):(0,v.jsxs)(oe,{tone:"danger",testId:"sekyro-error-notice",children:[(0,v.jsx)("span",{children:u(fr(i.error))}),i.error.retryable?(0,v.jsx)(te,{ref:or,kind:"ghost",className:"sekyro-btn--start",onClick:i.retry,children:u("common.retry")}):null]}):null,G!==null?(0,v.jsxs)(oe,{tone:"danger",testId:"sekyro-unavailable-notice",children:[(0,v.jsx)("span",{children:(G.reasonCode==="attestation"&&G.attestationError==="clock_wrong"?u("errors.device_clock"):yt(G.reasonCode))??u(G.reasonCode===void 0?"errors.session_expired":"errors.network_error")}),Ln?(0,v.jsx)(te,{ref:or,kind:"ghost",className:"sekyro-btn--start",onClick:i.retry,children:u(G.reasonCode==="attestation"?"common.retry":"capture.recordAgain")}):null]}):null,ar!==null&&Ce!==null?(0,v.jsx)(oe,{tone:Ce.status==="not_verified"?"danger":"info",testId:"sekyro-result-notice",children:(0,v.jsx)("span",{children:ar})}):null,(0,v.jsx)("div",{className:Ge?void 0:"sekyro-hidden","data-capture-live":Ge?"":void 0,children:Ze?D({videoRef:I,guidance:Pe&&Ue?u("capture.checking"):ht,coached:pt&&!(Pe&&Ue),note:Pe?Ue?u(he?"capture.busy":"capture.checkingHint"):null:ze??(ae!==null?gt(ae):Wt),settled:Pe&&Ue,progress:i.gate.progress,phase:Zt,still:Pe?Ft:null,live:Ge,modeSwitch:Kt,...Bt?{status:ze}:{},ramp:i.rampColour===null?null:{colour:i.rampColour}}):(0,v.jsx)(br,{videoRef:I,guidanceText:ht,guidanceHint:We,guidanceKey:Re,progress:i.gate.progress,phase:Zt,draining:i.draining,stillUrl:Ft,showChecking:Ue,operatorText:Wt,voicePrompt:Rn,overlay:l(g=>(0,v.jsxs)(v.Fragment,{children:[a?.stageOverlay?.(g),(0,v.jsx)(Cr,{colour:i.rampColour})]}),"overlay"),reduceMotion:i.reduceMotion,modeSwitch:Kt})}),In&&O.choice!==null?(0,v.jsx)(Vr,{title:u("method.title"),description:u("method.description"),options:O.choice.options.map(g=>({id:g,label:u(`method.${g}`)})),busy:O.busy,error:O.failed?u("errors.network_error"):null,focus:i.state==="done",testId:"sekyro-method",look:"buttons",onChoose:l(g=>{vt(g)},"onChoose")}):null,Sn?(0,v.jsxs)(v.Fragment,{children:[ge&&a?.header===void 0&&a?.intro===void 0?(0,v.jsxs)("div",{className:"sekyro-stack sekyro-stack--1",children:[(0,v.jsx)("h2",{className:"sekyro-text-body",children:u("returning.title")}),(0,v.jsx)("p",{className:"sekyro-text-muted",children:u("returning.description")})]}):null,En,a?.intro!==void 0?a.intro(b,Mn):(0,v.jsx)(tn,{assets:ut,onRetryAssets:T.retry,permission:W.permission,captureMode:Y.mode,voice:Be,tips:p??St,summary:An,startLabel:S,startDisabled:d,onStart:b})]}):null,(0,v.jsx)(Qr,{showCoaching:ae!==null,coaching:lt(ae?.reasonCode,ae?.retakeHint),attemptsText:ae?.attemptsRemaining!==void 0?yr(k,t,ae.attemptsRemaining):null,showRetake:ae!==null&&!Z&&!be||!Ue&&i.state==="captured",onRetake:i.retry}),a?.footer]})})}l(Wn,"Ei");s(Wn,"LivenessCapture");var jt=U(K(),1),ct=U(K(),1),f=U(de(),1);var Ss={document:"card",population_registry:"id",national_eid:"smartphone",phone_otp:"phone",email_otp:"email"};function Yn(e,t){switch(e.service){case"document":return t.t("method.document_photo");case"population_registry":return bt(e,t.locale)??t.t("method.nationalNumber");case"national_eid":return bt(e,t.locale)??t.t("method.nationalEid");default:return null}}l(Yn,"D");s(Yn,"identityLabel");function Qn(e,t){let[n,r]=(0,jt.useState)(!1),[a,o]=(0,jt.useState)(null);return{busy:n,error:a,run:s(c=>{r(!0),o(null),c().then(()=>r(!1),d=>{r(!1),o(e.t(Rr(d,e.strings))),t?.(d)})},"run")}}l(Qn,"W");s(Qn,"useChoiceAction");function Cn(){let e=`sekyro-face-light-${(0,ct.useId)().replace(/[^A-Za-z0-9_-]/g,"")}`;return(0,f.jsxs)("svg",{className:"sekyro-mark sekyro-mark--face",viewBox:"0 0 168 206","aria-hidden":"true",focusable:"false",children:[(0,f.jsx)("defs",{children:(0,f.jsx)("mask",{id:e,children:(0,f.jsx)("ellipse",{className:"sekyro-mark__arc",cx:"84",cy:"103",rx:"76",ry:"95",pathLength:"1",fill:"none",stroke:"#fff",strokeWidth:"16"})})}),(0,f.jsx)("ellipse",{cx:"84",cy:"103",rx:"64",ry:"83",fill:"none",className:"sekyro-mark__line"}),(0,f.jsx)("path",{className:"sekyro-mark__face",d:"M68 64v10M100 64v10M84 66v25q0 2-6 1M60 108q24 18 48 0"}),(0,f.jsx)("ellipse",{className:"sekyro-mark__ticks",cx:"84",cy:"103",rx:"76",ry:"95",pathLength:"56"}),(0,f.jsx)("ellipse",{className:"sekyro-mark__ticks sekyro-mark__ticks--light",cx:"84",cy:"103",rx:"76",ry:"95",pathLength:"56",mask:`url(#${e})`})]})}l(Cn,"B");s(Cn,"FaceMark");var Xn={glasses:"jGlasses",lighting:"light",faceCamera:"camera"};function Jn(e){if(!(e?.kind!=="liveness"||e.reason===void 0))return{reason:e.reason,...e.retakeHint!==void 0?{retakeHint:e.retakeHint}:{},attemptsRemaining:e.attemptsRemaining??0,attemptsExhausted:e.attemptsExhausted===!0}}l(Jn,"re");s(Jn,"faceIntroRetryOf");var es={"capture.retryFrontCamera.screenSide":"camera","capture.retryBackCamera.backSide":"camera","capture.retryUpright.vertical":"smartphone","capture.retryUpright.untilEnd":"smartphone","capture.retryRecording.cameraOn":"camera","capture.retryRecording.stay":"smartphone","capture.retryRecording.network":"smartphone","capture.retryDevice.screenRecording":"smartphone","capture.retryDevice.phone":"smartphone"};function ts({start:e,context:t,tips:n,tipsTitle:r,human:a=!1,returning:o=!1,notice:c,retry:d}){let S=wt(),{t:p}=S,w=d===void 0?"face":lt(d.reason,d.retakeHint),N=w==="face"?null:He[w].tips,j=(0,ct.useContext)(wr)?.busy===!0;return(0,f.jsxs)("section",{className:"sekyro-step",children:[(0,f.jsx)(Cn,{}),t.captureMode==="assisted"?(0,f.jsx)(tt,{title:p("capture.assisted.heading"),lead:p("capture.assisted.lead")}):o?(0,f.jsx)(tt,{title:p("returning.heading"),lead:p("returning.description")}):(0,f.jsx)(tt,{title:p(a?"native.face.humanIntroTitle":"native.face.introTitle"),lead:p(a?"native.face.humanIntroLead":"native.face.introLead")}),d!==void 0?(0,f.jsx)(_n,{retry:d,title:He[w].title}):null,r!==void 0&&N===null?(0,f.jsx)("p",{className:"sekyro-section-label",children:r}):null,(0,f.jsx)("ul",{className:"sekyro-tiprows",children:N!==null?N.map(R=>(0,f.jsxs)("li",{children:[(0,f.jsx)(Ee,{name:es[R]??"face"}),p(R)]},R)):n!==void 0?n.map(R=>(0,f.jsxs)("li",{children:[(0,f.jsx)(Ee,{name:Xn[R.id]??"face"}),R.text]},R.id)):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)("li",{children:[(0,f.jsx)(Ee,{name:"light"}),p("capture.tips.light")]}),(0,f.jsxs)("li",{children:[(0,f.jsx)(Ee,{name:"jGlasses"}),p("capture.tips.uncover")]}),(0,f.jsxs)("li",{children:[(0,f.jsx)(Ee,{name:"smartphone"}),p("capture.tips.eyeLevel")]})]})}),c??null,c!==void 0?null:t.assets==="failed"?(0,f.jsx)(te,{kind:"secondary",full:!0,onClick:t.retryAssets,children:p("common.retry")}):null,c!==void 0?null:(0,f.jsx)(_r,{children:(0,f.jsxs)(te,{full:!0,disabled:t.assets!=="ready"||j,"aria-busy":t.assets==="loading"||void 0,onClick:e,children:[(0,f.jsx)(Ee,{name:"camera"}),p("capture.start")]})})]})}l(ts,"ae");s(ts,"FaceIntro");var rs=new Set(["match_inconclusive","no_face_source","below_threshold"]);function _n({retry:e,title:t}){let n=wt(),r=e.retakeHint===void 0?null:Je(e.retakeHint),a=e.reason==="probe_not_from_liveness"?"capture.retrySamePerson.message":rs.has(e.reason)?"capture.retryMatch.message":et(e.reason);return(0,f.jsxs)(Sr,{tone:"warning",children:[r!==null?(0,f.jsx)("span",{children:n.t(r)}):a!==null?(0,f.jsx)("span",{children:n.t(a)}):null,r===null?(0,f.jsx)("span",{children:n.t(t)}):null,(0,f.jsx)("span",{children:xr(n,e.attemptsRemaining,e.attemptsExhausted)})]})}l(_n,"M");s(_n,"RetryNotice");function ns(e){return kt(e)}l(ns,"ce");s(ns,"isInAppBrowser");function ss(e,t){let n=t??(typeof navigator>"u"?"":String(navigator.userAgent??""));if(!/Android/i.test(n))return null;let r;try{r=new URL(e)}catch{return null}if(r.protocol!=="https:"&&r.protocol!=="http:")return null;let a=r.protocol.slice(0,-1);return`intent://${r.host}${r.pathname}${r.search}#Intent;scheme=${a};action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(e)};end`}l(ss,"pe");s(ss,"androidBrowserIntent");export{Vr as a,It as b,Dn as c,ln as d,Wn as e,Ss as f,Yn as g,Qn as h,Jn as i,ts as j,ns as k,ss as l};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as E,b as It,c as Et,d as K,e as Pt}from"./chunk-5Y7NCFTK.js";import{c as Mt,d as kt,e as vt,i as bt,j as xt,k as St,l as Q,m as _t,n as Rt,o as Ft,p as U,q as Tt,r as Dt,s as At,v as Ct,y as zt}from"./chunk-XKZZC74I.js";import{c as Lt,d as Ot}from"./chunk-37BKUH3E.js";import{b as j,d as yt}from"./chunk-W5WWCOOW.js";import{d as lt,e as ft,f as pt}from"./chunk-2CQQAB3Y.js";import{a as B,b as H,c as D,d as wt}from"./chunk-P7K7ELYZ.js";import{g as ct,i as ut,j as dt,k as mt,l as gt}from"./chunk-JS2IXPNL.js";import{a as c}from"./chunk-4FHWXBOB.js";var P=Object.freeze({sensing:{key:"sensing",reticle:"searching",minDurationMs:900},too_far:{key:"too_far",reticle:"coaching",minDurationMs:1400},too_close:{key:"too_close",reticle:"coaching",minDurationMs:1400},edge_clipped:{key:"edge_clipped",reticle:"coaching",minDurationMs:1400},wrong_shape:{key:"wrong_shape",reticle:"coaching",minDurationMs:1400},tilted:{key:"tilted",reticle:"coaching",minDurationMs:1400},too_dark:{key:"too_dark",reticle:"coaching",minDurationMs:1400},too_bright:{key:"too_bright",reticle:"coaching",minDurationMs:1400},blurry:{key:"blurry",reticle:"coaching",minDurationMs:1400},focus_far:{key:"focus_far",reticle:"coaching",minDurationMs:1600},low_contrast:{key:"low_contrast",reticle:"coaching",minDurationMs:1600},glare:{key:"glare",reticle:"coaching",minDurationMs:1400},hold_still:{key:"hold_still",reticle:"locking",minDurationMs:900},processing:{key:"processing",reticle:"processing",minDurationMs:800},side_captured:{key:"side_captured",reticle:"flip",minDurationMs:2600},captured:{key:"captured",reticle:"done",minDurationMs:800}});function oe(i){return i.framing==="no_document"?"sensing":i.framing==="too_far"?"too_far":i.framing==="too_close"?"too_close":i.framing==="edge_clipped"?"edge_clipped":i.framing==="wrong_shape"?"wrong_shape":i.framing==="tilted"?"tilted":i.lighting==="too_dark"?"too_dark":i.lighting==="too_bright"?"too_bright":i.glare==="glare"?"glare":i.blur==="blurry"?"blurry":"hold_still"}c(oe,"Bt");var T,ne=(T=class{constructor(t=2600,e=.35){this.windowMs=t,this.decayPerSecond=e,this.votes=[],this.current=P.sensing,this.currentSinceMs=null}reset(){this.votes=[],this.current=P.sensing,this.currentSinceMs=null}force(t,e){return this.votes=[],this.current=P[t],this.currentSinceMs=e,this.current}tick(t,e){if(this.currentSinceMs===null&&(this.currentSinceMs=e),this.votes.push({key:t,atMs:e}),this.votes=this.votes.filter(r=>e-r.atMs<=this.windowMs),e-this.currentSinceMs<this.current.minDurationMs)return this.current;let s=new Map;for(let r of this.votes){let o=(e-r.atMs)/1e3,n=this.decayPerSecond**o;s.set(r.key,(s.get(r.key)??0)+n)}let a=this.current.key,h=-1;for(let[r,o]of s)o>h&&(h=o,a=r);return a!==this.current.key&&(this.current=P[a],this.currentSinceMs=e),this.current}},c(T,"I"),T),le=Object.freeze({MAX_AREA_FRAC:.92,TILT_MAX_SIDE_RATIO:1.3,GLARE_MAX_SPECULAR_FRAC:.025});function ce(i){let{data:t,width:e,height:s}=i,a=e*s;if(a===0)return 0;let h=0;for(let r=0;r<a;r++){let o=r*4;.299*(t[o]??0)+.587*(t[o+1]??0)+.114*(t[o+2]??0)>=252&&h++}return h/a}c(ce,"Wt");function ue(i){let t=c((n,u)=>Math.hypot(u.x-n.x,u.y-n.y),"t"),e=t(i.topLeft,i.topRight),s=t(i.bottomLeft,i.bottomRight),a=t(i.topLeft,i.bottomLeft),h=t(i.topRight,i.bottomRight),r=Math.max(e,s)/Math.max(1e-6,Math.min(e,s)),o=Math.max(a,h)/Math.max(1e-6,Math.min(a,h));return Math.max(r,o)}c(ue,"De");function de(i){let t={...It,...i.thresholds},e=le,{quad:s,frameWidth:a,frameHeight:h,measures:r}=i,o=i.format==="ID-3",n="ok";if(s===null)n="no_document";else if(o){let d=K(s),m=a>0?d.width/a:0,w=d.height>0?d.width/d.height:0;m<t.ID3_BAND_MIN_WIDTH_FRAC?n="too_far":Gt(s,a,h,t.EDGE_CLIP_MARGIN_PX)?n="edge_clipped":(w<t.ID3_BAND_ASPECT_MIN||w>t.ID3_BAND_ASPECT_MAX)&&(n="wrong_shape")}else{let d=Et(s,a,h),m=K(s),w=Math.max(m.width,m.height)/Math.max(1e-6,Math.min(m.width,m.height));d<t.MIN_AREA_FRAC?n="too_far":d>e.MAX_AREA_FRAC?n="too_close":Gt(s,a,h,t.EDGE_CLIP_MARGIN_PX)?n="edge_clipped":Ot(i.format,w)?ue(s)>e.TILT_MAX_SIDE_RATIO&&(n="tilted"):n="wrong_shape"}let u=r.exposure>=t.GUIDE_EXPOSURE?"ok":r.meanLuma<(B[0]+B[1])/2?"too_dark":"too_bright",l=r.sharpness>=t.GUIDE_SHARPNESS?"ok":"blurry",f=r.specularFraction>=e.GLARE_MAX_SPECULAR_FRAC?"glare":"ok";return{framing:n,lighting:u,blur:l,glare:f,acceptable:n==="ok"&&u==="ok"&&l==="ok"&&f==="ok"}}c(de,"Ht");function Gt(i,t,e,s){return[i.topLeft,i.topRight,i.bottomRight,i.bottomLeft].some(a=>a.x<=s||a.y<=s||a.x>=t-s||a.y>=e-s)}c(Gt,"Nt");var Z=Object.freeze({width:1920,height:1080}),me=Object.freeze({width:3840,height:2160}),Wt=4096,ge=2560,fe=640,G=.15,A=Object.freeze({side:.2,above:.9,below:.3});function F(i){let t=[i.topLeft.x,i.topRight.x,i.bottomRight.x,i.bottomLeft.x],e=[i.topLeft.y,i.topRight.y,i.bottomRight.y,i.bottomLeft.y],s=Math.min(...t),a=Math.min(...e);return{x:s,y:a,width:Math.max(...t)-s,height:Math.max(...e)-a}}c(F,"v");function Yt(i,t){let e=Math.max(0,Math.floor(i.x)),s=Math.max(0,Math.floor(i.y)),a=Math.min(t.width,Math.ceil(i.x+i.width)),h=Math.min(t.height,Math.ceil(i.y+i.height));return a-e<16||h-s<16?null:{x:e,y:s,width:a-e,height:h-s}}c(Yt,"Vt");function pe(i,t,e){if(i===null||t.width<=0||t.height<=0)return null;let s=F(i);if(s.width<=0||s.height<=0)return null;let a=e==="ID-3"?{x:s.x-s.width*A.side,y:s.y-s.width*A.above,width:s.width*(1+2*A.side),height:s.height+s.width*(A.above+A.below)}:{x:s.x-s.width*G,y:s.y-s.height*G,width:s.width*(1+2*G),height:s.height*(1+2*G)};return Yt(a,t)}c(pe,"xe");function Jt(i,t,e){let s=Math.max(i,t);return s>0?Math.min(1,e/s):1}c(Jt,"J");function $t(i,t,e,s,a=ge){let h=t.width>0?e.width/t.width:1,r=t.height>0?e.height/t.height:1,o=i===null?null:{topLeft:{x:i.topLeft.x*h,y:i.topLeft.y*r},topRight:{x:i.topRight.x*h,y:i.topRight.y*r},bottomRight:{x:i.bottomRight.x*h,y:i.bottomRight.y*r},bottomLeft:{x:i.bottomLeft.x*h,y:i.bottomLeft.y*r}},n=pe(o,e,s)??{x:0,y:0,width:e.width,height:e.height},u=Jt(n.width,n.height,a),l=Math.max(1,Math.round(n.width*u)),f=Math.max(1,Math.round(n.height*u)),d=null;if(o!==null){let m=F(o);d=Yt({x:(m.x-n.x)*u,y:(m.y-n.y)*u,width:m.width*u,height:m.height*u},{width:l,height:f})}return{crop:n,width:l,height:f,docRegion:d}}c($t,"q");var we=960,X=[{width:1920,height:1080},{width:2560,height:1440}];function ye(i){let t=Number.isFinite(i)&&i>0?Math.min(1,i):.85;return X.find(e=>e.height*t>=we)??X[X.length-1]}c(ye,"Ce");function Me(i,t,e,s=me,a){if(e==="LOW")return null;let h=a===void 0?null:ye(a.fill),r=h!==null&&Math.max(h.width,h.height)>Math.max(s.width,s.height)?h:s,o=i?.width?.max,n=i?.height?.max;if(typeof o!="number"||typeof n!="number"||o<=0||n<=0)return null;let u=Math.max(o,n),l=Math.min(o,n),f=Math.min(u,Math.max(r.width,r.height)),d=Math.min(l,Math.min(r.width,r.height));return f<=Math.max(t.width,t.height)?null:{width:{ideal:f},height:{ideal:d}}}c(Me,"Zt");function ke(i){let t={},e=i?.imageWidth,s=i?.imageHeight;if(typeof e?.max=="number"&&e.max>0){let a=typeof s?.max=="number"&&s.max>0?e.max/s.max:1.3333333333333333,h=a>=1?Wt:Wt*a,r=Math.min(e.max,Math.floor(h)),o=typeof e.step=="number"&&e.step>0?e.step:1,n=typeof e.min=="number"?e.min:0;r=Math.max(n,n+Math.floor((r-n)/o)*o),t.imageWidth=r}return i?.fillLightMode?.includes("off")===!0&&(t.fillLightMode="off"),t}c(ke,"Xt");function ve(i,t){if(i.width<=0||i.height<=0||t.width<=0||t.height<=0)return!1;let e=i.width>i.height,s=t.width>t.height;return e!==s&&i.width!==i.height&&t.width!==t.height?!1:Math.max(i.width,i.height)>=1.2*Math.max(t.width,t.height)}c(ve,"jt");function be(i,t,e,s){if(e===null)return!1;let a=F(i),h=F(e);if(t.width<=0||s.width<=0)return!1;let r=a.width/t.width,o=h.width/s.width;return o>0&&r>=.6*o&&r<=1.25*o}c(be,"Yt");var Nt=3500,xe=.92;function te(){let i=globalThis.ImageCapture;return typeof i=="function"?i:null}c(te,"$t");function Se(i){return/AppleWebKit\//.test(i)&&!/(Chrome|Chromium|Edg|OPR)\//.test(i)}c(Se,"Re");function _e(i,t=typeof navigator>"u"?"":navigator.userAgent){return te()!==null&&!Se(t)&&i!=null&&i.kind==="video"&&i.readyState==="live"}c(_e,"te");function qt(i,t){return new Promise((e,s)=>{let a=setTimeout(()=>s(new Error("takePhoto timed out")),t);i.then(h=>{clearTimeout(a),e(h)},h=>{clearTimeout(a),s(h)})})}c(qt,"qt");function Y(i,t){let e=document.createElement("canvas");return e.width=i,e.height=t,e}c(Y,"$");function Re(i,t){return new Promise((e,s)=>{i.toBlob(a=>a?e(a):s(new Error("toBlob failed")),"image/jpeg",t)})}c(Re,"Fe");async function ee(i,t,e,s,a){let h=Y(e,s),r=Y(1,1);try{let o=h.getContext("2d");if(o===null)throw new Error("2d context unavailable");o.imageSmoothingQuality="high",o.drawImage(i,t.x,t.y,t.width,t.height,0,0,e,s);let n=await Re(h,xe),u=a===null?null:Mt({topLeft:{x:a.x,y:a.y},topRight:{x:a.x+a.width,y:a.y},bottomRight:{x:a.x+a.width,y:a.y+a.height},bottomLeft:{x:a.x,y:a.y+a.height}},{width:e,height:s},{width:e,height:s}),l=kt(h,u),f=Jt(e,s,fe);return r.width=Math.max(1,Math.round(e*f)),r.height=Math.max(1,Math.round(s*f)),r.getContext("2d")?.drawImage(h,0,0,r.width,r.height),{blob:n,previewDataUrl:r.toDataURL("image/jpeg",.85),sharpness:l}}finally{h.width=0,h.height=0,r.width=0,r.height=0}}c(ee,"ee");function Fe(i,t){let e=Math.min(1,t/i.width),s=Y(Math.max(1,Math.round(i.width*e)),Math.max(1,Math.round(i.height*e)));try{let a=s.getContext("2d",{willReadFrequently:!0});return a===null?null:(a.imageSmoothingQuality="high",a.drawImage(i,0,0,s.width,s.height),a.getImageData(0,0,s.width,s.height))}finally{s.width=0,s.height=0}}c(Fe,"Ae");async function Te(i,t,e,s){let a={width:Math.max(1,i.videoWidth),height:Math.max(1,i.videoHeight)},h=$t(t,e,a,s);return{...await ee(i,h.crop,h.width,h.height,h.docRegion),docRegion:h.docRegion,source:"video",width:h.width,height:h.height}}c(Te,"ie");async function De(i,t,e,s,a){let h=te();if(h===null)return null;let r=null;try{let o=new h(a.track),n=await qt(o.getPhotoCapabilities?.()??Promise.resolve({}),Nt).catch(()=>({})),u=await qt(o.takePhoto(ke(n)),Nt);r=await createImageBitmap(u);let l={width:i.videoWidth,height:i.videoHeight};if(!ve(r,l))return null;let f=Fe(r,a.detectWidth),d=null;f!==null&&t!==null&&(d=await a.detect(f).catch(()=>null));let m=f??{width:r.width,height:r.height};d!==null&&!be(d,m,t,e)&&(d=null);let w=$t(d,m,r,s);return{...await ee(r,w.crop,w.width,w.height,w.docRegion),docRegion:w.docRegion,source:"photo",width:w.width,height:w.height}}catch{return null}finally{r?.close()}}c(De,"oe");var it=Object.freeze({width:3840,height:2160,lensSelection:!0,continuousFocus:!0,refocusBeforePhotoMs:350,zoomMax:2,zoomNoFocusInfo:1.5,zoomMinSourcePx:2160,fillDistanceM:Object.freeze({id1:.11,id3:.15}),focusMarginFrac:.2,stillSharpnessMin:.16,stillRefusalsMax:2,focusFarFillFrac:.45,noDocFarHintMs:1500,zoomFallbackMs:8e3}),M=c((i,t,e)=>typeof i=="number"&&Number.isFinite(i)&&i>=t&&i<=e?i:void 0,"y");function hi(i){let t=it,e=i!==null&&typeof i=="object"?i:{},s=e.fillDistanceM!==null&&typeof e.fillDistanceM=="object"?e.fillDistanceM:{},a=c((h,r)=>typeof h=="boolean"?h:r,"s");return{width:M(e.width,640,7680)??t.width,height:M(e.height,480,4320)??t.height,lensSelection:a(e.lensSelection,t.lensSelection),continuousFocus:a(e.continuousFocus,t.continuousFocus),refocusBeforePhotoMs:M(e.refocusBeforePhotoMs,0,2e3)??t.refocusBeforePhotoMs,zoomMax:M(e.zoomMax,1,5)??t.zoomMax,zoomNoFocusInfo:M(e.zoomNoFocusInfo,1,5)??t.zoomNoFocusInfo,zoomMinSourcePx:M(e.zoomMinSourcePx,0,8e3)??t.zoomMinSourcePx,fillDistanceM:{id1:M(s.id1,.03,1)??t.fillDistanceM.id1,id3:M(s.id3,.03,1)??t.fillDistanceM.id3},focusMarginFrac:M(e.focusMarginFrac,0,2)??t.focusMarginFrac,stillSharpnessMin:M(e.stillSharpnessMin,0,10)??t.stillSharpnessMin,stillRefusalsMax:M(e.stillRefusalsMax,0,10)??t.stillRefusalsMax,focusFarFillFrac:M(e.focusFarFillFrac,0,1)??t.focusFarFillFrac,noDocFarHintMs:M(e.noDocFarHintMs,0,6e4)??t.noDocFarHintMs,zoomFallbackMs:M(e.zoomFallbackMs,0,12e4)??t.zoomFallbackMs}}c(hi,"ci");var J="sekyro.doc.camera";function Ae(){try{let i=globalThis.localStorage?.getItem(J);return typeof i=="string"&&i!==""?i:null}catch{return null}}c(Ae,"Ee");function Bt(i){try{i===null?globalThis.localStorage?.removeItem(J):globalThis.localStorage?.setItem(J,i)}catch{}}c(Bt,"se");var $=c((i,t)=>Array.isArray(i?.focusMode)&&i.focusMode.includes(t),"B");function Ht(i,t,e){if(!$(i,"single-shot"))return null;let s=c(a=>Math.min(1,Math.max(0,Number.isFinite(a)?a:.5)),"o");return{focusMode:"single-shot",pointsOfInterest:[{x:s(t),y:s(e)}]}}c(Ht,"it");function Ce(i,t,e,s=it){let a=i?.zoom?.min,h=i?.zoom?.max;if(typeof h!="number"||h<=1)return 1;let r=e==="ID-3"?s.fillDistanceM.id3:s.fillDistanceM.id1,o=i?.focusDistance?.min,n;if(typeof o=="number"&&o>0&&o<1){if(n=o*(1+s.focusMarginFrac)/r,n<=1.05)return 1}else{if(Math.min(t.width,t.height)<s.zoomMinSourcePx)return 1;n=s.zoomNoFocusInfo}let u=Math.min(n,s.zoomMax,h);typeof a=="number"&&(u=Math.max(u,a));let l=i?.zoom?.step;return typeof l=="number"&&l>0&&(u=Math.round(u/l)*l),u>1.01?Number(u.toFixed(2)):1}c(Ce,"re");function tt(i){try{return i.getVideoTracks?.()[0]}catch{return}}c(tt,"et");function jt(i){if(i!==null)for(let t of i.getTracks())t.stop()}c(jt,"ne");function ze(i){try{let t=tt(i)?.getCapabilities?.();return!Array.isArray(t?.focusMode)||t.focusMode.includes("continuous")}catch{return!0}}c(ze,"Le");async function Le(i){let t=c(h=>({audio:!1,video:{...h,width:{ideal:i.base.width},height:{ideal:i.base.height}}}),"t"),e=c(h=>i.getUserMedia(t({deviceId:{exact:h}})),"e"),s=c(()=>i.getUserMedia(t({facingMode:{ideal:"environment"}})),"o");if(i.lensSelection){let h=Ae();if(h!==null)try{return{stream:await e(h),lens:"stored"}}catch{Bt(null)}}let a=await s();if(!i.lensSelection||i.enumerateDevices===void 0)return{stream:a,lens:"default"};try{let h=gt(await i.enumerateDevices()).slice(0,3);if(h.length===0)return{stream:a,lens:"default"};let r=null;for(let o of h){let n=a!==null?tt(a)?.getSettings?.().deviceId:void 0;if(a===null||n!==o){jt(a),a=null;try{a=await e(o)}catch{continue}}if(r??(r=o),ze(a))return Bt(o),{stream:a,lens:"selected"}}if(a!==null&&r!==null&&tt(a)?.getSettings?.().deviceId===r)return{stream:a,lens:"selected"};if(jt(a),a=null,r!==null)try{return{stream:await e(r),lens:"selected"}}catch{}return{stream:await s(),lens:"default"}}catch{return{stream:a??await s(),lens:"default"}}}c(Le,"ae");var z=null;async function Oe(i){return z===null&&(z=(await import("./detector-scanic-3VQFGZAA-NF7AFUUP.js")).detectQuad),z(i)}c(Oe,"Pe");async function Ie(i){let t=j(i);return t===null?null:{topLeft:{x:t.x,y:t.y},topRight:{x:t.x+t.width,y:t.y},bottomRight:{x:t.x+t.width,y:t.y+t.height},bottomLeft:{x:t.x,y:t.y+t.height}}}c(Ie,"Oe");function ri(){z===null&&import("./detector-scanic-3VQFGZAA-NF7AFUUP.js").then(i=>{z=i.detectQuad}).catch(()=>{})}c(ri,"Fi");var Qt=4e3,Ee=2,Ut=3,Kt=Object.freeze({LOW:3,MID:5,HIGH:6}),Pe=600,Ge=8,We=3,Ne=90,et=Object.freeze({manualShutterMs:6e3,detectedNoLockMs:1950});function oi(i){let t=i!==null&&typeof i=="object"?i:{},e=c((s,a,h)=>typeof s=="number"&&Number.isFinite(s)&&s>=a&&s<=h?s:void 0,"e");return{manualShutterMs:e(t.manualShutterMs,1e3,6e4)??et.manualShutterMs,detectedNoLockMs:e(t.steadyMs,300,3e4)!==void 0?t.steadyMs+(e(t.lockMs,0,1e4)??450):et.detectedNoLockMs}}c(oi,"Ai");var S,ni=(S=class{constructor(t){this.upgraded=!1,this.tickCosts=[],this.photoOff=!1,this.demotion=null,this.torchOn=!1,this.stillRefusals=0,this.zoom=1,this.positioningSince=null,this.detectedSince=null,this.weakEdgesSince=null,this.lastSeenAt=null,this.lastGuideQuad=null,this.lastGuideCard=null,this.zones=[],this.lastStillAt=null,this.probeAt=null,this.lastOcrReady=null,this.shutterOffered=!1,this.stats=S.freshStats(),this.handlers=new Map,this.stream=null,this.timer=null,this.state="idle",this.lastGuidance=null,this.attempt=0,this.capturing=!1,this.feedback=new ne,this.lastFeedbackKey=null,this.lastQuad=null,this.lastDetect=null,this.frameWatch=null,this.reopened=!1,this.lit=!1,this.blackTicks=0,this.offEnded=null,this.opts=t,this.gate=new Pt(t.format??"ID-1",t.thresholds);let e=t.deviceClass??pt(ft());this.deviceClass=e,this.camera=t.camera??it,this.shutterTuning=t.shutter??et,this.guideTuning=t.guideLock??Dt,this.zones=t.zones??[],this.guideLock=new Ct(this.guideTuning),this.cadenceMs=1e3/Kt[e]}on(t,e){let s=this.handlers.get(t);return s||(s=new Set,this.handlers.set(t,s)),s.add(e),()=>s?.delete(e)}emit(t,e){for(let s of[...this.handlers.get(t)??[]])s(e)}async start(){let t=this.state==="error"?this.resumePlayback():null,e=++this.attempt;if(this.clearFrameWatch(),this.gate.reset(),this.resetSide(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.lit=!1,this.blackTicks=0,t!==null&&await t&&e===this.attempt){this.setState("positioning"),this.scheduleTick(e),this.watchFrames(e);return}if(e===this.attempt){this.releaseStream(),mt(),this.setState("preflight");try{let s=this.opts.getUserMedia??(r=>navigator.mediaDevices.getUserMedia(r));this.setState("acquiring");let a=this.opts.enumerateDevices??(this.opts.getUserMedia===void 0&&typeof navigator<"u"&&navigator.mediaDevices?.enumerateDevices?()=>navigator.mediaDevices.enumerateDevices():void 0),h=await Le({getUserMedia:s,...a!==void 0?{enumerateDevices:a}:{},lensSelection:this.camera.lensSelection,base:Z});if(e!==this.attempt){for(let r of h.stream.getTracks())r.stop();return}if(this.stream=h.stream,lt(this.stream),dt(this.stream),this.watchEnded(e),this.opts.upgradeResolution!==!1&&await this.upgradeResolution(),e!==this.attempt||(await this.applyFocusAndZoom(),e!==this.attempt)||(this.opts.video.srcObject=this.stream,await this.opts.video.play().catch(()=>{}),e!==this.attempt))return;this.setState("positioning"),this.scheduleTick(e),this.watchFrames(e)}catch(s){if(e!==this.attempt)return;let a=ut(s),h=ct(s);this.setState("error"),this.emit("error",{kind:a,retryable:!0,detail:h===void 0?{phase:"acquiring"}:{phase:"acquiring",name:h}})}}}resumePlayback(){let t=this.opts.video,e=this.videoTrack();if(this.stream===null||e===null||e.readyState!=="live"||t.srcObject!==this.stream)return null;try{return Promise.resolve(t.play()).then(()=>this.framesNow(),()=>!1)}catch{return null}}framesNow(){let t=this.opts.video;return this.opts.hasFrames!==void 0?this.opts.hasFrames(t):!t.paused&&t.readyState>=2&&t.videoWidth>0}watchFrames(t){let e=this.opts.firstFrameMs??Qt;e<=0||(this.clearFrameWatch(),this.frameWatch=setTimeout(()=>{if(this.frameWatch=null,!(t!==this.attempt||this.state!=="positioning")){if(this.framesNow()&&this.blackTicks<Ut){this.reopened=!1;return}this.cameraDead(t)}},e))}clearFrameWatch(){this.frameWatch!==null&&clearTimeout(this.frameWatch),this.frameWatch=null}watchEnded(t){this.offEnded?.(),this.offEnded=null;let e=this.videoTrack();if(e===null||typeof e.addEventListener!="function")return;let s=c(()=>{t===this.attempt&&(this.state==="positioning"||this.state==="acquiring")&&this.cameraDead(t)},"o");e.addEventListener("ended",s),this.offEnded=()=>e.removeEventListener?.("ended",s)}cameraDead(t){if(t!==this.attempt)return;let e=this.videoTrack(),s=e!==null&&e.readyState==="live"&&!e.muted&&this.opts.video.paused&&!this.framesNow();if(!s&&!this.reopened){this.reopened=!0,this.start();return}this.attempt+=1,this.timer!==null&&(this.opts.clearTimer??clearTimeout)(this.timer),this.timer=null,this.clearFrameWatch(),s||this.releaseStream(),this.reopened=!1,this.setState("error"),this.emit("error",{kind:"generic",retryable:!0,detail:{phase:"acquiring"}})}releaseStream(){if(this.offEnded?.(),this.offEnded=null,this.stream)for(let t of this.stream.getTracks())t.stop();this.stream=null,this.opts.video.srcObject!==null&&this.opts.video.srcObject!==void 0&&(this.opts.video.srcObject=null)}rearm(t){t!==void 0&&(this.opts.side=t),this.probeAt=null,this.gate.reset(),this.resetSide(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.stillRefusals=0,this.state==="captured"&&(this.setState("positioning"),this.scheduleTick(this.attempt))}async captureNow(){if(this.state!=="positioning"||this.capturing)return;let t=this.opts.video,e=this.lastDetect?.width??Math.max(1,t.videoWidth),s=this.lastDetect?.height??Math.max(1,t.videoHeight),a=this.lastQuad??this.lastGuideQuad??{topLeft:{x:0,y:0},topRight:{x:e,y:0},bottomRight:{x:e,y:s},bottomLeft:{x:0,y:s}},h=(this.opts.now??(()=>performance.now()))(),r=this.feedback.force("processing",h);this.lastFeedbackKey=r.key,this.emit("feedback",r),await this.fire(this.attempt,this.lastOcrReady!==null?this.lastOcrReady.quad:a,{width:e,height:s,tickSharpness:this.lastDetect?.tickSharpness??0},this.lastOcrReady?.via??"manual")}captureReport(){let t=this.stats;return{...this.opts.side!==void 0?{side:this.opts.side}:{},format:this.opts.format??"ID-1",deviceClass:this.deviceClass,video:{width:this.opts.video.videoWidth||0,height:this.opts.video.videoHeight||0},zoom:this.zoom,...t.zoomFallbackAtMs!==void 0?{zoomFallbackAtMs:t.zoomFallbackAtMs}:{},...t.msToCapture!==void 0?{msToCapture:t.msToCapture}:{},...t.via!==void 0?{via:t.via}:{},...t.shutterAtMs!==void 0?{shutterAtMs:t.shutterAtMs}:{},...t.shutterReason!==void 0?{shutterReason:t.shutterReason}:{},...t.shotGlare!==void 0?{shotGlare:t.shotGlare}:{},...t.shotSharpness!==void 0?{shotSharpness:t.shotSharpness}:{},...t.shotTorch!==void 0?{shotTorch:t.shotTorch}:{},...t.shotGlareZone!==void 0?{shotGlareZone:t.shotGlareZone}:{},...t.msSincePrevShot!==void 0?{msSincePrevShot:t.msSincePrevShot}:{},...t.stillSource!==void 0?{stillSource:t.stillSource}:{},...this.demotion!==null?{demotedFrom:this.demotion.from,demotedBy:this.demotion.by,...this.demotion.tickMedianMs!==void 0?{tickMedianMs:this.demotion.tickMedianMs}:{}}:{},ticks:t.ticks,quadFraming:{...t.quadFraming},qualityBlockers:{...t.qualityBlockers},guideBlockers:{...t.guideBlockers},stillRefusals:t.stillRefusals,...this.ocrReport()}}ocrReport(){let t=this.opts.ocr;if(t===void 0)return{};let e=(this.opts.format??"ID-1")==="ID-3"||this.opts.side==="single"?"single":this.opts.side==="verso"?"verso":"recto",s=t.report(e,this.stats.via,(this.opts.now??(()=>performance.now()))());return s===null?{}:{ocr:s}}static freshStats(){return{ticks:0,quadFraming:{},qualityBlockers:{},guideBlockers:{},stillRefusals:0}}setZones(t){this.zones=t??[]}setLockTuning(t){this.guideTuning=t,this.guideLock.setTuning(t)}setGuide(t){t===void 0?delete this.opts.guide:this.opts.guide=t,this.guideLock.reset(),this.probeAt=null}sideProbe(t,e,s,a){if(this.opts.sideProbe!==!0||!e)return;if(this.probeAt===null){this.probeAt=a;return}if(a-this.probeAt<Pe)return;this.probeAt=a;let h=this.guideRegion(t),r=h.x*t.width,o=h.y*t.height,n=h.width*t.width,u=h.height*t.height,l={topLeft:{x:r,y:o},topRight:{x:r+n,y:o},bottomRight:{x:r+n,y:o+u},bottomLeft:{x:r,y:o+u}};return vt(j,C(t,l),!0,s,!1,yt)==="verso"?"verso":"recto"}guideRegion(t){let e=t.width/Math.max(1,t.height),s=this.opts.guide;if(s!==void 0&&s.viewAspect>0){let o={width:s.viewAspect,height:1},n={x:s.rect.x*s.viewAspect,y:s.rect.y,width:s.rect.width*s.viewAspect,height:s.rect.height};return xt(o,n,e,0)}let a=Lt(this.opts.format??"ID-1").center,h=.86,r=h*e/a;return r>.84&&(r=.84,h=r*a/e),{x:(1-h)/2,y:(1-r)/2,width:h,height:r}}resetSide(){this.positioningSince=null,this.detectedSince=null,this.weakEdgesSince=null,this.lastSeenAt=null,this.guideLock.reset(),this.lastGuideQuad=null,this.lastGuideCard=null,this.lastOcrReady=null,this.opts.ocr?.reset(),this.stats=S.freshStats(),this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1}))}withdrawShutter(){this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1}))}zoomFallback(t){let e=this.videoTrack();if(e===null||this.zoom<=1)return;let s=this.focusCaps(),a=typeof s?.zoom?.min=="number"?Math.max(s.zoom.min,1):1;this.zoom=a,this.stats.zoomFallbackAtMs=Math.round(t-(this.positioningSince??t)),this.guideLock.reset(),this.gate.reset(),e.applyConstraints({advanced:[{zoom:a}]}).catch(()=>{})}offerShutter(t,e){this.shutterOffered||(this.shutterOffered=!0,this.stats.shutterAtMs=Math.round(e-(this.positioningSince??e)),this.stats.shutterReason=t,this.emit("shutter",{available:!0,reason:t}))}torchAvailable(){try{return this.stream?.getVideoTracks?.()[0]?.getCapabilities?.()?.torch===!0}catch{return!1}}async setTorch(t){this.torchOn=t;try{await this.stream?.getVideoTracks?.()[0]?.applyConstraints({advanced:[{torch:t}]})}catch{}}destroy(){if(this.attempt+=1,this.timer!==null&&(this.opts.clearTimer??clearTimeout)(this.timer),this.timer=null,this.clearFrameWatch(),this.offEnded?.(),this.offEnded=null,this.stream)for(let t of this.stream.getTracks())t.stop();this.stream=null,this.opts.video.srcObject=null}async upgradeResolution(){try{let t=this.stream?.getVideoTracks?.()[0];if(t===void 0)return;let e=t.getSettings?.()??{},s=Me(t.getCapabilities?.(),{width:e.width??0,height:e.height??0},this.deviceClass,{width:this.camera.width,height:this.camera.height},this.opts.ocr?.liveMrzOn===!0?{fill:this.guideRegion({width:1080,height:1920}).width}:void 0);s!==null&&(await t.applyConstraints(s),this.upgraded=!0)}catch{}}demote(t,e){if(this.tickCosts=null,this.deviceClass==="LOW"||(this.demotion={from:this.deviceClass,by:t,...e!==null?{tickMedianMs:Math.round(Math.min(6e4,e))}:{}},this.deviceClass="LOW",this.cadenceMs=1e3/Kt.LOW,!this.upgraded))return;this.upgraded=!1;let s=this.videoTrack();s!==null&&(this.guideLock.reset(),this.gate.reset(),s.applyConstraints({width:{ideal:Z.width},height:{ideal:Z.height}}).catch(()=>{}))}profileTick(t){if(this.deviceClass!=="LOW"&&this.opts.ocr?.tier==="low"){this.demote("ocr_tier",null);return}let e=this.tickCosts;if(e===null||(e.push(t),e.length<Ge))return;let s=[...e].sort((h,r)=>h-r),a=(s[s.length-1>>1]+s[s.length>>1])/2;a>Ne?this.demote("tick_cost",a):this.tickCosts=null}focusCaps(){try{return this.videoTrack()?.getCapabilities?.()??null}catch{return null}}async applyFocusAndZoom(){let t=this.videoTrack();if(t===null)return;let e=this.focusCaps();this.camera.continuousFocus&&$(e,"continuous")&&await t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{});let s={width:0,height:0};try{let h=t.getSettings?.()??{};s={width:h.width??0,height:h.height??0}}catch{}let a=Ce(e,s,this.opts.format??"ID-1",this.camera);if(a>1)try{await t.applyConstraints({advanced:[{zoom:a}]}),this.zoom=a}catch{this.zoom=1}}async focusAt(t,e){let s=this.videoTrack(),a=Ht(this.focusCaps(),t,e);if(!(s===null||a===null))try{await s.applyConstraints({advanced:[a]}),(this.opts.setTimer??setTimeout)(()=>{this.restoreContinuous()},1500)}catch{}}async restoreContinuous(){let t=this.videoTrack();t===null||!this.camera.continuousFocus||!$(this.focusCaps(),"continuous")||await t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{})}async refocusOn(t,e){let s=this.camera.refocusBeforePhotoMs,a=this.videoTrack();if(s<=0||a===null||e.width<=0||e.height<=0)return;let h=F(t),r=Ht(this.focusCaps(),(h.x+h.width/2)/e.width,(h.y+h.height/2)/e.height);if(r!==null)try{let o=this.opts.setTimer??setTimeout;await Promise.race([a.applyConstraints({advanced:[r]}),new Promise(n=>{o(()=>n(),Qe)})]),await new Promise(n=>{o(()=>n(),s)})}catch{}}videoTrack(){try{return this.stream?.getVideoTracks?.()[0]??null}catch{return null}}async takeStill(t,e,s){if(this.opts.captureStill!==void 0)return this.opts.captureStill(this.opts.video,t,e);let a=this.opts.format??"ID-1",h=this.videoTrack();if(s&&this.opts.photoCapture!==!1&&this.deviceClass!=="LOW"&&!this.photoOff&&!this.torchOn&&h!==null&&_e(h)){await this.refocusOn(t,e);let r=await De(this.opts.video,t,e,a,{track:h,detect:this.detector(),detectWidth:E});if(this.restoreContinuous(),r!==null)return r;this.photoOff=!0}return Te(this.opts.video,t,e,a)}detector(){return this.opts.detect??((this.opts.format??"ID-1")==="ID-3"?Ie:Oe)}setState(t){this.state=t,this.emit("statechange",{state:t})}scheduleTick(t){let e=this.opts.setTimer??setTimeout;this.timer=e(()=>{this.tick(t)},this.cadenceMs)}async tick(t){if(t!==this.attempt||this.state!=="positioning"||this.capturing)return;let e=this.opts.now??(()=>performance.now()),s=this.opts.grabDetectFrame??Vt,a=this.detector(),h=this.opts.workClock??(()=>performance.now()),r=h(),o=s(this.opts.video,E);if(o===null){this.scheduleTick(t);return}if(!this.lit){if(H(o)>Ee)this.lit=!0,this.blackTicks=0;else if(++this.blackTicks>=Ut&&this.frameWatch===null&&(this.opts.firstFrameMs??Qt)>0){this.cameraDead(t);return}}let n=null;try{n=await a(o)}catch{n=null}if(t!==this.attempt)return;let u=n!==null?C(o,n):o,l=e(),f={sharpness:D(u),exposure:wt(u),meanLuma:H(u),specularFraction:ce(u)},d=de({format:this.opts.format??"ID-1",quad:n,frameWidth:o.width,frameHeight:o.height,measures:f,...this.opts.thresholds!==void 0?{thresholds:this.opts.thresholds}:{}}),m=this.gate.tick({timestampMs:l,quad:n,quality:f,frameWidth:o.width,frameHeight:o.height}),w=(this.opts.format??"ID-1")!=="ID-3",p=w?St(o,this.guideRegion(o),At(this.guideTuning,this.zones)):bt,g=this.guideLock.tick(p,l,{torch:this.torchOn});this.lastGuideQuad=g.detected?_t(p):null,this.lastGuideCard=g.detected?{glare:p.cardGlare,sharpness:p.sharpness,glareZone:g.glareZone}:null;let v=g.detected&&g.glareZone!=="none",_=this.sideProbe(o,g.detected,p.fill,l),y=this.capturing?null:this.ocrTick(o,n,p,g.detected,d,l),W=g.detected&&(g.still||g.blocker==="locking")||n!==null&&m.stableTicks>=2;this.lastOcrReady?.via==="live_mrz"&&w&&!W&&(this.lastOcrReady=null);let b=w&&p.cardLight!=="scene"&&p.cardLuma!==void 0?U(p,this.guideTuning):n!==null?Rt(Q(u),this.guideTuning):w?U(p,this.guideTuning):Ft(Q(o),this.guideTuning);(b||v)&&(this.lastOcrReady=null),this.positioningSince??(this.positioningSince=l);let R=this.stats;if(R.ticks+=1,R.quadFraming[d.framing]=(R.quadFraming[d.framing]??0)+1,d.framing==="ok"&&!m.ready){let x=d.lighting!=="ok"?d.lighting:d.glare!=="ok"?"glare":d.blur!=="ok"?"blurry":"steadying";R.qualityBlockers[x]=(R.qualityBlockers[x]??0)+1}w&&Tt(p,g.detected,this.guideTuning)?this.weakEdgesSince??(this.weakEdgesSince=l):this.weakEdgesSince=null;let st=this.weakEdgesSince!==null&&l-this.weakEdgesSince>=this.guideTuning.weakEdgesHintMs,N=g.blocker==="dark"&&!b?"no_card":g.blocker,at=st?"surface":b&&N!=="glare"?"dark":N;R.guideBlockers[at]=(R.guideBlockers[at]??0)+1,n!==null||g.detected?(this.detectedSince??(this.detectedSince=l),this.lastSeenAt=l):this.detectedSince=null,this.lastSeenAt!==null&&l-this.lastSeenAt<=Xe?l-this.positioningSince>=this.shutterTuning.manualShutterMs?this.offerShutter("timeout",l):y?.suspendQuality!==!0&&this.detectedSince!==null&&l-this.detectedSince>=this.shutterTuning.detectedNoLockMs&&this.offerShutter("detected_no_lock",l):this.withdrawShutter();let ht=l-(this.lastSeenAt??this.positioningSince);this.zoom>1&&this.camera.zoomFallbackMs>0&&ht>=this.camera.zoomFallbackMs&&this.zoomFallback(l);let rt=!b&&!v&&(y?.suspendQuality!==!0&&(m.ready&&n!==null||g.ready&&this.lastGuideQuad!==null)||this.lastOcrReady!==null),ie=!rt&&!b&&!v&&y?.suspendQuality!==!0&&(g.detected&&g.blocker==="locking"||n!==null&&m.stableTicks>=2);this.emit("checks",{engine:"docv1",p:m.p,plausible:m.plausible,stableTicks:m.stableTicks,quad:m.quad,frameWidth:o.width,frameHeight:o.height,analysis:d,ready:rt,locking:ie,guide:{detected:g.detected,blocker:N,still:g.still,fill:p.fill,shape:p.shape,content:p.content,offsetX:p.offsetX,offsetY:p.offsetY},dark:b,...g.detected?{glareZone:g.glareZone}:{},...y!==null&&y.mode!=="off"?{ocr:{mode:y.mode,...y.mrz?{mrz:y.mrz}:{},...y.lock?{lock:y.lock}:{}}}:y?.mrz?{ocr:{mode:y.mode,mrz:y.mrz}}:{},..._!==void 0?{side:_}:{}}),this.lastQuad=m.plausible?n:null,this.lastDetect={width:o.width,height:o.height,tickSharpness:f.sharpness};let k=oe(d);d.framing!=="ok"&&g.detected&&(k=Ke(g.blocker,p.brightness<this.guideTuning.darkBrightness)),k==="blurry"&&n!==null&&Be(n,o,this.opts.format??"ID-1")>=this.camera.focusFarFillFrac&&(k="focus_far"),k==="sensing"&&this.zoom>1&&this.camera.noDocFarHintMs>0&&ht>=this.camera.noDocFarHintMs&&(k="focus_far"),st&&Ze.has(k)&&(k="low_contrast"),b&&k!=="glare"&&(k="too_dark");let ot=!v&&this.torchOn&&g.detected&&!b&&k==="hold_still";(v||ot)&&(k="glare");let q=ot&&this.lastFeedbackKey!=="glare"?this.feedback.force("glare",l):this.feedback.tick(k,l);q.key!==this.lastFeedbackKey&&(this.lastFeedbackKey=q.key,this.emit("feedback",q)),m.guidanceKey!==this.lastGuidance&&(this.lastGuidance=m.guidanceKey,this.emit("guidance",{key:m.guidanceKey}));let se=h()-r;if(this.stats.ticks>We&&this.profileTick(se),this.capturing)return;let nt=y?.suspendQuality!==!0&&!b&&!v,ae=nt&&m.ready&&n!==null,L=nt&&g.ready&&this.lastGuideQuad!==null,O=this.lastOcrReady;if(O!==null&&this.opts.autoCapture!==!1){let x=this.feedback.force("processing",l);this.lastFeedbackKey=x.key,this.emit("feedback",x);let I=D(C(o,O.quad));await this.fire(t,O.quad,{width:o.width,height:o.height,tickSharpness:I},O.via);return}if((ae||L)&&this.opts.autoCapture!==!1){let x=this.feedback.force("processing",l);this.lastFeedbackKey=x.key,this.emit("feedback",x);let I=L?this.lastGuideQuad:n,he=L?g.via==="steady"?"guide_steady":"guide_good":"quad",re=L?D(C(o,I)):f.sharpness;await this.fire(t,I,{width:o.width,height:o.height,tickSharpness:re},he);return}this.scheduleTick(t)}async fire(t,e,s,a){this.capturing=!0;let h=this.opts.grabDetectFrame??Vt,r=this.opts.setTimer??setTimeout,o={width:s.width,height:s.height},n=this.opts.workClock??(()=>performance.now()),u=n();try{let l={still:await this.takeStill(e,o,!0),sharpness:s.tickSharpness};if(t!==this.attempt)return;let f=l.still.source==="photo"||this.deviceClass==="LOW"?0:He;for(let p=0;p<f;p++){let g=n()-u;if(g+Xt+g/(p+1)>je)break;if(await new Promise(y=>{r(()=>y(),Xt)}),t!==this.attempt)return;let v=h(this.opts.video,E);if(v===null)continue;let _=D(C(v,e));if(_>l.sharpness*Ue){let y=await this.takeStill(e,o,!1);if(t!==this.attempt)return;l={still:y,sharpness:_}}}if(t!==this.attempt)return;let d=l.still.sharpness;if(this.opts.autoCapture!==!1&&a!=="manual"&&typeof d=="number"&&d>=0&&d<this.camera.stillSharpnessMin&&this.stillRefusals<this.camera.stillRefusalsMax){this.stillRefusals+=1,this.stats.stillRefusals+=1,this.guideLock.reset(),this.lastOcrReady=null,(a==="text_lock"||a==="live_mrz")&&this.opts.ocr?.rearmFace();let p=(this.opts.now??(()=>performance.now()))(),g=this.feedback.force("focus_far",p);this.lastFeedbackKey=g.key,this.emit("feedback",g),this.capturing=!1,this.gate.reset(),this.scheduleTick(t);return}this.stillRefusals=0;let m=(this.opts.now??(()=>performance.now()))();this.stats.via=a,this.stats.msToCapture=Math.round(m-(this.positioningSince??m));let w=this.lastGuideCard;w!==null&&(this.stats.shotGlare=Math.round(Math.min(1,Math.max(0,w.glare))*1e3)/1e3,this.stats.shotSharpness=Math.round(Math.min(1e6,Math.max(0,w.sharpness))),this.stats.shotGlareZone=w.glareZone),this.stats.shotTorch=this.torchOn,l.still.source!==void 0&&(this.stats.stillSource=l.still.source),this.lastStillAt!==null&&(this.stats.msSincePrevShot=Math.round(Math.min(36e5,Math.max(0,m-this.lastStillAt)))),this.lastStillAt=m,this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1})),this.setState("captured"),this.emit("artifacts",{keyframe:l.still.blob,previewDataUrl:l.still.previewDataUrl,...this.opts.side!==void 0?{side:this.opts.side}:{},...l.still.docRegion!==void 0?{docRegion:l.still.docRegion}:{},...(()=>{let p=a==="live_mrz"?this.opts.ocr?.liveCapture():null;return p?{liveMrz:p}:{}})()})}catch{if(t!==this.attempt)return;this.capturing=!1,this.gate.reset(),this.guideLock.reset(),this.lastOcrReady=null,(a==="text_lock"||a==="live_mrz")&&this.opts.ocr?.rearmFace(),this.scheduleTick(t)}}ocrTick(t,e,s,a,h,r){let o=this.opts.ocr,n=this.opts.video;if(o===void 0||!o.hasEngine)return this.lastOcrReady=null,null;let u=n.videoWidth,l=n.videoHeight;if(u<=0||l<=0||t.width<=0||t.height<=0)return null;let f=(this.opts.format??"ID-1")==="ID-3",d=this.guideRegion(t),m={x:d.x*u,y:d.y*l,w:d.width*u,h:d.height*l},w=u/t.width,p=l/t.height,g;f&&e!==null?g=qe(F(e),w,p,u,l):g=zt(m,o.bandTop,l);let v=f?h.glare==="ok":s.cardGlare<=this.guideTuning.glareMax,_=f?h.blur==="ok":s.sharpness>=this.guideTuning.sharpnessMin,y=o.tick({atMs:r,video:n,mrzFace:f||this.opts.side==="verso"||this.opts.side==="single",present:f||e!==null||a,card:m,band:g,portrait:l>u,glareOk:v,sharpOk:_});if(y.ready&&y.via!==void 0){let W=f?e??Zt(d,t):this.lastGuideQuad??Zt(d,t);this.lastOcrReady={quad:W,via:y.via}}else this.lastOcrReady=null;return y}},c(S,"i"),S);function qe(i,t,e,s,a){let h=Math.min(s,i.width*1.06*t),r=Math.min(a,Math.max(i.height*1.6*e,h/5)),o=(i.y+i.height/2)*e,n=Math.max(0,Math.min(s-h,(i.x-i.width*.03)*t)),u=Math.max(0,Math.min(a-r,o-r/2));return{x:n,y:u,w:h,h:r}}c(qe,"Ne");function Zt(i,t){let e=i.x*t.width,s=i.y*t.height,a=(i.x+i.width)*t.width,h=(i.y+i.height)*t.height;return{topLeft:{x:e,y:s},topRight:{x:a,y:s},bottomRight:{x:a,y:h},bottomLeft:{x:e,y:h}}}c(Zt,"de");function Be(i,t,e){let s=F(i);return t.width<=0||t.height<=0?0:e==="ID-3"?s.width/t.width:s.width*s.height/(t.width*t.height)}c(Be,"We");var He=2,Xt=260,je=1200,Qe=600,Ue=1.08,V=null;function Vt(i,t){let e=i.videoWidth,s=i.videoHeight;if(e===0||s===0)return null;let a=Math.min(1,t/e),h=Math.round(e*a),r=Math.round(s*a);V??(V=document.createElement("canvas"));let o=V;o.width!==h&&(o.width=h),o.height!==r&&(o.height=r);let n=o.getContext("2d",{willReadFrequently:!0});return n===null?null:(n.imageSmoothingQuality=e/Math.max(1,h)>4?"high":"low",n.drawImage(i,0,0,h,r),n.getImageData(0,0,h,r))}c(Vt,"fe");function C(i,t){let e=[t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x],s=[t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y],a=Math.max(0,Math.floor(Math.min(...e))),h=Math.max(0,Math.floor(Math.min(...s))),r=Math.min(i.width,Math.ceil(Math.max(...e))),o=Math.min(i.height,Math.ceil(Math.max(...s))),n=Math.max(1,r-a),u=Math.max(1,o-h),l=new Uint8ClampedArray(n*u*4);for(let f=0;f<u;f++){let d=((h+f)*i.width+a)*4;l.set(i.data.subarray(d,d+n*4),f*n*4)}return{data:l,width:n,height:u,colorSpace:i.colorSpace}}c(C,"R");function Ke(i,t){return i==="glare"?"glare":i==="too_small"?"too_far":i==="too_big"?"too_close":t?"too_dark":i==="blurry"?"blurry":i==="off_center"?"edge_clipped":i==="no_card"?"sensing":"hold_still"}c(Ke,"Ze");var Ze=new Set(["sensing","edge_clipped","wrong_shape","tilted"]),Xe=1200;export{hi as a,ri as b,Qt as c,Ee as d,Ut as e,Kt as f,Pe as g,Ge as h,We as i,Ne as j,et as k,oi as l,ni as m,qe as n,He as o,Xt as p,je as q,Qe as r};
|
|
1
|
+
import{a as E,b as It,c as Et,d as K,e as Pt}from"./chunk-5Y7NCFTK.js";import{c as Mt,d as kt,e as vt,i as bt,j as xt,k as St,l as Q,m as _t,n as Rt,o as Ft,p as U,q as Tt,r as Dt,s as At,v as Ct,y as zt}from"./chunk-XKZZC74I.js";import{c as Lt,d as Ot}from"./chunk-37BKUH3E.js";import{b as j,d as yt}from"./chunk-W5WWCOOW.js";import{d as lt,e as ft,f as pt}from"./chunk-GORELL4J.js";import{a as B,b as H,c as D,d as wt}from"./chunk-P7K7ELYZ.js";import{g as ct,i as ut,j as dt,k as mt,l as gt}from"./chunk-JS2IXPNL.js";import{a as c}from"./chunk-4FHWXBOB.js";var P=Object.freeze({sensing:{key:"sensing",reticle:"searching",minDurationMs:900},too_far:{key:"too_far",reticle:"coaching",minDurationMs:1400},too_close:{key:"too_close",reticle:"coaching",minDurationMs:1400},edge_clipped:{key:"edge_clipped",reticle:"coaching",minDurationMs:1400},wrong_shape:{key:"wrong_shape",reticle:"coaching",minDurationMs:1400},tilted:{key:"tilted",reticle:"coaching",minDurationMs:1400},too_dark:{key:"too_dark",reticle:"coaching",minDurationMs:1400},too_bright:{key:"too_bright",reticle:"coaching",minDurationMs:1400},blurry:{key:"blurry",reticle:"coaching",minDurationMs:1400},focus_far:{key:"focus_far",reticle:"coaching",minDurationMs:1600},low_contrast:{key:"low_contrast",reticle:"coaching",minDurationMs:1600},glare:{key:"glare",reticle:"coaching",minDurationMs:1400},hold_still:{key:"hold_still",reticle:"locking",minDurationMs:900},processing:{key:"processing",reticle:"processing",minDurationMs:800},side_captured:{key:"side_captured",reticle:"flip",minDurationMs:2600},captured:{key:"captured",reticle:"done",minDurationMs:800}});function oe(i){return i.framing==="no_document"?"sensing":i.framing==="too_far"?"too_far":i.framing==="too_close"?"too_close":i.framing==="edge_clipped"?"edge_clipped":i.framing==="wrong_shape"?"wrong_shape":i.framing==="tilted"?"tilted":i.lighting==="too_dark"?"too_dark":i.lighting==="too_bright"?"too_bright":i.glare==="glare"?"glare":i.blur==="blurry"?"blurry":"hold_still"}c(oe,"Bt");var T,ne=(T=class{constructor(t=2600,e=.35){this.windowMs=t,this.decayPerSecond=e,this.votes=[],this.current=P.sensing,this.currentSinceMs=null}reset(){this.votes=[],this.current=P.sensing,this.currentSinceMs=null}force(t,e){return this.votes=[],this.current=P[t],this.currentSinceMs=e,this.current}tick(t,e){if(this.currentSinceMs===null&&(this.currentSinceMs=e),this.votes.push({key:t,atMs:e}),this.votes=this.votes.filter(r=>e-r.atMs<=this.windowMs),e-this.currentSinceMs<this.current.minDurationMs)return this.current;let s=new Map;for(let r of this.votes){let o=(e-r.atMs)/1e3,n=this.decayPerSecond**o;s.set(r.key,(s.get(r.key)??0)+n)}let a=this.current.key,h=-1;for(let[r,o]of s)o>h&&(h=o,a=r);return a!==this.current.key&&(this.current=P[a],this.currentSinceMs=e),this.current}},c(T,"I"),T),le=Object.freeze({MAX_AREA_FRAC:.92,TILT_MAX_SIDE_RATIO:1.3,GLARE_MAX_SPECULAR_FRAC:.025});function ce(i){let{data:t,width:e,height:s}=i,a=e*s;if(a===0)return 0;let h=0;for(let r=0;r<a;r++){let o=r*4;.299*(t[o]??0)+.587*(t[o+1]??0)+.114*(t[o+2]??0)>=252&&h++}return h/a}c(ce,"Wt");function ue(i){let t=c((n,u)=>Math.hypot(u.x-n.x,u.y-n.y),"t"),e=t(i.topLeft,i.topRight),s=t(i.bottomLeft,i.bottomRight),a=t(i.topLeft,i.bottomLeft),h=t(i.topRight,i.bottomRight),r=Math.max(e,s)/Math.max(1e-6,Math.min(e,s)),o=Math.max(a,h)/Math.max(1e-6,Math.min(a,h));return Math.max(r,o)}c(ue,"De");function de(i){let t={...It,...i.thresholds},e=le,{quad:s,frameWidth:a,frameHeight:h,measures:r}=i,o=i.format==="ID-3",n="ok";if(s===null)n="no_document";else if(o){let d=K(s),m=a>0?d.width/a:0,w=d.height>0?d.width/d.height:0;m<t.ID3_BAND_MIN_WIDTH_FRAC?n="too_far":Gt(s,a,h,t.EDGE_CLIP_MARGIN_PX)?n="edge_clipped":(w<t.ID3_BAND_ASPECT_MIN||w>t.ID3_BAND_ASPECT_MAX)&&(n="wrong_shape")}else{let d=Et(s,a,h),m=K(s),w=Math.max(m.width,m.height)/Math.max(1e-6,Math.min(m.width,m.height));d<t.MIN_AREA_FRAC?n="too_far":d>e.MAX_AREA_FRAC?n="too_close":Gt(s,a,h,t.EDGE_CLIP_MARGIN_PX)?n="edge_clipped":Ot(i.format,w)?ue(s)>e.TILT_MAX_SIDE_RATIO&&(n="tilted"):n="wrong_shape"}let u=r.exposure>=t.GUIDE_EXPOSURE?"ok":r.meanLuma<(B[0]+B[1])/2?"too_dark":"too_bright",l=r.sharpness>=t.GUIDE_SHARPNESS?"ok":"blurry",f=r.specularFraction>=e.GLARE_MAX_SPECULAR_FRAC?"glare":"ok";return{framing:n,lighting:u,blur:l,glare:f,acceptable:n==="ok"&&u==="ok"&&l==="ok"&&f==="ok"}}c(de,"Ht");function Gt(i,t,e,s){return[i.topLeft,i.topRight,i.bottomRight,i.bottomLeft].some(a=>a.x<=s||a.y<=s||a.x>=t-s||a.y>=e-s)}c(Gt,"Nt");var Z=Object.freeze({width:1920,height:1080}),me=Object.freeze({width:3840,height:2160}),Wt=4096,ge=2560,fe=640,G=.15,A=Object.freeze({side:.2,above:.9,below:.3});function F(i){let t=[i.topLeft.x,i.topRight.x,i.bottomRight.x,i.bottomLeft.x],e=[i.topLeft.y,i.topRight.y,i.bottomRight.y,i.bottomLeft.y],s=Math.min(...t),a=Math.min(...e);return{x:s,y:a,width:Math.max(...t)-s,height:Math.max(...e)-a}}c(F,"v");function Yt(i,t){let e=Math.max(0,Math.floor(i.x)),s=Math.max(0,Math.floor(i.y)),a=Math.min(t.width,Math.ceil(i.x+i.width)),h=Math.min(t.height,Math.ceil(i.y+i.height));return a-e<16||h-s<16?null:{x:e,y:s,width:a-e,height:h-s}}c(Yt,"Vt");function pe(i,t,e){if(i===null||t.width<=0||t.height<=0)return null;let s=F(i);if(s.width<=0||s.height<=0)return null;let a=e==="ID-3"?{x:s.x-s.width*A.side,y:s.y-s.width*A.above,width:s.width*(1+2*A.side),height:s.height+s.width*(A.above+A.below)}:{x:s.x-s.width*G,y:s.y-s.height*G,width:s.width*(1+2*G),height:s.height*(1+2*G)};return Yt(a,t)}c(pe,"xe");function Jt(i,t,e){let s=Math.max(i,t);return s>0?Math.min(1,e/s):1}c(Jt,"J");function $t(i,t,e,s,a=ge){let h=t.width>0?e.width/t.width:1,r=t.height>0?e.height/t.height:1,o=i===null?null:{topLeft:{x:i.topLeft.x*h,y:i.topLeft.y*r},topRight:{x:i.topRight.x*h,y:i.topRight.y*r},bottomRight:{x:i.bottomRight.x*h,y:i.bottomRight.y*r},bottomLeft:{x:i.bottomLeft.x*h,y:i.bottomLeft.y*r}},n=pe(o,e,s)??{x:0,y:0,width:e.width,height:e.height},u=Jt(n.width,n.height,a),l=Math.max(1,Math.round(n.width*u)),f=Math.max(1,Math.round(n.height*u)),d=null;if(o!==null){let m=F(o);d=Yt({x:(m.x-n.x)*u,y:(m.y-n.y)*u,width:m.width*u,height:m.height*u},{width:l,height:f})}return{crop:n,width:l,height:f,docRegion:d}}c($t,"q");var we=960,X=[{width:1920,height:1080},{width:2560,height:1440}];function ye(i){let t=Number.isFinite(i)&&i>0?Math.min(1,i):.85;return X.find(e=>e.height*t>=we)??X[X.length-1]}c(ye,"Ce");function Me(i,t,e,s=me,a){if(e==="LOW")return null;let h=a===void 0?null:ye(a.fill),r=h!==null&&Math.max(h.width,h.height)>Math.max(s.width,s.height)?h:s,o=i?.width?.max,n=i?.height?.max;if(typeof o!="number"||typeof n!="number"||o<=0||n<=0)return null;let u=Math.max(o,n),l=Math.min(o,n),f=Math.min(u,Math.max(r.width,r.height)),d=Math.min(l,Math.min(r.width,r.height));return f<=Math.max(t.width,t.height)?null:{width:{ideal:f},height:{ideal:d}}}c(Me,"Zt");function ke(i){let t={},e=i?.imageWidth,s=i?.imageHeight;if(typeof e?.max=="number"&&e.max>0){let a=typeof s?.max=="number"&&s.max>0?e.max/s.max:1.3333333333333333,h=a>=1?Wt:Wt*a,r=Math.min(e.max,Math.floor(h)),o=typeof e.step=="number"&&e.step>0?e.step:1,n=typeof e.min=="number"?e.min:0;r=Math.max(n,n+Math.floor((r-n)/o)*o),t.imageWidth=r}return i?.fillLightMode?.includes("off")===!0&&(t.fillLightMode="off"),t}c(ke,"Xt");function ve(i,t){if(i.width<=0||i.height<=0||t.width<=0||t.height<=0)return!1;let e=i.width>i.height,s=t.width>t.height;return e!==s&&i.width!==i.height&&t.width!==t.height?!1:Math.max(i.width,i.height)>=1.2*Math.max(t.width,t.height)}c(ve,"jt");function be(i,t,e,s){if(e===null)return!1;let a=F(i),h=F(e);if(t.width<=0||s.width<=0)return!1;let r=a.width/t.width,o=h.width/s.width;return o>0&&r>=.6*o&&r<=1.25*o}c(be,"Yt");var Nt=3500,xe=.92;function te(){let i=globalThis.ImageCapture;return typeof i=="function"?i:null}c(te,"$t");function Se(i){return/AppleWebKit\//.test(i)&&!/(Chrome|Chromium|Edg|OPR)\//.test(i)}c(Se,"Re");function _e(i,t=typeof navigator>"u"?"":navigator.userAgent){return te()!==null&&!Se(t)&&i!=null&&i.kind==="video"&&i.readyState==="live"}c(_e,"te");function qt(i,t){return new Promise((e,s)=>{let a=setTimeout(()=>s(new Error("takePhoto timed out")),t);i.then(h=>{clearTimeout(a),e(h)},h=>{clearTimeout(a),s(h)})})}c(qt,"qt");function Y(i,t){let e=document.createElement("canvas");return e.width=i,e.height=t,e}c(Y,"$");function Re(i,t){return new Promise((e,s)=>{i.toBlob(a=>a?e(a):s(new Error("toBlob failed")),"image/jpeg",t)})}c(Re,"Fe");async function ee(i,t,e,s,a){let h=Y(e,s),r=Y(1,1);try{let o=h.getContext("2d");if(o===null)throw new Error("2d context unavailable");o.imageSmoothingQuality="high",o.drawImage(i,t.x,t.y,t.width,t.height,0,0,e,s);let n=await Re(h,xe),u=a===null?null:Mt({topLeft:{x:a.x,y:a.y},topRight:{x:a.x+a.width,y:a.y},bottomRight:{x:a.x+a.width,y:a.y+a.height},bottomLeft:{x:a.x,y:a.y+a.height}},{width:e,height:s},{width:e,height:s}),l=kt(h,u),f=Jt(e,s,fe);return r.width=Math.max(1,Math.round(e*f)),r.height=Math.max(1,Math.round(s*f)),r.getContext("2d")?.drawImage(h,0,0,r.width,r.height),{blob:n,previewDataUrl:r.toDataURL("image/jpeg",.85),sharpness:l}}finally{h.width=0,h.height=0,r.width=0,r.height=0}}c(ee,"ee");function Fe(i,t){let e=Math.min(1,t/i.width),s=Y(Math.max(1,Math.round(i.width*e)),Math.max(1,Math.round(i.height*e)));try{let a=s.getContext("2d",{willReadFrequently:!0});return a===null?null:(a.imageSmoothingQuality="high",a.drawImage(i,0,0,s.width,s.height),a.getImageData(0,0,s.width,s.height))}finally{s.width=0,s.height=0}}c(Fe,"Ae");async function Te(i,t,e,s){let a={width:Math.max(1,i.videoWidth),height:Math.max(1,i.videoHeight)},h=$t(t,e,a,s);return{...await ee(i,h.crop,h.width,h.height,h.docRegion),docRegion:h.docRegion,source:"video",width:h.width,height:h.height}}c(Te,"ie");async function De(i,t,e,s,a){let h=te();if(h===null)return null;let r=null;try{let o=new h(a.track),n=await qt(o.getPhotoCapabilities?.()??Promise.resolve({}),Nt).catch(()=>({})),u=await qt(o.takePhoto(ke(n)),Nt);r=await createImageBitmap(u);let l={width:i.videoWidth,height:i.videoHeight};if(!ve(r,l))return null;let f=Fe(r,a.detectWidth),d=null;f!==null&&t!==null&&(d=await a.detect(f).catch(()=>null));let m=f??{width:r.width,height:r.height};d!==null&&!be(d,m,t,e)&&(d=null);let w=$t(d,m,r,s);return{...await ee(r,w.crop,w.width,w.height,w.docRegion),docRegion:w.docRegion,source:"photo",width:w.width,height:w.height}}catch{return null}finally{r?.close()}}c(De,"oe");var it=Object.freeze({width:3840,height:2160,lensSelection:!0,continuousFocus:!0,refocusBeforePhotoMs:350,zoomMax:2,zoomNoFocusInfo:1.5,zoomMinSourcePx:2160,fillDistanceM:Object.freeze({id1:.11,id3:.15}),focusMarginFrac:.2,stillSharpnessMin:.16,stillRefusalsMax:2,focusFarFillFrac:.45,noDocFarHintMs:1500,zoomFallbackMs:8e3}),M=c((i,t,e)=>typeof i=="number"&&Number.isFinite(i)&&i>=t&&i<=e?i:void 0,"y");function hi(i){let t=it,e=i!==null&&typeof i=="object"?i:{},s=e.fillDistanceM!==null&&typeof e.fillDistanceM=="object"?e.fillDistanceM:{},a=c((h,r)=>typeof h=="boolean"?h:r,"s");return{width:M(e.width,640,7680)??t.width,height:M(e.height,480,4320)??t.height,lensSelection:a(e.lensSelection,t.lensSelection),continuousFocus:a(e.continuousFocus,t.continuousFocus),refocusBeforePhotoMs:M(e.refocusBeforePhotoMs,0,2e3)??t.refocusBeforePhotoMs,zoomMax:M(e.zoomMax,1,5)??t.zoomMax,zoomNoFocusInfo:M(e.zoomNoFocusInfo,1,5)??t.zoomNoFocusInfo,zoomMinSourcePx:M(e.zoomMinSourcePx,0,8e3)??t.zoomMinSourcePx,fillDistanceM:{id1:M(s.id1,.03,1)??t.fillDistanceM.id1,id3:M(s.id3,.03,1)??t.fillDistanceM.id3},focusMarginFrac:M(e.focusMarginFrac,0,2)??t.focusMarginFrac,stillSharpnessMin:M(e.stillSharpnessMin,0,10)??t.stillSharpnessMin,stillRefusalsMax:M(e.stillRefusalsMax,0,10)??t.stillRefusalsMax,focusFarFillFrac:M(e.focusFarFillFrac,0,1)??t.focusFarFillFrac,noDocFarHintMs:M(e.noDocFarHintMs,0,6e4)??t.noDocFarHintMs,zoomFallbackMs:M(e.zoomFallbackMs,0,12e4)??t.zoomFallbackMs}}c(hi,"ci");var J="sekyro.doc.camera";function Ae(){try{let i=globalThis.localStorage?.getItem(J);return typeof i=="string"&&i!==""?i:null}catch{return null}}c(Ae,"Ee");function Bt(i){try{i===null?globalThis.localStorage?.removeItem(J):globalThis.localStorage?.setItem(J,i)}catch{}}c(Bt,"se");var $=c((i,t)=>Array.isArray(i?.focusMode)&&i.focusMode.includes(t),"B");function Ht(i,t,e){if(!$(i,"single-shot"))return null;let s=c(a=>Math.min(1,Math.max(0,Number.isFinite(a)?a:.5)),"o");return{focusMode:"single-shot",pointsOfInterest:[{x:s(t),y:s(e)}]}}c(Ht,"it");function Ce(i,t,e,s=it){let a=i?.zoom?.min,h=i?.zoom?.max;if(typeof h!="number"||h<=1)return 1;let r=e==="ID-3"?s.fillDistanceM.id3:s.fillDistanceM.id1,o=i?.focusDistance?.min,n;if(typeof o=="number"&&o>0&&o<1){if(n=o*(1+s.focusMarginFrac)/r,n<=1.05)return 1}else{if(Math.min(t.width,t.height)<s.zoomMinSourcePx)return 1;n=s.zoomNoFocusInfo}let u=Math.min(n,s.zoomMax,h);typeof a=="number"&&(u=Math.max(u,a));let l=i?.zoom?.step;return typeof l=="number"&&l>0&&(u=Math.round(u/l)*l),u>1.01?Number(u.toFixed(2)):1}c(Ce,"re");function tt(i){try{return i.getVideoTracks?.()[0]}catch{return}}c(tt,"et");function jt(i){if(i!==null)for(let t of i.getTracks())t.stop()}c(jt,"ne");function ze(i){try{let t=tt(i)?.getCapabilities?.();return!Array.isArray(t?.focusMode)||t.focusMode.includes("continuous")}catch{return!0}}c(ze,"Le");async function Le(i){let t=c(h=>({audio:!1,video:{...h,width:{ideal:i.base.width},height:{ideal:i.base.height}}}),"t"),e=c(h=>i.getUserMedia(t({deviceId:{exact:h}})),"e"),s=c(()=>i.getUserMedia(t({facingMode:{ideal:"environment"}})),"o");if(i.lensSelection){let h=Ae();if(h!==null)try{return{stream:await e(h),lens:"stored"}}catch{Bt(null)}}let a=await s();if(!i.lensSelection||i.enumerateDevices===void 0)return{stream:a,lens:"default"};try{let h=gt(await i.enumerateDevices()).slice(0,3);if(h.length===0)return{stream:a,lens:"default"};let r=null;for(let o of h){let n=a!==null?tt(a)?.getSettings?.().deviceId:void 0;if(a===null||n!==o){jt(a),a=null;try{a=await e(o)}catch{continue}}if(r??(r=o),ze(a))return Bt(o),{stream:a,lens:"selected"}}if(a!==null&&r!==null&&tt(a)?.getSettings?.().deviceId===r)return{stream:a,lens:"selected"};if(jt(a),a=null,r!==null)try{return{stream:await e(r),lens:"selected"}}catch{}return{stream:await s(),lens:"default"}}catch{return{stream:a??await s(),lens:"default"}}}c(Le,"ae");var z=null;async function Oe(i){return z===null&&(z=(await import("./detector-scanic-3VQFGZAA-NF7AFUUP.js")).detectQuad),z(i)}c(Oe,"Pe");async function Ie(i){let t=j(i);return t===null?null:{topLeft:{x:t.x,y:t.y},topRight:{x:t.x+t.width,y:t.y},bottomRight:{x:t.x+t.width,y:t.y+t.height},bottomLeft:{x:t.x,y:t.y+t.height}}}c(Ie,"Oe");function ri(){z===null&&import("./detector-scanic-3VQFGZAA-NF7AFUUP.js").then(i=>{z=i.detectQuad}).catch(()=>{})}c(ri,"Fi");var Qt=4e3,Ee=2,Ut=3,Kt=Object.freeze({LOW:3,MID:5,HIGH:6}),Pe=600,Ge=8,We=3,Ne=90,et=Object.freeze({manualShutterMs:6e3,detectedNoLockMs:1950});function oi(i){let t=i!==null&&typeof i=="object"?i:{},e=c((s,a,h)=>typeof s=="number"&&Number.isFinite(s)&&s>=a&&s<=h?s:void 0,"e");return{manualShutterMs:e(t.manualShutterMs,1e3,6e4)??et.manualShutterMs,detectedNoLockMs:e(t.steadyMs,300,3e4)!==void 0?t.steadyMs+(e(t.lockMs,0,1e4)??450):et.detectedNoLockMs}}c(oi,"Ai");var S,ni=(S=class{constructor(t){this.upgraded=!1,this.tickCosts=[],this.photoOff=!1,this.demotion=null,this.torchOn=!1,this.stillRefusals=0,this.zoom=1,this.positioningSince=null,this.detectedSince=null,this.weakEdgesSince=null,this.lastSeenAt=null,this.lastGuideQuad=null,this.lastGuideCard=null,this.zones=[],this.lastStillAt=null,this.probeAt=null,this.lastOcrReady=null,this.shutterOffered=!1,this.stats=S.freshStats(),this.handlers=new Map,this.stream=null,this.timer=null,this.state="idle",this.lastGuidance=null,this.attempt=0,this.capturing=!1,this.feedback=new ne,this.lastFeedbackKey=null,this.lastQuad=null,this.lastDetect=null,this.frameWatch=null,this.reopened=!1,this.lit=!1,this.blackTicks=0,this.offEnded=null,this.opts=t,this.gate=new Pt(t.format??"ID-1",t.thresholds);let e=t.deviceClass??pt(ft());this.deviceClass=e,this.camera=t.camera??it,this.shutterTuning=t.shutter??et,this.guideTuning=t.guideLock??Dt,this.zones=t.zones??[],this.guideLock=new Ct(this.guideTuning),this.cadenceMs=1e3/Kt[e]}on(t,e){let s=this.handlers.get(t);return s||(s=new Set,this.handlers.set(t,s)),s.add(e),()=>s?.delete(e)}emit(t,e){for(let s of[...this.handlers.get(t)??[]])s(e)}async start(){let t=this.state==="error"?this.resumePlayback():null,e=++this.attempt;if(this.clearFrameWatch(),this.gate.reset(),this.resetSide(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.lit=!1,this.blackTicks=0,t!==null&&await t&&e===this.attempt){this.setState("positioning"),this.scheduleTick(e),this.watchFrames(e);return}if(e===this.attempt){this.releaseStream(),mt(),this.setState("preflight");try{let s=this.opts.getUserMedia??(r=>navigator.mediaDevices.getUserMedia(r));this.setState("acquiring");let a=this.opts.enumerateDevices??(this.opts.getUserMedia===void 0&&typeof navigator<"u"&&navigator.mediaDevices?.enumerateDevices?()=>navigator.mediaDevices.enumerateDevices():void 0),h=await Le({getUserMedia:s,...a!==void 0?{enumerateDevices:a}:{},lensSelection:this.camera.lensSelection,base:Z});if(e!==this.attempt){for(let r of h.stream.getTracks())r.stop();return}if(this.stream=h.stream,lt(this.stream),dt(this.stream),this.watchEnded(e),this.opts.upgradeResolution!==!1&&await this.upgradeResolution(),e!==this.attempt||(await this.applyFocusAndZoom(),e!==this.attempt)||(this.opts.video.srcObject=this.stream,await this.opts.video.play().catch(()=>{}),e!==this.attempt))return;this.setState("positioning"),this.scheduleTick(e),this.watchFrames(e)}catch(s){if(e!==this.attempt)return;let a=ut(s),h=ct(s);this.setState("error"),this.emit("error",{kind:a,retryable:!0,detail:h===void 0?{phase:"acquiring"}:{phase:"acquiring",name:h}})}}}resumePlayback(){let t=this.opts.video,e=this.videoTrack();if(this.stream===null||e===null||e.readyState!=="live"||t.srcObject!==this.stream)return null;try{return Promise.resolve(t.play()).then(()=>this.framesNow(),()=>!1)}catch{return null}}framesNow(){let t=this.opts.video;return this.opts.hasFrames!==void 0?this.opts.hasFrames(t):!t.paused&&t.readyState>=2&&t.videoWidth>0}watchFrames(t){let e=this.opts.firstFrameMs??Qt;e<=0||(this.clearFrameWatch(),this.frameWatch=setTimeout(()=>{if(this.frameWatch=null,!(t!==this.attempt||this.state!=="positioning")){if(this.framesNow()&&this.blackTicks<Ut){this.reopened=!1;return}this.cameraDead(t)}},e))}clearFrameWatch(){this.frameWatch!==null&&clearTimeout(this.frameWatch),this.frameWatch=null}watchEnded(t){this.offEnded?.(),this.offEnded=null;let e=this.videoTrack();if(e===null||typeof e.addEventListener!="function")return;let s=c(()=>{t===this.attempt&&(this.state==="positioning"||this.state==="acquiring")&&this.cameraDead(t)},"o");e.addEventListener("ended",s),this.offEnded=()=>e.removeEventListener?.("ended",s)}cameraDead(t){if(t!==this.attempt)return;let e=this.videoTrack(),s=e!==null&&e.readyState==="live"&&!e.muted&&this.opts.video.paused&&!this.framesNow();if(!s&&!this.reopened){this.reopened=!0,this.start();return}this.attempt+=1,this.timer!==null&&(this.opts.clearTimer??clearTimeout)(this.timer),this.timer=null,this.clearFrameWatch(),s||this.releaseStream(),this.reopened=!1,this.setState("error"),this.emit("error",{kind:"generic",retryable:!0,detail:{phase:"acquiring"}})}releaseStream(){if(this.offEnded?.(),this.offEnded=null,this.stream)for(let t of this.stream.getTracks())t.stop();this.stream=null,this.opts.video.srcObject!==null&&this.opts.video.srcObject!==void 0&&(this.opts.video.srcObject=null)}rearm(t){t!==void 0&&(this.opts.side=t),this.probeAt=null,this.gate.reset(),this.resetSide(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.stillRefusals=0,this.state==="captured"&&(this.setState("positioning"),this.scheduleTick(this.attempt))}async captureNow(){if(this.state!=="positioning"||this.capturing)return;let t=this.opts.video,e=this.lastDetect?.width??Math.max(1,t.videoWidth),s=this.lastDetect?.height??Math.max(1,t.videoHeight),a=this.lastQuad??this.lastGuideQuad??{topLeft:{x:0,y:0},topRight:{x:e,y:0},bottomRight:{x:e,y:s},bottomLeft:{x:0,y:s}},h=(this.opts.now??(()=>performance.now()))(),r=this.feedback.force("processing",h);this.lastFeedbackKey=r.key,this.emit("feedback",r),await this.fire(this.attempt,this.lastOcrReady!==null?this.lastOcrReady.quad:a,{width:e,height:s,tickSharpness:this.lastDetect?.tickSharpness??0},this.lastOcrReady?.via??"manual")}captureReport(){let t=this.stats;return{...this.opts.side!==void 0?{side:this.opts.side}:{},format:this.opts.format??"ID-1",deviceClass:this.deviceClass,video:{width:this.opts.video.videoWidth||0,height:this.opts.video.videoHeight||0},zoom:this.zoom,...t.zoomFallbackAtMs!==void 0?{zoomFallbackAtMs:t.zoomFallbackAtMs}:{},...t.msToCapture!==void 0?{msToCapture:t.msToCapture}:{},...t.via!==void 0?{via:t.via}:{},...t.shutterAtMs!==void 0?{shutterAtMs:t.shutterAtMs}:{},...t.shutterReason!==void 0?{shutterReason:t.shutterReason}:{},...t.shotGlare!==void 0?{shotGlare:t.shotGlare}:{},...t.shotSharpness!==void 0?{shotSharpness:t.shotSharpness}:{},...t.shotTorch!==void 0?{shotTorch:t.shotTorch}:{},...t.shotGlareZone!==void 0?{shotGlareZone:t.shotGlareZone}:{},...t.msSincePrevShot!==void 0?{msSincePrevShot:t.msSincePrevShot}:{},...t.stillSource!==void 0?{stillSource:t.stillSource}:{},...this.demotion!==null?{demotedFrom:this.demotion.from,demotedBy:this.demotion.by,...this.demotion.tickMedianMs!==void 0?{tickMedianMs:this.demotion.tickMedianMs}:{}}:{},ticks:t.ticks,quadFraming:{...t.quadFraming},qualityBlockers:{...t.qualityBlockers},guideBlockers:{...t.guideBlockers},stillRefusals:t.stillRefusals,...this.ocrReport()}}ocrReport(){let t=this.opts.ocr;if(t===void 0)return{};let e=(this.opts.format??"ID-1")==="ID-3"||this.opts.side==="single"?"single":this.opts.side==="verso"?"verso":"recto",s=t.report(e,this.stats.via,(this.opts.now??(()=>performance.now()))());return s===null?{}:{ocr:s}}static freshStats(){return{ticks:0,quadFraming:{},qualityBlockers:{},guideBlockers:{},stillRefusals:0}}setZones(t){this.zones=t??[]}setLockTuning(t){this.guideTuning=t,this.guideLock.setTuning(t)}setGuide(t){t===void 0?delete this.opts.guide:this.opts.guide=t,this.guideLock.reset(),this.probeAt=null}sideProbe(t,e,s,a){if(this.opts.sideProbe!==!0||!e)return;if(this.probeAt===null){this.probeAt=a;return}if(a-this.probeAt<Pe)return;this.probeAt=a;let h=this.guideRegion(t),r=h.x*t.width,o=h.y*t.height,n=h.width*t.width,u=h.height*t.height,l={topLeft:{x:r,y:o},topRight:{x:r+n,y:o},bottomRight:{x:r+n,y:o+u},bottomLeft:{x:r,y:o+u}};return vt(j,C(t,l),!0,s,!1,yt)==="verso"?"verso":"recto"}guideRegion(t){let e=t.width/Math.max(1,t.height),s=this.opts.guide;if(s!==void 0&&s.viewAspect>0){let o={width:s.viewAspect,height:1},n={x:s.rect.x*s.viewAspect,y:s.rect.y,width:s.rect.width*s.viewAspect,height:s.rect.height};return xt(o,n,e,0)}let a=Lt(this.opts.format??"ID-1").center,h=.86,r=h*e/a;return r>.84&&(r=.84,h=r*a/e),{x:(1-h)/2,y:(1-r)/2,width:h,height:r}}resetSide(){this.positioningSince=null,this.detectedSince=null,this.weakEdgesSince=null,this.lastSeenAt=null,this.guideLock.reset(),this.lastGuideQuad=null,this.lastGuideCard=null,this.lastOcrReady=null,this.opts.ocr?.reset(),this.stats=S.freshStats(),this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1}))}withdrawShutter(){this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1}))}zoomFallback(t){let e=this.videoTrack();if(e===null||this.zoom<=1)return;let s=this.focusCaps(),a=typeof s?.zoom?.min=="number"?Math.max(s.zoom.min,1):1;this.zoom=a,this.stats.zoomFallbackAtMs=Math.round(t-(this.positioningSince??t)),this.guideLock.reset(),this.gate.reset(),e.applyConstraints({advanced:[{zoom:a}]}).catch(()=>{})}offerShutter(t,e){this.shutterOffered||(this.shutterOffered=!0,this.stats.shutterAtMs=Math.round(e-(this.positioningSince??e)),this.stats.shutterReason=t,this.emit("shutter",{available:!0,reason:t}))}torchAvailable(){try{return this.stream?.getVideoTracks?.()[0]?.getCapabilities?.()?.torch===!0}catch{return!1}}async setTorch(t){this.torchOn=t;try{await this.stream?.getVideoTracks?.()[0]?.applyConstraints({advanced:[{torch:t}]})}catch{}}destroy(){if(this.attempt+=1,this.timer!==null&&(this.opts.clearTimer??clearTimeout)(this.timer),this.timer=null,this.clearFrameWatch(),this.offEnded?.(),this.offEnded=null,this.stream)for(let t of this.stream.getTracks())t.stop();this.stream=null,this.opts.video.srcObject=null}async upgradeResolution(){try{let t=this.stream?.getVideoTracks?.()[0];if(t===void 0)return;let e=t.getSettings?.()??{},s=Me(t.getCapabilities?.(),{width:e.width??0,height:e.height??0},this.deviceClass,{width:this.camera.width,height:this.camera.height},this.opts.ocr?.liveMrzOn===!0?{fill:this.guideRegion({width:1080,height:1920}).width}:void 0);s!==null&&(await t.applyConstraints(s),this.upgraded=!0)}catch{}}demote(t,e){if(this.tickCosts=null,this.deviceClass==="LOW"||(this.demotion={from:this.deviceClass,by:t,...e!==null?{tickMedianMs:Math.round(Math.min(6e4,e))}:{}},this.deviceClass="LOW",this.cadenceMs=1e3/Kt.LOW,!this.upgraded))return;this.upgraded=!1;let s=this.videoTrack();s!==null&&(this.guideLock.reset(),this.gate.reset(),s.applyConstraints({width:{ideal:Z.width},height:{ideal:Z.height}}).catch(()=>{}))}profileTick(t){if(this.deviceClass!=="LOW"&&this.opts.ocr?.tier==="low"){this.demote("ocr_tier",null);return}let e=this.tickCosts;if(e===null||(e.push(t),e.length<Ge))return;let s=[...e].sort((h,r)=>h-r),a=(s[s.length-1>>1]+s[s.length>>1])/2;a>Ne?this.demote("tick_cost",a):this.tickCosts=null}focusCaps(){try{return this.videoTrack()?.getCapabilities?.()??null}catch{return null}}async applyFocusAndZoom(){let t=this.videoTrack();if(t===null)return;let e=this.focusCaps();this.camera.continuousFocus&&$(e,"continuous")&&await t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{});let s={width:0,height:0};try{let h=t.getSettings?.()??{};s={width:h.width??0,height:h.height??0}}catch{}let a=Ce(e,s,this.opts.format??"ID-1",this.camera);if(a>1)try{await t.applyConstraints({advanced:[{zoom:a}]}),this.zoom=a}catch{this.zoom=1}}async focusAt(t,e){let s=this.videoTrack(),a=Ht(this.focusCaps(),t,e);if(!(s===null||a===null))try{await s.applyConstraints({advanced:[a]}),(this.opts.setTimer??setTimeout)(()=>{this.restoreContinuous()},1500)}catch{}}async restoreContinuous(){let t=this.videoTrack();t===null||!this.camera.continuousFocus||!$(this.focusCaps(),"continuous")||await t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{})}async refocusOn(t,e){let s=this.camera.refocusBeforePhotoMs,a=this.videoTrack();if(s<=0||a===null||e.width<=0||e.height<=0)return;let h=F(t),r=Ht(this.focusCaps(),(h.x+h.width/2)/e.width,(h.y+h.height/2)/e.height);if(r!==null)try{let o=this.opts.setTimer??setTimeout;await Promise.race([a.applyConstraints({advanced:[r]}),new Promise(n=>{o(()=>n(),Qe)})]),await new Promise(n=>{o(()=>n(),s)})}catch{}}videoTrack(){try{return this.stream?.getVideoTracks?.()[0]??null}catch{return null}}async takeStill(t,e,s){if(this.opts.captureStill!==void 0)return this.opts.captureStill(this.opts.video,t,e);let a=this.opts.format??"ID-1",h=this.videoTrack();if(s&&this.opts.photoCapture!==!1&&this.deviceClass!=="LOW"&&!this.photoOff&&!this.torchOn&&h!==null&&_e(h)){await this.refocusOn(t,e);let r=await De(this.opts.video,t,e,a,{track:h,detect:this.detector(),detectWidth:E});if(this.restoreContinuous(),r!==null)return r;this.photoOff=!0}return Te(this.opts.video,t,e,a)}detector(){return this.opts.detect??((this.opts.format??"ID-1")==="ID-3"?Ie:Oe)}setState(t){this.state=t,this.emit("statechange",{state:t})}scheduleTick(t){let e=this.opts.setTimer??setTimeout;this.timer=e(()=>{this.tick(t)},this.cadenceMs)}async tick(t){if(t!==this.attempt||this.state!=="positioning"||this.capturing)return;let e=this.opts.now??(()=>performance.now()),s=this.opts.grabDetectFrame??Vt,a=this.detector(),h=this.opts.workClock??(()=>performance.now()),r=h(),o=s(this.opts.video,E);if(o===null){this.scheduleTick(t);return}if(!this.lit){if(H(o)>Ee)this.lit=!0,this.blackTicks=0;else if(++this.blackTicks>=Ut&&this.frameWatch===null&&(this.opts.firstFrameMs??Qt)>0){this.cameraDead(t);return}}let n=null;try{n=await a(o)}catch{n=null}if(t!==this.attempt)return;let u=n!==null?C(o,n):o,l=e(),f={sharpness:D(u),exposure:wt(u),meanLuma:H(u),specularFraction:ce(u)},d=de({format:this.opts.format??"ID-1",quad:n,frameWidth:o.width,frameHeight:o.height,measures:f,...this.opts.thresholds!==void 0?{thresholds:this.opts.thresholds}:{}}),m=this.gate.tick({timestampMs:l,quad:n,quality:f,frameWidth:o.width,frameHeight:o.height}),w=(this.opts.format??"ID-1")!=="ID-3",p=w?St(o,this.guideRegion(o),At(this.guideTuning,this.zones)):bt,g=this.guideLock.tick(p,l,{torch:this.torchOn});this.lastGuideQuad=g.detected?_t(p):null,this.lastGuideCard=g.detected?{glare:p.cardGlare,sharpness:p.sharpness,glareZone:g.glareZone}:null;let v=g.detected&&g.glareZone!=="none",_=this.sideProbe(o,g.detected,p.fill,l),y=this.capturing?null:this.ocrTick(o,n,p,g.detected,d,l),W=g.detected&&(g.still||g.blocker==="locking")||n!==null&&m.stableTicks>=2;this.lastOcrReady?.via==="live_mrz"&&w&&!W&&(this.lastOcrReady=null);let b=w&&p.cardLight!=="scene"&&p.cardLuma!==void 0?U(p,this.guideTuning):n!==null?Rt(Q(u),this.guideTuning):w?U(p,this.guideTuning):Ft(Q(o),this.guideTuning);(b||v)&&(this.lastOcrReady=null),this.positioningSince??(this.positioningSince=l);let R=this.stats;if(R.ticks+=1,R.quadFraming[d.framing]=(R.quadFraming[d.framing]??0)+1,d.framing==="ok"&&!m.ready){let x=d.lighting!=="ok"?d.lighting:d.glare!=="ok"?"glare":d.blur!=="ok"?"blurry":"steadying";R.qualityBlockers[x]=(R.qualityBlockers[x]??0)+1}w&&Tt(p,g.detected,this.guideTuning)?this.weakEdgesSince??(this.weakEdgesSince=l):this.weakEdgesSince=null;let st=this.weakEdgesSince!==null&&l-this.weakEdgesSince>=this.guideTuning.weakEdgesHintMs,N=g.blocker==="dark"&&!b?"no_card":g.blocker,at=st?"surface":b&&N!=="glare"?"dark":N;R.guideBlockers[at]=(R.guideBlockers[at]??0)+1,n!==null||g.detected?(this.detectedSince??(this.detectedSince=l),this.lastSeenAt=l):this.detectedSince=null,this.lastSeenAt!==null&&l-this.lastSeenAt<=Xe?l-this.positioningSince>=this.shutterTuning.manualShutterMs?this.offerShutter("timeout",l):y?.suspendQuality!==!0&&this.detectedSince!==null&&l-this.detectedSince>=this.shutterTuning.detectedNoLockMs&&this.offerShutter("detected_no_lock",l):this.withdrawShutter();let ht=l-(this.lastSeenAt??this.positioningSince);this.zoom>1&&this.camera.zoomFallbackMs>0&&ht>=this.camera.zoomFallbackMs&&this.zoomFallback(l);let rt=!b&&!v&&(y?.suspendQuality!==!0&&(m.ready&&n!==null||g.ready&&this.lastGuideQuad!==null)||this.lastOcrReady!==null),ie=!rt&&!b&&!v&&y?.suspendQuality!==!0&&(g.detected&&g.blocker==="locking"||n!==null&&m.stableTicks>=2);this.emit("checks",{engine:"docv1",p:m.p,plausible:m.plausible,stableTicks:m.stableTicks,quad:m.quad,frameWidth:o.width,frameHeight:o.height,analysis:d,ready:rt,locking:ie,guide:{detected:g.detected,blocker:N,still:g.still,fill:p.fill,shape:p.shape,content:p.content,offsetX:p.offsetX,offsetY:p.offsetY},dark:b,...g.detected?{glareZone:g.glareZone}:{},...y!==null&&y.mode!=="off"?{ocr:{mode:y.mode,...y.mrz?{mrz:y.mrz}:{},...y.lock?{lock:y.lock}:{}}}:y?.mrz?{ocr:{mode:y.mode,mrz:y.mrz}}:{},..._!==void 0?{side:_}:{}}),this.lastQuad=m.plausible?n:null,this.lastDetect={width:o.width,height:o.height,tickSharpness:f.sharpness};let k=oe(d);d.framing!=="ok"&&g.detected&&(k=Ke(g.blocker,p.brightness<this.guideTuning.darkBrightness)),k==="blurry"&&n!==null&&Be(n,o,this.opts.format??"ID-1")>=this.camera.focusFarFillFrac&&(k="focus_far"),k==="sensing"&&this.zoom>1&&this.camera.noDocFarHintMs>0&&ht>=this.camera.noDocFarHintMs&&(k="focus_far"),st&&Ze.has(k)&&(k="low_contrast"),b&&k!=="glare"&&(k="too_dark");let ot=!v&&this.torchOn&&g.detected&&!b&&k==="hold_still";(v||ot)&&(k="glare");let q=ot&&this.lastFeedbackKey!=="glare"?this.feedback.force("glare",l):this.feedback.tick(k,l);q.key!==this.lastFeedbackKey&&(this.lastFeedbackKey=q.key,this.emit("feedback",q)),m.guidanceKey!==this.lastGuidance&&(this.lastGuidance=m.guidanceKey,this.emit("guidance",{key:m.guidanceKey}));let se=h()-r;if(this.stats.ticks>We&&this.profileTick(se),this.capturing)return;let nt=y?.suspendQuality!==!0&&!b&&!v,ae=nt&&m.ready&&n!==null,L=nt&&g.ready&&this.lastGuideQuad!==null,O=this.lastOcrReady;if(O!==null&&this.opts.autoCapture!==!1){let x=this.feedback.force("processing",l);this.lastFeedbackKey=x.key,this.emit("feedback",x);let I=D(C(o,O.quad));await this.fire(t,O.quad,{width:o.width,height:o.height,tickSharpness:I},O.via);return}if((ae||L)&&this.opts.autoCapture!==!1){let x=this.feedback.force("processing",l);this.lastFeedbackKey=x.key,this.emit("feedback",x);let I=L?this.lastGuideQuad:n,he=L?g.via==="steady"?"guide_steady":"guide_good":"quad",re=L?D(C(o,I)):f.sharpness;await this.fire(t,I,{width:o.width,height:o.height,tickSharpness:re},he);return}this.scheduleTick(t)}async fire(t,e,s,a){this.capturing=!0;let h=this.opts.grabDetectFrame??Vt,r=this.opts.setTimer??setTimeout,o={width:s.width,height:s.height},n=this.opts.workClock??(()=>performance.now()),u=n();try{let l={still:await this.takeStill(e,o,!0),sharpness:s.tickSharpness};if(t!==this.attempt)return;let f=l.still.source==="photo"||this.deviceClass==="LOW"?0:He;for(let p=0;p<f;p++){let g=n()-u;if(g+Xt+g/(p+1)>je)break;if(await new Promise(y=>{r(()=>y(),Xt)}),t!==this.attempt)return;let v=h(this.opts.video,E);if(v===null)continue;let _=D(C(v,e));if(_>l.sharpness*Ue){let y=await this.takeStill(e,o,!1);if(t!==this.attempt)return;l={still:y,sharpness:_}}}if(t!==this.attempt)return;let d=l.still.sharpness;if(this.opts.autoCapture!==!1&&a!=="manual"&&typeof d=="number"&&d>=0&&d<this.camera.stillSharpnessMin&&this.stillRefusals<this.camera.stillRefusalsMax){this.stillRefusals+=1,this.stats.stillRefusals+=1,this.guideLock.reset(),this.lastOcrReady=null,(a==="text_lock"||a==="live_mrz")&&this.opts.ocr?.rearmFace();let p=(this.opts.now??(()=>performance.now()))(),g=this.feedback.force("focus_far",p);this.lastFeedbackKey=g.key,this.emit("feedback",g),this.capturing=!1,this.gate.reset(),this.scheduleTick(t);return}this.stillRefusals=0;let m=(this.opts.now??(()=>performance.now()))();this.stats.via=a,this.stats.msToCapture=Math.round(m-(this.positioningSince??m));let w=this.lastGuideCard;w!==null&&(this.stats.shotGlare=Math.round(Math.min(1,Math.max(0,w.glare))*1e3)/1e3,this.stats.shotSharpness=Math.round(Math.min(1e6,Math.max(0,w.sharpness))),this.stats.shotGlareZone=w.glareZone),this.stats.shotTorch=this.torchOn,l.still.source!==void 0&&(this.stats.stillSource=l.still.source),this.lastStillAt!==null&&(this.stats.msSincePrevShot=Math.round(Math.min(36e5,Math.max(0,m-this.lastStillAt)))),this.lastStillAt=m,this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1})),this.setState("captured"),this.emit("artifacts",{keyframe:l.still.blob,previewDataUrl:l.still.previewDataUrl,...this.opts.side!==void 0?{side:this.opts.side}:{},...l.still.docRegion!==void 0?{docRegion:l.still.docRegion}:{},...(()=>{let p=a==="live_mrz"?this.opts.ocr?.liveCapture():null;return p?{liveMrz:p}:{}})()})}catch{if(t!==this.attempt)return;this.capturing=!1,this.gate.reset(),this.guideLock.reset(),this.lastOcrReady=null,(a==="text_lock"||a==="live_mrz")&&this.opts.ocr?.rearmFace(),this.scheduleTick(t)}}ocrTick(t,e,s,a,h,r){let o=this.opts.ocr,n=this.opts.video;if(o===void 0||!o.hasEngine)return this.lastOcrReady=null,null;let u=n.videoWidth,l=n.videoHeight;if(u<=0||l<=0||t.width<=0||t.height<=0)return null;let f=(this.opts.format??"ID-1")==="ID-3",d=this.guideRegion(t),m={x:d.x*u,y:d.y*l,w:d.width*u,h:d.height*l},w=u/t.width,p=l/t.height,g;f&&e!==null?g=qe(F(e),w,p,u,l):g=zt(m,o.bandTop,l);let v=f?h.glare==="ok":s.cardGlare<=this.guideTuning.glareMax,_=f?h.blur==="ok":s.sharpness>=this.guideTuning.sharpnessMin,y=o.tick({atMs:r,video:n,mrzFace:f||this.opts.side==="verso"||this.opts.side==="single",present:f||e!==null||a,card:m,band:g,portrait:l>u,glareOk:v,sharpOk:_});if(y.ready&&y.via!==void 0){let W=f?e??Zt(d,t):this.lastGuideQuad??Zt(d,t);this.lastOcrReady={quad:W,via:y.via}}else this.lastOcrReady=null;return y}},c(S,"i"),S);function qe(i,t,e,s,a){let h=Math.min(s,i.width*1.06*t),r=Math.min(a,Math.max(i.height*1.6*e,h/5)),o=(i.y+i.height/2)*e,n=Math.max(0,Math.min(s-h,(i.x-i.width*.03)*t)),u=Math.max(0,Math.min(a-r,o-r/2));return{x:n,y:u,w:h,h:r}}c(qe,"Ne");function Zt(i,t){let e=i.x*t.width,s=i.y*t.height,a=(i.x+i.width)*t.width,h=(i.y+i.height)*t.height;return{topLeft:{x:e,y:s},topRight:{x:a,y:s},bottomRight:{x:a,y:h},bottomLeft:{x:e,y:h}}}c(Zt,"de");function Be(i,t,e){let s=F(i);return t.width<=0||t.height<=0?0:e==="ID-3"?s.width/t.width:s.width*s.height/(t.width*t.height)}c(Be,"We");var He=2,Xt=260,je=1200,Qe=600,Ue=1.08,V=null;function Vt(i,t){let e=i.videoWidth,s=i.videoHeight;if(e===0||s===0)return null;let a=Math.min(1,t/e),h=Math.round(e*a),r=Math.round(s*a);V??(V=document.createElement("canvas"));let o=V;o.width!==h&&(o.width=h),o.height!==r&&(o.height=r);let n=o.getContext("2d",{willReadFrequently:!0});return n===null?null:(n.imageSmoothingQuality=e/Math.max(1,h)>4?"high":"low",n.drawImage(i,0,0,h,r),n.getImageData(0,0,h,r))}c(Vt,"fe");function C(i,t){let e=[t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x],s=[t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y],a=Math.max(0,Math.floor(Math.min(...e))),h=Math.max(0,Math.floor(Math.min(...s))),r=Math.min(i.width,Math.ceil(Math.max(...e))),o=Math.min(i.height,Math.ceil(Math.max(...s))),n=Math.max(1,r-a),u=Math.max(1,o-h),l=new Uint8ClampedArray(n*u*4);for(let f=0;f<u;f++){let d=((h+f)*i.width+a)*4;l.set(i.data.subarray(d,d+n*4),f*n*4)}return{data:l,width:n,height:u,colorSpace:i.colorSpace}}c(C,"R");function Ke(i,t){return i==="glare"?"glare":i==="too_small"?"too_far":i==="too_big"?"too_close":t?"too_dark":i==="blurry"?"blurry":i==="off_center"?"edge_clipped":i==="no_card"?"sensing":"hold_still"}c(Ke,"Ze");var Ze=new Set(["sensing","edge_clipped","wrong_shape","tilted"]),Xe=1200;export{hi as a,ri as b,Qt as c,Ee as d,Ut as e,Kt as f,Pe as g,Ge as h,We as i,Ne as j,et as k,oi as l,ni as m,qe as n,He as o,Xt as p,je as q,Qe as r};
|