@scandit/web-datacapture-barcode
Version:
Scandit Data Capture SDK for the Web
6 lines • 75.1 kB
JavaScript
(function(){var e=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}};function t(e){return typeof e==`object`&&!!e}function n(e){if(typeof e==`string`)return e;if(t(e)){if(typeof e.message==`string`)return e.message}else if(typeof e?.toString==`function`)return e.toString();return`unknown error`}let r;(function(e){e.Level=function(e){return e.Debug=`debug`,e.Info=`info`,e.Warn=`warn`,e.Error=`error`,e.Quiet=`quiet`,e}({});let t=new Map([[`debug`,1],[`info`,2],[`warn`,3],[`error`,4],[`quiet`,5]]),n=`debug`;function r(e){n=e}e.setLevel=r;function i(e,...r){if(!(t.get(n)>t.get(e)))switch(e){case`debug`:console.debug(...r);break;case`info`:console.log(...r);break;case`warn`:console.warn(...r);break;case`error`:console.error(...r);break;default:break}}e.log=i;function a(...e){i(`warn`,...e)}e.warn=a;function o(...e){i(`debug`,...e)}e.debug=o;function s(...e){i(`info`,...e)}e.info=s;function c(...e){i(`error`,...e)}e.error=c})(r||={});var i=class e extends Error{constructor(t){super(t.message),Object.setPrototypeOf(this,e.prototype),this.name=t.name}toString(){return`${this.name}: ${this.message}`}};function a(e){return/^https?:\/\/(?:[^./]*\.)*cdn.jsdelivr.net\//.test(e)?{result:!0,cdnBaseURL:`https://cdn.jsdelivr.net/npm/`}:/^https?:\/\/(?:[^./]*\.)*unpkg.com\//.test(e)?{result:!0,cdnBaseURL:`https://unpkg.com/`}:{result:!1,cdnBaseURL:``}}function o(e){let t=/@scandit\/web-datacapture-[a-z]+/i.exec(e);return t?t[0]:null}function s(e,t,n){let r=t,i=a(r);if(i.result){let t=o(r);t!=null&&(r=`${i.cdnBaseURL}${t}@${e}/sdc-lib/`)}let s=n.replace(`.wasm`,``);return i.result?{jsURI:`${r}${s}.js`,wasmURI:`${r}${s}.wasm`}:{jsURI:`${r}${s}.js?v=${e}`,wasmURI:`${r}${s}.wasm?v=${e}`}}(function(e){return e[e.Free=0]=`Free`,e[e.Writing=1]=`Writing`,e[e.Ready=2]=`Ready`,e[e.Processing=3]=`Processing`,e})({});var c=class e{constructor(e,t,n,r){this.getHeapBuffer=e,this.memAddressSlotByteLength=t,this.stateBuffer=n,this.addressBuffer=r,this._staleAddressDetected=!1}static create(t){let n=new Int32Array(new SharedArrayBuffer(t.memAddressSlotCount*Int32Array.BYTES_PER_ELEMENT)),r=new Uint32Array(new SharedArrayBuffer(t.memAddressSlotCount*Uint32Array.BYTES_PER_ELEMENT));for(let e=0;e<t.memAddressSlotCount;e++)Atomics.store(r,e,t.allocateUint8Array(t.memAddressSlotByteLength));return new e(t.getHeapBuffer,t.memAddressSlotByteLength,n,r)}static attach(t){return new e(()=>t.heapBuffer,t.memAddressSlotByteLength,new Int32Array(t.stateSharedBuffer),new Uint32Array(t.addressSharedBuffer))}get hasStaleAddresses(){return this._staleAddressDetected}get memAddressSlotCount(){return this.stateBuffer.length}get buffers(){return{stateSharedBuffer:this.stateBuffer.buffer,addressSharedBuffer:this.addressBuffer.buffer,heapBuffer:this.getHeapBuffer(),memAddressSlotByteLength:this.memAddressSlotByteLength}}viewFor(e){return new Uint8ClampedArray(this.getHeapBuffer(),e,this.memAddressSlotByteLength)}claimFreeMemAddressSlot(){for(let e=0;e<this.stateBuffer.length;e++)if(Atomics.compareExchange(this.stateBuffer,e,0,1)===0){let t=Atomics.load(this.addressBuffer,e);return t+this.memAddressSlotByteLength>this.getHeapBuffer().byteLength?(this._staleAddressDetected=!0,this.abandon(e),null):{index:e,address:t,view:this.viewFor(t)}}return null}markReady(e){let t=Atomics.compareExchange(this.stateBuffer,e,1,2);if(t!==1)throw Error(`SharedFrameMemAddressSlotPool: cannot mark memAddressSlot ${e} ready from state ${t}`)}abandon(e){let t=Atomics.compareExchange(this.stateBuffer,e,1,0);if(t!==1)throw Error(`SharedFrameMemAddressSlotPool: cannot abandon memAddressSlot ${e} from state ${t}`)}beginProcessing(e){if(Atomics.compareExchange(this.stateBuffer,e,2,3)!==2)return null;let t=Atomics.load(this.addressBuffer,e);return{index:e,address:t,view:this.viewFor(t)}}release(e,t){let n=Atomics.load(this.stateBuffer,e);if(n!==3)throw Error(`SharedFrameMemAddressSlotPool: cannot release memAddressSlot ${e} from state ${n}`);for(let n=0;n<this.addressBuffer.length;n++)if(Atomics.load(this.addressBuffer,n)===t)throw Error(`SharedFrameMemAddressSlotPool: replacement address ${t} for memAddressSlot ${e} is already in use by memAddressSlot ${n} — addresses must never be reused`);Atomics.store(this.addressBuffer,e,t),Atomics.store(this.stateBuffer,e,0)}dispose(e){for(let t=0;t<this.addressBuffer.length;t++)e(Atomics.load(this.addressBuffer,t))}},l=class{constructor(){this.promise=new Promise((e,t)=>{this.reject=t,this.resolve=e})}};let u;(function(e){function t(){return`8.7.2`}e.sdkVersion=t})(u||={});let d={};function f(e){return[...new Uint8Array(e)].map(e=>{let t=e.toString(16);return t.length===1?`0${t}`:t}).join(``)}async function*p(e){let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)return;yield n}}finally{t.releaseLock()}}async function m(e){let t=[],n=0,r=0;for await(let r of p(e))t.push(r),n+=r.length;let i=new Uint8Array(n);for(let e of t)i.set(e,r),r+=e.length;return i.buffer}(function(e){return e.VALID=`VALID`,e.INVALID=`INVALID`,e.NOT_VERIFIABLE=`NOT_VERIFIABLE`,e})({});async function h(e,t,n){if(typeof crypto.subtle.digest!=`function`)return r.log(r.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 ${n} could not be verified`),`NOT_VERIFIABLE`;try{let i=e instanceof Promise?await e:e,a=f(await crypto.subtle.digest(`SHA-256`,i));return t==null?(r.log(r.Level.Warn,`The library hash is not defined or empty, cannot correctly verify integrity.`),`NOT_VERIFIABLE`):a===t?(r.log(r.Level.Debug,`Data Capture library WASM integrity found at ${n} has been verified correctly.`),`VALID`):(r.log(r.Level.Warn,`The Scandit Data Capture library WASM file found at ${n} seems invalid: expected file hash doesn't match (received: ${a}, expected: ${t}). Please ensure the correct Scandit Data Capture file (with correct version) is retrieved.`),`INVALID`)}catch(e){return r.log(r.Level.Warn,`Wasm response could not be verified`,e),`NOT_VERIFIABLE`}}let g=new Map([[`br`,4.4],[`gzip`,2.9],[`none`,1]]);function _(e){let t=`content-encoding`;if(e==null||e.get(t)==null)return g.get(`none`);let n=new Set((e.get(t)??``).split(`,`).map(e=>e.trim()));for(let[e,t]of g)if(n.has(e))return t;return g.get(`none`)}function v(e){if(e==null)return 0;let t=_(e)??1,n=Number.parseInt(e.get(`content-length`)??`0`,10);return Number.isNaN(n)?0:Math.floor(n*t*100)/100}function y(e){let{pathname:t}=new URL(e);for(let[e,n]of Object.entries(d))if(t.endsWith(e))return n.bytes;return 0}function b(e){d=e}let x=(e,t)=>{let n=v(t);return n===0?y(e):n};function S(e,t,n,{onProgress:i,onError:a,onComplete:o}){if(!t.body)return[t];let s=x(e,t.headers),c=0,l=0;if(typeof TransformStream>`u`)return r.warn(`TransformStream is not supported in this environment. Progress tracking will be disabled.`),[t];let[u,d]=n?t.body.tee():[t.body],f=u.pipeThrough(new TransformStream({async transform(t,n){try{c+=t.length,l=Number((c/s*100).toFixed(2)),s>0&&t.length>0&&l<100?i?.({percentage:l,loadedBytes:c,privateUri:e}):s===0&&t.length>0&&i?.({percentage:null,loadedBytes:c,privateUri:e}),n.enqueue(t)}catch(e){n.error(e),a?.({error:e})}},flush(t){i?.({percentage:100,loadedBytes:c,privateUri:e}),o?.({percentage:100,loadedBytes:c,privateUri:e}),t.terminate()}}));return[new Response(f,{headers:new Headers(t.headers),status:t.status,statusText:t.statusText}),d]}async function C({wasmURI:e,expectedHash:t,verifyResponseHash:n,onProgress:r,onComplete:i,onError:a,referredOrigin:o}){let s=await fetch(e,{referrerPolicy:`origin`,referrer:o??``});if(!s.ok)throw Error(`HTTP status code is not ok: ${s.status}, ${s.statusText}`);let[c,l]=S(e,s,n,{onProgress:r,onError:a,onComplete:i});return l!=null&&h(m(l),t,e),c}function w({wasmURI:e,expectedHash:t,verifyResponseHash:n,progressCallback:i,successCallback:a,errorCallback:o,importObject:s,referredOrigin:c}){async function l(l){try{let r=await C({wasmURI:e,expectedHash:t,verifyResponseHash:n,onProgress:i,referredOrigin:c}),o=await(l??r).arrayBuffer(),u=await globalThis.WebAssembly.instantiate(o,s);a(u.instance,u.module)}catch(t){r.log(r.Level.Error,t),r.log(r.Level.Error,`Couldn't instantiate Scandit SDK DataCapture library at ${e}, did you configure the path for it correctly?`),o?.(t)}}async function u(){let o;try{o=await C({wasmURI:e,expectedHash:t,verifyResponseHash:n,onProgress:i,referredOrigin:c});let r=await globalThis.WebAssembly.instantiateStreaming(o,s);a(r.instance,r.module)}catch(e){r.log(r.Level.Warn,e),r.log(r.Level.Warn,`WebAssembly streaming compile failed. Falling back to ArrayBuffer instantiation (this will make things slower)`),l(o?.bodyUsed===!0?void 0:o)}}typeof globalThis.WebAssembly.instantiateStreaming==`function`?u():l()}async function T(e,t,n,r){return new Promise((i,a)=>{e().then(i).catch(o=>{let s=t*2;if(s>n){a(o);return}r(o),globalThis.setTimeout(()=>{T(e,s,n,r).then(i).catch(a)},t)})})}function E(e){var t;let n=`unknown`;if((t=e.href)!=null&&t.startsWith(`blob:null/`))n=`localhost`;else{let t=e.pathname?.length>1&&!e.pathname.startsWith(`/`);n=new URL(t?e.pathname:e.origin).hostname}return n.startsWith(`[`)&&n.endsWith(`]`)?(n=n.slice(1,-1),n):(/^(\d{1,3}\.){3}\d{1,3}$/.test(n)&&(n=n.split(`.`).map(e=>Number.parseInt(e,10).toString()).join(`.`)),n)}function D(){if(FS.syncfs.sdcCoordinated===!0)return;let e=FS.syncfs.bind(FS),t,n=[];function r(t){return new Promise((n,r)=>{e(t,e=>{e==null?n():r(e)})})}function i(){t=void 0;let e=n.shift();e!=null&&a(e.populate).then(e.resolve,e.reject)}function a(e){let n=r(e);return t=n,n.then(i,i),n}function o(e,r){let i=typeof e==`function`,o=!i&&e,s=i?e:r,c;if(t==null)c=a(o);else{let e=n[n.length-1];if(e!=null&&e.populate===o)c=e.promise;else{let e,t,r=new Promise((n,r)=>{e=n,t=r});n.push({populate:o,promise:r,resolve:e,reject:t}),c=r}}c.then(()=>s(),e=>s(e))}o.sdcCoordinated=!0,FS.syncfs=o}async function O(e,t){D();let n;try{let a=new Promise((t,n)=>{FS.syncfs(e,e=>{e==null?t():n(e)})}),o=new Promise((e,a)=>{n=setTimeout(()=>{r.debug(`IndexedDB database is blocked (timed out after ${t}ms). If you are running a Debug wasm build, things are slower and the timeout can be configured via IndexedDBBlockedTimeoutMs in localStorage (requires page reload).`),a(new i({name:`BlockedIndexedDB`,message:`IndexedDB database is blocked`}))},t)});await Promise.race([a,o])}finally{n!==void 0&&clearTimeout(n)}}async function ee(e){try{FS.mkdir(e.writableDataPath)}catch(e){if(e.code!==`EEXIST`)throw e}return FS.mount(IDBFS,{autoPersist:!0},e.writableDataPath),O(!0,e.indexedDBTimeoutMs)}async function k(e){return O(!1,e.indexedDBTimeoutMs)}async function A(e,t){function n(e){try{return new URL(e,self.location.href).origin!==self.location.origin}catch(t){return r.log(r.Level.Warn,`Could not determine origin for WASM JS URL "${e}": ${t instanceof Error?t.message:String(t)}. Defaulting to same-origin path.`),!1}}function i(t){r.log(r.Level.Warn,t),r.log(r.Level.Warn,`Couldn't retrieve Scandit Data Capture library at ${e}, retrying...`)}try{if(n(e)){let t=await T(async()=>{let t=await fetch(e,{mode:`cors`,credentials:`omit`});if(!t.ok)throw Error(`Failed to load WASM JS script: ${e} (status ${t.status})`);let n=await t.blob();return/javascript|ecmascript/i.test(n.type)?n:new Blob([n],{type:`application/javascript`})},250,4e3,i),n=URL.createObjectURL(t);try{await importScripts(n)}finally{URL.revokeObjectURL(n)}self.Module.mainScriptUrlOrBlob=t}else await T(async()=>importScripts(e),250,4e3,i),self.Module.mainScriptUrlOrBlob=e;let a=globalThis.SDC_WASM_JS_VERSION;return a!==t&&r.log(r.Level.Warn,`The Scandit Data Capture library JS file found at ${e} seems invalid: expected version doesn't match (received: ${a}, expected: ${t}). Please ensure the correct Scandit Data Capture file (with correct version) is retrieved.`),!0}catch(e){return r.log(r.Level.Error,e),!1}}function j(e,t,n){let r=t*n,i=new Uint8ClampedArray(r*4),a=new Uint32Array(i.buffer);for(let t=0;t<r;t++){let n=e[t];a[t]=4278190080|n<<16|n<<8|n}return i}var M=class{constructor(e,t){this.workerFunctions=e,this.options=t,this.imageIdCounter=0,this.conversions=new Map}convertToJpeg(e,t){let n=this.imageIdCounter++,r=new l;this.conversions.set(n,r);let i=e.toBitmap();return this.workerFunctions.postMessage({type:`convertToJPEG`,imageId:n,width:e.getWidth(),height:e.getHeight(),data:i,planes:e.getPlanes(),orientation:t,quality:this.options.quality},Array.from(new Set([i.buffer]))),r.promise}convertToBitmap(e){return{data:e.toBitmap(),byteOrder:1}}onConvertToJPEGResult(e,t){let n=this.conversions.get(e);n?(n.resolve(t),this.conversions.delete(e)):r.warn(`ImageConverterForwarder: Conversion for imageId ${e} not found in Map`)}},N=class{constructor(e){this.options=e}get quality(){return this.options.quality}async convertToJpeg(e,t){try{let{width:n,height:r,planes:i}=this.validateAndExtractImageData(e);this.prepareCanvas(n,r);let a=this.processImageData(e,i,n,r);return await this.convertToJpegBytes(a,t)}catch(e){throw r.warn(`Failed to convert image to JPEG: ${e}`),e instanceof Error?e:Error(`Failed to convert image to JPEG`)}}convertToBitmap(e){return{data:e.toBitmap(),byteOrder:1}}validateAndExtractImageData(e){let t=e.getWidth(),n=e.getHeight(),i=e.getPlanes();if(t<=0||n<=0)throw r.warn(`Invalid image dimensions: ${t}x${n}`),Error(`Invalid image dimensions: ${t}x${n}`);if(!i||i.length===0)throw r.warn(`ImageBuffer has no planes`),Error(`ImageBuffer has no planes`);return{width:t,height:n,planes:i}}prepareCanvas(e,t){if(!this.ensureCanvas(e,t))throw Error(`Failed to create OffscreenCanvas`);if(!this.canvas||!this.context)throw Error(`Canvas or context not properly initialized`)}processImageData(e,t,n,r){let i=this.createImageDataFromBuffer(e,t,n,r);if(i===null)throw Error(`Failed to create ImageData`);return this.validateImageData(i,n,r),i}validateImageData(e,t,n){if(e.width!==t||e.height!==n)throw r.warn(`ImageData dimensions mismatch: expected ${t}x${n}, got ${e.width}x${e.height}`),Error(`ImageData dimensions mismatch`);if(!e.data||e.data.length!==t*n*4)throw r.warn(`ImageData has invalid data length: expected ${t*n*4}, got ${e.data?.length||0}`),Error(`ImageData has invalid data length`)}async convertToJpegBytes(e,t){if(!this.context||!this.canvas)throw Error(`Canvas or context not available`);try{this.context.putImageData(e,0,0)}catch(e){throw r.warn(`Failed to put image data on canvas: ${e}`),Error(`Failed to put image data on canvas: ${e}`)}let n=t===0?this.canvas:this.applyRotation(this.canvas,t),i;try{i=await this.canvasToBlob(n)}catch(e){throw r.warn(`Failed to convert canvas to blob: ${e}`),Error(`Failed to convert canvas to blob: ${e}`)}if(!i||i.size===0)throw r.warn(`Canvas convertToBlob returned empty or null blob`),Error(`Failed to create JPEG blob`);let a;try{a=await i.arrayBuffer()}catch(e){throw r.warn(`Failed to get array buffer from blob: ${e}`),Error(`Failed to get array buffer from blob: ${e}`)}if(!a||a.byteLength===0)throw r.warn(`Blob arrayBuffer returned empty or null buffer`),Error(`Failed to get array buffer from blob`);return new Uint8Array(a)}ensureCanvas(e,t){try{return(!this.canvas||this.canvas.width!==e||this.canvas.height!==t)&&(this.canvas=this.getNewCanvas(e,t),this.context=this.canvas.getContext(`2d`)),this.context!==null}catch(e){return r.warn(`Failed to create HTMLCanvasElement`,e),!1}}createImageDataFromBuffer(e,t,n,i){let a=new Set(t.map(e=>e.channel));try{if(this.isYUVFormat(a)){let t=e.toBitmap();return!t||t.length!==n*i*4?(r.warn(`Invalid bitmap data from toBitmap(): expected ${n*i*4} bytes, got ${t?.length||0}`),null):new ImageData(new Uint8ClampedArray(t),n,i)}if(this.isRGBAFormat(a))return this.createImageDataFromRGBAPlanes(t,n,i);if(this.isRGBFormat(a))return this.createImageDataFromRGBPlanes(t,n,i);if(this.isGrayscaleFormat(a))return this.createImageDataFromGrayscalePlanes(t,n,i);r.warn(`Unknown image format with channels: ${Array.from(a).join(`, `)}, falling back to toBitmap()`);let o=e.toBitmap();if(!o||o.length===0)return r.warn(`toBitmap() returned empty or null data`),null;let s=o.length/(n*i);return s===4?new ImageData(new Uint8ClampedArray(o),n,i):(r.warn(`Unsupported format: ${s} bytes per pixel`),null)}catch(e){return r.warn(`Failed to create ImageData: ${e}`),null}}isYUVFormat(e){return e.has(0)&&e.has(1)&&e.has(2)}isRGBAFormat(e){return e.has(3)&&e.has(4)&&e.has(5)&&e.has(6)}isRGBFormat(e){return e.has(3)&&e.has(4)&&e.has(5)&&!e.has(6)}isGrayscaleFormat(e){return e.has(0)&&!e.has(1)&&!e.has(2)}createImageDataFromRGBAPlanes(e,t,n){let i=e.find(e=>e.channel===3),a=e.find(e=>e.channel===4),o=e.find(e=>e.channel===5),s=e.find(e=>e.channel===6);if(!i||!a||!o||!s)return r.warn(`Missing RGBA planes`),null;let c=new Uint8ClampedArray(t*n*4);for(let e=0;e<n;e++)for(let n=0;n<t;n++){let r=(e*t+n)*4;c[r]=this.getPixelFromPlane(i,n,e),c[r+1]=this.getPixelFromPlane(a,n,e),c[r+2]=this.getPixelFromPlane(o,n,e),c[r+3]=this.getPixelFromPlane(s,n,e)}return new ImageData(c,t,n)}createImageDataFromRGBPlanes(e,t,n){let i=e.find(e=>e.channel===3),a=e.find(e=>e.channel===4),o=e.find(e=>e.channel===5);if(!i||!a||!o)return r.warn(`Missing RGB planes`),null;let s=new Uint8ClampedArray(t*n*4);for(let e=0;e<n;e++)for(let n=0;n<t;n++){let r=(e*t+n)*4;s[r]=this.getPixelFromPlane(i,n,e),s[r+1]=this.getPixelFromPlane(a,n,e),s[r+2]=this.getPixelFromPlane(o,n,e),s[r+3]=255}return new ImageData(s,t,n)}createImageDataFromGrayscalePlanes(e,t,n){let i=e.find(e=>e.channel===0);if(!i)return r.warn(`Missing Y plane for grayscale`),null;let a=new Uint8ClampedArray(t*n*4);for(let e=0;e<n;e++)for(let n=0;n<t;n++){let r=(e*t+n)*4,o=this.getPixelFromPlane(i,n,e);a[r]=o,a[r+1]=o,a[r+2]=o,a[r+3]=255}return new ImageData(a,t,n)}getPixelFromPlane(e,t,n){let r=Math.floor(t/(e.subsamplingX||1)),i=Math.floor(n/(e.subsamplingY||1)),a=e.rowStride,o=e.pixelStride,s=i*a+r*o,c=e.data;return s<c.length?c[s]:0}applyRotation(e,t){let n=t*Math.PI/180,r=t===90||t===270||t===-90||t===-270,i=r?e.height:e.width,a=r?e.width:e.height,o=this.getNewCanvas(i,a),s=o.getContext(`2d`);if(!s)throw Error(`Failed to get 2D context for rotated canvas`);return s.translate(i/2,a/2),s.rotate(n),s.translate(-e.width/2,-e.height/2),s.drawImage(e,0,0),o}};N.JPEG_IMAGE_MIME_TYPE=`image/jpeg`;var te=class extends N{getNewCanvas(e,t){return new OffscreenCanvas(e,t)}canvasToBlob(e){return e.convertToBlob({type:N.JPEG_IMAGE_MIME_TYPE,quality:this.options.quality})}},ne=class{constructor(e){this.viewInfo=null,this.viewInfo=this.cloneViewInfo(e)}isSame(e){return this.viewInfo==null&&e==null?!0:this.viewInfo==null&&e!=null||this.viewInfo!=null&&e==null?!1:this.viewInfo.width===e.width&&this.viewInfo.height===e.height&&this.viewInfo.orientation===e.orientation&&this.viewInfo.viewFinderRect.origin.x===e.viewFinderRect.origin.x&&this.viewInfo.viewFinderRect.origin.y===e.viewFinderRect.origin.y&&this.viewInfo.viewFinderRect.size.width===e.viewFinderRect.size.width&&this.viewInfo.viewFinderRect.size.height===e.viewFinderRect.size.height}update(e){this.viewInfo=this.cloneViewInfo(e)}cloneViewInfo(e){return e?{...e,viewFinderRect:{origin:{...e.viewFinderRect.origin},size:{...e.viewFinderRect.size}}}:null}},P=class e{constructor(e,t){this.hintPresenter=null,this.threadsSupport=!0,this.insufficientMultithreadingReported=!1,this.MAX_NUMBER_OF_IMAGES_IN_FRAME_DATA_POOL=5,this.redrawInterval=1e3/30,this.redrawRequests=[],this._isDrawLoopRunning=!1,this.frameDataPool=new Map,this.lastFrameColorType=`RGBA`,this.lastFrameId=null,this.indexedDBTimeoutMs=1500,this.flushAnalyticsTimeoutMs=5e3,this.poorMansBenchmarkLogs=!1,this.writableDataPathStandard=`/scandit_sync_folder`,this.resourceFilesSubfolder=`resources`,this.performanceMetricsReporterTimer=void 0,this.lastMetricsReportTime=0,this.metricsReportInterval=1e3,this.performanceMetrics={frameDataPoolSize:0,cameraOutputFrames:0,redrawRequestsCount:0,actualRedrawsCount:0,frameProcessingStartedCount:0,frameProcessedCount:0,frameSkippedCount:0,frameHandoffTotalMicros:0,frameHandoffCount:0},this.frameProcessingStartedCount=0,this.frameProcessingFinishedCount=0,this.gestureListener=null,this.webPlatformHintPresenter=null,this.deviceInstance=null,this.deviceInfo=null,this.lastViewInfo=new ne(null),this.lastFrameProcessingStartedCount=0,this.lastFrameProcessingFinishedCount=0,this.moduleHandler=e,this.workerFunctions=t,this._loadProgressCallback=this._loadProgressCallback.bind(this),b(this.getWasmMetadata())}get Module(){return this.moduleHandler.get()}set isDrawLoopRunning(e){this._isDrawLoopRunning=e,!e&&typeof this.loopTimeoutId==`number`&&(clearTimeout(this.loopTimeoutId),this.loopTimeoutId=void 0)}get isDrawLoopRunning(){return this._isDrawLoopRunning}prepareFrameForListener(e){let t=this.lastFrameId;if(this.frameDataPool.size>=this.MAX_NUMBER_OF_IMAGES_IN_FRAME_DATA_POOL){let e=this.frameDataPool.keys().next().value;e!=null&&this.frameDataPool.delete(e)}let n=e.getFrameData(),r=new Uint8ClampedArray(n);this.frameDataPool.set(t,{data:r,colorType:this.lastFrameColorType,frameId:t,width:e.getWidth(),height:e.getHeight()});let i=this.lastUsedModuleMirrorAxis!=null&&this.lastUsedModuleMirrorAxis!==this.Module.Axis.None;return{frameId:t,width:e.getWidth(),height:e.getHeight(),isFrameSourceMirrored:i,colorType:this.lastFrameColorType}}createContext(e){var t,n,r,i;let a=this.getModeDeserializers(),o=E(location);(o===`localhost`||o===`127.0.0.1`)&&navigator.userAgent.includes(`Electron`)&&e.appName!=null&&(o+=`-${e.appName}`),this.parentDomain=e.parentDomain,this.contextDeserializer=new this.Module.DataCaptureContextDeserializer(this.writableDataPath,e.deviceId,e.context.deviceModelName,o,this.parentDomain,a,e.highEndBlurryRecognition,this.resourcePath,e.context.deviceManufacturer);let s=this.contextDeserializer.contextFromJson(JSON.stringify(e.context));if(s==null){let e=this.contextDeserializer.getLastError();throw Error(`Could not create the context: ${e}`)}let c=s.getView();this.context=s.getContext(),this.insufficientMultithreadingReported=!1,s.delete(),this.setupDeviceInterface(e.isTablet,e.batteryInfo);let l=this.Module.DataCaptureContextListener.extend(`DataCaptureContextListener`,{didChangeStatus:(e,t)=>{this.contextDidChangeStatus(JSON.parse(t.toJson())),e.delete()},didStartObservingContext:e=>{this.didStartObservingContext(),e.delete()},didStopObservingContext:e=>{e.delete()}}),u=this.Module.DataCaptureContextFrameListener.extend(`DataCaptureContextFrameListener`,{onObservationStarted:e=>{e.delete()},onObservationStopped:e=>{e.delete()},onFrameProcessingStarted:(e,t)=>{this.workerFunctions.postMessage({type:`onFrameProcessingStarted`}),t.delete(),e.delete()},onFrameProcessingFinished:(e,t)=>{this.workerFunctions.postMessage({type:`onFrameProcessingFinished`}),t.delete(),e.delete()},onFrameSkipped:(e,t)=>{this.workerFunctions.postMessage({type:`onFrameSkipped`}),t.delete(),e.delete()}}),d=this.Module.GestureRecognizer.extend(`GestureRecognizer`,{setGestureListener:(e,t)=>{var n;(n=this.gestureListener)==null||n.delete(),this.gestureListener=e.clone(),e.delete()}});(t=this.gestureRecognizer)==null||t.delete(),this.gestureRecognizer=new d;let f=new l;this.context.addListener(f),f.delete();let p=new u;this.context.addFrameListener(p),p.delete(),this.setView(c),(n=this.view)==null||n.setGestureRecognizer(this.gestureRecognizer);let m=this.Module.PlatformHintPresenter.extend(`PlatformHintPresenter`,{setHintPresenter:e=>{e.delete()},showToast:e=>{this.workerFunctions.postMessage({type:`showToast`,payload:JSON.parse(e)})},hideToast:e=>{this.workerFunctions.postMessage({type:`hideToast`,payload:JSON.parse(e)})},showGuidance:e=>{this.workerFunctions.postMessage({type:`showGuidance`,payload:JSON.parse(e)})},hideGuidance:e=>{this.workerFunctions.postMessage({type:`hideGuidance`,payload:JSON.parse(e)})},startUpdateTimer:e=>{this.workerFunctions.postMessage({type:`startUpdateTimer`,payload:{duration:{unit:`ms`,value:e}}})},stopUpdateTimer:()=>{this.workerFunctions.postMessage({type:`stopUpdateTimer`})}});if((r=this.hintPresenter)==null||r.delete(),this.hintPresenter=null,(i=this.webPlatformHintPresenter)==null||i.delete(),this.webPlatformHintPresenter=null,this.webPlatformHintPresenter=new m,this.view){var h;this.hintPresenter=new this.Module.HintPresenter(this.webPlatformHintPresenter),(h=this.view)==null||h.setHintPresenter(this.hintPresenter)}this.webImageConverterInstance=this.getImageConverterInstance({quality:1}),this.Module.ImageConverter.setInstance(this.webImageConverterInstance)}convertToJPEGResult(e,t){this.webImageConverterInstance instanceof M&&this.webImageConverterInstance.onConvertToJPEGResult(e,t)}getImageConverterInstance(e){return this.workerFunctions.getOffscreenCanvas()==null?new M(this.workerFunctions,e):new te(e)}onTap(e){var t;(t=this.gestureListener)==null||t.onTap(JSON.stringify(e))}hintPresenterUpdate(){var e;(e=this.hintPresenter)==null||e.update()}startReportingPerformanceMetrics(){this.performanceMetricsReporterTimer??(this.lastMetricsReportTime=performance.now(),this.scheduleMetricsReporting())}scheduleMetricsReporting(){this.performanceMetricsReporterTimer=setTimeout(()=>{this.checkAndReportMetrics()},100)}checkAndReportMetrics(){let e=performance.now();e-this.lastMetricsReportTime>=this.metricsReportInterval&&(this.reportPerformanceMetrics(),this.performanceMetrics.cameraOutputFrames=0,this.performanceMetrics.redrawRequestsCount=0,this.performanceMetrics.actualRedrawsCount=0,this.performanceMetrics.frameHandoffTotalMicros=0,this.performanceMetrics.frameHandoffCount=0,this.lastMetricsReportTime=e),this._isDrawLoopRunning?this.scheduleMetricsReporting():this.performanceMetricsReporterTimer=void 0}async reportPerformanceMetrics(){let e=this.frameProcessingStartedCount-this.lastFrameProcessingStartedCount,t=this.frameProcessingFinishedCount-this.lastFrameProcessingFinishedCount;this.lastFrameProcessingStartedCount=this.frameProcessingStartedCount,this.lastFrameProcessingFinishedCount=this.frameProcessingFinishedCount;let n={cameraOutputFrames:this.performanceMetrics.cameraOutputFrames,redrawRequestsCount:this.performanceMetrics.redrawRequestsCount,actualRedrawsCount:this.performanceMetrics.actualRedrawsCount,frameDataPoolSize:this.performanceMetrics.frameDataPoolSize,frameProcessingStartedCount:e,frameProcessedCount:t,frameSkippedCount:this.performanceMetrics.frameSkippedCount,frameHandoffTotalMicros:this.performanceMetrics.frameHandoffTotalMicros,frameHandoffCount:this.performanceMetrics.frameHandoffCount};this.workerFunctions.postMessage({type:`performanceMetricsReport`,payload:n})}deleteFrameData(e){this.frameDataPool.delete(e)}releaseAreGlowBridge(){}dispose(){var e,t,n,r,i,a;this.context.dispose(),(e=this.sharedFrameMemAddressSlotPool)==null||e.dispose(e=>this.Module.deleteUint8Array(e)),this.sharedFrameMemAddressSlotPool=void 0,this.frameDataPool.clear(),this.isDrawLoopRunning=!1,this.cleanupMetricsReporting(),(t=this.gestureRecognizer)==null||t.delete(),this.gestureRecognizer=null,(n=this.gestureListener)==null||n.delete(),this.gestureListener=null,(r=this.hintPresenter)==null||r.delete(),this.hintPresenter=null,(i=this.webPlatformHintPresenter)==null||i.delete(),this.webPlatformHintPresenter=null,(a=this.deviceInstance)==null||a.delete(),this.deviceInstance=null,this.deviceInfo=null}cleanupMetricsReporting(){this.performanceMetricsReporterTimer!=null&&(typeof this.performanceMetricsReporterTimer==`number`?cancelAnimationFrame(this.performanceMetricsReporterTimer):clearTimeout(this.performanceMetricsReporterTimer),this.performanceMetricsReporterTimer=void 0)}async flushAnalytics(){await this.waitForNativeFlushAnalytics(this.context,this.flushAnalyticsTimeoutMs),await this.syncAnalyticsToFilesystem()}flushAnalyticsWithoutWaitingForUpload(e){e.flushAnalytics(()=>{}),this.syncAnalyticsToFilesystem()}async waitForNativeFlushAnalytics(e,t){await new Promise(n=>{let i=!1,a=setTimeout(()=>{i||(i=!0,n())},t);try{e.flushAnalytics(()=>{i||(i=!0,clearTimeout(a),n())})}catch(e){r.error(`context.flushAnalytics threw`,e),i||(i=!0,clearTimeout(a),n())}})}async syncAnalyticsToFilesystem(){try{await k({indexedDBTimeoutMs:this.indexedDBTimeoutMs})}catch(e){r.error(`Failed to flush analytics`,e)}}reportInsufficientMultithreadingIfNeeded(e){if(this.threadsSupport||this.insufficientMultithreadingReported)return;this.insufficientMultithreadingReported=!0;let t=new this.Module.InsufficientMultithreadingAnalyticsData(e);this.Module.InsufficientMultithreadingAnalyticsHelper.storeAnalyticsEvent(this.context,t),t.delete()}extractCentaurusLicense(t){return{payload:{centaurus:{licenseKey:this.Module.LicenseUtils[e.get3dPartyLicenseKeyMethodName](t)}}}}getModeDeserializers(){return new this.Module.VectorDataCaptureModeDeserializer}loadLibrary(e){return this.libraryLoadingPromise??=this.setup(e),this.libraryLoadingPromise}processFrame(e){var t;if(this.context==null)return r.debug(`[processFrame] Context is null, returning frame without processing`),{payload:e,transferables:[e.data.buffer]};this.lastFrameId=e.frameId;let n=e.data,i=e.colorType===`GRAYSCALE`?this.Module.ImageBufferFormat.Grayscale8:this.Module.ImageBufferFormat.Rgba8888;this.lastFrameColorType=e.colorType===`GRAYSCALE`?`GRAYSCALE`:`RGBA`;let a=this.Module.allocateUint8Array(n.byteLength);return this.Module.HEAPU8.set(n,a),(t=this.imageFrameSource)==null||t.outputFrame(a,e.width,e.height,i),{payload:e,transferables:[e.data.buffer]}}negotiateSharedFramePath(e){var t;return this.Module.HEAPU8.buffer instanceof SharedArrayBuffer?((t=this.sharedFrameMemAddressSlotPool)==null||t.dispose(e=>this.Module.deleteUint8Array(e)),this.sharedFrameMemAddressSlotPool=c.create({memAddressSlotCount:e.memAddressSlotCount,memAddressSlotByteLength:e.memAddressSlotByteLength,allocateUint8Array:e=>this.Module.allocateUint8Array(e),getHeapBuffer:()=>this.Module.HEAPU8.buffer}),{payload:this.sharedFrameMemAddressSlotPool.buffers}):{payload:null}}processFrameFromMemAddressSlot(e){var t;if(this.context==null||this.sharedFrameMemAddressSlotPool==null)return;let n=this.sharedFrameMemAddressSlotPool.beginProcessing(e.memAddressSlotIndex);if(n==null)return;this.lastFrameId=e.frameId,this.lastFrameColorType=e.colorType===`GRAYSCALE`?`GRAYSCALE`:`RGBA`;let r=e.colorType===`GRAYSCALE`?this.Module.ImageBufferFormat.Grayscale8:this.Module.ImageBufferFormat.Rgba8888;(t=this.imageFrameSource)==null||t.outputFrame(n.address,e.width,e.height,r);let i=this.Module.allocateUint8Array(this.sharedFrameMemAddressSlotPool.buffers.memAddressSlotByteLength);this.sharedFrameMemAddressSlotPool.release(n.index,i)}reportCameraProperties(e){this.context.setCameraProperties(e.deviceId,e.isFrontFacing,e.hasAutofocus)}requestFrameData(e){let t=this.frameDataPool.get(e);if(t==null)return{payload:{data:null,frameId:null,colorType:null}};if(t.data.buffer.byteLength===0)return this.frameDataPool.delete(e),{payload:{data:null,frameId:null,colorType:null}};let n=t.data;t.colorType===`GRAYSCALE`&&(n=j(t.data,t.width,t.height));let r={payload:{data:n,frameId:t.frameId,colorType:t.colorType},transferables:[n.buffer]};return this.frameDataPool.delete(e),r}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 n;this.lastUsedModuleMirrorAxis=this.mapMirrorAxisOnModule(e),(n=this.imageFrameSource)==null||n.delete(),this.imageFrameSource=new this.Module.ImageBufferFrameSource(this.lastUsedModuleMirrorAxis,t,0),this.context.setFrameSource(this.imageFrameSource)}startDrawLoop(e){this.isDrawLoopRunning=!0;let t=e=>this.redrawRequests.length>0&&this.redrawRequests[0]<=e,n=e=>{for(;this.redrawRequests.length>0&&this.redrawRequests[0]<=e;)this.redrawRequests.shift()},r=()=>{this.loopTimeoutId=setTimeout(()=>{if(!this.isDrawLoopRunning)return;let i=performance.now();if(t(i)){n(i),e.draw();let t=e.getDrawCommands();this.sendViewRefreshCommands(new Uint8Array(t))}r()},this.redrawInterval)};r()}updateContext(e){if(this.context!=null&&this.contextDeserializer!=null){e.view!=null&&!e.view.visible&&this.context.flushAnalytics(()=>{});let t=this.onBeforeUpdateContextHook(e),n=this.contextDeserializer.updateContextFromJson(this.context,this.view,JSON.stringify(t.context));if(n==null){let e=this.contextDeserializer.getLastError();throw Error(`Could not update the context: ${e}`)}this.context.delete(),this.context=n.getContext(),this.insufficientMultithreadingReported=!1;let i=n.getView();n.delete(),i!=null&&t.view!=null&&(i.setViewSize(t.view.width,t.view.height,t.view.orientation),i.draw()),!this.hintPresenter&&this.webPlatformHintPresenter&&(this.hintPresenter=new this.Module.HintPresenter(this.webPlatformHintPresenter)),i!=null&&this.hintPresenter&&i.setHintPresenter(this.hintPresenter),this.gestureRecognizer!=null&&i?.setGestureRecognizer(this.gestureRecognizer),this.setView(i),this.notifyMainThreadOnViewInfoChanged(i),r.debug(`context updated`,t)}}notifyMainThreadOnViewInfoChanged(e){let t=this.getViewInfo(e);this.lastViewInfo.isSame(t)||(this.lastViewInfo.update(t),this.workerFunctions.postMessage({type:`viewSizeChanged`,payload:t}))}getViewInfo(e){if(e!=null)try{let t=JSON.parse(e.getViewInfo());if(t!=null){let e=this.getOrientationFromNumber(t.orientation);return{...t,orientation:e}}}catch(e){r.error(`Failed to get view size`,e)}return null}getOrientationFromNumber(e){switch(e){case 90:return`landscapeRight`;case 180:return`portraitUpsideDown`;case 270:return`landscapeLeft`;default:return`portrait`}}onBeforeUpdateContextHook(e){return e}onDocumentVisibilityChange(e){e===`hidden`&&this.flushAnalyticsWithoutWaitingForUpload(this.context)}isFeatureSupported(e){return{payload:{supported:this.context.isFeatureSupported(e)}}}getViewfinderInfo(){let e=this.getViewInfo(this.view);return{payload:{isDisplayingViewfinder:this.view?.isDisplayingViewfinder()??!1,rect:JSON.parse(this.view.getViewfinderRect()),width:e?.width??0,height:e?.height??0}}}getOpenSourceSoftwareLicenseInfo(){return{payload:{licenseText:this.Module.OpenSourceSoftwareLicenseInfo.getLicenseText()}}}getWasmDynamicLibraries(e){return this.getWasmSideModuleFileName()==null?[]:[`${e.replace(/\/[^/]*$/,`/`)}${this.getWasmSideModuleFileName()}`]}getWasmCoreExpectedHash(e,t){return t?e?`d1eb097cb4e2f773466fad9656a30ca8bf2e1543b0818a5adb65a2dff40c8e43`:`d82fea809167effacae861b1556e869799456a4e0fa301871213bdc99467500e`:e?`93071c6fffe21a8c19f578b3beee657ade248b49cda2a69338b8e23346b0abd1`:``}getWasmCoreFileName(e,t){return t?e?`scandit-datacapture-sdk-barcode-simd-pthreads.wasm`:`scandit-datacapture-sdk-barcode-pthreads.wasm`:e?`scandit-datacapture-sdk-barcode-simd.wasm`:``}getWasmMetadata(){return{"scandit-datacapture-sdk-barcode-pthreads.wasm":{bytes:8443120},"scandit-datacapture-sdk-barcode-simd-pthreads.wasm":{bytes:8383319},"scandit-datacapture-sdk-barcode-simd.wasm":{bytes:8435027},"scandit-datacapture-sdk-barcode.wasm":{bytes:8514451}}}getWasmSideModuleFileName(){return``}_loadProgressCallback(e){this.workerFunctions.postMessage({type:`loadLibraryProgress`,payload:e})}addRedrawRequest(e){this.redrawRequests.push(Math.round(performance.now())+e),this.redrawRequests.sort((e,t)=>e-t)}contextDidChangeStatus(e){e.code===260?e.message=e.message.replace(`domain name`,`domain name (${E(location)})`):e.code===265?e.message=e.message.replace(`domain name`,`domain name (${this.parentDomain})`):e.code===28&&(e.message+=` Resource files were expected at "${this.resourcePath}". This can be caused by a version mismatch, e.g. a browser or CDN cache still holding files from a previous SDK version. Please ensure the correct Scandit Data Capture resource files (with correct version) are retrieved.`),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??(this.isDrawLoopRunning=!1,this.sendViewRefreshCommands(new Uint8Array([])))}addNativeOverlay(e){r.warn(`addNativeOverlay has not been implemented for this module`,e)}removeNativeOverlay(e){r.warn(`removeNativeOverlay has not been implemented for this module`,e)}setViewRefreshHandler(e){if(e==null||e.isViewRefreshHandlerSet)return;let t=new(this.Module.NeedsRedrawDelegate.extend(`NeedsRedrawDelegate`,{setNeedsRedrawIn:this.scheduleRedraw.bind(this,e)}));e.setNeedsRedrawDelegate(t),e.isViewRefreshHandlerSet=!0}setupDataDecoding(){let e=this.moduleHandler.get(),t=e.DataDecoding.extend(`DataDecoding`,{decode(e,t){try{let n=JSON.parse(t),r=[];for(let t of n){let n=new TextDecoder(t.ianaName,{fatal:!0});r.push(n.decode(e.slice(t.startIndex,t.endIndex)))}return r.join(``)}catch{return``}}});e.setDataDecoding(new t)}getBatteryData(){var e;let t=(e=this.deviceInfo)==null||(e=e.batteryInfo)==null?void 0:e.percentage;if(t!=null)return{percentage:t}}isTablet(){return this.deviceInfo?.isTablet??!1}getDeviceState(){return{powerSaveMode:void 0,batteryHealth:void 0}}setupDeviceInterface(e,t){this.deviceInfo={isTablet:e,batteryInfo:t};let n=this.moduleHandler.get(),r=n.DeviceInterface.extend(`DeviceInterface`,{getBatteryData:this.getBatteryData.bind(this),isTablet:this.isTablet.bind(this),getDeviceState:this.getDeviceState.bind(this)});this.deviceInstance=new r,n.DeviceHolder.setCurrentDevice(this.deviceInstance)}updateBatteryInfo(e){this.deviceInfo&&(this.deviceInfo.batteryInfo=e)}start(e,t,n){e&&t&&(this.setupDataDecoding(),this.moduleHandler.get().callMain(),this.moduleHandler.get().__emscripten_proxy_main===void 0&&n())}getWritableDataPath(e){return e==null?this.writableDataPathStandard:(r.debug(`IndexedDB database name override in use to recover from blocked standard database: ${e}`),e)}numOfMBToPages(e){return Math.ceil(1024*e*1024/64/1024)}async setup({libraryLocation:e,locationPath:t,writableDataPathOverride:n,indexedDBTimeoutMs:a,verifyResponseHash:o,referredOrigin:c,fixedWasmMemory:d,simdSupport:f,threadsSupport:p}){let m=!1,h=!1;this.threadsSupport=p,this.writableDataPath=this.getWritableDataPath(n),this.indexedDBTimeoutMs=a,this.resourcePath=`${e}${this.resourceFilesSubfolder}/`,globalThis.path=t;let{resolve:g,reject:_,promise:v}=new l,y=u.sdkVersion();if(y===``)throw new i({name:`Invalid library version`,message:`Library version is not defined or empty, cannot generate proper path to library files.`});let{jsURI:b,wasmURI:x}=s(y,e,this.getWasmCoreFileName(f,p)),S={instantiateWasm:(e,t)=>(w({importObject:e,wasmURI:x,expectedHash:this.getWasmCoreExpectedHash(f,p),verifyResponseHash:o,successCallback:t,progressCallback:this._loadProgressCallback,errorCallback:e=>{_(e)},referredOrigin:c}),{})},C=d===null?null:new WebAssembly.Memory({initial:this.numOfMBToPages(d),maximum:this.numOfMBToPages(300),shared:p});return C!==null&&r.log(r.Level.Debug,`Fixed wasmMemory set`,C),this.moduleHandler.set({...C?{wasmMemory:C}:{},mainScriptUrlOrBlob:b,canvas:this.workerFunctions.getOffscreenCanvas()??{getContext:()=>null},...S,dynamicLibraries:this.getWasmDynamicLibraries(x),locateFile:t=>e+t,noInitialRun:!0,preRun:[async()=>{try{await ee({writableDataPath:this.writableDataPath,indexedDBTimeoutMs:a})}catch(e){if(e.name===`BlockedIndexedDB`){_(e.toString());return}r.log(r.Level.Debug,`No IndexedDB support, some data will not be persisted:`,e)}h=!0,this.start(h,m,g)}],onMainComplete:()=>{if([m,h].includes(!1)){r.log(r.Level.Warn,{runtimeLoaded:m,fileSystemSynced:h},`Both runtimeLoaded and fileSystemSynced should be true when calling onMainComplete`),_(`onMainComplete has been called but runtime or file system was not ready.`);return}g()},onRuntimeInitialized:()=>{m=!0,this.start(h,m,g)},print:e=>{r.info(e)}}),await A(b,y)||_(`Couldn't retrieve Scandit Data Capture library at ${b}, did you configure the path for it correctly?`),v}};P.get3dPartyLicenseKeyMethodName=atob(`Z2V0QmxpbmtJZExpY2Vuc2VLZXk=`);function re(e){console.warn(`Reached unexpected case`,e)}function ie(e){return typeof e==`object`&&!!e&&e.document==null&&`addEventListener`in e&&typeof e.importScripts==`function`}var ae=class{constructor(e){if(typeof e!=`function`)throw TypeError(`FinalizationRegistry callback must be a function`)}register(e,t,n){}unregister(e){return!1}};function oe(e){e.FinalizationRegistry===void 0&&(e.FinalizationRegistry=ae)}var se=class{constructor(e,t){this.onMessageListener=this.onMessage.bind(this),this.workerSelf=e,this.dataCaptureInstance=new P(t,{postMessage:this.postMessage.bind(this),getOffscreenCanvas:this.getOffscreenCanvas.bind(this)}),ie(e)&&(oe(e),this.listenToMessages())}listenToMessages(){this.workerSelf.addEventListener(`message`,this.onMessageListener),this.workerSelf.addEventListener(`error`,e=>{r.log(r.Level.Error,e)}),this.workerSelf.addEventListener(`messageerror`,e=>{r.log(r.Level.Error,e)})}postMessage(e,t){this.workerSelf.postMessage(e,t??[])}getOffscreenCanvas(){if(this.isOffscreenCanvasSupported())return new this.workerSelf.OffscreenCanvas(32,32)}isOffscreenCanvasSupported(){return typeof this.workerSelf.OffscreenCanvas==`function`}hasPayload(e){return t(e)&&`payload`in e}hasTransferables(e){return t(e)&&Array.isArray(e.transferables)}async respondWith(e,t,r){let i=null,a;try{a=r(),a instanceof Promise&&(a=await a)}catch(e){a=void 0,i=n(e)}let o={type:`workerTaskId`,command:e,id:t,payload:this.hasPayload(a)?a.payload:void 0};i!=null&&(o.error=i),this.postMessage(o,this.hasTransferables(a)?a.transferables:[])}onMessage(e){switch(e.data.command){case`loadLibrary`:{let{data:t}=e;this.respondWith(t.command,t.id,async()=>this.dataCaptureInstance.loadLibrary({libraryLocation:t.libraryLocation,locationPath:t.locationPath,referredOrigin:t.referredOrigin,writableDataPathOverride:t.writableDataPathOverride,threadsSupport:t.threadsSupport,simdSupport:t.simdSupport,verifyResponseHash:t.verifyResponseHash,fixedWasmMemory:t.fixedWasmMemory,indexedDBTimeoutMs:t.indexedDBTimeoutMs}))}break;case`onTap`:{let{data:t}=e;this.respondWith(t.command,t.id,async()=>{this.dataCaptureInstance.onTap(t.point)})}break;case`hintPresenterUpdate`:{let{data:t}=e;this.respondWith(t.command,t.id,async()=>{this.dataCaptureInstance.hintPresenterUpdate()})}break;case`createContext`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.createContext({context:t.context,deviceId:t.deviceId,highEndBlurryRecognition:t.highEndBlurryRecognition,appName:t.appName,parentDomain:t.parentDomain,isTablet:t.isTablet,batteryInfo:t.batteryInfo}))}break;case`setFrameSource`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.setFrameSource(t.mirrorAxis,t.isCameraFrameSource))}break;case`processFrame`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.processFrame({data:t.data,frameId:t.frameId,width:t.width,height:t.height,colorType:t.colorType}))}break;case`negotiateSharedFramePath`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.negotiateSharedFramePath({memAddressSlotByteLength:t.memAddressSlotByteLength,memAddressSlotCount:t.memAddressSlotCount}))}break;case`processFrameFromMemAddressSlot`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.processFrameFromMemAddressSlot({memAddressSlotIndex:t.memAddressSlotIndex,frameId:t.frameId,width:t.width,height:t.height,colorType:t.colorType}))}break;case`requestFrameData`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.requestFrameData(t.frameId))}break;case`deleteFrameData`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>{this.dataCaptureInstance.deleteFrameData(t.frameId)})}break;case`releaseAreGlowBridge`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>{this.dataCaptureInstance.releaseAreGlowBridge()})}break;case`updateContext`:{let{data:t}=e;this.respondWith(t.command,t.id,async()=>this.dataCaptureInstance.updateContext(t))}break;case`dispose`:this.respondWith(e.data.command,e.data.id,()=>this.dataCaptureInstance.dispose());break;case`flushAnalytics`:this.respondWith(e.data.command,e.data.id,async()=>this.dataCaptureInstance.flushAnalytics());break;case`reportCameraProperties`:{let{data:t}=e;this.respondWith(t.command,t.id,async()=>this.dataCaptureInstance.reportCameraProperties(t))}break;case`setLogLevel`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>{r.setLevel(t.level)})}break;case`updateBatteryInfo`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>{this.dataCaptureInstance.updateBatteryInfo(t.batteryInfo)})}break;case`extractCentaurusLicense`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.extractCentaurusLicense(t.licenseKey))}break;case`documentVisibility`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>{this.dataCaptureInstance.onDocumentVisibilityChange(t.state)})}break;case`isFeatureSupported`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.isFeatureSupported(t.feature))}break;case`getViewfinderInfo`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.getViewfinderInfo())}break;case`getOpenSourceSoftwareLicenseInfo`:{let{data:t}=e;this.respondWith(t.command,t.id,()=>this.dataCaptureInstance.getOpenSourceSoftwareLicenseInfo())}break;case`addNativeOverlay`:this.dataCaptureInstance.addNativeOverlay(e);break;case`removeNativeOverlay`:this.dataCaptureInstance.removeNativeOverlay(e);break;case`convertToJPEGResult`:{let{data:t}=e;this.dataCaptureInstance.convertToJPEGResult(t.imageId,t.result)}break;default:return re(e.data),!1}return!0}},F;e((()=>{F=class e{constructor(e,t){this._x=e,this._y=t}get x(){return this._x}get y(){return this._y}static mirrorX(t,n){let r=t.x-n.width;return r*=-1,new e(r,t.y)}static fromJSON(t){return new e(t.x,t.y)}toJSONObject(){return{x:this.x,y:this.y}}static areEquals(e,t){return e.x===t.x&&e.y===t.y}equals(e){return this.x===e.x&&this.y===e.y}}}))();var I=class e{constructor(e,t,n,r){this._topLeft=e,this._topRight=t,this._bottomRight=n,this._bottomLeft=r}get topLeft(){return this._topLeft}get topRight(){return this._topRight}get bottomRight(){return this._bottomRight}get bottomLeft(){return this._bottomLeft}static fromJSON(t){return new e(F.fromJSON(t.topLeft),F.fromJSON(t.topRight),F.fromJSON(t.bottomRight),F.fromJSON(t.bottomLeft))}toJSONObject(){return{topLeft:this.topLeft.toJSONObject(),topRight:this.topRight.toJSONObject(),bottomLeft:this.bottomLeft.toJSONObject(),bottomRight:this.bottomRight.toJSONObject()}}},L=class e{get endIndex(){return this._endIndex}get ianaName(){return this._ianaName}get startIndex(){return this._startIndex}static fromJSON(t){let n=new e;return n._ianaName=t.ianaName,n._startIndex=t.startIndex,n._endIndex=t.endIndex,n}toJSONObject(){return{endIndex:this.endIndex,ianaName:this.ianaName,startIndex:this.startIndex}}},R=class e{get barcodeSetId(){return this._barcodeSetId}get completeData(){return this._completeData}get encodingRanges(){return this._encodingRanges}get isComplete(){return this._complete}get rawCompleteData(){return this._rawCompleteData}get scannedSegmentCount(){return this._scannedSegmentCount}get totalSegmentCount(){return this._totalSegmentCount}static fromJSON(t){if(t==null)return null;let n=new e;return n._complete=t.complete,n._barcodeSetId=t.barcodeSetId,n._scannedSegmentCount=t.scannedSegmentCount,n._totalSegmentCount=t.totalSegmentCount,n._encodingRanges=t.completeDataEncodings.map(e=>L.fromJSON(e)),n._completeData=t.completeDataUtf8String,n._rawCompleteData=t.completeDataRaw,n}toJSONObject(){return{complete:this._complete,barcodeSetId:this.barcodeSetId,scannedSegmentCount:this.scannedSegmentCount,totalSegmentCount:this.totalSegmentCount,completeDataEncodings:this._encodingRanges.map(e=>e.toJSONObject()),completeDataUtf8String:this.completeData,completeDataRaw:this.rawCompleteData}}},z=class e{get isStructuredAppend(){return this._structuredAppendData!=null}get structuredAppendData(){return this._structuredAppendData}get addOnData(){return this._addOnData}get compositeData(){return this._compositeData}get compositeFlag(){return this._compositeFlag}get compositeRawData(){return this._compositeRawData}get data(){return this._data}get encodingRanges(){return this._encodingRanges}get frameID(){return this._frameID}get isColorInverted(){return this._isColorInverted}get isGS1DataCarrier(){return this._isGS1DataCarrier}get location(){return this._location}get rawData(){return this._rawData}get symbolCount(){return this._symbolCount}get symbology(){return this._symbology}static fromJSON(t){let n=new e;return n._symbology=t.symbology,n._data=t.data,n._rawData=t.rawData,n._compositeData=t.compositeData,n._compositeRawData=t.compositeRawData,n._addOnData=t.addOnData??null,n._isGS1DataCarrier=t.isGS1DataCarrier,n._compositeFlag=t.compositeFlag,n._isColorInverted=t.isColorInverted,n._symbolCount=t.symbolCount,n._frameID=t.frameId,n._encodingRanges=t.encodingRanges.map(e=>L.fromJSON(e)),n._location=I.fromJSON(t.location),n._structuredAppendData=R.fromJSON(t.structuredAppendData),n}toJSONObject(){return{symbology:this.symbology.toString(),data:this.data,rawData:this.rawData,compositeData:this.compositeData,compositeRawData:this.compositeRawData,addOnData:this.addOnData??null,isGS1DataCarrier:this.isGS1DataCarrier,compositeFlag:this.compositeFlag.toString(),isColorInverted:this.isColorInverted,symbolCount:this.symbolCount,frameId:this.frameID,encodingRanges:this.encodingRanges.map(e=>e.toJSONObject()),location:this.location.toJSONObject(),structuredAppendData:this.structuredAppendData?.toJSONObject()??null}}};function B(e){return JSON.stringify(Array.from({length:e},(e,t)=>t))}let V=`null`;var H=class{constructor(e,t,n){this.barcodeAr=null,this.nativeFilter=null,this.filterAppliedToNativeMode=!1,this.customerFilter=null,this.coreEngine=e,this.Module=t,this.workerFunctions=n}async forSettings(e,t){this.customerFilter=t??null,this.filterAppliedToNativeMode=!1,this.barcodeAr?.delete(),this.barcodeAr=new this.Module.BarcodeAr(this.coreEngine.context,JSON.stringify(e));let n=this.Module.BarcodeArListener.extend(`BarcodeArListener`,{didUpdateSession:(e,t,n)=>{let r=this.coreEngine.prepareFrameForListener(n);this.workerFunctions.postMessage({type:`barcodeArDidUpdateSession`,payload:{session:JSON.parse(t.toJsonIgnoringLicense()),frameData:r}}),e.delete(),t.delete(),n.delete()}});this.barcodeAr.addListener(new n,1),this.attachFilterToNativeMode(),this.Module.addBarcodeArToContext(this.coreEngine.context,this.barcodeAr),this.coreEngine.reportInsufficientMultithreadingIfNeeded(`BarcodeAr`)}start(){this.barcodeAr?.start()}pause(){this.barcodeAr?.pause()}stop(){this.barcodeAr?.stop()}setEnabled(e){this.barcodeAr?.setEnabled(e)}async removeMode(){this.barcodeAr!=null&&this.Module.removeBarcodeArFromContext(this.coreEngine.context,this.barcodeAr)}applySettings(e){this.barcodeAr?.applySettings(JSON.stringify(e))}setFilterFunction(e){this.customerFilter=e??null,this.attachFilterToNativeMode()}attachFilterToNativeMode(){if(this.barcodeAr!=null){if(this.customerFilter==null){this.filterAppliedToNativeMode&&=(this.barcodeAr.clearBarcodeFilter(),!1);return}this.nativeFilter??=this.createNativeFilter(),this.barcodeAr.setBarcodeFilter(this.nativeFilter),this.filterAppliedToNativeMode=!0}}createNativeFilter(){return new(this.Module.BarcodeArFilter.extend(`BarcodeArFilter`,{filterBarcodes:e=>this.keptBarcodeIndices(e)}))}keptBarcodeIndices(e){let t;try{t=JSON.parse(e)}catch{return V}if(!Array.isArray(t))return V;let n=this.customerFilter;if(n==null)return B(t.length);try{let e=t.map(e=>z.fromJSON(e)),r=n(e);if(!Array.isArray(r))return B(e.length);let i=new Set;for(let t of r){let n=e.indexOf(t);n!==-1&&i.add(n)}return JSON.stringify([...i])}catch{return B(t.length)}}},U=class{constructor(e,t,n){this.coreEngine=e,this.Module=t,this.workerFunctions=n,this.setup()}barcodeBatchDidUpdateSession(e){this.workerFunctions.postMessage({type:`barcodeBatchDidUpdateSession`,payload:JSON.parse(e.toJson())})}getBatchDeserializer(){return this.barcodeBatchDeserializer}setup(){let e=new(this.Module.BarcodeBatchListener.extend(`BarcodeTrackingListener`,{didUpdateSession:(e,t,n)=>{this.barcodeBatchDidUpdateSession(t),e.delete(),t.delete(),n.delete()},onTrackedBarcodeTapped:(e,t)=>{this.onTrackedBarcodeTapped(t),e.delete(),t.delete()}})),t=this.Module.BarcodeBatchDeserializerListener.extend(`BarcodeTrackingDeserializerListener`,{onModeDeserializationFinished:(t,n,r)=>{n.addListener(e,1),this.coreEngine.reportInsufficientMultithreadingIfNeeded(`BarcodeBatch`),t.delete(),n.delete(),r.delete()},onModeDeserializationStarted(e,t,n){e.delete(),t.delete(),n.delete()},onSettingsDeserializationStarted(e,t,n){e.delete(),t.delete(),n.delete()},onSettingsDeserializationFinished(e,t,n){e.delete(),t.delete(),n.delete()}});this.barcodeBatchDeserializer=new this.Module.BarcodeBatchDeserializer,this.barcodeBatchDeserializer.setListener(new t)}onTrackedBarcodeTapped(e){this.workerFunctions.postMessage({type:`didTapTrackedBarcode`,payload:JSON.parse(e.toJson())})}},W=class{constructor(e,t,n){this.captureListenerSet=!1,this.areGlowListener=null,this.areSyncStateListener=null,this.areBarcodeCaptureMode=null,this.coreEngine=e,this.Module=t,this.workerFunctions=n,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:(e,t,n)=>{this.barcodeCaptureDidScan(t,n),e.delete(),n.delete(),t.delete()},didUpdateSession:(e,t,n)=>{this.barcodeCaptureDidUpdateSession(t),e.delete(),n.delete(),t.delete()}}),t=this.Module.Feedback.extend(`Feedback`,{emit:()=>{this.successFeedback()}}),n=this.Module.AreServiceListener.extend(`AreServiceListener`,{onAreServiceDispatchStarted:(e,t,n)=>{this.barcodeCaptureAreServiceDispatchStarted(e,t,n),e.delete()},onAreServiceResponse:(e,t,n)=>{this.barcodeCaptureAreServiceResponse(e,t,n)},onAreServiceError:(e,t,n)=>{this.barcodeCaptureAreServiceError(e,t,n)}}),r=new e,i=new t,a=new n,o=this.Module.BarcodeCaptureDeserializerListener.extend(`BarcodeCaptureDeserializerListener`,{onModeDeserializationFinished:(e,t,n)=>{t.addListener(r,1),t.setSuccessFeedback(i),t.addAreServiceListener(a);let o=this.setupAreListeners(t);e.delete(),o||t.delete(),n.delete()},onModeDeserializationStarted(e,t,n){e.delete(),t.delete(),n.delete()},onSettingsDeserializationStarted(e,t,n){e.delete(),t.delete(),n.delete()},onSettingsDeserializationFinished(e,t,n){e.delete(),t.delete(),n.delete()}});this.barcodeCaptureDeserializer=new this.Module.BarcodeCaptureDeserializer,this.barcodeCaptureDeserializer.setListener(new o)}successFeedback(){this.workerFunctions.postMessage({type:`successFeedback`})}setupAreListeners(e){return this.areBarcodeCaptureMode?.isAliasOf(e)===!0?!1:(this.releaseAreMode(),this.areGlowListener??=new(this.Module.AreGlowListener.extend(`AreGlowListener`,{onGlowActiveChanged:e=>{this.workerFunctions.postMessage({type:`barcodeCaptureAreGlowActiveChanged`,payload:{active:e}})}})),this.areSyncStateListener??=new(this.Module.AreSyncStateListener.extend(`AreSyncStateListener`,{onAreSyncStateChanged:()=>{this.postAreSyncState()}})),this.areBarcodeCaptureMode=e,e.addAreGlowListener(this.areGlowListener),e.setAreSyncStateListener(this.areSyncStateListener),this.postAreSyncState(),!0)}releaseAreGlowBridge(){this.releaseAreMode()}releaseAreMode(){let e=this.areBarcodeCaptureMode;e&&(this.areBarcodeCaptureMode=null,this.areGlowListener&&e.removeAreGlowListener(this.areGlowListener),e.setAreSyncStateListener(null),e.delete())}postAreSyncState(){let e=this.areBarcodeCaptureMode?.hasSyncAreComponent()??!1;this.workerFunctions.postMessage({type:`barcodeCaptureAreSyncStateChanged`,payload:{hasSyncComponent:e}})}barcodeCaptureDidScan(e,t){let n=this.coreEngine.prepareFrameForListener(t);this.workerFunctions.postMessage({type:`barcodeCaptureDidScan`,payload:{session:JSON.parse(e.toJson()),frameData:n}})}barcodeCaptureAreServiceDispatchStarted(e,t,n){let r=this.coreEngine.prepareFrameForListener(e);this.workerFunctions.postMessage({type:`barcodeCaptureAreServiceDispatchStarted`,payload:{frameData:r,frameId:t,barcodes:JSON.parse(n)}})}barcodeCaptureAreServiceResponse(e,t,n){this.workerFunctions.postMessage({type:`barcodeCaptureAreServiceResponse`,payload:{response:e,frameId:t,barcodes:JSON.parse(n)}})}barcodeCaptureAreServiceError(e,t,n){this.workerFunctions.postMessage({type:`barcodeCaptureAreServiceError`,payload:{reason:e,frameId:t,barcodes:JSON.parse(n)}})}};function G(e){return e.charAt(0).toUpperCase()+e.slice(1)}function K(e){return e}var ce=class{constructor(e,t,n){this.barcodeFind=null,this.basicOverlay=null,this.transparentGuidanceHintStyle={backgroundColor:`00000000`,cornerRadius:4,fitToText:!1,isAnimatedToView:!1,textAlignment:`center`,hintIcon:`none`,hintAnchor:`center`,hintAnchorOffset:0,horizontalMargin:0,iconColor:`00000000`,lineHeight:-1,maxLines:1,maxWidthFraction:.8,textColor:`ffffffff`,textSize:15,textWeight:600},this.customerTransformation=K,this.coreEngine=e,this.Module=t,this.workerFunctions=n}async forSettings(e){this.barcodeFind?.delete(),this.barcodeFind=new this.Module.BarcodeFind(this.coreEngine.context,JSON.stringify(e));let t=this.Module.Feedback.extend(`Feedback`,{emit:()=>{this.listUpdatedFeedback()}}),n=this.Module.Feedback.extend(`Feedback`,{emit:()=>{this.barcodeFindFeedback()}}),r=this.Module.BarcodeFindTransformer.extend(`BarcodeFindTransformer`,{transformBarcodeData:e=>this.customerTransformation(e)}),i=this.Module.BarcodeFindListener.extend(`BarcodeFindListener`,{didUpdateSession:(e,t,n)=>{let r=this.coreEngine.prepareFrameForListener(n);this.workerFunctions.postMessage({type:`barcodeFindDidUpdateSession`,payload:{session:JSON.parse(t.toJsonIgnoringLicense()),frameData:r}}),e.delete(),t.delete(),n.delete()},onSearchPaused:e=>{let t=[];for(let n=0;n<e.size();n++)t.push(e.get(n));this.workerFunctions.postMessage({type:`barcodeFindSearchPaused`,payload:{foundItems:t}})},onSearchStopped:e=>{let t=[];for(let n=0;n<e.size();n++)t.push(e.get(n));this.workerFunctions.postMessage({type:`barcodeFindSearchStopped`,payload:{foundItems:t}})},onSearchStarted:()=>{this.workerFunctions.postMessage({type:`barcodeFindSearchStarted`,payload:{}})}});this.barcodeFind.setBarcodeFindTransformer(new r),this.barcodeFind.addListener(new i,1),this.barcodeFind.setItemListUpdatedFeedback(new t),this.barcodeFind.setFeedback(new n),this.Module.addBarcodeFindToContext(this.coreEngine.context,this.barcodeFind),this.coreEngine.reportInsufficientMultithreadingIfNeeded(`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 t=Object.entries(e).filter(([e,t])=>e!==`type`);for(let[e,n]of t){let t=`set${G(e)}`;this.basicOverlay!=null&&typeof this.basicOverlay[t]==`function`&&n!=null&&this.basicOverlay[t](n)}}setTransformerFunction(e){this.customerTransformation=e??K}successFeedback(){this.workerFunctions.postMessage({type:`successFeedback`})}listUpdatedFeedback(){this.workerFunctions.postMessage({type:`barcodeFindListUpdatedFeedback`,payload:{}})}setToast(e,t){let n=this.coreEngine.hintPresenter;e?n?.showToast(JSON.stringify(t)):n?.hideToast(t.tag)}setGuidance(e,t,n){let r={tag:n,text:t,hintStyle:this.transparentGuidanceHintStyle};this.workerFunctions.postMessage({type:e?`showGuidance`:`hideGuidance`,payload:r})}createWebFindGuidanceHandler(){return new(this.Module.BarcodeFindGuidanceHandler.extend(`BarcodeFindGuidanceHandler`,{setInitialGuidance:(e,t)=>{this.setGuidance(e,t,`InitialGuidance`)},setMoveCloserGuidance:(e,t)=>{this.setGuidance(!1,t,`InitialGuidance`),this.setGuidance(e,t,`MoveCloserGuidance`)},setTapShutterToPause:(e,t)=>{this.setGuidance(!1,t,`InitialGuidance`),this.setGuidance(e,t,`TapShutterToPause`)},setTapShutterToResume:(e,t)=>{this.setGuidance(!1,t,`InitialGuidance`),this.setGuidance(e,t,`TapShutterResume`)}}))}},q=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 e of this.subscribers)e.onPropertyChanged?.(this.property)}}};let le={torch_state:new q(`torch_state`),scanning_mode:new q(`scanning_mode`),sound_enabled:new q(`sound_enabled`),haptic_enabled:new q(`haptic_enabled`),session_stop_reason:new q(`session_stop_reason`),camera_position:new q(`camera_position`)};var ue=class{getBehaviorSubject(e){return le[e]}},de=class{constructor(e,t,n){this.captureListenerSet=!1,this.propertyPushSource=new ue,this.coreEngine=e,this.Module=t,this.workerFunctions=n,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:(e,t,n)=>{this.sparkScanDidScan(t,n),e.delete(),t.delete(),n.delete()},didUpdateSession:(e,t,n)=>{this.sparkScanDidUpdateSession(t),e.delete(),t.delete(),n.delete()}}),t=this.Module.Feedback.extend(`Feedback`,{emit:()=>{this.successFeedback()}}),n=this.Module.SparkScanDeserializerListener.extend(`SparkScanDeserializerListener`,{onModeDeserializationFinished:(n,r,i)=>{if(!this.captureListenerSet){r.addListener(new e,1),r.setSuccessFeedback(new t),r.setPropertyPushSource(this.propertyPushSource);let n=new(this.Module.SparkScanViewHandlerDelegate.extend(`SparkScanViewHandlerDelegate`,{onSwitchedAwayFromSmartScanSelection:()=>{this.smartScanSelectionOverlay?.delete(),this.smartScanSelectionOverlay=void 0,this.workerFunctions.postMessage({type:`sparkScanSwitchedAwayFromSmartScanSelection`})},onSwitchedToSmartScanSelection:()=>{this.workerFunctions.postMessage({type:`sparkScanSwitchedToSmartScanSelection`})},enableHapticWhenOverlapping:()=>{},onStateTransition:()=>{},resetAllTimers:()=>{}})),i=r.getStateMachine();i.setViewHandlerDelegate(n),n.delete(),i.delete(),this.sparkScan=r.clone(),this.captureListenerSet=!0}this.coreEngine.reportInsufficientMultithreadingIfNeeded(`SparkScan`),n.delete(),i.delete(),r.delete()},onModeDeserializationStarted(e,t,n){e.delete(),t.delete(),n.delete()},onSettingsDeserializationStarted(e,t,n){e.delete(),t.delete(),n.delete()},onSettingsDeserializationFinished(e,t,n){e.delete(),t.delete(),n.delete()},onOverlayDeserializationStarted(e,t,n){e.delete(),t.delete(),n.delete()},onOverlayDeserializationFinished:(e,t,n)=>{this.sparkScanOverlay?.delete(),this.sparkScanOverlay=t,e.delete(),n.delete()},onSmartScanSelectionOverlayCreated:(e,t,n)=>{this.smartScanSelectionOverlay?.delete(),this.smartScanSelectionOverlay=t,e.delete(),n.delete()}});this.sparkScanDeserializer=new this.Module.SparkScanDeserializer,this.sparkScanDeserializer.setListener(new n)}emitErrorFeedback(e){this.sparkScanOverlay?.onErrorFeedbackEmitted(e),this.smartScanSelectionOverlay?.onErrorFeedbackEmitted(e)}overlayReadyForDraw(){this.sparkScanOverlay?.onReadyForNewData()}discardEnqueuedData(){this.sparkScanOverlay?.discardEnqueuedData()}analyticsManagerPropertyChanged(e){this.propertyPushSource.getBehaviorSubject(e.key).setProperty(e)}successFeedback(){this.workerFunctions.postMessage({type:`successFeedback`})}selectItemWithSmartScanSelection(){this.sparkScan?.selectItemWithSmartScanSelectionAsync()}enableSingleScanMode(e){this.sparkScan?.enableSingleScanMode(e)}async removeMode(){this.captureListenerSet=!1,this.sparkScan?.delete(),this.sparkScan=void 0,this.sparkScanOverlay?.delete(),this.sparkScanOverlay=void 0,this.smartScanSelectionOverlay?.delete(),this.smartScanSelectionOverlay=void 0}sparkScanDidScan(e,t){let n=this.coreEngine.prepareFrameForListener(t);this.workerFunctions.postMessage({type:`sparkScanDidScan`,payload:{session:JSON.parse(e.toJson()),frameData:n}})}},fe=class extends P{constructor(e,t){super(e,t)}getModeDeserializers(){this.barcodeCaptureMode=new W(this,this.Module,this.workerFunctions),this.barcodeBatchMode=new U(this,this.Module,this.workerFunctions),this.sparkScanMode=new de(this,this.Module,this.workerFunctions),this.barcodeFindMode=new ce(this,this.Module,this.workerFunctions),this.barcodeArMode=new H(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,t){return t?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,t){return t?e?`d1eb097cb4e2f773466fad9656a30ca8bf2e1543b0818a5adb65a2dff40c8e43`:`d82fea809167effacae861b1556e869799456a4e0fa301871213bdc99467500e`:e?`93071c6fffe21a8c19f578b3beee657ade248b49cda2a69338b8e23346b0abd1`:`f7d91b27cd9697744170e0d04d84169e5199156e947bc7e8b13e74b09b397495`}getWasmMetadata(){return{"scandit-datacapture-sdk-barcode-pthreads.wasm":{bytes:8443120},"scandit-datacapture-sdk-barcode-simd-pthreads.wasm":{bytes:8383319},"scandit-datacapture-sdk-barcode-simd.wasm":{bytes:8435027},"scandit-datacapture-sdk-barcode.wasm":{bytes:8514451}}}releaseAreGlowBridge(){this.barcodeCaptureMode.releaseAreGlowBridge()}};function pe(e){return(e=>/^[$A-Z_a-z][\w$]*\s*\(.*\)\s*\{/.test(e)&&!e.startsWith(`function`))(e)?`function ${e}`:e}let J=[`fetch`,`XMLHttpRequest`,`eval`,`Function`,`self`,`globalThis`,`Module`,`importScripts`,`this`,`console`,`window`,`document`,`import`,`Worker`,`ServiceWorker`,`with`,`Reflect`,`Proxy`],Y=[`constructor`,`__proto__`];function me(e,t){let n=t+2,r=e.length;for(;n<r&&!(e[n]===`*`&&n+1<r&&e[n+1]===`/`);)n++;return Math.min(r,n+2)}function he(e,t){let n=t+2,r=e.length;for(;n<r&&e[n]!==`
`&&e[n]!==`\r`;)n++;return n}function X(e,t,n){let r=t+1,i=e.length;for(;r<i&&e[r]!==n&&e[r]!==`
`&&e[r]!==`\r`;)r+=e[r]===`\\`&&r+1<i?2:1;return r<i&&e[r]===n?r+1:r}function ge(e){let t=``,n=0,r=e.length;for(;n<r;){let i=e[n],a=n+1<r?e[n+1]:``;if(i===`/`&&a===`*`){n=me(e,n);continue}if(i===`/`&&a===`/`){n=he(e,n);continue}if(i===`'`||i===`"`){t+=i+i,n=X(e,n,i);continue}if(i==="`"){let r=Z(e,n);t+=r.text,n=r.next;continue}t+=i,n++}return t}function Z(e,t){let n=t+1,r=e.length,i=[];for(;n<r&&e[n]!=="`";){if(e[n]===`\\`&&n+1<r){n+=2;continue}if(e[n]===`$`&&n+1<r&&e[n+1]===`{`){let t=n+2,r=_e(e,t);i.push(e.substring(t,r)),n=r+1;continue}n++}return{text:i.length===0?"``":`\`\`+(${i.join(`)+(`)})`,next:Math.min(r,n+1)}}function _e(e,t){let n=1,r=t,i=e.length;for(;r<i&&n>0;){let t=e[r];if(t===`{`)n++,r++;else if(t===`}`){if(n--,n===0)return r;r++}else t===`'`||t===`"`?r=X(e,r,t):t==="`"?r=Z(e,r).next:t===`\\`&&r+1<i?r+=2:r++}return Math.min(i,r)}let ve=/(['"`])((?:\\.|(?!\1).)*)\1\s*\+\s*(['"`])((?:\\.|(?!\3).)*)\3/g;function ye(e){let t,n=e;do t=n,n=t.replace(ve,(e,t,n,r,i)=>`'${n}${i}'`);while(n!==t);return n}let be=[`getPrototypeOf`],xe=/^[$A-Z_a-z][\w$]*$/,Q=/^-?\d+(?:\.\d+)?$/,Se=/^(?:""|''|``(?:\+\([^()]*\))*)$/,Ce=new Set([`return`,`throw`,`typeof`,`void`,`delete`,`new`,`in`,`of`,`instanceof`,`await`,`yield`,`case`]);function we(e,t){let n=t-1;for(;n>=0&&/\s/.test(e[n]);)n--;if(n<0)return!1;let r=e[n];if(r===`)`||r===`]`)return!0;if(!/[\w$]/.test(r))return!1;let i=n+1;for(;n>=0&&/[\w$]/.test(e[n]);)n--;let a=e.substring(n+1,i);return!Ce.has(a)}function Te(e,t){let n=e.length,r=1,i=t+1;for(;i<n&&r>0;)e[i]===`[`?r++:e[i]===`]`&&r--,r>0&&i++;return i}function Ee(e){return e===``||xe.test(e)||Q.test(e)||Se.test(e)}function De(e){let t=e.length,n=0;for(;n<t;){if(e[n]!==`[`||!we(e,n)){n++;continue}let t=Te(e,n);if(!Ee(e.substring(n+1,t).trim()))return!0;n=t+1}return!1}function Oe(e){let t=ye(e),n=ge(t);for(let e of J)if(RegExp(`\\b${e}\\b`).test(n))return!0;for(let e of[...J,...Y])if(RegExp(`\\[\\s*(['"\`])${e}\\1\\s*\\]`).test(t))return!0;for(let e of Y)if(RegExp(`\\.\\s*${e}\\b`).test(n))return!0;for(let e of be)if(RegExp(`\\.\\s*${e}\\b`).test(n))return!0;return!!De(n)}function $(e){if(e==null)return null;let t=pe(e);if(Oe(t))throw Error(`Function should be pure. Shouldn't introduce side effects, or rely on global scope`);let n=new Set([`eval`,`this`,`import`,`with`]),r=`'use strict';
return (function (${J.filter(e=>!n.has(e)).join(`,`)}) {
return (${t});
})();`;try{return Function(r)()}catch{return null}}new class extends se{constructor(e,t){super(e,t),this.dataCaptureInstance=new fe(t,{postMessage:this.postMessage.bind(this),getOffscreenCanvas:this.getOffscreenCanvas.bind(this)})}rebuildBarcodeArFilter(e){let t=$(e);if(e!=null&&t==null)throw Error(`The barcode filter could not be rebuilt in the worker.`);return t??null}async respondWith(e,t,r){let i=null,a;try{a=r(),a instanceof Promise&&(a=await a)}catch(e){a=void 0,i=n(e)}let o={type:`workerTaskId`,command:e,id:t,payload:this.hasPayload(a)?a.payload:void 0};i!=null&&(o.error=i),this.postMessage(o,this.hasTransferables(a)?a.transferables:[])}onMessage(e){switch(e.data.command){case`sparkScanEmitErrorFeedback`:{let{data:t}=e;return this.respondWith(t.command,t.id,()=>{this.dataCaptureInstance.sparkScanMode.emitErrorFeedback(t.shouldRemoveBrush)}),!0}case`sparkScanOverlayReadyForDraw`:{let{data:t}=e;return this.respondWith(t.command,t.id,()=>{this.dataCaptureInstance.sparkScanMode.overlayReadyForDraw()}),!0}case`sparkScanOverlayDiscardEnqueuedData`:{let{data:t}=e;return this.respondWith(t.command,t.id,()=>{this.dataCaptureInstance.sparkScanMode.discardEnqueuedData()}),!0}case`sparkScanAnalyticsManagerPropertyChanged`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>{this.dataCaptureInstance.sparkScanMode.analyticsManagerPropertyChanged(t.property)}),!0}case`sparkScanSelectItemWithSmartScanSelection`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>{this.dataCaptureInstance.sparkScanMode.selectItemWithSmartScanSelection()}),!0}case`sparkScanEnableSingleScanMode`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>{this.dataCaptureInstance.sparkScanMode.enableSingleScanMode(t.enabled)}),!0}case`sparkScanModeRemove`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>this.dataCaptureInstance.sparkScanMode.removeMode()),!0}case`barcodeFindForSettings`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>this.dataCaptureInstance.barcodeFindMode.forSettings(t.settings)),!0}case`barcodeFindModeRemove`:{let{data:t}=e;return this.respondWith(t.command,t.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:t}=e;return this.respondWith(e.data.command,e.data.id,()=>{this.dataCaptureInstance.barcodeFindMode.setItemList(t.itemList)}),!0}case`barcodeFindSetEnabled`:{let{data:t}=e;return this.respondWith(e.data.command,e.data.id,()=>{this.dataCaptureInstance.barcodeFindMode.setEnabled(t.enabled)}),!0}case`barcodeFindApplySettings`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>this.dataCaptureInstance.barcodeFindMode.applySettings(t.settings)),!0}case`barcodeFindAddBasicOverlay`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>{this.dataCaptureInstance.barcodeFindMode.addBasicOverlay()}),!0}case`barcodeFindRemoveBasicOverlay`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>{this.dataCaptureInstance.barcodeFindMode.removeBasicOverlay()}),!0}case`barcodeFindUpdateBasicOverlay`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>{this.dataCaptureInstance.barcodeFindMode.updateBasicOverlay(t.jsonOverlay)}),!0}case`barcodeFindSetTransformerFunction`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>{let e=$(t.functionAsString);this.dataCaptureInstance.barcodeFindMode.setTransformerFunction(e)}),!0}case`barcodeArForSettings`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>this.dataCaptureInstance.barcodeArMode.forSettings(t.settings,this.rebuildBarcodeArFilter(t.barcodeFilterFunctionAsString))),!0}case`barcodeArModeRemove`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>this.dataCaptureInstance.barcodeArMode.removeMode()),!0}case`barcodeArSearchStart`:return this.respondWith(e.data.command,e.data.id,()=>{this.dataCaptureInstance.barcodeArMode.start()}),!0;case`barcodeArSearchPause`:return this.respondWith(e.data.command,e.data.id,()=>{this.dataCaptureInstance.barcodeArMode.pause()}),!0;case`barcodeArSearchStop`:return this.respondWith(e.data.command,e.data.id,()=>{this.dataCaptureInstance.barcodeArMode.stop()}),!0;case`barcodeArSetEnabled`:{let{data:t}=e;return this.respondWith(e.data.command,e.data.id,()=>{this.dataCaptureInstance.barcodeArMode.setEnabled(t.enabled)}),!0}case`barcodeArApplySettings`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>{this.dataCaptureInstance.barcodeArMode.applySettings(t.settings)}),!0}case`barcodeArSetBarcodeFilter`:{let{data:t}=e;return this.respondWith(t.command,t.id,async()=>{this.dataCaptureInstance.barcodeArMode.setFilterFunction(this.rebuildBarcodeArFilter(t.functionAsString))}),!0}default:return super.onMessage(e)}}}(globalThis,{get:()=>globalThis.Module,set:e=>{globalThis.Module=e}})})();