@incodetech/welcome 1.71.0-20240419161640.0 → 1.71.0-20240419164253.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -17914,7 +17914,7 @@ const SelfieFaceDetectionPipelineParams = {
17914
17914
  null,
17915
17915
  "Selfie face detection profile"
17916
17916
  )
17917
- }, probabilityThreshold = 0.9, wasmVersion = "v1.7.5", brazilianPipelineBundle = [
17917
+ }, probabilityThreshold = 0.9, wasmVersion = "v1.7.6", brazilianPipelineBundle = [
17918
17918
  PipelineProfileType.IdCaptureBrazilian,
17919
17919
  PipelineProfileType.IdVideoSelfieBrazilian,
17920
17920
  PipelineProfileType.SelfieFaceDetection
@@ -38218,7 +38218,7 @@ function renderUserConsent(ue, {
38218
38218
  })
38219
38219
  }), ue, He);
38220
38220
  }
38221
- const version = "1.71.0-20240419161640.0";
38221
+ const version = "1.71.0-20240419164253.0";
38222
38222
  function r(ue) {
38223
38223
  for (var me = "", Ue = 0; Ue < ue.length; ++Ue)
38224
38224
  if (Ue > 0) {
@@ -937,7 +937,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
937
937
  overflow: hidden;
938
938
  opacity: 0.7;
939
939
  white-space: nowrap;
940
- `;function copyLink(){const ue=window.location.href;navigator.clipboard.writeText(ue)}const isAppleDevice=mobile.isAppleDevice();function BrowserNotSupported({onContinue:ue,token:me}){const{t:Ue}=useTranslation();React$1.useEffect(()=>{me&&addEvent({token:me,code:"pageWasRenderedToUser",screen:"Unsupported Browser"})},[me]);const Qe=()=>{copyLink(),me&&addEvent({token:me,code:"userClickedCopyLink",screen:"Unsupported Browser"})},Ze=()=>{me&&addEvent({token:me,code:"userClickedContinueAnyway",screen:"Unsupported Browser"}),ue()};return jsxs(BrowserNotSupportedContainer,{className:"IncodeBrowserNotSupporterContainer",children:[jsxs("div",{className:"BrowserNotSupportedTopContainer",children:[jsx(Image$a,{src:BrowserNotSupportedIcon,alt:"browser not supported",className:"IncodeBrowserNotSupporterImage"}),jsx("h2",{className:"IncodeBrowserNotSupporterTitle",children:Ue("unsupportedBrowser.title")}),jsxs(Text$7,{className:"IncodeBrowserNotSupporterTextFirst",children:[Ue("unsupportedBrowser.betterExperience")," ",isAppleDevice&&jsxs(Fragment,{children:[jsx(Blue$1,{children:"Safari"})," or"," "]}),jsx(Blue$1,{children:"Chrome"})]})]}),jsxs(BrowserNotSupportedBottomContainer,{className:"BrowserNotSupportedBottomContainer",children:[jsx(LinkText,{className:"IncodeBrowserNotSupporterLinkText",children:window.location.href}),jsx("div",{children:jsx(Button$9,{onClick:Qe,type:"button",className:"IncodeBrowserNotSupporterCopyLinkButton",children:Ue("unsupportedBrowser.copyLink")})}),jsx(ContinueButton,{type:"button",onClick:Ze,className:"IncodeBrowserNotSupporterContinueButton",children:Ue("unsupportedBrowser.continueAnyways")})]})]})}const state={detecting:!0,intervalCounter:0,matchCounter:0,intervalId:null,cascadeLoaded:!1,selfieAttempt:0,selfieGetFrames:0,grabSelfieFrames:!1,frames:[],token:null,facefinderClassifyRegion:()=>-1,skipFrames:!0};class OnboardingCheck{constructor(me,Ue,Qe,Ze,Je,Ge,He,Xe,Ke,$e,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_=Ke,this.maeAccOldThreshold_=$e,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}}let options={darkMode:!1,hostingApp:"Web SDK",unsafeMode:!1,redirectFromUnsupportedBrowsers:!1};const setOptions=ue=>(options={...options,...ue},options);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=null,Je=""){this.pipelineType=me,this.modelNames=Ue,this.parameters=Qe,this.paramsConfigurator=Ze,this.description=Je}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)}}var PipelineType=(ue=>(ue[ue.IdCapturePipeline=0]="IdCapturePipeline",ue[ue.IdVideoSelfiePipeline=1]="IdVideoSelfiePipeline",ue[ue.SelfieFaceDetectionPipeline=2]="SelfieFaceDetectionPipeline",ue[ue.IdFaceDetectionPipeline=3]="IdFaceDetectionPipeline",ue))(PipelineType||{});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={[PipelineProfileType.IdCaptureBrazilian]:new PipelineProfile(PipelineType.IdCapturePipeline,["brazilian_mobile_025_ep199_fp16.ortmodelv2"],{glareThreshold:.2,classificationThreshold:.98,sharpnessThreshold:.3,sharpnessChangeThreshold:.3},IdCaptureParamsConfigurator,"Id Capture Profile with brazilian_mobile model"),[PipelineProfileType.IdCaptureVisas]:new PipelineProfile(PipelineType.IdCapturePipeline,["visas_mobile_025_best_v1_03_fp16.ortmodelv2"],{glareThreshold:.3,classificationThreshold:.98,sharpnessThreshold:.2,sharpnessChangeThreshold:.2},IdCaptureParamsConfigurator,"Id Capture Profile with visas_mobile model"),[PipelineProfileType.IdVideoSelfieBrazilian]:new PipelineProfile(PipelineType.IdVideoSelfiePipeline,["brazilian_mobile_025_ep199_fp16.ortmodelv2"],{glareThreshold:.2,classificationThreshold:.9,sharpnessThreshold:.3,sharpnessChangeThreshold:.3},IdCaptureParamsConfigurator,"Id Videoselfie profile with brazilian_mobile model"),[PipelineProfileType.IdVideoSelfieVisas]:new PipelineProfile(PipelineType.IdVideoSelfiePipeline,["visas_mobile_025_best_v1_03_fp16.ortmodelv2"],{glareThreshold:.3,classificationThreshold:.9,sharpnessThreshold:.2,sharpnessChangeThreshold:.2},IdCaptureParamsConfigurator,"Id Videoselfie Profile with visas_mobile model"),[PipelineProfileType.SelfieFaceDetection]:new PipelineProfile(PipelineType.SelfieFaceDetectionPipeline,["selfie_bf_angles_192x192_opset9_fp16.ortmodelv2","bf_attrib_31b8f9d92fb345c2b4bbdd222792562c_0_fp16.ortmodelv2"],SelfieFaceDetectionPipelineParams,null,"Selfie face detection profile")},probabilityThreshold=.9,wasmVersion="v1.7.5",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,Ke=new Map;for(const $e of PipelinesBundle.get(Ue)){if(!pipelineProfiles[$e])throw new Error(`Pipeline profile ${$e} not found`);const nt=pipelineProfiles[$e],tt=nt.modelNames;let et=[];for(const rt of tt)et.push(`${Qe}/${wasmVersion}/models/${rt}`);Xe.set(nt.pipelineType,et),Ke.set(nt.pipelineType,$e)}return{wasmModulePath:Ze,wasmSimdModulePath:Je,glueCodePath:Ge,versionsFilePath:He,pipelineModels:Xe,pipelineProfileTypes:Ke,enableSIMD:!0,bundle:Ue}}window.wasmArrayBuffer=null;class MlWasmJSApi{constructor(){this.versionsFile=null,this.modelsBuffers=null,this.inputImageBuffer=null,this.wasmModule=null,this.wasmApiHelpers=null,this.idCaptureWasmApi=null,this.faceDetectionWasmApi=null,this.imageWidth_=null,this.imageHeight_=null,this.pipelines_=null,this.isInitialized_=!1,this.Module=null,this.loadModule=async me=>{this.Module=(await import(me)).Module}}async initialize(me,Ue,Qe,Ze,Je,Ge){await this.freeResources(),this.pipelines_=Ge,this.versionsFile=Je,await this.loadModule(Qe),await this.loadWasm(Ze,me,Ue),this.wasmApiHelpers=new this.wasmModule.MlWasmApiHelpers,this.idCaptureWasmApi=new this.wasmModule.IdCaptureWasmApi,this.faceDetectionWasmApi=new this.wasmModule.FaceDetectionWasmApi,this.isInitialized_=!0}isInitialized(){return this.wasmApiHelpers!=null&&this.idCaptureWasmApi!=null&&this.faceDetectionWasmApi!=null&&this.isInitialized_}async allocateImageBuffers(me,Ue){this.checkWasmInitialization("Unable to allocate image buffers, cpp API hasn't been initialized"),!(me&&Ue&&me==this.imageWidth_&&Ue==this.imageHeight_&&this.inputImageBuffer&&me*Ue*4===this.inputImageBuffer.length)&&(this.imageWidth_=me,this.imageHeight_=Ue,this.inputImageBuffer=this.wasmApiHelpers.allocateInputImageBuffer(me,Ue,4))}async handleDetectionCallAndUpdateState(me){this.checkWasmInitialization("Unable to update pipeline state, cpp API hasn't been initialized"),this.wasmApiHelpers.handleDetectionCallAndUpdateState(this.toWasmEnum(me))}async encryptImage(me){return this.checkWasmInitialization("Unable to encrypt the image, cpp API hasn't been initialized"),this.wasmApiHelpers.encryptImage(me)}isVirtualCamera(me){return this.checkWasmInitialization("Unable to check if the camera is virtual, cpp API hasn't been initialized"),this.wasmApiHelpers.isVirtualCamera(me)}estimatePerformance(){return this.checkWasmInitialization("Unable to estimate performance, cpp API hasn't been initialized"),this.wasmApiHelpers.estimatePerformance()}async analyzeFrame(me){return this.checkWasmInitialization("Unable to analyze the frame, cpp API hasn't been initialized"),await this.allocateImageBuffers(me.width,me.height),this.inputImageBuffer.set(me.data),this.wasmApiHelpers.analyzeFrame()}async freeResources(){this.versionsFile=null,this.modelsBuffers=null,this.inputImageBuffer=null,this.imageWidth_=null,this.imageHeight_=null,this.pipelines_=null,window.wasmArrayBuffer=null,this.wasmApiHelpers&&typeof this.wasmApiHelpers.delete=="function"&&(this.wasmApiHelpers.delete(),this.wasmApiHelpers=null),this.idCaptureWasmApi&&typeof this.idCaptureWasmApi.delete=="function"&&(this.idCaptureWasmApi.delete(),this.idCaptureWasmApi=null),this.faceDetectionWasmApi&&typeof this.faceDetectionWasmApi.delete=="function"&&(this.faceDetectionWasmApi.delete(),this.faceDetectionWasmApi=null),this.wasmModule=null,this.isInitialized_=!1}resetPipeline(me){this.checkWasmInitialization("Unable to reset pipeline, cpp API hasn't been initialized"),this.wasmApiHelpers.resetPipeline(this.toWasmEnum(me))}resetAllPipelines(){this.checkWasmInitialization("Unable to reset pipelines, cpp API hasn't been initialized");for(const[me,Ue]of this.pipelines_)this.resetPipeline(me)}async process(me,Ue){if(this.checkWasmInitialization("Unable to process the image, cpp API hasn't been initialized"),this.inputImageBuffer===null)throw new Error("Unable to process the image, buffers haven't been allocated!");switch(this.inputImageBuffer.set(me.data),Ue){case PipelineType.IdCapturePipeline:return this.idCaptureWasmApi.runIdCapturePipeline();case PipelineType.IdFaceDetectionPipeline:return this.faceDetectionWasmApi.runIdFaceDetectionPipeline();case PipelineType.IdVideoSelfiePipeline:return this.idCaptureWasmApi.runIdVideoSelfiePipeline();case PipelineType.SelfieFaceDetectionPipeline:return this.faceDetectionWasmApi.runSelfieFaceDetectionPipeline();default:throw new Error("Unknown pipeline type")}}async runIdCapture(me){if(this.checkWasmInitialization("Unable to run Id Capture, cpp API hasn't been initialized"),this.inputImageBuffer===null)throw new Error("Unable to process the image, buffers haven't been allocated!");return this.inputImageBuffer.set(me.data),this.idCaptureWasmApi.runIdCapture()}async runSelfieCapture(me){if(this.checkWasmInitialization("Unable to run Selfie Capture, cpp API hasn't been initialized"),this.inputImageBuffer===null)throw new Error("Unable to process the image, buffers haven't been allocated!");return this.inputImageBuffer.set(me.data),this.faceDetectionWasmApi.runSelfieCapture()}async setFacePositionConstraints(me,Ue,Qe,Ze,Je){this.checkWasmInitialization("Unable to set face position constraints, cpp API hasn't been initialized"),this.faceDetectionWasmApi.setFacePositionConstraints(this.toWasmEnum(me),Ue,Qe,Ze,Je)}async setFaceDetectionThresholds(me,Ue,Qe,Ze,Je,Ge){this.checkWasmInitialization("Unable to set face detection thresholds, cpp API hasn't been initialized"),this.faceDetectionWasmApi.setFaceDetectionThresholds(this.toWasmEnum(me),Ue,Qe,Ze,Je,Ge)}async setFaceAttributesThresholds(me,Ue,Qe,Ze,Je){this.checkWasmInitialization("Unable to set face attributes thresholds, cpp API hasn't been initialized"),this.faceDetectionWasmApi.setFaceAttributesThresholds(this.toWasmEnum(me),Ue,Qe,Ze,Je)}async setFaceAttributesEnabled(me,Ue,Qe,Ze,Je){this.checkWasmInitialization("Unable to set face attributes enabled flags, cpp API hasn't been initialized"),this.faceDetectionWasmApi.setFaceAttributesEnabled(this.toWasmEnum(me),Ue,Qe,Ze,Je)}async setFaceDetectionMode(me,Ue){this.checkWasmInitialization("Unable to set face detection mode, cpp API hasn't been initialized"),this.faceDetectionWasmApi.setFaceDetectionMode(this.toWasmEnum(me),Ue)}async setFaceDetectionCallbacks(me,Ue,Qe,Ze,Je,Ge,He,Xe,Ke,$e,nt,tt,et,rt,at,it,ot){this.checkWasmInitialization("Unable to set face detection callbacks, cpp API hasn't been initialized"),this.faceDetectionWasmApi.setFaceDetectionCallbacks(this.toWasmEnum(me),Ue,Qe,Ze,Je,Ge,He,Xe,Ke,$e,nt,tt,et,rt,at,it,ot)}async setIdCaptureThresholds(me,Ue,Qe,Ze,Je,Ge){this.checkWasmInitialization("Unable to set thresholds, cpp API hasn't been initialized"),this.idCaptureWasmApi.setIdCaptureThresholds(this.toWasmEnum(me),Ue,Qe,Ze,Je,Ge)}async setIdCaptureCallbacks(me,Ue,Qe,Ze,Je,Ge,He,Xe,Ke){this.checkWasmInitialization("Unable to set callbacks, cpp API hasn't been initialized"),this.idCaptureWasmApi.setIdCaptureCallbacks(this.toWasmEnum(me),Ue,Qe,Ze,Je,Ge,He,Xe,Ke)}async setIdCaptureGeometryParams(me,Ue,Qe,Ze,Je,Ge,He,Xe,Ke,$e,nt,tt,et){this.checkWasmInitialization("Unable to set geometry params, cpp API hasn't been initialized"),this.idCaptureWasmApi.setIdCaptureGeometryParams(this.toWasmEnum(me),Ue,Qe,Ze,Je,Ge,He,Xe,Ke,$e,nt,tt,et)}async setIdCaptureConfigParams(me,Ue,Qe,Ze,Je,Ge){this.checkWasmInitialization("Unable to set config params, cpp API hasn't been initialized"),this.idCaptureWasmApi.setIdCaptureConfigParams(this.toWasmEnum(me),Ue,Qe,Ze,Je,Ge)}async getVersions(){const Ue=await(await fetch(this.versionsFile)).text();return JSON.parse(Ue)}async loadWasm(me,Ue,Qe){const Ze=me?Qe:Ue;try{window.wasmArrayBuffer=await fetch(Ze).then(Je=>Je.arrayBuffer()).then(Je=>new Uint8Array(Je)),this.wasmModule=await this.Module()}catch(Je){if(console.log(Je,me,"useSmd"),me)await this.loadWasm(!1,Ue,Qe);else throw Je}}async loadModels(){var Ze;this.checkWasmInitialization("Unable load the models, cpp API hasn't been initialized");let me=new this.wasmModule.PipelineTypeToIntMap,Ue=new Map,Qe=new Map;for(let[Je,Ge]of this.pipelines_){let He=this.toWasmEnum(Je),Xe=[],Ke=new this.wasmModule.VectorInt;for(let $e of Ge){if(!Qe.has($e)){let tt=await fetch($e).then(et=>et.arrayBuffer()).then(et=>new Uint8Array(et));Qe.set($e,tt)}let nt=Qe.get($e);Ke.push_back(nt.byteLength),Xe.push(nt)}me.set(He,Ke),Ue.set(He,Xe)}this.modelsBuffers=this.wasmApiHelpers.allocateModelsBuffers(me);for(let[Je,Ge]of Ue){let He=(Ze=this.modelsBuffers)==null?void 0:Ze.get(Je);for(let Xe=0;Xe<He.size();Xe++){let Ke=He==null?void 0:He.get(Xe);if(Ke)Ke.set(Ge[Xe]);else throw new Error("Unable to get model buffer from shared memory!")}}}async initializePipelines(){this.checkWasmInitialization("Unable to initialize pipelines, cpp API hasn't been initialized"),this.modelsBuffers||await this.loadModels(),this.wasmApiHelpers.initializePipelines()}async setProductionMode(me){this.checkWasmInitialization("Unable to set production mode, cpp API hasn't been initialized"),this.wasmApiHelpers.setProductionMode(me)}getPipelineState(){return this.checkWasmInitialization("Unable to get pipeline state, cpp API hasn't been initialized"),this.wasmApiHelpers.getPipelineState()}getCurrentPipeline(){return this.checkWasmInitialization("Unable to get current pipeline, cpp API hasn't been initialized"),this.fromWasmEnum(this.wasmApiHelpers.getCurrentPipeline())}toWasmEnum(me){switch(me){case PipelineType.IdCapturePipeline:return this.wasmModule.PipelineType.IdCapturePipeline;case PipelineType.IdFaceDetectionPipeline:return this.wasmModule.PipelineType.IdFaceDetectionPipeline;case PipelineType.IdVideoSelfiePipeline:return this.wasmModule.PipelineType.IdVideoSelfiePipeline;case PipelineType.SelfieFaceDetectionPipeline:return this.wasmModule.PipelineType.SelfieFaceDetectionPipeline;default:throw new Error("Unknown pipeline type")}}fromWasmEnum(me){switch(me){case this.wasmModule.PipelineType.IdCapturePipeline:return PipelineType.IdCapturePipeline;case this.wasmModule.PipelineType.IdFaceDetectionPipeline:return PipelineType.IdFaceDetectionPipeline;case this.wasmModule.PipelineType.IdVideoSelfiePipeline:return PipelineType.IdVideoSelfiePipeline;case this.wasmModule.PipelineType.SelfieFaceDetectionPipeline:return PipelineType.SelfieFaceDetectionPipeline;default:throw new Error("Unknown pipeline type")}}checkWasmInitialization(me){if(!this.isInitialized())throw new Error(me)}}function formatLandmarks(ue,me,Ue){const[Qe,Ze,Je,Ge,He,Xe,Ke,$e,nt,tt]=ue;return{rightEyeX:Qe,rightEyeY:Ze,leftEyeX:Je,leftEyeY:Ge,noseTipX:He,noseTipY:Xe,rightMouthX:Ke,rightMouthY:$e,mouthX:nt,mouthY:tt,x:me[0],y:me[1],width:Ue[0],height:Ue[1]}}let frame,fullImage,landmarks,topLeft,size;async function detectFace(ue){const{onNoFace:me,onCapturing:Ue,onCapture:Qe,onTooManyFaces:Ze,onTooClose:Je,onCenterFace:Ge,onFarAway:He,onFaceAngle:Xe,onDark:Ke,onBlur:$e,onHeadWear:nt,onLenses:tt,onEyesClosed:et,onFaceMask:rt,onSwitchToManualCapture:at,isLensesCheckEnabled:it,isMaskCheckEnabled:ot,isClosedEyesCheckEnabled:st,isHeadWearCheckEnabled:ut,isVideoSelfie:ct,autocaptureTimeout:dt,webcam:pt,pipelineProfileTypes:ht}=ue;try{const gt=getWasmApi();await gt.handleDetectionCallAndUpdateState(PipelineType.SelfieFaceDetectionPipeline);const Mt=ht.get(PipelineType.SelfieFaceDetectionPipeline),St=pipelineProfiles[Mt],Dt=cloneCanvas(pt.getCanvas(pt.video.videoWidth,pt.video.videoHeight));if(!Dt)return;if(state.skipFrames){state.skipFrames=!1;return}const yt=Dt.width,Tt=Dt.height,mt=pt.getBase64ScreenShot(yt,Tt,1,!1),Rt=pt.getFullImage(yt,Tt,1,Dt),It=Dt.getContext("2d").getImageData(0,0,yt,Tt);await gt.allocateImageBuffers(yt,Tt),await gt.setFacePositionConstraints(PipelineType.SelfieFaceDetectionPipeline,St.parameters.frameMinX,St.parameters.frameMinY,St.parameters.frameMaxX,St.parameters.frameMaxY),await gt.setFaceDetectionThresholds(PipelineType.SelfieFaceDetectionPipeline,St.parameters.brightnessThreshold,St.parameters.blurrinessThreshold,St.parameters.tiltRotationAngleThreshold,St.parameters.minMagicCropSize,dt),await gt.setFaceAttributesEnabled(PipelineType.SelfieFaceDetectionPipeline,it,ot,st,ut),await gt.setFaceAttributesThresholds(PipelineType.SelfieFaceDetectionPipeline,St.parameters.headwearThreshold,St.parameters.lensesThreshold,St.parameters.closedEyesThreshold,St.parameters.maskThreshold),await gt.setFaceDetectionMode(PipelineType.SelfieFaceDetectionPipeline,ct);const Et=()=>{Qe(frame,fullImage,formatLandmarks(landmarks,topLeft,size))},bt=vt=>{frame=mt,fullImage=Rt;const xt=vt.rect;topLeft=[xt.x,xt.y];const Bt=[xt.x+xt.width,xt.y+xt.height],Ct=topLeft,Zt=Bt;size=[Zt[0]-Ct[0],Zt[1]-Ct[1]],landmarks=[vt.rightEye.x,vt.rightEye.y,vt.leftEye.x,vt.leftEye.y,vt.noseTip.x,vt.noseTip.y,vt.rightMouthCorner.x,vt.rightMouthCorner.y,vt.leftMouthCorner.x,vt.leftMouthCorner.y]};await gt.setFaceDetectionCallbacks(PipelineType.SelfieFaceDetectionPipeline,He,Je,Ze,me,Et,Ue,Ge,Ke,$e,Xe,bt,tt,rt,et,nt,at),await gt.process(It,PipelineType.SelfieFaceDetectionPipeline)}catch(gt){console.error(`Exception: ${gt}`)}}const getImages$2=(ue,me,Ue)=>Ue.getImageData(ue,me);async function preprocessImage(ue){const me=ue.video.videoWidth,Ue=ue.video.videoHeight;return me===0||Ue===0?{image:null,status:0}:{image:getImages$2(me,Ue,ue),status:1}}async function configureIdPipeline(ue,me,Ue,Qe,Ze,Je,Ge,He,Xe,Ke,$e,nt,tt,et,rt=-1){const at=getWasmApi();await at.setIdCaptureCallbacks(ue,Ue,He,Ge,Ze,Qe,me,Je,Xe),await at.setIdCaptureThresholds(ue,et.parameters.sharpnessThreshold,et.parameters.sharpnessChangeThreshold,et.parameters.glareThreshold,et.parameters.classificationThreshold,rt),await at.setIdCaptureConfigParams(ue,$e,localStorage.getItem("isHighPerformance")==="true",Ke,nt,tt),await at.setIdCaptureGeometryParams(ue,et.parameters.areaDown,et.parameters.areaUp,et.parameters.areaIOSPassportUp,et.parameters.areaIOSPassportDown,et.parameters.widthIOSUp,et.parameters.widthIOSDown,et.parameters.widthDown,et.parameters.widthUp,window.outerWidth,window.outerHeight,window.innerWidth,window.innerHeight)}async function idDetection({webcam:ue,onCapturing:me,onFarAway:Ue,onGlare:Qe,onBlur:Ze,onIDNotDetected:Je,onMaskChange:Ge,idType:He,onDetectionStarted:Xe,onSwitchToManualCapture:Ke,isFixedMask:$e=!1,isKiosk:nt=!1,autocaptureTimeout:tt,pipelineProfileTypes:et}){try{const rt=getWasmApi();await rt.handleDetectionCallAndUpdateState(PipelineType.IdCapturePipeline);const at=et.get(PipelineType.IdCapturePipeline),it=pipelineProfiles[at];it.reconfigureParams(nt,mobile.isDesktop());const{image:ot,status:st}=await preprocessImage(ue);if(!st)return;const ut=(ct,dt)=>{me(ot,{sharpness:ct,glare:dt})};await configureIdPipeline(PipelineType.IdCapturePipeline,ut,Ue,Qe,Ze,Je,Ge,Xe,Ke,He,$e,!0,!0,it,tt),await rt.allocateImageBuffers(ot.imageElement.width,ot.imageElement.height),await rt.process(ot.imageElement,PipelineType.IdCapturePipeline)}catch(rt){console.error(`Exception: ${rt}`)}}const noop$1=()=>{};async function idVideoSelfieDetection({webcam:ue,onCapturing:me=noop$1,onFarAway:Ue=noop$1,onGlare:Qe=noop$1,onBlur:Ze=noop$1,onIdNotDetected:Je=noop$1,onMaskChange:Ge=noop$1,idType:He="null",onDetectionStarted:Xe=noop$1,isFixedMask:Ke=!1,isBlurCheckEnabled:$e,isGlareCheckEnabled:nt,onSwitchToManualCapture:tt,pipelineProfileTypes:et}){try{const rt=getWasmApi();await rt.handleDetectionCallAndUpdateState(PipelineType.IdVideoSelfiePipeline);const at=et.get(PipelineType.IdVideoSelfiePipeline),it=pipelineProfiles[at];it.reconfigureParams(!1,mobile.isDesktop());const{image:ot,status:st}=await preprocessImage(ue);if(!st)return;const ut=()=>{me()};await configureIdPipeline(PipelineType.IdVideoSelfiePipeline,ut,Ue,Qe,Ze,Je,Ge,Xe,tt,He,Ke,$e,nt,it),await rt.allocateImageBuffers(ot.imageElement.width,ot.imageElement.height),await rt.process(ot.imageElement,PipelineType.IdVideoSelfiePipeline)}catch(rt){console.error(`Exception: ${rt}`)}}const frontType="front",backType="back",selfieType="selfie",frontIdUrl="/omni/add/front-id",secondFrontIdUrl="/omni/add/front-second-id",backIdUrl="/omni/add/back-id",secondBackIdUrl="/omni/add/back-second-id",frontIdBase64Url="/omni/add/front-id/v2",backIdBase64Url="/omni/add/back-id/v2",getSelfieUrl=ue=>`/omni/add/face?imageType=${ue}`,getRealQualityValue=ue=>(1-ue)*100;function uploadFrontId({token:ue,image:me,onProgress:Ue=emptyFunc,sendBase64:Qe,onlyFront:Ze,isRetry:Je=!1,isSecondId:Ge=!1,glare:He,sharpness:Xe}){const Ke=Qe?frontIdBase64Url:Ge?secondFrontIdUrl:frontIdUrl,$e=Ze?`${Ke}?onlyFront=${Ze}`:Ke,nt=Qe?{base64Image:me}:me,tt=Qe?"application/json":"image/jpeg";return exports.api.post($e,nt,{headers:{"X-Incode-Hardware-Id":ue,"Content-Type":tt},onUploadProgress:({loaded:et,total:rt})=>Ue(et/rt*100),params:{...Je?{retry:!0}:void 0,...Xe?{sharpness:getRealQualityValue(Xe)}:void 0}}).then(et=>et.data)}function uploadBackId({token:ue,image:me,onProgress:Ue=emptyFunc,sendBase64:Qe,isRetry:Ze=!1,isSecondId:Je=!1,glare:Ge,sharpness:He,shouldSkipGlare:Xe}){const Ke=Qe?backIdBase64Url:Je?secondBackIdUrl:backIdUrl,$e=Qe?{base64Image:me}:me,nt=Qe?"application/json":"image/jpeg";return exports.api.post(Ke,$e,{headers:{"X-Incode-Hardware-Id":ue,"Content-Type":nt},onUploadProgress:({loaded:tt,total:et})=>Ue(tt/et*100),params:{...Ze?{retry:!0}:void 0,...Xe?{glare:100}:void 0,...He?{sharpness:getRealQualityValue(He)}:void 0}}).then(tt=>tt.data)}function uploadSelfie({token:ue,image:me,onProgress:Ue=emptyFunc,encrypted:Qe,imageType:Ze="selfie",faceCoordinates:Je=null}){return exports.api.post(getSelfieUrl(Ze),{base64Image:me,encrypted:Qe,faceCoordinates:Je,clientInfo:{deviceClass:getDeviceClass()}},{headers:{"X-Incode-Hardware-Id":ue},onUploadProgress:({loaded:Ge,total:He})=>Ue(Ge/He*100)}).then(Ge=>Ge.data)}function capture({type:ue,...me}){if(ue===frontType)return uploadFrontId({...me});if(ue===backType)return uploadBackId({...me});if(ue===selfieType)return uploadSelfie({...me});throw new Error(`type not supported, please use one of this: [${frontType}, ${backType}, ${selfieType}]`)}function setPerformanceLoadTime(){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))}let mlWasmJSApi=null,isSetupDetect=!1,pipelineLogs="",motionStatus="",analysisStatus="",estimatedPerformance="",pipelinesBundle=null,profileTypes=null,onboardingCheck=null;function getProfileTypes(){return profileTypes}function getPipelineLogs(){return pipelineLogs}function getMotionStatus(){return motionStatus}function getAnalysisStatus(){return analysisStatus}function getWasmApi(){if(mlWasmJSApi)return mlWasmJSApi;throw new Error("getWasmApi returned null")}let setupDetectPromise=null;const setupDetect=async()=>setupDetectPromise||(setupDetectPromise=_runSetupDetect(),setupDetectPromise);async function _runSetupDetect(){var Ue,Qe;if(isSetupDetect)return;addEvent({token:(Ue=state.token)==null?void 0:Ue.token,code:"modelLoadStart"}),setPerformanceLoadTime(),onboardingCheck=new OnboardingCheck(.3,.3,.3,.3,10,10,.3,.3,.3,.3,10,10),onboardingCheck.start(),mlWasmJSApi=new MlWasmJSApi;const ue=getInitializationParams(options.hostingApp==="Incode ID");for(pipelinesBundle=ue.bundle,profileTypes=ue.pipelineProfileTypes,await mlWasmJSApi.initialize(ue.wasmModulePath,ue.wasmSimdModulePath,ue.glueCodePath,ue.enableSIMD,ue.versionsFilePath,ue.pipelineModels);!mlWasmJSApi.isInitialized();)await new Promise(Ze=>setTimeout(Ze,100));estimatedPerformance=mlWasmJSApi.estimatePerformance(),await mlWasmJSApi.initializePipelines();const me={}.VITE_WASM_PRODUCTION_MODE==="true";try{await mlWasmJSApi.setProductionMode(me)}catch(Ze){console.error(`Exception: ${Ze}`)}isSetupDetect=!0,addEvent({token:(Qe=state.token)==null?void 0:Qe.token,code:"modelLoadEnd",payload:{loadSuccessful:!0}})}async function warmup(){for(;!getWasmApi().isInitialized();)await new Promise(ue=>setTimeout(ue,100))}async function analyzeFrame(ue){const me=await base64ToImageData(ue);await getWasmApi().analyzeFrame(me),updatePipelineStats()}function updatePipelineStats(){if(!(!mlWasmJSApi||!mlWasmJSApi.isInitialized()))try{const ue=mlWasmJSApi.getPipelineState();if(ue!==""){const me=JSON.parse(ue);analysisStatus=me.statsAnalysisStatus,me.pipelinesBundle=pipelinesBundle||"unknown",me.estimatedPerformance=estimatedPerformance,pipelineLogs=JSON.stringify(me),motionStatus===""&&(motionStatus=onboardingCheck.check())}}catch(ue){console.error(`Exception: ${ue}`)}}function detect({type:ue,canvas:me,webcam:Ue,onFarAway:Qe=emptyFunc,onBlur:Ze=emptyFunc,onGlare:Je=emptyFunc,onCapturing:Ge=emptyFunc,onCapture:He=emptyFunc,onTooManyFaces:Xe=emptyFunc,onCenterFace:Ke=emptyFunc,onIDNotDetected:$e=emptyFunc,onTooClose:nt=emptyFunc,onNothingHappen:tt=emptyFunc,onPercentage:et=emptyFunc,onNoFace:rt=emptyFunc,onMaskChange:at=emptyFunc,onDetectionStarted:it=emptyFunc,onFaceAngle:ot=emptyFunc,onDark:st=emptyFunc,onHeadWear:ut=emptyFunc,onLenses:ct=emptyFunc,onEyesClosed:dt=emptyFunc,onFaceMask:pt=emptyFunc,onSwitchToManualCapture:ht=emptyFunc,idType:gt="FrontId",isFixedMask:Mt=!1,isLensesCheckEnabled:St=!1,isMaskCheckEnabled:Dt=!1,isClosedEyesCheckEnabled:yt=!1,isHeadWearCheckEnabled:Tt=!1,isKiosk:mt=!1,isVideoSelfie:Rt,pipelineProfileTypes:Ut,autocaptureTimeout:It=-1}){if(!me)return;window.clearInterval(state.intervalId);const Et=(vt=>{if(vt===frontType||vt===backType)return idDetection;if(vt===selfieType)return detectFace;throw new Error(`type not supported, please use one of this: [${frontType}, ${backType}, ${selfieType}]`)})(ue),bt={webcam:Ue,onFarAway:Qe,onCenterFace:Ke,onTooManyFaces:Xe,onBlur:Ze,onGlare:Je,onCapturing:Ge,onCapture:He,onIDNotDetected:$e,onTooClose:nt,onNothingHappen:tt,onPercentage:et,onNoFace:rt,onMaskChange:at,onDetectionStarted:it,onDark:st,onFaceAngle:ot,isFixedMask:Mt,idType:gt,onHeadWear:ut,onLenses:ct,onEyesClosed:dt,onFaceMask:pt,onSwitchToManualCapture:ht,isLensesCheckEnabled:St,isMaskCheckEnabled:Dt,isClosedEyesCheckEnabled:yt,isHeadWearCheckEnabled:Tt,isKiosk:mt,isVideoSelfie:Rt,autocaptureTimeout:It,pipelineProfileTypes:Ut};if(Et===idDetection||Et===detectFace){const vt=async()=>{if(!state.detecting){await sleep(1e3);return}try{await Et(bt)}catch{}finally{await sleep(200),requestAnimationFrame(vt)}};requestAnimationFrame(vt)}else state.intervalId=window.setInterval(()=>{state.detecting&&Et(bt)},100)}function stopDetect(){window.clearInterval(state.intervalId),state.detecting=!1,state.skipFrames=!0}function resumeDetect(){state.detecting=!0,state.skipFrames=!0}function detectFrame(){return null}var lib$1={exports:{}},Modal$2={},propTypes$2={exports:{}};/*
940
+ `;function copyLink(){const ue=window.location.href;navigator.clipboard.writeText(ue)}const isAppleDevice=mobile.isAppleDevice();function BrowserNotSupported({onContinue:ue,token:me}){const{t:Ue}=useTranslation();React$1.useEffect(()=>{me&&addEvent({token:me,code:"pageWasRenderedToUser",screen:"Unsupported Browser"})},[me]);const Qe=()=>{copyLink(),me&&addEvent({token:me,code:"userClickedCopyLink",screen:"Unsupported Browser"})},Ze=()=>{me&&addEvent({token:me,code:"userClickedContinueAnyway",screen:"Unsupported Browser"}),ue()};return jsxs(BrowserNotSupportedContainer,{className:"IncodeBrowserNotSupporterContainer",children:[jsxs("div",{className:"BrowserNotSupportedTopContainer",children:[jsx(Image$a,{src:BrowserNotSupportedIcon,alt:"browser not supported",className:"IncodeBrowserNotSupporterImage"}),jsx("h2",{className:"IncodeBrowserNotSupporterTitle",children:Ue("unsupportedBrowser.title")}),jsxs(Text$7,{className:"IncodeBrowserNotSupporterTextFirst",children:[Ue("unsupportedBrowser.betterExperience")," ",isAppleDevice&&jsxs(Fragment,{children:[jsx(Blue$1,{children:"Safari"})," or"," "]}),jsx(Blue$1,{children:"Chrome"})]})]}),jsxs(BrowserNotSupportedBottomContainer,{className:"BrowserNotSupportedBottomContainer",children:[jsx(LinkText,{className:"IncodeBrowserNotSupporterLinkText",children:window.location.href}),jsx("div",{children:jsx(Button$9,{onClick:Qe,type:"button",className:"IncodeBrowserNotSupporterCopyLinkButton",children:Ue("unsupportedBrowser.copyLink")})}),jsx(ContinueButton,{type:"button",onClick:Ze,className:"IncodeBrowserNotSupporterContinueButton",children:Ue("unsupportedBrowser.continueAnyways")})]})]})}const state={detecting:!0,intervalCounter:0,matchCounter:0,intervalId:null,cascadeLoaded:!1,selfieAttempt:0,selfieGetFrames:0,grabSelfieFrames:!1,frames:[],token:null,facefinderClassifyRegion:()=>-1,skipFrames:!0};class OnboardingCheck{constructor(me,Ue,Qe,Ze,Je,Ge,He,Xe,Ke,$e,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_=Ke,this.maeAccOldThreshold_=$e,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}}let options={darkMode:!1,hostingApp:"Web SDK",unsafeMode:!1,redirectFromUnsupportedBrowsers:!1};const setOptions=ue=>(options={...options,...ue},options);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=null,Je=""){this.pipelineType=me,this.modelNames=Ue,this.parameters=Qe,this.paramsConfigurator=Ze,this.description=Je}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)}}var PipelineType=(ue=>(ue[ue.IdCapturePipeline=0]="IdCapturePipeline",ue[ue.IdVideoSelfiePipeline=1]="IdVideoSelfiePipeline",ue[ue.SelfieFaceDetectionPipeline=2]="SelfieFaceDetectionPipeline",ue[ue.IdFaceDetectionPipeline=3]="IdFaceDetectionPipeline",ue))(PipelineType||{});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={[PipelineProfileType.IdCaptureBrazilian]:new PipelineProfile(PipelineType.IdCapturePipeline,["brazilian_mobile_025_ep199_fp16.ortmodelv2"],{glareThreshold:.2,classificationThreshold:.98,sharpnessThreshold:.3,sharpnessChangeThreshold:.3},IdCaptureParamsConfigurator,"Id Capture Profile with brazilian_mobile model"),[PipelineProfileType.IdCaptureVisas]:new PipelineProfile(PipelineType.IdCapturePipeline,["visas_mobile_025_best_v1_03_fp16.ortmodelv2"],{glareThreshold:.3,classificationThreshold:.98,sharpnessThreshold:.2,sharpnessChangeThreshold:.2},IdCaptureParamsConfigurator,"Id Capture Profile with visas_mobile model"),[PipelineProfileType.IdVideoSelfieBrazilian]:new PipelineProfile(PipelineType.IdVideoSelfiePipeline,["brazilian_mobile_025_ep199_fp16.ortmodelv2"],{glareThreshold:.2,classificationThreshold:.9,sharpnessThreshold:.3,sharpnessChangeThreshold:.3},IdCaptureParamsConfigurator,"Id Videoselfie profile with brazilian_mobile model"),[PipelineProfileType.IdVideoSelfieVisas]:new PipelineProfile(PipelineType.IdVideoSelfiePipeline,["visas_mobile_025_best_v1_03_fp16.ortmodelv2"],{glareThreshold:.3,classificationThreshold:.9,sharpnessThreshold:.2,sharpnessChangeThreshold:.2},IdCaptureParamsConfigurator,"Id Videoselfie Profile with visas_mobile model"),[PipelineProfileType.SelfieFaceDetection]:new PipelineProfile(PipelineType.SelfieFaceDetectionPipeline,["selfie_bf_angles_192x192_opset9_fp16.ortmodelv2","bf_attrib_31b8f9d92fb345c2b4bbdd222792562c_0_fp16.ortmodelv2"],SelfieFaceDetectionPipelineParams,null,"Selfie face detection profile")},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,Ke=new Map;for(const $e of PipelinesBundle.get(Ue)){if(!pipelineProfiles[$e])throw new Error(`Pipeline profile ${$e} not found`);const nt=pipelineProfiles[$e],tt=nt.modelNames;let et=[];for(const rt of tt)et.push(`${Qe}/${wasmVersion}/models/${rt}`);Xe.set(nt.pipelineType,et),Ke.set(nt.pipelineType,$e)}return{wasmModulePath:Ze,wasmSimdModulePath:Je,glueCodePath:Ge,versionsFilePath:He,pipelineModels:Xe,pipelineProfileTypes:Ke,enableSIMD:!0,bundle:Ue}}window.wasmArrayBuffer=null;class MlWasmJSApi{constructor(){this.versionsFile=null,this.modelsBuffers=null,this.inputImageBuffer=null,this.wasmModule=null,this.wasmApiHelpers=null,this.idCaptureWasmApi=null,this.faceDetectionWasmApi=null,this.imageWidth_=null,this.imageHeight_=null,this.pipelines_=null,this.isInitialized_=!1,this.Module=null,this.loadModule=async me=>{this.Module=(await import(me)).Module}}async initialize(me,Ue,Qe,Ze,Je,Ge){await this.freeResources(),this.pipelines_=Ge,this.versionsFile=Je,await this.loadModule(Qe),await this.loadWasm(Ze,me,Ue),this.wasmApiHelpers=new this.wasmModule.MlWasmApiHelpers,this.idCaptureWasmApi=new this.wasmModule.IdCaptureWasmApi,this.faceDetectionWasmApi=new this.wasmModule.FaceDetectionWasmApi,this.isInitialized_=!0}isInitialized(){return this.wasmApiHelpers!=null&&this.idCaptureWasmApi!=null&&this.faceDetectionWasmApi!=null&&this.isInitialized_}async allocateImageBuffers(me,Ue){this.checkWasmInitialization("Unable to allocate image buffers, cpp API hasn't been initialized"),!(me&&Ue&&me==this.imageWidth_&&Ue==this.imageHeight_&&this.inputImageBuffer&&me*Ue*4===this.inputImageBuffer.length)&&(this.imageWidth_=me,this.imageHeight_=Ue,this.inputImageBuffer=this.wasmApiHelpers.allocateInputImageBuffer(me,Ue,4))}async handleDetectionCallAndUpdateState(me){this.checkWasmInitialization("Unable to update pipeline state, cpp API hasn't been initialized"),this.wasmApiHelpers.handleDetectionCallAndUpdateState(this.toWasmEnum(me))}async encryptImage(me){return this.checkWasmInitialization("Unable to encrypt the image, cpp API hasn't been initialized"),this.wasmApiHelpers.encryptImage(me)}isVirtualCamera(me){return this.checkWasmInitialization("Unable to check if the camera is virtual, cpp API hasn't been initialized"),this.wasmApiHelpers.isVirtualCamera(me)}estimatePerformance(){return this.checkWasmInitialization("Unable to estimate performance, cpp API hasn't been initialized"),this.wasmApiHelpers.estimatePerformance()}async analyzeFrame(me){return this.checkWasmInitialization("Unable to analyze the frame, cpp API hasn't been initialized"),await this.allocateImageBuffers(me.width,me.height),this.inputImageBuffer.set(me.data),this.wasmApiHelpers.analyzeFrame()}async freeResources(){this.versionsFile=null,this.modelsBuffers=null,this.inputImageBuffer=null,this.imageWidth_=null,this.imageHeight_=null,this.pipelines_=null,window.wasmArrayBuffer=null,this.wasmApiHelpers&&typeof this.wasmApiHelpers.delete=="function"&&(this.wasmApiHelpers.delete(),this.wasmApiHelpers=null),this.idCaptureWasmApi&&typeof this.idCaptureWasmApi.delete=="function"&&(this.idCaptureWasmApi.delete(),this.idCaptureWasmApi=null),this.faceDetectionWasmApi&&typeof this.faceDetectionWasmApi.delete=="function"&&(this.faceDetectionWasmApi.delete(),this.faceDetectionWasmApi=null),this.wasmModule=null,this.isInitialized_=!1}resetPipeline(me){this.checkWasmInitialization("Unable to reset pipeline, cpp API hasn't been initialized"),this.wasmApiHelpers.resetPipeline(this.toWasmEnum(me))}resetAllPipelines(){this.checkWasmInitialization("Unable to reset pipelines, cpp API hasn't been initialized");for(const[me,Ue]of this.pipelines_)this.resetPipeline(me)}async process(me,Ue){if(this.checkWasmInitialization("Unable to process the image, cpp API hasn't been initialized"),this.inputImageBuffer===null)throw new Error("Unable to process the image, buffers haven't been allocated!");switch(this.inputImageBuffer.set(me.data),Ue){case PipelineType.IdCapturePipeline:return this.idCaptureWasmApi.runIdCapturePipeline();case PipelineType.IdFaceDetectionPipeline:return this.faceDetectionWasmApi.runIdFaceDetectionPipeline();case PipelineType.IdVideoSelfiePipeline:return this.idCaptureWasmApi.runIdVideoSelfiePipeline();case PipelineType.SelfieFaceDetectionPipeline:return this.faceDetectionWasmApi.runSelfieFaceDetectionPipeline();default:throw new Error("Unknown pipeline type")}}async runIdCapture(me){if(this.checkWasmInitialization("Unable to run Id Capture, cpp API hasn't been initialized"),this.inputImageBuffer===null)throw new Error("Unable to process the image, buffers haven't been allocated!");return this.inputImageBuffer.set(me.data),this.idCaptureWasmApi.runIdCapture()}async runSelfieCapture(me){if(this.checkWasmInitialization("Unable to run Selfie Capture, cpp API hasn't been initialized"),this.inputImageBuffer===null)throw new Error("Unable to process the image, buffers haven't been allocated!");return this.inputImageBuffer.set(me.data),this.faceDetectionWasmApi.runSelfieCapture()}async setFacePositionConstraints(me,Ue,Qe,Ze,Je){this.checkWasmInitialization("Unable to set face position constraints, cpp API hasn't been initialized"),this.faceDetectionWasmApi.setFacePositionConstraints(this.toWasmEnum(me),Ue,Qe,Ze,Je)}async setFaceDetectionThresholds(me,Ue,Qe,Ze,Je,Ge){this.checkWasmInitialization("Unable to set face detection thresholds, cpp API hasn't been initialized"),this.faceDetectionWasmApi.setFaceDetectionThresholds(this.toWasmEnum(me),Ue,Qe,Ze,Je,Ge)}async setFaceAttributesThresholds(me,Ue,Qe,Ze,Je){this.checkWasmInitialization("Unable to set face attributes thresholds, cpp API hasn't been initialized"),this.faceDetectionWasmApi.setFaceAttributesThresholds(this.toWasmEnum(me),Ue,Qe,Ze,Je)}async setFaceAttributesEnabled(me,Ue,Qe,Ze,Je){this.checkWasmInitialization("Unable to set face attributes enabled flags, cpp API hasn't been initialized"),this.faceDetectionWasmApi.setFaceAttributesEnabled(this.toWasmEnum(me),Ue,Qe,Ze,Je)}async setFaceDetectionMode(me,Ue){this.checkWasmInitialization("Unable to set face detection mode, cpp API hasn't been initialized"),this.faceDetectionWasmApi.setFaceDetectionMode(this.toWasmEnum(me),Ue)}async setFaceDetectionCallbacks(me,Ue,Qe,Ze,Je,Ge,He,Xe,Ke,$e,nt,tt,et,rt,at,it,ot){this.checkWasmInitialization("Unable to set face detection callbacks, cpp API hasn't been initialized"),this.faceDetectionWasmApi.setFaceDetectionCallbacks(this.toWasmEnum(me),Ue,Qe,Ze,Je,Ge,He,Xe,Ke,$e,nt,tt,et,rt,at,it,ot)}async setIdCaptureThresholds(me,Ue,Qe,Ze,Je,Ge){this.checkWasmInitialization("Unable to set thresholds, cpp API hasn't been initialized"),this.idCaptureWasmApi.setIdCaptureThresholds(this.toWasmEnum(me),Ue,Qe,Ze,Je,Ge)}async setIdCaptureCallbacks(me,Ue,Qe,Ze,Je,Ge,He,Xe,Ke){this.checkWasmInitialization("Unable to set callbacks, cpp API hasn't been initialized"),this.idCaptureWasmApi.setIdCaptureCallbacks(this.toWasmEnum(me),Ue,Qe,Ze,Je,Ge,He,Xe,Ke)}async setIdCaptureGeometryParams(me,Ue,Qe,Ze,Je,Ge,He,Xe,Ke,$e,nt,tt,et){this.checkWasmInitialization("Unable to set geometry params, cpp API hasn't been initialized"),this.idCaptureWasmApi.setIdCaptureGeometryParams(this.toWasmEnum(me),Ue,Qe,Ze,Je,Ge,He,Xe,Ke,$e,nt,tt,et)}async setIdCaptureConfigParams(me,Ue,Qe,Ze,Je,Ge){this.checkWasmInitialization("Unable to set config params, cpp API hasn't been initialized"),this.idCaptureWasmApi.setIdCaptureConfigParams(this.toWasmEnum(me),Ue,Qe,Ze,Je,Ge)}async getVersions(){const Ue=await(await fetch(this.versionsFile)).text();return JSON.parse(Ue)}async loadWasm(me,Ue,Qe){const Ze=me?Qe:Ue;try{window.wasmArrayBuffer=await fetch(Ze).then(Je=>Je.arrayBuffer()).then(Je=>new Uint8Array(Je)),this.wasmModule=await this.Module()}catch(Je){if(console.log(Je,me,"useSmd"),me)await this.loadWasm(!1,Ue,Qe);else throw Je}}async loadModels(){var Ze;this.checkWasmInitialization("Unable load the models, cpp API hasn't been initialized");let me=new this.wasmModule.PipelineTypeToIntMap,Ue=new Map,Qe=new Map;for(let[Je,Ge]of this.pipelines_){let He=this.toWasmEnum(Je),Xe=[],Ke=new this.wasmModule.VectorInt;for(let $e of Ge){if(!Qe.has($e)){let tt=await fetch($e).then(et=>et.arrayBuffer()).then(et=>new Uint8Array(et));Qe.set($e,tt)}let nt=Qe.get($e);Ke.push_back(nt.byteLength),Xe.push(nt)}me.set(He,Ke),Ue.set(He,Xe)}this.modelsBuffers=this.wasmApiHelpers.allocateModelsBuffers(me);for(let[Je,Ge]of Ue){let He=(Ze=this.modelsBuffers)==null?void 0:Ze.get(Je);for(let Xe=0;Xe<He.size();Xe++){let Ke=He==null?void 0:He.get(Xe);if(Ke)Ke.set(Ge[Xe]);else throw new Error("Unable to get model buffer from shared memory!")}}}async initializePipelines(){this.checkWasmInitialization("Unable to initialize pipelines, cpp API hasn't been initialized"),this.modelsBuffers||await this.loadModels(),this.wasmApiHelpers.initializePipelines()}async setProductionMode(me){this.checkWasmInitialization("Unable to set production mode, cpp API hasn't been initialized"),this.wasmApiHelpers.setProductionMode(me)}getPipelineState(){return this.checkWasmInitialization("Unable to get pipeline state, cpp API hasn't been initialized"),this.wasmApiHelpers.getPipelineState()}getCurrentPipeline(){return this.checkWasmInitialization("Unable to get current pipeline, cpp API hasn't been initialized"),this.fromWasmEnum(this.wasmApiHelpers.getCurrentPipeline())}toWasmEnum(me){switch(me){case PipelineType.IdCapturePipeline:return this.wasmModule.PipelineType.IdCapturePipeline;case PipelineType.IdFaceDetectionPipeline:return this.wasmModule.PipelineType.IdFaceDetectionPipeline;case PipelineType.IdVideoSelfiePipeline:return this.wasmModule.PipelineType.IdVideoSelfiePipeline;case PipelineType.SelfieFaceDetectionPipeline:return this.wasmModule.PipelineType.SelfieFaceDetectionPipeline;default:throw new Error("Unknown pipeline type")}}fromWasmEnum(me){switch(me){case this.wasmModule.PipelineType.IdCapturePipeline:return PipelineType.IdCapturePipeline;case this.wasmModule.PipelineType.IdFaceDetectionPipeline:return PipelineType.IdFaceDetectionPipeline;case this.wasmModule.PipelineType.IdVideoSelfiePipeline:return PipelineType.IdVideoSelfiePipeline;case this.wasmModule.PipelineType.SelfieFaceDetectionPipeline:return PipelineType.SelfieFaceDetectionPipeline;default:throw new Error("Unknown pipeline type")}}checkWasmInitialization(me){if(!this.isInitialized())throw new Error(me)}}function formatLandmarks(ue,me,Ue){const[Qe,Ze,Je,Ge,He,Xe,Ke,$e,nt,tt]=ue;return{rightEyeX:Qe,rightEyeY:Ze,leftEyeX:Je,leftEyeY:Ge,noseTipX:He,noseTipY:Xe,rightMouthX:Ke,rightMouthY:$e,mouthX:nt,mouthY:tt,x:me[0],y:me[1],width:Ue[0],height:Ue[1]}}let frame,fullImage,landmarks,topLeft,size;async function detectFace(ue){const{onNoFace:me,onCapturing:Ue,onCapture:Qe,onTooManyFaces:Ze,onTooClose:Je,onCenterFace:Ge,onFarAway:He,onFaceAngle:Xe,onDark:Ke,onBlur:$e,onHeadWear:nt,onLenses:tt,onEyesClosed:et,onFaceMask:rt,onSwitchToManualCapture:at,isLensesCheckEnabled:it,isMaskCheckEnabled:ot,isClosedEyesCheckEnabled:st,isHeadWearCheckEnabled:ut,isVideoSelfie:ct,autocaptureTimeout:dt,webcam:pt,pipelineProfileTypes:ht}=ue;try{const gt=getWasmApi();await gt.handleDetectionCallAndUpdateState(PipelineType.SelfieFaceDetectionPipeline);const Mt=ht.get(PipelineType.SelfieFaceDetectionPipeline),St=pipelineProfiles[Mt],Dt=cloneCanvas(pt.getCanvas(pt.video.videoWidth,pt.video.videoHeight));if(!Dt)return;if(state.skipFrames){state.skipFrames=!1;return}const yt=Dt.width,Tt=Dt.height,mt=pt.getBase64ScreenShot(yt,Tt,1,!1),Rt=pt.getFullImage(yt,Tt,1,Dt),It=Dt.getContext("2d").getImageData(0,0,yt,Tt);await gt.allocateImageBuffers(yt,Tt),await gt.setFacePositionConstraints(PipelineType.SelfieFaceDetectionPipeline,St.parameters.frameMinX,St.parameters.frameMinY,St.parameters.frameMaxX,St.parameters.frameMaxY),await gt.setFaceDetectionThresholds(PipelineType.SelfieFaceDetectionPipeline,St.parameters.brightnessThreshold,St.parameters.blurrinessThreshold,St.parameters.tiltRotationAngleThreshold,St.parameters.minMagicCropSize,dt),await gt.setFaceAttributesEnabled(PipelineType.SelfieFaceDetectionPipeline,it,ot,st,ut),await gt.setFaceAttributesThresholds(PipelineType.SelfieFaceDetectionPipeline,St.parameters.headwearThreshold,St.parameters.lensesThreshold,St.parameters.closedEyesThreshold,St.parameters.maskThreshold),await gt.setFaceDetectionMode(PipelineType.SelfieFaceDetectionPipeline,ct);const Et=()=>{Qe(frame,fullImage,formatLandmarks(landmarks,topLeft,size))},bt=vt=>{frame=mt,fullImage=Rt;const xt=vt.rect;topLeft=[xt.x,xt.y];const Bt=[xt.x+xt.width,xt.y+xt.height],Ct=topLeft,Zt=Bt;size=[Zt[0]-Ct[0],Zt[1]-Ct[1]],landmarks=[vt.rightEye.x,vt.rightEye.y,vt.leftEye.x,vt.leftEye.y,vt.noseTip.x,vt.noseTip.y,vt.rightMouthCorner.x,vt.rightMouthCorner.y,vt.leftMouthCorner.x,vt.leftMouthCorner.y]};await gt.setFaceDetectionCallbacks(PipelineType.SelfieFaceDetectionPipeline,He,Je,Ze,me,Et,Ue,Ge,Ke,$e,Xe,bt,tt,rt,et,nt,at),await gt.process(It,PipelineType.SelfieFaceDetectionPipeline)}catch(gt){console.error(`Exception: ${gt}`)}}const getImages$2=(ue,me,Ue)=>Ue.getImageData(ue,me);async function preprocessImage(ue){const me=ue.video.videoWidth,Ue=ue.video.videoHeight;return me===0||Ue===0?{image:null,status:0}:{image:getImages$2(me,Ue,ue),status:1}}async function configureIdPipeline(ue,me,Ue,Qe,Ze,Je,Ge,He,Xe,Ke,$e,nt,tt,et,rt=-1){const at=getWasmApi();await at.setIdCaptureCallbacks(ue,Ue,He,Ge,Ze,Qe,me,Je,Xe),await at.setIdCaptureThresholds(ue,et.parameters.sharpnessThreshold,et.parameters.sharpnessChangeThreshold,et.parameters.glareThreshold,et.parameters.classificationThreshold,rt),await at.setIdCaptureConfigParams(ue,$e,localStorage.getItem("isHighPerformance")==="true",Ke,nt,tt),await at.setIdCaptureGeometryParams(ue,et.parameters.areaDown,et.parameters.areaUp,et.parameters.areaIOSPassportUp,et.parameters.areaIOSPassportDown,et.parameters.widthIOSUp,et.parameters.widthIOSDown,et.parameters.widthDown,et.parameters.widthUp,window.outerWidth,window.outerHeight,window.innerWidth,window.innerHeight)}async function idDetection({webcam:ue,onCapturing:me,onFarAway:Ue,onGlare:Qe,onBlur:Ze,onIDNotDetected:Je,onMaskChange:Ge,idType:He,onDetectionStarted:Xe,onSwitchToManualCapture:Ke,isFixedMask:$e=!1,isKiosk:nt=!1,autocaptureTimeout:tt,pipelineProfileTypes:et}){try{const rt=getWasmApi();await rt.handleDetectionCallAndUpdateState(PipelineType.IdCapturePipeline);const at=et.get(PipelineType.IdCapturePipeline),it=pipelineProfiles[at];it.reconfigureParams(nt,mobile.isDesktop());const{image:ot,status:st}=await preprocessImage(ue);if(!st)return;const ut=(ct,dt)=>{me(ot,{sharpness:ct,glare:dt})};await configureIdPipeline(PipelineType.IdCapturePipeline,ut,Ue,Qe,Ze,Je,Ge,Xe,Ke,He,$e,!0,!0,it,tt),await rt.allocateImageBuffers(ot.imageElement.width,ot.imageElement.height),await rt.process(ot.imageElement,PipelineType.IdCapturePipeline)}catch(rt){console.error(`Exception: ${rt}`)}}const noop$1=()=>{};async function idVideoSelfieDetection({webcam:ue,onCapturing:me=noop$1,onFarAway:Ue=noop$1,onGlare:Qe=noop$1,onBlur:Ze=noop$1,onIdNotDetected:Je=noop$1,onMaskChange:Ge=noop$1,idType:He="null",onDetectionStarted:Xe=noop$1,isFixedMask:Ke=!1,isBlurCheckEnabled:$e,isGlareCheckEnabled:nt,onSwitchToManualCapture:tt,pipelineProfileTypes:et}){try{const rt=getWasmApi();await rt.handleDetectionCallAndUpdateState(PipelineType.IdVideoSelfiePipeline);const at=et.get(PipelineType.IdVideoSelfiePipeline),it=pipelineProfiles[at];it.reconfigureParams(!1,mobile.isDesktop());const{image:ot,status:st}=await preprocessImage(ue);if(!st)return;const ut=()=>{me()};await configureIdPipeline(PipelineType.IdVideoSelfiePipeline,ut,Ue,Qe,Ze,Je,Ge,Xe,tt,He,Ke,$e,nt,it),await rt.allocateImageBuffers(ot.imageElement.width,ot.imageElement.height),await rt.process(ot.imageElement,PipelineType.IdVideoSelfiePipeline)}catch(rt){console.error(`Exception: ${rt}`)}}const frontType="front",backType="back",selfieType="selfie",frontIdUrl="/omni/add/front-id",secondFrontIdUrl="/omni/add/front-second-id",backIdUrl="/omni/add/back-id",secondBackIdUrl="/omni/add/back-second-id",frontIdBase64Url="/omni/add/front-id/v2",backIdBase64Url="/omni/add/back-id/v2",getSelfieUrl=ue=>`/omni/add/face?imageType=${ue}`,getRealQualityValue=ue=>(1-ue)*100;function uploadFrontId({token:ue,image:me,onProgress:Ue=emptyFunc,sendBase64:Qe,onlyFront:Ze,isRetry:Je=!1,isSecondId:Ge=!1,glare:He,sharpness:Xe}){const Ke=Qe?frontIdBase64Url:Ge?secondFrontIdUrl:frontIdUrl,$e=Ze?`${Ke}?onlyFront=${Ze}`:Ke,nt=Qe?{base64Image:me}:me,tt=Qe?"application/json":"image/jpeg";return exports.api.post($e,nt,{headers:{"X-Incode-Hardware-Id":ue,"Content-Type":tt},onUploadProgress:({loaded:et,total:rt})=>Ue(et/rt*100),params:{...Je?{retry:!0}:void 0,...Xe?{sharpness:getRealQualityValue(Xe)}:void 0}}).then(et=>et.data)}function uploadBackId({token:ue,image:me,onProgress:Ue=emptyFunc,sendBase64:Qe,isRetry:Ze=!1,isSecondId:Je=!1,glare:Ge,sharpness:He,shouldSkipGlare:Xe}){const Ke=Qe?backIdBase64Url:Je?secondBackIdUrl:backIdUrl,$e=Qe?{base64Image:me}:me,nt=Qe?"application/json":"image/jpeg";return exports.api.post(Ke,$e,{headers:{"X-Incode-Hardware-Id":ue,"Content-Type":nt},onUploadProgress:({loaded:tt,total:et})=>Ue(tt/et*100),params:{...Ze?{retry:!0}:void 0,...Xe?{glare:100}:void 0,...He?{sharpness:getRealQualityValue(He)}:void 0}}).then(tt=>tt.data)}function uploadSelfie({token:ue,image:me,onProgress:Ue=emptyFunc,encrypted:Qe,imageType:Ze="selfie",faceCoordinates:Je=null}){return exports.api.post(getSelfieUrl(Ze),{base64Image:me,encrypted:Qe,faceCoordinates:Je,clientInfo:{deviceClass:getDeviceClass()}},{headers:{"X-Incode-Hardware-Id":ue},onUploadProgress:({loaded:Ge,total:He})=>Ue(Ge/He*100)}).then(Ge=>Ge.data)}function capture({type:ue,...me}){if(ue===frontType)return uploadFrontId({...me});if(ue===backType)return uploadBackId({...me});if(ue===selfieType)return uploadSelfie({...me});throw new Error(`type not supported, please use one of this: [${frontType}, ${backType}, ${selfieType}]`)}function setPerformanceLoadTime(){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))}let mlWasmJSApi=null,isSetupDetect=!1,pipelineLogs="",motionStatus="",analysisStatus="",estimatedPerformance="",pipelinesBundle=null,profileTypes=null,onboardingCheck=null;function getProfileTypes(){return profileTypes}function getPipelineLogs(){return pipelineLogs}function getMotionStatus(){return motionStatus}function getAnalysisStatus(){return analysisStatus}function getWasmApi(){if(mlWasmJSApi)return mlWasmJSApi;throw new Error("getWasmApi returned null")}let setupDetectPromise=null;const setupDetect=async()=>setupDetectPromise||(setupDetectPromise=_runSetupDetect(),setupDetectPromise);async function _runSetupDetect(){var Ue,Qe;if(isSetupDetect)return;addEvent({token:(Ue=state.token)==null?void 0:Ue.token,code:"modelLoadStart"}),setPerformanceLoadTime(),onboardingCheck=new OnboardingCheck(.3,.3,.3,.3,10,10,.3,.3,.3,.3,10,10),onboardingCheck.start(),mlWasmJSApi=new MlWasmJSApi;const ue=getInitializationParams(options.hostingApp==="Incode ID");for(pipelinesBundle=ue.bundle,profileTypes=ue.pipelineProfileTypes,await mlWasmJSApi.initialize(ue.wasmModulePath,ue.wasmSimdModulePath,ue.glueCodePath,ue.enableSIMD,ue.versionsFilePath,ue.pipelineModels);!mlWasmJSApi.isInitialized();)await new Promise(Ze=>setTimeout(Ze,100));estimatedPerformance=mlWasmJSApi.estimatePerformance(),await mlWasmJSApi.initializePipelines();const me={}.VITE_WASM_PRODUCTION_MODE==="true";try{await mlWasmJSApi.setProductionMode(me)}catch(Ze){console.error(`Exception: ${Ze}`)}isSetupDetect=!0,addEvent({token:(Qe=state.token)==null?void 0:Qe.token,code:"modelLoadEnd",payload:{loadSuccessful:!0}})}async function warmup(){for(;!getWasmApi().isInitialized();)await new Promise(ue=>setTimeout(ue,100))}async function analyzeFrame(ue){const me=await base64ToImageData(ue);await getWasmApi().analyzeFrame(me),updatePipelineStats()}function updatePipelineStats(){if(!(!mlWasmJSApi||!mlWasmJSApi.isInitialized()))try{const ue=mlWasmJSApi.getPipelineState();if(ue!==""){const me=JSON.parse(ue);analysisStatus=me.statsAnalysisStatus,me.pipelinesBundle=pipelinesBundle||"unknown",me.estimatedPerformance=estimatedPerformance,pipelineLogs=JSON.stringify(me),motionStatus===""&&(motionStatus=onboardingCheck.check())}}catch(ue){console.error(`Exception: ${ue}`)}}function detect({type:ue,canvas:me,webcam:Ue,onFarAway:Qe=emptyFunc,onBlur:Ze=emptyFunc,onGlare:Je=emptyFunc,onCapturing:Ge=emptyFunc,onCapture:He=emptyFunc,onTooManyFaces:Xe=emptyFunc,onCenterFace:Ke=emptyFunc,onIDNotDetected:$e=emptyFunc,onTooClose:nt=emptyFunc,onNothingHappen:tt=emptyFunc,onPercentage:et=emptyFunc,onNoFace:rt=emptyFunc,onMaskChange:at=emptyFunc,onDetectionStarted:it=emptyFunc,onFaceAngle:ot=emptyFunc,onDark:st=emptyFunc,onHeadWear:ut=emptyFunc,onLenses:ct=emptyFunc,onEyesClosed:dt=emptyFunc,onFaceMask:pt=emptyFunc,onSwitchToManualCapture:ht=emptyFunc,idType:gt="FrontId",isFixedMask:Mt=!1,isLensesCheckEnabled:St=!1,isMaskCheckEnabled:Dt=!1,isClosedEyesCheckEnabled:yt=!1,isHeadWearCheckEnabled:Tt=!1,isKiosk:mt=!1,isVideoSelfie:Rt,pipelineProfileTypes:Ut,autocaptureTimeout:It=-1}){if(!me)return;window.clearInterval(state.intervalId);const Et=(vt=>{if(vt===frontType||vt===backType)return idDetection;if(vt===selfieType)return detectFace;throw new Error(`type not supported, please use one of this: [${frontType}, ${backType}, ${selfieType}]`)})(ue),bt={webcam:Ue,onFarAway:Qe,onCenterFace:Ke,onTooManyFaces:Xe,onBlur:Ze,onGlare:Je,onCapturing:Ge,onCapture:He,onIDNotDetected:$e,onTooClose:nt,onNothingHappen:tt,onPercentage:et,onNoFace:rt,onMaskChange:at,onDetectionStarted:it,onDark:st,onFaceAngle:ot,isFixedMask:Mt,idType:gt,onHeadWear:ut,onLenses:ct,onEyesClosed:dt,onFaceMask:pt,onSwitchToManualCapture:ht,isLensesCheckEnabled:St,isMaskCheckEnabled:Dt,isClosedEyesCheckEnabled:yt,isHeadWearCheckEnabled:Tt,isKiosk:mt,isVideoSelfie:Rt,autocaptureTimeout:It,pipelineProfileTypes:Ut};if(Et===idDetection||Et===detectFace){const vt=async()=>{if(!state.detecting){await sleep(1e3);return}try{await Et(bt)}catch{}finally{await sleep(200),requestAnimationFrame(vt)}};requestAnimationFrame(vt)}else state.intervalId=window.setInterval(()=>{state.detecting&&Et(bt)},100)}function stopDetect(){window.clearInterval(state.intervalId),state.detecting=!1,state.skipFrames=!0}function resumeDetect(){state.detecting=!0,state.skipFrames=!0}function detectFrame(){return null}var lib$1={exports:{}},Modal$2={},propTypes$2={exports:{}};/*
941
941
  object-assign
942
942
  (c) Sindre Sorhus
943
943
  @license MIT
@@ -2412,7 +2412,7 @@ newPrivacyConsent.text4
2412
2412
  `).filter(it=>!!it.trim());return jsxs(ConsentWrapper$1,{role:"region","aria-live":"assertive",className:`
2413
2413
  ${me.default?"IncodeDefaultConsent":"IncodeCustomConsent"}
2414
2414
  `,children:[jsx(ConsentTitle,{tabIndex:0,children:rt}),at.map((it,ot)=>jsx(ConsentParagraph,{tabIndex:0,children:me.default?jsx(Markdown,{disallowedElements:disallowedMarkdownElements,children:Ge(it)}):jsx(Markdown,{disallowedElements:disallowedMarkdownElements,children:it})},ot)),jsx(AcceptCheck$2,{consentChecked:He,setConsentChecked:Xe,text:tt,id:"one"}),Ze?jsx(AcceptCheck$2,{consentChecked:Ke,setConsentChecked:$e,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 Ke=nt=>{const tt=nt.split(`
2415
- `);return tt.length===1?tt.join(" "):tt.filter(et=>!!et.trim()).map(et=>Ge(et)).join(" ")},$e=({title:nt,content:tt,isDefault:et})=>{addConsent({title:`${et?Ge(nt):nt}`,content:et?Ke(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:$e,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-20240419161640.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=(Ke=100,$e=3e3,nt=0,function(){return Math.random()*Math.min($e,Ke*Math.pow(2,nt++))}),Xe=Ge.current(),Ke,$e,nt,tt,et;if(Xe===void 0)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var rt=function(at,it){return Ze(at).catch(function(ot){if(it+1>=Je)throw ot;(function(ct){if(!(ct instanceof Error))return!1;var dt=ct.message;return dt===E||dt===b})(ot)?Ge.exclude():Ge.postpone();var st,ut=Ge.current();if(ut===void 0)throw ot;return(st=He(),new Promise(function(ct){return setTimeout(ct,st)})).then(function(){return rt(ut,it+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 $e=[],nt=function(){$e.push({time:new Date,state:document.visibilityState})},tt=function(et,rt,at,it){return et.addEventListener(rt,at,it),function(){return et.removeEventListener(rt,at,it)}}(document,"visibilitychange",nt);return nt(),[$e,tt]}(),Xe=He[0],Ke=He[1];return Promise.resolve().then(function(){if(!Ze||typeof Ze!="string")throw new Error(I);var $e=function(nt,tt){return(Array.isArray(nt)?nt:[nt]).map(function(et){return function(rt,at){var it=encodeURIComponent;return rt.replace(/<[^<>]+>/g,function(ot){return ot==="<version>"?"3":ot==="<apiKey>"?it(at):ot==="<loaderVersion>"?it(U):ot})}(String(et),tt)})}(Ge,Ze);return g($e,F)}).catch(function($e){throw Ke(),function(nt){return nt instanceof Error&&nt.message===b?new Error(M):nt}($e)}).then(function($e){var nt=$e[0],tt=$e[1];return Ke(),nt.load(__assign$1(__assign$1({},Je),{ldi:{attempts:tt,visibilityStates:Xe}}))})}function F(ue){return function(me,Ue,Qe,Ze){var Je,Ge=document,He="securitypolicyviolation",Xe=function($e){var nt=new URL(me,location.href),tt=$e.blockedURI;tt!==nt.href&&tt!==nt.protocol.slice(0,-1)&&tt!==nt.origin||(Je=$e,Ke())};Ge.addEventListener(He,Xe);var Ke=function(){return Ge.removeEventListener(He,Xe)};return Ze==null||Ze.then(Ke,Ke),Promise.resolve().then(Ue).then(function($e){return Ke(),$e},function($e){return new Promise(function(nt){return setTimeout(nt)}).then(function(){if(Ke(),Je)return Qe(Je);throw $e})})}(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:Ke,hostingApp:$e,ipLocation:nt}){return exports.api.post(fingerPrintUrl,{hash:ue,ip:me,deviceType:Ue,data:Ze,osVersion:Je,deviceModel:Ge,browser:He,hasLiedBrowser:Ke,sdkVersion:Xe,hostingApp:$e,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,Ke,$e;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:(Ke=He.ipLocation.subdivisions)==null?void 0:Ke[0].name,ipCity:($e=He.ipLocation.city)==null?void 0:$e.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 Ke=Xe.data;emptyQueue(Ke.token);const $e=await sendFingerprint({token:Ke.token,interviewId:Ke.interviewId}).catch(()=>({regulationType:"",showMandatoryConsent:!1}));Ke.regulationType=$e.regulationType??"",Ke.showMandatoryConsent=$e.showMandatoryConsent??!1;const tt=new UAParser().getResult();return addEvent({code:"browser",payload:{userAgent:window.navigator.userAgent,isWebRtcSupported:isWebRtcSupported(),...tt},token:Ke.token}),Ke}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 Ke=ue[He];Xe=isObject$4(Ke)||Array.isArray(Ke)?Ke: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:Ke,valueAsDate:$e,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:Ke?Ge===""?NaN:+Ge:$e?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 Ke=Ue.slice(0,-(Ge+1)),$e=Ke.length-1;for(Ge>0&&(Je=ue);++He<Ke.length;){const nt=Ke[He];Xe=Xe?Xe[nt]:ue[nt],$e===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 Ke=getFieldValue(ue,He,Qe);!isUndefined$1(Ke)&&set(Qe.current,He,Ke)}if(!Ge.type||!Xe){delete ue.current[He];return}isRadioInput(Ge)||isCheckBoxInput(Ge)?Array.isArray(Xe.options)&&Xe.options.length?(compact(Xe.options).forEach((Ke={},$e)=>{(isDetached(Ke.ref)&&isSameRef(Ke,Ke.ref)||Je)&&(removeAllEventListeners(Ke.ref,me),unset(Xe.options,`[${$e}]`))}),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:Ke,pattern:$e,validate:nt},tt)=>{const et=Ue.name,rt={},at=isRadioInput(Ue),it=isCheckBoxInput(Ue),ot=at||it,st=Qe==="",ut=appendErrors.bind(null,et,me,rt),ct=(dt,pt,ht,gt=INPUT_VALIDATION_RULES.maxLength,Mt=INPUT_VALIDATION_RULES.minLength)=>{const St=dt?pt:ht;rt[et]=Object.assign({type:dt?gt:Mt,message:St,ref:Ue},ut(dt?gt:Mt,St))};if(Je&&(!at&&!it&&(st||isNullOrUndefined(Qe))||isBoolean(Qe)&&!Qe||it&&!getCheckboxValue(Ze).isValid||at&&!getRadioValue(Ze).isValid)){const{value:dt,message:pt}=isMessage(Je)?{value:!!Je,message:Je}:getValueAndMessage(Je);if(dt&&(rt[et]=Object.assign({type:INPUT_VALIDATION_RULES.required,message:pt,ref:ot?((ue.current[et].options||[])[0]||{}).ref:Ue},ut(INPUT_VALIDATION_RULES.required,pt)),!me))return rt}if((!isNullOrUndefined(Xe)||!isNullOrUndefined(Ke))&&Qe!==""){let dt,pt;const ht=getValueAndMessage(Ke),gt=getValueAndMessage(Xe);if(isNaN(Qe)){const Mt=Ue.valueAsDate||new Date(Qe);isString$2(ht.value)&&(dt=Mt>new Date(ht.value)),isString$2(gt.value)&&(pt=Mt<new Date(gt.value))}else{const Mt=Ue.valueAsNumber||parseFloat(Qe);isNullOrUndefined(ht.value)||(dt=Mt>ht.value),isNullOrUndefined(gt.value)||(pt=Mt<gt.value)}if((dt||pt)&&(ct(!!dt,ht.message,gt.message,INPUT_VALIDATION_RULES.max,INPUT_VALIDATION_RULES.min),!me))return rt}if(isString$2(Qe)&&!st&&(Ge||He)){const dt=getValueAndMessage(Ge),pt=getValueAndMessage(He),ht=!isNullOrUndefined(dt.value)&&Qe.length>dt.value,gt=!isNullOrUndefined(pt.value)&&Qe.length<pt.value;if((ht||gt)&&(ct(ht,dt.message,pt.message),!me))return rt}if(isString$2(Qe)&&$e&&!st){const{value:dt,message:pt}=getValueAndMessage($e);if(isRegex(dt)&&!dt.test(Qe)&&(rt[et]=Object.assign({type:INPUT_VALIDATION_RULES.pattern,message:pt,ref:Ue},ut(INPUT_VALIDATION_RULES.pattern,pt)),!me))return rt}if(nt){const dt=getFieldValue(ue,et,tt,!1,!0),pt=ot&&Ze?Ze[0].ref:Ue;if(isFunction$1(nt)){const ht=await nt(dt),gt=getValidateError(ht,pt);if(gt&&(rt[et]=Object.assign(Object.assign({},gt),ut(INPUT_VALIDATION_RULES.validate,gt.message)),!me))return rt}else if(isObject$4(nt)){let ht={};for(const[gt,Mt]of Object.entries(nt)){if(!isEmptyObject(ht)&&!me)break;const St=await Mt(dt),Dt=getValidateError(St,pt,gt);Dt&&(ht=Object.assign(Object.assign({},Dt),ut(gt,Dt.message)),me&&(rt[et]=ht))}if(!isEmptyObject(ht)&&(rt[et]=Object.assign({ref:pt},ht),!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({}),Ke=React$1.useRef({}),$e=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({}),it=React$1.useRef(Ze),ot=React$1.useRef(!1),st=React$1.useRef(!1),ut=React$1.useRef(),ct=React$1.useRef({}),dt=React$1.useRef({}),pt=React$1.useRef(Qe),ht=React$1.useRef(Ue),gt=React$1.useRef(new Set),Mt=React$1.useRef(modeChecker(ue)),{isOnSubmit:St,isOnTouch:Dt}=Mt.current,yt=He===VALIDATION_MODE.all,[Tt,mt]=React$1.useState({isDirty:!1,isValidating:!1,dirtyFields:{},isSubmitted:!1,submitCount:0,touched:{},isSubmitting:!1,isSubmitSuccessful:!1,isValid:!St,errors:{}}),Rt=React$1.useRef({isDirty:!isProxyEnabled,dirtyFields:!isProxyEnabled,touched:!isProxyEnabled||Dt,isValidating:!isProxyEnabled,isSubmitting:!isProxyEnabled,isValid:!isProxyEnabled}),Ut=React$1.useRef(Tt),It=React$1.useRef(),{isOnBlur:Et,isOnChange:bt}=React$1.useRef(modeChecker(me)).current;pt.current=Qe,ht.current=Ue,Ut.current=Tt,ct.current=Ge?{}:isEmptyObject(ct.current)?cloneObject(Ze):ct.current;const vt=React$1.useCallback((Ht={})=>{ot.current||(Ut.current=Object.assign(Object.assign({},Ut.current),Ht),mt(Ut.current))},[]),xt=()=>Rt.current.isValidating&&vt({isValidating:!0}),Bt=React$1.useCallback((Ht,$t,nn=!1,sn={},rn)=>{let hn=nn||isErrorStateChanged({errors:Ut.current.errors,error:$t,name:Ht,validFields:at.current,fieldsWithValidation:rt.current});const Nn=get(Ut.current.errors,Ht);$t?(unset(at.current,Ht),hn=hn||!Nn||!deepEqual(Nn,$t,!0),set(Ut.current.errors,Ht,$t)):((get(rt.current,Ht)||ht.current)&&(set(at.current,Ht,!0),hn=hn||Nn),unset(Ut.current.errors,Ht)),(hn&&!isNullOrUndefined(nn)||!isEmptyObject(sn)||Rt.current.isValidating)&&vt(Object.assign(Object.assign(Object.assign({},sn),ht.current?{isValid:!!rn}:{}),{isValidating:!1}))},[]),Ct=React$1.useCallback((Ht,$t)=>{const{ref:nn,options:sn}=Xe.current[Ht],rn=isWeb&&isHTMLElement(nn)&&isNullOrUndefined($t)?"":$t;isRadioInput(nn)?(sn||[]).forEach(({ref:hn})=>hn.checked=hn.value===rn):isFileInput(nn)&&!isString$2(rn)?nn.files=rn:isMultipleSelect(nn)?[...nn.options].forEach(hn=>hn.selected=rn.includes(hn.value)):isCheckBoxInput(nn)&&sn?sn.length>1?sn.forEach(({ref:hn})=>hn.checked=Array.isArray(rn)?!!rn.find(Nn=>Nn===hn.value):rn===hn.value):sn[0].ref.checked=!!rn:nn.value=rn},[]),Zt=React$1.useCallback((Ht,$t)=>{if(Rt.current.isDirty){const nn=kt();return Ht&&$t&&set(nn,Ht,$t),!deepEqual(nn,it.current)}return!1},[]),Wt=React$1.useCallback((Ht,$t=!0)=>{if(Rt.current.isDirty||Rt.current.dirtyFields){const nn=!deepEqual(get(it.current,Ht),getFieldValue(Xe,Ht,ct)),sn=get(Ut.current.dirtyFields,Ht),rn=Ut.current.isDirty;nn?set(Ut.current.dirtyFields,Ht,!0):unset(Ut.current.dirtyFields,Ht);const hn={isDirty:Zt(),dirtyFields:Ut.current.dirtyFields},Nn=Rt.current.isDirty&&rn!==hn.isDirty||Rt.current.dirtyFields&&sn!==get(Ut.current.dirtyFields,Ht);return Nn&&$t&&vt(hn),Nn?hn:{}}return{}},[]),Ot=React$1.useCallback(async(Ht,$t)=>{if(process.env.NODE_ENV!=="production"&&!Xe.current[Ht])return console.warn("📋 Field is missing with `name` attribute: ",Ht),!1;const nn=(await validateField(Xe,yt,Xe.current[Ht],ct))[Ht];return Bt(Ht,nn,$t),isUndefined$1(nn)},[Bt,yt]),Xt=React$1.useCallback(async Ht=>{const{errors:$t}=await ht.current(kt(),pt.current,yt),nn=Ut.current.isValid;if(Array.isArray(Ht)){const sn=Ht.map(rn=>{const hn=get($t,rn);return hn?set(Ut.current.errors,rn,hn):unset(Ut.current.errors,rn),!hn}).every(Boolean);return vt({isValid:isEmptyObject($t),isValidating:!1}),sn}else{const sn=get($t,Ht);return Bt(Ht,sn,nn!==isEmptyObject($t),{},isEmptyObject($t)),!sn}},[Bt,yt]),Kt=React$1.useCallback(async Ht=>{const $t=Ht||Object.keys(Xe.current);if(xt(),ht.current)return Xt($t);if(Array.isArray($t)){!Ht&&(Ut.current.errors={});const nn=await Promise.all($t.map(async sn=>await Ot(sn,null)));return vt({isValidating:!1}),nn.every(Boolean)}return await Ot($t)},[Xt,Ot]),Jt=React$1.useCallback((Ht,$t,{shouldDirty:nn,shouldValidate:sn})=>{const rn={};set(rn,Ht,$t);for(const hn of getPath(Ht,$t))Xe.current[hn]&&(Ct(hn,get(rn,hn)),nn&&Wt(hn),sn&&Kt(hn))},[Kt,Ct,Wt]),jt=React$1.useCallback((Ht,$t,nn)=>{if(!Ge&&!isPrimitive($t)&&set(ct.current,Ht,Array.isArray($t)?[...$t]:Object.assign({},$t)),Xe.current[Ht])Ct(Ht,$t),nn.shouldDirty&&Wt(Ht),nn.shouldValidate&&Kt(Ht);else if(!isPrimitive($t)&&(Jt(Ht,$t,nn),gt.current.has(Ht))){const sn=getFieldArrayParentName(Ht)||Ht;set(Ke.current,Ht,$t),dt.current[sn]({[sn]:get(Ke.current,sn)}),(Rt.current.isDirty||Rt.current.dirtyFields)&&nn.shouldDirty&&(set(Ut.current.dirtyFields,Ht,setFieldArrayDirtyFields($t,get(it.current,Ht,[]),get(Ut.current.dirtyFields,Ht,[]))),vt({isDirty:!deepEqual(Object.assign(Object.assign({},kt()),{[Ht]:$t}),it.current)}))}!Ge&&set(ct.current,Ht,$t)},[Wt,Ct,Jt]),Ft=Ht=>st.current||nt.current.has(Ht)||nt.current.has((Ht.match(/\w+/)||[])[0]),lt=Ht=>{let $t=!0;if(!isEmptyObject(tt.current))for(const nn in tt.current)(!Ht||!tt.current[nn].size||tt.current[nn].has(Ht)||tt.current[nn].has(getFieldArrayParentName(Ht)))&&(et.current[nn](),$t=!1);return $t};function At(Ht,$t,nn){jt(Ht,$t,nn||{}),Ft(Ht)&&vt(),lt(Ht)}ut.current=ut.current?ut.current:async({type:Ht,target:$t})=>{let nn=$t.name;const sn=Xe.current[nn];let rn,hn;if(sn){const Nn=Ht===EVENTS.BLUR,En=skipValidation(Object.assign({isBlurEvent:Nn,isReValidateOnChange:bt,isReValidateOnBlur:Et,isTouched:!!get(Ut.current.touched,nn),isSubmitted:Ut.current.isSubmitted},Mt.current));let Cn=Wt(nn,!1),zn=!isEmptyObject(Cn)||!Nn&&Ft(nn);if(Nn&&!get(Ut.current.touched,nn)&&Rt.current.touched&&(set(Ut.current.touched,nn,!0),Cn=Object.assign(Object.assign({},Cn),{touched:Ut.current.touched})),!Ge&&isCheckBoxInput($t)&&set(ct.current,nn,getFieldValue(Xe,nn)),En)return!Nn&&lt(nn),(!isEmptyObject(Cn)||zn&&isEmptyObject(Cn))&&vt(Cn);if(xt(),ht.current){const{errors:jn}=await ht.current(kt(),pt.current,yt),Qn=Ut.current.isValid;if(rn=get(jn,nn),isCheckBoxInput($t)&&!rn&&ht.current){const Hn=getFieldArrayParentName(nn),wn=get(jn,Hn,{});wn.type&&wn.message&&(rn=wn),Hn&&(wn||get(Ut.current.errors,Hn))&&(nn=Hn)}hn=isEmptyObject(jn),Qn!==hn&&(zn=!0)}else rn=(await validateField(Xe,yt,sn,ct))[nn];!Nn&&lt(nn),Bt(nn,rn,zn,Cn,hn)}};function Qt(Ht){if(!Ge){let $t=cloneObject(Ht);for(const nn of gt.current)isKey(nn)&&!$t[nn]&&($t=Object.assign(Object.assign({},$t),{[nn]:[]}));return $t}return Ht}function kt(Ht){if(isString$2(Ht))return getFieldValue(Xe,Ht,ct);if(Array.isArray(Ht)){const $t={};for(const nn of Ht)set($t,nn,getFieldValue(Xe,nn,ct));return $t}return Qt(getFieldsValues(Xe,cloneObject(ct.current),Ge))}const zt=React$1.useCallback(async(Ht={})=>{const $t=isEmptyObject(Xe.current)?it.current:{},{errors:nn}=await ht.current(Object.assign(Object.assign(Object.assign({},$t),kt()),Ht),pt.current,yt)||{},sn=isEmptyObject(nn);Ut.current.isValid!==sn&&vt({isValid:sn})},[yt]),Yt=React$1.useCallback((Ht,$t)=>{findRemovedFieldAndRemoveListener(Xe,ut.current,Ht,ct,Ge,$t),Ge&&(unset(at.current,Ht.ref.name),unset(rt.current,Ht.ref.name))},[Ge]),_t=React$1.useCallback(Ht=>{if(st.current)vt();else{for(const $t of nt.current)if($t.startsWith(Ht)){vt();break}lt(Ht)}},[]),Pt=React$1.useCallback((Ht,$t)=>{Ht&&(Yt(Ht,$t),Ge&&!compact(Ht.options||[]).length&&(unset(Ut.current.errors,Ht.ref.name),set(Ut.current.dirtyFields,Ht.ref.name,!0),vt({isDirty:Zt()}),Rt.current.isValid&&ht.current&&zt(),_t(Ht.ref.name)))},[zt,Yt]);function ln(Ht){Ht&&(Array.isArray(Ht)?Ht:[Ht]).forEach($t=>Xe.current[$t]&&isKey($t)?delete Ut.current.errors[$t]:unset(Ut.current.errors,$t)),vt({errors:Ht?Ut.current.errors:{}})}function cn(Ht,$t){const nn=(Xe.current[Ht]||{}).ref;set(Ut.current.errors,Ht,Object.assign(Object.assign({},$t),{ref:nn})),vt({isValid:!1}),$t.shouldFocus&&nn&&nn.focus&&nn.focus()}const pn=React$1.useCallback((Ht,$t,nn)=>{const sn=nn?tt.current[nn]:nt.current;let rn=getFieldsValues(Xe,cloneObject(ct.current),Ge,!1,Ht);if(isString$2(Ht)){const Nn=getFieldArrayParentName(Ht)||Ht;return gt.current.has(Nn)&&(rn=Object.assign(Object.assign({},$e.current),rn)),assignWatchFields(rn,Ht,sn,isUndefined$1(get(it.current,Ht))?$t:get(it.current,Ht),!0)}const hn=isUndefined$1($t)?it.current:$t;return Array.isArray(Ht)?Ht.reduce((Nn,En)=>Object.assign(Object.assign({},Nn),{[En]:assignWatchFields(rn,En,sn,hn)}),{}):(st.current=isUndefined$1(nn),transformToNestObject(!isEmptyObject(rn)&&rn||hn))},[]);function yn(Ht,$t){return pn(Ht,$t)}function Tn(Ht){for(const $t of Array.isArray(Ht)?Ht:[Ht])Pt(Xe.current[$t],!0)}function on(Ht,$t={}){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(gt.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:nn,type:sn,value:rn}=Ht,hn=Object.assign({ref:Ht},$t),Nn=Xe.current,En=isRadioOrCheckboxFunction(Ht),Cn=isNameInFieldArray(gt.current,nn),zn=xn=>isWeb&&(!isHTMLElement(Ht)||xn===Ht);let jn=Nn[nn],Qn=!0,Hn;if(jn&&(En?Array.isArray(jn.options)&&compact(jn.options).find(xn=>rn===xn.ref.value&&zn(xn.ref)):zn(jn.ref))){Nn[nn]=Object.assign(Object.assign({},jn),$t);return}sn?jn=En?Object.assign({options:[...compact(jn&&jn.options||[]),{ref:Ht}],ref:{type:sn,name:nn}},$t):Object.assign({},hn):jn=hn,Nn[nn]=jn;const wn=isUndefined$1(get(ct.current,nn));(!isEmptyObject(it.current)||!wn)&&(Hn=get(wn?it.current:ct.current,nn),Qn=isUndefined$1(Hn),!Qn&&!Cn&&Ct(nn,Hn)),isEmptyObject($t)||(set(rt.current,nn,!0),!St&&Rt.current.isValid&&validateField(Xe,yt,jn,ct).then(xn=>{const Yn=Ut.current.isValid;isEmptyObject(xn)?set(at.current,nn,!0):unset(at.current,nn),Yn!==isEmptyObject(xn)&&vt()})),Ge&&!(Cn&&Qn)&&!Cn&&unset(Ut.current.dirtyFields,nn),sn&&attachEventListeners(En&&jn.options?jn.options[jn.options.length-1]:jn,En||isSelectInput(Ht),ut.current)}function fn(Ht,$t){if(!isWindowUndefined)if(isString$2(Ht))on({name:Ht},$t);else if(isObject$4(Ht)&&"name"in Ht)on(Ht,$t);else return nn=>nn&&on(nn,Ht)}const mn=React$1.useCallback((Ht,$t)=>async nn=>{nn&&nn.preventDefault&&(nn.preventDefault(),nn.persist());let sn={},rn=Qt(getFieldsValues(Xe,cloneObject(ct.current),Ge,!0));Rt.current.isSubmitting&&vt({isSubmitting:!0});try{if(ht.current){const{errors:hn,values:Nn}=await ht.current(rn,pt.current,yt);Ut.current.errors=sn=hn,rn=Nn}else for(const hn of Object.values(Xe.current))if(hn){const{name:Nn}=hn.ref,En=await validateField(Xe,yt,hn,ct);En[Nn]?(set(sn,Nn,En[Nn]),unset(at.current,Nn)):get(rt.current,Nn)&&(unset(Ut.current.errors,Nn),set(at.current,Nn,!0))}isEmptyObject(sn)&&Object.keys(Ut.current.errors).every(hn=>hn in Xe.current)?(vt({errors:{},isSubmitting:!0}),await Ht(rn,nn)):(Ut.current.errors=Object.assign(Object.assign({},Ut.current.errors),sn),$t&&await $t(Ut.current.errors,nn),Je&&focusOnErrorField(Xe.current,Ut.current.errors))}finally{Ut.current.isSubmitting=!1,vt({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:isEmptyObject(Ut.current.errors),submitCount:Ut.current.submitCount+1})}},[Je,yt]),vn=({errors:Ht,isDirty:$t,isSubmitted:nn,touched:sn,isValid:rn,submitCount:hn,dirtyFields:Nn})=>{rn||(at.current={},rt.current={}),Ke.current={},nt.current=new Set,st.current=!1,vt({submitCount:hn?Ut.current.submitCount:0,isDirty:$t?Ut.current.isDirty:!1,isSubmitted:nn?Ut.current.isSubmitted:!1,isValid:rn?Ut.current.isValid:!1,dirtyFields:Nn?Ut.current.dirtyFields:{},touched:sn?Ut.current.touched:{},errors:Ht?Ut.current.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})},un=(Ht,$t={})=>{if(isWeb){for(const nn of Object.values(Xe.current))if(nn){const{ref:sn,options:rn}=nn,hn=isRadioOrCheckboxFunction(sn)&&Array.isArray(rn)?rn[0].ref:sn;if(isHTMLElement(hn))try{hn.closest("form").reset();break}catch{}}}Xe.current={},it.current=Object.assign({},Ht||it.current),Ht&&lt(""),Object.values(dt.current).forEach(nn=>isFunction$1(nn)&&nn()),ct.current=Ge?{}:cloneObject(Ht||it.current),vn($t)};React$1.useEffect(()=>{Ue&&Rt.current.isValid&&zt(),It.current=It.current||!isWeb?It.current:onDomRemove(Xe,Pt)},[Pt,it.current]),React$1.useEffect(()=>()=>{It.current&&It.current.disconnect(),ot.current=!0,process.env.NODE_ENV==="production"&&Object.values(Xe.current).forEach(Ht=>Pt(Ht,!0))},[]),!Ue&&Rt.current.isValid&&(Tt.isValid=deepEqual(at.current,rt.current)&&isEmptyObject(Ut.current.errors));const dn={trigger:Kt,setValue:React$1.useCallback(At,[jt,Kt]),getValues:React$1.useCallback(kt,[]),register:React$1.useCallback(fn,[it.current]),unregister:React$1.useCallback(Tn,[]),formState:isProxyEnabled?new Proxy(Tt,{get:(Ht,$t)=>{if(process.env.NODE_ENV!=="production"&&$t==="isValid"&&St&&console.warn("📋 `formState.isValid` is applicable with `onTouched`, `onChange` or `onBlur` mode. https://react-hook-form.com/api#formState"),$t in Ht)return Rt.current[$t]=!0,Ht[$t]}}):Tt},qt=React$1.useMemo(()=>Object.assign({isFormDirty:Zt,updateWatchedValue:_t,shouldUnregister:Ge,updateFormState:vt,removeFieldEventListener:Yt,watchInternal:pn,mode:Mt.current,reValidateMode:{isReValidateOnBlur:Et,isReValidateOnChange:bt},validateResolver:Ue?zt:void 0,fieldsRef:Xe,resetFieldArrayFunctionRef:dt,useWatchFieldsRef:tt,useWatchRenderFunctionsRef:et,fieldArrayDefaultValuesRef:Ke,validFieldsRef:at,fieldsWithValidationRef:rt,fieldArrayNamesRef:gt,readFormStateRef:Rt,formStateRef:Ut,defaultValuesRef:it,shallowFieldsStateRef:ct,fieldArrayValuesRef:$e},dn),[it.current,_t,Ge,Yt,pn]);return Object.assign({watch:yn,control:qt,handleSubmit:mn,reset:React$1.useCallback(un,[]),clearErrors:React$1.useCallback(ln,[]),setError:React$1.useCallback(cn,[]),errors:Tt.errors},dn)}/*! *****************************************************************************
2415
+ `);return tt.length===1?tt.join(" "):tt.filter(et=>!!et.trim()).map(et=>Ge(et)).join(" ")},$e=({title:nt,content:tt,isDefault:et})=>{addConsent({title:`${et?Ge(nt):nt}`,content:et?Ke(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:$e,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-20240419164253.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=(Ke=100,$e=3e3,nt=0,function(){return Math.random()*Math.min($e,Ke*Math.pow(2,nt++))}),Xe=Ge.current(),Ke,$e,nt,tt,et;if(Xe===void 0)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var rt=function(at,it){return Ze(at).catch(function(ot){if(it+1>=Je)throw ot;(function(ct){if(!(ct instanceof Error))return!1;var dt=ct.message;return dt===E||dt===b})(ot)?Ge.exclude():Ge.postpone();var st,ut=Ge.current();if(ut===void 0)throw ot;return(st=He(),new Promise(function(ct){return setTimeout(ct,st)})).then(function(){return rt(ut,it+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 $e=[],nt=function(){$e.push({time:new Date,state:document.visibilityState})},tt=function(et,rt,at,it){return et.addEventListener(rt,at,it),function(){return et.removeEventListener(rt,at,it)}}(document,"visibilitychange",nt);return nt(),[$e,tt]}(),Xe=He[0],Ke=He[1];return Promise.resolve().then(function(){if(!Ze||typeof Ze!="string")throw new Error(I);var $e=function(nt,tt){return(Array.isArray(nt)?nt:[nt]).map(function(et){return function(rt,at){var it=encodeURIComponent;return rt.replace(/<[^<>]+>/g,function(ot){return ot==="<version>"?"3":ot==="<apiKey>"?it(at):ot==="<loaderVersion>"?it(U):ot})}(String(et),tt)})}(Ge,Ze);return g($e,F)}).catch(function($e){throw Ke(),function(nt){return nt instanceof Error&&nt.message===b?new Error(M):nt}($e)}).then(function($e){var nt=$e[0],tt=$e[1];return Ke(),nt.load(__assign$1(__assign$1({},Je),{ldi:{attempts:tt,visibilityStates:Xe}}))})}function F(ue){return function(me,Ue,Qe,Ze){var Je,Ge=document,He="securitypolicyviolation",Xe=function($e){var nt=new URL(me,location.href),tt=$e.blockedURI;tt!==nt.href&&tt!==nt.protocol.slice(0,-1)&&tt!==nt.origin||(Je=$e,Ke())};Ge.addEventListener(He,Xe);var Ke=function(){return Ge.removeEventListener(He,Xe)};return Ze==null||Ze.then(Ke,Ke),Promise.resolve().then(Ue).then(function($e){return Ke(),$e},function($e){return new Promise(function(nt){return setTimeout(nt)}).then(function(){if(Ke(),Je)return Qe(Je);throw $e})})}(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:Ke,hostingApp:$e,ipLocation:nt}){return exports.api.post(fingerPrintUrl,{hash:ue,ip:me,deviceType:Ue,data:Ze,osVersion:Je,deviceModel:Ge,browser:He,hasLiedBrowser:Ke,sdkVersion:Xe,hostingApp:$e,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,Ke,$e;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:(Ke=He.ipLocation.subdivisions)==null?void 0:Ke[0].name,ipCity:($e=He.ipLocation.city)==null?void 0:$e.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 Ke=Xe.data;emptyQueue(Ke.token);const $e=await sendFingerprint({token:Ke.token,interviewId:Ke.interviewId}).catch(()=>({regulationType:"",showMandatoryConsent:!1}));Ke.regulationType=$e.regulationType??"",Ke.showMandatoryConsent=$e.showMandatoryConsent??!1;const tt=new UAParser().getResult();return addEvent({code:"browser",payload:{userAgent:window.navigator.userAgent,isWebRtcSupported:isWebRtcSupported(),...tt},token:Ke.token}),Ke}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 Ke=ue[He];Xe=isObject$4(Ke)||Array.isArray(Ke)?Ke: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:Ke,valueAsDate:$e,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:Ke?Ge===""?NaN:+Ge:$e?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 Ke=Ue.slice(0,-(Ge+1)),$e=Ke.length-1;for(Ge>0&&(Je=ue);++He<Ke.length;){const nt=Ke[He];Xe=Xe?Xe[nt]:ue[nt],$e===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 Ke=getFieldValue(ue,He,Qe);!isUndefined$1(Ke)&&set(Qe.current,He,Ke)}if(!Ge.type||!Xe){delete ue.current[He];return}isRadioInput(Ge)||isCheckBoxInput(Ge)?Array.isArray(Xe.options)&&Xe.options.length?(compact(Xe.options).forEach((Ke={},$e)=>{(isDetached(Ke.ref)&&isSameRef(Ke,Ke.ref)||Je)&&(removeAllEventListeners(Ke.ref,me),unset(Xe.options,`[${$e}]`))}),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:Ke,pattern:$e,validate:nt},tt)=>{const et=Ue.name,rt={},at=isRadioInput(Ue),it=isCheckBoxInput(Ue),ot=at||it,st=Qe==="",ut=appendErrors.bind(null,et,me,rt),ct=(dt,pt,ht,gt=INPUT_VALIDATION_RULES.maxLength,Mt=INPUT_VALIDATION_RULES.minLength)=>{const St=dt?pt:ht;rt[et]=Object.assign({type:dt?gt:Mt,message:St,ref:Ue},ut(dt?gt:Mt,St))};if(Je&&(!at&&!it&&(st||isNullOrUndefined(Qe))||isBoolean(Qe)&&!Qe||it&&!getCheckboxValue(Ze).isValid||at&&!getRadioValue(Ze).isValid)){const{value:dt,message:pt}=isMessage(Je)?{value:!!Je,message:Je}:getValueAndMessage(Je);if(dt&&(rt[et]=Object.assign({type:INPUT_VALIDATION_RULES.required,message:pt,ref:ot?((ue.current[et].options||[])[0]||{}).ref:Ue},ut(INPUT_VALIDATION_RULES.required,pt)),!me))return rt}if((!isNullOrUndefined(Xe)||!isNullOrUndefined(Ke))&&Qe!==""){let dt,pt;const ht=getValueAndMessage(Ke),gt=getValueAndMessage(Xe);if(isNaN(Qe)){const Mt=Ue.valueAsDate||new Date(Qe);isString$2(ht.value)&&(dt=Mt>new Date(ht.value)),isString$2(gt.value)&&(pt=Mt<new Date(gt.value))}else{const Mt=Ue.valueAsNumber||parseFloat(Qe);isNullOrUndefined(ht.value)||(dt=Mt>ht.value),isNullOrUndefined(gt.value)||(pt=Mt<gt.value)}if((dt||pt)&&(ct(!!dt,ht.message,gt.message,INPUT_VALIDATION_RULES.max,INPUT_VALIDATION_RULES.min),!me))return rt}if(isString$2(Qe)&&!st&&(Ge||He)){const dt=getValueAndMessage(Ge),pt=getValueAndMessage(He),ht=!isNullOrUndefined(dt.value)&&Qe.length>dt.value,gt=!isNullOrUndefined(pt.value)&&Qe.length<pt.value;if((ht||gt)&&(ct(ht,dt.message,pt.message),!me))return rt}if(isString$2(Qe)&&$e&&!st){const{value:dt,message:pt}=getValueAndMessage($e);if(isRegex(dt)&&!dt.test(Qe)&&(rt[et]=Object.assign({type:INPUT_VALIDATION_RULES.pattern,message:pt,ref:Ue},ut(INPUT_VALIDATION_RULES.pattern,pt)),!me))return rt}if(nt){const dt=getFieldValue(ue,et,tt,!1,!0),pt=ot&&Ze?Ze[0].ref:Ue;if(isFunction$1(nt)){const ht=await nt(dt),gt=getValidateError(ht,pt);if(gt&&(rt[et]=Object.assign(Object.assign({},gt),ut(INPUT_VALIDATION_RULES.validate,gt.message)),!me))return rt}else if(isObject$4(nt)){let ht={};for(const[gt,Mt]of Object.entries(nt)){if(!isEmptyObject(ht)&&!me)break;const St=await Mt(dt),Dt=getValidateError(St,pt,gt);Dt&&(ht=Object.assign(Object.assign({},Dt),ut(gt,Dt.message)),me&&(rt[et]=ht))}if(!isEmptyObject(ht)&&(rt[et]=Object.assign({ref:pt},ht),!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({}),Ke=React$1.useRef({}),$e=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({}),it=React$1.useRef(Ze),ot=React$1.useRef(!1),st=React$1.useRef(!1),ut=React$1.useRef(),ct=React$1.useRef({}),dt=React$1.useRef({}),pt=React$1.useRef(Qe),ht=React$1.useRef(Ue),gt=React$1.useRef(new Set),Mt=React$1.useRef(modeChecker(ue)),{isOnSubmit:St,isOnTouch:Dt}=Mt.current,yt=He===VALIDATION_MODE.all,[Tt,mt]=React$1.useState({isDirty:!1,isValidating:!1,dirtyFields:{},isSubmitted:!1,submitCount:0,touched:{},isSubmitting:!1,isSubmitSuccessful:!1,isValid:!St,errors:{}}),Rt=React$1.useRef({isDirty:!isProxyEnabled,dirtyFields:!isProxyEnabled,touched:!isProxyEnabled||Dt,isValidating:!isProxyEnabled,isSubmitting:!isProxyEnabled,isValid:!isProxyEnabled}),Ut=React$1.useRef(Tt),It=React$1.useRef(),{isOnBlur:Et,isOnChange:bt}=React$1.useRef(modeChecker(me)).current;pt.current=Qe,ht.current=Ue,Ut.current=Tt,ct.current=Ge?{}:isEmptyObject(ct.current)?cloneObject(Ze):ct.current;const vt=React$1.useCallback((Ht={})=>{ot.current||(Ut.current=Object.assign(Object.assign({},Ut.current),Ht),mt(Ut.current))},[]),xt=()=>Rt.current.isValidating&&vt({isValidating:!0}),Bt=React$1.useCallback((Ht,$t,nn=!1,sn={},rn)=>{let hn=nn||isErrorStateChanged({errors:Ut.current.errors,error:$t,name:Ht,validFields:at.current,fieldsWithValidation:rt.current});const Nn=get(Ut.current.errors,Ht);$t?(unset(at.current,Ht),hn=hn||!Nn||!deepEqual(Nn,$t,!0),set(Ut.current.errors,Ht,$t)):((get(rt.current,Ht)||ht.current)&&(set(at.current,Ht,!0),hn=hn||Nn),unset(Ut.current.errors,Ht)),(hn&&!isNullOrUndefined(nn)||!isEmptyObject(sn)||Rt.current.isValidating)&&vt(Object.assign(Object.assign(Object.assign({},sn),ht.current?{isValid:!!rn}:{}),{isValidating:!1}))},[]),Ct=React$1.useCallback((Ht,$t)=>{const{ref:nn,options:sn}=Xe.current[Ht],rn=isWeb&&isHTMLElement(nn)&&isNullOrUndefined($t)?"":$t;isRadioInput(nn)?(sn||[]).forEach(({ref:hn})=>hn.checked=hn.value===rn):isFileInput(nn)&&!isString$2(rn)?nn.files=rn:isMultipleSelect(nn)?[...nn.options].forEach(hn=>hn.selected=rn.includes(hn.value)):isCheckBoxInput(nn)&&sn?sn.length>1?sn.forEach(({ref:hn})=>hn.checked=Array.isArray(rn)?!!rn.find(Nn=>Nn===hn.value):rn===hn.value):sn[0].ref.checked=!!rn:nn.value=rn},[]),Zt=React$1.useCallback((Ht,$t)=>{if(Rt.current.isDirty){const nn=kt();return Ht&&$t&&set(nn,Ht,$t),!deepEqual(nn,it.current)}return!1},[]),Wt=React$1.useCallback((Ht,$t=!0)=>{if(Rt.current.isDirty||Rt.current.dirtyFields){const nn=!deepEqual(get(it.current,Ht),getFieldValue(Xe,Ht,ct)),sn=get(Ut.current.dirtyFields,Ht),rn=Ut.current.isDirty;nn?set(Ut.current.dirtyFields,Ht,!0):unset(Ut.current.dirtyFields,Ht);const hn={isDirty:Zt(),dirtyFields:Ut.current.dirtyFields},Nn=Rt.current.isDirty&&rn!==hn.isDirty||Rt.current.dirtyFields&&sn!==get(Ut.current.dirtyFields,Ht);return Nn&&$t&&vt(hn),Nn?hn:{}}return{}},[]),Ot=React$1.useCallback(async(Ht,$t)=>{if(process.env.NODE_ENV!=="production"&&!Xe.current[Ht])return console.warn("📋 Field is missing with `name` attribute: ",Ht),!1;const nn=(await validateField(Xe,yt,Xe.current[Ht],ct))[Ht];return Bt(Ht,nn,$t),isUndefined$1(nn)},[Bt,yt]),Xt=React$1.useCallback(async Ht=>{const{errors:$t}=await ht.current(kt(),pt.current,yt),nn=Ut.current.isValid;if(Array.isArray(Ht)){const sn=Ht.map(rn=>{const hn=get($t,rn);return hn?set(Ut.current.errors,rn,hn):unset(Ut.current.errors,rn),!hn}).every(Boolean);return vt({isValid:isEmptyObject($t),isValidating:!1}),sn}else{const sn=get($t,Ht);return Bt(Ht,sn,nn!==isEmptyObject($t),{},isEmptyObject($t)),!sn}},[Bt,yt]),Kt=React$1.useCallback(async Ht=>{const $t=Ht||Object.keys(Xe.current);if(xt(),ht.current)return Xt($t);if(Array.isArray($t)){!Ht&&(Ut.current.errors={});const nn=await Promise.all($t.map(async sn=>await Ot(sn,null)));return vt({isValidating:!1}),nn.every(Boolean)}return await Ot($t)},[Xt,Ot]),Jt=React$1.useCallback((Ht,$t,{shouldDirty:nn,shouldValidate:sn})=>{const rn={};set(rn,Ht,$t);for(const hn of getPath(Ht,$t))Xe.current[hn]&&(Ct(hn,get(rn,hn)),nn&&Wt(hn),sn&&Kt(hn))},[Kt,Ct,Wt]),jt=React$1.useCallback((Ht,$t,nn)=>{if(!Ge&&!isPrimitive($t)&&set(ct.current,Ht,Array.isArray($t)?[...$t]:Object.assign({},$t)),Xe.current[Ht])Ct(Ht,$t),nn.shouldDirty&&Wt(Ht),nn.shouldValidate&&Kt(Ht);else if(!isPrimitive($t)&&(Jt(Ht,$t,nn),gt.current.has(Ht))){const sn=getFieldArrayParentName(Ht)||Ht;set(Ke.current,Ht,$t),dt.current[sn]({[sn]:get(Ke.current,sn)}),(Rt.current.isDirty||Rt.current.dirtyFields)&&nn.shouldDirty&&(set(Ut.current.dirtyFields,Ht,setFieldArrayDirtyFields($t,get(it.current,Ht,[]),get(Ut.current.dirtyFields,Ht,[]))),vt({isDirty:!deepEqual(Object.assign(Object.assign({},kt()),{[Ht]:$t}),it.current)}))}!Ge&&set(ct.current,Ht,$t)},[Wt,Ct,Jt]),Ft=Ht=>st.current||nt.current.has(Ht)||nt.current.has((Ht.match(/\w+/)||[])[0]),lt=Ht=>{let $t=!0;if(!isEmptyObject(tt.current))for(const nn in tt.current)(!Ht||!tt.current[nn].size||tt.current[nn].has(Ht)||tt.current[nn].has(getFieldArrayParentName(Ht)))&&(et.current[nn](),$t=!1);return $t};function At(Ht,$t,nn){jt(Ht,$t,nn||{}),Ft(Ht)&&vt(),lt(Ht)}ut.current=ut.current?ut.current:async({type:Ht,target:$t})=>{let nn=$t.name;const sn=Xe.current[nn];let rn,hn;if(sn){const Nn=Ht===EVENTS.BLUR,En=skipValidation(Object.assign({isBlurEvent:Nn,isReValidateOnChange:bt,isReValidateOnBlur:Et,isTouched:!!get(Ut.current.touched,nn),isSubmitted:Ut.current.isSubmitted},Mt.current));let Cn=Wt(nn,!1),zn=!isEmptyObject(Cn)||!Nn&&Ft(nn);if(Nn&&!get(Ut.current.touched,nn)&&Rt.current.touched&&(set(Ut.current.touched,nn,!0),Cn=Object.assign(Object.assign({},Cn),{touched:Ut.current.touched})),!Ge&&isCheckBoxInput($t)&&set(ct.current,nn,getFieldValue(Xe,nn)),En)return!Nn&&lt(nn),(!isEmptyObject(Cn)||zn&&isEmptyObject(Cn))&&vt(Cn);if(xt(),ht.current){const{errors:jn}=await ht.current(kt(),pt.current,yt),Qn=Ut.current.isValid;if(rn=get(jn,nn),isCheckBoxInput($t)&&!rn&&ht.current){const Hn=getFieldArrayParentName(nn),wn=get(jn,Hn,{});wn.type&&wn.message&&(rn=wn),Hn&&(wn||get(Ut.current.errors,Hn))&&(nn=Hn)}hn=isEmptyObject(jn),Qn!==hn&&(zn=!0)}else rn=(await validateField(Xe,yt,sn,ct))[nn];!Nn&&lt(nn),Bt(nn,rn,zn,Cn,hn)}};function Qt(Ht){if(!Ge){let $t=cloneObject(Ht);for(const nn of gt.current)isKey(nn)&&!$t[nn]&&($t=Object.assign(Object.assign({},$t),{[nn]:[]}));return $t}return Ht}function kt(Ht){if(isString$2(Ht))return getFieldValue(Xe,Ht,ct);if(Array.isArray(Ht)){const $t={};for(const nn of Ht)set($t,nn,getFieldValue(Xe,nn,ct));return $t}return Qt(getFieldsValues(Xe,cloneObject(ct.current),Ge))}const zt=React$1.useCallback(async(Ht={})=>{const $t=isEmptyObject(Xe.current)?it.current:{},{errors:nn}=await ht.current(Object.assign(Object.assign(Object.assign({},$t),kt()),Ht),pt.current,yt)||{},sn=isEmptyObject(nn);Ut.current.isValid!==sn&&vt({isValid:sn})},[yt]),Yt=React$1.useCallback((Ht,$t)=>{findRemovedFieldAndRemoveListener(Xe,ut.current,Ht,ct,Ge,$t),Ge&&(unset(at.current,Ht.ref.name),unset(rt.current,Ht.ref.name))},[Ge]),_t=React$1.useCallback(Ht=>{if(st.current)vt();else{for(const $t of nt.current)if($t.startsWith(Ht)){vt();break}lt(Ht)}},[]),Pt=React$1.useCallback((Ht,$t)=>{Ht&&(Yt(Ht,$t),Ge&&!compact(Ht.options||[]).length&&(unset(Ut.current.errors,Ht.ref.name),set(Ut.current.dirtyFields,Ht.ref.name,!0),vt({isDirty:Zt()}),Rt.current.isValid&&ht.current&&zt(),_t(Ht.ref.name)))},[zt,Yt]);function ln(Ht){Ht&&(Array.isArray(Ht)?Ht:[Ht]).forEach($t=>Xe.current[$t]&&isKey($t)?delete Ut.current.errors[$t]:unset(Ut.current.errors,$t)),vt({errors:Ht?Ut.current.errors:{}})}function cn(Ht,$t){const nn=(Xe.current[Ht]||{}).ref;set(Ut.current.errors,Ht,Object.assign(Object.assign({},$t),{ref:nn})),vt({isValid:!1}),$t.shouldFocus&&nn&&nn.focus&&nn.focus()}const pn=React$1.useCallback((Ht,$t,nn)=>{const sn=nn?tt.current[nn]:nt.current;let rn=getFieldsValues(Xe,cloneObject(ct.current),Ge,!1,Ht);if(isString$2(Ht)){const Nn=getFieldArrayParentName(Ht)||Ht;return gt.current.has(Nn)&&(rn=Object.assign(Object.assign({},$e.current),rn)),assignWatchFields(rn,Ht,sn,isUndefined$1(get(it.current,Ht))?$t:get(it.current,Ht),!0)}const hn=isUndefined$1($t)?it.current:$t;return Array.isArray(Ht)?Ht.reduce((Nn,En)=>Object.assign(Object.assign({},Nn),{[En]:assignWatchFields(rn,En,sn,hn)}),{}):(st.current=isUndefined$1(nn),transformToNestObject(!isEmptyObject(rn)&&rn||hn))},[]);function yn(Ht,$t){return pn(Ht,$t)}function Tn(Ht){for(const $t of Array.isArray(Ht)?Ht:[Ht])Pt(Xe.current[$t],!0)}function on(Ht,$t={}){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(gt.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:nn,type:sn,value:rn}=Ht,hn=Object.assign({ref:Ht},$t),Nn=Xe.current,En=isRadioOrCheckboxFunction(Ht),Cn=isNameInFieldArray(gt.current,nn),zn=xn=>isWeb&&(!isHTMLElement(Ht)||xn===Ht);let jn=Nn[nn],Qn=!0,Hn;if(jn&&(En?Array.isArray(jn.options)&&compact(jn.options).find(xn=>rn===xn.ref.value&&zn(xn.ref)):zn(jn.ref))){Nn[nn]=Object.assign(Object.assign({},jn),$t);return}sn?jn=En?Object.assign({options:[...compact(jn&&jn.options||[]),{ref:Ht}],ref:{type:sn,name:nn}},$t):Object.assign({},hn):jn=hn,Nn[nn]=jn;const wn=isUndefined$1(get(ct.current,nn));(!isEmptyObject(it.current)||!wn)&&(Hn=get(wn?it.current:ct.current,nn),Qn=isUndefined$1(Hn),!Qn&&!Cn&&Ct(nn,Hn)),isEmptyObject($t)||(set(rt.current,nn,!0),!St&&Rt.current.isValid&&validateField(Xe,yt,jn,ct).then(xn=>{const Yn=Ut.current.isValid;isEmptyObject(xn)?set(at.current,nn,!0):unset(at.current,nn),Yn!==isEmptyObject(xn)&&vt()})),Ge&&!(Cn&&Qn)&&!Cn&&unset(Ut.current.dirtyFields,nn),sn&&attachEventListeners(En&&jn.options?jn.options[jn.options.length-1]:jn,En||isSelectInput(Ht),ut.current)}function fn(Ht,$t){if(!isWindowUndefined)if(isString$2(Ht))on({name:Ht},$t);else if(isObject$4(Ht)&&"name"in Ht)on(Ht,$t);else return nn=>nn&&on(nn,Ht)}const mn=React$1.useCallback((Ht,$t)=>async nn=>{nn&&nn.preventDefault&&(nn.preventDefault(),nn.persist());let sn={},rn=Qt(getFieldsValues(Xe,cloneObject(ct.current),Ge,!0));Rt.current.isSubmitting&&vt({isSubmitting:!0});try{if(ht.current){const{errors:hn,values:Nn}=await ht.current(rn,pt.current,yt);Ut.current.errors=sn=hn,rn=Nn}else for(const hn of Object.values(Xe.current))if(hn){const{name:Nn}=hn.ref,En=await validateField(Xe,yt,hn,ct);En[Nn]?(set(sn,Nn,En[Nn]),unset(at.current,Nn)):get(rt.current,Nn)&&(unset(Ut.current.errors,Nn),set(at.current,Nn,!0))}isEmptyObject(sn)&&Object.keys(Ut.current.errors).every(hn=>hn in Xe.current)?(vt({errors:{},isSubmitting:!0}),await Ht(rn,nn)):(Ut.current.errors=Object.assign(Object.assign({},Ut.current.errors),sn),$t&&await $t(Ut.current.errors,nn),Je&&focusOnErrorField(Xe.current,Ut.current.errors))}finally{Ut.current.isSubmitting=!1,vt({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:isEmptyObject(Ut.current.errors),submitCount:Ut.current.submitCount+1})}},[Je,yt]),vn=({errors:Ht,isDirty:$t,isSubmitted:nn,touched:sn,isValid:rn,submitCount:hn,dirtyFields:Nn})=>{rn||(at.current={},rt.current={}),Ke.current={},nt.current=new Set,st.current=!1,vt({submitCount:hn?Ut.current.submitCount:0,isDirty:$t?Ut.current.isDirty:!1,isSubmitted:nn?Ut.current.isSubmitted:!1,isValid:rn?Ut.current.isValid:!1,dirtyFields:Nn?Ut.current.dirtyFields:{},touched:sn?Ut.current.touched:{},errors:Ht?Ut.current.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})},un=(Ht,$t={})=>{if(isWeb){for(const nn of Object.values(Xe.current))if(nn){const{ref:sn,options:rn}=nn,hn=isRadioOrCheckboxFunction(sn)&&Array.isArray(rn)?rn[0].ref:sn;if(isHTMLElement(hn))try{hn.closest("form").reset();break}catch{}}}Xe.current={},it.current=Object.assign({},Ht||it.current),Ht&&lt(""),Object.values(dt.current).forEach(nn=>isFunction$1(nn)&&nn()),ct.current=Ge?{}:cloneObject(Ht||it.current),vn($t)};React$1.useEffect(()=>{Ue&&Rt.current.isValid&&zt(),It.current=It.current||!isWeb?It.current:onDomRemove(Xe,Pt)},[Pt,it.current]),React$1.useEffect(()=>()=>{It.current&&It.current.disconnect(),ot.current=!0,process.env.NODE_ENV==="production"&&Object.values(Xe.current).forEach(Ht=>Pt(Ht,!0))},[]),!Ue&&Rt.current.isValid&&(Tt.isValid=deepEqual(at.current,rt.current)&&isEmptyObject(Ut.current.errors));const dn={trigger:Kt,setValue:React$1.useCallback(At,[jt,Kt]),getValues:React$1.useCallback(kt,[]),register:React$1.useCallback(fn,[it.current]),unregister:React$1.useCallback(Tn,[]),formState:isProxyEnabled?new Proxy(Tt,{get:(Ht,$t)=>{if(process.env.NODE_ENV!=="production"&&$t==="isValid"&&St&&console.warn("📋 `formState.isValid` is applicable with `onTouched`, `onChange` or `onBlur` mode. https://react-hook-form.com/api#formState"),$t in Ht)return Rt.current[$t]=!0,Ht[$t]}}):Tt},qt=React$1.useMemo(()=>Object.assign({isFormDirty:Zt,updateWatchedValue:_t,shouldUnregister:Ge,updateFormState:vt,removeFieldEventListener:Yt,watchInternal:pn,mode:Mt.current,reValidateMode:{isReValidateOnBlur:Et,isReValidateOnChange:bt},validateResolver:Ue?zt:void 0,fieldsRef:Xe,resetFieldArrayFunctionRef:dt,useWatchFieldsRef:tt,useWatchRenderFunctionsRef:et,fieldArrayDefaultValuesRef:Ke,validFieldsRef:at,fieldsWithValidationRef:rt,fieldArrayNamesRef:gt,readFormStateRef:Rt,formStateRef:Ut,defaultValuesRef:it,shallowFieldsStateRef:ct,fieldArrayValuesRef:$e},dn),[it.current,_t,Ge,Yt,pn]);return Object.assign({watch:yn,control:qt,handleSubmit:mn,reset:React$1.useCallback(un,[]),clearErrors:React$1.useCallback(ln,[]),setError:React$1.useCallback(cn,[]),errors:Tt.errors},dn)}/*! *****************************************************************************
2416
2416
  Copyright (c) Microsoft Corporation.
2417
2417
 
2418
2418
  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-20240419161640.0",
6
+ "version": "1.71.0-20240419164253.0",
7
7
  "publishConfig": {},
8
8
  "exports": {
9
9
  ".": {