/*! 20250418 20240828 20250225091709
* Dynamsoft JavaScript Library
* Product: Dynamic Web TWAIN
* Web Site: https://www.dynamsoft.com
*
* Copyright 2025, Dynamsoft Corporation
* Author: Dynamsoft Support Team
*
* Module: BarcodeReader
* Version: 19.3
* 
*/
var Dynamsoft=self.Dynamsoft||{};Dynamsoft.DWT=Dynamsoft.DWT||{},Dynamsoft.DBR=Dynamsoft.DBR||{},Dynamsoft.aryAddonReadyFun=Dynamsoft.aryAddonReadyFun||[],Dynamsoft.AddonReady=Dynamsoft.AddonReady||function(e){Dynamsoft.aryAddonReadyFun.push(e)},function(){Dynamsoft.BarcodeReaderAddon=Dynamsoft.BarcodeReaderAddon||{};var n=Dynamsoft.BarcodeReaderAddon;n.Version="9.6.2.0318",n._decoding=!1,n._decodeQueue=[],n._decodeNext=function(){var e,t;0==n._decodeQueue.length?n._decoding=!1:(e=(t=n._decodeQueue[0]).method,t=t.args,n._decodeQueue.splice(0,1),e.apply(null,t))},n._defaultRuntimeSettingsStr="",n._defaultTemplateStr="",n._activeXInstance=!1,n.BarcodeReaderException=function(){var e=arguments[0],t=Dynamsoft.DBR.EnumErrorCode.DBR_UNKNOWN,e="number"==typeof e?(t=e,new Error(arguments[1])):new Error(e);return e.code=t,e},n.RemoveNonPrintableChar=function(e){return Dynamsoft.Lib.isString(e)?e.replace(/[^\x20-\x7E]|(\\")/g,""):e},n.errors={webcamNotInstalled:"The Webcam add-on not installed.",nonServiceNotSupportWebcamDecode:"The BarcodeReader add-on does not support reading barcodes from video streams.",decodeResultEmpty:"decode result is empty.",ServiceEditionNotSupportDbr:"The BarcodeReader add-on does not support your Operating System.",ServiceEditionNotSupportWasmMode:"You cannot call this method on this WebTwain instance."},n._activeXMaxIEVersion=9,n.logLevel=3,Dynamsoft.DBR.EnumAccompanyingTextRecognitionMode={ATRM_GENERAL:1,ATRM_SKIP:0},Dynamsoft.DBR.EnumBarcodeColourMode={BICM_DARK_ON_LIGHT:1,BICM_LIGHT_ON_DARK:2,BICM_DARK_ON_DARK:4,BICM_LIGHT_ON_LIGHT:8,BICM_DARK_LIGHT_MIXED:16,BICM_DARK_ON_LIGHT_DARK_SURROUNDING:32,BICM_SKIP:0},Dynamsoft.DBR.EnumBarcodeComplementMode={BCM_AUTO:1,BCM_GENERAL:2,BCM_SKIP:0},Dynamsoft.DBR.EnumBarcodeFormat={BF_ALL:-32505857,BF_ONED:2047,BF_GS1_DATABAR:260096,BF_CODE_39:1,BF_CODE_128:2,BF_CODE_93:4,BF_CODABAR:8,BF_ITF:16,BF_EAN_13:32,BF_EAN_8:64,BF_UPC_A:128,BF_UPC_E:256,BF_INDUSTRIAL_25:512,BF_CODE_39_EXTENDED:1024,BF_GS1_DATABAR_OMNIDIRECTIONAL:2048,BF_GS1_DATABAR_TRUNCATED:4096,BF_GS1_DATABAR_STACKED:8192,BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL:16384,BF_GS1_DATABAR_EXPANDED:32768,BF_GS1_DATABAR_EXPANDED_STACKED:65536,BF_GS1_DATABAR_LIMITED:131072,BF_PATCHCODE:262144,BF_PDF417:33554432,BF_QR_CODE:67108864,BF_DATAMATRIX:134217728,BF_AZTEC:268435456,BF_MAXICODE:536870912,BF_MICRO_QR:1073741824,BF_MICRO_PDF417:524288,BF_GS1_COMPOSITE:-2147483648,BF_NULL:0},Dynamsoft.DBR.EnumBarcodeFormat_2={BF2_NULL:0,BF2_POSTALCODE:32505856,BF2_NONSTANDARD_BARCODE:1,BF2_USPSINTELLIGENTMAIL:1048576,BF2_POSTNET:2097152,BF2_PLANET:4194304,BF2_AUSTRALIANPOST:8388608,BF2_RM4SCC:16777216,BF2_DOTCODE:2},Dynamsoft.DBR.EnumBinarizationMode={BM_AUTO:1,BM_LOCAL_BLOCK:2,BM_SKIP:0},Dynamsoft.DBR.EnumClarityCalculationMethod={ECCM_CONTRAST:1},Dynamsoft.DBR.EnumClarityFilterMode={CFM_GENERAL:1},Dynamsoft.DBR.EnumColourClusteringMode={CCM_AUTO:1,CCM_GENERAL_HSV:2,CCM_SKIP:0},Dynamsoft.DBR.EnumColourConversionMode={CICM_GENERAL:1,CICM_SKIP:0},Dynamsoft.DBR.EnumConflictMode={CM_IGNORE:1,CM_OVERWRITE:2},Dynamsoft.DBR.EnumDeformationResistingMode={DRM_AUTO:1,DRM_GENERAL:2,DRM_SKIP:0},Dynamsoft.DBR.EnumDPMCodeReadingMode={DPMCRM_AUTO:1,DPMCRM_GENERAL:2,DPMCRM_SKIP:0},Dynamsoft.DBR.EnumErrorCode={DBR_SYSTEM_EXCEPTION:1,DBR_SUCCESS:0,DBR_UNKNOWN:-1e4,DBR_NO_MEMORY:-10001,DBR_NULL_REFERENCE:-10002,DBR_LICENSE_INVALID:-10003,DBR_LICENSE_EXPIRED:-10004,DBR_FILE_NOT_FOUND:-10005,DBR_FILETYPE_NOT_SUPPORTED:-10006,DBR_BPP_NOT_SUPPORTED:-10007,DBR_INDEX_INVALID:-10008,DBR_BARCODE_FORMAT_INVALID:-10009,DBR_CUSTOM_REGION_INVALID:-10010,DBR_MAX_BARCODE_NUMBER_INVALID:-10011,DBR_IMAGE_READ_FAILED:-10012,DBR_TIFF_READ_FAILED:-10013,DBR_QR_LICENSE_INVALID:-10016,DBR_1D_LICENSE_INVALID:-10017,DBR_DIB_BUFFER_INVALID:-10018,DBR_PDF417_LICENSE_INVALID:-10019,DBR_DATAMATRIX_LICENSE_INVALID:-10020,DBR_PDF_READ_FAILED:-10021,DBR_PDF_DLL_MISSING:-10022,DBR_PAGE_NUMBER_INVALID:-10023,DBR_CUSTOM_SIZE_INVALID:-10024,DBR_CUSTOM_MODULESIZE_INVALID:-10025,DBR_RECOGNITION_TIMEOUT:-10026,DBR_JSON_PARSE_FAILED:-10030,DBR_JSON_TYPE_INVALID:-10031,DBR_JSON_KEY_INVALID:-10032,DBR_JSON_VALUE_INVALID:-10033,DBR_JSON_NAME_KEY_MISSING:-10034,DBR_JSON_NAME_VALUE_DUPLICATED:-10035,DBR_TEMPLATE_NAME_INVALID:-10036,DBR_JSON_NAME_REFERENCE_INVALID:-10037,DBR_PARAMETER_VALUE_INVALID:-10038,DBR_DOMAIN_NOT_MATCHED:-10039,DBR_RESERVEDINFO_NOT_MATCHED:-10040,DBR_AZTEC_LICENSE_INVALID:-10041,DBR_LICENSE_DLL_MISSING:-10042,DBR_LICENSEKEY_NOT_MATCHED:-10043,DBR_REQUESTED_FAILED:-10044,DBR_LICENSE_INIT_FAILED:-10045,DBR_PATCHCODE_LICENSE_INVALID:-10046,DBR_POSTALCODE_LICENSE_INVALID:-10047,DBR_DPM_LICENSE_INVALID:-10048,DBR_FRAME_DECODING_THREAD_EXISTS:-10049,DBR_STOP_DECODING_THREAD_FAILED:-10050,DBR_SET_MODE_ARGUMENT_ERROR:-10051,DBR_LICENSE_CONTENT_INVALID:-10052,DBR_LICENSE_KEY_INVALID:-10053,DBR_LICENSE_DEVICE_RUNS_OUT:-10054,DBR_GET_MODE_ARGUMENT_ERROR:-10055,DBR_IRT_LICENSE_INVALID:-10056,DBR_MAXICODE_LICENSE_INVALID:-10057,DBR_GS1_DATABAR_LICENSE_INVALID:-10058,DBR_GS1_COMPOSITE_LICENSE_INVALID:-10059,DBR_DOTCODE_LICENSE_INVALID:-10061,DMERR_FAILED_TO_REACH_LTS:-20200},Dynamsoft.DBR.EnumGrayscaleTransformationMode={GTM_INVERTED:1,GTM_ORIGINAL:2,GTM_SKIP:0},Dynamsoft.DBR.EnumImagePixelFormat={IPF_Binary:0,IPF_BinaryInverted:1,IPF_GrayScaled:2,IPF_NV21:3,IPF_RGB_565:4,IPF_RGB_555:5,IPF_RGB_888:6,IPF_ARGB_8888:7,IPF_RGB_161616:8,IPF_ARGB_16161616:9,IPF_ABGR_8888:10,IPF_ABGR_16161616:11,IPF_BGR_888:12},Dynamsoft.DBR.EnumImagePreprocessingMode={IPM_AUTO:1,IPM_GENERAL:2,IPM_GRAY_EQUALIZE:4,IPM_GRAY_SMOOTH:8,IPM_SHARPEN_SMOOTH:16,IPM_MORPHOLOGY:32,IPM_SKIP:0},Dynamsoft.DBR.EnumIMResultDataType={IMRDT_IMAGE:1,IMRDT_CONTOUR:2,IMRDT_LINESEGMENT:4,IMRDT_LOCALIZATIONRESULT:8,IMRDT_REGIONOFINTEREST:16,IMRDT_QUADRILATERAL:32},Dynamsoft.DBR.EnumIntermediateResultSavingMode={IRSM_MEMORY:1,IRSM_FILESYSTEM:2,IRSM_BOTH:4},Dynamsoft.DBR.EnumIntermediateResultType={IRT_NO_RESULT:0,IRT_ORIGINAL_IMAGE:1,IRT_COLOUR_CLUSTERED_IMAGE:2,IRT_COLOUR_CONVERTED_GRAYSCALE_IMAGE:4,IRT_TRANSFORMED_GRAYSCALE_IMAGE:8,IRT_PREDETECTED_REGION:16,IRT_PREPROCESSED_IMAGE:32,IRT_BINARIZED_IMAGE:64,IRT_TEXT_ZONE:128,IRT_CONTOUR:256,IRT_LINE_SEGMENT:512,IRT_FORM:1024,IRT_SEGMENTATION_BLOCK:2048,IRT_TYPED_BARCODE_ZONE:4096,IRT_PREDETECTED_QUADRILATERAL:8192},Dynamsoft.DBR.EnumLocalizationMode={LM_SKIP:0,LM_AUTO:1,LM_CONNECTED_BLOCKS:2,LM_LINES:8,LM_STATISTICS:4,LM_SCAN_DIRECTLY:16,LM_STATISTICS_MARKS:32,LM_STATISTICS_POSTAL_CODE:64},Dynamsoft.DBR.EnumPDFReadingMode={PDFRM_RASTER:1,PDFRM_AUTO:2,PDFRM_VECTOR:4},Dynamsoft.DBR.EnumQRCodeErrorCorrectionLevel={QRECL_ERROR_CORRECTION_H:0,QRECL_ERROR_CORRECTION_L:1,QRECL_ERROR_CORRECTION_M:2,QRECL_ERROR_CORRECTION_Q:3},Dynamsoft.DBR.EnumRegionPredetectionMode={RPM_AUTO:1,RPM_GENERAL:2,RPM_GENERAL_RGB_CONTRAST:4,RPM_GENERAL_GRAY_CONTRAST:8,RPM_GENERAL_HSV_CONTRAST:16,RPM_SKIP:0},Dynamsoft.DBR.EnumResultCoordinateType={RCT_PIXEL:1,RCT_PERCENTAGE:2},Dynamsoft.DBR.EnumResultType={RT_STANDARD_TEXT:0,RT_RAW_TEXT:1,RT_CANDIDATE_TEXT:2,RT_PARTIAL_TEXT:3},Dynamsoft.DBR.EnumScaleUpMode={SUM_AUTO:1,SUM_LINEAR_INTERPOLATION:2,SUM_NEAREST_NEIGHBOUR_INTERPOLATION:4,SUM_SKIP:0},Dynamsoft.DBR.EnumTerminatePhase={TP_REGION_PREDETECTED:1,TP_IMAGE_PREPROCESSED:2,TP_IMAGE_BINARIZED:4,TP_BARCODE_LOCALIZED:8,TP_BARCODE_TYPE_DETERMINED:16,TP_BARCODE_RECOGNIZED:32},Dynamsoft.DBR.EnumTextAssistedCorrectionMode={TACM_AUTO:1,TACM_VERIFYING:2,TACM_VERIFYING_PATCHING:4,TACM_SKIP:0},Dynamsoft.DBR.EnumTextFilterMode={TFM_AUTO:1,TFM_GENERAL_CONTOUR:2,TFM_SKIP:0},Dynamsoft.DBR.EnumTextResultOrderMode={TROM_CONFIDENCE:1,TROM_POSITION:2,TROM_FORMAT:4,TROM_SKIP:0},Dynamsoft.DBR.EnumTextureDetectionMode={TDM_AUTO:1,TDM_GENERAL_WIDTH_CONCENTRATION:2,TDM_SKIP:0}}(),Dynamsoft.AddonReady(function(T,e){var t,u=Dynamsoft.BarcodeReaderAddon;function M(e){return e&&e instanceof ArrayBuffer}u.Class=function(){function e(e){this._runtimeSettings=null,this._initSettingsContent=null,this._tplContentArr=[],this._stwain=e}var E;e.prototype._decodeBlob=function(t,e){var n=this;return new T.Promise(function(e){if(!(t instanceof Blob))throw TypeError("'_decodeBlob(blob, templateName)': Type of 'blob' should be 'Blob'.");e()}).then(function(){return n._innerDecode(0,t,e)})},e.prototype._decodeArrayBuffer=function(t,e){var n=this;return new T.Promise(function(e){if(!(t instanceof ArrayBuffer))throw TypeError("'_decodeBlob(arrayBuffer, templateName)': Type of 'arrayBuffer' should be 'ArrayBuffer'.");e()}).then(function(){return n._innerDecode(0,t,e)})},e.prototype._decodeUint8Array=function(t,e){var n=this;return new T.Promise(function(e){if(!(t instanceof Uint8Array||self.Uint8ClampedArray&&t instanceof Uint8ClampedArray))throw TypeError("'_decodeBlob(uint8Array, templateName)': Type of 'uint8Array' should be 'Uint8Array'.");e()}).then(function(){return n._innerDecode(0,t,e)})},e.prototype._decodeImage=function(t,n){var o=this;return new T.Promise(function(e){if(!(t instanceof HTMLImageElement))throw TypeError("'_decodeImage(image, templateName)': Type of 'image' should be 'HTMLImageElement'.");if(t.crossOrigin&&"anonymous"!=t.crossOrigin)throw"cors";n=n||"",e()}).then(function(){return"data:image/"==t.src.substring(0,11)?o._decodeBase64(t.src,n):o._decodeUrl(t.src,n).catch(function(e){return 3<=u.logLevel&&console&&console.warn&&(console.warn("'_decodeImage(image, templateName)': Image src not available. Use '_decodeCanvas' instead."),console.warn(e)),self.HTMLCanvasElement?((e=document.createElement("canvas")).width=t.naturalWidth,e.height=t.naturalHeight,e.getContext("2d").drawImage(t,0,0),o._decodeCanvas(e,n)):T.Promise.reject(Error("'_decodeImage(image, templateName)': Browser not support HTMLCanvasElement."))})})},e.prototype._decodeCanvas=function(n,o){var t=this;return new T.Promise(function(t){if(!(n instanceof HTMLCanvasElement))throw TypeError("'_decodeCanvas(canvas, templateName)': Type of 'canvas' should be 'HTMLCanvasElement'.");if(n.crossOrigin&&"anonymous"!=n.crossOrigin)throw"cors";o=o||"",n.toBlob?n.toBlob(function(e){t(e)}):n.msToBlob?n.msToBlob(function(e){t(e)}):t(n.toDataURL())}).then(function(e){return n.toBlob||n.msToBlob?t._decodeBlob(e,o):t._decodeBase64(e,o)})},e.prototype._decodeVideo=function(d){var s,t=this,c=arguments;return new T.Promise(function(e){if(!(d instanceof HTMLVideoElement))throw TypeError("'_decodeVideo(video [ [, sx, sy, sWidth, sHeight], dWidth, dHeight] [, templateName] )': Type of 'video' should be 'HTMLVideoElement'.");if(d.crossOrigin&&"anonymous"!=d.crossOrigin)throw"cors";c.length<=2?(t=n=0,o=i=d.videoWidth,r=a=d.videoHeight):a=c.length<=4?(t=n=0,o=d.videoWidth,r=d.videoHeight,i=c[1],c[2]):(t=c[1],n=c[2],o=c[3],r=c[4],i=c[5],c[6]),s="string"==typeof c[c.length-1]?c[c.length-1]:"";var t,n,o,r,i,a,_=document.createElement("canvas");_.width=i,_.height=a,_.getContext("2d").drawImage(d,t,n,o,r,0,0,i,a),e(_)}).then(function(e){return t._decodeCanvas(e,s)})},e.prototype._decodeBase64=e.prototype.decodeBase64String=function(t,e){var n=this;return new T.Promise(function(e){if(!("string"==typeof t||"object"==typeof t&&t instanceof String))throw TypeError("'decodeBase64(base64Str, templateName)': Type of 'base64Str' should be 'String'.");"data:image/"==t.substring(0,11)&&(t=t.substring(t.indexOf(",")+1)),e()}).then(function(){return n._innerDecode(1,t,e)})},e.prototype._decodeUrl=function(o,r){var t=this;return o&&o.indexOf&&(0==o.indexOf("dwt://")||0==o.indexOf("dcs://"))?t._decodeDynamsoftServiceInnerUrl(o,r):new T.Promise(function(e,t){var n;if(!("string"==typeof o||"object"==typeof o&&o instanceof String))throw TypeError("'_decodeUrl(url, templateName)': Type of 'url' should be 'String'.");r=r||"",u._activeXInstance?((n=new ActiveXObject("MSXML2.XMLHTTP")).open("GET",o,!0),n.overrideMimeType?n.overrideMimeType("text/plain; charset=x-user-defined"):n.setRequestHeader("Accept-Charset","x-user-defined"),n.onreadystatechange=function(){4==n.readyState&&e(new VBArray(n.responseBody).toArray())},n.send("")):((n=new XMLHttpRequest).open("GET",o,!0),n.responseType="arraybuffer",n.send(),n.onloadend=function(){e(this.response)},n.onerror=function(){t(Error(n.error))})}).then(function(e){return u._activeXInstance?t._activeXDecodeArray(e,r):t._decodeArrayBuffer(e,r)})},e.prototype._decodeDynamsoftServiceInnerUrl=function(t,e){var n=this;return new T.Promise(function(e){if(!("string"==typeof t||"object"==typeof t&&t instanceof String))throw TypeError("'_decodeUrl(url, templateName)': Type of 'innerUrl' should be 'String'.");if(0!=t.indexOf("dwt://")&&0!=t.indexOf("dcs://"))throw TypeError("'_decodeDynamsoftServiceInnerUrl(innerUrl, templateName)': 'innerUrl' should start with 'dwt://' or 'dcs://'.");e()}).then(function(){return n._innerDecode(4e3,t,e)})},e.prototype._activeXDecodeArray=function(n,o){var t=this;return new T.Promise(function(e,t){if(!(n instanceof Array))throw TypeError("'_activeXDecodeArray(array, templateName)': Type of 'array' should be 'Array'.");o=o||"";try{e(Dynamsoft.Lib.btoa(String.fromCharCode.apply(String,n)))}catch(e){t(e)}}).then(function(e){return t._decodeBase64(e,o)})},e.prototype._activeXDecodeHandle=function(e,t){var n=this;return new T.Promise(function(e){t=t||"",e()}).then(function(){return n._innerDecode(4001,e,t)})},e.prototype._decode=e.prototype.decode=function(e,t){return u._activeXInstance?"string"==typeof e||e instanceof String?this._activeXDecodeHandle(e,t):T.Promise.reject(TypeError("'_decode(source, templateName)' in activeX: Type of 'source' should be 'String(partUrl)'.")):self.Blob&&e instanceof Blob?this._decodeBlob(e,t):self.ArrayBuffer&&e instanceof ArrayBuffer?this._decodeArrayBuffer(e,t):self.Uint8Array&&e instanceof Uint8Array||self.Uint8ClampedArray&&e instanceof Uint8ClampedArray?this._decodeUint8Array(e,t):e instanceof Array?this._activeXDecodeArray(e,t):self.HTMLImageElement&&e instanceof HTMLImageElement?this._decodeImage(e,t):self.HTMLCanvasElement&&e instanceof HTMLCanvasElement?this._decodeCanvas(e,t):self.HTMLVideoElement&&e instanceof HTMLVideoElement?this._decodeVideo(e,t):isNaN(e)?"string"==typeof e||e instanceof String?"data:image/"==e.substring(0,11)?this._decodeBase64(e,t):this._decodeUrl(e,t):T.Promise.reject(TypeError("'_decode(source, templateName)' in H5: Type of 'source' should be 'Blob', 'ArrayBuffer', 'Uint8Array', 'HTMLImageElement', 'HTMLCanvasElement', 'HTMLVideoElement', 'String(base64 with image mime)' or 'String(url)'.")):this._activeXDecodeHandle(e,t)},e.prototype._innerServiceCmd=function(r,i){var a=this._stwain;return new T.Promise(function(t,n){var e,o={method:"ReadBarcode",parameter:[Dynamsoft.Lib.product.refProductKey,4002,"",""],updateSettings:r,initSettingsContent:i};u._activeXInstance?t(u._activeXInstance.Process(T.stringify(o),location.protocol+"//"+location.host)):(a._blts?(e="",a&&a._bRemoteMode&&a._dmService&&a._dmService.attrs&&a._dmService.attrs.UUID&&(e=a._dmService.attrs.UUID),Dynamsoft.DWT.lglic(Dynamsoft.DWT.EnumInstance.dwt_desktop,e).then(function(e){return o.parameter.push(e.ar),o.parameter.push(e.cu),o.parameter.push(0),o.parameter.push(""),T.stringify(o)})):T.Promise.resolve(T.stringify(o))).then(function(e){return T.fetch(a._dbrUrlRoot+"ReadBarcode",{mode:"cors",method:"post",body:e,dataType:"arrayBuffer"})}).then(function(e){M(e)?t(String.fromCharCode.apply(null,new Uint8Array(e))):t(e)},function(e){var t="Init template & runtimeSettings failed.";e&&(t=[t," Http info: ",e.errorString," (",e.httpCode,")"].join("")),n(t)})})},e.prototype._innerDecode=function(i,a,_,d){var R=this;return R._runtimeSettings&&0==R._runtimeSettings.expectedBarcodesCount&&(R._runtimeSettings.expectedBarcodesCount=512),new T.Promise(function(s,c){function o(e,t,n){try{var o,r,i,a,_=E&&E(e);for(_&&_.textResults||c(new u.BarcodeReaderException(_.exception,_.description)),T.product.bHTML5Edition&&n&&n.config.data&&(o=T.parse(n.config.data),T.isArray(o.parameter))&&2<o.parameter.length&&4e3==o.parameter[1]&&(4<o.parameter.length&&o.parameter[4]?_.textResults.imageid=o.parameter[4]:0<=(a=(i=o.parameter[2]).indexOf("&index="))&&(_.textResults.imageid=i.substring(a+7,i.indexOf("&t=")))),r=0;r<_.textResults.length;r++){var d=_.textResults[r];d.BarcodeText=d.barcodeText,_.exception!=Dynamsoft.DBR.EnumErrorCode.DBR_SUCCESS&&(d.exception=_.exception)}_.exception!=Dynamsoft.DBR.EnumErrorCode.DBR_SUCCESS&&(_.textResults.exception=_.exception,_.textResults.description=_.description),u._activeXInstance&&_.records&&(Dynamsoft.Lib.each(_.records,function(e,t){Dynamsoft.DWT.lavrf(t,e,Dynamsoft.DWT.EnumInstance.dwt_desktop)}),Dynamsoft.DWT.lavrf_(1,Dynamsoft.DWT.EnumInstance.dwt_desktop)),s(_.textResults)}catch(e){c(e)}}var t,e,n={method:"ReadBarcode",parameter:[Dynamsoft.Lib.product.refProductKey,i,0!=i?a:null,_||""],updateSettings:R._runtimeSettings,conflictMode:1==R.conflictMode?"ignore":"overwrite",initSettingsContent:R._initSettingsContent,tplContent:function(){if(_)for(var e=0;e<R._tplContentArr.length;++e)if(_==R._tplContentArr[e].ImageParameter.Name)return T.stringify(R._tplContentArr[e]);return null}()},r=R._stwain;u._activeXInstance?r._blts?Dynamsoft.DWT.lglic(Dynamsoft.DWT.EnumInstance.dwt_desktop,"").then(function(e){n.parameter.push(e.ar),n.parameter.push(e.cu),n.parameter.push(0),n.parameter.push(""),o(u._activeXInstance.Process(T.stringify(n),location.protocol+"//"+location.host))}):o(u._activeXInstance.Process(T.stringify(n),location.protocol+"//"+location.host)):(t=r._dbrUrlRoot+"ReadBarcode",0==i&&(t+="/LoadZipFromBytes?cmd="+encodeURIComponent(T.stringify(n))),(0==i?T.Promise.resolve(a):r._blts?(e="",r&&r._bRemoteMode&&r._dmService&&r._dmService.attrs&&r._dmService.attrs.UUID&&(e=r._dmService.attrs.UUID),Dynamsoft.DWT.lglic(Dynamsoft.DWT.EnumInstance.dwt_desktop,e).then(function(e){return n.parameter.push(e.ar),n.parameter.push(e.cu),n.parameter.push(0),n.parameter.push([T.product.getDWTPrefix(),T.product.getServerVersionInfo(),"/verify?id=",d,"&t=",T.getRandom()].join("")),T.stringify(n)})):T.Promise.resolve(T.stringify(n))).then(function(e){return T.fetch(t,{mode:"cors",method:"post",body:e,dataType:"arrayBuffer"})}).then(function(e,t,n){M(e)?o(String.fromCharCode.apply(null,new Uint8Array(e)),0,n):o(e,0,n)},function(e){var t="ReadBarcode request fail.";e&&(t=[t," Http info: ",e.errorString," (",e.httpCode,")"].join("")),c(Error(t))}))})},E=u._handleRetJsonString=function(t){var n;if("string"==typeof t||"object"==typeof t&&t instanceof String)try{n=T.parse(t)}catch(e){n=T.parse(u.RemoveNonPrintableChar(t))}else n=t;if(!n)throw u.BarcodeReaderException(Dynamsoft.DBR.EnumErrorCode.DBR_UNKNOWN,u.errors.decodeResultEmpty);if("textResults"in n&&T.isArray(n.textResults)||n.exception==Dynamsoft.DBR.EnumErrorCode.DBR_SUCCESS)return n;throw u.BarcodeReaderException(n.exception,n.description)},e.prototype.getAllParameterTemplateNames=function(){for(var e=[],t=0;t<this._tplContentArr.length;++t)e.push(this._tplContentArr[t].ImageParameter.Name);return e},e.prototype.getRuntimeSettings=function(){return this._runtimeSettings||(this._runtimeSettings=T.parse(u._defaultRuntimeSettingsStr)),T.Promise.resolve(this._runtimeSettings)};return e.prototype.updateRuntimeSettings=function(e){var t,n=this;if("string"==typeof e||"object"==typeof e&&e instanceof String){if("speed"==e||"balance"==e||"coverage"==e||"default"==e)return n.initRuntimeSettingsWithString("speed"==e?'{"ImageParameter":{"AccompanyingTextRecognitionModes":[{"Mode":"ATRM_SKIP"}],"BarcodeColourModes":[{"LightReflection":1,"Mode":"BICM_DARK_ON_LIGHT"}],"BarcodeComplementModes":[{"Mode":"BCM_SKIP"}],"BarcodeFormatIds":["BF_ALL"],"BarcodeFormatIds_2":["BF2_POSTALCODE","BF2_DOTCODE"],"BinarizationModes":[{"BlockSizeX":0,"BlockSizeY":0,"EnableFillBinaryVacancy":1,"ImagePreprocessingModesIndex":-1,"Mode":"BM_LOCAL_BLOCK","ThreshValueCoefficient":10}],"ColourClusteringModes":[{"Mode":"CCM_SKIP"}],"ColourConversionModes":[{"BlueChannelWeight":-1,"GreenChannelWeight":-1,"Mode":"CICM_GENERAL","RedChannelWeight":-1}],"DPMCodeReadingModes":[{"Mode":"DPMCRM_SKIP"}],"DeblurLevel":3,"DeformationResistingModes":[{"Mode":"DRM_SKIP"}],"Description":"","ExpectedBarcodesCount":512,"FormatSpecificationNameArray":null,"GrayscaleTransformationModes":[{"Mode":"GTM_ORIGINAL"}],"ImagePreprocessingModes":[{"Mode":"IPM_GENERAL"}],"IntermediateResultSavingMode":{"Mode":"IRSM_MEMORY"},"IntermediateResultTypes":["IRT_NO_RESULT"],"LocalizationModes":[{"Mode":"LM_CONNECTED_BLOCKS"},{"Mode":"LM_STATISTICS_MARKS"},{"Mode":"LM_STATISTICS_POSTAL_CODE"}],"MaxAlgorithmThreadCount":4,"Name":"bestSpeed","PDFRasterDPI":300,"PDFReadingMode":{"Mode":"PDFRM_AUTO"},"Pages":"","RegionDefinitionNameArray":null,"RegionPredetectionModes":[{"Mode":"RPM_GENERAL"}],"ResultCoordinateType":"RCT_PIXEL","ReturnBarcodeZoneClarity":0,"ScaleDownThreshold":2300,"ScaleUpModes":[{"Mode":"SUM_AUTO"}],"TerminatePhase":"TP_BARCODE_RECOGNIZED","TextAssistedCorrectionMode":{"BottomTextPercentageSize":0,"LeftTextPercentageSize":0,"Mode":"TACM_VERIFYING","RightTextPercentageSize":0,"TopTextPercentageSize":0},"TextFilterModes":[{"Mode":"TFM_SKIP"}],"TextResultOrderModes":[{"Mode":"TROM_CONFIDENCE"},{"Mode":"TROM_POSITION"},{"Mode":"TROM_FORMAT"}],"TextureDetectionModes":[{"Mode":"TDM_GENERAL_WIDTH_CONCENTRATION","Sensitivity":5}],"Timeout":10000},"Version":"3.0"}':"balance"==e?'{"ImageParameter":{"AccompanyingTextRecognitionModes":[{"Mode":"ATRM_SKIP"}],"BarcodeColourModes":[{"LightReflection":1,"Mode":"BICM_DARK_ON_LIGHT"}],"BarcodeComplementModes":[{"Mode":"BCM_SKIP"}],"BarcodeFormatIds":["BF_ALL"],"BarcodeFormatIds_2":["BF2_POSTALCODE","BF2_DOTCODE"],"BinarizationModes":[{"BlockSizeX":0,"BlockSizeY":0,"EnableFillBinaryVacancy":1,"ImagePreprocessingModesIndex":-1,"Mode":"BM_LOCAL_BLOCK","ThreshValueCoefficient":10}],"ColourClusteringModes":[{"Mode":"CCM_SKIP"}],"ColourConversionModes":[{"BlueChannelWeight":-1,"GreenChannelWeight":-1,"Mode":"CICM_GENERAL","RedChannelWeight":-1}],"DPMCodeReadingModes":[{"Mode":"DPMCRM_SKIP"}],"DeblurLevel":5,"DeformationResistingModes":[{"Mode":"DRM_SKIP"}],"Description":"","ExpectedBarcodesCount":512,"FormatSpecificationNameArray":null,"GrayscaleTransformationModes":[{"Mode":"GTM_ORIGINAL"}],"ImagePreprocessingModes":[{"Mode":"IPM_GENERAL"}],"IntermediateResultSavingMode":{"Mode":"IRSM_MEMORY"},"IntermediateResultTypes":["IRT_NO_RESULT"],"LocalizationModes":[{"Mode":"LM_CONNECTED_BLOCKS"},{"Mode":"LM_STATISTICS"},{"Mode":"LM_STATISTICS_MARKS"},{"Mode":"LM_STATISTICS_POSTAL_CODE"}],"MaxAlgorithmThreadCount":4,"Name":"balance","PDFRasterDPI":300,"PDFReadingMode":{"Mode":"PDFRM_AUTO"},"Pages":"","RegionDefinitionNameArray":null,"RegionPredetectionModes":[{"Mode":"RPM_GENERAL"}],"ResultCoordinateType":"RCT_PIXEL","ReturnBarcodeZoneClarity":0,"ScaleDownThreshold":2300,"ScaleUpModes":[{"Mode":"SUM_AUTO"}],"TerminatePhase":"TP_BARCODE_RECOGNIZED","TextAssistedCorrectionMode":{"BottomTextPercentageSize":0,"LeftTextPercentageSize":0,"Mode":"TACM_VERIFYING","RightTextPercentageSize":0,"TopTextPercentageSize":0},"TextFilterModes":[{"MinImageDimension":65536,"Mode":"TFM_GENERAL_CONTOUR","Sensitivity":0}],"TextResultOrderModes":[{"Mode":"TROM_CONFIDENCE"},{"Mode":"TROM_POSITION"},{"Mode":"TROM_FORMAT"}],"TextureDetectionModes":[{"Mode":"TDM_GENERAL_WIDTH_CONCENTRATION","Sensitivity":5}],"Timeout":10000},"Version":"3.0"}':"coverage"==e?'{"ImageParameter":{"AccompanyingTextRecognitionModes":[{"Mode":"ATRM_SKIP"}],"BarcodeColourModes":[{"LightReflection":1,"Mode":"BICM_DARK_ON_LIGHT"}],"BarcodeComplementModes":[{"Mode":"BCM_SKIP"}],"BarcodeFormatIds":["BF_ALL"],"BarcodeFormatIds_2":["BF2_POSTALCODE","BF2_DOTCODE"],"BinarizationModes":[{"BlockSizeX":0,"BlockSizeY":0,"EnableFillBinaryVacancy":1,"ImagePreprocessingModesIndex":-1,"Mode":"BM_LOCAL_BLOCK","ThreshValueCoefficient":10}],"ColourClusteringModes":[{"Mode":"CCM_SKIP"}],"ColourConversionModes":[{"BlueChannelWeight":-1,"GreenChannelWeight":-1,"Mode":"CICM_GENERAL","RedChannelWeight":-1}],"DPMCodeReadingModes":[{"Mode":"DPMCRM_SKIP"}],"DeblurLevel":9,"DeformationResistingModes":[{"Mode":"DRM_SKIP"}],"Description":"","ExpectedBarcodesCount":512,"FormatSpecificationNameArray":null,"GrayscaleTransformationModes":[{"Mode":"GTM_ORIGINAL"},{"Mode":"GTM_INVERTED"}],"ImagePreprocessingModes":[{"Mode":"IPM_GENERAL"}],"IntermediateResultSavingMode":{"Mode":"IRSM_MEMORY"},"IntermediateResultTypes":["IRT_NO_RESULT"],"LocalizationModes":[{"Mode":"LM_CONNECTED_BLOCKS"},{"Mode":"LM_SCAN_DIRECTLY","ScanDirection":0,"ScanStride":0},{"Mode":"LM_STATISTICS"},{"Mode":"LM_LINES"},{"Mode":"LM_STATISTICS_MARKS"},{"Mode":"LM_STATISTICS_POSTAL_CODE"}],"MaxAlgorithmThreadCount":4,"Name":"coverage","PDFRasterDPI":300,"PDFReadingMode":{"Mode":"PDFRM_AUTO"},"Pages":"","RegionDefinitionNameArray":null,"RegionPredetectionModes":[{"Mode":"RPM_GENERAL"}],"ResultCoordinateType":"RCT_PIXEL","ReturnBarcodeZoneClarity":0,"ScaleDownThreshold":214748347,"ScaleUpModes":[{"Mode":"SUM_AUTO"}],"TerminatePhase":"TP_BARCODE_RECOGNIZED","TextAssistedCorrectionMode":{"BottomTextPercentageSize":0,"LeftTextPercentageSize":0,"Mode":"TACM_VERIFYING","RightTextPercentageSize":0,"TopTextPercentageSize":0},"TextFilterModes":[{"MinImageDimension":65536,"Mode":"TFM_GENERAL_CONTOUR","Sensitivity":0}],"TextResultOrderModes":[{"Mode":"TROM_CONFIDENCE"},{"Mode":"TROM_POSITION"},{"Mode":"TROM_FORMAT"}],"TextureDetectionModes":[{"Mode":"TDM_GENERAL_WIDTH_CONCENTRATION","Sensitivity":5}],"Timeout":10000},"Version":"3.0"}':'{"ImageParameter":{"AccompanyingTextRecognitionModes":[{"Mode":"ATRM_SKIP"}],"BarcodeColourModes":[{"LightReflection":1,"Mode":"BICM_DARK_ON_LIGHT"}],"BarcodeComplementModes":[{"Mode":"BCM_SKIP"}],"BarcodeFormatIds":["BF_ALL"],"BarcodeFormatIds_2":null,"BinarizationModes":[{"BlockSizeX":0,"BlockSizeY":0,"EnableFillBinaryVacancy":1,"ImagePreprocessingModesIndex":-1,"Mode":"BM_LOCAL_BLOCK","ThreshValueCoefficient":10}],"ColourClusteringModes":[{"Mode":"CCM_SKIP"}],"ColourConversionModes":[{"BlueChannelWeight":-1,"GreenChannelWeight":-1,"Mode":"CICM_GENERAL","RedChannelWeight":-1}],"DPMCodeReadingModes":[{"Mode":"DPMCRM_SKIP"}],"DeblurLevel":9,"DeformationResistingModes":[{"Mode":"DRM_SKIP"}],"Description":"","ExpectedBarcodesCount":512,"FormatSpecificationNameArray":null,"GrayscaleTransformationModes":[{"Mode":"GTM_ORIGINAL"}],"ImagePreprocessingModes":[{"Mode":"IPM_GENERAL"}],"IntermediateResultSavingMode":{"Mode":"IRSM_MEMORY"},"IntermediateResultTypes":["IRT_NO_RESULT"],"LocalizationModes":[{"Mode":"LM_CONNECTED_BLOCKS"},{"Mode":"LM_SCAN_DIRECTLY","ScanDirection":0,"ScanStride":0},{"Mode":"LM_STATISTICS"},{"Mode":"LM_LINES"}],"MaxAlgorithmThreadCount":4,"Name":"default","PDFRasterDPI":300,"PDFReadingMode":{"Mode":"PDFRM_AUTO"},"Pages":"","RegionDefinitionNameArray":null,"RegionPredetectionModes":[{"Mode":"RPM_GENERAL"}],"ResultCoordinateType":"RCT_PIXEL","ReturnBarcodeZoneClarity":0,"ScaleDownThreshold":2300,"ScaleUpModes":[{"Mode":"SUM_AUTO"}],"TerminatePhase":"TP_BARCODE_RECOGNIZED","TextAssistedCorrectionMode":{"BottomTextPercentageSize":0,"LeftTextPercentageSize":0,"Mode":"TACM_VERIFYING","RightTextPercentageSize":0,"TopTextPercentageSize":0},"TextFilterModes":[{"MinImageDimension":65536,"Mode":"TFM_GENERAL_CONTOUR","Sensitivity":0}],"TextResultOrderModes":[{"Mode":"TROM_CONFIDENCE"},{"Mode":"TROM_POSITION"},{"Mode":"TROM_FORMAT"}],"TextureDetectionModes":[{"Mode":"TDM_GENERAL_WIDTH_CONCENTRATION","Sensitivity":5}],"Timeout":10000},"Version":"3.0"}');t=e}else{if("object"!=typeof e)throw TypeError("'setTemplateSettings(settings)': Type of 'settings' should be 'String' or 'PlainObject'.");t=T.stringify(e)}e=T.parse(t);return n._runtimeSettings=e,n._initSettingsContent=null,n._innerServiceCmd(n._runtimeSettings,null).then(function(e){e=u._handleRetJsonString(e);return n._runtimeSettings=e.settings,n._runtimeSettings||(n._runtimeSettings=T.parse(u._defaultRuntimeSettingsStr)),e.settings})},e.prototype.resetRuntimeSettings=function(){var t=this;return t._runtimeSettings=T.parse(u._defaultRuntimeSettingsStr),t._initSettingsContent=null,t._innerServiceCmd(t._runtimeSettings,null).then(function(e){e=u._handleRetJsonString(e);return t._runtimeSettings=e.settings,t._runtimeSettings||(t._runtimeSettings=T.parse(u._defaultRuntimeSettingsStr)),e.settings})},e.prototype.outputSettingsToString=function(e){if(!e)return u._defaultTemplateStr;for(var t=0;t<this._tplContentArr.length;++t)if(e==this._tplContentArr[t].ImageParameter.Name)return T.stringify(this._tplContentArr[t])},e.prototype.initRuntimeSettingsWithString=function(e){var t=this;if(T.isString(e))return t._runtimeSettings=null,t._initSettingsContent=T.parse(e),t._innerServiceCmd(null,t._initSettingsContent).then(function(e){e=u._handleRetJsonString(e);return t._runtimeSettings=e.settings,t._runtimeSettings||(t._runtimeSettings=T.parse(u._defaultRuntimeSettingsStr)),e.settings});throw TypeError("'initRuntimeSettingsWithString(settings)': Type of 'settings' should be 'String'.")},e}(),u._dbr_ax=!1,u._dbr=!1,u._initH5=function(r,n,o){return new T.Promise(function(e,t){r._bRemoteMode&&r._dmService&&r._dmService.attrs&&r._dmService.attrs.url&&(r._dbrUrlRoot=r._dmService.attrs.url+"dcp/dbr_"+u.Version.replace(/\./g,"")+"/"),r._dbrUrlRoot||(r._dbrUrlRoot=Dynamsoft.DWT.NetManager.getModuleUrl("dcp/dbr_"+u.Version.replace(/\./g,"")+"/"));var n=5,o={method:"POST",url:r._dbrUrlRoot+"VersionInfo?t="+T.getRandom(),data:'{"method":"VersionInfo"}',onSuccess:function(){e()},onError:function(){if(--n<=0)return t("Failed to connect to the Barcode Reader Add-on, the library may be missing in the Dynamic Web TWAIN Service directory.");setTimeout(function(){T.ajax(o)},300)},dataType:"json",async:!0,timeout:800};T.ajax(o)}).then(function(){return u._dbr=new u.Class(r),u._dbr._innerServiceCmd(null,null)}).then(function(e){try{var t=u._handleRetJsonString(e);u._dbr._runtimeSettings=t.settings,u._defaultRuntimeSettingsStr=T.stringify(t.settings),u._defaultTemplateStr=T.stringify(t.outputSettings),n(u._dbr)}catch(e){o(Error("Init template & runtimeSettings failed: "+e.message)||e)}},function(e){o(e)})},u.dbrInitPromiseFun=function(n){return new T.Promise(function(e,t){u.innerDbrInit(n,e,t)})},u.innerDbrInit=function(e,t,n){var o=!1,r=!1,i=(T.product.bHTML5Edition?o=!0:r=!0,Dynamsoft.BarcodeReaderAddon);if(o){if(i._dbr)return void t(i._dbr)}else if(r&&i._dbr_ax)return void t(i._dbr_ax);if(o&&i._initH5(e,t,n),r){o=Dynamsoft.navInfoSync,r={method:"ReadBarcode",parameter:[Dynamsoft.Lib.product.refProductKey,4002,"",""]};if(!o.bIE)return n(Error("The DBR init error."));try{i._activeXInstance=new ActiveXObject("DBRModule.AtlDBR");var a,_=i._activeXInstance.Process(T.stringify(r),location.protocol+"//"+location.host),d=T.parse(_);return d?"settings"in d?(i._dbr_ax=new i.Class(e),i._dbr_ax._runtimeSettings=d.settings,i._defaultRuntimeSettingsStr=T.stringify(d.settings),"outputSettings"in d&&(i._defaultTemplateStr=T.stringify(d.outputSettings)),void t(i._dbr_ax)):(a=d.description||"The DBR init error.",n(Error(a))):n(Error("The DBR init error."))}catch(e){return n(Error("The DBR .dll is missing or not accessible: "+(e.message||e)))}}},T.DynamicLoadAddonFuns&&T.DynamicLoadAddonFuns.push(function(a){if(t=a._b64bit?"dbrx64_"+Dynamsoft.BarcodeReaderAddon.Version+".dll":"dbr_"+Dynamsoft.BarcodeReaderAddon.Version+".dll",T.product.bHTML5Edition)try{a._innerSend("GetAddOnVersion",T.html5.Funs.makeParams("barcodereader",t),!0,!1,!1).catch(function(){})}catch(e){}function n(e){return!T.License.checkProductKey(e,{Core:!0})||!!(Dynamsoft.Lib.env.bMobile)&&(e._errorCode=Dynamsoft.DBR.EnumErrorCode.DBR_UNKNOWN,e._errorString=u.errors.ServiceEditionNotSupportDbr,!0)}var e={BarcodeReader:{decode:function(t){return n(a)?T.Promise.reject(u.BarcodeReaderException(a._errorCode,a._errorString)):!T.isNumber(t)||t<0||t>=a.HowManyImagesInBuffer?(T.Errors.IndexOutOfRange(a),T.Promise.reject(u.BarcodeReaderException(a._errorCode,a._errorString))):new T.Promise(function(e){u._decoding?u._decodeQueue.push({method:e,args:[t]}):(u._decoding=!0,e(t))}).then(function(e){var i;if(T.product.bHTML5Edition){if(-1==(i=a._ImgManager.convertClientIndexToServerId(e)))throw T.Errors.IndexOutOfRange(a),setTimeout(u._decodeNext,0),u.BarcodeReaderException(a._errorCode,a._errorString)}else i=e;return new T.Promise(function(o,r){u.dbrInitPromiseFun(a).then(function(e){var t;if(!T.product.bHTML5Edition)return t=i,n=a.GetImagePartURL(t,-1,-1),e._innerDecode(4001,n,"").then(function(e){e.imageid=a.IndexToImageID(t),setTimeout(u._decodeNext,0),o(e)},function(e){setTimeout(u._decodeNext,0),r(e)});t=a._ImgManager.convertServerIdToClientIndex(i);var n=a.GetImagePartURL(t,-1,-1);return e._innerDecode(4e3,n,"",a._clientId).then(function(e){e.imageid=a.IndexToImageID(t),setTimeout(u._decodeNext,0),o(e),a._blts&&Dynamsoft.DWT.lcvrf(a)},function(e){setTimeout(u._decodeNext,0),r(e)})},function(e){setTimeout(u._decodeNext,0),r(e)})})})},resetRuntimeSettings:function(){return n(a)?T.Promise.reject(u.BarcodeReaderException(a._errorCode,a._errorString)):u.dbrInitPromiseFun(a).then(function(e){return e.resetRuntimeSettings()})},getRuntimeSettings:function(e){return n(a)?T.Promise.reject(u.BarcodeReaderException(a._errorCode,a._errorString)):!T.isString(e)||"speed"!=e&&"balance"!=e&&"coverage"!=e&&"default"!=e?u.dbrInitPromiseFun(a).then(function(e){return e.getRuntimeSettings()}):this.updateRuntimeSettings(e)},updateRuntimeSettings:function(t){return n(a)?T.Promise.reject(u.BarcodeReaderException(a._errorCode,a._errorString)):u.dbrInitPromiseFun(a).then(function(e){return e.updateRuntimeSettings(t)})},initRuntimeSettingsWithString:function(t){return n(a)?T.Promise.reject(u.BarcodeReaderException(a._errorCode,a._errorString)):u.dbrInitPromiseFun(a).then(function(e){return e.initRuntimeSettingsWithString(t)})}}};T.product.bHTML5Edition?(a.__addon=a.__addon||{},T.mix(a.__addon,e)):(a.Addon=a.Addon||{},T.mix(a.Addon,e))})});