@sekyro/web 0.1.0-rc.23 → 0.1.0-rc.25

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 (49) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +34 -2
  3. package/dist/{capture-session-doc-BBDKMEAP.js → capture-session-doc-O33KRXH7.js} +1 -1
  4. package/dist/{capture-session-v3-CFXYS0Pg.d.cts → capture-session-v3-BoGn8vLv.d.cts} +1 -1
  5. package/dist/{capture-session-v3-DID39wUZ.d.ts → capture-session-v3-C0bbHvDc.d.ts} +1 -1
  6. package/dist/challenge-frame-NUGPTWFP.js +1 -0
  7. package/dist/{chunk-LFMIFR6T.js → chunk-24F6JCVH.js} +1 -1
  8. package/dist/chunk-4ESM6SSR.js +1 -0
  9. package/dist/chunk-6XXMWK72.js +1 -0
  10. package/dist/{chunk-JWEHH2MS.js → chunk-7HV77AOV.js} +1 -1
  11. package/dist/{chunk-5DTWBDCP.js → chunk-DIKSFEYQ.js} +1 -1
  12. package/dist/{chunk-JYU5YHXN.js → chunk-EHKCOBE2.js} +1 -1
  13. package/dist/chunk-GLXOSYBH.js +3 -0
  14. package/dist/chunk-HVW2AB35.js +1 -0
  15. package/dist/{chunk-PBLZ5W7P.js → chunk-J4S3QMK6.js} +1 -1
  16. package/dist/{chunk-YWGW63B3.js → chunk-MGO2ME5X.js} +1 -1
  17. package/dist/client/index.cjs +1 -1
  18. package/dist/client/index.d.cts +3 -3
  19. package/dist/client/index.d.ts +3 -3
  20. package/dist/client/index.js +1 -1
  21. package/dist/core/index.cjs +1 -1
  22. package/dist/core/index.d.cts +3 -3
  23. package/dist/core/index.d.ts +3 -3
  24. package/dist/core/index.js +1 -1
  25. package/dist/{create-document-capture-K5PDVOGV.js → create-document-capture-OLKNUVTU.js} +1 -1
  26. package/dist/{create-verification-BP2L4rzV.d.cts → create-verification-D5CrT5f5.d.cts} +66 -10
  27. package/dist/{create-verification-Dc1Rd-4T.d.ts → create-verification-DOBYRCV_.d.ts} +66 -10
  28. package/dist/{icao-gate-COt4O4h_.d.ts → icao-gate-CJPTgKFb.d.ts} +1 -1
  29. package/dist/{icao-gate-CIXjbPCL.d.cts → icao-gate-DGtY696t.d.cts} +1 -1
  30. package/dist/{icao-policy-Cizs5guu.d.cts → icao-policy-Bm0rG91t.d.cts} +2 -2
  31. package/dist/{icao-policy-DI4kU6Mv.d.ts → icao-policy-D8domgld.d.ts} +2 -2
  32. package/dist/index.cjs +3 -1
  33. package/dist/index.d.cts +7 -7
  34. package/dist/index.d.ts +7 -7
  35. package/dist/index.js +1 -1
  36. package/dist/internal/index.cjs +3 -1
  37. package/dist/internal/index.d.cts +7 -52
  38. package/dist/internal/index.d.ts +7 -52
  39. package/dist/internal/index.js +1 -1
  40. package/dist/{plan-runner-AD2JTMC7.js → plan-runner-VKPRZ3AD.js} +1 -1
  41. package/dist/{types-Cjnp1o8i.d.cts → types-ZBcpvLdo.d.cts} +34 -23
  42. package/dist/{types-Cjnp1o8i.d.ts → types-ZBcpvLdo.d.ts} +34 -23
  43. package/package.json +1 -1
  44. package/sbom.cdx.json +10 -10
  45. package/dist/chunk-72LG73YL.js +0 -1
  46. package/dist/chunk-RPVI2OGR.js +0 -1
  47. package/dist/chunk-U3NYGTX7.js +0 -1
  48. package/dist/chunk-X6UIO5E3.js +0 -1
  49. package/dist/turnstile-F4DS2L3F.js +0 -1
