@tsocial/tvweb-sdk 5.38.0 → 5.38.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/build/esm/chunk-05ac2e29.js +1 -0
  2. package/build/esm/{chunk-c74892c9.js → chunk-148a64eb.js} +1 -1
  3. package/build/esm/{chunk-71bc3d31.js → chunk-18c2104b.js} +1 -1
  4. package/build/esm/{chunk-0e095921.js → chunk-26f22aaa.js} +1 -1
  5. package/build/esm/{chunk-da9e4f99.js → chunk-2f00d703.js} +1 -1
  6. package/build/esm/chunk-30941db8.js +1 -0
  7. package/build/esm/{chunk-99247a2f.js → chunk-4588a2bc.js} +31 -12
  8. package/build/esm/{chunk-32ffba48.js → chunk-4dbeaf6f.js} +1 -1
  9. package/build/esm/{chunk-6a6c84e6.js → chunk-5952fbfb.js} +1 -1
  10. package/build/esm/{chunk-d8a92cb1.js → chunk-67dba361.js} +1 -1
  11. package/build/esm/{chunk-7b389c71.js → chunk-69854c99.js} +1 -1
  12. package/build/esm/{chunk-47f573ed.js → chunk-7a1034f3.js} +1 -1
  13. package/build/esm/{chunk-b2a6294d.js → chunk-94b9613e.js} +1 -1
  14. package/build/esm/{chunk-27a081f0.js → chunk-95585c1a.js} +1 -1
  15. package/build/esm/{chunk-4c5427d3.js → chunk-a9d5f5ae.js} +1 -1
  16. package/build/esm/{chunk-f003d34d.js → chunk-bb5383fa.js} +29 -10
  17. package/build/esm/{chunk-60dc6fe1.js → chunk-d436b362.js} +1 -1
  18. package/build/esm/{chunk-61824c72.js → chunk-d6a3ff5a.js} +1 -1
  19. package/build/esm/{chunk-37cdf0c6.js → chunk-d7808881.js} +1 -1
  20. package/build/esm/{chunk-191cab03.js → chunk-df438efe.js} +1 -1
  21. package/build/esm/{chunk-825b5b31.js → chunk-e2249d38.js} +1 -1
  22. package/build/esm/{chunk-4bdebcdd.js → chunk-f253519c.js} +1 -1
  23. package/build/esm/tvweb-sdk.esm.min.js +1 -1
  24. package/build/tvweb-sdk.cjs.min.js +92 -54
  25. package/build/tvweb-sdk.standalone.js +235 -182
  26. package/build/tvweb-sdk.standalone.min.js +89 -51
  27. package/package.json +5 -5
  28. package/build/esm/chunk-0ffdb7d1.js +0 -1
  29. package/build/esm/chunk-17ccf2c0.js +0 -1
@@ -1,4 +1,4 @@
1
- import{aM as e,z as i,aN as r,aO as t,aP as s,m as o,b as n,r as a,K as l,P as d,D as c,s as g,Y as h,j as f,i as u,y as p,B as m,k as w,aQ as k}from"./chunk-f003d34d.js";var b=Object.freeze({__proto__:null,blink:e,flipY:i,slide:r,spin:t,splash:s});let R=({curStep:e,faceDirection:i})=>{let r=n(e,"stepTimeConstraints.delayTime");return!!r&&(null===e.firstFrameSpottedAt?(e.name===i&&(e.firstFrameSpottedAt=new Date().getTime()),!0):!!(new Date().getTime()-e.firstFrameSpottedAt<r)||!1)},S=(e,i)=>({radius:e.radius??o("Selfie.progressCircle.radius")({theme:i}),strokeWidth:e.strokeWidth??o("Selfie.progressCircle.strokeWidth")({theme:i}),progress:e.progress??o("Selfie.progressCircle.progress")({theme:i}),showErrorRing:e.showErrorRing??o("Selfie.progressCircle.showErrorRing")({theme:i}),activeColor:e.activeColor??o("Selfie.progressCircle.activeColor")({theme:i}),innerPadding:e.innerPadding??o("Selfie.progressCircle.innerPadding")({theme:i}),outsideRingColor:e.outsideRingColor??o("Selfie.progressCircle.outsideRingColor")({theme:i}),outsideRingOpacity:e.outsideRingOpacity??o("Selfie.progressCircle.outsideRingOpacity")({theme:i}),insideRingColor:e.insideRingColor??o("Selfie.progressCircle.insideRingColor")({theme:i}),insideRingWidth:e.insideRingWidth??o("Selfie.progressCircle.insideRingWidth")({theme:i}),insideRingStrokeDash:e.insideRingStrokeDash??o("Selfie.progressCircle.insideRingStrokeDash")({theme:i}),errorRingWidth:e.errorRingWidth??o("Selfie.progressCircle.errorRingWidth")({theme:i}),errorRingColor:e.errorRingColor??o("Selfie.progressCircle.errorRingColor")({theme:i}),dashedRingColor:e.dashedRingColor??o("Selfie.progressCircle.dashedRingColor")({theme:i}),dashedRingOpacity:e.dashedRingOpacity??o("Selfie.progressCircle.dashedRingOpacity")({theme:i}),dashedRingWidth:e.dashedRingWidth??o("Selfie.progressCircle.dashedRingWidth")({theme:i}),dashedRingLineThick:e.dashedRingLineThick??o("Selfie.progressCircle.dashedRingLineThick")({theme:i}),dashedRingLineSpacing:e.dashedRingLineSpacing??o("Selfie.progressCircle.dashedRingLineSpacing")({theme:i}),dashedInsideRingColor:e.dashedInsideRingColor??o("Selfie.progressCircle.dashedInsideRingColor")({theme:i}),dashedInsideRingWidth:e.dashedInsideRingWidth??o("Selfie.progressCircle.dashedInsideRingWidth")({theme:i}),showOutsideRing:e.showOutsideRing??o("Selfie.progressCircle.showOutsideRing")({theme:i}),showInsideRing:e.showInsideRing??o("Selfie.progressCircle.showInsideRing")({theme:i}),showDashedRing:e.showDashedRing??o("Selfie.progressCircle.showDashedRing")({theme:i})}),_=(e,i)=>({radius:e.radius??o("Selfie.progressCircleV2.radius")({theme:i}),strokeWidth:e.strokeWidth??o("Selfie.progressCircleV2.strokeWidth")({theme:i}),progress:e.progress??o("Selfie.progressCircleV2.progress")({theme:i}),activeColor:e.activeColor??o("Selfie.progressCircleV2.activeColor")({theme:i}),neutralColor:e.neutralColor??o("Selfie.progressCircleV2.neutralColor")({theme:i}),errorColor:e.errorColor??o("Selfie.progressCircleV2.errorColor")({theme:i}),tickWidth:e.tickWidth??o("Selfie.progressCircleV2.tickWidth")({theme:i}),numberOfTicks:e.numberOfTicks??o("Selfie.progressCircleV2.numberOfTicks")({theme:i})}),y=({incomingFrame:e,currentBestFrame:i})=>e?.isEyeClosed&&!i?.isEyeClosed?i:!e?.isEyeClosed&&i?.isEyeClosed?e:e?.blurScore>i?.blurScore?e:i;function C(e){return new Promise(i=>{let r=new Image;r.onload=i,r.onerror=i,r.src=e})}let x=[],v=()=>{x=[]},$=(e,i,r,t)=>{t&&v(),x.push({id:null});let s=x.length-1;if(e&&e.key){let t=new Blob([JSON.stringify(i)]);r.uploadFile({file:t,metadata:JSON.stringify({type:"selfie"}),label:"video"},{"X-TV-Key":e.key}).then(e=>{e&&e.data&&e.data.file_id?x[s].id=e.data.file_id:x[s].id=-1})}else{let e=new Blob([JSON.stringify(i)]);r.uploadFile({file:e,metadata:JSON.stringify({type:"selfie"}),label:"video"}).then(e=>{e&&e.data&&e.data.file_id?x[s].id=e.data.file_id:x[s].id=-1})}},W=()=>new Promise(e=>{let i=setInterval(()=>{x.every(e=>e.id)&&(e(),clearInterval(i))},200)}),j=e=>e.enable?x.some(e=>-1===e.id)?null:x:[],I=[],O=null,D=!1,A=()=>I,T=()=>{D=!0,I=[];try{O instanceof MediaStream&&(O.getTracks().forEach(e=>e.stop()),O=null)}catch(e){}};async function E({outputImagesSize:e,videoEl:i,resultAnalyzeVideoAndWindowSizes:r}){let t;T();let s=document.createElement("canvas");s.width=e,s.height=e;let o=s.getContext("2d");try{let n={mimeType:"video/webm"};try{let e=(O=i?.captureStream()?.clone()).getVideoTracks()[0];await e.applyConstraints({width:{min:360,ideal:400},height:{min:360,ideal:400}})}catch(e){}MediaRecorder.isTypeSupported("video/mp4")&&(D=!1,!function e(i,r,t,s){if(!i||!s)return;let{cropX:o,cropY:n,cropWidth:a,cropHeight:l}=s;i.drawImage(r,o,n,a,l,0,0,t,t),D||requestAnimationFrame(()=>e(i,r,t,s))}(o,i,e,r),O=s.captureStream(25),n={mimeType:"video/mp4",videoBitsPerSecond:25e5}),t=new MediaRecorder(O,n);let a=async()=>{await new Promise((e,i)=>{t.ondataavailable=r=>(function(e,i,r){if(e.data.size>0){let r=new Blob([e.data],{type:"video/mp4"});I.push(r),i()}else console.error("No video have recored!"),r()})(r,e,i),"inactive"!==t.state&&t.stop()})};t.stopVideoRecording=a,t.discardRecording=()=>{"inactive"!==t.state&&t.stop()}}catch(e){}return{mediaRecorder:t}}let P={data:{settings:{sdk_settings:{passive_liveness_settings:{auto_capture:{enable:!0,show_capture_button:!0,show_countdown:!0,wait_for_best_image_time_ms_web:3e3},manual_capture:{show_countdown:!0,wait_for_best_image_time_ms_web:3e3},blur_check:{enable:!0,web_blurry_threshold:.4},close_eye_detector:{enable:!0,web_threshold:.342,web_timeout:5,force_check:!1},web_is_required_frontal_face:!0},active_liveness_settings:{reset_flow_on_orientation_change:!0,wait_before_start_flow_ms:2e3,face_tracking_setting:{enable:!1,web_terminate_threshold:.0030152991993743408,web_warning_threshold:.0017317430600108828,limit_for:"all_flow",max_warning_time:5},flow_interval_time_ms:3e3,take_one_picture_time_ms:3e3,limit_time_liveness_check:{enable:!1,limit_time_second:45,remain_time_show:10,format:"s",max_retry_count:0,non_stoppable:!1},terminate_if_no_face:{enable:!1,max_invalid_frame:5,max_time_ms:1e3},close_eye_detector:{enable:!0,web_threshold:.342,web_timeout:5,force_check:!1},exif_data_settings:{enable:!0},record_video:{enable:!1},save_encoded_frames:{enable:!1,enable_logging:!1,frames_batch_len:0,frames_interval_ms:180,quality_android:90,quality_ios:80},auto_gen_frame_ids:{enable:!1,max_items:50}}}}}},V=30,L=e=>{let{shouldStart:i,totalTime:r,totalDelayBetweenReset:t,interruptible:s=!0,onReset:o,onTick:n,onTimesUp:d}=e,c=a.useRef(new l({totalTime:r,totalDelayBetweenReset:t,interruptible:s}));return a.useEffect(()=>c.current.on("tick",({remainTime:e})=>{n({remainTime:e})}),[n]),a.useEffect(()=>c.current.on("delaystart",()=>{d()}),[d]),a.useEffect(()=>c.current.on("reset",({attemptCount:e,fromBackground:i})=>{o({attemptCount:e,fromBackground:i})}),[o]),a.useEffect(()=>i?c.current.start():()=>{},[i]),{stopTimer:a.useCallback(()=>{c.current.stop()},[])}},{ErrorDuration:z}=g;function M({children:e,errorMsg:i,className:r}){return h.isValidElement(e)?i?f.jsx("div",{className:r,children:h.cloneElement(e,{errorMsg:i})}):null:i?f.jsx("div",{className:r,children:i}):null}function B({children:e,className:i,error:r}){let t=a.useRef(0),s=a.useRef(""),o=c(),n=a.useRef(z.SHORT),{code:l,duration:d=z.SHORT}=r||{},g=o(l);return Date.now()-t.current>=n.current?(t.current=Date.now(),n.current=d,s.current=g,M({children:e,errorMsg:g,className:i})):M({children:e,errorMsg:s.current,className:i})}B.propTypes={children:d.node,className:d.string},B.defaultProps={className:""};let N=u.g`
1
+ import{aM as e,z as i,aN as r,aO as t,aP as s,m as o,b as n,r as a,K as l,P as d,D as c,s as g,Y as h,j as f,i as u,y as p,B as m,k as w,aQ as k}from"./chunk-bb5383fa.js";var b=Object.freeze({__proto__:null,blink:e,flipY:i,slide:r,spin:t,splash:s});let R=({curStep:e,faceDirection:i})=>{let r=n(e,"stepTimeConstraints.delayTime");return!!r&&(null===e.firstFrameSpottedAt?(e.name===i&&(e.firstFrameSpottedAt=new Date().getTime()),!0):!!(new Date().getTime()-e.firstFrameSpottedAt<r)||!1)},S=(e,i)=>({radius:e.radius??o("Selfie.progressCircle.radius")({theme:i}),strokeWidth:e.strokeWidth??o("Selfie.progressCircle.strokeWidth")({theme:i}),progress:e.progress??o("Selfie.progressCircle.progress")({theme:i}),showErrorRing:e.showErrorRing??o("Selfie.progressCircle.showErrorRing")({theme:i}),activeColor:e.activeColor??o("Selfie.progressCircle.activeColor")({theme:i}),innerPadding:e.innerPadding??o("Selfie.progressCircle.innerPadding")({theme:i}),outsideRingColor:e.outsideRingColor??o("Selfie.progressCircle.outsideRingColor")({theme:i}),outsideRingOpacity:e.outsideRingOpacity??o("Selfie.progressCircle.outsideRingOpacity")({theme:i}),insideRingColor:e.insideRingColor??o("Selfie.progressCircle.insideRingColor")({theme:i}),insideRingWidth:e.insideRingWidth??o("Selfie.progressCircle.insideRingWidth")({theme:i}),insideRingStrokeDash:e.insideRingStrokeDash??o("Selfie.progressCircle.insideRingStrokeDash")({theme:i}),errorRingWidth:e.errorRingWidth??o("Selfie.progressCircle.errorRingWidth")({theme:i}),errorRingColor:e.errorRingColor??o("Selfie.progressCircle.errorRingColor")({theme:i}),dashedRingColor:e.dashedRingColor??o("Selfie.progressCircle.dashedRingColor")({theme:i}),dashedRingOpacity:e.dashedRingOpacity??o("Selfie.progressCircle.dashedRingOpacity")({theme:i}),dashedRingWidth:e.dashedRingWidth??o("Selfie.progressCircle.dashedRingWidth")({theme:i}),dashedRingLineThick:e.dashedRingLineThick??o("Selfie.progressCircle.dashedRingLineThick")({theme:i}),dashedRingLineSpacing:e.dashedRingLineSpacing??o("Selfie.progressCircle.dashedRingLineSpacing")({theme:i}),dashedInsideRingColor:e.dashedInsideRingColor??o("Selfie.progressCircle.dashedInsideRingColor")({theme:i}),dashedInsideRingWidth:e.dashedInsideRingWidth??o("Selfie.progressCircle.dashedInsideRingWidth")({theme:i}),showOutsideRing:e.showOutsideRing??o("Selfie.progressCircle.showOutsideRing")({theme:i}),showInsideRing:e.showInsideRing??o("Selfie.progressCircle.showInsideRing")({theme:i}),showDashedRing:e.showDashedRing??o("Selfie.progressCircle.showDashedRing")({theme:i})}),_=(e,i)=>({radius:e.radius??o("Selfie.progressCircleV2.radius")({theme:i}),strokeWidth:e.strokeWidth??o("Selfie.progressCircleV2.strokeWidth")({theme:i}),progress:e.progress??o("Selfie.progressCircleV2.progress")({theme:i}),activeColor:e.activeColor??o("Selfie.progressCircleV2.activeColor")({theme:i}),neutralColor:e.neutralColor??o("Selfie.progressCircleV2.neutralColor")({theme:i}),errorColor:e.errorColor??o("Selfie.progressCircleV2.errorColor")({theme:i}),tickWidth:e.tickWidth??o("Selfie.progressCircleV2.tickWidth")({theme:i}),numberOfTicks:e.numberOfTicks??o("Selfie.progressCircleV2.numberOfTicks")({theme:i})}),y=({incomingFrame:e,currentBestFrame:i})=>e?.isEyeClosed&&!i?.isEyeClosed?i:!e?.isEyeClosed&&i?.isEyeClosed?e:e?.blurScore>i?.blurScore?e:i;function C(e){return new Promise(i=>{let r=new Image;r.onload=i,r.onerror=i,r.src=e})}let x=[],v=()=>{x=[]},$=(e,i,r,t)=>{t&&v(),x.push({id:null});let s=x.length-1;if(e&&e.key){let t=new Blob([JSON.stringify(i)]);r.uploadFile({file:t,metadata:JSON.stringify({type:"selfie"}),label:"video"},{"X-TV-Key":e.key}).then(e=>{e&&e.data&&e.data.file_id?x[s].id=e.data.file_id:x[s].id=-1})}else{let e=new Blob([JSON.stringify(i)]);r.uploadFile({file:e,metadata:JSON.stringify({type:"selfie"}),label:"video"}).then(e=>{e&&e.data&&e.data.file_id?x[s].id=e.data.file_id:x[s].id=-1})}},W=()=>new Promise(e=>{let i=setInterval(()=>{x.every(e=>e.id)&&(e(),clearInterval(i))},200)}),j=e=>e.enable?x.some(e=>-1===e.id)?null:x:[],I=[],O=null,D=!1,A=()=>I,T=()=>{D=!0,I=[];try{O instanceof MediaStream&&(O.getTracks().forEach(e=>e.stop()),O=null)}catch(e){}};async function E({outputImagesSize:e,videoEl:i,resultAnalyzeVideoAndWindowSizes:r}){let t;T();let s=document.createElement("canvas");s.width=e,s.height=e;let o=s.getContext("2d");try{let n={mimeType:"video/webm"};try{let e=(O=i?.captureStream()?.clone()).getVideoTracks()[0];await e.applyConstraints({width:{min:360,ideal:400},height:{min:360,ideal:400}})}catch(e){}MediaRecorder.isTypeSupported("video/mp4")&&(D=!1,!function e(i,r,t,s){if(!i||!s)return;let{cropX:o,cropY:n,cropWidth:a,cropHeight:l}=s;i.drawImage(r,o,n,a,l,0,0,t,t),D||requestAnimationFrame(()=>e(i,r,t,s))}(o,i,e,r),O=s.captureStream(25),n={mimeType:"video/mp4",videoBitsPerSecond:25e5}),t=new MediaRecorder(O,n);let a=async()=>{await new Promise((e,i)=>{t.ondataavailable=r=>(function(e,i,r){if(e.data.size>0){let r=new Blob([e.data],{type:"video/mp4"});I.push(r),i()}else console.error("No video have recored!"),r()})(r,e,i),"inactive"!==t.state&&t.stop()})};t.stopVideoRecording=a,t.discardRecording=()=>{"inactive"!==t.state&&t.stop()}}catch(e){}return{mediaRecorder:t}}let P={data:{settings:{sdk_settings:{passive_liveness_settings:{auto_capture:{enable:!0,show_capture_button:!0,show_countdown:!0,wait_for_best_image_time_ms_web:3e3},manual_capture:{show_countdown:!0,wait_for_best_image_time_ms_web:3e3},blur_check:{enable:!0,web_blurry_threshold:.4},close_eye_detector:{enable:!0,web_threshold:.342,web_timeout:5,force_check:!1},web_is_required_frontal_face:!0},active_liveness_settings:{reset_flow_on_orientation_change:!0,wait_before_start_flow_ms:2e3,face_tracking_setting:{enable:!1,web_terminate_threshold:.0030152991993743408,web_warning_threshold:.0017317430600108828,limit_for:"all_flow",max_warning_time:5},flow_interval_time_ms:3e3,take_one_picture_time_ms:3e3,limit_time_liveness_check:{enable:!1,limit_time_second:45,remain_time_show:10,format:"s",max_retry_count:0,non_stoppable:!1},terminate_if_no_face:{enable:!1,max_invalid_frame:5,max_time_ms:1e3},close_eye_detector:{enable:!0,web_threshold:.342,web_timeout:5,force_check:!1},exif_data_settings:{enable:!0},record_video:{enable:!1},save_encoded_frames:{enable:!1,enable_logging:!1,frames_batch_len:0,frames_interval_ms:180,quality_android:90,quality_ios:80},auto_gen_frame_ids:{enable:!1,max_items:50}}}}}},V=30,L=e=>{let{shouldStart:i,totalTime:r,totalDelayBetweenReset:t,interruptible:s=!0,onReset:o,onTick:n,onTimesUp:d}=e,c=a.useRef(new l({totalTime:r,totalDelayBetweenReset:t,interruptible:s}));return a.useEffect(()=>c.current.on("tick",({remainTime:e})=>{n({remainTime:e})}),[n]),a.useEffect(()=>c.current.on("delaystart",()=>{d()}),[d]),a.useEffect(()=>c.current.on("reset",({attemptCount:e,fromBackground:i})=>{o({attemptCount:e,fromBackground:i})}),[o]),a.useEffect(()=>i?c.current.start():()=>{},[i]),{stopTimer:a.useCallback(()=>{c.current.stop()},[])}},{ErrorDuration:z}=g;function M({children:e,errorMsg:i,className:r}){return h.isValidElement(e)?i?f.jsx("div",{className:r,children:h.cloneElement(e,{errorMsg:i})}):null:i?f.jsx("div",{className:r,children:i}):null}function B({children:e,className:i,error:r}){let t=a.useRef(0),s=a.useRef(""),o=c(),n=a.useRef(z.SHORT),{code:l,duration:d=z.SHORT}=r||{},g=o(l);return Date.now()-t.current>=n.current?(t.current=Date.now(),n.current=d,s.current=g,M({children:e,errorMsg:g,className:i})):M({children:e,errorMsg:s.current,className:i})}B.propTypes={children:d.node,className:d.string},B.defaultProps={className:""};let N=u.g`
2
2
  transition: stroke-dashoffset 0.4s;
