@tsocial/tvweb-sdk.abb 0.0.0-beta.20260625-024836
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/audio/en/keep_back_id_fit_border.mp3 +0 -0
- package/assets/audio/en/keep_front_id_fit_border.mp3 +0 -0
- package/assets/audio/en/move_face_closer.mp3 +0 -0
- package/assets/audio/en/move_face_into_frame.mp3 +0 -0
- package/assets/audio/en/please_hold_still.mp3 +0 -0
- package/assets/audio/vi/keep_back_id_fit_border.mp3 +0 -0
- package/assets/audio/vi/keep_front_id_fit_border.mp3 +0 -0
- package/assets/audio/vi/move_face_closer.mp3 +0 -0
- package/assets/audio/vi/move_face_into_frame.mp3 +0 -0
- package/assets/audio/vi/please_hold_still.mp3 +0 -0
- package/assets/v2/bg_camera_mask.png +0 -0
- package/assets/v2/bg_camera_mask_red.png +0 -0
- package/assets/v2/brand_logo.svg +35 -0
- package/assets/v2/flash_overlay.webp +0 -0
- package/assets/v2/flash_pattern_desktop.webp +0 -0
- package/assets/v2/flash_pattern_mobile.webp +0 -0
- package/assets/v2/frontal_arrow.gif +0 -0
- package/assets/v2/frontal_arrow.svg +6 -0
- package/assets/v2/ic_camera.svg +4 -0
- package/assets/v2/ic_close.png +0 -0
- package/assets/v2/ic_close.svg +9 -0
- package/assets/v2/ic_close_flash.svg +9 -0
- package/assets/v2/ic_close_white.png +0 -0
- package/assets/v2/ic_loading.gif +0 -0
- package/assets/v2/ic_loading.png +0 -0
- package/assets/v2/id_card_frame.png +0 -0
- package/assets/v2/id_card_frame_error.png +0 -0
- package/assets/v2/instruction_frontal.svg +6 -0
- package/assets/v2/instruction_left.svg +5 -0
- package/assets/v2/instruction_right.svg +5 -0
- package/assets/v2/instruction_up.svg +6 -0
- package/assets/v2/left_arrow.gif +0 -0
- package/assets/v2/qr_capture_cursor.png +0 -0
- package/assets/v2/qr_code_banner.png +0 -0
- package/assets/v2/qr_instruction.svg +49 -0
- package/assets/v2/right_arrow.gif +0 -0
- package/assets/v2/ts_logo.svg +6 -0
- package/assets/v2/up_arrow.gif +0 -0
- package/build/esm/chunk-0015538d.js +1 -0
- package/build/esm/chunk-080d4642.js +1 -0
- package/build/esm/chunk-08ab07a4.js +1 -0
- package/build/esm/chunk-1520b763.js +3 -0
- package/build/esm/chunk-23f22cf0.js +1 -0
- package/build/esm/chunk-259479f1.js +502 -0
- package/build/esm/chunk-2d04cdda.js +1 -0
- package/build/esm/chunk-3ba3f5be.js +1 -0
- package/build/esm/chunk-50924bca.js +1 -0
- package/build/esm/chunk-5c360a9c.js +85 -0
- package/build/esm/chunk-5d7eeacb.js +1261 -0
- package/build/esm/chunk-630b6747.js +1 -0
- package/build/esm/chunk-6e5fa179.js +1 -0
- package/build/esm/chunk-7daa3b76.js +1 -0
- package/build/esm/chunk-8a5beb79.js +1 -0
- package/build/esm/chunk-9950b40e.js +1 -0
- package/build/esm/chunk-b8d5649c.js +183 -0
- package/build/esm/chunk-bc46f915.js +1 -0
- package/build/esm/chunk-cb845d85.js +1 -0
- package/build/esm/chunk-e3a1c9ae.js +10 -0
- package/build/esm/chunk-f164fe97.js +3 -0
- package/build/esm/chunk-ffa40a6f.js +256 -0
- package/build/esm/tvweb-sdk.abb.esm.min.js +1 -0
- package/build/tvweb-sdk.abb.cjs.min.js +2296 -0
- package/build/tvweb-sdk.abb.standalone.js +96426 -0
- package/build/tvweb-sdk.abb.standalone.min.js +2296 -0
- package/build/types/index.d.ts +1857 -0
- package/package.json +39 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a3 as r}from"./chunk-5d7eeacb.js";import{r as o}from"./chunk-50924bca.js";var a=r(o());export{a as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,b as t,v as a,aI as n,s as s,q as i,ac as r,m as l,U as c,as as o,ar as m,p as g,X as u,a as _,aL as f,aM as d,c as b,a1 as h,O as p,Y as v,ax as w,E as F,aD as k}from"./chunk-5d7eeacb.js";import{d as y}from"./chunk-630b6747.js";import{t as I}from"./chunk-50924bca.js";import{w as T,o as R,q as S,t as L,u as x,r as B,s as D,v as E,x as M,y as A,z as O}from"./chunk-ffa40a6f.js";import{m as N}from"./chunk-080d4642.js";import{u as P}from"./chunk-2d04cdda.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},U=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 T();let t=R(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})}},j=n.faceTracker(),V=new f,{FaceDirection:W,Errors:z,Messages:$,TrackLivenessEvents:J}=s,K={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}},X=()=>{},G=()=>{},H=()=>{};function Z({apiCheck:f,bgCameraMask:T,bgCameraMaskRed:R,surroundStyle:C,cropAreaDimension:Y,customInstructions:Q,customIcon:ee,customDirectionIcon:et,customStepTimeConstraints:ea=q,onLivenessDetectionDone:en,onError:es,frontalMinSize:ei,waitingTimeToGetBetterFrames:er=500,captureFrameSettings:el=K,setRemainingTime:ec=X,onProcessing:eo=H,customErrors:em,customMessages:eg,apiCredentials:eu={},onFramesCaptured:e_=G,initFirstGestureTimeout:ef=2e3,outputEncryptionSettings:ed,cameraScale:eb=1,sendCustomEvent:eh,serviceSettings:ep,currentOrientation:ev,onReset:ew}={}){let[eF,ek]=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:eM}=i.useSDKSettings(),eA=r.useSDKLocale(),{apiClient:eO}=l.useApiClient({apiCredentials:eu}),[,eN]=e.useReducer(e=>e+1,0),eP=e.useRef(null),eC=e.useRef(!1),[eU,ej]=e.useState(!1),eV=e.useRef({}),{sendEvent:eW}=c.useSDKTracking(),ez=e.useRef(null);null===ez.current&&(ez.current=n.initFaceVerificationData({assetRoot:eD,customInstructions:Q,customIcon:ee,customDirectionIcon:et,customStepTimeConstraints:ea,Locale:eA,lang:eB}));let[e$,eJ]=e.useState(),eK=e.useCallback(e=>{eJ(e)},[]),eq=e.useMemo(()=>I(eK,500),[eK]),eX=e.useRef([]),eG=e.useRef(),eH=P(),{faceTrackingSetting:eZ,flowIntervalTimeMs:eY,limitTimeLivenessCheck:eQ,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({},S,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:eH}),e9=1e3*eQ.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,eH),[eH,ep]),tr=e.useRef(""),tl=e.useCallback(e=>{if(e?.event){if(e.event===J?.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:J?.start_camera,log:{}})},[tl]),e.useEffect(()=>(V.start(),()=>{V.stop()}),[]),e.useEffect(()=>{let e=!1;return async function t(){!eU&&(eG.current=performance.now(),eV.current=await d(eE),await b.initTensorFlow({preferredBackends:["wasm","webgl","cpu"]}),e||(ej(!0),tl({tag:"selfie",event:J?.show_warmup,log:{}}),tl({tag:"selfie",event:J?.finish_load_model,log:{status:"success",time_in_ms:performance.now()-eG.current}}),eG.current=null))}(),()=>{e=!0}},[eU,eE,tl]);let tu=e.useRef(!1),t_=e.useCallback(()=>{ez.current.curStepIndex=ez.current.steps.length,tu.current=!0,eR(!1),tg.current?.discardRecording()},[]),tf=e.useCallback(()=>{if(ez.current=n.initFaceVerificationData({assetRoot:eD,customInstructions:Q,customIcon:ee,customDirectionIcon:et,Locale:eA,lang:eB}),to.current=0,tm.current=null,eX.current=[],eL(!1),eJ(null),A(),tg.current?.start(),tu.current=!1,e8.enable){let e=tt();u.addExifData("frame_batch_ids",e)}"function"==typeof ew&&ew(),eN()},[eA,eD,e8.enable,et,ee,Q,eB,ew,tt]),td=e.useCallback(()=>{t_(),setTimeout(()=>{tf()},eY)},[t_,eY,tf]),tb=e.useMemo(()=>({...z,...em}),[em]),th=e.useMemo(()=>({...$,...eg}),[eg]),tp=e.useCallback(({remainTime:e})=>{if(e>0&&e<=eQ.remainTimeShow){let t=L(th.REMAIN_TIME[eB]),a=e;switch(eQ.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,eQ.format,eQ.remainTimeShow,th.REMAIN_TIME,ec]),tv=e.useCallback(()=>{let e={};Object.keys(tb.liveness_terminated_time_out?.msg).forEach(t=>{let a=L(tb.liveness_terminated_time_out?.msg[t]);e[t]=a({x:eQ.limitTimeSecond})}),eJ({...tb.liveness_terminated_time_out,msg:e,duration:.95*eY}),tl({tag:"selfie",event:J?.show_alert,log:{alert:"liveness_terminated_time_out,"}}),V.stop(),ec(""),t_()},[tb.liveness_terminated_time_out,eY,eQ.limitTimeSecond,t_,tl,ec]),tw=e.useCallback(({attemptCount:e,fromBackground:t})=>{eQ.enableMaxRetries&&e>=eQ.totalMaxRetries&&es(s.Errors.max_retry_reached),t&&t_(),V.start(),tf()},[eQ.enableMaxRetries,eQ.totalMaxRetries,es,tf,t_]),{stopTimer:tF}=x({totalTime:eQ.limitTimeSecond,totalDelayBetweenReset:eY/1e3,interruptible:eQ.interruptible,shouldStart:ey&&eQ.enable&&eU,onTimesUp:tv,onTick:tp,onReset:tw}),tk=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:T,surroundStyle:C},"object"==typeof Y?eP.current={...eP.current,...Y}:"function"==typeof Y&&(eP.current={...eP.current,...Y({clientWidth:e,clientHeight:t,videoAreaWidth:a,videoAreaHeight:n,lostX:s,lostY:i,isMobile:_.isMobile,width:r,height:l})}),eN(),eI(!0)},[T,C,Y]),ty=e.useRef({});e.useEffect(()=>{ty.current.isFirstValidFrameFoundRef=eS},[eS]),e.useEffect(()=>{let e,t=ex.current,a=async()=>{let{steps:e}=ez.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(eX.current.length/e4.framesBatchLength)}x${e4.framesBatchLength}`,t=eX.current.length%e4.framesBatchLength>0?`+${eX.current.length%e4.framesBatchLength}`:"";s=`${eX.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}=ez.current,t=e[ez.current.curStepIndex];if((t&&tl({tag:"selfie",event:{[s.FaceDirection.UP]:J?.capture_up_face,[s.FaceDirection.LEFT]:J?.capture_left_face,[s.FaceDirection.RIGHT]:J?.capture_right_face,[s.FaceDirection.FRONTAL]:J?.capture_frontal_face}[t.name],log:{time_capture_in_seconds:((performance.now()-eG.current)/1e3).toFixed(1)}}),ez.current.curStepIndex++,eG.current=performance.now(),eZ.enable&&"each_gesture"===eZ.limitFor&&(to.current=0),ez.current.curStepIndex===e.length)&&(eQ.enable&&(V.stop(),tF(),ec("")),en)){let t=eX.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:J?.finish_capture,log:{time_capture_in_seconds:V.duration("from_1st_frame")}}),eo(),await tg.current?.stopVideoRecording(),ek(!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=eX.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 U({apiClient:eO,faceVerificationFlowData:ez,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:J?.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()}ek(!1)}eN()},r=y(()=>{let{curStepIndex:e,steps:t}=ez.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}=ez.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||w.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||w.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([w.calculateBlurScore(i),F.getModelPredictions({model:b,sCanvas:i})]),{error:y,fullFace:I,faceRatio:S,faceNotFrontalMinThreshold:L}=await n.validatePredictions({predictions:v,width:F.SIZE,height:F.SIZE});r=y,eP.current.image=T;let x=null,D=null,E=null,M=null,{curStepIndex:A,steps:O}=ez.current;if(I){let e=O[A],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);(M=e)&&!r&&(r=z.close_eye)}}let N=r?.code==="no_face"||r?.code==="partial_face",P=A<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&&(eJ({...tb.liveness_terminated_no_face,duration:eY}),tl({tag:"selfie",event:J?.show_alert,log:{alert:"liveness_terminated_no_face"}}),td())}({noFace:N&&P,isFirstValidFrameFoundRef:m}),r?.code&&tc({tag:"selfie",event:J?.show_alert,log:{alert:r.code}}),!r||"face_too_small"===r.code&&x!==W.FRONTAL&&S>=L?(m||(eL(!0),eG.current=performance.now(),V.start("from_1st_frame")),function({trackingScore:e,isFirstValidFrameFoundRef:t}){if(!eZ.enable||null===e||!t)return!0;let{webWarningThreshold:a,webTerminateThreshold:n,maxWarningTime:s}=eZ;return!!(e<a)||(e<n&&to.current<s?(to.current++,to.current===s?(eJ({...tb.liveness_terminated_face_tracking,duration:eY}),tl({tag:"selfie",event:J?.show_alert,log:{alert:"liveness_terminated_face_tracking"}})):eJ({...tb.liveness_too_fast,duration:1500}),!0):(eJ({...tb.liveness_terminated,duration:eY}),tl({tag:"selfie",event:J?.show_alert,log:{alert:"liveness_terminated"}}),td(),!1))}({trackingScore:function(e,t,a,n){if(eX.current.length&&Date.now()-eX.current[eX.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}=j(e,0===eX.current.length),c={label:"portrait",base64:t.toDataURL("image/jpeg",.8).split(",")[1],landmarks:a,original_landmarks:a,score:r,time:l,index:eX.current.length,bbox:i,original_bbox:i,metadata:JSON.stringify({})};if(ed&&ed.key){if(c.base64=k.encryptFrameBase64(c.base64,ed.key),eX.current.push(c),e4.framesBatchLength>0&&eX.current.length%e4.framesBatchLength==0&&e_){let e=eX.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,eX.current.length===e4.framesBatchLength)})}}else if(eX.current.push(c),e4.framesBatchLength>0&&eX.current.length%e4.framesBatchLength==0&&e_){let e=eX.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,eX.current.length===e4.framesBatchLength)}return r}return null}(v[0],i,E,A>=O.length),isFirstValidFrameFoundRef:m})&&await l({faceDirection:x,canvas:i,blurScore:p,leftRightScore:D,isEyeClose:M})):A<O.length&&(o=tb[r.code],eP.current.image=R),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 M({outputImagesSize:400,videoEl:t,resultAnalyzeVideoAndWindowSizes:e}):{};tg.current=s,tg.current&&tg.current.start(),c(e,a)}return ey&&eU&&setTimeout(()=>{o()},e3??ef),()=>{cancelAnimationFrame(e),e=-1}},[ev,e3,ef,ey,eB,eO,f,T,R,en,es,ei,er,e4,eo,eZ,eQ.enable,ec,eq,ea,eY,td,e0,tb,eU,tl,e_,ed,eb,e1?.enable,e1?.webThreshold,e1?.webTimeout,e1?.forceCheck,e6.enable,eM,tc,ts,ti,tF,e7,tn,e8.enable]);let{curStepIndex:tI,steps:tT}=ez.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:tk,instructions:tL,refVideo:ex,refIsReseting:tu,steps:tT,videoPlayed:ey,activeCapturing:eT,isFirstValidFrameFound:eS,warmupDone:eU,showLoading:eF}}export{Z as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,s as t,P as s,j as a,b as n,v as i,a as r,n as l,g as o,ar as _,as as g,V as c,X as d,at as f,au as h,av as u,aw as m,ax as b,ay as p,az as v,aA as y,aB as S,O as k,Z as C,m as F,p as x,Y as E,aC as w,aD as M,a1 as R}from"./chunk-5d7eeacb.js";import{d as L}from"./chunk-630b6747.js";import{t as W}from"./chunk-50924bca.js";import{C as I,O as A}from"./chunk-5c360a9c.js";import{u as D,S as T,a as B,F as O,b as q,c as P,d as j,n as V,l as Q,e as N,s as U,f as H,R as $,g as G,h as J,i as z,j as K,W as X,k as Y,m as Z,o as ee,p as et,q as es,r as ea,A as en,O as ei}from"./chunk-e3a1c9ae.js";import{m as er,a as el,u as eo}from"./chunk-080d4642.js";import{u as e_}from"./chunk-2d04cdda.js";let eg=e.createContext(t.Mode.FLASH_ADVANCED),ec=({flashMode:e,children:s})=>{let n=e===t.Mode.FLASH||e.startsWith("flash_")?e:t.Mode.FLASH;return a.jsx(eg.Provider,{value:n,children:s})};ec.defaultProps={flashMode:t.Mode.FLASH_ADVANCED},ec.propTypes={flashMode(e,t,s){if(!/(^flash_|^flash$)/.test(e[t]))return Error(`Invalid prop \`${t}\` of value \`${e[t]}\` supplied to \`${s}\`. \`${t}\` is either 'flash' or begins with 'flash_'. Falling back to 'flash'.`)},children:s.node.isRequired};let ed=()=>{let t=e.useContext(eg);if(void 0===t)throw Error("useFlashMode must be used within a FlashModeProvider");return t},ef=0,eh=1,eu={data:{settings:{flashing_modes:{flash:{frames_per_color:8,frames_per_color_web:8,colors:"r r rrr",colors_web:"r r rrr"}},sdk_settings:{flash_liveness_settings:{frontal_face_check:{enable:!0,up_down_bound_min:.35,up_down_bound_max:.7},capture_frame_settings:{enable:!1,frames_batch_length:10,frames_interval_time:0,frame_quality:.8,frame_scale:1,auto_capture_min_frames:0,auto_capture_min_frames_far:0,auto_capture_min_frames_close:0},not_qualified_settings:{enable_far:!1,enable_close:!1,threshold_far:.11,threshold_close:.11},close_eyes_settings:{enable:!1,timeout:5,force_check:!1},face_settings:{close_face_ratio:.82,max_far_face_ratio:.9,min_far_face_ratio:.8,mobile:{close_face_ratio:.95,max_far_face_ratio:.9,min_far_face_ratio:.85}},flash_settings:{colors_length:10,flash_color:"rgb(255, 0, 0)",secondary_flash_color:"rgba(0,0,0,0.6)",delay_between_colors:120,flash_intensity:1,frames_per_color:4,use_face_detector_when_flashing:!1,flash_frame_interval:0},liveness_settings:{enable_far_step:!0},timeout_settings:{enable:!0,total:30,countdown:10,max_retry_count:0,non_stoppable:!1},exif_data_settings:{enable:!0},mask_settings:{chin_to_mask_bottom_padding:20,large_scale:.85,mobile:{chin_to_mask_bottom_padding:20,large_scale:.9,oval_padding:{bottom:20,left:20,right:20,top:0},oval_vertical_offset:60,small_scale:.65},oval_padding:{bottom:20,left:30,right:30,top:0},oval_vertical_offset:0,small_scale:.6},image_settings:{valid_face_ratio:.6,image_quality:1,crop_center_far:!0,crop_center_close:!1,detection_to_whole_face_ratio:.8},blur_far_settings:{enable:!0,blurry_threshold:.4,wait_for_best_image_time_ms:1e3},blur_close_settings:{enable:!0,blurry_threshold:.4,wait_for_best_image_time_ms:1e3},brightness_detection_far_settings:{enable_too_bright_check:!1,enable_too_dark_check:!1,too_bright_threshold:.83,too_dark_threshold:.195},brightness_detection_close_settings:{enable_too_bright_check:!1,enable_too_dark_check:!1,too_bright_threshold:.83,too_dark_threshold:.195},output_image_settings:{image_ordering:["close","far"]},auto_gen_frame_ids:{enable:!1,max_items:50}}}}}},em=()=>{let s=e_(),a=ed();return e.useMemo(()=>{let e=er({},eu,s),l=n(e,`data.settings.flashing_modes.${t.Mode.FLASH}`),o=n(e,`data.settings.flashing_modes.${a}`,l),_={enable:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.capture_frame_settings.enable"),framesIntervalTime:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.capture_frame_settings.frames_interval_time"),framesBatchLength:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.capture_frame_settings.frames_batch_length"),frameScale:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.capture_frame_settings.frame_scale"),frameQuality:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.capture_frame_settings.frame_quality"),autoCaptureMinFramesFar:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.capture_frame_settings.auto_capture_min_frames_far"),autoCaptureMinFramesClose:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.capture_frame_settings.auto_capture_min_frames_close")},g={enableFarStep:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.liveness_settings.enable_far_step")},c={flashColor:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.flash_settings.flash_color"),secondaryFlashColor:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.flash_settings.secondary_flash_color"),colors:i.getWebSetting(o,"colors"),delayBetweenColors:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.flash_settings.delay_between_colors"),framesPerColor:i.getWebSetting(o,"frames_per_color"),flashIntensity:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.flash_settings.flash_intensity"),useFaceDetectorWhenFlashing:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.flash_settings.use_face_detector_when_flashing"),flashFrameInterval:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.flash_settings.flash_frame_interval")},d={smallScale:i.getWebSetting(e,r.isMobile?"data.settings.sdk_settings.flash_liveness_settings.mask_settings.mobile.small_scale":"data.settings.sdk_settings.flash_liveness_settings.mask_settings.small_scale"),largeScale:i.getWebSetting(e,r.isMobile?"data.settings.sdk_settings.flash_liveness_settings.mask_settings.mobile.large_scale":"data.settings.sdk_settings.flash_liveness_settings.mask_settings.large_scale"),ovalPadding:{left:i.getWebSetting(e,r.isMobile?"data.settings.sdk_settings.flash_liveness_settings.mask_settings.mobile.oval_padding.left":"data.settings.sdk_settings.flash_liveness_settings.mask_settings.oval_padding.left"),right:i.getWebSetting(e,r.isMobile?"data.settings.sdk_settings.flash_liveness_settings.mask_settings.mobile.oval_padding.right":"data.settings.sdk_settings.flash_liveness_settings.mask_settings.oval_padding.right"),top:i.getWebSetting(e,r.isMobile?"data.settings.sdk_settings.flash_liveness_settings.mask_settings.mobile.oval_padding.top":"data.settings.sdk_settings.flash_liveness_settings.mask_settings.oval_padding.top"),bottom:i.getWebSetting(e,r.isMobile?"data.settings.sdk_settings.flash_liveness_settings.mask_settings.mobile.oval_padding.bottom":"data.settings.sdk_settings.flash_liveness_settings.mask_settings.oval_padding.bottom")},ovalVerticalOffset:i.getWebSetting(e,r.isMobile?"data.settings.sdk_settings.flash_liveness_settings.mask_settings.mobile.oval_vertical_offset":"data.settings.sdk_settings.flash_liveness_settings.mask_settings.oval_vertical_offset"),chinToMaskBottomPadding:i.getWebSetting(e,r.isMobile?"data.settings.sdk_settings.flash_liveness_settings.mask_settings.mobile.chin_to_mask_bottom_padding":"data.settings.sdk_settings.flash_liveness_settings.mask_settings.chin_to_mask_bottom_padding")},f={minFarFaceRatio:i.getWebSetting(e,r.isMobile?"data.settings.sdk_settings.flash_liveness_settings.face_settings.mobile.min_far_face_ratio":"data.settings.sdk_settings.flash_liveness_settings.face_settings.min_far_face_ratio"),maxFarFaceRatio:i.getWebSetting(e,r.isMobile?"data.settings.sdk_settings.flash_liveness_settings.face_settings.mobile.max_far_face_ratio":"data.settings.sdk_settings.flash_liveness_settings.face_settings.max_far_face_ratio"),closeFaceRatio:i.getWebSetting(e,r.isMobile?"data.settings.sdk_settings.flash_liveness_settings.face_settings.mobile.close_face_ratio":"data.settings.sdk_settings.flash_liveness_settings.face_settings.close_face_ratio")},h={enable:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.close_eyes_settings.enable"),timeout:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.close_eyes_settings.timeout"),forceCheck:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.close_eyes_settings.force_check")},u={enable:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.exif_data_settings.enable")},m={imageQuality:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.image_settings.image_quality"),validFaceRatio:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.image_settings.valid_face_ratio"),enableCropCenterFar:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.image_settings.crop_center_far"),enableCropCenterClose:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.image_settings.crop_center_close"),detectionToWholeFaceRatio:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.image_settings.detection_to_whole_face_ratio")},b=i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.timeout_settings.max_retry_count"),p={enable:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.timeout_settings.enable"),total:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.timeout_settings.total"),countdown:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.timeout_settings.countdown"),enableMaxRetryCount:b>0,maxRetryCount:b,interruptible:!i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.timeout_settings.non_stoppable")},v={enable:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.blur_far_settings.enable"),threshold:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.blur_far_settings.blurry_threshold"),duration:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.blur_far_settings.wait_for_best_image_time_ms")},y={enable:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.blur_close_settings.enable"),threshold:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.blur_close_settings.blurry_threshold"),duration:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.blur_close_settings.wait_for_best_image_time_ms")},S={enable:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.not_qualified_settings.enable_far"),threshold:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.not_qualified_settings.threshold_far")},k={enable:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.not_qualified_settings.enable_close"),threshold:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.not_qualified_settings.threshold_close")},C={enableTooBrightCheck:n(e,"data.settings.sdk_settings.flash_liveness_settings.brightness_detection_far_settings.enable_too_bright_check"),enableTooDarkCheck:n(e,"data.settings.sdk_settings.flash_liveness_settings.brightness_detection_far_settings.enable_too_dark_check"),tooBrightThreshold:n(e,"data.settings.sdk_settings.flash_liveness_settings.brightness_detection_far_settings.too_bright_threshold"),tooDarkThreshold:n(e,"data.settings.sdk_settings.flash_liveness_settings.brightness_detection_far_settings.too_dark_threshold")},F={enableTooBrightCheck:n(e,"data.settings.sdk_settings.flash_liveness_settings.brightness_detection_close_settings.enable_too_bright_check"),enableTooDarkCheck:n(e,"data.settings.sdk_settings.flash_liveness_settings.brightness_detection_close_settings.enable_too_dark_check"),tooBrightThreshold:n(e,"data.settings.sdk_settings.flash_liveness_settings.brightness_detection_close_settings.too_bright_threshold"),tooDarkThreshold:n(e,"data.settings.sdk_settings.flash_liveness_settings.brightness_detection_close_settings.too_dark_threshold")},x={imageOrdering:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.output_image_settings.image_ordering"),farImageOrder:eh,closeImageOrder:ef};Array.isArray(x.imageOrdering)&&2===x.imageOrdering.length&&"far"===x.imageOrdering[0]&&"close"===x.imageOrdering[1]&&(x.farImageOrder=0,x.closeImageOrder=1);let E={enable:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.auto_gen_frame_ids.enable")&&p.enable,maxItems:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.auto_gen_frame_ids.max_items")};return{captureFrameSettings:_,livenessSettings:g,flashSettings:c,maskSettings:d,faceSettings:f,closeEyesSettings:h,exifSettings:u,imageSettings:m,timeoutSettings:p,blurCheckFarSettings:v,blurCheckCloseSettings:y,notQualifiedFarSettings:S,notQualifiedCloseSettings:k,brightnessDetectionFarSettings:C,brightnessDetectionCloseSettings:F,outputImageSettings:x,autoGenFrameIds:E,frontalFaceCheckSettings:{enable:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.frontal_face_check.enable"),upDownBoundMin:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.frontal_face_check.up_down_bound_min"),upDownBoundMax:i.getWebSetting(e,"data.settings.sdk_settings.flash_liveness_settings.frontal_face_check.up_down_bound_max")}}},[s,a])},eb=r.isMobile?{width:{ideal:640},whiteBalanceMode:"none"}:{width:{ideal:9999},whiteBalanceMode:"none"},ep=(e,t)=>""===t.faceError&&(!!e.isEyeClosed&&!t.isEyeClosed||(!!e.isEyeClosed||!t.isEyeClosed)&&(!!m.hasBetterBrightnessScore(t.brightnessScore,e.brightnessScore)||!!m.hasSameBrightnessScore(t.brightnessScore,e.brightnessScore)&&b.hasBetterBlurScore(t.blurScore,e.blurScore)));function ev(s){let{onReset:n,onFlashDone:i,frontCamera:r,styledComponent:m,onFramesCaptured:b,customComponent:F,extraConfig:x,onImageCaptured:E}=s,{onCloseCallback:w,onErrorCallback:M}=el(),R=em(),A=F?.FlashLivenessBody??p,ee=F?.FlashLivenessOverlay??v,et=F?.FlashLivenessError??y,es=F?.FlashLivenessCloseIcon??S,{maskSettings:ea,flashSettings:en,faceSettings:ei,livenessSettings:er,captureFrameSettings:e_,imageSettings:eg,timeoutSettings:ec,blurCheckFarSettings:ef,blurCheckCloseSettings:eh,exifSettings:eu,autoGenFrameIds:ev}=R;if(ea.smallScale>ea.largeScale)throw Error("smallScale must be smaller than largeScale");let ey=e.useRef(),eS=D(),ek=eo(),{framesPerColor:eC,delayBetweenColors:eF,useFaceDetectorWhenFlashing:ex,flashIntensity:eE,flashColor:ew,colors:eM,flashFrameInterval:eR,secondaryFlashColor:eL}=en,[eW,eI]=e.useState(""),eA=e.useMemo(()=>W(eI,1e3),[]),[eD,eT]=e.useState(!1),[eB,eO]=e.useState(T.LOADING),eq=l(),eP={width:o("FlashLiveness.mask.width")({theme:eq}),height:o("FlashLiveness.mask.height")({theme:eq}),strokeColor:(eB===T.FAR_FACE||eB===T.CLOSE_FACE)&&eW&&!eD?o("FlashLiveness.mask.strokeColorError")({theme:eq}):o("FlashLiveness.mask.strokeColor")({theme:eq}),strokeWidth:2*o("FlashLiveness.mask.strokeWidth")({theme:eq}),path:o("FlashLiveness.mask.path")({theme:eq}),backgroundColor:o("FlashLiveness.maskFill")({theme:eq})},ej=e.useRef(null),[eV,eQ,eN,eU]=B(),[eH,e$]=e.useState(0),[eG,eJ]=e.useState(!1),ez=e.useRef({frames:[],total:{[O.FAR_FACE]:0,[O.CLOSE_FACE]:0}}),eK=e.useRef(!1),eX=e.useRef(!1),eY=e.useRef(!1),eZ=q({compareFn:ep,duration:ef.duration,minFrames:e_.autoCaptureMinFramesFar}),e0=q({compareFn:ep,duration:eh.duration,minFrames:e_.autoCaptureMinFramesClose}),e1=ed(),[e2,e3]=e.useState(!1),{sessionId:e5,updateSessionId:e8}=P(),e9=e.useRef(_.createSingleUUID()),{onVideoPlayed:e6,cropArea:e4,isPlaying:e7}=j({}),{smallScale:te,largeScale:tt}=V(ea,{width:eP.width,height:eP.height},{width:e4.width,height:e4.height}),ts=e.useRef(null),ta=e.useRef(null),tn=1e3*ec.total/e_.framesIntervalTime+eM.length*eC,{uuids:ti,getNextUUID:tr,reset:tl}=g({total:Math.min(ev.maxItems,Math.ceil(tn/e_.framesBatchLength))}),to=e.useCallback(e=>{let t=e[e.length-1];try{let e=JSON.parse(t.metadata);ev.enable&&(e.global_batch_id=tr()),e.global_session_id=e9.current,t.metadata=JSON.stringify(e)}catch(e){console.error("Unable to process last frame metadata",e)}},[ev.enable,tr]),{playVoice:t_}=c.useVoicePlayer(),tg=e.useMemo(()=>L(({reason:e})=>{if(eY.current=!1,ez.current.frames=[],ez.current.total[O.FAR_FACE]=0,ez.current.total[O.CLOSE_FACE]=0,eK.current=!1,eX.current=!1,ts.current=null,ta.current=null,er.enableFarStep?(e$(te),eO(T.FAR_FACE),t_("move_face_into_frame")):t_("move_face_closer"),e8(),ev.enable){let e=tl();d.addExifData("frame_batch_ids",e)}n({reason:e})},200,{leading:!0}),[er.enableFarStep,e8,ev.enable,n,te,t_,tl]),tc=Q({offset:ea.ovalVerticalOffset,ovalPadding:ea.ovalPadding,largeScale:tt,maskHeight:e4.height,ovalHeight:eP.height}),{flashingColors:td,currentColor:tf,colorIndex:th,startFlashing:tu,goToNextColor:tm,colorInfoRef:tb,checkIsLastColor:tp}=(({colors:s="",onFlashDone:a,onErrorCallback:n,framesPerColor:i,flashColor:r,secondaryFlashColor:l})=>{let[o,_]=e.useState(null),g=e.useRef({colorIndex:null,frameIndex:null,colorStringIndex:null}),c=e.useMemo(()=>s.split("").reduce((e,t)=>e+t.repeat(i),""),[s,i]),d=" "===c[o]?l:r,f=e.useCallback(()=>g.current.colorStringIndex===c.length-1,[c.length]),h=e.useCallback(()=>{if(g.current.colorIndex+=Math.floor((g.current.frameIndex+1)/i),g.current.frameIndex=(g.current.frameIndex+1)%i,g.current.colorStringIndex+=1,!(g.current.colorStringIndex>c.length)){if(g.current.colorStringIndex<c.length)return void _(e=>e+1);_(null),g.current={colorIndex:null,frameIndex:null,colorStringIndex:null},"function"==typeof a&&a()}},[c.length,i,a]),u=e.useCallback(()=>{_(0),g.current={colorIndex:0,frameIndex:0,colorStringIndex:0}},[]);return e.useEffect(()=>{0===c.length&&"function"==typeof n&&n(t.Errors.flashing_color_error)},[c.length,n]),{flashingColors:c,colorIndex:o,currentColor:d,goToNextColor:h,startFlashing:u,colorInfoRef:g,checkIsLastColor:f}})({colors:eM,onFlashDone:e.useCallback(async()=>{eO(T.STOP_DECTECTING),eS("selfie_flash","user_activity.finish_flash"),eS("selfie_flash","user_activity",({lastTimeLog:e})=>({flash_liveness_in_ms:e-ey.current}));let{frames:e}=ez.current;if(e_.enable&&e_.framesBatchLength>0){let t=e.length%e_.framesBatchLength;if(0!==t){let s=e.slice(-1*t);to(s),"function"==typeof b&&b(s)}}try{"function"==typeof i&&await i({frames:ez.current.frames})}catch(e){M({error:e})}},[eS,e_.enable,e_.framesBatchLength,to,b,i,M]),onErrorCallback:M,framesPerColor:eC,flashColor:ew,secondaryFlashColor:eL}),tv=e.useCallback(()=>{!er.enableFarStep||(0===ez.current.total[O.FAR_FACE]&&(eY.current=!0),e_.enable&&(ez.current.total[O.FAR_FACE]+=1))},[e_.enable,er.enableFarStep]),ty=e.useMemo(()=>({x:Math.max(eQ?.left,0),y:Math.max(eQ?.top,0),width:Math.min(eQ?.right-eQ?.left,e4.width),height:Math.min(eQ?.bottom-eQ?.top,e4.height)}),[e4.height,e4.width,eQ?.bottom,eQ?.left,eQ?.right,eQ?.top]),tS=e.useCallback(({frame:e,prediction:t,originalRatio:s})=>{if(eK.current)return;let a=e=>{let t=Y({maskBoundingBox:ty,faceRatio:e.faceRatio,validFaceRatio:eg.validFaceRatio,video:ej.current,shouldCropCenterSquare:eg.enableCropCenterFar,cropArea:e4,frame:e.snapshot,facePrediction:e.facePrediction,detectionToWholeFaceRatio:eg.detectionToWholeFaceRatio}),s={blob:k.takePicture({canvas:t,quality:eg.imageQuality}),gesture:"frontal",captureTime:e.captureTime,selfieLabel:O.FAR_FACE,qualifyScore:e.qualifyScore,blurScore:e.blurScore,brightnessScore:e.brightnessScore,realQualifyScore:e.realQualifyScore,qualifyModelMessage:e.qualifyModelMessage};eK.current=!0,d.addExifData("flash_liveness.number_of_frames.far_frames",ez.current.total[O.FAR_FACE]),d.addExifData("model_score.face_blurry_score",s.blurScore),d.addExifData("model_score.face_brightness_score",s.brightnessScore),d.addExifData("model_score.face_qualify_score",s.qualifyScore),d.addExifData("debug_log.face_real_qualify_score",s.realQualifyScore),d.addExifData("debug_log.face_qualify_model_message",s.qualifyModelMessage),d.addExifData("selfie_label",s.selfieLabel),d.addExifData("capture_time",s.captureTime),d.addExifData("type",s.gesture),E(s),eI(""),e$(tt),eU(!0),eO(T.CLOSE_FACE),t_("move_face_closer")},n={qualifyScore:e.qualifyScore,blurScore:e.blurScore,isEyeClosed:e.isEyeClosed,faceRatio:e.faceRatio,snapshot:N(ej.current),captureTime:Date.now(),facePrediction:U(t,s),brightnessScore:e.brightnessScore,faceError:e.faceError,realQualifyScore:e.realQualifyScore,qualifyModelMessage:e.qualifyModelMessage};if(!ef.enable)return void a(n);if(!eZ.isAutoCapturing()){eT(!0),eZ.startCapturing({onDone:e=>{eT(!1),a(e)},initialFrame:n});return}eZ.captureFrame(n)},[ef.enable,eZ,ty,eg.validFaceRatio,eg.enableCropCenterFar,eg.detectionToWholeFaceRatio,eg.imageQuality,e4,E,tt,eU,t_]),tk=e.useCallback(({frame:e,prediction:t,originalRatio:s})=>{if(eX.current)return;let a=e=>{let t=Y({maskBoundingBox:ty,faceRatio:e.faceRatio,validFaceRatio:eg.validFaceRatio,video:ej.current,shouldCropCenterSquare:eg.enableCropCenterClose,cropArea:e4,frame:e.snapshot,facePrediction:e.facePrediction,detectionToWholeFaceRatio:eg.detectionToWholeFaceRatio}),s={blob:k.takePicture({canvas:t,quality:eg.imageQuality}),gesture:"frontal",captureTime:e.captureTime,selfieLabel:O.CLOSE_FACE,qualifyScore:e.qualifyScore,blurScore:e.blurScore,brightnessScore:e.brightnessScore,realQualifyScore:e.realQualifyScore,qualifyModelMessage:e.qualifyModelMessage};eX.current=!0,d.addExifData("flash_liveness.number_of_frames.close_frames",ez.current.total[O.CLOSE_FACE]),d.addExifData("model_score.face_blurry_score",s.blurScore),d.addExifData("model_score.face_brightness_score",s.brightnessScore),d.addExifData("model_score.face_qualify_score",s.qualifyScore),d.addExifData("debug_log.face_real_qualify_score",s.realQualifyScore),d.addExifData("debug_log.face_qualify_model_message",s.qualifyModelMessage),d.addExifData("selfie_label",s.selfieLabel),d.addExifData("capture_time",s.captureTime),d.addExifData("type",s.gesture),E(s),eI(""),eJ(!1),eO(T.START_FLASHING),tu()},n={qualifyScore:e.qualifyScore,blurScore:e.blurScore,isEyeClosed:e.isEyeClosed,faceRatio:e.faceRatio,snapshot:N(ej.current),captureTime:Date.now(),facePrediction:U(t,s),brightnessScore:e.brightnessScore,faceError:e.faceError,realQualifyScore:e.realQualifyScore,qualifyModelMessage:e.qualifyModelMessage};if(!eh.enable)return void a(n);if(!e0.isAutoCapturing()){t_("please_hold_still"),eT(!0),e0.startCapturing({onDone:e=>{eT(!1),a(e)},initialFrame:n});return}e0.captureFrame(n)},[eh.enable,e0,ty,eg.validFaceRatio,eg.enableCropCenterClose,eg.detectionToWholeFaceRatio,eg.imageQuality,e4,E,tu,t_]),tC=e.useMemo(()=>{if("number"==typeof th&&th%eC==0){let e=td[th-1];return e===td[th]?eR:Math.max(eF,eR)}return eR},[th,eF,eR,td,eC]),tF=null!==th&&eB===T.START_FLASHING,tx=e.useRef(!1),tE=e.useCallback(({prediction:e,canvas:t})=>{if(!tF||tx.current||null===tb.current.colorIndex||null===tb.current.frameIndex)return;if(!e_.enable)return void tm();let s=performance.now();if(null!==ta.current&&s-ta.current<tC)return;ta.current=s;let{frames:a}=ez.current,n=H({prediction:e,canvas:t,index:a.length,quality:e_.frameQuality}),i={color:tf,type:O.FLASHING,time:Math.round(performance.now()),colorIndex:tb.current.colorIndex,frameIndex:tb.current.frameIndex,colorStringIndex:tb.current.colorStringIndex,pattern:eM,session_id:e5},r=tp();if(r&&eu.enable&&(d.addExifData("flash_liveness.flash_liveness_in_ms",Math.round(performance.now()-ey.current)),i.exif=d.getCurrentExif()),n.metadata=JSON.stringify(i),a.push(n),e_.framesBatchLength>0&&a.length%e_.framesBatchLength==0){let e=a.slice(-1*e_.framesBatchLength);to(e),"function"==typeof b&&b(e)}r&&(tx.current=!0),tm()},[tF,e_.enable,e_.frameQuality,e_.framesBatchLength,tC,tf,tb,eM,e5,tp,eu.enable,tm,to,b]),tw=e.useCallback(({error:e})=>{eA(e),("no_face"===e||"multiple_faces"===e)&&"no_face"===e&&eY.current&&!eD&&tg({reason:$.no_face})},[eD,tg,eA]),{warmupDone:tM}=G({onError:M,isVideoPlaying:e7,step:eB,cropArea:e4,videoRef:ej,onFarFaceDetected:tv,onFarFullFaceDetected:tS,onCloseFaceDetected:e.useCallback(({prediction:e,canvas:t})=>{let{frames:s}=ez.current;if(er.enableFarStep||0!==s.length||(eY.current=!0),!e_.enable)return;let a=performance.now();if(null!==ta.current&&a-ta.current<e_.framesIntervalTime)return;ta.current=a;let n=H({prediction:e,canvas:t,index:s.length,quality:e_.frameQuality});if(n.metadata=JSON.stringify({color:"",type:O.CLOSE_FACE,time:Math.round(performance.now()),colorIndex:tb.current.colorIndex,pattern:eM,session_id:e5}),ez.current.total[O.CLOSE_FACE]+=1,s.push(n),e_.framesBatchLength>0&&s.length%e_.framesBatchLength==0){let e=s.slice(-1*e_.framesBatchLength);to(e),"function"==typeof b&&b(e)}},[er.enableFarStep,e_.enable,e_.framesIntervalTime,e_.frameQuality,e_.framesBatchLength,tb,eM,e5,to,b]),onCloseFullFaceDetected:tk,onFlashingFramesCaptured:tE,useFaceDetectorWhenFlashing:ex,onFaceError:tw,maskBoundingRect:eQ,shouldPauseFaceDetection:eN||e2,faceDetectionSettings:R,shouldContinueOnError:eD,debug:ek});J(ej.current);z(()=>{!async function(){let{resourceReport:e,measureReport:t}=await C.reportAll();Object.values(e).forEach(e=>{eS("selfie_flash","sdk.download_model",e)}),Object.values(t).forEach(e=>{eS("selfie_flash","sdk.init_model",e)})}()},tM),z(()=>{er.enableFarStep?(t_("move_face_into_frame"),eO(T.FAR_FACE),e$(te)):(t_("move_face_closer"),eO(T.CLOSE_FACE),e$(tt)),eJ(!0),d.addExifData("selfie_type",e1),d.addExifData("flash_liveness",{flash_settings:{delay_between_colors:en.delayBetweenColors,flash_color:en.flashColor,secondary_flash_color:en.secondaryFlashColor},face_settings:{close_face_ratio:ei.closeFaceRatio,max_far_face_ratio:ei.maxFarFaceRatio,min_far_face_ratio:ei.minFarFaceRatio},mask_settings:{oval_vertical_offset:ea.ovalVerticalOffset,small_scale:ea.smallScale,large_scale:ea.largeScale},image_settings:{valid_face_ratio:eg.validFaceRatio}}),d.addExifData("global_session_id",e9.current),d.addExifData("pattern",eM),ev.enable&&d.addExifData("frame_batch_ids",ti),ey.current||(ey.current=performance.now())},tM&&e7),z(()=>eS("selfie_flash","user_activity.start"),!0),z(()=>eS("selfie_flash","user_activity.start_far"),eB===T.FAR_FACE),z(()=>eS("selfie_flash","user_activity.start_close"),eB===T.CLOSE_FACE),z(()=>eS("selfie_flash","user_activity.start_flash"),eB===T.START_FLASHING);let tR=null===th?0:Math.min(Math.round((th+1)/(eM.length*eC)*100),100),{Loading:tL}=m,tW=e.useCallback(()=>{eT(!1),eZ.stopCapturing(),e0.stopCapturing(),e3(!0)},[e0,eZ]),tI=e.useCallback(()=>{e3(!1),tg({reason:$.timeout})},[tg]),{remaining:tA}=K({shouldStart:eG&&ec.enable,onTimeout:tW,onDelayEnd:tI,onError:M,totalTime:ec.total,totalDelay:3,maxRetriesSettings:{enable:ec.enableMaxRetryCount,total:ec.maxRetryCount},interruptible:ec.interruptible}),tD=Z(eW),tT=e4.y+e4.height/2+tc;return a.jsxs(a.Fragment,{children:[a.jsx(f,{frontCamera:r,onVideoPlayed:e6,onClose:w,flipHorizontal:r,ref:ej,onError:M,videoSettings:eb,closeButton:a.jsx(es,{}),children:a.jsxs(X,{overlay:!tM||!e7,loadingComponent:tL,children:[""!==eW&&a.jsx(h,{}),a.jsx(I,{x:`${Math.round(e4.x)}px`,y:`${Math.round(e4.y)}px`,width:`${e4.width}px`,height:`${e4.height}px`,surroundStyle:{background:o("FlashLiveness.maskFill")({theme:eq})},children:a.jsx(u,{ref:eV,scale:eH,debug:ek,width:e4.width,height:e4.height,padding:ea.ovalPadding,verticalOffset:tc,mask:eP})}),!eD&&""!==tD&&"start_flashing"!==eB&&a.jsx(et,{errorY:tT,errorMessage:tD})]})}),a.jsx(A,{step:eB,currentProgress:tR,errorCode:eW,timeoutProps:{remaining:tA,warningThreshold:ec.countdown,total:ec.total,shouldStart:eG&&ec.enable},isFlashingColor:tf===ew,isAutoCapturing:eD,extraConfig:x}),a.jsx(ee,{step:eB,currentColor:tf,flashIntensity:eE,flashColor:ew,secondaryFlashColor:eL})]})}let ey=s=>{let{apiCheck:n,onLivenessDetectionDone:i,frontalMinSize:r,serviceSettings:l,apiCredentials:o,..._}=s,g=_.customComponent?.FlashLivenessLoading??w,[c,f]=e.useState(!1),h=ee(),u=ed(),m=e_(),b=x.getEnabledServices(l,m),{verifyFlashLiveness:p,uploadImage:v}=function({outputEncryptionSettings:t,selfieType:s,enabledServices:a,apiCredentials:n}){let{apiClient:i}=F.useApiClient({apiCredentials:n}),r=e.useCallback(async e=>{if(!t.enable)return i.uploadImage({label:"portrait",file:e.blob,metadata:JSON.stringify({label:e.selfieLabel})});let s=new Blob([e.encrypted.hex]);return i.uploadImage({file:s,label:"portrait",metadata:JSON.stringify({label:e.selfieLabel})},{"X-TV-Key":t.key})},[i,t.enable,t.key]);return{verifyFlashLiveness:e.useCallback(async({videos:e,uploadedImages:t,metadata:n})=>{try{let r=null;a.enableVerifyFaceLiveness&&(r=i.verifyFaceLiveness({images:t.map(e=>({id:e?.data?.image_id,label:"portrait"})),videos:e,metadata:n,selfie_type:s}));let l=null;a.enableVerifySanityPortrait&&(l=i.requestVerifyPortrait({image:{id:t[t.length-1]?.data?.image_id},selfie_type:s}));let[o,_]=await Promise.all([r,l]);return{uploadedImages:t,faceLivenessResult:o,portraitResult:_}}catch(e){return console.error(e),{}}},[i,a.enableVerifyFaceLiveness,a.enableVerifySanityPortrait,s]),uploadImage:r}}({outputEncryptionSettings:h,selfieType:u,enabledServices:b,apiCredentials:o}),{captureFrameSettings:y,flashSettings:S,exifSettings:k,outputImageSettings:C}=em(),{framesIntervalTime:L}=y,{onFramesCaptured:W,onReset:I}=s,{onErrorCallback:A}=el(),D=et(),T=e.useRef([]),B=e.useRef([]),q=async e=>{let t=e;if(h.enable&&(t=await M.encryptFrames(t,h.key)),"function"==typeof W&&W(t),n&&b.enableUploadFrames){let e={};h.enable&&(e["X-TV-Key"]=h.key),es.uploadFrameBatch(ea(t),D,e)}},P=e.useCallback(async e=>{let t,s=e.selfieLabel===O.FAR_FACE?C.farImageOrder:C.closeImageOrder;if(T.current[s])return;let a=new Promise(e=>{t=e});B.current.push(a);let i={...e,blob:await e.blob},r=await d.writeCurrentExif({imageData:i,enableExifData:k.enable});i.blob=r,h.enable&&(i.encrypted=await E.encrypt({blob:i.blob,key:h.key})),T.current[s]={image:i,uploadPromise:n&&b.enableUploadImages?v(i):null},t()},[n,b.enableUploadImages,k.enable,h.enable,h.key,C.closeImageOrder,C.farImageOrder,v]),j=async e=>{f(!0),await Promise.all(B.current);let s={flash_color:S.flashColor,colors:S.colors,frames_per_color:S.framesPerColor,frame_interval:L,delay_between_colors:S.delayBetweenColors,use_face_detector_when_flashing:S.useFaceDetectorWhenFlashing};T.current=T.current.filter(e=>!!e);let a=T.current.map(e=>e.image).filter(e=>"frontal"===e.gesture),l=a.map(e=>e.blob),o=a.map(e=>e.encrypted),_=l[l.length-1],g=_&&"number"==typeof r?await R.scaleImage(_,{minsize:r}):null,c=e.frames;if(h.enable&&(c=await M.encryptFrames(c,h.key)),!n||!b.enableUploadImages){await i({capturedFrames:c,frontalFaces:l,frontalFacesEncrypted:o,frontalScaledImage:g,steps:[],metadata:s}),f(!1);return}try{let e=null;e=y.enable?await es.getAllUploadedBatches():[{frames:ea(c)}];let t=await Promise.all(T.current.map(e=>e.uploadPromise)),{faceLivenessResult:a,portraitResult:n}=await p({videos:e,uploadedImages:t,metadata:s});if(es.resetUploadBatches(),f(!1),a?.errors)throw a.errors;if(n?.errors)throw n.errors;await i({capturedFrames:c,steps:[],frontalFaces:l.map((e,s)=>({blob:e,id:t?.[s]?.data?.image_id})),frontalFacesEncrypted:o,frontalScaledImage:g,apiCheckPassed:a?.data.is_live??!1,verifyFaceLivenessResult:a?.data??null,verifyPortraitResult:n?.data??null,uploadFramesResult:e})}catch(e){console.error(e),f(!1),A({...t.Errors.api_call_error,details:e})}};return a.jsxs(a.Fragment,{children:[a.jsx(ev,{..._,apiCheck:n,onFlashDone:j,onFramesCaptured:q,onReset:()=>{T.current=[],B.current=[],es.resetUploadBatches(),"function"==typeof I&&I()},onImageCaptured:P}),a.jsx(g,{loading:c})]})},eS=e=>{let{apiCredentials:t,outputEncryptionSettings:s,mode:n}=e;return a.jsx(A,{version:"v2",unmountOnHidden:!0,children:a.jsx(en,{apiCredentials:t,children:a.jsx(ec,{flashMode:n,children:a.jsx(ei,{settings:s,children:a.jsx(ey,{...e})})})})})};eS.propTypes={apiCheck:s.bool,apiCredentials:s.shape({accessKey:s.string,secretKey:s.string,apiUrl:s.string}),onReset:s.func,onLivenessDetectionDone:s.func,onClose:s.func,onError:s.func,onFramesCaptured:s.func,frontCamera:s.bool,styledComponent:s.shape({CloseCameraButton:s.node}),outputEncryptionSettings:s.shape({key:s.string}),frontalMinSize:s.number,serviceSettings:s.shape({enableGetClientSettings:s.bool,enableUploadFrames:s.bool,enableUploadImages:s.bool,enableVerifySanityPortrait:s.bool,enableVerifyFaceLiveness:s.bool}),mode:s.string,flowId:s.string,customTexts:s.shape({}),customComponents:s.shape({FlashLivenessBody:s.elementType,FlashLivenessOverlay:s.elementType}),extraConfig:s.shape({})},eS.defaultProps={apiCheck:!1,apiCredentials:{},onReset:()=>{},onLivenessDetectionDone:()=>{},onClose:()=>{},onError:()=>{},onFramesCaptured:()=>{},frontCamera:!0,styledComponent:{CloseCameraButton:null},outputEncryptionSettings:{key:""},frontalMinSize:null,serviceSettings:{enableGetClientSettings:!0,enableUploadFrames:!0,enableUploadImages:!0,enableVerifySanityPortrait:!0,enableVerifyFaceLiveness:!0},mode:t.Mode.FLASH_ADVANCED,flowId:"",customTexts:{},customComponents:{FlashLivenessBody:null,FlashLivenessOverlay:null},extraConfig:null};export{eS as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let e,t;import{b as n,s as a,m as s,r as r,P as i,ad as o,j as l,p as u,q as c,v as f,t as p,w as d}from"./chunk-5d7eeacb.js";import{L as g,C as m,S as h,u as v}from"./chunk-2d04cdda.js";import{W as A}from"./chunk-080d4642.js";var C,S,b,y,F,T,E,I,x,_={exports:{}};function M(){if(C)return _.exports;C=1;var e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(e){var t=new Uint8Array(16);_.exports=function(){return e(t),t}}else{var n=Array(16);_.exports=function(){for(var e,t=0;t<16;t++)(3&t)==0&&(e=0x100000000*Math.random()),n[t]=e>>>((3&t)<<3)&255;return n}}return _.exports}function D(){if(b)return S;b=1;for(var e=[],t=0;t<256;++t)e[t]=(t+256).toString(16).substr(1);return S=function(t,n){var a=n||0;return""+e[t[a++]]+e[t[a++]]+e[t[a++]]+e[t[a++]]+"-"+e[t[a++]]+e[t[a++]]+"-"+e[t[a++]]+e[t[a++]]+"-"+e[t[a++]]+e[t[a++]]+"-"+e[t[a++]]+e[t[a++]]+e[t[a++]]+e[t[a++]]+e[t[a++]]+e[t[a++]]}}var U=function(){if(x)return I;x=1;var e=function(){if(F)return y;F=1;var e,t,n=M(),a=D(),s=0,r=0;return y=function(i,o,l){var u=o&&l||0,c=o||[],f=(i=i||{}).node||e,p=void 0!==i.clockseq?i.clockseq:t;if(null==f||null==p){var d=n();null==f&&(f=e=[1|d[0],d[1],d[2],d[3],d[4],d[5]]),null==p&&(p=t=(d[6]<<8|d[7])&16383)}var g=void 0!==i.msecs?i.msecs:new Date().getTime(),m=void 0!==i.nsecs?i.nsecs:r+1,h=g-s+(m-r)/1e4;if(h<0&&void 0===i.clockseq&&(p=p+1&16383),(h<0||g>s)&&void 0===i.nsecs&&(m=0),m>=1e4)throw Error("uuid.v1(): Can't create more than 10M uuids/sec");s=g,r=m,t=p;var v=((0xfffffff&(g+=122192928e5))*1e4+m)%0x100000000;c[u++]=v>>>24&255,c[u++]=v>>>16&255,c[u++]=v>>>8&255,c[u++]=255&v;var A=g/0x100000000*1e4&0xfffffff;c[u++]=A>>>8&255,c[u++]=255&A,c[u++]=A>>>24&15|16,c[u++]=A>>>16&255,c[u++]=p>>>8|128,c[u++]=255&p;for(var C=0;C<6;++C)c[u+C]=f[C];return o||a(c)}}(),t=function(){if(E)return T;E=1;var e=M(),t=D();return T=function(n,a,s){var r=a&&s||0;"string"==typeof n&&(a="binary"===n?Array(16):null,n=null);var i=(n=n||{}).random||(n.rng||e)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,a)for(var o=0;o<16;++o)a[r+o]=i[o];return a||t(i)}}();return t.v1=e,t.v4=t,I=t}();let k=e=>{let t={};return Object.entries(e).forEach(([e,n])=>{if(n){if("customerUserId"===e){t.cus_user_id=n;return}if("faces"===e){t.faces=n.map(e=>({id:e.id}));return}if("gestureFaces"===e){t.gesture_faces=n.map(e=>({gesture:e.gesture,images:e.images.map(e=>({id:e.id}))}));return}if("videos"===e){t.videos=n;return}t[e.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)]=n}}),t},R={enableVerifySanityPortrait:!1,enableVerifyFaceLiveness:!1};function w(e){let{apiCheck:t,mode:i,authType:o,authMethod:g,apiCredentials:m,onDone:h,onError:C,onClose:S,onReset:b,captureFrameSettings:y,onFramesCaptured:F,clientSettings:T,outputEncryptionSettings:E,logCredentials:I,flowId:x,serviceSettings:_,cameraScale:M,offsetFaceY:D,frontalMinSize:w,customTheme:N,livenessDetectionComponent:j,customComponent:V,customTexts:H,extraConfig:L}=e,B=v(),G=r.useMemo(()=>{let e={..._,...R};return u.getEnabledServices(e,B)},[B,_]),{FaceAuthenticationLoading:O}=V,[P,K]=r.useState(!1),{registerFace:W,authenFace:q}=function({apiCredentials:e,authMethod:t,enabledServices:a,authType:i}){let{apiClient:o}=s.useApiClient({apiCredentials:e}),l=r.useCallback(async e=>{let n=e.frontalFaces?.map(e=>({id:e.id}))??[],s=e.steps?.map(e=>({gesture:e.name,images:[{id:e.id}]})),r=[];return{selfieType:t,faces:n,gestureFaces:s,videos:r=a.enableUploadFrames?e.uploadFramesResult??[]:e.capturedFrames??[]}},[t,a.enableUploadFrames]),u=r.useCallback(async({sdkResult:e})=>{let t=await l(e),s=U.v4();t={...t,faceType:"selfie",customerUserId:s};let r=null;if(a.enableRegisterFace){let e=k(t);"success"===n(r=await o.httpClient.post("/v1/face_auth_register",e),"data.status")&&localStorage.setItem("tv:cus-user-id",s)}return{...t,apiResult:r}},[o.httpClient,l,a.enableRegisterFace]);return{registerFace:u,authenFace:r.useCallback(async({sdkResult:e})=>{let t=await l(e),n=localStorage.getItem("tv:cus-user-id");t={...t,customerUserId:n,authType:i};let s=null;if(a.enableAuthenticateFace){let e=k(t);s=await o.httpClient.post("/v1/face_auth",e)}return{...t,apiResult:s}},[o.httpClient,i,l,a.enableAuthenticateFace])}}({apiCredentials:m,authMethod:g,enabledServices:G,authType:o}),{billingSettings:z,enableBilling:Y}=c.useSDKSettings(),Z=f.getWebSetting(B,"data.settings.sdk_settings.billing_settings.billing_config"),$=f.getWebSetting(B,"data.settings.sdk_settings.billing_settings.url"),J=p.buildBillingInput(e),{submitBilling:Q}=d({enable:Y,onError:C,billingSettings:z??{json:Z??{}},billingUrl:$}),X=r.useCallback(e=>{let t={sdkStatus:a.BillingStatus.success,result:p.buildBillingOutput(e)};Q({service:a.BillingService.faceAuth,input:J,output:t}),h&&h(e)},[J,h,Q]),ee=r.useCallback(e=>{if(a.ErrorsWithoutBilling.includes(e.code))return void C(e);let t={error:e,sdkStatus:a.BillingStatus.fail};Q({service:a.BillingService.faceAuth,input:J,output:t}),C&&C(e)},[J,C,Q]),et=r.useCallback(e=>{var t,s;let r,l,u,c=(s={...e,frontalFaces:(r=n(t=e,"frontalFaces",[]),l=n(t,"frontalFacesEncrypted",[]),r.map((e,t)=>({blob:e,encrypted:l[t]??null})))},u={},u.faces=n(s,"frontalFaces"),u.videos=Array.isArray(n(s,"capturedFrames"))&&n(s,"capturedFrames").length>0?[{frames:n(s,"capturedFrames")}]:null,u.gestureFaces=Array.isArray(n(s,"steps"))&&n(s,"steps").length>0?n(s,"steps").map(e=>{let{name:t}=e;return{gesture:t,images:[{...e?.image}]}}):null,u);i===a.FaceAuthenticationMode.REGISTRATION&&(c={...c,customerUserID:U.v4(),faceType:"selfie",selfieType:g}),i===a.FaceAuthenticationMode.AUTHENTICATION&&(c={...c,selfieType:g,authType:o}),X(c)},[i,X,g,o]),en=r.useCallback(async e=>{if(!t||!G.enableUploadImages)return void et(e);try{let t;K(!0),i===a.FaceAuthenticationMode.REGISTRATION&&(t=await W({sdkResult:e})),i===a.FaceAuthenticationMode.AUTHENTICATION&&(t=await q({sdkResult:e})),X(t)}catch(e){console.error(e),ee({...a.Errors.api_call_error,details:e})}finally{K(!1)}},[t,G.enableUploadImages,et,i,X,W,q,ee]);return l.jsxs(A,{isWrappedBy:"face_authen",children:[l.jsx(j,{mode:(e=>{switch(e){case a.FaceAuthMethod.STANDARD_AUTHEN:return a.Mode.PASSIVE;case a.FaceAuthMethod.ADVANCED_AUTHEN_ACTIVE:return a.Mode.ACTIVE;case a.FaceAuthMethod.EDGE_AUTHEN:return a.Mode.FLASH_EDGE;case a.FaceAuthMethod.ADVANCED_AUTHEN_FLASH:return a.Mode.FLASH_ADVANCED;case a.FaceAuthMethod.LIGHT_AUTHEN:return a.Mode.PASSIVE;default:return e}})(g),cameraScale:M,offsetFaceY:D,frontalMinSize:w,captureFrameSettings:y,logCredentials:I,onLivenessDetectionDone:en,outputEncryptionSettings:E,onFramesCaptured:F,onError:C,onClose:S,onReset:b,clientSettings:T,customTheme:N,extraConfig:L,customComponent:V,apiCheck:t,apiCredentials:m,serviceSettings:G,flowId:x,customTexts:H}),l.jsx(O,{loading:P})]})}w.propTypes={apiCheck:i.bool,mode:i.string,authMethod:i.string,authType:i.string,onDone:i.func,onError:i.func,onClose:i.func,outputEncryptionSettings:i.shape({}),captureFrameSettings:i.shape({enable:i.bool,framesIntervalTime:i.number,framesBatchLength:i.number}),cameraScale:i.number,offsetFaceY:i.number,frontalMinSize:i.number,apiCredentials:i.shape({accessKey:i.string,secretKey:i.string,apiUrl:i.string}),logCredentials:i.shape({}),customTheme:i.shape({}),serviceSettings:i.shape({}),flowId:i.string,clientSettings:i.shape({}),livenessDetectionComponent:i.elementType,customComponent:i.shape({FaceAuthenticationLoading:i.elementType}),extraConfig:i.shape({}),onReset:i.func,onFramesCaptured:i.func,customTexts:i.shape({})},w.defaultProps={apiCheck:!1,mode:a.FaceAuthenticationMode.REGISTRATION,authMethod:a.FaceAuthMethod.EDGE_AUTHEN,authType:"transfer",onDone:()=>{},onError:()=>{},onClose:()=>{},outputEncryptionSettings:null,captureFrameSettings:{enable:!0,framesIntervalTime:180,framesBatchLength:15},cameraScale:1,offsetFaceY:0,frontalMinSize:null,apiCredentials:{accessKey:"",secretKey:"",apiUrl:""},logCredentials:null,customTheme:null,serviceSettings:{enableUploadFrames:!0,enableUploadImages:!0,enableRegisterFace:!0,enableAuthenticateFace:!0},flowId:"face_authen",clientSettings:null,livenessDetectionComponent:g,customComponent:{FaceAuthenticationLoading:o},extraConfig:null,onReset:()=>{},onFramesCaptured:()=>{},customTexts:{}};var N=(e=w,t=function(t){let{customTexts:n}=t;return l.jsx(h,{customTexts:n,children:l.jsx(e,{...t})})},function(e){let{apiCheck:n,apiCredentials:a,serviceSettings:s,flowId:r,clientSettings:i}=e,o=n&&(s?.enableGetClientSettings??!0);return l.jsx(m,{enableGetClientSettings:o,clientSettings:i,apiCredentials:a,flowId:r,children:l.jsx(t,{...e})})});function j(e){return l.jsx(N,{...e})}j.propTypes={logCredentials:i.shape({}),clientSettings:i.shape({})},j.defaultProps={logCredentials:null,clientSettings:null};export{j as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as e,r as t,m as r,p as a,q as i,t as n,v as l,w as s,x as d,j as o,y as u,P as c}from"./chunk-5d7eeacb.js";import{g as p,d as g,c as f}from"./chunk-259479f1.js";import{W as m}from"./chunk-080d4642.js";import"./chunk-5c360a9c.js";let{IDCardSide:y,Errors:I}=e;async function b({image:e,cardType:t,cardSide:r,apiClient:a,outputEncryptionSettings:i}){let n={label:`id_card.${t}.${r}`};if(i&&i.key){let t=new File([e.encrypted.hex],`${Date.now()}.jpg`,{type:"image/jpeg"});return a.uploadImage({file:t,...n},{"X-TV-Key":i.key})}let l=new File([e.blob],`${Date.now()}.jpg`,{type:"image/jpeg"});return a.uploadImage({file:l,...n})}let S={data:{image_id:null}};async function _({image:e,apiClient:t,rawString:r,results:a,outputEncryptionSettings:i}){if(!e||!e.blob||!r)return Promise.resolve(S);let n={raw:r};a&&a.length>1&&(n=a.reduce((e,t,r)=>(e[0===r?"raw":`raw${r+1}`]=t,e),{}));let l={label:"qr_code",metadata:JSON.stringify(n)};if(i&&i.key){let r=new Blob([e.encrypted.hex]);return t.uploadImage({file:r,...l},{"X-TV-Key":i.key})}return t.uploadImage({file:e.blob,...l})}let C={data:{file_id:null}};async function h({video:e,apiClient:t,outputEncryptionSettings:r}){if(!e||!e.blob)return Promise.resolve(C);let a={label:"video"};if(r&&r.key){let i=new Blob([e.encrypted.hex]);return t.uploadFile({file:i,...a},{"X-TV-Key":r.key})}return t.uploadFile({file:e.blob,...a})}async function v({imageId:e,cardType:t,apiClient:r}){return r.requestVerifyIDCard({card_type:t,image1:{id:e}})}async function D({apiClient:e,cardType:t,frontCardId:r,isCapturingFrontSide:a,backCardId:i,recordedVideos:n=[],qrImageId:l,previousCapturingVideoId:s,previousFullVideoId:d,latestCapturingVideoId:o,latestFullVideoId:u}){let c=n.filter(e=>null!==e.id),p=n.filter(e=>null===e.id&&e.frames.length>0),g=await Promise.all(p.map(t=>e.fileService.request({frames:t.frames}))),f={card_type:t,image:{id:r},image2:a?void 0:{id:i},videos:[...[s,d,o,u].filter(e=>null!=e).map(e=>({id:e})),...c.map(e=>({id:e.id})),...g.map(e=>({id:e.data.file_id}))]};return l&&(f.qr1_images=[{id:l}]),e.detectIDTampering(f)}async function w({cardType:e,apiClient:t,cardImageId:r,qrImageId:a}){let i={card_type:e,image1:{id:r}};return a&&(i.qr1_images=[{id:a}]),t.readIDCard(i)}async function k({image:e,frontCardId:t,qrImageId:r,onError:a,recordedVideos:i,apiClient:n,cardType:l,cardSide:s,qrScannedResult:d,outputEncryptionSettings:o,enabledServices:u,fullVideo:c,capturingVideo:p,previousCapturingVideoId:g,previousFullVideoId:f}){let m=[b({image:e,cardType:l,cardSide:s,apiClient:n,outputEncryptionSettings:o})];m.push(_({image:d?.image,apiClient:n,rawString:d?.result,results:d?.results,outputEncryptionSettings:o})),m.push(h({video:c,apiClient:n,outputEncryptionSettings:o}),h({video:p,apiClient:n,outputEncryptionSettings:o}));let[S,C,k,E]=await Promise.all(m);if(S.errors)return void a({...I.upload_error,details:S.errors});let V=S.data.image_id,j=C?.data?.image_id||r,R={data:null};if(u?.enableVerifySanityIDCard){let e=await v({imageId:V,cardType:l,apiClient:n});if(e.errors)return void a({...I.sanity_check_error,details:e.errors});R.data=e.data}let B={data:null};if(u?.enableReadIDCardInfo){let e=await w({cardType:l,apiClient:n,cardImageId:V,qrImageId:j});if(e.errors)return void a({...I.read_id_card_error,details:e.errors});B.data=e.data}let F=k?.data?.file_id||null,T=E?.data?.file_id||null,q={data:null};if(u?.enableDetectIDCardTampering){let e,r;if(s===y.BACK&&!t)return void a(I.missing_front_id_card);let d=s===y.FRONT;d?e=V:(e=t,r=V);let o=await D({apiClient:n,cardType:l,frontCardId:e,isCapturingFrontSide:d,backCardId:r,recordedVideos:i,qrImageId:j,previousCapturingVideoId:g,previousFullVideoId:f,latestCapturingVideoId:T,latestFullVideoId:F});if(o.errors)return void a({...I.detect_id_tampering_error,details:o.errors});q.data=o.data}return{sanityResult:R.data,tamperingInfo:q.data,cardInfo:B.data,cardImageId:V,qrImageId:j,mp4VideoIds:{full:F,capturing:T}}}let{Errors:E}=e,V=({readIDCardUIOnlyComponent:c,...f})=>{let{onError:y,onStepDone:I,apiCredentials:b,logCredentials:S,outputEncryptionSettings:_,serviceSettings:C,flowId:h,clientSettings:v,...D}=f,[w,V]=t.useState(v),[j,R]=t.useState(!1),{apiClient:B}=r.useApiClient({apiCredentials:b,logCredentials:S}),F=t.useRef(""),T=t.useRef(""),q=t.useRef(null),K=t.useRef(null),U=a.getEnabledServices(C,w),{billingSettings:x,enableBilling:O}=i.useSDKSettings(),P=n.buildBillingInput(f),A=l.getWebSetting(w,"data.settings.sdk_settings.billing_settings.billing_config"),{submitBilling:W}=s({enable:O,onError:y,billingSettings:x??{json:A??{}},billingUrl:l.getWebSetting(w,"data.settings.sdk_settings.billing_settings.url")}),$=t.useCallback(t=>{if(e.ErrorsWithoutBilling.includes(t.code))return void y(t);let r={error:t,sdkStatus:e.BillingStatus.fail};W({service:p(D.steps),input:P,output:r}),y&&y(t)},[W,D.steps,P,y]),G=t.useCallback((t,r)=>{if(r){let r={sdkStatus:e.BillingStatus.success,result:n.buildBillingOutput(t)},a={service:p(D.steps),input:P,output:r};if(Array.isArray(D.steps)&&1===D.steps.length&&D.steps[0].scannerType===g.QR_CODE){let{qrScannedResult:r={}}=t,i=r.result;if(i){let e=i.split("|")[0];a.id_num=d.SHA256(e),a.full_hash=d.SHA256(i)}else a.output={...a.output,sdkStatus:e.BillingStatus.cancel}}W(a)}I&&I(t)},[I,D.steps,P,W]);t.useEffect(()=>{async function e(){try{let e=await B.clientSettings({flow_id:h});V(e)}catch(e){console.error("Error fetching client settings:",e)}finally{R(!0)}}U.enableGetClientSettings&&e()},[B,U.enableGetClientSettings,h]);let N=t.useCallback(async(t,{shouldBilling:r})=>{let{cardType:a,cardSide:i,recordedVideos:n,qrScannedResult:l,image:s,fullVideo:d,capturingVideo:o}=t;try{if(!U.enableUploadImages||!s.blob)return void G(t,r);let u=null;(u=await k({image:s,cardSide:i,frontCardId:F.current,qrImageId:T.current,onError:$,apiClient:B,cardType:a,recordedVideos:n,qrScannedResult:l,outputEncryptionSettings:_,enabledServices:U,fullVideo:d,capturingVideo:o,previousCapturingVideoId:K.current,previousFullVideoId:q.current}))&&(i===e.IDCardSide.FRONT&&(F.current=u.cardImageId),K.current=u?.mp4VideoIds?.capturing,q.current=u?.mp4VideoIds?.full,T.current=u.qrImageId,G({...t,apiResult:u},r))}catch(e){$({...E.api_call_error,details:e})}},[B,U,$,G,_]);return U.enableGetClientSettings&&!j?null:o.jsx(u.LicenseProvider,{clientSettings:w,onError:y,children:o.jsx(m,{isWrappedBy:"id_with_api_call",children:o.jsx(c,{logCredentials:S,onError:y,onStepDone:N,outputEncryptionSettings:_,...D,clientSettings:w})})})};V.propTypes={onError:c.func,onStepDone:c.func,apiCredentials:c.shape({accessKey:c.string,secretKey:c.string,apiUrl:c.string}),logCredentials:c.shape({}),outputEncryptionSettings:c.shape({}),readIDCardUIOnlyComponent:c.func,serviceSettings:c.shape({}),flowId:c.string,clientSettings:c.shape({})},V.defaultProps={onError:()=>{},onStepDone:()=>{},apiCredentials:{accessKey:"",secretKey:"",apiUrl:""},logCredentials:{enable:!1},outputEncryptionSettings:{key:""},readIDCardUIOnlyComponent:f,serviceSettings:{enableUploadFrames:!0,enableUploadImages:!0,enableVerifySanityPortrait:!0,enableVerifySanityIDCard:!0,enableVerifyFaceLiveness:!0,enableDetectIDCardTampering:!0,enableReadIDCardInfo:!0},flowId:"",clientSettings:null};export{V as default};
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import{l as e,B as t,d as i,g as o,a as n,b as r,A as s,o as a,c as l,h as d,s as c,j as u,P as p,r as h,n as g,u as f,e as x,f as C,i as m,C as b,S as S,k as w}from"./chunk-5d7eeacb.js";import{A as j,F as $}from"./chunk-ffa40a6f.js";import"./chunk-6e5fa179.js";import{C as y}from"./chunk-3ba3f5be.js";import{u as k,a as v,T as _,b as I,P as A,S as E,U as F,R as T,Q as D,C as M,G as R,c as z}from"./chunk-259479f1.js";import{u as O,a as L,t as B}from"./chunk-080d4642.js";import{W as U,C as P,P as V,O as H}from"./chunk-5c360a9c.js";import"./chunk-2d04cdda.js";import"./chunk-1520b763.js";import"./chunk-9950b40e.js";import"./chunk-7daa3b76.js";import"./chunk-8a5beb79.js";import"./chunk-23f22cf0.js";import"./chunk-630b6747.js";import"./chunk-50924bca.js";import"./chunk-e3a1c9ae.js";let{blink:W,slide:Z}=j,N=e`
|
|
2
|
+
z-index: ${t+20};
|
|
3
|
+
color: #ffffff;
|
|
4
|
+
`,Q=i.div`
|
|
5
|
+
${N}
|
|
6
|
+
`,Y=e`
|
|
7
|
+
${N}
|
|
8
|
+
${({top:t})=>t&&e`
|
|
9
|
+
top: ${t}px;
|
|
10
|
+
`}
|
|
11
|
+
${({bottom:t})=>t&&e`
|
|
12
|
+
bottom: ${t}px;
|
|
13
|
+
`}
|
|
14
|
+
${({centerY:t})=>t&&e`
|
|
15
|
+
top: 50%;
|
|
16
|
+
transform: translateY(-50%);
|
|
17
|
+
`}
|
|
18
|
+
font-size: ${o("Selfie.error.fontSize")};
|
|
19
|
+
font-weight: ${o("Selfie.error.fontWeight")};
|
|
20
|
+
background: ${o("Selfie.error.backgroundColor")};
|
|
21
|
+
color: ${o("Selfie.error.color")};
|
|
22
|
+
padding: ${o("Selfie.error.padding")};
|
|
23
|
+
border-radius: ${o("Selfie.error.borderRadius")};
|
|
24
|
+
position: absolute;
|
|
25
|
+
white-space: pre-wrap;
|
|
26
|
+
text-align: center;
|
|
27
|
+
max-width: 80%;
|
|
28
|
+
`;i($)`
|
|
29
|
+
${Y}
|
|
30
|
+
`,i(Q)`
|
|
31
|
+
${({top:t})=>t&&e`
|
|
32
|
+
top: ${t}px;
|
|
33
|
+
`}
|
|
34
|
+
font-size: ${o("Selfie.countdown.fontSize")};
|
|
35
|
+
font-weight: ${o("Selfie.countdown.fontWeight")};
|
|
36
|
+
background: ${o("Selfie.countdown.backgroundColor")};
|
|
37
|
+
color: ${o("Selfie.countdown.color")};
|
|
38
|
+
padding: ${o("Selfie.countdown.padding")};
|
|
39
|
+
border-radius: ${o("Selfie.countdown.borderRadius")};
|
|
40
|
+
position: absolute;
|
|
41
|
+
left: 50%;
|
|
42
|
+
transform: translate(-50%, 0);
|
|
43
|
+
white-space: nowrap;
|
|
44
|
+
`,i(Q)`
|
|
45
|
+
position: absolute;
|
|
46
|
+
${({top:t})=>t&&e`
|
|
47
|
+
top: ${t}px;
|
|
48
|
+
`}
|
|
49
|
+
${({bottom:t})=>t&&e`
|
|
50
|
+
bottom: ${t}px;
|
|
51
|
+
`}
|
|
52
|
+
color: ${o("Selfie.Active.instruction.color")};
|
|
53
|
+
font-size: ${o("Selfie.Active.instruction.fontSize")};
|
|
54
|
+
font-weight: ${o("Selfie.Active.instruction.fontWeight")};
|
|
55
|
+
text-shadow: ${o("Selfie.Active.instruction.textShadow")};
|
|
56
|
+
background-color: ${o("Selfie.Active.instruction.backgroundColor")};
|
|
57
|
+
border: ${o("Selfie.Active.instruction.border")};
|
|
58
|
+
border-radius: ${o("Selfie.Active.instruction.borderRadius")};
|
|
59
|
+
`,i.div`
|
|
60
|
+
height: ${()=>n.isMobile?"50px":"70px"};
|
|
61
|
+
position: absolute;
|
|
62
|
+
${({top:t})=>t&&e`
|
|
63
|
+
top: ${t}px;
|
|
64
|
+
`}
|
|
65
|
+
${({bottom:t})=>t&&e`
|
|
66
|
+
bottom: ${t}px;
|
|
67
|
+
`}
|
|
68
|
+
width: 100%;
|
|
69
|
+
display: flex;
|
|
70
|
+
justify-content: center;
|
|
71
|
+
align-items: center;
|
|
72
|
+
z-index: ${t+20};
|
|
73
|
+
`,i.div`
|
|
74
|
+
width: ${o("Selfie.Active.imageHolder.width")};
|
|
75
|
+
height: ${o("Selfie.Active.imageHolder.height")};
|
|
76
|
+
border-radius: ${o("Selfie.Active.imageHolder.borderRadius")};
|
|
77
|
+
font-size: ${o("Selfie.Active.imageHolder.fontSize")};
|
|
78
|
+
color: ${o("Selfie.Active.imageHolder.color")};
|
|
79
|
+
font-weight: ${o("Selfie.Active.imageHolder.fontWeight")};
|
|
80
|
+
|
|
81
|
+
${({theme:e})=>"v2"===r(e,"themeVersion")?"border: unset;":`border: ${o("Selfie.Active.imageHolder.border")({theme:e})};`}
|
|
82
|
+
|
|
83
|
+
display: flex;
|
|
84
|
+
justify-content: center;
|
|
85
|
+
align-items: center;
|
|
86
|
+
|
|
87
|
+
& + & {
|
|
88
|
+
margin-left: 10px;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
${t=>!t.active&&e`
|
|
92
|
+
opacity: 0.6;
|
|
93
|
+
`}
|
|
94
|
+
|
|
95
|
+
img {
|
|
96
|
+
width: 100%;
|
|
97
|
+
margin: 0;
|
|
98
|
+
border-radius: ${o("Selfie.Active.imageHolder.borderRadius")};
|
|
99
|
+
}
|
|
100
|
+
img.image_preview {
|
|
101
|
+
border: ${o("Selfie.Active.imageHolder.border")};
|
|
102
|
+
}
|
|
103
|
+
`,i.div`
|
|
104
|
+
color: #ffffff;
|
|
105
|
+
height: 70px;
|
|
106
|
+
position: absolute;
|
|
107
|
+
bottom: 0;
|
|
108
|
+
width: 100%;
|
|
109
|
+
display: flex;
|
|
110
|
+
justify-content: center;
|
|
111
|
+
align-items: center;
|
|
112
|
+
z-index: ${t+20};
|
|
113
|
+
`,i.div`
|
|
114
|
+
${({disabled:t})=>t?e`
|
|
115
|
+
pointer-events: none;
|
|
116
|
+
`:e`
|
|
117
|
+
cursor: pointer;
|
|
118
|
+
`}
|
|
119
|
+
text-align: center;
|
|
120
|
+
|
|
121
|
+
img {
|
|
122
|
+
width: ${o("Selfie.captureIcon.width")};
|
|
123
|
+
}
|
|
124
|
+
`,i.div`
|
|
125
|
+
position: absolute;
|
|
126
|
+
width: 100%;
|
|
127
|
+
top: 0;
|
|
128
|
+
bottom: 0;
|
|
129
|
+
display: flex;
|
|
130
|
+
justify-content: center;
|
|
131
|
+
align-items: center;
|
|
132
|
+
color: #ffffff;
|
|
133
|
+
font-size: 140px;
|
|
134
|
+
opacity: 0.6;
|
|
135
|
+
`,i.div`
|
|
136
|
+
position: absolute;
|
|
137
|
+
width: 100%;
|
|
138
|
+
top: 0;
|
|
139
|
+
bottom: 0;
|
|
140
|
+
display: flex;
|
|
141
|
+
flex-direction: column;
|
|
142
|
+
justify-content: center;
|
|
143
|
+
align-items: center;
|
|
144
|
+
${Z.default};
|
|
145
|
+
${W.default};
|
|
146
|
+
`;var q=Object.freeze({__proto__:null,AutoCapturingIcon:s,Camera:y});function G({size:e=32}){return u.jsxs("svg",{width:e,height:e,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.jsx("mask",{id:"abb_ic_checked_mask",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:28,height:28,children:u.jsx("path",{d:"M15.9993 2.66602C8.65268 2.66602 2.66602 8.65268 2.66602 15.9993C2.66602 23.346 8.65268 29.3327 15.9993 29.3327C23.346 29.3327 29.3327 23.346 29.3327 15.9993C29.3327 8.65268 23.346 2.66602 15.9993 2.66602ZM22.3727 12.9327L14.8127 20.4927C14.626 20.6793 14.3727 20.786 14.106 20.786C13.8393 20.786 13.586 20.6793 13.3993 20.4927L9.62601 16.7193C9.23935 16.3327 9.23935 15.6927 9.62601 15.306C10.0127 14.9193 10.6527 14.9193 11.0393 15.306L14.106 18.3727L20.9593 11.5193C21.346 11.1327 21.986 11.1327 22.3727 11.5193C22.7593 11.906 22.7593 12.5327 22.3727 12.9327Z",fill:"black"})}),u.jsx("g",{mask:"url(#abb_ic_checked_mask)",children:u.jsx("rect",{width:32,height:32,fill:"#00BC3C"})})]})}function J({size:e=32}){return u.jsxs("svg",{width:e,height:e,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.jsx("mask",{id:"abb_ic_warning_mask",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:28,height:27,children:u.jsx("path",{d:"M29.0133 21.226L20.48 5.86602C19.3333 3.79935 17.7466 2.66602 16 2.66602C14.2533 2.66602 12.6666 3.79935 11.52 5.86602L2.98664 21.226C1.90664 23.186 1.78664 25.066 2.6533 26.546C3.51997 28.026 5.22664 28.8393 7.46664 28.8393H24.5333C26.7733 28.8393 28.48 28.026 29.3466 26.546C30.2133 25.066 30.0933 23.1727 29.0133 21.226ZM15 11.9993C15 11.4527 15.4533 10.9993 16 10.9993C16.5466 10.9993 17 11.4527 17 11.9993V18.666C17 19.2127 16.5466 19.666 16 19.666C15.4533 19.666 15 19.2127 15 18.666V11.9993ZM16.9466 23.6127C16.88 23.666 16.8133 23.7193 16.7466 23.7727C16.6666 23.826 16.5866 23.866 16.5066 23.8927C16.4266 23.9327 16.3466 23.9593 16.2533 23.9727C16.1733 23.986 16.08 23.9993 16 23.9993C15.92 23.9993 15.8266 23.986 15.7333 23.9727C15.6533 23.9593 15.5733 23.9327 15.4933 23.8927C15.4133 23.866 15.3333 23.826 15.2533 23.7727C15.1866 23.7193 15.12 23.666 15.0533 23.6127C14.8133 23.3593 14.6666 23.0127 14.6666 22.666C14.6666 22.3193 14.8133 21.9727 15.0533 21.7194C15.12 21.666 15.1866 21.6127 15.2533 21.5593C15.3333 21.506 15.4133 21.466 15.4933 21.4394C15.5733 21.3993 15.6533 21.3727 15.7333 21.3594C15.9066 21.3193 16.0933 21.3193 16.2533 21.3594C16.3466 21.3727 16.4266 21.3993 16.5066 21.4394C16.5866 21.466 16.6666 21.506 16.7466 21.5593C16.8133 21.6127 16.88 21.666 16.9466 21.7194C17.1866 21.9727 17.3333 22.3193 17.3333 22.666C17.3333 23.0127 17.1866 23.3593 16.9466 23.6127Z",fill:"black"})}),u.jsx("g",{mask:"url(#abb_ic_warning_mask)",children:u.jsx("rect",{width:32,height:32,fill:"#F58220"})})]})}function K({size:e=32}){return u.jsxs("svg",{width:e,height:e,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.jsx("mask",{id:"abb_ic_error_mask",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:28,height:28,children:u.jsx("path",{d:"M15.9993 2.66602C8.65268 2.66602 2.66602 8.65268 2.66602 15.9993C2.66602 23.346 8.65268 29.3327 15.9993 29.3327C23.346 29.3327 29.3327 23.346 29.3327 15.9993C29.3327 8.65268 23.346 2.66602 15.9993 2.66602ZM20.4793 19.066C20.866 19.4527 20.866 20.0927 20.4793 20.4793C20.2793 20.6793 20.026 20.7727 19.7727 20.7727C19.5193 20.7727 19.266 20.6793 19.066 20.4793L15.9993 17.4127L12.9327 20.4793C12.7327 20.6793 12.4793 20.7727 12.226 20.7727C11.9727 20.7727 11.7193 20.6793 11.5193 20.4793C11.1327 20.0927 11.1327 19.4527 11.5193 19.066L14.586 15.9993L11.5193 12.9327C11.1327 12.546 11.1327 11.906 11.5193 11.5193C11.906 11.1327 12.546 11.1327 12.9327 11.5193L15.9993 14.586L19.066 11.5193C19.4527 11.1327 20.0927 11.1327 20.4793 11.5193C20.866 11.906 20.866 12.546 20.4793 12.9327L17.4127 15.9993L20.4793 19.066Z",fill:"black"})}),u.jsx("g",{mask:"url(#abb_ic_error_mask)",children:u.jsx("rect",{width:32,height:32,fill:"#E60A32"})})]})}a(async function e(e,t){let{tfScriptUrls:i,blazefaceModelUrl:o,closeEyesModelUrl:n,opencvUrl:r,idCardModelUrls:s}=e;try{l.loadTensorFlow(i).then(()=>{l.loadBlazefaceModel({modelUrl:o})}),await Promise.all([l.preloadResource({modelUrl:n}),d.init({url:r}),...Object.values(s).map(e=>l.preloadResource({modelUrl:e}))])}catch(e){t({...c.Errors.unable_to_load_model,details:e})}}),i.div`
|
|
147
|
+
width: 100%;
|
|
148
|
+
padding-bottom: ${e=>1/e.ratio*100}%;
|
|
149
|
+
position: relative;
|
|
150
|
+
`,i.div`
|
|
151
|
+
position: absolute;
|
|
152
|
+
top: ${e=>e.padding};
|
|
153
|
+
left: ${e=>e.padding};
|
|
154
|
+
right: ${e=>e.padding};
|
|
155
|
+
bottom: ${e=>e.padding};
|
|
156
|
+
`;let{BUTTON_MARGIN_BOTTOM:X,BUTTON_SIZE:ee,CaptureButton:et,DebugInfo:ei,Description:eo,LoadingIcon:en,ToggleContainer:er,WorkingCanvasFrame:es}=T,{AutoCapturingIcon:ea}=q,el={position:"absolute",opacity:0,pointerEvents:"none",width:0,height:0,overflow:"hidden"},ed={holdStill:{bg:"#FFFFFF",text:"#000000"},capturingDone:{bg:"#E5F8EB",text:"#00BC3C"},noCard:{bg:"#FCE6EA",text:"#E60A32"},otherError:{bg:"#FEF2E8",text:"#F58220"}},ec=["id_detector_front_no_cards","id_detector_back_no_cards"],eu=i.div`
|
|
157
|
+
position: absolute;
|
|
158
|
+
top: ${e=>e.$top};
|
|
159
|
+
z-index: ${t+20};
|
|
160
|
+
display: flex;
|
|
161
|
+
align-items: center;
|
|
162
|
+
gap: 8px;
|
|
163
|
+
padding: 12px 16px;
|
|
164
|
+
border-radius: 12px;
|
|
165
|
+
max-width: calc(100% - 40px);
|
|
166
|
+
box-sizing: border-box;
|
|
167
|
+
text-align: center;
|
|
168
|
+
font-size: 16px;
|
|
169
|
+
font-weight: 600;
|
|
170
|
+
line-height: 1.4;
|
|
171
|
+
background: ${e=>ed[e.$variant].bg};
|
|
172
|
+
color: ${e=>ed[e.$variant].text};
|
|
173
|
+
`,ep=i.div`
|
|
174
|
+
position: absolute;
|
|
175
|
+
bottom: ${24}px;
|
|
176
|
+
left: 0;
|
|
177
|
+
right: 0;
|
|
178
|
+
text-align: center;
|
|
179
|
+
color: #ffffff;
|
|
180
|
+
z-index: ${t+20};
|
|
181
|
+
`,eh=i(et)`
|
|
182
|
+
${!n.isMobile&&"bottom: 60px;"}
|
|
183
|
+
`,eg=h.forwardRef((e,t)=>{let{description:i,usePortraitMask:r,windowAndVideoInfo:s,refVideo:a,frontSide:l,allowedCardTypes:d,settings:c,onCaptureDone:p,onUISpacingChange:m,outputEncryptionSettings:b,isShowingSpinner:S,uploadFromDevice:w,uploadFlowAPI:j}=e,$=g(),[y,T]=h.useState({}),{yMessage:D,yButtonRow:M,yToggleButton:R}=y,z=f("IDCapturing.captureIcon.src","ic_camera.svg"),L=f("IDCapturing.captureIcon.disabled.src","ic_camera.svg"),B=f("IDCapturing.loadingIcon.src","ic_loading.gif"),[H,W]=h.useState(""),Z=x(),[N,Q]=h.useState(null),[Y,q]=h.useState(""),[et,ed]=h.useState(""),[eg,ef]=h.useState(null),{showPopup:ex,popupShown:eC,popupType:em}=k(),eb=O(),[eS,ew]=h.useState(!1),ej=h.useRef(()=>{}),e$=h.useCallback(e=>{if(null===e)q(""),ed("");else{let t=e?.code;ed(t??""),q(Z(t,{side:l?Z("front"):Z("back")}))}},[Z,l]),ey=h.useCallback(()=>{Q(""),ej.current()},[]),ek=h.useCallback((...e)=>{Q(""),p(...e)},[p]),{warmupDone:ev,isPostProcessing:e_,isAutoCapturing:eI,isProcessing:eA,takePictureManually:eE,restartSession:eF,resetIsProcessingImageBlobTaken:eT,isAutoCaptureModeOn:eD,onToggleAutoCaptureMode:eM,autoCaptureDuration:eR,pauseScan:ez,resumeScan:eO,setUploadInProgress:eL}=v({shouldStart:!0,refVideo:a,cropArea:eg,settings:c,onModelErrorChange:e$,frontSide:l,allowedCardTypes:d,onDebugInfoChange:W,onSessionTimeout:ey,onCaptureDone:ek,onAboutToTimeout:h.useCallback(({curTimeLeft:e})=>{Q(Z("remaining_time",{x:e}))},[Z]),outputEncryptionSettings:b}),eB=h.useMemo(()=>({pauseScan:ez,resumeScan:eO,setUploadInProgress:eL,restartSession:eF}),[ez,eO,eL,eF]),eU=h.useCallback(()=>{ex({popupType:null}),eT()},[ex,eT]),eP=h.useCallback(async()=>{ew(!1),eU(),await eF()},[eU,eF]);ej.current=eP;let eV=o("IDCapturing.backgroundColor")({theme:$}),{showCaptureButtonInAuto:eH=!0,showHoldStillProgress:eW=!1,showAutoCaptureToggle:eZ}=c??{},eN=Math.ceil((eR??0)/1e3),eQ=null;eW&&eI?eQ=eS?"capturingDone":"holdStill":!eI&&et&&(eQ=ec.includes(et)?"noCard":"otherError");let eY=eg?eg.y+eg.height+44:0;h.useEffect(()=>{if(s){let e,t,i,o,a,l,d,{videoAreaWidth:c,videoAreaHeight:u,lostX:p,lostY:h,clientHeight:g}=s;r?a=.7*(l=u-165):l=Math.floor(Math.min((a=n.isMobile?c-40:Math.floor(.4*c))/1.5,g-2*h-(ee+2*X)-100)),d=h+140,o=(e=24)+30,i=eZ?d+l+20:d+l,t=d+l+135,ef({x:Math.floor((c-a)/2)+p,y:d,width:a,height:l,surroundStyle:{backgroundColor:eV}});let f={yTitle:e,yMessage:o,yButtonRow:t,yToggleButton:i};T(f),m(f)}},[$.themeVersion,s,r,m,eV,eZ]);let eq=h.useCallback(async()=>{Q(""),await eE()},[eE]);h.useImperativeHandle(t,()=>({restartSession:eP}),[eP]);let eG=eI&&e_||S||!Y;return u.jsxs(u.Fragment,{children:[!ev&&u.jsx(U,{}),eb&&u.jsx(ei,{children:JSON.stringify(H,null,2)}),eW&&!eI&&e_&&u.jsx(en,{children:u.jsx("img",{src:B,alt:"loading icon"})}),!eW&&(eI||e_)&&u.jsx(en,{children:u.jsx("img",{src:B,alt:"loading icon"})}),eg&&u.jsx(P,{x:`${eg.x}px`,y:`${eg.y}px`,width:`${eg.width}px`,height:`${eg.height}px`,surroundStyle:eg.surroundStyle,children:u.jsx(es,{width:eg.width,height:eg.height,type:eG?_.DEFAULT:_.ERROR})}),eW&&eI&&u.jsx("div",{style:el,children:u.jsx(ea,{duration:eR,onCircleAnimationEnd:()=>{ew(!0)}})}),eg&&eQ&&u.jsxs(eu,{$top:`${eY}px`,$variant:eQ,children:["capturingDone"===eQ&&u.jsx(G,{}),"noCard"===eQ&&u.jsx(K,{}),"otherError"===eQ&&u.jsx(J,{}),u.jsxs("span",{children:["holdStill"===eQ&&Z("id_capture.instruction.hold_still",{x:eN}),"capturingDone"===eQ&&Z("id_capture.instruction.capturing_done"),"noCard"===eQ&&C.getStringWithLineBreak(Z(et,{side:l?Z("front"):Z("back")})),"otherError"===eQ&&C.getStringWithLineBreak(Y)]})]}),eZ&&u.jsxs(er,{y:`${R}px`,children:[u.jsx("span",{children:Z("toggle_id_capture_mode")}),u.jsx(I,{checked:eD,disabled:eI||e_||S,onChange:eM})]}),(!eD||eH)&&u.jsx(eh,{onClick:eq,y:`${M}px`,disabled:c?.disableCaptureButtonIfAlert&&Y||eI||e_||S,children:Y?u.jsx("img",{src:L,alt:"capture button disabled"}):u.jsx("img",{src:z,alt:"capture button enabled"})}),u.jsx(eo,{y:`${D}px`,children:i}),N&&u.jsx(ep,{children:N}),u.jsx(V,{open:eC,children:em===A.SESSION_TIMEOUT&&u.jsx(E,{onOk:eP,maxSessionTime:c?.idCardSessionTime})}),u.jsx(F,{uploadFromDevice:w,uploadFlowAPI:j,scanControl:eB,isCaptureInFlight:eA,shouldShowSpinner:S,yButtonRow:M,bottomOffset:X})]})});eg.propTypes={usePortraitMask:p.bool,description:p.string,windowAndVideoInfo:p.shape({}),refVideo:p.shape({}),frontSide:p.bool,allowedCardTypes:p.arrayOf(p.string),settings:p.shape({}),onCaptureDone:p.func,onUISpacingChange:p.func,outputEncryptionSettings:p.shape({}),isShowingSpinner:p.bool,uploadFromDevice:p.shape({enable:p.bool,enableConfirmPopup:p.bool}),uploadFlowAPI:p.shape({})},eg.defaultProps={usePortraitMask:!1,description:"",windowAndVideoInfo:{},refVideo:{},frontSide:!0,allowedCardTypes:[],settings:{},onCaptureDone:()=>{},onUISpacingChange:()=>{},outputEncryptionSettings:null,isShowingSpinner:!1,uploadFromDevice:void 0,uploadFlowAPI:void 0};let{animationDuration:ef,IconImage:ex,LoadingIcon:eC,RotateAnimationWrapper:em,SplashAnimation:eb,Title:eS,TitleWrapper:ew,Wrapper:ej}=T;function e$(e){let{settings:t,outputEncryptionSettings:i,defaultCameraId:o,globalStyle:n,styledComponent:s,frontCamera:a,flipVideoHorizontal:l,scannerTypeCons:d,allowedCardTypes:c,uploadFromDevice:p,...x}=e,{numberOfCaptures:C,stepNumber:j,frontSide:$,titleIcon:y,title:k,description:v,scannerType:_,usePortraitMask:I,shouldShowSpinner:E,handleQRCaptureDone:F,handleIDCardCaptureDone:T,handleRestartSession:R,refIDCardReader:z,handleClickConfirm:O,popupType:U,popupShown:P,popupProps:W,uploadFlowAPI:Z}=x,N=g(),Q=h.useRef(null),[Y,q]=h.useState(null),[G,J]=h.useState(!1),K=f("IDCapturing.loadingIcon.src","ic_loading.gif"),{onErrorCallback:X,onCloseCallback:ee}=L(),[et,ei]=h.useState({}),{yTitle:eo}=et,en=h.useCallback(e=>{q(e),J(!0)},[]);h.useEffect(()=>{J(!1)},[a]);let er=f("IDCapturing.cardIcon.src",y),{CloseCameraButton:es}=s,ea=h.useCallback((e,t)=>{e!==t?Q.current?.pause():Q.current?.play()},[Q]);return u.jsx(H,{onOrientationChange:ea,children:u.jsxs(m,{theme:B,children:[u.jsxs(ej,{children:[u.jsxs(b,{frontCamera:a,onVideoPlayed:en,onClose:ee,flipHorizontal:l??a,ref:Q,onError:X,defaultCameraId:o,closeButton:es||null,videoSettings:t?.imageSettings.videoSettings,children:[G&&u.jsxs(u.Fragment,{children:[_===d.ID_CARD&&u.jsx(eg,{ref:z,windowAndVideoInfo:Y,refVideo:Q,settings:t,onCaptureDone:T,onUISpacingChange:ei,frontSide:$,allowedCardTypes:c,description:v,usePortraitMask:I,outputEncryptionSettings:i,isShowingSpinner:E,uploadFromDevice:p,uploadFlowAPI:Z},j),_===d.QR_CODE&&u.jsx(D,{refVideo:Q,windowAndVideoInfo:Y,settings:t,onCaptureDone:F,onUISpacingChange:ei,outputEncryptionSettings:i},j)]}),u.jsx(eb,{keyForTransition:C}),u.jsx(em,{y:`${eo}px`,children:u.jsx(S,{children:u.jsx(w,{timeout:{enter:ef,exit:ef},classNames:"flipY",unmountOnExit:!0,children:u.jsxs(ew,{children:[y&&"v2"!==r(N,"themeVersion")&&u.jsx(ex,{src:er,alt:""}),u.jsx(eS,{className:"title",$isQr:_===d.QR_CODE,$isFront:$,children:k})]})},k)})}),E&&u.jsx(eC,{children:u.jsx("img",{src:K,alt:""})})]},a),u.jsx(V,{open:P,children:U===A.CONFIRM&&u.jsx(M,{...W,onConfirm:O,onTryAgain:R,frontSide:$})})]}),u.jsx(n,{})]})})}let ey={allowedCardTypes:p.arrayOf(p.string),settings:p.shape({}),onClose:p.func,onError:p.func,outputEncryptionSettings:p.shape({}),defaultCameraId:p.string,globalStyle:p.shape({}),styledComponent:p.shape({CloseCameraButton:p.node}),frontCamera:p.bool,flipVideoHorizontal:p.bool,scannerTypeCons:p.shape({}).isRequired,customTexts:p.shape({})};e$.propTypes=ey,e$.defaultProps={allowedCardTypes:[],settings:null,onClose:()=>{},onError:()=>{},outputEncryptionSettings:null,defaultCameraId:void 0,globalStyle:R,styledComponent:{CloseCameraButton:null},frontCamera:!1,customTexts:null,flipVideoHorizontal:null};let ek=e=>u.jsx(z,{...e,uiOnlyComponent:e$});export{ek as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,K as r,u as s,r as a,g as n,q as t,s as o,j as i,C as c,aB as l,b as u,P as p,a as d}from"./chunk-5d7eeacb.js";import{p as m,g as f,S as g,a as h,O as C,C as y,E as j,b as D,B as F,c as x,L as S}from"./chunk-ffa40a6f.js";import{u as b,C as I}from"./chunk-3ba3f5be.js";import{M as T,O as E,W as k,C as R}from"./chunk-5c360a9c.js";import{D as L}from"./chunk-1520b763.js";import{a as v}from"./chunk-080d4642.js";import"./chunk-50924bca.js";import"./chunk-2d04cdda.js";let P=d.isMobile?{width:{ideal:640}}:null;function A(p){let{apiCheck:d,onLivenessDetectionDone:L,captureFrameSettings:A,onFramesCaptured:M,frontCamera:H,flipVideoHorizontal:O,customDirectionIcon:w,customStepTimeConstraints:U,onProcessing:V,customErrors:B,apiCredentials:K,outputEncryptionSettings:$,cameraScale:_,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]),ed=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:em,countdownToTakePicture:ef,cropArea:eg,curStepIndex:eh,faceDetectionError:eC,resetFlow:ey,handleTriggerPassiveMode:ej,handleVideoPlayed:eD,refVideo:eF,showCountdown:ex,steps:eS,refIsReseting:eb,videoPlayed:eI,warmupDone:eT,showCaptureButton:eE,shouldShowCountdown:ek,showLoading:eR}=b({currentOrientation:el,apiCheck:d,bgCameraMask:ee,bgCameraMaskRed:er,surroundStyle:ep,onLivenessDetectionDone:L,onError:X,cropAreaDimension:ed,customDirectionIcon:w,captureFrameSettings:A,onFramesCaptured:M,setRemainingTime:ec,customStepTimeConstraints:U,onProcessing:V,customErrors:B,apiCredentials:K,outputEncryptionSettings:$,cameraScale:_,passiveModeAuto:z,serviceSettings:W,onReset:q});a.useEffect(()=>{"string"==typeof eS[0]?.directionIcon&&Promise.all(eS.map(e=>m(e.directionIcon)))},[eS]);let{CloseCameraButton:eL}=Y,ev=f(p,Q),eP=eb.current?0:eh/eS.length*100,{lang:eA}=t.useSDKSettings(),eM=a.useRef(0),eH=a.useRef({}),eO=a.useRef(o.ErrorDuration.SHORT),ew=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,eh]),eU=a.useCallback(e=>{eu(e),em?ey():e===T.LANDSCAPE?eF.current?.pause():eF.current?.play()},[eF,ey,em]);return i.jsx(E,{onOrientationChange:eU,children:i.jsxs(c,{frontCamera:H,onVideoPlayed:eD,onClose:Z,flipHorizontal:O??H,ref:eF,videoSettings:P,onError:X,scale:_,defaultCameraId:N,closeButton:eL||i.jsx(l,{}),children:[!eT&&i.jsx(k,{}),eI?i.jsxs(i.Fragment,{children:["string"==typeof ew?i.jsx(g,{top:et-15,className:"face-detection-error",children:ew}):null,eg.current?i.jsxs(R,{x:`${eg.current.x}px`,y:`${eg.current.y}px`,width:`${eg.current.width}px`,height:`${eg.current.height}px`,surroundStyle:eg.current.surroundStyle,children:[i.jsx(h,{}),i.jsx(C,{...ev,progress:eP,showErrorRing:!!eC&&n("Selfie.progressCircle.showErrorRing")({theme:Q})}),ek?i.jsx(y,{children:ef}):null,eC&&i.jsx(j,{})]}):null,ei&&i.jsx(D,{top:eo-30,children:ei}),eE?i.jsx(F,{children:i.jsx(x,{onClick:ej,disabled:ex,children:u(Q,"Selfie.captureIcon.src")?i.jsx("img",{src:u(Q,"Selfie.captureIcon.src"),alt:""}):i.jsx(I,{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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,K as r,u as s,r as a,g as n,q as t,s as o,j as i,C as c,b as l,P as u,a as p}from"./chunk-5d7eeacb.js";import{p as d,g as m,S as f,a as g,O as h,C as C,E as y,b as D,B as j,c as F,L as S}from"./chunk-ffa40a6f.js";import{u as b,C as x}from"./chunk-3ba3f5be.js";import{M as I,O as T,W as E,C as k}from"./chunk-5c360a9c.js";import{D as R}from"./chunk-1520b763.js";import{a as L}from"./chunk-080d4642.js";import"./chunk-50924bca.js";import"./chunk-2d04cdda.js";let v=p.isMobile?{width:{ideal:640}}:null;function P(u){let{apiCheck:p,onLivenessDetectionDone:R,captureFrameSettings:P,onFramesCaptured:A,frontCamera:M,flipVideoHorizontal:O,customDirectionIcon:H,customStepTimeConstraints:V,onProcessing:w,customErrors:U,apiCredentials:K,outputEncryptionSettings:$,cameraScale:_,defaultCameraId:B,passiveModeAuto:N,offsetFaceY:z,styledComponent:G,serviceSettings:Y,onReset:W,isLoading:q}=u,J=e(),{onErrorCallback:Q,onCloseCallback:X}=L(),Z=r.useAsset("bg_camera_mask.png"),ee=r.useAsset("bg_camera_mask_red.png"),er=s("IDCapturing.loadingIcon.src","ic_loading.gif"),[es,ea]=a.useState({}),{yFaceDetectionError:en,yFaceVerificationStepsWrapper:et}=es,[eo,ei]=a.useState(""),[ec,el]=a.useState(),eu=a.useMemo(()=>({backgroundColor:n("Selfie.backgroundColor")({theme:J})}),[J]),ep=a.useCallback(({lostY:e,height:r,clientHeight:s})=>{let a=e+25,n=a+30;ea({yFaceDetectionError:a,yFaceVerificationStepsWrapper:n+r+20});let t=Math.floor(e),o=Math.floor(s-e),i=Math.floor(n);return 0!==z&&(i+z<t||i+z+r>o)?Q({code:`offsetFaceY must be in [-${i-t}, ${o-r-i}]`}):i+=z,{y:i}},[z,Q]),{shouldResetFlowOnOrientationChange:ed,countdownToTakePicture:em,cropArea:ef,curStepIndex:eg,faceDetectionError:eh,resetFlow:eC,handleTriggerPassiveMode:ey,handleVideoPlayed:eD,refVideo:ej,showCountdown:eF,steps:eS,refIsReseting:eb,videoPlayed:ex,warmupDone:eI,showCaptureButton:eT,shouldShowCountdown:eE,showLoading:ek}=b({currentOrientation:ec,apiCheck:p,bgCameraMask:Z,bgCameraMaskRed:ee,surroundStyle:eu,onLivenessDetectionDone:R,onError:Q,cropAreaDimension:ep,customDirectionIcon:H,captureFrameSettings:P,onFramesCaptured:A,setRemainingTime:ei,customStepTimeConstraints:V,onProcessing:w,customErrors:U,apiCredentials:K,outputEncryptionSettings:$,cameraScale:_,passiveModeAuto:N,serviceSettings:Y,onReset:W});a.useEffect(()=>{"string"==typeof eS[0]?.directionIcon&&Promise.all(eS.map(e=>d(e.directionIcon)))},[eS]);let{CloseCameraButton:eR}=G,eL=m(u,J),ev=eb.current?0:eg/eS.length*100,{lang:eP}=t.useSDKSettings(),eA=a.useRef(0),eM=a.useRef({}),eO=a.useRef(o.ErrorDuration.SHORT),eH=a.useMemo(()=>{let{msg:e,duration:r=o.ErrorDuration.SHORT}=eh||{},s=e?.[eP];return Date.now()-eA.current>=eO.current&&(eA.current=Date.now(),eO.current=r,eM.current=s),eM.current},[eh,eg]),eV=a.useCallback(e=>{el(e),ed?eC():e===I.LANDSCAPE?ej.current?.pause():ej.current?.play()},[ej,eC,ed]);return i.jsx(T,{onOrientationChange:eV,children:i.jsxs(c,{frontCamera:M,onVideoPlayed:eD,onClose:X,flipHorizontal:O??M,ref:ej,videoSettings:v,onError:Q,scale:_,defaultCameraId:B,closeButton:eR||null,children:[!eI&&i.jsx(E,{}),ex?i.jsxs(i.Fragment,{children:["string"==typeof eH?i.jsx(f,{top:en-15,className:"face-detection-error",children:eH}):null,ef.current?i.jsxs(k,{x:`${ef.current.x}px`,y:`${ef.current.y}px`,width:`${ef.current.width}px`,height:`${ef.current.height}px`,surroundStyle:ef.current.surroundStyle,children:[i.jsx(g,{}),i.jsx(h,{...eL,progress:ev,showErrorRing:!!eh&&n("Selfie.progressCircle.showErrorRing")({theme:J})}),eE?i.jsx(C,{children:em}):null,eh&&i.jsx(y,{})]}):null,eo&&i.jsx(D,{top:et-30,children:eo}),eT?i.jsx(j,{children:i.jsx(F,{onClick:ey,disabled:eF,children:l(J,"Selfie.captureIcon.src")?i.jsx("img",{src:l(J,"Selfie.captureIcon.src"),alt:""}):i.jsx(x,{fillColor:"rgba(193, 197, 204, 1)"})})}):null]}):null,(ek||q)&&i.jsx(S,{children:i.jsx("img",{src:er,alt:""})})]})})}P.propTypes={apiCheck:u.bool,mode:u.string,onLivenessDetectionDone:u.func,onClose:u.func,onError:u.func,onReset:u.func,captureFrameSettings:u.shape({}),onFramesCaptured:u.func,frontCamera:u.bool,isLoading:u.bool,flipVideoHorizontal:u.bool,customDirectionIcon:u.shape({}),customStepTimeConstraints:u.shape({}),onProcessing:u.func,customErrors:u.shape({}),apiCredentials:u.shape({accessKey:u.string,secretKey:u.string,apiUrl:u.string}),outputEncryptionSettings:u.shape({}),cameraScale:u.number,defaultCameraId:u.string,passiveModeAuto:u.bool,offsetFaceY:u.number,styledComponent:u.shape({CloseCameraButton:u.node}),serviceSettings:u.shape({})},P.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(R,{type:o.FaceDirection.LEFT}),[o.FaceDirection.RIGHT]:i.jsx(R,{type:o.FaceDirection.RIGHT}),[o.FaceDirection.UP]:i.jsx(R,{type:o.FaceDirection.UP}),[o.FaceDirection.FRONTAL]:i.jsx(R,{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{P as default};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
let e,t;import{r as r,d as a,j as o,U as i,O as n,o as l,c as s,aw as c,aG as u,aH as h,s as d,q as f,R as m,E as g,aI as _,F as p,ax as b,a as y,T as w,P as E,m as C}from"./chunk-5d7eeacb.js";import{W as A}from"./chunk-5c360a9c.js";let v=({onVideoPlayed:e})=>{let[t,a]=r.useState(!1),[o,i]=r.useState({});return{onVideoPlayed:r.useCallback(t=>{i((e=>{let{videoAreaWidth:t,videoAreaHeight:r,lostX:a,lostY:o}=e;return{width:t,height:r,x:Math.max(a,0),y:Math.max(o,0)}})(t)),a(!0),"function"==typeof e&&e(t)},[e]),cropArea:o,isPlaying:t}},F={LOADING:"loading",FAR_FACE:"far_face",CLOSE_FACE:"close_face",START_FLASHING:"start_flashing",STOP_DECTECTING:"stop_detecting"},R={FAR_FACE:"far",CLOSE_FACE:"close",FLASHING:"flashing"},S={timeout:"timeout",no_face:"no_face"},x=({prediction:e,canvas:t,index:r,quality:a=.8})=>{let o=t.toDataURL("image/jpeg",a);return e?{label:"portrait",base64:o.split(",")[1],landmarks:e.landmarks,index:r}:{label:"portrait",base64:o.split(",")[1],index:r}},k=a.div`
|
|
2
|
+
position: fixed;
|
|
3
|
+
top: 0;
|
|
4
|
+
left: 0;
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 100%;
|
|
7
|
+
z-index: 1001;
|
|
8
|
+
|
|
9
|
+
background-color: ${e=>e.$overlay?"white":"transparent"};
|
|
10
|
+
`,T=({children:e=null,overlay:t=!1,loadingComponent:r=o.jsx(A,{})})=>o.jsxs(k,{$overlay:t,children:[t&&r,o.jsx("div",{style:{visibility:t?"hidden":"visible"},children:e})]}),L=(e,t,r)=>{let{smallScale:a,largeScale:o,ovalPadding:i}=e,n=t.width/t.height,l=a*r.height,s=o*r.height,c=i.top+i.bottom,u=i.left+i.right,h=s-c;if(parseFloat((h*n).toFixed(2))+u>r.width){let e=Number(((r.width-u)/t.width).toFixed(2));return{smallScale:Number((a/o*e).toFixed(2)),largeScale:e}}let d=Number(((l-c)/t.height).toFixed(2));return{smallScale:d,largeScale:Number((h/t.height).toFixed(2))}},M=({offset:e,ovalPadding:t,largeScale:r,ovalHeight:a,maskHeight:o})=>{let i=a/2+t.bottom;return(i+e)*r>o/2?o/2/r-i:e},O=e=>{r.useEffect(()=>()=>{e&&e.srcObject?.getTracks().forEach(e=>{e.stop()})},[e])},P=()=>{let[e,t]=r.useState(null),[a,o]=r.useState(!1),i=r.useRef(null);return r.useEffect(()=>{if(!i.current)return()=>{};let e=i.current,r=()=>{t(e.getBoundingClientRect()),o(!1)},a=()=>{o(!0)};return e.addEventListener("transitionstart",a),e.addEventListener("transitionend",r),()=>{e.removeEventListener("transitionstart",a),e.removeEventListener("transitionend",r)}},[]),[i,e??i.current?.getBoundingClientRect(),a,o]},B=()=>{let e=r.useRef(),{sendEvent:t}=i.useSDKTracking();return r.useCallback((r,a,o={})=>{let i=performance.now(),n={};"object"==typeof o&&(n={...o},e.current&&(n.interval_vs_previous_in_ms=Math.round(i-e.current))),"function"==typeof o&&(n=o({lastTimeLog:e.current})),e.current=i,t({tag:r,event:a,log:n})},[t])},D=(e,t)=>{let a=r.useRef(e);r.useEffect(()=>{a.current=e},[e]),r.useEffect(()=>{t&&"function"==typeof a.current&&a.current()},[t])},I=({compareFn:e,duration:t,minFrames:a=null})=>{let o=r.useRef(null),i=r.useRef(!1),n=r.useRef(0),l=r.useRef(()=>{}),{compareAndStoreResult:s,getBestResult:c,reset:u}=r.useMemo(()=>{var r,a;let o,i,n;return r=e,a=t,o=null,i=null,n=()=>null!==i&&performance.now()-i>a,{checkIsTimeUp:n,compareAndStoreResult:e=>{null===o&&(o=e,i=performance.now()),n()||r(o,e)&&(o=e)},getBestResult:()=>o,reset:()=>{o=null,i=null}}},[e,t]),h=r.useCallback(()=>{u(),n.current=0,i.current=!1,o.current&&(clearTimeout(o.current),o.current=null)},[u]),d=r.useCallback(()=>null!==o.current,[]),f=r.useCallback(e=>{if(s(e),n.current+=1,!i.current||"number"!=typeof a||n.current<a)return;let t=c();l.current(t),h()},[s,c,a,h]),m=r.useCallback(({initialFrame:e,onDone:r})=>{l.current=r,f(e),o.current=setTimeout(()=>{if(i.current=!0,"number"==typeof a&&n.current<a)return;let e=c();l.current(e),h()},t)},[f,t,c,a,h]);return r.useEffect(()=>()=>{clearTimeout(o.current)},[]),r.useMemo(()=>({captureFrame:f,getBestResult:c,isAutoCapturing:d,startCapturing:m,stopCapturing:h}),[f,c,d,m,h])},N=e=>{let t=document.createElement("canvas");return t.setAttribute("width",e.videoWidth.toString()),t.setAttribute("height",e.videoHeight.toString()),t.getContext("2d").drawImage(e,0,0,e.videoWidth,e.videoHeight),t},j=()=>{let[e,t]=r.useState(Date.now());return{sessionId:e,updateSessionId:r.useCallback(()=>{t(Date.now())},[])}},z=(e,t)=>{if(0===Object.keys(e).length)return{topLeft:[0,0],bottomRight:[0,0],probability:0,landmarks:[]};let r=e.topLeft??[0,0],a=e.bottomRight??[0,0],o=e.probability??0,i=e.landmarks??[];return{topLeft:[r[0]*t,r[1]*t],bottomRight:[a[0]*t,a[1]*t],probability:o,landmarks:i.map(e=>[e[0]*t,e[1]*t])}},W=200,q=({size:e,scale:t=1,video:r,baseSize:a=W})=>{let{width:o,height:i}=e,{videoWidth:n=Number.MAX_SAFE_INTEGER,videoHeight:l=Number.MAX_SAFE_INTEGER}=r??{},s=Math.min(o,i)/a,c=Math.round(o/s*t),u=Math.round(i/s*t);return c>n||u>l?{width:o,height:i}:{width:c,height:u}},G=({width:e,height:t,cameraScale:r})=>{let a=document.createElement("canvas");a.width=e,a.height=t;let o=a.getContext("2d");return o?(o.translate(e,0),o.scale(-1*r,+r)):console.error("Failed to get 2D context from canvas in createLivenessCanvas"),a},H=({maskBoundingBox:e,faceRatio:t,validFaceRatio:r,video:a,shouldCropCenterSquare:o=!0,cropArea:i,frame:l,facePrediction:s,detectionToWholeFaceRatio:c=.8})=>{let u=e.width*t/r,h=u/e.width,d=e.height*h,f={x:e.x-(u-e.width)/2,y:e.y-(d-e.height)/2,width:u,height:d};f.x+f.width>i.x+i.width&&(f.width=i.width,f.x=i.x),f.y+f.height>i.y+i.height&&(f.height=i.height,f.y=i.y);let m=null;if(o){let e=Math.min(f.width,f.height),t=(s.bottomRight[1]-s.topLeft[1])/c,r=s.bottomRight[1]-t+(t-e)/2+i.y;r+e>f.y+f.height&&(r=f.y+f.height-e);let o={x:f.x+f.width/2-e/2,y:r,width:e,height:e};m=n.analyzeVideoAndWindowSizes(a,o)}else m=n.analyzeVideoAndWindowSizes(a,f);let g=q({size:{width:m.cropWidth,height:m.cropHeight},baseSize:400,video:a}),_=G({width:g.width,height:g.height,cameraScale:1}),p=_.width,b=_.height;return _.getContext("2d").drawImage(l,m.cropX,m.cropY,m.cropWidth,m.cropHeight,0,0,p,b),_},V=l(async function e({tfScriptUrls:t,closeEyesModelUrl:r,blazefaceModelUrl:a,qualifyModelUrl:o,opencvUrl:i}={}){let n=new u(r),l=new h(o),d=new c;await s.loadTensorFlow(t),await s.initTensorFlow({preferredBackends:["wasm","cpu"]});let f=[s.loadBlazefaceModel({modelUrl:a}),n.load(),l.init({opencvUrl:i}),c.init({opencvUrl:i})],[{blazefaceModel:m}]=await Promise.all(f);return{closeEyesModel:n,blazefaceModel:m,notQualifiedModel:l,brightnessDetector:d}}),U=({width:e,height:t,cameraScale:a=1,debug:o=!1})=>{let[i,n]=r.useState(null);return r.useEffect(()=>{let r=G({width:e,height:t,cameraScale:a});return o&&(document.body.appendChild(r),r.style.position="fixed",r.style.top="0",r.style.left="0",r.style.zIndex="9999"),n(r),()=>{o&&document.body.removeChild(r)}},[a,o,t,e]),i},K=y.isMobile?200:400;function X({cameraScale:e=1,isVideoPlaying:t,step:a,cropArea:o,videoRef:i,onFarFaceDetected:l,onFarFullFaceDetected:s,onCloseFaceDetected:c,onCloseFullFaceDetected:u,onFlashingFramesCaptured:h,frameInterval:y=0,useFaceDetectorWhenFlashing:w,onFaceError:E,onError:C,maskBoundingRect:A,shouldPauseFaceDetection:v,shouldContinueOnError:R,debug:S=!1,faceDetectionSettings:x}){let{faceSettings:k,maskSettings:T,closeEyesSettings:L,captureFrameSettings:M,blurCheckFarSettings:O,blurCheckCloseSettings:P,brightnessDetectionFarSettings:B,brightnessDetectionCloseSettings:D,notQualifiedFarSettings:I,notQualifiedCloseSettings:N,frontalFaceCheckSettings:j}=x,{chinToMaskBottomPadding:W}=T,{frameScale:G}=M,{enable:H,timeout:X,forceCheck:$}=L,{enable:J,upDownBoundMin:Y,upDownBoundMax:Q}=j,{minFarFaceRatio:Z,maxFarFaceRatio:ee,closeFaceRatio:et}=k,er=(e=>{let[t,a]=r.useState(e);return r.useEffect(()=>{(async()=>{try{let t=Math.max(16.666666666666668,33.333333333333336,e);a(t)}catch(e){console.error(e),a(20)}})()},[e]),t})(y),ea=(({videoRef:e,cropArea:t})=>r.useMemo(()=>e.current&&0!==Object.keys(t).length?n.analyzeVideoAndWindowSizes(e.current,t):{},[e,t]))({videoRef:i,cropArea:o}),eo=q({size:{width:ea.cropWidth,height:ea.cropHeight},scale:G,video:i.current}),ei=(({cropArea:e,maskBoundingRect:t,baseSize:r})=>{let{width:a,height:o,x:i,y:n}=e,l=Math.min(a,o)/r,s=t?.left??0,c=t?.top??0,u=t?.right??a;return{left:Math.max((s-i)/l,0),right:Math.min((u-i)/l,a/l),top:Math.max((c-n)/l,0),bottom:Math.min(((t?.bottom??o)-n)/l,o/l)}})({cropArea:o,maskBoundingRect:A,baseSize:Math.min(eo.width,eo.height)}),en=U({width:eo.width,height:eo.height,cameraScale:e}),el=Math.min(o.width,o.height)/Math.min(eo.width,eo.height),es=U({width:K,height:K*(eo.height/eo.width),cameraScale:e,debug:S}),ec=(({width:e,height:t,debug:a})=>{let o=r.useRef(null),i=r.useMemo(()=>{let r=document.createElement("canvas");return r.width=e,r.height=t,r.style.position="fixed",r.style.bottom="0",r.style.left="0",r.style.zIndex="99999",o.current=r,a&&document.body.appendChild(r),r},[t,e,a]);return r.useEffect(()=>()=>{a&&document.body.removeChild(o.current)},[a]),i})({width:160,height:150,debug:S}),{customUrls:eu}=f.useSDKSettings(),[eh,ed]=((e,t)=>{let[a,o]=r.useState({}),i=Object.keys(a).length>0;return r.useEffect(()=>{let r=!1;return(async()=>{try{let t=await V(e);if(r)return;o(t)}catch(e){t({...d.Errors.unable_to_load_model,details:e}),console.error(e)}})(),()=>{r=!0}},[i,e,t]),[a,i]})(eu,C),ef=r.useRef(null),{markTime:em,checkIfEllapsed:eg}=(({timeout:e})=>{let t=r.useRef(null),a=r.useCallback(()=>{t.current=performance.now()},[]),o=r.useCallback(()=>null===t.current?(a(),!1):performance.now()-t.current>e,[a,e]);return{markTime:a,checkIfEllapsed:o}})({timeout:1e3*X}),e_=ed&&t,{closeEyesModel:ep,blazefaceModel:eb,notQualifiedModel:ey,brightnessDetector:ew}=eh,eE=r.useCallback(async(e,t)=>{try{if(t?.width===0||t?.height===0||null===i.current||v||a===F.STOP_DECTECTING)return;let{cropX:n,cropY:f,cropWidth:y,cropHeight:C}=e,A=t.width,x=t.height;t.getContext("2d").drawImage(i.current,n,f,y,C,0,0,A,x);let k=m.drawToSquareCanvas(t),T=K/A;if(S&&es.getContext("2d").drawImage(i.current,n,f,y,C,0,0,A*T,x*T),!w&&a===F.START_FLASHING){"function"==typeof h&&await h({prediction:null,originalRatio:el,canvas:t});return}let L=await g.getModelPredictions({model:eb,sCanvas:k}),M=[[ei.left,ei.top],[ei.right,ei.bottom]],{error:j,fullFace:q,faceRatio:G}=await _.validatePredictions({predictions:L,cropAreaCoordinates:M});if(S){var r,o;let e,t={left:ei.left*T,top:ei.top*T,right:ei.right*T,bottom:ei.bottom*T};r=es,o={x:t.left,y:t.top,width:t.right-t.left,height:t.bottom-t.top},e=r.getContext("2d"),e?(e.strokeStyle="red",e.lineWidth=1,e.beginPath(),e.rect(o.x,o.y,o.width,o.height),e.stroke(),e.closePath()):console.warn("drawBoundingBox: 2D context is not available.");let a=L.map(e=>z(e,T));((e,t,r=!1)=>{let a=e.getContext("2d");if(!a)return;let o=e.width;a.strokeStyle="blue",a.fillStyle="blue",a.lineWidth=1,t.forEach(e=>{e.landmarks.forEach(e=>{a.beginPath(),a.arc(r?o-e[0]:e[0],e[1],2,0,2*Math.PI),a.fill(),a.closePath()}),a.beginPath();let t={x:r?o-e.bottomRight[0]:e.bottomRight[0],y:e.topLeft[1],width:e.bottomRight[0]-e.topLeft[0],height:e.bottomRight[1]-e.topLeft[1]};a.rect(t.x,t.y,t.width,t.height),a.stroke(),a.closePath()})})(es,a,!0)}let V=d.FaceDirection.FRONTAL;if(q&&J){let e=await _.calculateFaceDirection({landmarks:q.landmarks,upDownBound:{lower:Y,upper:Q}});V=e?.gesture??""}(q||j?.code===d.Errors.partial_face.code)&&a===F.FAR_FACE&&"function"==typeof l&&await l({prediction:L[0],originalRatio:el,canvas:t}),(q||j?.code===d.Errors.partial_face.code)&&a===F.CLOSE_FACE&&"function"==typeof c&&await c({prediction:L[0],originalRatio:el,canvas:t});let U=j?.code;try{if(U===d.Errors.no_face.code)throw Error("no_face");if(U===d.Errors.multiple_faces.code){let e=_.calculateFaceArea(L[0]),t=_.calculateFaceArea(L[1]);if(e<=2*t)throw Error("multiple_faces")}if(V!==d.FaceDirection.FRONTAL)throw Error("face_not_frontal");if(U===d.Errors.partial_face.code){let e=_.cropFaceInsideBox([L[0].topLeft,L[0].bottomRight],M);if(p.rectEdgeRatio(e,M)>.95)throw Error("face_too_large")}if(a===F.FAR_FACE){if(G>ee)throw Error("face_too_large");if(G<Z)throw Error("face_too_small")}if(a===F.CLOSE_FACE&&G<et)throw Error("face_too_small");if(Array.isArray(L)&&L.length>0&&ei.bottom-L[0].bottomRight[1]>W)throw Error("face_too_high");if(U===d.Errors.face_out_of_box.code&&(a===F.FAR_FACE&&G>=Z&&G<=ee||a===F.CLOSE_FACE&&G>=et))throw Error("")}catch(e){U=e.message}let X=null;if(H)if(U)em();else{let e=await ep.predict(t,q.landmarks),r=!$&&eg();X=e.isEyeClose,e.isEyeClose&&!r&&(U="eye_close")}let er=null,ea=a===F.FAR_FACE?B:D;if((ea.enableTooBrightCheck||ea.enableTooDarkCheck)&&Array.isArray(L)&&L.length>0){let e=[[Math.max(L[0].topLeft[1],0),Math.min(L[0].bottomRight[0],t.width),Math.min(L[0].bottomRight[1],t.height),Math.max(L[0].topLeft[0],0)]],{score:r,message:a}=ew.score(t,e,ea.tooDarkThreshold,ea.tooBrightThreshold);er=r,""===U&&ea.enableTooBrightCheck&&"face_too_bright"===a&&(U="face_too_bright"),""===U&&ea.enableTooDarkCheck&&"face_too_dark"===a&&(U="face_too_dark")}let eo=0,en={enable:a===F.FAR_FACE?O.enable:P.enable,threshold:a===F.FAR_FACE?O.threshold:P.threshold};en.enable&&(eo=await b.calculateBlurScore(t),""!==U||b.hasBetterBlurScore(eo,en.threshold)||(U="blurry_face"));let eu=0,eh=0,ed="model_not_run",ef={enable:a===F.FAR_FACE?I.enable:N.enable,threshold:a===F.FAR_FACE?I.threshold:N.threshold};if(ef.enable&&q&&q.landmarks){let[e,r,a,o]=await ey.predict(t,q.landmarks,ef.threshold);eu=r,eh=o,ed=a,""!==U||e||(U="face_not_qualified")}if((S&&m.drawDebugCanvas(ec,{error:U,ovalFaceRatio:G?.toFixed(3)??"null",ovalError:j?.code??"null",step:a===F.FAR_FACE?"far":"close",blurScore:eo.toFixed(3),qualifyScore:eu.toFixed(3),brightnessScore:er?.toFixed(3)??"null"}),U)&&("function"==typeof E&&await E({error:U,currentStep:a}),!R))return;let e_=q,eE=G;if(!e_&&R&&(e_=Array.isArray(L)&&L.length>0?L[0]:{},eE=a===F.FAR_FACE?ee:et),a===F.FAR_FACE&&e_&&Z<=eE&&eE<=ee&&"function"==typeof s)return void await s({prediction:e_,originalRatio:el,canvas:t,frame:{faceRatio:eE,isEyeClosed:X,blurScore:eo,qualifyScore:eu,realQualifyScore:eh,qualifyModelMessage:ed,brightnessScore:er,faceError:U}});if(e_&&a===F.CLOSE_FACE&&eE>=et&&"function"==typeof u)return void await u({prediction:e_,originalRatio:el,canvas:t,frame:{faceRatio:eE,isEyeClosed:X,blurScore:eo,qualifyScore:eu,realQualifyScore:eh,qualifyModelMessage:ed,brightnessScore:er,faceError:U}});w&&e_&&a===F.START_FLASHING&&eE>=et&&"function"==typeof h&&await h({prediction:e_,originalRatio:el,canvas:t,faceError:U})}catch(e){console.error(e),C({error:e})}},[i,v,a,S,w,eb,ei.left,ei.top,ei.right,ei.bottom,J,H,B,D,O.enable,O.threshold,P.enable,P.threshold,I.enable,I.threshold,N.enable,N.threshold,R,Z,ee,et,es,h,el,Y,Q,l,c,W,ep,$,eg,em,ew,ey,ec,E,s,u,C]);return r.useEffect(()=>{let e=null,t=!1;return e_&&function r(){e=requestAnimationFrame(async e=>{t||null===i.current||((null===ef.current&&(ef.current=e),e-ef.current<er)?r():(ef.current=e,await eE(ea,en),r()))})}(),()=>{t=!0,cancelAnimationFrame(e)}},[en,ea,eE,e_,i,er]),{warmupDone:ed}}let $=e=>{let{shouldStart:t,totalTime:a,totalDelay:o,onError:i,onTimeout:n,onDelayEnd:l,maxRetriesSettings:s,interruptible:c=!0}=e,u=r.useRef(new w({totalTime:a,interruptible:c,totalDelayBetweenReset:o})),[h,f]=r.useState(a);return r.useEffect(()=>u.current.on("tick",({remainTime:e})=>{f(e)}),[n]),r.useEffect(()=>u.current.on("delaystart",({attemptCount:e})=>{s.enable&&e>=s.total?i(d.Errors.max_retry_reached):n()}),[s.enable,s.total,i,n]),r.useEffect(()=>u.current.on("delayend",()=>{l()}),[l]),r.useEffect(()=>u.current.on("reset",({attemptCount:e,fromBackground:t})=>{s.enable&&e>=s.total&&i(d.Errors.max_retry_reached),t&&(n(),l())}),[n,l,s.enable,s.total,i]),r.useEffect(()=>t?u.current.start():()=>{},[t]),{remaining:h}},J=e=>{switch(e){case"partial_face":return"flash_liveness.error.partial_face";case"no_face":case"face_out_of_box":return"flash_liveness.error.no_face";case"face_too_small":return"flash_liveness.error.face_too_small";case"face_too_large":return"flash_liveness.error.face_too_large";case"eye_close":return"flash_liveness.error.close_eye";case"face_not_frontal":return"flash_liveness.error.face_not_frontal";case"multiple_faces":return"flash_liveness.error.multiple_faces";case"face_too_high":return"flash_liveness.error.face_too_high";case"blurry_face":return"flash_liveness.error.face_too_blurry";case"face_not_qualified":return"flash_liveness.error.face_not_qualified";case"face_too_bright":return"flash_liveness.error.face_too_bright";case"face_too_dark":return"flash_liveness.error.face_too_dark";default:return""}},Y=e=>Array.isArray(e)?e.map(({base64:e,label:t,index:r,metadata:a})=>({base64:e,label:t,index:r,metadata:a})):e,Q=r.createContext({enable:!1,key:""}),Z=({children:e,settings:t})=>{let a=r.useMemo(()=>{let e=t?.key??"";return{enable:!!e,key:e}},[t?.key]);return o.jsx(Q.Provider,{value:a,children:e})};Z.propTypes={children:E.node.isRequired,settings:E.shape({key:E.string})},Z.defaultProps={settings:{key:""}};let ee=()=>r.useContext(Q),et=r.createContext({}),er=({apiCredentials:e,children:t})=>{let{apiClient:r}=C.useApiClient({apiCredentials:e});return o.jsx(et.Provider,{value:r,children:t})};er.propTypes={apiCredentials:E.shape({accessKey:E.string.isRequired,secretKey:E.string.isRequired,apiUrl:E.string.isRequired}),children:E.node.isRequired},er.defaultProps={apiCredentials:{}};let ea=()=>r.useContext(et);let eo=(e=[],t=async()=>(await Promise.all(e)).map(e=>({id:e?.data?.file_id??-1})),{uploadFrameBatch:(t,r,a)=>{let o=new Blob([JSON.stringify(t)]);e.push(r.uploadFile({file:o,metadata:JSON.stringify({type:"selfie"}),label:"video"},a))},getAllUploadedBatches:t,resetUploadBatches:()=>{e.length=0}});export{er as A,R as F,Z as O,S as R,F as S,T as W,P as a,I as b,j as c,v as d,N as e,x as f,X as g,O as h,D as i,$ as j,H as k,M as l,J as m,L as n,ee as o,ea as p,eo as q,Y as r,z as s,B as u};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{d as e,P as r,s as t,n as n,u as s,g as i,b as a,j as o,K as c,r as l,aJ as u,q as m,C as p,a as d,aK as f}from"./chunk-5d7eeacb.js";import{M as g,O as h,W as x,C as j}from"./chunk-5c360a9c.js";import{u as F}from"./chunk-6e5fa179.js";import{p as y,g as C,a as D,O as S,I as b,i as T,j as v,k as I,l as E,L as L,b as R,S as k}from"./chunk-ffa40a6f.js";import{a as V}from"./chunk-080d4642.js";import"./chunk-630b6747.js";import"./chunk-50924bca.js";import"./chunk-2d04cdda.js";let _=e.img`
|
|
2
|
+
width: ${({width:e})=>e};
|
|
3
|
+
`;function w({type:e}){let r=n(),t=s(`Selfie.Active.directionIcon.${e}`,`${e}_arrow.gif`),c=i(`Selfie.Active.directionIcon.${e}Width`)({theme:r}),l=a(r,`Selfie.Active.directionIcon.${e}`);return null===l?o.jsx(o.Fragment,{}):l&&null!==l?o.jsx(_,{src:a(r,`Selfie.Active.directionIcon.${e}`),width:c,alt:""}):o.jsx(_,{src:t,alt:"",width:c})}w.propTypes={type:r.oneOf([t.FaceDirection.LEFT,t.FaceDirection.RIGHT,t.FaceDirection.UP,t.FaceDirection.FRONTAL])},w.defaultProps={type:t.FaceDirection.LEFT};let A=d.isMobile?{width:{ideal:640}}:null,$=({stepNumber:e,type:r,theme:t})=>{let n=f(`instruction_${r}.svg`),s=a(t,`Selfie.Active.imageHolder.${r}`);return null===s?o.jsx(o.Fragment,{}):"string"==typeof s&&""!==s?o.jsx("img",{src:s,alt:""}):"v1"===a(t,"themeVersion")?o.jsx("span",{children:e}):o.jsx("img",{src:n,alt:""})};function P(e){var r,f;let{apiCheck:_,onLivenessDetectionDone:w,captureFrameSettings:P,onFramesCaptured:N,frontCamera:H,flipVideoHorizontal:O,customDirectionIcon:M,customStepTimeConstraints:U,onProcessing:K,customErrors:B,apiCredentials:G,outputEncryptionSettings:W,cameraScale:z,defaultCameraId:Y,offsetFaceY:q,styledComponent:J,isLoading:Q,serviceSettings:X,onReset:Z}=e,ee=n(),{onErrorCallback:er,onCloseCallback:et}=V(),en=c.useAsset("bg_camera_mask.png"),es=c.useAsset("bg_camera_mask_red.png"),ei=s("IDCapturing.loadingIcon.src","ic_loading.gif"),[ea,eo]=l.useState({}),{yFaceVerificationStepsWrapper:ec,yFaceDetectionError:el}=ea,[eu,em]=l.useState(""),[ep,ed]=l.useState(),ef=l.useMemo(()=>({backgroundColor:i("Selfie.backgroundColor")({theme:ee})}),[ee]);u(a(ee,"themeVersion"),"up_arrow.gif"),u(a(ee,"themeVersion"),"left_arrow.gif"),u(a(ee,"themeVersion"),"right_arrow.gif"),u(a(ee,"themeVersion"),"frontal_arrow.gif"),u(a(ee,"themeVersion"),"instruction_up.svg"),u(a(ee,"themeVersion"),"instruction_left.svg"),u(a(ee,"themeVersion"),"instruction_right.svg"),u(a(ee,"themeVersion"),"instruction_frontal.svg");let eg=l.useCallback(({clientHeight:e,videoAreaWidth:r,videoAreaHeight:t,lostX:n,lostY:s})=>{let i,a;d.isMobile?a=i=r:i=a=t-200;let o=Math.floor((r-i)/2)+n,c=5+s,l=s+25,u=l+30;eo({yFaceDetectionError:l,yFaceVerificationStepsWrapper:u+a+20});let m=Math.floor(s),p=Math.floor(e-s);return c=Math.floor(u),0!==q&&(c+q<m||c+q+a>p)?er({code:`offsetFaceY must be in [-${c-m}, ${p-a-c}]`}):c+=q,{x:o,y:c,width:i,height:a}},[q,er]),{shouldResetFlowOnOrientationChange:eh,cropArea:ex,curStepIndex:ej,directionIcon:eF,directionIconAnimation:ey,faceDetectionError:eC,resetFlow:eD,handleVideoPlayed:eS,instructions:eb,refVideo:eT,refIsReseting:ev,steps:eI,videoPlayed:eE,activeCapturing:eL,warmupDone:eR,showLoading:ek}=F({currentOrientation:ep,apiCheck:_,bgCameraMask:en,bgCameraMaskRed:es,surroundStyle:ef,onLivenessDetectionDone:w,onError:er,cropAreaDimension:eg,customDirectionIcon:M,captureFrameSettings:P,onFramesCaptured:N,setRemainingTime:em,customStepTimeConstraints:U,onProcessing:K,customErrors:B,apiCredentials:G,outputEncryptionSettings:W,cameraScale:z,serviceSettings:X,onReset:Z});l.useEffect(()=>{"string"==typeof eI[0]?.directionIcon&&Promise.all(eI.map(e=>y(e.directionIcon)))},[eI]);let{CloseCameraButton:eV}=J,e_=C(e,ee),ew=ev.current?0:ej/eI.length*100,{lang:eA}=m.useSDKSettings(),e$=l.useRef(0),eP=l.useRef({}),eN=l.useRef(t.ErrorDuration.SHORT),eH=l.useMemo(()=>{let{msg:e,duration:r=t.ErrorDuration.SHORT}=eC||{},n=e?.[eA];return Date.now()-e$.current>=eN.current&&(e$.current=Date.now(),eN.current=r,eP.current=n),eP.current},[eC,ej]),eO=l.useCallback(e=>{ed(e),eh?eD():e===g.LANDSCAPE?eT.current?.pause():eT.current?.play()},[eT,eD,eh]);return o.jsx(h,{onOrientationChange:eO,children:o.jsxs(p,{frontCamera:H,onVideoPlayed:eS,onClose:et,flipHorizontal:O??H,ref:eT,videoSettings:A,onError:er,scale:z,defaultCameraId:Y,closeButton:eV||null,children:[!eR&&o.jsx(x,{}),eE?o.jsxs(o.Fragment,{children:[ex.current?o.jsxs(j,{x:`${ex.current.x}px`,y:`${ex.current.y}px`,width:`${ex.current.width}px`,height:`${ex.current.height}px`,surroundStyle:ex.current.surroundStyle,children:[o.jsx(D,{}),o.jsx(S,{...e_,progress:ew,showErrorRing:!!eC&&i("Selfie.progressCircle.showErrorRing")({theme:ee})}),o.jsx(b,{children:(r=eF,f=ey,r?"string"==typeof r?o.jsx("img",{className:f,src:r,alt:"",style:{maxWidth:"98px",maxHeight:"98px",marginBottom:"25px"}}):r:null)}),eL&&o.jsx(T,{})]}):null,eb?o.jsxs(o.Fragment,{children:[o.jsx(v,{top:ec+5,className:"instructions",children:eb}),o.jsx(I,{top:ec+35,children:eI.map((e,r)=>{let{name:t,image:{objUrl:n}}=e;return o.jsx(E,{active:ej>=r,className:"step-item",children:n?o.jsx("img",{className:"image_preview",src:n,alt:""}):o.jsx($,{stepNumber:r+1,type:t,theme:ee})},t)})})]}):null]}):null,(ek||Q)&&o.jsx(L,{children:o.jsx("img",{src:ei,alt:"",className:"spin"})}),eu&&o.jsx(R,{top:ec-30,children:eu}),"string"==typeof eH?o.jsx(k,{top:el-15,className:"face-detection-error",children:eH}):null]})})}P.propTypes={apiCheck:r.bool,onLivenessDetectionDone:r.func,onClose:r.func,onError:r.func,onReset:r.func,captureFrameSettings:r.shape({}),onFramesCaptured:r.func,flipVideoHorizontal:r.bool,frontCamera:r.bool,isLoading:r.bool,customDirectionIcon:r.shape({}),customStepTimeConstraints:r.shape({}),onProcessing:r.func,customErrors:r.shape({}),apiCredentials:r.shape({accessKey:r.string,secretKey:r.string,apiUrl:r.string}),outputEncryptionSettings:r.shape({}),cameraScale:r.number,defaultCameraId:r.string,offsetFaceY:r.number,styledComponent:r.shape({CloseCameraButton:r.node}),serviceSettings:r.shape({})},P.defaultProps={apiCheck:!1,onLivenessDetectionDone:null,onClose:null,onError:()=>{},onReset:()=>{},captureFrameSettings:{enable:!1,framesIntervalTime:180,framesBatchLength:0},onFramesCaptured:()=>{},flipVideoHorizontal:null,frontCamera:!0,isLoading:!1,customDirectionIcon:{[t.FaceDirection.LEFT]:o.jsx(w,{type:t.FaceDirection.LEFT}),[t.FaceDirection.RIGHT]:o.jsx(w,{type:t.FaceDirection.RIGHT}),[t.FaceDirection.UP]:o.jsx(w,{type:t.FaceDirection.UP}),[t.FaceDirection.FRONTAL]:o.jsx(w,{type:t.FaceDirection.FRONTAL})},customStepTimeConstraints:{[t.FaceDirection.UP]:{delayTime:0},[t.FaceDirection.LEFT]:{delayTime:0},[t.FaceDirection.RIGHT]:{delayTime:0},[t.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{P as default};
|