@@ -1 +1 @@
1
- "use strict";var fr=Object.create;var Y=Object.defineProperty;var pr=Object.getOwnPropertyDescriptor;var hr=Object.getOwnPropertyNames;var gr=Object.getPrototypeOf,br=Object.prototype.hasOwnProperty;var L=(t,e)=>()=>(t&&(e=t(t=0)),e);var N=(t,e)=>{for(var r in e)Y(t,r,{get:e[r],enumerable:!0})},Ke=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of hr(e))!br.call(t,i)&&i!==r&&Y(t,i,{get:()=>e[i],enumerable:!(n=pr(e,i))||n.enumerable});return t};var yr=(t,e,r)=>(r=t!=null?fr(gr(t)):{},Ke(e||!t||!t.__esModule?Y(r,"default",{value:t,enumerable:!0}):r,t)),vr=t=>Ke(Y({},"__esModule",{value:!0}),t);var rt={};N(rt,{blobBytes:()=>Xe,inspectClip:()=>Rr,inspectClipBytes:()=>Ye,webmDurationMs:()=>Hr,withWebmDuration:()=>Br});async function Rr(t){try{return Ye(await Xe(t))}catch{return null}}async function Xe(t){return typeof t.arrayBuffer=="function"?new Uint8Array(await t.arrayBuffer()):new Promise((e,r)=>{let n=new FileReader;n.onload=()=>e(new Uint8Array(n.result)),n.onerror=()=>r(n.error),n.readAsArrayBuffer(t)})}function Ye(t){if(t.length<8)return null;try{if(t[0]===26&&t[1]===69&&t[2]===223&&t[3]===163)return Gr(t);if(be(t,4,4)==="ftyp")return Ar(t)}catch{return null}return null}function Ar(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength),r=[],n=null,i=null,a=0,o=(c,u)=>{let l=c;for(;l+8<=u;){let d=e.getUint32(l),f=be(t,l+4,4),h=8;if(d===1){if(l+16>u)return;d=Number(e.getBigUint64(l+8)),h=16}else d===0&&(d=u-l);if(d<h)return;let p=Math.min(l+d,u),m=l+h;if(f==="trak"&&(n={id:0,video:!1,timescale:0,frames:0,units:0,defaultDuration:0},r.push(n)),f==="traf"&&(i=null,a=0),_r.has(f))o(m,p);else if(f==="tkhd"&&n)n.id=e.getUint32(m+(t[m]===1?20:12));else if(f==="hdlr"&&n)n.video=be(t,m+8,4)==="vide";else if(f==="mdhd"&&n)n.timescale=e.getUint32(m+(t[m]===1?20:12));else if(f==="stts"&&n){let b=e.getUint32(m+4);for(let g=0;g<b;g++){let y=e.getUint32(m+8+g*8);n.frames+=y,n.units+=y*e.getUint32(m+12+g*8)}}else if(f==="trex"){let b=r.find(g=>g.id===e.getUint32(m+4));b&&(b.defaultDuration=e.getUint32(m+12))}else if(f==="tfhd"){let b=e.getUint32(m)&16777215;i=r.find(y=>y.id===e.getUint32(m+4))??null;let g=m+8;b&1&&(g+=8),b&2&&(g+=4),a=b&8?e.getUint32(g):i?.defaultDuration??0}else if(f==="trun"&&i){let b=e.getUint32(m)&16777215,g=e.getUint32(m+4),y=m+8;b&1&&(y+=4),b&4&&(y+=4);let S=(b&256?4:0)+(b&512?4:0)+(b&1024?4:0)+(b&2048?4:0);for(let M=0;M<g;M++)i.units+=b&256?e.getUint32(y+M*S):a;i.frames+=g}l=p}};o(0,t.length);let s=r.find(c=>c.video&&c.timescale>0);return!s||s.frames===0?null:{container:"mp4",frames:s.frames,durationMs:Me(s.units*1e3/s.timescale)}}function Ur(t,e){let r=t[e];if(r===void 0||r===0)return null;let n=Math.clz32(r)-23;if(n<1||n>4||e+n>t.length)return null;let i=0;for(let a=0;a<n;a++)i=i*256+t[e+a];return[i,n]}function tt(t,e){let r=t[e];if(r===void 0||r===0)return null;let n=Math.clz32(r)-23;if(n<1||n>8||e+n>t.length)return null;let i=r&255>>n,a=i===255>>n;for(let o=1;o<n;o++){let s=t[e+o];i=i*256+s,s!==255&&(a=!1)}return[a?-1:i,n]}function C(t,e,r){let n=0;for(let i=0;i<r;i++)n=n*256+t[e+i];return n}function ve(t){let e=[],r=0;for(;r<t.length;){let n=Ur(t,r);if(!n)break;let i=tt(t,r+n[1]);if(!i)break;let a={id:n[0],start:r,sizeAt:r+n[1],data:r+n[1]+i[1],size:i[0]};if(e.push(a),et.has(a.id))r=a.data;else{if(a.size<0)break;r=a.data+a.size}}return e}function Gr(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength),r=1e6,n=[],i=0,a=[];for(let c of ve(t)){if(c.data+Math.max(0,c.size)>t.length&&!et.has(c.id))break;switch(c.id){case ye:r=C(t,c.data,c.size)||r;break;case Qe:n.push({num:0,type:0});break;case Or:n.length&&(n[n.length-1].num=C(t,c.data,c.size));break;case Pr:n.length&&(n[n.length-1].type=C(t,c.data,c.size));break;case Fr:i=C(t,c.data,c.size);break;case Lr:case Nr:{let u=tt(t,c.data);if(!u||c.data+u[1]+2>t.length)break;let l=n.filter(d=>d.type===1).map(d=>d.num);if(l.length>0&&!l.includes(u[0]))break;a.push((i+e.getInt16(c.data+u[1]))*r/1e6);break}default:break}}if(a.length===0)return null;a.sort((c,u)=>c-u);let o=a.slice(1).map((c,u)=>c-a[u]),s=o.length?o.sort((c,u)=>c-u)[Math.floor(o.length/2)]:0;return{container:"webm",frames:a.length,durationMs:Me(a[a.length-1]-a[0]+s)}}function Br(t,e){if(!(e>0))return null;let r=ve(t),n=r.find(m=>m.id===Ze);if(!n||n.size!==-1||r.some(m=>m.id===Vr))return null;let i=r.find(m=>m.id===je);if(!i||i.size<0||i.data+i.size>t.length)return null;let a=1e6,o=[];for(let m of r)m.start<i.data||m.start>=i.data+i.size||(m.id===ye&&(a=C(t,m.data,m.size)||a),m.id!==Je&&o.push(t.subarray(m.start,m.data+m.size)));let s=new Uint8Array(11);s.set([68,137,136]),new DataView(s.buffer).setFloat64(3,e*1e6/a);let c=o.reduce((m,b)=>m+b.length,0)+s.length,u=new Uint8Array(12);u.set([21,73,169,102,1]);let l=c;for(let m=11;m>=5;m--)u[m]=l&255,l=Math.floor(l/256);let d=t.subarray(i.data+i.size),f=new Uint8Array(i.start+u.length+c+d.length),h=0,p=m=>{f.set(m,h),h+=m.length};return p(t.subarray(0,i.start)),p(u),o.forEach(p),p(s),p(d),f}function Hr(t){let e=1e6,r=null,n=new DataView(t.buffer,t.byteOffset,t.byteLength);for(let i of ve(t))if(i.id===ye&&(e=C(t,i.data,i.size)||e),i.id===Je&&(r=i.size===8?n.getFloat64(i.data):i.size===4?n.getFloat32(i.data):null),i.id===$e)break;return r===null?null:Me(r*e/1e6)}function be(t,e,r){let n="";for(let i=0;i<r&&e+i<t.length;i++)n+=String.fromCharCode(t[e+i]);return n}function Me(t){return Math.round(t*10)/10}var _r,Ze,je,Dr,Qe,$e,Ir,ye,Je,Or,Pr,Fr,Lr,Nr,Vr,et,nt=L(()=>{"use strict";_r=new Set(["moov","trak","mdia","minf","stbl","mvex","moof","traf","edts"]);Ze=408125543,je=357149030,Dr=374648427,Qe=174,$e=524531317,Ir=160,ye=2807729,Je=17545,Or=215,Pr=131,Fr=231,Lr=163,Nr=161,Vr=290298740,et=new Set([Ze,je,Dr,Qe,$e,Ir])});function St(t){let e=(t??"").trim().toLowerCase();return e.length===0?"unknown":sn.some(r=>e.includes(r))?"known_virtual":cn.some(r=>r.test(e))?"platform":"unknown"}var sn,cn,Tt=L(()=>{"use strict";sn=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo"],cn=[/^(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]});var Et={};N(Et,{bounded:()=>q,cameraHash:()=>wt,hex16:()=>oe,noteCameraTrait:()=>dn});function q(t,e){return new Promise(r=>{let n=setTimeout(()=>r(void 0),e),i=a=>{clearTimeout(n),r(a)};try{t().then(i,()=>i(void 0))}catch{i(void 0)}})}async function oe(t){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(JSON.stringify(t)));return Array.from(new Uint8Array(e).subarray(0,8),r=>r.toString(16).padStart(2,"0")).join("")}function ln(t){try{return t.getSettings?.().facingMode==="environment"}catch{return!1}}async function wt(t){try{if(t.readyState==="ended"||ln(t))return;let e={};try{e=t.getCapabilities?.()??{}}catch{}let r=await q(()=>navigator.mediaDevices.enumerateDevices(),un);return await oe([Ie(e.width),Ie(e.height),Ie(e.frameRate),De(e.facingMode),De(e.focusMode),De(e.exposureMode),St(t.label),r?.filter(n=>n.kind==="videoinput").length??null])}catch{return}}async function dn(t,e){let r=await wt(t);r&&e.noteCamera(r)}var un,De,Ie,Oe=L(()=>{"use strict";Tt();un=1e3;De=t=>Array.isArray(t)?[...t].sort():null,Ie=t=>{let e=t;return e==null?null:[e.min??null,e.max??null]}});var _t={};N(_t,{computePrint:()=>Tn,readHints:()=>Rt});function xt(t,e){if(typeof t!="string")return;let r=t.trim();return r.length>0&&r.length<=e?r:void 0}async function Rt(){let t=navigator.userAgentData;if(typeof t?.getHighEntropyValues!="function")return;let e=await q(()=>t.getHighEntropyValues(["model","platformVersion"]),hn);if(e==null)return;let r=xt(e.model,bn),n=xt(e.platformVersion,yn),i={...r!==void 0?{model:r}:{},...n!==void 0?{platformVersion:n}:{}};return Object.keys(i).length>0?i:void 0}async function kn(){let[t,e]=await Promise.all([new Ct.Thumbmark({stabilize:["private","iframe"],exclude:["permissions","webrtc","speech"],logging:!1,collect_beacon:!1,timeout:fn}).get(),Rt()]),r=t?.thumbmark;if(typeof r!="string"||r.length<vn||r.length>Mn)return;let n={};for(let i of mn){let a=t.components?.[i];a==null||a.timeout==="true"||(n[i]=await oe(a))}return{hash:r,c:n,...e!==void 0?{hints:e}:{}}}function Sn(){return new Promise(t=>{typeof globalThis.requestIdleCallback=="function"?globalThis.requestIdleCallback(()=>t(),{timeout:gn}):t()})}async function Tn(t){return t()||(await Sn(),t())?"busy":q(kn,pn)}var Ct,mn,fn,pn,hn,gn,bn,yn,vn,Mn,At=L(()=>{"use strict";Ct=require("@thumbmarkjs/thumbmarkjs");Oe();mn=["canvas","webgl","audio","fonts","hardware","screen","system","locales","math","plugins"],fn=2e3,pn=4e3,hn=1e3,gn=2e3,bn=64,yn=32,vn=8,Mn=128});var ir={};N(ir,{RANK_CANDIDATES:()=>qn,RANK_TOLERANCE:()=>ue,RANK_WINDOW_MS:()=>Xn,ROLL_ZERO_DEG:()=>Zn,SHARPNESS_REPORT_MAX:()=>rr,YAW_REPORT_MAX:()=>tr,YAW_ZERO_IOD:()=>Yn,collectRankedKeyframes:()=>nr,default:()=>Qn,featuresOf:()=>Jt,frontalOf:()=>$t,rankKeyframes:()=>er});function $t(t){let e=t.eyes;if(e===void 0)return{frontal:1,yaw:null,roll:null};let r=e.right.x-e.left.x,n=e.right.y-e.left.y,i=r*r+n*n;if(i===0)return{frontal:1,yaw:null,roll:null};let a=Math.abs(Math.atan2(n,Math.abs(r))*180/Math.PI),o=Qt(1-a/30),s=null,c=t.nose;if(c!==void 0){let u=(e.left.x+e.right.x)/2,l=(e.left.y+e.right.y)/2;s=Math.abs(((c.x-u)*r+(c.y-l)*n)/i),o*=Qt(1-s/.5)}return{frontal:o,yaw:s,roll:a}}function Jt(t,e){return t===null?{face:!1,frontal:0,yaw:null,roll:null,eyes:null,score:0,sharpness:e}:{face:!0,...$t(t),eyes:null,score:t.score,sharpness:e}}function er(t){let e=t.map((i,a)=>a),r=(i,a)=>{let o=Number.NEGATIVE_INFINITY;for(let s of e)o=Math.max(o,i(t[s]));e=e.filter(s=>i(t[s])>=o-a)};r(i=>i.frontal,ue.frontal),r(i=>i.eyes??1,ue.eyes),r(i=>i.score,ue.score);let n=-1;for(let i of e)(n===-1||t[i].sharpness>t[n].sharpness)&&(n=i);return n}function jn(t){return{face:t.face,frontal:F(t.frontal),...t.yaw!==null?{yaw:Math.min(F(t.yaw),tr)}:{},...t.roll!==null?{roll:F(t.roll)}:{},...t.eyes!==null?{eyes:F(t.eyes)}:{},score:F(t.score),sharpness:Math.min(F(t.sharpness),rr)}}async function nr(t,e){let{options:r}=t,n=r.video,i=r.now??(()=>performance.now()),a=r.captureKeyframe??(f=>t.defaultKeyframe(f)),o=600/3,s=[],c=[],u=0;for(let f=0;f<4;f+=1){if(e!==t.attempt)return null;let h=t.detector,p=Promise.resolve(null),m,b=0;try{if(h!==null){let M=t.profiler?.profile.inputWidth??160,k=r.makeSnapshot?.(n,M)??t.defaultSnapshot(n,M);m=a(n).then(E=>(b=i(),E));let v=i();p=h.detect(k,n.videoWidth,n.videoHeight).then(E=>(u+=i()-v,E),()=>null)}else m=a(n).then(M=>(b=i(),M));let[y,S]=await Promise.all([m,p]);s.push(y),c.push(Jt(S,y.sharpness))}catch{m?.catch(()=>{})}let g=b>0?Math.max(0,i()-b):0;f<3&&await new Promise(y=>setTimeout(y,Math.max(0,o-g)))}if(e!==t.attempt)return null;let l=er(c);if(l===-1)return null;let d=0;c.forEach((f,h)=>{f.sharpness>c[d].sharpness&&(d=h)});try{r.telemetry?.({type:"keyframe",tier:t.detector?.tier??null,chosen:l,sharpest:d,detectMs:Math.round(u),candidates:c.map(jn)})}catch{}return s[l]??null}var qn,Xn,Yn,Zn,ue,Qt,F,tr,rr,Qn,ar=L(()=>{"use strict";qn=4,Xn=600,Yn=.5,Zn=30,ue={frontal:.1,eyes:.1,score:.05},Qt=t=>t<0?0:t>1?1:t;F=t=>Number.isFinite(t)?Math.round(t*1e3)/1e3:0,tr=99,rr=999999;Qn=nr});var ni={};N(ni,{CENTERED_FACTOR:()=>Zr,CIRCLE_RADIUS_FACTOR:()=>Xr,CLIP_MS:()=>$,CaptureSessionV3:()=>He,ClipError:()=>T,ClipRecorder:()=>U,DEFAULT_CLIP_MIME:()=>j,DEFAULT_TIER_ORDER:()=>gt,DEFAULT_V3_ASSET_BASE_URL:()=>ht,DEVICE_PROFILES:()=>vt,DetectScheduler:()=>z,DetectorLadderError:()=>_,DeviceProfiler:()=>W,ENCODER_TAIL_MS:()=>ot,EXPOSURE_BAND:()=>K,FRAME_POLL_MS:()=>ct,FaceGateV3:()=>I,GATE_SNAPSHOT_MS:()=>cr,GateBlockStats:()=>P,HOLD_UPRIGHT_KEY:()=>le,INSPECT_WAIT_MS:()=>ut,IN_CIRCLE_FACTOR:()=>Yr,KEYFRAME_CANDIDATES:()=>de,KEYFRAME_WINDOW_MS:()=>lr,MAX_CLIP_BYTES:()=>Q,MAX_OVERRUN_MS:()=>st,MIME_CANDIDATES:()=>Z,PHONE_MAX_SHORT_SIDE:()=>dt,PROVENANCE_WAIT_MS:()=>dr,SECOND_FACE_AREA_RATIO:()=>pt,SHARP_REF:()=>ki,SHORT_CLIP_TOLERANCE_MS:()=>lt,STOP_GRACE_MS:()=>at,TIMESLICE_MS:()=>it,UPRIGHT_WATCH_MS:()=>ur,V3_GATE_DEFAULTS:()=>yt,VIDEO_BPS:()=>Se,betterTake:()=>Te,blockReasonOf:()=>jt,buildCaptureConstraints:()=>we,buildLivenessV2FormData:()=>Sr,cameraPreflight:()=>pe,captureMirroredKeyframe:()=>he,classifyDevice:()=>Ae,countExtraFaces:()=>B,createDetector:()=>A,detectFormFactor:()=>ee,detectIsMobile:()=>Ee,errorCopy:()=>Tr,exposure:()=>Ce,extForMime:()=>me,intrinsicSize:()=>R,isClipTooLarge:()=>V,isMediaRecorderSupported:()=>kr,mapGetUserMediaError:()=>fe,meanLuma:()=>ie,needsRetake:()=>J,pickMimeType:()=>Mr,probeDevice:()=>_e,sharpness:()=>ae,toStreamPixels:()=>H,trackFacingMode:()=>G,uiCopy:()=>wr});module.exports=vr(ni);var Z=["video/mp4;codecs=avc1.42E01E,mp4a.40.2","video/mp4;codecs=avc1.42E01E","video/mp4","video/webm;codecs=vp9,opus","video/webm;codecs=vp9","video/webm;codecs=vp8,opus","video/webm;codecs=vp8","video/webm"];function Mr(){let t=globalThis.MediaRecorder;return!t||typeof t.isTypeSupported!="function"?"":Z.find(e=>t.isTypeSupported(e))??""}var j="video/webm";function fe(t){if(t instanceof TypeError)return"insecure";switch(t?.name??""){case"NotAllowedError":case"PermissionDeniedError":return"permission";case"NotFoundError":case"DevicesNotFoundError":return"notfound";case"NotReadableError":case"TrackStartError":return"inuse";case"OverconstrainedError":case"ConstraintNotSatisfiedError":return"overconstrained";default:return"generic"}}function pe(){let t=globalThis;if(typeof t.window<"u"&&t.window.isSecureContext===!1)return"INSECURE_CONTEXT";let e=t.navigator?.mediaDevices;return!e||typeof e.getUserMedia!="function"?"UNSUPPORTED":"OK"}function kr(){let t=globalThis.MediaRecorder;return typeof t<"u"&&typeof t.isTypeSupported=="function"}var Q=8*1024*1024;function V(t){return t.size>Q}function me(t){let e=(t||"").toLowerCase();return e.startsWith("image/jpeg")?"jpg":e.startsWith("video/mp4")?"mp4":(e.startsWith("video/webm"),"webm")}function Sr(t){let{token:e,clip:r,keyframe:n}=t,i=t.ts??Date.now(),a=r.type||j,o=n.type||"image/jpeg",s=new FormData;return s.append("token",e),s.append("clip",new File([r],`liveness-${i}.${me(a)}`,{type:a})),s.append("keyframe",new File([n],`keyframe-${i}.${me(o)}`,{type:o})),s}function he(t,e,r=.92){return new Promise((n,i)=>{let a=t.videoWidth,o=t.videoHeight;if(!a||!o){i(new Error("video-not-ready"));return}let s=e.getContext("2d");if(!s){i(new Error("no-2d-context"));return}e.width=a,e.height=o,s.scale(-1,1),s.drawImage(t,-a,0),e.toBlob(c=>c?n(c):i(new Error("empty-keyframe")),"image/jpeg",r)})}var Tr={permission:{key:"fcv2.err.permission",fr:"Autorisez la cam\xE9ra dans les r\xE9glages du navigateur (ic\xF4ne cam\xE9ra dans la barre d\u2019adresse), puis r\xE9essayez."},notfound:{key:"fcv2.err.notfound",fr:"Aucune cam\xE9ra d\xE9tect\xE9e. Branchez ou activez une cam\xE9ra, puis r\xE9essayez."},inuse:{key:"fcv2.err.inuse",fr:"La cam\xE9ra est utilis\xE9e par une autre application. Fermez-la puis r\xE9essayez."},overconstrained:{key:"fcv2.err.overconstrained",fr:"La cam\xE9ra ne prend pas en charge les r\xE9glages demand\xE9s. Nouvel essai en cours\u2026"},insecure:{key:"fcv2.err.insecure",fr:"La cam\xE9ra n\xE9cessite une connexion s\xE9curis\xE9e (HTTPS). Ouvrez la page en HTTPS."},unsupported:{key:"fcv2.err.unsupported",fr:"Votre navigateur ne prend pas en charge l\u2019enregistrement vid\xE9o. Utilisez un navigateur r\xE9cent."},generic:{key:"fcv2.err.generic",fr:"Cam\xE9ra indisponible. R\xE9essayez ou contactez le support."}},wr={recording:{key:"fcv2.recording",fr:"Enregistrement en cours\u2026"},uploading:{key:"fcv2.uploading",fr:"Envoi en cours\u2026"},clipTooLarge:{key:"fcv2.err.cliptoolarge",fr:"La vid\xE9o est trop volumineuse. R\xE9essayez dans un endroit mieux \xE9clair\xE9."},retry:{key:"fcv2.retry",fr:"R\xE9essayer"},listen:{key:"fcv2.listen",fr:"\xC9couter"}};var Er=[...Z.filter(t=>t.startsWith("video/mp4")),"video/webm;codecs=h264","video/webm;codecs=avc1","video/webm;codecs=vp8","video/webm;codecs=vp9","video/webm"],We=new Set;function xr(t){let e=/(?:Chrome|Chromium)\/(\d+)\./.exec(t??"");return e?Number(e[1]):null}function ze(t=Cr(),e=globalThis.navigator?.userAgent){if(t===void 0)return"";let r=xr(e)===126;for(let n of Er)if(!(We.has(n)||r&&n.startsWith("video/mp4")))try{if(t(n))return n}catch{}return""}function ge(t){t!==""&&We.add(t)}function qe(t){return t.replace(/^video\/x-matroska/i,"video/webm")}function Cr(){let t=globalThis.MediaRecorder;return t&&typeof t.isTypeSupported=="function"?e=>t.isTypeSupported(e):void 0}var $=2500,it=1e3,at=1500,Se=25e5,ot=100,st=700,ct=20,ut=1500,ke=null;function Kr(){return ke??(ke=Promise.resolve().then(()=>(nt(),rt)).catch(t=>{throw ke=null,t})),ke.catch(()=>null)}var T=class extends Error{constructor(e,r){super(r??e),this.kind=e}},lt=100;function J(t,e){return t.stats===void 0?!1:t.stats===null?!0:t.stats.durationMs<e-lt}function Te(t,e){return t.stats?e.stats?t.stats.durationMs>e.stats.durationMs:!0:!1}var U=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,r,n,i=$,a){let o=ze(),s=Kr();return this.recordRaw(e,r,n,i,a,o).then(c=>Wr(c,s),c=>{throw c instanceof T&&(c.requestedMimeType=o),c})}recordRaw(e,r,n,i,a,o){return this.recorder&&!this.settled?Promise.reject(new T("generic","record() called while a recording is in flight \u2014 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((s,c)=>{let u;try{u=new MediaRecorder(e,o?{mimeType:o,videoBitsPerSecond:Se}:{videoBitsPerSecond:Se})}catch{try{u=new MediaRecorder(e)}catch{c(new T("unsupported"));return}}this.recorder=u;let l=g=>{this.settled||(this.settled=!0,this.clearTimers(),g())},d=()=>l(()=>{let g=qe(u.mimeType||o||j),y=new Blob(this.chunks,{type:g});if(y.size===0){c(new T("generic","empty clip"));return}if(V(y)){c(new T("cliptoolarge"));return}s({blob:y,mimeType:g,requestedMimeType:o})});u.ondataavailable=g=>{g.data&&g.data.size&&(this.chunks.push(g.data),this.bytes+=g.data.size,this.bytes>Q&&l(()=>{try{u.state!=="inactive"&&u.stop()}catch{}c(new T("cliptoolarge"))}))},u.onstop=d,u.onerror=()=>l(()=>c(new T("generic")));let f=this.now();if(n!==void 0||a!==void 0){let g=!1;u.onstart=()=>{if(!(g||this.settled)&&(g=!0,f=this.now(),n!==void 0))try{n()}catch{}}}try{u.start(it)}catch{l(()=>c(new T("generic")));return}let h=()=>{if(this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=null,this.settled||r?.(),u.state!=="inactive"){try{u.stop()}catch{d()}this.graceTimer=setTimeout(d,at)}else d()},p=this.now();if(a===void 0){this.hardStopTimer=setTimeout(h,i);return}let m=null,b=!1;this.hardStopTimer=setTimeout(h,i+st),this.pollTimer=setInterval(()=>{if(this.settled||b)return;let g=null;try{g=a.latest()}catch{g=null}let y=g?.presentationTimeMs;y!==void 0&&Number.isFinite(y)&&y>=f&&m===null&&(m=y);let S=m!==null&&y!==void 0&&y-m>=i,M=m===null&&this.now()-p>=i;if(!(!S&&!M)){if(b=!0,this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,M){h();return}this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=setTimeout(h,ot)}},ct)}))}stop(e){this.clearTimers();let r=this.recorder;if(r&&r.state!=="inactive")try{r.stop()}catch{}this.recorder=null,(e??this.stream)?.getTracks().forEach(i=>i.stop()),this.stream=null}};async function Wr(t,e){let r,n=new Promise(u=>{r=setTimeout(()=>u(null),ut)}),i=await Promise.race([e,n]);if(clearTimeout(r),i===null)return t;let a;try{a=await i.blobBytes(t.blob)}catch{return{...t,stats:null}}let o=i.inspectClipBytes(a);if(o?.container!=="webm")return{...t,stats:o};let s=i.withWebmDuration(a,o.durationMs);if(s===null)return{...t,stats:o};let c=i.inspectClipBytes(s);return c===null||c.frames!==o.frames||c.durationMs!==o.durationMs?{...t,stats:o}:{...t,blob:new Blob([s],{type:t.blob.type}),stats:o}}function we(t,e){return{video:{width:{ideal:1280,max:1280},height:{ideal:720,max:720},facingMode:e,frameRate:{ideal:24,max:30}},audio:!1}}var dt=600;function ee(){if(typeof window>"u"||typeof navigator>"u")return"desktop";let t=navigator.userAgentData,e=t?.mobile||/Android|i(Pad)?OS/.test(String(t?.platform)),r=String(navigator.userAgent??"");if(/iPhone|iPod/i.test(r))return"phone";if(/iPad/i.test(r))return"tablet";if(/Android/i.test(r))return/Mobile/i.test(r)?"phone":"tablet";if(/BlackBerry|IEMobile|Opera Mini/i.test(r))return"phone";if(!e){if(Number(navigator.maxTouchPoints??0)<=1)return"desktop";if(/Macintosh/.test(r))return"tablet";if(/Windows NT|CrOS/.test(r)||!qr())return"desktop"}let n=zr();return n>0&&n<dt?"phone":"tablet"}function Ee(){return ee()!=="desktop"}function zr(){try{let t=window.screen,e=Number(t?.width??0),r=Number(t?.height??0);return e>0&&r>0?Math.min(e,r):0}catch{return 0}}function G(t){try{let r=t?.getVideoTracks?.()[0]?.getSettings?.().facingMode;return r==="user"||r==="environment"?r:null}catch{return null}}function qr(){try{return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}catch{return!1}}var Xr=.45,Yr=.9,Zr=.4;var mt=1e4,te=class t{constructor(e,r){this.tier="blaze";this.inner=e,r!==void 0&&(this.fallbackReason=r)}static async create(e,r){let n=await import("@mediapipe/tasks-vision"),i=await n.FilesetResolver.forVisionTasks(e),a=await n.FaceDetector.createFromOptions(i,{baseOptions:{modelAssetPath:`${e}/blaze_face_short_range.tflite`,delegate:"CPU"},runningMode:"IMAGE"});return new t(a,r)}async detect(e,r,n){let i;try{i=this.inner.detect(e).detections}catch{return null}let a=jr(i);if(a?.boundingBox===void 0)return null;let o=R(e),s=Qr(a.keypoints,o),c=a.keypoints?.[2],u={box:{x:a.boundingBox.originX,y:a.boundingBox.originY,width:a.boundingBox.width,height:a.boundingBox.height},...s!==void 0?{eyes:s}:{},...c!==void 0?{nose:{x:c.x*o.width,y:c.y*o.height}}:{},score:a.categories[0]?.score??0,extraFaces:B(i.map(l=>l.boundingBox??{width:0,height:0}),i.indexOf(a))};return H(u,e,r,n)}destroy(){try{this.inner.close()}catch{}}};function jr(t){let e,r=-1;for(let n of t){let i=n.categories[0]?.score??0;i>r&&(e=n,r=i)}return e}function Qr(t,e){let r=t?.[0],n=t?.[1];if(r===void 0||n===void 0)return;let i=s=>({x:s.x*e.width,y:s.y*e.height}),[a,o]=[i(r),i(n)];return a.x<=o.x?{left:a,right:o}:{left:o,right:a}}function $r(){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(2,2);let t=document.createElement("canvas");return t.width=2,t.height=2,t}var Jr=4;async function ft(){let t=globalThis.FaceDetector;if(typeof t!="function")return{ok:!1,reason:"unsupported"};try{let e=new t({fastMode:!0,maxDetectedFaces:Jr});return await e.detect($r()),{ok:!0,instance:e}}catch(e){return{ok:!1,reason:`smoke_failed:${e instanceof Error?e.message:String(e)}`}}}var re=class{constructor(e,r){this.tier="native";this.inner=e,r!==void 0&&(this.fallbackReason=r)}async detect(e,r,n){let i;try{i=await this.inner.detect(e)}catch{return null}let a=i.map(l=>l.boundingBox),o=-1;a.forEach((l,d)=>{let f=a[o];(f===void 0||l.width*l.height>f.width*f.height)&&(o=d)});let s=i[o];if(s===void 0)return null;let c=en(s.landmarks),u={box:{x:s.boundingBox.x,y:s.boundingBox.y,width:s.boundingBox.width,height:s.boundingBox.height},...c!==void 0?{eyes:c}:{},score:1,extraFaces:B(a,o)};return H(u,e,r,n)}destroy(){}};function en(t){if(t===void 0)return;let e=t.filter(i=>i.type==="eye").map(i=>i.locations[0]).filter(i=>i!==void 0),[r,n]=e;if(!(r===void 0||n===void 0))return r.x<=n.x?{left:r,right:n}:{left:n,right:r}}var pt=.25;function B(t,e){let r=t[e],n=r===void 0?0:r.width*r.height;if(!(n>0))return 0;let i=0;return t.forEach((a,o)=>{o!==e&&a.width*a.height>=pt*n&&(i+=1)}),i}var ht="/models-v3",gt=["native","blaze"],_=class extends Error{constructor(e){super(`no detector tier available (${e})`),this.name="DetectorLadderError",this.fallbackReason=e}};function R(t){let e=t;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 r=typeof e.width=="number"?e.width:0,n=typeof e.height=="number"?e.height:0;return{width:r,height:n}}function H(t,e,r,n){let i=R(e),a=i.width>0?r/i.width:1,o=i.height>0?n/i.height:1,s=c=>({x:c.x*a,y:c.y*o});return{box:{x:t.box.x*a,y:t.box.y*o,width:t.box.width*a,height:t.box.height*o},...t.eyes!==void 0?{eyes:{left:s(t.eyes.left),right:s(t.eyes.right)}}:{},...t.nose!==void 0?{nose:s(t.nose)}:{},score:t.score,...t.extraFaces!==void 0?{extraFaces:t.extraFaces}:{}}}function tn(t){return t instanceof Error?t.message:String(t)}async function A(t){let e=t.preferred??gt,r=[];for(let n of e){if(n==="native"){let i=await ft();if(i.ok)return new re(i.instance,xe(r));r.push(`native:${i.reason}`);continue}try{return await rn(te.create(t.v3AssetBaseUrl??ht,xe(r)),t.blazeInitTimeoutMs??mt)}catch(i){r.push(i instanceof ne?"blaze:blaze_init_timeout":`blaze:${tn(i)}`)}}throw new _(xe(r)??"no_tier_available")}function xe(t){return t.length>0?t.join("; "):void 0}var ne=class extends Error{};function rn(t,e){return new Promise((r,n)=>{let i=setTimeout(()=>{n(new ne(`init exceeded ${e}ms`)),t.then(a=>a.destroy(),()=>{})},e);t.then(a=>{clearTimeout(i),r(a)},a=>{clearTimeout(i),n(a)})})}var ki=180,K=[100,190],nn=64;function bt(t,e){return .299*(t[e]??0)+.587*(t[e+1]??0)+.114*(t[e+2]??0)}function ie(t){let{data:e,width:r,height:n}=t,i=r*n;if(i===0)return 0;let a=0;for(let o=0;o<i;o+=1)a+=bt(e,o*4);return a/i}function ae(t){let{data:e,width:r,height:n}=t;if(r<3||n<3)return 0;let i=new Float32Array(r*n);for(let l=0;l<i.length;l+=1)i[l]=bt(e,l*4);let a=0,o=0,s=0;for(let l=1;l<n-1;l+=1)for(let d=1;d<r-1;d+=1){let f=l*r+d,h=(i[f-r]??0)+(i[f-1]??0)+(i[f+1]??0)+(i[f+r]??0)-4*(i[f]??0);a+=h,o+=h*h,s+=1}if(s===0)return 0;let c=a/s,u=o/s-c*c;return Math.min(1,Math.max(0,u)/180)}function Ce(t){let e=ie(t),[r,n]=K,i=e<r?r-e:e>n?e-n:0;return Math.max(0,1-i/nn)}var yt=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}),D=t=>Math.min(1,Math.max(0,t)),I=class{constructor(e={}){this.p=0;this.lastTickAt=null;this.lastCenter=null;this.velocityEma=0;this.qWindow=[];this.lastSizeDirection="ideal";this.t={...yt,...e}}reset(){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal"}tick(e){let{observation:r,quality:n,timestampMs:i}=e,a=this.lastTickAt===null?0:Math.max(0,(i-this.lastTickAt)/1e3);this.lastTickAt=i;let o={presence:0,single:1,centering:0,size:0,pose:0,sharpness:D(n.sharpness),exposure:D(n.exposure),motion:1};if(r!==null){o.presence=1,o.single=(r.extraFaces??0)>0?0:1;let l=this.geometryOf(r,e);o.centering=l.centering,o.size=l.size,o.pose=l.pose,o.motion=this.motionOf(l.center,l.iod,i)}else this.lastCenter=null,this.velocityEma=0;let s=Math.min(o.presence,o.single,o.centering,o.size,o.pose,o.sharpness,o.exposure,o.motion);this.p=D(this.p+(s>=this.t.Q_GOOD?this.t.RISE_PER_S*s:-this.t.FALL_PER_S*(1-s))*a),this.qWindow.push({at:i,q:s}),this.qWindow=this.qWindow.filter(l=>l.at>=i-this.t.READY_WINDOW_MS);let c=this.qWindow.map(l=>l.q);if(c.length>=3){let l=Math.min(...c),d=c.indexOf(l);c=c.filter((f,h)=>h!==d)}let u=this.p>=1&&c.every(l=>l>=this.t.Q_GOOD);return{at:i,q:s,p:this.p,factors:o,guidanceKey:this.guidanceOf(o,n,s),ready:u,accepted:s>=this.t.Q_GOOD}}geometryOf(e,r){let{box:n,eyes:i}=e,a={x:r.frameWidth/2,y:r.frameHeight/2},o=Math.min(r.frameWidth,r.frameHeight),s=i!==void 0?{x:(i.left.x+i.right.x)/2,y:(i.left.y+i.right.y)/2}:{x:n.x+n.width/2,y:n.y+n.height/2-this.t.BOX_EYE_OFFSET_FACTOR*n.height},c=i!==void 0?Math.hypot(i.right.x-i.left.x,i.right.y-i.left.y):this.t.IOD_BOX_PROXY_FACTOR*n.width,u=Math.hypot(s.x-a.x,s.y-a.y),l=c<=0?0:1-D(u/(this.t.CENTER_FALLOFF_IOD_MULTIPLE*c)),d=o>0?c/o:0;this.lastSizeDirection=d<this.t.SIZE_IDEAL_MIN?"far":d>this.t.SIZE_IDEAL_MAX?"close":"ideal";let f;d<this.t.SIZE_HARD_MIN||d>this.t.SIZE_HARD_MAX?f=0:d<this.t.SIZE_IDEAL_MIN?f=(d-this.t.SIZE_HARD_MIN)/(this.t.SIZE_IDEAL_MIN-this.t.SIZE_HARD_MIN):d>this.t.SIZE_IDEAL_MAX?f=(this.t.SIZE_HARD_MAX-d)/(this.t.SIZE_HARD_MAX-this.t.SIZE_IDEAL_MAX):f=1;let h=1;if(i!==void 0){let p=Math.abs(Math.atan2(i.right.y-i.left.y,i.right.x-i.left.x))*180/Math.PI;h=1-D(p/this.t.ROLL_MAX_DEG)}return{center:s,iod:c,centering:l,size:f,pose:h}}motionOf(e,r,n){let i=this.lastCenter;if(this.lastCenter={...e,at:n},i===null||r<=0)return 1;let a=(n-i.at)/1e3;if(a<=0)return 1;let o=Math.hypot(e.x-i.x,e.y-i.y)/r/a;o<=this.t.MOTION_DEADBAND_IOD_PER_S&&(o=0);let s=1-Math.exp(-a/this.t.MOTION_TAU_S);return this.velocityEma=s*o+(1-s)*this.velocityEma,1-D(this.velocityEma/this.t.MOTION_VELOCITY_IOD_PER_S)}guidanceOf(e,r,n){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(r);if(e.sharpness<this.t.GUIDE_SHARPNESS)return"fcv3.steady_camera";if(e.motion<this.t.GUIDE_MOTION)return"fcv3.hold_still";if(n<this.t.Q_GOOD){let i=[["size",this.sizeGuidance()],["centering","fcv3.center_face"],["pose","fcv3.straighten"],["exposure",this.exposureGuidance(r)],["sharpness","fcv3.steady_camera"],["motion","fcv3.hold_still"]],a=i[0];for(let o of i)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 r=(K[0]+K[1])/2;return e.meanLuma<r?"fcv3.more_light":"fcv3.too_bright"}};var vt=Object.freeze({LOW:Object.freeze({cadenceHz:5,inputWidth:128,animations:"reduced"}),MID:Object.freeze({cadenceHz:8,inputWidth:160,animations:"full"}),HIGH:Object.freeze({cadenceHz:10,inputWidth:192,animations:"full"})}),an=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);function _e(){let t=typeof navigator>"u"?void 0:navigator,e=!1;try{e=typeof WebAssembly<"u"&&WebAssembly.validate(an)}catch{e=!1}return{cores:t?.hardwareConcurrency??2,memGB:t?.deviceMemory??null,simd:e}}function Ae(t){let e=t.memGB??4;return t.cores<4||e<3?"LOW":t.cores>=8&&e>=6?"HIGH":"MID"}var Re=["LOW","MID","HIGH"],W=class{constructor(e){this.samples=[];this.adjusted=!1;this.current=e}get deviceClass(){return this.current}get profile(){return vt[this.current]}record(e){if(this.adjusted||this.samples.length>=10)return this.current;if(this.samples.push(e),this.samples.length<10)return this.current;this.adjusted=!0;let r=this.samples.reduce((n,i)=>n+i,0)/this.samples.length;if(r>70)this.current="LOW";else if(r<25){let n=Re.indexOf(this.current);this.current=Re[Math.min(Re.length-1,n+1)]??this.current}return this.current}};var z=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 r=()=>{this.running&&(this.frameCallbackId=e.requestVideoFrameCallback?.(()=>{this.frameCallbackId=null,this.now()-this.lastRunAt>=this.periodMs&&this.tick(),r()}))};r();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((r,n)=>r+n,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()})}};var Mt="0.1.0-rc.23";var on=/FBAN|FBAV|FB_IAB|FBIOS|MessengerForiOS|Instagram|WhatsApp|musical_ly|BytedanceWebview|TikTok|Snapchat|\bLine\/|LinkedInApp|Pinterest|MicroMessenger|; wv\)/i;function kt(t){let e=t??(typeof navigator>"u"?"":String(navigator.userAgent??""));return on.test(e)}var Dt="sekyro.did",wn=1e4,Pt=()=>globalThis.process?.versions?.node,It;function Ot(){let t=globalThis.crypto;try{if(typeof t?.randomUUID=="function")return t.randomUUID()}catch{}try{if(typeof t?.getRandomValues=="function"){let e=t.getRandomValues(new Uint8Array(16));return Array.from(e,r=>r.toString(16).padStart(2,"0")).join("")}}catch{}}function En(){try{let t=localStorage.getItem(Dt);if(t)return t;let e=Ot();return e!==void 0&&localStorage.setItem(Dt,e),e}catch{return It??(It=Ot()),It}}async function xn(){let t=globalThis.crypto?.subtle;if(!t)return"";let e=navigator,r=JSON.stringify([e.userAgent,e.platform,e.hardwareConcurrency??null,e.deviceMemory??null,e.maxTouchPoints??0,screen.width,screen.height,screen.colorDepth,globalThis.devicePixelRatio??1,Intl.DateTimeFormat().resolvedOptions().timeZone,e.languages?.join(",")??e.language]),n=await t.digest("SHA-256",new TextEncoder().encode(r));return Array.from(new Uint8Array(n),i=>i.toString(16).padStart(2,"0")).join("").slice(0,32)}function Cn(){try{let t=Number(navigator.maxTouchPoints);return Number.isFinite(t)&&t>=0?{touch:Math.min(64,Math.trunc(t))}:{}}catch{return{}}}function Rn(t){let e=new TextEncoder().encode(t),r="";for(let n of e)r+=String.fromCharCode(n);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function _n(t){let e,r,n,i,a,o,s=()=>o?.readyState==="live",c=()=>{a!==void 0||!globalThis.crypto?.subtle||Pt()||s()||(a=Promise.race([Promise.resolve().then(()=>(At(),_t)),new Promise(u=>setTimeout(u,wn))]).then(u=>u?.computePrint(s)).then(u=>{u==="busy"?a=void 0:i=u}).catch(()=>{}))};return{timezone(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone?.slice(0,64)||void 0}catch{return}},noteCameraLabel(u){u&&(e=u.slice(0,128))},noteCamera(u){r=u},noteCameraTrack(u){o=u},async deviceHeader(){try{n??(n=xn().catch(()=>""));let u=[];navigator.webdriver&&u.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&u.push("headless");let l=await n,d=En(),f={v:1,platform:"web",sdk:t.sdk.slice(0,64),ids:[...d?[{kind:"web_local",value:d.slice(0,128)}]:[],...l?[{kind:"web_fp",value:l}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},...Cn(),...e?{cameraLabel:e}:{},...u.length?{signals:u}:{},...i?{print:{v:2,...i,...r?{camera:r}:{}}}:{},...kt()?{inApp:!0}:{}},h=Rn(JSON.stringify(f));return c(),h}catch{return}},printReady(){return a??Promise.resolve()}}}var Pe=Symbol.for("sekyro.web.clientContext"),Fe=globalThis,Le=Fe[Pe]??(Fe[Pe]=_n({sdk:`@sekyro/web@${Mt}`}));function Ft(t){try{let e=t.getVideoTracks?.()[0];if(e){if(Le.noteCameraLabel(e.label),Le.noteCameraTrack(e),Pt())return;Promise.resolve().then(()=>(Oe(),Et)).then(r=>r.noteCameraTrait(e,Le)).catch(()=>{})}}catch{}}var Ne=Symbol.for("sekyro.web.cameraStreams"),Ve=globalThis,An=Ve[Ne]??(Ve[Ne]=new Set);function Lt(t){try{An.add(t)}catch{}}var Dn=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo"],In=[/^(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 On(t){let e=(t??"").trim().toLowerCase();return e.length===0?"unknown":Dn.some(r=>e.includes(r))?"known_virtual":In.some(r=>r.test(e))?"platform":"unknown"}function Nt(t){if(typeof t!="function")return!1;try{return/\{\s*\[native code\]\s*\}\s*$/.test(Function.prototype.toString.call(t))}catch{return!1}}function Pn(t=globalThis){return Nt(t.navigator?.mediaDevices?.getUserMedia)&&Nt(t.MediaStreamTrack?.prototype?.getSettings)}async function Fn(t,e=globalThis){let r=e.crypto?.subtle?.digest;if(typeof r=="function")try{let n=new Uint8Array(await r.call(e.crypto?.subtle,"SHA-256",new TextEncoder().encode(t)));return Array.from(n.subarray(0,8),i=>i.toString(16).padStart(2,"0")).join("")}catch{return}}async function Vt(t,e=globalThis){let r={};try{r=typeof t.getSettings=="function"?t.getSettings()??{}:{}}catch{r={}}let n={};if((r.facingMode==="user"||r.facingMode==="environment"||r.facingMode==="left"||r.facingMode==="right")&&(n.facingMode=r.facingMode),typeof r.frameRate=="number"&&Number.isFinite(r.frameRate)&&(n.frameRate=r.frameRate),typeof r.width=="number"&&Number.isFinite(r.width)&&(n.width=r.width),typeof r.height=="number"&&Number.isFinite(r.height)&&(n.height=r.height),typeof r.deviceId=="string"&&r.deviceId.length>0){let a=await Fn(r.deviceId,e);a!==void 0&&(n.deviceIdHash=a)}let i;try{i=t.label}catch{i=void 0}return{trackSettings:n,capabilitiesPresent:typeof t.getCapabilities=="function",labelClass:On(i),prototypesIntact:Pn(e)}}var Ue=t=>Math.round(t*100)/100;function Ut(t){let e=t,r=typeof e?.requestVideoFrameCallback=="function",n=null,i=null,a=0,o=0,s=0,c=0,u=0,l=0,d=()=>{!r||e?.requestVideoFrameCallback===void 0||(n=e.requestVideoFrameCallback((f,h)=>{if(n=null,!r)return;let p=h.presentationTime;if(i!==null){let m=p-i.presentationTimeMs;o+=1;let b=m-s;s+=b/o,c+=b*(m-s)}typeof h.captureTime=="number"&&Number.isFinite(h.captureTime)&&(u+=p-h.captureTime,l+=1),a+=1,i={mediaTimeMs:h.mediaTime*1e3,presentationTimeMs:p},d()}))};return d(),{latest:()=>i,stats:()=>({n:a,meanGapMs:o===0?0:Ue(s),stdGapMs:o<2?0:Ue(Math.sqrt(c/(o-1))),captureLatencyMs:l===0?null:Ue(u/l)}),stop:()=>{r&&(r=!1,n!==null&&e?.cancelVideoFrameCallback?.(n),n=null)}}}function Gt(t,e,r){return{...t,rvfc:e,rampPainter:r}}var Ln=["magenta","yellow","green","blue"];var Nn=4,Vn=4,se=t=>typeof t=="number"&&Number.isFinite(t);function Bt(t){if(typeof t!="object"||t===null)return!1;let e=t;if(typeof e.nonce!="string"||e.nonce.length===0||!Array.isArray(e.colours)||e.colours.length<1||e.colours.length>8||!e.colours.every(n=>Ln.includes(n))||!Array.isArray(e.onsetsMs)||e.onsetsMs.length!==e.colours.length)return!1;let r=-1;for(let n of e.onsetsMs){if(!se(n)||n<0||n<=r)return!1;r=n}return!(!se(e.holdMs)||e.holdMs<=0||!se(e.endMs)||e.endMs<=r||!se(e.clipMs)||e.clipMs<e.endMs||e.clipMs>8e3)}function Ht(t,e){return Bt(t)?Math.max(e,Math.ceil(t.clipMs)):e}function Kt(t,e){let r=e.now??(()=>performance.now()),n=Bt(t)?t:void 0,i=[],a=null,o=null,s=null,c=!1,u=null,l=p=>{u=p;try{e.paint(p)}catch{}},d=p=>{let m=e.frames?.()??null;return m!==null&&s!==null?m.mediaTimeMs+(p-m.presentationTimeMs)-s:p-(o??p)},f=(p,m,b=0)=>{if(c)return;let g=Math.max(0,p-d(r()));a=setTimeout(()=>{if(a=null,!c){if(b<Nn&&d(r())<p-Vn){f(p,m,b+1);return}m()}},g)},h=p=>{if(n===void 0)return;let m=n.endMs;if(p>=n.colours.length){f(m,()=>l(null));return}let b=n.onsetsMs[p],g=p+1<n.onsetsMs.length?n.onsetsMs[p+1]:m;f(b,()=>{let y=d(r());if(y>m){u!==null&&l(null);return}let S=n.colours[p];l(S);let M=i.length===0?0:i[i.length-1].tMs;i.push({tMs:Math.max(M,Math.round(y)),colour:S});let k=b+n.holdMs;if(k<g){f(k,()=>{if(d(r())>m){u!==null&&l(null);return}l("dark"),h(p+1)});return}h(p+1)})};return{started(p){if(n===void 0||c||o!==null)return;o=p;let m=e.frames?.()??null;s=m===null?null:m.mediaTimeMs+(p-m.presentationTimeMs),h(0)},stop(){c||(c=!0,a!==null&&clearTimeout(a),a=null,u!==null&&l(null))},report(){return n===void 0?void 0:{nonce:n.nonce,rendered:[...i]}}}}var Un=40;function O(t){if(t===null||typeof t!="object"&&typeof t!="function")return;let e;try{e=t.name}catch{return}return Gn(e)}function Gn(t){if(typeof t!="string")return;let e=t.replace(/[^A-Za-z]/g,"").slice(0,Un);return e===""?void 0:e}function Wt(t){let e=fe(t);if(e!=="generic")return e;switch(O(t)){case"AbortError":return"inuse";case"SecurityError":return"permission";default:return e}}function Bn(t){let e=t.toLowerCase();return e===""?"unknown":/front|facing front|user|selfie|face ?time/.test(e)?"front":/ultra|0\.5x|wide angle/.test(e)?"ultra":/tele|zoom|periscope|[2-9]x/.test(e)?"tele":/depth|tof|infrared|\bir\b|truedepth|lidar|macro|monochrome|mono\b/.test(e)?"depth":/dual|triple/.test(e)?"virtual":/back|rear|environment|facing back|arrière|خلفية/.test(e)?"main":"unknown"}function Hn(t){let e=/camera2?\s*(\d+)/i.exec(t);return e?Number(e[1]):Number.POSITIVE_INFINITY}function zt(t){let e={main:0,virtual:1,ultra:9,tele:9,depth:9,front:9,unknown:9};return t.filter(r=>(r.kind===void 0||r.kind==="videoinput")&&r.deviceId!=="").map((r,n)=>({id:r.deviceId,kind:Bn(r.label),index:Hn(r.label),i:n})).filter(r=>e[r.kind]<9).sort((r,n)=>e[r.kind]-e[n.kind]||r.index-n.index||r.i-n.i).map(r=>r.id)}var X=class extends Error{constructor(){super("the back camera could not be opened");this.name="BackCameraUnavailableError"}},qt=new Set(["NotAllowedError","PermissionDeniedError","SecurityError"]);function Xt(t){try{return String(t?.name??"")}catch{return""}}function Ge(t){if(t!==null)for(let e of t.getTracks())e.stop()}async function Yt(t,e,r){let n=l=>({video:{...e,...l},audio:!1});if(t==="user")return r.getUserMedia(n({facingMode:"user"}));let i=l=>G(l)!=="user";try{let l=await r.getUserMedia(n({facingMode:{exact:"environment"}}));if(i(l))return l;Ge(l)}catch(l){if(qt.has(Xt(l)))throw l}let a=!1,o=async()=>{if(r.enumerateDevices===void 0||a)return null;let l;try{l=zt(await r.enumerateDevices()).slice(0,3)}catch{return null}a=l.length>0;for(let d of l){let f;try{f=await r.getUserMedia(n({deviceId:{exact:d}}))}catch(h){if(qt.has(Xt(h)))throw h;continue}if(i(f))return f;Ge(f)}return null},s=await o();if(s!==null)return s;let c=await r.getUserMedia(n({facingMode:"environment"}));if(i(c))return c;Ge(c);let u=await o();if(u!==null)return u;throw new X}var x=1;function Zt(){return typeof OffscreenCanvas=="function"&&typeof createImageBitmap=="function"&&typeof Worker=="function"}function Wn(t,e={}){let r=e.createDetector??A,n=null;t.onmessage=i=>{let a=i.data;if(a.v!==x){a.bitmap?.close?.();return}if(a.type==="init"){r(a.options).then(o=>{n=o;let s={v:x,type:"ready",tier:o.tier,...o.fallbackReason!==void 0?{fallbackReason:o.fallbackReason}:{}};t.postMessage(s)});return}if(a.type==="detect"){let o=s=>{let c={v:x,type:"result",id:a.id,observation:s};t.postMessage(c),a.bitmap.close?.()};if(n===null){o(null);return}n.detect(a.bitmap,a.streamWidth,a.streamHeight).then(o,()=>o(null))}}}typeof self<"u"&&typeof self.importScripts=="function"&&Wn(self);var ce=class t{constructor(e,r){this.pending=new Map;this.nextId=1;this.worker=e,this.tier=r.tier,r.fallbackReason!==void 0&&(this.fallbackReason=r.fallbackReason),e.addEventListener("message",n=>{let i=n.data;if(i.v!==x||i.type!=="result")return;let a=this.pending.get(i.id);this.pending.delete(i.id),a?.(i.observation)})}static create(e,r,n=1e4){return new Promise((i,a)=>{let o=setTimeout(()=>{e.removeEventListener("message",s),e.terminate(),a(new Error(`worker detector not ready within ${n}ms`))},n),s=u=>{let l=u.data;l.v!==x||l.type!=="ready"||(clearTimeout(o),e.removeEventListener("message",s),i(new t(e,l)))};e.addEventListener("message",s);let c={v:x,type:"init",options:r};e.postMessage(c)})}async detect(e,r,n){let i;try{typeof ImageBitmap<"u"&&e instanceof ImageBitmap?i=e:typeof createImageBitmap=="function"?i=await createImageBitmap(e):i=e}catch{return null}let a=this.nextId;return this.nextId+=1,new Promise(o=>{this.pending.set(a,o);let s={v:x,type:"detect",id:a,bitmap:i,streamWidth:r,streamHeight:n};this.worker.postMessage(s,[i])})}destroy(){for(let e of this.pending.values())e(null);this.pending.clear(),this.worker.terminate()}};var zn=["single","size","centering","pose","exposure","sharpness","motion"];function jt(t){if(t.accepted)return null;if(t.factors.presence<=0)return"no_face";let e="single";for(let r of zn)t.factors[r]<t.factors[e]&&(e=r);return e}var P=class{constructor(){this.blocked={};this.acceptedMs=0;this.ticks=0;this.lastAt=null}record(e){let r=this.lastAt===null?0:Math.max(0,e.at-this.lastAt);this.lastAt=e.at,this.ticks+=1;let n=jt(e);if(n===null){this.acceptedMs+=r;return}let i=this.blocked[n]??{count:0,ms:0};i.count+=1,i.ms+=r,this.blocked[n]=i}summary(){let e={};for(let[r,n]of Object.entries(this.blocked))e[r]={count:n.count,ms:Math.round(n.ms)};return{blocked:e,acceptedMs:Math.round(this.acceptedMs),ticks:this.ticks}}};var cr=1e3,le="fcv3.hold_upright",ur=200,de=4,lr=600,dr=1e3,or={sharpness:1,exposure:1,meanLuma:128};function $n(t,e){return e.width=t.videoWidth,e.height=t.videoHeight,e.getContext("2d").drawImage(t,0,0),new Promise((r,n)=>e.toBlob(i=>i?r(i):n(new Error("empty-keyframe")),"image/jpeg",.92))}function Jn(){return ee()==="phone"}var He=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,r){let n=this.handlers.get(e);return n||(n=new Set,this.handlers.set(e,n)),n.add(r),()=>n?.delete(r)}emit(e,r){for(let n of[...this.handlers.get(e)??[]])n(r)}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:r}=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=(r.isPhone??Jn)(),this.setState("preflight");let n=pe();if(n!=="OK"){this.fail(n==="INSECURE_CONTEXT"?"insecure":"unsupported",{phase:"preflight"});return}this.setState("acquiring");let i=r.getUserMedia??(u=>navigator.mediaDevices.getUserMedia(u)),a;this.cameraRequestedAt=this.now();try{let{facingMode:u,...l}=we(Ee(),this.facing).video;a=await Yt(this.facing,l,{getUserMedia:i,enumerateDevices:ri(r)})}catch(u){if(e!==this.attempt)return;if(u instanceof X){this.fail("backcamera",{phase:"acquiring",name:O(u)});return}this.fail(Wt(u),{phase:"acquiring",name:O(u)});return}if(Ft(a),Lt(a),e!==this.attempt){for(let u of a.getTracks())u.stop();return}this.stream=a;let o=a.getVideoTracks?.()[0];if(this.trackProvenance=o===void 0?null:Vt(o).catch(()=>null),this.facing=G(a)??this.facing,r.video.srcObject=a,await r.video.play().catch(()=>{}),e!==this.attempt)return;if(this.cameraReadyAt=this.now(),this.detector===null){let u={v3AssetBaseUrl:r.v3AssetBaseUrl},l=r.createDetector??(r.createWorker!==void 0&&Zt()?async()=>{try{return await ce.create(r.createWorker(),u)}catch{return A(u)}}:()=>A(u)),d;try{d=await l()}catch(f){e===this.attempt&&this.fail("models",{phase:"models",name:O(f)},f instanceof _?f.fallbackReason:ti(f));return}if(e!==this.attempt){d.destroy();return}this.detector=d,this.options.telemetry?.({type:"detector",tier:d.tier,fallbackReason:d.fallbackReason})}let s=_e(),c=r.deviceClass??Ae(s);this.profiler=new W(c),this.options.telemetry?.({type:"profile",staticClass:c,activeClass:this.profiler.deviceClass,simd:s.simd}),this.gate=new I(r.thresholds??{}),this.blockStats=new P,this.lastGateSnapshotAt=this.now(),r.rankKeyframes?.()&&Promise.resolve().then(()=>(ar(),ir)).then(u=>Be=u,()=>{}),this.setState("positioning"),this.positioningStartedAt=this.now(),this.startScheduler(e)}get animations(){return this.profiler?.profile.animations??"full"}startScheduler(e){let r=this.profiler;if(r===null)return;if(this.scheduler!==null){let i=this.scheduler.stats();this.carriedDegrade+=i.degradeCount,i.meanDetectMs>0&&this.carriedMeans.push(i.meanDetectMs),this.scheduler.stop()}let n=new z({cadenceHz:r.profile.cadenceHz,video:this.options.video,now:this.options.now,run:()=>this.detectTick(e)});this.scheduler=n,n.start()}async detectTick(e){let{detector:r,gate:n,profiler:i}=this,a=this.options.video;if(e!==this.attempt||r===null||n===null||i===null||this.fired||a.videoWidth===0)return;if(this.isLandscape()){this.holdUpright(e);return}let o=i.deviceClass,s=this.now(),c=this.options.makeSnapshot?.(a,i.profile.inputWidth)??this.defaultSnapshot(a,i.profile.inputWidth),u=null;try{u=await r.detect(c,a.videoWidth,a.videoHeight)}catch{u=null}if(e!==this.attempt||this.fired)return;i.record(this.now()-s),i.deviceClass!==o&&this.startScheduler(e);let l=u===null?or:this.options.measureQuality?.(a,u.box)??this.defaultQuality(a,u.box),d=n.tick({timestampMs:this.now(),observation:u,quality:l,frameWidth:a.videoWidth,frameHeight:a.videoHeight});d.accepted&&this.faceAcquiredAt===null&&(this.faceAcquiredAt=d.at),this.blockStats?.record(d),!d.ready&&d.at-this.lastGateSnapshotAt>=cr&&(this.lastGateSnapshotAt=d.at,this.reportGate(!1)),this.emit("checks",{engine:"v3",progress:d.p,q:d.q,factors:d.factors,attempt:e}),d.guidanceKey!==this.lastGuidanceKey&&(this.lastGuidanceKey=d.guidanceKey,this.emit("guidance",{key:d.guidanceKey})),d.ready&&this.stateValue==="positioning"&&(this.fired=!0,this.captureCompleteAt=d.at,this.fire(e))}async fire(e){let{options:r}=this,n=this.scheduler;n?.stop(),this.reportGate(!0);let i=n?.stats()??{degradeCount:0,meanDetectMs:0},a=[...this.carriedMeans,...i.meanDetectMs>0?[i.meanDetectMs]:[]];r.telemetry?.({type:"fired",timeToGateMs:this.now()-this.positioningStartedAt,degradeCount:this.carriedDegrade+i.degradeCount,meanDetectMs:a.length===0?0:a.reduce((k,v)=>k+v,0)/a.length});let o=r.mode??"clip",s=r.rankKeyframes?.()&&Be?Be.default(this,e).catch(()=>this.collectKeyframes(e)):this.collectKeyframes(e);if(o==="photo"){let k=this.watchRotation(e,null),v=await s;if(k(),e!==this.attempt)return;if(v===null){this.fail("generic",{phase:"keyframes"});return}let E=await this.provenance({n:0,meanGapMs:0,stdGapMs:0,captureLatencyMs:null},!1);if(e!==this.attempt)return;this.finishCapture({keyframe:v.blob,previewDataUrl:v.previewDataUrl,...E});return}this.setState("recording");let c=this.stream;if(c===null){this.fail("generic",{phase:"recording"});return}let u=r.screenRamp?.(),l=u!==void 0,d=null;s.then(k=>{d=k},()=>{});let f=()=>{e===this.attempt&&d!==null&&this.emit("frozen",{previewDataUrl:d.previewDataUrl})},h=Ht(u,$),p=null,m,b=0;try{let k=this.recordTake(e,c,u,h,void 0).then(w=>w,w=>({failed:w})),[v,E]=await Promise.all([k,s]);if(m=E,e!==this.attempt)return;if("failed"in v){if(v.failed.kind==="cliptoolarge")throw v.failed;ge(v.failed.requestedMimeType??"")}else p=v,J(v.clip,h)?v.clip.stats===null&&ge(v.clip.requestedMimeType??""):f();if(p===null||J(p.clip,h)){b=1,r.telemetry?.({type:"clip_retake",reason:p===null?"error":p.clip.stats===null?"unreadable":"short"});let w=null;try{w=await this.recordTake(e,c,u,h,f)}catch(mr){if(p===null)throw mr}if(e!==this.attempt)return;w!==null&&(p===null||Te(w.clip,p.clip))&&(p=w),w===null&&f()}}catch(k){if(e!==this.attempt)return;let v=k.kind;this.fail(v==="cliptoolarge"?"cliptoolarge":"recorder",{phase:"recording",name:O(k)});return}if(p===null){this.fail("recorder",{phase:"recording"});return}let{clip:g,rvfc:y,report:S}=p;if(V(g.blob)){this.fail("cliptoolarge",{phase:"recording"});return}if(m===null){this.fail("generic",{phase:"keyframes"});return}let M=await this.provenance(y,l);e===this.attempt&&this.finishCapture({clip:g.blob,clipMimeType:g.mimeType,...g.stats?{clipStats:g.stats}:{},clipRetakes:b,keyframe:m.blob,previewDataUrl:m.previewDataUrl,...S!==void 0&&S.rendered.length>0?{screenRamp:S}:{},...M})}async recordTake(e,r,n,i,a){let o=this.options.createRecorder?.()??new U({now:()=>this.now()}),s=Ut(this.options.video),c=Kt(n,{paint:d=>{(d===null||e===this.attempt)&&this.emit("ramp",{colour:d})},now:()=>this.now(),frames:s.latest});this.ramp=c;let u=()=>{s.stop(),c.stop(),this.ramp===c&&(this.ramp=null)},l=this.watchRotation(e,o);try{return{clip:await o.record(r,a,()=>c.started(this.now()),i,s),rvfc:s.stats(),report:c.report()}}finally{l(),u()}}async provenance(e,r){let n=this.trackProvenance;if(n===null)return{};let i,a=new Promise(s=>{i=setTimeout(()=>s(null),dr)}),o=await Promise.race([n,a]);return clearTimeout(i),o===null?{}:{provenance:Gt(o,e,r)}}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!==le&&(this.lastGuidanceKey=le,this.emit("guidance",{key:le}))}watchRotation(e,r){if(!this.uprightGuard)return()=>{};let n=this.options.video,i=()=>{if(e!==this.attempt||r!==null&&this.stateValue!=="recording"){s();return}n.videoWidth>0&&this.isLandscape()&&(s(),this.abortRecording(e,r))},a=setInterval(i,ur);n.addEventListener?.("resize",i);let o=!1;function s(){o||(o=!0,clearInterval(a),n.removeEventListener?.("resize",i))}return s}abortRecording(e,r){if(e!==this.attempt)return;this.attempt+=1;let n=this.attempt;try{r?.stop()}catch{}this.ramp?.stop(),this.ramp=null,this.fired=!1,this.captureCompleteAt=null,this.gate=new I(this.options.thresholds??{}),this.blockStats=new P,this.lastGateSnapshotAt=this.now(),this.lastGuidanceKey=null,this.setState("positioning"),this.positioningStartedAt=this.now(),this.holdUpright(n),this.startScheduler(n)}async collectKeyframes(e){let r=this.options.captureKeyframe??(a=>this.defaultKeyframe(a)),n=lr/(de-1),i=null;for(let a=0;a<de;a+=1){if(e!==this.attempt)return i;try{let o=await r(this.options.video);(i===null||o.sharpness>i.sharpness)&&(i=o)}catch{}a<de-1&&await ei(n)}return i}finishCapture(e){this.stopTracks(),this.setState("captured");let r=this.captureTiming();this.emit("artifacts",r===void 0?e:{...e,timing:r})}captureTiming(){let e={},r=(n,i,a)=>{i!==null&&a!==null&&(e[n]=Math.max(0,Math.round(a-i)))};return r("cameraReadyMs",this.cameraRequestedAt,this.cameraReadyAt),r("faceAcquireMs",this.cameraReadyAt,this.faceAcquiredAt),r("captureMs",this.faceAcquiredAt,this.captureCompleteAt),Object.keys(e).length>0?e:void 0}async defaultKeyframe(e){let r=document.createElement("canvas"),n=await(this.facing==="user"?he:$n)(e,r),i=r.toDataURL("image/jpeg",.92);return{blob:n,previewDataUrl:i,sharpness:this.centerSharpness(e)}}defaultSnapshot(e,r){try{let n=this.snapshotCanvas??document.createElement("canvas"),i=r/Math.max(1,e.videoWidth),a=Math.max(1,Math.round(e.videoWidth*i)),o=Math.max(1,Math.round(e.videoHeight*i)),s=n.getContext("2d");return s===null?e:(n.width!==a&&(n.width=a),n.height!==o&&(n.height=o),s.drawImage(e,0,0,a,o),this.snapshotCanvas=n,n)}catch{return e}}defaultQuality(e,r){let n=sr(e,r,96);return n===null?or:{sharpness:ae(n),exposure:Ce(n),meanLuma:ie(n)}}centerSharpness(e){let r=R(e),n=sr(e,{x:r.width*.25,y:r.height*.25,width:r.width*.5,height:r.height*.5},96);return n===null?0:ae(n)}teardownAttempt(){this.scheduler?.stop(),this.scheduler=null,this.reportGate(!0),this.gate=null,this.ramp?.stop(),this.ramp=null,this.stopTracks()}reportGate(e){let r=this.blockStats,n=this.profiler;if(r===null||n===null)return;let i=r.summary();e&&(this.blockStats=null),i.ticks!==0&&this.options.telemetry?.({type:"gate",final:e,activeClass:n.deviceClass,cadenceHz:n.profile.cadenceHz,...i})}stopTracks(){if(this.stream!==null){for(let e of this.stream.getTracks())e.stop();this.stream=null}}fail(e,r,n){this.scheduler?.stop(),this.reportGate(!0),this.stopTracks(),this.setState("error"),this.options.telemetry?.({type:"error",kind:e,fallbackReason:n});let{phase:i,name:a}=r;this.emit("error",{kind:e,retryable:e!=="insecure"&&e!=="unsupported",detail:a===void 0?{phase:i}:{phase:i,name:a}})}setState(e){this.stateValue=e,this.emit("statechange",{state:e})}now(){return this.options.now?.()??performance.now()}},Be;function ei(t){return new Promise(e=>setTimeout(e,t))}function ti(t){return t instanceof Error?t.message:String(t)}function sr(t,e,r){try{let n=document.createElement("canvas"),i=r/Math.max(1,e.width);n.width=Math.max(1,Math.round(e.width*i)),n.height=Math.max(1,Math.round(e.height*i));let a=n.getContext("2d");return a===null?null:(a.drawImage(t,e.x,e.y,e.width,e.height,0,0,n.width,n.height),a.getImageData(0,0,n.width,n.height))}catch{return null}}function ri(t){if(t.enumerateDevices!==void 0)return t.enumerateDevices;if(t.getUserMedia===void 0&&!(typeof navigator>"u"||typeof navigator.mediaDevices?.enumerateDevices!="function"))return()=>navigator.mediaDevices.enumerateDevices()}0&&(module.exports={CENTERED_FACTOR,CIRCLE_RADIUS_FACTOR,CLIP_MS,CaptureSessionV3,ClipError,ClipRecorder,DEFAULT_CLIP_MIME,DEFAULT_TIER_ORDER,DEFAULT_V3_ASSET_BASE_URL,DEVICE_PROFILES,DetectScheduler,DetectorLadderError,DeviceProfiler,ENCODER_TAIL_MS,EXPOSURE_BAND,FRAME_POLL_MS,FaceGateV3,GATE_SNAPSHOT_MS,GateBlockStats,HOLD_UPRIGHT_KEY,INSPECT_WAIT_MS,IN_CIRCLE_FACTOR,KEYFRAME_CANDIDATES,KEYFRAME_WINDOW_MS,MAX_CLIP_BYTES,MAX_OVERRUN_MS,MIME_CANDIDATES,PHONE_MAX_SHORT_SIDE,PROVENANCE_WAIT_MS,SECOND_FACE_AREA_RATIO,SHARP_REF,SHORT_CLIP_TOLERANCE_MS,STOP_GRACE_MS,TIMESLICE_MS,UPRIGHT_WATCH_MS,V3_GATE_DEFAULTS,VIDEO_BPS,betterTake,blockReasonOf,buildCaptureConstraints,buildLivenessV2FormData,cameraPreflight,captureMirroredKeyframe,classifyDevice,countExtraFaces,createDetector,detectFormFactor,detectIsMobile,errorCopy,exposure,extForMime,intrinsicSize,isClipTooLarge,isMediaRecorderSupported,mapGetUserMediaError,meanLuma,needsRetake,pickMimeType,probeDevice,sharpness,toStreamPixels,trackFacingMode,uiCopy});
1
+ "use strict";var fr=Object.create;var Y=Object.defineProperty;var pr=Object.getOwnPropertyDescriptor;var hr=Object.getOwnPropertyNames;var gr=Object.getPrototypeOf,br=Object.prototype.hasOwnProperty;var L=(t,e)=>()=>(t&&(e=t(t=0)),e);var N=(t,e)=>{for(var r in e)Y(t,r,{get:e[r],enumerable:!0})},Ke=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of hr(e))!br.call(t,i)&&i!==r&&Y(t,i,{get:()=>e[i],enumerable:!(n=pr(e,i))||n.enumerable});return t};var yr=(t,e,r)=>(r=t!=null?fr(gr(t)):{},Ke(e||!t||!t.__esModule?Y(r,"default",{value:t,enumerable:!0}):r,t)),vr=t=>Ke(Y({},"__esModule",{value:!0}),t);var rt={};N(rt,{blobBytes:()=>Xe,inspectClip:()=>Rr,inspectClipBytes:()=>Ye,webmDurationMs:()=>Hr,withWebmDuration:()=>Br});async function Rr(t){try{return Ye(await Xe(t))}catch{return null}}async function Xe(t){return typeof t.arrayBuffer=="function"?new Uint8Array(await t.arrayBuffer()):new Promise((e,r)=>{let n=new FileReader;n.onload=()=>e(new Uint8Array(n.result)),n.onerror=()=>r(n.error),n.readAsArrayBuffer(t)})}function Ye(t){if(t.length<8)return null;try{if(t[0]===26&&t[1]===69&&t[2]===223&&t[3]===163)return Gr(t);if(be(t,4,4)==="ftyp")return Ar(t)}catch{return null}return null}function Ar(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength),r=[],n=null,i=null,a=0,o=(c,u)=>{let l=c;for(;l+8<=u;){let d=e.getUint32(l),f=be(t,l+4,4),h=8;if(d===1){if(l+16>u)return;d=Number(e.getBigUint64(l+8)),h=16}else d===0&&(d=u-l);if(d<h)return;let p=Math.min(l+d,u),m=l+h;if(f==="trak"&&(n={id:0,video:!1,timescale:0,frames:0,units:0,defaultDuration:0},r.push(n)),f==="traf"&&(i=null,a=0),_r.has(f))o(m,p);else if(f==="tkhd"&&n)n.id=e.getUint32(m+(t[m]===1?20:12));else if(f==="hdlr"&&n)n.video=be(t,m+8,4)==="vide";else if(f==="mdhd"&&n)n.timescale=e.getUint32(m+(t[m]===1?20:12));else if(f==="stts"&&n){let b=e.getUint32(m+4);for(let g=0;g<b;g++){let y=e.getUint32(m+8+g*8);n.frames+=y,n.units+=y*e.getUint32(m+12+g*8)}}else if(f==="trex"){let b=r.find(g=>g.id===e.getUint32(m+4));b&&(b.defaultDuration=e.getUint32(m+12))}else if(f==="tfhd"){let b=e.getUint32(m)&16777215;i=r.find(y=>y.id===e.getUint32(m+4))??null;let g=m+8;b&1&&(g+=8),b&2&&(g+=4),a=b&8?e.getUint32(g):i?.defaultDuration??0}else if(f==="trun"&&i){let b=e.getUint32(m)&16777215,g=e.getUint32(m+4),y=m+8;b&1&&(y+=4),b&4&&(y+=4);let S=(b&256?4:0)+(b&512?4:0)+(b&1024?4:0)+(b&2048?4:0);for(let M=0;M<g;M++)i.units+=b&256?e.getUint32(y+M*S):a;i.frames+=g}l=p}};o(0,t.length);let s=r.find(c=>c.video&&c.timescale>0);return!s||s.frames===0?null:{container:"mp4",frames:s.frames,durationMs:Me(s.units*1e3/s.timescale)}}function Ur(t,e){let r=t[e];if(r===void 0||r===0)return null;let n=Math.clz32(r)-23;if(n<1||n>4||e+n>t.length)return null;let i=0;for(let a=0;a<n;a++)i=i*256+t[e+a];return[i,n]}function tt(t,e){let r=t[e];if(r===void 0||r===0)return null;let n=Math.clz32(r)-23;if(n<1||n>8||e+n>t.length)return null;let i=r&255>>n,a=i===255>>n;for(let o=1;o<n;o++){let s=t[e+o];i=i*256+s,s!==255&&(a=!1)}return[a?-1:i,n]}function C(t,e,r){let n=0;for(let i=0;i<r;i++)n=n*256+t[e+i];return n}function ve(t){let e=[],r=0;for(;r<t.length;){let n=Ur(t,r);if(!n)break;let i=tt(t,r+n[1]);if(!i)break;let a={id:n[0],start:r,sizeAt:r+n[1],data:r+n[1]+i[1],size:i[0]};if(e.push(a),et.has(a.id))r=a.data;else{if(a.size<0)break;r=a.data+a.size}}return e}function Gr(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength),r=1e6,n=[],i=0,a=[];for(let c of ve(t)){if(c.data+Math.max(0,c.size)>t.length&&!et.has(c.id))break;switch(c.id){case ye:r=C(t,c.data,c.size)||r;break;case Qe:n.push({num:0,type:0});break;case Or:n.length&&(n[n.length-1].num=C(t,c.data,c.size));break;case Pr:n.length&&(n[n.length-1].type=C(t,c.data,c.size));break;case Fr:i=C(t,c.data,c.size);break;case Lr:case Nr:{let u=tt(t,c.data);if(!u||c.data+u[1]+2>t.length)break;let l=n.filter(d=>d.type===1).map(d=>d.num);if(l.length>0&&!l.includes(u[0]))break;a.push((i+e.getInt16(c.data+u[1]))*r/1e6);break}default:break}}if(a.length===0)return null;a.sort((c,u)=>c-u);let o=a.slice(1).map((c,u)=>c-a[u]),s=o.length?o.sort((c,u)=>c-u)[Math.floor(o.length/2)]:0;return{container:"webm",frames:a.length,durationMs:Me(a[a.length-1]-a[0]+s)}}function Br(t,e){if(!(e>0))return null;let r=ve(t),n=r.find(m=>m.id===Ze);if(!n||n.size!==-1||r.some(m=>m.id===Vr))return null;let i=r.find(m=>m.id===je);if(!i||i.size<0||i.data+i.size>t.length)return null;let a=1e6,o=[];for(let m of r)m.start<i.data||m.start>=i.data+i.size||(m.id===ye&&(a=C(t,m.data,m.size)||a),m.id!==Je&&o.push(t.subarray(m.start,m.data+m.size)));let s=new Uint8Array(11);s.set([68,137,136]),new DataView(s.buffer).setFloat64(3,e*1e6/a);let c=o.reduce((m,b)=>m+b.length,0)+s.length,u=new Uint8Array(12);u.set([21,73,169,102,1]);let l=c;for(let m=11;m>=5;m--)u[m]=l&255,l=Math.floor(l/256);let d=t.subarray(i.data+i.size),f=new Uint8Array(i.start+u.length+c+d.length),h=0,p=m=>{f.set(m,h),h+=m.length};return p(t.subarray(0,i.start)),p(u),o.forEach(p),p(s),p(d),f}function Hr(t){let e=1e6,r=null,n=new DataView(t.buffer,t.byteOffset,t.byteLength);for(let i of ve(t))if(i.id===ye&&(e=C(t,i.data,i.size)||e),i.id===Je&&(r=i.size===8?n.getFloat64(i.data):i.size===4?n.getFloat32(i.data):null),i.id===$e)break;return r===null?null:Me(r*e/1e6)}function be(t,e,r){let n="";for(let i=0;i<r&&e+i<t.length;i++)n+=String.fromCharCode(t[e+i]);return n}function Me(t){return Math.round(t*10)/10}var _r,Ze,je,Dr,Qe,$e,Ir,ye,Je,Or,Pr,Fr,Lr,Nr,Vr,et,nt=L(()=>{"use strict";_r=new Set(["moov","trak","mdia","minf","stbl","mvex","moof","traf","edts"]);Ze=408125543,je=357149030,Dr=374648427,Qe=174,$e=524531317,Ir=160,ye=2807729,Je=17545,Or=215,Pr=131,Fr=231,Lr=163,Nr=161,Vr=290298740,et=new Set([Ze,je,Dr,Qe,$e,Ir])});function St(t){let e=(t??"").trim().toLowerCase();return e.length===0?"unknown":sn.some(r=>e.includes(r))?"known_virtual":cn.some(r=>r.test(e))?"platform":"unknown"}var sn,cn,Tt=L(()=>{"use strict";sn=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo"],cn=[/^(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]});var Et={};N(Et,{bounded:()=>q,cameraHash:()=>wt,hex16:()=>oe,noteCameraTrait:()=>dn});function q(t,e){return new Promise(r=>{let n=setTimeout(()=>r(void 0),e),i=a=>{clearTimeout(n),r(a)};try{t().then(i,()=>i(void 0))}catch{i(void 0)}})}async function oe(t){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(JSON.stringify(t)));return Array.from(new Uint8Array(e).subarray(0,8),r=>r.toString(16).padStart(2,"0")).join("")}function ln(t){try{return t.getSettings?.().facingMode==="environment"}catch{return!1}}async function wt(t){try{if(t.readyState==="ended"||ln(t))return;let e={};try{e=t.getCapabilities?.()??{}}catch{}let r=await q(()=>navigator.mediaDevices.enumerateDevices(),un);return await oe([Ie(e.width),Ie(e.height),Ie(e.frameRate),De(e.facingMode),De(e.focusMode),De(e.exposureMode),St(t.label),r?.filter(n=>n.kind==="videoinput").length??null])}catch{return}}async function dn(t,e){let r=await wt(t);r&&e.noteCamera(r)}var un,De,Ie,Oe=L(()=>{"use strict";Tt();un=1e3;De=t=>Array.isArray(t)?[...t].sort():null,Ie=t=>{let e=t;return e==null?null:[e.min??null,e.max??null]}});var _t={};N(_t,{computePrint:()=>Tn,readHints:()=>Rt});function xt(t,e){if(typeof t!="string")return;let r=t.trim();return r.length>0&&r.length<=e?r:void 0}async function Rt(){let t=navigator.userAgentData;if(typeof t?.getHighEntropyValues!="function")return;let e=await q(()=>t.getHighEntropyValues(["model","platformVersion"]),hn);if(e==null)return;let r=xt(e.model,bn),n=xt(e.platformVersion,yn),i={...r!==void 0?{model:r}:{},...n!==void 0?{platformVersion:n}:{}};return Object.keys(i).length>0?i:void 0}async function kn(){let[t,e]=await Promise.all([new Ct.Thumbmark({stabilize:["private","iframe"],exclude:["permissions","webrtc","speech"],logging:!1,collect_beacon:!1,timeout:fn}).get(),Rt()]),r=t?.thumbmark;if(typeof r!="string"||r.length<vn||r.length>Mn)return;let n={};for(let i of mn){let a=t.components?.[i];a==null||a.timeout==="true"||(n[i]=await oe(a))}return{hash:r,c:n,...e!==void 0?{hints:e}:{}}}function Sn(){return new Promise(t=>{typeof globalThis.requestIdleCallback=="function"?globalThis.requestIdleCallback(()=>t(),{timeout:gn}):t()})}async function Tn(t){return t()||(await Sn(),t())?"busy":q(kn,pn)}var Ct,mn,fn,pn,hn,gn,bn,yn,vn,Mn,At=L(()=>{"use strict";Ct=require("@thumbmarkjs/thumbmarkjs");Oe();mn=["canvas","webgl","audio","fonts","hardware","screen","system","locales","math","plugins"],fn=2e3,pn=4e3,hn=1e3,gn=2e3,bn=64,yn=32,vn=8,Mn=128});var ir={};N(ir,{RANK_CANDIDATES:()=>qn,RANK_TOLERANCE:()=>ue,RANK_WINDOW_MS:()=>Xn,ROLL_ZERO_DEG:()=>Zn,SHARPNESS_REPORT_MAX:()=>rr,YAW_REPORT_MAX:()=>tr,YAW_ZERO_IOD:()=>Yn,collectRankedKeyframes:()=>nr,default:()=>Qn,featuresOf:()=>Jt,frontalOf:()=>$t,rankKeyframes:()=>er});function $t(t){let e=t.eyes;if(e===void 0)return{frontal:1,yaw:null,roll:null};let r=e.right.x-e.left.x,n=e.right.y-e.left.y,i=r*r+n*n;if(i===0)return{frontal:1,yaw:null,roll:null};let a=Math.abs(Math.atan2(n,Math.abs(r))*180/Math.PI),o=Qt(1-a/30),s=null,c=t.nose;if(c!==void 0){let u=(e.left.x+e.right.x)/2,l=(e.left.y+e.right.y)/2;s=Math.abs(((c.x-u)*r+(c.y-l)*n)/i),o*=Qt(1-s/.5)}return{frontal:o,yaw:s,roll:a}}function Jt(t,e){return t===null?{face:!1,frontal:0,yaw:null,roll:null,eyes:null,score:0,sharpness:e}:{face:!0,...$t(t),eyes:null,score:t.score,sharpness:e}}function er(t){let e=t.map((i,a)=>a),r=(i,a)=>{let o=Number.NEGATIVE_INFINITY;for(let s of e)o=Math.max(o,i(t[s]));e=e.filter(s=>i(t[s])>=o-a)};r(i=>i.frontal,ue.frontal),r(i=>i.eyes??1,ue.eyes),r(i=>i.score,ue.score);let n=-1;for(let i of e)(n===-1||t[i].sharpness>t[n].sharpness)&&(n=i);return n}function jn(t){return{face:t.face,frontal:F(t.frontal),...t.yaw!==null?{yaw:Math.min(F(t.yaw),tr)}:{},...t.roll!==null?{roll:F(t.roll)}:{},...t.eyes!==null?{eyes:F(t.eyes)}:{},score:F(t.score),sharpness:Math.min(F(t.sharpness),rr)}}async function nr(t,e){let{options:r}=t,n=r.video,i=r.now??(()=>performance.now()),a=r.captureKeyframe??(f=>t.defaultKeyframe(f)),o=600/3,s=[],c=[],u=0;for(let f=0;f<4;f+=1){if(e!==t.attempt)return null;let h=t.detector,p=Promise.resolve(null),m,b=0;try{if(h!==null){let M=t.profiler?.profile.inputWidth??160,k=r.makeSnapshot?.(n,M)??t.defaultSnapshot(n,M);m=a(n).then(E=>(b=i(),E));let v=i();p=h.detect(k,n.videoWidth,n.videoHeight).then(E=>(u+=i()-v,E),()=>null)}else m=a(n).then(M=>(b=i(),M));let[y,S]=await Promise.all([m,p]);s.push(y),c.push(Jt(S,y.sharpness))}catch{m?.catch(()=>{})}let g=b>0?Math.max(0,i()-b):0;f<3&&await new Promise(y=>setTimeout(y,Math.max(0,o-g)))}if(e!==t.attempt)return null;let l=er(c);if(l===-1)return null;let d=0;c.forEach((f,h)=>{f.sharpness>c[d].sharpness&&(d=h)});try{r.telemetry?.({type:"keyframe",tier:t.detector?.tier??null,chosen:l,sharpest:d,detectMs:Math.round(u),candidates:c.map(jn)})}catch{}return s[l]??null}var qn,Xn,Yn,Zn,ue,Qt,F,tr,rr,Qn,ar=L(()=>{"use strict";qn=4,Xn=600,Yn=.5,Zn=30,ue={frontal:.1,eyes:.1,score:.05},Qt=t=>t<0?0:t>1?1:t;F=t=>Number.isFinite(t)?Math.round(t*1e3)/1e3:0,tr=99,rr=999999;Qn=nr});var ni={};N(ni,{CENTERED_FACTOR:()=>Zr,CIRCLE_RADIUS_FACTOR:()=>Xr,CLIP_MS:()=>$,CaptureSessionV3:()=>He,ClipError:()=>T,ClipRecorder:()=>U,DEFAULT_CLIP_MIME:()=>j,DEFAULT_TIER_ORDER:()=>gt,DEFAULT_V3_ASSET_BASE_URL:()=>ht,DEVICE_PROFILES:()=>vt,DetectScheduler:()=>z,DetectorLadderError:()=>_,DeviceProfiler:()=>W,ENCODER_TAIL_MS:()=>ot,EXPOSURE_BAND:()=>K,FRAME_POLL_MS:()=>ct,FaceGateV3:()=>I,GATE_SNAPSHOT_MS:()=>cr,GateBlockStats:()=>P,HOLD_UPRIGHT_KEY:()=>le,INSPECT_WAIT_MS:()=>ut,IN_CIRCLE_FACTOR:()=>Yr,KEYFRAME_CANDIDATES:()=>de,KEYFRAME_WINDOW_MS:()=>lr,MAX_CLIP_BYTES:()=>Q,MAX_OVERRUN_MS:()=>st,MIME_CANDIDATES:()=>Z,PHONE_MAX_SHORT_SIDE:()=>dt,PROVENANCE_WAIT_MS:()=>dr,SECOND_FACE_AREA_RATIO:()=>pt,SHARP_REF:()=>ki,SHORT_CLIP_TOLERANCE_MS:()=>lt,STOP_GRACE_MS:()=>at,TIMESLICE_MS:()=>it,UPRIGHT_WATCH_MS:()=>ur,V3_GATE_DEFAULTS:()=>yt,VIDEO_BPS:()=>Se,betterTake:()=>Te,blockReasonOf:()=>jt,buildCaptureConstraints:()=>we,buildLivenessV2FormData:()=>Sr,cameraPreflight:()=>pe,captureMirroredKeyframe:()=>he,classifyDevice:()=>Ae,countExtraFaces:()=>B,createDetector:()=>A,detectFormFactor:()=>ee,detectIsMobile:()=>Ee,errorCopy:()=>Tr,exposure:()=>Ce,extForMime:()=>me,intrinsicSize:()=>R,isClipTooLarge:()=>V,isMediaRecorderSupported:()=>kr,mapGetUserMediaError:()=>fe,meanLuma:()=>ie,needsRetake:()=>J,pickMimeType:()=>Mr,probeDevice:()=>_e,sharpness:()=>ae,toStreamPixels:()=>H,trackFacingMode:()=>G,uiCopy:()=>wr});module.exports=vr(ni);var Z=["video/mp4;codecs=avc1.42E01E,mp4a.40.2","video/mp4;codecs=avc1.42E01E","video/mp4","video/webm;codecs=vp9,opus","video/webm;codecs=vp9","video/webm;codecs=vp8,opus","video/webm;codecs=vp8","video/webm"];function Mr(){let t=globalThis.MediaRecorder;return!t||typeof t.isTypeSupported!="function"?"":Z.find(e=>t.isTypeSupported(e))??""}var j="video/webm";function fe(t){if(t instanceof TypeError)return"insecure";switch(t?.name??""){case"NotAllowedError":case"PermissionDeniedError":return"permission";case"NotFoundError":case"DevicesNotFoundError":return"notfound";case"NotReadableError":case"TrackStartError":return"inuse";case"OverconstrainedError":case"ConstraintNotSatisfiedError":return"overconstrained";default:return"generic"}}function pe(){let t=globalThis;if(typeof t.window<"u"&&t.window.isSecureContext===!1)return"INSECURE_CONTEXT";let e=t.navigator?.mediaDevices;return!e||typeof e.getUserMedia!="function"?"UNSUPPORTED":"OK"}function kr(){let t=globalThis.MediaRecorder;return typeof t<"u"&&typeof t.isTypeSupported=="function"}var Q=8*1024*1024;function V(t){return t.size>Q}function me(t){let e=(t||"").toLowerCase();return e.startsWith("image/jpeg")?"jpg":e.startsWith("video/mp4")?"mp4":(e.startsWith("video/webm"),"webm")}function Sr(t){let{token:e,clip:r,keyframe:n}=t,i=t.ts??Date.now(),a=r.type||j,o=n.type||"image/jpeg",s=new FormData;return s.append("token",e),s.append("clip",new File([r],`liveness-${i}.${me(a)}`,{type:a})),s.append("keyframe",new File([n],`keyframe-${i}.${me(o)}`,{type:o})),s}function he(t,e,r=.92){return new Promise((n,i)=>{let a=t.videoWidth,o=t.videoHeight;if(!a||!o){i(new Error("video-not-ready"));return}let s=e.getContext("2d");if(!s){i(new Error("no-2d-context"));return}e.width=a,e.height=o,s.scale(-1,1),s.drawImage(t,-a,0),e.toBlob(c=>c?n(c):i(new Error("empty-keyframe")),"image/jpeg",r)})}var Tr={permission:{key:"fcv2.err.permission",fr:"Autorisez la cam\xE9ra dans les r\xE9glages du navigateur (ic\xF4ne cam\xE9ra dans la barre d\u2019adresse), puis r\xE9essayez."},notfound:{key:"fcv2.err.notfound",fr:"Aucune cam\xE9ra d\xE9tect\xE9e. Branchez ou activez une cam\xE9ra, puis r\xE9essayez."},inuse:{key:"fcv2.err.inuse",fr:"La cam\xE9ra est utilis\xE9e par une autre application. Fermez-la puis r\xE9essayez."},overconstrained:{key:"fcv2.err.overconstrained",fr:"La cam\xE9ra ne prend pas en charge les r\xE9glages demand\xE9s. Nouvel essai en cours\u2026"},insecure:{key:"fcv2.err.insecure",fr:"La cam\xE9ra n\xE9cessite une connexion s\xE9curis\xE9e (HTTPS). Ouvrez la page en HTTPS."},unsupported:{key:"fcv2.err.unsupported",fr:"Votre navigateur ne prend pas en charge l\u2019enregistrement vid\xE9o. Utilisez un navigateur r\xE9cent."},generic:{key:"fcv2.err.generic",fr:"Cam\xE9ra indisponible. R\xE9essayez ou contactez le support."}},wr={recording:{key:"fcv2.recording",fr:"Enregistrement en cours\u2026"},uploading:{key:"fcv2.uploading",fr:"Envoi en cours\u2026"},clipTooLarge:{key:"fcv2.err.cliptoolarge",fr:"La vid\xE9o est trop volumineuse. R\xE9essayez dans un endroit mieux \xE9clair\xE9."},retry:{key:"fcv2.retry",fr:"R\xE9essayer"},listen:{key:"fcv2.listen",fr:"\xC9couter"}};var Er=[...Z.filter(t=>t.startsWith("video/mp4")),"video/webm;codecs=h264","video/webm;codecs=avc1","video/webm;codecs=vp8","video/webm;codecs=vp9","video/webm"],We=new Set;function xr(t){let e=/(?:Chrome|Chromium)\/(\d+)\./.exec(t??"");return e?Number(e[1]):null}function ze(t=Cr(),e=globalThis.navigator?.userAgent){if(t===void 0)return"";let r=xr(e)===126;for(let n of Er)if(!(We.has(n)||r&&n.startsWith("video/mp4")))try{if(t(n))return n}catch{}return""}function ge(t){t!==""&&We.add(t)}function qe(t){return t.replace(/^video\/x-matroska/i,"video/webm")}function Cr(){let t=globalThis.MediaRecorder;return t&&typeof t.isTypeSupported=="function"?e=>t.isTypeSupported(e):void 0}var $=2500,it=1e3,at=1500,Se=25e5,ot=100,st=700,ct=20,ut=1500,ke=null;function Kr(){return ke??(ke=Promise.resolve().then(()=>(nt(),rt)).catch(t=>{throw ke=null,t})),ke.catch(()=>null)}var T=class extends Error{constructor(e,r){super(r??e),this.kind=e}},lt=100;function J(t,e){return t.stats===void 0?!1:t.stats===null?!0:t.stats.durationMs<e-lt}function Te(t,e){return t.stats?e.stats?t.stats.durationMs>e.stats.durationMs:!0:!1}var U=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,r,n,i=$,a){let o=ze(),s=Kr();return this.recordRaw(e,r,n,i,a,o).then(c=>Wr(c,s),c=>{throw c instanceof T&&(c.requestedMimeType=o),c})}recordRaw(e,r,n,i,a,o){return this.recorder&&!this.settled?Promise.reject(new T("generic","record() called while a recording is in flight \u2014 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((s,c)=>{let u;try{u=new MediaRecorder(e,o?{mimeType:o,videoBitsPerSecond:Se}:{videoBitsPerSecond:Se})}catch{try{u=new MediaRecorder(e)}catch{c(new T("unsupported"));return}}this.recorder=u;let l=g=>{this.settled||(this.settled=!0,this.clearTimers(),g())},d=()=>l(()=>{let g=qe(u.mimeType||o||j),y=new Blob(this.chunks,{type:g});if(y.size===0){c(new T("generic","empty clip"));return}if(V(y)){c(new T("cliptoolarge"));return}s({blob:y,mimeType:g,requestedMimeType:o})});u.ondataavailable=g=>{g.data&&g.data.size&&(this.chunks.push(g.data),this.bytes+=g.data.size,this.bytes>Q&&l(()=>{try{u.state!=="inactive"&&u.stop()}catch{}c(new T("cliptoolarge"))}))},u.onstop=d,u.onerror=()=>l(()=>c(new T("generic")));let f=this.now();if(n!==void 0||a!==void 0){let g=!1;u.onstart=()=>{if(!(g||this.settled)&&(g=!0,f=this.now(),n!==void 0))try{n()}catch{}}}try{u.start(it)}catch{l(()=>c(new T("generic")));return}let h=()=>{if(this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=null,this.settled||r?.(),u.state!=="inactive"){try{u.stop()}catch{d()}this.graceTimer=setTimeout(d,at)}else d()},p=this.now();if(a===void 0){this.hardStopTimer=setTimeout(h,i);return}let m=null,b=!1;this.hardStopTimer=setTimeout(h,i+st),this.pollTimer=setInterval(()=>{if(this.settled||b)return;let g=null;try{g=a.latest()}catch{g=null}let y=g?.presentationTimeMs;y!==void 0&&Number.isFinite(y)&&y>=f&&m===null&&(m=y);let S=m!==null&&y!==void 0&&y-m>=i,M=m===null&&this.now()-p>=i;if(!(!S&&!M)){if(b=!0,this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,M){h();return}this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=setTimeout(h,ot)}},ct)}))}stop(e){this.clearTimers();let r=this.recorder;if(r&&r.state!=="inactive")try{r.stop()}catch{}this.recorder=null,(e??this.stream)?.getTracks().forEach(i=>i.stop()),this.stream=null}};async function Wr(t,e){let r,n=new Promise(u=>{r=setTimeout(()=>u(null),ut)}),i=await Promise.race([e,n]);if(clearTimeout(r),i===null)return t;let a;try{a=await i.blobBytes(t.blob)}catch{return{...t,stats:null}}let o=i.inspectClipBytes(a);if(o?.container!=="webm")return{...t,stats:o};let s=i.withWebmDuration(a,o.durationMs);if(s===null)return{...t,stats:o};let c=i.inspectClipBytes(s);return c===null||c.frames!==o.frames||c.durationMs!==o.durationMs?{...t,stats:o}:{...t,blob:new Blob([s],{type:t.blob.type}),stats:o}}function we(t,e){return{video:{width:{ideal:1280,max:1280},height:{ideal:720,max:720},facingMode:e,frameRate:{ideal:24,max:30}},audio:!1}}var dt=600;function ee(){if(typeof window>"u"||typeof navigator>"u")return"desktop";let t=navigator.userAgentData,e=t?.mobile||/Android|i(Pad)?OS/.test(String(t?.platform)),r=String(navigator.userAgent??"");if(/iPhone|iPod/i.test(r))return"phone";if(/iPad/i.test(r))return"tablet";if(/Android/i.test(r))return/Mobile/i.test(r)?"phone":"tablet";if(/BlackBerry|IEMobile|Opera Mini/i.test(r))return"phone";if(!e){if(Number(navigator.maxTouchPoints??0)<=1)return"desktop";if(/Macintosh/.test(r))return"tablet";if(/Windows NT|CrOS/.test(r)||!qr())return"desktop"}let n=zr();return n>0&&n<dt?"phone":"tablet"}function Ee(){return ee()!=="desktop"}function zr(){try{let t=window.screen,e=Number(t?.width??0),r=Number(t?.height??0);return e>0&&r>0?Math.min(e,r):0}catch{return 0}}function G(t){try{let r=t?.getVideoTracks?.()[0]?.getSettings?.().facingMode;return r==="user"||r==="environment"?r:null}catch{return null}}function qr(){try{return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}catch{return!1}}var Xr=.45,Yr=.9,Zr=.4;var mt=1e4,te=class t{constructor(e,r){this.tier="blaze";this.inner=e,r!==void 0&&(this.fallbackReason=r)}static async create(e,r){let n=await import("@mediapipe/tasks-vision"),i=await n.FilesetResolver.forVisionTasks(e),a=await n.FaceDetector.createFromOptions(i,{baseOptions:{modelAssetPath:`${e}/blaze_face_short_range.tflite`,delegate:"CPU"},runningMode:"IMAGE"});return new t(a,r)}async detect(e,r,n){let i;try{i=this.inner.detect(e).detections}catch{return null}let a=jr(i);if(a?.boundingBox===void 0)return null;let o=R(e),s=Qr(a.keypoints,o),c=a.keypoints?.[2],u={box:{x:a.boundingBox.originX,y:a.boundingBox.originY,width:a.boundingBox.width,height:a.boundingBox.height},...s!==void 0?{eyes:s}:{},...c!==void 0?{nose:{x:c.x*o.width,y:c.y*o.height}}:{},score:a.categories[0]?.score??0,extraFaces:B(i.map(l=>l.boundingBox??{width:0,height:0}),i.indexOf(a))};return H(u,e,r,n)}destroy(){try{this.inner.close()}catch{}}};function jr(t){let e,r=-1;for(let n of t){let i=n.categories[0]?.score??0;i>r&&(e=n,r=i)}return e}function Qr(t,e){let r=t?.[0],n=t?.[1];if(r===void 0||n===void 0)return;let i=s=>({x:s.x*e.width,y:s.y*e.height}),[a,o]=[i(r),i(n)];return a.x<=o.x?{left:a,right:o}:{left:o,right:a}}function $r(){if(typeof OffscreenCanvas=="function")return new OffscreenCanvas(2,2);let t=document.createElement("canvas");return t.width=2,t.height=2,t}var Jr=4;async function ft(){let t=globalThis.FaceDetector;if(typeof t!="function")return{ok:!1,reason:"unsupported"};try{let e=new t({fastMode:!0,maxDetectedFaces:Jr});return await e.detect($r()),{ok:!0,instance:e}}catch(e){return{ok:!1,reason:`smoke_failed:${e instanceof Error?e.message:String(e)}`}}}var re=class{constructor(e,r){this.tier="native";this.inner=e,r!==void 0&&(this.fallbackReason=r)}async detect(e,r,n){let i;try{i=await this.inner.detect(e)}catch{return null}let a=i.map(l=>l.boundingBox),o=-1;a.forEach((l,d)=>{let f=a[o];(f===void 0||l.width*l.height>f.width*f.height)&&(o=d)});let s=i[o];if(s===void 0)return null;let c=en(s.landmarks),u={box:{x:s.boundingBox.x,y:s.boundingBox.y,width:s.boundingBox.width,height:s.boundingBox.height},...c!==void 0?{eyes:c}:{},score:1,extraFaces:B(a,o)};return H(u,e,r,n)}destroy(){}};function en(t){if(t===void 0)return;let e=t.filter(i=>i.type==="eye").map(i=>i.locations[0]).filter(i=>i!==void 0),[r,n]=e;if(!(r===void 0||n===void 0))return r.x<=n.x?{left:r,right:n}:{left:n,right:r}}var pt=.25;function B(t,e){let r=t[e],n=r===void 0?0:r.width*r.height;if(!(n>0))return 0;let i=0;return t.forEach((a,o)=>{o!==e&&a.width*a.height>=pt*n&&(i+=1)}),i}var ht="/models-v3",gt=["native","blaze"],_=class extends Error{constructor(e){super(`no detector tier available (${e})`),this.name="DetectorLadderError",this.fallbackReason=e}};function R(t){let e=t;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 r=typeof e.width=="number"?e.width:0,n=typeof e.height=="number"?e.height:0;return{width:r,height:n}}function H(t,e,r,n){let i=R(e),a=i.width>0?r/i.width:1,o=i.height>0?n/i.height:1,s=c=>({x:c.x*a,y:c.y*o});return{box:{x:t.box.x*a,y:t.box.y*o,width:t.box.width*a,height:t.box.height*o},...t.eyes!==void 0?{eyes:{left:s(t.eyes.left),right:s(t.eyes.right)}}:{},...t.nose!==void 0?{nose:s(t.nose)}:{},score:t.score,...t.extraFaces!==void 0?{extraFaces:t.extraFaces}:{}}}function tn(t){return t instanceof Error?t.message:String(t)}async function A(t){let e=t.preferred??gt,r=[];for(let n of e){if(n==="native"){let i=await ft();if(i.ok)return new re(i.instance,xe(r));r.push(`native:${i.reason}`);continue}try{return await rn(te.create(t.v3AssetBaseUrl??ht,xe(r)),t.blazeInitTimeoutMs??mt)}catch(i){r.push(i instanceof ne?"blaze:blaze_init_timeout":`blaze:${tn(i)}`)}}throw new _(xe(r)??"no_tier_available")}function xe(t){return t.length>0?t.join("; "):void 0}var ne=class extends Error{};function rn(t,e){return new Promise((r,n)=>{let i=setTimeout(()=>{n(new ne(`init exceeded ${e}ms`)),t.then(a=>a.destroy(),()=>{})},e);t.then(a=>{clearTimeout(i),r(a)},a=>{clearTimeout(i),n(a)})})}var ki=180,K=[100,190],nn=64;function bt(t,e){return .299*(t[e]??0)+.587*(t[e+1]??0)+.114*(t[e+2]??0)}function ie(t){let{data:e,width:r,height:n}=t,i=r*n;if(i===0)return 0;let a=0;for(let o=0;o<i;o+=1)a+=bt(e,o*4);return a/i}function ae(t){let{data:e,width:r,height:n}=t;if(r<3||n<3)return 0;let i=new Float32Array(r*n);for(let l=0;l<i.length;l+=1)i[l]=bt(e,l*4);let a=0,o=0,s=0;for(let l=1;l<n-1;l+=1)for(let d=1;d<r-1;d+=1){let f=l*r+d,h=(i[f-r]??0)+(i[f-1]??0)+(i[f+1]??0)+(i[f+r]??0)-4*(i[f]??0);a+=h,o+=h*h,s+=1}if(s===0)return 0;let c=a/s,u=o/s-c*c;return Math.min(1,Math.max(0,u)/180)}function Ce(t){let e=ie(t),[r,n]=K,i=e<r?r-e:e>n?e-n:0;return Math.max(0,1-i/nn)}var yt=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}),D=t=>Math.min(1,Math.max(0,t)),I=class{constructor(e={}){this.p=0;this.lastTickAt=null;this.lastCenter=null;this.velocityEma=0;this.qWindow=[];this.lastSizeDirection="ideal";this.t={...yt,...e}}reset(){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal"}tick(e){let{observation:r,quality:n,timestampMs:i}=e,a=this.lastTickAt===null?0:Math.max(0,(i-this.lastTickAt)/1e3);this.lastTickAt=i;let o={presence:0,single:1,centering:0,size:0,pose:0,sharpness:D(n.sharpness),exposure:D(n.exposure),motion:1};if(r!==null){o.presence=1,o.single=(r.extraFaces??0)>0?0:1;let l=this.geometryOf(r,e);o.centering=l.centering,o.size=l.size,o.pose=l.pose,o.motion=this.motionOf(l.center,l.iod,i)}else this.lastCenter=null,this.velocityEma=0;let s=Math.min(o.presence,o.single,o.centering,o.size,o.pose,o.sharpness,o.exposure,o.motion);this.p=D(this.p+(s>=this.t.Q_GOOD?this.t.RISE_PER_S*s:-this.t.FALL_PER_S*(1-s))*a),this.qWindow.push({at:i,q:s}),this.qWindow=this.qWindow.filter(l=>l.at>=i-this.t.READY_WINDOW_MS);let c=this.qWindow.map(l=>l.q);if(c.length>=3){let l=Math.min(...c),d=c.indexOf(l);c=c.filter((f,h)=>h!==d)}let u=this.p>=1&&c.every(l=>l>=this.t.Q_GOOD);return{at:i,q:s,p:this.p,factors:o,guidanceKey:this.guidanceOf(o,n,s),ready:u,accepted:s>=this.t.Q_GOOD}}geometryOf(e,r){let{box:n,eyes:i}=e,a={x:r.frameWidth/2,y:r.frameHeight/2},o=Math.min(r.frameWidth,r.frameHeight),s=i!==void 0?{x:(i.left.x+i.right.x)/2,y:(i.left.y+i.right.y)/2}:{x:n.x+n.width/2,y:n.y+n.height/2-this.t.BOX_EYE_OFFSET_FACTOR*n.height},c=i!==void 0?Math.hypot(i.right.x-i.left.x,i.right.y-i.left.y):this.t.IOD_BOX_PROXY_FACTOR*n.width,u=Math.hypot(s.x-a.x,s.y-a.y),l=c<=0?0:1-D(u/(this.t.CENTER_FALLOFF_IOD_MULTIPLE*c)),d=o>0?c/o:0;this.lastSizeDirection=d<this.t.SIZE_IDEAL_MIN?"far":d>this.t.SIZE_IDEAL_MAX?"close":"ideal";let f;d<this.t.SIZE_HARD_MIN||d>this.t.SIZE_HARD_MAX?f=0:d<this.t.SIZE_IDEAL_MIN?f=(d-this.t.SIZE_HARD_MIN)/(this.t.SIZE_IDEAL_MIN-this.t.SIZE_HARD_MIN):d>this.t.SIZE_IDEAL_MAX?f=(this.t.SIZE_HARD_MAX-d)/(this.t.SIZE_HARD_MAX-this.t.SIZE_IDEAL_MAX):f=1;let h=1;if(i!==void 0){let p=Math.abs(Math.atan2(i.right.y-i.left.y,i.right.x-i.left.x))*180/Math.PI;h=1-D(p/this.t.ROLL_MAX_DEG)}return{center:s,iod:c,centering:l,size:f,pose:h}}motionOf(e,r,n){let i=this.lastCenter;if(this.lastCenter={...e,at:n},i===null||r<=0)return 1;let a=(n-i.at)/1e3;if(a<=0)return 1;let o=Math.hypot(e.x-i.x,e.y-i.y)/r/a;o<=this.t.MOTION_DEADBAND_IOD_PER_S&&(o=0);let s=1-Math.exp(-a/this.t.MOTION_TAU_S);return this.velocityEma=s*o+(1-s)*this.velocityEma,1-D(this.velocityEma/this.t.MOTION_VELOCITY_IOD_PER_S)}guidanceOf(e,r,n){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(r);if(e.sharpness<this.t.GUIDE_SHARPNESS)return"fcv3.steady_camera";if(e.motion<this.t.GUIDE_MOTION)return"fcv3.hold_still";if(n<this.t.Q_GOOD){let i=[["size",this.sizeGuidance()],["centering","fcv3.center_face"],["pose","fcv3.straighten"],["exposure",this.exposureGuidance(r)],["sharpness","fcv3.steady_camera"],["motion","fcv3.hold_still"]],a=i[0];for(let o of i)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 r=(K[0]+K[1])/2;return e.meanLuma<r?"fcv3.more_light":"fcv3.too_bright"}};var vt=Object.freeze({LOW:Object.freeze({cadenceHz:5,inputWidth:128,animations:"reduced"}),MID:Object.freeze({cadenceHz:8,inputWidth:160,animations:"full"}),HIGH:Object.freeze({cadenceHz:10,inputWidth:192,animations:"full"})}),an=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);function _e(){let t=typeof navigator>"u"?void 0:navigator,e=!1;try{e=typeof WebAssembly<"u"&&WebAssembly.validate(an)}catch{e=!1}return{cores:t?.hardwareConcurrency??2,memGB:t?.deviceMemory??null,simd:e}}function Ae(t){let e=t.memGB??4;return t.cores<4||e<3?"LOW":t.cores>=8&&e>=6?"HIGH":"MID"}var Re=["LOW","MID","HIGH"],W=class{constructor(e){this.samples=[];this.adjusted=!1;this.current=e}get deviceClass(){return this.current}get profile(){return vt[this.current]}record(e){if(this.adjusted||this.samples.length>=10)return this.current;if(this.samples.push(e),this.samples.length<10)return this.current;this.adjusted=!0;let r=this.samples.reduce((n,i)=>n+i,0)/this.samples.length;if(r>70)this.current="LOW";else if(r<25){let n=Re.indexOf(this.current);this.current=Re[Math.min(Re.length-1,n+1)]??this.current}return this.current}};var z=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 r=()=>{this.running&&(this.frameCallbackId=e.requestVideoFrameCallback?.(()=>{this.frameCallbackId=null,this.now()-this.lastRunAt>=this.periodMs&&this.tick(),r()}))};r();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((r,n)=>r+n,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()})}};var Mt="0.1.0-rc.25";var on=/FBAN|FBAV|FB_IAB|FBIOS|MessengerForiOS|Instagram|WhatsApp|musical_ly|BytedanceWebview|TikTok|Snapchat|\bLine\/|LinkedInApp|Pinterest|MicroMessenger|; wv\)/i;function kt(t){let e=t??(typeof navigator>"u"?"":String(navigator.userAgent??""));return on.test(e)}var Dt="sekyro.did",wn=1e4,Pt=()=>globalThis.process?.versions?.node,It;function Ot(){let t=globalThis.crypto;try{if(typeof t?.randomUUID=="function")return t.randomUUID()}catch{}try{if(typeof t?.getRandomValues=="function"){let e=t.getRandomValues(new Uint8Array(16));return Array.from(e,r=>r.toString(16).padStart(2,"0")).join("")}}catch{}}function En(){try{let t=localStorage.getItem(Dt);if(t)return t;let e=Ot();return e!==void 0&&localStorage.setItem(Dt,e),e}catch{return It??(It=Ot()),It}}async function xn(){let t=globalThis.crypto?.subtle;if(!t)return"";let e=navigator,r=JSON.stringify([e.userAgent,e.platform,e.hardwareConcurrency??null,e.deviceMemory??null,e.maxTouchPoints??0,screen.width,screen.height,screen.colorDepth,globalThis.devicePixelRatio??1,Intl.DateTimeFormat().resolvedOptions().timeZone,e.languages?.join(",")??e.language]),n=await t.digest("SHA-256",new TextEncoder().encode(r));return Array.from(new Uint8Array(n),i=>i.toString(16).padStart(2,"0")).join("").slice(0,32)}function Cn(){try{let t=Number(navigator.maxTouchPoints);return Number.isFinite(t)&&t>=0?{touch:Math.min(64,Math.trunc(t))}:{}}catch{return{}}}function Rn(t){let e=new TextEncoder().encode(t),r="";for(let n of e)r+=String.fromCharCode(n);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function _n(t){let e,r,n,i,a,o,s=()=>o?.readyState==="live",c=()=>{a!==void 0||!globalThis.crypto?.subtle||Pt()||s()||(a=Promise.race([Promise.resolve().then(()=>(At(),_t)),new Promise(u=>setTimeout(u,wn))]).then(u=>u?.computePrint(s)).then(u=>{u==="busy"?a=void 0:i=u}).catch(()=>{}))};return{timezone(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone?.slice(0,64)||void 0}catch{return}},noteCameraLabel(u){u&&(e=u.slice(0,128))},noteCamera(u){r=u},noteCameraTrack(u){o=u},async deviceHeader(){try{n??(n=xn().catch(()=>""));let u=[];navigator.webdriver&&u.push("webdriver"),/HeadlessChrome/.test(navigator.userAgent)&&u.push("headless");let l=await n,d=En(),f={v:1,platform:"web",sdk:t.sdk.slice(0,64),ids:[...d?[{kind:"web_local",value:d.slice(0,128)}]:[],...l?[{kind:"web_fp",value:l}]:[]],screen:{w:screen.width,h:screen.height,dpr:globalThis.devicePixelRatio??1},...Cn(),...e?{cameraLabel:e}:{},...u.length?{signals:u}:{},...i?{print:{v:2,...i,...r?{camera:r}:{}}}:{},...kt()?{inApp:!0}:{}},h=Rn(JSON.stringify(f));return c(),h}catch{return}},printReady(){return a??Promise.resolve()}}}var Pe=Symbol.for("sekyro.web.clientContext"),Fe=globalThis,Le=Fe[Pe]??(Fe[Pe]=_n({sdk:`@sekyro/web@${Mt}`}));function Ft(t){try{let e=t.getVideoTracks?.()[0];if(e){if(Le.noteCameraLabel(e.label),Le.noteCameraTrack(e),Pt())return;Promise.resolve().then(()=>(Oe(),Et)).then(r=>r.noteCameraTrait(e,Le)).catch(()=>{})}}catch{}}var Ne=Symbol.for("sekyro.web.cameraStreams"),Ve=globalThis,An=Ve[Ne]??(Ve[Ne]=new Set);function Lt(t){try{An.add(t)}catch{}}var Dn=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo"],In=[/^(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 On(t){let e=(t??"").trim().toLowerCase();return e.length===0?"unknown":Dn.some(r=>e.includes(r))?"known_virtual":In.some(r=>r.test(e))?"platform":"unknown"}function Nt(t){if(typeof t!="function")return!1;try{return/\{\s*\[native code\]\s*\}\s*$/.test(Function.prototype.toString.call(t))}catch{return!1}}function Pn(t=globalThis){return Nt(t.navigator?.mediaDevices?.getUserMedia)&&Nt(t.MediaStreamTrack?.prototype?.getSettings)}async function Fn(t,e=globalThis){let r=e.crypto?.subtle?.digest;if(typeof r=="function")try{let n=new Uint8Array(await r.call(e.crypto?.subtle,"SHA-256",new TextEncoder().encode(t)));return Array.from(n.subarray(0,8),i=>i.toString(16).padStart(2,"0")).join("")}catch{return}}async function Vt(t,e=globalThis){let r={};try{r=typeof t.getSettings=="function"?t.getSettings()??{}:{}}catch{r={}}let n={};if((r.facingMode==="user"||r.facingMode==="environment"||r.facingMode==="left"||r.facingMode==="right")&&(n.facingMode=r.facingMode),typeof r.frameRate=="number"&&Number.isFinite(r.frameRate)&&(n.frameRate=r.frameRate),typeof r.width=="number"&&Number.isFinite(r.width)&&(n.width=r.width),typeof r.height=="number"&&Number.isFinite(r.height)&&(n.height=r.height),typeof r.deviceId=="string"&&r.deviceId.length>0){let a=await Fn(r.deviceId,e);a!==void 0&&(n.deviceIdHash=a)}let i;try{i=t.label}catch{i=void 0}return{trackSettings:n,capabilitiesPresent:typeof t.getCapabilities=="function",labelClass:On(i),prototypesIntact:Pn(e)}}var Ue=t=>Math.round(t*100)/100;function Ut(t){let e=t,r=typeof e?.requestVideoFrameCallback=="function",n=null,i=null,a=0,o=0,s=0,c=0,u=0,l=0,d=()=>{!r||e?.requestVideoFrameCallback===void 0||(n=e.requestVideoFrameCallback((f,h)=>{if(n=null,!r)return;let p=h.presentationTime;if(i!==null){let m=p-i.presentationTimeMs;o+=1;let b=m-s;s+=b/o,c+=b*(m-s)}typeof h.captureTime=="number"&&Number.isFinite(h.captureTime)&&(u+=p-h.captureTime,l+=1),a+=1,i={mediaTimeMs:h.mediaTime*1e3,presentationTimeMs:p},d()}))};return d(),{latest:()=>i,stats:()=>({n:a,meanGapMs:o===0?0:Ue(s),stdGapMs:o<2?0:Ue(Math.sqrt(c/(o-1))),captureLatencyMs:l===0?null:Ue(u/l)}),stop:()=>{r&&(r=!1,n!==null&&e?.cancelVideoFrameCallback?.(n),n=null)}}}function Gt(t,e,r){return{...t,rvfc:e,rampPainter:r}}var Ln=["magenta","yellow","green","blue"];var Nn=4,Vn=4,se=t=>typeof t=="number"&&Number.isFinite(t);function Bt(t){if(typeof t!="object"||t===null)return!1;let e=t;if(typeof e.nonce!="string"||e.nonce.length===0||!Array.isArray(e.colours)||e.colours.length<1||e.colours.length>8||!e.colours.every(n=>Ln.includes(n))||!Array.isArray(e.onsetsMs)||e.onsetsMs.length!==e.colours.length)return!1;let r=-1;for(let n of e.onsetsMs){if(!se(n)||n<0||n<=r)return!1;r=n}return!(!se(e.holdMs)||e.holdMs<=0||!se(e.endMs)||e.endMs<=r||!se(e.clipMs)||e.clipMs<e.endMs||e.clipMs>8e3)}function Ht(t,e){return Bt(t)?Math.max(e,Math.ceil(t.clipMs)):e}function Kt(t,e){let r=e.now??(()=>performance.now()),n=Bt(t)?t:void 0,i=[],a=null,o=null,s=null,c=!1,u=null,l=p=>{u=p;try{e.paint(p)}catch{}},d=p=>{let m=e.frames?.()??null;return m!==null&&s!==null?m.mediaTimeMs+(p-m.presentationTimeMs)-s:p-(o??p)},f=(p,m,b=0)=>{if(c)return;let g=Math.max(0,p-d(r()));a=setTimeout(()=>{if(a=null,!c){if(b<Nn&&d(r())<p-Vn){f(p,m,b+1);return}m()}},g)},h=p=>{if(n===void 0)return;let m=n.endMs;if(p>=n.colours.length){f(m,()=>l(null));return}let b=n.onsetsMs[p],g=p+1<n.onsetsMs.length?n.onsetsMs[p+1]:m;f(b,()=>{let y=d(r());if(y>m){u!==null&&l(null);return}let S=n.colours[p];l(S);let M=i.length===0?0:i[i.length-1].tMs;i.push({tMs:Math.max(M,Math.round(y)),colour:S});let k=b+n.holdMs;if(k<g){f(k,()=>{if(d(r())>m){u!==null&&l(null);return}l("dark"),h(p+1)});return}h(p+1)})};return{started(p){if(n===void 0||c||o!==null)return;o=p;let m=e.frames?.()??null;s=m===null?null:m.mediaTimeMs+(p-m.presentationTimeMs),h(0)},stop(){c||(c=!0,a!==null&&clearTimeout(a),a=null,u!==null&&l(null))},report(){return n===void 0?void 0:{nonce:n.nonce,rendered:[...i]}}}}var Un=40;function O(t){if(t===null||typeof t!="object"&&typeof t!="function")return;let e;try{e=t.name}catch{return}return Gn(e)}function Gn(t){if(typeof t!="string")return;let e=t.replace(/[^A-Za-z]/g,"").slice(0,Un);return e===""?void 0:e}function Wt(t){let e=fe(t);if(e!=="generic")return e;switch(O(t)){case"AbortError":return"inuse";case"SecurityError":return"permission";default:return e}}function Bn(t){let e=t.toLowerCase();return e===""?"unknown":/front|facing front|user|selfie|face ?time/.test(e)?"front":/ultra|0\.5x|wide angle/.test(e)?"ultra":/tele|zoom|periscope|[2-9]x/.test(e)?"tele":/depth|tof|infrared|\bir\b|truedepth|lidar|macro|monochrome|mono\b/.test(e)?"depth":/dual|triple/.test(e)?"virtual":/back|rear|environment|facing back|arrière|خلفية/.test(e)?"main":"unknown"}function Hn(t){let e=/camera2?\s*(\d+)/i.exec(t);return e?Number(e[1]):Number.POSITIVE_INFINITY}function zt(t){let e={main:0,virtual:1,ultra:9,tele:9,depth:9,front:9,unknown:9};return t.filter(r=>(r.kind===void 0||r.kind==="videoinput")&&r.deviceId!=="").map((r,n)=>({id:r.deviceId,kind:Bn(r.label),index:Hn(r.label),i:n})).filter(r=>e[r.kind]<9).sort((r,n)=>e[r.kind]-e[n.kind]||r.index-n.index||r.i-n.i).map(r=>r.id)}var X=class extends Error{constructor(){super("the back camera could not be opened");this.name="BackCameraUnavailableError"}},qt=new Set(["NotAllowedError","PermissionDeniedError","SecurityError"]);function Xt(t){try{return String(t?.name??"")}catch{return""}}function Ge(t){if(t!==null)for(let e of t.getTracks())e.stop()}async function Yt(t,e,r){let n=l=>({video:{...e,...l},audio:!1});if(t==="user")return r.getUserMedia(n({facingMode:"user"}));let i=l=>G(l)!=="user";try{let l=await r.getUserMedia(n({facingMode:{exact:"environment"}}));if(i(l))return l;Ge(l)}catch(l){if(qt.has(Xt(l)))throw l}let a=!1,o=async()=>{if(r.enumerateDevices===void 0||a)return null;let l;try{l=zt(await r.enumerateDevices()).slice(0,3)}catch{return null}a=l.length>0;for(let d of l){let f;try{f=await r.getUserMedia(n({deviceId:{exact:d}}))}catch(h){if(qt.has(Xt(h)))throw h;continue}if(i(f))return f;Ge(f)}return null},s=await o();if(s!==null)return s;let c=await r.getUserMedia(n({facingMode:"environment"}));if(i(c))return c;Ge(c);let u=await o();if(u!==null)return u;throw new X}var x=1;function Zt(){return typeof OffscreenCanvas=="function"&&typeof createImageBitmap=="function"&&typeof Worker=="function"}function Wn(t,e={}){let r=e.createDetector??A,n=null;t.onmessage=i=>{let a=i.data;if(a.v!==x){a.bitmap?.close?.();return}if(a.type==="init"){r(a.options).then(o=>{n=o;let s={v:x,type:"ready",tier:o.tier,...o.fallbackReason!==void 0?{fallbackReason:o.fallbackReason}:{}};t.postMessage(s)});return}if(a.type==="detect"){let o=s=>{let c={v:x,type:"result",id:a.id,observation:s};t.postMessage(c),a.bitmap.close?.()};if(n===null){o(null);return}n.detect(a.bitmap,a.streamWidth,a.streamHeight).then(o,()=>o(null))}}}typeof self<"u"&&typeof self.importScripts=="function"&&Wn(self);var ce=class t{constructor(e,r){this.pending=new Map;this.nextId=1;this.worker=e,this.tier=r.tier,r.fallbackReason!==void 0&&(this.fallbackReason=r.fallbackReason),e.addEventListener("message",n=>{let i=n.data;if(i.v!==x||i.type!=="result")return;let a=this.pending.get(i.id);this.pending.delete(i.id),a?.(i.observation)})}static create(e,r,n=1e4){return new Promise((i,a)=>{let o=setTimeout(()=>{e.removeEventListener("message",s),e.terminate(),a(new Error(`worker detector not ready within ${n}ms`))},n),s=u=>{let l=u.data;l.v!==x||l.type!=="ready"||(clearTimeout(o),e.removeEventListener("message",s),i(new t(e,l)))};e.addEventListener("message",s);let c={v:x,type:"init",options:r};e.postMessage(c)})}async detect(e,r,n){let i;try{typeof ImageBitmap<"u"&&e instanceof ImageBitmap?i=e:typeof createImageBitmap=="function"?i=await createImageBitmap(e):i=e}catch{return null}let a=this.nextId;return this.nextId+=1,new Promise(o=>{this.pending.set(a,o);let s={v:x,type:"detect",id:a,bitmap:i,streamWidth:r,streamHeight:n};this.worker.postMessage(s,[i])})}destroy(){for(let e of this.pending.values())e(null);this.pending.clear(),this.worker.terminate()}};var zn=["single","size","centering","pose","exposure","sharpness","motion"];function jt(t){if(t.accepted)return null;if(t.factors.presence<=0)return"no_face";let e="single";for(let r of zn)t.factors[r]<t.factors[e]&&(e=r);return e}var P=class{constructor(){this.blocked={};this.acceptedMs=0;this.ticks=0;this.lastAt=null}record(e){let r=this.lastAt===null?0:Math.max(0,e.at-this.lastAt);this.lastAt=e.at,this.ticks+=1;let n=jt(e);if(n===null){this.acceptedMs+=r;return}let i=this.blocked[n]??{count:0,ms:0};i.count+=1,i.ms+=r,this.blocked[n]=i}summary(){let e={};for(let[r,n]of Object.entries(this.blocked))e[r]={count:n.count,ms:Math.round(n.ms)};return{blocked:e,acceptedMs:Math.round(this.acceptedMs),ticks:this.ticks}}};var cr=1e3,le="fcv3.hold_upright",ur=200,de=4,lr=600,dr=1e3,or={sharpness:1,exposure:1,meanLuma:128};function $n(t,e){return e.width=t.videoWidth,e.height=t.videoHeight,e.getContext("2d").drawImage(t,0,0),new Promise((r,n)=>e.toBlob(i=>i?r(i):n(new Error("empty-keyframe")),"image/jpeg",.92))}function Jn(){return ee()==="phone"}var He=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,r){let n=this.handlers.get(e);return n||(n=new Set,this.handlers.set(e,n)),n.add(r),()=>n?.delete(r)}emit(e,r){for(let n of[...this.handlers.get(e)??[]])n(r)}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:r}=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=(r.isPhone??Jn)(),this.setState("preflight");let n=pe();if(n!=="OK"){this.fail(n==="INSECURE_CONTEXT"?"insecure":"unsupported",{phase:"preflight"});return}this.setState("acquiring");let i=r.getUserMedia??(u=>navigator.mediaDevices.getUserMedia(u)),a;this.cameraRequestedAt=this.now();try{let{facingMode:u,...l}=we(Ee(),this.facing).video;a=await Yt(this.facing,l,{getUserMedia:i,enumerateDevices:ri(r)})}catch(u){if(e!==this.attempt)return;if(u instanceof X){this.fail("backcamera",{phase:"acquiring",name:O(u)});return}this.fail(Wt(u),{phase:"acquiring",name:O(u)});return}if(Ft(a),Lt(a),e!==this.attempt){for(let u of a.getTracks())u.stop();return}this.stream=a;let o=a.getVideoTracks?.()[0];if(this.trackProvenance=o===void 0?null:Vt(o).catch(()=>null),this.facing=G(a)??this.facing,r.video.srcObject=a,await r.video.play().catch(()=>{}),e!==this.attempt)return;if(this.cameraReadyAt=this.now(),this.detector===null){let u={v3AssetBaseUrl:r.v3AssetBaseUrl},l=r.createDetector??(r.createWorker!==void 0&&Zt()?async()=>{try{return await ce.create(r.createWorker(),u)}catch{return A(u)}}:()=>A(u)),d;try{d=await l()}catch(f){e===this.attempt&&this.fail("models",{phase:"models",name:O(f)},f instanceof _?f.fallbackReason:ti(f));return}if(e!==this.attempt){d.destroy();return}this.detector=d,this.options.telemetry?.({type:"detector",tier:d.tier,fallbackReason:d.fallbackReason})}let s=_e(),c=r.deviceClass??Ae(s);this.profiler=new W(c),this.options.telemetry?.({type:"profile",staticClass:c,activeClass:this.profiler.deviceClass,simd:s.simd}),this.gate=new I(r.thresholds??{}),this.blockStats=new P,this.lastGateSnapshotAt=this.now(),r.rankKeyframes?.()&&Promise.resolve().then(()=>(ar(),ir)).then(u=>Be=u,()=>{}),this.setState("positioning"),this.positioningStartedAt=this.now(),this.startScheduler(e)}get animations(){return this.profiler?.profile.animations??"full"}startScheduler(e){let r=this.profiler;if(r===null)return;if(this.scheduler!==null){let i=this.scheduler.stats();this.carriedDegrade+=i.degradeCount,i.meanDetectMs>0&&this.carriedMeans.push(i.meanDetectMs),this.scheduler.stop()}let n=new z({cadenceHz:r.profile.cadenceHz,video:this.options.video,now:this.options.now,run:()=>this.detectTick(e)});this.scheduler=n,n.start()}async detectTick(e){let{detector:r,gate:n,profiler:i}=this,a=this.options.video;if(e!==this.attempt||r===null||n===null||i===null||this.fired||a.videoWidth===0)return;if(this.isLandscape()){this.holdUpright(e);return}let o=i.deviceClass,s=this.now(),c=this.options.makeSnapshot?.(a,i.profile.inputWidth)??this.defaultSnapshot(a,i.profile.inputWidth),u=null;try{u=await r.detect(c,a.videoWidth,a.videoHeight)}catch{u=null}if(e!==this.attempt||this.fired)return;i.record(this.now()-s),i.deviceClass!==o&&this.startScheduler(e);let l=u===null?or:this.options.measureQuality?.(a,u.box)??this.defaultQuality(a,u.box),d=n.tick({timestampMs:this.now(),observation:u,quality:l,frameWidth:a.videoWidth,frameHeight:a.videoHeight});d.accepted&&this.faceAcquiredAt===null&&(this.faceAcquiredAt=d.at),this.blockStats?.record(d),!d.ready&&d.at-this.lastGateSnapshotAt>=cr&&(this.lastGateSnapshotAt=d.at,this.reportGate(!1)),this.emit("checks",{engine:"v3",progress:d.p,q:d.q,factors:d.factors,attempt:e}),d.guidanceKey!==this.lastGuidanceKey&&(this.lastGuidanceKey=d.guidanceKey,this.emit("guidance",{key:d.guidanceKey})),d.ready&&this.stateValue==="positioning"&&(this.fired=!0,this.captureCompleteAt=d.at,this.fire(e))}async fire(e){let{options:r}=this,n=this.scheduler;n?.stop(),this.reportGate(!0);let i=n?.stats()??{degradeCount:0,meanDetectMs:0},a=[...this.carriedMeans,...i.meanDetectMs>0?[i.meanDetectMs]:[]];r.telemetry?.({type:"fired",timeToGateMs:this.now()-this.positioningStartedAt,degradeCount:this.carriedDegrade+i.degradeCount,meanDetectMs:a.length===0?0:a.reduce((k,v)=>k+v,0)/a.length});let o=r.mode??"clip",s=r.rankKeyframes?.()&&Be?Be.default(this,e).catch(()=>this.collectKeyframes(e)):this.collectKeyframes(e);if(o==="photo"){let k=this.watchRotation(e,null),v=await s;if(k(),e!==this.attempt)return;if(v===null){this.fail("generic",{phase:"keyframes"});return}let E=await this.provenance({n:0,meanGapMs:0,stdGapMs:0,captureLatencyMs:null},!1);if(e!==this.attempt)return;this.finishCapture({keyframe:v.blob,previewDataUrl:v.previewDataUrl,...E});return}this.setState("recording");let c=this.stream;if(c===null){this.fail("generic",{phase:"recording"});return}let u=r.screenRamp?.(),l=u!==void 0,d=null;s.then(k=>{d=k},()=>{});let f=()=>{e===this.attempt&&d!==null&&this.emit("frozen",{previewDataUrl:d.previewDataUrl})},h=Ht(u,$),p=null,m,b=0;try{let k=this.recordTake(e,c,u,h,void 0).then(w=>w,w=>({failed:w})),[v,E]=await Promise.all([k,s]);if(m=E,e!==this.attempt)return;if("failed"in v){if(v.failed.kind==="cliptoolarge")throw v.failed;ge(v.failed.requestedMimeType??"")}else p=v,J(v.clip,h)?v.clip.stats===null&&ge(v.clip.requestedMimeType??""):f();if(p===null||J(p.clip,h)){b=1,r.telemetry?.({type:"clip_retake",reason:p===null?"error":p.clip.stats===null?"unreadable":"short"});let w=null;try{w=await this.recordTake(e,c,u,h,f)}catch(mr){if(p===null)throw mr}if(e!==this.attempt)return;w!==null&&(p===null||Te(w.clip,p.clip))&&(p=w),w===null&&f()}}catch(k){if(e!==this.attempt)return;let v=k.kind;this.fail(v==="cliptoolarge"?"cliptoolarge":"recorder",{phase:"recording",name:O(k)});return}if(p===null){this.fail("recorder",{phase:"recording"});return}let{clip:g,rvfc:y,report:S}=p;if(V(g.blob)){this.fail("cliptoolarge",{phase:"recording"});return}if(m===null){this.fail("generic",{phase:"keyframes"});return}let M=await this.provenance(y,l);e===this.attempt&&this.finishCapture({clip:g.blob,clipMimeType:g.mimeType,...g.stats?{clipStats:g.stats}:{},clipRetakes:b,keyframe:m.blob,previewDataUrl:m.previewDataUrl,...S!==void 0&&S.rendered.length>0?{screenRamp:S}:{},...M})}async recordTake(e,r,n,i,a){let o=this.options.createRecorder?.()??new U({now:()=>this.now()}),s=Ut(this.options.video),c=Kt(n,{paint:d=>{(d===null||e===this.attempt)&&this.emit("ramp",{colour:d})},now:()=>this.now(),frames:s.latest});this.ramp=c;let u=()=>{s.stop(),c.stop(),this.ramp===c&&(this.ramp=null)},l=this.watchRotation(e,o);try{return{clip:await o.record(r,a,()=>c.started(this.now()),i,s),rvfc:s.stats(),report:c.report()}}finally{l(),u()}}async provenance(e,r){let n=this.trackProvenance;if(n===null)return{};let i,a=new Promise(s=>{i=setTimeout(()=>s(null),dr)}),o=await Promise.race([n,a]);return clearTimeout(i),o===null?{}:{provenance:Gt(o,e,r)}}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!==le&&(this.lastGuidanceKey=le,this.emit("guidance",{key:le}))}watchRotation(e,r){if(!this.uprightGuard)return()=>{};let n=this.options.video,i=()=>{if(e!==this.attempt||r!==null&&this.stateValue!=="recording"){s();return}n.videoWidth>0&&this.isLandscape()&&(s(),this.abortRecording(e,r))},a=setInterval(i,ur);n.addEventListener?.("resize",i);let o=!1;function s(){o||(o=!0,clearInterval(a),n.removeEventListener?.("resize",i))}return s}abortRecording(e,r){if(e!==this.attempt)return;this.attempt+=1;let n=this.attempt;try{r?.stop()}catch{}this.ramp?.stop(),this.ramp=null,this.fired=!1,this.captureCompleteAt=null,this.gate=new I(this.options.thresholds??{}),this.blockStats=new P,this.lastGateSnapshotAt=this.now(),this.lastGuidanceKey=null,this.setState("positioning"),this.positioningStartedAt=this.now(),this.holdUpright(n),this.startScheduler(n)}async collectKeyframes(e){let r=this.options.captureKeyframe??(a=>this.defaultKeyframe(a)),n=lr/(de-1),i=null;for(let a=0;a<de;a+=1){if(e!==this.attempt)return i;try{let o=await r(this.options.video);(i===null||o.sharpness>i.sharpness)&&(i=o)}catch{}a<de-1&&await ei(n)}return i}finishCapture(e){this.stopTracks(),this.setState("captured");let r=this.captureTiming();this.emit("artifacts",r===void 0?e:{...e,timing:r})}captureTiming(){let e={},r=(n,i,a)=>{i!==null&&a!==null&&(e[n]=Math.max(0,Math.round(a-i)))};return r("cameraReadyMs",this.cameraRequestedAt,this.cameraReadyAt),r("faceAcquireMs",this.cameraReadyAt,this.faceAcquiredAt),r("captureMs",this.faceAcquiredAt,this.captureCompleteAt),Object.keys(e).length>0?e:void 0}async defaultKeyframe(e){let r=document.createElement("canvas"),n=await(this.facing==="user"?he:$n)(e,r),i=r.toDataURL("image/jpeg",.92);return{blob:n,previewDataUrl:i,sharpness:this.centerSharpness(e)}}defaultSnapshot(e,r){try{let n=this.snapshotCanvas??document.createElement("canvas"),i=r/Math.max(1,e.videoWidth),a=Math.max(1,Math.round(e.videoWidth*i)),o=Math.max(1,Math.round(e.videoHeight*i)),s=n.getContext("2d");return s===null?e:(n.width!==a&&(n.width=a),n.height!==o&&(n.height=o),s.drawImage(e,0,0,a,o),this.snapshotCanvas=n,n)}catch{return e}}defaultQuality(e,r){let n=sr(e,r,96);return n===null?or:{sharpness:ae(n),exposure:Ce(n),meanLuma:ie(n)}}centerSharpness(e){let r=R(e),n=sr(e,{x:r.width*.25,y:r.height*.25,width:r.width*.5,height:r.height*.5},96);return n===null?0:ae(n)}teardownAttempt(){this.scheduler?.stop(),this.scheduler=null,this.reportGate(!0),this.gate=null,this.ramp?.stop(),this.ramp=null,this.stopTracks()}reportGate(e){let r=this.blockStats,n=this.profiler;if(r===null||n===null)return;let i=r.summary();e&&(this.blockStats=null),i.ticks!==0&&this.options.telemetry?.({type:"gate",final:e,activeClass:n.deviceClass,cadenceHz:n.profile.cadenceHz,...i})}stopTracks(){if(this.stream!==null){for(let e of this.stream.getTracks())e.stop();this.stream=null}}fail(e,r,n){this.scheduler?.stop(),this.reportGate(!0),this.stopTracks(),this.setState("error"),this.options.telemetry?.({type:"error",kind:e,fallbackReason:n});let{phase:i,name:a}=r;this.emit("error",{kind:e,retryable:e!=="insecure"&&e!=="unsupported",detail:a===void 0?{phase:i}:{phase:i,name:a}})}setState(e){this.stateValue=e,this.emit("statechange",{state:e})}now(){return this.options.now?.()??performance.now()}},Be;function ei(t){return new Promise(e=>setTimeout(e,t))}function ti(t){return t instanceof Error?t.message:String(t)}function sr(t,e,r){try{let n=document.createElement("canvas"),i=r/Math.max(1,e.width);n.width=Math.max(1,Math.round(e.width*i)),n.height=Math.max(1,Math.round(e.height*i));let a=n.getContext("2d");return a===null?null:(a.drawImage(t,e.x,e.y,e.width,e.height,0,0,n.width,n.height),a.getImageData(0,0,n.width,n.height))}catch{return null}}function ri(t){if(t.enumerateDevices!==void 0)return t.enumerateDevices;if(t.getUserMedia===void 0&&!(typeof navigator>"u"||typeof navigator.mediaDevices?.enumerateDevices!="function"))return()=>navigator.mediaDevices.enumerateDevices()}0&&(module.exports={CENTERED_FACTOR,CIRCLE_RADIUS_FACTOR,CLIP_MS,CaptureSessionV3,ClipError,ClipRecorder,DEFAULT_CLIP_MIME,DEFAULT_TIER_ORDER,DEFAULT_V3_ASSET_BASE_URL,DEVICE_PROFILES,DetectScheduler,DetectorLadderError,DeviceProfiler,ENCODER_TAIL_MS,EXPOSURE_BAND,FRAME_POLL_MS,FaceGateV3,GATE_SNAPSHOT_MS,GateBlockStats,HOLD_UPRIGHT_KEY,INSPECT_WAIT_MS,IN_CIRCLE_FACTOR,KEYFRAME_CANDIDATES,KEYFRAME_WINDOW_MS,MAX_CLIP_BYTES,MAX_OVERRUN_MS,MIME_CANDIDATES,PHONE_MAX_SHORT_SIDE,PROVENANCE_WAIT_MS,SECOND_FACE_AREA_RATIO,SHARP_REF,SHORT_CLIP_TOLERANCE_MS,STOP_GRACE_MS,TIMESLICE_MS,UPRIGHT_WATCH_MS,V3_GATE_DEFAULTS,VIDEO_BPS,betterTake,blockReasonOf,buildCaptureConstraints,buildLivenessV2FormData,cameraPreflight,captureMirroredKeyframe,classifyDevice,countExtraFaces,createDetector,detectFormFactor,detectIsMobile,errorCopy,exposure,extForMime,intrinsicSize,isClipTooLarge,isMediaRecorderSupported,mapGetUserMediaError,meanLuma,needsRetake,pickMimeType,probeDevice,sharpness,toStreamPixels,trackFacingMode,uiCopy});
@@ -1,8 +1,8 @@
1
- import { C as CameraErrorKind } from '../capture-session-v3-CFXYS0Pg.cjs';
2
- export { a as CLIP_MS, b as CaptureArtifacts, c as CaptureErrorKind, d as CaptureSessionEvents, e as CaptureSessionV3, f as CaptureSessionV3Events, g as CaptureSessionV3Options, h as CaptureSessionV3StartOptions, i as CaptureState, j as CaptureTiming, k as ClipError, l as ClipErrorKind, m as ClipRecorder, n as ClipRecorderOptions, o as ClipResult, D as DEFAULT_CLIP_MIME, p as DEVICE_PROFILES, q as DeviceClass, r as DeviceProbe, s as DeviceProfile, t as DeviceProfiler, E as ENCODER_TAIL_MS, u as EscalationClipArtifact, v as EscalationHook, F as FRAME_POLL_MS, w as FaceGateV3, x as FrameClock, G as GATE_SNAPSHOT_MS, y as GateBlockEntry, z as GateBlockReason, A as GateBlockStats, B as GateBlockSummary, H as GateChecks, I as HOLD_UPRIGHT_KEY, J as INSPECT_WAIT_MS, K as KEYFRAME_CANDIDATES, L as KEYFRAME_WINDOW_MS, M as MAX_CLIP_BYTES, N as MAX_OVERRUN_MS, O as MIME_CANDIDATES, P as PROVENANCE_WAIT_MS, S as SHORT_CLIP_TOLERANCE_MS, Q as STOP_GRACE_MS, T as TIMESLICE_MS, U as UPRIGHT_WATCH_MS, V as V3ChecksPayload, R as V3GateFactor, W as V3GateQuality, X as V3GateThresholds, Y as V3GateTick, Z as V3GateTickInput, _ as V3TelemetryEvent, $ as V3_GATE_DEFAULTS, a0 as VIDEO_BPS, a1 as betterTake, a2 as blockReasonOf, a3 as buildLivenessV2FormData, a4 as cameraPreflight, a5 as classifyDevice, a6 as extForMime, a7 as isClipTooLarge, a8 as isMediaRecorderSupported, a9 as mapGetUserMediaError, aa as needsRetake, ab as pickMimeType, ac as probeDevice } from '../capture-session-v3-CFXYS0Pg.cjs';
1
+ import { C as CameraErrorKind } from '../capture-session-v3-BoGn8vLv.cjs';
2
+ export { a as CLIP_MS, b as CaptureArtifacts, c as CaptureErrorKind, d as CaptureSessionEvents, e as CaptureSessionV3, f as CaptureSessionV3Events, g as CaptureSessionV3Options, h as CaptureSessionV3StartOptions, i as CaptureState, j as CaptureTiming, k as ClipError, l as ClipErrorKind, m as ClipRecorder, n as ClipRecorderOptions, o as ClipResult, D as DEFAULT_CLIP_MIME, p as DEVICE_PROFILES, q as DeviceClass, r as DeviceProbe, s as DeviceProfile, t as DeviceProfiler, E as ENCODER_TAIL_MS, u as EscalationClipArtifact, v as EscalationHook, F as FRAME_POLL_MS, w as FaceGateV3, x as FrameClock, G as GATE_SNAPSHOT_MS, y as GateBlockEntry, z as GateBlockReason, A as GateBlockStats, B as GateBlockSummary, H as GateChecks, I as HOLD_UPRIGHT_KEY, J as INSPECT_WAIT_MS, K as KEYFRAME_CANDIDATES, L as KEYFRAME_WINDOW_MS, M as MAX_CLIP_BYTES, N as MAX_OVERRUN_MS, O as MIME_CANDIDATES, P as PROVENANCE_WAIT_MS, S as SHORT_CLIP_TOLERANCE_MS, Q as STOP_GRACE_MS, T as TIMESLICE_MS, U as UPRIGHT_WATCH_MS, V as V3ChecksPayload, R as V3GateFactor, W as V3GateQuality, X as V3GateThresholds, Y as V3GateTick, Z as V3GateTickInput, _ as V3TelemetryEvent, $ as V3_GATE_DEFAULTS, a0 as VIDEO_BPS, a1 as betterTake, a2 as blockReasonOf, a3 as buildLivenessV2FormData, a4 as cameraPreflight, a5 as classifyDevice, a6 as extForMime, a7 as isClipTooLarge, a8 as isMediaRecorderSupported, a9 as mapGetUserMediaError, aa as needsRetake, ab as pickMimeType, ac as probeDevice } from '../capture-session-v3-BoGn8vLv.cjs';
3
3
  export { C as CENTERED_FACTOR, a as CIRCLE_RADIUS_FACTOR, F as FormFactor, I as IN_CIRCLE_FACTOR, P as PHONE_MAX_SHORT_SIDE, b as buildCaptureConstraints, d as detectFormFactor, c as detectIsMobile, t as trackFacingMode } from '../capture-constraints-CVqpMNGA.cjs';
