@tsocial/tvweb-sdk 5.38.1 → 5.38.3

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 (40) hide show
  1. package/build/esm/chunk-05fa8f5c.js +1 -0
  2. package/build/esm/chunk-0da5ca80.js +1 -0
  3. package/build/esm/chunk-2c071949.js +3 -0
  4. package/build/esm/{chunk-9fe80ed2.js → chunk-39590709.js} +2 -2
  5. package/build/esm/chunk-39bd8f09.js +1 -0
  6. package/build/esm/chunk-412186c9.js +1 -0
  7. package/build/esm/chunk-5a4684bb.js +256 -0
  8. package/build/esm/chunk-5b66da4d.js +1 -0
  9. package/build/esm/chunk-6633ffde.js +1 -0
  10. package/build/esm/{chunk-9d0b0fc7.js → chunk-68a33382.js} +32 -32
  11. package/build/esm/{chunk-f703e0a4.js → chunk-776149f4.js} +1 -1
  12. package/build/esm/chunk-804b51ae.js +1 -0
  13. package/build/esm/chunk-85504064.js +1 -0
  14. package/build/esm/{chunk-d15b739a.js → chunk-8eff00f2.js} +1 -1
  15. package/build/esm/{chunk-411ea759.js → chunk-93ad2e94.js} +1 -1
  16. package/build/esm/chunk-abc9d931.js +1195 -0
  17. package/build/esm/{chunk-4377ca3e.js → chunk-b0d9736a.js} +2 -2
  18. package/build/esm/{chunk-84471c81.js → chunk-bf273baf.js} +1 -1
  19. package/build/esm/{chunk-e2211b41.js → chunk-dbd45d78.js} +5 -5
  20. package/build/esm/chunk-e1e2700f.js +1 -0
  21. package/build/esm/tvweb-sdk.esm.min.js +1 -1
  22. package/build/tvweb-sdk.cjs.min.js +651 -695
  23. package/build/tvweb-sdk.standalone.js +5990 -7685
  24. package/build/tvweb-sdk.standalone.min.js +651 -695
  25. package/build/types/index.d.ts +1 -9
  26. package/package.json +5 -5
  27. package/build/esm/chunk-265525fb.js +0 -1
  28. package/build/esm/chunk-2a4cb9f5.js +0 -1
  29. package/build/esm/chunk-2bdac502.js +0 -1
  30. package/build/esm/chunk-37a2eeaf.js +0 -1
  31. package/build/esm/chunk-4552fd9e.js +0 -3
  32. package/build/esm/chunk-575fb45a.js +0 -1195
  33. package/build/esm/chunk-7b93e41f.js +0 -1
  34. package/build/esm/chunk-7fd19a76.js +0 -1
  35. package/build/esm/chunk-8c9bb671.js +0 -1
  36. package/build/esm/chunk-906e840c.js +0 -256
  37. package/build/esm/chunk-b8138130.js +0 -45
  38. package/build/esm/chunk-ddb2ebe0.js +0 -1
  39. package/build/esm/chunk-fa315830.js +0 -1
  40. package/build/esm/chunk-fd4614fe.js +0 -1
