@sekyro/web 0.1.0-rc.4 → 0.1.0-rc.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +491 -0
- package/LICENSE +25 -16
- package/README.md +158 -62
- package/THIRD-PARTY-NOTICES.txt +154 -0
- package/dist/assets.generated-DpkbvoII.d.cts +249 -0
- package/dist/assets.generated-DpkbvoII.d.ts +249 -0
- package/dist/background-monitor-A7FKJOAG.js +1 -0
- package/dist/barcode-detect-C5IOXMKI.js +1 -0
- package/dist/camera-trait-DELAK3YN.js +1 -0
- package/dist/capture-constraints-CVqpMNGA.d.cts +48 -0
- package/dist/capture-constraints-CVqpMNGA.d.ts +48 -0
- package/dist/capture-session-doc-DFLSX6BB.js +1 -0
- package/dist/{capture-session-v3-uXJr1Wlm.d.ts → capture-session-v3-C-9FB_vX.d.cts} +232 -13
- package/dist/{capture-session-v3-DEInCOUg.d.cts → capture-session-v3-DEpGJ_fI.d.ts} +232 -13
- package/dist/challenge-frame-YBTLAQ5G.js +1 -0
- package/dist/chunk-22AW4NJD.js +1 -0
- package/dist/chunk-33KKMPJ5.js +1 -0
- package/dist/chunk-3WQJI7UL.js +1 -0
- package/dist/chunk-4NO6MQPH.js +1 -0
- package/dist/chunk-53POX7U4.js +1 -0
- package/dist/chunk-7QZWBDI5.js +1 -0
- package/dist/chunk-BD4KIQQD.js +1 -0
- package/dist/chunk-BPAGOPYL.js +1 -0
- package/dist/chunk-BRLQIJYF.js +1 -0
- package/dist/chunk-CJHMFPL6.js +1 -0
- package/dist/chunk-CPUECYAJ.js +1 -0
- package/dist/chunk-FPXL63KZ.js +1 -0
- package/dist/chunk-FSSMUAKC.js +1 -0
- package/dist/chunk-FYU7J2DC.js +1 -0
- package/dist/chunk-GFJATPUR.js +1 -0
- package/dist/chunk-GI3UFGRQ.js +1 -0
- package/dist/chunk-JLVZ35QK.js +2 -0
- package/dist/chunk-L3TNFMQK.js +1 -0
- package/dist/chunk-M3637QGB.js +1 -0
- package/dist/chunk-MQHTFHSN.js +1 -0
- package/dist/chunk-POIQGEZM.js +1 -0
- package/dist/chunk-QB62OPX5.js +1 -0
- package/dist/chunk-QZUFICG3.js +1 -0
- package/dist/chunk-RI3E7GBN.js +1 -0
- package/dist/chunk-SJ5OJ677.js +1 -0
- package/dist/chunk-SMKCBUJL.js +1 -0
- package/dist/chunk-SX7TUC3V.js +1 -0
- package/dist/chunk-TSA6GHUG.js +1 -0
- package/dist/chunk-U5TL63CG.js +1 -0
- package/dist/chunk-VSLJZ7GH.js +1 -0
- package/dist/chunk-VWGKUQ3C.js +1 -0
- package/dist/chunk-W357WDNU.js +1 -0
- package/dist/chunk-WNBEOK5Q.js +1 -0
- package/dist/chunk-Y5GRT27C.js +3 -0
- package/dist/chunk-ZVD6VHM2.js +1 -0
- package/dist/client/index.cjs +1 -357
- package/dist/client/index.d.cts +6 -37
- package/dist/client/index.d.ts +6 -37
- package/dist/client/index.js +1 -15
- package/dist/clip-inspect-DLJXVKV6.js +1 -0
- package/dist/core/index.cjs +1 -1634
- package/dist/core/index.d.cts +5 -4
- package/dist/core/index.d.ts +5 -4
- package/dist/core/index.js +1 -139
- package/dist/core/ocr/worker.bundle.js +41 -0
- package/dist/core/ocr/worker.cjs +41 -0
- package/dist/core/ocr/worker.d.cts +97 -0
- package/dist/core/ocr/worker.d.ts +97 -0
- package/dist/core/ocr/worker.js +40 -0
- package/dist/core/v3/detect-worker.cjs +1 -392
- package/dist/core/v3/detect-worker.d.cts +1 -1
- package/dist/core/v3/detect-worker.d.ts +1 -1
- package/dist/core/v3/detect-worker.js +1 -13
- package/dist/create-document-capture-4ZOSBL3Y.js +1 -0
- package/dist/create-portrait-capture-5VGYZUOK.js +1 -0
- package/dist/create-verification-B8c9xBnz.d.ts +3871 -0
- package/dist/create-verification-BadlGBh3.d.cts +3871 -0
- package/dist/{detect-worker-CKXHlXx9.d.ts → detect-worker-CHqsPJoM.d.cts} +25 -2
- package/dist/{detect-worker-CKXHlXx9.d.cts → detect-worker-CHqsPJoM.d.ts} +25 -2
- package/dist/detector-scanic-P2RTEQUV.js +1 -0
- package/dist/icao-gate-BqXxEAq6.d.cts +610 -0
- package/dist/icao-gate-C7D7Lce7.d.ts +610 -0
- package/dist/icao-gate-T3BTOKFJ.js +1 -0
- package/dist/icao-policy-Bo7TQyTd.d.ts +80 -0
- package/dist/icao-policy-CgSI4oFo.d.cts +80 -0
- package/dist/icao-tuning-4ETMF53W.js +1 -0
- package/dist/index.cjs +3 -2698
- package/dist/index.d.cts +138 -5
- package/dist/index.d.ts +138 -5
- package/dist/index.js +1 -28
- package/dist/internal/index.cjs +3 -4228
- package/dist/internal/index.d.cts +306 -371
- package/dist/internal/index.d.ts +306 -371
- package/dist/internal/index.js +1 -647
- package/dist/keyframe-rank-YAJLYJYF.js +1 -0
- package/dist/landmarker-KB7LVXAU.js +1 -0
- package/dist/mrz-band-VYHOTDHY.js +1 -0
- package/dist/plan-runner-3BLEJWHF.js +1 -0
- package/dist/popup/index.cjs +1 -76
- package/dist/popup/index.d.cts +9 -3
- package/dist/popup/index.d.ts +9 -3
- package/dist/popup/index.js +1 -11
- package/dist/print-DCYX3CZD.js +1 -0
- package/dist/scanic-ml-stub-KW7IZHUT.js +1 -0
- package/dist/segmenter-USLNBX65.js +1 -0
- package/dist/types-BAAj6TOZ.d.cts +2230 -0
- package/dist/types-BAAj6TOZ.d.ts +2230 -0
- package/dist/upload-file-EGXXM6TQ.js +1 -0
- package/package.json +30 -11
- package/sbom.cdx.json +349 -0
- package/dist/capture-constraints-BujkZcfb.d.cts +0 -21
- package/dist/capture-constraints-BujkZcfb.d.ts +0 -21
- package/dist/chunk-EWRNPKTR.js +0 -1123
- package/dist/chunk-EWRNPKTR.js.map +0 -1
- package/dist/chunk-MWNFSNMP.js +0 -52
- package/dist/chunk-MWNFSNMP.js.map +0 -1
- package/dist/chunk-NILNKLK6.js +0 -50
- package/dist/chunk-NILNKLK6.js.map +0 -1
- package/dist/chunk-NWF46H7K.js +0 -359
- package/dist/chunk-NWF46H7K.js.map +0 -1
- package/dist/chunk-TBANUT3X.js +0 -885
- package/dist/chunk-TBANUT3X.js.map +0 -1
- package/dist/chunk-WY6U7AIK.js +0 -193
- package/dist/chunk-WY6U7AIK.js.map +0 -1
- package/dist/chunk-YVFF4Q4G.js +0 -327
- package/dist/chunk-YVFF4Q4G.js.map +0 -1
- package/dist/client/index.cjs.map +0 -1
- package/dist/client/index.js.map +0 -1
- package/dist/core/index.cjs.map +0 -1
- package/dist/core/index.js.map +0 -1
- package/dist/core/v3/detect-worker.cjs.map +0 -1
- package/dist/core/v3/detect-worker.js.map +0 -1
- package/dist/create-verification-Ce1y5kJR.d.ts +0 -371
- package/dist/create-verification-Dkb2tXuY.d.cts +0 -371
- package/dist/detector-scanic-4C6IEW2K.js +0 -787
- package/dist/detector-scanic-4C6IEW2K.js.map +0 -1
- package/dist/hosted-client-DWzCRYJK.d.cts +0 -421
- package/dist/hosted-client-DWzCRYJK.d.ts +0 -421
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/internal/index.cjs.map +0 -1
- package/dist/internal/index.js.map +0 -1
- package/dist/popup/index.cjs.map +0 -1
- package/dist/popup/index.js.map +0 -1
- package/dist/scanic-ml-stub-S2OZ6HEF.js +0 -10
- package/dist/scanic-ml-stub-S2OZ6HEF.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as se,b as oe}from"./chunk-SX7TUC3V.js";import{b as J,c as ee}from"./chunk-W357WDNU.js";import{b as pe,c as he,d as me}from"./chunk-POIQGEZM.js";import{a as Z,c as Q,e as Y,g as j,h as R,k,m as $,n as re}from"./chunk-CPUECYAJ.js";import{b as x,c as fe,d as G,e as ve}from"./chunk-FPXL63KZ.js";import{c as ie,d as ne,e as ae}from"./chunk-U5TL63CG.js";import{a as W,c as q,d as z,e as X}from"./chunk-TSA6GHUG.js";import{d as te}from"./chunk-22AW4NJD.js";import{e as le,f as ce,h as P,j as ue,l as de}from"./chunk-FSSMUAKC.js";var Oe=[...Z.filter(n=>n.startsWith("video/mp4")),"video/webm;codecs=h264","video/webm;codecs=avc1","video/webm;codecs=vp8","video/webm;codecs=vp9","video/webm"],ge=new Set;function Pe(n){let e=/(?:Chrome|Chromium)\/(\d+)\./.exec(n??"");return e?Number(e[1]):null}function be(n=xe(),e=globalThis.navigator?.userAgent){if(n===void 0)return"";let t=Pe(e)===126;for(let r of Oe)if(!(ge.has(r)||t&&r.startsWith("video/mp4")))try{if(n(r))return r}catch{}return""}function L(n){n!==""&&ge.add(n)}function ye(n){return n.replace(/^video\/x-matroska/i,"video/webm")}function lt(n){let e=/codecs=["']?([^,;"']+)/i.exec(n);return e?e[1].trim():n.split(";")[0].trim()}function xe(){let n=globalThis.MediaRecorder;return n&&typeof n.isTypeSupported=="function"?e=>n.isTypeSupported(e):void 0}var V=2500,Ge=1e3,Le=1500,Te=25e5,Fe=100,Ve=700,Ne=20,Ue=1500,F=null;function He(){return F??(F=import("./clip-inspect-DLJXVKV6.js").catch(n=>{throw F=null,n})),F.catch(()=>null)}var T=class extends Error{constructor(e,t){super(t??e),this.kind=e}},Ke=100;function N(n,e){return n.stats===void 0?!1:n.stats===null?!0:n.stats.durationMs<e-Ke}function Ee(n,e){return n.stats?e.stats?n.stats.durationMs>e.stats.durationMs:!0:!1}var A=class{constructor(e={}){this.recorder=null;this.stream=null;this.chunks=[];this.bytes=0;this.hardStopTimer=null;this.graceTimer=null;this.pollTimer=null;this.settled=!1;this.now=e.now??(()=>globalThis.performance?.now?.()??Date.now())}clearTimers(){this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.graceTimer&&clearTimeout(this.graceTimer),this.pollTimer&&clearInterval(this.pollTimer),this.hardStopTimer=null,this.graceTimer=null,this.pollTimer=null}record(e,t,r,i=V,a){let s=be(),o=He();return this.recordRaw(e,t,r,i,a,s).then(c=>Be(c,o),c=>{throw c instanceof T&&(c.requestedMimeType=s),c})}recordRaw(e,t,r,i,a,s){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((o,c)=>{let l;try{l=new MediaRecorder(e,s?{mimeType:s,videoBitsPerSecond:Te}:{videoBitsPerSecond:Te})}catch{try{l=new MediaRecorder(e)}catch{c(new T("unsupported"));return}}this.recorder=l;let d=h=>{this.settled||(this.settled=!0,this.clearTimers(),h())},u=()=>d(()=>{let h=ye(l.mimeType||s||Q),b=new Blob(this.chunks,{type:h});if(b.size===0){c(new T("generic","empty clip"));return}if(R(b)){c(new T("cliptoolarge"));return}o({blob:b,mimeType:h,requestedMimeType:s})});l.ondataavailable=h=>{h.data&&h.data.size&&(this.chunks.push(h.data),this.bytes+=h.data.size,this.bytes>j&&d(()=>{try{l.state!=="inactive"&&l.stop()}catch{}c(new T("cliptoolarge"))}))},l.onstop=u,l.onerror=()=>d(()=>c(new T("generic")));let p=this.now();if(r!==void 0||a!==void 0){let h=!1;l.onstart=()=>{if(!(h||this.settled)&&(h=!0,p=this.now(),r!==void 0))try{r()}catch{}}}try{l.start(Ge)}catch{d(()=>c(new T("generic")));return}let m=()=>{if(this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=null,this.settled||t?.(),l.state!=="inactive"){try{l.stop()}catch{u()}this.graceTimer=setTimeout(u,Le)}else u()},f=this.now();if(a===void 0){this.hardStopTimer=setTimeout(m,i);return}let g=null,M=!1;this.hardStopTimer=setTimeout(m,i+Ve),this.pollTimer=setInterval(()=>{if(this.settled||M)return;let h=null;try{h=a.latest()}catch{h=null}let b=h?.presentationTimeMs;b!==void 0&&Number.isFinite(b)&&b>=p&&g===null&&(g=b);let S=g!==null&&b!==void 0&&b-g>=i,I=g===null&&this.now()-f>=i;if(!(!S&&!I)){if(M=!0,this.pollTimer&&clearInterval(this.pollTimer),this.pollTimer=null,I){m();return}this.hardStopTimer&&clearTimeout(this.hardStopTimer),this.hardStopTimer=setTimeout(m,Fe)}},Ne)}))}stop(e){this.clearTimers();let t=this.recorder;if(t&&t.state!=="inactive")try{t.stop()}catch{}this.recorder=null,(e??this.stream)?.getTracks().forEach(i=>i.stop()),this.stream=null}};async function Be(n,e){let t,r=new Promise(l=>{t=setTimeout(()=>l(null),Ue)}),i=await Promise.race([e,r]);if(clearTimeout(t),i===null)return n;let a;try{a=await i.blobBytes(n.blob)}catch{return{...n,stats:null}}let s=i.inspectClipBytes(a);if(s?.container!=="webm")return{...n,stats:s};let o=i.withWebmDuration(a,s.durationMs);if(o===null)return{...n,stats:s};let c=i.inspectClipBytes(o);return c===null||c.frames!==s.frames||c.durationMs!==s.durationMs?{...n,stats:s}:{...n,blob:new Blob([o],{type:n.blob.type}),stats:s}}function Me(n,e,t=.92){return new Promise((r,i)=>{let a=n.videoWidth,s=n.videoHeight;if(!a||!s){i(new Error("video-not-ready"));return}let o=e.getContext("2d");if(!o){i(new Error("no-2d-context"));return}e.width=a,e.height=s,o.scale(-1,1),o.drawImage(n,-a,0),e.toBlob(c=>c?r(c):i(new Error("empty-keyframe")),"image/jpeg",t)})}var D=class{constructor(e){this.timer=null;this.frameCallbackId=null;this.running=!1;this.busy=!1;this.lastRunAt=Number.NEGATIVE_INFINITY;this.degradeCount=0;this.durations=[];this.options=e,this.periodMs=1e3/e.cadenceHz}start(){if(this.running)return;this.running=!0;let e=this.options.video;if(typeof e?.requestVideoFrameCallback=="function"){let t=()=>{this.running&&(this.frameCallbackId=e.requestVideoFrameCallback?.(()=>{this.frameCallbackId=null,this.now()-this.lastRunAt>=this.periodMs&&this.tick(),t()}))};t();return}this.timer=setInterval(()=>this.tick(),this.periodMs)}stop(){this.running=!1,this.timer!==null&&(clearInterval(this.timer),this.timer=null),this.frameCallbackId!==null&&(this.options.video?.cancelVideoFrameCallback?.(this.frameCallbackId),this.frameCallbackId=null)}stats(){let e=this.durations.length===0?0:this.durations.reduce((t,r)=>t+r,0)/this.durations.length;return{degradeCount:this.degradeCount,meanDetectMs:e}}now(){return this.options.now?.()??performance.now()}tick(){if(!this.running)return;if(this.busy){this.degradeCount+=1;return}this.busy=!0,this.lastRunAt=this.now();let e=this.now();this.options.run().catch(()=>{}).finally(()=>{this.busy=!1,this.durations.push(this.now()-e),this.durations.length>20&&this.durations.shift()})}};var We=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}),C=n=>Math.min(1,Math.max(0,n)),_=class{constructor(e={}){this.p=0;this.lastTickAt=null;this.lastCenter=null;this.velocityEma=0;this.qWindow=[];this.lastSizeDirection="ideal";this.t={...We,...e}}reset(){this.p=0,this.lastTickAt=null,this.lastCenter=null,this.velocityEma=0,this.qWindow=[],this.lastSizeDirection="ideal"}tick(e){let{observation:t,quality:r,timestampMs:i}=e,a=this.lastTickAt===null?0:Math.max(0,(i-this.lastTickAt)/1e3);this.lastTickAt=i;let s={presence:0,single:1,centering:0,size:0,pose:0,sharpness:C(r.sharpness),exposure:C(r.exposure),motion:1};if(t!==null){s.presence=1,s.single=(t.extraFaces??0)>0?0:1;let d=this.geometryOf(t,e);s.centering=d.centering,s.size=d.size,s.pose=d.pose,s.motion=this.motionOf(d.center,d.iod,i)}else this.lastCenter=null,this.velocityEma=0;let o=Math.min(s.presence,s.single,s.centering,s.size,s.pose,s.sharpness,s.exposure,s.motion);this.p=C(this.p+(o>=this.t.Q_GOOD?this.t.RISE_PER_S*o:-this.t.FALL_PER_S*(1-o))*a),this.qWindow.push({at:i,q:o}),this.qWindow=this.qWindow.filter(d=>d.at>=i-this.t.READY_WINDOW_MS);let c=this.qWindow.map(d=>d.q);if(c.length>=3){let d=Math.min(...c),u=c.indexOf(d);c=c.filter((p,m)=>m!==u)}let l=this.p>=1&&c.every(d=>d>=this.t.Q_GOOD);return{at:i,q:o,p:this.p,factors:s,guidanceKey:this.guidanceOf(s,r,o),ready:l,accepted:o>=this.t.Q_GOOD}}geometryOf(e,t){let{box:r,eyes:i}=e,a={x:t.frameWidth/2,y:t.frameHeight/2},s=Math.min(t.frameWidth,t.frameHeight),o=i!==void 0?{x:(i.left.x+i.right.x)/2,y:(i.left.y+i.right.y)/2}:{x:r.x+r.width/2,y:r.y+r.height/2-this.t.BOX_EYE_OFFSET_FACTOR*r.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*r.width,l=Math.hypot(o.x-a.x,o.y-a.y),d=c<=0?0:1-C(l/(this.t.CENTER_FALLOFF_IOD_MULTIPLE*c)),u=s>0?c/s:0;this.lastSizeDirection=u<this.t.SIZE_IDEAL_MIN?"far":u>this.t.SIZE_IDEAL_MAX?"close":"ideal";let p;u<this.t.SIZE_HARD_MIN||u>this.t.SIZE_HARD_MAX?p=0:u<this.t.SIZE_IDEAL_MIN?p=(u-this.t.SIZE_HARD_MIN)/(this.t.SIZE_IDEAL_MIN-this.t.SIZE_HARD_MIN):u>this.t.SIZE_IDEAL_MAX?p=(this.t.SIZE_HARD_MAX-u)/(this.t.SIZE_HARD_MAX-this.t.SIZE_IDEAL_MAX):p=1;let m=1;if(i!==void 0){let f=Math.abs(Math.atan2(i.right.y-i.left.y,i.right.x-i.left.x))*180/Math.PI;m=1-C(f/this.t.ROLL_MAX_DEG)}return{center:o,iod:c,centering:d,size:p,pose:m}}motionOf(e,t,r){let i=this.lastCenter;if(this.lastCenter={...e,at:r},i===null||t<=0)return 1;let a=(r-i.at)/1e3;if(a<=0)return 1;let s=Math.hypot(e.x-i.x,e.y-i.y)/t/a;s<=this.t.MOTION_DEADBAND_IOD_PER_S&&(s=0);let o=1-Math.exp(-a/this.t.MOTION_TAU_S);return this.velocityEma=o*s+(1-o)*this.velocityEma,1-C(this.velocityEma/this.t.MOTION_VELOCITY_IOD_PER_S)}guidanceOf(e,t,r){if(e.presence<=0)return"fcv3.no_face";if(e.single<=0)return"fcv3.one_face";if(e.size<this.t.GUIDE_SIZE)return this.sizeGuidance();if(e.centering<this.t.GUIDE_CENTERING)return"fcv3.center_face";if(e.pose<this.t.GUIDE_POSE)return"fcv3.straighten";if(e.exposure<this.t.GUIDE_EXPOSURE)return this.exposureGuidance(t);if(e.sharpness<this.t.GUIDE_SHARPNESS)return"fcv3.steady_camera";if(e.motion<this.t.GUIDE_MOTION)return"fcv3.hold_still";if(r<this.t.Q_GOOD){let i=[["size",this.sizeGuidance()],["centering","fcv3.center_face"],["pose","fcv3.straighten"],["exposure",this.exposureGuidance(t)],["sharpness","fcv3.steady_camera"],["motion","fcv3.hold_still"]],a=i[0];for(let s of i)e[s[0]]<e[a[0]]&&(a=s);return a[1]}return"fcv3.hold_still"}sizeGuidance(){return this.lastSizeDirection==="far"?"fcv3.come_closer":"fcv3.move_back"}exposureGuidance(e){let t=(x[0]+x[1])/2;return e.meanLuma<t?"fcv3.more_light":"fcv3.too_bright"}};var qe=["single","size","centering","pose","exposure","sharpness","motion"];function ze(n){if(n.accepted)return null;if(n.factors.presence<=0)return"no_face";let e="single";for(let t of qe)n.factors[t]<n.factors[e]&&(e=t);return e}var w=class{constructor(){this.blocked={};this.acceptedMs=0;this.ticks=0;this.lastAt=null}record(e){let t=this.lastAt===null?0:Math.max(0,e.at-this.lastAt);this.lastAt=e.at,this.ticks+=1;let r=ze(e);if(r===null){this.acceptedMs+=t;return}let i=this.blocked[r]??{count:0,ms:0};i.count+=1,i.ms+=t,this.blocked[r]=i}summary(){let e={};for(let[t,r]of Object.entries(this.blocked))e[t]={count:r.count,ms:Math.round(r.ms)};return{blocked:e,acceptedMs:Math.round(this.acceptedMs),ticks:this.ticks}}};var Xe=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo","fake_device","fake-capture-device"],Ze=[/^(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 Qe(n){let e=(n??"").trim().toLowerCase();return e.length===0?"unknown":Xe.some(t=>e.includes(t))?"known_virtual":Ze.some(t=>t.test(e))?"platform":"unknown"}function Ce(n){if(typeof n!="function")return!1;try{return/\{\s*\[native code\]\s*\}\s*$/.test(Function.prototype.toString.call(n))}catch{return!1}}function Ye(n=globalThis){return Ce(n.navigator?.mediaDevices?.getUserMedia)&&Ce(n.MediaStreamTrack?.prototype?.getSettings)}async function je(n,e=globalThis){let t=e.crypto?.subtle?.digest;if(typeof t=="function")try{let r=new Uint8Array(await t.call(e.crypto?.subtle,"SHA-256",new TextEncoder().encode(n)));return Array.from(r.subarray(0,8),i=>i.toString(16).padStart(2,"0")).join("")}catch{return}}async function Se(n,e=globalThis){let t={};try{t=typeof n.getSettings=="function"?n.getSettings()??{}:{}}catch{t={}}let r={};if((t.facingMode==="user"||t.facingMode==="environment"||t.facingMode==="left"||t.facingMode==="right")&&(r.facingMode=t.facingMode),typeof t.frameRate=="number"&&Number.isFinite(t.frameRate)&&(r.frameRate=t.frameRate),typeof t.width=="number"&&Number.isFinite(t.width)&&(r.width=t.width),typeof t.height=="number"&&Number.isFinite(t.height)&&(r.height=t.height),typeof t.deviceId=="string"&&t.deviceId.length>0){let a=await je(t.deviceId,e);a!==void 0&&(r.deviceIdHash=a)}let i;try{i=n.label}catch{i=void 0}return{trackSettings:r,capabilitiesPresent:typeof n.getCapabilities=="function",labelClass:Qe(i),prototypesIntact:Ye(e)}}var U=n=>Math.round(n*100)/100;function ke(n){let e=n,t=typeof e?.requestVideoFrameCallback=="function",r=null,i=null,a=0,s=0,o=0,c=0,l=0,d=0,u=()=>{!t||e?.requestVideoFrameCallback===void 0||(r=e.requestVideoFrameCallback((p,m)=>{if(r=null,!t)return;let f=m.presentationTime;if(i!==null){let g=f-i.presentationTimeMs;s+=1;let M=g-o;o+=M/s,c+=M*(g-o)}typeof m.captureTime=="number"&&Number.isFinite(m.captureTime)&&(l+=f-m.captureTime,d+=1),a+=1,i={mediaTimeMs:m.mediaTime*1e3,presentationTimeMs:f},u()}))};return u(),{latest:()=>i,stats:()=>({n:a,meanGapMs:s===0?0:U(o),stdGapMs:s<2?0:U(Math.sqrt(c/(s-1))),captureLatencyMs:d===0?null:U(l/d)}),stop:()=>{t&&(t=!1,r!==null&&e?.cancelVideoFrameCallback?.(r),r=null)}}}function _e(n,e,t){return{...n,rvfc:e,rampPainter:t}}var $e=1e3,H="fcv3.hold_upright",Je=200,K=4,et=600,tt=1e3,we={sharpness:1,exposure:1,meanLuma:128};function rt(n,e){return e.width=n.videoWidth,e.height=n.videoHeight,e.getContext("2d").drawImage(n,0,0),new Promise((t,r)=>e.toBlob(i=>i?t(i):r(new Error("empty-keyframe")),"image/jpeg",.92))}function it(){return q()==="phone"}var Ie=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.openEnvironment=null;this.ramp=null;this.snapshotCanvas=null;this.options=e,this.facing=e.facingMode??"user"}get state(){return this.stateValue}on(e,t){let r=this.handlers.get(e);return r||(r=new Set,this.handlers.set(e,r)),r.add(t),()=>r?.delete(t)}emit(e,t){for(let r of[...this.handlers.get(e)??[]])r(t)}async start(e={}){e.facingMode!==void 0&&(this.facing=e.facingMode),this.attempt+=1,await this.run(this.attempt)}get facingMode(){return this.facing}retry(){this.teardownAttempt(),this.start()}switchCamera(){this.facing=this.facing==="user"?"environment":"user",this.teardownAttempt(),this.start()}restart(e){this.facing=e,this.teardownAttempt(),this.start()}destroy(){this.attempt+=1,this.teardownAttempt(),this.detector?.destroy(),this.detector=null,this.options.video.srcObject=null}async run(e){let{options:t}=this;this.fired=!1,this.lastGuidanceKey=null,this.carriedDegrade=0,this.carriedMeans=[],this.cameraRequestedAt=null,this.cameraReadyAt=null,this.faceAcquiredAt=null,this.captureCompleteAt=null,this.uprightGuard=(t.isPhone??it)(),this.setState("preflight");let r=Y();if(r!=="OK"){this.fail(r==="INSECURE_CONTEXT"?"insecure":"unsupported",{phase:"preflight"});return}this.setState("acquiring");let i=t.getUserMedia??(l=>navigator.mediaDevices.getUserMedia(l)),a;this.cameraRequestedAt=this.now();try{let{facingMode:l,...d}=W(z(),this.facing).video;a=await oe(this.facing,d,{getUserMedia:i,enumerateDevices:st(t)})}catch(l){if(e!==this.attempt)return;if(l instanceof se){this.fail("backcamera",{phase:"acquiring",name:k(l)});return}this.fail($(l),{phase:"acquiring",name:k(l)});return}if(te(a),re(a),e!==this.attempt){for(let l of a.getTracks())l.stop();return}this.stream=a;let s=a.getVideoTracks?.()[0];if(this.trackProvenance=s===void 0?null:Se(s).catch(()=>null),this.openEnvironment=s===void 0?null:J(s).catch(()=>({})),this.facing=X(a)??this.facing,t.video.srcObject=a,await t.video.play().catch(()=>{}),e!==this.attempt)return;if(this.cameraReadyAt=this.now(),this.detector===null){let l={v3AssetBaseUrl:t.v3AssetBaseUrl},d=t.createDetector??(t.createWorker!==void 0&&ue()?async()=>{try{return await de.create(t.createWorker(),l)}catch{return P(l)}}:()=>P(l)),u;try{u=await d()}catch(p){e===this.attempt&&this.fail("models",{phase:"models",name:k(p)},p instanceof le?p.fallbackReason:at(p));return}if(e!==this.attempt){u.destroy();return}this.detector=u,this.options.telemetry?.({type:"detector",tier:u.tier,fallbackReason:u.fallbackReason})}let o=pe(),c=t.deviceClass??he(o);this.profiler=new me(c),this.options.telemetry?.({type:"profile",staticClass:c,activeClass:this.profiler.deviceClass,simd:o.simd}),this.gate=new _(t.thresholds??{}),this.blockStats=new w,this.lastGateSnapshotAt=this.now(),t.rankKeyframes?.()&&import("./keyframe-rank-YAJLYJYF.js").then(l=>B=l,()=>{}),this.setState("positioning"),this.positioningStartedAt=this.now(),this.startScheduler(e)}get animations(){return this.profiler?.profile.animations??"full"}startScheduler(e){let t=this.profiler;if(t===null)return;if(this.scheduler!==null){let i=this.scheduler.stats();this.carriedDegrade+=i.degradeCount,i.meanDetectMs>0&&this.carriedMeans.push(i.meanDetectMs),this.scheduler.stop()}let r=new D({cadenceHz:t.profile.cadenceHz,video:this.options.video,now:this.options.now,run:()=>this.detectTick(e)});this.scheduler=r,r.start()}async detectTick(e){let{detector:t,gate:r,profiler:i}=this,a=this.options.video;if(e!==this.attempt||t===null||r===null||i===null||this.fired||a.videoWidth===0)return;if(this.isLandscape()){this.holdUpright(e);return}let s=i.deviceClass,o=this.now(),c=this.options.makeSnapshot?.(a,i.profile.inputWidth)??this.defaultSnapshot(a,i.profile.inputWidth),l=null;try{l=await t.detect(c,a.videoWidth,a.videoHeight)}catch{l=null}if(e!==this.attempt||this.fired)return;i.record(this.now()-o),i.deviceClass!==s&&this.startScheduler(e);let d=l===null?we:this.options.measureQuality?.(a,l.box)??this.defaultQuality(a,l.box),u=r.tick({timestampMs:this.now(),observation:l,quality:d,frameWidth:a.videoWidth,frameHeight:a.videoHeight});u.accepted&&this.faceAcquiredAt===null&&(this.faceAcquiredAt=u.at),this.blockStats?.record(u),!u.ready&&u.at-this.lastGateSnapshotAt>=$e&&(this.lastGateSnapshotAt=u.at,this.reportGate(!1)),this.emit("checks",{engine:"v3",progress:u.p,q:u.q,factors:u.factors,attempt:e}),u.guidanceKey!==this.lastGuidanceKey&&(this.lastGuidanceKey=u.guidanceKey,this.emit("guidance",{key:u.guidanceKey})),u.ready&&this.stateValue==="positioning"&&(this.fired=!0,this.captureCompleteAt=u.at,this.fire(e))}async fire(e){let{options:t}=this,r=this.scheduler;r?.stop(),this.reportGate(!0);let i=r?.stats()??{degradeCount:0,meanDetectMs:0},a=[...this.carriedMeans,...i.meanDetectMs>0?[i.meanDetectMs]:[]];t.telemetry?.({type:"fired",timeToGateMs:this.now()-this.positioningStartedAt,degradeCount:this.carriedDegrade+i.degradeCount,meanDetectMs:a.length===0?0:a.reduce((y,v)=>y+v,0)/a.length});let s=t.mode??"clip",o=t.rankKeyframes?.()&&B?B.default(this,e).catch(()=>this.collectKeyframes(e)):this.collectKeyframes(e);if(s==="photo"){let y=this.watchRotation(e,null),v=await o;if(y(),e!==this.attempt)return;if(v===null){this.fail("generic",{phase:"keyframes"});return}let O=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,...O});return}this.setState("recording");let c=this.stream;if(c===null){this.fail("generic",{phase:"recording"});return}let l=t.screenRamp?.(),d=ie(l),u=null;o.then(y=>{u=y},()=>{});let p=()=>{e===this.attempt&&u!==null&&this.emit("frozen",{previewDataUrl:u.previewDataUrl})},m=ne(l,V),f=null,g,M=0;try{let y=this.recordTake(e,c,l,m,void 0).then(E=>E,E=>({failed:E})),[v,O]=await Promise.all([y,o]);if(g=O,e!==this.attempt)return;if("failed"in v){if(v.failed.kind==="cliptoolarge")throw v.failed;L(v.failed.requestedMimeType??"")}else f=v,N(v.clip,m)?v.clip.stats===null&&L(v.clip.requestedMimeType??""):p();if(f===null||N(f.clip,m)){M=1,t.telemetry?.({type:"clip_retake",reason:f===null?"error":f.clip.stats===null?"unreadable":"short"});let E=null;try{E=await this.recordTake(e,c,l,m,p)}catch(De){if(f===null)throw De}if(e!==this.attempt)return;E!==null&&(f===null||Ee(E.clip,f.clip))&&(f=E),E===null&&p()}}catch(y){if(e!==this.attempt)return;let v=y.kind;this.fail(v==="cliptoolarge"?"cliptoolarge":"recorder",{phase:"recording",name:k(y)});return}if(f===null){this.fail("recorder",{phase:"recording"});return}let{clip:h,rvfc:b,report:S,watched:I}=f;if(R(h.blob)){this.fail("cliptoolarge",{phase:"recording"});return}if(g===null){this.fail("generic",{phase:"keyframes"});return}let Ae=await this.provenance(b,d,I);e===this.attempt&&this.finishCapture({clip:h.blob,clipMimeType:h.mimeType,...h.stats?{clipStats:h.stats}:{},clipRetakes:M,keyframe:g.blob,previewDataUrl:g.previewDataUrl,...S!==void 0&&S.rendered.length>0?{screenRamp:S}:{},...Ae})}async recordTake(e,t,r,i,a){let s=this.options.createRecorder?.()??new A({now:()=>this.now()}),o=ke(this.options.video),c=ae(r,{paint:p=>{(p===null||e===this.attempt)&&this.emit("ramp",{colour:p})},now:()=>this.now(),frames:o.latest});this.ramp=c;let l=()=>{o.stop(),c.stop(),this.ramp===c&&(this.ramp=null)},d=this.watchRotation(e,s),u=ee();try{return{clip:await s.record(t,a,()=>c.started(this.now()),i,o),rvfc:o.stats(),report:c.report(),watched:u.stop()}}finally{u.stop(),d(),l()}}async provenance(e,t,r={}){let i=this.trackProvenance;if(i===null)return{};let a,s=new Promise(d=>{a=setTimeout(()=>d(null),tt)}),o=await Promise.race([i,s]),c=o===null?null:await Promise.race([this.openEnvironment,s]);if(clearTimeout(a),o===null)return{};let l={...c,...r};return{provenance:{..._e(o,e,t),...Object.keys(l).length>0?{env:l}:{}}}}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!==H&&(this.lastGuidanceKey=H,this.emit("guidance",{key:H}))}watchRotation(e,t){if(!this.uprightGuard)return()=>{};let r=this.options.video,i=()=>{if(e!==this.attempt||t!==null&&this.stateValue!=="recording"){o();return}r.videoWidth>0&&this.isLandscape()&&(o(),this.abortRecording(e,t))},a=setInterval(i,Je);r.addEventListener?.("resize",i);let s=!1;function o(){s||(s=!0,clearInterval(a),r.removeEventListener?.("resize",i))}return o}abortRecording(e,t){if(e!==this.attempt)return;this.attempt+=1;let r=this.attempt;try{t?.stop()}catch{}this.ramp?.stop(),this.ramp=null,this.fired=!1,this.captureCompleteAt=null,this.gate=new _(this.options.thresholds??{}),this.blockStats=new w,this.lastGateSnapshotAt=this.now(),this.lastGuidanceKey=null,this.setState("positioning"),this.positioningStartedAt=this.now(),this.holdUpright(r),this.startScheduler(r)}async collectKeyframes(e){let t=this.options.captureKeyframe??(a=>this.defaultKeyframe(a)),r=et/(K-1),i=null;for(let a=0;a<K;a+=1){if(e!==this.attempt)return i;try{let s=await t(this.options.video);(i===null||s.sharpness>i.sharpness)&&(i=s)}catch{}a<K-1&&await nt(r)}return i}finishCapture(e){this.stopTracks(),this.setState("captured");let t=this.captureTiming();this.emit("artifacts",t===void 0?e:{...e,timing:t})}captureTiming(){let e={},t=(r,i,a)=>{i!==null&&a!==null&&(e[r]=Math.max(0,Math.round(a-i)))};return t("cameraReadyMs",this.cameraRequestedAt,this.cameraReadyAt),t("faceAcquireMs",this.cameraReadyAt,this.faceAcquiredAt),t("captureMs",this.faceAcquiredAt,this.captureCompleteAt),Object.keys(e).length>0?e:void 0}async defaultKeyframe(e){let t=document.createElement("canvas"),r=await(this.facing==="user"?Me:rt)(e,t),i=t.toDataURL("image/jpeg",.92);return{blob:r,previewDataUrl:i,sharpness:this.centerSharpness(e)}}defaultSnapshot(e,t){try{let r=this.snapshotCanvas??document.createElement("canvas"),i=t/Math.max(1,e.videoWidth),a=Math.max(1,Math.round(e.videoWidth*i)),s=Math.max(1,Math.round(e.videoHeight*i)),o=r.getContext("2d");return o===null?e:(r.width!==a&&(r.width=a),r.height!==s&&(r.height=s),o.drawImage(e,0,0,a,s),this.snapshotCanvas=r,r)}catch{return e}}defaultQuality(e,t){let r=Re(e,t,96);return r===null?we:{sharpness:G(r),exposure:ve(r),meanLuma:fe(r)}}centerSharpness(e){let t=ce(e),r=Re(e,{x:t.width*.25,y:t.height*.25,width:t.width*.5,height:t.height*.5},96);return r===null?0:G(r)}teardownAttempt(){this.scheduler?.stop(),this.scheduler=null,this.reportGate(!0),this.gate=null,this.ramp?.stop(),this.ramp=null,this.stopTracks()}reportGate(e){let t=this.blockStats,r=this.profiler;if(t===null||r===null)return;let i=t.summary();e&&(this.blockStats=null),i.ticks!==0&&this.options.telemetry?.({type:"gate",final:e,activeClass:r.deviceClass,cadenceHz:r.profile.cadenceHz,...i})}stopTracks(){if(this.stream!==null){for(let e of this.stream.getTracks())e.stop();this.stream=null}}fail(e,t,r){this.scheduler?.stop(),this.reportGate(!0),this.stopTracks(),this.setState("error"),this.options.telemetry?.({type:"error",kind:e,fallbackReason:r});let{phase:i,name:a}=t;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()}},B;function nt(n){return new Promise(e=>setTimeout(e,n))}function at(n){return n instanceof Error?n.message:String(n)}function Re(n,e,t){try{let r=document.createElement("canvas"),i=t/Math.max(1,e.width);r.width=Math.max(1,Math.round(e.width*i)),r.height=Math.max(1,Math.round(e.height*i));let a=r.getContext("2d");return a===null?null:(a.drawImage(n,e.x,e.y,e.width,e.height,0,0,r.width,r.height),a.getImageData(0,0,r.width,r.height))}catch{return null}}function st(n){if(n.enumerateDevices!==void 0)return n.enumerateDevices;if(n.getUserMedia===void 0&&!(typeof navigator>"u"||typeof navigator.mediaDevices?.enumerateDevices!="function"))return()=>navigator.mediaDevices.enumerateDevices()}export{lt as a,V as b,Ge as c,Le as d,Te as e,Fe as f,Ve as g,Ne as h,Ue as i,T as j,Ke as k,N as l,Ee as m,A as n,Me as o,D as p,We as q,_ as r,ze as s,w as t,$e as u,H as v,Je as w,K as x,et as y,tt as z,Ie as A};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var l=["session.verified","session.not_verified","session.review_pending","session.cancelled"],u=new Set([0,1,2,3]),E="sekyro-verify",a="width=480,height=720,noopener=false",f=new Set(l);function y(e){if(e===null||typeof e!="object")return!1;let n=e;return n.source==="sekyro"&&n.version===1&&typeof n.sessionId=="string"&&typeof n.event=="string"&&f.has(n.event)}function S(e){let n=new URL(e.hostedUrl).origin,t=window.open(e.hostedUrl,E,a);if(!t)return{error:"popup_blocked"};let r=o=>{if(o.source!==t||o.origin!==n||!y(o.data))return;let{source:p,version:d,event:c,sessionId:v,level:s}=o.data,i={source:p,version:d,event:c,sessionId:v};u.has(s)&&(i.level=s),e.onEvent(i)};return window.addEventListener("message",r),{close(){window.removeEventListener("message",r),t.close()}}}function k(e,n){return n.mode==="redirect"?(window.location.assign(e),{close(){}}):S({hostedUrl:e,onEvent:n.onEvent??(()=>{})})}export{l as a,S as b,k as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var K={enabled:!0,hz:3,segmenterTimeoutMs:8e3,segmenterBudgetMs:120,maskThreshold:.5,maxColorStd:28,maxEdgeDensity:.08,edgeLuma:24,maxGradient:.18,minPixels:300,timeoutMs:4e3},V=12e3,b=(n,o,t)=>Math.min(t,Math.max(o,Math.round(n)));function W(n,o,t){let{x:r,y:m,width:a,height:u}=n;if(t)return[{x:r-1.5*a,y:m-.8*u,width:4*a,height:2.8*u}];let d=m-.4*u,p=1.4*u;return[{x:r-.9*a,y:d,width:.75*a,height:p},{x:r+1.15*a,y:d,width:.75*a,height:p}].map(h=>{let M=Math.max(0,h.x),l=Math.min(o.width,h.x+h.width);return{x:M,y:h.y,width:Math.max(0,l-M),height:h.height}})}function Z(n,o,t,r=K){let m=t!==null&&t.width>0&&t.height>0,a=W(o,n,m),u=a.reduce((e,s)=>e+Math.max(0,s.width)*Math.max(0,s.height),0);if(u<=0)return null;let d=Math.max(1,Math.floor(Math.sqrt(u/V))),p=m?t.data instanceof Float32Array?1:1/255:1,h=(e,s)=>{if(!m)return!1;let w=b(e/n.width*t.width-.5,0,t.width-1),C=b(s/n.height*t.height-.5,0,t.height-1);return t.data[C*t.width+w]*p>=r.maskThreshold},M=e=>.299*n.data[e]+.587*n.data[e+1]+.114*n.data[e+2],l=0,B=[0,0,0],S=[0,0,0],k=0,T=0,D=0,_=0,P=0,A=0,E=0,L=0,F=0,G=0,O=Math.min(...a.map(e=>e.x)),j=Math.max(...a.map(e=>e.x+e.width)),H=Math.min(...a.map(e=>e.y)),I=Math.max(...a.map(e=>e.y+e.height)),J=(O+j)/2,Q=(H+I)/2;for(let e of a){let s=b(e.x,0,n.width),w=b(e.x+e.width,0,n.width),C=b(e.y,0,n.height),q=b(e.y+e.height,0,n.height);for(let c=C;c<q;c+=d)for(let g=s;g<w;g+=d){if(h(g,c))continue;let Y=(c*n.width+g)*4;for(let i=0;i<3;i+=1){let x=n.data[Y+i];B[i]=B[i]+x,S[i]=S[i]+x*x}l+=1;let y=M(Y);g<J?(D+=y,_+=1):(P+=y,A+=1),c<Q?(E+=y,L+=1):(F+=y,G+=1);for(let[i,x]of[[g+d,c],[g,c+d]])i>=w||x>=q||h(i,x)||(k+=1,Math.abs(M((x*n.width+i)*4)-y)>r.edgeLuma&&(T+=1))}}if(l<r.minPixels)return null;let U=0;for(let e=0;e<3;e+=1){let s=B[e]/l;U+=Math.max(0,S[e]/l-s*s)}let N=Math.sqrt(U/3),z=k===0?0:T/k,f=(e,s)=>s===0?null:e/s,R=(e,s)=>e===null||s===null?0:Math.abs(e-s)/255,X=Math.max(R(f(D,_),f(P,A)),R(f(E,L),f(F,G)));return{method:m?"segmenter":"strip",uniform:N<=r.maxColorStd&&z<=r.maxEdgeDensity&&X<=r.maxGradient,colorStd:Math.round(N*10)/10,edgeDensity:Math.round(z*1e3)/1e3,gradient:Math.round(X*1e3)/1e3,pixels:l}}function $(n){let o=n!==null&&typeof n=="object"?n:{},t=K,r=(m,a,u,d)=>typeof m=="number"&&Number.isFinite(m)&&m>=u&&m<=d?m:a;return{enabled:typeof o.enabled=="boolean"?o.enabled:t.enabled,hz:r(o.hz,t.hz,.5,15),segmenterTimeoutMs:r(o.segmenterTimeoutMs,t.segmenterTimeoutMs,0,6e4),segmenterBudgetMs:r(o.segmenterBudgetMs,t.segmenterBudgetMs,1,2e3),maskThreshold:r(o.maskThreshold,t.maskThreshold,0,1),maxColorStd:r(o.maxColorStd,t.maxColorStd,0,255),maxEdgeDensity:r(o.maxEdgeDensity,t.maxEdgeDensity,0,1),edgeLuma:r(o.edgeLuma,t.edgeLuma,0,255),maxGradient:r(o.maxGradient,t.maxGradient,0,1),minPixels:r(o.minPixels,t.minPixels,1,1e6),timeoutMs:r(o.timeoutMs,t.timeoutMs,0,6e4)}}export{K as a,Z as b,$ as c};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var n="sekyro-mrz-1";function e(r){return Array.from(new Uint8Array(r),t=>t.toString(16).padStart(2,"0")).join("")}async function o(r){return e(await crypto.subtle.digest("SHA-256",r))}function i(r,t){return o(new TextEncoder().encode(`${n}\0${r}\0${t.join(`
|
|
2
|
+
`)}`))}export{o as a,i as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as qt,h as $t,k as ee}from"./chunk-MQHTFHSN.js";import{b as te}from"./chunk-SMKCBUJL.js";import{a as et,b as ie,c as oe,e as mt,f as ne}from"./chunk-3WQJI7UL.js";import{c as Zt,d as Jt}from"./chunk-BRLQIJYF.js";import{b as Xt,c as jt}from"./chunk-POIQGEZM.js";import{k as Bt,m as Ut,n as Ht,o as Kt,p as Vt,r as ut}from"./chunk-CPUECYAJ.js";import{b as ht,c as dt,d as j,e as Yt}from"./chunk-FPXL63KZ.js";import{d as Wt}from"./chunk-22AW4NJD.js";var it=Object.freeze({sensing:{key:"sensing",reticle:"searching",minDurationMs:900},too_far:{key:"too_far",reticle:"coaching",minDurationMs:1400},too_close:{key:"too_close",reticle:"coaching",minDurationMs:1400},edge_clipped:{key:"edge_clipped",reticle:"coaching",minDurationMs:1400},wrong_shape:{key:"wrong_shape",reticle:"coaching",minDurationMs:1400},tilted:{key:"tilted",reticle:"coaching",minDurationMs:1400},too_dark:{key:"too_dark",reticle:"coaching",minDurationMs:1400},too_bright:{key:"too_bright",reticle:"coaching",minDurationMs:1400},blurry:{key:"blurry",reticle:"coaching",minDurationMs:1400},focus_far:{key:"focus_far",reticle:"coaching",minDurationMs:1600},glare:{key:"glare",reticle:"coaching",minDurationMs:1400},hold_still:{key:"hold_still",reticle:"locking",minDurationMs:900},processing:{key:"processing",reticle:"processing",minDurationMs:800},side_captured:{key:"side_captured",reticle:"flip",minDurationMs:2600},captured:{key:"captured",reticle:"done",minDurationMs:800}});function se(i){return i.framing==="no_document"?"sensing":i.framing==="too_far"?"too_far":i.framing==="too_close"?"too_close":i.framing==="edge_clipped"?"edge_clipped":i.framing==="wrong_shape"?"wrong_shape":i.framing==="tilted"?"tilted":i.lighting==="too_dark"?"too_dark":i.lighting==="too_bright"?"too_bright":i.glare==="glare"?"glare":i.blur==="blurry"?"blurry":"hold_still"}var ot=class{constructor(t=2600,e=.35){this.windowMs=t;this.decayPerSecond=e;this.votes=[];this.current=it.sensing;this.currentSinceMs=null}reset(){this.votes=[],this.current=it.sensing,this.currentSinceMs=null}force(t,e){return this.votes=[],this.current=it[t],this.currentSinceMs=e,this.current}tick(t,e){if(this.currentSinceMs===null&&(this.currentSinceMs=e),this.votes.push({key:t,atMs:e}),this.votes=this.votes.filter(r=>e-r.atMs<=this.windowMs),e-this.currentSinceMs<this.current.minDurationMs)return this.current;let o=new Map;for(let r of this.votes){let c=(e-r.atMs)/1e3,a=this.decayPerSecond**c;o.set(r.key,(o.get(r.key)??0)+a)}let n=this.current.key,s=-1;for(let[r,c]of o)c>s&&(s=c,n=r);return n!==this.current.key&&(this.current=it[n],this.currentSinceMs=e),this.current}};var je=Object.freeze({MAX_AREA_FRAC:.92,TILT_MAX_SIDE_RATIO:1.3,GLARE_MAX_SPECULAR_FRAC:.025});function ae(i){let{data:t,width:e,height:o}=i,n=e*o;if(n===0)return 0;let s=0;for(let r=0;r<n;r++){let c=r*4;.299*(t[c]??0)+.587*(t[c+1]??0)+.114*(t[c+2]??0)>=252&&s++}return s/n}function Ye(i){let t=(a,l)=>Math.hypot(l.x-a.x,l.y-a.y),e=t(i.topLeft,i.topRight),o=t(i.bottomLeft,i.bottomRight),n=t(i.topLeft,i.bottomLeft),s=t(i.topRight,i.bottomRight),r=Math.max(e,o)/Math.max(1e-6,Math.min(e,o)),c=Math.max(n,s)/Math.max(1e-6,Math.min(n,s));return Math.max(r,c)}function ce(i){let t={...ie,...i.thresholds},e=je,{quad:o,frameWidth:n,frameHeight:s,measures:r}=i,c=i.format==="ID-3",a="ok";if(o===null)a="no_document";else if(c){let m=mt(o),h=n>0?m.width/n:0,f=m.height>0?m.width/m.height:0;h<t.ID3_BAND_MIN_WIDTH_FRAC?a="too_far":re(o,n,s,t.EDGE_CLIP_MARGIN_PX)?a="edge_clipped":(f<t.ID3_BAND_ASPECT_MIN||f>t.ID3_BAND_ASPECT_MAX)&&(a="wrong_shape")}else{let m=oe(o,n,s),h=mt(o),f=Math.max(h.width,h.height)/Math.max(1e-6,Math.min(h.width,h.height));m<t.MIN_AREA_FRAC?a="too_far":m>e.MAX_AREA_FRAC?a="too_close":re(o,n,s,t.EDGE_CLIP_MARGIN_PX)?a="edge_clipped":Jt(i.format,f)?Ye(o)>e.TILT_MAX_SIDE_RATIO&&(a="tilted"):a="wrong_shape"}let l=r.exposure>=t.GUIDE_EXPOSURE?"ok":r.meanLuma<(ht[0]+ht[1])/2?"too_dark":"too_bright",u=r.sharpness>=t.GUIDE_SHARPNESS?"ok":"blurry",d=r.specularFraction>=e.GLARE_MAX_SPECULAR_FRAC?"glare":"ok";return{framing:a,lighting:l,blur:u,glare:d,acceptable:a==="ok"&&l==="ok"&&u==="ok"&&d==="ok"}}function re(i,t,e,o){return[i.topLeft,i.topRight,i.bottomRight,i.bottomLeft].some(s=>s.x<=o||s.y<=o||s.x>=t-o||s.y>=e-o)}var ue=Object.freeze({width:1920,height:1080}),Ze=Object.freeze({width:3840,height:2160}),le=4096,Je=2560,he=640,nt=.15,Y=Object.freeze({side:.2,above:.9,below:.3});function E(i){let t=[i.topLeft.x,i.topRight.x,i.bottomRight.x,i.bottomLeft.x],e=[i.topLeft.y,i.topRight.y,i.bottomRight.y,i.bottomLeft.y],o=Math.min(...t),n=Math.min(...e);return{x:o,y:n,width:Math.max(...t)-o,height:Math.max(...e)-n}}function de(i,t){let e=Math.max(0,Math.floor(i.x)),o=Math.max(0,Math.floor(i.y)),n=Math.min(t.width,Math.ceil(i.x+i.width)),s=Math.min(t.height,Math.ceil(i.y+i.height));return n-e<16||s-o<16?null:{x:e,y:o,width:n-e,height:s-o}}function qe(i,t,e){if(i===null||t.width<=0||t.height<=0)return null;let o=E(i);if(o.width<=0||o.height<=0)return null;let n=e==="ID-3"?{x:o.x-o.width*Y.side,y:o.y-o.width*Y.above,width:o.width*(1+2*Y.side),height:o.height+o.width*(Y.above+Y.below)}:{x:o.x-o.width*nt,y:o.y-o.height*nt,width:o.width*(1+2*nt),height:o.height*(1+2*nt)};return de(n,t)}function pt(i,t,e){let o=Math.max(i,t);return o>0?Math.min(1,e/o):1}function gt(i,t,e,o,n=Je){let s=t.width>0?e.width/t.width:1,r=t.height>0?e.height/t.height:1,c=i===null?null:{topLeft:{x:i.topLeft.x*s,y:i.topLeft.y*r},topRight:{x:i.topRight.x*s,y:i.topRight.y*r},bottomRight:{x:i.bottomRight.x*s,y:i.bottomRight.y*r},bottomLeft:{x:i.bottomLeft.x*s,y:i.bottomLeft.y*r}},a=qe(c,e,o)??{x:0,y:0,width:e.width,height:e.height},l=pt(a.width,a.height,n),u=Math.max(1,Math.round(a.width*l)),d=Math.max(1,Math.round(a.height*l)),m=null;if(c!==null){let h=E(c);m=de({x:(h.x-a.x)*l,y:(h.y-a.y)*l,width:h.width*l,height:h.height*l},{width:u,height:d})}return{crop:a,width:u,height:d,docRegion:m}}var $e=960,ft=[{width:1920,height:1080},{width:2560,height:1440}];function ti(i){let t=Number.isFinite(i)&&i>0?Math.min(1,i):.85;return ft.find(e=>e.height*t>=$e)??ft[ft.length-1]}function me(i,t,e,o=Ze,n){if(e==="LOW")return null;let s=n===void 0?null:ti(n.fill),r=s!==null&&Math.max(s.width,s.height)>Math.max(o.width,o.height)?s:o,c=i?.width?.max,a=i?.height?.max;if(typeof c!="number"||typeof a!="number"||c<=0||a<=0)return null;let l=Math.max(c,a),u=Math.min(c,a),d=Math.min(l,Math.max(r.width,r.height)),m=Math.min(u,Math.min(r.width,r.height));return d<=Math.max(t.width,t.height)?null:{width:{ideal:d},height:{ideal:m}}}function fe(i){let t={},e=i?.imageWidth,o=i?.imageHeight;if(typeof e?.max=="number"&&e.max>0){let n=typeof o?.max=="number"&&o.max>0?e.max/o.max:1.3333333333333333,s=n>=1?le:le*n,r=Math.min(e.max,Math.floor(s)),c=typeof e.step=="number"&&e.step>0?e.step:1,a=typeof e.min=="number"?e.min:0;r=Math.max(a,a+Math.floor((r-a)/c)*c),t.imageWidth=r}return i?.fillLightMode?.includes("off")===!0&&(t.fillLightMode="off"),t}function pe(i,t){if(i.width<=0||i.height<=0||t.width<=0||t.height<=0)return!1;let e=i.width>i.height,o=t.width>t.height;return e!==o&&i.width!==i.height&&t.width!==t.height?!1:Math.max(i.width,i.height)>=1.2*Math.max(t.width,t.height)}function ge(i,t,e,o){if(e===null)return!1;let n=E(i),s=E(e);if(t.width<=0||o.width<=0)return!1;let r=n.width/t.width,c=s.width/o.width;return c>0&&r>=.6*c&&r<=1.25*c}var be=3500,ei=.92;function Me(){let i=globalThis.ImageCapture;return typeof i=="function"?i:null}function ii(i){return/AppleWebKit\//.test(i)&&!/(Chrome|Chromium|Edg|OPR)\//.test(i)}function ke(i,t=typeof navigator>"u"?"":navigator.userAgent){return Me()!==null&&!ii(t)&&i!=null&&i.kind==="video"&&i.readyState==="live"}function ye(i,t){return new Promise((e,o)=>{let n=setTimeout(()=>o(new Error("takePhoto timed out")),t);i.then(s=>{clearTimeout(n),e(s)},s=>{clearTimeout(n),o(s)})})}function bt(i,t){let e=document.createElement("canvas");return e.width=i,e.height=t,e}function oi(i,t){return new Promise((e,o)=>{i.toBlob(n=>n?e(n):o(new Error("toBlob failed")),"image/jpeg",t)})}async function xe(i,t,e,o,n){let s=bt(e,o),r=bt(1,1);try{let c=s.getContext("2d");if(c===null)throw new Error("2d context unavailable");c.imageSmoothingQuality="high",c.drawImage(i,t.x,t.y,t.width,t.height,0,0,e,o);let a=await oi(s,ei),l=n===null?null:qt({topLeft:{x:n.x,y:n.y},topRight:{x:n.x+n.width,y:n.y},bottomRight:{x:n.x+n.width,y:n.y+n.height},bottomLeft:{x:n.x,y:n.y+n.height}},{width:e,height:o},{width:e,height:o}),u=$t(s,l),d=pt(e,o,he);return r.width=Math.max(1,Math.round(e*d)),r.height=Math.max(1,Math.round(o*d)),r.getContext("2d")?.drawImage(s,0,0,r.width,r.height),{blob:a,previewDataUrl:r.toDataURL("image/jpeg",.85),sharpness:u}}finally{s.width=0,s.height=0,r.width=0,r.height=0}}function ni(i,t){let e=Math.min(1,t/i.width),o=bt(Math.max(1,Math.round(i.width*e)),Math.max(1,Math.round(i.height*e)));try{let n=o.getContext("2d",{willReadFrequently:!0});return n===null?null:(n.imageSmoothingQuality="high",n.drawImage(i,0,0,o.width,o.height),n.getImageData(0,0,o.width,o.height))}finally{o.width=0,o.height=0}}async function De(i,t,e,o){let n={width:Math.max(1,i.videoWidth),height:Math.max(1,i.videoHeight)},s=gt(t,e,n,o);return{...await xe(i,s.crop,s.width,s.height,s.docRegion),docRegion:s.docRegion,source:"video",width:s.width,height:s.height}}async function we(i,t,e,o,n){let s=Me();if(s===null)return null;let r=null;try{let c=new s(n.track),a=await ye(c.getPhotoCapabilities?.()??Promise.resolve({}),be).catch(()=>({})),l=await ye(c.takePhoto(fe(a)),be);r=await createImageBitmap(l);let u={width:i.videoWidth,height:i.videoHeight};if(!pe(r,u))return null;let d=ni(r,n.detectWidth),m=null;d!==null&&t!==null&&(m=await n.detect(d).catch(()=>null));let h=d??{width:r.width,height:r.height};m!==null&&!ge(m,h,t,e)&&(m=null);let f=gt(m,h,r,o);return{...await xe(r,f.crop,f.width,f.height,f.docRegion),docRegion:f.docRegion,source:"photo",width:f.width,height:f.height}}catch{return null}finally{r?.close()}}var st=Object.freeze({width:3840,height:2160,lensSelection:!0,continuousFocus:!0,refocusBeforePhotoMs:350,zoomMax:2,zoomNoFocusInfo:1.5,zoomMinSourcePx:2160,fillDistanceM:Object.freeze({id1:.11,id3:.15}),focusMarginFrac:.2,stillSharpnessMin:.16,stillRefusalsMax:2,focusFarFillFrac:.45,noDocFarHintMs:1500,zoomFallbackMs:8e3}),S=(i,t,e)=>typeof i=="number"&&Number.isFinite(i)&&i>=t&&i<=e?i:void 0;function Ri(i){let t=st,e=i!==null&&typeof i=="object"?i:{},o=e.fillDistanceM!==null&&typeof e.fillDistanceM=="object"?e.fillDistanceM:{},n=(s,r)=>typeof s=="boolean"?s:r;return{width:S(e.width,640,7680)??t.width,height:S(e.height,480,4320)??t.height,lensSelection:n(e.lensSelection,t.lensSelection),continuousFocus:n(e.continuousFocus,t.continuousFocus),refocusBeforePhotoMs:S(e.refocusBeforePhotoMs,0,2e3)??t.refocusBeforePhotoMs,zoomMax:S(e.zoomMax,1,5)??t.zoomMax,zoomNoFocusInfo:S(e.zoomNoFocusInfo,1,5)??t.zoomNoFocusInfo,zoomMinSourcePx:S(e.zoomMinSourcePx,0,8e3)??t.zoomMinSourcePx,fillDistanceM:{id1:S(o.id1,.03,1)??t.fillDistanceM.id1,id3:S(o.id3,.03,1)??t.fillDistanceM.id3},focusMarginFrac:S(e.focusMarginFrac,0,2)??t.focusMarginFrac,stillSharpnessMin:S(e.stillSharpnessMin,0,10)??t.stillSharpnessMin,stillRefusalsMax:S(e.stillRefusalsMax,0,10)??t.stillRefusalsMax,focusFarFillFrac:S(e.focusFarFillFrac,0,1)??t.focusFarFillFrac,noDocFarHintMs:S(e.noDocFarHintMs,0,6e4)??t.noDocFarHintMs,zoomFallbackMs:S(e.zoomFallbackMs,0,12e4)??t.zoomFallbackMs}}var yt="sekyro.doc.camera";function si(){try{let i=globalThis.localStorage?.getItem(yt);return typeof i=="string"&&i!==""?i:null}catch{return null}}function ve(i){try{i===null?globalThis.localStorage?.removeItem(yt):globalThis.localStorage?.setItem(yt,i)}catch{}}var rt=(i,t)=>Array.isArray(i?.focusMode)&&i.focusMode.includes(t);function kt(i,t,e){if(!rt(i,"single-shot"))return null;let o=n=>Math.min(1,Math.max(0,Number.isFinite(n)?n:.5));return{focusMode:"single-shot",pointsOfInterest:[{x:o(t),y:o(e)}]}}function Ci(i,t,e,o){if(!Number.isFinite(i)||!Number.isFinite(t)||e.width<=0||e.height<=0||o.width<=0||o.height<=0)return null;let n=Math.max(e.width/o.width,e.height/o.height),s=o.width*n,r=o.height*n,c=(i-e.left+(s-e.width)/2)/s,a=(t-e.top+(r-e.height)/2)/r;return{x:Math.min(1,Math.max(0,c)),y:Math.min(1,Math.max(0,a))}}function _e(i,t,e,o=st){let n=i?.zoom?.min,s=i?.zoom?.max;if(typeof s!="number"||s<=1)return 1;let r=e==="ID-3"?o.fillDistanceM.id3:o.fillDistanceM.id1,c=i?.focusDistance?.min,a;if(typeof c=="number"&&c>0&&c<1){if(a=c*(1+o.focusMarginFrac)/r,a<=1.05)return 1}else{if(Math.min(t.width,t.height)<o.zoomMinSourcePx)return 1;a=o.zoomNoFocusInfo}let l=Math.min(a,o.zoomMax,s);typeof n=="number"&&(l=Math.max(l,n));let u=i?.zoom?.step;return typeof u=="number"&&u>0&&(l=Math.round(l/u)*u),l>1.01?Number(l.toFixed(2)):1}function Mt(i){try{return i.getVideoTracks?.()[0]}catch{return}}function Se(i){if(i!==null)for(let t of i.getTracks())t.stop()}function ri(i){try{let t=Mt(i)?.getCapabilities?.();return!Array.isArray(t?.focusMode)||t.focusMode.includes("continuous")}catch{return!0}}async function Te(i){let t=s=>({audio:!1,video:{...s,width:{ideal:i.base.width},height:{ideal:i.base.height}}}),e=s=>i.getUserMedia(t({deviceId:{exact:s}})),o=()=>i.getUserMedia(t({facingMode:{ideal:"environment"}}));if(i.lensSelection){let s=si();if(s!==null)try{return{stream:await e(s),lens:"stored"}}catch{ve(null)}}let n=await o();if(!i.lensSelection||i.enumerateDevices===void 0)return{stream:n,lens:"default"};try{let s=ut(await i.enumerateDevices()).slice(0,3);if(s.length===0)return{stream:n,lens:"default"};let r=null;for(let c of s){let a=n!==null?Mt(n)?.getSettings?.().deviceId:void 0;if(n===null||a!==c){Se(n),n=null;try{n=await e(c)}catch{continue}}if(r??(r=c),ri(n))return ve(c),{stream:n,lens:"selected"}}if(n!==null&&r!==null&&Mt(n)?.getSettings?.().deviceId===r)return{stream:n,lens:"selected"};if(Se(n),n=null,r!==null)try{return{stream:await e(r),lens:"selected"}}catch{}return{stream:await o(),lens:"default"}}catch{return{stream:n??await o(),lens:"default"}}}var Z=Object.freeze({brightness:0,glare:0,cardGlare:0,sharpness:0,fill:0,shape:0,content:0,offsetX:0,offsetY:0,edgeConfidence:0,box:null}),L=i=>Math.min(1,Math.max(0,i));function Fe(i,t,e,o=.06){let n=Math.max(i.width/e,i.height),s=n*e,r=(i.width-s)/2,c=(i.height-n)/2,a=L((t.x-t.width*o-r)/s),l=L((t.y-t.height*o-c)/n),u=L((t.x+t.width*(1+o)-r)/s),d=L((t.y+t.height*(1+o)-c)/n);return{x:a,y:l,width:u-a,height:d-l}}function Ce(i,t,e={}){let o=e.edgePeakFrac??0,{width:n,height:s,data:r}=i;if(n<=0||s<=0)return Z;let c=L(t.x),a=L(t.y),l={x:c,y:a,width:Math.max(0,L(t.x+t.width)-c),height:Math.max(0,L(t.y+t.height)-a)};if(l.width<=0||l.height<=0)return Z;let u=l.x*n,d=l.y*s,m=(l.x+l.width)*n,h=(l.y+l.height)*s,f=(m-u)*.15,g=(h-d)*.15,y=(p,b,R)=>Math.min(R,Math.max(b,p)),x=y(Math.floor(u-f),0,n-1),w=y(Math.floor(d-g),0,s-1),O=y(Math.ceil(m+f),x+1,n),v=y(Math.ceil(h+g),w+1,s),D=Math.max(1,Math.ceil(Math.max(O-x,v-w)/320)),M=Math.floor((O-x+D-1)/D),_=Math.floor((v-w+D-1)/D);if(M<3||_<3)return Z;let k=new Int32Array(M*_);for(let p=0;p<_;p++){let b=w+p*D;for(let R=0;R<M;R++){let F=(b*n+x+R*D)*4;k[p*M+R]=(r[F]??0)*77+(r[F+1]??0)*150+(r[F+2]??0)*29>>8}}let C=(p,b)=>(p-b-.5)/D,T=C(u,x),A=C(m,x),B=C(d,w),U=C(h,w),Dt=(m-u)/D,wt=(h-d)/D,vt=y(Math.ceil(T),0,M-1),Ge=y(Math.floor(A),vt,M-1),St=y(Math.ceil(B),0,_-1),ze=y(Math.floor(U),St,_-1),_t=0,Tt=0,W=0,Rt=0,Ft=0,H=0;for(let p=St;p<=ze;p++)for(let b=vt;b<=Ge;b++){let R=k[p*M+b];if(_t+=R,R>=248&&Tt++,W++,b>=1&&b<M-1&&p>=1&&p<_-1){let F=k[p*M+b-1]+k[p*M+b+1]+k[(p-1)*M+b]+k[(p+1)*M+b]-4*R;Rt+=F,Ft+=F*F,H++}}let Ne=W>0?_t/W:0,Ct=W>0?Tt/W:0,At=H>0?Rt/H:0,Qe=H>0?Math.max(0,Ft/H-At*At):0,K=new Float64Array(M),V=new Float64Array(_);for(let p=0;p<_;p++)for(let b=1;b<M-1;b++)K[b]=K[b]+Math.abs(k[p*M+b+1]-k[p*M+b-1]);for(let p=1;p<_-1;p++)for(let b=0;b<M;b++)V[p]=V[p]+Math.abs(k[(p+1)*M+b]-k[(p-1)*M+b]);let I=at(K,!0,T,o),P=at(K,!1,A,o),G=at(V,!0,B,o),z=at(V,!1,U,o),Et=(P.position-I.position)/Dt,Lt=(z.position-G.position)/wt,Be=Lt>0?Et/Lt:0,Ue=((I.position+P.position)/2-(T+A)/2)/Dt,We=((G.position+z.position)/2-(B+U)/2)/wt,Ot=Re(K),It=Re(V),He=Ot<=0||It<=0?0:Math.min(Math.min(I.value,P.value)/Ot,Math.min(G.value,z.value)/It),$=(p,b)=>b+(p+.5)*D,Pt=Ct,Gt=0;{let p=(P.position-I.position)*.06,b=(z.position-G.position)*.06,R=y(Math.ceil(I.position+p),0,M-1),F=y(Math.floor(P.position-p),0,M-1),Ke=y(Math.ceil(G.position+b),0,_-1),zt=y(Math.floor(z.position-b),0,_-1),Nt=0,tt=0,Qt=0;for(let N=Ke;N<=zt;N++)for(let Q=R;Q<=F;Q++){tt++;let X=k[N*M+Q];X>=248&&Nt++;let Ve=Q+2<=F?k[N*M+Q+2]:X,Xe=N+2<=zt?k[(N+2)*M+Q]:X;(Math.abs(Ve-X)>=24||Math.abs(Xe-X)>=24)&&Qt++}tt>=16&&(Pt=Nt/tt,Gt=Qt/tt)}return{brightness:Ne,glare:Ct,cardGlare:Pt,sharpness:Qe,fill:Et,shape:Be,content:Gt,offsetX:Ue,offsetY:We,edgeConfidence:He,box:{left:$(I.position,x),right:$(P.position,x),top:$(G.position,w),bottom:$(z.position,w)}}}function at(i,t,e,o){let n=i.length,s=Math.max(1,Math.floor(n*.45)),r=t?1:Math.max(1,n-1-s),c=t?Math.min(n-2,s):n-2,a=r;for(let h=r;h<=c;h++)i[h]>i[a]&&(a=h);if(o>0&&o<1){let h=i[a]*o,f=a,g=Math.abs(a-e);for(let y=r;y<=c;y++){let x=i[y];if(x<h||x<(i[y-1]??0)||x<(i[y+1]??0))continue;let w=Math.abs(y-e);w<g&&(f=y,g=w)}a=f}let l=a>0?i[a-1]:0,u=i[a],d=a<n-1?i[a+1]:0,m=l+u+d;return{position:m>0?a+(d-l)/m:a,value:u}}function Re(i){if(i.length<3)return 0;let t=0;for(let e=1;e<i.length-1;e++)t+=i[e];return t/(i.length-2)}function Ae(i){let t=i.box;return t===null||t.right-t.left<4||t.bottom-t.top<4?null:{topLeft:{x:t.left,y:t.top},topRight:{x:t.right,y:t.top},bottomRight:{x:t.right,y:t.bottom},bottomLeft:{x:t.left,y:t.bottom}}}var J=Object.freeze({fillMin:.82,fillMax:1.06,offsetMax:.06,glareMax:.025,sharpnessMin:180,edgeConfidenceMin:1.6,darkBrightness:70,lockMs:450,steadyMs:900,steadyFillMin:.45,steadyFillMax:1.3,steadyFillDelta:.06,steadyOffsetDelta:.04,steadyRefMs:100,edgePeakFrac:.4,shapeTolerance:.2,contentMin:.1});function Oi(i){let t=i!==null&&typeof i=="object"?i:{},e={...J};for(let o of Object.keys(J)){let n=t[o];typeof n=="number"&&Number.isFinite(n)&&n>=0&&n<=1e6&&(e[o]=n)}return e}var ct=class{constructor(t=J){this.t=t;this.goodSince=null;this.steadySince=null;this.last=null}reset(){this.goodSince=null,this.steadySince=null,this.last=null}tick(t,e){let o=this.t,n=o.shapeTolerance<=0||Math.abs(t.shape-1)<=o.shapeTolerance,s=t.edgeConfidence>=o.edgeConfidenceMin&&n&&t.content>=o.contentMin,r=t.fill>=o.fillMin&&t.fill<=o.fillMax,c=Math.abs(t.offsetX)<=o.offsetMax&&Math.abs(t.offsetY)<=o.offsetMax,a=t.cardGlare<=o.glareMax,l=t.sharpness>=o.sharpnessMin,u=this.last;this.last={fill:t.fill,offsetX:t.offsetX,offsetY:t.offsetY,at:e};let d=u!==null&&o.steadyRefMs>0?Math.min(3,Math.max(1,(e-u.at)/o.steadyRefMs)):1,m=s&&a&&l&&t.fill>=o.steadyFillMin&&t.fill<=o.steadyFillMax&&u!==null&&Math.abs(t.fill-u.fill)<=o.steadyFillDelta*d&&Math.abs(t.offsetX-u.offsetX)<=o.steadyOffsetDelta*d&&Math.abs(t.offsetY-u.offsetY)<=o.steadyOffsetDelta*d,h=s&&r&&c&&a&&l,f;if(s?a?t.fill<o.fillMin?f="too_small":t.fill>o.fillMax?f="too_big":l?c?f="locking":f="off_center":f="blurry":f="glare":f="no_card",h){if(m&&(this.steadySince??(this.steadySince=e)),this.goodSince??(this.goodSince=e),e-this.goodSince>=o.lockMs)return{detected:s,ready:!0,via:"good",blocker:"locking"};let g=this.steadySince!==null&&e-this.steadySince>=o.steadyMs;return{detected:s,ready:g,via:g?"steady":null,blocker:"locking"}}if(this.goodSince=null,m){this.steadySince??(this.steadySince=e);let g=e-this.steadySince>=o.steadyMs;return{detected:s,ready:g,via:g?"steady":null,blocker:g?"locking":"steadying"}}return this.steadySince=null,{detected:s,ready:!1,via:null,blocker:f}}};var q=null;async function ai(i){return q===null&&(q=(await import("./detector-scanic-P2RTEQUV.js")).detectQuad),q(i)}async function ci(i){let t=te(i);return t===null?null:{topLeft:{x:t.x,y:t.y},topRight:{x:t.x+t.width,y:t.y},bottomRight:{x:t.x+t.width,y:t.y+t.height},bottomLeft:{x:t.x,y:t.y+t.height}}}function Ji(){q===null&&import("./detector-scanic-P2RTEQUV.js").then(i=>{q=i.detectQuad}).catch(()=>{})}var Ee=4e3,li=2,Le=3,ui=Object.freeze({LOW:3,MID:5,HIGH:6}),xt=Object.freeze({manualShutterMs:6e3,detectedNoLockMs:1950});function qi(i){let t=i!==null&&typeof i=="object"?i:{},e=(o,n,s)=>typeof o=="number"&&Number.isFinite(o)&&o>=n&&o<=s?o:void 0;return{manualShutterMs:e(t.manualShutterMs,1e3,6e4)??xt.manualShutterMs,detectedNoLockMs:e(t.steadyMs,300,3e4)!==void 0?t.steadyMs+(e(t.lockMs,0,1e4)??450):xt.detectedNoLockMs}}var Oe=class i{constructor(t){this.torchOn=!1;this.stillRefusals=0;this.zoom=1;this.positioningSince=null;this.detectedSince=null;this.lastSeenAt=null;this.lastGuideQuad=null;this.lastOcrReady=null;this.shutterOffered=!1;this.stats=i.freshStats();this.handlers=new Map;this.stream=null;this.timer=null;this.state="idle";this.lastGuidance=null;this.attempt=0;this.capturing=!1;this.feedback=new ot;this.lastFeedbackKey=null;this.lastQuad=null;this.lastDetect=null;this.frameWatch=null;this.reopened=!1;this.lit=!1;this.blackTicks=0;this.offEnded=null;this.opts=t,this.gate=new ne(t.format??"ID-1",t.thresholds);let e=t.deviceClass??jt(Xt());this.deviceClass=e,this.camera=t.camera??st,this.shutterTuning=t.shutter??xt,this.guideTuning=t.guideLock??J,this.guideLock=new ct(this.guideTuning),this.cadenceMs=1e3/ui[e]}on(t,e){let o=this.handlers.get(t);return o||(o=new Set,this.handlers.set(t,o)),o.add(e),()=>o?.delete(e)}emit(t,e){for(let o of[...this.handlers.get(t)??[]])o(e)}async start(){let t=this.state==="error"?this.resumePlayback():null,e=++this.attempt;if(this.clearFrameWatch(),this.gate.reset(),this.resetSide(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.lit=!1,this.blackTicks=0,t!==null&&await t&&e===this.attempt){this.setState("positioning"),this.scheduleTick(e),this.watchFrames(e);return}if(e===this.attempt){this.releaseStream(),Kt(),this.setState("preflight");try{let o=this.opts.getUserMedia??(r=>navigator.mediaDevices.getUserMedia(r));this.setState("acquiring");let n=this.opts.enumerateDevices??(this.opts.getUserMedia===void 0&&typeof navigator<"u"&&navigator.mediaDevices?.enumerateDevices?()=>navigator.mediaDevices.enumerateDevices():void 0),s=await Te({getUserMedia:o,...n!==void 0?{enumerateDevices:n}:{},lensSelection:this.camera.lensSelection,base:ue});if(e!==this.attempt){for(let r of s.stream.getTracks())r.stop();return}if(this.stream=s.stream,Wt(this.stream),Ht(this.stream),this.watchEnded(e),this.opts.upgradeResolution!==!1&&await this.upgradeResolution(),e!==this.attempt||(await this.applyFocusAndZoom(),e!==this.attempt)||(this.opts.video.srcObject=this.stream,await this.opts.video.play().catch(()=>{}),e!==this.attempt))return;this.setState("positioning"),this.scheduleTick(e),this.watchFrames(e)}catch(o){if(e!==this.attempt)return;let n=Ut(o),s=Bt(o);this.setState("error"),this.emit("error",{kind:n,retryable:!0,detail:s===void 0?{phase:"acquiring"}:{phase:"acquiring",name:s}})}}}resumePlayback(){let t=this.opts.video,e=this.videoTrack();if(this.stream===null||e===null||e.readyState!=="live"||t.srcObject!==this.stream)return null;try{return Promise.resolve(t.play()).then(()=>this.framesNow(),()=>!1)}catch{return null}}framesNow(){let t=this.opts.video;return this.opts.hasFrames!==void 0?this.opts.hasFrames(t):!t.paused&&t.readyState>=2&&t.videoWidth>0}watchFrames(t){let e=this.opts.firstFrameMs??Ee;e<=0||(this.clearFrameWatch(),this.frameWatch=setTimeout(()=>{if(this.frameWatch=null,!(t!==this.attempt||this.state!=="positioning")){if(this.framesNow()&&this.blackTicks<Le){this.reopened=!1;return}this.cameraDead(t)}},e))}clearFrameWatch(){this.frameWatch!==null&&clearTimeout(this.frameWatch),this.frameWatch=null}watchEnded(t){this.offEnded?.(),this.offEnded=null;let e=this.videoTrack();if(e===null||typeof e.addEventListener!="function")return;let o=()=>{t===this.attempt&&(this.state==="positioning"||this.state==="acquiring")&&this.cameraDead(t)};e.addEventListener("ended",o),this.offEnded=()=>e.removeEventListener?.("ended",o)}cameraDead(t){if(t!==this.attempt)return;let e=this.videoTrack(),o=e!==null&&e.readyState==="live"&&!e.muted&&this.opts.video.paused&&!this.framesNow();if(!o&&!this.reopened){this.reopened=!0,this.start();return}this.attempt+=1,this.timer!==null&&(this.opts.clearTimer??clearTimeout)(this.timer),this.timer=null,this.clearFrameWatch(),o||this.releaseStream(),this.reopened=!1,this.setState("error"),this.emit("error",{kind:"generic",retryable:!0,detail:{phase:"acquiring"}})}releaseStream(){if(this.offEnded?.(),this.offEnded=null,this.stream)for(let t of this.stream.getTracks())t.stop();this.stream=null,this.opts.video.srcObject!==null&&this.opts.video.srcObject!==void 0&&(this.opts.video.srcObject=null)}rearm(t){t!==void 0&&(this.opts.side=t),this.gate.reset(),this.resetSide(),this.feedback.reset(),this.lastFeedbackKey=null,this.lastGuidance=null,this.capturing=!1,this.stillRefusals=0,this.state==="captured"&&(this.setState("positioning"),this.scheduleTick(this.attempt))}async captureNow(){if(this.state!=="positioning"||this.capturing)return;let t=this.opts.video,e=this.lastDetect?.width??Math.max(1,t.videoWidth),o=this.lastDetect?.height??Math.max(1,t.videoHeight),n=this.lastQuad??this.lastGuideQuad??{topLeft:{x:0,y:0},topRight:{x:e,y:0},bottomRight:{x:e,y:o},bottomLeft:{x:0,y:o}},s=(this.opts.now??(()=>performance.now()))(),r=this.feedback.force("processing",s);this.lastFeedbackKey=r.key,this.emit("feedback",r),await this.fire(this.attempt,this.lastOcrReady!==null?this.lastOcrReady.quad:n,{width:e,height:o,tickSharpness:this.lastDetect?.tickSharpness??0},this.lastOcrReady?.via??"manual")}captureReport(){let t=this.stats;return{...this.opts.side!==void 0?{side:this.opts.side}:{},format:this.opts.format??"ID-1",deviceClass:this.deviceClass,video:{width:this.opts.video.videoWidth||0,height:this.opts.video.videoHeight||0},zoom:this.zoom,...t.zoomFallbackAtMs!==void 0?{zoomFallbackAtMs:t.zoomFallbackAtMs}:{},...t.msToCapture!==void 0?{msToCapture:t.msToCapture}:{},...t.via!==void 0?{via:t.via}:{},...t.shutterAtMs!==void 0?{shutterAtMs:t.shutterAtMs}:{},...t.shutterReason!==void 0?{shutterReason:t.shutterReason}:{},ticks:t.ticks,quadFraming:{...t.quadFraming},qualityBlockers:{...t.qualityBlockers},guideBlockers:{...t.guideBlockers},stillRefusals:t.stillRefusals,...this.ocrReport()}}ocrReport(){let t=this.opts.ocr;if(t===void 0)return{};let e=(this.opts.format??"ID-1")==="ID-3"||this.opts.side==="single"?"single":this.opts.side==="verso"?"verso":"recto",o=t.report(e,this.stats.via,(this.opts.now??(()=>performance.now()))());return o===null?{}:{ocr:o}}static freshStats(){return{ticks:0,quadFraming:{},qualityBlockers:{},guideBlockers:{},stillRefusals:0}}setGuide(t){t===void 0?delete this.opts.guide:this.opts.guide=t,this.guideLock.reset()}guideRegion(t){let e=t.width/Math.max(1,t.height),o=this.opts.guide;if(o!==void 0&&o.viewAspect>0){let c={width:o.viewAspect,height:1},a={x:o.rect.x*o.viewAspect,y:o.rect.y,width:o.rect.width*o.viewAspect,height:o.rect.height};return Fe(c,a,e,0)}let n=Zt(this.opts.format??"ID-1").center,s=.86,r=s*e/n;return r>.84&&(r=.84,s=r*n/e),{x:(1-s)/2,y:(1-r)/2,width:s,height:r}}resetSide(){this.positioningSince=null,this.detectedSince=null,this.lastSeenAt=null,this.guideLock.reset(),this.lastGuideQuad=null,this.lastOcrReady=null,this.opts.ocr?.reset(),this.stats=i.freshStats(),this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1}))}withdrawShutter(){this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1}))}zoomFallback(t){let e=this.videoTrack();if(e===null||this.zoom<=1)return;let o=this.focusCaps(),n=typeof o?.zoom?.min=="number"?Math.max(o.zoom.min,1):1;this.zoom=n,this.stats.zoomFallbackAtMs=Math.round(t-(this.positioningSince??t)),this.guideLock.reset(),this.gate.reset(),e.applyConstraints({advanced:[{zoom:n}]}).catch(()=>{})}offerShutter(t,e){this.shutterOffered||(this.shutterOffered=!0,this.stats.shutterAtMs=Math.round(e-(this.positioningSince??e)),this.stats.shutterReason=t,this.emit("shutter",{available:!0,reason:t}))}torchAvailable(){try{return this.stream?.getVideoTracks?.()[0]?.getCapabilities?.()?.torch===!0}catch{return!1}}async setTorch(t){this.torchOn=t;try{await this.stream?.getVideoTracks?.()[0]?.applyConstraints({advanced:[{torch:t}]})}catch{}}destroy(){if(this.attempt+=1,this.timer!==null&&(this.opts.clearTimer??clearTimeout)(this.timer),this.timer=null,this.clearFrameWatch(),this.offEnded?.(),this.offEnded=null,this.stream)for(let t of this.stream.getTracks())t.stop();this.stream=null,this.opts.video.srcObject=null}async upgradeResolution(){try{let t=this.stream?.getVideoTracks?.()[0];if(t===void 0)return;let e=t.getSettings?.()??{},o=me(t.getCapabilities?.(),{width:e.width??0,height:e.height??0},this.deviceClass,{width:this.camera.width,height:this.camera.height},this.opts.ocr?.liveMrzOn===!0?{fill:this.guideRegion({width:1080,height:1920}).width}:void 0);o!==null&&await t.applyConstraints(o)}catch{}}focusCaps(){try{return this.videoTrack()?.getCapabilities?.()??null}catch{return null}}async applyFocusAndZoom(){let t=this.videoTrack();if(t===null)return;let e=this.focusCaps();this.camera.continuousFocus&&rt(e,"continuous")&&await t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{});let o={width:0,height:0};try{let s=t.getSettings?.()??{};o={width:s.width??0,height:s.height??0}}catch{}let n=_e(e,o,this.opts.format??"ID-1",this.camera);if(n>1)try{await t.applyConstraints({advanced:[{zoom:n}]}),this.zoom=n}catch{this.zoom=1}}async focusAt(t,e){let o=this.videoTrack(),n=kt(this.focusCaps(),t,e);if(!(o===null||n===null))try{await o.applyConstraints({advanced:[n]}),(this.opts.setTimer??setTimeout)(()=>{this.restoreContinuous()},1500)}catch{}}async restoreContinuous(){let t=this.videoTrack();t===null||!this.camera.continuousFocus||!rt(this.focusCaps(),"continuous")||await t.applyConstraints({advanced:[{focusMode:"continuous"}]}).catch(()=>{})}async refocusOn(t,e){let o=this.camera.refocusBeforePhotoMs,n=this.videoTrack();if(o<=0||n===null||e.width<=0||e.height<=0)return;let s=E(t),r=kt(this.focusCaps(),(s.x+s.width/2)/e.width,(s.y+s.height/2)/e.height);if(r!==null)try{await n.applyConstraints({advanced:[r]});let c=this.opts.setTimer??setTimeout;await new Promise(a=>{c(()=>a(),o)})}catch{}}videoTrack(){try{return this.stream?.getVideoTracks?.()[0]??null}catch{return null}}async takeStill(t,e,o){if(this.opts.captureStill!==void 0)return this.opts.captureStill(this.opts.video,t,e);let n=this.opts.format??"ID-1",s=this.videoTrack();if(o&&this.opts.photoCapture!==!1&&this.deviceClass!=="LOW"&&!this.torchOn&&s!==null&&ke(s)){await this.refocusOn(t,e);let r=await we(this.opts.video,t,e,n,{track:s,detect:this.detector(),detectWidth:et});if(this.restoreContinuous(),r!==null)return r}return De(this.opts.video,t,e,n)}detector(){return this.opts.detect??((this.opts.format??"ID-1")==="ID-3"?ci:ai)}setState(t){this.state=t,this.emit("statechange",{state:t})}scheduleTick(t){let e=this.opts.setTimer??setTimeout;this.timer=e(()=>{this.tick(t)},this.cadenceMs)}async tick(t){if(t!==this.attempt||this.state!=="positioning"||this.capturing)return;let e=this.opts.now??(()=>performance.now()),o=this.opts.grabDetectFrame??Pe,n=this.detector(),s=o(this.opts.video,et);if(s===null){this.scheduleTick(t);return}if(!this.lit){if(dt(s)>li)this.lit=!0,this.blackTicks=0;else if(++this.blackTicks>=Le&&this.frameWatch===null&&(this.opts.firstFrameMs??Ee)>0){this.cameraDead(t);return}}let r=null;try{r=await n(s)}catch{r=null}if(t!==this.attempt)return;let c=r!==null?lt(s,r):s,a=e(),l={sharpness:j(c),exposure:Yt(c),meanLuma:dt(c),specularFraction:ae(c)},u=ce({format:this.opts.format??"ID-1",quad:r,frameWidth:s.width,frameHeight:s.height,measures:l,...this.opts.thresholds!==void 0?{thresholds:this.opts.thresholds}:{}}),d=this.gate.tick({timestampMs:a,quad:r,quality:l,frameWidth:s.width,frameHeight:s.height}),h=(this.opts.format??"ID-1")!=="ID-3"?Ce(s,this.guideRegion(s),{edgePeakFrac:this.guideTuning.edgePeakFrac}):Z,f=this.guideLock.tick(h,a);this.lastGuideQuad=f.detected?Ae(h):null;let g=this.capturing?null:this.ocrTick(s,r,h,f.detected,u,a);this.positioningSince??(this.positioningSince=a);let y=this.stats;if(y.ticks+=1,y.quadFraming[u.framing]=(y.quadFraming[u.framing]??0)+1,u.framing==="ok"&&!d.ready){let T=u.lighting!=="ok"?u.lighting:u.glare!=="ok"?"glare":u.blur!=="ok"?"blurry":"steadying";y.qualityBlockers[T]=(y.qualityBlockers[T]??0)+1}y.guideBlockers[f.blocker]=(y.guideBlockers[f.blocker]??0)+1,r!==null||f.detected?(this.detectedSince??(this.detectedSince=a),this.lastSeenAt=a):this.detectedSince=null,this.lastSeenAt!==null&&a-this.lastSeenAt<=bi?a-this.positioningSince>=this.shutterTuning.manualShutterMs?this.offerShutter("timeout",a):g?.suspendQuality!==!0&&this.detectedSince!==null&&a-this.detectedSince>=this.shutterTuning.detectedNoLockMs&&this.offerShutter("detected_no_lock",a):this.withdrawShutter();let O=a-(this.lastSeenAt??this.positioningSince);this.zoom>1&&this.camera.zoomFallbackMs>0&&O>=this.camera.zoomFallbackMs&&this.zoomFallback(a),this.emit("checks",{engine:"docv1",p:d.p,plausible:d.plausible,stableTicks:d.stableTicks,quad:d.quad,frameWidth:s.width,frameHeight:s.height,analysis:u,ready:g?.suspendQuality!==!0&&(d.ready&&r!==null||f.ready&&this.lastGuideQuad!==null)||this.lastOcrReady!==null,guide:{detected:f.detected,blocker:f.blocker,fill:h.fill,shape:h.shape,content:h.content,offsetX:h.offsetX,offsetY:h.offsetY},...g!==null&&g.mode!=="off"?{ocr:{mode:g.mode,...g.mrz?{mrz:g.mrz}:{},...g.lock?{lock:g.lock}:{}}}:g?.mrz?{ocr:{mode:g.mode,mrz:g.mrz}}:{}}),this.lastQuad=d.plausible?r:null,this.lastDetect={width:s.width,height:s.height,tickSharpness:l.sharpness};let v=se(u);u.framing!=="ok"&&f.detected&&(v=gi(f.blocker,h.brightness<this.guideTuning.darkBrightness)),v==="blurry"&&r!==null&&di(r,s,this.opts.format??"ID-1")>=this.camera.focusFarFillFrac&&(v="focus_far"),v==="sensing"&&this.zoom>1&&this.camera.noDocFarHintMs>0&&O>=this.camera.noDocFarHintMs&&(v="focus_far");let D=this.feedback.tick(v,a);if(D.key!==this.lastFeedbackKey&&(this.lastFeedbackKey=D.key,this.emit("feedback",D)),d.guidanceKey!==this.lastGuidance&&(this.lastGuidance=d.guidanceKey,this.emit("guidance",{key:d.guidanceKey})),this.capturing)return;let M=g?.suspendQuality!==!0,_=M&&d.ready&&r!==null,k=M&&f.ready&&this.lastGuideQuad!==null,C=this.lastOcrReady;if(C!==null&&this.opts.autoCapture!==!1){let T=this.feedback.force("processing",a);this.lastFeedbackKey=T.key,this.emit("feedback",T);let A=j(lt(s,C.quad));await this.fire(t,C.quad,{width:s.width,height:s.height,tickSharpness:A},C.via);return}if((_||k)&&this.opts.autoCapture!==!1){let T=this.feedback.force("processing",a);this.lastFeedbackKey=T.key,this.emit("feedback",T);let A=k?this.lastGuideQuad:r,B=k?f.via==="steady"?"guide_steady":"guide_good":"quad",U=k?j(lt(s,A)):l.sharpness;await this.fire(t,A,{width:s.width,height:s.height,tickSharpness:U},B);return}this.scheduleTick(t)}async fire(t,e,o,n){this.capturing=!0;let s=this.opts.grabDetectFrame??Pe,r=this.opts.setTimer??setTimeout,c={width:o.width,height:o.height};try{let a={still:await this.takeStill(e,c,!0),sharpness:o.tickSharpness};if(t!==this.attempt)return;let l=a.still.source==="photo"||this.deviceClass==="LOW"?0:mi;for(let m=0;m<l;m++){if(await new Promise(g=>{r(()=>g(),fi)}),t!==this.attempt)return;let h=s(this.opts.video,et);if(h===null)continue;let f=j(lt(h,e));if(f>a.sharpness*pi){let g=await this.takeStill(e,c,!1);if(t!==this.attempt)return;a={still:g,sharpness:f}}}if(t!==this.attempt)return;let u=a.still.sharpness;if(this.opts.autoCapture!==!1&&n!=="manual"&&typeof u=="number"&&u>=0&&u<this.camera.stillSharpnessMin&&this.stillRefusals<this.camera.stillRefusalsMax){this.stillRefusals+=1,this.stats.stillRefusals+=1,this.guideLock.reset(),this.lastOcrReady=null,(n==="text_lock"||n==="live_mrz")&&this.opts.ocr?.rearmFace();let m=(this.opts.now??(()=>performance.now()))(),h=this.feedback.force("focus_far",m);this.lastFeedbackKey=h.key,this.emit("feedback",h),this.capturing=!1,this.gate.reset(),this.scheduleTick(t);return}this.stillRefusals=0;let d=(this.opts.now??(()=>performance.now()))();this.stats.via=n,this.stats.msToCapture=Math.round(d-(this.positioningSince??d)),this.shutterOffered&&(this.shutterOffered=!1,this.emit("shutter",{available:!1})),this.setState("captured"),this.emit("artifacts",{keyframe:a.still.blob,previewDataUrl:a.still.previewDataUrl,...this.opts.side!==void 0?{side:this.opts.side}:{},...a.still.docRegion!==void 0?{docRegion:a.still.docRegion}:{},...(()=>{let m=n==="live_mrz"?this.opts.ocr?.liveCapture():null;return m?{liveMrz:m}:{}})()})}catch{if(t!==this.attempt)return;this.capturing=!1,this.gate.reset(),this.guideLock.reset(),this.lastOcrReady=null,(n==="text_lock"||n==="live_mrz")&&this.opts.ocr?.rearmFace(),this.scheduleTick(t)}}ocrTick(t,e,o,n,s,r){let c=this.opts.ocr,a=this.opts.video;if(c===void 0||!c.hasEngine)return this.lastOcrReady=null,null;let l=a.videoWidth,u=a.videoHeight;if(l<=0||u<=0||t.width<=0||t.height<=0)return null;let m=(this.opts.format??"ID-1")==="ID-3",h=this.guideRegion(t),f={x:h.x*l,y:h.y*u,w:h.width*l,h:h.height*u},g=l/t.width,y=u/t.height,x;m&&e!==null?x=hi(E(e),g,y,l,u):x=ee(f,c.bandTop,u);let w=m?s.glare==="ok":o.cardGlare<=this.guideTuning.glareMax,O=m?s.blur==="ok":o.sharpness>=this.guideTuning.sharpnessMin,v=c.tick({atMs:r,video:a,mrzFace:m||this.opts.side==="verso"||this.opts.side==="single",present:m||e!==null||n,card:f,band:x,portrait:u>l,glareOk:w,sharpOk:O});if(v.ready&&v.via!==void 0){let D=m?e??Ie(h,t):this.lastGuideQuad??Ie(h,t);this.lastOcrReady={quad:D,via:v.via}}else this.lastOcrReady=null;return v}};function hi(i,t,e,o,n){let s=Math.min(o,i.width*1.06*t),r=Math.min(n,Math.max(i.height*1.6*e,s/5)),c=(i.y+i.height/2)*e,a=Math.max(0,Math.min(o-s,(i.x-i.width*.03)*t)),l=Math.max(0,Math.min(n-r,c-r/2));return{x:a,y:l,w:s,h:r}}function Ie(i,t){let e=i.x*t.width,o=i.y*t.height,n=(i.x+i.width)*t.width,s=(i.y+i.height)*t.height;return{topLeft:{x:e,y:o},topRight:{x:n,y:o},bottomRight:{x:n,y:s},bottomLeft:{x:e,y:s}}}function di(i,t,e){let o=E(i);return t.width<=0||t.height<=0?0:e==="ID-3"?o.width/t.width:o.width*o.height/(t.width*t.height)}var mi=2,fi=260,pi=1.08;function Pe(i,t){let e=i.videoWidth,o=i.videoHeight;if(e===0||o===0)return null;let n=Math.min(1,t/e),s=Math.round(e*n),r=Math.round(o*n),c=document.createElement("canvas");c.width=s,c.height=r;let a=c.getContext("2d",{willReadFrequently:!0});return a===null?null:(e/Math.max(1,s)>4&&(a.imageSmoothingQuality="high"),a.drawImage(i,0,0,s,r),a.getImageData(0,0,s,r))}function lt(i,t){let e=[t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x],o=[t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y],n=Math.max(0,Math.floor(Math.min(...e))),s=Math.max(0,Math.floor(Math.min(...o))),r=Math.min(i.width,Math.ceil(Math.max(...e))),c=Math.min(i.height,Math.ceil(Math.max(...o))),a=Math.max(1,r-n),l=Math.max(1,c-s),u=new Uint8ClampedArray(a*l*4);for(let d=0;d<l;d++){let m=((s+d)*i.width+n)*4;u.set(i.data.subarray(m,m+a*4),d*a*4)}return{data:u,width:a,height:l,colorSpace:i.colorSpace}}function gi(i,t){return i==="glare"?"glare":i==="too_small"?"too_far":i==="too_big"?"too_close":t?"too_dark":i==="blurry"?"blurry":i==="off_center"?"edge_clipped":i==="no_card"?"sensing":"hold_still"}var bi=1200;export{it as a,se as b,ot as c,je as d,ae as e,Ye as f,ce as g,st as h,Ri as i,yt as j,si as k,ve as l,rt as m,kt as n,Ci as o,_e as p,ri as q,Te as r,Z as s,Fe as t,Ce as u,Ae as v,J as w,Oi as x,ct as y,Ji as z,Ee as A,li as B,Le as C,ui as D,xt as E,qi as F,Oe as G,hi as H,mi as I,fi as J};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as P,d as A,e as H}from"./chunk-QZUFICG3.js";var z=new Set(["nni_unbound","id_number_unbound","method_required","mobile_required","portrait_required"]);function Ce(e){return z.has(e)}function ve(e,n,t){let i=n.detail;return{check:e,kind:n.kind,...i?.name!==void 0?{name:i.name}:{},...i?.phase!==void 0?{phase:i.phase}:{},...i?.engineKind!==void 0?{engineKind:i.engineKind}:{},attempt:Math.max(0,Math.min(1e3,t))}}function Pe(){let e=-1,n="";return{note(t){t==="starting"&&n!=="starting"&&(e+=1),n=t},newHandle(){n=""},noteError(){e<0&&(e=0)},get value(){return e}}}var j={document:"document_photo",nfc:"document_chip",population_registry:"national_number",national_eid:"national_eid"};function f(e){return e.plan?.steps??[]}function x(e){return Math.max(0,e.attempts.max-e.attempts.used)}function J(e){let n=e.plan?.choice;return n!==void 0&&e.plan?.current===n.nodeId?n:null}function Me(e){let n=J(e);if(n?.kind!=="identity_method")return null;let t=n.options.map(r=>j[r.service]).filter(r=>r!==void 0),i=n.options.find(r=>r.nationalEid)?.nationalEid;return i?{available:!0,selected:null,options:t,nationalEid:i}:{available:!0,selected:null,options:t}}var W=new Set(["liveness","face_match"]);function S(e){return e!==void 0&&(e.state==="pending"||e.state==="input_required")}function T(e){return e.status!=="created"&&e.status!=="in_progress"}function M(e){let n=e.plan?.current,t=n==null?void 0:f(e).find(i=>i.id===n);return S(t)?t:void 0}function _(e,n){return f(e).find(t=>t.checkType===n)}function y(e){let n=f(e),t=n.findIndex(i=>i.checkType==="liveness");return n.find((i,r)=>r>t&&i.checkType==="face_match")}function F(e,n){let t=_(n,"liveness")?.state,i=y(n)?.state;return(y(e)?.state??"pending")==="pending"&&(t==="passed"||t==="review")&&i!==void 0&&i!=="pending"&&i!=="skipped"}function V(e,n){let t=new Map(f(e).map(i=>[i.id,i.state]));return f(n).filter(i=>i.checkType==="face_match"&&(t.get(i.id)??"pending")==="pending"&&i.state!=="pending"&&i.state!=="skipped").map(i=>i.id)}var G=/^[0-9a-f]{24}$/i;function R(e){return G.test(e)?`ses_${e}`:e}function w(e,n){let t=R(e);return n===void 0?{sessionId:t,status:"unavailable"}:{sessionId:t,status:"unavailable",reasonCode:n}}function O(e,n,t){let i=R(e);return t===void 0?{sessionId:i,status:n}:{sessionId:i,status:n,reasonCode:t}}function Ve(e,n){let t=Q(e,n),i=Z(e);return i!==void 0&&(t.sandbox={simulated:!0,reason:i}),t}var X=new Set(["no_testers","tester_gate_not_used","tester_gate_missed"]);function Z(e){if(e.sandbox!==!0)return;let n=e.simulation?.reason;return X.has(n)?n:void 0}function Q(e,n){let t=R(e.sessionId);switch(e.status){case"created":case"in_progress":return re(e,n);case"verified":return C(e,{sessionId:t,status:"verified"});case"review_pending":return C(e,O(t,"review",L(e,"review")));case"not_verified":return C(e,ne(e));default:return C(e,{sessionId:t,status:"not_verified"})}}var ee=new Set([0,1,2,3]);function C(e,n){return ee.has(e.level)&&(n.level=e.level),typeof e.assurance=="string"&&e.assurance.length>0&&(n.assurance=e.assurance),n}function ne(e){let n={sessionId:R(e.sessionId),status:"not_verified"};return e.reason!==void 0&&(n.reason=e.reason),e.reasonCode!==void 0&&(n.reasonCode=e.reasonCode),e.reasonCode==="device_cooldown"&&e.retryAfter!==void 0&&(n.retryAfter=e.retryAfter),n}function te(e){return e==="rejected"?"rejected":e==="unavailable"?"unavailable":"inconclusive"}function ie(e,n){if(n===void 0)return!1;let t=f(n).find(i=>i.id===e.id);return t!==void 0&&t.attempts.used===e.attempts.used}function re(e,n){let t=R(e.sessionId),i=f(e).find(o=>W.has(o.checkType)&&o.state==="input_required"&&o.reason!==void 0);if(i?.reason==="mobile_required")return w(t,"mobile_required");if(i?.reason!==void 0){if(i.result==="unavailable")return w(t,i.reason);let u=n.autoRetry&&(x(i)>0||ie(i,n.previous))?{sessionId:t,status:"retry",reasonCode:i.reason,attemptsRemaining:x(i)}:{sessionId:t,status:"not_verified",reason:te(i.result),reasonCode:i.reason,attemptsRemaining:x(i)};return i.retakeHint!==void 0&&(u.retakeHint=i.retakeHint),u}let r=M(e);return r===void 0&&f(e).some(o=>o.state==="review")?O(t,"review",L(e,"review")):r?.checkType==="portrait_icao"?w(t,"portrait_required"):w(t)}function L(e,n){return f(e).find(t=>t.state===n&&t.reason!==void 0)?.reason}function K(e,n,t,i,r){return e.presignCapture!==void 0?e.presignCapture(n,t,i,r):e.presign(n,t,i)}function q(e){return{engine:e?.engine,durationMs:e?.clipMs,arm:e?.screenRamp?.nonce}}var oe=["video/webm","video/mp4"],N="image/jpeg",se=2,ae=1e3,ue=1e4,de=3,ce=10,le=3,pe=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),fe=new Set(["session_not_active","check_not_found","check_already_finalized","check_out_of_order","identity_confirm_required","check_not_active","step_not_on_path","native_app_required"]),k=class extends Error{constructor(){super("verification destroyed"),this.name="FlowCancelledError"}};function me(e){let n=y(e);return _(e,"portrait_icao")?.state!=="pending"&&(n!==void 0?S(n):e.capture?.livePhoto?.oneCapture===!0)}var h=class extends Error{constructor(n){super(n),this.name="AttestationError"}},E=class extends h{constructor(n){super(`no attestation token: ${n}`),this.name="AttestationUnavailableError",this.code=n}};async function D(e,n,t={}){let i=e.uuid(),r=!1,o=!1,u=0,p=0;for(;;)try{return await n(e.client,i)}catch(s){if(s instanceof h){if(o||s instanceof E)throw s;o=!0,t.onAttestationInvalid?.(),i=e.uuid();continue}if(!(s instanceof P))throw s;if(s.code==="consent_required"&&!r){r=!0,await e.ensureConsent({force:!0}),i=e.uuid();continue}if(s.code==="attestation_invalid"&&!o){o=!0,t.onAttestationInvalid?.(),i=e.uuid();continue}if(s.code==="inference_unavailable"&&p<de){p+=1;let a=A(s.retryAfterSeconds,ce,e.random??Math.random);e.onBusy?.({attempt:p,retryAfterSeconds:a/1e3}),await e.sleep(a),t.onAttestationInvalid?.(),i=e.uuid();continue}if(pe.has(s.code)&&u<se){u+=1;let a=s.retryAfterSeconds!==void 0?s.retryAfterSeconds*1e3:void 0;await e.sleep(a!==void 0?Math.min(a,ue):ae);continue}throw s}}var he=new Set(["passed","review","processing","skipped"]);async function Fe(e){let{artifacts:n}=e,t=n.clip,i=H(n.clipMime??"");if(n.degraded==="NO_RECORDER"||t===void 0||!oe.includes(i))return{kind:"unavailable",reason:"no_recorder"};e.client.armCapture?.(2);let r=_e(e,n.keyframe),o=ge(e,t,i,r),u=ye(e,r),p=!1,s=new Set,a=!0,b=0;for(;;){if(e.isCancelled())return{kind:"cancelled"};let c=e.getView();if(T(c))return{kind:"settled"};let d=M(c),g=d?.checkType,v=g==="liveness"&&!p?"liveness":g==="face_match"&&!s.has(d?.id)&&s.size<2&&a?"face_match":null;if(v===null)return{kind:"settled"};if(v==="liveness"&&n.captureChannel==="desktop")return{kind:"unavailable",reason:"mobile_required"};try{if(v==="liveness"){p=!0;let l=await o();if(e.isCancelled())return{kind:"cancelled"};F(c,l)&&s.add(y(l)?.id);for(let Y of V(c,l))s.add(Y);await e.applySubmit(l,"liveness");let m=_(e.getView(),"liveness")?.state;a=m===void 0||he.has(m)}else{s.add(d?.id);let l=await u();if(e.isCancelled())return{kind:"cancelled"};for(let m of V(c,l))s.add(m);await e.applySubmit(l,"face_match")}}catch(l){if(e.isCancelled()||l instanceof k)return{kind:"cancelled"};let m=be(l);if(m.kind!=="resync"||b>=le)return m;b+=1,await e.refreshView()}}}function _e(e,n){let t=null,i=null,r=()=>t!==null?Promise.resolve(t):(i??(i=(async()=>{let o=await K(e.client,"image",N,n.size,q(e.artifacts));return await e.client.uploadToSpaces(o.uploadUrl,n,N),t=(await e.client.completeMedia(o.key)).key,e.onKeyframePromoted?.(t),t})().finally(()=>{i=null})),i);return{ensure:r,attempt:()=>r().catch(()=>null),current:()=>t}}function ge(e,n,t,i){let r=e.clipKeys?.get()??null,o,u=null,p=0,s;return()=>D(e,async(a,b)=>{if(r===null||o===void 0){if(e.isCancelled())throw new k;o===void 0&&!me(e.getView())&&(o=null),e.onPhase("uploading");let[c,d]=await Promise.all([r!==null?Promise.resolve(r):(async()=>{let g=await K(a,"clip",t,n.size,q(e.artifacts));return await a.uploadToSpaces(g.uploadUrl,n,t),(await a.completeMedia(g.key)).key})(),o!==void 0?Promise.resolve(o===null?null:o.imageKey):i.attempt()]);r=c,e.clipKeys?.set(c),o===void 0&&(o=d===null?null:{imageKey:d})}if(u===null){let c=performance.now();try{u=await e.getAttestation(),s=e.attestationError?.()}catch(d){throw d instanceof h?d:new h(d instanceof Error?d.message:String(d))}p=Math.round(performance.now()-c)}return e.onPhase("checking"),a.submitCheck("liveness",{clipKey:r,attestation:u,captureChannel:e.artifacts.captureChannel,capture:{...Se(e.artifacts),attestationMs:p,attestationError:s,...ke(e.attestationFacts?.())},...o!==null?{faceMatch:o}:{}},{idempotencyKey:b})},{onAttestationInvalid:()=>{u=null}})}function ye(e,n){return()=>D(e,async(t,i)=>{if(n.current()===null){if(e.isCancelled())throw new k;e.onPhase("uploading")}let r=await n.ensure();return e.onPhase("checking"),t.submitCheck("face_match",{imageKey:r},{idempotencyKey:i})})}function Se(e){let n={width:e.width,height:e.height};for(let t of Re)e[t]!==void 0&&(n[t]=e[t]);return n}var Re=["engine","facingMode","mode","formFactor","clipMs","clipFrames","fps","clipRetakes","codec","cameraReadyMs","faceAcquireMs","captureMs","screenRamp","provenance"];function ke(e){return e===void 0?{}:{attestationChecks:e.checks,...e.challengeMs!==void 0?{attestationChallengeMs:e.challengeMs}:{}}}function be(e){if(e instanceof h)return{kind:"unavailable",reason:"attestation"};if(e instanceof P){if(e.code==="attestation_invalid")return{kind:"unavailable",reason:"attestation"};if(e.code==="inference_unavailable")return{kind:"unavailable",reason:"inference_unavailable"};if(e.code==="mobile_required")return{kind:"unavailable",reason:"mobile_required"};if(fe.has(e.code))return{kind:"resync"}}return{kind:"unavailable",reason:"network"}}var Le="form_answers_invalid",U=class extends Error{constructor(n,t){super(`form answers refused (${n.map(i=>`${i.id}: ${i.code}`).join(", ")})`),this.name="FormAnswersError",this.issues=n,this.source=t}};var B=class extends Error{constructor(n,t){super(`invalid ${n} (${t})`),this.name="InvalidInputError",this.field=n,this.kind=t}},$=class extends Error{constructor(n,t){super(`invalid ${n} (${t})`),this.name="OtpInputError",this.field=n,this.kind=t}};function I(e){return e?.source==="upload"?null:e?.source==="choice"&&e.sourcePick!=="camera"?"upload_or_phone":"phone"}function De(e,n){if(n===void 0||!S(n)||n.requiresMobile!==!0)return null;switch(n.checkType){case"liveness":return"phone";case"face_match":{if(n.reason!==void 0)return"phone";let t=_(e,"portrait_icao");return t?.state==="passed"||t?.state==="review"?null:"phone"}case"doc_ocr":return I(e.documents);case"poa":return I(e.proofOfAddress);case"portrait_icao":{let t=e.portrait;return t?.pendingFix!==void 0||t?.reuse?.pending===!0?null:I(t)}default:return null}}function we(e){let n=e?.capture,t=n?.mode;return t==="assisted"||t==="self"||t==="choice"?t:n?.cameraSwitch===!0?"assisted":"self"}function Be(e){let n=e?.capture?.pick;return we(e)==="choice"&&(n==="self"||n==="assisted")?n:null}function $e(e,n,t=null){return e==="choice"?n??t??"self":e}var ze={"JP:drivers_license":{normalize:"upper_no_space_or_hyphen",pattern:"^[0-9]{12}$",check:null,registrySources:[],describe:"number must be the 12-digit Japanese driving licence number"},"JP:residence_permit":{normalize:"upper_no_space_or_hyphen",pattern:"^[A-Z]{2}[0-9]{8}[A-Z]{2}$",check:null,registrySources:[],describe:"number must be the 12-character residence card number: two letters, eight digits, two letters"},"MR:drivers_license":{normalize:"upper_no_space_or_hyphen",pattern:"^[0-9]{8}$",check:null,registrySources:[],describe:"number must be the 8-digit Mauritanian driver's license number"},"MR:national_id":{normalize:"trim",pattern:"^[0-9]{10}$",check:"mr_nni_mod97",registrySources:["MR.anrpts"],describe:"number must be the 10-digit Mauritanian national ID number with a valid check digit"}};export{Ce as a,ve as b,Pe as c,j as d,f as e,x as f,J as g,Me as h,S as i,T as j,M as k,_ as l,R as m,w as n,Ve as o,Z as p,De as q,we as r,Be as s,$e as t,K as u,oe as v,se as w,ae as x,de as y,ce as z,h as A,E as B,D as C,Fe as D,Se as E,Le as F,U as G,ze as H,B as I,$ as J};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as z,b as S,e as R,f as L}from"./chunk-WNBEOK5Q.js";var W=1e3,E=[[1,0],[0,1],[1,1],[1,-1]];function w(i){let{width:t,height:e,data:r}=i;if(t<16||e<16)return-1;let s=new Uint8Array(t*e);for(let n=0,o=0;n<s.length;n+=1,o+=4)s[n]=Math.round(.299*(r[o]??0)+.587*(r[o+1]??0)+.114*(r[o+2]??0));let l=-1;for(let[n,o]of E){let h=new Uint32Array(256),a=new Float64Array(256),b=0;for(let c=1;c<e-1;c+=1){let u=c*t,_=(c+o)*t,A=(c-o)*t;for(let M=1;M<t-1;M+=1){let y=s[_+M+n]??0,T=s[A+M-n]??0,k=Math.abs(y-T);h[k]=(h[k]??0)+1,a[k]=(a[k]??0)+Math.abs(y+T-2*(s[u+M]??0)),b+=1}}let v=Math.max(1,Math.floor(b/20)),d=0,m=0,f=0;for(let c=255;c>=0&&d<v;c-=1){let u=h[c]??0;d+=u,m+=u*c,f+=a[c]??0}if(m===0)return 0;let p=f/m;l=l<0?p:Math.min(l,p)}return l}var F=.06;function B(i,t,e,r=F){if(i===null||t.width<=0||t.height<=0)return null;let s=[i.topLeft,i.topRight,i.bottomRight,i.bottomLeft],l=e.width/t.width,n=e.height/t.height,o=Math.min(...s.map(u=>u.x))*l,h=Math.max(...s.map(u=>u.x))*l,a=Math.min(...s.map(u=>u.y))*n,b=Math.max(...s.map(u=>u.y))*n,v=(h-o)*r,d=(b-a)*r,m=Math.max(0,Math.floor(o-v)),f=Math.max(0,Math.floor(a-d)),p=Math.min(e.width,Math.ceil(h+v)),c=Math.min(e.height,Math.ceil(b+d));return p-m<16||c-f<16?null:{x:m,y:f,width:p-m,height:c-f}}function D(i,t){let e=new Uint8ClampedArray(t.width*t.height*4);for(let r=0;r<t.height;r+=1)for(let s=0;s<t.width*4;s+=1)e[r*t.width*4+s]=i.data[((t.y+r)*i.width+t.x)*4+s]??0;return{data:e,width:t.width,height:t.height}}function O(i,t=1e3){let e=t/Math.max(i.width,i.height);if(e>=1)return i;let r=Math.max(1,Math.round(i.width*e)),s=Math.max(1,Math.round(i.height*e)),l=new Uint8ClampedArray(r*s*4);for(let n=0;n<s;n+=1){let o=Math.floor(n/e),h=Math.min(i.height,Math.max(o+1,Math.floor((n+1)/e)));for(let a=0;a<r;a+=1){let b=Math.floor(a/e),v=Math.min(i.width,Math.max(b+1,Math.floor((a+1)/e)));for(let d=0;d<3;d+=1){let m=0;for(let f=o;f<h;f+=1)for(let p=b;p<v;p+=1)m+=i.data[(f*i.width+p)*4+d]??0;l[(n*r+a)*4+d]=m/((h-o)*(v-b))}l[(n*r+a)*4+3]=255}}return{data:l,width:r,height:s}}function Q(i,t){return w(O(t===null?i:D(i,t)))}function U(i,t){let e=t??{x:0,y:0,width:i.width,height:i.height},r=Math.min(1,1e3/Math.max(e.width,e.height)),s=Math.max(1,Math.round(e.width*r)),l=Math.max(1,Math.round(e.height*r)),n=document.createElement("canvas");n.width=s,n.height=l;try{let o=n.getContext("2d",{willReadFrequently:!0});return o===null?-1:(o.imageSmoothingQuality="high",o.drawImage(i,e.x,e.y,e.width,e.height,0,0,s,l),w(o.getImageData(0,0,s,l)))}catch{return-1}finally{n.width=0,n.height=0}}var g=class{constructor(t=2){this.stableReads=t;this.last=null;this.run=0}offer(t){return t===null?(this.reset(),!1):(this.run=t===this.last?this.run+1:1,this.last=t,this.run>=this.stableReads)}reset(){this.last=null,this.run=0}};var N=Object.freeze({...z,minIntervalMs:150,maxWidthPx:480,detectorLimit:960,searchTimeoutMs:12e3}),P=Object.freeze({detectorLimit:960,bandMaxWidthPx:1280,minBandWidthPx:900,bandTop:.55,minIntervalMs:150,stableReads:2,profileReads:5,maxReadMs:1200,searchTimeoutMs:12e3}),C=()=>typeof document>"u"||document.visibilityState!=="hidden",G=(i,t,e)=>createImageBitmap(i,Math.round(t.x),Math.round(t.y),Math.max(1,Math.round(t.w)),Math.max(1,Math.round(t.h)),{resizeWidth:Math.max(1,Math.round(Math.min(t.w,e))),resizeQuality:"high"}),x=(i,t)=>{if(i.length===0)return 0;let e=[...i].sort((r,s)=>r-s);return e[Math.min(e.length-1,Math.floor(e.length*t))]};function V(i){return i<=250?"fast":i<=600?"mid":"slow"}function X(i,t,e){let r=i.y+i.h*t,s=Math.min(e,i.y+i.h*1.05);return{x:i.x,y:r,w:i.w,h:Math.max(1,s-r)}}var I=class{constructor(t){this.o=t;this.engine=null;this.tier=null;this.gen=0;this.ticksSinceRead=Number.POSITIVE_INFINITY;this.hiddenSince=null;this.inFlight=!1;this.lastReadAt=Number.NEGATIVE_INFINITY;this.firstSeen=null;this.reads=0;this.times=[];this.mrzState={state:"searching"};this.lockState={state:"searching"};this.fallback=null;this.lockOff=!1;this.lockError=!1;this.fired=null;this.valid=null;this.faceMode="off";this.disabled=!1;this.crop=t.crop??G,this.visible=t.visible??C,this.mrzGate=new g(t.liveMrz?.stableReads??2),this.lockGate=new S(t.textLock??N)}setEngine(t,e){this.engine=t,e!==void 0&&(this.tier=e)}liveCadence(t){let e=this.tier===null?null:R[this.tier];return{stride:e?.stride??1,bandWidthPx:Math.min(t.bandMaxWidthPx,e?.bandWidthPx??t.bandMaxWidthPx)}}get bandTop(){return this.o.liveMrz?.bandTop??P.bandTop}get liveMrzOn(){return this.o.liveMrz!==null}get hasEngine(){return this.engine!==null&&!this.disabled}reset(){this.gen++,this.inFlight=!1,this.lastReadAt=Number.NEGATIVE_INFINITY,this.ticksSinceRead=Number.POSITIVE_INFINITY,this.hiddenSince=null,this.firstSeen=null,this.reads=0,this.times=[],this.mrzGate.reset(),this.lockGate.reset(),this.mrzState={state:"searching"},this.lockState={state:"searching"},this.fallback=null,this.lockOff=!1,this.lockError=!1,this.fired=null,this.valid=null,this.faceMode="off"}rearmFace(){this.gen++,this.inFlight=!1,this.lastReadAt=Number.NEGATIVE_INFINITY,this.ticksSinceRead=Number.POSITIVE_INFINITY,this.mrzGate.reset(),this.lockGate.reset(),this.fired=null,this.valid=null,this.fallback===null&&(this.mrzState={state:"searching"}),this.lockOff||(this.lockState={state:"searching"})}liveCapture(){return this.fired?.via==="live_mrz"?this.valid:null}modeFor(t){return this.engine===null||this.disabled?"off":t.mrzFace&&this.o.liveMrz!==null&&this.fallback===null?"live_mrz":this.o.textLock!==null&&!this.lockOff?"text_lock":"off"}tick(t){let e=this.modeFor(t);return e!=="off"&&(this.faceMode=e),this.fired!==null?{ready:!0,via:this.fired.via,suspendQuality:this.fired.via==="live_mrz",mode:e,...this.states()}:e!=="off"&&!this.visible()?(this.hiddenSince??(this.hiddenSince=t.atMs),this.mrzGate.reset(),{ready:!1,suspendQuality:e==="live_mrz"&&this.fallback===null,mode:e,...this.states()}):(this.hiddenSince!==null&&(this.firstSeen!==null&&(this.firstSeen+=t.atMs-this.hiddenSince),this.hiddenSince=null),e==="live_mrz"?this.liveTick(t,this.o.liveMrz):e==="text_lock"?this.lockTick(t,this.o.textLock):{ready:!1,suspendQuality:!1,mode:e,...this.states()})}states(){return{...this.faceMode==="live_mrz"||this.fallback!==null?{mrz:this.fallback!==null?{state:"fallback",reason:this.fallback}:this.mrzState}:{},...this.faceMode==="text_lock"?{lock:this.lockState}:{}}}canRead(t,e){let r=this.engine;return r!==null&&!this.inFlight&&!r.busy&&t-this.lastReadAt>=e}fall(t){this.fallback=t,this.mrzGate.reset()}liveTick(t,e){let r=()=>this.tier!=="low"||this.firstSeen===null||t.atMs-this.firstSeen<L,s=()=>this.fallback!==null?{ready:!1,suspendQuality:!1,mode:"live_mrz",mrz:{state:"fallback",reason:this.fallback}}:{ready:!1,suspendQuality:r(),mode:"live_mrz",mrz:this.mrzState};if(!t.present||t.band===null)return this.mrzGate.reset(),this.mrzState={state:"searching"},s();if(this.firstSeen??(this.firstSeen=t.atMs),t.atMs-this.firstSeen>e.searchTimeoutMs)return this.fall("timeout"),s();if(t.band.w<e.minBandWidthPx)return t.card!==null&&t.card.w<e.minBandWidthPx?(this.fall("unsupported"),s()):(this.mrzState={state:"reading",coach:t.portrait?"turnSideways":"moveCloser"},{ready:!1,suspendQuality:!1,mode:"live_mrz",mrz:this.mrzState});let l=this.liveCadence(e);if(this.ticksSinceRead++,this.ticksSinceRead<l.stride||!this.canRead(t.atMs,e.minIntervalMs))return s();this.inFlight=!0,this.lastReadAt=t.atMs,this.ticksSinceRead=0;let n=this.gen,o=this.engine,h=t.glareOk?t.sharpOk?void 0:"holdStill":"glare";return this.crop(t.video,t.band,l.bandWidthPx).then(a=>o.bandRead(a,e.detectorLimit)).then(a=>{if(n===this.gen){if(this.reads++,this.times.push(a.ms),this.times.length>8&&this.times.shift(),this.reads>=e.profileReads&&x(this.times,.5)>e.maxReadMs)return this.fall("slow");if(this.mrzGate.offer(a.valid?a.digest??null:null)&&a.format&&a.digest){this.valid={format:a.format,...a.documentCode!==void 0?{documentCode:a.documentCode}:{},digest:a.digest,lineCount:a.lineCount,framesToValid:this.reads,msToValid:Math.round(t.atMs-(this.firstSeen??t.atMs))},this.mrzState={state:"valid",format:a.format},this.fired={via:"live_mrz",at:t.atMs};return}this.mrzState={state:"reading",...h?{coach:h}:{},...a.format?{format:a.format}:{}}}}).catch(()=>{n===this.gen&&this.fall("error")}).finally(()=>{n===this.gen&&(this.inFlight=!1)}),s()}lockTick(t,e){let r=()=>({ready:!1,suspendQuality:!1,mode:"text_lock",lock:this.lockState,...this.fallback!==null?{mrz:{state:"fallback",reason:this.fallback}}:{}});if(!t.present||t.card===null)return this.lockGate.reset(),this.lockState={state:"searching"},r();if(this.firstSeen??(this.firstSeen=t.atMs),t.atMs-this.firstSeen>e.searchTimeoutMs)return this.lockOff=!0,r();if(!this.canRead(t.atMs,e.minIntervalMs))return r();this.inFlight=!0,this.lastReadAt=t.atMs;let s=this.gen,l=this.engine,n={glareOk:t.glareOk,sharpOk:t.sharpOk};return this.crop(t.video,t.card,e.maxWidthPx).then(o=>l.layoutRead(o,e.detectorLimit)).then(o=>{if(s!==this.gen)return;this.reads++,this.times.push(o.ms),this.times.length>8&&this.times.shift();let h=this.lockGate.offer(o,t.atMs,n);this.lockState=h.state==="locked"?{state:"locked"}:{state:h.state,...h.hint?{hint:h.hint}:{}},h.state==="locked"&&(this.fired={via:"text_lock",at:t.atMs})}).catch(()=>{s===this.gen&&(this.lockOff=!0,this.lockError=!0)}).finally(()=>{s===this.gen&&(this.inFlight=!1)}),r()}disable(){this.disabled=!0,this.reset()}report(t,e,r){let s=this.faceMode;if(s==="off")return null;let l=x(this.times,.5),n={capture:t,mode:s,reads:this.reads,...this.times.length>0?{readP50Ms:Math.round(l),readP90Ms:Math.round(x(this.times,.9)),deviceClass:V(l)}:{}};return s==="live_mrz"?this.fired?.via==="live_mrz"&&this.valid!==null&&e==="live_mrz"?{...n,outcome:"valid",format:this.valid.format,framesToValid:this.valid.framesToValid,msToValid:this.valid.msToValid}:this.fallback!==null?{...n,outcome:this.fallback}:{...n,outcome:r-(this.firstSeen??r)>=(this.o.liveMrz?.searchTimeoutMs??1/0)?"timeout":"off"}:this.fired?.via==="text_lock"?{...n,outcome:"locked",framesToLock:Math.max(1,this.reads),msToLock:Math.round(this.fired.at-(this.firstSeen??this.fired.at))}:{...n,outcome:this.lockError?"error":this.lockOff?"timeout":"off"}}};export{W as a,w as b,F as c,B as d,D as e,O as f,Q as g,U as h,N as i,P as j,X as k,I as l};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a=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"})}),u=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 o(){let t=typeof navigator>"u"?void 0:navigator,e=!1;try{e=typeof WebAssembly<"u"&&WebAssembly.validate(u)}catch{e=!1}return{cores:t?.hardwareConcurrency??2,memGB:t?.deviceMemory??null,simd:e}}function l(t){let e=t.memGB??4;return t.cores<4||e<3?"LOW":t.cores>=8&&e>=6?"HIGH":"MID"}var n=["LOW","MID","HIGH"],i=class{constructor(e){this.samples=[];this.adjusted=!1;this.current=e}get deviceClass(){return this.current}get profile(){return a[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 s=this.samples.reduce((r,c)=>r+c,0)/this.samples.length;if(s>70)this.current="LOW";else if(s<25){let r=n.indexOf(this.current);this.current=n[Math.min(n.length-1,r+1)]??this.current}return this.current}};export{a,o as b,l as c,i as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a={fp12:"936b9c4ccc4a",engine:"sekyro-ocr-1",precision:"fp32",files:{"sekyro-ocr.wasm":{bytes:3550687,sha256:"00d6b1a4e42da8146e662ab0283b97485397811acc806299046933ce1943fb09",tier:"live",contentType:"application/wasm"},"sekyro-ocr.mjs":{bytes:4270,sha256:"209a78d96ca53344996a0c2300aed4ff8a5c69e142713216975a2840eec08cac",tier:"bundled",contentType:"text/javascript"},"det.param":{bytes:24252,sha256:"c39ba0b1195e8ad37cfc5bdd7acedcfc1d9cb901e7b8eb1c9c4f6e5a66c04eb3",tier:"live",contentType:"text/plain"},"det.bin":{bytes:4685856,sha256:"652bafe366565109a1a5766caf482bc46f01481f8044d3a785bd9a1be67c63bb",tier:"live",contentType:"application/octet-stream"},"mrz-rec.param":{bytes:3510,sha256:"bc69b1b9683e35f6605b21001fadeb81468063459c00c0fc83c67c139f23df01",tier:"live",contentType:"text/plain"},"mrz-rec.bin":{bytes:494196,sha256:"de93a2aa2f08670cc7dedd17ba378d2f5d7cf6ae409054a9eac863a02c2febae",tier:"live",contentType:"application/octet-stream"},"mrz_dict.txt":{bytes:73,sha256:"b19858a4de2ccbbbdd4b53982188ea2c7664013183bbd1ae9d20ab52c661f97f",tier:"live",contentType:"text/plain"},"v5-latin-fp16.param":{bytes:19800,sha256:"843964335e9863681bb17d876c69e7315844e0850e3c04f91b11a3f0c2a57bc6",tier:"lazy",group:"latin",contentType:"text/plain"},"v5-latin-fp16.bin":{bytes:3995900,sha256:"0516474d30cff75a6365869992699d27fbc03f00fcf3d7274c3eed651ee6ea90",tier:"lazy",group:"latin",contentType:"application/octet-stream"},"latin.dict.txt":{bytes:2615,sha256:"c3ab00106e4a4d151a8575b1129b91901a68a35b79a81fd63faab00418b87d75",tier:"lazy",group:"latin",contentType:"text/plain"},"v5-arabic-fp16.param":{bytes:19791,sha256:"1d1e219d277bb1a76909741573f56cfae465f11b61a9be4ca4c29580758c8760",tier:"lazy",group:"arabic",contentType:"text/plain"},"v5-arabic-fp16.bin":{bytes:3974364,sha256:"4ced47b32ab4e7ad16ddebc074f31594eb42b912465a8ed7458bb2842af9efe1",tier:"lazy",group:"arabic",contentType:"application/octet-stream"},"arabic.dict.txt":{bytes:2368,sha256:"8f239c13f6c8b1bdf15f332a65a05002ddd4d99b9286a4bfaf6f0327c36ebbec",tier:"lazy",group:"arabic",contentType:"text/plain"},"v5-cyrillic-fp16.param":{bytes:19806,sha256:"c87b42bfa343509b319dd193dcca4c0e20bb13b1d07bfbf4925a9f5d045966d4",tier:"lazy",group:"cyrillic",contentType:"text/plain"},"v5-cyrillic-fp16.bin":{bytes:3999288,sha256:"97446e221c0d2d84cb76dca6d4217a850efad4d5ec85e3fadc78db353cf97afa",tier:"lazy",group:"cyrillic",contentType:"application/octet-stream"},"cyrillic.dict.txt":{bytes:2780,sha256:"2de016b31edd687acfc1bf72170f4feff9f0c4893edac87cef30b2c5a82443ec",tier:"lazy",group:"cyrillic",contentType:"text/plain"},"v5-greek-fp16.param":{bytes:19815,sha256:"1cc1d47d3aa3fce86d3dbe901a553fd29412f44934a4919d986c155d23f63207",tier:"lazy",group:"greek",contentType:"text/plain"},"v5-greek-fp16.bin":{bytes:3879256,sha256:"04190cd4ee2b023665346d4cd239ee118965f837812108869d3d9894d30c4db3",tier:"lazy",group:"greek",contentType:"application/octet-stream"},"greek.dict.txt":{bytes:1102,sha256:"60e017885fd98fd0fb5c402da86179f1fe24ae229b374b3b96d313f99a09de59",tier:"lazy",group:"greek",contentType:"text/plain"},"v5-devanagari-fp16.param":{bytes:19807,sha256:"c6540a818cbb46c5b511dc4dd20ebfeae9038ec64e5cf175cd2d25f1b9f95c51",tier:"lazy",group:"devanagari",contentType:"text/plain"},"v5-devanagari-fp16.bin":{bytes:3931044,sha256:"d3086391eb2298c4d4e5a6d20a7fc58a8d0f3ce0a12395c88e9d485c5d595828",tier:"lazy",group:"devanagari",contentType:"application/octet-stream"},"devanagari.dict.txt":{bytes:1942,sha256:"c66d17ef6ced6fbfb4413810e75f0f788cfde37d4192bd17af7923fa190066c8",tier:"lazy",group:"devanagari",contentType:"text/plain"},"v5-thai-fp16.param":{bytes:19786,sha256:"4422df9dcc960e42082166adcca42da2aa6df62abebc75daf0c887e89381c039",tier:"lazy",group:"thai",contentType:"text/plain"},"v5-thai-fp16.bin":{bytes:3920396,sha256:"3458d7c5f0a7f88cb804d084c6596dea3f67c5ea99082654938d71a4eb72a079",tier:"lazy",group:"thai",contentType:"application/octet-stream"},"thai.dict.txt":{bytes:1766,sha256:"e0f32101004cc828ed4505bba80126be06e282700c4c79175ed2b21a4d454dfa",tier:"lazy",group:"thai",contentType:"text/plain"},"v5-hangul-fp16.param":{bytes:19804,sha256:"8daec1a4aa09d3bc92a476438330921c910263b8e61d62334d79e2d1dd14247c",tier:"lazy",group:"hangul",contentType:"text/plain"},"v5-hangul-fp16.bin":{bytes:6684280,sha256:"1d38192b59765cf71c1909ea4b972ee3c8588537a53844e6830f57fbf47976a4",tier:"lazy",group:"hangul",contentType:"application/octet-stream"},"hangul.dict.txt":{bytes:47450,sha256:"a7872c929cd25cf615cdfea08579cf800db1943900fe683468df4dcff6f848bb",tier:"lazy",group:"hangul",contentType:"text/plain"}},scripts:{latin:{classes:838,rtl:!1,param:"v5-latin-fp16.param",bin:"v5-latin-fp16.bin",dict:"latin.dict.txt"},arabic:{classes:749,rtl:!0,param:"v5-arabic-fp16.param",bin:"v5-arabic-fp16.bin",dict:"arabic.dict.txt"},cyrillic:{classes:852,rtl:!1,param:"v5-cyrillic-fp16.param",bin:"v5-cyrillic-fp16.bin",dict:"cyrillic.dict.txt"},greek:{classes:356,rtl:!1,param:"v5-greek-fp16.param",bin:"v5-greek-fp16.bin",dict:"greek.dict.txt"},devanagari:{classes:570,rtl:!1,param:"v5-devanagari-fp16.param",bin:"v5-devanagari-fp16.bin",dict:"devanagari.dict.txt"},thai:{classes:526,rtl:!1,param:"v5-thai-fp16.param",bin:"v5-thai-fp16.bin",dict:"thai.dict.txt"},hangul:{classes:11947,rtl:!1,param:"v5-hangul-fp16.param",bin:"v5-hangul-fp16.bin",dict:"hangul.dict.txt"}}};export{a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as g}from"./chunk-U5TL63CG.js";import{c as _}from"./chunk-TSA6GHUG.js";import{a as b,c as y}from"./chunk-22AW4NJD.js";var I=["session_token_invalid","session_token_required","session_token_session_mismatch","session_not_found","rate_limit_exceeded","consent_required","session_not_active","check_not_found","check_already_finalized","check_out_of_order","check_type_unsupported","force_outcome_forbidden","attestation_invalid","platform_unregistered","app_attest_invalid","too_many_challenges","inference_unavailable","mobile_required","nni_locked","document_nni_mismatch","media_content_type_not_allowed","media_too_large","media_key_invalid","media_key_forbidden","media_not_found","media_unreadable","media_session_invalid","idempotency_key_collision","idempotency_in_progress","idempotency_key_required","validation_error","internal_error","unknown_error","upload_failed","network_error","timeout","nfc_outcome_not_accepted","identity_confirm_required","identity_confirm_locked","choice_not_found","choice_locked","choice_option_unavailable","step_not_on_path","check_not_active","sekyro_app_not_allowed","sekyro_app_unverified","id_number_locked","document_id_number_mismatch","simulated_capture_forbidden","native_app_required"];function q(i){return I.includes(i)}var u=class extends Error{constructor(e){super(e.message),this.name="HostedApiError",this.status=e.status,this.code=e.code,e.retryAfterSeconds!==void 0&&(this.retryAfterSeconds=e.retryAfterSeconds),e.details&&(this.details=e.details)}};function T(i,e,n=Math.random){let t=(i??e)*1e3,s=Math.min(Math.max(t,500),2e4),o=Math.round(s*(1+(n()*2-1)*.25));return Math.min(Math.max(o,500),2e4)}var w=6e4,h=4,E=3e4,P=9e5,M=200,C=5,A=400,v=new Set(["server_busy","request_timeout"]),O=20,N=60,H=600,x=2;function l(i){return(i.split(";")[0]??"").trim()}var D={liveness:"clipKey",face_match:"imageKey",doc_ocr:"imageKey"},U=`@sekyro/web/${b}`,K=U,S=class{constructor(e){this.sessionId=null;this.bootstrap=null;this.captureNonces=[];this.captureFetch=null;this.reportedIssues=new Map;this.issueReports=0;this.issuesPausedUntil=0;this.apiOrigin=e.apiOrigin.replace(/\/+$/,""),this.sessionToken=e.sessionToken;let n=e.fetch;this.fetchImpl=(t,s)=>(n??globalThis.fetch).call(globalThis,t,s),this.requestTimeoutMs=e.requestTimeoutMs??E,this.retryAttempts=e.inProgressRetry?.attempts??C,this.retryDelayMs=e.inProgressRetry?.delayMs??A,this.random=e.random??Math.random,this.clientLocale=e.locale}async getSession(){let e=await this.api("GET","/hosted/session");return this.sessionId=e.sessionId,e}async recordConsent(e){let n=await this.api("POST","/hosted/consent",{body:{locale:e},busyRetry:!0}),t=this.captureHold;return this.captureHold=void 0,t&&this.armCapture(t),n}async reportCameraUnavailable(e){return this.api("POST","/hosted/camera-unavailable",{body:{cause:e}})}async testerGate(e){return this.api("POST","/hosted/tester-gate",{body:{input:e}})}async reportCaptureIssue(e){let n=typeof e.name=="string"?e.name.replace(/[^A-Za-z]/g,"").slice(0,40):"",t=typeof e.engineKind=="string"&&/^[a-z_]{1,32}$/.test(e.engineKind)?e.engineKind:void 0,s=typeof e.attempt=="number"&&Number.isInteger(e.attempt)&&e.attempt>=0&&e.attempt<=1e3?e.attempt:void 0,o=e.check==="attestation"?s??"":"",r=[e.check,o,e.kind,n,e.phase??"",t??""].join("|"),c=this.reportedIssues.get(r);if(c!==void 0)return c;if(Date.now()<this.issuesPausedUntil||this.issueReports>=O)return;let a={check:e.check,kind:e.kind,...n!==""?{name:n}:{},...e.phase!==void 0?{phase:e.phase}:{},...t!==void 0?{engineKind:t}:{},...s!==void 0?{attempt:s}:{},...e.formFactor!==void 0?{formFactor:e.formFactor}:{},...typeof e.detail=="string"&&/^\d{1,10}$/.test(e.detail)?{detail:e.detail}:{},...k(e.challengeMs)?{challengeMs:e.challengeMs}:{},...k(e.readyMs)?{readyMs:e.readyMs}:{},...e.inApp===!0?{inApp:!0}:{}};this.issueReports+=1;let p=this.api("POST","/hosted/capture-issue",{body:a,empty:!0}).catch(d=>{if(d instanceof u&&d.status===429){let m=Math.min(Math.max(d.retryAfterSeconds??N,0),H);this.issuesPausedUntil=Math.max(this.issuesPausedUntil,Date.now()+m*1e3);return}(!(d instanceof u)||d.status===0||d.status>=500)&&this.reportedIssues.delete(r)});return this.reportedIssues.set(r,p),p}async choose(e,n){let t=await this.api("POST","/hosted/choice",{body:{nodeId:e,option:n},busyRetry:!0});return this.sessionId=t.sessionId,t}async confirmIdentity(e){return this.api("POST","/hosted/identity/confirm",{body:{decision:e}})}async identityPortrait(){return this.api("GET","/hosted/identity/portrait",{blob:!0})}async presign(e,n,t,s={}){let o=await this.ensureSessionId(),r={kind:e,contentType:l(n),contentLength:t,...s.source==="upload"?{source:"upload"}:{}};return this.api("POST",`/sessions/${o}/media`,{body:r})}armCapture(e=2){let n=Date.now();this.captureNonces.filter(t=>t.expiresAt-w>n).length>=e||(this.captureHold===void 0?this.fillCaptureNonces(e,e):this.captureHold=Math.max(this.captureHold,e))}async armRamp(){try{let e=await this.ensureSessionId(),n=await this.api("POST",`/sessions/${e}/media/capture-nonces`,{body:{count:2,ramp:!0}}),t=Date.now(),s=g(n.screenRamp)?n.screenRamp:void 0,o=t+Math.max(0,n.expiresIn)*1e3;for(let c of Array.isArray(n.nonces)?n.nonces:[])typeof c!="string"||c.length===0||this.captureNonces.push({nonce:c,expiresAt:o,...s!==void 0?{arm:s.nonce}:{}});this.captureNonces=this.captureNonces.slice(-h),this.captureHold=void 0;let r=typeof n.rampExpiresIn=="number"&&n.rampExpiresIn>0?n.rampExpiresIn:0;return{...s!==void 0?{challenge:s}:{},expiresAt:t+r*1e3}}catch{return}}async presignCapture(e,n,t,s={}){let o=await this.ensureSessionId(),r=await this.takeCaptureNonce(s.arm),c=r===void 0?void 0:{nonce:r,...s.engine!==void 0?{engine:s.engine.slice(0,32)}:{},...s.durationMs!==void 0&&Number.isFinite(s.durationMs)?{captureMs:Math.min(36e5,Math.max(0,Math.round(s.durationMs)))}:{}},a={kind:e,contentType:l(n),contentLength:t,capture:c};return this.api("POST",`/sessions/${o}/media`,{body:a})}async takeCaptureNonce(e){let n=()=>{let t=Date.now();this.captureNonces=this.captureNonces.filter(o=>o.expiresAt-w>t);let s=this.captureNonces.findIndex(o=>o.arm===e);return this.captureNonces.splice(s<0?0:s,1)[0]?.nonce};for(let t=0;t<2;t++){let s=n();if(s!==void 0)return s;await this.fillCaptureNonces(1)}return n()}fillCaptureNonces(e,n=0){return this.captureFetch??(this.captureFetch=(async()=>{try{let t=await this.ensureSessionId(),s=await this.api("POST",`/sessions/${t}/media/capture-nonces`,{body:{count:Math.min(h,Math.max(1,e))}}),o=Date.now()+Math.max(0,s.expiresIn)*1e3;for(let r of Array.isArray(s.nonces)?s.nonces:[])typeof r=="string"&&r.length>0&&this.captureNonces.push({nonce:r,expiresAt:o});this.captureNonces=this.captureNonces.slice(-h),this.captureHold=void 0}catch(t){t instanceof u&&t.code==="consent_required"&&(this.captureHold=Math.max(this.captureHold??0,n))}})().finally(()=>{this.captureFetch=null})),this.captureFetch}async uploadToSpaces(e,n,t){let s;try{s=await this.fetchImpl(e,{method:"PUT",headers:{"content-type":l(t)},body:n,signal:AbortSignal.timeout(P)})}catch(o){throw f(o)}if(!s.ok){let o=(await s.text().catch(()=>"")).slice(0,M);throw new u({status:s.status,code:"upload_failed",message:`media upload failed (HTTP ${s.status})${o?`: ${o}`:""}`})}}async completeMedia(e){let n=await this.ensureSessionId();return this.api("POST",`/sessions/${n}/media/complete`,{body:{key:e}})}async submitCheck(e,n,t={}){let s=await this.ensureSessionId(),o={input:n,forceOutcome:t.forceOutcome};return this.api("POST",`/sessions/${s}/checks/${e}`,{body:o,idempotencyKey:t.idempotencyKey,...t.browserCheckToken!==void 0?{browserCheckToken:t.browserCheckToken}:{},busyRetry:t.idempotencyKey!==void 0})}async uploadAndSubmit(e,n,t,s={}){let o=l(n.contentType),r=await this.presign(n.kind,o,n.blob.size);await this.uploadToSpaces(r.uploadUrl,n.blob,o);let c=await this.completeMedia(r.key),a={...t,[D[e]]:c.key};return this.submitCheck(e,a,s)}async ensureSessionId(){return this.sessionId!==null?this.sessionId:(this.bootstrap??(this.bootstrap=this.getSession().finally(()=>{this.bootstrap=null})),(await this.bootstrap).sessionId)}async api(e,n,t={}){let s=e==="GET"||t.busyRetry===!0,o=`${this.apiOrigin}/api/v2${n}`,r={"x-session-token":this.sessionToken,"x-sekyro-sdk":K};t.body!==void 0&&(r["content-type"]="application/json"),t.idempotencyKey!==void 0&&(r["x-idempotency-key"]=t.idempotencyKey),t.browserCheckToken!==void 0&&(r["sekyro-browser-check"]=t.browserCheckToken),this.clientLocale!==void 0&&(r["sekyro-client-locale"]=this.clientLocale);try{let c=y.timezone();c!==void 0&&(r["sekyro-client-timezone"]=c)}catch{}r["sekyro-client-form-factor"]=_();try{let c=await y.deviceHeader();c!==void 0&&(r["sekyro-client-device"]=c)}catch{}for(let c=0;;c++){let a;try{a=await this.fetchImpl(o,{method:e,headers:r,...t.body!==void 0?{body:JSON.stringify(t.body)}:{},cache:"no-store",signal:AbortSignal.timeout(this.requestTimeoutMs)})}catch(d){throw f(d)}if(a.ok){if(t.empty===!0)return;if(t.blob===!0)try{return await a.blob()}catch(m){throw f(m)}let d;try{d=await a.json()}catch{throw new u({status:a.status,code:"unknown_error",message:`response body was not valid JSON (HTTP ${a.status})`})}return L(d)}let p=await V(a);if(p.code==="idempotency_in_progress"&&c<this.retryAttempts){this.retryDelayMs>0&&await R(this.retryDelayMs);continue}if(s&&p.status===503&&v.has(p.code)){s=!1,await R(T(p.retryAfterSeconds,x,this.random));continue}throw p}}};function k(i){return typeof i=="number"&&Number.isInteger(i)&&i>=0&&i<=6e5}function f(i){if((typeof i=="object"&&i!==null?i.name:void 0)==="TimeoutError")return new u({status:0,code:"timeout",message:"request timed out"});let n=i instanceof Error?i.message:String(i);return new u({status:0,code:"network_error",message:`network request failed: ${n}`})}function L(i){return i!==null&&typeof i=="object"&&"success"in i&&"data"in i?i.data:i}async function V(i){let e="unknown_error",n=`request failed (HTTP ${i.status})`,t=Number.NaN,s;try{let c=await i.json();if(c!==null&&typeof c=="object"){let a=c;typeof a.code=="string"&&a.code.length>0&&(e=a.code),typeof a.message=="string"&&a.message.length>0&&(n=a.message),typeof a.retryAfterSeconds=="number"&&(t=a.retryAfterSeconds),Array.isArray(a.details?.issues)?s=a.details:Array.isArray(a.details?.errors)&&(s={...a.details,issues:[]})}}catch{}let o=i.headers.get("retry-after"),r=o===null?Math.floor(t):Number.parseInt(o,10);return new u({status:i.status,code:e,message:n,...Number.isFinite(r)&&r>=0?{retryAfterSeconds:r}:{},details:s})}function R(i){return new Promise(e=>setTimeout(e,i))}function J(i){let e=i?.portrait,n=e?.icao,t=e?.purpose==="id_document";return n==null?t?{policy:"reject",profile:"id_document"}:null:{policy:n.policy==="alert"?"alert":"reject",profile:t||n.profile==="id_document"?"id_document":"selfie"}}function Q(i){return{...i.baselineEyeOpenness!==void 0?{baselineEyeOpenness:i.baselineEyeOpenness}:{},...i.baselineEyeOpennessLeft!==void 0&&i.baselineEyeOpennessRight!==void 0?{baselineEyeOpennessLeft:i.baselineEyeOpennessLeft,baselineEyeOpennessRight:i.baselineEyeOpennessRight}:{},criteria:i.verdict??{},...i.backgroundCheck!==void 0?{backgroundCheck:i.backgroundCheck}:{}}}export{I as a,q as b,u as c,T as d,l as e,U as f,S as g,J as h,Q as i};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as M}from"./chunk-GI3UFGRQ.js";var A=2;function L(u){let l=u.tuning,s=u.now??(()=>performance.now()),t=null,o=!1,g=!1,d=Number.NEGATIVE_INFINITY,a=null,h=0,i=null,n=null,f=0,p=!1,T=()=>{if(p||!l.enabled)return;p=!0;let r=(u.createSegmenter??(e=>import("./segmenter-USLNBX65.js").then(m=>m.createSelfieSegmenter(e))))(u.assetBaseUrl);n=setTimeout(()=>{t===null&&(o=!0)},l.segmenterTimeoutMs),r.then(e=>{n!==null&&clearTimeout(n),g||o?e.close():t=e},()=>{n!==null&&clearTimeout(n),o=!0})};return{measure(r,e,m,S){if(!l.enabled||r.pixels===null)return null;T();let c=s();if(c-d<1e3/l.hz)return a;d=c;let k=r.width/Math.max(1,m),y=r.height/Math.max(1,S),w={x:e.x*k,y:e.y*y,width:e.width*k,height:e.height*y},B=null;if(t!==null&&!o){let x=Math.max(c,h+1);h=x;let U=s();B=t.segment(r.source,x);let b=s()-U;f+=1,f>A&&(i=i===null?b:i*.7+b*.3),i!==null&&i>l.segmenterBudgetMs&&(o=!0,t.close(),t=null)}return a=M(r.pixels,w,B,l),a},close(){g=!0,n!==null&&clearTimeout(n),t?.close(),t=null}}}export{L as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as Me,F as ve,G as ie,H as Te,I as N,J as Y,d as q,e as Ce,f as Pe,g as Ae,i as Re,j as re,l as $,m as oe,o as we,p as xe,q as Ee,u as Ie}from"./chunk-M3637QGB.js";import{c as _e,d as be,e as ke}from"./chunk-FPXL63KZ.js";import{c as j,h as J,i as Oe}from"./chunk-QZUFICG3.js";var Ne=["AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","XK","YE","YT","ZA","ZM","ZW"];var ut=["carte_identite","passport","residence_permit","drivers_license"],ct=["carte_identite","passport","residence_permit"];function dt(e,t){let n=e.byIssuer?.[t]??e.default;return ut.filter(i=>n==="*"?ct.includes(i):n.includes(i))}function Ln(e,t=Ne){return[...new Set([...t,...Object.keys(e.byIssuer??{})])].filter(i=>dt(e,i).length>0).sort()}function Le(e){if(e.acceptedDocuments)return e.acceptedDocuments;let t=e.acceptedDocumentTypes?.length?[...e.acceptedDocumentTypes]:["carte_identite","passport"];return{default:[],byIssuer:{MR:t}}}var lt=640,pt=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]),Ve=6,Fe=1500,He={sharpness:1,exposure:1,meanLuma:128},De=null;function ft(e,t){try{De??(De=document.createElement("canvas"));let n=De,i=96/Math.max(1,t.width);n.width=Math.max(1,Math.round(t.width*i)),n.height=Math.max(1,Math.round(t.height*i));let r=n.getContext("2d");if(r===null)return He;r.drawImage(e,t.x,t.y,t.width,t.height,0,0,n.width,n.height);let a=r.getImageData(0,0,n.width,n.height);return{sharpness:be(a),exposure:ke(a),meanLuma:_e(a)}}catch{return He}}async function mt(e,t){let n=e.source;return"convertToBlob"in n?n.convertToBlob({type:"image/jpeg",quality:t}):new Promise((i,r)=>{n.toBlob(a=>a===null?r(new Error("encode failed")):i(a),"image/jpeg",t)})}function Gn(e,t={}){let n=t.now??(()=>performance.now()),i=t.setTimer??((m,k)=>setTimeout(m,k)),r=t.clearTimer??(m=>clearTimeout(m)),a=t.encode??mt,d=t.quality??ft,c=e.tuningVersion??null,l=new Set,h=!1,S=e.video??null,w=null,g=t.grabFrame??null,y=null,O=1e3/Ve,E=null,I=null,v=!1,V=!1,D=Number.NEGATIVE_INFINITY,x=null,U=0,F=null,K=null,te=Promise.all([import("./icao-gate-T3BTOKFJ.js"),import("./icao-tuning-4ETMF53W.js"),import("./create-portrait-capture-5VGYZUOK.js"),import("./landmarker-KB7LVXAU.js"),import("./background-monitor-A7FKJOAG.js")]).then(async([m,k,A,T,H])=>{let R=k.resolveIcaoTuning(e.tuning,e.tuningVersion??void 0);R.background.required&&(I=H.createBackgroundMonitor({tuning:R.backgroundCheck,assetBaseUrl:e.assetBaseUrl??"/models-v3",...t.createSegmenter!==void 0?{createSegmenter:t.createSegmenter}:{},now:n})),w=m.createIcaoGate(R,{policy:e.policy??"reject"}),g??(g=A.defaultGrabber()),y=A.observe,O=1e3/Math.min(Ve,R.cadenceHz);let M=(t.createLandmarker??T.createFaceLandmarker)(e.assetBaseUrl??"/models-v3"),o=await new Promise((s,u)=>{let p=setTimeout(()=>{u(new Error("landmarker init timeout")),M.then(f=>f.close(),()=>{})},T.LANDMARKER_INIT_TIMEOUT_MS);M.then(f=>{clearTimeout(p),s(f)},f=>{clearTimeout(p),u(f)})});h?o.close():E=o}).catch(()=>{v=!0}),Z=m=>{for(let k of l)k({holding:V||v,update:m})},G=()=>{if(x=null,!(h||E===null||w===null||g===null||y===null||S===null)){if(n()-D>Fe){Z(null);return}try{let m=g(S,lt);if(m!==null){let k=Math.max(n(),U+1);U=k;let A=E.detect(m.source,k),T=S.videoWidth||m.width,H=S.videoHeight||m.height,R=y(A,m,T,H);R.geometry!==null&&I!==null&&(R.backgroundCheck=I.measure(m,R.geometry.box,T,H));let M=w.push(R,n());V=M.ready,Z(M)}}catch{}x=i(G,O)}},ne=()=>{let m=n()-D>Fe;D=n(),m&&(w?.reset(),V=!1,F=null,K=null),x===null&&E!==null&&!h&&(x=i(G,0))},W=()=>{let m=g===null||S===null?null:g(S,null);if(m===null||w===null||Math.max(m.width,m.height)<e.still.minLongSidePx)return Promise.resolve(null);let k=w.summary();return a(m,e.still.jpegQuality).then(A=>({image:A,width:m.width,height:m.height,gate:k}),()=>null)},Q=null;return{engineOptions:{measureQuality:(m,k)=>{S=m,ne();let A=d(m,k);return V||v?A:{...A,sharpness:0}},telemetry:m=>{if(m.type!=="fired"||h)return;F=W();let k=Q;k!==null&&F.then(A=>A===null?void 0:k(A).catch(()=>{})),V=!1,x!==null&&r(x),x=null,D=Number.NEGATIVE_INFINITY}},decorate:m=>{let k=new WeakMap,A=new Map,T=o=>{let s=k.get(o);return s===void 0&&(s=(async()=>{let u=await Ie(m,"image","image/jpeg",o.image.size,{engine:"portrait"});return await m.uploadToSpaces(u.uploadUrl,o.image,"image/jpeg"),(await m.completeMedia(u.key)).key})(),s.catch(()=>k.delete(o)),k.set(o,s)),s};Q=T;let H=async o=>{let s;try{s=await T(o)}catch(u){let p=u?.code;if(typeof p=="string"&&pt.has(p))throw u;return null}return{media:{portrait:s},gate:Oe(o.gate),...c!==null?{tuningVersion:c}:{}}},R=m.submitCheck.bind(m),M=(async(o,s,u)=>{if(o!=="liveness")return R(o,s,u);let p=u?.idempotencyKey,f=p===void 0?void 0:A.get(p);if(f===void 0){let b=F;f=b===null?Promise.resolve(null):b.then(ye=>ye===null?null:H(ye)),p!==void 0&&(A.set(p,f),f.catch(()=>A.delete(p)))}let _=await f;if(_===null)return R("liveness",s,u);let P=await R("liveness",{...s,portraitIcao:_},u);return K=_,P});return new Proxy(m,{get(o,s){if(s==="submitCheck")return M;let u=Reflect.get(o,s);return typeof u=="function"?u.bind(o):u}})},onGate:m=>(l.add(m),()=>l.delete(m)),lastPortraitInput:()=>K,destroy:()=>{h=!0,F=null,K=null,x!==null&&r(x),x=null,l.clear(),te.then(()=>{E?.close(),E=null,I?.close(),I=null})}}}function Ge(e){return e.idNumberBound??e.nniBound}function Be(e){return e===void 0?void 0:e.idNumberFromDocument??e.nniFromDocument}function Ue(e){let t=e.idNumberMasked??e.nniMasked;return typeof t=="string"&&t!==""?t:void 0}var Ke=Object.freeze({nni_invalid:"id_number_invalid",nni_not_found:"registry_record_not_found",nni_recheck:"id_number_recheck",document_nni_mismatch:"document_id_number_mismatch",nni_locked:"id_number_locked",nni_unbound:"id_number_unbound",missing_nni:"missing_id_number",registry_needs_nni_source:"registry_needs_id_number_source"}),ht=new Map(Object.entries(Ke)),Kn=new Map(Object.entries(Ke).map(([e,t])=>[t,e]));function je(e){return ht.get(e)??e}var C={fullNameMin:2,fullName:200,email:254,occupation:120,shortText:120,longText:1e3,addressLine:120,addressLines:4,city:80,postcode:16,number:1e12,dateMin:"1900-01-01",dateMax:"2100-12-31"},gt=new Set(["full_name","birth_date","email","phone","address","country","occupation"]),St=new Set(["short_text","long_text","single_choice","multiple_choice","yes_no","date","number"]),yt=new Set(["ar","fa","he","ur"]);function qe(e){return yt.has(e.split("-")[0]?.toLowerCase()??"")?"rtl":"ltr"}function Ye(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.locale!="string"||!Array.isArray(t.questions)||t.questions.length===0)return null;let n=t.consents??[];if(!Array.isArray(n))return null;for(let r of t.questions)if(!_t(r))return null;for(let r of n)if(!bt(r))return null;let i={locale:t.locale,questions:t.questions,consents:n};return typeof t.title=="string"&&t.title.trim()!==""&&(i.title=t.title),typeof t.intro=="string"&&t.intro.trim()!==""&&(i.intro=t.intro),typeof t.prefill=="object"&&t.prefill!==null&&!Array.isArray(t.prefill)&&(i.prefill=t.prefill),i}function _t(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.id!="string"||typeof t.required!="boolean"?!1:t.kind==="field"?typeof t.field=="string"&>.has(t.field):t.kind!=="custom"||typeof t.type!="string"||!St.has(t.type)||typeof t.label!="string"?!1:t.type==="single_choice"||t.type==="multiple_choice"?Array.isArray(t.choices)&&t.choices.length>=2&&t.choices.every(n=>typeof n=="object"&&n!==null&&typeof n.value=="string"&&typeof n.label=="string"):!0}function bt(e){if(typeof e!="object"||e===null)return!1;let t=e;if(typeof t.id!="string"||typeof t.required!="boolean"||typeof t.text!="string")return!1;if(t.link===void 0)return!0;let n=t.link;return typeof n=="object"&&n!==null&&typeof n.url=="string"&&/^https:\/\//.test(n.url)&&typeof n.label=="string"}var kt=/^(\d{4})-(\d{2})-(\d{2})$/;function Ct(e){if(typeof e!="string")return!1;let t=kt.exec(e);return t===null?!1:new Date(Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3]))).toISOString().slice(0,10)===e&&e>=C.dateMin&&e<=C.dateMax}function Pt(e){return typeof e=="number"&&Number.isFinite(e)&&Math.abs(e)<C.number&&Math.round(e*100)/100===e}function Ze(e){for(let t of e.matchAll(/\d[\d -]{11,}\d/g)){let n=t[0].replace(/[ -]/g,"");if(n.length>=13&&n.length<=19&&At(n))return!0}return!1}function At(e){let t=0;for(let n=0;n<e.length;n++){let i=Number(e[e.length-1-n]);n%2===1&&(i*=2,i>9&&(i-=9)),t+=i}return t%10===0}var Rt=/^[^\s@]+@[^\s@.]+(\.[^\s@.]+)+$/,wt=/^\+[1-9]\d{6,14}$/,We=/^[A-Z]{2}$/,xt=e=>e===void 0||typeof e=="string"&&e.trim()===""||Array.isArray(e)&&e.length===0;function Qe(e=Date.now()){return new Date(e).toISOString().slice(0,10)}function X(e,t,n=Qe()){let i=[];for(let r of e.questions){let a=t.answers[r.id];if(xt(a)){r.required&&i.push({id:r.id,code:"required"});continue}let d=r.kind==="field"?Et(r.field,a,n):Mt(r,a,n);d!==null&&i.push({id:r.id,...d})}for(let r of e.consents)r.required&&t.consents[r.id]!==!0&&i.push({id:r.id,code:"consent_required"});return i}function z(e,t,n=1){if(typeof e!="string")return{code:"required"};let i=e.trim();return[...i].length>t?{code:"too_long",params:{max:t}}:[...i].length<n?{code:"too_short",params:{min:n}}:Ze(i)?{code:"card_number"}:null}function $e(e,t,n={}){return Ct(e)?n.period==="past"&&e>=t?{code:"date_not_past"}:n.period==="future"&&e<=t?{code:"date_not_future"}:n.min!==void 0&&e<n.min?{code:"date_too_early",params:{date:n.min}}:n.max!==void 0&&e>n.max?{code:"date_too_late",params:{date:n.max}}:null:{code:"date_invalid"}}function Et(e,t,n){switch(e){case"full_name":return z(t,C.fullName,C.fullNameMin);case"occupation":return z(t,C.occupation);case"birth_date":return $e(t,n,{period:"past"});case"email":return typeof t=="string"&&t.trim().length<=C.email&&Rt.test(t.trim())?null:{code:"email_invalid"};case"phone":return typeof t=="string"&&wt.test(t)?null:{code:"phone_invalid"};case"country":return typeof t=="string"&&We.test(t)?null:{code:"choice_invalid"};case"address":return It(t)?null:{code:"address_invalid"};default:return null}}function It(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e,n=Array.isArray(t.lines)?t.lines.filter(i=>typeof i=="string"&&i.trim()!==""):[];return typeof t.country=="string"&&We.test(t.country)&&typeof t.city=="string"&&t.city.trim()!==""&&t.city.trim().length<=C.city&&n.length>=1&&n.length<=C.addressLines&&n.every(i=>i.trim().length<=C.addressLine&&!Ze(i))&&(t.postcode===void 0||typeof t.postcode=="string"&&t.postcode.trim().length<=C.postcode)}function Mt(e,t,n){let i=new Set((e.choices??[]).map(r=>r.value));switch(e.type){case"short_text":return z(t,C.shortText);case"long_text":return z(t,C.longText);case"single_choice":return typeof t=="string"&&i.has(t)?null:{code:"choice_invalid"};case"multiple_choice":return Array.isArray(t)&&t.length>0&&new Set(t).size===t.length&&t.every(r=>i.has(r))?null:{code:"choice_invalid"};case"yes_no":return typeof t=="boolean"?null:{code:"choice_invalid"};case"date":{let r=e.options??{};return $e(t,n,{...typeof r.min=="string"?{min:r.min}:{},...typeof r.max=="string"?{max:r.max}:{},...r.period==="past"||r.period==="future"?{period:r.period}:{}})}case"number":{if(typeof t!="number"||!Number.isFinite(t)||Math.abs(t)>=C.number)return{code:"number_invalid"};let r=e.options??{};return r.integer===!0&&!Number.isInteger(t)?{code:"number_not_integer"}:Pt(t)?typeof r.min=="number"&&t<r.min?{code:"number_too_small",params:{min:r.min}}:typeof r.max=="number"&&t>r.max?{code:"number_too_large",params:{max:r.max}}:null:{code:"number_decimals"}}default:return null}}function Je(e,t,n,i=Qe()){let r=e?.errors;return Array.isArray(r)?r.flatMap(a=>{if(typeof a!="object"||a===null)return[];let{id:d,code:c}=a;return typeof d!="string"||typeof c!="string"?[]:[vt(d,c,t,n)]}):X(t,n,i)}var Ot={full_name:C.fullName,occupation:C.occupation,email:C.email,short_text:C.shortText,long_text:C.longText};function vt(e,t,n,i){let r=n.questions.find(l=>l.id===e),a=r===void 0?void 0:r.kind==="field"?r.field:r.type,d=i.answers[e],c=r!==void 0&&r.kind==="custom"?r.options??{}:{};switch(t){case"required":case"card_number":return{id:e,code:t};case"consent_required":return{id:e,code:"consent_required"};case"too_short":return{id:e,code:t,params:{min:a==="full_name"?C.fullNameMin:1}};case"too_long":{let l=a===void 0?void 0:Ot[a];return l===void 0?{id:e,code:t}:{id:e,code:t,params:{max:l}}}case"not_a_choice":return{id:e,code:"choice_invalid"};case"not_in_past":return{id:e,code:"date_not_past"};case"not_in_future":return{id:e,code:"date_not_future"};case"not_an_integer":return{id:e,code:"number_not_integer"};case"out_of_range":return Tt(e,a,d,c);case"invalid":return r===void 0?n.consents.some(l=>l.id===e)?{id:e,code:"consent_required"}:{id:e,code:t}:{id:e,code:Nt(a,d)};default:return{id:e,code:t}}}function Tt(e,t,n,i){if(t==="date"){let c=typeof i.min=="string"?i.min:void 0,l=typeof i.max=="string"?i.max:void 0;return l!==void 0&&(c===void 0||typeof n=="string"&&n>l)?{id:e,code:"date_too_late",params:{date:l}}:c!==void 0?{id:e,code:"date_too_early",params:{date:c}}:{id:e,code:"date_invalid"}}let r=typeof i.min=="number"?i.min:void 0,a=typeof i.max=="number"?i.max:void 0;return a!==void 0&&(r===void 0||typeof n=="number"&&n>a)?{id:e,code:"number_too_large",params:{max:a}}:r!==void 0?{id:e,code:"number_too_small",params:{min:r}}:{id:e,code:"number_invalid"}}function Nt(e,t){switch(e){case"email":return"email_invalid";case"phone":return"phone_invalid";case"birth_date":case"date":return"date_invalid";case"number":return typeof t=="number"&&Number.isFinite(t)&&Math.abs(t)<C.number?"number_decimals":"number_invalid";case"address":return"address_invalid";case"full_name":case"occupation":case"short_text":case"long_text":return"required";default:return"choice_invalid"}}var Lt=new Set(["phone_otp","email_otp","national_eid","document","nfc","population_registry","supplied_identity","summary_confirm","liveness","portrait","face_match","aml_screening","face_dedup","age_estimation","proof_of_address","form"]),Vt=new Set(["supplied_identity","aml_screening","face_dedup","age_estimation"]),ae=["document","population_registry","national_eid"],ue=["phone_otp","email_otp"],et={identity_method:ae,contact:ue},Ft=["population_registry","document"],ce="platform_unsupported",Ht=new Set(["prefilled","user_entered","prefilled_or_entered"]),Dt={phone_otp:"contact",email_otp:"contact",eid_auth:"identity",doc_ocr:"identity",nfc_chip:"identity",population_registry:"identity",liveness:"live_photo",portrait_icao:"live_photo",face_match:"live_photo",poa:"documents",form:"form"};function L(e){return e.section??Dt[e.checkType]??null}function de(e,t){let n=e.plan?.choice;if(n===void 0||n.locked)return;let i=n.options.find(r=>r.id!==n.selected&&r.available!==!1&&t.includes(r.service));return i===void 0?void 0:{nodeId:n.nodeId,option:i}}function le(e){let t=e.plan,n=t?.choice;if(t===void 0||n===void 0||n.locked||t.current===null||t.current===n.nodeId||re(e))return null;let i=et[n.kind]??[...ae,...ue],r=n.options.flatMap(c=>{if(c.available===!1||!i.includes(c.service))return[];let l=c.nationalEid!=null?{id:c.id,service:c.service,nationalEid:c.nationalEid}:{id:c.id,service:c.service},h=c.countries??(c.nationalEid!=null?[c.nationalEid.country]:void 0);return h!==void 0&&h.length>0&&(l.countries=h),c.names!=null&&Object.keys(c.names).length>0&&(l.names=c.names),[l]}),a=t.steps.find(c=>c.id===t.current)?.service,d=n.selected??r.find(c=>c.service===a)?.id??null;return r.some(c=>c.id!==d)?{nodeId:n.nodeId,kind:n.kind,current:d,options:r}:null}function tt(e){return e==null?[]:e.options.filter(t=>t.id!==e.current)}function Gt(e){let t=e.simulation;if(typeof t!="object"||t===null)return;let{otpCode:n,skipCapture:i}=t;if(typeof n!="string"||n===""||typeof i!="boolean")return;let r=xe(e);return r!==void 0?{otpCode:n,skipCapture:i,reason:r}:{otpCode:n,skipCapture:i}}function Bt(e){let t=e.levelTarget?.max;return typeof t=="number"&&t<=1?"contact":e.purpose??"identity"}function Ut(e){let t=(e.plan?.sections??[]).map(d=>({id:d.id,state:d.state})),n={sessionId:oe(e.sessionId),orgName:e.orgName,sandbox:e.sandbox===!0,returning:e.returning===!0,consentRecorded:e.consentRecorded,expiresAt:e.expiresAt,sections:t.map(d=>d.id),progress:t,purpose:e.purpose??"identity",levelName:Bt(e)};e.branding!==void 0&&(n.branding=e.branding),e.cameraUnavailableHandled===!0&&(n.cameraUnavailableHandled=!0);let i=Gt(e);i!==void 0&&(n.simulation=i);let r=e.testerGate;r?.offered===!0&&typeof r.attemptsLeft=="number"&&r.attemptsLeft>0&&(n.testerGate={attemptsLeft:r.attemptsLeft});let a=le(e);return a!==null&&(n.switchable=a),n}function Kt(e){let t={attemptsRemaining:Pe(e),attemptsExhausted:e.attempts.used>=e.attempts.max};return e.reason!==void 0&&(t.reason=e.reason),e.retakeHint!==void 0&&(t.retakeHint=e.retakeHint),t}var nt={phone_otp:"phone",email_otp:"email"};function jt(e,t){let n=de(e,[t==="phone_otp"?"email_otp":"phone_otp"]);return n===void 0?void 0:nt[n.option.service]}function qt(e,t,n,i){let r=t.checkType==="email_otp",a=(r?t.emailOtp:t.otp)??{},d=r?t.emailOtp?.emailSource:t.otp?.numberSource,c=d!==void 0&&Ht.has(d)?d:r?"prefilled_or_entered":"user_entered",l=typeof a.sentToMasked=="string"&&a.sentToMasked.length>0,h=a.prefilled===!0,S=jt(e,r?"email_otp":"phone_otp"),w={key:t.checkType,context:n,section:L(t),phase:l?"verify":"send",canSwitch:S!==void 0,...i},g=r?{kind:"email_otp",...w,emailSource:c,needsEmail:c!=="prefilled"&&!h}:{kind:"phone_otp",...w,numberSource:c,needsPhone:c!=="prefilled"&&!h,channels:(t.otp?.channels??[]).filter(y=>y==="whatsapp"||y==="sms")};if(S!==void 0&&(g.switchChannel=S),h&&(g.prefilled=!0),l&&(g.sentToMasked=a.sentToMasked),!r&&t.otp?.channel!==void 0&&(g.channel=t.otp.channel),!r&&Array.isArray(t.phoneCountries)&&(g.phoneCountries=t.phoneCountries.filter(y=>typeof y=="string"&&/^[A-Z]{2}$/.test(y))),!r&&Array.isArray(t.phoneRules)){let y=g.phoneCountries??[];g.phoneRules=t.phoneRules.flatMap(O=>{let E=Wt(O);return E!==void 0&&y.includes(E.code)?[E]:[]})}return!r&&t.phoneInternational===!0&&(g.phoneInternational=!0),a.expiresAt!==void 0&&(g.codeExpiresAt=a.expiresAt),a.resendAvailableAt!==void 0&&(g.resendAvailableAt=a.resendAvailableAt),g}var Yt=/^[\d[\]\-|()?:^]{1,64}$/;function Zt(e){try{return typeof e=="string"&&Yt.test(e)&&new RegExp(e)!==null}catch{return!1}}var ze=e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=15;function Wt(e){let{code:t,dial:n,trunk:i,lengths:r,formats:a}=e??{};if(typeof t!="string"||typeof n!="string"||!/^\d{1,3}$/.test(n)||i!==void 0&&(typeof i!="string"||!/^\d{1,3}$/.test(i))||!Array.isArray(r)||r.length===0||!r.every(ze))return;let d={code:t,dial:n,lengths:[...r].sort((c,l)=>c-l)};if(i!==void 0&&(d.trunk=i),a!==void 0){if(!(Array.isArray(a)&&a.length<=8&&a.every(l=>Zt(l?.leading)&&Array.isArray(l.groups)&&l.groups.every(ze)&&r.includes(l.groups.reduce((h,S)=>h+S,0)))))return;d.formats=a.map(l=>({leading:l.leading,groups:[...l.groups]}))}return d}function Qt(e,t,n,i){let r=Ge(e)===!0?"bound":Be(t)===!0?"document":"typed",a=r==="typed"&&t.state==="input_required"&&t.reason!==void 0&&je(t.reason)==="id_number_recheck",d=tt(le(e)),c=!i.attemptsExhausted&&d.length===1&&d[0]?.service==="document";return{kind:"registry",key:"registry",context:n,section:L(t),state:t.state==="input_required"?"input_required":"pending",source:r,recheck:a,canUseDocument:c,...i}}function $t(e,t,n,i,r){let a=[...t.acceptedSides??[]],d={kind:"document",key:"document",context:n,section:L(t),side:a.includes("recto")?"verso":"recto",acceptedSides:a,documents:Le(e),photo:fe(pe(e.documents),r),...i};return e.detectedCountry!==void 0&&(d.detectedCountry=e.detectedCountry),Xt(e)&&(d.ageStepUp=!0),d}function pe(e,t=!0){let n=e?.source==="upload"||e?.source==="choice"?e.source:"camera",i=e?.sourcePick==="camera"||e?.sourcePick==="upload"?e.sourcePick:null;return{source:n,pick:i,uploadOffered:t&&e?.uploadOffered===!0}}function fe(e,t){return t?{...e,cameraOnPhone:!0}:e}var Jt=10*1024*1024;function zt(e,t,n,i,r){let a=e.proofOfAddress,d=a?.pdf?.maxBytes,c=a?.phase==="holder_letter"?"holder_letter":"document";return{kind:"proof_of_address",key:"proof_of_address",context:n,section:L(t),phase:c,rule:a?.rule??{country:null,countryFrom:"global",source:"preset_global",kinds:[]},nameMatch:a?.nameMatch??"exact_person",photo:fe(pe(a),r),maxPages:3,pdf:{maxBytes:typeof d=="number"&&d>0?d:Jt,maxPages:3},licenceAddressAccepted:c==="document"&&a?.licenceAddressAccepted===!0,...i}}function Xt(e){let t=Ce(e).find(i=>i.checkType==="age_estimation"),n=t?.reason;return t?.state==="failed"&&(n==="age_uncertain"||n==="age_unavailable")}function en(e){let t=$(e,"liveness");return t?.state==="passed"||t?.state==="review"}function Xe(e,t,n,i,r,a=!1){let d=t.icao?.report,c=e.portrait,l=r==="capture"?c?.pendingFix??null:null;l!==null&&(r="review");let h=rt(e);return{kind:"portrait",key:`portrait:${r}`,context:n,section:L(t),phase:r,report:Array.isArray(d)?d:null,review:t.state==="review",tuning:e.capture?.icao??null,tuningVersion:e.capture?.tuningVersion??null,icao:J(e),retakeOnly:r==="capture"&&t.state==="input_required"&&h===void 0&&e.capture?.livePhoto?.oneCapture===!0&&en(e),photo:fe(pe(c,r==="capture"),a&&r==="capture"),pendingFix:l,...h!==void 0?{captureMode:h}:{},...c?.reuse?.pending===!0?{reuse:!0}:{},...i}}function rt(e){let t=e.portrait?.captureMode;return t==="self"||t==="assisted"||t==="choice"?t:void 0}var se={minLongSidePx:1280,jpegQuality:.95};function tn(e,t){let n=e.capture?.livePhoto;if(n?.oneCapture!==!0)return null;let i=$(e,"portrait_icao"),r=n.still??se;return{icao:t==="liveness"&&J(e)!==null&&rt(e)===void 0&&i!==void 0&&i.state==="pending"&&i.reason===void 0,still:{minLongSidePx:r.minLongSidePx??se.minLongSidePx,jpegQuality:r.jpegQuality??se.jpegQuality}}}function nn(e,t,n,i){let r=t.eid,a=L(t);if(r===void 0||r.challenge!=="app_code")return{kind:"unsupported",key:"unsupported:eid_auth",context:n,section:a,checkType:"eid_auth",reason:"update_required"};let d=tt(le(e)),c=d.length===1&&Ft.includes(d[0]?.service??"")?d[0]:void 0,l=c===void 0?void 0:q[c.service],h=l!==void 0,S={kind:"eid",key:"eid",context:n,section:a,provider:r.provider,providerName:r.providerName,country:r.country,challenge:"app_code",phase:r.awaiting==="code"?"code":"identifier",identifierBound:r.identifierBound===!0,canUseCamera:h,afterPass:r.afterPass==="continue"?"continue":"end",...i};return h&&(S.cameraMethod=l),r.expiresAt!==void 0&&(S.codeExpiresAt=r.expiresAt),r.resendAvailableAt!==void 0&&(S.resendAvailableAt=r.resendAvailableAt),r.resendsRemaining!==void 0&&(S.resendsRemaining=r.resendsRemaining),r.codeAttemptsRemaining!==void 0&&(S.codeAttemptsRemaining=r.codeAttemptsRemaining),S}function rn(e,t){if(t.checkType!=="face_match"||t.reason!==void 0)return null;let n=$(e,"portrait_icao");return n!==void 0&&(n.state==="passed"||n.state==="review")?n:null}var on={rejected:"rejected",inconclusive:"inconclusive",unavailable:"unavailable",abandoned:"expired",not_opened:"expired",cancelled:"expired",superseded:"expired",policy:"policy"};function sn(e){return e.reasonCode===ce?"platform_unsupported":e.status==="review_pending"?"review":e.status==="verified"?"verified":e.reasonCode==="device_cooldown"?"cooldown":e.reasonCode==="starter_credit_claimed"?"policy":(e.status==="not_verified"&&e.reason!==void 0?on[e.reason]:void 0)??"rejected"}function an(e,t){let n=sn(e),i=n==="platform_unsupported"?{sessionId:oe(e.sessionId),status:"unavailable",reasonCode:ce}:we(e,{autoRetry:!1}),r={kind:"result",key:"result",context:t,section:null,display:n,result:i};return e.status==="not_verified"&&e.reason!==void 0&&(r.reason=e.reason),e.reasonCode!==void 0&&(r.reasonCode=e.reasonCode),e.status==="not_verified"&&e.step!==void 0&&(r.step=e.step),e.retryAfter!==void 0&&(r.retryAfter=e.retryAfter),r}function un(e,t,n){let i=e.identitySummary;if(i==null)return null;let r={kind:"identity_summary",key:"identity_summary",context:t,section:n??"identity",summaryKind:i.kind==="partial"?"partial":i.kind??"full",source:i.source,portraitAvailable:i.portrait?.available===!0,retakeAvailable:i.retakeAvailable===!0};for(let d of cn){let c=i[d];typeof c=="string"&&c!==""&&(r[d]=c)}let a=Ue(i);return a!==void 0&&(r.idNumberMasked=a,r.nniMasked=a),r}var cn=["fullName","birthDate","birthYear","nationality","documentType","documentNumberMasked","expiryDate","retakeTarget"];function B(e,t,n,i){return{kind:"unsupported",key:`unsupported:${n}`,context:e,section:t,checkType:n,reason:i}}function dn(e){return e.kind==="contact"?"contact":(e.kind==="identity_method","identity")}function ln(e,t){let n=et[e.kind]??[...ae,...ue],i=dn(e),r=e.options.flatMap(d=>{if(d.available===!1||!n.includes(d.service))return[];let c={id:d.id,service:d.service};d.nationalEid!=null&&(c.nationalEid=d.nationalEid);let l=(d.channels??[]).filter(h=>h==="whatsapp"||h==="sms");return d.service==="phone_otp"&&l.length>0&&(c.channels=l),[c]});if(r.length===0){let d=e.options.length>0&&e.options.every(c=>c.service==="nfc");return B(t,i,"choice",d?"platform_unsupported":"update_required")}let a={nodeId:e.nodeId,kind:e.kind,selected:e.selected,options:r};if(e.kind==="identity_method"){let d={kind:"method",key:"method",context:t,section:i,options:r.map(l=>q[l.service]),choice:a},c=r.find(l=>l.nationalEid!==void 0)?.nationalEid;return c!==void 0&&(d.nationalEid=c),d}return e.kind==="contact"?{kind:"contact_choice",key:"contact_choice",context:t,section:i,options:r.map(d=>nt[d.service]),selected:null,locked:!1,choice:a}:{kind:"choice",key:`choice:${e.nodeId}`,context:t,section:i,choice:a}}function pn(e,t,n,i){let r=e.nativeApp,a=typeof r=="object"&&r!==null?r:{},d={sekyroApp:a.sekyroApp===!0};return typeof a.link=="string"&&a.link!==""&&(d.link=a.link),d.sekyroApp&&typeof a.sekyroAppLink=="string"&&a.sekyroAppLink.startsWith("sekyro://")&&(d.sekyroAppLink=a.sekyroAppLink),{kind:"native_app_required",key:`native_app_required:${i}`,context:t,section:n,checkType:i,nativeApp:d}}function ee(e,t={}){let n=Ut(e);if(re(e)||e.reasonCode===ce)return an(e,n);let i=e.plan;if(i===void 0||!Array.isArray(i.sections))return B(n,null,"plan","update_required");let r=Ae(e);if(r!==null)return ln(r,n);let a=i.current===null?void 0:i.steps.find(g=>g.id===i.current),d=g=>{let y={kind:"processing",key:"processing",context:n,section:g!==void 0?L(g):i.sections.find(O=>O.state==="current")?.id??null,stalled:!1};return typeof g?.service=="string"&&g.service!==""&&(y.service=g.service),y};if(i.current===null)return d(i.steps.find(g=>g.state==="processing"));if(a===void 0)return B(n,null,"step","update_required");if(!Lt.has(a.service))return a.interaction==="server"?d(a):B(n,L(a),a.service,"update_required");if(Vt.has(a.service)||!Re(a))return d(a);let c=a,l=Kt(c),h=c.checkType,S=L(c);if(c.requiresNativeApp===!0)return pn(e,n,S,h);let w=t.isMobile===!1?Ee(e,c):null;if(w==="phone")return{kind:"mobile_required",key:"mobile_required",context:n,section:S,checkType:h};switch(h){case"phone_otp":case"email_otp":return qt(e,c,n,l);case"population_registry":return Qt(e,c,n,l);case"eid_auth":return nn(e,c,n,l);case"doc_ocr":return $t(e,c,n,l,w==="upload_or_phone");case"identity_confirm":return un(e,n,S)??d(c);case"portrait_icao":return Xe(e,c,n,l,"capture",w==="upload_or_phone");case"liveness":case"face_match":{let g=rn(e,c);if(g!==null)return Xe(e,g,n,l,"match");let y=c.requiresMobile===!0,O=J(e);return{kind:"liveness",key:"biometric",context:n,section:S,mode:h==="face_match"?"selfie":"liveness",requiresMobile:y,instructions:O===null?"standard":"icao",icao:O,livePhoto:tn(e,h),...l}}case"poa":return zt(e,c,n,l,w==="upload_or_phone");case"form":{let g=Ye(c.form);return g===null?B(n,S,h,"update_required"):{kind:"form",key:"form",context:n,section:S,form:g,dir:qe(g.locale),...l}}case"nfc_chip":return B(n,S,h,"platform_unsupported");default:return B(n,S,h,"update_required")}}var fn=/^[A-Z0-9][A-Z0-9 -]{0,39}$/,mn=Object.freeze({normalize:e=>e.trim().toUpperCase().replace(/\s+/g," "),check:e=>fn.test(e),registrySources:Object.freeze([]),describe:"number must be 1 to 40 letters, digits, spaces or hyphens"}),hn=/^[A-Z0-9]{4,20}$/,me=e=>e.trim().toUpperCase().replace(/[\s-]+/g,""),gn=Object.freeze({normalize:me,check:e=>hn.test(me(e)),registrySources:Object.freeze([]),describe:"number must be 4 to 20 letters or digits"});function Sn(e){return typeof e=="string"&&/^\d{10}$/.test(e)&&Number(e)%97===1}var yn={trim:e=>e.trim(),upper_single_space:e=>e.trim().toUpperCase().replace(/\s+/g," "),upper_no_space_or_hyphen:me},_n={mr_nni_mod97:e=>Sn(e)};function bn(e){let t=new RegExp(e.pattern,"u"),n=e.check===null?void 0:_n[e.check];return Object.freeze({normalize:yn[e.normalize],check:i=>t.test(i.trim())&&(n===void 0||n(i)),registrySources:Object.freeze([...e.registrySources]),describe:e.describe})}var kn=Object.freeze(Object.fromEntries(Object.entries(Te).map(([e,t])=>[e,bn(t)])));function he(e,t){return kn[`${e.toUpperCase()}:${t}`]??(t==="drivers_license"?gn:mn)}var Cn=Object.freeze({JPN:"JP",MRT:"MR"});function ot(e,t){let n=e.trim().toUpperCase();return he(Cn[n]??n,t)}function it(e){let t=ot(e.issuingCountry,e.type);return t.check(t.normalize(e.number))}function st(e){return he("MR","national_id").check(e)}function ge(e){let t="";for(let n of e){let i=n.codePointAt(0)??0;i>=1632&&i<=1641?t+=String(i-1632):i>=1776&&i<=1785?t+=String(i-1776):n!==" "&&n!=="-"&&n!==" "&&(t+=n)}return t}var Pn=[1e3,2e3,4e3,8e3,15e3],An=3e4,Rn=/^\+[1-9]\d{6,14}$/,wn=/^\d{6}$/,xn=/^\d{6}$/,En=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,at=new Set(["session_not_active","check_not_found","check_already_finalized","check_out_of_order","identity_confirm_required","identity_confirm_locked","choice_locked","choice_option_unavailable","choice_not_found","step_not_on_path","check_not_active","native_app_required"]),In={simulatedCapture:!0},Mn=new Set(["network_error","timeout","upload_failed","unknown_error","rate_limit_exceeded"]);function pr(e){let t=!1,n=null,i="",r=!1,a=!1,d=!1,c={},l={},h=new Set,S=!1,w=!1,g=null,y="idle",O=new Map,E=new Map,I=(o,s,u)=>{let p=`${o}.${s}`,f=O.get(p);if(f!==void 0)return f;let _=E.get(o),P=(_===void 0?u():_.then(u)).finally(()=>{O.delete(p)});O.set(p,P);let b=P.then(()=>{},()=>{});return E.set(o,b),b.then(()=>{E.get(o)===b&&E.delete(o)}),P},v=async(o,s,u)=>{await e.ensureConsent();let p;try{p=await Me(e.runtime,s)}catch(_){if(_ instanceof j&&at.has(_.code)){await e.refreshView();return}throw _}if(u?.(p),e.destroyed())return;let f=p;f.plan!==void 0&&e.setView!==void 0?e.setView(f):await e.refreshView()},V=async o=>{await e.ensureConsent();let s;try{try{s=await o(e.runtime.client)}catch(u){if(!(u instanceof j)||u.code!=="consent_required")throw u;await e.runtime.ensureConsent({force:!0}),s=await o(e.runtime.client)}}catch(u){if(u instanceof j&&at.has(u.code)){await e.refreshView();return}throw u}e.destroyed()||(s!==void 0&&e.setView!==void 0?e.setView(s):await e.refreshView())},D=(o,s)=>I("choice",`${o}:${s}`,()=>V(u=>u.choose(o,s))),x=(o,s)=>o.options.some(u=>u.id===s)?D(o.nodeId,s):Promise.reject(new RangeError(`option ${String(s)} is not offered`)),U=(o,s)=>{let u=e.currentView(),p=u===null?void 0:de(u,o);return p===void 0?Promise.reject(new RangeError(`the ${s} is not offered`)):D(p.nodeId,p.option.id)},F=o=>I("identity",o,()=>V(s=>s.confirmIdentity===void 0?Promise.reject(new Error("identity confirmation is not available in this build")):s.confirmIdentity(o))),K=(o,s)=>{let u=X(o.form,s);if(u.length>0)return Promise.reject(new ie(u,"client"));let p={answers:{...s.answers},consents:{}};for(let f of o.form.consents)p.consents[f.id]=s.consents[f.id]===!0;return I("form","submit",()=>v("form",(f,_)=>f.submitCheck("form",p,{idempotencyKey:_})).catch(f=>{throw f instanceof j&&f.code===ve?new ie(Je(f.details,o.form,p),"server"):f}))},te=(o,s)=>{let u=o.kind,p=u==="phone_otp",f=p?"phone":"email",_={action:"send"};if(p?o.needsPhone:o.needsEmail){let P=s[f]??l[u],b=p?P?.replace(/[\s().-]/g,""):P?.trim();if(b!==void 0||o.phase!=="verify"){if(b===void 0||!(p?Rn:En).test(b))return Promise.reject(p?new N("phone","format"):new Y("email","format"));_[f]=b}}if(p){let P=o.channels,b=s.channel??(P.length===1?P[0]:void 0);if(P.length>0){if(b===void 0)return Promise.reject(new Y("channel","required"));if(!P.includes(b))return Promise.reject(new Y("channel","unavailable"))}b!==void 0&&(_.channel=b),_.phoneRules=1}return I(u,"send",()=>v(u,(P,b)=>P.submitCheck(u,_,{idempotencyKey:b}),P=>{vn(P,u)||(c[u]=e.now(),_[f]!==void 0&&(l[u]=_[f]))}))},Z=(o,s)=>wn.test(s)?I(o,"verify",()=>v(o,(u,p)=>u.submitCheck(o,{action:"verify",code:s},{idempotencyKey:p}))):Promise.reject(new N("code","format")),G=(o,s)=>I("eid_auth",o,()=>v("eid_auth",(u,p)=>u.submitCheck("eid_auth",s,{idempotencyKey:p}))),ne=(o,s)=>{if(o.identifierBound)return G("start",{action:"start"});let u=ge(s??"");if(o.country==="MR"){if(!/^\d{10}$/.test(u))return Promise.reject(new N("nni","format"));if(!st(u))return Promise.reject(new N("nni","check_digit"))}else if(u==="")return Promise.reject(new N("nni","format"));return G("start",{action:"start",identifier:u})},W=(o,s,u)=>{if(o.source!=="typed")return Promise.reject(new RangeError("this session already holds the ID number"));let p=ge(s);return/^\d{10}$/.test(p)?it({type:"national_id",issuingCountry:"MR",number:p})?I("population_registry","submitIdNumber",()=>v("population_registry",(f,_)=>f.submitCheck("population_registry",{idNumber:p,nni:p},{idempotencyKey:_}),()=>{g=`\u2022\u2022\u2022\u2022\u2022\u2022${p.slice(-4)}`})):Promise.reject(new N(u,"check_digit")):Promise.reject(new N(u,"format"))},Q=o=>(e.stopCameras?.(),I(o,"skipCapture",()=>v(o,(s,u)=>s.submitCheck(o,In,{idempotencyKey:u}),()=>{(o==="liveness"||o==="portrait_icao")&&(S=!0)}))),Se=o=>{if(o.kind==="result"||o.context.simulation?.skipCapture!==!0)return o;let s=On(o);return s===null?o:{...o,skipCapture:()=>Q(s)}},m=o=>((o.kind==="document"||o.kind==="portrait"||o.kind==="proof_of_address")&&o.photo?.cameraOnPhone===!0&&(o.refresh=async()=>{await e.refreshView()}),o),k=o=>{switch(o.kind){case"phone_otp":case"email_otp":{let s={...o,send:(p={})=>te(o,p),verify:p=>Z(o.kind,p),switchTo:()=>o.canSwitch&&o.switchChannel!==void 0?U([o.switchChannel==="email"?"email_otp":"phone_otp"],"other contact option"):Promise.reject(new RangeError("this session has no other contact option"))},u=c[o.kind];return s.resendAvailableAt===void 0&&u!==void 0&&(s.resendAvailableAt=new Date(u+An).toISOString()),s}case"eid":return{...o,start:s=>ne(o,s),verify:s=>xn.test(s)?G("verify",{action:"verify",code:s}):Promise.reject(new N("code","format")),resend:()=>o.resendsRemaining===0?Promise.reject(new RangeError("no new code can be sent for this session")):G("resend",{action:"resend"}),useCamera:()=>o.canUseCamera&&o.cameraMethod!==void 0?U(o.cameraMethod==="document_photo"?["document"]:["population_registry"],"camera path"):Promise.reject(new RangeError("the camera path is not offered"))};case"method":return{...o,select:s=>{let u=o.choice.options.find(p=>q[p.service]===s);return u!==void 0?x(o.choice,u.id):Promise.reject(new RangeError(`method ${String(s)} is not offered`))},choose:s=>x(o.choice,s)};case"choice":return{...o,choose:s=>x(o.choice,s)};case"registry":return{...o,submitIdNumber:s=>W(o,s,"idNumber"),submitNni:s=>W(o,s,"nni"),confirm:()=>I("population_registry","confirm",()=>v("population_registry",(s,u)=>s.submitCheck("population_registry",{},{idempotencyKey:u}))),useDocument:()=>o.canUseDocument?U(["document"],"document method"):Promise.reject(new RangeError("the document method is not offered"))};case"document":return e.bindDocument!==void 0?m(e.bindDocument(o,M)):{...o,issuer:null,documentType:null,captureSide:null,selectDocument:()=>{throw new Error("document capture is not available in this build")},capture:()=>{throw new Error("document capture is not available in this build")},uploadDocument:()=>Promise.reject(new Error("document upload is not available in this build"))};case"portrait":return e.bindPortrait!==void 0?m(e.bindPortrait(o,M)):{...o,uploadFailed:!1,resubmit:()=>Promise.resolve(),capture:()=>{throw new Error("portrait capture is not available in this build")},uploadPortrait:()=>Promise.reject(new Error("portrait upload is not available in this build")),confirmFix:()=>Promise.reject(new Error("portrait review is not available in this build"))};case"proof_of_address":return e.bindProofOfAddress!==void 0?m(e.bindProofOfAddress(o,M)):{...o,uploadPages:()=>Promise.reject(new Error("proof of address upload is not available in this build")),uploadHolderLetter:()=>Promise.reject(new Error("proof of address upload is not available in this build")),capturePage:()=>{throw new Error("proof of address capture is not available in this build")}};case"form":return{...o,validate:s=>X(o.form,s),submit:s=>K(o,s)};case"contact_choice":return{...o,select:s=>{let u=s==="phone"?"phone_otp":s==="email"?"email_otp":void 0,p=o.choice.options.find(f=>f.service===u);return p!==void 0?x(o.choice,p.id):Promise.reject(new RangeError(`contact ${String(s)} is not offered`))},choose:s=>x(o.choice,s)};case"identity_summary":return{...o,...o.idNumberMasked===void 0&&o.summaryKind==="partial"&&g!==null?{idNumberMasked:g,nniMasked:g}:{},portrait:async()=>{let s=e.runtime.client;if(!o.portraitAvailable||s.identityPortrait===void 0)return null;try{return await s.identityPortrait()}catch{return null}},confirm:()=>F("confirm"),retake:()=>o.retakeAvailable?F("retake"):Promise.reject(new RangeError("no retake is left"))};case"liveness":return{...o,capture:s=>e.liveness(s),onLivePhoto:s=>o.livePhoto?.icao===!0&&e.onLivePhoto!==void 0?e.onLivePhoto(s):()=>{}};case"mobile_required":case"native_app_required":case"processing":return{...o,refresh:async()=>{r=!1,await e.refreshView()}};case"unsupported":case"result":return{...o};default:{let s=o;throw new Error(`runner: unhandled step ${JSON.stringify(s)}`)}}},A=o=>Se(k(o)),T=async()=>{if(!a){a=!0;try{for(let o of Pn){if(await e.sleep(o),!t||e.destroyed())return;let s=await e.refreshView().catch(()=>null);if(s!==null&&ee(s,{isMobile:e.isMobile()}).kind!=="processing")return}r=!0,M()}finally{a=!1}}},H=o=>{if(o.kind!=="liveness"||o.mode!=="selfie")return null;let s={kind:"processing",key:"processing",context:o.context,section:o.section,stalled:!1};if(y==="inflight")return s;if(!w||y==="done")return null;let u=e.keptFaceKey?.()??null;return u===null?null:(y="inflight",v("face_match",(p,f)=>p.submitCheck("face_match",{imageKey:u},{idempotencyKey:f}),()=>{y="done"}).then(()=>{y==="inflight"&&(y="done",M())},()=>{y="done",M()}),s)},R=(o,s=!1)=>{if(!t||e.destroyed()||e.chainBusy())return;let u=ee(o,{isMobile:e.isMobile()});u.kind==="registry"&&u.recheck&&(w=!0,y="idle"),u=H(u)??u,u.kind==="processing"?u.stalled=r:r=!1;let p=A(u),f=u.kind==="result"?void 0:u.context.switchable,_=f===void 0?p:{...p,chooseOption:b=>x({nodeId:f.nodeId,kind:f.kind,selected:f.current,options:f.options},b)},P=JSON.stringify(_);u.kind==="registry"&&u.source==="document"&&u.state==="pending"&&!h.has("registry")&&(h.add("registry"),_.confirm().catch(b=>{(!(b instanceof j)||Mn.has(b.code))&&h.delete("registry")})),!(!s&&P===i)&&(i=P,n=_,e.emitStep(_),u.kind==="processing"&&!r&&y!=="inflight"&&T(),u.kind==="result"&&!d&&(d=!0,e.emitResult(u.result)))};function M(){let o=e.currentView();o!==null&&R(o,!0)}return{run:async()=>{if(e.destroyed())throw new Error("verification destroyed");t=!0;let o=await e.ensureView();return n===null&&R(o),n??A(ee(o,{isMobile:e.isMobile()}))},current:()=>n,onView:o=>R(o),onChainIdle:()=>{let o=e.currentView();o!==null&&R(o)},republish:M,submit:v,faceProbeSkipped:()=>S}}function On(e){switch(e.kind){case"document":return"doc_ocr";case"liveness":return e.mode==="selfie"?"face_match":"liveness";case"portrait":return e.phase==="capture"?"portrait_icao":null;case"proof_of_address":return"poa";case"mobile_required":case"native_app_required":return e.checkType;case"unsupported":return e.checkType==="nfc_chip"?"nfc_chip":null;default:return null}}function vn(e,t){let n=e,i=n?.plan?.steps??n?.steps;return Array.isArray(i)?i.some(r=>r.checkType===t&&typeof r.reason=="string"):!1}export{dt as a,Ln as b,Ve as c,Fe as d,Gn as e,rt as f,ee as g,Pn as h,An as i,pr as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var p=Object.freeze({EDGE_LUMA_DELTA:40,MIN_ROW_DENSITY:.08,MIN_COLUMN_COVERAGE:.6,MIN_WIDTH_FRAC:.55,MIN_HEIGHT_FRAC:.02,MAX_HEIGHT_FRAC:.16,ROW_MERGE_GAP:18}),I=12;function F(H,D={}){let r={...p,...D},{data:s,width:n,height:t}=H;if(n<32||t<32)return null;let c=new Array(t).fill(!1),R=new Float32Array(t),u=new Int32Array(t).fill(n),a=new Int32Array(t).fill(-1),w=n/I,d=new Array(I);for(let e=0;e<t;e++){let M=0;d.fill(!1);let E=e*n*4,G=.299*(s[E]??0)+.587*(s[E+1]??0)+.114*(s[E+2]??0);for(let o=1;o<n;o++){let T=E+o*4,y=.299*(s[T]??0)+.587*(s[T+1]??0)+.114*(s[T+2]??0);Math.abs(y-G)>=r.EDGE_LUMA_DELTA&&(M+=1,d[Math.min(I-1,Math.floor(o/w))]=!0,o<u[e]&&(u[e]=o),o>a[e]&&(a[e]=o)),G=y}R[e]=M/n;let O=d.filter(Boolean).length/I;c[e]=R[e]>=r.MIN_ROW_DENSITY&&O>=r.MIN_COLUMN_COVERAGE&&a[e]-u[e]>=r.MIN_WIDTH_FRAC*n}let _=null,l=-1,f=-1,i=0,N=e=>{if(l<0)return;let M=e-l+1;M>=r.MIN_HEIGHT_FRAC*t&&M<=r.MAX_HEIGHT_FRAC*t&&i>=4&&(_===null||i>_.rows)&&(_={top:l,bottom:e,rows:i}),l=-1,i=0};for(let e=0;e<t;e++)c[e]&&(l<0?l=e:e-f>r.ROW_MERGE_GAP&&(N(f),l=e),f=e,i+=1);if(N(f),_===null)return null;let b=_,m=n,A=-1,C=0,h=0;for(let e=b.top;e<=b.bottom;e++)c[e]&&(u[e]<m&&(m=u[e]),a[e]>A&&(A=a[e]),C+=R[e],h+=1);return A-m<r.MIN_WIDTH_FRAC*n?null:{x:m,y:b.top,width:A-m,height:b.bottom-b.top+1,density:h>0?C/h:0}}export{p as a,F as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{p as k,r as w}from"./chunk-CPUECYAJ.js";import{e as M}from"./chunk-TSA6GHUG.js";var u=class extends Error{constructor(){super("the back camera could not be opened");this.name="BackCameraUnavailableError"}},S=new Set(["NotAllowedError","PermissionDeniedError","SecurityError"]);function h(r){try{return String(r?.name??"")}catch{return""}}function c(r){if(r!==null)for(let t of r.getTracks())t.stop()}async function C(r,t,n){let a=e=>({video:{...t,...e},audio:!1});if(r==="user")return n.getUserMedia(a({facingMode:"user"}));let o=e=>M(e)!=="user";try{let e=await n.getUserMedia(a({facingMode:{exact:"environment"}}));if(o(e))return e;c(e)}catch(e){if(S.has(h(e)))throw e}let d=!1,l=async()=>{if(n.enumerateDevices===void 0||d)return null;let e;try{e=w(await n.enumerateDevices()).slice(0,3)}catch{return null}d=e.length>0;for(let v of e){let i;try{i=await n.getUserMedia(a({deviceId:{exact:v}}))}catch(g){if(S.has(h(g)))throw g;continue}if(o(i))return i;c(i)}return null},m=await l();if(m!==null)return m;let s=await n.getUserMedia(a({facingMode:"environment"}));if(o(s))return s;c(s);let f=await l();if(f!==null)return f;throw new u}export{u as a,C as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function c(e,n){return{video:{width:{ideal:1280,max:1280},height:{ideal:720,max:720},facingMode:n,frameRate:{ideal:24,max:30}},audio:!1}}var o=600;function i(){if(typeof window>"u"||typeof navigator>"u")return"desktop";let e=navigator.userAgentData,n=e?.mobile||/Android|i(Pad)?OS/.test(String(e?.platform)),t=String(navigator.userAgent??"");if(/iPhone|iPod/i.test(t))return"phone";if(/iPad/i.test(t))return"tablet";if(/Android/i.test(t))return/Mobile/i.test(t)?"phone":"tablet";if(/BlackBerry|IEMobile|Opera Mini/i.test(t))return"phone";if(!n){if(Number(navigator.maxTouchPoints??0)<=1)return"desktop";if(/Macintosh/.test(t))return"tablet";if(/Windows NT|CrOS/.test(t)||!s())return"desktop"}let r=a();return r>0&&r<o?"phone":"tablet"}function u(){return i()!=="desktop"}function a(){try{let e=window.screen,n=Number(e?.width??0),t=Number(e?.height??0);return n>0&&t>0?Math.min(n,t):0}catch{return 0}}function d(e){try{let t=e?.getVideoTracks?.()[0]?.getSettings?.().facingMode;return t==="user"||t==="environment"?t:null}catch{return null}}function s(){try{return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}catch{return!1}}var l=.45,f=.9,p=.4;export{c as a,o as b,i as c,u as d,d as e,l as f,f as g,p as h};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var A=["magenta","yellow","green","blue"];var E={magenta:"rgb(255, 72, 150)",yellow:"rgb(255, 190, 0)",green:"rgb(0, 238, 175)",blue:"rgb(25, 150, 255)",dark:"rgb(0, 0, 0)"};function P(l){return E[l]}var T=4,v=4,R=l=>typeof l=="number"&&Number.isFinite(l);function _(l){if(typeof l!="object"||l===null)return!1;let e=l;if(typeof e.nonce!="string"||e.nonce.length===0||!Array.isArray(e.colours)||e.colours.length<1||e.colours.length>8||!e.colours.every(r=>A.includes(r))||!Array.isArray(e.onsetsMs)||e.onsetsMs.length!==e.colours.length)return!1;let o=-1;for(let r of e.onsetsMs){if(!R(r)||r<0||r<=o)return!1;o=r}return!(!R(e.holdMs)||e.holdMs<=0||!R(e.endMs)||e.endMs<=o||!R(e.clipMs)||e.clipMs<e.endMs||e.clipMs>8e3)}function O(l,e){return _(l)?Math.max(e,Math.ceil(l.clipMs)):e}function w(l,e){let o=e.now??(()=>performance.now()),r=_(l)?l:void 0,a=[],u=null,d=null,M=null,i=!1,m=null,s=n=>{m=n;try{e.paint(n)}catch{}},p=n=>{let t=e.frames?.()??null;return t!==null&&M!==null?t.mediaTimeMs+(n-t.presentationTimeMs)-M:n-(d??n)},f=(n,t,c=0)=>{if(i)return;let g=Math.max(0,n-p(o()));u=setTimeout(()=>{if(u=null,!i){if(c<T&&p(o())<n-v){f(n,t,c+1);return}t()}},g)},S=n=>{if(r===void 0)return;let t=r.endMs;if(n>=r.colours.length){f(t,()=>s(null));return}let c=r.onsetsMs[n],g=n+1<r.onsetsMs.length?r.onsetsMs[n+1]:t;f(c,()=>{let h=p(o());if(h>t){m!==null&&s(null);return}let b=r.colours[n];s(b);let y=a.length===0?0:a[a.length-1].tMs;a.push({tMs:Math.max(y,Math.round(h)),colour:b});let C=c+r.holdMs;if(C<g){f(C,()=>{if(p(o())>t){m!==null&&s(null);return}s("dark"),S(n+1)});return}S(n+1)})};return{started(n){if(r===void 0||i||d!==null)return;d=n;let t=e.frames?.()??null;M=t===null?null:t.mediaTimeMs+(n-t.presentationTimeMs),S(0)},stop(){i||(i=!0,u!==null&&clearTimeout(u),u=null,m!==null&&s(null))},report(){return r===void 0?void 0:{nonce:r.nonce,rendered:[...a]}}}}export{A as a,P as b,_ as c,O as d,w as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var u=["obs","manycam","virtual","snap camera","xsplit","droidcam","iriun","camo","fake_device","fake-capture-device"],l=[/^(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 c(n){let e=(n??"").trim().toLowerCase();return e.length===0?"unknown":u.some(t=>e.includes(t))?"known_virtual":l.some(t=>t.test(e))?"platform":"unknown"}var d=1e3;function m(n,e){return new Promise(t=>{let a=setTimeout(()=>t(void 0),e),r=s=>{clearTimeout(a),t(s)};try{n().then(r,()=>r(void 0))}catch{r(void 0)}})}async function f(n){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(JSON.stringify(n)));return Array.from(new Uint8Array(e).subarray(0,8),t=>t.toString(16).padStart(2,"0")).join("")}var i=n=>Array.isArray(n)?[...n].sort():null,o=n=>{let e=n;return e==null?null:[e.min??null,e.max??null]};function p(n){try{return n.getSettings?.().facingMode==="environment"}catch{return!1}}async function b(n){try{if(n.readyState==="ended"||p(n))return;let e={};try{e=n.getCapabilities?.()??{}}catch{}let t=await m(()=>navigator.mediaDevices.enumerateDevices(),d);return await f([o(e.width),o(e.height),o(e.frameRate),i(e.facingMode),i(e.focusMode),i(e.exposureMode),c(n.label),t?.filter(a=>a.kind==="videoinput").length??null])}catch{return}}async function v(n,e){let t=await b(n);t&&e.noteCamera(t)}export{m as a,f as b,b as c,v as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as G,e as me,g as fe,m as he}from"./chunk-53POX7U4.js";import{b as ge}from"./chunk-33KKMPJ5.js";import{a as pe,d as ye}from"./chunk-CJHMFPL6.js";import{a as be}from"./chunk-RI3E7GBN.js";import{a as ce,d as ue,e as K,f as le,g as de}from"./chunk-7QZWBDI5.js";import{a as V,b as se}from"./chunk-SX7TUC3V.js";import{k as N,m as oe,n as ie}from"./chunk-CPUECYAJ.js";import{e as ae}from"./chunk-TSA6GHUG.js";var Ee=250,Ie=180,Re=96;function xe(n){let{data:e,width:t,height:a}=n,r=new Uint8Array(t*a);for(let o=0,s=0;o<r.length;o+=1,s+=4)r[o]=Math.round(.299*(e[s]??0)+.587*(e[s+1]??0)+.114*(e[s+2]??0));return{data:r,width:t,height:a}}function W(n,e){return{x0:Math.max(0,Math.floor(n.x)),y0:Math.max(0,Math.floor(n.y)),x1:Math.min(e.width,Math.ceil(n.x+n.width)),y1:Math.min(e.height,Math.ceil(n.y+n.height))}}function T(n,e,t){let a=W(e,n),r=t===void 0?null:W(t,n),o=0,s=0,l=0,m=0;for(let c=a.y0;c<a.y1;c+=1)for(let b=a.x0;b<a.x1;b+=1){if(r!==null&&b>=r.x0&&b<r.x1&&c>=r.y0&&c<r.y1)continue;let L=n.data[c*n.width+b];o+=1,s+=L,l+=L*L,L>=Ee&&(m+=1)}if(o===0)return{mean:0,sd:0,clipped:0,count:0};let d=s/o;return{mean:d,sd:Math.sqrt(Math.max(0,l/o-d*d)),clipped:m/o,count:o}}function ve(n){let{box:e}=n,a=(n.leftEye.y+n.rightEye.y)/2-.1*e.height,r=e.y+.85*e.height;return{x:e.x+.15*e.width,y:a,width:.7*e.width,height:Math.max(1,r-a)}}function Be(n,e){let t=ve(e),a=T(n,t);if(a.count===0)return null;let r=Math.min(Math.max(e.nose.x,t.x+1),t.x+t.width-1),o=T(n,{x:t.x,y:t.y,width:r-t.x,height:t.height}),s=T(n,{x:r,y:t.y,width:t.x+t.width-r,height:t.height}),l=s.mean>0?o.mean/s.mean:o.mean>0?Number.POSITIVE_INFINITY:1;return{faceLuma:a.mean,halfRatio:l,clipped:a.clipped}}function Ge(n,e){let t=0,a=0;for(let r of[e.leftEyeBox,e.rightEyeBox]){let o=r.width*.15,s=r.height*.5,l=T(n,{x:r.x-o,y:r.y-s,width:r.width+2*o,height:r.height+2*s});t+=l.count,a+=l.clipped*l.count}return t===0?null:a/t}function Ae(n,e){let t=me(e),{box:a}=e,r={x:a.x-.2*a.width,y:t.y,width:1.4*a.width,height:a.y+a.height-t.y},o=0,s=0,l=0;for(let d of[t.x,t.x+.8*t.width]){let c=T(n,{x:d,y:t.y+.04*t.height,width:.2*t.width,height:.25*t.height},r);o+=c.count,s+=c.mean*c.count,l+=(c.sd*c.sd+c.mean*c.mean)*c.count}if(o===0)return null;let m=s/o;return{luma:m,sd:Math.sqrt(Math.max(0,l/o-m*m)),count:o}}function Oe(n,e){let t=W(ve(e),n),a=Math.max(1,Math.floor(Math.max(t.x1-t.x0,t.y1-t.y0)/Re)),r=(d,c)=>n.data[c*n.width+d],o=0,s=0,l=0;for(let d=t.y0+a;d<t.y1-a;d+=a)for(let c=t.x0+a;c<t.x1-a;c+=a){let b=r(c,d-a)+r(c-a,d)+r(c+a,d)+r(c,d+a)-4*r(c,d);o+=1,s+=b,l+=b*b}if(o===0)return null;let m=s/o;return Math.min(1,Math.max(0,l/o-m*m)/Ie)}function we(n,e){return{lighting:Be(n,e),eyeSpecular:Ge(n,e),background:Ae(n,e),sharpness:Oe(n,e)}}var Ue="/models-v3",De=640,_e=.92;function Y(n){return{width:n.videoWidth||0,height:n.videoHeight||0}}function j(n,e){if(typeof document<"u"){let t=document.createElement("canvas");return t.width=n,t.height=e,t}return typeof OffscreenCanvas=="function"?new OffscreenCanvas(n,e):null}function He(){let n=null;return(e,t)=>{let{width:a,height:r}=Y(e);if(a===0||r===0)return null;let o=t===null?1:Math.min(1,t/Math.max(a,r)),s=Math.round(a*o),l=Math.round(r*o),m;t===null?m=j(s,l):((n===null||n.width!==s||n.height!==l)&&(n=j(s,l)),m=n);let d=m?.getContext("2d",{willReadFrequently:!0});if(m==null||d==null)return null;d.drawImage(e,0,0,s,l);let c=null;try{c=d.getImageData(0,0,s,l)}catch{c=null}return{source:m,width:s,height:l,pixels:c}}}async function qe(n,e,t,a){let r=Math.round(t*e.width/e.height),o=j(r,t),s=o?.getContext("2d");if(o==null||s==null)throw new Error("canvas unavailable");return s.fillStyle="#fff",s.fillRect(0,0,r,t),s.drawImage(n.source,e.x,e.y,e.width,e.height,0,0,r,t),"convertToBlob"in o?o.convertToBlob({type:"image/jpeg",quality:a}):new Promise((l,m)=>{o.toBlob(d=>d===null?m(new Error("encode failed")):l(d),"image/jpeg",a)})}var z=class extends Error{};function Ne(n,e,t){return new Promise((a,r)=>{let o=setTimeout(()=>{r(new z(`init exceeded ${e}ms`)),n.then(t,()=>{})},e);n.then(s=>{clearTimeout(o),a(s)},s=>{clearTimeout(o),r(s)})})}function Ve(n){if(n instanceof V)return{kind:"notfound",retryable:!0,detail:{name:n.name,phase:"acquiring",engineKind:"backcamera"}};let e=oe(n),t=e==="overconstrained"?"generic":e,a=N(n);return{kind:t,retryable:t!=="insecure"&&t!=="unsupported",detail:{...a!==void 0?{name:a}:{},phase:"acquiring",engineKind:e}}}function Ke(n,e,t,a){let r=n.length===1?n[0]:void 0,o=r===void 0?null:G(r.landmarks,t,a),s=null;if(r!==void 0&&e.pixels!==null){let l=G(r.landmarks,e.width,e.height),m=xe(e.pixels);l!==null&&(s=we(m,l))}return{frameWidth:t,frameHeight:a,faces:n.length,geometry:o,matrix:r?.matrix??null,blendshapes:r?.blendshapes??null,stats:s}}function ct(n,e={},t=()=>"self",a){let r=ge(n.tuning,n.tuningVersion),o=ce(),s=e.now??(()=>performance.now()),l=e.setTimer??((i,u)=>setTimeout(i,u)),m=e.clearTimer??(i=>clearTimeout(i)),d=e.grabFrame??He(),c=e.encodeRegion??qe,b=e.getUserMedia??(i=>navigator.mediaDevices.getUserMedia(i)),L=e.enumerateDevices??(e.getUserMedia===void 0&&typeof navigator<"u"&&typeof navigator.mediaDevices?.enumerateDevices=="function"?()=>navigator.mediaDevices.enumerateDevices():void 0),Ce=e.createLandmarker??ye,J=n.assetBaseUrl??Ue,Q=de({enabled:n.keepScreenAwake!==!1}),S=he(r,{policy:n.policy??"reject"}),w=n.video,X=be({tuning:r.backgroundCheck,assetBaseUrl:J,...e.createSegmenter!==void 0?{createSegmenter:e.createSegmenter}:{},now:s}),f="idle",C=null,x=null,E=null,A=!1,g=!1,p=0,$=0,O=[],v="user",U=le(),Z=!1,ke=e.canChooseFacing??ue,k=i=>{f===i||g||(f=i,Q.setActive(i==="starting"||i==="gating"),o.emit("state",i))},D=()=>{E!==null&&m(E),E=null},I=()=>{D();for(let i of C?.getTracks()??[])i.stop();C=null;try{w.srcObject=null}catch{}},_=i=>{I(),k("error"),o.emit("error",i)},ee=()=>{let i=Math.max(s(),$+1);return $=i,i},Me=async i=>{let u=d(w,null),{width:M,height:P}=u??Y(w);if(u===null||x===null){S.reset();return}let h=x.detect(u.source,ee()),y=(h.length===1?h:O.length===1?O:[])[0],F=y===void 0?null:G(y.landmarks,M,P);if(F===null){S.reset();return}let B=fe(F,M,P,{margin:r.cropMargin,minWidth:r.resolution.minWidth,minHeight:r.resolution.minHeight}),q=Math.max(r.resolution.minHeight,B.height),Te=await c(u,B,q,_e);if(g||i!==p)return;let re={image:Te,width:Math.round(q*B.width/B.height),height:q,gate:S.summary(),facingMode:v};r.tuningVersion!==null&&(re.tuningVersion=r.tuningVersion),D(),k("captured"),o.emit("captured",re)},H=async i=>{if(!(g||i!==p||f!=="gating"||x===null)){if(!A){A=!0;try{let u=d(w,De);if(u!==null){let{width:M,height:P}=Y(w),h=x.detect(u.source,ee());O=h;let y=Ke(h,u,M||u.width,P||u.height);y.geometry!==null&&r.background.required&&(y.backgroundCheck=X.measure(u,y.geometry.box,M||u.width,P||u.height));let F=S.push(y,s());if(g||i!==p||(o.emit("gate",F),F.ready&&(await Me(i),f!=="gating")))return}}catch{}finally{A=!1}}!g&&i===p&&f==="gating"&&(E=l(()=>{H(i)},1e3/r.cadenceHz))}},Pe=()=>Ne(Ce(J),2e4,i=>i.close()),Le=i=>{let u=t()==="assisted"?"assisted":"self";return Z||U.facing(u,n.facing),U.facing(u,i)},te=!1;function Se(){return te||a===void 0||a.session()!=="choice"||t()!=="assisted"?!1:(te=!0,a.onModeChange("self"),v=K("self"),k("mode_switch"),R({facing:v}),!0)}let R=async i=>{if(g||f==="starting"||f==="gating")return;p+=1;let u=p;S.reset(),k("starting");let M=Le(i?.facing);if(C!==null&&M!==v&&I(),v=M,Z=!0,C===null&&e.getUserMedia===void 0&&(typeof navigator>"u"||typeof navigator.mediaDevices?.getUserMedia!="function")){let h=typeof window<"u"&&window.isSecureContext===!1?"insecure":"unsupported";_({kind:h,retryable:!1,detail:{phase:"preflight",engineKind:h}});return}let P=x!==null?Promise.resolve(x):Pe();P.catch(()=>{});try{if(C===null){let h=await se(v,{width:{ideal:r.camera.width},height:{ideal:r.camera.height}},{getUserMedia:b,...L!==void 0?{enumerateDevices:L}:{}});if(g||u!==p){for(let y of h.getTracks())y.stop();return}C=h,ie(h),v=ae(h)??v,w.srcObject=C,w.muted=!0,w.playsInline=!0,await w.play().catch(()=>{})}}catch(h){if(g||u!==p||h instanceof V&&Se())return;_(Ve(h));return}try{x=await P}catch(h){if(!g&&u===p){let y=N(h);_({kind:"generic",retryable:!0,detail:{...y!==void 0?{name:y}:{},phase:"models",engineKind:"models"}})}return}g||u!==p||(k("gating"),H(u))},ne=async()=>a!==void 0&&a.session()==="choice"&&await ke().catch(()=>!1),Fe=()=>f==="idle"||f==="starting"||f==="gating"||f==="error";return{handle:{get state(){return f},get captureMode(){return t()},get facingMode(){return v},on:(i,u)=>o.on(i,u),start:R,retry:()=>{if(!g){if(C!==null&&x!==null&&f!=="error"){p+=1;let i=p;D(),S.reset(),k("gating"),H(i);return}f="idle",R()}},switchCamera:()=>U.refuseSwitch(t()==="assisted"?"assisted":"self"),canSwitchCaptureMode:ne,setCaptureMode:async i=>{if(g||a===void 0||i===t()||!await ne()||g||!Fe())return!1;a.onModeChange(i);let u=K(i);return f==="idle"&&C===null||(p+=1,I(),v=u,k("mode_switch"),R({facing:u})),!0},destroy:()=>{g||(p+=1,I(),Q.setActive(!1),g=!0,x?.close(),x=null,X.close(),o.clear())}},gateScores:()=>S.scores(),setFlowState:i=>{(f==="captured"||f==="uploading"||f==="checking"||f==="done"&&i==="done")&&k(i)}}}function ut(){import("@mediapipe/tasks-vision").catch(()=>{})}export{Ee as a,Ie as b,xe as c,T as d,Be as e,Ge as f,Ae as g,Oe as h,we as i,De as j,_e as k,He as l,Ke as m,ct as n,ut as o};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var M="zoom torch focusMode focusDistance exposureMode exposureCompensation exposureTime whiteBalanceMode colorTemperature iso facingMode frameRate width height aspectRatio resizeMode deviceId groupId".split(" "),C=/^(portrait|landscape)-(primary|secondary)$/,w=1e3;function g(n,e=80){return typeof n=="string"&&n.replace(/[^A-Za-z0-9 ()\-._,]/g,"").trim().slice(0,e)||void 0}var u=n=>typeof n=="number"&&Number.isFinite(n)&&n>=0?Math.round(n):void 0,h=n=>typeof n=="boolean"?n:void 0,b=n=>Math.round(n*1e4)/1e4;function c(n){try{return n()}catch{return}}function m(n){let e={};for(let[t,i]of Object.entries(n))i!==void 0&&(e[t]=i);return Object.keys(e).length>0?e:void 0}var s;function R(n,e){s=m({renderer:g(n),vendor:g(e)})??s}function T(n){return s===void 0&&(s=null,c(()=>{let e=n?.createElement("canvas").getContext("webgl");if(e){let t=e.getExtension("WEBGL_debug_renderer_info");R(e.getParameter(t?t.UNMASKED_RENDERER_WEBGL:e.RENDERER),e.getParameter(t?t.UNMASKED_VENDOR_WEBGL:e.VENDOR)),e.getExtension("WEBGL_lose_context")?.loseContext()}})),s??void 0}var y=(n,e)=>c(()=>n.matchMedia?.(e).matches);function P(n){let e=n.navigator,t=n.screen?.orientation?.type,i=n.devicePixelRatio;return m({touchPoints:u(e?.maxTouchPoints),webdriver:h(e?.webdriver),uaMobile:h(e?.userAgentData?.mobile),uaPlatform:g(e?.userAgentData?.platform,32),screenW:u(n.screen?.width),screenH:u(n.screen?.height),dpr:typeof i=="number"&&i>0&&Number.isFinite(i)?b(i):void 0,coarse:y(n,"(pointer: coarse)"),noHover:y(n,"(hover: none)"),orientation:C.test(t)?t:void 0})}function N(n,e){let t=c(()=>n.getCapabilities?.()),i=a=>{let o=a;return typeof o?.min=="number"&&typeof o.max=="number"?o.max>o.min:void 0};return m({inputs:e,capabilities:t?M.filter(a=>a in t):void 0,frameRateRange:i(t?.frameRate),widthRange:i(t?.width)})}async function D(n,e=globalThis){let t=new Promise(o=>{let r=()=>o(T(e.document));s!==void 0?r():typeof e.requestIdleCallback=="function"?e.requestIdleCallback(r,{timeout:w}):setTimeout(r,0)}),i=Promise.race([Promise.resolve().then(()=>e.navigator?.mediaDevices?.enumerateDevices?.()).then(o=>o?.filter(r=>r.kind==="videoinput").length,()=>{}),new Promise(o=>setTimeout(o,w))]),a=c(()=>P(e));return m({gpu:await t,device:a,camera:N(n,await i)})??{}}function x(){let n=0,e=0,t=0;return{add(i,a,o){if(typeof i!="number"||typeof a!="number"||typeof o!="number")return;let r=Math.hypot(i,a,o);if(!Number.isFinite(r))return;n+=1;let l=r-e;e+=l/n,t+=l*(r-e)},std:()=>n<2?void 0:b(Math.sqrt(t/(n-1)))}}function L(n=globalThis){let e=n.DeviceMotionEvent,t=typeof e=="function"&&typeof e.requestPermission!="function"&&typeof n.addEventListener=="function",i=0,a,o=x(),r=x(),l=d=>{i+=1,typeof d.interval=="number"&&d.interval>=0&&Number.isFinite(d.interval)&&(a=b(d.interval));let v=d.accelerationIncludingGravity;v&&o.add(v.x,v.y,v.z);let p=d.rotationRate;p&&r.add(p.alpha,p.beta,p.gamma)},E=0,k=()=>{E+=1};c(()=>{t&&n.addEventListener("devicemotion",l),n.document?.addEventListener("visibilitychange",k)});let f;return{stop(){return f!==void 0||(c(()=>{t&&n.removeEventListener?.("devicemotion",l),n.document?.removeEventListener("visibilitychange",k)}),f={motion:t?{available:t,events:i,...m({intervalMs:a,accelStd:o.std(),rotationStd:r.std()})}:{available:t},page:m({visibilityChanges:E,outerW:u(n.outerWidth),outerH:u(n.outerHeight),innerW:u(n.innerWidth),innerH:u(n.innerHeight)})}),f}}}export{R as a,D as b,L as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var x=Object.freeze({minLines:4,fillMin:.55,fillMax:.98,offsetMax:.12,steadyFillDelta:.04,steadyOffsetDelta:.03,layoutShiftMax:.025,lineCountDelta:1,lockMs:600,steadyMs:900,minFrames:3});function M(s,o){let r=s.lineBoxes;if(r.length===0)return{lineCount:0,detected:!1,fill:0,offsetX:0,offsetY:0,centers:[]};let i=Math.min(...r.map(n=>n[0])),e=Math.max(...r.map(n=>n[0]+n[2])),t=Math.min(...r.map(n=>n[1])),l=Math.max(...r.map(n=>n[1]+n[3]));return{lineCount:r.length,detected:r.length>=o.minLines,fill:e-i,offsetX:(i+e)/2-.5,offsetY:(t+l)/2-.5,centers:r.map(n=>[n[0]+n[2]/2,n[1]+n[3]/2])}}function p(s,o){if(s.centers.length===0||o.centers.length===0)return Number.POSITIVE_INFINITY;let r=0;for(let[i,e]of o.centers){let t=Number.POSITIVE_INFINITY;for(let[l,n]of s.centers)t=Math.min(t,Math.hypot(i-l,e-n));r+=t}return r/o.centers.length}var y=class{constructor(o=x){this.t=o;this.last=null;this.goodSince=null;this.steadySince=null;this.frames=0}offer(o,r,i={glareOk:!0,sharpOk:!0}){let e=this.t,t=M(o,e),l=this.last;this.last=t;let n=t.fill>=e.fillMin&&t.fill<=e.fillMax,u=Math.abs(t.offsetX)<=e.offsetMax&&Math.abs(t.offsetY)<=e.offsetMax,d=l!==null&&l.detected&&Math.abs(t.lineCount-l.lineCount)<=e.lineCountDelta&&p(l,t)<=e.layoutShiftMax,m=t.detected&&i.glareOk&&i.sharpOk&&n&&d&&l!==null&&Math.abs(t.fill-l.fill)<=e.steadyFillDelta&&Math.abs(t.offsetX-l.offsetX)<=e.steadyOffsetDelta&&Math.abs(t.offsetY-l.offsetY)<=e.steadyOffsetDelta,c=m&&u,h=t.detected?i.glareOk?t.fill<e.fillMin?"closer":t.fill>e.fillMax?"farther":u?i.sharpOk?void 0:"blurry":"center":"glare":void 0;return m?(this.frames++,this.steadySince??(this.steadySince=r),this.goodSince=c?this.goodSince??r:null,(this.goodSince!==null&&r-this.goodSince>=e.lockMs||r-this.steadySince>=e.steadyMs)&&this.frames>=e.minFrames?{state:"locked"}:{state:"locking",...h?{hint:h}:{}}):(this.goodSince=null,this.steadySince=null,this.frames=t.detected?1:0,{state:t.detected?"locking":"searching",...h?{hint:h}:{}})}reset(){this.last=null,this.goodSince=null,this.steadySince=null,this.frames=0}};function g(s,o,r){let i=e=>Math.round(Math.min(1,Math.max(0,e))*1e4)/1e4;return s.map(e=>{let t=[e[0],e[2],e[4],e[6]],l=[e[1],e[3],e[5],e[7]],n=Math.min(...t),u=Math.min(...l);return[i(n/o),i(u/r),i((Math.max(...t)-n)/o),i((Math.max(...l)-u)/r)]}).sort((e,t)=>e[1]-t[1]||e[0]-t[0])}function L(s,o){if(!Number.isFinite(s)||s<0)return"low";if(s<=150)return"high";let r=typeof o!="number"||!Number.isFinite(o)||o>3;return s<=400&&r?"mid":"low"}var _=Object.freeze({low:Object.freeze({stride:1,bandWidthPx:960}),mid:Object.freeze({stride:2,bandWidthPx:1280}),high:Object.freeze({stride:1,bandWidthPx:1280})}),O=3e3;function S(s=globalThis){let o=s.navigator?.deviceMemory;return typeof o=="number"&&Number.isFinite(o)&&o>0?o:null}function T(){let r=new Uint8Array(1228800).fill(255),i=24301,e=()=>(i=i*1103515245+12345&2147483647,i/2147483647),t=(d,m)=>{let c=(m*960+d)*4;r[c]=20,r[c+1]=20,r[c+2]=20},l=20,n=14,u=28;for(let d of[110,190])for(let m=0;m<44;m++){let c=40+m*l;if(e()<.25){for(let a=0;a<n/2;a++)for(let f=0;f<2;f++)t(c+n/2-a,d+u/2-a+f),t(c+n/2-a,d+u/2+a+f);continue}let h=Math.floor(e()*(n-3));for(let a=0;a<u;a++)for(let f=0;f<3;f++)t(c+h+f,d+a);for(let a of[0,u/2-1,u-3])if(!(e()<.4))for(let f=0;f<n;f++)for(let b=0;b<3;b++)t(c+f,d+a+b)}return{rgba:r,width:960,height:320}}export{x as a,y as b,g as c,L as d,_ as e,O as f,S as g,T as h};
|