@sekyro/elements 0.1.0-rc.23 → 0.1.0-rc.24
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 +15 -0
- package/dist/cdn/chunks/capture-session-doc-BGLEMR2J-LN5RQDCK.js +1 -0
- package/dist/cdn/chunks/challenge-frame-3JHCNDHE-IYU6HGYD.js +1 -0
- package/dist/cdn/chunks/{chunk-NGWIL3RI.js → chunk-6JA64VAB.js} +1 -1
- package/dist/cdn/chunks/{chunk-4RREQCYP.js → chunk-75QP4SUF.js} +1 -1
- package/dist/cdn/chunks/chunk-7UCVVWRT.js +1 -0
- package/dist/cdn/chunks/{chunk-BZCLR3ZW.js → chunk-BE4SRRNK.js} +1 -1
- package/dist/cdn/chunks/chunk-CCPSNJ26.js +1 -0
- package/dist/cdn/chunks/chunk-EAHT3Y3Z.js +1 -0
- package/dist/cdn/chunks/chunk-F6BL7IXJ.js +1 -0
- package/dist/cdn/chunks/{chunk-QFCNXANK.js → chunk-H4EO527J.js} +1 -1
- package/dist/cdn/chunks/chunk-HBIVE2ZZ.js +33 -0
- package/dist/cdn/chunks/{chunk-TCXBCGZF.js → chunk-HPTAAPIB.js} +1 -1
- package/dist/cdn/chunks/chunk-ICGDGBER.js +1 -0
- package/dist/cdn/chunks/{chunk-POVLMWGM.js → chunk-IX5EXDOC.js} +1 -1
- package/dist/cdn/chunks/{chunk-HM5EP25H.js → chunk-L2FCXJYM.js} +1 -1
- package/dist/cdn/chunks/{chunk-HHBISLBD.js → chunk-MXKAKHUA.js} +1 -1
- package/dist/cdn/chunks/chunk-QVU5SNFG.js +25 -0
- package/dist/cdn/chunks/{chunk-PXF2CWO3.js → chunk-SGAGSEY4.js} +1 -1
- package/dist/cdn/chunks/{chunk-RVPBL3KC.js → chunk-SX373VNU.js} +1 -1
- package/dist/cdn/chunks/{chunk-MLNUIPVU.js → chunk-TD2XP34G.js} +1 -1
- package/dist/cdn/chunks/{chunk-B7JVGTNG.js → chunk-UJ2FDGWQ.js} +1 -1
- package/dist/cdn/chunks/{chunk-RCDZUOGM.js → chunk-VHJIEZ5D.js} +1 -1
- package/dist/cdn/chunks/chunk-W5WWCOOW.js +1 -0
- package/dist/cdn/chunks/{chunk-UMGCNKDP.js → chunk-X7U4LD32.js} +1 -1
- package/dist/cdn/chunks/chunk-XXYPLLFI.js +3 -0
- package/dist/cdn/chunks/{chunk-ZWC7BGLD.js → chunk-YFZ54VRE.js} +1 -1
- package/dist/cdn/chunks/create-document-capture-KATGPNCR-KPF7ZYWX.js +1 -0
- package/dist/cdn/chunks/document-capture-view-PTB5A72I-LW2M5LK2.js +1 -0
- package/dist/cdn/chunks/{eid-view-FEJHQBSB-YSYB6LNM.js → eid-view-B2M6AJ3J-ASEHPZBH.js} +1 -1
- package/dist/cdn/chunks/{email-otp-view-4EY5CKR5-QMWJOSCD.js → email-otp-view-FLSDWKJU-TQOH44CO.js} +1 -1
- package/dist/cdn/chunks/flow-views-UZRN6BIU-HPYJIEOF.js +1 -0
- package/dist/cdn/chunks/form-view-26PNMO6Q-DNIJNLLU.js +1 -0
- package/dist/cdn/chunks/icons-form-R366YPMB-6C7SJPCB.js +1 -0
- package/dist/cdn/chunks/mrz-band-IH54XO42-AE4D3F2E.js +1 -0
- package/dist/cdn/chunks/overlay-de-TP7ROFVF-5EEFWZ4E.js +1 -0
- package/dist/cdn/chunks/overlay-es-LLTS3D6J-U2DPYDC2.js +1 -0
- package/dist/cdn/chunks/overlay-pt-UUJUOJNJ-E57Q5MWT.js +1 -0
- package/dist/cdn/chunks/plan-runner-XGT4VKVF-NDQH73OS.js +1 -0
- package/dist/cdn/chunks/{portrait-capture-view-Q6XYTGE7-BL2EYATL.js → portrait-capture-view-IFT7B4OG-EYDBLNTC.js} +1 -1
- package/dist/cdn/chunks/{portrait-review-view-KZVKR6XN-QEZYASJF.js → portrait-review-view-BISWT5BQ-YJ6TLEKW.js} +1 -1
- package/dist/cdn/chunks/{proof-of-address-view-YYZTILHQ-BVR6FUOS.js → proof-of-address-view-UXF6OH5N-6HTCJNXW.js} +1 -1
- package/dist/cdn/define.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/{chunk-L2F6LQ7G.js → chunk-2N6CQWVG.js} +1 -1
- package/dist/{chunk-3J5LUPKY.js → chunk-73G4CDPH.js} +1 -1
- package/dist/chunk-CO3QPDWV.js +25 -0
- package/dist/{chunk-OAQM45LZ.js → chunk-DEVOHXNC.js} +1 -1
- package/dist/chunk-HBK2ROSI.js +1 -0
- package/dist/{chunk-ZBTWLEPS.js → chunk-L5QAOX6C.js} +1 -1
- package/dist/chunk-NEP66INV.js +33 -0
- package/dist/{chunk-APMABLNO.js → chunk-QLIY4W2U.js} +1 -1
- package/dist/{chunk-PEFS2JPA.js → chunk-R7M4HNG5.js} +1 -1
- package/dist/chunk-S5CM7A4T.js +1 -0
- package/dist/{chunk-ZTBXWO2O.js → chunk-TPO4FOFT.js} +1 -1
- package/dist/{chunk-XZZPJ2FQ.js → chunk-VK6DRWZL.js} +1 -1
- package/dist/{chunk-TEJOSW5W.js → chunk-VWAWL2QM.js} +1 -1
- package/dist/{chunk-5KU4GIMW.js → chunk-W6RHH3ZZ.js} +1 -1
- package/dist/{chunk-NHOIIIGP.js → chunk-YD6JLLO5.js} +1 -1
- package/dist/define.cjs +5 -5
- package/dist/define.js +1 -1
- package/dist/document-capture-view-PTB5A72I-J2XPPS5A.js +1 -0
- package/dist/{eid-view-FEJHQBSB-NDFXLUCN.js → eid-view-B2M6AJ3J-ASHVXRTP.js} +1 -1
- package/dist/{email-otp-view-4EY5CKR5-PXH6WYZN.js → email-otp-view-FLSDWKJU-3KB6CCWB.js} +1 -1
- package/dist/{flow-views-JC2DWBW3-YYRQOY3A.js → flow-views-UZRN6BIU-SEDEA5AH.js} +1 -1
- package/dist/form-view-26PNMO6Q-6W54V6CN.js +1 -0
- package/dist/icons-form-R366YPMB-KUTXHC7X.js +1 -0
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +1 -1
- package/dist/overlay-de-TP7ROFVF-5EB3LXPD.js +1 -0
- package/dist/overlay-es-LLTS3D6J-4M7PVHUX.js +1 -0
- package/dist/overlay-pt-UUJUOJNJ-LDRAURGT.js +1 -0
- package/dist/{portrait-capture-view-Q6XYTGE7-VKH2G5FA.js → portrait-capture-view-IFT7B4OG-RA2APHRL.js} +1 -1
- package/dist/{portrait-review-view-KZVKR6XN-RIAO3V65.js → portrait-review-view-BISWT5BQ-HV4F6WC7.js} +1 -1
- package/dist/{proof-of-address-view-YYZTILHQ-7OJWBD3P.js → proof-of-address-view-UXF6OH5N-4HTOLYIT.js} +1 -1
- package/dist/styles.css +40 -0
- package/package.json +2 -2
- package/sbom.cdx.json +4 -4
- package/dist/cdn/chunks/capture-session-doc-ENDGVJ3L-IMAPC36N.js +0 -1
- package/dist/cdn/chunks/challenge-frame-FGQBS3HD-S3UO5OUT.js +0 -1
- package/dist/cdn/chunks/chunk-BG7ZLMF3.js +0 -1
- package/dist/cdn/chunks/chunk-CUFOLAZN.js +0 -25
- package/dist/cdn/chunks/chunk-FUMXKBXY.js +0 -3
- package/dist/cdn/chunks/chunk-HHII35OF.js +0 -1
- package/dist/cdn/chunks/chunk-LSBUNQZU.js +0 -1
- package/dist/cdn/chunks/chunk-NNIK6RGK.js +0 -1
- package/dist/cdn/chunks/chunk-NU2VUYVN.js +0 -1
- package/dist/cdn/chunks/chunk-PSLOZIUH.js +0 -33
- package/dist/cdn/chunks/create-document-capture-SZ4SIVVC-P4MMZXVZ.js +0 -1
- package/dist/cdn/chunks/document-capture-view-ZQONDCSM-CX2F54ZS.js +0 -1
- package/dist/cdn/chunks/flow-views-JC2DWBW3-GP5F4777.js +0 -1
- package/dist/cdn/chunks/form-view-GPITA6X5-YDYPXP7W.js +0 -1
- package/dist/cdn/chunks/mrz-band-A6NIHZV3-GJO4UMKB.js +0 -1
- package/dist/cdn/chunks/overlay-de-7NCDPEIN-KI2BS6I6.js +0 -1
- package/dist/cdn/chunks/overlay-es-6MGCPCFO-CYCUQRCB.js +0 -1
- package/dist/cdn/chunks/overlay-pt-VTK6XJDH-VFNANCPU.js +0 -1
- package/dist/cdn/chunks/plan-runner-MC6KC7PK-E55J5SPN.js +0 -1
- package/dist/chunk-AVSVM522.js +0 -25
- package/dist/chunk-GDJMAPFB.js +0 -33
- package/dist/chunk-QNR2GBZ5.js +0 -1
- package/dist/document-capture-view-ZQONDCSM-HUO7JCZZ.js +0 -1
- package/dist/form-view-GPITA6X5-VZF6Y2HM.js +0 -1
- package/dist/overlay-de-7NCDPEIN-BWTDIED4.js +0 -1
- package/dist/overlay-es-6MGCPCFO-SV56NQSV.js +0 -1
- package/dist/overlay-pt-VTK6XJDH-IWQLAZ7L.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @sekyro/elements
|
|
2
2
|
|
|
3
|
+
## 0.1.0-rc.24
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Carries the @sekyro/react release of this version: the changes in its changelog reach the element.
|
|
8
|
+
- Updated dependencies [7f58208]
|
|
9
|
+
- Updated dependencies [67f74be]
|
|
10
|
+
- Updated dependencies [44e6d28]
|
|
11
|
+
- Updated dependencies [7c81d07]
|
|
12
|
+
- Updated dependencies [a9ffcc2]
|
|
13
|
+
- Updated dependencies [fdd6a6b]
|
|
14
|
+
- Updated dependencies [f378602]
|
|
15
|
+
- Updated dependencies [fc9612d]
|
|
16
|
+
- @sekyro/web@0.1.0-rc.45
|
|
17
|
+
|
|
3
18
|
## 0.1.0-rc.23
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as s,c as a,d as _,e as C,f as D,g as A,h as E,i as S,j as o,k as r,l as t,m as T,n as p,o as O,p as i,q as m,r as I,s as M}from"./chunk-ICGDGBER.js";import"./chunk-IWZRAEUN.js";import"./chunk-F6BL7IXJ.js";import"./chunk-F4Q2Q4OC.js";import"./chunk-W5WWCOOW.js";import"./chunk-VHJIEZ5D.js";import"./chunk-P7K7ELYZ.js";import"./chunk-JS2IXPNL.js";import"./chunk-4FHWXBOB.js";export{i as CAPTURE_CANDIDATE_SPACING_MS,O as CAPTURE_EXTRA_CANDIDATES,m as CAPTURE_WINDOW_MS,T as CaptureSessionDoc,_ as DOC_BLACK_FRAME_LUMA,C as DOC_BLACK_FRAME_TICKS,D as DOC_CADENCE_HZ,a as DOC_FIRST_FRAME_MS,E as DOC_PROFILE_TICKS,r as DOC_SHUTTER_DEFAULTS,o as DOC_SLOW_TICK_MS,S as DOC_WARMUP_TICKS,M as DOC_WEAK_EDGES_HINT_MS,I as REFOCUS_APPLY_MAX_MS,A as SIDE_PROBE_MS,p as passportBandOf,t as resolveDocShutterTuning,s as warmDocDetector};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as i}from"./chunk-4FHWXBOB.js";var x=new Set(["challenge_frame_blocked","challenge_script_blocked","site_key_rejected","challenge_failed","timeout","embedder_opaque"]),f,o=(f=class extends Error{constructor(t,r){super(`Sekyro challenge failed: ${t}${r!==void 0?` (${r})`:""}`),this.name="ChallengeError",this.code=t,r!==void 0&&(this.detail=r)}},i(f,"i"),f),w=3e4,v=12e4,A="sekyro.challenge.",k="position:fixed;width:1px;height:1px;inset-block-start:0;inset-inline-start:0;opacity:0;pointer-events:none;border:0",M="position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);width:300px;height:65px;max-width:calc(100vw - 32px);opacity:1;pointer-events:auto;border:0;border-radius:8px;z-index:2147483647;background:transparent",T="position:fixed;inset:0;background:rgba(0,0,0,0.55);z-index:2147483646";function L(e){if(e.backdrop!==null)return;let t=document.createElement("div");t.setAttribute("style",T),t.setAttribute("data-sekyro-challenge-backdrop",""),document.body.appendChild(t),e.backdrop=t,e.focusBefore=document.activeElement,e.iframe.setAttribute("style",M),e.iframe.removeAttribute("aria-hidden"),e.iframe.setAttribute("tabindex","0");try{e.iframe.focus()}catch{}}i(L,"M");function y(e){if(e.backdrop===null)return;e.backdrop.remove(),e.backdrop=null,e.iframe.setAttribute("style",k),e.iframe.setAttribute("aria-hidden","true"),e.iframe.setAttribute("tabindex","-1");let t=e.focusBefore;if(e.focusBefore=null,t instanceof HTMLElement&&t.isConnected)try{t.focus()}catch{}}i(y,"u");var d=null,b=Promise.resolve();function S(){h(),b=Promise.resolve(),g=!1}i(S,"K");function u(){return new o("aborted")}i(u,"d");function C(){let e=globalThis.crypto;return e!==void 0&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}i(C,"k");function _(e){return new URL(e,document.baseURI).origin}i(_,"w");function h(){let e=d;if(e!==null){d=null,window.removeEventListener("message",e.listener),y(e),e.iframe.remove();for(let t of e.waiters.values())t.reject(new o("challenge_frame_blocked"));e.waiters.clear()}}i(h,"f");function R(e,t){if(t.source!==e.iframe.contentWindow||t.origin!==e.origin)return;let r=t.data;if(typeof r!="object"||r===null)return;let n=r;if(typeof n.type!="string"||!n.type.startsWith(A)||n.v!==1)return;if(n.type==="sekyro.challenge.ready"){e.readyMs??(e.readyMs=Date.now()-e.insertedAt),e.isReady=!0,e.onReady?.();return}if(typeof n.id!="string")return;let l=e.waiters.get(n.id);if(l!==void 0){if(n.type==="sekyro.challenge.interactive"){let a=r.state;a==="show"?L(e):a==="hide"&&y(e);return}if(n.type==="sekyro.challenge.token"&&typeof n.token=="string"&&n.token!=="")e.waiters.delete(n.id),y(e),l.resolve(n.token);else if(n.type==="sekyro.challenge.error"){e.waiters.delete(n.id),y(e);let a=typeof n.code=="string"&&x.has(n.code)?n.code:"challenge_failed",s=typeof n.detail=="string"||typeof n.detail=="number"?String(n.detail).slice(0,32):void 0;l.reject(new o(a==="challenge_failed"&&s==="200100"?"clock_wrong":a,s))}}}i(R,"F");function U(e){if(d!==null&&d.url===e)return d;h();let t=document.createElement("iframe");t.setAttribute("title","Security check"),t.setAttribute("aria-hidden","true"),t.setAttribute("tabindex","-1"),t.setAttribute("referrerpolicy","no-referrer"),t.setAttribute("style",k);let r={url:e,origin:_(e),iframe:t,isReady:!1,insertedAt:Date.now(),onReady:null,waiters:new Map,listener:i(n=>R(r,n),"listener"),backdrop:null,focusBefore:null};return window.addEventListener("message",r.listener),t.src=e,document.body.appendChild(t),d=r,r}i(U,"S");function D(e,t,r){return e.isReady?Promise.resolve():new Promise((n,l)=>{let a=i(()=>{clearTimeout(c),r?.removeEventListener("abort",s),e.onReady=null},"o"),s=i(()=>{a(),l(u())},"s"),c=setTimeout(()=>{a(),l(new o("challenge_frame_blocked"))},t);r?.addEventListener("abort",s,{once:!0}),e.onReady=()=>{a(),n()}})}i(D,"T");async function p(e){if(e.signal?.aborted)throw u();let t=U(e.frameUrl);try{return await j(t,e)}catch(r){throw r instanceof o&&t.readyMs!==void 0&&(r.readyMs??(r.readyMs=t.readyMs)),r}}i(p,"y");async function j(e,t){let r=t.signal;await D(e,t.readyTimeoutMs??w,r);let n=e.iframe.contentWindow;if(n===null)throw new o("challenge_frame_blocked");let l=t.timeoutMs??v,a=C(),s,c;try{return await new Promise((E,m)=>{e.waiters.set(a,{resolve:E,reject:m}),s=setTimeout(()=>m(new o("timeout")),l),r!==void 0&&(c=i(()=>m(u()),"l"),r.addEventListener("abort",c,{once:!0})),n.postMessage({type:"sekyro.challenge.request",v:1,id:a,siteKey:t.siteKey,action:t.action,subject:t.subject},e.origin)})}finally{clearTimeout(s),r!==void 0&&c!==void 0&&r.removeEventListener("abort",c),e.waiters.delete(a),y(e)}}i(j,"R");var g=!1;function P(e,t){if(g)return;let r;if(t==="challenge_frame_blocked"){let n=e;try{n=_(e)}catch{}r=`Sekyro: the security check frame could not load. Allow \`frame-src ${n}\` in your Content-Security-Policy.`}else if(t==="embedder_opaque")r="Sekyro: the security check needs a page with an origin. Do not run the SDK in a sandboxed or data: document.";else return;g=!0,console.warn(r)}i(P,"L");async function $(e){if(globalThis.origin==="null")throw new o("embedder_opaque");if(e.signal?.aborted)throw u();try{return await p(e)}catch(t){if(h(),e.signal?.aborted||t instanceof o&&t.code==="aborted")throw u();if(t instanceof o&&t.code==="timeout")throw t;try{return await p(e)}catch(r){throw h(),e.signal?.aborted?u():r instanceof o?r:new o("challenge_failed")}}}i($,"P");function I(e){let t=i(()=>$(e).catch(n=>{throw n instanceof o&&P(e.frameUrl,n.code),n}),"t"),r=b.then(t,t);return b=r.catch(()=>{}),r}i(I,"O");export{v as CHALLENGE_EXECUTE_TIMEOUT_MS,w as CHALLENGE_READY_TIMEOUT_MS,o as ChallengeError,I as executeChallenge,S as resetChallengeFrameForTests};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as X}from"./chunk-FUMXKBXY.js";import{a as z,b as ee}from"./chunk-CUFOLAZN.js";import{a as n}from"./chunk-5QL6W6FW.js";import{a,c as Z}from"./chunk-4FHWXBOB.js";var u=Z(z(),1),J=Z(z(),1),s=Z(ee(),1);var h=Z(ee(),1);var he="AC247 AD376 AE971/0 AF93/0 AG1/1 AI1/1 AL355/0 AM374/0 AO244 AR54/0 AS1/1 AT43/0 AU61/0 AW297 AX358/0 AZ994/0 BA387/0 BB1/1 BD880/0 BE32/0 BF226 BG359/0 BH973 BI257 BJ229 BL590/0 BM1/1 BN673 BO591/0 BQ599 BR55/0 BS1/1 BT975 BW267 BY375/8 BZ501 CA1/1 CC61/0 CD243/0 CF236 CG242 CH41/0 CI225 CK682 CL56 CM237 CN86/0 CO57/0 CR506 CU53/0 CV238 CW599 CX61/0 CY357 CZ420 DE49/0 DJ253 DK45 DM1/1 DO1/1 DZ213/0 EC593/0 EE372 EG20/0 EH212/0 ER291/0 ES34 ET251/0 FI358/0 FJ679 FK500 FM691 FO298 FR33/0 GA241 GB44/0 GD1/1 GE995/0 GF594/0 GG44/0 GH233/0 GI350 GL299 GM220 GN224 GP590/0 GQ240 GR30 GT502 GU1/1 GW245 GY592 HK852 HN504 HR385/0 HT509 HU36/06 ID62/0 IE353/0 IL972/0 IM44/0 IN91/0 IO246 IQ964/0 IR98/0 IS354 IT39 JE44/0 JM1/1 JO962/0 JP81/0 KE254/0 KG996/0 KH855/0 KI686/0 KM269 KN1/1 KP850/0 KR82/0 KW965 KY1/1 KZ7/8 LA856/0 LB961/0 LC1/1 LI423/0 LK94/0 LR231/0 LS266 LT370/0 LU352 LV371 LY218/0 MA212/0 MC377/0 MD373/0 ME382/0 MF590/0 MG261/0 MH692/1 MK389/0 ML223 MM95/0 MN976/0 MO853 MP1/1 MQ596/0 MR222 MS1/1 MT356 MU230 MV960 MW265/0 MX52 MY60/0 MZ258 NA264/0 NC687 NE227 NF672 NG234/0 NI505 NL31/0 NO47 NP977/0 NR674 NU683 NZ64/0 OM968 PA507 PE51/0 PF689 PG675 PH63/0 PK92/0 PL48 PM508/0 PR1/1 PS970/0 PT351 PW680 PY595/0 QA974 RE262/0 RO40/0 RS381/0 RU7/8 RW250/0 SA966/0 SB677 SC248 SD249/0 SE46/0 SG65 SH290 SI386/0 SJ47 SK421/0 SL232/0 SM378 SN221 SO252/0 SR597 SS211/0 ST239 SV503 SX1/1 SY963/0 SZ268 TA290 TC1/1 TD235 TG228 TH66/0 TJ992 TK690 TL670 TM993/8 TN216 TO676 TR90/0 TT1/1 TV688 TW886/0 TZ255/0 UA380/0 UG256/0 US1/1 UY598/0 UZ998 VA39 VC1/1 VE58/0 VG1/1 VI1/1 VN84/0 VU678 WF681 WS685 XK383/0 YE967/0 YT262/0 ZA27/0 ZM260/0 ZW263/0",j;function Q(e){return j??(j=new Map(he.split(" ").map(l=>{let[r,t]=l.slice(2).split("/");return[l.slice(0,2),[r,t]]}))),j.get(e.toUpperCase())}a(Q,"z");n(Q,"entryOf");function pe(e){return Q(e)?.[0]}a(pe,"Ne");n(pe,"dialCodeOf");function ne(e){return Q(e)?.[1]}a(ne,"ee");n(ne,"nationalPrefixOf");var le=n(e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLocaleLowerCase(),"fold");function ae(e,l){let r=le(l.trim());return r===""?e:e.filter(t=>le(t.name).includes(r)||t.code.toLowerCase()===r)}a(ae,"ce");n(ae,"matchCountries");function oe({countries:e,label:l,searchPlaceholder:r,noMatch:t,onPick:v,selected:P,searchRef:f,scroll:E=!1,searchable:w=!0,detail:D,extra:y}){let[M,b]=(0,J.useState)(""),c=(0,J.useId)(),T=ae(e,M),N=(0,s.jsxs)("ul",{className:`sekyro-rows${E?" sekyro-rows--scroll":""}`,children:[T.map(d=>{let S=D?.(d.code);return(0,s.jsx)("li",{children:(0,s.jsxs)("button",{type:"button",className:"sekyro-row-btn","aria-current":P===d.code||void 0,onClick:a(()=>v(d.code),"onClick"),children:[(0,s.jsx)("span",{className:"sekyro-row-btn__flag","aria-hidden":"true",children:ce(d.code)}),(0,s.jsx)("span",{className:"sekyro-row-btn__name",children:d.name}),S!==void 0?(0,s.jsx)("bdi",{className:"sekyro-row-btn__detail",dir:"ltr",children:S}):null]})},d.code)}),y!==void 0?(0,s.jsx)("li",{children:(0,s.jsxs)("button",{type:"button",className:"sekyro-row-btn","aria-current":y.current||void 0,onClick:y.onPick,children:[(0,s.jsx)("span",{className:"sekyro-row-btn__flag","aria-hidden":"true",children:"🌐"}),(0,s.jsx)("span",{className:"sekyro-row-btn__name",children:y.label})]})}):null]});return w?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"sekyro-field",children:[(0,s.jsx)("label",{className:"sekyro-label",htmlFor:c,children:l}),(0,s.jsx)("input",{ref:f,id:c,type:"search",className:"sekyro-input",placeholder:r,value:M,onChange:a(d=>b(d.target.value),"onChange")})]}),T.length===0&&y===void 0?(0,s.jsx)("p",{className:"sekyro-text-muted",children:t}):N]}):N}a(oe,"te");n(oe,"CountryList");function U(e){let l=X(e).replace(/\D/g,"");return/^\D*\+/.test(e)?`+${l}`:l.startsWith("00")?`+${l.slice(2)}`:l}a(U,"H");n(U,"digitsOf");var te=n((e,l)=>(l.trunk!==void 0&&e.startsWith(l.trunk)?e.slice(l.trunk.length):e).slice(0,Math.max(...l.lengths)),"fitDigits");function Y(e,l){let r="",t=0;for(let v of l?.formats?.find(P=>new RegExp(`^(?:${P.leading})`).test(e))?.groups??[])t<e.length&&(r+=(t>0?" ":"")+e.slice(t,t+v)),t+=v;return r+e.slice(t)}a(Y,"Z");n(Y,"groupDigits");function ie(e,l){let r=0;for(let t=l;t>0&&r<e.length;r+=1)e[r]!==" "&&(t-=1);return r}a(ie,"oe");n(ie,"caretAfter");var se=n((e,l)=>l.find(r=>e.startsWith(r.dial)),"countryOfNumber"),me=n((e,l)=>e.lengths.join(", ").replace(/, (\d+)$/,` ${l} $1`),"lengthsLabel");function q(e){let l=U(e).replace("+","");return/^\d{8,15}$/.test(l)?`+${l}`:null}a(q,"le");n(q,"normalizedPhone");var ce=n(e=>String.fromCodePoint(...Array.from(e.toUpperCase(),l=>127397+l.charCodeAt(0))),"flagOf");function de(e,l){if(l===null||!e.startsWith(l.dial))return q(e);let r=e.slice(l.dial.length).replace(/\D/g,""),t=ne(l.code);return t!==void 0&&r.startsWith(t)&&(r=r.slice(t.length)),q(l.dial+r)}a(de,"ye");n(de,"e164Of");var re=n((e,l)=>(se(e,l)??l[0])?.code??null,"countryFor");function ue(e){let l=null;try{l=new Intl.DisplayNames([e],{type:"region"})}catch{}return r=>`${l?.of(r.code)??r.code} (${r.dial})`}a(ue,"me");n(ue,"countryLabels");var fe="other",ye=8;function ge({countries:e,international:l,closed:r,defaultPhone:t}){let[v,P]=(0,u.useState)(()=>re(t,e)),[f,E]=(0,u.useState)(t),[w,D]=(0,u.useState)(!1),[y,M]=(0,u.useState)(!1),b=e.map(o=>o.code).join(","),c=e.find(o=>o.code===v)??null,T=(0,u.useRef)(c);c!==null&&(T.current=c),(0,u.useEffect)(()=>{if(v===null||!e.some(o=>o.code===v)){let o=re(t,e);P(o);let i=T.current,k=e.find(C=>C.code===o)?.dial;k!==void 0&&E(C=>i!==null&&C.startsWith(i.dial)?k+C.slice(i.dial.length):C.startsWith("+")?C:k)}},[b,t]);let N=w||c===null,d=N||f.startsWith("+")&&!f.startsWith(c.dial),S=d?void 0:c.rule,x=d?f:f.replace(c.dial,"").replace(/\D/g,""),p=S?te(x,S):x,W=d&&!N&&!l&&r&&!e.some(o=>o.dial.startsWith(f)),I=W?null:S?S.lengths.includes(p.length)?c.dial+p:null:N&&!f.startsWith("+")?null:de(f,w?null:c),H=d||c===null?I??f:`${c.dial} ${Y(p,S)}`,B=d?U(f).replace("+","")==="":p==="";return{countries:e,international:l,phone:f,selected:c,other:w,whole:d,free:N,rule:S,national:p,refused:W,typed:I,shown:H,empty:B,lengthShown:y,setLengthShown:M,onNumber:n(o=>{let i=o.target,k=o.nativeEvent.inputType,C=Math.max(0,i.value.lastIndexOf("+")),G=U(i.value.slice(C)),A=se(G,e),_=U(i.value.slice(C,i.selectionStart)).length,F=G,V=G;if(M(!1),!A&&(N||G.startsWith("+")))l&&D(!0);else{let R=A??c,g=A?G.slice(A.dial.length):G;if(P(R.code),D(!1),g===p&&k?.startsWith("delete")&&(k.endsWith("Forward")||(_-=1),g=g.slice(0,_)+g.slice(_+1)),R.rule){let $=te(g,R.rule),O=g.length-$.length;_-=O,g=O>0&&!A&&p.length===$.length?p:$}V=R.dial+g,F=Y(g,R.rule)}E(V),i.value=F;let K=ie(F,_);i.setSelectionRange(K,K)},"onNumber"),onCountry:n(o=>{M(!1);let i=e.find(k=>k.code===o);D(i===void 0),i!==void 0&&P(i.code),E(i===void 0?"":i.dial+(d?"":p))},"onCountry")}}a(ge,"_e");n(ge,"usePhoneField");function Ne({field:e,id:l,locale:r,t,inputRef:v,invalid:P=!1,describedby:f,required:E,compact:w=!1,ready:D}){let{selected:y,whole:M,other:b,free:c,national:T,rule:N,phone:d,refused:S,typed:x,countries:p,international:W}=e,[I,H]=(0,u.useState)(!1),B=(0,u.useRef)(null),o=(0,u.useRef)(null),i=(0,u.useRef)(null),k=(0,u.useRef)(null),C=v??k,G=(0,u.useId)(),A=S?t("otp.reason_otp_destination_not_allowed"):e.lengthShown&&N?t("otp.phoneLengthError",{digits:me(N,t("otp.or"))}):"",_=p.length>1||W,F=ue(r),V=(0,u.useMemo)(()=>{let m=null;try{m=new Intl.DisplayNames([r],{type:"region"})}catch{}return p.map(L=>({code:L.code,name:m?.of(L.code)??L.code}))},[p,r]),K=p.length>ye,R=[M?"":`${l}-dial ${l}-hint`,A?`${l}-error`:"",f??""].join(" ").trim()||void 0,g=n(m=>{H(!1),requestAnimationFrame(()=>(m==="lead"?B.current:C.current)?.focus())},"close"),$=n(()=>{if(I)return g("lead");H(!0),requestAnimationFrame(()=>(i.current??o.current?.querySelector('[aria-current="true"]')??o.current?.querySelector("button"))?.focus())},"toggle"),O=n(()=>(0,h.jsxs)("span",{className:"sekyro-phone__dial",id:`${l}-dial`,"aria-hidden":_||void 0,children:[(0,h.jsx)("span",{className:"sekyro-phone__flag","aria-hidden":"true",children:b?"🌐":ce(y.code)}),b?null:y.dial]}),"dial");return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:`sekyro-phone${w?" sekyro-phone--compact":""}`,dir:"ltr",children:[y===null||M&&!b?null:_?(0,h.jsx)("button",{ref:B,type:"button",className:"sekyro-phone__lead sekyro-phone__pick","aria-label":`${t("otp.countryLabel")}: ${b?t("otp.otherCountry"):F(y)}`,"aria-expanded":I,"aria-controls":I?G:void 0,onClick:$,children:O()}):(0,h.jsx)("div",{className:"sekyro-phone__lead",children:O()}),(0,h.jsx)("input",{ref:C,id:l,className:"sekyro-phone__input",type:"tel",dir:"ltr",inputMode:"tel",autoComplete:"tel",required:E,"aria-describedby":R,"aria-invalid":!!A||P||void 0,placeholder:c?"+":void 0,value:M?d:Y(T,N),onChange:e.onNumber,onKeyDown:a(m=>{m.key==="Enter"&&D===!1&&e.setLengthShown(!0)},"onKeyDown"),onBlur:a(m=>{let L=m.relatedTarget;L!==null&&(B.current?.contains(L)||o.current?.contains(L))||e.setLengthShown(T!==""&&x===null)},"onBlur")})]}),I?(0,h.jsx)("div",{ref:o,id:G,className:"sekyro-phone__list",onKeyDown:a(m=>{m.key==="Escape"&&(m.preventDefault(),g("lead"))},"onKeyDown"),children:(0,h.jsx)(oe,{countries:V,label:(0,h.jsx)("span",{className:"sekyro-visually-hidden",children:t("otp.countrySearch")}),searchPlaceholder:t("otp.countrySearch"),noMatch:t("doc.noCountryMatch"),searchable:K,scroll:!0,...K?{searchRef:i}:{},...!b&&y!==null?{selected:y.code}:{},detail:a(m=>p.find(L=>L.code===m)?.dial,"detail"),onPick:a(m=>{e.onCountry(m),g("number")},"onPick"),...W?{extra:{label:t("otp.otherCountry"),current:b,onPick:n(()=>{e.onCountry(fe),g("number")},"onPick")}}:{}})}):null,M?null:(0,h.jsx)("span",{className:"sekyro-help",id:`${l}-hint`,children:t("otp.phonePlaceholderGeneric")}),A?(0,h.jsx)("span",{className:"sekyro-help is-danger",id:`${l}-error`,role:"alert",children:A}):null]})}a(Ne,"xe");n(Ne,"PhoneField");export{pe as a,oe as b,ce as c,ge as d,Ne as e};
|
|
1
|
+
import{i as X}from"./chunk-XXYPLLFI.js";import{a as z,b as ee}from"./chunk-QVU5SNFG.js";import{a as n}from"./chunk-5QL6W6FW.js";import{a,c as Z}from"./chunk-4FHWXBOB.js";var u=Z(z(),1),J=Z(z(),1),s=Z(ee(),1);var h=Z(ee(),1);var he="AC247 AD376 AE971/0 AF93/0 AG1/1 AI1/1 AL355/0 AM374/0 AO244 AR54/0 AS1/1 AT43/0 AU61/0 AW297 AX358/0 AZ994/0 BA387/0 BB1/1 BD880/0 BE32/0 BF226 BG359/0 BH973 BI257 BJ229 BL590/0 BM1/1 BN673 BO591/0 BQ599 BR55/0 BS1/1 BT975 BW267 BY375/8 BZ501 CA1/1 CC61/0 CD243/0 CF236 CG242 CH41/0 CI225 CK682 CL56 CM237 CN86/0 CO57/0 CR506 CU53/0 CV238 CW599 CX61/0 CY357 CZ420 DE49/0 DJ253 DK45 DM1/1 DO1/1 DZ213/0 EC593/0 EE372 EG20/0 EH212/0 ER291/0 ES34 ET251/0 FI358/0 FJ679 FK500 FM691 FO298 FR33/0 GA241 GB44/0 GD1/1 GE995/0 GF594/0 GG44/0 GH233/0 GI350 GL299 GM220 GN224 GP590/0 GQ240 GR30 GT502 GU1/1 GW245 GY592 HK852 HN504 HR385/0 HT509 HU36/06 ID62/0 IE353/0 IL972/0 IM44/0 IN91/0 IO246 IQ964/0 IR98/0 IS354 IT39 JE44/0 JM1/1 JO962/0 JP81/0 KE254/0 KG996/0 KH855/0 KI686/0 KM269 KN1/1 KP850/0 KR82/0 KW965 KY1/1 KZ7/8 LA856/0 LB961/0 LC1/1 LI423/0 LK94/0 LR231/0 LS266 LT370/0 LU352 LV371 LY218/0 MA212/0 MC377/0 MD373/0 ME382/0 MF590/0 MG261/0 MH692/1 MK389/0 ML223 MM95/0 MN976/0 MO853 MP1/1 MQ596/0 MR222 MS1/1 MT356 MU230 MV960 MW265/0 MX52 MY60/0 MZ258 NA264/0 NC687 NE227 NF672 NG234/0 NI505 NL31/0 NO47 NP977/0 NR674 NU683 NZ64/0 OM968 PA507 PE51/0 PF689 PG675 PH63/0 PK92/0 PL48 PM508/0 PR1/1 PS970/0 PT351 PW680 PY595/0 QA974 RE262/0 RO40/0 RS381/0 RU7/8 RW250/0 SA966/0 SB677 SC248 SD249/0 SE46/0 SG65 SH290 SI386/0 SJ47 SK421/0 SL232/0 SM378 SN221 SO252/0 SR597 SS211/0 ST239 SV503 SX1/1 SY963/0 SZ268 TA290 TC1/1 TD235 TG228 TH66/0 TJ992 TK690 TL670 TM993/8 TN216 TO676 TR90/0 TT1/1 TV688 TW886/0 TZ255/0 UA380/0 UG256/0 US1/1 UY598/0 UZ998 VA39 VC1/1 VE58/0 VG1/1 VI1/1 VN84/0 VU678 WF681 WS685 XK383/0 YE967/0 YT262/0 ZA27/0 ZM260/0 ZW263/0",j;function Q(e){return j??(j=new Map(he.split(" ").map(l=>{let[r,t]=l.slice(2).split("/");return[l.slice(0,2),[r,t]]}))),j.get(e.toUpperCase())}a(Q,"z");n(Q,"entryOf");function pe(e){return Q(e)?.[0]}a(pe,"Ne");n(pe,"dialCodeOf");function ne(e){return Q(e)?.[1]}a(ne,"ee");n(ne,"nationalPrefixOf");var le=n(e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLocaleLowerCase(),"fold");function ae(e,l){let r=le(l.trim());return r===""?e:e.filter(t=>le(t.name).includes(r)||t.code.toLowerCase()===r)}a(ae,"ce");n(ae,"matchCountries");function oe({countries:e,label:l,searchPlaceholder:r,noMatch:t,onPick:v,selected:P,searchRef:f,scroll:E=!1,searchable:w=!0,detail:D,extra:y}){let[M,b]=(0,J.useState)(""),c=(0,J.useId)(),T=ae(e,M),N=(0,s.jsxs)("ul",{className:`sekyro-rows${E?" sekyro-rows--scroll":""}`,children:[T.map(d=>{let S=D?.(d.code);return(0,s.jsx)("li",{children:(0,s.jsxs)("button",{type:"button",className:"sekyro-row-btn","aria-current":P===d.code||void 0,onClick:a(()=>v(d.code),"onClick"),children:[(0,s.jsx)("span",{className:"sekyro-row-btn__flag","aria-hidden":"true",children:ce(d.code)}),(0,s.jsx)("span",{className:"sekyro-row-btn__name",children:d.name}),S!==void 0?(0,s.jsx)("bdi",{className:"sekyro-row-btn__detail",dir:"ltr",children:S}):null]})},d.code)}),y!==void 0?(0,s.jsx)("li",{children:(0,s.jsxs)("button",{type:"button",className:"sekyro-row-btn","aria-current":y.current||void 0,onClick:y.onPick,children:[(0,s.jsx)("span",{className:"sekyro-row-btn__flag","aria-hidden":"true",children:"🌐"}),(0,s.jsx)("span",{className:"sekyro-row-btn__name",children:y.label})]})}):null]});return w?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"sekyro-field",children:[(0,s.jsx)("label",{className:"sekyro-label",htmlFor:c,children:l}),(0,s.jsx)("input",{ref:f,id:c,type:"search",className:"sekyro-input",placeholder:r,value:M,onChange:a(d=>b(d.target.value),"onChange")})]}),T.length===0&&y===void 0?(0,s.jsx)("p",{className:"sekyro-text-muted",children:t}):N]}):N}a(oe,"te");n(oe,"CountryList");function U(e){let l=X(e).replace(/\D/g,"");return/^\D*\+/.test(e)?`+${l}`:l.startsWith("00")?`+${l.slice(2)}`:l}a(U,"H");n(U,"digitsOf");var te=n((e,l)=>(l.trunk!==void 0&&e.startsWith(l.trunk)?e.slice(l.trunk.length):e).slice(0,Math.max(...l.lengths)),"fitDigits");function Y(e,l){let r="",t=0;for(let v of l?.formats?.find(P=>new RegExp(`^(?:${P.leading})`).test(e))?.groups??[])t<e.length&&(r+=(t>0?" ":"")+e.slice(t,t+v)),t+=v;return r+e.slice(t)}a(Y,"Z");n(Y,"groupDigits");function ie(e,l){let r=0;for(let t=l;t>0&&r<e.length;r+=1)e[r]!==" "&&(t-=1);return r}a(ie,"oe");n(ie,"caretAfter");var se=n((e,l)=>l.find(r=>e.startsWith(r.dial)),"countryOfNumber"),me=n((e,l)=>e.lengths.join(", ").replace(/, (\d+)$/,` ${l} $1`),"lengthsLabel");function q(e){let l=U(e).replace("+","");return/^\d{8,15}$/.test(l)?`+${l}`:null}a(q,"le");n(q,"normalizedPhone");var ce=n(e=>String.fromCodePoint(...Array.from(e.toUpperCase(),l=>127397+l.charCodeAt(0))),"flagOf");function de(e,l){if(l===null||!e.startsWith(l.dial))return q(e);let r=e.slice(l.dial.length).replace(/\D/g,""),t=ne(l.code);return t!==void 0&&r.startsWith(t)&&(r=r.slice(t.length)),q(l.dial+r)}a(de,"ye");n(de,"e164Of");var re=n((e,l)=>(se(e,l)??l[0])?.code??null,"countryFor");function ue(e){let l=null;try{l=new Intl.DisplayNames([e],{type:"region"})}catch{}return r=>`${l?.of(r.code)??r.code} (${r.dial})`}a(ue,"me");n(ue,"countryLabels");var fe="other",ye=8;function ge({countries:e,international:l,closed:r,defaultPhone:t}){let[v,P]=(0,u.useState)(()=>re(t,e)),[f,E]=(0,u.useState)(t),[w,D]=(0,u.useState)(!1),[y,M]=(0,u.useState)(!1),b=e.map(o=>o.code).join(","),c=e.find(o=>o.code===v)??null,T=(0,u.useRef)(c);c!==null&&(T.current=c),(0,u.useEffect)(()=>{if(v===null||!e.some(o=>o.code===v)){let o=re(t,e);P(o);let i=T.current,k=e.find(C=>C.code===o)?.dial;k!==void 0&&E(C=>i!==null&&C.startsWith(i.dial)?k+C.slice(i.dial.length):C.startsWith("+")?C:k)}},[b,t]);let N=w||c===null,d=N||f.startsWith("+")&&!f.startsWith(c.dial),S=d?void 0:c.rule,x=d?f:f.replace(c.dial,"").replace(/\D/g,""),p=S?te(x,S):x,W=d&&!N&&!l&&r&&!e.some(o=>o.dial.startsWith(f)),I=W?null:S?S.lengths.includes(p.length)?c.dial+p:null:N&&!f.startsWith("+")?null:de(f,w?null:c),H=d||c===null?I??f:`${c.dial} ${Y(p,S)}`,B=d?U(f).replace("+","")==="":p==="";return{countries:e,international:l,phone:f,selected:c,other:w,whole:d,free:N,rule:S,national:p,refused:W,typed:I,shown:H,empty:B,lengthShown:y,setLengthShown:M,onNumber:n(o=>{let i=o.target,k=o.nativeEvent.inputType,C=Math.max(0,i.value.lastIndexOf("+")),G=U(i.value.slice(C)),A=se(G,e),_=U(i.value.slice(C,i.selectionStart)).length,F=G,V=G;if(M(!1),!A&&(N||G.startsWith("+")))l&&D(!0);else{let R=A??c,g=A?G.slice(A.dial.length):G;if(P(R.code),D(!1),g===p&&k?.startsWith("delete")&&(k.endsWith("Forward")||(_-=1),g=g.slice(0,_)+g.slice(_+1)),R.rule){let $=te(g,R.rule),O=g.length-$.length;_-=O,g=O>0&&!A&&p.length===$.length?p:$}V=R.dial+g,F=Y(g,R.rule)}E(V),i.value=F;let K=ie(F,_);i.setSelectionRange(K,K)},"onNumber"),onCountry:n(o=>{M(!1);let i=e.find(k=>k.code===o);D(i===void 0),i!==void 0&&P(i.code),E(i===void 0?"":i.dial+(d?"":p))},"onCountry")}}a(ge,"_e");n(ge,"usePhoneField");function Ne({field:e,id:l,locale:r,t,inputRef:v,invalid:P=!1,describedby:f,required:E,compact:w=!1,ready:D}){let{selected:y,whole:M,other:b,free:c,national:T,rule:N,phone:d,refused:S,typed:x,countries:p,international:W}=e,[I,H]=(0,u.useState)(!1),B=(0,u.useRef)(null),o=(0,u.useRef)(null),i=(0,u.useRef)(null),k=(0,u.useRef)(null),C=v??k,G=(0,u.useId)(),A=S?t("otp.reason_otp_destination_not_allowed"):e.lengthShown&&N?t("otp.phoneLengthError",{digits:me(N,t("otp.or"))}):"",_=p.length>1||W,F=ue(r),V=(0,u.useMemo)(()=>{let m=null;try{m=new Intl.DisplayNames([r],{type:"region"})}catch{}return p.map(L=>({code:L.code,name:m?.of(L.code)??L.code}))},[p,r]),K=p.length>ye,R=[M?"":`${l}-dial ${l}-hint`,A?`${l}-error`:"",f??""].join(" ").trim()||void 0,g=n(m=>{H(!1),requestAnimationFrame(()=>(m==="lead"?B.current:C.current)?.focus())},"close"),$=n(()=>{if(I)return g("lead");H(!0),requestAnimationFrame(()=>(i.current??o.current?.querySelector('[aria-current="true"]')??o.current?.querySelector("button"))?.focus())},"toggle"),O=n(()=>(0,h.jsxs)("span",{className:"sekyro-phone__dial",id:`${l}-dial`,"aria-hidden":_||void 0,children:[(0,h.jsx)("span",{className:"sekyro-phone__flag","aria-hidden":"true",children:b?"🌐":ce(y.code)}),b?null:y.dial]}),"dial");return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:`sekyro-phone${w?" sekyro-phone--compact":""}`,dir:"ltr",children:[y===null||M&&!b?null:_?(0,h.jsx)("button",{ref:B,type:"button",className:"sekyro-phone__lead sekyro-phone__pick","aria-label":`${t("otp.countryLabel")}: ${b?t("otp.otherCountry"):F(y)}`,"aria-expanded":I,"aria-controls":I?G:void 0,onClick:$,children:O()}):(0,h.jsx)("div",{className:"sekyro-phone__lead",children:O()}),(0,h.jsx)("input",{ref:C,id:l,className:"sekyro-phone__input",type:"tel",dir:"ltr",inputMode:"tel",autoComplete:"tel",required:E,"aria-describedby":R,"aria-invalid":!!A||P||void 0,placeholder:c?"+":void 0,value:M?d:Y(T,N),onChange:e.onNumber,onKeyDown:a(m=>{m.key==="Enter"&&D===!1&&e.setLengthShown(!0)},"onKeyDown"),onBlur:a(m=>{let L=m.relatedTarget;L!==null&&(B.current?.contains(L)||o.current?.contains(L))||e.setLengthShown(T!==""&&x===null)},"onBlur")})]}),I?(0,h.jsx)("div",{ref:o,id:G,className:"sekyro-phone__list",onKeyDown:a(m=>{m.key==="Escape"&&(m.preventDefault(),g("lead"))},"onKeyDown"),children:(0,h.jsx)(oe,{countries:V,label:(0,h.jsx)("span",{className:"sekyro-visually-hidden",children:t("otp.countrySearch")}),searchPlaceholder:t("otp.countrySearch"),noMatch:t("doc.noCountryMatch"),searchable:K,scroll:!0,...K?{searchRef:i}:{},...!b&&y!==null?{selected:y.code}:{},detail:a(m=>p.find(L=>L.code===m)?.dial,"detail"),onPick:a(m=>{e.onCountry(m),g("number")},"onPick"),...W?{extra:{label:t("otp.otherCountry"),current:b,onPick:n(()=>{e.onCountry(fe),g("number")},"onPick")}}:{}})}):null,M?null:(0,h.jsx)("span",{className:"sekyro-help",id:`${l}-hint`,children:t("otp.phonePlaceholderGeneric")}),A?(0,h.jsx)("span",{className:"sekyro-help is-danger",id:`${l}-error`,role:"alert",children:A}):null]})}a(Ne,"xe");n(Ne,"PhoneField");export{pe as a,oe as b,ce as c,ge as d,Ne as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as L}from"./chunk-RVPBL3KC.js";import{a as J,c as R}from"./chunk-RCDZUOGM.js";import{b as U}from"./chunk-6MYG4HWP.js";import{a as r}from"./chunk-4FHWXBOB.js";var g,h=(g=class extends Error{constructor(t){super(t.message),this.name="HostedApiError",this.status=t.status,this.code=t.code,t.retryAfterSeconds!==void 0&&(this.retryAfterSeconds=t.retryAfterSeconds),t.details&&(this.details=t.details)}},r(g,"u"),g);function H(e,t,n=Math.random){let i=(e??t)*1e3,s=Math.min(Math.max(i,500),2e4),a=Math.round(s*(1+(n()*2-1)*.25));return Math.min(Math.max(a,500),2e4)}r(H,"T");var V=6e4,N=4,se=3e4,re=9e5,ae=200,oe=5,ce=400,de=new Set(["server_busy","request_timeout"]),ue=20,le=60,pe=600,he=2;function v(e){return(e.split(";")[0]??"").trim()}r(v,"l");var me={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},fe=`@sekyro/web/${J}`,ye=fe,b,st=(b=class{constructor(t){this.sessionId=null,this.bootstrap=null,this.captureNonces=[],this.captureFetch=null,this.reportedIssues=new Map,this.issueReports=0,this.issuesPausedUntil=0,this.apiOrigin=t.apiOrigin.replace(/\/+$/,""),this.sessionToken=t.sessionToken;let n=t.fetch;this.fetchImpl=(i,s)=>(n??globalThis.fetch).call(globalThis,i,s),this.requestTimeoutMs=t.requestTimeoutMs??se,this.retryAttempts=t.inProgressRetry?.attempts??oe,this.retryDelayMs=t.inProgressRetry?.delayMs??ce,this.random=t.random??Math.random,this.clientLocale=t.locale}async getSession(){let t=await this.api("GET","/hosted/session");return this.sessionId=t.sessionId,t}async recordConsent(t){let n=await this.api("POST","/hosted/consent",{body:{locale:t},busyRetry:!0}),i=this.captureHold;return this.captureHold=void 0,i&&this.armCapture(i),n}async reportCameraUnavailable(t){return this.api("POST","/hosted/camera-unavailable",{body:{cause:t}})}async testerGate(t){return this.api("POST","/hosted/tester-gate",{body:{input:t}})}async reportCaptureIssue(t){let n=typeof t.name=="string"?t.name.replace(/[^A-Za-z]/g,"").slice(0,40):"",i=typeof t.engineKind=="string"&&/^[a-z_]{1,32}$/.test(t.engineKind)?t.engineKind:void 0,s=typeof t.attempt=="number"&&Number.isInteger(t.attempt)&&t.attempt>=0&&t.attempt<=1e3?t.attempt:void 0,a=t.check==="attestation"?s??"":"",c=[t.check,a,t.kind,n,t.phase??"",i??""].join("|"),d=this.reportedIssues.get(c);if(d!==void 0)return d;if(Date.now()<this.issuesPausedUntil||this.issueReports>=ue)return;let o={check:t.check,kind:t.kind,...n!==""?{name:n}:{},...t.phase!==void 0?{phase:t.phase}:{},...i!==void 0?{engineKind:i}:{},...s!==void 0?{attempt:s}:{},...t.formFactor!==void 0?{formFactor:t.formFactor}:{},...typeof t.detail=="string"&&/^\d{1,10}$/.test(t.detail)?{detail:t.detail}:{},...G(t.challengeMs)?{challengeMs:t.challengeMs}:{},...G(t.readyMs)?{readyMs:t.readyMs}:{},...t.inApp===!0?{inApp:!0}:{}};this.issueReports+=1;let u=this.api("POST","/hosted/capture-issue",{body:o,empty:!0}).catch(l=>{if(l instanceof h&&l.status===429){let p=Math.min(Math.max(l.retryAfterSeconds??le,0),pe);this.issuesPausedUntil=Math.max(this.issuesPausedUntil,Date.now()+p*1e3);return}(!(l instanceof h)||l.status===0||l.status>=500)&&this.reportedIssues.delete(c)});return this.reportedIssues.set(c,u),u}async choose(t,n){let i=await this.api("POST","/hosted/choice",{body:{nodeId:t,option:n},busyRetry:!0});return this.sessionId=i.sessionId,i}async confirmIdentity(t){return this.api("POST","/hosted/identity/confirm",{body:{decision:t}})}async identityPortrait(){return this.api("GET","/hosted/identity/portrait",{blob:!0})}async presign(t,n,i,s={}){let a=await this.ensureSessionId(),c={kind:t,contentType:v(n),contentLength:i,...s.source==="upload"?{source:"upload"}:{}};return this.api("POST",`/sessions/${a}/media`,{body:c})}armCapture(t=2){let n=Date.now();this.captureNonces.filter(i=>i.expiresAt-V>n).length>=t||(this.captureHold===void 0?this.fillCaptureNonces(t,t):this.captureHold=Math.max(this.captureHold,t))}async armRamp(){try{let t=await this.ensureSessionId(),n=await this.api("POST",`/sessions/${t}/media/capture-nonces`,{body:{count:2,ramp:!0}}),i=Date.now(),s=L(n.screenRamp)?n.screenRamp:void 0,a=i+Math.max(0,n.expiresIn)*1e3;for(let d of Array.isArray(n.nonces)?n.nonces:[])typeof d!="string"||d.length===0||this.captureNonces.push({nonce:d,expiresAt:a,...s!==void 0?{arm:s.nonce}:{}});this.captureNonces=this.captureNonces.slice(-N),this.captureHold=void 0;let c=typeof n.rampExpiresIn=="number"&&n.rampExpiresIn>0?n.rampExpiresIn:0;return{...s!==void 0?{challenge:s}:{},expiresAt:i+c*1e3}}catch{return}}async presignCapture(t,n,i,s={}){let a=await this.ensureSessionId(),c=await this.takeCaptureNonce(s.arm),d=c===void 0?void 0:{nonce:c,...s.engine!==void 0?{engine:s.engine.slice(0,32)}:{},...s.durationMs!==void 0&&Number.isFinite(s.durationMs)?{captureMs:Math.min(36e5,Math.max(0,Math.round(s.durationMs)))}:{}},o={kind:t,contentType:v(n),contentLength:i,capture:d};return this.api("POST",`/sessions/${a}/media`,{body:o})}async takeCaptureNonce(t){let n=r(()=>{let i=Date.now();this.captureNonces=this.captureNonces.filter(a=>a.expiresAt-V>i);let s=this.captureNonces.findIndex(a=>a.arm===t);return this.captureNonces.splice(s<0?0:s,1)[0]?.nonce},"n");for(let i=0;i<2;i++){let s=n();if(s!==void 0)return s;await this.fillCaptureNonces(1)}return n()}fillCaptureNonces(t,n=0){return this.captureFetch??(this.captureFetch=(async()=>{try{let i=await this.ensureSessionId(),s=await this.api("POST",`/sessions/${i}/media/capture-nonces`,{body:{count:Math.min(N,Math.max(1,t))}}),a=Date.now()+Math.max(0,s.expiresIn)*1e3;for(let c of Array.isArray(s.nonces)?s.nonces:[])typeof c=="string"&&c.length>0&&this.captureNonces.push({nonce:c,expiresAt:a});this.captureNonces=this.captureNonces.slice(-N),this.captureHold=void 0}catch(i){i instanceof h&&i.code==="consent_required"&&(this.captureHold=Math.max(this.captureHold??0,n))}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(t,n,i){let s;try{s=await this.fetchImpl(t,{method:"PUT",headers:{"content-type":v(i)},body:n,signal:AbortSignal.timeout(re)})}catch(a){throw K(a)}if(!s.ok){let a=(await s.text().catch(()=>"")).slice(0,ae);throw new h({status:s.status,code:"upload_failed",message:`media upload failed (HTTP ${s.status})${a?`: ${a}`:""}`})}}async completeMedia(t){let n=await this.ensureSessionId();return this.api("POST",`/sessions/${n}/media/complete`,{body:{key:t}})}async submitCheck(t,n,i={}){let s=await this.ensureSessionId(),a={input:n,forceOutcome:i.forceOutcome};return this.api("POST",`/sessions/${s}/checks/${t}`,{body:a,idempotencyKey:i.idempotencyKey,...i.browserCheckToken!==void 0?{browserCheckToken:i.browserCheckToken}:{},busyRetry:i.idempotencyKey!==void 0})}async uploadAndSubmit(t,n,i,s={}){let a=v(n.contentType),c=await this.presign(n.kind,a,n.blob.size);await this.uploadToSpaces(c.uploadUrl,n.blob,a);let d=await this.completeMedia(c.key),o={...i,[me[t]]:d.key};return this.submitCheck(t,o,s)}async ensureSessionId(){return this.sessionId!==null?this.sessionId:(this.bootstrap??(this.bootstrap=this.getSession().finally(()=>{this.bootstrap=null})),(await this.bootstrap).sessionId)}async api(t,n,i={}){let s=t==="GET"||i.busyRetry===!0,a=`${this.apiOrigin}/api/v2${n}`,c={"x-session-token":this.sessionToken,"x-sekyro-sdk":ye};i.body!==void 0&&(c["content-type"]="application/json"),i.idempotencyKey!==void 0&&(c["x-idempotency-key"]=i.idempotencyKey),i.browserCheckToken!==void 0&&(c["sekyro-browser-check"]=i.browserCheckToken),this.clientLocale!==void 0&&(c["sekyro-client-locale"]=this.clientLocale);try{let d=R.timezone();d!==void 0&&(c["sekyro-client-timezone"]=d)}catch{}c["sekyro-client-form-factor"]=U();try{let d=await R.deviceHeader();d!==void 0&&(c["sekyro-client-device"]=d)}catch{}for(let d=0;;d++){let o;try{o=await this.fetchImpl(a,{method:t,headers:c,...i.body!==void 0?{body:JSON.stringify(i.body)}:{},cache:"no-store",signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(l){throw K(l)}if(o.ok){if(i.empty===!0)return;if(i.blob===!0)try{return await o.blob()}catch(p){throw K(p)}let l;try{l=await o.json()}catch{throw new h({status:o.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${o.status})`})}return _e(l)}let u=await ve(o);if(u.code==="idempotency_in_progress"&&d<this.retryAttempts){this.retryDelayMs>0&&await B(this.retryDelayMs);continue}if(s&&u.status===503&&de.has(u.code)){s=!1,await B(H(u.retryAfterSeconds,he,this.random));continue}throw u}}},r(b,"S"),b);function G(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=6e5}r(G,"k");function K(e){if((typeof e=="object"&&e!==null?e.name:void 0)==="TimeoutError")return new h({status:0,code:"timeout",message:"request timed out"});let t=e instanceof Error?e.message:String(e);return new h({status:0,code:"network_error",message:`network request failed: ${t}`})}r(K,"f");function _e(e){return e!==null&&typeof e=="object"&&"success"in e&&"data"in e?e.data:e}r(_e,"L");async function ve(e){let t="unknown_error",n=`request failed (HTTP ${e.status})`,i=Number.NaN,s;try{let d=await e.json();if(d!==null&&typeof d=="object"){let o=d;typeof o.code=="string"&&o.code.length>0&&(t=o.code),typeof o.message=="string"&&o.message.length>0&&(n=o.message),typeof o.retryAfterSeconds=="number"&&(i=o.retryAfterSeconds),Array.isArray(o.details?.issues)?s=o.details:Array.isArray(o.details?.errors)&&(s={...o.details,issues:[]})}}catch{}let a=e.headers.get("retry-after"),c=a===null?Math.floor(i):Number.parseInt(a,10);return new h({status:e.status,code:t,message:n,...Number.isFinite(c)&&c>=0?{retryAfterSeconds:c}:{},details:s})}r(ve,"V");function B(e){return new Promise(t=>setTimeout(t,e))}r(B,"R");function rt(e){let t=e?.portrait,n=t?.icao,i=t?.purpose==="id_document";return n==null?i?{policy:"reject",profile:"id_document"}:null:{policy:n.policy==="alert"?"alert":"reject",profile:i||n.profile==="id_document"?"id_document":"selfie"}}r(rt,"J");function at(e){return{...e.baselineEyeOpenness!==void 0?{baselineEyeOpenness:e.baselineEyeOpenness}:{},...e.baselineEyeOpennessLeft!==void 0&&e.baselineEyeOpennessRight!==void 0?{baselineEyeOpennessLeft:e.baselineEyeOpennessLeft,baselineEyeOpennessRight:e.baselineEyeOpennessRight}:{},criteria:e.verdict??{},...e.backgroundCheck!==void 0?{backgroundCheck:e.backgroundCheck}:{}}}r(at,"Q");var ge=new Set(["nni_unbound","id_number_unbound","method_required","mobile_required","portrait_required"]);function ut(e){return ge.has(e)}r(ut,"ve");function lt(e,t,n){let i=t.detail;return{check:e,kind:t.kind,...i?.name!==void 0?{name:i.name}:{},...i?.phase!==void 0?{phase:i.phase}:{},...i?.engineKind!==void 0?{engineKind:i.engineKind}:{},attempt:Math.max(0,Math.min(1e3,n))}}r(lt,"Pe");function pt(){let e=-1,t="";return{note(n){n==="starting"&&t!=="starting"&&(e+=1),t=n},newHandle(){t=""},noteError(){e<0&&(e=0)},get value(){return e}}}r(pt,"xe");var be={document:"document_photo",nfc:"document_chip",population_registry:"national_number",national_eid:"national_eid"};function y(e){return e.plan?.steps??[]}r(y,"f");function F(e){return Math.max(0,e.attempts.max-e.attempts.used)}r(F,"x");function ke(e){let t=e.plan?.choice;return t!==void 0&&e.plan?.current===t.nodeId?t:null}r(ke,"J");function ht(e){let t=ke(e);if(t?.kind!=="identity_method")return null;let n=t.options.map(s=>be[s.service]).filter(s=>s!==void 0),i=t.options.find(s=>s.nationalEid)?.nationalEid;return i?{available:!0,selected:null,options:n,nationalEid:i}:{available:!0,selected:null,options:n}}r(ht,"Ve");var we=new Set(["liveness","face_match"]);function j(e){return e!==void 0&&(e.state==="pending"||e.state==="input_required")}r(j,"R");function Me(e){return e.status!=="created"&&e.status!=="in_progress"}r(Me,"T");function Y(e){let t=e.plan?.current,n=t==null?void 0:y(e).find(i=>i.id===t);return j(n)?n:void 0}r(Y,"M");function $(e,t){return y(e).find(n=>n.checkType===t)}r($,"_");function O(e){let t=y(e),n=t.findIndex(i=>i.checkType==="liveness");return t.find((i,s)=>s>n&&i.checkType==="face_match")}r(O,"S");function Se(e,t){let n=$(t,"liveness")?.state,i=O(t)?.state;return(O(e)?.state??"pending")==="pending"&&(n==="passed"||n==="review")&&i!==void 0&&i!=="pending"&&i!=="skipped"}r(Se,"F");function Z(e,t){let n=new Map(y(e).map(i=>[i.id,i.state]));return y(t).filter(i=>i.checkType==="face_match"&&(n.get(i.id)??"pending")==="pending"&&i.state!=="pending"&&i.state!=="skipped").map(i=>i.id)}r(Z,"V");var Ie=/^[0-9a-f]{24}$/i;function x(e){return Ie.test(e)?`ses_${e}`:e}r(x,"k");function E(e,t){let n=x(e);return t===void 0?{sessionId:n,status:"unavailable"}:{sessionId:n,status:"unavailable",reasonCode:t}}r(E,"C");function W(e,t,n){let i=x(e);return n===void 0?{sessionId:i,status:t}:{sessionId:i,status:t,reasonCode:n}}r(W,"O");function mt(e,t){let n=Ae(e,t),i=Te(e);return i!==void 0&&(n.sandbox={simulated:!0,reason:i}),n}r(mt,"Ee");var Ce=new Set(["no_testers","tester_gate_not_used","tester_gate_missed"]);function Te(e){if(e.sandbox!==!0)return;let t=e.simulation?.reason;return Ce.has(t)?t:void 0}r(Te,"Z");function Ae(e,t){let n=x(e.sessionId);switch(e.status){case"created":case"in_progress":return $e(e,t);case"verified":return P(e,{sessionId:n,status:"verified"});case"review_pending":return P(e,W(n,"review",X(e,"review")));case"not_verified":return P(e,Ee(e));default:return P(e,{sessionId:n,status:"not_verified"})}}r(Ae,"Q");var xe=new Set([0,1,2,3]);function P(e,t){return xe.has(e.level)&&(t.level=e.level),typeof e.assurance=="string"&&e.assurance.length>0&&(t.assurance=e.assurance),t}r(P,"v");function Ee(e){let t={sessionId:x(e.sessionId),status:"not_verified"};return e.reason!==void 0&&(t.reason=e.reason),e.reasonCode!==void 0&&(t.reasonCode=e.reasonCode),e.reasonCode==="device_cooldown"&&e.retryAfter!==void 0&&(t.retryAfter=e.retryAfter),t}r(Ee,"ne");function Pe(e){return e==="rejected"?"rejected":e==="unavailable"?"unavailable":"inconclusive"}r(Pe,"te");function Oe(e,t){if(t===void 0)return!1;let n=y(t).find(i=>i.id===e.id);return n!==void 0&&n.attempts.used===e.attempts.used}r(Oe,"ie");function $e(e,t){let n=x(e.sessionId),i=y(e).find(a=>we.has(a.checkType)&&a.state==="input_required"&&a.reason!==void 0);if(i?.reason==="mobile_required")return E(n,"mobile_required");if(i?.reason!==void 0){if(i.result==="unavailable")return E(n,i.reason);let a=t.autoRetry&&(F(i)>0||Oe(i,t.previous))?{sessionId:n,status:"retry",reasonCode:i.reason,attemptsRemaining:F(i)}:{sessionId:n,status:"not_verified",reason:Pe(i.result),reasonCode:i.reason,attemptsRemaining:F(i)};return i.retakeHint!==void 0&&(a.retakeHint=i.retakeHint),a}let s=Y(e);return s===void 0&&y(e).some(a=>a.state==="review")?W(n,"review",X(e,"review")):s?.checkType==="portrait_icao"?E(n,"portrait_required"):E(n)}r($e,"re");function X(e,t){return y(e).find(n=>n.state===t&&n.reason!==void 0)?.reason}r(X,"L");function ee(e,t,n,i,s){return e.presignCapture!==void 0?e.presignCapture(t,n,i,s):e.presign(t,n,i)}r(ee,"K");function te(e){return{engine:e?.engine,durationMs:e?.clipMs,arm:e?.screenRamp?.nonce}}r(te,"q");var qe=["video/webm","video/mp4"],Q="image/jpeg",Re=2,Ne=1e3,Ke=1e4,He=3,Fe=10,ze=3,je=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),De=new Set(["session_not_active","check_not_found","check_already_finalized","check_out_of_order","identity_confirm_required","check_not_active","step_not_on_path","native_app_required"]),k,D=(k=class extends Error{constructor(){super("verification destroyed"),this.name="FlowCancelledError"}},r(k,"b"),k);function Le(e){let t=O(e);return $(e,"portrait_icao")?.state!=="pending"&&(t!==void 0?j(t):e.capture?.livePhoto?.oneCapture===!0)}r(Le,"me");var w,A=(w=class extends Error{constructor(t){super(t),this.name="AttestationError"}},r(w,"h"),w),M,Ue=(M=class extends A{constructor(t){super(`no attestation token: ${t}`),this.name="AttestationUnavailableError",this.code=t}},r(M,"E"),M);function ft(e){return new h({status:400,code:"attestation_invalid",message:`browser check: ${e}`,details:{issues:[],browserCheck:e}})}r(ft,"Oe");function Je(e){if(!(e instanceof h)||e.code!=="attestation_invalid")return;let t=e.details?.browserCheck;return typeof t=="string"?t:void 0}r(Je,"he");async function ne(e,t,n={}){let i=e.uuid(),s=!1,a=!1,c=0,d=0;for(;;)try{return await t(e.client,i)}catch(o){if(o instanceof A){if(a||o instanceof Ue)throw o;a=!0,n.onAttestationInvalid?.(),i=e.uuid();continue}if(!(o instanceof h))throw o;if(o.code==="consent_required"&&!s){s=!0,await e.ensureConsent({force:!0}),i=e.uuid();continue}if(o.code==="attestation_invalid"&&!a&&Je(o)===void 0){a=!0,n.onAttestationInvalid?.(),i=e.uuid();continue}if(o.code==="inference_unavailable"&&d<He){d+=1;let u=H(o.retryAfterSeconds,Fe,e.random??Math.random);e.onBusy?.({attempt:d,retryAfterSeconds:u/1e3}),await e.sleep(u),n.onAttestationInvalid?.(),i=e.uuid();continue}if(je.has(o.code)&&c<Re){c+=1;let u=o.retryAfterSeconds!==void 0?o.retryAfterSeconds*1e3:void 0;await e.sleep(u!==void 0?Math.min(u,Ke):Ne);continue}throw o}}r(ne,"D");var Ve=new Set(["passed","review","processing","skipped"]);async function yt(e){let{artifacts:t}=e,n=t.clip,i=v(t.clipMime??"");if(t.degraded==="NO_RECORDER"||n===void 0||!qe.includes(i))return{kind:"unavailable",reason:"no_recorder"};e.client.armCapture?.(2);let s=Ge(e,t.keyframe),a=Be(e,n,i,s),c=Ze(e,s),d=!1,o=new Set,u=!0,l=0;for(;;){if(e.isCancelled())return{kind:"cancelled"};let p=e.getView();if(Me(p))return{kind:"settled"};let m=Y(p),T=m?.checkType,q=T==="liveness"&&!d?"liveness":T==="face_match"&&!o.has(m?.id)&&o.size<2&&u?"face_match":null;if(q===null)return{kind:"settled"};if(q==="liveness"&&t.captureChannel==="desktop")return{kind:"unavailable",reason:"mobile_required"};try{if(q==="liveness"){d=!0;let f=await a();if(e.isCancelled())return{kind:"cancelled"};Se(p,f)&&o.add(O(f)?.id);for(let ie of Z(p,f))o.add(ie);await e.applySubmit(f,"liveness");let _=$(e.getView(),"liveness")?.state;u=_===void 0||Ve.has(_)}else{o.add(m?.id);let f=await c();if(e.isCancelled())return{kind:"cancelled"};for(let _ of Z(p,f))o.add(_);await e.applySubmit(f,"face_match")}}catch(f){if(e.isCancelled()||f instanceof D)return{kind:"cancelled"};let _=Xe(f);if(_.kind!=="resync"||l>=ze)return _;l+=1,await e.refreshView()}}}r(yt,"Le");function Ge(e,t){let n=null,i=null,s=r(()=>n!==null?Promise.resolve(n):(i??(i=(async()=>{let a=await ee(e.client,"image",Q,t.size,te(e.artifacts));return await e.client.uploadToSpaces(a.uploadUrl,t,Q),n=(await e.client.completeMedia(a.key)).key,e.onKeyframePromoted?.(n),n})().finally(()=>{i=null})),i),"r");return{ensure:s,attempt:r(()=>s().catch(()=>null),"attempt"),current:r(()=>n,"current")}}r(Ge,"ge");function Be(e,t,n,i){let s=e.clipKeys?.get()??null,a,c=null,d=0,o;return()=>ne(e,async(u,l)=>{if(s===null||a===void 0){if(e.isCancelled())throw new D;a===void 0&&!Le(e.getView())&&(a=null),e.onPhase("uploading");let[p,m]=await Promise.all([s!==null?Promise.resolve(s):(async()=>{let T=await ee(u,"clip",n,t.size,te(e.artifacts));return await u.uploadToSpaces(T.uploadUrl,t,n),(await u.completeMedia(T.key)).key})(),a!==void 0?Promise.resolve(a===null?null:a.imageKey):i.attempt()]);s=p,e.clipKeys?.set(p),a===void 0&&(a=m===null?null:{imageKey:m})}if(c===null){let p=performance.now();try{c=await e.getAttestation(),o=e.attestationError?.()}catch(m){throw m instanceof A?m:new A(m instanceof Error?m.message:String(m))}d=Math.round(performance.now()-p)}return e.onPhase("checking"),u.submitCheck("liveness",{clipKey:s,attestation:c,captureChannel:e.artifacts.captureChannel,capture:{...Qe(e.artifacts),attestationMs:d,attestationError:o,...We(e.attestationFacts?.())},...a!==null?{faceMatch:a}:{}},{idempotencyKey:l})},{onAttestationInvalid:r(()=>{c=null},"onAttestationInvalid")})}r(Be,"ye");function Ze(e,t){return()=>ne(e,async(n,i)=>{if(t.current()===null){if(e.isCancelled())throw new D;e.onPhase("uploading")}let s=await t.ensure();return e.onPhase("checking"),n.submitCheck("face_match",{imageKey:s},{idempotencyKey:i})})}r(Ze,"Se");function Qe(e){let t={width:e.width,height:e.height};for(let n of Ye)e[n]!==void 0&&(t[n]=e[n]);return t}r(Qe,"Re");var Ye=["engine","facingMode","mode","formFactor","clipMs","clipFrames","fps","clipRetakes","codec","cameraReadyMs","faceAcquireMs","captureMs","screenRamp","provenance"];function We(e){return e===void 0?{}:{attestationChecks:e.checks,...e.challengeMs!==void 0?{attestationChallengeMs:e.challengeMs}:{}}}r(We,"be");function Xe(e){if(e instanceof A)return{kind:"unavailable",reason:"attestation"};if(e instanceof h){if(e.code==="attestation_invalid")return{kind:"unavailable",reason:"attestation"};if(e.code==="inference_unavailable")return{kind:"unavailable",reason:"inference_unavailable"};if(e.code==="mobile_required")return{kind:"unavailable",reason:"mobile_required"};if(De.has(e.code))return{kind:"resync"}}return{kind:"unavailable",reason:"network"}}r(Xe,"we");var _t="form_answers_invalid",S,vt=(S=class extends Error{constructor(t,n){super(`form answers refused (${t.map(i=>`${i.id}: ${i.code}`).join(", ")})`),this.name="FormAnswersError",this.issues=t,this.source=n}},r(S,"U"),S),I,gt=(I=class extends Error{constructor(t,n){super(`invalid ${t} (${n})`),this.name="InvalidInputError",this.field=t,this.kind=n}},r(I,"B"),I),C,bt=(C=class extends Error{constructor(t,n){super(`invalid ${t} (${n})`),this.name="OtpInputError",this.field=t,this.kind=n}},r(C,"$"),C);function z(e){return e?.source==="upload"?null:e?.source==="choice"&&e.sourcePick!=="camera"?"upload_or_phone":"phone"}r(z,"I");function kt(e,t){if(t===void 0||!j(t)||t.requiresMobile!==!0)return null;switch(t.checkType){case"liveness":return"phone";case"face_match":{if(t.reason!==void 0)return"phone";let n=$(e,"portrait_icao");return n?.state==="passed"||n?.state==="review"?null:"phone"}case"doc_ocr":return z(e.documents);case"poa":return z(e.proofOfAddress);case"portrait_icao":{let n=e.portrait;return n?.pendingFix!==void 0||n?.reuse?.pending===!0?null:z(n)}default:return null}}r(kt,"Be");function et(e){let t=e?.capture,n=t?.mode;return n==="assisted"||n==="self"||n==="choice"?n:t?.cameraSwitch===!0?"assisted":"self"}r(et,"Ce");function wt(e){let t=e?.capture?.pick;return et(e)==="choice"&&(t==="self"||t==="assisted")?t:null}r(wt,"Ye");function Mt(e,t,n=null){return e==="choice"?t??n??"self":e}r(Mt,"ze");var St={"JP:drivers_license":{normalize:"upper_no_space_or_hyphen",pattern:"^[0-9]{12}$",check:null,registrySources:[],describe:"number must be the 12-digit Japanese driving licence number"},"JP:residence_permit":{normalize:"upper_no_space_or_hyphen",pattern:"^[A-Z]{2}[0-9]{8}[A-Z]{2}$",check:null,registrySources:[],describe:"number must be the 12-character residence card number: two letters, eight digits, two letters"},"MR:drivers_license":{normalize:"upper_no_space_or_hyphen",pattern:"^[0-9]{8}$",check:null,registrySources:[],describe:"number must be the 8-digit Mauritanian driver's license number"},"MR:national_id":{normalize:"trim",pattern:"^[0-9]{10}$",check:"mr_nni_mod97",registrySources:["MR.anrpts"],describe:"number must be the 10-digit Mauritanian national ID number with a valid check digit"}};export{h as a,v as b,st as c,rt as d,at as e,ut as f,lt as g,pt as h,be as i,y as j,F as k,ke as l,ht as m,j as n,Me as o,Y as p,$ as q,x as r,E as s,mt as t,Te as u,ee as v,qe as w,Ue as x,ft as y,Je as z,ne as A,yt as B,Qe as C,_t as D,vt as E,gt as F,bt as G,kt as H,et as I,wt as J,Mt as K,St as L};
|
|
1
|
+
import{b as L}from"./chunk-SX373VNU.js";import{a as J,c as R}from"./chunk-VHJIEZ5D.js";import{b as U}from"./chunk-6MYG4HWP.js";import{a as r}from"./chunk-4FHWXBOB.js";var g,h=(g=class extends Error{constructor(t){super(t.message),this.name="HostedApiError",this.status=t.status,this.code=t.code,t.retryAfterSeconds!==void 0&&(this.retryAfterSeconds=t.retryAfterSeconds),t.details&&(this.details=t.details)}},r(g,"u"),g);function H(e,t,n=Math.random){let i=(e??t)*1e3,s=Math.min(Math.max(i,500),2e4),a=Math.round(s*(1+(n()*2-1)*.25));return Math.min(Math.max(a,500),2e4)}r(H,"T");var V=6e4,N=4,se=3e4,re=9e5,ae=200,oe=5,ce=400,de=new Set(["server_busy","request_timeout"]),ue=20,le=60,pe=600,he=2;function v(e){return(e.split(";")[0]??"").trim()}r(v,"l");var me={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},fe=`@sekyro/web/${J}`,ye=fe,b,st=(b=class{constructor(t){this.sessionId=null,this.bootstrap=null,this.captureNonces=[],this.captureFetch=null,this.reportedIssues=new Map,this.issueReports=0,this.issuesPausedUntil=0,this.apiOrigin=t.apiOrigin.replace(/\/+$/,""),this.sessionToken=t.sessionToken;let n=t.fetch;this.fetchImpl=(i,s)=>(n??globalThis.fetch).call(globalThis,i,s),this.requestTimeoutMs=t.requestTimeoutMs??se,this.retryAttempts=t.inProgressRetry?.attempts??oe,this.retryDelayMs=t.inProgressRetry?.delayMs??ce,this.random=t.random??Math.random,this.clientLocale=t.locale}async getSession(){let t=await this.api("GET","/hosted/session");return this.sessionId=t.sessionId,t}async recordConsent(t){let n=await this.api("POST","/hosted/consent",{body:{locale:t},busyRetry:!0}),i=this.captureHold;return this.captureHold=void 0,i&&this.armCapture(i),n}async reportCameraUnavailable(t){return this.api("POST","/hosted/camera-unavailable",{body:{cause:t}})}async testerGate(t){return this.api("POST","/hosted/tester-gate",{body:{input:t}})}async reportCaptureIssue(t){let n=typeof t.name=="string"?t.name.replace(/[^A-Za-z]/g,"").slice(0,40):"",i=typeof t.engineKind=="string"&&/^[a-z_]{1,32}$/.test(t.engineKind)?t.engineKind:void 0,s=typeof t.attempt=="number"&&Number.isInteger(t.attempt)&&t.attempt>=0&&t.attempt<=1e3?t.attempt:void 0,a=t.check==="attestation"?s??"":"",c=[t.check,a,t.kind,n,t.phase??"",i??""].join("|"),d=this.reportedIssues.get(c);if(d!==void 0)return d;if(Date.now()<this.issuesPausedUntil||this.issueReports>=ue)return;let o={check:t.check,kind:t.kind,...n!==""?{name:n}:{},...t.phase!==void 0?{phase:t.phase}:{},...i!==void 0?{engineKind:i}:{},...s!==void 0?{attempt:s}:{},...t.formFactor!==void 0?{formFactor:t.formFactor}:{},...typeof t.detail=="string"&&/^\d{1,10}$/.test(t.detail)?{detail:t.detail}:{},...G(t.challengeMs)?{challengeMs:t.challengeMs}:{},...G(t.readyMs)?{readyMs:t.readyMs}:{},...t.inApp===!0?{inApp:!0}:{}};this.issueReports+=1;let u=this.api("POST","/hosted/capture-issue",{body:o,empty:!0}).catch(l=>{if(l instanceof h&&l.status===429){let p=Math.min(Math.max(l.retryAfterSeconds??le,0),pe);this.issuesPausedUntil=Math.max(this.issuesPausedUntil,Date.now()+p*1e3);return}(!(l instanceof h)||l.status===0||l.status>=500)&&this.reportedIssues.delete(c)});return this.reportedIssues.set(c,u),u}async choose(t,n){let i=await this.api("POST","/hosted/choice",{body:{nodeId:t,option:n},busyRetry:!0});return this.sessionId=i.sessionId,i}async confirmIdentity(t){return this.api("POST","/hosted/identity/confirm",{body:{decision:t}})}async identityPortrait(){return this.api("GET","/hosted/identity/portrait",{blob:!0})}async presign(t,n,i,s={}){let a=await this.ensureSessionId(),c={kind:t,contentType:v(n),contentLength:i,...s.source==="upload"?{source:"upload"}:{}};return this.api("POST",`/sessions/${a}/media`,{body:c})}armCapture(t=2){let n=Date.now();this.captureNonces.filter(i=>i.expiresAt-V>n).length>=t||(this.captureHold===void 0?this.fillCaptureNonces(t,t):this.captureHold=Math.max(this.captureHold,t))}async armRamp(){try{let t=await this.ensureSessionId(),n=await this.api("POST",`/sessions/${t}/media/capture-nonces`,{body:{count:2,ramp:!0}}),i=Date.now(),s=L(n.screenRamp)?n.screenRamp:void 0,a=i+Math.max(0,n.expiresIn)*1e3;for(let d of Array.isArray(n.nonces)?n.nonces:[])typeof d!="string"||d.length===0||this.captureNonces.push({nonce:d,expiresAt:a,...s!==void 0?{arm:s.nonce}:{}});this.captureNonces=this.captureNonces.slice(-N),this.captureHold=void 0;let c=typeof n.rampExpiresIn=="number"&&n.rampExpiresIn>0?n.rampExpiresIn:0;return{...s!==void 0?{challenge:s}:{},expiresAt:i+c*1e3}}catch{return}}async presignCapture(t,n,i,s={}){let a=await this.ensureSessionId(),c=await this.takeCaptureNonce(s.arm),d=c===void 0?void 0:{nonce:c,...s.engine!==void 0?{engine:s.engine.slice(0,32)}:{},...s.durationMs!==void 0&&Number.isFinite(s.durationMs)?{captureMs:Math.min(36e5,Math.max(0,Math.round(s.durationMs)))}:{}},o={kind:t,contentType:v(n),contentLength:i,capture:d};return this.api("POST",`/sessions/${a}/media`,{body:o})}async takeCaptureNonce(t){let n=r(()=>{let i=Date.now();this.captureNonces=this.captureNonces.filter(a=>a.expiresAt-V>i);let s=this.captureNonces.findIndex(a=>a.arm===t);return this.captureNonces.splice(s<0?0:s,1)[0]?.nonce},"n");for(let i=0;i<2;i++){let s=n();if(s!==void 0)return s;await this.fillCaptureNonces(1)}return n()}fillCaptureNonces(t,n=0){return this.captureFetch??(this.captureFetch=(async()=>{try{let i=await this.ensureSessionId(),s=await this.api("POST",`/sessions/${i}/media/capture-nonces`,{body:{count:Math.min(N,Math.max(1,t))}}),a=Date.now()+Math.max(0,s.expiresIn)*1e3;for(let c of Array.isArray(s.nonces)?s.nonces:[])typeof c=="string"&&c.length>0&&this.captureNonces.push({nonce:c,expiresAt:a});this.captureNonces=this.captureNonces.slice(-N),this.captureHold=void 0}catch(i){i instanceof h&&i.code==="consent_required"&&(this.captureHold=Math.max(this.captureHold??0,n))}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(t,n,i){let s;try{s=await this.fetchImpl(t,{method:"PUT",headers:{"content-type":v(i)},body:n,signal:AbortSignal.timeout(re)})}catch(a){throw K(a)}if(!s.ok){let a=(await s.text().catch(()=>"")).slice(0,ae);throw new h({status:s.status,code:"upload_failed",message:`media upload failed (HTTP ${s.status})${a?`: ${a}`:""}`})}}async completeMedia(t){let n=await this.ensureSessionId();return this.api("POST",`/sessions/${n}/media/complete`,{body:{key:t}})}async submitCheck(t,n,i={}){let s=await this.ensureSessionId(),a={input:n,forceOutcome:i.forceOutcome};return this.api("POST",`/sessions/${s}/checks/${t}`,{body:a,idempotencyKey:i.idempotencyKey,...i.browserCheckToken!==void 0?{browserCheckToken:i.browserCheckToken}:{},busyRetry:i.idempotencyKey!==void 0})}async uploadAndSubmit(t,n,i,s={}){let a=v(n.contentType),c=await this.presign(n.kind,a,n.blob.size);await this.uploadToSpaces(c.uploadUrl,n.blob,a);let d=await this.completeMedia(c.key),o={...i,[me[t]]:d.key};return this.submitCheck(t,o,s)}async ensureSessionId(){return this.sessionId!==null?this.sessionId:(this.bootstrap??(this.bootstrap=this.getSession().finally(()=>{this.bootstrap=null})),(await this.bootstrap).sessionId)}async api(t,n,i={}){let s=t==="GET"||i.busyRetry===!0,a=`${this.apiOrigin}/api/v2${n}`,c={"x-session-token":this.sessionToken,"x-sekyro-sdk":ye};i.body!==void 0&&(c["content-type"]="application/json"),i.idempotencyKey!==void 0&&(c["x-idempotency-key"]=i.idempotencyKey),i.browserCheckToken!==void 0&&(c["sekyro-browser-check"]=i.browserCheckToken),this.clientLocale!==void 0&&(c["sekyro-client-locale"]=this.clientLocale);try{let d=R.timezone();d!==void 0&&(c["sekyro-client-timezone"]=d)}catch{}c["sekyro-client-form-factor"]=U();try{let d=await R.deviceHeader();d!==void 0&&(c["sekyro-client-device"]=d)}catch{}for(let d=0;;d++){let o;try{o=await this.fetchImpl(a,{method:t,headers:c,...i.body!==void 0?{body:JSON.stringify(i.body)}:{},cache:"no-store",signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(l){throw K(l)}if(o.ok){if(i.empty===!0)return;if(i.blob===!0)try{return await o.blob()}catch(p){throw K(p)}let l;try{l=await o.json()}catch{throw new h({status:o.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${o.status})`})}return _e(l)}let u=await ve(o);if(u.code==="idempotency_in_progress"&&d<this.retryAttempts){this.retryDelayMs>0&&await B(this.retryDelayMs);continue}if(s&&u.status===503&&de.has(u.code)){s=!1,await B(H(u.retryAfterSeconds,he,this.random));continue}throw u}}},r(b,"S"),b);function G(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=6e5}r(G,"k");function K(e){if((typeof e=="object"&&e!==null?e.name:void 0)==="TimeoutError")return new h({status:0,code:"timeout",message:"request timed out"});let t=e instanceof Error?e.message:String(e);return new h({status:0,code:"network_error",message:`network request failed: ${t}`})}r(K,"f");function _e(e){return e!==null&&typeof e=="object"&&"success"in e&&"data"in e?e.data:e}r(_e,"L");async function ve(e){let t="unknown_error",n=`request failed (HTTP ${e.status})`,i=Number.NaN,s;try{let d=await e.json();if(d!==null&&typeof d=="object"){let o=d;typeof o.code=="string"&&o.code.length>0&&(t=o.code),typeof o.message=="string"&&o.message.length>0&&(n=o.message),typeof o.retryAfterSeconds=="number"&&(i=o.retryAfterSeconds),Array.isArray(o.details?.issues)?s=o.details:Array.isArray(o.details?.errors)&&(s={...o.details,issues:[]})}}catch{}let a=e.headers.get("retry-after"),c=a===null?Math.floor(i):Number.parseInt(a,10);return new h({status:e.status,code:t,message:n,...Number.isFinite(c)&&c>=0?{retryAfterSeconds:c}:{},details:s})}r(ve,"V");function B(e){return new Promise(t=>setTimeout(t,e))}r(B,"R");function rt(e){let t=e?.portrait,n=t?.icao,i=t?.purpose==="id_document";return n==null?i?{policy:"reject",profile:"id_document"}:null:{policy:n.policy==="alert"?"alert":"reject",profile:i||n.profile==="id_document"?"id_document":"selfie"}}r(rt,"J");function at(e){return{...e.baselineEyeOpenness!==void 0?{baselineEyeOpenness:e.baselineEyeOpenness}:{},...e.baselineEyeOpennessLeft!==void 0&&e.baselineEyeOpennessRight!==void 0?{baselineEyeOpennessLeft:e.baselineEyeOpennessLeft,baselineEyeOpennessRight:e.baselineEyeOpennessRight}:{},criteria:e.verdict??{},...e.backgroundCheck!==void 0?{backgroundCheck:e.backgroundCheck}:{}}}r(at,"Q");var ge=new Set(["nni_unbound","id_number_unbound","method_required","mobile_required","portrait_required"]);function ut(e){return ge.has(e)}r(ut,"ve");function lt(e,t,n){let i=t.detail;return{check:e,kind:t.kind,...i?.name!==void 0?{name:i.name}:{},...i?.phase!==void 0?{phase:i.phase}:{},...i?.engineKind!==void 0?{engineKind:i.engineKind}:{},attempt:Math.max(0,Math.min(1e3,n))}}r(lt,"Pe");function pt(){let e=-1,t="";return{note(n){n==="starting"&&t!=="starting"&&(e+=1),t=n},newHandle(){t=""},noteError(){e<0&&(e=0)},get value(){return e}}}r(pt,"xe");var be={document:"document_photo",nfc:"document_chip",population_registry:"national_number",national_eid:"national_eid"};function y(e){return e.plan?.steps??[]}r(y,"f");function F(e){return Math.max(0,e.attempts.max-e.attempts.used)}r(F,"x");function ke(e){let t=e.plan?.choice;return t!==void 0&&e.plan?.current===t.nodeId?t:null}r(ke,"J");function ht(e){let t=ke(e);if(t?.kind!=="identity_method")return null;let n=t.options.map(s=>be[s.service]).filter(s=>s!==void 0),i=t.options.find(s=>s.nationalEid)?.nationalEid;return i?{available:!0,selected:null,options:n,nationalEid:i}:{available:!0,selected:null,options:n}}r(ht,"Ve");var we=new Set(["liveness","face_match"]);function j(e){return e!==void 0&&(e.state==="pending"||e.state==="input_required")}r(j,"R");function Me(e){return e.status!=="created"&&e.status!=="in_progress"}r(Me,"T");function Y(e){let t=e.plan?.current,n=t==null?void 0:y(e).find(i=>i.id===t);return j(n)?n:void 0}r(Y,"M");function $(e,t){return y(e).find(n=>n.checkType===t)}r($,"_");function O(e){let t=y(e),n=t.findIndex(i=>i.checkType==="liveness");return t.find((i,s)=>s>n&&i.checkType==="face_match")}r(O,"S");function Se(e,t){let n=$(t,"liveness")?.state,i=O(t)?.state;return(O(e)?.state??"pending")==="pending"&&(n==="passed"||n==="review")&&i!==void 0&&i!=="pending"&&i!=="skipped"}r(Se,"F");function Z(e,t){let n=new Map(y(e).map(i=>[i.id,i.state]));return y(t).filter(i=>i.checkType==="face_match"&&(n.get(i.id)??"pending")==="pending"&&i.state!=="pending"&&i.state!=="skipped").map(i=>i.id)}r(Z,"V");var Ie=/^[0-9a-f]{24}$/i;function x(e){return Ie.test(e)?`ses_${e}`:e}r(x,"k");function E(e,t){let n=x(e);return t===void 0?{sessionId:n,status:"unavailable"}:{sessionId:n,status:"unavailable",reasonCode:t}}r(E,"C");function W(e,t,n){let i=x(e);return n===void 0?{sessionId:i,status:t}:{sessionId:i,status:t,reasonCode:n}}r(W,"O");function mt(e,t){let n=Ae(e,t),i=Te(e);return i!==void 0&&(n.sandbox={simulated:!0,reason:i}),n}r(mt,"Ee");var Ce=new Set(["no_testers","tester_gate_not_used","tester_gate_missed"]);function Te(e){if(e.sandbox!==!0)return;let t=e.simulation?.reason;return Ce.has(t)?t:void 0}r(Te,"Z");function Ae(e,t){let n=x(e.sessionId);switch(e.status){case"created":case"in_progress":return $e(e,t);case"verified":return P(e,{sessionId:n,status:"verified"});case"review_pending":return P(e,W(n,"review",X(e,"review")));case"not_verified":return P(e,Ee(e));default:return P(e,{sessionId:n,status:"not_verified"})}}r(Ae,"Q");var xe=new Set([0,1,2,3]);function P(e,t){return xe.has(e.level)&&(t.level=e.level),typeof e.assurance=="string"&&e.assurance.length>0&&(t.assurance=e.assurance),t}r(P,"v");function Ee(e){let t={sessionId:x(e.sessionId),status:"not_verified"};return e.reason!==void 0&&(t.reason=e.reason),e.reasonCode!==void 0&&(t.reasonCode=e.reasonCode),e.reasonCode==="device_cooldown"&&e.retryAfter!==void 0&&(t.retryAfter=e.retryAfter),t}r(Ee,"ne");function Pe(e){return e==="rejected"?"rejected":e==="unavailable"?"unavailable":"inconclusive"}r(Pe,"te");function Oe(e,t){if(t===void 0)return!1;let n=y(t).find(i=>i.id===e.id);return n!==void 0&&n.attempts.used===e.attempts.used}r(Oe,"ie");function $e(e,t){let n=x(e.sessionId),i=y(e).find(a=>we.has(a.checkType)&&a.state==="input_required"&&a.reason!==void 0);if(i?.reason==="mobile_required")return E(n,"mobile_required");if(i?.reason!==void 0){if(i.result==="unavailable")return E(n,i.reason);let a=t.autoRetry&&(F(i)>0||Oe(i,t.previous))?{sessionId:n,status:"retry",reasonCode:i.reason,attemptsRemaining:F(i)}:{sessionId:n,status:"not_verified",reason:Pe(i.result),reasonCode:i.reason,attemptsRemaining:F(i)};return i.retakeHint!==void 0&&(a.retakeHint=i.retakeHint),a}let s=Y(e);return s===void 0&&y(e).some(a=>a.state==="review")?W(n,"review",X(e,"review")):s?.checkType==="portrait_icao"?E(n,"portrait_required"):E(n)}r($e,"re");function X(e,t){return y(e).find(n=>n.state===t&&n.reason!==void 0)?.reason}r(X,"L");function ee(e,t,n,i,s){return e.presignCapture!==void 0?e.presignCapture(t,n,i,s):e.presign(t,n,i)}r(ee,"K");function te(e){return{engine:e?.engine,durationMs:e?.clipMs,arm:e?.screenRamp?.nonce}}r(te,"q");var qe=["video/webm","video/mp4"],Q="image/jpeg",Re=2,Ne=1e3,Ke=1e4,He=3,Fe=10,ze=3,je=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),De=new Set(["session_not_active","check_not_found","check_already_finalized","check_out_of_order","identity_confirm_required","check_not_active","step_not_on_path","native_app_required"]),k,D=(k=class extends Error{constructor(){super("verification destroyed"),this.name="FlowCancelledError"}},r(k,"b"),k);function Le(e){let t=O(e);return $(e,"portrait_icao")?.state!=="pending"&&(t!==void 0?j(t):e.capture?.livePhoto?.oneCapture===!0)}r(Le,"me");var w,A=(w=class extends Error{constructor(t){super(t),this.name="AttestationError"}},r(w,"h"),w),M,Ue=(M=class extends A{constructor(t){super(`no attestation token: ${t}`),this.name="AttestationUnavailableError",this.code=t}},r(M,"E"),M);function ft(e){return new h({status:400,code:"attestation_invalid",message:`browser check: ${e}`,details:{issues:[],browserCheck:e}})}r(ft,"Oe");function Je(e){if(!(e instanceof h)||e.code!=="attestation_invalid")return;let t=e.details?.browserCheck;return typeof t=="string"?t:void 0}r(Je,"he");async function ne(e,t,n={}){let i=e.uuid(),s=!1,a=!1,c=0,d=0;for(;;)try{return await t(e.client,i)}catch(o){if(o instanceof A){if(a||o instanceof Ue)throw o;a=!0,n.onAttestationInvalid?.(),i=e.uuid();continue}if(!(o instanceof h))throw o;if(o.code==="consent_required"&&!s){s=!0,await e.ensureConsent({force:!0}),i=e.uuid();continue}if(o.code==="attestation_invalid"&&!a&&Je(o)===void 0){a=!0,n.onAttestationInvalid?.(),i=e.uuid();continue}if(o.code==="inference_unavailable"&&d<He){d+=1;let u=H(o.retryAfterSeconds,Fe,e.random??Math.random);e.onBusy?.({attempt:d,retryAfterSeconds:u/1e3}),await e.sleep(u),n.onAttestationInvalid?.(),i=e.uuid();continue}if(je.has(o.code)&&c<Re){c+=1;let u=o.retryAfterSeconds!==void 0?o.retryAfterSeconds*1e3:void 0;await e.sleep(u!==void 0?Math.min(u,Ke):Ne);continue}throw o}}r(ne,"D");var Ve=new Set(["passed","review","processing","skipped"]);async function yt(e){let{artifacts:t}=e,n=t.clip,i=v(t.clipMime??"");if(t.degraded==="NO_RECORDER"||n===void 0||!qe.includes(i))return{kind:"unavailable",reason:"no_recorder"};e.client.armCapture?.(2);let s=Ge(e,t.keyframe),a=Be(e,n,i,s),c=Ze(e,s),d=!1,o=new Set,u=!0,l=0;for(;;){if(e.isCancelled())return{kind:"cancelled"};let p=e.getView();if(Me(p))return{kind:"settled"};let m=Y(p),T=m?.checkType,q=T==="liveness"&&!d?"liveness":T==="face_match"&&!o.has(m?.id)&&o.size<2&&u?"face_match":null;if(q===null)return{kind:"settled"};if(q==="liveness"&&t.captureChannel==="desktop")return{kind:"unavailable",reason:"mobile_required"};try{if(q==="liveness"){d=!0;let f=await a();if(e.isCancelled())return{kind:"cancelled"};Se(p,f)&&o.add(O(f)?.id);for(let ie of Z(p,f))o.add(ie);await e.applySubmit(f,"liveness");let _=$(e.getView(),"liveness")?.state;u=_===void 0||Ve.has(_)}else{o.add(m?.id);let f=await c();if(e.isCancelled())return{kind:"cancelled"};for(let _ of Z(p,f))o.add(_);await e.applySubmit(f,"face_match")}}catch(f){if(e.isCancelled()||f instanceof D)return{kind:"cancelled"};let _=Xe(f);if(_.kind!=="resync"||l>=ze)return _;l+=1,await e.refreshView()}}}r(yt,"Le");function Ge(e,t){let n=null,i=null,s=r(()=>n!==null?Promise.resolve(n):(i??(i=(async()=>{let a=await ee(e.client,"image",Q,t.size,te(e.artifacts));return await e.client.uploadToSpaces(a.uploadUrl,t,Q),n=(await e.client.completeMedia(a.key)).key,e.onKeyframePromoted?.(n),n})().finally(()=>{i=null})),i),"r");return{ensure:s,attempt:r(()=>s().catch(()=>null),"attempt"),current:r(()=>n,"current")}}r(Ge,"ge");function Be(e,t,n,i){let s=e.clipKeys?.get()??null,a,c=null,d=0,o;return()=>ne(e,async(u,l)=>{if(s===null||a===void 0){if(e.isCancelled())throw new D;a===void 0&&!Le(e.getView())&&(a=null),e.onPhase("uploading");let[p,m]=await Promise.all([s!==null?Promise.resolve(s):(async()=>{let T=await ee(u,"clip",n,t.size,te(e.artifacts));return await u.uploadToSpaces(T.uploadUrl,t,n),(await u.completeMedia(T.key)).key})(),a!==void 0?Promise.resolve(a===null?null:a.imageKey):i.attempt()]);s=p,e.clipKeys?.set(p),a===void 0&&(a=m===null?null:{imageKey:m})}if(c===null){let p=performance.now();try{c=await e.getAttestation(),o=e.attestationError?.()}catch(m){throw m instanceof A?m:new A(m instanceof Error?m.message:String(m))}d=Math.round(performance.now()-p)}return e.onPhase("checking"),u.submitCheck("liveness",{clipKey:s,attestation:c,captureChannel:e.artifacts.captureChannel,capture:{...Qe(e.artifacts),attestationMs:d,attestationError:o,...We(e.attestationFacts?.())},...a!==null?{faceMatch:a}:{}},{idempotencyKey:l})},{onAttestationInvalid:r(()=>{c=null},"onAttestationInvalid")})}r(Be,"ye");function Ze(e,t){return()=>ne(e,async(n,i)=>{if(t.current()===null){if(e.isCancelled())throw new D;e.onPhase("uploading")}let s=await t.ensure();return e.onPhase("checking"),n.submitCheck("face_match",{imageKey:s},{idempotencyKey:i})})}r(Ze,"Se");function Qe(e){let t={width:e.width,height:e.height};for(let n of Ye)e[n]!==void 0&&(t[n]=e[n]);return t}r(Qe,"Re");var Ye=["engine","facingMode","mode","formFactor","clipMs","clipFrames","fps","clipRetakes","codec","cameraReadyMs","faceAcquireMs","captureMs","screenRamp","provenance"];function We(e){return e===void 0?{}:{attestationChecks:e.checks,...e.challengeMs!==void 0?{attestationChallengeMs:e.challengeMs}:{}}}r(We,"be");function Xe(e){if(e instanceof A)return{kind:"unavailable",reason:"attestation"};if(e instanceof h){if(e.code==="attestation_invalid")return{kind:"unavailable",reason:"attestation"};if(e.code==="inference_unavailable")return{kind:"unavailable",reason:"inference_unavailable"};if(e.code==="mobile_required")return{kind:"unavailable",reason:"mobile_required"};if(De.has(e.code))return{kind:"resync"}}return{kind:"unavailable",reason:"network"}}r(Xe,"we");var _t="form_answers_invalid",S,vt=(S=class extends Error{constructor(t,n){super(`form answers refused (${t.map(i=>`${i.id}: ${i.code}`).join(", ")})`),this.name="FormAnswersError",this.issues=t,this.source=n}},r(S,"U"),S),I,gt=(I=class extends Error{constructor(t,n){super(`invalid ${t} (${n})`),this.name="InvalidInputError",this.field=t,this.kind=n}},r(I,"B"),I),C,bt=(C=class extends Error{constructor(t,n){super(`invalid ${t} (${n})`),this.name="OtpInputError",this.field=t,this.kind=n}},r(C,"$"),C);function z(e){return e?.source==="upload"?null:e?.source==="choice"&&e.sourcePick!=="camera"?"upload_or_phone":"phone"}r(z,"I");function kt(e,t){if(t===void 0||!j(t)||t.requiresMobile!==!0)return null;switch(t.checkType){case"liveness":return"phone";case"face_match":{if(t.reason!==void 0)return"phone";let n=$(e,"portrait_icao");return n?.state==="passed"||n?.state==="review"?null:"phone"}case"doc_ocr":return z(e.documents);case"poa":return z(e.proofOfAddress);case"portrait_icao":{let n=e.portrait;return n?.pendingFix!==void 0||n?.reuse?.pending===!0?null:z(n)}default:return null}}r(kt,"Be");function et(e){let t=e?.capture,n=t?.mode;return n==="assisted"||n==="self"||n==="choice"?n:t?.cameraSwitch===!0?"assisted":"self"}r(et,"Ce");function wt(e){let t=e?.capture?.pick;return et(e)==="choice"&&(t==="self"||t==="assisted")?t:null}r(wt,"Ye");function Mt(e,t,n=null){return e==="choice"?t??n??"self":e}r(Mt,"ze");var St={"JP:drivers_license":{normalize:"upper_no_space_or_hyphen",pattern:"^[0-9]{12}$",check:null,registrySources:[],describe:"number must be the 12-digit Japanese driving licence number"},"JP:residence_permit":{normalize:"upper_no_space_or_hyphen",pattern:"^[A-Z]{2}[0-9]{8}[A-Z]{2}$",check:null,registrySources:[],describe:"number must be the 12-character residence card number: two letters, eight digits, two letters"},"MR:drivers_license":{normalize:"upper_no_space_or_hyphen",pattern:"^[0-9]{8}$",check:null,registrySources:[],describe:"number must be the 8-digit Mauritanian driver's license number"},"MR:national_id":{normalize:"trim",pattern:"^[0-9]{10}$",check:"mr_nni_mod97",registrySources:["MR.anrpts"],describe:"number must be the 10-digit Mauritanian national ID number with a valid check digit"}};export{h as a,v as b,st as c,rt as d,at as e,ut as f,lt as g,pt as h,be as i,y as j,F as k,ke as l,ht as m,j as n,Me as o,Y as p,$ as q,x as r,E as s,mt as t,Te as u,ee as v,qe as w,Ue as x,ft as y,Je as z,ne as A,yt as B,Qe as C,_t as D,vt as E,gt as F,bt as G,kt as H,et as I,wt as J,Mt as K,St as L};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./chunk-SIBJ56BG.js";import{a}from"./chunk-5QL6W6FW.js";import{a as o}from"./chunk-4FHWXBOB.js";var c=5;function i(t,n){try{return new Intl.ListFormat([n],{style:"long",type:"conjunction"}).format(t)}catch{return t.join(", ")}}o(i,"a");a(i,"joined");function u(t,n){if(t===void 0||t.length===0||t.length>c)return null;let r=i(t.map(l=>e(l,n.locale)),n.locale);return n.t(t.length===1?"doc.nationalityOne":"doc.nationalityMany",{countries:r})}o(u,"c");a(u,"nationalityLine");export{u as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as j}from"./chunk-
|
|
1
|
+
import{a as j}from"./chunk-IX5EXDOC.js";import{d as U}from"./chunk-L2FCXJYM.js";import{L as k,M as I,a as A,b as V,c as h,v as T,w as _,y as C}from"./chunk-QVU5SNFG.js";import{a as n}from"./chunk-5QL6W6FW.js";import{a as s,c as N}from"./chunk-4FHWXBOB.js";var f=N(A(),1),e=N(V(),1);var D={"portrait.source.title":"كيف تريد إضافة صورتك الشخصية؟","portrait.source.description":"التقط صورة جديدة بالكاميرا، أو ارفع صورة حديثة من هذا الجهاز.","portrait.source.camera":"التقاط صورة","portrait.source.upload":"رفع صورة","portrait.source.uploadInstead":"رفع صورة بدلًا من ذلك","portrait.upload.title":"ارفع صورتك الشخصية","portrait.upload.hint":"صورة حديثة لوجهك، تنظر فيها مباشرة إلى الكاميرا، أمام جدار فاتح وبلون واحد.","portrait.upload.choose":"اختيار صورة","portrait.upload.unsupported":"اختر صورة بصيغة JPEG أو PNG أو HEIC.","portrait.upload.failed":"تعذّر إرسال هذه الصورة. حاول مرة أخرى.","portrait.review.title":"تحقّق من صورتك المعدّلة","portrait.review.description":"عدّلنا صورتك لتطابق قواعد صور الهوية. لم نغيّر وجهك.","portrait.review.original":"صورتك","portrait.review.fixed":"الصورة المعدّلة","portrait.review.fixesTitle":"ما الذي غيّرناه","portrait.review.accept":"استخدام هذه الصورة","portrait.review.retake":"إعادة الالتقاط","portrait.review.uploadAnother":"رفع صورة أخرى","portrait.fixes.crop":"قُصّت","portrait.fixes.scale":"غُيّر حجمها","portrait.fixes.straighten":"عُدّل ميلها","portrait.fixes.background":"استُبدلت الخلفية","portrait.fixes.exposure":"عُدّل السطوع","portrait.fixes.white_balance":"وُزنت الألوان","reasons.portrait_morph_suspected":"لا يمكن استخدام هذه الصورة. التقط صورة جديدة للشخص.","reasons.portrait_reference_mismatch":"لا تطابق الصورة المرجع. التقط صورة جديدة للشخص.","reasons.portrait_declined_fix":"التقط صورة أخرى أو ارفعها."},y={"portrait.source.title":"How do you want to add your ID photo?","portrait.source.description":"Take a new photo with the camera, or upload a recent photo from this device.","portrait.source.camera":"Take a photo","portrait.source.upload":"Upload a photo","portrait.source.uploadInstead":"Upload a photo instead","portrait.upload.title":"Upload your ID photo","portrait.upload.hint":"A recent photo of your face, looking straight at the camera, in front of a plain, light wall.","portrait.upload.choose":"Choose a photo","portrait.upload.unsupported":"Choose a JPEG, PNG or HEIC photo.","portrait.upload.failed":"We could not send this photo. Try again.","portrait.review.title":"Check your adjusted photo","portrait.review.description":"We adjusted your photo to meet the ID photo rules. Your face was not changed.","portrait.review.original":"Your photo","portrait.review.fixed":"Adjusted photo","portrait.review.fixesTitle":"What we changed","portrait.review.accept":"Use this photo","portrait.review.retake":"Take another","portrait.review.uploadAnother":"Upload another","portrait.fixes.crop":"Cropped","portrait.fixes.scale":"Resized","portrait.fixes.straighten":"Straightened","portrait.fixes.background":"Background replaced","portrait.fixes.exposure":"Brightness adjusted","portrait.fixes.white_balance":"Colours balanced","reasons.portrait_morph_suspected":"This photo cannot be used. Take a new photo of the person.","reasons.portrait_reference_mismatch":"The photo does not match the reference. Take a new photo of the person.","reasons.portrait_declined_fix":"Take or upload another photo."},G={"portrait.source.title":"Comment voulez-vous ajouter votre photo d'identité ?","portrait.source.description":"Prenez une nouvelle photo avec la caméra, ou importez une photo récente depuis cet appareil.","portrait.source.camera":"Prendre une photo","portrait.source.upload":"Importer une photo","portrait.source.uploadInstead":"Importer une photo à la place","portrait.upload.title":"Importez votre photo d'identité","portrait.upload.hint":"Une photo récente de votre visage, de face, devant un mur clair et uni.","portrait.upload.choose":"Choisir une photo","portrait.upload.unsupported":"Choisissez une photo JPEG, PNG ou HEIC.","portrait.upload.failed":"Nous n'avons pas pu envoyer cette photo. Réessayez.","portrait.review.title":"Vérifiez votre photo ajustée","portrait.review.description":"Nous avons ajusté votre photo pour qu'elle respecte les règles des photos d'identité. Votre visage n'a pas été modifié.","portrait.review.original":"Votre photo","portrait.review.fixed":"Photo ajustée","portrait.review.fixesTitle":"Ce que nous avons modifié","portrait.review.accept":"Utiliser cette photo","portrait.review.retake":"Reprendre","portrait.review.uploadAnother":"Importer une autre","portrait.fixes.crop":"Recadrée","portrait.fixes.scale":"Redimensionnée","portrait.fixes.straighten":"Redressée","portrait.fixes.background":"Fond remplacé","portrait.fixes.exposure":"Luminosité ajustée","portrait.fixes.white_balance":"Couleurs équilibrées","reasons.portrait_morph_suspected":"Cette photo ne peut pas être utilisée. Prenez une nouvelle photo de la personne.","reasons.portrait_reference_mismatch":"La photo ne correspond pas à la référence. Prenez une nouvelle photo de la personne.","reasons.portrait_declined_fix":"Prenez ou importez une autre photo."},H={en:y,fr:G,ar:D,es:y,pt:y,de:y},S="image/jpeg,image/png,image/heic,image/heif";function m(r){let o=r.strings,a=H[r.locale];return t=>o[t]??a[t]??""}s(m,"v");n(m,"portraitCopy");function b({step:r,i18n:o}){if(r.reason===void 0||r.reason==="portrait_fix_review")return null;let a=m(o)(`reasons.${r.reason}`)||o.t("portrait.retryTitle");return(0,e.jsxs)(k,{tone:"warning",children:[(0,e.jsx)("span",{children:a}),(0,e.jsx)("span",{children:I(o,r.attemptsRemaining,r.attemptsExhausted)})]})}s(b,"R");n(b,"ReasonNotice");function z({step:r,i18n:o,onCamera:a,onUpload:t}){let i=m(o),p=r.photo?.cameraOnPhone===!0;return(0,e.jsx)(j,{testId:"sekyro-portrait-source",title:i("portrait.source.title"),lead:i("portrait.source.description"),cameraLabel:p?o.t("capture.source.phone"):i("portrait.source.camera"),onPhone:p,uploadLabel:i("portrait.source.upload"),notice:(0,e.jsx)(b,{step:r,i18n:o}),onCamera:a,onUpload:t})}s(z,"z");n(z,"PortraitSourceView");function R({step:r,i18n:o,onCamera:a}){let t=m(o),i=(0,f.useRef)(null),[p,v]=(0,f.useState)("idle"),u=p==="sending",d=r.photo?.uploadOffered===!0,g=n(async c=>{let x=c.currentTarget.files?.[0];if(c.currentTarget.value="",x!==void 0){v("sending");try{await r.uploadPortrait(x),v("idle")}catch(w){v(w instanceof TypeError&&w.message==="unsupported_file"?"unsupported":"failed")}}},"onFile");return(0,e.jsxs)("section",{className:"sekyro-step","data-testid":"sekyro-portrait-upload-screen",children:[(0,e.jsx)(_,{title:t("portrait.upload.title"),lead:t("portrait.upload.hint")}),p==="idle"||p==="sending"?(0,e.jsx)(b,{step:r,i18n:o}):null,p==="unsupported"||p==="failed"?(0,e.jsx)(k,{tone:"warning",children:(0,e.jsx)("span",{children:t(p==="unsupported"?"portrait.upload.unsupported":"portrait.upload.failed")})}):null,u?(0,e.jsx)("p",{className:"sekyro-text-muted",role:"status","aria-busy":"true",children:o.t("portrait.uploading")}):null,(0,e.jsx)("input",{ref:i,type:"file",accept:S,hidden:!0,"data-testid":"sekyro-portrait-upload","aria-label":t("portrait.upload.title"),onChange:s(c=>{g(c)},"onChange")}),(0,e.jsxs)(C,{children:[(0,e.jsx)(h,{full:!0,onClick:s(()=>i.current?.click(),"onClick"),disabled:u||!d||r.attemptsExhausted,children:t("portrait.upload.choose")}),a!==void 0?(0,e.jsxs)(h,{full:!0,kind:"ghost",onClick:a,disabled:u,children:[(0,e.jsx)(T,{name:"camera"}),t("portrait.source.camera")]}):null]})]})}s(R,"A");n(R,"PortraitUploadView");function E({step:r,i18n:o,onDeclined:a}){let t=m(o),[i,p]=(0,f.useState)(!1),[v,u]=(0,f.useState)(!1),d=r.pendingFix;if(d==null)return null;let g=n(async l=>{p(!0),u(!1);try{await r.confirmFix(l),l||a?.()}catch{u(!0)}finally{p(!1)}},"answer"),c=r.photo?.source==="upload"?t("portrait.review.uploadAnother"):t("portrait.review.retake"),x=n(l=>t(`portrait.fixes.${l}`)||l,"fixName"),w=t("portrait.review.original"),P=t("portrait.review.fixed");return(0,e.jsxs)("section",{className:"sekyro-step","data-testid":"sekyro-portrait-review",children:[(0,e.jsx)(_,{title:t("portrait.review.title"),lead:t("portrait.review.description")}),(0,e.jsxs)("div",{className:"sekyro-portrait-pair",children:[(0,e.jsxs)("figure",{className:"sekyro-portrait-pair__item",children:[(0,e.jsx)("img",{src:d.originalUrl,alt:w}),(0,e.jsx)("figcaption",{className:"sekyro-text-muted",children:w})]}),(0,e.jsxs)("figure",{className:"sekyro-portrait-pair__item",children:[(0,e.jsx)("img",{src:d.fixedUrl,alt:P}),(0,e.jsx)("figcaption",{className:"sekyro-text-muted",children:P})]})]}),d.fixes.length>0?(0,e.jsxs)("div",{className:"sekyro-stack sekyro-stack--1",children:[(0,e.jsx)("p",{className:"sekyro-text-body",children:t("portrait.review.fixesTitle")}),(0,e.jsx)("ul",{className:"sekyro-portrait-fixes","data-testid":"sekyro-portrait-fixes",children:d.fixes.map(l=>(0,e.jsx)("li",{children:x(l)},l))})]}):null,v?(0,e.jsx)(k,{tone:"danger",children:(0,e.jsx)("span",{children:o.t("errors.network_error")})}):null,(0,e.jsxs)(C,{children:[(0,e.jsx)(h,{full:!0,onClick:s(()=>{g(!0)},"onClick"),disabled:i,"data-testid":"sekyro-portrait-accept",children:t("portrait.review.accept")}),(0,e.jsx)(h,{full:!0,kind:"ghost",onClick:s(()=>{g(!1)},"onClick"),disabled:i,"data-testid":"sekyro-portrait-decline",children:c})]})]})}s(E,"j");n(E,"PortraitReviewView");function q({screen:r,step:o,i18n:a,onCamera:t,onUpload:i,onDeclined:p}){return r==="phone"?(0,e.jsx)(U,{i18n:a,lead:a.t("handoff.lead.portrait"),refresh:o.refresh,actions:(0,e.jsx)(h,{kind:"ghost",full:!0,onClick:i,children:m(a)("portrait.source.upload")})}):r==="review"?(0,e.jsx)(E,{step:o,i18n:a,onDeclined:p}):r==="upload"?(0,e.jsx)(R,{step:o,i18n:a,...t!==void 0?{onCamera:t}:{}}):(0,e.jsx)(z,{step:o,i18n:a,onCamera:t??i,onUpload:i})}s(q,"Q");n(q,"PortraitScreens");export{m as a,z as b,R as c,E as d,q as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as Qe,b as Ze,c as Re,d as Ke,f as et,g as tt,h as rt,n as it,s as at,t as ot,v as nt}from"./chunk-F6BL7IXJ.js";import{a as ze,d as st,e as dt}from"./chunk-F4Q2Q4OC.js";import{f as ge}from"./chunk-SX373VNU.js";import{e as $e,k as Je}from"./chunk-6MYG4HWP.js";import{g as Ae}from"./chunk-JS2IXPNL.js";import{a}from"./chunk-4FHWXBOB.js";function lt(e,t){let i=new Set(e.flatMap(n=>n.sides.filter(d=>d[t]!==null).map(d=>d.side)));return i.size===1?[...i][0]:null}a(lt,"ct");function At(e){let t=st.find(n=>n.docType===e),i=t.mrz==="none"?null:t.mrz==="td3"?"single":"verso";return{sides:t.sides,format:dt(e),mrz:t.mrz==="none"?"none":"required",mrzSide:i,barcodeSide:null,portraitSide:t.portraitSide,scripts:null}}a(At,"qt");function Rt(e){let t=[];for(let i of e)for(let n of i.sides){if(!Array.isArray(n.scripts))return null;for(let d of n.scripts)t.includes(d)||t.push(d)}return t}a(Rt,"Xt");function zt(e,t){if(t.length===0)return At(e);let i=t.some(l=>l.sides.length>1),n=new Set(t.map(l=>l.format)),d=n.size===1?[...n][0]:"card",u=t.filter(l=>l.sides.some(f=>f.mrz!==null)).length,c=t.find(l=>l.sides.length>1===i)?.sides.find(l=>l.portrait)?.side;return{sides:i?["recto","verso"]:["single"],format:d,mrz:u===t.length?"required":u===0?"none":"optional",mrzSide:lt(t,"mrz"),barcodeSide:lt(t,"barcode"),portraitSide:c??(i?"recto":"single"),scripts:Rt(t)}}a(zt,"lt");function Ft(e,t){if(e===void 0)return[];let i=e.toUpperCase();return Object.prototype.hasOwnProperty.call(ze,i)?ze[i]?.[t]??[]:[]}a(Ft,"ft");async function Et(e,t,i){return await e(t)?i:i==="recto"?"verso":"recto"}a(Et,"mt");function Wt(e,t,i){return e!==t&&t==="verso"&&i.recto!==void 0&&i.verso===void 0?"verso":e}a(Wt,"pt");var Ot={low:{maxLongEdge:1920,payloadTargetBytes:7e5,qMin:.7,qMax:.92},mid:{maxLongEdge:2240,payloadTargetBytes:12e5,qMin:.7,qMax:.92},good:{maxLongEdge:2560,payloadTargetBytes:16e5,qMin:.7,qMax:.92}};function qt(e){let{deviceMemory:t,effectiveType:i,saveData:n,downlinkMbps:d,sourceLongEdge:u}=e,c=n===!0||i==="slow-2g"||i==="2g"||d!=null&&d>0&&d<1,l=t!=null&&t<=2,f=i==="4g"||d!=null&&d>=5,y=t!=null&&t>=6,T;c||l?T="low":f&&y?T="good":T="mid";let s=Ot[T],z=u&&u>0?Math.min(s.maxLongEdge,u):s.maxLongEdge;return{tier:T,...s,maxLongEdge:z}}a(qt,"jt");function Bt(e){let t={};try{let i=navigator;typeof i.deviceMemory=="number"&&(t.deviceMemory=i.deviceMemory);let n=i.connection;n&&(t.effectiveType=n.effectiveType,t.saveData=n.saveData,t.downlinkMbps=n.downlink)}catch{}return typeof e=="number"&&e>0&&(t.sourceLongEdge=e),qt(t)}a(Bt,"ht");function Nt(e,t,i){let n=Math.min(1,Math.max(0,(e-.28)/.21999999999999997)),d=(t+i)/2;return Math.max(t,i-n*(i-d))}a(Nt,"Qt");function Dt(e,t,i){let n=Math.max(e,t),d=n>0?Math.min(1,i/n):1;return{width:Math.max(1,Math.round(e*d)),height:Math.max(1,Math.round(t*d))}}a(Dt,"Kt");async function It(e,t){let i=t.startQ,n=await e(i);for(let d=0;d<4&&!(n.size<=t.budgetBytes||i<=t.qMin);d++)i=Math.max(t.qMin,i-.08),n=await e(i);return{blob:n,quality:i}}a(It,"$t");async function Ut(e,t,i,n,d){if(t<=0||i<=0)return null;let{width:u,height:c}=Dt(t,i,n.maxLongEdge),l=document.createElement("canvas");l.width=u,l.height=c;let f=l.getContext("2d");if(!f)return null;f.drawImage(e,0,0,u,c);let y=a(v=>new Promise((F,p)=>{l.toBlob(C=>C?F(C):p(new Error("canvas toBlob returned null")),"image/jpeg",v)}),"g"),T=Nt(d,n.qMin,n.qMax),{blob:s,quality:z}=await It(y,{startQ:T,qMin:n.qMin,budgetBytes:n.payloadTargetBytes}).finally(()=>{l.width=0,l.height=0});if(s.size>5242880)throw new Error("encoded document exceeds the 5242880-byte media cap");return{blob:s,quality:z,width:u,height:c}}a(Ut,"St");async function Vt(e){let t=Bt(Math.max(e.width,e.height)),i=await Ut(e,e.width,e.height,t,.5);if(i===null)throw new Error("canvas encode unavailable");return{blob:i.blob,width:i.width,height:i.height}}a(Vt,"Ee");function ft(e,t,i={safetyNetMs:null,sideChangeMs:null}){return{layout:e,phase:"framing",captured:{},pending:[],lastCaptureAt:t,lastReportAt:t,manualShutter:!1,restPhase:"framing",readSides:[],needFlip:!1,flipped:!1,flipTimeoutSpent:!1,timeoutCapture:!1,lastShotByTimeout:!1,tuning:i,safetyNetSpent:!1,sideHits:0,turnSeen:!1}}a(ft,"ve");var Be=a(e=>e==="recto"?"verso":"recto","Oe"),vt=a(e=>e.phase==="framing"||e.phase==="locking"||e.phase==="flipCue"||e.phase==="reaskRecto","bt"),ne=a(e=>(e.captured.recto!==void 0?1:0)+(e.captured.verso!==void 0?1:0)+e.pending.length,"oe");function Fe(e,t){return e.lastCaptureAt>=0&&e.lastReportAt>=0?e:{...e,lastCaptureAt:e.lastCaptureAt<0?t:e.lastCaptureAt,lastReportAt:e.lastReportAt<0?t:e.lastReportAt}}a(Fe,"xe");function _t(e){if(ne(e)===1)return e.captured.recto!==void 0?"recto":e.captured.verso!==void 0?"verso":void 0}a(_t,"Jt");function Ht(e,t,i){if(e.phase==="result")return{...e,lastReportAt:i};let n=!t.present||e.captureArea!==void 0&&t.areaFrac<.6*e.captureArea,{flipped:d,awaySince:u}=e,c=e.sideSince,l=e.sideHits,f=_t(e),y=e.tuning.sideChangeMs!==null&&e.needFlip&&f!==void 0,T=!1;y&&f==="recto"&&t.side==="verso"?(c=c??i,l+=1,T=l>=2&&i-c>=e.tuning.sideChangeMs,T&&(d=!0)):(!y||t.side!==void 0)&&(c=void 0,l=0),n&&(u=u??i),u!==void 0&&i-u>=250&&(d=!0,T=!0),n||(u=void 0);let s=y&&f==="verso"&&t.side==="verso";s&&(d=!1);let z=s?!1:e.turnSeen||T,v=e.flipTimeoutSpent&&!(d&&!e.flipped),F=e.notice==="same_face"&&d&&!e.flipped?void 0:e.notice,p=t.present&&t.steady!==!1&&!s,C=d&&!e.flipped||z&&!e.turnSeen,L=p?C?i:e.presentSince??i:void 0,k={...e,lastReportAt:i,flipped:d,awaySince:u,sideSince:c,sideHits:l,presentSince:L,turnSeen:z,flipTimeoutSpent:v,notice:F,lastArea:t.areaFrac};if(!vt(e))return k;let N=jt(e,k,t,i,d,v),V=e.tuning.safetyNetMs;return V!==null&&e.layout==="twoSided"&&ne(e)===1&&!e.safetyNetSpent&&z&&L!==void 0&&i-L>=V&&N.phase!=="capturing"?{...N,phase:"capturing",safetyNetSpent:!0,shotVia:"safety_net"}:N}a(Ht,"Zt");function jt(e,t,i,n,d,u){if(e.needFlip&&!d){if(!i.ready)return{...t,phase:e.restPhase,goodSince:void 0};let c=e.lastShot!==void 0&&e.pending.includes(e.lastShot);if(u||c)return{...t,goodSince:void 0,phase:e.restPhase};let l=e.goodSince??n;return n-l>=1800?{...t,goodSince:l,phase:"capturing",flipTimeoutSpent:!0,timeoutCapture:!0}:{...t,goodSince:l,phase:e.restPhase}}return i.ready?{...t,phase:"capturing",goodSince:e.goodSince??n}:{...t,goodSince:void 0,phase:i.locking?"locking":e.restPhase}}a(jt,"en");function Gt(e,t){if(!vt(e)||e.manualShutter)return e;let i=t-e.lastReportAt>=2e3,n=t-e.lastCaptureAt>=6e3;return i||n?{...e,manualShutter:!0}:e}a(Gt,"tn");function Yt(e,t,i){let n=e.layout==="singlePage",d=n?{recto:t}:e.captured,u=n?[]:[...e.pending,t],c={...e,captured:d,pending:u,lastShot:t,lastCaptureAt:i,lastReportAt:-1,manualShutter:!1,goodSince:void 0,notice:void 0,awaySince:void 0,flipped:!1,lastShotByTimeout:e.timeoutCapture,timeoutCapture:!1,captureArea:e.lastArea,sideSince:void 0,sideHits:0,presentSince:void 0,turnSeen:!1,shotVia:void 0,lastShotVia:e.phase==="capturing"?e.timeoutCapture?"flip_timeout":e.shotVia??"ready":"manual"};return n||ne({captured:d,pending:u})>=2?{...c,phase:"reading",restPhase:"framing",current:void 0,needFlip:!1}:{...c,phase:"flipCue",restPhase:"flipCue",current:void 0,needFlip:!0}}a(Yt,"nn");function gt(e,t,i){return e.pending.includes(t)?{...e,pending:e.pending.filter(n=>n!==t),lastShot:e.lastShot===t?void 0:e.lastShot,phase:e.phase==="capturing"?e.phase:"flipCue",restPhase:"flipCue",current:Be(i),needFlip:!0,flipTimeoutSpent:!1,goodSince:void 0,manualShutter:!0,notice:"same_face",lastCaptureAt:-1,lastReportAt:-1,turnSeen:!1,presentSince:void 0}:e}a(gt,"yt");function Xt(e,t,i,n=!1){if(!e.pending.includes(t))return e;if(e.captured[i]!==void 0)return gt(e,t,i);let d=e.pending.filter(y=>y!==t),u={...e,pending:d,captured:{...e.captured,[i]:t}};if(ne(u)!==1||e.layout==="singlePage")return u;if(n)return{...u,unsure:t,phase:"reading",restPhase:"flipCue",current:void 0,needFlip:!1};let c=Be(i),l=c==="recto"&&e.restPhase==="reaskRecto"?"reaskRecto":"flipCue",f=e.phase==="flipCue"||e.phase==="reaskRecto"||e.phase==="framing";return{...u,restPhase:l,current:c,phase:f?l:e.phase}}a(Xt,"rn");function $t(e,t,i){let n=e.captured.recto===t?"recto":e.captured.verso===t?"verso":void 0;if(n===void 0||n===i&&e.unsure!==t)return e;let d=Be(i),u={[i]:t};e.captured[d]!==void 0&&e.captured[d]!==t&&(u[d]=e.captured[d]);let c=[u.recto,u.verso,...e.pending],l={...e,captured:u,unsure:void 0,readSides:e.readSides.filter(f=>u[f]!==void 0&&u[f]===e.captured[f]),lastShot:e.lastShot!==void 0&&c.includes(e.lastShot)?e.lastShot:void 0};return e.layout==="singlePage"||ne(l)!==1||e.phase!=="reading"&&e.phase!=="result"?l:{...l,phase:"flipCue",restPhase:"flipCue",current:d,needFlip:!0,flipped:!1,flipTimeoutSpent:!1,goodSince:void 0,awaySince:void 0,turnSeen:!1,safetyNetSpent:!1,presentSince:void 0,sideSince:void 0,sideHits:0,captureArea:e.lastArea,lastCaptureAt:-1,lastReportAt:-1,manualShutter:!1}}a($t,"on");function Jt(e,t){if(t.id!==void 0&&e.captured.recto!==t.id&&e.captured.verso!==t.id&&!e.pending.includes(t.id))return e;let i=t.id??e.captured[t.side],n={...e.captured};(t.id===void 0||n[t.side]===t.id)&&delete n[t.side];let d=e.pending.filter(y=>y!==i),u=e.layout==="twoSided"&&ne({captured:n,pending:d})>0,c=e.lastShotByTimeout||i===e.lastShot!==e.flipped,l=u&&!c,f=l?t.side==="recto"?"reaskRecto":"flipCue":"framing";return{...e,captured:n,pending:d,readSides:e.readSides.filter(y=>y!==t.side),unsure:e.unsure===i?void 0:e.unsure,lastShot:e.lastShot===i?void 0:e.lastShot,notice:t.issue,goodSince:void 0,manualShutter:!1,phase:f,restPhase:f,current:t.side,needFlip:l,flipped:!1,flipTimeoutSpent:!1,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1,safetyNetSpent:!1,sideSince:void 0,sideHits:0,presentSince:void 0,turnSeen:u&&!l&&i===e.lastShot&&!e.flipped&&!e.lastShotByTimeout}}a(Jt,"an");function Qt(e,t){switch(t.type){case"report":return Ht(Fe(e,t.at),t.report,t.at);case"tick":return Gt(Fe(e,t.at),t.at);case"captured":return Yt(Fe(e,t.at),t.id,t.at);case"captureFailed":return{...e,phase:e.restPhase,goodSince:void 0,lastCaptureAt:t.at,manualShutter:!0,timeoutCapture:!1,shotVia:void 0,...e.shotVia==="safety_net"?{safetyNetSpent:!1,presentSince:void 0}:{}};case"classified":return Xt(e,t.id,t.side,t.unsure===!0);case"held":return $t(e,t.id,t.side);case"duplicate":return gt(e,t.id,t.side);case"readOk":{let i=e.readSides.includes(t.side)?e.readSides:[...e.readSides,t.side],n=["recto","verso"].filter(u=>e.captured[u]!==void 0),d=e.phase==="reading"&&e.pending.length===0&&n.every(u=>i.includes(u));return{...e,readSides:i,flipTimeoutSpent:!1,phase:d?"result":e.phase}}case"readFailed":return Jt(e,t);case"clockRestart":return e.lastCaptureAt<0&&e.lastReportAt<0&&e.awaySince===void 0&&e.presentSince===void 0&&e.sideSince===void 0&&e.sideHits===0?e:{...e,awaySince:void 0,presentSince:void 0,sideSince:void 0,sideHits:0,lastCaptureAt:-1,lastReportAt:-1};case"retake":return{...ft(e.layout,-1,e.tuning),lastCaptureAt:-1,lastReportAt:-1};default:return e}}a(Qt,"Mt");var Zt={card:80,probe:40,phase:160,hold:80},Ee=36e5,Kt=0;function G(e){if(e===void 0||!e.startsWith("shot-"))return 0;let t=Number(e.slice(5));return Number.isInteger(t)&&t>0?Math.min(t,999):0}a(G,"H");var ce=a(e=>Math.round(Math.min(1,Math.max(0,e))*1e3)/1e3,"ue"),X=a((e,t)=>Math.max(0,Math.min(t,Math.round(e))),"Q");function er(e){return e.mrzFace!==null?"live_mrz":e.byBarcode!==null?"barcode":e.banded===null?"order":e.verdict==="recto"&&e.confirmed===void 0&&e.seen==="verso"?"turn":e.confirmed!==void 0?"reader":"band"}a(er,"wt");function tr(e){let t=Math.min(Kt+=1,999),i=null,n=0,d=0,u=[],c=new Map,l=new Set,f=null,y=null,T,s=null,z="{}",v=!1,F=a(()=>i===null?0:X(e.now()-i,Ee),"W"),p=!1,C=a(()=>p?F():(p=!0,0),"M"),L=a(()=>{if(u.length===0)return;let w=u;if(u=[],n>=20||e.sink===void 0){d+=w.length;return}let b={kind:"capture_trace",platform:"web",step:"document",run:t,seq:n++,events:w,...d>0?{dropped:Math.min(d,1e5)}:{}};d=0;try{e.sink([b])}catch{}},"w"),k=a((w,b=F())=>{if(v)return;let h=Zt[w.e];if(h!==void 0){let P=(c.get(w.e)??0)+1;if(c.set(w.e,P),P>h){d+=1;return}}if(n>=20){d+=1;return}u.push({t:b,...w}),u.length>=40&&L()},"b"),N=a(w=>{if(w.layout==="singlePage")return w.captured.recto!==void 0?{single:G(w.captured.recto)}:{};let b={};for(let h of["recto","verso"]){let P=w.captured[h];P!==void 0&&P!==w.unsure&&(b[h]=G(P))}return b},"L"),V={start(w,b){i===null&&(i=e.now()),k({e:"start",layout:w,...b==="recto"||b==="verso"?{expect:b}:{}},C())},observe(w,b,h){if(h.type==="report"){let{present:A,steady:D,side:q}=h.report;A!==y&&(k({e:"card",present:A,...D!==void 0?{steady:D}:{}}),y=A),T=D,(q==="recto"||q==="verso")&&q!==s&&(s=q,k({e:"probe",side:q}))}if(b===w)return;if(!w.flipped&&b.flipped&&k({e:"turn",by:b.awaySince!==void 0?"away":"probe"}),!w.manualShutter&&b.manualShutter){let A=h.type==="tick"?"timer":h.type==="duplicate"?"same_side":h.type==="captureFailed"?"no_photo":"other";k({e:"shutter",why:A})}if(h.type==="classified")k({e:"filed",photo:G(h.id),side:b.layout==="singlePage"?"single":h.side,...h.unsure===!0?{unsure:!0}:{}});else if(h.type==="duplicate"){let A=G(h.id);k({e:"same_side",photo:A,side:h.side,why:l.has(A)?"classifier":"mrz_twin"})}else h.type==="held"?k({e:"held",photo:G(h.id),side:h.side}):h.type==="readFailed"&&k({e:"refused",...h.id!==void 0?{photo:G(h.id)}:{},side:h.side,issue:h.issue});if(w.phase!==b.phase){let A=F();w.phase==="locking"&&f!==null&&(k({e:"hold",ms:X(A-f,Ee),end:b.phase==="capturing"?"shot":"lost"}),f=null),b.phase==="locking"&&(f=A),k({e:"phase",phase:b.phase,...b.current!==void 0?{expect:b.current}:{}})}let P=N(b),g=JSON.stringify(P);g!==z&&(z=g,k({e:"tray",...P})),b.phase==="result"&&w.phase!=="result"&&Promise.resolve().then(L)},shot(w,b,h,P){let g=b,A={};for(let[D,q]of Object.entries(g?.guideBlockers??{}))rr.has(D)&&typeof q=="number"&&q>0&&(A[D]=X(q,1e5));k({e:"shot",photo:w,...h!==void 0?{via:h}:{},...g?.via!==void 0?{engineVia:g.via}:{},...g?.stillSource==="photo"||g?.stillSource==="video"?{still:g.stillSource}:{},...P!==void 0?{expect:P}:{},...T!==void 0?{steady:T}:{},...g?.msToCapture!==void 0?{ms:X(g.msToCapture,Ee)}:{},...typeof g?.ticks=="number"?{ticks:X(g.ticks,1e5)}:{},...g?.shotGlare!==void 0?{glare:ce(g.shotGlare)}:{},...g?.shotSharpness!==void 0?{sharpness:X(g.shotSharpness,1e6)}:{},...g?.deviceClass!==void 0?{deviceClass:g.deviceClass}:{},...g?.demotedFrom!==void 0?{demotedFrom:g.demotedFrom}:{},...g?.demotedBy!==void 0?{demotedBy:g.demotedBy}:{},...g?.tickMedianMs!==void 0?{tickMedianMs:X(g.tickMedianMs,6e4)}:{},...g?.video!==void 0?{videoWidth:X(g.video.width,16384),videoHeight:X(g.video.height,16384)}:{},...typeof g?.zoom=="number"?{zoom:Math.round(Math.min(Math.max(g.zoom,0),20)*100)/100}:{},...Object.keys(A).length>0?{blockers:A}:{}})},band(w){return b=>(h,P={})=>{let g=b(h,P),A=P.EDGE_LUMA_DELTA!==void 0?"soft":P.MAX_HEIGHT_FRAC!==void 0?"td1":P.LONE_EDGE_PX!==void 0?"default":"plain",D=h.width||1,q=h.height||1;return k({e:"band",photo:w,pass:A,px:X(h.width,16384),found:g!==null,...g!==null?{x:ce(g.x/D),y:ce(g.y/q),w:ce(g.width/D),h:ce(g.height/q)}:{}}),g}},reader(w,b){k({e:"reader",photo:w,lines:X(b.lineCount,9),valid:b.valid===!0,...b.format!==void 0?{format:b.format}:{}})},side(w,b,h,P){l.add(w),k({e:"side",photo:w,side:b,path:h,...P!==void 0?{format:P}:{}})},answer(w,b,h,P){let g=typeof P=="string"?P.split("/")[2]?.split(".")[0]:void 0;k({e:"answer",photo:w,accepted:(b??[]).filter(A=>A==="recto"||A==="verso"),...b===null?{done:!0}:{},...g!==void 0&&/^[0-9a-f-]{8,64}$/i.test(g)?{media:g.toLowerCase()}:{},...h!==void 0&&/^[a-z][a-z0-9_]{0,63}$/.test(h)?{reason:h}:{}})},settle(w,b,h){k({e:"settle",...w!==void 0?{photo:w}:{},sent:b,ok:h.ok,...h.ok&&h.heldAs!==void 0?{keptAs:h.heldAs}:{},...h.ok?{}:{issue:h.issue}}),Promise.resolve().then(L)},end(w){k({e:"end",outcome:w}),v=!0,L()},flush:L},Z={};for(let[w,b]of Object.entries(V))Z[w]=w==="band"?h=>P=>{let g;try{g=V.band(h)(P)}catch{return P}return(A,D)=>{try{return g(A,D)}catch{return P(A,D)}}}:(...h)=>{try{return b(...h)}catch{return}};return Z}a(tr,"Ct");var rr=new Set(["no_card","too_small","too_big","off_center","glare","blurry","steadying","locking"]),We=a((e,t,i)=>Math.min(i,Math.max(t,Math.round(e))),"Ae"),ye=a(e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4,"ge");async function ir(e,t,i,n){let d=n.decode??(f=>createImageBitmap(f)),u=a(async()=>e.stillRead(await d(t),n.region??[0,0,1,1],n.detectorLimit),"u"),c;try{c=await u()}catch{try{await new Promise(f=>setTimeout(f,n.retryMs??300)),c=await u()}catch{return null}}let l=c.mrzBox;return l===void 0?null:{engine:n.engine,source:"live_mrz",format:i.format,lineCount:We(i.lineCount,2,3),checkDigitsValid:!0,stillConfirmed:c.valid&&c.digest===i.digest,band:[ye(l[0]),ye(l[1]),ye(Math.min(l[2],1-l[0])),ye(Math.min(l[3],1-l[1]))],digest:i.digest,framesToValid:We(i.framesToValid,1,1e3),msToValid:We(i.msToValid,0,12e4)}}a(ir,"kt");var ar=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]),or=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,7,1,5,0,6,64,11,11]);function nr(e=globalThis){let t=e.WebAssembly?.validate;if(typeof t!="function")return{ok:!1,reason:"simd"};try{if(!t.call(e.WebAssembly,ar)||!t.call(e.WebAssembly,or))return{ok:!1,reason:"simd"}}catch{return{ok:!1,reason:"simd"}}return typeof e.Worker!="function"?{ok:!1,reason:"worker"}:typeof e.createImageBitmap!="function"?{ok:!1,reason:"bitmap"}:{ok:!0}}a(nr,"Dt");function sr(e=globalThis){let t=e.navigator?.connection;return t?.saveData===!0||["slow-2g","2g","3g"].includes(t?.effectiveType??"")}a(sr,"Tt");var oe,$=(oe=class extends Error{constructor(t){super(t),this.name="OcrEngineError",this.code=t}},a(oe,"j"),oe);function ut(){let e=a(t=>(t.close(),Promise.reject(new $("unsupported"))),"e");return{ready:Promise.resolve("unsupported"),busy:!1,bandRead:e,stillRead:e,layoutRead:e,dispose:a(()=>{},"dispose")}}a(ut,"_t");function dr(e){let t;try{if(e.createWorker)t=e.createWorker();else if(e.workerUrl!==void 0)t=new Worker(e.workerUrl,{type:"module",name:"sekyro-ocr"});else return ut()}catch{return ut()}let i=new Map,n=0,d=!1,u=!1,c=!1;t.addEventListener("message",p=>{let C=p.data,L=i.get(C.id);L&&(i.delete(C.id),L.resolve(C))});let l=a(()=>{for(let p of i.values())p.reject(new $("error"));i.clear(),y()},"d");t.addEventListener("error",l),t.addEventListener("messageerror",l);function f(p,C=[]){if(d)return Promise.reject(new $("disposed"));let L=++n;return new Promise((k,N)=>{i.set(L,{resolve:k,reject:N});try{t.postMessage({...p,id:L},C)}catch{i.delete(L),N(new $("error"))}})}a(f,"m");function y(){if(!d){d=!0;try{t.postMessage({id:++n,kind:"dispose"})}catch{}t.terminate();for(let p of i.values())p.reject(new $("disposed"));i.clear()}}a(y,"g");let T=(async()=>{let p=await f({kind:"init",baseUrl:e.baseUrl,salt:e.salt,detectorLimit:e.tuning.detectorLimit,maxDownloadMs:e.tuning.maxDownloadMs});if(p.kind==="failed")return p.reason;if(p.kind!=="ready")return"error";let C=await f({kind:"warmup"});if(C.kind!=="ready")return"error";let L=C.benchMs??C.warmupMs,k=e.deviceMemoryGb===void 0?Ze():e.deviceMemoryGb;return{warmupMs:C.warmupMs,downloadMs:p.downloadMs,cached:p.cached,benchMs:L,tier:Qe(L,k)}})().catch(()=>"error"),s,z=new Promise(p=>{s=setTimeout(()=>p("timeout"),e.tuning.loadTimeoutMs)}),v=Promise.race([T,z]).then(p=>(clearTimeout(s),typeof p=="string"?y():c=!0,d&&typeof p!="string"?"error":p));(e.page===void 0?globalThis.addEventListener?globalThis:null:e.page)?.addEventListener("pagehide",y,{once:!0});async function F(p,C,L){if(d)throw C.close(),new $("disposed");if(!c)throw C.close(),new $("not_ready");if(u)throw C.close(),new $("busy");u=!0;let k;try{let N=new Promise((Z,w)=>{k=setTimeout(()=>{w(new $("timeout")),y()},e.tuning.readTimeoutMs??1e4)}),V=await Promise.race([f(p,[C]),N]);if(V.kind===L){let{id:Z,...w}=V;return w}throw new $(V.kind==="error"?V.code:V.kind==="failed"?V.reason:"error")}finally{clearTimeout(k),u=!1}}return a(F,"R"),{ready:v,get busy(){return u},bandRead:a((p,C=e.tuning.detectorLimit,L)=>F({kind:"band",bitmap:p,detectorLimit:C,...L!==void 0?{expiredBefore:L}:{}},p,"band"),"bandRead"),stillRead:a((p,C,L=e.tuning.detectorLimit)=>F({kind:"still",bitmap:p,region:C,detectorLimit:L},p,"band"),"stillRead"),layoutRead:a((p,C)=>F({kind:"layout",bitmap:p,detectorLimit:C},p,"layout"),"layoutRead"),dispose:y}}a(dr,"Rt");var we="sekyro-ocr-1",Oe=a(e=>e!==null&&typeof e=="object"?e:{},"Be"),j=a((e,t,i,n)=>typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=i?e:n,"X"),ct=a((e,t)=>typeof e=="boolean"?e:t,"Pt"),pt=a(e=>{let t=typeof e=="string"?/^sekyro-ocr-(\d{1,4})$/.exec(e):null;return t?Number(t[1]):Number.POSITIVE_INFINITY},"Et");function lr(e,t={}){let i=Oe(e),n=Oe(i.liveMrz),d=Oe(i.frontLock),u=pt(t.engine??we),c=t.mode==="off",l=n.enabled===!0,f=d.enabled===!0,y=a((p,C)=>!c&&C&&pt(p.minEngine??we)<=u,"g"),T=ot,s=y(n,l)?{detectorLimit:j(n.detectorLimit,320,1600,T.detectorLimit),bandMaxWidthPx:j(n.bandMaxWidthPx,320,4096,T.bandMaxWidthPx),minBandWidthPx:j(n.minBandWidthPx,0,4096,T.minBandWidthPx),bandTop:j(n.bandTop,0,.95,T.bandTop),minIntervalMs:j(n.minIntervalMs,0,5e3,T.minIntervalMs),stableReads:Math.round(j(n.stableReads,1,10,T.stableReads)),profileReads:Math.round(j(n.profileReads,1,100,T.profileReads)),maxReadMs:j(n.maxReadMs,50,6e4,T.maxReadMs),searchTimeoutMs:j(n.searchTimeoutMs,1e3,12e4,T.searchTimeoutMs),hint:ct(n.hint,!0),stillConfirm:ct(n.stillConfirm,!0)}:null,z=at,v=a((p,C,L)=>j(d[p],C,L,z[p]),"h"),F=y(d,f)?{minLines:Math.round(v("minLines",1,50)),fillMin:v("fillMin",0,1),fillMax:v("fillMax",0,2),offsetMax:v("offsetMax",0,1),steadyFillDelta:v("steadyFillDelta",0,1),steadyOffsetDelta:v("steadyOffsetDelta",0,1),layoutShiftMax:v("layoutShiftMax",0,1),lineCountDelta:Math.round(v("lineCountDelta",0,50)),lockMs:v("lockMs",0,3e4),steadyMs:v("steadyMs",0,3e4),minFrames:Math.round(v("minFrames",1,100)),minIntervalMs:v("minIntervalMs",0,5e3),maxWidthPx:v("maxWidthPx",160,2048),detectorLimit:v("detectorLimit",320,1600),searchTimeoutMs:v("searchTimeoutMs",1e3,12e4)}:null;return{enabled:s!==null||F!==null,liveMrz:s,textLock:F,liveMrzOn:l,frontLockOn:f,load:{detectorLimit:s?.detectorLimit??F?.detectorLimit??T.detectorLimit,loadTimeoutMs:j(n.loadTimeoutMs,1e3,12e4,2e4),maxDownloadMs:j(n.maxDownloadMs,1e3,12e4,2e4)},reportSampleRate:j(n.reportSampleRate,0,1,1)}}a(lr,"xt");function ur(e,t){return e.enabled?!(t.probe??nr)().ok||(t.slow??sr)()?{ok:!1,reason:"unsupported"}:{ok:!0,engine:dr({baseUrl:t.baseUrl,salt:t.salt,tuning:{detectorLimit:e.load.detectorLimit,maxDownloadMs:e.load.maxDownloadMs,loadTimeoutMs:e.load.loadTimeoutMs},...t.workerUrl!==void 0?{workerUrl:t.workerUrl}:{},...t.createWorker!==void 0?{createWorker:t.createWorker}:{},...t.page!==void 0?{page:t.page}:{},...t.deviceMemoryGb!==void 0?{deviceMemoryGb:t.deviceMemoryGb}:{}})}:{ok:!1,reason:"off"}}a(ur,"vt");function cr(e=typeof navigator<"u"?navigator.userAgent:""){return/SamsungBrowser\//.test(e)?"samsung":/Firefox\/|FxiOS\//.test(e)?"firefox":/Chrome\/|CriOS\/|Chromium\//.test(e)&&!/Edg\/|OPR\//.test(e)?"chrome":/Safari\//.test(e)&&/Version\/|Mobile\//.test(e)&&!/Chrome\/|CriOS\//.test(e)?"safari":"other"}a(cr,"fn");var Q=a(e=>e===void 0||!Number.isFinite(e)?void 0:Math.min(6e5,Math.max(0,Math.round(e))),"$"),qe=a((e,t,i)=>e===void 0||!Number.isFinite(e)?void 0:Math.min(i,Math.max(t,Math.round(e))),"Fe");function pr(e){let t=e.assist??null,i=e.load!==null&&e.load!==void 0&&typeof e.load=="object"?e.load:null,n=typeof e.load=="string"?e.load:null,d=t!==null?t.outcome:n==="unsupported"||n==="download"||n==="integrity"?n:n==="error"||n==="timeout"?"error":"off",u={kind:"live_mrz",platform:"web",engine:e.engine??we,capture:e.capture,outcome:d,reads:qe(t?.reads??0,0,1e4)??0,browser:e.browser??cr()},c=a((l,f)=>{f!==void 0&&(u[l]=f)},"c");return c("format",t?.format),c("framesToValid",qe(t?.framesToValid,1,1e4)),c("msToValid",Q(t?.msToValid)),c("framesToLock",qe(t?.framesToLock,1,1e4)),c("msToLock",Q(t?.msToLock)),c("msToCapture",Q(e.msToCapture)),c("readP50Ms",Q(t?.readP50Ms)),c("readP90Ms",Q(t?.readP90Ms)),c("deviceClass",t?.deviceClass),i!==null&&(c("warmupMs",Q(i.warmupMs)),c("downloadMs",Q(i.downloadMs)),c("cached",i.cached),c("tier",i.tier),c("benchMs",Q(i.benchMs))),c("stillConfirmed",e.stillConfirmed),c("typeMismatch",e.typeMismatch),u}a(pr,"Ot");function ht(e,t){return e===void 0?!1:t==="passport"?e!=="TD3":e==="TD3"}a(ht,"Ie");var hr=2,mr=1500,fr=2500;async function vr(e){let t=await import("./capture-session-doc-BGLEMR2J-LN5RQDCK.js");return new t.CaptureSessionDoc(e)}a(vr,"Sn");function gr(e){return{topLeft:{x:e.x,y:e.y},topRight:{x:e.x+e.width,y:e.y},bottomRight:{x:e.x+e.width,y:e.y+e.height},bottomLeft:{x:e.x,y:e.y+e.height}}}a(gr,"gn");function mt(e){let t=[e.topLeft.x,e.topRight.x,e.bottomRight.x,e.bottomLeft.x],i=[e.topLeft.y,e.topRight.y,e.bottomRight.y,e.bottomLeft.y],n=Math.min(...t),d=Math.min(...i);return{x:n,y:d,width:Math.max(...t)-n,height:Math.max(...i)-d}}a(mt,"Lt");function yr(e,t,i){let n=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft],d=0;for(let u=0;u<n.length;u+=1){let c=n[u],l=n[(u+1)%n.length];d+=c.x*l.y-l.x*c.y}return t>0&&i>0?Math.abs(d)/2/(t*i):0}a(yr,"bn");function wr(e,t){return t==="verso"?"verso":t==="recto"?e==="recto"||e===null?"recto":"unsure":t===null?"unsure":e??"unsure"}a(wr,"yn");function pe(e){return e.startsWith("shot-")?Number(e.slice(5)):0}a(pe,"le");function Lr(){import("./capture-session-doc-BGLEMR2J-LN5RQDCK.js").then(e=>e.warmDocDetector()).catch(()=>{})}a(Lr,"fr");function Pr(e){return br(e,{}).handle}a(Pr,"mr");function br(e,t){let i=$e(),n=Je({enabled:e.keepScreenAwake!==!1}),d=t.decode??(r=>createImageBitmap(r)),u=t.blurRefuseSharpnessMax??.16,c=t.now??(()=>performance.now()),l=tr({now:c,sink:t.traceSink});i.on("captured",()=>l.flush());let f=zt(e.documentType,t.catalogCapture===!0?t.captureSeries??Ft(e.issuer,e.documentType):[]),y=f.sides.length===1||e.side==="single",T=t.secondSide,s=ft(y?"singlePage":"twoSided",c(),T!==void 0?{safetyNetMs:T.safetyNetMs,sideChangeMs:T.sideChangeMs}:void 0);if(!y&&(e.side==="recto"||e.side==="verso")){let r=e.side==="recto"?"verso":"recto";s={...s,captured:{[r]:"server"},readSides:[r],current:e.side,phase:"flipCue",restPhase:"flipCue"}}let z="idle",v=null,F=null,p=!0,C=0,L=0,k=null,N=!1,V=!1,Z="",w=null,b,h=null,P=[],g="base",A=a(r=>{T===void 0||v===null||r===g||(g=r,v.setLockTuning?.(r==="second"?T.guide:t.engineOptions?.guideLock??it))},"P"),D=a(()=>!y&&(s.captured.recto!==void 0?1:0)+(s.captured.verso!==void 0?1:0)==1,"N"),q=a(()=>A(D()?"second":"base"),"F"),Ne=f.mrz==="none",yt=f.barcodeSide==="recto"||f.barcodeSide==="verso"?f.barcodeSide:null,ie=Ne&&!y?t.barcode?.side??yt:null,De=e.barcodeAssetBaseUrl??t.barcode?.assetBaseUrl,be=null,Ie=a(()=>ie===null||De===void 0||t.barcode?.seen!==void 0?Promise.resolve(null):(be??(be=import("./barcode-detect-C5IOXMKI-ZOZ2WOWU.js").then(r=>r.loadBarcodeDetect(De)).catch(()=>null)),be),"Ge"),wt=a((r,o)=>{if(ie===null)return Promise.resolve(null);let m,x=new Promise(M=>{m=setTimeout(()=>M(null),t.barcode?.budgetMs??mr)});return Promise.race([bt(r,o,ie),x]).finally(()=>clearTimeout(m))},"Bt"),bt=a(async(r,o,m)=>{let x=m==="recto"?"verso":"recto";try{let M=t.barcode?.seen;if(M!==void 0)return await M(r)?m:x;let[E,R]=await Promise.all([Ie(),o()]);if(E===null||R===null)return null;let H=Math.min(1600,R.width),S=document.createElement("canvas");S.width=H,S.height=Math.max(1,Math.round(R.height/R.width*H));try{let U=S.getContext("2d");return U===null?null:(U.drawImage(R,0,0,S.width,S.height),await Et(E,U.getImageData(0,0,S.width,S.height),m))}finally{S.width=0,S.height=0}}catch{return null}},"Ft"),I=t.webOcr!==void 0&&!Ne?lr(t.webOcr.captureDocument,{mode:e.liveMrz?.mode??"auto"}):null,K=null,_=I===null||!I.enabled?"off":null,he=null,me=null,Ue=new WeakMap,fe=new WeakMap,Ve=new Map,Mt=a(async(r,o,m=0)=>{let x=K;if(x===null||_===null||typeof _!="object"||!("tier"in _))return null;let M=a(async()=>{let S=await d(r),U=o?.inStill===!0?tt(mt(o.quad),S)[0]:{x:0,y:0,width:S.width,height:S.height},Y=[U.x/S.width,U.y/S.height,U.width/S.width,U.height/S.height];return x.stillRead(S,Y,I?.liveMrz?.detectorLimit)},"D"),E,R=new Promise(S=>{E=setTimeout(()=>S(null),fr)}),H=M().catch(()=>new Promise(S=>setTimeout(S,300)).then(M)).then(S=>(l.reader(m,S),S)).then(S=>S.valid&&S.digest!==void 0?{side:"verso",digest:S.digest}:S.lineCount===0?{side:"recto"}:null).catch(()=>null);return Promise.race([H,R]).finally(()=>clearTimeout(E))},"It"),Me="";if(I!==null&&I.enabled&&t.webOcr!==void 0){let r=t.webOcr,o=ur(I,{baseUrl:e.liveMrz?.assetBaseUrl??r.baseUrl,salt:r.salt,...e.liveMrz?.workerUrl!==void 0?{workerUrl:e.liveMrz.workerUrl}:{},...r.createWorker!==void 0?{createWorker:r.createWorker}:{}});if(o.ok){K=o.engine;let m=new nt({textLock:I.textLock,liveMrz:I.liveMrz,...t.expiredBefore!==void 0?{expiredBefore:t.expiredBefore}:{}});he=m;let x=o.engine;x.ready.then(M=>{_=M,typeof M!="string"&&p&&m.setEngine(x,M.tier)})}else _=o.reason}let ee=a(r=>{let o=JSON.stringify(r);o!==Me&&(Me=o,i.emit("mrz",r))},"Z"),_e=a((r,o)=>{let m=t.webOcr?.reports;if(m===void 0||I===null||r===void 0)return;let x=r.format==="ID-3"||r.side==="single"?"single":r.side==="verso"?"verso":"recto";if(!(x!=="recto"&&I.liveMrzOn||I.frontLockOn)||Math.random()>=I.reportSampleRate)return;let M=r.via==="live_mrz"?me:null,E=a(()=>{let R=M?.value??null;m([pr({capture:x,assist:r.ocr??null,load:_,...r.msToCapture!==void 0?{msToCapture:r.msToCapture}:{},...R!==null&&R.stillConfirmed!==void 0?{stillConfirmed:R.stillConfirmed}:{},...o!==void 0?{typeMismatch:ht(o.format,f.format==="ID-3"?"passport":"card")}:{}})])},"O");M!==null&&M.value===null?Promise.race([M.promise,new Promise(R=>setTimeout(R,3e3))]).then(E):E()},"Ve"),te=a(r=>{!p||r===z||(z=r,n.setActive(r==="starting"||r==="scanning"),i.emit("state",r))},"ee"),St=a((r,o)=>o===void 0?null:y?"single":r.captured.recto===o?"recto":r.captured.verso===o?"verso":null,"zt"),kt=a(r=>({phase:r.phase,captured:y?r.captured.recto!==void 0?["single"]:[]:["recto","verso"].filter(o=>r.captured[o]!==void 0&&r.captured[o]!==r.unsure),photos:y?r.captured.recto!==void 0&&pe(r.captured.recto)>0?{single:pe(r.captured.recto)}:{}:Object.fromEntries(["recto","verso"].filter(o=>r.captured[o]!==void 0&&r.captured[o]!==r.unsure&&pe(r.captured[o])>0).map(o=>[o,pe(r.captured[o])])),expected:y?null:r.current??null,notice:r.notice??null,lastShot:St(r,r.lastShot),manualShutter:r.manualShutter,torchAvailable:v?.torchAvailable()??!1,torch:V}),"Wt"),He=a(()=>{let r=v;if(r===null)return;let o=C,m=a(()=>{p&&v===r&&C===o&&s.phase==="capturing"&&W({type:"captureFailed",at:c()})},"f");r.captureNow().then(m,m)},"qe");function W(r){if(!p)return;let o=s;s=Qt(s,r),l.observe(o,s,r),s.phase==="capturing"&&o.phase!=="capturing"&&Promise.resolve().then(He),s.phase==="result"&&o.phase!=="result"&&(te("done"),je());let m=kt(s),x=JSON.stringify(m);x!==Z&&(Z=x,i.emit("scan",m))}a(W,"A");function je(){h!==null&&clearInterval(h),h=null;for(let r of P.splice(0))r();v?.destroy(),v=null,n.setActive(!1)}a(je,"Xe");let Ge=a(()=>v?.captureReport?.(),"Ye"),Se=!1,Ye=a((r,o)=>{if(!(r===void 0||t.onFaceReport===void 0))try{t.onFaceReport(r,o)}catch{}},"je"),ae=a(r=>{Me="",!(v===null||s.phase==="reading"||s.phase==="result")&&(Se=!1,k=y?"single":s.current??r,v.rearm(k))},"re"),xt=a(async(r,o,m,x)=>{me=null;let M=_!==null&&typeof _=="object"&&_.tier==="low";if(x!==void 0&&K!==null&&I?.liveMrz?.hint===!0&&!M){let O={promise:ir(K,r,x,{engine:we,detectorLimit:I.liveMrz.detectorLimit}).catch(()=>null),value:null};O.promise.then(se=>{O.value=se}),me=O}x!==void 0&&ht(x.format,f.format==="ID-3"?"passport":"card")&&ee({state:"mismatch",format:x.format});let E=`shot-${C+=1}`,R=s.current;W({type:"captured",id:E,at:c()});let H=s.lastShotVia,S=Ge();l.shot(G(E),S,H,R),Ye(S===void 0||s.lastShotVia===void 0?S:{...S,shotVia:s.lastShotVia},"captured"),Se=!0,_e(S,x);let U=m===void 0?w:m===null?null:{quad:gr(m),frameWidth:0,frameHeight:0,inStill:!0},Y={decoded:null},B=a(()=>(Y.decoded??(Y.decoded=Promise.resolve().then(()=>d(r)).catch(()=>null)),Y.decoded),"z");try{await Tt(E,R,r,o,U,B,me,x,H)}finally{Y.decoded!==null&&(await Y.decoded)?.close()}},"Nt"),Tt=a(async(r,o,m,x,M,E,R,H,S)=>{if(e.haptics!==!1)try{globalThis.navigator?.vibrate?.(30)}catch{}if(!N&&u>0){let B=await(t.measureSharpness!==void 0?t.measureSharpness(m,M):E().then(O=>O===null?-1:Ke(O,Re(M?.quad??null,M?.inStill===!0?O:{width:M?.frameWidth??0,height:M?.frameHeight??0},O)))).catch(()=>-1);if(!p)return;if(Number.isFinite(B)&&B>=0&&B<u){N=!0;let O=y?"recto":s.current??(s.captured.recto===void 0?"recto":"verso");W({type:"readFailed",side:O,id:r,issue:"blurry"}),q(),ae(O);return}}N=!1;let U;if(y)U="single";else{let B=H!==void 0&&H.format!=="TD3"&&(f.mrzSide==="recto"||f.mrzSide==="verso")?f.mrzSide:null,O=B===null&&t.classify===void 0?await wt(m,E):null,se=O===null||ie===null?O:Wt(O,ie,s.captured),xe=B??se??(se===null&&ie!==null&&o!==void 0?o:null),de=xe!==null?null:await(t.classify!==void 0?t.classify(m):E().then(J=>J===null?"unsure":M?.inStill===!0?et(J,mt(M.quad),480,l.band(G(r))):rt(J,480,Re(M?.quad??null,{width:M?.frameWidth??0,height:M?.frameHeight??0},J),void 0,void 0,l.band(G(r))))).catch(()=>"unsure"),Te=s.captured.recto===void 0&&s.captured.verso===void 0,Lt=K!==null&&(_===null||typeof _=="object"&&"tier"in _),le,Xe;if(de!==null&&Lt&&f.mrzSide==="verso"&&(Te||de!=="recto"&&s.captured.verso!==void 0)){let J=await Mt(m,M,G(r));if(!p)return;le=J?.side??null,Xe=J?.digest}let ue=wr(de,le),ve=H?.digest??Xe;ve!==void 0&&Ve.set(r,ve);let Ce=ve===void 0?void 0:["recto","verso"].find(J=>{let Pe=s.captured[J];return Pe!==void 0&&Pe!==r&&Ve.get(Pe)===ve});if(Ce!==void 0){W({type:"duplicate",id:r,side:Ce}),ae(Ce==="recto"?"verso":"recto");return}let Le=s.captured.recto===void 0?"recto":s.captured.verso===void 0?"verso":void 0,Pt=Te&&xe===null&&ue==="unsure"&&t.deferRead===!0,re=xe??(ue==="unsure"?Te?de==="verso"&&le!=="recto"?"verso":"recto":Le??"recto":ue==="recto"&&le===void 0&&S!=="flip_timeout"&&s.captured.recto!==void 0&&s.captured.verso===void 0?"verso":ue);if(l.side(G(r),re,er({mrzFace:B,byBarcode:se,banded:de,confirmed:le,verdict:ue,seen:re}),H?.format),!p)return;if(s.captured[re]!==void 0&&L<hr){L+=1,W({type:"duplicate",id:r,side:re}),ae(re==="recto"?"verso":"recto");return}U=s.captured[re]!==void 0&&Le!==void 0?Le:re,L=0,W({type:"classified",id:r,side:U,...Pt?{unsure:!0}:{}}),D()&&A("second")}let Y=U==="verso"?"verso":"recto";try{let B=t.encode!==void 0?await t.encode(m):await E().then(O=>{if(O===null)throw new Error("the still could not be decoded");return Vt(O)});if(!p)return;R!==null&&Ue.set(B.blob,R),fe.set(B.blob,r),i.emit("captured",{image:B.blob,side:U,photo:pe(r),documentType:e.documentType,...e.issuer!==void 0?{issuer:e.issuer}:{},width:B.width,height:B.height,previewDataUrl:x}),t.deferRead!==!0&&W({type:"readOk",side:Y})}catch(B){W({type:"readFailed",side:Y,id:r,issue:"technical"}),q(),i.emit("error",ge("generic",!0,{phase:"keyframes",name:Ae(B)}))}ae(Y==="recto"?"verso":"recto")},"Gt"),Ct=a(r=>{P.push(r.on("statechange",({state:o})=>{o==="preflight"||o==="acquiring"?te("starting"):o==="positioning"?te("scanning"):o==="captured"?te("captured"):o==="error"&&te("error")}),r.on("feedback",({key:o,reticle:m})=>i.emit("feedback",{key:o,reticle:m})),r.on("checks",o=>{i.emit("gate",{progress:o.p,quad:o.quad,frameWidth:o.frameWidth,frameHeight:o.frameHeight,...o.guide!==void 0?{guide:{detected:o.guide.detected,fill:o.guide.fill,offsetX:o.guide.offsetX??0,offsetY:o.guide.offsetY??0}}:{}});let m=o.ocr?.mrz;m!==void 0&&(m.state==="fallback"?ee({state:"fallback",reason:m.reason}):m.state==="valid"?ee({state:"valid",format:m.format}):m.state==="expired"?ee({state:"expired",format:m.format}):m.state==="reading"?ee({state:"reading",...m.format?{format:m.format}:{},...m.coach?{coach:m.coach}:{}}):ee({state:"searching"}));let x=o.quad===null?0:yr(o.quad,o.frameWidth,o.frameHeight);w=o.quad===null?null:{quad:o.quad,frameWidth:o.frameWidth,frameHeight:o.frameHeight},W({type:"report",report:{present:o.quad!==null&&o.plausible||o.guide?.detected===!0,ready:o.ready===!0,locking:o.ready===!0||o.locking===!0,areaFrac:x,...o.side!==void 0?{side:o.side}:{},...o.guide?.still!==void 0?{steady:o.guide.detected&&o.guide.still}:{}},at:c()})}),r.on("error",({kind:o,retryable:m,detail:x})=>i.emit("error",ge(o,m,x))),r.on("artifacts",o=>{xt(o.keyframe,o.previewDataUrl,o.docRegion,o.liveMrz)}))},"Ut"),ke=a(()=>(F??(F=(async()=>{if(p){if(Ie(),v===null){let r;try{r=await(t.createEngine??vr)({...t.engineOptions??{},...b!==void 0?{guide:b}:{},video:e.video,format:f.format,side:y?"single":e.side??"recto",autoCapture:!1,...he!==null?{ocr:he}:{},...T!==void 0&&!y&&f.mrzSide==="verso"?{sideProbe:!0}:{}})}catch(m){te("error"),i.emit("error",ge("models",!0,{phase:"models",name:Ae(m)}));return}if(!p){r.destroy();return}v=r,l.start(y?"singlePage":"twoSided",e.side),g="base",k=y?"single":e.side??"recto",Ct(r),D()&&A("second");let o=t.tickMs??500;o>0&&(h=setInterval(()=>W({type:"tick",at:c()}),o))}W({type:"clockRestart"}),I!==null&&I.liveMrzOn&&(_==="unsupported"||_==="off")&&ee({state:"fallback",reason:_}),await v.start()}})().finally(()=>{F=null})),F),"Me");return{handle:{get state(){return z},on:a((r,o)=>i.on(r,o),"on"),start:ke,retry:a(()=>{if(v===null&&s.phase==="result"){W({type:"retake"}),L=0,N=!1,ke();return}if(v!==null&&z!=="error"){W({type:"retake"}),L=0,N=!1,A("base"),k=y?"single":e.side??"recto",v.rearm(k);return}ke()},"retry"),setSide:a(r=>{y||r==="single"||v!==null&&s.current===r&&k===r&&s.phase!=="reading"&&s.phase!=="result"||(s.current!==r&&(s={...s,current:r}),W({type:"clockRestart"}),s.phase!=="reading"&&s.phase!=="result"&&v!==null&&(k=r,v.rearm(r)))},"setSide"),shutter:He,focusAt:a((r,o)=>{v?.focusAt?.(r,o)},"focusAt"),setGuide:a(r=>{b=r,v?.setGuide?.(r)},"setGuide"),setTorch:a(r=>{V=r,v?.setTorch(r),W({type:"tick",at:c()})},"setTorch"),destroy:a(()=>{if(p&&l.end(z==="done"?"done":"abandoned"),p&&v!==null&&z!=="done"){let r=Ge();!Se&&r!==void 0&&r.ticks>0&&Ye(r,"abandoned"),_e(r,void 0)}p=!1,je(),he?.setEngine(null),K?.dispose(),K=null,i.clear()},"destroy")},plan:f,setFlowState:a(r=>{(s.phase==="reading"||s.phase==="result")&&te(r==="done"&&s.phase!=="result"?"scanning":r)},"setFlowState"),settle:a((r,o,m)=>{let x=r==="verso"?"verso":"recto",M=m!==void 0?fe.get(m.image):s.unsure;if(M!==void 0&&s.captured.recto!==M&&s.captured.verso!==M&&!s.pending.includes(M))return;if(l.settle(M!==void 0?G(M):void 0,y?"single":x,o),o.ok){let R=y?x:o.heldAs??x,H=s.phase;M!==void 0&&!y&&W({type:"held",id:M,side:R}),W({type:"readOk",side:R}),(H==="reading"||H==="result")&&s.phase!=="reading"&&s.phase!=="result"&&(q(),ae(s.current??(R==="recto"?"verso":"recto")));return}let E=s;W({type:"readFailed",side:x,...M!==void 0?{id:M}:{},issue:o.issue}),s!==E&&(q(),ae(x))},"settle"),takeDeviceRead:a(r=>Ue.get(r.image)?.value??null,"takeDeviceRead"),traceAnswer:a((r,o,m,x)=>l.answer(G(fe.get(r.image)),o,m,x),"traceAnswer"),serverHolds:a(r=>{if(y||r!=="recto"&&r!=="verso"||s.captured[r]!==void 0)return;let o=s;s={...s,captured:{...s.captured,[r]:"server"},readSides:s.readSides.includes(r)?s.readSides:[...s.readSides,r]},l.observe(o,s,{type:"held",id:"server",side:r})},"serverHolds"),dropped:a(r=>{let o=fe.get(r.image);return o!==void 0&&!y&&s.captured.recto!==o&&s.captured.verso!==o&&!s.pending.includes(o)},"dropped")}}a(br,"Mn");export{hr as a,mr as b,fr as c,wr as d,Lr as e,Pr as f,br as g};
|