UNPKG

@tsocial/tvweb-sdk

Version:

TV Web SDK - The Standalone SDK

2 lines (1 loc) 5.69 kB
import{x as e,y as r,Q as s,r as a,e as n,c as t,s as o,j as i,a2 as c,ay as l,n as u,P as p,b as d}from"./chunk-554942c8.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 x,c as F,L as S}from"./chunk-c347f1a0.js";import{u as b,C as I}from"./chunk-cd77ddca.js";import{M as T,O as E,W as k,C as R}from"./chunk-2221afbd.js";import{D as L}from"./chunk-644e2eb3.js";import{u as v}from"./chunk-306b4e50.js";import"./chunk-1c4b07c3.js";import"./chunk-d34f70f1.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:$,apiCredentials:_,outputEncryptionSettings:B,cameraScale:K,defaultCameraId:N,passiveModeAuto:z,offsetFaceY:G,styledComponent:Y,serviceSettings:W,onReset:Q,isLoading:q}=p,J=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:J})}),[J]),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:ex,showCountdown:eF,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:$,apiCredentials:_,outputEncryptionSettings:B,cameraScale:K,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,J),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?ex.current?.pause():ex.current?.play()},[ex,ey,em]);return i.jsx(E,{onOrientationChange:eU,children:i.jsxs(c,{frontCamera:H,onVideoPlayed:eD,onClose:Z,flipHorizontal:O??H,ref:ex,videoSettings:P,onError:X,scale:K,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:J})}),ek?i.jsx(y,{children:ef}):null,eC&&i.jsx(j,{})]}):null,ei&&i.jsx(D,{top:eo-30,children:ei}),eE?i.jsx(x,{children:i.jsx(F,{onClick:ej,disabled:eF,children:u(J,"Selfie.captureIcon.src")?i.jsx("img",{src:u(J,"Selfie.captureIcon.src"),alt:""}):i.jsx(I,{fillColor:"rgba(193, 197, 204, 1)"})})}):null]}):null,(eR||q)&&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};