UNPKG

@scandit/web-datacapture-barcode

Version:

Scandit Data Capture SDK for the Web

6 lines (3 loc) 45.6 kB
import { DataCaptureLoader, Logger } from '@scandit/web-datacapture-core'; function i(r){let e=URL.createObjectURL(new Blob(['"use strict";(()=>{var u={"scandit-datacapture-sdk-barcode-pthreads.wasm":{bytes:7033774},"scandit-datacapture-sdk-barcode-simd-pthreads.wasm":{bytes:7180211},"scandit-datacapture-sdk-barcode-simd.wasm":{bytes:7534917},"scandit-datacapture-sdk-barcode.wasm":{bytes:7353667}};function k(t){return typeof t=="object"&&t!=null}function D(t){if(typeof t=="string")return t;if(k(t)){if(typeof t.message=="string")return t.message}else if(typeof t?.toString=="function")return t.toString();return"unknown error"}var c;(t=>{(o=>(o.Debug="debug",o.Info="info",o.Warn="warn",o.Error="error",o.Quiet="quiet"))(t.Level||(t.Level={}));let e=new Map([["debug",1],["info",2],["warn",3],["error",4],["quiet",5]]),r="debug";function a(o){r=o}t.setLevel=a;function i(o,...p){if(!(e.get(r)>e.get(o)))switch(o){case"debug":{console.debug(...p);break}case"info":{console.log(...p);break}case"warn":{console.warn(...p);break}case"error":{console.error(...p);break}}}t.log=i;function s(...o){i("warn",...o)}t.warn=s;function n(...o){i("debug",...o)}t.debug=n;function d(...o){i("info",...o)}t.info=d;function l(...o){i("error",...o)}t.error=l})(c||(c={}));var J=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t);var $=function(t,e){this[0]=t,this[1]=e},Q=(t,e,r)=>{var a=(n,d,l,o)=>{try{var p=r[n](d),b=(d=p.value)instanceof $,h=p.done;Promise.resolve(b?d[0]:d).then(m=>b?a(n==="return"?n:"next",d[1]?{done:m.done,value:m.value}:m,l,o):l({value:m,done:h})).catch(m=>a("throw",m,l,o))}catch(m){o(m)}},i=n=>s[n]=d=>new Promise((l,o)=>a(n,d,l,o)),s={};return r=r.apply(t,e),s[J("asyncIterator")]=()=>s,i("next"),i("throw"),i("return"),s},ee=(t,e,r)=>(e=t[J("asyncIterator")])?e.call(t):(t=t[J("iterator")](),e={},r=(a,i)=>(i=t[a])&&(e[a]=s=>new Promise((n,d,l)=>(s=i.call(t,s),l=s.done,Promise.resolve(s.value).then(o=>n({value:o,done:l}),d)))),r("next"),r("return"),e);var te={};function Oe(t){return[...new Uint8Array(t)].map(e=>{let r=e.toString(16);return r.length===1?`0${r}`:r}).join("")}function Le(t){return Q(this,null,function*(){let e=t.getReader();try{for(;;){let{done:r,value:a}=yield new $(e.read());if(r)return;yield a}}finally{e.releaseLock()}})}async function Be(t){let e=[],r=0,a=0;try{for(var i=ee(Le(t)),s,n,d;s=!(n=await i.next()).done;s=!1){let o=n.value;e.push(o),r+=o.length}}catch(o){d=[o]}finally{try{s&&(n=i.return)&&await n.call(i)}finally{if(d)throw d[0]}}let l=new Uint8Array(r);for(let o of e)l.set(o,a),a+=o.length;return l.buffer}var Te=(t=>(t.VALID="VALID",t.INVALID="INVALID",t.NOT_VERIFIABLE="NOT_VERIFIABLE",t))(Te||{});async function Ie(t,e,r){if(typeof crypto.subtle.digest!="function")return c.log(c.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 a=t instanceof Promise?await t:t,i=await crypto.subtle.digest("SHA-256",a),s=Oe(i);return e==null?(c.log(c.Level.Warn,"The library hash is not defined or empty, cannot correctly verify integrity."),"NOT_VERIFIABLE"):s===e?(c.log(c.Level.Debug,`Data Capture library WASM integrity found at ${r} has been verified correctly.`),"VALID"):(c.log(c.Level.Warn,`The Scandit Data Capture library WASM file found at ${r} 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(a){return c.log(c.Level.Warn,"Wasm response could not be verified",a),"NOT_VERIFIABLE"}}var j=new Map([["br",4.4],["gzip",2.9],["none",1]]);function Ae(t){var e;let r="content-encoding";if(t==null||t.get(r)==null)return j.get("none");let a=new Set(((e=t.get(r))!=null?e:"").split(",").map(i=>i.trim()));for(let[i,s]of j)if(a.has(i))return s;return j.get("none")}function We(t){var e,r;if(t==null)return 0;let a=(e=Ae(t))!=null?e:1,i=Number.parseInt((r=t.get("content-length"))!=null?r:"0",10);return Number.isNaN(i)?0:Math.floor(i*a*100)/100}function Ee(t){let{pathname:e}=new URL(t);for(let[r,a]of Object.entries(te))if(e.endsWith(r))return a.bytes;return 0}function re(t){te=t}var Re=(t,e)=>{let r=We(e);return r===0?Ee(t):r};function Ne(t,e,r,{onProgress:a,onError:i,onComplete:s}){if(!e.body)return[e];let n=Re(t,e.headers),d=0,l=0,[o,p]=r?e.body.tee():[e.body],b=o.pipeThrough(new TransformStream({async transform(h,m){try{d+=h.length,l=Number((d/n*100).toFixed(2)),n>0&&h.length>0&&l<100?a?.({percentage:l,loadedBytes:d,privateUri:t}):n===0&&h.length>0&&a?.({percentage:null,loadedBytes:d,privateUri:t}),m.enqueue(h)}catch(f){m.error(f),i?.({error:f})}},flush(h){a?.({percentage:100,loadedBytes:d,privateUri:t}),s?.({percentage:100,loadedBytes:d,privateUri:t}),h.terminate()}}));return[new Response(b,{headers:new Headers(e.headers),status:e.status,statusText:e.statusText}),p]}async function G({wasmURI:t,expectedHash:e,verifyResponseHash:r,onProgress:a,onComplete:i,onError:s,referredOrigin:n}){let d=await fetch(t,{referrerPolicy:"origin",referrer:n??""});if(!d.ok)throw new Error(`HTTP status code is not ok: ${d.status}, ${d.statusText}`);let[l,o]=Ne(t,d,r,{onProgress:a,onError:s,onComplete:i});return o!=null&&Ie(Be(o),e,t),l}function ae({wasmURI:t,expectedHash:e,verifyResponseHash:r,progressCallback:a,successCallback:i,importObject:s,referredOrigin:n}){async function d(o){try{let p=await G({wasmURI:t,expectedHash:e,verifyResponseHash:r,onProgress:a,referredOrigin:n}),b=await(o??p).arrayBuffer(),h=await globalThis.WebAssembly.instantiate(b,s);i(h.instance,h.module)}catch(p){c.log(c.Level.Error,p),c.log(c.Level.Error,`Couldn\'t instantiate Scandit SDK DataCapture library at ${t}, did you configure the path for it correctly?`)}}async function l(){let o;try{o=await G({wasmURI:t,expectedHash:e,verifyResponseHash:r,onProgress:a,referredOrigin:n});let p=await globalThis.WebAssembly.instantiateStreaming(o,s);i(p.instance,p.module)}catch(p){c.log(c.Level.Warn,p),c.log(c.Level.Warn,"WebAssembly streaming compile failed. Falling back to ArrayBuffer instantiation (this will make things slower)"),d(o?.bodyUsed===!0?void 0:o)}}typeof globalThis.WebAssembly.instantiateStreaming=="function"?l():d()}async function q(t,e,r,a){return new Promise((i,s)=>{t().then(i).catch(n=>{let d=e*2;if(d>r){s(n);return}a(n),globalThis.setTimeout(()=>{q(t,d,r,a).then(i).catch(s)},e)})})}function K(t){var e,r;let a="";if((e=t.href)!=null&&e.startsWith("blob:null/"))a="localhost";else{let i=((r=t.pathname)==null?void 0:r.length)>1&&!t.pathname.startsWith("/");a=new URL(i?t.pathname:t.origin).hostname}return a.startsWith("[")&&a.endsWith("]")&&(a=a.slice(1,-1)),a}async function ie(t,e){async function r(){return importScripts(t)}try{await q(r,250,4e3,i=>{c.log(c.Level.Warn,i),c.log(c.Level.Warn,`Couldn\'t retrieve Scandit Data Capture library at ${t}, retrying...`)}),self.Module.mainScriptUrlOrBlob=t;let a=globalThis.SDC_WASM_JS_VERSION;return a!==e&&c.log(c.Level.Warn,`The Scandit Data Capture library JS file found at ${t} seems invalid: expected version doesn\'t match (received: ${a}, expected: ${e}). Please ensure the correct Scandit Data Capture file (with correct version) is retrieved.`),!0}catch(a){return c.log(c.Level.Error,a),!1}}var L=class se extends Error{constructor(e){super(e.message),Object.setPrototypeOf(this,se.prototype),this.name=e.name}toString(){return`${this.name}: ${this.message}`}};var B=Promise.resolve(),T=!1,X=!1,P,C={writableDataPathPreload:"",writableDataPath:"",preloading:!1};async function _e(){let t="FILE_DATA",e,r,a,i,s;function n(){clearTimeout(s),a.result.close(),i.result.close(),e(0)}function d(){try{let l=[],o=a.result.transaction(t,"readonly");o.addEventListener("error",n),o.addEventListener("abort",n);let p=o.objectStore(t).openCursor();p.onsuccess=()=>{let b=p.result;if(b==null)try{let h=0,m=i.result.transaction(t,"readwrite"),f=m.objectStore(t);m.addEventListener("error",n),m.addEventListener("abort",n),m.oncomplete=()=>{clearTimeout(s),a.result.close(),i.result.close(),e(h)};for(let y of l){let v=f.count(y.primaryKey);v.onsuccess=()=>{v.result===0&&(++h,f.add(y.value,y.primaryKey))},clearTimeout(s),s=globalThis.setTimeout(()=>{c.log(c.Level.Warn,"IndexedDB database is blocked! Resetting Scandit Data Capture library..."),r(new L({name:"BlockedIndexedDB",message:"IndexedDB database is blocked"}))},500)}}catch(h){n.call({error:h})}else{let{writableDataPathPreload:h,writableDataPath:m}=C;l.push({value:b.value,primaryKey:b.primaryKey.toString().replace(`${h}/`,`${m}/`)}),b.continue()}},p.onerror=n}catch(l){n.call({error:l})}}return new Promise((l,o)=>{let{writableDataPathPreload:p,writableDataPath:b}=C;e=l,r=o,a=indexedDB.open(p),a.onupgradeneeded=()=>{try{a.result.createObjectStore(t)}catch{}},a.onsuccess=()=>{if(!Array.from(a.result.objectStoreNames).includes(t)){l(0);return}i=indexedDB.open(b),i.onupgradeneeded=()=>{try{i.result.createObjectStore(t)}catch{}},i.onsuccess=()=>{d()},i.onblocked=i.onerror=n},a.onblocked=a.onerror=n})}async function ne(t,e){let{preloading:r}=C;if(P!=null){if(T=!0,!r&&t){let a=await _e();if(!e&&a===0){T=!1;return}}await new Promise((a,i)=>{P?.(t,s=>{if(T=!1,s!=null){i(s);return}a()})})}}async function oe(t,e=!1,r=!1){return(!X||r)&&(T?(X=!0,B=B.then(async()=>(X=!1,ne(t,e)))):B=ne(t,e)),B}async function de(t){C=t,P=FS.syncfs,FS.syncfs=(e,r)=>{let a=r,i=s=>{a(s)};oe(e).then(i).catch(i)};try{FS.mkdir(C.writableDataPath)}catch(e){if(e.code!=="EEXIST")throw P=void 0,e}return FS.mount(IDBFS,{},C.writableDataPath),oe(!0,!0)}function He(t){return/^https?:\\/\\/(?:[^./]*\\.)*cdn.jsdelivr.net\\//.test(t)?{result:!0,cdnBaseURL:"https://cdn.jsdelivr.net/npm/"}:/^https?:\\/\\/(?:[^./]*\\.)*unpkg.com\\//.test(t)?{result:!0,cdnBaseURL:"https://unpkg.com/"}:{result:!1,cdnBaseURL:""}}function ze(t){let e=/@scandit\\/web-datacapture-[a-z]+/i.exec(t);return e?e[0]:null}function ce(t,e,r){let a=e,i=He(a);if(i.result){let n=ze(a);n!=null&&(a=`${i.cdnBaseURL}${n}@${t}/sdc-lib/`)}let s=r.replace(".wasm","");return i.result?{jsURI:`${a}${s}.js`,wasmURI:`${a}${s}.wasm`}:{jsURI:`${a}${s}.js?v=${t}`,wasmURI:`${a}${s}.wasm?v=${t}`}}var I;(t=>{function e(){return"7.0.0"}t.sdkVersion=e})(I||(I={}));var le=class{constructor(){this.promise=new Promise((t,e)=>{this.reject=e,this.resolve=t})}};var Ve=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])),Ue=()=>(async t=>{try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(t)}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 Je(){return typeof crossOriginIsolated>"u"?!1:crossOriginIsolated}function $e(){try{return new WebAssembly.Memory({initial:1,maximum:1,shared:!0}).buffer.constructor.name==="SharedArrayBuffer"}catch{return!1}}async function ue(){return Ve()}async function je(){if(!await Ue())return!1;let t=null;try{t=new Worker(URL.createObjectURL(new Blob([\'postMessage("Worker" in self);\'],{type:"text/javascript"})),{name:"nestedWorkerTest"})}catch{return!1}return new Promise(e=>{if(t==null){e(!1);return}t.onmessage=r=>{t?.terminate(),e(r.data)}})}async function pe(){let t=await je();return Je()&&$e()&&t}var he=class me{constructor(e,r){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.writableDataPathPreload="/scandit_sync_folder_preload",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=r,this._loadProgressCallback=this._loadProgressCallback.bind(this),re(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 r=this.getNextFrameId();this.frameDataPool.set(r,new Uint8ClampedArray(e.getFrameData()));let a=this.lastUsedModuleMirrorAxis==null?!1:this.lastUsedModuleMirrorAxis!==this.Module.Axis.None;return{frameId:r,width:e.getWidth(),height:e.getHeight(),isFrameSourceMirrored:a}}createContext(e){var r,a,i,s,n;let d=this.getModeDeserializers(),l=K(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 o=this.contextDeserializer.contextFromJson(JSON.stringify(e.context));if(o==null){let g=this.contextDeserializer.getLastError();throw new Error(`Could not create the context: ${g}`)}let p=o.getView();this.context=o.getContext(),o.delete();let b=this.Module.DataCaptureContextListener.extend("DataCaptureContextListener",{didChangeStatus:(g,F)=>{this.contextDidChangeStatus(JSON.parse(F.toJson()))},didStartObservingContext:()=>{this.didStartObservingContext()}}),h=this.Module.DataCaptureContextFrameListener.extend("DataCaptureContextFrameListener",{onObservationStarted:g=>{},onObservationStopped:g=>{},onFrameProcessingStarted:(g,F)=>{this.workerFunctions.postMessage({type:"onFrameProcessingStarted"})},onFrameProcessingFinished:(g,F)=>{this.workerFunctions.postMessage({type:"onFrameProcessingFinished"})},onFrameSkipped:(g,F)=>{this.workerFunctions.postMessage({type:"onFrameSkipped"})}}),m=this.Module.GestureRecognizer.extend("GestureRecognizer",{setGestureListener:(g,F)=>{var M;(M=this.gestureListener)==null||M.delete(),this.gestureListener=g.clone()}});(r=this.gestureRecognizer)==null||r.delete(),this.gestureRecognizer=new m;let f=new b;this.context.addListener(f),f.delete();let y=new h;this.context.addFrameListener(y),y.delete(),this.setView(p),(a=this.view)==null||a.setGestureRecognizer(this.gestureRecognizer);let v=this.Module.PlatformHintPresenter.extend("PlatformHintPresenter",{setHintPresenter:g=>{},showToast:g=>{this.workerFunctions.postMessage({type:"showToast",payload:JSON.parse(g)})},hideToast:g=>{this.workerFunctions.postMessage({type:"hideToast",payload:JSON.parse(g)})},showGuidance:g=>{this.workerFunctions.postMessage({type:"showGuidance",payload:JSON.parse(g)})},hideGuidance:g=>{this.workerFunctions.postMessage({type:"hideGuidance",payload:JSON.parse(g)})},startUpdateTimer:g=>{this.workerFunctions.postMessage({type:"startUpdateTimer",payload:{duration:{unit:"ms",value:g}}})},stopUpdateTimer:()=>{this.workerFunctions.postMessage({type:"stopUpdateTimer"})}});(i=this.hintPresenterV2)==null||i.delete(),(s=this.webPlatformHintPresenter)==null||s.delete(),this.webPlatformHintPresenter=new v,this.hintPresenterV2=new this.Module.HintPresenterV2(this.webPlatformHintPresenter),(n=this.view)==null||n.setHintPresenterV2(this.hintPresenterV2)}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.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,r;this.context.dispose(),this.frameDataPool.clear(),this.isDrawLoopRunning=!1,this.lastFrameCounter=-1,(e=this.gestureRecognizer)==null||e.delete(),this.gestureRecognizer=null,(r=this.gestureListener)==null||r.delete(),this.gestureListener=null}flushAnalytics(){this.context.flushAnalytics()}extractCentaurusLicense(e){return{payload:{centaurus:{licenseKey:this.Module.LicenseUtils[me.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{payload:e,transferables:[e.data.buffer]};let a=e.data,i=e.colorType==="GRAYSCALE"?this.Module.ImageBufferFormat.Grayscale8:this.Module.ImageBufferFormat.Rgba8888,s=this.Module.allocateUint8Array(a.byteLength);return this.Module.HEAPU8.set(a,s),(r=this.imageFrameSource)==null||r.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 r=this.frameDataPool.get(e);return r==null?{payload:{data:null}}:{payload:{data:r},transferables:[r.buffer]}}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 a;this.lastUsedModuleMirrorAxis=this.mapMirrorAxisOnModule(e),(a=this.imageFrameSource)==null||a.delete(),this.imageFrameSource=new this.Module.ImageBufferFrameSource(this.lastUsedModuleMirrorAxis,r,0),this.context.setFrameSource(this.imageFrameSource)}startDrawLoop(e){this.isDrawLoopRunning=!0;let r=s=>this.redrawRequests.length>0&&this.redrawRequests[0]<=s,a=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(r(s)){a(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 r=this.contextDeserializer.updateContextFromJson(this.context,this.view,JSON.stringify(e.context));if(r==null){let i=this.contextDeserializer.getLastError();throw new Error(`Could not update the context: ${i}`)}this.context.delete(),this.context=r.getContext();let a=r.getView();r.delete(),a!=null&&e.view!=null&&a.setViewSize(e.view.width,e.view.height,e.view.orientation),this.hintPresenterV2!=null&&a?.setHintPresenterV2(this.hintPresenterV2),this.gestureRecognizer!=null&&a?.setGestureRecognizer(this.gestureRecognizer),this.setView(a),c.log(c.Level.Debug,"context updated",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()}}}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,r){return r?e?"f158ddbcbaf519430f67072a843628a250fe0a0e4089369ebc6242b7dc1db4f8":"2e15106b5958443377b8f14ea9ebee5e2eab015e9061749900b16e6c46c3a653":e?"ce6ac1878290b06fc9782429a0da5f8c5dda32662b5ee9634402021d9cef590c":""}getWasmCoreFileName(e,r){return r?e?"scandit-datacapture-sdk-barcode-simd-pthreads.wasm":"scandit-datacapture-sdk-barcode-pthreads.wasm":e?"scandit-datacapture-sdk-barcode-simd.wasm":""}getWasmMetadata(){return u}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,a)=>r-a)}contextDidChangeStatus(e){e.code===260?e.message=e.message.replace("domain name",`domain name (${K(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 r=this.Module.NeedsRedrawDelegate.extend("NeedsRedrawDelegate",{setNeedsRedrawIn:this.scheduleRedraw.bind(this,e)}),a=new r;e.setNeedsRedrawDelegate(a),e.isViewRefreshHandlerSet=!0}setupDataDecoding(){let e=this.moduleHandler.get(),r=e.DataDecoding.extend("DataDecoding",{decode(a,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(a.slice(d.startIndex,d.endIndex)))}return n.join("")}catch{return""}}});e.setDataDecoding(new r)}start(e,r,a){e&&r&&(this.setupDataDecoding(),this.moduleHandler.get().callMain(),typeof this.moduleHandler.get().PThread=="object"||a())}getWritableDataPath(e,r){return e?this.writableDataPathPreload:r!=null?(c.log(c.Level.Debug,`IndexedDB database name override in use to recover from blocked standard database: ${r}`),r):this.writableDataPathStandard}async setup({libraryLocation:e,locationPath:r,preloadEngine:a,writableDataPathOverride:i,overrideThreadsSupport:s,overrideSimdSupport:n,verifyResponseHash:d,referredOrigin:l}){var o;let p=!1,b=!1;this.writableDataPath=this.getWritableDataPath(a,i),this.resourcePath=`${e}${this.resourceFilesSubfolder}/`,globalThis.path=r;let{resolve:h,reject:m,promise:f}=new le,y=I.sdkVersion();if(y==="")throw new L({name:"Invalid library version",message:"Library version is not defined or empty, cannot generate proper path to library files."});let[v,g]=await Promise.all([ue(),pe()]);s!=="auto"&&(g=s==="on"),n!=="auto"&&(v=n==="on");let F=ce(y,e,this.getWasmCoreFileName(v,g)),{jsURI:M,wasmURI:Z}=F,De={instantiateWasm:(w,Pe)=>(ae({importObject:w,wasmURI:Z,expectedHash:this.getWasmCoreExpectedHash(v,g),verifyResponseHash:d,successCallback:Pe,progressCallback:this._loadProgressCallback,referredOrigin:l}),{})};return this.moduleHandler.set({mainScriptUrlOrBlob:M,canvas:(o=this.workerFunctions.getOffscreenCanvas())!=null?o:{getContext:()=>null},...De,dynamicLibraries:this.getWasmDynamicLibraries(Z),locateFile:w=>e+w,noInitialRun:!0,preRun:[async()=>{try{await de({writableDataPathPreload:this.writableDataPathPreload,writableDataPath:this.writableDataPath,preloading:a})}catch(w){if(w.name==="BlockedIndexedDB"){m(w.toString());return}c.log(c.Level.Debug,"No IndexedDB support, some data will not be persisted:",w)}b=!0,this.start(b,p,h)}],onMainComplete:()=>{if([p,b].includes(!1)){c.log(c.Level.Warn,{runtimeLoaded:p,fileSystemSynced:b},"Both runtimeLoaded and fileSystemSynced should be true when calling onMainComplete"),m("onMainComplete has been called but runtime or file system was not ready.");return}h()},onRuntimeInitialized:()=>{p=!0,this.start(b,p,h)},print:w=>{c.log(c.Level.Info,w)}}),await ie(M,y)||m(`Couldn\'t retrieve Scandit Data Capture library at ${M}, did you configure the path for it correctly?`),f}};he.get3dPartyLicenseKeyMethodName=atob("Z2V0QmxpbmtJZExpY2Vuc2VLZXk=");var x=he;function ge(t){console.warn("Reached unexpected case",t)}function be(t){return typeof t=="object"&&t!=null&&t.document==null&&"addEventListener"in t&&typeof t.importScripts=="function"}var Y=class{constructor(t,e){this.onMessageListener=this.onMessage.bind(this),this.workerSelf=t,this.dataCaptureInstance=new x(e,{postMessage:this.postMessage.bind(this),getOffscreenCanvas:this.getOffscreenCanvas.bind(this)}),be(t)&&this.listenToMessages()}listenToMessages(){this.workerSelf.addEventListener("message",this.onMessageListener),this.workerSelf.addEventListener("error",t=>{c.log(c.Level.Error,t)}),this.workerSelf.addEventListener("messageerror",t=>{c.log(c.Level.Error,t)})}postMessage(t,e){this.workerSelf.postMessage(t,e??[])}getOffscreenCanvas(){if(typeof this.workerSelf.OffscreenCanvas=="function")return new this.workerSelf.OffscreenCanvas(32,32)}hasPayload(t){return k(t)&&"payload"in t}hasTransferables(t){return k(t)&&Array.isArray(t.transferables)}async respondWith(t,e,r){let a=null,i;try{i=r(),i instanceof Promise&&(i=await i)}catch(n){i=void 0,a=D(n)}let s={type:"workerTaskId",command:t,id:e,payload:this.hasPayload(i)?i.payload:void 0};a!=null&&(s.error=a),this.postMessage(s,this.hasTransferables(i)?i.transferables:[])}onMessage(t){switch(t.data.command){case"loadLibrary":{{let{data:e}=t;this.respondWith(e.command,e.id,async()=>this.dataCaptureInstance.loadLibrary({libraryLocation:e.libraryLocation,locationPath:e.locationPath,referredOrigin:e.referredOrigin,preloadEngine:e.preloadEngine,writableDataPathOverride:e.writableDataPathOverride,overrideThreadsSupport:e.overrideThreadsSupport,overrideSimdSupport:e.overrideSimdSupport,verifyResponseHash:e.verifyResponseHash}))}break}case"onTap":{{let{data:e}=t;this.respondWith(e.command,e.id,async()=>{this.dataCaptureInstance.onTap(e.point)})}break}case"hintPresenterV2update":{{let{data:e}=t;this.respondWith(e.command,e.id,async()=>{this.dataCaptureInstance.hintPresenterV2Update()})}break}case"createContext":{{let{data:e}=t;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}=t;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.setFrameSource(e.mirrorAxis,e.isCameraFrameSource))}break}case"processFrame":{{let{data:e}=t;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}=t;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.requestFrameData(e.frameId))}break}case"deleteFrameData":{{let{data:e}=t;this.respondWith(e.command,e.id,()=>{this.dataCaptureInstance.deleteFrameData(e.frameId)})}break}case"updateContext":{{let{data:e}=t;this.respondWith(e.command,e.id,async()=>this.dataCaptureInstance.updateContext(e))}break}case"dispose":{this.respondWith(t.data.command,t.data.id,()=>this.dataCaptureInstance.dispose());break}case"flushAnalytics":{this.respondWith(t.data.command,t.data.id,()=>{this.dataCaptureInstance.flushAnalytics()});break}case"reportCameraProperties":{{let{data:e}=t;this.respondWith(e.command,e.id,async()=>this.dataCaptureInstance.reportCameraProperties(e))}break}case"setLogLevel":{{let{data:e}=t;this.respondWith(e.command,e.id,()=>{c.setLevel(e.level)})}break}case"extractCentaurusLicense":{{let{data:e}=t;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.extractCentaurusLicense(e.licenseKey))}break}case"documentVisibility":{{let{data:e}=t;this.respondWith(e.command,e.id,()=>{this.dataCaptureInstance.onDocumentVisibilityChange(e.state)})}break}case"isFeatureSupported":{{let{data:e}=t;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.isFeatureSupported(e.feature))}break}case"getViewfinderInfo":{{let{data:e}=t;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.getViewfinderInfo())}break}case"getOpenSourceSoftwareLicenseInfo":{{let{data:e}=t;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.getOpenSourceSoftwareLicenseInfo())}break}default:return ge(t.data),!1}return!0}};var fe=(t=>(t.Body="body",t.Footnote="footnote",t))(fe||{}),A=(t=>(t.Start="start",t.Center="center",t.End="end",t))(A||{}),ye=(t=>(t.Normal="normal",t.Wider="wider",t.FitText="fitText",t))(ye||{}),Se=(t=>(t.Normal="normal",t.Taller="taller",t))(Se||{}),we=(t=>(t.Square="square",t.Rounded="rounded",t))(we||{}),W=(t=>(t.None="none",t.Check="check",t.ExclamationMark="exclamationMark",t))(W||{}),E=(t=>(t.Top="top",t.AboveViewFinder="aboveViewFinder",t.BelowViewFinder="belowViewFinder",t))(E||{}),ve=(t=>(t.AboveViewFinder="aboveViewFinder",t.BelowViewFinder="belowViewFinder",t))(ve||{}),Fe=(t=>(t.BlackOnWhite="blackOnWhite",t.WhiteOnBlack="whiteOnBlack",t.Transparent="transparent",t))(Fe||{}),O=(t=>(t.Success="success",t.Error="error",t.Warning="warning",t.Info="info",t.Notification="notification",t))(O||{}),Me=(t=>(t[t.Ocr=0]="Ocr",t[t.HideLogo=1]="HideLogo",t[t.ShowTestLicenseMessage=2]="ShowTestLicenseMessage",t[t.AugmentedReality=5]="AugmentedReality",t[t.ActivityPingStatsAddon=8]="ActivityPingStatsAddon",t[t.ActivityPing=9]="ActivityPing",t[t.Registration=10]="Registration",t[t.Parser=11]="Parser",t[t.BarcodeCapture=14]="BarcodeCapture",t[t.Analytics=17]="Analytics",t[t.AnalyticsBatchMode=18]="AnalyticsBatchMode",t[t.AnalyticsScanContent=19]="AnalyticsScanContent",t[t.AnalyticsOnlineVerification=20]="AnalyticsOnlineVerification",t[t.SparkScan=21]="SparkScan",t[t.AamvaIdBarcodeVerification=22]="AamvaIdBarcodeVerification",t[t.MappingForTracking=23]="MappingForTracking",t[t.BarcodeFind=24]="BarcodeFind",t[t.MandatoryRegistration=25]="MandatoryRegistration",t[t.FeatureTracking=26]="FeatureTracking",t[t.IdCaptureViz=27]="IdCaptureViz",t[t.IdCaptureMrz=28]="IdCaptureMrz",t[t.IdCaptureBarcode=29]="IdCaptureBarcode",t[t.BarcodeSelectionAimToScan=30]="BarcodeSelectionAimToScan",t[t.BarcodeSelectionTapToScan=31]="BarcodeSelectionTapToScan",t[t.BarcodeCount=32]="BarcodeCount",t[t.BarcodePick=33]="BarcodePick",t[t.IdVerificationDataComparison=34]="IdVerificationDataComparison",t[t.SmartLabelBarcode=35]="SmartLabelBarcode",t[t.SmartLabelText=36]="SmartLabelText",t[t.VoidedIdDetection=37]="VoidedIdDetection",t[t.BarcodeArFull=38]="BarcodeArFull",t))(Me||{});var R=class{constructor(e,r,a){this.captureListenerSet=!1;this.coreEngine=e,this.Module=r,this.workerFunctions=a,this.setup()}barcodeCaptureDidUpdateSession(e){this.workerFunctions.postMessage({type:"barcodeCaptureDidUpdateSession",payload:JSON.parse(e.toJson())})}barcodeBatchDidUpdateSession(e){this.workerFunctions.postMessage({type:"barcodeBatchDidUpdateSession",payload:JSON.parse(e.toJson())})}getCaptureDeserializer(){return this.barcodeCaptureDeserializer}getTrackingDeserializer(){return this.barcodeBatchDeserializer}setup(){let e=this.Module.BarcodeCaptureListener.extend("BarcodeCaptureListener",{didScan:(n,d,l)=>{this.barcodeCaptureDidScan(d,l)},didUpdateSession:(n,d)=>{this.barcodeCaptureDidUpdateSession(d)}}),r=this.Module.Feedback.extend("Feedback",{emit:()=>{this.successFeedback()}}),a=new e,i=new r,s=this.Module.BarcodeCaptureDeserializerListener.extend("BarcodeCaptureDeserializerListener",{onModeDeserializationFinished:(n,d)=>{d.addListener(a,1),d.setSuccessFeedback(i)},onModeDeserializationStarted(){},onSettingsDeserializationStarted(){},onSettingsDeserializationFinished(){}});this.barcodeCaptureDeserializer=new this.Module.BarcodeCaptureDeserializer,this.barcodeCaptureDeserializer.setListener(new s)}successFeedback(){this.workerFunctions.postMessage({type:"successFeedback"})}barcodeCaptureDidScan(e,r){let a=this.coreEngine.convertToLoadableFrameData(r);this.workerFunctions.postMessage({type:"barcodeCaptureDidScan",payload:{session:JSON.parse(e.toJson()),frameData:a}})}};function Ge(t){return t.charAt(0).toUpperCase()+t.slice(1)}function Ce(t){return t}var N=class{constructor(e,r,a){this.barcodeFind=null;this.basicOverlay=null;this.transparentGuidanceHintStyle={backgroundColor:"00000000",cornerRadius:4,fitToText:!1,isAnimatedToView:!1,textAlignment:A.Center,hintIcon:W.None,hintAnchor:E.AboveViewFinder,hintAnchorOffset:-12,horizontalMargin:0,iconColor:"00000000",lineHeight:-1,maxLines:1,maxWidthFraction:.8,textColor:"ffffffff",textSize:15,textWeight:600};this.customerTransformation=Ce;this.coreEngine=e,this.Module=r,this.workerFunctions=a}async forSettings(e){this.barcodeFind?.delete(),this.barcodeFind=new this.Module.BarcodeFind(this.coreEngine.context,JSON.stringify(e));let r=this.Module.Feedback.extend("Feedback",{emit:()=>{this.listUpdatedFeedback()}}),a=this.Module.Feedback.extend("Feedback",{emit:()=>{this.barcodeFindFeedback()}}),i=this.Module.BarcodeFindTransformer.extend("BarcodeFindTransformer",{transformBarcodeData:n=>this.customerTransformation(n)}),s=this.Module.BarcodeFindListener.extend("BarcodeFindListener",{didUpdateSession:(n,d,l)=>{let o=this.coreEngine.convertToLoadableFrameData(l);this.workerFunctions.postMessage({type:"barcodeFindDidUpdateSession",payload:{session:JSON.parse(d.toJson()),frameData:o}})},onSearchPaused:n=>{let d=[];for(let l=0;l<n.size();l++)d.push(n.get(l));this.workerFunctions.postMessage({type:"barcodeFindSearchPaused",payload:{foundItems:d}})},onSearchStopped:n=>{let d=[];for(let l=0;l<n.size();l++)d.push(n.get(l));this.workerFunctions.postMessage({type:"barcodeFindSearchStopped",payload:{foundItems:d}})},onSearchStarted:()=>{this.workerFunctions.postMessage({type:"barcodeFindSearchStarted",payload:{}})}});this.barcodeFind.setBarcodeFindTransformer(new i),this.barcodeFind.addListener(new s,1),this.barcodeFind.setItemListUpdatedFeedback(new r),this.barcodeFind.setFeedback(new a),this.Module.addBarcodeFindToContext(this.coreEngine.context,this.barcodeFind)}barcodeFindFeedback(){this.workerFunctions.postMessage({type:"barcodeFindFeedback",payload:{}})}start(){this.barcodeFind?.start()}stop(){this.barcodeFind?.stop()}pause(){this.barcodeFind?.pause()}setEnabled(e){this.barcodeFind?.setEnabled(e)}setItemList(e){this.barcodeFind?.setItemList(JSON.stringify(e))}async removeMode(){this.barcodeFind!=null&&this.Module.removeBarcodeFindFromContext(this.coreEngine.context,this.barcodeFind)}addBasicOverlay(){this.basicOverlay?.delete(),this.basicOverlay=null,this.barcodeFind!=null&&(this.basicOverlay=new this.Module.BarcodeFindBasicOverlay(this.barcodeFind)),this.coreEngine.view!=null&&this.basicOverlay!=null&&(this.basicOverlay.setGuidanceHandler(this.createWebFindGuidanceHandler()),this.Module.addBarcodeFindBasicOverlayToView(this.coreEngine.view,this.basicOverlay))}removeBasicOverlay(){this.coreEngine.view!=null&&this.basicOverlay!=null&&this.Module.removeBarcodeFindBasicOverlayFromView(this.coreEngine.view,this.basicOverlay)}async applySettings(e){this.barcodeFind?.applySettings(JSON.stringify(e))}updateBasicOverlay(e){let r=Object.entries(e).filter(([a,i])=>a!=="type");for(let[a,i]of r){let s=`set${Ge(a)}`;this.basicOverlay!=null&&typeof this.basicOverlay[s]=="function"&&i!=null&&this.basicOverlay[s](i)}}setTransformerFunction(e){this.customerTransformation=e??Ce}successFeedback(){this.workerFunctions.postMessage({type:"successFeedback"})}listUpdatedFeedback(){this.workerFunctions.postMessage({type:"barcodeFindListUpdatedFeedback",payload:{}})}setToast(e,r){let a=this.coreEngine.hintPresenterV2;e?a?.showToast(JSON.stringify(r)):a?.hideToast(r.tag)}setGuidance(e,r,a){let i={tag:a,text:r,hintStyle:this.transparentGuidanceHintStyle};this.workerFunctions.postMessage({type:e?"showGuidance":"hideGuidance",payload:i})}createWebFindGuidanceHandler(){let e=this.Module.BarcodeFindGuidanceHandler.extend("BarcodeFindGuidanceHandler",{setInitialGuidance:(r,a)=>{this.setGuidance(r,a,"InitialGuidance")},setMoveCloserGuidance:(r,a)=>{this.setGuidance(!1,a,"InitialGuidance"),this.setGuidance(r,a,"MoveCloserGuidance")},setAllItemsFound:(r,a)=>{let i={text:a,toastHintStyle:O.Success,tag:"AllItemsFound"};this.setToast(r,i)},setTapShutterToPause:(r,a)=>{this.setGuidance(!1,a,"InitialGuidance"),this.setGuidance(r,a,"TapShutterToPause")},setTapShutterToResume:(r,a)=>{this.setGuidance(!1,a,"InitialGuidance"),this.setGuidance(r,a,"TapShutterResume")},setItemListUpdated:(r,a)=>{let i={text:a,toastHintStyle:O.Info,tag:"ItemListUpdated"};this.setToast(r,i)}});return new e}};var _=class{constructor(e,r,a){this.trackingListenerSet=!1;this.coreEngine=e,this.Module=r,this.workerFunctions=a,this.setup()}barcodeBatchDidUpdateSession(e){this.workerFunctions.postMessage({type:"barcodeBatchDidUpdateSession",payload:JSON.parse(e.toJson())})}getBatchDeserializer(){return this.barcodeBatchDeserializer}setup(){let e=this.Module.BarcodeBatchListener.extend("BarcodeTrackingListener",{didUpdateSession:(a,i)=>{this.barcodeBatchDidUpdateSession(i)},onTrackedBarcodeTapped:(a,i)=>{this.onTrackedBarcodeTapped(i)}}),r=this.Module.BarcodeBatchDeserializerListener.extend("BarcodeTrackingDeserializerListener",{onModeDeserializationFinished:(a,i)=>{this.trackingListenerSet||(i.addListener(new e,1),this.trackingListenerSet=!0)},onModeDeserializationStarted(){},onSettingsDeserializationStarted(){},onSettingsDeserializationFinished(){}});this.barcodeBatchDeserializer=new this.Module.BarcodeBatchDeserializer,this.barcodeBatchDeserializer.setListener(new r)}onTrackedBarcodeTapped(e){this.workerFunctions.postMessage({type:"didTapTrackedBarcode",payload:JSON.parse(e.toJson())})}};var S=class{constructor(e){this.subscribers=new Set;this.property={key:e,value:null}}addSubscriber(e){this.subscribers.add(e),e.onPropertyChanged?.(this.property)}removeSubscriber(e){this.subscribers.delete(e)}setProperty(e){if(this.property.value!==e.value){this.property={key:this.property.key,value:e.value};for(let r of this.subscribers)r.onPropertyChanged?.(this.property)}}};var qe={torch_state:new S("torch_state"),scanning_mode:new S("scanning_mode"),sound_enabled:new S("sound_enabled"),haptic_enabled:new S("haptic_enabled"),hand_mode:new S("hand_mode"),session_stop_reason:new S("session_stop_reason"),camera_position:new S("camera_position")},H=class{getBehaviorSubject(e){return qe[e]}};var z=class{constructor(e,r,a){this.captureListenerSet=!1;this.propertyPushSource=new H;this.coreEngine=e,this.Module=r,this.workerFunctions=a,this.setup()}sparkScanDidUpdateSession(e){this.workerFunctions.postMessage({type:"sparkScanDidUpdateSession",payload:JSON.parse(e.toJson())})}getSparkScanDeserializer(){return this.sparkScanDeserializer}setup(){let e=this.Module.SparkScanListener.extend("SparkScanListener",{didScan:(i,s,n)=>{this.sparkScanDidScan(s,n)},didUpdateSession:(i,s)=>{this.sparkScanDidUpdateSession(s)}}),r=this.Module.Feedback.extend("Feedback",{emit:()=>{this.successFeedback()}}),a=this.Module.SparkScanDeserializerListener.extend("SparkScanDeserializerListener",{onModeDeserializationFinished:(i,s)=>{this.captureListenerSet||(s.addListener(new e,1),s.setSuccessFeedback(new r),s.setPropertyPushSource(this.propertyPushSource),this.captureListenerSet=!0)},onModeDeserializationStarted(){},onSettingsDeserializationStarted(){},onSettingsDeserializationFinished(){},onOverlayDeserializationStarted(){},onOverlayDeserializationFinished:(i,s,n)=>{this.sparkScanOverlay?.delete(),this.sparkScanOverlay=s.clone()}});this.sparkScanDeserializer=new this.Module.SparkScanDeserializer,this.sparkScanDeserializer.setListener(new a)}emitErrorFeedback(e){this.sparkScanOverlay?.onErrorFeedbackEmitted(e)}overlayReadyForDraw(){this.sparkScanOverlay?.onReadyForNewData()}analyticsManagerPropertyChanged(e){this.propertyPushSource.getBehaviorSubject(e.key).setProperty(e)}successFeedback(){this.workerFunctions.postMessage({type:"successFeedback"})}sparkScanDidScan(e,r){let a=this.coreEngine.convertToLoadableFrameData(r);this.workerFunctions.postMessage({type:"sparkScanDidScan",payload:{session:JSON.parse(e.toJson()),frameData:a}})}};var V=class extends x{constructor(e,r){super(e,r)}getModeDeserializers(){this.barcodeCaptureMode=new R(this,this.Module,this.workerFunctions),this.barcodeBatchMode=new _(this,this.Module,this.workerFunctions),this.sparkScanMode=new z(this,this.Module,this.workerFunctions),this.barcodeFindMode=new N(this,this.Module,this.workerFunctions);let e=super.getModeDeserializers();return e.push_back(this.barcodeCaptureMode.getCaptureDeserializer()),e.push_back(this.barcodeBatchMode.getBatchDeserializer()),e.push_back(this.sparkScanMode.getSparkScanDeserializer()),e}getWasmSideModuleFileName(){return""}getWasmCoreFileName(e,r){return r?e?"scandit-datacapture-sdk-barcode-simd-pthreads.wasm":"scandit-datacapture-sdk-barcode-pthreads.wasm":e?"scandit-datacapture-sdk-barcode-simd.wasm":"scandit-datacapture-sdk-barcode.wasm"}getWasmCoreExpectedHash(e,r){return r?e?"f158ddbcbaf519430f67072a843628a250fe0a0e4089369ebc6242b7dc1db4f8":"2e15106b5958443377b8f14ea9ebee5e2eab015e9061749900b16e6c46c3a653":e?"ce6ac1878290b06fc9782429a0da5f8c5dda32662b5ee9634402021d9cef590c":"cb3203ac8d18b08947974f71da2856fd268b7257668686f68170fd17e1d402ad"}getWasmMetadata(){return u}};function Ke(t){return(r=>/^[$A-Z_a-z][\\w$]*\\s*\\(.*\\)\\s*\\{/.test(r)&&!r.startsWith("function"))(t)?`function ${t}`:t}var Xe=["fetch","XMLHttpRequest","eval","Function","self","globalThis","Module","importScripts","this","console","window","document","import","Worker","ServiceWorker"];function Ye(t){return Xe.map(r=>new RegExp(`\\\\b${r}\\\\b`,"g")).some(r=>r.test(t))}function ke(t){if(t==null)return null;let e=Ke(t);if(Ye(e))throw new Error("Function should be pure. Shouldn\'t introduce side effects, or rely on global scope");let r=`\'use strict\';\n return (${e});`;try{return new Function(r)()}catch{return null}}var U=class extends Y{constructor(e,r){super(e,r),this.dataCaptureInstance=new V(r,{postMessage:this.postMessage.bind(this),getOffscreenCanvas:this.getOffscreenCanvas.bind(this)})}async respondWith(e,r,a){let i=null,s;try{s=a(),s instanceof Promise&&(s=await s)}catch(d){s=void 0,i=D(d)}let n={type:"workerTaskId",command:e,id:r,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"sparkScanEmitErrorFeedback":{let{data:r}=e;return this.respondWith(r.command,r.id,()=>{this.dataCaptureInstance.sparkScanMode.emitErrorFeedback(r.shouldRemoveBrush)}),!0}case"sparkScanOverlayReadyForDraw":{let{data:r}=e;return this.respondWith(r.command,r.id,()=>{this.dataCaptureInstance.sparkScanMode.overlayReadyForDraw()}),!0}case"sparkScanAnalyticsManagerPropertyChanged":{let{data:r}=e;return this.respondWith(r.command,r.id,async()=>{this.dataCaptureInstance.sparkScanMode.analyticsManagerPropertyChanged(r.property)}),!0}case"barcodeFindForSettings":{let{data:r}=e;return this.respondWith(r.command,r.id,async()=>this.dataCaptureInstance.barcodeFindMode.forSettings(r.settings)),!0}case"barcodeFindModeRemove":{let{data:r}=e;return this.respondWith(r.command,r.id,async()=>this.dataCaptureInstance.barcodeFindMode.removeMode()),!0}case"barcodeFindSearchStart":return this.respondWith(e.data.command,e.data.id,()=>{this.dataCaptureInstance.barcodeFindMode.start()}),!0;case"barcodeFindSearchPause":return this.respondWith(e.data.command,e.data.id,()=>{this.dataCaptureInstance.barcodeFindMode.pause()}),!0;case"barcodeFindSearchStop":return this.respondWith(e.data.command,e.data.id,()=>{this.dataCaptureInstance.barcodeFindMode.stop()}),!0;case"barcodeFindSetItemList":{let{data:r}=e;return this.respondWith(e.data.command,e.data.id,()=>{this.dataCaptureInstance.barcodeFindMode.setItemList(r.itemList)}),!0}case"barcodeFindSetEnabled":{let{data:r}=e;return this.respondWith(e.data.command,e.data.id,()=>{this.dataCaptureInstance.barcodeFindMode.setEnabled(r.enabled)}),!0}case"barcodeFindApplySettings":{let{data:r}=e;return this.respondWith(r.command,r.id,async()=>this.dataCaptureInstance.barcodeFindMode.applySettings(r.settings)),!0}case"barcodeFindAddBasicOverlay":{let{data:r}=e;return this.respondWith(r.command,r.id,async()=>{this.dataCaptureInstance.barcodeFindMode.addBasicOverlay()}),!0}case"barcodeFindRemoveBasicOverlay":{let{data:r}=e;return this.respondWith(r.command,r.id,async()=>{this.dataCaptureInstance.barcodeFindMode.removeBasicOverlay()}),!0}case"barcodeFindUpdateBasicOverlay":{let{data:r}=e;return this.respondWith(r.command,r.id,async()=>{this.dataCaptureInstance.barcodeFindMode.updateBasicOverlay(r.jsonOverlay)}),!0}case"barcodeFindSetTransformerFunction":{let{data:r}=e;return this.respondWith(r.command,r.id,async()=>{let a=ke(r.functionAsString);this.dataCaptureInstance.barcodeFindMode.setTransformerFunction(a)}),!0}default:return super.onMessage(e)}}};var Kr=new U(globalThis,{get:()=>globalThis.Module,set:t=>{globalThis.Module=t}});function Xr(t){}})();\n'],{type:"application/javascript"})),t=new Worker(e,r);return URL.revokeObjectURL(e),t}var n=class r extends DataCaptureLoader{get dataCaptureWorker(){return (this._dataCaptureWorker)!=null||(this._dataCaptureWorker=i({name:this.name})),this._dataCaptureWorker}get name(){return `BarcodeCapture${this.isPreloadEngine?" (preload)":""}`}static async create(e){var a;let t=new r(e);return await t.workerCommand("setLogLevel",{level:(a=e.logLevel)!=null?a:Logger.Level.Debug}),await t.load(),t}async workerCommand(e,t,a){return new Promise((o,d)=>{let s=this.workerCommandId++;this.workerTasks.set(s,{resolve:o,reject:d,command:e});let c={...t,command:e,id:s};this.dataCaptureWorker.postMessage(c,a);})}}; export { n as a };