@@ -1 +0,0 @@
1
- import{r as e,b as t,u as s,aH as a,s as n,c as i,ab as r,d as l,e as c,f as o,k as u,aK as _,aL as m,I as g,O as d,Z as f,Q as h,G as b,av as v,t as p,aB as w,j as k}from"./chunk-575fb45a.js";import{t as y}from"./chunk-d15b739a.js";import{t as F}from"./chunk-37a2eeaf.js";import{n as T,u as L,o as R,q as B,r as C,v as S,s as x,x as I}from"./chunk-906e840c.js";import{m as M}from"./chunk-2bdac502.js";import{u as D}from"./chunk-8c9bb671.js";let E=a.faceTracker(),j=new _,{FaceDirection:P,Errors:A,Messages:V,TrackLivenessEvents:W}=n,N={enable:!1,framesIntervalTime:180,framesBatchLength:0},U={[n.FaceDirection.UP]:{delayTime:0},[n.FaceDirection.LEFT]:{delayTime:0},[n.FaceDirection.RIGHT]:{delayTime:0},[n.FaceDirection.FRONTAL]:{delayTime:2e3}},O=()=>{},z=()=>{},K=()=>{};function Z({apiCheck:_,bgCameraMask:k,bgCameraMaskRed:q,surroundStyle:G,cropAreaDimension:H,customInstructions:J,customIcon:Q,customDirectionIcon:X,customStepTimeConstraints:Y=U,onLivenessDetectionDone:$,onError:ee,frontalMinSize:et,waitingTimeToGetBetterFrames:es=500,captureFrameSettings:ea=N,setRemainingTime:en=O,onProcessing:ei=K,customErrors:er,customMessages:el,apiCredentials:ec={},onFramesCaptured:eo=z,initFirstGestureTimeout:eu=2e3,outputEncryptionSettings:e_,cameraScale:em=1,passiveModeAuto:eg=!1,sendCustomEvent:ed,serviceSettings:ef,currentOrientation:eh,onReset:eb}={}){let[ev,ep]=e.useState(!1),[ew,ek]=e.useState(!1),[ey,eF]=e.useState(!1),[eT,eL]=e.useState(!1),eR=e.useRef(null),{lang:eB,assetRoot:eC,customUrls:eS,exifKey:ex}=i.useSDKSettings(),eI=r.useSDKLocale(),{apiClient:eM}=l.useApiClient({apiCredentials:ec}),[,eD]=e.useReducer(e=>e+1,0),eE=e.useRef(null),[ej,eP]=e.useState(!1),eA=e.useRef({}),{sendEvent:eV}=c.useSDKTracking(),[eW,eN]=e.useState(3),[eU,eO]=e.useState(!1),ez=e.useRef(!1),eK=e.useCallback(e=>{eO(e),ez.current=e},[]),eZ=e.useRef(null),eq=e.useRef([]),eG=e.useRef(null),eH=e.useRef(),eJ=e.useRef(null);null===eJ.current&&(eJ.current=a.initFaceVerificationData({assetRoot:eC,customInstructions:J,customIcon:Q,customDirectionIcon:X,customStepTimeConstraints:Y,Locale:eI,lang:eB}));let[eQ,eX]=e.useState(),eY=e.useCallback(e=>{eX(e)},[]),e$=e.useMemo(()=>y(eY,500),[eY]),e0=e.useRef([]),e1=e.useRef(),e4=D(),{flowIntervalTimeMs:e2,limitTimeLivenessCheck:e3,terminateIfNoFace:e5,closeEyeDetectorSettings:e7,exifDataSettings:e6,recordVideo:e8,autoCaptureSettings:e9,manualCaptureSettings:te,blurCheckSettings:tt,webIsRequiredFrontalFace:ts,waitBeforeStartFlowMs:ta,resetFlowOnOrientationChange:tn,captureFrameSettings:ti}=function({clientSettings:a,captureFrameSettingsProp:n}){return e.useMemo(()=>{let e,i=M({},T,a),r={enable:t(i,"data.settings.sdk_settings.passive_liveness_settings.auto_capture.enable"),showCaptureButton:t(i,"data.settings.sdk_settings.passive_liveness_settings.auto_capture.show_capture_button"),showCountdown:t(i,"data.settings.sdk_settings.passive_liveness_settings.auto_capture.show_countdown"),waitForBestImageTimeMsWeb:t(i,"data.settings.sdk_settings.passive_liveness_settings.auto_capture.wait_for_best_image_time_ms_web")},l={showCountdown:t(i,"data.settings.sdk_settings.passive_liveness_settings.manual_capture.show_countdown"),waitForBestImageTimeMsWeb:t(i,"data.settings.sdk_settings.passive_liveness_settings.manual_capture.wait_for_best_image_time_ms_web")},c={enable:t(i,"data.settings.sdk_settings.passive_liveness_settings.blur_check.enable"),webBlurryThreshold:t(i,"data.settings.sdk_settings.passive_liveness_settings.blur_check.web_blurry_threshold")},o={enable:t(i,"data.settings.sdk_settings.passive_liveness_settings.close_eye_detector.enable"),webThreshold:t(i,"data.settings.sdk_settings.passive_liveness_settings.close_eye_detector.web_threshold"),webTimeout:t(i,"data.settings.sdk_settings.passive_liveness_settings.close_eye_detector.web_timeout"),forceCheck:t(i,"data.settings.sdk_settings.passive_liveness_settings.close_eye_detector.force_check")},u=t(i,"data.settings.sdk_settings.passive_liveness_settings.web_is_required_frontal_face"),_=s.getWebSetting(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.max_retry_count"),m={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.enable"),limitTimeSecond:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.limit_time_second"),remainTimeShow:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.remain_time_show"),format:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.format"),enableMaxRetries:_>0,totalMaxRetries:_,interruptible:!s.getWebSetting(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.non_stoppable")},g={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.terminate_if_no_face.enable"),maxInvalidFrame:t(i,"data.settings.sdk_settings.active_liveness_settings.terminate_if_no_face.max_invalid_frame"),maxTimeMs:t(i,"data.settings.sdk_settings.active_liveness_settings.terminate_if_no_face.max_time_ms")},d={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.exif_data_settings.enable")},f={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.record_video.enable")},h=t(i,"data.settings.sdk_settings.active_liveness_settings.wait_before_start_flow_ms"),b=t(i,"data.settings.sdk_settings.active_liveness_settings.reset_flow_on_orientation_change"),v=t(i,"data.settings.sdk_settings.active_liveness_settings.flow_interval_time_ms"),p=t(a,"data.settings.sdk_settings.active_liveness_settings.save_encoded_frames");return{autoCaptureSettings:r,manualCaptureSettings:l,blurCheckSettings:c,closeEyeDetectorSettings:o,webIsRequiredFrontalFace:u,limitTimeLivenessCheck:m,terminateIfNoFace:g,exifDataSettings:d,recordVideo:f,waitBeforeStartFlowMs:h,resetFlowOnOrientationChange:b,flowIntervalTimeMs:v,captureFrameSettings:e=p?{enable:p.enable,enableLogging:p.enable_logging,framesBatchLength:p.frames_batch_len,framesIntervalTime:p.frames_interval_ms}:n}},[a,n])}({clientSettings:e4,captureFrameSettingsProp:ea}),tr=e9?.enable?e9?.waitForBestImageTimeMsWeb:te?.waitForBestImageTimeMsWeb,tl=e8?.enable,tc=e.useMemo(()=>o.getEnabledServices(ef,e4),[e4,ef]),to=e.useRef(""),tu=e.useCallback(e=>{if(e?.event){if(e.event===W?.show_alert){let t=e.log?.alert;if(t===to.current)return;to.current=t}eV(e),ed&&ed(e)}},[ed,eV]),t_=e.useMemo(()=>y(e=>{tu(e)},2e3),[tu]),tm=e.useRef(0),tg=e.useRef(),td=e.useRef();e.useEffect(()=>{tu({tag:"selfie",event:W?.start_camera,log:{}})},[tu]),e.useEffect(()=>(j.start(),()=>{j.stop()}),[]),e.useEffect(()=>{let e=!1;return async function t(){!ej&&(e1.current=performance.now(),eA.current=await m(eS),await g.initTensorFlow({preferredBackends:["wasm","webgl","cpu"]}),e||(eP(!0),tu({tag:"selfie",event:W?.show_warmup,log:{}}),tu({tag:"selfie",event:W?.finish_load_model,log:{status:"success",time_in_ms:performance.now()-e1.current}}),e1.current=null))}(),()=>{e=!0}},[ej,eS,tu]);let tf=e.useRef(!1),th=e.useCallback(()=>{eJ.current.curStepIndex=eJ.current.steps.length,tf.current=!0,eF(!1),td.current?.discardRecording(),clearInterval(eZ.current)},[]),tb=e.useCallback(()=>{eJ.current=a.initFaceVerificationData({assetRoot:eC,customInstructions:J,customIcon:Q,customDirectionIcon:X,Locale:eI,lang:eB}),tm.current=0,tg.current=null,e0.current=[],eL(!1),eX(null),x(),td.current?.start(),tf.current=!1,eK(!1),eN(3),eG.current=null,eq.current=[],eH.current=null,"function"==typeof eb&&eb(),eD()},[eI,eC,X,Q,J,eK,eB,eb]),tv=e.useCallback(()=>{th(),setTimeout(()=>{tb()},e2)},[e2,tb,th]),tp=e.useMemo(()=>({...A,...er}),[er]),tw=e.useMemo(()=>({...V,...el}),[el]),tk=e.useCallback(()=>{let e={};Object.keys(tp.liveness_terminated_time_out?.msg).forEach(t=>{let s=F(tp.liveness_terminated_time_out?.msg[t]);e[t]=s({x:e3.limitTimeSecond})}),eX({...tp.liveness_terminated_time_out,msg:e,duration:.95*e2}),tu({tag:"selfie",event:W?.show_alert,log:{alert:"liveness_terminated_time_out,"}}),j.stop(),en(""),th()},[tp.liveness_terminated_time_out,e2,e3.limitTimeSecond,th,tu,en]),ty=e.useCallback(({remainTime:e})=>{if(e>0&&e<=e3.remainTimeShow){let t=F(tw.REMAIN_TIME[eB]),s=e;switch(e3.format){case"mm:ss":s=e.toString().padStart(5,"00:00");break;case"ss":s=e.toString().padStart(2,"0")}en(t({x:s}))}},[eB,e3.format,e3.remainTimeShow,tw.REMAIN_TIME,en]),tF=e.useCallback(({attemptCount:e,fromBackground:t})=>{e3.enableMaxRetries&&e>=e3.totalMaxRetries&&ee(n.Errors.max_retry_reached),t&&th(),j.start(),tb()},[e3.enableMaxRetries,e3.totalMaxRetries,ee,tb,th]),{stopTimer:tT}=L({totalTime:e3.limitTimeSecond,totalDelayBetweenReset:e2/1e3,interruptible:e3.interruptible,shouldStart:ew&&e3.enable&&ej,onTimesUp:tk,onTick:ty,onReset:tF}),tL=e.useCallback(({clientWidth:e,clientHeight:t,videoAreaWidth:s,videoAreaHeight:a,lostX:n,lostY:i})=>{let r,l;u.isMobile?l=r=s:r=l=a-200;let c=Math.floor((s-r)/2)+n;eE.current={x:c,y:5+i,width:r,height:l,image:k,surroundStyle:G},"object"==typeof H?eE.current={...eE.current,...H}:"function"==typeof H&&(eE.current={...eE.current,...H({clientWidth:e,clientHeight:t,videoAreaWidth:s,videoAreaHeight:a,lostX:n,lostY:i,isMobile:u.isMobile,width:r,height:l})}),eD(),ek(!0)},[k,G,H]),tR=e.useCallback(()=>{eN(3),clearInterval(eZ.current),eK(!0);let e=async e=>{if(e-1==0){let e;j.stop(),tT(),clearInterval(eZ.current),ei(),await td.current?.stopVideoRecording(),ep(!0),d.addExifData("user_action",{start_selfie:Date.now()-1e3*j.duration("from_1st_frame"),end_selfie:Date.now()});let t=(e=e9.enable?[eG.current]:eq.current).map(e=>f.resizeBlobImg(e.blob,400,400)),s=(await Promise.all(t)).map((t,s)=>{let a=d.parseLivenessImg({...e[s],gesture:"frontal"});return d.writeCurrentExif({imageData:{blob:t},enableExifData:e6.enable,additionalData:a})}),a=await Promise.all(s),n={};if(e_&&e_.key){let{key:e}=e_,t=a.map(t=>h.encrypt({blob:t,key:e}));n={frontalFacesEncrypted:await Promise.all(t)}}let i=[...e0.current];if(e_&&e_.key){let e=await Promise.all(i.map(e=>e?.base64));if(i=i.map((t,s)=>({...t,base64:e[s]})),ti.enable&&ti.framesBatchLength>0&&i.length%ti.framesBatchLength>0){let e=i.slice(-1*(i.length%ti.framesBatchLength));eo(e),_&&tc.enableUploadFrames&&R(e_,e,eM,i.length===ti.framesBatchLength)}}else ti.enable&&ti.framesBatchLength>0&&i.length%ti.framesBatchLength>0&&(eo(i.slice(-1*(i.length%ti.framesBatchLength)).map(({base64:e,label:t,index:s})=>({base64:e,label:t,index:s}))),_&&tc.enableUploadFrames&&R(e_,i.slice(-1*(i.length%ti.framesBatchLength)),eM));if(_&&tc.enableUploadImages){let t=e=>({label:"portrait",metadata:JSON.stringify({gesture_score:e,gesture:P.FRONTAL})}),s=e.map((e,s)=>eM.uploadImage({file:a[s],...t(e.leftRightScore)}));e_&&e_.key&&(s=e.map((e,s)=>{let a=new Blob([n.frontalFacesEncrypted[s].hex]);return eM.uploadImage({file:a,...t(e.leftRightScore)},{"X-TV-Key":e_.key})}));try{let t=await Promise.all(s),a=null;tc.enableVerifyFaceLiveness&&(a=eM.verifyFaceLiveness({images:t.map(e=>({id:e.data.image_id})),videos:[{frames:i}]}));let n=null;tc.enableVerifySanityPortrait&&(n=eM.requestVerifyPortrait({image:{id:t?.[t.length-1]?.data?.image_id}}));let[r,l]=await Promise.all([a,n]);$({apiCheckPassed:r?.data.is_live??!1,verifyFaceLivenessResult:r?.data??null,verifyFacePortraitResult:l?.data??null,frontalFaces:t.map((t,s)=>({id:t?.data?.image_id,blob:e?.[s]?.blob}))})}catch(e){ee({error:e})}}else $({frontalFaces:a,...n,capturedFrames:i,video:B()}),C()}};eZ.current=setInterval(()=>{eN(t=>(e(t),t-1))},tr/3)},[eK,tr,tT,ei,e9.enable,e_,ti.enable,ti.framesBatchLength,_,tc.enableUploadImages,tc.enableUploadFrames,tc.enableVerifyFaceLiveness,tc.enableVerifySanityPortrait,e6.enable,eo,eM,$,ee]),tB=e.useRef({});e.useEffect(()=>{tB.current.isFirstValidFrameFoundRef=eT},[eT]),e.useEffect(()=>{let e,t=eR.current;async function s({faceDirection:e,canvas:t,leftRightScore:s,blurScore:a,isEyeClosed:n}){if(!0===ez.current&&(ts&&e===P.FRONTAL||!ts)){let e=await b.takePicture({canvas:t});e9?.enable&&Date.now()-eH.current<e9?.waitForBestImageTimeMsWeb?(eG.current||(eG.current={blob:e,blurScore:a,isEyeClosed:n,captureTime:Date.now()}),tt?.enable&&(eG.current=I({incomingFrame:{blob:e,blurScore:a,isEyeClosed:n,captureTime:Date.now()},currentBestFrame:eG.current}))):eq.current.length<1&&eq.current.push({blob:e,leftRightScore:s,captureTime:Date.now(),blurScore:a})}}async function i(r,l){let c,o;if(l?.width===0||l?.height===0)return;let{isFirstValidFrameFoundRef:u}=tB.current,{cropX:m,cropY:g,cropWidth:d,cropHeight:f}=r;l.getContext("2d").drawImage(t,m,g,d,f,-((400*em-400)/2)/em,-((400*em-400)/2)/em,400,400);let{blazefaceModel:h,closeEyesModel:b}=eA.current,[y,F]=await Promise.all([v.calculateBlurScore(l),p.getModelPredictions({model:h,sCanvas:l})]),{error:T,fullFace:L,faceRatio:B,faceNotFrontalMinThreshold:C}=await a.validatePredictions({predictions:F,width:p.SIZE,height:p.SIZE});c=T,eE.current.image=k;let S=null,x=null,I=null,{curStepIndex:M,steps:D}=eJ.current;if(L){I=L.landmarks;let e=await a.calculateFaceDirection({landmarks:I,getPerfectFrontal:!0});e&&(S=e.gesture,x=e.leftRightScore);let t=e7?.webTimeout+Y[n.FaceDirection.FRONTAL].delayTime/1e3;if(e7?.enable&&(-1===j.duration("limit_close_eye")||j.duration("limit_close_eye")<t)){e7?.forceCheck||-1!==j.duration("limit_close_eye")||j.start("limit_close_eye");let{isEyeClose:e}=await b.predict(l,I,e7?.webThreshold);e&&!c&&(c=A.close_eye)}}let V=c?.code==="no_face"||c?.code==="partial_face",N=M<D.length;if(!function({noFace:e,isFirstValidFrameFoundRef:t}){if(!e5.enable||!t)return;let{max_time_ms:s}=e5;tg.current&&e||(tg.current={time:Date.now(),frame:0}),e&&tg.current.frame++;let{time:a}=tg.current;e&&Date.now()-a>=s&&(eX({...tp.liveness_terminated_no_face,duration:e2}),tu({tag:"selfie",event:W?.show_alert,log:{alert:"liveness_terminated_no_face"}}),tv())}({noFace:V&&N,isFirstValidFrameFoundRef:u}),c?.code&&t_({tag:"selfie",event:W?.show_alert,log:{alert:c.code}}),!c||"face_too_small"===c.code&&S!==P.FRONTAL&&B>=C){if(!function(e,t,s,a){if(e0.current.length&&Date.now()-e0.current[e0.current.length-1].time<ti.framesIntervalTime)return;if(ti.enable&&!0){let{topLeft:a,bottomRight:n}=e,i=[...a,...n],{score:r,time:l}=E(e,0===e0.current.length),c={label:"portrait",base64:t.toDataURL("image/jpeg",.8).split(",")[1],landmarks:s,original_landmarks:s,score:r,time:l,index:e0.current.length,bbox:i,original_bbox:i};if(e_&&e_.key){if(c.base64=w.encryptFrameBase64(c.base64,e_.key),e0.current.push(c),ti.framesBatchLength>0&&e0.current.length%ti.framesBatchLength==0&&eo){let e=e0.current.slice(-ti.framesBatchLength);Promise.all(e.map(e=>e?.base64)).then(t=>{eo(e.map(({label:e,index:s},a)=>({base64:t[a],label:e,index:s}))),_&&tc.enableUploadFrames&&R(e_,e.map(({label:e,index:s},a)=>({base64:t[a],label:e,index:s})),eM,e0.current.length===ti.framesBatchLength)})}}else e0.current.push(c),ti.framesBatchLength>0&&e0.current.length%ti.framesBatchLength==0&&eo&&(eo(e0.current.slice(-ti.framesBatchLength).map(({base64:e,label:t,index:s})=>({base64:e,label:t,index:s}))),_&&tc.enableUploadFrames&&R(e_,e0.current.slice(-ti.framesBatchLength),eM,e0.current.length===ti.framesBatchLength));return};}(F[0],l,I),S!==P.FRONTAL&&ts)o=tp.not_frontal_face,eE.current.image=q;else if(!c){u||(eL(!0),j.start("from_1st_frame"));let e=e9?.enable&&!ez.current&&0===eq.current.length;tt?.enable?null!==y&&y>tt?.webBlurryThreshold?(o=null,e&&(eH.current=Date.now(),tR())):ez.current||(o=tp.liveness_blurry):e&&(eH.current=Date.now(),tR());let{isEyeClose:t}=await b.predict(l,I,e7?.webThreshold);await s({faceDirection:S,canvas:l,leftRightScore:x,blurScore:y,...null!==t?{isEyeClosed:t}:{}})}}else M<D.length&&(o=tp[c.code],eE.current.image=q);e$(o),-1!==e&&(e=requestAnimationFrame(()=>i(r,l)))}async function r(){let e=b.analyzeVideoAndWindowSizes(t,eE.current),s=document.createElement("canvas");s.width=400,s.height=400;let a=s.getContext("2d");a.translate(400,0),a.scale(-1*em,+em);let{mediaRecorder:n}=tl&&t?await S({outputImagesSize:400,videoEl:t,resultAnalyzeVideoAndWindowSizes:e}):{};td.current=n,td.current&&td.current.start(),i(e,s)}return ew&&ej&&setTimeout(()=>{r()},ta??eu),()=>{cancelAnimationFrame(e),e=-1}},[eh,ta,ts,tt?.enable,tt?.webBlurryThreshold,e9?.enable,e9?.waitForBestImageTimeMsWeb,eu,ew,eB,eM,_,k,q,$,ee,et,es,ti,ei,e3.enable,en,e$,Y,e2,tv,e5,tp,ej,tu,eo,e_,em,tR,eg,e7?.enable,e7?.webThreshold,e7?.webTimeout,e7?.forceCheck,e6.enable,ex,t_,ti.framesBatchLength,tl,tc.enableUploadFrames]),e.useEffect(()=>{eQ&&(eQ?.code!==tp?.liveness_terminated_time_out&&eQ?.code!==tp?.liveness_terminated_no_face&&e9?.enable&&ez.current||(clearInterval(eZ.current),eK(!1),eG.current=null,eq.current=[],eH.current=null))},[e9?.enable,eQ,eK,tp]);let{curStepIndex:tC,steps:tS}=eJ.current,tx=eT&&!eQ&&!eg&&(!e9?.enable||e9?.showCaptureButton),tI=eU&&!tf.current&&(e9?.enable?e9?.showCountdown:te?.showCountdown);return{resetFlowOnOrientationChange:tn,countdownToTakePicture:eW,cropArea:eE,curStepIndex:tC,faceDetectionError:eQ,resetFlow:tv,handleTriggerPassiveMode:tR,handleVideoPlayed:tL,refVideo:eR,refIsReseting:tf,showCountdown:eU,steps:tS,videoPlayed:ew,activeCapturing:ey,isFirstValidFrameFound:eT,warmupDone:ej,showLoading:ev,showCaptureButton:tx,shouldShowCountdown:tI}}function q({className:e="",fillColor:t=null}){return k.jsxs("svg",{className:e,width:"38px",height:"32px",viewBox:"0 0 24 21","data-testid":"camera-icon",children:[k.jsx("title",{children:"FA45C15C-1E21-4D7B-9585-07FB9F999CB8"}),k.jsx("desc",{children:"Created with sketchtool."}),k.jsx("g",{id:"Web-demo",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:k.jsx("g",{id:"step1",transform:"translate(-950.000000, -380.000000)",fill:t??"currentColor",fillRule:"nonzero",children:k.jsx("g",{id:"Group",transform:"translate(950.000000, 380.000000)",children:k.jsx("g",{id:"Group-2",children:k.jsx("g",{id:"camera",children:k.jsx("path",{d:"M21,3 L17,3 L15,0 L9,0 L7,3 L3,3 C1.34314575,3 0,4.34314575 0,6 L0,18 C0,19.6568542 1.34314575,21 3,21 L21,21 C22.6568542,21 24,19.6568542 24,18 L24,6 C24,4.34314575 22.6568542,3 21,3 Z M12,17 C9.23857625,17 7,14.7614237 7,12 C7,9.23857625 9.23857625,7 12,7 C14.7614237,7 17,9.23857625 17,12 C17,14.7614237 14.7614237,17 12,17 L12,17 Z",id:"Shape"})})})})})})]})}export{q as C,Z as u};
@@ -1 +0,0 @@
1
- import{r as e,b as t,u as a,aH as n,s as s,c as i,ab as r,d as l,e as c,aq as o,ap as m,f as g,O as u,k as _,aK as f,aL as d,I as b,Z as h,G as p,Q as v,av as k,t as w,aB as F}from"./chunk-575fb45a.js";import{d as y}from"./chunk-fa315830.js";import{t as I}from"./chunk-d15b739a.js";import{t as T}from"./chunk-37a2eeaf.js";import{w as R,m as S,n as L,u as x,o as B,q as D,r as E,v as A,s as M,t as O}from"./chunk-906e840c.js";import{m as N}from"./chunk-2bdac502.js";import{u as P}from"./chunk-8c9bb671.js";let C=async({steps:e,apiClient:t,FaceDirection:a,outputEncryptionSettings:n,video:s})=>{let i=[];e.forEach(e=>{let{name:s,image:r,frontalFaceImage:l}=e;if(s!==a.FRONTAL){let e={label:"portrait",metadata:JSON.stringify({gesture_score:r.leftRightScore,gesture:s})};if(n&&n.key){let a=new Blob([r.encrypted.hex]);i.push(t.uploadImage({file:a,...e},{"X-TV-Key":n.key}))}else i.push(t.uploadImage({file:r.blob,...e}))}else i.push(Promise.resolve({data:{image_id:null}}));if(l.blob){let e={label:"portrait",metadata:JSON.stringify({gesture_score:l.leftRightScore,gesture:a.FRONTAL})};if(n&&n.key){let a=new Blob([l.encrypted.hex]);i.push(t.uploadImage({file:a,...e},{"X-TV-Key":n.key}))}else i.push(t.uploadImage({file:l.blob,...e}))}else i.push(Promise.resolve({data:{image_id:null}}))});let r=s?t.uploadFile({file:s,label:"video"}):Promise.resolve({data:{file_id:null}}),[l,...c]=await Promise.all([r,...i]);return e.forEach((e,t)=>{e.image.imageId=c[2*t].data.image_id,e.frontalFaceImage.imageId=c[2*t+1].data.image_id}),l},j=async({apiClient:e,faceVerificationFlowData:t,onLivenessDetectionDone:a,captureFrameSettings:n,FaceDirection:s,onError:i,outputEncryptionSettings:r,video:l,enabledServices:c,capturedFrames:o})=>{try{let i=t.current.steps;await C({steps:i,apiClient:e,FaceDirection:s,outputEncryptionSettings:r,video:l});let m=i.filter(e=>e.frontalFaceImage.imageId);if(0===m.length)a({error:"wrong_face_movement"});else{await R();let t=S(n);if(t){let n=null;c.enableVerifyFaceLiveness&&(n=e.verifyFaceLiveness({images:m.map(e=>({id:e.frontalFaceImage.imageId})),gesture_images:i.filter(e=>e.image.imageId&&e.name!==s.FRONTAL).map(({name:e,image:{imageId:t}})=>({gesture:e,images:[{id:t}]})),videos:t}));let r=null;c.enableVerifySanityPortrait&&(r=e.requestVerifyPortrait({image:{id:m[m.length-1].frontalFaceImage.imageId}}));let[l,g]=await Promise.all([n,r]),u=l?.data.is_live===!0;a({apiCheckPassed:u,verifyFaceLivenessResult:l?.data??null,verifyFacePortraitResult:g?.data??null,frontalFaces:m.map(e=>({id:e.frontalFaceImage.imageId,blob:e.frontalFaceImage.blob})),steps:i.filter(e=>e.image.imageId&&e.name!==s.FRONTAL).map(({name:e,image:t})=>({name:e,blob:t.blob,id:t.imageId})),uploadFramesResult:t,capturedFrames:o})}else a({error:"network_error"})}}catch(e){i({error:e})}},U=n.faceTracker(),V=new f,{FaceDirection:W,Errors:K,Messages:$,TrackLivenessEvents:z}=s,J={enable:!1,framesIntervalTime:180,framesBatchLength:0},q={[s.FaceDirection.UP]:{delayTime:0},[s.FaceDirection.LEFT]:{delayTime:0},[s.FaceDirection.RIGHT]:{delayTime:0},[s.FaceDirection.FRONTAL]:{delayTime:2e3}},G=()=>{},H=()=>{},Z=()=>{};function X({apiCheck:f,bgCameraMask:R,bgCameraMaskRed:S,surroundStyle:C,cropAreaDimension:Q,customInstructions:Y,customIcon:ee,customDirectionIcon:et,customStepTimeConstraints:ea=q,onLivenessDetectionDone:en,onError:es,frontalMinSize:ei,waitingTimeToGetBetterFrames:er=500,captureFrameSettings:el=J,setRemainingTime:ec=G,onProcessing:eo=Z,customErrors:em,customMessages:eg,apiCredentials:eu={},onFramesCaptured:e_=H,initFirstGestureTimeout:ef=2e3,outputEncryptionSettings:ed,cameraScale:eb=1,sendCustomEvent:eh,serviceSettings:ep,currentOrientation:ev,onReset:ek}={}){let[ew,eF]=e.useState(!1),[ey,eI]=e.useState(!1),[eT,eR]=e.useState(!1),[eS,eL]=e.useState(!1),ex=e.useRef(null),{lang:eB,assetRoot:eD,customUrls:eE,exifKey:eA}=i.useSDKSettings(),eM=r.useSDKLocale(),{apiClient:eO}=l.useApiClient({apiCredentials:eu}),[,eN]=e.useReducer(e=>e+1,0),eP=e.useRef(null),eC=e.useRef(!1),[ej,eU]=e.useState(!1),eV=e.useRef({}),{sendEvent:eW}=c.useSDKTracking(),eK=e.useRef(null);null===eK.current&&(eK.current=n.initFaceVerificationData({assetRoot:eD,customInstructions:Y,customIcon:ee,customDirectionIcon:et,customStepTimeConstraints:ea,Locale:eM,lang:eB}));let[e$,ez]=e.useState(),eJ=e.useCallback(e=>{ez(e)},[]),eq=e.useMemo(()=>I(eJ,500),[eJ]),eG=e.useRef([]),eH=e.useRef(),eZ=P(),{faceTrackingSetting:eX,flowIntervalTimeMs:eQ,limitTimeLivenessCheck:eY,terminateIfNoFace:e0,closeEyeSettings:e1,captureFrameSettings:e4,exifDataSettings:e6,recordVideo:e2,waitBeforeStartFlowMs:e3,resetFlowOnOrientationChange:e5,autoGenFrameIds:e8}=function({captureFrameSettingsProp:n,clientSettings:s}){return e.useMemo(()=>{let e,i=N({},L,s),r={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.face_tracking_setting.enable"),webTerminateThreshold:t(i,"data.settings.sdk_settings.active_liveness_settings.face_tracking_setting.web_terminate_threshold"),webWarningThreshold:t(i,"data.settings.sdk_settings.active_liveness_settings.face_tracking_setting.web_warning_threshold"),limitFor:t(i,"data.settings.sdk_settings.active_liveness_settings.face_tracking_setting.limit_for"),maxWarningTime:t(i,"data.settings.sdk_settings.active_liveness_settings.face_tracking_setting.max_warning_time")},l=t(i,"data.settings.sdk_settings.active_liveness_settings.reset_flow_on_orientation_change"),c=t(i,"data.settings.sdk_settings.active_liveness_settings.wait_before_start_flow_ms"),o=t(i,"data.settings.sdk_settings.active_liveness_settings.flow_interval_time_ms"),m=t(i,"data.settings.sdk_settings.active_liveness_settings.take_one_picture_time_ms"),g=a.getWebSetting(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.max_retry_count"),u={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.enable"),limitTimeSecond:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.limit_time_second"),remainTimeShow:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.remain_time_show"),format:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.format"),enableMaxRetries:g>0,totalMaxRetries:g,interruptible:!a.getWebSetting(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.non_stoppable")},_={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.terminate_if_no_face.enable"),maxInvalidFrame:t(i,"data.settings.sdk_settings.active_liveness_settings.terminate_if_no_face.max_invalid_frame"),maxTimeMs:t(i,"data.settings.sdk_settings.active_liveness_settings.terminate_if_no_face.max_time_ms")},f={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.close_eye_detector.enable"),webThreshold:t(i,"data.settings.sdk_settings.active_liveness_settings.close_eye_detector.web_threshold"),webTimeout:t(i,"data.settings.sdk_settings.active_liveness_settings.close_eye_detector.web_timeout"),forceCheck:t(i,"data.settings.sdk_settings.active_liveness_settings.close_eye_detector.force_check")},d={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.exif_data_settings.enable")},b={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.record_video.enable")},h=t(s,"data.settings.sdk_settings.active_liveness_settings.save_encoded_frames");e=h?{enable:h.enable,enableLogging:h.enable_logging,framesBatchLength:h.frames_batch_len,framesIntervalTime:h.frames_interval_ms}:n;let p={enable:a.getWebSetting(i,"data.settings.sdk_settings.active_liveness_settings.auto_gen_frame_ids.enable")&&u.enable,maxItems:a.getWebSetting(i,"data.settings.sdk_settings.active_liveness_settings.auto_gen_frame_ids.max_items")};return{faceTrackingSetting:r,resetFlowOnOrientationChange:l,waitBeforeStartFlowMs:c,flowIntervalTimeMs:o,takeOnePictureTimeMs:m,limitTimeLivenessCheck:u,terminateIfNoFace:_,closeEyeSettings:f,exifDataSettings:d,recordVideo:b,captureFrameSettings:e,autoGenFrameIds:p}},[n,s])}({captureFrameSettingsProp:el,clientSettings:eZ}),e9=1e3*eY.limitTimeSecond/e4.framesIntervalTime,{uuids:e7,getNextUUID:te,reset:tt}=o({total:Math.min(e8.maxItems,Math.ceil(e9/e4.framesBatchLength*1.2))}),ta=e.useRef(m.createSingleUUID()),tn=e.useCallback(e=>{let t=e[e.length-1];try{let e=JSON.parse(t.metadata);e8.enable&&(e.global_batch_id=te()),e.global_session_id=ta.current,t.metadata=JSON.stringify(e)}catch(e){console.error("Unable to process last frame metadata",e)}},[e8.enable,te]),ts=e2?.enable,ti=e.useMemo(()=>g.getEnabledServices(ep,eZ),[eZ,ep]),tr=e.useRef(""),tl=e.useCallback(e=>{if(e?.event){if(e.event===z?.show_alert){let t=e.log?.alert;if(t===tr.current)return;tr.current=t}eW(e),eh&&eh(e)}},[eh,eW]),tc=e.useMemo(()=>I(e=>{tl(e)},2e3),[tl]),to=e.useRef(0),tm=e.useRef(),tg=e.useRef();e.useEffect(()=>{tl({tag:"selfie",event:z?.start_camera,log:{}})},[tl]),e.useEffect(()=>(V.start(),()=>{V.stop()}),[]),e.useEffect(()=>{let e=!1;return async function t(){!ej&&(eH.current=performance.now(),eV.current=await d(eE),await b.initTensorFlow({preferredBackends:["wasm","webgl","cpu"]}),e||(eU(!0),tl({tag:"selfie",event:z?.show_warmup,log:{}}),tl({tag:"selfie",event:z?.finish_load_model,log:{status:"success",time_in_ms:performance.now()-eH.current}}),eH.current=null))}(),()=>{e=!0}},[ej,eE,tl]);let tu=e.useRef(!1),t_=e.useCallback(()=>{eK.current.curStepIndex=eK.current.steps.length,tu.current=!0,eR(!1),tg.current?.discardRecording()},[]),tf=e.useCallback(()=>{if(eK.current=n.initFaceVerificationData({assetRoot:eD,customInstructions:Y,customIcon:ee,customDirectionIcon:et,Locale:eM,lang:eB}),to.current=0,tm.current=null,eG.current=[],eL(!1),ez(null),M(),tg.current?.start(),tu.current=!1,e8.enable){let e=tt();u.addExifData("frame_batch_ids",e)}"function"==typeof ek&&ek(),eN()},[eM,eD,e8.enable,et,ee,Y,eB,ek,tt]),td=e.useCallback(()=>{t_(),setTimeout(()=>{tf()},eQ)},[t_,eQ,tf]),tb=e.useMemo(()=>({...K,...em}),[em]),th=e.useMemo(()=>({...$,...eg}),[eg]),tp=e.useCallback(({remainTime:e})=>{if(e>0&&e<=eY.remainTimeShow){let t=T(th.REMAIN_TIME[eB]),a=e;switch(eY.format){case"mm:ss":a=e.toString().padStart(5,"00:00");break;case"ss":a=e.toString().padStart(2,"0")}ec(t({x:a}))}},[eB,eY.format,eY.remainTimeShow,th.REMAIN_TIME,ec]),tv=e.useCallback(()=>{let e={};Object.keys(tb.liveness_terminated_time_out?.msg).forEach(t=>{let a=T(tb.liveness_terminated_time_out?.msg[t]);e[t]=a({x:eY.limitTimeSecond})}),ez({...tb.liveness_terminated_time_out,msg:e,duration:.95*eQ}),tl({tag:"selfie",event:z?.show_alert,log:{alert:"liveness_terminated_time_out,"}}),V.stop(),ec(""),t_()},[tb.liveness_terminated_time_out,eQ,eY.limitTimeSecond,t_,tl,ec]),tk=e.useCallback(({attemptCount:e,fromBackground:t})=>{eY.enableMaxRetries&&e>=eY.totalMaxRetries&&es(s.Errors.max_retry_reached),t&&t_(),V.start(),tf()},[eY.enableMaxRetries,eY.totalMaxRetries,es,tf,t_]),{stopTimer:tw}=x({totalTime:eY.limitTimeSecond,totalDelayBetweenReset:eQ/1e3,interruptible:eY.interruptible,shouldStart:ey&&eY.enable&&ej,onTimesUp:tv,onTick:tp,onReset:tk}),tF=e.useCallback(({clientWidth:e,clientHeight:t,videoAreaWidth:a,videoAreaHeight:n,lostX:s,lostY:i})=>{let r,l;_.isMobile?l=r=a-40:(l=450,r=450);let c=Math.floor((a-r)/2)+s;eP.current={x:c,y:5+i,width:r,height:l,image:R,surroundStyle:C},"object"==typeof Q?eP.current={...eP.current,...Q}:"function"==typeof Q&&(eP.current={...eP.current,...Q({clientWidth:e,clientHeight:t,videoAreaWidth:a,videoAreaHeight:n,lostX:s,lostY:i,isMobile:_.isMobile,width:r,height:l})}),eN(),eI(!0)},[R,C,Q]),ty=e.useRef({});e.useEffect(()=>{ty.current.isFirstValidFrameFoundRef=eS},[eS]),e.useEffect(()=>{let e,t=ex.current,a=async()=>{let{steps:e}=eK.current,t=[];e.map(e=>(t.push({name:e.name,blob:e.image.blob,captureTime:e.image.captureTime,gesture:e.name}),e.frontalFaceImage.blob&&t.push({name:e.name,blob:e.frontalFaceImage.blob,captureTime:e.frontalFaceImage.captureTime,gesture:W.FRONTAL}),0));let a=t.map(e=>h.resizeBlobImg(e.blob,400,400)),n=await Promise.all(a),s="0";if(e4.framesBatchLength>0){let e=`${Math.floor(eG.current.length/e4.framesBatchLength)}x${e4.framesBatchLength}`,t=eG.current.length%e4.framesBatchLength>0?`+${eG.current.length%e4.framesBatchLength}`:"";s=`${eG.current.length}:${e}${t}`}let i=n.map((e,a)=>{let n=u.parseLivenessImg({...t[a],frames:s});return u.writeCurrentExif({imageData:{blob:e},enableExifData:e6.enable,additionalData:n})}),r=await Promise.all(i),l=t.map((e,t)=>({name:e.name,blob:r[t]}));await Promise.all(e.map(async(t,a)=>{let n=l.filter(e=>e.name===t.name);if(e[a].image.blob=n[0].blob,t.frontalFaceImage.blob&&(e[a].frontalFaceImage.blob=n[1].blob),ed&&ed.key){let{key:s}=ed;e[a].image.encrypted=await v.encrypt({blob:n[0].blob,key:s}),t.frontalFaceImage.blob&&(e[a].frontalFaceImage.encrypted=await v.encrypt({blob:n[1].blob,key:s}))}return 0}))},i=async()=>{let{steps:e}=eK.current,t=e[eK.current.curStepIndex];if((t&&tl({tag:"selfie",event:{[s.FaceDirection.UP]:z?.capture_up_face,[s.FaceDirection.LEFT]:z?.capture_left_face,[s.FaceDirection.RIGHT]:z?.capture_right_face,[s.FaceDirection.FRONTAL]:z?.capture_frontal_face}[t.name],log:{time_capture_in_seconds:((performance.now()-eH.current)/1e3).toFixed(1)}}),eK.current.curStepIndex++,eH.current=performance.now(),eX.enable&&"each_gesture"===eX.limitFor&&(to.current=0),eK.current.curStepIndex===e.length)&&(eY.enable&&(V.stop(),tw(),ec("")),en)){let t=eG.current;if(ed&&ed.key){let e=await Promise.all(t.map(e=>e?.base64));if(t=t.map((t,a)=>({...t,base64:e[a]})),e4.enable&&e4.framesBatchLength>0&&t.length%e4.framesBatchLength>0){let e=t.slice(-1*(t.length%e4.framesBatchLength));e_(e),f&&B(ed,e,eO,t.length===e4.framesBatchLength)}}else if(e4.enable&&e4.framesBatchLength>0&&t.length%e4.framesBatchLength>0){let e=t.slice(-1*(t.length%e4.framesBatchLength));tn(e),e_(e.map(({base64:e,label:t,index:a,metadata:n})=>({base64:e,label:t,index:a,metadata:n}))),f&&ti.enableUploadFrames&&B(ed,e,eO)}tl({tag:"selfie",event:z?.finish_capture,log:{time_capture_in_seconds:V.duration("from_1st_frame")}}),eo(),await tg.current?.stopVideoRecording(),eF(!0),u.addExifData("user_action",{start_selfie:Date.now()-1e3*V.duration("from_1st_frame"),end_selfie:Date.now()}),u.addExifData("global_session_id",ta.current),e8.enable&&u.addExifData("frame_batch_ids",e7),await a();let n=eG.current;if(ed&&ed.key){let e=await Promise.all(n.map(e=>e?.base64));n=n.map((t,a)=>({...t,base64:e[a]}))}if(f&&ti.enableUploadImages)await j({apiClient:eO,faceVerificationFlowData:eK,onLivenessDetectionDone:en,captureFrameSettings:e4,FaceDirection:W,onError:es,outputEncryptionSettings:ed,video:D().length?D()[0]:null,enabledServices:ti,capturedFrames:n});else{let t=e.filter(e=>e.name!==W.FRONTAL).map(e=>({name:e.name,image:{blob:e.image.blob,encrypted:e.image.encrypted}})),a=e.filter(e=>e.name!==W.FRONTAL).map(e=>e.frontalFaceImage.blob).filter(e=>null!==e),s=e.filter(e=>e.name!==W.FRONTAL).map(e=>e.frontalFaceImage.encrypted).filter(e=>e&&e.hex),i=e.find(e=>e.name===W.FRONTAL)?.image?.blob,r=e.find(e=>e.name===W.FRONTAL)?.image?.encrypted,l=i&&ei?await h.scaleImage(i,{minSize:ei}):null;i&&a.push(i),r&&s.push(r),tl({tag:"result",event:z?.liveness_detection_done,log:{result_object:{steps:t,frontalFaces:a,frontalScaledImage:l}}}),en({steps:t,frontalFaces:a,frontalFacesEncrypted:s,frontalScaledImage:l,capturedFrames:n,video:D().length?D()[0]:null}),E()}eF(!1)}eN()},r=y(()=>{let{curStepIndex:e,steps:t}=eK.current,a=t[e],n=a?.image.blob!==null,s=a?.frontalFaceImage.blob!==null,r=t.filter(e=>e.frontalFaceImage.blob).length,l=!1;return n&&(s||![1].includes(e)||r>=1)?(eC.current=!1,i(),l=!0):n&&!s?eC.current=!0:eC.current=!1,eR(!1),l},er);async function l({faceDirection:e,canvas:t,blurScore:a,leftRightScore:n,isEyeClose:s}){let{curStepIndex:l,steps:c}=eK.current;if(l<c.length){let o=c[l];if(O({faceDirection:e,curStep:o})||s)return;if(e===W.FRONTAL&&(null===o.frontalFaceImage.blurScore||k.hasBetterBlurScore(a,o.frontalFaceImage.blurScore))){o.frontalFaceImage.blurScore=a;let e=await p.takePicture({canvas:t});o.frontalFaceImage.blob=e,o.frontalFaceImage.leftRightScore=n,o.frontalFaceImage.captureTime=Date.now(),eC.current&&(eC.current=!1,i())}if(o.name===e&&(null===o.image.blurScore||k.hasBetterBlurScore(a,o.image.blurScore))){eR(!0),o.image.blurScore=a;let e=await p.takePicture({canvas:t});o.image.blob=e,o.image.leftRightScore=n,o.image.captureTime=Date.now(),o.image.objUrl&&URL.revokeObjectURL(o.image.objUrl),o.image.objUrl=URL.createObjectURL(e),r()}}}async function c(a,i){let r,o;if(i?.width===0||i?.height===0)return;let{isFirstValidFrameFoundRef:m}=ty.current,{cropX:g,cropY:u,cropWidth:_,cropHeight:d}=a;i.getContext("2d").drawImage(t,g,u,_,d,-((400*eb-400)/2)/eb,-((400*eb-400)/2)/eb,400,400);let{blazefaceModel:b,closeEyesModel:h}=eV.current,[p,v]=await Promise.all([k.calculateBlurScore(i),w.getModelPredictions({model:b,sCanvas:i})]),{error:y,fullFace:I,faceRatio:T,faceNotFrontalMinThreshold:L}=await n.validatePredictions({predictions:v,width:w.SIZE,height:w.SIZE});r=y,eP.current.image=R;let x=null,D=null,E=null,A=null,{curStepIndex:M,steps:O}=eK.current;if(I){let e=O[M],t=e&&e.name===W.FRONTAL;E=I.landmarks;let a=await n.calculateFaceDirection({landmarks:E,getPerfectFrontal:t});a&&(x=a.gesture,D=a.leftRightScore);let l=e1?.webTimeout+ea[s.FaceDirection.FRONTAL].delayTime/1e3;if(t&&e1?.enable&&(-1===V.duration("limit_close_eye")||V.duration("limit_close_eye")<l)){e1?.forceCheck||-1!==V.duration("limit_close_eye")||V.start("limit_close_eye");let{isEyeClose:e}=await h.predict(i,E,e1?.webThreshold);(A=e)&&!r&&(r=K.close_eye)}}let N=r?.code==="no_face"||r?.code==="partial_face",P=M<O.length;!function({noFace:e,isFirstValidFrameFoundRef:t}){if(!e0.enable||!t)return;let{maxTimeMs:a}=e0;tm.current&&e||(tm.current={time:Date.now(),frame:0}),e&&tm.current.frame++;let{time:n}=tm.current;e&&Date.now()-n>=a&&(ez({...tb.liveness_terminated_no_face,duration:eQ}),tl({tag:"selfie",event:z?.show_alert,log:{alert:"liveness_terminated_no_face"}}),td())}({noFace:N&&P,isFirstValidFrameFoundRef:m}),r?.code&&tc({tag:"selfie",event:z?.show_alert,log:{alert:r.code}}),!r||"face_too_small"===r.code&&x!==W.FRONTAL&&T>=L?(m||(eL(!0),eH.current=performance.now(),V.start("from_1st_frame")),function({trackingScore:e,isFirstValidFrameFoundRef:t}){if(!eX.enable||null===e||!t)return!0;let{webWarningThreshold:a,webTerminateThreshold:n,maxWarningTime:s}=eX;return!!(e<a)||(e<n&&to.current<s?(to.current++,to.current===s?(ez({...tb.liveness_terminated_face_tracking,duration:eQ}),tl({tag:"selfie",event:z?.show_alert,log:{alert:"liveness_terminated_face_tracking"}})):ez({...tb.liveness_too_fast,duration:1500}),!0):(ez({...tb.liveness_terminated,duration:eQ}),tl({tag:"selfie",event:z?.show_alert,log:{alert:"liveness_terminated"}}),td(),!1))}({trackingScore:function(e,t,a,n){if(eG.current.length&&Date.now()-eG.current[eG.current.length-1].time<e4.framesIntervalTime)return null;if(e4.enable&&!n){let{topLeft:n,bottomRight:s}=e,i=[...n,...s],{score:r,time:l}=U(e,0===eG.current.length),c={label:"portrait",base64:t.toDataURL("image/jpeg",.8).split(",")[1],landmarks:a,original_landmarks:a,score:r,time:l,index:eG.current.length,bbox:i,original_bbox:i,metadata:JSON.stringify({})};if(ed&&ed.key){if(c.base64=F.encryptFrameBase64(c.base64,ed.key),eG.current.push(c),e4.framesBatchLength>0&&eG.current.length%e4.framesBatchLength==0&&e_){let e=eG.current.slice(-e4.framesBatchLength);Promise.all(e.map(e=>e?.base64)).then(t=>{e_(e.map(({label:e,index:a},n)=>({base64:t[n],label:e,index:a}))),f&&ti.enableUploadFrames&&B(ed,e.map(({label:e,index:a},n)=>({base64:t[n],label:e,index:a})),eO,eG.current.length===e4.framesBatchLength)})}}else if(eG.current.push(c),e4.framesBatchLength>0&&eG.current.length%e4.framesBatchLength==0&&e_){let e=eG.current.slice(-e4.framesBatchLength);tn(e),e_(e.map(({base64:e,label:t,index:a,metadata:n})=>({base64:e,label:t,index:a,metadata:n}))),f&&ti.enableUploadFrames&&B(ed,e,eO,eG.current.length===e4.framesBatchLength)}return r}return null}(v[0],i,E,M>=O.length),isFirstValidFrameFoundRef:m})&&await l({faceDirection:x,canvas:i,blurScore:p,leftRightScore:D,isEyeClose:A})):M<O.length&&(o=tb[r.code],eP.current.image=S),eq(o),-1!==e&&(e=requestAnimationFrame(()=>c(a,i)))}async function o(){let e=p.analyzeVideoAndWindowSizes(t,eP.current),a=document.createElement("canvas");a.width=400,a.height=400;let n=a.getContext("2d");n.translate(400,0),n.scale(-1*eb,+eb);let{mediaRecorder:s}=ts&&t?await A({outputImagesSize:400,videoEl:t,resultAnalyzeVideoAndWindowSizes:e}):{};tg.current=s,tg.current&&tg.current.start(),c(e,a)}return ey&&ej&&setTimeout(()=>{o()},e3??ef),()=>{cancelAnimationFrame(e),e=-1}},[ev,e3,ef,ey,eB,eO,f,R,S,en,es,ei,er,e4,eo,eX,eY.enable,ec,eq,ea,eQ,td,e0,tb,ej,tl,e_,ed,eb,e1?.enable,e1?.webThreshold,e1?.webTimeout,e1?.forceCheck,e6.enable,eA,tc,ts,ti,tw,e7,tn,e8.enable]);let{curStepIndex:tI,steps:tT}=eK.current,tR=e.useMemo(()=>tT.find(e=>e.name===s.FaceDirection.FRONTAL),[tT]),tS=eC.current?tR:tT[tI],tL=tS&&eS?tS.instructions[eB]:null,tx=tS&&eS?tS.directionIcon:"";return{resetFlowOnOrientationChange:e5,cropArea:eP,curStepIndex:tI,directionIcon:tx,directionIconAnimation:tS?tS.directionIconAnimation:"",faceDetectionError:e$,resetFlow:td,handleVideoPlayed:tF,instructions:tL,refVideo:ex,refIsReseting:tu,steps:tT,videoPlayed:ey,activeCapturing:eT,isFirstValidFrameFound:eS,warmupDone:ej,showLoading:ew}}export{X as u};
@@ -1 +0,0 @@
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-575fb45a.js";import{e as f,d as j,c as p,D as b,S as x}from"./chunk-2bdac502.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-84471c81.js")),w=v.lazy(()=>import("./chunk-fd4614fe.js")),A=v.lazy(()=>import("./chunk-f703e0a4.js")),K=v.lazy(()=>import("./chunk-ddb2ebe0.js")),I=v.lazy(()=>import("./chunk-9fe80ed2.js")),V=v.lazy(()=>import("./chunk-2a4cb9f5.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,256 +0,0 @@
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-575fb45a.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
- transition: stroke-dashoffset 0.4s;
3
- transform: rotate(-90deg);
4
- transform-origin: 50% 50%;
5
- `,F=u.circle`
6
- transition: stroke-dashoffset 0.4s, stroke 0.4s;
7
- transform: rotate(-90deg);
8
- transform-origin: 50% 50%;
9
- fill: none;
10
- `,H=u.circle`
11
- transition: stroke-dashoffset 0.4s;
12
- transform: rotate(-90deg);
13
- transform-origin: 50% 50%;
14
- `;function K({className:e,style:i,radius:r,strokeWidth:t,progress:s,showErrorRing:o,activeColor:n,innerPadding:a,outsideRingColor:l,outsideRingOpacity:d,insideRingColor:c,insideRingWidth:g,insideRingStrokeDash:h,errorRingWidth:u,errorRingColor:p,dashedRingColor:m,dashedRingOpacity:w,dashedRingWidth:k,dashedRingLineThick:b,dashedRingLineSpacing:R,dashedInsideRingColor:S,dashedInsideRingWidth:_,showOutsideRing:y,showInsideRing:C,showDashedRing:x}){let v=2*r,$=2*r,W=r-2*t,j=2*Math.PI*W,I=W-k/2-t/2-a,O=2*Math.PI*I,D=I-_/2-k/2,A=2*Math.PI*D,T=D-g/2-_/2,E=D-u/2-_/2;return f.jsxs("svg",{className:e,style:i,width:v,height:$,viewBox:`0 0 ${v} ${$}`,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[y?f.jsxs(f.Fragment,{children:[f.jsx("circle",{"data-testid":"outsideRing",opacity:d,cx:r,cy:r,r:W,stroke:l}),f.jsx(H,{"data-testid":"outsideAnimateRing",cx:r,cy:r,r:W,stroke:n,strokeWidth:t,strokeLinecap:"round",strokeDasharray:`${j} ${j}`,style:{strokeDashoffset:j-s/100*j}})]}):null,x?f.jsxs(f.Fragment,{children:[f.jsx("circle",{"data-testid":"dashedRing",opacity:w,cx:r,cy:r,r:I,stroke:m,strokeWidth:k,strokeDasharray:`${b} ${R}`}),f.jsx("mask",{id:"mask0","mask-type":"alpha",maskUnits:"userSpaceOnUse",children:f.jsx("circle",{cx:r,cy:r,r:I,stroke:n,strokeWidth:k,strokeDasharray:`${b} ${R}`})}),f.jsx("g",{mask:"url(#mask0)",children:f.jsx(H,{"data-testid":"dashedAnimateRing",cx:r,cy:r,r:I,stroke:n,strokeWidth:k,strokeDasharray:`${O} ${O}`,style:{strokeDashoffset:O-s/100*O}})}),f.jsx("circle",{"data-testid":"dashedInsideRing",opacity:w,cx:r,cy:r,r:D,stroke:S,strokeWidth:_}),f.jsx(H,{"data-testid":"dashedInsideAnimateRing",cx:r,cy:r,r:D,stroke:n,strokeWidth:_,strokeLinecap:"round",strokeDasharray:`${A} ${A}`,style:{strokeDashoffset:A-s/100*A}})]}):null,C?f.jsx("circle",{"data-testid":"insideRing",strokeDasharray:h,cx:r,cy:r,r:T,stroke:c,strokeWidth:g}):null,o?f.jsx("circle",{"data-testid":"errorRing",strokeDasharray:h,cx:r,cy:r,r:E,stroke:p,strokeWidth:u}):null]})}K.propTypes={className:d.string,style:d.shape({}),radius:d.number,strokeWidth:d.number,progress:d.number,showErrorRing:d.bool,activeColor:d.string,innerPadding:d.number,outsideRingColor:d.string,outsideRingOpacity:d.number,insideRingColor:d.string,insideRingWidth:d.number,insideRingStrokeDash:d.string,errorRingColor:d.string,errorRingWidth:d.number,dashedRingColor:d.string,dashedRingOpacity:d.number,dashedRingWidth:d.number,dashedRingLineThick:d.number,dashedRingLineSpacing:d.number,dashedInsideRingColor:d.string,dashedInsideRingWidth:d.number,showOutsideRing:d.bool,showDashedRing:d.bool,showInsideRing:d.bool},K.defaultProps={className:"",style:null,radius:160,strokeWidth:3,progress:0,showErrorRing:!1,activeColor:"#0092ff",innerPadding:5,outsideRingColor:"#f2f6f9",outsideRingOpacity:.1,insideRingColor:"#f2f6f9",insideRingWidth:3,insideRingStrokeDash:"0",errorRingColor:"#df0000",errorRingWidth:3,dashedRingColor:"#ffffff",dashedRingOpacity:.3,dashedRingWidth:10,dashedRingLineThick:1,dashedRingLineSpacing:6,dashedInsideRingColor:"#ffffff",dashedInsideRingWidth:0,showOutsideRing:!0,showDashedRing:!0,showInsideRing:!0};let{blink:U,slide:q,spin:J}=b,Y=p`
15
- z-index: ${m+20};
16
- color: #ffffff;
17
- `,Z=u.div`
18
- ${Y}
19
- `,G=p`
20
- ${Y}
21
- ${({top:e})=>e&&p`
22
- top: ${e}px;
23
- `}
24
- ${({bottom:e})=>e&&p`
25
- bottom: ${e}px;
26
- `}
27
- ${({centerY:e})=>e&&p`
28
- top: 50%;
29
- transform: translateY(-50%);
30
- `}
31
- font-size: ${o("Selfie.error.fontSize")};
32
- font-weight: ${o("Selfie.error.fontWeight")};
33
- background: ${o("Selfie.error.backgroundColor")};
34
- color: ${o("Selfie.error.color")};
35
- padding: ${o("Selfie.error.padding")};
36
- border-radius: ${o("Selfie.error.borderRadius")};
37
- position: absolute;
38
- white-space: pre-wrap;
39
- text-align: center;
40
- max-width: 80%;
41
- `;u(B)`
42
- ${G}
43
- `;let Q=u.div`
44
- ${G}
45
- `,X=u.div`
46
- z-index: ${m+20};
47
- display: flex;
48
- align-items: center;
49
- position: absolute;
50
- left: 50%;
51
- transform: translate(-50%, 0);
52
- ${({top:e})=>e&&p`
53
- top: ${e}px;
54
- `}
55
- `,ee=u(Z)`
56
- font-size: ${o("Selfie.countdown.fontSize")};
57
- font-weight: ${o("Selfie.countdown.fontWeight")};
58
- background: ${o("Selfie.countdown.backgroundColor")};
59
- color: ${o("Selfie.countdown.color")};
60
- padding: ${o("Selfie.countdown.padding")};
61
- border-radius: ${o("Selfie.countdown.borderRadius")};
62
- white-space: nowrap;
63
- `,ei=u(ee)`
64
- position: absolute;
65
- left: 50%;
66
- transform: translate(-50%, 0);
67
- ${({top:e})=>e&&p`
68
- top: ${e}px;
69
- `}
70
- `,er=u(Z)`
71
- position: absolute;
72
- ${({top:e})=>e&&p`
73
- top: ${e}px;
74
- `}
75
- ${({bottom:e})=>e&&p`
76
- bottom: ${e}px;
77
- `}
78
- color: ${o("Selfie.Active.instruction.color")};
79
- font-size: ${o("Selfie.Active.instruction.fontSize")};
80
- font-weight: ${o("Selfie.Active.instruction.fontWeight")};
81
- text-shadow: ${o("Selfie.Active.instruction.textShadow")};
82
- background-color: ${o("Selfie.Active.instruction.backgroundColor")};
83
- border: ${o("Selfie.Active.instruction.border")};
84
- border-radius: ${o("Selfie.Active.instruction.borderRadius")};
85
- `,et=u.div`
86
- height: ${()=>w.isMobile?"50px":"70px"};
87
- position: absolute;
88
- ${({top:e})=>e&&p`
89
- top: ${e}px;
90
- `}
91
- ${({bottom:e})=>e&&p`
92
- bottom: ${e}px;
93
- `}
94
- width: 100%;
95
- display: flex;
96
- justify-content: center;
97
- align-items: center;
98
- z-index: ${m+20};
99
- `,es=u.div`
100
- width: ${o("Selfie.Active.imageHolder.width")};
101
- height: ${o("Selfie.Active.imageHolder.height")};
102
- border-radius: ${o("Selfie.Active.imageHolder.borderRadius")};
103
- font-size: ${o("Selfie.Active.imageHolder.fontSize")};
104
- color: ${o("Selfie.Active.imageHolder.color")};
105
- font-weight: ${o("Selfie.Active.imageHolder.fontWeight")};
106
-
107
- ${({theme:e})=>"v2"===n(e,"themeVersion")?"border: unset;":`border: ${o("Selfie.Active.imageHolder.border")({theme:e})};`}
108
-
109
- display: flex;
110
- justify-content: center;
111
- align-items: center;
112
-
113
- & + & {
114
- margin-left: 10px;
115
- }
116
-
117
- ${e=>e.active?p`
118
- img:not(.image_preview) {
119
- border: ${o("Selfie.Active.imageHolder.activeStepBorder")};
120
- border-radius: ${o("Selfie.Active.imageHolder.activeStepBorderRadius")};
121
- }
122
- `:p`
123
- opacity: 0.3;
124
- `}
125
-
126
- img {
127
- width: 100%;
128
- margin: 0;
129
- border-radius: ${o("Selfie.Active.imageHolder.borderRadius")};
130
- }
131
- img.image_preview {
132
- border: ${o("Selfie.Active.imageHolder.border")};
133
- }
134
- `,eo=u.div`
135
- color: #ffffff;
136
- height: 70px;
137
- position: absolute;
138
- bottom: 0;
139
- width: 100%;
140
- display: flex;
141
- justify-content: center;
142
- align-items: center;
143
- z-index: ${m+20};
144
- `,en=u.div`
145
- ${({disabled:e})=>e?p`
146
- pointer-events: none;
147
- `:p`
148
- cursor: pointer;
149
- `}
150
- text-align: center;
151
-
152
- img {
153
- width: ${o("Selfie.captureIcon.width")};
154
- }
155
- `,ea=u.div`
156
- position: absolute;
157
- width: 100%;
158
- top: 0;
159
- bottom: 0;
160
- display: flex;
161
- justify-content: center;
162
- align-items: center;
163
- color: #ffffff;
164
- font-size: 140px;
165
- opacity: 0.6;
166
- `,el=u.div`
167
- position: absolute;
168
- width: 100%;
169
- top: 0;
170
- bottom: 0;
171
- display: flex;
172
- flex-direction: column;
173
- justify-content: center;
174
- align-items: center;
175
- ${q.default};
176
- ${U.default};
177
- `,ed=u(K)`
178
- position: absolute;
179
- top: 0;
180
- left: 0;
181
- width: 100%;
182
- height: 100%;
183
- `,ec=u(({className:e="",radius:i=80,neutralColor:r="#CBD5E1",activeColor:t="#0276F1",errorColor:s="#E84848",strokeWidth:o=2,tickWidth:n=15,numberOfTicks:a=200,progress:l=0,showErrorRing:d=!1})=>{let c=2*i,g=i-5,h=2*Math.PI*g,u=Array.from({length:a}).map((e,r)=>{let t=360*r/a+3;return f.jsx("use",{href:"#tick",transform:`rotate(${t} ${i} ${i})`},r)}),p=i-V,m=2*Math.PI*p;return f.jsxs("svg",{height:c,width:c,viewBox:`0 0 ${c} ${c}`,className:e,xmlns:"http://www.w3.org/2000/svg",children:[d?f.jsx("circle",{cx:i,cy:i,r:i-V,stroke:s,strokeWidth:o,fill:"none"}):f.jsxs(f.Fragment,{children:[f.jsx("circle",{cx:i,cy:i,r:p,stroke:r,strokeWidth:o,fill:"none"}),f.jsx(F,{cx:i,cy:i,r:p,stroke:t,strokeWidth:o,strokeLinecap:"round",strokeDasharray:`${m} ${m}`,style:{strokeDashoffset:m-l/100*m}})]}),f.jsx("defs",{children:f.jsx("line",{id:"tick",x1:i,y1:"0",x2:i,y2:n,stroke:r,strokeWidth:o,strokeLinecap:"round"})}),f.jsx("g",{id:"border-segments",children:u}),f.jsx("mask",{id:"tickMask",maskUnits:"userSpaceOnUse",children:f.jsx("g",{id:"tick-mask-segments",children:u})}),f.jsx("g",{mask:"url(#tickMask)",children:f.jsx(N,{strokeDasharray:`${h} ${h}`,style:{strokeDashoffset:h-l/100*h},children:f.jsx("circle",{cx:i,cy:i,r:g,stroke:t,strokeWidth:20,fill:"none"})})})]})})`
184
- position: absolute;
185
- top: 0;
186
- left: 0;
187
- width: 100%;
188
- height: 100%;
189
- `,eg=u(function({className:e=""}){return f.jsx("svg",{className:e,width:"320",height:"320",viewBox:"0 0 320 320",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:f.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M320 0H0V320H320V0ZM160 296C235.111 296 296 235.111 296 160C296 84.8893 235.111 24 160 24C84.8893 24 24 84.8893 24 160C24 235.111 84.8893 296 160 296Z",fill:"currentColor"})})})`
190
- width: 100%;
191
- height: 100%;
192
- vertical-align: middle;
193
- margin: 0;
194
- color: ${o("Selfie.backgroundColor")};
195
- `,eh=u(function({className:e="",radius:i=160,backgroundColor:r="#fff",padding:t=0}){let s=2*i;return f.jsxs("svg",{className:e,width:s,height:s,viewBox:`0 0 ${s} ${s}`,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[f.jsxs("mask",{id:"CIRCLE_MASK",children:[f.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:"white",mask:"url(#CIRCLE_MASK)"}),f.jsx("circle",{cx:i,cy:i,r:i-t,fill:"black"})]}),f.jsx("circle",{cx:i,cy:i,r:i,fill:"none"}),f.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:r,mask:"url(#CIRCLE_MASK)"})]})})`
196
- width: 100%;
197
- height: 100%;
198
- vertical-align: middle;
199
- margin: 0;
200
- color: ${o("Selfie.backgroundColor")};
201
- `,ef=u.div`
202
- position: absolute;
203
- z-index: -1;
204
- background: rgba(223, 0, 0, 0.2);
205
- border-radius: 50%;
206
- width: 86%;
207
- height: 86%;
208
- top: 7%;
209
- left: 7%;
210
- `,eu=k`
211
- from {
212
- opacity: 1;
213
- }
214
-
215
- to {
216
- opacity: 0;
217
- }
218
- `,ep=u.div`
219
- position: absolute;
220
- width: 100%;
221
- top: 0;
222
- bottom: 0;
223
- z-index: -1;
224
- background: rgba(255, 255, 255, 0.3);
225
- animation: ${eu} 1s infinite;
226
- border-radius: 50%;
227
- `,em=u.div`
228
- top: 0;
229
- left: 0;
230
- right: 0;
231
- bottom: 0;
232
- position: absolute;
233
- margin: auto;
234
- width: ${o("Selfie.loadingIcon.width")};
235
- height: ${o("Selfie.loadingIcon.height")};
236
-
237
- img {
238
- width: 100%;
239
- }
240
-
241
- z-index: ${m+20};
242
- ${J.default}
243
- `,ew=u.div`
244
- text-align: center;
245
- color: ${o("Selfie.title.color")};
246
- font-size: ${o("Selfie.title.fontSize")};
247
- font-weight: ${o("Selfie.title.fontWeight")};
248
- background-color: ${o("Selfie.title.backgroundColor")};
249
- position: absolute;
250
- top: ${e=>e.y};
251
- z-index: ${m+10};
252
- display: flex;
253
- align-items: center;
254
- justify-content: center;
255
- width: 100%;
256
- `;export{V as A,eo as B,ea as C,ef as E,er as F,el as I,em as L,ed as O,Q as S,ew as T,eg as a,ei as b,en as c,_ as d,eh as e,ec as f,S as g,ep as h,et as i,es as j,X as k,ee as l,j as m,P as n,$ as o,C as p,A as q,T as r,v as s,R as t,L as u,E as v,W as w,y as x};
@@ -1,45 +0,0 @@
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-575fb45a.js";import{P as o,O as u}from"./chunk-e2211b41.js";import{u as f,a as p,S as m,R as g,U as y}from"./chunk-9d0b0fc7.js";import{d as _,m as C}from"./chunk-2bdac502.js";import{L as h}from"./chunk-8c9bb671.js";import{t as R}from"./chunk-37a2eeaf.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
- display: flex;
3
- justify-content: space-between;
4
- align-items: center;
5
- flex-direction: column;
6
- padding: 10px;
7
- `,ea=d.button`
8
- margin-top: 20px;
9
- width: 100%;
10
- max-width: 160px;
11
- height: 50px;
12
- background-color: #0276f1;
13
- border: 0;
14
- outline: none;
15
- border-radius: 0.25rem;
16
- color: #fff;
17
- font-weight: 400;
18
- cursor: pointer;
19
- font-size: 1rem;
20
- `,et=d.div`
21
- margin: 20px 0;
22
- width: 100%;
23
- display: flex;
24
- justify-content: space-evenly;
25
- gap: 10px;
26
- `,er=({onRetry:e,onStop:t,children:s})=>{let{lang:n}=a.useSDKSettings();return r.jsxs(ee,{children:[s,r.jsxs(et,{children:[r.jsx(ea,{onClick:t,children:b.STOP_BUTTON[n]}),r.jsx(ea,{onClick:e,children:b.RETRY_BUTTON[n]})]})]})};er.propTypes={children:e.node,onRetry:e.func,onStop:e.func},er.defaultProps={children:null,onRetry:()=>{},onStop:()=>{}};let es=d.div`
27
- display: flex;
28
- justify-content: space-between;
29
- align-items: center;
30
- flex-direction: column;
31
- padding: 10px;
32
- `,en=d.button`
33
- margin-top: 20px;
34
- width: 100%;
35
- max-width: 160px;
36
- height: 50px;
37
- background-color: #0276f1;
38
- border: 0;
39
- outline: none;
40
- border-radius: 0.25rem;
41
- color: #fff;
42
- font-weight: 400;
43
- cursor: pointer;
44
- font-size: 1rem;
45
- `,ei=({onStop:e,children:t})=>{let{lang:s}=a.useSDKSettings();return r.jsxs(es,{children:[t,r.jsx(en,{onClick:e,children:b.STOP_BUTTON[s]})]})};ei.propTypes={children:e.node,onStop:e.func},ei.defaultProps={children:null,onStop:()=>{}};let ec="FAIL_CARD_SANITY",el="FAIL_FACE_SANITY",ed="FAIL_LIVENESS_TAMPERING_OCR_RETRY_ID",eo="FAIL_LIVENESS_TAMPERING_OCR_RETRY_FACE",eu="FAIL_COMPARE_FACES",ef="RESET_ACTIONS",ep="SET_STEP",em={currentStep:null,readIdCardKey:0,faceLivenessKey:0,cardSanityRetries:-1,compareFacesRetries:-1,portraitSanityRetries:-1,faceLivenessCardTamperingOCRRetries:-1};function eg(e,a){switch(a.type){case ec:return{...e,cardSanityRetries:e.cardSanityRetries+1};case el:return{...e,portraitSanityRetries:e.portraitSanityRetries+1,faceLivenessKey:e.faceLivenessKey+1};case ed:return{...e,readIdCardKey:e.readIdCardKey+1,faceLivenessCardTamperingOCRRetries:e.faceLivenessCardTamperingOCRRetries+1,currentStep:T};case eo:return{...e,faceLivenessKey:e.faceLivenessKey+1,faceLivenessCardTamperingOCRRetries:e.faceLivenessCardTamperingOCRRetries+1,currentStep:A};case eu:return{...e,compareFacesRetries:e.compareFacesRetries+1,readIdCardKey:e.readIdCardKey+1,faceLivenessKey:e.faceLivenessKey+1,currentStep:T};case ep:return{...e,currentStep:a.payload};case ef:return em;default:return e}}let{IDCardSide:ey,Errors:e_}=l,eC={padding:50,paddingBottom:20},eh=({content:e,lang:a,isStopPopup:t=!1})=>{var s,n;let i;return r.jsxs(r.Fragment,{children:[r.jsx("div",{style:eC,children:e.results.map((e,a)=>r.jsx("div",{children:e},a))}),t?null:r.jsx("div",{style:{padding:50,paddingBottom:0,color:"red"},children:(s=a,i=Array.isArray(n=e.retryAt)?n.map(e=>b[e][s]).join(", "):b[n][s],R(b.FAIL_STEP[s])({step:i}))})]})};function eR(e){let{lang:s}=a.useSDKSettings(),{onDoneEkyc:n,readIDCardProps:c,livenessDetectionProps:d,onError:u,onClose:f,sdkAdapter:p,flow:m,customTheme:g}=e,{clientSettings:y}=p,[_,R]=t.useState(!1),[b,L]=t.useState(!1),[D,O]=t.useState({}),[N,j]=t.useState(!1),[M,Y]=t.useReducer(eg,em),{currentStep:G,readIdCardKey:U,faceLivenessKey:V,cardSanityRetries:J,compareFacesRetries:z,portraitSanityRetries:$,faceLivenessCardTamperingOCRRetries:Q}=M,ee=t.useRef(S),ea=t.useRef(),et=t.useRef(),es=t.useRef(),en=t.useRef(""),ef=t.useRef(""),{cardSanityMaxRetries:eC,portraitSanityMaxRetries:eR,faceLivenessCardTamperingOCRMaxRetries:ev,compareFacesMaxRetries:eI,services:eF}=t.useMemo(()=>(e=>{let a=i(e,"data.settings.sdk_settings.sdk_adapter.services",null),t=i(e,"data.settings.sdk_settings.sdk_adapter.retries",null),r=C({},F,a),{id_card_sanity:s,portrait_sanity:n,face_liveness_with_card_tampering_ocr:c,compare_faces:l}=C({},I,t);return{cardSanityMaxRetries:s,portraitSanityMaxRetries:n,faceLivenessCardTamperingOCRMaxRetries:c,compareFacesMaxRetries:l,services:r}})(D),[D]),eT=t.useMemo(()=>{let e;return(m===l.EkycFlow.FULL_FLOW||m===l.EkycFlow.ID_CARD)&&(i(e=eF,"card_sanity",!1)||i(e,"card_tampering",!1)||i(e,"card_ocr",!1))},[m,eF]),eA=t.useMemo(()=>{let e;return(m===l.EkycFlow.FULL_FLOW||m===l.EkycFlow.FACE)&&(i(e=eF,"face_sanity",!1)||i(e,"face_liveness",!1)||i(e,"compare_faces",!1)||i(e,"search_face",!1)||i(e,"index_face",!1))},[m,eF]),ek=i(D,"data.card_types[0].has_back_side",!0),eS=2===i(c,"steps",[]).length||ek;t.useEffect(()=>{(async function e(){O(await y())})()},[y]),t.useEffect(()=>{eT?Y({type:ep,payload:T}):Y({type:ep,payload:A})},[eT]),t.useEffect(()=>()=>{Y({type:"RESET_ACTIONS"}),R(!1),L(!1),ee.current=S,ea.current=null,et.current=null},[]);let eb=t.useCallback(()=>{J+1>=eC?L(!0):(et.current=K(ee.current,T,s),ea.current=()=>{Y({type:ec}),j(!1),"function"==typeof es.current&&es.current()},R(!0))},[eC,J,s]),eL=t.useCallback(()=>{Q+1>=ev?L(!0):(et.current=K(ee.current,T,s),ea.current=()=>{Y({type:ed}),j(!1)},R(!0))},[ev,Q,s]),ew=t.useCallback(()=>{$+1>=eR?L(!0):(et.current=K(ee.current,A,s),ea.current=()=>{Y({type:el}),j(!1)},R(!0))},[eR,$,s]),eE=t.useCallback((e,a)=>{Q+1>=ev?L(!0):(et.current=K(ee.current,e,s),e===T?ea.current=()=>{Y({type:ed}),a||(ee.current=S)}:ea.current=()=>{Y({type:eo})},R(!0))},[ev,Q,s]),eD=t.useCallback(()=>{z+1>=eI?L(!0):(et.current=K(ee.current,[T,A],s),ea.current=()=>{Y({type:eu}),ee.current=S,j(!1)},R(!0))},[eI,z,s]),eO=t.useCallback(async e=>{if(eT&&await x(ee,eF,eS))return T;return!!e&&A},[eT,eF,eS]),eN=t.useCallback(async()=>{try{let e=await Z({...ee.current,livenessMode:d.mode,sdkAdapter:p,onError:u,services:eF,hasBackCardStep:eS,hasIDFlow:eT});if(e)if(ee.current={...ee.current,...e},i(e,"step",null))eD();else{let e=B(ee);n(e);return}}catch(e){u({...e_.api_call_error,details:e})}},[eS,d.mode,p,u,eF,eD,n,eT]),eP=t.useCallback(async({stepResult:e})=>{if(i(e,"cardSide")===ey.FRONT){let a=await W({stepResult:e,frontCardId:en.current,qrImageId:ef.current,onError:u,sdkAdapter:p,services:eF});if(!a)return void j(!1);en.current=a.apiResult.frontCardId,ef.current=a.apiResult.qrImageId;if(ee.current={...ee.current,frontCard:a},E(a,eF))return eb(),{retryAt:ey.FRONT};if(!eS)if(eA)Y({type:ep,payload:A});else{if(await x(ee,eF,eS))return void eL();n(B(ee))}}else if(i(e,"cardSide")===ey.BACK)if(await P(ee,eF,eS))eL();else{let a=await W({hasBackCardStep:eS,stepResult:e,frontCardId:en.current,qrImageId:ef.current,sdkAdapter:p,onError:u,refEkycResult:ee,services:eF,handleFailCardTamperingOCRBackground:eL});if(ee.current={...ee.current,backCard:a},E(a,eF))return eb(),{retryAt:ey.BACK};if(eA)Y({type:ep,payload:A});else{if(await x(ee,eF,eS))return void eL();n(B(ee))}}},[eb,eL,eS,eA,n,u,p,eF]),ex=t.useCallback(async({stepResult:e})=>{if(eT&&await x(ee,eF,eS)){eL(),j(!1);return}let a=await X({mode:i(d,"mode",l.Mode.ACTIVE),stepResult:e,sdkAdapter:p,services:eF});if(ee.current={...ee.current,faceLiveness:a},((e,a)=>{if(!i(a,"face_sanity"))return!1;let t=i(e,"verifyFacePortraitResult.status",""),r=i(e,"verifyFacePortraitResult.portrait_sanity.verdict","");return"success"!==t||"good"!==r})(a,eF))ew();else{let e=await eO(w(a,eF));e?eE(e,!w(a)):await eN()}},[eN,eL,ew,eE,eO,eS,eT,d,p,eF]),ej=t.useCallback(async e=>{let a;return"function"==typeof i(e,"restartSession")&&(es.current=e.restartSession),j(!0),G===T?a=await eP({stepResult:e}):G===A&&(a=await ex({stepResult:e})),j(!1),a},[G,eP,ex]),eB=t.useCallback(()=>{R(!1),ea.current()},[]),eK=t.useCallback(()=>{R(!1),L(!1),n(B(ee)),Y({type:ep,payload:k})},[n]);return r.jsxs(r.Fragment,{children:[G===T?t.createElement(v,{...e,...c,onStepDone:ej,onError:u,onClose:f,clientSettings:D,key:U,customTheme:g}):null,G===A?t.createElement(h,{...e,...d,onFramesCaptured:e=>((e,a)=>{let{uploadFiles:t}=a;t({frames:e,metadata:JSON.stringify({type:"selfie"})},{"Content-Type":"application/json"}).then(e=>{e&&e.data&&e.data.file_id?q.push({id:e.data.file_id}):q.push({id:-1})})})(e,p),onReset:H,onLivenessDetectionDone:ej,onError:u,onClose:f,clientSettings:D,key:V,isLoading:N,customTheme:g}):null,r.jsxs(o,{open:_||b,children:[_&&r.jsx(er,{onRetry:eB,onStop:eK,children:r.jsx(eh,{content:et.current,lang:s})}),b&&r.jsx(ei,{onStop:eK,children:r.jsx(eh,{content:et.current,lang:s,isStopPopup:!0})})]})]})}function ev(e){let{logCredentials:a,ekycFlowComponent:t}=e;return r.jsx(u,{children:r.jsx(n.SDKTrackingProvider,{value:{tracking:{...a}},children:r.jsx(t,{...e})})})}eR.propTypes={sdkAdapter:e.shape({}),onDoneEkyc:e.func,onError:e.func,onClose:e.func,readIDCardProps:e.shape({}),livenessDetectionProps:e.shape({}),flow:e.oneOf([l.EkycFlow.FULL_FLOW,l.EkycFlow.ID_CARD,l.EkycFlow.FACE]),customTheme:e.shape({})},eR.defaultProps={sdkAdapter:null,onDoneEkyc:()=>{},onError:()=>{},onClose:()=>{},readIDCardProps:{},livenessDetectionProps:{},flow:l.EkycFlow.FULL_FLOW,customTheme:{}},ev.propTypes={logCredentials:e.shape({}),clientSettings:e.shape({}),ekycFlowComponent:e.func},ev.defaultProps={logCredentials:void 0,clientSettings:void 0,ekycFlowComponent:eR};export{ev as default};
@@ -1 +0,0 @@
1
- import{A as e,C as r,U as s,r as t,m as n,aI as a,b as o,c as i,s as c,j as l,a4 as u,az as m,a7 as p,X as d,P as h,k as g,aJ as f}from"./chunk-575fb45a.js";import{M as j,O as x,W as y,C as C}from"./chunk-e2211b41.js";import{u as F}from"./chunk-7fd19a76.js";import{D as D}from"./chunk-4552fd9e.js";import{p as S,d as b,e as v,A as T,f as k,I as I,h as E,F as _,i as V,j as L,T as R,L as w,k as A,l as P,S as H}from"./chunk-906e840c.js";import{u as N}from"./chunk-2bdac502.js";import"./chunk-fa315830.js";import"./chunk-d15b739a.js";import"./chunk-37a2eeaf.js";import"./chunk-8c9bb671.js";let M=g.isMobile?{width:{ideal:640}}:null,U=({stepNumber:e,type:r,theme:s})=>{let t=f(`instruction_${r}.svg`),n=o(s,`Selfie.Active.imageHolder.${r}`);return null===n?l.jsx(l.Fragment,{}):"string"==typeof n&&""!==n?l.jsx("img",{src:n,alt:""}):"v1"===o(s,"themeVersion")?l.jsx("span",{children:e}):l.jsx("img",{src:t,alt:""})};function $(h){var f,D;let{apiCheck:$,onLivenessDetectionDone:O,captureFrameSettings:B,onFramesCaptured:K,frontCamera:z,flipVideoHorizontal:G,customDirectionIcon:W,customStepTimeConstraints:Y,onProcessing:J,customErrors:X,apiCredentials:q,outputEncryptionSettings:Q,cameraScale:Z,defaultCameraId:ee,offsetFaceY:er,isLoading:es,serviceSettings:et,onReset:en}=h,ea=e(),{onErrorCallback:eo,onCloseCallback:ei}=N(),ec=r.useAsset("bg_camera_mask.png"),el=r.useAsset("bg_camera_mask_red.png"),eu=s("IDCapturing.loadingIcon.src","ic_loading.gif"),[em,ep]=t.useState({}),{yFaceVerificationStepsWrapper:ed,yFaceDetectionError:eh,yCountdown:eg}=em,[ef,ej]=t.useState(""),[ex,ey]=t.useState(),eC=t.useMemo(()=>({backgroundColor:n("Selfie.backgroundColor")({theme:ea})}),[ea]);a(o(ea,"themeVersion"),"up_arrow.gif"),a(o(ea,"themeVersion"),"left_arrow.gif"),a(o(ea,"themeVersion"),"right_arrow.gif"),a(o(ea,"themeVersion"),"frontal_arrow.svg"),a(o(ea,"themeVersion"),"instruction_up.svg"),a(o(ea,"themeVersion"),"instruction_left.svg"),a(o(ea,"themeVersion"),"instruction_right.svg"),a(o(ea,"themeVersion"),"instruction_frontal.svg");let eF=t.useCallback(({lostY:e,height:r,clientHeight:s})=>{let t=g.isMobile?e:e+80,n=t+r+20,a=n+110;ep({yFaceDetectionError:a+30,yCountdown:a,yFaceVerificationStepsWrapper:n});let o=Math.floor(e),i=Math.floor(s-e),c=Math.floor(t);return 0!==er&&(c+er<o||c+er+r>i)?eo({code:`offsetFaceY must be in [-${c-o}, ${i-r-c}]`}):c+=er,{y:c}},[er,eo]),{shouldResetFlowOnOrientationChange:eD,cropArea:eS,curStepIndex:eb,directionIcon:ev,directionIconAnimation:eT,faceDetectionError:ek,resetFlow:eI,handleVideoPlayed:eE,instructions:e_,refVideo:eV,refIsReseting:eL,steps:eR,videoPlayed:ew,activeCapturing:eA,warmupDone:eP,showLoading:eH}=F({currentOrientation:ex,apiCheck:$,bgCameraMask:ec,bgCameraMaskRed:el,surroundStyle:eC,onLivenessDetectionDone:O,onError:eo,cropAreaDimension:eF,customDirectionIcon:W,captureFrameSettings:B,onFramesCaptured:K,setRemainingTime:ej,customStepTimeConstraints:Y,onProcessing:J,customErrors:X,apiCredentials:q,outputEncryptionSettings:Q,cameraScale:Z,serviceSettings:et,onReset:en});t.useEffect(()=>{"string"==typeof eR[0]?.directionIcon&&Promise.all(eR.map(e=>S(e.directionIcon)))},[eR]);let eN=b(h,ea),eM=eL.current?0:eb/eR.length*100,{lang:eU}=i.useSDKSettings(),e$=t.useRef(0),eO=t.useRef({}),eB=t.useRef(c.ErrorDuration.SHORT),eK=t.useMemo(()=>{let{msg:e,duration:r=c.ErrorDuration.SHORT}=ek||{},s=e?.[eU];return Date.now()-e$.current>=eB.current&&(e$.current=Date.now(),eB.current=r,eO.current=s),eO.current},[ek,eb]),ez=t.useCallback(e=>{ey(e),eD?eI():e===j.LANDSCAPE?eV.current?.pause():eV.current?.play()},[eV,eI,eD]);return l.jsx(x,{onOrientationChange:ez,children:l.jsxs(u,{frontCamera:z,onVideoPlayed:eE,onClose:ei,flipHorizontal:G??z,ref:eV,videoSettings:M,onError:eo,scale:Z,defaultCameraId:ee,closeButton:l.jsx(m,{}),children:[!eP&&l.jsx(y,{}),ew?l.jsxs(l.Fragment,{children:[eS.current?l.jsxs(C,{x:`${eS.current.x}px`,y:`${eS.current.y}px`,width:`${eS.current.width}px`,height:`${eS.current.height}px`,surroundStyle:eS.current.surroundStyle,children:[l.jsx(v,{padding:T}),l.jsx(k,{...eN,progress:eM,showErrorRing:!!ek}),l.jsx(I,{children:(f=ev,D=eT,f?"string"==typeof f?l.jsx("img",{className:D,src:f,alt:"",style:{maxWidth:"98px",maxHeight:"98px",marginBottom:"25px"}}):f:null)}),eA&&l.jsx(E,{})]}):null,e_?l.jsxs(l.Fragment,{children:[l.jsx(_,{top:ed+5,className:"instructions",children:e_}),l.jsx(V,{top:ed+40,children:eR.map((e,r)=>{let{name:s,image:{objUrl:t}}=e;return l.jsx(L,{active:eb>=r,className:"step-item",children:t?l.jsx("img",{className:"image_preview",src:t,alt:""}):l.jsx(U,{stepNumber:r+1,type:s,theme:ea})},s)})})]}):null]}):null,l.jsx(R,{y:"20px",children:l.jsx(p,{id:"flash_liveness.title"})}),(eH||es)&&l.jsx(w,{children:l.jsx("img",{src:eu,alt:""})}),ef&&l.jsxs(A,{top:eg,children:[l.jsx(d,{color:n("Selfie.countdown.color")({theme:ea})}),l.jsx(P,{children:ef})]}),"string"==typeof eK?l.jsx(H,{top:eh,className:"face-detection-error",children:eK}):null]})})}$.propTypes={apiCheck:h.bool,onLivenessDetectionDone:h.func,onClose:h.func,onError:h.func,onReset:h.func,captureFrameSettings:h.shape({}),onFramesCaptured:h.func,flipVideoHorizontal:h.bool,frontCamera:h.bool,isLoading:h.bool,customDirectionIcon:h.shape({}),customStepTimeConstraints:h.shape({}),onProcessing:h.func,customErrors:h.shape({}),apiCredentials:h.shape({accessKey:h.string,secretKey:h.string,apiUrl:h.string}),outputEncryptionSettings:h.shape({}),cameraScale:h.number,defaultCameraId:h.string,offsetFaceY:h.number,styledComponent:h.shape({CloseCameraButton:h.node}),serviceSettings:h.shape({})},$.defaultProps={apiCheck:!1,onLivenessDetectionDone:null,onClose:null,onError:()=>{},onReset:()=>{},captureFrameSettings:{enable:!1,framesIntervalTime:180,framesBatchLength:0},onFramesCaptured:()=>{},flipVideoHorizontal:null,frontCamera:!0,isLoading:!1,customDirectionIcon:{[c.FaceDirection.LEFT]:l.jsx(D,{type:c.FaceDirection.LEFT}),[c.FaceDirection.RIGHT]:l.jsx(D,{type:c.FaceDirection.RIGHT}),[c.FaceDirection.UP]:l.jsx(D,{type:c.FaceDirection.UP}),[c.FaceDirection.FRONTAL]:l.jsx(D,{type:c.FaceDirection.FRONTAL})},customStepTimeConstraints:{[c.FaceDirection.UP]:{delayTime:0},[c.FaceDirection.LEFT]:{delayTime:0},[c.FaceDirection.RIGHT]:{delayTime:0},[c.FaceDirection.FRONTAL]:{delayTime:2e3}},onProcessing:()=>{},customErrors:null,apiCredentials:{accessKey:"",secretKey:"",apiUrl:""},outputEncryptionSettings:null,cameraScale:1,defaultCameraId:void 0,offsetFaceY:0,styledComponent:{CloseCameraButton:null},serviceSettings:{enableUploadFrames:!0,enableUploadImages:!0,enableVerifySanityPortrait:!0,enableVerifySanityIDCard:!0,enableVerifyFaceLiveness:!0,enableDetectIDCardTampering:!0,enableReadIDCardInfo:!0}};export{$ as default};
@@ -1 +0,0 @@
1
- import{$ as r}from"./chunk-575fb45a.js";import{r as o}from"./chunk-d15b739a.js";var s=r(o());export{s as d};
@@ -1 +0,0 @@
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-575fb45a.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-906e840c.js";import{u as b,C as k}from"./chunk-7b93e41f.js";import{M as I,O as T,W as E,C as R}from"./chunk-e2211b41.js";import{D as L}from"./chunk-4552fd9e.js";import{u as v}from"./chunk-2bdac502.js";import"./chunk-d15b739a.js";import"./chunk-37a2eeaf.js";import"./chunk-8c9bb671.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};