3
3
  transform: rotate(-90deg);
4
4
  transform-origin: 50% 50%;
@@ -1 +1 @@
1
- import{A as e,C as r,U as s,r as a,m as n,c as t,s as o,j as i,a4 as c,az as l,b as u,P as p,k as m}from"./chunk-f003d34d.js";import{p as d,g as f,S as h,a as g,O as C,C as j,E as y,b as D,B as F,c as x,L as S}from"./chunk-32ffba48.js";import{u as b,C as k}from"./chunk-da9e4f99.js";import{M as I,O as T,W as E,C as R}from"./chunk-60dc6fe1.js";import{D as L}from"./chunk-27a081f0.js";import{u as v}from"./chunk-17ccf2c0.js";import"./chunk-61824c72.js";import"./chunk-47f573ed.js";import"./chunk-d8a92cb1.js";let P=m.isMobile?{width:{ideal:640}}:null;function A(p){let{apiCheck:m,onLivenessDetectionDone:L,captureFrameSettings:A,onFramesCaptured:M,frontCamera:H,flipVideoHorizontal:O,customDirectionIcon:U,customStepTimeConstraints:w,onProcessing:V,customErrors:$,apiCredentials:_,outputEncryptionSettings:B,cameraScale:K,defaultCameraId:N,passiveModeAuto:z,offsetFaceY:G,styledComponent:Y,serviceSettings:W,onReset:q,isLoading:J}=p,Q=e(),{onErrorCallback:X,onCloseCallback:Z}=v(),ee=r.useAsset("bg_camera_mask.png"),er=r.useAsset("bg_camera_mask_red.png"),es=s("IDCapturing.loadingIcon.src","ic_loading.gif"),[ea,en]=a.useState({}),{yFaceDetectionError:et,yFaceVerificationStepsWrapper:eo}=ea,[ei,ec]=a.useState(""),[el,eu]=a.useState(),ep=a.useMemo(()=>({backgroundColor:n("Selfie.backgroundColor")({theme:Q})}),[Q]),em=a.useCallback(({lostY:e,height:r,clientHeight:s})=>{let a=e+25,n=a+30;en({yFaceDetectionError:a,yFaceVerificationStepsWrapper:n+r+20});let t=Math.floor(e),o=Math.floor(s-e),i=Math.floor(n);return 0!==G&&(i+G<t||i+G+r>o)?X({code:`offsetFaceY must be in [-${i-t}, ${o-r-i}]`}):i+=G,{y:i}},[G,X]),{shouldResetFlowOnOrientationChange:ed,countdownToTakePicture:ef,cropArea:eh,curStepIndex:eg,faceDetectionError:eC,resetFlow:ej,handleTriggerPassiveMode:ey,handleVideoPlayed:eD,refVideo:eF,showCountdown:ex,steps:eS,refIsReseting:eb,videoPlayed:ek,warmupDone:eI,showCaptureButton:eT,shouldShowCountdown:eE,showLoading:eR}=b({currentOrientation:el,apiCheck:m,bgCameraMask:ee,bgCameraMaskRed:er,surroundStyle:ep,onLivenessDetectionDone:L,onError:X,cropAreaDimension:em,customDirectionIcon:U,captureFrameSettings:A,onFramesCaptured:M,setRemainingTime:ec,customStepTimeConstraints:w,onProcessing:V,customErrors:$,apiCredentials:_,outputEncryptionSettings:B,cameraScale:K,passiveModeAuto:z,serviceSettings:W,onReset:q});a.useEffect(()=>{"string"==typeof eS[0]?.directionIcon&&Promise.all(eS.map(e=>d(e.directionIcon)))},[eS]);let{CloseCameraButton:eL}=Y,ev=f(p,Q),eP=eb.current?0:eg/eS.length*100,{lang:eA}=t.useSDKSettings(),eM=a.useRef(0),eH=a.useRef({}),eO=a.useRef(o.ErrorDuration.SHORT),eU=a.useMemo(()=>{let{msg:e,duration:r=o.ErrorDuration.SHORT}=eC||{},s=e?.[eA];return Date.now()-eM.current>=eO.current&&(eM.current=Date.now(),eO.current=r,eH.current=s),eH.current},[eC,eg]),ew=a.useCallback(e=>{eu(e),ed?ej():e===I.LANDSCAPE?eF.current?.pause():eF.current?.play()},[eF,ej,ed]);return i.jsx(T,{onOrientationChange:ew,children:i.jsxs(c,{frontCamera:H,onVideoPlayed:eD,onClose:Z,flipHorizontal:O??H,ref:eF,videoSettings:P,onError:X,scale:K,defaultCameraId:N,closeButton:eL||i.jsx(l,{}),children:[!eI&&i.jsx(E,{}),ek?i.jsxs(i.Fragment,{children:["string"==typeof eU?i.jsx(h,{top:et-15,className:"face-detection-error",children:eU}):null,eh.current?i.jsxs(R,{x:`${eh.current.x}px`,y:`${eh.current.y}px`,width:`${eh.current.width}px`,height:`${eh.current.height}px`,surroundStyle:eh.current.surroundStyle,children:[i.jsx(g,{}),i.jsx(C,{...ev,progress:eP,showErrorRing:!!eC&&n("Selfie.progressCircle.showErrorRing")({theme:Q})}),eE?i.jsx(j,{children:ef}):null,eC&&i.jsx(y,{})]}):null,ei&&i.jsx(D,{top:eo-30,children:ei}),eT?i.jsx(F,{children:i.jsx(x,{onClick:ey,disabled:ex,children:u(Q,"Selfie.captureIcon.src")?i.jsx("img",{src:u(Q,"Selfie.captureIcon.src"),alt:""}):i.jsx(k,{fillColor:"rgba(193, 197, 204, 1)"})})}):null]}):null,(eR||J)&&i.jsx(S,{children:i.jsx("img",{src:es,alt:""})})]})})}A.propTypes={apiCheck:p.bool,mode:p.string,onLivenessDetectionDone:p.func,onClose:p.func,onError:p.func,onReset:p.func,captureFrameSettings:p.shape({}),onFramesCaptured:p.func,frontCamera:p.bool,isLoading:p.bool,flipVideoHorizontal:p.bool,customDirectionIcon:p.shape({}),customStepTimeConstraints:p.shape({}),onProcessing:p.func,customErrors:p.shape({}),apiCredentials:p.shape({accessKey:p.string,secretKey:p.string,apiUrl:p.string}),outputEncryptionSettings:p.shape({}),cameraScale:p.number,defaultCameraId:p.string,passiveModeAuto:p.bool,offsetFaceY:p.number,styledComponent:p.shape({CloseCameraButton:p.node}),serviceSettings:p.shape({})},A.defaultProps={apiCheck:!1,mode:null,onLivenessDetectionDone:null,onClose:null,onError:()=>{},onReset:()=>{},captureFrameSettings:{enable:!1,framesIntervalTime:180,framesBatchLength:0},onFramesCaptured:()=>{},frontCamera:!0,isLoading:!1,flipVideoHorizontal:null,customDirectionIcon:{[o.FaceDirection.LEFT]:i.jsx(L,{type:o.FaceDirection.LEFT}),[o.FaceDirection.RIGHT]:i.jsx(L,{type:o.FaceDirection.RIGHT}),[o.FaceDirection.UP]:i.jsx(L,{type:o.FaceDirection.UP}),[o.FaceDirection.FRONTAL]:i.jsx(L,{type:o.FaceDirection.FRONTAL})},customStepTimeConstraints:{[o.FaceDirection.UP]:{delayTime:0},[o.FaceDirection.LEFT]:{delayTime:0},[o.FaceDirection.RIGHT]:{delayTime:0},[o.FaceDirection.FRONTAL]:{delayTime:2e3}},onProcessing:()=>{},customErrors:null,apiCredentials:{accessKey:"",secretKey:"",apiUrl:""},outputEncryptionSettings:null,cameraScale:1,defaultCameraId:void 0,passiveModeAuto:!1,offsetFaceY:0,styledComponent:{CloseCameraButton:null},serviceSettings:{enableUploadFrames:!0,enableUploadImages:!0,enableVerifySanityPortrait:!0,enableVerifySanityIDCard:!0,enableVerifyFaceLiveness:!0,enableDetectIDCardTampering:!0,enableReadIDCardInfo:!0}};export{A as default};
1
+ import{A as e,C as r,U as s,r as a,m as n,c as t,s as o,j as i,a4 as c,az as l,b as u,P as p,k as m}from"./chunk-bb5383fa.js";import{p as d,g as f,S as h,a as g,O as C,C as j,E as y,b as D,B as F,c as x,L as S}from"./chunk-4dbeaf6f.js";import{u as b,C as k}from"./chunk-2f00d703.js";import{M as I,O as T,W as E,C as R}from"./chunk-d436b362.js";import{D as L}from"./chunk-95585c1a.js";import{u as v}from"./chunk-30941db8.js";import"./chunk-d6a3ff5a.js";import"./chunk-7a1034f3.js";import"./chunk-67dba361.js";let P=m.isMobile?{width:{ideal:640}}:null;function A(p){let{apiCheck:m,onLivenessDetectionDone:L,captureFrameSettings:A,onFramesCaptured:M,frontCamera:H,flipVideoHorizontal:O,customDirectionIcon:U,customStepTimeConstraints:w,onProcessing:V,customErrors:$,apiCredentials:_,outputEncryptionSettings:B,cameraScale:K,defaultCameraId:N,passiveModeAuto:z,offsetFaceY:G,styledComponent:Y,serviceSettings:W,onReset:q,isLoading:J}=p,Q=e(),{onErrorCallback:X,onCloseCallback:Z}=v(),ee=r.useAsset("bg_camera_mask.png"),er=r.useAsset("bg_camera_mask_red.png"),es=s("IDCapturing.loadingIcon.src","ic_loading.gif"),[ea,en]=a.useState({}),{yFaceDetectionError:et,yFaceVerificationStepsWrapper:eo}=ea,[ei,ec]=a.useState(""),[el,eu]=a.useState(),ep=a.useMemo(()=>({backgroundColor:n("Selfie.backgroundColor")({theme:Q})}),[Q]),em=a.useCallback(({lostY:e,height:r,clientHeight:s})=>{let a=e+25,n=a+30;en({yFaceDetectionError:a,yFaceVerificationStepsWrapper:n+r+20});let t=Math.floor(e),o=Math.floor(s-e),i=Math.floor(n);return 0!==G&&(i+G<t||i+G+r>o)?X({code:`offsetFaceY must be in [-${i-t}, ${o-r-i}]`}):i+=G,{y:i}},[G,X]),{shouldResetFlowOnOrientationChange:ed,countdownToTakePicture:ef,cropArea:eh,curStepIndex:eg,faceDetectionError:eC,resetFlow:ej,handleTriggerPassiveMode:ey,handleVideoPlayed:eD,refVideo:eF,showCountdown:ex,steps:eS,refIsReseting:eb,videoPlayed:ek,warmupDone:eI,showCaptureButton:eT,shouldShowCountdown:eE,showLoading:eR}=b({currentOrientation:el,apiCheck:m,bgCameraMask:ee,bgCameraMaskRed:er,surroundStyle:ep,onLivenessDetectionDone:L,onError:X,cropAreaDimension:em,customDirectionIcon:U,captureFrameSettings:A,onFramesCaptured:M,setRemainingTime:ec,customStepTimeConstraints:w,onProcessing:V,customErrors:$,apiCredentials:_,outputEncryptionSettings:B,cameraScale:K,passiveModeAuto:z,serviceSettings:W,onReset:q});a.useEffect(()=>{"string"==typeof eS[0]?.directionIcon&&Promise.all(eS.map(e=>d(e.directionIcon)))},[eS]);let{CloseCameraButton:eL}=Y,ev=f(p,Q),eP=eb.current?0:eg/eS.length*100,{lang:eA}=t.useSDKSettings(),eM=a.useRef(0),eH=a.useRef({}),eO=a.useRef(o.ErrorDuration.SHORT),eU=a.useMemo(()=>{let{msg:e,duration:r=o.ErrorDuration.SHORT}=eC||{},s=e?.[eA];return Date.now()-eM.current>=eO.current&&(eM.current=Date.now(),eO.current=r,eH.current=s),eH.current},[eC,eg]),ew=a.useCallback(e=>{eu(e),ed?ej():e===I.LANDSCAPE?eF.current?.pause():eF.current?.play()},[eF,ej,ed]);return i.jsx(T,{onOrientationChange:ew,children:i.jsxs(c,{frontCamera:H,onVideoPlayed:eD,onClose:Z,flipHorizontal:O??H,ref:eF,videoSettings:P,onError:X,scale:K,defaultCameraId:N,closeButton:eL||i.jsx(l,{}),children:[!eI&&i.jsx(E,{}),ek?i.jsxs(i.Fragment,{children:["string"==typeof eU?i.jsx(h,{top:et-15,className:"face-detection-error",children:eU}):null,eh.current?i.jsxs(R,{x:`${eh.current.x}px`,y:`${eh.current.y}px`,width:`${eh.current.width}px`,height:`${eh.current.height}px`,surroundStyle:eh.current.surroundStyle,children:[i.jsx(g,{}),i.jsx(C,{...ev,progress:eP,showErrorRing:!!eC&&n("Selfie.progressCircle.showErrorRing")({theme:Q})}),eE?i.jsx(j,{children:ef}):null,eC&&i.jsx(y,{})]}):null,ei&&i.jsx(D,{top:eo-30,children:ei}),eT?i.jsx(F,{children:i.jsx(x,{onClick:ey,disabled:ex,children:u(Q,"Selfie.captureIcon.src")?i.jsx("img",{src:u(Q,"Selfie.captureIcon.src"),alt:""}):i.jsx(k,{fillColor:"rgba(193, 197, 204, 1)"})})}):null]}):null,(eR||J)&&i.jsx(S,{children:i.jsx("img",{src:es,alt:""})})]})})}A.propTypes={apiCheck:p.bool,mode:p.string,onLivenessDetectionDone:p.func,onClose:p.func,onError:p.func,onReset:p.func,captureFrameSettings:p.shape({}),onFramesCaptured:p.func,frontCamera:p.bool,isLoading:p.bool,flipVideoHorizontal:p.bool,customDirectionIcon:p.shape({}),customStepTimeConstraints:p.shape({}),onProcessing:p.func,customErrors:p.shape({}),apiCredentials:p.shape({accessKey:p.string,secretKey:p.string,apiUrl:p.string}),outputEncryptionSettings:p.shape({}),cameraScale:p.number,defaultCameraId:p.string,passiveModeAuto:p.bool,offsetFaceY:p.number,styledComponent:p.shape({CloseCameraButton:p.node}),serviceSettings:p.shape({})},A.defaultProps={apiCheck:!1,mode:null,onLivenessDetectionDone:null,onClose:null,onError:()=>{},onReset:()=>{},captureFrameSettings:{enable:!1,framesIntervalTime:180,framesBatchLength:0},onFramesCaptured:()=>{},frontCamera:!0,isLoading:!1,flipVideoHorizontal:null,customDirectionIcon:{[o.FaceDirection.LEFT]:i.jsx(L,{type:o.FaceDirection.LEFT}),[o.FaceDirection.RIGHT]:i.jsx(L,{type:o.FaceDirection.RIGHT}),[o.FaceDirection.UP]:i.jsx(L,{type:o.FaceDirection.UP}),[o.FaceDirection.FRONTAL]:i.jsx(L,{type:o.FaceDirection.FRONTAL})},customStepTimeConstraints:{[o.FaceDirection.UP]:{delayTime:0},[o.FaceDirection.LEFT]:{delayTime:0},[o.FaceDirection.RIGHT]:{delayTime:0},[o.FaceDirection.FRONTAL]:{delayTime:2e3}},onProcessing:()=>{},customErrors:null,apiCredentials:{accessKey:"",secretKey:"",apiUrl:""},outputEncryptionSettings:null,cameraScale:1,defaultCameraId:void 0,passiveModeAuto:!1,offsetFaceY:0,styledComponent:{CloseCameraButton:null},serviceSettings:{enableUploadFrames:!0,enableUploadImages:!0,enableVerifySanityPortrait:!0,enableVerifySanityIDCard:!0,enableVerifyFaceLiveness:!0,enableDetectIDCardTampering:!0,enableReadIDCardInfo:!0}};export{A as default};
@@ -1 +1 @@
1
- let e;import{d as t,r as s,j as n,a as i,aa as l,c as r,a9 as a,ab as o,o as c,u as u,g as g,p as d,s as S,e as h,Y as v}from"./chunk-f003d34d.js";import{e as f,d as j,c as p,D as b,S as x}from"./chunk-17ccf2c0.js";let k=s.createContext({}),y={},C=({children:e,enableGetClientSettings:i,clientSettings:l,apiCredentials:r,flowId:a})=>{let{apiClient:o}=t.useApiClient({apiCredentials:r}),[c,u]=s.useState({}),[g,d]=s.useState(!1);s.useEffect(()=>{i?async function e(){try{if(!o||"function"!=typeof o.clientSettings)return;let e=await o.clientSettings({flow_id:a});u(e)}catch(e){console.error(e)}finally{d(!0)}}():d(!0)},[i,o,a]);let S=y;return(l&&Object.keys(l).length>0?S=l:i&&(S=c),g)?n.jsx(k.Provider,{value:S,children:e}):null},m=()=>s.useContext(k),_=({children:e,onError:t})=>{let s=m();return n.jsx(i.LicenseProvider,{clientSettings:s,onError:t,children:e})},E=({children:e,onError:t,type:s})=>{let i=m();return n.jsx(l.Provider,{clientSettings:i,type:s,onError:t,children:e})},D={},P=({children:e,customTexts:t=D})=>{let s=m(),{lang:i,uiSettings:l}=r.useSDKSettings(),c=a({customTexts:t,clientSettings:s,lang:i,uiSettings:l});return n.jsx(o.SDKLocaleProvider,{value:c,children:e})},L={},B=({children:e,customTheme:t=L})=>{let s=m(),{uiSettings:i,themeVersion:l}=r.useSDKSettings(),a=f({customTheme:t,clientSettings:s,themeVersion:l,uiSettings:i,defaultThemes:j});return n.jsx(c,{theme:a,children:e})},z=v.lazy(()=>import("./chunk-4bdebcdd.js")),w=v.lazy(()=>import("./chunk-6a6c84e6.js")),A=v.lazy(()=>import("./chunk-4c5427d3.js")),K=v.lazy(()=>import("./chunk-825b5b31.js")),I=v.lazy(()=>import("./chunk-191cab03.js")),V=v.lazy(()=>import("./chunk-37cdf0c6.js"));var T=(e=e=>{var t,i,l;let a,{logCredentials:o={enable:!1},livenessComponent:c,customTheme:v={},customTexts:f,...j}=e,{mode:k,flowId:y,onError:C,onClose:D,debug:L,onLivenessDetectionDone:T}=j,W=m(),{billingSettings:M,enableBilling:O,themeVersion:G}=r.useSDKSettings(),F=u.getWebSetting(W,"data.settings.sdk_settings.billing_settings.billing_config"),{submitBilling:U}=g({enable:O,onError:C,billingSettings:M??{json:F??{}},billingUrl:u.getWebSetting(W,"data.settings.sdk_settings.billing_settings.url")}),Y=d.buildBillingInput(e),$=p(),q="face_authen"===$?S.BillingService.faceAuth:S.BillingService.selfie,H=s.useCallback(async(...e)=>{if("face_authen"===$)return void await T(...e);try{if(!await U({service:q,input:Y,output:{...d.buildBillingOutput(e?.[0]||{}),sdkStatus:S.BillingStatus.success}}))return}catch(e){console.error(e)}await T(...e)},[Y,q,$,T,U]),J=s.useCallback(e=>{S.ErrorsWithoutBilling.includes(e.code)?C(e):(U({service:q,input:Y,output:{error:e,sdkStatus:S.BillingStatus.fail}}),C&&C(e))},[U,q,Y,C]),N=s.useCallback(()=>{U({service:q,input:Y,output:{sdkStatus:S.BillingStatus.cancel}}),D&&D()},[U,q,Y,D]),Q=(t=k,i=c,l=G,a=K,t===S.Mode.ACTIVE&&(a=i?.ActiveLiveness??("v1"===l?I:K)),t===S.Mode.PASSIVE_V2&&(a=i?.PassiveLivenessV2??A),t===S.Mode.PASSIVE&&(a=i?.PassiveLiveness??("v1"===l?V:w)),"string"==typeof t&&t.startsWith("flash")&&(a=i?.FlashLiveness??z),a);return n.jsx(b,{debug:L,children:n.jsx(x,{onDone:T,onError:J,onClose:N,children:n.jsx(P,{customTexts:f,children:n.jsx(E,{onError:J,type:"face_authen"===y?"face_auth":"liveness",children:n.jsx(_,{onError:C,children:n.jsx(B,{customTheme:v,children:n.jsx(h.SDKTrackingProvider,{value:{tracking:{...o}},children:n.jsx(s.Suspense,{fallback:null,children:n.jsx(Q,{...j,onLivenessDetectionDone:H})})})})})})})})})},function(t){let{apiCheck:s,apiCredentials:i,serviceSettings:l,flowId:r,clientSettings:a}=t,o=s&&(l?.enableGetClientSettings??!0);return n.jsx(C,{enableGetClientSettings:o,clientSettings:a,apiCredentials:i,flowId:r,children:n.jsx(e,{...t})})}),W=Object.freeze({__proto__:null,default:T});export{C as C,T as L,P as S,W as i,m as u};
1
+ let e;import{d as t,r as s,j as n,a as i,aa as l,c as r,a9 as a,ab as o,o as c,u as u,g as g,p as d,s as S,e as h,Y as v}from"./chunk-bb5383fa.js";import{e as f,d as j,c as p,D as b,S as x}from"./chunk-30941db8.js";let k=s.createContext({}),y={},C=({children:e,enableGetClientSettings:i,clientSettings:l,apiCredentials:r,flowId:a})=>{let{apiClient:o}=t.useApiClient({apiCredentials:r}),[c,u]=s.useState({}),[g,d]=s.useState(!1);s.useEffect(()=>{i?async function e(){try{if(!o||"function"!=typeof o.clientSettings)return;let e=await o.clientSettings({flow_id:a});u(e)}catch(e){console.error(e)}finally{d(!0)}}():d(!0)},[i,o,a]);let S=y;return(l&&Object.keys(l).length>0?S=l:i&&(S=c),g)?n.jsx(k.Provider,{value:S,children:e}):null},m=()=>s.useContext(k),_=({children:e,onError:t})=>{let s=m();return n.jsx(i.LicenseProvider,{clientSettings:s,onError:t,children:e})},E=({children:e,onError:t,type:s})=>{let i=m();return n.jsx(l.Provider,{clientSettings:i,type:s,onError:t,children:e})},D={},P=({children:e,customTexts:t=D})=>{let s=m(),{lang:i,uiSettings:l}=r.useSDKSettings(),c=a({customTexts:t,clientSettings:s,lang:i,uiSettings:l});return n.jsx(o.SDKLocaleProvider,{value:c,children:e})},L={},B=({children:e,customTheme:t=L})=>{let s=m(),{uiSettings:i,themeVersion:l}=r.useSDKSettings(),a=f({customTheme:t,clientSettings:s,themeVersion:l,uiSettings:i,defaultThemes:j});return n.jsx(c,{theme:a,children:e})},z=v.lazy(()=>import("./chunk-f253519c.js")),w=v.lazy(()=>import("./chunk-5952fbfb.js")),A=v.lazy(()=>import("./chunk-a9d5f5ae.js")),K=v.lazy(()=>import("./chunk-e2249d38.js")),I=v.lazy(()=>import("./chunk-df438efe.js")),V=v.lazy(()=>import("./chunk-d7808881.js"));var T=(e=e=>{var t,i,l;let a,{logCredentials:o={enable:!1},livenessComponent:c,customTheme:v={},customTexts:f,...j}=e,{mode:k,flowId:y,onError:C,onClose:D,debug:L,onLivenessDetectionDone:T}=j,W=m(),{billingSettings:M,enableBilling:O,themeVersion:G}=r.useSDKSettings(),F=u.getWebSetting(W,"data.settings.sdk_settings.billing_settings.billing_config"),{submitBilling:U}=g({enable:O,onError:C,billingSettings:M??{json:F??{}},billingUrl:u.getWebSetting(W,"data.settings.sdk_settings.billing_settings.url")}),Y=d.buildBillingInput(e),$=p(),q="face_authen"===$?S.BillingService.faceAuth:S.BillingService.selfie,H=s.useCallback(async(...e)=>{if("face_authen"===$)return void await T(...e);try{if(!await U({service:q,input:Y,output:{...d.buildBillingOutput(e?.[0]||{}),sdkStatus:S.BillingStatus.success}}))return}catch(e){console.error(e)}await T(...e)},[Y,q,$,T,U]),J=s.useCallback(e=>{S.ErrorsWithoutBilling.includes(e.code)?C(e):(U({service:q,input:Y,output:{error:e,sdkStatus:S.BillingStatus.fail}}),C&&C(e))},[U,q,Y,C]),N=s.useCallback(()=>{U({service:q,input:Y,output:{sdkStatus:S.BillingStatus.cancel}}),D&&D()},[U,q,Y,D]),Q=(t=k,i=c,l=G,a=K,t===S.Mode.ACTIVE&&(a=i?.ActiveLiveness??("v1"===l?I:K)),t===S.Mode.PASSIVE_V2&&(a=i?.PassiveLivenessV2??A),t===S.Mode.PASSIVE&&(a=i?.PassiveLiveness??("v1"===l?V:w)),"string"==typeof t&&t.startsWith("flash")&&(a=i?.FlashLiveness??z),a);return n.jsx(b,{debug:L,children:n.jsx(x,{onDone:T,onError:J,onClose:N,children:n.jsx(P,{customTexts:f,children:n.jsx(E,{onError:J,type:"face_authen"===y?"face_auth":"liveness",children:n.jsx(_,{onError:C,children:n.jsx(B,{customTheme:v,children:n.jsx(h.SDKTrackingProvider,{value:{tracking:{...o}},children:n.jsx(s.Suspense,{fallback:null,children:n.jsx(Q,{...j,onLivenessDetectionDone:H})})})})})})})})})},function(t){let{apiCheck:s,apiCredentials:i,serviceSettings:l,flowId:r,clientSettings:a}=t,o=s&&(l?.enableGetClientSettings??!0);return n.jsx(C,{enableGetClientSettings:o,clientSettings:a,apiCredentials:i,flowId:r,children:n.jsx(e,{...t})})}),W=Object.freeze({__proto__:null,default:T});export{C as C,T as L,P as S,W as i,m as u};
@@ -1,4 +1,4 @@
1
- let e,t;import{r as r,i as a,j as o,e as i,G as n,aE as l,I as s,au as c,aF as u,aG as h,s as d,c as f,J as m,t as g,aH as _,v as p,av as b,k as y,K as w,P as E,d as C}from"./chunk-f003d34d.js";import{W as v}from"./chunk-60dc6fe1.js";let A=({onVideoPlayed:e})=>{let[t,a]=r.useState(!1),[o,i]=r.useState({});return{onVideoPlayed:r.useCallback(t=>{i((e=>{let{videoAreaWidth:t,videoAreaHeight:r,lostX:a,lostY:o}=e;return{width:t,height:r,x:Math.max(a,0),y:Math.max(o,0)}})(t)),a(!0),"function"==typeof e&&e(t)},[e]),cropArea:o,isPlaying:t}},F={LOADING:"loading",FAR_FACE:"far_face",CLOSE_FACE:"close_face",START_FLASHING:"start_flashing",STOP_DECTECTING:"stop_detecting"},R={FAR_FACE:"far",CLOSE_FACE:"close",FLASHING:"flashing"},S={timeout:"timeout",no_face:"no_face"},x=({prediction:e,canvas:t,index:r,quality:a=.8})=>{let o=t.toDataURL("image/jpeg",a);return e?{label:"portrait",base64:o.split(",")[1],landmarks:e.landmarks,index:r}:{label:"portrait",base64:o.split(",")[1],index:r}},k=a.div`
1
+ let e,t;import{r as r,i as a,j as o,e as i,G as n,aE as l,I as s,au as c,aF as u,aG as h,s as d,c as f,J as m,t as g,aH as _,v as p,av as b,k as y,K as w,P as E,d as C}from"./chunk-bb5383fa.js";import{W as v}from"./chunk-d436b362.js";let A=({onVideoPlayed:e})=>{let[t,a]=r.useState(!1),[o,i]=r.useState({});return{onVideoPlayed:r.useCallback(t=>{i((e=>{let{videoAreaWidth:t,videoAreaHeight:r,lostX:a,lostY:o}=e;return{width:t,height:r,x:Math.max(a,0),y:Math.max(o,0)}})(t)),a(!0),"function"==typeof e&&e(t)},[e]),cropArea:o,isPlaying:t}},F={LOADING:"loading",FAR_FACE:"far_face",CLOSE_FACE:"close_face",START_FLASHING:"start_flashing",STOP_DECTECTING:"stop_detecting"},R={FAR_FACE:"far",CLOSE_FACE:"close",FLASHING:"flashing"},S={timeout:"timeout",no_face:"no_face"},x=({prediction:e,canvas:t,index:r,quality:a=.8})=>{let o=t.toDataURL("image/jpeg",a);return e?{label:"portrait",base64:o.split(",")[1],landmarks:e.landmarks,index:r}:{label:"portrait",base64:o.split(",")[1],index:r}},k=a.div`
2
2
  position: fixed;
