@tsocial/tvweb-sdk.platform 5.38.1 → 5.38.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/build/esm/{chunk-ebbd1c81.js → chunk-0319b1ae.js} +1 -1
  2. package/build/esm/{chunk-af89e5b6.js → chunk-036bae4b.js} +1 -1
  3. package/build/esm/{chunk-9778c61e.js → chunk-2118775a.js} +1 -1
  4. package/build/esm/{chunk-db6c3ef2.js → chunk-2b4d00a3.js} +1 -1
  5. package/build/esm/{chunk-dc7036ac.js → chunk-30dc9915.js} +1 -1
  6. package/build/esm/{chunk-530590d7.js → chunk-3aa490f8.js} +1 -1
  7. package/build/esm/{chunk-19191a88.js → chunk-3b109c2f.js} +1 -1
  8. package/build/esm/{chunk-3a50b76b.js → chunk-409b3310.js} +1 -1
  9. package/build/esm/{chunk-e8ed1b74.js → chunk-48199d95.js} +1 -1
  10. package/build/esm/{chunk-0da61929.js → chunk-51b3fd2d.js} +1 -1
  11. package/build/esm/{chunk-f7c561aa.js → chunk-6e5358d6.js} +1 -1
  12. package/build/esm/{chunk-64ec8617.js → chunk-71508ce2.js} +1 -1
  13. package/build/esm/chunk-71ff4107.js +1 -0
  14. package/build/esm/{chunk-9dfcc42f.js → chunk-7618f5a4.js} +1 -1
  15. package/build/esm/{chunk-d01fee9b.js → chunk-7fa83a52.js} +1 -1
  16. package/build/esm/{chunk-d70fed0c.js → chunk-88ec0901.js} +1 -1
  17. package/build/esm/{chunk-00ef2df8.js → chunk-91b54c2c.js} +1 -1
  18. package/build/esm/{chunk-d315aa24.js → chunk-c747321c.js} +2 -2
  19. package/build/esm/{chunk-460be0ec.js → chunk-d7bc8179.js} +1 -1
  20. package/build/esm/{chunk-ca868cf7.js → chunk-da8ef78b.js} +1 -1
  21. package/build/esm/{chunk-661f2995.js → chunk-ddb14dfb.js} +1 -1
  22. package/build/esm/{chunk-8d117718.js → chunk-e5a92416.js} +1 -1
  23. package/build/esm/tvweb-sdk.platform.esm.min.js +1 -1
  24. package/build/tvweb-sdk.platform.cjs.min.js +2 -2
  25. package/build/tvweb-sdk.platform.standalone.js +42 -43
  26. package/build/tvweb-sdk.platform.standalone.min.js +2 -2
  27. package/package.json +5 -5
  28. package/build/esm/chunk-14e1b552.js +0 -1