4
4
  export { C as CreateDetectorOptions, D as DEFAULT_TIER_ORDER, a as DEFAULT_V3_ASSET_BASE_URL, b as Detector, c as DetectorLadderError, F as FaceObservation, S as SECOND_FACE_AREA_RATIO, d as countExtraFaces, e as createDetector, i as intrinsicSize, t as toStreamPixels } from '../detect-worker-CHqsPJoM.cjs';
5
- import '../types-Cjnp1o8i.cjs';
5
+ import '../types-ZBcpvLdo.cjs';
6
6
 
7
7
  declare function captureMirroredKeyframe(video: HTMLVideoElement, canvas: HTMLCanvasElement, quality?: number): Promise<Blob>;
8
8
 
@@ -1,8 +1,8 @@
1
- import { C as CameraErrorKind } from '../capture-session-v3-DID39wUZ.js';
2
- export { a as CLIP_MS, b as CaptureArtifacts, c as CaptureErrorKind, d as CaptureSessionEvents, e as CaptureSessionV3, f as CaptureSessionV3Events, g as CaptureSessionV3Options, h as CaptureSessionV3StartOptions, i as CaptureState, j as CaptureTiming, k as ClipError, l as ClipErrorKind, m as ClipRecorder, n as ClipRecorderOptions, o as ClipResult, D as DEFAULT_CLIP_MIME, p as DEVICE_PROFILES, q as DeviceClass, r as DeviceProbe, s as DeviceProfile, t as DeviceProfiler, E as ENCODER_TAIL_MS, u as EscalationClipArtifact, v as EscalationHook, F as FRAME_POLL_MS, w as FaceGateV3, x as FrameClock, G as GATE_SNAPSHOT_MS, y as GateBlockEntry, z as GateBlockReason, A as GateBlockStats, B as GateBlockSummary, H as GateChecks, I as HOLD_UPRIGHT_KEY, J as INSPECT_WAIT_MS, K as KEYFRAME_CANDIDATES, L as KEYFRAME_WINDOW_MS, M as MAX_CLIP_BYTES, N as MAX_OVERRUN_MS, O as MIME_CANDIDATES, P as PROVENANCE_WAIT_MS, S as SHORT_CLIP_TOLERANCE_MS, Q as STOP_GRACE_MS, T as TIMESLICE_MS, U as UPRIGHT_WATCH_MS, V as V3ChecksPayload, R as V3GateFactor, W as V3GateQuality, X as V3GateThresholds, Y as V3GateTick, Z as V3GateTickInput, _ as V3TelemetryEvent, $ as V3_GATE_DEFAULTS, a0 as VIDEO_BPS, a1 as betterTake, a2 as blockReasonOf, a3 as buildLivenessV2FormData, a4 as cameraPreflight, a5 as classifyDevice, a6 as extForMime, a7 as isClipTooLarge, a8 as isMediaRecorderSupported, a9 as mapGetUserMediaError, aa as needsRetake, ab as pickMimeType, ac as probeDevice } from '../capture-session-v3-DID39wUZ.js';
1
+ import { C as CameraErrorKind } from '../capture-session-v3-C0bbHvDc.js';
2
+ export { a as CLIP_MS, b as CaptureArtifacts, c as CaptureErrorKind, d as CaptureSessionEvents, e as CaptureSessionV3, f as CaptureSessionV3Events, g as CaptureSessionV3Options, h as CaptureSessionV3StartOptions, i as CaptureState, j as CaptureTiming, k as ClipError, l as ClipErrorKind, m as ClipRecorder, n as ClipRecorderOptions, o as ClipResult, D as DEFAULT_CLIP_MIME, p as DEVICE_PROFILES, q as DeviceClass, r as DeviceProbe, s as DeviceProfile, t as DeviceProfiler, E as ENCODER_TAIL_MS, u as EscalationClipArtifact, v as EscalationHook, F as FRAME_POLL_MS, w as FaceGateV3, x as FrameClock, G as GATE_SNAPSHOT_MS, y as GateBlockEntry, z as GateBlockReason, A as GateBlockStats, B as GateBlockSummary, H as GateChecks, I as HOLD_UPRIGHT_KEY, J as INSPECT_WAIT_MS, K as KEYFRAME_CANDIDATES, L as KEYFRAME_WINDOW_MS, M as MAX_CLIP_BYTES, N as MAX_OVERRUN_MS, O as MIME_CANDIDATES, P as PROVENANCE_WAIT_MS, S as SHORT_CLIP_TOLERANCE_MS, Q as STOP_GRACE_MS, T as TIMESLICE_MS, U as UPRIGHT_WATCH_MS, V as V3ChecksPayload, R as V3GateFactor, W as V3GateQuality, X as V3GateThresholds, Y as V3GateTick, Z as V3GateTickInput, _ as V3TelemetryEvent, $ as V3_GATE_DEFAULTS, a0 as VIDEO_BPS, a1 as betterTake, a2 as blockReasonOf, a3 as buildLivenessV2FormData, a4 as cameraPreflight, a5 as classifyDevice, a6 as extForMime, a7 as isClipTooLarge, a8 as isMediaRecorderSupported, a9 as mapGetUserMediaError, aa as needsRetake, ab as pickMimeType, ac as probeDevice } from '../capture-session-v3-C0bbHvDc.js';
3
3
  export { C as CENTERED_FACTOR, a as CIRCLE_RADIUS_FACTOR, F as FormFactor, I as IN_CIRCLE_FACTOR, P as PHONE_MAX_SHORT_SIDE, b as buildCaptureConstraints, d as detectFormFactor, c as detectIsMobile, t as trackFacingMode } from '../capture-constraints-CVqpMNGA.js';
