@incodetech/welcome 1.71.0-20240430151632.0 → 1.71.0-20240430161557.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"detectionSetup.d.ts","sourceRoot":"","sources":["../../../../src/detection/detectionSetup.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,cAAM,cAAc;IAClB,OAAO,CAAC,kBAAkB,CAA8B;IACxD,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,eAAe,CAAuB;IAC9C,OAAO,CAAC,QAAQ,CAAmD;IAEnE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAiB;WAE1B,WAAW,IAAI,cAAc;IAO3C,OAAO,CAAC,4BAA4B;IAqB9B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAQlC,kBAAkB,IAAI,MAAM,GAAG,IAAI;IAInC,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG,eAAe,GAAG,IAAI;IAIhD,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAMvB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;CAqDvC;;AAED,wBAA4C"}
1
+ {"version":3,"file":"detectionSetup.d.ts","sourceRoot":"","sources":["../../../../src/detection/detectionSetup.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,cAAM,cAAc;IAClB,OAAO,CAAC,kBAAkB,CAA8B;IACxD,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,eAAe,CAAuB;IAC9C,OAAO,CAAC,QAAQ,CAAmD;IAEnE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAiB;WAE1B,WAAW,IAAI,cAAc;IAO3C,OAAO,CAAC,4BAA4B;IAqB9B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAQlC,kBAAkB,IAAI,MAAM,GAAG,IAAI;IAInC,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG,eAAe,GAAG,IAAI;IAIhD,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAMvB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;CAmDvC;;AAED,wBAA4C"}
@@ -21575,9 +21575,7 @@ class DetectionSetup {
21575
21575
  token: (Qe = state.token) == null ? void 0 : Qe.token,
21576
21576
  code: "modelLoadStart"
21577
21577
  }), this.setIsHighPerformanceVariable();
21578
- const me = getInitializationParams(
21579
- options.hostingApp === "Incode ID"
21580
- );
21578
+ const me = getInitializationParams(!1);
21581
21579
  for (this.pipelinesBundle = me.bundle, this.profiles = me.profiles, OnboardingAnalytics$1.setPipelinesBundle(this.pipelinesBundle), OnboardingAnalytics$1.startOnboardingCheck(), await MlWasmJSApi$1.initialize(
21582
21580
  me.wasmModulePath,
21583
21581
  me.wasmSimdModulePath,
@@ -45721,7 +45719,7 @@ function renderUserConsent(ue, {
45721
45719
  })
45722
45720
  }), ue, He);
45723
45721
  }
