@scandit/web-datacapture-barcode
Version:
Scandit Data Capture SDK for the Web
1 lines • 60.4 kB
JavaScript
import {DataCaptureLoader,Logger}from'@scandit/web-datacapture-core';function d(r){let n=URL.createObjectURL(new Blob(['"use strict";(()=>{var u={"scandit-datacapture-sdk-barcode-pthreads.wasm":{bytes:8235252},"scandit-datacapture-sdk-barcode-simd.wasm":{bytes:7988723},"scandit-datacapture-sdk-barcode-simd-pthreads.wasm":{bytes:8126829},"scandit-datacapture-sdk-barcode.wasm":{bytes:8097127}};function C(t){return typeof t=="object"&&t!=null}function k(t){if(typeof t=="string")return t;if(C(t)){if(typeof t.message=="string")return t.message}else if(typeof(t==null?void 0:t.toString)=="function")return t.toString();return"unknown error"}var d;(t=>{(l=>(l.Debug="debug",l.Info="info",l.Warn="warn",l.Error="error",l.Quiet="quiet"))(t.Level||(t.Level={}));let e=new Map([["debug",1],["info",2],["warn",3],["error",4],["quiet",5]]),a="debug";function r(l){a=l}t.setLevel=r;function i(l,...h){if(!(e.get(a)>e.get(l)))switch(l){case"debug":{console.debug(...h);break}case"info":{console.log(...h);break}case"warn":{console.warn(...h);break}case"error":{console.error(...h);break}}}t.log=i;function n(...l){i("warn",...l)}t.warn=n;function o(...l){i("debug",...l)}t.debug=o;function s(...l){i("info",...l)}t.info=s;function c(...l){i("error",...l)}t.error=c})(d||(d={}));var Re=class{constructor(t){if(typeof t!="function")throw new TypeError("FinalizationRegistry callback must be a function")}register(t,e,a){}unregister(t){return!1}};function re(t){typeof t.FinalizationRegistry>"u"&&(t.FinalizationRegistry=Re)}function ie(t,e,a){let r=e*a,i=new Uint8ClampedArray(r*4),n=new Uint32Array(i.buffer);for(let o=0;o<r;o++){let s=t[o];n[o]=4278190080|s<<16|s<<8|s}return i}var x=class ne extends Error{constructor(e){super(e.message),Object.setPrototypeOf(this,ne.prototype),this.name=e.name}toString(){return`${this.name}: ${this.message}`}};var D=Promise.resolve(),q=!1,G=!1,T=!1,v,Y=1500,j="";async function se(t){if(v==null)return;q=!0;let e;try{let a=new Promise((i,n)=>{e=setTimeout(()=>{d.debug(`IndexedDB database is blocked (timed out after ${Y}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).`),n(new x({name:"BlockedIndexedDB",message:"IndexedDB database is blocked"}))},Y)}),r=new Promise((i,n)=>{v==null||v(t,o=>{o!=null?n(o):i()})});await Promise.race([r,a])}finally{e!==void 0&&clearTimeout(e),q=!1}}async function oe(t){return G?(T=t,D):(q?(G=!0,T=t,D=D.then(async()=>(G=!1,se(T)))):(T=t,D=se(t)),D)}function Ee(){FS.syncfs=((t,e)=>{oe(t).then(()=>e(),a=>e(a))})}async function de(t){if(j=t.writableDataPath,Y=t.indexedDBTimeoutMs,v=FS.syncfs,v==null)throw new Error("FS.syncfs is not available");Ee();try{FS.mkdir(j)}catch(e){if(e.code!=="EEXIST")throw v=void 0,e}try{FS.mount(IDBFS,{},j)}catch(e){throw v=void 0,e}return oe(!0)}var ce={};function Le(t){return[...new Uint8Array(t)].map(e=>{let a=e.toString(16);return a.length===1?`0${a}`:a}).join("")}async function*We(t){let e=t.getReader();try{for(;;){let{done:a,value:r}=await e.read();if(a)return;yield r}}finally{e.releaseLock()}}async function Ne(t){let e=[],a=0,r=0;for await(let n of We(t))e.push(n),a+=n.length;let i=new Uint8Array(a);for(let n of e)i.set(n,r),r+=n.length;return i.buffer}var He=(t=>(t.VALID="VALID",t.INVALID="INVALID",t.NOT_VERIFIABLE="NOT_VERIFIABLE",t))(He||{});async function _e(t,e,a){if(typeof crypto.subtle.digest!="function")return d.log(d.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 ${a} could not be verified`),"NOT_VERIFIABLE";try{let r=t instanceof Promise?await t:t,i=await crypto.subtle.digest("SHA-256",r),n=Le(i);return e==null?(d.log(d.Level.Warn,"The library hash is not defined or empty, cannot correctly verify integrity."),"NOT_VERIFIABLE"):n===e?(d.log(d.Level.Debug,`Data Capture library WASM integrity found at ${a} has been verified correctly.`),"VALID"):(d.log(d.Level.Warn,`The Scandit Data Capture library WASM file found at ${a} seems invalid: expected file hash doesn\'t match (received: ${n}, expected: ${e}). Please ensure the correct Scandit Data Capture file (with correct version) is retrieved.`),"INVALID")}catch(r){return d.log(d.Level.Warn,"Wasm response could not be verified",r),"NOT_VERIFIABLE"}}var X=new Map([["br",4.4],["gzip",2.9],["none",1]]);function ze(t){var e;let a="content-encoding";if(t==null||t.get(a)==null)return X.get("none");let r=new Set(((e=t.get(a))!=null?e:"").split(",").map(i=>i.trim()));for(let[i,n]of X)if(r.has(i))return n;return X.get("none")}function Ve(t){var e,a;if(t==null)return 0;let r=(e=ze(t))!=null?e:1,i=Number.parseInt((a=t.get("content-length"))!=null?a:"0",10);return Number.isNaN(i)?0:Math.floor(i*r*100)/100}function Je(t){let{pathname:e}=new URL(t);for(let[a,r]of Object.entries(ce))if(e.endsWith(a))return r.bytes;return 0}function le(t){ce=t}var Ue=(t,e)=>{let a=Ve(e);return a===0?Je(t):a};function $e(t,e,a,{onProgress:r,onError:i,onComplete:n}){if(!e.body)return[e];let o=Ue(t,e.headers),s=0,c=0;if(typeof TransformStream>"u")return d.warn("TransformStream is not supported in this environment. Progress tracking will be disabled."),[e];let[l,h]=a?e.body.tee():[e.body],m=l.pipeThrough(new TransformStream({async transform(g,f){try{s+=g.length,c=Number((s/o*100).toFixed(2)),o>0&&g.length>0&&c<100?r==null||r({percentage:c,loadedBytes:s,privateUri:t}):o===0&&g.length>0&&(r==null||r({percentage:null,loadedBytes:s,privateUri:t})),f.enqueue(g)}catch(b){f.error(b),i==null||i({error:b})}},flush(g){r==null||r({percentage:100,loadedBytes:s,privateUri:t}),n==null||n({percentage:100,loadedBytes:s,privateUri:t}),g.terminate()}}));return[new Response(m,{headers:new Headers(e.headers),status:e.status,statusText:e.statusText}),h]}async function K({wasmURI:t,expectedHash:e,verifyResponseHash:a,onProgress:r,onComplete:i,onError:n,referredOrigin:o}){let s=await fetch(t,{referrerPolicy:"origin",referrer:o!=null?o:""});if(!s.ok)throw new Error(`HTTP status code is not ok: ${s.status}, ${s.statusText}`);let[c,l]=$e(t,s,a,{onProgress:r,onError:n,onComplete:i});return l!=null&&_e(Ne(l),e,t),c}function ue({wasmURI:t,expectedHash:e,verifyResponseHash:a,progressCallback:r,successCallback:i,errorCallback:n,importObject:o,referredOrigin:s}){async function c(h){try{let m=await K({wasmURI:t,expectedHash:e,verifyResponseHash:a,onProgress:r,referredOrigin:s}),g=await(h!=null?h:m).arrayBuffer(),f=await self.WebAssembly.instantiate(g,o);i(f.instance,f.module)}catch(m){d.log(d.Level.Error,m),d.log(d.Level.Error,`Couldn\'t instantiate Scandit SDK DataCapture library at ${t}, did you configure the path for it correctly?`),n==null||n(m)}}async function l(){let h;try{h=await K({wasmURI:t,expectedHash:e,verifyResponseHash:a,onProgress:r,referredOrigin:s});let m=await self.WebAssembly.instantiateStreaming(h,o);i(m.instance,m.module)}catch(m){d.log(d.Level.Warn,m),d.log(d.Level.Warn,"WebAssembly streaming compile failed. Falling back to ArrayBuffer instantiation (this will make things slower)"),c((h==null?void 0:h.bodyUsed)===!0?void 0:h)}}typeof self.WebAssembly.instantiateStreaming=="function"?l():c()}async function Z(t,e,a,r){return new Promise((i,n)=>{t().then(i).catch(o=>{let s=e*2;if(s>a){n(o);return}r(o),self.setTimeout(()=>{Z(t,s,a,r).then(i).catch(n)},e)})})}function Q(t){var e,a;let r="unknown";if((e=t.href)!=null&&e.startsWith("blob:null/"))r="localhost";else{let i=((a=t.pathname)==null?void 0:a.length)>1&&!t.pathname.startsWith("/");r=new URL(i?t.pathname:t.origin).hostname}return r.startsWith("[")&&r.endsWith("]")?(r=r.slice(1,-1),r):(/^(\\d{1,3}\\.){3}\\d{1,3}$/.test(r)&&(r=r.split(".").map(i=>Number.parseInt(i,10).toString()).join(".")),r)}async function pe(t,e){async function a(){return importScripts(t)}try{await Z(a,250,4e3,i=>{d.log(d.Level.Warn,i),d.log(d.Level.Warn,`Couldn\'t retrieve Scandit Data Capture library at ${t}, retrying...`)}),self.Module.mainScriptUrlOrBlob=t;let r=self.SDC_WASM_JS_VERSION;return r!==e&&d.log(d.Level.Warn,`The Scandit Data Capture library JS file found at ${t} seems invalid: expected version doesn\'t match (received: ${r}, expected: ${e}). Please ensure the correct Scandit Data Capture file (with correct version) is retrieved.`),!0}catch(r){return d.log(d.Level.Error,r),!1}}var A=class{constructor(){this.promise=new Promise((t,e)=>{this.reject=e,this.resolve=t})}};var ee=class{constructor(t,e){this.workerFunctions=t,this.options=e,this.imageIdCounter=0,this.conversions=new Map}convertToJpeg(t,e){let a=this.imageIdCounter++,r=new A;this.conversions.set(a,r);let i=t.toBitmap();return this.workerFunctions.postMessage({type:"convertToJPEG",imageId:a,width:t.getWidth(),height:t.getHeight(),data:i,planes:t.getPlanes(),orientation:e,quality:this.options.quality},Array.from(new Set([i.buffer]))),r.promise}convertToBitmap(t){return{data:t.toBitmap(),byteOrder:1}}onConvertToJPEGResult(t,e){let a=this.conversions.get(t);a?(a.resolve(e),this.conversions.delete(t)):d.warn(`ImageConverterForwarder: Conversion for imageId ${t} not found in Map`)}};var O=class{constructor(t){this.options=t}get quality(){return this.options.quality}async convertToJpeg(t,e){try{let{width:a,height:r,planes:i}=this.validateAndExtractImageData(t);this.prepareCanvas(a,r);let n=this.processImageData(t,i,a,r);return await this.convertToJpegBytes(n,e)}catch(a){throw d.warn(`Failed to convert image to JPEG: ${a}`),a instanceof Error?a:new Error("Failed to convert image to JPEG")}}convertToBitmap(t){return{data:t.toBitmap(),byteOrder:1}}validateAndExtractImageData(t){let e=t.getWidth(),a=t.getHeight(),r=t.getPlanes();if(e<=0||a<=0)throw d.warn(`Invalid image dimensions: ${e}x${a}`),new Error(`Invalid image dimensions: ${e}x${a}`);if(!r||r.length===0)throw d.warn("ImageBuffer has no planes"),new Error("ImageBuffer has no planes");return{width:e,height:a,planes:r}}prepareCanvas(t,e){if(!this.ensureCanvas(t,e))throw new Error("Failed to create OffscreenCanvas");if(!this.canvas||!this.context)throw new Error("Canvas or context not properly initialized")}processImageData(t,e,a,r){let i=this.createImageDataFromBuffer(t,e,a,r);if(i===null)throw new Error("Failed to create ImageData");return this.validateImageData(i,a,r),i}validateImageData(t,e,a){var r;if(t.width!==e||t.height!==a)throw d.warn(`ImageData dimensions mismatch: expected ${e}x${a}, got ${t.width}x${t.height}`),new Error("ImageData dimensions mismatch");if(!t.data||t.data.length!==e*a*4)throw d.warn(`ImageData has invalid data length: expected ${e*a*4}, got ${((r=t.data)==null?void 0:r.length)||0}`),new Error("ImageData has invalid data length")}async convertToJpegBytes(t,e){if(!this.context||!this.canvas)throw new Error("Canvas or context not available");try{this.context.putImageData(t,0,0)}catch(n){throw d.warn(`Failed to put image data on canvas: ${n}`),new Error(`Failed to put image data on canvas: ${n}`)}let a=e!==0?this.applyRotation(this.canvas,e):this.canvas,r;try{r=await this.canvasToBlob(a)}catch(n){throw d.warn(`Failed to convert canvas to blob: ${n}`),new Error(`Failed to convert canvas to blob: ${n}`)}if(!r||r.size===0)throw d.warn("Canvas convertToBlob returned empty or null blob"),new Error("Failed to create JPEG blob");let i;try{i=await r.arrayBuffer()}catch(n){throw d.warn(`Failed to get array buffer from blob: ${n}`),new Error(`Failed to get array buffer from blob: ${n}`)}if(!i||i.byteLength===0)throw d.warn("Blob arrayBuffer returned empty or null buffer"),new Error("Failed to get array buffer from blob");return new Uint8Array(i)}ensureCanvas(t,e){try{return(!this.canvas||this.canvas.width!==t||this.canvas.height!==e)&&(this.canvas=this.getNewCanvas(t,e),this.context=this.canvas.getContext("2d")),this.context!==null}catch(a){return d.warn("Failed to create HTMLCanvasElement",a),!1}}createImageDataFromBuffer(t,e,a,r){let i=new Set(e.map(n=>n.channel));try{if(this.isYUVFormat(i)){let s=t.toBitmap();return!s||s.length!==a*r*4?(d.warn(`Invalid bitmap data from toBitmap(): expected ${a*r*4} bytes, got ${(s==null?void 0:s.length)||0}`),null):new ImageData(new Uint8ClampedArray(s),a,r)}if(this.isRGBAFormat(i))return this.createImageDataFromRGBAPlanes(e,a,r);if(this.isRGBFormat(i))return this.createImageDataFromRGBPlanes(e,a,r);if(this.isGrayscaleFormat(i))return this.createImageDataFromGrayscalePlanes(e,a,r);d.warn(`Unknown image format with channels: ${Array.from(i).join(", ")}, falling back to toBitmap()`);let n=t.toBitmap();if(!n||n.length===0)return d.warn("toBitmap() returned empty or null data"),null;let o=n.length/(a*r);return o===4?new ImageData(new Uint8ClampedArray(n),a,r):(d.warn(`Unsupported format: ${o} bytes per pixel`),null)}catch(n){return d.warn(`Failed to create ImageData: ${n}`),null}}isYUVFormat(t){return t.has(0)&&t.has(1)&&t.has(2)}isRGBAFormat(t){return t.has(3)&&t.has(4)&&t.has(5)&&t.has(6)}isRGBFormat(t){return t.has(3)&&t.has(4)&&t.has(5)&&!t.has(6)}isGrayscaleFormat(t){return t.has(0)&&!t.has(1)&&!t.has(2)}createImageDataFromRGBAPlanes(t,e,a){let r=t.find(c=>c.channel===3),i=t.find(c=>c.channel===4),n=t.find(c=>c.channel===5),o=t.find(c=>c.channel===6);if(!r||!i||!n||!o)return d.warn("Missing RGBA planes"),null;let s=new Uint8ClampedArray(e*a*4);for(let c=0;c<a;c++)for(let l=0;l<e;l++){let h=(c*e+l)*4;s[h]=this.getPixelFromPlane(r,l,c),s[h+1]=this.getPixelFromPlane(i,l,c),s[h+2]=this.getPixelFromPlane(n,l,c),s[h+3]=this.getPixelFromPlane(o,l,c)}return new ImageData(s,e,a)}createImageDataFromRGBPlanes(t,e,a){let r=t.find(s=>s.channel===3),i=t.find(s=>s.channel===4),n=t.find(s=>s.channel===5);if(!r||!i||!n)return d.warn("Missing RGB planes"),null;let o=new Uint8ClampedArray(e*a*4);for(let s=0;s<a;s++)for(let c=0;c<e;c++){let l=(s*e+c)*4;o[l]=this.getPixelFromPlane(r,c,s),o[l+1]=this.getPixelFromPlane(i,c,s),o[l+2]=this.getPixelFromPlane(n,c,s),o[l+3]=255}return new ImageData(o,e,a)}createImageDataFromGrayscalePlanes(t,e,a){let r=t.find(n=>n.channel===0);if(!r)return d.warn("Missing Y plane for grayscale"),null;let i=new Uint8ClampedArray(e*a*4);for(let n=0;n<a;n++)for(let o=0;o<e;o++){let s=(n*e+o)*4,c=this.getPixelFromPlane(r,o,n);i[s]=c,i[s+1]=c,i[s+2]=c,i[s+3]=255}return new ImageData(i,e,a)}getPixelFromPlane(t,e,a){let r=Math.floor(e/(t.subsamplingX||1)),i=Math.floor(a/(t.subsamplingY||1)),n=t.rowStride,o=t.pixelStride,s=i*n+r*o,c=t.data;return s<c.length?c[s]:0}applyRotation(t,e){let a=e*Math.PI/180,r=e===90||e===270||e===-90||e===-270,i=r?t.height:t.width,n=r?t.width:t.height,o=this.getNewCanvas(i,n),s=o.getContext("2d");if(!s)throw new Error("Failed to get 2D context for rotated canvas");return s.translate(i/2,n/2),s.rotate(a),s.translate(-t.width/2,-t.height/2),s.drawImage(t,0,0),o}};O.JPEG_IMAGE_MIME_TYPE="image/jpeg";var he=class extends O{getNewCanvas(t,e){return new OffscreenCanvas(t,e)}canvasToBlob(t){return t.convertToBlob({type:O.JPEG_IMAGE_MIME_TYPE,quality:this.options.quality})}};var me=class{constructor(t){this.viewInfo=null,this.viewInfo=this.cloneViewInfo(t)}isSame(t){return this.viewInfo==null&&t==null?!0:this.viewInfo==null&&t!=null||this.viewInfo!=null&&t==null?!1:this.viewInfo.width===t.width&&this.viewInfo.height===t.height&&this.viewInfo.orientation===t.orientation&&this.viewInfo.viewFinderRect.origin.x===t.viewFinderRect.origin.x&&this.viewInfo.viewFinderRect.origin.y===t.viewFinderRect.origin.y&&this.viewInfo.viewFinderRect.size.width===t.viewFinderRect.size.width&&this.viewInfo.viewFinderRect.size.height===t.viewFinderRect.size.height}update(t){this.viewInfo=this.cloneViewInfo(t)}cloneViewInfo(t){return t?{...t,viewFinderRect:{origin:{...t.viewFinderRect.origin},size:{...t.viewFinderRect.size}}}:null}};var R;(t=>{function e(){return"8.3.1"}t.sdkVersion=e})(R||(R={}));function Ge(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 je(t){let e=/@scandit\\/web-datacapture-[a-z]+/i.exec(t);return e?e[0]:null}function ge(t,e,a){let r=e,i=Ge(r);if(i.result){let o=je(r);o!=null&&(r=`${i.cdnBaseURL}${o}@${t}/sdc-lib/`)}let n=a.replace(".wasm","");return i.result?{jsURI:`${r}${n}.js`,wasmURI:`${r}${n}.wasm`}:{jsURI:`${r}${n}.js?v=${t}`,wasmURI:`${r}${n}.wasm?v=${t}`}}var fe=class be{constructor(e,a){this.hintPresenterV2=null,this.MAX_NUMBER_OF_IMAGES_IN_FRAME_DATA_POOL=5,this.redrawInterval=1e3/30,this.redrawRequests=[],this._isDrawLoopRunning=!1,this.frameDataPool=new Map,this.lastFrameColorType="RGBA",this.lastFrameId=null,this.poorMansBenchmarkLogs=!1,this.writableDataPathStandard="/scandit_sync_folder",this.resourceFilesSubfolder="resources",this.performanceMetricsReporterTimer=void 0,this.lastMetricsReportTime=0,this.metricsReportInterval=1e3,this.performanceMetrics={frameDataPoolSize:0,cameraOutputFrames:0,redrawRequestsCount:0,actualRedrawsCount:0,frameProcessingStartedCount:0,frameProcessedCount:0,frameSkippedCount:0},this.frameProcessingStartedCount=0,this.frameProcessingFinishedCount=0,this.gestureListener=null,this.webPlatformHintPresenter=null,this.deviceInstance=null,this.deviceInfo=null,this.lastViewInfo=new me(null),this.lastFrameProcessingStartedCount=0,this.lastFrameProcessingFinishedCount=0,this.moduleHandler=e,this.workerFunctions=a,this._loadProgressCallback=this._loadProgressCallback.bind(this),le(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 a=this.lastFrameId;if(this.frameDataPool.size>=this.MAX_NUMBER_OF_IMAGES_IN_FRAME_DATA_POOL){let o=this.frameDataPool.keys().next().value;o!=null&&this.frameDataPool.delete(o)}let r=e.getFrameData(),i=new Uint8ClampedArray(r);this.frameDataPool.set(a,{data:i,colorType:this.lastFrameColorType,frameId:a,width:e.getWidth(),height:e.getHeight()});let n=this.lastUsedModuleMirrorAxis==null?!1:this.lastUsedModuleMirrorAxis!==this.Module.Axis.None;return{frameId:a,width:e.getWidth(),height:e.getHeight(),isFrameSourceMirrored:n,colorType:this.lastFrameColorType}}createContext(e){var a,r,i,n,o;let s=this.getModeDeserializers(),c=Q(location);(c==="localhost"||c==="127.0.0.1")&&navigator.userAgent.includes("Electron")&&e.appName!=null&&(c+=`-${e.appName}`),this.parentDomain=e.parentDomain,this.contextDeserializer=new this.Module.DataCaptureContextDeserializer(this.writableDataPath,e.deviceId,e.context.deviceModelName,c,this.parentDomain,s,e.delayedRegistration,e.highEndBlurryRecognition,this.resourcePath);let l=this.contextDeserializer.contextFromJson(JSON.stringify(e.context));if(l==null){let p=this.contextDeserializer.getLastError();throw new Error(`Could not create the context: ${p}`)}let h=l.getView();this.context=l.getContext(),l.delete(),this.setupDeviceInterface(e.isTablet,e.batteryInfo);let m=this.Module.DataCaptureContextListener.extend("DataCaptureContextListener",{didChangeStatus:(p,y)=>{this.contextDidChangeStatus(JSON.parse(y.toJson())),p.delete()},didStartObservingContext:p=>{this.didStartObservingContext(),p.delete()},didStopObservingContext:p=>{p.delete()}}),g=this.Module.DataCaptureContextFrameListener.extend("DataCaptureContextFrameListener",{onObservationStarted:p=>{p.delete()},onObservationStopped:p=>{p.delete()},onFrameProcessingStarted:(p,y)=>{this.workerFunctions.postMessage({type:"onFrameProcessingStarted"}),y.delete(),p.delete()},onFrameProcessingFinished:(p,y)=>{this.workerFunctions.postMessage({type:"onFrameProcessingFinished"}),y.delete(),p.delete()},onFrameSkipped:(p,y)=>{this.workerFunctions.postMessage({type:"onFrameSkipped"}),y.delete(),p.delete()}}),f=this.Module.GestureRecognizer.extend("GestureRecognizer",{setGestureListener:(p,y)=>{var F;(F=this.gestureListener)==null||F.delete(),this.gestureListener=p.clone(),p.delete()}});(a=this.gestureRecognizer)==null||a.delete(),this.gestureRecognizer=new f;let b=new m;this.context.addListener(b),b.delete();let P=new g;this.context.addFrameListener(P),P.delete(),this.setView(h),(r=this.view)==null||r.setGestureRecognizer(this.gestureRecognizer);let M=this.Module.PlatformHintPresenter.extend("PlatformHintPresenter",{setHintPresenter:p=>{p.delete()},showToast:p=>{this.workerFunctions.postMessage({type:"showToast",payload:JSON.parse(p)})},hideToast:p=>{this.workerFunctions.postMessage({type:"hideToast",payload:JSON.parse(p)})},showGuidance:p=>{this.workerFunctions.postMessage({type:"showGuidance",payload:JSON.parse(p)})},hideGuidance:p=>{this.workerFunctions.postMessage({type:"hideGuidance",payload:JSON.parse(p)})},startUpdateTimer:p=>{this.workerFunctions.postMessage({type:"startUpdateTimer",payload:{duration:{unit:"ms",value:p}}})},stopUpdateTimer:()=>{this.workerFunctions.postMessage({type:"stopUpdateTimer"})}});(i=this.hintPresenterV2)==null||i.delete(),this.hintPresenterV2=null,(n=this.webPlatformHintPresenter)==null||n.delete(),this.webPlatformHintPresenter=null,this.webPlatformHintPresenter=new M,this.view&&(this.hintPresenterV2=new this.Module.HintPresenterV2(this.webPlatformHintPresenter),(o=this.view)==null||o.setHintPresenterV2(this.hintPresenterV2)),this.webImageConverterInstance=this.getImageConverterInstance({quality:1}),this.Module.ImageConverter.setInstance(this.webImageConverterInstance)}convertToJPEGResult(e,a){this.webImageConverterInstance instanceof ee&&this.webImageConverterInstance.onConvertToJPEGResult(e,a)}getImageConverterInstance(e){return this.workerFunctions.getOffscreenCanvas()!=null?new he(e):new ee(this.workerFunctions,e)}onTap(e){var a;(a=this.gestureListener)==null||a.onTap(JSON.stringify(e))}hintPresenterV2Update(){var e;(e=this.hintPresenterV2)==null||e.update()}startReportingPerformanceMetrics(){this.performanceMetricsReporterTimer==null&&(this.lastMetricsReportTime=performance.now(),this.scheduleMetricsReporting())}scheduleMetricsReporting(){this.performanceMetricsReporterTimer=setTimeout(()=>{this.checkAndReportMetrics()},100)}checkAndReportMetrics(){let e=performance.now();e-this.lastMetricsReportTime>=this.metricsReportInterval&&(this.reportPerformanceMetrics(),this.performanceMetrics.cameraOutputFrames=0,this.performanceMetrics.redrawRequestsCount=0,this.performanceMetrics.actualRedrawsCount=0,this.lastMetricsReportTime=e),this._isDrawLoopRunning&&this.scheduleMetricsReporting()}async reportPerformanceMetrics(){let e=this.frameProcessingStartedCount-this.lastFrameProcessingStartedCount,a=this.frameProcessingFinishedCount-this.lastFrameProcessingFinishedCount;this.lastFrameProcessingStartedCount=this.frameProcessingStartedCount,this.lastFrameProcessingFinishedCount=this.frameProcessingFinishedCount;let r={cameraOutputFrames:this.performanceMetrics.cameraOutputFrames,redrawRequestsCount:this.performanceMetrics.redrawRequestsCount,actualRedrawsCount:this.performanceMetrics.actualRedrawsCount,frameDataPoolSize:this.performanceMetrics.frameDataPoolSize,frameProcessingStartedCount:e,frameProcessedCount:a,frameSkippedCount:this.performanceMetrics.frameSkippedCount};this.workerFunctions.postMessage({type:"performanceMetricsReport",payload:r})}deleteFrameData(e){this.frameDataPool.delete(e)}dispose(){var e,a,r,i,n;this.context.dispose(),this.frameDataPool.clear(),this.isDrawLoopRunning=!1,this.cleanupMetricsReporting(),(e=this.gestureRecognizer)==null||e.delete(),this.gestureRecognizer=null,(a=this.gestureListener)==null||a.delete(),this.gestureListener=null,(r=this.hintPresenterV2)==null||r.delete(),this.hintPresenterV2=null,(i=this.webPlatformHintPresenter)==null||i.delete(),this.webPlatformHintPresenter=null,(n=this.deviceInstance)==null||n.delete(),this.deviceInstance=null,this.deviceInfo=null}cleanupMetricsReporting(){this.performanceMetricsReporterTimer!=null&&(typeof this.performanceMetricsReporterTimer=="number"?cancelAnimationFrame(this.performanceMetricsReporterTimer):clearTimeout(this.performanceMetricsReporterTimer),this.performanceMetricsReporterTimer=void 0)}flushAnalytics(){this.context.flushAnalytics()}extractCentaurusLicense(e){return{payload:{centaurus:{licenseKey:this.Module.LicenseUtils[be.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 a;if(this.context==null)return d.debug("[processFrame] Context is null, returning frame without processing"),{payload:e,transferables:[e.data.buffer]};this.lastFrameId=e.frameId;let r=e.data,i=e.colorType==="GRAYSCALE"?this.Module.ImageBufferFormat.Grayscale8:this.Module.ImageBufferFormat.Rgba8888;this.lastFrameColorType=e.colorType==="GRAYSCALE"?"GRAYSCALE":"RGBA";let n=this.Module.allocateUint8Array(r.byteLength);return this.Module.HEAPU8.set(r,n),(a=this.imageFrameSource)==null||a.outputFrame(n,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 a=this.frameDataPool.get(e);if(a==null)return{payload:{data:null,frameId:null,colorType:null}};if(a.data.buffer.byteLength===0)return this.frameDataPool.delete(e),{payload:{data:null,frameId:null,colorType:null}};let r=a.data;a.colorType==="GRAYSCALE"&&(r=ie(a.data,a.width,a.height));let i={payload:{data:r,frameId:a.frameId,colorType:a.colorType},transferables:[r.buffer]};return this.frameDataPool.delete(e),i}scheduleRedraw(e,a){this.addRedrawRequest(a),this.isDrawLoopRunning||this.startDrawLoop(e)}sendViewRefreshCommands(e){this.workerFunctions.postMessage({type:"draw",payload:e},[e.buffer])}setFrameSource(e,a){var r;this.lastUsedModuleMirrorAxis=this.mapMirrorAxisOnModule(e),(r=this.imageFrameSource)==null||r.delete(),this.imageFrameSource=new this.Module.ImageBufferFrameSource(this.lastUsedModuleMirrorAxis,a,0),this.context.setFrameSource(this.imageFrameSource)}startDrawLoop(e){this.isDrawLoopRunning=!0;let a=n=>this.redrawRequests.length>0&&this.redrawRequests[0]<=n,r=n=>{for(;this.redrawRequests.length>0&&this.redrawRequests[0]<=n;)this.redrawRequests.shift()},i=()=>{this.loopTimeoutId=setTimeout(()=>{if(!this.isDrawLoopRunning)return;let n=performance.now();if(a(n)){r(n),e.draw();let o=e.getDrawCommands();this.sendViewRefreshCommands(new Uint8Array(o))}i()},this.redrawInterval)};i()}updateContext(e){if(this.context!=null&&this.contextDeserializer!=null){e.view!=null&&!e.view.visible&&this.context.flushAnalytics();let a=this.onBeforeUpdateContextHook(e),r=this.contextDeserializer.updateContextFromJson(this.context,this.view,JSON.stringify(a.context));if(r==null){let n=this.contextDeserializer.getLastError();throw new Error(`Could not update the context: ${n}`)}this.context.delete(),this.context=r.getContext();let i=r.getView();r.delete(),i!=null&&a.view!=null&&(i.setViewSize(a.view.width,a.view.height,a.view.orientation),i.draw()),!this.hintPresenterV2&&this.webPlatformHintPresenter&&(this.hintPresenterV2=new this.Module.HintPresenterV2(this.webPlatformHintPresenter)),i!=null&&this.hintPresenterV2&&i.setHintPresenterV2(this.hintPresenterV2),this.gestureRecognizer!=null&&(i==null||i.setGestureRecognizer(this.gestureRecognizer)),this.setView(i),this.notifyMainThreadOnViewInfoChanged(i),d.debug("context updated",a)}}notifyMainThreadOnViewInfoChanged(e){let a=this.getViewInfo(e);this.lastViewInfo.isSame(a)||(this.lastViewInfo.update(a),this.workerFunctions.postMessage({type:"viewSizeChanged",payload:a}))}getViewInfo(e){if(e!=null)try{let a=JSON.parse(e.getViewInfo());if(a!=null){let r=this.getOrientationFromNumber(a.orientation);return{...a,orientation:r}}}catch(a){d.error("Failed to get view size",a)}return null}getOrientationFromNumber(e){switch(e){case 90:return"landscapeRight";case 180:return"portraitUpsideDown";case 270:return"landscapeLeft";default:return"portrait"}}onBeforeUpdateContextHook(e){return e}onDocumentVisibilityChange(e){e==="hidden"&&this.context.flushAnalytics()}isFeatureSupported(e){return{payload:{supported:this.context.isFeatureSupported(e)}}}getViewfinderInfo(){var e,a;return{payload:{isDisplayingViewfinder:(a=(e=this.view)==null?void 0:e.isDisplayingViewfinder())!=null?a:!1,rect:JSON.parse(this.view.getViewfinderRect())}}}getOpenSourceSoftwareLicenseInfo(){return{payload:{licenseText:this.Module.OpenSourceSoftwareLicenseInfo.getLicenseText()}}}getWasmDynamicLibraries(e){return this.getWasmSideModuleFileName()==null?[]:[`${e.replace(/\\/[^/]*$/,"/")}${this.getWasmSideModuleFileName()}`]}getWasmCoreExpectedHash(e,a){return a?e?"472c3b762d18caa8d47b1181bf90bb45c922dd8e667b1f701fe4c0563d5da1b9":"94d7a2af70a372f171c828ba59f3fbb0acfe998b52ff71bc7ee225b824c69e17":e?"7758b80f4d62be0956d4cc61c5244702891a57bfa677ad0724d0d24b07245163":""}getWasmCoreFileName(e,a){return a?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((a,r)=>a-r)}contextDidChangeStatus(e){e.code===260?e.message=e.message.replace("domain name",`domain name (${Q(location)})`):e.code===265&&(e.message=e.message.replace("domain name",`domain name (${this.parentDomain})`)),this.workerFunctions.postMessage({type:"contextDidChangeStatus",payload:e})}didStartObservingContext(){this.workerFunctions.postMessage({type:"didStartObservingContext"})}mapMirrorAxisOnModule(e){switch(e){case"None":return this.Module.Axis.None;case"X":return this.Module.Axis.X;case"Y":return this.Module.Axis.Y;default:return this.Module.Axis.None}}setView(e){this.view=e,this.setViewRefreshHandler(e),e==null&&(this.isDrawLoopRunning=!1,this.sendViewRefreshCommands(new Uint8Array([])))}addNativeOverlay(e){d.warn("addNativeOverlay has not been implemented for this module",e)}removeNativeOverlay(e){d.warn("removeNativeOverlay has not been implemented for this module",e)}setViewRefreshHandler(e){if(e==null||e.isViewRefreshHandlerSet)return;let a=this.Module.NeedsRedrawDelegate.extend("NeedsRedrawDelegate",{setNeedsRedrawIn:this.scheduleRedraw.bind(this,e)}),r=new a;e.setNeedsRedrawDelegate(r),e.isViewRefreshHandlerSet=!0}setupDataDecoding(){let e=this.moduleHandler.get(),a=e.DataDecoding.extend("DataDecoding",{decode(r,i){try{let n=JSON.parse(i),o=[];for(let s of n){let c=new TextDecoder(s.ianaName,{fatal:!0});o.push(c.decode(r.slice(s.startIndex,s.endIndex)))}return o.join("")}catch{return""}}});e.setDataDecoding(new a)}getBatteryData(){var e,a;let r=(a=(e=this.deviceInfo)==null?void 0:e.batteryInfo)==null?void 0:a.percentage;if(r!=null)return{percentage:r}}isTablet(){var e,a;return(a=(e=this.deviceInfo)==null?void 0:e.isTablet)!=null?a:!1}setupDeviceInterface(e,a){this.deviceInfo={isTablet:e,batteryInfo:a};let r=this.moduleHandler.get(),i=r.DeviceInterface.extend("DeviceInterface",{getBatteryData:this.getBatteryData.bind(this),isTablet:this.isTablet.bind(this)});this.deviceInstance=new i,r.DeviceHolder.setCurrentDevice(this.deviceInstance)}updateBatteryInfo(e){this.deviceInfo&&(this.deviceInfo.batteryInfo=e)}start(e,a,r){e&&a&&(this.setupDataDecoding(),this.moduleHandler.get().callMain(),this.moduleHandler.get().__emscripten_proxy_main!==void 0||r())}getWritableDataPath(e){return e!=null?(d.debug(`IndexedDB database name override in use to recover from blocked standard database: ${e}`),e):this.writableDataPathStandard}numOfMBToPages(e){return Math.ceil(1024*e*1024/64/1024)}async setup({libraryLocation:e,locationPath:a,writableDataPathOverride:r,indexedDBTimeoutMs:i,verifyResponseHash:n,referredOrigin:o,fixedWasmMemory:s,simdSupport:c,threadsSupport:l}){var h;let m=!1,g=!1;this.writableDataPath=this.getWritableDataPath(r),this.resourcePath=`${e}${this.resourceFilesSubfolder}/`,self.path=a;let{resolve:f,reject:b,promise:P}=new A,M=R.sdkVersion();if(M==="")throw new x({name:"Invalid library version",message:"Library version is not defined or empty, cannot generate proper path to library files."});let p=this.getWasmCoreFileName(c,l),y=ge(M,e,p),{jsURI:F,wasmURI:ae}=y,xe={instantiateWasm:(S,Te)=>(ue({importObject:S,wasmURI:ae,expectedHash:this.getWasmCoreExpectedHash(c,l),verifyResponseHash:n,successCallback:Te,progressCallback:this._loadProgressCallback,errorCallback:Ae=>{b(Ae)},referredOrigin:o}),{})},B=s===null?null:new WebAssembly.Memory({initial:this.numOfMBToPages(s),maximum:this.numOfMBToPages(300),shared:l});return B!==null&&d.log(d.Level.Debug,"Fixed wasmMemory set",B),this.moduleHandler.set({...B?{wasmMemory:B}:{},mainScriptUrlOrBlob:F,canvas:(h=this.workerFunctions.getOffscreenCanvas())!=null?h:{getContext:()=>null},...xe,dynamicLibraries:this.getWasmDynamicLibraries(ae),locateFile:S=>e+S,noInitialRun:!0,preRun:[async()=>{try{await de({writableDataPath:this.writableDataPath,indexedDBTimeoutMs:i})}catch(S){if(S.name==="BlockedIndexedDB"){b(S.toString());return}d.log(d.Level.Debug,"No IndexedDB support, some data will not be persisted:",S)}g=!0,this.start(g,m,f)}],onMainComplete:()=>{if([m,g].includes(!1)){d.log(d.Level.Warn,{runtimeLoaded:m,fileSystemSynced:g},"Both runtimeLoaded and fileSystemSynced should be true when calling onMainComplete"),b("onMainComplete has been called but runtime or file system was not ready.");return}f()},onRuntimeInitialized:()=>{m=!0,this.start(g,m,f)},print:S=>{d.info(S)}}),await pe(F,M)||b(`Couldn\'t retrieve Scandit Data Capture library at ${F}, did you configure the path for it correctly?`),P}};fe.get3dPartyLicenseKeyMethodName=atob("Z2V0QmxpbmtJZExpY2Vuc2VLZXk=");var I=fe;function ye(t){return typeof t=="object"&&t!=null&&t.document==null&&"addEventListener"in t&&typeof t.importScripts=="function"}function Se(t){console.warn("Reached unexpected case",t)}var te=class{constructor(t,e){this.onMessageListener=this.onMessage.bind(this),this.workerSelf=t,this.dataCaptureInstance=new I(e,{postMessage:this.postMessage.bind(this),getOffscreenCanvas:this.getOffscreenCanvas.bind(this)}),ye(t)&&(re(t),this.listenToMessages())}listenToMessages(){this.workerSelf.addEventListener("message",this.onMessageListener),this.workerSelf.addEventListener("error",t=>{d.log(d.Level.Error,t)}),this.workerSelf.addEventListener("messageerror",t=>{d.log(d.Level.Error,t)})}postMessage(t,e){this.workerSelf.postMessage(t,e!=null?e:[])}getOffscreenCanvas(){if(this.isOffscreenCanvasSupported())return new this.workerSelf.OffscreenCanvas(32,32)}isOffscreenCanvasSupported(){return typeof this.workerSelf.OffscreenCanvas=="function"}hasPayload(t){return C(t)&&"payload"in t}hasTransferables(t){return C(t)&&Array.isArray(t.transferables)}async respondWith(t,e,a){let r=null,i;try{i=a(),i instanceof Promise&&(i=await i)}catch(o){i=void 0,r=k(o)}let n={type:"workerTaskId",command:t,id:e,payload:this.hasPayload(i)?i.payload:void 0};r!=null&&(n.error=r),this.postMessage(n,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,writableDataPathOverride:e.writableDataPathOverride,threadsSupport:e.threadsSupport,simdSupport:e.simdSupport,verifyResponseHash:e.verifyResponseHash,fixedWasmMemory:e.fixedWasmMemory,indexedDBTimeoutMs:e.indexedDBTimeoutMs}))}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,isTablet:e.isTablet,batteryInfo:e.batteryInfo}))}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,frameId:e.frameId,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,()=>{d.setLevel(e.level)})}break}case"updateBatteryInfo":{{let{data:e}=t;this.respondWith(e.command,e.id,()=>{this.dataCaptureInstance.updateBatteryInfo(e.batteryInfo)})}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}case"addNativeOverlay":this.dataCaptureInstance.addNativeOverlay(t);break;case"removeNativeOverlay":this.dataCaptureInstance.removeNativeOverlay(t);break;case"convertToJPEGResult":{{let{data:e}=t;this.dataCaptureInstance.convertToJPEGResult(e.imageId,e.result)}break}default:return Se(t.data),!1}return!0}};var we=(t=>(t.Body="body",t.Footnote="footnote",t))(we||{}),E=(t=>(t.Start="start",t.Center="center",t.End="end",t))(E||{}),ve=(t=>(t.Normal="normal",t.Wider="wider",t.FitText="fitText",t))(ve||{}),Fe=(t=>(t.Normal="normal",t.Taller="taller",t))(Fe||{}),Me=(t=>(t.Square="square",t.Rounded="rounded",t))(Me||{}),L=(t=>(t.None="none",t.Check="check",t.ExclamationMark="exclamationMark",t))(L||{}),W=(t=>(t.Top="top",t.Center="center",t.AboveViewFinder="aboveViewFinder",t.BelowViewFinder="belowViewFinder",t))(W||{}),Ce=(t=>(t.AboveViewFinder="aboveViewFinder",t.BelowViewFinder="belowViewFinder",t))(Ce||{}),ke=(t=>(t.BlackOnWhite="blackOnWhite",t.WhiteOnBlack="whiteOnBlack",t.Transparent="transparent",t))(ke||{}),De=(t=>(t.Success="success",t.Error="error",t.Warning="warning",t.Info="info",t.Notification="notification",t))(De||{}),Ie=(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[t.BarcodeSequence=39]="BarcodeSequence",t))(Ie||{});var N=class{constructor(e,a,r){this.barcodeAr=null;this.coreEngine=e,this.Module=a,this.workerFunctions=r}async forSettings(e){var r;(r=this.barcodeAr)==null||r.delete(),this.barcodeAr=new this.Module.BarcodeAr(this.coreEngine.context,JSON.stringify(e));let a=this.Module.BarcodeArListener.extend("BarcodeArListener",{didUpdateSession:(i,n,o)=>{let s=this.coreEngine.prepareFrameForListener(o);this.workerFunctions.postMessage({type:"barcodeArDidUpdateSession",payload:{session:JSON.parse(n.toJson()),frameData:s}}),i.delete(),n.delete(),o.delete()}});this.barcodeAr.addListener(new a,1),this.Module.addBarcodeArToContext(this.coreEngine.context,this.barcodeAr)}start(){var e;(e=this.barcodeAr)==null||e.start()}pause(){var e;(e=this.barcodeAr)==null||e.pause()}stop(){var e;(e=this.barcodeAr)==null||e.stop()}setEnabled(e){var a;(a=this.barcodeAr)==null||a.setEnabled(e)}async removeMode(){this.barcodeAr!=null&&this.Module.removeBarcodeArFromContext(this.coreEngine.context,this.barcodeAr)}applySettings(e){var a;(a=this.barcodeAr)==null||a.applySettings(JSON.stringify(e))}};var H=class{constructor(e,a,r){this.trackingListenerSet=!1;this.coreEngine=e,this.Module=a,this.workerFunctions=r,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:(r,i,n)=>{this.barcodeBatchDidUpdateSession(i),r.delete(),i.delete(),n.delete()},onTrackedBarcodeTapped:(r,i)=>{this.onTrackedBarcodeTapped(i),r.delete(),i.delete()}}),a=this.Module.BarcodeBatchDeserializerListener.extend("BarcodeTrackingDeserializerListener",{onModeDeserializationFinished:(r,i,n)=>{this.trackingListenerSet||(i.addListener(new e,1),this.trackingListenerSet=!0),r.delete(),i.delete(),n.delete()},onModeDeserializationStarted(r,i,n){r.delete(),i.delete(),n.delete()},onSettingsDeserializationStarted(r,i,n){r.delete(),i.delete(),n.delete()},onSettingsDeserializationFinished(r,i,n){r.delete(),i.delete(),n.delete()}});this.barcodeBatchDeserializer=new this.Module.BarcodeBatchDeserializer,this.barcodeBatchDeserializer.setListener(new a)}onTrackedBarcodeTapped(e){this.workerFunctions.postMessage({type:"didTapTrackedBarcode",payload:JSON.parse(e.toJson())})}};var _=class{constructor(e,a,r){this.captureListenerSet=!1;this.coreEngine=e,this.Module=a,this.workerFunctions=r,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:(o,s,c)=>{this.barcodeCaptureDidScan(s,c),o.delete(),c.delete(),s.delete()},didUpdateSession:(o,s,c)=>{this.barcodeCaptureDidUpdateSession(s),o.delete(),c.delete(),s.delete()}}),a=this.Module.Feedback.extend("Feedback",{emit:()=>{this.successFeedback()}}),r=new e,i=new a,n=this.Module.BarcodeCaptureDeserializerListener.extend("BarcodeCaptureDeserializerListener",{onModeDeserializationFinished:(o,s,c)=>{s.addListener(r,1),s.setSuccessFeedback(i),o.delete(),s.delete(),c.delete()},onModeDeserializationStarted(o,s,c){o.delete(),s.delete(),c.delete()},onSettingsDeserializationStarted(o,s,c){o.delete(),s.delete(),c.delete()},onSettingsDeserializationFinished(o,s,c){o.delete(),s.delete(),c.delete()}});this.barcodeCaptureDeserializer=new this.Module.BarcodeCaptureDeserializer,this.barcodeCaptureDeserializer.setListener(new n)}successFeedback(){this.workerFunctions.postMessage({type:"successFeedback"})}barcodeCaptureDidScan(e,a){let r=this.coreEngine.prepareFrameForListener(a);this.workerFunctions.postMessage({type:"barcodeCaptureDidScan",payload:{session:JSON.parse(e.toJson()),frameData:r}})}};function qe(t){return t.charAt(0).toUpperCase()+t.slice(1)}function Pe(t){return t}var z=class{constructor(e,a,r){this.barcodeFind=null;this.basicOverlay=null;this.transparentGuidanceHintStyle={backgroundColor:"00000000",cornerRadius:4,fitToText:!1,isAnimatedToView:!1,textAlignment:E.Center,hintIcon:L.None,hintAnchor:W.Center,hintAnchorOffset:0,horizontalMargin:0,iconColor:"00000000",lineHeight:-1,maxLines:1,maxWidthFraction:.8,textColor:"ffffffff",textSize:15,textWeight:600};this.customerTransformation=Pe;this.coreEngine=e,this.Module=a,this.workerFunctions=r}async forSettings(e){var o;(o=this.barcodeFind)==null||o.delete(),this.barcodeFind=new this.Module.BarcodeFind(this.coreEngine.context,JSON.stringify(e));let a=this.Module.Feedback.extend("Feedback",{emit:()=>{this.listUpdatedFeedback()}}),r=this.Module.Feedback.extend("Feedback",{emit:()=>{this.barcodeFindFeedback()}}),i=this.Module.BarcodeFindTransformer.extend("BarcodeFindTransformer",{transformBarcodeData:s=>this.customerTransformation(s)}),n=this.Module.BarcodeFindListener.extend("BarcodeFindListener",{didUpdateSession:(s,c,l)=>{let h=this.coreEngine.prepareFrameForListener(l);this.workerFunctions.postMessage({type:"barcodeFindDidUpdateSession",payload:{session:JSON.parse(c.toJson()),frameData:h}}),s.delete(),c.delete(),l.delete()},onSearchPaused:s=>{let c=[];for(let l=0;l<s.size();l++)c.push(s.get(l));this.workerFunctions.postMessage({type:"barcodeFindSearchPaused",payload:{foundItems:c}})},onSearchStopped:s=>{let c=[];for(let l=0;l<s.size();l++)c.push(s.get(l));this.workerFunctions.postMessage({type:"barcodeFindSearchStopped",payload:{foundItems:c}})},onSearchStarted:()=>{this.workerFunctions.postMessage({type:"barcodeFindSearchStarted",payload:{}})}});this.barcodeFind.setBarcodeFindTransformer(new i),this.barcodeFind.addListener(new n,1),this.barcodeFind.setItemListUpdatedFeedback(new a),this.barcodeFind.setFeedback(new r),this.Module.addBarcodeFindToContext(this.coreEngine.context,this.barcodeFind)}barcodeFindFeedback(){this.workerFunctions.postMessage({type:"barcodeFindFeedback",payload:{}})}start(){var e;(e=this.barcodeFind)==null||e.start()}stop(){var e;(e=this.barcodeFind)==null||e.stop()}pause(){var e;(e=this.barcodeFind)==null||e.pause()}setEnabled(e){var a;(a=this.barcodeFind)==null||a.setEnabled(e)}setItemList(e){var a;(a=this.barcodeFind)==null||a.setItemList(JSON.stringify(e))}async removeMode(){this.barcodeFind!=null&&this.Module.removeBarcodeFindFromContext(this.coreEngine.context,this.barcodeFind)}addBasicOverlay(){var e;(e=this.basicOverlay)==null||e.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){var a;(a=this.barcodeFind)==null||a.applySettings(JSON.stringify(e))}updateBasicOverlay(e){let a=Object.entries(e).filter(([r,i])=>r!=="type");for(let[r,i]of a){let n=`set${qe(r)}`;this.basicOverlay!=null&&typeof this.basicOverlay[n]=="function"&&i!=null&&this.basicOverlay[n](i)}}setTransformerFunction(e){this.customerTransformation=e!=null?e:Pe}successFeedback(){this.workerFunctions.postMessage({type:"successFeedback"})}listUpdatedFeedback(){this.workerFunctions.postMessage({type:"barcodeFindListUpdatedFeedback",payload:{}})}setToast(e,a){let r=this.coreEngine.hintPresenterV2;e?r==null||r.showToast(JSON.stringify(a)):r==null||r.hideToast(a.tag)}setGuidance(e,a,r){let i={tag:r,text:a,hintStyle:this.transparentGuidanceHintStyle};this.workerFunctions.postMessage({type:e?"showGuidance":"hideGuidance",payload:i})}createWebFindGuidanceHandler(){let e=this.Module.BarcodeFindGuidanceHandler.extend("BarcodeFindGuidanceHandler",{setInitialGuidance:(a,r)=>{this.setGuidance(a,r,"InitialGuidance")},setMoveCloserGuidance:(a,r)=>{this.setGuidance(!1,r,"InitialGuidance"),this.setGuidance(a,r,"MoveCloserGuidance")},setTapShutterToPause:(a,r)=>{this.setGuidance(!1,r,"InitialGuidance"),this.setGuidance(a,r,"TapShutterToPause")},setTapShutterToResume:(a,r)=>{this.setGuidance(!1,r,"InitialGuidance"),this.setGuidance(a,r,"TapShutterResume")}});return new e}};var w=class{constructor(e){this.subscribers=new Set;this.property={key:e,value:null}}addSubscriber(e){var a;this.subscribers.add(e),(a=e.onPropertyChanged)==null||a.call(e,this.property)}removeSubscriber(e){this.subscribers.delete(e)}setProperty(e){var a;if(this.property.value!==e.value){this.property={key:this.property.key,value:e.value};for(let r of this.subscribers)(a=r.onPropertyChanged)==null||a.call(r,this.property)}}};var Ye={torch