UNPKG

scandit-web-datacapture-id

Version:

Scandit Data Capture SDK for the Web

6 lines (5 loc) 181 kB
import { CameraSettings, Color, Feedback, Sound, Quadrilateral, DataCaptureError, Logger, convertToPublicFrameData, Brush, Localization, OverrideState, DataCaptureLoader, BrowserHelper, isObject, assertUnreachable, Point } from 'scandit-web-datacapture-core'; import { match } from 'scandit-web-datacapture-core/build/js/private/utils/match.js'; import { ViewClassNames } from 'scandit-web-datacapture-core/build/js/private/ViewClassNames.js'; import { ShutterButton } from 'scandit-web-datacapture-core/build/js/private/ui/atoms/ShutterButton.js'; var h={"scandit-datacapture-sdk-id-pthreads.wasm":{bytes:8534920},"scandit-datacapture-sdk-id-simd.wasm":{bytes:9147899},"scandit-datacapture-sdk-id-simd-pthreads.wasm":{bytes:8695005},"scandit-datacapture-sdk-id.wasm":{bytes:8953392}};var re=(n=>(n.Undefined="Undefined",n.RecoveredAfterFailure="RecoveredAfterFailure",n.InvalidLicenseKeyForVIZProcessing="InvalidLicenseKeyForVIZProcessing",n.InvalidSettingsForVIZProcessing="InvalidSettingsForVIZProcessing",n.InvalidLicenseKeyForParser="InvalidLicenseKeyForParser",n))(re||{}),E=class e extends Error{constructor(){super(...arguments);this._type="Undefined";this._message="";}get type(){return this._type}get message(){return this._message}static create(r){let i=new e;return r&&(i.name=r.type,i._type=r.type,i._message=r.message),i}static fromJSON(r){let i=new e;return i._type=r.type,i._message=r.message,i}};var ft={"id.idCaptureOverlay.scanFrontSideHint":"","id.idCaptureOverlay.scanBackSideHint":"","id.idCaptureOverlay.moveCloseTextHint":"","id.idCaptureOverlay.moveFurtherAwayTextHint":"","id.idCaptureOverlay.tapShutterToScan":"","id.idCaptureOverlay.lookingForDocument":"","id.idCaptureOverlay.holdStill":""};var Sr=URL.createObjectURL(new Blob(['"use strict";(()=>{var C={"scandit-datacapture-sdk-id-pthreads.wasm":{bytes:8534920},"scandit-datacapture-sdk-id-simd.wasm":{bytes:9147899},"scandit-datacapture-sdk-id-simd-pthreads.wasm":{bytes:8695005},"scandit-datacapture-sdk-id.wasm":{bytes:8953392}};var o;(a=>{(s=>(s.Debug="debug",s.Info="info",s.Warn="warn",s.Error="error",s.Quiet="quiet"))(a.Level||(a.Level={}));let e=new Map([["debug",1],["info",2],["warn",3],["error",4],["quiet",5]]),t="debug";function r(s){t=s}a.setLevel=r;function i(s,...n){if(!(e.get(t)>e.get(s)))switch(s){case"debug":console.debug(...n);break;case"info":console.log(...n);break;case"warn":console.warn(...n);break;case"error":console.error(...n);break}}a.log=i})(o||(o={}));var A=class q extends Error{constructor(e){super(e.message),Object.setPrototypeOf(this,q.prototype),this.name=e.name}toString(){return`${this.name}: ${this.message}`}};var O=Promise.resolve(),E=!1,N=!1,v,T={writableDataPath:""};async function X(a){if(v==null)return;E=!0;let e=new Promise((t,r)=>{setTimeout(()=>{r(new A({name:"BlockedIndexedDB",message:"IndexedDB database is blocked"}))},1500)});try{await Promise.race([new Promise((t,r)=>{v?.(a,i=>{if(i!=null){r(i);return}t()})}),e])}finally{E=!1}}async function Y(a){return N||(E?(N=!0,O=O.then(async()=>(N=!1,X(a)))):O=X(a)),O}async function Z(a){T=a,v=FS.syncfs,FS.syncfs=(e,t)=>{let r=t,i=s=>{r(s)};Y(e).then(i).catch(i)};try{FS.mkdir(T.writableDataPath)}catch(e){if(e.code!=="EEXIST")throw v=void 0,e}return FS.mount(IDBFS,{},T.writableDataPath),Y(!0)}var z=(a,e)=>(e=Symbol[a])?e:Symbol.for("Symbol."+a);var H=function(a,e){this[0]=a,this[1]=e},Q=(a,e,t)=>{var r=(n,d,l,u)=>{try{var p=t[n](d),m=(d=p.value)instanceof H,c=p.done;Promise.resolve(m?d[0]:d).then(g=>m?r(n==="return"?n:"next",d[1]?{done:g.done,value:g.value}:g,l,u):l({value:g,done:c})).catch(g=>r("throw",g,l,u))}catch(g){u(g)}},i=n=>s[n]=d=>new Promise((l,u)=>r(n,d,l,u)),s={};return t=t.apply(a,e),s[z("asyncIterator")]=()=>s,i("next"),i("throw"),i("return"),s},ee=(a,e,t)=>(e=a[z("asyncIterator")])?e.call(a):(a=a[z("iterator")](),e={},t=(r,i)=>(i=a[r])&&(e[r]=s=>new Promise((n,d,l)=>(s=i.call(a,s),l=s.done,Promise.resolve(s.value).then(u=>n({value:u,done:l}),d)))),t("next"),t("return"),e);var te={};function Ie(a){return[...new Uint8Array(a)].map(e=>{let t=e.toString(16);return t.length===1?`0${t}`:t}).join("")}function be(a){return Q(this,null,function*(){let e=a.getReader();try{for(;;){let{done:t,value:r}=yield new H(e.read());if(t)return;yield r}}finally{e.releaseLock()}})}async function ve(a){let e=[],t=0,r=0;try{for(var i=ee(be(a)),s,n,d;s=!(n=await i.next()).done;s=!1){let u=n.value;e.push(u),t+=u.length}}catch(u){d=[u]}finally{try{s&&(n=i.return)&&await n.call(i)}finally{if(d)throw d[0]}}let l=new Uint8Array(t);for(let u of e)l.set(u,r),r+=u.length;return l.buffer}var we=(a=>(a.VALID="VALID",a.INVALID="INVALID",a.NOT_VERIFIABLE="NOT_VERIFIABLE",a))(we||{});async function Me(a,e,t){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 ${t} could not be verified`),"NOT_VERIFIABLE";try{let r=a instanceof Promise?await a:a,i=await crypto.subtle.digest("SHA-256",r),s=Ie(i);return e==null?(o.log(o.Level.Warn,"The library hash is not defined or empty, cannot correctly verify integrity."),"NOT_VERIFIABLE"):s===e?(o.log(o.Level.Debug,"Data Capture library WASM integrity has been verified correctly."),"VALID"):(o.log(o.Level.Warn,`The Scandit Data Capture library WASM file found at ${t} seems invalid: expected file hash doesn\'t match (received: ${s}, expected: ${e}). Please ensure the correct Scandit Data Capture file (with correct version) is retrieved.`),"INVALID")}catch(r){return o.log(o.Level.Warn,"Wasm response could not be verified",r),"NOT_VERIFIABLE"}}var B=new Map([["br",4.4],["gzip",2.9],["none",1]]);function xe(a){var e;let t="content-encoding";if(a==null||a.get(t)==null)return B.get("none");let r=new Set(((e=a.get(t))!=null?e:"").split(",").map(i=>i.trim()));for(let[i,s]of B)if(r.has(i))return s;return B.get("none")}function ke(a){var e,t;if(a==null)return 0;let r=(e=xe(a))!=null?e:1,i=Number.parseInt((t=a.get("content-length"))!=null?t:"0",10);return Number.isNaN(i)?0:Math.floor(i*r*100)/100}function Le(a){let{pathname:e}=new URL(a);for(let[t,r]of Object.entries(te))if(e.endsWith(t))return r.bytes;return 0}function ae(a){te=a}var Re=(a,e)=>{let t=ke(e);return t===0?Le(a):t};function Ae(a,e,t,{onProgress:r,onError:i,onComplete:s}){if(!e.body)return[e];let n=Re(a,e.headers),d=0,l=0,[u,p]=t?e.body.tee():[e.body],m=u.pipeThrough(new TransformStream({async transform(c,g){try{d+=c.length,l=Number((d/n*100).toFixed(2)),n>0&&c.length>0&&l<100?r?.({percentage:l,loadedBytes:d,privateUri:a}):n===0&&c.length>0&&r?.({percentage:null,loadedBytes:d,privateUri:a}),g.enqueue(c)}catch(S){g.error(S),i?.({error:S})}},flush(c){r?.({percentage:100,loadedBytes:d,privateUri:a}),s?.({percentage:100,loadedBytes:d,privateUri:a}),c.terminate()}}));return[new Response(m,{headers:new Headers(e.headers),status:e.status,statusText:e.statusText}),p]}async function J({wasmURI:a,expectedHash:e,verifyResponseHash:t,onProgress:r,onComplete:i,onError:s,referredOrigin:n}){let d=await fetch(a,{referrerPolicy:"origin",referrer:n??""});if(!d.ok)throw new Error(`HTTP status code is not ok: ${d.status}, ${d.statusText}`);let[l,u]=Ae(a,d,t,{onProgress:r,onError:s,onComplete:i});return u!=null&&Me(ve(u),e,a),l}function re({wasmURI:a,expectedHash:e,verifyResponseHash:t,progressCallback:r,successCallback:i,importObject:s,referredOrigin:n}){async function d(u){try{let p=await J({wasmURI:a,expectedHash:e,verifyResponseHash:t,onProgress:r,referredOrigin:n}),m=await(u??p).arrayBuffer(),c=await globalThis.WebAssembly.instantiate(m,s);i(c.instance,c.module)}catch(p){o.log(o.Level.Error,p),o.log(o.Level.Error,`Couldn\'t instantiate Scandit SDK DataCapture library at ${a}, did you configure the path for it correctly?`)}}async function l(){let u;try{u=await J({wasmURI:a,expectedHash:e,verifyResponseHash:t,onProgress:r,referredOrigin:n});let p=await globalThis.WebAssembly.instantiateStreaming(u,s);i(p.instance,p.module)}catch(p){o.log(o.Level.Warn,p),o.log(o.Level.Warn,"WebAssembly streaming compile failed. Falling back to ArrayBuffer instantiation (this will make things slower)"),d(u?.bodyUsed===!0?void 0:u)}}typeof globalThis.WebAssembly.instantiateStreaming=="function"?l():d()}async function _(a,e,t,r){return new Promise((i,s)=>{a().then(i).catch(n=>{let d=e*2;if(d>t){s(n);return}r(n),globalThis.setTimeout(()=>{_(a,d,t,r).then(i).catch(s)},e)})})}function U(a){var e,t;let r="";if((e=a.href)!=null&&e.startsWith("blob:null/"))r="localhost";else{let i=((t=a.pathname)==null?void 0:t.length)>1&&!a.pathname.startsWith("/");r=new URL(i?a.pathname:a.origin).hostname}return r.startsWith("[")&&r.endsWith("]")&&(r=r.slice(1,-1)),r}async function se(a,e){async function t(){return importScripts(a)}try{await _(t,250,4e3,i=>{o.log(o.Level.Warn,i),o.log(o.Level.Warn,`Couldn\'t retrieve Scandit Data Capture library at ${a}, retrying...`)}),self.Module.mainScriptUrlOrBlob=a;let r=globalThis.SDC_WASM_JS_VERSION;return r!==e&&o.log(o.Level.Warn,`The Scandit Data Capture library JS file found at ${a} seems invalid: expected version doesn\'t match (received: ${r}, expected: ${e}). Please ensure the correct Scandit Data Capture file (with correct version) is retrieved.`),!0}catch(r){return o.log(o.Level.Error,r),!1}}function Oe(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 Fe(a){let e=/scandit-web-datacapture-[a-z]+/i.exec(a);return e?e[0]:null}function ie(a,e,t){let r=e,i=Oe(r);if(i.result){let n=Fe(r);n!=null&&(r=`${i.cdnBaseURL}${n}@${a}/build/engine/`)}let s=t.replace(".wasm","");return i.result?{jsURI:`${r}${s}.js`,wasmURI:`${r}${s}.wasm`}:{jsURI:`${r}${s}.js?v=${a}`,wasmURI:`${r}${s}.wasm?v=${a}`}}var F;(a=>{function e(){return"6.28.7"}a.sdkVersion=e})(F||(F={}));var ne=class{constructor(){this.promise=new Promise((a,e)=>{this.reject=e,this.resolve=a})}};var Pe=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),We=()=>(async a=>{try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(a)}catch{return!1}})(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]));function Ve(){return typeof crossOriginIsolated>"u"?!1:crossOriginIsolated}function Ne(){try{return new WebAssembly.Memory({initial:1,maximum:1,shared:!0}).buffer.constructor.name==="SharedArrayBuffer"}catch{return!1}}async function oe(){return Pe()}async function Te(){if(!await We())return!1;let a=null;try{a=new Worker(URL.createObjectURL(new Blob([\'postMessage("Worker" in self);\'],{type:"text/javascript"})),{name:"nestedWorkerTest"})}catch{return!1}return new Promise(e=>{if(a==null){e(!1);return}a.onmessage=t=>{a?.terminate(),e(t.data)}})}async function de(){let a=await Te();return Ve()&&Ne()&&a}var ue=class le{constructor(e,t){this.hintPresenterV2=null,this.MAX_NUMBER_OF_IMAGES_IN_FRAME_DATA_POOL=10,this.redrawInterval=1e3/30,this.redrawRequests=[],this._isDrawLoopRunning=!1,this.frameDataPool=new Map,this.lastFrameCounter=-1,this.poorMansBenchmarkLogs=!1,this.writableDataPathStandard="/scandit_sync_folder",this.resourceFilesSubfolder="resources",this.performanceMetricsReporterTimer=void 0,this.performanceMetrics={frameDataPoolSize:0,processedFramesCount:0,redrawRequestsCount:0,actualRedrawsCount:0},this.gestureListener=null,this.webPlatformHintPresenter=null,this.moduleHandler=e,this.workerFunctions=t,this._loadProgressCallback=this._loadProgressCallback.bind(this),ae(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}convertToLoadableFrameData(e){let t=this.getNextFrameId();this.frameDataPool.set(t,new Uint8ClampedArray(e.getFrameData()));let r=this.lastUsedModuleMirrorAxis==null?!1:this.lastUsedModuleMirrorAxis!==this.Module.Axis.None;return{frameId:t,width:e.getWidth(),height:e.getHeight(),isFrameSourceMirrored:r}}createContext(e){var t,r,i,s,n;let d=this.getModeDeserializers(),l=U(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,d,e.delayedRegistration,e.highEndBlurryRecognition,this.resourcePath);let u=this.contextDeserializer.contextFromJson(JSON.stringify(e.context));if(u==null)throw new Error("Could not create the context");let p=u.getView();this.context=u.getContext(),u.delete();let m=this.Module.DataCaptureContextListener.extend("DataCaptureContextListener",{didChangeStatus:(h,D)=>{this.contextDidChangeStatus(JSON.parse(D.toJson()))},didStartObservingContext:()=>{this.didStartObservingContext()}}),c=this.Module.DataCaptureContextFrameListener.extend("DataCaptureContextFrameListener",{onObservationStarted:h=>{},onObservationStopped:h=>{},onFrameProcessingStarted:(h,D)=>{this.workerFunctions.postMessage({type:"onFrameProcessingStarted"})},onFrameProcessingFinished:(h,D)=>{this.workerFunctions.postMessage({type:"onFrameProcessingFinished"})},onFrameSkipped:(h,D)=>{this.workerFunctions.postMessage({type:"onFrameSkipped"})}}),g=this.Module.GestureRecognizer.extend("GestureRecognizer",{setGestureListener:(h,D)=>{var L;(L=this.gestureListener)==null||L.delete(),this.gestureListener=h.clone()}});(t=this.gestureRecognizer)==null||t.delete(),this.gestureRecognizer=new g;let S=new m;this.context.addListener(S),S.delete();let I=new c;this.context.addFrameListener(I),I.delete(),this.setView(p),(r=this.view)==null||r.setGestureRecognizer(this.gestureRecognizer);let b=this.Module.PlatformHintPresenter.extend("PlatformHintPresenter",{setHintPresenter:h=>{},showToast:h=>{this.workerFunctions.postMessage({type:"showToast",payload:JSON.parse(h)})},hideToast:h=>{this.workerFunctions.postMessage({type:"hideToast",payload:JSON.parse(h)})},showGuidance:h=>{this.workerFunctions.postMessage({type:"showGuidance",payload:JSON.parse(h)})},hideGuidance:h=>{this.workerFunctions.postMessage({type:"hideGuidance",payload:JSON.parse(h)})},startUpdateTimer:h=>{this.workerFunctions.postMessage({type:"startUpdateTimer",payload:{duration:{unit:"ms",value:h}}})},stopUpdateTimer:()=>{this.workerFunctions.postMessage({type:"stopUpdateTimer"})}});(i=this.hintPresenterV2)==null||i.delete(),(s=this.webPlatformHintPresenter)==null||s.delete(),this.webPlatformHintPresenter=new b,this.hintPresenterV2=new this.Module.HintPresenterV2(this.webPlatformHintPresenter),(n=this.view)==null||n.setHintPresenterV2(this.hintPresenterV2)}onTap(e){var t;(t=this.gestureListener)==null||t.onTap(JSON.stringify(e))}hintPresenterV2Update(){var e;(e=this.hintPresenterV2)==null||e.update()}startReportingPerformanceMetrics(){this.performanceMetricsReporterTimer==null&&(this.performanceMetricsReporterTimer=setInterval(()=>{this.reportPerformanceMetrics();for(let e of Object.keys(this.performanceMetrics))this.performanceMetrics[e]=0},1e3))}async reportPerformanceMetrics(){this.workerFunctions.postMessage({type:"performanceMetricsReport",payload:{...this.performanceMetrics}})}deleteFrameData(e){this.frameDataPool.delete(e)}dispose(){var e,t;this.context.dispose(),this.frameDataPool.clear(),this.isDrawLoopRunning=!1,this.lastFrameCounter=-1,(e=this.gestureRecognizer)==null||e.delete(),this.gestureRecognizer=null,(t=this.gestureListener)==null||t.delete(),this.gestureListener=null}flushAnalytics(){this.context.flushAnalytics()}extractCentaurusLicense(e){return{payload:{centaurus:{licenseKey:this.Module.LicenseUtils[le.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 t;if(this.context==null)return{payload:e,transferables:[e.data.buffer]};let r=e.data,i=e.colorType==="GRAYSCALE"?this.Module.ImageBufferFormat.Grayscale8:this.Module.ImageBufferFormat.Rgba8888,s=this.Module.allocateUint8Array(r.byteLength);return this.Module.HEAPU8.set(r,s),(t=this.imageFrameSource)==null||t.outputFrame(s,e.width,e.height,i),{payload:e,transferables:[e.data.buffer]}}reportCameraProperties(e){this.context.setCameraProperties(e.deviceId,e.isFrontFacing,e.hasAutofocus)}requestFrameData(e){let t=this.frameDataPool.get(e);return t==null?{payload:{data:null}}:{payload:{data:t},transferables:[t.buffer]}}scheduleRedraw(e,t){this.addRedrawRequest(t),this.isDrawLoopRunning||this.startDrawLoop(e)}sendViewRefreshCommands(e){this.workerFunctions.postMessage({type:"draw",payload:e},[e.buffer])}setFrameSource(e,t){var r;this.lastUsedModuleMirrorAxis=this.mapMirrorAxisOnModule(e),(r=this.imageFrameSource)==null||r.delete(),this.imageFrameSource=new this.Module.ImageBufferFrameSource(this.lastUsedModuleMirrorAxis,t,0),this.context.setFrameSource(this.imageFrameSource)}startDrawLoop(e){this.isDrawLoopRunning=!0;let t=s=>this.redrawRequests.length>0&&this.redrawRequests[0]<=s,r=s=>{for(;this.redrawRequests.length>0&&this.redrawRequests[0]<=s;)this.redrawRequests.shift()},i=()=>{this.loopTimeoutId=setTimeout(()=>{if(!this.isDrawLoopRunning)return;let s=performance.now();if(t(s)){r(s),e.draw();let n=e.getDrawCommands();this.sendViewRefreshCommands(new Uint8Array(n))}i()},this.redrawInterval)};i()}updateContext(e){if(this.context!=null&&this.contextDeserializer!=null){e.view!=null&&!e.view.visible&&this.context.flushAnalytics();let t=this.contextDeserializer.updateContextFromJson(this.context,this.view,JSON.stringify(e.context));if(t==null)throw new Error("Could not update the context");this.context.delete(),this.context=t.getContext();let r=t.getView();t.delete(),r!=null&&e.view!=null&&r.setViewSize(e.view.width,e.view.height,e.view.orientation),this.hintPresenterV2!=null&&r?.setHintPresenterV2(this.hintPresenterV2),this.gestureRecognizer!=null&&r?.setGestureRecognizer(this.gestureRecognizer),this.setView(r),o.log(o.Level.Debug,"context updated",e)}}onDocumentVisibilityChange(e){e==="hidden"&&this.context.flushAnalytics()}isFeatureSupported(e){return{payload:{supported:this.context.isFeatureSupported(e)}}}getViewfinderInfo(){var e,t;return{payload:{isDisplayingViewfinder:(t=(e=this.view)==null?void 0:e.isDisplayingViewfinder())!=null?t:!1,rect:JSON.parse(this.view.getViewfinderRect())}}}getNextFrameId(){return this.lastFrameCounter++,this.lastFrameCounter>=this.MAX_NUMBER_OF_IMAGES_IN_FRAME_DATA_POOL&&(this.lastFrameCounter=0),this.lastFrameCounter}getWasmDynamicLibraries(e){return this.getWasmSideModuleFileName()==null?[]:[`${e.replace(/\\/[^/]*$/,"/")}${this.getWasmSideModuleFileName()}`]}getWasmCoreExpectedHash(e,t){return t?e?"c4c1c9fe966a735bc4ed5e8c53cbaf5a06e1fda0b18c9ccb04bf561966178f4f":"49e6d934782440ca6764c902aabc2714fc161b4ffce8ab644ac1d9914b32fd21":e?"c9e2b50dc2808dc240989e13b3509205e282685b14c6ea50244d50b2a27d6ca4":""}getWasmCoreFileName(e,t){return t?e?"scandit-datacapture-sdk-id-simd-pthreads.wasm":"scandit-datacapture-sdk-id-pthreads.wasm":e?"scandit-datacapture-sdk-id-simd.wasm":""}getWasmMetadata(){return C}getWasmSideModuleFileName(){return""}_loadProgressCallback(e){this.workerFunctions.postMessage({type:"loadLibraryProgress",payload:e})}addRedrawRequest(e){this.redrawRequests.push(Math.round(performance.now())+e),this.redrawRequests.sort((t,r)=>t-r)}contextDidChangeStatus(e){e.code===260?e.message=e.message.replace("domain name",`domain name (${U(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([])))}setViewRefreshHandler(e){if(e==null||e.isViewRefreshHandlerSet)return;let t=this.Module.NeedsRedrawDelegate.extend("NeedsRedrawDelegate",{setNeedsRedrawIn:this.scheduleRedraw.bind(this,e)}),r=new t;e.setNeedsRedrawDelegate(r),e.isViewRefreshHandlerSet=!0}setupDataDecoding(){let e=this.moduleHandler.get(),t=e.DataDecoding.extend("DataDecoding",{decode(r,i){try{let s=JSON.parse(i),n=[];for(let d of s){let l=new TextDecoder(d.ianaName,{fatal:!0});n.push(l.decode(r.slice(d.startIndex,d.endIndex)))}return n.join("")}catch{return""}}});e.setDataDecoding(new t)}start(e,t,r){e&&t&&(this.setupDataDecoding(),this.moduleHandler.get().callMain(),typeof this.moduleHandler.get().PThread=="object"||r())}getWritableDataPath(e){return e!=null?(o.log(o.Level.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:t,writableDataPathOverride:r,overrideThreadsSupport:i,overrideSimdSupport:s,verifyResponseHash:n,referredOrigin:d,fixedWasmMemory:l}){var u;let p=!1,m=!1;this.writableDataPath=this.getWritableDataPath(r),this.resourcePath=`${e}${this.resourceFilesSubfolder}/`,globalThis.path=t;let{resolve:c,reject:g,promise:S}=new ne,I=F.sdkVersion();if(I==="")throw new A({name:"Invalid library version",message:"Library version is not defined or empty, cannot generate proper path to library files."});let[b,h]=await Promise.all([oe(),de()]);i!=="auto"&&(h=i==="on"),s!=="auto"&&(b=s==="on");let D=this.getWasmCoreFileName(b,h),L=ie(I,e,D),{jsURI:V,wasmURI:G}=L,ye={instantiateWasm:(y,Se)=>(re({importObject:y,wasmURI:G,expectedHash:this.getWasmCoreExpectedHash(b,h),verifyResponseHash:n,successCallback:Se,progressCallback:this._loadProgressCallback,referredOrigin:d}),{})},R=l===null?null:new WebAssembly.Memory({initial:this.numOfMBToPages(l),maximum:this.numOfMBToPages(l),shared:h});return R!==null&&o.log(o.Level.Debug,"Fixed wasmMemory set",R),this.moduleHandler.set({...R?{wasmMemory:R}:{},mainScriptUrlOrBlob:V,canvas:(u=this.workerFunctions.getOffscreenCanvas())!=null?u:{getContext:()=>null},...ye,dynamicLibraries:this.getWasmDynamicLibraries(G),locateFile:y=>e+y,noInitialRun:!0,preRun:[async()=>{try{await Z({writableDataPath:this.writableDataPath})}catch(y){if(y.name==="BlockedIndexedDB"){g(y.toString());return}o.log(o.Level.Debug,"No IndexedDB support, some data will not be persisted:",y)}m=!0,this.start(m,p,c)}],onMainComplete:()=>{if([p,m].includes(!1)){o.log(o.Level.Warn,{runtimeLoaded:p,fileSystemSynced:m},"Both runtimeLoaded and fileSystemSynced should be true when calling onMainComplete"),g("onMainComplete has been called but runtime or file system was not ready.");return}c()},onRuntimeInitialized:()=>{p=!0,this.start(m,p,c)},print:y=>{o.log(o.Level.Info,y)}}),await se(V,I)||g(`Couldn\'t retrieve Scandit Data Capture library at ${V}, did you configure the path for it correctly?`),S}};ue.get3dPartyLicenseKeyMethodName=atob("Z2V0QmxpbmtJZExpY2Vuc2VLZXk=");var w=ue;function M(a){return typeof a=="object"&&a!=null}function x(a){if(typeof a=="string")return a;if(M(a)){if(typeof a.message=="string")return a.message}else if(typeof a?.toString=="function")return a.toString();return"unknown error"}function pe(a){return typeof a=="object"&&a!=null&&a.document==null&&"addEventListener"in a&&typeof a.importScripts=="function"}function ce(a){console.warn("Reached unexpected case",a)}var $=class{constructor(a,e){this.onMessageListener=this.onMessage.bind(this),this.workerSelf=a,this.dataCaptureInstance=new w(e,{postMessage:this.postMessage.bind(this),getOffscreenCanvas:this.getOffscreenCanvas.bind(this)}),pe(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??[])}getOffscreenCanvas(){if(typeof this.workerSelf.OffscreenCanvas=="function")return new this.workerSelf.OffscreenCanvas(32,32)}hasPayload(a){return M(a)&&"payload"in a}hasTransferables(a){return M(a)&&Array.isArray(a.transferables)}async respondWith(a,e,t){let r=null,i;try{i=t(),i instanceof Promise&&(i=await i)}catch(n){i=void 0,r=x(n)}let s={type:"workerTaskId",command:a,id:e,payload:this.hasPayload(i)?i.payload:void 0};r!=null&&(s.error=r),this.postMessage(s,this.hasTransferables(i)?i.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,overrideThreadsSupport:e.overrideThreadsSupport,overrideSimdSupport:e.overrideSimdSupport,verifyResponseHash:e.verifyResponseHash,fixedWasmMemory:e.fixedWasmMemory}))}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}))}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,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"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}default:return ce(a.data),!1}return!0}};var me={"core.view.loading":"Loading the Scandit SDK...","core.singleImageUploader.title":"Analyze an image from your device.","core.singleImageUploader.button":"Choose an Image","core.camera.recovery":"Tap/click to resume scanning","barcode.find.view.textForCollapseCardsButton":"Collapse Cards"};var Ce=class k{constructor(){this.translations=new Map}static getInstance(){return k.instance==null&&(k.instance=new k),k.instance}get(e){var t;return(t=this.translations.get(e))!=null?t:""}getAll(){return{...this.translations}}update(e){this.translations=new Map(Object.entries({...Object.fromEntries(this.translations),...e}))}updateIfMissing(e){for(let[t,r]of Object.entries(e))this.translations.has(t)||this.translations.set(t,r)}};Ce.getInstance().updateIfMissing(me);function he(a){return a.ok()}function ge(a,e){return he(a)?a.value():e}function fe(a,e){return he(a)?e:a.error()}function Ee(a){return a.has_value()}function f(a,e){return Ee(a)?a.value():e}function j(a){if(typeof a=="string")try{return JSON.parse(a)}catch{return null}return null}var P=class extends w{constructor(t,r){super(t,r);this.lastIdCaptureModeSerializedSettings=""}processFrame(t){return this.idCaptureMode.isReadyToProcessFrame()?super.processFrame(t):{payload:t,transferables:[t.data.buffer]}}updateContext(t){super.updateContext(t),this.idCaptureMode.start()}idCaptureSetLastResult(t){this.idCaptureMode.setLastResult(t)}idCaptureSetLastError(t){this.idCaptureMode.setLastError(t)}idCaptureSetLastLocalizedId(t){this.idCaptureMode.setLastLocalizedId(t)}idCaptureSetLastDetectionIssue(t){this.idCaptureMode.setLastDetectionIssue(t)}async idCaptureReset(){this.idCaptureMode.reset()}async idCaptureApplySettings(t){return this.idCaptureMode.applySettings(t)}async idCaptureParse(t){return{payload:{result:this.idCaptureMode.parse(t)}}}idCaptureVerifyAamvaCapture(t){return{payload:{result:this.idCaptureMode.idCaptureVerifyAamvaCapture(t)}}}idCaptureVerifyVizMrzCapture(t){return{payload:{result:this.idCaptureMode.idCaptureVerifyVizMrzCapture(t)}}}async idCaptureBarcodeVerifyAamvaCapture(t,r){return{payload:{result:await this.idCaptureMode.idCaptureBarcodeVerifyAamvaCapture(t,r)}}}idCaptureDrivingLicenseDetailsCreateWithBlinkIdData(t,r,i){let s=this.Module.DrivingLicenseDetails.createWithBlinkIdData(t,r,i);return{payload:{result:JSON.parse(s)}}}getModeDeserializers(){this.idCaptureMode=new K(this,this.Module,this.workerFunctions),this.idCaptureMode.start();let t=super.getModeDeserializers();return t.push_back(this.idCaptureMode.getDeserializer()),t}getWasmSideModuleFileName(){return""}getWasmCoreFileName(t,r){return r?t?"scandit-datacapture-sdk-id-simd-pthreads.wasm":"scandit-datacapture-sdk-id-pthreads.wasm":t?"scandit-datacapture-sdk-id-simd.wasm":"scandit-datacapture-sdk-id.wasm"}getWasmCoreExpectedHash(t,r){return r?t?"c4c1c9fe966a735bc4ed5e8c53cbaf5a06e1fda0b18c9ccb04bf561966178f4f":"49e6d934782440ca6764c902aabc2714fc161b4ffce8ab644ac1d9914b32fd21":t?"c9e2b50dc2808dc240989e13b3509205e282685b14c6ea50244d50b2a27d6ca4":"af3aa70cdf04e021d0f67f77bd16582992f0b632e4e3a9905936810ebbe2d56d"}getWasmMetadata(){return C}},K=class{constructor(e,t,r){this.SDCIdCaptureMode=null;this.listenerSet=!1;this.lastResult="";this.lastError="";this.lastLocalizedId="";this.lastDetectionIssue="";this._state="initial";this.coreEngine=e,this.Module=t,this.workerFunctions=r,this.state="created"}get state(){return this._state}set state(e){this._state=e}isReadyToProcessFrame(){return this.state==="started"}setLastResult(e){this.lastResult=e}setLastError(e){this.lastError=e}setLastLocalizedId(e){this.lastLocalizedId=e}setLastDetectionIssue(e){this.lastDetectionIssue=e}async applySettings(e){this.SDCIdCaptureMode?.applySettings(JSON.stringify(e))}reset(){this.SDCIdCaptureMode?.reset()}parse(e){if(this.SDCIdCaptureMode){let t=this.SDCIdCaptureMode.parse(e);if(t.ok()){let r=ge(t,null);if(r!=null){let i=JSON.parse(r.toJson()),s=this.buildCapturedIdFromCommonFields(r,i);if(s!=null)return{status:"success",capturedId:s}}}else return{status:"error",error:fe(t,"Undefined error")}}return null}idCaptureVerifyAamvaCapture(e){let r=new this.Module.AamvaVizBarcodeComparisonVerifier().verify(JSON.stringify(e));return JSON.parse(r.toJson())}idCaptureVerifyVizMrzCapture(e){let r=new this.Module.VizMrzComparisonVerifier(this.coreEngine.context).verify(JSON.stringify(e));return JSON.parse(r.toJson())}async idCaptureBarcodeVerifyAamvaCapture(e,t){return new Promise(r=>{let i=this.Module.AamvaBarcodeVerifier.extend("AamvaBarcodeVerifier",{retriggerVerificationIn(n){setTimeout(()=>{s.startVerification(JSON.stringify(e))},n)},verificationEnded(){let n=s.getBarcodeVerificationResponse();r({isSuccess:n.isSuccess,error:n.error,allChecksPassed:n.allChecksPassed,serverResponseJSON:n.serverResponseJson})}}),s=new i;s.initialize(this.coreEngine.context,t??""),s.startVerification(JSON.stringify(e))})}start(){if(this.initHintPresenterIfNotInitialized(),this.state==="started")return;let e=this.Module.IdCaptureListener.extend("IdCaptureListener",{onSessionUpdated:(p,m,c)=>{this.onSessionUpdated(m,c)},onIdCaptured:(p,m,c)=>{this.onIdCapturedCallback(m,c)},onIdLocalized:(p,m,c)=>{this.onIdLocalizedCallback(m,c)},onIdRejected:(p,m,c)=>{this.onIdRejectedCallback(m,c)},onIdCaptureTimedOut:(p,m,c)=>{this.onIdCaptureTimedOutCallback(m,c)},onShutterButtonPositionChanged:p=>{this.onShutterButtonPositionChangedCallback(p)},onShutterButtonStateChanged:p=>{this.onShutterButtonStateChangedCallback(p)}}),t=this.Module.Feedback.extend("Feedback",{emit:()=>{this.workerFunctions.postMessage({type:"idCaptureIdCapturedFeedback"})}}),r=this.Module.Feedback.extend("Feedback",{emit:()=>{this.workerFunctions.postMessage({type:"idCaptureIdRejectedFeedback"})}}),i=this.Module.Feedback.extend("Feedback",{emit:()=>{this.workerFunctions.postMessage({type:"idCaptureIdCaptureTimeoutFeedback"})}}),s=this.Module.IdCaptureDeserializerListener.extend("IdCaptureDeserializerListener",{onModeDeserializationFinished:(p,m)=>{if(!this.listenerSet){let c=new e;m.addListener(c),c.delete(),this.listenerSet=!0,m.setFeedbacks(new t,new r,new i)}},onModeDeserializationStarted(){},onSettingsDeserializationStarted(){},onSettingsDeserializationFinished(){}}),n=this.Module.IdCaptureBackend.extend("IdCaptureBackend",{getLastError:()=>this.lastError,getLastResult:()=>this.lastResult,getLocalizedOnlyId:()=>this.lastLocalizedId,getLastIssue:()=>this.lastDetectionIssue,processFrame:()=>{},reset:this.onResetFromSDC.bind(this),setDetectionOnlyMode:this.setDetectionOnlyMode.bind(this)}),d=this.Module.IdCaptureDeserializerHelper.extend("IdCaptureDeserializerHelper",{createMode:(p,m)=>{this.SDCIdCaptureMode!=null&&this.SDCIdCaptureMode.delete();let c=new n;return this.SDCIdCaptureMode=new this.Module.IdCapture(p,c,m,null),c.delete(),this.SDCIdCaptureMode}}),l=new d;this.idCaptureDeserializer=new this.Module.IdCaptureDeserializer(l),l.delete();let u=new s;this.idCaptureDeserializer.setListener(u),u.delete(),this.state="started"}onResetFromSDC(){this.workerFunctions.postMessage({type:"idCaptureBackendReset"}),this.lastError="",this.lastResult="",this.lastLocalizedId=""}setDetectionOnlyMode(e){this.workerFunctions.postMessage({type:"idCaptureDetectionOnlyMode",payload:{detectionOnlyMode:e}})}onSessionUpdated(e,t){let r=this.parseIdCaptureSession(e),i=this.coreEngine.convertToLoadableFrameData(t);this.workerFunctions.postMessage({type:"idCaptureDidUpdateSession",payload:{session:{...r,newlyCapturedId:this.buildCapturedIdFromSession(e,r.newlyCapturedId)},frameData:i}})}onIdCapturedCallback(e,t){let r=this.parseIdCaptureSession(e);if(r.newlyCapturedId){let i=this.buildCapturedIdFromSession(e,r.newlyCapturedId),s=this.coreEngine.convertToLoadableFrameData(t);this.workerFunctions.postMessage({type:"idCaptureDidCaptureId",payload:{session:{...r,newlyCapturedId:i},frameData:s}})}}buildCapturedIdFromSession(e,t){let r=f(e.getCapturedId(),null);return r&&t?this.buildCapturedIdFromCommonFields(r,t):null}buildCapturedIdFromCommonFields(e,t){if(e&&t){let r={firstName:f(e.getFirstName(),""),lastName:f(e.getLastName(),""),secondaryLastName:f(e.getSecondaryLastName(),""),fullName:e.getFullName(),sex:f(e.getSex(),""),age:f(e.getAge(),null),isExpired:f(e.isExpired(),null),nationality:f(e.getNationality(),""),address:f(e.getAddress(),""),issuingCountry:f(e.getIssuingCountry(),""),issuingCountryIso:f(e.getIssuingCountryIso(),""),documentNumber:f(e.getDocumentNumber(),""),documentAdditionalNumber:f(e.getDocumentAdditionalNumber(),""),dateOfBirth:j(f(e.getDateOfBirth(),null)),dateOfExpiry:j(f(e.getDateOfExpiry(),null)),dateOfIssue:j(f(e.getDateOfIssue(),null)),documentType:e.getDocumentType()};return e.delete(),{...r,...t}}return null}onIdLocalizedCallback(e,t){let r=this.parseIdCaptureSession(e);if(r.localizedOnlyId){let i=this.coreEngine.convertToLoadableFrameData(t);this.workerFunctions.postMessage({type:"idCaptureDidLocalizeId",payload:{session:r,frameData:i}})}}onIdRejectedCallback(e,t){let r=this.parseIdCaptureSession(e);if(r.newlyRejectedId){let i=this.coreEngine.convertToLoadableFrameData(t);this.workerFunctions.postMessage({type:"idCaptureDidRejectId",payload:{session:r,frameData:i}})}}onIdCaptureTimedOutCallback(e,t){let r=this.parseIdCaptureSession(e),i=this.coreEngine.convertToLoadableFrameData(t);this.workerFunctions.postMessage({type:"idCaptureDidTimedOut",payload:{session:r,frameData:i}})}onShutterButtonPositionChangedCallback(e){this.workerFunctions.postMessage({type:"idCaptureDidShutterButtonPositionChanged",payload:{position:JSON.parse(e)}})}onShutterButtonStateChangedCallback(e){this.workerFunctions.postMessage({type:"idCaptureDidShutterButtonStateChanged",payload:{state:e}})}parseIdCaptureSession(e){return JSON.parse(e.toJson())}getDeserializer(){return this.idCaptureDeserializer}dispose(){this.state==="started"&&(this.idCaptureDeserializer.delete(),this.lastError="",this.lastLocalizedId="",this.lastResult="",this.listenerSet=!1,this.state="disposed")}restart(){this.dispose(),this.start()}isReadyToDisplayHints(){return this.coreEngine.view?this.coreEngine.view.hintPresenterInitialized():!1}initHintPresenterIfNotInitialized(){if(this.isReadyToDisplayHints())return;let e=this.Module.HintPresenter.extend("HintPresenter",{showHint:(t,r)=>{this.workerFunctions.postMessage({type:"showHint",payload:{text:t,style:JSON.parse(r)}})},updateHint:t=>{this.workerFunctions.postMessage({type:"updateHint",payload:{style:JSON.parse(t)}})},hideHint:()=>{this.workerFunctions.postMessage({type:"hideHint",payload:{}})}});this.coreEngine.view?.setHintPresenter(new e)}};var W=class extends ${constructor(e,t){super(e,t),this.dataCaptureInstance=new P(t,{postMessage:this.postMessage.bind(this),getOffscreenCanvas:this.getOffscreenCanvas.bind(this)})}async respondWith(e,t,r){let i=null,s;try{s=r(),s instanceof Promise&&(s=await s)}catch(d){o.log(o.Level.Debug,d),s=void 0,i=x(d)}let n={type:"workerTaskId",command:e,id:t,payload:this.hasPayload(s)?s.payload:void 0};i!=null&&(n.error=i),this.postMessage(n,this.hasTransferables(s)?s.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"idCaptureReset":{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>this.dataCaptureInstance.idCaptureReset()),!0}case"idCaptureApplySettings":{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>this.dataCaptureInstance.idCaptureApplySettings(t.settings)),!0}case"idCaptureParse":{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>this.dataCaptureInstance.idCaptureParse(t.code)),!0}case"idCaptureVerifyAamvaCapture":{let{data:t}=e;return this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.idCaptureVerifyAamvaCapture(t.capturedId)),!0}case"idCaptureBarcodeVerifyAamvaCapture":{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>this.dataCaptureInstance.idCaptureBarcodeVerifyAamvaCapture(t.capturedId,t.endpoint)),!0}case"idCaptureVerifyVizMrzCapture":{let{data:t}=e;return this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.idCaptureVerifyVizMrzCapture(t.capturedId)),!0}case"idCaptureDrivingLicenseDetailsCreateWithBlinkIdData":{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>this.dataCaptureInstance.idCaptureDrivingLicenseDetailsCreateWithBlinkIdData(t.details.vehicleClass,t.details.restrictions,t.details.endorsements)),!0}default:return super.onMessage(e)}}};var Ia=new W(globalThis,{get:()=>globalThis.Module,set:a=>{globalThis.Module=a}});function ba(a){}})();\n'],{type:"application/javascript"}));function Ct(e){return new Worker(Sr,e)}var ie=class e extends DataCaptureLoader{constructor(){super(...arguments);this._name="IdCapture";}get dataCaptureWorker(){return (this._dataCaptureWorker)!=null||(this._dataCaptureWorker=Ct({name:this.name})),this._dataCaptureWorker}get name(){return this._name}get fixedWasmMemory(){return BrowserHelper.isIPhone()&&BrowserHelper.isSafari()?256:null}static async create(r){var a;let i=new e(r);return i.workerCommand("setLogLevel",{level:(a=r.logLevel)!=null?a:Logger.Level.Debug}),await i.load(),i}async workerCommand(...r){let[i,a,n]=r;return new Promise((o,c)=>{let d=this.workerCommandId++;this.workerTasks.set(d,{resolve:o,reject:c,command:i});let S={...a,command:i,id:d};this.dataCaptureWorker.postMessage(S,n);})}};var rt=0;function gr(){let e=rt;return rt=rt+1,e}var f=class{constructor(t){this.action=t,this.messageID=gr();}},ae=class e extends f{constructor(t,r){super(e.action),this.wasmModuleName=t.wasmModuleName,this.licenseKey=t.licenseKey,this.userId=r,this.registerLoadCallback=t.loadProgressCallback!==null,this.allowHelloMessage=t.allowHelloMessage,this.engineLocation=t.engineLocation,this.wasmType=t.wasmType,this.initialMemory=t.initialMemory,this.blinkIDVariant=t.blinkIdVariant,this.numberOfWorkers=t.numberOfWorkers;}};ae.action="init";var J;(function(e){e[e.Any=0]="Any",e[e.Recognizer=1]="Recognizer",e[e.RecognizerSettings=2]="RecognizerSettings",e[e.Callback=3]="Callback";})(J||(J={}));var se=class e extends f{constructor(t,r){super(e.action),this.className=t,this.params=r;}};se.action="createNewNativeObject";var ne=class e extends f{constructor(t,r,i){super(e.action),this.recognizerHandles=t,this.allowMultipleResults=r,this.registeredMetadataCallbacks=i;}};ne.action="createRecognizerRunner";var oe=class e extends f{constructor(t,r){super(e.action),this.recognizerHandles=t,this.allowMultipleResults=r;}};oe.action="reconfigureRecognizerRunner";var le=class e extends f{constructor(){super(e.action);}};le.action="deleteRecognizerRunner";var P=class e extends f{constructor(t,r,i){super(e.action),this.objectHandle=t,this.methodName=r,this.params=i;}};P.action="invokeObject";var ue=class e extends f{constructor(t){super(e.action),this.frame=t;}getTransferrables(){return [this.frame.imageData.data.buffer]}};ue.action="processImage";var de=class e extends f{constructor(t){super(e.action),this.hardReset=t;}};de.action="resetRecognizers";var it=class{constructor(){this.onDebugText=!1,this.onDetectionFailed=!1,this.onQuadDetection=!1,this.onPointsDetection=!1,this.onFirstSideResult=!1;}},ce=class e extends f{constructor(t){super(e.action),this.registeredMetadataCallbacks=t;}};ce.action="registerMetadataCallbacks";var pe=class e extends f{constructor(t){super(e.action),this.detectionOnlyMode=t;}};pe.action="setDetectionOnly";var he=class e extends f{constructor(t){super(e.action),this.cameraPreviewMirrored=t;}};he.action="setCameraPreviewMirrored";var Ae=class e extends f{constructor(t){super(e.action),this.userId=t;}};Ae.action="getProductIntegrationInfo";var me=class e extends f{constructor(t){super(e.action),this.pingProxyUrl=t;}};me.action="setPingProxyUrl";var Ie=class e extends f{constructor(t){super(e.action),this.data=t;}};Ie.action="setPingData";var v;(function(e){e[e.onDebugText=0]="onDebugText",e[e.onDetectionFailed=1]="onDetectionFailed",e[e.onQuadDetection=2]="onQuadDetection",e[e.onPointsDetection=3]="onPointsDetection",e[e.onFirstSideResult=4]="onFirstSideResult",e[e.recognizerCallback=5]="recognizerCallback";})(v||(v={}));var q;(function(e){e.Basic="BASIC",e.Advanced="ADVANCED",e.AdvancedWithThreads="ADVANCED_WITH_THREADS";})(q||(q={}));var fr=atob("Q2VudGF1cnVz"),g=class extends Error{constructor(t,r){if(super(),!t.code||!t.message)throw new Error("Instance of SDKError is required to have code and message.");if(this.message=t.message,this.code=t.code,"details"in t){if("message"in t.details){let i=new Error(t.details.message);"stack"in t.details&&(i.stack=t.details.stack),this.details=i;}}else this.details=r;}};function Cr(e){return /^https:\/\/[^\/]+(?::\d+)?\/?$/.test(e)}var p;(function(e){e.WORKER_WASM_LOAD_FAILURE="WORKER_WASM_LOAD_FAILURE",e.WORKER_WASM_INIT_MISSING="WORKER_WASM_INIT_MISSING",e.WORKER_FUNCTION_INVOKE_FAILURE="WORKER_FUNCTION_INVOKE_FAILURE",e.WORKER_RECOGNIZER_CREATION_FAILURE="WORKER_RECOGNIZER_CREATION_FAILURE",e.WORKER_RUNNER_EXISTS="WORKER_RUNNER_EXISTS",e.WORKER_RUNNER_CREATION_FAILURE="WORKER_RUNNER_CREATION_FAILURE",e.WORKER_RUNNER_MISSING="WORKER_RUNNER_MISSING",e.WORKER_RUNNER_RECONFIGURE_FAILURE="WORKER_RUNNER_RECONFIGURE_FAILURE",e.WORKER_RUNNER_DELETED="WORKER_RUNNER_DELETED",e.WORKER_RUNNER_DELETE_FAILURE="WORKER_RUNNER_DELETE_FAILURE",e.WORKER_OBJECT_INVOKE_FAILURE="WORKER_OBJECT_INVOKE_FAILURE",e.WORKER_IMAGE_PROCESS_FAILURE="WORKER_IMAGE_PROCESS_FAILURE",e.WORKER_HANDLE_UNDEFINED="WORKER_HANDLE_UNDEFINED",e.WORKER_MESSAGE_ACTION_UNKNOWN="WORKER_MESSAGE_ACTION_UNKNOWN",e.WORKER_LICENSE_UNLOCK_ERROR="WORKER_LICENSE_UNLOCK_ERROR",e.WORKER_INTEGRATION_INFO_FAILURE="WORKER_INTEGRATION_INFO_FAILURE",e.LOCAL_SDK_RUNNER_MISSING="LOCAL_SDK_RUNNER_MISSING",e.LOCAL_SDK_RUNNER_EMPTY="LOCAL_SDK_RUNNER_EMPTY",e.LICENSE_UNLOCK_ERROR="LICENSE_UNLOCK_ERROR",e.FRAME_CAPTURE_SVG_UNSUPPORTED="FRAME_CAPTURE_SVG_UNSUPPORTED",e.FRAME_CAPTURE_CANVAS_MISSING="FRAME_CAPTURE_CANVAS_MISSING",e.SDK_WASM_SETTINGS_MISSING="SDK_WASM_SETTINGS_MISSING",e.SDK_LICENSE_KEY_MISSING="SDK_LICENSE_KEY_MISSING",e.SDK_WASM_MODULE_NAME_MISSING="SDK_WASM_MODULE_NAME_MISSING",e.SDK_ENGINE_LOCATION_INVALID="SDK_ENGINE_LOCATION_INVALID",e.SDK_WORKER_LOCATION_INVALID="SDK_WORKER_LOCATION_INVALID",e.SDK_MISSING="SDK_MISSING",e.SDK_RECOGNIZERS_MISSING="SDK_RECOGNIZERS_MISSING",e.VIDEO_RECOGNIZER_ELEMENT_MISSING="VIDEO_RECOGNIZER_ELEMENT_MISSING",e.VIDEO_RECOGNIZER_CAMERA_MISSING="VIDEO_RECOGNIZER_CAMERA_MISSING",e.VIDEO_RECOGNIZER_CAMERA_NOT_ALLOWED="VIDEO_RECOGNIZER_CAMERA_NOT_ALLOWED",e.VIDEO_RECOGNIZER_CAMERA_UNAVAILABLE="VIDEO_RECOGNIZER_CAMERA_UNAVAILABLE",e.VIDEO_RECOGNIZER_CAMERA_IN_USE="VIDEO_RECOGNIZER_CAMERA_IN_USE",e.VIDEO_RECOGNIZER_MEDIA_DEVICES_UNSUPPORTED="VIDEO_RECOGNIZER_MEDIA_DEVICES_UNSUPPORTED",e.VIDEO_RECOGNIZER_FEED_RELEASED="VIDEO_RECOGNIZER_FEED_RELEASED",e.VIDEO_RECOGNIZER_FEED_NOT_PAUSED="VIDEO_RECOGNIZER_FEED_NOT_PAUSED",e.VIDEO_RECOGNIZER_PLAY_REQUEST_INTERRUPTED="VIDEO_RECOGNIZER_PLAY_REQUEST_INTERRUPTED",e.VIDEO_RECOGNIZER_FEED_PAUSED="VIDEO_RECOGNIZER_FEED_PAUSED",e.VIDEO_RECOGNIZER_RECOGNIZERS_RESET_FAILURE="VIDEO_RECOGNIZER_RECOGNIZERS_RESET_FAILURE",e.VIDEO_RECOGNIZER_FEED_MISSING="VIDEO_RECOGNIZER_FEED_MISSING",e.INVALID_PING_PROXY_URL="INVALID_PROXY_URL",e.PING_PROXY_PERMISSION_NOT_GRANTED="PING_PROXY_PERMISSION_NOT_GRANTED",e.PING_DATA_KEYS_AMOUNT_EXCEEDED="PING_DATA_KEYS_AMOUNT_EXCEEDED",e.PING_DATA_KEY_LENGTH_EXCEEDED="PING_DATA_KEY_LENGTH_EXCEEDED",e.PING_DATA_VALUE_LENGTH_EXCEEDED="PING_DATA_VALUE_LENGTH_EXCEEDED";})(p||(p={}));var A;(function(e){e.WORKER_HANDLE_UNDEFINED="Cannot find object with handle: undefined",e.WORKER_WASM_LOAD_FAILURE="Failed to load WASM in web worker!",e.WORKER_WASM_INIT_MISSING="WASM module is not initialized!",e.WORKER_FUNCTION_INVOKE_FAILURE="Failed to invoke function!",e.WORKER_RECOGNIZER_CREATION_FAILURE="Failed to create new recognizer!",e.WORKER_RUNNER_EXISTS="Recognizer runner is already created! Multiple instances are not allowed!",e.WORKER_RUNNER_CREATION_FAILURE="Failed to create new recognizer runner!",e.WORKER_RUNNER_MISSING="Recognizer runner is not created! There is nothing to reconfigure!",e.WORKER_RUNNER_RECONFIGURE_FAILURE="Failed to reconfigure recognizer runner!",e.WORKER_RUNNER_DELETED="Recognizer runner is already deleted!",e.WORKER_RUNNER_DELETE_FAILURE="Failed to delete recognizer runner!",e.WORKER_OBJECT_INVOKE_FAILURE="Failed to invoke object!",e.WORKER_IMAGE_PROCESS_FAILURE="Recognizer runner is not initialized! Cannot process image!",e.WORKER_INTEGRATION_INFO_FAILURE="Failed to get product integration info!",e.LOCAL_SDK_RUNNER_MISSING="Property nativeRecognizerRunner is not available!",e.LOCAL_SDK_RUNNER_EMPTY="Native RecognizerRunner cannot be empty!",e.LICENSE_TOKEN_STATE_INCORRECT="Internal error (Incorrect token state)",e.LICENSE_PAYLOAD_VERIFICATION_FAILED="Failed to verify server permission's digital signature!",e.LICENSE_PAYLOAD_CORRUPTED="Server permission payload is corrupted!",e.LICENSE_PERMISSION_EXPIRED="Internal error (server permission expired)",e.LICENSE_REMOTE_LOCKED="Provided license key has been remotely locked. Please contact support for more information!",e.FRAME_CAPTURE_SVG_UNSUPPORTED="Recognition of SVG elements not supported!",e.FRAME_CAPTURE_CANVAS_MISSING="Could not get canvas 2d context!",e.SDK_WASM_SETTINGS_MISSING="Missing WASM load settings!",e.SDK_LICENSE_KEY_MISSING="Missing license key!",e.SDK_WASM_MODULE_NAME_MISSING="Missing WASM module name!",e.SDK_ENGINE_LOCATION_INVALID="Setting property 'engineLocation' must be a str