4
4
  export { C as CreateDetectorOptions, D as DEFAULT_TIER_ORDER, a as DEFAULT_V3_ASSET_BASE_URL, b as Detector, c as DetectorLadderError, F as FaceObservation, S as SECOND_FACE_AREA_RATIO, d as countExtraFaces, e as createDetector, i as intrinsicSize, t as toStreamPixels } from '../detect-worker-CHqsPJoM.js';
5
- import '../types-Cjnp1o8i.js';
5
+ import '../types-ZBcpvLdo.js';
6
6
 
7
7
  declare function captureMirroredKeyframe(video: HTMLVideoElement, canvas: HTMLCanvasElement, quality?: number): Promise<Blob>;
8
8
 
@@ -1 +1 @@
1
- import{A as ae,B as se,C as te,b as x,c as k,d as z,e as C,f as L,g as T,h as E,i as R,j as h,k as b,l as A,m as H,n as K,q as P,r as I,s as Y,t as Z,u as _,v as $,w as ee,x as re,y as oe,z as ne}from"../chunk-PBLZ5W7P.js";import"../chunk-SX7TUC3V.js";import{a as q,b as w,c as D,d as G}from"../chunk-POIQGEZM.js";import{a as c,b as p,c as u,d as f,e as m,f as d,g as l,h as v,i as y,j as g}from"../chunk-CPUECYAJ.js";import{a as J,b as M,c as Q,d as W,e as X}from"../chunk-FPXL63KZ.js";import{a as e,b as r,c as o,d as n,e as a,f as s,g as t,h as i}from"../chunk-TSA6GHUG.js";import"../chunk-JYU5YHXN.js";import{a as S,b as B,c as F,d as N,e as O,f as U,g as V,h as j}from"../chunk-FSSMUAKC.js";var ie={permission:{key:"fcv2.err.permission",fr:"Autorisez la cam\xE9ra dans les r\xE9glages du navigateur (ic\xF4ne cam\xE9ra dans la barre d\u2019adresse), puis r\xE9essayez."},notfound:{key:"fcv2.err.notfound",fr:"Aucune cam\xE9ra d\xE9tect\xE9e. Branchez ou activez une cam\xE9ra, puis r\xE9essayez."},inuse:{key:"fcv2.err.inuse",fr:"La cam\xE9ra est utilis\xE9e par une autre application. Fermez-la puis r\xE9essayez."},overconstrained:{key:"fcv2.err.overconstrained",fr:"La cam\xE9ra ne prend pas en charge les r\xE9glages demand\xE9s. Nouvel essai en cours\u2026"},insecure:{key:"fcv2.err.insecure",fr:"La cam\xE9ra n\xE9cessite une connexion s\xE9curis\xE9e (HTTPS). Ouvrez la page en HTTPS."},unsupported:{key:"fcv2.err.unsupported",fr:"Votre navigateur ne prend pas en charge l\u2019enregistrement vid\xE9o. Utilisez un navigateur r\xE9cent."},generic:{key:"fcv2.err.generic",fr:"Cam\xE9ra indisponible. R\xE9essayez ou contactez le support."}},ce={recording:{key:"fcv2.recording",fr:"Enregistrement en cours\u2026"},uploading:{key:"fcv2.uploading",fr:"Envoi en cours\u2026"},clipTooLarge:{key:"fcv2.err.cliptoolarge",fr:"La vid\xE9o est trop volumineuse. R\xE9essayez dans un endroit mieux \xE9clair\xE9."},retry:{key:"fcv2.retry",fr:"R\xE9essayer"},listen:{key:"fcv2.listen",fr:"\xC9couter"}};export{i as CENTERED_FACTOR,s as CIRCLE_RADIUS_FACTOR,x as CLIP_MS,te as CaptureSessionV3,h as ClipError,K as ClipRecorder,u as DEFAULT_CLIP_MIME,N as DEFAULT_TIER_ORDER,F as DEFAULT_V3_ASSET_BASE_URL,q as DEVICE_PROFILES,I as DetectScheduler,O as DetectorLadderError,G as DeviceProfiler,L as ENCODER_TAIL_MS,M as EXPOSURE_BAND,E as FRAME_POLL_MS,Z as FaceGateV3,ee as GATE_SNAPSHOT_MS,$ as GateBlockStats,re as HOLD_UPRIGHT_KEY,R as INSPECT_WAIT_MS,t as IN_CIRCLE_FACTOR,ne as KEYFRAME_CANDIDATES,ae as KEYFRAME_WINDOW_MS,l as MAX_CLIP_BYTES,T as MAX_OVERRUN_MS,c as MIME_CANDIDATES,r as PHONE_MAX_SHORT_SIDE,se as PROVENANCE_WAIT_MS,S as SECOND_FACE_AREA_RATIO,J as SHARP_REF,b as SHORT_CLIP_TOLERANCE_MS,z as STOP_GRACE_MS,k as TIMESLICE_MS,oe as UPRIGHT_WATCH_MS,Y as V3_GATE_DEFAULTS,C as VIDEO_BPS,H as betterTake,_ as blockReasonOf,e as buildCaptureConstraints,g as buildLivenessV2FormData,m as cameraPreflight,P as captureMirroredKeyframe,D as classifyDevice,B as countExtraFaces,j as createDetector,o as detectFormFactor,n as detectIsMobile,ie as errorCopy,X as exposure,y as extForMime,U as intrinsicSize,v as isClipTooLarge,d as isMediaRecorderSupported,f as mapGetUserMediaError,Q as meanLuma,A as needsRetake,p as pickMimeType,w as probeDevice,W as sharpness,V as toStreamPixels,a as trackFacingMode,ce as uiCopy};
1
+ import{A as ae,B as se,C as te,b as x,c as k,d as z,e as C,f as L,g as T,h as E,i as R,j as h,k as b,l as A,m as H,n as K,q as P,r as I,s as Y,t as Z,u as _,v as $,w as ee,x as re,y as oe,z as ne}from"../chunk-J4S3QMK6.js";import"../chunk-SX7TUC3V.js";import{a as q,b as w,c as D,d as G}from"../chunk-POIQGEZM.js";import{a as c,b as p,c as u,d as f,e as m,f as d,g as l,h as v,i as y,j as g}from"../chunk-CPUECYAJ.js";import{a as J,b as M,c as Q,d as W,e as X}from"../chunk-FPXL63KZ.js";import{a as e,b as r,c as o,d as n,e as a,f as s,g as t,h as i}from"../chunk-TSA6GHUG.js";import"../chunk-EHKCOBE2.js";import{a as S,b as B,c as F,d as N,e as O,f as U,g as V,h as j}from"../chunk-FSSMUAKC.js";var ie={permission:{key:"fcv2.err.permission",fr:"Autorisez la cam\xE9ra dans les r\xE9glages du navigateur (ic\xF4ne cam\xE9ra dans la barre d\u2019adresse), puis r\xE9essayez."},notfound:{key:"fcv2.err.notfound",fr:"Aucune cam\xE9ra d\xE9tect\xE9e. Branchez ou activez une cam\xE9ra, puis r\xE9essayez."},inuse:{key:"fcv2.err.inuse",fr:"La cam\xE9ra est utilis\xE9e par une autre application. Fermez-la puis r\xE9essayez."},overconstrained:{key:"fcv2.err.overconstrained",fr:"La cam\xE9ra ne prend pas en charge les r\xE9glages demand\xE9s. Nouvel essai en cours\u2026"},insecure:{key:"fcv2.err.insecure",fr:"La cam\xE9ra n\xE9cessite une connexion s\xE9curis\xE9e (HTTPS). Ouvrez la page en HTTPS."},unsupported:{key:"fcv2.err.unsupported",fr:"Votre navigateur ne prend pas en charge l\u2019enregistrement vid\xE9o. Utilisez un navigateur r\xE9cent."},generic:{key:"fcv2.err.generic",fr:"Cam\xE9ra indisponible. R\xE9essayez ou contactez le support."}},ce={recording:{key:"fcv2.recording",fr:"Enregistrement en cours\u2026"},uploading:{key:"fcv2.uploading",fr:"Envoi en cours\u2026"},clipTooLarge:{key:"fcv2.err.cliptoolarge",fr:"La vid\xE9o est trop volumineuse. R\xE9essayez dans un endroit mieux \xE9clair\xE9."},retry:{key:"fcv2.retry",fr:"R\xE9essayer"},listen:{key:"fcv2.listen",fr:"\xC9couter"}};export{i as CENTERED_FACTOR,s as CIRCLE_RADIUS_FACTOR,x as CLIP_MS,te as CaptureSessionV3,h as ClipError,K as ClipRecorder,u as DEFAULT_CLIP_MIME,N as DEFAULT_TIER_ORDER,F as DEFAULT_V3_ASSET_BASE_URL,q as DEVICE_PROFILES,I as DetectScheduler,O as DetectorLadderError,G as DeviceProfiler,L as ENCODER_TAIL_MS,M as EXPOSURE_BAND,E as FRAME_POLL_MS,Z as FaceGateV3,ee as GATE_SNAPSHOT_MS,$ as GateBlockStats,re as HOLD_UPRIGHT_KEY,R as INSPECT_WAIT_MS,t as IN_CIRCLE_FACTOR,ne as KEYFRAME_CANDIDATES,ae as KEYFRAME_WINDOW_MS,l as MAX_CLIP_BYTES,T as MAX_OVERRUN_MS,c as MIME_CANDIDATES,r as PHONE_MAX_SHORT_SIDE,se as PROVENANCE_WAIT_MS,S as SECOND_FACE_AREA_RATIO,J as SHARP_REF,b as SHORT_CLIP_TOLERANCE_MS,z as STOP_GRACE_MS,k as TIMESLICE_MS,oe as UPRIGHT_WATCH_MS,Y as V3_GATE_DEFAULTS,C as VIDEO_BPS,H as betterTake,_ as blockReasonOf,e as buildCaptureConstraints,g as buildLivenessV2FormData,m as cameraPreflight,P as captureMirroredKeyframe,D as classifyDevice,B as countExtraFaces,j as createDetector,o as detectFormFactor,n as detectIsMobile,ie as errorCopy,X as exposure,y as extForMime,U as intrinsicSize,v as isClipTooLarge,d as isMediaRecorderSupported,f as mapGetUserMediaError,Q as meanLuma,A as needsRetake,p as pickMimeType,w as probeDevice,W as sharpness,V as toStreamPixels,a as trackFacingMode,ce as uiCopy};
@@ -1 +1 @@
1
- import{u as a,v as b,w as c,x as d}from"./chunk-YWGW63B3.js";import"./chunk-G6LKLN4U.js";import"./chunk-TDLIXFDT.js";import"./chunk-5DTWBDCP.js";import"./chunk-7QZWBDI5.js";import"./chunk-PBLZ5W7P.js";import"./chunk-SX7TUC3V.js";import"./chunk-POIQGEZM.js";import"./chunk-CPUECYAJ.js";import"./chunk-FPXL63KZ.js";import"./chunk-TSA6GHUG.js";import"./chunk-JYU5YHXN.js";import"./chunk-FSSMUAKC.js";import"./chunk-DK5YPBDQ.js";export{a as SAME_FACE_MAX_DROPS,c as createDocumentCapture,d as createDocumentCaptureInternal,b as warmDocumentCapture};
1
+ import{u as a,v as b,w as c,x as d}from"./chunk-MGO2ME5X.js";import"./chunk-G6LKLN4U.js";import"./chunk-TDLIXFDT.js";import"./chunk-DIKSFEYQ.js";import"./chunk-7QZWBDI5.js";import"./chunk-J4S3QMK6.js";import"./chunk-SX7TUC3V.js";import"./chunk-POIQGEZM.js";import"./chunk-CPUECYAJ.js";import"./chunk-FPXL63KZ.js";import"./chunk-TSA6GHUG.js";import"./chunk-EHKCOBE2.js";import"./chunk-FSSMUAKC.js";import"./chunk-DK5YPBDQ.js";export{a as SAME_FACE_MAX_DROPS,c as createDocumentCapture,d as createDocumentCaptureInternal,b as warmDocumentCapture};
@@ -1,7 +1,50 @@
1
1
  import { b as Detector } from './detect-worker-CHqsPJoM.cjs';