@@ -1 +1 @@
1
- import{j as r,r as o,s as e,a2 as n,ac as t,ad as i,ae as a,af as s,ag as u,ah as d,ai as c,aj as l,ak as g,al as f,am as p,an as h,$ as b,u as y,ao as x}from"./chunk-d315aa24.js";let k=o.createContext(!1),C=({children:o,debug:e=!1})=>r.jsx(k.Provider,{value:e,children:o}),T=()=>o.useContext(k),v={tsBlue:"#0276f1",tsSecondary:"rgba(0, 47, 117, 0.6)"},m={IDCapturing:{backgroundColor:"rgba(0, 0, 0, 0.6)",titleFront:{color:"#fff",fontSize:"20px",fontWeight:"normal",backgroundColor:"unset"},titleBack:{color:"#fff",fontSize:"20px",fontWeight:"normal",backgroundColor:"unset"},instruction:{padding:"unset",color:"#fff",fontSize:"16px",fontWeight:"normal",backgroundColor:"unset",border:"unset",borderRadius:"unset"},captureInstruction:{capturing:{padding:"12px 12px",color:"#ffffff",fontSize:"14px",fontWeight:"normal",background:"rgba(15, 23, 42, 0.25)",border:"none",borderRadius:"100px"},captured:{padding:"12px 12px",color:"#ffffff",fontSize:"14px",fontWeight:"normal",background:"rgba(15, 23, 42, 0.25)",border:"none",borderRadius:"100px"}},error:{padding:"5px 10px",color:"#fff",fontSize:"16px",fontWeight:"normal",backgroundColor:"#ea3223",border:"unset",borderRadius:"3px"},toggle:{color:"#d1d1d1",fontSize:"16px",fontWeight:"500",gap:"16px",backgroundColor:"#fff",active:{backgroundColor:"#2196f3"},inactive:{backgroundColor:"#ccc"}},countdown:{color:"#fff",fontSize:"18px",fontWeight:"normal",backgroundColor:"#ea3223",border:"unset",borderRadius:"3px"},cardIcon:{src:"",width:"auto",height:"38px"},captureIcon:{src:"",width:"60px",height:"60px",disabled:{src:""}},loadingIcon:{src:"",width:"100px",height:"100px"},rectangleMask:{width:600,height:400,strokeWidth:2,strokeStyles:{},radius:10,paddingStyle:{fill:"rgba(0, 0, 0, 0.6)"},default:{fill:"none",stroke:"#fff",strokeWidth:2,strokeDasharray:"7, 4",opacity:.6},error:{fill:"rgba(234,50,35, 0.1)",strokeWidth:2,stroke:"#ea3223"}}},IDConfirmPopup:{image:{borderRadius:"5px"}},IDUploadButton:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.25)",borderRadius:"8px",color:"#ffffff",padding:"12px",leftOffset:"24px",focusOutlineColor:"#ffffff"},IDUploadErrorToast:{background:"rgba(0, 0, 0, 0.75)",color:"#ffffff",borderRadius:"8px",fontSize:"14px",padding:"10px 16px",maxWidthInset:"48px"},QRStep:{title:{color:"#fff",fontSize:"20px",fontWeight:"700",backgroundColor:"unset"},guidelinePopup:{image:{src:"",borderRadius:"5px",backgroundColor:"#e7e6e6"},guideText:{color:v.tsSecondary,fontSize:"16px",fontWeight:"normal",textAlign:"center",lineHeight:"20px"},countdownText:{color:v.tsSecondary,fontSize:"16px",fontWeight:"normal",textAlign:"center",lineHeight:"20px"}},scanTooltip:{backgroundColor:"#00ce78",borderRadius:"8px",color:"#fff",padding:"10px",textAlign:"center"},scanCountdown:{textAlign:"center",color:"#fff",fontSize:"18px",fontWeight:"normal",backgroundColor:"#ea3223",border:"none",borderRadius:"3px",padding:"5px 10px"},invalidPopup:{padding:"10px",title:{display:"block",color:v.tsSecondary,fontSize:"16px",fontWeight:"bold",margin:"25px 0 0 0",padding:"0 0 0 0"},description:{color:v.tsSecondary,fontSize:"16px",fontWeight:"normal",textAlign:"center",margin:"30px 0 0 0",padding:"0 0 0 0"},retryButton:{color:"#fff",fontSize:"1rem",fontWeight:"normal",backgroundColor:v.tsBlue,border:"none",borderRadius:"3px",outline:"none",height:"66px",margin:"30px 0 0 0"},skipButton:{color:v.tsBlue,fontSize:"1rem",fontWeight:"normal",backgroundColor:"unset",border:"none",borderRadius:"unset",outline:"none",height:"unset",margin:"20px 0"}},resultText:{success:{textColor:"#000",fontSize:"1rem",fontWeight:"normal",mainColor:"#34ce60"},error:{textColor:"#000",fontSize:"1rem",fontWeight:"normal",mainColor:"#ff9532"}}}},D={IDCapturing:{backgroundColor:"rgba(0, 0, 0, 0.6)",titleFront:{...e.DesignToken.Typography.h4,color:e.DesignToken.Color.base.white,backgroundColor:"unset"},titleBack:{...e.DesignToken.Typography.h4,color:e.DesignToken.Color.base.white,backgroundColor:"unset"},instruction:{...e.DesignToken.Typography.body,padding:"5px 10px",color:"rgba(255, 255, 255, 0.8)",backgroundColor:"unset",border:"unset",borderRadius:"unset"},captureInstruction:{capturing:{...e.DesignToken.Typography.label,color:e.DesignToken.Color.base.white,padding:`6px ${e.DesignToken.Spacing.sm}`,background:"rgba(15, 23, 42, 0.35)",border:"none",borderRadius:"100px"},captured:{...e.DesignToken.Typography.label,color:e.DesignToken.Color.base.white,padding:`6px ${e.DesignToken.Spacing.sm}`,background:"rgba(15, 23, 42, 0.35)",border:"none",borderRadius:"100px"}},error:{...e.DesignToken.Typography.body,padding:"5px 10px",color:e.DesignToken.Color.semantic.error[400],backgroundColor:"transparent",border:"unset",borderRadius:e.DesignToken.CornerRadius["2xs"]},toggle:{...e.DesignToken.Typography.body,color:e.DesignToken.Color.base.white,gap:e.DesignToken.Spacing.base,backgroundColor:e.DesignToken.Color.base.white,active:{backgroundColor:e.DesignToken.Color.base.blue},inactive:{backgroundColor:e.DesignToken.Color.neutral[300]}},countdown:{...e.DesignToken.Typography.body,color:e.DesignToken.Color.semantic.error[400],backgroundColor:"transparent",border:"unset",borderRadius:e.DesignToken.CornerRadius["2xs"]},cardIcon:{src:"",width:"auto",height:"38px"},captureIcon:{src:"",width:e.DesignToken.Height["7xl"],height:e.DesignToken.Height["7xl"],disabled:{src:""}},loadingIcon:{src:"",width:"47px",height:"47px"},rectangleMask:{width:600,height:400,strokeWidth:n.getCSSNumericValue(e.DesignToken.BorderWidth["3xl"]),strokeStyles:{},radius:n.getCSSNumericValue(e.DesignToken.CornerRadius.base),paddingStyle:{fill:"rgba(0, 0, 0, 0.6)"},default:{fill:"none",stroke:e.DesignToken.Color.neutral[400],strokeWidth:n.getCSSNumericValue(e.DesignToken.BorderWidth["3xl"])},error:{fill:"none",strokeWidth:n.getCSSNumericValue(e.DesignToken.BorderWidth["3xl"]),stroke:e.DesignToken.Color.semantic.error[400]}}},IDConfirmPopup:{image:{borderRadius:e.DesignToken.CornerRadius["2xs"]}},IDUploadButton:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.25)",borderRadius:e.DesignToken.CornerRadius.xs,color:e.DesignToken.Color.base.white,padding:e.DesignToken.Spacing.sm,leftOffset:"24px",focusOutlineColor:e.DesignToken.Color.base.white},IDUploadErrorToast:{background:"rgba(0, 0, 0, 0.75)",color:e.DesignToken.Color.base.white,borderRadius:e.DesignToken.CornerRadius.xs,fontSize:"14px",padding:"10px 16px",maxWidthInset:"48px"},QRStep:{title:{...e.DesignToken.Typography.h4,backgroundColor:"unset"},guidelinePopup:{image:{src:"",borderRadius:e.DesignToken.CornerRadius["2xs"],backgroundColor:"transparent"},guideText:{...e.DesignToken.Typography.body,color:e.DesignToken.Color.neutral[600],textAlign:"center"},countdownText:{...e.DesignToken.UIText.medium,color:e.DesignToken.Color.neutral[500],textAlign:"center"}},scanTooltip:{backgroundColor:"transparent",borderRadius:e.DesignToken.CornerRadius.xs,color:e.DesignToken.Color.base.white,padding:"10px",textAlign:"center"},scanCountdown:{...e.DesignToken.Typography.body,color:e.DesignToken.Color.semantic.error[400],textAlign:"center",backgroundColor:"transparent",border:"none",borderRadius:e.DesignToken.CornerRadius["2xs"],padding:"0px"},invalidPopup:{padding:"10px",title:{...e.DesignToken.Typography.h6,color:e.DesignToken.Color.content.primary,display:"none",margin:"25px 0 0 0",padding:"0 0 0 0"},description:{...e.DesignToken.Typography.body,color:e.DesignToken.Color.content.secondary,textAlign:"center",margin:"30px 0 0 0",padding:"0 0 0 0"},retryButton:{...e.DesignToken.Typography.body,color:e.DesignToken.Color.base.white,backgroundColor:e.DesignToken.Color.base.blue,borderRadius:e.DesignToken.CornerRadius.xs,border:"none",outline:"none",height:e.DesignToken.Height["3xl"],margin:"24px 0 0 0"},skipButton:{...e.DesignToken.Typography.body,color:e.DesignToken.Color.content.primary,backgroundColor:e.DesignToken.Color.background.tertiary,borderRadius:e.DesignToken.CornerRadius.xs,border:"none",outline:"none",height:e.DesignToken.Height["3xl"],margin:"12px 0"}},resultText:{success:{...e.DesignToken.Typography.body,textColor:e.DesignToken.Color.content.primary,mainColor:e.DesignToken.Color.semantic.success[400]},error:{...e.DesignToken.Typography.body,textColor:e.DesignToken.Color.content.primary,mainColor:e.DesignToken.Color.semantic.warning[500]}}}},R=m,S=D,{DesignToken:W}=e,w={FlashLiveness:{maskFill:"#fff",mask:{strokeColor:W.Color.separators.secondary,strokeColorError:W.Color.semantic.error[400],strokeWidth:4,path:"M118.5 2.5C54.2233 2.5 2.5 59.5579 2.5 129.447C2.5 146.072 3.68394 172.618 8.16415 200.483C12.6369 228.301 20.4309 257.673 33.7816 279.787C46.9667 301.626 59.6817 317.047 73.3658 327.003C87.1207 337.011 101.735 341.41 118.5 341.41C135.265 341.41 149.879 337.011 163.634 327.003C177.318 317.047 190.033 301.626 203.218 279.787C216.569 257.673 224.363 228.301 228.836 200.483C233.316 172.618 234.5 146.072 234.5 129.447C234.5 59.5579 182.777 2.5 118.5 2.5Z",width:237,height:344},title:{hidden:!1,height:"auto",color:W.Color.content.primary,fontSize:W.Typography.h5.fontSize,fontWeight:W.Typography.h5.fontWeight,lineHeight:W.Typography.h5.lineHeight},guideline:{text:{close:{color:W.Color.content.primary,fontSize:W.Typography.h6.fontSize,fontWeight:W.FontWeight["semi-bold"],background:W.Color.background.secondary,border:`${W.BorderWidth.base} solid ${W.Color.separators.tertiary}`,borderRadius:"100px",padding:"12px 16px"},far:{color:W.Color.content.primary,fontSize:W.Typography.h6.fontSize,fontWeight:W.FontWeight["semi-bold"],background:W.Color.background.secondary,border:`${W.BorderWidth.base} solid ${W.Color.separators.tertiary}`,borderRadius:"100px",padding:"12px 16px"},flashing:{color:W.Color.content["on-bg-color"],fontSize:W.Typography.label.fontSize,fontWeight:W.Typography.label.fontWeight,background:"rgba(15, 23, 42, 0.35)",border:"none",borderRadius:"100px",padding:"12px 16px"}},icon:{color:W.Color.blue[900],src:""}},instruction:{color:W.Color.content["on-bg-color"],fontSize:W.Typography.label.fontSize,fontWeight:W.Typography.label.fontWeight,background:"rgba(15, 23, 42, 0.35)",border:"none",borderRadius:"100px"},timeoutText:{color:W.Color.semantic.error[400],fontSize:W.Typography.body.fontSize,fontWeight:W.Typography.body.fontWeight,padding:"0"},errorOverlay:{backgroundColor:"transparent",opacity:0},progressBar:{mainColor:W.Color.blue[900],secondaryColor:W.Color.blue[100],textColor:W.Color.blue[900],fontSize:W.Typography.body.fontSize,fontWeight:W.FontWeight["semi-bold"]},flashing:{logo:{src:"",width:"140px",height:"auto"},backgroundPattern:{srcMobile:"",srcDesktop:"",width:"100%",height:"auto"}}}},z=w,j=w,{DesignToken:_}=e,I={Selfie:{backgroundColor:"#FFF",title:{...e.DesignToken.Typography.h5,color:e.DesignToken.Color.content.primary},countdown:{color:_.Color.semantic.error[400],fontSize:_.Typography.body.fontSize,fontWeight:_.Typography.body.fontWeight,backgroundColor:"transparent",border:"unset",borderRadius:"3px",padding:"0px"},loadingIcon:{src:"",width:"47px",height:"47px"},error:{color:_.Color.semantic.error[400],fontSize:_.Typography.body.fontSize,fontWeight:_.Typography.body.fontWeight,backgroundColor:"transparent",border:"unset",borderRadius:"3px",padding:"5px 10px"},progressCircle:{activeColor:"rgba(52, 152, 211, 1)",innerPadding:3,showDashedRing:!0,showOutsideRing:!1,dashedRingLineThick:"2",dashedRingLineSpacing:"3.5",dashedRingColor:"rgba(193, 197, 204, 1)",dashedRingOpacity:1,insideRingColor:"#fff",insideRingWidth:10,insideRingStrokeDash:"0",outsideRingOpacity:1,outsideRingColor:"#fff",errorRingWidth:0,radius:160,strokeWidth:3,progress:0,showErrorRing:!1,errorRingColor:"#df0000",dashedRingWidth:10,dashedInsideRingColor:"#fff",dashedInsideRingWidth:3,showInsideRing:!0},progressCircleV2:{activeColor:_.Color.blue[900],neutralColor:_.Color.neutral[300],errorColor:_.Color.semantic.error[400],radius:160,strokeWidth:2,progress:0,tickWidth:15,numberOfTicks:200},Active:{instruction:{color:_.Color.content.primary,fontSize:_.Typography.body.fontSize,fontWeight:_.Typography.body.fontWeight,textShadow:"none",backgroundColor:"unset",border:"unset",borderRadius:"unset"},directionIcon:{frontal:"",frontalWidth:"168px",left:"",leftWidth:"150px",right:"",rightWidth:"150px",up:"",upWidth:"150px"},imageHolder:{width:"72px",height:"72px",borderRadius:"50%",border:`3px solid ${_.Color.blue[900]}`,fontSize:"16px",color:"#fff",fontWeight:"700",frontal:"",left:"",right:"",up:"",activeStepBorder:`1px solid ${_.Color.separators.tertiary}`,activeStepBorderRadius:"50%"}}}},O={Selfie:{backgroundColor:"rgba(0, 0, 0, 0.6)",captureIcon:{src:"",width:"50px"},countdown:{color:"#fff",fontSize:"18px",fontWeight:"normal",backgroundColor:"#ea3223",border:"unset",borderRadius:"3px",padding:"5px 10px"},loadingIcon:{src:"",width:"47px",height:"47px"},error:{color:"#fff",fontSize:"18px",fontWeight:"normal",backgroundColor:"#ea3223",border:"unset",borderRadius:"3px",padding:"5px 10px"},progressCircle:{radius:160,strokeWidth:3,progress:0,showErrorRing:!0,activeColor:"#0092ff",innerPadding:5,outsideRingColor:"#f2f6f9",outsideRingOpacity:.1,insideRingColor:"#f2f6f9",insideRingWidth:1,insideRingStrokeDash:"2",errorRingColor:"#df0000",errorRingWidth:1,dashedRingColor:"#ffffff",dashedRingOpacity:.3,dashedRingWidth:10,dashedRingLineThick:1,dashedRingLineSpacing:6,dashedInsideRingColor:"#ffffff",dashedInsideRingWidth:0,showOutsideRing:!1,showDashedRing:!1,showInsideRing:!0},Active:{instruction:{color:"#fff",fontSize:"20px",fontWeight:"normal",textShadow:"2px 2px 4px #000000",backgroundColor:"unset",border:"unset",borderRadius:"unset"},directionIcon:{frontal:"",frontalWidth:"140px",left:"",leftWidth:"80px",right:"",rightWidth:"80px",up:"",upWidth:"80px"},imageHolder:{width:"40px",height:"40px",borderRadius:"50%",border:"2px solid #fff",fontSize:"16px",color:"#fff",fontWeight:"700",frontal:"",left:"",right:"",up:""}}}},A=I,{DesignToken:B}=e,P={PassiveLiveness:{instruction:{color:B.Color.content["on-bg-color"],fontSize:B.Typography.label.fontSize,fontWeight:B.Typography.label.fontWeight,background:"rgba(15, 23, 42, 0.35)",border:"none",borderRadius:"100px",backdropFilter:"blur(28px)",padding:"12px 12px"}}},F=P,q=P,U={closeButton:{top:e.DesignToken.Spacing.base,right:e.DesignToken.Spacing.base,left:"auto",bottom:"auto",display:"block",src:"",width:"24px",height:"auto"},popup:{backgroundColor:e.DesignToken.Color.base.white,padding:"10px",border:"none",borderRadius:e.DesignToken.CornerRadius.sm,overlay:{backgroundColor:e.DesignToken.Color.mask[70]},title:{...e.DesignToken.Typography.h6,fontWeight:e.DesignToken.FontWeight["semi-bold"],color:e.DesignToken.Color.content.primary,textAlign:"center",display:"initial",margin:"25px 0 0 0",padding:"0 0 0 0"},description:{...e.DesignToken.Typography.body,color:e.DesignToken.Color.content.secondary,textAlign:"center",border:"unset",borderRadius:"unset",margin:"30px 0 0 0",padding:"0 0 0 0"},primaryButton:{...e.DesignToken.Typography.body,color:e.DesignToken.Color.base.white,backgroundColor:e.DesignToken.Color.base.blue,borderRadius:e.DesignToken.CornerRadius.xs,border:"none",outline:"none",height:e.DesignToken.Height["3xl"],maxWidth:"unset"},secondaryButton:{...e.DesignToken.Typography.body,color:e.DesignToken.Color.content.primary,backgroundColor:e.DesignToken.Color.background.tertiary,borderRadius:e.DesignToken.CornerRadius.xs,border:"none",outline:"none",height:e.DesignToken.Height["3xl"],maxWidth:"unset"}}},H={v1:{...R,...z,...O,...F,...U},v2:{...S,...j,...A,...q,...U}};function $(){if(rn)return re;rn=1;var r=s();return re=function(){try{var o=r(Object,"defineProperty");return o({},"",{}),o}catch(r){}}()}function E(){if(ri)return rt;ri=1;var r=$();return rt=function(o,e,n){"__proto__"==e&&r?r(o,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):o[e]=n}}function L(){if(rs)return ra;rs=1;var r=E(),o=u();return ra=function(e,n,t){(void 0===t||o(e[n],t))&&(void 0!==t||n in e)||r(e,n,t)}}var M,V,K,N,Q,Z,G,J,X,Y,rr,ro,re,rn,rt,ri,ra,rs,ru,rd,rc,rl,rg,rf,rp,rh,rb,ry,rx,rk,rC,rT,rv,rm,rD,rR,rS,rW,rw,rz,rj,r_,rI,rO,rA,rB,rP,rF,rq,rU,rH,r$,rE,rL,rM,rV,rK,rN,rQ,rZ,rG,rJ,rX,rY,r0,r1,r2,r3,r5,r4,r6,r7,r8,r9,or,oo,oe,on,ot,oi,oa,os,ou,od,oc,ol,og,of,op,oh,ob,oy,ox,ok,oC,oT,ov,om,oD,oR,oS,oW,ow,oz,oj,o_,oI,oO,oA,oB={exports:{}};oB.exports;function oP(){return rD?rm:(rD=1,rm=function(r,o){return function(e){return r(o(e))}})}function oF(){return rS?rR:(rS=1,rR=oP()(Object.getPrototypeOf,Object))}function oq(){if(rw)return rW;rw=1;var r=Object.prototype;return rW=function(o){var e=o&&o.constructor;return o===("function"==typeof e&&e.prototype||r)}}function oU(){if(rA)return rO;rA=1;var r=function(){if(rI)return r_;rI=1;var r=l(),o=g();return r_=function(e){return o(e)&&"[object Arguments]"==r(e)}}(),o=g(),e=Object.prototype,n=e.hasOwnProperty,t=e.propertyIsEnumerable;return rO=r(function(){return arguments}())?r:function(r){return o(r)&&n.call(r,"callee")&&!t.call(r,"callee")}}function oH(){return rP?rB:(rP=1,rB=function(r){return"number"==typeof r&&r>-1&&r%1==0&&r<=0x1fffffffffffff})}function o$(){if(rq)return rF;rq=1;var r=f(),o=oH();return rF=function(e){return null!=e&&o(e.length)&&!r(e)}}var oE={exports:{}};function oL(){var r,o,e,n,t,i,a,s;if(rL)return oE.exports;return rL=1,r=oE,o=oE.exports,e=d(),n=rE?r$:(rE=1,r$=function(){return!1}),s=(a=(i=(t=o&&!o.nodeType&&o)&&r&&!r.nodeType&&r)&&i.exports===t?e.Buffer:void 0)?a.isBuffer:void 0,r.exports=s||n,oE.exports}function oM(){if(rV)return rM;rV=1;var r=l(),o=oF(),e=g(),n=Object.prototype,t=Function.prototype.toString,i=n.hasOwnProperty,a=t.call(Object);return rM=function(n){if(!e(n)||"[object Object]"!=r(n))return!1;var s=o(n);if(null===s)return!0;var u=i.call(s,"constructor")&&s.constructor;return"function"==typeof u&&u instanceof u&&t.call(u)==a}}oE.exports;var oV={exports:{}};oV.exports;function oK(){if(rX)return rJ;rX=1;var r=function(){if(rN)return rK;rN=1;var r=l(),o=oH(),e=g(),n={};return n["[object Float32Array]"]=n["[object Float64Array]"]=n["[object Int8Array]"]=n["[object Int16Array]"]=n["[object Int32Array]"]=n["[object Uint8Array]"]=n["[object Uint8ClampedArray]"]=n["[object Uint16Array]"]=n["[object Uint32Array]"]=!0,n["[object Arguments]"]=n["[object Array]"]=n["[object ArrayBuffer]"]=n["[object Boolean]"]=n["[object DataView]"]=n["[object Date]"]=n["[object Error]"]=n["[object Function]"]=n["[object Map]"]=n["[object Number]"]=n["[object Object]"]=n["[object RegExp]"]=n["[object Set]"]=n["[object String]"]=n["[object WeakMap]"]=!1,rK=function(t){return e(t)&&o(t.length)&&!!n[r(t)]}}(),o=rZ?rQ:(rZ=1,rQ=function(r){return function(o){return r(o)}}),e=function(){var r,o,e,n,t,i;if(rG)return oV.exports;return rG=1,r=oV,o=oV.exports,e=p(),i=(t=(n=o&&!o.nodeType&&o)&&r&&!r.nodeType&&r)&&t.exports===n&&e.process,r.exports=function(){try{var r=t&&t.require&&t.require("util").types;if(r)return r;return i&&i.binding&&i.binding("util")}catch(r){}}(),oV.exports}(),n=e&&e.isTypedArray;return rJ=n?o(n):r}function oN(){return r0?rY:(r0=1,rY=function(r,o){if("constructor"!==o||"function"!=typeof r[o]){if("__proto__"!=o)return r[o]}})}function oQ(){if(r5)return r3;r5=1;var r=function(){if(r2)return r1;r2=1;var r=E(),o=u(),e=Object.prototype.hasOwnProperty;return r1=function(n,t,i){var a=n[t];e.call(n,t)&&o(a,i)&&(void 0!==i||t in n)||r(n,t,i)}}(),o=E();return r3=function(e,n,t,i){var a=!t;t||(t={});for(var s=-1,u=n.length;++s<u;){var d=n[s],c=i?i(t[d],e[d],d,t,e):void 0;void 0===c&&(c=e[d]),a?o(t,d,c):r(t,d,c)}return t}}function oZ(){if(r8)return r7;r8=1;var r=/^(?:0|[1-9]\d*)$/;return r7=function(o,e){var n=typeof o;return!!(e=null==e?0x1fffffffffffff:e)&&("number"==n||"symbol"!=n&&r.test(o))&&o>-1&&o%1==0&&o<e}}function oG(){if(or)return r9;or=1;var r=r6?r4:(r6=1,r4=function(r,o){for(var e=-1,n=Array(r);++e<r;)n[e]=o(e);return n}),o=oU(),e=h(),n=oL(),t=oZ(),i=oK(),a=Object.prototype.hasOwnProperty;return r9=function(s,u){var d=e(s),c=!d&&o(s),l=!d&&!c&&n(s),g=!d&&!c&&!l&&i(s),f=d||c||l||g,p=f?r(s.length,String):[],h=p.length;for(var b in s)(u||a.call(s,b))&&!(f&&("length"==b||l&&("offset"==b||"parent"==b)||g&&("buffer"==b||"byteLength"==b||"byteOffset"==b)||t(b,h)))&&p.push(b);return p}}function oJ(){if(oa)return oi;oa=1;var r=oG(),o=function(){if(ot)return on;ot=1;var r=c(),o=oq(),e=oe?oo:(oe=1,oo=function(r){var o=[];if(null!=r)for(var e in Object(r))o.push(e);return o}),n=Object.prototype.hasOwnProperty;return on=function(t){if(!r(t))return e(t);var i=o(t),a=[];for(var s in t)"constructor"==s&&(i||!n.call(t,s))||a.push(s);return a}}(),e=o$();return oi=function(n){return e(n)?r(n,!0):o(n)}}function oX(){return op?of:(op=1,of=function(r){return r})}function oY(){return ob?oh:(ob=1,oh=function(r,o,e){switch(e.length){case 0:return r.call(o);case 1:return r.call(o,e[0]);case 2:return r.call(o,e[0],e[1]);case 3:return r.call(o,e[0],e[1],e[2])}return r.apply(o,e)})}function o0(){if(ow)return oW;ow=1;var r=oX(),o=function(){if(ox)return oy;ox=1;var r=oY(),o=Math.max;return oy=function(e,n,t){return n=o(void 0===n?e.length-1:n,0),function(){for(var i=arguments,a=-1,s=o(i.length-n,0),u=Array(s);++a<s;)u[a]=i[n+a];a=-1;for(var d=Array(n+1);++a<n;)d[a]=i[a];return d[n]=t(u),r(e,this,d)}}}(),e=function(){if(oS)return oR;oS=1;var r=function(){if(ov)return oT;ov=1;var r=oC?ok:(oC=1,ok=function(r){return function(){return r}}),o=$(),e=oX();return oT=o?function(e,n){return o(e,"toString",{configurable:!0,enumerable:!1,value:r(n),writable:!0})}:e}();return oR=(function(){if(oD)return om;oD=1;var r=Date.now;return om=function(o){var e=0,n=0;return function(){var t=r(),i=16-(t-n);if(n=t,i>0){if(++e>=800)return arguments[0]}else e=0;return o.apply(void 0,arguments)}}})()(r)}();return oW=function(n,t){return e(o(n,t,r),n+"")}}function o1(){if(oj)return oz;oj=1;var r=u(),o=o$(),e=oZ(),n=c();return oz=function(t,i,a){if(!n(a))return!1;var s=typeof i;return("number"==s?!!(o(a)&&e(i,a.length)):"string"==s&&i in a)&&r(a[i],t)}}function o2(){if(oI)return o_;oI=1;var r=o0(),o=o1();return o_=function(e){return r(function(r,n){var t=-1,i=n.length,a=i>1?n[i-1]:void 0,s=i>2?n[2]:void 0;for(a=e.length>3&&"function"==typeof a?(i--,a):void 0,s&&o(n[0],n[1],s)&&(a=i<3?void 0:a,i=1),r=Object(r);++t<i;){var u=n[t];u&&e(r,u,t,a)}return r})}}var o3=b(function(){if(oA)return oO;oA=1;var r=function(){if(og)return ol;og=1;var r=function(){if(ro)return rr;ro=1;var r=t(),o=function(){if(V)return M;V=1;var r=t();return M=function(){this.__data__=new r,this.size=0}}(),e=N?K:(N=1,K=function(r){var o=this.__data__,e=o.delete(r);return this.size=o.size,e}),n=Z?Q:(Z=1,Q=function(r){return this.__data__.get(r)}),s=J?G:(J=1,G=function(r){return this.__data__.has(r)}),u=function(){if(Y)return X;Y=1;var r=t(),o=i(),e=a();return X=function(n,t){var i=this.__data__;if(i instanceof r){var a=i.__data__;if(!o||a.length<199)return a.push([n,t]),this.size=++i.size,this;i=this.__data__=new e(a)}return i.set(n,t),this.size=i.size,this}}();function d(o){var e=this.__data__=new r(o);this.size=e.size}return d.prototype.clear=o,d.prototype.delete=e,d.prototype.get=n,d.prototype.has=s,d.prototype.set=u,rr=d}(),o=L(),e=rl?rc:(rl=1,rc=(rd?ru:(rd=1,ru=function(r){return function(o,e,n){for(var t=-1,i=Object(o),a=n(o),s=a.length;s--;){var u=a[r?s:++t];if(!1===e(i[u],u,i))break}return o}}))()),n=function(){if(oc)return od;oc=1;var r=L(),o=function(){var r,o,e,n,t,i,a;if(rg)return oB.exports;return rg=1,r=oB,o=oB.exports,e=d(),a=(i=(t=(n=o&&!o.nodeType&&o)&&r&&!r.nodeType&&r)&&t.exports===n?e.Buffer:void 0)?i.allocUnsafe:void 0,r.exports=function(r,o){if(o)return r.slice();var e=r.length,n=a?a(e):new r.constructor(e);return r.copy(n),n},oB.exports}(),e=function(){if(rx)return ry;rx=1;var r=function(){if(rb)return rh;rb=1;var r=rp?rf:(rp=1,rf=d().Uint8Array);return rh=function(o){var e=new o.constructor(o.byteLength);return new r(e).set(new r(o)),e}}();return ry=function(o,e){var n=e?r(o.buffer):o.buffer;return new o.constructor(n,o.byteOffset,o.length)}}(),n=rC?rk:(rC=1,rk=function(r,o){var e=-1,n=r.length;for(o||(o=Array(n));++e<n;)o[e]=r[e];return o}),t=function(){if(rj)return rz;rj=1;var r=function(){if(rv)return rT;rv=1;var r=c(),o=Object.create;return rT=function(){function e(){}return function(n){if(!r(n))return{};if(o)return o(n);e.prototype=n;var t=new e;return e.prototype=void 0,t}}()}(),o=oF(),e=oq();return rz=function(n){return"function"!=typeof n.constructor||e(n)?{}:r(o(n))}}(),i=oU(),a=h(),s=function(){if(rH)return rU;rH=1;var r=o$(),o=g();return rU=function(e){return o(e)&&r(e)}}(),u=oL(),l=f(),p=c(),b=oM(),y=oK(),x=oN(),k=function(){if(ou)return os;ou=1;var r=oQ(),o=oJ();return os=function(e){return r(e,o(e))}}();return od=function(d,c,g,f,h,C,T){var v=x(d,g),m=x(c,g),D=T.get(m);if(D)return void r(d,g,D);var R=C?C(v,m,g+"",d,c,T):void 0,S=void 0===R;if(S){var W=a(m),w=!W&&u(m),z=!W&&!w&&y(m);R=m,W||w||z?a(v)?R=v:s(v)?R=n(v):w?(S=!1,R=o(m,!0)):z?(S=!1,R=e(m,!0)):R=[]:b(m)||i(m)?(R=v,i(v)?R=k(v):(!p(v)||l(v))&&(R=t(m))):S=!1}S&&(T.set(m,R),h(R,m,f,C,T),T.delete(m)),r(d,g,R)}}(),s=c(),u=oJ(),l=oN();return ol=function t(i,a,d,c,g){i!==a&&e(a,function(e,u){if(g||(g=new r),s(e))n(i,a,u,d,t,c,g);else{var f=c?c(l(i,u),e,u+"",i,a,g):void 0;void 0===f&&(f=e),o(i,u,f)}},u)}}();return oO=o2()(function(o,e,n){r(o,e,n)})}());let o5=r=>{let{customTheme:e,clientSettings:n,themeVersion:t,uiSettings:i,defaultThemes:a=H}=r,s=y.getWebSetting(n,"data.settings.sdk_settings.ui_custom_settings");return o.useMemo(()=>{let r=x.selectUiSettings(i,s);return{...o3({},x.mapUISettingsToCustomTheme(r),e),themeVersion:t,defaultThemes:a}},[e,a,t,i,s])},o4=()=>{},o6=o.createContext({onDoneCallback:o4,onErrorCallback:o4,onCloseCallback:o4}),o7=({children:e,onDone:n=o4,onError:t=o4,onClose:i=o4})=>{let a=o.useCallback(r=>{n&&n(r)},[n]),s=o.useCallback(r=>{t&&t(r)},[t]),u=o.useCallback(()=>{i&&i()},[i]),d=o.useMemo(()=>({onDoneCallback:a,onErrorCallback:s,onCloseCallback:u}),[a,s,u]);return r.jsx(o6.Provider,{value:d,children:e})},o8=()=>{let r=o.useContext(o6);if(void 0===r)throw Error("useSDKCallback must be used within a SDKCallbackProvider");return r},o9=o.createContext(""),er=({children:o,isWrappedBy:e=""})=>r.jsx(o9.Provider,{value:e,children:o}),eo=()=>o.useContext(o9);export{C as D,o7 as S,er as W,D as a,T as b,eo as c,H as d,o5 as e,o2 as f,oJ as g,oM as h,o0 as i,oY as j,oP as k,oq as l,o3 as m,oG as n,o$ as o,o1 as p,oQ as r,v as t,o8 as u};
1
+ import{j as r,r as o,s as e,a2 as n,ac as t,ad as i,ae as a,af as s,ag as u,ah as d,ai as c,aj as l,ak as g,al as f,am as p,an as h,$ as b,u as y,ao as x}from"./chunk-c747321c.js";let k=o.createContext(!1),C=({children:o,debug:e=!1})=>r.jsx(k.Provider,{value:e,children:o}),T=()=>o.useContext(k),v={tsBlue:"#0276f1",tsSecondary:"rgba(0, 47, 117, 0.6)"},m={IDCapturing:{backgroundColor:"rgba(0, 0, 0, 0.6)",titleFront:{color:"#fff",fontSize:"20px",fontWeight:"normal",backgroundColor:"unset"},titleBack:{color:"#fff",fontSize:"20px",fontWeight:"normal",backgroundColor:"unset"},instruction:{padding:"unset",color:"#fff",fontSize:"16px",fontWeight:"normal",backgroundColor:"unset",border:"unset",borderRadius:"unset"},captureInstruction:{capturing:{padding:"12px 12px",color:"#ffffff",fontSize:"14px",fontWeight:"normal",background:"rgba(15, 23, 42, 0.25)",border:"none",borderRadius:"100px"},captured:{padding:"12px 12px",color:"#ffffff",fontSize:"14px",fontWeight:"normal",background:"rgba(15, 23, 42, 0.25)",border:"none",borderRadius:"100px"}},error:{padding:"5px 10px",color:"#fff",fontSize:"16px",fontWeight:"normal",backgroundColor:"#ea3223",border:"unset",borderRadius:"3px"},toggle:{color:"#d1d1d1",fontSize:"16px",fontWeight:"500",gap:"16px",backgroundColor:"#fff",active:{backgroundColor:"#2196f3"},inactive:{backgroundColor:"#ccc"}},countdown:{color:"#fff",fontSize:"18px",fontWeight:"normal",backgroundColor:"#ea3223",border:"unset",borderRadius:"3px"},cardIcon:{src:"",width:"auto",height:"38px"},captureIcon:{src:"",width:"60px",height:"60px",disabled:{src:""}},loadingIcon:{src:"",width:"100px",height:"100px"},rectangleMask:{width:600,height:400,strokeWidth:2,strokeStyles:{},radius:10,paddingStyle:{fill:"rgba(0, 0, 0, 0.6)"},default:{fill:"none",stroke:"#fff",strokeWidth:2,strokeDasharray:"7, 4",opacity:.6},error:{fill:"rgba(234,50,35, 0.1)",strokeWidth:2,stroke:"#ea3223"}}},IDConfirmPopup:{image:{borderRadius:"5px"}},IDUploadButton:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.25)",borderRadius:"8px",color:"#ffffff",padding:"12px",leftOffset:"24px",focusOutlineColor:"#ffffff"},IDUploadErrorToast:{background:"rgba(0, 0, 0, 0.75)",color:"#ffffff",borderRadius:"8px",fontSize:"14px",padding:"10px 16px",maxWidthInset:"48px"},QRStep:{title:{color:"#fff",fontSize:"20px",fontWeight:"700",backgroundColor:"unset"},guidelinePopup:{image:{src:"",borderRadius:"5px",backgroundColor:"#e7e6e6"},guideText:{color:v.tsSecondary,fontSize:"16px",fontWeight:"normal",textAlign:"center",lineHeight:"20px"},countdownText:{color:v.tsSecondary,fontSize:"16px",fontWeight:"normal",textAlign:"center",lineHeight:"20px"}},scanTooltip:{backgroundColor:"#00ce78",borderRadius:"8px",color:"#fff",padding:"10px",textAlign:"center"},scanCountdown:{textAlign:"center",color:"#fff",fontSize:"18px",fontWeight:"normal",backgroundColor:"#ea3223",border:"none",borderRadius:"3px",padding:"5px 10px"},invalidPopup:{padding:"10px",title:{display:"block",color:v.tsSecondary,fontSize:"16px",fontWeight:"bold",margin:"25px 0 0 0",padding:"0 0 0 0"},description:{color:v.tsSecondary,fontSize:"16px",fontWeight:"normal",textAlign:"center",margin:"30px 0 0 0",padding:"0 0 0 0"},retryButton:{color:"#fff",fontSize:"1rem",fontWeight:"normal",backgroundColor:v.tsBlue,border:"none",borderRadius:"3px",outline:"none",height:"66px",margin:"30px 0 0 0"},skipButton:{color:v.tsBlue,fontSize:"1rem",fontWeight:"normal",backgroundColor:"unset",border:"none",borderRadius:"unset",outline:"none",height:"unset",margin:"20px 0"}},resultText:{success:{textColor:"#000",fontSize:"1rem",fontWeight:"normal",mainColor:"#34ce60"},error:{textColor:"#000",fontSize:"1rem",fontWeight:"normal",mainColor:"#ff9532"}}}},D={IDCapturing:{backgroundColor:"rgba(0, 0, 0, 0.6)",titleFront:{...e.DesignToken.Typography.h4,color:e.DesignToken.Color.base.white,backgroundColor:"unset"},titleBack:{...e.DesignToken.Typography.h4,color:e.DesignToken.Color.base.white,backgroundColor:"unset"},instruction:{...e.DesignToken.Typography.body,padding:"5px 10px",color:"rgba(255, 255, 255, 0.8)",backgroundColor:"unset",border:"unset",borderRadius:"unset"},captureInstruction:{capturing:{...e.DesignToken.Typography.label,color:e.DesignToken.Color.base.white,padding:`6px ${e.DesignToken.Spacing.sm}`,background:"rgba(15, 23, 42, 0.35)",border:"none",borderRadius:"100px"},captured:{...e.DesignToken.Typography.label,color:e.DesignToken.Color.base.white,padding:`6px ${e.DesignToken.Spacing.sm}`,background:"rgba(15, 23, 42, 0.35)",border:"none",borderRadius:"100px"}},error:{...e.DesignToken.Typography.body,padding:"5px 10px",color:e.DesignToken.Color.semantic.error[400],backgroundColor:"transparent",border:"unset",borderRadius:e.DesignToken.CornerRadius["2xs"]},toggle:{...e.DesignToken.Typography.body,color:e.DesignToken.Color.base.white,gap:e.DesignToken.Spacing.base,backgroundColor:e.DesignToken.Color.base.white,active:{backgroundColor:e.DesignToken.Color.base.blue},inactive:{backgroundColor:e.DesignToken.Color.neutral[300]}},countdown:{...e.DesignToken.Typography.body,color:e.DesignToken.Color.semantic.error[400],backgroundColor:"transparent",border:"unset",borderRadius:e.DesignToken.CornerRadius["2xs"]},cardIcon:{src:"",width:"auto",height:"38px"},captureIcon:{src:"",width:e.DesignToken.Height["7xl"],height:e.DesignToken.Height["7xl"],disabled:{src:""}},loadingIcon:{src:"",width:"47px",height:"47px"},rectangleMask:{width:600,height:400,strokeWidth:n.getCSSNumericValue(e.DesignToken.BorderWidth["3xl"]),strokeStyles:{},radius:n.getCSSNumericValue(e.DesignToken.CornerRadius.base),paddingStyle:{fill:"rgba(0, 0, 0, 0.6)"},default:{fill:"none",stroke:e.DesignToken.Color.neutral[400],strokeWidth:n.getCSSNumericValue(e.DesignToken.BorderWidth["3xl"])},error:{fill:"none",strokeWidth:n.getCSSNumericValue(e.DesignToken.BorderWidth["3xl"]),stroke:e.DesignToken.Color.semantic.error[400]}}},IDConfirmPopup:{image:{borderRadius:e.DesignToken.CornerRadius["2xs"]}},IDUploadButton:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.25)",borderRadius:e.DesignToken.CornerRadius.xs,color:e.DesignToken.Color.base.white,padding:e.DesignToken.Spacing.sm,leftOffset:"24px",focusOutlineColor:e.DesignToken.Color.base.white},IDUploadErrorToast:{background:"rgba(0, 0, 0, 0.75)",color:e.DesignToken.Color.base.white,borderRadius:e.DesignToken.CornerRadius.xs,fontSize:"14px",padding:"10px 16px",maxWidthInset:"48px"},QRStep:{title:{...e.DesignToken.Typography.h4,backgroundColor:"unset"},guidelinePopup:{image:{src:"",borderRadius:e.DesignToken.CornerRadius["2xs"],backgroundColor:"transparent"},guideText:{...e.DesignToken.Typography.body,color:e.DesignToken.Color.neutral[600],textAlign:"center"},countdownText:{...e.DesignToken.UIText.medium,color:e.DesignToken.Color.neutral[500],textAlign:"center"}},scanTooltip:{backgroundColor:"transparent",borderRadius:e.DesignToken.CornerRadius.xs,color:e.DesignToken.Color.base.white,padding:"10px",textAlign:"center"},scanCountdown:{...e.DesignToken.Typography.body,color:e.DesignToken.Color.semantic.error[400],textAlign:"center",backgroundColor:"transparent",border:"none",borderRadius:e.DesignToken.CornerRadius["2xs"],padding:"0px"},invalidPopup:{padding:"10px",title:{...e.DesignToken.Typography.h6,color:e.DesignToken.Color.content.primary,display:"none",margin:"25px 0 0 0",padding:"0 0 0 0"},description:{...e.DesignToken.Typography.body,color:e.DesignToken.Color.content.secondary,textAlign:"center",margin:"30px 0 0 0",padding:"0 0 0 0"},retryButton:{...e.DesignToken.Typography.body,color:e.DesignToken.Color.base.white,backgroundColor:e.DesignToken.Color.base.blue,borderRadius:e.DesignToken.CornerRadius.xs,border:"none",outline:"none",height:e.DesignToken.Height["3xl"],margin:"24px 0 0 0"},skipButton:{...e.DesignToken.Typography.body,color:e.DesignToken.Color.content.primary,backgroundColor:e.DesignToken.Color.background.tertiary,borderRadius:e.DesignToken.CornerRadius.xs,border:"none",outline:"none",height:e.DesignToken.Height["3xl"],margin:"12px 0"}},resultText:{success:{...e.DesignToken.Typography.body,textColor:e.DesignToken.Color.content.primary,mainColor:e.DesignToken.Color.semantic.success[400]},error:{...e.DesignToken.Typography.body,textColor:e.DesignToken.Color.content.primary,mainColor:e.DesignToken.Color.semantic.warning[500]}}}},R=m,S=D,{DesignToken:W}=e,w={FlashLiveness:{maskFill:"#fff",mask:{strokeColor:W.Color.separators.secondary,strokeColorError:W.Color.semantic.error[400],strokeWidth:4,path:"M118.5 2.5C54.2233 2.5 2.5 59.5579 2.5 129.447C2.5 146.072 3.68394 172.618 8.16415 200.483C12.6369 228.301 20.4309 257.673 33.7816 279.787C46.9667 301.626 59.6817 317.047 73.3658 327.003C87.1207 337.011 101.735 341.41 118.5 341.41C135.265 341.41 149.879 337.011 163.634 327.003C177.318 317.047 190.033 301.626 203.218 279.787C216.569 257.673 224.363 228.301 228.836 200.483C233.316 172.618 234.5 146.072 234.5 129.447C234.5 59.5579 182.777 2.5 118.5 2.5Z",width:237,height:344},title:{hidden:!1,height:"auto",color:W.Color.content.primary,fontSize:W.Typography.h5.fontSize,fontWeight:W.Typography.h5.fontWeight,lineHeight:W.Typography.h5.lineHeight},guideline:{text:{close:{color:W.Color.content.primary,fontSize:W.Typography.h6.fontSize,fontWeight:W.FontWeight["semi-bold"],background:W.Color.background.secondary,border:`${W.BorderWidth.base} solid ${W.Color.separators.tertiary}`,borderRadius:"100px",padding:"12px 16px"},far:{color:W.Color.content.primary,fontSize:W.Typography.h6.fontSize,fontWeight:W.FontWeight["semi-bold"],background:W.Color.background.secondary,border:`${W.BorderWidth.base} solid ${W.Color.separators.tertiary}`,borderRadius:"100px",padding:"12px 16px"},flashing:{color:W.Color.content["on-bg-color"],fontSize:W.Typography.label.fontSize,fontWeight:W.Typography.label.fontWeight,background:"rgba(15, 23, 42, 0.35)",border:"none",borderRadius:"100px",padding:"12px 16px"}},icon:{color:W.Color.blue[900],src:""}},instruction:{color:W.Color.content["on-bg-color"],fontSize:W.Typography.label.fontSize,fontWeight:W.Typography.label.fontWeight,background:"rgba(15, 23, 42, 0.35)",border:"none",borderRadius:"100px"},timeoutText:{color:W.Color.semantic.error[400],fontSize:W.Typography.body.fontSize,fontWeight:W.Typography.body.fontWeight,padding:"0"},errorOverlay:{backgroundColor:"transparent",opacity:0},progressBar:{mainColor:W.Color.blue[900],secondaryColor:W.Color.blue[100],textColor:W.Color.blue[900],fontSize:W.Typography.body.fontSize,fontWeight:W.FontWeight["semi-bold"]},flashing:{logo:{src:"",width:"140px",height:"auto"},backgroundPattern:{srcMobile:"",srcDesktop:"",width:"100%",height:"auto"}}}},z=w,j=w,{DesignToken:_}=e,I={Selfie:{backgroundColor:"#FFF",title:{...e.DesignToken.Typography.h5,color:e.DesignToken.Color.content.primary},countdown:{color:_.Color.semantic.error[400],fontSize:_.Typography.body.fontSize,fontWeight:_.Typography.body.fontWeight,backgroundColor:"transparent",border:"unset",borderRadius:"3px",padding:"0px"},loadingIcon:{src:"",width:"47px",height:"47px"},error:{color:_.Color.semantic.error[400],fontSize:_.Typography.body.fontSize,fontWeight:_.Typography.body.fontWeight,backgroundColor:"transparent",border:"unset",borderRadius:"3px",padding:"5px 10px"},progressCircle:{activeColor:"rgba(52, 152, 211, 1)",innerPadding:3,showDashedRing:!0,showOutsideRing:!1,dashedRingLineThick:"2",dashedRingLineSpacing:"3.5",dashedRingColor:"rgba(193, 197, 204, 1)",dashedRingOpacity:1,insideRingColor:"#fff",insideRingWidth:10,insideRingStrokeDash:"0",outsideRingOpacity:1,outsideRingColor:"#fff",errorRingWidth:0,radius:160,strokeWidth:3,progress:0,showErrorRing:!1,errorRingColor:"#df0000",dashedRingWidth:10,dashedInsideRingColor:"#fff",dashedInsideRingWidth:3,showInsideRing:!0},progressCircleV2:{activeColor:_.Color.blue[900],neutralColor:_.Color.neutral[300],errorColor:_.Color.semantic.error[400],radius:160,strokeWidth:2,progress:0,tickWidth:15,numberOfTicks:200},Active:{instruction:{color:_.Color.content.primary,fontSize:_.Typography.body.fontSize,fontWeight:_.Typography.body.fontWeight,textShadow:"none",backgroundColor:"unset",border:"unset",borderRadius:"unset"},directionIcon:{frontal:"",frontalWidth:"168px",left:"",leftWidth:"150px",right:"",rightWidth:"150px",up:"",upWidth:"150px"},imageHolder:{width:"72px",height:"72px",borderRadius:"50%",border:`3px solid ${_.Color.blue[900]}`,fontSize:"16px",color:"#fff",fontWeight:"700",frontal:"",left:"",right:"",up:"",activeStepBorder:`1px solid ${_.Color.separators.tertiary}`,activeStepBorderRadius:"50%"}}}},O={Selfie:{backgroundColor:"rgba(0, 0, 0, 0.6)",captureIcon:{src:"",width:"50px"},countdown:{color:"#fff",fontSize:"18px",fontWeight:"normal",backgroundColor:"#ea3223",border:"unset",borderRadius:"3px",padding:"5px 10px"},loadingIcon:{src:"",width:"47px",height:"47px"},error:{color:"#fff",fontSize:"18px",fontWeight:"normal",backgroundColor:"#ea3223",border:"unset",borderRadius:"3px",padding:"5px 10px"},progressCircle:{radius:160,strokeWidth:3,progress:0,showErrorRing:!0,activeColor:"#0092ff",innerPadding:5,outsideRingColor:"#f2f6f9",outsideRingOpacity:.1,insideRingColor:"#f2f6f9",insideRingWidth:1,insideRingStrokeDash:"2",errorRingColor:"#df0000",errorRingWidth:1,dashedRingColor:"#ffffff",dashedRingOpacity:.3,dashedRingWidth:10,dashedRingLineThick:1,dashedRingLineSpacing:6,dashedInsideRingColor:"#ffffff",dashedInsideRingWidth:0,showOutsideRing:!1,showDashedRing:!1,showInsideRing:!0},Active:{instruction:{color:"#fff",fontSize:"20px",fontWeight:"normal",textShadow:"2px 2px 4px #000000",backgroundColor:"unset",border:"unset",borderRadius:"unset"},directionIcon:{frontal:"",frontalWidth:"140px",left:"",leftWidth:"80px",right:"",rightWidth:"80px",up:"",upWidth:"80px"},imageHolder:{width:"40px",height:"40px",borderRadius:"50%",border:"2px solid #fff",fontSize:"16px",color:"#fff",fontWeight:"700",frontal:"",left:"",right:"",up:""}}}},A=I,{DesignToken:B}=e,P={PassiveLiveness:{instruction:{color:B.Color.content["on-bg-color"],fontSize:B.Typography.label.fontSize,fontWeight:B.Typography.label.fontWeight,background:"rgba(15, 23, 42, 0.35)",border:"none",borderRadius:"100px",backdropFilter:"blur(28px)",padding:"12px 12px"}}},F=P,q=P,U={closeButton:{top:e.DesignToken.Spacing.base,right:e.DesignToken.Spacing.base,left:"auto",bottom:"auto",display:"block",src:"",width:"24px",height:"auto"},popup:{backgroundColor:e.DesignToken.Color.base.white,padding:"10px",border:"none",borderRadius:e.DesignToken.CornerRadius.sm,overlay:{backgroundColor:e.DesignToken.Color.mask[70]},title:{...e.DesignToken.Typography.h6,fontWeight:e.DesignToken.FontWeight["semi-bold"],color:e.DesignToken.Color.content.primary,textAlign:"center",display:"initial",margin:"25px 0 0 0",padding:"0 0 0 0"},description:{...e.DesignToken.Typography.body,color:e.DesignToken.Color.content.secondary,textAlign:"center",border:"unset",borderRadius:"unset",margin:"30px 0 0 0",padding:"0 0 0 0"},primaryButton:{...e.DesignToken.Typography.body,color:e.DesignToken.Color.base.white,backgroundColor:e.DesignToken.Color.base.blue,borderRadius:e.DesignToken.CornerRadius.xs,border:"none",outline:"none",height:e.DesignToken.Height["3xl"],maxWidth:"unset"},secondaryButton:{...e.DesignToken.Typography.body,color:e.DesignToken.Color.content.primary,backgroundColor:e.DesignToken.Color.background.tertiary,borderRadius:e.DesignToken.CornerRadius.xs,border:"none",outline:"none",height:e.DesignToken.Height["3xl"],maxWidth:"unset"}}},H={v1:{...R,...z,...O,...F,...U},v2:{...S,...j,...A,...q,...U}};function $(){if(rn)return re;rn=1;var r=s();return re=function(){try{var o=r(Object,"defineProperty");return o({},"",{}),o}catch(r){}}()}function E(){if(ri)return rt;ri=1;var r=$();return rt=function(o,e,n){"__proto__"==e&&r?r(o,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):o[e]=n}}function L(){if(rs)return ra;rs=1;var r=E(),o=u();return ra=function(e,n,t){(void 0===t||o(e[n],t))&&(void 0!==t||n in e)||r(e,n,t)}}var M,V,K,N,Q,Z,G,J,X,Y,rr,ro,re,rn,rt,ri,ra,rs,ru,rd,rc,rl,rg,rf,rp,rh,rb,ry,rx,rk,rC,rT,rv,rm,rD,rR,rS,rW,rw,rz,rj,r_,rI,rO,rA,rB,rP,rF,rq,rU,rH,r$,rE,rL,rM,rV,rK,rN,rQ,rZ,rG,rJ,rX,rY,r0,r1,r2,r3,r5,r4,r6,r7,r8,r9,or,oo,oe,on,ot,oi,oa,os,ou,od,oc,ol,og,of,op,oh,ob,oy,ox,ok,oC,oT,ov,om,oD,oR,oS,oW,ow,oz,oj,o_,oI,oO,oA,oB={exports:{}};oB.exports;function oP(){return rD?rm:(rD=1,rm=function(r,o){return function(e){return r(o(e))}})}function oF(){return rS?rR:(rS=1,rR=oP()(Object.getPrototypeOf,Object))}function oq(){if(rw)return rW;rw=1;var r=Object.prototype;return rW=function(o){var e=o&&o.constructor;return o===("function"==typeof e&&e.prototype||r)}}function oU(){if(rA)return rO;rA=1;var r=function(){if(rI)return r_;rI=1;var r=l(),o=g();return r_=function(e){return o(e)&&"[object Arguments]"==r(e)}}(),o=g(),e=Object.prototype,n=e.hasOwnProperty,t=e.propertyIsEnumerable;return rO=r(function(){return arguments}())?r:function(r){return o(r)&&n.call(r,"callee")&&!t.call(r,"callee")}}function oH(){return rP?rB:(rP=1,rB=function(r){return"number"==typeof r&&r>-1&&r%1==0&&r<=0x1fffffffffffff})}function o$(){if(rq)return rF;rq=1;var r=f(),o=oH();return rF=function(e){return null!=e&&o(e.length)&&!r(e)}}var oE={exports:{}};function oL(){var r,o,e,n,t,i,a,s;if(rL)return oE.exports;return rL=1,r=oE,o=oE.exports,e=d(),n=rE?r$:(rE=1,r$=function(){return!1}),s=(a=(i=(t=o&&!o.nodeType&&o)&&r&&!r.nodeType&&r)&&i.exports===t?e.Buffer:void 0)?a.isBuffer:void 0,r.exports=s||n,oE.exports}function oM(){if(rV)return rM;rV=1;var r=l(),o=oF(),e=g(),n=Object.prototype,t=Function.prototype.toString,i=n.hasOwnProperty,a=t.call(Object);return rM=function(n){if(!e(n)||"[object Object]"!=r(n))return!1;var s=o(n);if(null===s)return!0;var u=i.call(s,"constructor")&&s.constructor;return"function"==typeof u&&u instanceof u&&t.call(u)==a}}oE.exports;var oV={exports:{}};oV.exports;function oK(){if(rX)return rJ;rX=1;var r=function(){if(rN)return rK;rN=1;var r=l(),o=oH(),e=g(),n={};return n["[object Float32Array]"]=n["[object Float64Array]"]=n["[object Int8Array]"]=n["[object Int16Array]"]=n["[object Int32Array]"]=n["[object Uint8Array]"]=n["[object Uint8ClampedArray]"]=n["[object Uint16Array]"]=n["[object Uint32Array]"]=!0,n["[object Arguments]"]=n["[object Array]"]=n["[object ArrayBuffer]"]=n["[object Boolean]"]=n["[object DataView]"]=n["[object Date]"]=n["[object Error]"]=n["[object Function]"]=n["[object Map]"]=n["[object Number]"]=n["[object Object]"]=n["[object RegExp]"]=n["[object Set]"]=n["[object String]"]=n["[object WeakMap]"]=!1,rK=function(t){return e(t)&&o(t.length)&&!!n[r(t)]}}(),o=rZ?rQ:(rZ=1,rQ=function(r){return function(o){return r(o)}}),e=function(){var r,o,e,n,t,i;if(rG)return oV.exports;return rG=1,r=oV,o=oV.exports,e=p(),i=(t=(n=o&&!o.nodeType&&o)&&r&&!r.nodeType&&r)&&t.exports===n&&e.process,r.exports=function(){try{var r=t&&t.require&&t.require("util").types;if(r)return r;return i&&i.binding&&i.binding("util")}catch(r){}}(),oV.exports}(),n=e&&e.isTypedArray;return rJ=n?o(n):r}function oN(){return r0?rY:(r0=1,rY=function(r,o){if("constructor"!==o||"function"!=typeof r[o]){if("__proto__"!=o)return r[o]}})}function oQ(){if(r5)return r3;r5=1;var r=function(){if(r2)return r1;r2=1;var r=E(),o=u(),e=Object.prototype.hasOwnProperty;return r1=function(n,t,i){var a=n[t];e.call(n,t)&&o(a,i)&&(void 0!==i||t in n)||r(n,t,i)}}(),o=E();return r3=function(e,n,t,i){var a=!t;t||(t={});for(var s=-1,u=n.length;++s<u;){var d=n[s],c=i?i(t[d],e[d],d,t,e):void 0;void 0===c&&(c=e[d]),a?o(t,d,c):r(t,d,c)}return t}}function oZ(){if(r8)return r7;r8=1;var r=/^(?:0|[1-9]\d*)$/;return r7=function(o,e){var n=typeof o;return!!(e=null==e?0x1fffffffffffff:e)&&("number"==n||"symbol"!=n&&r.test(o))&&o>-1&&o%1==0&&o<e}}function oG(){if(or)return r9;or=1;var r=r6?r4:(r6=1,r4=function(r,o){for(var e=-1,n=Array(r);++e<r;)n[e]=o(e);return n}),o=oU(),e=h(),n=oL(),t=oZ(),i=oK(),a=Object.prototype.hasOwnProperty;return r9=function(s,u){var d=e(s),c=!d&&o(s),l=!d&&!c&&n(s),g=!d&&!c&&!l&&i(s),f=d||c||l||g,p=f?r(s.length,String):[],h=p.length;for(var b in s)(u||a.call(s,b))&&!(f&&("length"==b||l&&("offset"==b||"parent"==b)||g&&("buffer"==b||"byteLength"==b||"byteOffset"==b)||t(b,h)))&&p.push(b);return p}}function oJ(){if(oa)return oi;oa=1;var r=oG(),o=function(){if(ot)return on;ot=1;var r=c(),o=oq(),e=oe?oo:(oe=1,oo=function(r){var o=[];if(null!=r)for(var e in Object(r))o.push(e);return o}),n=Object.prototype.hasOwnProperty;return on=function(t){if(!r(t))return e(t);var i=o(t),a=[];for(var s in t)"constructor"==s&&(i||!n.call(t,s))||a.push(s);return a}}(),e=o$();return oi=function(n){return e(n)?r(n,!0):o(n)}}function oX(){return op?of:(op=1,of=function(r){return r})}function oY(){return ob?oh:(ob=1,oh=function(r,o,e){switch(e.length){case 0:return r.call(o);case 1:return r.call(o,e[0]);case 2:return r.call(o,e[0],e[1]);case 3:return r.call(o,e[0],e[1],e[2])}return r.apply(o,e)})}function o0(){if(ow)return oW;ow=1;var r=oX(),o=function(){if(ox)return oy;ox=1;var r=oY(),o=Math.max;return oy=function(e,n,t){return n=o(void 0===n?e.length-1:n,0),function(){for(var i=arguments,a=-1,s=o(i.length-n,0),u=Array(s);++a<s;)u[a]=i[n+a];a=-1;for(var d=Array(n+1);++a<n;)d[a]=i[a];return d[n]=t(u),r(e,this,d)}}}(),e=function(){if(oS)return oR;oS=1;var r=function(){if(ov)return oT;ov=1;var r=oC?ok:(oC=1,ok=function(r){return function(){return r}}),o=$(),e=oX();return oT=o?function(e,n){return o(e,"toString",{configurable:!0,enumerable:!1,value:r(n),writable:!0})}:e}();return oR=(function(){if(oD)return om;oD=1;var r=Date.now;return om=function(o){var e=0,n=0;return function(){var t=r(),i=16-(t-n);if(n=t,i>0){if(++e>=800)return arguments[0]}else e=0;return o.apply(void 0,arguments)}}})()(r)}();return oW=function(n,t){return e(o(n,t,r),n+"")}}function o1(){if(oj)return oz;oj=1;var r=u(),o=o$(),e=oZ(),n=c();return oz=function(t,i,a){if(!n(a))return!1;var s=typeof i;return("number"==s?!!(o(a)&&e(i,a.length)):"string"==s&&i in a)&&r(a[i],t)}}function o2(){if(oI)return o_;oI=1;var r=o0(),o=o1();return o_=function(e){return r(function(r,n){var t=-1,i=n.length,a=i>1?n[i-1]:void 0,s=i>2?n[2]:void 0;for(a=e.length>3&&"function"==typeof a?(i--,a):void 0,s&&o(n[0],n[1],s)&&(a=i<3?void 0:a,i=1),r=Object(r);++t<i;){var u=n[t];u&&e(r,u,t,a)}return r})}}var o3=b(function(){if(oA)return oO;oA=1;var r=function(){if(og)return ol;og=1;var r=function(){if(ro)return rr;ro=1;var r=t(),o=function(){if(V)return M;V=1;var r=t();return M=function(){this.__data__=new r,this.size=0}}(),e=N?K:(N=1,K=function(r){var o=this.__data__,e=o.delete(r);return this.size=o.size,e}),n=Z?Q:(Z=1,Q=function(r){return this.__data__.get(r)}),s=J?G:(J=1,G=function(r){return this.__data__.has(r)}),u=function(){if(Y)return X;Y=1;var r=t(),o=i(),e=a();return X=function(n,t){var i=this.__data__;if(i instanceof r){var a=i.__data__;if(!o||a.length<199)return a.push([n,t]),this.size=++i.size,this;i=this.__data__=new e(a)}return i.set(n,t),this.size=i.size,this}}();function d(o){var e=this.__data__=new r(o);this.size=e.size}return d.prototype.clear=o,d.prototype.delete=e,d.prototype.get=n,d.prototype.has=s,d.prototype.set=u,rr=d}(),o=L(),e=rl?rc:(rl=1,rc=(rd?ru:(rd=1,ru=function(r){return function(o,e,n){for(var t=-1,i=Object(o),a=n(o),s=a.length;s--;){var u=a[r?s:++t];if(!1===e(i[u],u,i))break}return o}}))()),n=function(){if(oc)return od;oc=1;var r=L(),o=function(){var r,o,e,n,t,i,a;if(rg)return oB.exports;return rg=1,r=oB,o=oB.exports,e=d(),a=(i=(t=(n=o&&!o.nodeType&&o)&&r&&!r.nodeType&&r)&&t.exports===n?e.Buffer:void 0)?i.allocUnsafe:void 0,r.exports=function(r,o){if(o)return r.slice();var e=r.length,n=a?a(e):new r.constructor(e);return r.copy(n),n},oB.exports}(),e=function(){if(rx)return ry;rx=1;var r=function(){if(rb)return rh;rb=1;var r=rp?rf:(rp=1,rf=d().Uint8Array);return rh=function(o){var e=new o.constructor(o.byteLength);return new r(e).set(new r(o)),e}}();return ry=function(o,e){var n=e?r(o.buffer):o.buffer;return new o.constructor(n,o.byteOffset,o.length)}}(),n=rC?rk:(rC=1,rk=function(r,o){var e=-1,n=r.length;for(o||(o=Array(n));++e<n;)o[e]=r[e];return o}),t=function(){if(rj)return rz;rj=1;var r=function(){if(rv)return rT;rv=1;var r=c(),o=Object.create;return rT=function(){function e(){}return function(n){if(!r(n))return{};if(o)return o(n);e.prototype=n;var t=new e;return e.prototype=void 0,t}}()}(),o=oF(),e=oq();return rz=function(n){return"function"!=typeof n.constructor||e(n)?{}:r(o(n))}}(),i=oU(),a=h(),s=function(){if(rH)return rU;rH=1;var r=o$(),o=g();return rU=function(e){return o(e)&&r(e)}}(),u=oL(),l=f(),p=c(),b=oM(),y=oK(),x=oN(),k=function(){if(ou)return os;ou=1;var r=oQ(),o=oJ();return os=function(e){return r(e,o(e))}}();return od=function(d,c,g,f,h,C,T){var v=x(d,g),m=x(c,g),D=T.get(m);if(D)return void r(d,g,D);var R=C?C(v,m,g+"",d,c,T):void 0,S=void 0===R;if(S){var W=a(m),w=!W&&u(m),z=!W&&!w&&y(m);R=m,W||w||z?a(v)?R=v:s(v)?R=n(v):w?(S=!1,R=o(m,!0)):z?(S=!1,R=e(m,!0)):R=[]:b(m)||i(m)?(R=v,i(v)?R=k(v):(!p(v)||l(v))&&(R=t(m))):S=!1}S&&(T.set(m,R),h(R,m,f,C,T),T.delete(m)),r(d,g,R)}}(),s=c(),u=oJ(),l=oN();return ol=function t(i,a,d,c,g){i!==a&&e(a,function(e,u){if(g||(g=new r),s(e))n(i,a,u,d,t,c,g);else{var f=c?c(l(i,u),e,u+"",i,a,g):void 0;void 0===f&&(f=e),o(i,u,f)}},u)}}();return oO=o2()(function(o,e,n){r(o,e,n)})}());let o5=r=>{let{customTheme:e,clientSettings:n,themeVersion:t,uiSettings:i,defaultThemes:a=H}=r,s=y.getWebSetting(n,"data.settings.sdk_settings.ui_custom_settings");return o.useMemo(()=>{let r=x.selectUiSettings(i,s);return{...o3({},x.mapUISettingsToCustomTheme(r),e),themeVersion:t,defaultThemes:a}},[e,a,t,i,s])},o4=()=>{},o6=o.createContext({onDoneCallback:o4,onErrorCallback:o4,onCloseCallback:o4}),o7=({children:e,onDone:n=o4,onError:t=o4,onClose:i=o4})=>{let a=o.useCallback(r=>{n&&n(r)},[n]),s=o.useCallback(r=>{t&&t(r)},[t]),u=o.useCallback(()=>{i&&i()},[i]),d=o.useMemo(()=>({onDoneCallback:a,onErrorCallback:s,onCloseCallback:u}),[a,s,u]);return r.jsx(o6.Provider,{value:d,children:e})},o8=()=>{let r=o.useContext(o6);if(void 0===r)throw Error("useSDKCallback must be used within a SDKCallbackProvider");return r},o9=o.createContext(""),er=({children:o,isWrappedBy:e=""})=>r.jsx(o9.Provider,{value:e,children:o}),eo=()=>o.useContext(o9);export{C as D,o7 as S,er as W,D as a,T as b,eo as c,H as d,o5 as e,o2 as f,oJ as g,oM as h,o0 as i,oY as j,oP as k,oq as l,o3 as m,oG as n,o$ as o,o1 as p,oQ as r,v as t,o8 as u};
@@ -1 +1 @@
1
- let e;import{d as t,r as s,j as n,a as i,aa as l,c as r,a9 as a,ab as o,o as c,u as u,g as g,p as d,s as S,e as h,Y as v}from"./chunk-d315aa24.js";import{e as f,d as j,c as p,D as b,S as x}from"./chunk-0da61929.js";let k=s.createContext({}),y={},C=({children:e,enableGetClientSettings:i,clientSettings:l,apiCredentials:r,flowId:a})=>{let{apiClient:o}=t.useApiClient({apiCredentials:r}),[c,u]=s.useState({}),[g,d]=s.useState(!1);s.useEffect(()=>{i?async function e(){try{if(!o||"function"!=typeof o.clientSettings)return;let e=await o.clientSettings({flow_id:a});u(e)}catch(e){console.error(e)}finally{d(!0)}}():d(!0)},[i,o,a]);let S=y;return(l&&Object.keys(l).length>0?S=l:i&&(S=c),g)?n.jsx(k.Provider,{value:S,children:e}):null},m=()=>s.useContext(k),_=({children:e,onError:t})=>{let s=m();return n.jsx(i.LicenseProvider,{clientSettings:s,onError:t,children:e})},E=({children:e,onError:t,type:s})=>{let i=m();return n.jsx(l.Provider,{clientSettings:i,type:s,onError:t,children:e})},D={},P=({children:e,customTexts:t=D})=>{let s=m(),{lang:i,uiSettings:l}=r.useSDKSettings(),c=a({customTexts:t,clientSettings:s,lang:i,uiSettings:l});return n.jsx(o.SDKLocaleProvider,{value:c,children:e})},L={},B=({children:e,customTheme:t=L})=>{let s=m(),{uiSettings:i,themeVersion:l}=r.useSDKSettings(),a=f({customTheme:t,clientSettings:s,themeVersion:l,uiSettings:i,defaultThemes:j});return n.jsx(c,{theme:a,children:e})},z=v.lazy(()=>import("./chunk-dc7036ac.js")),w=v.lazy(()=>import("./chunk-00ef2df8.js")),A=v.lazy(()=>import("./chunk-9dfcc42f.js")),K=v.lazy(()=>import("./chunk-8d117718.js")),I=v.lazy(()=>import("./chunk-9778c61e.js")),V=v.lazy(()=>import("./chunk-460be0ec.js"));var T=(e=e=>{var t,i,l;let a,{logCredentials:o={enable:!1},livenessComponent:c,customTheme:v={},customTexts:f,...j}=e,{mode:k,flowId:y,onError:C,onClose:D,debug:L,onLivenessDetectionDone:T}=j,W=m(),{billingSettings:M,enableBilling:O,themeVersion:G}=r.useSDKSettings(),F=u.getWebSetting(W,"data.settings.sdk_settings.billing_settings.billing_config"),{submitBilling:U}=g({enable:O,onError:C,billingSettings:M??{json:F??{}},billingUrl:u.getWebSetting(W,"data.settings.sdk_settings.billing_settings.url")}),Y=d.buildBillingInput(e),$=p(),q="face_authen"===$?S.BillingService.faceAuth:S.BillingService.selfie,H=s.useCallback(async(...e)=>{if("face_authen"===$)return void await T(...e);try{if(!await U({service:q,input:Y,output:{...d.buildBillingOutput(e?.[0]||{}),sdkStatus:S.BillingStatus.success}}))return}catch(e){console.error(e)}await T(...e)},[Y,q,$,T,U]),J=s.useCallback(e=>{S.ErrorsWithoutBilling.includes(e.code)?C(e):(U({service:q,input:Y,output:{error:e,sdkStatus:S.BillingStatus.fail}}),C&&C(e))},[U,q,Y,C]),N=s.useCallback(()=>{U({service:q,input:Y,output:{sdkStatus:S.BillingStatus.cancel}}),D&&D()},[U,q,Y,D]),Q=(t=k,i=c,l=G,a=K,t===S.Mode.ACTIVE&&(a=i?.ActiveLiveness??("v1"===l?I:K)),t===S.Mode.PASSIVE_V2&&(a=i?.PassiveLivenessV2??A),t===S.Mode.PASSIVE&&(a=i?.PassiveLiveness??("v1"===l?V:w)),"string"==typeof t&&t.startsWith("flash")&&(a=i?.FlashLiveness??z),a);return n.jsx(b,{debug:L,children:n.jsx(x,{onDone:T,onError:J,onClose:N,children:n.jsx(P,{customTexts:f,children:n.jsx(E,{onError:J,type:"face_authen"===y?"face_auth":"liveness",children:n.jsx(_,{onError:C,children:n.jsx(B,{customTheme:v,children:n.jsx(h.SDKTrackingProvider,{value:{tracking:{...o}},children:n.jsx(s.Suspense,{fallback:null,children:n.jsx(Q,{...j,onLivenessDetectionDone:H})})})})})})})})})},function(t){let{apiCheck:s,apiCredentials:i,serviceSettings:l,flowId:r,clientSettings:a}=t,o=s&&(l?.enableGetClientSettings??!0);return n.jsx(C,{enableGetClientSettings:o,clientSettings:a,apiCredentials:i,flowId:r,children:n.jsx(e,{...t})})}),W=Object.freeze({__proto__:null,default:T});export{C as C,T as L,P as S,W as i,m as u};
1
+ let e;import{d as t,r as s,j as n,a as i,aa as l,c as r,a9 as a,ab as o,o as c,u as u,g as g,p as d,s as S,e as h,Y as v}from"./chunk-c747321c.js";import{e as f,d as j,c as p,D as b,S as x}from"./chunk-51b3fd2d.js";let k=s.createContext({}),y={},C=({children:e,enableGetClientSettings:i,clientSettings:l,apiCredentials:r,flowId:a})=>{let{apiClient:o}=t.useApiClient({apiCredentials:r}),[c,u]=s.useState({}),[g,d]=s.useState(!1);s.useEffect(()=>{i?async function e(){try{if(!o||"function"!=typeof o.clientSettings)return;let e=await o.clientSettings({flow_id:a});u(e)}catch(e){console.error(e)}finally{d(!0)}}():d(!0)},[i,o,a]);let S=y;return(l&&Object.keys(l).length>0?S=l:i&&(S=c),g)?n.jsx(k.Provider,{value:S,children:e}):null},m=()=>s.useContext(k),_=({children:e,onError:t})=>{let s=m();return n.jsx(i.LicenseProvider,{clientSettings:s,onError:t,children:e})},E=({children:e,onError:t,type:s})=>{let i=m();return n.jsx(l.Provider,{clientSettings:i,type:s,onError:t,children:e})},D={},P=({children:e,customTexts:t=D})=>{let s=m(),{lang:i,uiSettings:l}=r.useSDKSettings(),c=a({customTexts:t,clientSettings:s,lang:i,uiSettings:l});return n.jsx(o.SDKLocaleProvider,{value:c,children:e})},L={},B=({children:e,customTheme:t=L})=>{let s=m(),{uiSettings:i,themeVersion:l}=r.useSDKSettings(),a=f({customTheme:t,clientSettings:s,themeVersion:l,uiSettings:i,defaultThemes:j});return n.jsx(c,{theme:a,children:e})},z=v.lazy(()=>import("./chunk-30dc9915.js")),w=v.lazy(()=>import("./chunk-91b54c2c.js")),A=v.lazy(()=>import("./chunk-7618f5a4.js")),K=v.lazy(()=>import("./chunk-e5a92416.js")),I=v.lazy(()=>import("./chunk-2118775a.js")),V=v.lazy(()=>import("./chunk-d7bc8179.js"));var T=(e=e=>{var t,i,l;let a,{logCredentials:o={enable:!1},livenessComponent:c,customTheme:v={},customTexts:f,...j}=e,{mode:k,flowId:y,onError:C,onClose:D,debug:L,onLivenessDetectionDone:T}=j,W=m(),{billingSettings:M,enableBilling:O,themeVersion:G}=r.useSDKSettings(),F=u.getWebSetting(W,"data.settings.sdk_settings.billing_settings.billing_config"),{submitBilling:U}=g({enable:O,onError:C,billingSettings:M??{json:F??{}},billingUrl:u.getWebSetting(W,"data.settings.sdk_settings.billing_settings.url")}),Y=d.buildBillingInput(e),$=p(),q="face_authen"===$?S.BillingService.faceAuth:S.BillingService.selfie,H=s.useCallback(async(...e)=>{if("face_authen"===$)return void await T(...e);try{if(!await U({service:q,input:Y,output:{...d.buildBillingOutput(e?.[0]||{}),sdkStatus:S.BillingStatus.success}}))return}catch(e){console.error(e)}await T(...e)},[Y,q,$,T,U]),J=s.useCallback(e=>{S.ErrorsWithoutBilling.includes(e.code)?C(e):(U({service:q,input:Y,output:{error:e,sdkStatus:S.BillingStatus.fail}}),C&&C(e))},[U,q,Y,C]),N=s.useCallback(()=>{U({service:q,input:Y,output:{sdkStatus:S.BillingStatus.cancel}}),D&&D()},[U,q,Y,D]),Q=(t=k,i=c,l=G,a=K,t===S.Mode.ACTIVE&&(a=i?.ActiveLiveness??("v1"===l?I:K)),t===S.Mode.PASSIVE_V2&&(a=i?.PassiveLivenessV2??A),t===S.Mode.PASSIVE&&(a=i?.PassiveLiveness??("v1"===l?V:w)),"string"==typeof t&&t.startsWith("flash")&&(a=i?.FlashLiveness??z),a);return n.jsx(b,{debug:L,children:n.jsx(x,{onDone:T,onError:J,onClose:N,children:n.jsx(P,{customTexts:f,children:n.jsx(E,{onError:J,type:"face_authen"===y?"face_auth":"liveness",children:n.jsx(_,{onError:C,children:n.jsx(B,{customTheme:v,children:n.jsx(h.SDKTrackingProvider,{value:{tracking:{...o}},children:n.jsx(s.Suspense,{fallback:null,children:n.jsx(Q,{...j,onLivenessDetectionDone:H})})})})})})})})})},function(t){let{apiCheck:s,apiCredentials:i,serviceSettings:l,flowId:r,clientSettings:a}=t,o=s&&(l?.enableGetClientSettings??!0);return n.jsx(C,{enableGetClientSettings:o,clientSettings:a,apiCredentials:i,flowId:r,children:n.jsx(e,{...t})})}),W=Object.freeze({__proto__:null,default:T});export{C as C,T as L,P as S,W as i,m as u};
@@ -1 +1 @@
1
- import{r as e,b as t,u as a,aH as n,s as s,c as i,ab as r,d as l,e as c,aq as o,ap as m,f as g,O as u,k as _,aK as f,aL as d,I as b,Z as h,G as p,Q as v,av as k,t as w,aB as F}from"./chunk-d315aa24.js";import{d as y}from"./chunk-14e1b552.js";import{t as I}from"./chunk-af89e5b6.js";import{t as T}from"./chunk-661f2995.js";import{w as R,m as S,n as L,u as x,o as B,q as D,r as E,v as A,s as M,t as O}from"./chunk-d70fed0c.js";import{m as N}from"./chunk-0da61929.js";import{u as P}from"./chunk-f7c561aa.js";let C=async({steps:e,apiClient:t,FaceDirection:a,outputEncryptionSettings:n,video:s})=>{let i=[];e.forEach(e=>{let{name:s,image:r,frontalFaceImage:l}=e;if(s!==a.FRONTAL){let e={label:"portrait",metadata:JSON.stringify({gesture_score:r.leftRightScore,gesture:s})};if(n&&n.key){let a=new Blob([r.encrypted.hex]);i.push(t.uploadImage({file:a,...e},{"X-TV-Key":n.key}))}else i.push(t.uploadImage({file:r.blob,...e}))}else i.push(Promise.resolve({data:{image_id:null}}));if(l.blob){let e={label:"portrait",metadata:JSON.stringify({gesture_score:l.leftRightScore,gesture:a.FRONTAL})};if(n&&n.key){let a=new Blob([l.encrypted.hex]);i.push(t.uploadImage({file:a,...e},{"X-TV-Key":n.key}))}else i.push(t.uploadImage({file:l.blob,...e}))}else i.push(Promise.resolve({data:{image_id:null}}))});let r=s?t.uploadFile({file:s,label:"video"}):Promise.resolve({data:{file_id:null}}),[l,...c]=await Promise.all([r,...i]);return e.forEach((e,t)=>{e.image.imageId=c[2*t].data.image_id,e.frontalFaceImage.imageId=c[2*t+1].data.image_id}),l},j=async({apiClient:e,faceVerificationFlowData:t,onLivenessDetectionDone:a,captureFrameSettings:n,FaceDirection:s,onError:i,outputEncryptionSettings:r,video:l,enabledServices:c,capturedFrames:o})=>{try{let i=t.current.steps;await C({steps:i,apiClient:e,FaceDirection:s,outputEncryptionSettings:r,video:l});let m=i.filter(e=>e.frontalFaceImage.imageId);if(0===m.length)a({error:"wrong_face_movement"});else{await R();let t=S(n);if(t){let n=null;c.enableVerifyFaceLiveness&&(n=e.verifyFaceLiveness({images:m.map(e=>({id:e.frontalFaceImage.imageId})),gesture_images:i.filter(e=>e.image.imageId&&e.name!==s.FRONTAL).map(({name:e,image:{imageId:t}})=>({gesture:e,images:[{id:t}]})),videos:t}));let r=null;c.enableVerifySanityPortrait&&(r=e.requestVerifyPortrait({image:{id:m[m.length-1].frontalFaceImage.imageId}}));let[l,g]=await Promise.all([n,r]),u=l?.data.is_live===!0;a({apiCheckPassed:u,verifyFaceLivenessResult:l?.data??null,verifyFacePortraitResult:g?.data??null,frontalFaces:m.map(e=>({id:e.frontalFaceImage.imageId,blob:e.frontalFaceImage.blob})),steps:i.filter(e=>e.image.imageId&&e.name!==s.FRONTAL).map(({name:e,image:t})=>({name:e,blob:t.blob,id:t.imageId})),uploadFramesResult:t,capturedFrames:o})}else a({error:"network_error"})}}catch(e){i({error:e})}},U=n.faceTracker(),V=new f,{FaceDirection:W,Errors:K,Messages:$,TrackLivenessEvents:z}=s,J={enable:!1,framesIntervalTime:180,framesBatchLength:0},q={[s.FaceDirection.UP]:{delayTime:0},[s.FaceDirection.LEFT]:{delayTime:0},[s.FaceDirection.RIGHT]:{delayTime:0},[s.FaceDirection.FRONTAL]:{delayTime:2e3}},G=()=>{},H=()=>{},Z=()=>{};function X({apiCheck:f,bgCameraMask:R,bgCameraMaskRed:S,surroundStyle:C,cropAreaDimension:Q,customInstructions:Y,customIcon:ee,customDirectionIcon:et,customStepTimeConstraints:ea=q,onLivenessDetectionDone:en,onError:es,frontalMinSize:ei,waitingTimeToGetBetterFrames:er=500,captureFrameSettings:el=J,setRemainingTime:ec=G,onProcessing:eo=Z,customErrors:em,customMessages:eg,apiCredentials:eu={},onFramesCaptured:e_=H,initFirstGestureTimeout:ef=2e3,outputEncryptionSettings:ed,cameraScale:eb=1,sendCustomEvent:eh,serviceSettings:ep,currentOrientation:ev,onReset:ek}={}){let[ew,eF]=e.useState(!1),[ey,eI]=e.useState(!1),[eT,eR]=e.useState(!1),[eS,eL]=e.useState(!1),ex=e.useRef(null),{lang:eB,assetRoot:eD,customUrls:eE,exifKey:eA}=i.useSDKSettings(),eM=r.useSDKLocale(),{apiClient:eO}=l.useApiClient({apiCredentials:eu}),[,eN]=e.useReducer(e=>e+1,0),eP=e.useRef(null),eC=e.useRef(!1),[ej,eU]=e.useState(!1),eV=e.useRef({}),{sendEvent:eW}=c.useSDKTracking(),eK=e.useRef(null);null===eK.current&&(eK.current=n.initFaceVerificationData({assetRoot:eD,customInstructions:Y,customIcon:ee,customDirectionIcon:et,customStepTimeConstraints:ea,Locale:eM,lang:eB}));let[e$,ez]=e.useState(),eJ=e.useCallback(e=>{ez(e)},[]),eq=e.useMemo(()=>I(eJ,500),[eJ]),eG=e.useRef([]),eH=e.useRef(),eZ=P(),{faceTrackingSetting:eX,flowIntervalTimeMs:eQ,limitTimeLivenessCheck:eY,terminateIfNoFace:e0,closeEyeSettings:e1,captureFrameSettings:e4,exifDataSettings:e6,recordVideo:e2,waitBeforeStartFlowMs:e3,resetFlowOnOrientationChange:e5,autoGenFrameIds:e8}=function({captureFrameSettingsProp:n,clientSettings:s}){return e.useMemo(()=>{let e,i=N({},L,s),r={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.face_tracking_setting.enable"),webTerminateThreshold:t(i,"data.settings.sdk_settings.active_liveness_settings.face_tracking_setting.web_terminate_threshold"),webWarningThreshold:t(i,"data.settings.sdk_settings.active_liveness_settings.face_tracking_setting.web_warning_threshold"),limitFor:t(i,"data.settings.sdk_settings.active_liveness_settings.face_tracking_setting.limit_for"),maxWarningTime:t(i,"data.settings.sdk_settings.active_liveness_settings.face_tracking_setting.max_warning_time")},l=t(i,"data.settings.sdk_settings.active_liveness_settings.reset_flow_on_orientation_change"),c=t(i,"data.settings.sdk_settings.active_liveness_settings.wait_before_start_flow_ms"),o=t(i,"data.settings.sdk_settings.active_liveness_settings.flow_interval_time_ms"),m=t(i,"data.settings.sdk_settings.active_liveness_settings.take_one_picture_time_ms"),g=a.getWebSetting(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.max_retry_count"),u={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.enable"),limitTimeSecond:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.limit_time_second"),remainTimeShow:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.remain_time_show"),format:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.format"),enableMaxRetries:g>0,totalMaxRetries:g,interruptible:!a.getWebSetting(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.non_stoppable")},_={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.terminate_if_no_face.enable"),maxInvalidFrame:t(i,"data.settings.sdk_settings.active_liveness_settings.terminate_if_no_face.max_invalid_frame"),maxTimeMs:t(i,"data.settings.sdk_settings.active_liveness_settings.terminate_if_no_face.max_time_ms")},f={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.close_eye_detector.enable"),webThreshold:t(i,"data.settings.sdk_settings.active_liveness_settings.close_eye_detector.web_threshold"),webTimeout:t(i,"data.settings.sdk_settings.active_liveness_settings.close_eye_detector.web_timeout"),forceCheck:t(i,"data.settings.sdk_settings.active_liveness_settings.close_eye_detector.force_check")},d={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.exif_data_settings.enable")},b={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.record_video.enable")},h=t(s,"data.settings.sdk_settings.active_liveness_settings.save_encoded_frames");e=h?{enable:h.enable,enableLogging:h.enable_logging,framesBatchLength:h.frames_batch_len,framesIntervalTime:h.frames_interval_ms}:n;let p={enable:a.getWebSetting(i,"data.settings.sdk_settings.active_liveness_settings.auto_gen_frame_ids.enable")&&u.enable,maxItems:a.getWebSetting(i,"data.settings.sdk_settings.active_liveness_settings.auto_gen_frame_ids.max_items")};return{faceTrackingSetting:r,resetFlowOnOrientationChange:l,waitBeforeStartFlowMs:c,flowIntervalTimeMs:o,takeOnePictureTimeMs:m,limitTimeLivenessCheck:u,terminateIfNoFace:_,closeEyeSettings:f,exifDataSettings:d,recordVideo:b,captureFrameSettings:e,autoGenFrameIds:p}},[n,s])}({captureFrameSettingsProp:el,clientSettings:eZ}),e9=1e3*eY.limitTimeSecond/e4.framesIntervalTime,{uuids:e7,getNextUUID:te,reset:tt}=o({total:Math.min(e8.maxItems,Math.ceil(e9/e4.framesBatchLength*1.2))}),ta=e.useRef(m.createSingleUUID()),tn=e.useCallback(e=>{let t=e[e.length-1];try{let e=JSON.parse(t.metadata);e8.enable&&(e.global_batch_id=te()),e.global_session_id=ta.current,t.metadata=JSON.stringify(e)}catch(e){console.error("Unable to process last frame metadata",e)}},[e8.enable,te]),ts=e2?.enable,ti=e.useMemo(()=>g.getEnabledServices(ep,eZ),[eZ,ep]),tr=e.useRef(""),tl=e.useCallback(e=>{if(e?.event){if(e.event===z?.show_alert){let t=e.log?.alert;if(t===tr.current)return;tr.current=t}eW(e),eh&&eh(e)}},[eh,eW]),tc=e.useMemo(()=>I(e=>{tl(e)},2e3),[tl]),to=e.useRef(0),tm=e.useRef(),tg=e.useRef();e.useEffect(()=>{tl({tag:"selfie",event:z?.start_camera,log:{}})},[tl]),e.useEffect(()=>(V.start(),()=>{V.stop()}),[]),e.useEffect(()=>{let e=!1;return async function t(){!ej&&(eH.current=performance.now(),eV.current=await d(eE),await b.initTensorFlow({preferredBackends:["wasm","webgl","cpu"]}),e||(eU(!0),tl({tag:"selfie",event:z?.show_warmup,log:{}}),tl({tag:"selfie",event:z?.finish_load_model,log:{status:"success",time_in_ms:performance.now()-eH.current}}),eH.current=null))}(),()=>{e=!0}},[ej,eE,tl]);let tu=e.useRef(!1),t_=e.useCallback(()=>{eK.current.curStepIndex=eK.current.steps.length,tu.current=!0,eR(!1),tg.current?.discardRecording()},[]),tf=e.useCallback(()=>{if(eK.current=n.initFaceVerificationData({assetRoot:eD,customInstructions:Y,customIcon:ee,customDirectionIcon:et,Locale:eM,lang:eB}),to.current=0,tm.current=null,eG.current=[],eL(!1),ez(null),M(),tg.current?.start(),tu.current=!1,e8.enable){let e=tt();u.addExifData("frame_batch_ids",e)}"function"==typeof ek&&ek(),eN()},[eM,eD,e8.enable,et,ee,Y,eB,ek,tt]),td=e.useCallback(()=>{t_(),setTimeout(()=>{tf()},eQ)},[t_,eQ,tf]),tb=e.useMemo(()=>({...K,...em}),[em]),th=e.useMemo(()=>({...$,...eg}),[eg]),tp=e.useCallback(({remainTime:e})=>{if(e>0&&e<=eY.remainTimeShow){let t=T(th.REMAIN_TIME[eB]),a=e;switch(eY.format){case"mm:ss":a=e.toString().padStart(5,"00:00");break;case"ss":a=e.toString().padStart(2,"0")}ec(t({x:a}))}},[eB,eY.format,eY.remainTimeShow,th.REMAIN_TIME,ec]),tv=e.useCallback(()=>{let e={};Object.keys(tb.liveness_terminated_time_out?.msg).forEach(t=>{let a=T(tb.liveness_terminated_time_out?.msg[t]);e[t]=a({x:eY.limitTimeSecond})}),ez({...tb.liveness_terminated_time_out,msg:e,duration:.95*eQ}),tl({tag:"selfie",event:z?.show_alert,log:{alert:"liveness_terminated_time_out,"}}),V.stop(),ec(""),t_()},[tb.liveness_terminated_time_out,eQ,eY.limitTimeSecond,t_,tl,ec]),tk=e.useCallback(({attemptCount:e,fromBackground:t})=>{eY.enableMaxRetries&&e>=eY.totalMaxRetries&&es(s.Errors.max_retry_reached),t&&t_(),V.start(),tf()},[eY.enableMaxRetries,eY.totalMaxRetries,es,tf,t_]),{stopTimer:tw}=x({totalTime:eY.limitTimeSecond,totalDelayBetweenReset:eQ/1e3,interruptible:eY.interruptible,shouldStart:ey&&eY.enable&&ej,onTimesUp:tv,onTick:tp,onReset:tk}),tF=e.useCallback(({clientWidth:e,clientHeight:t,videoAreaWidth:a,videoAreaHeight:n,lostX:s,lostY:i})=>{let r,l;_.isMobile?l=r=a-40:(l=450,r=450);let c=Math.floor((a-r)/2)+s;eP.current={x:c,y:5+i,width:r,height:l,image:R,surroundStyle:C},"object"==typeof Q?eP.current={...eP.current,...Q}:"function"==typeof Q&&(eP.current={...eP.current,...Q({clientWidth:e,clientHeight:t,videoAreaWidth:a,videoAreaHeight:n,lostX:s,lostY:i,isMobile:_.isMobile,width:r,height:l})}),eN(),eI(!0)},[R,C,Q]),ty=e.useRef({});e.useEffect(()=>{ty.current.isFirstValidFrameFoundRef=eS},[eS]),e.useEffect(()=>{let e,t=ex.current,a=async()=>{let{steps:e}=eK.current,t=[];e.map(e=>(t.push({name:e.name,blob:e.image.blob,captureTime:e.image.captureTime,gesture:e.name}),e.frontalFaceImage.blob&&t.push({name:e.name,blob:e.frontalFaceImage.blob,captureTime:e.frontalFaceImage.captureTime,gesture:W.FRONTAL}),0));let a=t.map(e=>h.resizeBlobImg(e.blob,400,400)),n=await Promise.all(a),s="0";if(e4.framesBatchLength>0){let e=`${Math.floor(eG.current.length/e4.framesBatchLength)}x${e4.framesBatchLength}`,t=eG.current.length%e4.framesBatchLength>0?`+${eG.current.length%e4.framesBatchLength}`:"";s=`${eG.current.length}:${e}${t}`}let i=n.map((e,a)=>{let n=u.parseLivenessImg({...t[a],frames:s});return u.writeCurrentExif({imageData:{blob:e},enableExifData:e6.enable,additionalData:n})}),r=await Promise.all(i),l=t.map((e,t)=>({name:e.name,blob:r[t]}));await Promise.all(e.map(async(t,a)=>{let n=l.filter(e=>e.name===t.name);if(e[a].image.blob=n[0].blob,t.frontalFaceImage.blob&&(e[a].frontalFaceImage.blob=n[1].blob),ed&&ed.key){let{key:s}=ed;e[a].image.encrypted=await v.encrypt({blob:n[0].blob,key:s}),t.frontalFaceImage.blob&&(e[a].frontalFaceImage.encrypted=await v.encrypt({blob:n[1].blob,key:s}))}return 0}))},i=async()=>{let{steps:e}=eK.current,t=e[eK.current.curStepIndex];if((t&&tl({tag:"selfie",event:{[s.FaceDirection.UP]:z?.capture_up_face,[s.FaceDirection.LEFT]:z?.capture_left_face,[s.FaceDirection.RIGHT]:z?.capture_right_face,[s.FaceDirection.FRONTAL]:z?.capture_frontal_face}[t.name],log:{time_capture_in_seconds:((performance.now()-eH.current)/1e3).toFixed(1)}}),eK.current.curStepIndex++,eH.current=performance.now(),eX.enable&&"each_gesture"===eX.limitFor&&(to.current=0),eK.current.curStepIndex===e.length)&&(eY.enable&&(V.stop(),tw(),ec("")),en)){let t=eG.current;if(ed&&ed.key){let e=await Promise.all(t.map(e=>e?.base64));if(t=t.map((t,a)=>({...t,base64:e[a]})),e4.enable&&e4.framesBatchLength>0&&t.length%e4.framesBatchLength>0){let e=t.slice(-1*(t.length%e4.framesBatchLength));e_(e),f&&B(ed,e,eO,t.length===e4.framesBatchLength)}}else if(e4.enable&&e4.framesBatchLength>0&&t.length%e4.framesBatchLength>0){let e=t.slice(-1*(t.length%e4.framesBatchLength));tn(e),e_(e.map(({base64:e,label:t,index:a,metadata:n})=>({base64:e,label:t,index:a,metadata:n}))),f&&ti.enableUploadFrames&&B(ed,e,eO)}tl({tag:"selfie",event:z?.finish_capture,log:{time_capture_in_seconds:V.duration("from_1st_frame")}}),eo(),await tg.current?.stopVideoRecording(),eF(!0),u.addExifData("user_action",{start_selfie:Date.now()-1e3*V.duration("from_1st_frame"),end_selfie:Date.now()}),u.addExifData("global_session_id",ta.current),e8.enable&&u.addExifData("frame_batch_ids",e7),await a();let n=eG.current;if(ed&&ed.key){let e=await Promise.all(n.map(e=>e?.base64));n=n.map((t,a)=>({...t,base64:e[a]}))}if(f&&ti.enableUploadImages)await j({apiClient:eO,faceVerificationFlowData:eK,onLivenessDetectionDone:en,captureFrameSettings:e4,FaceDirection:W,onError:es,outputEncryptionSettings:ed,video:D().length?D()[0]:null,enabledServices:ti,capturedFrames:n});else{let t=e.filter(e=>e.name!==W.FRONTAL).map(e=>({name:e.name,image:{blob:e.image.blob,encrypted:e.image.encrypted}})),a=e.filter(e=>e.name!==W.FRONTAL).map(e=>e.frontalFaceImage.blob).filter(e=>null!==e),s=e.filter(e=>e.name!==W.FRONTAL).map(e=>e.frontalFaceImage.encrypted).filter(e=>e&&e.hex),i=e.find(e=>e.name===W.FRONTAL)?.image?.blob,r=e.find(e=>e.name===W.FRONTAL)?.image?.encrypted,l=i&&ei?await h.scaleImage(i,{minSize:ei}):null;i&&a.push(i),r&&s.push(r),tl({tag:"result",event:z?.liveness_detection_done,log:{result_object:{steps:t,frontalFaces:a,frontalScaledImage:l}}}),en({steps:t,frontalFaces:a,frontalFacesEncrypted:s,frontalScaledImage:l,capturedFrames:n,video:D().length?D()[0]:null}),E()}eF(!1)}eN()},r=y(()=>{let{curStepIndex:e,steps:t}=eK.current,a=t[e],n=a?.image.blob!==null,s=a?.frontalFaceImage.blob!==null,r=t.filter(e=>e.frontalFaceImage.blob).length,l=!1;return n&&(s||![1].includes(e)||r>=1)?(eC.current=!1,i(),l=!0):n&&!s?eC.current=!0:eC.current=!1,eR(!1),l},er);async function l({faceDirection:e,canvas:t,blurScore:a,leftRightScore:n,isEyeClose:s}){let{curStepIndex:l,steps:c}=eK.current;if(l<c.length){let o=c[l];if(O({faceDirection:e,curStep:o})||s)return;if(e===W.FRONTAL&&(null===o.frontalFaceImage.blurScore||k.hasBetterBlurScore(a,o.frontalFaceImage.blurScore))){o.frontalFaceImage.blurScore=a;let e=await p.takePicture({canvas:t});o.frontalFaceImage.blob=e,o.frontalFaceImage.leftRightScore=n,o.frontalFaceImage.captureTime=Date.now(),eC.current&&(eC.current=!1,i())}if(o.name===e&&(null===o.image.blurScore||k.hasBetterBlurScore(a,o.image.blurScore))){eR(!0),o.image.blurScore=a;let e=await p.takePicture({canvas:t});o.image.blob=e,o.image.leftRightScore=n,o.image.captureTime=Date.now(),o.image.objUrl&&URL.revokeObjectURL(o.image.objUrl),o.image.objUrl=URL.createObjectURL(e),r()}}}async function c(a,i){let r,o;if(i?.width===0||i?.height===0)return;let{isFirstValidFrameFoundRef:m}=ty.current,{cropX:g,cropY:u,cropWidth:_,cropHeight:d}=a;i.getContext("2d").drawImage(t,g,u,_,d,-((400*eb-400)/2)/eb,-((400*eb-400)/2)/eb,400,400);let{blazefaceModel:b,closeEyesModel:h}=eV.current,[p,v]=await Promise.all([k.calculateBlurScore(i),w.getModelPredictions({model:b,sCanvas:i})]),{error:y,fullFace:I,faceRatio:T,faceNotFrontalMinThreshold:L}=await n.validatePredictions({predictions:v,width:w.SIZE,height:w.SIZE});r=y,eP.current.image=R;let x=null,D=null,E=null,A=null,{curStepIndex:M,steps:O}=eK.current;if(I){let e=O[M],t=e&&e.name===W.FRONTAL;E=I.landmarks;let a=await n.calculateFaceDirection({landmarks:E,getPerfectFrontal:t});a&&(x=a.gesture,D=a.leftRightScore);let l=e1?.webTimeout+ea[s.FaceDirection.FRONTAL].delayTime/1e3;if(t&&e1?.enable&&(-1===V.duration("limit_close_eye")||V.duration("limit_close_eye")<l)){e1?.forceCheck||-1!==V.duration("limit_close_eye")||V.start("limit_close_eye");let{isEyeClose:e}=await h.predict(i,E,e1?.webThreshold);(A=e)&&!r&&(r=K.close_eye)}}let N=r?.code==="no_face"||r?.code==="partial_face",P=M<O.length;!function({noFace:e,isFirstValidFrameFoundRef:t}){if(!e0.enable||!t)return;let{maxTimeMs:a}=e0;tm.current&&e||(tm.current={time:Date.now(),frame:0}),e&&tm.current.frame++;let{time:n}=tm.current;e&&Date.now()-n>=a&&(ez({...tb.liveness_terminated_no_face,duration:eQ}),tl({tag:"selfie",event:z?.show_alert,log:{alert:"liveness_terminated_no_face"}}),td())}({noFace:N&&P,isFirstValidFrameFoundRef:m}),r?.code&&tc({tag:"selfie",event:z?.show_alert,log:{alert:r.code}}),!r||"face_too_small"===r.code&&x!==W.FRONTAL&&T>=L?(m||(eL(!0),eH.current=performance.now(),V.start("from_1st_frame")),function({trackingScore:e,isFirstValidFrameFoundRef:t}){if(!eX.enable||null===e||!t)return!0;let{webWarningThreshold:a,webTerminateThreshold:n,maxWarningTime:s}=eX;return!!(e<a)||(e<n&&to.current<s?(to.current++,to.current===s?(ez({...tb.liveness_terminated_face_tracking,duration:eQ}),tl({tag:"selfie",event:z?.show_alert,log:{alert:"liveness_terminated_face_tracking"}})):ez({...tb.liveness_too_fast,duration:1500}),!0):(ez({...tb.liveness_terminated,duration:eQ}),tl({tag:"selfie",event:z?.show_alert,log:{alert:"liveness_terminated"}}),td(),!1))}({trackingScore:function(e,t,a,n){if(eG.current.length&&Date.now()-eG.current[eG.current.length-1].time<e4.framesIntervalTime)return null;if(e4.enable&&!n){let{topLeft:n,bottomRight:s}=e,i=[...n,...s],{score:r,time:l}=U(e,0===eG.current.length),c={label:"portrait",base64:t.toDataURL("image/jpeg",.8).split(",")[1],landmarks:a,original_landmarks:a,score:r,time:l,index:eG.current.length,bbox:i,original_bbox:i,metadata:JSON.stringify({})};if(ed&&ed.key){if(c.base64=F.encryptFrameBase64(c.base64,ed.key),eG.current.push(c),e4.framesBatchLength>0&&eG.current.length%e4.framesBatchLength==0&&e_){let e=eG.current.slice(-e4.framesBatchLength);Promise.all(e.map(e=>e?.base64)).then(t=>{e_(e.map(({label:e,index:a},n)=>({base64:t[n],label:e,index:a}))),f&&ti.enableUploadFrames&&B(ed,e.map(({label:e,index:a},n)=>({base64:t[n],label:e,index:a})),eO,eG.current.length===e4.framesBatchLength)})}}else if(eG.current.push(c),e4.framesBatchLength>0&&eG.current.length%e4.framesBatchLength==0&&e_){let e=eG.current.slice(-e4.framesBatchLength);tn(e),e_(e.map(({base64:e,label:t,index:a,metadata:n})=>({base64:e,label:t,index:a,metadata:n}))),f&&ti.enableUploadFrames&&B(ed,e,eO,eG.current.length===e4.framesBatchLength)}return r}return null}(v[0],i,E,M>=O.length),isFirstValidFrameFoundRef:m})&&await l({faceDirection:x,canvas:i,blurScore:p,leftRightScore:D,isEyeClose:A})):M<O.length&&(o=tb[r.code],eP.current.image=S),eq(o),-1!==e&&(e=requestAnimationFrame(()=>c(a,i)))}async function o(){let e=p.analyzeVideoAndWindowSizes(t,eP.current),a=document.createElement("canvas");a.width=400,a.height=400;let n=a.getContext("2d");n.translate(400,0),n.scale(-1*eb,+eb);let{mediaRecorder:s}=ts&&t?await A({outputImagesSize:400,videoEl:t,resultAnalyzeVideoAndWindowSizes:e}):{};tg.current=s,tg.current&&tg.current.start(),c(e,a)}return ey&&ej&&setTimeout(()=>{o()},e3??ef),()=>{cancelAnimationFrame(e),e=-1}},[ev,e3,ef,ey,eB,eO,f,R,S,en,es,ei,er,e4,eo,eX,eY.enable,ec,eq,ea,eQ,td,e0,tb,ej,tl,e_,ed,eb,e1?.enable,e1?.webThreshold,e1?.webTimeout,e1?.forceCheck,e6.enable,eA,tc,ts,ti,tw,e7,tn,e8.enable]);let{curStepIndex:tI,steps:tT}=eK.current,tR=e.useMemo(()=>tT.find(e=>e.name===s.FaceDirection.FRONTAL),[tT]),tS=eC.current?tR:tT[tI],tL=tS&&eS?tS.instructions[eB]:null,tx=tS&&eS?tS.directionIcon:"";return{resetFlowOnOrientationChange:e5,cropArea:eP,curStepIndex:tI,directionIcon:tx,directionIconAnimation:tS?tS.directionIconAnimation:"",faceDetectionError:e$,resetFlow:td,handleVideoPlayed:tF,instructions:tL,refVideo:ex,refIsReseting:tu,steps:tT,videoPlayed:ey,activeCapturing:eT,isFirstValidFrameFound:eS,warmupDone:ej,showLoading:ew}}export{X as u};
1
+ import{r as e,b as t,u as a,aH as n,s as s,c as i,ab as r,d as l,e as c,aq as o,ap as m,f as g,O as u,k as _,aK as f,aL as d,I as b,Z as h,G as p,Q as v,av as k,t as w,aB as F}from"./chunk-c747321c.js";import{d as y}from"./chunk-71ff4107.js";import{t as I}from"./chunk-036bae4b.js";import{t as T}from"./chunk-ddb14dfb.js";import{w as R,m as S,n as L,u as x,o as B,q as D,r as E,v as A,s as M,t as O}from"./chunk-88ec0901.js";import{m as N}from"./chunk-51b3fd2d.js";import{u as P}from"./chunk-6e5358d6.js";let C=async({steps:e,apiClient:t,FaceDirection:a,outputEncryptionSettings:n,video:s})=>{let i=[];e.forEach(e=>{let{name:s,image:r,frontalFaceImage:l}=e;if(s!==a.FRONTAL){let e={label:"portrait",metadata:JSON.stringify({gesture_score:r.leftRightScore,gesture:s})};if(n&&n.key){let a=new Blob([r.encrypted.hex]);i.push(t.uploadImage({file:a,...e},{"X-TV-Key":n.key}))}else i.push(t.uploadImage({file:r.blob,...e}))}else i.push(Promise.resolve({data:{image_id:null}}));if(l.blob){let e={label:"portrait",metadata:JSON.stringify({gesture_score:l.leftRightScore,gesture:a.FRONTAL})};if(n&&n.key){let a=new Blob([l.encrypted.hex]);i.push(t.uploadImage({file:a,...e},{"X-TV-Key":n.key}))}else i.push(t.uploadImage({file:l.blob,...e}))}else i.push(Promise.resolve({data:{image_id:null}}))});let r=s?t.uploadFile({file:s,label:"video"}):Promise.resolve({data:{file_id:null}}),[l,...c]=await Promise.all([r,...i]);return e.forEach((e,t)=>{e.image.imageId=c[2*t].data.image_id,e.frontalFaceImage.imageId=c[2*t+1].data.image_id}),l},j=async({apiClient:e,faceVerificationFlowData:t,onLivenessDetectionDone:a,captureFrameSettings:n,FaceDirection:s,onError:i,outputEncryptionSettings:r,video:l,enabledServices:c,capturedFrames:o})=>{try{let i=t.current.steps;await C({steps:i,apiClient:e,FaceDirection:s,outputEncryptionSettings:r,video:l});let m=i.filter(e=>e.frontalFaceImage.imageId);if(0===m.length)a({error:"wrong_face_movement"});else{await R();let t=S(n);if(t){let n=null;c.enableVerifyFaceLiveness&&(n=e.verifyFaceLiveness({images:m.map(e=>({id:e.frontalFaceImage.imageId})),gesture_images:i.filter(e=>e.image.imageId&&e.name!==s.FRONTAL).map(({name:e,image:{imageId:t}})=>({gesture:e,images:[{id:t}]})),videos:t}));let r=null;c.enableVerifySanityPortrait&&(r=e.requestVerifyPortrait({image:{id:m[m.length-1].frontalFaceImage.imageId}}));let[l,g]=await Promise.all([n,r]),u=l?.data.is_live===!0;a({apiCheckPassed:u,verifyFaceLivenessResult:l?.data??null,verifyFacePortraitResult:g?.data??null,frontalFaces:m.map(e=>({id:e.frontalFaceImage.imageId,blob:e.frontalFaceImage.blob})),steps:i.filter(e=>e.image.imageId&&e.name!==s.FRONTAL).map(({name:e,image:t})=>({name:e,blob:t.blob,id:t.imageId})),uploadFramesResult:t,capturedFrames:o})}else a({error:"network_error"})}}catch(e){i({error:e})}},U=n.faceTracker(),V=new f,{FaceDirection:W,Errors:K,Messages:$,TrackLivenessEvents:z}=s,J={enable:!1,framesIntervalTime:180,framesBatchLength:0},q={[s.FaceDirection.UP]:{delayTime:0},[s.FaceDirection.LEFT]:{delayTime:0},[s.FaceDirection.RIGHT]:{delayTime:0},[s.FaceDirection.FRONTAL]:{delayTime:2e3}},G=()=>{},H=()=>{},Z=()=>{};function X({apiCheck:f,bgCameraMask:R,bgCameraMaskRed:S,surroundStyle:C,cropAreaDimension:Q,customInstructions:Y,customIcon:ee,customDirectionIcon:et,customStepTimeConstraints:ea=q,onLivenessDetectionDone:en,onError:es,frontalMinSize:ei,waitingTimeToGetBetterFrames:er=500,captureFrameSettings:el=J,setRemainingTime:ec=G,onProcessing:eo=Z,customErrors:em,customMessages:eg,apiCredentials:eu={},onFramesCaptured:e_=H,initFirstGestureTimeout:ef=2e3,outputEncryptionSettings:ed,cameraScale:eb=1,sendCustomEvent:eh,serviceSettings:ep,currentOrientation:ev,onReset:ek}={}){let[ew,eF]=e.useState(!1),[ey,eI]=e.useState(!1),[eT,eR]=e.useState(!1),[eS,eL]=e.useState(!1),ex=e.useRef(null),{lang:eB,assetRoot:eD,customUrls:eE,exifKey:eA}=i.useSDKSettings(),eM=r.useSDKLocale(),{apiClient:eO}=l.useApiClient({apiCredentials:eu}),[,eN]=e.useReducer(e=>e+1,0),eP=e.useRef(null),eC=e.useRef(!1),[ej,eU]=e.useState(!1),eV=e.useRef({}),{sendEvent:eW}=c.useSDKTracking(),eK=e.useRef(null);null===eK.current&&(eK.current=n.initFaceVerificationData({assetRoot:eD,customInstructions:Y,customIcon:ee,customDirectionIcon:et,customStepTimeConstraints:ea,Locale:eM,lang:eB}));let[e$,ez]=e.useState(),eJ=e.useCallback(e=>{ez(e)},[]),eq=e.useMemo(()=>I(eJ,500),[eJ]),eG=e.useRef([]),eH=e.useRef(),eZ=P(),{faceTrackingSetting:eX,flowIntervalTimeMs:eQ,limitTimeLivenessCheck:eY,terminateIfNoFace:e0,closeEyeSettings:e1,captureFrameSettings:e4,exifDataSettings:e6,recordVideo:e2,waitBeforeStartFlowMs:e3,resetFlowOnOrientationChange:e5,autoGenFrameIds:e8}=function({captureFrameSettingsProp:n,clientSettings:s}){return e.useMemo(()=>{let e,i=N({},L,s),r={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.face_tracking_setting.enable"),webTerminateThreshold:t(i,"data.settings.sdk_settings.active_liveness_settings.face_tracking_setting.web_terminate_threshold"),webWarningThreshold:t(i,"data.settings.sdk_settings.active_liveness_settings.face_tracking_setting.web_warning_threshold"),limitFor:t(i,"data.settings.sdk_settings.active_liveness_settings.face_tracking_setting.limit_for"),maxWarningTime:t(i,"data.settings.sdk_settings.active_liveness_settings.face_tracking_setting.max_warning_time")},l=t(i,"data.settings.sdk_settings.active_liveness_settings.reset_flow_on_orientation_change"),c=t(i,"data.settings.sdk_settings.active_liveness_settings.wait_before_start_flow_ms"),o=t(i,"data.settings.sdk_settings.active_liveness_settings.flow_interval_time_ms"),m=t(i,"data.settings.sdk_settings.active_liveness_settings.take_one_picture_time_ms"),g=a.getWebSetting(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.max_retry_count"),u={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.enable"),limitTimeSecond:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.limit_time_second"),remainTimeShow:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.remain_time_show"),format:t(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.format"),enableMaxRetries:g>0,totalMaxRetries:g,interruptible:!a.getWebSetting(i,"data.settings.sdk_settings.active_liveness_settings.limit_time_liveness_check.non_stoppable")},_={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.terminate_if_no_face.enable"),maxInvalidFrame:t(i,"data.settings.sdk_settings.active_liveness_settings.terminate_if_no_face.max_invalid_frame"),maxTimeMs:t(i,"data.settings.sdk_settings.active_liveness_settings.terminate_if_no_face.max_time_ms")},f={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.close_eye_detector.enable"),webThreshold:t(i,"data.settings.sdk_settings.active_liveness_settings.close_eye_detector.web_threshold"),webTimeout:t(i,"data.settings.sdk_settings.active_liveness_settings.close_eye_detector.web_timeout"),forceCheck:t(i,"data.settings.sdk_settings.active_liveness_settings.close_eye_detector.force_check")},d={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.exif_data_settings.enable")},b={enable:t(i,"data.settings.sdk_settings.active_liveness_settings.record_video.enable")},h=t(s,"data.settings.sdk_settings.active_liveness_settings.save_encoded_frames");e=h?{enable:h.enable,enableLogging:h.enable_logging,framesBatchLength:h.frames_batch_len,framesIntervalTime:h.frames_interval_ms}:n;let p={enable:a.getWebSetting(i,"data.settings.sdk_settings.active_liveness_settings.auto_gen_frame_ids.enable")&&u.enable,maxItems:a.getWebSetting(i,"data.settings.sdk_settings.active_liveness_settings.auto_gen_frame_ids.max_items")};return{faceTrackingSetting:r,resetFlowOnOrientationChange:l,waitBeforeStartFlowMs:c,flowIntervalTimeMs:o,takeOnePictureTimeMs:m,limitTimeLivenessCheck:u,terminateIfNoFace:_,closeEyeSettings:f,exifDataSettings:d,recordVideo:b,captureFrameSettings:e,autoGenFrameIds:p}},[n,s])}({captureFrameSettingsProp:el,clientSettings:eZ}),e9=1e3*eY.limitTimeSecond/e4.framesIntervalTime,{uuids:e7,getNextUUID:te,reset:tt}=o({total:Math.min(e8.maxItems,Math.ceil(e9/e4.framesBatchLength*1.2))}),ta=e.useRef(m.createSingleUUID()),tn=e.useCallback(e=>{let t=e[e.length-1];try{let e=JSON.parse(t.metadata);e8.enable&&(e.global_batch_id=te()),e.global_session_id=ta.current,t.metadata=JSON.stringify(e)}catch(e){console.error("Unable to process last frame metadata",e)}},[e8.enable,te]),ts=e2?.enable,ti=e.useMemo(()=>g.getEnabledServices(ep,eZ),[eZ,ep]),tr=e.useRef(""),tl=e.useCallback(e=>{if(e?.event){if(e.event===z?.show_alert){let t=e.log?.alert;if(t===tr.current)return;tr.current=t}eW(e),eh&&eh(e)}},[eh,eW]),tc=e.useMemo(()=>I(e=>{tl(e)},2e3),[tl]),to=e.useRef(0),tm=e.useRef(),tg=e.useRef();e.useEffect(()=>{tl({tag:"selfie",event:z?.start_camera,log:{}})},[tl]),e.useEffect(()=>(V.start(),()=>{V.stop()}),[]),e.useEffect(()=>{let e=!1;return async function t(){!ej&&(eH.current=performance.now(),eV.current=await d(eE),await b.initTensorFlow({preferredBackends:["wasm","webgl","cpu"]}),e||(eU(!0),tl({tag:"selfie",event:z?.show_warmup,log:{}}),tl({tag:"selfie",event:z?.finish_load_model,log:{status:"success",time_in_ms:performance.now()-eH.current}}),eH.current=null))}(),()=>{e=!0}},[ej,eE,tl]);let tu=e.useRef(!1),t_=e.useCallback(()=>{eK.current.curStepIndex=eK.current.steps.length,tu.current=!0,eR(!1),tg.current?.discardRecording()},[]),tf=e.useCallback(()=>{if(eK.current=n.initFaceVerificationData({assetRoot:eD,customInstructions:Y,customIcon:ee,customDirectionIcon:et,Locale:eM,lang:eB}),to.current=0,tm.current=null,eG.current=[],eL(!1),ez(null),M(),tg.current?.start(),tu.current=!1,e8.enable){let e=tt();u.addExifData("frame_batch_ids",e)}"function"==typeof ek&&ek(),eN()},[eM,eD,e8.enable,et,ee,Y,eB,ek,tt]),td=e.useCallback(()=>{t_(),setTimeout(()=>{tf()},eQ)},[t_,eQ,tf]),tb=e.useMemo(()=>({...K,...em}),[em]),th=e.useMemo(()=>({...$,...eg}),[eg]),tp=e.useCallback(({remainTime:e})=>{if(e>0&&e<=eY.remainTimeShow){let t=T(th.REMAIN_TIME[eB]),a=e;switch(eY.format){case"mm:ss":a=e.toString().padStart(5,"00:00");break;case"ss":a=e.toString().padStart(2,"0")}ec(t({x:a}))}},[eB,eY.format,eY.remainTimeShow,th.REMAIN_TIME,ec]),tv=e.useCallback(()=>{let e={};Object.keys(tb.liveness_terminated_time_out?.msg).forEach(t=>{let a=T(tb.liveness_terminated_time_out?.msg[t]);e[t]=a({x:eY.limitTimeSecond})}),ez({...tb.liveness_terminated_time_out,msg:e,duration:.95*eQ}),tl({tag:"selfie",event:z?.show_alert,log:{alert:"liveness_terminated_time_out,"}}),V.stop(),ec(""),t_()},[tb.liveness_terminated_time_out,eQ,eY.limitTimeSecond,t_,tl,ec]),tk=e.useCallback(({attemptCount:e,fromBackground:t})=>{eY.enableMaxRetries&&e>=eY.totalMaxRetries&&es(s.Errors.max_retry_reached),t&&t_(),V.start(),tf()},[eY.enableMaxRetries,eY.totalMaxRetries,es,tf,t_]),{stopTimer:tw}=x({totalTime:eY.limitTimeSecond,totalDelayBetweenReset:eQ/1e3,interruptible:eY.interruptible,shouldStart:ey&&eY.enable&&ej,onTimesUp:tv,onTick:tp,onReset:tk}),tF=e.useCallback(({clientWidth:e,clientHeight:t,videoAreaWidth:a,videoAreaHeight:n,lostX:s,lostY:i})=>{let r,l;_.isMobile?l=r=a-40:(l=450,r=450);let c=Math.floor((a-r)/2)+s;eP.current={x:c,y:5+i,width:r,height:l,image:R,surroundStyle:C},"object"==typeof Q?eP.current={...eP.current,...Q}:"function"==typeof Q&&(eP.current={...eP.current,...Q({clientWidth:e,clientHeight:t,videoAreaWidth:a,videoAreaHeight:n,lostX:s,lostY:i,isMobile:_.isMobile,width:r,height:l})}),eN(),eI(!0)},[R,C,Q]),ty=e.useRef({});e.useEffect(()=>{ty.current.isFirstValidFrameFoundRef=eS},[eS]),e.useEffect(()=>{let e,t=ex.current,a=async()=>{let{steps:e}=eK.current,t=[];e.map(e=>(t.push({name:e.name,blob:e.image.blob,captureTime:e.image.captureTime,gesture:e.name}),e.frontalFaceImage.blob&&t.push({name:e.name,blob:e.frontalFaceImage.blob,captureTime:e.frontalFaceImage.captureTime,gesture:W.FRONTAL}),0));let a=t.map(e=>h.resizeBlobImg(e.blob,400,400)),n=await Promise.all(a),s="0";if(e4.framesBatchLength>0){let e=`${Math.floor(eG.current.length/e4.framesBatchLength)}x${e4.framesBatchLength}`,t=eG.current.length%e4.framesBatchLength>0?`+${eG.current.length%e4.framesBatchLength}`:"";s=`${eG.current.length}:${e}${t}`}let i=n.map((e,a)=>{let n=u.parseLivenessImg({...t[a],frames:s});return u.writeCurrentExif({imageData:{blob:e},enableExifData:e6.enable,additionalData:n})}),r=await Promise.all(i),l=t.map((e,t)=>({name:e.name,blob:r[t]}));await Promise.all(e.map(async(t,a)=>{let n=l.filter(e=>e.name===t.name);if(e[a].image.blob=n[0].blob,t.frontalFaceImage.blob&&(e[a].frontalFaceImage.blob=n[1].blob),ed&&ed.key){let{key:s}=ed;e[a].image.encrypted=await v.encrypt({blob:n[0].blob,key:s}),t.frontalFaceImage.blob&&(e[a].frontalFaceImage.encrypted=await v.encrypt({blob:n[1].blob,key:s}))}return 0}))},i=async()=>{let{steps:e}=eK.current,t=e[eK.current.curStepIndex];if((t&&tl({tag:"selfie",event:{[s.FaceDirection.UP]:z?.capture_up_face,[s.FaceDirection.LEFT]:z?.capture_left_face,[s.FaceDirection.RIGHT]:z?.capture_right_face,[s.FaceDirection.FRONTAL]:z?.capture_frontal_face}[t.name],log:{time_capture_in_seconds:((performance.now()-eH.current)/1e3).toFixed(1)}}),eK.current.curStepIndex++,eH.current=performance.now(),eX.enable&&"each_gesture"===eX.limitFor&&(to.current=0),eK.current.curStepIndex===e.length)&&(eY.enable&&(V.stop(),tw(),ec("")),en)){let t=eG.current;if(ed&&ed.key){let e=await Promise.all(t.map(e=>e?.base64));if(t=t.map((t,a)=>({...t,base64:e[a]})),e4.enable&&e4.framesBatchLength>0&&t.length%e4.framesBatchLength>0){let e=t.slice(-1*(t.length%e4.framesBatchLength));e_(e),f&&B(ed,e,eO,t.length===e4.framesBatchLength)}}else if(e4.enable&&e4.framesBatchLength>0&&t.length%e4.framesBatchLength>0){let e=t.slice(-1*(t.length%e4.framesBatchLength));tn(e),e_(e.map(({base64:e,label:t,index:a,metadata:n})=>({base64:e,label:t,index:a,metadata:n}))),f&&ti.enableUploadFrames&&B(ed,e,eO)}tl({tag:"selfie",event:z?.finish_capture,log:{time_capture_in_seconds:V.duration("from_1st_frame")}}),eo(),await tg.current?.stopVideoRecording(),eF(!0),u.addExifData("user_action",{start_selfie:Date.now()-1e3*V.duration("from_1st_frame"),end_selfie:Date.now()}),u.addExifData("global_session_id",ta.current),e8.enable&&u.addExifData("frame_batch_ids",e7),await a();let n=eG.current;if(ed&&ed.key){let e=await Promise.all(n.map(e=>e?.base64));n=n.map((t,a)=>({...t,base64:e[a]}))}if(f&&ti.enableUploadImages)await j({apiClient:eO,faceVerificationFlowData:eK,onLivenessDetectionDone:en,captureFrameSettings:e4,FaceDirection:W,onError:es,outputEncryptionSettings:ed,video:D().length?D()[0]:null,enabledServices:ti,capturedFrames:n});else{let t=e.filter(e=>e.name!==W.FRONTAL).map(e=>({name:e.name,image:{blob:e.image.blob,encrypted:e.image.encrypted}})),a=e.filter(e=>e.name!==W.FRONTAL).map(e=>e.frontalFaceImage.blob).filter(e=>null!==e),s=e.filter(e=>e.name!==W.FRONTAL).map(e=>e.frontalFaceImage.encrypted).filter(e=>e&&e.hex),i=e.find(e=>e.name===W.FRONTAL)?.image?.blob,r=e.find(e=>e.name===W.FRONTAL)?.image?.encrypted,l=i&&ei?await h.scaleImage(i,{minSize:ei}):null;i&&a.push(i),r&&s.push(r),tl({tag:"result",event:z?.liveness_detection_done,log:{result_object:{steps:t,frontalFaces:a,frontalScaledImage:l}}}),en({steps:t,frontalFaces:a,frontalFacesEncrypted:s,frontalScaledImage:l,capturedFrames:n,video:D().length?D()[0]:null}),E()}eF(!1)}eN()},r=y(()=>{let{curStepIndex:e,steps:t}=eK.current,a=t[e],n=a?.image.blob!==null,s=a?.frontalFaceImage.blob!==null,r=t.filter(e=>e.frontalFaceImage.blob).length,l=!1;return n&&(s||![1].includes(e)||r>=1)?(eC.current=!1,i(),l=!0):n&&!s?eC.current=!0:eC.current=!1,eR(!1),l},er);async function l({faceDirection:e,canvas:t,blurScore:a,leftRightScore:n,isEyeClose:s}){let{curStepIndex:l,steps:c}=eK.current;if(l<c.length){let o=c[l];if(O({faceDirection:e,curStep:o})||s)return;if(e===W.FRONTAL&&(null===o.frontalFaceImage.blurScore||k.hasBetterBlurScore(a,o.frontalFaceImage.blurScore))){o.frontalFaceImage.blurScore=a;let e=await p.takePicture({canvas:t});o.frontalFaceImage.blob=e,o.frontalFaceImage.leftRightScore=n,o.frontalFaceImage.captureTime=Date.now(),eC.current&&(eC.current=!1,i())}if(o.name===e&&(null===o.image.blurScore||k.hasBetterBlurScore(a,o.image.blurScore))){eR(!0),o.image.blurScore=a;let e=await p.takePicture({canvas:t});o.image.blob=e,o.image.leftRightScore=n,o.image.captureTime=Date.now(),o.image.objUrl&&URL.revokeObjectURL(o.image.objUrl),o.image.objUrl=URL.createObjectURL(e),r()}}}async function c(a,i){let r,o;if(i?.width===0||i?.height===0)return;let{isFirstValidFrameFoundRef:m}=ty.current,{cropX:g,cropY:u,cropWidth:_,cropHeight:d}=a;i.getContext("2d").drawImage(t,g,u,_,d,-((400*eb-400)/2)/eb,-((400*eb-400)/2)/eb,400,400);let{blazefaceModel:b,closeEyesModel:h}=eV.current,[p,v]=await Promise.all([k.calculateBlurScore(i),w.getModelPredictions({model:b,sCanvas:i})]),{error:y,fullFace:I,faceRatio:T,faceNotFrontalMinThreshold:L}=await n.validatePredictions({predictions:v,width:w.SIZE,height:w.SIZE});r=y,eP.current.image=R;let x=null,D=null,E=null,A=null,{curStepIndex:M,steps:O}=eK.current;if(I){let e=O[M],t=e&&e.name===W.FRONTAL;E=I.landmarks;let a=await n.calculateFaceDirection({landmarks:E,getPerfectFrontal:t});a&&(x=a.gesture,D=a.leftRightScore);let l=e1?.webTimeout+ea[s.FaceDirection.FRONTAL].delayTime/1e3;if(t&&e1?.enable&&(-1===V.duration("limit_close_eye")||V.duration("limit_close_eye")<l)){e1?.forceCheck||-1!==V.duration("limit_close_eye")||V.start("limit_close_eye");let{isEyeClose:e}=await h.predict(i,E,e1?.webThreshold);(A=e)&&!r&&(r=K.close_eye)}}let N=r?.code==="no_face"||r?.code==="partial_face",P=M<O.length;!function({noFace:e,isFirstValidFrameFoundRef:t}){if(!e0.enable||!t)return;let{maxTimeMs:a}=e0;tm.current&&e||(tm.current={time:Date.now(),frame:0}),e&&tm.current.frame++;let{time:n}=tm.current;e&&Date.now()-n>=a&&(ez({...tb.liveness_terminated_no_face,duration:eQ}),tl({tag:"selfie",event:z?.show_alert,log:{alert:"liveness_terminated_no_face"}}),td())}({noFace:N&&P,isFirstValidFrameFoundRef:m}),r?.code&&tc({tag:"selfie",event:z?.show_alert,log:{alert:r.code}}),!r||"face_too_small"===r.code&&x!==W.FRONTAL&&T>=L?(m||(eL(!0),eH.current=performance.now(),V.start("from_1st_frame")),function({trackingScore:e,isFirstValidFrameFoundRef:t}){if(!eX.enable||null===e||!t)return!0;let{webWarningThreshold:a,webTerminateThreshold:n,maxWarningTime:s}=eX;return!!(e<a)||(e<n&&to.current<s?(to.current++,to.current===s?(ez({...tb.liveness_terminated_face_tracking,duration:eQ}),tl({tag:"selfie",event:z?.show_alert,log:{alert:"liveness_terminated_face_tracking"}})):ez({...tb.liveness_too_fast,duration:1500}),!0):(ez({...tb.liveness_terminated,duration:eQ}),tl({tag:"selfie",event:z?.show_alert,log:{alert:"liveness_terminated"}}),td(),!1))}({trackingScore:function(e,t,a,n){if(eG.current.length&&Date.now()-eG.current[eG.current.length-1].time<e4.framesIntervalTime)return null;if(e4.enable&&!n){let{topLeft:n,bottomRight:s}=e,i=[...n,...s],{score:r,time:l}=U(e,0===eG.current.length),c={label:"portrait",base64:t.toDataURL("image/jpeg",.8).split(",")[1],landmarks:a,original_landmarks:a,score:r,time:l,index:eG.current.length,bbox:i,original_bbox:i,metadata:JSON.stringify({})};if(ed&&ed.key){if(c.base64=F.encryptFrameBase64(c.base64,ed.key),eG.current.push(c),e4.framesBatchLength>0&&eG.current.length%e4.framesBatchLength==0&&e_){let e=eG.current.slice(-e4.framesBatchLength);Promise.all(e.map(e=>e?.base64)).then(t=>{e_(e.map(({label:e,index:a},n)=>({base64:t[n],label:e,index:a}))),f&&ti.enableUploadFrames&&B(ed,e.map(({label:e,index:a},n)=>({base64:t[n],label:e,index:a})),eO,eG.current.length===e4.framesBatchLength)})}}else if(eG.current.push(c),e4.framesBatchLength>0&&eG.current.length%e4.framesBatchLength==0&&e_){let e=eG.current.slice(-e4.framesBatchLength);tn(e),e_(e.map(({base64:e,label:t,index:a,metadata:n})=>({base64:e,label:t,index:a,metadata:n}))),f&&ti.enableUploadFrames&&B(ed,e,eO,eG.current.length===e4.framesBatchLength)}return r}return null}(v[0],i,E,M>=O.length),isFirstValidFrameFoundRef:m})&&await l({faceDirection:x,canvas:i,blurScore:p,leftRightScore:D,isEyeClose:A})):M<O.length&&(o=tb[r.code],eP.current.image=S),eq(o),-1!==e&&(e=requestAnimationFrame(()=>c(a,i)))}async function o(){let e=p.analyzeVideoAndWindowSizes(t,eP.current),a=document.createElement("canvas");a.width=400,a.height=400;let n=a.getContext("2d");n.translate(400,0),n.scale(-1*eb,+eb);let{mediaRecorder:s}=ts&&t?await A({outputImagesSize:400,videoEl:t,resultAnalyzeVideoAndWindowSizes:e}):{};tg.current=s,tg.current&&tg.current.start(),c(e,a)}return ey&&ej&&setTimeout(()=>{o()},e3??ef),()=>{cancelAnimationFrame(e),e=-1}},[ev,e3,ef,ey,eB,eO,f,R,S,en,es,ei,er,e4,eo,eX,eY.enable,ec,eq,ea,eQ,td,e0,tb,ej,tl,e_,ed,eb,e1?.enable,e1?.webThreshold,e1?.webTimeout,e1?.forceCheck,e6.enable,eA,tc,ts,ti,tw,e7,tn,e8.enable]);let{curStepIndex:tI,steps:tT}=eK.current,tR=e.useMemo(()=>tT.find(e=>e.name===s.FaceDirection.FRONTAL),[tT]),tS=eC.current?tR:tT[tI],tL=tS&&eS?tS.instructions[eB]:null,tx=tS&&eS?tS.directionIcon:"";return{resetFlowOnOrientationChange:e5,cropArea:eP,curStepIndex:tI,directionIcon:tx,directionIconAnimation:tS?tS.directionIconAnimation:"",faceDetectionError:e$,resetFlow:td,handleVideoPlayed:tF,instructions:tL,refVideo:ex,refIsReseting:tu,steps:tT,videoPlayed:ey,activeCapturing:eT,isFirstValidFrameFound:eS,warmupDone:ej,showLoading:ew}}export{X as u};
@@ -0,0 +1 @@
1
+ import{$ as r}from"./chunk-c747321c.js";import{r as o}from"./chunk-036bae4b.js";var s=r(o());export{s as d};
@@ -1 +1 @@
1
- import{r as e,u as t,k as s,b as a,A as i,m as n,ap as r,aq as l,M as o,O as _,Q as g,j as d,ar as c,as as m,at as f,au as u,av as v,aC as b,aD as h,az as p,G as k,R as y,d as S,f as C,s as F,aA as x,aB as w,Z as E,P as W}from"./chunk-d315aa24.js";import{d as R}from"./chunk-14e1b552.js";import{t as M}from"./chunk-af89e5b6.js";import{C as L,O as O}from"./chunk-ca868cf7.js";import{u as D,S as B,a as I,o as P,b as T,c as j,d as A,n as V,l as q,f as U,F as z,e as Q,s as N,g as G,h as J,i as H,j as K,W as $,k as X,m as Y,p as Z,q as ee,r as et,A as es,O as ea}from"./chunk-e8ed1b74.js";import{m as ei,u as en,b as er}from"./chunk-0da61929.js";import{u as el}from"./chunk-f7c561aa.js";let eo=0,e_=1,eg={data:{settings:{sdk_settings:{passive_liveness_v2_settings:{frontal_face_check:{enable:!0,up_down_bound_min:.35,up_down_bound_max:.7},capture_frame_settings:{enable:!1,frames_batch_length:10,frames_interval_time:0,frame_quality:.8,frame_scale:1,auto_capture_min_frames:8,auto_capture_min_frames_far:8,auto_capture_min_frames_close:0},not_qualified_settings:{enable_far:!1,threshold_far:.11},close_eyes_settings:{enable:!1,timeout:5,force_check:!1},face_settings:{chin_height:20,max_far_face_ratio:.9,min_far_face_ratio:.8,mobile:{chin_height:20,max_far_face_ratio:.9,min_far_face_ratio:.85}},timeout_settings:{enable:!0,total:30,countdown:10,max_retry_count:0,non_stoppable:!1},exif_data_settings:{enable:!0},mask_settings:{mobile:{oval_vertical_padding:20,oval_horizontal_padding:20,oval_vertical_offset:60,small_scale:.65},oval_horizontal_padding:20,oval_vertical_padding:20,oval_vertical_offset:0,small_scale:.6},image_settings:{valid_face_ratio:.6,image_quality:1,crop_center_far:!0,crop_center_close:!1,detection_to_whole_face_ratio:.8},blur_far_settings:{enable:!0,blurry_threshold:.4,wait_for_best_image_time_ms:1e3},brightness_detection_far_settings:{enable_too_bright_check:!1,enable_too_dark_check:!1,too_bright_threshold:.83,too_dark_threshold:.195},output_image_settings:{image_ordering:["far","close"]},auto_gen_frame_ids:{enable:!1,max_items:50}}}}}},ed=()=>{let i=el();return e.useMemo(()=>{let e=ei({},eg,i),n={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.enable"),framesIntervalTime:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.frames_interval_time"),framesBatchLength:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.frames_batch_length"),frameScale:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.frame_scale"),frameQuality:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.frame_quality"),autoCaptureMinFrames:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.auto_capture_min_frames"),autoCaptureMinFramesFar:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.auto_capture_min_frames_far"),autoCaptureMinFramesClose:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.auto_capture_min_frames_close")},r={smallScale:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.small_scale":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.small_scale"),largeScale:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.small_scale":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.small_scale"),ovalPadding:{left:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_horizontal_padding":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_horizontal_padding"),right:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_horizontal_padding":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_horizontal_padding"),top:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_vertical_padding":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_vertical_padding"),bottom:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_vertical_padding":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_vertical_padding")},ovalVerticalOffset:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_vertical_offset":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_vertical_offset"),chinToMaskBottomPadding:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.mobile.chin_height":"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.chin_height")},l={minFarFaceRatio:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.mobile.min_far_face_ratio":"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.min_far_face_ratio"),maxFarFaceRatio:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.mobile.max_far_face_ratio":"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.max_far_face_ratio")},o={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.close_eyes_settings.enable"),timeout:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.close_eyes_settings.timeout"),forceCheck:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.close_eyes_settings.force_check")},_={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.exif_data_settings.enable")},g={imageQuality:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.image_settings.image_quality"),validFaceRatio:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.image_settings.valid_face_ratio"),enableCropCenterFar:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.image_settings.crop_center_far"),detectionToWholeFaceRatio:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.image_settings.detection_to_whole_face_ratio")},d=t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.max_retry_count"),c={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.enable"),total:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.total"),countdown:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.countdown"),enableMaxRetryCount:d>0,maxRetryCount:d,interruptible:!t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.non_stoppable")},m={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.blur_far_settings.enable"),threshold:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.blur_far_settings.blurry_threshold"),duration:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.blur_far_settings.wait_for_best_image_time_ms")},f={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.not_qualified_settings.enable_far"),threshold:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.not_qualified_settings.threshold_far")},u={enableTooBrightCheck:a(e,"data.settings.sdk_settings.passive_liveness_v2_settings.brightness_detection_far_settings.enable_too_bright_check"),enableTooDarkCheck:a(e,"data.settings.sdk_settings.passive_liveness_v2_settings.brightness_detection_far_settings.enable_too_dark_check"),tooBrightThreshold:a(e,"data.settings.sdk_settings.passive_liveness_v2_settings.brightness_detection_far_settings.too_bright_threshold"),tooDarkThreshold:a(e,"data.settings.sdk_settings.passive_liveness_v2_settings.brightness_detection_far_settings.too_dark_threshold")},v={imageOrdering:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.output_image_settings.image_ordering"),farImageOrder:e_,closeImageOrder:eo};Array.isArray(v.imageOrdering)&&2===v.imageOrdering.length&&"far"===v.imageOrdering[0]&&"close"===v.imageOrdering[1]&&(v.farImageOrder=0,v.closeImageOrder=1);let b={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.auto_gen_frame_ids.enable")&&c.enable,maxItems:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.auto_gen_frame_ids.max_items")};return{captureFrameSettings:n,livenessSettings:{},flashSettings:{},maskSettings:r,faceSettings:l,closeEyesSettings:o,exifSettings:_,imageSettings:g,timeoutSettings:c,blurCheckFarSettings:m,blurCheckCloseSettings:{},notQualifiedFarSettings:f,notQualifiedCloseSettings:{},brightnessDetectionFarSettings:u,brightnessDetectionCloseSettings:{},outputImageSettings:v,autoGenFrameIds:b,frontalFaceCheckSettings:{enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.frontal_face_check.enable"),upDownBoundMin:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.frontal_face_check.up_down_bound_min"),upDownBoundMax:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.frontal_face_check.up_down_bound_max")}}},[i])},ec=s.isMobile?{width:{ideal:640},whiteBalanceMode:"none"}:{width:{ideal:9999},whiteBalanceMode:"none"},em=(e,t)=>""===t.faceError&&(!!e.isEyeClosed&&!t.isEyeClosed||(!!e.isEyeClosed||!t.isEyeClosed)&&(!!u.hasBetterBrightnessScore(t.brightnessScore,e.brightnessScore)||!!u.hasSameBrightnessScore(t.brightnessScore,e.brightnessScore)&&v.hasBetterBlurScore(t.blurScore,e.blurScore)));function ef(t){let{onReset:s,onDone:a,frontCamera:u,styledComponent:v,onFramesCaptured:S,customComponent:C,extraConfig:F}=t,{onErrorCallback:x,onCloseCallback:w}=en(),E=ed(),W=C?.PassiveLivenessBody??b,O=C?.PassiveLivenessError??h,Z=C?.PassiveLivenessCloseIcon??p,{maskSettings:ee,faceSettings:et,captureFrameSettings:es,exifSettings:ea,imageSettings:ei,timeoutSettings:el,blurCheckFarSettings:eo,outputImageSettings:e_,autoGenFrameIds:eg}=E,ef=e.useRef(),eu=D(),ev=er(),[eb,eh]=e.useState(""),ep=e.useMemo(()=>M(eh,1e3),[]),[ek,ey]=e.useState(!1),[eS,eC]=e.useState(B.LOADING),eF=i(),ex={width:n("FlashLiveness.mask.width")({theme:eF}),height:n("FlashLiveness.mask.height")({theme:eF}),strokeColor:(eS===B.FAR_FACE||eS===B.CLOSE_FACE)&&eb&&!ek?n("FlashLiveness.mask.strokeColorError")({theme:eF}):n("FlashLiveness.mask.strokeColor")({theme:eF}),strokeWidth:2*n("FlashLiveness.mask.strokeWidth")({theme:eF}),path:n("FlashLiveness.mask.path")({theme:eF}),backgroundColor:n("FlashLiveness.maskFill")({theme:eF})},ew=e.useRef(null),[eE,eW,eR]=I(),[eM,eL]=e.useState(0),[eO,eD]=e.useState(!1),eB=e.useRef({frames:[],images:[]}),eI=e.useRef(!1),eP=P(),eT=T({compareFn:em,duration:eo.duration,minFrames:es.autoCaptureMinFrames}),[ej,eA]=e.useState(!1),{sessionId:eV,updateSessionId:eq}=j(),eU=e.useRef(r.createSingleUUID()),{onVideoPlayed:ez,cropArea:eQ,isPlaying:eN}=A({}),{smallScale:eG,largeScale:eJ}=V(ee,{width:ex.width,height:ex.height},{width:eQ.width,height:eQ.height}),eH=1e3*el.total/es.framesIntervalTime,{uuids:eK,getNextUUID:e$,reset:eX}=l({total:Math.min(eg.maxItems,Math.ceil(eH/es.framesBatchLength*1.2))}),eY=e.useCallback(e=>{let t=e[e.length-1];try{let e=JSON.parse(t.metadata);eg.enable&&(e.global_batch_id=e$()),e.global_session_id=eU.current,t.metadata=JSON.stringify(e)}catch(e){console.error("Unable to process last frame metadata",e)}},[eg.enable,e$]),eZ=e.useRef(null),{playVoice:e2}=o.useVoicePlayer(),e0=e.useMemo(()=>R(()=>{if(eI.current=!1,eB.current.frames=[],eB.current.images=[],eZ.current=null,eL(eG),eC(B.FAR_FACE),e2("move_face_into_frame"),eq(),eT.stopCapturing(),ey(!1),eg.enable){let e=eX();_.addExifData("frame_batch_ids",e)}s()},200,{leading:!0}),[eG,e2,eq,eT,eg.enable,s,eX]),e1=q({offset:ee.ovalVerticalOffset,ovalPadding:ee.ovalPadding,largeScale:eJ,maskHeight:eQ.height,ovalHeight:ex.height}),e8=e.useCallback(async()=>{eC(B.STOP_DECTECTING),eu("selfie_passive_v2","user_activity",()=>({passive_liveness_in_ms:performance.now()-ef.current}));let{frames:e}=eB.current;if(es.enable&&es.framesBatchLength>0){let t=e.length%es.framesBatchLength;if(0!==t){let s=e.slice(-1*t);eY(s),"function"==typeof S&&S(s)}}eB.current.images[e_.farImageOrder].blob=await eB.current.images[e_.farImageOrder].blob,_.addExifData("selfie_type","passive_v2"),_.addExifData("passive_liveness_v2",{number_of_frames:{far_frames:e.length},passive_liveness_in_ms:Math.round(performance.now()-ef.current),face_settings:{max_far_face_ratio:et.maxFarFaceRatio,min_far_face_ratio:et.minFarFaceRatio},mask_settings:{oval_vertical_offset:ee.ovalVerticalOffset,small_scale:ee.smallScale},image_settings:{valid_face_ratio:ei.validFaceRatio}});let t=await _.writeCurrentExif({imageData:eB.current.images[e_.farImageOrder],enableExifData:ea.enable});eB.current.images[e_.farImageOrder].blob=t,eP.enable&&(eB.current.images[e_.farImageOrder].encrypted=await g.encrypt({blob:eB.current.images[e_.farImageOrder].blob,key:eP.key})),eB.current.images=eB.current.images.filter(e=>!!e);try{"function"==typeof a&&await a({images:eB.current.images,frames:eB.current.frames})}catch(e){x({error:e})}},[eu,es.enable,es.framesBatchLength,e_.farImageOrder,et.maxFarFaceRatio,et.minFarFaceRatio,ee.ovalVerticalOffset,ee.smallScale,ei.validFaceRatio,ea.enable,eP.enable,eP.key,eY,S,a,x]),e3=e.useCallback(({prediction:e,canvas:t})=>{if(!es.enable)return;let{frames:s}=eB.current,a=U({prediction:e,canvas:t,index:s.length,quality:es.frameQuality});if(a.metadata=JSON.stringify({type:z.FAR_FACE,time:Math.round(performance.now()),session_id:eV}),s.push(a),es.framesBatchLength<=0||s.length%es.framesBatchLength!=0)return;let i=s.slice(-1*es.framesBatchLength);eY(i),"function"==typeof S&&S(i)},[es.enable,es.frameQuality,es.framesBatchLength,S,eY,eV]),e9=e.useCallback(async()=>{let{frames:e}=eB.current;0===e.length&&(eI.current=!0)},[]),e5=e.useMemo(()=>({x:Math.max(eW?.left,0),y:Math.max(eW?.top,0),width:Math.min(eW?.right-eW?.left,eQ.width),height:Math.min(eW?.bottom-eW?.top,eQ.height)}),[eQ.height,eQ.width,eW?.bottom,eW?.left,eW?.right,eW?.top]),e6=e.useCallback(async({frame:e,prediction:t,canvas:s,originalRatio:a})=>{if("no_face"===e.faceError||eB.current.images[e_.farImageOrder])return;if(es.enable){let e=performance.now();if(null!==eZ.current&&e-eZ.current<es.framesIntervalTime)return;eZ.current=e}let i=e=>{let t=X({maskBoundingBox:e5,faceRatio:e.faceRatio,validFaceRatio:ei.validFaceRatio,video:ew.current,shouldCropCenterSquare:ei.enableCropCenterFar,cropArea:eQ,frame:e.snapshot,facePrediction:e.facePrediction,detectionToWholeFaceRatio:ei.detectionToWholeFaceRatio}),s={blob:k.takePicture({canvas:t,quality:ei.imageQuality}),gesture:"frontal",captureTime:e.captureTime,selfieLabel:z.FAR_FACE,qualifyScore:e.qualifyScore,blurScore:e.blurScore,brightnessScore:e.brightnessScore};_.addExifData("model_score.face_blurry_score",s.blurScore),_.addExifData("model_score.face_brightness_score",s.brightnessScore),_.addExifData("model_score.face_qualify_score",s.qualifyScore),_.addExifData("selfie_label",s.selfieLabel),_.addExifData("capture_time",s.captureTime),_.addExifData("type",s.gesture),eB.current.images[e_.farImageOrder]=s},n={qualifyScore:e.qualifyScore,blurScore:e.blurScore,isEyeClosed:e.isEyeClosed,faceRatio:e.faceRatio,snapshot:Q(ew.current),captureTime:Date.now(),facePrediction:N(t,a),brightnessScore:e.brightnessScore,faceError:e.faceError};if(!eo.enable){e3({prediction:t,canvas:s}),i(n),await e8();return}if(!eT.isAutoCapturing()){await e2("please_hold_still"),ey(!0),e3({prediction:t,canvas:s}),eT.startCapturing({onDone:async e=>{i(e),await e8()},initialFrame:n});return}e3({prediction:t,canvas:s}),eT.captureFrame(n)},[e_.farImageOrder,es.enable,es.framesIntervalTime,eo.enable,eT,e3,e5,ei.validFaceRatio,ei.enableCropCenterFar,ei.detectionToWholeFaceRatio,ei.imageQuality,eQ,e8,e2]),{warmupDone:e4}=G({onError:x,isVideoPlaying:eN,step:eS,cropArea:eQ,videoRef:ew,onFarFaceDetected:e9,onFarFullFaceDetected:e6,onFaceError:e.useCallback(({error:e})=>{ep(e),("no_face"===e||"multiple_faces"===e)&&"no_face"===e&&eI.current&&e0()},[e0,ep]),faceSettings:et,maskBoundingRect:eW,shouldPauseFaceDetection:eR||ej,faceDetectionSettings:E,shouldContinueOnError:ek,debug:ev});J(ew.current);H(()=>{!async function(){let{resourceReport:e,measureReport:t}=await y.reportAll();Object.values(e).forEach(e=>{eu("selfie_passive_v2","sdk.download_model",e)}),Object.values(t).forEach(e=>{eu("selfie_passive_v2","sdk.init_model",e)})}()},e4),H(()=>{eC(B.FAR_FACE),eL(eG),e2("move_face_into_frame"),eD(!0),eg.enable&&_.addExifData("frame_batch_ids",eK),_.addExifData("global_session_id",eU.current),ef.current||(ef.current=performance.now())},e4&&eN),H(()=>eu("selfie_passive_v2","user_activity.start"),!0),H(()=>eu("selfie_passive_v2","user_activity.start_far"),eS===B.FAR_FACE);let{Loading:e7}=v,te=e.useCallback(()=>{ey(!1),eT.stopCapturing(),eA(!0)},[eT]),tt=e.useCallback(()=>{eA(!1),e0()},[e0]),{remaining:ts}=K({shouldStart:eO&&el.enable,onTimeout:te,onDelayEnd:tt,onError:x,totalTime:el.total,totalDelay:3,maxRetriesSettings:{enable:el.enableMaxRetryCount,total:el.maxRetryCount},interruptible:el.interruptible}),ta=Y(eb),ti=eQ.y+eQ.height/2+e1,tn=eo.duration,tr=Math.max(tn,es.autoCaptureMinFrames*es.framesIntervalTime);return d.jsxs(d.Fragment,{children:[d.jsx(c,{frontCamera:u,onVideoPlayed:ez,onClose:w,flipHorizontal:u,ref:ew,onError:x,videoSettings:ec,closeButton:d.jsx(Z,{}),children:d.jsxs($,{overlay:!e4||!eN,loadingComponent:e7,children:[!ek&&""!==eb&&d.jsx(m,{}),d.jsx(L,{x:`${Math.round(eQ.x)}px`,y:`${Math.round(eQ.y)}px`,width:`${eQ.width}px`,height:`${eQ.height}px`,surroundStyle:{background:n("FlashLiveness.maskFill")({theme:eF})},children:d.jsx(f,{ref:eE,scale:eM,debug:ev,width:eQ.width,height:eQ.height,padding:ee.ovalPadding,verticalOffset:e1,mask:ex})}),!ek&&""!==ta&&d.jsx(O,{errorY:ti,errorMessage:ta})]})}),d.jsx(W,{step:eS,errorCode:eb,timeoutProps:{remaining:ts,warningThreshold:el.countdown,total:el.total,shouldStart:eO&&el.enable},isAutoCapturing:ek,autoCaptureDuration:tr,extraConfig:F})]})}let eu=t=>{let{apiCheck:s,onLivenessDetectionDone:a,frontalMinSize:i,serviceSettings:n,apiCredentials:r,...l}=t,o=l.customComponent?.FlashLivenessLoading??x,[_,g]=e.useState(!1),c=P(),m=el(),f=C.getEnabledServices(n,m),{verifyLiveness:u}=function({outputEncryptionSettings:t,selfieType:s,enabledServices:a,apiCredentials:i}){let{apiClient:n}=S.useApiClient({apiCredentials:i});return{verifyLiveness:e.useCallback(async({videos:e,images:i,metadata:r})=>{try{let l=await Promise.all(i.map(e=>{if(!t.enable)return n.uploadImage({label:"portrait",file:e.blob,metadata:JSON.stringify({label:e.selfieLabel})});let s=new Blob([e.encrypted.hex]);return n.uploadImage({file:s,label:"portrait",metadata:JSON.stringify({label:e.selfieLabel})},{"X-TV-Key":t.key})})),o=null;a.enableVerifyFaceLiveness&&(o=n.verifyFaceLiveness({images:l.map(e=>({id:e?.data?.image_id,label:"portrait"})),videos:e,metadata:r,selfie_type:s}));let _=null;a.enableVerifySanityPortrait&&(_=n.requestVerifyPortrait({image:{id:l[l.length-1]?.data?.image_id},selfie_type:s}));let[g,d]=await Promise.all([o,_]);return{uploadedImages:l,faceLivenessResult:g,portraitResult:d}}catch(e){return console.error(e),{}}},[n,a.enableVerifyFaceLiveness,a.enableVerifySanityPortrait,t.enable,t.key,s])}}({apiCredentials:r,outputEncryptionSettings:c,selfieType:F.Mode.PASSIVE_V2,enabledServices:f}),{captureFrameSettings:v}=ed(),{framesIntervalTime:b}=v,{onFramesCaptured:h,onReset:p}=t,{onErrorCallback:k}=en(),y=Z(),W=async e=>{let t=e;if(c.enable&&(t=await w.encryptFrames(t,c.key)),"function"==typeof h&&h(t),s&&f.enableUploadFrames){let e={};c.enable&&(e["X-TV-Key"]=c.key),ee.uploadFrameBatch(et(t),y,e)}},R=async e=>{let t={frame_interval:b},n=e.images.filter(e=>"frontal"===e.gesture),r=n.map(e=>e.blob),l=n.map(e=>e.encrypted),o=r[r.length-1],_=o&&"number"==typeof i?await E.scaleImage(o,{minsize:i}):null,d=e.frames;if(c.enable&&(d=await w.encryptFrames(d,c.key)),!s||!f.enableUploadImages)return void await a({capturedFrames:d,frontalFaces:r,frontalFacesEncrypted:l,frontalScaledImage:_,steps:[],metadata:t});try{g(!0);let s=null;s=v.enable?await ee.getAllUploadedBatches():[{frames:et(d)}];let{uploadedImages:i,faceLivenessResult:n,portraitResult:o}=await u({videos:s,images:e.images,metadata:t});if(ee.resetUploadBatches(),g(!1),n?.errors)throw n.errors;if(o?.errors)throw o.errors;await a({capturedFrames:d,steps:[],frontalFaces:r.map((e,t)=>({blob:e,id:i?.[t]?.data?.image_id})),frontalFacesEncrypted:l,frontalScaledImage:_,apiCheckPassed:n?.data.is_live??!1,verifyFaceLivenessResult:n?.data??null,verifyPortraitResult:o?.data??null,uploadFramesResult:s})}catch(e){console.error(e),g(!1),k({error:e})}};return d.jsxs(d.Fragment,{children:[d.jsx(ef,{...l,apiCheck:s,onDone:R,onFramesCaptured:W,onReset:()=>{ee.resetUploadBatches(),"function"==typeof p&&p()}}),s&&d.jsx(o,{loading:_})]})},ev=e=>{let{apiCredentials:t,outputEncryptionSettings:s}=e;return d.jsx(O,{version:"v2",unmountOnHidden:!0,children:d.jsx(es,{apiCredentials:t,children:d.jsx(ea,{settings:s,children:d.jsx(eu,{...e})})})})};ev.propTypes={apiCheck:W.bool,apiCredentials:W.shape({accessKey:W.string,secretKey:W.string,apiUrl:W.string}),onReset:W.func,onLivenessDetectionDone:W.func,onClose:W.func,onError:W.func,onFramesCaptured:W.func,frontCamera:W.bool,styledComponent:W.shape({CloseCameraButton:W.node}),outputEncryptionSettings:W.shape({key:W.string}),frontalMinSize:W.number,serviceSettings:W.shape({enableGetClientSettings:W.bool,enableUploadFrames:W.bool,enableUploadImages:W.bool,enableVerifySanityPortrait:W.bool,enableVerifyFaceLiveness:W.bool}),mode:W.string,flowId:W.string,customTexts:W.shape({}),customComponents:W.shape({PassiveLivenessBody:W.elementType}),extraConfig:W.shape({})},ev.defaultProps={apiCheck:!1,apiCredentials:{},onReset:()=>{},onLivenessDetectionDone:()=>{},onClose:()=>{},onError:()=>{},onFramesCaptured:()=>{},frontCamera:!0,styledComponent:{CloseCameraButton:null},outputEncryptionSettings:{key:""},frontalMinSize:null,serviceSettings:{enableGetClientSettings:!0,enableUploadFrames:!0,enableUploadImages:!0,enableVerifySanityPortrait:!0,enableVerifyFaceLiveness:!0},flowId:"",customTexts:{},customComponents:{PassiveLivenessBody:null},extraConfig:null};export{ev as default};
1
+ import{r as e,u as t,k as s,b as a,A as i,m as n,ap as r,aq as l,M as o,O as _,Q as g,j as d,ar as c,as as m,at as f,au as u,av as v,aC as b,aD as h,az as p,G as k,R as y,d as S,f as C,s as F,aA as x,aB as w,Z as E,P as W}from"./chunk-c747321c.js";import{d as R}from"./chunk-71ff4107.js";import{t as M}from"./chunk-036bae4b.js";import{C as L,O as O}from"./chunk-da8ef78b.js";import{u as D,S as B,a as I,o as P,b as T,c as j,d as A,n as V,l as q,f as U,F as z,e as Q,s as N,g as G,h as J,i as H,j as K,W as $,k as X,m as Y,p as Z,q as ee,r as et,A as es,O as ea}from"./chunk-48199d95.js";import{m as ei,u as en,b as er}from"./chunk-51b3fd2d.js";import{u as el}from"./chunk-6e5358d6.js";let eo=0,e_=1,eg={data:{settings:{sdk_settings:{passive_liveness_v2_settings:{frontal_face_check:{enable:!0,up_down_bound_min:.35,up_down_bound_max:.7},capture_frame_settings:{enable:!1,frames_batch_length:10,frames_interval_time:0,frame_quality:.8,frame_scale:1,auto_capture_min_frames:8,auto_capture_min_frames_far:8,auto_capture_min_frames_close:0},not_qualified_settings:{enable_far:!1,threshold_far:.11},close_eyes_settings:{enable:!1,timeout:5,force_check:!1},face_settings:{chin_height:20,max_far_face_ratio:.9,min_far_face_ratio:.8,mobile:{chin_height:20,max_far_face_ratio:.9,min_far_face_ratio:.85}},timeout_settings:{enable:!0,total:30,countdown:10,max_retry_count:0,non_stoppable:!1},exif_data_settings:{enable:!0},mask_settings:{mobile:{oval_vertical_padding:20,oval_horizontal_padding:20,oval_vertical_offset:60,small_scale:.65},oval_horizontal_padding:20,oval_vertical_padding:20,oval_vertical_offset:0,small_scale:.6},image_settings:{valid_face_ratio:.6,image_quality:1,crop_center_far:!0,crop_center_close:!1,detection_to_whole_face_ratio:.8},blur_far_settings:{enable:!0,blurry_threshold:.4,wait_for_best_image_time_ms:1e3},brightness_detection_far_settings:{enable_too_bright_check:!1,enable_too_dark_check:!1,too_bright_threshold:.83,too_dark_threshold:.195},output_image_settings:{image_ordering:["far","close"]},auto_gen_frame_ids:{enable:!1,max_items:50}}}}}},ed=()=>{let i=el();return e.useMemo(()=>{let e=ei({},eg,i),n={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.enable"),framesIntervalTime:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.frames_interval_time"),framesBatchLength:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.frames_batch_length"),frameScale:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.frame_scale"),frameQuality:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.frame_quality"),autoCaptureMinFrames:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.auto_capture_min_frames"),autoCaptureMinFramesFar:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.auto_capture_min_frames_far"),autoCaptureMinFramesClose:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.capture_frame_settings.auto_capture_min_frames_close")},r={smallScale:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.small_scale":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.small_scale"),largeScale:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.small_scale":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.small_scale"),ovalPadding:{left:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_horizontal_padding":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_horizontal_padding"),right:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_horizontal_padding":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_horizontal_padding"),top:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_vertical_padding":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_vertical_padding"),bottom:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_vertical_padding":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_vertical_padding")},ovalVerticalOffset:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.mobile.oval_vertical_offset":"data.settings.sdk_settings.passive_liveness_v2_settings.mask_settings.oval_vertical_offset"),chinToMaskBottomPadding:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.mobile.chin_height":"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.chin_height")},l={minFarFaceRatio:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.mobile.min_far_face_ratio":"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.min_far_face_ratio"),maxFarFaceRatio:t.getWebSetting(e,s.isMobile?"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.mobile.max_far_face_ratio":"data.settings.sdk_settings.passive_liveness_v2_settings.face_settings.max_far_face_ratio")},o={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.close_eyes_settings.enable"),timeout:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.close_eyes_settings.timeout"),forceCheck:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.close_eyes_settings.force_check")},_={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.exif_data_settings.enable")},g={imageQuality:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.image_settings.image_quality"),validFaceRatio:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.image_settings.valid_face_ratio"),enableCropCenterFar:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.image_settings.crop_center_far"),detectionToWholeFaceRatio:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.image_settings.detection_to_whole_face_ratio")},d=t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.max_retry_count"),c={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.enable"),total:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.total"),countdown:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.countdown"),enableMaxRetryCount:d>0,maxRetryCount:d,interruptible:!t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.timeout_settings.non_stoppable")},m={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.blur_far_settings.enable"),threshold:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.blur_far_settings.blurry_threshold"),duration:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.blur_far_settings.wait_for_best_image_time_ms")},f={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.not_qualified_settings.enable_far"),threshold:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.not_qualified_settings.threshold_far")},u={enableTooBrightCheck:a(e,"data.settings.sdk_settings.passive_liveness_v2_settings.brightness_detection_far_settings.enable_too_bright_check"),enableTooDarkCheck:a(e,"data.settings.sdk_settings.passive_liveness_v2_settings.brightness_detection_far_settings.enable_too_dark_check"),tooBrightThreshold:a(e,"data.settings.sdk_settings.passive_liveness_v2_settings.brightness_detection_far_settings.too_bright_threshold"),tooDarkThreshold:a(e,"data.settings.sdk_settings.passive_liveness_v2_settings.brightness_detection_far_settings.too_dark_threshold")},v={imageOrdering:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.output_image_settings.image_ordering"),farImageOrder:e_,closeImageOrder:eo};Array.isArray(v.imageOrdering)&&2===v.imageOrdering.length&&"far"===v.imageOrdering[0]&&"close"===v.imageOrdering[1]&&(v.farImageOrder=0,v.closeImageOrder=1);let b={enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.auto_gen_frame_ids.enable")&&c.enable,maxItems:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.auto_gen_frame_ids.max_items")};return{captureFrameSettings:n,livenessSettings:{},flashSettings:{},maskSettings:r,faceSettings:l,closeEyesSettings:o,exifSettings:_,imageSettings:g,timeoutSettings:c,blurCheckFarSettings:m,blurCheckCloseSettings:{},notQualifiedFarSettings:f,notQualifiedCloseSettings:{},brightnessDetectionFarSettings:u,brightnessDetectionCloseSettings:{},outputImageSettings:v,autoGenFrameIds:b,frontalFaceCheckSettings:{enable:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.frontal_face_check.enable"),upDownBoundMin:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.frontal_face_check.up_down_bound_min"),upDownBoundMax:t.getWebSetting(e,"data.settings.sdk_settings.passive_liveness_v2_settings.frontal_face_check.up_down_bound_max")}}},[i])},ec=s.isMobile?{width:{ideal:640},whiteBalanceMode:"none"}:{width:{ideal:9999},whiteBalanceMode:"none"},em=(e,t)=>""===t.faceError&&(!!e.isEyeClosed&&!t.isEyeClosed||(!!e.isEyeClosed||!t.isEyeClosed)&&(!!u.hasBetterBrightnessScore(t.brightnessScore,e.brightnessScore)||!!u.hasSameBrightnessScore(t.brightnessScore,e.brightnessScore)&&v.hasBetterBlurScore(t.blurScore,e.blurScore)));function ef(t){let{onReset:s,onDone:a,frontCamera:u,styledComponent:v,onFramesCaptured:S,customComponent:C,extraConfig:F}=t,{onErrorCallback:x,onCloseCallback:w}=en(),E=ed(),W=C?.PassiveLivenessBody??b,O=C?.PassiveLivenessError??h,Z=C?.PassiveLivenessCloseIcon??p,{maskSettings:ee,faceSettings:et,captureFrameSettings:es,exifSettings:ea,imageSettings:ei,timeoutSettings:el,blurCheckFarSettings:eo,outputImageSettings:e_,autoGenFrameIds:eg}=E,ef=e.useRef(),eu=D(),ev=er(),[eb,eh]=e.useState(""),ep=e.useMemo(()=>M(eh,1e3),[]),[ek,ey]=e.useState(!1),[eS,eC]=e.useState(B.LOADING),eF=i(),ex={width:n("FlashLiveness.mask.width")({theme:eF}),height:n("FlashLiveness.mask.height")({theme:eF}),strokeColor:(eS===B.FAR_FACE||eS===B.CLOSE_FACE)&&eb&&!ek?n("FlashLiveness.mask.strokeColorError")({theme:eF}):n("FlashLiveness.mask.strokeColor")({theme:eF}),strokeWidth:2*n("FlashLiveness.mask.strokeWidth")({theme:eF}),path:n("FlashLiveness.mask.path")({theme:eF}),backgroundColor:n("FlashLiveness.maskFill")({theme:eF})},ew=e.useRef(null),[eE,eW,eR]=I(),[eM,eL]=e.useState(0),[eO,eD]=e.useState(!1),eB=e.useRef({frames:[],images:[]}),eI=e.useRef(!1),eP=P(),eT=T({compareFn:em,duration:eo.duration,minFrames:es.autoCaptureMinFrames}),[ej,eA]=e.useState(!1),{sessionId:eV,updateSessionId:eq}=j(),eU=e.useRef(r.createSingleUUID()),{onVideoPlayed:ez,cropArea:eQ,isPlaying:eN}=A({}),{smallScale:eG,largeScale:eJ}=V(ee,{width:ex.width,height:ex.height},{width:eQ.width,height:eQ.height}),eH=1e3*el.total/es.framesIntervalTime,{uuids:eK,getNextUUID:e$,reset:eX}=l({total:Math.min(eg.maxItems,Math.ceil(eH/es.framesBatchLength*1.2))}),eY=e.useCallback(e=>{let t=e[e.length-1];try{let e=JSON.parse(t.metadata);eg.enable&&(e.global_batch_id=e$()),e.global_session_id=eU.current,t.metadata=JSON.stringify(e)}catch(e){console.error("Unable to process last frame metadata",e)}},[eg.enable,e$]),eZ=e.useRef(null),{playVoice:e2}=o.useVoicePlayer(),e0=e.useMemo(()=>R(()=>{if(eI.current=!1,eB.current.frames=[],eB.current.images=[],eZ.current=null,eL(eG),eC(B.FAR_FACE),e2("move_face_into_frame"),eq(),eT.stopCapturing(),ey(!1),eg.enable){let e=eX();_.addExifData("frame_batch_ids",e)}s()},200,{leading:!0}),[eG,e2,eq,eT,eg.enable,s,eX]),e1=q({offset:ee.ovalVerticalOffset,ovalPadding:ee.ovalPadding,largeScale:eJ,maskHeight:eQ.height,ovalHeight:ex.height}),e8=e.useCallback(async()=>{eC(B.STOP_DECTECTING),eu("selfie_passive_v2","user_activity",()=>({passive_liveness_in_ms:performance.now()-ef.current}));let{frames:e}=eB.current;if(es.enable&&es.framesBatchLength>0){let t=e.length%es.framesBatchLength;if(0!==t){let s=e.slice(-1*t);eY(s),"function"==typeof S&&S(s)}}eB.current.images[e_.farImageOrder].blob=await eB.current.images[e_.farImageOrder].blob,_.addExifData("selfie_type","passive_v2"),_.addExifData("passive_liveness_v2",{number_of_frames:{far_frames:e.length},passive_liveness_in_ms:Math.round(performance.now()-ef.current),face_settings:{max_far_face_ratio:et.maxFarFaceRatio,min_far_face_ratio:et.minFarFaceRatio},mask_settings:{oval_vertical_offset:ee.ovalVerticalOffset,small_scale:ee.smallScale},image_settings:{valid_face_ratio:ei.validFaceRatio}});let t=await _.writeCurrentExif({imageData:eB.current.images[e_.farImageOrder],enableExifData:ea.enable});eB.current.images[e_.farImageOrder].blob=t,eP.enable&&(eB.current.images[e_.farImageOrder].encrypted=await g.encrypt({blob:eB.current.images[e_.farImageOrder].blob,key:eP.key})),eB.current.images=eB.current.images.filter(e=>!!e);try{"function"==typeof a&&await a({images:eB.current.images,frames:eB.current.frames})}catch(e){x({error:e})}},[eu,es.enable,es.framesBatchLength,e_.farImageOrder,et.maxFarFaceRatio,et.minFarFaceRatio,ee.ovalVerticalOffset,ee.smallScale,ei.validFaceRatio,ea.enable,eP.enable,eP.key,eY,S,a,x]),e3=e.useCallback(({prediction:e,canvas:t})=>{if(!es.enable)return;let{frames:s}=eB.current,a=U({prediction:e,canvas:t,index:s.length,quality:es.frameQuality});if(a.metadata=JSON.stringify({type:z.FAR_FACE,time:Math.round(performance.now()),session_id:eV}),s.push(a),es.framesBatchLength<=0||s.length%es.framesBatchLength!=0)return;let i=s.slice(-1*es.framesBatchLength);eY(i),"function"==typeof S&&S(i)},[es.enable,es.frameQuality,es.framesBatchLength,S,eY,eV]),e9=e.useCallback(async()=>{let{frames:e}=eB.current;0===e.length&&(eI.current=!0)},[]),e5=e.useMemo(()=>({x:Math.max(eW?.left,0),y:Math.max(eW?.top,0),width:Math.min(eW?.right-eW?.left,eQ.width),height:Math.min(eW?.bottom-eW?.top,eQ.height)}),[eQ.height,eQ.width,eW?.bottom,eW?.left,eW?.right,eW?.top]),e6=e.useCallback(async({frame:e,prediction:t,canvas:s,originalRatio:a})=>{if("no_face"===e.faceError||eB.current.images[e_.farImageOrder])return;if(es.enable){let e=performance.now();if(null!==eZ.current&&e-eZ.current<es.framesIntervalTime)return;eZ.current=e}let i=e=>{let t=X({maskBoundingBox:e5,faceRatio:e.faceRatio,validFaceRatio:ei.validFaceRatio,video:ew.current,shouldCropCenterSquare:ei.enableCropCenterFar,cropArea:eQ,frame:e.snapshot,facePrediction:e.facePrediction,detectionToWholeFaceRatio:ei.detectionToWholeFaceRatio}),s={blob:k.takePicture({canvas:t,quality:ei.imageQuality}),gesture:"frontal",captureTime:e.captureTime,selfieLabel:z.FAR_FACE,qualifyScore:e.qualifyScore,blurScore:e.blurScore,brightnessScore:e.brightnessScore};_.addExifData("model_score.face_blurry_score",s.blurScore),_.addExifData("model_score.face_brightness_score",s.brightnessScore),_.addExifData("model_score.face_qualify_score",s.qualifyScore),_.addExifData("selfie_label",s.selfieLabel),_.addExifData("capture_time",s.captureTime),_.addExifData("type",s.gesture),eB.current.images[e_.farImageOrder]=s},n={qualifyScore:e.qualifyScore,blurScore:e.blurScore,isEyeClosed:e.isEyeClosed,faceRatio:e.faceRatio,snapshot:Q(ew.current),captureTime:Date.now(),facePrediction:N(t,a),brightnessScore:e.brightnessScore,faceError:e.faceError};if(!eo.enable){e3({prediction:t,canvas:s}),i(n),await e8();return}if(!eT.isAutoCapturing()){await e2("please_hold_still"),ey(!0),e3({prediction:t,canvas:s}),eT.startCapturing({onDone:async e=>{i(e),await e8()},initialFrame:n});return}e3({prediction:t,canvas:s}),eT.captureFrame(n)},[e_.farImageOrder,es.enable,es.framesIntervalTime,eo.enable,eT,e3,e5,ei.validFaceRatio,ei.enableCropCenterFar,ei.detectionToWholeFaceRatio,ei.imageQuality,eQ,e8,e2]),{warmupDone:e4}=G({onError:x,isVideoPlaying:eN,step:eS,cropArea:eQ,videoRef:ew,onFarFaceDetected:e9,onFarFullFaceDetected:e6,onFaceError:e.useCallback(({error:e})=>{ep(e),("no_face"===e||"multiple_faces"===e)&&"no_face"===e&&eI.current&&e0()},[e0,ep]),faceSettings:et,maskBoundingRect:eW,shouldPauseFaceDetection:eR||ej,faceDetectionSettings:E,shouldContinueOnError:ek,debug:ev});J(ew.current);H(()=>{!async function(){let{resourceReport:e,measureReport:t}=await y.reportAll();Object.values(e).forEach(e=>{eu("selfie_passive_v2","sdk.download_model",e)}),Object.values(t).forEach(e=>{eu("selfie_passive_v2","sdk.init_model",e)})}()},e4),H(()=>{eC(B.FAR_FACE),eL(eG),e2("move_face_into_frame"),eD(!0),eg.enable&&_.addExifData("frame_batch_ids",eK),_.addExifData("global_session_id",eU.current),ef.current||(ef.current=performance.now())},e4&&eN),H(()=>eu("selfie_passive_v2","user_activity.start"),!0),H(()=>eu("selfie_passive_v2","user_activity.start_far"),eS===B.FAR_FACE);let{Loading:e7}=v,te=e.useCallback(()=>{ey(!1),eT.stopCapturing(),eA(!0)},[eT]),tt=e.useCallback(()=>{eA(!1),e0()},[e0]),{remaining:ts}=K({shouldStart:eO&&el.enable,onTimeout:te,onDelayEnd:tt,onError:x,totalTime:el.total,totalDelay:3,maxRetriesSettings:{enable:el.enableMaxRetryCount,total:el.maxRetryCount},interruptible:el.interruptible}),ta=Y(eb),ti=eQ.y+eQ.height/2+e1,tn=eo.duration,tr=Math.max(tn,es.autoCaptureMinFrames*es.framesIntervalTime);return d.jsxs(d.Fragment,{children:[d.jsx(c,{frontCamera:u,onVideoPlayed:ez,onClose:w,flipHorizontal:u,ref:ew,onError:x,videoSettings:ec,closeButton:d.jsx(Z,{}),children:d.jsxs($,{overlay:!e4||!eN,loadingComponent:e7,children:[!ek&&""!==eb&&d.jsx(m,{}),d.jsx(L,{x:`${Math.round(eQ.x)}px`,y:`${Math.round(eQ.y)}px`,width:`${eQ.width}px`,height:`${eQ.height}px`,surroundStyle:{background:n("FlashLiveness.maskFill")({theme:eF})},children:d.jsx(f,{ref:eE,scale:eM,debug:ev,width:eQ.width,height:eQ.height,padding:ee.ovalPadding,verticalOffset:e1,mask:ex})}),!ek&&""!==ta&&d.jsx(O,{errorY:ti,errorMessage:ta})]})}),d.jsx(W,{step:eS,errorCode:eb,timeoutProps:{remaining:ts,warningThreshold:el.countdown,total:el.total,shouldStart:eO&&el.enable},isAutoCapturing:ek,autoCaptureDuration:tr,extraConfig:F})]})}let eu=t=>{let{apiCheck:s,onLivenessDetectionDone:a,frontalMinSize:i,serviceSettings:n,apiCredentials:r,...l}=t,o=l.customComponent?.FlashLivenessLoading??x,[_,g]=e.useState(!1),c=P(),m=el(),f=C.getEnabledServices(n,m),{verifyLiveness:u}=function({outputEncryptionSettings:t,selfieType:s,enabledServices:a,apiCredentials:i}){let{apiClient:n}=S.useApiClient({apiCredentials:i});return{verifyLiveness:e.useCallback(async({videos:e,images:i,metadata:r})=>{try{let l=await Promise.all(i.map(e=>{if(!t.enable)return n.uploadImage({label:"portrait",file:e.blob,metadata:JSON.stringify({label:e.selfieLabel})});let s=new Blob([e.encrypted.hex]);return n.uploadImage({file:s,label:"portrait",metadata:JSON.stringify({label:e.selfieLabel})},{"X-TV-Key":t.key})})),o=null;a.enableVerifyFaceLiveness&&(o=n.verifyFaceLiveness({images:l.map(e=>({id:e?.data?.image_id,label:"portrait"})),videos:e,metadata:r,selfie_type:s}));let _=null;a.enableVerifySanityPortrait&&(_=n.requestVerifyPortrait({image:{id:l[l.length-1]?.data?.image_id},selfie_type:s}));let[g,d]=await Promise.all([o,_]);return{uploadedImages:l,faceLivenessResult:g,portraitResult:d}}catch(e){return console.error(e),{}}},[n,a.enableVerifyFaceLiveness,a.enableVerifySanityPortrait,t.enable,t.key,s])}}({apiCredentials:r,outputEncryptionSettings:c,selfieType:F.Mode.PASSIVE_V2,enabledServices:f}),{captureFrameSettings:v}=ed(),{framesIntervalTime:b}=v,{onFramesCaptured:h,onReset:p}=t,{onErrorCallback:k}=en(),y=Z(),W=async e=>{let t=e;if(c.enable&&(t=await w.encryptFrames(t,c.key)),"function"==typeof h&&h(t),s&&f.enableUploadFrames){let e={};c.enable&&(e["X-TV-Key"]=c.key),ee.uploadFrameBatch(et(t),y,e)}},R=async e=>{let t={frame_interval:b},n=e.images.filter(e=>"frontal"===e.gesture),r=n.map(e=>e.blob),l=n.map(e=>e.encrypted),o=r[r.length-1],_=o&&"number"==typeof i?await E.scaleImage(o,{minsize:i}):null,d=e.frames;if(c.enable&&(d=await w.encryptFrames(d,c.key)),!s||!f.enableUploadImages)return void await a({capturedFrames:d,frontalFaces:r,frontalFacesEncrypted:l,frontalScaledImage:_,steps:[],metadata:t});try{g(!0);let s=null;s=v.enable?await ee.getAllUploadedBatches():[{frames:et(d)}];let{uploadedImages:i,faceLivenessResult:n,portraitResult:o}=await u({videos:s,images:e.images,metadata:t});if(ee.resetUploadBatches(),g(!1),n?.errors)throw n.errors;if(o?.errors)throw o.errors;await a({capturedFrames:d,steps:[],frontalFaces:r.map((e,t)=>({blob:e,id:i?.[t]?.data?.image_id})),frontalFacesEncrypted:l,frontalScaledImage:_,apiCheckPassed:n?.data.is_live??!1,verifyFaceLivenessResult:n?.data??null,verifyPortraitResult:o?.data??null,uploadFramesResult:s})}catch(e){console.error(e),g(!1),k({error:e})}};return d.jsxs(d.Fragment,{children:[d.jsx(ef,{...l,apiCheck:s,onDone:R,onFramesCaptured:W,onReset:()=>{ee.resetUploadBatches(),"function"==typeof p&&p()}}),s&&d.jsx(o,{loading:_})]})},ev=e=>{let{apiCredentials:t,outputEncryptionSettings:s}=e;return d.jsx(O,{version:"v2",unmountOnHidden:!0,children:d.jsx(es,{apiCredentials:t,children:d.jsx(ea,{settings:s,children:d.jsx(eu,{...e})})})})};ev.propTypes={apiCheck:W.bool,apiCredentials:W.shape({accessKey:W.string,secretKey:W.string,apiUrl:W.string}),onReset:W.func,onLivenessDetectionDone:W.func,onClose:W.func,onError:W.func,onFramesCaptured:W.func,frontCamera:W.bool,styledComponent:W.shape({CloseCameraButton:W.node}),outputEncryptionSettings:W.shape({key:W.string}),frontalMinSize:W.number,serviceSettings:W.shape({enableGetClientSettings:W.bool,enableUploadFrames:W.bool,enableUploadImages:W.bool,enableVerifySanityPortrait:W.bool,enableVerifyFaceLiveness:W.bool}),mode:W.string,flowId:W.string,customTexts:W.shape({}),customComponents:W.shape({PassiveLivenessBody:W.elementType}),extraConfig:W.shape({})},ev.defaultProps={apiCheck:!1,apiCredentials:{},onReset:()=>{},onLivenessDetectionDone:()=>{},onClose:()=>{},onError:()=>{},onFramesCaptured:()=>{},frontCamera:!0,styledComponent:{CloseCameraButton:null},outputEncryptionSettings:{key:""},frontalMinSize:null,serviceSettings:{enableGetClientSettings:!0,enableUploadFrames:!0,enableUploadImages:!0,enableVerifySanityPortrait:!0,enableVerifyFaceLiveness:!0},flowId:"",customTexts:{},customComponents:{PassiveLivenessBody:null},extraConfig:null};export{ev as default};
@@ -1 +1 @@
1
- import{s as e,r as t,d as r,f as a,c as i,p as n,u as l,g as s,l as d,j as o,a as u,P as c}from"./chunk-d315aa24.js";import{g as p,S as g,R as f}from"./chunk-530590d7.js";import{W as m}from"./chunk-0da61929.js";import"./chunk-ca868cf7.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,K={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});K.data=o.data}return{sanityResult:R.data,tamperingInfo:K.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(""),K=t.useRef(null),U=t.useRef(null),q=a.getEnabledServices(C,w),{billingSettings:O,enableBilling:P}=i.useSDKSettings(),x=n.buildBillingInput(f),A=l.getWebSetting(w,"data.settings.sdk_settings.billing_settings.billing_config"),{submitBilling:W}=s({enable:P,onError:y,billingSettings:O??{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:x,output:r}),y&&y(t)},[W,D.steps,x,y]),G=t.useCallback((t,r)=>{if(r){let r={sdkStatus:e.BillingStatus.success,result:n.buildBillingOutput(t)},a={service:p(D.steps),input:x,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,x,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)}}q.enableGetClientSettings&&e()},[B,q.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(!q.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:q,fullVideo:d,capturingVideo:o,previousCapturingVideoId:U.current,previousFullVideoId:K.current}))&&(i===e.IDCardSide.FRONT&&(F.current=u.cardImageId),U.current=u?.mp4VideoIds?.capturing,K.current=u?.mp4VideoIds?.full,T.current=u.qrImageId,G({...t,apiResult:u},r))}catch(e){$({...E.api_call_error,details:e})}},[B,q,$,G,_]);return q.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};
1
+ import{s as e,r as t,d as r,f as a,c as i,p as n,u as l,g as s,l as d,j as o,a as u,P as c}from"./chunk-c747321c.js";import{g as p,S as g,R as f}from"./chunk-3aa490f8.js";import{W as m}from"./chunk-51b3fd2d.js";import"./chunk-da8ef78b.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,K={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});K.data=o.data}return{sanityResult:R.data,tamperingInfo:K.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(""),K=t.useRef(null),U=t.useRef(null),q=a.getEnabledServices(C,w),{billingSettings:O,enableBilling:P}=i.useSDKSettings(),x=n.buildBillingInput(f),A=l.getWebSetting(w,"data.settings.sdk_settings.billing_settings.billing_config"),{submitBilling:W}=s({enable:P,onError:y,billingSettings:O??{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:x,output:r}),y&&y(t)},[W,D.steps,x,y]),G=t.useCallback((t,r)=>{if(r){let r={sdkStatus:e.BillingStatus.success,result:n.buildBillingOutput(t)},a={service:p(D.steps),input:x,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,x,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)}}q.enableGetClientSettings&&e()},[B,q.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(!q.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:q,fullVideo:d,capturingVideo:o,previousCapturingVideoId:U.current,previousFullVideoId:K.current}))&&(i===e.IDCardSide.FRONT&&(F.current=u.cardImageId),U.current=u?.mp4VideoIds?.capturing,K.current=u?.mp4VideoIds?.full,T.current=u.qrImageId,G({...t,apiResult:u},r))}catch(e){$({...E.api_call_error,details:e})}},[B,q,$,G,_]);return q.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};
@@ -1,4 +1,4 @@
1
- import{aM as e,z as i,aN as r,aO as t,aP as s,m as o,b as n,r as a,K as l,P as d,D as c,s as g,Y as h,j as f,i as u,y as p,B as m,k as w,aQ as k}from"./chunk-d315aa24.js";var b=Object.freeze({__proto__:null,blink:e,flipY:i,slide:r,spin:t,splash:s});let R=({curStep:e,faceDirection:i})=>{let r=n(e,"stepTimeConstraints.delayTime");return!!r&&(null===e.firstFrameSpottedAt?(e.name===i&&(e.firstFrameSpottedAt=new Date().getTime()),!0):!!(new Date().getTime()-e.firstFrameSpottedAt<r)||!1)},S=(e,i)=>({radius:e.radius??o("Selfie.progressCircle.radius")({theme:i}),strokeWidth:e.strokeWidth??o("Selfie.progressCircle.strokeWidth")({theme:i}),progress:e.progress??o("Selfie.progressCircle.progress")({theme:i}),showErrorRing:e.showErrorRing??o("Selfie.progressCircle.showErrorRing")({theme:i}),activeColor:e.activeColor??o("Selfie.progressCircle.activeColor")({theme:i}),innerPadding:e.innerPadding??o("Selfie.progressCircle.innerPadding")({theme:i}),outsideRingColor:e.outsideRingColor??o("Selfie.progressCircle.outsideRingColor")({theme:i}),outsideRingOpacity:e.outsideRingOpacity??o("Selfie.progressCircle.outsideRingOpacity")({theme:i}),insideRingColor:e.insideRingColor??o("Selfie.progressCircle.insideRingColor")({theme:i}),insideRingWidth:e.insideRingWidth??o("Selfie.progressCircle.insideRingWidth")({theme:i}),insideRingStrokeDash:e.insideRingStrokeDash??o("Selfie.progressCircle.insideRingStrokeDash")({theme:i}),errorRingWidth:e.errorRingWidth??o("Selfie.progressCircle.errorRingWidth")({theme:i}),errorRingColor:e.errorRingColor??o("Selfie.progressCircle.errorRingColor")({theme:i}),dashedRingColor:e.dashedRingColor??o("Selfie.progressCircle.dashedRingColor")({theme:i}),dashedRingOpacity:e.dashedRingOpacity??o("Selfie.progressCircle.dashedRingOpacity")({theme:i}),dashedRingWidth:e.dashedRingWidth??o("Selfie.progressCircle.dashedRingWidth")({theme:i}),dashedRingLineThick:e.dashedRingLineThick??o("Selfie.progressCircle.dashedRingLineThick")({theme:i}),dashedRingLineSpacing:e.dashedRingLineSpacing??o("Selfie.progressCircle.dashedRingLineSpacing")({theme:i}),dashedInsideRingColor:e.dashedInsideRingColor??o("Selfie.progressCircle.dashedInsideRingColor")({theme:i}),dashedInsideRingWidth:e.dashedInsideRingWidth??o("Selfie.progressCircle.dashedInsideRingWidth")({theme:i}),showOutsideRing:e.showOutsideRing??o("Selfie.progressCircle.showOutsideRing")({theme:i}),showInsideRing:e.showInsideRing??o("Selfie.progressCircle.showInsideRing")({theme:i}),showDashedRing:e.showDashedRing??o("Selfie.progressCircle.showDashedRing")({theme:i})}),_=(e,i)=>({radius:e.radius??o("Selfie.progressCircleV2.radius")({theme:i}),strokeWidth:e.strokeWidth??o("Selfie.progressCircleV2.strokeWidth")({theme:i}),progress:e.progress??o("Selfie.progressCircleV2.progress")({theme:i}),activeColor:e.activeColor??o("Selfie.progressCircleV2.activeColor")({theme:i}),neutralColor:e.neutralColor??o("Selfie.progressCircleV2.neutralColor")({theme:i}),errorColor:e.errorColor??o("Selfie.progressCircleV2.errorColor")({theme:i}),tickWidth:e.tickWidth??o("Selfie.progressCircleV2.tickWidth")({theme:i}),numberOfTicks:e.numberOfTicks??o("Selfie.progressCircleV2.numberOfTicks")({theme:i})}),y=({incomingFrame:e,currentBestFrame:i})=>e?.isEyeClosed&&!i?.isEyeClosed?i:!e?.isEyeClosed&&i?.isEyeClosed?e:e?.blurScore>i?.blurScore?e:i;function C(e){return new Promise(i=>{let r=new Image;r.onload=i,r.onerror=i,r.src=e})}let x=[],v=()=>{x=[]},$=(e,i,r,t)=>{t&&v(),x.push({id:null});let s=x.length-1;if(e&&e.key){let t=new Blob([JSON.stringify(i)]);r.uploadFile({file:t,metadata:JSON.stringify({type:"selfie"}),label:"video"},{"X-TV-Key":e.key}).then(e=>{e&&e.data&&e.data.file_id?x[s].id=e.data.file_id:x[s].id=-1})}else{let e=new Blob([JSON.stringify(i)]);r.uploadFile({file:e,metadata:JSON.stringify({type:"selfie"}),label:"video"}).then(e=>{e&&e.data&&e.data.file_id?x[s].id=e.data.file_id:x[s].id=-1})}},W=()=>new Promise(e=>{let i=setInterval(()=>{x.every(e=>e.id)&&(e(),clearInterval(i))},200)}),j=e=>e.enable?x.some(e=>-1===e.id)?null:x:[],I=[],O=null,D=!1,A=()=>I,T=()=>{D=!0,I=[];try{O instanceof MediaStream&&(O.getTracks().forEach(e=>e.stop()),O=null)}catch(e){}};async function E({outputImagesSize:e,videoEl:i,resultAnalyzeVideoAndWindowSizes:r}){let t;T();let s=document.createElement("canvas");s.width=e,s.height=e;let o=s.getContext("2d");try{let n={mimeType:"video/webm"};try{let e=(O=i?.captureStream()?.clone()).getVideoTracks()[0];await e.applyConstraints({width:{min:360,ideal:400},height:{min:360,ideal:400}})}catch(e){}MediaRecorder.isTypeSupported("video/mp4")&&(D=!1,!function e(i,r,t,s){if(!i||!s)return;let{cropX:o,cropY:n,cropWidth:a,cropHeight:l}=s;i.drawImage(r,o,n,a,l,0,0,t,t),D||requestAnimationFrame(()=>e(i,r,t,s))}(o,i,e,r),O=s.captureStream(25),n={mimeType:"video/mp4",videoBitsPerSecond:25e5}),t=new MediaRecorder(O,n);let a=async()=>{await new Promise((e,i)=>{t.ondataavailable=r=>(function(e,i,r){if(e.data.size>0){let r=new Blob([e.data],{type:"video/mp4"});I.push(r),i()}else console.error("No video have recored!"),r()})(r,e,i),"inactive"!==t.state&&t.stop()})};t.stopVideoRecording=a,t.discardRecording=()=>{"inactive"!==t.state&&t.stop()}}catch(e){}return{mediaRecorder:t}}let P={data:{settings:{sdk_settings:{passive_liveness_settings:{auto_capture:{enable:!0,show_capture_button:!0,show_countdown:!0,wait_for_best_image_time_ms_web:3e3},manual_capture:{show_countdown:!0,wait_for_best_image_time_ms_web:3e3},blur_check:{enable:!0,web_blurry_threshold:.4},close_eye_detector:{enable:!0,web_threshold:.342,web_timeout:5,force_check:!1},web_is_required_frontal_face:!0},active_liveness_settings:{reset_flow_on_orientation_change:!0,wait_before_start_flow_ms:2e3,face_tracking_setting:{enable:!1,web_terminate_threshold:.0030152991993743408,web_warning_threshold:.0017317430600108828,limit_for:"all_flow",max_warning_time:5},flow_interval_time_ms:3e3,take_one_picture_time_ms:3e3,limit_time_liveness_check:{enable:!1,limit_time_second:45,remain_time_show:10,format:"s",max_retry_count:0,non_stoppable:!1},terminate_if_no_face:{enable:!1,max_invalid_frame:5,max_time_ms:1e3},close_eye_detector:{enable:!0,web_threshold:.342,web_timeout:5,force_check:!1},exif_data_settings:{enable:!0},record_video:{enable:!1},save_encoded_frames:{enable:!1,enable_logging:!1,frames_batch_len:0,frames_interval_ms:180,quality_android:90,quality_ios:80},auto_gen_frame_ids:{enable:!1,max_items:50}}}}}},V=30,L=e=>{let{shouldStart:i,totalTime:r,totalDelayBetweenReset:t,interruptible:s=!0,onReset:o,onTick:n,onTimesUp:d}=e,c=a.useRef(new l({totalTime:r,totalDelayBetweenReset:t,interruptible:s}));return a.useEffect(()=>c.current.on("tick",({remainTime:e})=>{n({remainTime:e})}),[n]),a.useEffect(()=>c.current.on("delaystart",()=>{d()}),[d]),a.useEffect(()=>c.current.on("reset",({attemptCount:e,fromBackground:i})=>{o({attemptCount:e,fromBackground:i})}),[o]),a.useEffect(()=>i?c.current.start():()=>{},[i]),{stopTimer:a.useCallback(()=>{c.current.stop()},[])}},{ErrorDuration:z}=g;function M({children:e,errorMsg:i,className:r}){return h.isValidElement(e)?i?f.jsx("div",{className:r,children:h.cloneElement(e,{errorMsg:i})}):null:i?f.jsx("div",{className:r,children:i}):null}function B({children:e,className:i,error:r}){let t=a.useRef(0),s=a.useRef(""),o=c(),n=a.useRef(z.SHORT),{code:l,duration:d=z.SHORT}=r||{},g=o(l);return Date.now()-t.current>=n.current?(t.current=Date.now(),n.current=d,s.current=g,M({children:e,errorMsg:g,className:i})):M({children:e,errorMsg:s.current,className:i})}B.propTypes={children:d.node,className:d.string},B.defaultProps={className:""};let N=u.g`
1
+ import{aM as e,z as i,aN as r,aO as t,aP as s,m as o,b as n,r as a,K as l,P as d,D as c,s as g,Y as h,j as f,i as u,y as p,B as m,k as w,aQ as k}from"./chunk-c747321c.js";var b=Object.freeze({__proto__:null,blink:e,flipY:i,slide:r,spin:t,splash:s});let R=({curStep:e,faceDirection:i})=>{let r=n(e,"stepTimeConstraints.delayTime");return!!r&&(null===e.firstFrameSpottedAt?(e.name===i&&(e.firstFrameSpottedAt=new Date().getTime()),!0):!!(new Date().getTime()-e.firstFrameSpottedAt<r)||!1)},S=(e,i)=>({radius:e.radius??o("Selfie.progressCircle.radius")({theme:i}),strokeWidth:e.strokeWidth??o("Selfie.progressCircle.strokeWidth")({theme:i}),progress:e.progress??o("Selfie.progressCircle.progress")({theme:i}),showErrorRing:e.showErrorRing??o("Selfie.progressCircle.showErrorRing")({theme:i}),activeColor:e.activeColor??o("Selfie.progressCircle.activeColor")({theme:i}),innerPadding:e.innerPadding??o("Selfie.progressCircle.innerPadding")({theme:i}),outsideRingColor:e.outsideRingColor??o("Selfie.progressCircle.outsideRingColor")({theme:i}),outsideRingOpacity:e.outsideRingOpacity??o("Selfie.progressCircle.outsideRingOpacity")({theme:i}),insideRingColor:e.insideRingColor??o("Selfie.progressCircle.insideRingColor")({theme:i}),insideRingWidth:e.insideRingWidth??o("Selfie.progressCircle.insideRingWidth")({theme:i}),insideRingStrokeDash:e.insideRingStrokeDash??o("Selfie.progressCircle.insideRingStrokeDash")({theme:i}),errorRingWidth:e.errorRingWidth??o("Selfie.progressCircle.errorRingWidth")({theme:i}),errorRingColor:e.errorRingColor??o("Selfie.progressCircle.errorRingColor")({theme:i}),dashedRingColor:e.dashedRingColor??o("Selfie.progressCircle.dashedRingColor")({theme:i}),dashedRingOpacity:e.dashedRingOpacity??o("Selfie.progressCircle.dashedRingOpacity")({theme:i}),dashedRingWidth:e.dashedRingWidth??o("Selfie.progressCircle.dashedRingWidth")({theme:i}),dashedRingLineThick:e.dashedRingLineThick??o("Selfie.progressCircle.dashedRingLineThick")({theme:i}),dashedRingLineSpacing:e.dashedRingLineSpacing??o("Selfie.progressCircle.dashedRingLineSpacing")({theme:i}),dashedInsideRingColor:e.dashedInsideRingColor??o("Selfie.progressCircle.dashedInsideRingColor")({theme:i}),dashedInsideRingWidth:e.dashedInsideRingWidth??o("Selfie.progressCircle.dashedInsideRingWidth")({theme:i}),showOutsideRing:e.showOutsideRing??o("Selfie.progressCircle.showOutsideRing")({theme:i}),showInsideRing:e.showInsideRing??o("Selfie.progressCircle.showInsideRing")({theme:i}),showDashedRing:e.showDashedRing??o("Selfie.progressCircle.showDashedRing")({theme:i})}),_=(e,i)=>({radius:e.radius??o("Selfie.progressCircleV2.radius")({theme:i}),strokeWidth:e.strokeWidth??o("Selfie.progressCircleV2.strokeWidth")({theme:i}),progress:e.progress??o("Selfie.progressCircleV2.progress")({theme:i}),activeColor:e.activeColor??o("Selfie.progressCircleV2.activeColor")({theme:i}),neutralColor:e.neutralColor??o("Selfie.progressCircleV2.neutralColor")({theme:i}),errorColor:e.errorColor??o("Selfie.progressCircleV2.errorColor")({theme:i}),tickWidth:e.tickWidth??o("Selfie.progressCircleV2.tickWidth")({theme:i}),numberOfTicks:e.numberOfTicks??o("Selfie.progressCircleV2.numberOfTicks")({theme:i})}),y=({incomingFrame:e,currentBestFrame:i})=>e?.isEyeClosed&&!i?.isEyeClosed?i:!e?.isEyeClosed&&i?.isEyeClosed?e:e?.blurScore>i?.blurScore?e:i;function C(e){return new Promise(i=>{let r=new Image;r.onload=i,r.onerror=i,r.src=e})}let x=[],v=()=>{x=[]},$=(e,i,r,t)=>{t&&v(),x.push({id:null});let s=x.length-1;if(e&&e.key){let t=new Blob([JSON.stringify(i)]);r.uploadFile({file:t,metadata:JSON.stringify({type:"selfie"}),label:"video"},{"X-TV-Key":e.key}).then(e=>{e&&e.data&&e.data.file_id?x[s].id=e.data.file_id:x[s].id=-1})}else{let e=new Blob([JSON.stringify(i)]);r.uploadFile({file:e,metadata:JSON.stringify({type:"selfie"}),label:"video"}).then(e=>{e&&e.data&&e.data.file_id?x[s].id=e.data.file_id:x[s].id=-1})}},W=()=>new Promise(e=>{let i=setInterval(()=>{x.every(e=>e.id)&&(e(),clearInterval(i))},200)}),j=e=>e.enable?x.some(e=>-1===e.id)?null:x:[],I=[],O=null,D=!1,A=()=>I,T=()=>{D=!0,I=[];try{O instanceof MediaStream&&(O.getTracks().forEach(e=>e.stop()),O=null)}catch(e){}};async function E({outputImagesSize:e,videoEl:i,resultAnalyzeVideoAndWindowSizes:r}){let t;T();let s=document.createElement("canvas");s.width=e,s.height=e;let o=s.getContext("2d");try{let n={mimeType:"video/webm"};try{let e=(O=i?.captureStream()?.clone()).getVideoTracks()[0];await e.applyConstraints({width:{min:360,ideal:400},height:{min:360,ideal:400}})}catch(e){}MediaRecorder.isTypeSupported("video/mp4")&&(D=!1,!function e(i,r,t,s){if(!i||!s)return;let{cropX:o,cropY:n,cropWidth:a,cropHeight:l}=s;i.drawImage(r,o,n,a,l,0,0,t,t),D||requestAnimationFrame(()=>e(i,r,t,s))}(o,i,e,r),O=s.captureStream(25),n={mimeType:"video/mp4",videoBitsPerSecond:25e5}),t=new MediaRecorder(O,n);let a=async()=>{await new Promise((e,i)=>{t.ondataavailable=r=>(function(e,i,r){if(e.data.size>0){let r=new Blob([e.data],{type:"video/mp4"});I.push(r),i()}else console.error("No video have recored!"),r()})(r,e,i),"inactive"!==t.state&&t.stop()})};t.stopVideoRecording=a,t.discardRecording=()=>{"inactive"!==t.state&&t.stop()}}catch(e){}return{mediaRecorder:t}}let P={data:{settings:{sdk_settings:{passive_liveness_settings:{auto_capture:{enable:!0,show_capture_button:!0,show_countdown:!0,wait_for_best_image_time_ms_web:3e3},manual_capture:{show_countdown:!0,wait_for_best_image_time_ms_web:3e3},blur_check:{enable:!0,web_blurry_threshold:.4},close_eye_detector:{enable:!0,web_threshold:.342,web_timeout:5,force_check:!1},web_is_required_frontal_face:!0},active_liveness_settings:{reset_flow_on_orientation_change:!0,wait_before_start_flow_ms:2e3,face_tracking_setting:{enable:!1,web_terminate_threshold:.0030152991993743408,web_warning_threshold:.0017317430600108828,limit_for:"all_flow",max_warning_time:5},flow_interval_time_ms:3e3,take_one_picture_time_ms:3e3,limit_time_liveness_check:{enable:!1,limit_time_second:45,remain_time_show:10,format:"s",max_retry_count:0,non_stoppable:!1},terminate_if_no_face:{enable:!1,max_invalid_frame:5,max_time_ms:1e3},close_eye_detector:{enable:!0,web_threshold:.342,web_timeout:5,force_check:!1},exif_data_settings:{enable:!0},record_video:{enable:!1},save_encoded_frames:{enable:!1,enable_logging:!1,frames_batch_len:0,frames_interval_ms:180,quality_android:90,quality_ios:80},auto_gen_frame_ids:{enable:!1,max_items:50}}}}}},V=30,L=e=>{let{shouldStart:i,totalTime:r,totalDelayBetweenReset:t,interruptible:s=!0,onReset:o,onTick:n,onTimesUp:d}=e,c=a.useRef(new l({totalTime:r,totalDelayBetweenReset:t,interruptible:s}));return a.useEffect(()=>c.current.on("tick",({remainTime:e})=>{n({remainTime:e})}),[n]),a.useEffect(()=>c.current.on("delaystart",()=>{d()}),[d]),a.useEffect(()=>c.current.on("reset",({attemptCount:e,fromBackground:i})=>{o({attemptCount:e,fromBackground:i})}),[o]),a.useEffect(()=>i?c.current.start():()=>{},[i]),{stopTimer:a.useCallback(()=>{c.current.stop()},[])}},{ErrorDuration:z}=g;function M({children:e,errorMsg:i,className:r}){return h.isValidElement(e)?i?f.jsx("div",{className:r,children:h.cloneElement(e,{errorMsg:i})}):null:i?f.jsx("div",{className:r,children:i}):null}function B({children:e,className:i,error:r}){let t=a.useRef(0),s=a.useRef(""),o=c(),n=a.useRef(z.SHORT),{code:l,duration:d=z.SHORT}=r||{},g=o(l);return Date.now()-t.current>=n.current?(t.current=Date.now(),n.current=d,s.current=g,M({children:e,errorMsg:g,className:i})):M({children:e,errorMsg:s.current,className:i})}B.propTypes={children:d.node,className:d.string},B.defaultProps={className:""};let N=u.g`
2
2
  transition: stroke-dashoffset 0.4s;
