@sekyro/elements 0.1.0-rc.11 → 0.1.0-rc.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cdn/chunks/{capture-session-doc-2XRGB6AO-ZURBQ4YP.js → capture-session-doc-GCL2FYQH-X7QTUFGI.js} +1 -1
  3. package/dist/cdn/chunks/challenge-frame-YBTLAQ5G-NN763UU5.js +1 -0
  4. package/dist/cdn/chunks/{chunk-RH3APX6G.js → chunk-26HXTRWG.js} +1 -1
  5. package/dist/cdn/chunks/{chunk-ADYI7APR.js → chunk-3DDOCOIB.js} +1 -1
  6. package/dist/cdn/chunks/{chunk-DW3VKKDE.js → chunk-3I6AVO6X.js} +1 -1
  7. package/dist/cdn/chunks/chunk-3NOBU7TE.js +1 -0
  8. package/dist/cdn/chunks/{chunk-R3P75ZRR.js → chunk-5JWGGQBH.js} +1 -1
  9. package/dist/cdn/chunks/chunk-A5SXWFOO.js +1 -0
  10. package/dist/cdn/chunks/{chunk-RKNAZPA7.js → chunk-AARN2MG7.js} +1 -1
  11. package/dist/cdn/chunks/{chunk-BMOSAKXR.js → chunk-CK3CQAFP.js} +1 -1
  12. package/dist/cdn/chunks/{chunk-XSGAV3PT.js → chunk-CPVOHNLU.js} +1 -1
  13. package/dist/cdn/chunks/{chunk-S774ZMGH.js → chunk-CSKOH7QX.js} +1 -1
  14. package/dist/cdn/chunks/{chunk-QMBS54J5.js → chunk-CSPTLSJY.js} +2 -2
  15. package/dist/cdn/chunks/{chunk-JI5WT66H.js → chunk-CX52FPYW.js} +1 -1
  16. package/dist/cdn/chunks/chunk-DEGFGNRM.js +3 -0
  17. package/dist/cdn/chunks/{chunk-FQYXVP54.js → chunk-DKZUKWGP.js} +1 -1
  18. package/dist/cdn/chunks/{chunk-TXDGBMD4.js → chunk-F7DKVXQW.js} +1 -1
  19. package/dist/cdn/chunks/chunk-FZXXMIZ4.js +1 -0
  20. package/dist/cdn/chunks/{chunk-E7OQJP4I.js → chunk-GZOBS7KG.js} +1 -1
  21. package/dist/cdn/chunks/chunk-JJ3Q52P3.js +25 -0
  22. package/dist/cdn/chunks/{chunk-3CEJV42Q.js → chunk-LHEWQFCZ.js} +1 -1
  23. package/dist/cdn/chunks/{chunk-TPDANNML.js → chunk-PYUD6W3P.js} +1 -1
  24. package/dist/cdn/chunks/chunk-QTPSRWXY.js +1 -0
  25. package/dist/cdn/chunks/{chunk-O23O5AAH.js → chunk-SHOVUF5C.js} +1 -1
  26. package/dist/cdn/chunks/chunk-VXXXAUQD.js +1 -0
  27. package/dist/cdn/chunks/{chunk-VPJEUYYP.js → chunk-ZPSZDTDP.js} +1 -1
  28. package/dist/cdn/chunks/{create-document-capture-XWNBUC55-FZGHPB6L.js → create-document-capture-IMDGCTMM-TBX7G2XG.js} +1 -1
  29. package/dist/cdn/chunks/{detector-scanic-S4PB2RNW-3KSM3MW5.js → detector-scanic-QVQVJI3C-K3ZARXJR.js} +1 -1
  30. package/dist/cdn/chunks/{document-capture-view-2NFKF44N-4F3CP2ZO.js → document-capture-view-GENB535Z-J72QDPT4.js} +1 -1
  31. package/dist/cdn/chunks/{eid-view-UGYVZ5NM-NQLRT4US.js → eid-view-IQRZGEMP-RHLNP5ZM.js} +1 -1
  32. package/dist/cdn/chunks/{email-otp-view-ENQVRS66-DCCJA246.js → email-otp-view-CL76K5TY-ZSNIDTY3.js} +1 -1
  33. package/dist/cdn/chunks/{flow-views-HNJPDQ63-ER7B4XJF.js → flow-views-C3EIMXME-U7PKRKNU.js} +1 -1
  34. package/dist/cdn/chunks/{form-view-6ERKUFVD-2JHV2SHY.js → form-view-MEYCK437-HDYDY2QI.js} +1 -1
  35. package/dist/cdn/chunks/overlay-de-LOQWEHOH-HSNQGD4A.js +1 -0
  36. package/dist/cdn/chunks/overlay-es-F54CKFZO-BTQKTR4A.js +1 -0
  37. package/dist/cdn/chunks/overlay-pt-NHIQY3JB-DQ7MH2QJ.js +1 -0
  38. package/dist/cdn/chunks/plan-runner-HBUVNDGH-6DM4PNGI.js +1 -0
  39. package/dist/cdn/chunks/{portrait-capture-view-ARRN3JW6-XRLTO3JS.js → portrait-capture-view-VTN2VU3E-WCQNHK3E.js} +1 -1
  40. package/dist/cdn/chunks/{portrait-review-view-JF6TYNBU-57HERUGH.js → portrait-review-view-JTRGDYNV-25TZW6WY.js} +1 -1
  41. package/dist/cdn/chunks/{proof-of-address-view-46Q6F7H5-7ES2ZRQL.js → proof-of-address-view-UQOZZXQO-DITYLW35.js} +1 -1
  42. package/dist/cdn/define.js +1 -1
  43. package/dist/cdn/index.js +1 -1
  44. package/dist/{chunk-DXR3ZGW2.js → chunk-6OZGEXX6.js} +1 -1
  45. package/dist/{chunk-37I3KKNR.js → chunk-753PBLDK.js} +1 -1
  46. package/dist/chunk-BZGVYIDN.js +25 -0
  47. package/dist/{chunk-NC6MJEKS.js → chunk-FBXU2OZN.js} +1 -1
  48. package/dist/{chunk-Y6IZDRYW.js → chunk-FCIH6PVW.js} +1 -1
  49. package/dist/{chunk-ZDYBRXXU.js → chunk-GA2DVM5C.js} +1 -1
  50. package/dist/{chunk-PNZPHUSG.js → chunk-HLMRVFVD.js} +1 -1
  51. package/dist/{chunk-5MQUCOFK.js → chunk-K7PFKAQD.js} +1 -1
  52. package/dist/{chunk-Q5HUTAIF.js → chunk-KNWOL5RR.js} +1 -1
  53. package/dist/{chunk-GBOZODQT.js → chunk-LGFZBFVB.js} +2 -2
  54. package/dist/{chunk-JQOJI5Z3.js → chunk-PYQREZ33.js} +1 -1
  55. package/dist/{chunk-43AFSR5C.js → chunk-W6ODZ5JK.js} +1 -1
  56. package/dist/{chunk-FHAN7WFM.js → chunk-XEWL7C6M.js} +1 -1
  57. package/dist/{chunk-OCLSIGRD.js → chunk-ZUVOUGIA.js} +1 -1
  58. package/dist/define.cjs +3 -3
  59. package/dist/define.js +1 -1
  60. package/dist/{document-capture-view-2NFKF44N-4JPWTBPF.js → document-capture-view-GENB535Z-L5V7YSPP.js} +1 -1
  61. package/dist/{eid-view-UGYVZ5NM-H7FHAGGG.js → eid-view-IQRZGEMP-LAMWORUL.js} +1 -1
  62. package/dist/{email-otp-view-ENQVRS66-5ZB3UKOO.js → email-otp-view-CL76K5TY-C7O472UB.js} +1 -1
  63. package/dist/{flow-views-HNJPDQ63-RAX3SDYO.js → flow-views-C3EIMXME-GGE4OUEO.js} +1 -1
  64. package/dist/{form-view-6ERKUFVD-Q2C54SUQ.js → form-view-MEYCK437-356QICGF.js} +1 -1
  65. package/dist/index.cjs +3 -3
  66. package/dist/index.d.cts +1 -0
  67. package/dist/index.d.ts +1 -0
  68. package/dist/index.js +1 -1
  69. package/dist/overlay-de-LOQWEHOH-YIQXHAUD.js +1 -0
  70. package/dist/overlay-es-F54CKFZO-JNTVTVWI.js +1 -0
  71. package/dist/overlay-pt-NHIQY3JB-V5CJ5SGF.js +1 -0
  72. package/dist/{portrait-capture-view-ARRN3JW6-RZYLVCCJ.js → portrait-capture-view-VTN2VU3E-2HKWLWRG.js} +1 -1
  73. package/dist/{portrait-review-view-JF6TYNBU-NHMROJU3.js → portrait-review-view-JTRGDYNV-TNR7WBYD.js} +1 -1
  74. package/dist/{proof-of-address-view-46Q6F7H5-TPLEKAFW.js → proof-of-address-view-UQOZZXQO-XJTGU3G6.js} +1 -1
  75. package/package.json +2 -2
  76. package/sbom.cdx.json +4 -4
  77. package/dist/cdn/chunks/challenge-frame-YAQJ5YMB-MHZYRGKY.js +0 -1
  78. package/dist/cdn/chunks/chunk-2FETDQV5.js +0 -1
  79. package/dist/cdn/chunks/chunk-C6HZ7TYS.js +0 -3
  80. package/dist/cdn/chunks/chunk-K5SATFJY.js +0 -1
  81. package/dist/cdn/chunks/chunk-QXWWOMOK.js +0 -1
  82. package/dist/cdn/chunks/chunk-S4ABXV4B.js +0 -1
  83. package/dist/cdn/chunks/chunk-SOI356LX.js +0 -25
  84. package/dist/cdn/chunks/chunk-XSGZY4JI.js +0 -1
  85. package/dist/cdn/chunks/overlay-de-2DL4MNC7-5CBBHT7P.js +0 -1
  86. package/dist/cdn/chunks/overlay-es-FMHWRKQW-REFKUX4J.js +0 -1
  87. package/dist/cdn/chunks/overlay-pt-OGIELLCM-GU2A32BS.js +0 -1
  88. package/dist/cdn/chunks/plan-runner-KX7KUS3M-CECACJOR.js +0 -1
  89. package/dist/chunk-VD7QSFUC.js +0 -25
  90. package/dist/overlay-de-2DL4MNC7-ELIZ2XHC.js +0 -1
  91. package/dist/overlay-es-FMHWRKQW-5PQ3EGK2.js +0 -1
  92. package/dist/overlay-pt-OGIELLCM-QT53YCS2.js +0 -1