2
- import { A as AcceptedDocumentType, a8 as NationalEidOption, aH as StepSection, aS as HostedBranding, am as PlanSectionView, aj as PlanChoiceKind, T as HostedSimulationView, l as ContactChannel, f as CheckReason, aW as RetakeHint, ag as PhotoSource, ah as PhotoSourcePick, $ as IdentityMethod, E as EidAfterPass, a0 as IdentitySummarySource, J as HostedIcaoPolicy, ac as PhoneCountryRule, Z as IcaoReportEntry, aV as IcaoCaptureTuning, Q as HostedPortraitPendingFix, b as CaptureMode, aB as SessionReason, az as SessionDecidingStep, S as HostedSessionView, U as HostedStepView, an as PlanStepView, ay as ResolvedCaptureMode, a_ as ScreenRampReport, aR as CaptureProvenance, aY as ScreenRampPaint, aA as SessionFailureReason, aO as AgeEstimationReason, aM as VerificationLevel, aL as VerificationAssurance, a7 as MethodChoiceView, aP as CameraUnavailableCause, aQ as CaptureIssueReport, X as HostedVoiceView, aX as ScreenRampChallenge, b3 as PersonMask, a as AttestationInput, h as CheckType, as as PortraitIcaoInput } from './types-Cjnp1o8i.cjs';
3
- import { i as CaptureState$1, f as CaptureSessionV3Events, g as CaptureSessionV3Options, c as CaptureErrorKind$1, q as DeviceClass, b as CaptureArtifacts, ad as EngineErrorDetail, W as V3GateQuality, _ as V3TelemetryEvent } from './capture-session-v3-CFXYS0Pg.cjs';
4
- import { f as IcaoGateSummary, g as IcaoGateUpdate, P as Point, p as IcaoGateScores, h as Box, m as IcaoFrameObservation, H as HostedClient, n as IcaoGate } from './icao-gate-CIXjbPCL.cjs';
2
+ import { A as AcceptedDocumentType, a9 as NationalEidOption, aI as StepSection, aT as HostedBranding, an as PlanSectionView, ak as PlanChoiceKind, U as HostedSimulationView, l as ContactChannel, f as CheckReason, aX as RetakeHint, ah as PhotoSource, ai as PhotoSourcePick, a0 as IdentityMethod, E as EidAfterPass, a1 as IdentitySummarySource, K as HostedIcaoPolicy, ad as PhoneCountryRule, _ as IcaoReportEntry, aW as IcaoCaptureTuning, R as HostedPortraitPendingFix, b as CaptureMode, aC as SessionReason, aA as SessionDecidingStep, T as HostedSessionView, V as HostedStepView, ao as PlanStepView, az as ResolvedCaptureMode, a$ as ScreenRampReport, aS as CaptureProvenance, aZ as ScreenRampPaint, aB as SessionFailureReason, aP as AgeEstimationReason, aN as VerificationLevel, aM as VerificationAssurance, a8 as MethodChoiceView, aQ as CameraUnavailableCause, aR as CaptureIssueReport, Y as HostedVoiceView, aY as ScreenRampChallenge, b4 as PersonMask, a as AttestationInput, h as CheckType, at as PortraitIcaoInput, w as HostedChallengeView } from './types-ZBcpvLdo.cjs';
3
+ import { i as CaptureState$1, f as CaptureSessionV3Events, g as CaptureSessionV3Options, c as CaptureErrorKind$1, q as DeviceClass, b as CaptureArtifacts, ad as EngineErrorDetail, W as V3GateQuality, _ as V3TelemetryEvent } from './capture-session-v3-BoGn8vLv.cjs';
4
+ import { f as IcaoGateSummary, g as IcaoGateUpdate, P as Point, p as IcaoGateScores, h as Box, m as IcaoFrameObservation, H as HostedClient, n as IcaoGate } from './icao-gate-DGtY696t.cjs';
5
+
6
+ /** Why a challenge produced no token (spec §4.5). */
7
+ type ChallengeErrorCode = "challenge_frame_blocked" | "challenge_script_blocked" | "site_key_rejected" | "challenge_failed" | "timeout" | "embedder_opaque" | "aborted";
8
+ /** A challenge that produced no token. `detail` is Cloudflare's numeric error code when there is one. */
9
+ declare class ChallengeError extends Error {
10
+ readonly code: ChallengeErrorCode;
11
+ readonly detail?: string;
12
+ constructor(code: ChallengeErrorCode, detail?: string);
13
+ }
14
+ /** Bound on the frame's `ready` message after it is inserted (a blocked frame never sends it). */
15
+ declare const CHALLENGE_READY_TIMEOUT_MS = 10000;
16
+ /**
17
+ * Bound on one challenge after the request is posted. A healthy invisible
18
+ * challenge settles in a few seconds, but slow phones and networks routinely
19
+ * take 10 to 20 s (incident 2026-11-10), so the bound is 30 s.
20
+ */
21
+ declare const CHALLENGE_EXECUTE_TIMEOUT_MS = 30000;
22
+ /** What the token is for: the liveness submission, or the try-link start. */
23
+ type ChallengeAction = "liveness" | "try_link";
24
+ /** Options of {@link executeChallenge}. */
25
+ interface ExecuteChallengeOptions {
26
+ /** The frame URL (`HostedSessionView.challenge.url`). */
27
+ frameUrl: string;
28
+ /** The site key the frame renders (`HostedSessionView.challenge.siteKey`). */
29
+ siteKey: string;
30
+ action: ChallengeAction;
31
+ /** The session id (`ses_...`) for `liveness`; the hex sha256 of the try token for `try_link`. */
32
+ subject: string;
33
+ /** Aborts the challenge: the promise rejects with `aborted` and the frame is removed. */
34
+ signal?: AbortSignal;
35
+ /** Bound on the challenge once requested; default {@link CHALLENGE_EXECUTE_TIMEOUT_MS}. */
36
+ timeoutMs?: number;
37
+ /** Bound on the frame's `ready`; default {@link CHALLENGE_READY_TIMEOUT_MS}. */
38
+ readyTimeoutMs?: number;
39
+ }
40
+ /** Test-only: drop the kept frame and the queue between cases. */
41
+ declare function resetChallengeFrameForTests(): void;
42
+ /**
43
+ * Obtain one token from the challenge frame. Challenges run in order on one
44
+ * kept frame; a failed challenge runs once more on a fresh frame before the
45
+ * promise rejects with a {@link ChallengeError}.
46
+ */
47
+ declare function executeChallenge(opts: ExecuteChallengeOptions): Promise<string>;
5
48
 
