/*!
 * Dynamsoft JavaScript Library
 * @product Dynamsoft Barcode Reader JS Edition
 * @website http://www.dynamsoft.com
 * @copyright Copyright 2024, Dynamsoft Corporation
 * @author Dynamsoft
 * @version 9.6.41 (js 20240108)
 * @fileoverview Dynamsoft JavaScript Library for Barcode Reader
 * More info on DBR JS: https://www.dynamsoft.com/barcode-reader/sdk-javascript/
 */
import{Howl as e}from"dm-howler";import{CameraEnhancer as t,DrawingItem as i}from"dynamsoft-camera-enhancer";const s="undefined"==typeof self,a=s?{}:self;let r,o,n,c,d;"undefined"!=typeof navigator&&(r=navigator,o=r.userAgent,n=r.platform,c=r.mediaDevices),function(){if(!s){const e={Edge:{search:"Edg",verSearch:"Edg"},OPR:null,Chrome:null,Safari:{str:r.vendor,search:"Apple",verSearch:["Version","iPhone OS","CPU OS"]},Firefox:null,Explorer:{search:"MSIE",verSearch:"MSIE"}},t={HarmonyOS:null,Android:null,iPhone:null,iPad:null,Windows:{str:n,search:"Win"},Mac:{str:n},Linux:{str:n}};let i="unknownBrowser",s=0,a="unknownOS";for(let t in e){const a=e[t]||{};let r=a.str||o,n=a.search||t,c=a.verStr||o,d=a.verSearch||t;if(d instanceof Array||(d=[d]),-1!=r.indexOf(n)){i=t;for(let e of d){let t=c.indexOf(e);if(-1!=t){s=parseFloat(c.substring(t+e.length+1));break}}break}}for(let e in t){const i=t[e]||{};let s=i.str||o,r=i.search||e;if(-1!=s.indexOf(r)){a=e;break}}"Linux"==a&&-1!=o.indexOf("Windows NT")&&(a="HarmonyOS"),d={browser:i,version:s,OS:a}}s&&(d={browser:"ssr",version:0,OS:"ssr"})}();const l="undefined"!=typeof WebAssembly&&o&&!(/Safari/.test(o)&&!/Chrome/.test(o)&&/\(.+\s11_2_([2-6]).*\)/.test(o)),h=!("undefined"==typeof Worker),_=!(!c||!c.getUserMedia),u=async()=>{let e=!1;if(_)try{(await c.getUserMedia({video:!0})).getTracks().forEach((e=>{e.stop()})),e=!0}catch(e){}return e};"Chrome"===d.browser&&d.version>66||"Safari"===d.browser&&d.version>13||"OPR"===d.browser&&d.version>43||"Edge"===d.browser&&d.version;const g=(()=>{if(!s&&document.currentScript){let e=document.currentScript.src,t=e.indexOf("?");if(-1!=t)e=e.substring(0,t);else{let t=e.indexOf("#");-1!=t&&(e=e.substring(0,t))}return e.substring(0,e.lastIndexOf("/")+1)}return"./"})(),m=" is not allowed to change after `createInstance` or `loadWasm` is called.",R=!s&&document.currentScript&&(document.currentScript.getAttribute("data-license")||document.currentScript.getAttribute("data-productKeys")||document.currentScript.getAttribute("data-licenseKey")||document.currentScript.getAttribute("data-handshakeCode")||document.currentScript.getAttribute("data-organizationID"))||"",I=!s&&document.currentScript&&document.currentScript.getAttribute("data-sessionPassword")||"",S=e=>{if(null==e)e=[];else{e=e instanceof Array?[...e]:[e];for(let t=0;t<e.length;++t){if(!s){let i=document.createElement("a");i.href=e[t],e[t]=i.href}e[t].endsWith("/")||(e[t]+="/")}}return e};var E,A,f,T,D;!function(e){e[e.IPF_Binary=0]="IPF_Binary",e[e.IPF_BinaryInverted=1]="IPF_BinaryInverted",e[e.IPF_GrayScaled=2]="IPF_GrayScaled",e[e.IPF_NV21=3]="IPF_NV21",e[e.IPF_RGB_565=4]="IPF_RGB_565",e[e.IPF_RGB_555=5]="IPF_RGB_555",e[e.IPF_RGB_888=6]="IPF_RGB_888",e[e.IPF_ARGB_8888=7]="IPF_ARGB_8888",e[e.IPF_RGB_161616=8]="IPF_RGB_161616",e[e.IPF_ARGB_16161616=9]="IPF_ARGB_16161616",e[e.IPF_ABGR_8888=10]="IPF_ABGR_8888",e[e.IPF_ABGR_16161616=11]="IPF_ABGR_16161616",e[e.IPF_BGR_888=12]="IPF_BGR_888"}(E||(E={})),function(e){e[e.DBR_SYSTEM_EXCEPTION=1]="DBR_SYSTEM_EXCEPTION",e[e.DBR_SUCCESS=0]="DBR_SUCCESS",e[e.DBR_UNKNOWN=-1e4]="DBR_UNKNOWN",e[e.DBR_NO_MEMORY=-10001]="DBR_NO_MEMORY",e[e.DBR_NULL_REFERENCE=-10002]="DBR_NULL_REFERENCE",e[e.DBR_LICENSE_INVALID=-10003]="DBR_LICENSE_INVALID",e[e.DBR_LICENSE_EXPIRED=-10004]="DBR_LICENSE_EXPIRED",e[e.DBR_FILE_NOT_FOUND=-10005]="DBR_FILE_NOT_FOUND",e[e.DBR_FILETYPE_NOT_SUPPORTED=-10006]="DBR_FILETYPE_NOT_SUPPORTED",e[e.DBR_BPP_NOT_SUPPORTED=-10007]="DBR_BPP_NOT_SUPPORTED",e[e.DBR_INDEX_INVALID=-10008]="DBR_INDEX_INVALID",e[e.DBR_BARCODE_FORMAT_INVALID=-10009]="DBR_BARCODE_FORMAT_INVALID",e[e.DBR_CUSTOM_REGION_INVALID=-10010]="DBR_CUSTOM_REGION_INVALID",e[e.DBR_MAX_BARCODE_NUMBER_INVALID=-10011]="DBR_MAX_BARCODE_NUMBER_INVALID",e[e.DBR_IMAGE_READ_FAILED=-10012]="DBR_IMAGE_READ_FAILED",e[e.DBR_TIFF_READ_FAILED=-10013]="DBR_TIFF_READ_FAILED",e[e.DBR_QR_LICENSE_INVALID=-10016]="DBR_QR_LICENSE_INVALID",e[e.DBR_1D_LICENSE_INVALID=-10017]="DBR_1D_LICENSE_INVALID",e[e.DBR_DIB_BUFFER_INVALID=-10018]="DBR_DIB_BUFFER_INVALID",e[e.DBR_PDF417_LICENSE_INVALID=-10019]="DBR_PDF417_LICENSE_INVALID",e[e.DBR_DATAMATRIX_LICENSE_INVALID=-10020]="DBR_DATAMATRIX_LICENSE_INVALID",e[e.DBR_PDF_READ_FAILED=-10021]="DBR_PDF_READ_FAILED",e[e.DBR_PDF_DLL_MISSING=-10022]="DBR_PDF_DLL_MISSING",e[e.DBR_PAGE_NUMBER_INVALID=-10023]="DBR_PAGE_NUMBER_INVALID",e[e.DBR_CUSTOM_SIZE_INVALID=-10024]="DBR_CUSTOM_SIZE_INVALID",e[e.DBR_CUSTOM_MODULESIZE_INVALID=-10025]="DBR_CUSTOM_MODULESIZE_INVALID",e[e.DBR_RECOGNITION_TIMEOUT=-10026]="DBR_RECOGNITION_TIMEOUT",e[e.DBR_JSON_PARSE_FAILED=-10030]="DBR_JSON_PARSE_FAILED",e[e.DBR_JSON_TYPE_INVALID=-10031]="DBR_JSON_TYPE_INVALID",e[e.DBR_JSON_KEY_INVALID=-10032]="DBR_JSON_KEY_INVALID",e[e.DBR_JSON_VALUE_INVALID=-10033]="DBR_JSON_VALUE_INVALID",e[e.DBR_JSON_NAME_KEY_MISSING=-10034]="DBR_JSON_NAME_KEY_MISSING",e[e.DBR_JSON_NAME_VALUE_DUPLICATED=-10035]="DBR_JSON_NAME_VALUE_DUPLICATED",e[e.DBR_TEMPLATE_NAME_INVALID=-10036]="DBR_TEMPLATE_NAME_INVALID",e[e.DBR_JSON_NAME_REFERENCE_INVALID=-10037]="DBR_JSON_NAME_REFERENCE_INVALID",e[e.DBR_PARAMETER_VALUE_INVALID=-10038]="DBR_PARAMETER_VALUE_INVALID",e[e.DBR_DOMAIN_NOT_MATCHED=-10039]="DBR_DOMAIN_NOT_MATCHED",e[e.DBR_RESERVEDINFO_NOT_MATCHED=-10040]="DBR_RESERVEDINFO_NOT_MATCHED",e[e.DBR_AZTEC_LICENSE_INVALID=-10041]="DBR_AZTEC_LICENSE_INVALID",e[e.DBR_LICENSE_DLL_MISSING=-10042]="DBR_LICENSE_DLL_MISSING",e[e.DBR_LICENSEKEY_NOT_MATCHED=-10043]="DBR_LICENSEKEY_NOT_MATCHED",e[e.DBR_REQUESTED_FAILED=-10044]="DBR_REQUESTED_FAILED",e[e.DBR_LICENSE_INIT_FAILED=-10045]="DBR_LICENSE_INIT_FAILED",e[e.DBR_PATCHCODE_LICENSE_INVALID=-10046]="DBR_PATCHCODE_LICENSE_INVALID",e[e.DBR_POSTALCODE_LICENSE_INVALID=-10047]="DBR_POSTALCODE_LICENSE_INVALID",e[e.DBR_DPM_LICENSE_INVALID=-10048]="DBR_DPM_LICENSE_INVALID",e[e.DBR_FRAME_DECODING_THREAD_EXISTS=-10049]="DBR_FRAME_DECODING_THREAD_EXISTS",e[e.DBR_STOP_DECODING_THREAD_FAILED=-10050]="DBR_STOP_DECODING_THREAD_FAILED",e[e.DBR_SET_MODE_ARGUMENT_ERROR=-10051]="DBR_SET_MODE_ARGUMENT_ERROR",e[e.DBR_LICENSE_CONTENT_INVALID=-10052]="DBR_LICENSE_CONTENT_INVALID",e[e.DBR_LICENSE_KEY_INVALID=-10053]="DBR_LICENSE_KEY_INVALID",e[e.DBR_LICENSE_DEVICE_RUNS_OUT=-10054]="DBR_LICENSE_DEVICE_RUNS_OUT",e[e.DBR_GET_MODE_ARGUMENT_ERROR=-10055]="DBR_GET_MODE_ARGUMENT_ERROR",e[e.DBR_IRT_LICENSE_INVALID=-10056]="DBR_IRT_LICENSE_INVALID",e[e.DBR_MAXICODE_LICENSE_INVALID=-10057]="DBR_MAXICODE_LICENSE_INVALID",e[e.DBR_GS1_DATABAR_LICENSE_INVALID=-10058]="DBR_GS1_DATABAR_LICENSE_INVALID",e[e.DBR_GS1_COMPOSITE_LICENSE_INVALID=-10059]="DBR_GS1_COMPOSITE_LICENSE_INVALID",e[e.DBR_PANORAMA_LICENSE_INVALID=-10060]="DBR_PANORAMA_LICENSE_INVALID",e[e.DBR_DOTCODE_LICENSE_INVALID=-10061]="DBR_DOTCODE_LICENSE_INVALID",e[e.DBR_PHARMACODE_LICENSE_INVALID=-10062]="DBR_PHARMACODE_LICENSE_INVALID",e[e.DBR_IMAGE_ORIENTATION_INVALID=-10063]="DBR_IMAGE_ORIENTATION_INVALID",e[e.DMERR_NO_LICENSE=-2e4]="DMERR_NO_LICENSE",e[e.DMERR_LICENSE_SYNC_FAILED=-20003]="DMERR_LICENSE_SYNC_FAILED",e[e.DMERR_TRIAL_LICENSE=-20010]="DMERR_TRIAL_LICENSE",e[e.DMERR_FAILED_TO_REACH_LTS=-20200]="DMERR_FAILED_TO_REACH_LTS"}(A||(A={})),function(e){e[e.IMRDT_IMAGE=1]="IMRDT_IMAGE",e[e.IMRDT_CONTOUR=2]="IMRDT_CONTOUR",e[e.IMRDT_LINESEGMENT=4]="IMRDT_LINESEGMENT",e[e.IMRDT_LOCALIZATIONRESULT=8]="IMRDT_LOCALIZATIONRESULT",e[e.IMRDT_REGIONOFINTEREST=16]="IMRDT_REGIONOFINTEREST",e[e.IMRDT_QUADRILATERAL=32]="IMRDT_QUADRILATERAL"}(f||(f={})),function(e){e[e.BF_ALL=-29360129]="BF_ALL",e[e.BF_ONED=3147775]="BF_ONED",e[e.BF_GS1_DATABAR=260096]="BF_GS1_DATABAR",e[e.BF_CODE_39=1]="BF_CODE_39",e[e.BF_CODE_128=2]="BF_CODE_128",e[e.BF_CODE_93=4]="BF_CODE_93",e[e.BF_CODABAR=8]="BF_CODABAR",e[e.BF_ITF=16]="BF_ITF",e[e.BF_EAN_13=32]="BF_EAN_13",e[e.BF_EAN_8=64]="BF_EAN_8",e[e.BF_UPC_A=128]="BF_UPC_A",e[e.BF_UPC_E=256]="BF_UPC_E",e[e.BF_INDUSTRIAL_25=512]="BF_INDUSTRIAL_25",e[e.BF_CODE_39_EXTENDED=1024]="BF_CODE_39_EXTENDED",e[e.BF_GS1_DATABAR_OMNIDIRECTIONAL=2048]="BF_GS1_DATABAR_OMNIDIRECTIONAL",e[e.BF_GS1_DATABAR_TRUNCATED=4096]="BF_GS1_DATABAR_TRUNCATED",e[e.BF_GS1_DATABAR_STACKED=8192]="BF_GS1_DATABAR_STACKED",e[e.BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL=16384]="BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL",e[e.BF_GS1_DATABAR_EXPANDED=32768]="BF_GS1_DATABAR_EXPANDED",e[e.BF_GS1_DATABAR_EXPANDED_STACKED=65536]="BF_GS1_DATABAR_EXPANDED_STACKED",e[e.BF_GS1_DATABAR_LIMITED=131072]="BF_GS1_DATABAR_LIMITED",e[e.BF_PATCHCODE=262144]="BF_PATCHCODE",e[e.BF_PDF417=33554432]="BF_PDF417",e[e.BF_QR_CODE=67108864]="BF_QR_CODE",e[e.BF_DATAMATRIX=134217728]="BF_DATAMATRIX",e[e.BF_AZTEC=268435456]="BF_AZTEC",e[e.BF_MAXICODE=536870912]="BF_MAXICODE",e[e.BF_MICRO_QR=1073741824]="BF_MICRO_QR",e[e.BF_MICRO_PDF417=524288]="BF_MICRO_PDF417",e[e.BF_GS1_COMPOSITE=-2147483648]="BF_GS1_COMPOSITE",e[e.BF_MSI_CODE=1048576]="BF_MSI_CODE",e[e.BF_CODE_11=2097152]="BF_CODE_11",e[e.BF_NULL=0]="BF_NULL"}(T||(T={})),function(e){e[e.IRT_NO_RESULT=0]="IRT_NO_RESULT",e[e.IRT_ORIGINAL_IMAGE=1]="IRT_ORIGINAL_IMAGE",e[e.IRT_COLOUR_CLUSTERED_IMAGE=2]="IRT_COLOUR_CLUSTERED_IMAGE",e[e.IRT_COLOUR_CONVERTED_GRAYSCALE_IMAGE=4]="IRT_COLOUR_CONVERTED_GRAYSCALE_IMAGE",e[e.IRT_TRANSFORMED_GRAYSCALE_IMAGE=8]="IRT_TRANSFORMED_GRAYSCALE_IMAGE",e[e.IRT_PREDETECTED_REGION=16]="IRT_PREDETECTED_REGION",e[e.IRT_PREPROCESSED_IMAGE=32]="IRT_PREPROCESSED_IMAGE",e[e.IRT_BINARIZED_IMAGE=64]="IRT_BINARIZED_IMAGE",e[e.IRT_TEXT_ZONE=128]="IRT_TEXT_ZONE",e[e.IRT_CONTOUR=256]="IRT_CONTOUR",e[e.IRT_LINE_SEGMENT=512]="IRT_LINE_SEGMENT",e[e.IRT_FORM=1024]="IRT_FORM",e[e.IRT_SEGMENTATION_BLOCK=2048]="IRT_SEGMENTATION_BLOCK",e[e.IRT_TYPED_BARCODE_ZONE=4096]="IRT_TYPED_BARCODE_ZONE",e[e.IRT_PREDETECTED_QUADRILATERAL=8192]="IRT_PREDETECTED_QUADRILATERAL"}(D||(D={}));const C=e=>e&&"object"==typeof e&&"function"==typeof e.then;class y extends Promise{constructor(e){let t,i;super(((e,s)=>{t=e,i=s})),this._s="pending",this.resolve=e=>{this.isPending&&(C(e)?this.task=e:(this._s="fulfilled",t(e)))},this.reject=e=>{this.isPending&&(this._s="rejected",i(e))},this.task=e}get status(){return this._s}get isPending(){return"pending"===this._s}get isFulfilled(){return"fulfilled"===this._s}get isRejected(){return"rejected"===this._s}get task(){return this._task}set task(e){let t;this._task=e,C(e)?t=e:"function"==typeof e&&(t=new Promise(e)),t&&(async()=>{try{const i=await t;e===this._task&&this.resolve(i)}catch(t){e===this._task&&this.reject(t)}})()}get isEmpty(){return null==this._task}}const p=["iPhone","iPad","Android","HarmonyOS"].includes(d.OS)?2048:4096;class L{static get version(){return this._version}static get license(){return this._license}static set license(e){((e,t)=>{const i=e;if(!i._pLoad.isEmpty)throw new Error("`license`"+m);i._license=t})(L,e)}static get productKeys(){return this._license}static set productKeys(e){L.license=e}static get handshakeCode(){return this._license}static set handshakeCode(e){L.license=e}static get organizationID(){return this._license}static set organizationID(e){L.license=e}static set sessionPassword(e){((e,t)=>{const i=e;if(!i._pLoad.isEmpty)throw new Error("`sessionPassword`"+m);i._sessionPassword=t})(L,e)}static get sessionPassword(){return this._sessionPassword}static async detectEnvironment(){return await(async()=>({wasm:l,worker:h,getUserMedia:_,camera:await u(),browser:d.browser,version:d.version,OS:d.OS}))()}static get engineResourcePath(){return this._engineResourcePath}static set engineResourcePath(e){if(!this._pLoad.isEmpty)throw new Error("`engineResourcePath` is not allowed to change after `createInstance` or `loadWasm` is called.");L._engineResourcePath=(e=>{if(null==e&&(e="./"),s);else{let t=document.createElement("a");t.href=e,e=t.href}return e.endsWith("/")||(e+="/"),e})(e)}static get licenseServer(){return this._licenseServer}static set licenseServer(e){((e,t)=>{const i=e;if(!i._pLoad.isEmpty)throw new Error("`licenseServer`"+m);i._licenseServer=S(t)})(L,e)}static get deviceFriendlyName(){return this._deviceFriendlyName}static set deviceFriendlyName(e){((e,t)=>{const i=e;if(!i._pLoad.isEmpty)throw new Error("`deviceFriendlyName`"+m);i._deviceFriendlyName=t||""})(L,e)}static get _bUseFullFeature(){return this.__bUseFullFeature}static set _bUseFullFeature(e){if(!this._pLoad.isEmpty)throw new Error("`_bUseFullFeature` is not allowed to change after `createInstance` or `loadWasm` is called.");L.__bUseFullFeature=e}static isImageSource(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&"getImage"in e}static isDSImage(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&("data"in e&&("width"in e&&("height"in e&&"pixelFormat"in e)))}static isDCEFrame(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&("data"in e&&("region"in e&&("sx"in e&&("sy"in e&&("width"in e&&("height"in e&&(("colorMode"in e||"pixelFormat"in e)&&("timeSpent"in e&&("timeStamp"in e&&("isCropped"in e&&("toCanvas"in e&&("_sWidth"in e&&("_sHeight"in e&&"_bUseWebGL"in e)))))))))))))}get ifSaveOriginalImageInACanvas(){return this._ifSaveOriginalImageInACanvas}set ifSaveOriginalImageInACanvas(e){this._ifSaveOriginalImageInACanvas=e}getOriginalImageInACanvas(){return!this.oriCanvas&&this.oriCanvasData?this.oriCanvasData.toCanvas():this.oriCanvas}set region(e){this._region=e,this.array_decodeFrameTimeCost.length=0,this.array_getFrameTimeCost.length=0,this._intervalGetVideoFrame=0}get region(){return this._region}static isWasmLoaded(){return this._pLoad.isFulfilled}isContextDestroyed(){return this.bDestroyed}static get lastErrorCode(){return this._lastErrorCode}static get lastErrorString(){return this._lastErrorString}get lastErrorCode(){return this._lastErrorCode}get lastErrorString(){return this._lastErrorString}static get defaultUIElementURL(){var e;return null===(e=L._defaultUIElementURL)||void 0===e?void 0:e.replace("@engineResourcePath/",L.engineResourcePath)}static set defaultUIElementURL(e){L._defaultUIElementURL=e}static _fireHTTPSWarnning(){L.onWarning&&location&&"https:"!==location.protocol&&setTimeout((()=>{L.onWarning&&L.onWarning({id:2,message:"Not connected via SSL (HTTPS), the SDK may not work correctly."})}),0)}get soundSource(){return this._soundSource}set soundSource(t){this._soundSource=t,this.beepSound=new e({src:[this._soundSource],onplayerror:(e,t)=>{console.warn(`Sound '${e}' playback failure: ${t}`)}})}get whenToPlaySoundforSuccessfulRead(){return!0===this.bPlaySoundOnSuccessfulRead?"frame":this.bPlaySoundOnSuccessfulRead?this.bPlaySoundOnSuccessfulRead:"never"}set whenToPlaySoundforSuccessfulRead(e){this.bPlaySoundOnSuccessfulRead="never"!==e&&e}get whenToVibrateforSuccessfulRead(){return!0===this.bVibrateOnSuccessfulRead?"frame":this.bVibrateOnSuccessfulRead?this.bVibrateOnSuccessfulRead:"never"}set whenToVibrateforSuccessfulRead(e){this.bVibrateOnSuccessfulRead="never"!==e&&e}set dce(e){this._dce=e}get dce(){return!this._dce||this._dce.isDisposed||this._dce.disposed?null:this._dce}set maxCvsSideLength(e){this._maxCvsSideLength=e,this._dceControler&&this._dceControler.setDisiredValue(this,"maxCvsSideLength",e)}get maxCvsSideLength(){return this._maxCvsSideLength}async _registerDCEControler(){if(!this.dce)return;L._onLog&&L._onLog("_registerDCEControler()");const e=this.dce;this._dceControler=e._createControler();const t=this._dceControler;t.register(this),t.setDisiredValue(this,"refreshInterval",200),t.setDisiredValue(this,"maxCvsSideLength",this._maxCvsSideLength),this._styleIdBeforeVerification=this.dce.createDrawingStyle({fillStyle:"rgba(248,252,0,0.2)",strokeStyle:"transparent",paintMode:"strokeAndFill"});try{ResizeObserver}catch(e){"ReferenceError"===e.name&&window&&(window.ResizeObserver=void 0)}const i=e.getUIElement(),s=this.dce.constructor;if("@engineResourcePath/dce.ui.html"===s._defaultUIElementURL)try{i?i===t._innerSetUI&&(await e.setUIElement(`${s.engineResourcePath}dce.ui.html`),t._innerSetUI=e.getUIElement()):(await e.setUIElement(`${s.engineResourcePath}dbr.ui.html`),t._innerSetUI=e.getUIElement())}catch(t){await e.setUIElement(s.defaultUIElementURL)}else i||await e.setUIElement(s.defaultUIElementURL);this.callbackCameraChange=()=>{this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._drawResults(null),this.array_decodeFrameTimeCost.length=0,this.array_getFrameTimeCost.length=0,this._intervalGetVideoFrame=0},this.callbackResolutionChange=()=>{this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._drawResults(null),this.array_decodeFrameTimeCost.length=0,this.array_getFrameTimeCost.length=0,this._intervalGetVideoFrame=0},this.callbackCameraClose=()=>{this.stopScanning(!0),this.array_decodeFrameTimeCost.length=0,this.array_getFrameTimeCost.length=0,this._intervalGetVideoFrame=0,this._bPauseScan=!1},this.callbackSingleFrameAcquired=async e=>{this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._drawResults(null);let t=await this._decode_DCEFrame(e,{bCopyData:!1}),i=null;if(t&&t.length){const{sx:s,sy:a,width:r,height:o,_sWidth:n,_sHeight:c}=e;i=t.map((e=>({localizationResult:JSON.parse(JSON.stringify(e.localizationResult))}))),L.recalculateResultLocation(i,s,a,n,c,r,o)}if(this._drawResults(i,t),await this.clearMapDecodeRecord(),this.onImageRead&&this.dce.isOpen()&&!this._bPauseScan){let e=this._cloneDecodeResults(t);this.onImageRead(e)}if(this.onUniqueRead&&this.dce.isOpen()&&!this._bPauseScan)for(let e of t)this.onUniqueRead(e.barcodeText,this._cloneDecodeResults(e))},e.on("cameraChange",this.callbackCameraChange),e.on("resolutionChange",this.callbackResolutionChange),e.on("cameraClose",this.callbackCameraClose),e.on("singleFrameAcquired",this.callbackSingleFrameAcquired)}_logoutDCEControler(){this.dce&&this._dceControler&&(L._onLog&&L._onLog("_logoutDCEControler()"),this._dceControler.logout(this),this.dce.off("cameraChange",this.callbackCameraChange),this.dce.off("resolutionChange",this.callbackResolutionChange),this.dce.off("cameraClose",this.callbackCameraClose),this.dce.off("singleFrameAcquired",this.callbackSingleFrameAcquired),this._dceControler=null,this.dce=null)}async setImageSource(e,t){if(null==e)return this._imgSource=null,this._logoutDCEControler(),void(this._drawingItemNamespace=null);if(e&&e.isCameraEnhancer)this.dce=e,await this._registerDCEControler(),this._imgSource=null;else{if(!L.isImageSource(e))throw new Error("Invalid value.");this._logoutDCEControler(),this._imgSource=e}t&&t.resultsHighlightBaseShapes&&(this._drawingItemNamespace=t.resultsHighlightBaseShapes)}static async loadWasm(){if(this._pLoad.isEmpty){let{lt:e,l:t,ls:i,sp:s,rmk:r}=((e,t=!1)=>{const i=e;if(i._pLoad.isEmpty){let e,s,r,o=i._license||"",n=JSON.parse(JSON.stringify(i._licenseServer)),c=i._sessionPassword,d=0;if(o.startsWith("t")||o.startsWith("f"))d=0;else if(0===o.length||o.startsWith("P")||o.startsWith("L")||o.startsWith("Y")||o.startsWith("A"))d=1;else{d=2;const t=o.indexOf(":");-1!=t&&(o=o.substring(t+1));const i=o.indexOf("?");if(-1!=i&&(s=o.substring(i+1),o=o.substring(0,i)),o.startsWith("DLC2"))d=0;else{if(o.startsWith("DLS2")){let t;try{let e=o.substring(4);e=atob(e),t=JSON.parse(e)}catch(e){throw new Error("Format Error: The license string you specified is invalid, please check to make sure it is correct.")}if(o=t.handshakeCode?t.handshakeCode:t.organizationID?t.organizationID:"","number"==typeof o&&(o=JSON.stringify(o)),0===n.length){let e=[];t.mainServerURL&&(e[0]=t.mainServerURL),t.standbyServerURL&&(e[1]=t.standbyServerURL),n=S(e)}!c&&t.sessionPassword&&(c=t.sessionPassword),e=t.remark}o&&"200001"!==o&&!o.startsWith("200001-")||(d=1)}}if(d&&(t||(a.crypto||(r="Please upgrade your browser to support online key."),a.crypto.subtle||(r="Require https to use online key in this browser."))),r){if(1!==d)throw new Error(r);d=0,console.warn(r),i._lastErrorCode=-1,i._lastErrorString=r}return 1===d&&(o="",console.warn("Applying for a public trial license ...")),{lt:d,l:o,ls:n,sp:c,rmk:e,cv:s}}throw new Error("Can't preprocess license again"+m)})(L);this._pLoad.task=async(a,o)=>{let n=L.engineResourcePath+L._workerName;L.engineResourcePath.startsWith(location.origin)||(n=await fetch(n).then((e=>e.blob())).then((e=>URL.createObjectURL(e)))),L._dbrWorker=new Worker(n),URL.revokeObjectURL(n),L._dbrWorker.onerror=e=>{let t=new Error(e.message);o(t)},L._dbrWorker.onmessage=async t=>{let i=t.data?t.data:t;switch(i.type){case"log":L._onLog&&L._onLog(i.message);break;case"load":{i.message&&(i.message=i.message.replace("(https://www.dynamsoft.com/purchase-center/)","(https://www.dynamsoft.com/store/dynamsoft-barcode-reader/#javascript)"));let t,s=!1;1===e&&(s=!0,i.message||(i.message="Using a temporary license. [Register for a 30-day trial license >>>](https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&deploymenttype=browser)")),i.success?(L._dbrWorker.onerror=null,L._version=i.version+"(JS "+L._jsVersion+"."+L._jsEditVersion+")",L._onLog&&L._onLog("load dbr worker success"),i.message&&console.warn(i.message)):(t=new Error(i.message),t.stack=i.stack+"\n"+t.stack,t.ltsErrorCode=i.ltsErrorCode,s||111==i.ltsErrorCode&&-1!=i.message.toLowerCase().indexOf("trial license")&&(s=!0)),s&&L.showDialog(i.success?"warn":"error",i.message),i.success?a():o(t);break}case"task":{let e=i.id,t=i.body;try{L._taskCallbackMap.get(e)(t),L._taskCallbackMap.delete(e)}catch(t){throw L._taskCallbackMap.delete(e),t}break}default:L._onLog&&L._onLog(t)}},L._dbrWorker.postMessage({type:"loadWasm",engineResourcePath:L.engineResourcePath,bUseFullFeature:L._bUseFullFeature,bd:L._bWasmDebug,v:L._jsVersion,brtk:!!e,bptk:1===e,l:t,dm:location.origin.startsWith("http")?location.origin:"https://localhost",os:d,cv:L.authCacheVersion,fn:L.deviceFriendlyName,ls:i,sp:s,rmk:r})}}await this._pLoad}static async showDialog(e,t){await(async(e,t,i)=>{if(!e._bNeverShowDialog)try{let s=await fetch(e.engineResourcePath+"dls.license.dialog.html");if(!s.ok)throw Error("Get license dialog fail. Network Error: "+s.statusText);let a=await s.text();if(!a.trim().startsWith("<"))throw Error("Get license dialog fail. Can't get valid HTMLElement.");let r=document.createElement("div");r.innerHTML=a;let o=[];for(let e=0;e<r.childElementCount;++e){let t=r.children[e];t instanceof HTMLStyleElement&&(o.push(t),document.head.append(t))}let n=1==r.childElementCount?r.children[0]:r;n.remove();let c,d,l,h,_,u=[n],g=n.children;for(let e of g)u.push(e);for(let e=0;e<u.length;++e)for(let t of u[e].children)u.push(t);for(let e of u)if(!c&&e.classList.contains("dls-license-mask"))c=e,e.addEventListener("click",(t=>{if(e==t.target){n.remove();for(let e of o)e.remove()}}));else if(!d&&e.classList.contains("dls-license-icon-close"))d=e,e.addEventListener("click",(()=>{n.remove();for(let e of o)e.remove()}));else if(!l&&e.classList.contains("dls-license-icon-error"))l=e,"error"!=t&&e.remove();else if(!h&&e.classList.contains("dls-license-icon-warn"))h=e,"warn"!=t&&e.remove();else if(!_&&e.classList.contains("dls-license-msg-content")){_=e;let t=i;for(;t;){let i=t.indexOf("["),s=t.indexOf("]",i),a=t.indexOf("(",s),r=t.indexOf(")",a);if(-1==i||-1==s||-1==a||-1==r){e.appendChild(new Text(t));break}i>0&&e.appendChild(new Text(t.substring(0,i)));let o=document.createElement("a"),n=t.substring(i+1,s);o.innerText=n;let c=t.substring(a+1,r);o.setAttribute("href",c),o.setAttribute("target","_blank"),e.appendChild(o),t=t.substring(r+1)}}document.body.appendChild(n)}catch(t){e._onLog&&e._onLog(t.message||t)}})(this,e,t)}static async createInstanceInWorker(e=!1){return await L.loadWasm(),await new Promise(((t,i)=>{let s=L._nextTaskID++;L._taskCallbackMap.set(s,(e=>{if(e.success)return t(e.instanceID);{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}})),L._dbrWorker.postMessage({type:"createInstance",id:s,bScanner:e})}))}constructor(){this._instanceID=void 0,this._ifSaveOriginalImageInACanvas=!1,this.oriCanvas=null,this.oriCanvasData=null,this.canvas=null,this.bFilterRegionInJs=!1,this._region=null,this._timeStartDecode=null,this._timeEnterInnerDBR=null,this._timeGetMessage=null,this.decodeRecords={},this.bDestroyed=!1,this._lastErrorCode=0,this._lastErrorString="",this._lastInnerDecodeDuration=0,this.intervalTime=0,this._intervalGetVideoFrame=0,this.array_getFrameTimeCost=[],this.array_decodeFrameTimeCost=[],this._indexCurrentDecodingFrame=0,this._arrPolygons=[],this._bPauseScan=!1,this._intervalDetectVideoPause=1e3,this._soundSource="data:audio/mpeg;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjI5LjEwMAAAAAAAAAAAAAAA/+M4wAAAAAAAAAAAAEluZm8AAAAPAAAABQAAAkAAgICAgICAgICAgICAgICAgICAgKCgoKCgoKCgoKCgoKCgoKCgoKCgwMDAwMDAwMDAwMDAwMDAwMDAwMDg4ODg4ODg4ODg4ODg4ODg4ODg4P//////////////////////////AAAAAExhdmM1OC41NAAAAAAAAAAAAAAAACQEUQAAAAAAAAJAk0uXRQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/+MYxAANQAbGeUEQAAHZYZ3fASqD4P5TKBgocg+Bw/8+CAYBA4XB9/4EBAEP4nB9+UOf/6gfUCAIKyjgQ/Kf//wfswAAAwQA/+MYxAYOqrbdkZGQAMA7DJLCsQxNOij///////////+tv///3RWiZGBEhsf/FO/+LoCSFs1dFVS/g8f/4Mhv0nhqAieHleLy/+MYxAYOOrbMAY2gABf/////////////////usPJ66R0wI4boY9/8jQYg//g2SPx1M0N3Z0kVJLIs///Uw4aMyvHJJYmPBYG/+MYxAgPMALBucAQAoGgaBoFQVBUFQWDv6gZBUFQVBUGgaBr5YSgqCoKhIGg7+IQVBUFQVBoGga//SsFSoKnf/iVTEFNRTMu/+MYxAYAAANIAAAAADEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",this.bPlaySoundOnSuccessfulRead=!1,this.bVibrateOnSuccessfulRead=!1,this.vibrateDuration=300,this.captureAndDecodeInParallel=!0,this.autoSuggestTip=!1,this.suggestTipFrameArray=[],this.suggestTipFrameLimit=[5,3],this.noIntermediateResultsCount=0,this.noIntermediateResultsTipLimit=100,this.tinyBarcodeTipModuleSizeLimit=3,this.hugeBarcodeTipLimit=.9,this.autoZoomInFrameArray=[],this.autoZoomInFrameLimit=[5,3],this.autoZoomInStepRate=1/3,this.autoZoomInMaxStep=1.5,this.autoZoomInMaxTimes=5,this.autoZoomInMinStep=Math.pow(10,1/this.autoZoomInMaxTimes),this.autoZoomInIdealModuleSize=6,this.autoZoomOutFrameCount=0,this.autoZoomOutFrameLimit=3,this.autoZoomOutStepRate=1/3,this.autoZoomOutMinValue=1,this.autoZoomOutMinStep=2,this.autoZoomOutStepRate_2=.05,this.autoZoomOutMinValue_2=2,this.frameArrayInIdealZoom=[],this.frameLimitInIdealZoom=[5,3],this.enableZoomOutInIdealZoom=!1,this.nextActionInIdealZoom="focus",this.autoFocusFrameArray=[],this.autoFocusFrameLimit=[5,3],this.autoZoomIdealArea=[0,.05],this.autoZoomTargetBorder=.9,this.autoZoomDetectionArea=.5,this.autoZoom=!1,this.autoFocus=!1,this._resultHighlightingDuration=-1,this._dce=null,this._imgSource=null,this._maxCvsSideLength=p,this._promiseStartScan=null,this.beepSound=new e({src:[this._soundSource],onplayerror:(e,t)=>{console.warn(`Sound '${e}' playback failure: ${t}`)}})}static async createInstance(){const e=new L;return e._instanceID=await L.createInstanceInWorker(),L._fireHTTPSWarnning(),e}async clearMapDecodeRecord(){return await new Promise(((e,t)=>{let i=L._nextTaskID++;L._taskCallbackMap.set(i,(i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}})),L._dbrWorker.postMessage({type:"clearMapDecodeRecord",id:i,instanceID:this._instanceID})}))}async decode(e){L._onLog&&L._onLog("decode(source: any)"),L._onLog&&(this._timeStartDecode=Date.now());let t={};return!this.region||this.region instanceof Array||(t.region=JSON.parse(JSON.stringify(this.region))),e instanceof Blob?await this._decode_Blob(e,t):e instanceof ArrayBuffer?await this._decode_ArrayBuffer(e,t):e instanceof Uint8Array||e instanceof Uint8ClampedArray?await this._decode_Uint8Array(e,t):e instanceof HTMLImageElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?await this._decode_Image(e,t):e instanceof HTMLCanvasElement?await this._decode_Canvas(e,t):e instanceof HTMLVideoElement?await this._decode_Video(e,t):"string"==typeof e?"data:image/"==e.substring(0,11)?await this._decode_Base64(e,t):await this._decode_Url(e,t):L.isDCEFrame(e)?(t.bCopyData=!0,await this._decode_DCEFrame(e,t)):L.isDSImage(e)?(t.bCopyData=!0,await this._decode_DSImage(e,t)):await Promise.reject(TypeError("'_decode(source, config)': Type of 'source' should be 'Blob', 'ArrayBuffer', 'Uint8Array', 'HTMLImageElement', 'HTMLCanvasElement', 'HTMLVideoElement', 'String(base64 with image mime)' or 'String(url)'."))}async decodeBase64String(e){let t={};return!this.region||this.region instanceof Array||(t.region=JSON.parse(JSON.stringify(this.region))),this._decode_Base64(e,t)}async decodeUrl(e){let t={};return!this.region||this.region instanceof Array||(t.region=JSON.parse(JSON.stringify(this.region))),this._decode_Url(e,t)}async _decodeBuffer_Uint8Array(e,t,i,s,a,r,o){return await new Promise(((n,c)=>{let d=L._nextTaskID++;L._taskCallbackMap.set(d,(e=>{if(e.success){let t,i=L._onLog?Date.now():0;L._onLog&&L._onLog("worker return result: "+i),this._lastInnerDecodeDuration=e.duration;try{t=this._handleRetJsonString(e.decodeReturn)}catch(e){return c(e)}if(L._onLog){let e=Date.now();L._onLog("DBR getting message from worker timestamp: "+i),L._onLog("From DBR staring decoding to entering worker costs: "+(this._timeEnterInnerDBR-this._timeStartDecode)),L._onLog("From DBR entering worker to returning message from worker costs: "+(i-this._timeEnterInnerDBR)),L._onLog("Handling results from DBR worker costs: "+(e-i)),L._onLog("Total decoding image costs: "+(e-this._timeStartDecode))}return n(t)}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,c(t)}})),this._timeEnterInnerDBR=Date.now(),L._onLog&&L._onLog("Sending buffer to worker timestamp:"+this._timeEnterInnerDBR),L._dbrWorker.postMessage({type:"decodeBuffer",id:d,instanceID:this._instanceID,body:{buffer:e,width:t,height:i,stride:s,format:a,orientation:r,config:o}},[e.buffer]),L._onLog&&o&&o.timeStamp&&L._onLog("Delay of decoding image: "+(this._timeEnterInnerDBR-o.timeStamp))}))}async _decodeBuffer_Blob(e,t,i,s,a,r,o){L._onLog&&L._onLog("_decodeBuffer_Blob(buffer,width,height,stride,format)");const n=e.arrayBuffer?await e.arrayBuffer():await new Promise(((t,i)=>{let s=new FileReader;s.readAsArrayBuffer(e),s.onload=()=>{t(s.result)},s.onerror=()=>{i(s.error)}}));return await this._decodeBuffer_Uint8Array(new Uint8Array(n),t,i,s,a,r,o)}async decodeBuffer(e,t,i,s,a,r,o){let n;return L._onLog&&L._onLog("decodeBuffer(buffer,width,height,stride,format)"),L._onLog&&(this._timeStartDecode=Date.now()),e instanceof Uint8Array||e instanceof Uint8ClampedArray?n=await this._decodeBuffer_Uint8Array(e,t,i,s,a,r,o):e instanceof ArrayBuffer?n=await this._decodeBuffer_Uint8Array(new Uint8Array(e),t,i,s,a,r,o):e instanceof Blob&&(n=await this._decodeBuffer_Blob(e,t,i,s,a,r,o)),n}async _decodeFileInMemory_Uint8Array(e){return await new Promise(((t,i)=>{let s=L._nextTaskID++;L._taskCallbackMap.set(s,(e=>{if(e.success){let s;this._lastInnerDecodeDuration=e.duration;try{s=this._handleRetJsonString(e.decodeReturn)}catch(e){return i(e)}return t(s)}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}})),L._dbrWorker.postMessage({type:"decodeFileInMemory",id:s,instanceID:this._instanceID,body:{bytes:e}})}))}async getRuntimeSettings(){return await new Promise(((e,t)=>{let i=L._nextTaskID++;L._taskCallbackMap.set(i,(i=>{if(i.success){let t=JSON.parse(i.results);return null!=this.userDefinedRegion&&(t.region=JSON.parse(JSON.stringify(this.userDefinedRegion))),e(t)}{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}})),L._dbrWorker.postMessage({type:"getRuntimeSettings",id:i,instanceID:this._instanceID})}))}async updateRuntimeSettings(e){let t;if("string"==typeof e)if("speed"==e){let e=await this.getRuntimeSettings();await this.resetRuntimeSettings(),t=await this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,t.region=e.region,t.deblurLevel=3,t.expectedBarcodesCount=0,t.localizationModes=[2,0,0,0,0,0,0,0]}else if("balance"==e){let e=await this.getRuntimeSettings();await this.resetRuntimeSettings(),t=await this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,t.region=e.region,t.deblurLevel=5,t.expectedBarcodesCount=512,t.localizationModes=[2,16,0,0,0,0,0,0]}else if("coverage"==e){let e=await this.getRuntimeSettings();await this.resetRuntimeSettings(),t=await this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,t.region=e.region}else if("dense"==e){let e=await this.getRuntimeSettings();await this.resetRuntimeSettings(),this.maxCvsSideLength=4096,t=await this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,t.region=e.region,t.deblurLevel=9,t.expectedBarcodesCount=0,t.localizationModes=[2,8,0,0,0,0,0,0]}else if("distance"==e){let e=await this.getRuntimeSettings();await this.resetRuntimeSettings(),this.maxCvsSideLength=4096,t=await this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,t.region=e.region,t.deblurLevel=3,t.expectedBarcodesCount=0,t.localizationModes=[2,8,0,0,0,0,0,0]}else t=JSON.parse(e);else{if("object"!=typeof e)throw TypeError("'UpdateRuntimeSettings(settings)': Type of 'settings' should be 'string' or 'PlainObject'.");if(t=JSON.parse(JSON.stringify(e)),t.region instanceof Array){let e=t.region;[e.regionLeft,e.regionTop,e.regionLeft,e.regionBottom,e.regionMeasuredByPercentage].some((e=>void 0!==e))&&(t.region={regionLeft:e.regionLeft||0,regionTop:e.regionTop||0,regionRight:e.regionRight||0,regionBottom:e.regionBottom||0,regionMeasuredByPercentage:e.regionMeasuredByPercentage||0})}}if(!L._bUseFullFeature){if(t.barcodeFormatIds&~(T.BF_ONED|T.BF_QR_CODE|T.BF_PDF417|T.BF_DATAMATRIX)||0!=t.barcodeFormatIds_2)throw Error("Some of the specified barcode formats are not supported in the compact version. Please try the full-featured version.");if(0!=t.intermediateResultTypes)throw Error("Intermediate results is not supported in the compact version. Please try the full-featured version.")}if(this.bFilterRegionInJs){let e=t.region;if(e instanceof Array)throw Error("The `region` of type `Array` is only allowed in `BarcodeScanner`.");this.userDefinedRegion=JSON.parse(JSON.stringify(e)),(e.regionLeft||e.regionTop||e.regionRight||e.regionBottom||e.regionMeasuredByPercentage)&&(e.regionLeft||e.regionTop||100!=e.regionRight||100!=e.regionBottom||!e.regionMeasuredByPercentage)?this.region=e:this.region=null,t.region={regionLeft:0,regionTop:0,regionRight:0,regionBottom:0,regionMeasuredByPercentage:0}}else this.userDefinedRegion=null,this.region=null;return(this.autoZoom||this.autoFocus)&&(t.intermediateResultTypes|=D.IRT_TYPED_BARCODE_ZONE),await new Promise(((e,i)=>{let s=L._nextTaskID++;L._taskCallbackMap.set(s,(t=>{if(t.success){try{this._handleRetJsonString(t.updateReturn)}catch(e){i(e)}return e()}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}})),L._dbrWorker.postMessage({type:"updateRuntimeSettings",id:s,instanceID:this._instanceID,body:{settings:JSON.stringify(t)}})}))}async resetRuntimeSettings(){return this.userDefinedRegion=null,this.region=null,this.maxCvsSideLength=p,await new Promise(((e,t)=>{let i=L._nextTaskID++;L._taskCallbackMap.set(i,(i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}})),L._dbrWorker.postMessage({type:"resetRuntimeSettings",id:i,instanceID:this._instanceID})}))}async _resetRuntimeSettingsToCppDefault(){return this.userDefinedRegion=null,this.region=null,this.maxCvsSideLength=p,await new Promise(((e,t)=>{let i=L._nextTaskID++;L._taskCallbackMap.set(i,(i=>{if(i.success)return e();{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}})),L._dbrWorker.postMessage({type:"resetRuntimeSettingsToCppDefault",id:i,instanceID:this._instanceID})}))}async outputRuntimeSettingsToString(){if(!L._bUseFullFeature)throw Error("outputRuntimeSettingsToString() is not supported in the compact version. Please try the full-featured version.");return await new Promise(((e,t)=>{let i=L._nextTaskID++;L._taskCallbackMap.set(i,(i=>{if(i.success)return e(i.results);{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}})),L._dbrWorker.postMessage({type:"outputRuntimeSettingsToString",id:i,instanceID:this._instanceID})}))}async initRuntimeSettingsWithString(e){if(!L._bUseFullFeature)throw Error("initRuntimeSettingsWithString() is not supported in the compact version. Please try the full-featured version.");if("string"==typeof e);else{if("object"!=typeof e)throw TypeError("'initRuntimeSettingstWithString(settings)': Type of 'settings' should be 'string' or 'PlainObject'.");e=JSON.stringify(e)}return await new Promise(((t,i)=>{let s=L._nextTaskID++;L._taskCallbackMap.set(s,(e=>{if(e.success){try{this._handleRetJsonString(e.initReturn)}catch(e){i(e)}return t()}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,i(t)}})),L._dbrWorker.postMessage({type:"initRuntimeSettingsWithString",id:s,instanceID:this._instanceID,body:{settings:e}})}))}async _decode_Blob(e,t){L._onLog&&L._onLog("_decode_Blob(blob: Blob)");let i=null,s=null;if("undefined"!=typeof createImageBitmap)try{i=await createImageBitmap(e)}catch(e){}i||(s=await function(e){return new Promise(((t,i)=>{let s=URL.createObjectURL(e),a=new Image;a.src=s,a.onload=()=>{URL.revokeObjectURL(a.src),t(a)},a.onerror=e=>{i(new Error("Can't convert blob to image : "+(e instanceof Event?e.type:e)))}}))}(e));let a=await this._decode_Image(i||s,t);return i&&i.close(),a}async _decode_ArrayBuffer(e,t){return await this._decode_Blob(new Blob([e]),t)}async _decode_Uint8Array(e,t){return await this._decode_Blob(new Blob([e]),t)}async _decode_Image(e,t){L._onLog&&L._onLog("_decode_Image(image: HTMLImageElement|ImageBitmap)"),t=t||{};let i,s,a=e instanceof HTMLImageElement?e.naturalWidth:e.width,r=e instanceof HTMLImageElement?e.naturalHeight:e.height,o=Math.max(a,r);if(o>this._maxCvsSideLength){let e=this._maxCvsSideLength/o;i=Math.round(a*e),s=Math.round(r*e)}else i=a,s=r;this.canvas||(this.canvas=document.createElement("canvas"));const n=this.canvas;n.width===i&&n.height===s||(n.width=i,n.height=s),n.ctx2d||(n.ctx2d=n.getContext("2d",{willReadFrequently:!0}));n.ctx2d.drawImage(e,0,0,a,r,0,0,i,s);let c=await this._decode_Canvas(n,t);if(this.ifSaveOriginalImageInACanvas){const t=document.createElement("canvas");t.width=e.width,t.height=e.height;t.getContext("2d").drawImage(e,0,0),this.oriCanvas=t,this.oriCanvasData=null}return L.recalculateResultLocation(c,0,0,a,r,i,s),c}async _decode_Canvas(e,t){if(L._onLog&&L._onLog("_decode_Canvas(canvas:HTMLCanvasElement)"),e.crossOrigin&&"anonymous"!=e.crossOrigin)throw"cors";if(0===e.width||0===e.height)throw Error("The width or height of the 'canvas' is 0.");this.ifSaveOriginalImageInACanvas&&(this.oriCanvas=e,this.oriCanvasData=null);let i=(e.ctx2d||e.getContext("2d",{willReadFrequently:!0})).getImageData(0,0,e.width,e.height).data;return await this._decodeBuffer_Uint8Array(i,e.width,e.height,4*e.width,E.IPF_ABGR_8888,0,t)}async _decode_Video(e,t){if(L._onLog&&L._onLog("_decode_Video(video)"),!(e instanceof HTMLVideoElement))throw TypeError("'_decode_Video(video [, config] )': Type of 'video' should be 'HTMLVideoElement'.");if(e.crossOrigin&&"anonymous"!=e.crossOrigin)throw"cors";t=t||{};let i,s,a=e.videoWidth,r=e.videoHeight,o=Math.max(a,r);if(o>this._maxCvsSideLength){let e=this._maxCvsSideLength/o;i=Math.round(a*e),s=Math.round(r*e)}else i=a,s=r;this.canvas||(this.canvas=document.createElement("canvas"));const n=this.canvas;n.width===i&&n.height===s||(n.width=i,n.height=s),n.ctx2d||(n.ctx2d=n.getContext("2d",{willReadFrequently:!0}));n.ctx2d.drawImage(e,0,0,a,r,0,0,i,s);let c=await this._decode_Canvas(n,t);if(this.ifSaveOriginalImageInACanvas){const t=document.createElement("canvas");t.width=e.videoWidth,t.height=e.videoHeight;t.getContext("2d").drawImage(e,0,0),this.oriCanvas=t,this.oriCanvasData=null}return L.recalculateResultLocation(c,0,0,a,r,i,s),c}async _decode_DCEFrame(e,t){if(L._onLog&&L._onLog("_decode_DCEFrame(dceFrame)"),!L.isDCEFrame(e))return[];let i=[];this.ifSaveOriginalImageInACanvas&&(this.oriCanvas=null,this.oriCanvasData={width:e.width,height:e.height,colorMode:e.colorMode,pixelFormat:e.pixelFormat,data:new Uint8Array(e.data),toCanvas:e.toCanvas});const{width:s,height:a,colorMode:r,pixelFormat:o,stride:n,timeStamp:c}=e;let d;d=t&&t.bCopyData?new Uint8Array(e.data):e.data;let l=null;if(t?(l=JSON.parse(JSON.stringify(t)),l.timeStamp=c):l={timeStamp:c},o&&n)if("grey"===o)i=await this._decodeBuffer_Uint8Array(d,s,a,n,E.IPF_GrayScaled,0,l);else if("rgba"===o)i=await this._decodeBuffer_Uint8Array(d,s,a,n,E.IPF_ABGR_8888,0,l);else{if("bgra"!==o)throw new Error(`Pixel format '${o}' is not supported to decode.`);i=await this._decodeBuffer_Uint8Array(d,s,a,n,E.IPF_ARGB_8888,0,l)}else if("grey"===r)i=await this._decodeBuffer_Uint8Array(d,s,a,s,E.IPF_GrayScaled,0,l);else if("rgba"===r)i=await this._decodeBuffer_Uint8Array(d,s,a,4*s,E.IPF_ABGR_8888,0,l);else{if("bgra"!==r)throw new Error(`Color mode '${r}' is not supported to decode.`);i=await this._decodeBuffer_Uint8Array(d,s,a,4*s,E.IPF_ARGB_8888,0,l)}return i}async _decode_DSImage(e,t){if(L._onLog&&L._onLog("_decode_DSImage(dsImage)"),!L.isDSImage(e))return null;this.ifSaveOriginalImageInACanvas&&(this.oriCanvas=null,this.oriCanvasData={width:e.width,height:e.height,pixelFormat:e.pixelFormat.toLowerCase(),data:new Uint8Array(e.data),toCanvas:function(){const e=document.createElement("canvas");let t;switch(e.width=this.width,e.height=this.height,this.pixelFormat){case"grey":t=new Uint8ClampedArray(this.width*this.height*4);for(let e=0;e<t.length;e+=4)t[e]=this.data[e/4],t[e+1]=this.data[e/4],t[e+2]=this.data[e/4],t[e+3]=255;break;case"rgb":t=new Uint8ClampedArray(this.width*this.height*4);for(let e=0;e<t.length;e+=4)t[e]=this.data[e],t[e+1]=this.data[e+1],t[e+2]=this.data[e+2],t[e+3]=255;break;case"bgr":t=new Uint8ClampedArray(this.width*this.height*4);for(let e=0;e<t.length;e+=4)t[e]=this.data[e],t[e+1]=this.data[e+1],t[e+2]=this.data[e+2],t[e+3]=255;break;case"rgba":case"bgra":t=new Uint8ClampedArray(this.data);break;default:throw new Error("The content of 2D Canvas is currently limited to the sRGB color space.")}const i=new ImageData(t,this.width,this.height);return e.getContext("2d").putImageData(i,0,0),e}});const{width:i,height:s}=e;let a,r,o,n=e.pixelFormat.toLowerCase();switch(a=t&&t.bCopyData?new Uint8Array(e.data):e.data,n){case"grey":o=E.IPF_GrayScaled,r=i;break;case"rgb":o=E.IPF_BGR_888,r=3*i;break;case"bgr":o=E.IPF_RGB_888,r=3*i;break;case"rgba":o=E.IPF_ABGR_8888,r=4*i;break;case"bgra":o=E.IPF_ARGB_8888,r=4*i;break;default:throw new Error("The pixel format is not supported to decode.")}return await this._decodeBuffer_Uint8Array(a,i,s,r,o,0,t)}async _decode_Base64(e,t){if(L._onLog&&L._onLog("_decode_Base64(base64Str)"),"string"!=typeof e)return Promise.reject("'_decode_Base64(base64Str, config)': Type of 'base64Str' should be 'string'.");"data:image/"==e.substring(0,11)&&(e=e.substring(e.indexOf(",")+1));let i=atob(e),s=i.length,a=new Uint8Array(s);for(;s--;)a[s]=i.charCodeAt(s);return await this._decode_Blob(new Blob([a]),t)}async _decode_Url(e,t){if(L._onLog&&L._onLog("_decode_Url(url)"),"string"!=typeof e)throw TypeError("'_decode_Url(url, config)': Type of 'url' should be 'string'.");let i=await new Promise(((t,i)=>{let s=new XMLHttpRequest;s.open("GET",e,!0),s.responseType="blob",s.send(),s.onloadend=async()=>{t(s.response)},s.onerror=()=>{i(new Error("Network Error: "+s.statusText))}}));return await this._decode_Blob(i,t)}static recalculateResultLocation(e,t,i,s,a,r,o){if(e.length>0)for(let n of e){let e=n.localizationResult;2==e.resultCoordinateType&&(e.x1*=.01*r,e.x2*=.01*r,e.x3*=.01*r,e.x4*=.01*r,e.y1*=.01*o,e.y2*=.01*o,e.y3*=.01*o,e.y4*=.01*o);let c=r/s,d=o/a;e.x1=e.x1/c+t,e.x2=e.x2/c+t,e.x3=e.x3/c+t,e.x4=e.x4/c+t,e.y1=e.y1/d+i,e.y2=e.y2/d+i,e.y3=e.y3/d+i,e.y4=e.y4/d+i,2==e.resultCoordinateType&&(e.x1*=100/s,e.x2*=100/s,e.x3*=100/s,e.x4*=100/s,e.y1*=100/a,e.y2*=100/a,e.y3*=100/a,e.y4*=100/a),e.x1=Math.round(e.x1),e.x2=Math.round(e.x2),e.x3=Math.round(e.x3),e.x4=Math.round(e.x4),e.y1=Math.round(e.y1),e.y2=Math.round(e.y2),e.y3=Math.round(e.y3),e.y4=Math.round(e.y4)}}static BarcodeReaderException(e,t){let i,s=A.DBR_UNKNOWN;return"number"==typeof e?(s=e,i=new Error(t)):i=new Error(e),i.code=s,i}_handleRetJsonString(e){let t=A;if(e.textResults){for(let t=0;t<e.textResults.length;t++){let i=e.textResults[t];try{let e=i.barcodeText,t="";for(let i=0;i<e.length;i++)t+=String.fromCharCode(e[i]);try{i.barcodeText=decodeURIComponent(escape(t))}catch(e){i.barcodeText=t}}catch(e){i.barcodeText=""}if(null!=i.exception){L._setWarnnedEx.has(i.exception)||(L._setWarnnedEx.add(i.exception),console.warn(i.exception));let e={};i.exception.split(";").forEach((t=>{let i=t.indexOf(":");e[t.substring(0,i)]=t.substring(i+1)})),i.exception=e}}return e.decodeRecords?this.decodeRecords=e.decodeRecords:this.decodeRecords={},this._lastErrorCode=e.exception,this._lastErrorString=e.description,e.exception&&!L._setWarnnedEx.has(e.description)&&(L._setWarnnedEx.add(e.description),console.warn(e.description)),e.textResults}if(e.exception==t.DBR_SUCCESS)return e.data;throw L.BarcodeReaderException(e.exception,e.description)}async setModeArgument(e,t,i,s){return await new Promise(((a,r)=>{let o=L._nextTaskID++;L._taskCallbackMap.set(o,(e=>{if(e.success){try{this._handleRetJsonString(e.setReturn)}catch(e){return r(e)}return a()}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,r(t)}})),L._dbrWorker.postMessage({type:"setModeArgument",id:o,instanceID:this._instanceID,body:{modeName:e,index:t,argumentName:i,argumentValue:s}})}))}async getModeArgument(e,t,i){return await new Promise(((s,a)=>{let r=L._nextTaskID++;L._taskCallbackMap.set(r,(e=>{if(e.success){let t;try{t=this._handleRetJsonString(e.getReturn)}catch(e){return a(e)}return s(t)}{let t=new Error(e.message);return t.stack=e.stack+"\n"+t.stack,a(t)}})),L._dbrWorker.postMessage({type:"getModeArgument",id:r,instanceID:this._instanceID,body:{modeName:e,index:t,argumentName:i}})}))}async getIntermediateResults(){return await new Promise(((e,t)=>{let i=L._nextTaskID++;L._taskCallbackMap.set(i,(i=>{if(i.success)return e(i.results);{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}})),L._dbrWorker.postMessage({type:"getIntermediateResults",id:i,instanceID:this._instanceID,body:{isCharge:!0}})}))}async getIntermediateCanvas(){let e=await this.getIntermediateResults(),t=[];for(let i of e)if(i.dataType==f.IMRDT_IMAGE)for(let e of i.results){const i=e.bytes;let s;switch(L._onLog&&L._onLog(" "+i.length+" "+i.byteLength+" "+e.width+" "+e.height+" "+e.stride+" "+e.format),e.format){case E.IPF_ABGR_8888:s=new Uint8ClampedArray(i);break;case E.IPF_RGB_888:{const e=i.length/3;s=new Uint8ClampedArray(4*e);for(let t=0;t<e;++t)s[4*t]=i[3*t+2],s[4*t+1]=i[3*t+1],s[4*t+2]=i[3*t],s[4*t+3]=255;break}case E.IPF_GrayScaled:{const e=i.length;s=new Uint8ClampedArray(4*e);for(let t=0;t<e;t++)s[4*t]=s[4*t+1]=s[4*t+2]=i[t],s[4*t+3]=255;break}case E.IPF_Binary:case E.IPF_BinaryInverted:{const t=i.length,a=e.width,r=e.height,o=e.stride;s=new Uint8ClampedArray(a*r*4);for(let e=0;e<t;e++){let t=i[e],r=e%o*8,n=Math.floor(e/o);for(let e=0;e<8;e++){let i=r+e,o=4*(n*a+i);if(i>=a)break;s[o]=s[o+1]=s[o+2]=(128&t)/128*255,s[o+3]=255,t<<=1}}break}default:console.warn("unknow intermediate image",e)}if(!s)continue;let a=new ImageData(s,e.width,e.height),r=document.createElement("canvas");r.width=e.width,r.height=e.height,r.getContext("2d").putImageData(a,0,0),t.push(r)}return t}async getScanSettings(){return await new Promise(((e,t)=>{let i=L._nextTaskID++;L._taskCallbackMap.set(i,(i=>{if(i.success){let t=i.results;return t.intervalTime=this.intervalTime,t.whenToPlaySoundforSuccessfulRead=this.whenToPlaySoundforSuccessfulRead,t.soundOnSuccessfullRead=this.soundSource,t.whenToVibrateforSuccessfulRead=this.whenToVibrateforSuccessfulRead,t.vibrateDuration=this.vibrateDuration,t.captureAndDecodeInParallel=this.captureAndDecodeInParallel,t.autoZoom=this.autoZoom,t.autoFocus=this.autoFocus,t.autoSuggestTip=this.autoSuggestTip,e(t)}{let e=new Error(i.message);return e.stack+="\n"+i.stack,t(e)}})),L._dbrWorker.postMessage({type:"getScanSettings",id:i,instanceID:this._instanceID})}))}async updateScanSettings(e){if(!e)return;const t=JSON.parse(JSON.stringify(e));if(t.autoZoom||t.autoFocus||t.autoSuggestTip){if(!L._bUseFullFeature)throw new Error("'autoZoom', 'autoFocus' and 'autoSuggestTip' are not supported in the compact version. Please try the full-featured version.");const e=await this.getRuntimeSettings();e.intermediateResultTypes|=D.IRT_TYPED_BARCODE_ZONE,await this.updateRuntimeSettings(e)}return t.hasOwnProperty("intervalTime")&&(this.intervalTime=Math.max(t.intervalTime,0),delete t.intervalTime),t.hasOwnProperty("whenToPlaySoundforSuccessfulRead")&&(this.whenToPlaySoundforSuccessfulRead=t.whenToPlaySoundforSuccessfulRead,delete t.whenToPlaySoundforSuccessfulRead),t.hasOwnProperty("soundOnSuccessfullRead")&&(this.soundSource=t.soundOnSuccessfullRead,delete t.soundOnSuccessfullRead),t.hasOwnProperty("whenToVibrateforSuccessfulRead")&&(this.whenToVibrateforSuccessfulRead=t.whenToVibrateforSuccessfulRead,delete t.whenToVibrateforSuccessfulRead),t.hasOwnProperty("vibrateDuration")&&(this.vibrateDuration=t.vibrateDuration,delete t.vibrateDuration),t.hasOwnProperty("captureAndDecodeInParallel")&&(this.captureAndDecodeInParallel=t.captureAndDecodeInParallel,delete t.captureAndDecodeInParallel),t.hasOwnProperty("autoZoom")&&(this.autoZoom&&this.autoZoom!=t.autoZoom&&this.dce&&this.dce.setZoom({factor:1}).catch((()=>{})),this.autoZoom=t.autoZoom,delete t.autoZoom),t.hasOwnProperty("autoFocus")&&(this.autoFocus=t.autoFocus,this.dce&&this.dce.setFocus({mode:"continuous"}).catch((()=>{})),delete t.autoFocus),t.hasOwnProperty("autoSuggestTip")&&(this.autoSuggestTip=t.autoSuggestTip,delete t.autoFocus),await new Promise(((e,i)=>{let s=L._nextTaskID++;L._taskCallbackMap.set(s,(t=>{if(t.success)return e();{let e=new Error(t.message);return e.stack+="\n"+t.stack,i(e)}})),L._dbrWorker.postMessage({type:"updateScanSettings",id:s,instanceID:this._instanceID,body:{settings:t}})}))}_cloneDecodeResults(e){if(e instanceof Array){let t=[];for(let i of e)t.push(this._cloneDecodeResults(i));return t}{let t=e;return JSON.parse(JSON.stringify(t,((e,t)=>"oriVideoCanvas"==e||"searchRegionCanvas"==e?void 0:t)))}}async _loopReadVideo(){if(this.bDestroyed)return this.dce&&this._dceControler&&this._dceControler.setDisiredAction(this,"stopFetchingLoop"),this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),void this._drawResults(null);if(this.dce&&!this.dce.isOpen())return this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._drawResults(null),void await this.clearMapDecodeRecord();if(!this.dce&&!this._imgSource||this._bPauseScan)return L._onLog&&L._onLog("Scan is paused, or imageSource is not set. Ask in 1s."),await this.clearMapDecodeRecord(),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),void(this._loopReadVideoTimeoutId=setTimeout((()=>{this._loopReadVideo()}),this._intervalDetectVideoPause));L._onLog&&L._onLog("======= once read ======="),L._onLog&&(this._timeStartDecode=Date.now());let e=null,t=null;if(this.dce)e=this._getVideoFrame();else if(this._imgSource&&(t=await this._imgSource.getImage(),!L.isDSImage(t)))throw new Error("Invalid DSImage.");if(!e&&!t)return L._onLog&&L._onLog("Get invalid frame."),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),void(this._loopReadVideoTimeoutId=setTimeout((()=>{this._loopReadVideo()}),0));(async()=>{let i=[];if(e){i=await this._decode_DCEFrame(e,{bScanner:!0,bCopyData:!1});let t=null;if(i&&i.length){const{sx:s,sy:a,width:r,height:o,_sWidth:n,_sHeight:c}=e;t=i.map((e=>({resultState:e.resultState,localizationResult:JSON.parse(JSON.stringify(e.localizationResult))}))),L.recalculateResultLocation(t,s,a,n,c,r,o)}0==this._resultHighlightingDuration?this._drawResults(null):this._drawResults(t,i),this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._resultHighlightingDuration>0&&(this._clearResultsCanvasTimeoutId=setTimeout((()=>{this.bDestroyed||this._drawResults(null)}),this._resultHighlightingDuration))}else t&&(i=await this._decode_DSImage(t,{bScanner:!0,bCopyData:!1}));return i})().then((e=>{if(L._onLog&&L._onLog(e),this.dce&&this.captureAndDecodeInParallel){let e=this.array_decodeFrameTimeCost,t=this.array_getFrameTimeCost;const i=()=>{let i=0;if(t&&t.length){let s=Math.min(...e),a=Math.max(...t);s&&a&&(i=s-a)}else i=0;return i>0?i:0};(()=>{for(;e.length>=5;)e.shift();e.push(this._lastInnerDecodeDuration)})(),this._intervalGetVideoFrame=i()+this.intervalTime}if((this.dce&&this.dce.isOpen()||this._imgSource)&&!this._bPauseScan){if(this.bPlaySoundOnSuccessfulRead&&e.length){let t=!1;!0===this.bPlaySoundOnSuccessfulRead||"frame"===this.bPlaySoundOnSuccessfulRead?t=e.some((e=>e.resultState>=0)):"unique"===this.bPlaySoundOnSuccessfulRead&&(t=e.some((e=>0==e.resultState))),t&&this.beepSound&&(this.beepSound.stop(),this.beepSound.play())}if(navigator.vibrate&&this.bVibrateOnSuccessfulRead&&e.length){let t=!1;if(!0===this.bVibrateOnSuccessfulRead||"frame"===this.bVibrateOnSuccessfulRead?t=e.some((e=>e.resultState>=0)):"unique"===this.bVibrateOnSuccessfulRead&&(t=e.some((e=>0==e.resultState))),t)try{navigator.vibrate(this.vibrateDuration)}catch(e){console.warn("Vibration not allowed. User interaction required: "+(e.message||e))}}if(this.onImageRead){e=e.filter((e=>e.resultState>=0));const t=this._cloneDecodeResults(e);this.onImageRead(t)}if(this.onUniqueRead){e=e.filter((e=>0==e.resultState));const t=this._cloneDecodeResults(e);for(let e of t)this.onUniqueRead(e.barcodeText,e)}}this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this.intervalTime?this._loopReadVideoTimeoutId=setTimeout((()=>{this._loopReadVideo()}),this.intervalTime):this._loopReadVideo()})).catch((e=>{this.dce&&this._dceControler&&this._dceControler.setDisiredAction(this,"stopFetchingLoop"),L._onLog&&L._onLog(e.message||e),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout((()=>{this.dce&&(this.dce.startFetchingLoop(),this._dceControler&&this._dceControler.clearUserDisiredAction({user:this,actionName:"stopFetchingLoop"})),this._loopReadVideo()}),Math.max(this.intervalTime,1e3)),"platform error"==e.message||console.warn(e.message)}))}_getVideoFrame(){if(!this.dce)return null;let e;if(this.captureAndDecodeInParallel){if(L._onLog&&L._onLog("Get frame in parallel."),this._dceControler&&this._dceControler.setDisiredValue(this,"loopInterval",this._intervalGetVideoFrame),!this.dce.numberOfFramesInBuffer)return this._dceControler&&this._dceControler.setDisiredValue(this,"loopInterval",0),null;e=this.dce.getFrameFromBuffer();const t=e=>{if(!e)return;let t=e.timeSpent,i=this.array_getFrameTimeCost;for(;i.length>=5;)i.shift();i.push(t)};t(e)}else L._onLog&&L._onLog("Get frame in serial."),this._dceControler&&this._dceControler.setDisiredAction(this,"stopFetchingLoop"),e=this.dce.getFrame();return e}_drawResults(e,t){if(!this.dce||this.dce.disposed||this._bPauseScan||!this._drawingItemNamespace||!this._drawingItemNamespace.DT_Polygon)return;if(!this._dbrDrawingLayer){if(!this.dce.isOpen())return;if(!(this.dce.singleFrameMode||this.dce.video&&this.dce._videoTrack))return;const t=e=>this.dce.getDrawingLayers().some((t=>t.getId()===e));if(!t(3)&&!(null==e?void 0:e.length))return;this._dbrDrawingLayer=this.dce.getDrawingLayer(3)}const i=this._dbrDrawingLayer;e||(e=[]);let s=this._arrPolygons;for(let a=0;a<e.length;a++){let r,o=e[a].localizationResult;s[a]?(r=s[a],i.hasDrawingItem(r)||i.addDrawingItem(r),r.set("vertices",[{x:o.x1,y:o.y1},{x:o.x2,y:o.y2},{x:o.x3,y:o.y3},{x:o.x4,y:o.y4}]),(r.set||r.setAttribute).call(r,"vertices",[{x:o.x1,y:o.y1},{x:o.x2,y:o.y2},{x:o.x3,y:o.y3},{x:o.x4,y:o.y4}])):(r=new this._drawingItemNamespace.DT_Polygon([{x:o.x1,y:o.y1},{x:o.x2,y:o.y2},{x:o.x3,y:o.y3},{x:o.x4,y:o.y4}]),i.addDrawingItem(r),s[a]=r),-1===e[a].resultState?(r.styleId=this._styleIdBeforeVerification,r._mapStyle.set("default",this.dce.getDrawingStyle(this._styleIdBeforeVerification)),r._mapStyle.set("selected",this.dce.getDrawingStyle(this._styleIdBeforeVerification))):(r.styleId=null,r._mapStyle.set("default",this.dce.getDrawingStyle(3)),r._mapStyle.set("selected",this.dce.getDrawingStyle(7))),t&&t[a]?r.addNote({name:"Barcode_Result",content:t[a]},!0):r.addNote({name:"Barcode_Result",content:e[a]},!0)}for(let t=e.length;t<s.length;t++)s[t].deleteNote("Barcode_Result"),i.removeDrawingItem(s[t]);i.renderAll()}async startScanning(e){if(!this.dce&&!this._imgSource)throw new Error("'imageSource' is not set. call 'setImageSource()' before 'startScanning()'.");if(this._promiseStartScan&&this._promiseStartScan.isPending)return this._promiseStartScan;this._promiseStartScan=new y;let t=null;if(this.dce){if(this.dce.isOpen())if(e&&this.dce.appendAndShowUI(),this.dce.playCallbackInfo)t=JSON.parse(JSON.stringify(this.dce.playCallbackInfo));else{const e=this.dce.getSelectedCamera();t={width:this.dce.video.videoWidth,height:this.dce.video.videoHeight,deviceId:e&&e.deviceId}}else if(t=await this.dce.open(e),!this._promiseStartScan)return null;this._dceControler&&(this._dceControler.clearUserDisiredAction({user:this,actionName:"close"}),this._dceControler.setDisiredValue(this,"ifShowScanRegionLaser",!0),this.dce.ifShowScanRegionLaser&&this.dce.showScanRegionLaser())}return this._bPauseScan=!1,this.dce&&this.dce.singleFrameMode||(this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout((()=>{this.dce&&(this.dce.startFetchingLoop(),this._dceControler&&this._dceControler.clearUserDisiredAction({user:this,actionName:"stopFetchingLoop"})),this._loopReadVideo()}),0)),this._promiseStartScan.resolve(t),t}stopScanning(e){this.dce&&(this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._drawResults(null),this._dceControler&&(this._dceControler.setDisiredValue(this,"ifShowScanRegionLaser",!1),this.dce.ifShowScanRegionLaser||this.dce.hideScanRegionLaser(),this._dceControler.setDisiredAction(this,"close",[e]))),this._bPauseScan=!0,this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this.array_decodeFrameTimeCost.length=0,this.array_getFrameTimeCost.length=0,this._intervalGetVideoFrame=0,this._promiseStartScan=null}pauseScanning(e){if(this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),e&&e.keepResultsHighlighted||this._drawResults(null),this._bPauseScan=!0,this.dce){if(this.dce.singleFrameMode)throw new Error("'pauseScanning()' is unavailable when property 'singleFrameMode' of the 'CameraEnhancer' instance is true.");this._dceControler&&(this._dceControler.setDisiredValue(this,"ifShowScanRegionLaser",!1),this.dce.ifShowScanRegionLaser||this.dce.hideScanRegionLaser(),this._dceControler.setDisiredAction(this,"stopFetchingLoop"))}}resumeScanning(){if(this._bPauseScan=!1,this.dce){if(this.dce.singleFrameMode)throw new Error("'resumeScanning()' is unavailable when property 'singleFrameMode' of the 'CameraEnhancer' instance is true.");this.dce.startFetchingLoop(),this._dceControler&&(this._dceControler.clearUserDisiredAction({user:this,actionName:"stopFetchingLoop"}),this._dceControler.setDisiredValue(this,"ifShowScanRegionLaser",!0),this.dce.ifShowScanRegionLaser&&this.dce.showScanRegionLaser())}}destroyContext(){if(L._onLog&&L._onLog("destroyContext()"),this.bDestroyed)return;this.bDestroyed=!0,(this.dce||this._promiseStartScan)&&this.stopScanning(),this.setImageSource(null);let e=L._nextTaskID++;L._taskCallbackMap.set(e,(e=>{if(!e.success){let t=new Error(e.message);throw t.stack=e.stack+"\n"+t.stack,t}})),L._dbrWorker.postMessage({type:"destroyContext",id:e,instanceID:this._instanceID})}}function M(e,t,i){return(i.x-e.x)*(t.y-e.y)==(t.x-e.x)*(i.y-e.y)&&Math.min(e.x,t.x)<=i.x&&i.x<=Math.max(e.x,t.x)&&Math.min(e.y,t.y)<=i.y&&i.y<=Math.max(e.y,t.y)}function O(e){return Math.abs(e)<1e-6?0:e<0?-1:1}function w(e,t,i,s){let a=e[0]*(i[1]-t[1])+t[0]*(e[1]-i[1])+i[0]*(t[1]-e[1]),r=e[0]*(s[1]-t[1])+t[0]*(e[1]-s[1])+s[0]*(t[1]-e[1]);return!((a^r)>=0&&0!==a&&0!==r)&&(a=i[0]*(e[1]-s[1])+s[0]*(i[1]-e[1])+e[0]*(s[1]-i[1]),r=i[0]*(t[1]-s[1])+s[0]*(i[1]-t[1])+t[0]*(s[1]-i[1]),!((a^r)>=0&&0!==a&&0!==r))}var F,B,N,b,P,v,V,x,U,k,G,Z,W,H,K,J,Y,Q,X,z,j,q,$,ee,te,ie,se;L._jsVersion="9.6.41",L._jsEditVersion="20240108",L._version=`loading...(JS ${L._jsVersion}.${L._jsEditVersion})`,L._license=R,L._sessionPassword=I,L.browserInfo=d,L._workerName=`dbr-${L._jsVersion}.browser.worker.js`,L._engineResourcePath=g,L._licenseServer=[],L._deviceFriendlyName="",L._isShowRelDecodeTimeInResults=!1,L._bWasmDebug=!1,L._bNeverShowDialog=!1,L.__bUseFullFeature=!0,L._nextTaskID=0,L._taskCallbackMap=new Map,L._pLoad=new y,L._lastErrorCode=0,L._lastErrorString="",L._setWarnnedEx=new Set,L._defaultUIElementURL="@engineResourcePath/dbr.ui.html","function"==typeof SuppressedError&&SuppressedError;class ae extends L{static set _onLog(e){!function(e,t,i,s,a){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!a)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===s?a.call(e,i):a?a.value=i:t.set(e,i)}(ae,F,e,"f",B),t._onLog=e}static get _onLog(){return function(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)}(ae,F,"f",B)}static get version(){return this._version+`(DCE ${t.getVersion()})`}static _fireHTTPSWarnning(){ae.onWarning&&location&&"https:"!==location.protocol&&setTimeout((()=>{ae.onWarning&&ae.onWarning({id:2,message:"Not connected via SSL (HTTPS), the SDK may not work correctly."})}),0)}static async testCameraAccess(){return t.testCameraAccess()}_fireResolutionWarning(){if(!this.singleFrameMode&&this.onWarning&&this.dce.isOpen()){const e=this.dce.getConstraints();e&&e.width<1280&&e.height<720&&setTimeout((()=>{this.onWarning&&this.onWarning({id:3,message:"Camera resolution too low, please use a higher resolution (720P or better)."})}),0)}}getUIElement(){return this.dce.getUIElement()}async setUIElement(e){await this.dce.setUIElement(e)}get singleFrameMode(){return this.dce.singleFrameMode}set singleFrameMode(e){if("boolean"!=typeof e&&!["image","camera"].includes(e))throw new Error("Invalid value.");this.dce.singleFrameMode=e,e&&(this.dce.ifShowScanRegionLaser=!1,(async()=>{let e=await this.getScanSettings();e.oneDTrustFrameCount=1,await this.updateScanSettings(e)})())}get onUnduplicatedRead(){return this.onUniqueRead}set onUnduplicatedRead(e){this.onUniqueRead=e}get video(){return this.dce&&this.dce.video}set videoSrc(e){this.dce&&(this.dce.videoSrc=e)}get videoSrc(){return this.dce&&this.dce.videoSrc}set cameraOpenTimeout(e){this.dce&&(this.dce.cameraOpenTimeout=e)}get cameraOpenTimeout(){return this.dce&&this.dce.cameraOpenTimeout}set onTipSuggested(e){this.dce&&(this.dce.onTipSuggested=e)}get onTipSuggested(){return this.dce&&this.dce.onTipSuggested}_assertOpen(){if(!this.dce.isOpen())throw Error("The scanner is not open.")}set barcodeFillStyle(e){this._barcodeFillStyle=e,this.dce&&this.dce.updateDrawingStyle(3,{fillStyle:e})}get barcodeFillStyle(){return this._barcodeFillStyle}set barcodeStrokeStyle(e){this._barcodeStrokeStyle=e,this.dce&&this.dce.updateDrawingStyle(3,{strokeStyle:e})}get barcodeStrokeStyle(){return this._barcodeStrokeStyle}set barcodeLineWidth(e){this._barcodeLineWidth=e,this.dce&&this.dce.updateDrawingStyle(3,{lineWidth:e})}get barcodeLineWidth(){return this._barcodeLineWidth}set barcodeFillStyleBeforeVerification(e){this._barcodeFillStyleBeforeVerification=e,this._styleIdBeforeVerification&&this.dce.updateDrawingStyle(this._styleIdBeforeVerification,{fillStyle:e})}get barcodeFillStyleBeforeVerification(){return this._barcodeFillStyleBeforeVerification}set barcodeStrokeStyleBeforeVerification(e){this._barcodeStrokeStyleBeforeVerification=e,this._styleIdBeforeVerification&&this.dce.updateDrawingStyle(this._styleIdBeforeVerification,{strokeStyle:e})}get barcodeStrokeStyleBeforeVerification(){return this._barcodeStrokeStyleBeforeVerification}set barcodeLineWidthBeforeVerification(e){this._barcodeLineWidthBeforeVerification=e,this._styleIdBeforeVerification&&this.dce.updateDrawingStyle(this._styleIdBeforeVerification,{lineWidth:e})}get barcodeLineWidthBeforeVerification(){return this._barcodeLineWidthBeforeVerification}set regionMaskFillStyle(e){this.dce.setScanRegionMaskStyle({fillStyle:e})}get regionMaskFillStyle(){return this.dce.regionMaskFillStyle}set regionMaskStrokeStyle(e){this.dce.setScanRegionMaskStyle({strokeStyle:e})}get regionMaskStrokeStyle(){return this.dce.regionMaskStrokeStyle}set regionMaskLineWidth(e){this.dce.setScanRegionMaskStyle({lineWidth:e})}get regionMaskLineWidth(){return this.dce.regionMaskLineWidth}set region(e){this._region=e,this.dce&&(e?e instanceof Array||this.dce.setScanRegion(e):this.dce.setScanRegion(null)),this.array_decodeFrameTimeCost.length=0,this.array_getFrameTimeCost.length=0,this._intervalGetVideoFrame=0}get region(){return this._region}set ifSaveOriginalImageInACanvas(e){this._ifSaveOriginalImageInACanvas=e,this.dce.framePixelFormat=e?"rgba":"grey"}get ifSaveOriginalImageInACanvas(){return this._ifSaveOriginalImageInACanvas}async createDCEInstance(){this.dce||(L._onLog&&L._onLog("createDCEInstance()"),t.defaultUIElementURL=null,this.dce=await t.createInstance(),this.dce.cameraOpenTimeout<15e3&&(this.dce.cameraOpenTimeout=15e3),this.dce.refreshInterval=200,this.dce.framePixelFormat="grey",this.dce.maxCvsSideLength=this.maxCvsSideLength,this._drawingItemNamespace=i,["iPhone","iPad","Android","HarmonyOS"].includes(L.browserInfo.OS)||this.dce.setResolution(1920,1080),this._styleIdBeforeVerification=this.dce.createDrawingStyle({fillStyle:"rgba(248,252,0,0.2)",strokeStyle:"transparent",paintMode:"strokeAndFill"}),this.barcodeLineWidth=this._barcodeLineWidth,this.dce.on("cameraChange",(()=>{this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._drawResults(null),this.array_decodeFrameTimeCost.length=0,this.array_getFrameTimeCost.length=0,this._intervalGetVideoFrame=0})),this.dce.on("resolutionChange",(()=>{this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._drawResults(null),this.array_decodeFrameTimeCost.length=0,this.array_getFrameTimeCost.length=0,this._intervalGetVideoFrame=0})),this.dce.on("cameraClose",(()=>{this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._drawResults(null),this.array_decodeFrameTimeCost.length=0,this.array_getFrameTimeCost.length=0,this._intervalGetVideoFrame=0,this._bPauseScan=!1})),this.dce.on("singleFrameAcquired",(async e=>{if(!e)return;if(!e.data)return;let t;this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._drawResults(null),this.ifSaveOriginalImageInACanvas&&(this.oriCanvas=null,this.oriCanvasData={width:e.width,height:e.height,pixelFormat:e.pixelFormat,data:new Uint8Array(e.data),toCanvas:e.toCanvas});const{data:i,sx:s,sy:a,width:r,height:o,stride:n,pixelFormat:c,timeStamp:d,_sWidth:l,_sHeight:h}=e,_={timeStamp:d};if("grey"===c)t=await this._decodeBuffer_Uint8Array(i,r,o,n,E.IPF_GrayScaled,0,_);else if("rgba"===c)t=await this._decodeBuffer_Uint8Array(i,r,o,n,E.IPF_ABGR_8888,0,_);else{if("bgra"!==c)throw new Error(`Pixel format '${c}' is not supported.`);t=await this._decodeBuffer_Uint8Array(i,r,o,n,E.IPF_ARGB_8888,0,_)}if(await this.clearMapDecodeRecord(),L.recalculateResultLocation(t,s,a,l,h,r,o),this._drawResults(t),this.onFrameRead&&this.isOpen()&&!this._bPauseScan){let e=this._cloneDecodeResults(t);this.onFrameRead(e)}if(this.onUniqueRead&&this.isOpen()&&!this._bPauseScan)for(let e of t)this.onUniqueRead(e.barcodeText,this._cloneDecodeResults(e))})))}set maxCvsSideLength(e){this._maxCvsSideLength=e,this.dce.maxCvsSideLength=e}get maxCvsSideLength(){return this._maxCvsSideLength}constructor(){super(),this._barcodeFillStyle="rgba(254,180,32,0.3)",this._barcodeStrokeStyle="rgba(254,180,32,0.9)",this._barcodeLineWidth=1,this._barcodeFillStyleBeforeVerification="rgba(248,252,0,0.2)",this._barcodeStrokeStyleBeforeVerification="transparent",this._barcodeLineWidthBeforeVerification=2,this.bFilterRegionInJs=!0,this._onPlayed=null}static async createInstance(e){const t=new ae;t._instanceID=await ae.createInstanceInWorker(!0),await t.createDCEInstance(),"string"==typeof e&&(e=JSON.parse(e));for(let i in e)t[i]=e[i];return await t.dce.setUIElement(ae.defaultUIElementURL),t.singleFrameMode&&console.warn("The `navigator.mediaDevices.getUserMedia` is unavailable. automatically change to `singleFrameMode`."),ae._fireHTTPSWarnning(),t.singleFrameMode||await t.updateRuntimeSettings("single"),t}async decodeCurrentFrame(e){this._assertOpen();let t=null;e&&e.region&&(t=e.region);const i=this.dce._getVideoData(null,{region:t});return this._decode_DCEFrame(i)}async updateRuntimeSettings(e){let t;if("string"==typeof e)if("speed"==e){let e=await this.getRuntimeSettings();await this.resetRuntimeSettings(),t=await this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,e.region&&(t.region=e.region),t.expectedBarcodesCount=0,t.localizationModes=[2,0,0,0,0,0,0,0],t.barcodeZoneMinDistanceToImageBorders=9}else if("balance"==e){let e=await this.getRuntimeSettings();await this.resetRuntimeSettings(),t=await this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,e.region&&(t.region=e.region),t.expectedBarcodesCount=512,t.deblurLevel=3,t.localizationModes=[2,16,0,0,0,0,0,0],t.barcodeZoneMinDistanceToImageBorders=9,t.timeout=1e5}else if("coverage"==e){let e=await this.getRuntimeSettings();await this.resetRuntimeSettings(),t=await this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,e.region&&(t.region=e.region),t.expectedBarcodesCount=512,t.deblurLevel=5,t.scaleDownThreshold=1e5,t.localizationModes=[2,16,4,8,0,0,0,0],t.barcodeZoneMinDistanceToImageBorders=9,t.timeout=1e5}else if("single"==e){let e=await this.getRuntimeSettings();await this.resetRuntimeSettings(),t=await this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,e.region&&(t.region=e.region)}else if("dense"==e){let e=await this.getRuntimeSettings();await this.resetRuntimeSettings(),this.maxCvsSideLength=4096,t=await this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,e.region&&(t.region=e.region),t.expectedBarcodesCount=0,t.deblurLevel=7,t.scaleDownThreshold=1e5,t.localizationModes=[2,8,0,0,0,0,0,0],t.minResultConfidence=0,t.barcodeZoneMinDistanceToImageBorders=9,t.timeout=1e5}else if("distance"==e){let e=await this.getRuntimeSettings();await this.resetRuntimeSettings(),this.maxCvsSideLength=4096,t=await this.getRuntimeSettings(),t.barcodeFormatIds=e.barcodeFormatIds,t.barcodeFormatIds_2=e.barcodeFormatIds_2,e.region&&(t.region=e.region),t.expectedBarcodesCount=0,t.scaleDownThreshold=1e5,t.localizationModes=[2,8,0,0,0,0,0,0],t.barcodeZoneMinDistanceToImageBorders=9,t.timeout=1e5}else t=JSON.parse(e);else{if("object"!=typeof e)throw TypeError("'UpdateRuntimeSettings(settings)': Type of 'settings' should be 'string' or 'PlainObject'.");if(t=JSON.parse(JSON.stringify(e)),t.region instanceof Array){let i=e.region;[i.regionLeft,i.regionTop,i.regionLeft,i.regionBottom,i.regionMeasuredByPercentage].some((e=>void 0!==e))&&(t.region={regionLeft:i.regionLeft||0,regionTop:i.regionTop||0,regionRight:i.regionRight||0,regionBottom:i.regionBottom||0,regionMeasuredByPercentage:i.regionMeasuredByPercentage||0})}}if(!L._bUseFullFeature){if(t.barcodeFormatIds&~(T.BF_ONED|T.BF_QR_CODE|T.BF_PDF417|T.BF_DATAMATRIX)||0!=t.barcodeFormatIds_2)throw Error("Some of the specified barcode formats are not supported in the compact version. Please try the full-featured version.");if(0!=t.intermediateResultTypes)throw Error("Intermediate results is not supported in the compact version. Please try the full-featured version.")}{let e=t.region;if(this.bFilterRegionInJs?this.userDefinedRegion=JSON.parse(JSON.stringify(e)):this.userDefinedRegion=null,e instanceof Array)if(e.length){for(let t=0;t<e.length;++t){let i=e[t];i&&((i.regionLeft||i.regionTop||i.regionRight||i.regionBottom||i.regionMeasuredByPercentage)&&(i.regionLeft||i.regionTop||100!=i.regionRight||100!=i.regionBottom||!i.regionMeasuredByPercentage)||(e[t]=null))}this.region=e}else this.region=null;else e&&(e.regionLeft||e.regionTop||e.regionRight||e.regionBottom||e.regionMeasuredByPercentage)&&(e.regionLeft||e.regionTop||100!=e.regionRight||100!=e.regionBottom||!e.regionMeasuredByPercentage)?this.region=e:this.region=null;this.bFilterRegionInJs&&(t.region={regionLeft:0,regionTop:0,regionRight:0,regionBottom:0,regionMeasuredByPercentage:0})}(this.autoZoom||this.autoFocus)&&(t.intermediateResultTypes|=D.IRT_TYPED_BARCODE_ZONE),await new Promise(((e,i)=>{let s=L._nextTaskID++;L._taskCallbackMap.set(s,(t=>{if(t.success){try{this._handleRetJsonString(t.updateReturn)}catch(e){i(e)}return e()}{let e=new Error(t.message);return e.stack=t.stack+"\n"+e.stack,i(e)}})),L._dbrWorker.postMessage({type:"updateRuntimeSettings",id:s,instanceID:this._instanceID,body:{settings:JSON.stringify(t)}})})),"string"==typeof e&&["speed","balance","coverage","dense","distance"].includes(e)&&(await this.setModeArgument("BinarizationModes",0,"EnableFillBinaryVacancy","1"),await this.setModeArgument("BinarizationModes",0,"BlockSizeX","0"),await this.setModeArgument("BinarizationModes",0,"BlockSizeY","0"))}_bindUI(){if(!this.getUIElement())throw new Error("Need to define `UIElement` before opening.");if(this.dce._bindUI(),!this.dce.video)throw this._unbindUI(),Error("Can not find the video container element with class 'dce-video-container'")}_unbindUI(){this.dce._unbindUI()}set onPlayed(e){this.dce.off("played",this._onPlayed),this._onPlayed=e,this.dce.on("played",this._onPlayed)}get onPlayed(){return this._onPlayed}async getAllCameras(){return this.dce.getAllCameras()}async getCurrentCamera(){return this.dce.getSelectedCamera()}async setCurrentCamera(e){const t=await this.dce.selectCamera(e);return this._fireResolutionWarning(),t}getResolution(){return this.dce.getResolution()}async setResolution(e,t){const i=await this.dce.setResolution(e,t);return this._fireResolutionWarning(),i}getVideoSettings(){return this.dce.getVideoSettings()}updateVideoSettings(e){return this.dce.updateVideoSettings(e)}isOpen(){return this.dce&&this.dce.isOpen()}setVideoFit(e){return this.dce&&this.dce.setVideoFit(e)}getVideoFit(){return this.dce&&this.dce.getVideoFit()}set ifShowScanRegionMask(e){this.dce&&(this.dce.ifShowScanRegionMask=e)}get ifShowScanRegionMask(){return this.dce&&this.dce.ifShowScanRegionMask}set ifSaveLastUsedCamera(e){this.dce&&(this.dce.ifSaveLastUsedCamera=e)}get ifSaveLastUsedCamera(){return this.dce&&this.dce.ifSaveLastUsedCamera}set ifSkipCameraInspection(e){this.dce&&(this.dce.ifSkipCameraInspection=e)}get ifSkipCameraInspection(){return this.dce&&this.dce.ifSkipCameraInspection}stop(){this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._drawResults(null),this.dce.stop(),this.dce.ifShowScanRegionLaser=!1,this.dce.hideViewDecorator(),this.array_decodeFrameTimeCost.length=0,this.array_getFrameTimeCost.length=0,this._intervalGetVideoFrame=0}pause(){this.dce.pause()}async play(e,t,i){this.dce.ifShowScanRegionLaser=!0;const s=await this.dce.play(e,t,i);return this._fireResolutionWarning(),s}pauseScan(e){this._assertOpen(),this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),e&&e.keepResultsHighlighted||this._drawResults(null),this._bPauseScan=!0,this.dce.ifShowScanRegionLaser=!1,this.dce.stopFetchingLoop()}resumeScan(){this._assertOpen(),this._bPauseScan=!1,this.dce.ifShowScanRegionLaser=!0}getCapabilities(){return this.dce.getCapabilities()}getCameraSettings(){return this.dce.getCameraSettings()}getConstraints(){return this.dce.getConstraints()}async applyConstraints(e){return this.dce.applyConstraints(e)}async turnOnTorch(){return this.dce.turnOnTorch()}async turnOffTorch(){return this.dce.turnOffTorch()}async setColorTemperature(e){return this.dce.setColorTemperature(e)}getColorTemperature(){return this.dce.getColorTemperature()}async setExposureCompensation(e){return this.dce.setExposureCompensation(e)}getExposureCompensation(){return this.dce.getExposureCompensation()}async setZoom(e){return this.dce.setZoom(e)}getZoomSettings(){return this.dce.getZoomSettings()}resetZoom(){return this.dce.resetZoom()}async setFrameRate(e){return this.dce.setFrameRate(e)}getFrameRate(){return this.dce.getFrameRate()}async setFocus(e,t){return this.dce.setFocus(e,t)}getFocus(){return this.dce.getFocus()}getFocusSettings(){return this.dce.getFocusSettings()}async _loopReadVideo(){if(this.bDestroyed)return this.dce&&this.dce.stopFetchingLoop(),this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),void this._drawResults(null);if(!this.isOpen())return this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._drawResults(null),void await this.clearMapDecodeRecord();if(!this.dce.video||this.dce.video.paused||this._bPauseScan)return L._onLog&&L._onLog("Video or scan is paused. Ask in 1s."),await this.clearMapDecodeRecord(),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),void(this._loopReadVideoTimeoutId=setTimeout((()=>{this._loopReadVideo()}),this._intervalDetectVideoPause));L._onLog&&L._onLog("======= once read ======="),L._onLog&&(this._timeStartDecode=Date.now());const e=this._getVideoFrame();if(!e)return L._onLog&&L._onLog("Get invalid frame."),this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._drawResults(null),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),void(this._loopReadVideoTimeoutId=setTimeout((()=>{this._loopReadVideo()}),0));(async()=>{e._bUseWebGL||"grey"!==e.pixelFormat||(this.dce.framePixelFormat="rgba");let t=[];this.ifSaveOriginalImageInACanvas&&(this.oriCanvas=null,this.oriCanvasData={width:e.width,height:e.height,pixelFormat:e.pixelFormat,data:new Uint8Array(e.data),toCanvas:e.toCanvas});const{data:i,sx:s,sy:a,width:r,height:o,stride:n,pixelFormat:c,timeStamp:d,_sWidth:l,_sHeight:h}=e,_={timeStamp:d};if("grey"===c)t=await this._decodeBuffer_Uint8Array(i,r,o,n,E.IPF_GrayScaled,0,_);else if("rgba"===c)t=await this._decodeBuffer_Uint8Array(i,r,o,n,E.IPF_ABGR_8888,0,_);else{if("bgra"!==c)throw new Error(`Pixel format '${c}' is not supported.`);t=await this._decodeBuffer_Uint8Array(i,r,o,n,E.IPF_ARGB_8888,0,_)}if(L.recalculateResultLocation(t,s,a,l,h,r,o),0==this._resultHighlightingDuration?this._drawResults(null):this._drawResults(t),this._clearResultsCanvasTimeoutId&&clearTimeout(this._clearResultsCanvasTimeoutId),this._resultHighlightingDuration>0&&(this._clearResultsCanvasTimeoutId=setTimeout((()=>{this.bDestroyed||this._drawResults(null)}),this._resultHighlightingDuration)),this.isOpen()&&this.dce.video&&!this.dce.video.paused&&!this._bPauseScan&&(this.autoZoom||this.autoFocus||this.autoSuggestTip))if(t.length)this.autoZoomInFrameArray.length=0,this.autoZoomOutFrameCount=0,this.frameArrayInIdealZoom.length=0,this.suggestTipFrameArray.length=0,this.autoZoom&&this.autoFocus&&(this.nextActionInIdealZoom="focus"),this.autoFocusFrameArray.length=0,this.noIntermediateResultsCount=0;else{const e=async()=>new Promise(((e,t)=>{let i=L._nextTaskID++;L._taskCallbackMap.set(i,(i=>{if(i.success)return e(i.results);{let e=new Error(i.message);return e.stack=i.stack+"\n"+e.stack,t(e)}})),L._dbrWorker.postMessage({type:"getIntermediateResults",id:i,instanceID:this._instanceID,body:{isCharge:!1}})})),t=await e(),i=(e,t,i,s,a,r,o)=>{let n=r/s,c=o/a;e.x1=e.x1/n+t,e.x2=e.x2/n+t,e.x3=e.x3/n+t,e.x4=e.x4/n+t,e.y1=e.y1/c+i,e.y2=e.y2/c+i,e.y3=e.y3/c+i,e.y4=e.y4/c+i},n=e=>{if(!e)return null;const t={};let n,c,d,_,u;{const e=this.video.videoWidth*(1-this.autoZoomDetectionArea)/2,t=this.video.videoWidth*(1+this.autoZoomDetectionArea)/2,i=t,s=e,a=this.video.videoHeight*(1-this.autoZoomDetectionArea)/2,r=a,o=this.video.videoHeight*(1+this.autoZoomDetectionArea)/2;u={x1:e,x2:t,x3:i,x4:s,y1:a,y2:r,y3:o,y4:o}}const g=(e,t)=>{const i=(e,t)=>{if(!e&&!t)throw new Error("Invalid arguments.");return function(e,t,i){let s=!1;const a=e.length;if(a<=2)return!1;for(let r=0;r<a;r++){const o=e[r],n=e[(r+1)%a];if(M(o,n,{x:t,y:i}))return!0;O(o.y-i)>0!=O(n.y-i)>0&&O(t-(i-o.y)*(o.x-n.x)/(o.y-n.y)-o.x)<0&&(s=!s)}return s}([{x:t.x1,y:t.y1},{x:t.x2,y:t.y2},{x:t.x3,y:t.y3},{x:t.x4,y:t.y4}],e.x,e.y)},s=(e,t)=>!!(w([e[0],e[1]],[e[2],e[3]],[t.x1,t.y1],[t.x2,t.y2])||w([e[0],e[1]],[e[2],e[3]],[t.x2,t.y2],[t.x3,t.y3])||w([e[0],e[1]],[e[2],e[3]],[t.x3,t.y3],[t.x4,t.y4])||w([e[0],e[1]],[e[2],e[3]],[t.x4,t.y4],[t.x1,t.y1]));return!!(i({x:e.x1,y:e.y1},t)||i({x:e.x2,y:e.y2},t)||i({x:e.x3,y:e.y3},t)||i({x:e.x4,y:e.y4},t))||(!!(i({x:t.x1,y:t.y1},e)||i({x:t.x2,y:t.y2},e)||i({x:t.x3,y:t.y3},e)||i({x:t.x4,y:t.y4},e))||!!(s([t.x1,t.y1,t.x2,t.y2],e)||s([t.x2,t.y2,t.x3,t.y3],e)||s([t.x3,t.y3,t.x4,t.y4],e)||s([t.x4,t.y4,t.x1,t.y1],e)))},m=[];for(let t of e){if(t.resultType!==D.IRT_TYPED_BARCODE_ZONE)continue;const e=t.scaleDownRatio;for(let n of t.results){if(!n)continue;const t={x1:n.x1=n.x1*e,x2:n.x2=n.x2*e,x3:n.x3=n.x3*e,x4:n.x4=n.x4*e,y1:n.y1=n.y1*e,y2:n.y2=n.y2*e,y3:n.y4=n.y3*e,y4:n.y4=n.y4*e};i(t,s,a,l,h,r,o),g(u,t)&&m.push(n)}}const R=(e=>{if(!e||!e.length)return null;const t=e=>{const t=(e.x1+e.x2+e.x3+e.x4)/4,i=(e.y1+e.y2+e.y3+e.y4)/4;return(t-r/2)*(t-r/2)+(i-o/2)*(i-o/2)};let i,s=e.filter((e=>e.barcodeFormat==T.BF_QR_CODE||e.barcodeFormat==T.BF_DATAMATRIX));if(s.length||(s=e.filter((e=>e.barcodeFormat==T.BF_ONED)),s.length||(s=e)),!s.length)return null;i=s[0];let a=t(i);if(1!=s.length)for(let e=1;e<s.length;e++){const r=t(s[e]);s[e].confidence>1.1*i.confidence?(i=s[e],a=r):s[e].confidence>.9*i.confidence&&r<a&&(i=s[e],a=r)}return i})(m);if(!R)return null;const I=R.x1,S=R.x2,E=R.x3,A=R.x4,f=R.y1,C=R.y2,y=R.y3,p=R.y4;return n=Math.min(I,S,E,A),c=Math.max(I,S,E,A),d=Math.min(f,C,y,p),_=Math.max(f,C,y,p),t.x1=t.x4=n,t.x2=t.x3=c,t.y1=t.y2=d,t.y3=t.y4=_,t.result=R,t},c=n(t);if(c&&c.x1){if(this.autoZoomOutFrameCount=0,this.noIntermediateResultsCount=0,this.suggestTipFrameArray.push(!0),this.suggestTipFrameArray.splice(0,this.suggestTipFrameArray.length-this.suggestTipFrameLimit[0]),this.autoSuggestTip&&this.suggestTipFrameArray.filter((e=>!0===e)).length>=this.suggestTipFrameLimit[1]){this.suggestTipFrameArray.length=0;const e=c.x3-c.x1,t=c.y3-c.y1;c.result.moduleSize<this.tinyBarcodeTipModuleSizeLimit?this.dce&&this.dce.suggestTip("tiny-barcode","Please zoom in or move closer."):e>t?e>r*this.hugeBarcodeTipLimit?this.dce&&this.dce.suggestTip("huge-barcode","Please zoom out or move farther."):e>.6*r&&Math.max(this.video.videoWidth,this.video.videoHeight)<=1280&&Math.min(this.video.videoWidth,this.video.videoHeight)<=720&&this.dce&&this.dce.suggestTip("low-resolution","Please use a higher resolution."):e<=t&&(t>o*this.hugeBarcodeTipLimit?this.dce&&this.dce.suggestTip("huge-barcode","Please zoom out or move farther."):t>.6*o&&Math.max(this.video.videoWidth,this.video.videoHeight)<=1280&&Math.min(this.video.videoWidth,this.video.videoHeight)<=720&&this.dce&&this.dce.suggestTip("low-resolution","Please use a higher resolution."))}if(this.autoZoom){const e=this.autoZoomIdealArea[1];let t=(1-this.autoZoomTargetBorder)/2;const n=c.x1/l,d=(l-c.x3)/l,_=c.y1/h,u=(h-c.y3)/h;if(n>e&&d>e&&_>e&&u>e&&c.result.moduleSize<this.autoZoomInIdealModuleSize){if(this.autoZoomInFrameArray.push(!0),this.autoZoomInFrameArray.splice(0,this.autoZoomInFrameArray.length-this.autoZoomInFrameLimit[0]),this.frameArrayInIdealZoom.length=0,this.autoFocus&&(this.nextActionInIdealZoom="focus",this.setFocus({mode:"continuous"}).catch((()=>{}))),this.autoZoomInFrameArray.filter((e=>!0===e)).length>=this.autoZoomInFrameLimit[1]){this.autoZoomInFrameArray.length=0;const e=[(.5-t)/(.5-n),(.5-t)/(.5-d),(.5-t)/(.5-_),(.5-t)/(.5-u)].filter((e=>e>0)),i=Math.min(...e,this.autoZoomInIdealModuleSize/c.result.moduleSize),s=this.dce.getZoomSettings().factor;let a=Math.max(Math.pow(s*i,1/this.autoZoomInMaxTimes),this.autoZoomInMinStep);a=Math.min(a,i);const r=s*a;try{await this.setZoom({factor:r})}catch(e){const t=e.message||e;console.warn(t)}this.dce.clearFrameBuffer()}}else if(this.autoZoomInFrameArray.length=0,this.frameArrayInIdealZoom.push(!0),this.frameArrayInIdealZoom.splice(0,this.frameArrayInIdealZoom.length-this.frameLimitInIdealZoom[0]),this.frameArrayInIdealZoom.filter((e=>!0===e)).length>=this.frameLimitInIdealZoom[1])if(this.frameArrayInIdealZoom.length=0,"focus"===this.nextActionInIdealZoom&&this.autoFocus){i(c,s,a,l,h,r,o);try{await this.setFocus({mode:"manual",area:{centerPoint:{x:(c.x1+c.x3)/2+"px",y:(c.y1+c.y3)/2+"px"},width:c.x3-c.x1+"px",height:c.y3-c.y1+"px"}})}catch(e){const t=e.message||e;console.warn(t)}this.dce.clearFrameBuffer(),this.nextActionInIdealZoom="zoomOut"}else{if("zoomOut"!==this.nextActionInIdealZoom&&this.autoFocus)throw new Error("Invalid action.");if(this.enableZoomOutInIdealZoom){t=this.autoZoomIdealArea[1]+this.autoZoomOutStepRate_2;const e=[(.5-t)/(.5-n),(.5-t)/(.5-d),(.5-t)/(.5-_),(.5-t)/(.5-u)].filter((e=>e>0));let i=Math.min(...e)*this.dce.getZoomSettings().factor;try{await this.setZoom({factor:i})}catch(e){const t=e.message||e;console.warn(t)}this.dce.clearFrameBuffer(),this.autoFocus&&(this.nextActionInIdealZoom="focus",this.setFocus({mode:"continuous"}).catch((()=>{})))}}}else if(this.autoFocus&&(this.autoFocusFrameArray.push(!0),this.autoFocusFrameArray.splice(0,this.autoFocusFrameArray.length-this.autoFocusFrameLimit[0]),this.autoFocusFrameArray.filter((e=>!0===e)).length>=this.autoFocusFrameLimit[1])){this.autoFocusFrameArray.length=0;try{i(c,s,a,l,h,r,o),await this.setFocus({mode:"manual",area:{centerPoint:{x:(c.x1+c.x3)/2+"px",y:(c.y1+c.y3)/2+"px"},width:c.x3-c.x1+"px",height:c.y3-c.y1+"px"}})}catch(e){const t=e.message||e;console.warn(t)}this.dce.clearFrameBuffer()}}else if(this.noIntermediateResultsCount++,this.suggestTipFrameArray.push(!1),this.autoZoom){if(this.autoZoomInFrameArray.push(!1),this.autoZoomInFrameArray.splice(0,this.autoZoomInFrameArray.length-this.autoZoomInFrameLimit[0]),this.autoZoomOutFrameCount++,this.frameArrayInIdealZoom.push(!1),this.frameArrayInIdealZoom.splice(0,this.frameArrayInIdealZoom.length-this.frameLimitInIdealZoom[0]),this.autoZoomOutFrameCount>=this.autoZoomOutFrameLimit){this.autoZoomOutFrameCount=0;const e=this.getZoomSettings().factor;if(e>this.autoZoomOutMinValue){const t=Math.max((e-1)*this.autoZoomOutStepRate,this.autoZoomOutMinStep),i=Math.max(e-t,this.autoZoomOutMinValue);try{await this.setZoom({factor:i})}catch(e){const t=e.message||e;console.warn(t)}this.dce.clearFrameBuffer()}}this.autoFocus&&(this.nextActionInIdealZoom="focus",this.setFocus({mode:"continuous"}).catch((()=>{})))}else this.autoFocus&&(this.autoFocusFrameArray.length=0,this.setFocus({mode:"continuous"}).catch((()=>{})))}return t})().then((e=>{if(L._onLog&&L._onLog(e),this.captureAndDecodeInParallel){let e=this.array_decodeFrameTimeCost,t=this.array_getFrameTimeCost,i=this._indexCurrentDecodingFrame;const s=()=>{let s=0;if(this.region instanceof Array){let a=0,r=0;a=i+1>=this.region.length?0:i+1,r=a+1>=this.region.length?0:a+1,s=e[a]&&e[a].length&&t[r]&&t[r].length?Math.min(...e[a])-Math.max(...t[r]):0}else if(t&&t.length){let i=Math.min(...e),a=Math.max(...t);i&&a&&(s=i-a)}else s=0;return s>0?s:0};(()=>{if(this.region instanceof Array){for(e[i]&&e[i]instanceof Array||(e[i]=[]);e[i].length>=5;)e[i].shift();e[i].push(this._lastInnerDecodeDuration)}else{for(;e.length>=5;)e.shift();e.push(this._lastInnerDecodeDuration)}})(),this._intervalGetVideoFrame=s()+this.intervalTime,L._onLog&&L._onLog("Next fetching frame loop interval: "+this._intervalGetVideoFrame)}if(this.isOpen()&&this.dce.video&&!this.dce.video.paused&&!this._bPauseScan){if(this.bPlaySoundOnSuccessfulRead&&e.length){let t=!1;!0===this.bPlaySoundOnSuccessfulRead||"frame"===this.bPlaySoundOnSuccessfulRead?t=e.some((e=>e.resultState>=0)):"unique"===this.bPlaySoundOnSuccessfulRead&&(t=e.some((e=>0==e.resultState))),t&&this.beepSound&&(this.beepSound.stop(),this.beepSound.play())}if(navigator.vibrate&&this.bVibrateOnSuccessfulRead&&e.length){let t=!1;if(!0===this.bVibrateOnSuccessfulRead||"frame"===this.bVibrateOnSuccessfulRead?t=e.some((e=>e.resultState>=0)):"unique"===this.bVibrateOnSuccessfulRead&&(t=e.some((e=>0==e.resultState))),t)try{navigator.vibrate(this.vibrateDuration)}catch(e){console.warn("Vibration not allowed. User interaction required: "+(e.message||e))}}if(this.onFrameRead){e=e.filter((e=>e.resultState>=0));const t=this._cloneDecodeResults(e);this.onFrameRead(t)}if(this.onUniqueRead){e=e.filter((e=>0==e.resultState));const t=this._cloneDecodeResults(e);for(let e of t)this.onUniqueRead(e.barcodeText,e)}}this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this.intervalTime?this._loopReadVideoTimeoutId=setTimeout((()=>{this._loopReadVideo()}),this.intervalTime):this._loopReadVideo()}))}_getVideoFrame(){if(!this.dce)return null;let e;if(this.captureAndDecodeInParallel){L._onLog&&L._onLog("Get frame in parallel.");let t=this.dce.isFetchingLoopStarted();if(this.dce.loopInterval=this._intervalGetVideoFrame,t||this.dce.startFetchingLoop(),!this.dce.numberOfFramesInBuffer)return this.dce.loopInterval=0,null;e=this.dce.getFrameFromBuffer();const i=e=>{if(!e)return;let t=e.timeSpent,i=this.array_getFrameTimeCost;for(;i.length>=5;)i.shift();i.push(t)};i(e)}else L._onLog&&L._onLog("Get frame in serial."),this.dce.stopFetchingLoop(),e=this.dce.getFrame();return e}async open(){this._bindUI();const e=await this.dce.open();return this._bPauseScan=!1,this.singleFrameMode||(this.dce&&(this.dce.ifShowScanRegionLaser=!0),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout((()=>{this._loopReadVideo()}),0)),this._fireResolutionWarning(),e}async openVideo(){this._bindUI(),this.dce.ifShowScanRegionLaser=!1;const e=await this.dce.open();return this._bPauseScan=!0,this.singleFrameMode||(this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout((()=>{this._loopReadVideo()}),0)),this._fireResolutionWarning(),e}close(){this._drawResults(null),this.dce.close(),this._bPauseScan=!0,this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId)}async show(){this._bindUI();const e=await this.dce.open(!0);return this._bPauseScan=!1,this.singleFrameMode||(this.dce&&(this.dce.ifShowScanRegionLaser=!0),this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout((()=>{this._loopReadVideo()}),0)),this._fireResolutionWarning(),e}async showVideo(){this._bindUI(),this.dce.ifShowScanRegionLaser=!1;const e=await this.dce.open(!0);return this._bPauseScan=!0,this.singleFrameMode||(this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId),this._loopReadVideoTimeoutId=setTimeout((()=>{this._loopReadVideo()}),0)),this._fireResolutionWarning(),e}hide(){this.dce.close(!0),this._bPauseScan=!0,this._loopReadVideoTimeoutId&&clearTimeout(this._loopReadVideoTimeoutId)}showTip(e,t,i,s,a=3e3,r=!0){this.dce&&this.dce.showTip(e,t,i,s,a,r)}hideTip(){this.dce&&this.dce.hideTip()}updateTipMessage(e){this.dce&&this.dce.updateTipMessage(e)}async enableTapToFocus(){this.dce&&this.dce.enableTapToFocus()}disableTapToFocus(){this.dce&&this.dce.disableTapToFocus()}isTapToFocusEnabled(){return this.dce.isTapToFocusEnabled()}convertToPageCoordinates(e){return this.dce.convertToPageCoordinates(e)}convertToClientCoordinates(e){return this.dce.convertToClientCoordinates(e)}destroyContext(){this.close(),this.dce&&this.dce.dispose(!1),this.bDestroyed||super.destroyContext()}}F=ae,B={value:void 0},function(e){e[e.BICM_DARK_ON_LIGHT=1]="BICM_DARK_ON_LIGHT",e[e.BICM_LIGHT_ON_DARK=2]="BICM_LIGHT_ON_DARK",e[e.BICM_DARK_ON_DARK=4]="BICM_DARK_ON_DARK",e[e.BICM_LIGHT_ON_LIGHT=8]="BICM_LIGHT_ON_LIGHT",e[e.BICM_DARK_LIGHT_MIXED=16]="BICM_DARK_LIGHT_MIXED",e[e.BICM_DARK_ON_LIGHT_DARK_SURROUNDING=32]="BICM_DARK_ON_LIGHT_DARK_SURROUNDING",e[e.BICM_SKIP=0]="BICM_SKIP",e[e.BICM_REV=2147483648]="BICM_REV"}(N||(N={})),function(e){e[e.BCM_AUTO=1]="BCM_AUTO",e[e.BCM_GENERAL=2]="BCM_GENERAL",e[e.BCM_SKIP=0]="BCM_SKIP",e[e.BCM_REV=2147483648]="BCM_REV"}(b||(b={})),function(e){e[e.BF2_NULL=0]="BF2_NULL",e[e.BF2_POSTALCODE=32505856]="BF2_POSTALCODE",e[e.BF2_NONSTANDARD_BARCODE=1]="BF2_NONSTANDARD_BARCODE",e[e.BF2_USPSINTELLIGENTMAIL=1048576]="BF2_USPSINTELLIGENTMAIL",e[e.BF2_POSTNET=2097152]="BF2_POSTNET",e[e.BF2_PLANET=4194304]="BF2_PLANET",e[e.BF2_AUSTRALIANPOST=8388608]="BF2_AUSTRALIANPOST",e[e.BF2_RM4SCC=16777216]="BF2_RM4SCC",e[e.BF2_DOTCODE=2]="BF2_DOTCODE",e[e.BF2_PHARMACODE_ONE_TRACK=4]="BF2_PHARMACODE_ONE_TRACK",e[e.BF2_PHARMACODE_TWO_TRACK=8]="BF2_PHARMACODE_TWO_TRACK",e[e.BF2_PHARMACODE=12]="BF2_PHARMACODE",e[e.BF2_ALL=-1]="BF2_ALL"}(P||(P={})),function(e){e[e.BM_AUTO=1]="BM_AUTO",e[e.BM_LOCAL_BLOCK=2]="BM_LOCAL_BLOCK",e[e.BM_SKIP=0]="BM_SKIP",e[e.BM_THRESHOLD=4]="BM_THRESHOLD",e[e.BM_REV=2147483648]="BM_REV"}(v||(v={})),function(e){e[e.ECCM_CONTRAST=1]="ECCM_CONTRAST"}(V||(V={})),function(e){e[e.CFM_GENERAL=1]="CFM_GENERAL"}(x||(x={})),function(e){e[e.CCM_AUTO=1]="CCM_AUTO",e[e.CCM_GENERAL_HSV=2]="CCM_GENERAL_HSV",e[e.CCM_SKIP=0]="CCM_SKIP",e[e.CCM_REV=2147483648]="CCM_REV"}(U||(U={})),function(e){e[e.CICM_GENERAL=1]="CICM_GENERAL",e[e.CICM_SKIP=0]="CICM_SKIP",e[e.CICM_REV=2147483648]="CICM_REV"}(k||(k={})),function(e){e[e.CM_IGNORE=1]="CM_IGNORE",e[e.CM_OVERWRITE=2]="CM_OVERWRITE"}(G||(G={})),function(e){e[e.DM_SKIP=0]="DM_SKIP",e[e.DM_DIRECT_BINARIZATION=1]="DM_DIRECT_BINARIZATION",e[e.DM_THRESHOLD_BINARIZATION=2]="DM_THRESHOLD_BINARIZATION",e[e.DM_GRAY_EQUALIZATION=4]="DM_GRAY_EQUALIZATION",e[e.DM_SMOOTHING=8]="DM_SMOOTHING",e[e.DM_MORPHING=16]="DM_MORPHING",e[e.DM_DEEP_ANALYSIS=32]="DM_DEEP_ANALYSIS",e[e.DM_SHARPENING=64]="DM_SHARPENING",e[e.DM_BASED_ON_LOC_BIN=128]="DM_BASED_ON_LOC_BIN",e[e.DM_SHARPENING_SMOOTHING=256]="DM_SHARPENING_SMOOTHING"}(Z||(Z={})),function(e){e[e.DRM_AUTO=1]="DRM_AUTO",e[e.DRM_GENERAL=2]="DRM_GENERAL",e[e.DRM_BROAD_WARP=4]="DRM_BROAD_WARP",e[e.DRM_LOCAL_REFERENCE=8]="DRM_LOCAL_REFERENCE",e[e.DRM_DEWRINKLE=16]="DRM_DEWRINKLE",e[e.DRM_SKIP=0]="DRM_SKIP",e[e.DRM_REV=2147483648]="DRM_REV"}(W||(W={})),function(e){e[e.DPMCRM_AUTO=1]="DPMCRM_AUTO",e[e.DPMCRM_GENERAL=2]="DPMCRM_GENERAL",e[e.DPMCRM_SKIP=0]="DPMCRM_SKIP",e[e.DPMCRM_REV=2147483648]="DPMCRM_REV"}(H||(H={})),function(e){e[e.GTM_INVERTED=1]="GTM_INVERTED",e[e.GTM_ORIGINAL=2]="GTM_ORIGINAL",e[e.GTM_SKIP=0]="GTM_SKIP",e[e.GTM_REV=2147483648]="GTM_REV"}(K||(K={})),function(e){e[e.IPM_AUTO=1]="IPM_AUTO",e[e.IPM_GENERAL=2]="IPM_GENERAL",e[e.IPM_GRAY_EQUALIZE=4]="IPM_GRAY_EQUALIZE",e[e.IPM_GRAY_SMOOTH=8]="IPM_GRAY_SMOOTH",e[e.IPM_SHARPEN_SMOOTH=16]="IPM_SHARPEN_SMOOTH",e[e.IPM_MORPHOLOGY=32]="IPM_MORPHOLOGY",e[e.IPM_SKIP=0]="IPM_SKIP",e[e.IPM_REV=2147483648]="IPM_REV"}(J||(J={})),function(e){e[e.IRSM_MEMORY=1]="IRSM_MEMORY",e[e.IRSM_FILESYSTEM=2]="IRSM_FILESYSTEM",e[e.IRSM_BOTH=4]="IRSM_BOTH"}(Y||(Y={})),function(e){e[e.LM_SKIP=0]="LM_SKIP",e[e.LM_AUTO=1]="LM_AUTO",e[e.LM_CONNECTED_BLOCKS=2]="LM_CONNECTED_BLOCKS",e[e.LM_LINES=8]="LM_LINES",e[e.LM_STATISTICS=4]="LM_STATISTICS",e[e.LM_SCAN_DIRECTLY=16]="LM_SCAN_DIRECTLY",e[e.LM_STATISTICS_MARKS=32]="LM_STATISTICS_MARKS",e[e.LM_STATISTICS_POSTAL_CODE=64]="LM_STATISTICS_POSTAL_CODE",e[e.LM_CENTRE=128]="LM_CENTRE",e[e.LM_ONED_FAST_SCAN=256]="LM_ONED_FAST_SCAN",e[e.LM_REV=2147483648]="LM_REV"}(Q||(Q={})),function(e){e[e.QRECL_ERROR_CORRECTION_H=0]="QRECL_ERROR_CORRECTION_H",e[e.QRECL_ERROR_CORRECTION_L=1]="QRECL_ERROR_CORRECTION_L",e[e.QRECL_ERROR_CORRECTION_M=2]="QRECL_ERROR_CORRECTION_M",e[e.QRECL_ERROR_CORRECTION_Q=3]="QRECL_ERROR_CORRECTION_Q"}(X||(X={})),function(e){e[e.RPM_AUTO=1]="RPM_AUTO",e[e.RPM_GENERAL=2]="RPM_GENERAL",e[e.RPM_GENERAL_RGB_CONTRAST=4]="RPM_GENERAL_RGB_CONTRAST",e[e.RPM_GENERAL_GRAY_CONTRAST=8]="RPM_GENERAL_GRAY_CONTRAST",e[e.RPM_GENERAL_HSV_CONTRAST=16]="RPM_GENERAL_HSV_CONTRAST",e[e.RPM_SKIP=0]="RPM_SKIP",e[e.RPM_REV=2147483648]="RPM_REV"}(z||(z={})),function(e){e[e.RCT_PIXEL=1]="RCT_PIXEL",e[e.RCT_PERCENTAGE=2]="RCT_PERCENTAGE"}(j||(j={})),function(e){e[e.RT_STANDARD_TEXT=0]="RT_STANDARD_TEXT",e[e.RT_RAW_TEXT=1]="RT_RAW_TEXT",e[e.RT_CANDIDATE_TEXT=2]="RT_CANDIDATE_TEXT",e[e.RT_PARTIAL_TEXT=3]="RT_PARTIAL_TEXT"}(q||(q={})),function(e){e[e.SUM_AUTO=1]="SUM_AUTO",e[e.SUM_LINEAR_INTERPOLATION=2]="SUM_LINEAR_INTERPOLATION",e[e.SUM_NEAREST_NEIGHBOUR_INTERPOLATION=4]="SUM_NEAREST_NEIGHBOUR_INTERPOLATION",e[e.SUM_SKIP=0]="SUM_SKIP",e[e.SUM_REV=2147483648]="SUM_REV"}($||($={})),function(e){e[e.TP_REGION_PREDETECTED=1]="TP_REGION_PREDETECTED",e[e.TP_IMAGE_PREPROCESSED=2]="TP_IMAGE_PREPROCESSED",e[e.TP_IMAGE_BINARIZED=4]="TP_IMAGE_BINARIZED",e[e.TP_BARCODE_LOCALIZED=8]="TP_BARCODE_LOCALIZED",e[e.TP_BARCODE_TYPE_DETERMINED=16]="TP_BARCODE_TYPE_DETERMINED",e[e.TP_BARCODE_RECOGNIZED=32]="TP_BARCODE_RECOGNIZED"}(ee||(ee={})),function(e){e[e.TFM_AUTO=1]="TFM_AUTO",e[e.TFM_GENERAL_CONTOUR=2]="TFM_GENERAL_CONTOUR",e[e.TFM_SKIP=0]="TFM_SKIP",e[e.TFM_REV=2147483648]="TFM_REV"}(te||(te={})),function(e){e[e.TROM_CONFIDENCE=1]="TROM_CONFIDENCE",e[e.TROM_POSITION=2]="TROM_POSITION",e[e.TROM_FORMAT=4]="TROM_FORMAT",e[e.TROM_SKIP=0]="TROM_SKIP",e[e.TROM_REV=2147483648]="TROM_REV"}(ie||(ie={})),function(e){e[e.TDM_AUTO=1]="TDM_AUTO",e[e.TDM_GENERAL_WIDTH_CONCENTRATION=2]="TDM_GENERAL_WIDTH_CONCENTRATION",e[e.TDM_SKIP=0]="TDM_SKIP",e[e.TDM_REV=2147483648]="TDM_REV"}(se||(se={}));export{L as BarcodeReader,ae as BarcodeScanner,N as EnumBarcodeColourMode,b as EnumBarcodeComplementMode,T as EnumBarcodeFormat,P as EnumBarcodeFormat_2,v as EnumBinarizationMode,V as EnumClarityCalculationMethod,x as EnumClarityFilterMode,U as EnumColourClusteringMode,k as EnumColourConversionMode,G as EnumConflictMode,H as EnumDPMCodeReadingMode,Z as EnumDeblurMode,W as EnumDeformationResistingMode,A as EnumErrorCode,K as EnumGrayscaleTransformationMode,f as EnumIMResultDataType,E as EnumImagePixelFormat,J as EnumImagePreprocessingMode,Y as EnumIntermediateResultSavingMode,D as EnumIntermediateResultType,Q as EnumLocalizationMode,X as EnumQRCodeErrorCorrectionLevel,z as EnumRegionPredetectionMode,j as EnumResultCoordinateType,q as EnumResultType,$ as EnumScaleUpMode,ee as EnumTerminatePhase,te as EnumTextFilterMode,ie as EnumTextResultOrderMode,se as EnumTextureDetectionMode};