@@ -1 +1 @@
1
- "use client";import{a as N}from"./chunk-37I3KKNR.js";import"./chunk-ZDYBRXXU.js";import{a as te}from"./chunk-Q5HUTAIF.js";import"./chunk-JQOJI5Z3.js";import{c as X}from"./chunk-NC6MJEKS.js";import{a as ae,b as re,c as ie}from"./chunk-43AFSR5C.js";import"./chunk-Y6IZDRYW.js";import"./chunk-PNZPHUSG.js";import{B as Y,G as Z,K as f,L as ee,a as ke,b as ye,c as C,t as Q}from"./chunk-VD7QSFUC.js";import{a as S,c as O,i as n}from"./chunk-SSU37LFQ.js";var i=O(ke(),1),e=O(ye(),1);var x=["pose","eyes","mouth","lighting","background","resolution"],se="occlusion";function le(r){return r?.startsWith("icao_")===!0?r.slice(5):null}S(le,"Se");n(le,"reasonCriterion");function ve({step:r,i18n:c,assetBaseUrl:M,onUpload:P}){let{t:a}=c,B=(0,i.useRef)(null),p=(0,i.useRef)(null),[s,oe]=(0,i.useState)("idle"),[k,L]=(0,i.useState)(null),[_,y]=(0,i.useState)(null),[$,E]=(0,i.useState)({facing:"user",assisted:!1}),[F,ne]=(0,i.useState)(!1),[de,I]=(0,i.useState)(!1),[j,ce]=(0,i.useState)(!1),pe=Q(),T=(0,i.useContext)(Y),U=(0,i.useContext)(ae),A=(0,i.useRef)(U);A.current=U,(0,i.useEffect)(()=>{let t=B.current;if(t===null)return;let l=r.capture({video:t,...M!==void 0?{assetBaseUrl:M}:{}});p.current=l;let g=n(()=>E({facing:l.facingMode??"user",assisted:l.captureMode==="assisted"}),"readCamera");g();let fe=[l.on("state",o=>{g(),o==="mode_switch"?I(!0):o!=="starting"&&o!=="gating"&&I(!1),oe(o)}),l.on("gate",L),l.on("error",o=>{y(o);let K=A.current;K!==null&&ie(K,re("portrait",o,0))})],J=!0;return Promise.resolve(l.canSwitchCaptureMode?.()??!1).catch(()=>!1).then(o=>{J&&ne(o===!0)}),l.start().catch(()=>{}),()=>{J=!1;for(let o of fe)o();l.destroy(),p.current=null}},[]);let u=s==="uploading"||s==="checking",h=s==="done",v=h&&r.reason!==void 0&&!r.uploadFailed,ue=s==="starting"||s==="idle"||s==="mode_switch"?"portrait.starting":s==="captured"?"portrait.taken":s==="uploading"?"portrait.uploading":s==="checking"?"portrait.checking":`portrait.coach.${k?.coach??"no_face"}`,R=(r.report??[]).filter(t=>!t.pass),V=r.reason!==void 0?`reasons.${r.reason}`:null,m=le(r.reason),q=R.filter(t=>t.criterion!==m),H=new Set([...R.map(t=>t.criterion),...m!==null?[m]:[]]),he=H.has(se),W=n(()=>{y(null),p.current?.retry()},"retake"),w=n(t=>{let l=k?.criteria.find(g=>g.criterion===t);return l!==void 0&&(l.held||l.waived)},"met"),me=k?.ready||s==="captured"||u?1:x.filter(w).length/x.length;v&&!j&&ce(!0);let z=V!==null&&(v||s==="gating"&&(m===null||!j)),ge=!v,D=s==="starting"||s==="gating"||s==="error"||s==="mode_switch",d=$.assisted?"self":"assisted",G=F&&D?{to:d,label:a(d==="assisted"?"capture.modeSwitch.toAssisted":"capture.modeSwitch.toSelfPhoto"),description:a(d==="assisted"?"capture.modeSwitch.toAssistedLabelPhoto":"capture.modeSwitch.toSelfLabelPhoto"),onSwitch:n(()=>{let t=p.current;t?.setCaptureMode(d).then(l=>{l&&(y(null),L(null),E({facing:t.facingMode??"user",assisted:d==="assisted"}))})},"onSwitch")}:null,b=de&&D?a("capture.modeSwitch.restarted"):null;return(0,e.jsxs)(te,{testId:"sekyro-portrait",video:(0,e.jsx)("video",{ref:B,className:`sekyro-lm-video sekyro-fc-video${$.facing==="environment"?" is-rear":""}`,playsInline:!0,muted:!0,autoPlay:!0,"aria-hidden":"true"}),instruction:a(ue),...b!==null?{note:b}:{},...F?{status:b}:{},progress:me,closeLabel:a("native.close"),...T!==void 0?{onClose:T}:{},...G!==null?{end:(0,e.jsx)(X,{view:G,className:"sekyro-glass sekyro-glass--label"})}:{},children:[(0,e.jsx)("h2",{ref:pe,tabIndex:-1,className:"sekyro-visually-hidden",children:a(r.reason!==void 0?"portrait.retryTitle":"session.steps.portrait.title")}),z||_!==null||h&&(r.uploadFailed||!r.attemptsExhausted)?(0,e.jsxs)("div",{className:"sekyro-fc-panel",children:[z?(0,e.jsxs)(f,{tone:"warning",children:[(0,e.jsx)("span",{children:N(c)(V)||a("portrait.retryTitle")}),q.length>0?(0,e.jsxs)("span",{children:[a("portrait.reportTitle"),": ",q.map(t=>a(`portrait.report.${t.criterion}`)).join(", ")]}):null,(0,e.jsx)("span",{children:ee(c,r.attemptsRemaining,r.attemptsExhausted)})]}):null,_!==null?(0,e.jsxs)(f,{tone:"danger",children:[(0,e.jsx)("span",{children:a("portrait.cameraBlocked")}),(0,e.jsx)("span",{children:a("portrait.cameraBlockedHint")}),(0,e.jsx)(C,{kind:"secondary",onClick:W,children:a("portrait.retryCamera")})]}):null,r.uploadFailed&&h?(0,e.jsx)(f,{tone:"danger",children:(0,e.jsx)("span",{children:a("portrait.uploadFailed")})}):null,h&&!r.attemptsExhausted?(0,e.jsx)(C,{full:!0,onClick:W,disabled:u,children:a("portrait.retake")}):null]}):null,ge?(0,e.jsxs)("ul",{className:"sekyro-fc-checks","aria-label":a("portrait.checksLabel"),children:[x.map(t=>(0,e.jsxs)("li",{className:w(t)?"is-met":H.has(t)?"is-flagged":void 0,"data-criterion":t,children:[(0,e.jsx)("span",{className:"sekyro-fc-mark","aria-hidden":"true",children:(0,e.jsx)("svg",{viewBox:"0 0 18 18",children:(0,e.jsx)("path",{d:"M5 9.2l2.6 2.6L13 6.4"})})}),(0,e.jsx)("span",{children:a(`portrait.criteria.${t}`)}),(0,e.jsx)("span",{className:"sekyro-visually-hidden",children:a(w(t)?"portrait.met":"portrait.notMet")})]},t)),he?(0,e.jsxs)("li",{className:"is-flagged","data-criterion":se,children:[(0,e.jsx)("span",{className:"sekyro-fc-mark","aria-hidden":"true",children:(0,e.jsx)("svg",{viewBox:"0 0 18 18",children:(0,e.jsx)("path",{d:"M5 9.2l2.6 2.6L13 6.4"})})}),(0,e.jsx)("span",{children:a("portrait.report.occlusion")}),(0,e.jsx)("span",{className:"sekyro-visually-hidden",children:a("portrait.notMet")})]}):null]}):null,P!==void 0&&!u?(0,e.jsx)("button",{type:"button",className:"sekyro-lm-upload",onClick:P,"data-testid":"sekyro-portrait-upload-instead",children:N(c)("portrait.source.uploadInstead")}):null,u?null:(0,e.jsx)(Z,{})]})}S(ve,"Le");n(ve,"PortraitCaptureView");export{ve as PortraitCaptureView};
1
+ "use client";import{a as N}from"./chunk-753PBLDK.js";import"./chunk-GA2DVM5C.js";import{a as te}from"./chunk-KNWOL5RR.js";import"./chunk-PYQREZ33.js";import{c as X}from"./chunk-FBXU2OZN.js";import{a as ae,b as re,c as ie}from"./chunk-W6ODZ5JK.js";import"./chunk-FCIH6PVW.js";import"./chunk-HLMRVFVD.js";import{B as Y,G as Z,K as f,L as ee,a as ke,b as ye,c as C,t as Q}from"./chunk-BZGVYIDN.js";import{a as S,c as O,i as n}from"./chunk-SSU37LFQ.js";var i=O(ke(),1),e=O(ye(),1);var x=["pose","eyes","mouth","lighting","background","resolution"],se="occlusion";function le(r){return r?.startsWith("icao_")===!0?r.slice(5):null}S(le,"Se");n(le,"reasonCriterion");function ve({step:r,i18n:c,assetBaseUrl:M,onUpload:P}){let{t:a}=c,B=(0,i.useRef)(null),p=(0,i.useRef)(null),[s,oe]=(0,i.useState)("idle"),[k,L]=(0,i.useState)(null),[_,y]=(0,i.useState)(null),[$,E]=(0,i.useState)({facing:"user",assisted:!1}),[F,ne]=(0,i.useState)(!1),[de,I]=(0,i.useState)(!1),[j,ce]=(0,i.useState)(!1),pe=Q(),T=(0,i.useContext)(Y),U=(0,i.useContext)(ae),A=(0,i.useRef)(U);A.current=U,(0,i.useEffect)(()=>{let t=B.current;if(t===null)return;let l=r.capture({video:t,...M!==void 0?{assetBaseUrl:M}:{}});p.current=l;let g=n(()=>E({facing:l.facingMode??"user",assisted:l.captureMode==="assisted"}),"readCamera");g();let fe=[l.on("state",o=>{g(),o==="mode_switch"?I(!0):o!=="starting"&&o!=="gating"&&I(!1),oe(o)}),l.on("gate",L),l.on("error",o=>{y(o);let K=A.current;K!==null&&ie(K,re("portrait",o,0))})],J=!0;return Promise.resolve(l.canSwitchCaptureMode?.()??!1).catch(()=>!1).then(o=>{J&&ne(o===!0)}),l.start().catch(()=>{}),()=>{J=!1;for(let o of fe)o();l.destroy(),p.current=null}},[]);let u=s==="uploading"||s==="checking",h=s==="done",v=h&&r.reason!==void 0&&!r.uploadFailed,ue=s==="starting"||s==="idle"||s==="mode_switch"?"portrait.starting":s==="captured"?"portrait.taken":s==="uploading"?"portrait.uploading":s==="checking"?"portrait.checking":`portrait.coach.${k?.coach??"no_face"}`,R=(r.report??[]).filter(t=>!t.pass),V=r.reason!==void 0?`reasons.${r.reason}`:null,m=le(r.reason),q=R.filter(t=>t.criterion!==m),H=new Set([...R.map(t=>t.criterion),...m!==null?[m]:[]]),he=H.has(se),W=n(()=>{y(null),p.current?.retry()},"retake"),w=n(t=>{let l=k?.criteria.find(g=>g.criterion===t);return l!==void 0&&(l.held||l.waived)},"met"),me=k?.ready||s==="captured"||u?1:x.filter(w).length/x.length;v&&!j&&ce(!0);let z=V!==null&&(v||s==="gating"&&(m===null||!j)),ge=!v,D=s==="starting"||s==="gating"||s==="error"||s==="mode_switch",d=$.assisted?"self":"assisted",G=F&&D?{to:d,label:a(d==="assisted"?"capture.modeSwitch.toAssisted":"capture.modeSwitch.toSelfPhoto"),description:a(d==="assisted"?"capture.modeSwitch.toAssistedLabelPhoto":"capture.modeSwitch.toSelfLabelPhoto"),onSwitch:n(()=>{let t=p.current;t?.setCaptureMode(d).then(l=>{l&&(y(null),L(null),E({facing:t.facingMode??"user",assisted:d==="assisted"}))})},"onSwitch")}:null,b=de&&D?a("capture.modeSwitch.restarted"):null;return(0,e.jsxs)(te,{testId:"sekyro-portrait",video:(0,e.jsx)("video",{ref:B,className:`sekyro-lm-video sekyro-fc-video${$.facing==="environment"?" is-rear":""}`,playsInline:!0,muted:!0,autoPlay:!0,"aria-hidden":"true"}),instruction:a(ue),...b!==null?{note:b}:{},...F?{status:b}:{},progress:me,closeLabel:a("native.close"),...T!==void 0?{onClose:T}:{},...G!==null?{end:(0,e.jsx)(X,{view:G,className:"sekyro-glass sekyro-glass--label"})}:{},children:[(0,e.jsx)("h2",{ref:pe,tabIndex:-1,className:"sekyro-visually-hidden",children:a(r.reason!==void 0?"portrait.retryTitle":"session.steps.portrait.title")}),z||_!==null||h&&(r.uploadFailed||!r.attemptsExhausted)?(0,e.jsxs)("div",{className:"sekyro-fc-panel",children:[z?(0,e.jsxs)(f,{tone:"warning",children:[(0,e.jsx)("span",{children:N(c)(V)||a("portrait.retryTitle")}),q.length>0?(0,e.jsxs)("span",{children:[a("portrait.reportTitle"),": ",q.map(t=>a(`portrait.report.${t.criterion}`)).join(", ")]}):null,(0,e.jsx)("span",{children:ee(c,r.attemptsRemaining,r.attemptsExhausted)})]}):null,_!==null?(0,e.jsxs)(f,{tone:"danger",children:[(0,e.jsx)("span",{children:a("portrait.cameraBlocked")}),(0,e.jsx)("span",{children:a("portrait.cameraBlockedHint")}),(0,e.jsx)(C,{kind:"secondary",onClick:W,children:a("portrait.retryCamera")})]}):null,r.uploadFailed&&h?(0,e.jsx)(f,{tone:"danger",children:(0,e.jsx)("span",{children:a("portrait.uploadFailed")})}):null,h&&!r.attemptsExhausted?(0,e.jsx)(C,{full:!0,onClick:W,disabled:u,children:a("portrait.retake")}):null]}):null,ge?(0,e.jsxs)("ul",{className:"sekyro-fc-checks","aria-label":a("portrait.checksLabel"),children:[x.map(t=>(0,e.jsxs)("li",{className:w(t)?"is-met":H.has(t)?"is-flagged":void 0,"data-criterion":t,children:[(0,e.jsx)("span",{className:"sekyro-fc-mark","aria-hidden":"true",children:(0,e.jsx)("svg",{viewBox:"0 0 18 18",children:(0,e.jsx)("path",{d:"M5 9.2l2.6 2.6L13 6.4"})})}),(0,e.jsx)("span",{children:a(`portrait.criteria.${t}`)}),(0,e.jsx)("span",{className:"sekyro-visually-hidden",children:a(w(t)?"portrait.met":"portrait.notMet")})]},t)),he?(0,e.jsxs)("li",{className:"is-flagged","data-criterion":se,children:[(0,e.jsx)("span",{className:"sekyro-fc-mark","aria-hidden":"true",children:(0,e.jsx)("svg",{viewBox:"0 0 18 18",children:(0,e.jsx)("path",{d:"M5 9.2l2.6 2.6L13 6.4"})})}),(0,e.jsx)("span",{children:a("portrait.report.occlusion")}),(0,e.jsx)("span",{className:"sekyro-visually-hidden",children:a("portrait.notMet")})]}):null]}):null,P!==void 0&&!u?(0,e.jsx)("button",{type:"button",className:"sekyro-lm-upload",onClick:P,"data-testid":"sekyro-portrait-upload-instead",children:N(c)("portrait.source.uploadInstead")}):null,u?null:(0,e.jsx)(Z,{})]})}S(ve,"Le");n(ve,"PortraitCaptureView");export{ve as PortraitCaptureView};
@@ -1 +1 @@
1
- "use client";import{a as r,b as t,c as i,d as o,e as a}from"./chunk-37I3KKNR.js";import"./chunk-ZDYBRXXU.js";import"./chunk-JQOJI5Z3.js";import"./chunk-Y6IZDRYW.js";import"./chunk-VD7QSFUC.js";import"./chunk-SSU37LFQ.js";export{o as PortraitReviewView,a as PortraitScreens,t as PortraitSourceView,i as PortraitUploadView,r as portraitCopy};
1
+ "use client";import{a as r,b as t,c as i,d as o,e as a}from"./chunk-753PBLDK.js";import"./chunk-GA2DVM5C.js";import"./chunk-PYQREZ33.js";import"./chunk-FCIH6PVW.js";import"./chunk-BZGVYIDN.js";import"./chunk-SSU37LFQ.js";export{o as PortraitReviewView,a as PortraitScreens,t as PortraitSourceView,i as PortraitUploadView,r as portraitCopy};
@@ -1 +1 @@
1
- "use client";import{a as S}from"./chunk-ZDYBRXXU.js";import{a as J}from"./chunk-P223YKM3.js";import{d as M}from"./chunk-JQOJI5Z3.js";import"./chunk-Y6IZDRYW.js";import{a as q}from"./chunk-5MQUCOFK.js";import"./chunk-PNZPHUSG.js";import{K as b,L as G,a as O,b as j,c as k,v as N,w as D,y as R}from"./chunk-VD7QSFUC.js";import{a as l,c as x,i as p}from"./chunk-SSU37LFQ.js";var v=x(O(),1),f=x(O(),1),o=x(j(),1),t=x(j(),1);var ee={"poa.title":"إثبات العنوان","poa.lead":"ارفع وثيقة حديثة تُظهر اسمك وعنوانك الحالي.","poa.accepted":"الوثائق المقبولة","poa.acceptedFor":"مقبول في {country}","poa.kindDated":"{kind}، صادر خلال آخر {days} يومًا","poa.kinds.utility_bill":"فاتورة كهرباء أو ماء أو غاز","poa.kinds.telecom_bill":"فاتورة هاتف أو إنترنت","poa.kinds.bank_statement":"كشف حساب بنكي","poa.kinds.tax_notice":"إشعار ضريبي","poa.kinds.rental_agreement":"عقد إيجار","poa.kinds.government_certificate":"شهادة السكن","poa.kinds.insurance_statement":"وثيقة تأمين","poa.source.camera":"التقاط صورة","poa.source.upload":"رفع ملف","poa.source.lead":"صورة للوثيقة، أو ملف PDF أو صورة من جهازك","poa.upload.hint":"PDF أو JPEG أو PNG، بحد أقصى 3 صفحات و10 ميغابايت","poa.upload.choose":"اختيار ملف","poa.upload.addPage":"إضافة صفحة","poa.upload.pages":"{count} من 3 صفحات","poa.upload.send":"إرسال الوثيقة","poa.upload.sending":"جارٍ إرسال وثيقتك…","poa.upload.unsupported":"نوع الملف هذا غير مقبول. اختر ملف PDF أو JPEG أو PNG","poa.upload.tooManyPages":"أرسل 3 صفحات على الأكثر. احذف صفحة أو اختر ملفًا أقصر","poa.upload.tooLarge":"حجم الملف يتجاوز 10 ميغابايت. اختر ملفًا أصغر","poa.upload.failed":"تعذّر إرسال الوثيقة. تحقّق من اتصالك وحاول مرة أخرى","poa.camera.lead":"ضع الوثيقة بشكل مسطّح واملأ الإطار. التقط صورة واحدة لكل صفحة","poa.camera.capture":"التقاط الصورة","poa.camera.retake":"إعادة الالتقاط","poa.camera.next":"الصفحة التالية","poa.camera.page":"الصفحة {number}","poa.letter.title":"رسالة من صاحب الفاتورة","poa.letter.lead":"الوثيقة باسم شخص آخر. أضف رسالة موقّعة من هذا الشخص تفيد بأنك تسكن في هذا العنوان","poa.letter.send":"إرسال الرسالة","poa.licence.use":"استخدام العنوان المذكور في رخصة القيادة","poa.licence.note":"قرأنا هذا العنوان من رخصتك. لا تحتاج إلى وثيقة أخرى.","poa.retry.document_too_old":"هذه الوثيقة أقدم من المسموح. ارفع وثيقة أحدث من القائمة أدناه","poa.retry.document_date_invalid":"تاريخ الوثيقة في المستقبل. ارفع وثيقة بتاريخ اليوم أو قبله","poa.retry.document_kind_not_accepted":"نوع هذه الوثيقة غير مقبول. ارفع إحدى الوثائق المذكورة أدناه","poa.retry.name_mismatch":"الاسم في الوثيقة لا يطابق اسمك. ارفع وثيقة باسمك","poa.retry.address_mismatch":"العنوان في الوثيقة لا يطابق العنوان الذي وصلنا. ارفع وثيقة لهذا العنوان","poa.retry.holder_letter_missing":"يجب أن تكون الرسالة موقّعة وأن تذكر اسمك واسم صاحب الفاتورة. ارفع رسالة كاملة","poa.retry.unreadable":"تعذّرت قراءة الوثيقة. ارفع نسخة كاملة وأكثر وضوحًا","poa.retry.pdf_protected":"أزل كلمة المرور من ملف PDF وحاول مرة أخرى","poa.retry.provider_unavailable":"تعذّر فحص الوثيقة حاليًا. حاول مرة أخرى بعد قليل","poa.hint.blurry":"الصورة غير واضحة","poa.hint.cropped":"جزء من الوثيقة مقطوع","poa.hint.glare":"يوجد انعكاس ضوء على الوثيقة","reasons.provider_unavailable":"تعذّر فحص الوثيقة حاليًا","reasons.pdf_protected":"ملف PDF محمي بكلمة مرور أو يحتوي على محتوى نشط","reasons.document_kind_not_accepted":"نوع الوثيقة غير مقبول","reasons.document_date_invalid":"تاريخ الوثيقة في المستقبل","reasons.document_too_old":"الوثيقة قديمة جدًا","reasons.document_tampered":"يبدو أن الوثيقة قد عُدّلت","reasons.holder_letter_required":"يلزم تقديم رسالة من صاحب الفاتورة","reasons.holder_letter_missing":"رسالة صاحب الفاتورة مفقودة أو غير مكتملة","reasons.address_mismatch":"العنوان لا يطابق العنوان المقدَّم"},U={"poa.title":"Proof of address","poa.lead":"Upload a recent document that shows your name and your current address.","poa.accepted":"Accepted documents","poa.acceptedFor":"Accepted for {country}","poa.kindDated":"{kind}, dated within the last {days} days","poa.kinds.utility_bill":"Electricity, water or gas bill","poa.kinds.telecom_bill":"Phone or internet bill","poa.kinds.bank_statement":"Bank statement","poa.kinds.tax_notice":"Tax notice","poa.kinds.rental_agreement":"Rental agreement","poa.kinds.government_certificate":"Residence certificate","poa.kinds.insurance_statement":"Insurance statement","poa.source.camera":"Take a photo","poa.source.upload":"Upload a file","poa.source.lead":"A photo of the document, or a PDF or image from your device","poa.upload.hint":"PDF, JPEG or PNG, up to 3 pages and 10 MB","poa.upload.choose":"Choose a file","poa.upload.addPage":"Add a page","poa.upload.pages":"{count} of 3 pages","poa.upload.send":"Send document","poa.upload.sending":"Sending your document…","poa.upload.unsupported":"This file type is not accepted. Choose a PDF, JPEG or PNG","poa.upload.tooManyPages":"Send at most 3 pages. Remove a page or choose a shorter file","poa.upload.tooLarge":"The file is over 10 MB. Choose a smaller file","poa.upload.failed":"We could not send the document. Check your connection and try again","poa.camera.lead":"Lay the document flat and fill the frame. Take one photo per page","poa.camera.capture":"Take photo","poa.camera.retake":"Retake","poa.camera.next":"Next page","poa.camera.page":"Page {number}","poa.letter.title":"Letter from the bill holder","poa.letter.lead":"The document is in another person's name. Add a signed letter from that person saying that you live at this address","poa.letter.send":"Send letter","poa.licence.use":"Use the address on my driver's license","poa.licence.note":"We read this address from your license. You don't need another document.","poa.retry.document_too_old":"This document is older than allowed. Upload a more recent one from the list below","poa.retry.document_date_invalid":"The date on the document is in the future. Upload a document with today's date or earlier","poa.retry.document_kind_not_accepted":"This document type is not accepted. Upload one of the documents listed below","poa.retry.name_mismatch":"The name on the document does not match yours. Upload a document in your name","poa.retry.address_mismatch":"The address on the document does not match the one we were given. Upload a document for that address","poa.retry.holder_letter_missing":"The letter must be signed and name both you and the bill holder. Upload a complete letter","poa.retry.unreadable":"We could not read the document. Upload a sharper, complete copy","poa.retry.pdf_protected":"Remove the password from the PDF and try again","poa.retry.provider_unavailable":"The document could not be checked right now. Try again in a moment","poa.hint.blurry":"The image is blurry","poa.hint.cropped":"Part of the document is cut off","poa.hint.glare":"There is glare on the document","reasons.provider_unavailable":"The document could not be checked right now","reasons.pdf_protected":"The PDF is password-protected or contains active content","reasons.document_kind_not_accepted":"The document type is not accepted","reasons.document_date_invalid":"The document date is in the future","reasons.document_too_old":"The document is too old","reasons.document_tampered":"The document appears to have been edited","reasons.holder_letter_required":"A letter from the bill holder is needed","reasons.holder_letter_missing":"The letter from the bill holder is missing or incomplete","reasons.address_mismatch":"The address does not match the one supplied"},ae={"poa.title":"Justificatif de domicile","poa.lead":"Importez un document récent qui indique votre nom et votre adresse actuelle.","poa.accepted":"Documents acceptés","poa.acceptedFor":"Accepté pour {country}","poa.kindDated":"{kind}, daté des {days} derniers jours","poa.kinds.utility_bill":"Facture d'électricité, d'eau ou de gaz","poa.kinds.telecom_bill":"Facture de téléphone ou d'internet","poa.kinds.bank_statement":"Relevé bancaire","poa.kinds.tax_notice":"Avis d'imposition","poa.kinds.rental_agreement":"Bail ou quittance de loyer","poa.kinds.government_certificate":"Certificat de résidence","poa.kinds.insurance_statement":"Attestation d'assurance","poa.source.camera":"Prendre une photo","poa.source.upload":"Importer un fichier","poa.source.lead":"Une photo du document, ou un PDF ou une image depuis votre appareil","poa.upload.hint":"PDF, JPEG ou PNG, 3 pages et 10 Mo au maximum","poa.upload.choose":"Choisir un fichier","poa.upload.addPage":"Ajouter une page","poa.upload.pages":"{count} sur 3 pages","poa.upload.send":"Envoyer le document","poa.upload.sending":"Envoi de votre document…","poa.upload.unsupported":"Ce type de fichier n'est pas accepté. Choisissez un PDF, un JPEG ou un PNG","poa.upload.tooManyPages":"Envoyez 3 pages au maximum. Retirez une page ou choisissez un fichier plus court","poa.upload.tooLarge":"Le fichier dépasse 10 Mo. Choisissez un fichier plus léger","poa.upload.failed":"Nous n'avons pas pu envoyer le document. Vérifiez votre connexion et réessayez","poa.camera.lead":"Posez le document à plat et remplissez le cadre. Prenez une photo par page","poa.camera.capture":"Prendre la photo","poa.camera.retake":"Reprendre","poa.camera.next":"Page suivante","poa.camera.page":"Page {number}","poa.letter.title":"Lettre du titulaire de la facture","poa.letter.lead":"Le document est au nom d'une autre personne. Ajoutez une lettre signée de cette personne attestant que vous habitez à cette adresse","poa.letter.send":"Envoyer la lettre","poa.licence.use":"Utiliser l'adresse de mon permis de conduire","poa.licence.note":"Nous avons lu cette adresse sur votre permis. Vous n'avez pas besoin d'un autre document.","poa.retry.document_too_old":"Ce document est plus ancien que la limite. Importez un document plus récent parmi ceux de la liste ci-dessous","poa.retry.document_date_invalid":"La date du document est dans le futur. Importez un document daté d'aujourd'hui ou d'avant","poa.retry.document_kind_not_accepted":"Ce type de document n'est pas accepté. Importez l'un des documents de la liste ci-dessous","poa.retry.name_mismatch":"Le nom sur le document ne correspond pas au vôtre. Importez un document à votre nom","poa.retry.address_mismatch":"L'adresse du document ne correspond pas à celle qui nous a été transmise. Importez un document pour cette adresse","poa.retry.holder_letter_missing":"La lettre doit être signée et nommer à la fois vous et le titulaire de la facture. Importez une lettre complète","poa.retry.unreadable":"Nous n'avons pas pu lire le document. Importez une copie plus nette et complète","poa.retry.pdf_protected":"Retirez le mot de passe du PDF et réessayez","poa.retry.provider_unavailable":"Le document n'a pas pu être vérifié pour le moment. Réessayez dans un instant","poa.hint.blurry":"L'image est floue","poa.hint.cropped":"Une partie du document est coupée","poa.hint.glare":"Il y a un reflet sur le document","reasons.provider_unavailable":"Le document n'a pas pu être vérifié pour le moment","reasons.pdf_protected":"Le PDF est protégé par un mot de passe ou contient du contenu actif","reasons.document_kind_not_accepted":"Ce type de document n'est pas accepté","reasons.document_date_invalid":"La date du document est dans le futur","reasons.document_too_old":"Le document est trop ancien","reasons.document_tampered":"Le document semble avoir été modifié","reasons.holder_letter_required":"Une lettre du titulaire de la facture est nécessaire","reasons.holder_letter_missing":"La lettre du titulaire de la facture est absente ou incomplète","reasons.address_mismatch":"L'adresse ne correspond pas à celle qui a été transmise"};function B({blob:a,label:n}){let[e,r]=(0,f.useState)(void 0);return(0,f.useEffect)(()=>{if(typeof URL.createObjectURL!="function")return;let d=URL.createObjectURL(a);return r(d),()=>URL.revokeObjectURL(d)},[a]),(0,o.jsx)("img",{src:e,alt:n})}l(B,"Q");p(B,"PageThumb");function $({step:a,i18n:n,c:e,title:r,notice:d,intro:m,onUpload:i}){let y=(0,f.useRef)(null),s=(0,f.useRef)(null),[c,_]=(0,f.useState)([]),[h,P]=(0,f.useState)(!1),[L,C]=(0,f.useState)("idle"),[K,F]=(0,f.useState)(!1),A=p(u=>{P(!1),u.start().catch(()=>P(!0))},"open");(0,f.useEffect)(()=>{let u=y.current;if(u===null)return;let g;try{g=a.capturePage({video:u})}catch{P(!0);return}return s.current=g,A(g),()=>{g.destroy(),s.current=null}},[]);let E=c.length>=a.maxPages,Q=p(async()=>{let u=s.current;if(!(u===null||E)){C("taking"),F(!1);try{await u.takePage()}catch{}_([...u.pages]),C("idle")}},"take"),X=p(u=>{let g=s.current;g!==null&&(g.removePage(u),_([...g.pages]))},"retake"),Z=p(async()=>{let u=s.current;if(!(u===null||c.length===0)){C("sending"),F(!1);try{await u.submitPages()}catch{F(!0)}C("idle")}},"send"),T=L==="sending";return(0,o.jsxs)("section",{className:"sekyro-step","data-testid":"sekyro-poa-camera",children:[(0,o.jsx)(D,{title:r,lead:e("poa.camera.lead")}),d,K?(0,o.jsx)(b,{tone:"danger",children:(0,o.jsx)("span",{children:e("poa.upload.failed")})}):null,h?(0,o.jsxs)(b,{tone:"danger",children:[(0,o.jsx)("span",{children:e("doc.cameraBlocked")}),(0,o.jsx)("span",{children:e("doc.cameraBlockedHint")}),s.current!==null?(0,o.jsx)(k,{kind:"secondary",onClick:l(()=>s.current!==null&&A(s.current),"onClick"),children:e("doc.retryCamera")}):null]}):null,c.length===0?m:null,(0,o.jsx)("video",{ref:y,className:"sekyro-poa-video",playsInline:!0,muted:!0,autoPlay:!0,"aria-hidden":"true"}),c.length>0?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("p",{className:"sekyro-text-muted",role:"status",children:e("poa.upload.pages",{count:c.length})}),(0,o.jsx)("ul",{className:"sekyro-poa-pages",children:c.map((u,g)=>{let I=e("poa.camera.page",{number:g+1});return(0,o.jsxs)("li",{children:[(0,o.jsx)(B,{blob:u,label:I}),(0,o.jsx)(k,{kind:"ghost",onClick:l(()=>X(g),"onClick"),disabled:T,"aria-label":`${e("poa.camera.retake")} ${I}`,children:e("poa.camera.retake")})]},g)})})]}):null,T?(0,o.jsx)("p",{className:"sekyro-text-muted",role:"status","aria-busy":"true",children:e("poa.upload.sending")}):null,(0,o.jsxs)(R,{children:[(0,o.jsxs)(k,{full:!0,kind:c.length>0?"secondary":"primary",onClick:l(()=>{Q()},"onClick"),disabled:E||h||L!=="idle"||a.attemptsExhausted,"aria-busy":L==="taking"||void 0,children:[(0,o.jsx)(N,{name:"camera"}),e("poa.camera.capture")]}),c.length>0?(0,o.jsx)(k,{full:!0,onClick:l(()=>{Z()},"onClick"),disabled:L!=="idle","aria-busy":T||void 0,children:e("poa.upload.send")}):null,i!==void 0?(0,o.jsx)(k,{full:!0,kind:"ghost",onClick:i,disabled:T,children:e("poa.source.upload")}):null]})]})}l($,"J");p($,"PageCamera");var te={en:U,fr:ae,ar:ee,es:U,pt:U,de:U},oe="image/jpeg,image/png,image/heic,image/heif,application/pdf";function V(a){let n=a.strings,e=te[a.locale];return(r,d)=>q(n[r]??e[r]??"",d)}l(V,"ae");p(V,"poaCopy");function z({step:a,i18n:n,c:e}){if(a.reason===void 0)return null;let r=e(`poa.retry.${a.reason}`)||e(`reasons.${a.reason}`)||e("poa.retry.unreadable");return(0,t.jsxs)(b,{tone:"warning",children:[(0,t.jsx)("span",{children:r}),(0,t.jsx)("span",{children:G(n,a.attemptsRemaining,a.attemptsExhausted)})]})}l(z,"U");p(z,"RetryNotice");function w({step:a,i18n:n,c:e}){let r=(0,v.useId)(),{country:d}=a.rule,m=d===null?e("poa.accepted"):e("poa.acceptedFor",{country:J(d,n.locale)});return(0,t.jsxs)("div",{className:"sekyro-poa-accepted",children:[(0,t.jsx)("p",{id:r,className:"sekyro-poa-accepted__title",children:m}),(0,t.jsx)("ul",{className:"sekyro-poa-list","aria-labelledby":r,children:a.rule.kinds.map(i=>(0,t.jsx)("li",{children:e("poa.kindDated",{kind:e(`poa.kinds.${i.kind}`)||i.kind,days:i.maxAgeDays})},i.kind))})]})}l(w,"j");p(w,"AcceptedList");var re={unsupported:"poa.upload.unsupported",tooMany:"poa.upload.tooManyPages",tooLarge:"poa.upload.tooLarge",failed:"poa.upload.failed"};function W(a){return a instanceof TypeError&&a.message==="unsupported_file"?"unsupported":a instanceof RangeError&&a.message==="file_too_large"?"tooLarge":a instanceof RangeError&&(a.message==="too_many_pages"||a.message==="no_pages")?"tooMany":"failed"}l(W,"re");p(W,"refusalOf");function H({step:a,i18n:n,c:e,letter:r,onCamera:d}){let m=(0,v.useRef)(null),[i,y]=(0,v.useState)("idle"),s=i==="sending",c=p(async _=>{let h=Array.from(_.currentTarget.files??[]);if(_.currentTarget.value="",h.length!==0){if(h.length>a.maxPages){y("tooMany");return}y("sending");try{await(r?a.uploadHolderLetter(h):a.uploadPages(h)),y("idle")}catch(P){y(W(P))}}},"onFiles");return(0,t.jsxs)("section",{className:"sekyro-step","data-testid":r?"sekyro-poa-letter":"sekyro-poa-upload",children:[(0,t.jsx)(D,{title:e(r?"poa.letter.title":"poa.title"),lead:e(r?"poa.letter.lead":"poa.lead")}),i==="idle"||s?(0,t.jsx)(z,{step:a,i18n:n,c:e}):null,i!=="idle"&&!s?(0,t.jsx)(b,{tone:"danger",children:(0,t.jsx)("span",{children:e(re[i])})}):null,r?null:(0,t.jsx)(w,{step:a,i18n:n,c:e}),(0,t.jsx)("p",{className:"sekyro-text-muted",children:e("poa.upload.hint")}),s?(0,t.jsx)("p",{className:"sekyro-text-muted",role:"status","aria-busy":"true",children:e("poa.upload.sending")}):null,(0,t.jsx)("input",{ref:m,type:"file",accept:oe,multiple:!0,hidden:!0,"data-testid":"sekyro-poa-file","aria-label":e(r?"poa.letter.title":"poa.title"),onChange:l(_=>{c(_)},"onChange")}),(0,t.jsxs)(R,{children:[(0,t.jsx)(k,{full:!0,onClick:l(()=>m.current?.click(),"onClick"),disabled:s||!a.photo.uploadOffered||a.attemptsExhausted,"aria-busy":s||void 0,children:e("poa.upload.choose")}),d!==void 0?(0,t.jsxs)(k,{full:!0,kind:"ghost",onClick:d,disabled:s,children:[(0,t.jsx)(N,{name:a.photo.cameraOnPhone===!0?"smartphone":"camera"}),a.photo.cameraOnPhone===!0?e("capture.source.phone"):e("poa.source.camera")]}):null]})]})}l(H,"se");p(H,"UploadScreen");function Y({step:a,c:n}){let[e,r]=(0,v.useState)("idle"),d=a.useLicenceAddress;if(d===void 0)return null;let m=p(async()=>{r("sending");try{await d(),r("idle")}catch{r("failed")}},"onUse");return(0,t.jsxs)("div",{className:"sekyro-poa-licence","data-testid":"sekyro-poa-licence",children:[(0,t.jsx)("p",{className:"sekyro-text-muted",children:n("poa.licence.note")}),e==="failed"?(0,t.jsx)(b,{tone:"danger",children:(0,t.jsx)("span",{children:n("poa.upload.failed")})}):null,(0,t.jsx)(k,{full:!0,kind:"secondary",onClick:l(()=>{m()},"onClick"),disabled:e==="sending"||a.attemptsExhausted,"aria-busy":e==="sending"||void 0,children:n("poa.licence.use")})]})}l(Y,"de");p(Y,"LicenceShortcut");function ne({step:a,i18n:n}){let e=V(n),[r,d]=(0,v.useState)(null),m=a.phase==="holder_letter",i=a.photo.source,y=i==="choice"?r??a.photo.pick:i,s=a.photo.cameraOnPhone===!0,c=a.photo.uploadOffered?()=>d("upload"):void 0,_=e(m?"poa.letter.title":"poa.title"),h;return y===null?h=(0,t.jsx)(S,{testId:"sekyro-poa-source",title:_,lead:e("poa.source.lead"),cameraLabel:e(s?"capture.source.phone":"poa.source.camera"),uploadLabel:e("poa.source.upload"),onPhone:s,notice:(0,t.jsx)(z,{step:a,i18n:n,c:e}),onCamera:l(()=>d("camera"),"onCamera"),onUpload:l(()=>d("upload"),"onUpload")}):y==="camera"&&s?h=(0,t.jsx)(M,{i18n:n,lead:e("handoff.lead.poa"),refresh:a.refresh,actions:c!==void 0?(0,t.jsx)(k,{kind:"ghost",full:!0,onClick:c,children:e("poa.source.upload")}):null}):y==="camera"?h=(0,t.jsx)($,{step:a,i18n:n,c:e,title:_,notice:(0,t.jsx)(z,{step:a,i18n:n,c:e}),intro:m?null:(0,t.jsx)(w,{step:a,i18n:n,c:e}),...i==="choice"&&c!==void 0?{onUpload:c}:{}}):h=(0,t.jsx)(H,{step:a,i18n:n,c:e,letter:m,...i==="choice"?{onCamera:p(()=>d("camera"),"onCamera")}:{}}),(0,t.jsxs)(t.Fragment,{children:[m?null:(0,t.jsx)(Y,{step:a,c:e}),h]})}l(ne,"we");p(ne,"ProofOfAddressView");export{oe as POA_UPLOAD_ACCEPT,ne as ProofOfAddressView,V as poaCopy};
1
+ "use client";import{a as S}from"./chunk-GA2DVM5C.js";import{a as J}from"./chunk-P223YKM3.js";import{d as M}from"./chunk-PYQREZ33.js";import"./chunk-FCIH6PVW.js";import{a as q}from"./chunk-K7PFKAQD.js";import"./chunk-HLMRVFVD.js";import{K as b,L as G,a as O,b as j,c as k,v as N,w as D,y as R}from"./chunk-BZGVYIDN.js";import{a as l,c as x,i as p}from"./chunk-SSU37LFQ.js";var v=x(O(),1),f=x(O(),1),o=x(j(),1),t=x(j(),1);var ee={"poa.title":"إثبات العنوان","poa.lead":"ارفع وثيقة حديثة تُظهر اسمك وعنوانك الحالي.","poa.accepted":"الوثائق المقبولة","poa.acceptedFor":"مقبول في {country}","poa.kindDated":"{kind}، صادر خلال آخر {days} يومًا","poa.kinds.utility_bill":"فاتورة كهرباء أو ماء أو غاز","poa.kinds.telecom_bill":"فاتورة هاتف أو إنترنت","poa.kinds.bank_statement":"كشف حساب بنكي","poa.kinds.tax_notice":"إشعار ضريبي","poa.kinds.rental_agreement":"عقد إيجار","poa.kinds.government_certificate":"شهادة السكن","poa.kinds.insurance_statement":"وثيقة تأمين","poa.source.camera":"التقاط صورة","poa.source.upload":"رفع ملف","poa.source.lead":"صورة للوثيقة، أو ملف PDF أو صورة من جهازك","poa.upload.hint":"PDF أو JPEG أو PNG، بحد أقصى 3 صفحات و10 ميغابايت","poa.upload.choose":"اختيار ملف","poa.upload.addPage":"إضافة صفحة","poa.upload.pages":"{count} من 3 صفحات","poa.upload.send":"إرسال الوثيقة","poa.upload.sending":"جارٍ إرسال وثيقتك…","poa.upload.unsupported":"نوع الملف هذا غير مقبول. اختر ملف PDF أو JPEG أو PNG","poa.upload.tooManyPages":"أرسل 3 صفحات على الأكثر. احذف صفحة أو اختر ملفًا أقصر","poa.upload.tooLarge":"حجم الملف يتجاوز 10 ميغابايت. اختر ملفًا أصغر","poa.upload.failed":"تعذّر إرسال الوثيقة. تحقّق من اتصالك وحاول مرة أخرى","poa.camera.lead":"ضع الوثيقة بشكل مسطّح واملأ الإطار. التقط صورة واحدة لكل صفحة","poa.camera.capture":"التقاط الصورة","poa.camera.retake":"إعادة الالتقاط","poa.camera.next":"الصفحة التالية","poa.camera.page":"الصفحة {number}","poa.letter.title":"رسالة من صاحب الفاتورة","poa.letter.lead":"الوثيقة باسم شخص آخر. أضف رسالة موقّعة من هذا الشخص تفيد بأنك تسكن في هذا العنوان","poa.letter.send":"إرسال الرسالة","poa.licence.use":"استخدام العنوان المذكور في رخصة القيادة","poa.licence.note":"قرأنا هذا العنوان من رخصتك. لا تحتاج إلى وثيقة أخرى.","poa.retry.document_too_old":"هذه الوثيقة أقدم من المسموح. ارفع وثيقة أحدث من القائمة أدناه","poa.retry.document_date_invalid":"تاريخ الوثيقة في المستقبل. ارفع وثيقة بتاريخ اليوم أو قبله","poa.retry.document_kind_not_accepted":"نوع هذه الوثيقة غير مقبول. ارفع إحدى الوثائق المذكورة أدناه","poa.retry.name_mismatch":"الاسم في الوثيقة لا يطابق اسمك. ارفع وثيقة باسمك","poa.retry.address_mismatch":"العنوان في الوثيقة لا يطابق العنوان الذي وصلنا. ارفع وثيقة لهذا العنوان","poa.retry.holder_letter_missing":"يجب أن تكون الرسالة موقّعة وأن تذكر اسمك واسم صاحب الفاتورة. ارفع رسالة كاملة","poa.retry.unreadable":"تعذّرت قراءة الوثيقة. ارفع نسخة كاملة وأكثر وضوحًا","poa.retry.pdf_protected":"أزل كلمة المرور من ملف PDF وحاول مرة أخرى","poa.retry.provider_unavailable":"تعذّر فحص الوثيقة حاليًا. حاول مرة أخرى بعد قليل","poa.hint.blurry":"الصورة غير واضحة","poa.hint.cropped":"جزء من الوثيقة مقطوع","poa.hint.glare":"يوجد انعكاس ضوء على الوثيقة","reasons.provider_unavailable":"تعذّر فحص الوثيقة حاليًا","reasons.pdf_protected":"ملف PDF محمي بكلمة مرور أو يحتوي على محتوى نشط","reasons.document_kind_not_accepted":"نوع الوثيقة غير مقبول","reasons.document_date_invalid":"تاريخ الوثيقة في المستقبل","reasons.document_too_old":"الوثيقة قديمة جدًا","reasons.document_tampered":"يبدو أن الوثيقة قد عُدّلت","reasons.holder_letter_required":"يلزم تقديم رسالة من صاحب الفاتورة","reasons.holder_letter_missing":"رسالة صاحب الفاتورة مفقودة أو غير مكتملة","reasons.address_mismatch":"العنوان لا يطابق العنوان المقدَّم"},U={"poa.title":"Proof of address","poa.lead":"Upload a recent document that shows your name and your current address.","poa.accepted":"Accepted documents","poa.acceptedFor":"Accepted for {country}","poa.kindDated":"{kind}, dated within the last {days} days","poa.kinds.utility_bill":"Electricity, water or gas bill","poa.kinds.telecom_bill":"Phone or internet bill","poa.kinds.bank_statement":"Bank statement","poa.kinds.tax_notice":"Tax notice","poa.kinds.rental_agreement":"Rental agreement","poa.kinds.government_certificate":"Residence certificate","poa.kinds.insurance_statement":"Insurance statement","poa.source.camera":"Take a photo","poa.source.upload":"Upload a file","poa.source.lead":"A photo of the document, or a PDF or image from your device","poa.upload.hint":"PDF, JPEG or PNG, up to 3 pages and 10 MB","poa.upload.choose":"Choose a file","poa.upload.addPage":"Add a page","poa.upload.pages":"{count} of 3 pages","poa.upload.send":"Send document","poa.upload.sending":"Sending your document…","poa.upload.unsupported":"This file type is not accepted. Choose a PDF, JPEG or PNG","poa.upload.tooManyPages":"Send at most 3 pages. Remove a page or choose a shorter file","poa.upload.tooLarge":"The file is over 10 MB. Choose a smaller file","poa.upload.failed":"We could not send the document. Check your connection and try again","poa.camera.lead":"Lay the document flat and fill the frame. Take one photo per page","poa.camera.capture":"Take photo","poa.camera.retake":"Retake","poa.camera.next":"Next page","poa.camera.page":"Page {number}","poa.letter.title":"Letter from the bill holder","poa.letter.lead":"The document is in another person's name. Add a signed letter from that person saying that you live at this address","poa.letter.send":"Send letter","poa.licence.use":"Use the address on my driver's license","poa.licence.note":"We read this address from your license. You don't need another document.","poa.retry.document_too_old":"This document is older than allowed. Upload a more recent one from the list below","poa.retry.document_date_invalid":"The date on the document is in the future. Upload a document with today's date or earlier","poa.retry.document_kind_not_accepted":"This document type is not accepted. Upload one of the documents listed below","poa.retry.name_mismatch":"The name on the document does not match yours. Upload a document in your name","poa.retry.address_mismatch":"The address on the document does not match the one we were given. Upload a document for that address","poa.retry.holder_letter_missing":"The letter must be signed and name both you and the bill holder. Upload a complete letter","poa.retry.unreadable":"We could not read the document. Upload a sharper, complete copy","poa.retry.pdf_protected":"Remove the password from the PDF and try again","poa.retry.provider_unavailable":"The document could not be checked right now. Try again in a moment","poa.hint.blurry":"The image is blurry","poa.hint.cropped":"Part of the document is cut off","poa.hint.glare":"There is glare on the document","reasons.provider_unavailable":"The document could not be checked right now","reasons.pdf_protected":"The PDF is password-protected or contains active content","reasons.document_kind_not_accepted":"The document type is not accepted","reasons.document_date_invalid":"The document date is in the future","reasons.document_too_old":"The document is too old","reasons.document_tampered":"The document appears to have been edited","reasons.holder_letter_required":"A letter from the bill holder is needed","reasons.holder_letter_missing":"The letter from the bill holder is missing or incomplete","reasons.address_mismatch":"The address does not match the one supplied"},ae={"poa.title":"Justificatif de domicile","poa.lead":"Importez un document récent qui indique votre nom et votre adresse actuelle.","poa.accepted":"Documents acceptés","poa.acceptedFor":"Accepté pour {country}","poa.kindDated":"{kind}, daté des {days} derniers jours","poa.kinds.utility_bill":"Facture d'électricité, d'eau ou de gaz","poa.kinds.telecom_bill":"Facture de téléphone ou d'internet","poa.kinds.bank_statement":"Relevé bancaire","poa.kinds.tax_notice":"Avis d'imposition","poa.kinds.rental_agreement":"Bail ou quittance de loyer","poa.kinds.government_certificate":"Certificat de résidence","poa.kinds.insurance_statement":"Attestation d'assurance","poa.source.camera":"Prendre une photo","poa.source.upload":"Importer un fichier","poa.source.lead":"Une photo du document, ou un PDF ou une image depuis votre appareil","poa.upload.hint":"PDF, JPEG ou PNG, 3 pages et 10 Mo au maximum","poa.upload.choose":"Choisir un fichier","poa.upload.addPage":"Ajouter une page","poa.upload.pages":"{count} sur 3 pages","poa.upload.send":"Envoyer le document","poa.upload.sending":"Envoi de votre document…","poa.upload.unsupported":"Ce type de fichier n'est pas accepté. Choisissez un PDF, un JPEG ou un PNG","poa.upload.tooManyPages":"Envoyez 3 pages au maximum. Retirez une page ou choisissez un fichier plus court","poa.upload.tooLarge":"Le fichier dépasse 10 Mo. Choisissez un fichier plus léger","poa.upload.failed":"Nous n'avons pas pu envoyer le document. Vérifiez votre connexion et réessayez","poa.camera.lead":"Posez le document à plat et remplissez le cadre. Prenez une photo par page","poa.camera.capture":"Prendre la photo","poa.camera.retake":"Reprendre","poa.camera.next":"Page suivante","poa.camera.page":"Page {number}","poa.letter.title":"Lettre du titulaire de la facture","poa.letter.lead":"Le document est au nom d'une autre personne. Ajoutez une lettre signée de cette personne attestant que vous habitez à cette adresse","poa.letter.send":"Envoyer la lettre","poa.licence.use":"Utiliser l'adresse de mon permis de conduire","poa.licence.note":"Nous avons lu cette adresse sur votre permis. Vous n'avez pas besoin d'un autre document.","poa.retry.document_too_old":"Ce document est plus ancien que la limite. Importez un document plus récent parmi ceux de la liste ci-dessous","poa.retry.document_date_invalid":"La date du document est dans le futur. Importez un document daté d'aujourd'hui ou d'avant","poa.retry.document_kind_not_accepted":"Ce type de document n'est pas accepté. Importez l'un des documents de la liste ci-dessous","poa.retry.name_mismatch":"Le nom sur le document ne correspond pas au vôtre. Importez un document à votre nom","poa.retry.address_mismatch":"L'adresse du document ne correspond pas à celle qui nous a été transmise. Importez un document pour cette adresse","poa.retry.holder_letter_missing":"La lettre doit être signée et nommer à la fois vous et le titulaire de la facture. Importez une lettre complète","poa.retry.unreadable":"Nous n'avons pas pu lire le document. Importez une copie plus nette et complète","poa.retry.pdf_protected":"Retirez le mot de passe du PDF et réessayez","poa.retry.provider_unavailable":"Le document n'a pas pu être vérifié pour le moment. Réessayez dans un instant","poa.hint.blurry":"L'image est floue","poa.hint.cropped":"Une partie du document est coupée","poa.hint.glare":"Il y a un reflet sur le document","reasons.provider_unavailable":"Le document n'a pas pu être vérifié pour le moment","reasons.pdf_protected":"Le PDF est protégé par un mot de passe ou contient du contenu actif","reasons.document_kind_not_accepted":"Ce type de document n'est pas accepté","reasons.document_date_invalid":"La date du document est dans le futur","reasons.document_too_old":"Le document est trop ancien","reasons.document_tampered":"Le document semble avoir été modifié","reasons.holder_letter_required":"Une lettre du titulaire de la facture est nécessaire","reasons.holder_letter_missing":"La lettre du titulaire de la facture est absente ou incomplète","reasons.address_mismatch":"L'adresse ne correspond pas à celle qui a été transmise"};function B({blob:a,label:n}){let[e,r]=(0,f.useState)(void 0);return(0,f.useEffect)(()=>{if(typeof URL.createObjectURL!="function")return;let d=URL.createObjectURL(a);return r(d),()=>URL.revokeObjectURL(d)},[a]),(0,o.jsx)("img",{src:e,alt:n})}l(B,"Q");p(B,"PageThumb");function $({step:a,i18n:n,c:e,title:r,notice:d,intro:m,onUpload:i}){let y=(0,f.useRef)(null),s=(0,f.useRef)(null),[c,_]=(0,f.useState)([]),[h,P]=(0,f.useState)(!1),[L,C]=(0,f.useState)("idle"),[K,F]=(0,f.useState)(!1),A=p(u=>{P(!1),u.start().catch(()=>P(!0))},"open");(0,f.useEffect)(()=>{let u=y.current;if(u===null)return;let g;try{g=a.capturePage({video:u})}catch{P(!0);return}return s.current=g,A(g),()=>{g.destroy(),s.current=null}},[]);let E=c.length>=a.maxPages,Q=p(async()=>{let u=s.current;if(!(u===null||E)){C("taking"),F(!1);try{await u.takePage()}catch{}_([...u.pages]),C("idle")}},"take"),X=p(u=>{let g=s.current;g!==null&&(g.removePage(u),_([...g.pages]))},"retake"),Z=p(async()=>{let u=s.current;if(!(u===null||c.length===0)){C("sending"),F(!1);try{await u.submitPages()}catch{F(!0)}C("idle")}},"send"),T=L==="sending";return(0,o.jsxs)("section",{className:"sekyro-step","data-testid":"sekyro-poa-camera",children:[(0,o.jsx)(D,{title:r,lead:e("poa.camera.lead")}),d,K?(0,o.jsx)(b,{tone:"danger",children:(0,o.jsx)("span",{children:e("poa.upload.failed")})}):null,h?(0,o.jsxs)(b,{tone:"danger",children:[(0,o.jsx)("span",{children:e("doc.cameraBlocked")}),(0,o.jsx)("span",{children:e("doc.cameraBlockedHint")}),s.current!==null?(0,o.jsx)(k,{kind:"secondary",onClick:l(()=>s.current!==null&&A(s.current),"onClick"),children:e("doc.retryCamera")}):null]}):null,c.length===0?m:null,(0,o.jsx)("video",{ref:y,className:"sekyro-poa-video",playsInline:!0,muted:!0,autoPlay:!0,"aria-hidden":"true"}),c.length>0?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("p",{className:"sekyro-text-muted",role:"status",children:e("poa.upload.pages",{count:c.length})}),(0,o.jsx)("ul",{className:"sekyro-poa-pages",children:c.map((u,g)=>{let I=e("poa.camera.page",{number:g+1});return(0,o.jsxs)("li",{children:[(0,o.jsx)(B,{blob:u,label:I}),(0,o.jsx)(k,{kind:"ghost",onClick:l(()=>X(g),"onClick"),disabled:T,"aria-label":`${e("poa.camera.retake")} ${I}`,children:e("poa.camera.retake")})]},g)})})]}):null,T?(0,o.jsx)("p",{className:"sekyro-text-muted",role:"status","aria-busy":"true",children:e("poa.upload.sending")}):null,(0,o.jsxs)(R,{children:[(0,o.jsxs)(k,{full:!0,kind:c.length>0?"secondary":"primary",onClick:l(()=>{Q()},"onClick"),disabled:E||h||L!=="idle"||a.attemptsExhausted,"aria-busy":L==="taking"||void 0,children:[(0,o.jsx)(N,{name:"camera"}),e("poa.camera.capture")]}),c.length>0?(0,o.jsx)(k,{full:!0,onClick:l(()=>{Z()},"onClick"),disabled:L!=="idle","aria-busy":T||void 0,children:e("poa.upload.send")}):null,i!==void 0?(0,o.jsx)(k,{full:!0,kind:"ghost",onClick:i,disabled:T,children:e("poa.source.upload")}):null]})]})}l($,"J");p($,"PageCamera");var te={en:U,fr:ae,ar:ee,es:U,pt:U,de:U},oe="image/jpeg,image/png,image/heic,image/heif,application/pdf";function V(a){let n=a.strings,e=te[a.locale];return(r,d)=>q(n[r]??e[r]??"",d)}l(V,"ae");p(V,"poaCopy");function z({step:a,i18n:n,c:e}){if(a.reason===void 0)return null;let r=e(`poa.retry.${a.reason}`)||e(`reasons.${a.reason}`)||e("poa.retry.unreadable");return(0,t.jsxs)(b,{tone:"warning",children:[(0,t.jsx)("span",{children:r}),(0,t.jsx)("span",{children:G(n,a.attemptsRemaining,a.attemptsExhausted)})]})}l(z,"U");p(z,"RetryNotice");function w({step:a,i18n:n,c:e}){let r=(0,v.useId)(),{country:d}=a.rule,m=d===null?e("poa.accepted"):e("poa.acceptedFor",{country:J(d,n.locale)});return(0,t.jsxs)("div",{className:"sekyro-poa-accepted",children:[(0,t.jsx)("p",{id:r,className:"sekyro-poa-accepted__title",children:m}),(0,t.jsx)("ul",{className:"sekyro-poa-list","aria-labelledby":r,children:a.rule.kinds.map(i=>(0,t.jsx)("li",{children:e("poa.kindDated",{kind:e(`poa.kinds.${i.kind}`)||i.kind,days:i.maxAgeDays})},i.kind))})]})}l(w,"j");p(w,"AcceptedList");var re={unsupported:"poa.upload.unsupported",tooMany:"poa.upload.tooManyPages",tooLarge:"poa.upload.tooLarge",failed:"poa.upload.failed"};function W(a){return a instanceof TypeError&&a.message==="unsupported_file"?"unsupported":a instanceof RangeError&&a.message==="file_too_large"?"tooLarge":a instanceof RangeError&&(a.message==="too_many_pages"||a.message==="no_pages")?"tooMany":"failed"}l(W,"re");p(W,"refusalOf");function H({step:a,i18n:n,c:e,letter:r,onCamera:d}){let m=(0,v.useRef)(null),[i,y]=(0,v.useState)("idle"),s=i==="sending",c=p(async _=>{let h=Array.from(_.currentTarget.files??[]);if(_.currentTarget.value="",h.length!==0){if(h.length>a.maxPages){y("tooMany");return}y("sending");try{await(r?a.uploadHolderLetter(h):a.uploadPages(h)),y("idle")}catch(P){y(W(P))}}},"onFiles");return(0,t.jsxs)("section",{className:"sekyro-step","data-testid":r?"sekyro-poa-letter":"sekyro-poa-upload",children:[(0,t.jsx)(D,{title:e(r?"poa.letter.title":"poa.title"),lead:e(r?"poa.letter.lead":"poa.lead")}),i==="idle"||s?(0,t.jsx)(z,{step:a,i18n:n,c:e}):null,i!=="idle"&&!s?(0,t.jsx)(b,{tone:"danger",children:(0,t.jsx)("span",{children:e(re[i])})}):null,r?null:(0,t.jsx)(w,{step:a,i18n:n,c:e}),(0,t.jsx)("p",{className:"sekyro-text-muted",children:e("poa.upload.hint")}),s?(0,t.jsx)("p",{className:"sekyro-text-muted",role:"status","aria-busy":"true",children:e("poa.upload.sending")}):null,(0,t.jsx)("input",{ref:m,type:"file",accept:oe,multiple:!0,hidden:!0,"data-testid":"sekyro-poa-file","aria-label":e(r?"poa.letter.title":"poa.title"),onChange:l(_=>{c(_)},"onChange")}),(0,t.jsxs)(R,{children:[(0,t.jsx)(k,{full:!0,onClick:l(()=>m.current?.click(),"onClick"),disabled:s||!a.photo.uploadOffered||a.attemptsExhausted,"aria-busy":s||void 0,children:e("poa.upload.choose")}),d!==void 0?(0,t.jsxs)(k,{full:!0,kind:"ghost",onClick:d,disabled:s,children:[(0,t.jsx)(N,{name:a.photo.cameraOnPhone===!0?"smartphone":"camera"}),a.photo.cameraOnPhone===!0?e("capture.source.phone"):e("poa.source.camera")]}):null]})]})}l(H,"se");p(H,"UploadScreen");function Y({step:a,c:n}){let[e,r]=(0,v.useState)("idle"),d=a.useLicenceAddress;if(d===void 0)return null;let m=p(async()=>{r("sending");try{await d(),r("idle")}catch{r("failed")}},"onUse");return(0,t.jsxs)("div",{className:"sekyro-poa-licence","data-testid":"sekyro-poa-licence",children:[(0,t.jsx)("p",{className:"sekyro-text-muted",children:n("poa.licence.note")}),e==="failed"?(0,t.jsx)(b,{tone:"danger",children:(0,t.jsx)("span",{children:n("poa.upload.failed")})}):null,(0,t.jsx)(k,{full:!0,kind:"secondary",onClick:l(()=>{m()},"onClick"),disabled:e==="sending"||a.attemptsExhausted,"aria-busy":e==="sending"||void 0,children:n("poa.licence.use")})]})}l(Y,"de");p(Y,"LicenceShortcut");function ne({step:a,i18n:n}){let e=V(n),[r,d]=(0,v.useState)(null),m=a.phase==="holder_letter",i=a.photo.source,y=i==="choice"?r??a.photo.pick:i,s=a.photo.cameraOnPhone===!0,c=a.photo.uploadOffered?()=>d("upload"):void 0,_=e(m?"poa.letter.title":"poa.title"),h;return y===null?h=(0,t.jsx)(S,{testId:"sekyro-poa-source",title:_,lead:e("poa.source.lead"),cameraLabel:e(s?"capture.source.phone":"poa.source.camera"),uploadLabel:e("poa.source.upload"),onPhone:s,notice:(0,t.jsx)(z,{step:a,i18n:n,c:e}),onCamera:l(()=>d("camera"),"onCamera"),onUpload:l(()=>d("upload"),"onUpload")}):y==="camera"&&s?h=(0,t.jsx)(M,{i18n:n,lead:e("handoff.lead.poa"),refresh:a.refresh,actions:c!==void 0?(0,t.jsx)(k,{kind:"ghost",full:!0,onClick:c,children:e("poa.source.upload")}):null}):y==="camera"?h=(0,t.jsx)($,{step:a,i18n:n,c:e,title:_,notice:(0,t.jsx)(z,{step:a,i18n:n,c:e}),intro:m?null:(0,t.jsx)(w,{step:a,i18n:n,c:e}),...i==="choice"&&c!==void 0?{onUpload:c}:{}}):h=(0,t.jsx)(H,{step:a,i18n:n,c:e,letter:m,...i==="choice"?{onCamera:p(()=>d("camera"),"onCamera")}:{}}),(0,t.jsxs)(t.Fragment,{children:[m?null:(0,t.jsx)(Y,{step:a,c:e}),h]})}l(ne,"we");p(ne,"ProofOfAddressView");export{oe as POA_UPLOAD_ACCEPT,ne as ProofOfAddressView,V as poaCopy};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sekyro/elements",
3
- "version": "0.1.0-rc.11",
3
+ "version": "0.1.0-rc.13",
4
4
  "description": "Sekyro AI custom elements: <sekyro-verification> for Vue, Angular, Svelte and plain HTML, the @sekyro/react flow with React bundled inside",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {
@@ -94,7 +94,7 @@
94
94
  "api:check": "api-extractor run"
95
95
  },