6
49
  declare const ISSUER_CODES: readonly string[];
7
50
 
@@ -1074,7 +1117,8 @@ interface LivenessCaptureOptions {
1074
1117
  /**
1075
1118
  * SDK-side failure reasons (status `'unavailable'`):
1076
1119
  * - `no_recorder` — no MediaRecorder / unsupported clip container;
1077
- * - `attestation` — Turnstile failed client-side or `attestation_invalid` after one retry;
1120
+ * - `attestation` — the challenge frame produced no token and the server refused the submission without one, or
1121
+ * `attestation_invalid` after one retry ({@link VerificationResult.attestationError} says why the frame failed);
1078
1122
  * - `network` — transport / API failure after the bounded replays;
1079
1123
  * - `nni_unbound` — `population_registry` is the frontier but the session was
1080
1124
  * minted WITHOUT a bound ID number (`POST /sessions` `subject.idNumber`), so
@@ -1157,6 +1201,12 @@ interface VerificationResult {
1157
1201
  level?: VerificationLevel;
1158
1202
  /** How the level was proved, when the API reports it. */
1159
1203
  assurance?: VerificationAssurance;
1204
+ /**
1205
+ * `unavailable` with reason code `attestation` only: why the security check frame produced no token, when it
1206
+ * failed on this page. `challenge_frame_blocked` means the page's Content-Security-Policy (or an extension) blocked
1207
+ * the frame: allow `frame-src` for the Sekyro verification host. Absent when the server refused a token.
1208
+ */
1209
+ attestationError?: ChallengeErrorCode;
1160
1210
  }