45724
- const version = "1.71.0-20240430151632.0";
45722
+ const version = "1.71.0-20240430161557.0";
45725
45723
  function r(ue) {
45726
45724
  for (var me = "", Ue = 0; Ue < ue.length; ++Ue)
45727
45725
  if (Ue > 0) {
@@ -1396,7 +1396,7 @@ https://fb.me/react-async-component-lifecycle-hooks`)}if(typeof ue.getDerivedSta
1396
1396
  overflow: hidden;
1397
1397
  margin: auto;
1398
1398
  }
1399
- `,isAndroid=!!mobile.Android(),isJ7Prime=!!mobile.J7Prime(),isAlcatel1x=!!mobile.Alcatel1x(),isLenovoVibeB=!!mobile.LenovoVibeB(),isDesktop=mobile.isDesktop(),parser=new UAParser,{browser:browser$1}=parser.getResult(),Webcam=React$1.forwardRef(({className:ue,onPlay:me,videoSource:Ue,screenshotFormat:Qe,isSelfie:Ze=!1,type:Je,permissionMessage:Ge,onLog:He=emptyFunc,stream:Xe,onError:$e=emptyFunc,token:Ke,interviewId:nt,onStreamReady:tt=emptyFunc,showCustomCameraPermissionScreen:et,assistedOnboarding:rt,deviceId:at,onRestartOnboarding:ot=reload,showDoublePermissionsRequest:it=!1,publishAudio:st=!1,fullHeight:ct=!1,isRecordingEnabled:lt=!1,isKiosk:dt=!1},ft)=>{const[gt,ht]=React$1.useState(!1),[vt,Rt]=React$1.useState(Xe),[bt,At]=React$1.useState(!0),[Nt,mt]=React$1.useState(!0),[It,yt]=React$1.useState(!1),Mt=React$1.useRef(null),St=React$1.useRef(),xt=React$1.useRef(0),{t:Ut}=useTranslation(),[Ft,wt]=usePermissions(),Ct=St.current,Zt=React$1.useRef(),Jt=React$1.useRef(!1),Qt=React$1.useRef();Zt.current=Ft;const[$t,Gt]=React$1.useState(!it);Ge=Ge||Ut("permissionMessage"),React$1.useEffect(()=>{Zt.current&&!isDesktop&&!dt&&Gt(Zt.current)},[Ft]),React$1.useEffect(()=>{const fn=sessionStorage.getItem("cameraPermissionsGranted")==="true";!isDesktop&&fn&&!dt&&Gt(!0)},[Ft]),React$1.useEffect(()=>{const fn=Mt.current;return()=>{fn.pause(),fn.srcObject=null}},[]),React$1.useEffect(()=>()=>{vt==null||vt.getTracks().forEach(fn=>fn.stop())},[vt]),React$1.useEffect(()=>{if(options.protect&&It){const fn=setInterval(async()=>{if(Mt.current){if(Mt.current.paused){Qt.current=null;return}const Mn=getImageBase64FromVideo(Mt.current);Mn===Qt.current&&window.location.reload(),Qt.current=Mn}},250);return()=>clearInterval(fn)}},[It]);const Pt=React$1.useCallback(()=>{var fn,Mn,un;if(!document.hidden)return(Mn=(fn=Mt.current)==null?void 0:fn.srcObject)==null||Mn.clone(),(un=Mt.current)==null?void 0:un.play()},[]);useEventListener("visibilitychange",Pt,document);const jt=fn=>{const Mn=fn.getVideoTracks()[0],{width:un,height:hn}=Mn.getSettings(),{focusMode:en=!1}=navigator.mediaDevices.getSupportedConstraints();addEvent({code:"cameraType",payload:{type:"webRTC",resolution:`${un}x${hn}`,autofocus:en,label:Mn.label},token:Ke}),Ze&&addEvent({code:"cameraSelfie",token:Ke})},Dt=fn=>{mt(!1),fn.constructor.name==="DOMException"?(addEvent({code:"permissionDenied",payload:{message:"User denied to use camera."},token:Ke}),He(getLogObject("permissionDenied",{message:"User denied to use camera."})),fn.type="permissionDenied",et?ht(!0):$e(fn)):fn.constructor.name==="OverconstrainedError"?(He(getLogObject("OSVersionNotSupported",{message:"OS version is not supported."})),At(!1)):(He(getLogObject("browserNotSupported",{message:"Browser is not supported."})),At(!1))},ut=async fn=>{wt(!0);const Mn=()=>{Mt.current.srcObject=fn,tt(fn),Rt(fn),lt||mt(!1)},un=fn.getVideoTracks()[0];MlWasmJSApi$1.isVirtualCamera(un.label)&&$e(new Error("Virtual camera is detected")),mobile.iOS()?un.applyConstraints({advanced:[{focusDistance:1}]}).finally(()=>{Mn()}):Mn()};React$1.useEffect(()=>((async()=>{function Mn(en){const Ht={resizeMode:"none",facingMode:"environment"};switch(en){case 0:return{...Ht,height:{ideal:localStorage.getItem("isHighPerformance")==="true"?1080:720}};case 1:return{...Ht,width:{min:3200,ideal:3840,max:4096},height:{min:1800,ideal:2160,max:2400}};case 2:return{...Ht,width:{min:1400,ideal:1920,max:2160},height:{min:900,ideal:1080,max:1440}};case 3:return{...Ht,width:{min:640,ideal:640,max:800},height:{min:480,ideal:480,max:600}};case 4:return{...Ht,width:{min:640,ideal:800,max:960},height:{min:480,ideal:480,max:480}};default:return{}}}const un=async en=>{const Ht={video:Ue==="environment"?Mn(en.current):localStorage.getItem("isHighPerformance")==="true"?{height:{ideal:1080}}:{facingMode:Ue,height:{ideal:480},width:{ideal:640}},audio:st},rn={audio:isSafari()||st,video:{facingMode:"user",deviceId:at?{exact:at}:void 0}};if(mobile.isIpad()&&Ue==="user")try{const ln=await getNonUltraWideFrontCameraStream();ut(ln),jt(ln)}catch(ln){$e({...ln,type:"permissionDenied"})}else isAndroid&&Ue==="environment"?navigator.mediaDevices.getUserMedia(Ht).then(async ln=>{const an=ln.getVideoTracks()[0],mn=await getCameras(),yn=adjustCamerasFromCameraStream(an,mn);ln.getTracks().forEach(wn=>wn.stop());let bn=1280,Cn=720;if(en.current>1||isJ7Prime||isAlcatel1x||isLenovoVibeB){const{width:wn,height:Dn}=Mn(isJ7Prime?2:isAlcatel1x||isLenovoVibeB?4:en.current);bn=wn==null?void 0:wn.ideal,Cn=Dn==null?void 0:Dn.ideal}const Bn={video:{deviceId:{exact:yn.deviceId},width:{ideal:bn},height:{ideal:Cn}}};navigator.mediaDevices.getUserMedia(Bn).then(wn=>{jt(wn),ut(wn)})}).catch(ln=>{en.current=en.current+1,en.current>4?Dt(ln):un(en)}):navigator.mediaDevices.getUserMedia(mobile.any()?Ht:rn).then(ln=>{jt(ln),ut(ln)}).catch(ln=>{Dt(ln)})};if(mobile.iOS()&&Jt.current)return;if($t===!0||isDesktop||dt||it===!1){if(Jt.current=!0,Xe){ut(Xe);return}mt(!0),un(xt),addEvent({token:Ke,code:"cameraFeedbackDisplayed",payload:{feedback:"Loading..."},module:"ID Capture",screen:`${Je} Camera Capture`})}const hn=document.createElement("canvas");St.current=hn})(),()=>{$t&&(Jt.current=!1,Xe==null||Xe.getTracks().forEach(Mn=>Mn.stop()))}),[$t,Ue,Xe]),React$1.useLayoutEffect(()=>{ft&&(typeof ft=="function"?ft(Mt.current):ft.current=Mt.current)},[ft,Mt]),React$1.useImperativeHandle(ft,()=>({getBase64ScreenShot:Vt,getImageData:Ot,getFullImage:Xt,dataURLtoBlob:Yt,video:Mt.current,stream:vt,getProperSizeCanvas:Et,getCanvas:Lt,getFullCanvas:zt,setIsLoadingCamera:mt}));const Et=(fn,Mn=!0)=>{const un=Math.abs(Mt.current.clientWidth-window.innerWidth),hn=document.createElement("canvas"),en=(Mn?fn.height:fn.videoHeight)/Mt.current.clientHeight,Ht=window.innerWidth,Kt=window.innerHeight;return hn.width=Ht,hn.height=Kt,hn.getContext("2d").drawImage(fn,en*un/2,0,en*Ht,en*Kt,0,0,Ht,Kt),hn},Vt=(fn,Mn,un,hn=!0)=>{const en=Lt(fn,Mn);return(Ze?en:(rn=>{const ln=getMaskPosition(),an=hn?ln.left:0,mn=hn?ln.top:0,yn=hn?ln.width:rn.width,bn=hn?ln.height:rn.height,Cn=document.createElement("canvas");return Cn.width=yn,Cn.height=bn,Cn.getContext("2d").drawImage(rn,an,mn,yn,bn,0,0,yn,bn),Cn})(Et(en))).toDataURL("image/jpeg",un).split(",")[1]},Ot=(fn,Mn)=>{const un=Lt(fn,Mn),hn=un.getContext("2d",{willReadFrequently:!0});return{canvasElement:un,imageElement:un&&hn.getImageData(0,0,un.width,un.height)}},Lt=(fn=1280,Mn=720)=>{if(!Mt.current.videoHeight||!Ct)return null;Ct.width=fn,Ct.height=Mn;const un=Ct.getContext("2d");return un.clearRect(0,0,fn,Mn),un.drawImage(Mt.current,0,0),Ct},zt=(fn=1280,Mn=720)=>{if(!Mt.current.videoHeight)return null;if(mobile.any()){Ct.width=fn,Ct.height=Mn;const un=Ct.getContext("2d");un.clearRect(0,0,fn,Mn),un.drawImage(Mt.current,0,0)}return Ct},Xt=(fn,Mn,un,hn=null)=>{let en;return hn?en=hn:en=Lt(fn,Mn),en.toDataURL("image/jpeg",un).split(",")[1]},Yt=(fn,Mn,un)=>{const en=Lt(fn,Mn).toDataURL("image/jpeg",un),Ht=atob(en.split(",")[1]),Kt=[];for(let rn=0;rn<Ht.length;rn++)Kt.push(Ht.charCodeAt(rn));return new Blob([new Uint8Array(Kt)],{type:Qe})},sn=()=>Mt.current?Mt.current.videoWidth>Mt.current.videoHeight:!1,cn=()=>{Gt(!0),sessionStorage.setItem("cameraPermissionsGranted",String(!0)),addEvent({token:Ke,code:"permissionsAllowedCustom"}),addEvent({token:Ke,code:"cameraPermissionSubmitted",payload:{requestor:"browser",requestorDetails:browser$1.name,permission:"allowed"},module:"ID capture",screen:`${Je} Camera Capture`})},pn=()=>{addEvent({token:Ke,code:"permissionsQuitFlow"}),setTimeout(()=>{window.location.reload()},0)},vn=()=>{addEvent({token:Ke,code:"permissionsDeniedCustom"}),addEvent({token:Ke,code:"cameraPermissionSubmitted",payload:{requestor:"browser",requestorDetails:browser$1.name,permission:"denied"},module:"ID capture",screen:`${Je} Camera Capture`})},Tn=sessionStorage.getItem("cameraPermissionsGranted")==="true",tn=it&&(typeof Ft<"u"&&!Ft&&!$t||typeof $t<"u"&&!$t)&&!isDesktop&&!dt&&!Tn,dn=()=>{!It&&me&&typeof me=="function"&&me(),yt(!0)};return jsxs(React$1.Fragment,{children:[gt&&jsx(AllowCameraUse,{handleAllowCamera:ot}),tn&&jsx(FakePermissionsRequest,{handleDenyPermission:vn,handleCameraPermission:cn,handleQuitOnboarding:pn,type:Je,token:Ke,interviewId:nt}),!bt&&jsx(BrowserNotSupported,{}),Nt&&!tn&&jsx(Loader$1,{message:Ut("webcam.loading"),fullScreen:!0}),jsx(Video$1,{"aria-hidden":"true",autoPlay:!0,className:classNames(ue,{selfie:Ze,horizontal:sn(),desktop:!mobile.any(),assistedOnboarding:rt,"full-height":ct}),playsInline:!0,onPlay:dn,ref:Mt,muted:!0})]})}),captureButton="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2NSIgaGVpZ2h0PSI2NSIgdmlld0JveD0iMCAwIDY1IDY1Ij4KICAgIDxnIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPGc+CiAgICAgICAgICAgIDxnPgogICAgICAgICAgICAgICAgPGcgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTE1NSAtNjQ2KSB0cmFuc2xhdGUoMTU1IDY0NikiPgogICAgICAgICAgICAgICAgICAgIDxjaXJjbGUgY3g9IjMyLjMxOSIgY3k9IjMyLjMxOSIgcj0iMzIuMzE5IiBmaWxsPSIjMjAyNjNEIi8+CiAgICAgICAgICAgICAgICAgICAgPGNpcmNsZSBjeD0iMzIuMzE5IiBjeT0iMzIuMzE5IiByPSIyNS4xMzciIGZpbGw9IiNGRkYiIGZpbGwtb3BhY2l0eT0iLjA5MyIgc3Ryb2tlPSIjRkZGIiBzdHJva2Utd2lkdGg9IjIuMDUyIi8+CiAgICAgICAgICAgICAgICA8L2c+CiAgICAgICAgICAgICAgICA8ZyBmaWxsPSIjRkZGIiBmaWxsLXJ1bGU9Im5vbnplcm8iPgogICAgICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik0xNy4xOTMgMTIuMjRjMCAyLjI5NC0xLjg4IDQuMTYtNC4xOTMgNC4xNi0yLjMxMiAwLTQuMTkyLTEuODY2LTQuMTkyLTQuMTYgMC0yLjI5MyAxLjg4LTQuMTYgNC4xOTItNC4xNiAyLjMxMiAwIDQuMTkzIDEuODY3IDQuMTkzIDQuMTZ6TTI2IDYuMzM0djExLjgxNEMyNiAxOS43MjMgMjQuNzEzIDIxIDIzLjEyNSAyMUgyLjg3NUMxLjI4NyAyMSAwIDE5LjcyMyAwIDE4LjE0OFY2LjMzNEMwIDQuNzYgMS4yODcgMy40ODIgMi44NzUgMy40ODJoMy41MzZ2LS45ODdDNi40MTEgMS4xMTcgNy41MzcgMCA4LjkyNyAwaDguMTQ2YzEuMzkgMCAyLjUxNiAxLjExNyAyLjUxNiAyLjQ5NXYuOTg2aDMuNTM2QzI0LjcxMyAzLjQ4MiAyNiA0Ljc2IDI2IDYuMzM0em0tNi42NSA1LjkwNmMwLTMuNDczLTIuODQ5LTYuMjk4LTYuMzUtNi4yOTgtMy41IDAtNi4zNDkgMi44MjUtNi4zNDkgNi4yOThTOS41IDE4LjU0IDEzIDE4LjU0YzMuNTAxIDAgNi4zNS0yLjgyNiA2LjM1LTYuMjk5eiIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTE1NSAtNjQ2KSB0cmFuc2xhdGUoMTU1IDY0NikgdHJhbnNsYXRlKDE5IDIxKSIvPgogICAgICAgICAgICAgICAgPC9nPgogICAgICAgICAgICA8L2c+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4K",faceFrame$1="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMzYiIGhlaWdodD0iNTE4IiB2aWV3Qm94PSIwIDAgMzM2IDUxOCI+CiAgICA8cGF0aCBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHN0cm9rZT0iI0ZGRiIgc3Ryb2tlLWRhc2hhcnJheT0iNy4xMzk5OTk2NzU3NTA3MzIsMTkuMDM5OTk5Njc1NzUwNzMiIHN0cm9rZS13aWR0aD0iOS4wNDQiIGQ9Ik0xNjggNTEzLjM5MmM3Ni44MyAwIDE2Mi44OTMtMTEzLjkyIDE2Mi44OTMtMjU0LjQ0N1MyODAuMjM2IDQuNDk4IDE2OCA0LjQ5OCA1LjEwNyAxMTguNDE4IDUuMTA3IDI1OC45NDUgOTEuMTcgNTEzLjM5MiAxNjggNTEzLjM5MnoiLz4KPC9zdmc+Cg==",deviceStatsQueue=[];let isReady=!1;function addDeviceStats(ue,me){if(!isReady){deviceStatsQueue.push(me);return}return exports.api.post("/omni/device/stats",me,{headers:{"X-Incode-Hardware-Id":ue}}).catch(()=>{})}function emptyDeviceStatsQueue(ue){isReady=!0,deviceStatsQueue.forEach(me=>{addDeviceStats(ue,me)})}class FaceDetection{constructor(){this.pipelineProfile=null,this.bestFrame=null,this.bestFullImage=null,this.bestLandmarks=null,this.bestTopLeft=null,this.bestSize=null,this.currFrame=null,this.currFullImage=null}formatLandmarks(me,Ue,Qe){const[Ze,Je,Ge,He,Xe,$e,Ke,nt,tt,et]=me;return{rightEyeX:Ze,rightEyeY:Je,leftEyeX:Ge,leftEyeY:He,noseTipX:Xe,noseTipY:$e,rightMouthX:Ke,rightMouthY:nt,mouthX:tt,mouthY:et,x:Ue[0],y:Ue[1],width:Qe[0],height:Qe[1]}}async retrieveInputData(me){const Ue=cloneCanvas(me.getCanvas(me.video.videoWidth,me.video.videoHeight));if(!Ue)return null;const Qe=Ue.width,Ze=Ue.height,Je=me.getBase64ScreenShot(Qe,Ze,1,!1),Ge=me.getFullImage(Qe,Ze,1,Ue);return{imageData:Ue.getContext("2d").getImageData(0,0,Qe,Ze),frameStr:Je,fullFrameStr:Ge}}async initialize(me){const{onNoFace:Ue,onCapturing:Qe,onCapture:Ze,onTooManyFaces:Je,onTooClose:Ge,onCenterFace:He,onFarAway:Xe,onFaceAngle:$e,onDark:Ke,onBlur:nt,onHeadWear:tt,onLenses:et,onEyesClosed:rt,onFaceMask:at,onSwitchToManualCapture:ot,isLensesCheckEnabled:it,isMaskCheckEnabled:st,isClosedEyesCheckEnabled:ct,isHeadWearCheckEnabled:lt,isVideoSelfie:dt,pipelineProfile:ft,autocaptureTimeout:gt}=me;this.pipelineProfile=ft;const ht=this.pipelineProfile.pipelineType;await MlWasmJSApi$1.setFacePositionConstraints(ht,ft.parameters.frameMinX,ft.parameters.frameMinY,ft.parameters.frameMaxX,ft.parameters.frameMaxY),await MlWasmJSApi$1.setFaceDetectionThresholds(ht,ft.parameters.brightnessThreshold,ft.parameters.blurrinessThreshold,ft.parameters.tiltRotationAngleThreshold,ft.parameters.minMagicCropSize,gt),await MlWasmJSApi$1.setFaceAttributesEnabled(ht,it,st,ct,lt),await MlWasmJSApi$1.setFaceAttributesThresholds(ht,ft.parameters.headwearThreshold,ft.parameters.lensesThreshold,ft.parameters.closedEyesThreshold,ft.parameters.maskThreshold),await MlWasmJSApi$1.setFaceDetectionMode(ht,dt);const vt=()=>{Ze(this.bestFrame,this.bestFullImage,this.formatLandmarks(this.bestLandmarks,this.bestTopLeft,this.bestSize))},Rt=bt=>{this.bestFrame=this.currFrame,this.bestFullImage=this.currFullImage;const At=bt.rect;this.bestTopLeft=[At.x,At.y];const Nt=[At.x+At.width,At.y+At.height],mt=this.bestTopLeft,It=Nt;this.bestSize=[It[0]-mt[0],It[1]-mt[1]],this.bestLandmarks=[bt.rightEye.x,bt.rightEye.y,bt.leftEye.x,bt.leftEye.y,bt.noseTip.x,bt.noseTip.y,bt.rightMouthCorner.x,bt.rightMouthCorner.y,bt.leftMouthCorner.x,bt.leftMouthCorner.y]};await MlWasmJSApi$1.setFaceDetectionCallbacks(ht,Xe,Ge,Je,Ue,vt,Qe,He,Ke,nt,$e,Rt,et,at,rt,tt,ot)}async detect(me){try{const Ue=await this.retrieveInputData(me);if(!Ue)return;this.currFrame=Ue.frameStr,this.currFullImage=Ue.fullFrameStr,await MlWasmJSApi$1.allocateImageBuffers(Ue.imageData.width,Ue.imageData.height),await MlWasmJSApi$1.process(Ue.imageData,PipelineType.SelfieFaceDetectionPipeline)}catch(Ue){console.error(`Exception: ${Ue}`)}}}const state={token:null};var PipelineProfileType=(ue=>(ue[ue.IdCaptureBrazilian=0]="IdCaptureBrazilian",ue[ue.IdCaptureVisas=1]="IdCaptureVisas",ue[ue.IdVideoSelfieBrazilian=2]="IdVideoSelfieBrazilian",ue[ue.IdVideoSelfieVisas=3]="IdVideoSelfieVisas",ue[ue.SelfieFaceDetection=4]="SelfieFaceDetection",ue))(PipelineProfileType||{});class PipelineProfile{constructor(me,Ue,Qe,Ze,Je=null,Ge=""){this.pipelineType=me,this.profileType=Ue,this.modelNames=Qe,this.parameters=Ze,this.paramsConfigurator=Je,this.description=Ge}reconfigureParams(me=null,Ue=null){if(this.paramsConfigurator==null)throw new Error("PipelineProfile does not have a paramsConfigurator");this.paramsConfigurator(this.parameters,this.pipelineType,me,Ue)}}function IdCaptureParamsConfigurator(ue,me,Ue,Qe){Object.assign(ue,{areaDown:Qe||Ue?55e3:25e3,areaUp:Qe||Ue?75e3:55e3,areaIOSPassportUp:3e4,areaIOSPassportDown:2e4,widthIOSUp:me==PipelineType.IdCapturePipeline?125:180,widthIOSDown:me==PipelineType.IdCapturePipeline?85:150,widthDown:Qe||Ue?185:135,widthUp:Qe||Ue?255:205})}const SelfieFaceDetectionPipelineParams={frameMinX:0,frameMinY:0,frameMaxX:1,frameMaxY:1,brightnessThreshold:50,blurrinessThreshold:50,tiltRotationAngleThreshold:7,minMagicCropSize:200,headwearThreshold:.95,lensesThreshold:.95,closedEyesThreshold:.9,maskThreshold:.5},pipelineProfiles=[new PipelineProfile(PipelineType.IdCapturePipeline,PipelineProfileType.IdCaptureBrazilian,["brazilian_mobile_025_ep199_fp16.ortmodelv2"],{glareThreshold:.2,classificationThreshold:.98,sharpnessThreshold:.3,sharpnessChangeThreshold:.3},IdCaptureParamsConfigurator,"Id Capture Profile with brazilian_mobile model"),new PipelineProfile(PipelineType.IdCapturePipeline,PipelineProfileType.IdCaptureVisas,["visas_mobile_025_best_v1_03_fp16.ortmodelv2"],{glareThreshold:.3,classificationThreshold:.98,sharpnessThreshold:.2,sharpnessChangeThreshold:.2},IdCaptureParamsConfigurator,"Id Capture Profile with visas_mobile model"),new PipelineProfile(PipelineType.IdVideoSelfiePipeline,PipelineProfileType.IdVideoSelfieBrazilian,["brazilian_mobile_025_ep199_fp16.ortmodelv2"],{glareThreshold:.2,classificationThreshold:.9,sharpnessThreshold:.3,sharpnessChangeThreshold:.3},IdCaptureParamsConfigurator,"Id Videoselfie profile with brazilian_mobile model"),new PipelineProfile(PipelineType.IdVideoSelfiePipeline,PipelineProfileType.IdVideoSelfieVisas,["visas_mobile_025_best_v1_03_fp16.ortmodelv2"],{glareThreshold:.3,classificationThreshold:.9,sharpnessThreshold:.2,sharpnessChangeThreshold:.2},IdCaptureParamsConfigurator,"Id Videoselfie Profile with visas_mobile model"),new PipelineProfile(PipelineType.SelfieFaceDetectionPipeline,PipelineProfileType.SelfieFaceDetection,["selfie_bf_angles_192x192_opset9_fp16.ortmodelv2","bf_attrib_31b8f9d92fb345c2b4bbdd222792562c_0_fp16.ortmodelv2"],SelfieFaceDetectionPipelineParams,null,"Selfie face detection profile")];function getProfile(ue){const me=pipelineProfiles.find(Ue=>Ue.profileType===ue);if(!me)throw new Error(`Profile not found for type: ${ue}`);return me}const probabilityThreshold=.9,wasmVersion="v1.7.6",brazilianPipelineBundle=[PipelineProfileType.IdCaptureBrazilian,PipelineProfileType.IdVideoSelfieBrazilian,PipelineProfileType.SelfieFaceDetection],visasPipelineBundle=[PipelineProfileType.IdCaptureVisas,PipelineProfileType.IdVideoSelfieVisas,PipelineProfileType.SelfieFaceDetection],PipelinesBundle=new Map([["brazilianPipelineBundle",brazilianPipelineBundle],["visasPipelineBundle",visasPipelineBundle]]);function switchBundle(){return Math.random()<probabilityThreshold?"brazilianPipelineBundle":"visasPipelineBundle"}function getInitializationParams(ue){const Ue=ue?switchBundle():"brazilianPipelineBundle",Qe="https://d3vv997wtl2myz.cloudfront.net/webcamera/onnx-backend-wasm",Ze=`${Qe}/${wasmVersion}/webLib.wasm`,Je=`${Qe}/${wasmVersion}/webLibSimd.wasm`,Ge=`${Qe}/${wasmVersion}/webLib.js`,He=`${Qe}/${wasmVersion}/versions.json`;let Xe=new Map,$e=new Map;for(const Ke of PipelinesBundle.get(Ue)){const nt=getProfile(Ke);if(!nt)throw new Error(`Profile not found for type: ${Ke}`);const tt=nt.modelNames;let et=[];for(const rt of tt)et.push(`${Qe}/${wasmVersion}/models/${rt}`);Xe.set(nt.pipelineType,et),$e.set(nt.pipelineType,nt)}return{wasmModulePath:Ze,wasmSimdModulePath:Je,glueCodePath:Ge,versionsFilePath:He,pipelineModels:Xe,enableSIMD:!0,bundle:Ue,profiles:$e}}class MotionStatusCheck{constructor(me,Ue,Qe,Ze,Je,Ge,He,Xe,$e,Ke,nt,tt){this.isRunning_=!1,this.acl_=null,this.gyro_=null,this.permission_=!0,this.minNumberOfFrames_=3,this.maxFrequency_=60,this.emptyParams={meanX:0,meanY:0,meanZ:0,m2X:0,m2Y:0,m2Z:0,cumulativeAbsErrorX:0,cumulativeAbsErrorY:0,cumulativeAbsErrorZ:0,ptsNum:0},this.paramsAcc_={...this.emptyParams},this.paramsGyro_={...this.emptyParams},this.paramsAccGrOld_={...this.emptyParams},this.paramsAccOld_={...this.emptyParams},this.paramsGyroscopeOld_={...this.emptyParams},this.paramsOrientationOld_={...this.emptyParams},this.waitForClick=()=>new Promise(et=>{document.addEventListener("click",async()=>{const rt=await this.requestMotionPermission();et(rt)},{once:!0})}),this.deviceMotionListener=et=>{if(et.accelerationIncludingGravity){const rt={x:et.accelerationIncludingGravity.x,y:et.accelerationIncludingGravity.y,z:et.accelerationIncludingGravity.z};this.checkFields(rt)&&(this.paramsAccGrOld_.ptsNum+=1,this.updateParams(this.paramsAccGrOld_,rt))}if(et.acceleration){const rt={x:et.acceleration.x,y:et.acceleration.y,z:et.acceleration.z};this.checkFields(rt)&&(this.paramsAccOld_.ptsNum+=1,this.updateParams(this.paramsAccOld_,rt))}if(et.rotationRate){const rt={x:et.rotationRate.alpha,y:et.rotationRate.beta,z:et.rotationRate.gamma};this.checkFields(rt)&&(this.paramsGyroscopeOld_.ptsNum+=1,this.updateParams(this.paramsGyroscopeOld_,rt))}},this.deviceOrientationListener=et=>{const rt={x:et.alpha,y:et.beta,z:et.gamma};this.checkFields(rt)&&(this.paramsOrientationOld_.ptsNum+=1,this.updateParams(this.paramsOrientationOld_,rt))},this.accThreshold_=me,this.gyroThreshold_=Ue,this.accGrOldThreshold_=Qe,this.accOldThreshold_=Ze,this.gyroscopeOldThreshold_=Je,this.orientationOldThreshold_=Ge,this.maeAccThreshold_=He,this.maeGyroThreshold_=Xe,this.maeAccGrOldThreshold_=$e,this.maeAccOldThreshold_=Ke,this.maeGyroscopeOldThreshold_=nt,this.maeOrientationOldThreshold_=tt}async requestMotionPermission(){DeviceMotionEvent&&typeof DeviceMotionEvent.requestPermission=="function"&&DeviceMotionEvent.requestPermission().then(me=>{me!=="granted"&&(this.permission_=!1)}).catch(console.error)}initializeAccelerometer(){if("Accelerometer"in window)try{this.acl_=new window.Accelerometer({frequency:this.maxFrequency_}),this.acl_.addEventListener("reading",()=>this.updateAcc())}catch{}}initializeGyroscope(){if("Gyroscope"in window)try{this.gyro_=new window.Gyroscope({frequency:this.maxFrequency_}),this.gyro_.addEventListener("reading",()=>this.updateGyro())}catch{}}async start(){this.run()}run(){if(!(this.isRunning_||!this.permission_)){try{this.initializeAccelerometer(),this.acl_.start()}catch{}try{this.initializeGyroscope(),this.gyro_.start()}catch{}window.addEventListener("devicemotion",this.deviceMotionListener),window.addEventListener("deviceorientation",this.deviceOrientationListener),this.isRunning_=!0}}stop(){this.isRunning_=!1,this.acl_&&this.acl_.stop(),this.gyro_&&this.gyro_.stop(),window.removeEventListener("devicemotion",this.deviceMotionListener),window.removeEventListener("deviceorientation",this.deviceOrientationListener),this.paramsAcc_={...this.emptyParams},this.paramsGyro_={...this.emptyParams},this.paramsAccGrOld_={...this.emptyParams},this.paramsAccOld_={...this.emptyParams},this.paramsGyroscopeOld_={...this.emptyParams},this.paramsOrientationOld_={...this.emptyParams}}updateAcc(){if(!(!this.isRunning_||!this.acl_)&&(this.paramsAcc_.ptsNum+=1,this.acl_)){const me={x:this.acl_.x,y:this.acl_.y,z:this.acl_.z};this.checkFields(me)&&this.updateParams(this.paramsAcc_,me)}}updateGyro(){if(!(!this.isRunning_||!this.gyro_)&&(this.paramsGyro_.ptsNum+=1,this.gyro_)){const me={x:this.gyro_.x,y:this.gyro_.y,z:this.gyro_.z};this.checkFields(me)&&this.updateParams(this.paramsGyro_,me)}}check(){if(!this.permission_)return"UNCLEAR";const me=this.checkStability();return me===null?"UNCLEAR":me?"FAIL":"PASS"}checkStability(){if(!this.isRunning_)return null;const Ue=[this.gyro_?this.isBelowStdThreshold(this.paramsGyro_,this.gyroThreshold_):null,this.acl_?this.isBelowStdThreshold(this.paramsAcc_,this.accThreshold_):null,this.isBelowStdThreshold(this.paramsAccGrOld_,this.accGrOldThreshold_),this.isBelowStdThreshold(this.paramsAccOld_,this.accOldThreshold_),this.isBelowStdThreshold(this.paramsGyroscopeOld_,this.gyroscopeOldThreshold_),this.isBelowStdThreshold(this.paramsOrientationOld_,this.orientationOldThreshold_)].filter(He=>He!==null),Qe=Ue.length>0?Ue.every(He=>He):null,Je=[this.gyro_?this.isBelowMaeThreshold(this.paramsGyro_,this.maeGyroThreshold_):null,this.acl_?this.isBelowMaeThreshold(this.paramsAcc_,this.maeAccThreshold_):null,this.isBelowMaeThreshold(this.paramsAccGrOld_,this.maeAccGrOldThreshold_),this.isBelowMaeThreshold(this.paramsAccOld_,this.maeAccOldThreshold_),this.isBelowMaeThreshold(this.paramsGyroscopeOld_,this.maeGyroscopeOldThreshold_),this.isBelowMaeThreshold(this.paramsOrientationOld_,this.maeOrientationOldThreshold_)].filter(He=>He!==null),Ge=Je.length>0?Je.every(He=>He):null;return Qe===null?Ge===null?null:Ge:Ge!==null?Qe&&Ge:Qe}updateParams(me,Ue){const Qe=Ue.x-me.meanX,Ze=Ue.y-me.meanY,Je=Ue.z-me.meanZ;me.meanX+=Qe/me.ptsNum,me.meanY+=Ze/me.ptsNum,me.meanZ+=Je/me.ptsNum,me.m2X+=Qe*(Ue.x-me.meanX),me.m2Y+=Ze*(Ue.y-me.meanY),me.m2Z+=Je*(Ue.z-me.meanZ),me.cumulativeAbsErrorX+=Math.abs(Ue.x-me.meanX),me.cumulativeAbsErrorY+=Math.abs(Ue.y-me.meanY),me.cumulativeAbsErrorZ+=Math.abs(Ue.z-me.meanZ)}calculateStd(me){const Ue={x:me.m2X/me.ptsNum,y:me.m2Y/me.ptsNum,z:me.m2Z/me.ptsNum};return{x:Math.sqrt(Ue.x),y:Math.sqrt(Ue.y),z:Math.sqrt(Ue.z)}}calculateMae(me){return{x:me.cumulativeAbsErrorX/me.ptsNum,y:me.cumulativeAbsErrorY/me.ptsNum,z:me.cumulativeAbsErrorZ/me.ptsNum}}checkFields(me){return me.x!==null&&me.y!==null&&me.z!==null}isBelowStdThreshold(me,Ue){if(me.ptsNum<this.minNumberOfFrames_)return null;const Qe=this.calculateStd(me);return Qe.x<Ue&&Qe.y<Ue&&Qe.z<Ue}isBelowMaeThreshold(me,Ue){if(me.ptsNum<this.minNumberOfFrames_)return null;const Qe=this.calculateMae(me);return Qe.x<Ue&&Qe.y<Ue&&Qe.z<Ue}}class OnboardingAnalytics{constructor(){this.motionStatusCheck=null,this.estimatedPerformance=null,this.analysisStatus="",this.motionStatus="",this.pipelineLogs="",this.pipelinesBundle=null,this.motionStatusCheck=new MotionStatusCheck(.3,.3,.3,.3,10,10,.3,.3,.3,.3,10,10)}static getInstance(){return OnboardingAnalytics.instance||(OnboardingAnalytics.instance=new OnboardingAnalytics),OnboardingAnalytics.instance}setPipelinesBundle(me){this.pipelinesBundle=me}getPipelineLogs(){return this.pipelineLogs}getMotionStatus(){return this.motionStatus}getAnalysisStatus(){return this.analysisStatus}async analyzeFrame(me){const Ue=await base64ToImageData(me);await MlWasmJSApi$1.analyzeFrame(Ue),this.updatePipelineStats()}async startOnboardingCheck(){this.motionStatusCheck.start()}estimatePerformance(){if(this.estimatedPerformance)return this.estimatedPerformance;this.estimatedPerformance=MlWasmJSApi$1.estimatePerformance()}updatePipelineStats(){if(MlWasmJSApi$1.isInitialized())try{const me=MlWasmJSApi$1.getPipelineState();if(me!==""){const Ue=JSON.parse(me);this.analysisStatus=Ue.statsAnalysisStatus,Ue.pipelinesBundle=this.pipelinesBundle?this.pipelinesBundle:"unknown",Ue.estimatedPerformance=this.estimatedPerformance,this.pipelineLogs=JSON.stringify(Ue),this.motionStatus===""&&(this.motionStatus=this.motionStatusCheck.check())}}catch(me){console.error(`Exception: ${me}`)}}}const OnboardingAnalytics$1=OnboardingAnalytics.getInstance();class DetectionSetup{constructor(){this.setupDetectPromise=null,this.isSetupDetect=!1,this.pipelinesBundle=null,this.profiles=null}static getInstance(){return DetectionSetup.instance||(DetectionSetup.instance=new DetectionSetup),DetectionSetup.instance}setIsHighPerformanceVariable(){if(!mobile.iOS())return;if(new URLSearchParams(window.location.search).get("smallFrame")==="true"){localStorage.setItem("isHighPerformance","true");return}localStorage.setItem("isHighPerformance",String(window.outerHeight===852&&window.outerWidth===393||window.outerHeight===932&&window.outerWidth===430||window.innerHeight===631&&window.innerWidth===375))}async setupDetect(){return this.setupDetectPromise?this.setupDetectPromise:(this.setupDetectPromise=this._runSetupDetect(),this.setupDetectPromise)}getPipelinesBundle(){return this.pipelinesBundle}getProfile(me){var Ue;return((Ue=this.profiles)==null?void 0:Ue.get(me))??null}async warmup(){for(;!MlWasmJSApi$1.isInitialized();)await new Promise(me=>setTimeout(me,100))}async _runSetupDetect(){var Qe,Ze;if(this.isSetupDetect)return;addEvent({token:(Qe=state.token)==null?void 0:Qe.token,code:"modelLoadStart"}),this.setIsHighPerformanceVariable();const me=getInitializationParams(options.hostingApp==="Incode ID");for(this.pipelinesBundle=me.bundle,this.profiles=me.profiles,OnboardingAnalytics$1.setPipelinesBundle(this.pipelinesBundle),OnboardingAnalytics$1.startOnboardingCheck(),await MlWasmJSApi$1.initialize(me.wasmModulePath,me.wasmSimdModulePath,me.glueCodePath,me.enableSIMD,me.versionsFilePath,me.pipelineModels);!MlWasmJSApi$1.isInitialized();)await new Promise(Je=>setTimeout(Je,100));OnboardingAnalytics$1.estimatePerformance(),await MlWasmJSApi$1.initializePipelines();const Ue={}.VITE_WASM_PRODUCTION_MODE==="true";try{await MlWasmJSApi$1.setProductionMode(Ue)}catch(Je){console.error(`Exception: ${Je}`)}this.isSetupDetect=!0,addEvent({token:(Ze=state.token)==null?void 0:Ze.token,code:"modelLoadEnd",payload:{loadSuccessful:!0}})}}const DetectionSetup$1=DetectionSetup.getInstance();function useSelfie({timeout:ue=4e4,onLog:me=emptyFunc,handleCapture:Ue,numberOfTries:Qe=3,handleNoAttempsLeft:Ze=emptyFunc,webcam:Je,token:Ge,isDetecting:He,onSwitchManualCapture:Xe=emptyFunc,onManualCaptureSelfie:$e=emptyFunc}){const Ke=React$1.useRef(0),nt=React$1.useRef(!1),tt=React$1.useRef(!1),[et,rt]=React$1.useState(""),[at,ot]=React$1.useState("idle"),[it,st]=React$1.useState(!1),[ct,lt]=React$1.useState(!1),dt=React$1.useRef(),ft=React$1.useRef(Xe),gt=React$1.useRef(null),{t:ht}=useTranslation(),vt=async(Yt,sn,cn)=>{tt.current||(He.current=!1,await sleep(300),tt.current=!0,ot("uploading"),Ue(Yt,sn,cn),await sleep(2e3),bt().catch(console.log))},Rt=500;async function bt(){if(mobile.isDesktop())return;const Yt=document.querySelector("video"),sn=Yt.srcObject;await zoomCameraToTheMax(sn),await sleep(Rt);const cn=Yt.videoWidth,pn=Yt.videoHeight,vn=await captureImageFromStream(sn,cn,pn);await MlWasmJSApi$1.allocateImageBuffers(cn,pn),(await MlWasmJSApi$1.runSelfieCapture(vn)).faces.size()>0&&addDeviceStats(Ge,{virtualCameraDetected:!0})}const At=()=>{var sn;const Yt=getLogObject("timeout",{message:"No face found"});(sn=ft.current)==null||sn.call(ft),me(Yt),lt(!0)},Nt=()=>{nt.current||(me(getLogObject("tooFar",{message:ht("notifications.moveCloser")})),rt(ht("notifications.moveCloser")))},mt=()=>{nt.current||(me(getLogObject("tooManyFaces",{message:ht("notifications.tooManyFaces")})),rt(ht("notifications.tooManyFaces")))},It=()=>{nt.current||(me(getLogObject("centerFace",{message:ht("notifications.centerFace")})),rt(ht("notifications.centerFace")))},yt=()=>{tt.current||nt.current||(ot("capturing"),me(getLogObject("dontMove",{message:ht("notifications.dontMove")})),rt(ht("notifications.getReady")),nt.current=!0)},Mt=()=>{nt.current||tt.current||rt(ht("notifications.moveAway"))},St=()=>{nt.current||tt.current||rt(ht("notifications.onDark"))},xt=()=>{nt.current||tt.current||rt(ht("notifications.onBlur"))},Ut=()=>{nt.current||tt.current||rt(ht("notifications.onFaceAngle"))},Ft=()=>{nt.current||tt.current||rt(ht("notifications.removeHeadwear"))},wt=()=>{nt.current||tt.current||rt(ht("notifications.removeLenses"))},Ct=()=>{nt.current||tt.current||rt(ht("notifications.openEyes"))},Zt=()=>{nt.current||tt.current||rt(ht("notifications.removeMask"))},Jt=async()=>{gt.current=new FaceDetection,await gt.current.initialize({onNoFace:emptyFunc,onCaptureFace:emptyFunc,onTooManyFaces:mt,onTooClose:Mt,onCenterFace:It,onFarAway:Nt,onCapturing:yt,onBlur:xt,onDark:St,onFaceAngle:Ut,onHeadWear:Ft,onLenses:wt,onEyesClosed:Ct,onFaceMask:Zt,onSwitchToManualCapture:At,onCapture:vt,isLensesCheckEnabled:!1,isMaskCheckEnabled:!1,isClosedEyesCheckEnabled:!1,isHeadWearCheckEnabled:!1,isVideoSelfie:!1,pipelineProfile:DetectionSetup$1.getProfile(PipelineType.SelfieFaceDetectionPipeline),autocaptureTimeout:ue})};React$1.useEffect(()=>{ft.current=Xe},[Xe]),React$1.useEffect(()=>{lt(!1)},[]);const Qt=async({response:Yt,livenessPassed:sn,imageBase64:cn})=>{if(Ke.current=Ke.current+1,Qe!==-1&&Ke.current>=Qe)return Ze({response:Yt,livenessPassed:sn,imageBase64:cn});rt(""),ot("idle"),nt.current=!1,tt.current=!1,zoomCameraToTheMin(document.querySelector("video").srcObject),await sleep(1e3)},$t=Yt=>{const sn=Yt.errorMessage||Yt.message||Yt.reason,{status:cn}=Yt;if(zoomCameraToTheMin(document.querySelector("video").srcObject),cn===3004){rt(ht("notifications.unableToCrop")),me(getLogObject("unableToCrop",{message:`${ht("notifications.unableToCrop")}`}));return}switch(sn){case"No faces found on the image":rt(ht("notifications.face")),me(getLogObject("faceNotDetected",{message:`${ht("notifications.face")}`}));break;case"BadRequestException: More than one face detected.":rt(ht("notifications.multiple")),me(getLogObject("multipleFacesDetected",{message:`${ht("notifications.multiple")}`}));break;case"Cropping area goes off the image.":rt(ht("notifications.crop")),me(getLogObject("cropTooSmall",{message:`${ht("notifications.crop")}`}));break;case"Image in portrait orientation is expected.":rt(ht("notifications.portrait")),me(getLogObject("imageNotPortrait",{message:`${ht("notifications.portrait")}`}));break;default:me(getLogObject("InternalServerError",{message:`${ht("notifications.error")}`})),rt(ht("notifications.error"));break}},Gt=React$1.useCallback(()=>{const Yt=async()=>{if(!He.current){await sleep(1e3);return}gt.current||await Jt();try{await MlWasmJSApi$1.handleDetectionCallAndUpdateState(PipelineType.SelfieFaceDetectionPipeline),await gt.current.detect(Je.current)}catch(sn){console.error(sn)}requestAnimationFrame(Yt)};He.current||(He.current=!0,requestAnimationFrame(Yt))},[me,Jt]),Pt=React$1.useCallback(async()=>{st(!0),await sleep(4e3),Gt()},[Gt]);function jt(){$e();const Yt=Je.current.getBase64ScreenShot(Je.current.video.videoWidth,Je.current.video.videoHeight,1,!1),sn=Je.current.getFullImage(Je.current.video.videoWidth,Je.current.video.videoHeight,1);vt(Yt,sn,null)}const Dt=at==="capturing",ut=at==="uploading",Et=at==="success",Vt=at==="error",Ot=Dt||ut,Lt=ut||Et||Vt;return{notificationMessage:et,mode:at,capturing:nt,cameraReady:it,showManualCapture:ct,handleFaceAutoCapture:vt,setMode:ot,resetLoading:Qt,setNotificationMessage:rt,handleError:$t,autoDetectFace:Gt,startAutoDetect:Pt,handleManualCapture:jt,isCapturing:Dt,isUploading:ut,isSuccess:Et,isError:Vt,isLoading:Ot,hideCamera:Lt,showBorders:it&&(at==="idle"||Vt),shouldShowManualCapture:ct&&!Lt,selfieTimeoutRef:dt}}async function sendMfa({verificationCode:ue,transactionId:me}){return exports.api.post("/omni/oneToN/mfa",{verificationCode:ue,transactionId:me}).then(Ue=>Ue.data).catch(Ue=>{var Qe;return Promise.reject((Qe=Ue==null?void 0:Ue.response)==null?void 0:Qe.data)})}const ErrorContainer$1=styled.div`
1399
+ `,isAndroid=!!mobile.Android(),isJ7Prime=!!mobile.J7Prime(),isAlcatel1x=!!mobile.Alcatel1x(),isLenovoVibeB=!!mobile.LenovoVibeB(),isDesktop=mobile.isDesktop(),parser=new UAParser,{browser:browser$1}=parser.getResult(),Webcam=React$1.forwardRef(({className:ue,onPlay:me,videoSource:Ue,screenshotFormat:Qe,isSelfie:Ze=!1,type:Je,permissionMessage:Ge,onLog:He=emptyFunc,stream:Xe,onError:$e=emptyFunc,token:Ke,interviewId:nt,onStreamReady:tt=emptyFunc,showCustomCameraPermissionScreen:et,assistedOnboarding:rt,deviceId:at,onRestartOnboarding:ot=reload,showDoublePermissionsRequest:it=!1,publishAudio:st=!1,fullHeight:ct=!1,isRecordingEnabled:lt=!1,isKiosk:dt=!1},ft)=>{const[gt,ht]=React$1.useState(!1),[vt,Rt]=React$1.useState(Xe),[bt,At]=React$1.useState(!0),[Nt,mt]=React$1.useState(!0),[It,yt]=React$1.useState(!1),Mt=React$1.useRef(null),St=React$1.useRef(),xt=React$1.useRef(0),{t:Ut}=useTranslation(),[Ft,wt]=usePermissions(),Ct=St.current,Zt=React$1.useRef(),Jt=React$1.useRef(!1),Qt=React$1.useRef();Zt.current=Ft;const[$t,Gt]=React$1.useState(!it);Ge=Ge||Ut("permissionMessage"),React$1.useEffect(()=>{Zt.current&&!isDesktop&&!dt&&Gt(Zt.current)},[Ft]),React$1.useEffect(()=>{const fn=sessionStorage.getItem("cameraPermissionsGranted")==="true";!isDesktop&&fn&&!dt&&Gt(!0)},[Ft]),React$1.useEffect(()=>{const fn=Mt.current;return()=>{fn.pause(),fn.srcObject=null}},[]),React$1.useEffect(()=>()=>{vt==null||vt.getTracks().forEach(fn=>fn.stop())},[vt]),React$1.useEffect(()=>{if(options.protect&&It){const fn=setInterval(async()=>{if(Mt.current){if(Mt.current.paused){Qt.current=null;return}const Mn=getImageBase64FromVideo(Mt.current);Mn===Qt.current&&window.location.reload(),Qt.current=Mn}},250);return()=>clearInterval(fn)}},[It]);const Pt=React$1.useCallback(()=>{var fn,Mn,un;if(!document.hidden)return(Mn=(fn=Mt.current)==null?void 0:fn.srcObject)==null||Mn.clone(),(un=Mt.current)==null?void 0:un.play()},[]);useEventListener("visibilitychange",Pt,document);const jt=fn=>{const Mn=fn.getVideoTracks()[0],{width:un,height:hn}=Mn.getSettings(),{focusMode:en=!1}=navigator.mediaDevices.getSupportedConstraints();addEvent({code:"cameraType",payload:{type:"webRTC",resolution:`${un}x${hn}`,autofocus:en,label:Mn.label},token:Ke}),Ze&&addEvent({code:"cameraSelfie",token:Ke})},Dt=fn=>{mt(!1),fn.constructor.name==="DOMException"?(addEvent({code:"permissionDenied",payload:{message:"User denied to use camera."},token:Ke}),He(getLogObject("permissionDenied",{message:"User denied to use camera."})),fn.type="permissionDenied",et?ht(!0):$e(fn)):fn.constructor.name==="OverconstrainedError"?(He(getLogObject("OSVersionNotSupported",{message:"OS version is not supported."})),At(!1)):(He(getLogObject("browserNotSupported",{message:"Browser is not supported."})),At(!1))},ut=async fn=>{wt(!0);const Mn=()=>{Mt.current.srcObject=fn,tt(fn),Rt(fn),lt||mt(!1)},un=fn.getVideoTracks()[0];MlWasmJSApi$1.isVirtualCamera(un.label)&&$e(new Error("Virtual camera is detected")),mobile.iOS()?un.applyConstraints({advanced:[{focusDistance:1}]}).finally(()=>{Mn()}):Mn()};React$1.useEffect(()=>((async()=>{function Mn(en){const Ht={resizeMode:"none",facingMode:"environment"};switch(en){case 0:return{...Ht,height:{ideal:localStorage.getItem("isHighPerformance")==="true"?1080:720}};case 1:return{...Ht,width:{min:3200,ideal:3840,max:4096},height:{min:1800,ideal:2160,max:2400}};case 2:return{...Ht,width:{min:1400,ideal:1920,max:2160},height:{min:900,ideal:1080,max:1440}};case 3:return{...Ht,width:{min:640,ideal:640,max:800},height:{min:480,ideal:480,max:600}};case 4:return{...Ht,width:{min:640,ideal:800,max:960},height:{min:480,ideal:480,max:480}};default:return{}}}const un=async en=>{const Ht={video:Ue==="environment"?Mn(en.current):localStorage.getItem("isHighPerformance")==="true"?{height:{ideal:1080}}:{facingMode:Ue,height:{ideal:480},width:{ideal:640}},audio:st},rn={audio:isSafari()||st,video:{facingMode:"user",deviceId:at?{exact:at}:void 0}};if(mobile.isIpad()&&Ue==="user")try{const ln=await getNonUltraWideFrontCameraStream();ut(ln),jt(ln)}catch(ln){$e({...ln,type:"permissionDenied"})}else isAndroid&&Ue==="environment"?navigator.mediaDevices.getUserMedia(Ht).then(async ln=>{const an=ln.getVideoTracks()[0],mn=await getCameras(),yn=adjustCamerasFromCameraStream(an,mn);ln.getTracks().forEach(wn=>wn.stop());let bn=1280,Cn=720;if(en.current>1||isJ7Prime||isAlcatel1x||isLenovoVibeB){const{width:wn,height:Dn}=Mn(isJ7Prime?2:isAlcatel1x||isLenovoVibeB?4:en.current);bn=wn==null?void 0:wn.ideal,Cn=Dn==null?void 0:Dn.ideal}const Bn={video:{deviceId:{exact:yn.deviceId},width:{ideal:bn},height:{ideal:Cn}}};navigator.mediaDevices.getUserMedia(Bn).then(wn=>{jt(wn),ut(wn)})}).catch(ln=>{en.current=en.current+1,en.current>4?Dt(ln):un(en)}):navigator.mediaDevices.getUserMedia(mobile.any()?Ht:rn).then(ln=>{jt(ln),ut(ln)}).catch(ln=>{Dt(ln)})};if(mobile.iOS()&&Jt.current)return;if($t===!0||isDesktop||dt||it===!1){if(Jt.current=!0,Xe){ut(Xe);return}mt(!0),un(xt),addEvent({token:Ke,code:"cameraFeedbackDisplayed",payload:{feedback:"Loading..."},module:"ID Capture",screen:`${Je} Camera Capture`})}const hn=document.createElement("canvas");St.current=hn})(),()=>{$t&&(Jt.current=!1,Xe==null||Xe.getTracks().forEach(Mn=>Mn.stop()))}),[$t,Ue,Xe]),React$1.useLayoutEffect(()=>{ft&&(typeof ft=="function"?ft(Mt.current):ft.current=Mt.current)},[ft,Mt]),React$1.useImperativeHandle(ft,()=>({getBase64ScreenShot:Vt,getImageData:Ot,getFullImage:Xt,dataURLtoBlob:Yt,video:Mt.current,stream:vt,getProperSizeCanvas:Et,getCanvas:Lt,getFullCanvas:zt,setIsLoadingCamera:mt}));const Et=(fn,Mn=!0)=>{const un=Math.abs(Mt.current.clientWidth-window.innerWidth),hn=document.createElement("canvas"),en=(Mn?fn.height:fn.videoHeight)/Mt.current.clientHeight,Ht=window.innerWidth,Kt=window.innerHeight;return hn.width=Ht,hn.height=Kt,hn.getContext("2d").drawImage(fn,en*un/2,0,en*Ht,en*Kt,0,0,Ht,Kt),hn},Vt=(fn,Mn,un,hn=!0)=>{const en=Lt(fn,Mn);return(Ze?en:(rn=>{const ln=getMaskPosition(),an=hn?ln.left:0,mn=hn?ln.top:0,yn=hn?ln.width:rn.width,bn=hn?ln.height:rn.height,Cn=document.createElement("canvas");return Cn.width=yn,Cn.height=bn,Cn.getContext("2d").drawImage(rn,an,mn,yn,bn,0,0,yn,bn),Cn})(Et(en))).toDataURL("image/jpeg",un).split(",")[1]},Ot=(fn,Mn)=>{const un=Lt(fn,Mn),hn=un.getContext("2d",{willReadFrequently:!0});return{canvasElement:un,imageElement:un&&hn.getImageData(0,0,un.width,un.height)}},Lt=(fn=1280,Mn=720)=>{if(!Mt.current.videoHeight||!Ct)return null;Ct.width=fn,Ct.height=Mn;const un=Ct.getContext("2d");return un.clearRect(0,0,fn,Mn),un.drawImage(Mt.current,0,0),Ct},zt=(fn=1280,Mn=720)=>{if(!Mt.current.videoHeight)return null;if(mobile.any()){Ct.width=fn,Ct.height=Mn;const un=Ct.getContext("2d");un.clearRect(0,0,fn,Mn),un.drawImage(Mt.current,0,0)}return Ct},Xt=(fn,Mn,un,hn=null)=>{let en;return hn?en=hn:en=Lt(fn,Mn),en.toDataURL("image/jpeg",un).split(",")[1]},Yt=(fn,Mn,un)=>{const en=Lt(fn,Mn).toDataURL("image/jpeg",un),Ht=atob(en.split(",")[1]),Kt=[];for(let rn=0;rn<Ht.length;rn++)Kt.push(Ht.charCodeAt(rn));return new Blob([new Uint8Array(Kt)],{type:Qe})},sn=()=>Mt.current?Mt.current.videoWidth>Mt.current.videoHeight:!1,cn=()=>{Gt(!0),sessionStorage.setItem("cameraPermissionsGranted",String(!0)),addEvent({token:Ke,code:"permissionsAllowedCustom"}),addEvent({token:Ke,code:"cameraPermissionSubmitted",payload:{requestor:"browser",requestorDetails:browser$1.name,permission:"allowed"},module:"ID capture",screen:`${Je} Camera Capture`})},pn=()=>{addEvent({token:Ke,code:"permissionsQuitFlow"}),setTimeout(()=>{window.location.reload()},0)},vn=()=>{addEvent({token:Ke,code:"permissionsDeniedCustom"}),addEvent({token:Ke,code:"cameraPermissionSubmitted",payload:{requestor:"browser",requestorDetails:browser$1.name,permission:"denied"},module:"ID capture",screen:`${Je} Camera Capture`})},Tn=sessionStorage.getItem("cameraPermissionsGranted")==="true",tn=it&&(typeof Ft<"u"&&!Ft&&!$t||typeof $t<"u"&&!$t)&&!isDesktop&&!dt&&!Tn,dn=()=>{!It&&me&&typeof me=="function"&&me(),yt(!0)};return jsxs(React$1.Fragment,{children:[gt&&jsx(AllowCameraUse,{handleAllowCamera:ot}),tn&&jsx(FakePermissionsRequest,{handleDenyPermission:vn,handleCameraPermission:cn,handleQuitOnboarding:pn,type:Je,token:Ke,interviewId:nt}),!bt&&jsx(BrowserNotSupported,{}),Nt&&!tn&&jsx(Loader$1,{message:Ut("webcam.loading"),fullScreen:!0}),jsx(Video$1,{"aria-hidden":"true",autoPlay:!0,className:classNames(ue,{selfie:Ze,horizontal:sn(),desktop:!mobile.any(),assistedOnboarding:rt,"full-height":ct}),playsInline:!0,onPlay:dn,ref:Mt,muted:!0})]})}),captureButton="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2NSIgaGVpZ2h0PSI2NSIgdmlld0JveD0iMCAwIDY1IDY1Ij4KICAgIDxnIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPGc+CiAgICAgICAgICAgIDxnPgogICAgICAgICAgICAgICAgPGcgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTE1NSAtNjQ2KSB0cmFuc2xhdGUoMTU1IDY0NikiPgogICAgICAgICAgICAgICAgICAgIDxjaXJjbGUgY3g9IjMyLjMxOSIgY3k9IjMyLjMxOSIgcj0iMzIuMzE5IiBmaWxsPSIjMjAyNjNEIi8+CiAgICAgICAgICAgICAgICAgICAgPGNpcmNsZSBjeD0iMzIuMzE5IiBjeT0iMzIuMzE5IiByPSIyNS4xMzciIGZpbGw9IiNGRkYiIGZpbGwtb3BhY2l0eT0iLjA5MyIgc3Ryb2tlPSIjRkZGIiBzdHJva2Utd2lkdGg9IjIuMDUyIi8+CiAgICAgICAgICAgICAgICA8L2c+CiAgICAgICAgICAgICAgICA8ZyBmaWxsPSIjRkZGIiBmaWxsLXJ1bGU9Im5vbnplcm8iPgogICAgICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik0xNy4xOTMgMTIuMjRjMCAyLjI5NC0xLjg4IDQuMTYtNC4xOTMgNC4xNi0yLjMxMiAwLTQuMTkyLTEuODY2LTQuMTkyLTQuMTYgMC0yLjI5MyAxLjg4LTQuMTYgNC4xOTItNC4xNiAyLjMxMiAwIDQuMTkzIDEuODY3IDQuMTkzIDQuMTZ6TTI2IDYuMzM0djExLjgxNEMyNiAxOS43MjMgMjQuNzEzIDIxIDIzLjEyNSAyMUgyLjg3NUMxLjI4NyAyMSAwIDE5LjcyMyAwIDE4LjE0OFY2LjMzNEMwIDQuNzYgMS4yODcgMy40ODIgMi44NzUgMy40ODJoMy41MzZ2LS45ODdDNi40MTEgMS4xMTcgNy41MzcgMCA4LjkyNyAwaDguMTQ2YzEuMzkgMCAyLjUxNiAxLjExNyAyLjUxNiAyLjQ5NXYuOTg2aDMuNTM2QzI0LjcxMyAzLjQ4MiAyNiA0Ljc2IDI2IDYuMzM0em0tNi42NSA1LjkwNmMwLTMuNDczLTIuODQ5LTYuMjk4LTYuMzUtNi4yOTgtMy41IDAtNi4zNDkgMi44MjUtNi4zNDkgNi4yOThTOS41IDE4LjU0IDEzIDE4LjU0YzMuNTAxIDAgNi4zNS0yLjgyNiA2LjM1LTYuMjk5eiIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTE1NSAtNjQ2KSB0cmFuc2xhdGUoMTU1IDY0NikgdHJhbnNsYXRlKDE5IDIxKSIvPgogICAgICAgICAgICAgICAgPC9nPgogICAgICAgICAgICA8L2c+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4K",faceFrame$1="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMzYiIGhlaWdodD0iNTE4IiB2aWV3Qm94PSIwIDAgMzM2IDUxOCI+CiAgICA8cGF0aCBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHN0cm9rZT0iI0ZGRiIgc3Ryb2tlLWRhc2hhcnJheT0iNy4xMzk5OTk2NzU3NTA3MzIsMTkuMDM5OTk5Njc1NzUwNzMiIHN0cm9rZS13aWR0aD0iOS4wNDQiIGQ9Ik0xNjggNTEzLjM5MmM3Ni44MyAwIDE2Mi44OTMtMTEzLjkyIDE2Mi44OTMtMjU0LjQ0N1MyODAuMjM2IDQuNDk4IDE2OCA0LjQ5OCA1LjEwNyAxMTguNDE4IDUuMTA3IDI1OC45NDUgOTEuMTcgNTEzLjM5MiAxNjggNTEzLjM5MnoiLz4KPC9zdmc+Cg==",deviceStatsQueue=[];let isReady=!1;function addDeviceStats(ue,me){if(!isReady){deviceStatsQueue.push(me);return}return exports.api.post("/omni/device/stats",me,{headers:{"X-Incode-Hardware-Id":ue}}).catch(()=>{})}function emptyDeviceStatsQueue(ue){isReady=!0,deviceStatsQueue.forEach(me=>{addDeviceStats(ue,me)})}class FaceDetection{constructor(){this.pipelineProfile=null,this.bestFrame=null,this.bestFullImage=null,this.bestLandmarks=null,this.bestTopLeft=null,this.bestSize=null,this.currFrame=null,this.currFullImage=null}formatLandmarks(me,Ue,Qe){const[Ze,Je,Ge,He,Xe,$e,Ke,nt,tt,et]=me;return{rightEyeX:Ze,rightEyeY:Je,leftEyeX:Ge,leftEyeY:He,noseTipX:Xe,noseTipY:$e,rightMouthX:Ke,rightMouthY:nt,mouthX:tt,mouthY:et,x:Ue[0],y:Ue[1],width:Qe[0],height:Qe[1]}}async retrieveInputData(me){const Ue=cloneCanvas(me.getCanvas(me.video.videoWidth,me.video.videoHeight));if(!Ue)return null;const Qe=Ue.width,Ze=Ue.height,Je=me.getBase64ScreenShot(Qe,Ze,1,!1),Ge=me.getFullImage(Qe,Ze,1,Ue);return{imageData:Ue.getContext("2d").getImageData(0,0,Qe,Ze),frameStr:Je,fullFrameStr:Ge}}async initialize(me){const{onNoFace:Ue,onCapturing:Qe,onCapture:Ze,onTooManyFaces:Je,onTooClose:Ge,onCenterFace:He,onFarAway:Xe,onFaceAngle:$e,onDark:Ke,onBlur:nt,onHeadWear:tt,onLenses:et,onEyesClosed:rt,onFaceMask:at,onSwitchToManualCapture:ot,isLensesCheckEnabled:it,isMaskCheckEnabled:st,isClosedEyesCheckEnabled:ct,isHeadWearCheckEnabled:lt,isVideoSelfie:dt,pipelineProfile:ft,autocaptureTimeout:gt}=me;this.pipelineProfile=ft;const ht=this.pipelineProfile.pipelineType;await MlWasmJSApi$1.setFacePositionConstraints(ht,ft.parameters.frameMinX,ft.parameters.frameMinY,ft.parameters.frameMaxX,ft.parameters.frameMaxY),await MlWasmJSApi$1.setFaceDetectionThresholds(ht,ft.parameters.brightnessThreshold,ft.parameters.blurrinessThreshold,ft.parameters.tiltRotationAngleThreshold,ft.parameters.minMagicCropSize,gt),await MlWasmJSApi$1.setFaceAttributesEnabled(ht,it,st,ct,lt),await MlWasmJSApi$1.setFaceAttributesThresholds(ht,ft.parameters.headwearThreshold,ft.parameters.lensesThreshold,ft.parameters.closedEyesThreshold,ft.parameters.maskThreshold),await MlWasmJSApi$1.setFaceDetectionMode(ht,dt);const vt=()=>{Ze(this.bestFrame,this.bestFullImage,this.formatLandmarks(this.bestLandmarks,this.bestTopLeft,this.bestSize))},Rt=bt=>{this.bestFrame=this.currFrame,this.bestFullImage=this.currFullImage;const At=bt.rect;this.bestTopLeft=[At.x,At.y];const Nt=[At.x+At.width,At.y+At.height],mt=this.bestTopLeft,It=Nt;this.bestSize=[It[0]-mt[0],It[1]-mt[1]],this.bestLandmarks=[bt.rightEye.x,bt.rightEye.y,bt.leftEye.x,bt.leftEye.y,bt.noseTip.x,bt.noseTip.y,bt.rightMouthCorner.x,bt.rightMouthCorner.y,bt.leftMouthCorner.x,bt.leftMouthCorner.y]};await MlWasmJSApi$1.setFaceDetectionCallbacks(ht,Xe,Ge,Je,Ue,vt,Qe,He,Ke,nt,$e,Rt,et,at,rt,tt,ot)}async detect(me){try{const Ue=await this.retrieveInputData(me);if(!Ue)return;this.currFrame=Ue.frameStr,this.currFullImage=Ue.fullFrameStr,await MlWasmJSApi$1.allocateImageBuffers(Ue.imageData.width,Ue.imageData.height),await MlWasmJSApi$1.process(Ue.imageData,PipelineType.SelfieFaceDetectionPipeline)}catch(Ue){console.error(`Exception: ${Ue}`)}}}const state={token:null};var PipelineProfileType=(ue=>(ue[ue.IdCaptureBrazilian=0]="IdCaptureBrazilian",ue[ue.IdCaptureVisas=1]="IdCaptureVisas",ue[ue.IdVideoSelfieBrazilian=2]="IdVideoSelfieBrazilian",ue[ue.IdVideoSelfieVisas=3]="IdVideoSelfieVisas",ue[ue.SelfieFaceDetection=4]="SelfieFaceDetection",ue))(PipelineProfileType||{});class PipelineProfile{constructor(me,Ue,Qe,Ze,Je=null,Ge=""){this.pipelineType=me,this.profileType=Ue,this.modelNames=Qe,this.parameters=Ze,this.paramsConfigurator=Je,this.description=Ge}reconfigureParams(me=null,Ue=null){if(this.paramsConfigurator==null)throw new Error("PipelineProfile does not have a paramsConfigurator");this.paramsConfigurator(this.parameters,this.pipelineType,me,Ue)}}function IdCaptureParamsConfigurator(ue,me,Ue,Qe){Object.assign(ue,{areaDown:Qe||Ue?55e3:25e3,areaUp:Qe||Ue?75e3:55e3,areaIOSPassportUp:3e4,areaIOSPassportDown:2e4,widthIOSUp:me==PipelineType.IdCapturePipeline?125:180,widthIOSDown:me==PipelineType.IdCapturePipeline?85:150,widthDown:Qe||Ue?185:135,widthUp:Qe||Ue?255:205})}const SelfieFaceDetectionPipelineParams={frameMinX:0,frameMinY:0,frameMaxX:1,frameMaxY:1,brightnessThreshold:50,blurrinessThreshold:50,tiltRotationAngleThreshold:7,minMagicCropSize:200,headwearThreshold:.95,lensesThreshold:.95,closedEyesThreshold:.9,maskThreshold:.5},pipelineProfiles=[new PipelineProfile(PipelineType.IdCapturePipeline,PipelineProfileType.IdCaptureBrazilian,["brazilian_mobile_025_ep199_fp16.ortmodelv2"],{glareThreshold:.2,classificationThreshold:.98,sharpnessThreshold:.3,sharpnessChangeThreshold:.3},IdCaptureParamsConfigurator,"Id Capture Profile with brazilian_mobile model"),new PipelineProfile(PipelineType.IdCapturePipeline,PipelineProfileType.IdCaptureVisas,["visas_mobile_025_best_v1_03_fp16.ortmodelv2"],{glareThreshold:.3,classificationThreshold:.98,sharpnessThreshold:.2,sharpnessChangeThreshold:.2},IdCaptureParamsConfigurator,"Id Capture Profile with visas_mobile model"),new PipelineProfile(PipelineType.IdVideoSelfiePipeline,PipelineProfileType.IdVideoSelfieBrazilian,["brazilian_mobile_025_ep199_fp16.ortmodelv2"],{glareThreshold:.2,classificationThreshold:.9,sharpnessThreshold:.3,sharpnessChangeThreshold:.3},IdCaptureParamsConfigurator,"Id Videoselfie profile with brazilian_mobile model"),new PipelineProfile(PipelineType.IdVideoSelfiePipeline,PipelineProfileType.IdVideoSelfieVisas,["visas_mobile_025_best_v1_03_fp16.ortmodelv2"],{glareThreshold:.3,classificationThreshold:.9,sharpnessThreshold:.2,sharpnessChangeThreshold:.2},IdCaptureParamsConfigurator,"Id Videoselfie Profile with visas_mobile model"),new PipelineProfile(PipelineType.SelfieFaceDetectionPipeline,PipelineProfileType.SelfieFaceDetection,["selfie_bf_angles_192x192_opset9_fp16.ortmodelv2","bf_attrib_31b8f9d92fb345c2b4bbdd222792562c_0_fp16.ortmodelv2"],SelfieFaceDetectionPipelineParams,null,"Selfie face detection profile")];function getProfile(ue){const me=pipelineProfiles.find(Ue=>Ue.profileType===ue);if(!me)throw new Error(`Profile not found for type: ${ue}`);return me}const probabilityThreshold=.9,wasmVersion="v1.7.6",brazilianPipelineBundle=[PipelineProfileType.IdCaptureBrazilian,PipelineProfileType.IdVideoSelfieBrazilian,PipelineProfileType.SelfieFaceDetection],visasPipelineBundle=[PipelineProfileType.IdCaptureVisas,PipelineProfileType.IdVideoSelfieVisas,PipelineProfileType.SelfieFaceDetection],PipelinesBundle=new Map([["brazilianPipelineBundle",brazilianPipelineBundle],["visasPipelineBundle",visasPipelineBundle]]);function switchBundle(){return Math.random()<probabilityThreshold?"brazilianPipelineBundle":"visasPipelineBundle"}function getInitializationParams(ue){const Ue=ue?switchBundle():"brazilianPipelineBundle",Qe="https://d3vv997wtl2myz.cloudfront.net/webcamera/onnx-backend-wasm",Ze=`${Qe}/${wasmVersion}/webLib.wasm`,Je=`${Qe}/${wasmVersion}/webLibSimd.wasm`,Ge=`${Qe}/${wasmVersion}/webLib.js`,He=`${Qe}/${wasmVersion}/versions.json`;let Xe=new Map,$e=new Map;for(const Ke of PipelinesBundle.get(Ue)){const nt=getProfile(Ke);if(!nt)throw new Error(`Profile not found for type: ${Ke}`);const tt=nt.modelNames;let et=[];for(const rt of tt)et.push(`${Qe}/${wasmVersion}/models/${rt}`);Xe.set(nt.pipelineType,et),$e.set(nt.pipelineType,nt)}return{wasmModulePath:Ze,wasmSimdModulePath:Je,glueCodePath:Ge,versionsFilePath:He,pipelineModels:Xe,enableSIMD:!0,bundle:Ue,profiles:$e}}class MotionStatusCheck{constructor(me,Ue,Qe,Ze,Je,Ge,He,Xe,$e,Ke,nt,tt){this.isRunning_=!1,this.acl_=null,this.gyro_=null,this.permission_=!0,this.minNumberOfFrames_=3,this.maxFrequency_=60,this.emptyParams={meanX:0,meanY:0,meanZ:0,m2X:0,m2Y:0,m2Z:0,cumulativeAbsErrorX:0,cumulativeAbsErrorY:0,cumulativeAbsErrorZ:0,ptsNum:0},this.paramsAcc_={...this.emptyParams},this.paramsGyro_={...this.emptyParams},this.paramsAccGrOld_={...this.emptyParams},this.paramsAccOld_={...this.emptyParams},this.paramsGyroscopeOld_={...this.emptyParams},this.paramsOrientationOld_={...this.emptyParams},this.waitForClick=()=>new Promise(et=>{document.addEventListener("click",async()=>{const rt=await this.requestMotionPermission();et(rt)},{once:!0})}),this.deviceMotionListener=et=>{if(et.accelerationIncludingGravity){const rt={x:et.accelerationIncludingGravity.x,y:et.accelerationIncludingGravity.y,z:et.accelerationIncludingGravity.z};this.checkFields(rt)&&(this.paramsAccGrOld_.ptsNum+=1,this.updateParams(this.paramsAccGrOld_,rt))}if(et.acceleration){const rt={x:et.acceleration.x,y:et.acceleration.y,z:et.acceleration.z};this.checkFields(rt)&&(this.paramsAccOld_.ptsNum+=1,this.updateParams(this.paramsAccOld_,rt))}if(et.rotationRate){const rt={x:et.rotationRate.alpha,y:et.rotationRate.beta,z:et.rotationRate.gamma};this.checkFields(rt)&&(this.paramsGyroscopeOld_.ptsNum+=1,this.updateParams(this.paramsGyroscopeOld_,rt))}},this.deviceOrientationListener=et=>{const rt={x:et.alpha,y:et.beta,z:et.gamma};this.checkFields(rt)&&(this.paramsOrientationOld_.ptsNum+=1,this.updateParams(this.paramsOrientationOld_,rt))},this.accThreshold_=me,this.gyroThreshold_=Ue,this.accGrOldThreshold_=Qe,this.accOldThreshold_=Ze,this.gyroscopeOldThreshold_=Je,this.orientationOldThreshold_=Ge,this.maeAccThreshold_=He,this.maeGyroThreshold_=Xe,this.maeAccGrOldThreshold_=$e,this.maeAccOldThreshold_=Ke,this.maeGyroscopeOldThreshold_=nt,this.maeOrientationOldThreshold_=tt}async requestMotionPermission(){DeviceMotionEvent&&typeof DeviceMotionEvent.requestPermission=="function"&&DeviceMotionEvent.requestPermission().then(me=>{me!=="granted"&&(this.permission_=!1)}).catch(console.error)}initializeAccelerometer(){if("Accelerometer"in window)try{this.acl_=new window.Accelerometer({frequency:this.maxFrequency_}),this.acl_.addEventListener("reading",()=>this.updateAcc())}catch{}}initializeGyroscope(){if("Gyroscope"in window)try{this.gyro_=new window.Gyroscope({frequency:this.maxFrequency_}),this.gyro_.addEventListener("reading",()=>this.updateGyro())}catch{}}async start(){this.run()}run(){if(!(this.isRunning_||!this.permission_)){try{this.initializeAccelerometer(),this.acl_.start()}catch{}try{this.initializeGyroscope(),this.gyro_.start()}catch{}window.addEventListener("devicemotion",this.deviceMotionListener),window.addEventListener("deviceorientation",this.deviceOrientationListener),this.isRunning_=!0}}stop(){this.isRunning_=!1,this.acl_&&this.acl_.stop(),this.gyro_&&this.gyro_.stop(),window.removeEventListener("devicemotion",this.deviceMotionListener),window.removeEventListener("deviceorientation",this.deviceOrientationListener),this.paramsAcc_={...this.emptyParams},this.paramsGyro_={...this.emptyParams},this.paramsAccGrOld_={...this.emptyParams},this.paramsAccOld_={...this.emptyParams},this.paramsGyroscopeOld_={...this.emptyParams},this.paramsOrientationOld_={...this.emptyParams}}updateAcc(){if(!(!this.isRunning_||!this.acl_)&&(this.paramsAcc_.ptsNum+=1,this.acl_)){const me={x:this.acl_.x,y:this.acl_.y,z:this.acl_.z};this.checkFields(me)&&this.updateParams(this.paramsAcc_,me)}}updateGyro(){if(!(!this.isRunning_||!this.gyro_)&&(this.paramsGyro_.ptsNum+=1,this.gyro_)){const me={x:this.gyro_.x,y:this.gyro_.y,z:this.gyro_.z};this.checkFields(me)&&this.updateParams(this.paramsGyro_,me)}}check(){if(!this.permission_)return"UNCLEAR";const me=this.checkStability();return me===null?"UNCLEAR":me?"FAIL":"PASS"}checkStability(){if(!this.isRunning_)return null;const Ue=[this.gyro_?this.isBelowStdThreshold(this.paramsGyro_,this.gyroThreshold_):null,this.acl_?this.isBelowStdThreshold(this.paramsAcc_,this.accThreshold_):null,this.isBelowStdThreshold(this.paramsAccGrOld_,this.accGrOldThreshold_),this.isBelowStdThreshold(this.paramsAccOld_,this.accOldThreshold_),this.isBelowStdThreshold(this.paramsGyroscopeOld_,this.gyroscopeOldThreshold_),this.isBelowStdThreshold(this.paramsOrientationOld_,this.orientationOldThreshold_)].filter(He=>He!==null),Qe=Ue.length>0?Ue.every(He=>He):null,Je=[this.gyro_?this.isBelowMaeThreshold(this.paramsGyro_,this.maeGyroThreshold_):null,this.acl_?this.isBelowMaeThreshold(this.paramsAcc_,this.maeAccThreshold_):null,this.isBelowMaeThreshold(this.paramsAccGrOld_,this.maeAccGrOldThreshold_),this.isBelowMaeThreshold(this.paramsAccOld_,this.maeAccOldThreshold_),this.isBelowMaeThreshold(this.paramsGyroscopeOld_,this.maeGyroscopeOldThreshold_),this.isBelowMaeThreshold(this.paramsOrientationOld_,this.maeOrientationOldThreshold_)].filter(He=>He!==null),Ge=Je.length>0?Je.every(He=>He):null;return Qe===null?Ge===null?null:Ge:Ge!==null?Qe&&Ge:Qe}updateParams(me,Ue){const Qe=Ue.x-me.meanX,Ze=Ue.y-me.meanY,Je=Ue.z-me.meanZ;me.meanX+=Qe/me.ptsNum,me.meanY+=Ze/me.ptsNum,me.meanZ+=Je/me.ptsNum,me.m2X+=Qe*(Ue.x-me.meanX),me.m2Y+=Ze*(Ue.y-me.meanY),me.m2Z+=Je*(Ue.z-me.meanZ),me.cumulativeAbsErrorX+=Math.abs(Ue.x-me.meanX),me.cumulativeAbsErrorY+=Math.abs(Ue.y-me.meanY),me.cumulativeAbsErrorZ+=Math.abs(Ue.z-me.meanZ)}calculateStd(me){const Ue={x:me.m2X/me.ptsNum,y:me.m2Y/me.ptsNum,z:me.m2Z/me.ptsNum};return{x:Math.sqrt(Ue.x),y:Math.sqrt(Ue.y),z:Math.sqrt(Ue.z)}}calculateMae(me){return{x:me.cumulativeAbsErrorX/me.ptsNum,y:me.cumulativeAbsErrorY/me.ptsNum,z:me.cumulativeAbsErrorZ/me.ptsNum}}checkFields(me){return me.x!==null&&me.y!==null&&me.z!==null}isBelowStdThreshold(me,Ue){if(me.ptsNum<this.minNumberOfFrames_)return null;const Qe=this.calculateStd(me);return Qe.x<Ue&&Qe.y<Ue&&Qe.z<Ue}isBelowMaeThreshold(me,Ue){if(me.ptsNum<this.minNumberOfFrames_)return null;const Qe=this.calculateMae(me);return Qe.x<Ue&&Qe.y<Ue&&Qe.z<Ue}}class OnboardingAnalytics{constructor(){this.motionStatusCheck=null,this.estimatedPerformance=null,this.analysisStatus="",this.motionStatus="",this.pipelineLogs="",this.pipelinesBundle=null,this.motionStatusCheck=new MotionStatusCheck(.3,.3,.3,.3,10,10,.3,.3,.3,.3,10,10)}static getInstance(){return OnboardingAnalytics.instance||(OnboardingAnalytics.instance=new OnboardingAnalytics),OnboardingAnalytics.instance}setPipelinesBundle(me){this.pipelinesBundle=me}getPipelineLogs(){return this.pipelineLogs}getMotionStatus(){return this.motionStatus}getAnalysisStatus(){return this.analysisStatus}async analyzeFrame(me){const Ue=await base64ToImageData(me);await MlWasmJSApi$1.analyzeFrame(Ue),this.updatePipelineStats()}async startOnboardingCheck(){this.motionStatusCheck.start()}estimatePerformance(){if(this.estimatedPerformance)return this.estimatedPerformance;this.estimatedPerformance=MlWasmJSApi$1.estimatePerformance()}updatePipelineStats(){if(MlWasmJSApi$1.isInitialized())try{const me=MlWasmJSApi$1.getPipelineState();if(me!==""){const Ue=JSON.parse(me);this.analysisStatus=Ue.statsAnalysisStatus,Ue.pipelinesBundle=this.pipelinesBundle?this.pipelinesBundle:"unknown",Ue.estimatedPerformance=this.estimatedPerformance,this.pipelineLogs=JSON.stringify(Ue),this.motionStatus===""&&(this.motionStatus=this.motionStatusCheck.check())}}catch(me){console.error(`Exception: ${me}`)}}}const OnboardingAnalytics$1=OnboardingAnalytics.getInstance();class DetectionSetup{constructor(){this.setupDetectPromise=null,this.isSetupDetect=!1,this.pipelinesBundle=null,this.profiles=null}static getInstance(){return DetectionSetup.instance||(DetectionSetup.instance=new DetectionSetup),DetectionSetup.instance}setIsHighPerformanceVariable(){if(!mobile.iOS())return;if(new URLSearchParams(window.location.search).get("smallFrame")==="true"){localStorage.setItem("isHighPerformance","true");return}localStorage.setItem("isHighPerformance",String(window.outerHeight===852&&window.outerWidth===393||window.outerHeight===932&&window.outerWidth===430||window.innerHeight===631&&window.innerWidth===375))}async setupDetect(){return this.setupDetectPromise?this.setupDetectPromise:(this.setupDetectPromise=this._runSetupDetect(),this.setupDetectPromise)}getPipelinesBundle(){return this.pipelinesBundle}getProfile(me){var Ue;return((Ue=this.profiles)==null?void 0:Ue.get(me))??null}async warmup(){for(;!MlWasmJSApi$1.isInitialized();)await new Promise(me=>setTimeout(me,100))}async _runSetupDetect(){var Qe,Ze;if(this.isSetupDetect)return;addEvent({token:(Qe=state.token)==null?void 0:Qe.token,code:"modelLoadStart"}),this.setIsHighPerformanceVariable();const me=getInitializationParams(!1);for(this.pipelinesBundle=me.bundle,this.profiles=me.profiles,OnboardingAnalytics$1.setPipelinesBundle(this.pipelinesBundle),OnboardingAnalytics$1.startOnboardingCheck(),await MlWasmJSApi$1.initialize(me.wasmModulePath,me.wasmSimdModulePath,me.glueCodePath,me.enableSIMD,me.versionsFilePath,me.pipelineModels);!MlWasmJSApi$1.isInitialized();)await new Promise(Je=>setTimeout(Je,100));OnboardingAnalytics$1.estimatePerformance(),await MlWasmJSApi$1.initializePipelines();const Ue={}.VITE_WASM_PRODUCTION_MODE==="true";try{await MlWasmJSApi$1.setProductionMode(Ue)}catch(Je){console.error(`Exception: ${Je}`)}this.isSetupDetect=!0,addEvent({token:(Ze=state.token)==null?void 0:Ze.token,code:"modelLoadEnd",payload:{loadSuccessful:!0}})}}const DetectionSetup$1=DetectionSetup.getInstance();function useSelfie({timeout:ue=4e4,onLog:me=emptyFunc,handleCapture:Ue,numberOfTries:Qe=3,handleNoAttempsLeft:Ze=emptyFunc,webcam:Je,token:Ge,isDetecting:He,onSwitchManualCapture:Xe=emptyFunc,onManualCaptureSelfie:$e=emptyFunc}){const Ke=React$1.useRef(0),nt=React$1.useRef(!1),tt=React$1.useRef(!1),[et,rt]=React$1.useState(""),[at,ot]=React$1.useState("idle"),[it,st]=React$1.useState(!1),[ct,lt]=React$1.useState(!1),dt=React$1.useRef(),ft=React$1.useRef(Xe),gt=React$1.useRef(null),{t:ht}=useTranslation(),vt=async(Yt,sn,cn)=>{tt.current||(He.current=!1,await sleep(300),tt.current=!0,ot("uploading"),Ue(Yt,sn,cn),await sleep(2e3),bt().catch(console.log))},Rt=500;async function bt(){if(mobile.isDesktop())return;const Yt=document.querySelector("video"),sn=Yt.srcObject;await zoomCameraToTheMax(sn),await sleep(Rt);const cn=Yt.videoWidth,pn=Yt.videoHeight,vn=await captureImageFromStream(sn,cn,pn);await MlWasmJSApi$1.allocateImageBuffers(cn,pn),(await MlWasmJSApi$1.runSelfieCapture(vn)).faces.size()>0&&addDeviceStats(Ge,{virtualCameraDetected:!0})}const At=()=>{var sn;const Yt=getLogObject("timeout",{message:"No face found"});(sn=ft.current)==null||sn.call(ft),me(Yt),lt(!0)},Nt=()=>{nt.current||(me(getLogObject("tooFar",{message:ht("notifications.moveCloser")})),rt(ht("notifications.moveCloser")))},mt=()=>{nt.current||(me(getLogObject("tooManyFaces",{message:ht("notifications.tooManyFaces")})),rt(ht("notifications.tooManyFaces")))},It=()=>{nt.current||(me(getLogObject("centerFace",{message:ht("notifications.centerFace")})),rt(ht("notifications.centerFace")))},yt=()=>{tt.current||nt.current||(ot("capturing"),me(getLogObject("dontMove",{message:ht("notifications.dontMove")})),rt(ht("notifications.getReady")),nt.current=!0)},Mt=()=>{nt.current||tt.current||rt(ht("notifications.moveAway"))},St=()=>{nt.current||tt.current||rt(ht("notifications.onDark"))},xt=()=>{nt.current||tt.current||rt(ht("notifications.onBlur"))},Ut=()=>{nt.current||tt.current||rt(ht("notifications.onFaceAngle"))},Ft=()=>{nt.current||tt.current||rt(ht("notifications.removeHeadwear"))},wt=()=>{nt.current||tt.current||rt(ht("notifications.removeLenses"))},Ct=()=>{nt.current||tt.current||rt(ht("notifications.openEyes"))},Zt=()=>{nt.current||tt.current||rt(ht("notifications.removeMask"))},Jt=async()=>{gt.current=new FaceDetection,await gt.current.initialize({onNoFace:emptyFunc,onCaptureFace:emptyFunc,onTooManyFaces:mt,onTooClose:Mt,onCenterFace:It,onFarAway:Nt,onCapturing:yt,onBlur:xt,onDark:St,onFaceAngle:Ut,onHeadWear:Ft,onLenses:wt,onEyesClosed:Ct,onFaceMask:Zt,onSwitchToManualCapture:At,onCapture:vt,isLensesCheckEnabled:!1,isMaskCheckEnabled:!1,isClosedEyesCheckEnabled:!1,isHeadWearCheckEnabled:!1,isVideoSelfie:!1,pipelineProfile:DetectionSetup$1.getProfile(PipelineType.SelfieFaceDetectionPipeline),autocaptureTimeout:ue})};React$1.useEffect(()=>{ft.current=Xe},[Xe]),React$1.useEffect(()=>{lt(!1)},[]);const Qt=async({response:Yt,livenessPassed:sn,imageBase64:cn})=>{if(Ke.current=Ke.current+1,Qe!==-1&&Ke.current>=Qe)return Ze({response:Yt,livenessPassed:sn,imageBase64:cn});rt(""),ot("idle"),nt.current=!1,tt.current=!1,zoomCameraToTheMin(document.querySelector("video").srcObject),await sleep(1e3)},$t=Yt=>{const sn=Yt.errorMessage||Yt.message||Yt.reason,{status:cn}=Yt;if(zoomCameraToTheMin(document.querySelector("video").srcObject),cn===3004){rt(ht("notifications.unableToCrop")),me(getLogObject("unableToCrop",{message:`${ht("notifications.unableToCrop")}`}));return}switch(sn){case"No faces found on the image":rt(ht("notifications.face")),me(getLogObject("faceNotDetected",{message:`${ht("notifications.face")}`}));break;case"BadRequestException: More than one face detected.":rt(ht("notifications.multiple")),me(getLogObject("multipleFacesDetected",{message:`${ht("notifications.multiple")}`}));break;case"Cropping area goes off the image.":rt(ht("notifications.crop")),me(getLogObject("cropTooSmall",{message:`${ht("notifications.crop")}`}));break;case"Image in portrait orientation is expected.":rt(ht("notifications.portrait")),me(getLogObject("imageNotPortrait",{message:`${ht("notifications.portrait")}`}));break;default:me(getLogObject("InternalServerError",{message:`${ht("notifications.error")}`})),rt(ht("notifications.error"));break}},Gt=React$1.useCallback(()=>{const Yt=async()=>{if(!He.current){await sleep(1e3);return}gt.current||await Jt();try{await MlWasmJSApi$1.handleDetectionCallAndUpdateState(PipelineType.SelfieFaceDetectionPipeline),await gt.current.detect(Je.current)}catch(sn){console.error(sn)}requestAnimationFrame(Yt)};He.current||(He.current=!0,requestAnimationFrame(Yt))},[me,Jt]),Pt=React$1.useCallback(async()=>{st(!0),await sleep(4e3),Gt()},[Gt]);function jt(){$e();const Yt=Je.current.getBase64ScreenShot(Je.current.video.videoWidth,Je.current.video.videoHeight,1,!1),sn=Je.current.getFullImage(Je.current.video.videoWidth,Je.current.video.videoHeight,1);vt(Yt,sn,null)}const Dt=at==="capturing",ut=at==="uploading",Et=at==="success",Vt=at==="error",Ot=Dt||ut,Lt=ut||Et||Vt;return{notificationMessage:et,mode:at,capturing:nt,cameraReady:it,showManualCapture:ct,handleFaceAutoCapture:vt,setMode:ot,resetLoading:Qt,setNotificationMessage:rt,handleError:$t,autoDetectFace:Gt,startAutoDetect:Pt,handleManualCapture:jt,isCapturing:Dt,isUploading:ut,isSuccess:Et,isError:Vt,isLoading:Ot,hideCamera:Lt,showBorders:it&&(at==="idle"||Vt),shouldShowManualCapture:ct&&!Lt,selfieTimeoutRef:dt}}async function sendMfa({verificationCode:ue,transactionId:me}){return exports.api.post("/omni/oneToN/mfa",{verificationCode:ue,transactionId:me}).then(Ue=>Ue.data).catch(Ue=>{var Qe;return Promise.reject((Qe=Ue==null?void 0:Ue.response)==null?void 0:Qe.data)})}const ErrorContainer$1=styled.div`
1400
1400
  text-align: center;
1401
1401
  margin-top: 10px;
1402
1402
  `,ErrorSpan=styled.span`
@@ -2557,7 +2557,7 @@ newPrivacyConsent.text4
2557
2557
  `).filter(ot=>!!ot.trim());return jsxs(ConsentWrapper$1,{role:"region","aria-live":"assertive",className:`
2558
2558
  ${me.default?"IncodeDefaultConsent":"IncodeCustomConsent"}
2559
2559
  `,children:[jsx(ConsentTitle,{tabIndex:0,children:rt}),at.map((ot,it)=>jsx(ConsentParagraph,{tabIndex:0,children:me.default?jsx(Markdown,{disallowedElements:disallowedMarkdownElements,children:Ge(ot)}):jsx(Markdown,{disallowedElements:disallowedMarkdownElements,children:ot})},it)),jsx(AcceptCheck$2,{consentChecked:He,setConsentChecked:Xe,text:tt,id:"one"}),Ze?jsx(AcceptCheck$2,{consentChecked:$e,setConsentChecked:Ke,text:Ge("privacyCheck.aeromexico"),id:"two"}):null,jsx("div",{children:jsx(Button$9,{tabIndex:0,"aria-disabled":et,disabled:et,onClick:nt,children:Ge("privacyConsent.button.continue")})})]})}function PrivacyConsent({session:ue,title:me,text:Ue,goNext:Qe,isAeroMexicoClient:Ze,customCheck:Je}){const{t:Ge}=useTranslation(),[He,Xe]=React$1.useState(null);React$1.useEffect(()=>{Object.hasOwn||(Object.hasOwn=(nt,tt)=>Object.prototype.hasOwnProperty.call(nt,tt))},[]);const $e=nt=>{const tt=nt.split(`
2560
- `);return tt.length===1?tt.join(" "):tt.filter(et=>!!et.trim()).map(et=>Ge(et)).join(" ")},Ke=({title:nt,content:tt,isDefault:et})=>{addConsent({title:`${et?Ge(nt):nt}`,content:et?$e(tt):tt,status:!0,session:ue})};return React$1.useEffect(()=>{if(me||Ue){Xe({title:me||defaultPrivacyConsent.title,text:Ue||defaultPrivacyConsent.text,consentType:defaultPrivacyConsent.consentType,default:!Ue});return}getPrivacyConsentData({session:ue,type:"PRIVACY"}).then(({consents:nt})=>{const tt=nt.find(({consentType:et})=>et==="PRIVACY");tt!=null&&tt.text?Xe({...tt,title:(tt==null?void 0:tt.title.trim())||defaultPrivacyConsent.title,text:tt.text.trim()||defaultPrivacyConsent.text,default:!(tt!=null&&tt.text)}):Xe(defaultPrivacyConsent)}).catch(()=>{Xe(defaultPrivacyConsent)})},[ue,me,Ue]),He?jsx(NormalPrivacyConsent,{consent:He,goNext:Qe,addPrivacyConsent:Ke,session:ue,isAeroMexicoClient:Ze,customCheck:Je}):null}function renderUserConsent(ue,{session:me,onSuccess:Ue,title:Qe,text:Ze,isAeroMexicoClient:Je=!1,customCheck:Ge=null}){const He=createRoot$1(ue),Xe=handleUnmountRoot(Ue,He,ue);customRender(jsx(App$1,{token:me.token,children:jsx(PrivacyConsent,{goNext:Xe,session:me,title:Qe,text:Ze,isAeroMexicoClient:Je,customCheck:Ge})}),ue,He)}const version="1.71.0-20240430151632.0";function r(ue){for(var me="",Ue=0;Ue<ue.length;++Ue)if(Ue>0){var Qe=ue[Ue].toLowerCase();Qe!==ue[Ue]?me+=" ".concat(Qe):me+=ue[Ue]}else me+=ue[Ue].toUpperCase();return me}function o(ue,me){return function(Ue,Qe){return Object.prototype.hasOwnProperty.call(Ue,Qe)}(ue,me)?ue[me]:void 0}var i$1={default:"endpoint"},u={default:"tlsEndpoint"},a="Client timeout",R="Network connection error",c="Network request aborted",s="Response cannot be parsed",E="Blocked by CSP",f="The endpoint parameter is not a valid URL",d=r("WrongRegion"),l=r("SubscriptionNotActive"),_=r("UnsupportedVersion"),p=r("InstallationMethodRestricted"),v=r("HostnameRestricted"),O=r("IntegrationFailed"),I="API key required",h="API key not found",N="API key expired",T="Request cannot be parsed",m="Request failed",w="Request failed to process",A="Too many requests, rate limit exceeded",P="Not available for this origin",y="Not available with restricted header",D=I,S=h,L=N,U="3.8.6",b="9319";function g(ue,me){var Ue=[];return function(Qe,Ze){var Je=5,Ge=(tt=Qe,et=__spreadArray$1([],tt,!0),{current:function(){return et[0]},postpone:function(){var at=et.shift();at!==void 0&&et.push(at)},exclude:function(){et.shift()}}),He=($e=100,Ke=3e3,nt=0,function(){return Math.random()*Math.min(Ke,$e*Math.pow(2,nt++))}),Xe=Ge.current(),$e,Ke,nt,tt,et;if(Xe===void 0)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var rt=function(at,ot){return Ze(at).catch(function(it){if(ot+1>=Je)throw it;(function(lt){if(!(lt instanceof Error))return!1;var dt=lt.message;return dt===E||dt===b})(it)?Ge.exclude():Ge.postpone();var st,ct=Ge.current();if(ct===void 0)throw it;return(st=He(),new Promise(function(lt){return setTimeout(lt,st)})).then(function(){return rt(ct,ot+1)})})};return rt(Xe,0)}(ue,function(Qe){var Ze=new Date,Je=function(He){return Ue.push({url:Qe,startedAt:Ze,finishedAt:new Date,error:He})},Ge=me(Qe);return Ge.then(function(){return Je()},Je),Ge}).then(function(Qe){return[Qe,Ue]})}var C="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",K=C,M="Failed to load the JS script of the agent";function B(ue){var me;ue.scriptUrlPattern;var Ue=ue.token,Qe=ue.apiKey,Ze=Qe===void 0?Ue:Qe,Je=__rest$1(ue,["scriptUrlPattern","token","apiKey"]),Ge=(me=o(ue,"scriptUrlPattern"))!==null&&me!==void 0?me:C,He=function(){var Ke=[],nt=function(){Ke.push({time:new Date,state:document.visibilityState})},tt=function(et,rt,at,ot){return et.addEventListener(rt,at,ot),function(){return et.removeEventListener(rt,at,ot)}}(document,"visibilitychange",nt);return nt(),[Ke,tt]}(),Xe=He[0],$e=He[1];return Promise.resolve().then(function(){if(!Ze||typeof Ze!="string")throw new Error(I);var Ke=function(nt,tt){return(Array.isArray(nt)?nt:[nt]).map(function(et){return function(rt,at){var ot=encodeURIComponent;return rt.replace(/<[^<>]+>/g,function(it){return it==="<version>"?"3":it==="<apiKey>"?ot(at):it==="<loaderVersion>"?ot(U):it})}(String(et),tt)})}(Ge,Ze);return g(Ke,F)}).catch(function(Ke){throw $e(),function(nt){return nt instanceof Error&&nt.message===b?new Error(M):nt}(Ke)}).then(function(Ke){var nt=Ke[0],tt=Ke[1];return $e(),nt.load(__assign$2(__assign$2({},Je),{ldi:{attempts:tt,visibilityStates:Xe}}))})}function F(ue){return function(me,Ue,Qe,Ze){var Je,Ge=document,He="securitypolicyviolation",Xe=function(Ke){var nt=new URL(me,location.href),tt=Ke.blockedURI;tt!==nt.href&&tt!==nt.protocol.slice(0,-1)&&tt!==nt.origin||(Je=Ke,$e())};Ge.addEventListener(He,Xe);var $e=function(){return Ge.removeEventListener(He,Xe)};return Ze==null||Ze.then($e,$e),Promise.resolve().then(Ue).then(function(Ke){return $e(),Ke},function(Ke){return new Promise(function(nt){return setTimeout(nt)}).then(function(){if($e(),Je)return Qe(Je);throw Ke})})}(ue,function(){return function(me){return new Promise(function(Ue,Qe){var Ze=document.createElement("script"),Je=function(){var He;return(He=Ze.parentNode)===null||He===void 0?void 0:He.removeChild(Ze)},Ge=document.head||document.getElementsByTagName("head")[0];Ze.onload=function(){Je(),Ue()},Ze.onerror=function(){Je(),Qe(new Error(M))},Ze.async=!0,Ze.src=me,Ge.appendChild(Ze)})}(ue)},function(){throw new Error(E)}).then(V)}function V(){var ue=window,me="__fpjs_p_l_b",Ue=ue[me];if(function(Qe,Ze){var Je,Ge=(Je=Object.getOwnPropertyDescriptor)===null||Je===void 0?void 0:Je.call(Object,Qe,Ze);Ge!=null&&Ge.configurable?delete Qe[Ze]:Ge&&!Ge.writable||(Qe[Ze]=void 0)}(ue,me),typeof(Ue==null?void 0:Ue.load)!="function")throw new Error(b);return Ue}var k={load:B,defaultScriptUrlPattern:K,ERROR_SCRIPT_LOAD_FAIL:M,ERROR_API_KEY_EXPIRED:N,ERROR_API_KEY_INVALID:h,ERROR_API_KEY_MISSING:I,ERROR_BAD_REQUEST_FORMAT:T,ERROR_BAD_RESPONSE_FORMAT:s,ERROR_CLIENT_TIMEOUT:a,ERROR_CSP_BLOCK:E,ERROR_FORBIDDEN_ENDPOINT:v,ERROR_FORBIDDEN_HEADER:y,ERROR_FORBIDDEN_ORIGIN:P,ERROR_GENERAL_SERVER_FAILURE:m,ERROR_INSTALLATION_METHOD_RESTRICTED:p,ERROR_INTEGRATION_FAILURE:O,ERROR_INVALID_ENDPOINT:f,ERROR_NETWORK_ABORT:c,ERROR_NETWORK_CONNECTION:R,ERROR_RATE_LIMIT:A,ERROR_SERVER_TIMEOUT:w,ERROR_SUBSCRIPTION_NOT_ACTIVE:l,ERROR_TOKEN_EXPIRED:L,ERROR_TOKEN_INVALID:S,ERROR_TOKEN_MISSING:D,ERROR_UNSUPPORTED_VERSION:_,ERROR_WRONG_REGION:d,defaultEndpoint:i$1,defaultTlsEndpoint:u};let fingerprintApiKey;function setFingerprintApiKey(ue){fingerprintApiKey=ue}async function getFingerPrint(){return k.load({token:fingerprintApiKey,endpoint:"https://fingerprint.incodesmile.com",scriptUrlPattern:"https://fingerprint.incodesmile.com/web/v<version>/<apiKey>/loader_v<loaderVersion>.js"}).then(ue=>ue.get({extendedResult:!0}))}const fingerPrintUrl="/omni/add/device-fingerprint";function postFingerprint({hash:ue,ip:me,deviceType:Ue,token:Qe,data:Ze,osVersion:Je,deviceModel:Ge,browser:He,sdkVersion:Xe,hasLiedBrowser:$e,hostingApp:Ke,ipLocation:nt}){return exports.api.post(fingerPrintUrl,{hash:ue,ip:me,deviceType:Ue,data:Ze,osVersion:Je,deviceModel:Ge,browser:He,hasLiedBrowser:$e,sdkVersion:Xe,hostingApp:Ke,ipLocation:nt},{headers:{"X-Incode-Hardware-Id":Qe}}).then(tt=>tt.data).catch(tt=>Promise.reject(tt.response.data))}function formatDeviceModel({vendor:ue,model:me}){return`${ue||""} ${me||""}`.trim()}const emptyFingerprint={visitorId:void 0,ip:void 0,ipLocation:{country:{name:void 0},subdivisions:[],city:{name:void 0},latitude:void 0,longitude:void 0}};async function sendFingerprint({token:ue},me=!0,Ue=!0){var Xe,$e,Ke;const Qe="WEBAPP",{os:Ze,device:Je,browser:Ge}=getUAParserResults(),He=Ue?await getFingerPrint().catch(nt=>(addEvent({code:"fingerprintFetchFailed",payload:{message:nt.message},token:ue}),emptyFingerprint)):emptyFingerprint;return postFingerprint({hash:He.visitorId||"",ip:me&&He.ip||"",deviceType:Qe,token:ue,data:JSON.stringify(He),osVersion:`${Ze.name} ${Ze.version}`,deviceModel:formatDeviceModel(Je),browser:`${Ge.name} ${Ge.version}`,hasLiedBrowser:isBrowserSimulation(),hostingApp:options.hostingApp,sdkVersion:version,ipLocation:{ipCountry:(Xe=He.ipLocation.country)==null?void 0:Xe.name,ipRegion:($e=He.ipLocation.subdivisions)==null?void 0:$e[0].name,ipCity:(Ke=He.ipLocation.city)==null?void 0:Ke.name,ipLatitude:He.ipLocation.latitude,ipLongitude:He.ipLocation.longitude}}).then(nt=>(emptyDeviceStatsQueue(ue),nt))}function mapI18nLang(ue){const me={en:"en-US",es:"es-ES",pt:"pt-BR"},Ue=ue==null?void 0:ue.substring(0,2);return me[Ue]||"en-US"}const createSessionUrl="/omni/start";async function createNewSession({externalId:ue,externalCustomerId:me,configurationId:Ue,uuid:Qe,interviewId:Ze,customFields:Je,language:Ge}={}){const He=Ge||mapI18nLang(i18nInstance.language);try{const Xe=await exports.api.post(createSessionUrl,{externalId:ue,externalCustomerId:me,configurationId:Ue,uuid:Qe,interviewId:Ze,customFields:Je,language:He});state.token=Xe.data;const $e=Xe.data;emptyQueue($e.token);const Ke=await sendFingerprint({token:$e.token,interviewId:$e.interviewId}).catch(()=>({regulationType:"",showMandatoryConsent:!1}));$e.regulationType=Ke.regulationType??"",$e.showMandatoryConsent=Ke.showMandatoryConsent??!1;const tt=new UAParser().getResult();return addEvent({code:"browser",payload:{userAgent:window.navigator.userAgent,isWebRtcSupported:isWebRtcSupported(),...tt},token:$e.token}),$e}catch(Xe){throw Xe!=null&&Xe.response?Xe.response.data:Xe}}const createRedirectUrl=async({session:ue})=>{const{url:me}=await exports.api.get("/omni/onboarding-url",{params:{clientId:ue.clientId},headers:{"X-Incode-Hardware-Id":ue.token}}).then(Ue=>Ue.data);return me};async function createSession$4(ue,me,{externalCustomerId:Ue,configurationId:Qe,uuid:Ze,interviewId:Je,customFields:Ge,language:He}={}){return createNewSession({externalId:me,externalCustomerId:Ue,configurationId:Qe,uuid:Ze,interviewId:Je,customFields:Ge,language:He})}var isHTMLElement=ue=>ue instanceof HTMLElement;const EVENTS={BLUR:"blur",CHANGE:"change",INPUT:"input"},VALIDATION_MODE={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},SELECT="select",UNDEFINED="undefined",INPUT_VALIDATION_RULES={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};function attachEventListeners({ref:ue},me,Ue){isHTMLElement(ue)&&Ue&&(ue.addEventListener(me?EVENTS.CHANGE:EVENTS.INPUT,Ue),ue.addEventListener(EVENTS.BLUR,Ue))}var isNullOrUndefined=ue=>ue==null;const isObjectType=ue=>typeof ue=="object";var isObject$4=ue=>!isNullOrUndefined(ue)&&!Array.isArray(ue)&&isObjectType(ue)&&!(ue instanceof Date),isKey=ue=>/^\w*$/.test(ue),compact=ue=>ue.filter(Boolean),stringToPath=ue=>compact(ue.replace(/["|']/g,"").replace(/\[/g,".").replace(/\]/g,"").split("."));function set(ue,me,Ue){let Qe=-1;const Ze=isKey(me)?[me]:stringToPath(me),Je=Ze.length,Ge=Je-1;for(;++Qe<Je;){const He=Ze[Qe];let Xe=Ue;if(Qe!==Ge){const $e=ue[He];Xe=isObject$4($e)||Array.isArray($e)?$e:isNaN(+Ze[Qe+1])?{}:[]}ue[He]=Xe,ue=ue[He]}return ue}var transformToNestObject=(ue,me={})=>{for(const Ue in ue)isKey(Ue)?me[Ue]=ue[Ue]:set(me,Ue,ue[Ue]);return me},isUndefined$1=ue=>ue===void 0,get=(ue={},me,Ue)=>{const Qe=compact(me.split(/[,[\].]+?/)).reduce((Ze,Je)=>isNullOrUndefined(Ze)?Ze:Ze[Je],ue);return isUndefined$1(Qe)||Qe===ue?isUndefined$1(ue[me])?Ue:ue[me]:Qe},focusOnErrorField=(ue,me)=>{for(const Ue in ue)if(get(me,Ue)){const Qe=ue[Ue];if(Qe){if(Qe.ref.focus&&isUndefined$1(Qe.ref.focus()))break;if(Qe.options){Qe.options[0].ref.focus();break}}}},removeAllEventListeners=(ue,me)=>{isHTMLElement(ue)&&ue.removeEventListener&&(ue.removeEventListener(EVENTS.INPUT,me),ue.removeEventListener(EVENTS.CHANGE,me),ue.removeEventListener(EVENTS.BLUR,me))};const defaultReturn={isValid:!1,value:null};var getRadioValue=ue=>Array.isArray(ue)?ue.reduce((me,Ue)=>Ue&&Ue.ref.checked?{isValid:!0,value:Ue.ref.value}:me,defaultReturn):defaultReturn,getMultipleSelectValue=ue=>[...ue].filter(({selected:me})=>me).map(({value:me})=>me),isRadioInput=ue=>ue.type==="radio",isFileInput=ue=>ue.type==="file",isCheckBoxInput=ue=>ue.type==="checkbox",isMultipleSelect=ue=>ue.type===`${SELECT}-multiple`;const defaultResult={value:!1,isValid:!1},validResult={value:!0,isValid:!0};var getCheckboxValue=ue=>{if(Array.isArray(ue)){if(ue.length>1){const Ze=ue.filter(Je=>Je&&Je.ref.checked).map(({ref:{value:Je}})=>Je);return{value:Ze,isValid:!!Ze.length}}const{checked:me,value:Ue,attributes:Qe}=ue[0].ref;return me?Qe&&!isUndefined$1(Qe.value)?isUndefined$1(Ue)||Ue===""?validResult:{value:Ue,isValid:!0}:validResult:defaultResult}return defaultResult};function getFieldValue(ue,me,Ue,Qe,Ze){const Je=ue.current[me];if(Je){const{ref:{value:Ge,disabled:He},ref:Xe,valueAsNumber:$e,valueAsDate:Ke,setValueAs:nt}=Je;return He&&Qe?void 0:isFileInput(Xe)?Xe.files:isRadioInput(Xe)?getRadioValue(Je.options).value:isMultipleSelect(Xe)?getMultipleSelectValue(Xe.options):isCheckBoxInput(Xe)?getCheckboxValue(Je.options).value:Ze?Ge:$e?Ge===""?NaN:+Ge:Ke?Xe.valueAsDate:nt?nt(Ge):Ge}if(Ue)return get(Ue.current,me)}function isDetached(ue){return ue?!(ue instanceof HTMLElement)||ue.nodeType===Node.DOCUMENT_NODE?!1:isDetached(ue.parentNode):!0}var isEmptyObject=ue=>isObject$4(ue)&&!Object.keys(ue).length,isBoolean=ue=>typeof ue=="boolean";function baseGet(ue,me){const Ue=me.slice(0,-1).length;let Qe=0;for(;Qe<Ue;)ue=isUndefined$1(ue)?Qe++:ue[me[Qe++]];return ue}function unset(ue,me){const Ue=isKey(me)?[me]:stringToPath(me),Qe=Ue.length==1?ue:baseGet(ue,Ue),Ze=Ue[Ue.length-1];let Je;Qe&&delete Qe[Ze];for(let Ge=0;Ge<Ue.slice(0,-1).length;Ge++){let He=-1,Xe;const $e=Ue.slice(0,-(Ge+1)),Ke=$e.length-1;for(Ge>0&&(Je=ue);++He<$e.length;){const nt=$e[He];Xe=Xe?Xe[nt]:ue[nt],Ke===He&&(isObject$4(Xe)&&isEmptyObject(Xe)||Array.isArray(Xe)&&!Xe.filter(tt=>isObject$4(tt)&&!isEmptyObject(tt)||isBoolean(tt)).length)&&(Je?delete Je[nt]:delete ue[nt]),Je=Xe}}return ue}const isSameRef=(ue,me)=>ue&&ue.ref===me;function findRemovedFieldAndRemoveListener(ue,me,Ue,Qe,Ze,Je){const{ref:Ge,ref:{name:He}}=Ue,Xe=ue.current[He];if(!Ze){const $e=getFieldValue(ue,He,Qe);!isUndefined$1($e)&&set(Qe.current,He,$e)}if(!Ge.type||!Xe){delete ue.current[He];return}isRadioInput(Ge)||isCheckBoxInput(Ge)?Array.isArray(Xe.options)&&Xe.options.length?(compact(Xe.options).forEach(($e={},Ke)=>{(isDetached($e.ref)&&isSameRef($e,$e.ref)||Je)&&(removeAllEventListeners($e.ref,me),unset(Xe.options,`[${Ke}]`))}),Xe.options&&!compact(Xe.options).length&&delete ue.current[He]):delete ue.current[He]:(isDetached(Ge)&&isSameRef(Xe,Ge)||Je)&&(removeAllEventListeners(Ge,me),delete ue.current[He])}var isPrimitive=ue=>isNullOrUndefined(ue)||!isObjectType(ue);function deepMerge(ue,me){if(isPrimitive(ue)||isPrimitive(me))return me;for(const Ue in me){const Qe=ue[Ue],Ze=me[Ue];try{ue[Ue]=isObject$4(Qe)&&isObject$4(Ze)||Array.isArray(Qe)&&Array.isArray(Ze)?deepMerge(Qe,Ze):Ze}catch{}}return ue}function deepEqual(ue,me,Ue){if(isPrimitive(ue)||isPrimitive(me)||ue instanceof Date||me instanceof Date)return ue===me;if(!React$1.isValidElement(ue)){const Qe=Object.keys(ue),Ze=Object.keys(me);if(Qe.length!==Ze.length)return!1;for(const Je of Qe){const Ge=ue[Je];if(!(Ue&&Je==="ref")){const He=me[Je];if((isObject$4(Ge)||Array.isArray(Ge))&&(isObject$4(He)||Array.isArray(He))?!deepEqual(Ge,He,Ue):Ge!==He)return!1}}}return!0}function setDirtyFields(ue,me,Ue,Qe,Ze){let Je=-1;for(;++Je<ue.length;){for(const Ge in ue[Je])Array.isArray(ue[Je][Ge])?(!Ue[Je]&&(Ue[Je]={}),Ue[Je][Ge]=[],setDirtyFields(ue[Je][Ge],get(me[Je]||{},Ge,[]),Ue[Je][Ge],Ue[Je],Ge)):deepEqual(get(me[Je]||{},Ge),ue[Je][Ge])?set(Ue[Je]||{},Ge):Ue[Je]=Object.assign(Object.assign({},Ue[Je]),{[Ge]:!0});Qe&&!Ue.length&&delete Qe[Ze]}return Ue}var setFieldArrayDirtyFields=(ue,me,Ue)=>deepMerge(setDirtyFields(ue,me,Ue.slice(0,ue.length)),setDirtyFields(me,ue,Ue.slice(0,ue.length))),isString$2=ue=>typeof ue=="string",getFieldsValues=(ue,me,Ue,Qe,Ze)=>{const Je={};for(const Ge in ue.current)(isUndefined$1(Ze)||(isString$2(Ze)?Ge.startsWith(Ze):Array.isArray(Ze)&&Ze.find(He=>Ge.startsWith(He))))&&(Je[Ge]=getFieldValue(ue,Ge,void 0,Qe));return Ue?transformToNestObject(Je):deepMerge(me,transformToNestObject(Je))},isErrorStateChanged=({errors:ue,name:me,error:Ue,validFields:Qe,fieldsWithValidation:Ze})=>{const Je=isUndefined$1(Ue),Ge=get(ue,me);return Je&&!!Ge||!Je&&!deepEqual(Ge,Ue,!0)||Je&&get(Ze,me)&&!get(Qe,me)},isRegex=ue=>ue instanceof RegExp,getValueAndMessage=ue=>isObject$4(ue)&&!isRegex(ue)?ue:{value:ue,message:""},isFunction$1=ue=>typeof ue=="function",isMessage=ue=>isString$2(ue)||React$1.isValidElement(ue);function getValidateError(ue,me,Ue="validate"){if(isMessage(ue)||isBoolean(ue)&&!ue)return{type:Ue,message:isMessage(ue)?ue:"",ref:me}}var appendErrors=(ue,me,Ue,Qe,Ze)=>me?Object.assign(Object.assign({},Ue[ue]),{types:Object.assign(Object.assign({},Ue[ue]&&Ue[ue].types?Ue[ue].types:{}),{[Qe]:Ze||!0})}):{},validateField=async(ue,me,{ref:Ue,ref:{value:Qe},options:Ze,required:Je,maxLength:Ge,minLength:He,min:Xe,max:$e,pattern:Ke,validate:nt},tt)=>{const et=Ue.name,rt={},at=isRadioInput(Ue),ot=isCheckBoxInput(Ue),it=at||ot,st=Qe==="",ct=appendErrors.bind(null,et,me,rt),lt=(dt,ft,gt,ht=INPUT_VALIDATION_RULES.maxLength,vt=INPUT_VALIDATION_RULES.minLength)=>{const Rt=dt?ft:gt;rt[et]=Object.assign({type:dt?ht:vt,message:Rt,ref:Ue},ct(dt?ht:vt,Rt))};if(Je&&(!at&&!ot&&(st||isNullOrUndefined(Qe))||isBoolean(Qe)&&!Qe||ot&&!getCheckboxValue(Ze).isValid||at&&!getRadioValue(Ze).isValid)){const{value:dt,message:ft}=isMessage(Je)?{value:!!Je,message:Je}:getValueAndMessage(Je);if(dt&&(rt[et]=Object.assign({type:INPUT_VALIDATION_RULES.required,message:ft,ref:it?((ue.current[et].options||[])[0]||{}).ref:Ue},ct(INPUT_VALIDATION_RULES.required,ft)),!me))return rt}if((!isNullOrUndefined(Xe)||!isNullOrUndefined($e))&&Qe!==""){let dt,ft;const gt=getValueAndMessage($e),ht=getValueAndMessage(Xe);if(isNaN(Qe)){const vt=Ue.valueAsDate||new Date(Qe);isString$2(gt.value)&&(dt=vt>new Date(gt.value)),isString$2(ht.value)&&(ft=vt<new Date(ht.value))}else{const vt=Ue.valueAsNumber||parseFloat(Qe);isNullOrUndefined(gt.value)||(dt=vt>gt.value),isNullOrUndefined(ht.value)||(ft=vt<ht.value)}if((dt||ft)&&(lt(!!dt,gt.message,ht.message,INPUT_VALIDATION_RULES.max,INPUT_VALIDATION_RULES.min),!me))return rt}if(isString$2(Qe)&&!st&&(Ge||He)){const dt=getValueAndMessage(Ge),ft=getValueAndMessage(He),gt=!isNullOrUndefined(dt.value)&&Qe.length>dt.value,ht=!isNullOrUndefined(ft.value)&&Qe.length<ft.value;if((gt||ht)&&(lt(gt,dt.message,ft.message),!me))return rt}if(isString$2(Qe)&&Ke&&!st){const{value:dt,message:ft}=getValueAndMessage(Ke);if(isRegex(dt)&&!dt.test(Qe)&&(rt[et]=Object.assign({type:INPUT_VALIDATION_RULES.pattern,message:ft,ref:Ue},ct(INPUT_VALIDATION_RULES.pattern,ft)),!me))return rt}if(nt){const dt=getFieldValue(ue,et,tt,!1,!0),ft=it&&Ze?Ze[0].ref:Ue;if(isFunction$1(nt)){const gt=await nt(dt),ht=getValidateError(gt,ft);if(ht&&(rt[et]=Object.assign(Object.assign({},ht),ct(INPUT_VALIDATION_RULES.validate,ht.message)),!me))return rt}else if(isObject$4(nt)){let gt={};for(const[ht,vt]of Object.entries(nt)){if(!isEmptyObject(gt)&&!me)break;const Rt=await vt(dt),bt=getValidateError(Rt,ft,ht);bt&&(gt=Object.assign(Object.assign({},bt),ct(ht,bt.message)),me&&(rt[et]=gt))}if(!isEmptyObject(gt)&&(rt[et]=Object.assign({ref:ft},gt),!me))return rt}}return rt};const getPath=(ue,me,Ue=[])=>{for(const Qe in me){const Ze=ue+(isObject$4(me)?`.${Qe}`:`[${Qe}]`);isPrimitive(me[Qe])?Ue.push(Ze):getPath(Ze,me[Qe],Ue)}return Ue};var assignWatchFields=(ue,me,Ue,Qe,Ze)=>{let Je;return Ue.add(me),isEmptyObject(ue)||(Je=get(ue,me),(isObject$4(Je)||Array.isArray(Je))&&getPath(me,Je).forEach(Ge=>Ue.add(Ge))),isUndefined$1(Je)?Ze?Qe:get(Qe,me):Je},skipValidation=({isOnBlur:ue,isOnChange:me,isOnTouch:Ue,isTouched:Qe,isReValidateOnBlur:Ze,isReValidateOnChange:Je,isBlurEvent:Ge,isSubmitted:He,isOnAll:Xe})=>Xe?!1:!He&&Ue?!(Qe||Ge):(He?Ze:ue)?!Ge:(He?Je:me)?Ge:!0,getFieldArrayParentName=ue=>ue.substring(0,ue.indexOf("["));const isMatchFieldArrayName=(ue,me)=>RegExp(`^${me}([|.)\\d+`.replace(/\[/g,"\\[").replace(/\]/g,"\\]")).test(ue);var isNameInFieldArray=(ue,me)=>[...ue].some(Ue=>isMatchFieldArrayName(me,Ue)),isSelectInput=ue=>ue.type===`${SELECT}-one`;function onDomRemove(ue,me){const Ue=new MutationObserver(()=>{for(const Qe of Object.values(ue.current))if(Qe&&Qe.options)for(const Ze of Qe.options)Ze&&Ze.ref&&isDetached(Ze.ref)&&me(Qe);else Qe&&isDetached(Qe.ref)&&me(Qe)});return Ue.observe(window.document,{childList:!0,subtree:!0}),Ue}var isWeb=typeof window!==UNDEFINED&&typeof document!==UNDEFINED;function cloneObject(ue){var me;let Ue;if(isPrimitive(ue)||isWeb&&(ue instanceof File||isHTMLElement(ue))||!["Set","Map","Object","Date","Array"].includes((me=ue.constructor)===null||me===void 0?void 0:me.name))return ue;if(ue instanceof Date)return Ue=new Date(ue.getTime()),Ue;if(ue instanceof Set){Ue=new Set;for(const Qe of ue)Ue.add(Qe);return Ue}if(ue instanceof Map){Ue=new Map;for(const Qe of ue.keys())Ue.set(Qe,cloneObject(ue.get(Qe)));return Ue}Ue=Array.isArray(ue)?[]:{};for(const Qe in ue)Ue[Qe]=cloneObject(ue[Qe]);return Ue}var modeChecker=ue=>({isOnSubmit:!ue||ue===VALIDATION_MODE.onSubmit,isOnBlur:ue===VALIDATION_MODE.onBlur,isOnChange:ue===VALIDATION_MODE.onChange,isOnAll:ue===VALIDATION_MODE.all,isOnTouch:ue===VALIDATION_MODE.onTouched}),isRadioOrCheckboxFunction=ue=>isRadioInput(ue)||isCheckBoxInput(ue);const isWindowUndefined=typeof window===UNDEFINED,isProxyEnabled=isWeb?"Proxy"in window:typeof Proxy!==UNDEFINED;function useForm({mode:ue=VALIDATION_MODE.onSubmit,reValidateMode:me=VALIDATION_MODE.onChange,resolver:Ue,context:Qe,defaultValues:Ze={},shouldFocusError:Je=!0,shouldUnregister:Ge=!0,criteriaMode:He}={}){const Xe=React$1.useRef({}),$e=React$1.useRef({}),Ke=React$1.useRef({}),nt=React$1.useRef(new Set),tt=React$1.useRef({}),et=React$1.useRef({}),rt=React$1.useRef({}),at=React$1.useRef({}),ot=React$1.useRef(Ze),it=React$1.useRef(!1),st=React$1.useRef(!1),ct=React$1.useRef(),lt=React$1.useRef({}),dt=React$1.useRef({}),ft=React$1.useRef(Qe),gt=React$1.useRef(Ue),ht=React$1.useRef(new Set),vt=React$1.useRef(modeChecker(ue)),{isOnSubmit:Rt,isOnTouch:bt}=vt.current,At=He===VALIDATION_MODE.all,[Nt,mt]=React$1.useState({isDirty:!1,isValidating:!1,dirtyFields:{},isSubmitted:!1,submitCount:0,touched:{},isSubmitting:!1,isSubmitSuccessful:!1,isValid:!Rt,errors:{}}),It=React$1.useRef({isDirty:!isProxyEnabled,dirtyFields:!isProxyEnabled,touched:!isProxyEnabled||bt,isValidating:!isProxyEnabled,isSubmitting:!isProxyEnabled,isValid:!isProxyEnabled}),yt=React$1.useRef(Nt),Mt=React$1.useRef(),{isOnBlur:St,isOnChange:xt}=React$1.useRef(modeChecker(me)).current;ft.current=Qe,gt.current=Ue,yt.current=Nt,lt.current=Ge?{}:isEmptyObject(lt.current)?cloneObject(Ze):lt.current;const Ut=React$1.useCallback((Ht={})=>{it.current||(yt.current=Object.assign(Object.assign({},yt.current),Ht),mt(yt.current))},[]),Ft=()=>It.current.isValidating&&Ut({isValidating:!0}),wt=React$1.useCallback((Ht,Kt,rn=!1,ln={},an)=>{let mn=rn||isErrorStateChanged({errors:yt.current.errors,error:Kt,name:Ht,validFields:at.current,fieldsWithValidation:rt.current});const yn=get(yt.current.errors,Ht);Kt?(unset(at.current,Ht),mn=mn||!yn||!deepEqual(yn,Kt,!0),set(yt.current.errors,Ht,Kt)):((get(rt.current,Ht)||gt.current)&&(set(at.current,Ht,!0),mn=mn||yn),unset(yt.current.errors,Ht)),(mn&&!isNullOrUndefined(rn)||!isEmptyObject(ln)||It.current.isValidating)&&Ut(Object.assign(Object.assign(Object.assign({},ln),gt.current?{isValid:!!an}:{}),{isValidating:!1}))},[]),Ct=React$1.useCallback((Ht,Kt)=>{const{ref:rn,options:ln}=Xe.current[Ht],an=isWeb&&isHTMLElement(rn)&&isNullOrUndefined(Kt)?"":Kt;isRadioInput(rn)?(ln||[]).forEach(({ref:mn})=>mn.checked=mn.value===an):isFileInput(rn)&&!isString$2(an)?rn.files=an:isMultipleSelect(rn)?[...rn.options].forEach(mn=>mn.selected=an.includes(mn.value)):isCheckBoxInput(rn)&&ln?ln.length>1?ln.forEach(({ref:mn})=>mn.checked=Array.isArray(an)?!!an.find(yn=>yn===mn.value):an===mn.value):ln[0].ref.checked=!!an:rn.value=an},[]),Zt=React$1.useCallback((Ht,Kt)=>{if(It.current.isDirty){const rn=Ot();return Ht&&Kt&&set(rn,Ht,Kt),!deepEqual(rn,ot.current)}return!1},[]),Jt=React$1.useCallback((Ht,Kt=!0)=>{if(It.current.isDirty||It.current.dirtyFields){const rn=!deepEqual(get(ot.current,Ht),getFieldValue(Xe,Ht,lt)),ln=get(yt.current.dirtyFields,Ht),an=yt.current.isDirty;rn?set(yt.current.dirtyFields,Ht,!0):unset(yt.current.dirtyFields,Ht);const mn={isDirty:Zt(),dirtyFields:yt.current.dirtyFields},yn=It.current.isDirty&&an!==mn.isDirty||It.current.dirtyFields&&ln!==get(yt.current.dirtyFields,Ht);return yn&&Kt&&Ut(mn),yn?mn:{}}return{}},[]),Qt=React$1.useCallback(async(Ht,Kt)=>{if(process.env.NODE_ENV!=="production"&&!Xe.current[Ht])return console.warn("📋 Field is missing with `name` attribute: ",Ht),!1;const rn=(await validateField(Xe,At,Xe.current[Ht],lt))[Ht];return wt(Ht,rn,Kt),isUndefined$1(rn)},[wt,At]),$t=React$1.useCallback(async Ht=>{const{errors:Kt}=await gt.current(Ot(),ft.current,At),rn=yt.current.isValid;if(Array.isArray(Ht)){const ln=Ht.map(an=>{const mn=get(Kt,an);return mn?set(yt.current.errors,an,mn):unset(yt.current.errors,an),!mn}).every(Boolean);return Ut({isValid:isEmptyObject(Kt),isValidating:!1}),ln}else{const ln=get(Kt,Ht);return wt(Ht,ln,rn!==isEmptyObject(Kt),{},isEmptyObject(Kt)),!ln}},[wt,At]),Gt=React$1.useCallback(async Ht=>{const Kt=Ht||Object.keys(Xe.current);if(Ft(),gt.current)return $t(Kt);if(Array.isArray(Kt)){!Ht&&(yt.current.errors={});const rn=await Promise.all(Kt.map(async ln=>await Qt(ln,null)));return Ut({isValidating:!1}),rn.every(Boolean)}return await Qt(Kt)},[$t,Qt]),Pt=React$1.useCallback((Ht,Kt,{shouldDirty:rn,shouldValidate:ln})=>{const an={};set(an,Ht,Kt);for(const mn of getPath(Ht,Kt))Xe.current[mn]&&(Ct(mn,get(an,mn)),rn&&Jt(mn),ln&&Gt(mn))},[Gt,Ct,Jt]),jt=React$1.useCallback((Ht,Kt,rn)=>{if(!Ge&&!isPrimitive(Kt)&&set(lt.current,Ht,Array.isArray(Kt)?[...Kt]:Object.assign({},Kt)),Xe.current[Ht])Ct(Ht,Kt),rn.shouldDirty&&Jt(Ht),rn.shouldValidate&&Gt(Ht);else if(!isPrimitive(Kt)&&(Pt(Ht,Kt,rn),ht.current.has(Ht))){const ln=getFieldArrayParentName(Ht)||Ht;set($e.current,Ht,Kt),dt.current[ln]({[ln]:get($e.current,ln)}),(It.current.isDirty||It.current.dirtyFields)&&rn.shouldDirty&&(set(yt.current.dirtyFields,Ht,setFieldArrayDirtyFields(Kt,get(ot.current,Ht,[]),get(yt.current.dirtyFields,Ht,[]))),Ut({isDirty:!deepEqual(Object.assign(Object.assign({},Ot()),{[Ht]:Kt}),ot.current)}))}!Ge&&set(lt.current,Ht,Kt)},[Jt,Ct,Pt]),Dt=Ht=>st.current||nt.current.has(Ht)||nt.current.has((Ht.match(/\w+/)||[])[0]),ut=Ht=>{let Kt=!0;if(!isEmptyObject(tt.current))for(const rn in tt.current)(!Ht||!tt.current[rn].size||tt.current[rn].has(Ht)||tt.current[rn].has(getFieldArrayParentName(Ht)))&&(et.current[rn](),Kt=!1);return Kt};function Et(Ht,Kt,rn){jt(Ht,Kt,rn||{}),Dt(Ht)&&Ut(),ut(Ht)}ct.current=ct.current?ct.current:async({type:Ht,target:Kt})=>{let rn=Kt.name;const ln=Xe.current[rn];let an,mn;if(ln){const yn=Ht===EVENTS.BLUR,bn=skipValidation(Object.assign({isBlurEvent:yn,isReValidateOnChange:xt,isReValidateOnBlur:St,isTouched:!!get(yt.current.touched,rn),isSubmitted:yt.current.isSubmitted},vt.current));let Cn=Jt(rn,!1),Bn=!isEmptyObject(Cn)||!yn&&Dt(rn);if(yn&&!get(yt.current.touched,rn)&&It.current.touched&&(set(yt.current.touched,rn,!0),Cn=Object.assign(Object.assign({},Cn),{touched:yt.current.touched})),!Ge&&isCheckBoxInput(Kt)&&set(lt.current,rn,getFieldValue(Xe,rn)),bn)return!yn&&ut(rn),(!isEmptyObject(Cn)||Bn&&isEmptyObject(Cn))&&Ut(Cn);if(Ft(),gt.current){const{errors:wn}=await gt.current(Ot(),ft.current,At),Dn=yt.current.isValid;if(an=get(wn,rn),isCheckBoxInput(Kt)&&!an&&gt.current){const Wn=getFieldArrayParentName(rn),kn=get(wn,Wn,{});kn.type&&kn.message&&(an=kn),Wn&&(kn||get(yt.current.errors,Wn))&&(rn=Wn)}mn=isEmptyObject(wn),Dn!==mn&&(Bn=!0)}else an=(await validateField(Xe,At,ln,lt))[rn];!yn&&ut(rn),wt(rn,an,Bn,Cn,mn)}};function Vt(Ht){if(!Ge){let Kt=cloneObject(Ht);for(const rn of ht.current)isKey(rn)&&!Kt[rn]&&(Kt=Object.assign(Object.assign({},Kt),{[rn]:[]}));return Kt}return Ht}function Ot(Ht){if(isString$2(Ht))return getFieldValue(Xe,Ht,lt);if(Array.isArray(Ht)){const Kt={};for(const rn of Ht)set(Kt,rn,getFieldValue(Xe,rn,lt));return Kt}return Vt(getFieldsValues(Xe,cloneObject(lt.current),Ge))}const Lt=React$1.useCallback(async(Ht={})=>{const Kt=isEmptyObject(Xe.current)?ot.current:{},{errors:rn}=await gt.current(Object.assign(Object.assign(Object.assign({},Kt),Ot()),Ht),ft.current,At)||{},ln=isEmptyObject(rn);yt.current.isValid!==ln&&Ut({isValid:ln})},[At]),zt=React$1.useCallback((Ht,Kt)=>{findRemovedFieldAndRemoveListener(Xe,ct.current,Ht,lt,Ge,Kt),Ge&&(unset(at.current,Ht.ref.name),unset(rt.current,Ht.ref.name))},[Ge]),Xt=React$1.useCallback(Ht=>{if(st.current)Ut();else{for(const Kt of nt.current)if(Kt.startsWith(Ht)){Ut();break}ut(Ht)}},[]),Yt=React$1.useCallback((Ht,Kt)=>{Ht&&(zt(Ht,Kt),Ge&&!compact(Ht.options||[]).length&&(unset(yt.current.errors,Ht.ref.name),set(yt.current.dirtyFields,Ht.ref.name,!0),Ut({isDirty:Zt()}),It.current.isValid&&gt.current&&Lt(),Xt(Ht.ref.name)))},[Lt,zt]);function sn(Ht){Ht&&(Array.isArray(Ht)?Ht:[Ht]).forEach(Kt=>Xe.current[Kt]&&isKey(Kt)?delete yt.current.errors[Kt]:unset(yt.current.errors,Kt)),Ut({errors:Ht?yt.current.errors:{}})}function cn(Ht,Kt){const rn=(Xe.current[Ht]||{}).ref;set(yt.current.errors,Ht,Object.assign(Object.assign({},Kt),{ref:rn})),Ut({isValid:!1}),Kt.shouldFocus&&rn&&rn.focus&&rn.focus()}const pn=React$1.useCallback((Ht,Kt,rn)=>{const ln=rn?tt.current[rn]:nt.current;let an=getFieldsValues(Xe,cloneObject(lt.current),Ge,!1,Ht);if(isString$2(Ht)){const yn=getFieldArrayParentName(Ht)||Ht;return ht.current.has(yn)&&(an=Object.assign(Object.assign({},Ke.current),an)),assignWatchFields(an,Ht,ln,isUndefined$1(get(ot.current,Ht))?Kt:get(ot.current,Ht),!0)}const mn=isUndefined$1(Kt)?ot.current:Kt;return Array.isArray(Ht)?Ht.reduce((yn,bn)=>Object.assign(Object.assign({},yn),{[bn]:assignWatchFields(an,bn,ln,mn)}),{}):(st.current=isUndefined$1(rn),transformToNestObject(!isEmptyObject(an)&&an||mn))},[]);function vn(Ht,Kt){return pn(Ht,Kt)}function Tn(Ht){for(const Kt of Array.isArray(Ht)?Ht:[Ht])Yt(Xe.current[Kt],!0)}function tn(Ht,Kt={}){if(process.env.NODE_ENV!=="production"){if(!Ht.name)return console.warn("📋 Field is missing `name` attribute",Ht,"https://react-hook-form.com/api#useForm");if(ht.current.has(Ht.name.split(/\[\d+\]$/)[0])&&!RegExp(`^${Ht.name.split(/\[\d+\]$/)[0]}[\\d+].\\w+`.replace(/\[/g,"\\[").replace(/\]/g,"\\]")).test(Ht.name))return console.warn('📋 `name` prop should be in object shape: name="test[index].name"',Ht,"https://react-hook-form.com/api#useFieldArray")}const{name:rn,type:ln,value:an}=Ht,mn=Object.assign({ref:Ht},Kt),yn=Xe.current,bn=isRadioOrCheckboxFunction(Ht),Cn=isNameInFieldArray(ht.current,rn),Bn=jn=>isWeb&&(!isHTMLElement(Ht)||jn===Ht);let wn=yn[rn],Dn=!0,Wn;if(wn&&(bn?Array.isArray(wn.options)&&compact(wn.options).find(jn=>an===jn.ref.value&&Bn(jn.ref)):Bn(wn.ref))){yn[rn]=Object.assign(Object.assign({},wn),Kt);return}ln?wn=bn?Object.assign({options:[...compact(wn&&wn.options||[]),{ref:Ht}],ref:{type:ln,name:rn}},Kt):Object.assign({},mn):wn=mn,yn[rn]=wn;const kn=isUndefined$1(get(lt.current,rn));(!isEmptyObject(ot.current)||!kn)&&(Wn=get(kn?ot.current:lt.current,rn),Dn=isUndefined$1(Wn),!Dn&&!Cn&&Ct(rn,Wn)),isEmptyObject(Kt)||(set(rt.current,rn,!0),!Rt&&It.current.isValid&&validateField(Xe,At,wn,lt).then(jn=>{const Pn=yt.current.isValid;isEmptyObject(jn)?set(at.current,rn,!0):unset(at.current,rn),Pn!==isEmptyObject(jn)&&Ut()})),Ge&&!(Cn&&Dn)&&!Cn&&unset(yt.current.dirtyFields,rn),ln&&attachEventListeners(bn&&wn.options?wn.options[wn.options.length-1]:wn,bn||isSelectInput(Ht),ct.current)}function dn(Ht,Kt){if(!isWindowUndefined)if(isString$2(Ht))tn({name:Ht},Kt);else if(isObject$4(Ht)&&"name"in Ht)tn(Ht,Kt);else return rn=>rn&&tn(rn,Ht)}const fn=React$1.useCallback((Ht,Kt)=>async rn=>{rn&&rn.preventDefault&&(rn.preventDefault(),rn.persist());let ln={},an=Vt(getFieldsValues(Xe,cloneObject(lt.current),Ge,!0));It.current.isSubmitting&&Ut({isSubmitting:!0});try{if(gt.current){const{errors:mn,values:yn}=await gt.current(an,ft.current,At);yt.current.errors=ln=mn,an=yn}else for(const mn of Object.values(Xe.current))if(mn){const{name:yn}=mn.ref,bn=await validateField(Xe,At,mn,lt);bn[yn]?(set(ln,yn,bn[yn]),unset(at.current,yn)):get(rt.current,yn)&&(unset(yt.current.errors,yn),set(at.current,yn,!0))}isEmptyObject(ln)&&Object.keys(yt.current.errors).every(mn=>mn in Xe.current)?(Ut({errors:{},isSubmitting:!0}),await Ht(an,rn)):(yt.current.errors=Object.assign(Object.assign({},yt.current.errors),ln),Kt&&await Kt(yt.current.errors,rn),Je&&focusOnErrorField(Xe.current,yt.current.errors))}finally{yt.current.isSubmitting=!1,Ut({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:isEmptyObject(yt.current.errors),submitCount:yt.current.submitCount+1})}},[Je,At]),Mn=({errors:Ht,isDirty:Kt,isSubmitted:rn,touched:ln,isValid:an,submitCount:mn,dirtyFields:yn})=>{an||(at.current={},rt.current={}),$e.current={},nt.current=new Set,st.current=!1,Ut({submitCount:mn?yt.current.submitCount:0,isDirty:Kt?yt.current.isDirty:!1,isSubmitted:rn?yt.current.isSubmitted:!1,isValid:an?yt.current.isValid:!1,dirtyFields:yn?yt.current.dirtyFields:{},touched:ln?yt.current.touched:{},errors:Ht?yt.current.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})},un=(Ht,Kt={})=>{if(isWeb){for(const rn of Object.values(Xe.current))if(rn){const{ref:ln,options:an}=rn,mn=isRadioOrCheckboxFunction(ln)&&Array.isArray(an)?an[0].ref:ln;if(isHTMLElement(mn))try{mn.closest("form").reset();break}catch{}}}Xe.current={},ot.current=Object.assign({},Ht||ot.current),Ht&&ut(""),Object.values(dt.current).forEach(rn=>isFunction$1(rn)&&rn()),lt.current=Ge?{}:cloneObject(Ht||ot.current),Mn(Kt)};React$1.useEffect(()=>{Ue&&It.current.isValid&&Lt(),Mt.current=Mt.current||!isWeb?Mt.current:onDomRemove(Xe,Yt)},[Yt,ot.current]),React$1.useEffect(()=>()=>{Mt.current&&Mt.current.disconnect(),it.current=!0,process.env.NODE_ENV==="production"&&Object.values(Xe.current).forEach(Ht=>Yt(Ht,!0))},[]),!Ue&&It.current.isValid&&(Nt.isValid=deepEqual(at.current,rt.current)&&isEmptyObject(yt.current.errors));const hn={trigger:Gt,setValue:React$1.useCallback(Et,[jt,Gt]),getValues:React$1.useCallback(Ot,[]),register:React$1.useCallback(dn,[ot.current]),unregister:React$1.useCallback(Tn,[]),formState:isProxyEnabled?new Proxy(Nt,{get:(Ht,Kt)=>{if(process.env.NODE_ENV!=="production"&&Kt==="isValid"&&Rt&&console.warn("📋 `formState.isValid` is applicable with `onTouched`, `onChange` or `onBlur` mode. https://react-hook-form.com/api#formState"),Kt in Ht)return It.current[Kt]=!0,Ht[Kt]}}):Nt},en=React$1.useMemo(()=>Object.assign({isFormDirty:Zt,updateWatchedValue:Xt,shouldUnregister:Ge,updateFormState:Ut,removeFieldEventListener:zt,watchInternal:pn,mode:vt.current,reValidateMode:{isReValidateOnBlur:St,isReValidateOnChange:xt},validateResolver:Ue?Lt:void 0,fieldsRef:Xe,resetFieldArrayFunctionRef:dt,useWatchFieldsRef:tt,useWatchRenderFunctionsRef:et,fieldArrayDefaultValuesRef:$e,validFieldsRef:at,fieldsWithValidationRef:rt,fieldArrayNamesRef:ht,readFormStateRef:It,formStateRef:yt,defaultValuesRef:ot,shallowFieldsStateRef:lt,fieldArrayValuesRef:Ke},hn),[ot.current,Xt,Ge,zt,pn]);return Object.assign({watch:vn,control:en,handleSubmit:fn,reset:React$1.useCallback(un,[]),clearErrors:React$1.useCallback(sn,[]),setError:React$1.useCallback(cn,[]),errors:Nt.errors},hn)}/*! *****************************************************************************
2560
+ `);return tt.length===1?tt.join(" "):tt.filter(et=>!!et.trim()).map(et=>Ge(et)).join(" ")},Ke=({title:nt,content:tt,isDefault:et})=>{addConsent({title:`${et?Ge(nt):nt}`,content:et?$e(tt):tt,status:!0,session:ue})};return React$1.useEffect(()=>{if(me||Ue){Xe({title:me||defaultPrivacyConsent.title,text:Ue||defaultPrivacyConsent.text,consentType:defaultPrivacyConsent.consentType,default:!Ue});return}getPrivacyConsentData({session:ue,type:"PRIVACY"}).then(({consents:nt})=>{const tt=nt.find(({consentType:et})=>et==="PRIVACY");tt!=null&&tt.text?Xe({...tt,title:(tt==null?void 0:tt.title.trim())||defaultPrivacyConsent.title,text:tt.text.trim()||defaultPrivacyConsent.text,default:!(tt!=null&&tt.text)}):Xe(defaultPrivacyConsent)}).catch(()=>{Xe(defaultPrivacyConsent)})},[ue,me,Ue]),He?jsx(NormalPrivacyConsent,{consent:He,goNext:Qe,addPrivacyConsent:Ke,session:ue,isAeroMexicoClient:Ze,customCheck:Je}):null}function renderUserConsent(ue,{session:me,onSuccess:Ue,title:Qe,text:Ze,isAeroMexicoClient:Je=!1,customCheck:Ge=null}){const He=createRoot$1(ue),Xe=handleUnmountRoot(Ue,He,ue);customRender(jsx(App$1,{token:me.token,children:jsx(PrivacyConsent,{goNext:Xe,session:me,title:Qe,text:Ze,isAeroMexicoClient:Je,customCheck:Ge})}),ue,He)}const version="1.71.0-20240430161557.0";function r(ue){for(var me="",Ue=0;Ue<ue.length;++Ue)if(Ue>0){var Qe=ue[Ue].toLowerCase();Qe!==ue[Ue]?me+=" ".concat(Qe):me+=ue[Ue]}else me+=ue[Ue].toUpperCase();return me}function o(ue,me){return function(Ue,Qe){return Object.prototype.hasOwnProperty.call(Ue,Qe)}(ue,me)?ue[me]:void 0}var i$1={default:"endpoint"},u={default:"tlsEndpoint"},a="Client timeout",R="Network connection error",c="Network request aborted",s="Response cannot be parsed",E="Blocked by CSP",f="The endpoint parameter is not a valid URL",d=r("WrongRegion"),l=r("SubscriptionNotActive"),_=r("UnsupportedVersion"),p=r("InstallationMethodRestricted"),v=r("HostnameRestricted"),O=r("IntegrationFailed"),I="API key required",h="API key not found",N="API key expired",T="Request cannot be parsed",m="Request failed",w="Request failed to process",A="Too many requests, rate limit exceeded",P="Not available for this origin",y="Not available with restricted header",D=I,S=h,L=N,U="3.8.6",b="9319";function g(ue,me){var Ue=[];return function(Qe,Ze){var Je=5,Ge=(tt=Qe,et=__spreadArray$1([],tt,!0),{current:function(){return et[0]},postpone:function(){var at=et.shift();at!==void 0&&et.push(at)},exclude:function(){et.shift()}}),He=($e=100,Ke=3e3,nt=0,function(){return Math.random()*Math.min(Ke,$e*Math.pow(2,nt++))}),Xe=Ge.current(),$e,Ke,nt,tt,et;if(Xe===void 0)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var rt=function(at,ot){return Ze(at).catch(function(it){if(ot+1>=Je)throw it;(function(lt){if(!(lt instanceof Error))return!1;var dt=lt.message;return dt===E||dt===b})(it)?Ge.exclude():Ge.postpone();var st,ct=Ge.current();if(ct===void 0)throw it;return(st=He(),new Promise(function(lt){return setTimeout(lt,st)})).then(function(){return rt(ct,ot+1)})})};return rt(Xe,0)}(ue,function(Qe){var Ze=new Date,Je=function(He){return Ue.push({url:Qe,startedAt:Ze,finishedAt:new Date,error:He})},Ge=me(Qe);return Ge.then(function(){return Je()},Je),Ge}).then(function(Qe){return[Qe,Ue]})}var C="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",K=C,M="Failed to load the JS script of the agent";function B(ue){var me;ue.scriptUrlPattern;var Ue=ue.token,Qe=ue.apiKey,Ze=Qe===void 0?Ue:Qe,Je=__rest$1(ue,["scriptUrlPattern","token","apiKey"]),Ge=(me=o(ue,"scriptUrlPattern"))!==null&&me!==void 0?me:C,He=function(){var Ke=[],nt=function(){Ke.push({time:new Date,state:document.visibilityState})},tt=function(et,rt,at,ot){return et.addEventListener(rt,at,ot),function(){return et.removeEventListener(rt,at,ot)}}(document,"visibilitychange",nt);return nt(),[Ke,tt]}(),Xe=He[0],$e=He[1];return Promise.resolve().then(function(){if(!Ze||typeof Ze!="string")throw new Error(I);var Ke=function(nt,tt){return(Array.isArray(nt)?nt:[nt]).map(function(et){return function(rt,at){var ot=encodeURIComponent;return rt.replace(/<[^<>]+>/g,function(it){return it==="<version>"?"3":it==="<apiKey>"?ot(at):it==="<loaderVersion>"?ot(U):it})}(String(et),tt)})}(Ge,Ze);return g(Ke,F)}).catch(function(Ke){throw $e(),function(nt){return nt instanceof Error&&nt.message===b?new Error(M):nt}(Ke)}).then(function(Ke){var nt=Ke[0],tt=Ke[1];return $e(),nt.load(__assign$2(__assign$2({},Je),{ldi:{attempts:tt,visibilityStates:Xe}}))})}function F(ue){return function(me,Ue,Qe,Ze){var Je,Ge=document,He="securitypolicyviolation",Xe=function(Ke){var nt=new URL(me,location.href),tt=Ke.blockedURI;tt!==nt.href&&tt!==nt.protocol.slice(0,-1)&&tt!==nt.origin||(Je=Ke,$e())};Ge.addEventListener(He,Xe);var $e=function(){return Ge.removeEventListener(He,Xe)};return Ze==null||Ze.then($e,$e),Promise.resolve().then(Ue).then(function(Ke){return $e(),Ke},function(Ke){return new Promise(function(nt){return setTimeout(nt)}).then(function(){if($e(),Je)return Qe(Je);throw Ke})})}(ue,function(){return function(me){return new Promise(function(Ue,Qe){var Ze=document.createElement("script"),Je=function(){var He;return(He=Ze.parentNode)===null||He===void 0?void 0:He.removeChild(Ze)},Ge=document.head||document.getElementsByTagName("head")[0];Ze.onload=function(){Je(),Ue()},Ze.onerror=function(){Je(),Qe(new Error(M))},Ze.async=!0,Ze.src=me,Ge.appendChild(Ze)})}(ue)},function(){throw new Error(E)}).then(V)}function V(){var ue=window,me="__fpjs_p_l_b",Ue=ue[me];if(function(Qe,Ze){var Je,Ge=(Je=Object.getOwnPropertyDescriptor)===null||Je===void 0?void 0:Je.call(Object,Qe,Ze);Ge!=null&&Ge.configurable?delete Qe[Ze]:Ge&&!Ge.writable||(Qe[Ze]=void 0)}(ue,me),typeof(Ue==null?void 0:Ue.load)!="function")throw new Error(b);return Ue}var k={load:B,defaultScriptUrlPattern:K,ERROR_SCRIPT_LOAD_FAIL:M,ERROR_API_KEY_EXPIRED:N,ERROR_API_KEY_INVALID:h,ERROR_API_KEY_MISSING:I,ERROR_BAD_REQUEST_FORMAT:T,ERROR_BAD_RESPONSE_FORMAT:s,ERROR_CLIENT_TIMEOUT:a,ERROR_CSP_BLOCK:E,ERROR_FORBIDDEN_ENDPOINT:v,ERROR_FORBIDDEN_HEADER:y,ERROR_FORBIDDEN_ORIGIN:P,ERROR_GENERAL_SERVER_FAILURE:m,ERROR_INSTALLATION_METHOD_RESTRICTED:p,ERROR_INTEGRATION_FAILURE:O,ERROR_INVALID_ENDPOINT:f,ERROR_NETWORK_ABORT:c,ERROR_NETWORK_CONNECTION:R,ERROR_RATE_LIMIT:A,ERROR_SERVER_TIMEOUT:w,ERROR_SUBSCRIPTION_NOT_ACTIVE:l,ERROR_TOKEN_EXPIRED:L,ERROR_TOKEN_INVALID:S,ERROR_TOKEN_MISSING:D,ERROR_UNSUPPORTED_VERSION:_,ERROR_WRONG_REGION:d,defaultEndpoint:i$1,defaultTlsEndpoint:u};let fingerprintApiKey;function setFingerprintApiKey(ue){fingerprintApiKey=ue}async function getFingerPrint(){return k.load({token:fingerprintApiKey,endpoint:"https://fingerprint.incodesmile.com",scriptUrlPattern:"https://fingerprint.incodesmile.com/web/v<version>/<apiKey>/loader_v<loaderVersion>.js"}).then(ue=>ue.get({extendedResult:!0}))}const fingerPrintUrl="/omni/add/device-fingerprint";function postFingerprint({hash:ue,ip:me,deviceType:Ue,token:Qe,data:Ze,osVersion:Je,deviceModel:Ge,browser:He,sdkVersion:Xe,hasLiedBrowser:$e,hostingApp:Ke,ipLocation:nt}){return exports.api.post(fingerPrintUrl,{hash:ue,ip:me,deviceType:Ue,data:Ze,osVersion:Je,deviceModel:Ge,browser:He,hasLiedBrowser:$e,sdkVersion:Xe,hostingApp:Ke,ipLocation:nt},{headers:{"X-Incode-Hardware-Id":Qe}}).then(tt=>tt.data).catch(tt=>Promise.reject(tt.response.data))}function formatDeviceModel({vendor:ue,model:me}){return`${ue||""} ${me||""}`.trim()}const emptyFingerprint={visitorId:void 0,ip:void 0,ipLocation:{country:{name:void 0},subdivisions:[],city:{name:void 0},latitude:void 0,longitude:void 0}};async function sendFingerprint({token:ue},me=!0,Ue=!0){var Xe,$e,Ke;const Qe="WEBAPP",{os:Ze,device:Je,browser:Ge}=getUAParserResults(),He=Ue?await getFingerPrint().catch(nt=>(addEvent({code:"fingerprintFetchFailed",payload:{message:nt.message},token:ue}),emptyFingerprint)):emptyFingerprint;return postFingerprint({hash:He.visitorId||"",ip:me&&He.ip||"",deviceType:Qe,token:ue,data:JSON.stringify(He),osVersion:`${Ze.name} ${Ze.version}`,deviceModel:formatDeviceModel(Je),browser:`${Ge.name} ${Ge.version}`,hasLiedBrowser:isBrowserSimulation(),hostingApp:options.hostingApp,sdkVersion:version,ipLocation:{ipCountry:(Xe=He.ipLocation.country)==null?void 0:Xe.name,ipRegion:($e=He.ipLocation.subdivisions)==null?void 0:$e[0].name,ipCity:(Ke=He.ipLocation.city)==null?void 0:Ke.name,ipLatitude:He.ipLocation.latitude,ipLongitude:He.ipLocation.longitude}}).then(nt=>(emptyDeviceStatsQueue(ue),nt))}function mapI18nLang(ue){const me={en:"en-US",es:"es-ES",pt:"pt-BR"},Ue=ue==null?void 0:ue.substring(0,2);return me[Ue]||"en-US"}const createSessionUrl="/omni/start";async function createNewSession({externalId:ue,externalCustomerId:me,configurationId:Ue,uuid:Qe,interviewId:Ze,customFields:Je,language:Ge}={}){const He=Ge||mapI18nLang(i18nInstance.language);try{const Xe=await exports.api.post(createSessionUrl,{externalId:ue,externalCustomerId:me,configurationId:Ue,uuid:Qe,interviewId:Ze,customFields:Je,language:He});state.token=Xe.data;const $e=Xe.data;emptyQueue($e.token);const Ke=await sendFingerprint({token:$e.token,interviewId:$e.interviewId}).catch(()=>({regulationType:"",showMandatoryConsent:!1}));$e.regulationType=Ke.regulationType??"",$e.showMandatoryConsent=Ke.showMandatoryConsent??!1;const tt=new UAParser().getResult();return addEvent({code:"browser",payload:{userAgent:window.navigator.userAgent,isWebRtcSupported:isWebRtcSupported(),...tt},token:$e.token}),$e}catch(Xe){throw Xe!=null&&Xe.response?Xe.response.data:Xe}}const createRedirectUrl=async({session:ue})=>{const{url:me}=await exports.api.get("/omni/onboarding-url",{params:{clientId:ue.clientId},headers:{"X-Incode-Hardware-Id":ue.token}}).then(Ue=>Ue.data);return me};async function createSession$4(ue,me,{externalCustomerId:Ue,configurationId:Qe,uuid:Ze,interviewId:Je,customFields:Ge,language:He}={}){return createNewSession({externalId:me,externalCustomerId:Ue,configurationId:Qe,uuid:Ze,interviewId:Je,customFields:Ge,language:He})}var isHTMLElement=ue=>ue instanceof HTMLElement;const EVENTS={BLUR:"blur",CHANGE:"change",INPUT:"input"},VALIDATION_MODE={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},SELECT="select",UNDEFINED="undefined",INPUT_VALIDATION_RULES={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};function attachEventListeners({ref:ue},me,Ue){isHTMLElement(ue)&&Ue&&(ue.addEventListener(me?EVENTS.CHANGE:EVENTS.INPUT,Ue),ue.addEventListener(EVENTS.BLUR,Ue))}var isNullOrUndefined=ue=>ue==null;const isObjectType=ue=>typeof ue=="object";var isObject$4=ue=>!isNullOrUndefined(ue)&&!Array.isArray(ue)&&isObjectType(ue)&&!(ue instanceof Date),isKey=ue=>/^\w*$/.test(ue),compact=ue=>ue.filter(Boolean),stringToPath=ue=>compact(ue.replace(/["|']/g,"").replace(/\[/g,".").replace(/\]/g,"").split("."));function set(ue,me,Ue){let Qe=-1;const Ze=isKey(me)?[me]:stringToPath(me),Je=Ze.length,Ge=Je-1;for(;++Qe<Je;){const He=Ze[Qe];let Xe=Ue;if(Qe!==Ge){const $e=ue[He];Xe=isObject$4($e)||Array.isArray($e)?$e:isNaN(+Ze[Qe+1])?{}:[]}ue[He]=Xe,ue=ue[He]}return ue}var transformToNestObject=(ue,me={})=>{for(const Ue in ue)isKey(Ue)?me[Ue]=ue[Ue]:set(me,Ue,ue[Ue]);return me},isUndefined$1=ue=>ue===void 0,get=(ue={},me,Ue)=>{const Qe=compact(me.split(/[,[\].]+?/)).reduce((Ze,Je)=>isNullOrUndefined(Ze)?Ze:Ze[Je],ue);return isUndefined$1(Qe)||Qe===ue?isUndefined$1(ue[me])?Ue:ue[me]:Qe},focusOnErrorField=(ue,me)=>{for(const Ue in ue)if(get(me,Ue)){const Qe=ue[Ue];if(Qe){if(Qe.ref.focus&&isUndefined$1(Qe.ref.focus()))break;if(Qe.options){Qe.options[0].ref.focus();break}}}},removeAllEventListeners=(ue,me)=>{isHTMLElement(ue)&&ue.removeEventListener&&(ue.removeEventListener(EVENTS.INPUT,me),ue.removeEventListener(EVENTS.CHANGE,me),ue.removeEventListener(EVENTS.BLUR,me))};const defaultReturn={isValid:!1,value:null};var getRadioValue=ue=>Array.isArray(ue)?ue.reduce((me,Ue)=>Ue&&Ue.ref.checked?{isValid:!0,value:Ue.ref.value}:me,defaultReturn):defaultReturn,getMultipleSelectValue=ue=>[...ue].filter(({selected:me})=>me).map(({value:me})=>me),isRadioInput=ue=>ue.type==="radio",isFileInput=ue=>ue.type==="file",isCheckBoxInput=ue=>ue.type==="checkbox",isMultipleSelect=ue=>ue.type===`${SELECT}-multiple`;const defaultResult={value:!1,isValid:!1},validResult={value:!0,isValid:!0};var getCheckboxValue=ue=>{if(Array.isArray(ue)){if(ue.length>1){const Ze=ue.filter(Je=>Je&&Je.ref.checked).map(({ref:{value:Je}})=>Je);return{value:Ze,isValid:!!Ze.length}}const{checked:me,value:Ue,attributes:Qe}=ue[0].ref;return me?Qe&&!isUndefined$1(Qe.value)?isUndefined$1(Ue)||Ue===""?validResult:{value:Ue,isValid:!0}:validResult:defaultResult}return defaultResult};function getFieldValue(ue,me,Ue,Qe,Ze){const Je=ue.current[me];if(Je){const{ref:{value:Ge,disabled:He},ref:Xe,valueAsNumber:$e,valueAsDate:Ke,setValueAs:nt}=Je;return He&&Qe?void 0:isFileInput(Xe)?Xe.files:isRadioInput(Xe)?getRadioValue(Je.options).value:isMultipleSelect(Xe)?getMultipleSelectValue(Xe.options):isCheckBoxInput(Xe)?getCheckboxValue(Je.options).value:Ze?Ge:$e?Ge===""?NaN:+Ge:Ke?Xe.valueAsDate:nt?nt(Ge):Ge}if(Ue)return get(Ue.current,me)}function isDetached(ue){return ue?!(ue instanceof HTMLElement)||ue.nodeType===Node.DOCUMENT_NODE?!1:isDetached(ue.parentNode):!0}var isEmptyObject=ue=>isObject$4(ue)&&!Object.keys(ue).length,isBoolean=ue=>typeof ue=="boolean";function baseGet(ue,me){const Ue=me.slice(0,-1).length;let Qe=0;for(;Qe<Ue;)ue=isUndefined$1(ue)?Qe++:ue[me[Qe++]];return ue}function unset(ue,me){const Ue=isKey(me)?[me]:stringToPath(me),Qe=Ue.length==1?ue:baseGet(ue,Ue),Ze=Ue[Ue.length-1];let Je;Qe&&delete Qe[Ze];for(let Ge=0;Ge<Ue.slice(0,-1).length;Ge++){let He=-1,Xe;const $e=Ue.slice(0,-(Ge+1)),Ke=$e.length-1;for(Ge>0&&(Je=ue);++He<$e.length;){const nt=$e[He];Xe=Xe?Xe[nt]:ue[nt],Ke===He&&(isObject$4(Xe)&&isEmptyObject(Xe)||Array.isArray(Xe)&&!Xe.filter(tt=>isObject$4(tt)&&!isEmptyObject(tt)||isBoolean(tt)).length)&&(Je?delete Je[nt]:delete ue[nt]),Je=Xe}}return ue}const isSameRef=(ue,me)=>ue&&ue.ref===me;function findRemovedFieldAndRemoveListener(ue,me,Ue,Qe,Ze,Je){const{ref:Ge,ref:{name:He}}=Ue,Xe=ue.current[He];if(!Ze){const $e=getFieldValue(ue,He,Qe);!isUndefined$1($e)&&set(Qe.current,He,$e)}if(!Ge.type||!Xe){delete ue.current[He];return}isRadioInput(Ge)||isCheckBoxInput(Ge)?Array.isArray(Xe.options)&&Xe.options.length?(compact(Xe.options).forEach(($e={},Ke)=>{(isDetached($e.ref)&&isSameRef($e,$e.ref)||Je)&&(removeAllEventListeners($e.ref,me),unset(Xe.options,`[${Ke}]`))}),Xe.options&&!compact(Xe.options).length&&delete ue.current[He]):delete ue.current[He]:(isDetached(Ge)&&isSameRef(Xe,Ge)||Je)&&(removeAllEventListeners(Ge,me),delete ue.current[He])}var isPrimitive=ue=>isNullOrUndefined(ue)||!isObjectType(ue);function deepMerge(ue,me){if(isPrimitive(ue)||isPrimitive(me))return me;for(const Ue in me){const Qe=ue[Ue],Ze=me[Ue];try{ue[Ue]=isObject$4(Qe)&&isObject$4(Ze)||Array.isArray(Qe)&&Array.isArray(Ze)?deepMerge(Qe,Ze):Ze}catch{}}return ue}function deepEqual(ue,me,Ue){if(isPrimitive(ue)||isPrimitive(me)||ue instanceof Date||me instanceof Date)return ue===me;if(!React$1.isValidElement(ue)){const Qe=Object.keys(ue),Ze=Object.keys(me);if(Qe.length!==Ze.length)return!1;for(const Je of Qe){const Ge=ue[Je];if(!(Ue&&Je==="ref")){const He=me[Je];if((isObject$4(Ge)||Array.isArray(Ge))&&(isObject$4(He)||Array.isArray(He))?!deepEqual(Ge,He,Ue):Ge!==He)return!1}}}return!0}function setDirtyFields(ue,me,Ue,Qe,Ze){let Je=-1;for(;++Je<ue.length;){for(const Ge in ue[Je])Array.isArray(ue[Je][Ge])?(!Ue[Je]&&(Ue[Je]={}),Ue[Je][Ge]=[],setDirtyFields(ue[Je][Ge],get(me[Je]||{},Ge,[]),Ue[Je][Ge],Ue[Je],Ge)):deepEqual(get(me[Je]||{},Ge),ue[Je][Ge])?set(Ue[Je]||{},Ge):Ue[Je]=Object.assign(Object.assign({},Ue[Je]),{[Ge]:!0});Qe&&!Ue.length&&delete Qe[Ze]}return Ue}var setFieldArrayDirtyFields=(ue,me,Ue)=>deepMerge(setDirtyFields(ue,me,Ue.slice(0,ue.length)),setDirtyFields(me,ue,Ue.slice(0,ue.length))),isString$2=ue=>typeof ue=="string",getFieldsValues=(ue,me,Ue,Qe,Ze)=>{const Je={};for(const Ge in ue.current)(isUndefined$1(Ze)||(isString$2(Ze)?Ge.startsWith(Ze):Array.isArray(Ze)&&Ze.find(He=>Ge.startsWith(He))))&&(Je[Ge]=getFieldValue(ue,Ge,void 0,Qe));return Ue?transformToNestObject(Je):deepMerge(me,transformToNestObject(Je))},isErrorStateChanged=({errors:ue,name:me,error:Ue,validFields:Qe,fieldsWithValidation:Ze})=>{const Je=isUndefined$1(Ue),Ge=get(ue,me);return Je&&!!Ge||!Je&&!deepEqual(Ge,Ue,!0)||Je&&get(Ze,me)&&!get(Qe,me)},isRegex=ue=>ue instanceof RegExp,getValueAndMessage=ue=>isObject$4(ue)&&!isRegex(ue)?ue:{value:ue,message:""},isFunction$1=ue=>typeof ue=="function",isMessage=ue=>isString$2(ue)||React$1.isValidElement(ue);function getValidateError(ue,me,Ue="validate"){if(isMessage(ue)||isBoolean(ue)&&!ue)return{type:Ue,message:isMessage(ue)?ue:"",ref:me}}var appendErrors=(ue,me,Ue,Qe,Ze)=>me?Object.assign(Object.assign({},Ue[ue]),{types:Object.assign(Object.assign({},Ue[ue]&&Ue[ue].types?Ue[ue].types:{}),{[Qe]:Ze||!0})}):{},validateField=async(ue,me,{ref:Ue,ref:{value:Qe},options:Ze,required:Je,maxLength:Ge,minLength:He,min:Xe,max:$e,pattern:Ke,validate:nt},tt)=>{const et=Ue.name,rt={},at=isRadioInput(Ue),ot=isCheckBoxInput(Ue),it=at||ot,st=Qe==="",ct=appendErrors.bind(null,et,me,rt),lt=(dt,ft,gt,ht=INPUT_VALIDATION_RULES.maxLength,vt=INPUT_VALIDATION_RULES.minLength)=>{const Rt=dt?ft:gt;rt[et]=Object.assign({type:dt?ht:vt,message:Rt,ref:Ue},ct(dt?ht:vt,Rt))};if(Je&&(!at&&!ot&&(st||isNullOrUndefined(Qe))||isBoolean(Qe)&&!Qe||ot&&!getCheckboxValue(Ze).isValid||at&&!getRadioValue(Ze).isValid)){const{value:dt,message:ft}=isMessage(Je)?{value:!!Je,message:Je}:getValueAndMessage(Je);if(dt&&(rt[et]=Object.assign({type:INPUT_VALIDATION_RULES.required,message:ft,ref:it?((ue.current[et].options||[])[0]||{}).ref:Ue},ct(INPUT_VALIDATION_RULES.required,ft)),!me))return rt}if((!isNullOrUndefined(Xe)||!isNullOrUndefined($e))&&Qe!==""){let dt,ft;const gt=getValueAndMessage($e),ht=getValueAndMessage(Xe);if(isNaN(Qe)){const vt=Ue.valueAsDate||new Date(Qe);isString$2(gt.value)&&(dt=vt>new Date(gt.value)),isString$2(ht.value)&&(ft=vt<new Date(ht.value))}else{const vt=Ue.valueAsNumber||parseFloat(Qe);isNullOrUndefined(gt.value)||(dt=vt>gt.value),isNullOrUndefined(ht.value)||(ft=vt<ht.value)}if((dt||ft)&&(lt(!!dt,gt.message,ht.message,INPUT_VALIDATION_RULES.max,INPUT_VALIDATION_RULES.min),!me))return rt}if(isString$2(Qe)&&!st&&(Ge||He)){const dt=getValueAndMessage(Ge),ft=getValueAndMessage(He),gt=!isNullOrUndefined(dt.value)&&Qe.length>dt.value,ht=!isNullOrUndefined(ft.value)&&Qe.length<ft.value;if((gt||ht)&&(lt(gt,dt.message,ft.message),!me))return rt}if(isString$2(Qe)&&Ke&&!st){const{value:dt,message:ft}=getValueAndMessage(Ke);if(isRegex(dt)&&!dt.test(Qe)&&(rt[et]=Object.assign({type:INPUT_VALIDATION_RULES.pattern,message:ft,ref:Ue},ct(INPUT_VALIDATION_RULES.pattern,ft)),!me))return rt}if(nt){const dt=getFieldValue(ue,et,tt,!1,!0),ft=it&&Ze?Ze[0].ref:Ue;if(isFunction$1(nt)){const gt=await nt(dt),ht=getValidateError(gt,ft);if(ht&&(rt[et]=Object.assign(Object.assign({},ht),ct(INPUT_VALIDATION_RULES.validate,ht.message)),!me))return rt}else if(isObject$4(nt)){let gt={};for(const[ht,vt]of Object.entries(nt)){if(!isEmptyObject(gt)&&!me)break;const Rt=await vt(dt),bt=getValidateError(Rt,ft,ht);bt&&(gt=Object.assign(Object.assign({},bt),ct(ht,bt.message)),me&&(rt[et]=gt))}if(!isEmptyObject(gt)&&(rt[et]=Object.assign({ref:ft},gt),!me))return rt}}return rt};const getPath=(ue,me,Ue=[])=>{for(const Qe in me){const Ze=ue+(isObject$4(me)?`.${Qe}`:`[${Qe}]`);isPrimitive(me[Qe])?Ue.push(Ze):getPath(Ze,me[Qe],Ue)}return Ue};var assignWatchFields=(ue,me,Ue,Qe,Ze)=>{let Je;return Ue.add(me),isEmptyObject(ue)||(Je=get(ue,me),(isObject$4(Je)||Array.isArray(Je))&&getPath(me,Je).forEach(Ge=>Ue.add(Ge))),isUndefined$1(Je)?Ze?Qe:get(Qe,me):Je},skipValidation=({isOnBlur:ue,isOnChange:me,isOnTouch:Ue,isTouched:Qe,isReValidateOnBlur:Ze,isReValidateOnChange:Je,isBlurEvent:Ge,isSubmitted:He,isOnAll:Xe})=>Xe?!1:!He&&Ue?!(Qe||Ge):(He?Ze:ue)?!Ge:(He?Je:me)?Ge:!0,getFieldArrayParentName=ue=>ue.substring(0,ue.indexOf("["));const isMatchFieldArrayName=(ue,me)=>RegExp(`^${me}([|.)\\d+`.replace(/\[/g,"\\[").replace(/\]/g,"\\]")).test(ue);var isNameInFieldArray=(ue,me)=>[...ue].some(Ue=>isMatchFieldArrayName(me,Ue)),isSelectInput=ue=>ue.type===`${SELECT}-one`;function onDomRemove(ue,me){const Ue=new MutationObserver(()=>{for(const Qe of Object.values(ue.current))if(Qe&&Qe.options)for(const Ze of Qe.options)Ze&&Ze.ref&&isDetached(Ze.ref)&&me(Qe);else Qe&&isDetached(Qe.ref)&&me(Qe)});return Ue.observe(window.document,{childList:!0,subtree:!0}),Ue}var isWeb=typeof window!==UNDEFINED&&typeof document!==UNDEFINED;function cloneObject(ue){var me;let Ue;if(isPrimitive(ue)||isWeb&&(ue instanceof File||isHTMLElement(ue))||!["Set","Map","Object","Date","Array"].includes((me=ue.constructor)===null||me===void 0?void 0:me.name))return ue;if(ue instanceof Date)return Ue=new Date(ue.getTime()),Ue;if(ue instanceof Set){Ue=new Set;for(const Qe of ue)Ue.add(Qe);return Ue}if(ue instanceof Map){Ue=new Map;for(const Qe of ue.keys())Ue.set(Qe,cloneObject(ue.get(Qe)));return Ue}Ue=Array.isArray(ue)?[]:{};for(const Qe in ue)Ue[Qe]=cloneObject(ue[Qe]);return Ue}var modeChecker=ue=>({isOnSubmit:!ue||ue===VALIDATION_MODE.onSubmit,isOnBlur:ue===VALIDATION_MODE.onBlur,isOnChange:ue===VALIDATION_MODE.onChange,isOnAll:ue===VALIDATION_MODE.all,isOnTouch:ue===VALIDATION_MODE.onTouched}),isRadioOrCheckboxFunction=ue=>isRadioInput(ue)||isCheckBoxInput(ue);const isWindowUndefined=typeof window===UNDEFINED,isProxyEnabled=isWeb?"Proxy"in window:typeof Proxy!==UNDEFINED;function useForm({mode:ue=VALIDATION_MODE.onSubmit,reValidateMode:me=VALIDATION_MODE.onChange,resolver:Ue,context:Qe,defaultValues:Ze={},shouldFocusError:Je=!0,shouldUnregister:Ge=!0,criteriaMode:He}={}){const Xe=React$1.useRef({}),$e=React$1.useRef({}),Ke=React$1.useRef({}),nt=React$1.useRef(new Set),tt=React$1.useRef({}),et=React$1.useRef({}),rt=React$1.useRef({}),at=React$1.useRef({}),ot=React$1.useRef(Ze),it=React$1.useRef(!1),st=React$1.useRef(!1),ct=React$1.useRef(),lt=React$1.useRef({}),dt=React$1.useRef({}),ft=React$1.useRef(Qe),gt=React$1.useRef(Ue),ht=React$1.useRef(new Set),vt=React$1.useRef(modeChecker(ue)),{isOnSubmit:Rt,isOnTouch:bt}=vt.current,At=He===VALIDATION_MODE.all,[Nt,mt]=React$1.useState({isDirty:!1,isValidating:!1,dirtyFields:{},isSubmitted:!1,submitCount:0,touched:{},isSubmitting:!1,isSubmitSuccessful:!1,isValid:!Rt,errors:{}}),It=React$1.useRef({isDirty:!isProxyEnabled,dirtyFields:!isProxyEnabled,touched:!isProxyEnabled||bt,isValidating:!isProxyEnabled,isSubmitting:!isProxyEnabled,isValid:!isProxyEnabled}),yt=React$1.useRef(Nt),Mt=React$1.useRef(),{isOnBlur:St,isOnChange:xt}=React$1.useRef(modeChecker(me)).current;ft.current=Qe,gt.current=Ue,yt.current=Nt,lt.current=Ge?{}:isEmptyObject(lt.current)?cloneObject(Ze):lt.current;const Ut=React$1.useCallback((Ht={})=>{it.current||(yt.current=Object.assign(Object.assign({},yt.current),Ht),mt(yt.current))},[]),Ft=()=>It.current.isValidating&&Ut({isValidating:!0}),wt=React$1.useCallback((Ht,Kt,rn=!1,ln={},an)=>{let mn=rn||isErrorStateChanged({errors:yt.current.errors,error:Kt,name:Ht,validFields:at.current,fieldsWithValidation:rt.current});const yn=get(yt.current.errors,Ht);Kt?(unset(at.current,Ht),mn=mn||!yn||!deepEqual(yn,Kt,!0),set(yt.current.errors,Ht,Kt)):((get(rt.current,Ht)||gt.current)&&(set(at.current,Ht,!0),mn=mn||yn),unset(yt.current.errors,Ht)),(mn&&!isNullOrUndefined(rn)||!isEmptyObject(ln)||It.current.isValidating)&&Ut(Object.assign(Object.assign(Object.assign({},ln),gt.current?{isValid:!!an}:{}),{isValidating:!1}))},[]),Ct=React$1.useCallback((Ht,Kt)=>{const{ref:rn,options:ln}=Xe.current[Ht],an=isWeb&&isHTMLElement(rn)&&isNullOrUndefined(Kt)?"":Kt;isRadioInput(rn)?(ln||[]).forEach(({ref:mn})=>mn.checked=mn.value===an):isFileInput(rn)&&!isString$2(an)?rn.files=an:isMultipleSelect(rn)?[...rn.options].forEach(mn=>mn.selected=an.includes(mn.value)):isCheckBoxInput(rn)&&ln?ln.length>1?ln.forEach(({ref:mn})=>mn.checked=Array.isArray(an)?!!an.find(yn=>yn===mn.value):an===mn.value):ln[0].ref.checked=!!an:rn.value=an},[]),Zt=React$1.useCallback((Ht,Kt)=>{if(It.current.isDirty){const rn=Ot();return Ht&&Kt&&set(rn,Ht,Kt),!deepEqual(rn,ot.current)}return!1},[]),Jt=React$1.useCallback((Ht,Kt=!0)=>{if(It.current.isDirty||It.current.dirtyFields){const rn=!deepEqual(get(ot.current,Ht),getFieldValue(Xe,Ht,lt)),ln=get(yt.current.dirtyFields,Ht),an=yt.current.isDirty;rn?set(yt.current.dirtyFields,Ht,!0):unset(yt.current.dirtyFields,Ht);const mn={isDirty:Zt(),dirtyFields:yt.current.dirtyFields},yn=It.current.isDirty&&an!==mn.isDirty||It.current.dirtyFields&&ln!==get(yt.current.dirtyFields,Ht);return yn&&Kt&&Ut(mn),yn?mn:{}}return{}},[]),Qt=React$1.useCallback(async(Ht,Kt)=>{if(process.env.NODE_ENV!=="production"&&!Xe.current[Ht])return console.warn("📋 Field is missing with `name` attribute: ",Ht),!1;const rn=(await validateField(Xe,At,Xe.current[Ht],lt))[Ht];return wt(Ht,rn,Kt),isUndefined$1(rn)},[wt,At]),$t=React$1.useCallback(async Ht=>{const{errors:Kt}=await gt.current(Ot(),ft.current,At),rn=yt.current.isValid;if(Array.isArray(Ht)){const ln=Ht.map(an=>{const mn=get(Kt,an);return mn?set(yt.current.errors,an,mn):unset(yt.current.errors,an),!mn}).every(Boolean);return Ut({isValid:isEmptyObject(Kt),isValidating:!1}),ln}else{const ln=get(Kt,Ht);return wt(Ht,ln,rn!==isEmptyObject(Kt),{},isEmptyObject(Kt)),!ln}},[wt,At]),Gt=React$1.useCallback(async Ht=>{const Kt=Ht||Object.keys(Xe.current);if(Ft(),gt.current)return $t(Kt);if(Array.isArray(Kt)){!Ht&&(yt.current.errors={});const rn=await Promise.all(Kt.map(async ln=>await Qt(ln,null)));return Ut({isValidating:!1}),rn.every(Boolean)}return await Qt(Kt)},[$t,Qt]),Pt=React$1.useCallback((Ht,Kt,{shouldDirty:rn,shouldValidate:ln})=>{const an={};set(an,Ht,Kt);for(const mn of getPath(Ht,Kt))Xe.current[mn]&&(Ct(mn,get(an,mn)),rn&&Jt(mn),ln&&Gt(mn))},[Gt,Ct,Jt]),jt=React$1.useCallback((Ht,Kt,rn)=>{if(!Ge&&!isPrimitive(Kt)&&set(lt.current,Ht,Array.isArray(Kt)?[...Kt]:Object.assign({},Kt)),Xe.current[Ht])Ct(Ht,Kt),rn.shouldDirty&&Jt(Ht),rn.shouldValidate&&Gt(Ht);else if(!isPrimitive(Kt)&&(Pt(Ht,Kt,rn),ht.current.has(Ht))){const ln=getFieldArrayParentName(Ht)||Ht;set($e.current,Ht,Kt),dt.current[ln]({[ln]:get($e.current,ln)}),(It.current.isDirty||It.current.dirtyFields)&&rn.shouldDirty&&(set(yt.current.dirtyFields,Ht,setFieldArrayDirtyFields(Kt,get(ot.current,Ht,[]),get(yt.current.dirtyFields,Ht,[]))),Ut({isDirty:!deepEqual(Object.assign(Object.assign({},Ot()),{[Ht]:Kt}),ot.current)}))}!Ge&&set(lt.current,Ht,Kt)},[Jt,Ct,Pt]),Dt=Ht=>st.current||nt.current.has(Ht)||nt.current.has((Ht.match(/\w+/)||[])[0]),ut=Ht=>{let Kt=!0;if(!isEmptyObject(tt.current))for(const rn in tt.current)(!Ht||!tt.current[rn].size||tt.current[rn].has(Ht)||tt.current[rn].has(getFieldArrayParentName(Ht)))&&(et.current[rn](),Kt=!1);return Kt};function Et(Ht,Kt,rn){jt(Ht,Kt,rn||{}),Dt(Ht)&&Ut(),ut(Ht)}ct.current=ct.current?ct.current:async({type:Ht,target:Kt})=>{let rn=Kt.name;const ln=Xe.current[rn];let an,mn;if(ln){const yn=Ht===EVENTS.BLUR,bn=skipValidation(Object.assign({isBlurEvent:yn,isReValidateOnChange:xt,isReValidateOnBlur:St,isTouched:!!get(yt.current.touched,rn),isSubmitted:yt.current.isSubmitted},vt.current));let Cn=Jt(rn,!1),Bn=!isEmptyObject(Cn)||!yn&&Dt(rn);if(yn&&!get(yt.current.touched,rn)&&It.current.touched&&(set(yt.current.touched,rn,!0),Cn=Object.assign(Object.assign({},Cn),{touched:yt.current.touched})),!Ge&&isCheckBoxInput(Kt)&&set(lt.current,rn,getFieldValue(Xe,rn)),bn)return!yn&&ut(rn),(!isEmptyObject(Cn)||Bn&&isEmptyObject(Cn))&&Ut(Cn);if(Ft(),gt.current){const{errors:wn}=await gt.current(Ot(),ft.current,At),Dn=yt.current.isValid;if(an=get(wn,rn),isCheckBoxInput(Kt)&&!an&&gt.current){const Wn=getFieldArrayParentName(rn),kn=get(wn,Wn,{});kn.type&&kn.message&&(an=kn),Wn&&(kn||get(yt.current.errors,Wn))&&(rn=Wn)}mn=isEmptyObject(wn),Dn!==mn&&(Bn=!0)}else an=(await validateField(Xe,At,ln,lt))[rn];!yn&&ut(rn),wt(rn,an,Bn,Cn,mn)}};function Vt(Ht){if(!Ge){let Kt=cloneObject(Ht);for(const rn of ht.current)isKey(rn)&&!Kt[rn]&&(Kt=Object.assign(Object.assign({},Kt),{[rn]:[]}));return Kt}return Ht}function Ot(Ht){if(isString$2(Ht))return getFieldValue(Xe,Ht,lt);if(Array.isArray(Ht)){const Kt={};for(const rn of Ht)set(Kt,rn,getFieldValue(Xe,rn,lt));return Kt}return Vt(getFieldsValues(Xe,cloneObject(lt.current),Ge))}const Lt=React$1.useCallback(async(Ht={})=>{const Kt=isEmptyObject(Xe.current)?ot.current:{},{errors:rn}=await gt.current(Object.assign(Object.assign(Object.assign({},Kt),Ot()),Ht),ft.current,At)||{},ln=isEmptyObject(rn);yt.current.isValid!==ln&&Ut({isValid:ln})},[At]),zt=React$1.useCallback((Ht,Kt)=>{findRemovedFieldAndRemoveListener(Xe,ct.current,Ht,lt,Ge,Kt),Ge&&(unset(at.current,Ht.ref.name),unset(rt.current,Ht.ref.name))},[Ge]),Xt=React$1.useCallback(Ht=>{if(st.current)Ut();else{for(const Kt of nt.current)if(Kt.startsWith(Ht)){Ut();break}ut(Ht)}},[]),Yt=React$1.useCallback((Ht,Kt)=>{Ht&&(zt(Ht,Kt),Ge&&!compact(Ht.options||[]).length&&(unset(yt.current.errors,Ht.ref.name),set(yt.current.dirtyFields,Ht.ref.name,!0),Ut({isDirty:Zt()}),It.current.isValid&&gt.current&&Lt(),Xt(Ht.ref.name)))},[Lt,zt]);function sn(Ht){Ht&&(Array.isArray(Ht)?Ht:[Ht]).forEach(Kt=>Xe.current[Kt]&&isKey(Kt)?delete yt.current.errors[Kt]:unset(yt.current.errors,Kt)),Ut({errors:Ht?yt.current.errors:{}})}function cn(Ht,Kt){const rn=(Xe.current[Ht]||{}).ref;set(yt.current.errors,Ht,Object.assign(Object.assign({},Kt),{ref:rn})),Ut({isValid:!1}),Kt.shouldFocus&&rn&&rn.focus&&rn.focus()}const pn=React$1.useCallback((Ht,Kt,rn)=>{const ln=rn?tt.current[rn]:nt.current;let an=getFieldsValues(Xe,cloneObject(lt.current),Ge,!1,Ht);if(isString$2(Ht)){const yn=getFieldArrayParentName(Ht)||Ht;return ht.current.has(yn)&&(an=Object.assign(Object.assign({},Ke.current),an)),assignWatchFields(an,Ht,ln,isUndefined$1(get(ot.current,Ht))?Kt:get(ot.current,Ht),!0)}const mn=isUndefined$1(Kt)?ot.current:Kt;return Array.isArray(Ht)?Ht.reduce((yn,bn)=>Object.assign(Object.assign({},yn),{[bn]:assignWatchFields(an,bn,ln,mn)}),{}):(st.current=isUndefined$1(rn),transformToNestObject(!isEmptyObject(an)&&an||mn))},[]);function vn(Ht,Kt){return pn(Ht,Kt)}function Tn(Ht){for(const Kt of Array.isArray(Ht)?Ht:[Ht])Yt(Xe.current[Kt],!0)}function tn(Ht,Kt={}){if(process.env.NODE_ENV!=="production"){if(!Ht.name)return console.warn("📋 Field is missing `name` attribute",Ht,"https://react-hook-form.com/api#useForm");if(ht.current.has(Ht.name.split(/\[\d+\]$/)[0])&&!RegExp(`^${Ht.name.split(/\[\d+\]$/)[0]}[\\d+].\\w+`.replace(/\[/g,"\\[").replace(/\]/g,"\\]")).test(Ht.name))return console.warn('📋 `name` prop should be in object shape: name="test[index].name"',Ht,"https://react-hook-form.com/api#useFieldArray")}const{name:rn,type:ln,value:an}=Ht,mn=Object.assign({ref:Ht},Kt),yn=Xe.current,bn=isRadioOrCheckboxFunction(Ht),Cn=isNameInFieldArray(ht.current,rn),Bn=jn=>isWeb&&(!isHTMLElement(Ht)||jn===Ht);let wn=yn[rn],Dn=!0,Wn;if(wn&&(bn?Array.isArray(wn.options)&&compact(wn.options).find(jn=>an===jn.ref.value&&Bn(jn.ref)):Bn(wn.ref))){yn[rn]=Object.assign(Object.assign({},wn),Kt);return}ln?wn=bn?Object.assign({options:[...compact(wn&&wn.options||[]),{ref:Ht}],ref:{type:ln,name:rn}},Kt):Object.assign({},mn):wn=mn,yn[rn]=wn;const kn=isUndefined$1(get(lt.current,rn));(!isEmptyObject(ot.current)||!kn)&&(Wn=get(kn?ot.current:lt.current,rn),Dn=isUndefined$1(Wn),!Dn&&!Cn&&Ct(rn,Wn)),isEmptyObject(Kt)||(set(rt.current,rn,!0),!Rt&&It.current.isValid&&validateField(Xe,At,wn,lt).then(jn=>{const Pn=yt.current.isValid;isEmptyObject(jn)?set(at.current,rn,!0):unset(at.current,rn),Pn!==isEmptyObject(jn)&&Ut()})),Ge&&!(Cn&&Dn)&&!Cn&&unset(yt.current.dirtyFields,rn),ln&&attachEventListeners(bn&&wn.options?wn.options[wn.options.length-1]:wn,bn||isSelectInput(Ht),ct.current)}function dn(Ht,Kt){if(!isWindowUndefined)if(isString$2(Ht))tn({name:Ht},Kt);else if(isObject$4(Ht)&&"name"in Ht)tn(Ht,Kt);else return rn=>rn&&tn(rn,Ht)}const fn=React$1.useCallback((Ht,Kt)=>async rn=>{rn&&rn.preventDefault&&(rn.preventDefault(),rn.persist());let ln={},an=Vt(getFieldsValues(Xe,cloneObject(lt.current),Ge,!0));It.current.isSubmitting&&Ut({isSubmitting:!0});try{if(gt.current){const{errors:mn,values:yn}=await gt.current(an,ft.current,At);yt.current.errors=ln=mn,an=yn}else for(const mn of Object.values(Xe.current))if(mn){const{name:yn}=mn.ref,bn=await validateField(Xe,At,mn,lt);bn[yn]?(set(ln,yn,bn[yn]),unset(at.current,yn)):get(rt.current,yn)&&(unset(yt.current.errors,yn),set(at.current,yn,!0))}isEmptyObject(ln)&&Object.keys(yt.current.errors).every(mn=>mn in Xe.current)?(Ut({errors:{},isSubmitting:!0}),await Ht(an,rn)):(yt.current.errors=Object.assign(Object.assign({},yt.current.errors),ln),Kt&&await Kt(yt.current.errors,rn),Je&&focusOnErrorField(Xe.current,yt.current.errors))}finally{yt.current.isSubmitting=!1,Ut({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:isEmptyObject(yt.current.errors),submitCount:yt.current.submitCount+1})}},[Je,At]),Mn=({errors:Ht,isDirty:Kt,isSubmitted:rn,touched:ln,isValid:an,submitCount:mn,dirtyFields:yn})=>{an||(at.current={},rt.current={}),$e.current={},nt.current=new Set,st.current=!1,Ut({submitCount:mn?yt.current.submitCount:0,isDirty:Kt?yt.current.isDirty:!1,isSubmitted:rn?yt.current.isSubmitted:!1,isValid:an?yt.current.isValid:!1,dirtyFields:yn?yt.current.dirtyFields:{},touched:ln?yt.current.touched:{},errors:Ht?yt.current.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})},un=(Ht,Kt={})=>{if(isWeb){for(const rn of Object.values(Xe.current))if(rn){const{ref:ln,options:an}=rn,mn=isRadioOrCheckboxFunction(ln)&&Array.isArray(an)?an[0].ref:ln;if(isHTMLElement(mn))try{mn.closest("form").reset();break}catch{}}}Xe.current={},ot.current=Object.assign({},Ht||ot.current),Ht&&ut(""),Object.values(dt.current).forEach(rn=>isFunction$1(rn)&&rn()),lt.current=Ge?{}:cloneObject(Ht||ot.current),Mn(Kt)};React$1.useEffect(()=>{Ue&&It.current.isValid&&Lt(),Mt.current=Mt.current||!isWeb?Mt.current:onDomRemove(Xe,Yt)},[Yt,ot.current]),React$1.useEffect(()=>()=>{Mt.current&&Mt.current.disconnect(),it.current=!0,process.env.NODE_ENV==="production"&&Object.values(Xe.current).forEach(Ht=>Yt(Ht,!0))},[]),!Ue&&It.current.isValid&&(Nt.isValid=deepEqual(at.current,rt.current)&&isEmptyObject(yt.current.errors));const hn={trigger:Gt,setValue:React$1.useCallback(Et,[jt,Gt]),getValues:React$1.useCallback(Ot,[]),register:React$1.useCallback(dn,[ot.current]),unregister:React$1.useCallback(Tn,[]),formState:isProxyEnabled?new Proxy(Nt,{get:(Ht,Kt)=>{if(process.env.NODE_ENV!=="production"&&Kt==="isValid"&&Rt&&console.warn("📋 `formState.isValid` is applicable with `onTouched`, `onChange` or `onBlur` mode. https://react-hook-form.com/api#formState"),Kt in Ht)return It.current[Kt]=!0,Ht[Kt]}}):Nt},en=React$1.useMemo(()=>Object.assign({isFormDirty:Zt,updateWatchedValue:Xt,shouldUnregister:Ge,updateFormState:Ut,removeFieldEventListener:zt,watchInternal:pn,mode:vt.current,reValidateMode:{isReValidateOnBlur:St,isReValidateOnChange:xt},validateResolver:Ue?Lt:void 0,fieldsRef:Xe,resetFieldArrayFunctionRef:dt,useWatchFieldsRef:tt,useWatchRenderFunctionsRef:et,fieldArrayDefaultValuesRef:$e,validFieldsRef:at,fieldsWithValidationRef:rt,fieldArrayNamesRef:ht,readFormStateRef:It,formStateRef:yt,defaultValuesRef:ot,shallowFieldsStateRef:lt,fieldArrayValuesRef:Ke},hn),[ot.current,Xt,Ge,zt,pn]);return Object.assign({watch:vn,control:en,handleSubmit:fn,reset:React$1.useCallback(un,[]),clearErrors:React$1.useCallback(sn,[]),setError:React$1.useCallback(cn,[]),errors:Nt.errors},hn)}/*! *****************************************************************************
2561
2561
  Copyright (c) Microsoft Corporation.
2562
2562
 
2563
2563
  Permission to use, copy, modify, and/or distribute this software for any
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "main": "./dist/onBoarding.umd.js",
4
4
  "module": "./dist/onBoarding.mjs",
5
5
  "types": "./dist/incode-welcome/src/index.d.ts",
6
- "version": "1.71.0-20240430151632.0",
6
+ "version": "1.71.0-20240430161557.0",
7
7
  "publishConfig": {},
8
8
  "exports": {
9
9
  ".": {