/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@scandit/web-datacapture-id@8.3.0/build/js/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
import{Brush,Color,CameraSettings,VideoResolution,FocusGestureStrategy,Logger,Feedback,Sound,Quadrilateral,DataCaptureError,Localization,INTERNAL_ACCESS,AdditionalLayerPosition,DataCaptureContext,BrowserHelper,DataCaptureLoader,assertUnreachable,Point}from"@scandit/web-datacapture-core";import{SafeStorage}from"@scandit/web-datacapture-core/build/js/private/utils/safeStorage.js";import{ScanditHTMLElement,html,defineCustomElements,css}from"@scandit/web-datacapture-core/build/js/private/utils/index.js";var l={"scandit-datacapture-sdk-id-simd-pthreads.wasm":{bytes:10172712},"scandit-datacapture-sdk-id-pthreads.wasm":{bytes:10270312},"scandit-datacapture-sdk-id-simd.wasm":{bytes:10059403},"scandit-datacapture-sdk-id.wasm":{bytes:10157757}},Xe=(e=>(e.Undefined="Undefined",e.RecoveredAfterFailure="RecoveredAfterFailure",e.InvalidLicenseKeyForVIZProcessing="InvalidLicenseKeyForVIZProcessing",e.InvalidSettingsForVIZProcessing="InvalidSettingsForVIZProcessing",e.InvalidLicenseKeyForParser="InvalidLicenseKeyForParser",e))(Xe||{}),O=class e extends Error{constructor(){super(...arguments),this._type="Undefined",this._message=""}get type(){return this._type}get message(){return this._message}static create(t){let a=new e;return t&&(a.name=t.type,a._type=t.type,a._message=t.message),a}static fromJSON(t){let a=new e;return a._type=t.type,a._message=t.message,a}},de=class{constructor(e){this.idCaptureWorkerManager=e}get workerCommand(){return this.idCaptureWorkerManager.workerCommand.bind(this.idCaptureWorkerManager)}async getLicenseText(){return(await this.workerCommand("getIdOpenSourceSoftwareLicenseInfo",{})).licenseText}},wt={"id.idCaptureOverlay.scanFrontSideHint":"","id.idCaptureOverlay.scanBackSideHint":"","id.idCaptureOverlay.moveCloseTextHint":"","id.idCaptureOverlay.moveFurtherAwayTextHint":"","id.idCaptureOverlay.tapShutterToScan":"","id.idCaptureOverlay.lookingForDocument":"","id.idCaptureOverlay.holdStill":"","id.idCaptureOverlay.processingDocument":"Processing..."};function At(e){let t=URL.createObjectURL(new Blob(['"use strict";(()=>{var ye=(a,e)=>()=>(a&&(e=a(a=0)),e);var m,u=ye(()=>{m={"scandit-datacapture-sdk-id-simd-pthreads.wasm":{bytes:10172712},"scandit-datacapture-sdk-id-pthreads.wasm":{bytes:10270312},"scandit-datacapture-sdk-id-simd.wasm":{bytes:10059403},"scandit-datacapture-sdk-id.wasm":{bytes:10157757}}});u();u();u();u();var o;(a=>{(c=>(c.Debug="debug",c.Info="info",c.Warn="warn",c.Error="error",c.Quiet="quiet"))(a.Level||(a.Level={}));let e=new Map([["debug",1],["info",2],["warn",3],["error",4],["quiet",5]]),r="debug";function t(c){r=c}a.setLevel=t;function s(c,...h){if(!(e.get(r)>e.get(c)))switch(c){case"debug":{console.debug(...h);break}case"info":{console.log(...h);break}case"warn":{console.warn(...h);break}case"error":{console.error(...h);break}}}a.log=s;function i(...c){s("warn",...c)}a.warn=i;function d(...c){s("debug",...c)}a.debug=d;function n(...c){s("info",...c)}a.info=n;function l(...c){s("error",...c)}a.error=l})(o||(o={}));u();u();var be=class{constructor(a){if(typeof a!="function")throw new TypeError("FinalizationRegistry callback must be a function")}register(a,e,r){}unregister(a){return!1}};function Q(a){typeof a.FinalizationRegistry>"u"&&(a.FinalizationRegistry=be)}u();u();function X(a,e,r){let t=e*r,s=new Uint8ClampedArray(t*4),i=new Uint32Array(s.buffer);for(let d=0;d<t;d++){let n=a[d];i[d]=4278190080|n<<16|n<<8|n}return s}u();u();var L=class Z extends Error{constructor(e){super(e.message),Object.setPrototypeOf(this,Z.prototype),this.name=e.name}toString(){return`${this.name}: ${this.message}`}};var R=Promise.resolve(),J=!1,z=!1,O=!1,M,U=1500,_="";async function ee(a){if(M==null)return;J=!0;let e;try{let r=new Promise((s,i)=>{e=setTimeout(()=>{o.debug(`IndexedDB database is blocked (timed out after ${U}ms). If you are running a Debug wasm build, things are slower and the timeout can be configured via IndexedDBBlockedTimeoutMs in localStorage (requires page reload).`),i(new L({name:"BlockedIndexedDB",message:"IndexedDB database is blocked"}))},U)}),t=new Promise((s,i)=>{M==null||M(a,d=>{d!=null?i(d):s()})});await Promise.race([t,r])}finally{e!==void 0&&clearTimeout(e),J=!1}}async function te(a){return z?(O=a,R):(J?(z=!0,O=a,R=R.then(async()=>(z=!1,ee(O)))):(O=a,R=ee(a)),R)}function we(){FS.syncfs=((a,e)=>{te(a).then(()=>e(),r=>e(r))})}async function ae(a){if(_=a.writableDataPath,U=a.indexedDBTimeoutMs,M=FS.syncfs,M==null)throw new Error("FS.syncfs is not available");we();try{FS.mkdir(_)}catch(e){if(e.code!=="EEXIST")throw M=void 0,e}try{FS.mount(IDBFS,{},_)}catch(e){throw M=void 0,e}return te(!0)}u();u();u();var re={};function De(a){return[...new Uint8Array(a)].map(e=>{let r=e.toString(16);return r.length===1?`0${r}`:r}).join("")}async function*ve(a){let e=a.getReader();try{for(;;){let{done:r,value:t}=await e.read();if(r)return;yield t}}finally{e.releaseLock()}}async function Me(a){let e=[],r=0,t=0;for await(let i of ve(a))e.push(i),r+=i.length;let s=new Uint8Array(r);for(let i of e)s.set(i,t),t+=i.length;return s.buffer}var xe=(a=>(a.VALID="VALID",a.INVALID="INVALID",a.NOT_VERIFIABLE="NOT_VERIFIABLE",a))(xe||{});async function Re(a,e,r){if(typeof crypto.subtle.digest!="function")return o.log(o.Level.Warn,`Insecure context (see https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts): The hash of the Scandit Data Capture library WASM file found at ${r} could not be verified`),"NOT_VERIFIABLE";try{let t=a instanceof Promise?await a:a,s=await crypto.subtle.digest("SHA-256",t),i=De(s);return e==null?(o.log(o.Level.Warn,"The library hash is not defined or empty, cannot correctly verify integrity."),"NOT_VERIFIABLE"):i===e?(o.log(o.Level.Debug,`Data Capture library WASM integrity found at ${r} has been verified correctly.`),"VALID"):(o.log(o.Level.Warn,`The Scandit Data Capture library WASM file found at ${r} seems invalid: expected file hash doesn\'t match (received: ${i}, expected: ${e}). Please ensure the correct Scandit Data Capture file (with correct version) is retrieved.`),"INVALID")}catch(t){return o.log(o.Level.Warn,"Wasm response could not be verified",t),"NOT_VERIFIABLE"}}var G=new Map([["br",4.4],["gzip",2.9],["none",1]]);function Fe(a){var e;let r="content-encoding";if(a==null||a.get(r)==null)return G.get("none");let t=new Set(((e=a.get(r))!=null?e:"").split(",").map(s=>s.trim()));for(let[s,i]of G)if(t.has(s))return i;return G.get("none")}function ke(a){var e,r;if(a==null)return 0;let t=(e=Fe(a))!=null?e:1,s=Number.parseInt((r=a.get("content-length"))!=null?r:"0",10);return Number.isNaN(s)?0:Math.floor(s*t*100)/100}function Ae(a){let{pathname:e}=new URL(a);for(let[r,t]of Object.entries(re))if(e.endsWith(r))return t.bytes;return 0}function se(a){re=a}var Pe=(a,e)=>{let r=ke(e);return r===0?Ae(a):r};function Ee(a,e,r,{onProgress:t,onError:s,onComplete:i}){if(!e.body)return[e];let d=Pe(a,e.headers),n=0,l=0;if(typeof TransformStream>"u")return o.warn("TransformStream is not supported in this environment. Progress tracking will be disabled."),[e];let[c,h]=r?e.body.tee():[e.body],f=c.pipeThrough(new TransformStream({async transform(I,g){try{n+=I.length,l=Number((n/d*100).toFixed(2)),d>0&&I.length>0&&l<100?t==null||t({percentage:l,loadedBytes:n,privateUri:a}):d===0&&I.length>0&&(t==null||t({percentage:null,loadedBytes:n,privateUri:a})),g.enqueue(I)}catch(C){g.error(C),s==null||s({error:C})}},flush(I){t==null||t({percentage:100,loadedBytes:n,privateUri:a}),i==null||i({percentage:100,loadedBytes:n,privateUri:a}),I.terminate()}}));return[new Response(f,{headers:new Headers(e.headers),status:e.status,statusText:e.statusText}),h]}async function $({wasmURI:a,expectedHash:e,verifyResponseHash:r,onProgress:t,onComplete:s,onError:i,referredOrigin:d}){let n=await fetch(a,{referrerPolicy:"origin",referrer:d!=null?d:""});if(!n.ok)throw new Error(`HTTP status code is not ok: ${n.status}, ${n.statusText}`);let[l,c]=Ee(a,n,r,{onProgress:t,onError:i,onComplete:s});return c!=null&&Re(Me(c),e,a),l}function ie({wasmURI:a,expectedHash:e,verifyResponseHash:r,progressCallback:t,successCallback:s,errorCallback:i,importObject:d,referredOrigin:n}){async function l(h){try{let f=await $({wasmURI:a,expectedHash:e,verifyResponseHash:r,onProgress:t,referredOrigin:n}),I=await(h!=null?h:f).arrayBuffer(),g=await self.WebAssembly.instantiate(I,d);s(g.instance,g.module)}catch(f){o.log(o.Level.Error,f),o.log(o.Level.Error,`Couldn\'t instantiate Scandit SDK DataCapture library at ${a}, did you configure the path for it correctly?`),i==null||i(f)}}async function c(){let h;try{h=await $({wasmURI:a,expectedHash:e,verifyResponseHash:r,onProgress:t,referredOrigin:n});let f=await self.WebAssembly.instantiateStreaming(h,d);s(f.instance,f.module)}catch(f){o.log(o.Level.Warn,f),o.log(o.Level.Warn,"WebAssembly streaming compile failed. Falling back to ArrayBuffer instantiation (this will make things slower)"),l((h==null?void 0:h.bodyUsed)===!0?void 0:h)}}typeof self.WebAssembly.instantiateStreaming=="function"?c():l()}async function j(a,e,r,t){return new Promise((s,i)=>{a().then(s).catch(d=>{let n=e*2;if(n>r){i(d);return}t(d),self.setTimeout(()=>{j(a,n,r,t).then(s).catch(i)},e)})})}function q(a){var e,r;let t="unknown";if((e=a.href)!=null&&e.startsWith("blob:null/"))t="localhost";else{let s=((r=a.pathname)==null?void 0:r.length)>1&&!a.pathname.startsWith("/");t=new URL(s?a.pathname:a.origin).hostname}return t.startsWith("[")&&t.endsWith("]")?(t=t.slice(1,-1),t):(/^(\\d{1,3}\\.){3}\\d{1,3}$/.test(t)&&(t=t.split(".").map(s=>Number.parseInt(s,10).toString()).join(".")),t)}async function ne(a,e){async function r(){return importScripts(a)}try{await j(r,250,4e3,s=>{o.log(o.Level.Warn,s),o.log(o.Level.Warn,`Couldn\'t retrieve Scandit Data Capture library at ${a}, retrying...`)}),self.Module.mainScriptUrlOrBlob=a;let t=self.SDC_WASM_JS_VERSION;return t!==e&&o.log(o.Level.Warn,`The Scandit Data Capture library JS file found at ${a} seems invalid: expected version doesn\'t match (received: ${t}, expected: ${e}). Please ensure the correct Scandit Data Capture file (with correct version) is retrieved.`),!0}catch(t){return o.log(o.Level.Error,t),!1}}u();u();var T=class{constructor(){this.promise=new Promise((a,e)=>{this.reject=e,this.resolve=a})}};var K=class{constructor(a,e){this.workerFunctions=a,this.options=e,this.imageIdCounter=0,this.conversions=new Map}convertToJpeg(a,e){let r=this.imageIdCounter++,t=new T;this.conversions.set(r,t);let s=a.toBitmap();return this.workerFunctions.postMessage({type:"convertToJPEG",imageId:r,width:a.getWidth(),height:a.getHeight(),data:s,planes:a.getPlanes(),orientation:e,quality:this.options.quality},Array.from(new Set([s.buffer]))),t.promise}convertToBitmap(a){return{data:a.toBitmap(),byteOrder:1}}onConvertToJPEGResult(a,e){let r=this.conversions.get(a);r?(r.resolve(e),this.conversions.delete(a)):o.warn(`ImageConverterForwarder: Conversion for imageId ${a} not found in Map`)}};u();u();var W=class{constructor(a){this.options=a}get quality(){return this.options.quality}async convertToJpeg(a,e){try{let{width:r,height:t,planes:s}=this.validateAndExtractImageData(a);this.prepareCanvas(r,t);let i=this.processImageData(a,s,r,t);return await this.convertToJpegBytes(i,e)}catch(r){throw o.warn(`Failed to convert image to JPEG: ${r}`),r instanceof Error?r:new Error("Failed to convert image to JPEG")}}convertToBitmap(a){return{data:a.toBitmap(),byteOrder:1}}validateAndExtractImageData(a){let e=a.getWidth(),r=a.getHeight(),t=a.getPlanes();if(e<=0||r<=0)throw o.warn(`Invalid image dimensions: ${e}x${r}`),new Error(`Invalid image dimensions: ${e}x${r}`);if(!t||t.length===0)throw o.warn("ImageBuffer has no planes"),new Error("ImageBuffer has no planes");return{width:e,height:r,planes:t}}prepareCanvas(a,e){if(!this.ensureCanvas(a,e))throw new Error("Failed to create OffscreenCanvas");if(!this.canvas||!this.context)throw new Error("Canvas or context not properly initialized")}processImageData(a,e,r,t){let s=this.createImageDataFromBuffer(a,e,r,t);if(s===null)throw new Error("Failed to create ImageData");return this.validateImageData(s,r,t),s}validateImageData(a,e,r){var t;if(a.width!==e||a.height!==r)throw o.warn(`ImageData dimensions mismatch: expected ${e}x${r}, got ${a.width}x${a.height}`),new Error("ImageData dimensions mismatch");if(!a.data||a.data.length!==e*r*4)throw o.warn(`ImageData has invalid data length: expected ${e*r*4}, got ${((t=a.data)==null?void 0:t.length)||0}`),new Error("ImageData has invalid data length")}async convertToJpegBytes(a,e){if(!this.context||!this.canvas)throw new Error("Canvas or context not available");try{this.context.putImageData(a,0,0)}catch(i){throw o.warn(`Failed to put image data on canvas: ${i}`),new Error(`Failed to put image data on canvas: ${i}`)}let r=e!==0?this.applyRotation(this.canvas,e):this.canvas,t;try{t=await this.canvasToBlob(r)}catch(i){throw o.warn(`Failed to convert canvas to blob: ${i}`),new Error(`Failed to convert canvas to blob: ${i}`)}if(!t||t.size===0)throw o.warn("Canvas convertToBlob returned empty or null blob"),new Error("Failed to create JPEG blob");let s;try{s=await t.arrayBuffer()}catch(i){throw o.warn(`Failed to get array buffer from blob: ${i}`),new Error(`Failed to get array buffer from blob: ${i}`)}if(!s||s.byteLength===0)throw o.warn("Blob arrayBuffer returned empty or null buffer"),new Error("Failed to get array buffer from blob");return new Uint8Array(s)}ensureCanvas(a,e){try{return(!this.canvas||this.canvas.width!==a||this.canvas.height!==e)&&(this.canvas=this.getNewCanvas(a,e),this.context=this.canvas.getContext("2d")),this.context!==null}catch(r){return o.warn("Failed to create HTMLCanvasElement",r),!1}}createImageDataFromBuffer(a,e,r,t){let s=new Set(e.map(i=>i.channel));try{if(this.isYUVFormat(s)){let n=a.toBitmap();return!n||n.length!==r*t*4?(o.warn(`Invalid bitmap data from toBitmap(): expected ${r*t*4} bytes, got ${(n==null?void 0:n.length)||0}`),null):new ImageData(new Uint8ClampedArray(n),r,t)}if(this.isRGBAFormat(s))return this.createImageDataFromRGBAPlanes(e,r,t);if(this.isRGBFormat(s))return this.createImageDataFromRGBPlanes(e,r,t);if(this.isGrayscaleFormat(s))return this.createImageDataFromGrayscalePlanes(e,r,t);o.warn(`Unknown image format with channels: ${Array.from(s).join(", ")}, falling back to toBitmap()`);let i=a.toBitmap();if(!i||i.length===0)return o.warn("toBitmap() returned empty or null data"),null;let d=i.length/(r*t);return d===4?new ImageData(new Uint8ClampedArray(i),r,t):(o.warn(`Unsupported format: ${d} bytes per pixel`),null)}catch(i){return o.warn(`Failed to create ImageData: ${i}`),null}}isYUVFormat(a){return a.has(0)&&a.has(1)&&a.has(2)}isRGBAFormat(a){return a.has(3)&&a.has(4)&&a.has(5)&&a.has(6)}isRGBFormat(a){return a.has(3)&&a.has(4)&&a.has(5)&&!a.has(6)}isGrayscaleFormat(a){return a.has(0)&&!a.has(1)&&!a.has(2)}createImageDataFromRGBAPlanes(a,e,r){let t=a.find(l=>l.channel===3),s=a.find(l=>l.channel===4),i=a.find(l=>l.channel===5),d=a.find(l=>l.channel===6);if(!t||!s||!i||!d)return o.warn("Missing RGBA planes"),null;let n=new Uint8ClampedArray(e*r*4);for(let l=0;l<r;l++)for(let c=0;c<e;c++){let h=(l*e+c)*4;n[h]=this.getPixelFromPlane(t,c,l),n[h+1]=this.getPixelFromPlane(s,c,l),n[h+2]=this.getPixelFromPlane(i,c,l),n[h+3]=this.getPixelFromPlane(d,c,l)}return new ImageData(n,e,r)}createImageDataFromRGBPlanes(a,e,r){let t=a.find(n=>n.channel===3),s=a.find(n=>n.channel===4),i=a.find(n=>n.channel===5);if(!t||!s||!i)return o.warn("Missing RGB planes"),null;let d=new Uint8ClampedArray(e*r*4);for(let n=0;n<r;n++)for(let l=0;l<e;l++){let c=(n*e+l)*4;d[c]=this.getPixelFromPlane(t,l,n),d[c+1]=this.getPixelFromPlane(s,l,n),d[c+2]=this.getPixelFromPlane(i,l,n),d[c+3]=255}return new ImageData(d,e,r)}createImageDataFromGrayscalePlanes(a,e,r){let t=a.find(i=>i.channel===0);if(!t)return o.warn("Missing Y plane for grayscale"),null;let s=new Uint8ClampedArray(e*r*4);for(let i=0;i<r;i++)for(let d=0;d<e;d++){let n=(i*e+d)*4,l=this.getPixelFromPlane(t,d,i);s[n]=l,s[n+1]=l,s[n+2]=l,s[n+3]=255}return new ImageData(s,e,r)}getPixelFromPlane(a,e,r){let t=Math.floor(e/(a.subsamplingX||1)),s=Math.floor(r/(a.subsamplingY||1)),i=a.rowStride,d=a.pixelStride,n=s*i+t*d,l=a.data;return n<l.length?l[n]:0}applyRotation(a,e){let r=e*Math.PI/180,t=e===90||e===270||e===-90||e===-270,s=t?a.height:a.width,i=t?a.width:a.height,d=this.getNewCanvas(s,i),n=d.getContext("2d");if(!n)throw new Error("Failed to get 2D context for rotated canvas");return n.translate(s/2,i/2),n.rotate(r),n.translate(-a.width/2,-a.height/2),n.drawImage(a,0,0),d}};W.JPEG_IMAGE_MIME_TYPE="image/jpeg";var oe=class extends W{getNewCanvas(a,e){return new OffscreenCanvas(a,e)}canvasToBlob(a){return a.convertToBlob({type:W.JPEG_IMAGE_MIME_TYPE,quality:this.options.quality})}};u();var de=class{constructor(a){this.viewInfo=null,this.viewInfo=this.cloneViewInfo(a)}isSame(a){return this.viewInfo==null&&a==null?!0:this.viewInfo==null&&a!=null||this.viewInfo!=null&&a==null?!1:this.viewInfo.width===a.width&&this.viewInfo.height===a.height&&this.viewInfo.orientation===a.orientation&&this.viewInfo.viewFinderRect.origin.x===a.viewFinderRect.origin.x&&this.viewInfo.viewFinderRect.origin.y===a.viewFinderRect.origin.y&&this.viewInfo.viewFinderRect.size.width===a.viewFinderRect.size.width&&this.viewInfo.viewFinderRect.size.height===a.viewFinderRect.size.height}update(a){this.viewInfo=this.cloneViewInfo(a)}cloneViewInfo(a){return a?{...a,viewFinderRect:{origin:{...a.viewFinderRect.origin},size:{...a.viewFinderRect.size}}}:null}};u();var B;(a=>{function e(){return"8.3.0"}a.sdkVersion=e})(B||(B={}));u();function Le(a){return/^https?:\\/\\/(?:[^./]*\\.)*cdn.jsdelivr.net\\//.test(a)?{result:!0,cdnBaseURL:"https://cdn.jsdelivr.net/npm/"}:/^https?:\\/\\/(?:[^./]*\\.)*unpkg.com\\//.test(a)?{result:!0,cdnBaseURL:"https://unpkg.com/"}:{result:!1,cdnBaseURL:""}}function Oe(a){let e=/@scandit\\/web-datacapture-[a-z]+/i.exec(a);return e?e[0]:null}function le(a,e,r){let t=e,s=Le(t);if(s.result){let d=Oe(t);d!=null&&(t=`${s.cdnBaseURL}${d}@${a}/sdc-lib/`)}let i=r.replace(".wasm","");return s.result?{jsURI:`${t}${i}.js`,wasmURI:`${t}${i}.wasm`}:{jsURI:`${t}${i}.js?v=${a}`,wasmURI:`${t}${i}.wasm?v=${a}`}}var ue=class ce{constructor(e,r){this.hintPresenterV2=null,this.MAX_NUMBER_OF_IMAGES_IN_FRAME_DATA_POOL=5,this.redrawInterval=1e3/30,this.redrawRequests=[],this._isDrawLoopRunning=!1,this.frameDataPool=new Map,this.lastFrameColorType="RGBA",this.lastFrameId=null,this.poorMansBenchmarkLogs=!1,this.writableDataPathStandard="/scandit_sync_folder",this.resourceFilesSubfolder="resources",this.performanceMetricsReporterTimer=void 0,this.lastMetricsReportTime=0,this.metricsReportInterval=1e3,this.performanceMetrics={frameDataPoolSize:0,cameraOutputFrames:0,redrawRequestsCount:0,actualRedrawsCount:0,frameProcessingStartedCount:0,frameProcessedCount:0,frameSkippedCount:0},this.frameProcessingStartedCount=0,this.frameProcessingFinishedCount=0,this.gestureListener=null,this.webPlatformHintPresenter=null,this.deviceInstance=null,this.deviceInfo=null,this.lastViewInfo=new de(null),this.lastFrameProcessingStartedCount=0,this.lastFrameProcessingFinishedCount=0,this.moduleHandler=e,this.workerFunctions=r,this._loadProgressCallback=this._loadProgressCallback.bind(this),se(this.getWasmMetadata())}get Module(){return this.moduleHandler.get()}set isDrawLoopRunning(e){this._isDrawLoopRunning=e,!e&&typeof this.loopTimeoutId=="number"&&(clearTimeout(this.loopTimeoutId),this.loopTimeoutId=void 0)}get isDrawLoopRunning(){return this._isDrawLoopRunning}prepareFrameForListener(e){let r=this.lastFrameId;if(this.frameDataPool.size>=this.MAX_NUMBER_OF_IMAGES_IN_FRAME_DATA_POOL){let d=this.frameDataPool.keys().next().value;d!=null&&this.frameDataPool.delete(d)}let t=e.getFrameData(),s=new Uint8ClampedArray(t);this.frameDataPool.set(r,{data:s,colorType:this.lastFrameColorType,frameId:r,width:e.getWidth(),height:e.getHeight()});let i=this.lastUsedModuleMirrorAxis==null?!1:this.lastUsedModuleMirrorAxis!==this.Module.Axis.None;return{frameId:r,width:e.getWidth(),height:e.getHeight(),isFrameSourceMirrored:i,colorType:this.lastFrameColorType}}createContext(e){var r,t,s,i,d;let n=this.getModeDeserializers(),l=q(location);(l==="localhost"||l==="127.0.0.1")&&navigator.userAgent.includes("Electron")&&e.appName!=null&&(l+=`-${e.appName}`),this.parentDomain=e.parentDomain,this.contextDeserializer=new this.Module.DataCaptureContextDeserializer(this.writableDataPath,e.deviceId,e.context.deviceModelName,l,this.parentDomain,n,e.delayedRegistration,e.highEndBlurryRecognition,this.resourcePath);let c=this.contextDeserializer.contextFromJson(JSON.stringify(e.context));if(c==null){let p=this.contextDeserializer.getLastError();throw new Error(`Could not create the context: ${p}`)}let h=c.getView();this.context=c.getContext(),c.delete(),this.setupDeviceInterface(e.isTablet,e.batteryInfo);let f=this.Module.DataCaptureContextListener.extend("DataCaptureContextListener",{didChangeStatus:(p,y)=>{this.contextDidChangeStatus(JSON.parse(y.toJson())),p.delete()},didStartObservingContext:p=>{this.didStartObservingContext(),p.delete()},didStopObservingContext:p=>{p.delete()}}),I=this.Module.DataCaptureContextFrameListener.extend("DataCaptureContextFrameListener",{onObservationStarted:p=>{p.delete()},onObservationStopped:p=>{p.delete()},onFrameProcessingStarted:(p,y)=>{this.workerFunctions.postMessage({type:"onFrameProcessingStarted"}),y.delete(),p.delete()},onFrameProcessingFinished:(p,y)=>{this.workerFunctions.postMessage({type:"onFrameProcessingFinished"}),y.delete(),p.delete()},onFrameSkipped:(p,y)=>{this.workerFunctions.postMessage({type:"onFrameSkipped"}),y.delete(),p.delete()}}),g=this.Module.GestureRecognizer.extend("GestureRecognizer",{setGestureListener:(p,y)=>{var b;(b=this.gestureListener)==null||b.delete(),this.gestureListener=p.clone(),p.delete()}});(r=this.gestureRecognizer)==null||r.delete(),this.gestureRecognizer=new g;let C=new f;this.context.addListener(C),C.delete();let S=new I;this.context.addFrameListener(S),S.delete(),this.setView(h),(t=this.view)==null||t.setGestureRecognizer(this.gestureRecognizer);let D=this.Module.PlatformHintPresenter.extend("PlatformHintPresenter",{setHintPresenter:p=>{p.delete()},showToast:p=>{this.workerFunctions.postMessage({type:"showToast",payload:JSON.parse(p)})},hideToast:p=>{this.workerFunctions.postMessage({type:"hideToast",payload:JSON.parse(p)})},showGuidance:p=>{this.workerFunctions.postMessage({type:"showGuidance",payload:JSON.parse(p)})},hideGuidance:p=>{this.workerFunctions.postMessage({type:"hideGuidance",payload:JSON.parse(p)})},startUpdateTimer:p=>{this.workerFunctions.postMessage({type:"startUpdateTimer",payload:{duration:{unit:"ms",value:p}}})},stopUpdateTimer:()=>{this.workerFunctions.postMessage({type:"stopUpdateTimer"})}});(s=this.hintPresenterV2)==null||s.delete(),this.hintPresenterV2=null,(i=this.webPlatformHintPresenter)==null||i.delete(),this.webPlatformHintPresenter=null,this.webPlatformHintPresenter=new D,this.view&&(this.hintPresenterV2=new this.Module.HintPresenterV2(this.webPlatformHintPresenter),(d=this.view)==null||d.setHintPresenterV2(this.hintPresenterV2)),this.webImageConverterInstance=this.getImageConverterInstance({quality:1}),this.Module.ImageConverter.setInstance(this.webImageConverterInstance)}convertToJPEGResult(e,r){this.webImageConverterInstance instanceof K&&this.webImageConverterInstance.onConvertToJPEGResult(e,r)}getImageConverterInstance(e){return this.workerFunctions.getOffscreenCanvas()!=null?new oe(e):new K(this.workerFunctions,e)}onTap(e){var r;(r=this.gestureListener)==null||r.onTap(JSON.stringify(e))}hintPresenterV2Update(){var e;(e=this.hintPresenterV2)==null||e.update()}startReportingPerformanceMetrics(){this.performanceMetricsReporterTimer==null&&(this.lastMetricsReportTime=performance.now(),this.scheduleMetricsReporting())}scheduleMetricsReporting(){this.performanceMetricsReporterTimer=setTimeout(()=>{this.checkAndReportMetrics()},100)}checkAndReportMetrics(){let e=performance.now();e-this.lastMetricsReportTime>=this.metricsReportInterval&&(this.reportPerformanceMetrics(),this.performanceMetrics.cameraOutputFrames=0,this.performanceMetrics.redrawRequestsCount=0,this.performanceMetrics.actualRedrawsCount=0,this.lastMetricsReportTime=e),this._isDrawLoopRunning&&this.scheduleMetricsReporting()}async reportPerformanceMetrics(){let e=this.frameProcessingStartedCount-this.lastFrameProcessingStartedCount,r=this.frameProcessingFinishedCount-this.lastFrameProcessingFinishedCount;this.lastFrameProcessingStartedCount=this.frameProcessingStartedCount,this.lastFrameProcessingFinishedCount=this.frameProcessingFinishedCount;let t={cameraOutputFrames:this.performanceMetrics.cameraOutputFrames,redrawRequestsCount:this.performanceMetrics.redrawRequestsCount,actualRedrawsCount:this.performanceMetrics.actualRedrawsCount,frameDataPoolSize:this.performanceMetrics.frameDataPoolSize,frameProcessingStartedCount:e,frameProcessedCount:r,frameSkippedCount:this.performanceMetrics.frameSkippedCount};this.workerFunctions.postMessage({type:"performanceMetricsReport",payload:t})}deleteFrameData(e){this.frameDataPool.delete(e)}dispose(){var e,r,t,s,i;this.context.dispose(),this.frameDataPool.clear(),this.isDrawLoopRunning=!1,this.cleanupMetricsReporting(),(e=this.gestureRecognizer)==null||e.delete(),this.gestureRecognizer=null,(r=this.gestureListener)==null||r.delete(),this.gestureListener=null,(t=this.hintPresenterV2)==null||t.delete(),this.hintPresenterV2=null,(s=this.webPlatformHintPresenter)==null||s.delete(),this.webPlatformHintPresenter=null,(i=this.deviceInstance)==null||i.delete(),this.deviceInstance=null,this.deviceInfo=null}cleanupMetricsReporting(){this.performanceMetricsReporterTimer!=null&&(typeof this.performanceMetricsReporterTimer=="number"?cancelAnimationFrame(this.performanceMetricsReporterTimer):clearTimeout(this.performanceMetricsReporterTimer),this.performanceMetricsReporterTimer=void 0)}flushAnalytics(){this.context.flushAnalytics()}extractCentaurusLicense(e){return{payload:{centaurus:{licenseKey:this.Module.LicenseUtils[ce.get3dPartyLicenseKeyMethodName](e)}}}}getModeDeserializers(){return new this.Module.VectorDataCaptureModeDeserializer}loadLibrary(e){return this.libraryLoadingPromise!=null?this.libraryLoadingPromise:(this.libraryLoadingPromise=this.setup(e),this.libraryLoadingPromise)}processFrame(e){var r;if(this.context==null)return o.debug("[processFrame] Context is null, returning frame without processing"),{payload:e,transferables:[e.data.buffer]};this.lastFrameId=e.frameId;let t=e.data,s=e.colorType==="GRAYSCALE"?this.Module.ImageBufferFormat.Grayscale8:this.Module.ImageBufferFormat.Rgba8888;this.lastFrameColorType=e.colorType==="GRAYSCALE"?"GRAYSCALE":"RGBA";let i=this.Module.allocateUint8Array(t.byteLength);return this.Module.HEAPU8.set(t,i),(r=this.imageFrameSource)==null||r.outputFrame(i,e.width,e.height,s),{payload:e,transferables:[e.data.buffer]}}reportCameraProperties(e){this.context.setCameraProperties(e.deviceId,e.isFrontFacing,e.hasAutofocus)}requestFrameData(e){let r=this.frameDataPool.get(e);if(r==null)return{payload:{data:null,frameId:null,colorType:null}};if(r.data.buffer.byteLength===0)return this.frameDataPool.delete(e),{payload:{data:null,frameId:null,colorType:null}};let t=r.data;r.colorType==="GRAYSCALE"&&(t=X(r.data,r.width,r.height));let s={payload:{data:t,frameId:r.frameId,colorType:r.colorType},transferables:[t.buffer]};return this.frameDataPool.delete(e),s}scheduleRedraw(e,r){this.addRedrawRequest(r),this.isDrawLoopRunning||this.startDrawLoop(e)}sendViewRefreshCommands(e){this.workerFunctions.postMessage({type:"draw",payload:e},[e.buffer])}setFrameSource(e,r){var t;this.lastUsedModuleMirrorAxis=this.mapMirrorAxisOnModule(e),(t=this.imageFrameSource)==null||t.delete(),this.imageFrameSource=new this.Module.ImageBufferFrameSource(this.lastUsedModuleMirrorAxis,r,0),this.context.setFrameSource(this.imageFrameSource)}startDrawLoop(e){this.isDrawLoopRunning=!0;let r=i=>this.redrawRequests.length>0&&this.redrawRequests[0]<=i,t=i=>{for(;this.redrawRequests.length>0&&this.redrawRequests[0]<=i;)this.redrawRequests.shift()},s=()=>{this.loopTimeoutId=setTimeout(()=>{if(!this.isDrawLoopRunning)return;let i=performance.now();if(r(i)){t(i),e.draw();let d=e.getDrawCommands();this.sendViewRefreshCommands(new Uint8Array(d))}s()},this.redrawInterval)};s()}updateContext(e){if(this.context!=null&&this.contextDeserializer!=null){e.view!=null&&!e.view.visible&&this.context.flushAnalytics();let r=this.onBeforeUpdateContextHook(e),t=this.contextDeserializer.updateContextFromJson(this.context,this.view,JSON.stringify(r.context));if(t==null){let i=this.contextDeserializer.getLastError();throw new Error(`Could not update the context: ${i}`)}this.context.delete(),this.context=t.getContext();let s=t.getView();t.delete(),s!=null&&r.view!=null&&(s.setViewSize(r.view.width,r.view.height,r.view.orientation),s.draw()),!this.hintPresenterV2&&this.webPlatformHintPresenter&&(this.hintPresenterV2=new this.Module.HintPresenterV2(this.webPlatformHintPresenter)),s!=null&&this.hintPresenterV2&&s.setHintPresenterV2(this.hintPresenterV2),this.gestureRecognizer!=null&&(s==null||s.setGestureRecognizer(this.gestureRecognizer)),this.setView(s),this.notifyMainThreadOnViewInfoChanged(s),o.debug("context updated",r)}}notifyMainThreadOnViewInfoChanged(e){let r=this.getViewInfo(e);this.lastViewInfo.isSame(r)||(this.lastViewInfo.update(r),this.workerFunctions.postMessage({type:"viewSizeChanged",payload:r}))}getViewInfo(e){if(e!=null)try{let r=JSON.parse(e.getViewInfo());if(r!=null){let t=this.getOrientationFromNumber(r.orientation);return{...r,orientation:t}}}catch(r){o.error("Failed to get view size",r)}return null}getOrientationFromNumber(e){switch(e){case 90:return"landscapeRight";case 180:return"portraitUpsideDown";case 270:return"landscapeLeft";default:return"portrait"}}onBeforeUpdateContextHook(e){return e}onDocumentVisibilityChange(e){e==="hidden"&&this.context.flushAnalytics()}isFeatureSupported(e){return{payload:{supported:this.context.isFeatureSupported(e)}}}getViewfinderInfo(){var e,r;return{payload:{isDisplayingViewfinder:(r=(e=this.view)==null?void 0:e.isDisplayingViewfinder())!=null?r:!1,rect:JSON.parse(this.view.getViewfinderRect())}}}getOpenSourceSoftwareLicenseInfo(){return{payload:{licenseText:this.Module.OpenSourceSoftwareLicenseInfo.getLicenseText()}}}getWasmDynamicLibraries(e){return this.getWasmSideModuleFileName()==null?[]:[`${e.replace(/\\/[^/]*$/,"/")}${this.getWasmSideModuleFileName()}`]}getWasmCoreExpectedHash(e,r){return r?e?"f9e95a3a99a2ce178c63c35a2c7dfc2243991b938dcbd9009da2556ffdaa9d33":"3b91bccc7ad85e41437e7768dc2cbe9cdfef497eabcfba40775b27b2a9a1ff74":e?"5b421e6d1c15865bcfd5915031c6a19596847cbe10063d73b6db0e81c57ecb79":""}getWasmCoreFileName(e,r){return r?e?"scandit-datacapture-sdk-id-simd-pthreads.wasm":"scandit-datacapture-sdk-id-pthreads.wasm":e?"scandit-datacapture-sdk-id-simd.wasm":""}getWasmMetadata(){return m}getWasmSideModuleFileName(){return""}_loadProgressCallback(e){this.workerFunctions.postMessage({type:"loadLibraryProgress",payload:e})}addRedrawRequest(e){this.redrawRequests.push(Math.round(performance.now())+e),this.redrawRequests.sort((r,t)=>r-t)}contextDidChangeStatus(e){e.code===260?e.message=e.message.replace("domain name",`domain name (${q(location)})`):e.code===265&&(e.message=e.message.replace("domain name",`domain name (${this.parentDomain})`)),this.workerFunctions.postMessage({type:"contextDidChangeStatus",payload:e})}didStartObservingContext(){this.workerFunctions.postMessage({type:"didStartObservingContext"})}mapMirrorAxisOnModule(e){switch(e){case"None":return this.Module.Axis.None;case"X":return this.Module.Axis.X;case"Y":return this.Module.Axis.Y;default:return this.Module.Axis.None}}setView(e){this.view=e,this.setViewRefreshHandler(e),e==null&&(this.isDrawLoopRunning=!1,this.sendViewRefreshCommands(new Uint8Array([])))}addNativeOverlay(e){o.warn("addNativeOverlay has not been implemented for this module",e)}removeNativeOverlay(e){o.warn("removeNativeOverlay has not been implemented for this module",e)}setViewRefreshHandler(e){if(e==null||e.isViewRefreshHandlerSet)return;let r=this.Module.NeedsRedrawDelegate.extend("NeedsRedrawDelegate",{setNeedsRedrawIn:this.scheduleRedraw.bind(this,e)}),t=new r;e.setNeedsRedrawDelegate(t),e.isViewRefreshHandlerSet=!0}setupDataDecoding(){let e=this.moduleHandler.get(),r=e.DataDecoding.extend("DataDecoding",{decode(t,s){try{let i=JSON.parse(s),d=[];for(let n of i){let l=new TextDecoder(n.ianaName,{fatal:!0});d.push(l.decode(t.slice(n.startIndex,n.endIndex)))}return d.join("")}catch{return""}}});e.setDataDecoding(new r)}getBatteryData(){var e,r;let t=(r=(e=this.deviceInfo)==null?void 0:e.batteryInfo)==null?void 0:r.percentage;if(t!=null)return{percentage:t}}isTablet(){var e,r;return(r=(e=this.deviceInfo)==null?void 0:e.isTablet)!=null?r:!1}setupDeviceInterface(e,r){this.deviceInfo={isTablet:e,batteryInfo:r};let t=this.moduleHandler.get(),s=t.DeviceInterface.extend("DeviceInterface",{getBatteryData:this.getBatteryData.bind(this),isTablet:this.isTablet.bind(this)});this.deviceInstance=new s,t.DeviceHolder.setCurrentDevice(this.deviceInstance)}updateBatteryInfo(e){this.deviceInfo&&(this.deviceInfo.batteryInfo=e)}start(e,r,t){e&&r&&(this.setupDataDecoding(),this.moduleHandler.get().callMain(),this.moduleHandler.get().__emscripten_proxy_main!==void 0||t())}getWritableDataPath(e){return e!=null?(o.debug(`IndexedDB database name override in use to recover from blocked standard database: ${e}`),e):this.writableDataPathStandard}numOfMBToPages(e){return Math.ceil(1024*e*1024/64/1024)}async setup({libraryLocation:e,locationPath:r,writableDataPathOverride:t,indexedDBTimeoutMs:s,verifyResponseHash:i,referredOrigin:d,fixedWasmMemory:n,simdSupport:l,threadsSupport:c}){var h;let f=!1,I=!1;this.writableDataPath=this.getWritableDataPath(t),this.resourcePath=`${e}${this.resourceFilesSubfolder}/`,self.path=r;let{resolve:g,reject:C,promise:S}=new T,D=B.sdkVersion();if(D==="")throw new L({name:"Invalid library version",message:"Library version is not defined or empty, cannot generate proper path to library files."});let p=this.getWasmCoreFileName(l,c),y=le(D,e,p),{jsURI:b,wasmURI:x}=y,P={instantiateWasm:(w,fe)=>(ie({importObject:w,wasmURI:x,expectedHash:this.getWasmCoreExpectedHash(l,c),verifyResponseHash:i,successCallback:fe,progressCallback:this._loadProgressCallback,errorCallback:Ie=>{C(Ie)},referredOrigin:d}),{})},E=n===null?null:new WebAssembly.Memory({initial:this.numOfMBToPages(n),maximum:this.numOfMBToPages(300),shared:c});return E!==null&&o.log(o.Level.Debug,"Fixed wasmMemory set",E),this.moduleHandler.set({...E?{wasmMemory:E}:{},mainScriptUrlOrBlob:b,canvas:(h=this.workerFunctions.getOffscreenCanvas())!=null?h:{getContext:()=>null},...P,dynamicLibraries:this.getWasmDynamicLibraries(x),locateFile:w=>e+w,noInitialRun:!0,preRun:[async()=>{try{await ae({writableDataPath:this.writableDataPath,indexedDBTimeoutMs:s})}catch(w){if(w.name==="BlockedIndexedDB"){C(w.toString());return}o.log(o.Level.Debug,"No IndexedDB support, some data will not be persisted:",w)}I=!0,this.start(I,f,g)}],onMainComplete:()=>{if([f,I].includes(!1)){o.log(o.Level.Warn,{runtimeLoaded:f,fileSystemSynced:I},"Both runtimeLoaded and fileSystemSynced should be true when calling onMainComplete"),C("onMainComplete has been called but runtime or file system was not ready.");return}g()},onRuntimeInitialized:()=>{f=!0,this.start(I,f,g)},print:w=>{o.info(w)}}),await ne(b,D)||C(`Couldn\'t retrieve Scandit Data Capture library at ${b}, did you configure the path for it correctly?`),S}};ue.get3dPartyLicenseKeyMethodName=atob("Z2V0QmxpbmtJZExpY2Vuc2VLZXk=");var F=ue;u();u();function k(a){return typeof a=="object"&&a!=null}function A(a){if(typeof a=="string")return a;if(k(a)){if(typeof a.message=="string")return a.message}else if(typeof(a==null?void 0:a.toString)=="function")return a.toString();return"unknown error"}u();function pe(a){return typeof a=="object"&&a!=null&&a.document==null&&"addEventListener"in a&&typeof a.importScripts=="function"}u();function he(a){console.warn("Reached unexpected case",a)}var Y=class{constructor(a,e){this.onMessageListener=this.onMessage.bind(this),this.workerSelf=a,this.dataCaptureInstance=new F(e,{postMessage:this.postMessage.bind(this),getOffscreenCanvas:this.getOffscreenCanvas.bind(this)}),pe(a)&&(Q(a),this.listenToMessages())}listenToMessages(){this.workerSelf.addEventListener("message",this.onMessageListener),this.workerSelf.addEventListener("error",a=>{o.log(o.Level.Error,a)}),this.workerSelf.addEventListener("messageerror",a=>{o.log(o.Level.Error,a)})}postMessage(a,e){this.workerSelf.postMessage(a,e!=null?e:[])}getOffscreenCanvas(){if(this.isOffscreenCanvasSupported())return new this.workerSelf.OffscreenCanvas(32,32)}isOffscreenCanvasSupported(){return typeof this.workerSelf.OffscreenCanvas=="function"}hasPayload(a){return k(a)&&"payload"in a}hasTransferables(a){return k(a)&&Array.isArray(a.transferables)}async respondWith(a,e,r){let t=null,s;try{s=r(),s instanceof Promise&&(s=await s)}catch(d){s=void 0,t=A(d)}let i={type:"workerTaskId",command:a,id:e,payload:this.hasPayload(s)?s.payload:void 0};t!=null&&(i.error=t),this.postMessage(i,this.hasTransferables(s)?s.transferables:[])}onMessage(a){switch(a.data.command){case"loadLibrary":{{let{data:e}=a;this.respondWith(e.command,e.id,async()=>this.dataCaptureInstance.loadLibrary({libraryLocation:e.libraryLocation,locationPath:e.locationPath,referredOrigin:e.referredOrigin,writableDataPathOverride:e.writableDataPathOverride,threadsSupport:e.threadsSupport,simdSupport:e.simdSupport,verifyResponseHash:e.verifyResponseHash,fixedWasmMemory:e.fixedWasmMemory,indexedDBTimeoutMs:e.indexedDBTimeoutMs}))}break}case"onTap":{{let{data:e}=a;this.respondWith(e.command,e.id,async()=>{this.dataCaptureInstance.onTap(e.point)})}break}case"hintPresenterV2update":{{let{data:e}=a;this.respondWith(e.command,e.id,async()=>{this.dataCaptureInstance.hintPresenterV2Update()})}break}case"createContext":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.createContext({context:e.context,deviceId:e.deviceId,delayedRegistration:e.delayedRegistration,highEndBlurryRecognition:e.highEndBlurryRecognition,appName:e.appName,parentDomain:e.parentDomain,isTablet:e.isTablet,batteryInfo:e.batteryInfo}))}break}case"setFrameSource":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.setFrameSource(e.mirrorAxis,e.isCameraFrameSource))}break}case"processFrame":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.processFrame({data:e.data,frameId:e.frameId,width:e.width,height:e.height,colorType:e.colorType}))}break}case"requestFrameData":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.requestFrameData(e.frameId))}break}case"deleteFrameData":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>{this.dataCaptureInstance.deleteFrameData(e.frameId)})}break}case"updateContext":{{let{data:e}=a;this.respondWith(e.command,e.id,async()=>this.dataCaptureInstance.updateContext(e))}break}case"dispose":{this.respondWith(a.data.command,a.data.id,()=>this.dataCaptureInstance.dispose());break}case"flushAnalytics":{this.respondWith(a.data.command,a.data.id,()=>{this.dataCaptureInstance.flushAnalytics()});break}case"reportCameraProperties":{{let{data:e}=a;this.respondWith(e.command,e.id,async()=>this.dataCaptureInstance.reportCameraProperties(e))}break}case"setLogLevel":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>{o.setLevel(e.level)})}break}case"updateBatteryInfo":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>{this.dataCaptureInstance.updateBatteryInfo(e.batteryInfo)})}break}case"extractCentaurusLicense":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.extractCentaurusLicense(e.licenseKey))}break}case"documentVisibility":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>{this.dataCaptureInstance.onDocumentVisibilityChange(e.state)})}break}case"isFeatureSupported":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.isFeatureSupported(e.feature))}break}case"getViewfinderInfo":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.getViewfinderInfo())}break}case"getOpenSourceSoftwareLicenseInfo":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.getOpenSourceSoftwareLicenseInfo())}break}case"addNativeOverlay":this.dataCaptureInstance.addNativeOverlay(a);break;case"removeNativeOverlay":this.dataCaptureInstance.removeNativeOverlay(a);break;case"convertToJPEGResult":{{let{data:e}=a;this.dataCaptureInstance.convertToJPEGResult(e.imageId,e.result)}break}default:return he(a.data),!1}return!0}};u();u();u();u();u();function me(a){return a.ok()}function ge(a,e){return me(a)?a.value():e}function Ce(a,e){return me(a)?e:a.error()}function v(a,e){return a===void 0?e:a}var N=class{constructor(e,r,t){this.SDCIdCaptureMode=null;this.lastResult="";this.lastError="";this.lastLocalizedId="";this.lastDetectionIssue="";this.lastDiagnostics="";this.coreEngine=e,this.Module=e.Module,this.workerFunctions=e.workerFunctions,this.start(r,t)}start(e,r){this.initHintPresenterIfNotInitialized();let t=this.Module.IdCaptureListener.extend("IdCaptureListener",{onSessionUpdated:(g,C)=>{this.onIdOutlineUpdatedCallback(C.getIdOutline()),g.delete(),C.delete()},onIdCaptured:(g,C)=>{this.onIdCapturedCallback(C),g.delete(),C.delete()},onIdPartiallyCaptured:(g,C)=>{this.onIdPartiallyCapturedCallback(C),g.delete(),C.delete()},onIdRejected:(g,C,S)=>{this.onIdRejectedCallback(C,S),g.delete(),C==null||C.delete()},onIdLocalized:(g,C)=>{this.onIdLocalizedCallback(C),g.delete()},onShutterButtonPositionChanged:g=>{this.onShutterButtonPositionChangedCallback(g)},onShutterButtonStateChanged:g=>{this.onShutterButtonStateChangedCallback(g)},onCloudProcessingStarted:()=>{this.onCloudProcessingStartedCallback()},onCloudProcessingFinished:()=>{this.onCloudProcessingFinishedCallback()}}),s=this.Module.Feedback.extend("Feedback",{emit:()=>{this.workerFunctions.postMessage({type:"idCaptureIdCapturedFeedback"})}}),i=this.Module.Feedback.extend("Feedback",{emit:()=>{this.workerFunctions.postMessage({type:"idCaptureIdRejectedFeedback"})}}),d=this.Module.IdCaptureBackend.extend("IdCaptureBackend",{getLastError:()=>this.lastError,getLastResult:()=>this.backendGetLastResult(),getLocalizedOnlyId:()=>this.lastLocalizedId,getLastIssue:()=>this.lastDetectionIssue,getLastDiagnostics:()=>this.lastDiagnostics,processFrame:()=>{},reset:this.onResetFromSDC.bind(this),setDetectionOnlyMode:this.setDetectionOnlyMode.bind(this)}),n=this.Module.IdCaptureImageProcessor.extend("IdCaptureImageProcessor",{outlineRegions:g=>g,obscureRegions:g=>g}),l=new d,c=new n;this.SDCIdCaptureMode=new this.Module.IdCapture(e,l,r,c),l.delete(),c.delete();let h=new t;this.SDCIdCaptureMode.addListener(h),h.delete();let f=new s,I=new i;this.SDCIdCaptureMode.setFeedbacks(f,I),f.delete(),I.delete()}getSDCIdCaptureMode(){if(!this.SDCIdCaptureMode)throw new Error("IdCaptureMode not initialized");return this.SDCIdCaptureMode}backendGetLastResult(){return this.lastResult}setLastResult(e){this.lastResult=e}setLastError(e){this.lastError=e}setLastLocalizedId(e){this.lastLocalizedId=e}setLastDetectionIssue(e){this.lastDetectionIssue=e}setLastDiagnostics(e){this.lastDiagnostics=e}applySettings(e){var r;(r=this.SDCIdCaptureMode)==null||r.applySettings(JSON.stringify(e))}reset(){var e;(e=this.SDCIdCaptureMode)==null||e.reset()}setExternalTransactionId(e){var r;(r=this.SDCIdCaptureMode)==null||r.setExternalTransactionId(e)}getExternalTransactionId(){var e;return(e=this.SDCIdCaptureMode)==null?void 0:e.getExternalTransactionId()}parseCode(e){if(this.SDCIdCaptureMode){let r=this.SDCIdCaptureMode.parse(e);if(r.ok()){let t=ge(r,null);if(t!=null){let s=this.extractCaptureId(t);if(s!=null)return{status:"success",capturedId:s}}}else return{status:"error",error:Ce(r,"Undefined error")}}return null}getCentaurusSettings(){let e=this.getSDCIdCaptureMode().getCentaurusSettings();return JSON.parse(e)}async barcodeVerifyAamvaCapture(e,r){return new Promise(t=>{let s=this.Module.AamvaBarcodeVerifier.extend("AamvaBarcodeVerifier",{retriggerVerificationIn(d){setTimeout(()=>{i.startVerification(JSON.stringify(e))},d)},verificationEnded(){let d=i.getBarcodeVerificationResponse();t({isSuccess:d.isSuccess,error:d.error,allChecksPassed:d.allChecksPassed})}}),i=new s;i.initialize(this.coreEngine.context,r==null?"":r),i.startVerification(JSON.stringify(e))})}onResetFromSDC(e){this.workerFunctions.postMessage({type:"idCaptureBackendReset"}),this.lastError="",this.lastResult="",this.lastLocalizedId=""}setDetectionOnlyMode(e){this.workerFunctions.postMessage({type:"idCaptureDetectionOnlyMode",payload:{detectionOnlyMode:e}})}onIdOutlineUpdatedCallback(e){let r=e?JSON.parse(e):null;this.workerFunctions.postMessage({type:"idCaptureDidUpdateIdOutline",payload:{idOutline:r}})}onIdCapturedCallback(e){let r=this.extractCaptureId(e);r&&this.workerFunctions.postMessage({type:"idCaptureDidCaptureId",payload:{capturedId:r}},this.extractImageTransferablesFromCapturedId(r))}onIdPartiallyCapturedCallback(e){let r=this.extractCaptureId(e);r&&this.workerFunctions.postMessage({type:"idCaptureDidPartiallyCaptureId",payload:{capturedId:r}},this.extractImageTransferablesFromCapturedId(r))}onIdRejectedCallback(e,r){let t=this.extractCaptureId(e);this.workerFunctions.postMessage({type:"idCaptureDidRejectId",payload:{capturedId:t,rejectionReason:r}},t?this.extractImageTransferablesFromCapturedId(t):[])}onIdLocalizedCallback(e){this.workerFunctions.postMessage({type:"idCaptureDidLocalizeId",payload:{localization:JSON.parse(e)}})}extractCaptureId(e){var C,S,D,p,y,b,x,P;if(e==null)return null;let r=e.getImages(),t=r.getFrameFront(),s=r.getFrameBack(),i=v(r.getFace(),null),d=v(r.getCroppedDocumentFront(),null),n=v(r.getCroppedDocumentBack(),null),l=v(r.getFrameObscuredRegionsFront(),null),c=v(r.getFrameObscuredRegionsBack(),null),h=v(r.getCroppedDocumentObscuredRegionsFront(),null),f=v(r.getCroppedDocumentObscuredRegionsBack(),null),I={front:{face:this.prefixImageWithDataUriIfNeeded(i),croppedDocument:{image:this.prefixImageWithDataUriIfNeeded(d),obscuredRegions:JSON.parse(h!=null?h:"[]")},frame:{image:{data:t?new Uint8ClampedArray(t.getFrameData()):null,width:(C=t==null?void 0:t.getWidth())!=null?C:0,height:(S=t==null?void 0:t.getHeight())!=null?S:0,mirrorAxis:(D=t==null?void 0:t.getMirrorAxis().value)!=null?D:0,orientation:(p=t==null?void 0:t.getOrientation())!=null?p:0},obscuredRegions:JSON.parse(l!=null?l:"[]")}},back:{face:null,croppedDocument:{image:this.prefixImageWithDataUriIfNeeded(n),obscuredRegions:JSON.parse(f!=null?f:"[]")},frame:{image:{data:s?new Uint8ClampedArray(s.getFrameData()):null,width:(y=s==null?void 0:s.getWidth())!=null?y:0,height:(b=s==null?void 0:s.getHeight())!=null?b:0,mirrorAxis:(x=s==null?void 0:s.getMirrorAxis().value)!=null?x:0,orientation:(P=s==null?void 0:s.getOrientation())!=null?P:0},obscuredRegions:JSON.parse(c!=null?c:"[]")}}};return t==null||t.delete(),s==null||s.delete(),r.delete(),{...JSON.parse(e.toJson()),rawImageInfo:I}}prefixImageWithDataUriIfNeeded(e){return e==null?null:e.includes("data:image/")?e:`data:image/jpeg;base64,${e}`}onShutterButtonPositionChangedCallback(e){this.workerFunctions.postMessage({type:"idCaptureDidShutterButtonPositionChanged",payload:{position:JSON.parse(e)}})}onShutterButtonStateChangedCallback(e){this.workerFunctions.postMessage({type:"idCaptureDidShutterButtonStateChanged",payload:{state:e}})}onCloudProcessingStartedCallback(){this.workerFunctions.postMessage({type:"idCaptureCloudProcessingStarted"})}onCloudProcessingFinishedCallback(){this.workerFunctions.postMessage({type:"idCaptureCloudProcessingFinished"})}async reportSafariAbruptReload(e){let r=new this.Module.OutOfMemoryAnalyticsData(e.framesProcessedCount,e.didCaptureCount,e.didRejectCount,e.applySettingsCount,e.upTime,e.videoResolution,e.parentDomain,e.centaurusEnabled);this.Module.OutOfMemoryAnalyticsHelper.storeAnalyticsEvent(this.coreEngine.context,r),r.delete()}parseIdCaptureSession(e){return JSON.parse(e.toJson())}dispose(){var e;(e=this.SDCIdCaptureMode)==null||e.delete(),this.SDCIdCaptureMode=null,this.lastError="",this.lastLocalizedId="",this.lastResult=""}extractImageTransferablesFromCapturedId(e){let r=[],t=e.rawImageInfo.front.frame.image.data;t&&t.length>0&&r.push(t.buffer);let s=e.rawImageInfo.back.frame.image.data;return s&&s.length>0&&r.push(s.buffer),r}isReadyToDisplayHints(){return this.coreEngine.view?this.coreEngine.view.hintPresenterInitialized():!1}initHintPresenterIfNotInitialized(){var r;if(this.isReadyToDisplayHints())return;let e=this.Module.HintPresenter.extend("HintPresenter",{showHint:(t,s)=>{this.workerFunctions.postMessage({type:"showHint",payload:{text:t,style:JSON.parse(s)}})},updateHint:t=>{this.workerFunctions.postMessage({type:"updateHint",payload:{style:JSON.parse(t)}})},hideHint:()=>{this.workerFunctions.postMessage({type:"hideHint",payload:{}})}});(r=this.coreEngine.view)==null||r.setHintPresenter(new e)}};function Te(a,e,r){let t=e.IdCaptureDeserializerHelper.extend("IdCaptureDeserializerHelper",{createMode:(d,n)=>{let l=new N(a,d,n);return r(l),d.delete(),n.delete(),l.getSDCIdCaptureMode()}}),s=new t,i=new e.IdCaptureDeserializer(s);return s.delete(),i}var H=class extends F{constructor(){super(...arguments);this.idCaptureMode=null;this.lastIdCaptureModeSerializedSettings=""}getModeDeserializers(){let r=super.getModeDeserializers(),t=Te(this,this.Module,this.receiveNewCaptureMode.bind(this));return r.push_back(t),t.delete(),r}receiveNewCaptureMode(r){this.idCaptureMode=r}processFrame(r){return this.idCaptureMode?super.processFrame(r):{payload:r,transferables:[r.data.buffer]}}updateContext(r){super.updateContext(r)}idCaptureSetLastResult(r){var t;(t=this.idCaptureMode)==null||t.setLastResult(r)}idCaptureSetLastError(r){var t;(t=this.idCaptureMode)==null||t.setLastError(r)}idCaptureSetLastLocalizedId(r){var t;(t=this.idCaptureMode)==null||t.setLastLocalizedId(r)}idCaptureSetLastDetectionIssue(r){var t;(t=this.idCaptureMode)==null||t.setLastDetectionIssue(r)}idCaptureSetLastDiagnostics(r){var t;(t=this.idCaptureMode)==null||t.setLastDiagnostics(r)}idCaptureReset(){var r;(r=this.idCaptureMode)==null||r.reset()}idCaptureSetExternalTransactionId(r){var t;(t=this.idCaptureMode)==null||t.setExternalTransactionId(r)}idCaptureGetExternalTransactionId(){var r,t;return{payload:{transactionId:(t=(r=this.idCaptureMode)==null?void 0:r.getExternalTransactionId())!=null?t:null}}}idCaptureApplySettings(r){var t;(t=this.idCaptureMode)==null||t.applySettings(r)}idCaptureGetCentaurusSettings(){return{payload:{result:this.idCaptureMode.getCentaurusSettings()}}}idCaptureParse(r){var t,s;return{payload:{result:(s=(t=this.idCaptureMode)==null?void 0:t.parseCode(r))!=null?s:null}}}async idCaptureBarcodeVerifyAamvaCapture(r,t){var s,i;return{payload:{result:(i=await((s=this.idCaptureMode)==null?void 0:s.barcodeVerifyAamvaCapture(r,t)))!=null?i:null}}}idCaptureDrivingLicenseDetailsCreateWithCentaurusData(r,t,s){let i=this.Module.DrivingLicenseDetails.createWithCentaurusData(r,t,s);return{payload:{result:JSON.parse(i)}}}getIdOpenSourceSoftwareLicenseInfo(){return{payload:{licenseText:this.Module.IdOpenSourceSoftwareLicenseInfo.getLicenseText()}}}idCaptureReportSafariAbruptReload(r){var t;(t=this.idCaptureMode)==null||t.reportSafariAbruptReload(r)}idCaptureDispose(){var r;(r=this.idCaptureMode)==null||r.dispose(),this.idCaptureMode=null}getWasmSideModuleFileName(){return""}getWasmCoreFileName(r,t){return t?r?"scandit-datacapture-sdk-id-simd-pthreads.wasm":"scandit-datacapture-sdk-id-pthreads.wasm":r?"scandit-datacapture-sdk-id-simd.wasm":"scandit-datacapture-sdk-id.wasm"}getWasmCoreExpectedHash(r,t){return t?r?"f9e95a3a99a2ce178c63c35a2c7dfc2243991b938dcbd9009da2556ffdaa9d33":"3b91bccc7ad85e41437e7768dc2cbe9cdfef497eabcfba40775b27b2a9a1ff74":r?"5b421e6d1c15865bcfd5915031c6a19596847cbe10063d73b6db0e81c57ecb79":"e15d2914ee5f53dc4ac8cf4118062b7294d13a2fddd78065a0c472c21f19e145"}getWasmMetadata(){return m}};var V=class extends Y{constructor(e,r){super(e,r),this.dataCaptureInstance=new H(r,{postMessage:this.postMessage.bind(this),getOffscreenCanvas:this.getOffscreenCanvas.bind(this)})}async respondWith(e,r,t){let s=null,i;try{i=t(),i instanceof Promise&&(i=await i)}catch(n){o.log(o.Level.Debug,n),i=void 0,s=A(n)}let d={type:"workerTaskId",command:e,id:r,payload:this.hasPayload(i)?i.payload:void 0};s!=null&&(d.error=s),this.postMessage(d,this.hasTransferables(i)?i.transferables:[])}onMessage(e){switch(e.data.command){case"idCaptureSetLastResult":{let{data:t}=e;return this.respondWith(t.command,t.id,()=>{this.dataCaptureInstance.idCaptureSetLastResult(t.result)}),!0}case"idCaptureSetLastError":{let{data:t}=e;return this.respondWith(t.command,t.id,()=>{this.dataCaptureInstance.idCaptureSetLastError(t.error)}),!0}case"idCaptureSetLastLocalizedId":{let{data:t}=e;return this.respondWith(t.command,t.id,()=>{this.dataCaptureInstance.idCaptureSetLastLocalizedId(t.localizedId)}),!0}case"idCaptureSetLastDetectionIssue":{let{data:t}=e;return this.respondWith(t.command,t.id,()=>{this.dataCaptureInstance.idCaptureSetLastDetectionIssue(t.issue)}),!0}case"idCaptureSetLastDiagnostics":{let{data:t}=e;return this.respondWith(t.command,t.id,()=>{this.dataCaptureInstance.idCaptureSetLastDiagnostics(t.diagnostics)}),!0}case"idCaptureReset":{let{data:t}=e;return this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.idCaptureReset()),!0}case"idCaptureDispose":{let{data:t}=e;return this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.idCaptureDispose()),!0}case"idCaptureApplySettings":{let{data:t}=e;return this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.idCaptureApplySettings(t.settings)),!0}case"idCaptureParse":{let{data:t}=e;return this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.idCaptureParse(t.code)),!0}case"idCaptureGetCentaurusSettings":{let{data:t}=e;return this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.idCaptureGetCentaurusSettings()),!0}case"idCaptureBarcodeVerifyAamvaCapture":{let{data:t}=e;return this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.idCaptureBarcodeVerifyAamvaCapture(t.capturedId,t.endpoint)),!0}case"idCaptureDrivingLicenseDetailsCreateWithCentaurusData":{let{data:t}=e;return this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.idCaptureDrivingLicenseDetailsCreateWithCentaurusData(t.details.vehicleClass,t.details.restrictions,t.details.endorsements)),!0}case"getIdOpenSourceSoftwareLicenseInfo":{let{data:t}=e;return this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.getIdOpenSourceSoftwareLicenseInfo()),!0}case"idCaptureReportSafariAbruptReload":{let{data:t}=e;return this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.idCaptureReportSafariAbruptReload(t.environmentData)),!0}case"idCaptureSetExternalTransactionId":{let{data:t}=e;return this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.idCaptureSetExternalTransactionId(t.transactionId)),!0}case"idCaptureGetExternalTransactionId":{let{data:t}=e;return this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.idCaptureGetExternalTransactionId()),!0}default:return super.onMessage(e)}}};var Ba=new V(self,{get:()=>self.Module,set:a=>{self.Module=a}});function Na(a){}})();\n'],{type:"application/javascript"})),a=new Worker(t,e);return URL.revokeObjectURL(t),a}var pe=class e extends DataCaptureLoader{constructor(){super(...arguments),this._name="IdCapture"}get dataCaptureWorker(){return null!=this._dataCaptureWorker||(this._dataCaptureWorker=At({name:this.name})),this._dataCaptureWorker}get name(){return this._name}get fixedWasmMemory(){return BrowserHelper.isIPhone()&&BrowserHelper.isSafari()?256:null}static async create(t){var a;let i=new e(t);return i.workerCommand("setLogLevel",{level:null!=(a=t.logLevel)?a:Logger.Level.Debug}),await i.load(),i}async workerCommand(...e){let[t,a,i]=e;return new Promise(((e,r)=>{let n=this.workerCommandId++;this.workerTasks.set(n,{resolve:e,reject:r,command:t});let s={...a,command:t,id:n};this.dataCaptureWorker.postMessage(s,i)}))}},Tt=Symbol("Comlink.proxy"),hr=Symbol("Comlink.endpoint"),Mt=Symbol("Comlink.releaseProxy"),et=Symbol("Comlink.finalizer"),he=Symbol("Comlink.thrown"),kt=e=>"object"==typeof e&&null!==e||"function"==typeof e,gr={canHandle:e=>kt(e)&&e[Tt],serialize(e){let{port1:t,port2:a}=new MessageChannel;return Ft(e,t),[a,[a]]},deserialize:e=>(e.start(),Et(e))},fr={canHandle:e=>kt(e)&&he in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(new Error(e.value.message),e.value):e.value}},Lt=new Map([["proxy",gr],["throw",fr]]);function Cr(e,t){for(let a of e)if(t===a||"*"===a||a instanceof RegExp&&a.test(t))return!0;return!1}function Ft(e,t=globalThis,a=["*"]){t.addEventListener("message",(function i(r){if(!r||!r.data)return;if(!Cr(a,r.origin))return void console.warn(`Invalid origin '${r.origin}' for comlink proxy`);let n,{id:s,type:o,path:l}=Object.assign({path:[]},r.data),u=(r.data.argumentList||[]).map(E);try{let t=l.slice(0,-1).reduce(((e,t)=>e[t]),e),a=l.reduce(((e,t)=>e[t]),e);switch(o){case"GET":n=a;break;case"SET":t[l.slice(-1)[0]]=E(r.data.value),n=!0;break;case"APPLY":n=a.apply(t,u);break;case"CONSTRUCT":n=zt(new a(...u));break;case"ENDPOINT":{let{port1:t,port2:a}=new MessageChannel;Ft(e,a),n=vr(t,[t])}break;case"RELEASE":n=void 0;break;default:return}}catch(e){n={value:e,[he]:0}}Promise.resolve(n).catch((e=>({value:e,[he]:0}))).then((a=>{let[r,n]=Ce(a);t.postMessage(Object.assign(Object.assign({},r),{id:s}),n),"RELEASE"===o&&(t.removeEventListener("message",i),jt(t),et in e&&"function"==typeof e[et]&&e[et]())})).catch((e=>{let[a,i]=Ce({value:new TypeError("Unserializable return value"),[he]:0});t.postMessage(Object.assign(Object.assign({},a),{id:s}),i)}))})),t.start&&t.start()}function Sr(e){return"MessagePort"===e.constructor.name}function jt(e){Sr(e)&&e.close()}function Et(e,t){let a=new Map;return e.addEventListener("message",(function(e){let{data:t}=e;if(!t||!t.id)return;let i=a.get(t.id);if(i)try{i(t)}finally{a.delete(t.id)}})),tt(e,a,[],t)}function me(e){if(e)throw new Error("Proxy has been released and is not useable")}function Bt(e){return J(e,new Map,{type:"RELEASE"}).then((()=>{jt(e)}))}var ge=new WeakMap,fe="FinalizationRegistry"in globalThis&&new FinalizationRegistry((e=>{let t=(ge.get(e)||0)-1;ge.set(e,t),0===t&&Bt(e)}));function yr(e,t){let a=(ge.get(t)||0)+1;ge.set(t,a),fe&&fe.register(e,t,e)}function br(e){fe&&fe.unregister(e)}function tt(e,t,a=[],i=function(){}){let r=!1,n=new Proxy(i,{get(i,s){if(me(r),s===Mt)return()=>{br(n),Bt(e),t.clear(),r=!0};if("then"===s){if(0===a.length)return{then:()=>n};let i=J(e,t,{type:"GET",path:a.map((e=>e.toString()))}).then(E);return i.then.bind(i)}return tt(e,t,[...a,s])},set(i,n,s){me(r);let[o,l]=Ce(s);return J(e,t,{type:"SET",path:[...a,n].map((e=>e.toString())),value:o},l).then(E)},apply(i,n,s){me(r);let o=a[a.length-1];if(o===hr)return J(e,t,{type:"ENDPOINT"}).then(E);if("bind"===o)return tt(e,t,a.slice(0,-1));let[l,u]=qt(s);return J(e,t,{type:"APPLY",path:a.map((e=>e.toString())),argumentList:l},u).then(E)},construct(i,n){me(r);let[s,o]=qt(n);return J(e,t,{type:"CONSTRUCT",path:a.map((e=>e.toString())),argumentList:s},o).then(E)}});return yr(n,e),n}function Ir(e){return Array.prototype.concat.apply([],e)}function qt(e){let t=e.map(Ce);return[t.map((e=>e[0])),Ir(t.map((e=>e[1])))]}var Jt=new WeakMap;function vr(e,t){return Jt.set(e,t),e}function zt(e){return Object.assign(e,{[Tt]:!0})}function Ce(e){for(let[t,a]of Lt)if(a.canHandle(e)){let[i,r]=a.serialize(e);return[{type:"HANDLER",name:t,value:i},r]}return[{type:"RAW",value:e},Jt.get(e)||[]]}function E(e){switch(e.type){case"HANDLER":return Lt.get(e.name).deserialize(e.value);case"RAW":return e.value}}function J(e,t,a,i){return new Promise((r=>{let n=Dr();t.set(n,r),e.start&&e.start(),e.postMessage(Object.assign({id:n},a),i)}))}function Dr(){return new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-")}var Nt="application/javascript",wr=(e,t={})=>{let a,i={skipSameOrigin:!0,useBlob:!0,...t};if(i.skipSameOrigin&&new URL(e).origin===self.location.origin)return Promise.resolve(e);try{let e=new AbortController;a=e.signal;let t=setTimeout((()=>{e.abort()}),3e3),i=()=>{clearTimeout(t),e.abort()};a.addEventListener("abort",i)}catch{}return new Promise(((t,r)=>{fetch(e,{signal:a}).then((e=>e.text())).then((e=>{let a="";if(i.useBlob){let t=new Blob([e],{type:Nt});a=URL.createObjectURL(t)}else a=`data:${Nt},`+encodeURIComponent(e);t(a)})).catch((()=>{r(new Error(`Failed to fetch worker from ${e}`))}))}))},Ar=function(){function e(e,t){for(var a=0;a<t.length;a++){var i=t[a];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,a,i){return a&&e(t.prototype,a),i&&e(t,i),t}}(),Or=qr(["",""],["",""]);function qr(e,t){return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function Nr(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var D=function(){function e(){for(var t=this,a=arguments.length,i=Array(a),r=0;r<a;r++)i[r]=arguments[r];return Nr(this,e),this.tag=function(e){for(var a=arguments.length,i=Array(a>1?a-1:0),r=1;r<a;r++)i[r-1]=arguments[r];return"function"==typeof e?t.interimTag.bind(t,e):"string"==typeof e?t.transformEndResult(e):(e=e.map(t.transformString.bind(t)),t.transformEndResult(e.reduce(t.processSubstitutions.bind(t,i))))},i.length>0&&Array.isArray(i[0])&&(i=i[0]),this.transformers=i.map((function(e){return"function"==typeof e?e():e})),this.tag}return Ar(e,[{key:"interimTag",value:function(e,t){for(var a=arguments.length,i=Array(a>2?a-2:0),r=2;r<a;r++)i[r-2]=arguments[r];return this.tag(Or,e.apply(void 0,[t].concat(i)))}},{key:"processSubstitutions",value:function(e,t,a){var i=this.transformSubstitution(e.shift(),t);return"".concat(t,i,a)}},{key:"transformString",value:function(e){return this.transformers.reduce((function(e,t){return t.onString?t.onString(e):e}),e)}},{key:"transformSubstitution",value:function(e,t){return this.transformers.reduce((function(e,a){return a.onSubstitution?a.onSubstitution(e,t):e}),e)}},{key:"transformEndResult",value:function(e){return this.transformers.reduce((function(e,t){return t.onEndResult?t.onEndResult(e):e}),e)}}]),e}(),w=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return{onEndResult:function(t){if(""===e)return t.trim();if("start"===(e=e.toLowerCase())||"left"===e)return t.replace(/^\s*/,"");if("end"===e||"right"===e)return t.replace(/\s*$/,"");throw new Error("Side not supported: "+e)}}};function xr(e){if(Array.isArray(e)){for(var t=0,a=Array(e.length);t<e.length;t++)a[t]=e[t];return a}return Array.from(e)}var T=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"initial";return{onEndResult:function(t){if("initial"===e){var a=t.match(/^[^\S\n]*(?=\S)/gm),i=a&&Math.min.apply(Math,xr(a.map((function(e){return e.length}))));if(i){var r=new RegExp("^.{"+i+"}","gm");return t.replace(r,"")}return t}if("all"===e)return t.replace(/^[^\S\n]+/gm,"");throw new Error("Unknown type: "+e)}}},z=function(e,t){return{onEndResult:function(a){if(null==e||null==t)throw new Error("replaceResultTransformer requires at least 2 arguments.");return a.replace(e,t)}}},B=function(e,t){return{onSubstitution:function(a,i){if(null==e||null==t)throw new Error("replaceSubstitutionTransformer requires at least 2 arguments.");return null==a?a:a.toString().replace(e,t)}}},Rr={separator:"",conjunction:"",serial:!1},q=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Rr;return{onSubstitution:function(t,a){if(Array.isArray(t)){var i=t.length,r=e.separator,n=e.conjunction,s=e.serial,o=a.match(/(\n?[^\S\n]+)$/);if(t=o?t.join(r+o[1]):t.join(r+" "),n&&i>1){var l=t.lastIndexOf(r);t=t.slice(0,l)+(s?r:"")+" "+n+t.slice(l+1)}}return t}}},_t=function(e){return{onSubstitution:function(t,a){return"string"==typeof t&&t.includes(e)&&(t=t.split(e)),t}}},xt=function(e){return null!=e&&!Number.isNaN(e)&&"boolean"!=typeof e},Pr=function(){return{onSubstitution:function(e){return Array.isArray(e)?e.filter(xt):xt(e)?e:""}}};new D(q({separator:","}),T,w),new D(q({separator:",",conjunction:"and"}),T,w),new D(q({separator:",",conjunction:"or"}),T,w),new D(_t("\n"),Pr,q,T,w),new D(_t("\n"),q,T,w,B(/&/g,"&amp;"),B(/</g,"&lt;"),B(/>/g,"&gt;"),B(/"/g,"&quot;"),B(/'/g,"&#x27;"),B(/`/g,"&#x60;")),new D(z(/(?:\n(?:\s*))+/g," "),w);var Tr=new D(z(/(?:\n\s*)/g,""),w);new D(q({separator:","}),z(/(?:\s+)/g," "),w),new D(q({separator:",",conjunction:"or"}),z(/(?:\s+)/g," "),w),new D(q({separator:",",conjunction:"and"}),z(/(?:\s+)/g," "),w),new D(q,T,w),new D(q,z(/(?:\s+)/g," "),w),new D(T,w),new D(T("all"),w);var Mr=e=>e.startsWith("data:"),kr=e=>e.startsWith("blob:"),Lr=e=>!Mr(e)&&!kr(e),Fr=async e=>{let t=await fetch(e,{method:"HEAD"}),a=t.headers.get("content-type"),i=null==a?void 0:a.includes("javascript");if(null!=a&&a.includes("html"))throw new Error(Tr`${e} resolved to a resource with the content type ${a}.
      This is likely an issue with the server configuration redirecting to an index.html file.
      Check that your resources are properly hosted`);if(!i)throw new Error(`Worker file is not a JavaScript file: ${a}`);if(!t.ok)throw new Error(`Worker file not found or inaccessible: ${t.status} ${t.statusText}`)},jr=async(e=window.location.href)=>{let t=await wr(new URL("resources/centaurus-worker.js",e).toString());Lr(t)&&await Fr(t);let a=new Worker(t,{type:"module"});a.onerror=e=>{console.error("Worker error:",e),i[Mt]()};let i=Et(a);return i},Rt=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce(((e,t)=>e+=(t&=63)<36?t.toString(36):t<62?(t-26).toString(36).toUpperCase():t>62?"-":"_"),""),Pt="centaurus-userid";function Er(){if(!Br())return Rt();let e=localStorage.getItem(Pt);if(e)return e;let t=Rt();return localStorage.setItem(Pt,t),t}function Br(){try{return localStorage.setItem("test","test"),localStorage.removeItem("test"),!0}catch{return!1}}var Jr={inputImageSource:"video",scanningMode:"automatic",scanningSettings:{allowUncertainFrontSideScan:!1,blurDetectionLevel:"mid",glareDetectionLevel:"mid",tiltDetectionLevel:"mid",skipImagesWithBlur:!0,skipImagesWithGlare:!0,skipImagesOccludedByHand:!0,skipImagesWithInadequateLightingConditions:!0,combineResultsFromMultipleInputImages:!0,croppedImageSettings:{dotsPerInch:250,extensionFactor:0,returnDocumentImage:!1,returnFaceImage:!1,returnSignatureImage:!1},customDocumentAnonymizationSettings:[],customDocumentRules:[],enableBarcodeScanOnly:!1,enableCharacterValidation:!0,inputImageMargin:.02,maxAllowedMismatchesPerField:0,recognitionModeFilter:{enableBarcodeId:!0,enableFullDocumentRecognition:!0,enableMrzId:!0,enableMrzPassport:!0,enableMrzVisa:!0,enablePhotoId:!0},returnInputImages:!1,scanCroppedDocumentImage:!1,scanPassportDataPageOnly:!0,scanUnsupportedBack:!1,anonymizationMode:"full-result"}};async function Vt(e,t){let a=await jr(e.resourcesLocation);e.userId||(e.userId=Er()),e.resourcesLocation||(e.resourcesLocation=window.location.href),void 0===e.useLightweightBuild&&(e.useLightweightBuild=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));let i=t?zt(t):void 0;try{return await a[atob("aW5pdEJsaW5rSWQ=")](e,Jr,i),a}catch(e){throw new Error("Failed to initialize Centaurus",{cause:e})}}var Ut=Symbol();globalThis.__CENTAURUS_CORE__||(globalThis.__CENTAURUS_CORE__=Ut),globalThis.__CENTAURUS_CORE__!==Ut&&console.warn("Detected multiple instances of Centaurus. This can lead to unexpected behavior.");var Ht=new Map;Ht.set([77,105,99,114,111,98,108,105,110,107],"Scandit"),Ht.set([66,108,105,110,107,73,68],"ID Capture");var at="Centaurus",x=class e{static async load(t){let a=new e;try{await a.initCentaurus(t)}catch(e){throw a.createErrorFromCentaurusError(e)}return a}static unload(){var t;null==(t=e.wasmSDK)||t.terminate(),e.wasmSDK=void 0}static replaceCentaurusMentions(e,t){return"string"==typeof e?[...t.entries()].reduce(((e,[t,a])=>{let i=t.map((e=>String.fromCodePoint(e))).join("");return e.replace(new RegExp(i,"gi"),a)}),e):"(no message)"}createErrorFromCentaurusError(e){return e instanceof Error&&"LicenseError"===(e.cause instanceof Error?e.cause:e).name?new DataCaptureError({name:"IdCaptureLoadingError",message:"Error 260: The Scandit SDK license validation failed. Your license key does not include support for this domain (Centaurus error)."}):new DataCaptureError({name:"IdCaptureLoadingError",message:"Error while loading Centaurus library."})}static async getWasmType(){let[e,t]=await Promise.all([BrowserHelper.hasSIMDSupport(),BrowserHelper.hasThreadsSupport()]);return e?t&&BrowserHelper.isDesktopDevice()?"advanced-threads":"advanced":"basic"}async initCentaurus(t){e.licenseKey=t.licenseKey;let a=new URL("8.3.0/",t.libraryLocation).toString(),i={licenseKey:t.licenseKey,initialMemory:500,resourcesLocation:a,useLightweightBuild:!0,wasmVariant:await e.getWasmType()};e.wasmSDK=await Vt(i,(({progress:e})=>{var a;null==(a=t.loadProgressNotifier)||a.call(t,{percentage:e,privateUri:new URL(`${at}.wasm`,t.libraryLocation).toString()})}))}},it=43,_r=100-it;function Vr(e){if("function"!=typeof e)return;let t=Object.keys(l);return function(a){if(null===a.percentage)return void e(a);let{pathname:i}=new URL(a.privateUri,document.baseURI),r={...a};t.some((e=>i.endsWith(e)))?r.percentage=it*a.percentage/100:i.endsWith(`${at}.wasm`)&&(r.percentage=it+_r*a.percentage/100),e(r)}}var Gt=Vr,Se=class e{get allChecksPassed(){var e,t;return null!=(t=null==(e=this.json)?void 0:e.allChecksPassed)&&t}get error(){var e;return"string"==typeof(null==(e=this.json)?void 0:e.error)&&""!==this.json.error?this.json.error:null}static fromJSON(t){let a=new e;return a.json=t,a}},Zt=class e{constructor(e,t=null){this._context=e,this._endpoint=t}static async create(t){return new e(t)}async verify(e){var t,a;let i=await this._context.workerCommand("idCaptureBarcodeVerifyAamvaCapture",{capturedId:e.toJSONObject(),endpoint:this._endpoint});return null!=(t=i.result)&&t.isSuccess||Logger.log(Logger.Level.Warn,"Error during Aamva verification:",null==(a=i.result)?void 0:a.error),Se.fromJSON(i.result)}},ye=class{constructor(e,t,a){this._days=e,this._months=t,this._years=a}get days(){return this._days}get months(){return this._months}get years(){return this._years}toJSONObject(){return{days:this.days,months:this.months,years:this.years}}},Ur=(e=>(e.FrontOnly="frontOnly",e.FrontAndBack="frontAndBack",e))(Ur||{}),Wr=(e=>(e.Face="face",e.CroppedDocument="croppedDocument",e.Frame="frame",e))(Wr||{}),Hr=(e=>(e.Front="front",e.Back="back",e))(Hr||{}),Gr=(e=>(e.None="none",e.FieldsOnly="fieldsOnly",e.ImagesOnly="imagesOnly",e.FieldsAndImages="fieldsAndImages",e))(Gr||{}),Kr=(e=>(e.Auto="auto",e.ButtonTap="buttonTap",e))(Kr||{}),Zr=(e=>(e.AdditionalAddressInformation="additionalAddressInformation",e.AdditionalNameInformation="additionalNameInformation",e.Address="address",e.Age="age",e.BarcodeDictionary="barcodeDictionary",e.BloodType="bloodType",e.DateOfBirth="dateOfBirth",e.DateOfExpiry="dateOfExpiry",e.DateOfIssue="dateOfIssue",e.DocumentAdditionalNumber="documentAdditionalNumber",e.DocumentNumber="documentNumber",e.Employer="employer",e.FathersName="fathersName",e.FirstName="firstName",e.FullName="fullName",e.IssuingAuthority="issuingAuthority",e.LastName="lastName",e.MaritalStatus="maritalStatus",e.MothersName="mothersName",e.MrzOptionalDataInLine1="mrzOptionalDataInLine1",e.MrzOptionalDataInLine2="mrzOptionalDataInLine2",e.Nationality="nationality",e.PersonalIdNumber="personalIdNumber",e.PlaceOfBirth="placeOfBirth",e.Profession="profession",e.Race="race",e.Religion="religion",e.ResidentialStatus="residentialStatus",e.Sex="sex",e))(Zr||{}),$r=(e=>(e.Rounded="rounded",e.Square="square",e))($r||{}),Qr=(e=>(e.Light="light",e.Bold="bold",e))(Qr||{}),Yr=(e=>(e.NotAvailable="notAvailable",e.NotRealIdCompliant="notRealIdCompliant",e.RealIdCompliant="realIdCompliant",e))(Yr||{}),Xr=(e=>(e.Female="female",e.Male="male",e.Unspecified="unspecified",e))(Xr||{}),nt=(e=>(e.Approved="approved",e.Granted="granted",e.Pending="pending",e.Denied="denied",e.Revoked="revoked",e.Expired="expired",e.Cancelled="cancelled",e.Other="other",e.Unknown="unknown",e))(nt||{}),$t="data:audio/mpeg;base64,SUQzBAAAAAACGFRFTkMAAAALAAADUHJvIFRvb2xzAFRYWFgAAAAjAAADb3JpZ2luYXRvcl9yZWZlcmVuY2UAYWE0RVFOcW9VQk9rAFRJVDIAAAAeAAADMDdfU2NhbmRpdF9TY2FubmVkLVdyb25nSXRlbQBUWFhYAAAASQAAA3VtaWQAMHgwNjBBMkIzNDAxMDEwMTA1MDEwMTBGMTAxMzAwMDAwMDg2RUUzOTA5RUE3QjgwMDBGNjZGQzVERDdBNzc5ODE0AFRYWFgAAAAYAAADdGltZV9yZWZlcmVuY2UAMjY3MDU5MABURFJDAAAADAAAAzIwMjMtMDMtMjQAVFNTRQAAAA8AAANMYXZmNTkuMTcuMTAxAAAAAAAAAAAAAAD/+1QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABJbmZvAAAADwAAABQAAAhAACIiIiIuLi4uLjo6Ojo6RUVFRUVRUVFRUV1dXV1daGhoaGh0dHR0dICAgICAi4uLi4uXl5eXl6KioqKirq6urq66urq6usXFxcXF0dHR0dHd3d3d3ejo6Ojo9PT09PT//////wAAAABMYXZjNTkuMjAAAAAAAAAAAAAAAAAkAsAAAAAAAAAIQBl5jwn/+xRkAAAAVgDUjQBgAAAADSCgAAEDiBduGIGACAAANIMAAAAgP8plFgg7znL+Q4k4B5uo2Rk9c+LQuOexRB4iCTT6t24x+9f7f/ve/OAAwiE0lTn2XHl6PVZxCA5GsdT/+xRkCoPwcwJexxhAAAAADSDgAAEBiAl0oJxAEAAANIAAAAQLpHM6PLpQzOOJP9g5lhihlyb2dlebf8JCDTyRW9i0P7qaz/+QAFBoW4NDEqQuutHr41//tAlwcSVBnm3/+xRkGwPwdwHbgCsQAAAADSAAAAEBlAd5AIhAAAAANIAAAATHiGz+Vc+PkABIAc4KvoFaqtnriqAiChQ15lfsMNqJ+6pCWSiwWiCplZ48GhwdztADJY5zm8nAqeDYITz/+xRkKwPweAReQCYQAAAADSAAAAEB5BF+gYhgKAAANIAAAARCDP8WxCCX+BeBTH3/iEEQWPLf/j9xbSKUgEEVL1p+0zaZlevKU5jbmwnBfkrWVYFOA8ttpVTjnZNQTAj/+xRkOYHwcAJeQCIYAAAADSAAAAEBwAd1AJhAAAAANIAAAAQh4cpNFFitO6uKSSRkaPEOmFCjhCufYvSYAMRykUrsTqSNnkFv2JqLbTWsOJFsnYRXo/r1z8r/7+mDiwH/+xRkSYAAdwLcJSQACAAADSCgAAEEeJFKGKUACAAANIMAAABxOtc6Jp53xlXP35AAcoV0pquMq1q/64ds9sxEh5Gt1gF6lGuqIWmtoDBY0qSi+FDRUEFIX0BPlJEDhYT/+xRkTgPxAxRZhzDAAAAADSDgAAEBlAl5AJhAAAAANIAAAATqelYAwIlAy0/IoV/EKh5Gw6UEDpn9pqpMQU1FqkxBTUUzLjk5LjWqqqqqqqqqqqqqqqqqqqqqqqqqqqr/+xRkVYPweQJfIMkQCAAADSAAAAEBzAlyAJwAAAAANIAAAASqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkxBTUUzLjk5LjWqqqqqqqqqqqqqqqqqqqqqqqqqqqr/+xRkZIPwdAdgoEEYigAADSAAAAEB1AuEgQhAKAAANIAAAASqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkxBTUUzLjk5LjWqqqqqqqqqqqqqqqqqqqqqqqqqqqr/+xRkc4PwcAdewMEQoAAADSAAAAEBrAmCgQhgKAAANIAAAASqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkxBTUUzLjk5LjWqqqqqqqqqqqqqqqqqqqqqqqqqqqr/+xRkg4fwcgHcIMYICgAADSAAAAEBcA8wrGHgKAAANIAAAASqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkxBTUUzLjk5LjWqqqqqqqqqqqqqqqqqqqqqqqqqqqr/+xRklI/wTgLEAwkACgAADSAAAAEBWBTkBIxiaAAANIAAAASqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqkxBTUUzLjk5LjWqqqqqqqqqqqqqqqqqqqqqqqqqqqr/+xRkqA/wAABpAAAACAAADSAAAAEAAAGkAAAAIAAANIAAAASqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr/+xRkxg/wAABpAAAACAAADSAAAAEAAAGkAAAAIAAANIAAAASqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr/+xRk4Y/wAABpAAAACAAADSAAAAEAAAGkAAAAIAAANIAAAASqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr/+xRk4Y/wAABpAAAACAAADSAAAAEAAAGkAAAAIAAANIAAAASqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr/+xRk4Y/wAABpAAAACAAADSAAAAEAAAGkAAAAIAAANIAAAASqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr/+xRk4Y/wAABpAAAACAAADSAAAAEAAAGkAAAAIAAANIAAAASqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr/+xRk4Y/wAABpAAAACAAADSAAAAEAAAGkAAAAIAAANIAAAASqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr/+xRk4Y/wAABpAAAACAAADSAAAAEAAAGkAAAAIAAANIAAAASqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqo=",be=class e{constructor(){this.idCaptured=Feedback.defaultFeedback,this.idRejected=new Feedback(null,null)}static get defaultFeedback(){return new e}static get defaultSuccessSound(){return Sound.defaultSound}static get defaultFailureSound(){return new Sound($t)}toJSONObject(){return{idCaptured:this.idCaptured.toJSONObject(),idRejected:this.idRejected.toJSONObject()}}},R=(e=>(e.Passport="passport",e.IdCard="idCard",e.DriverLicense="driverLicense",e.VisaIcao="visaIcao",e.ResidencePermit="residencePermit",e.HealthInsuranceCard="healthInsuranceCard",e.RegionSpecific="regionSpecific",e.VisaLetter="visaLetter",e))(R||{}),S=class{constructor(e){this._region=e}get region(){return this._region}isPassport(){return"passport"===this.documentType}isIdCard(){return"idCard"===this.documentType}isDriverLicense(){return"driverLicense"===this.documentType}isVisaIcao(){return"visaIcao"===this.documentType}isVisaLetter(){return"visaLetter"===this.documentType}isHealthInsuranceCard(){return"healthInsuranceCard"===this.documentType}isResidencePermit(){return"residencePermit"===this.documentType}isRegionSpecific(){return"regionSpecific"===this.documentType}},Ie=class e{constructor(){this.json={}}get errorCorrection(){return this.json.errorCorrection}get moduleCountX(){return this.json.moduleCountX}get moduleCountY(){return this.json.moduleCountY}static fromJSON(t){if(null==t)return null;let a=new e;return a.json=t,a}toJSONObject(){return{errorCorrection:this.errorCorrection,moduleCountX:this.moduleCountX,moduleCountY:this.moduleCountY}}},m=class e{constructor(){this.json={}}get day(){return this.json.day}get month(){return this.json.month}get year(){return this.json.year}get localDate(){return new Date(this.json.year,this.json.month?this.json.month-1:0,this.json.day||1)}get utcDate(){return new Date(Date.UTC(this.json.year,this.json.month?this.json.month-1:0,this.json.day||1))}static fromJSON(t){if(null==t)return null;let a=new e;return a.json=t,a}toJSONObject(){return{day:this.day,month:this.month,year:this.year}}},ve=class e{get dateOfExpiry(){var e;return null!=(e=m.fromJSON(this.json.dateOfExpiry))?e:new m}get codes(){return this.json.codes}static fromJSON(t){if(null===t)return null;let a=new e;return a.json=t,a}toJSONObject(){return{codes:[...this.codes],dateOfExpiry:this.dateOfExpiry.toJSONObject()}}},De=class e{get vehicleCode(){return this.json.vehicleCode}get vehicleRestriction(){return this.json.vehicleRestriction}get dateOfIssue(){var e;return null!=(e=m.fromJSON(this.json.dateOfIssue))?e:new m}static fromJSON(t){if(null===t)return null;let a=new e;return a.json=t,a}toJSONObject(){return{dateOfIssue:this.dateOfIssue.toJSONObject(),vehicleCode:this.vehicleCode,vehicleRestriction:this.vehicleRestriction}}},we=class e{get aamvaVersion(){return this.json.aamvaVersion}get aliasFamilyName(){return this.json.aliasFamilyName}get aliasGivenName(){return this.json.aliasGivenName}get aliasSuffixName(){return this.json.aliasSuffixName}get bloodType(){return this.json.bloodType}get branchOfService(){return this.json.branchOfService}get cardInstanceIdentifier(){return this.json.cardInstanceIdentifier}get cardRevisionDate(){return m.fromJSON(this.json.cardRevisionDate)}get categories(){return null!=this.json.categories?this.json.categories:[]}get champusEffectiveDate(){return m.fromJSON(this.json.champusEffectiveDate)}get champusExpiryDate(){return m.fromJSON(this.json.champusExpiryDate)}get citizenshipStatus(){return this.json.citizenshipStatus}get civilianHealthCareFlagCode(){return this.json.civilianHealthCareFlagCode}get civilianHealthCareFlagDescription(){return this.json.civilianHealthCareFlagDescription}get commissaryFlagCode(){return this.json.commissaryFlagCode}get commissaryFlagDescription(){return this.json.commissaryFlagDescription}get countryOfBirth(){return this.json.countryOfBirth}get countryOfBirthIso(){return this.json.countryOfBirthIso}get deersDependentSuffixCode(){return this.json.deersDependentSuffixCode}get deersDependentSuffixDescription(){return this.json.deersDependentSuffixDescription}get directCareFlagCode(){return this.json.directCareFlagCode}get directCareFlagDescription(){return this.json.directCareFlagDescription}get documentCopy(){return this.json.documentCopy}get documentDiscriminatorNumber(){return this.json.documentDiscriminatorNumber}get driverNamePrefix(){return this.json.driverNamePrefix}get driverNameSuffix(){return this.json.driverNameSuffix}get driverRestrictionCodes(){return null!=this.json.driverRestrictionCodes?this.json.driverRestrictionCodes:[]}get ediPersonIdentifier(){return this.json.ediPersonIdentifier}get endorsementsCode(){return this.json.endorsementsCode}get exchangeFlagCode(){return this.json.exchangeFlagCode}get exchangeFlagDescription(){return this.json.exchangeFlagDescription}get eyeColor(){return this.json.eyeColor}get familySequenceNumber(){return this.json.familySequenceNumber}get firstNameTruncation(){return this.json.firstNameTruncation}get firstNameWithoutMiddleName(){return this.json.firstNameWithoutMiddleName}get formNumber(){return this.json.formNumber}get genevaConventionCategory(){return this.json.genevaConventionCategory}get hairColor(){return this.json.hairColor}get heightCm(){return this.json.heightCm}get heightInch(){return this.json.heightInch}get IIN(){return this.json.iin}get identificationType(){return this.json.identificationType}get issuingJurisdiction(){return this.json.issuingJurisdiction}get issuingJurisdictionIso(){return this.json.issuingJurisdictionIso}get barcodeMetadata(){return Ie.fromJSON(this.json.barcodeMetadata)}get jpegData(){return this.json.jpegData}get jurisdictionVersion(){return this.json.jurisdictionVersion}get lastNameTruncation(){return this.json.lastNameTruncation}get licenseCountryOfIssue(){return this.json.licenseCountryOfIssue}get middleName(){return this.json.middleName}get middleNameTruncation(){return this.json.middleNameTruncation}get mwrFlagCode(){return this.json.mwrFlagCode}get mwrFlagDescription(){return this.json.mwrFlagDescription}get payGrade(){return this.json.payGrade}get payPlanCode(){return this.json.payPlanCode}get payPlanGradeCode(){return this.json.payPlanGradeCode}get personDesignatorDocument(){return this.json.personDesignatorDocument}get personDesignatorTypeCode(){return this.json.personDesignatorTypeCode}get personMiddleInitial(){return this.json.personMiddleInitial}get personalIdNumber(){return this.json.personalIdNumber}get personalIdNumberType(){return this.json.personalIdNumberType}get personnelCategoryCode(){return this.json.personnelCategoryCode}get personnelEntitlementConditionType(){return this.json.personnelEntitlementConditionType}get placeOfBirth(){return this.json.placeOfBirth}get professionalDrivingPermit(){return null!=this.json.professionalDrivingPermit?ve.fromJSON(this.json.professionalDrivingPermit):null}get race(){return this.json.race}get rank(){return this.json.rank}get rawData(){return this.json.rawData}get relationshipCode(){return this.json.relationshipCode}get relationshipDescription(){return this.json.relationshipDescription}get restrictionsCode(){return this.json.restrictionsCode}get securityCode(){return this.json.securityCode}get serviceCode(){return this.json.serviceCode}get sponsorFlag(){return this.json.sponsorFlag}get sponsorName(){return this.json.sponsorName}get sponsorPersonDesignatorIdentifier(){return this.json.sponsorPersonDesignatorIdentifier}get statusCode(){return this.json.statusCode}get statusCodeDescription(){return this.json.statusCodeDescription}get vehicleClass(){return this.json.vehicleClass}get vehicleRestrictions(){return null!=this.json.vehicleRestrictions?this.json.vehicleRestrictions.map((e=>De.fromJSON(e))).filter((e=>null!=e)):[]}get version(){return this.json.version}get weightKg(){return this.json.weightKg}get weightLbs(){return this.json.weightLbs}get isRealId(){return this.json.isRealId}get firstName(){return this.json.firstName}get lastName(){return this.json.lastName}get fullName(){return this.json.fullName}get sex(){return this.json.sex}get dateOfBirth(){return m.fromJSON(this.json.dateOfBirth)}get nationality(){return this.json.nationality}get address(){return this.json.address}get documentNumber(){return this.json.documentNumber}get dateOfExpiry(){return m.fromJSON(this.json.dateOfExpiry)}get dateOfIssue(){return m.fromJSON(this.json.dateOfIssue)}get barcodeDataElements(){return this.json.dictionary}static fromJSON(t){let a=new e;return a.json=t,a}toJSONObject(){var e,t,a,i,r,n,s,o,l,u,d,c,h,p,m;return{aamvaVersion:this.aamvaVersion,address:this.address,aliasFamilyName:this.aliasFamilyName,aliasGivenName:this.aliasGivenName,aliasSuffixName:this.aliasSuffixName,barcodeMetadata:null!=(t=null==(e=this.barcodeMetadata)?void 0:e.toJSONObject())?t:null,bloodType:this.bloodType,branchOfService:this.branchOfService,cardInstanceIdentifier:this.cardInstanceIdentifier,cardRevisionDate:this.cardRevisionDate?this.cardRevisionDate.toJSONObject():null,categories:[...this.categories],champusEffectiveDate:null!=(i=null==(a=this.champusEffectiveDate)?void 0:a.toJSONObject())?i:null,champusExpiryDate:null!=(n=null==(r=this.champusExpiryDate)?void 0:r.toJSONObject())?n:null,citizenshipStatus:this.citizenshipStatus,civilianHealthCareFlagCode:this.civilianHealthCareFlagCode,civilianHealthCareFlagDescription:this.civilianHealthCareFlagDescription,commissaryFlagCode:this.commissaryFlagCode,commissaryFlagDescription:this.commissaryFlagDescription,countryOfBirth:this.countryOfBirth,countryOfBirthIso:this.countryOfBirthIso,dateOfBirth:null!=(o=null==(s=this.dateOfBirth)?void 0:s.toJSONObject())?o:null,dateOfExpiry:null!=(u=null==(l=this.dateOfExpiry)?void 0:l.toJSONObject())?u:null,dateOfIssue:null!=(c=null==(d=this.dateOfIssue)?void 0:d.toJSONObject())?c:null,deersDependentSuffixCode:this.deersDependentSuffixCode,deersDependentSuffixDescription:this.deersDependentSuffixDescription,dictionary:{...this.barcodeDataElements},directCareFlagCode:this.directCareFlagCode,directCareFlagDescription:this.directCareFlagDescription,documentAdditionalNumber:this.json.documentAdditionalNumber,documentCopy:this.documentCopy,documentDiscriminatorNumber:this.documentDiscriminatorNumber,documentNumber:this.documentNumber,documentSubtype:this.json.documentSubtype,documentType:this.json.documentType,driverNamePrefix:this.driverNamePrefix,driverNameSuffix:this.driverNameSuffix,driverRestrictionCodes:[...this.driverRestrictionCodes],ediPersonIdentifier:this.ediPersonIdentifier,endorsementsCode:this.endorsementsCode,exchangeFlagCode:this.exchangeFlagCode,exchangeFlagDescription:this.exchangeFlagDescription,eyeColor:this.eyeColor,familySequenceNumber:this.familySequenceNumber,firstName:this.firstName,firstNameTruncation:this.firstNameTruncation,firstNameWithoutMiddleName:this.firstNameWithoutMiddleName,formNumber:this.formNumber,fullName:this.fullName,genevaConventionCategory:this.genevaConventionCategory,hairColor:this.hairColor,heightCm:this.heightCm,heightInch:this.heightInch,iin:this.IIN,identificationType:this.identificationType,isRealId:this.isRealId,issuingCountry:this.json.issuingCountry,issuingCountryIso:this.json.issuingCountryIso,issuingJurisdiction:this.issuingJurisdiction,issuingJurisdictionIso:this.issuingJurisdictionIso,jpegData:this.jpegData,jurisdictionVersion:this.jurisdictionVersion,lastNameTruncation:this.lastNameTruncation,licenseCountryOfIssue:this.licenseCountryOfIssue,lastName:this.lastName,location:null!=(h=this.json.location)?h:null,middleName:this.middleName,middleNameTruncation:this.middleNameTruncation,mwrFlagCode:this.mwrFlagCode,mwrFlagDescription:this.mwrFlagDescription,nationality:this.nationality,payGrade:this.payGrade,payPlanCode:this.payPlanCode,payPlanGradeCode:this.payPlanGradeCode,personDesignatorDocument:this.personDesignatorDocument,personDesignatorTypeCode:this.personDesignatorTypeCode,personMiddleInitial:this.personMiddleInitial,personalIdNumber:this.personalIdNumber,personalIdNumberType:this.personalIdNumberType,personnelCategoryCode:this.personnelCategoryCode,personnelEntitlementConditionType:this.personnelEntitlementConditionType,placeOfBirth:this.placeOfBirth,professionalDrivingPermit:null!=(m=null==(p=this.professionalDrivingPermit)?void 0:p.toJSONObject())?m:null,race:this.race,rank:this.rank,rawData:this.rawData,relationshipCode:this.relationshipCode,relationshipDescription:this.relationshipDescription,restrictionsCode:this.restrictionsCode,securityCode:this.securityCode,serviceCode:this.serviceCode,sex:this.sex,sexOriginal:this.json.sexOriginal,sponsorFlag:this.sponsorFlag,sponsorName:this.sponsorName,sponsorPersonDesignatorIdentifier:this.sponsorPersonDesignatorIdentifier,statusCode:this.statusCode,statusCodeDescription:this.statusCodeDescription,vehicleClass:this.vehicleClass,vehicleRestrictions:this.vehicleRestrictions.map((e=>e.toJSONObject())),version:this.version,weightKg:this.weightKg,weightLbs:this.weightLbs}}},Ae=class e{constructor(){this.json=null}get face(){var e,t;return null!=(t=null==(e=this.json)?void 0:e.front.face)?t:null}get frame(){var e,t,a,i;return null!=(i=null!=(a=null==(e=this.json)?void 0:e.front.frame)?a:null==(t=this.json)?void 0:t.back.frame)?i:null}static fromJSON(t){let a=new e;return null!=t&&(a.json=t),a}getFrame(e){var t,a,i,r;switch(e){case"front":return null!=(a=null==(t=this.json)?void 0:t.front.frame)?a:null;case"back":return null!=(r=null==(i=this.json)?void 0:i.back.frame)?r:null}return null}getCroppedDocument(e){var t,a,i,r;switch(e){case"front":return null!=(a=null==(t=this.json)?void 0:t.front.croppedDocument)?a:null;case"back":return null!=(r=null==(i=this.json)?void 0:i.back.croppedDocument)?r:null}return null}toJSONObject(){return{front:{face:this.face,croppedDocument:this.getCroppedDocument("front"),frame:this.getFrame("front")},back:{face:null,croppedDocument:this.getCroppedDocument("back"),frame:this.getFrame("back")}}}},Oe=class e{get documentCode(){return this.json.documentCode}get namesAreTruncated(){return this.json.namesAreTruncated}get optionalDataInLine1(){return this.json.optionalDataInLine1}get optionalDataInLine2(){return this.json.optionalDataInLine2}get capturedMrz(){return this.json.capturedMrz}get personalIdNumber(){return this.json.personalIdNumber}get renewalTimes(){return this.json.renewalTimes}get fullNameSimplifiedChinese(){return this.json.fullNameSimplifiedChinese}get omittedCharacterCountInGbkName(){return this.json.omittedCharacterCountInGbkName}get omittedNameCount(){return this.json.omittedNameCount}get issuingAuthorityCode(){return this.json.issuingAuthorityCode}get passportIssuerIso(){return this.json.passportIssuerIso}get passportNumber(){return this.json.passportNumber}get passportDateOfExpiry(){return m.fromJSON(this.json.passportDateOfExpiry)}get firstName(){return this.json.firstName}get lastName(){return this.json.lastName}get fullName(){return this.json.fullName}get sex(){return this.json.sex}get dateOfBirth(){return m.fromJSON(this.json.dateOfBirth)}get nationality(){return this.json.nationality}get address(){return this.json.address}get documentNumber(){return this.json.documentNumber}get dateOfExpiry(){return m.fromJSON(this.json.dateOfExpiry)}get dateOfIssue(){return m.fromJSON(this.json.dateOfIssue)}static fromJSON(t){let a=new e;return a.json=t,a}toJSONObject(){var e,t,a,i;return{...this.json,documentCode:this.documentCode,namesAreTruncated:this.namesAreTruncated,optionalDataInLine1:this.optionalDataInLine1,optionalDataInLine2:this.optionalDataInLine2,capturedMrz:this.capturedMrz,personalIdNumber:this.personalIdNumber,renewalTimes:this.renewalTimes,fullNameSimplifiedChinese:this.fullNameSimplifiedChinese,omittedCharacterCountInGbkName:this.omittedCharacterCountInGbkName,omittedNameCount:this.omittedNameCount,issuingAuthorityCode:this.issuingAuthorityCode,passportIssuerIso:this.passportIssuerIso,passportNumber:this.passportNumber,passportDateOfExpiry:this.passportDateOfExpiry?this.passportDateOfExpiry.toJSONObject():null,firstName:this.firstName,lastName:this.lastName,fullName:this.fullName,sex:this.sex,dateOfBirth:this.dateOfBirth?this.dateOfBirth.toJSONObject():null,nationality:this.nationality,address:this.address,documentNumber:this.documentNumber,dateOfExpiry:null!=(t=null==(e=this.dateOfExpiry)?void 0:e.toJSONObject())?t:null,dateOfIssue:null!=(i=null==(a=this.dateOfIssue)?void 0:a.toJSONObject())?i:null}}},qe=class e{constructor(){this.json={}}get code(){return this.json.code}get dateOfIssue(){return m.fromJSON(this.json.dateOfIssue)}get dateOfExpiry(){return m.fromJSON(this.json.dateOfExpiry)}static fromJSON(t){if(null==t)return null;let a=new e;return a.json=t,a}toJSONObject(){return{code:this.code,dateOfIssue:this.dateOfIssue?this.dateOfIssue.toJSONObject():null,dateOfExpiry:this.dateOfExpiry?this.dateOfExpiry.toJSONObject():null}}},_=class e{constructor(){this.json={}}get drivingLicenseCategories(){return this.json.drivingLicenseCategories.map((e=>qe.fromJSON(e))).filter((e=>null!=e))}get restrictions(){return this.json.restrictions}get endorsements(){return this.json.endorsements}static fromJSON(t){if(null==t)return null;let a=new e;return a.json=t,a}toJSONObject(){return{drivingLicenseCategories:this.drivingLicenseCategories.map((e=>e.toJSONObject())),restrictions:this.restrictions,endorsements:this.endorsements}}},Ne=class e{get applicationStatus(){return Object.values(nt).includes(this.json.applicationStatus)?this.json.applicationStatus:null}get durationInDays(){return this.json.durationInDays}get fullName(){return this.json.fullName}get geographicValidity(){return this.json.geographicValidity}get dateOfIssue(){return m.fromJSON(this.json.dateOfIssue)}get issuingCountryIso(){return this.json.issuingCountryIso}get issuingAuthority(){return this.json.issuingAuthority}get numberOfEntries(){return this.json.numberOfEntries}get multipleEntries(){return this.json.multipleEntries}get passportNumber(){return this.json.passportNumber}get visaNumber(){return this.json.visaNumber}get validFrom(){return m.fromJSON(this.json.validFrom)}get validUntil(){return m.fromJSON(this.json.validUntil)}get visaType(){return this.json.visaType}toJSONObject(){var e,t,a,i,r,n,s;return{applicationStatus:this.applicationStatus,dateOfIssue:null!=(t=null==(e=this.dateOfIssue)?void 0:e.toJSONObject())?t:null,durationInDays:this.durationInDays,fullName:this.fullName,geographicValidity:this.geographicValidity,issuingCountryIso:this.issuingCountryIso,issuingAuthority:this.issuingAuthority,multipleEntries:this.multipleEntries,numberOfEntries:this.numberOfEntries,passportNumber:this.passportNumber,visaNumber:this.visaNumber,validFrom:null!=(i=null==(a=this.validFrom)?void 0:a.toJSONObject())?i:null,validUntil:null!=(n=null==(r=this.validUntil)?void 0:r.toJSONObject())?n:null,visaType:null!=(s=this.visaType)?s:null}}static fromJSON(t){if(null==t)return null;let a=new e;return a.json=t,a}},xe=class e{get firstName(){return this.json.firstName}get lastName(){return this.json.lastName}get fullName(){return this.json.fullName}get additionalAddressInformation(){return this.json.additionalAddressInformation}get additionalNameInformation(){return this.json.additionalNameInformation}get documentAdditionalNumber(){return this.json.documentAdditionalNumber}get employer(){return this.json.employer}get issuingAuthority(){return this.json.issuingAuthority}get issuingJurisdiction(){return this.json.issuingJurisdiction}get issuingJurisdictionIso(){return this.json.issuingJurisdictionIso}get maritalStatus(){return this.json.maritalStatus}get personalIdNumber(){return this.json.personalIdNumber}get placeOfBirth(){return this.json.placeOfBirth}get profession(){return this.json.profession}get race(){return this.json.race}get religion(){return this.json.religion}get residentialStatus(){return this.json.residentialStatus}get mothersName(){return this.json.mothersName}get fathersName(){return this.json.fathersName}get capturedSides(){return this.json.capturedSides}get isBackSideCaptureSupported(){return this.json.isBackSideCaptureSupported}get drivingLicenseDetails(){return _.fromJSON(this.json.drivingLicenseDetails)}get bloodType(){return this.json.bloodType}get sponsor(){return this.json.sponsor}get visaNumber(){return this.json.visaNumber}get passportNumber(){return this.json.passportNumber}get sex(){return this.json.sex}get dateOfBirth(){return m.fromJSON(this.json.dateOfBirth)}get nationality(){return this.json.nationality}get address(){return this.json.address}get documentNumber(){return this.json.documentNumber}get dateOfExpiry(){return m.fromJSON(this.json.dateOfExpiry)}get dateOfIssue(){return m.fromJSON(this.json.dateOfIssue)}get vehicleOwner(){return this.json.vehicleOwner}get visaDetails(){return Ne.fromJSON(this.json.visaDetails)}static fromJSON(t){if(null==t)return null;let a=new e;return a.json=t,a}toJSONObject(){var e,t,a,i,r,n,s,o;return{...this.json,firstName:this.firstName,lastName:this.lastName,fullName:this.fullName,additionalAddressInformation:this.additionalAddressInformation,additionalNameInformation:this.additionalNameInformation,documentAdditionalNumber:this.documentAdditionalNumber,employer:this.employer,issuingAuthority:this.issuingAuthority,issuingJurisdiction:this.issuingJurisdiction,issuingJurisdictionIso:this.issuingJurisdictionIso,maritalStatus:this.maritalStatus,personalIdNumber:this.personalIdNumber,placeOfBirth:this.placeOfBirth,profession:this.profession,race:this.race,religion:this.religion,residentialStatus:this.residentialStatus,mothersName:this.mothersName,fathersName:this.fathersName,capturedSides:this.capturedSides,isBackSideCaptureSupported:this.isBackSideCaptureSupported,drivingLicenseDetails:this.drivingLicenseDetails?this.drivingLicenseDetails.toJSONObject():null,bloodType:this.bloodType,sponsor:this.sponsor,passportNumber:this.passportNumber,visaNumber:this.visaNumber,sex:this.sex,dateOfBirth:null!=(t=null==(e=this.dateOfBirth)?void 0:e.toJSONObject())?t:null,nationality:this.nationality,address:this.address,documentNumber:this.documentNumber,dateOfExpiry:null!=(i=null==(a=this.dateOfExpiry)?void 0:a.toJSONObject())?i:null,dateOfIssue:null!=(n=null==(r=this.dateOfIssue)?void 0:r.toJSONObject())?n:null,vehicleOwner:this.vehicleOwner,visaDetails:null!=(o=null==(s=this.visaDetails)?void 0:s.toJSONObject())?o:null}}},N={IssuingCountryIso:"issuing country",IssuingJurisdictionIso:"issuing jurisdiction",DocumentNumber:"document number",FullName:"full name",BirthDate:"date of birth",ExpiryDate:"date of expiry",IssueDate:"date of issue",FirstName:"first name",LastName:"last name"},Re=class e{constructor(){this.json={}}get allChecksPassed(){return this.json.allChecksPassed}get failedChecks(){return this.json.failedChecks}get skippedChecks(){return this.json.skippedChecks}get passedChecks(){return this.json.passedChecks}static fromJSON(t){let a=new e;return a.json=t,a}async frontReviewImage(){let e=this.json.frontFieldLocations,t=null!=e&&Object.keys(e).length>0,a=this.json.frontImage;if(!this.allChecksPassed&&null!=a&&t)try{return await this.highlightImage(a,e)}catch(e){Logger.log(Logger.Level.Warn,"Failed to create image with mismatching fields.",e)}return""}toJSONObject(){return{...this.json}}async highlightImage(e,t){let a=new Image;a.src=`data:image/png;base64,${e}`,await a.decode();let i=document.createElement("canvas");i.width=a.width,i.height=a.height;let r=i.getContext("2d");if(!r)throw new Error("Failed to get 2d context from canvas");r.drawImage(a,0,0);let n=this.getMismatchedQuads(t);if(0===n.length)return"";r.beginPath(),r.rect(0,0,a.width,a.height);for(let e of n)r.moveTo(e.topLeft.x,e.topLeft.y),r.lineTo(e.topLeft.x,e.bottomRight.y),r.lineTo(e.bottomRight.x,e.bottomRight.y),r.lineTo(e.bottomRight.x,e.topLeft.y),r.lineTo(e.topLeft.x,e.topLeft.y);r.fillStyle="rgba(0, 0, 0, 0.30)",r.fill(),r.lineWidth=3,r.strokeStyle="red",r.beginPath();for(let e of n)r.rect(e.topLeft.x,e.topLeft.y,e.bottomRight.x-e.topLeft.x,e.bottomRight.y-e.topLeft.y);return r.stroke(),i.toDataURL("image/jpeg",1)}getQuadsForFields(e,t){return t.map((t=>e[t])).filter((e=>null!=e)).map((e=>Quadrilateral.fromJSON(e)))}getMismatchedQuads(e){if(null==e)return[];let t=new Set;for(let e of this.failedChecks)switch(e){case"documentNumberComparison":t.add(N.DocumentNumber);break;case"fullNameComparison":t.add(N.FullName),t.add(N.FirstName),t.add(N.LastName);break;case"issuingCountryComparison":t.add(N.IssuingCountryIso);break;case"issuingJurisdictionComparison":t.add(N.IssuingJurisdictionIso);break;case"dateOfBirthComparison":t.add(N.BirthDate);break;case"dateOfExpiryComparison":t.add(N.ExpiryDate);break;case"dateOfIssueComparison":t.add(N.IssueDate)}return this.getQuadsForFields(e,Array.from(t))}},ne=class e{constructor(){this.json=null}get dataConsistency(){var e;return null!=(null==(e=this.json)?void 0:e.dataConsistencyResult)?Re.fromJSON(this.json.dataConsistencyResult):null}static fromJSON(t){let a=new e;return a.json=t,a}toJSONObject(){var e,t;return{dataConsistencyResult:null!=(t=null==(e=this.dataConsistency)?void 0:e.toJSONObject())?t:null}}},V=class extends S{constructor(e){super(e),this.documentType="driverLicense"}get region(){return this._region}toJSONObject(){return{region:this.region,documentType:this.documentType}}},U=class extends S{constructor(e){super(e),this.documentType="healthInsuranceCard"}get region(){return this._region}toJSONObject(){return{region:this.region,documentType:this.documentType}}},W=class extends S{constructor(e){super(e),this.documentType="idCard"}get region(){return this._region}toJSONObject(){return{region:this.region,documentType:this.documentType}}},H=class extends S{constructor(e){super(e),this.documentType="passport"}get region(){return this._region}toJSONObject(){return{region:this.region,documentType:this.documentType}}},ta=(e=>(e.Any="any",e.EuAndSchengen="euAndSchengen",e.Aruba="aruba",e.Afghanistan="afghanistan",e.Angola="angola",e.Anguilla="anguilla",e.AlandIslands="alandIslands",e.Albania="albania",e.Andorra="andorra",e.Uae="uae",e.Argentina="argentina",e.Armenia="armenia",e.AmericanSamoa="americanSamoa",e.Antarctica="antarctica",e.FrenchSouthernTerritories="frenchSouthernTerritories",e.AntiguaAndBarbuda="antiguaAndBarbuda",e.Australia="australia",e.Austria="austria",e.Azerbaijan="azerbaijan",e.Burundi="burundi",e.Belgium="belgium",e.Benin="benin",e.BonaireSintEustatiusAndSaba="bonaireSintEustatiusAndSaba",e.BurkinaFaso="burkinaFaso",e.Bangladesh="bangladesh",e.Bulgaria="bulgaria",e.Bahrain="bahrain",e.Bahamas="bahamas",e.BosniaHerzegovina="bosniaHerzegovina",e.SaintBarthelemy="saintBarthelemy",e.Belarus="belarus",e.Belize="belize",e.Bermuda="bermuda",e.Bolivia="bolivia",e.Brazil="brazil",e.Barbados="barbados",e.BruneiDarussalam="bruneiDarussalam",e.Bhutan="bhutan",e.BouvetIsland="bouvetIsland",e.Botswana="botswana",e.Car="car",e.Canada="canada",e.CocosIslands="cocosIslands",e.Switzerland="switzerland",e.Chile="chile",e.China="china",e.CoteIvoire="coteIvoire",e.Cameroon="cameroon",e.DemocraticRepublicOfCongo="democraticRepublicOfCongo",e.Congo="congo",e.CookIslands="cookIslands",e.Colombia="colombia",e.Comoros="comoros",e.CaboVerde="caboVerde",e.CostaRica="costaRica",e.Cuba="cuba",e.Curacao="curacao",e.ChristmasIsland="christmasIsland",e.CaymanIslands="caymanIslands",e.Cyprus="cyprus",e.Czechia="czechia",e.Germany="germany",e.Djibouti="djibouti",e.Dominica="dominica",e.Denmark="denmark",e.DominicanRepublic="dominicanRepublic",e.Algeria="algeria",e.Ecuador="ecuador",e.Egypt="egypt",e.Eritrea="eritrea",e.WesternSahara="westernSahara",e.Spain="spain",e.Estonia="estonia",e.Ethiopia="ethiopia",e.Finland="finland",e.Fiji="fiji",e.FalklandIslands="falklandIslands",e.France="france",e.FaroeIslands="faroeIslands",e.Micronesia="micronesia",e.Gabon="gabon",e.Uk="uk",e.Georgia="georgia",e.Guernsey="guernsey",e.Ghana="ghana",e.Gibraltar="gibraltar",e.Guinea="guinea",e.Guadeloupe="guadeloupe",e.Gambia="gambia",e.GuineaBissau="guineaBissau",e.EquatorialGuinea="equatorialGuinea",e.Greece="greece",e.Grenada="grenada",e.Greenland="greenland",e.Guatemala="guatemala",e.FrenchGuiana="frenchGuiana",e.Guam="guam",e.Guyana="guyana",e.HongKong="hongKong",e.HeardIslandAndMcDonaldIslands="heardIslandAndMcDonaldIslands",e.Honduras="honduras",e.Croatia="croatia",e.Haiti="haiti",e.Hungary="hungary",e.Indonesia="indonesia",e.IsleOfMan="isleOfMan",e.India="india",e.BritishIndianOceanTerritory="britishIndianOceanTerritory",e.Ireland="ireland",e.Iran="iran",e.Iraq="iraq",e.Iceland="iceland",e.Israel="israel",e.Italy="italy",e.Jamaica="jamaica",e.Jersey="jersey",e.Jordan="jordan",e.Japan="japan",e.Kazakhstan="kazakhstan",e.Kenya="kenya",e.Kyrgyzstan="kyrgyzstan",e.Cambodia="cambodia",e.Kiribati="kiribati",e.SaintKittsAndNevis="saintKittsAndNevis",e.SouthKorea="southKorea",e.Kuwait="kuwait",e.Lao="lao",e.Lebanon="lebanon",e.Liberia="liberia",e.Libya="libya",e.SaintLucia="saintLucia",e.Liechtenstein="liechtenstein",e.SriLanka="sriLanka",e.Lesotho="lesotho",e.Lithuania="lithuania",e.Luxembourg="luxembourg",e.Latvia="latvia",e.Macao="macao",e.FrenchSaintMartin="frenchSaintMartin",e.Morocco="morocco",e.Monaco="monaco",e.Moldova="moldova",e.Madagascar="madagascar",e.Maldives="maldives",e.Mexico="mexico",e.MarshallIslands="marshallIslands",e.NorthMacedonia="northMacedonia",e.Mali="mali",e.Malta="malta",e.Myanmar="myanmar",e.Montenegro="montenegro",e.Mongolia="mongolia",e.NorthernMarianaIslands="northernMarianaIslands",e.Mozambique="mozambique",e.Mauritania="mauritania",e.Montserrat="montserrat",e.Martinique="martinique",e.Mauritius="mauritius",e.Malawi="malawi",e.Malaysia="malaysia",e.Mayotte="mayotte",e.Namibia="namibia",e.NewCaledonia="newCaledonia",e.Niger="niger",e.NorfolkIsland="norfolkIsland",e.Nigeria="nigeria",e.Nicaragua="nicaragua",e.Niue="niue",e.Netherlands="netherlands",e.Norway="norway",e.Nepal="nepal",e.Nauru="nauru",e.NewZealand="newZealand",e.Oman="oman",e.Pakistan="pakistan",e.Panama="panama",e.Pitcairn="pitcairn",e.Peru="peru",e.Philippines="philippines",e.Palau="palau",e.PapuaNewGuinea="papuaNewGuinea",e.Poland="poland",e.PuertoRico="puertoRico",e.NorthKorea="northKorea",e.Portugal="portugal",e.Paraguay="paraguay",e.Palestine="palestine",e.FrenchPolynesia="frenchPolynesia",e.Qatar="qatar",e.Reunion="reunion",e.Romania="romania",e.Russia="russia",e.Rwanda="rwanda",e.SaudiArabia="saudiArabia",e.Sudan="sudan",e.Senegal="senegal",e.Singapore="singapore",e.SouthGeorgiaAndTheSouthSandwichIslands="southGeorgiaAndTheSouthSandwichIslands",e.SaintHelena="saintHelena",e.SvalbardAndJanMayen="svalbardAndJanMayen",e.SolomonIslands="solomonIslands",e.SierraLeone="sierraLeone",e.ElSalvador="elSalvador",e.SanMarino="sanMarino",e.Somalia="somalia",e.SaintPierreAndMiquelon="saintPierreAndMiquelon",e.Serbia="serbia",e.SouthSudan="southSudan",e.SaoTomeAndPrincipe="saoTomeAndPrincipe",e.Suriname="suriname",e.Slovakia="slovakia",e.Slovenia="slovenia",e.Sweden="sweden",e.Eswatini="eswatini",e.DutchSintMaarten="dutchSintMaarten",e.Seychelles="seychelles",e.Syria="syria",e.TurksAndCaicosIslands="turksAndCaicosIslands",e.Chad="chad",e.Togo="togo",e.Thailand="thailand",e.Tajikistan="tajikistan",e.Tokelau="tokelau",e.Turkmenistan="turkmenistan",e.TimorLeste="timorLeste",e.Tonga="tonga",e.TrinidadAndTobago="trinidadAndTobago",e.Tunisia="tunisia",e.Turkey="turkey",e.Tuvalu="tuvalu",e.Taiwan="taiwan",e.Tanzania="tanzania",e.Uganda="uganda",e.Ukraine="ukraine",e.UsMinorOutlyingIslands="usMinorOutlyingIslands",e.Uruguay="uruguay",e.Us="us",e.Uzbekistan="uzbekistan",e.HolySee="holySee",e.SaintVincentAndTheGrenadines="saintVincentAndTheGrenadines",e.Venezuela="venezuela",e.BritishVirginIslands="britishVirginIslands",e.UsVirginIslands="usVirginIslands",e.Vietnam="vietnam",e.Vanuatu="vanuatu",e.WallisAndFutuna="wallisAndFutuna",e.Samoa="samoa",e.Kosovo="kosovo",e.Yemen="yemen",e.SouthAfrica="southAfrica",e.Zambia="zambia",e.Zimbabwe="zimbabwe",e))(ta||{}),G=class extends S{constructor(e){super("any"),this.documentType="regionSpecific",this.subtype=e}get region(){return this._region}toJSONObject(){return{region:this.region,documentType:this.documentType,documentSubtype:this.subtype}}},K=class extends S{constructor(e){super(e),this.documentType="residencePermit"}get region(){return this._region}toJSONObject(){return{region:this.region,documentType:this.documentType}}},Z=class extends S{constructor(e){super(e),this.documentType="visaIcao"}get region(){return this._region}toJSONObject(){return{region:this.region,documentType:this.documentType}}},Pe=class e{get dateOfBirth(){return m.fromJSON(this.json.dateOfBirth)}get dateOfExpiry(){return m.fromJSON(this.json.dateOfExpiry)}get documentNumber(){return this.json.documentNumber}get firstName(){return this.json.firstName}get fullName(){return this.json.fullName}get lastName(){return this.json.lastName}get sex(){return this.json.sex}get nationality(){return this.json.nationality}get address(){return this.json.address}get documentAdditionalNumber(){return this.json.documentAdditionalNumber}get dateOfIssue(){return m.fromJSON(this.json.dateOfIssue)}get issuingJurisdiction(){return this.json.issuingJurisdiction}get issuingJurisdictionIso(){return this.json.issuingJurisdictionIso}static fromJSON(t){let a=new e;return a.json=t,a}toJSONObject(){var e,t,a,i,r,n;return{dateOfBirth:null!=(t=null==(e=this.dateOfBirth)?void 0:e.toJSONObject())?t:null,dateOfExpiry:null!=(i=null==(a=this.dateOfExpiry)?void 0:a.toJSONObject())?i:null,dateOfIssue:null!=(n=null==(r=this.dateOfIssue)?void 0:r.toJSONObject())?n:null,documentNumber:this.documentNumber,documentAdditionalNumber:this.documentAdditionalNumber,firstName:this.firstName,fullName:this.fullName,lastName:this.lastName,sex:this.sex,nationality:this.nationality,address:this.address,issuingJurisdiction:this.issuingJurisdiction,issuingJurisdictionIso:this.issuingJurisdictionIso}}},$=class extends S{constructor(e){super(e),this.documentType="visaLetter"}get region(){return this._region}toJSONObject(){return{region:this.region,documentType:this.documentType}}},se=class e{get firstName(){return this.json.firstName}get lastName(){return this.json.lastName}get fullName(){return this.json.fullName}get sexType(){return this.json.sex}get sex(){return this.json.sex}get dateOfBirth(){return m.fromJSON(this.json.dateOfBirth)}get age(){return this.json.age}get nationality(){return this.json.nationality}get nationalityISO(){return this.json.nationalityISO}get address(){return this.json.address}get document(){if(null!=this.json.documentType){let e=this.json.documentType,t=this.json.documentSubtype,a=this.issuingCountry;switch(e){case"passport":return new H(a);case"idCard":return new W(a);case"driverLicense":return new V(a);case"visaIcao":return new Z(a);case"residencePermit":return new K(a);case"healthInsuranceCard":return new U(a);case"regionSpecific":return new G(t);case"visaLetter":return new $(a)}}return null}get issuingCountryIso(){return this.json.issuingCountryIso}get issuingCountry(){return this.json.issuingCountry}get documentNumber(){return this.json.documentNumber}get documentAdditionalNumber(){return this.json.documentAdditionalNumber}get dateOfExpiry(){return m.fromJSON(this.json.dateOfExpiry)}get isExpired(){return this.json.isExpired}get isCitizenPassport(){if("boolean"!=typeof this.json.isCitizenPassport)throw new Error("Missing or invalid property isCitizenPassport in json data");return this.json.isCitizenPassport}get dateOfIssue(){return m.fromJSON(this.json.dateOfIssue)}get usRealIdStatus(){var e,t;if(null!=(null==(e=this.json.vizResult)?void 0:e.usRealIdStatus)&&"notAvailable"!==this.json.vizResult.usRealIdStatus)return this.json.vizResult.usRealIdStatus;switch(null==(t=this.barcode)?void 0:t.isRealId){case!0:return"realIdCompliant";case!1:return"notRealIdCompliant";default:return"notAvailable"}}get isCapturingComplete(){return this.json.isCapturingComplete}get barcode(){var e;return null==this._barcodeResult&&null!=this.json.barcodeResult&&(this._barcodeResult=we.fromJSON(this.json.barcodeResult)),null!=(e=this._barcodeResult)?e:null}get mrzResult(){var e;return null==this._mrzResult&&null!=this.json.mrzResult&&(this._mrzResult=Oe.fromJSON(this.json.mrzResult)),null!=(e=this._mrzResult)?e:null}get vizResult(){var e;return null==this._vizResult&&null!=this.json.vizResult&&(this._vizResult=xe.fromJSON(this.json.vizResult)),null!=(e=this._vizResult)?e:null}get mobileDocumentOCRResult(){var e;return null==this._mobileDocumentOCRResult&&null!=this.json.mobileDocumentOcrResult&&(this._mobileDocumentOCRResult=Pe.fromJSON(this.json.mobileDocumentOcrResult)),null!=(e=this._mobileDocumentOCRResult)?e:null}get verificationResult(){var e;return null==this._verificationResult&&null!=this.json.verificationResult&&(this._verificationResult=ne.fromJSON(this.json.verificationResult)),null!=(e=this._verificationResult)?e:new ne}get images(){return Ae.fromJSON(this.json.imageInfo)}get anonymizedFields(){var e;return(null!=(e=this.json.anonymizedFields)?e:[]).map((e=>e))}get rejectionDiagnosticJSON(){return this.json.rejectionDiagnosticJSON}isAnonymized(e){return-1!==this.anonymizedFields.indexOf(e)}get barcodeResultsJSON(){var e,t;return{barcodeResult:null!=(t=null==(e=this.barcode)?void 0:e.toJSONObject())?t:null}}get mrzResultsJSON(){return{mrzResult:this.mrzResult?this.mrzResult.toJSONObject():null}}static fromJSON(t){let a=new e;return a.json=t,a}isIdCard(){var e,t;return null!=(t=null==(e=this.document)?void 0:e.isIdCard())&&t}isDriverLicense(){var e,t;return null!=(t=null==(e=this.document)?void 0:e.isDriverLicense())&&t}isPassport(){var e,t;return null!=(t=null==(e=this.document)?void 0:e.isPassport())&&t}isVisaIcao(){var e,t;return null!=(t=null==(e=this.document)?void 0:e.isVisaIcao())&&t}isVisaLetter(){var e,t;return null!=(t=null==(e=this.document)?void 0:e.isVisaLetter())&&t}isRegionSpecific(e){return!!this.document&&(this.document.isRegionSpecific()&&this.document.subtype===e)}isResidencePermit(){var e,t;return null!=(t=null==(e=this.document)?void 0:e.isResidencePermit())&&t}isHealthInsuranceCard(){var e,t;return null!=(t=null==(e=this.document)?void 0:e.isHealthInsuranceCard())&&t}toJSONObject(){var e,t,a,i,r,n,s,o,l,u,d,c,h,p,m;return{firstName:this.firstName,lastName:this.lastName,fullName:this.fullName,sex:this.sex,nationality:this.nationality,nationalityISO:this.nationalityISO,address:this.address,issuingCountry:this.issuingCountry,issuingCountryIso:this.issuingCountryIso,documentNumber:this.documentNumber,documentAdditionalNumber:this.documentAdditionalNumber,dateOfBirth:null!=(t=null==(e=this.dateOfBirth)?void 0:e.toJSONObject())?t:null,age:this.age,dateOfExpiry:null!=(i=null==(a=this.dateOfExpiry)?void 0:a.toJSONObject())?i:null,isExpired:this.isExpired,dateOfIssue:null!=(n=null==(r=this.dateOfIssue)?void 0:r.toJSONObject())?n:null,documentType:null!=(o=null==(s=this.document)?void 0:s.documentType)?o:null,documentSubtype:null==(null==(l=this.document)?void 0:l.isRegionSpecific())?null:this.document.subtype,imageInfo:this.images.toJSONObject(),verificationResult:null!=(d=null==(u=this.verificationResult)?void 0:u.toJSONObject())?d:null,vizResult:null!=(h=null==(c=this.vizResult)?void 0:c.toJSONObject())?h:null,mobileDocumentOcrResult:null!=(m=null==(p=this.mobileDocumentOCRResult)?void 0:p.toJSONObject())?m:null,idVerificationDataComparisonAvailable:this.json.idVerificationDataComparisonAvailable,usRealIdStatus:this.usRealIdStatus,isCapturingComplete:this.isCapturingComplete,isCitizenPassport:this.isCitizenPassport,anonymizedFields:this.anonymizedFields,rejectionDiagnosticJSON:this.rejectionDiagnosticJSON,...this.barcodeResultsJSON,...this.mrzResultsJSON}}},Y={IdCapture:{RecommendedCameraSettings:CameraSettings.fromJSON({zoomFactor:1,zoomGestureZoomFactor:2,focusGestureStrategy:FocusGestureStrategy.ManualUntilCapture,preferredResolution:VideoResolution.FullHD}),IdCaptureOverlayDefaults:{defaultCapturedBrush:new Brush(Color.fromJSON("#00000000"),Color.fromJSON("#FFFFFFFF"),3),defaultLocalizedBrush:new Brush(Color.fromJSON("#FFFFFF80"),Color.fromJSON("#FFFFFF00"),0),defaultRejectedBrush:new Brush(Color.fromJSON("#00000000"),Color.fromJSON("#FFFFFFFF"),3)}}},X=class e{get location(){return this._location}static fromJSON(t){let a=new e;return null!=t.location&&(a._location=Quadrilateral.fromJSON(t.location)),a}toJSONObject(){return{location:this.location.toJSONObject()}}};function tr(e){return new Quadrilateral(new Point(e.upperLeft.x,e.upperLeft.y),new Point(e.upperRight.x,e.upperRight.y),new Point(e.lowerRight.x,e.lowerRight.y),new Point(e.lowerLeft.x,e.lowerLeft.y))}function ee(e){return null==e?null:"object"==typeof e.latin&&e.latin.value.length>0?e.latin:"object"==typeof e.arabic&&e.arabic.value.length>0?e.arabic:"object"==typeof e.cyrillic&&e.cyrillic.value.length>0?e.cyrillic:"object"==typeof e.greek&&e.greek.value.length>0?e.greek:null}function ot(e){return null!=e.location&&"number"==typeof e.location.x}function rr(e){return"object"==typeof e&&null!==e}function Te(e){return!!rr(e)&&(Object.prototype.hasOwnProperty.call(e,"filledByDomainKnowledge")&&Object.prototype.hasOwnProperty.call(e,"originalString"))}function ut(e){return!!rr(e)&&(Object.prototype.hasOwnProperty.call(e,"latin")&&Object.prototype.hasOwnProperty.call(e,"arabic")&&Object.prototype.hasOwnProperty.call(e,"cyrillic")&&Object.prototype.hasOwnProperty.call(e,"greek"))}function oe(e){if(null!=e&&Te(e)&&!0===e.successfullyParsed){if(null==e.year)return null;let t=e;return{day:t.day,month:t.month,year:t.year}}return null}function lt(e){let{x:t,y:a,width:i,height:r}=e;return new Quadrilateral(new Point(t,a),new Point(t+i,a),new Point(t+i,a+r),new Point(t,a+r)).toJSONObject()}var oa={"australian-capital-territory":"Australian Capital Territory","new-south-wales":"New South Wales","northern-territory":"Northern Territory",queensland:"Queensland","south-australia":"South Australia",tasmania:"Tasmania","western-australia":"Western Australia",victoria:"Victoria",alberta:"Alberta","british-columbia":"British Columbia",manitoba:"Manitoba","new-brunswick":"New Brunswick","newfoundland-and-labrador":"Newfoundland and Labrador","northwest-territories":"Northwest Territories","nova-scotia":"Nova Scotia",nunavut:"Nunavut","prince-edward-island":"Prince Edward Island",quebec:"Quebec",saskatchewan:"Saskatchewan","andhra-pradesh":"Andhra Pradesh",gujarat:"Gujarat",haryana:"Haryana",karnataka:"Karnataka",kerala:"Kerala","madhya-pradesh":"Madhya Pradesh",maharashtra:"Maharashtra",punjab:"Punjab","tamil-nadu":"Tamil Nadu",telangana:"Telangana",aguascalientes:"Aguascalientes","baja-california":"Baja California","baja-california-sur":"Baja California Sur",campeche:"Campeche",chiapas:"Chiapas",chihuahua:"Chihuahua","ciudad-de-mexico":"Mexico City",coahuila:"Coahuila",colima:"Colima",durango:"Durango",guanajuato:"Guanajuato",guerrero:"Guerrero","guerrero-acapulco-de-juarez":"Acapulco de Juárez, Guerrero","guerrero-cocula":"Cocula, Guerrero","guerrero-juchitan":"Juchitán, Guerrero","guerrero-tepecoacuilco":"Tepecoacuilco de Trujano, Guerrero","guerrero-tlacoapa":"Tlacoapa, Guerrero",hidalgo:"Hidalgo",jalisco:"Jalisco",mexico:"México",michoacan:"Michoacán",morelos:"Morelos",nayarit:"Nayarit","nuevo-leon":"Nuevo León",oaxaca:"Oaxaca",puebla:"Puebla","quintana-roo":"Quintana Roo","quintana-roo-benito-juarez":"Benito Juárez, Quintana Roo","quintana-roo-solidaridad":"Solidaridad, Quintana Roo","quintana-roo-cozumel":"Cozumel, Quintana Roo",queretaro:"Querétaro","san-luis-potosi":"San Luis Potosí",sinaloa:"Sinaloa",sonora:"Sonora",tabasco:"Tabasco",tamaulipas:"Tamaulipas",tlaxcala:"Tlaxcala",veracruz:"Veracruz",yucatan:"Yucatan",zacatecas:"Zacatecas","khyber-pakhtunkhwa":"Khyber Pakhtunkhwa",alabama:"Alabama",alaska:"Alaska",arizona:"Arizona",arkansas:"Arkansas",california:"California",colorado:"Colorado",connecticut:"Connecticut",delaware:"Delaware","district-of-columbia":"District of Columbia",florida:"Florida",georgia:"Georgia",hawaii:"Hawaii",idaho:"Idaho",illinois:"Illinois",indiana:"Indiana",iowa:"Iowa",kansas:"Kansas",kentucky:"Kentucky",louisiana:"Louisiana",maine:"Maine",maryland:"Maryland",massachusetts:"Massachusetts",michigan:"Michigan",minnesota:"Minnesota",mississippi:"Mississippi",missouri:"Missouri",montana:"Montana",nebraska:"Nebraska",nevada:"Nevada","new-hampshire":"New Hampshire","new-jersey":"New Jersey","new-mexico":"New Mexico","new-york":"New York","new-york-city":"New York City","north-carolina":"North Carolina","north-dakota":"North Dakota",ohio:"Ohio",oklahoma:"Oklahoma",ontario:"Ontario",oregon:"Oregon",pennsylvania:"Pennsylvania","rhode-island":"Rhode Island","south-carolina":"South Carolina","south-dakota":"South Dakota",tennessee:"Tennessee",texas:"Texas",utah:"Utah",vermont:"Vermont",virginia:"Virginia",washington:"Washington","west-virginia":"West Virginia",wisconsin:"Wisconsin",wyoming:"Wyoming",yukon:"Yukon",ceara:"Ceará","distrito-federal":"Federal District",goias:"Goiás",maranhao:"Maranhão","mato-grosso":"Mato Grosso","minas-gerais":"Minas Gerais",para:"Pará",parana:"Paraná",pernambuco:"Pernambuco","rio-de-janeiro":"Rio de Janeiro","rio-grande-do-sul":"Rio Grand do Sul","santa-catarina":"Santa Catarina","sao-paolo":"Sao Paolo",sergipe:"Sergipe",alagoas:"Alagoas",bangsamoro:"Bangsamoro"};function ar(e){var t;return null==e?null:null!=(t=oa[e])?t:null}var Me=class e{constructor(e){this.workerCall=e}static create(t){return new e(t)}async createDrivingLicenseDetailsFromCentaurusData(e,t,a){let i=await this.workerCall("idCaptureDrivingLicenseDetailsCreateWithCentaurusData",{details:{vehicleClass:e,restrictions:t,endorsements:a}});return _.fromJSON(i.result)}},ir={ABW:"aruba",AFG:"afghanistan",AGO:"angola",AIA:"anguilla",ALA:"alandIslands",ALB:"albania",AND:"andorra",ARE:"uae",ARG:"argentina",ARM:"armenia",ASM:"americanSamoa",ATA:"antarctica",ATF:"frenchSouthernTerritories",ATG:"antiguaAndBarbuda",AUS:"australia",AUT:"austria",AZE:"azerbaijan",BDI:"burundi",BEL:"belgium",BEN:"benin",BES:"bonaireSintEustatiusAndSaba",BFA:"burkinaFaso",BGD:"bangladesh",BGR:"bulgaria",BHR:"bahrain",BHS:"bahamas",BIH:"bosniaHerzegovina",BLM:"saintBarthelemy",BLR:"belarus",BLZ:"belize",BMU:"bermuda",BOL:"bolivia",BRA:"brazil",BRB:"barbados",BRN:"bruneiDarussalam",BTN:"bhutan",BVT:"bouvetIsland",BWA:"botswana",CAF:"car",CAN:"canada",CCK:"cocosIslands",CHE:"switzerland",CHL:"chile",CHN:"china",CIV:"coteIvoire",CMR:"cameroon",COD:"democraticRepublicOfCongo",COG:"congo",COK:"cookIslands",COL:"colombia",COM:"comoros",CPV:"caboVerde",CRI:"costaRica",CUB:"cuba",CUW:"curacao",CXR:"christmasIsland",CYM:"caymanIslands",CYP:"cyprus",CZE:"czechia",DEU:"germany",DJI:"djibouti",DMA:"dominica",DNK:"denmark",DOM:"dominicanRepublic",DZA:"algeria",ECU:"ecuador",EGY:"egypt",ERI:"eritrea",ESH:"westernSahara",ESP:"spain",EST:"estonia",ETH:"ethiopia",FIN:"finland",FJI:"fiji",FLK:"falklandIslands",FRA:"france",FRO:"faroeIslands",FSM:"micronesia",GAB:"gabon",GBR:"uk",GEO:"georgia",GGY:"guernsey",GHA:"ghana",GIB:"gibraltar",GIN:"guinea",GLP:"guadeloupe",GMB:"gambia",GNB:"guineaBissau",GNQ:"equatorialGuinea",GRC:"greece",GRD:"grenada",GRL:"greenland",GTM:"guatemala",GUF:"frenchGuiana",GUM:"guam",GUY:"guyana",HKG:"hongKong",HMD:"heardIslandAndMcDonaldIslands",HND:"honduras",HRV:"croatia",HTI:"haiti",HUN:"hungary",IDN:"indonesia",IMN:"isleOfMan",IND:"india",IOT:"britishIndianOceanTerritory",IRL:"ireland",IRN:"iran",IRQ:"iraq",ISL:"iceland",ISR:"israel",ITA:"italy",JAM:"jamaica",JEY:"jersey",JOR:"jordan",JPN:"japan",KAZ:"kazakhstan",KEN:"kenya",KGZ:"kyrgyzstan",KHM:"cambodia",KIR:"kiribati",KNA:"saintKittsAndNevis",KOR:"southKorea",KWT:"kuwait",LAO:"lao",LBN:"lebanon",LBR:"liberia",LBY:"libya",LCA:"saintLucia",LIE:"liechtenstein",LKA:"sriLanka",LSO:"lesotho",LTU:"lithuania",LUX:"luxembourg",LVA:"latvia",MAC:"macao",MAF:"frenchSaintMartin",MAR:"morocco",MCO:"monaco",MDA:"moldova",MDG:"madagascar",MDV:"maldives",MEX:"mexico",MHL:"marshallIslands",MKD:"northMacedonia",MLI:"mali",MLT:"malta",MMR:"myanmar",MNE:"montenegro",MNG:"mongolia",MNP:"northernMarianaIslands",MOZ:"mozambique",MRT:"mauritania",MSR:"montserrat",MTQ:"martinique",MUS:"mauritius",MWI:"malawi",MYS:"malaysia",MYT:"mayotte",NAM:"namibia",NCL:"newCaledonia",NER:"niger",NFK:"norfolkIsland",NGA:"nigeria",NIC:"nicaragua",NIU:"niue",NLD:"netherlands",NOR:"norway",NPL:"nepal",NRU:"nauru",NZL:"newZealand",OMN:"oman",PAK:"pakistan",PAN:"panama",PCN:"pitcairn",PER:"peru",PHL:"philippines",PLW:"palau",PNG:"papuaNewGuinea",POL:"poland",PRI:"puertoRico",PRK:"northKorea",PRT:"portugal",PRY:"paraguay",PSE:"palestine",PYF:"frenchPolynesia",QAT:"qatar",REU:"reunion",ROU:"romania",RUS:"russia",RWA:"rwanda",SAU:"saudiArabia",SDN:"sudan",SEN:"senegal",SGP:"singapore",SGS:"southGeorgiaAndTheSouthSandwichIslands",SHN:"saintHelena",SJM:"svalbardAndJanMayen",SLB:"solomonIslands",SLE:"sierraLeone",SLV:"elSalvador",SMR:"sanMarino",SOM:"somalia",SPM:"saintPierreAndMiquelon",SRB:"serbia",SSD:"southSudan",STP:"saoTomeAndPrincipe",SUR:"suriname",SVK:"slovakia",SVN:"slovenia",SWE:"sweden",SWZ:"eswatini",SXM:"dutchSintMaarten",SYC:"seychelles",SYR:"syria",TCA:"turksAndCaicosIslands",TCD:"chad",TGO:"togo",THA:"thailand",TJK:"tajikistan",TKL:"tokelau",TKM:"turkmenistan",TLS:"timorLeste",TON:"tonga",TTO:"trinidadAndTobago",TUN:"tunisia",TUR:"turkey",TUV:"tuvalu",TWN:"taiwan",TZA:"tanzania",UGA:"uganda",UKR:"ukraine",UMI:"usMinorOutlyingIslands",URY:"uruguay",USA:"us",UZB:"uzbekistan",VAT:"holySee",VCT:"saintVincentAndTheGrenadines",VEN:"venezuela",VGB:"britishVirginIslands",VIR:"usVirginIslands",VNM:"vietnam",VUT:"vanuatu",WLF:"wallisAndFutuna",WSM:"samoa",XKX:"kosovo",YEM:"yemen",ZAF:"southAfrica",ZMB:"zambia",ZWE:"zimbabwe"},ua=(e=>(e.UsBorderCrossingCard="usBorderCrossingCard",e.ChinaExitEntryPermit="chinaExitEntryPermit",e.UsGlobalEntryCard="usGlobalEntryCard",e.ChinaMainlandTravelPermitTaiwan="chinaMainlandTravelPermitTaiwan",e.UsNexusCard="usNexusCard",e.ChinaMainlandTravelPermitHongKongMacau="chinaMainlandTravelPermitHongKongMacau",e.ApecBusinessTravelCard="apecBusinessTravelCard",e.PakistanAfghanCitizenCard="pakistanAfghanCitizenCard",e.SingaporeFinCard="singaporeFinCard",e.MalaysiaIkad="malaysiaIkad",e.MalaysiaMykad="malaysiaMykad",e.MalaysiaMypr="malaysiaMypr",e.MexicoConsularVoterId="mexicoConsularVoterId",e.GermanyEid="germanyEid",e.UsCommonAccessCard="usCommonAccessCard",e.PhilippinesMultipurposeId="philippinesMultipurposeId",e.MalaysiaMykas="malaysiaMykas",e.MalaysiaMykid="malaysiaMykid",e.MalaysiaMytentera="malaysiaMytentera",e.MexicoProfessionalId="mexicoProfessionalId",e.MalaysiaRefugeeId="malaysiaRefugeeId",e.CanadaTribalId="canadaTribalId",e.UsUniformedServicesId="usUniformedServicesId",e.UsVeteranId="usVeteranId",e.PhilippinesWorkPermit="philippinesWorkPermit",e.SingaporeWorkPermit="singaporeWorkPermit",e.UsWorkPermit="usWorkPermit",e.PhilippinesSocialSecurityCard="philippinesSocialSecurityCard",e.SwedenSocialSecurityCard="swedenSocialSecurityCard",e.CanadaSocialSecurityCard="canadaSocialSecurityCard",e.UsSocialSecurityCard="usSocialSecurityCard",e.BelgiumMinorsId="belgiumMinorsId",e.ColombiaMinorsId="colombiaMinorsId",e.PeruMinorsId="peruMinorsId",e.BoliviaMinorsId="boliviaMinorsId",e.HungaryAddressCard="hungaryAddressCard",e.UkAsylumRequest="ukAsylumRequest",e.CanadaCitizenshipCertificate="canadaCitizenshipCertificate",e.SingaporeEmploymentPass="singaporeEmploymentPass",e.CanadaMinorsPublicServicesCard="canadaMinorsPublicServicesCard",e.MalaysiaMypolis="malaysiaMypolis",e.PhilippinesNbiClearance="philippinesNbiClearance",e.IndiaPanCard="indiaPanCard",e.PhilippinesPostalId="philippinesPostalId",e.PakistanProofOfRegistration="pakistanProofOfRegistration",e.SingaporeSPass="singaporeSPass",e.SwedenSisId="swedenSisId",e.ColombiaTemporaryProtectionPermit="colombiaTemporaryProtectionPermit",e.UsTwicCard="usTwicCard",e.UsWeaponPermit="usWeaponPermit",e.CanadaWeaponPermit="canadaWeaponPermit",e.IrelandPublicServicesCard="irelandPublicServicesCard",e.CanadaPublicServicesCard="canadaPublicServicesCard",e.PakistanConsularId="pakistanConsularId",e.GuatemalaConsularId="guatemalaConsularId",e.MexicoConsularId="mexicoConsularId",e.PhilippinesTaxId="philippinesTaxId",e.MexicoTaxId="mexicoTaxId",e.ChinaOneWayPermit="chinaOneWayPermit",e.UsMedicalMarijuanaCard="usMedicalMarijuanaCard",e.UsMunicipalId="usMunicipalId",e.AustraliaAsicCard="australiaAsicCard",e.UaeVehicleRegistrationCard="uaeVehicleRegistrationCard",e.UaeEsaadCard="uaeEsaadCard",e.UkMilitaryId="ukMilitaryId",e))(ua||{}),ct={additionalAddressInformation:"additional address information",additionalNameInformation:"additional name information",address:"address",bloodType:"blood type",dateOfBirth:"date of birth",dateOfExpiry:"date of expiry",dateOfIssue:"date of issue",documentAdditionalNumber:"document additional number",documentNumber:"document number",employer:"employer",fathersName:"fathers name",firstName:"first name",fullName:"full name",issuingAuthority:"issuing authority",lastName:"last name",maritalStatus:"marital status",mothersName:"mothers name",nationality:"nationality",personalIdNumber:"personal id number",placeOfBirth:"place of birth",profession:"profession",race:"race",religion:"religion",residentialStatus:"residential status",sex:"sex"},ca=["field-identification-failed","invalid-characters-found","mandatory-field-missing","detection-failed","image-return-failed","image-preprocessing-failed","stability-test-failed","not-scanned"],ke=class{constructor(e){this.workerCallProvider=e}async processResult(e,t,a){return!this.hasFrontVIZResult(e)||ca.includes(t.processingStatus)?null:{nationalityISO:null,mrzResult:null,barcodeResult:null,mobileDocumentOcrResult:null,verificationResult:null,vizResult:await this.getVizResult(e,t,a),imageInfo:this.getImageData(e),rejectionDiagnosticJSON:null}}isBackSideCaptureSupported(e,t){let{scanningStatus:a}=e;return"side-scanned"===a||t.subResults.length>1}async getVizResult(e,t,a){var i,r,n,s;let o={...await this.extractVizData(t.documentClassInfo,e,a),usRealIdStatus:this.getRealIdStatus(t),capturedSides:"frontOnly",isBackSideCaptureSupported:this.isBackSideCaptureSupported(a,e),frontFieldLocations:this.getFieldLocations(null!=(r=null==(i=e.subResults[0])?void 0:i.viz)?r:{}),backFieldLocations:this.getFieldLocations(null!=(s=null==(n=e.subResults[1])?void 0:n.viz)?s:{}),location:this.getLocation(t),visaDetails:null};if(this.adjustResultForSpecialCases(e,o),"document-scanned"===a.scanningStatus&&this.hasFrontAndBackVIZResult(e)){o.capturedSides="frontAndBack";let t=["address","dateOfBirth","dateOfExpiry","dateOfIssue","documentNumber","firstName","fullName","lastName","nationality","sex","additionalAddressInformation","additionalNameInformation","documentAdditionalNumber","employer","issuingAuthority","maritalStatus","personalIdNumber","placeOfBirth","profession","race","religion","residentialStatus","mothersName","fathersName"],a=e.subResults[1].viz;for(let e of t){let t=null==o[e]||""===o[e],i=null==a?void 0:a[e];t&&null!=i&&this.handleEmptyFrontValue(o,e,i)}}return o}handleEmptyFrontValue(e,t,a){if(Te(a)){let i=oe(a);i&&(e[t]=i)}else if(ut(a)){let i=ee(a);null!=i&&i.value&&i.value.length>0&&(e[t]=i.value)}}async extractVizData(e,t,a){var i,r,n,s,o,l,u,d,c,h,p,m;let g=t.subResults[0].viz;function f(e){var t,a;return null==e?null:null!=(a=null==(t=ee(e))?void 0:t.value)?a:null}let y=null!=(r=f(null==(i=t.driverLicenseDetailedInfo)?void 0:i.vehicleClass))?r:"",C=null!=(s=f(null==(n=t.driverLicenseDetailedInfo)?void 0:n.restrictions))?s:"",S=null!=(l=f(null==(o=t.driverLicenseDetailedInfo)?void 0:o.endorsements))?l:"",b=this.workerCallProvider(),v=null;b&&(y.length>0||C.length>0||S.length>0)&&(v=await Me.create(b).createDrivingLicenseDetailsFromCentaurusData(y,C,S));let[I,w]=null!=(u=da(e.type,e.country))?u:[null,null],A="voter-id"===e.type;return{address:f(g.address),additionalAddressInformation:f(g.additionalAddressInformation),additionalNameInformation:g.additionalNameInformation?f(g.additionalNameInformation):f(t.additionalNameInformation),bloodType:f(g.bloodType),dateOfBirth:oe(g.dateOfBirth),dateOfExpiry:oe(g.dateOfExpiry),dateOfIssue:oe(g.dateOfIssue),documentAdditionalNumber:f(g.documentAdditionalNumber),documentNumber:f(g.documentNumber),documentType:I,documentSubtype:w,drivingLicenseDetails:null!=(d=null==v?void 0:v.toJSONObject())?d:null,employer:f(g.employer),fathersName:f(g.fathersName),firstName:f(g.firstName),fullName:null!=(c=f(g.fullName))?c:"",issuingAuthority:f(g.issuingAuthority),issuingCountryIso:null!=(h=e.isoAlpha3CountryCode)?h:null,issuingCountry:null!=(m=ir[null!=(p=e.isoAlpha3CountryCode)?p:""])?m:null,issuingJurisdictionIso:null,lastName:f(g.lastName),maritalStatus:f(g.maritalStatus),mothersName:f(g.mothersName),mrzDetected:a.mrzExtracted,isVoterCard:A,nationality:f(g.nationality),passportNumber:null,personalIdNumber:f(g.personalIdNumber),placeOfBirth:f(g.placeOfBirth),profession:f(g.profession),race:f(g.race),religion:f(g.religion),residentialStatus:f(g.residentialStatus),sex:f(g.sex),sexOriginal:f(g.sex),issuingJurisdiction:ar(e.region),sponsor:f(g.sponsor),vehicleOwner:f(g.vehicleOwner),visaNumber:null}}adjustResultForSpecialCases(e,t){var a,i,r;let n=e.documentClassInfo;if("germany"===n.country&&"id"===n.type){let n=e.lastName?e.lastName:null==(a=e.subResults[0].viz)?void 0:a.lastName;t.lastName=null!=(r=null==(i=ee(n))?void 0:i.value)?r:null}}getFieldLocations(e){let t={};for(let[a,i]of Object.entries(e)){let e=a in ct?ct[a]:a;if("object"==typeof i&&null!=i)if(Te(i)){let a=ee(i.originalString);a&&ot(a)&&(t[e]=lt(a.location))}else if(ut(i)){let a=ee(i);null!=a&&ot(a)&&(t[e]=lt(a.location))}}return t}getLocation(e){return"failed"!==e.documentDetectionStatus&&e.documentLocation?tr(e.documentLocation).toJSONObject():null}getImageBase64String(e){if(null==e)return null;let t=document.createElement("canvas");t.width=e.width,t.height=e.height;let a=t.getContext("2d");return a?(a.putImageData(e,0,0),t.toDataURL("image/jpeg",1).split(",")[1]):null}getImageData(e){var t;let[a,i]=e.subResults,r={face:this.getImageBase64String(null==(t=null==a?void 0:a.faceImage)?void 0:t.image)};return this.hasFrontAndBackVIZResult(e)?{front:{...r,croppedDocument:this.getImageBase64String(a.documentImage),frame:null},back:{face:null,croppedDocument:this.getImageBase64String(null==i?void 0:i.documentImage),frame:null}}:{front:{...r,croppedDocument:this.getImageBase64String(null==a?void 0:a.documentImage),frame:null},back:{face:null,croppedDocument:null,frame:null}}}getRealIdStatus(e){switch(e.realIDDetectionStatus){case"not-available":default:return"notAvailable";case"not-detected":return"notRealIdCompliant";case"detected":return"realIdCompliant"}}hasFrontVIZResult(e){return null!=e.subResults[0].viz}hasFrontAndBackVIZResult(e){return e.subResults.length>1}};function da(e,t){if(null==e)return null;switch(e){case"id":case"voter-id":case"passport-card":case"proof-of-registration":case"non-voter-id":case"proof-of-age-card":return["idCard",null];case"dl":case"dl-public-services-card":case"professional-dl":case"driver-card":case"driving-privilege-card":case"driver-qualification-card":case"provisional-dl":return["driverLicense",null];case"passport":case"alien-passport":case"consular-passport":case"minors-passport":case"refugee-passport":case"emergency-passport":case"temporary-passport":return["passport",null];case"residence-permit":case"resident-id":case"temporary-residence-permit":case"alien-id":case"special-id":case"green-card":case"registration-certificate":return["residencePermit",null];case"visa":case"immigrant-visa":return["visaIcao",null];case"health-insurance-card":case"interim-health-insurance-card":case"reciprocal-health-insurance-card":return["healthInsuranceCard",null];case"consular-id":return ma(t);case"employment-pass":return["regionSpecific","singaporeEmploymentPass"];case"fin-card":return["regionSpecific","singaporeFinCard"];case"multipurpose-id":return["regionSpecific","philippinesMultipurposeId"];case"mykad":return["regionSpecific","malaysiaMykad"];case"mykid":return["regionSpecific","malaysiaMykid"];case"mypr":return["regionSpecific","malaysiaMypr"];case"mytentera":return["regionSpecific","malaysiaMytentera"];case"pan-card":return["regionSpecific","indiaPanCard"];case"professional-id":return["regionSpecific","mexicoProfessionalId"];case"public-services-card":return ha(t);case"work-permit":return ga(t);case"ikad":return["regionSpecific","malaysiaIkad"];case"military-id":return pa(t);case"mykas":return["regionSpecific","malaysiaMykas"];case"social-security-card":return fa(t);case"s-pass":return["regionSpecific","singaporeSPass"];case"address-card":return["regionSpecific","hungaryAddressCard"];case"minors-id":return Ca(t);case"postal-id":return["regionSpecific","philippinesPostalId"];case"tax-id":return Sa(t);case"weapon-permit":return ya(t);case"border-crossing-card":return["regionSpecific","usBorderCrossingCard"];case"global-entry-card":return["regionSpecific","usGlobalEntryCard"];case"mypolis":return["regionSpecific","malaysiaMypolis"];case"nexus-card":return["regionSpecific","usNexusCard"];case"refugee-id":return["regionSpecific","malaysiaRefugeeId"];case"tribal-id":case"non-card-tribal-id":return["regionSpecific","canadaTribalId"];case"veteran-id":return["regionSpecific","usVeteranId"];case"citizenship-certificate":return["regionSpecific","canadaCitizenshipCertificate"];case"minors-public-services-card":return["regionSpecific","canadaMinorsPublicServicesCard"];case"asylum-request":return["regionSpecific","ukAsylumRequest"];case"uniformed-services-id":return["regionSpecific","usUniformedServicesId"];case"consular-voter-id":return["regionSpecific","mexicoConsularVoterId"];case"twic-card":return["regionSpecific","usTwicCard"];case"nbi-clearance":return["regionSpecific","philippinesNbiClearance"];case"temporary-protection-permit":return["regionSpecific","colombiaTemporaryProtectionPermit"];case"afghan-citizen-card":return["regionSpecific","pakistanAfghanCitizenCard"];case"eid":return["regionSpecific","germanyEid"];case"sis-id":return["regionSpecific","swedenSisId"];case"asic-card":return["regionSpecific","australiaAsicCard"];case"vehicle-registration":return["regionSpecific","uaeVehicleRegistrationCard"];case"esaad-card":return["regionSpecific","uaeEsaadCard"];case"medical-marijuana-id":return["regionSpecific","usMedicalMarijuanaCard"];case"exit-entry-permit":return["regionSpecific","chinaExitEntryPermit"];case"mainland-travel-permit-taiwan":return["regionSpecific","chinaMainlandTravelPermitTaiwan"];case"diplomatic-id":case"bidoon-card":case"pass":case"my-number-card":case"adr-certificate":case"metis-federation-card":return null;default:assertUnreachable(e)}return null}function pa(e){return"uk"===e?["regionSpecific","ukMilitaryId"]:["regionSpecific","usCommonAccessCard"]}function ma(e){switch(e){case"pakistan":return["regionSpecific","pakistanConsularId"];case"guatemala":return["regionSpecific","guatemalaConsularId"];case"mexico":return["regionSpecific","mexicoConsularId"];default:return["regionSpecific",null]}}function ha(e){switch(e){case"ireland":return["regionSpecific","irelandPublicServicesCard"];case"canada":return["regionSpecific","canadaPublicServicesCard"];default:return["regionSpecific",null]}}function ga(e){switch(e){case"philippines":return["regionSpecific","philippinesWorkPermit"];case"singapore":return["regionSpecific","singaporeWorkPermit"];case"usa":return["regionSpecific","usWorkPermit"];default:return["regionSpecific",null]}}function fa(e){switch(e){case"philippines":return["regionSpecific","philippinesSocialSecurityCard"];case"sweden":return["regionSpecific","swedenSocialSecurityCard"];case"canada":return["regionSpecific","canadaSocialSecurityCard"];case"usa":return["regionSpecific","usSocialSecurityCard"];default:return["regionSpecific",null]}}function Ca(e){switch(e){case"belgium":return["regionSpecific","belgiumMinorsId"];case"colombia":return["regionSpecific","colombiaMinorsId"];case"peru":return["regionSpecific","peruMinorsId"];case"bolivia":return["regionSpecific","boliviaMinorsId"];default:return["regionSpecific",null]}}function Sa(e){switch(e){case"philippines":return["regionSpecific","philippinesTaxId"];case"mexico":return["regionSpecific","mexicoTaxId"];default:return["regionSpecific",null]}}function ya(e){switch(e){case"usa":return["regionSpecific","usWeaponPermit"];case"canada":return["regionSpecific","canadaWeaponPermit"];default:return["regionSpecific",null]}}var A=class{constructor(e,t,a){this.isDeleted=!1,this.isRecreating=!1,this.centaurusWasmSDK=e,this.idCaptureSettings=t,this.scannerDefaultSettings=a}get type(){return this._type}async process(e){return{...await this.session.process(e),centaurusResult:await this.getResult()}}async getResult(){if(this.isDeleted||this.isRecreating)throw new Error(`Cannot call getResult() on ${this._type} session that is ${this.isDeleted?"deleted":"being recreated"}`);return this.session.getResult()}async delete(){this.isDeleted||(this.isDeleted=!0,await this.session.delete())}async createSession(e){var t,a;let i={inputImageSource:this.inputImageSource,scanningMode:null!=(t=this.idCaptureSettings.scanner.physicalDocument)&&t.isSingleSideScanner()?"single":"automatic",scanningSettings:{anonymizationMode:null,scanCroppedDocumentImage:null!=(a=null==e?void 0:e.scanCroppedDocumentImage)&&a,skipImagesOccludedByHand:this.scannerDefaultSettings.skipImagesOccludedByHand,combineResultsFromMultipleInputImages:this.scannerDefaultSettings.combineResultsFromMultipleInputImages,scanUnsupportedBack:this.scannerDefaultSettings.scanUnsupportedBack,recognitionModeFilter:{enableBarcodeId:this.scannerDefaultSettings.filter.enableBarcodeId,enableFullDocumentRecognition:!(null!=e&&e.detectionOnlyMode)&&this.scannerDefaultSettings.filter.enableFullDocumentRecognition,enableMrzId:this.scannerDefaultSettings.filter.enableMrzId,enableMrzPassport:this.scannerDefaultSettings.filter.enableMrzPassport,enableMrzVisa:this.scannerDefaultSettings.filter.enableMrzVisa,enablePhotoId:this.scannerDefaultSettings.filter.enablePhotoId},croppedImageSettings:{returnDocumentImage:this.idCaptureSettings.getShouldPassImageTypeToResult("croppedDocument")||this.shouldEnforceCroppedDocumentImage(),returnFaceImage:this.idCaptureSettings.getShouldPassImageTypeToResult("face")}}},r=[99,114,101,97,116,101,66,108,105,110,107,73,100,83,99,97,110,110,105,110,103,83,101,115,115,105,111,110].map((e=>String.fromCodePoint(e))).join("");return this.centaurusWasmSDK[r](i)}shouldEnforceCroppedDocumentImage(){return this.idCaptureSettings.getShouldPassImageTypeToResult("frame")&&("imagesOnly"===this.idCaptureSettings.anonymizationMode||"fieldsAndImages"===this.idCaptureSettings.anonymizationMode)}},Le=class e extends A{constructor(){super(...arguments),this._type="default",this.inputImageSource="video"}static async create(t,a,i){let r=new e(t,a,i);return r.session=await r.createSession(),r}},Fe=class e extends A{constructor(){super(...arguments),this._type="localizeOnly",this.inputImageSource="video",this.needsRecreation=!1}static async create(t,a,i){let r=new e(t,a,i);return r.session=await r.createSession(),r}async createSession(){return super.createSession({detectionOnlyMode:!0})}async process(e){this.needsRecreation&&await this.recreateSession();let t=await super.process(e);return"document-scanned"===t.resultCompleteness.scanningStatus&&(this.needsRecreation=!0),t}async recreateSession(){this.needsRecreation=!1,this.isRecreating=!0;try{await this.session.delete(),this.session=await this.createSession()}finally{this.isRecreating=!1}}},je=class e extends A{constructor(){super(...arguments),this._type="photoMode",this.inputImageSource="photo"}static async create(t,a,i){let r=new e(t,a,i);return r.session=await r.createSession(),r}},Ee=class e extends A{constructor(){super(...arguments),this._type="scanCroppedDocument",this.inputImageSource="photo"}static async create(t,a,i,r){let n=new e(t,a,i);return n.session=await n.createSession({scanCroppedDocumentImage:!0}),n.resultProcessor=r,n}async process(e){let t=await this.doProcess(e);if(t.hasCapturedId)return t;let a=[.9,.8,.7];for(let i of a){let a=await this.scaleImage(this.imageDataFromArrayBuffer(t.arrayBuffer,e.width,e.height),i);if(a&&(t=await this.doProcess(a),t.hasCapturedId))return t}return t}async scaleImage(e,t){let a=document.createElement("canvas");a.width=e.width,a.height=e.height;let i=a.getContext("2d"),r=await createImageBitmap(e);return i?(i.fillStyle="#000000",i.fillRect(0,0,a.width,a.height),i.scale(t,t),i.drawImage(r,(a.width/t-e.width)/2,(a.height/t-e.height)/2,e.width,e.height),i.getImageData(0,0,a.width,a.height)):null}async doProcess(e){let{inputImageAnalysisResult:t,resultCompleteness:a,arrayBuffer:i}=await this.session.process(e),r=await this.getResult();return{inputImageAnalysisResult:t,resultCompleteness:a,arrayBuffer:i,centaurusResult:r,hasCapturedId:null!=await this.resultProcessor.processResult(r,t,a)}}imageDataFromArrayBuffer(e,t,a){return new ImageData(new Uint8ClampedArray(e),t,a,{colorSpace:"srgb"})}},Be=class e extends A{constructor(){super(...arguments),this._type="combinedSingleImage",this.inputImageSource="photo",this.lastSessionUsed=null}static async create(t,a,i,r){let n=new e(t,a,i);return n.photoModeSession=await je.create(t,a,i),n.croppedDocumentSession=await Ee.create(t,a,i,r),n}async process(e){if(null!==this.lastSessionUsed)return this.processWithSession(e,this.lastSessionUsed);let t=await this.processWithSession(e,this.photoModeSession);return this.hasPositiveResult(t)?t:this.processWithSession(e,this.croppedDocumentSession)}async delete(){this.isDeleted||(await this.photoModeSession.delete(),await this.croppedDocumentSession.delete(),this.isDeleted=!0)}async processWithSession(e,t){let a=await t.process(e);return this.hasPositiveResult(a)&&(this.lastSessionUsed=t),a}hasPositiveResult(e){return"side-scanned"===e.resultCompleteness.scanningStatus||"document-scanned"===e.resultCompleteness.scanningStatus}},Je=class{constructor(e,t){this.isProcessing=!1,this._lastError=null,this._lastResult=null,this._lastLocalization=null,this._initialized=!1,this._currentFrameSourceType=null,this._engagedSession=null,this._isDetectionOnlyMode=!1,this._hasDefaultSessionFullResult=!1,this.centaurusWasmSDK=e,this._workerCallProvider=t}get engagedSession(){var e;return null!=(e=this._engagedSession)?e:null}set engagedSession(e){this._engagedSession!==e&&(this._engagedSession=e)}async init(e,t,a){var i,r;this.idCaptureSettings=e.clone(),this.resultProcessor=new ke(this._workerCallProvider),this.scannerDefaultSettings=t,this._currentFrameSourceType=null!=(r=null==(i=null==a?void 0:a.toJSONObject())?void 0:i.type)?r:null,await this.createAllSessions(),this._lastResult=null,this._lastError=null,this._lastLocalization=null,this._initialized=!0}isReadyToProcessFrame(){return!1===this.isProcessing}async processFrame(e){this.isProcessing=!0,this.engagedSession=this.autoSelectSession();let{inputImageAnalysisResult:t,resultCompleteness:a,arrayBuffer:i,centaurusResult:r}=await this.engagedSession.process({...e,colorSpace:"srgb"}),n=null;this.engagedSession!==this.localizeOnlySession&&(n=await this.resultProcessor.processResult(r,t,a),"document-scanned"===a.scanningStatus&&(this._hasDefaultSessionFullResult=!0));let s=this.toLocalizedOnlyId(this.resultProcessor.getLocation(t)),o=this.toDetectionIssue(t.documentDetectionStatus),l=this.extractDiagnosticJSON(t);return this.isProcessing=!1,{arrayBuffer:i,capturedId:n,localizedOnlyId:s,detectionIssue:o,diagnostics:l}}async reset(){await this.deleteAllSessions(),await this.createAllSessions(),this._lastResult=null,this._lastError=null,this._lastLocalization=null,this._hasDefaultSessionFullResult=!1}async deleteAllSessions(){for(let e of[this.defaultSession,this.localizeOnlySession,this.combinedSingeImageSession])await(null==e?void 0:e.delete())}async applySettings(e){this.idCaptureSettings=e.clone(),await this.reset(),this.setDetectionOnlyMode("buttonTap"===this.idCaptureSettings.captureTrigger)}async setDetectionOnlyMode(e){this._isDetectionOnlyMode!==e&&(this._isDetectionOnlyMode=e)}async dispose(){for(let e of[this.defaultSession,this.combinedSingeImageSession,this.localizeOnlySession])await(null==e?void 0:e.delete())}async onFrameSourceChanged(e){var t,a;if(!this._initialized)return;let i=null!=(a=null==(t=null==e?void 0:e.toJSONObject())?void 0:t.type)?a:null;i!==this._currentFrameSourceType&&(this._currentFrameSourceType=i)}async createAllSessions(){this.defaultSession=await Le.create(this.centaurusWasmSDK,this.idCaptureSettings,this.scannerDefaultSettings),this.combinedSingeImageSession=await Be.create(this.centaurusWasmSDK,this.idCaptureSettings,this.scannerDefaultSettings,this.resultProcessor),this.localizeOnlySession=await Fe.create(this.centaurusWasmSDK,this.idCaptureSettings,this.scannerDefaultSettings)}autoSelectSession(){return this._hasDefaultSessionFullResult||this._isDetectionOnlyMode?this.localizeOnlySession:"singleImageUploader"===this._currentFrameSourceType||"imageFrameSource"===this._currentFrameSourceType?this.combinedSingeImageSession:this.defaultSession}toLocalizedOnlyId(e){return null!=e?X.fromJSON({location:e}):null}toDetectionIssue(e){let t=null;switch(e){case"camera-too-far":t="DocumentTooFar";break;case"camera-too-close":case"document-too-close-to-camera-edge":case"document-partially-visible":t="DocumentTooClose";break;default:t=null}return t}extractDiagnosticJSON(e){var t;try{let a={idType:"viz"};switch("detected"===e.blurDetectionStatus&&(a.blurDetected=!0),"detected"===e.glareDetectionStatus&&(a.glareDetected=!0),e.documentLightingStatus){case"too-dark":a.lightingIssue="tooDark";break;case"too-bright":a.lightingIssue="tooBright"}return"detected"===e.documentHandOcclusionStatus&&(a.occlusionDetected=!0),(null==(t=e.missingMandatoryFields)?void 0:t.length)>0&&(a.mandatoryFieldsMissing=e.missingMandatoryFields.map((e=>e.rawValue?e.rawValue:e))),Object.keys(a).length>1?JSON.stringify(a):null}catch{return null}}displayDetectionStatusInUI(e){let t=window,a=t.centaurusDetectionStatus;null==a&&(a=document.createElement("div"),a.className="centaurusDetectionStatus",a.style.position="absolute",a.style.zIndex="1000",a.style.top="10px",a.style.left="10px",a.style.padding="0 1rem",a.style.backgroundColor="white",document.body.append(a),t.centaurusDetectionStatus=a),a.textContent=`LocalizedStatus: ${e}`}},ba=(e=>(e.NotAcceptedDocumentType="notAcceptedDocumentType",e.InvalidFormat="invalidFormat",e.DocumentVoided="documentVoided",e.Timeout="timeout",e.SingleImageNotRecognized="singleImageNotRecognized",e.DocumentExpired="documentExpired",e.DocumentExpiresSoon="documentExpiresSoon",e.NotRealIdCompliant="notRealIdCompliant",e.HolderUnderage="holderUnderage",e.ForgedAamvaBarcode="forgedAamvaBarcode",e.InconsistentData="inconsistentData",e.CloudRequestFailed="cloudRequestFailed",e))(ba||{}),ze=class{constructor(e){this.quadType=e}async outlineRegions(e,t){let a=await this.renderImage(e);a.beginPath(),a.rect(0,0,a.canvas.width,a.canvas.height);for(let e of t)a.moveTo(e.topLeft.x,e.topLeft.y),a.lineTo(e.topLeft.x,e.bottomRight.y),a.lineTo(e.bottomRight.x,e.bottomRight.y),a.lineTo(e.bottomRight.x,e.topLeft.y),a.lineTo(e.topLeft.x,e.topLeft.y);a.fillStyle="rgba(0, 0, 0, 0.30)",a.fill(),a.lineWidth=3,a.strokeStyle="red",a.beginPath();for(let e of t)a.rect(e.topLeft.x,e.topLeft.y,e.bottomRight.x-e.topLeft.x,e.bottomRight.y-e.topLeft.y);return a.stroke(),a.canvas.toDataURL("image/jpeg",1)}async obscureRegions(e,t){let a=await this.renderImage(e);a.beginPath(),a.fillStyle="black";for(let e of t)a.rect(e.topLeft.x,e.topLeft.y,e.bottomRight.x-e.topLeft.x,e.bottomRight.y-e.topLeft.y);return a.fill(),a.canvas.toDataURL("image/jpeg",1)}get canvas(){return this._canvas||(this._canvas=document.createElement("canvas")),this._canvas}async renderImage(e){let t=await this.loadImage(e);this.canvas.width=t.naturalWidth,this.canvas.height=t.naturalHeight;let a=this.canvas.getContext("2d");return a.drawImage(t,0,0),a}async loadImage(e){let t=new Image;return t.src=e,await t.decode(),t}},_e="reloadDetector",Ue=class e{constructor(t,a=e.DEFAULT_WRITE_INTERVAL_MS){this._lastWrite=0,this._storage=t,this._writeIntervalMs=a}hasDataAlreadyWritten(){return null!==this._storage.getItem(_e)}write(e){return this._pendingData={...e},this.scheduleWrite(),e}read(){var e;if(this._pendingData)return this._pendingData;let t=null!=(e=this._storage.getItem(_e))?e:"{}";return JSON.parse(t)}clear(){this._storage.removeItem(_e),this._pendingData=void 0,this._lastWrite=0,clearTimeout(this._writeTimer)}scheduleWrite(){clearTimeout(this._writeTimer);let e=performance.now()-this._lastWrite;e>this._writeIntervalMs?(this._storage.setItem(_e,JSON.stringify(this._pendingData)),this._pendingData=void 0,this._lastWrite=performance.now()):this._writeTimer=setTimeout(this.scheduleWrite.bind(this),this._writeIntervalMs-e)}};Ue.DEFAULT_WRITE_INTERVAL_MS=500;var Ve=Ue,ue=class{constructor(e){this.onUnload=()=>{this._storage.clear()},this._onPageAbruptlyReloaded=e,this._storage=new Ve(this.getStorage())}static isSafari(){return BrowserHelper.isSafari()}install(){if(BrowserHelper.isSafari()){if(window.addEventListener("unload",this.onUnload,{once:!0}),!this._storage.hasDataAlreadyWritten())return void this._storage.write({});this._onPageAbruptlyReloaded()}}updateData(e){this._storage.write(e)}get data(){return this._storage.read()}uninstall(){window.removeEventListener("unload",this.onUnload)}getStorage(){return SafeStorage.getInstanceFor("sessionStorage")}},He=class e{constructor(e){this._framesProcessedCount=0,this._didCaptureCount=0,this._didRejectCount=0,this._applySettingsCount=1,this._videoResolution="",this._upTimeMs=0,this._upTimeTimer=null,this._detector=e}destroy(){this._upTimeTimer&&(clearInterval(this._upTimeTimer),this._upTimeTimer=null)}get framesProcessedCount(){return this._framesProcessedCount}get didCaptureCount(){return this._didCaptureCount}get didRejectCount(){return this._didRejectCount}get applySettingsCount(){return this._applySettingsCount}get videoResolution(){return this._videoResolution}set framesProcessedCount(t){this._framesProcessedCount=t,null==this._upTimeTimer&&(this._firstFrameProcessedTime=performance.now(),this._upTimeTimer=setInterval(this.updateUpTime.bind(this),e.UP_TIME_UPDATE_INTERVAL_MS)),this._detector.updateData(this.data)}set didCaptureCount(e){this._didCaptureCount=e,this._detector.updateData(this.data)}set didRejectCount(e){this._didRejectCount=e,this._detector.updateData(this.data)}set applySettingsCount(e){this._applySettingsCount=e,this._detector.updateData(this.data)}set videoResolution(e){this._videoResolution=e,this._detector.updateData(this.data)}get data(){return{framesProcessedCount:this._framesProcessedCount,didCaptureCount:this._didCaptureCount,didRejectCount:this._didRejectCount,applySettingsCount:this._applySettingsCount,upTime:Math.round(this._upTimeMs/100)/10,videoResolution:this._videoResolution}}updateUpTime(){this._firstFrameProcessedTime&&(this._upTimeMs=performance.now()-this._firstFrameProcessedTime,this._detector.updateData(this.data))}};He.UP_TIME_UPDATE_INTERVAL_MS=500;var We=He,I=Symbol("ID Capture internals"),y={Initializing:"Initializing",Available:"Available",ProcessingFrame:"ProcessingFrame",ProcessingQueue:"ProcessingQueue"},sr=class e{constructor(e){this.type="idCapture",this._synchronousFrameFlow=!0,this.state=y.Initializing,this._isEnabled=!0,this._context=null,this.listeners=[],this.overlayListeners=new Set,this._endOfCycleTasks=[],this._feedback=be.defaultFeedback,this._scanMode="local",this._onProcessFrameListener=this.onProcessFrame.bind(this),this.workerMessageListener=this.onWorkerMessage.bind(this),this.settings=e.clone(),this.shouldEnableCentaurus()&&(this._centaurusConnector=new Je(x.wasmSDK,(()=>{var e;return null==(e=this.privateContext)?void 0:e.workerCommand}))),this.contextListener={didChangeFrameSource:this.didChangeFrameSource.bind(this)}}static get recommendedCameraSettings(){return new CameraSettings(Y.IdCapture.RecommendedCameraSettings)}get context(){return this._context}get feedback(){return this._feedback}get privateContext(){return this.context}static async forContext(t,a){let i=new e(a);return t&&(await t.addMode(i),i.shouldEnableCentaurus()&&await i.initCentaurusConnector()),i.moveToState(y.Available),i}async setFeedback(e){return this._feedback=e,this.didChange()}addListener(e){this.listeners.includes(e)||this.listeners.push(e)}removeListener(e){this.listeners.includes(e)&&this.listeners.splice(this.listeners.indexOf(e),1)}isEnabled(){return this._isEnabled}async setEnabled(e){this._isEnabled!==e&&(this._isEnabled=e,this.enqueueTask((async()=>this.didChange([{type:"modeEnabled",newValue:e}]))),this.state===y.Available&&this.moveToState(y.ProcessingQueue)),e&&this.checkCaptureSettingsAgainstSDKConfiguration(this._settings)}async reset(){this.enqueueTask((async()=>this.doReset())),this.state===y.Available&&this.moveToState(y.ProcessingQueue)}async applySettings(e){this.enqueueTask((async()=>this.doApplySettings(e.clone()))),this.state===y.Available&&this.moveToState(y.ProcessingQueue)}async parse(e){if(this.context){let t=await this.context.workerCommand("idCaptureParse",{code:e});if(null!=(null==t?void 0:t.result)){let e=t.result;if("error"===(null==e?void 0:e.status))throw O.create({type:"InvalidLicenseKeyForParser",message:e.error});if("success"===(null==e?void 0:e.status)){let t=await this.processRawImages(e.capturedId.rawImageInfo);return se.fromJSON({...e.capturedId,imageInfo:t})}}}return null}async setExternalTransactionId(e){var t;return null==(t=this.privateContext)?void 0:t.workerCommand("idCaptureSetExternalTransactionId",{transactionId:e})}async getExternalTransactionId(){var e,t,a;return null!=(a=null==(t=await(null==(e=this.privateContext)?void 0:e.workerCommand("idCaptureGetExternalTransactionId",{})))?void 0:t.transactionId)?a:null}toJSONObject(){var e;return{enabled:this._isEnabled,type:this.type,settings:{...this.settings.toJSONObject(),licensee:"",licenseKey:null!=(e=x.licenseKey)?e:""}}}get settings(){return this._settings}set settings(e){e[I].willScanInTheCloud()?(e.setProperty("displayIdOutline",!0),this._scanMode="cloud"):this._scanMode="local",this._settings=e}shouldEnableCentaurus(){return null!=x.wasmSDK&&!this.settings[I].willScanInTheCloud()}async initCentaurusConnector(){var e,t,a;if(!this.privateContext)throw O.create({type:"Undefined",message:"Cannot initialize Centaurus without a context"});let i=await(null==(e=this.privateContext)?void 0:e.workerCommand("idCaptureGetCentaurusSettings",{}));try{await this._centaurusConnector.init(this.settings,Object.freeze(i.result),null!=(a=null==(t=this._context)?void 0:t.frameSource)?a:null)}catch(e){throw e instanceof DataCaptureError&&"MULTIPLE_RECOGNIZER_RUNNER"===e.name&&Logger.log(Logger.Level.Error,"The newly created IdCapture mode is invalid, an existing IdCapture mode is still attached to the context and must be removed first."),e}}async onSDCResetDone(){var e;return null==(e=this._centaurusConnector)?void 0:e.reset()}didChangeFrameSource(e,t){var a;this.moveToState(y.ProcessingQueue),null==(a=this._centaurusConnector)||a.onFrameSourceChanged(t)}moveToState(e){this.state=e,e===y.ProcessingQueue&&this.processQueue()}async doReset(){var e;await(null==(e=this.privateContext)?void 0:e.workerCommand("idCaptureReset",{}))}async doApplySettings(e){var t,a,i;this.context&&(this.settings=e.clone(),await Promise.all([e[I].shouldEnableVIZScanner()?null==(t=this._centaurusConnector)?void 0:t.applySettings(e):Promise.resolve(),null==(a=this.privateContext)?void 0:a.workerCommand("idCaptureApplySettings",{settings:e.toJSONObject()}),null==(i=this.privateContext)?void 0:i.update()]),this._safariOOMStatsCollector&&this._safariOOMStatsCollector.applySettingsCount++)}addOverlayListener(e){this.overlayListeners.add(e)}removeOverlayListener(e){this.overlayListeners.delete(e)}checkCaptureSettingsAgainstSDKConfiguration(e){!this._centaurusConnector&&e[I].shouldEnableVIZScanner()&&Logger.warn('Invalid IdCapture configuration or settings: VIZ scanner enabled but not loaded. You either need to set the "enableVIZDocuments" option to true when calling configure(), or adapt the Id Capture settings to not enable VIZ scanning.');let t=e.scanner.physicalDocument;null!=t&&t.isSingleSideScanner()&&t.freeFormText&&!e[I].allowCloudScanning()&&Logger.warn("Invalid IdCapture settings: singleSideScanner has freeFormText enabled but allowCloudScanning is not set to true."),e[I].validateScannerForCloudDocuments()||Logger.warn("Invalid IdCapture settings: some cloud documents are enabled but the scanner is not a single side scanner with free form text enabled."),e[I].documentsRequireCloudScanning()&&e[I].allowCloudScanning()&&(null==t||!t.isSingleSideScanner()||!t.freeFormText)&&Logger.warn("Invalid IdCapture settings: cloud-compatible documents are configured with allowCloudScanning enabled but free-form text is not enabled on the scanner.")}async onProcessFrame(e){var t,a;if(this.state!==y.Available)return{action:"skip",frame:e};null==(t=this.privateContext)||t.performanceMark("processFrameBeforeCentaurus"),this.moveToState(y.ProcessingFrame);let i=await this.doProcessFrame(e);return null==(a=this.privateContext)||a.performanceMark("processFrameAfterCentaurus"),{action:"continue",frame:i}}async doProcessFrame(e){return this._isEnabled&&this.settings[I].shouldEnableVIZScanner()?await this.processFrameWithCentaurus(e):e}async onAfterProcessFrame(){var e,t;if(this._safariOOMStatsCollector){this._safariOOMStatsCollector.framesProcessedCount++;let a=null==(t=null==(e=this.context)?void 0:e.frameSource)?void 0:t.currentResolution;this._safariOOMStatsCollector.videoResolution=a?`${a.width}x${a.height}`:""}this.moveToState(y.ProcessingQueue)}async onCloudProcessingStarted(){var e,t;null==(t=null==(e=this.privateContext)?void 0:e.getView())||t.freezeFrame();let a=this.getOverlay();null==a||a.onCloudProcessingStarted()}async onCloudProcessingFinished(){var e,t;null==(t=null==(e=this.privateContext)?void 0:e.getView())||t.unfreezeFrame();let a=this.getOverlay();null==a||a.onCloudProcessingFinished()}getOverlay(){var e;let t,a=null==(e=this.privateContext)?void 0:e.getView();if(a)for(let e of a.overlays)if("idCapture"===e.type){t=e;break}return t}logPerformance(){let e=performance.getEntriesByName("processFrameBeforeCentaurus").length>0?performance.measure("Centaurus","processFrameBeforeCentaurus","processFrameAfterCentaurus").duration:0,t=performance.measure("SDC","processFrameBeforeSDC","processFrameAfterSDC").duration,a=`${(e+t).toFixed(2)}ms`;Logger.debug(`centaurus: ${e.toFixed(2)}`,`sdc: ${t.toFixed(2)}`,`total: ${a}`),performance.clearMarks()}enqueueTask(e){this._endOfCycleTasks.push(e)}async processQueue(){if(0!==this._endOfCycleTasks.length){for(;this._endOfCycleTasks.length>0;){let e=this._endOfCycleTasks.shift();await(null==e?void 0:e())}this.moveToState(y.Available)}else this.moveToState(y.Available)}attachedToContext(e){var t;this._context=e,this._context.subscribeToWorkerMessages(this.workerMessageListener),this._context.registerFrameHandler(this._onProcessFrameListener),ue.isSafari()&&(this._safariOOMDetector=new ue(this.onPageAbruptlyReloaded.bind(this)),this._safariOOMDetector.install(),this._safariOOMStatsCollector=new We(this._safariOOMDetector)),this._context.addListener(this.contextListener),null==(t=this._centaurusConnector)||t.onFrameSourceChanged(this.context.frameSource)}async detachedFromContext(){await this.dispose()}async dispose(){var e,t,a,i,r,n,s;null==(e=this._context)||e.unsubscribeToWorkerMessages(this.workerMessageListener),null==(t=this._context)||t.unregisterFrameHandler(this._onProcessFrameListener),null==(a=this._context)||a.removeListener(this.contextListener),null==(i=this._safariOOMDetector)||i.uninstall(),this._safariOOMDetector=void 0,null==(r=this._safariOOMStatsCollector)||r.destroy(),this._safariOOMStatsCollector=void 0,this.listeners=[],await(null==(n=this._centaurusConnector)?void 0:n.dispose()),this._centaurusConnector=void 0,null==(s=this.privateContext)||s.workerCommand("idCaptureDispose",{}),this._context=null,this.moveToState("Available")}async didChange(e){if(this.context)return this.context.update(e)}async onWorkerMessage(e){switch(e.type){case"idCaptureDidCaptureId":this.triggerListenersForResult("didCaptureId",e.payload);break;case"idCaptureDidPartiallyCaptureId":this.triggerListenersForResult("didPartiallyCaptureId",e.payload);break;case"idCaptureDidRejectId":await this.triggerListenersForResult("didRejectId",e.payload),"singleImageNotRecognized"===e.payload.rejectionReason&&await this.reset();break;case"idCaptureDidLocalizeId":this.triggerListenersForLocalization(e.payload.localization);break;case"idCaptureDidShutterButtonPositionChanged":for(let t of this.overlayListeners)t.onShutterPositionUpdate(e.payload.position);break;case"idCaptureDidShutterButtonStateChanged":for(let t of this.overlayListeners)t.onShutterButtonStateChanged(e.payload.state);break;case"idCaptureIdCapturedFeedback":this._feedback.idCaptured.emit();break;case"idCaptureIdRejectedFeedback":this._feedback.idRejected.emit();break;case"idCaptureDidUpdateIdOutline":case"onFrameProcessingStarted":break;case"idCaptureBackendReset":this.enqueueTask((async()=>this.onSDCResetDone()));break;case"idCaptureDetectionOnlyMode":this.enqueueTask((async()=>{var t;return null==(t=this._centaurusConnector)?void 0:t.setDetectionOnlyMode(e.payload.detectionOnlyMode)})),this.state===y.Available&&this.moveToState(y.ProcessingQueue);break;case"onFrameProcessingFinished":case"onFrameSkipped":this.onAfterProcessFrame();break;case"idCaptureCloudProcessingStarted":this.onCloudProcessingStarted();break;case"idCaptureCloudProcessingFinished":this.onCloudProcessingFinished()}}async processFrameWithCentaurus(e){var t;if(null==(t=this._centaurusConnector)||!t.isReadyToProcessFrame())return e;try{let{arrayBuffer:t,capturedId:a,detectionIssue:i,localizedOnlyId:r,diagnostics:n}=await this._centaurusConnector.processFrame(e);return await this.reportToBackend(a,i,r,n),{frameId:e.frameId,width:e.width,height:e.height,colorType:e.colorType,data:new Uint8ClampedArray(t)}}catch(t){return t instanceof O?(Logger.log(Logger.Level.Debug,t.message),this.triggerErrorListener(t)):(Logger.log(Logger.Level.Debug,"Error while processing incoming frame from SDC",t),this.triggerErrorListener(O.create({type:"Undefined",message:"Error while processing a frame"}))),e}}async reportToBackend(e,t,a,i){void 0!==e&&await this.reportLastResult(e),await this.reportLastLocalizedId(a),await this.reportLastDetectionIssue(t),await this.reportLastDiagnostics(i),await this.reportLastError(null)}uint8ArrayImageToBase64(e,t,a){let i=document.createElement("canvas");i.width=t,i.height=a;let r=i.getContext("2d");if(!r)throw new Error("Could not get 2d context from an HTMLCanvasElement");r.putImageData(new ImageData(e,t,a,{colorSpace:"srgb"}),0,0);let n=r.canvas.toDataURL("image/png",1);return r=null,i=null,n}async processRawImages(e){let{front:t,back:a}=e,i=e.front.frame.image,r=e.back.frame.image;return{front:{face:t.face,croppedDocument:await this.anonymizeImage(t.croppedDocument.image,t.croppedDocument.obscuredRegions),frame:await this.anonymizeImage(null==i.data?null:this.uint8ArrayImageToBase64(i.data,i.width,i.height),t.frame.obscuredRegions)},back:{face:null,croppedDocument:await this.anonymizeImage(a.croppedDocument.image,a.croppedDocument.obscuredRegions),frame:await this.anonymizeImage(null==r.data?null:this.uint8ArrayImageToBase64(r.data,r.width,r.height),a.frame.obscuredRegions)}}}async anonymizeImage(e,t){return null==e?null:0===t.length?e:await new ze("obscure").obscureRegions(e,t)}async triggerListenersForLocalization(e){for(let t of this.listeners)"function"==typeof t.didLocalizeId&&t.didLocalizeId(X.fromJSON(e))}async triggerListenersForResult(e,t){if(!this.context||!this._isEnabled)return;"didCaptureId"===e?this._safariOOMStatsCollector&&this._safariOOMStatsCollector.didCaptureCount++:"didRejectId"===e&&this._safariOOMStatsCollector&&this._safariOOMStatsCollector.didRejectCount++;let a=null;if(t.capturedId){let e=await this.processRawImages(t.capturedId.rawImageInfo);a=se.fromJSON({...t.capturedId,imageInfo:e})}for(let i of this.listeners)if("function"==typeof i[e]){let r=[a];"didRejectId"===e&&"string"==typeof t.rejectionReason&&r.push(t.rejectionReason);let n=i[e].apply(null,r);n instanceof Promise&&await n}}notifyRecoveryAfterCrash(){var e;if(!this._isEnabled)return;let t=!1;for(let e of this.listeners)"function"==typeof e.didFailWithError&&(e.didFailWithError(this,O.create({type:"RecoveredAfterFailure",message:"Last image processing failed but SDK could recover. Please reset scanning process."})),t=!0);!t&&null!=(e=this.settings.scanner.physicalDocument)&&e.isFullDocumentScanner()&&Logger.log(Logger.Level.Warn,'A process responsible to scan images malfunctioned and was restarted. No listener for "didFailWithError" was\n        found: this may result in unexpected behaviour in your application. Please define the listener\n        "didFailWithError" and handle the error "IdCaptureErrorCode.RecoveredAfterFailure". Informing the user to\n        start over and calling "idCapture.reset()" in this case is recommended.')}triggerErrorListener(e){if(this._isEnabled)for(let t of this.listeners)"function"==typeof t.didFailWithError&&t.didFailWithError(this,e)}async reportLastResult(e){var t;if(this.context)return null==(t=this.privateContext)?void 0:t.workerCommand("idCaptureSetLastResult",{result:null==e?"":JSON.stringify(e)})}async reportLastError(e){var t;if(this.context)return null==(t=this.privateContext)?void 0:t.workerCommand("idCaptureSetLastError",{error:null==e?"":JSON.stringify(e)})}async reportLastLocalizedId(e){var t;if(this.context)return null==(t=this.privateContext)?void 0:t.workerCommand("idCaptureSetLastLocalizedId",{localizedId:null==e?"":JSON.stringify(e.toJSONObject())})}async reportLastDetectionIssue(e){var t;return null==(t=this.privateContext)?void 0:t.workerCommand("idCaptureSetLastDetectionIssue",{issue:e?JSON.stringify({issue:e}):""})}async reportLastDiagnostics(e){var t;try{return null==(t=this.privateContext)?void 0:t.workerCommand("idCaptureSetLastDiagnostics",{diagnostics:null!=e?e:""})}catch{}}async onPageAbruptlyReloaded(){var e,t;if(Logger.debug("Detected abrupt page reload"),null==this.context||null==this._safariOOMDetector)return;let a={...this._safariOOMDetector.data,parentDomain:null!=(e=function(e){if(null==e)return null;try{return new URL(e).hostname}catch{return null}}(document.referrer))?e:void 0,centaurusEnabled:null!=x.wasmSDK};Logger.debug("Abrupt page reload environment data",a),null==(t=this.privateContext)||t.workerCommand("idCaptureReportSafariAbruptReload",{environmentData:a})}},Ke={standby:"standby",active:"active",scanning:"scanning"},Ge=class{constructor(){this.type="shutter",this.controlsLayout=void 0}toJSONObject(){return{type:this.type}}async install(e){if(this.controlsLayout=e.controlsElement,!this.shutterButton){let{ShutterButton:e}=await import("@scandit/web-datacapture-core/build/js/private/ui/atoms/ShutterButton.js");this.shutterButton||(e.register(),this.shutterButton=e.create(),this.shutterButton.style.margin="0",this.shutterButton.style.position="absolute",this.shutterButton.style.pointerEvents="all",this.shutterButton.style.width="32px",this.shutterButton.style.height="32px",this.shutterButton.style.backgroundColor="transparent",this.shutterButton.style.backgroundRepeat="no-repeat",this.shutterButton.style.border="none",this.shutterButton.style.cursor="pointer",this.lastPositionReceived&&this.applyPositioning(this.lastPositionReceived))}return this.appendShutterButton(),!0}updatePosition(e){0===e.size.width&&0===e.size.height&&this.shutterButton?this.remove():(this.lastPositionReceived=structuredClone(e),this.applyPositioning(e),this.appendShutterButton())}updateState(e){if(this.shutterButton)switch(e){case"scanning":this.shutterButton.rotating=!0,this.shutterButton.pulse=!1;break;case"standby":this.shutterButton.rotating=!1,this.shutterButton.pulse=!1;break;case"active":this.shutterButton.rotating=!1,this.shutterButton.pulse=!0}}remove(e){var t;null==(t=this.shutterButton)||t.remove(),!0===e&&(this.shutterButton=void 0,this.controlsLayout=void 0)}appendShutterButton(){this.shutterButton&&this.controlsLayout&&!this.controlsLayout.contains(this.shutterButton)&&this.controlsLayout.append(this.shutterButton)}applyPositioning(e){this.shutterButton&&(this.shutterButton.style.position="absolute",this.shutterButton.style.left=`${e.origin.x}px`,this.shutterButton.style.top=`${e.origin.y}px`,this.shutterButton.style.width=`${e.size.width}px`,this.shutterButton.style.height=`${e.size.height}px`)}},k=class e extends ScanditHTMLElement{static get observedAttributes(){return["visible"]}constructor(){super();let t=this.attachShadow({mode:"open"});t.innerHTML=html`<div class="line"></div>
      <div class="text"><slot></slot></div>`,t.append(e.createStyleElement().cloneNode(!0)),t.querySelector("slot").addEventListener("slotchange",(()=>this.updateTextVisibility())),this.updateTextVisibility()}attributeChangedCallback(e,t,a){this.updateTextVisibility()}get visible(){return this.hasAttribute("visible")}set visible(e){this.toggleAttribute("visible",e)}updateTextVisibility(){let e=this.shadowRoot.querySelector("slot"),t=this.shadowRoot.querySelector(".text"),a=e.assignedNodes({flatten:!0}).some((e=>{var t,a;return e.nodeType!==Node.TEXT_NODE||""!==(null!=(a=null==(t=e.textContent)?void 0:t.trim())?a:"")}));t.style.display=a?"":"none"}static create(){return e.register(),document.createElement(e.tag)}static register(){defineCustomElements({[e.tag]:e})}static createStyleElement(){return css`
      :host {
        position: absolute;
        display: flex;
        inset: 0;
        width: 100%;
        height: 100%;
        opacity: 0;
        transition: opacity 1s ease-in-out;
        pointer-events: none;
      }

      :host([visible]) {
        opacity: 1;
        pointer-events: auto;
      }

      .line {
        position: absolute;
        top: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 2px;
        background: #eee;
        box-shadow: 0 0 30px 25px #ffffff80;
        clip-path: inset(0);
      }

      :host([visible]) .line {
        animation: 2s ease-in-out infinite alternate scan, 4s ease-in-out infinite trailing-shadow;
      }

      .text {
        margin: auto;
        padding: 2rem;
        background-color: rgba(255 255 255 / 1);
        color: #111619ff;
        font-size: 15px;
        font-weight: 600;
        justify-content: center;
        border-radius: 0.4rem;
        animation: 1s ease-in-out infinite alternate bgnd;
      }

      @keyframes bgnd {
        0% {
          color: #111619ff;
        }
        100% {
          color: #11161980;
        }
      }

      @keyframes scan {
        to {
          transform: translateY(100dvh);
        }
      }

      @keyframes trailing-shadow {
        33% {
          clip-path: inset(-50px 0 0 0);
        }
        50% {
          clip-path: inset(0 0 0 0);
        }
        83% {
          clip-path: inset(0 0 -50px 0);
        }
      }
    `}};k.tag="scandit-horizontal-scanning-animation";var ur,Ze=k,or=class e{constructor(){this.type="idCapture",this._idLayoutStyle="rounded",this._defaultCapturedBrush=Y.IdCapture.IdCaptureOverlayDefaults.defaultCapturedBrush.clone(),this._defaultLocalizedBrush=Y.IdCapture.IdCaptureOverlayDefaults.defaultLocalizedBrush.clone(),this._defaultRejectedBrush=Y.IdCapture.IdCaptureOverlayDefaults.defaultRejectedBrush.clone(),this._capturedBrush=this._defaultCapturedBrush,this._localizedBrush=this._defaultLocalizedBrush,this._rejectedBrush=this._defaultRejectedBrush,this._idLayoutLineStyle="light",this._showTextHints=!0,this._frontSideTextHint=Localization.getInstance().get("id.idCaptureOverlay.scanFrontSideHint"),this._backSideTextHint=Localization.getInstance().get("id.idCaptureOverlay.scanBackSideHint"),this._moveCloserTextHint=Localization.getInstance().get("id.idCaptureOverlay.moveCloseTextHint"),this._moveFurtherAwayTextHint=Localization.getInstance().get("id.idCaptureOverlay.moveFurtherAwayTextHint"),this._tapShutterToScanTextHint=Localization.getInstance().get("id.idCaptureOverlay.tapShutterToScan"),this._lookingForDocumentTextHint=Localization.getInstance().get("id.idCaptureOverlay.lookingForDocument"),this._holdStillTextHint=Localization.getInstance().get("id.idCaptureOverlay.holdStill"),this.shutterControl=new Ge,this._cloudScanningAnimation=null,this.onShutterPositionUpdateListener=this.onShutterPositionUpdate.bind(this),this.onShutterButtonStateChangedListener=this.onShutterButtonStateChanged.bind(this),this.onContextUpdatedListener=this.onContextUpdated.bind(this),this.overlayListener={onShutterPositionUpdate:this.onShutterPositionUpdateListener,onShutterButtonStateChanged:this.onShutterButtonStateChangedListener}}get idLayoutStyle(){return this._idLayoutStyle}set idLayoutStyle(e){this._idLayoutStyle=e,this.idCapture.didChange()}get idLayoutLineStyle(){return this._idLayoutLineStyle}set idLayoutLineStyle(e){this._idLayoutLineStyle=e,this.idCapture.didChange()}get showTextHints(){return this._showTextHints}set showTextHints(e){this._showTextHints=e,this.idCapture.didChange()}get defaultCapturedBrush(){return this._defaultCapturedBrush}get defaultLocalizedBrush(){return this._defaultLocalizedBrush}get defaultRejectedBrush(){return this._defaultRejectedBrush}static async withIdCapture(t){return e.withIdCaptureForView(t,null)}static async withIdCaptureForView(t,a){var i;let r=new e;return r.idCapture=t,await r.setCapturedBrush(r.defaultCapturedBrush),await r.setLocalizedBrush(r.defaultLocalizedBrush),await r.setRejectedBrush(r.defaultRejectedBrush),a&&(r.view=a,await a.addOverlay(r),await r.installShutterButton()),t.addOverlayListener(r.overlayListener),null==(i=t.context)||i.updateListeners.add(r.onContextUpdatedListener),r._cloudScanningAnimation=Ze.create(),null==a||a[INTERNAL_ACCESS].attachAdditionalLayer(r._cloudScanningAnimation,AdditionalLayerPosition.AboveControls),r}onCloudProcessingStarted(){this.showCloudProcessingAnimation()}onCloudProcessingFinished(){this.hideCloudProcessingAnimation()}showCloudProcessingAnimation(){this._cloudScanningAnimation&&(this._cloudScanningAnimation.textContent=Localization.getInstance().get("id.idCaptureOverlay.processingDocument"),this._cloudScanningAnimation.setAttribute("visible","true"))}hideCloudProcessingAnimation(){var e;null==(e=this._cloudScanningAnimation)||e.removeAttribute("visible")}async setFrontSideTextHint(e){Logger.log(Logger.Level.Debug,"DEPRECATED: IdCaptureOverlay.setFrontSideTextHint. Use the Localization API instead."),this._frontSideTextHint=e,await this.idCapture.didChange()}async setBackSideTextHint(e){Logger.log(Logger.Level.Debug,"DEPRECATED: IdCaptureOverlay.setBackSideTextHint. Use the Localization API instead."),this._backSideTextHint=e,await this.idCapture.didChange()}async setMoveCloserTextHint(e){Logger.log(Logger.Level.Debug,"DEPRECATED: IdCaptureOverlay.setMoveCloserTextHint. Use the Localization API instead."),this._moveCloserTextHint=e,await this.idCapture.didChange()}async setMoveFurtherAwayTextHint(e){Logger.log(Logger.Level.Debug,"DEPRECATED: IdCaptureOverlay.setMoveFurtherAwayTextHint. Use the Localization API instead."),this._moveFurtherAwayTextHint=e,await this.idCapture.didChange()}getCapturedBrush(){return this._capturedBrush}async setCapturedBrush(e){this._capturedBrush=e,await this.idCapture.didChange()}getLocalizedBrush(){return this._localizedBrush}async setLocalizedBrush(e){this._localizedBrush=e,await this.idCapture.didChange()}getRejectedBrush(){return this._rejectedBrush}async setRejectedBrush(e){this._rejectedBrush=e,await this.idCapture.didChange()}toJSONObject(){return{type:this.type,idLayoutStyle:this.idLayoutStyle,idLayoutLineStyle:this.idLayoutLineStyle,showTextHints:this._showTextHints,capturedBrush:this._capturedBrush.toJSONObject(),localizedBrush:this._localizedBrush.toJSONObject(),rejectedBrush:this._rejectedBrush.toJSONObject(),frontSideTextHint:this._frontSideTextHint,backSideTextHint:this._backSideTextHint,moveCloserTextHint:this._moveCloserTextHint,moveFurtherAwayTextHint:this._moveFurtherAwayTextHint,tapShutterToScanTextHint:this._tapShutterToScanTextHint,lookingForDocumentTextHint:this._lookingForDocumentTextHint,holdStillTextHint:this._holdStillTextHint}}async installShutterButton(){this.view&&"buttonTap"===this.idCapture.settings.captureTrigger&&this.view.addControl(this.shutterControl)}onContextUpdated(e){var t,a,i,r;if("modeEnabled"===e.type&&!e.newValue&&this.shutterControl)return void(null==(t=this.view)||t.removeControl(this.shutterControl));"removeOverlay"===e.type&&e.newValue===this&&(this.idCapture.removeOverlayListener(this.overlayListener),null==(a=this.idCapture.context)||a.updateListeners.delete(this.onContextUpdatedListener));let n=null==(i=this.idCapture.context)?void 0:i.toJSONObject().modes,s=null==n?void 0:n.find((e=>"idCapture"===e.type));s&&"auto"===s.settings.captureTrigger&&this.shutterControl?null==(r=this.view)||r.removeControl(this.shutterControl):this.installShutterButton()}onShutterPositionUpdate(e){var t,a;null==(t=this.shutterControl)||t.updatePosition(e),0===e.size.width&&0===e.size.height&&this.shutterControl&&(null==(a=this.view)||a.removeControl(this.shutterControl))}onShutterButtonStateChanged(e){var t,a,i;switch(e){case"untapped":null==(t=this.shutterControl)||t.updateState(Ke.standby);break;case"untappedLocalized":null==(a=this.shutterControl)||a.updateState(Ke.active);break;case"tapped":null==(i=this.shutterControl)||i.updateState(Ke.scanning)}}};ur=I;var cr,le=class{constructor(e){var t,a,i;this.allowCloudScanning=!1,this[ur]={setAllowCloudScanning:e=>{this.allowCloudScanning=e},getAllowCloudScanning:()=>this.allowCloudScanning},this.physicalDocument=null!=(t=null==e?void 0:e.physicalDocument)?t:null,this.mobileDocument=null!=(a=null==e?void 0:e.mobileDocument)?a:null,this.allowCloudScanning=null!=(i=null==e?void 0:e.allowCloudScanning)&&i}toJSONObject(){var e,t,a,i;let r={physicalDocument:null!=(t=null==(e=this.physicalDocument)?void 0:e.toJSONObject())?t:null,mobileDocument:null!=(i=null==(a=this.mobileDocument)?void 0:a.toJSONObject())?i:null};return this.allowCloudScanning&&(r.allowCloudScanning=this.allowCloudScanning),r}},$e=class{constructor(){this._ocr=!0}toJSONObject(){return{ocr:this._ocr}}},dt=(e=>(e.FullDocument="fullDocument",e.SingleSide="singleSide",e))(dt||{}),te=class{isSingleSideScanner(){return"singleSide"===this.type}isFullDocumentScanner(){return"fullDocument"===this.type}},Qe=class extends te{constructor(){super(),this.type="fullDocument"}toJSONObject(){return{type:this.type,isFull:!0,options:{barcode:!0,machineReadableZone:!0,visualInspectionZone:!0}}}},Ye=class extends te{constructor(e,t,a,i=!1){super(),this.type="singleSide",this._freeFormText=!1,this._barcode=e,this._machineReadableZone=t,this._visualInspectionZone=a,this._freeFormText=i}get barcode(){return this._barcode}get machineReadableZone(){return this._machineReadableZone}get visualInspectionZone(){return this._visualInspectionZone}get freeFormText(){return this._freeFormText}toJSONObject(){let e={barcode:this.barcode,machineReadableZone:this.machineReadableZone,visualInspectionZone:this.visualInspectionZone,freeFormText:this.freeFormText};return{type:this.type,isFull:!1,options:e}}};cr=I;var ie,re=class e{constructor(){this.acceptedDocuments=[],this.rejectedDocuments=[],this.anonymizationMode="fieldsOnly",this.anonymizeDefaultFields=!0,this.captureTrigger="auto",this.rejectVoidedIds=!1,this.decodeBackOfEuropeanDrivingLicense=!1,this.rejectExpiredIds=!1,this.rejectNotRealIdCompliant=!1,this.rejectInconsistentData=!1,this.rejectHolderBelowAge=null,this.rejectIdsExpiringIn=null,this.rejectionTimeoutSeconds=6,this.notifyOnSideCapture=!1,this.properties={},this.imageToResult={},this.anonymizationMap=new Map,this[cr]={allowCloudScanning:this.allowCloudScanning.bind(this),documentsRequireCloudScanning:this.documentsRequireCloudScanning.bind(this),shouldEnableVIZScanner:this.shouldEnableVIZScanner.bind(this),validateScannerForCloudDocuments:this.validateScannerForCloudDocuments.bind(this),willScanInTheCloud:this.willScanInTheCloud.bind(this)},this.scanner=new le}setProperty(e,t){this.properties[e]=t}getProperty(e){return this.properties[e]}setShouldPassImageTypeToResult(e,t){this.imageToResult[e]=t}getShouldPassImageTypeToResult(e){var t;return null!=(t=this.imageToResult[e])&&t}addAnonymizedField(e,t){var a;let i=JSON.stringify(e.toJSONObject()),r=null!=(a=this.anonymizationMap.get(i))?a:new Set;r.add(t),this.anonymizationMap.set(i,r)}removeAnonymizedField(e,t){let a=JSON.stringify(e.toJSONObject()),i=this.anonymizationMap.get(a);void 0!==i&&(i.delete(t),0===i.size&&this.anonymizationMap.delete(a))}clearAnonymizedFields(){this.anonymizationMap.clear()}clone(){return e.fromJSON(this.toJSONObject())}toJSONObject(){var e,t,a;let i={};for(let[e,t]of this.anonymizationMap)i[e]=Array.from(t);return{acceptedDocuments:this.acceptedDocuments.map((e=>e.toJSONObject())),rejectedDocuments:this.rejectedDocuments.map((e=>e.toJSONObject())),scanner:this.scanner.toJSONObject(),imageToResult:{face:null!=(e=this.imageToResult.face)&&e,croppedDocument:null!=(t=this.imageToResult.croppedDocument)&&t,frame:null!=(a=this.imageToResult.frame)&&a},properties:this.properties,anonymizationMode:this.anonymizationMode,anonymizeDefaultFields:this.anonymizeDefaultFields,anonymizationMap:i,captureTrigger:this.captureTrigger,rejectVoidedIds:this.rejectVoidedIds,decodeBackOfEuropeanDrivingLicense:this.decodeBackOfEuropeanDrivingLicense,rejectExpiredIds:this.rejectExpiredIds,rejectNotRealIdCompliant:this.rejectNotRealIdCompliant,rejectInconsistentData:this.rejectInconsistentData,rejectHolderBelowAge:this.rejectHolderBelowAge,rejectIdsExpiringIn:this.rejectIdsExpiringIn?this.rejectIdsExpiringIn.toJSONObject():null,rejectionTimeoutSeconds:this.rejectionTimeoutSeconds,notifyOnSideCapture:this.notifyOnSideCapture}}allowCloudScanning(){var e;return null!=(e=this.scanner[I].getAllowCloudScanning())&&e}willScanInTheCloud(){return this.validateScannerForCloudDocuments()&&this.allowCloudScanning()}validateScannerForCloudDocuments(){var e;if(this.documentsRequireCloudScanning()){let t=this.scanner.physicalDocument;return null!=(e=(null==t?void 0:t.isSingleSideScanner())&&t.freeFormText)&&e}return!0}documentsRequireCloudScanning(){return this.acceptedDocuments.some((e=>"visaLetter"===e.documentType))}shouldEnableVIZScanner(){var e,t,a;return!this.documentsRequireCloudScanning()&&(!(null==(e=this.scanner.physicalDocument)||!e.isFullDocumentScanner())||null!=(a=null==(t=this.scanner.physicalDocument)?void 0:t.visualInspectionZone)&&a)}static fromJSON(t){var a,i,r;let n=new e;if(n.acceptedDocuments=t.acceptedDocuments.map((t=>e.createDocumentFromJSON(t))),n.rejectedDocuments=t.rejectedDocuments.map((t=>e.createDocumentFromJSON(t))),n.scanner=new le,null!=t.scanner.mobileDocument&&(n.scanner.mobileDocument=new $e),t.scanner.allowCloudScanning&&n.scanner[I].setAllowCloudScanning(!0),null!=t.scanner.physicalDocument)if("fullDocument"===t.scanner.physicalDocument.type)n.scanner.physicalDocument=new Qe;else{let e=t.scanner.physicalDocument;n.scanner.physicalDocument=new Ye(e.options.barcode,e.options.machineReadableZone,e.options.visualInspectionZone,null!=(a=e.options.freeFormText)&&a)}n.anonymizationMode=t.anonymizationMode,n.anonymizeDefaultFields=null==(i=t.anonymizeDefaultFields)||i,n.decodeBackOfEuropeanDrivingLicense=t.decodeBackOfEuropeanDrivingLicense,n.captureTrigger=t.captureTrigger,n.rejectVoidedIds=t.rejectVoidedIds,n.rejectExpiredIds=t.rejectExpiredIds,n.rejectNotRealIdCompliant=t.rejectNotRealIdCompliant,n.rejectInconsistentData=t.rejectInconsistentData,n.rejectHolderBelowAge=t.rejectHolderBelowAge;let s=t.rejectIdsExpiringIn;if(n.rejectIdsExpiringIn=s?new ye(s.days,s.months,s.years):null,n.rejectionTimeoutSeconds=null!=(r=t.rejectionTimeoutSeconds)?r:6,n.imageToResult={...t.imageToResult},n.properties={...t.properties},n.notifyOnSideCapture=t.notifyOnSideCapture,t.anonymizationMap)for(let[e,a]of Object.entries(t.anonymizationMap))n.anonymizationMap.set(e,new Set(a));return n}static createDocumentFromJSON(e){let t=e.documentType,a=e.region;switch(t){case"driverLicense":return new V(a);case"healthInsuranceCard":return new U(a);case"idCard":return new W(a);case"passport":return new H(a);case"residencePermit":return new K(a);case"visaIcao":return new Z(a);case"regionSpecific":return new G(e.documentSubtype);case"visaLetter":return new $(a)}}},lr=re;function Iu(e){Localization.getInstance().updateIfMissing({...wt});let t="boolean"==typeof(null==e?void 0:e.enableVIZDocuments)&&e.enableVIZDocuments;return{moduleName:"IdCapture",load:async e=>{if(e.loadProgressNotifier=t?Gt(e.loadProgressNotifier):e.loadProgressNotifier,e.threadsSupport=!1,e.verifyResponseHash=!0,ie=await pe.create(e),DataCaptureContext.moduleLicenseTextProviders.push(new de(ie)),!t)return Logger.log(Logger.Level.Debug,"VIZ scanning is disabled (enableVIZDocuments option was not passed to idCaptureLoader, or its value was false)"),ie;let a=(await ie.workerCommand("extractCentaurusLicense",{licenseKey:e.licenseKey})).centaurus.licenseKey;if(0===a.length)throw Logger.log(Logger.Level.Error,"Invalid license key: VIZ scanning is enabled in the options but the license key has no VIZ scanning enabled. Update the license key or disable VIZ scanning when calling idCaptureloader."),O.create({type:"InvalidLicenseKeyForVIZProcessing",message:"Invalid license key for VIZ scanning. Update license key or disable VIZ scanning."});return Logger.log(Logger.Level.Debug,"VIZ scanning is enabled, VIZ processor will be initialized"),await x.load({libraryLocation:`${e.libraryLocation}idcapture/`,licenseKey:a,logLevel:e.logLevel,loadProgressNotifier:e.loadProgressNotifier}),ie}}}function vu(e){ie=e}export{Se as AamvaBarcodeVerificationResult,Zt as AamvaBarcodeVerifier,nt as ApplicationStatus,we as BarcodeResult,se as CapturedId,Ur as CapturedSides,Re as DataConsistencyResult,m as DateResult,V as DriverLicense,qe as DrivingLicenseCategory,_ as DrivingLicenseDetails,ye as Duration,Qe as FullDocumentScanner,U as HealthInsuranceCard,I as INTERNAL_ACCESS,Gr as IdAnonymizationMode,sr as IdCapture,S as IdCaptureDocument,R as IdCaptureDocumentType,O as IdCaptureError,Xe as IdCaptureErrorCode,be as IdCaptureFeedback,or as IdCaptureOverlay,le as IdCaptureScanner,lr as IdCaptureSettings,Kr as IdCaptureTrigger,W as IdCard,Zr as IdFieldType,Wr as IdImageType,Qr as IdLayoutLineStyle,$r as IdLayoutStyle,Hr as IdSide,X as LocalizedOnlyId,Oe as MRZResult,$e as MobileDocumentScanner,H as Passport,te as PhysicalDocumentScanner,dt as PhysicalDocumentScannerType,ve as ProfessionalDrivingPermit,ta as Region,G as RegionSpecific,ua as RegionSpecificSubtype,ba as RejectionReason,K as ResidencePermit,y as STATE,Xr as Sex,Ye as SingleSideScanner,Yr as UsRealIdStatus,xe as VIZResult,De as VehicleRestriction,Z as VisaIcao,$ as VisaLetter,Iu as idCaptureLoader,ie as mainDataCaptureLoader,vu as setMainDataCaptureLoader};
//# sourceMappingURL=/sm/ad7e2aae348eac3a3ddc31bf84cfab234905b001b5d9cd10622e2d591f5ca450.map