96
96
  "peerDependencies": {
97
- "@sekyro/web": "^0.1.0-rc.32 || ^0.2.0-rc.0"
97
+ "@sekyro/web": "^0.1.0-rc.34 || ^0.2.0-rc.0"
98
98
  },
99
99
  "devDependencies": {
100
100
  "@microsoft/api-extractor": "^7.59.4",
package/sbom.cdx.json CHANGED
@@ -97,8 +97,8 @@
97
97
  "type": "application",
98
98
  "name": "elements",
99
99
  "group": "@sekyro",
100
- "version": "0.1.0-rc.11",
101
- "bom-ref": "@sekyro/elements@0.1.0-rc.11",
100
+ "version": "0.1.0-rc.13",
101
+ "bom-ref": "@sekyro/elements@0.1.0-rc.13",
102
102
  "description": "Sekyro AI custom elements: <sekyro-verification> for Vue, Angular, Svelte and plain HTML, the @sekyro/react flow with React bundled inside",
103
103
  "licenses": [
104
104
  {
@@ -108,7 +108,7 @@
108
108
  }
109
109
  }
110
110
  ],
111
- "purl": "pkg:npm/%40sekyro/elements@0.1.0-rc.11?vcs_url=git%2Bhttps%3A%2F%2Fgithub.com%2FIBTIKAR-Technologies%2Fibtikar-identity.git%23packages%2Fsekyro-elements",
111
+ "purl": "pkg:npm/%40sekyro/elements@0.1.0-rc.13?vcs_url=git%2Bhttps%3A%2F%2Fgithub.com%2FIBTIKAR-Technologies%2Fibtikar-identity.git%23packages%2Fsekyro-elements",
112
112
  "externalReferences": [
113
113
  {
114
114
  "url": "https://github.com/IBTIKAR-Technologies/ibtikar-identity/issues",
@@ -147,7 +147,7 @@
147
147
  "components": [],
148
148
  "dependencies": [
149
149
  {
150
- "ref": "@sekyro/elements@0.1.0-rc.11"
150
+ "ref": "@sekyro/elements@0.1.0-rc.13"
151
151
  }
152
152
  ]
153
153
  }
@@ -1 +0,0 @@
1
- import{a as i}from"./chunk-4FHWXBOB.js";var k=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),b=3e4,p=12e4,E="sekyro.challenge.",M="position:fixed;width:1px;height:1px;inset-block-start:0;inset-inline-start:0;opacity:0;pointer-events:none;border:0",d=null,m=Promise.resolve();function T(){y(),m=Promise.resolve(),g=!1}i(T,"F");function u(){return new o("aborted")}i(u,"c");function S(){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(S,"C");function v(e){return new URL(e,document.baseURI).origin}i(v,"h");function y(){let e=d;if(e!==null){d=null,window.removeEventListener("message",e.listener),e.iframe.remove();for(let t of e.waiters.values())t.reject(new o("challenge_frame_blocked"));e.waiters.clear()}}i(y,"u");function A(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(E)||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.token"&&typeof n.token=="string"&&n.token!=="")e.waiters.delete(n.id),l.resolve(n.token);else if(n.type==="sekyro.challenge.error"){e.waiters.delete(n.id);let a=typeof n.code=="string"&&k.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,s))}}}i(A,"M");function L(e){if(d!==null&&d.url===e)return d;y();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",M);let r={url:e,origin:v(e),iframe:t,isReady:!1,insertedAt:Date.now(),onReady:null,waiters:new Map,listener:i(n=>A(r,n),"listener")};return window.addEventListener("message",r.listener),t.src=e,document.body.appendChild(t),d=r,r}i(L,"k");function R(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(R,"A");async function w(e){if(e.signal?.aborted)throw u();let t=L(e.frameUrl);try{return await U(t,e)}catch(r){throw r instanceof o&&t.readyMs!==void 0&&(r.readyMs??(r.readyMs=t.readyMs)),r}}i(w,"y");async function U(e,t){let r=t.signal;await R(e,t.readyTimeoutMs??b,r);let n=e.iframe.contentWindow;if(n===null)throw new o("challenge_frame_blocked");let l=t.timeoutMs??p,a=S(),s,c;try{return await new Promise((_,h)=>{e.waiters.set(a,{resolve:_,reject:h}),s=setTimeout(()=>h(new o("timeout")),l),r!==void 0&&(c=i(()=>h(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)}}i(U,"x");var g=!1;function x(e,t){if(g)return;let r;if(t==="challenge_frame_blocked"){let n=e;try{n=v(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(x,"R");async function C(e){if(globalThis.origin==="null")throw new o("embedder_opaque");if(e.signal?.aborted)throw u();try{return await w(e)}catch(t){if(y(),e.signal?.aborted||t instanceof o&&t.code==="aborted")throw u();if(t instanceof o&&t.code==="timeout")throw t;try{return await w(e)}catch(r){throw y(),e.signal?.aborted?u():r instanceof o?r:new o("challenge_failed")}}}i(C,"S");function D(e){let t=i(()=>C(e).catch(n=>{throw n instanceof o&&x(e.frameUrl,n.code),n}),"n"),r=m.then(t,t);return m=r.catch(()=>{}),r}i(D,"T");export{p as CHALLENGE_EXECUTE_TIMEOUT_MS,b as CHALLENGE_READY_TIMEOUT_MS,o as ChallengeError,D as executeChallenge,T as resetChallengeFrameForTests};
@@ -1 +0,0 @@
1
- import{a as n}from"./chunk-4FHWXBOB.js";var z=Object.freeze({minLines:4,fillMin:.55,fillMax:.98,offsetMax:.12,steadyFillDelta:.04,steadyOffsetDelta:.03,layoutShiftMax:.025,lineCountDelta:1,lockMs:600,steadyMs:900,minFrames:3});function R(r,t){let e=r.lineBoxes;if(e.length===0)return{lineCount:0,detected:!1,fill:0,offsetX:0,offsetY:0,centers:[]};let s=Math.min(...e.map(i=>i[0])),a=Math.max(...e.map(i=>i[0]+i[2])),l=Math.min(...e.map(i=>i[1])),h=Math.max(...e.map(i=>i[1]+i[3]));return{lineCount:e.length,detected:e.length>=t.minLines,fill:a-s,offsetX:(s+a)/2-.5,offsetY:(l+h)/2-.5,centers:e.map(i=>[i[0]+i[2]/2,i[1]+i[3]/2])}}n(R,"y");function N(r,t){if(r.centers.length===0||t.centers.length===0)return Number.POSITIVE_INFINITY;let e=0;for(let[s,a]of t.centers){let l=Number.POSITIVE_INFINITY;for(let[h,i]of r.centers)l=Math.min(l,Math.hypot(s-h,a-i));e+=l}return e/t.centers.length}n(N,"x");var x,O=(x=class{constructor(t=z){this.t=t,this.last=null,this.goodSince=null,this.steadySince=null,this.frames=0}offer(t,e,s={glareOk:!0,sharpOk:!0}){let a=this.t,l=R(t,a),h=this.last;this.last=l;let i=l.fill>=a.fillMin&&l.fill<=a.fillMax,o=Math.abs(l.offsetX)<=a.offsetMax&&Math.abs(l.offsetY)<=a.offsetMax,c=h!==null&&h.detected&&Math.abs(l.lineCount-h.lineCount)<=a.lineCountDelta&&N(h,l)<=a.layoutShiftMax,u=l.detected&&s.glareOk&&s.sharpOk&&i&&c&&h!==null&&Math.abs(l.fill-h.fill)<=a.steadyFillDelta&&Math.abs(l.offsetX-h.offsetX)<=a.steadyOffsetDelta&&Math.abs(l.offsetY-h.offsetY)<=a.steadyOffsetDelta,g=u&&o,m=l.detected?s.glareOk?l.fill<a.fillMin?"closer":l.fill>a.fillMax?"farther":o?s.sharpOk?void 0:"blurry":"center":"glare":void 0;return u?(this.frames++,this.steadySince??(this.steadySince=e),this.goodSince=g?this.goodSince??e:null,(this.goodSince!==null&&e-this.goodSince>=a.lockMs||e-this.steadySince>=a.steadyMs)&&this.frames>=a.minFrames?{state:"locked"}:{state:"locking",...m?{hint:m}:{}}):(this.goodSince=null,this.steadySince=null,this.frames=l.detected?1:0,{state:l.detected?"locking":"searching",...m?{hint:m}:{}})}reset(){this.last=null,this.goodSince=null,this.steadySince=null,this.frames=0}},n(x,"c"),x);var C=[[1,0],[0,1],[1,1],[1,-1]];function E(r){let{width:t,height:e,data:s}=r;if(t<16||e<16)return-1;let a=new Uint8Array(t*e);for(let h=0,i=0;h<a.length;h+=1,i+=4)a[h]=Math.round(.299*(s[i]??0)+.587*(s[i+1]??0)+.114*(s[i+2]??0));let l=-1;for(let[h,i]of C){let o=new Uint32Array(256),c=new Float64Array(256),u=0;for(let d=1;d<e-1;d+=1){let f=d*t,F=(d+i)*t,_=(d-i)*t;for(let p=1;p<t-1;p+=1){let T=a[F+p+h]??0,I=a[_+p-h]??0,S=Math.abs(T-I);o[S]=(o[S]??0)+1,c[S]=(c[S]??0)+Math.abs(T+I-2*(a[f+p]??0)),u+=1}}let g=Math.max(1,Math.floor(u/20)),m=0,M=0,k=0;for(let d=255;d>=0&&m<g;d-=1){let f=o[d]??0;m+=f,M+=f*d,k+=c[d]??0}if(M===0)return 0;let y=k/M;l=l<0?y:Math.min(l,y)}return l}n(E,"w");var A=.06;function B(r,t,e,s=A){if(r===null||t.width<=0||t.height<=0)return null;let a=[r.topLeft,r.topRight,r.bottomRight,r.bottomLeft],l=e.width/t.width,h=e.height/t.height,i=Math.min(...a.map(f=>f.x))*l,o=Math.max(...a.map(f=>f.x))*l,c=Math.min(...a.map(f=>f.y))*h,u=Math.max(...a.map(f=>f.y))*h,g=(o-i)*s,m=(u-c)*s,M=Math.max(0,Math.floor(i-g)),k=Math.max(0,Math.floor(c-m)),y=Math.min(e.width,Math.ceil(o+g)),d=Math.min(e.height,Math.ceil(u+m));return y-M<16||d-k<16?null:{x:M,y:k,width:y-M,height:d-k}}n(B,"P");function X(r,t){let e=t??{x:0,y:0,width:r.width,height:r.height},s=Math.min(1,1e3/Math.max(e.width,e.height)),a=Math.max(1,Math.round(e.width*s)),l=Math.max(1,Math.round(e.height*s)),h=document.createElement("canvas");h.width=a,h.height=l;try{let i=h.getContext("2d",{willReadFrequently:!0});return i===null?-1:(i.imageSmoothingQuality="high",i.drawImage(r,e.x,e.y,e.width,e.height,0,0,a,l),E(i.getImageData(0,0,a,l)))}catch{return-1}finally{h.width=0,h.height=0}}n(X,"B");var b,G=(b=class{constructor(t=2){this.stableReads=t,this.last=null,this.run=0}offer(t){return t===null?(this.reset(),!1):(this.run=t===this.last?this.run+1:1,this.last=t,this.run>=this.stableReads)}reset(){this.last=null,this.run=0}},n(b,"k"),b),L=Object.freeze({...z,minIntervalMs:150,maxWidthPx:480,detectorLimit:960,searchTimeoutMs:12e3}),P=Object.freeze({detectorLimit:960,bandMaxWidthPx:1280,minBandWidthPx:900,bandTop:.55,minIntervalMs:150,stableReads:2,profileReads:5,maxReadMs:1200,searchTimeoutMs:12e3}),V=n((r,t,e)=>createImageBitmap(r,Math.round(t.x),Math.round(t.y),Math.max(1,Math.round(t.w)),Math.max(1,Math.round(t.h)),{resizeWidth:Math.max(1,Math.round(Math.min(t.w,e))),resizeQuality:"high"}),"C"),w=n((r,t)=>{if(r.length===0)return 0;let e=[...r].sort((s,a)=>s-a);return e[Math.min(e.length-1,Math.floor(e.length*t))]},"x");function Y(r){return r<=250?"fast":r<=600?"mid":"slow"}n(Y,"G");function j(r,t,e){let s=r.y+r.h*t,a=Math.min(e,r.y+r.h*1.05);return{x:r.x,y:s,w:r.w,h:Math.max(1,a-s)}}n(j,"Y");var v,U=(v=class{constructor(t){this.o=t,this.engine=null,this.gen=0,this.inFlight=!1,this.lastReadAt=Number.NEGATIVE_INFINITY,this.firstSeen=null,this.reads=0,this.times=[],this.mrzState={state:"searching"},this.lockState={state:"searching"},this.fallback=null,this.lockOff=!1,this.lockError=!1,this.fired=null,this.valid=null,this.faceMode="off",this.disabled=!1,this.crop=t.crop??V,this.mrzGate=new G(t.liveMrz?.stableReads??2),this.lockGate=new O(t.textLock??L)}setEngine(t){this.engine=t}get bandTop(){return this.o.liveMrz?.bandTop??P.bandTop}get hasEngine(){return this.engine!==null&&!this.disabled}reset(){this.gen++,this.inFlight=!1,this.lastReadAt=Number.NEGATIVE_INFINITY,this.firstSeen=null,this.reads=0,this.times=[],this.mrzGate.reset(),this.lockGate.reset(),this.mrzState={state:"searching"},this.lockState={state:"searching"},this.fallback=null,this.lockOff=!1,this.lockError=!1,this.fired=null,this.valid=null,this.faceMode="off"}rearmFace(){this.gen++,this.inFlight=!1,this.lastReadAt=Number.NEGATIVE_INFINITY,this.mrzGate.reset(),this.lockGate.reset(),this.fired=null,this.valid=null,this.fallback===null&&(this.mrzState={state:"searching"}),this.lockOff||(this.lockState={state:"searching"})}liveCapture(){return this.fired?.via==="live_mrz"?this.valid:null}modeFor(t){return this.engine===null||this.disabled?"off":t.mrzFace&&this.o.liveMrz!==null&&this.fallback===null?"live_mrz":this.o.textLock!==null&&!this.lockOff?"text_lock":"off"}tick(t){let e=this.modeFor(t);return e!=="off"&&(this.faceMode=e),this.fired!==null?{ready:!0,via:this.fired.via,suspendQuality:this.fired.via==="live_mrz",mode:e,...this.states()}:e==="live_mrz"?this.liveTick(t,this.o.liveMrz):e==="text_lock"?this.lockTick(t,this.o.textLock):{ready:!1,suspendQuality:!1,mode:e,...this.states()}}states(){return{...this.faceMode==="live_mrz"||this.fallback!==null?{mrz:this.fallback!==null?{state:"fallback",reason:this.fallback}:this.mrzState}:{},...this.faceMode==="text_lock"?{lock:this.lockState}:{}}}canRead(t,e){let s=this.engine;return s!==null&&!this.inFlight&&!s.busy&&t-this.lastReadAt>=e}fall(t){this.fallback=t,this.mrzGate.reset()}liveTick(t,e){let s=n(()=>this.fallback!==null?{ready:!1,suspendQuality:!1,mode:"live_mrz",mrz:{state:"fallback",reason:this.fallback}}:{ready:!1,suspendQuality:!0,mode:"live_mrz",mrz:this.mrzState},"r");if(!t.present||t.band===null)return this.mrzGate.reset(),this.mrzState={state:"searching"},s();if(this.firstSeen??(this.firstSeen=t.atMs),t.atMs-this.firstSeen>e.searchTimeoutMs)return this.fall("timeout"),s();if(t.band.w<e.minBandWidthPx)return t.card!==null&&t.card.w<e.minBandWidthPx?(this.fall("unsupported"),s()):(this.mrzState={state:"reading",coach:t.portrait?"turnSideways":"moveCloser"},{ready:!1,suspendQuality:!1,mode:"live_mrz",mrz:this.mrzState});if(!this.canRead(t.atMs,e.minIntervalMs))return s();this.inFlight=!0,this.lastReadAt=t.atMs;let a=this.gen,l=this.engine,h=t.glareOk?t.sharpOk?void 0:"holdStill":"glare";return this.crop(t.video,t.band,e.bandMaxWidthPx).then(i=>l.bandRead(i,e.detectorLimit)).then(i=>{if(a===this.gen){if(this.reads++,this.times.push(i.ms),this.times.length>8&&this.times.shift(),this.reads>=e.profileReads&&w(this.times,.5)>e.maxReadMs)return this.fall("slow");if(this.mrzGate.offer(i.valid?i.digest??null:null)&&i.format&&i.digest){this.valid={format:i.format,...i.documentCode!==void 0?{documentCode:i.documentCode}:{},digest:i.digest,lineCount:i.lineCount,framesToValid:this.reads,msToValid:Math.round(t.atMs-(this.firstSeen??t.atMs))},this.mrzState={state:"valid",format:i.format},this.fired={via:"live_mrz",at:t.atMs};return}this.mrzState={state:"reading",...h?{coach:h}:{},...i.format?{format:i.format}:{}}}}).catch(()=>{a===this.gen&&this.fall("error")}).finally(()=>{a===this.gen&&(this.inFlight=!1)}),s()}lockTick(t,e){let s=n(()=>({ready:!1,suspendQuality:!1,mode:"text_lock",lock:this.lockState,...this.fallback!==null?{mrz:{state:"fallback",reason:this.fallback}}:{}}),"r");if(!t.present||t.card===null)return this.lockGate.reset(),this.lockState={state:"searching"},s();if(this.firstSeen??(this.firstSeen=t.atMs),t.atMs-this.firstSeen>e.searchTimeoutMs)return this.lockOff=!0,s();if(!this.canRead(t.atMs,e.minIntervalMs))return s();this.inFlight=!0,this.lastReadAt=t.atMs;let a=this.gen,l=this.engine,h={glareOk:t.glareOk,sharpOk:t.sharpOk};return this.crop(t.video,t.card,e.maxWidthPx).then(i=>l.layoutRead(i,e.detectorLimit)).then(i=>{if(a!==this.gen)return;this.reads++,this.times.push(i.ms),this.times.length>8&&this.times.shift();let o=this.lockGate.offer(i,t.atMs,h);this.lockState=o.state==="locked"?{state:"locked"}:{state:o.state,...o.hint?{hint:o.hint}:{}},o.state==="locked"&&(this.fired={via:"text_lock",at:t.atMs})}).catch(()=>{a===this.gen&&(this.lockOff=!0,this.lockError=!0)}).finally(()=>{a===this.gen&&(this.inFlight=!1)}),s()}disable(){this.disabled=!0,this.reset()}report(t,e,s){let a=this.faceMode;if(a==="off")return null;let l=w(this.times,.5),h={capture:t,mode:a,reads:this.reads,...this.times.length>0?{readP50Ms:Math.round(l),readP90Ms:Math.round(w(this.times,.9)),deviceClass:Y(l)}:{}};return a==="live_mrz"?this.fired?.via==="live_mrz"&&this.valid!==null&&e==="live_mrz"?{...h,outcome:"valid",format:this.valid.format,framesToValid:this.valid.framesToValid,msToValid:this.valid.msToValid}:this.fallback!==null?{...h,outcome:this.fallback}:{...h,outcome:s-(this.firstSeen??s)>=(this.o.liveMrz?.searchTimeoutMs??1/0)?"timeout":"off"}:this.fired?.via==="text_lock"?{...h,outcome:"locked",framesToLock:Math.max(1,this.reads),msToLock:Math.round(this.fired.at-(this.firstSeen??this.fired.at))}:{...h,outcome:this.lockError?"error":this.lockOff?"timeout":"off"}}},n(v,"L"),v);export{B as a,X as b,L as c,P as d,j as e,U as f};
@@ -1,3 +0,0 @@
1
- import{A as Je,F as ue,G as W,H as Qe,I as Xe,J as et,a as I,b as Ue,c as Fe,f as je,g as Ke,h as Be,i as Ve,j as se,k as $e,m as P,o as M,p as O,q as j,r as Z,s as E,t as le,v as He,w as ze,x as Ze,y as We,z as Ye}from"./chunk-QXWWOMOK.js";import{f as nt}from"./chunk-FQYXVP54.js";import{b as Ge}from"./chunk-TXDGBMD4.js";import{b as qe,c as oe,e as tt}from"./chunk-6MYG4HWP.js";import{a as t}from"./chunk-4FHWXBOB.js";function Et(r){return r.idNumberBound??r.nniBound}t(Et,"ae");function rt(r){return r===void 0?void 0:r.idNumberFromDocument??r.nniFromDocument}t(rt,"ee");var ot="https://api.sekyro.ai",Rt=5e3,Nt=24e4,Pt=9e4,Ot=25*6e4,Lt=20*6e4,Dt=3,qt=3e3,Gt=1500,Ut=10;function it(r){return r instanceof Error&&r.name==="ChallengeError"&&r.code||"challenge_failed"}t(it,"St");var at=new Set(["aborted","embedder_opaque","site_key_rejected"]);function Ft(r){return new Promise(l=>setTimeout(l,r))}t(Ft,"un");function jt(){let r=globalThis.crypto;if(r!==void 0&&typeof r.randomUUID=="function")return r.randomUUID();let l=new Uint8Array(16);if(r!==void 0&&typeof r.getRandomValues=="function")r.getRandomValues(l);else for(let f=0;f<16;f+=1)l[f]=Math.floor(Math.random()*256);l[6]=(l[6]??0)&15|64,l[8]=(l[8]??0)&63|128;let p=[...l].map(f=>f.toString(16).padStart(2,"0")).join("");return`${p.slice(0,8)}-${p.slice(8,12)}-${p.slice(12,16)}-${p.slice(16,20)}-${p.slice(20)}`}t(jt,"cn");function Kt(r){return Bt(r,{})}t(Kt,"wo");function Bt(r,l){let p=r.apiOrigin??ot,f=r.autoRetry??!0,dt=r.rearm??"auto",K=l.client??new Fe({apiOrigin:p,sessionToken:r.clientToken,fetch:r.fetch}),y=new Proxy(K,{get(e,n){if(n==="submitCheck")return _t;let i=Reflect.get(e,n,e);return typeof i=="function"?i.bind(e):i}}),D=l.sleep??Ft,pe=l.uuid??jt,pt=l.getChallengeToken??((e,n)=>import("./challenge-frame-YAQJ5YMB-MHZYRGKY.js").then(i=>i.executeChallenge({frameUrl:e.url,siteKey:e.siteKey,action:"liveness",subject:n.subject,signal:n.signal}))),S=tt(),R=null,fe=null,u=!1,me=new AbortController,c=null,B=null,V=null,$=t(()=>V??Qe(c),"ne"),he=t(()=>Xe(W(c),$()),"Re"),b=t(e=>{c=e,!M(e)&&(xe(Lt)||yt(e))&&ie(e),S.emit("view",e),R?.onView(e)},"O"),v=t(()=>c!==null?Promise.resolve(c):(B??(B=y.getSession().then(e=>(b(e),e)).finally(()=>{B=null})),B),"A"),k=t(async()=>{let e=await y.getSession();return b(e),e},"E"),Y=t(async(e,n)=>{e.plan!==void 0?b(e):await k()},"de"),H=null,ye=t(async e=>{let n=await v();if(e||!n.consentRecorded){let i=await y.recordConsent(r.locale);i.plan!==void 0?b(i):c!==null&&b({...c,consentRecorded:!0})}z()&&ie(n)},"Ie"),A=t(e=>e?.force===!0?ye(!0):(H??(H=ye(!1).finally(()=>{H=null})),H),"N"),J={client:y,ensureConsent:t(e=>A(e),"ensureConsent"),sleep:D,uuid:pe,...l.random!==void 0?{random:l.random}:{},onBusy:t(e=>{u||S.emit("busy",e)},"onBusy")},ve=!1,_e=null,Q=t(e=>{if(e.status==="verified"||e.status==="not_verified"||e.status==="review"){if(ve)return;ve=!0}_e=JSON.stringify(e),S.emit("result",e)},"fe"),ft=t(e=>{_e!==JSON.stringify(e)&&Q(e)},"Nt"),ge=t(async e=>{let n=c;e&&(n=await k().catch(()=>c));let i=n===null?null:P(n);return i!==null&&!u&&S.emit("method",i),i!==null},"Ee"),X=null,be=!1,ke=!1,we=t(()=>We(J,(e,n)=>e.submitCheck("population_registry",{},{idempotencyKey:n})),"Ne"),Ae=t(e=>Et(e)===!0||rt(j(e,"population_registry"))===!0,"Fe"),mt=t(async()=>{try{let e=await v();if(M(e)||P(e)!==null||O(e)?.checkType!=="population_registry")return;if(!Ae(e)&&rt(j(e,"population_registry"))===void 0&&(e=await k()),!Ae(e)){ke=!0;return}await A(),await Y(await we(),"population_registry");let n=c===null?void 0:j(c,"population_registry");if(n?.state==="input_required"&&n.reason==="registry_unavailable"&&$e(n)>0){if(await D(Rt),u)return;await Y(await we(),"population_registry")}}catch(e){if(e instanceof I&&(e.code==="check_not_active"||e.code==="step_not_on_path")){await k().catch(()=>{});return}be=!0;return}c!==null&&M(c)&&Q(le(c,{autoRetry:f}))},"Ft"),Ce=t(()=>(X??(X=mt()),X),"He"),w=l.now??Date.now,N=null,q,ee,ht=0,te=t((e,n)=>`${e.url}
2
- ${e.siteKey}
3
- ${n}`,"he"),Me=0,ne,re=t((e,n)=>{Me+=1;let i=w(),s=pt(e,{signal:me.signal,subject:n}),o={key:te(e,n),at:i,token:s};return s.then(()=>{o.issuedAt=w(),ee=void 0},d=>{let m=it(d);if(o.failed=m,u||m==="aborted")return;ee=m;let{detail:h,readyMs:a}=d;G({check:"attestation",kind:"unavailable",engineKind:m,attempt:ht++,challengeMs:w()-i,readyMs:a,detail:h,inApp:Ge()})}),s.catch(()=>{}),o},"ge"),Se=t((e,n)=>e!==null&&e.key===n&&(e.issuedAt===void 0||w()-e.issuedAt<Nt),"De"),ie=t((e,n={})=>{let i=e?.challenge??null;if(e===null||i===null||u)return;let s=Z(e.sessionId),o=N;(n.replaceFailed===!0&&o?.failed!==void 0&&!at.has(o.failed)||!Se(o,te(i,s)))&&(N=re(i,s))},"Se"),Te=t(async(e,n)=>{let i=te(e,n),s=N;N=null;let o=Se(s,i)?s:re(e,n),d=o===s?0:1,m,h=new Promise(a=>{m=setTimeout(()=>a("late"),Pt)});try{for(;;){let a=await Promise.race([o.token.then(_=>({token:_}),_=>({error:it(_)})),h]);if(a==="late")return!u&&N===null&&(N=o),{error:ee??"timeout"};if("token"in a)return ne=Math.max(0,Math.round((o.issuedAt??w())-o.at)),a;if(u||at.has(a.error)||d>=Dt||d>0&&await Promise.race([D(qt*d),h])==="late")return a;if(u)return{error:"aborted"};d+=1,o=re(e,n)}}finally{clearTimeout(m)}},"Ue"),T=null,yt=t(e=>se(e).some(n=>(n.checkType==="phone_otp"||n.checkType==="email_otp")&&n.state!=="passed"&&n.state!=="skipped"),"Lt"),xe=t(e=>T===null||w()-T>=e,"Be"),z=t(()=>xe(Ot),"oe"),vt=t(e=>{let n=e.attestation;return typeof n?.turnstileToken=="string"&&n.turnstileToken.length>0},"Dt"),Ie=new Map,Ee=t(async()=>{let e=await v(),n=e.challenge;if(n==null||e.simulation!==void 0)return;let i=await Te(n,Z(e.sessionId));if(!("token"in i))throw new I({status:400,code:"attestation_invalid",message:`browser check: ${i.error}`});return i.token},"Ge"),_t=t(async(e,n,i={})=>{let s=n;if("attestation"in s)try{let a=await K.submitCheck(e,n,i);return vt(s)&&(T=w()),a}catch(a){throw a instanceof I&&a.code==="attestation_invalid"&&(T=null),a}let o=(e==="phone_otp"||e==="email_otp")&&s.action!=="verify",d=i.idempotencyKey,m=d!==void 0?Ie.get(d):void 0;m===void 0&&(o||z())&&(m=await Ee(),d!==void 0&&m!==void 0&&Ie.set(d,m));let h=t((a,_)=>a!==void 0?{..._,browserCheckToken:a}:_,"w");try{let a=await K.submitCheck(e,n,h(m,i));return m!==void 0&&(T=w()),a}catch(a){if(!(a instanceof I)||a.code!=="attestation_invalid"||(T=null,m!==void 0))throw a;let _=await Ee(),x=d!==void 0?{...i,idempotencyKey:pe()}:i,C=await K.submitCheck(e,n,h(_,x));return _!==void 0&&(T=w()),C}},"Ut"),Re=t(async(e={})=>{if(q=void 0,e.always!==!0&&!z())return{};let n=await v(),i=n.challenge;if(i==null)return{};let s=await Te(i,Z(n.sessionId));if("token"in s)return{channel:"hosted_web",turnstileToken:s.token};if(q=s.error,n.simulation!==void 0)return{channel:"hosted_web"};throw new Ze(s.error)},"Ke"),gt=t(()=>q,"Bt"),bt=t(()=>({checks:Math.min(50,Me),...ne!==void 0?{challengeMs:Math.min(6e5,ne)}:{}}),"qt"),G=t(e=>{if(u)return;let n=y.reportCaptureIssue;if(n===void 0)return;let i=e.formFactor;try{i??(i=qe())}catch{}try{Promise.resolve(n.call(y,{...e,...i!==void 0?{formFactor:i}:{}})).catch(()=>{})}catch{}},"W"),g=null,U=null,Ne=new WeakMap,Pe=Promise.resolve(),F=0,kt=t(async()=>{let e=await v();for(let n=0;n<Ut&&!u&&!M(e)&&O(e)===void 0&&se(e).some(i=>i.state==="processing")&&(await D(Gt),!u);n+=1)e=await k();return e},"Gt"),wt=t(async(e,n,i)=>{let{capture:s}=e,o=t(()=>u,"p"),d=t(()=>e.alive&&e.attempt===i,"k"),m=t(a=>{d()&&s.setFlowState(a)},"C"),h=t(a=>{if(!o()&&(a.status==="unavailable"&&a.reasonCode!==void 0&&!je(a.reasonCode)&&G({check:"liveness",kind:"unavailable",phase:"upload",engineKind:a.reasonCode,attempt:Math.max(0,e.issues.value)}),Q(a),!!d())){if(a.status==="retry"&&dt==="auto"){s.handle.retry();return}s.setFlowState("done")}},"w");if(n.degraded==="NO_RECORDER"){let a=c?.sessionId??(await v().catch(()=>null))?.sessionId??"";h(E(a,"no_recorder"));return}m("uploading");try{if(await Ce(),o())return;let a=await v(),_;if(!M(a)&&P(a)!==null){await ge(!1),h(E(a.sessionId,"method_required"));return}if(!M(a)){if(O(a)?.checkType==="population_registry"){h(E(a.sessionId,ke?"nni_unbound":be?"network":"registry_unavailable"));return}if(await A(),o())return;_=c??a;let x=await Ye({...J,artifacts:n,getAttestation:Re,attestationError:gt,attestationFacts:bt,clipKeys:{get:t(()=>Ne.get(n)??null,"get"),set:t(C=>{Ne.set(n,C)},"set")},getView:t(()=>c??a,"getView"),refreshView:k,applySubmit:Y,onPhase:m,isCancelled:o,onKeyframePromoted:t(C=>{fe=C},"onKeyframePromoted")});if(o())return;if(x.kind==="unavailable"){x.reason==="attestation"&&(U={bound:e,artifacts:n});let C=E(a.sessionId,x.reason),De=x.reason==="attestation"?q:void 0;h(De!==void 0?{...C,attestationError:De}:C);return}if(x.kind==="resync"&&await k(),c!==null&&P(c)!==null){await ge(!1),h(E(a.sessionId,"method_required"));return}a=await kt()}h(le(a,{autoRetry:f,previous:_}))}catch{if(o())return;h(E(c?.sessionId??"","network"))}},"Kt"),Oe=t((e,n)=>{let i=e.attempt;F>0&&e.alive&&e.capture.setFlowState("uploading"),F+=1,Pe=Pe.then(()=>wt(e,n,i)).finally(()=>{F-=1,F===0&&R?.onChainIdle()}).catch(()=>{})},"We"),Le=t(e=>{g?.capture.handle.destroy(),g!==null&&(g.alive=!1);let n=nt(e,R?.captureInternals?.(e)??l.capture,()=>c?.capture?.liveness?.keyframe?.rank===!0,he,()=>c?.capture?.liveness?.screenRamp,{session:t(()=>W(c),"session"),onModeChange:t(o=>{V=o},"onModeChange")}),i={capture:n,alive:!0,attempt:0,issues:Be()};g=i,n.handle.on("error",o=>{G(Ke("liveness",o,i.issues.value))}),n.handle.on("state",o=>{if(i.issues.note(o),o==="starting"){i.attempt+=1,U?.bound===i&&(U=null),z()&&ie(c,{replaceFailed:!0});let d=c===null?void 0:O(c)?.checkType;(d==="liveness"||d==="face_match")&&A().catch(()=>{})}}),n.handle.on("captured",o=>{Promise.resolve().then(()=>Oe(i,o))});let s=n.handle;return{get state(){return s.state},get captureMode(){return s.captureMode},get facingMode(){return s.facingMode},on:t((o,d)=>s.on(o,d),"on"),start:t(async o=>{if(c===null&&await v().catch(()=>{}),!!i.alive)return s.start(o)},"start"),retry:t(()=>{let o=U;if(o!==null&&o.bound===i&&i.alive){U=null,Oe(i,o.artifacts);return}s.retry()},"retry"),switchCamera:t(()=>s.switchCamera(),"switchCamera"),canSwitchCaptureMode:t(()=>s.canSwitchCaptureMode(),"canSwitchCaptureMode"),setCaptureMode:t(o=>s.setCaptureMode(o),"setCaptureMode"),destroy:t(()=>{i.alive=!1,g===i&&(g=null),s.destroy()},"destroy")}},"$e"),At=t(async()=>{if(u)return null;try{let e=await v();return u?null:P(e)}catch{return null}},"jt"),Ct=t(async()=>{if(u)return"self";try{let e=await v();if(u)return"self";let n=W(e);return n==="choice"?$()??n:n}catch{return"self"}},"Yt"),Mt=t(async()=>{if(u)return!1;try{let e=await v();return u||M(e)||oe()?!1:ue(e,O(e))==="phone"||ue(e,j(e,"liveness"))==="phone"}catch{return!1}},"Wt"),St=t(async()=>{if(u)return!1;try{let e=await v();return!u&&e.returning===!0}catch{return!1}},"$t"),Tt=t(async e=>{let n=(await v()).plan?.choice,i=n?.options.find(o=>Ve[o.service]===e);if(!i)throw new RangeError(`method ${String(e)} is not offered`);let s=await y.choose(n.nodeId,i.id);u||b(s)},"Qt"),ae=null,xt=t(()=>(ae??(ae=import("./plan-runner-KX7KUS3M-CECACJOR.js").then(e=>{let n=e.createPlanRunner({runtime:J,currentView:t(()=>c,"currentView"),cameraMode:he,captureModeSwitch:{pick:$,choose:t(i=>{V=i},"choose")},ensureView:v,refreshView:k,ensureConsent:t(()=>A(),"ensureConsent"),liveness:Le,stopLiveness:t(()=>{g!==null&&(g.alive=!1,g.capture.handle.destroy(),g=null)},"stopLiveness"),chainBusy:t(()=>F>0,"chainBusy"),destroyed:t(()=>u,"destroyed"),sleep:D,isMobile:oe,now:l.now??Date.now,keptFaceKey:t(()=>fe,"keptFaceKey"),setView:b,baseCapture:l.capture,emitStep:t(i=>{u||S.emit("step",i)},"emitStep"),emitResult:ft,reportCaptureIssue:G,documentInternals:l.document,portraitInternals:l.portrait,livePhotoInternals:l.livePhoto,uploadInternals:l.upload,pageCameraInternals:l.pageCamera});return R=n,n})),ae),"Zt");return{consent:t(()=>A(),"consent"),startRegistry:Ce,methodChoice:At,selectMethod:Tt,reportCameraUnavailable:t(async e=>{await A();let n=y.reportCameraUnavailable;if(n===void 0)throw new TypeError("this client cannot report a missing camera");let i=await n.call(y,e).catch(s=>{if(s instanceof I&&s.code==="check_out_of_order")return y.getSession();throw s});u||b(i)},"reportCameraUnavailable"),reportCaptureIssue:G,testerGate:t(async e=>{let n=y.testerGate;if(n===void 0)throw new TypeError("this client cannot run the tester gate");let i=e.clip,s=Ue(e.clipMime??"");if(i===void 0||!ze.includes(s))throw new TypeError("the capture has no clip");await A();let o=await He(y,"clip",s,i.size,{engine:e.engine,durationMs:e.clipMs});await y.uploadToSpaces(o.uploadUrl,i,s);let{key:d}=await y.completeMedia(o.key),m=await Re({always:!0}),h=await n.call(y,{clipKey:d,attestation:m,captureChannel:e.captureChannel,capture:{...Je(e),attestationError:q}}),{bound:a,..._}=h;return u||(_.plan!==void 0?b(_):await k()),{bound:a===!0}},"testerGate"),mobileRequired:Mt,captureMode:Ct,chooseCaptureMode:t(e=>{V=e},"chooseCaptureMode"),get captureChoice(){return $()},returning:St,liveness:Le,run:t(async()=>{if(u)throw new Error("verification destroyed");return(await xt()).run()},"run"),currentStep:t(()=>R?.current()??null,"currentStep"),voiceClips:t(async()=>{if(u)return null;try{let e=await v();return u?null:e.voice??null}catch{return null}},"voiceClips"),on:t((e,n)=>S.on(e,n),"on"),destroy:t(()=>{u=!0,me.abort(),R?.destroy(),g!==null&&(g.alive=!1,g.capture.handle.destroy(),g=null),S.clear()},"destroy")}}t(Bt,"dn");var st=["AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","XK","YE","YT","ZA","ZM","ZW"],lt=["carte_identite","passport","residence_permit","drivers_license"],Vt=["carte_identite","passport","residence_permit"];function ce(r,l){let p=r.byIssuer?.[l]??r.default;return lt.filter(f=>p==="*"?Vt.includes(f):p.includes(f))}t(ce,"fn");function ut(r,l=st){return[...new Set([...l,...Object.keys(r.byIssuer??{})])].filter(p=>ce(r,p).length>0).sort()}t(ut,"Ro");var L={fullNameMin:2,fullName:200,email:254,occupation:120,shortText:120,longText:1e3,addressLine:120,addressLines:4,city:80,postcode:16,number:1e12,dateMin:"1900-01-01",dateMax:"2100-12-31"};var yn={full_name:L.fullName,occupation:L.occupation,email:L.email,short_text:L.shortText,long_text:L.longText},ct=Object.freeze({nni_invalid:"id_number_invalid",nni_not_found:"registry_record_not_found",nni_recheck:"id_number_recheck",document_nni_mismatch:"document_id_number_mismatch",nni_locked:"id_number_locked",nni_unbound:"id_number_unbound",missing_nni:"missing_id_number",registry_needs_nni_source:"registry_needs_id_number_source"}),vn=new Map(Object.entries(ct)),_n=new Map(Object.entries(ct).map(([r,l])=>[l,r]));var gn=10*1024*1024;function ir(r){if(r==="permission")return"denied";if(r==="notfound"||r==="insecure"||r==="unsupported")return"no_camera"}t(ir,"ce");var $t=/^[A-Z0-9][A-Z0-9 -]{0,39}$/,Ht=Object.freeze({normalize:t(r=>r.trim().toUpperCase().replace(/\s+/g," "),"normalize"),check:t(r=>$t.test(r),"check"),registrySources:Object.freeze([]),describe:"number must be 1 to 40 letters, digits, spaces or hyphens"}),zt=/^[A-Z0-9]{4,20}$/,de=t(r=>r.trim().toUpperCase().replace(/[\s-]+/g,""),"m"),Zt=Object.freeze({normalize:de,check:t(r=>zt.test(de(r)),"check"),registrySources:Object.freeze([]),describe:"number must be 4 to 20 letters or digits"});function Wt(r){return typeof r=="string"&&/^\d{10}$/.test(r)&&Number(r)%97===1}t(Wt,"fe");var Yt={trim:t(r=>r.trim(),"trim"),upper_single_space:t(r=>r.trim().toUpperCase().replace(/\s+/g," "),"upper_single_space"),upper_no_space_or_hyphen:de},Jt={mr_nni_mod97:t(r=>Wt(r),"mr_nni_mod97")};function Qt(r){let l=new RegExp(r.pattern,"u"),p=r.check===null?void 0:Jt[r.check];return Object.freeze({normalize:Yt[r.normalize],check:t(f=>l.test(f.trim())&&(p===void 0||p(f)),"check"),registrySources:Object.freeze([...r.registrySources]),describe:r.describe})}t(Qt,"Pe");var Xt=Object.freeze(Object.fromEntries(Object.entries(et).map(([r,l])=>[r,Qt(l)])));function en(r,l){return Xt[`${r.toUpperCase()}:${l}`]??(l==="drivers_license"?Zt:Ht)}t(en,"C");var ar=Object.freeze({MRT:"MR"});function or(r){return en("MR","national_id").check(r)}t(or,"Me");function tn(r){let l="";for(let p of r){let f=p.codePointAt(0)??0;f>=1632&&f<=1641?l+=String(f-1632):f>=1776&&f<=1785?l+=String(f-1776):p!==" "&&p!=="-"&&p!==" "&&(l+=p)}return l}t(tn,"H");function sr(r){return tn(r)}t(sr,"He");var lr=ce,ur=ut;var nn=t(()=>import("./create-document-capture-XWNBUC55-FZGHPB6L.js"),"E");function rn(){nn().then(r=>r.warmDocumentCapture()).catch(()=>{})}t(rn,"D");function cr(){rn()}t(cr,"et");var an=t(()=>import("./create-portrait-capture-5VGYZUOK-KTCFCHTN.js"),"O");function on(){an().then(r=>r.warmPortraitCapture()).catch(()=>{})}t(on,"I");function dr(){on()}t(dr,"at");export{Kt as a,ir as b,or as c,sr as d,lr as e,ur as f,cr as g,dr as h};
@@ -1 +0,0 @@
1
- import{a as tt,b as $t,c as te,d as dt,e as ee}from"./chunk-JI5WT66H.js";import{a as Ut,b as Kt,e as Yt}from"./chunk-2FETDQV5.js";import{b as Vt,c as Zt}from"./chunk-XSGZY4JI.js";import{b as Jt}from"./chunk-L22GFJQV.js";import{d as Wt,e as Ht,f as Qt}from"./chunk-TXDGBMD4.js";import{a as ct,b as ut,c as Y,d as Xt}from"./chunk-P7K7ELYZ.js";import{g as Nt,i as qt,j as Gt,k as jt,l as Bt}from"./chunk-JS2IXPNL.js";import{a as n}from"./chunk-4FHWXBOB.js";var et=Object.freeze({sensing:{key:"sensing",reticle:"searching",minDurationMs:900},too_far:{key:"too_far",reticle:"coaching",minDurationMs:1400},too_close:{key:"too_close",reticle:"coaching",minDurationMs:1400},edge_clipped:{key:"edge_clipped",reticle:"coaching",minDurationMs:1400},wrong_shape:{key:"wrong_shape",reticle:"coaching",minDurationMs:1400},tilted:{key:"tilted",reticle:"coaching",minDurationMs:1400},too_dark:{key:"too_dark",reticle:"coaching",minDurationMs:1400},too_bright:{key:"too_bright",reticle:"coaching",minDurationMs:1400},blurry:{key:"blurry",reticle:"coaching",minDurationMs:1400},focus_far:{key:"focus_far",reticle:"coaching",minDurationMs:1600},glare:{key:"glare",reticle:"coaching",minDurationMs:1400},hold_still:{key:"hold_still",reticle:"locking",minDurationMs:900},processing:{key:"processing",reticle:"processing",minDurationMs:800},side_captured:{key:"side_captured",reticle:"flip",minDurationMs:2600},captured:{key:"captured",reticle:"done",minDurationMs:800}});function Ae(s){return s.framing==="no_document"?"sensing":s.framing==="too_far"?"too_far":s.framing==="too_close"?"too_close":s.framing==="edge_clipped"?"edge_clipped":s.framing==="wrong_shape"?"wrong_shape":s.framing==="tilted"?"tilted":s.lighting==="too_dark"?"too_dark":s.lighting==="too_bright"?"too_bright":s.glare==="glare"?"glare":s.blur==="blurry"?"blurry":"hold_still"}n(Ae,"ne");var G,ze=(G=class{constructor(t=2600,e=.35){this.windowMs=t,this.decayPerSecond=e,this.votes=[],this.current=et.sensing,this.currentSinceMs=null}reset(){this.votes=[],this.current=et.sensing,this.currentSinceMs=null}force(t,e){return this.votes=[],this.current=et[t],this.currentSinceMs=e,this.current}tick(t,e){if(this.currentSinceMs===null&&(this.currentSinceMs=e),this.votes.push({key:t,atMs:e}),this.votes=this.votes.filter(o=>e-o.atMs<=this.windowMs),e-this.currentSinceMs<this.current.minDurationMs)return this.current;let i=new Map;for(let o of this.votes){let l=(e-o.atMs)/1e3,r=this.decayPerSecond**l;i.set(o.key,(i.get(o.key)??0)+r)}let a=this.current.key,h=-1;for(let[o,l]of i)l>h&&(h=l,a=o);return a!==this.current.key&&(this.current=et[a],this.currentSinceMs=e),this.current}},n(G,"ot"),G),Ce=Object.freeze({MAX_AREA_FRAC:.92,TILT_MAX_SIDE_RATIO:1.3,GLARE_MAX_SPECULAR_FRAC:.025});function Ie(s){let{data:t,width:e,height:i}=s,a=e*i;if(a===0)return 0;let h=0;for(let o=0;o<a;o++){let l=o*4;.299*(t[l]??0)+.587*(t[l+1]??0)+.114*(t[l+2]??0)>=252&&h++}return h/a}n(Ie,"re");function Le(s){let t=n((r,c)=>Math.hypot(c.x-r.x,c.y-r.y),"t"),e=t(s.topLeft,s.topRight),i=t(s.bottomLeft,s.bottomRight),a=t(s.topLeft,s.bottomLeft),h=t(s.topRight,s.bottomRight),o=Math.max(e,i)/Math.max(1e-6,Math.min(e,i)),l=Math.max(a,h)/Math.max(1e-6,Math.min(a,h));return Math.max(o,l)}n(Le,"je");function Oe(s){let t={...$t,...s.thresholds},e=Ce,{quad:i,frameWidth:a,frameHeight:h,measures:o}=s,l=s.format==="ID-3",r="ok";if(i===null)r="no_document";else if(l){let d=dt(i),m=a>0?d.width/a:0,g=d.height>0?d.width/d.height:0;m<t.ID3_BAND_MIN_WIDTH_FRAC?r="too_far":ie(i,a,h,t.EDGE_CLIP_MARGIN_PX)?r="edge_clipped":(g<t.ID3_BAND_ASPECT_MIN||g>t.ID3_BAND_ASPECT_MAX)&&(r="wrong_shape")}else{let d=te(i,a,h),m=dt(i),g=Math.max(m.width,m.height)/Math.max(1e-6,Math.min(m.width,m.height));d<t.MIN_AREA_FRAC?r="too_far":d>e.MAX_AREA_FRAC?r="too_close":ie(i,a,h,t.EDGE_CLIP_MARGIN_PX)?r="edge_clipped":Zt(s.format,g)?Le(i)>e.TILT_MAX_SIDE_RATIO&&(r="tilted"):r="wrong_shape"}let c=o.exposure>=t.GUIDE_EXPOSURE?"ok":o.meanLuma<(ct[0]+ct[1])/2?"too_dark":"too_bright",u=o.sharpness>=t.GUIDE_SHARPNESS?"ok":"blurry",f=o.specularFraction>=e.GLARE_MAX_SPECULAR_FRAC?"glare":"ok";return{framing:r,lighting:c,blur:u,glare:f,acceptable:r==="ok"&&c==="ok"&&u==="ok"&&f==="ok"}}n(Oe,"ae");function ie(s,t,e,i){return[s.topLeft,s.topRight,s.bottomRight,s.bottomLeft].some(a=>a.x<=i||a.y<=i||a.x>=t-i||a.y>=e-i)}n(ie,"se");var Ee=Object.freeze({width:1920,height:1080}),Pe=Object.freeze({width:3840,height:2160}),se=4096,We=2560,Ne=640,it=.15,V=Object.freeze({side:.2,above:.9,below:.3});function C(s){let t=[s.topLeft.x,s.topRight.x,s.bottomRight.x,s.bottomLeft.x],e=[s.topLeft.y,s.topRight.y,s.bottomRight.y,s.bottomLeft.y],i=Math.min(...t),a=Math.min(...e);return{x:i,y:a,width:Math.max(...t)-i,height:Math.max(...e)-a}}n(C,"E");function me(s,t){let e=Math.max(0,Math.floor(s.x)),i=Math.max(0,Math.floor(s.y)),a=Math.min(t.width,Math.ceil(s.x+s.width)),h=Math.min(t.height,Math.ceil(s.y+s.height));return a-e<16||h-i<16?null:{x:e,y:i,width:a-e,height:h-i}}n(me,"he");function qe(s,t,e){if(s===null||t.width<=0||t.height<=0)return null;let i=C(s);if(i.width<=0||i.height<=0)return null;let a=e==="ID-3"?{x:i.x-i.width*V.side,y:i.y-i.width*V.above,width:i.width*(1+2*V.side),height:i.height+i.width*(V.above+V.below)}:{x:i.x-i.width*it,y:i.y-i.height*it,width:i.width*(1+2*it),height:i.height*(1+2*it)};return me(a,t)}n(qe,"Je");function ge(s,t,e){let i=Math.max(s,t);return i>0?Math.min(1,e/i):1}n(ge,"ft");function pe(s,t,e,i,a=We){let h=t.width>0?e.width/t.width:1,o=t.height>0?e.height/t.height:1,l=s===null?null:{topLeft:{x:s.topLeft.x*h,y:s.topLeft.y*o},topRight:{x:s.topRight.x*h,y:s.topRight.y*o},bottomRight:{x:s.bottomRight.x*h,y:s.bottomRight.y*o},bottomLeft:{x:s.bottomLeft.x*h,y:s.bottomLeft.y*o}},r=qe(l,e,i)??{x:0,y:0,width:e.width,height:e.height},c=ge(r.width,r.height,a),u=Math.max(1,Math.round(r.width*c)),f=Math.max(1,Math.round(r.height*c)),d=null;if(l!==null){let m=C(l);d=me({x:(m.x-r.x)*c,y:(m.y-r.y)*c,width:m.width*c,height:m.height*c},{width:u,height:f})}return{crop:r,width:u,height:f,docRegion:d}}n(pe,"pt");function Ge(s,t,e,i=Pe){if(e==="LOW")return null;let a=s?.width?.max,h=s?.height?.max;if(typeof a!="number"||typeof h!="number"||a<=0||h<=0)return null;let o=Math.max(a,h),l=Math.min(a,h),r=Math.min(o,Math.max(i.width,i.height)),c=Math.min(l,Math.min(i.width,i.height));return r<=Math.max(t.width,t.height)?null:{width:{ideal:r},height:{ideal:c}}}n(Ge,"de");function je(s){let t={},e=s?.imageWidth,i=s?.imageHeight;if(typeof e?.max=="number"&&e.max>0){let a=typeof i?.max=="number"&&i.max>0?e.max/i.max:1.3333333333333333,h=a>=1?se:se*a,o=Math.min(e.max,Math.floor(h)),l=typeof e.step=="number"&&e.step>0?e.step:1,r=typeof e.min=="number"?e.min:0;o=Math.max(r,r+Math.floor((o-r)/l)*l),t.imageWidth=o}return s?.fillLightMode?.includes("off")===!0&&(t.fillLightMode="off"),t}n(je,"me");function Be(s,t){if(s.width<=0||s.height<=0||t.width<=0||t.height<=0)return!1;let e=s.width>s.height,i=t.width>t.height;return e!==i&&s.width!==s.height&&t.width!==t.height?!1:Math.max(s.width,s.height)>=1.2*Math.max(t.width,t.height)}n(Be,"fe");function He(s,t,e,i){if(e===null)return!1;let a=C(s),h=C(e);if(t.width<=0||i.width<=0)return!1;let o=a.width/t.width,l=h.width/i.width;return l>0&&o>=.6*l&&o<=1.25*l}n(He,"pe");var ae=3500,Qe=.92;function Me(){let s=globalThis.ImageCapture;return typeof s=="function"?s:null}n(Me,"ye");function Xe(s){return/AppleWebKit\//.test(s)&&!/(Chrome|Chromium|Edg|OPR)\//.test(s)}n(Xe,"$e");function Ue(s,t=typeof navigator>"u"?"":navigator.userAgent){return Me()!==null&&!Xe(t)&&s!=null&&s.kind==="video"&&s.readyState==="live"}n(Ue,"Me");function he(s,t){return new Promise((e,i)=>{let a=setTimeout(()=>i(new Error("takePhoto timed out")),t);s.then(h=>{clearTimeout(a),e(h)},h=>{clearTimeout(a),i(h)})})}n(he,"be");function ft(s,t){let e=document.createElement("canvas");return e.width=s,e.height=t,e}n(ft,"gt");function Ke(s,t){return new Promise((e,i)=>{s.toBlob(a=>a?e(a):i(new Error("toBlob failed")),"image/jpeg",t)})}n(Ke,"ti");async function ye(s,t,e,i,a){let h=ft(e,i),o=ft(1,1);try{let l=h.getContext("2d");if(l===null)throw new Error("2d context unavailable");l.imageSmoothingQuality="high",l.drawImage(s,t.x,t.y,t.width,t.height,0,0,e,i);let r=await Ke(h,Qe),c=a===null?null:Ut({topLeft:{x:a.x,y:a.y},topRight:{x:a.x+a.width,y:a.y},bottomRight:{x:a.x+a.width,y:a.y+a.height},bottomLeft:{x:a.x,y:a.y+a.height}},{width:e,height:i},{width:e,height:i}),u=Kt(h,c),f=ge(e,i,Ne);return o.width=Math.max(1,Math.round(e*f)),o.height=Math.max(1,Math.round(i*f)),o.getContext("2d")?.drawImage(h,0,0,o.width,o.height),{blob:r,previewDataUrl:o.toDataURL("image/jpeg",.85),sharpness:u}}finally{h.width=0,h.height=0,o.width=0,o.height=0}}n(ye,"ke");function Ye(s,t){let e=Math.min(1,t/s.width),i=ft(Math.max(1,Math.round(s.width*e)),Math.max(1,Math.round(s.height*e)));try{let a=i.getContext("2d",{willReadFrequently:!0});return a===null?null:(a.imageSmoothingQuality="high",a.drawImage(s,0,0,i.width,i.height),a.getImageData(0,0,i.width,i.height))}finally{i.width=0,i.height=0}}n(Ye,"ei");async function Ve(s,t,e,i){let a={width:Math.max(1,s.videoWidth),height:Math.max(1,s.videoHeight)},h=pe(t,e,a,i);return{...await ye(s,h.crop,h.width,h.height,h.docRegion),docRegion:h.docRegion,source:"video",width:h.width,height:h.height}}n(Ve,"De");async function Ze(s,t,e,i,a){let h=Me();if(h===null)return null;let o=null;try{let l=new h(a.track),r=await he(l.getPhotoCapabilities?.()??Promise.resolve({}),ae).catch(()=>({})),c=await he(l.takePhoto(je(r)),ae);o=await createImageBitmap(c);let u={width:s.videoWidth,height:s.videoHeight};if(!Be(o,u))return null;let f=Ye(o,a.detectWidth),d=null;f!==null&&t!==null&&(d=await a.detect(f).catch(()=>null));let m=f??{width:o.width,height:o.height};d!==null&&!He(d,m,t,e)&&(d=null);let g=pe(d,m,o,i);return{...await ye(o,g.crop,g.width,g.height,g.docRegion),docRegion:g.docRegion,source:"photo",width:g.width,height:g.height}}catch{return null}finally{o?.close()}}n(Ze,"xe");var yt=Object.freeze({width:3840,height:2160,lensSelection:!0,continuousFocus:!0,refocusBeforePhotoMs:350,zoomMax:2,zoomNoFocusInfo:1.5,zoomMinSourcePx:2160,fillDistanceM:Object.freeze({id1:.11,id3:.15}),focusMarginFrac:.2,stillSharpnessMin:.16,stillRefusalsMax:2,focusFarFillFrac:.45,noDocFarHintMs:1500,zoomFallbackMs:8e3}),R=n((s,t,e)=>typeof s=="number"&&Number.isFinite(s)&&s>=t&&s<=e?s:void 0,"S");function Ri(s){let t=yt,e=s!==null&&typeof s=="object"?s:{},i=e.fillDistanceM!==null&&typeof e.fillDistanceM=="object"?e.fillDistanceM:{},a=n((h,o)=>typeof h=="boolean"?h:o,"n");return{width:R(e.width,640,7680)??t.width,height:R(e.height,480,4320)??t.height,lensSelection:a(e.lensSelection,t.lensSelection),continuousFocus:a(e.continuousFocus,t.continuousFocus),refocusBeforePhotoMs:R(e.refocusBeforePhotoMs,0,2e3)??t.refocusBeforePhotoMs,zoomMax:R(e.zoomMax,1,5)??t.zoomMax,zoomNoFocusInfo:R(e.zoomNoFocusInfo,1,5)??t.zoomNoFocusInfo,zoomMinSourcePx:R(e.zoomMinSourcePx,0,8e3)??t.zoomMinSourcePx,fillDistanceM:{id1:R(i.id1,.03,1)??t.fillDistanceM.id1,id3:R(i.id3,.03,1)??t.fillDistanceM.id3},focusMarginFrac:R(e.focusMarginFrac,0,2)??t.focusMarginFrac,stillSharpnessMin:R(e.stillSharpnessMin,0,10)??t.stillSharpnessMin,stillRefusalsMax:R(e.stillRefusalsMax,0,10)??t.stillRefusalsMax,focusFarFillFrac:R(e.focusFarFillFrac,0,1)??t.focusFarFillFrac,noDocFarHintMs:R(e.noDocFarHintMs,0,6e4)??t.noDocFarHintMs,zoomFallbackMs:R(e.zoomFallbackMs,0,12e4)??t.zoomFallbackMs}}n(Ri,"Si");var mt="sekyro.doc.camera";function Je(){try{let s=globalThis.localStorage?.getItem(mt);return typeof s=="string"&&s!==""?s:null}catch{return null}}n(Je,"ii");function oe(s){try{s===null?globalThis.localStorage?.removeItem(mt):globalThis.localStorage?.setItem(mt,s)}catch{}}n(oe,"we");var gt=n((s,t)=>Array.isArray(s?.focusMode)&&s.focusMode.includes(t),"rt");function re(s,t,e){if(!gt(s,"single-shot"))return null;let i=n(a=>Math.min(1,Math.max(0,Number.isFinite(a)?a:.5)),"o");return{focusMode:"single-shot",pointsOfInterest:[{x:i(t),y:i(e)}]}}n(re,"Mt");function $e(s,t,e,i=yt){let a=s?.zoom?.min,h=s?.zoom?.max;if(typeof h!="number"||h<=1)return 1;let o=e==="ID-3"?i.fillDistanceM.id3:i.fillDistanceM.id1,l=s?.focusDistance?.min,r;if(typeof l=="number"&&l>0&&l<1){if(r=l*(1+i.focusMarginFrac)/o,r<=1.05)return 1}else{if(Math.min(t.width,t.height)<i.zoomMinSourcePx)return 1;r=i.zoomNoFocusInfo}let c=Math.min(r,i.zoomMax,h);typeof a=="number"&&(c=Math.max(c,a));let u=s?.zoom?.step;return typeof u=="number"&&u>0&&(c=Math.round(c/u)*u),c>1.01?Number(c.toFixed(2)):1}n($e,"Se");function pt(s){try{return s.getVideoTracks?.()[0]}catch{return}}n(pt,"yt");function le(s){if(s!==null)for(let t of s.getTracks())t.stop()}n(le,"ve");function ti(s){try{let t=pt(s)?.getCapabilities?.();return!Array.isArray(t?.focusMode)||t.focusMode.includes("continuous")}catch{return!0}}n(ti,"oi");async function ei(s){let t=n(h=>({audio:!1,video:{...h,width:{ideal:s.base.width},height:{ideal:s.base.height}}}),"t"),e=n(h=>s.getUserMedia(t({deviceId:{exact:h}})),"e"),i=n(()=>s.getUserMedia(t({facingMode:{ideal:"environment"}})),"o");if(s.lensSelection){let h=Je();if(h!==null)try{return{stream:await e(h),lens:"stored"}}catch{oe(null)}}let a=await i();if(!s.lensSelection||s.enumerateDevices===void 0)return{stream:a,lens:"default"};try{let h=Bt(await s.enumerateDevices()).slice(0,3);if(h.length===0)return{stream:a,lens:"default"};let o=null;for(let l of h){let r=a!==null?pt(a)?.getSettings?.().deviceId:void 0;if(a===null||r!==l){le(a),a=null;try{a=await e(l)}catch{continue}}if(o??(o=l),ti(a))return oe(l),{stream:a,lens:"selected"}}if(a!==null&&o!==null&&pt(a)?.getSettings?.().deviceId===o)return{stream:a,lens:"selected"};if(le(a),a=null,o!==null)try{return{stream:await e(o),lens:"selected"}}catch{}return{stream:await i(),lens:"default"}}catch{return{stream:a??await i(),lens:"default"}}}n(ei,"Te");var ht=Object.freeze({brightness:0,glare:0,cardGlare:0,sharpness:0,fill:0,shape:0,content:0,offsetX:0,offsetY:0,edgeConfidence:0,box:null}),A=n(s=>Math.min(1,Math.max(0,s)),"L");function ii(s,t,e,i=.06){let a=Math.max(s.width/e,s.height),h=a*e,o=(s.width-h)/2,l=(s.height-a)/2,r=A((t.x-t.width*i-o)/h),c=A((t.y-t.height*i-l)/a),u=A((t.x+t.width*(1+i)-o)/h),f=A((t.y+t.height*(1+i)-l)/a);return{x:r,y:c,width:u-r,height:f-c}}n(ii,"Re");function si(s,t,e={}){let i=e.edgePeakFrac??0,{width:a,height:h,data:o}=s;if(a<=0||h<=0)return ht;let l=A(t.x),r=A(t.y),c={x:l,y:r,width:Math.max(0,A(t.x+t.width)-l),height:Math.max(0,A(t.y+t.height)-r)};if(c.width<=0||c.height<=0)return ht;let u=c.x*a,f=c.y*h,d=(c.x+c.width)*a,m=(c.y+c.height)*h,g=(d-u)*.15,b=(m-f)*.15,w=n((p,M,_)=>Math.min(_,Math.max(M,p)),"y"),k=w(Math.floor(u-g),0,a-1),S=w(Math.floor(f-b),0,h-1),D=w(Math.ceil(d+g),k+1,a),I=w(Math.ceil(m+b),S+1,h),F=Math.max(1,Math.ceil(Math.max(D-k,I-S)/320)),y=Math.floor((D-k+F-1)/F),x=Math.floor((I-S+F-1)/F);if(y<3||x<3)return ht;let v=new Int32Array(y*x);for(let p=0;p<x;p++){let M=S+p*F;for(let _=0;_<y;_++){let T=(M*a+k+_*F)*4;v[p*y+_]=(o[T]??0)*77+(o[T+1]??0)*150+(o[T+2]??0)*29>>8}}let L=n((p,M)=>(p-M-.5)/F,"C"),B=L(u,k),rt=L(d,k),lt=L(f,S),nt=L(m,S),wt=(d-u)/F,bt=(m-f)/F,kt=w(Math.ceil(B),0,y-1),we=w(Math.floor(rt),kt,y-1),xt=w(Math.ceil(lt),0,x-1),be=w(Math.floor(nt),xt,x-1),vt=0,St=0,H=0,Ft=0,Rt=0,Q=0;for(let p=xt;p<=be;p++)for(let M=kt;M<=we;M++){let _=v[p*y+M];if(vt+=_,_>=248&&St++,H++,M>=1&&M<y-1&&p>=1&&p<x-1){let T=v[p*y+M-1]+v[p*y+M+1]+v[(p-1)*y+M]+v[(p+1)*y+M]-4*_;Ft+=T,Rt+=T*T,Q++}}let ke=H>0?vt/H:0,_t=H>0?St/H:0,Dt=Q>0?Ft/Q:0,xe=Q>0?Math.max(0,Rt/Q-Dt*Dt):0,X=new Float64Array(y),U=new Float64Array(x);for(let p=0;p<x;p++)for(let M=1;M<y-1;M++)X[M]=X[M]+Math.abs(v[p*y+M+1]-v[p*y+M-1]);for(let p=1;p<x-1;p++)for(let M=0;M<y;M++)U[p]=U[p]+Math.abs(v[(p+1)*y+M]-v[(p-1)*y+M]);let O=st(X,!0,B,i),E=st(X,!1,rt,i),P=st(U,!0,lt,i),W=st(U,!1,nt,i),Tt=(E.position-O.position)/wt,At=(W.position-P.position)/bt,ve=At>0?Tt/At:0,Se=((O.position+E.position)/2-(B+rt)/2)/wt,Fe=((P.position+W.position)/2-(lt+nt)/2)/bt,zt=ne(X),Ct=ne(U),Re=zt<=0||Ct<=0?0:Math.min(Math.min(O.value,E.value)/zt,Math.min(P.value,W.value)/Ct),J=n((p,M)=>M+(p+.5)*F,"$"),It=_t,Lt=0;{let p=(E.position-O.position)*.06,M=(W.position-P.position)*.06,_=w(Math.ceil(O.position+p),0,y-1),T=w(Math.floor(E.position-p),0,y-1),_e=w(Math.ceil(P.position+M),0,x-1),Ot=w(Math.floor(W.position-M),0,x-1),Et=0,$=0,Pt=0;for(let N=_e;N<=Ot;N++)for(let q=_;q<=T;q++){$++;let K=v[N*y+q];K>=248&&Et++;let De=q+2<=T?v[N*y+q+2]:K,Te=N+2<=Ot?v[(N+2)*y+q]:K;(Math.abs(De-K)>=24||Math.abs(Te-K)>=24)&&Pt++}$>=16&&(It=Et/$,Lt=Pt/$)}return{brightness:ke,glare:_t,cardGlare:It,sharpness:xe,fill:Tt,shape:ve,content:Lt,offsetX:Se,offsetY:Fe,edgeConfidence:Re,box:{left:J(O.position,k),right:J(E.position,k),top:J(P.position,S),bottom:J(W.position,S)}}}n(si,"Fe");function st(s,t,e,i){let a=s.length,h=Math.max(1,Math.floor(a*.45)),o=t?1:Math.max(1,a-1-h),l=t?Math.min(a-2,h):a-2,r=o;for(let m=o;m<=l;m++)s[m]>s[r]&&(r=m);if(i>0&&i<1){let m=s[r]*i,g=r,b=Math.abs(r-e);for(let w=o;w<=l;w++){let k=s[w];if(k<m||k<(s[w-1]??0)||k<(s[w+1]??0))continue;let S=Math.abs(w-e);S<b&&(g=w,b=S)}r=g}let c=r>0?s[r-1]:0,u=s[r],f=r<a-1?s[r+1]:0,d=c+u+f;return{position:d>0?r+(f-c)/d:r,value:u}}n(st,"at");function ne(s){if(s.length<3)return 0;let t=0;for(let e=1;e<s.length-1;e++)t+=s[e];return t/(s.length-2)}n(ne,"_e");function ai(s){let t=s.box;return t===null||t.right-t.left<4||t.bottom-t.top<4?null:{topLeft:{x:t.left,y:t.top},topRight:{x:t.right,y:t.top},bottomRight:{x:t.right,y:t.bottom},bottomLeft:{x:t.left,y:t.bottom}}}n(ai,"Ce");var ot=Object.freeze({fillMin:.82,fillMax:1.06,offsetMax:.06,glareMax:.025,sharpnessMin:180,edgeConfidenceMin:1.6,darkBrightness:70,lockMs:450,steadyMs:900,steadyFillMin:.45,steadyFillMax:1.3,steadyFillDelta:.06,steadyOffsetDelta:.04,steadyRefMs:100,edgePeakFrac:.4,shapeTolerance:.2,contentMin:.1});function _i(s){let t=s!==null&&typeof s=="object"?s:{},e={...ot};for(let i of Object.keys(ot)){let a=t[i];typeof a=="number"&&Number.isFinite(a)&&a>=0&&a<=1e6&&(e[i]=a)}return e}n(_i,"Ai");var j,hi=(j=class{constructor(t=ot){this.t=t,this.goodSince=null,this.steadySince=null,this.last=null}reset(){this.goodSince=null,this.steadySince=null,this.last=null}tick(t,e){let i=this.t,a=i.shapeTolerance<=0||Math.abs(t.shape-1)<=i.shapeTolerance,h=t.edgeConfidence>=i.edgeConfidenceMin&&a&&t.content>=i.contentMin,o=t.fill>=i.fillMin&&t.fill<=i.fillMax,l=Math.abs(t.offsetX)<=i.offsetMax&&Math.abs(t.offsetY)<=i.offsetMax,r=t.cardGlare<=i.glareMax,c=t.sharpness>=i.sharpnessMin,u=this.last;this.last={fill:t.fill,offsetX:t.offsetX,offsetY:t.offsetY,at:e};let f=u!==null&&i.steadyRefMs>0?Math.min(3,Math.max(1,(e-u.at)/i.steadyRefMs)):1,d=h&&r&&c&&t.fill>=i.steadyFillMin&&t.fill<=i.steadyFillMax&&u!==null&&Math.abs(t.fill-u.fill)<=i.steadyFillDelta*f&&Math.abs(t.offsetX-u.offsetX)<=i.steadyOffsetDelta*f&&Math.abs(t.offsetY-u.offsetY)<=i.steadyOffsetDelta*f,m=h&&o&&l&&r&&c,g;if(h?r?t.fill<i.fillMin?g="too_small":t.fill>i.fillMax?g="too_big":c?l?g="locking":g="off_center":g="blurry":g="glare":g="no_card",m){if(d&&(this.steadySince??(this.steadySince=e)),this.goodSince??(this.goodSince=e),e-this.goodSince>=i.lockMs)return{detected:h,ready:!0,via:"good",blocker:"locking"};let b=this.steadySince!==null&&e-this.steadySince>=i.steadyMs;return{detected:h,ready:b,via:b?"steady":null,blocker:"locking"}}if(this.goodSince=null,d){this.steadySince??(this.steadySince=e);let b=e-this.steadySince>=i.steadyMs;return{detected:h,ready:b,via:b?"steady":null,blocker:b?"locking":"steadying"}}return this.steadySince=null,{detected:h,ready:!1,via:null,blocker:g}}},n(j,"ct"),j),Z=null;async function oi(s){return Z===null&&(Z=(await import("./detector-scanic-S4PB2RNW-3KSM3MW5.js")).detectQuad),Z(s)}n(oi,"ni");async function ri(s){let t=Jt(s);return t===null?null:{topLeft:{x:t.x,y:t.y},topRight:{x:t.x+t.width,y:t.y},bottomRight:{x:t.x+t.width,y:t.y+t.height},bottomLeft:{x:t.x,y:t.y+t.height}}}n(ri,"si");function Di(){Z===null&&import("./detector-scanic-S4PB2RNW-3KSM3MW5.js").then(s=>{Z=s.detectQuad}).catch(()=>{})}n(Di,"ji");var ce=4e3,li=2,ue=3,ni=Object.freeze({LOW:3,MID:5,HIGH:6}),Mt=Object.freeze({manualShutterMs:6e3,detectedNoLockMs:1950});function Ti(s){let t=s!==null&&typeof s=="object"?s:{},e=n((i,a,h)=>typeof i=="number"&&Number.isFinite(i)&&i>=a&&i<=h?i:void 0,"e");return{manualShutterMs:e(t.manualShutterMs,1e3,6e4)??Mt.manualShutterMs,detectedNoLockMs:e(t.steadyMs,300,3e4)!==void 0?t.steadyMs+(e(t.lockMs,0,1e4)??450):Mt.detectedNoLockMs}}n(Ti,"Yi");var z,Ai=(z=class{constructor(t){this.torchOn=!1,this.stillRefusals=0,this.zoom=1,this.positioningSince=null,this.detectedSince=null,this.lastSeenAt=null,this.lastGuideQuad=null,this.lastOcrReady=null,this.shutterOffered=!1,this.stats=z.freshStats(),this.handlers=new Map,this.stream=null,this.timer=null,this.state="idle",this.lastGuidance=null,this.attempt=0,this.capturing=!1,this.feedback=new ze,this.lastFeedbackKey=null,this.lastQuad=null,this.lastDetect=null,this.frameWatch=null,this.reopened=!1,this.lit=!1,this.blackTicks=0,this.offEnded=null,this.opts=t,this.gate=new ee(t.format??"ID-1",t.thresholds);let e=t.deviceClass??Qt(Ht());this.deviceClass=e,this.camera=t.camera??yt,this.shutterTuning=t.shutter??Mt,this.guideTuning=t.guideLock??ot,this.guideLock=new hi(this.guideTuning),this.cadenceMs=1e3/ni[e]}on(t,e){let i=this.handlers.get(t);return i||(i=new Set,this.handlers.set(t,i)),i.add(e),()=>i?.delete(e)}emit(t,e){for(let i of[...this.handlers.get(t)??[]])i(e)}async start(){let t=this.state==="error"?this.resumePlayback():null,e=++this.attempt;if(this.clearFrameWatch(),this.gate.reset(),this.resetSide(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.lit=!1,this.blackTicks=0,t!==null&&await t&&e===this.attempt){this.setState("positioning"),this.scheduleTick(e),this.watchFrames(e);return}if(e===this.attempt){this.releaseStream(),jt(),this.setState("preflight");try{let i=this.opts.getUserMedia??(o=>navigator.mediaDevices.getUserMedia(o));this.setState("acquiring");let a=this.opts.enumerateDevices??(this.opts.getUserMedia===void 0&&typeof navigator<"u"&&navigator.mediaDevices?.enumerateDevices?()=>navigator.mediaDevices.enumerateDevices():void 0),h=await ei({getUserMedia:i,...a!==void 0?{enumerateDevices:a}:{},lensSelection:this.camera.lensSelection,base:Ee});if(e!==this.attempt){for(let o of h.stream.getTracks())o.stop();return}if(this.stream=h.stream,Wt(this.stream),Gt(this.stream),this.watchEnded(e),this.opts.upgradeResolution!==!1&&await this.upgradeResolution(),e!==this.attempt||(await this.applyFocusAndZoom(),e!==this.attempt)||(this.opts.video.srcObject=this.stream,await this.opts.video.play().catch(()=>{}),e!==this.attempt))return;this.setState("positioning"),this.scheduleTick(e),this.watchFrames(e)}catch(i){if(e!==this.attempt)return;let a=qt(i),h=Nt(i);this.setState("error"),this.emit("error",{kind:a,retryable:!0,detail:h===void 0?{phase:"acquiring"}:{phase:"acquiring",name:h}})}}}resumePlayback(){let t=this.opts.video,e=this.videoTrack();if(this.stream===null||e===null||e.readyState!=="live"||t.srcObject!==this.stream)return null;try{return Promise.resolve(t.play()).then(()=>this.framesNow(),()=>!1)}catch{return null}}framesNow(){let t=this.opts.video;return this.opts.hasFrames!==void 0?this.opts.hasFrames(t):!t.paused&&t.readyState>=2&&t.videoWidth>0}watchFrames(t){let e=this.opts.firstFrameMs??ce;e<=0||(this.clearFrameWatch(),this.frameWatch=setTimeout(()=>{if(this.frameWatch=null,!(t!==this.attempt||this.state!=="positioning")){if(this.framesNow()&&this.blackTicks<ue){this.reopened=!1;return}this.cameraDead(t)}},e))}clearFrameWatch(){this.frameWatch!==null&&clearTimeout(this.frameWatch),this.frameWatch=null}watchEnded(t){this.offEnded?.(),this.offEnded=null;let e=this.videoTrack();if(e===null||typeof e.addEventListener!="function")return;let i=n(()=>{t===this.attempt&&(this.state==="positioning"||this.state==="acquiring")&&this.cameraDead(t)},"o");e.addEventListener("ended",i),this.offEnded=()=>e.removeEventListener?.("ended",i)}cameraDead(t){if(t!==this.attempt)return;let e=this.videoTrack(),i=e!==null&&e.readyState==="live"&&!e.muted&&this.opts.video.paused&&!this.framesNow();if(!i&&!this.reopened){this.reopened=!0,this.start();return}this.attempt+=1,this.timer!==null&&(this.opts.clearTimer??clearTimeout)(this.timer),this.timer=null,this.clearFrameWatch(),i||this.releaseStream(),this.reopened=!1,this.setState("error"),this.emit("error",{kind:"generic",retryable:!0,detail:{phase:"acquiring"}})}releaseStream(){if(this.offEnded?.(),this.offEnded=null,this.stream)for(let t of this.stream.getTracks())t.stop();this.stream=null,this.opts.video.srcObject!==null&&this.opts.video.srcObject!==void 0&&(this.opts.video.srcObject=null)}rearm(t){t!==void 0&&(this.opts.side=t),this.gate.reset(),this.resetSide(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.stillRefusals=0,this.state==="captured"&&(this.setState("positioning"),this.scheduleTick(this.attempt))}async captureNow(){if(this.state!=="positioning"||this.capturing)return;let t=this.opts.video,e=this.lastDetect?.width??Math.max(1,t.videoWidth),i=this.lastDetect?.height??Math.max(1,t.videoHeight),a=this.lastQuad??this.lastGuideQuad??{topLeft:{x:0,y:0},topRight:{x:e,y:0},bottomRight:{x:e,y:i},bottomLeft:{x:0,y:i}},h=(this.opts.now??(()=>performance.now()))(),o=this.feedback.force("processing",h);this.lastFeedbackKey=o.key,this.emit("feedback",o),await this.fire(this.attempt,this.lastOcrReady!==null?this.lastOcrReady.quad:a,{width:e,height:i,tickSharpness:this.lastDetect?.tickSharpness??0},this.lastOcrReady?.via??"manual")}captureReport(){let t=this.stats;return{...this.opts.side!==void 0?{side:this.opts.side}:{},format:this.opts.format??"ID-1",deviceClass:this.deviceClass,video:{width:this.opts.video.videoWidth||0,height:this.opts.video.videoHeight||0},zoom:this.zoom,...t.zoomFallbackAtMs!==void 0?{zoomFallbackAtMs:t.zoomFallbackAtMs}:{},...t.msToCapture!==void 0?{msToCapture:t.msToCapture}:{},...t.via!==void 0?{via:t.via}:{},...t.shutterAtMs!==void 0?{shutterAtMs:t.shutterAtMs}:{},...t.shutterReason!==void 0?{shutterReason:t.shutterReason}:{},ticks:t.ticks,quadFraming:{...t.quadFraming},qualityBlockers:{...t.qualityBlockers},guideBlockers:{...t.guideBlockers},stillRefusals:t.stillRefusals,...this.ocrReport()}}ocrReport(){let t=this.opts.ocr;if(t===void 0)return{};let e=(this.opts.format??"ID-1")==="ID-3"||this.opts.side==="single"?"single":this.opts.side==="verso"?"verso":"recto",i=t.report(e,this.stats.via,(this.opts.now??(()=>performance.now()))());return i===null?{}:{ocr:i}}static freshStats(){return{ticks:0,quadFraming:{},qualityBlockers:{},guideBlockers:{},stillRefusals:0}}setGuide(t){t===void 0?delete this.opts.guide:this.opts.guide=t,this.guideLock.reset()}guideRegion(t){let e=t.width/Math.max(1,t.height),i=this.opts.guide;if(i!==void 0&&i.viewAspect>0){let l={width:i.viewAspect,height:1},r={x:i.rect.x*i.viewAspect,y:i.rect.y,width:i.rect.width*i.viewAspect,height:i.rect.height};return ii(l,r,e,0)}let a=Vt(this.opts.format??"ID-1").center,h=.86,o=h*e/a;return o>.84&&(o=.84,h=o*a/e),{x:(1-h)/2,y:(1-o)/2,width:h,height:o}}resetSide(){this.positioningSince=null,this.detectedSince=null,this.lastSeenAt=null,this.guideLock.reset(),this.lastGuideQuad=null,this.lastOcrReady=null,this.opts.ocr?.reset(),this.stats=z.freshStats(),this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1}))}withdrawShutter(){this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1}))}zoomFallback(t){let e=this.videoTrack();if(e===null||this.zoom<=1)return;let i=this.focusCaps(),a=typeof i?.zoom?.min=="number"?Math.max(i.zoom.min,1):1;this.zoom=a,this.stats.zoomFallbackAtMs=Math.round(t-(this.positioningSince??t)),this.guideLock.reset(),this.gate.reset(),e.applyConstraints({advanced:[{zoom:a}]}).catch(()=>{})}offerShutter(t,e){this.shutterOffered||(this.shutterOffered=!0,this.stats.shutterAtMs=Math.round(e-(this.positioningSince??e)),this.stats.shutterReason=t,this.emit("shutter",{available:!0,reason:t}))}torchAvailable(){try{return this.stream?.getVideoTracks?.()[0]?.getCapabilities?.()?.torch===!0}catch{return!1}}async setTorch(t){this.torchOn=t;try{await this.stream?.getVideoTracks?.()[0]?.applyConstraints({advanced:[{torch:t}]})}catch{}}destroy(){if(this.attempt+=1,this.timer!==null&&(this.opts.clearTimer??clearTimeout)(this.timer),this.timer=null,this.clearFrameWatch(),this.offEnded?.(),this.offEnded=null,this.stream)for(let t of this.stream.getTracks())t.stop();this.stream=null,this.opts.video.srcObject=null}async upgradeResolution(){try{let t=this.stream?.getVideoTracks?.()[0];if(t===void 0)return;let e=t.getSettings?.()??{},i=Ge(t.getCapabilities?.(),{width:e.width??0,height:e.height??0},this.deviceClass,{width:this.camera.width,height:this.camera.height});i!==null&&await t.applyConstraints(i)}catch{}}focusCaps(){try{return this.videoTrack()?.getCapabilities?.()??null}catch{return null}}async applyFocusAndZoom(){let t=this.videoTrack();if(t===null)return;let e=this.focusCaps();this.camera.continuousFocus&&gt(e,"continuous")&&await t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{});let i={width:0,height:0};try{let h=t.getSettings?.()??{};i={width:h.width??0,height:h.height??0}}catch{}let a=$e(e,i,this.opts.format??"ID-1",this.camera);if(a>1)try{await t.applyConstraints({advanced:[{zoom:a}]}),this.zoom=a}catch{this.zoom=1}}async focusAt(t,e){let i=this.videoTrack(),a=re(this.focusCaps(),t,e);if(!(i===null||a===null))try{await i.applyConstraints({advanced:[a]}),(this.opts.setTimer??setTimeout)(()=>{this.restoreContinuous()},1500)}catch{}}async restoreContinuous(){let t=this.videoTrack();t===null||!this.camera.continuousFocus||!gt(this.focusCaps(),"continuous")||await t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{})}async refocusOn(t,e){let i=this.camera.refocusBeforePhotoMs,a=this.videoTrack();if(i<=0||a===null||e.width<=0||e.height<=0)return;let h=C(t),o=re(this.focusCaps(),(h.x+h.width/2)/e.width,(h.y+h.height/2)/e.height);if(o!==null)try{await a.applyConstraints({advanced:[o]});let l=this.opts.setTimer??setTimeout;await new Promise(r=>{l(()=>r(),i)})}catch{}}videoTrack(){try{return this.stream?.getVideoTracks?.()[0]??null}catch{return null}}async takeStill(t,e,i){if(this.opts.captureStill!==void 0)return this.opts.captureStill(this.opts.video,t,e);let a=this.opts.format??"ID-1",h=this.videoTrack();if(i&&this.opts.photoCapture!==!1&&this.deviceClass!=="LOW"&&!this.torchOn&&h!==null&&Ue(h)){await this.refocusOn(t,e);let o=await Ze(this.opts.video,t,e,a,{track:h,detect:this.detector(),detectWidth:tt});if(this.restoreContinuous(),o!==null)return o}return Ve(this.opts.video,t,e,a)}detector(){return this.opts.detect??((this.opts.format??"ID-1")==="ID-3"?ri:oi)}setState(t){this.state=t,this.emit("statechange",{state:t})}scheduleTick(t){let e=this.opts.setTimer??setTimeout;this.timer=e(()=>{this.tick(t)},this.cadenceMs)}async tick(t){if(t!==this.attempt||this.state!=="positioning"||this.capturing)return;let e=this.opts.now??(()=>performance.now()),i=this.opts.grabDetectFrame??fe,a=this.detector(),h=i(this.opts.video,tt);if(h===null){this.scheduleTick(t);return}if(!this.lit){if(ut(h)>li)this.lit=!0,this.blackTicks=0;else if(++this.blackTicks>=ue&&this.frameWatch===null&&(this.opts.firstFrameMs??ce)>0){this.cameraDead(t);return}}let o=null;try{o=await a(h)}catch{o=null}if(t!==this.attempt)return;let l=o!==null?at(h,o):h,r=e(),c={sharpness:Y(l),exposure:Xt(l),meanLuma:ut(l),specularFraction:Ie(l)},u=Oe({format:this.opts.format??"ID-1",quad:o,frameWidth:h.width,frameHeight:h.height,measures:c,...this.opts.thresholds!==void 0?{thresholds:this.opts.thresholds}:{}}),f=this.gate.tick({timestampMs:r,quad:o,quality:c,frameWidth:h.width,frameHeight:h.height}),d=(this.opts.format??"ID-1")!=="ID-3"?si(h,this.guideRegion(h),{edgePeakFrac:this.guideTuning.edgePeakFrac}):ht,m=this.guideLock.tick(d,r);this.lastGuideQuad=m.detected?ai(d):null;let g=this.capturing?null:this.ocrTick(h,o,d,m.detected,u,r);this.positioningSince??(this.positioningSince=r);let b=this.stats;if(b.ticks+=1,b.quadFraming[u.framing]=(b.quadFraming[u.framing]??0)+1,u.framing==="ok"&&!f.ready){let x=u.lighting!=="ok"?u.lighting:u.glare!=="ok"?"glare":u.blur!=="ok"?"blurry":"steadying";b.qualityBlockers[x]=(b.qualityBlockers[x]??0)+1}b.guideBlockers[m.blocker]=(b.guideBlockers[m.blocker]??0)+1,o!==null||m.detected?(this.detectedSince??(this.detectedSince=r),this.lastSeenAt=r):this.detectedSince=null,this.lastSeenAt!==null&&r-this.lastSeenAt<=pi?r-this.positioningSince>=this.shutterTuning.manualShutterMs?this.offerShutter("timeout",r):g?.suspendQuality!==!0&&this.detectedSince!==null&&r-this.detectedSince>=this.shutterTuning.detectedNoLockMs&&this.offerShutter("detected_no_lock",r):this.withdrawShutter();let w=r-(this.lastSeenAt??this.positioningSince);this.zoom>1&&this.camera.zoomFallbackMs>0&&w>=this.camera.zoomFallbackMs&&this.zoomFallback(r),this.emit("checks",{engine:"docv1",p:f.p,plausible:f.plausible,stableTicks:f.stableTicks,quad:f.quad,frameWidth:h.width,frameHeight:h.height,analysis:u,ready:g?.suspendQuality!==!0&&(f.ready&&o!==null||m.ready&&this.lastGuideQuad!==null)||this.lastOcrReady!==null,guide:{detected:m.detected,blocker:m.blocker,fill:d.fill,shape:d.shape,content:d.content,offsetX:d.offsetX,offsetY:d.offsetY},...g!==null&&g.mode!=="off"?{ocr:{mode:g.mode,...g.mrz?{mrz:g.mrz}:{},...g.lock?{lock:g.lock}:{}}}:g?.mrz?{ocr:{mode:g.mode,mrz:g.mrz}}:{}}),this.lastQuad=f.plausible?o:null,this.lastDetect={width:h.width,height:h.height,tickSharpness:c.sharpness};let k=Ae(u);u.framing!=="ok"&&m.detected&&(k=gi(m.blocker,d.brightness<this.guideTuning.darkBrightness)),k==="blurry"&&o!==null&&ui(o,h,this.opts.format??"ID-1")>=this.camera.focusFarFillFrac&&(k="focus_far"),k==="sensing"&&this.zoom>1&&this.camera.noDocFarHintMs>0&&w>=this.camera.noDocFarHintMs&&(k="focus_far");let S=this.feedback.tick(k,r);if(S.key!==this.lastFeedbackKey&&(this.lastFeedbackKey=S.key,this.emit("feedback",S)),f.guidanceKey!==this.lastGuidance&&(this.lastGuidance=f.guidanceKey,this.emit("guidance",{key:f.guidanceKey})),this.capturing)return;let D=g?.suspendQuality!==!0,I=D&&f.ready&&o!==null,F=D&&m.ready&&this.lastGuideQuad!==null,y=this.lastOcrReady;if(y!==null&&this.opts.autoCapture!==!1){let x=this.feedback.force("processing",r);this.lastFeedbackKey=x.key,this.emit("feedback",x);let v=Y(at(h,y.quad));await this.fire(t,y.quad,{width:h.width,height:h.height,tickSharpness:v},y.via);return}if((I||F)&&this.opts.autoCapture!==!1){let x=this.feedback.force("processing",r);this.lastFeedbackKey=x.key,this.emit("feedback",x);let v=F?this.lastGuideQuad:o,L=F?m.via==="steady"?"guide_steady":"guide_good":"quad",B=F?Y(at(h,v)):c.sharpness;await this.fire(t,v,{width:h.width,height:h.height,tickSharpness:B},L);return}this.scheduleTick(t)}async fire(t,e,i,a){this.capturing=!0;let h=this.opts.grabDetectFrame??fe,o=this.opts.setTimer??setTimeout,l={width:i.width,height:i.height};try{let r={still:await this.takeStill(e,l,!0),sharpness:i.tickSharpness};if(t!==this.attempt)return;let c=r.still.source==="photo"?0:di;for(let d=0;d<c;d++){if(await new Promise(b=>{o(()=>b(),fi)}),t!==this.attempt)return;let m=h(this.opts.video,tt);if(m===null)continue;let g=Y(at(m,e));if(g>r.sharpness*mi){let b=await this.takeStill(e,l,!1);if(t!==this.attempt)return;r={still:b,sharpness:g}}}if(t!==this.attempt)return;let u=r.still.sharpness;if(this.opts.autoCapture!==!1&&a!=="manual"&&typeof u=="number"&&u>=0&&u<this.camera.stillSharpnessMin&&this.stillRefusals<this.camera.stillRefusalsMax){this.stillRefusals+=1,this.stats.stillRefusals+=1,this.guideLock.reset(),this.lastOcrReady=null,(a==="text_lock"||a==="live_mrz")&&this.opts.ocr?.rearmFace();let d=(this.opts.now??(()=>performance.now()))(),m=this.feedback.force("focus_far",d);this.lastFeedbackKey=m.key,this.emit("feedback",m),this.capturing=!1,this.gate.reset(),this.scheduleTick(t);return}this.stillRefusals=0;let f=(this.opts.now??(()=>performance.now()))();this.stats.via=a,this.stats.msToCapture=Math.round(f-(this.positioningSince??f)),this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1})),this.setState("captured"),this.emit("artifacts",{keyframe:r.still.blob,previewDataUrl:r.still.previewDataUrl,...this.opts.side!==void 0?{side:this.opts.side}:{},...r.still.docRegion!==void 0?{docRegion:r.still.docRegion}:{},...(()=>{let d=a==="live_mrz"?this.opts.ocr?.liveCapture():null;return d?{liveMrz:d}:{}})()})}catch{if(t!==this.attempt)return;this.capturing=!1,this.gate.reset(),this.guideLock.reset(),this.lastOcrReady=null,(a==="text_lock"||a==="live_mrz")&&this.opts.ocr?.rearmFace(),this.scheduleTick(t)}}ocrTick(t,e,i,a,h,o){let l=this.opts.ocr,r=this.opts.video;if(l===void 0||!l.hasEngine)return this.lastOcrReady=null,null;let c=r.videoWidth,u=r.videoHeight;if(c<=0||u<=0||t.width<=0||t.height<=0)return null;let f=(this.opts.format??"ID-1")==="ID-3",d=this.guideRegion(t),m={x:d.x*c,y:d.y*u,w:d.width*c,h:d.height*u},g=c/t.width,b=u/t.height,w;f&&e!==null?w=ci(C(e),g,b,c,u):w=Yt(m,l.bandTop,u);let k=f?h.glare==="ok":i.cardGlare<=this.guideTuning.glareMax,S=f?h.blur==="ok":i.sharpness>=this.guideTuning.sharpnessMin,D=l.tick({atMs:o,video:r,mrzFace:f||this.opts.side==="verso"||this.opts.side==="single",present:f||e!==null||a,card:m,band:w,portrait:u>c,glareOk:k,sharpOk:S});if(D.ready&&D.via!==void 0){let I=f?e??de(d,t):this.lastGuideQuad??de(d,t);this.lastOcrReady={quad:I,via:D.via}}else this.lastOcrReady=null;return D}},n(z,"i"),z);function ci(s,t,e,i,a){let h=Math.min(i,s.width*1.06*t),o=Math.min(a,Math.max(s.height*1.6*e,h/5)),l=(s.y+s.height/2)*e,r=Math.max(0,Math.min(i-h,(s.x-s.width*.03)*t)),c=Math.max(0,Math.min(a-o,l-o/2));return{x:r,y:c,w:h,h:o}}n(ci,"ci");function de(s,t){let e=s.x*t.width,i=s.y*t.height,a=(s.x+s.width)*t.width,h=(s.y+s.height)*t.height;return{topLeft:{x:e,y:i},topRight:{x:a,y:i},bottomRight:{x:a,y:h},bottomLeft:{x:e,y:h}}}n(de,"Oe");function ui(s,t,e){let i=C(s);return t.width<=0||t.height<=0?0:e==="ID-3"?i.width/t.width:i.width*i.height/(t.width*t.height)}n(ui,"li");var di=2,fi=260,mi=1.08;function fe(s,t){let e=s.videoWidth,i=s.videoHeight;if(e===0||i===0)return null;let a=Math.min(1,t/e),h=Math.round(e*a),o=Math.round(i*a),l=document.createElement("canvas");l.width=h,l.height=o;let r=l.getContext("2d",{willReadFrequently:!0});return r===null?null:(e/Math.max(1,h)>4&&(r.imageSmoothingQuality="high"),r.drawImage(s,0,0,h,o),r.getImageData(0,0,h,o))}n(fe,"Pe");function at(s,t){let e=[t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x],i=[t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y],a=Math.max(0,Math.floor(Math.min(...e))),h=Math.max(0,Math.floor(Math.min(...i))),o=Math.min(s.width,Math.ceil(Math.max(...e))),l=Math.min(s.height,Math.ceil(Math.max(...i))),r=Math.max(1,o-a),c=Math.max(1,l-h),u=new Uint8ClampedArray(r*c*4);for(let f=0;f<c;f++){let d=((h+f)*s.width+a)*4;u.set(s.data.subarray(d,d+r*4),f*r*4)}return{data:u,width:r,height:c,colorSpace:s.colorSpace}}n(at,"lt");function gi(s,t){return s==="glare"?"glare":s==="too_small"?"too_far":s==="too_big"?"too_close":t?"too_dark":s==="blurry"?"blurry":s==="off_center"?"edge_clipped":s==="no_card"?"sensing":"hold_still"}n(gi,"mi");var pi=1200;export{Ri as a,_i as b,Di as c,ce as d,li as e,ue as f,ni as g,Mt as h,Ti as i,Ai as j,ci as k,di as l,fi as m};
@@ -1 +0,0 @@
1
- import{a as U,c as R}from"./chunk-TXDGBMD4.js";import{b as H}from"./chunk-6MYG4HWP.js";import{a as s}from"./chunk-4FHWXBOB.js";var k,m=(k=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)}},s(k,"u"),k);function N(e,t,n=Math.random){let i=(e??t)*1e3,r=Math.min(Math.max(i,500),2e4),a=Math.round(r*(1+(n()*2-1)*.25));return Math.min(Math.max(a,500),2e4)}s(N,"b");var ne=6e4,L=4,ie=3e4,se=9e5,re=200,ae=5,oe=400,ce=new Set(["server_busy","request_timeout"]),de=20,ue=60,le=600,pe=2;function v(e){return(e.split(";")[0]??"").trim()}s(v,"l");var he={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},fe=`@sekyro/web/${U}`,me=fe,g,tt=(g=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,r)=>(n??globalThis.fetch).call(globalThis,i,r),this.requestTimeoutMs=t.requestTimeoutMs??ie,this.retryAttempts=t.inProgressRetry?.attempts??ae,this.retryDelayMs=t.inProgressRetry?.delayMs??oe,this.random=t.random??Math.random}async getSession(){let t=await this.api("GET","/hosted/session");return this.sessionId=t.sessionId,t}async recordConsent(t){return this.api("POST","/hosted/consent",{body:{locale:t},busyRetry:!0})}async reportCameraUnavailable(t){return this.api("POST","/hosted/camera-unavailable",{body:{cause:t}})}async testerGate(t){return this.api("POST","/hosted/tester-gate",{body:{input:t}})}async reportCaptureIssue(t){let n=typeof t.name=="string"?t.name.replace(/[^A-Za-z]/g,"").slice(0,40):"",i=typeof t.engineKind=="string"&&/^[a-z_]{1,32}$/.test(t.engineKind)?t.engineKind:void 0,r=typeof t.attempt=="number"&&Number.isInteger(t.attempt)&&t.attempt>=0&&t.attempt<=1e3?t.attempt:void 0,a=t.check==="attestation"?r??"":"",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>=de)return;let o={check:t.check,kind:t.kind,...n!==""?{name:n}:{},...t.phase!==void 0?{phase:t.phase}:{},...i!==void 0?{engineKind:i}:{},...r!==void 0?{attempt:r}:{},...t.formFactor!==void 0?{formFactor:t.formFactor}:{},...typeof t.detail=="string"&&/^\d{1,10}$/.test(t.detail)?{detail:t.detail}:{},...V(t.challengeMs)?{challengeMs:t.challengeMs}:{},...V(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 m&&l.status===429){let p=Math.min(Math.max(l.retryAfterSeconds??ue,0),le);this.issuesPausedUntil=Math.max(this.issuesPausedUntil,Date.now()+p*1e3);return}(!(l instanceof m)||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,r={}){let a=await this.ensureSessionId(),c={kind:t,contentType:v(n),contentLength:i,...r.source==="upload"?{source:"upload"}:{}};return this.api("POST",`/sessions/${a}/media`,{body:c})}armCapture(t=2){this.fillCaptureNonces(t)}async presignCapture(t,n,i,r={}){let a=await this.ensureSessionId(),c=await this.takeCaptureNonce(),d=c===void 0?void 0:{nonce:c,...r.engine!==void 0?{engine:r.engine.slice(0,32)}:{},...r.durationMs!==void 0&&Number.isFinite(r.durationMs)?{captureMs:Math.min(36e5,Math.max(0,Math.round(r.durationMs)))}:{}},o={kind:t,contentType:v(n),contentLength:i,capture:d};return this.api("POST",`/sessions/${a}/media`,{body:o})}async takeCaptureNonce(){let t=s(()=>{let n=Date.now();return this.captureNonces=this.captureNonces.filter(i=>i.expiresAt-ne>n),this.captureNonces.shift()?.nonce},"e");for(let n=0;n<2;n++){let i=t();if(i!==void 0)return i;await this.fillCaptureNonces(1)}return t()}fillCaptureNonces(t){return this.captureFetch??(this.captureFetch=(async()=>{try{let n=await this.ensureSessionId(),i=await this.api("POST",`/sessions/${n}/media/capture-nonces`,{body:{count:Math.min(L,Math.max(1,t))}}),r=Date.now()+Math.max(0,i.expiresIn)*1e3;for(let a of Array.isArray(i.nonces)?i.nonces:[])typeof a=="string"&&a.length>0&&this.captureNonces.push({nonce:a,expiresAt:r});this.captureNonces=this.captureNonces.slice(-L)}catch{}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(t,n,i){let r;try{r=await this.fetchImpl(t,{method:"PUT",headers:{"content-type":v(i)},body:n,signal:AbortSignal.timeout(se)})}catch(a){throw K(a)}if(!r.ok){let a=(await r.text().catch(()=>"")).slice(0,re);throw new m({status:r.status,code:"upload_failed",message:`media upload failed (HTTP ${r.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 r=await this.ensureSessionId(),a={input:n,forceOutcome:i.forceOutcome};return this.api("POST",`/sessions/${r}/checks/${t}`,{body:a,idempotencyKey:i.idempotencyKey,...i.browserCheckToken!==void 0?{browserCheckToken:i.browserCheckToken}:{},busyRetry:i.idempotencyKey!==void 0})}async uploadAndSubmit(t,n,i,r={}){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,[he[t]]:d.key};return this.submitCheck(t,o,r)}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 r=t==="GET"||i.busyRetry===!0,a=`${this.apiOrigin}/api/v2${n}`,c={"x-session-token":this.sessionToken,"x-sekyro-sdk":me};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);try{let d=R.timezone();d!==void 0&&(c["sekyro-client-timezone"]=d)}catch{}c["sekyro-client-form-factor"]=H();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 m({status:o.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${o.status})`})}return ye(l)}let u=await _e(o);if(u.code==="idempotency_in_progress"&&d<this.retryAttempts){this.retryDelayMs>0&&await G(this.retryDelayMs);continue}if(r&&u.status===503&&ce.has(u.code)){r=!1,await G(N(u.retryAfterSeconds,pe,this.random));continue}throw u}}},s(g,"T"),g);function V(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=6e5}s(V,"k");function K(e){if((typeof e=="object"&&e!==null?e.name:void 0)==="TimeoutError")return new m({status:0,code:"timeout",message:"request timed out"});let t=e instanceof Error?e.message:String(e);return new m({status:0,code:"network_error",message:`network request failed: ${t}`})}s(K,"h");function ye(e){return e!==null&&typeof e=="object"&&"success"in e&&"data"in e?e.data:e}s(ye,"K");async function _e(e){let t="unknown_error",n=`request failed (HTTP ${e.status})`,i=Number.NaN,r;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)?r=o.details:Array.isArray(o.details?.errors)&&(r={...o.details,issues:[]})}}catch{}let a=e.headers.get("retry-after"),c=a===null?Math.floor(i):Number.parseInt(a,10);return new m({status:e.status,code:t,message:n,...Number.isFinite(c)&&c>=0?{retryAfterSeconds:c}:{},details:r})}s(_e,"V");function G(e){return new Promise(t=>setTimeout(t,e))}s(G,"S");function nt(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"}}s(nt,"z");function it(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}:{}}}s(it,"X");var ve=new Set(["nni_unbound","id_number_unbound","method_required","mobile_required","portrait_required"]);function ot(e){return ve.has(e)}s(ot,"be");function ct(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))}}s(ct,"ve");function dt(){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}}}s(dt,"Pe");var ke={document:"document_photo",nfc:"document_chip",population_registry:"national_number",national_eid:"national_eid"};function y(e){return e.plan?.steps??[]}s(y,"f");function F(e){return Math.max(0,e.attempts.max-e.attempts.used)}s(F,"x");function ge(e){let t=e.plan?.choice;return t!==void 0&&e.plan?.current===t.nodeId?t:null}s(ge,"W");function ut(e){let t=ge(e);if(t?.kind!=="identity_method")return null;let n=t.options.map(r=>ke[r.service]).filter(r=>r!==void 0),i=t.options.find(r=>r.nationalEid)?.nationalEid;return i?{available:!0,selected:null,options:n,nationalEid:i}:{available:!0,selected:null,options:n}}s(ut,"Me");var be=new Set(["liveness","face_match"]);function j(e){return e!==void 0&&(e.state==="pending"||e.state==="input_required")}s(j,"y");function we(e){return e.status!=="created"&&e.status!=="in_progress"}s(we,"T");function X(e){let t=e.plan?.current,n=t==null?void 0:y(e).find(i=>i.id===t);return j(n)?n:void 0}s(X,"M");function q(e,t){return y(e).find(n=>n.checkType===t)}s(q,"_");function O(e){let t=y(e),n=t.findIndex(i=>i.checkType==="liveness");return t.find((i,r)=>r>n&&i.checkType==="face_match")}s(O,"S");function Me(e,t){let n=q(t,"liveness")?.state,i=O(t)?.state;return(O(e)?.state??"pending")==="pending"&&(n==="passed"||n==="review")&&i!==void 0&&i!=="pending"&&i!=="skipped"}s(Me,"F");function B(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)}s(B,"V");var Se=/^[0-9a-f]{24}$/i;function E(e){return Se.test(e)?`ses_${e}`:e}s(E,"R");function P(e,t){let n=E(e);return t===void 0?{sessionId:n,status:"unavailable"}:{sessionId:n,status:"unavailable",reasonCode:t}}s(P,"w");function Z(e,t,n){let i=E(e);return n===void 0?{sessionId:i,status:t}:{sessionId:i,status:t,reasonCode:n}}s(Z,"O");function lt(e,t){let n=Ce(e,t),i=Te(e);return i!==void 0&&(n.sandbox={simulated:!0,reason:i}),n}s(lt,"Ve");var Ie=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 Ie.has(t)?t:void 0}s(Te,"Q");function Ce(e,t){let n=E(e.sessionId);switch(e.status){case"created":case"in_progress":return Oe(e,t);case"verified":return x(e,{sessionId:n,status:"verified"});case"review_pending":return x(e,Z(n,"review",Q(e,"review")));case"not_verified":return x(e,Ee(e));default:return x(e,{sessionId:n,status:"not_verified"})}}s(Ce,"Z");var Ae=new Set([0,1,2,3]);function x(e,t){return Ae.has(e.level)&&(t.level=e.level),typeof e.assurance=="string"&&e.assurance.length>0&&(t.assurance=e.assurance),t}s(x,"b");function Ee(e){let t={sessionId:E(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}s(Ee,"ne");function Pe(e){return e==="rejected"?"rejected":e==="unavailable"?"unavailable":"inconclusive"}s(Pe,"te");function xe(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}s(xe,"ie");function Oe(e,t){let n=E(e.sessionId),i=y(e).find(a=>be.has(a.checkType)&&a.state==="input_required"&&a.reason!==void 0);if(i?.reason==="mobile_required")return P(n,"mobile_required");if(i?.reason!==void 0){if(i.result==="unavailable")return P(n,i.reason);let a=t.autoRetry&&(F(i)>0||xe(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 r=X(e);return r===void 0&&y(e).some(a=>a.state==="review")?Z(n,"review",Q(e,"review")):r?.checkType==="portrait_icao"?P(n,"portrait_required"):P(n)}s(Oe,"re");function Q(e,t){return y(e).find(n=>n.state===t&&n.reason!==void 0)?.reason}s(Q,"L");function W(e,t,n,i,r){return e.presignCapture!==void 0?e.presignCapture(t,n,i,r):e.presign(t,n,i)}s(W,"K");function Y(e){return{engine:e?.engine,durationMs:e?.clipMs}}s(Y,"q");var qe=["video/webm","video/mp4"],J="image/jpeg",$e=2,Re=1e3,Ke=1e4,Ne=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"]),b,D=(b=class extends Error{constructor(){super("verification destroyed"),this.name="FlowCancelledError"}},s(b,"k"),b);function He(e){let t=O(e);return q(e,"portrait_icao")?.state!=="pending"&&(t!==void 0?j(t):e.capture?.livePhoto?.oneCapture===!0)}s(He,"me");var w,A=(w=class extends Error{constructor(t){super(t),this.name="AttestationError"}},s(w,"h"),w),M,Ue=(M=class extends A{constructor(t){super(`no attestation token: ${t}`),this.name="AttestationUnavailableError",this.code=t}},s(M,"E"),M);async function ee(e,t,n={}){let i=e.uuid(),r=!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 m))throw o;if(o.code==="consent_required"&&!r){r=!0,await e.ensureConsent({force:!0}),i=e.uuid();continue}if(o.code==="attestation_invalid"&&!a){a=!0,n.onAttestationInvalid?.(),i=e.uuid();continue}if(o.code==="inference_unavailable"&&d<Ne){d+=1;let u=N(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<$e){c+=1;let u=o.retryAfterSeconds!==void 0?o.retryAfterSeconds*1e3:void 0;await e.sleep(u!==void 0?Math.min(u,Ke):Re);continue}throw o}}s(ee,"D");var Le=new Set(["passed","review","processing","skipped"]);async function pt(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 r=Ve(e,t.keyframe),a=Ge(e,n,i,r),c=Be(e,r),d=!1,o=new Set,u=!0,l=0;for(;;){if(e.isCancelled())return{kind:"cancelled"};let p=e.getView();if(we(p))return{kind:"settled"};let h=X(p),C=h?.checkType,$=C==="liveness"&&!d?"liveness":C==="face_match"&&!o.has(h?.id)&&o.size<2&&u?"face_match":null;if($===null)return{kind:"settled"};if($==="liveness"&&t.captureChannel==="desktop")return{kind:"unavailable",reason:"mobile_required"};try{if($==="liveness"){d=!0;let f=await a();if(e.isCancelled())return{kind:"cancelled"};Me(p,f)&&o.add(O(f)?.id);for(let te of B(p,f))o.add(te);await e.applySubmit(f,"liveness");let _=q(e.getView(),"liveness")?.state;u=_===void 0||Le.has(_)}else{o.add(h?.id);let f=await c();if(e.isCancelled())return{kind:"cancelled"};for(let _ of B(p,f))o.add(_);await e.applySubmit(f,"face_match")}}catch(f){if(e.isCancelled()||f instanceof D)return{kind:"cancelled"};let _=Qe(f);if(_.kind!=="resync"||l>=ze)return _;l+=1,await e.refreshView()}}}s(pt,"Fe");function Ve(e,t){let n=null,i=null,r=s(()=>n!==null?Promise.resolve(n):(i??(i=(async()=>{let a=await W(e.client,"image",J,t.size,Y(e.artifacts));return await e.client.uploadToSpaces(a.uploadUrl,t,J),n=(await e.client.completeMedia(a.key)).key,e.onKeyframePromoted?.(n),n})().finally(()=>{i=null})),i),"r");return{ensure:r,attempt:s(()=>r().catch(()=>null),"attempt"),current:s(()=>n,"current")}}s(Ve,"_e");function Ge(e,t,n,i){let r=e.clipKeys?.get()??null,a,c=null,d=0,o;return()=>ee(e,async(u,l)=>{if(r===null||a===void 0){if(e.isCancelled())throw new D;a===void 0&&!He(e.getView())&&(a=null),e.onPhase("uploading");let[p,h]=await Promise.all([r!==null?Promise.resolve(r):(async()=>{let C=await W(u,"clip",n,t.size,Y(e.artifacts));return await u.uploadToSpaces(C.uploadUrl,t,n),(await u.completeMedia(C.key)).key})(),a!==void 0?Promise.resolve(a===null?null:a.imageKey):i.attempt()]);r=p,e.clipKeys?.set(p),a===void 0&&(a=h===null?null:{imageKey:h})}if(c===null){let p=performance.now();try{c=await e.getAttestation(),o=e.attestationError?.()}catch(h){throw h instanceof A?h:new A(h instanceof Error?h.message:String(h))}d=Math.round(performance.now()-p)}return e.onPhase("checking"),u.submitCheck("liveness",{clipKey:r,attestation:c,captureChannel:e.artifacts.captureChannel,capture:{...Je(e.artifacts),attestationMs:d,attestationError:o,...Ze(e.attestationFacts?.())},...a!==null?{faceMatch:a}:{}},{idempotencyKey:l})},{onAttestationInvalid:s(()=>{c=null},"onAttestationInvalid")})}s(Ge,"ge");function Be(e,t){return()=>ee(e,async(n,i)=>{if(t.current()===null){if(e.isCancelled())throw new D;e.onPhase("uploading")}let r=await t.ensure();return e.onPhase("checking"),n.submitCheck("face_match",{imageKey:r},{idempotencyKey:i})})}s(Be,"Se");function Je(e){let t={width:e.width,height:e.height};for(let n of Xe)e[n]!==void 0&&(t[n]=e[n]);return t}s(Je,"ye");var Xe=["engine","facingMode","mode","formFactor","clipMs","clipFrames","fps","clipRetakes","codec","cameraReadyMs","faceAcquireMs","captureMs","screenRamp","provenance"];function Ze(e){return e===void 0?{}:{attestationChecks:e.checks,...e.challengeMs!==void 0?{attestationChallengeMs:e.challengeMs}:{}}}s(Ze,"ke");function Qe(e){if(e instanceof A)return{kind:"unavailable",reason:"attestation"};if(e instanceof m){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"}}s(Qe,"Ce");var ht="form_answers_invalid",S,ft=(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}},s(S,"U"),S),I,mt=(I=class extends Error{constructor(t,n){super(`invalid ${t} (${n})`),this.name="InvalidInputError",this.field=t,this.kind=n}},s(I,"B"),I),T,yt=(T=class extends Error{constructor(t,n){super(`invalid ${t} (${n})`),this.name="OtpInputError",this.field=t,this.kind=n}},s(T,"$"),T);function z(e){return e?.source==="upload"?null:e?.source==="choice"&&e.sourcePick!=="camera"?"upload_or_phone":"phone"}s(z,"I");function _t(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=q(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}}s(_t,"De");function We(e){let t=e?.capture,n=t?.mode;return n==="assisted"||n==="self"||n==="choice"?n:t?.cameraSwitch===!0?"assisted":"self"}s(We,"we");function vt(e){let t=e?.capture?.pick;return We(e)==="choice"&&(t==="self"||t==="assisted")?t:null}s(vt,"Be");function kt(e,t,n=null){return e==="choice"?t??n??"self":e}s(kt,"$e");var gt={"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{m as a,v as b,tt as c,nt as d,it as e,ot as f,ct as g,dt as h,ke as i,y as j,F as k,ge as l,ut as m,j as n,we as o,X as p,q,E as r,P as s,lt as t,Te as u,W as v,qe as w,Ue as x,ee as y,pt as z,Je as A,ht as B,ft as C,mt as D,yt as E,_t as F,We as G,vt as H,kt as I,gt as J};
@@ -1 +0,0 @@
1
- import{a as ae,b as be,c as ke,d as Se,f as xe}from"./chunk-2FETDQV5.js";import{a as ie,d as Te,e as Ce}from"./chunk-XSGZY4JI.js";import{e as J}from"./chunk-FQYXVP54.js";import{e as we,k as Me}from"./chunk-6MYG4HWP.js";import{g as re}from"./chunk-JS2IXPNL.js";import{a as n}from"./chunk-4FHWXBOB.js";function Re(e,t){let r=new Set(e.flatMap(i=>i.sides.filter(l=>l[t]!==null).map(l=>l.side)));return r.size===1?[...r][0]:null}n(Re,"_e");function _e(e){let t=Te.find(i=>i.docType===e),r=t.mrz==="none"?null:t.mrz==="td3"?"single":"verso";return{sides:t.sides,format:Ce(e),mrz:t.mrz==="none"?"none":"required",mrzSide:r,barcodeSide:null,portraitSide:t.portraitSide}}n(_e,"ot");function Ge(e,t){if(t.length===0)return _e(e);let r=t.some(s=>s.sides.length>1),i=new Set(t.map(s=>s.format)),l=i.size===1?[...i][0]:"card",u=t.filter(s=>s.sides.some(h=>h.mrz!==null)).length,d=t.find(s=>s.sides.length>1===r)?.sides.find(s=>s.portrait)?.side;return{sides:r?["recto","verso"]:["single"],format:l,mrz:u===t.length?"required":u===0?"none":"optional",mrzSide:Re(t,"mrz"),barcodeSide:Re(t,"barcode"),portraitSide:d??(r?"recto":"single")}}n(Ge,"Pe");function He(e,t){if(e===void 0)return[];let r=e.toUpperCase();return Object.prototype.hasOwnProperty.call(ie,r)?ie[r]?.[t]??[]:[]}n(He,"Ee");async function Xe(e,t,r){return await e(t)?r:r==="recto"?"verso":"recto"}n(Xe,"Oe");var Ye={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 Je(e){let{deviceMemory:t,effectiveType:r,saveData:i,downlinkMbps:l,sourceLongEdge:u}=e,d=i===!0||r==="slow-2g"||r==="2g"||l!=null&&l>0&&l<1,s=t!=null&&t<=2,h=r==="4g"||l!=null&&l>=5,c=t!=null&&t>=6,b;d||s?b="low":h&&c?b="good":b="mid";let f=Ye[b],P=u&&u>0?Math.min(f.maxLongEdge,u):f.maxLongEdge;return{tier:b,...f,maxLongEdge:P}}n(Je,"it");function Qe(e){let t={};try{let r=navigator;typeof r.deviceMemory=="number"&&(t.deviceMemory=r.deviceMemory);let i=r.connection;i&&(t.effectiveType=i.effectiveType,t.saveData=i.saveData,t.downlinkMbps=i.downlink)}catch{}return typeof e=="number"&&e>0&&(t.sourceLongEdge=e),Je(t)}n(Qe,"Ae");function $e(e,t,r){let i=Math.min(1,Math.max(0,(e-.28)/.21999999999999997)),l=(t+r)/2;return Math.max(t,r-i*(r-l))}n($e,"st");function Ze(e,t,r){let i=Math.max(e,t),l=i>0?Math.min(1,r/i):1;return{width:Math.max(1,Math.round(e*l)),height:Math.max(1,Math.round(t*l))}}n(Ze,"ut");async function Ke(e,t){let r=t.startQ,i=await e(r);for(let l=0;l<4&&!(i.size<=t.budgetBytes||r<=t.qMin);l++)r=Math.max(t.qMin,r-.08),i=await e(r);return{blob:i,quality:r}}n(Ke,"ct");async function et(e,t,r,i,l){if(t<=0||r<=0)return null;let{width:u,height:d}=Ze(t,r,i.maxLongEdge),s=document.createElement("canvas");s.width=u,s.height=d;let h=s.getContext("2d");if(!h)return null;h.drawImage(e,0,0,u,d);let c=n(C=>new Promise((y,p)=>{s.toBlob(g=>g?y(g):p(new Error("canvas toBlob returned null")),"image/jpeg",C)}),"d"),b=$e(l,i.qMin,i.qMax),{blob:f,quality:P}=await Ke(c,{startQ:b,qMin:i.qMin,budgetBytes:i.payloadTargetBytes}).finally(()=>{s.width=0,s.height=0});if(f.size>5242880)throw new Error("encoded document exceeds the 5242880-byte media cap");return{blob:f,quality:P,width:u,height:d}}n(et,"Be");async function tt(e){let t=Qe(Math.max(e.width,e.height)),r=await et(e,e.width,e.height,t,.5);if(r===null)throw new Error("canvas encode unavailable");return{blob:r.blob,width:r.width,height:r.height}}n(tt,"oe");function Ee(e,t){return{layout:e,phase:"framing",captured:{},pending:[],lastCaptureAt:t,lastReportAt:t,manualShutter:!1,restPhase:"framing",readSides:[],needFlip:!1,flipped:!1,flipTimeoutSpent:!1,timeoutCapture:!1,lastShotByTimeout:!1}}n(Ee,"ie");var We=n(e=>e==="recto"?"verso":"recto","Fe"),qe=n(e=>e.phase==="framing"||e.phase==="locking"||e.phase==="flipCue"||e.phase==="reaskRecto","We"),de=n(e=>(e.captured.recto!==void 0?1:0)+(e.captured.verso!==void 0?1:0)+e.pending.length,"se");function ne(e,t){return e.lastCaptureAt>=0&&e.lastReportAt>=0?e:{...e,lastCaptureAt:e.lastCaptureAt<0?t:e.lastCaptureAt,lastReportAt:e.lastReportAt<0?t:e.lastReportAt}}n(ne,"ae");function rt(e,t,r){if(e.phase==="result")return{...e,lastReportAt:r};let i=!t.present||e.captureArea!==void 0&&t.areaFrac<.6*e.captureArea,{flipped:l,awaySince:u}=e;i&&(u=u??r),u!==void 0&&r-u>=250&&(l=!0),i||(u=void 0);let d=e.flipTimeoutSpent&&!(l&&!e.flipped),s={...e,lastReportAt:r,flipped:l,awaySince:u,flipTimeoutSpent:d,lastArea:t.areaFrac};if(!qe(e))return s;if(e.needFlip&&!l){if(!t.ready)return{...s,phase:e.restPhase,goodSince:void 0};let h=e.lastShot!==void 0&&e.pending.includes(e.lastShot);if(d||h)return{...s,goodSince:void 0,phase:e.restPhase};let c=e.goodSince??r;return r-c>=1800?{...s,goodSince:c,phase:"capturing",flipTimeoutSpent:!0,timeoutCapture:!0}:{...s,goodSince:c,phase:e.restPhase}}return t.ready?{...s,phase:"capturing",goodSince:e.goodSince??r}:{...s,goodSince:void 0,phase:t.locking?"locking":e.restPhase}}n(rt,"lt");function at(e,t){if(!qe(e)||e.manualShutter)return e;let r=t-e.lastReportAt>=2e3,i=t-e.lastCaptureAt>=6e3;return r||i?{...e,manualShutter:!0}:e}n(at,"dt");function it(e,t,r){let i=e.layout==="singlePage",l=i?{recto:t}:e.captured,u=i?[]:[...e.pending,t],d={...e,captured:l,pending:u,lastShot:t,lastCaptureAt:r,lastReportAt:-1,manualShutter:!1,goodSince:void 0,notice:void 0,awaySince:void 0,flipped:!1,lastShotByTimeout:e.timeoutCapture,timeoutCapture:!1,captureArea:e.lastArea};return i||de({captured:l,pending:u})>=2?{...d,phase:"reading",restPhase:"framing",current:void 0,needFlip:!1}:{...d,phase:"flipCue",restPhase:"flipCue",current:void 0,needFlip:!0}}n(it,"mt");function Fe(e,t,r){return e.pending.includes(t)?{...e,pending:e.pending.filter(i=>i!==t),lastShot:e.lastShot===t?void 0:e.lastShot,phase:e.phase==="capturing"?e.phase:"flipCue",restPhase:"flipCue",current:We(r),needFlip:!0,flipTimeoutSpent:!0,goodSince:void 0,manualShutter:!0,notice:"same_face",lastCaptureAt:-1,lastReportAt:-1}:e}n(Fe,"ze");function nt(e,t,r){if(!e.pending.includes(t))return e;if(e.captured[r]!==void 0)return Fe(e,t,r);let i=e.pending.filter(h=>h!==t),l={...e,pending:i,captured:{...e.captured,[r]:t}};if(de(l)!==1||e.layout==="singlePage")return l;let u=We(r),d=u==="recto"&&e.restPhase==="reaskRecto"?"reaskRecto":"flipCue",s=e.phase==="flipCue"||e.phase==="reaskRecto"||e.phase==="framing";return{...l,restPhase:d,current:u,phase:s?d:e.phase}}n(nt,"pt");function ot(e,t){let r=t.id??e.captured[t.side],i={...e.captured};(t.id===void 0||i[t.side]===t.id)&&delete i[t.side];let l=e.pending.filter(c=>c!==r),u=e.layout==="twoSided"&&de({captured:i,pending:l})>0,d=e.lastShotByTimeout||r===e.lastShot!==e.flipped,s=u&&!d,h=s?t.side==="recto"?"reaskRecto":"flipCue":"framing";return{...e,captured:i,pending:l,readSides:e.readSides.filter(c=>c!==t.side),lastShot:e.lastShot===r?void 0:e.lastShot,notice:t.issue,goodSince:void 0,manualShutter:!1,phase:h,restPhase:h,current:t.side,needFlip:s,flipped:!1,flipTimeoutSpent:!1,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1}}n(ot,"ft");function lt(e,t){switch(t.type){case"report":return rt(ne(e,t.at),t.report,t.at);case"tick":return at(ne(e,t.at),t.at);case"captured":return it(ne(e,t.at),t.id,t.at);case"captureFailed":return{...e,phase:e.restPhase,goodSince:void 0,lastCaptureAt:t.at,manualShutter:!0,timeoutCapture:!1};case"classified":return nt(e,t.id,t.side);case"duplicate":return Fe(e,t.id,t.side);case"readOk":{let r=e.readSides.includes(t.side)?e.readSides:[...e.readSides,t.side],i=["recto","verso"].filter(u=>e.captured[u]!==void 0),l=e.phase==="reading"&&e.pending.length===0&&i.every(u=>r.includes(u));return{...e,readSides:r,flipTimeoutSpent:!1,phase:l?"result":e.phase}}case"readFailed":return ot(e,t);case"clockRestart":return e.lastCaptureAt<0&&e.lastReportAt<0&&e.awaySince===void 0?e:{...e,awaySince:void 0,lastCaptureAt:-1,lastReportAt:-1};case"retake":return{...Ee(e.layout,-1),lastCaptureAt:-1,lastReportAt:-1};default:return e}}n(lt,"Ue");function st(e,t,r=!1){let i=e(t);return i===null?"recto":!r||i.y+i.height/2>=t.height/2?"verso":"recto"}n(st,"gt");async function dt(e,t=!1){let{detectMrzBand:r}=await import("./mrz-band-VYHOTDHY-VEZ2J5IL.js");return st(r,e,t)}n(dt,"ht");async function Ae(e,t=480,r,i=r!=null){let l=r??{x:0,y:0,width:e.width,height:e.height},u=Math.max(1,Math.round(l.height/l.width*t)),d=document.createElement("canvas");d.width=t,d.height=u;try{let s=d.getContext("2d");return s===null?"recto":(s.drawImage(e,l.x,l.y,l.width,l.height,0,0,t,u),await dt(s.getImageData(0,0,t,u),i))}finally{d.width=0,d.height=0}}n(Ae,"ue");var oe=n((e,t,r)=>Math.min(r,Math.max(t,Math.round(e))),"ce"),Q=n(e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4,"$");async function ut(e,t,r,i){let l=i.decode??(h=>createImageBitmap(h)),u=n(async()=>e.stillRead(await l(t),i.region??[0,0,1,1],i.detectorLimit),"c"),d;try{d=await u()}catch{try{await new Promise(h=>setTimeout(h,i.retryMs??300)),d=await u()}catch{return null}}let s=d.mrzBox;return s===void 0?null:{engine:i.engine,source:"live_mrz",format:r.format,lineCount:oe(r.lineCount,2,3),checkDigitsValid:!0,stillConfirmed:d.valid&&d.digest===r.digest,band:[Q(s[0]),Q(s[1]),Q(Math.min(s[2],1-s[0])),Q(Math.min(s[3],1-s[1]))],digest:r.digest,framesToValid:oe(r.framesToValid,1,1e3),msToValid:oe(r.msToValid,0,12e4)}}n(ut,"Ne");var ct=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]),mt=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 pt(e,t=globalThis){let r=t.WebAssembly?.validate;if(typeof r!="function")return{ok:!1,reason:"simd"};try{if(!r.call(t.WebAssembly,ct)||!r.call(t.WebAssembly,mt))return{ok:!1,reason:"simd"}}catch{return{ok:!1,reason:"simd"}}if(typeof t.Worker!="function")return{ok:!1,reason:"worker"};if(typeof t.createImageBitmap!="function")return{ok:!1,reason:"bitmap"};let i=t.navigator?.deviceMemory;return typeof i=="number"&&i<e.minDeviceMemoryGb?{ok:!1,reason:"memory"}:{ok:!0}}n(pt,"Ge");function ht(e=globalThis){let t=e.navigator?.connection;return t?.saveData===!0||["slow-2g","2g","3g"].includes(t?.effectiveType??"")}n(ht,"qe");var N,E=(N=class extends Error{constructor(t){super(t),this.name="OcrEngineError",this.code=t}},n(N,"E"),N);function Le(){let e=n(t=>(t.close(),Promise.reject(new E("unsupported"))),"e");return{ready:Promise.resolve("unsupported"),busy:!1,bandRead:e,stillRead:e,layoutRead:e,dispose:n(()=>{},"dispose")}}n(Le,"He");function ft(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 Le()}catch{return Le()}let r=new Map,i=0,l=!1,u=!1,d=!1;t.addEventListener("message",p=>{let g=p.data,x=r.get(g.id);x&&(r.delete(g.id),x.resolve(g))});let s=n(()=>{for(let p of r.values())p.reject(new E("error"));r.clear(),c()},"s");t.addEventListener("error",s),t.addEventListener("messageerror",s);function h(p,g=[]){if(l)return Promise.reject(new E("disposed"));let x=++i;return new Promise((W,q)=>{r.set(x,{resolve:W,reject:q});try{t.postMessage({...p,id:x},g)}catch{r.delete(x),q(new E("error"))}})}n(h,"p");function c(){if(!l){l=!0;try{t.postMessage({id:++i,kind:"dispose"})}catch{}t.terminate();for(let p of r.values())p.reject(new E("disposed"));r.clear()}}n(c,"d");let b=(async()=>{let p=await h({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 g=await h({kind:"warmup"});return g.kind!=="ready"?"error":{warmupMs:g.warmupMs,downloadMs:p.downloadMs,cached:p.cached}})().catch(()=>"error"),f,P=new Promise(p=>{f=setTimeout(()=>p("timeout"),e.tuning.loadTimeoutMs)}),C=Promise.race([b,P]).then(p=>(clearTimeout(f),typeof p=="string"?c():d=!0,l&&typeof p!="string"?"error":p));(e.page===void 0?globalThis.addEventListener?globalThis:null:e.page)?.addEventListener("pagehide",c,{once:!0});async function y(p,g,x){if(l)throw g.close(),new E("disposed");if(!d)throw g.close(),new E("not_ready");if(u)throw g.close(),new E("busy");u=!0;let W;try{let q=new Promise((I,U)=>{W=setTimeout(()=>{U(new E("timeout")),c()},e.tuning.readTimeoutMs??1e4)}),z=await Promise.race([h(p,[g]),q]);if(z.kind===x){let{id:I,...U}=z;return U}throw new E(z.kind==="error"?z.code:z.kind==="failed"?z.reason:"error")}finally{clearTimeout(W),u=!1}}return n(y,"x"),{ready:C,get busy(){return u},bandRead:n((p,g=e.tuning.detectorLimit)=>y({kind:"band",bitmap:p,detectorLimit:g},p,"band"),"bandRead"),stillRead:n((p,g,x=e.tuning.detectorLimit)=>y({kind:"still",bitmap:p,region:g,detectorLimit:x},p,"band"),"stillRead"),layoutRead:n((p,g)=>y({kind:"layout",bitmap:p,detectorLimit:g},p,"layout"),"layoutRead"),dispose:c}}n(ft,"Xe");var $="sekyro-ocr-1",le=n(e=>e!==null&&typeof e=="object"?e:{},"le"),D=n((e,t,r,i)=>typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=r?e:i,"T"),Pe=n((e,t)=>typeof e=="boolean"?e:t,"Ye"),De=n(e=>{let t=typeof e=="string"?/^sekyro-ocr-(\d{1,4})$/.exec(e):null;return t?Number(t[1]):Number.POSITIVE_INFINITY},"Ve");function gt(e,t={}){let r=le(e),i=le(r.liveMrz),l=le(r.frontLock),u=De(t.engine??$),d=t.mode==="off",s=n(g=>g.enabled===!0?g.arm==="live"?"live":"control":null,"s"),h=s(i),c=s(l),b=n((g,x)=>!d&&x==="live"&&De(g.minEngine??$)<=u,"M"),f=Se,P=b(i,h)?{detectorLimit:D(i.detectorLimit,320,1600,f.detectorLimit),bandMaxWidthPx:D(i.bandMaxWidthPx,320,4096,f.bandMaxWidthPx),minBandWidthPx:D(i.minBandWidthPx,0,4096,f.minBandWidthPx),bandTop:D(i.bandTop,0,.95,f.bandTop),minIntervalMs:D(i.minIntervalMs,0,5e3,f.minIntervalMs),stableReads:Math.round(D(i.stableReads,1,10,f.stableReads)),profileReads:Math.round(D(i.profileReads,1,100,f.profileReads)),maxReadMs:D(i.maxReadMs,50,6e4,f.maxReadMs),searchTimeoutMs:D(i.searchTimeoutMs,1e3,12e4,f.searchTimeoutMs),hint:Pe(i.hint,!0),stillConfirm:Pe(i.stillConfirm,!0)}:null,C=ke,y=n((g,x,W)=>D(l[g],x,W,C[g]),"S"),p=b(l,c)?{minLines:Math.round(y("minLines",1,50)),fillMin:y("fillMin",0,1),fillMax:y("fillMax",0,2),offsetMax:y("offsetMax",0,1),steadyFillDelta:y("steadyFillDelta",0,1),steadyOffsetDelta:y("steadyOffsetDelta",0,1),layoutShiftMax:y("layoutShiftMax",0,1),lineCountDelta:Math.round(y("lineCountDelta",0,50)),lockMs:y("lockMs",0,3e4),steadyMs:y("steadyMs",0,3e4),minFrames:Math.round(y("minFrames",1,100)),minIntervalMs:y("minIntervalMs",0,5e3),maxWidthPx:y("maxWidthPx",160,2048),detectorLimit:y("detectorLimit",320,1600),searchTimeoutMs:y("searchTimeoutMs",1e3,12e4)}:null;return{enabled:P!==null||p!==null,liveMrz:P,textLock:p,liveMrzArm:h,frontLockArm:c,load:{detectorLimit:P?.detectorLimit??p?.detectorLimit??f.detectorLimit,loadTimeoutMs:D(i.loadTimeoutMs,1e3,12e4,2e4),maxDownloadMs:D(i.maxDownloadMs,1e3,12e4,2e4),minDeviceMemoryGb:D(i.minDeviceMemoryGb,0,64,2)},reportSampleRate:D(i.reportSampleRate,0,1,1)}}n(gt,"Qe");function vt(e,t){return e.enabled?!(t.probe??pt)({minDeviceMemoryGb:e.load.minDeviceMemoryGb}).ok||(t.slow??ht)()?{ok:!1,reason:"unsupported"}:{ok:!0,engine:ft({baseUrl:t.baseUrl,salt:t.salt,tuning:{detectorLimit:e.load.detectorLimit,maxDownloadMs:e.load.maxDownloadMs,loadTimeoutMs:e.load.loadTimeoutMs},...t.workerUrl!==void 0?{workerUrl:t.workerUrl}:{},...t.createWorker!==void 0?{createWorker:t.createWorker}:{},...t.page!==void 0?{page:t.page}:{}})}:{ok:!1,reason:"off"}}n(vt,"Ke");function yt(e=typeof navigator<"u"?navigator.userAgent:""){return/SamsungBrowser\//.test(e)?"samsung":/Firefox\/|FxiOS\//.test(e)?"firefox":/Chrome\/|CriOS\/|Chromium\//.test(e)&&!/Edg\/|OPR\//.test(e)?"chrome":/Safari\//.test(e)&&/Version\/|Mobile\//.test(e)&&!/Chrome\/|CriOS\//.test(e)?"safari":"other"}n(yt,"St");var B=n(e=>e===void 0||!Number.isFinite(e)?void 0:Math.min(6e5,Math.max(0,Math.round(e))),"F"),se=n((e,t,r)=>e===void 0||!Number.isFinite(e)?void 0:Math.min(r,Math.max(t,Math.round(e))),"de");function wt(e){let t=e.assist??null,r=e.load!==null&&e.load!==void 0&&typeof e.load=="object"?e.load:null,i=typeof e.load=="string"?e.load:null,l=t!==null?t.outcome:i==="unsupported"||i==="download"||i==="integrity"?i:i==="error"||i==="timeout"?"error":"off",u={kind:"live_mrz",platform:"web",engine:e.engine??$,arm:e.arm,capture:e.capture,outcome:l,reads:se(t?.reads??0,0,1e4)??0,browser:e.browser??yt()},d=n((s,h)=>{h!==void 0&&(u[s]=h)},"u");return d("format",t?.format),d("framesToValid",se(t?.framesToValid,1,1e4)),d("msToValid",B(t?.msToValid)),d("framesToLock",se(t?.framesToLock,1,1e4)),d("msToLock",B(t?.msToLock)),d("msToCapture",B(e.msToCapture)),d("readP50Ms",B(t?.readP50Ms)),d("readP90Ms",B(t?.readP90Ms)),d("deviceClass",t?.deviceClass),r!==null&&(d("warmupMs",B(r.warmupMs)),d("downloadMs",B(r.downloadMs)),d("cached",r.cached)),d("stillConfirmed",e.stillConfirmed),d("typeMismatch",e.typeMismatch),u}n(wt,"je");function ze(e,t){return e===void 0?!1:t==="passport"?e!=="TD3":e==="TD3"}n(ze,"me");var Mt=2;async function bt(e){let t=await import("./capture-session-doc-2XRGB6AO-ZURBQ4YP.js");return new t.CaptureSessionDoc(e)}n(bt,"Dt");function kt(e){return{topLeft:{x:e.x,y:e.y},topRight:{x:e.x+e.width,y:e.y},bottomRight:{x:e.x+e.width,y:e.y+e.height},bottomLeft:{x:e.x,y:e.y+e.height}}}n(kt,"wt");function St(e,t,r){let i=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft],l=0;for(let u=0;u<i.length;u+=1){let d=i[u],s=i[(u+1)%i.length];l+=d.x*s.y-s.x*d.y}return t>0&&r>0?Math.abs(l)/2/(t*r):0}n(St,"kt");function Pt(){import("./capture-session-doc-2XRGB6AO-ZURBQ4YP.js").then(e=>e.warmDocDetector()).catch(()=>{})}n(Pt,"ln");function Dt(e){return xt(e,{}).handle}n(Dt,"dn");function xt(e,t){let r=we(),i=Me({enabled:e.keepScreenAwake!==!1}),l=t.decode??(a=>createImageBitmap(a)),u=t.blurRefuseSharpnessMax??.16,d=t.now??(()=>performance.now()),s=Ge(e.documentType,t.catalogCapture===!0?He(e.issuer,e.documentType):[]),h=s.sides.length===1||e.side==="single",c=Ee(h?"singlePage":"twoSided",d());if(!h&&(e.side==="recto"||e.side==="verso")){let a=e.side==="recto"?"verso":"recto";c={...c,captured:{[a]:"server"},readSides:[a],current:e.side,phase:"flipCue",restPhase:"flipCue"}}let b="idle",f=null,P=null,C=!0,y=0,p=0,g=!1,x=!1,W="",q=null,z,I=null,U=[],ue=s.mrz==="none",Be=s.barcodeSide==="recto"||s.barcodeSide==="verso"?s.barcodeSide:null,V=ue&&!h?t.barcode?.side??Be:null,ce=e.barcodeAssetBaseUrl??t.barcode?.assetBaseUrl,Z=null,me=n(()=>V===null||ce===void 0||t.barcode?.seen!==void 0?Promise.resolve(null):(Z??(Z=import("./barcode-detect-C5IOXMKI-ZOZ2WOWU.js").then(a=>a.loadBarcodeDetect(ce)).catch(()=>null)),Z),"ge"),Ie=n(async(a,o)=>{if(V===null)return null;let m=V==="recto"?"verso":"recto";try{let v=t.barcode?.seen;if(v!==void 0)return await v(a)?V:m;let[L,k]=await Promise.all([me(),o()]);if(L===null||k===null)return null;let T=Math.min(1600,k.width),M=document.createElement("canvas");M.width=T,M.height=Math.max(1,Math.round(k.height/k.width*T));try{let w=M.getContext("2d");return w===null?null:(w.drawImage(k,0,0,M.width,M.height),await Xe(L,w.getImageData(0,0,M.width,M.height),V))}finally{M.width=0,M.height=0}}catch{return null}},"Je"),R=t.webOcr!==void 0&&!ue?gt(t.webOcr.captureDocument,{mode:e.liveMrz?.mode??"auto"}):null,_=null,O=R===null||!R.enabled?"off":null,G=null,H=null,pe=new WeakMap,K="";if(R!==null&&R.enabled&&t.webOcr!==void 0){let a=t.webOcr,o=vt(R,{baseUrl:e.liveMrz?.assetBaseUrl??a.baseUrl,salt:a.salt,...e.liveMrz?.workerUrl!==void 0?{workerUrl:e.liveMrz.workerUrl}:{},...a.createWorker!==void 0?{createWorker:a.createWorker}:{}});if(o.ok){_=o.engine;let m=new xe({textLock:R.textLock,liveMrz:R.liveMrz});G=m;let v=o.engine;v.ready.then(L=>{O=L,typeof L!="string"&&C&&m.setEngine(v)})}else O=o.reason}let j=n(a=>{let o=JSON.stringify(a);o!==K&&(K=o,r.emit("mrz",a))},"U"),he=n((a,o)=>{let m=t.webOcr?.reports;if(m===void 0||R===null||a===void 0)return;let v=a.format==="ID-3"||a.side==="single"?"single":a.side==="verso"?"verso":"recto",L=v!=="recto"?R.liveMrzArm??R.frontLockArm:R.frontLockArm;if(L===null||Math.random()>=R.reportSampleRate)return;let k=a.via==="live_mrz"?H:null,T=n(()=>{let M=k?.value??null;m([wt({arm:L,capture:v,assist:a.ocr??null,load:L==="control"?"off":O,...a.msToCapture!==void 0?{msToCapture:a.msToCapture}:{},...M!==null&&M.stillConfirmed!==void 0?{stillConfirmed:M.stillConfirmed}:{},...o!==void 0?{typeMismatch:ze(o.format,s.format==="ID-3"?"passport":"card")}:{}})])},"w");k!==null&&k.value===null?Promise.race([k.promise,new Promise(M=>setTimeout(M,3e3))]).then(T):T()},"be"),F=n(a=>{!C||a===b||(b=a,i.setActive(a==="starting"||a==="scanning"),r.emit("state",a))},"I"),Ue=n((a,o)=>o===void 0?null:h?"single":a.captured.recto===o?"recto":a.captured.verso===o?"verso":null,"Ze"),Oe=n(a=>({phase:a.phase,captured:h?a.captured.recto!==void 0?["single"]:[]:["recto","verso"].filter(o=>a.captured[o]!==void 0),expected:h?null:a.current??null,notice:a.notice??null,lastShot:Ue(a,a.lastShot),manualShutter:a.manualShutter,torchAvailable:f?.torchAvailable()??!1,torch:x}),"et"),fe=n(()=>{let a=f;a!==null&&a.captureNow().catch(()=>A({type:"captureFailed",at:d()}))},"ye");function A(a){if(!C)return;let o=c;c=lt(c,a),c.phase==="capturing"&&o.phase!=="capturing"&&Promise.resolve().then(fe),c.phase==="result"&&o.phase!=="result"&&(F("done"),ge());let m=Oe(c),v=JSON.stringify(m);v!==W&&(W=v,r.emit("scan",m))}n(A,"v");function ge(){I!==null&&clearInterval(I),I=null;for(let a of U.splice(0))a();f?.destroy(),f=null,i.setActive(!1)}n(ge,"Se");let ve=n(()=>f?.captureReport?.(),"Me"),ee=!1,ye=n((a,o)=>{if(!(a===void 0||t.onFaceReport===void 0))try{t.onFaceReport(a,o)}catch{}},"De"),X=n(a=>{K="",!(f===null||c.phase==="reading"||c.phase==="result")&&(ee=!1,f.rearm(h?"single":c.current??a))},"Q"),je=n(async(a,o,m,v)=>{if(H=null,v!==void 0&&_!==null&&R?.liveMrz?.hint===!0){let w={promise:ut(_,a,v,{engine:$,detectorLimit:R.liveMrz.detectorLimit}).catch(()=>null),value:null};w.promise.then(S=>{w.value=S}),H=w}v!==void 0&&ze(v.format,s.format==="ID-3"?"passport":"card")&&j({state:"mismatch",format:v.format});let L=ve();ye(L,"captured"),ee=!0,he(L,v);let k=m===void 0?q:m===null?null:{quad:kt(m),frameWidth:0,frameHeight:0,inStill:!0},T={decoded:null},M=n(()=>(T.decoded??(T.decoded=Promise.resolve().then(()=>l(a)).catch(()=>null)),T.decoded),"y");try{await Ne(a,o,k,M,H)}finally{T.decoded!==null&&(await T.decoded)?.close()}},"tt"),Ne=n(async(a,o,m,v,L)=>{let k=`shot-${y+=1}`;if(A({type:"captured",id:k,at:d()}),e.haptics!==!1)try{globalThis.navigator?.vibrate?.(30)}catch{}if(!g&&u>0){let w=await(t.measureSharpness!==void 0?t.measureSharpness(a,m):v().then(S=>S===null?-1:be(S,ae(m?.quad??null,m?.inStill===!0?S:{width:m?.frameWidth??0,height:m?.frameHeight??0},S)))).catch(()=>-1);if(!C)return;if(Number.isFinite(w)&&w>=0&&w<u){g=!0;let S=h?"recto":c.current??(c.captured.recto===void 0?"recto":"verso");A({type:"readFailed",side:S,id:k,issue:"blurry"}),X(S);return}}g=!1;let T;if(h)T="single";else{let w=c.current,S=(t.classify===void 0?await Ie(a,v):null)??await(t.classify!==void 0?t.classify(a):v().then(Y=>Y===null?w??"recto":m?.inStill===!0?Ae(Y,480,null,!0):Ae(Y,480,ae(m?.quad??null,{width:m?.frameWidth??0,height:m?.frameHeight??0},Y)))).catch(()=>w??"recto");if(!C)return;if(c.captured[S]!==void 0&&p<Mt){p+=1,A({type:"duplicate",id:k,side:S}),X(S==="recto"?"verso":"recto");return}T=c.captured[S]!==void 0&&w!==void 0?w:S,p=0,A({type:"classified",id:k,side:T})}let M=T==="verso"?"verso":"recto";try{let w=t.encode!==void 0?await t.encode(a):await v().then(S=>{if(S===null)throw new Error("the still could not be decoded");return tt(S)});if(!C)return;L!==null&&pe.set(w.blob,L),r.emit("captured",{image:w.blob,side:T,documentType:e.documentType,...e.issuer!==void 0?{issuer:e.issuer}:{},width:w.width,height:w.height,previewDataUrl:o}),t.deferRead!==!0&&A({type:"readOk",side:M})}catch(w){A({type:"readFailed",side:M,id:k,issue:"technical"}),r.emit("error",J("generic",!0,{phase:"keyframes",name:re(w)}))}X(M==="recto"?"verso":"recto")},"nt"),Ve=n(a=>{U.push(a.on("statechange",({state:o})=>{o==="preflight"||o==="acquiring"?F("starting"):o==="positioning"?F("scanning"):o==="captured"?F("captured"):o==="error"&&F("error")}),a.on("feedback",({key:o,reticle:m})=>r.emit("feedback",{key:o,reticle:m})),a.on("checks",o=>{r.emit("gate",{progress:o.p,quad:o.quad,frameWidth:o.frameWidth,frameHeight:o.frameHeight,...o.guide!==void 0?{guide:{detected:o.guide.detected,fill:o.guide.fill,offsetX:o.guide.offsetX??0,offsetY:o.guide.offsetY??0}}:{}});let m=o.ocr?.mrz;m!==void 0&&(m.state==="fallback"?j({state:"fallback",reason:m.reason}):m.state==="valid"?j({state:"valid",format:m.format}):m.state==="reading"?j({state:"reading",...m.format?{format:m.format}:{},...m.coach?{coach:m.coach}:{}}):j({state:"searching"}));let v=o.quad===null?0:St(o.quad,o.frameWidth,o.frameHeight);q=o.quad===null?null:{quad:o.quad,frameWidth:o.frameWidth,frameHeight:o.frameHeight},A({type:"report",report:{present:o.quad!==null&&o.plausible||o.guide?.detected===!0,ready:o.ready===!0,locking:o.p>=.5,areaFrac:v},at:d()})}),a.on("error",({kind:o,retryable:m,detail:v})=>r.emit("error",J(o,m,v))),a.on("artifacts",o=>{je(o.keyframe,o.previewDataUrl,o.docRegion,o.liveMrz)}))},"rt"),te=n(()=>(P??(P=(async()=>{if(C){if(me(),f===null){let a;try{a=await(t.createEngine??bt)({...t.engineOptions??{},...z!==void 0?{guide:z}:{},video:e.video,format:s.format,side:h?"single":e.side??"recto",autoCapture:!1,...G!==null?{ocr:G}:{}})}catch(m){F("error"),r.emit("error",J("models",!0,{phase:"models",name:re(m)}));return}if(!C){a.destroy();return}f=a,Ve(a);let o=t.tickMs??500;o>0&&(I=setInterval(()=>A({type:"tick",at:d()}),o))}A({type:"clockRestart"}),R!==null&&R.liveMrzArm==="live"&&(O==="unsupported"||O==="off")&&j({state:"fallback",reason:O}),await f.start()}})().finally(()=>{P=null})),P),"ee");return{handle:{get state(){return b},on:n((a,o)=>r.on(a,o),"on"),start:te,retry:n(()=>{if(f===null&&c.phase==="result"){A({type:"retake"}),p=0,g=!1,te();return}if(f!==null&&b!=="error"){A({type:"retake"}),p=0,g=!1,f.rearm(h?"single":void 0);return}te()},"retry"),setSide:n(a=>{h||a==="single"||(c.current!==a&&(c={...c,current:a}),A({type:"clockRestart"}),c.phase!=="reading"&&c.phase!=="result"&&f?.rearm(a))},"setSide"),shutter:fe,focusAt:n((a,o)=>{f?.focusAt?.(a,o)},"focusAt"),setGuide:n(a=>{z=a,f?.setGuide?.(a)},"setGuide"),setTorch:n(a=>{x=a,f?.setTorch(a),A({type:"tick",at:d()})},"setTorch"),destroy:n(()=>{if(C&&f!==null&&b!=="done"){let a=ve();!ee&&a!==void 0&&a.ticks>0&&ye(a,"abandoned"),he(a,void 0)}C=!1,ge(),G?.setEngine(null),_?.dispose(),_=null,r.clear()},"destroy")},setFlowState:n(a=>{(c.phase==="reading"||c.phase==="result")&&F(a==="done"&&c.phase!=="result"?"scanning":a)},"setFlowState"),settle:n((a,o)=>{let m=a==="verso"?"verso":"recto";A(o.ok?{type:"readOk",side:m}:{type:"readFailed",side:m,issue:o.issue}),o.ok||X(m)},"settle"),takeDeviceRead:n(a=>pe.get(a.image)?.value??null,"takeDeviceRead")}}n(xt,"Ct");export{Mt as a,Pt as b,Dt as c,xt as d};