3
3
  transform: rotate(-90deg);
4
4
  transform-origin: 50% 50%;
@@ -1 +1 @@
1
- import{A as e,C as r,U as s,r as a,m as n,c as t,s as o,j as i,a4 as c,az as l,b as u,P as p,k as m}from"./chunk-d315aa24.js";import{p as d,g as f,S as h,a as g,O as C,C as j,E as y,b as D,B as F,c as x,L as S}from"./chunk-d70fed0c.js";import{u as b,C as k}from"./chunk-3a50b76b.js";import{M as I,O as T,W as E,C as R}from"./chunk-ca868cf7.js";import{D as L}from"./chunk-db6c3ef2.js";import{u as v}from"./chunk-0da61929.js";import"./chunk-af89e5b6.js";import"./chunk-661f2995.js";import"./chunk-f7c561aa.js";let P=m.isMobile?{width:{ideal:640}}:null;function A(p){let{apiCheck:m,onLivenessDetectionDone:L,captureFrameSettings:A,onFramesCaptured:M,frontCamera:H,flipVideoHorizontal:O,customDirectionIcon:U,customStepTimeConstraints:w,onProcessing:V,customErrors:$,apiCredentials:_,outputEncryptionSettings:B,cameraScale:K,defaultCameraId:N,passiveModeAuto:z,offsetFaceY:G,styledComponent:Y,serviceSettings:W,onReset:q,isLoading:J}=p,Q=e(),{onErrorCallback:X,onCloseCallback:Z}=v(),ee=r.useAsset("bg_camera_mask.png"),er=r.useAsset("bg_camera_mask_red.png"),es=s("IDCapturing.loadingIcon.src","ic_loading.gif"),[ea,en]=a.useState({}),{yFaceDetectionError:et,yFaceVerificationStepsWrapper:eo}=ea,[ei,ec]=a.useState(""),[el,eu]=a.useState(),ep=a.useMemo(()=>({backgroundColor:n("Selfie.backgroundColor")({theme:Q})}),[Q]),em=a.useCallback(({lostY:e,height:r,clientHeight:s})=>{let a=e+25,n=a+30;en({yFaceDetectionError:a,yFaceVerificationStepsWrapper:n+r+20});let t=Math.floor(e),o=Math.floor(s-e),i=Math.floor(n);return 0!==G&&(i+G<t||i+G+r>o)?X({code:`offsetFaceY must be in [-${i-t}, ${o-r-i}]`}):i+=G,{y:i}},[G,X]),{shouldResetFlowOnOrientationChange:ed,countdownToTakePicture:ef,cropArea:eh,curStepIndex:eg,faceDetectionError:eC,resetFlow:ej,handleTriggerPassiveMode:ey,handleVideoPlayed:eD,refVideo:eF,showCountdown:ex,steps:eS,refIsReseting:eb,videoPlayed:ek,warmupDone:eI,showCaptureButton:eT,shouldShowCountdown:eE,showLoading:eR}=b({currentOrientation:el,apiCheck:m,bgCameraMask:ee,bgCameraMaskRed:er,surroundStyle:ep,onLivenessDetectionDone:L,onError:X,cropAreaDimension:em,customDirectionIcon:U,captureFrameSettings:A,onFramesCaptured:M,setRemainingTime:ec,customStepTimeConstraints:w,onProcessing:V,customErrors:$,apiCredentials:_,outputEncryptionSettings:B,cameraScale:K,passiveModeAuto:z,serviceSettings:W,onReset:q});a.useEffect(()=>{"string"==typeof eS[0]?.directionIcon&&Promise.all(eS.map(e=>d(e.directionIcon)))},[eS]);let{CloseCameraButton:eL}=Y,ev=f(p,Q),eP=eb.current?0:eg/eS.length*100,{lang:eA}=t.useSDKSettings(),eM=a.useRef(0),eH=a.useRef({}),eO=a.useRef(o.ErrorDuration.SHORT),eU=a.useMemo(()=>{let{msg:e,duration:r=o.ErrorDuration.SHORT}=eC||{},s=e?.[eA];return Date.now()-eM.current>=eO.current&&(eM.current=Date.now(),eO.current=r,eH.current=s),eH.current},[eC,eg]),ew=a.useCallback(e=>{eu(e),ed?ej():e===I.LANDSCAPE?eF.current?.pause():eF.current?.play()},[eF,ej,ed]);return i.jsx(T,{onOrientationChange:ew,children:i.jsxs(c,{frontCamera:H,onVideoPlayed:eD,onClose:Z,flipHorizontal:O??H,ref:eF,videoSettings:P,onError:X,scale:K,defaultCameraId:N,closeButton:eL||i.jsx(l,{}),children:[!eI&&i.jsx(E,{}),ek?i.jsxs(i.Fragment,{children:["string"==typeof eU?i.jsx(h,{top:et-15,className:"face-detection-error",children:eU}):null,eh.current?i.jsxs(R,{x:`${eh.current.x}px`,y:`${eh.current.y}px`,width:`${eh.current.width}px`,height:`${eh.current.height}px`,surroundStyle:eh.current.surroundStyle,children:[i.jsx(g,{}),i.jsx(C,{...ev,progress:eP,showErrorRing:!!eC&&n("Selfie.progressCircle.showErrorRing")({theme:Q})}),eE?i.jsx(j,{children:ef}):null,eC&&i.jsx(y,{})]}):null,ei&&i.jsx(D,{top:eo-30,children:ei}),eT?i.jsx(F,{children:i.jsx(x,{onClick:ey,disabled:ex,children:u(Q,"Selfie.captureIcon.src")?i.jsx("img",{src:u(Q,"Selfie.captureIcon.src"),alt:""}):i.jsx(k,{fillColor:"rgba(193, 197, 204, 1)"})})}):null]}):null,(eR||J)&&i.jsx(S,{children:i.jsx("img",{src:es,alt:""})})]})})}A.propTypes={apiCheck:p.bool,mode:p.string,onLivenessDetectionDone:p.func,onClose:p.func,onError:p.func,onReset:p.func,captureFrameSettings:p.shape({}),onFramesCaptured:p.func,frontCamera:p.bool,isLoading:p.bool,flipVideoHorizontal:p.bool,customDirectionIcon:p.shape({}),customStepTimeConstraints:p.shape({}),onProcessing:p.func,customErrors:p.shape({}),apiCredentials:p.shape({accessKey:p.string,secretKey:p.string,apiUrl:p.string}),outputEncryptionSettings:p.shape({}),cameraScale:p.number,defaultCameraId:p.string,passiveModeAuto:p.bool,offsetFaceY:p.number,styledComponent:p.shape({CloseCameraButton:p.node}),serviceSettings:p.shape({})},A.defaultProps={apiCheck:!1,mode:null,onLivenessDetectionDone:null,onClose:null,onError:()=>{},onReset:()=>{},captureFrameSettings:{enable:!1,framesIntervalTime:180,framesBatchLength:0},onFramesCaptured:()=>{},frontCamera:!0,isLoading:!1,flipVideoHorizontal:null,customDirectionIcon:{[o.FaceDirection.LEFT]:i.jsx(L,{type:o.FaceDirection.LEFT}),[o.FaceDirection.RIGHT]:i.jsx(L,{type:o.FaceDirection.RIGHT}),[o.FaceDirection.UP]:i.jsx(L,{type:o.FaceDirection.UP}),[o.FaceDirection.FRONTAL]:i.jsx(L,{type:o.FaceDirection.FRONTAL})},customStepTimeConstraints:{[o.FaceDirection.UP]:{delayTime:0},[o.FaceDirection.LEFT]:{delayTime:0},[o.FaceDirection.RIGHT]:{delayTime:0},[o.FaceDirection.FRONTAL]:{delayTime:2e3}},onProcessing:()=>{},customErrors:null,apiCredentials:{accessKey:"",secretKey:"",apiUrl:""},outputEncryptionSettings:null,cameraScale:1,defaultCameraId:void 0,passiveModeAuto:!1,offsetFaceY:0,styledComponent:{CloseCameraButton:null},serviceSettings:{enableUploadFrames:!0,enableUploadImages:!0,enableVerifySanityPortrait:!0,enableVerifySanityIDCard:!0,enableVerifyFaceLiveness:!0,enableDetectIDCardTampering:!0,enableReadIDCardInfo:!0}};export{A as default};
1
+ import{A as e,C as r,U as s,r as a,m as n,c as t,s as o,j as i,a4 as c,az as l,b as u,P as p,k as m}from"./chunk-c747321c.js";import{p as d,g as f,S as h,a as g,O as C,C as j,E as y,b as D,B as F,c as x,L as S}from"./chunk-88ec0901.js";import{u as b,C as k}from"./chunk-409b3310.js";import{M as I,O as T,W as E,C as R}from"./chunk-da8ef78b.js";import{D as L}from"./chunk-2b4d00a3.js";import{u as v}from"./chunk-51b3fd2d.js";import"./chunk-036bae4b.js";import"./chunk-ddb14dfb.js";import"./chunk-6e5358d6.js";let P=m.isMobile?{width:{ideal:640}}:null;function A(p){let{apiCheck:m,onLivenessDetectionDone:L,captureFrameSettings:A,onFramesCaptured:M,frontCamera:H,flipVideoHorizontal:O,customDirectionIcon:U,customStepTimeConstraints:w,onProcessing:V,customErrors:$,apiCredentials:_,outputEncryptionSettings:B,cameraScale:K,defaultCameraId:N,passiveModeAuto:z,offsetFaceY:G,styledComponent:Y,serviceSettings:W,onReset:q,isLoading:J}=p,Q=e(),{onErrorCallback:X,onCloseCallback:Z}=v(),ee=r.useAsset("bg_camera_mask.png"),er=r.useAsset("bg_camera_mask_red.png"),es=s("IDCapturing.loadingIcon.src","ic_loading.gif"),[ea,en]=a.useState({}),{yFaceDetectionError:et,yFaceVerificationStepsWrapper:eo}=ea,[ei,ec]=a.useState(""),[el,eu]=a.useState(),ep=a.useMemo(()=>({backgroundColor:n("Selfie.backgroundColor")({theme:Q})}),[Q]),em=a.useCallback(({lostY:e,height:r,clientHeight:s})=>{let a=e+25,n=a+30;en({yFaceDetectionError:a,yFaceVerificationStepsWrapper:n+r+20});let t=Math.floor(e),o=Math.floor(s-e),i=Math.floor(n);return 0!==G&&(i+G<t||i+G+r>o)?X({code:`offsetFaceY must be in [-${i-t}, ${o-r-i}]`}):i+=G,{y:i}},[G,X]),{shouldResetFlowOnOrientationChange:ed,countdownToTakePicture:ef,cropArea:eh,curStepIndex:eg,faceDetectionError:eC,resetFlow:ej,handleTriggerPassiveMode:ey,handleVideoPlayed:eD,refVideo:eF,showCountdown:ex,steps:eS,refIsReseting:eb,videoPlayed:ek,warmupDone:eI,showCaptureButton:eT,shouldShowCountdown:eE,showLoading:eR}=b({currentOrientation:el,apiCheck:m,bgCameraMask:ee,bgCameraMaskRed:er,surroundStyle:ep,onLivenessDetectionDone:L,onError:X,cropAreaDimension:em,customDirectionIcon:U,captureFrameSettings:A,onFramesCaptured:M,setRemainingTime:ec,customStepTimeConstraints:w,onProcessing:V,customErrors:$,apiCredentials:_,outputEncryptionSettings:B,cameraScale:K,passiveModeAuto:z,serviceSettings:W,onReset:q});a.useEffect(()=>{"string"==typeof eS[0]?.directionIcon&&Promise.all(eS.map(e=>d(e.directionIcon)))},[eS]);let{CloseCameraButton:eL}=Y,ev=f(p,Q),eP=eb.current?0:eg/eS.length*100,{lang:eA}=t.useSDKSettings(),eM=a.useRef(0),eH=a.useRef({}),eO=a.useRef(o.ErrorDuration.SHORT),eU=a.useMemo(()=>{let{msg:e,duration:r=o.ErrorDuration.SHORT}=eC||{},s=e?.[eA];return Date.now()-eM.current>=eO.current&&(eM.current=Date.now(),eO.current=r,eH.current=s),eH.current},[eC,eg]),ew=a.useCallback(e=>{eu(e),ed?ej():e===I.LANDSCAPE?eF.current?.pause():eF.current?.play()},[eF,ej,ed]);return i.jsx(T,{onOrientationChange:ew,children:i.jsxs(c,{frontCamera:H,onVideoPlayed:eD,onClose:Z,flipHorizontal:O??H,ref:eF,videoSettings:P,onError:X,scale:K,defaultCameraId:N,closeButton:eL||i.jsx(l,{}),children:[!eI&&i.jsx(E,{}),ek?i.jsxs(i.Fragment,{children:["string"==typeof eU?i.jsx(h,{top:et-15,className:"face-detection-error",children:eU}):null,eh.current?i.jsxs(R,{x:`${eh.current.x}px`,y:`${eh.current.y}px`,width:`${eh.current.width}px`,height:`${eh.current.height}px`,surroundStyle:eh.current.surroundStyle,children:[i.jsx(g,{}),i.jsx(C,{...ev,progress:eP,showErrorRing:!!eC&&n("Selfie.progressCircle.showErrorRing")({theme:Q})}),eE?i.jsx(j,{children:ef}):null,eC&&i.jsx(y,{})]}):null,ei&&i.jsx(D,{top:eo-30,children:ei}),eT?i.jsx(F,{children:i.jsx(x,{onClick:ey,disabled:ex,children:u(Q,"Selfie.captureIcon.src")?i.jsx("img",{src:u(Q,"Selfie.captureIcon.src"),alt:""}):i.jsx(k,{fillColor:"rgba(193, 197, 204, 1)"})})}):null]}):null,(eR||J)&&i.jsx(S,{children:i.jsx("img",{src:es,alt:""})})]})})}A.propTypes={apiCheck:p.bool,mode:p.string,onLivenessDetectionDone:p.func,onClose:p.func,onError:p.func,onReset:p.func,captureFrameSettings:p.shape({}),onFramesCaptured:p.func,frontCamera:p.bool,isLoading:p.bool,flipVideoHorizontal:p.bool,customDirectionIcon:p.shape({}),customStepTimeConstraints:p.shape({}),onProcessing:p.func,customErrors:p.shape({}),apiCredentials:p.shape({accessKey:p.string,secretKey:p.string,apiUrl:p.string}),outputEncryptionSettings:p.shape({}),cameraScale:p.number,defaultCameraId:p.string,passiveModeAuto:p.bool,offsetFaceY:p.number,styledComponent:p.shape({CloseCameraButton:p.node}),serviceSettings:p.shape({})},A.defaultProps={apiCheck:!1,mode:null,onLivenessDetectionDone:null,onClose:null,onError:()=>{},onReset:()=>{},captureFrameSettings:{enable:!1,framesIntervalTime:180,framesBatchLength:0},onFramesCaptured:()=>{},frontCamera:!0,isLoading:!1,flipVideoHorizontal:null,customDirectionIcon:{[o.FaceDirection.LEFT]:i.jsx(L,{type:o.FaceDirection.LEFT}),[o.FaceDirection.RIGHT]:i.jsx(L,{type:o.FaceDirection.RIGHT}),[o.FaceDirection.UP]:i.jsx(L,{type:o.FaceDirection.UP}),[o.FaceDirection.FRONTAL]:i.jsx(L,{type:o.FaceDirection.FRONTAL})},customStepTimeConstraints:{[o.FaceDirection.UP]:{delayTime:0},[o.FaceDirection.LEFT]:{delayTime:0},[o.FaceDirection.RIGHT]:{delayTime:0},[o.FaceDirection.FRONTAL]:{delayTime:2e3}},onProcessing:()=>{},customErrors:null,apiCredentials:{accessKey:"",secretKey:"",apiUrl:""},outputEncryptionSettings:null,cameraScale:1,defaultCameraId:void 0,passiveModeAuto:!1,offsetFaceY:0,styledComponent:{CloseCameraButton:null},serviceSettings:{enableUploadFrames:!0,enableUploadImages:!0,enableVerifySanityPortrait:!0,enableVerifySanityIDCard:!0,enableVerifyFaceLiveness:!0,enableDetectIDCardTampering:!0,enableReadIDCardInfo:!0}};export{A as default};