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

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 (94) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cdn/chunks/{capture-session-doc-2LIRRKFX-GZQBYOR3.js → capture-session-doc-2XRGB6AO-ZURBQ4YP.js} +1 -1
  3. package/dist/cdn/chunks/{chunk-X7QE75V5.js → chunk-3CEJV42Q.js} +1 -1
  4. package/dist/cdn/chunks/{chunk-UQKRYXN5.js → chunk-5JSOPXYS.js} +1 -1
  5. package/dist/cdn/chunks/chunk-6MYG4HWP.js +1 -0
  6. package/dist/cdn/chunks/chunk-ADYI7APR.js +1 -0
  7. package/dist/cdn/chunks/{chunk-NNYJYD3Q.js → chunk-BMOSAKXR.js} +1 -1
  8. package/dist/cdn/chunks/{chunk-52CHUGVC.js → chunk-C6HZ7TYS.js} +2 -2
  9. package/dist/cdn/chunks/{chunk-PH7RJ5GZ.js → chunk-DW3VKKDE.js} +1 -1
  10. package/dist/cdn/chunks/{chunk-MDDGAHO6.js → chunk-E7OQJP4I.js} +1 -1
  11. package/dist/cdn/chunks/chunk-FQYXVP54.js +1 -0
  12. package/dist/cdn/chunks/{chunk-SVROKIYG.js → chunk-JI5WT66H.js} +1 -1
  13. package/dist/cdn/chunks/{chunk-ZRL6E7XH.js → chunk-K5SATFJY.js} +1 -1
  14. package/dist/cdn/chunks/{chunk-YPIQ6IU7.js → chunk-O23O5AAH.js} +1 -1
  15. package/dist/cdn/chunks/chunk-QMBS54J5.js +33 -0
  16. package/dist/cdn/chunks/chunk-QXWWOMOK.js +1 -0
  17. package/dist/cdn/chunks/{chunk-SJAQ7DUY.js → chunk-R3P75ZRR.js} +1 -1
  18. package/dist/cdn/chunks/{chunk-FVMJYXGV.js → chunk-RH3APX6G.js} +1 -1
  19. package/dist/cdn/chunks/{chunk-MZ6WG3QQ.js → chunk-RKNAZPA7.js} +1 -1
  20. package/dist/cdn/chunks/{chunk-Q6GRUOR3.js → chunk-S4ABXV4B.js} +1 -1
  21. package/dist/cdn/chunks/{chunk-BZDKXIWD.js → chunk-S774ZMGH.js} +1 -1
  22. package/dist/cdn/chunks/{chunk-WKQRKYX4.js → chunk-SOI356LX.js} +1 -1
  23. package/dist/cdn/chunks/{chunk-JDANRDDK.js → chunk-TPDANNML.js} +1 -1
  24. package/dist/cdn/chunks/{chunk-6N4AXKCS.js → chunk-TXDGBMD4.js} +1 -1
  25. package/dist/cdn/chunks/{chunk-NT7PZPBW.js → chunk-VPJEUYYP.js} +1 -1
  26. package/dist/cdn/chunks/{chunk-YGXNL7S2.js → chunk-XSGAV3PT.js} +1 -1
  27. package/dist/cdn/chunks/chunk-XSGZY4JI.js +1 -0
  28. package/dist/cdn/chunks/create-document-capture-XWNBUC55-FZGHPB6L.js +1 -0
  29. package/dist/cdn/chunks/{create-portrait-capture-5VGYZUOK-N3333DJC.js → create-portrait-capture-5VGYZUOK-KTCFCHTN.js} +1 -1
  30. package/dist/cdn/chunks/{detector-scanic-KMAVOHGF-NFYSZ7GU.js → detector-scanic-S4PB2RNW-3KSM3MW5.js} +1 -1
  31. package/dist/cdn/chunks/{document-capture-view-QMXAAYA2-5HJJKIZ4.js → document-capture-view-2NFKF44N-4F3CP2ZO.js} +1 -1
  32. package/dist/cdn/chunks/{eid-view-3QTJORA7-S7APLLOM.js → eid-view-UGYVZ5NM-NQLRT4US.js} +1 -1
  33. package/dist/cdn/chunks/{email-otp-view-6MD74OFN-PRYGFOHY.js → email-otp-view-ENQVRS66-DCCJA246.js} +1 -1
  34. package/dist/cdn/chunks/flow-views-HNJPDQ63-ER7B4XJF.js +1 -0
  35. package/dist/cdn/chunks/{form-view-YAGVGWMI-7BEAIBSC.js → form-view-6ERKUFVD-2JHV2SHY.js} +1 -1
  36. package/dist/cdn/chunks/overlay-de-2DL4MNC7-5CBBHT7P.js +1 -0
  37. package/dist/cdn/chunks/overlay-es-FMHWRKQW-REFKUX4J.js +1 -0
  38. package/dist/cdn/chunks/overlay-pt-OGIELLCM-GU2A32BS.js +1 -0
  39. package/dist/cdn/chunks/{plan-runner-T2ZTSBI4-SEXJ6KJP.js → plan-runner-KX7KUS3M-CECACJOR.js} +1 -1
  40. package/dist/cdn/chunks/{portrait-capture-view-6EUUL2QA-7F2WSHIW.js → portrait-capture-view-ARRN3JW6-XRLTO3JS.js} +1 -1
  41. package/dist/cdn/chunks/{portrait-review-view-TTVTYGLG-SVRXTB4Q.js → portrait-review-view-JF6TYNBU-57HERUGH.js} +1 -1
  42. package/dist/cdn/chunks/{proof-of-address-view-5WWGRXJL-JQWHMWVI.js → proof-of-address-view-46Q6F7H5-7ES2ZRQL.js} +1 -1
  43. package/dist/cdn/define.js +1 -1
  44. package/dist/cdn/index.js +1 -1
  45. package/dist/{chunk-M3SKGQUG.js → chunk-37I3KKNR.js} +1 -1
  46. package/dist/{chunk-DMESMWZ7.js → chunk-43AFSR5C.js} +1 -1
  47. package/dist/chunk-5MQUCOFK.js +1 -0
  48. package/dist/{chunk-F2IYM4GV.js → chunk-DXR3ZGW2.js} +1 -1
  49. package/dist/{chunk-NQQZCBHQ.js → chunk-FHAN7WFM.js} +1 -1
  50. package/dist/chunk-GBOZODQT.js +33 -0
  51. package/dist/{chunk-GIMNUGVE.js → chunk-JQOJI5Z3.js} +1 -1
  52. package/dist/{chunk-XJJ3KCLT.js → chunk-NC6MJEKS.js} +1 -1
  53. package/dist/{chunk-F67N4IZQ.js → chunk-OCLSIGRD.js} +1 -1
  54. package/dist/{chunk-YC4IK7VG.js → chunk-PNZPHUSG.js} +1 -1
  55. package/dist/{chunk-PCLZBE2D.js → chunk-Q5HUTAIF.js} +1 -1
  56. package/dist/{chunk-K5DAJSLX.js → chunk-VD7QSFUC.js} +1 -1
  57. package/dist/{chunk-2WPZFQUP.js → chunk-Y6IZDRYW.js} +1 -1
  58. package/dist/{chunk-SSSIPHG7.js → chunk-ZDYBRXXU.js} +1 -1
  59. package/dist/define.cjs +5 -5
  60. package/dist/define.js +1 -1
  61. package/dist/{document-capture-view-QMXAAYA2-62JPLXV7.js → document-capture-view-2NFKF44N-4JPWTBPF.js} +1 -1
  62. package/dist/{eid-view-3QTJORA7-TLA52WL7.js → eid-view-UGYVZ5NM-H7FHAGGG.js} +1 -1
  63. package/dist/{email-otp-view-6MD74OFN-WVIWSE4A.js → email-otp-view-ENQVRS66-5ZB3UKOO.js} +1 -1
  64. package/dist/flow-views-HNJPDQ63-RAX3SDYO.js +1 -0
  65. package/dist/{form-view-YAGVGWMI-CWM5GSJJ.js → form-view-6ERKUFVD-Q2C54SUQ.js} +1 -1
  66. package/dist/index.cjs +5 -5
  67. package/dist/index.d.cts +10 -0
  68. package/dist/index.d.ts +10 -0
  69. package/dist/index.js +1 -1
  70. package/dist/overlay-de-2DL4MNC7-ELIZ2XHC.js +1 -0
  71. package/dist/overlay-es-FMHWRKQW-5PQ3EGK2.js +1 -0
  72. package/dist/overlay-pt-OGIELLCM-QT53YCS2.js +1 -0
  73. package/dist/{portrait-capture-view-6EUUL2QA-ZTAGMPU2.js → portrait-capture-view-ARRN3JW6-RZYLVCCJ.js} +1 -1
  74. package/dist/{portrait-review-view-TTVTYGLG-HVTGBDRR.js → portrait-review-view-JF6TYNBU-NHMROJU3.js} +1 -1
  75. package/dist/{proof-of-address-view-5WWGRXJL-3BWMP23I.js → proof-of-address-view-46Q6F7H5-TPLEKAFW.js} +1 -1
  76. package/package.json +2 -2
  77. package/sbom.cdx.json +4 -4
  78. package/dist/cdn/chunks/chunk-574O5HZZ.js +0 -1
  79. package/dist/cdn/chunks/chunk-5FPDMYLD.js +0 -33
  80. package/dist/cdn/chunks/chunk-BIK4PGBE.js +0 -1
  81. package/dist/cdn/chunks/chunk-CW56KMMH.js +0 -1
  82. package/dist/cdn/chunks/chunk-LAF6JZRH.js +0 -1
  83. package/dist/cdn/chunks/chunk-X42LECG5.js +0 -1
  84. package/dist/cdn/chunks/create-document-capture-X35M4UAK-BB2SCTPK.js +0 -1
  85. package/dist/cdn/chunks/flow-views-AEVFAZOT-DUBO6WU5.js +0 -1
  86. package/dist/cdn/chunks/overlay-de-U5AM34SS-UPJSNTKZ.js +0 -1
  87. package/dist/cdn/chunks/overlay-es-LS4JWU5J-UFZMJAU6.js +0 -1
  88. package/dist/cdn/chunks/overlay-pt-M4ZJJRFE-HJIXIX5G.js +0 -1
  89. package/dist/chunk-BCDTYNQ3.js +0 -1
  90. package/dist/chunk-W23RACX3.js +0 -33
  91. package/dist/flow-views-AEVFAZOT-PKXWQC2K.js +0 -1
  92. package/dist/overlay-de-U5AM34SS-ISYPWAT7.js +0 -1
  93. package/dist/overlay-es-LS4JWU5J-2VRTV7R4.js +0 -1
  94. package/dist/overlay-pt-M4ZJJRFE-UCQAZFCI.js +0 -1