1161
1211
  /**
1162
1212
  * `on('busy')` payload: the model service answered
@@ -3222,7 +3272,7 @@ declare const TRANSPORT_REPLAY_DELAY_MS = 1000;
3222
3272
  */
3223
3273
  declare const INFERENCE_RETRY_ATTEMPTS = 3;
3224
3274
  declare const INFERENCE_RETRY_DEFAULT_S = 10;
3225
- /** A Turnstile challenge failed client-side (load / render / error-callback / timeout). */
3275
+ /** `getAttestation` threw (a host's own seam): the submission is not sent. The challenge frame never throws here. */
3226
3276
  declare class AttestationError extends Error {
3227
3277
  constructor(message: string);
3228
3278
  }
@@ -3262,8 +3312,13 @@ declare function runSubmission(rt: SubmitRuntime, executor: SubmitExecutor, hook
3262
3312
  }): Promise<HostedSessionView>;
3263
3313
  interface LivenessFlowDeps extends SubmitRuntime {
3264
3314
  artifacts: CapturedArtifacts;
3265
- /** Fresh attestation per call (Turnstile execute; `{}` when the view has no site key). */
3315
+ /** Fresh attestation per call (the challenge frame's token; `{}` when the view has no challenge). */
3266
3316
  getAttestation(): Promise<AttestationInput>;
3317
+ /**
3318
+ * Why the challenge behind the attestation just returned produced no token (a `ChallengeErrorCode`), sent as
3319
+ * `input.capture.attestationError`; undefined when it did.
3320
+ */
3321
+ attestationError?(): string | undefined;
3267
3322
  /** Latest hosted view (frontier decisions). */
3268
3323
  getView(): HostedSessionView;
3269
3324
  /** Re-GET the view from the server (after a RESYNC code) and fold it in. */
@@ -3396,11 +3451,12 @@ interface VerificationInternals {
3396
3451
  /** Replace the HTTP client (default: `new HostedClient({...})`). */
3397
3452
  client?: HostedClientLike;
3398
3453
  /**
3399
- * Replace the Turnstile challenge (default: `executeTurnstile`, loaded on first use). The
3400
- * `signal` aborts when the verification is destroyed (M1).
3454
+ * Replace the challenge (default: `executeChallenge` on the view's challenge frame, loaded on first use).
3455
+ * `subject` is the session id the token is bound to; the `signal` aborts when the verification is destroyed (M1).
3401
3456
  */
3402
- getTurnstileToken?: (siteKey: string, opts: {
3457
+ getChallengeToken?: (challenge: HostedChallengeView, opts: {
3403
3458
  signal: AbortSignal;
3459
+ subject: string;
3404
3460
  }) => Promise<string>;
3405
3461
  /** Capture-engine seams forwarded to {@link createLivenessCaptureInternal}. */
3406
3462
  capture?: LivenessCaptureInternals;
@@ -3429,4 +3485,4 @@ declare function createVerification(options: VerificationOptions): Verification;
3429
3485
  /** {@link createVerification} with construction seams (tests / Sekyro AI-internal hosts). */
3430
3486
  declare function createVerificationInternal(options: VerificationOptions, internals: VerificationInternals): Verification;
3431
3487
 
3432
- export { type LivePhotoPlan as $, type AcceptedDocumentsLike as A, type DocumentGuideMeasure as B, type CameraFacing as C, type DocumentCaptureOptions as D, type DocumentLiveMrzOptions as E, type DocumentMrzUpdate as F, type DocumentPoint as G, type DocumentQuad as H, type DocumentReticle as I, type DocumentScanPhase as J, type DocumentScanUpdate as K, type DocumentSide as L, type DocumentSnapshot as M, type DocumentStepHandle as N, type EidSnapshot as O, type PortraitCaptureOptions as P, type EidStepHandle as Q, type EmailOtpSnapshot as R, type EmailOtpStepHandle as S, type EmailSource as T, type GateHint as U, type GateUpdate as V, ISSUER_CODES as W, type IdentitySummarySnapshot as X, type IdentitySummaryStepHandle as Y, type InLaneSwitch as Z, type LivePhotoGateUpdate as _, type DocumentCaptureHandle as a, sectionOf as a$, type LivenessAssetsStatus as a0, type LivenessCaptureEvents as a1, type LivenessCaptureHandle as a2, type LivenessCaptureOptions as a3, type LivenessSnapshot as a4, type LivenessStartOptions as a5, type LivenessStepHandle as a6, type MethodSnapshot as a7, type MethodStepHandle as a8, type MobileRequiredSnapshot as a9, type StepContext as aA, type StepSnapshot as aB, type UnsupportedReason as aC, type UnsupportedSnapshot as aD, type UnsupportedStepHandle as aE, type Verification as aF, type VerificationBusy as aG, type VerificationEvents as aH, type VerificationLocale as aI, type VerificationOptions as aJ, type VerificationResult as aK, type VerificationStatus as aL, type VerificationStep as aM, WEB_IDENTITY_METHODS as aN, acceptedIssuers as aO, acceptedTypesFor as aP, cameraUnavailableCauseOf as aQ, createLivenessCapture as aR, createVerification as aS, deriveStep as aT, flagOf as aU, getLivenessAssetsStatus as aV, laneOf as aW, otherOptions as aX, preloadLivenessAssets as aY, releaseLivenessAssets as aZ, resolveAcceptedDocuments as a_, type MobileRequiredStepHandle as aa, type OtpChannel as ab, type OtpNumberSource as ac, PLATFORM_UNSUPPORTED as ad, type PhoneOtpSnapshot as ae, type PhoneOtpStepHandle as af, type PhotoSourceState as ag, type PlanChoiceSnapshot as ah, type PortraitCaptureEvents as ai, type PortraitCaptureState as aj, type PortraitGateUpdate as ak, type PortraitSnapshot as al, type PortraitStartOptions as am, type PortraitStepHandle as an, type PreloadLivenessAssetsOptions as ao, type ProcessingSnapshot as ap, type ProcessingStepHandle as aq, type ReasonCode as ar, type RegistrySnapshot as as, type RegistrySource as at, type RegistryStepHandle as au, type ResultDisplay as av, type ResultSnapshot as aw, type ResultStepHandle as ax, type SdkFailureReason as ay, type StepAttempts as az, type PortraitCaptureHandle as b, type EncodedDocument as b$, subscribeLivenessAssets as b0, type DocCatalogEntry as b1, type LiveMrzTuning as b2, type TextLockTuning as b3, type OcrEngineClient as b4, type DocAssistReport as b5, type ReadyInfo as b6, type LoadFailure as b7, type OcrEngineOptions as b8, type SubmitRuntime as b9, DocAssist as bA, type DocAssistEngine as bB, type DocAssistTick as bC, type DocCameraTuning as bD, type DocCaptureReport as bE, type DocCaptureVia as bF, type DocChecksPayload as bG, type DocEngineLike as bH, DocFeedbackAggregator as bI, type DocFeedbackKey as bJ, type DocFeedbackState as bK, type DocFormat as bL, type DocFrameAnalysis as bM, type DocFrameMeasures as bN, type DocGateQuality as bO, type DocGateThresholds as bP, type DocGateTick as bQ, type DocGateTickInput as bR, DocGateV1 as bS, type DocQuad as bT, type DocQuadPoint as bU, type DocShutterReason as bV, type DocShutterTuning as bW, type DocSide as bX, type DocumentCaptureController as bY, type DocumentCaptureInternals as bZ, EMPTY_GUIDE_METRICS as b_, type HostedClientLike as ba, ANALYSIS_LONG_EDGE as bb, ASPECT_BANDS as bc, AttestationError as bd, BLUR_REFUSE_SHARPNESS_MAX as be, type BlurStatus as bf, CAPTURE_CANDIDATE_SPACING_MS as bg, CAPTURE_EXTRA_CANDIDATES as bh, CLIP_MIME_ALLOWLIST as bi, type CaptureEngine as bj, CaptureSessionDoc as bk, type CaptureSessionDocEvents as bl, type CaptureSessionDocOptions as bm, DOC_ANALYSIS_DEFAULTS as bn, DOC_BLACK_FRAME_LUMA as bo, DOC_BLACK_FRAME_TICKS as bp, DOC_CADENCE_HZ as bq, DOC_CAMERA_TUNING_DEFAULTS as br, DOC_CATALOG as bs, DOC_DETECT_WIDTH as bt, DOC_FEEDBACK_STATES as bu, DOC_FIRST_FRAME_MS as bv, DOC_GATE_V1_DEFAULTS as bw, DOC_SHUTTER_DEFAULTS as bx, type DeviceReadHint as by, type DocArtifacts as bz, type CaptureChannel as c, analyzeGuide as c$, FLIP_FILL_MIN as c0, FLIP_GAP_MS as c1, FLIP_TIMEOUT_MS as c2, type FocusCaps as c3, type FramingStatus as c4, GUIDE_LOCK_DEFAULTS as c5, type GlareStatus as c6, type GrabbedFrame as c7, type GuideBlocker as c8, GuideLock as c9, MANUAL_SHUTTER_MS as cA, MR_DOC_CATALOG as cB, NO_REPORT_MS as cC, type OpenDocCameraDeps as cD, PORTRAIT_JPEG_QUALITY as cE, PRELOAD_BLAZE_INIT_TIMEOUT_MS as cF, PRELOAD_BUDGET_MS as cG, PROCESSING_POLL_DELAY_MS as cH, PROCESSING_POLL_MAX as cI, type PortraitCaptureController as cJ, type PortraitCaptureInternals as cK, REGISTRY_RETRY_DELAY_MS as cL, type ReticleType as cM, SAME_FACE_MAX_DROPS as cN, type ScanEvent as cO, type ScanLayout as cP, type ScanNotice as cQ, type ScanPhase as cR, type ScanReport as cS, type ScanSide as cT, type ScanState as cU, type SubmitExecutor as cV, TEXT_LOCK_DEFAULTS as cW, TRANSPORT_REPLAY_ATTEMPTS as cX, TRANSPORT_REPLAY_DELAY_MS as cY, type VerificationInternals as cZ, analyzeDocFrame as c_, type GuideLockTick as ca, type GuideLockTuning as cb, type GuideMetrics as cc, type GuideRect as cd, INFERENCE_RETRY_ATTEMPTS as ce, INFERENCE_RETRY_DEFAULT_S as cf, LANDMARKER_MODEL as cg, LENS_STORAGE_KEY as ch, LIVE_MRZ_DEFAULTS as ci, LIVE_PHOTO_IDLE_MS as cj, LIVE_PHOTO_MAX_HZ as ck, type LandmarkedFace as cl, type LandmarkerLike as cm, type LensSource as cn, type LightingStatus as co, type LiveMrzCapture as cp, type LiveMrzState as cq, type LivePhotoGate as cr, type LivePhotoKit as cs, type LivePhotoKitInternals as ct, type LivePhotoKitOptions as cu, type LivePhotoStill as cv, type LivenessCaptureInternalHandle as cw, type LivenessCaptureInternals as cx, type LivenessFlowDeps as cy, type LivenessFlowOutcome as cz, type CaptureEngineId as d, aspectBand as d0, aspectFits as d1, buildDeviceReadHint as d2, coverPointToVideo as d3, createDocumentCaptureInternal as d4, createFaceLandmarker as d5, createLivePhotoKit as d6, createLivenessCaptureInternal as d7, createPortraitCaptureInternal as d8, createVerificationInternal as d9, resolveDocShutterTuning as dA, resolveGuideLockTuning as dB, runLivenessFlow as dC, runSubmission as dD, scannerFormatFor as dE, setPreloadLoaderForTests as dF, settledHint as dG, singleShotFocusAt as dH, specularFraction as dI, supportsFocusMode as dJ, warmDocDetector as dK, writeStoredLens as dL, docZoomFor as da, encodeDocumentImage as db, facesOf as dc, feedbackVoteOf as dd, focusOk as de, guideQuad as df, guideRegionInFrame as dg, initialScanState as dh, mapEngineState as di, mapErrorKind as dj, mapGuidanceHint as dk, nextScanState as dl, observe as dm, openDocCamera as dn, passportBandOf as dp, portraitMatchStep as dq, preloadedDetectorFactory as dr, quadAreaFrac as ds, quadBounds as dt, quadIou as du, quadTiltRatio as dv, randomUuid as dw, readStoredLens as dx, resetLivenessAssetsForTests as dy, resolveDocCameraTuning as dz, type CaptureError as e, type CaptureErrorDetail as f, type CaptureErrorKind as g, type CaptureErrorPhase as h, type CaptureState as i, type CapturedArtifacts as j, type CapturedDocument as k, type CapturedPortrait as l, type ChoiceOptionSnapshot as m, type ChoiceSnapshot as n, type ChoiceStepHandle as o, type ContactChoiceSnapshot as p, type ContactChoiceStepHandle as q, DEFAULT_API_ORIGIN as r, DOCUMENT_TYPE_ORDER as s, type DeriveStepEnv as t, type DocumentCaptureEvents as u, type DocumentCaptureState as v, type DocumentFeedback as w, type DocumentFeedbackKey as x, type DocumentGateUpdate as y, type DocumentGuide as z };
3488
+ export { type LivePhotoGateUpdate as $, type AcceptedDocumentsLike as A, type DocumentGuide as B, type CameraFacing as C, type DocumentCaptureOptions as D, type DocumentGuideMeasure as E, type DocumentLiveMrzOptions as F, type DocumentMrzUpdate as G, type DocumentPoint as H, type DocumentQuad as I, type DocumentReticle as J, type DocumentScanPhase as K, type DocumentScanUpdate as L, type DocumentSide as M, type DocumentSnapshot as N, type DocumentStepHandle as O, type PortraitCaptureOptions as P, type EidSnapshot as Q, type EidStepHandle as R, type EmailOtpSnapshot as S, type EmailOtpStepHandle as T, type EmailSource as U, type GateHint as V, type GateUpdate as W, ISSUER_CODES as X, type IdentitySummarySnapshot as Y, type IdentitySummaryStepHandle as Z, type InLaneSwitch as _, type DocumentCaptureHandle as a, resolveAcceptedDocuments as a$, type LivePhotoPlan as a0, type LivenessAssetsStatus as a1, type LivenessCaptureEvents as a2, type LivenessCaptureHandle as a3, type LivenessCaptureOptions as a4, type LivenessSnapshot as a5, type LivenessStartOptions as a6, type LivenessStepHandle as a7, type MethodSnapshot as a8, type MethodStepHandle as a9, type StepAttempts as aA, type StepContext as aB, type StepSnapshot as aC, type UnsupportedReason as aD, type UnsupportedSnapshot as aE, type UnsupportedStepHandle as aF, type Verification as aG, type VerificationBusy as aH, type VerificationEvents as aI, type VerificationLocale as aJ, type VerificationOptions as aK, type VerificationResult as aL, type VerificationStatus as aM, type VerificationStep as aN, WEB_IDENTITY_METHODS as aO, acceptedIssuers as aP, acceptedTypesFor as aQ, cameraUnavailableCauseOf as aR, createLivenessCapture as aS, createVerification as aT, deriveStep as aU, flagOf as aV, getLivenessAssetsStatus as aW, laneOf as aX, otherOptions as aY, preloadLivenessAssets as aZ, releaseLivenessAssets as a_, type MobileRequiredSnapshot as aa, type MobileRequiredStepHandle as ab, type OtpChannel as ac, type OtpNumberSource as ad, PLATFORM_UNSUPPORTED as ae, type PhoneOtpSnapshot as af, type PhoneOtpStepHandle as ag, type PhotoSourceState as ah, type PlanChoiceSnapshot as ai, type PortraitCaptureEvents as aj, type PortraitCaptureState as ak, type PortraitGateUpdate as al, type PortraitSnapshot as am, type PortraitStartOptions as an, type PortraitStepHandle as ao, type PreloadLivenessAssetsOptions as ap, type ProcessingSnapshot as aq, type ProcessingStepHandle as ar, type ReasonCode as as, type RegistrySnapshot as at, type RegistrySource as au, type RegistryStepHandle as av, type ResultDisplay as aw, type ResultSnapshot as ax, type ResultStepHandle as ay, type SdkFailureReason as az, type PortraitCaptureHandle as b, type DocShutterTuning as b$, sectionOf as b0, subscribeLivenessAssets as b1, type DocCatalogEntry as b2, type LiveMrzTuning as b3, type TextLockTuning as b4, type OcrEngineClient as b5, type DocAssistReport as b6, type ReadyInfo as b7, type LoadFailure as b8, type OcrEngineOptions as b9, DOC_FIRST_FRAME_MS as bA, DOC_GATE_V1_DEFAULTS as bB, DOC_SHUTTER_DEFAULTS as bC, type DeviceReadHint as bD, type DocArtifacts as bE, DocAssist as bF, type DocAssistEngine as bG, type DocAssistTick as bH, type DocCameraTuning as bI, type DocCaptureReport as bJ, type DocCaptureVia as bK, type DocChecksPayload as bL, type DocEngineLike as bM, DocFeedbackAggregator as bN, type DocFeedbackKey as bO, type DocFeedbackState as bP, type DocFormat as bQ, type DocFrameAnalysis as bR, type DocFrameMeasures as bS, type DocGateQuality as bT, type DocGateThresholds as bU, type DocGateTick as bV, type DocGateTickInput as bW, DocGateV1 as bX, type DocQuad as bY, type DocQuadPoint as bZ, type DocShutterReason as b_, type SubmitRuntime as ba, type HostedClientLike as bb, ANALYSIS_LONG_EDGE as bc, ASPECT_BANDS as bd, AttestationError as be, BLUR_REFUSE_SHARPNESS_MAX as bf, type BlurStatus as bg, CAPTURE_CANDIDATE_SPACING_MS as bh, CAPTURE_EXTRA_CANDIDATES as bi, CHALLENGE_EXECUTE_TIMEOUT_MS as bj, CHALLENGE_READY_TIMEOUT_MS as bk, CLIP_MIME_ALLOWLIST as bl, type CaptureEngine as bm, CaptureSessionDoc as bn, type CaptureSessionDocEvents as bo, type CaptureSessionDocOptions as bp, type ChallengeAction as bq, ChallengeError as br, DOC_ANALYSIS_DEFAULTS as bs, DOC_BLACK_FRAME_LUMA as bt, DOC_BLACK_FRAME_TICKS as bu, DOC_CADENCE_HZ as bv, DOC_CAMERA_TUNING_DEFAULTS as bw, DOC_CATALOG as bx, DOC_DETECT_WIDTH as by, DOC_FEEDBACK_STATES as bz, type CaptureChannel as c, type SubmitExecutor as c$, type DocSide as c0, type DocumentCaptureController as c1, type DocumentCaptureInternals as c2, EMPTY_GUIDE_METRICS as c3, type EncodedDocument as c4, type ExecuteChallengeOptions as c5, FLIP_FILL_MIN as c6, FLIP_GAP_MS as c7, FLIP_TIMEOUT_MS as c8, type FocusCaps as c9, type LivePhotoKitOptions as cA, type LivePhotoStill as cB, type LivenessCaptureInternalHandle as cC, type LivenessCaptureInternals as cD, type LivenessFlowDeps as cE, type LivenessFlowOutcome as cF, MANUAL_SHUTTER_MS as cG, MR_DOC_CATALOG as cH, NO_REPORT_MS as cI, type OpenDocCameraDeps as cJ, PORTRAIT_JPEG_QUALITY as cK, PRELOAD_BLAZE_INIT_TIMEOUT_MS as cL, PRELOAD_BUDGET_MS as cM, PROCESSING_POLL_DELAY_MS as cN, PROCESSING_POLL_MAX as cO, type PortraitCaptureController as cP, type PortraitCaptureInternals as cQ, REGISTRY_RETRY_DELAY_MS as cR, type ReticleType as cS, SAME_FACE_MAX_DROPS as cT, type ScanEvent as cU, type ScanLayout as cV, type ScanNotice as cW, type ScanPhase as cX, type ScanReport as cY, type ScanSide as cZ, type ScanState as c_, type FramingStatus as ca, GUIDE_LOCK_DEFAULTS as cb, type GlareStatus as cc, type GrabbedFrame as cd, type GuideBlocker as ce, GuideLock as cf, type GuideLockTick as cg, type GuideLockTuning as ch, type GuideMetrics as ci, type GuideRect as cj, INFERENCE_RETRY_ATTEMPTS as ck, INFERENCE_RETRY_DEFAULT_S as cl, LANDMARKER_MODEL as cm, LENS_STORAGE_KEY as cn, LIVE_MRZ_DEFAULTS as co, LIVE_PHOTO_IDLE_MS as cp, LIVE_PHOTO_MAX_HZ as cq, type LandmarkedFace as cr, type LandmarkerLike as cs, type LensSource as ct, type LightingStatus as cu, type LiveMrzCapture as cv, type LiveMrzState as cw, type LivePhotoGate as cx, type LivePhotoKit as cy, type LivePhotoKitInternals as cz, type CaptureEngineId as d, TEXT_LOCK_DEFAULTS as d0, TRANSPORT_REPLAY_ATTEMPTS as d1, TRANSPORT_REPLAY_DELAY_MS as d2, type VerificationInternals as d3, analyzeDocFrame as d4, analyzeGuide as d5, aspectBand as d6, aspectFits as d7, buildDeviceReadHint as d8, coverPointToVideo as d9, quadBounds as dA, quadIou as dB, quadTiltRatio as dC, randomUuid as dD, readStoredLens as dE, resetChallengeFrameForTests as dF, resetLivenessAssetsForTests as dG, resolveDocCameraTuning as dH, resolveDocShutterTuning as dI, resolveGuideLockTuning as dJ, runLivenessFlow as dK, runSubmission as dL, scannerFormatFor as dM, setPreloadLoaderForTests as dN, settledHint as dO, singleShotFocusAt as dP, specularFraction as dQ, supportsFocusMode as dR, warmDocDetector as dS, writeStoredLens as dT, createDocumentCaptureInternal as da, createFaceLandmarker as db, createLivePhotoKit as dc, createLivenessCaptureInternal as dd, createPortraitCaptureInternal as de, createVerificationInternal as df, docZoomFor as dg, encodeDocumentImage as dh, executeChallenge as di, facesOf as dj, feedbackVoteOf as dk, focusOk as dl, guideQuad as dm, guideRegionInFrame as dn, initialScanState as dp, mapEngineState as dq, mapErrorKind as dr, mapGuidanceHint as ds, nextScanState as dt, observe as du, openDocCamera as dv, passportBandOf as dw, portraitMatchStep as dx, preloadedDetectorFactory as dy, quadAreaFrac as dz, type CaptureError as e, type CaptureErrorDetail as f, type CaptureErrorKind as g, type CaptureErrorPhase as h, type CaptureState as i, type CapturedArtifacts as j, type CapturedDocument as k, type CapturedPortrait as l, type ChallengeErrorCode as m, type ChoiceOptionSnapshot as n, type ChoiceSnapshot as o, type ChoiceStepHandle as p, type ContactChoiceSnapshot as q, type ContactChoiceStepHandle as r, DEFAULT_API_ORIGIN as s, DOCUMENT_TYPE_ORDER as t, type DeriveStepEnv as u, type DocumentCaptureEvents as v, type DocumentCaptureState as w, type DocumentFeedback as x, type DocumentFeedbackKey as y, type DocumentGateUpdate as z };