3
3
  top: 0;
4
4
  left: 0;
@@ -1 +1 @@
1
- import{aj as r,ak as n,aR as t,ag as e,aS as u,$ as o}from"./chunk-f003d34d.js";import{r as a,f as i,g as c,h as s,i as p,j as f,k as l,l as _,n as v,o as g,p as b}from"./chunk-17ccf2c0.js";function j(){if(d)return O;d=1;var t=r(),e=n(),u=s();return O=function(r){if(!e(r))return!1;var n=t(r);return"[object Error]"==n||"[object DOMException]"==n||"string"==typeof r.message&&"string"==typeof r.name&&!u(r)}}function m(){return M?I:(M=1,I=/<%=([\s\S]+?)%>/g)}var y,h,O,d,w,E,R,$,k,S,x,L,P,U,q,A,D,F,I,M,z,B,C,G,H,J,K,N,Q,T,V,W,X,Y,Z=o(function(){if(Y)return X;Y=1;var r=function(){if(h)return y;h=1;var r=a(),n=i(),t=c();return y=n(function(n,e,u,o){r(e,t(e),n,o)})}(),n=function(){if(E)return w;E=1;var r=f(),n=p(),t=j();return w=n(function(n,e){try{return r(n,void 0,e)}catch(r){return t(r)?r:Error(r)}})}(),o=function(){if($)return R;$=1;var r=t();return R=function(n,t){return r(t,function(r){return n[r]})}}(),s=function(){if(S)return k;S=1;var r=e(),n=Object.prototype,t=n.hasOwnProperty;return k=function(e,u,o,a){return void 0===e||r(e,n[o])&&!t.call(a,o)?u:e}}(),O=function(){if(L)return x;L=1;var r={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"};return x=function(n){return"\\"+r[n]}}(),d=j(),I=b(),M=function(){if(F)return D;F=1;var r=v(),n=function(){if(A)return q;A=1;var r=_(),n=U?P:(U=1,P=l()(Object.keys,Object)),t=Object.prototype.hasOwnProperty;return q=function(e){if(!r(e))return n(e);var u=[];for(var o in Object(e))t.call(e,o)&&"constructor"!=o&&u.push(o);return u}}(),t=g();return D=function(e){return t(e)?r(e):n(e)}}(),Z=m(),rr=function(){if(W)return V;W=1;var r=function(){if(J)return H;J=1;var r=function(){if(G)return C;G=1;var r=B?z:(B=1,z=function(r){return function(n){return null==r?void 0:r[n]}});return C=r({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})}(),n=u(),t=/[&<>"']/g,e=RegExp(t.source);return H=function(u){return(u=n(u))&&e.test(u)?u.replace(t,r):u}}(),n=N?K:(N=1,K=/<%-([\s\S]+?)%>/g),t=T?Q:(T=1,Q=/<%([\s\S]+?)%>/g),e=m();return V={escape:n,evaluate:t,interpolate:e,variable:"",imports:{_:{escape:r}}}}(),rn=u(),rt=/\b__p \+= '';/g,re=/\b(__p \+=) '' \+/g,ru=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ro=/[()=,{}\[\]\/\s]/,ra=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ri=/($^)/,rc=/['\n\r\u2028\u2029\\]/g,rs=Object.prototype.hasOwnProperty;return X=function(t,e,u){var a=rr.imports._.templateSettings||rr;u&&I(t,e,u)&&(e=void 0),t=rn(t),e=r({},e,a,s);var i=r({},e.imports,a.imports,s),c=M(i),p=o(i,c),f,l,_=0,v=e.interpolate||ri,g="__p += '",b=RegExp((e.escape||ri).source+"|"+v.source+"|"+(v===Z?ra:ri).source+"|"+(e.evaluate||ri).source+"|$","g"),j=rs.call(e,"sourceURL")?"//# sourceURL="+(e.sourceURL+"").replace(/\s/g," ")+"\n":"";t.replace(b,function(r,n,e,u,o,a){return e||(e=u),g+=t.slice(_,a).replace(rc,O),n&&(f=!0,g+="' +\n__e("+n+") +\n'"),o&&(l=!0,g+="';\n"+o+";\n__p += '"),e&&(g+="' +\n((__t = ("+e+")) == null ? '' : __t) +\n'"),_=a+r.length,r}),g+="';\n";var m=rs.call(e,"variable")&&e.variable;if(m){if(ro.test(m))throw Error("Invalid `variable` option passed into `_.template`")}else g="with (obj) {\n"+g+"\n}\n";g=(l?g.replace(rt,""):g).replace(re,"$1").replace(ru,"$1;"),g="function("+(m||"obj")+") {\n"+(m?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(f?", __e = _.escape":"")+(l?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+g+"return __p\n}";var y=n(function(){return Function(c,j+"return "+g).apply(void 0,p)});if(y.source=g,d(y))throw y;return y}}());export{Z as t};
1
+ import{aj as r,ak as n,aR as t,ag as e,aS as u,$ as o}from"./chunk-bb5383fa.js";import{r as a,f as i,g as c,h as s,i as p,j as f,k as l,l as _,n as v,o as g,p as b}from"./chunk-30941db8.js";function j(){if(d)return O;d=1;var t=r(),e=n(),u=s();return O=function(r){if(!e(r))return!1;var n=t(r);return"[object Error]"==n||"[object DOMException]"==n||"string"==typeof r.message&&"string"==typeof r.name&&!u(r)}}function m(){return M?I:(M=1,I=/<%=([\s\S]+?)%>/g)}var y,h,O,d,w,E,R,$,k,S,x,L,P,U,q,A,D,F,I,M,z,B,C,G,H,J,K,N,Q,T,V,W,X,Y,Z=o(function(){if(Y)return X;Y=1;var r=function(){if(h)return y;h=1;var r=a(),n=i(),t=c();return y=n(function(n,e,u,o){r(e,t(e),n,o)})}(),n=function(){if(E)return w;E=1;var r=f(),n=p(),t=j();return w=n(function(n,e){try{return r(n,void 0,e)}catch(r){return t(r)?r:Error(r)}})}(),o=function(){if($)return R;$=1;var r=t();return R=function(n,t){return r(t,function(r){return n[r]})}}(),s=function(){if(S)return k;S=1;var r=e(),n=Object.prototype,t=n.hasOwnProperty;return k=function(e,u,o,a){return void 0===e||r(e,n[o])&&!t.call(a,o)?u:e}}(),O=function(){if(L)return x;L=1;var r={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"};return x=function(n){return"\\"+r[n]}}(),d=j(),I=b(),M=function(){if(F)return D;F=1;var r=v(),n=function(){if(A)return q;A=1;var r=_(),n=U?P:(U=1,P=l()(Object.keys,Object)),t=Object.prototype.hasOwnProperty;return q=function(e){if(!r(e))return n(e);var u=[];for(var o in Object(e))t.call(e,o)&&"constructor"!=o&&u.push(o);return u}}(),t=g();return D=function(e){return t(e)?r(e):n(e)}}(),Z=m(),rr=function(){if(W)return V;W=1;var r=function(){if(J)return H;J=1;var r=function(){if(G)return C;G=1;var r=B?z:(B=1,z=function(r){return function(n){return null==r?void 0:r[n]}});return C=r({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})}(),n=u(),t=/[&<>"']/g,e=RegExp(t.source);return H=function(u){return(u=n(u))&&e.test(u)?u.replace(t,r):u}}(),n=N?K:(N=1,K=/<%-([\s\S]+?)%>/g),t=T?Q:(T=1,Q=/<%([\s\S]+?)%>/g),e=m();return V={escape:n,evaluate:t,interpolate:e,variable:"",imports:{_:{escape:r}}}}(),rn=u(),rt=/\b__p \+= '';/g,re=/\b(__p \+=) '' \+/g,ru=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ro=/[()=,{}\[\]\/\s]/,ra=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ri=/($^)/,rc=/['\n\r\u2028\u2029\\]/g,rs=Object.prototype.hasOwnProperty;return X=function(t,e,u){var a=rr.imports._.templateSettings||rr;u&&I(t,e,u)&&(e=void 0),t=rn(t),e=r({},e,a,s);var i=r({},e.imports,a.imports,s),c=M(i),p=o(i,c),f,l,_=0,v=e.interpolate||ri,g="__p += '",b=RegExp((e.escape||ri).source+"|"+v.source+"|"+(v===Z?ra:ri).source+"|"+(e.evaluate||ri).source+"|$","g"),j=rs.call(e,"sourceURL")?"//# sourceURL="+(e.sourceURL+"").replace(/\s/g," ")+"\n":"";t.replace(b,function(r,n,e,u,o,a){return e||(e=u),g+=t.slice(_,a).replace(rc,O),n&&(f=!0,g+="' +\n__e("+n+") +\n'"),o&&(l=!0,g+="';\n"+o+";\n__p += '"),e&&(g+="' +\n((__t = ("+e+")) == null ? '' : __t) +\n'"),_=a+r.length,r}),g+="';\n";var m=rs.call(e,"variable")&&e.variable;if(m){if(ro.test(m))throw Error("Invalid `variable` option passed into `_.template`")}else g="with (obj) {\n"+g+"\n}\n";g=(l?g.replace(rt,""):g).replace(re,"$1").replace(ru,"$1;"),g="function("+(m||"obj")+") {\n"+(m?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(f?", __e = _.escape":"")+(l?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+g+"return __p\n}";var y=n(function(){return Function(c,j+"return "+g).apply(void 0,p)});if(y.source=g,d(y))throw y;return y}}());export{Z as t};
@@ -1,4 +1,4 @@
1
- import{P as e,c as a,r as t,j as r,o as s,e as n,b as i,h as c,s as l,i as d}from"./chunk-f003d34d.js";import{P as o,O as u}from"./chunk-60dc6fe1.js";import{u as f,a as p,S as m,R as g,U as y}from"./chunk-99247a2f.js";import{d as _,m as C}from"./chunk-17ccf2c0.js";import{L as h}from"./chunk-d8a92cb1.js";import{t as R}from"./chunk-47f573ed.js";let v=e=>{let{clientSettings:i,onError:c,onStepDone:l,logCredentials:d,uiOnlyComponent:o,detectIdCard:u,outputEncryptionSettings:g,steps:y,customTheme:C}=e,{settings:h}=f({clientSettings:i}),{themeVersion:R}=a.useSDKSettings(),v=t.useCallback(async e=>await l({...e,restartSession:I?.handleRestartSession}),[l,I?.handleRestartSession]),I=p({settings:h,onError:c,detectIdCard:u,outputEncryptionSettings:g,steps:y,onStepDone:v});return r.jsx(s,{theme:{...C,themeVersion:R,defaultThemes:_},children:r.jsx(n.SDKTrackingProvider,{value:{tracking:{...d}},children:r.jsx(o,{...e,onStepDone:v,settings:h,scannerTypeCons:m,...I})})})};v.propTypes={clientSettings:e.shape({}),onError:e.func,onStepDone:e.func,logCredentials:e.shape({}),readIDCardUIOnlyComponent:e.func,uiOnlyComponent:e.func,steps:e.arrayOf(e.shape({})),detectIdCard:e.func,outputEncryptionSettings:e.shape({}),customTheme:e.shape({})},v.defaultProps={clientSettings:void 0,onError:()=>{},onStepDone:()=>{},logCredentials:{enable:!0},readIDCardUIOnlyComponent:g,uiOnlyComponent:y,steps:void 0,detectIdCard:void 0,outputEncryptionSettings:null,customTheme:{}};let I={id_card_sanity:3,portrait_sanity:3,face_liveness_with_card_tampering_ocr:3,compare_faces:3},F={card_sanity:!0,card_tampering:!0,card_ocr:!0,face_sanity:!0,face_liveness:!0,compare_faces:!0,search_face:!0,index_face:!0},T="ID_CARD",A="FACE_LIVENESS",k="IDLE",S={},b={REACH_RETRY_LIMIT:{en:"You have reached the retry limit. Please try again later.",vi:"Bạn đ\xe3 vượt qu\xe1 số lần thử. Vui l\xf2ng thử lại sau."},FAIL_STEP:{en:"Please try again at step: <%= step %>.",vi:"Vui l\xf2ng thử lại ở bước: <%= step %>."},FAIL_FRONT_CARD_SANITY:{en:"The front side of your ID card failed sanity check.",vi:"H\xecnh ảnh Mặt trước của GTTT kh\xf4ng đạt chất lượng y\xeau cầu."},FAIL_FRONT_CARD_TAMPERING:{en:"The front side of your ID card failed tampering check.",vi:"H\xecnh ảnh Mặt trước của GTTT kh\xf4ng hợp lệ."},FAIL_FRONT_CARD_OCR:{en:"Cannot read information on the front side of your ID card.",vi:"Kh\xf4ng đọc được th\xf4ng tin từ h\xecnh ảnh Mặt trước của GTTT."},FAIL_BACK_CARD_SANITY:{en:"The back side of your ID card failed sanity check.",vi:"H\xecnh ảnh Mặt sau của GTTT kh\xf4ng đạt chất lượng y\xeau cầu."},FAIL_BACK_CARD_TAMPERING:{en:"The back side of your ID card failed tampering check.",vi:"H\xecnh ảnh Mặt sau của GTTT kh\xf4ng hợp lệ."},FAIL_BACK_CARD_OCR:{en:"Cannot read information on the back side of your ID card.",vi:"Kh\xf4ng đọc được th\xf4ng tin từ h\xecnh ảnh Mặt sau của GTTT."},FAIL_FACE_SANITY:{en:"Selfie step failed sanity check.",vi:"H\xecnh ảnh khu\xf4n mặt kh\xf4ng đạt chất lượng y\xeau cầu."},FAIL_FACE_LIVENESS:{en:"Selfie step failed liveness check.",vi:"H\xecnh ảnh khu\xf4n mặt kh\xf4ng hợp lệ."},FAIL_COMPARE_FACE:{en:"Failed compare faces between ID photo and selfie.",vi:"H\xecnh ảnh khu\xf4n mặt tr\xean GTTT kh\xf4ng giống h\xecnh chụp ch\xe2n dung"},RETRY_BUTTON:{en:"Retry",vi:"Thử lại"},STOP_BUTTON:{en:"Stop",vi:"Dừng"},FRONT_CARD:{en:"Front Card",vi:"Mặt trước"},BACK_CARD:{en:"Back Card",vi:"Mặt sau"},ID_CARD:{en:"ID Card",vi:"Thẻ ID"},FACE_LIVENESS:{en:"Face Liveness",vi:"Nhận diện khu\xf4n mặt"}};function L(e){var a;if("object"!=typeof(a=e)||"function"!=typeof a.then)return"pending";let t={};return Promise.race([e,t]).then(e=>e===t?"pending":"fulfilled",()=>"rejected")}let w=(e,a)=>{if(!i(a,"face_liveness"))return!1;let t=i(e,"verifyFaceLivenessResult.is_live",!1),r=i(e,"verifyFaceLivenessResult.status","");return!t||"success"!==r},E=(e,a)=>{if(!i(a,"card_sanity"))return!1;let t=i(e,"apiResult.sanityResult.status",""),r=i(e,"apiResult.sanityResult.card_sanity.verdict","");return"success"!==t||"good"!==r},D=e=>!!i(e,"errors")||"success"!==i(e,"data.status","")||"good"!==i(e,"data.card_tampering.verdict",""),O=e=>!!i(e,"errors")||"success"!==i(e,"data.status",""),N=e=>{let a=i(e,"compare_faces",[]);return a[0]?.result!=="matched"||1!==a.filter(e=>e?.result==="matched").length||e.errors},P=async(e,a,t)=>{if(i(a,"card_tampering")){let a=i(e.current,"frontCard.apiResult.detectIDTamperingBackground");if("fulfilled"===await L(a)){let{result:a,message:t}=await i(e.current,"frontCard.apiResult.detectIDTamperingBackground"),r=D(a),s={frontCard:{apiResult:{tamperingInfo:{...a?.data,message:r?i(t,"error"):i(t,"success")}}}};if(C(e.current,s),r)return!0}if(t){let a=i(e.current,"backCard.apiResult.detectIDTamperingBackground");if("fulfilled"===await L(a)){let{result:a,message:t}=await i(e.current,"backCard.apiResult.detectIDTamperingBackground"),r=D(a),s={backCard:{apiResult:{tamperingInfo:{...a?.data,message:r?i(t,"error"):i(t,"success")}}}};if(C(e.current,s),r)return!0}}}if(i(a,"card_ocr")){let a=i(e.current,"frontCard.apiResult.readIDCardBackground");if("fulfilled"===await L(a)){let{result:a,message:t}=await i(e.current,"frontCard.apiResult.readIDCardBackground"),r=O(a),s={frontCard:{apiResult:{cardInfo:{...a?.data,message:r?i(t,"error"):i(t,"success")}}}};if(C(e.current,s),r)return!0}if(t){let a=i(e.current,"backCard.apiResult.readIDCardBackground");if("fulfilled"===await L(a)){let{result:a,message:t}=await i(e.current,"backCard.apiResult.readIDCardBackground"),r=O(a),s={backCard:{apiResult:{cardInfo:{...a?.data,message:r?i(t,"error"):i(t,"success")}}}};if(C(e.current,s),r)return!0}}}return!1},x=async(e,a,t)=>{let r=!1;if(i(a,"card_tampering")){let{result:a,message:s}=await i(e.current,"frontCard.apiResult.detectIDTamperingBackground"),n=D(a);r=r||n;let c={frontCard:{apiResult:{tamperingInfo:{...a?.data,message:n?i(s,"error"):i(s,"success")}}}};if(C(e.current,c),t){let{result:a}=await i(e.current,"backCard.apiResult.detectIDTamperingBackground"),t=D(a);r=r||t;let n={backCard:{apiResult:{tamperingInfo:{...a?.data,message:t?i(s,"error"):i(s,"success")}}}};C(e.current,n)}}if(i(a,"card_ocr")){let{result:a,message:s}=await i(e.current,"frontCard.apiResult.readIDCardBackground"),n=O(a);r=r||n;let c={frontCard:{apiResult:{cardInfo:{...a?.data,message:n?i(s,"error"):i(s,"success")}}}};if(C(e.current,c),t){let{result:a}=await i(e.current,"backCard.apiResult.readIDCardBackground"),t=O(a);r=r||t;let n={backCard:{apiResult:{cardInfo:{...a?.data,message:t?i(s,"error"):i(s,"success")}}}};C(e.current,n)}}return r},j=(e,a)=>{for(let t in e)a.includes(t)?delete e[t]:"object"==typeof e[t]&&j(e[t],a);return e},B=e=>j(e.current,["message","step","restartSession","detectIDTamperingBackground","readIDCardBackground"]),K=(e,a,t)=>{let r=[];if(i(e,"frontCard.apiResult.sanityResult")&&"good"!==i(e,"frontCard.apiResult.sanityResult.card_sanity.verdict","")){let a=i(e,"frontCard.apiResult.sanityResult.message",null);a?.[t]?r.push(a[t]):r.push(b.FAIL_FRONT_CARD_SANITY[t])}if(i(e,"frontCard.apiResult.tamperingInfo")&&"good"!==i(e,"frontCard.apiResult.tamperingInfo.card_tampering.verdict","")){let a=i(e,"frontCard.apiResult.tamperingInfo.message",null);a?.[t]?r.push(a[t]):r.push(b.FAIL_FRONT_CARD_TAMPERING[t])}if(i(e,"frontCard.apiResult.cardInfo")&&"success"!==i(e,"frontCard.apiResult.cardInfo.status","")){let a=i(e,"frontCard.apiResult.cardInfo.message",null);a?.[t]?r.push(a[t]):r.push(b.FAIL_FRONT_CARD_OCR[t])}if(i(e,"backCard.apiResult.sanityResult")&&"good"!==i(e,"backCard.apiResult.sanityResult.card_sanity.verdict","")){let a=i(e,"backCard.apiResult.sanityResult.message",null);a?.[t]?r.push(a[t]):r.push(b.FAIL_BACK_CARD_SANITY[t])}if(i(e,"backCard.apiResult.tamperingInfo")&&"good"!==i(e,"backCard.apiResult.tamperingInfo.card_tampering.verdict","")){let a=i(e,"backCard.apiResult.tamperingInfo.message",null);a?.[t]?r.push(a[t]):r.push(b.FAIL_BACK_CARD_TAMPERING[t])}if(i(e,"backCard.apiResult.cardInfo")&&"success"!==i(e,"backCard.apiResult.cardInfo.status","")){let a=i(e,"backCard.apiResult.cardInfo.message",null);a?.[t]?r.push(a[t]):r.push(b.FAIL_BACK_CARD_OCR[t])}if(i(e,"faceLiveness.verifyFacePortraitResult")&&"good"!==i(e,"faceLiveness.verifyFacePortraitResult.portrait_sanity.verdict","")){let a=i(e,"faceLiveness.verifyFacePortraitResult.message",null);a?.[t]?r.push(a[t]):r.push(b.FAIL_FACE_SANITY[t])}if(i(e,"faceLiveness.verifyFaceLivenessResult")&&!i(e,"faceLiveness.verifyFaceLivenessResult.is_live",!1)){let a=i(e,"faceLiveness.verifyFaceLivenessResult.message",null);a?.[t]?r.push(a[t]):r.push(b.FAIL_FACE_LIVENESS[t])}if(i(e,"compareFaces",null)&&N(i(e,"compareFaces"))){let a=i(e,"compareFaces.message",null);a?.[t]?r.push(a[t]):r.push(b.FAIL_COMPARE_FACE[t])}return{retryAt:a,results:r}},M=e=>{let a=i(e,"frontCard.apiResult.cardInfo.card_information",[]).find(e=>"id"===e.field);return i(a,"value","")},{Errors:Y,IDCardSide:G,FaceDirection:U,Mode:V}=l,q=[],H=()=>{q=[]},J=()=>new Promise(e=>{let a=setInterval(()=>{q.every(e=>e.id)&&(e(),clearInterval(a))},200)});async function W({hasBackCardStep:e,stepResult:a,frontCardId:t,qrImageId:r,sdkAdapter:s,onError:n,refEkycResult:l,handleFailCardTamperingOCRBackground:d,services:o}){let u,f,p,m;if(!(s instanceof c))return a;let{cardSide:g,cardType:y,recordedVideos:_,qrScannedResult:C,image:h}=a;if(g===G.BACK&&!t)return n(Y.missing_front_id_card),!1;let{uploadImage:R,uploadFiles:v,requestVerifyIDCard:I,detectIDTampering:F,readIDCard:T}=s,A=[R({file:h?.blob,label:`id_card.${y}.${g}`})];C&&C.image&&C.result&&A.push(R({file:C?.image?.blob,label:"qr_code",rawString:C?.result}));let[k,S]=await Promise.all(A);if(k.errors)return n({...Y.upload_error,details:k.reason}),!1;let b=k?.data?.image_id,L=S?.data?.image_data||r;g===G.FRONT?u=b:(u=t,f=b);let w={qrImageId:L,frontCardId:u,backCardId:f};if(i(o,"card_sanity")){let{result:e,message:t}=await I({card_type:y,image1:{id:g===G.FRONT?u:f}});if("good"!==i(e,"data.card_sanity.verdict","")||e.errors)return{...a,apiResult:{...w,sanityResult:{...e?.data,message:i(t,"error")}}};w.sanityResult={...e?.data,message:i(t,"success")}}if(g===G.BACK&&"function"==typeof d&&await P(l,o,e))return d(),{...a,apiResult:w};if(i(o,"card_tampering")){let e={card_type:y,image:{id:u},...g===G.FRONT?{image2:void 0,level:"1"}:{image2:{id:f},level:"concurrent"}};if(L&&(e.qr1_images=[{id:L}]),_&&Array.isArray(_)&&_.length>0){let a=_.filter(e=>null!==e.id),t=_.filter(e=>null===e.id&&e.frames.length>0),r=await Promise.all(t.map(e=>v({frames:e.frames})));e.videos=[...a.map(e=>({id:e.id})),...r.map(e=>({id:e.data.file_id}))]}p=F(e)}if(i(o,"card_ocr")){let e={card_type:y,image1:g===G.FRONT?{id:u}:{id:f}};L&&(e.qr1_images={id:L}),m=T(e)}return{...a,apiResult:{...w,detectIDTamperingBackground:p,readIDCardBackground:m}}}async function z({stepResult:e,sdkAdapter:a,services:t}){let{uploadImage:r,uploadFiles:s,verifyFaceLiveness:n,requestVerifyPortrait:c}=a,l=i(e,"frontalFaces",[]).map(e=>r({file:e,label:"portrait",metadata:JSON.stringify({gesture:U.FRONTAL},{"Content-Type":"multipart/form-data"})})),d=i(e,"steps",[]).map(e=>r({file:e?.image?.blob,label:"portrait",metadata:JSON.stringify({gesture:e?.name})},{"Content-Type":"multipart/form-data"})),o=await Promise.all([...l,...d]),u=o.slice(0,l.length),f=o.slice(-d.length);await J();let{video:p}=e;p&&await s({file:p,label:"video"},{"Content-Type":"multipart/form-data"});let m={...e,frontalFaces:u.map((a,t)=>({id:a?.data?.image_id,blob:e?.frontalFaces?.[t]})),steps:f.map((a,t)=>({image:{id:a?.data?.image_id,blob:e?.steps?.[t]?.image?.blob},name:e?.steps?.[t]?.name})),capturedFrames:e?.capturedFrames};if(i(t,"face_sanity")){let{result:e,message:a}=await c({image:{id:u?.[u.length-1]?.data?.image_id}});if("good"!==i(e,"data.portrait_sanity.verdict","")||i(e,"errors"))return{...m,verifyFacePortraitResult:{...i(e,"data",i(e,"error",{})),message:i(a,"error")}};m.verifyFacePortraitResult={...e?.data,message:i(a,"success")}}if(i(t,"face_liveness")){let{result:a,message:t}=await n({images:u.map(e=>({id:e?.data?.image_id})),gesture_images:f.map((a,t)=>({gesture:e?.steps?.[t]?.name,images:[{id:a?.data?.image_id}]})),videos:q}),r=i(a,"data.is_live");m.verifyFaceLivenessResult={...i(a,"data",i(a,"error",{})),message:r?i(t,"success"):i(t,"error")}}return m}async function $({stepResult:e,sdkAdapter:a,services:t}){let{uploadImage:r,uploadFiles:s,verifyFaceLiveness:n,requestVerifyPortrait:c}=a,l=i(e,"frontalFaces",[]).map(e=>r({file:e,label:"portrait",metadata:JSON.stringify({gesture:U.FRONTAL},{"Content-Type":"multipart/form-data"})})),d=await Promise.all(l);await J();let{video:o}=e;o&&Array.isArray(o)&&o.length>0&&await s({file:o[0],label:"video"},{"Content-Type":"multipart/form-data"});let u={...e,images:d.map((a,t)=>({id:a?.data?.image_id,blob:e?.frontalFaces?.[t]})),frontalFaces:d.map((a,t)=>({id:a?.data?.image_id,blob:e?.frontalFaces?.[t]})),capturedFrames:e?.capturedFrames};if(i(t,"face_sanity")){let{result:e,message:a}=await c({image:{id:d?.[d.length-1]?.data?.image_id}});if("good"!==i(e,"data.portrait_sanity.verdict","")||i(e,"errors"))return{...u,verifyFacePortraitResult:{...i(e,"data",i(e,"error",{})),message:i(a,"error")}};u.verifyFacePortraitResult={...e?.data,message:i(a,"success")}}if(i(t,"face_liveness")){let{result:e,message:a}=await n({images:d.map(e=>({id:e?.data?.image_id})),videos:q}),t=i(e,"data.is_live");u.verifyFaceLivenessResult={...i(e,"data",i(e,"error",{})),message:t?i(a,"success"):i(a,"error")}}return u}async function Q({stepResult:e,sdkAdapter:a,services:t}){let{uploadImage:r,uploadFiles:s,verifyFaceLiveness:n,requestVerifyPortrait:c}=a,l=i(e,"frontalFaces",[]).map(e=>r({file:e,label:"portrait",metadata:JSON.stringify({gesture:U.FRONTAL},{"Content-Type":"multipart/form-data"})})),d=await Promise.all(l);await J();let{video:o}=e;o&&Array.isArray(o)&&o.length>0&&await s({file:o[0],label:"video"},{"Content-Type":"multipart/form-data"});let u={...e,frontalFaces:d.map((a,t)=>({id:a?.data?.image_id,blob:e?.frontalFaces?.[t]})),capturedFrames:e?.capturedFrames};if(i(t,"face_sanity")){let{result:e,message:a}=await c({image:{id:d?.[d.length-1]?.data?.image_id}});if("good"!==i(e,"data.portrait_sanity.verdict","")||i(e,"errors"))return{...u,verifyFacePortraitResult:{...i(e,"data",i(e,"error",{})),message:i(a,"error")}};u.verifyFacePortraitResult={...e?.data,message:i(a,"success")}}if(i(t,"face_liveness")){let{result:e,message:a}=await n({images:d.map(e=>({id:e?.data?.image_id})),videos:q}),t=i(e,"data.is_live");u.verifyFaceLivenessResult={...i(e,"data",i(e,"error",{})),message:t?i(a,"success"):i(a,"error")}}return u}async function X({mode:e,stepResult:a,sdkAdapter:t,services:r}){return e===V.ACTIVE?z({stepResult:a,sdkAdapter:t,services:r}):e===V.PASSIVE?$({stepResult:a,sdkAdapter:t,services:r}):e.includes("flash")?Q({stepResult:a,sdkAdapter:t,services:r}):void 0}async function Z(e){let{livenessMode:a,sdkAdapter:t,onError:r,services:s,hasBackCardStep:n,hasIDFlow:l,...d}=e;if(!(t instanceof c))return d;let{compareFaces:o,searchFaces:u,indexFaces:f}=t,p=i(e,"frontCard.apiResult.frontCardId",null),m=null,g=i(e,"faceLiveness.frontalFaces",[]);m=g[g.length-1]?.id;let y=p&&m,_={...d};if(i(s,"compare_faces")&&l&&y){let{result:e,message:a}=await o({image1:{id:p},image2:{id:m}});if(N(i(e,"data")))return{..._,step:T,compareFaces:{...i(e,"data",i(e,"error",{})),message:i(a,"error")}};_={..._,compareFaces:{...e?.data,message:i(a,"success")}}}if(i(s,"search_face")){let{result:e,message:a}=await u({image:{id:m}}),t=i(e,"data.faces",null);if(Array.isArray(t)&&t.length)return{..._,searchFaces:{...i(e,"data",i(e,"error",{})),message:i(a,"error")}};_={..._,searchFaces:{...e?.data,message:i(a,"success")}}}if(i(s,"index_face")){let a=M(e),{result:t}=await f({image:{id:m,...a?{metadata:JSON.stringify({id:M(e)})}:{}}});_={..._,indexFaces:t?.data}}return _}let ee=d.div`
1
+ import{P as e,c as a,r as t,j as r,o as s,e as n,b as i,h as c,s as l,i as d}from"./chunk-bb5383fa.js";import{P as o,O as u}from"./chunk-d436b362.js";import{u as f,a as p,S as m,R as g,U as y}from"./chunk-4588a2bc.js";import{d as _,m as C}from"./chunk-30941db8.js";import{L as h}from"./chunk-67dba361.js";import{t as R}from"./chunk-7a1034f3.js";let v=e=>{let{clientSettings:i,onError:c,onStepDone:l,logCredentials:d,uiOnlyComponent:o,detectIdCard:u,outputEncryptionSettings:g,steps:y,customTheme:C}=e,{settings:h}=f({clientSettings:i}),{themeVersion:R}=a.useSDKSettings(),v=t.useCallback(async e=>await l({...e,restartSession:I?.handleRestartSession}),[l,I?.handleRestartSession]),I=p({settings:h,onError:c,detectIdCard:u,outputEncryptionSettings:g,steps:y,onStepDone:v});return r.jsx(s,{theme:{...C,themeVersion:R,defaultThemes:_},children:r.jsx(n.SDKTrackingProvider,{value:{tracking:{...d}},children:r.jsx(o,{...e,onStepDone:v,settings:h,scannerTypeCons:m,...I})})})};v.propTypes={clientSettings:e.shape({}),onError:e.func,onStepDone:e.func,logCredentials:e.shape({}),readIDCardUIOnlyComponent:e.func,uiOnlyComponent:e.func,steps:e.arrayOf(e.shape({})),detectIdCard:e.func,outputEncryptionSettings:e.shape({}),customTheme:e.shape({})},v.defaultProps={clientSettings:void 0,onError:()=>{},onStepDone:()=>{},logCredentials:{enable:!0},readIDCardUIOnlyComponent:g,uiOnlyComponent:y,steps:void 0,detectIdCard:void 0,outputEncryptionSettings:null,customTheme:{}};let I={id_card_sanity:3,portrait_sanity:3,face_liveness_with_card_tampering_ocr:3,compare_faces:3},F={card_sanity:!0,card_tampering:!0,card_ocr:!0,face_sanity:!0,face_liveness:!0,compare_faces:!0,search_face:!0,index_face:!0},T="ID_CARD",A="FACE_LIVENESS",k="IDLE",S={},b={REACH_RETRY_LIMIT:{en:"You have reached the retry limit. Please try again later.",vi:"Bạn đ\xe3 vượt qu\xe1 số lần thử. Vui l\xf2ng thử lại sau."},FAIL_STEP:{en:"Please try again at step: <%= step %>.",vi:"Vui l\xf2ng thử lại ở bước: <%= step %>."},FAIL_FRONT_CARD_SANITY:{en:"The front side of your ID card failed sanity check.",vi:"H\xecnh ảnh Mặt trước của GTTT kh\xf4ng đạt chất lượng y\xeau cầu."},FAIL_FRONT_CARD_TAMPERING:{en:"The front side of your ID card failed tampering check.",vi:"H\xecnh ảnh Mặt trước của GTTT kh\xf4ng hợp lệ."},FAIL_FRONT_CARD_OCR:{en:"Cannot read information on the front side of your ID card.",vi:"Kh\xf4ng đọc được th\xf4ng tin từ h\xecnh ảnh Mặt trước của GTTT."},FAIL_BACK_CARD_SANITY:{en:"The back side of your ID card failed sanity check.",vi:"H\xecnh ảnh Mặt sau của GTTT kh\xf4ng đạt chất lượng y\xeau cầu."},FAIL_BACK_CARD_TAMPERING:{en:"The back side of your ID card failed tampering check.",vi:"H\xecnh ảnh Mặt sau của GTTT kh\xf4ng hợp lệ."},FAIL_BACK_CARD_OCR:{en:"Cannot read information on the back side of your ID card.",vi:"Kh\xf4ng đọc được th\xf4ng tin từ h\xecnh ảnh Mặt sau của GTTT."},FAIL_FACE_SANITY:{en:"Selfie step failed sanity check.",vi:"H\xecnh ảnh khu\xf4n mặt kh\xf4ng đạt chất lượng y\xeau cầu."},FAIL_FACE_LIVENESS:{en:"Selfie step failed liveness check.",vi:"H\xecnh ảnh khu\xf4n mặt kh\xf4ng hợp lệ."},FAIL_COMPARE_FACE:{en:"Failed compare faces between ID photo and selfie.",vi:"H\xecnh ảnh khu\xf4n mặt tr\xean GTTT kh\xf4ng giống h\xecnh chụp ch\xe2n dung"},RETRY_BUTTON:{en:"Retry",vi:"Thử lại"},STOP_BUTTON:{en:"Stop",vi:"Dừng"},FRONT_CARD:{en:"Front Card",vi:"Mặt trước"},BACK_CARD:{en:"Back Card",vi:"Mặt sau"},ID_CARD:{en:"ID Card",vi:"Thẻ ID"},FACE_LIVENESS:{en:"Face Liveness",vi:"Nhận diện khu\xf4n mặt"}};function L(e){var a;if("object"!=typeof(a=e)||"function"!=typeof a.then)return"pending";let t={};return Promise.race([e,t]).then(e=>e===t?"pending":"fulfilled",()=>"rejected")}let w=(e,a)=>{if(!i(a,"face_liveness"))return!1;let t=i(e,"verifyFaceLivenessResult.is_live",!1),r=i(e,"verifyFaceLivenessResult.status","");return!t||"success"!==r},E=(e,a)=>{if(!i(a,"card_sanity"))return!1;let t=i(e,"apiResult.sanityResult.status",""),r=i(e,"apiResult.sanityResult.card_sanity.verdict","");return"success"!==t||"good"!==r},D=e=>!!i(e,"errors")||"success"!==i(e,"data.status","")||"good"!==i(e,"data.card_tampering.verdict",""),O=e=>!!i(e,"errors")||"success"!==i(e,"data.status",""),N=e=>{let a=i(e,"compare_faces",[]);return a[0]?.result!=="matched"||1!==a.filter(e=>e?.result==="matched").length||e.errors},P=async(e,a,t)=>{if(i(a,"card_tampering")){let a=i(e.current,"frontCard.apiResult.detectIDTamperingBackground");if("fulfilled"===await L(a)){let{result:a,message:t}=await i(e.current,"frontCard.apiResult.detectIDTamperingBackground"),r=D(a),s={frontCard:{apiResult:{tamperingInfo:{...a?.data,message:r?i(t,"error"):i(t,"success")}}}};if(C(e.current,s),r)return!0}if(t){let a=i(e.current,"backCard.apiResult.detectIDTamperingBackground");if("fulfilled"===await L(a)){let{result:a,message:t}=await i(e.current,"backCard.apiResult.detectIDTamperingBackground"),r=D(a),s={backCard:{apiResult:{tamperingInfo:{...a?.data,message:r?i(t,"error"):i(t,"success")}}}};if(C(e.current,s),r)return!0}}}if(i(a,"card_ocr")){let a=i(e.current,"frontCard.apiResult.readIDCardBackground");if("fulfilled"===await L(a)){let{result:a,message:t}=await i(e.current,"frontCard.apiResult.readIDCardBackground"),r=O(a),s={frontCard:{apiResult:{cardInfo:{...a?.data,message:r?i(t,"error"):i(t,"success")}}}};if(C(e.current,s),r)return!0}if(t){let a=i(e.current,"backCard.apiResult.readIDCardBackground");if("fulfilled"===await L(a)){let{result:a,message:t}=await i(e.current,"backCard.apiResult.readIDCardBackground"),r=O(a),s={backCard:{apiResult:{cardInfo:{...a?.data,message:r?i(t,"error"):i(t,"success")}}}};if(C(e.current,s),r)return!0}}}return!1},x=async(e,a,t)=>{let r=!1;if(i(a,"card_tampering")){let{result:a,message:s}=await i(e.current,"frontCard.apiResult.detectIDTamperingBackground"),n=D(a);r=r||n;let c={frontCard:{apiResult:{tamperingInfo:{...a?.data,message:n?i(s,"error"):i(s,"success")}}}};if(C(e.current,c),t){let{result:a}=await i(e.current,"backCard.apiResult.detectIDTamperingBackground"),t=D(a);r=r||t;let n={backCard:{apiResult:{tamperingInfo:{...a?.data,message:t?i(s,"error"):i(s,"success")}}}};C(e.current,n)}}if(i(a,"card_ocr")){let{result:a,message:s}=await i(e.current,"frontCard.apiResult.readIDCardBackground"),n=O(a);r=r||n;let c={frontCard:{apiResult:{cardInfo:{...a?.data,message:n?i(s,"error"):i(s,"success")}}}};if(C(e.current,c),t){let{result:a}=await i(e.current,"backCard.apiResult.readIDCardBackground"),t=O(a);r=r||t;let n={backCard:{apiResult:{cardInfo:{...a?.data,message:t?i(s,"error"):i(s,"success")}}}};C(e.current,n)}}return r},j=(e,a)=>{for(let t in e)a.includes(t)?delete e[t]:"object"==typeof e[t]&&j(e[t],a);return e},B=e=>j(e.current,["message","step","restartSession","detectIDTamperingBackground","readIDCardBackground"]),K=(e,a,t)=>{let r=[];if(i(e,"frontCard.apiResult.sanityResult")&&"good"!==i(e,"frontCard.apiResult.sanityResult.card_sanity.verdict","")){let a=i(e,"frontCard.apiResult.sanityResult.message",null);a?.[t]?r.push(a[t]):r.push(b.FAIL_FRONT_CARD_SANITY[t])}if(i(e,"frontCard.apiResult.tamperingInfo")&&"good"!==i(e,"frontCard.apiResult.tamperingInfo.card_tampering.verdict","")){let a=i(e,"frontCard.apiResult.tamperingInfo.message",null);a?.[t]?r.push(a[t]):r.push(b.FAIL_FRONT_CARD_TAMPERING[t])}if(i(e,"frontCard.apiResult.cardInfo")&&"success"!==i(e,"frontCard.apiResult.cardInfo.status","")){let a=i(e,"frontCard.apiResult.cardInfo.message",null);a?.[t]?r.push(a[t]):r.push(b.FAIL_FRONT_CARD_OCR[t])}if(i(e,"backCard.apiResult.sanityResult")&&"good"!==i(e,"backCard.apiResult.sanityResult.card_sanity.verdict","")){let a=i(e,"backCard.apiResult.sanityResult.message",null);a?.[t]?r.push(a[t]):r.push(b.FAIL_BACK_CARD_SANITY[t])}if(i(e,"backCard.apiResult.tamperingInfo")&&"good"!==i(e,"backCard.apiResult.tamperingInfo.card_tampering.verdict","")){let a=i(e,"backCard.apiResult.tamperingInfo.message",null);a?.[t]?r.push(a[t]):r.push(b.FAIL_BACK_CARD_TAMPERING[t])}if(i(e,"backCard.apiResult.cardInfo")&&"success"!==i(e,"backCard.apiResult.cardInfo.status","")){let a=i(e,"backCard.apiResult.cardInfo.message",null);a?.[t]?r.push(a[t]):r.push(b.FAIL_BACK_CARD_OCR[t])}if(i(e,"faceLiveness.verifyFacePortraitResult")&&"good"!==i(e,"faceLiveness.verifyFacePortraitResult.portrait_sanity.verdict","")){let a=i(e,"faceLiveness.verifyFacePortraitResult.message",null);a?.[t]?r.push(a[t]):r.push(b.FAIL_FACE_SANITY[t])}if(i(e,"faceLiveness.verifyFaceLivenessResult")&&!i(e,"faceLiveness.verifyFaceLivenessResult.is_live",!1)){let a=i(e,"faceLiveness.verifyFaceLivenessResult.message",null);a?.[t]?r.push(a[t]):r.push(b.FAIL_FACE_LIVENESS[t])}if(i(e,"compareFaces",null)&&N(i(e,"compareFaces"))){let a=i(e,"compareFaces.message",null);a?.[t]?r.push(a[t]):r.push(b.FAIL_COMPARE_FACE[t])}return{retryAt:a,results:r}},M=e=>{let a=i(e,"frontCard.apiResult.cardInfo.card_information",[]).find(e=>"id"===e.field);return i(a,"value","")},{Errors:Y,IDCardSide:G,FaceDirection:U,Mode:V}=l,q=[],H=()=>{q=[]},J=()=>new Promise(e=>{let a=setInterval(()=>{q.every(e=>e.id)&&(e(),clearInterval(a))},200)});async function W({hasBackCardStep:e,stepResult:a,frontCardId:t,qrImageId:r,sdkAdapter:s,onError:n,refEkycResult:l,handleFailCardTamperingOCRBackground:d,services:o}){let u,f,p,m;if(!(s instanceof c))return a;let{cardSide:g,cardType:y,recordedVideos:_,qrScannedResult:C,image:h}=a;if(g===G.BACK&&!t)return n(Y.missing_front_id_card),!1;let{uploadImage:R,uploadFiles:v,requestVerifyIDCard:I,detectIDTampering:F,readIDCard:T}=s,A=[R({file:h?.blob,label:`id_card.${y}.${g}`})];C&&C.image&&C.result&&A.push(R({file:C?.image?.blob,label:"qr_code",rawString:C?.result}));let[k,S]=await Promise.all(A);if(k.errors)return n({...Y.upload_error,details:k.reason}),!1;let b=k?.data?.image_id,L=S?.data?.image_data||r;g===G.FRONT?u=b:(u=t,f=b);let w={qrImageId:L,frontCardId:u,backCardId:f};if(i(o,"card_sanity")){let{result:e,message:t}=await I({card_type:y,image1:{id:g===G.FRONT?u:f}});if("good"!==i(e,"data.card_sanity.verdict","")||e.errors)return{...a,apiResult:{...w,sanityResult:{...e?.data,message:i(t,"error")}}};w.sanityResult={...e?.data,message:i(t,"success")}}if(g===G.BACK&&"function"==typeof d&&await P(l,o,e))return d(),{...a,apiResult:w};if(i(o,"card_tampering")){let e={card_type:y,image:{id:u},...g===G.FRONT?{image2:void 0,level:"1"}:{image2:{id:f},level:"concurrent"}};if(L&&(e.qr1_images=[{id:L}]),_&&Array.isArray(_)&&_.length>0){let a=_.filter(e=>null!==e.id),t=_.filter(e=>null===e.id&&e.frames.length>0),r=await Promise.all(t.map(e=>v({frames:e.frames})));e.videos=[...a.map(e=>({id:e.id})),...r.map(e=>({id:e.data.file_id}))]}p=F(e)}if(i(o,"card_ocr")){let e={card_type:y,image1:g===G.FRONT?{id:u}:{id:f}};L&&(e.qr1_images={id:L}),m=T(e)}return{...a,apiResult:{...w,detectIDTamperingBackground:p,readIDCardBackground:m}}}async function z({stepResult:e,sdkAdapter:a,services:t}){let{uploadImage:r,uploadFiles:s,verifyFaceLiveness:n,requestVerifyPortrait:c}=a,l=i(e,"frontalFaces",[]).map(e=>r({file:e,label:"portrait",metadata:JSON.stringify({gesture:U.FRONTAL},{"Content-Type":"multipart/form-data"})})),d=i(e,"steps",[]).map(e=>r({file:e?.image?.blob,label:"portrait",metadata:JSON.stringify({gesture:e?.name})},{"Content-Type":"multipart/form-data"})),o=await Promise.all([...l,...d]),u=o.slice(0,l.length),f=o.slice(-d.length);await J();let{video:p}=e;p&&await s({file:p,label:"video"},{"Content-Type":"multipart/form-data"});let m={...e,frontalFaces:u.map((a,t)=>({id:a?.data?.image_id,blob:e?.frontalFaces?.[t]})),steps:f.map((a,t)=>({image:{id:a?.data?.image_id,blob:e?.steps?.[t]?.image?.blob},name:e?.steps?.[t]?.name})),capturedFrames:e?.capturedFrames};if(i(t,"face_sanity")){let{result:e,message:a}=await c({image:{id:u?.[u.length-1]?.data?.image_id}});if("good"!==i(e,"data.portrait_sanity.verdict","")||i(e,"errors"))return{...m,verifyFacePortraitResult:{...i(e,"data",i(e,"error",{})),message:i(a,"error")}};m.verifyFacePortraitResult={...e?.data,message:i(a,"success")}}if(i(t,"face_liveness")){let{result:a,message:t}=await n({images:u.map(e=>({id:e?.data?.image_id})),gesture_images:f.map((a,t)=>({gesture:e?.steps?.[t]?.name,images:[{id:a?.data?.image_id}]})),videos:q}),r=i(a,"data.is_live");m.verifyFaceLivenessResult={...i(a,"data",i(a,"error",{})),message:r?i(t,"success"):i(t,"error")}}return m}async function $({stepResult:e,sdkAdapter:a,services:t}){let{uploadImage:r,uploadFiles:s,verifyFaceLiveness:n,requestVerifyPortrait:c}=a,l=i(e,"frontalFaces",[]).map(e=>r({file:e,label:"portrait",metadata:JSON.stringify({gesture:U.FRONTAL},{"Content-Type":"multipart/form-data"})})),d=await Promise.all(l);await J();let{video:o}=e;o&&Array.isArray(o)&&o.length>0&&await s({file:o[0],label:"video"},{"Content-Type":"multipart/form-data"});let u={...e,images:d.map((a,t)=>({id:a?.data?.image_id,blob:e?.frontalFaces?.[t]})),frontalFaces:d.map((a,t)=>({id:a?.data?.image_id,blob:e?.frontalFaces?.[t]})),capturedFrames:e?.capturedFrames};if(i(t,"face_sanity")){let{result:e,message:a}=await c({image:{id:d?.[d.length-1]?.data?.image_id}});if("good"!==i(e,"data.portrait_sanity.verdict","")||i(e,"errors"))return{...u,verifyFacePortraitResult:{...i(e,"data",i(e,"error",{})),message:i(a,"error")}};u.verifyFacePortraitResult={...e?.data,message:i(a,"success")}}if(i(t,"face_liveness")){let{result:e,message:a}=await n({images:d.map(e=>({id:e?.data?.image_id})),videos:q}),t=i(e,"data.is_live");u.verifyFaceLivenessResult={...i(e,"data",i(e,"error",{})),message:t?i(a,"success"):i(a,"error")}}return u}async function Q({stepResult:e,sdkAdapter:a,services:t}){let{uploadImage:r,uploadFiles:s,verifyFaceLiveness:n,requestVerifyPortrait:c}=a,l=i(e,"frontalFaces",[]).map(e=>r({file:e,label:"portrait",metadata:JSON.stringify({gesture:U.FRONTAL},{"Content-Type":"multipart/form-data"})})),d=await Promise.all(l);await J();let{video:o}=e;o&&Array.isArray(o)&&o.length>0&&await s({file:o[0],label:"video"},{"Content-Type":"multipart/form-data"});let u={...e,frontalFaces:d.map((a,t)=>({id:a?.data?.image_id,blob:e?.frontalFaces?.[t]})),capturedFrames:e?.capturedFrames};if(i(t,"face_sanity")){let{result:e,message:a}=await c({image:{id:d?.[d.length-1]?.data?.image_id}});if("good"!==i(e,"data.portrait_sanity.verdict","")||i(e,"errors"))return{...u,verifyFacePortraitResult:{...i(e,"data",i(e,"error",{})),message:i(a,"error")}};u.verifyFacePortraitResult={...e?.data,message:i(a,"success")}}if(i(t,"face_liveness")){let{result:e,message:a}=await n({images:d.map(e=>({id:e?.data?.image_id})),videos:q}),t=i(e,"data.is_live");u.verifyFaceLivenessResult={...i(e,"data",i(e,"error",{})),message:t?i(a,"success"):i(a,"error")}}return u}async function X({mode:e,stepResult:a,sdkAdapter:t,services:r}){return e===V.ACTIVE?z({stepResult:a,sdkAdapter:t,services:r}):e===V.PASSIVE?$({stepResult:a,sdkAdapter:t,services:r}):e.includes("flash")?Q({stepResult:a,sdkAdapter:t,services:r}):void 0}async function Z(e){let{livenessMode:a,sdkAdapter:t,onError:r,services:s,hasBackCardStep:n,hasIDFlow:l,...d}=e;if(!(t instanceof c))return d;let{compareFaces:o,searchFaces:u,indexFaces:f}=t,p=i(e,"frontCard.apiResult.frontCardId",null),m=null,g=i(e,"faceLiveness.frontalFaces",[]);m=g[g.length-1]?.id;let y=p&&m,_={...d};if(i(s,"compare_faces")&&l&&y){let{result:e,message:a}=await o({image1:{id:p},image2:{id:m}});if(N(i(e,"data")))return{..._,step:T,compareFaces:{...i(e,"data",i(e,"error",{})),message:i(a,"error")}};_={..._,compareFaces:{...e?.data,message:i(a,"success")}}}if(i(s,"search_face")){let{result:e,message:a}=await u({image:{id:m}}),t=i(e,"data.faces",null);if(Array.isArray(t)&&t.length)return{..._,searchFaces:{...i(e,"data",i(e,"error",{})),message:i(a,"error")}};_={..._,searchFaces:{...e?.data,message:i(a,"success")}}}if(i(s,"index_face")){let a=M(e),{result:t}=await f({image:{id:m,...a?{metadata:JSON.stringify({id:M(e)})}:{}}});_={..._,indexFaces:t?.data}}return _}let ee=d.div`
2
2
  display: flex;
3
3
  justify-content: space-between;
4
4
  align-items: center;
@@ -1,3 +1,3 @@
1
- import{i as i,P as e,s as t,A as c,U as o,m as r,b as n,j as a}from"./chunk-f003d34d.js";let s=i.img`
1
+ import{i as i,P as e,s as t,A as c,U as o,m as r,b as n,j as a}from"./chunk-bb5383fa.js";let s=i.img`
2
2
  width: ${({width:i})=>i};
3
3
  `;function l({type:i}){let e=c(),l=o(`Selfie.Active.directionIcon.${i}`,`${i}_arrow.gif`),F=o(`Selfie.Active.directionIcon.${t.FaceDirection.FRONTAL}`,"frontal_arrow.svg"),d=r(`Selfie.Active.directionIcon.${i}Width`)({theme:e}),f=n(e,`Selfie.Active.directionIcon.${i}`);return null===f?a.jsx(a.Fragment,{}):i===t.FaceDirection.FRONTAL&&F?a.jsx(s,{src:F,width:d,alt:""}):f&&null!==f?a.jsx(s,{src:n(e,`Selfie.Active.directionIcon.${i}`),width:d,alt:""}):a.jsx(s,{src:l,alt:"",width:d})}l.propTypes={type:e.oneOf([t.FaceDirection.LEFT,t.FaceDirection.RIGHT,t.FaceDirection.UP,t.FaceDirection.FRONTAL])},l.defaultProps={type:t.FaceDirection.LEFT};export{l as D};
@@ -1 +1 @@
1
- import{r as e,u as t,k as s,b as a,A as i,m as n,ap as r,aq as l,M as o,O as _,Q as g,j as d,ar as c,as as m,at as f,au as u,av as v,aC as b,aD as h,az as p,G as k,R as y,d as S,f as C,s as F,aA as x,aB as w,Z as E,P as W}from"./chunk-f003d34d.js";import{d as R}from"./chunk-0ffdb7d1.js";import{t as M}from"./chunk-61824c72.js";import{C as L,O as O}from"./chunk-60dc6fe1.js";import{u as D,S as B,a as I,o as P,b as T,c as j,d as A,n as V,l as q,f as U,F as z,e as Q,s as N,g as G,h as J,i as H,j as K,W as $,k as X,m as Y,p as Z,q as ee,r as et,A as es,O as ea}from"./chunk-7b389c71.js";import{m as ei,u as en,b as er}from"./chunk-17ccf2c0.js";import{u as el}from"./chunk-d8a92cb1.js";let eo=0,e_=1,eg={data:{settings:{sdk_settings:{passive_liveness_v2_settings:{frontal_face_check:{enable:!0,up_down_bound_min:.35,up_down_bound_max:.7},capture_frame_settings:{enable:!1,frames_batch_length:10,frames_interval_time:0,frame_quality:.8,frame_scale:1,auto_capture_min_frames:8,auto_capture_min_frames_far:8,auto_capture_min_frames_close:0},not_qualified_settings:{enable_far:!1,threshold_far:.11},close_eyes_settings:{enable:!1,timeout:5,force_check:!1},face_settings:{chin_height:20,max_far_face_ratio:.9,min_far_face_ratio:.8,mobile:{chin_height:20,max_far_face_ratio:.9,min_far_face_ratio:.85}},timeout_settings:{enable:!0,total:30,countdown:10,max_retry_count:0,non_stoppable:!1},exif_data_settings:{enable:!0},mask_settings:{mobile:{oval_vertical_padding:20,oval_horizontal_padding:20,oval_vertical_offset:60,small_scale:.65},oval_horizontal_padding:20,oval_vertical_padding:20,oval_vertical_offset:0,small_scale:.6},image_settings:{valid_face_ratio:.6,image_quality:1,crop_center_far:!0,crop_center_close:!1,detection_to_whole_face_ratio:.8},blur_far_settings:{enable:!0,blurry_threshold:.4,wait_for_best_image_time_ms:1e3},brightness_detection_far_settings:{enable_too_bright_check:!1,enable_too_dark_check:!1,too_bright_threshold:.83,too_dark_threshold:.195},output_image_settings:{image_ordering:["far","close"]},auto_gen_frame_ids:{enable:!1,max_items:50}}}}}},ed=()=>{let i=el();return e.useMemo(()=>{let e=ei({},eg,i),n={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.enable"),framesIntervalTime:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.frames_interval_time"),framesBatchLength:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.frames_batch_length"),frameScale:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.frame_scale"),frameQuality:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.frame_quality"),autoCaptureMinFrames:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.auto_capture_min_frames"),autoCaptureMinFramesFar:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.auto_capture_min_frames_far"),autoCaptureMinFramesClose:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.auto_capture_min_frames_close")},r={smallScale:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.small_scale":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.small_scale"),largeScale:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.small_scale":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.small_scale"),ovalPadding:{left:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_horizontal_padding":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_horizontal_padding"),right:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_horizontal_padding":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_horizontal_padding"),top:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_vertical_padding":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_vertical_padding"),bottom:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_vertical_padding":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_vertical_padding")},ovalVerticalOffset:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_vertical_offset":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_vertical_offset"),chinToMaskBottomPadding:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.mobile.chin_height":"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.chin_height")},l={minFarFaceRatio:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.mobile.min_far_face_ratio":"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.min_far_face_ratio"),maxFarFaceRatio:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.mobile.max_far_face_ratio":"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.max_far_face_ratio")},o={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.close_eyes_settings.enable"),timeout:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.close_eyes_settings.timeout"),forceCheck:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.close_eyes_settings.force_check")},_={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.exif_data_settings.enable")},g={imageQuality:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.image_settings.image_quality"),validFaceRatio:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.image_settings.valid_face_ratio"),enableCropCenterFar:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.image_settings.crop_center_far"),detectionToWholeFaceRatio:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.image_settings.detection_to_whole_face_ratio")},d=t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.max_retry_count"),c={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.enable"),total:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.total"),countdown:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.countdown"),enableMaxRetryCount:d>0,maxRetryCount:d,interruptible:!t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.non_stoppable")},m={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.blur_far_settings.enable"),threshold:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.blur_far_settings.blurry_threshold"),duration:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.blur_far_settings.wait_for_best_image_time_ms")},f={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.not_qualified_settings.enable_far"),threshold:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.not_qualified_settings.threshold_far")},u={enableTooBrightCheck:a(e,"data.settings.sdk_settings.passive_liveness_v2_settings.brightness_detection_far_settings.enable_too_bright_check"),enableTooDarkCheck:a(e,"data.settings.sdk_settings.passive_liveness_v2_settings.brightness_detection_far_settings.enable_too_dark_check"),tooBrightThreshold:a(e,"data.settings.sdk_settings.passive_liveness_v2_settings.brightness_detection_far_settings.too_bright_threshold"),tooDarkThreshold:a(e,"data.settings.sdk_settings.passive_liveness_v2_settings.brightness_detection_far_settings.too_dark_threshold")},v={imageOrdering:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.output_image_settings.image_ordering"),farImageOrder:e_,closeImageOrder:eo};Array.isArray(v.imageOrdering)&&2===v.imageOrdering.length&&"far"===v.imageOrdering[0]&&"close"===v.imageOrdering[1]&&(v.farImageOrder=0,v.closeImageOrder=1);let b={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.auto_gen_frame_ids.enable")&&c.enable,maxItems:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.auto_gen_frame_ids.max_items")};return{captureFrameSettings:n,livenessSettings:{},flashSettings:{},maskSettings:r,faceSettings:l,closeEyesSettings:o,exifSettings:_,imageSettings:g,timeoutSettings:c,blurCheckFarSettings:m,blurCheckCloseSettings:{},notQualifiedFarSettings:f,notQualifiedCloseSettings:{},brightnessDetectionFarSettings:u,brightnessDetectionCloseSettings:{},outputImageSettings:v,autoGenFrameIds:b,frontalFaceCheckSettings:{enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.frontal_face_check.enable"),upDownBoundMin:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.frontal_face_check.up_down_bound_min"),upDownBoundMax:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.frontal_face_check.up_down_bound_max")}}},[i])},ec=s.isMobile?{width:{ideal:640},whiteBalanceMode:"none"}:{width:{ideal:9999},whiteBalanceMode:"none"},em=(e,t)=>""===t.faceError&&(!!e.isEyeClosed&&!t.isEyeClosed||(!!e.isEyeClosed||!t.isEyeClosed)&&(!!u.hasBetterBrightnessScore(t.brightnessScore,e.brightnessScore)||!!u.hasSameBrightnessScore(t.brightnessScore,e.brightnessScore)&&v.hasBetterBlurScore(t.blurScore,e.blurScore)));function ef(t){let{onReset:s,onDone:a,frontCamera:u,styledComponent:v,onFramesCaptured:S,customComponent:C,extraConfig:F}=t,{onErrorCallback:x,onCloseCallback:w}=en(),E=ed(),W=C?.PassiveLivenessBody??b,O=C?.PassiveLivenessError??h,Z=C?.PassiveLivenessCloseIcon??p,{maskSettings:ee,faceSettings:et,captureFrameSettings:es,exifSettings:ea,imageSettings:ei,timeoutSettings:el,blurCheckFarSettings:eo,outputImageSettings:e_,autoGenFrameIds:eg}=E,ef=e.useRef(),eu=D(),ev=er(),[eb,eh]=e.useState(""),ep=e.useMemo(()=>M(eh,1e3),[]),[ek,ey]=e.useState(!1),[eS,eC]=e.useState(B.LOADING),eF=i(),ex={width:n("FlashLiveness.mask.width")({theme:eF}),height:n("FlashLiveness.mask.height")({theme:eF}),strokeColor:(eS===B.FAR_FACE||eS===B.CLOSE_FACE)&&eb&&!ek?n("FlashLiveness.mask.strokeColorError")({theme:eF}):n("FlashLiveness.mask.strokeColor")({theme:eF}),strokeWidth:2*n("FlashLiveness.mask.strokeWidth")({theme:eF}),path:n("FlashLiveness.mask.path")({theme:eF}),backgroundColor:n("FlashLiveness.maskFill")({theme:eF})},ew=e.useRef(null),[eE,eW,eR]=I(),[eM,eL]=e.useState(0),[eO,eD]=e.useState(!1),eB=e.useRef({frames:[],images:[]}),eI=e.useRef(!1),eP=P(),eT=T({compareFn:em,duration:eo.duration,minFrames:es.autoCaptureMinFrames}),[ej,eA]=e.useState(!1),{sessionId:eV,updateSessionId:eq}=j(),eU=e.useRef(r.createSingleUUID()),{onVideoPlayed:ez,cropArea:eQ,isPlaying:eN}=A({}),{smallScale:eG,largeScale:eJ}=V(ee,{width:ex.width,height:ex.height},{width:eQ.width,height:eQ.height}),eH=1e3*el.total/es.framesIntervalTime,{uuids:eK,getNextUUID:e$,reset:eX}=l({total:Math.min(eg.maxItems,Math.ceil(eH/es.framesBatchLength*1.2))}),eY=e.useCallback(e=>{let t=e[e.length-1];try{let e=JSON.parse(t.metadata);eg.enable&&(e.global_batch_id=e$()),e.global_session_id=eU.current,t.metadata=JSON.stringify(e)}catch(e){console.error("Unable to process last frame metadata",e)}},[eg.enable,e$]),eZ=e.useRef(null),{playVoice:e2}=o.useVoicePlayer(),e0=e.useMemo(()=>R(()=>{if(eI.current=!1,eB.current.frames=[],eB.current.images=[],eZ.current=null,eL(eG),eC(B.FAR_FACE),e2("move_face_into_frame"),eq(),eT.stopCapturing(),ey(!1),eg.enable){let e=eX();_.addExifData("frame_batch_ids",e)}s()},200,{leading:!0}),[eG,e2,eq,eT,eg.enable,s,eX]),e1=q({offset:ee.ovalVerticalOffset,ovalPadding:ee.ovalPadding,largeScale:eJ,maskHeight:eQ.height,ovalHeight:ex.height}),e8=e.useCallback(async()=>{eC(B.STOP_DECTECTING),eu("selfie_passive_v2","user_activity",()=>({passive_liveness_in_ms:performance.now()-ef.current}));let{frames:e}=eB.current;if(es.enable&&es.framesBatchLength>0){let t=e.length%es.framesBatchLength;if(0!==t){let s=e.slice(-1*t);eY(s),"function"==typeof S&&S(s)}}eB.current.images[e_.farImageOrder].blob=await eB.current.images[e_.farImageOrder].blob,_.addExifData("selfie_type","passive_v2"),_.addExifData("passive_liveness_v2",{number_of_frames:{far_frames:e.length},passive_liveness_in_ms:Math.round(performance.now()-ef.current),face_settings:{max_far_face_ratio:et.maxFarFaceRatio,min_far_face_ratio:et.minFarFaceRatio},mask_settings:{oval_vertical_offset:ee.ovalVerticalOffset,small_scale:ee.smallScale},image_settings:{valid_face_ratio:ei.validFaceRatio}});let t=await _.writeCurrentExif({imageData:eB.current.images[e_.farImageOrder],enableExifData:ea.enable});eB.current.images[e_.farImageOrder].blob=t,eP.enable&&(eB.current.images[e_.farImageOrder].encrypted=await g.encrypt({blob:eB.current.images[e_.farImageOrder].blob,key:eP.key})),eB.current.images=eB.current.images.filter(e=>!!e);try{"function"==typeof a&&await a({images:eB.current.images,frames:eB.current.frames})}catch(e){x({error:e})}},[eu,es.enable,es.framesBatchLength,e_.farImageOrder,et.maxFarFaceRatio,et.minFarFaceRatio,ee.ovalVerticalOffset,ee.smallScale,ei.validFaceRatio,ea.enable,eP.enable,eP.key,eY,S,a,x]),e3=e.useCallback(({prediction:e,canvas:t})=>{if(!es.enable)return;let{frames:s}=eB.current,a=U({prediction:e,canvas:t,index:s.length,quality:es.frameQuality});if(a.metadata=JSON.stringify({type:z.FAR_FACE,time:Math.round(performance.now()),session_id:eV}),s.push(a),es.framesBatchLength<=0||s.length%es.framesBatchLength!=0)return;let i=s.slice(-1*es.framesBatchLength);eY(i),"function"==typeof S&&S(i)},[es.enable,es.frameQuality,es.framesBatchLength,S,eY,eV]),e9=e.useCallback(async()=>{let{frames:e}=eB.current;0===e.length&&(eI.current=!0)},[]),e5=e.useMemo(()=>({x:Math.max(eW?.left,0),y:Math.max(eW?.top,0),width:Math.min(eW?.right-eW?.left,eQ.width),height:Math.min(eW?.bottom-eW?.top,eQ.height)}),[eQ.height,eQ.width,eW?.bottom,eW?.left,eW?.right,eW?.top]),e6=e.useCallback(async({frame:e,prediction:t,canvas:s,originalRatio:a})=>{if("no_face"===e.faceError||eB.current.images[e_.farImageOrder])return;if(es.enable){let e=performance.now();if(null!==eZ.current&&e-eZ.current<es.framesIntervalTime)return;eZ.current=e}let i=e=>{let t=X({maskBoundingBox:e5,faceRatio:e.faceRatio,validFaceRatio:ei.validFaceRatio,video:ew.current,shouldCropCenterSquare:ei.enableCropCenterFar,cropArea:eQ,frame:e.snapshot,facePrediction:e.facePrediction,detectionToWholeFaceRatio:ei.detectionToWholeFaceRatio}),s={blob:k.takePicture({canvas:t,quality:ei.imageQuality}),gesture:"frontal",captureTime:e.captureTime,selfieLabel:z.FAR_FACE,qualifyScore:e.qualifyScore,blurScore:e.blurScore,brightnessScore:e.brightnessScore};_.addExifData("model_score.face_blurry_score",s.blurScore),_.addExifData("model_score.face_brightness_score",s.brightnessScore),_.addExifData("model_score.face_qualify_score",s.qualifyScore),_.addExifData("selfie_label",s.selfieLabel),_.addExifData("capture_time",s.captureTime),_.addExifData("type",s.gesture),eB.current.images[e_.farImageOrder]=s},n={qualifyScore:e.qualifyScore,blurScore:e.blurScore,isEyeClosed:e.isEyeClosed,faceRatio:e.faceRatio,snapshot:Q(ew.current),captureTime:Date.now(),facePrediction:N(t,a),brightnessScore:e.brightnessScore,faceError:e.faceError};if(!eo.enable){e3({prediction:t,canvas:s}),i(n),await e8();return}if(!eT.isAutoCapturing()){await e2("please_hold_still"),ey(!0),e3({prediction:t,canvas:s}),eT.startCapturing({onDone:async e=>{i(e),await e8()},initialFrame:n});return}e3({prediction:t,canvas:s}),eT.captureFrame(n)},[e_.farImageOrder,es.enable,es.framesIntervalTime,eo.enable,eT,e3,e5,ei.validFaceRatio,ei.enableCropCenterFar,ei.detectionToWholeFaceRatio,ei.imageQuality,eQ,e8,e2]),{warmupDone:e4}=G({onError:x,isVideoPlaying:eN,step:eS,cropArea:eQ,videoRef:ew,onFarFaceDetected:e9,onFarFullFaceDetected:e6,onFaceError:e.useCallback(({error:e})=>{ep(e),("no_face"===e||"multiple_faces"===e)&&"no_face"===e&&eI.current&&e0()},[e0,ep]),faceSettings:et,maskBoundingRect:eW,shouldPauseFaceDetection:eR||ej,faceDetectionSettings:E,shouldContinueOnError:ek,debug:ev});J(ew.current);H(()=>{!async function(){let{resourceReport:e,measureReport:t}=await y.reportAll();Object.values(e).forEach(e=>{eu("selfie_passive_v2","sdk.download_model",e)}),Object.values(t).forEach(e=>{eu("selfie_passive_v2","sdk.init_model",e)})}()},e4),H(()=>{eC(B.FAR_FACE),eL(eG),e2("move_face_into_frame"),eD(!0),eg.enable&&_.addExifData("frame_batch_ids",eK),_.addExifData("global_session_id",eU.current),ef.current||(ef.current=performance.now())},e4&&eN),H(()=>eu("selfie_passive_v2","user_activity.start"),!0),H(()=>eu("selfie_passive_v2","user_activity.start_far"),eS===B.FAR_FACE);let{Loading:e7}=v,te=e.useCallback(()=>{ey(!1),eT.stopCapturing(),eA(!0)},[eT]),tt=e.useCallback(()=>{eA(!1),e0()},[e0]),{remaining:ts}=K({shouldStart:eO&&el.enable,onTimeout:te,onDelayEnd:tt,onError:x,totalTime:el.total,totalDelay:3,maxRetriesSettings:{enable:el.enableMaxRetryCount,total:el.maxRetryCount},interruptible:el.interruptible}),ta=Y(eb),ti=eQ.y+eQ.height/2+e1,tn=eo.duration,tr=Math.max(tn,es.autoCaptureMinFrames*es.framesIntervalTime);return d.jsxs(d.Fragment,{children:[d.jsx(c,{frontCamera:u,onVideoPlayed:ez,onClose:w,flipHorizontal:u,ref:ew,onError:x,videoSettings:ec,closeButton:d.jsx(Z,{}),children:d.jsxs($,{overlay:!e4||!eN,loadingComponent:e7,children:[!ek&&""!==eb&&d.jsx(m,{}),d.jsx(L,{x:`${Math.round(eQ.x)}px`,y:`${Math.round(eQ.y)}px`,width:`${eQ.width}px`,height:`${eQ.height}px`,surroundStyle:{background:n("FlashLiveness.maskFill")({theme:eF})},children:d.jsx(f,{ref:eE,scale:eM,debug:ev,width:eQ.width,height:eQ.height,padding:ee.ovalPadding,verticalOffset:e1,mask:ex})}),!ek&&""!==ta&&d.jsx(O,{errorY:ti,errorMessage:ta})]})}),d.jsx(W,{step:eS,errorCode:eb,timeoutProps:{remaining:ts,warningThreshold:el.countdown,total:el.total,shouldStart:eO&&el.enable},isAutoCapturing:ek,autoCaptureDuration:tr,extraConfig:F})]})}let eu=t=>{let{apiCheck:s,onLivenessDetectionDone:a,frontalMinSize:i,serviceSettings:n,apiCredentials:r,...l}=t,o=l.customComponent?.FlashLivenessLoading??x,[_,g]=e.useState(!1),c=P(),m=el(),f=C.getEnabledServices(n,m),{verifyLiveness:u}=function({outputEncryptionSettings:t,selfieType:s,enabledServices:a,apiCredentials:i}){let{apiClient:n}=S.useApiClient({apiCredentials:i});return{verifyLiveness:e.useCallback(async({videos:e,images:i,metadata:r})=>{try{let l=await Promise.all(i.map(e=>{if(!t.enable)return n.uploadImage({label:"portrait",file:e.blob,metadata:JSON.stringify({label:e.selfieLabel})});let s=new Blob([e.encrypted.hex]);return n.uploadImage({file:s,label:"portrait",metadata:JSON.stringify({label:e.selfieLabel})},{"X-TV-Key":t.key})})),o=null;a.enableVerifyFaceLiveness&&(o=n.verifyFaceLiveness({images:l.map(e=>({id:e?.data?.image_id,label:"portrait"})),videos:e,metadata:r,selfie_type:s}));let _=null;a.enableVerifySanityPortrait&&(_=n.requestVerifyPortrait({image:{id:l[l.length-1]?.data?.image_id},selfie_type:s}));let[g,d]=await Promise.all([o,_]);return{uploadedImages:l,faceLivenessResult:g,portraitResult:d}}catch(e){return console.error(e),{}}},[n,a.enableVerifyFaceLiveness,a.enableVerifySanityPortrait,t.enable,t.key,s])}}({apiCredentials:r,outputEncryptionSettings:c,selfieType:F.Mode.PASSIVE_V2,enabledServices:f}),{captureFrameSettings:v}=ed(),{framesIntervalTime:b}=v,{onFramesCaptured:h,onReset:p}=t,{onErrorCallback:k}=en(),y=Z(),W=async e=>{let t=e;if(c.enable&&(t=await w.encryptFrames(t,c.key)),"function"==typeof h&&h(t),s&&f.enableUploadFrames){let e={};c.enable&&(e["X-TV-Key"]=c.key),ee.uploadFrameBatch(et(t),y,e)}},R=async e=>{let t={frame_interval:b},n=e.images.filter(e=>"frontal"===e.gesture),r=n.map(e=>e.blob),l=n.map(e=>e.encrypted),o=r[r.length-1],_=o&&"number"==typeof i?await E.scaleImage(o,{minsize:i}):null,d=e.frames;if(c.enable&&(d=await w.encryptFrames(d,c.key)),!s||!f.enableUploadImages)return void await a({capturedFrames:d,frontalFaces:r,frontalFacesEncrypted:l,frontalScaledImage:_,steps:[],metadata:t});try{g(!0);let s=null;s=v.enable?await ee.getAllUploadedBatches():[{frames:et(d)}];let{uploadedImages:i,faceLivenessResult:n,portraitResult:o}=await u({videos:s,images:e.images,metadata:t});if(ee.resetUploadBatches(),g(!1),n?.errors)throw n.errors;if(o?.errors)throw o.errors;await a({capturedFrames:d,steps:[],frontalFaces:r.map((e,t)=>({blob:e,id:i?.[t]?.data?.image_id})),frontalFacesEncrypted:l,frontalScaledImage:_,apiCheckPassed:n?.data.is_live??!1,verifyFaceLivenessResult:n?.data??null,verifyPortraitResult:o?.data??null,uploadFramesResult:s})}catch(e){console.error(e),g(!1),k({error:e})}};return d.jsxs(d.Fragment,{children:[d.jsx(ef,{...l,apiCheck:s,onDone:R,onFramesCaptured:W,onReset:()=>{ee.resetUploadBatches(),"function"==typeof p&&p()}}),s&&d.jsx(o,{loading:_})]})},ev=e=>{let{apiCredentials:t,outputEncryptionSettings:s}=e;return d.jsx(O,{version:"v2",unmountOnHidden:!0,children:d.jsx(es,{apiCredentials:t,children:d.jsx(ea,{settings:s,children:d.jsx(eu,{...e})})})})};ev.propTypes={apiCheck:W.bool,apiCredentials:W.shape({accessKey:W.string,secretKey:W.string,apiUrl:W.string}),onReset:W.func,onLivenessDetectionDone:W.func,onClose:W.func,onError:W.func,onFramesCaptured:W.func,frontCamera:W.bool,styledComponent:W.shape({CloseCameraButton:W.node}),outputEncryptionSettings:W.shape({key:W.string}),frontalMinSize:W.number,serviceSettings:W.shape({enableGetClientSettings:W.bool,enableUploadFrames:W.bool,enableUploadImages:W.bool,enableVerifySanityPortrait:W.bool,enableVerifyFaceLiveness:W.bool}),mode:W.string,flowId:W.string,customTexts:W.shape({}),customComponents:W.shape({PassiveLivenessBody:W.elementType}),extraConfig:W.shape({})},ev.defaultProps={apiCheck:!1,apiCredentials:{},onReset:()=>{},onLivenessDetectionDone:()=>{},onClose:()=>{},onError:()=>{},onFramesCaptured:()=>{},frontCamera:!0,styledComponent:{CloseCameraButton:null},outputEncryptionSettings:{key:""},frontalMinSize:null,serviceSettings:{enableGetClientSettings:!0,enableUploadFrames:!0,enableUploadImages:!0,enableVerifySanityPortrait:!0,enableVerifyFaceLiveness:!0},flowId:"",customTexts:{},customComponents:{PassiveLivenessBody:null},extraConfig:null};export{ev as default};
1
+ import{r as e,u as t,k as s,b as a,A as i,m as n,ap as r,aq as l,M as o,O as _,Q as g,j as d,ar as c,as as m,at as f,au as u,av as v,aC as b,aD as h,az as p,G as k,R as y,d as S,f as C,s as F,aA as x,aB as w,Z as E,P as W}from"./chunk-bb5383fa.js";import{d as R}from"./chunk-05ac2e29.js";import{t as M}from"./chunk-d6a3ff5a.js";import{C as L,O as O}from"./chunk-d436b362.js";import{u as D,S as B,a as I,o as P,b as T,c as j,d as A,n as V,l as q,f as U,F as z,e as Q,s as N,g as G,h as J,i as H,j as K,W as $,k as X,m as Y,p as Z,q as ee,r as et,A as es,O as ea}from"./chunk-69854c99.js";import{m as ei,u as en,b as er}from"./chunk-30941db8.js";import{u as el}from"./chunk-67dba361.js";let eo=0,e_=1,eg={data:{settings:{sdk_settings:{passive_liveness_v2_settings:{frontal_face_check:{enable:!0,up_down_bound_min:.35,up_down_bound_max:.7},capture_frame_settings:{enable:!1,frames_batch_length:10,frames_interval_time:0,frame_quality:.8,frame_scale:1,auto_capture_min_frames:8,auto_capture_min_frames_far:8,auto_capture_min_frames_close:0},not_qualified_settings:{enable_far:!1,threshold_far:.11},close_eyes_settings:{enable:!1,timeout:5,force_check:!1},face_settings:{chin_height:20,max_far_face_ratio:.9,min_far_face_ratio:.8,mobile:{chin_height:20,max_far_face_ratio:.9,min_far_face_ratio:.85}},timeout_settings:{enable:!0,total:30,countdown:10,max_retry_count:0,non_stoppable:!1},exif_data_settings:{enable:!0},mask_settings:{mobile:{oval_vertical_padding:20,oval_horizontal_padding:20,oval_vertical_offset:60,small_scale:.65},oval_horizontal_padding:20,oval_vertical_padding:20,oval_vertical_offset:0,small_scale:.6},image_settings:{valid_face_ratio:.6,image_quality:1,crop_center_far:!0,crop_center_close:!1,detection_to_whole_face_ratio:.8},blur_far_settings:{enable:!0,blurry_threshold:.4,wait_for_best_image_time_ms:1e3},brightness_detection_far_settings:{enable_too_bright_check:!1,enable_too_dark_check:!1,too_bright_threshold:.83,too_dark_threshold:.195},output_image_settings:{image_ordering:["far","close"]},auto_gen_frame_ids:{enable:!1,max_items:50}}}}}},ed=()=>{let i=el();return e.useMemo(()=>{let e=ei({},eg,i),n={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.enable"),framesIntervalTime:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.frames_interval_time"),framesBatchLength:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.frames_batch_length"),frameScale:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.frame_scale"),frameQuality:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.frame_quality"),autoCaptureMinFrames:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.auto_capture_min_frames"),autoCaptureMinFramesFar:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.auto_capture_min_frames_far"),autoCaptureMinFramesClose:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.auto_capture_min_frames_close")},r={smallScale:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.small_scale":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.small_scale"),largeScale:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.small_scale":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.small_scale"),ovalPadding:{left:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_horizontal_padding":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_horizontal_padding"),right:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_horizontal_padding":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_horizontal_padding"),top:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_vertical_padding":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_vertical_padding"),bottom:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_vertical_padding":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_vertical_padding")},ovalVerticalOffset:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_vertical_offset":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_vertical_offset"),chinToMaskBottomPadding:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.mobile.chin_height":"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.chin_height")},l={minFarFaceRatio:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.mobile.min_far_face_ratio":"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.min_far_face_ratio"),maxFarFaceRatio:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.mobile.max_far_face_ratio":"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.max_far_face_ratio")},o={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.close_eyes_settings.enable"),timeout:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.close_eyes_settings.timeout"),forceCheck:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.close_eyes_settings.force_check")},_={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.exif_data_settings.enable")},g={imageQuality:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.image_settings.image_quality"),validFaceRatio:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.image_settings.valid_face_ratio"),enableCropCenterFar:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.image_settings.crop_center_far"),detectionToWholeFaceRatio:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.image_settings.detection_to_whole_face_ratio")},d=t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.max_retry_count"),c={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.enable"),total:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.total"),countdown:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.countdown"),enableMaxRetryCount:d>0,maxRetryCount:d,interruptible:!t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.non_stoppable")},m={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.blur_far_settings.enable"),threshold:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.blur_far_settings.blurry_threshold"),duration:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.blur_far_settings.wait_for_best_image_time_ms")},f={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.not_qualified_settings.enable_far"),threshold:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.not_qualified_settings.threshold_far")},u={enableTooBrightCheck:a(e,"data.settings.sdk_settings.passive_liveness_v2_settings.brightness_detection_far_settings.enable_too_bright_check"),enableTooDarkCheck:a(e,"data.settings.sdk_settings.passive_liveness_v2_settings.brightness_detection_far_settings.enable_too_dark_check"),tooBrightThreshold:a(e,"data.settings.sdk_settings.passive_liveness_v2_settings.brightness_detection_far_settings.too_bright_threshold"),tooDarkThreshold:a(e,"data.settings.sdk_settings.passive_liveness_v2_settings.brightness_detection_far_settings.too_dark_threshold")},v={imageOrdering:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.output_image_settings.image_ordering"),farImageOrder:e_,closeImageOrder:eo};Array.isArray(v.imageOrdering)&&2===v.imageOrdering.length&&"far"===v.imageOrdering[0]&&"close"===v.imageOrdering[1]&&(v.farImageOrder=0,v.closeImageOrder=1);let b={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.auto_gen_frame_ids.enable")&&c.enable,maxItems:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.auto_gen_frame_ids.max_items")};return{captureFrameSettings:n,livenessSettings:{},flashSettings:{},maskSettings:r,faceSettings:l,closeEyesSettings:o,exifSettings:_,imageSettings:g,timeoutSettings:c,blurCheckFarSettings:m,blurCheckCloseSettings:{},notQualifiedFarSettings:f,notQualifiedCloseSettings:{},brightnessDetectionFarSettings:u,brightnessDetectionCloseSettings:{},outputImageSettings:v,autoGenFrameIds:b,frontalFaceCheckSettings:{enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.frontal_face_check.enable"),upDownBoundMin:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.frontal_face_check.up_down_bound_min"),upDownBoundMax:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.frontal_face_check.up_down_bound_max")}}},[i])},ec=s.isMobile?{width:{ideal:640},whiteBalanceMode:"none"}:{width:{ideal:9999},whiteBalanceMode:"none"},em=(e,t)=>""===t.faceError&&(!!e.isEyeClosed&&!t.isEyeClosed||(!!e.isEyeClosed||!t.isEyeClosed)&&(!!u.hasBetterBrightnessScore(t.brightnessScore,e.brightnessScore)||!!u.hasSameBrightnessScore(t.brightnessScore,e.brightnessScore)&&v.hasBetterBlurScore(t.blurScore,e.blurScore)));function ef(t){let{onReset:s,onDone:a,frontCamera:u,styledComponent:v,onFramesCaptured:S,customComponent:C,extraConfig:F}=t,{onErrorCallback:x,onCloseCallback:w}=en(),E=ed(),W=C?.PassiveLivenessBody??b,O=C?.PassiveLivenessError??h,Z=C?.PassiveLivenessCloseIcon??p,{maskSettings:ee,faceSettings:et,captureFrameSettings:es,exifSettings:ea,imageSettings:ei,timeoutSettings:el,blurCheckFarSettings:eo,outputImageSettings:e_,autoGenFrameIds:eg}=E,ef=e.useRef(),eu=D(),ev=er(),[eb,eh]=e.useState(""),ep=e.useMemo(()=>M(eh,1e3),[]),[ek,ey]=e.useState(!1),[eS,eC]=e.useState(B.LOADING),eF=i(),ex={width:n("FlashLiveness.mask.width")({theme:eF}),height:n("FlashLiveness.mask.height")({theme:eF}),strokeColor:(eS===B.FAR_FACE||eS===B.CLOSE_FACE)&&eb&&!ek?n("FlashLiveness.mask.strokeColorError")({theme:eF}):n("FlashLiveness.mask.strokeColor")({theme:eF}),strokeWidth:2*n("FlashLiveness.mask.strokeWidth")({theme:eF}),path:n("FlashLiveness.mask.path")({theme:eF}),backgroundColor:n("FlashLiveness.maskFill")({theme:eF})},ew=e.useRef(null),[eE,eW,eR]=I(),[eM,eL]=e.useState(0),[eO,eD]=e.useState(!1),eB=e.useRef({frames:[],images:[]}),eI=e.useRef(!1),eP=P(),eT=T({compareFn:em,duration:eo.duration,minFrames:es.autoCaptureMinFrames}),[ej,eA]=e.useState(!1),{sessionId:eV,updateSessionId:eq}=j(),eU=e.useRef(r.createSingleUUID()),{onVideoPlayed:ez,cropArea:eQ,isPlaying:eN}=A({}),{smallScale:eG,largeScale:eJ}=V(ee,{width:ex.width,height:ex.height},{width:eQ.width,height:eQ.height}),eH=1e3*el.total/es.framesIntervalTime,{uuids:eK,getNextUUID:e$,reset:eX}=l({total:Math.min(eg.maxItems,Math.ceil(eH/es.framesBatchLength*1.2))}),eY=e.useCallback(e=>{let t=e[e.length-1];try{let e=JSON.parse(t.metadata);eg.enable&&(e.global_batch_id=e$()),e.global_session_id=eU.current,t.metadata=JSON.stringify(e)}catch(e){console.error("Unable to process last frame metadata",e)}},[eg.enable,e$]),eZ=e.useRef(null),{playVoice:e2}=o.useVoicePlayer(),e0=e.useMemo(()=>R(()=>{if(eI.current=!1,eB.current.frames=[],eB.current.images=[],eZ.current=null,eL(eG),eC(B.FAR_FACE),e2("move_face_into_frame"),eq(),eT.stopCapturing(),ey(!1),eg.enable){let e=eX();_.addExifData("frame_batch_ids",e)}s()},200,{leading:!0}),[eG,e2,eq,eT,eg.enable,s,eX]),e1=q({offset:ee.ovalVerticalOffset,ovalPadding:ee.ovalPadding,largeScale:eJ,maskHeight:eQ.height,ovalHeight:ex.height}),e8=e.useCallback(async()=>{eC(B.STOP_DECTECTING),eu("selfie_passive_v2","user_activity",()=>({passive_liveness_in_ms:performance.now()-ef.current}));let{frames:e}=eB.current;if(es.enable&&es.framesBatchLength>0){let t=e.length%es.framesBatchLength;if(0!==t){let s=e.slice(-1*t);eY(s),"function"==typeof S&&S(s)}}eB.current.images[e_.farImageOrder].blob=await eB.current.images[e_.farImageOrder].blob,_.addExifData("selfie_type","passive_v2"),_.addExifData("passive_liveness_v2",{number_of_frames:{far_frames:e.length},passive_liveness_in_ms:Math.round(performance.now()-ef.current),face_settings:{max_far_face_ratio:et.maxFarFaceRatio,min_far_face_ratio:et.minFarFaceRatio},mask_settings:{oval_vertical_offset:ee.ovalVerticalOffset,small_scale:ee.smallScale},image_settings:{valid_face_ratio:ei.validFaceRatio}});let t=await _.writeCurrentExif({imageData:eB.current.images[e_.farImageOrder],enableExifData:ea.enable});eB.current.images[e_.farImageOrder].blob=t,eP.enable&&(eB.current.images[e_.farImageOrder].encrypted=await g.encrypt({blob:eB.current.images[e_.farImageOrder].blob,key:eP.key})),eB.current.images=eB.current.images.filter(e=>!!e);try{"function"==typeof a&&await a({images:eB.current.images,frames:eB.current.frames})}catch(e){x({error:e})}},[eu,es.enable,es.framesBatchLength,e_.farImageOrder,et.maxFarFaceRatio,et.minFarFaceRatio,ee.ovalVerticalOffset,ee.smallScale,ei.validFaceRatio,ea.enable,eP.enable,eP.key,eY,S,a,x]),e3=e.useCallback(({prediction:e,canvas:t})=>{if(!es.enable)return;let{frames:s}=eB.current,a=U({prediction:e,canvas:t,index:s.length,quality:es.frameQuality});if(a.metadata=JSON.stringify({type:z.FAR_FACE,time:Math.round(performance.now()),session_id:eV}),s.push(a),es.framesBatchLength<=0||s.length%es.framesBatchLength!=0)return;let i=s.slice(-1*es.framesBatchLength);eY(i),"function"==typeof S&&S(i)},[es.enable,es.frameQuality,es.framesBatchLength,S,eY,eV]),e9=e.useCallback(async()=>{let{frames:e}=eB.current;0===e.length&&(eI.current=!0)},[]),e5=e.useMemo(()=>({x:Math.max(eW?.left,0),y:Math.max(eW?.top,0),width:Math.min(eW?.right-eW?.left,eQ.width),height:Math.min(eW?.bottom-eW?.top,eQ.height)}),[eQ.height,eQ.width,eW?.bottom,eW?.left,eW?.right,eW?.top]),e6=e.useCallback(async({frame:e,prediction:t,canvas:s,originalRatio:a})=>{if("no_face"===e.faceError||eB.current.images[e_.farImageOrder])return;if(es.enable){let e=performance.now();if(null!==eZ.current&&e-eZ.current<es.framesIntervalTime)return;eZ.current=e}let i=e=>{let t=X({maskBoundingBox:e5,faceRatio:e.faceRatio,validFaceRatio:ei.validFaceRatio,video:ew.current,shouldCropCenterSquare:ei.enableCropCenterFar,cropArea:eQ,frame:e.snapshot,facePrediction:e.facePrediction,detectionToWholeFaceRatio:ei.detectionToWholeFaceRatio}),s={blob:k.takePicture({canvas:t,quality:ei.imageQuality}),gesture:"frontal",captureTime:e.captureTime,selfieLabel:z.FAR_FACE,qualifyScore:e.qualifyScore,blurScore:e.blurScore,brightnessScore:e.brightnessScore};_.addExifData("model_score.face_blurry_score",s.blurScore),_.addExifData("model_score.face_brightness_score",s.brightnessScore),_.addExifData("model_score.face_qualify_score",s.qualifyScore),_.addExifData("selfie_label",s.selfieLabel),_.addExifData("capture_time",s.captureTime),_.addExifData("type",s.gesture),eB.current.images[e_.farImageOrder]=s},n={qualifyScore:e.qualifyScore,blurScore:e.blurScore,isEyeClosed:e.isEyeClosed,faceRatio:e.faceRatio,snapshot:Q(ew.current),captureTime:Date.now(),facePrediction:N(t,a),brightnessScore:e.brightnessScore,faceError:e.faceError};if(!eo.enable){e3({prediction:t,canvas:s}),i(n),await e8();return}if(!eT.isAutoCapturing()){await e2("please_hold_still"),ey(!0),e3({prediction:t,canvas:s}),eT.startCapturing({onDone:async e=>{i(e),await e8()},initialFrame:n});return}e3({prediction:t,canvas:s}),eT.captureFrame(n)},[e_.farImageOrder,es.enable,es.framesIntervalTime,eo.enable,eT,e3,e5,ei.validFaceRatio,ei.enableCropCenterFar,ei.detectionToWholeFaceRatio,ei.imageQuality,eQ,e8,e2]),{warmupDone:e4}=G({onError:x,isVideoPlaying:eN,step:eS,cropArea:eQ,videoRef:ew,onFarFaceDetected:e9,onFarFullFaceDetected:e6,onFaceError:e.useCallback(({error:e})=>{ep(e),("no_face"===e||"multiple_faces"===e)&&"no_face"===e&&eI.current&&e0()},[e0,ep]),faceSettings:et,maskBoundingRect:eW,shouldPauseFaceDetection:eR||ej,faceDetectionSettings:E,shouldContinueOnError:ek,debug:ev});J(ew.current);H(()=>{!async function(){let{resourceReport:e,measureReport:t}=await y.reportAll();Object.values(e).forEach(e=>{eu("selfie_passive_v2","sdk.download_model",e)}),Object.values(t).forEach(e=>{eu("selfie_passive_v2","sdk.init_model",e)})}()},e4),H(()=>{eC(B.FAR_FACE),eL(eG),e2("move_face_into_frame"),eD(!0),eg.enable&&_.addExifData("frame_batch_ids",eK),_.addExifData("global_session_id",eU.current),ef.current||(ef.current=performance.now())},e4&&eN),H(()=>eu("selfie_passive_v2","user_activity.start"),!0),H(()=>eu("selfie_passive_v2","user_activity.start_far"),eS===B.FAR_FACE);let{Loading:e7}=v,te=e.useCallback(()=>{ey(!1),eT.stopCapturing(),eA(!0)},[eT]),tt=e.useCallback(()=>{eA(!1),e0()},[e0]),{remaining:ts}=K({shouldStart:eO&&el.enable,onTimeout:te,onDelayEnd:tt,onError:x,totalTime:el.total,totalDelay:3,maxRetriesSettings:{enable:el.enableMaxRetryCount,total:el.maxRetryCount},interruptible:el.interruptible}),ta=Y(eb),ti=eQ.y+eQ.height/2+e1,tn=eo.duration,tr=Math.max(tn,es.autoCaptureMinFrames*es.framesIntervalTime);return d.jsxs(d.Fragment,{children:[d.jsx(c,{frontCamera:u,onVideoPlayed:ez,onClose:w,flipHorizontal:u,ref:ew,onError:x,videoSettings:ec,closeButton:d.jsx(Z,{}),children:d.jsxs($,{overlay:!e4||!eN,loadingComponent:e7,children:[!ek&&""!==eb&&d.jsx(m,{}),d.jsx(L,{x:`${Math.round(eQ.x)}px`,y:`${Math.round(eQ.y)}px`,width:`${eQ.width}px`,height:`${eQ.height}px`,surroundStyle:{background:n("FlashLiveness.maskFill")({theme:eF})},children:d.jsx(f,{ref:eE,scale:eM,debug:ev,width:eQ.width,height:eQ.height,padding:ee.ovalPadding,verticalOffset:e1,mask:ex})}),!ek&&""!==ta&&d.jsx(O,{errorY:ti,errorMessage:ta})]})}),d.jsx(W,{step:eS,errorCode:eb,timeoutProps:{remaining:ts,warningThreshold:el.countdown,total:el.total,shouldStart:eO&&el.enable},isAutoCapturing:ek,autoCaptureDuration:tr,extraConfig:F})]})}let eu=t=>{let{apiCheck:s,onLivenessDetectionDone:a,frontalMinSize:i,serviceSettings:n,apiCredentials:r,...l}=t,o=l.customComponent?.FlashLivenessLoading??x,[_,g]=e.useState(!1),c=P(),m=el(),f=C.getEnabledServices(n,m),{verifyLiveness:u}=function({outputEncryptionSettings:t,selfieType:s,enabledServices:a,apiCredentials:i}){let{apiClient:n}=S.useApiClient({apiCredentials:i});return{verifyLiveness:e.useCallback(async({videos:e,images:i,metadata:r})=>{try{let l=await Promise.all(i.map(e=>{if(!t.enable)return n.uploadImage({label:"portrait",file:e.blob,metadata:JSON.stringify({label:e.selfieLabel})});let s=new Blob([e.encrypted.hex]);return n.uploadImage({file:s,label:"portrait",metadata:JSON.stringify({label:e.selfieLabel})},{"X-TV-Key":t.key})})),o=null;a.enableVerifyFaceLiveness&&(o=n.verifyFaceLiveness({images:l.map(e=>({id:e?.data?.image_id,label:"portrait"})),videos:e,metadata:r,selfie_type:s}));let _=null;a.enableVerifySanityPortrait&&(_=n.requestVerifyPortrait({image:{id:l[l.length-1]?.data?.image_id},selfie_type:s}));let[g,d]=await Promise.all([o,_]);return{uploadedImages:l,faceLivenessResult:g,portraitResult:d}}catch(e){return console.error(e),{}}},[n,a.enableVerifyFaceLiveness,a.enableVerifySanityPortrait,t.enable,t.key,s])}}({apiCredentials:r,outputEncryptionSettings:c,selfieType:F.Mode.PASSIVE_V2,enabledServices:f}),{captureFrameSettings:v}=ed(),{framesIntervalTime:b}=v,{onFramesCaptured:h,onReset:p}=t,{onErrorCallback:k}=en(),y=Z(),W=async e=>{let t=e;if(c.enable&&(t=await w.encryptFrames(t,c.key)),"function"==typeof h&&h(t),s&&f.enableUploadFrames){let e={};c.enable&&(e["X-TV-Key"]=c.key),ee.uploadFrameBatch(et(t),y,e)}},R=async e=>{let t={frame_interval:b},n=e.images.filter(e=>"frontal"===e.gesture),r=n.map(e=>e.blob),l=n.map(e=>e.encrypted),o=r[r.length-1],_=o&&"number"==typeof i?await E.scaleImage(o,{minsize:i}):null,d=e.frames;if(c.enable&&(d=await w.encryptFrames(d,c.key)),!s||!f.enableUploadImages)return void await a({capturedFrames:d,frontalFaces:r,frontalFacesEncrypted:l,frontalScaledImage:_,steps:[],metadata:t});try{g(!0);let s=null;s=v.enable?await ee.getAllUploadedBatches():[{frames:et(d)}];let{uploadedImages:i,faceLivenessResult:n,portraitResult:o}=await u({videos:s,images:e.images,metadata:t});if(ee.resetUploadBatches(),g(!1),n?.errors)throw n.errors;if(o?.errors)throw o.errors;await a({capturedFrames:d,steps:[],frontalFaces:r.map((e,t)=>({blob:e,id:i?.[t]?.data?.image_id})),frontalFacesEncrypted:l,frontalScaledImage:_,apiCheckPassed:n?.data.is_live??!1,verifyFaceLivenessResult:n?.data??null,verifyPortraitResult:o?.data??null,uploadFramesResult:s})}catch(e){console.error(e),g(!1),k({error:e})}};return d.jsxs(d.Fragment,{children:[d.jsx(ef,{...l,apiCheck:s,onDone:R,onFramesCaptured:W,onReset:()=>{ee.resetUploadBatches(),"function"==typeof p&&p()}}),s&&d.jsx(o,{loading:_})]})},ev=e=>{let{apiCredentials:t,outputEncryptionSettings:s}=e;return d.jsx(O,{version:"v2",unmountOnHidden:!0,children:d.jsx(es,{apiCredentials:t,children:d.jsx(ea,{settings:s,children:d.jsx(eu,{...e})})})})};ev.propTypes={apiCheck:W.bool,apiCredentials:W.shape({accessKey:W.string,secretKey:W.string,apiUrl:W.string}),onReset:W.func,onLivenessDetectionDone:W.func,onClose:W.func,onError:W.func,onFramesCaptured:W.func,frontCamera:W.bool,styledComponent:W.shape({CloseCameraButton:W.node}),outputEncryptionSettings:W.shape({key:W.string}),frontalMinSize:W.number,serviceSettings:W.shape({enableGetClientSettings:W.bool,enableUploadFrames:W.bool,enableUploadImages:W.bool,enableVerifySanityPortrait:W.bool,enableVerifyFaceLiveness:W.bool}),mode:W.string,flowId:W.string,customTexts:W.shape({}),customComponents:W.shape({PassiveLivenessBody:W.elementType}),extraConfig:W.shape({})},ev.defaultProps={apiCheck:!1,apiCredentials:{},onReset:()=>{},onLivenessDetectionDone:()=>{},onClose:()=>{},onError:()=>{},onFramesCaptured:()=>{},frontCamera:!0,styledComponent:{CloseCameraButton:null},outputEncryptionSettings:{key:""},frontalMinSize:null,serviceSettings:{enableGetClientSettings:!0,enableUploadFrames:!0,enableUploadImages:!0,enableVerifySanityPortrait:!0,enableVerifyFaceLiveness:!0},flowId:"",customTexts:{},customComponents:{PassiveLivenessBody:null},extraConfig:null};export{ev as default};