@@ -1 +1 @@
1
- import{a as Nr}from"./chunk-NNYJYD3Q.js";import{c as _t}from"./chunk-LAF6JZRH.js";import{b as kr,d as br}from"./chunk-JDANRDDK.js";import{b as xr,c as Ct}from"./chunk-MDDGAHO6.js";import{a as yr,b as vr,c as gr,d as Le}from"./chunk-MZ6WG3QQ.js";import{F as _r,K as wr,L as Sr,a as D,b as de,c as X,m as pr,n as Xe,p as hr,q as et,r as fr,s as mr,t as bt,u as se,v as Ae,w as tt,y as Cr}from"./chunk-WKQRKYX4.js";import{b as lr,c as cr,d as ur,g as dr}from"./chunk-X42LECG5.js";import{b as kt}from"./chunk-6N4AXKCS.js";import{a as s}from"./chunk-5QL6W6FW.js";import{f as ir}from"./chunk-CW56KMMH.js";import{a as o,c as E}from"./chunk-4FHWXBOB.js";var Rr=E(D(),1),v=E(de(),1),ee=E(de(),1),ye=E(D(),1),B=E(de(),1),C=E(D(),1),y=E(D(),1),at=E(D(),1),fe=E(de(),1),Wr=E(D(),1),Y=E(D(),1),it=E(D(),1),we=E(de(),1),Se=E(de(),1),U=E(de(),1);var lt=E(D(),1),pe=E(D(),1);var Q=E(D(),1);var M=E(D(),1),me=E(D(),1),Oe=E(D(),1),Rt=E(de(),1),k=E(de(),1);function oe({className:e,children:t}){return(0,v.jsx)("svg",{"aria-hidden":"true",focusable:"false",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",className:e??"sekyro-icon sekyro-icon--sm",children:t})}o(oe,"te");s(oe,"Svg");var Lt="M4 7.5h2.2l1.4-1.9h8.8l1.4 1.9H20a1.6 1.6 0 0 1 1.6 1.6v8.3A1.6 1.6 0 0 1 20 19H4a1.6 1.6 0 0 1-1.6-1.6V9.1A1.6 1.6 0 0 1 4 7.5Z";function Lr(e){return(0,v.jsxs)(oe,{...e,children:[(0,v.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,v.jsx)("path",{d:"M12 2.5v2M12 19.5v2M2.5 12h2M19.5 12h2M5.3 5.3l1.4 1.4M17.3 17.3l1.4 1.4M5.3 18.7l1.4-1.4M17.3 6.7l1.4-1.4"})]})}o(Lr,"ln");s(Lr,"SunIcon");function Ar(e){return(0,v.jsxs)(oe,{...e,children:[(0,v.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,v.jsx)("path",{d:"M9 10h.01M15 10h.01M8.8 14.6a4.2 4.2 0 0 0 6.4 0"})]})}o(Ar,"un");s(Ar,"FaceUncoveredIcon");function Er(e){return(0,v.jsxs)(oe,{...e,children:[(0,v.jsx)("rect",{x:"7",y:"2.5",width:"10",height:"19",rx:"2"}),(0,v.jsx)("path",{d:"M10.5 18.5h3M2.5 9.5h2.5M19 9.5h2.5"}),(0,v.jsx)("circle",{cx:"12",cy:"9.5",r:"1.6"})]})}o(Er,"dn");s(Er,"PhoneEyeLevelIcon");function Ir(e){return(0,v.jsxs)(oe,{...e,children:[(0,v.jsx)("path",{d:"M2.5 12S6 5.5 12 5.5 21.5 12 21.5 12 18 18.5 12 18.5 2.5 12 2.5 12Z"}),(0,v.jsx)("circle",{cx:"12",cy:"12",r:"2.8"})]})}o(Ir,"pn");s(Ir,"LookStraightIcon");function Ur(e){return(0,v.jsxs)(oe,{...e,children:[(0,v.jsx)("path",{d:Lt}),(0,v.jsx)("path",{d:"M9 13l2 2 4-4"})]})}o(Ur,"fn");s(Ur,"CameraCheckIcon");function jr(e){return(0,v.jsxs)(oe,{...e,children:[(0,v.jsx)("path",{d:Lt}),(0,v.jsx)("path",{d:"M10.2 11.2a1.9 1.9 0 1 1 2.6 1.8c-.5.2-.8.6-.8 1.1v.3M12 16.4h.01"})]})}o(jr,"mn");s(jr,"CameraAskIcon");function Or(e){return(0,v.jsxs)(oe,{...e,children:[(0,v.jsx)("path",{d:Lt}),(0,v.jsx)("path",{d:"M3 3l18 18"})]})}o(Or,"yn");s(Or,"CameraBlockedIcon");function nt({off:e,className:t}){return(0,v.jsxs)(oe,{className:t,children:[(0,v.jsx)("path",{d:"M4.5 9.5v5H8l4 3.5v-12L8 9.5H4.5Z"}),e?(0,v.jsx)("path",{d:"M4 4l16 16"}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("path",{d:"M15.5 9.7a3.6 3.6 0 0 1 0 4.6"}),(0,v.jsx)("path",{d:"M18 7.6a6.6 6.6 0 0 1 0 8.8"})]})]})}o(nt,"Ve");s(nt,"SpeakerIcon");function Pr(e){return(0,v.jsx)(oe,{...e,children:(0,v.jsx)("path",{d:"M5 12.5l4.5 4.5L19 7.5"})})}o(Pr,"gn");s(Pr,"CheckIcon");function Tr(e){return(0,v.jsxs)(oe,{className:e.className??"sekyro-spinner",children:[(0,v.jsx)("circle",{cx:"12",cy:"12",r:"9",opacity:"0.25"}),(0,v.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9"})]})}o(Tr,"hn");s(Tr,"SpinnerIcon");var wt=["light","uncover","eyeLevel","straight"],En={light:{key:"capture.tips.light",icon:s(()=>(0,ee.jsx)(Lr,{}),"icon")},uncover:{key:"capture.tips.uncover",icon:s(()=>(0,ee.jsx)(Ar,{}),"icon")},eyeLevel:{key:"capture.tips.eyeLevel",icon:s(()=>(0,ee.jsx)(Er,{}),"icon")},straight:{key:"capture.tips.straight",icon:s(()=>(0,ee.jsx)(Ir,{}),"icon")}};function Br({tips:e}){let t=Le(),n=(0,Rr.useId)();return e.length===0?null:(0,ee.jsxs)("section",{className:"sekyro-tips","aria-labelledby":n,"data-testid":"sekyro-tips",children:[(0,ee.jsx)("p",{className:"sekyro-tips__title",id:n,children:t("capture.tips.title")}),(0,ee.jsx)("ul",{className:"sekyro-tips__list",children:e.map(r=>{let a=typeof r=="string"?En[r]:void 0,i=typeof r=="string"?r:r.id,l=a!==void 0?a.icon():typeof r=="string"?void 0:r.icon,u=a!==void 0?t(a.key):typeof r=="string"?r:r.text;return(0,ee.jsxs)("li",{className:"sekyro-tips__item",children:[l!=null?(0,ee.jsx)("span",{className:"sekyro-tips__icon","aria-hidden":"true",children:l}):null,(0,ee.jsx)("span",{children:u})]},i)})})]})}o(Br,"Cn");s(Br,"TipList");var In=220;function qr({title:e,description:t,options:n,busy:r,error:a,focus:i,testId:l,look:u="cards",marked:S,onChoose:h}){let w=(0,ye.useId)(),x=bt(),[I,d]=(0,ye.useState)(null),N=(0,ye.useRef)(null);(0,ye.useEffect)(()=>{a!==null&&d(null)},[a]),(0,ye.useEffect)(()=>()=>{N.current!==null&&clearTimeout(N.current)},[]);let R=s(p=>{r||I!==null||(d(p),N.current=setTimeout(()=>{N.current=null,d(null),h(p)},In))},"choose");return(0,B.jsxs)("section",{className:"sekyro-stack sekyro-stack--4 sekyro-choice","aria-labelledby":w,"data-testid":l,children:[(0,B.jsxs)("div",{className:u==="cards"?"sekyro-heading":"sekyro-stack sekyro-stack--1",children:[(0,B.jsx)("h2",{id:w,ref:i?x:void 0,tabIndex:-1,className:"sekyro-text-body",children:e}),t!==void 0&&t!==""?(0,B.jsx)("p",{className:"sekyro-text-muted",children:t}):null]}),a!==null?(0,B.jsx)(se,{tone:"danger",children:(0,B.jsx)("span",{children:a})}):null,u==="buttons"?(0,B.jsx)("div",{className:"sekyro-stack sekyro-stack--3",children:n.map((p,j)=>(0,B.jsx)(X,{kind:j===0?"primary":"ghost",full:!0,disabled:r,"aria-busy":r||void 0,onClick:o(()=>h(p.id),"onClick"),children:p.label},p.id))}):(0,B.jsx)("div",{className:"sekyro-choices",children:n.map(p=>(0,B.jsxs)("button",{type:"button",className:"sekyro-card","aria-pressed":(I??S)===p.id,"aria-busy":r||void 0,disabled:r||I!==null&&I!==p.id,onClick:o(()=>R(p.id),"onClick"),children:[p.glyph!==void 0?(0,B.jsx)("span",{className:"sekyro-card__tile",children:p.glyph}):null,(0,B.jsxs)("span",{className:"sekyro-card__body",children:[(0,B.jsx)("span",{className:"sekyro-card__title",children:p.label}),p.sub!==void 0?(0,B.jsx)("span",{className:"sekyro-card__sub",children:p.sub}):null]}),(0,B.jsx)("span",{className:"sekyro-radio","aria-hidden":"true"})]},p.id))})]})}o(qr,"bn");s(qr,"ChoiceScreen");var Vr=["fcv3.no_face","fcv3.come_closer","fcv3.move_back","fcv3.center_face","fcv3.straighten","fcv3.more_light","fcv3.too_bright","fcv3.hold_still","fcv3.steady_camera","fcv3.hold_upright","fcv3.one_face","capture.tips.summary","capture.lookAtColours"];function st(e){return e!==null&&Vr.includes(e)}o(st,"he");s(st,"isVoiceKey");var Un=s((e,t)=>Object.prototype.hasOwnProperty.call(e,t),"own");function je(e,t,n){let r;try{if(typeof e=="function")r=e(t,n);else{let a=e[n];r=a!=null&&Un(a,t)?a[t]:null}}catch{return null}return typeof r=="string"&&r!==""?r:null}o(je,"Me");s(je,"resolveClip");var jn="UklGRiQAAABXQVZFZm10IBAAAAABAAEAESsAACJWAAACABAAZGF0YQAAAAA=",On={ar:"ar-SA",fr:"fr-FR",en:"en-US",es:"es-ES",pt:"pt-BR",de:"de-DE"};function ae(){return typeof window<"u"&&"speechSynthesis"in window?window.speechSynthesis:null}o(ae,"ne");s(ae,"synth");function Hr(){return ae()!==null&&typeof SpeechSynthesisUtterance=="function"}o(Hr,"Lr");s(Hr,"speechAvailable");function St(e){return(e.split(/[-_]/)[0]??e).toLowerCase()}o(St,"Sn");s(St,"baseLang");function At(e,t){let n=s(a=>a.replace(/_/g,"-").toLowerCase(),"norm"),r=St(t);return e.find(a=>n(a.lang)===n(t))??e.find(a=>St(a.lang)===r)}o(At,"Mn");s(At,"pickVoice");function Dr(e){if(!Hr())return!1;let t=[];try{t=ae()?.getVoices()??[]}catch{return!0}return t.length===0||At(t,e)!==void 0}o(Dr,"wn");s(Dr,"speechUsable");function Fr(e){let t=ae();return t===null||typeof t.addEventListener!="function"?()=>{}:(t.addEventListener("voiceschanged",e),()=>t.removeEventListener?.("voiceschanged",e))}o(Fr,"Ln");s(Fr,"subscribeVoices");function He(e){try{let t=typeof location<"u"?location.href:"http://localhost/",n=new URL(e,t);return`clip:${n.origin}${n.pathname}`}catch{return`clip:${e}`}}o(He,"Ke");s(He,"clipIdentity");function xt(e){e.pause(),e.removeAttribute("src"),e.load()}o(xt,"Rn");s(xt,"release");function $r(){let e=null,t=null,n=0,r=null,a=[],i=new Map,l=s(()=>{a=ae()?.getVoices()??[]},"loadVoices"),u=!1,S=s(()=>{let d=ae();u||d===null||(u=!0,l(),d.addEventListener?.("voiceschanged",l))},"bindVoices"),h=s(()=>(e??(e=new Audio),e),"element"),w=s((d,N,R)=>{let p=ae();if(p!==null&&d!==""&&typeof SpeechSynthesisUtterance=="function"){S();let j=At(a,N);if(a.length===0||j!==void 0){p.cancel();let _=new SpeechSynthesisUtterance(d);_.lang=N,j!==void 0&&(_.voice=j),_.rate=.95,R!==void 0&&(_.onend=_.onerror=R),p.speak(_);return}}R?.()},"speak"),x=s(()=>{n+=1,r=null,e!==null&&(e.pause(),e.currentTime=0),ae()?.cancel()},"stop"),I=s(d=>{for(let N of d){let R=He(N);if(i.has(R))continue;let p=new Audio;p.preload="auto",p.src=N,i.set(R,p)}},"warmClips");return{say(d){let N=d.url!==null?He(d.url):`tts:${d.lang}:${d.text}`;if(N===r)return;r=N,n+=1;let R=n,p=d.onEnd,j=p!==void 0?()=>{R===n&&p()}:void 0;if(ae()?.cancel(),d.url!==null){let _=h();_.pause(),_.muted=!1,_.src=d.url,_.currentTime=0,_.onended=j??null,_.play()?.catch(A=>{R===n&&A?.name!=="AbortError"&&(d.speech?w(d.text,d.lang,j):j?.())});return}d.speech?w(d.text,d.lang,j):j?.()},unlock({lang:d,speech:N,prefetch:R}){let p=h();if(t===null&&typeof Blob=="function"&&typeof URL.createObjectURL=="function"){let A=Uint8Array.from(atob(jn),q=>q.charCodeAt(0));t=URL.createObjectURL(new Blob([A],{type:"audio/wav"}))}let j=p.paused===!1&&t!==null&&p.src!==t;t!==null&&!j&&(p.muted=!0,p.onended=null,p.src=t,p.play()?.catch(()=>{}));let _=ae();if(N&&_!==null&&typeof SpeechSynthesisUtterance=="function"){S();let A=new SpeechSynthesisUtterance(" ");A.volume=0,A.lang=d,_.speak(A)}I(R??[])},prefetch:I,stop:x,dispose(){x(),u&&ae()?.removeEventListener?.("voiceschanged",l),u=!1,t!==null&&URL.revokeObjectURL(t),t=null,e!==null&&xt(e),e=null;for(let d of i.values())xt(d);i.clear()}}}o($r,"_n");s($r,"createVoicePlayer");var Pn="sekyro.voiceGuidance";function Gr(e){try{if(typeof window>"u")return null;let t=window.localStorage.getItem(e);return t==="1"?!0:t==="0"?!1:null}catch{return null}}o(Gr,"xn");s(Gr,"readVoicePreference");function Kr(e,t){try{if(typeof window>"u")return;window.localStorage.setItem(e,t?"1":"0")}catch{}}o(Kr,"En");s(Kr,"writeVoicePreference");var Ve="capture.tips.summary",Tn=typeof window<"u"?C.useLayoutEffect:C.useEffect,Bn=Object.freeze({});function rt(e,t){let n=new Set,r=[];for(let a of Vr){let i=a===Ve?null:je(e,a,t);i===null||n.has(He(i))||(n.add(He(i)),r.push(i))}return r}o(rt,"ht");s(rt,"resolvedClipUrls");function zr({locale:e,defaultClips:t,options:n}){let r=n===!1,a=r?{}:n??{},i=a.storageKey===void 0?Pn:a.storageKey,[l,u]=(0,C.useState)(a.defaultEnabled??!0),S=(0,C.useRef)(l),[h,w]=(0,C.useState)(!1),[x,I]=(0,C.useState)("none"),[d,N]=(0,C.useState)(!1),R=(0,C.useRef)(!1),[p,j]=(0,C.useState)(0),_=(0,C.useRef)(null),A=(0,C.useCallback)(()=>(_.current??(_.current=$r()),_.current),[]),q=On[e],F=a.speechFallback,f=F===void 0||F===!0?!0:F===!1?!1:F.includes(e),G=a.clips??t??Bn,ie=(0,C.useRef)(!1),le=(0,C.useRef)(G);Tn(()=>{le.current=G,S.current=l}),(0,C.useEffect)(()=>{if(r||i===null)return;let L=Gr(i);L!==null&&(S.current=L,u(L))},[r,i]),(0,C.useEffect)(()=>{if(!(r||!f))return Fr(()=>j(L=>L+1))},[r,f]);let c=a.clips;(0,C.useEffect)(()=>{if(r)return;let L=f&&Dr(q);w(rt(G,e).length>0||L),I(c!==void 0&&je(c,Ve,e)!==null?"partner":je(G,Ve,e)!==null||L?"default":"none")},[r,G,c,e,f,q,p]),(0,C.useEffect)(()=>{if(r||!l||!ie.current)return;let L=rt(G,e);L.length>0&&A().prefetch(L)},[r,l,G,e,A]),(0,C.useEffect)(()=>()=>{_.current?.dispose(),_.current=null,ie.current=!1},[]);let V=(0,C.useCallback)(L=>{r||(ie.current=!0,A().unlock({lang:q,speech:f,...L?{prefetch:rt(le.current,e)}:{}}))},[r,A,q,f,e]),O=(0,C.useCallback)(()=>V(S.current),[V]),K=(0,C.useCallback)(()=>{R.current=!1,N(!1)},[]),T=(0,C.useCallback)(()=>{K(),_.current?.stop()},[K]),ve=(0,C.useCallback)(()=>{R.current&&T()},[T]),he=(0,C.useCallback)((L,xe)=>{if(r)return;if(R.current){T();return}let ge=A();ge.stop(),R.current=!0,N(!0);let P=xe?.clip===!1?null:je(le.current,Ve,e);ge.say({url:P,text:L,lang:q,speech:f,onEnd:K})},[r,T,A,e,q,f,K]),z=(0,C.useCallback)(L=>{r||(L?V(!0):T(),i!==null&&Kr(i,L),S.current=L,u(L))},[r,V,T,i]),Z=(0,C.useCallback)(()=>z(!S.current),[z]),te=(0,C.useCallback)((L,xe)=>{if(r||!l)return;R.current&&K();let ge=je(le.current,L,e);A().say({url:ge,text:xe,lang:q,speech:f})},[r,l,e,A,q,f,K]);return(0,C.useMemo)(()=>({supported:!r&&h,enabled:!r&&l,setEnabled:z,toggle:Z,unlock:O,speakKey:te,stop:T,summary:r?"none":x,summaryPlaying:d,toggleSummary:he,stopSummary:ve}),[r,h,l,z,Z,O,te,T,x,d,he,ve])}o(zr,"vt");s(zr,"useVoiceGuidance");function Zr(e,t,n,r){let{speakKey:a,stop:i,enabled:l}=e,u=(0,C.useRef)(!1);(0,C.useEffect)(()=>{if(!r||!l){u.current&&i(),u.current=!1;return}u.current=!0,st(t)&&t!==Ve&&n!==""&&a(t,n)},[r,l,t,n,a,i])}o(Zr,"Ct");s(Zr,"useSpeakGuidance");function ot(e){switch(e){case"multiple_faces":return"one_face";case"capture_back_camera":return"front_camera";case"capture_front_camera":return"back_camera";case"capture_not_upright":return"upright";case"media_unreadable":case"clip_too_short":return"recording";case"device_integrity_failed":return"device";default:return"face"}}o(ot,"Pn");s(ot,"retryCoachingOf");var De={face:{title:"capture.retryCoaching.title",tips:["capture.retryCoaching.light","capture.retryCoaching.eyeLevel","capture.retryCoaching.head"]},one_face:{title:"capture.retryTips.title",tips:["capture.retryOneFace.alone","capture.retryOneFace.screens"]},front_camera:{title:"capture.retryTips.title",tips:["capture.retryFrontCamera.screenSide"]},back_camera:{title:"capture.retryTips.title",tips:["capture.retryBackCamera.backSide","capture.retryBackCamera.circle"]},upright:{title:"capture.retryTips.title",tips:["capture.retryUpright.vertical","capture.retryUpright.untilEnd"]},recording:{title:"capture.retryTips.title",tips:["capture.retryRecording.cameraOn","capture.retryRecording.stay","capture.retryRecording.network"]},device:{title:"capture.retryTips.title",tips:["capture.retryDevice.screenRecording","capture.retryDevice.phone"]}};function Qr({showCoaching:e,coaching:t="face",attemptsText:n,showRetake:r,onRetake:a}){let i=Le(),l=(0,at.useRef)(null);return(0,at.useEffect)(()=>{r&&l.current?.focus()},[r]),!e&&!r?null:(0,fe.jsxs)("div",{className:"sekyro-stack sekyro-stack--3","data-testid":"sekyro-captured-panel",children:[e?(0,fe.jsxs)("div",{className:"sekyro-stack sekyro-stack--1",children:[(0,fe.jsx)("p",{className:"sekyro-text-body",children:i(De[t].title)}),(0,fe.jsx)("ul",{className:"sekyro-coaching",children:De[t].tips.map(u=>(0,fe.jsx)("li",{children:i(u)},u))}),n!==null?(0,fe.jsx)("p",{className:"sekyro-text-muted","data-testid":"sekyro-attempts-remaining",children:n}):null]}):null,r?(0,fe.jsx)(X,{ref:l,className:"sekyro-btn--start",onClick:a,children:i("capture.recordAgain")}):null]})}o(Qr,"Tn");s(Qr,"CapturedPanel");function Et(){try{return!1}catch{return!1}}o(Et,"nt");s(Et,"isDevBuild");var qn=(0,Wr.createContext)(null);function Yr({state:e}){let t=Le(),[n,r]=(0,it.useState)(!1);(0,it.useEffect)(()=>{e!=="unknown"&&r(!0)},[e]);let a=e==="granted"?(0,we.jsx)(Ur,{}):e==="denied"?(0,we.jsx)(Or,{}):(0,we.jsx)(jr,{});return(0,we.jsxs)("div",{role:n?"status":void 0,className:`sekyro-permission sekyro-permission--${e}`,"data-testid":"sekyro-permission","data-state":e,children:[(0,we.jsx)("span",{className:"sekyro-permission__icon","aria-hidden":"true",children:a}),(0,we.jsx)("span",{children:t(`capture.permission.${e}`)})]})}o(Yr,"On");s(Yr,"PermissionRow");function Jr({voice:e}){let t=Le();if(!e.supported)return null;let n=e.enabled;return(0,Se.jsxs)("button",{type:"button",role:"switch","aria-checked":n,className:"sekyro-switch","data-testid":"sekyro-voice-switch",onClick:o(()=>e.toggle(),"onClick"),children:[(0,Se.jsxs)("span",{className:"sekyro-switch__label",children:[(0,Se.jsx)(nt,{off:!n}),t("capture.voiceGuidance")]}),(0,Se.jsx)("span",{className:"sekyro-switch__track","aria-hidden":"true",children:(0,Se.jsx)("span",{className:"sekyro-switch__thumb",children:n?(0,Se.jsx)(Pr,{className:"sekyro-switch__check"}):null})})]})}o(Jr,"Hn");s(Jr,"VoiceSwitch");function Xr({assets:e,onRetryAssets:t,permission:n,captureMode:r="self",voice:a,tips:i,summary:l,startLabel:u,startDisabled:S,onStart:h}){let w=Le(),x=(0,Y.useRef)(l?.stop);x.current=l?.stop,(0,Y.useEffect)(()=>()=>x.current?.(),[]);let I=(0,Y.useRef)(null),d=(0,Y.useRef)(null),N=(0,Y.useRef)(null),R=(0,Y.useRef)(e),p=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>{let f=R.current;if(R.current=e,f===e)return;let G=p.current;e!=="loading"&&(p.current=!1),en(I.current)&&(e==="failed"?N.current?.focus():G&&d.current?.focus())},[e]);let j=(0,Y.useCallback)(()=>{p.current=!0,t()},[t]),_=e==="loading",A=_||S,q=(0,Y.useCallback)(()=>{A||(x.current?.(),h())},[A,h]),F;return e==="failed"?F=(0,U.jsxs)(se,{tone:"danger",testId:"sekyro-assets-error",children:[(0,U.jsx)("p",{className:"sekyro-text-body",children:w("fcv2.err.models")}),(0,U.jsx)(X,{kind:"ghost",ref:N,className:"sekyro-btn--start",onClick:j,"data-testid":"sekyro-assets-retry",children:w("common.retry")})]}):F=(0,U.jsxs)("div",{className:"sekyro-stack sekyro-stack--1",children:[(0,U.jsx)(X,{ref:d,full:!0,"data-testid":"sekyro-start","aria-disabled":A?"true":void 0,"aria-busy":_?"true":void 0,onClick:q,children:_?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Tr,{}),w("capture.preparing.title")]}):u??w("capture.start")}),_?(0,U.jsx)("p",{className:"sekyro-text-muted",children:w("capture.preparing.hint")}):null]}),(0,U.jsxs)("div",{ref:I,className:"sekyro-stack sekyro-stack--4","data-testid":"sekyro-intro","data-assets":e,children:[r==="assisted"?(0,U.jsxs)("div",{className:"sekyro-stack sekyro-stack--1","data-testid":"sekyro-assisted-intro",children:[(0,U.jsx)("h2",{className:"sekyro-text-body",children:w("capture.assisted.title")}),(0,U.jsx)("p",{className:"sekyro-text-muted",children:w("capture.assisted.lead")})]}):null,i!==!1?(0,U.jsx)(Br,{tips:i}):null,l!==void 0?(0,U.jsxs)(X,{kind:"ghost",className:"sekyro-btn--start",onClick:l.toggle,"data-testid":"sekyro-tips-listen",children:[(0,U.jsx)(nt,{off:!1}),w(l.playing?"capture.tips.stop":"capture.tips.listen")]}):null,(0,U.jsx)(Yr,{state:n}),(0,U.jsx)(Jr,{voice:a}),(0,U.jsx)("p",{className:"sekyro-text-muted",children:w("capture.securityNote")}),F,(0,U.jsx)("p",{role:"status",className:"sekyro-visually-hidden","data-testid":"sekyro-intro-status",children:e==="loading"?w("capture.preparing.title"):e==="ready"?w("capture.ready"):""})]})}o(Xr,"Fn");s(Xr,"PreCaptureScreen");function en(e){if(typeof document>"u")return!1;let t=document.activeElement;return t===null||t===document.body||e!==null&&e.contains(t)}o(en,"Ur");s(en,"focusIsOurs");function tn(){let[e,t]=(0,lt.useState)({state:"unknown",settled:!1});return(0,lt.useEffect)(()=>ir(n=>t({state:n,settled:!0})),[]),{permission:e.state,permissionSettled:e.settled}}o(tn,"Dn");s(tn,"useCameraStatus");function rn(e){return It(e,"mobileRequired")}o(rn,"qn");s(rn,"useMobileRequired");function nn(e){return It(e,"returning").required}o(nn,"jn");s(nn,"useReturning");function It(e,t){let[n,r]=(0,pe.useState)({required:!1,settled:e===void 0});return(0,pe.useEffect)(()=>{let a=e?.[t];if(e===void 0||typeof a!="function"){r({required:!1,settled:!0});return}let i=!0;return r({required:!1,settled:!1}),Promise.resolve().then(()=>a.call(e)).then(l=>{i&&r({required:l===!0,settled:!0})},()=>{i&&r({required:!1,settled:!0})}),()=>{i=!1}},[e,t]),n}o(It,"Yn");s(It,"useFlag");function sn(e){let t=s(()=>e?.captureChoice??null,"initialChoice"),[n,r]=(0,pe.useState)(()=>({session:"self",choice:t(),settled:e===void 0}));(0,pe.useEffect)(()=>{let i=e?.captureMode,l=e?.captureChoice??null;if(e===void 0||typeof i!="function"){r({session:"self",choice:l,settled:!0});return}let u=!0;return r({session:"self",choice:l,settled:!1}),Promise.resolve().then(()=>i.call(e)).then(S=>{let h=e.captureChoice??null;u&&r({session:h!==null&&S===h?"choice":S==="assisted"||S==="choice"?S:"self",choice:h,settled:!0})},()=>{u&&r({session:"self",choice:null,settled:!0})}),()=>{u=!1}},[e]);let a=(0,pe.useCallback)(i=>{e?.chooseCaptureMode?.(i),r(l=>({...l,choice:i}))},[e]);return{mode:n.session==="choice"?n.choice??"self":n.session==="assisted"?"assisted":"self",session:n.session,choice:n.choice,settled:n.settled,choose:a}}o(sn,"$n");s(sn,"useCaptureMode");function an(e){let[t,n]=(0,pe.useState)(!1);return(0,pe.useEffect)(()=>{if(n(!1),e===void 0)return;let r=e.on("busy",()=>n(!0)),a=e.on("result",()=>n(!1));return()=>{r(),a()}},[e]),t}o(an,"zn");s(an,"useBusy");var Vn=s(()=>"idle","serverSnapshot");function Nt(e){return lr(e!==void 0?{assetBaseUrl:e}:{})}o(Nt,"Qn");s(Nt,"preload");function on(e,t=!0){let n=(0,Q.useSyncExternalStore)((0,Q.useCallback)(h=>ur(h,e),[e]),()=>cr(e),Vn),[r,a]=(0,Q.useState)(null),i=(0,Q.useRef)(!1),l=(0,Q.useCallback)(()=>{Nt(e).then(h=>{i.current&&h==="idle"&&a({base:e})})},[e]);(0,Q.useEffect)(()=>(i.current=!0,l(),()=>{i.current=!1}),[l]);let u=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(n!=="idle"){u.current={base:e};return}!t||u.current===null||u.current.base!==e||(u.current=null,l())},[n,e,l,t]);let S=(0,Q.useCallback)(()=>{Nt(e)},[e]);return{gate:r!==null&&r.base===e&&n==="idle"||n==="ready"?"ready":n==="failed"?"failed":"loading",retry:S}}o(on,"Jn");s(on,"useLivenessAssets");var Mr={progress:0,hint:null,faceDetected:!1};function ln(e){let{videoRef:t,assetBaseUrl:n}=e,r=(0,M.useRef)(e.verification).current,a=(0,M.useRef)(!1);e.verification!==r&&!a.current&&Et()&&(a.current=!0,console.warn("[@sekyro/react] <LivenessCapture>: the `verification` prop changed identity after mount. The first instance stays bound (the camera is not rebuilt); create the verification once (useMemo / useState / outside render) instead of on every render."));let i=(0,M.useRef)(null),[l,u]=(0,M.useState)("idle"),[S,h]=(0,M.useState)(Mr),[w,x]=(0,M.useState)(!1),[I,d]=(0,M.useState)(!1),[N,R]=(0,M.useState)(null),[p,j]=(0,M.useState)(!1),[_,A]=(0,M.useState)(null),[q,F]=(0,M.useState)(null),[f,G]=(0,M.useState)(null),[ie,le]=(0,M.useState)(null),[c,V]=(0,M.useState)(null),[O,K]=(0,M.useState)(!1),T=(0,M.useRef)(null),ve=(0,M.useRef)("idle"),he=(0,M.useRef)(-1),[z,Z]=(0,M.useState)(0),te=(0,M.useRef)(e);te.current=e,(0,M.useEffect)(()=>{let J=t.current;if(J===null)return;let ce={video:J,...n!==void 0?{assetBaseUrl:n}:{}},H=r!==void 0?r.liveness(ce):dr(ce);i.current=H;let Ne=s(()=>V(H.facingMode??null),"readFacing");Ne();let Fe=[H.on("state",b=>{b==="mode_switch"?K(!0):b!=="starting"&&b!=="gating"&&K(!1),b==="starting"?(ve.current!=="starting"&&(he.current+=1,Z(Math.max(0,he.current))),F(null),G(null),h(Mr),d(!1),x(!1),R(null),A(null),T.current=null):b==="gating"&&ve.current==="recording"&&(d(!1),x(!1),R(null),T.current=null),ve.current=b,Ne(),u(b),te.current.onStateChange?.(b)}),H.on("gate",b=>{let ke=T.current;T.current=b.progress,x(ke!==null&&b.progress<ke-.001&&b.progress>0&&b.progress<1),b.progress>=1&&d(!0),h(b)}),H.on("frozen",({previewDataUrl:b})=>R(b)),H.on("profile",({animations:b})=>j(b==="reduced")),H.on("ramp",({colour:b})=>A(b)),H.on("captured",b=>{F(b),le(null),te.current.onCaptured?.(b)}),H.on("error",b=>{G(b);let ke=r?.reportCaptureIssue;ke!==void 0&&Ct(Ee=>ke.call(r,Ee),xr("liveness",b,Math.max(0,he.current))),te.current.onError?.(b)}),r?.on("result",b=>{le(b),te.current.onResult?.(b)})];return()=>{for(let b of Fe)b?.();i.current=null,H.destroy()}},[r,t,n]);let L=(0,M.useCallback)(()=>{i.current?.start()},[]),xe=(0,M.useCallback)(()=>{i.current?.retry()},[]),ge=(0,M.useCallback)(async()=>{let J=i.current;return J===null||typeof J.canSwitchCaptureMode!="function"?!1:await J.canSwitchCaptureMode().catch(()=>!1)===!0},[]),P=(0,M.useCallback)(async J=>{let ce=i.current;if(ce===null||typeof ce.setCaptureMode!="function")return!1;let H=await ce.setCaptureMode(J).catch(()=>!1)===!0;return H&&V(ce.facingMode??null),H},[]);return{state:l,gate:S,draining:w,gateLocked:I,frozenPreview:N,reduceMotion:p,rampColour:_,artifacts:q,error:f,result:ie,facingMode:c,start:L,retry:xe,canSwitchCaptureMode:ge,setCaptureMode:P,modeRestarted:O,attempt:z}}o(ln,"er");s(ln,"useLivenessHandle");var Hn=new Set(["national_number"]);function Mt(e){if(e==null||!e.available||e.selected!==null)return null;let t=e.options.filter(n=>Hn.has(n));return t.length>0?{...e,options:t}:null}o(Mt,"tr");s(Mt,"pending");function cn(e){let[t,n]=(0,me.useState)(null),[r,a]=(0,me.useState)(e===void 0),[i,l]=(0,me.useState)(!1),[u,S]=(0,me.useState)(!1);(0,me.useEffect)(()=>{if(n(null),e===void 0){a(!0);return}let x=!0,I=e.methodChoice;typeof I=="function"?(a(!1),Promise.resolve().then(()=>I.call(e)).then(N=>{x&&n(Mt(N))},()=>{}).finally(()=>{x&&a(!0)})):a(!0);let d=e.on("method",N=>n(Mt(N)));return()=>{x=!1,d()}},[e]);let h=(0,me.useCallback)(async x=>{if(e===void 0)return!1;l(!0),S(!1);try{return await e.selectMethod(x),n(null),!0}catch{return S(!0),!1}finally{l(!1)}},[e]),w=t!==null&&t.options.length===1?t.options[0]:null;return{choice:t,auto:w==="national_number"&&!u?w:null,settled:r,busy:i,failed:u,select:h}}o(cn,"nr");s(cn,"useMethodChoice");var Dn=["ar","fr","en"];function un(e){if(typeof e!="string")return!1;try{let t=new URL(e);return t.protocol==="https:"||t.protocol==="http:"&&/^(localhost|127\.0\.0\.1)$/.test(t.hostname)}catch{return!1}}o(un,"so");s(un,"isClipUrl");function dn(e){let t=e.clips;if(typeof t!="object"||t===null)return null;let n={};for(let r of Dn){let a=t[r];if(!(typeof a!="object"||a===null))for(let[i,l]of Object.entries(a))!st(i)||!un(l)||((n[r]??(n[r]={}))[i]=l)}return Object.keys(n).length>0?n:null}o(dn,"io");s(dn,"toVoiceClipMap");function pn(e){let[t,n]=(0,Oe.useState)(null);(0,Oe.useEffect)(()=>{if(n(null),e===void 0)return;let a=!0,i=s(u=>{if(!a)return;let S=typeof u=="object"&&u!==null&&typeof u.setId=="string"?u:null;n(h=>h?.setId===S?.setId?h:S)},"take");try{typeof e.voiceClips=="function"&&Promise.resolve(e.voiceClips()).then(i,()=>i(null))}catch{i(null)}let l=e.on("view",u=>i(u.voice));return()=>{a=!1,l()}},[e]);let r=(0,Oe.useMemo)(()=>t!==null?dn(t):null,[t]);return e===void 0?null:r}o(pn,"rr");s(pn,"useServerVoiceClips");function hn({voice:e}){let t=Le();return(0,Rt.jsx)(X,{kind:"chip","aria-pressed":e.enabled,"aria-label":t("capture.voiceGuidance"),"data-testid":"sekyro-voice-toggle",onClick:o(()=>e.toggle(),"onClick"),children:(0,Rt.jsx)(nt,{off:!e.enabled,className:"sekyro-icon"})})}o(hn,"sr");s(hn,"VoiceChip");var Fn=new Set(["abandoned","not_opened","cancelled","superseded"]),$n=800,Gn="capture.lookAtColours";function fn(e){return e===void 0||e!==!1&&e.length===wt.length&&wt.every(t=>e.includes(t))}o(fn,"fo");s(fn,"isDefaultTips");function mn(e){if(e.type==="keydown"&&e.key==="Escape")return!1;let t=globalThis.navigator?.userActivation;return t===void 0?!(e.type==="pointerup"&&e.pointerType==="touch"):t.isActive}o(mn,"mo");s(mn,"carriesActivation");function yn(e){return typeof e=="object"&&e!==null&&!(0,y.isValidElement)(e)&&"tone"in e&&"text"in e}o(yn,"yo");s(yn,"isNoticeObject");var Kn=new Set(["nni_unbound","id_number_unbound","method_required","mobile_required","portrait_required"]);function vn(e){return e==="starting"||e==="gating"||e==="recording"||e==="mode_switch"}o(vn,"ho");s(vn,"isCapturing");function gn(e){return e==="captured"||e==="uploading"||e==="checking"}o(gn,"vo");s(gn,"isPostCapture");function zn({verification:e,locale:t,dir:n,strings:r,slots:a,autoStart:i=!1,notice:l,startDisabled:u=!1,startLabel:S,tips:h,tipsSummary:w,coach:x,voice:I,onGuidance:d,onCaptured:N,onResult:R,onError:p,onStateChange:j,assetBaseUrl:_,className:A}){let q=vr(t),F=(0,y.useMemo)(()=>yr(t,r),[t,r,q]),f=(0,y.useMemo)(()=>g=>F[g]??"",[F]),G=n??(t==="ar"?"rtl":"ltr"),ie=(0,y.useRef)(null),le=(0,y.useContext)(qn),c=ln({verification:e,videoRef:ie,assetBaseUrl:_,onCaptured:N,onResult:R,onError:p,onStateChange:j}),V=on(_,c.state==="idle"&&c.error===null),O=cn(e),K=O.choice!==null,T=rn(e),ve=nn(e),he=an(e),z=tn(),Z=sn(e),te=Z.session==="choice",L=Z.mode==="assisted",xe=I!==!1&&I?.clips===void 0,ge=pn(xe?e:void 0),P=zr({locale:t,defaultClips:ge,options:I}),J=L?"environment":"user",ce=Z.settled,H=(0,y.useRef)(null),Ne=(0,y.useRef)(!1),Fe=(0,y.useRef)(P.unlock);Fe.current=P.unlock,(0,y.useEffect)(()=>{let g=H.current;if(g===null)return;let ne=["pointerup","touchend","click","keydown"],_e=s(()=>{for(let qe of ne)g.removeEventListener(qe,Re,!0)},"disarm");function Re(qe){if(Ne.current){_e();return}mn(qe)&&(Ne.current=!0,_e(),Fe.current())}o(Re,"Re"),s(Re,"onGesture");for(let qe of ne)g.addEventListener(qe,Re,{capture:!0,passive:!0});return _e},[]);let b=(0,y.useCallback)(()=>{Ne.current||(Ne.current=!0,P.unlock()),c.start()},[P.unlock,c.start]),ke=(0,y.useCallback)(()=>c.start(),[c.start]),Ee=(0,y.useRef)(!1),Pe=c.state==="idle"&&c.error===null,jt=!K&&!T.required&&(i===!0||i==="when-permitted"&&z.permission==="granted"),Ot=jt&&O.settled&&T.settled&&ce,Cn=i==="when-permitted"&&!z.permissionSettled&&!Ee.current,Pt=jt&&Pe&&!Ee.current,ut=(Cn||Pt||!ce)&&V.gate==="ready"?"loading":V.gate;(0,y.useEffect)(()=>{!Ot||!Pe||V.gate!=="ready"||Ee.current||(Ee.current=!0,ke())},[Ot,Pe,V.gate,ke]);let _n=Pe&&!K&&!T.required&&!(Pt&&V.gate==="ready"),[Tt,Bt]=(0,y.useState)(!1),{canSwitchCaptureMode:qt,setCaptureMode:Vt}=c;(0,y.useEffect)(()=>{if(!Z.settled||!te){Bt(!1);return}let g=!0;return qt().then(ne=>{g&&Bt(ne)}),()=>{g=!1}},[Z.settled,te,qt]);let{choose:Ht}=Z,Ie=L?"self":"assisted",wn=(0,y.useCallback)(async()=>{await Vt(Ie)&&Ht(Ie)},[Vt,Ht,Ie]),Dt=c.state!=="idle"&&c.facingMode!==null?c.facingMode:J;(0,y.useEffect)(()=>{let g=ie.current?.style;Dt==="user"?g?.removeProperty("transform"):g&&(g.transform="none")},[Dt]);let $e=(0,y.useMemo)(()=>c.artifacts!==null&&typeof URL.createObjectURL=="function"?URL.createObjectURL(c.artifacts.keyframe):null,[c.artifacts]);(0,y.useEffect)(()=>{if($e!==null)return()=>URL.revokeObjectURL($e)},[$e]);let Ft=c.frozenPreview??$e,Ue=e!==void 0,$=vn(c.state),be=gn(c.state),Ge=$||be,re=c.result,$t=c.state==="done"&&re!==null,Ke=$&&c.rampColour!==null,dt=c.state==="recording"&&c.frozenPreview!==null&&!Ke,ze=le!==null,Gt=Tt&&$&&!dt?{to:Ie,label:f(Ie==="assisted"?"capture.modeSwitch.toAssisted":"capture.modeSwitch.toSelf"),description:f(Ie==="assisted"?"capture.modeSwitch.toAssistedLabel":"capture.modeSwitch.toSelfLabel"),onSwitch:s(()=>{wn()},"onSwitch")}:null,Ze=c.modeRestarted&&$?f("capture.modeSwitch.restarted"):null,Te=be||dt,Kt=be?"checking":dt?"frozen":c.state==="recording"||Ke?"recording":c.gateLocked||c.gate.progress>=1?"locked":c.gate.faceDetected?"aligning":"seeking",Qe=$?c.gate.hint:null,We=c.state==="starting"?"capture.preparing.title":Qe===null?null:Qe==="center"&&!c.gate.faceDetected?"fcv3.no_face":pr(Qe),[Sn,zt]=(0,y.useState)(null);(0,y.useEffect)(()=>{if(We!=="fcv3.no_face"){zt(We);return}if(!$)return;let g=setTimeout(()=>zt(We),$n);return()=>clearTimeout(g)},[We,$]);let pt=$&&!Ke&&typeof x=="string"&&x!=="",Zt=L&&$?f("capture.assisted.stage"):null,Me=$&&!pt?Ke?Gn:Sn:null,ht=pt?x:Me===null?"":f(Me);Zr(P,Me,ht,$);let Qt=(0,y.useRef)(d);Qt.current=d,(0,y.useEffect)(()=>{if(st(Me))try{Qt.current?.(Me)}catch(g){console.error("[@sekyro/react] onGuidance threw:",g)}},[Me]);let Be=(0,y.useMemo)(()=>({supported:P.supported,enabled:P.enabled,setEnabled:P.setEnabled,toggle:P.toggle}),[P.supported,P.enabled,P.setEnabled,P.toggle]),ft=a?.voicePrompt,Wt=ft!==void 0,Yt=I===void 0,Jt=(0,y.useRef)(!1);(0,y.useEffect)(()=>{!Wt||!Yt||Jt.current||!Et()||(Jt.current=!0,console.warn("[@sekyro/react] <LivenessCapture>: `slots.voicePrompt` is set and `voice` is undefined, so the component speaks the guidance itself. If your slot plays audio, pass voice={false} or the person hears every hint twice; pass voice={{}} to keep the built-in voice and silence this warning."))},[Wt,Yt]);let xn=ft!==void 0?(g,ne,_e)=>ft(g,ne,_e,Be):P.supported?()=>(0,k.jsx)(hn,{voice:Be}):void 0,{summary:mt,summaryPlaying:Xt,toggleSummary:er,stopSummary:tr}=P,Ye=w!==void 0&&w!=="",rr=Ye?w:f("capture.tips.summary"),nr=Ye?mt!=="none":mt==="partner"||mt==="default"&&fn(h),Nn=(0,y.useMemo)(()=>nr?{playing:Xt,toggle:s(()=>er(rr,{clip:!Ye}),"toggle"),stop:tr}:void 0,[nr,Xt,er,rr,tr,Ye]),Mn=(0,y.useMemo)(()=>({assets:ut,retryAssets:V.retry,permission:z.permission,permissionSettled:z.permissionSettled,captureMode:Z.mode,facing:J,voice:Be}),[ut,V.retry,z.permission,z.permissionSettled,Z.mode,J,Be]),Rn=yn(l)?(0,k.jsx)(se,{tone:l.tone,testId:"sekyro-host-notice",children:(0,k.jsx)("span",{children:l.text})}):l??null,ue=re!==null&&re.status==="retry"?re:null,W=$t&&re.status==="unavailable"&&!K&&re.reasonCode!=="portrait_required"?re:null,Ce=$t&&(re.status==="verified"||re.status==="not_verified"||re.status==="review")?re:null,yt=s((g,ne)=>{if(g===void 0)return null;if(g==="device_cooldown"){let Re=fr(t,ne);if(Re!==null)return f(Re.key).replace("{time}",Re.time)}let _e=et(g);return _e===null?null:f(_e)},"reasonText"),vt=s(g=>{let ne=g.retakeHint===void 0?null:Xe(g.retakeHint);return ne===null?yt(g.reasonCode):f(ne)},"retryText"),sr=Ce===null?null:yt(Ce.reasonCode,Ce.retryAfter)??(Ce.status==="not_verified"&&Ce.reason!==void 0&&Fn.has(Ce.reason)?f("errors.session_expired"):null),Ln=W!==null&&W.reasonCode!==void 0&&W.reasonCode!=="nni_unbound"&&W.reasonCode!=="id_number_unbound"&&W.reasonCode!=="method_required"&&W.reasonCode!=="mobile_required"&&!(W.reasonCode==="no_recorder"&&c.artifacts?.degraded==="NO_RECORDER"),Je=W?.reasonCode,ar=c.attempt;(0,y.useEffect)(()=>{W===null||Je===void 0||e?.reportCaptureIssue===void 0||Kn.has(Je)||Ct(g=>e.reportCaptureIssue?.(g),{check:"liveness",kind:"unavailable",phase:"upload",engineKind:Je,attempt:Math.min(1e3,ar)})},[W,Je,ar,e]);let or=bt(),An=K&&O.auto===null&&!$&&!be&&c.error===null,gt=(0,y.useCallback)(async g=>{await O.select(g)&&c.state==="done"&&c.retry()},[O.select,c.state,c.retry]);return(0,y.useEffect)(()=>{O.auto!==null&&!O.busy&&!$&&!be&&gt(O.auto)},[O.auto,O.busy,$,be,gt]),(0,k.jsx)(gr,{value:f,children:(0,k.jsxs)("div",{ref:H,className:A===void 0?"sekyro-capture":`sekyro-capture ${A}`,dir:G,lang:t,"data-testid":"sekyro-liveness-capture","data-state":c.state,children:[a?.header,ue!==null&&vt(ue)!==null&&!(ze&&Ge)?(0,k.jsx)(se,{tone:"warning",role:"status",testId:"sekyro-retry-notice",children:(0,k.jsx)("span",{children:vt(ue)})}):null,Ze!==null&&!ze?(0,k.jsx)(se,{tone:"info",role:"status",testId:"sekyro-mode-switch-status",children:(0,k.jsx)("span",{children:Ze})}):null,he&&be&&!ze?(0,k.jsx)(se,{tone:"info",role:"status",testId:"sekyro-busy-notice",children:(0,k.jsx)("span",{children:f("capture.busy")})}):null,T.required&&Pe?(0,k.jsx)(se,{tone:"info",role:"status",testId:"sekyro-mobile-required",children:(0,k.jsx)("span",{children:f("reasons.mobile_required")})}):null,c.error!==null?a?.errorPanel!==void 0?a.errorPanel(c.error,c.retry):(0,k.jsxs)(se,{tone:"danger",testId:"sekyro-error-notice",children:[(0,k.jsx)("span",{children:f(hr(c.error))}),c.error.retryable?(0,k.jsx)(X,{ref:or,kind:"ghost",className:"sekyro-btn--start",onClick:c.retry,children:f("common.retry")}):null]}):null,W!==null?(0,k.jsxs)(se,{tone:"danger",testId:"sekyro-unavailable-notice",children:[(0,k.jsx)("span",{children:yt(W.reasonCode)??f(W.reasonCode===void 0?"errors.session_expired":"errors.network_error")}),Ln?(0,k.jsx)(X,{ref:or,kind:"ghost",className:"sekyro-btn--start",onClick:c.retry,children:f("capture.recordAgain")}):null]}):null,sr!==null&&Ce!==null?(0,k.jsx)(se,{tone:Ce.status==="not_verified"?"danger":"info",testId:"sekyro-result-notice",children:(0,k.jsx)("span",{children:sr})}):null,(0,k.jsx)("div",{className:Ge?void 0:"sekyro-hidden","data-capture-live":Ge?"":void 0,children:ze?le({videoRef:ie,guidance:Te&&Ue?f("capture.checking"):ht,coached:pt&&!(Te&&Ue),note:Te?Ue?f(he?"capture.busy":"capture.checkingHint"):null:Ze??(ue!==null?vt(ue):Zt),settled:Te&&Ue,progress:c.gate.progress,phase:Kt,still:Te?Ft:null,live:Ge,modeSwitch:Gt,...Tt?{status:Ze}:{},ramp:c.rampColour===null?null:{colour:c.rampColour}}):(0,k.jsx)(kr,{videoRef:ie,guidanceText:ht,guidanceHint:Qe,guidanceKey:Me,progress:c.gate.progress,phase:Kt,draining:c.draining,stillUrl:Ft,showChecking:Ue,operatorText:Zt,voicePrompt:xn,overlay:o(g=>(0,k.jsxs)(k.Fragment,{children:[a?.stageOverlay?.(g),(0,k.jsx)(br,{colour:c.rampColour})]}),"overlay"),reduceMotion:c.reduceMotion,modeSwitch:Gt})}),An&&O.choice!==null?(0,k.jsx)(qr,{title:f("method.title"),description:f("method.description"),options:O.choice.options.map(g=>({id:g,label:f(`method.${g}`)})),busy:O.busy,error:O.failed?f("errors.network_error"):null,focus:c.state==="done",testId:"sekyro-method",look:"buttons",onChoose:o(g=>{gt(g)},"onChoose")}):null,_n?(0,k.jsxs)(k.Fragment,{children:[ve&&a?.header===void 0&&a?.intro===void 0?(0,k.jsxs)("div",{className:"sekyro-stack sekyro-stack--1",children:[(0,k.jsx)("h2",{className:"sekyro-text-body",children:f("returning.title")}),(0,k.jsx)("p",{className:"sekyro-text-muted",children:f("returning.description")})]}):null,Rn,a?.intro!==void 0?a.intro(b,Mn):(0,k.jsx)(Xr,{assets:ut,onRetryAssets:V.retry,permission:z.permission,captureMode:Z.mode,voice:Be,tips:h??wt,summary:Nn,startLabel:S,startDisabled:u,onStart:b})]}):null,(0,k.jsx)(Qr,{showCoaching:ue!==null,coaching:ot(ue?.reasonCode),attemptsText:ue?.attemptsRemaining!==void 0?mr(F,t,ue.attemptsRemaining):null,showRetake:ue!==null&&!$&&!be||!Ue&&c.state==="captured",onRetake:c.retry}),a?.footer]})})}o(zn,"xi");s(zn,"LivenessCapture");var Ut=E(D(),1),ct=E(D(),1),m=E(de(),1);var Cs={document:"card",population_registry:"id",national_eid:"smartphone",phone_otp:"phone",email_otp:"email"};function Zn(e,t){switch(e.service){case"document":return t.t("method.document_photo");case"population_registry":return t.t("method.national_number");case"national_eid":{let n=e.nationalEid?.providerName;return n?t.t("method.national_eid",{provider:n}):t.t("method.national_eidGeneric")}default:return null}}o(Zn,"Y");s(Zn,"identityLabel");function Qn(e,t){let[n,r]=(0,Ut.useState)(!1),[a,i]=(0,Ut.useState)(null);return{busy:n,error:a,run:s(l=>{r(!0),i(null),l().then(()=>r(!1),u=>{r(!1),i(e.t(Nr(u,e.strings))),t?.(u)})},"run")}}o(Qn,"q");s(Qn,"useChoiceAction");function kn(){let e=`sekyro-face-light-${(0,ct.useId)().replace(/[^A-Za-z0-9_-]/g,"")}`;return(0,m.jsxs)("svg",{className:"sekyro-mark sekyro-mark--face",viewBox:"0 0 168 206","aria-hidden":"true",focusable:"false",children:[(0,m.jsx)("defs",{children:(0,m.jsx)("mask",{id:e,children:(0,m.jsx)("ellipse",{className:"sekyro-mark__arc",cx:"84",cy:"103",rx:"76",ry:"95",pathLength:"1",fill:"none",stroke:"#fff",strokeWidth:"16"})})}),(0,m.jsx)("ellipse",{cx:"84",cy:"103",rx:"64",ry:"83",fill:"none",className:"sekyro-mark__line"}),(0,m.jsx)("path",{className:"sekyro-mark__face",d:"M68 64v10M100 64v10M84 66v25q0 2-6 1M60 108q24 18 48 0"}),(0,m.jsx)("ellipse",{className:"sekyro-mark__ticks",cx:"84",cy:"103",rx:"76",ry:"95",pathLength:"56"}),(0,m.jsx)("ellipse",{className:"sekyro-mark__ticks sekyro-mark__ticks--light",cx:"84",cy:"103",rx:"76",ry:"95",pathLength:"56",mask:`url(#${e})`})]})}o(kn,"O");s(kn,"FaceMark");var Wn={glasses:"jGlasses",lighting:"light",faceCamera:"camera"};function Yn(e){if(!(e?.kind!=="liveness"||e.reason===void 0))return{reason:e.reason,...e.retakeHint!==void 0?{retakeHint:e.retakeHint}:{},attemptsRemaining:e.attemptsRemaining??0,attemptsExhausted:e.attemptsExhausted===!0}}o(Yn,"te");s(Yn,"faceIntroRetryOf");var Jn={"capture.retryFrontCamera.screenSide":"camera","capture.retryBackCamera.backSide":"camera","capture.retryUpright.vertical":"smartphone","capture.retryUpright.untilEnd":"smartphone","capture.retryRecording.cameraOn":"camera","capture.retryRecording.stay":"smartphone","capture.retryRecording.network":"smartphone","capture.retryDevice.screenRecording":"smartphone","capture.retryDevice.phone":"smartphone"};function Xn({start:e,context:t,tips:n,tipsTitle:r,human:a=!1,returning:i=!1,notice:l,retry:u}){let S=_t(),{t:h}=S,w=u===void 0?"face":ot(u.reason),x=w==="face"?null:De[w].tips,I=(0,ct.useContext)(_r)?.busy===!0;return(0,m.jsxs)("section",{className:"sekyro-step",children:[(0,m.jsx)(kn,{}),t.captureMode==="assisted"?(0,m.jsx)(tt,{title:h("capture.assisted.heading"),lead:h("capture.assisted.lead")}):i?(0,m.jsx)(tt,{title:h("returning.heading"),lead:h("returning.description")}):(0,m.jsx)(tt,{title:h(a?"native.face.humanIntroTitle":"native.face.introTitle"),lead:h(a?"native.face.humanIntroLead":"native.face.introLead")}),u!==void 0?(0,m.jsx)(bn,{retry:u,title:De[w].title}):null,r!==void 0&&x===null?(0,m.jsx)("p",{className:"sekyro-section-label",children:r}):null,(0,m.jsx)("ul",{className:"sekyro-tiprows",children:x!==null?x.map(d=>(0,m.jsxs)("li",{children:[(0,m.jsx)(Ae,{name:Jn[d]??"face"}),h(d)]},d)):n!==void 0?n.map(d=>(0,m.jsxs)("li",{children:[(0,m.jsx)(Ae,{name:Wn[d.id]??"face"}),d.text]},d.id)):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)("li",{children:[(0,m.jsx)(Ae,{name:"light"}),h("capture.tips.light")]}),(0,m.jsxs)("li",{children:[(0,m.jsx)(Ae,{name:"jGlasses"}),h("capture.tips.uncover")]}),(0,m.jsxs)("li",{children:[(0,m.jsx)(Ae,{name:"smartphone"}),h("capture.tips.eyeLevel")]})]})}),l??null,l!==void 0?null:t.assets==="failed"?(0,m.jsx)(X,{kind:"secondary",full:!0,onClick:t.retryAssets,children:h("common.retry")}):null,l!==void 0?null:(0,m.jsx)(Cr,{children:(0,m.jsxs)(X,{full:!0,disabled:t.assets!=="ready"||I,"aria-busy":t.assets==="loading"||void 0,onClick:e,children:[(0,m.jsx)(Ae,{name:"camera"}),h("capture.start")]})})]})}o(Xn,"ne");s(Xn,"FaceIntro");var es=new Set(["match_inconclusive","no_face_source","below_threshold"]);function bn({retry:e,title:t}){let n=_t(),r=e.retakeHint===void 0?null:Xe(e.retakeHint),a=e.reason==="probe_not_from_liveness"?"capture.retrySamePerson.message":es.has(e.reason)?"capture.retryMatch.message":et(e.reason);return(0,m.jsxs)(wr,{tone:"warning",children:[r!==null?(0,m.jsx)("span",{children:n.t(r)}):a!==null?(0,m.jsx)("span",{children:n.t(a)}):null,r===null?(0,m.jsx)("span",{children:n.t(t)}):null,(0,m.jsx)("span",{children:Sr(n,e.attemptsRemaining,e.attemptsExhausted)})]})}o(bn,"T");s(bn,"RetryNotice");function ts(e){return kt(e)}o(ts,"se");s(ts,"isInAppBrowser");function rs(e,t){let n=t??(typeof navigator>"u"?"":String(navigator.userAgent??""));if(!/Android/i.test(n))return null;let r;try{r=new URL(e)}catch{return null}if(r.protocol!=="https:"&&r.protocol!=="http:")return null;let a=r.protocol.slice(0,-1);return`intent://${r.host}${r.pathname}${r.search}#Intent;scheme=${a};action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(e)};end`}o(rs,"ce");s(rs,"androidBrowserIntent");export{qr as a,Et as b,qn as c,sn as d,zn as e,Cs as f,Zn as g,Qn as h,Yn as i,Xn as j,ts as k,rs as l};
1
+ import{a as Nr}from"./chunk-BMOSAKXR.js";import{c as _t}from"./chunk-ADYI7APR.js";import{b as kr,d as br}from"./chunk-TPDANNML.js";import{b as xr,c as Ct}from"./chunk-E7OQJP4I.js";import{a as yr,b as vr,c as gr,d as Le}from"./chunk-RKNAZPA7.js";import{F as _r,K as wr,L as Sr,a as D,b as de,c as X,m as pr,n as Xe,p as hr,q as et,r as fr,s as mr,t as bt,u as se,v as Ae,w as tt,y as Cr}from"./chunk-SOI356LX.js";import{b as lr,c as cr,d as ur,g as dr}from"./chunk-FQYXVP54.js";import{b as kt}from"./chunk-TXDGBMD4.js";import{a as s}from"./chunk-5QL6W6FW.js";import{g as ir}from"./chunk-6MYG4HWP.js";import{a as o,c as E}from"./chunk-4FHWXBOB.js";var Rr=E(D(),1),v=E(de(),1),ee=E(de(),1),ye=E(D(),1),B=E(de(),1),C=E(D(),1),y=E(D(),1),at=E(D(),1),fe=E(de(),1),Wr=E(D(),1),Y=E(D(),1),it=E(D(),1),we=E(de(),1),Se=E(de(),1),U=E(de(),1);var lt=E(D(),1),pe=E(D(),1);var Q=E(D(),1);var M=E(D(),1),me=E(D(),1),Oe=E(D(),1),Rt=E(de(),1),k=E(de(),1);function oe({className:e,children:t}){return(0,v.jsx)("svg",{"aria-hidden":"true",focusable:"false",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",className:e??"sekyro-icon sekyro-icon--sm",children:t})}o(oe,"te");s(oe,"Svg");var Lt="M4 7.5h2.2l1.4-1.9h8.8l1.4 1.9H20a1.6 1.6 0 0 1 1.6 1.6v8.3A1.6 1.6 0 0 1 20 19H4a1.6 1.6 0 0 1-1.6-1.6V9.1A1.6 1.6 0 0 1 4 7.5Z";function Lr(e){return(0,v.jsxs)(oe,{...e,children:[(0,v.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,v.jsx)("path",{d:"M12 2.5v2M12 19.5v2M2.5 12h2M19.5 12h2M5.3 5.3l1.4 1.4M17.3 17.3l1.4 1.4M5.3 18.7l1.4-1.4M17.3 6.7l1.4-1.4"})]})}o(Lr,"ln");s(Lr,"SunIcon");function Ar(e){return(0,v.jsxs)(oe,{...e,children:[(0,v.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,v.jsx)("path",{d:"M9 10h.01M15 10h.01M8.8 14.6a4.2 4.2 0 0 0 6.4 0"})]})}o(Ar,"un");s(Ar,"FaceUncoveredIcon");function Er(e){return(0,v.jsxs)(oe,{...e,children:[(0,v.jsx)("rect",{x:"7",y:"2.5",width:"10",height:"19",rx:"2"}),(0,v.jsx)("path",{d:"M10.5 18.5h3M2.5 9.5h2.5M19 9.5h2.5"}),(0,v.jsx)("circle",{cx:"12",cy:"9.5",r:"1.6"})]})}o(Er,"dn");s(Er,"PhoneEyeLevelIcon");function Ir(e){return(0,v.jsxs)(oe,{...e,children:[(0,v.jsx)("path",{d:"M2.5 12S6 5.5 12 5.5 21.5 12 21.5 12 18 18.5 12 18.5 2.5 12 2.5 12Z"}),(0,v.jsx)("circle",{cx:"12",cy:"12",r:"2.8"})]})}o(Ir,"pn");s(Ir,"LookStraightIcon");function Ur(e){return(0,v.jsxs)(oe,{...e,children:[(0,v.jsx)("path",{d:Lt}),(0,v.jsx)("path",{d:"M9 13l2 2 4-4"})]})}o(Ur,"fn");s(Ur,"CameraCheckIcon");function jr(e){return(0,v.jsxs)(oe,{...e,children:[(0,v.jsx)("path",{d:Lt}),(0,v.jsx)("path",{d:"M10.2 11.2a1.9 1.9 0 1 1 2.6 1.8c-.5.2-.8.6-.8 1.1v.3M12 16.4h.01"})]})}o(jr,"mn");s(jr,"CameraAskIcon");function Or(e){return(0,v.jsxs)(oe,{...e,children:[(0,v.jsx)("path",{d:Lt}),(0,v.jsx)("path",{d:"M3 3l18 18"})]})}o(Or,"yn");s(Or,"CameraBlockedIcon");function nt({off:e,className:t}){return(0,v.jsxs)(oe,{className:t,children:[(0,v.jsx)("path",{d:"M4.5 9.5v5H8l4 3.5v-12L8 9.5H4.5Z"}),e?(0,v.jsx)("path",{d:"M4 4l16 16"}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("path",{d:"M15.5 9.7a3.6 3.6 0 0 1 0 4.6"}),(0,v.jsx)("path",{d:"M18 7.6a6.6 6.6 0 0 1 0 8.8"})]})]})}o(nt,"Ve");s(nt,"SpeakerIcon");function Pr(e){return(0,v.jsx)(oe,{...e,children:(0,v.jsx)("path",{d:"M5 12.5l4.5 4.5L19 7.5"})})}o(Pr,"gn");s(Pr,"CheckIcon");function Tr(e){return(0,v.jsxs)(oe,{className:e.className??"sekyro-spinner",children:[(0,v.jsx)("circle",{cx:"12",cy:"12",r:"9",opacity:"0.25"}),(0,v.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9"})]})}o(Tr,"hn");s(Tr,"SpinnerIcon");var wt=["light","uncover","eyeLevel","straight"],En={light:{key:"capture.tips.light",icon:s(()=>(0,ee.jsx)(Lr,{}),"icon")},uncover:{key:"capture.tips.uncover",icon:s(()=>(0,ee.jsx)(Ar,{}),"icon")},eyeLevel:{key:"capture.tips.eyeLevel",icon:s(()=>(0,ee.jsx)(Er,{}),"icon")},straight:{key:"capture.tips.straight",icon:s(()=>(0,ee.jsx)(Ir,{}),"icon")}};function Br({tips:e}){let t=Le(),n=(0,Rr.useId)();return e.length===0?null:(0,ee.jsxs)("section",{className:"sekyro-tips","aria-labelledby":n,"data-testid":"sekyro-tips",children:[(0,ee.jsx)("p",{className:"sekyro-tips__title",id:n,children:t("capture.tips.title")}),(0,ee.jsx)("ul",{className:"sekyro-tips__list",children:e.map(r=>{let a=typeof r=="string"?En[r]:void 0,i=typeof r=="string"?r:r.id,l=a!==void 0?a.icon():typeof r=="string"?void 0:r.icon,u=a!==void 0?t(a.key):typeof r=="string"?r:r.text;return(0,ee.jsxs)("li",{className:"sekyro-tips__item",children:[l!=null?(0,ee.jsx)("span",{className:"sekyro-tips__icon","aria-hidden":"true",children:l}):null,(0,ee.jsx)("span",{children:u})]},i)})})]})}o(Br,"Cn");s(Br,"TipList");var In=220;function qr({title:e,description:t,options:n,busy:r,error:a,focus:i,testId:l,look:u="cards",marked:S,onChoose:h}){let w=(0,ye.useId)(),x=bt(),[I,d]=(0,ye.useState)(null),N=(0,ye.useRef)(null);(0,ye.useEffect)(()=>{a!==null&&d(null)},[a]),(0,ye.useEffect)(()=>()=>{N.current!==null&&clearTimeout(N.current)},[]);let R=s(p=>{r||I!==null||(d(p),N.current=setTimeout(()=>{N.current=null,d(null),h(p)},In))},"choose");return(0,B.jsxs)("section",{className:"sekyro-stack sekyro-stack--4 sekyro-choice","aria-labelledby":w,"data-testid":l,children:[(0,B.jsxs)("div",{className:u==="cards"?"sekyro-heading":"sekyro-stack sekyro-stack--1",children:[(0,B.jsx)("h2",{id:w,ref:i?x:void 0,tabIndex:-1,className:"sekyro-text-body",children:e}),t!==void 0&&t!==""?(0,B.jsx)("p",{className:"sekyro-text-muted",children:t}):null]}),a!==null?(0,B.jsx)(se,{tone:"danger",children:(0,B.jsx)("span",{children:a})}):null,u==="buttons"?(0,B.jsx)("div",{className:"sekyro-stack sekyro-stack--3",children:n.map((p,j)=>(0,B.jsx)(X,{kind:j===0?"primary":"ghost",full:!0,disabled:r,"aria-busy":r||void 0,onClick:o(()=>h(p.id),"onClick"),children:p.label},p.id))}):(0,B.jsx)("div",{className:"sekyro-choices",children:n.map(p=>(0,B.jsxs)("button",{type:"button",className:"sekyro-card","aria-pressed":(I??S)===p.id,"aria-busy":r||void 0,disabled:r||I!==null&&I!==p.id,onClick:o(()=>R(p.id),"onClick"),children:[p.glyph!==void 0?(0,B.jsx)("span",{className:"sekyro-card__tile",children:p.glyph}):null,(0,B.jsxs)("span",{className:"sekyro-card__body",children:[(0,B.jsx)("span",{className:"sekyro-card__title",children:p.label}),p.sub!==void 0?(0,B.jsx)("span",{className:"sekyro-card__sub",children:p.sub}):null]}),(0,B.jsx)("span",{className:"sekyro-radio","aria-hidden":"true"})]},p.id))})]})}o(qr,"bn");s(qr,"ChoiceScreen");var Vr=["fcv3.no_face","fcv3.come_closer","fcv3.move_back","fcv3.center_face","fcv3.straighten","fcv3.more_light","fcv3.too_bright","fcv3.hold_still","fcv3.steady_camera","fcv3.hold_upright","fcv3.one_face","capture.tips.summary","capture.lookAtColours"];function st(e){return e!==null&&Vr.includes(e)}o(st,"he");s(st,"isVoiceKey");var Un=s((e,t)=>Object.prototype.hasOwnProperty.call(e,t),"own");function je(e,t,n){let r;try{if(typeof e=="function")r=e(t,n);else{let a=e[n];r=a!=null&&Un(a,t)?a[t]:null}}catch{return null}return typeof r=="string"&&r!==""?r:null}o(je,"Me");s(je,"resolveClip");var jn="UklGRiQAAABXQVZFZm10IBAAAAABAAEAESsAACJWAAACABAAZGF0YQAAAAA=",On={ar:"ar-SA",fr:"fr-FR",en:"en-US",es:"es-ES",pt:"pt-BR",de:"de-DE"};function ae(){return typeof window<"u"&&"speechSynthesis"in window?window.speechSynthesis:null}o(ae,"ne");s(ae,"synth");function Hr(){return ae()!==null&&typeof SpeechSynthesisUtterance=="function"}o(Hr,"Lr");s(Hr,"speechAvailable");function St(e){return(e.split(/[-_]/)[0]??e).toLowerCase()}o(St,"Sn");s(St,"baseLang");function At(e,t){let n=s(a=>a.replace(/_/g,"-").toLowerCase(),"norm"),r=St(t);return e.find(a=>n(a.lang)===n(t))??e.find(a=>St(a.lang)===r)}o(At,"Mn");s(At,"pickVoice");function Dr(e){if(!Hr())return!1;let t=[];try{t=ae()?.getVoices()??[]}catch{return!0}return t.length===0||At(t,e)!==void 0}o(Dr,"wn");s(Dr,"speechUsable");function Fr(e){let t=ae();return t===null||typeof t.addEventListener!="function"?()=>{}:(t.addEventListener("voiceschanged",e),()=>t.removeEventListener?.("voiceschanged",e))}o(Fr,"Ln");s(Fr,"subscribeVoices");function He(e){try{let t=typeof location<"u"?location.href:"http://localhost/",n=new URL(e,t);return`clip:${n.origin}${n.pathname}`}catch{return`clip:${e}`}}o(He,"Ke");s(He,"clipIdentity");function xt(e){e.pause(),e.removeAttribute("src"),e.load()}o(xt,"Rn");s(xt,"release");function $r(){let e=null,t=null,n=0,r=null,a=[],i=new Map,l=s(()=>{a=ae()?.getVoices()??[]},"loadVoices"),u=!1,S=s(()=>{let d=ae();u||d===null||(u=!0,l(),d.addEventListener?.("voiceschanged",l))},"bindVoices"),h=s(()=>(e??(e=new Audio),e),"element"),w=s((d,N,R)=>{let p=ae();if(p!==null&&d!==""&&typeof SpeechSynthesisUtterance=="function"){S();let j=At(a,N);if(a.length===0||j!==void 0){p.cancel();let _=new SpeechSynthesisUtterance(d);_.lang=N,j!==void 0&&(_.voice=j),_.rate=.95,R!==void 0&&(_.onend=_.onerror=R),p.speak(_);return}}R?.()},"speak"),x=s(()=>{n+=1,r=null,e!==null&&(e.pause(),e.currentTime=0),ae()?.cancel()},"stop"),I=s(d=>{for(let N of d){let R=He(N);if(i.has(R))continue;let p=new Audio;p.preload="auto",p.src=N,i.set(R,p)}},"warmClips");return{say(d){let N=d.url!==null?He(d.url):`tts:${d.lang}:${d.text}`;if(N===r)return;r=N,n+=1;let R=n,p=d.onEnd,j=p!==void 0?()=>{R===n&&p()}:void 0;if(ae()?.cancel(),d.url!==null){let _=h();_.pause(),_.muted=!1,_.src=d.url,_.currentTime=0,_.onended=j??null,_.play()?.catch(A=>{R===n&&A?.name!=="AbortError"&&(d.speech?w(d.text,d.lang,j):j?.())});return}d.speech?w(d.text,d.lang,j):j?.()},unlock({lang:d,speech:N,prefetch:R}){let p=h();if(t===null&&typeof Blob=="function"&&typeof URL.createObjectURL=="function"){let A=Uint8Array.from(atob(jn),q=>q.charCodeAt(0));t=URL.createObjectURL(new Blob([A],{type:"audio/wav"}))}let j=p.paused===!1&&t!==null&&p.src!==t;t!==null&&!j&&(p.muted=!0,p.onended=null,p.src=t,p.play()?.catch(()=>{}));let _=ae();if(N&&_!==null&&typeof SpeechSynthesisUtterance=="function"){S();let A=new SpeechSynthesisUtterance(" ");A.volume=0,A.lang=d,_.speak(A)}I(R??[])},prefetch:I,stop:x,dispose(){x(),u&&ae()?.removeEventListener?.("voiceschanged",l),u=!1,t!==null&&URL.revokeObjectURL(t),t=null,e!==null&&xt(e),e=null;for(let d of i.values())xt(d);i.clear()}}}o($r,"_n");s($r,"createVoicePlayer");var Pn="sekyro.voiceGuidance";function Gr(e){try{if(typeof window>"u")return null;let t=window.localStorage.getItem(e);return t==="1"?!0:t==="0"?!1:null}catch{return null}}o(Gr,"xn");s(Gr,"readVoicePreference");function Kr(e,t){try{if(typeof window>"u")return;window.localStorage.setItem(e,t?"1":"0")}catch{}}o(Kr,"En");s(Kr,"writeVoicePreference");var Ve="capture.tips.summary",Tn=typeof window<"u"?C.useLayoutEffect:C.useEffect,Bn=Object.freeze({});function rt(e,t){let n=new Set,r=[];for(let a of Vr){let i=a===Ve?null:je(e,a,t);i===null||n.has(He(i))||(n.add(He(i)),r.push(i))}return r}o(rt,"ht");s(rt,"resolvedClipUrls");function zr({locale:e,defaultClips:t,options:n}){let r=n===!1,a=r?{}:n??{},i=a.storageKey===void 0?Pn:a.storageKey,[l,u]=(0,C.useState)(a.defaultEnabled??!0),S=(0,C.useRef)(l),[h,w]=(0,C.useState)(!1),[x,I]=(0,C.useState)("none"),[d,N]=(0,C.useState)(!1),R=(0,C.useRef)(!1),[p,j]=(0,C.useState)(0),_=(0,C.useRef)(null),A=(0,C.useCallback)(()=>(_.current??(_.current=$r()),_.current),[]),q=On[e],F=a.speechFallback,f=F===void 0||F===!0?!0:F===!1?!1:F.includes(e),G=a.clips??t??Bn,ie=(0,C.useRef)(!1),le=(0,C.useRef)(G);Tn(()=>{le.current=G,S.current=l}),(0,C.useEffect)(()=>{if(r||i===null)return;let L=Gr(i);L!==null&&(S.current=L,u(L))},[r,i]),(0,C.useEffect)(()=>{if(!(r||!f))return Fr(()=>j(L=>L+1))},[r,f]);let c=a.clips;(0,C.useEffect)(()=>{if(r)return;let L=f&&Dr(q);w(rt(G,e).length>0||L),I(c!==void 0&&je(c,Ve,e)!==null?"partner":je(G,Ve,e)!==null||L?"default":"none")},[r,G,c,e,f,q,p]),(0,C.useEffect)(()=>{if(r||!l||!ie.current)return;let L=rt(G,e);L.length>0&&A().prefetch(L)},[r,l,G,e,A]),(0,C.useEffect)(()=>()=>{_.current?.dispose(),_.current=null,ie.current=!1},[]);let V=(0,C.useCallback)(L=>{r||(ie.current=!0,A().unlock({lang:q,speech:f,...L?{prefetch:rt(le.current,e)}:{}}))},[r,A,q,f,e]),O=(0,C.useCallback)(()=>V(S.current),[V]),K=(0,C.useCallback)(()=>{R.current=!1,N(!1)},[]),T=(0,C.useCallback)(()=>{K(),_.current?.stop()},[K]),ve=(0,C.useCallback)(()=>{R.current&&T()},[T]),he=(0,C.useCallback)((L,xe)=>{if(r)return;if(R.current){T();return}let ge=A();ge.stop(),R.current=!0,N(!0);let P=xe?.clip===!1?null:je(le.current,Ve,e);ge.say({url:P,text:L,lang:q,speech:f,onEnd:K})},[r,T,A,e,q,f,K]),z=(0,C.useCallback)(L=>{r||(L?V(!0):T(),i!==null&&Kr(i,L),S.current=L,u(L))},[r,V,T,i]),Z=(0,C.useCallback)(()=>z(!S.current),[z]),te=(0,C.useCallback)((L,xe)=>{if(r||!l)return;R.current&&K();let ge=je(le.current,L,e);A().say({url:ge,text:xe,lang:q,speech:f})},[r,l,e,A,q,f,K]);return(0,C.useMemo)(()=>({supported:!r&&h,enabled:!r&&l,setEnabled:z,toggle:Z,unlock:O,speakKey:te,stop:T,summary:r?"none":x,summaryPlaying:d,toggleSummary:he,stopSummary:ve}),[r,h,l,z,Z,O,te,T,x,d,he,ve])}o(zr,"vt");s(zr,"useVoiceGuidance");function Zr(e,t,n,r){let{speakKey:a,stop:i,enabled:l}=e,u=(0,C.useRef)(!1);(0,C.useEffect)(()=>{if(!r||!l){u.current&&i(),u.current=!1;return}u.current=!0,st(t)&&t!==Ve&&n!==""&&a(t,n)},[r,l,t,n,a,i])}o(Zr,"Ct");s(Zr,"useSpeakGuidance");function ot(e){switch(e){case"multiple_faces":return"one_face";case"capture_back_camera":return"front_camera";case"capture_front_camera":return"back_camera";case"capture_not_upright":return"upright";case"media_unreadable":case"clip_too_short":return"recording";case"device_integrity_failed":return"device";default:return"face"}}o(ot,"Pn");s(ot,"retryCoachingOf");var De={face:{title:"capture.retryCoaching.title",tips:["capture.retryCoaching.light","capture.retryCoaching.eyeLevel","capture.retryCoaching.head"]},one_face:{title:"capture.retryTips.title",tips:["capture.retryOneFace.alone","capture.retryOneFace.screens"]},front_camera:{title:"capture.retryTips.title",tips:["capture.retryFrontCamera.screenSide"]},back_camera:{title:"capture.retryTips.title",tips:["capture.retryBackCamera.backSide","capture.retryBackCamera.circle"]},upright:{title:"capture.retryTips.title",tips:["capture.retryUpright.vertical","capture.retryUpright.untilEnd"]},recording:{title:"capture.retryTips.title",tips:["capture.retryRecording.cameraOn","capture.retryRecording.stay","capture.retryRecording.network"]},device:{title:"capture.retryTips.title",tips:["capture.retryDevice.screenRecording","capture.retryDevice.phone"]}};function Qr({showCoaching:e,coaching:t="face",attemptsText:n,showRetake:r,onRetake:a}){let i=Le(),l=(0,at.useRef)(null);return(0,at.useEffect)(()=>{r&&l.current?.focus()},[r]),!e&&!r?null:(0,fe.jsxs)("div",{className:"sekyro-stack sekyro-stack--3","data-testid":"sekyro-captured-panel",children:[e?(0,fe.jsxs)("div",{className:"sekyro-stack sekyro-stack--1",children:[(0,fe.jsx)("p",{className:"sekyro-text-body",children:i(De[t].title)}),(0,fe.jsx)("ul",{className:"sekyro-coaching",children:De[t].tips.map(u=>(0,fe.jsx)("li",{children:i(u)},u))}),n!==null?(0,fe.jsx)("p",{className:"sekyro-text-muted","data-testid":"sekyro-attempts-remaining",children:n}):null]}):null,r?(0,fe.jsx)(X,{ref:l,className:"sekyro-btn--start",onClick:a,children:i("capture.recordAgain")}):null]})}o(Qr,"Tn");s(Qr,"CapturedPanel");function Et(){try{return!1}catch{return!1}}o(Et,"nt");s(Et,"isDevBuild");var qn=(0,Wr.createContext)(null);function Yr({state:e}){let t=Le(),[n,r]=(0,it.useState)(!1);(0,it.useEffect)(()=>{e!=="unknown"&&r(!0)},[e]);let a=e==="granted"?(0,we.jsx)(Ur,{}):e==="denied"?(0,we.jsx)(Or,{}):(0,we.jsx)(jr,{});return(0,we.jsxs)("div",{role:n?"status":void 0,className:`sekyro-permission sekyro-permission--${e}`,"data-testid":"sekyro-permission","data-state":e,children:[(0,we.jsx)("span",{className:"sekyro-permission__icon","aria-hidden":"true",children:a}),(0,we.jsx)("span",{children:t(`capture.permission.${e}`)})]})}o(Yr,"On");s(Yr,"PermissionRow");function Jr({voice:e}){let t=Le();if(!e.supported)return null;let n=e.enabled;return(0,Se.jsxs)("button",{type:"button",role:"switch","aria-checked":n,className:"sekyro-switch","data-testid":"sekyro-voice-switch",onClick:o(()=>e.toggle(),"onClick"),children:[(0,Se.jsxs)("span",{className:"sekyro-switch__label",children:[(0,Se.jsx)(nt,{off:!n}),t("capture.voiceGuidance")]}),(0,Se.jsx)("span",{className:"sekyro-switch__track","aria-hidden":"true",children:(0,Se.jsx)("span",{className:"sekyro-switch__thumb",children:n?(0,Se.jsx)(Pr,{className:"sekyro-switch__check"}):null})})]})}o(Jr,"Hn");s(Jr,"VoiceSwitch");function Xr({assets:e,onRetryAssets:t,permission:n,captureMode:r="self",voice:a,tips:i,summary:l,startLabel:u,startDisabled:S,onStart:h}){let w=Le(),x=(0,Y.useRef)(l?.stop);x.current=l?.stop,(0,Y.useEffect)(()=>()=>x.current?.(),[]);let I=(0,Y.useRef)(null),d=(0,Y.useRef)(null),N=(0,Y.useRef)(null),R=(0,Y.useRef)(e),p=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>{let f=R.current;if(R.current=e,f===e)return;let G=p.current;e!=="loading"&&(p.current=!1),en(I.current)&&(e==="failed"?N.current?.focus():G&&d.current?.focus())},[e]);let j=(0,Y.useCallback)(()=>{p.current=!0,t()},[t]),_=e==="loading",A=_||S,q=(0,Y.useCallback)(()=>{A||(x.current?.(),h())},[A,h]),F;return e==="failed"?F=(0,U.jsxs)(se,{tone:"danger",testId:"sekyro-assets-error",children:[(0,U.jsx)("p",{className:"sekyro-text-body",children:w("fcv2.err.models")}),(0,U.jsx)(X,{kind:"ghost",ref:N,className:"sekyro-btn--start",onClick:j,"data-testid":"sekyro-assets-retry",children:w("common.retry")})]}):F=(0,U.jsxs)("div",{className:"sekyro-stack sekyro-stack--1",children:[(0,U.jsx)(X,{ref:d,full:!0,"data-testid":"sekyro-start","aria-disabled":A?"true":void 0,"aria-busy":_?"true":void 0,onClick:q,children:_?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Tr,{}),w("capture.preparing.title")]}):u??w("capture.start")}),_?(0,U.jsx)("p",{className:"sekyro-text-muted",children:w("capture.preparing.hint")}):null]}),(0,U.jsxs)("div",{ref:I,className:"sekyro-stack sekyro-stack--4","data-testid":"sekyro-intro","data-assets":e,children:[r==="assisted"?(0,U.jsxs)("div",{className:"sekyro-stack sekyro-stack--1","data-testid":"sekyro-assisted-intro",children:[(0,U.jsx)("h2",{className:"sekyro-text-body",children:w("capture.assisted.title")}),(0,U.jsx)("p",{className:"sekyro-text-muted",children:w("capture.assisted.lead")})]}):null,i!==!1?(0,U.jsx)(Br,{tips:i}):null,l!==void 0?(0,U.jsxs)(X,{kind:"ghost",className:"sekyro-btn--start",onClick:l.toggle,"data-testid":"sekyro-tips-listen",children:[(0,U.jsx)(nt,{off:!1}),w(l.playing?"capture.tips.stop":"capture.tips.listen")]}):null,(0,U.jsx)(Yr,{state:n}),(0,U.jsx)(Jr,{voice:a}),(0,U.jsx)("p",{className:"sekyro-text-muted",children:w("capture.securityNote")}),F,(0,U.jsx)("p",{role:"status",className:"sekyro-visually-hidden","data-testid":"sekyro-intro-status",children:e==="loading"?w("capture.preparing.title"):e==="ready"?w("capture.ready"):""})]})}o(Xr,"Fn");s(Xr,"PreCaptureScreen");function en(e){if(typeof document>"u")return!1;let t=document.activeElement;return t===null||t===document.body||e!==null&&e.contains(t)}o(en,"Ur");s(en,"focusIsOurs");function tn(){let[e,t]=(0,lt.useState)({state:"unknown",settled:!1});return(0,lt.useEffect)(()=>ir(n=>t({state:n,settled:!0})),[]),{permission:e.state,permissionSettled:e.settled}}o(tn,"Dn");s(tn,"useCameraStatus");function rn(e){return It(e,"mobileRequired")}o(rn,"qn");s(rn,"useMobileRequired");function nn(e){return It(e,"returning").required}o(nn,"jn");s(nn,"useReturning");function It(e,t){let[n,r]=(0,pe.useState)({required:!1,settled:e===void 0});return(0,pe.useEffect)(()=>{let a=e?.[t];if(e===void 0||typeof a!="function"){r({required:!1,settled:!0});return}let i=!0;return r({required:!1,settled:!1}),Promise.resolve().then(()=>a.call(e)).then(l=>{i&&r({required:l===!0,settled:!0})},()=>{i&&r({required:!1,settled:!0})}),()=>{i=!1}},[e,t]),n}o(It,"Yn");s(It,"useFlag");function sn(e){let t=s(()=>e?.captureChoice??null,"initialChoice"),[n,r]=(0,pe.useState)(()=>({session:"self",choice:t(),settled:e===void 0}));(0,pe.useEffect)(()=>{let i=e?.captureMode,l=e?.captureChoice??null;if(e===void 0||typeof i!="function"){r({session:"self",choice:l,settled:!0});return}let u=!0;return r({session:"self",choice:l,settled:!1}),Promise.resolve().then(()=>i.call(e)).then(S=>{let h=e.captureChoice??null;u&&r({session:h!==null&&S===h?"choice":S==="assisted"||S==="choice"?S:"self",choice:h,settled:!0})},()=>{u&&r({session:"self",choice:null,settled:!0})}),()=>{u=!1}},[e]);let a=(0,pe.useCallback)(i=>{e?.chooseCaptureMode?.(i),r(l=>({...l,choice:i}))},[e]);return{mode:n.session==="choice"?n.choice??"self":n.session==="assisted"?"assisted":"self",session:n.session,choice:n.choice,settled:n.settled,choose:a}}o(sn,"$n");s(sn,"useCaptureMode");function an(e){let[t,n]=(0,pe.useState)(!1);return(0,pe.useEffect)(()=>{if(n(!1),e===void 0)return;let r=e.on("busy",()=>n(!0)),a=e.on("result",()=>n(!1));return()=>{r(),a()}},[e]),t}o(an,"zn");s(an,"useBusy");var Vn=s(()=>"idle","serverSnapshot");function Nt(e){return lr(e!==void 0?{assetBaseUrl:e}:{})}o(Nt,"Qn");s(Nt,"preload");function on(e,t=!0){let n=(0,Q.useSyncExternalStore)((0,Q.useCallback)(h=>ur(h,e),[e]),()=>cr(e),Vn),[r,a]=(0,Q.useState)(null),i=(0,Q.useRef)(!1),l=(0,Q.useCallback)(()=>{Nt(e).then(h=>{i.current&&h==="idle"&&a({base:e})})},[e]);(0,Q.useEffect)(()=>(i.current=!0,l(),()=>{i.current=!1}),[l]);let u=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(n!=="idle"){u.current={base:e};return}!t||u.current===null||u.current.base!==e||(u.current=null,l())},[n,e,l,t]);let S=(0,Q.useCallback)(()=>{Nt(e)},[e]);return{gate:r!==null&&r.base===e&&n==="idle"||n==="ready"?"ready":n==="failed"?"failed":"loading",retry:S}}o(on,"Jn");s(on,"useLivenessAssets");var Mr={progress:0,hint:null,faceDetected:!1};function ln(e){let{videoRef:t,assetBaseUrl:n}=e,r=(0,M.useRef)(e.verification).current,a=(0,M.useRef)(!1);e.verification!==r&&!a.current&&Et()&&(a.current=!0,console.warn("[@sekyro/react] <LivenessCapture>: the `verification` prop changed identity after mount. The first instance stays bound (the camera is not rebuilt); create the verification once (useMemo / useState / outside render) instead of on every render."));let i=(0,M.useRef)(null),[l,u]=(0,M.useState)("idle"),[S,h]=(0,M.useState)(Mr),[w,x]=(0,M.useState)(!1),[I,d]=(0,M.useState)(!1),[N,R]=(0,M.useState)(null),[p,j]=(0,M.useState)(!1),[_,A]=(0,M.useState)(null),[q,F]=(0,M.useState)(null),[f,G]=(0,M.useState)(null),[ie,le]=(0,M.useState)(null),[c,V]=(0,M.useState)(null),[O,K]=(0,M.useState)(!1),T=(0,M.useRef)(null),ve=(0,M.useRef)("idle"),he=(0,M.useRef)(-1),[z,Z]=(0,M.useState)(0),te=(0,M.useRef)(e);te.current=e,(0,M.useEffect)(()=>{let J=t.current;if(J===null)return;let ce={video:J,...n!==void 0?{assetBaseUrl:n}:{}},H=r!==void 0?r.liveness(ce):dr(ce);i.current=H;let Ne=s(()=>V(H.facingMode??null),"readFacing");Ne();let Fe=[H.on("state",b=>{b==="mode_switch"?K(!0):b!=="starting"&&b!=="gating"&&K(!1),b==="starting"?(ve.current!=="starting"&&(he.current+=1,Z(Math.max(0,he.current))),F(null),G(null),h(Mr),d(!1),x(!1),R(null),A(null),T.current=null):b==="gating"&&ve.current==="recording"&&(d(!1),x(!1),R(null),T.current=null),ve.current=b,Ne(),u(b),te.current.onStateChange?.(b)}),H.on("gate",b=>{let ke=T.current;T.current=b.progress,x(ke!==null&&b.progress<ke-.001&&b.progress>0&&b.progress<1),b.progress>=1&&d(!0),h(b)}),H.on("frozen",({previewDataUrl:b})=>R(b)),H.on("profile",({animations:b})=>j(b==="reduced")),H.on("ramp",({colour:b})=>A(b)),H.on("captured",b=>{F(b),le(null),te.current.onCaptured?.(b)}),H.on("error",b=>{G(b);let ke=r?.reportCaptureIssue;ke!==void 0&&Ct(Ee=>ke.call(r,Ee),xr("liveness",b,Math.max(0,he.current))),te.current.onError?.(b)}),r?.on("result",b=>{le(b),te.current.onResult?.(b)})];return()=>{for(let b of Fe)b?.();i.current=null,H.destroy()}},[r,t,n]);let L=(0,M.useCallback)(()=>{i.current?.start()},[]),xe=(0,M.useCallback)(()=>{i.current?.retry()},[]),ge=(0,M.useCallback)(async()=>{let J=i.current;return J===null||typeof J.canSwitchCaptureMode!="function"?!1:await J.canSwitchCaptureMode().catch(()=>!1)===!0},[]),P=(0,M.useCallback)(async J=>{let ce=i.current;if(ce===null||typeof ce.setCaptureMode!="function")return!1;let H=await ce.setCaptureMode(J).catch(()=>!1)===!0;return H&&V(ce.facingMode??null),H},[]);return{state:l,gate:S,draining:w,gateLocked:I,frozenPreview:N,reduceMotion:p,rampColour:_,artifacts:q,error:f,result:ie,facingMode:c,start:L,retry:xe,canSwitchCaptureMode:ge,setCaptureMode:P,modeRestarted:O,attempt:z}}o(ln,"er");s(ln,"useLivenessHandle");var Hn=new Set(["national_number"]);function Mt(e){if(e==null||!e.available||e.selected!==null)return null;let t=e.options.filter(n=>Hn.has(n));return t.length>0?{...e,options:t}:null}o(Mt,"tr");s(Mt,"pending");function cn(e){let[t,n]=(0,me.useState)(null),[r,a]=(0,me.useState)(e===void 0),[i,l]=(0,me.useState)(!1),[u,S]=(0,me.useState)(!1);(0,me.useEffect)(()=>{if(n(null),e===void 0){a(!0);return}let x=!0,I=e.methodChoice;typeof I=="function"?(a(!1),Promise.resolve().then(()=>I.call(e)).then(N=>{x&&n(Mt(N))},()=>{}).finally(()=>{x&&a(!0)})):a(!0);let d=e.on("method",N=>n(Mt(N)));return()=>{x=!1,d()}},[e]);let h=(0,me.useCallback)(async x=>{if(e===void 0)return!1;l(!0),S(!1);try{return await e.selectMethod(x),n(null),!0}catch{return S(!0),!1}finally{l(!1)}},[e]),w=t!==null&&t.options.length===1?t.options[0]:null;return{choice:t,auto:w==="national_number"&&!u?w:null,settled:r,busy:i,failed:u,select:h}}o(cn,"nr");s(cn,"useMethodChoice");var Dn=["ar","fr","en"];function un(e){if(typeof e!="string")return!1;try{let t=new URL(e);return t.protocol==="https:"||t.protocol==="http:"&&/^(localhost|127\.0\.0\.1)$/.test(t.hostname)}catch{return!1}}o(un,"so");s(un,"isClipUrl");function dn(e){let t=e.clips;if(typeof t!="object"||t===null)return null;let n={};for(let r of Dn){let a=t[r];if(!(typeof a!="object"||a===null))for(let[i,l]of Object.entries(a))!st(i)||!un(l)||((n[r]??(n[r]={}))[i]=l)}return Object.keys(n).length>0?n:null}o(dn,"io");s(dn,"toVoiceClipMap");function pn(e){let[t,n]=(0,Oe.useState)(null);(0,Oe.useEffect)(()=>{if(n(null),e===void 0)return;let a=!0,i=s(u=>{if(!a)return;let S=typeof u=="object"&&u!==null&&typeof u.setId=="string"?u:null;n(h=>h?.setId===S?.setId?h:S)},"take");try{typeof e.voiceClips=="function"&&Promise.resolve(e.voiceClips()).then(i,()=>i(null))}catch{i(null)}let l=e.on("view",u=>i(u.voice));return()=>{a=!1,l()}},[e]);let r=(0,Oe.useMemo)(()=>t!==null?dn(t):null,[t]);return e===void 0?null:r}o(pn,"rr");s(pn,"useServerVoiceClips");function hn({voice:e}){let t=Le();return(0,Rt.jsx)(X,{kind:"chip","aria-pressed":e.enabled,"aria-label":t("capture.voiceGuidance"),"data-testid":"sekyro-voice-toggle",onClick:o(()=>e.toggle(),"onClick"),children:(0,Rt.jsx)(nt,{off:!e.enabled,className:"sekyro-icon"})})}o(hn,"sr");s(hn,"VoiceChip");var Fn=new Set(["abandoned","not_opened","cancelled","superseded"]),$n=800,Gn="capture.lookAtColours";function fn(e){return e===void 0||e!==!1&&e.length===wt.length&&wt.every(t=>e.includes(t))}o(fn,"fo");s(fn,"isDefaultTips");function mn(e){if(e.type==="keydown"&&e.key==="Escape")return!1;let t=globalThis.navigator?.userActivation;return t===void 0?!(e.type==="pointerup"&&e.pointerType==="touch"):t.isActive}o(mn,"mo");s(mn,"carriesActivation");function yn(e){return typeof e=="object"&&e!==null&&!(0,y.isValidElement)(e)&&"tone"in e&&"text"in e}o(yn,"yo");s(yn,"isNoticeObject");var Kn=new Set(["nni_unbound","id_number_unbound","method_required","mobile_required","portrait_required"]);function vn(e){return e==="starting"||e==="gating"||e==="recording"||e==="mode_switch"}o(vn,"ho");s(vn,"isCapturing");function gn(e){return e==="captured"||e==="uploading"||e==="checking"}o(gn,"vo");s(gn,"isPostCapture");function zn({verification:e,locale:t,dir:n,strings:r,slots:a,autoStart:i=!1,notice:l,startDisabled:u=!1,startLabel:S,tips:h,tipsSummary:w,coach:x,voice:I,onGuidance:d,onCaptured:N,onResult:R,onError:p,onStateChange:j,assetBaseUrl:_,className:A}){let q=vr(t),F=(0,y.useMemo)(()=>yr(t,r),[t,r,q]),f=(0,y.useMemo)(()=>g=>F[g]??"",[F]),G=n??(t==="ar"?"rtl":"ltr"),ie=(0,y.useRef)(null),le=(0,y.useContext)(qn),c=ln({verification:e,videoRef:ie,assetBaseUrl:_,onCaptured:N,onResult:R,onError:p,onStateChange:j}),V=on(_,c.state==="idle"&&c.error===null),O=cn(e),K=O.choice!==null,T=rn(e),ve=nn(e),he=an(e),z=tn(),Z=sn(e),te=Z.session==="choice",L=Z.mode==="assisted",xe=I!==!1&&I?.clips===void 0,ge=pn(xe?e:void 0),P=zr({locale:t,defaultClips:ge,options:I}),J=L?"environment":"user",ce=Z.settled,H=(0,y.useRef)(null),Ne=(0,y.useRef)(!1),Fe=(0,y.useRef)(P.unlock);Fe.current=P.unlock,(0,y.useEffect)(()=>{let g=H.current;if(g===null)return;let ne=["pointerup","touchend","click","keydown"],_e=s(()=>{for(let qe of ne)g.removeEventListener(qe,Re,!0)},"disarm");function Re(qe){if(Ne.current){_e();return}mn(qe)&&(Ne.current=!0,_e(),Fe.current())}o(Re,"Re"),s(Re,"onGesture");for(let qe of ne)g.addEventListener(qe,Re,{capture:!0,passive:!0});return _e},[]);let b=(0,y.useCallback)(()=>{Ne.current||(Ne.current=!0,P.unlock()),c.start()},[P.unlock,c.start]),ke=(0,y.useCallback)(()=>c.start(),[c.start]),Ee=(0,y.useRef)(!1),Pe=c.state==="idle"&&c.error===null,jt=!K&&!T.required&&(i===!0||i==="when-permitted"&&z.permission==="granted"),Ot=jt&&O.settled&&T.settled&&ce,Cn=i==="when-permitted"&&!z.permissionSettled&&!Ee.current,Pt=jt&&Pe&&!Ee.current,ut=(Cn||Pt||!ce)&&V.gate==="ready"?"loading":V.gate;(0,y.useEffect)(()=>{!Ot||!Pe||V.gate!=="ready"||Ee.current||(Ee.current=!0,ke())},[Ot,Pe,V.gate,ke]);let _n=Pe&&!K&&!T.required&&!(Pt&&V.gate==="ready"),[Tt,Bt]=(0,y.useState)(!1),{canSwitchCaptureMode:qt,setCaptureMode:Vt}=c;(0,y.useEffect)(()=>{if(!Z.settled||!te){Bt(!1);return}let g=!0;return qt().then(ne=>{g&&Bt(ne)}),()=>{g=!1}},[Z.settled,te,qt]);let{choose:Ht}=Z,Ie=L?"self":"assisted",wn=(0,y.useCallback)(async()=>{await Vt(Ie)&&Ht(Ie)},[Vt,Ht,Ie]),Dt=c.state!=="idle"&&c.facingMode!==null?c.facingMode:J;(0,y.useEffect)(()=>{let g=ie.current?.style;Dt==="user"?g?.removeProperty("transform"):g&&(g.transform="none")},[Dt]);let $e=(0,y.useMemo)(()=>c.artifacts!==null&&typeof URL.createObjectURL=="function"?URL.createObjectURL(c.artifacts.keyframe):null,[c.artifacts]);(0,y.useEffect)(()=>{if($e!==null)return()=>URL.revokeObjectURL($e)},[$e]);let Ft=c.frozenPreview??$e,Ue=e!==void 0,$=vn(c.state),be=gn(c.state),Ge=$||be,re=c.result,$t=c.state==="done"&&re!==null,Ke=$&&c.rampColour!==null,dt=c.state==="recording"&&c.frozenPreview!==null&&!Ke,ze=le!==null,Gt=Tt&&$&&!dt?{to:Ie,label:f(Ie==="assisted"?"capture.modeSwitch.toAssisted":"capture.modeSwitch.toSelf"),description:f(Ie==="assisted"?"capture.modeSwitch.toAssistedLabel":"capture.modeSwitch.toSelfLabel"),onSwitch:s(()=>{wn()},"onSwitch")}:null,Ze=c.modeRestarted&&$?f("capture.modeSwitch.restarted"):null,Te=be||dt,Kt=be?"checking":dt?"frozen":c.state==="recording"||Ke?"recording":c.gateLocked||c.gate.progress>=1?"locked":c.gate.faceDetected?"aligning":"seeking",Qe=$?c.gate.hint:null,We=c.state==="starting"?"capture.preparing.title":Qe===null?null:Qe==="center"&&!c.gate.faceDetected?"fcv3.no_face":pr(Qe),[Sn,zt]=(0,y.useState)(null);(0,y.useEffect)(()=>{if(We!=="fcv3.no_face"){zt(We);return}if(!$)return;let g=setTimeout(()=>zt(We),$n);return()=>clearTimeout(g)},[We,$]);let pt=$&&!Ke&&typeof x=="string"&&x!=="",Zt=L&&$?f("capture.assisted.stage"):null,Me=$&&!pt?Ke?Gn:Sn:null,ht=pt?x:Me===null?"":f(Me);Zr(P,Me,ht,$);let Qt=(0,y.useRef)(d);Qt.current=d,(0,y.useEffect)(()=>{if(st(Me))try{Qt.current?.(Me)}catch(g){console.error("[@sekyro/react] onGuidance threw:",g)}},[Me]);let Be=(0,y.useMemo)(()=>({supported:P.supported,enabled:P.enabled,setEnabled:P.setEnabled,toggle:P.toggle}),[P.supported,P.enabled,P.setEnabled,P.toggle]),ft=a?.voicePrompt,Wt=ft!==void 0,Yt=I===void 0,Jt=(0,y.useRef)(!1);(0,y.useEffect)(()=>{!Wt||!Yt||Jt.current||!Et()||(Jt.current=!0,console.warn("[@sekyro/react] <LivenessCapture>: `slots.voicePrompt` is set and `voice` is undefined, so the component speaks the guidance itself. If your slot plays audio, pass voice={false} or the person hears every hint twice; pass voice={{}} to keep the built-in voice and silence this warning."))},[Wt,Yt]);let xn=ft!==void 0?(g,ne,_e)=>ft(g,ne,_e,Be):P.supported?()=>(0,k.jsx)(hn,{voice:Be}):void 0,{summary:mt,summaryPlaying:Xt,toggleSummary:er,stopSummary:tr}=P,Ye=w!==void 0&&w!=="",rr=Ye?w:f("capture.tips.summary"),nr=Ye?mt!=="none":mt==="partner"||mt==="default"&&fn(h),Nn=(0,y.useMemo)(()=>nr?{playing:Xt,toggle:s(()=>er(rr,{clip:!Ye}),"toggle"),stop:tr}:void 0,[nr,Xt,er,rr,tr,Ye]),Mn=(0,y.useMemo)(()=>({assets:ut,retryAssets:V.retry,permission:z.permission,permissionSettled:z.permissionSettled,captureMode:Z.mode,facing:J,voice:Be}),[ut,V.retry,z.permission,z.permissionSettled,Z.mode,J,Be]),Rn=yn(l)?(0,k.jsx)(se,{tone:l.tone,testId:"sekyro-host-notice",children:(0,k.jsx)("span",{children:l.text})}):l??null,ue=re!==null&&re.status==="retry"?re:null,W=$t&&re.status==="unavailable"&&!K&&re.reasonCode!=="portrait_required"?re:null,Ce=$t&&(re.status==="verified"||re.status==="not_verified"||re.status==="review")?re:null,yt=s((g,ne)=>{if(g===void 0)return null;if(g==="device_cooldown"){let Re=fr(t,ne);if(Re!==null)return f(Re.key).replace("{time}",Re.time)}let _e=et(g);return _e===null?null:f(_e)},"reasonText"),vt=s(g=>{let ne=g.retakeHint===void 0?null:Xe(g.retakeHint);return ne===null?yt(g.reasonCode):f(ne)},"retryText"),sr=Ce===null?null:yt(Ce.reasonCode,Ce.retryAfter)??(Ce.status==="not_verified"&&Ce.reason!==void 0&&Fn.has(Ce.reason)?f("errors.session_expired"):null),Ln=W!==null&&W.reasonCode!==void 0&&W.reasonCode!=="nni_unbound"&&W.reasonCode!=="id_number_unbound"&&W.reasonCode!=="method_required"&&W.reasonCode!=="mobile_required"&&!(W.reasonCode==="no_recorder"&&c.artifacts?.degraded==="NO_RECORDER"),Je=W?.reasonCode,ar=c.attempt;(0,y.useEffect)(()=>{W===null||Je===void 0||e?.reportCaptureIssue===void 0||Kn.has(Je)||Ct(g=>e.reportCaptureIssue?.(g),{check:"liveness",kind:"unavailable",phase:"upload",engineKind:Je,attempt:Math.min(1e3,ar)})},[W,Je,ar,e]);let or=bt(),An=K&&O.auto===null&&!$&&!be&&c.error===null,gt=(0,y.useCallback)(async g=>{await O.select(g)&&c.state==="done"&&c.retry()},[O.select,c.state,c.retry]);return(0,y.useEffect)(()=>{O.auto!==null&&!O.busy&&!$&&!be&&gt(O.auto)},[O.auto,O.busy,$,be,gt]),(0,k.jsx)(gr,{value:f,children:(0,k.jsxs)("div",{ref:H,className:A===void 0?"sekyro-capture":`sekyro-capture ${A}`,dir:G,lang:t,"data-testid":"sekyro-liveness-capture","data-state":c.state,children:[a?.header,ue!==null&&vt(ue)!==null&&!(ze&&Ge)?(0,k.jsx)(se,{tone:"warning",role:"status",testId:"sekyro-retry-notice",children:(0,k.jsx)("span",{children:vt(ue)})}):null,Ze!==null&&!ze?(0,k.jsx)(se,{tone:"info",role:"status",testId:"sekyro-mode-switch-status",children:(0,k.jsx)("span",{children:Ze})}):null,he&&be&&!ze?(0,k.jsx)(se,{tone:"info",role:"status",testId:"sekyro-busy-notice",children:(0,k.jsx)("span",{children:f("capture.busy")})}):null,T.required&&Pe?(0,k.jsx)(se,{tone:"info",role:"status",testId:"sekyro-mobile-required",children:(0,k.jsx)("span",{children:f("reasons.mobile_required")})}):null,c.error!==null?a?.errorPanel!==void 0?a.errorPanel(c.error,c.retry):(0,k.jsxs)(se,{tone:"danger",testId:"sekyro-error-notice",children:[(0,k.jsx)("span",{children:f(hr(c.error))}),c.error.retryable?(0,k.jsx)(X,{ref:or,kind:"ghost",className:"sekyro-btn--start",onClick:c.retry,children:f("common.retry")}):null]}):null,W!==null?(0,k.jsxs)(se,{tone:"danger",testId:"sekyro-unavailable-notice",children:[(0,k.jsx)("span",{children:yt(W.reasonCode)??f(W.reasonCode===void 0?"errors.session_expired":"errors.network_error")}),Ln?(0,k.jsx)(X,{ref:or,kind:"ghost",className:"sekyro-btn--start",onClick:c.retry,children:f("capture.recordAgain")}):null]}):null,sr!==null&&Ce!==null?(0,k.jsx)(se,{tone:Ce.status==="not_verified"?"danger":"info",testId:"sekyro-result-notice",children:(0,k.jsx)("span",{children:sr})}):null,(0,k.jsx)("div",{className:Ge?void 0:"sekyro-hidden","data-capture-live":Ge?"":void 0,children:ze?le({videoRef:ie,guidance:Te&&Ue?f("capture.checking"):ht,coached:pt&&!(Te&&Ue),note:Te?Ue?f(he?"capture.busy":"capture.checkingHint"):null:Ze??(ue!==null?vt(ue):Zt),settled:Te&&Ue,progress:c.gate.progress,phase:Kt,still:Te?Ft:null,live:Ge,modeSwitch:Gt,...Tt?{status:Ze}:{},ramp:c.rampColour===null?null:{colour:c.rampColour}}):(0,k.jsx)(kr,{videoRef:ie,guidanceText:ht,guidanceHint:Qe,guidanceKey:Me,progress:c.gate.progress,phase:Kt,draining:c.draining,stillUrl:Ft,showChecking:Ue,operatorText:Zt,voicePrompt:xn,overlay:o(g=>(0,k.jsxs)(k.Fragment,{children:[a?.stageOverlay?.(g),(0,k.jsx)(br,{colour:c.rampColour})]}),"overlay"),reduceMotion:c.reduceMotion,modeSwitch:Gt})}),An&&O.choice!==null?(0,k.jsx)(qr,{title:f("method.title"),description:f("method.description"),options:O.choice.options.map(g=>({id:g,label:f(`method.${g}`)})),busy:O.busy,error:O.failed?f("errors.network_error"):null,focus:c.state==="done",testId:"sekyro-method",look:"buttons",onChoose:o(g=>{gt(g)},"onChoose")}):null,_n?(0,k.jsxs)(k.Fragment,{children:[ve&&a?.header===void 0&&a?.intro===void 0?(0,k.jsxs)("div",{className:"sekyro-stack sekyro-stack--1",children:[(0,k.jsx)("h2",{className:"sekyro-text-body",children:f("returning.title")}),(0,k.jsx)("p",{className:"sekyro-text-muted",children:f("returning.description")})]}):null,Rn,a?.intro!==void 0?a.intro(b,Mn):(0,k.jsx)(Xr,{assets:ut,onRetryAssets:V.retry,permission:z.permission,captureMode:Z.mode,voice:Be,tips:h??wt,summary:Nn,startLabel:S,startDisabled:u,onStart:b})]}):null,(0,k.jsx)(Qr,{showCoaching:ue!==null,coaching:ot(ue?.reasonCode),attemptsText:ue?.attemptsRemaining!==void 0?mr(F,t,ue.attemptsRemaining):null,showRetake:ue!==null&&!$&&!be||!Ue&&c.state==="captured",onRetake:c.retry}),a?.footer]})})}o(zn,"xi");s(zn,"LivenessCapture");var Ut=E(D(),1),ct=E(D(),1),m=E(de(),1);var Cs={document:"card",population_registry:"id",national_eid:"smartphone",phone_otp:"phone",email_otp:"email"};function Zn(e,t){switch(e.service){case"document":return t.t("method.document_photo");case"population_registry":return t.t("method.national_number");case"national_eid":{let n=e.nationalEid?.providerName;return n?t.t("method.national_eid",{provider:n}):t.t("method.national_eidGeneric")}default:return null}}o(Zn,"Y");s(Zn,"identityLabel");function Qn(e,t){let[n,r]=(0,Ut.useState)(!1),[a,i]=(0,Ut.useState)(null);return{busy:n,error:a,run:s(l=>{r(!0),i(null),l().then(()=>r(!1),u=>{r(!1),i(e.t(Nr(u,e.strings))),t?.(u)})},"run")}}o(Qn,"q");s(Qn,"useChoiceAction");function kn(){let e=`sekyro-face-light-${(0,ct.useId)().replace(/[^A-Za-z0-9_-]/g,"")}`;return(0,m.jsxs)("svg",{className:"sekyro-mark sekyro-mark--face",viewBox:"0 0 168 206","aria-hidden":"true",focusable:"false",children:[(0,m.jsx)("defs",{children:(0,m.jsx)("mask",{id:e,children:(0,m.jsx)("ellipse",{className:"sekyro-mark__arc",cx:"84",cy:"103",rx:"76",ry:"95",pathLength:"1",fill:"none",stroke:"#fff",strokeWidth:"16"})})}),(0,m.jsx)("ellipse",{cx:"84",cy:"103",rx:"64",ry:"83",fill:"none",className:"sekyro-mark__line"}),(0,m.jsx)("path",{className:"sekyro-mark__face",d:"M68 64v10M100 64v10M84 66v25q0 2-6 1M60 108q24 18 48 0"}),(0,m.jsx)("ellipse",{className:"sekyro-mark__ticks",cx:"84",cy:"103",rx:"76",ry:"95",pathLength:"56"}),(0,m.jsx)("ellipse",{className:"sekyro-mark__ticks sekyro-mark__ticks--light",cx:"84",cy:"103",rx:"76",ry:"95",pathLength:"56",mask:`url(#${e})`})]})}o(kn,"O");s(kn,"FaceMark");var Wn={glasses:"jGlasses",lighting:"light",faceCamera:"camera"};function Yn(e){if(!(e?.kind!=="liveness"||e.reason===void 0))return{reason:e.reason,...e.retakeHint!==void 0?{retakeHint:e.retakeHint}:{},attemptsRemaining:e.attemptsRemaining??0,attemptsExhausted:e.attemptsExhausted===!0}}o(Yn,"te");s(Yn,"faceIntroRetryOf");var Jn={"capture.retryFrontCamera.screenSide":"camera","capture.retryBackCamera.backSide":"camera","capture.retryUpright.vertical":"smartphone","capture.retryUpright.untilEnd":"smartphone","capture.retryRecording.cameraOn":"camera","capture.retryRecording.stay":"smartphone","capture.retryRecording.network":"smartphone","capture.retryDevice.screenRecording":"smartphone","capture.retryDevice.phone":"smartphone"};function Xn({start:e,context:t,tips:n,tipsTitle:r,human:a=!1,returning:i=!1,notice:l,retry:u}){let S=_t(),{t:h}=S,w=u===void 0?"face":ot(u.reason),x=w==="face"?null:De[w].tips,I=(0,ct.useContext)(_r)?.busy===!0;return(0,m.jsxs)("section",{className:"sekyro-step",children:[(0,m.jsx)(kn,{}),t.captureMode==="assisted"?(0,m.jsx)(tt,{title:h("capture.assisted.heading"),lead:h("capture.assisted.lead")}):i?(0,m.jsx)(tt,{title:h("returning.heading"),lead:h("returning.description")}):(0,m.jsx)(tt,{title:h(a?"native.face.humanIntroTitle":"native.face.introTitle"),lead:h(a?"native.face.humanIntroLead":"native.face.introLead")}),u!==void 0?(0,m.jsx)(bn,{retry:u,title:De[w].title}):null,r!==void 0&&x===null?(0,m.jsx)("p",{className:"sekyro-section-label",children:r}):null,(0,m.jsx)("ul",{className:"sekyro-tiprows",children:x!==null?x.map(d=>(0,m.jsxs)("li",{children:[(0,m.jsx)(Ae,{name:Jn[d]??"face"}),h(d)]},d)):n!==void 0?n.map(d=>(0,m.jsxs)("li",{children:[(0,m.jsx)(Ae,{name:Wn[d.id]??"face"}),d.text]},d.id)):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)("li",{children:[(0,m.jsx)(Ae,{name:"light"}),h("capture.tips.light")]}),(0,m.jsxs)("li",{children:[(0,m.jsx)(Ae,{name:"jGlasses"}),h("capture.tips.uncover")]}),(0,m.jsxs)("li",{children:[(0,m.jsx)(Ae,{name:"smartphone"}),h("capture.tips.eyeLevel")]})]})}),l??null,l!==void 0?null:t.assets==="failed"?(0,m.jsx)(X,{kind:"secondary",full:!0,onClick:t.retryAssets,children:h("common.retry")}):null,l!==void 0?null:(0,m.jsx)(Cr,{children:(0,m.jsxs)(X,{full:!0,disabled:t.assets!=="ready"||I,"aria-busy":t.assets==="loading"||void 0,onClick:e,children:[(0,m.jsx)(Ae,{name:"camera"}),h("capture.start")]})})]})}o(Xn,"ne");s(Xn,"FaceIntro");var es=new Set(["match_inconclusive","no_face_source","below_threshold"]);function bn({retry:e,title:t}){let n=_t(),r=e.retakeHint===void 0?null:Xe(e.retakeHint),a=e.reason==="probe_not_from_liveness"?"capture.retrySamePerson.message":es.has(e.reason)?"capture.retryMatch.message":et(e.reason);return(0,m.jsxs)(wr,{tone:"warning",children:[r!==null?(0,m.jsx)("span",{children:n.t(r)}):a!==null?(0,m.jsx)("span",{children:n.t(a)}):null,r===null?(0,m.jsx)("span",{children:n.t(t)}):null,(0,m.jsx)("span",{children:Sr(n,e.attemptsRemaining,e.attemptsExhausted)})]})}o(bn,"T");s(bn,"RetryNotice");function ts(e){return kt(e)}o(ts,"se");s(ts,"isInAppBrowser");function rs(e,t){let n=t??(typeof navigator>"u"?"":String(navigator.userAgent??""));if(!/Android/i.test(n))return null;let r;try{r=new URL(e)}catch{return null}if(r.protocol!=="https:"&&r.protocol!=="http:")return null;let a=r.protocol.slice(0,-1);return`intent://${r.host}${r.pathname}${r.search}#Intent;scheme=${a};action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(e)};end`}o(rs,"ce");s(rs,"androidBrowserIntent");export{qr as a,Et as b,qn as c,sn as d,zn as e,Cs as f,Zn as g,Qn as h,Yn as i,Xn as j,ts as k,rs as l};
@@ -1 +1 @@
1
- import{a as d}from"./chunk-WKQRKYX4.js";import{a as t}from"./chunk-5QL6W6FW.js";import{a as i,c as r}from"./chunk-4FHWXBOB.js";var s=r(d(),1);var u=(0,s.createContext)(null);function c(a,n,o){let e=n.detail;return{check:a,kind:n.kind,...e?.name!==void 0?{name:e.name}:{},...e?.phase!==void 0?{phase:e.phase}:{},...e?.engineKind!==void 0?{engineKind:e.engineKind}:{},attempt:Math.max(0,Math.min(1e3,o))}}i(c,"a");t(c,"captureIssueOf");function m(a,n){if(a!==void 0)try{a(n)}catch{}}i(m,"o");t(m,"sendCaptureIssue");export{u as a,c as b,m as c};
1
+ import{a as d}from"./chunk-SOI356LX.js";import{a as t}from"./chunk-5QL6W6FW.js";import{a as i,c as r}from"./chunk-4FHWXBOB.js";var s=r(d(),1);var u=(0,s.createContext)(null);function c(a,n,o){let e=n.detail;return{check:a,kind:n.kind,...e?.name!==void 0?{name:e.name}:{},...e?.phase!==void 0?{phase:e.phase}:{},...e?.engineKind!==void 0?{engineKind:e.engineKind}:{},attempt:Math.max(0,Math.min(1e3,o))}}i(c,"a");t(c,"captureIssueOf");function m(a,n){if(a!==void 0)try{a(n)}catch{}}i(m,"o");t(m,"sendCaptureIssue");export{u as a,c as b,m as c};
@@ -0,0 +1 @@
1
+ import{d as xe,e as He,f as Ke,g as Xe}from"./chunk-TXDGBMD4.js";import{a as ne,b as Ze,c as oe,d as Ve}from"./chunk-P7K7ELYZ.js";import{a as Se,b as Y,c as Ie,d as Ae,e as De,h as Re,i as se,j as Ce,k as Oe,l as We,m as ze}from"./chunk-6MYG4HWP.js";import{a as Ge,b as Pe,c as Ue,d as Fe,e as Ne,f as ae,g as j,h as Be,i as Le,j as qe}from"./chunk-JS2IXPNL.js";import{a as n}from"./chunk-4FHWXBOB.js";var wt=1e4,C,bt=(C=class{constructor(e,t){this.tier="blaze",this.inner=e,t!==void 0&&(this.fallbackReason=t)}static async create(e,t){let r=await import("./vision_bundle-WBHR7TEE.js"),s=await r.FilesetResolver.forVisionTasks(e),a=await r.FaceDetector.createFromOptions(s,{baseOptions:{modelAssetPath:`${e}/blaze_face_short_range.tflite`,delegate:"CPU"},runningMode:"IMAGE"});return new C(a,t)}async detect(e,t,r){let s;try{s=this.inner.detect(e).detections}catch{return null}let a=Mt(s);if(a?.boundingBox===void 0)return null;let o=Q(e),l=kt(a.keypoints,o),c=a.keypoints?.[2],h={box:{x:a.boundingBox.originX,y:a.boundingBox.originY,width:a.boundingBox.width,height:a.boundingBox.height},...l!==void 0?{eyes:l}:{},...c!==void 0?{nose:{x:c.x*o.width,y:c.y*o.height}}:{},score:a.categories[0]?.score??0,extraFaces:je(s.map(d=>d.boundingBox??{width:0,height:0}),s.indexOf(a))};return $e(h,e,t,r)}destroy(){try{this.inner.close()}catch{}}},n(C,"t"),C);function Mt(i){let e,t=-1;for(let r of i){let s=r.categories[0]?.score??0;s>t&&(e=r,t=s)}return e}n(Mt,"R");function kt(i,e){let t=i?.[0],r=i?.[1];if(t===void 0||r===void 0)return;let s=n(l=>({x:l.x*e.width,y:l.y*e.height}),"n"),[a,o]=[s(t),s(r)];return a.x<=o.x?{left:a,right:o}:{left:o,right:a}}n(kt,"T");function Tt(){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(2,2);let i=document.createElement("canvas");return i.width=2,i.height=2,i}n(Tt,"E");var _t=4;async function Et(){let i=globalThis.FaceDetector;if(typeof i!="function")return{ok:!1,reason:"unsupported"};try{let e=new i({fastMode:!0,maxDetectedFaces:_t});return await e.detect(Tt()),{ok:!0,instance:e}}catch(e){return{ok:!1,reason:`smoke_failed:${e instanceof Error?e.message:String(e)}`}}}n(Et,"w");var P,St=(P=class{constructor(e,t){this.tier="native",this.inner=e,t!==void 0&&(this.fallbackReason=t)}async detect(e,t,r){let s;try{s=await this.inner.detect(e)}catch{return null}let a=s.map(d=>d.boundingBox),o=-1;a.forEach((d,u)=>{let v=a[o];(v===void 0||d.width*d.height>v.width*v.height)&&(o=u)});let l=s[o];if(l===void 0)return null;let c=It(l.landmarks),h={box:{x:l.boundingBox.x,y:l.boundingBox.y,width:l.boundingBox.width,height:l.boundingBox.height},...c!==void 0?{eyes:c}:{},score:1,extraFaces:je(a,o)};return $e(h,e,t,r)}destroy(){}},n(P,"b"),P);function It(i){if(i===void 0)return;let e=i.filter(s=>s.type==="eye").map(s=>s.locations[0]).filter(s=>s!==void 0),[t,r]=e;if(!(t===void 0||r===void 0))return t.x<=r.x?{left:t,right:r}:{left:r,right:t}}n(It,"S");var At=.25;function je(i,e){let t=i[e],r=t===void 0?0:t.width*t.height;if(!(r>0))return 0;let s=0;return i.forEach((a,o)=>{o!==e&&a.width*a.height>=At*r&&(s+=1)}),s}n(je,"f");var ce="/models-v3",xt=["native","blaze"],U,he=(U=class extends Error{constructor(e){super(`no detector tier available (${e})`),this.name="DetectorLadderError",this.fallbackReason=e}},n(U,"x"),U);function Q(i){let e=i;if(typeof e.videoWidth=="number"&&e.videoWidth>0)return{width:e.videoWidth,height:e.videoHeight??0};if(typeof e.naturalWidth=="number"&&e.naturalWidth>0)return{width:e.naturalWidth,height:e.naturalHeight??0};let t=typeof e.width=="number"?e.width:0,r=typeof e.height=="number"?e.height:0;return{width:t,height:r}}n(Q,"y");function $e(i,e,t,r){let s=Q(e),a=s.width>0?t/s.width:1,o=s.height>0?r/s.height:1,l=n(c=>({x:c.x*a,y:c.y*o}),"s");return{box:{x:i.box.x*a,y:i.box.y*o,width:i.box.width*a,height:i.box.height*o},...i.eyes!==void 0?{eyes:{left:l(i.eyes.left),right:l(i.eyes.right)}}:{},...i.nose!==void 0?{nose:l(i.nose)}:{},score:i.score,...i.extraFaces!==void 0?{extraFaces:i.extraFaces}:{}}}n($e,"h");function Dt(i){return i instanceof Error?i.message:String(i)}n(Dt,"C");async function x(i){let e=i.preferred??xt,t=[];for(let r of e){if(r==="native"){let s=await Et();if(s.ok)return new St(s.instance,le(t));t.push(`native:${s.reason}`);continue}try{return await Rt(bt.create(i.v3AssetBaseUrl??ce,le(t)),i.blazeInitTimeoutMs??wt)}catch(s){t.push(s instanceof Ye?"blaze:blaze_init_timeout":`blaze:${Dt(s)}`)}}throw new he(le(t)??"no_tier_available")}n(x,"O");function le(i){return i.length>0?i.join("; "):void 0}n(le,"v");var F,Ye=(F=class extends Error{},n(F,"g"),F);function Rt(i,e){return new Promise((t,r)=>{let s=setTimeout(()=>{r(new Ye(`init exceeded ${e}ms`)),i.then(a=>a.destroy(),()=>{})},e);i.then(a=>{clearTimeout(s),t(a)},a=>{clearTimeout(s),r(a)})})}n(Rt,"W");var R=1;function Qe(){return typeof OffscreenCanvas=="function"&&typeof createImageBitmap=="function"&&typeof Worker=="function"}n(Qe,"K");function Ct(i,e={}){let t=e.createDetector??x,r=null;i.onmessage=s=>{let a=s.data;if(a.v!==R){a.bitmap?.close?.();return}if(a.type==="init"){t(a.options).then(o=>{r=o;let l={v:R,type:"ready",tier:o.tier,...o.fallbackReason!==void 0?{fallbackReason:o.fallbackReason}:{}};i.postMessage(l)});return}if(a.type==="detect"){let o=n(l=>{let c={v:R,type:"result",id:a.id,observation:l};i.postMessage(c),a.bitmap.close?.()},"a");if(r===null){o(null);return}r.detect(a.bitmap,a.streamWidth,a.streamHeight).then(o,()=>o(null))}}}n(Ct,"B");typeof self<"u"&&typeof self.importScripts=="function"&&Ct(self);var O,Je=(O=class{constructor(e,t){this.pending=new Map,this.nextId=1,this.worker=e,this.tier=t.tier,t.fallbackReason!==void 0&&(this.fallbackReason=t.fallbackReason),e.addEventListener("message",r=>{let s=r.data;if(s.v!==R||s.type!=="result")return;let a=this.pending.get(s.id);this.pending.delete(s.id),a?.(s.observation)})}static create(e,t,r=1e4){return new Promise((s,a)=>{let o=setTimeout(()=>{e.removeEventListener("message",l),e.terminate(),a(new Error(`worker detector not ready within ${r}ms`))},r),l=n(h=>{let d=h.data;d.v!==R||d.type!=="ready"||(clearTimeout(o),e.removeEventListener("message",l),s(new O(e,d)))},"s");e.addEventListener("message",l);let c={v:R,type:"init",options:t};e.postMessage(c)})}async detect(e,t,r){let s;try{typeof ImageBitmap<"u"&&e instanceof ImageBitmap?s=e:typeof createImageBitmap=="function"?s=await createImageBitmap(e):s=e}catch{return null}let a=this.nextId;return this.nextId+=1,new Promise(o=>{this.pending.set(a,o);let l={v:R,type:"detect",id:a,bitmap:s,streamWidth:t,streamHeight:r};this.worker.postMessage(l,[s])})}destroy(){for(let e of this.pending.values())e(null);this.pending.clear(),this.worker.terminate()}},n(O,"t"),O);var Ot=[...Ge.filter(i=>i.startsWith("video/mp4")),"video/webm;codecs=h264","video/webm;codecs=avc1","video/webm;codecs=vp8","video/webm;codecs=vp9","video/webm"],lt=new Set;function Gt(i){let e=/(?:Chrome|Chromium)\/(\d+)\./.exec(i??"");return e?Number(e[1]):null}n(Gt,"De");function Pt(i=Ft(),e=globalThis.navigator?.userAgent){if(i===void 0)return"";let t=Gt(e)===126;for(let r of Ot)if(!(lt.has(r)||t&&r.startsWith("video/mp4")))try{if(i(r))return r}catch{}return""}n(Pt,"fe");function et(i){i!==""&&lt.add(i)}n(et,"V");function Ut(i){return i.replace(/^video\/x-matroska/i,"video/webm")}n(Ut,"ge");function ct(i){let e=/codecs=["']?([^,;"']+)/i.exec(i);return e?e[1].trim():i.split(";")[0].trim()}n(ct,"ut");function Ft(){let i=globalThis.MediaRecorder;return i&&typeof i.isTypeSupported=="function"?e=>i.isTypeSupported(e):void 0}n(Ft,"Oe");var ht=2500,Nt=1e3,Bt=1500,tt=25e5,Lt=100,qt=700,Wt=20,zt=1500,J=null;function Ht(){return J??(J=import("./clip-inspect-DLJXVKV6-TNHTD4LV.js").catch(i=>{throw J=null,i})),J.catch(()=>null)}n(Ht,"Ne");var B,D=(B=class extends Error{constructor(e,t){super(t??e),this.kind=e}},n(B,"S"),B),Kt=100;function it(i,e){return i.stats===void 0?!1:i.stats===null?!0:i.stats.durationMs<e-Kt}n(it,"H");function Xt(i,e){return i.stats?e.stats?i.stats.durationMs>e.stats.durationMs:!0:!1}n(Xt,"be");var L,Zt=(L=class{constructor(e={}){this.recorder=null,this.stream=null,this.chunks=[],this.bytes=0,this.hardStopTimer=null,this.graceTimer=null,this.pollTimer=null,this.settled=!1,this.now=e.now??(()=>globalThis.performance?.now?.()??Date.now())}clearTimers(){this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.graceTimer&&clearTimeout(this.graceTimer),this.pollTimer&&clearInterval(this.pollTimer),this.hardStopTimer=null,this.graceTimer=null,this.pollTimer=null}record(e,t,r,s=ht,a){let o=Pt(),l=Ht();return this.recordRaw(e,t,r,s,a,o).then(c=>Vt(c,l),c=>{throw c instanceof D&&(c.requestedMimeType=o),c})}recordRaw(e,t,r,s,a,o){return this.recorder&&!this.settled?Promise.reject(new D("generic","record() called while a recording is in flight — ClipRecorder handles one recording at a time")):(this.recorder=null,this.clearTimers(),this.chunks=[],this.bytes=0,this.settled=!1,this.stream=e,new Promise((l,c)=>{let h;try{h=new MediaRecorder(e,o?{mimeType:o,videoBitsPerSecond:tt}:{videoBitsPerSecond:tt})}catch{try{h=new MediaRecorder(e)}catch{c(new D("unsupported"));return}}this.recorder=h;let d=n(p=>{this.settled||(this.settled=!0,this.clearTimers(),p())},"d"),u=n(()=>d(()=>{let p=Ut(h.mimeType||o||Pe),M=new Blob(this.chunks,{type:p});if(M.size===0){c(new D("generic","empty clip"));return}if(ae(M)){c(new D("cliptoolarge"));return}l({blob:M,mimeType:p,requestedMimeType:o})}),"u");h.ondataavailable=p=>{p.data&&p.data.size&&(this.chunks.push(p.data),this.bytes+=p.data.size,this.bytes>Ne&&d(()=>{try{h.state!=="inactive"&&h.stop()}catch{}c(new D("cliptoolarge"))}))},h.onstop=u,h.onerror=()=>d(()=>c(new D("generic")));let v=this.now();if(r!==void 0||a!==void 0){let p=!1;h.onstart=()=>{if(!(p||this.settled)&&(p=!0,v=this.now(),r!==void 0))try{r()}catch{}}}try{h.start(Nt)}catch{d(()=>c(new D("generic")));return}let w=n(()=>{if(this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=null,this.settled||t?.(),h.state!=="inactive"){try{h.stop()}catch{u()}this.graceTimer=setTimeout(u,Bt)}else u()},"g"),m=this.now();if(a===void 0){this.hardStopTimer=setTimeout(w,s);return}let g=null,y=!1;this.hardStopTimer=setTimeout(w,s+qt),this.pollTimer=setInterval(()=>{if(this.settled||y)return;let p=null;try{p=a.latest()}catch{p=null}let M=p?.presentationTimeMs;M!==void 0&&Number.isFinite(M)&&M>=v&&g===null&&(g=M);let E=g!==null&&M!==void 0&&M-g>=s,I=g===null&&this.now()-m>=s;if(!(!E&&!I)){if(y=!0,this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,I){w();return}this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=setTimeout(w,Lt)}},Wt)}))}stop(e){this.clearTimers();let t=this.recorder;if(t&&t.state!=="inactive")try{t.stop()}catch{}this.recorder=null,(e??this.stream)?.getTracks().forEach(r=>r.stop()),this.stream=null}},n(L,"I"),L);async function Vt(i,e){let t,r=new Promise(h=>{t=setTimeout(()=>h(null),zt)}),s=await Promise.race([e,r]);if(clearTimeout(t),s===null)return i;let a;try{a=await s.blobBytes(i.blob)}catch{return{...i,stats:null}}let o=s.inspectClipBytes(a);if(o?.container!=="webm")return{...i,stats:o};let l=s.withWebmDuration(a,o.durationMs);if(l===null)return{...i,stats:o};let c=s.inspectClipBytes(l);return c===null||c.frames!==o.frames||c.durationMs!==o.durationMs?{...i,stats:o}:{...i,blob:new Blob([l],{type:i.blob.type}),stats:o}}n(Vt,"He");var jt=["magenta","yellow","green","blue"],$t={magenta:"rgb(255, 72, 150)",yellow:"rgb(255, 190, 0)",green:"rgb(0, 238, 175)",blue:"rgb(25, 150, 255)",dark:"rgb(0, 0, 0)"};function $i(i){return $t[i]}n($i,"ft");var Yt=4,Qt=4,ee=n(i=>typeof i=="number"&&Number.isFinite(i),"D");function pe(i){if(typeof i!="object"||i===null)return!1;let e=i;if(typeof e.nonce!="string"||e.nonce.length===0||!Array.isArray(e.colours)||e.colours.length<1||e.colours.length>8||!e.colours.every(r=>jt.includes(r))||!Array.isArray(e.onsetsMs)||e.onsetsMs.length!==e.colours.length)return!1;let t=-1;for(let r of e.onsetsMs){if(!ee(r)||r<0||r<=t)return!1;t=r}return!(!ee(e.holdMs)||e.holdMs<=0||!ee(e.endMs)||e.endMs<=t||!ee(e.clipMs)||e.clipMs<e.endMs||e.clipMs>8e3)}n(pe,"O");function Jt(i,e){return pe(i)?Math.max(e,Math.ceil(i.clipMs)):e}n(Jt,"ye");function ei(i,e){let t=e.now??(()=>performance.now()),r=pe(i)?i:void 0,s=[],a=null,o=null,l=null,c=!1,h=null,d=n(m=>{h=m;try{e.paint(m)}catch{}},"d"),u=n(m=>{let g=e.frames?.()??null;return g!==null&&l!==null?g.mediaTimeMs+(m-g.presentationTimeMs)-l:m-(o??m)},"u"),v=n((m,g,y=0)=>{if(c)return;let p=Math.max(0,m-u(t()));a=setTimeout(()=>{if(a=null,!c){if(y<Yt&&u(t())<m-Qt){v(m,g,y+1);return}g()}},p)},"f"),w=n(m=>{if(r===void 0)return;let g=r.endMs;if(m>=r.colours.length){v(g,()=>d(null));return}let y=r.onsetsMs[m],p=m+1<r.onsetsMs.length?r.onsetsMs[m+1]:g;v(y,()=>{let M=u(t());if(M>g){h!==null&&d(null);return}let E=r.colours[m];d(E);let I=s.length===0?0:s[s.length-1].tMs;s.push({tMs:Math.max(I,Math.round(M)),colour:E});let T=y+r.holdMs;if(T<p){v(T,()=>{if(u(t())>g){h!==null&&d(null);return}d("dark"),w(m+1)});return}w(m+1)})},"g");return{started(m){if(r===void 0||c||o!==null)return;o=m;let g=e.frames?.()??null;l=g===null?null:g.mediaTimeMs+(m-g.presentationTimeMs),w(0)},stop(){c||(c=!0,a!==null&&clearTimeout(a),a=null,h!==null&&d(null))},report(){return r===void 0?void 0:{nonce:r.nonce,rendered:[...s]}}}}n(ei,"Me");function ti(i,e,t=.92){return new Promise((r,s)=>{let a=i.videoWidth,o=i.videoHeight;if(!a||!o){s(new Error("video-not-ready"));return}let l=e.getContext("2d");if(!l){s(new Error("no-2d-context"));return}e.width=a,e.height=o,l.scale(-1,1),l.drawImage(i,-a,0),e.toBlob(c=>c?r(c):s(new Error("empty-keyframe")),"image/jpeg",t)})}n(ti,"Se");var q,ii=(q=class{constructor(e){this.timer=null,this.frameCallbackId=null,this.running=!1,this.busy=!1,this.lastRunAt=Number.NEGATIVE_INFINITY,this.degradeCount=0,this.durations=[],this.options=e,this.periodMs=1e3/e.cadenceHz}start(){if(this.running)return;this.running=!0;let e=this.options.video;if(typeof e?.requestVideoFrameCallback=="function"){let t=n(()=>{this.running&&(this.frameCallbackId=e.requestVideoFrameCallback?.(()=>{this.frameCallbackId=null,this.now()-this.lastRunAt>=this.periodMs&&this.tick(),t()}))},"t");t();return}this.timer=setInterval(()=>this.tick(),this.periodMs)}stop(){this.running=!1,this.timer!==null&&(clearInterval(this.timer),this.timer=null),this.frameCallbackId!==null&&(this.options.video?.cancelVideoFrameCallback?.(this.frameCallbackId),this.frameCallbackId=null)}stats(){let e=this.durations.length===0?0:this.durations.reduce((t,r)=>t+r,0)/this.durations.length;return{degradeCount:this.degradeCount,meanDetectMs:e}}now(){return this.options.now?.()??performance.now()}tick(){if(!this.running)return;if(this.busy){this.degradeCount+=1;return}this.busy=!0,this.lastRunAt=this.now();let e=this.now();this.options.run().catch(()=>{}).finally(()=>{this.busy=!1,this.durations.push(this.now()-e),this.durations.length>20&&this.durations.shift()})}},n(q,"P"),q),ri=Object.freeze({Q_GOOD:.6,RISE_PER_S:.9,FALL_PER_S:.25,CENTER_FALLOFF_IOD_MULTIPLE:1.35,BOX_EYE_OFFSET_FACTOR:.12,IOD_BOX_PROXY_FACTOR:.42,SIZE_IDEAL_MIN:.12,SIZE_IDEAL_MAX:.3,SIZE_HARD_MIN:.08,SIZE_HARD_MAX:.45,ROLL_MAX_DEG:25,MOTION_VELOCITY_IOD_PER_S:.5,MOTION_TAU_S:.4,MOTION_DEADBAND_IOD_PER_S:.1,READY_WINDOW_MS:500,GUIDE_SIZE:.6,GUIDE_CENTERING:.6,GUIDE_POSE:.6,GUIDE_EXPOSURE:.6,GUIDE_SHARPNESS:.35,GUIDE_MOTION:.5}),N=n(i=>Math.min(1,Math.max(0,i)),"_"),W,rt=(W=class{constructor(e={}){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal",this.t={...ri,...e}}reset(){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal"}tick(e){let{observation:t,quality:r,timestampMs:s}=e,a=this.lastTickAt===null?0:Math.max(0,(s-this.lastTickAt)/1e3);this.lastTickAt=s;let o={presence:0,single:1,centering:0,size:0,pose:0,sharpness:N(r.sharpness),exposure:N(r.exposure),motion:1};if(t!==null){o.presence=1,o.single=(t.extraFaces??0)>0?0:1;let d=this.geometryOf(t,e);o.centering=d.centering,o.size=d.size,o.pose=d.pose,o.motion=this.motionOf(d.center,d.iod,s)}else this.lastCenter=null,this.velocityEma=0;let l=Math.min(o.presence,o.single,o.centering,o.size,o.pose,o.sharpness,o.exposure,o.motion);this.p=N(this.p+(l>=this.t.Q_GOOD?this.t.RISE_PER_S*l:-this.t.FALL_PER_S*(1-l))*a),this.qWindow.push({at:s,q:l}),this.qWindow=this.qWindow.filter(d=>d.at>=s-this.t.READY_WINDOW_MS);let c=this.qWindow.map(d=>d.q);if(c.length>=3){let d=Math.min(...c),u=c.indexOf(d);c=c.filter((v,w)=>w!==u)}let h=this.p>=1&&c.every(d=>d>=this.t.Q_GOOD);return{at:s,q:l,p:this.p,factors:o,guidanceKey:this.guidanceOf(o,r,l),ready:h,accepted:l>=this.t.Q_GOOD}}geometryOf(e,t){let{box:r,eyes:s}=e,a={x:t.frameWidth/2,y:t.frameHeight/2},o=Math.min(t.frameWidth,t.frameHeight),l=s!==void 0?{x:(s.left.x+s.right.x)/2,y:(s.left.y+s.right.y)/2}:{x:r.x+r.width/2,y:r.y+r.height/2-this.t.BOX_EYE_OFFSET_FACTOR*r.height},c=s!==void 0?Math.hypot(s.right.x-s.left.x,s.right.y-s.left.y):this.t.IOD_BOX_PROXY_FACTOR*r.width,h=Math.hypot(l.x-a.x,l.y-a.y),d=c<=0?0:1-N(h/(this.t.CENTER_FALLOFF_IOD_MULTIPLE*c)),u=o>0?c/o:0;this.lastSizeDirection=u<this.t.SIZE_IDEAL_MIN?"far":u>this.t.SIZE_IDEAL_MAX?"close":"ideal";let v;u<this.t.SIZE_HARD_MIN||u>this.t.SIZE_HARD_MAX?v=0:u<this.t.SIZE_IDEAL_MIN?v=(u-this.t.SIZE_HARD_MIN)/(this.t.SIZE_IDEAL_MIN-this.t.SIZE_HARD_MIN):u>this.t.SIZE_IDEAL_MAX?v=(this.t.SIZE_HARD_MAX-u)/(this.t.SIZE_HARD_MAX-this.t.SIZE_IDEAL_MAX):v=1;let w=1;if(s!==void 0){let m=Math.abs(Math.atan2(s.right.y-s.left.y,s.right.x-s.left.x))*180/Math.PI;w=1-N(m/this.t.ROLL_MAX_DEG)}return{center:l,iod:c,centering:d,size:v,pose:w}}motionOf(e,t,r){let s=this.lastCenter;if(this.lastCenter={...e,at:r},s===null||t<=0)return 1;let a=(r-s.at)/1e3;if(a<=0)return 1;let o=Math.hypot(e.x-s.x,e.y-s.y)/t/a;o<=this.t.MOTION_DEADBAND_IOD_PER_S&&(o=0);let l=1-Math.exp(-a/this.t.MOTION_TAU_S);return this.velocityEma=l*o+(1-l)*this.velocityEma,1-N(this.velocityEma/this.t.MOTION_VELOCITY_IOD_PER_S)}guidanceOf(e,t,r){if(e.presence<=0)return"fcv3.no_face";if(e.single<=0)return"fcv3.one_face";if(e.size<this.t.GUIDE_SIZE)return this.sizeGuidance();if(e.centering<this.t.GUIDE_CENTERING)return"fcv3.center_face";if(e.pose<this.t.GUIDE_POSE)return"fcv3.straighten";if(e.exposure<this.t.GUIDE_EXPOSURE)return this.exposureGuidance(t);if(e.sharpness<this.t.GUIDE_SHARPNESS)return"fcv3.steady_camera";if(e.motion<this.t.GUIDE_MOTION)return"fcv3.hold_still";if(r<this.t.Q_GOOD){let s=[["size",this.sizeGuidance()],["centering","fcv3.center_face"],["pose","fcv3.straighten"],["exposure",this.exposureGuidance(t)],["sharpness","fcv3.steady_camera"],["motion","fcv3.hold_still"]],a=s[0];for(let o of s)e[o[0]]<e[a[0]]&&(a=o);return a[1]}return"fcv3.hold_still"}sizeGuidance(){return this.lastSizeDirection==="far"?"fcv3.come_closer":"fcv3.move_back"}exposureGuidance(e){let t=(ne[0]+ne[1])/2;return e.meanLuma<t?"fcv3.more_light":"fcv3.too_bright"}},n(W,"k"),W),si=["single","size","centering","pose","exposure","sharpness","motion"];function ai(i){if(i.accepted)return null;if(i.factors.presence<=0)return"no_face";let e="single";for(let t of si)i.factors[t]<i.factors[e]&&(e=t);return e}n(ai,"Ze");var z,st=(z=class{constructor(){this.blocked={},this.acceptedMs=0,this.ticks=0,this.lastAt=null}record(e){let t=this.lastAt===null?0:Math.max(0,e.at-this.lastAt);this.lastAt=e.at,this.ticks+=1;let r=ai(e);if(r===null){this.acceptedMs+=t;return}let s=this.blocked[r]??{count:0,ms:0};s.count+=1,s.ms+=t,this.blocked[r]=s}summary(){let e={};for(let[t,r]of Object.entries(this.blocked))e[t]={count:r.count,ms:Math.round(r.ms)};return{blocked:e,acceptedMs:Math.round(this.acceptedMs),ticks:this.ticks}}},n(z,"w"),z),ni=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo"],oi=[/^(front|back|rear)( [a-z ]+)? camera$/i,/^caméra (avant|arrière)\b/i,/^cámara (frontal|trasera|delantera)\b/i,/^câmera (frontal|traseira)\b/i,/^(front|rück)kamera\b/i,/^الكاميرا (الأمامية|الخلفية)/,/^camera2? ?\d+, facing (front|back|external)/i,/facetime/i,/\b(integrated|built-in|builtin) (web)?cam(era)?\b/i,/\b(hd )?web ?cam\b/i,/\([0-9a-f]{4}:[0-9a-f]{4}\)\s*$/i];function li(i){let e=(i??"").trim().toLowerCase();return e.length===0?"unknown":ni.some(t=>e.includes(t))?"known_virtual":oi.some(t=>t.test(e))?"platform":"unknown"}n(li,"je");function at(i){if(typeof i!="function")return!1;try{return/\{\s*\[native code\]\s*\}\s*$/.test(Function.prototype.toString.call(i))}catch{return!1}}n(at,"Te");function ci(i=globalThis){return at(i.navigator?.mediaDevices?.getUserMedia)&&at(i.MediaStreamTrack?.prototype?.getSettings)}n(ci,"$e");async function hi(i,e=globalThis){let t=e.crypto?.subtle?.digest;if(typeof t=="function")try{let r=new Uint8Array(await t.call(e.crypto?.subtle,"SHA-256",new TextEncoder().encode(i)));return Array.from(r.subarray(0,8),s=>s.toString(16).padStart(2,"0")).join("")}catch{return}}n(hi,"Je");async function ui(i,e=globalThis){let t={};try{t=typeof i.getSettings=="function"?i.getSettings()??{}:{}}catch{t={}}let r={};if((t.facingMode==="user"||t.facingMode==="environment"||t.facingMode==="left"||t.facingMode==="right")&&(r.facingMode=t.facingMode),typeof t.frameRate=="number"&&Number.isFinite(t.frameRate)&&(r.frameRate=t.frameRate),typeof t.width=="number"&&Number.isFinite(t.width)&&(r.width=t.width),typeof t.height=="number"&&Number.isFinite(t.height)&&(r.height=t.height),typeof t.deviceId=="string"&&t.deviceId.length>0){let a=await hi(t.deviceId,e);a!==void 0&&(r.deviceIdHash=a)}let s;try{s=i.label}catch{s=void 0}return{trackSettings:r,capabilitiesPresent:typeof i.getCapabilities=="function",labelClass:li(s),prototypesIntact:ci(e)}}n(ui,"Ce");var ue=n(i=>Math.round(i*100)/100,"K");function di(i){let e=i,t=typeof e?.requestVideoFrameCallback=="function",r=null,s=null,a=0,o=0,l=0,c=0,h=0,d=0,u=n(()=>{!t||e?.requestVideoFrameCallback===void 0||(r=e.requestVideoFrameCallback((v,w)=>{if(r=null,!t)return;let m=w.presentationTime;if(s!==null){let g=m-s.presentationTimeMs;o+=1;let y=g-l;l+=y/o,c+=y*(g-l)}typeof w.captureTime=="number"&&Number.isFinite(w.captureTime)&&(h+=m-w.captureTime,d+=1),a+=1,s={mediaTimeMs:w.mediaTime*1e3,presentationTimeMs:m},u()}))},"u");return u(),{latest:n(()=>s,"latest"),stats:n(()=>({n:a,meanGapMs:o===0?0:ue(l),stdGapMs:o<2?0:ue(Math.sqrt(c/(o-1))),captureLatencyMs:d===0?null:ue(h/d)}),"stats"),stop:n(()=>{t&&(t=!1,r!==null&&e?.cancelVideoFrameCallback?.(r),r=null)},"stop")}}n(di,"Ee");function fi(i,e,t){return{...i,rvfc:e,rampPainter:t}}n(fi,"_e");var mi=1e3,de="fcv3.hold_upright",pi=200,fe=4,gi=600,vi=1e3,nt={sharpness:1,exposure:1,meanLuma:128};function yi(i,e){return e.width=i.videoWidth,e.height=i.videoHeight,e.getContext("2d").drawImage(i,0,0),new Promise((t,r)=>e.toBlob(s=>s?t(s):r(new Error("empty-keyframe")),"image/jpeg",.92))}n(yi,"it");function wi(){return Y()==="phone"}n(wi,"at");var H,ut=(H=class{constructor(e){this.handlers=new Map,this.stateValue="idle",this.attempt=0,this.stream=null,this.detector=null,this.scheduler=null,this.gate=null,this.profiler=null,this.lastGuidanceKey=null,this.positioningStartedAt=0,this.cameraRequestedAt=null,this.cameraReadyAt=null,this.faceAcquiredAt=null,this.captureCompleteAt=null,this.fired=!1,this.carriedDegrade=0,this.carriedMeans=[],this.blockStats=null,this.lastGateSnapshotAt=Number.NEGATIVE_INFINITY,this.uprightGuard=!1,this.trackProvenance=null,this.ramp=null,this.snapshotCanvas=null,this.options=e,this.facing=e.facingMode??"user"}get state(){return this.stateValue}on(e,t){let r=this.handlers.get(e);return r||(r=new Set,this.handlers.set(e,r)),r.add(t),()=>r?.delete(t)}emit(e,t){for(let r of[...this.handlers.get(e)??[]])r(t)}async start(e={}){e.facingMode!==void 0&&(this.facing=e.facingMode),this.attempt+=1,await this.run(this.attempt)}get facingMode(){return this.facing}retry(){this.teardownAttempt(),this.start()}switchCamera(){this.facing=this.facing==="user"?"environment":"user",this.teardownAttempt(),this.start()}restart(e){this.facing=e,this.teardownAttempt(),this.start()}destroy(){this.attempt+=1,this.teardownAttempt(),this.detector?.destroy(),this.detector=null,this.options.video.srcObject=null}async run(e){let{options:t}=this;this.fired=!1,this.lastGuidanceKey=null,this.carriedDegrade=0,this.carriedMeans=[],this.cameraRequestedAt=null,this.cameraReadyAt=null,this.faceAcquiredAt=null,this.captureCompleteAt=null,this.uprightGuard=(t.isPhone??wi)(),this.setState("preflight");let r=Ue();if(r!=="OK"){this.fail(r==="INSECURE_CONTEXT"?"insecure":"unsupported",{phase:"preflight"});return}this.setState("acquiring");let s=t.getUserMedia??(h=>navigator.mediaDevices.getUserMedia(h)),a;this.cameraRequestedAt=this.now();try{let{facingMode:h,...d}=Se(Ie(),this.facing).video;a=await ze(this.facing,d,{getUserMedia:s,enumerateDevices:ki(t)})}catch(h){if(e!==this.attempt)return;if(h instanceof We){this.fail("backcamera",{phase:"acquiring",name:j(h)});return}this.fail(Le(h),{phase:"acquiring",name:j(h)});return}if(xe(a),qe(a),e!==this.attempt){for(let h of a.getTracks())h.stop();return}this.stream=a;let o=a.getVideoTracks?.()[0];if(this.trackProvenance=o===void 0?null:ui(o).catch(()=>null),this.facing=Ae(a)??this.facing,t.video.srcObject=a,await t.video.play().catch(()=>{}),e!==this.attempt)return;if(this.cameraReadyAt=this.now(),this.detector===null){let h={v3AssetBaseUrl:t.v3AssetBaseUrl},d=t.createDetector??(t.createWorker!==void 0&&Qe()?async()=>{try{return await Je.create(t.createWorker(),h)}catch{return x(h)}}:()=>x(h)),u;try{u=await d()}catch(v){e===this.attempt&&this.fail("models",{phase:"models",name:j(v)},v instanceof he?v.fallbackReason:Mi(v));return}if(e!==this.attempt){u.destroy();return}this.detector=u,this.options.telemetry?.({type:"detector",tier:u.tier,fallbackReason:u.fallbackReason})}let l=He(),c=t.deviceClass??Ke(l);this.profiler=new Xe(c),this.options.telemetry?.({type:"profile",staticClass:c,activeClass:this.profiler.deviceClass,simd:l.simd}),this.gate=new rt(t.thresholds??{}),this.blockStats=new st,this.lastGateSnapshotAt=this.now(),t.rankKeyframes?.()&&import("./keyframe-rank-YAJLYJYF-WCA6RPMD.js").then(h=>me=h,()=>{}),this.setState("positioning"),this.positioningStartedAt=this.now(),this.startScheduler(e)}get animations(){return this.profiler?.profile.animations??"full"}startScheduler(e){let t=this.profiler;if(t===null)return;if(this.scheduler!==null){let s=this.scheduler.stats();this.carriedDegrade+=s.degradeCount,s.meanDetectMs>0&&this.carriedMeans.push(s.meanDetectMs),this.scheduler.stop()}let r=new ii({cadenceHz:t.profile.cadenceHz,video:this.options.video,now:this.options.now,run:n(()=>this.detectTick(e),"run")});this.scheduler=r,r.start()}async detectTick(e){let{detector:t,gate:r,profiler:s}=this,a=this.options.video;if(e!==this.attempt||t===null||r===null||s===null||this.fired||a.videoWidth===0)return;if(this.isLandscape()){this.holdUpright(e);return}let o=s.deviceClass,l=this.now(),c=this.options.makeSnapshot?.(a,s.profile.inputWidth)??this.defaultSnapshot(a,s.profile.inputWidth),h=null;try{h=await t.detect(c,a.videoWidth,a.videoHeight)}catch{h=null}if(e!==this.attempt||this.fired)return;s.record(this.now()-l),s.deviceClass!==o&&this.startScheduler(e);let d=h===null?nt:this.options.measureQuality?.(a,h.box)??this.defaultQuality(a,h.box),u=r.tick({timestampMs:this.now(),observation:h,quality:d,frameWidth:a.videoWidth,frameHeight:a.videoHeight});u.accepted&&this.faceAcquiredAt===null&&(this.faceAcquiredAt=u.at),this.blockStats?.record(u),!u.ready&&u.at-this.lastGateSnapshotAt>=mi&&(this.lastGateSnapshotAt=u.at,this.reportGate(!1)),this.emit("checks",{engine:"v3",progress:u.p,q:u.q,factors:u.factors,attempt:e}),u.guidanceKey!==this.lastGuidanceKey&&(this.lastGuidanceKey=u.guidanceKey,this.emit("guidance",{key:u.guidanceKey})),u.ready&&this.stateValue==="positioning"&&(this.fired=!0,this.captureCompleteAt=u.at,this.fire(e))}async fire(e){let{options:t}=this,r=this.scheduler;r?.stop(),this.reportGate(!0);let s=r?.stats()??{degradeCount:0,meanDetectMs:0},a=[...this.carriedMeans,...s.meanDetectMs>0?[s.meanDetectMs]:[]];t.telemetry?.({type:"fired",timeToGateMs:this.now()-this.positioningStartedAt,degradeCount:this.carriedDegrade+s.degradeCount,meanDetectMs:a.length===0?0:a.reduce((T,b)=>T+b,0)/a.length});let o=t.mode??"clip",l=t.rankKeyframes?.()&&me?me.default(this,e).catch(()=>this.collectKeyframes(e)):this.collectKeyframes(e);if(o==="photo"){let T=this.watchRotation(e,null),b=await l;if(T(),e!==this.attempt)return;if(b===null){this.fail("generic",{phase:"keyframes"});return}let A=await this.provenance({n:0,meanGapMs:0,stdGapMs:0,captureLatencyMs:null},!1);if(e!==this.attempt)return;this.finishCapture({keyframe:b.blob,previewDataUrl:b.previewDataUrl,...A});return}this.setState("recording");let c=this.stream;if(c===null){this.fail("generic",{phase:"recording"});return}let h=t.screenRamp?.(),d=pe(h),u=null;l.then(T=>{u=T},()=>{});let v=n(()=>{e===this.attempt&&u!==null&&this.emit("frozen",{previewDataUrl:u.previewDataUrl})},"f"),w=Jt(h,ht),m=null,g,y=0;try{let T=this.recordTake(e,c,h,w,void 0).then(S=>S,S=>({failed:S})),[b,A]=await Promise.all([T,l]);if(g=A,e!==this.attempt)return;if("failed"in b){if(b.failed.kind==="cliptoolarge")throw b.failed;et(b.failed.requestedMimeType??"")}else m=b,it(b.clip,w)?b.clip.stats===null&&et(b.clip.requestedMimeType??""):v();if(m===null||it(m.clip,w)){y=1,t.telemetry?.({type:"clip_retake",reason:m===null?"error":m.clip.stats===null?"unreadable":"short"});let S=null;try{S=await this.recordTake(e,c,h,w,v)}catch(K){if(m===null)throw K}if(e!==this.attempt)return;S!==null&&(m===null||Xt(S.clip,m.clip))&&(m=S),S===null&&v()}}catch(T){if(e!==this.attempt)return;let b=T.kind;this.fail(b==="cliptoolarge"?"cliptoolarge":"recorder",{phase:"recording",name:j(T)});return}if(m===null){this.fail("recorder",{phase:"recording"});return}let{clip:p,rvfc:M,report:E}=m;if(ae(p.blob)){this.fail("cliptoolarge",{phase:"recording"});return}if(g===null){this.fail("generic",{phase:"keyframes"});return}let I=await this.provenance(M,d);e===this.attempt&&this.finishCapture({clip:p.blob,clipMimeType:p.mimeType,...p.stats?{clipStats:p.stats}:{},clipRetakes:y,keyframe:g.blob,previewDataUrl:g.previewDataUrl,...E!==void 0&&E.rendered.length>0?{screenRamp:E}:{},...I})}async recordTake(e,t,r,s,a){let o=this.options.createRecorder?.()??new Zt({now:n(()=>this.now(),"now")}),l=di(this.options.video),c=ei(r,{paint:n(u=>{(u===null||e===this.attempt)&&this.emit("ramp",{colour:u})},"paint"),now:n(()=>this.now(),"now"),frames:l.latest});this.ramp=c;let h=n(()=>{l.stop(),c.stop(),this.ramp===c&&(this.ramp=null)},"l"),d=this.watchRotation(e,o);try{return{clip:await o.record(t,a,()=>c.started(this.now()),s,l),rvfc:l.stats(),report:c.report()}}finally{d(),h()}}async provenance(e,t){let r=this.trackProvenance;if(r===null)return{};let s,a=new Promise(l=>{s=setTimeout(()=>l(null),vi)}),o=await Promise.race([r,a]);return clearTimeout(s),o===null?{}:{provenance:fi(o,e,t)}}isLandscape(){let e=this.options.video;return this.uprightGuard&&e.videoWidth>e.videoHeight}holdUpright(e){this.gate?.reset(),this.emit("checks",{engine:"v3",progress:0,q:0,factors:{presence:0,single:1,centering:0,size:0,pose:0,sharpness:0,exposure:0,motion:0},attempt:e}),this.lastGuidanceKey!==de&&(this.lastGuidanceKey=de,this.emit("guidance",{key:de}))}watchRotation(e,t){if(!this.uprightGuard)return()=>{};let r=this.options.video,s=n(()=>{if(e!==this.attempt||t!==null&&this.stateValue!=="recording"){l();return}r.videoWidth>0&&this.isLandscape()&&(l(),this.abortRecording(e,t))},"n"),a=setInterval(s,pi);r.addEventListener?.("resize",s);let o=!1;function l(){o||(o=!0,clearInterval(a),r.removeEventListener?.("resize",s))}return n(l,"o"),l}abortRecording(e,t){if(e!==this.attempt)return;this.attempt+=1;let r=this.attempt;try{t?.stop()}catch{}this.ramp?.stop(),this.ramp=null,this.fired=!1,this.captureCompleteAt=null,this.gate=new rt(this.options.thresholds??{}),this.blockStats=new st,this.lastGateSnapshotAt=this.now(),this.lastGuidanceKey=null,this.setState("positioning"),this.positioningStartedAt=this.now(),this.holdUpright(r),this.startScheduler(r)}async collectKeyframes(e){let t=this.options.captureKeyframe??(a=>this.defaultKeyframe(a)),r=gi/(fe-1),s=null;for(let a=0;a<fe;a+=1){if(e!==this.attempt)return s;try{let o=await t(this.options.video);(s===null||o.sharpness>s.sharpness)&&(s=o)}catch{}a<fe-1&&await bi(r)}return s}finishCapture(e){this.stopTracks(),this.setState("captured");let t=this.captureTiming();this.emit("artifacts",t===void 0?e:{...e,timing:t})}captureTiming(){let e={},t=n((r,s,a)=>{s!==null&&a!==null&&(e[r]=Math.max(0,Math.round(a-s)))},"t");return t("cameraReadyMs",this.cameraRequestedAt,this.cameraReadyAt),t("faceAcquireMs",this.cameraReadyAt,this.faceAcquiredAt),t("captureMs",this.faceAcquiredAt,this.captureCompleteAt),Object.keys(e).length>0?e:void 0}async defaultKeyframe(e){let t=document.createElement("canvas"),r=await(this.facing==="user"?ti:yi)(e,t),s=t.toDataURL("image/jpeg",.92);return{blob:r,previewDataUrl:s,sharpness:this.centerSharpness(e)}}defaultSnapshot(e,t){try{let r=this.snapshotCanvas??document.createElement("canvas"),s=t/Math.max(1,e.videoWidth),a=Math.max(1,Math.round(e.videoWidth*s)),o=Math.max(1,Math.round(e.videoHeight*s)),l=r.getContext("2d");return l===null?e:(r.width!==a&&(r.width=a),r.height!==o&&(r.height=o),l.drawImage(e,0,0,a,o),this.snapshotCanvas=r,r)}catch{return e}}defaultQuality(e,t){let r=ot(e,t,96);return r===null?nt:{sharpness:oe(r),exposure:Ve(r),meanLuma:Ze(r)}}centerSharpness(e){let t=Q(e),r=ot(e,{x:t.width*.25,y:t.height*.25,width:t.width*.5,height:t.height*.5},96);return r===null?0:oe(r)}teardownAttempt(){this.scheduler?.stop(),this.scheduler=null,this.reportGate(!0),this.gate=null,this.ramp?.stop(),this.ramp=null,this.stopTracks()}reportGate(e){let t=this.blockStats,r=this.profiler;if(t===null||r===null)return;let s=t.summary();e&&(this.blockStats=null),s.ticks!==0&&this.options.telemetry?.({type:"gate",final:e,activeClass:r.deviceClass,cadenceHz:r.profile.cadenceHz,...s})}stopTracks(){if(this.stream!==null){for(let e of this.stream.getTracks())e.stop();this.stream=null}}fail(e,t,r){this.scheduler?.stop(),this.reportGate(!0),this.stopTracks(),this.setState("error"),this.options.telemetry?.({type:"error",kind:e,fallbackReason:r});let{phase:s,name:a}=t;this.emit("error",{kind:e,retryable:e!=="insecure"&&e!=="unsupported",detail:a===void 0?{phase:s}:{phase:s,name:a}})}setState(e){this.stateValue=e,this.emit("statechange",{state:e})}now(){return this.options.now?.()??performance.now()}},n(H,"ke"),H),me;function bi(i){return new Promise(e=>setTimeout(e,i))}n(bi,"st");function Mi(i){return i instanceof Error?i.message:String(i)}n(Mi,"ot");function ot(i,e,t){try{let r=document.createElement("canvas"),s=t/Math.max(1,e.width);r.width=Math.max(1,Math.round(e.width*s)),r.height=Math.max(1,Math.round(e.height*s));let a=r.getContext("2d");return a===null?null:(a.drawImage(i,e.x,e.y,e.width,e.height,0,0,r.width,r.height),a.getImageData(0,0,r.width,r.height))}catch{return null}}n(ot,"we");function ki(i){if(i.enumerateDevices!==void 0)return i.enumerateDevices;if(i.getUserMedia===void 0&&!(typeof navigator>"u"||typeof navigator.mediaDevices?.enumerateDevices!="function"))return()=>navigator.mediaDevices.enumerateDevices()}n(ki,"lt");var Ti=12e4,dt=13e4,_i=3e3,Ei=1200,ge=Symbol.for("@sekyro/web.preload.v1");function ye(){let i=globalThis;return i[ge]??(i[ge]=new Map),i[ge]}n(ye,"h");function te(i){let e=(i??ce).replace(/\/+$/,"");return e===""?"/":e}n(te,"b");function mt(i){let e=ye(),t=e.get(i);return t===void 0&&(t={status:"idle",promise:null,scheduled:null,detectorPromise:null,detector:null,listeners:new Set},e.set(i,t)),t}n(mt,"ae");function ve(i,e){if(i.status!==e){i.status=e;for(let t of[...i.listeners])t(e)}}n(ve,"k");var Si=n(i=>x({preferred:["blaze"],v3AssetBaseUrl:i,blazeInitTimeoutMs:Ti}),"K"),Ii=Si;function Ai(){return typeof window<"u"&&typeof navigator<"u"&&typeof navigator.mediaDevices?.getUserMedia=="function"}n(Ai,"Ce");function xi(){return navigator.connection?.saveData===!0}n(xi,"Se");function Di(i){let e=window;if(typeof e.requestIdleCallback=="function"){let r=e.requestIdleCallback(i,{timeout:_i});return()=>e.cancelIdleCallback?.(r)}let t=setTimeout(i,Ei);return()=>clearTimeout(t)}n(Di,"Ee");function Ri(i,e){let t,r=new Promise(l=>{t=l}),s=!1,a=n(()=>{},"u"),o={promise:r,settle:n(l=>{s||(s=!0,a(),i.scheduled===o&&(i.scheduled=null),t(l))},"settle")};return i.scheduled=o,a=Di(()=>{s||o.settle(we(i,e))}),r}n(Ri,"ye");function we(i,e){if((i.status==="loading"||i.status==="ready")&&i.promise!==null)return i.promise;ve(i,"loading");let t=new Promise(o=>o(Ii(e)));i.detectorPromise=t;let r,s=new Promise((o,l)=>{r=setTimeout(()=>{t.then(c=>c.destroy(),()=>{}),l(new Error(`detector preload exceeded ${dt} ms`))},dt)}),a=Promise.race([t,s]).then(o=>i.detectorPromise!==t?(o.destroy(),i.status):(i.detector=o,ve(i,"ready"),"ready"),o=>(i.detectorPromise===t&&(i.detectorPromise=null,i.detector=null,ve(i,"failed"),console.warn("[@sekyro/web] face-detector preload failed:",o)),i.status)).finally(()=>clearTimeout(r));return i.promise=a,i.scheduled?.settle(a),a}n(we,"U");function sr(i={}){if(!Ai())return Promise.resolve("idle");let e=te(i.assetBaseUrl),t=mt(e);return i.respectSaveData===!0&&xi()?Promise.resolve(t.status):(t.status==="loading"||t.status==="ready")&&t.promise!==null?t.promise:i.idle===!0?t.scheduled?.promise??Ri(t,e):we(t,e)}n(sr,"xe");function ar(i){return ye().get(te(i))?.status??"idle"}n(ar,"Fe");function nr(i,e){let t=mt(te(e));return t.listeners.add(i),()=>{t.listeners.delete(i)}}n(nr,"Ie");function Ci(i){return{get tier(){return i.tier},get fallbackReason(){return i.fallbackReason},detect:n((...e)=>i.detect(...e),"detect"),destroy:n(()=>{},"destroy")}}n(Ci,"Le");function Oi(i){let e=te(i),t=ye().get(e);if(!(t===void 0||t.detector===null&&t.detectorPromise===null&&t.scheduled===null))return async()=>{t.scheduled!==null&&we(t,e);let r=t.promise;for(;t.detector===null&&r!==null&&(await r,t.promise!==r);)r=t.promise;return t.detector!==null?Ci(t.detector):x({v3AssetBaseUrl:e})}}n(Oi,"de");var Gi=new Set(["inuse","overconstrained","notfound"]),Pi=[500,1500];function Ui(i){switch(i){case"fcv3.no_face":case"fcv3.center_face":case"fcv3.straighten":return"center";case"fcv3.come_closer":return"closer";case"fcv3.move_back":return"farther";case"fcv3.more_light":case"fcv3.too_bright":return"light";case"fcv3.hold_still":case"fcv3.steady_camera":return"still";case"fcv3.hold_upright":return"upright";case"fcv3.one_face":return"one_face";default:return null}}n(Ui,"Ae");function Fi(i){switch(i){case"preflight":case"acquiring":return"starting";case"positioning":return"gating";default:return i}}n(Fi,"Pe");function ft(i){switch(i){case"permission":case"notfound":case"inuse":case"insecure":case"unsupported":return i;case"backcamera":return"notfound";default:{let e=i;return"generic"}}}n(ft,"ue");function Ni(i,e,t){if(t===void 0)return{kind:ft(i),retryable:e};let r=Be(t.name);return{kind:ft(i),retryable:e,detail:{...r!==void 0?{name:r}:{},phase:t.phase,engineKind:i}}}n(Ni,"we");var Bi=new Set(["captured","uploading","checking"]);function Li(i,e={},t,r=()=>"self",s=()=>{},a){let o=e.now??(()=>performance.now()),l=e.canChooseFacing??Re,c="user",h=Ce(),d=r(),u=De(),v=!Fe(),w=e.engineOptions,m=w?.createDetector===void 0&&w?.createWorker===void 0?{createDetector:n(()=>{let f=Oi(i.assetBaseUrl);return f!==void 0?f():x({v3AssetBaseUrl:i.assetBaseUrl})},"createDetector")}:{},g={video:i.video,mode:v?"photo":"clip",rankKeyframes:t,facingMode:void 0,v3AssetBaseUrl:i.assetBaseUrl,screenRamp:n(()=>d==="self"&&u.count("ramp")>0?s():void 0,"screenRamp"),...e.engineOptions??{},...m},y=e.createEngine?.(g)??new ut(g),p="idle",M=null,E=0,I=!1,T="full",b=null,A=null,S=0,K=0,be=n(()=>{i.video.videoWidth>0&&i.video.videoHeight>0&&(S=i.video.videoWidth,K=i.video.videoHeight)},"W"),Me=Oe({enabled:i.keepScreenAwake!==!1}),X=n(f=>{p=f,Me.setActive(f==="starting"||f==="gating"||f==="recording"),u.emit("state",f)},"S"),ie=n(()=>u.emit("gate",{progress:E,hint:M,faceDetected:I}),"F"),re=n(()=>{let f=y.animations??"full";f!==T&&(T=f,u.emit("profile",{animations:T}))},"I"),G=0,$=null,pt=e.schedule??((f,k)=>{let _=setTimeout(f,k);return()=>clearTimeout(_)}),Z=n(()=>{$?.(),$=null},"E"),gt=n((f,k)=>{if(V||!Gi.has(f)||k?.phase!=="acquiring")return!1;let _=Pi[G];return _===void 0?!1:(G+=1,Z(),$=pt(()=>{$=null,V||y.retry()},_),!0)},"fe"),vt=[y.on("statechange",({state:f})=>{if(f==="error")return;let k=Fi(f);k==="gating"&&(G=0),k==="starting"&&p!=="starting"&&(M=null,E=0,I=!1,b=null,A=null,S=0,K=0),X(k),re(),k==="recording"&&(be(),b=o(),M="hold",E=1,ie())}),y.on("checks",f=>{be(),E=f.progress,I=f.factors.presence>0,ie(),re()}),y.on("guidance",({key:f})=>{M=Ui(f),ie()}),y.on("frozen",({previewDataUrl:f})=>{A=o(),u.emit("frozen",{previewDataUrl:f})}),y.on("ramp",f=>u.emit("ramp",f)),y.on("artifacts",f=>{if(p!=="captured")return;let k=Y(),_=f.clipStats,_e=_!==void 0?Math.round(_.durationMs):b!==null&&A!==null?Math.max(0,Math.round(A-b)):void 0,Ee=_!==void 0&&_.frames>1&&_.durationMs>0?Math.round(_.frames*1e4/_.durationMs)/10:void 0;u.emit("captured",{keyframe:f.keyframe,...f.clip!==void 0?{clip:f.clip}:{},...f.clipMimeType!==void 0?{clipMime:f.clipMimeType}:{},width:i.video.videoWidth||S,height:i.video.videoHeight||K,..._e!==void 0?{clipMs:_e}:{},..._!==void 0?{clipFrames:_.frames}:{},...Ee!==void 0?{fps:Ee}:{},...f.clipRetakes!==void 0?{clipRetakes:f.clipRetakes}:{},...f.clipMimeType!==void 0?{codec:ct(f.clipMimeType)}:{},captureChannel:k==="desktop"?"desktop":"mobile",formFactor:k,...v?{degraded:"NO_RECORDER"}:{},engine:"v3",facingMode:y.facingMode,mode:d,...f.timing,...f.screenRamp!==void 0?{screenRamp:f.screenRamp}:{},...f.provenance!==void 0?{provenance:f.provenance}:{}})}),y.on("error",({kind:f,retryable:k,detail:_})=>{f==="backcamera"&&yt()||gt(f,_)||(X("error"),re(),u.emit("error",Ni(f,k,_)))})],ke=!1;function yt(){return V||ke||d!=="assisted"||a===void 0||a.session()!=="choice"?!1:(ke=!0,a.onModeChange("self"),d="self",c=se("self"),X("mode_switch"),y.restart(c),!0)}n(yt,"me");let Te=n(async()=>a!==void 0&&a.session()==="choice"&&await l().catch(()=>!1),"$"),V=!1;return{handle:{get state(){return p},get captureMode(){return r()},get facingMode(){return y.facingMode??c},on:n((f,k)=>u.on(f,k),"on"),start:n(f=>(d=r(),h.facing(d,i.facing),c=h.facing(d,f?.facing),Z(),G=0,y.start({facingMode:c})),"start"),retry:n(()=>{Z(),G=0,y.retry()},"retry"),switchCamera:n(()=>h.refuseSwitch(r()),"switchCamera"),canSwitchCaptureMode:Te,setCaptureMode:n(async f=>{if(f===r()||!await Te()||V||Bi.has(p)||a===void 0)return!1;a.onModeChange(f),d=f;let k=se(f);return c=k,p==="idle"||(X("mode_switch"),Z(),G=0,y.restart(k)),!0},"setCaptureMode"),destroy:n(()=>{V=!0,Z();for(let f of vt)f();Me.setActive(!1),y.destroy(),u.clear()},"destroy")},setFlowState:n(f=>{p!==f&&X(f)},"setFlowState")}}n(Li,"De");function or(i){return Li(i).handle}n(or,"Ze");export{$i as a,sr as b,ar as c,nr as d,Ni as e,Li as f,or as g};
@@ -1 +1 @@
1
- import{c as M}from"./chunk-BIK4PGBE.js";import{a as c}from"./chunk-P7K7ELYZ.js";import{a as r}from"./chunk-4FHWXBOB.js";var T=480,I=Object.freeze({MIN_AREA_FRAC:.15,EDGE_CLIP_MARGIN_PX:4,STABLE_TICKS:3,IOU_STABLE_MIN:.85,RISE_PER_S:.9,FALL_PER_S:.25,GUIDE_EXPOSURE:.6,GUIDE_SHARPNESS:.35,ID3_BAND_MIN_WIDTH_FRAC:.55,ID3_BAND_ASPECT_MIN:4,ID3_BAND_ASPECT_MAX:40}),x=r(i=>Math.min(1,Math.max(0,i)),"p");function E(i,h,t){let s=[i.topLeft,i.topRight,i.bottomRight,i.bottomLeft],e=0;for(let a=0;a<4;a++){let l=s[a],_=s[(a+1)%4];e+=l.x*_.y-_.x*l.y}let o=h*t;return o>0?Math.abs(e/2)/o:0}r(E,"E");function g(i,h){let t=A(i),s=A(h),e=Math.max(t.x1,s.x1),o=Math.max(t.y1,s.y1),a=Math.min(t.x2,s.x2),l=Math.min(t.y2,s.y2),_=Math.max(0,a-e)*Math.max(0,l-o),d=(t.x2-t.x1)*(t.y2-t.y1),u=(s.x2-s.x1)*(s.y2-s.y1),p=d+u-_;return p>0?_/p:0}r(g,"I");function L(i){let h=A(i);return{width:h.x2-h.x1,height:h.y2-h.y1}}r(L,"R");function A(i){let h=[i.topLeft,i.topRight,i.bottomRight,i.bottomLeft];return{x1:Math.min(...h.map(t=>t.x)),y1:Math.min(...h.map(t=>t.y)),x2:Math.max(...h.map(t=>t.x)),y2:Math.max(...h.map(t=>t.y))}}r(A,"D");function S(i){let h=Math.hypot(i.topRight.x-i.topLeft.x,i.topRight.y-i.topLeft.y),t=Math.hypot(i.bottomRight.x-i.bottomLeft.x,i.bottomRight.y-i.bottomLeft.y),s=Math.hypot(i.bottomLeft.x-i.topLeft.x,i.bottomLeft.y-i.topLeft.y),e=Math.hypot(i.bottomRight.x-i.topRight.x,i.bottomRight.y-i.topRight.y),o=(h+t)/2,a=(s+e)/2;return o<=0||a<=0?0:Math.max(o,a)/Math.min(o,a)}r(S,"M");var n,N=(n=class{constructor(h,t={}){this.p=0,this.lastTickAt=null,this.lastQuad=null,this.streak=0,this.format=h,this.t={...I,...t}}reset(){this.p=0,this.lastTickAt=null,this.lastQuad=null,this.streak=0}tick(h){let{quad:t,quality:s,timestampMs:e}=h,o=this.lastTickAt===null?0:Math.max(0,(e-this.lastTickAt)/1e3);this.lastTickAt=e;let a=null;if(t===null)a="dcv1.no_doc";else if(this.format==="ID-3"){let m=L(t),y=m.height>0?m.width/m.height:0;m.width<this.t.ID3_BAND_MIN_WIDTH_FRAC*h.frameWidth?a="dcv1.come_closer":this.edgeClipped(t,h.frameWidth,h.frameHeight)?a="dcv1.fit_document":(y<this.t.ID3_BAND_ASPECT_MIN||y>this.t.ID3_BAND_ASPECT_MAX)&&(a="dcv1.wrong_shape")}else E(t,h.frameWidth,h.frameHeight)<this.t.MIN_AREA_FRAC?a="dcv1.come_closer":this.edgeClipped(t,h.frameWidth,h.frameHeight)?a="dcv1.fit_document":M(this.format,S(t))||(a="dcv1.wrong_shape");let l=a===null,_=x(s.exposure)>=this.t.GUIDE_EXPOSURE,d=x(s.sharpness)>=this.t.GUIDE_SHARPNESS,u=_&&d;if(l&&u&&t!==null){let m=this.lastQuad===null||g(t,this.lastQuad)>=this.t.IOU_STABLE_MIN;this.streak=m?this.streak+1:1}else this.streak=0;this.lastQuad=t;let p=l&&u;this.p=x(this.p+(p?this.t.RISE_PER_S:-this.t.FALL_PER_S)*o);let R=p&&this.streak>=this.t.STABLE_TICKS,f;if(a!==null)f=a;else if(_)d?f="dcv1.hold_still":f="dcv1.steady";else{let m=(c[0]+c[1])/2;f=s.meanLuma<m?"dcv1.more_light":"dcv1.too_bright"}return{at:e,quad:t,plausible:l,p:this.p,guidanceKey:f,ready:R,stableTicks:this.streak}}edgeClipped(h,t,s){let e=this.t.EDGE_CLIP_MARGIN_PX;return[h.topLeft,h.topRight,h.bottomRight,h.bottomLeft].some(o=>o.x<=e||o.y<=e||o.x>=t-e||o.y>=s-e)}},r(n,"d"),n);export{T as a,I as b,E as c,L as d,N as e};
1
+ import{c as M}from"./chunk-XSGZY4JI.js";import{a as c}from"./chunk-P7K7ELYZ.js";import{a as r}from"./chunk-4FHWXBOB.js";var T=480,I=Object.freeze({MIN_AREA_FRAC:.15,EDGE_CLIP_MARGIN_PX:4,STABLE_TICKS:3,IOU_STABLE_MIN:.85,RISE_PER_S:.9,FALL_PER_S:.25,GUIDE_EXPOSURE:.6,GUIDE_SHARPNESS:.35,ID3_BAND_MIN_WIDTH_FRAC:.55,ID3_BAND_ASPECT_MIN:4,ID3_BAND_ASPECT_MAX:40}),x=r(i=>Math.min(1,Math.max(0,i)),"p");function E(i,h,t){let s=[i.topLeft,i.topRight,i.bottomRight,i.bottomLeft],e=0;for(let a=0;a<4;a++){let l=s[a],_=s[(a+1)%4];e+=l.x*_.y-_.x*l.y}let o=h*t;return o>0?Math.abs(e/2)/o:0}r(E,"E");function g(i,h){let t=A(i),s=A(h),e=Math.max(t.x1,s.x1),o=Math.max(t.y1,s.y1),a=Math.min(t.x2,s.x2),l=Math.min(t.y2,s.y2),_=Math.max(0,a-e)*Math.max(0,l-o),d=(t.x2-t.x1)*(t.y2-t.y1),u=(s.x2-s.x1)*(s.y2-s.y1),p=d+u-_;return p>0?_/p:0}r(g,"I");function L(i){let h=A(i);return{width:h.x2-h.x1,height:h.y2-h.y1}}r(L,"R");function A(i){let h=[i.topLeft,i.topRight,i.bottomRight,i.bottomLeft];return{x1:Math.min(...h.map(t=>t.x)),y1:Math.min(...h.map(t=>t.y)),x2:Math.max(...h.map(t=>t.x)),y2:Math.max(...h.map(t=>t.y))}}r(A,"D");function S(i){let h=Math.hypot(i.topRight.x-i.topLeft.x,i.topRight.y-i.topLeft.y),t=Math.hypot(i.bottomRight.x-i.bottomLeft.x,i.bottomRight.y-i.bottomLeft.y),s=Math.hypot(i.bottomLeft.x-i.topLeft.x,i.bottomLeft.y-i.topLeft.y),e=Math.hypot(i.bottomRight.x-i.topRight.x,i.bottomRight.y-i.topRight.y),o=(h+t)/2,a=(s+e)/2;return o<=0||a<=0?0:Math.max(o,a)/Math.min(o,a)}r(S,"M");var n,N=(n=class{constructor(h,t={}){this.p=0,this.lastTickAt=null,this.lastQuad=null,this.streak=0,this.format=h,this.t={...I,...t}}reset(){this.p=0,this.lastTickAt=null,this.lastQuad=null,this.streak=0}tick(h){let{quad:t,quality:s,timestampMs:e}=h,o=this.lastTickAt===null?0:Math.max(0,(e-this.lastTickAt)/1e3);this.lastTickAt=e;let a=null;if(t===null)a="dcv1.no_doc";else if(this.format==="ID-3"){let m=L(t),y=m.height>0?m.width/m.height:0;m.width<this.t.ID3_BAND_MIN_WIDTH_FRAC*h.frameWidth?a="dcv1.come_closer":this.edgeClipped(t,h.frameWidth,h.frameHeight)?a="dcv1.fit_document":(y<this.t.ID3_BAND_ASPECT_MIN||y>this.t.ID3_BAND_ASPECT_MAX)&&(a="dcv1.wrong_shape")}else E(t,h.frameWidth,h.frameHeight)<this.t.MIN_AREA_FRAC?a="dcv1.come_closer":this.edgeClipped(t,h.frameWidth,h.frameHeight)?a="dcv1.fit_document":M(this.format,S(t))||(a="dcv1.wrong_shape");let l=a===null,_=x(s.exposure)>=this.t.GUIDE_EXPOSURE,d=x(s.sharpness)>=this.t.GUIDE_SHARPNESS,u=_&&d;if(l&&u&&t!==null){let m=this.lastQuad===null||g(t,this.lastQuad)>=this.t.IOU_STABLE_MIN;this.streak=m?this.streak+1:1}else this.streak=0;this.lastQuad=t;let p=l&&u;this.p=x(this.p+(p?this.t.RISE_PER_S:-this.t.FALL_PER_S)*o);let R=p&&this.streak>=this.t.STABLE_TICKS,f;if(a!==null)f=a;else if(_)d?f="dcv1.hold_still":f="dcv1.steady";else{let m=(c[0]+c[1])/2;f=s.meanLuma<m?"dcv1.more_light":"dcv1.too_bright"}return{at:e,quad:t,plausible:l,p:this.p,guidanceKey:f,ready:R,stableTicks:this.streak}}edgeClipped(h,t,s){let e=this.t.EDGE_CLIP_MARGIN_PX;return[h.topLeft,h.topRight,h.bottomRight,h.bottomLeft].some(o=>o.x<=e||o.y<=e||o.x>=t-e||o.y>=s-e)}},r(n,"d"),n);export{T as a,I as b,E as c,L as d,N as e};