Socket
Socket
Sign inDemoInstall

dynamsoft-javascript-barcode

Package Overview
Dependencies
Maintainers
1
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dynamsoft-javascript-barcode - npm Package Compare versions

Comparing version 6.5.1 to 6.5.2

dist/dbr-6.5.1.d.ts

429

dist/dbr.d.ts

@@ -0,1 +1,13 @@

/**
* Dynamsoft JavaScript Library
* @product Dynamsoft Barcode Reader JS Edition
* @website http://www.dynamsoft.com
* @preserve Copyright 2019, Dynamsoft Corporation
* @author Dynamsoft
* @version 6.5.1
* @fileoverview Dynamsoft JavaScript Library for Barcode Reader
* More info on DBR JS: https://www.dynamsoft.com/Products/barcode-recognition-javascript.aspx
*/
//https://github.com/TypeStrong/typedoc to build doc
declare namespace dynamsoft{

@@ -5,6 +17,7 @@ /**

* ```html
* <script src='dbr-6.5.0.3.min.js'></script>
* <script src='dbr-6.5.1.min.js'></script>
* <script>
* // https://www.dynamsoft.com/CustomerPortal/Portal/TrialLicense.aspx
* dbr.licenseKey = 't0068MgAAAFp16mlue6QjhALowH1tFQxdNVNrtUjMSK8RDezLrZkGAP1TelJQ0cLBLi/BxG3ksSIsZjY3IJX+UVauIe5Zdh4=';
* dbr.createInstance().then(reader=>reader.decode('https://www.keillion.site/img/TestSmall.jpg')).then(r=>{console.log(r)});
* dbr.createInstance().then(reader=>reader.decode('./TestSmall.jpg')).then(r=>{console.log(r)});
* </script>

@@ -14,62 +27,209 @@ * ```

class BarcodeReader{
/**
* Set the global licenseKey. If you do not specify a new licenseKey when creating a `BarcodeReader` object, the global licenseKey will be used.
* Refer to https://www.dynamsoft.com/CustomerPortal/Portal/TrialLicense.aspx to get a try licenseKey.
*/
static licenseKey?: string;
static _resourcesPath?: string;
static _workerName?: string;
static _wasmjsName?: string;
static _wasmName?: string;
static _workerResourcePath?: string;
static _wasmjsResourcePath?: string;
static _wasmResourcePath?: string;
static _isShowRelDecodeTimeInResults: boolean;
static _bCustomWorker?: boolean;
static _bWithio?: boolean;
static _onWasmDownloaded?: () => void | any;
/**
* Manually load and compile the decoding module. Used for preloading to avoid taking too long for lazy loading.
* Whether you have not started loading, loading, success, or failure, you can safely call `loadWasm` repeatedly.
* If it has already been loaded, it will return to success immediately.
*/
static loadWasm(): Promise<void>;
/**
* A callback when wasm download success in browser environment.
*/
static _onWasmDownloaded: () => void;
/**
* Determine if the decoding module has been loaded successfully.
*/
static isLoaded(): boolean;
/**
* Create a BarcodeReader object. Can be used only after loading the decoding module.
* @param licenseKey
*/
constructor(licenseKey?: string);
createInstance(licenseKey?: string): Promise<BarcodeReader>;
/**
* Create a BarcodeReader object. If the decoding module is not loaded, it will be loaded automatically.
* @param licenseKey
*/
static createInstance(licenseKey?: string): Promise<BarcodeReader>;
/**
* Destructor the `BarcodeReader` object.
* When the `BarcodeReader` object is created, it will open up a space in memory that cannot be automatically reclaimed by js garbage collection.
* You can manually call this method to destruct the `BarcodeReader` object to release this memory.
*/
deleteInstance(): void;
decodeFileInMemory(source: Blob | ArrayBuffer | Uint8Array |
/**
* The main decoding method can accept a variety of data types, including binary data, images, base64, urls, etc.
* In the nodejs environment:
* <p>&nbsp;&nbsp;The method can accept Buffer, Uint8Array,</p>
* <p>&nbsp;&nbsp;base64 with mimetype, disk relative paths, disk pair paths, and absolute URLs.</p>
* <p>&nbsp;&nbsp;All data should be encoded as either jpg, png, bmp or gif.</p>
* In the browser environment:
* <p>&nbsp;&nbsp;The method can accept Blob, ArrayBuffer,</p>
* <p>&nbsp;&nbsp;Uint8Array, Uint8ClampedArray, HTMLImageElement, HTMLCanvasElement, HTMLVideoElement,</p>
* <p>&nbsp;&nbsp;base64 with mimetype, relative URLs, and absolute URLs.</p>
* <p>&nbsp;&nbsp;For URLs you need to handle cross-domain issues yourself, otherwise the promise will fail.</p>
* <p>&nbsp;&nbsp;Except HTMLCanvasElement and HTMLVideoElement, which have their own format,</p>
* <p>&nbsp;&nbsp;the other Data should be encoded as either jpg, png, bmp or gif.</p>
* @param source
*/
decode(source: Blob | Buffer | ArrayBuffer | Uint8Array |
Uint8ClampedArray | HTMLImageElement | HTMLCanvasElement |
HTMLVideoElement | string): Promise<DecodeResult[]>;
decodeVideo(video: HTMLVideoElement): Promise<DecodeResult[]>;
HTMLVideoElement | string): Promise<BarcodeReader.TextResult[]>;
/**
* Take a frame from the video, and then decode it.
* @param video
*/
decodeVideo(video: HTMLVideoElement): Promise<BarcodeReader.TextResult[]>;
/**
* Take a frame from the video, zoom it to the specified size, and then decode it.
* @param video
* @param dWidth
* @param dHeight
*/
decodeVideo(video: HTMLVideoElement,
dWidth: number, dHeight: number): Promise<DecodeResult[]>;
dWidth: number, dHeight: number): Promise<BarcodeReader.TextResult[]>;
/**
* Take a frame from the specified area of the video, zoom it to the specified size, and then decode it.
* @param video
* @param sx
* @param sy
* @param sWidth
* @param sHeight
* @param dWidth
* @param dHeight
*/
decodeVideo(video: HTMLVideoElement, sx: number, sy: number,
sWidth: number, sHeight: number,
dWidth: number, dHeight: number): Promise<DecodeResult[]>;
decodeBase64String(base64Str: string): Promise<DecodeResult[]>;
dWidth: number, dHeight: number): Promise<BarcodeReader.TextResult[]>;
/**
* Decode base64 type image data with or without minetype.
* @param base64Str
*/
decodeBase64String(base64Str: string): Promise<BarcodeReader.TextResult[]>;
/**
* Decode the raw data from the image acquisition device / the image conversion.
* Such as binary, binaryinverted, grayscaled, NV21, RGB555, RGB565, RGB888, ARGB888.
* @param source
* @param width
* @param height
* @param stride
* @param enumImagePixelFormat
*/
decodeBuffer(source: Blob | ArrayBuffer | Uint8Array | Uint8ClampedArray,
width: number, height: number, stride: number,
enumImagePixelFormat: BarcodeReader.EnumImagePixelFormat): Promise<DecodeResult[]>;//tudo: format
getRuntimeSettings(): RuntimeSettings;
updateRuntimeSettings(settings: RuntimeSettings): Promise<void>;
enumImagePixelFormat: BarcodeReader.EnumImagePixelFormat): Promise<BarcodeReader.TextResult[]>;
/**
* Get current settings and saves it into a struct.
*/
getRuntimeSettings(): BarcodeReader.RuntimeSettings;
/**
* Update runtime settings with a given struct.
* @param settings
*/
updateRuntimeSettings(settings: BarcodeReader.RuntimeSettings): Promise<void>;
/**
* Reset all parameters to default values.
*/
resetRuntimeSettings(): void;
getAllLocalizationResults(): LocalizationResult[];
/**
* Get all localization barcode results. It contains all recognized barcodes and unrecognized barcodes.
*/
getAllLocalizationResults(): BarcodeReader.LocalizationResult[];
}
namespace BarcodeReader{
interface DecodeResult{
interface TextResult{
/**
* The barcode text.
*/
BarcodeText: string;
/**
* The barcode format.
*/
BarcodeFormat: number | EnumBarcodeFormat;
/**
* Barcode type in string.
*/
BarcodeFormatString: string;
/**
* The barcode content in a byte array.
*/
BarcodeBytes: number[];
/**
* The corresponding localization result.
*/
LocalizationResult: LocalizationResult;
/**
* The original video canvas, existed when using a instance of class `Scanner` and set `bAddOriVideoCanvasToResult` as true.
*/
oriVideoCanvas?: HTMLCanvasElement;
/**
* The search region canvas, existed when using a instance of class `Scanner` and set `bAddSearchRegionCanvasToResult` as true.
*/
searchRegionCanvas?: HTMLCanvasElement;
}
interface LocalizationResult{
/**
* The angle of a barcode. Values range from 0 to 360.
*/
Angle: number;
/**
* The document name the barcode located in.
*/
DocumentName: string;
/**
* The barcode module size (the minimum bar width in pixel).
*/
ModuleSize: number;
/**
* The page number the barcode located in. The index is 0-based.
*/
PageNumber: number;
/**
* The region name the barcode located in.
*/
RegionName: string;
/**
* The stage when the results are returned.
*/
TerminateStage: EnumTerminateStage;
/**
* The X coordinate of the left-most point.
*/
X1: number;
/**
* The X coordinate of the second point in a clockwise direction.
*/
X2: number;
/**
* The X coordinate of the third point in a clockwise direction.
*/
X3: number;
/**
* The X coordinate of the fourth point in a clockwise direction.
*/
X4: number;
/**
* The Y coordinate of the left-most point.
*/
Y1: number;
/**
* The Y coordinate of the second point in a clockwise direction.
*/
Y2: number;
/**
* The Y coordinate of the third point in a clockwise direction.
*/
Y3: number;
/**
* The Y coordinate of the fourth point in a clockwise direction.
*/
Y4: number;
/**
* The extended result array.
*/
ExtendedResultArray: ExtendedResult[];

@@ -79,3 +239,9 @@ }

interface ExtendedResult{
/**
* The confidence of the result.
*/
Confidence: number;
/**
* Extended result type.
*/
ResultType: EnumResultType;

@@ -85,21 +251,81 @@ }

interface RuntimeSettings{
/**
* The degree of anti-damage of the barcode. This value decides how many localization algorithms will be used. To ensure the best results, the value of AntiDamageLevel is suggested to be set to 9 if the ExpectedBarcodesCount is set to 0 or 1; otherwise, the value of AntiDamageLevel is suggested to be set to 7.
*/
mAntiDamageLevel: number;
/**
* The types of barcode to be read. Barcode types can be combined as an array. For example, if you want to choose Code_39 and Code_93, you can set it to `EnumBarcodeFormat.CODE_39 | EnumBarcodeFormat.CODE_93`.
*/
mBarcodeFormatIds: number | EnumBarcodeFormat;
/**
* The ink colour for barcodes search.
*/
mBarcodeInvertMode: number;
/**
* The block size for the process of binarization. Block size means the size of a pixel neighbourhood that is used to calculate a threshold value for the pixel.
*/
mBinarizationBlockSize: number;
/**
* Whether to convert colour images. Recommend setting it to "Auto" if you want to pre-detect the barcode regions.
*/
mColourImageConvertMode: number;
/**
* The degree of blurriness of the barcode. The higher value you set, the much more effort the library will take to decode images, but it may also slow down the recognition process.
*/
mDeblurLevel: number;
/**
* For barcodes with a large module size there might be a vacant area in the position detection pattern after binarization which may result in a decoding failure. Setting this to true will fill in the vacant area with black and may help to decode it successfully.
*/
mEnableFillBinaryVacancy: number;
/**
* The expected number of barcodes to read for each image (or each region of the image if you specified barcode regions).
*/
mExpectedBarcodesCount: number;
/**
* The sensitivity used for gray equalization. The higher the value, the more likely gray equalization will be activated. Effective for images with low comparison between black and white colour. May cause adverse effect on images with high level of black and white colour comparison.
*/
mGrayEqualizationSensitivity: number;
/**
* The priority of localization algorithms.
*/
mLocalizationAlgorithmPriority: string;
/**
* The amount of image processing algorithm threads used to decode barcodes.
*/
mMaxAlgorithmThreadCount: number;
/**
* The maximum number of barcodes to read.
*/
mMaxBarcodesCount: number;
/**
* The maximum dimension of full image as barcode zone. Sets the maximum image dimension (in pixels) to localize barcode on the full image. If the image dimension is smaller than the given value, the library will localize barcode on the full image. Otherwise, "FullImageAsBarcodeZone" mode will not be enabled.
*/
mMaxImageDimensionToLocalizeBarcodesOnFullImage: number;
/**
* The output image resolution. When you are trying to decode a PDF file using DecodeFile method, the library will convert the pdf file to image(s) first, then perform barcode recognition.
*/
mPDFRasterDPI: number;
/**
* Values that represent region predetection modes
*/
mRegionPredetectionMode: number;
/**
* Reserved memory for struct. The length of this array indicates the size of the memory reserved for this struct.
*/
mReserved: string;
/**
* The threshold value of the image shrinking. If the shorter edge size is larger than the given value, the library will calculate the required height and width of the barcode image and shrink the image to that size before localization. Otherwise, it will perform barcode localization on the original image.
*/
mScaleDownThreshold: number;
/**
* The text filter mode for barcodes search.
*/
mTextFilterMode: number;
/**
* The sensitivity for texture detection. The higher value you set, the more efforts it will take to detect texture.
*/
mTextureDetectionSensitivity: number;
/**
* The maximum amount of time (in milliseconds) it should spend searching for a barcode per page. It does not include the time taken to load/decode an image (Tiff, PNG, etc) from disk into memory.
*/
mTimeout: number;

@@ -110,52 +336,92 @@ }

* ```js
* var videoReader = new dynamsoft.BarcodeReader.VideoReader({
* var videoReader = new dynamsoft.BarcodeReader.Scanner({
* onFrameRead:function(results){console.log(results);},
* onDiffCodeRead:function(txt, result){alert(txt);}
* onNewCodeRead:function(txt, result){alert(txt);}
* });
* videoReader.read();
* videoReader.open();
* ```
*/
class VideoReader{
constructor(config?: VideoReaderConfig);
isReading: () => boolean;
// The ui element.
class Scanner{
constructor(config?: ScannerConfig);
isOpen: () => boolean;
/**
* The HTML element that will contain the scanner object should you choose to customize the UI. It will have a simple default UI if you keep `htmlElement` undefined in initialization config.
*/
htmlElement: HTMLElement;
// Video play settings.
// Refer [MediaStreamConstraints](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#Syntax).
// Example: { video: { width: 1280, height: 720, facingMode: "environment" } }
// If during reading, need close() then read() to make it effective.
/**
* Video play settings.
* Refer [MediaStreamConstraints](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#Syntax).
* Example: `{ video: { width: 1280, height: 720, facingMode: "environment" } }`.
* If during reading, need close() then open() to make it effective.
*/
videoSettings?: MediaStreamConstraints;
// A raw result, whose confidence equals or larger than the confidence, will be regarded as a reliable result. Dafault 30.
/**
* This property is mainly related to 1D barcodes.
* If the confidence of a 1D barcode result is greater than or equal to this `confidence`, that is a reliable result that might cause `onNewCodeRead`.
* Otherwise if the confidence of a result is smaller than this `confidence`, the result will be ignored by `onNewCodeRead`.
* Default 30.
*/
confidence: number;
// Relex time between two read. Default 100(ms).
/**
* The time interval after the result is found in once reading and before the decoding begins in next reading. Default 100(ms).
*/
intervalTime: number;
// Runtime settings about decoding.
// Refer [RuntimeSettings](https://www.dynamsoft.com/help/Barcode-Reader/struct_dynamsoft_1_1_barcode_1_1_public_runtime_settings.html).
runtimeSettings: DBRPublicRuntimeSettings;
// like (video)=>{return [video, sx, sy, sWidth, sHeight, dWidth, dHeight];}
// also see: [drawImage](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawImage)
beforeDecodeVideo?: (video: HTMLVideoElement) => HTMLVideoElement | any[] | Promise<HTMLVideoElement | any[]>;
// like (config)=>{return config.reader.decodeVideo.apply(config.reader, config.args);}
duringDecodeVideo?: (config: VideoReaderDecodeVideoConfig) => Promise<DBRTextResult[]>;
// The callback will be called after each time decoding.
// Refer [TextResult](https://www.dynamsoft.com/help/Barcode-Reader/class_dynamsoft_1_1_barcode_1_1_text_result.html).
onFrameRead?: (results: DBRTextResult[]) => void;
// One code will be remember for `forgetTime`. After `forgetTime`, when the code comes up again, it will be regard as a new different code.
forgetTime: number;
// When a new different code comes up, the function will be called.
// Refer [TextResult](https://www.dynamsoft.com/help/Barcode-Reader/class_dynamsoft_1_1_barcode_1_1_text_result.html).
onDiffCodeRead?: (txt: string, result: DBRTextResult) => void;
// Strat the video and read barcodes.
read(): Promise<VideoReaderReadCallback>;
// Change video settings during reading
play(deviceId?: string, width?: number, height?: number): Promise<VideoReaderPlayCallback>;
// Pause the video.
/**
* Defines the different settings of the barcode reader itself. Find a full list of these settings and their corresponding descriptions [here](https://www.dynamsoft.com/help/Barcode-Reader/devguide/Template/TemplateSettingsList.html).
*/
runtimeSettings: RuntimeSettings;
/**
* Like `{sx:0, sy:0, sWidth:200, sHeight:200, dWidth:200, dHeight:200}`.
* Also see: [drawImage](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawImage).
* Or `{sx: 0.2, sy: 0.2, sWidth: 0.6, sHeight: 0.6, dWidth: 0.6, dHeight: 0.6}` to crop center 60% * 60% region.
* Another example, take a center 50% * 50% part of the video and resize the part to 25% * 25% of original video size before decode.
* `{sx: 0.25, sy: 0.25, sWidth: 0.5, sHeight: 0.5, dWidth: 0.25, dHeight: 0.25}`.
*/
searchRegion: ScannerSearchRegion;
/**
* Whether show oriVideoCanvas in result.
*/
bAddOriVideoCanvasToResult: boolean;
/**
* Whether show searchRegionCanvas in result.
*/
bAddSearchRegionCanvasToResult: boolean;
/**
* The event that is triggered once a single frame has been scanned. The results object contains all the barcode results that the reader was able to decode.
*/
onFrameRead?: (results: TextResult[]) => void;
/**
* The amount of time the reader "remembers" a barcode result once a single frame is read. Once the barcode result is obtained, the scanner will not trigger `onNewCodeRead` for the specific barcode again until forgetTime is up.
*/
duplicateForgetTime: number;
/**
* This event is triggered when a not duplicated new barcode is found. `txt` holds the barcode text result. `result` contains the actual barcode result, including the text result. Old barcode will remember for `duplicateForgetTime`.
*/
onNewCodeRead?: (txt: string, result: TextResult) => void;
/**
* Start the video and read barcodes.
*/
open(): Promise<ScannerOpenCallbackInfo>;
/**
* Change video settings during reading.
* @param deviceId
* @param width
* @param height
*/
play(deviceId?: string, width?: number, height?: number): Promise<ScannerPlayCallbackInfo>;
/**
* Pause the video.
*/
pause(): void;
// Close the video.
/**
* Close the video.
*/
close(): void;
// Update device list
updateDevice(): Promise<VideoReaderUpdateDeviceCallback>;
/**
* Update device list
*/
updateDevice(): Promise<ScannerUpdateDeviceCallbackInfo>;
}
interface VideoReaderConfig{
interface ScannerConfig{
htmlElement?: HTMLElement;

@@ -165,8 +431,9 @@ videoSettings?: MediaStreamConstraints;

intervalTime?: number;
runtimeSettings?: DBRPublicRuntimeSettings;
beforeDecodeVideo?: (video: HTMLVideoElement) => Promise<any[]>;
duringDecodeVideo?: (config: VideoReaderDecodeVideoConfig) => Promise<DBRTextResult[]>;
onFrameRead?: (results: DBRTextResult[]) => void;
forgetTime?: number;
onDiffCodeRead?: (txt: string, result: DBRTextResult) => void;
runtimeSettings?: RuntimeSettings;
searchRegion?: ScannerSearchRegion;
bAddOriVideoCanvasToResult?: boolean;
bAddSearchRegionCanvasToResult?: boolean;
onFrameRead?: (results: TextResult[]) => void;
duplicateForgetTime?: number;
onNewCodeRead?: (txt: string, result: TextResult) => void;
}

@@ -179,12 +446,16 @@

interface VideoReaderDecodeVideoConfig{
reader: dynamsoft.BarcodeReader,
args: any[]
interface ScannerSearchRegion{
sx?: number;
sy?: number;
sWidth?: number;
sHeight?: number;
dWidth?: number;
dHeight?: number;
}
interface VideoReaderPlayCallback{
interface ScannerPlayCallbackInfo{
width: number,
height: number
}
interface VideoReaderUpdateDeviceCallback{
interface ScannerUpdateDeviceCallbackInfo{
current?: VideoDeviceInfo,

@@ -194,3 +465,3 @@ all: VideoDeviceInfo[]

interface VideoReaderReadCallback extends VideoReaderPlayCallback, VideoReaderUpdateDeviceCallback {
interface ScannerOpenCallbackInfo extends ScannerPlayCallbackInfo, ScannerUpdateDeviceCallbackInfo {
}

@@ -265,3 +536,5 @@

IPF_RGB_888 = 6,
IPF_ARGB_8888 = 7
IPF_ARGB_8888 = 7,
IPF_RGB_161616 = 8,
IPF_ARGB_16161616 = 9
}

@@ -288,1 +561,5 @@ enum EnumResultType{

}
type BarcodeReader = dynamsoft.BarcodeReader;
type dbr = dynamsoft.BarcodeReader;
export = dynamsoft.BarcodeReader;

@@ -0,1 +1,13 @@

/**
* Dynamsoft JavaScript Library
* @product Dynamsoft Barcode Reader JS Edition
* @website http://www.dynamsoft.com
* @preserve Copyright 2019, Dynamsoft Corporation
* @author Dynamsoft
* @version 6.5.1
* @fileoverview Dynamsoft JavaScript Library for Barcode Reader
* More info on DBR JS: https://www.dynamsoft.com/Products/barcode-recognition-javascript.aspx
*/
//https://github.com/TypeStrong/typedoc to build doc
declare namespace dynamsoft{

@@ -5,6 +17,7 @@ /**

* ```html
* <script src='dbr-6.5.0.3.min.js'></script>
* <script src='dbr-6.5.1.min.js'></script>
* <script>
* // https://www.dynamsoft.com/CustomerPortal/Portal/TrialLicense.aspx
* dbr.licenseKey = 't0068MgAAAFp16mlue6QjhALowH1tFQxdNVNrtUjMSK8RDezLrZkGAP1TelJQ0cLBLi/BxG3ksSIsZjY3IJX+UVauIe5Zdh4=';
* dbr.createInstance().then(reader=>reader.decode('https://www.keillion.site/img/TestSmall.jpg')).then(r=>{console.log(r)});
* dbr.createInstance().then(reader=>reader.decode('./TestSmall.jpg')).then(r=>{console.log(r)});
* </script>

@@ -14,62 +27,209 @@ * ```

class BarcodeReader{
/**
* Set the global licenseKey. If you do not specify a new licenseKey when creating a `BarcodeReader` object, the global licenseKey will be used.
* Refer to https://www.dynamsoft.com/CustomerPortal/Portal/TrialLicense.aspx to get a try licenseKey.
*/
static licenseKey?: string;
static _resourcesPath?: string;
static _workerName?: string;
static _wasmjsName?: string;
static _wasmName?: string;
static _workerResourcePath?: string;
static _wasmjsResourcePath?: string;
static _wasmResourcePath?: string;
static _isShowRelDecodeTimeInResults: boolean;
static _bCustomWorker?: boolean;
static _bWithio?: boolean;
static _onWasmDownloaded?: () => void | any;
/**
* Manually load and compile the decoding module. Used for preloading to avoid taking too long for lazy loading.
* Whether you have not started loading, loading, success, or failure, you can safely call `loadWasm` repeatedly.
* If it has already been loaded, it will return to success immediately.
*/
static loadWasm(): Promise<void>;
/**
* A callback when wasm download success in browser environment.
*/
static _onWasmDownloaded: () => void;
/**
* Determine if the decoding module has been loaded successfully.
*/
static isLoaded(): boolean;
/**
* Create a BarcodeReader object. Can be used only after loading the decoding module.
* @param licenseKey
*/
constructor(licenseKey?: string);
createInstance(licenseKey?: string): Promise<BarcodeReader>;
/**
* Create a BarcodeReader object. If the decoding module is not loaded, it will be loaded automatically.
* @param licenseKey
*/
static createInstance(licenseKey?: string): Promise<BarcodeReader>;
/**
* Destructor the `BarcodeReader` object.
* When the `BarcodeReader` object is created, it will open up a space in memory that cannot be automatically reclaimed by js garbage collection.
* You can manually call this method to destruct the `BarcodeReader` object to release this memory.
*/
deleteInstance(): void;
decodeFileInMemory(source: Blob | ArrayBuffer | Uint8Array |
/**
* The main decoding method can accept a variety of data types, including binary data, images, base64, urls, etc.
* In the nodejs environment:
* <p>&nbsp;&nbsp;The method can accept Buffer, Uint8Array,</p>
* <p>&nbsp;&nbsp;base64 with mimetype, disk relative paths, disk pair paths, and absolute URLs.</p>
* <p>&nbsp;&nbsp;All data should be encoded as either jpg, png, bmp or gif.</p>
* In the browser environment:
* <p>&nbsp;&nbsp;The method can accept Blob, ArrayBuffer,</p>
* <p>&nbsp;&nbsp;Uint8Array, Uint8ClampedArray, HTMLImageElement, HTMLCanvasElement, HTMLVideoElement,</p>
* <p>&nbsp;&nbsp;base64 with mimetype, relative URLs, and absolute URLs.</p>
* <p>&nbsp;&nbsp;For URLs you need to handle cross-domain issues yourself, otherwise the promise will fail.</p>
* <p>&nbsp;&nbsp;Except HTMLCanvasElement and HTMLVideoElement, which have their own format,</p>
* <p>&nbsp;&nbsp;the other Data should be encoded as either jpg, png, bmp or gif.</p>
* @param source
*/
decode(source: Blob | Buffer | ArrayBuffer | Uint8Array |
Uint8ClampedArray | HTMLImageElement | HTMLCanvasElement |
HTMLVideoElement | string): Promise<DecodeResult[]>;
decodeVideo(video: HTMLVideoElement): Promise<DecodeResult[]>;
HTMLVideoElement | string): Promise<BarcodeReader.TextResult[]>;
/**
* Take a frame from the video, and then decode it.
* @param video
*/
decodeVideo(video: HTMLVideoElement): Promise<BarcodeReader.TextResult[]>;
/**
* Take a frame from the video, zoom it to the specified size, and then decode it.
* @param video
* @param dWidth
* @param dHeight
*/
decodeVideo(video: HTMLVideoElement,
dWidth: number, dHeight: number): Promise<DecodeResult[]>;
dWidth: number, dHeight: number): Promise<BarcodeReader.TextResult[]>;
/**
* Take a frame from the specified area of the video, zoom it to the specified size, and then decode it.
* @param video
* @param sx
* @param sy
* @param sWidth
* @param sHeight
* @param dWidth
* @param dHeight
*/
decodeVideo(video: HTMLVideoElement, sx: number, sy: number,
sWidth: number, sHeight: number,
dWidth: number, dHeight: number): Promise<DecodeResult[]>;
decodeBase64String(base64Str: string): Promise<DecodeResult[]>;
dWidth: number, dHeight: number): Promise<BarcodeReader.TextResult[]>;
/**
* Decode base64 type image data with or without minetype.
* @param base64Str
*/
decodeBase64String(base64Str: string): Promise<BarcodeReader.TextResult[]>;
/**
* Decode the raw data from the image acquisition device / the image conversion.
* Such as binary, binaryinverted, grayscaled, NV21, RGB555, RGB565, RGB888, ARGB888.
* @param source
* @param width
* @param height
* @param stride
* @param enumImagePixelFormat
*/
decodeBuffer(source: Blob | ArrayBuffer | Uint8Array | Uint8ClampedArray,
width: number, height: number, stride: number,
enumImagePixelFormat: BarcodeReader.EnumImagePixelFormat): Promise<DecodeResult[]>;//tudo: format
getRuntimeSettings(): RuntimeSettings;
updateRuntimeSettings(settings: RuntimeSettings): Promise<void>;
enumImagePixelFormat: BarcodeReader.EnumImagePixelFormat): Promise<BarcodeReader.TextResult[]>;
/**
* Get current settings and saves it into a struct.
*/
getRuntimeSettings(): BarcodeReader.RuntimeSettings;
/**
* Update runtime settings with a given struct.
* @param settings
*/
updateRuntimeSettings(settings: BarcodeReader.RuntimeSettings): Promise<void>;
/**
* Reset all parameters to default values.
*/
resetRuntimeSettings(): void;
getAllLocalizationResults(): LocalizationResult[];
/**
* Get all localization barcode results. It contains all recognized barcodes and unrecognized barcodes.
*/
getAllLocalizationResults(): BarcodeReader.LocalizationResult[];
}
namespace BarcodeReader{
interface DecodeResult{
interface TextResult{
/**
* The barcode text.
*/
BarcodeText: string;
/**
* The barcode format.
*/
BarcodeFormat: number | EnumBarcodeFormat;
/**
* Barcode type in string.
*/
BarcodeFormatString: string;
/**
* The barcode content in a byte array.
*/
BarcodeBytes: number[];
/**
* The corresponding localization result.
*/
LocalizationResult: LocalizationResult;
/**
* The original video canvas, existed when using a instance of class `Scanner` and set `bAddOriVideoCanvasToResult` as true.
*/
oriVideoCanvas?: HTMLCanvasElement;
/**
* The search region canvas, existed when using a instance of class `Scanner` and set `bAddSearchRegionCanvasToResult` as true.
*/
searchRegionCanvas?: HTMLCanvasElement;
}
interface LocalizationResult{
/**
* The angle of a barcode. Values range from 0 to 360.
*/
Angle: number;
/**
* The document name the barcode located in.
*/
DocumentName: string;
/**
* The barcode module size (the minimum bar width in pixel).
*/
ModuleSize: number;
/**
* The page number the barcode located in. The index is 0-based.
*/
PageNumber: number;
/**
* The region name the barcode located in.
*/
RegionName: string;
/**
* The stage when the results are returned.
*/
TerminateStage: EnumTerminateStage;
/**
* The X coordinate of the left-most point.
*/
X1: number;
/**
* The X coordinate of the second point in a clockwise direction.
*/
X2: number;
/**
* The X coordinate of the third point in a clockwise direction.
*/
X3: number;
/**
* The X coordinate of the fourth point in a clockwise direction.
*/
X4: number;
/**
* The Y coordinate of the left-most point.
*/
Y1: number;
/**
* The Y coordinate of the second point in a clockwise direction.
*/
Y2: number;
/**
* The Y coordinate of the third point in a clockwise direction.
*/
Y3: number;
/**
* The Y coordinate of the fourth point in a clockwise direction.
*/
Y4: number;
/**
* The extended result array.
*/
ExtendedResultArray: ExtendedResult[];

@@ -79,3 +239,9 @@ }

interface ExtendedResult{
/**
* The confidence of the result.
*/
Confidence: number;
/**
* Extended result type.
*/
ResultType: EnumResultType;

@@ -85,21 +251,81 @@ }

interface RuntimeSettings{
/**
* The degree of anti-damage of the barcode. This value decides how many localization algorithms will be used. To ensure the best results, the value of AntiDamageLevel is suggested to be set to 9 if the ExpectedBarcodesCount is set to 0 or 1; otherwise, the value of AntiDamageLevel is suggested to be set to 7.
*/
mAntiDamageLevel: number;
/**
* The types of barcode to be read. Barcode types can be combined as an array. For example, if you want to choose Code_39 and Code_93, you can set it to `EnumBarcodeFormat.CODE_39 | EnumBarcodeFormat.CODE_93`.
*/
mBarcodeFormatIds: number | EnumBarcodeFormat;
/**
* The ink colour for barcodes search.
*/
mBarcodeInvertMode: number;
/**
* The block size for the process of binarization. Block size means the size of a pixel neighbourhood that is used to calculate a threshold value for the pixel.
*/
mBinarizationBlockSize: number;
/**
* Whether to convert colour images. Recommend setting it to "Auto" if you want to pre-detect the barcode regions.
*/
mColourImageConvertMode: number;
/**
* The degree of blurriness of the barcode. The higher value you set, the much more effort the library will take to decode images, but it may also slow down the recognition process.
*/
mDeblurLevel: number;
/**
* For barcodes with a large module size there might be a vacant area in the position detection pattern after binarization which may result in a decoding failure. Setting this to true will fill in the vacant area with black and may help to decode it successfully.
*/
mEnableFillBinaryVacancy: number;
/**
* The expected number of barcodes to read for each image (or each region of the image if you specified barcode regions).
*/
mExpectedBarcodesCount: number;
/**
* The sensitivity used for gray equalization. The higher the value, the more likely gray equalization will be activated. Effective for images with low comparison between black and white colour. May cause adverse effect on images with high level of black and white colour comparison.
*/
mGrayEqualizationSensitivity: number;
/**
* The priority of localization algorithms.
*/
mLocalizationAlgorithmPriority: string;
/**
* The amount of image processing algorithm threads used to decode barcodes.
*/
mMaxAlgorithmThreadCount: number;
/**
* The maximum number of barcodes to read.
*/
mMaxBarcodesCount: number;
/**
* The maximum dimension of full image as barcode zone. Sets the maximum image dimension (in pixels) to localize barcode on the full image. If the image dimension is smaller than the given value, the library will localize barcode on the full image. Otherwise, "FullImageAsBarcodeZone" mode will not be enabled.
*/
mMaxImageDimensionToLocalizeBarcodesOnFullImage: number;
/**
* The output image resolution. When you are trying to decode a PDF file using DecodeFile method, the library will convert the pdf file to image(s) first, then perform barcode recognition.
*/
mPDFRasterDPI: number;
/**
* Values that represent region predetection modes
*/
mRegionPredetectionMode: number;
/**
* Reserved memory for struct. The length of this array indicates the size of the memory reserved for this struct.
*/
mReserved: string;
/**
* The threshold value of the image shrinking. If the shorter edge size is larger than the given value, the library will calculate the required height and width of the barcode image and shrink the image to that size before localization. Otherwise, it will perform barcode localization on the original image.
*/
mScaleDownThreshold: number;
/**
* The text filter mode for barcodes search.
*/
mTextFilterMode: number;
/**
* The sensitivity for texture detection. The higher value you set, the more efforts it will take to detect texture.
*/
mTextureDetectionSensitivity: number;
/**
* The maximum amount of time (in milliseconds) it should spend searching for a barcode per page. It does not include the time taken to load/decode an image (Tiff, PNG, etc) from disk into memory.
*/
mTimeout: number;

@@ -110,52 +336,92 @@ }

* ```js
* var videoReader = new dynamsoft.BarcodeReader.VideoReader({
* var videoReader = new dynamsoft.BarcodeReader.Scanner({
* onFrameRead:function(results){console.log(results);},
* onDiffCodeRead:function(txt, result){alert(txt);}
* onNewCodeRead:function(txt, result){alert(txt);}
* });
* videoReader.read();
* videoReader.open();
* ```
*/
class VideoReader{
constructor(config?: VideoReaderConfig);
isReading: () => boolean;
// The ui element.
class Scanner{
constructor(config?: ScannerConfig);
isOpen: () => boolean;
/**
* The HTML element that will contain the scanner object should you choose to customize the UI. It will have a simple default UI if you keep `htmlElement` undefined in initialization config.
*/
htmlElement: HTMLElement;
// Video play settings.
// Refer [MediaStreamConstraints](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#Syntax).
// Example: { video: { width: 1280, height: 720, facingMode: "environment" } }
// If during reading, need close() then read() to make it effective.
/**
* Video play settings.
* Refer [MediaStreamConstraints](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#Syntax).
* Example: `{ video: { width: 1280, height: 720, facingMode: "environment" } }`.
* If during reading, need close() then open() to make it effective.
*/
videoSettings?: MediaStreamConstraints;
// A raw result, whose confidence equals or larger than the confidence, will be regarded as a reliable result. Dafault 30.
/**
* This property is mainly related to 1D barcodes.
* If the confidence of a 1D barcode result is greater than or equal to this `confidence`, that is a reliable result that might cause `onNewCodeRead`.
* Otherwise if the confidence of a result is smaller than this `confidence`, the result will be ignored by `onNewCodeRead`.
* Default 30.
*/
confidence: number;
// Relex time between two read. Default 100(ms).
/**
* The time interval after the result is found in once reading and before the decoding begins in next reading. Default 100(ms).
*/
intervalTime: number;
// Runtime settings about decoding.
// Refer [RuntimeSettings](https://www.dynamsoft.com/help/Barcode-Reader/struct_dynamsoft_1_1_barcode_1_1_public_runtime_settings.html).
runtimeSettings: DBRPublicRuntimeSettings;
// like (video)=>{return [video, sx, sy, sWidth, sHeight, dWidth, dHeight];}
// also see: [drawImage](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawImage)
beforeDecodeVideo?: (video: HTMLVideoElement) => HTMLVideoElement | any[] | Promise<HTMLVideoElement | any[]>;
// like (config)=>{return config.reader.decodeVideo.apply(config.reader, config.args);}
duringDecodeVideo?: (config: VideoReaderDecodeVideoConfig) => Promise<DBRTextResult[]>;
// The callback will be called after each time decoding.
// Refer [TextResult](https://www.dynamsoft.com/help/Barcode-Reader/class_dynamsoft_1_1_barcode_1_1_text_result.html).
onFrameRead?: (results: DBRTextResult[]) => void;
// One code will be remember for `forgetTime`. After `forgetTime`, when the code comes up again, it will be regard as a new different code.
forgetTime: number;
// When a new different code comes up, the function will be called.
// Refer [TextResult](https://www.dynamsoft.com/help/Barcode-Reader/class_dynamsoft_1_1_barcode_1_1_text_result.html).
onDiffCodeRead?: (txt: string, result: DBRTextResult) => void;
// Strat the video and read barcodes.
read(): Promise<VideoReaderReadCallback>;
// Change video settings during reading
play(deviceId?: string, width?: number, height?: number): Promise<VideoReaderPlayCallback>;
// Pause the video.
/**
* Defines the different settings of the barcode reader itself. Find a full list of these settings and their corresponding descriptions [here](https://www.dynamsoft.com/help/Barcode-Reader/devguide/Template/TemplateSettingsList.html).
*/
runtimeSettings: RuntimeSettings;
/**
* Like `{sx:0, sy:0, sWidth:200, sHeight:200, dWidth:200, dHeight:200}`.
* Also see: [drawImage](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawImage).
* Or `{sx: 0.2, sy: 0.2, sWidth: 0.6, sHeight: 0.6, dWidth: 0.6, dHeight: 0.6}` to crop center 60% * 60% region.
* Another example, take a center 50% * 50% part of the video and resize the part to 25% * 25% of original video size before decode.
* `{sx: 0.25, sy: 0.25, sWidth: 0.5, sHeight: 0.5, dWidth: 0.25, dHeight: 0.25}`.
*/
searchRegion: ScannerSearchRegion;
/**
* Whether show oriVideoCanvas in result.
*/
bAddOriVideoCanvasToResult: boolean;
/**
* Whether show searchRegionCanvas in result.
*/
bAddSearchRegionCanvasToResult: boolean;
/**
* The event that is triggered once a single frame has been scanned. The results object contains all the barcode results that the reader was able to decode.
*/
onFrameRead?: (results: TextResult[]) => void;
/**
* The amount of time the reader "remembers" a barcode result once a single frame is read. Once the barcode result is obtained, the scanner will not trigger `onNewCodeRead` for the specific barcode again until forgetTime is up.
*/
duplicateForgetTime: number;
/**
* This event is triggered when a not duplicated new barcode is found. `txt` holds the barcode text result. `result` contains the actual barcode result, including the text result. Old barcode will remember for `duplicateForgetTime`.
*/
onNewCodeRead?: (txt: string, result: TextResult) => void;
/**
* Start the video and read barcodes.
*/
open(): Promise<ScannerOpenCallbackInfo>;
/**
* Change video settings during reading.
* @param deviceId
* @param width
* @param height
*/
play(deviceId?: string, width?: number, height?: number): Promise<ScannerPlayCallbackInfo>;
/**
* Pause the video.
*/
pause(): void;
// Close the video.
/**
* Close the video.
*/
close(): void;
// Update device list
updateDevice(): Promise<VideoReaderUpdateDeviceCallback>;
/**
* Update device list
*/
updateDevice(): Promise<ScannerUpdateDeviceCallbackInfo>;
}
interface VideoReaderConfig{
interface ScannerConfig{
htmlElement?: HTMLElement;

@@ -165,8 +431,9 @@ videoSettings?: MediaStreamConstraints;

intervalTime?: number;
runtimeSettings?: DBRPublicRuntimeSettings;
beforeDecodeVideo?: (video: HTMLVideoElement) => Promise<any[]>;
duringDecodeVideo?: (config: VideoReaderDecodeVideoConfig) => Promise<DBRTextResult[]>;
onFrameRead?: (results: DBRTextResult[]) => void;
forgetTime?: number;
onDiffCodeRead?: (txt: string, result: DBRTextResult) => void;
runtimeSettings?: RuntimeSettings;
searchRegion?: ScannerSearchRegion;
bAddOriVideoCanvasToResult?: boolean;
bAddSearchRegionCanvasToResult?: boolean;
onFrameRead?: (results: TextResult[]) => void;
duplicateForgetTime?: number;
onNewCodeRead?: (txt: string, result: TextResult) => void;
}

@@ -179,12 +446,16 @@

interface VideoReaderDecodeVideoConfig{
reader: dynamsoft.BarcodeReader,
args: any[]
interface ScannerSearchRegion{
sx?: number;
sy?: number;
sWidth?: number;
sHeight?: number;
dWidth?: number;
dHeight?: number;
}
interface VideoReaderPlayCallback{
interface ScannerPlayCallbackInfo{
width: number,
height: number
}
interface VideoReaderUpdateDeviceCallback{
interface ScannerUpdateDeviceCallbackInfo{
current?: VideoDeviceInfo,

@@ -194,3 +465,3 @@ all: VideoDeviceInfo[]

interface VideoReaderReadCallback extends VideoReaderPlayCallback, VideoReaderUpdateDeviceCallback {
interface ScannerOpenCallbackInfo extends ScannerPlayCallbackInfo, ScannerUpdateDeviceCallbackInfo {
}

@@ -265,3 +536,5 @@

IPF_RGB_888 = 6,
IPF_ARGB_8888 = 7
IPF_ARGB_8888 = 7,
IPF_RGB_161616 = 8,
IPF_ARGB_16161616 = 9
}

@@ -288,2 +561,5 @@ enum EnumResultType{

}
type BarcodeReader = dynamsoft.BarcodeReader;
type dbr = dynamsoft.BarcodeReader;
export default dynamsoft.BarcodeReader;

160

dist/dbr.esm.min.js

@@ -0,58 +1,70 @@

/**
* Dynamsoft JavaScript Library
* @product Dynamsoft Barcode Reader JS Edition
* @website http://www.dynamsoft.com
* @preserve Copyright 2019, Dynamsoft Corporation
* @author Dynamsoft
* @version 6.5.1
* @fileoverview Dynamsoft JavaScript Library for Barcode Reader
* More info on DBR JS: https://www.dynamsoft.com/Products/barcode-recognition-javascript.aspx
*/
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(c){var f=0;return function(){return f<c.length?{done:!1,value:c[f++]}:{done:!0}}};$jscomp.arrayIterator=function(c){return{next:$jscomp.arrayIteratorImpl(c)}};$jscomp.makeIterator=function(c){var f="undefined"!=typeof Symbol&&Symbol.iterator&&c[Symbol.iterator];return f?f.call(c):$jscomp.arrayIterator(c)};var dynamsoft="undefined"!=typeof dynamsoft?dynamsoft:("undefined"!=typeof dynamsoft?this.dynamsoft:void 0)||{};
dynamsoft.TaskQueue=dynamsoft.TaskQueue||function(){var c=function(){this._queue=[];this.isWorking=!1;this.timeout=100};c.prototype.push=function(c,b,e){this._queue.push({task:c,context:b,args:e});this.isWorking||this.next()};c.prototype.unshift=function(c,b,e){this._queue.unshift({task:c,context:b,args:e});this.isWorking||this.next()};c.prototype.next=function(){if(0==this._queue.length)this.isWorking=!1;else{this.isWorking=!0;var c=this._queue.shift(),b=c.task,e=c.context?c.context:null,d=c.args?
c.args:[];setTimeout(function(){b.apply(e,d)},this.timeout)}};return c}();dynamsoft.dbrEnv=dynamsoft.dbrEnv||{};"undefined"!=typeof self?(dynamsoft.dbrEnv._self=self,self.document?dynamsoft.dbrEnv._bDom=!0:dynamsoft.dbrEnv._bWorker=!0):(dynamsoft.dbrEnv._self=global,dynamsoft.dbrEnv._bNodejs=!0);
dynamsoft.BarcodeReader=dynamsoft.BarcodeReader||function(){var c=dynamsoft.dbrEnv,f=c._self,b=function(a){a=a||b.licenseKey||"";if(!("string"==typeof a||"object"==typeof a&&a instanceof String))throw TypeError("'Constructor BarcodeReader(licenseKey)': Type of 'licenseKey' should be 'String'.");this._licenseKey=a;if(b._BarcodeReaderWasm){this._instance=new b._BarcodeReaderWasm(this._licenseKey);if(!this._instance)throw b.BarcodeReaderException(b.EnumErrorCode.DBR_NULL_REFERENCE,"Can't create BarcodeReader instance.");
this._instance.bInWorker&&(this._instance=void 0)}else throw Error("'Constructor BarcodeReader(licenseKey)': Autoload haven't start or you want to call `loadWasm` manually.");};b._jsVersion="6.5.0.3";b._jsEditVersion="20190409";b.version="loading...(JS "+b._jsVersion+"."+b._jsEditVersion+")";b.isLoaded=function(){return"loaded"==this._loadWasmStatus};b.licenseKey=void 0;var e=c._bDom?import.meta.url.substring(0, import.meta.url.lastIndexOf("/")):void 0;b._resourcesPath=e;b._workerName=void 0;b._wasmjsName=void 0;b._wasmName=void 0;b._workerResourcePath=
void 0;b._wasmjsResourcePath=void 0;b._wasmResourcePath=void 0;b._isShowRelDecodeTimeInResults=!1;b._bCustomWorker=void 0;b._bWithio=void 0;b._onWasmDownloaded=void 0;b.createInstance=function(a){return b.loadWasm().then(function(){return Promise.resolve(new b(a))})};var d={};b._loadWorker=function(){return new Promise(function(a,g){var c=b._workerName||"dbr-"+b._jsVersion+".min.js";if(b._workerResourcePath||b._resourcesPath){var n=b._workerResourcePath||b._resourcesPath;"/"!=n.charAt(n.length-1)&&
(n+="/");c=n+c}fetch(c).then(function(a){return a.blob()}).then(function(c){var n=URL.createObjectURL(c);c=b._dbrWorker=new Worker(n);c.onerror=function(a){a="worker error, you should host the page in web service: "+a.message;f.kConsoleLog&&f.kConsoleError(a);g(a)};c.onmessage=function(c){c=c.data;switch(c.type){case "log":f.kConsoleLog&&f.kConsoleLog(c.message);break;case "load":c.success?(b.version=c.version,b._defaultRuntimeSettings=c._defaultRuntimeSettings,f.kConsoleLog&&f.kConsoleLog("load dbr worker success"),
a()):g(c.exception);URL.revokeObjectURL(n);break;case "task":try{d[c.id](c.body),d[c.id]=void 0}catch(k){throw d[c.id]=void 0,k;}break;default:f.kConsoleLog&&f.kConsoleLog(c)}};var e=document.createElement("a");e.href=b._resourcesPath||"./";var l=void 0;b._wasmjsResourcePath&&(l=document.createElement("a"),l.href=b._wasmjsResourcePath||"./",l=l.href);var p=void 0;b._wasmResourcePath&&(p=document.createElement("a"),p.href=b._wasmResourcePath||"./",p=p.href);c.postMessage({type:"loadWorker",_resourcesPath:e.href,
_wasmjsResourcePath:l,_wasmResourcePath:p,origin:location.origin})}).catch(function(a){g(a)})})};b.prototype._createWorkerInstance=function(){var a=this;return new Promise(function(c,l){var g=Math.random();d[g]=function(d){return d.success?d.instanceID?(a._instanceID=d.instanceID,c()):l(b.BarcodeReaderException(b.EnumErrorCode.DBR_NULL_REFERENCE,"Can't create BarcodeReader instance.")):l(d.exception)};b._dbrWorker.postMessage({type:"createInstance",id:g,licenseKey:a._licenseKey})})};b.prototype.deleteInstance=
function(){var a=this;if(this._instance)this._instance.delete();else return new Promise(function(c,l){var g=Math.random();d[g]=function(a){return a.success?c():l(a.exception)};b._dbrWorker.postMessage({type:"deleteInstance",id:g,instanceID:a._instanceID})})};b.prototype._decodeBlob=function(a,b){var d=this;if(!(f.Blob&&a instanceof Blob))return Promise.reject("'_decodeBlob(blob, templateName)': Type of 'blob' should be 'Blob'.");b=b||"";return c._bDom?(new Promise(function(b,d){var c=URL.createObjectURL(a),
g=new Image;g.dbrObjUrl=c;g.src=c;g.onload=function(){b(g)};g.onerror=function(){d(TypeError("'_decodeBlob(blob, templateName)': Can't convert the blob to image."))}})).then(function(a){return d._decodeImage(a)}):(new Promise(function(b){var d=new FileReader;d.onload=function(){b(d.result)};d.readAsArrayBuffer(a)})).then(function(a){return d._decodeArrayBuffer(a,b)})};b.prototype._decodeArrayBuffer=function(a,b){if(!(f.arrayBuffer&&a instanceof ArrayBuffer||f.Buffer&&a instanceof Buffer))return Promise.reject("'_decodeBlob(arrayBuffer, templateName)': Type of 'arrayBuffer' should be 'ArrayBuffer' or 'Buffer'.");
b=b||"";return c._bDom?this._decodeBlob(new Blob(a),b):this._decodeUint8Array(new Uint8Array(a))};b.prototype._decodeUint8Array=function(a,d){var g=this;if(!(f.Uint8Array&&a instanceof Uint8Array||f.Uint8ClampedArray&&a instanceof Uint8ClampedArray))return Promise.reject("'_decodeBlob(uint8Array, templateName)': Type of 'uint8Array' should be 'Uint8Array'.");d=d||"";return c._bDom?g._decodeBlob(new Blob(a),d):new Promise(function(c){if(b._isShowRelDecodeTimeInResults){var n=(new Date).getTime(),q=
g._instance.DecodeFileInMemory(a,d);n=(new Date).getTime()-n;q=h(q);q._decodeTime=n;return c(q)}return c(h(g._instance.DecodeFileInMemory(a,d)))})};b.prototype._decodeImage=function(a,b){var d=this;return(new Promise(function(d){if(!(f.HTMLImageElement&&a instanceof HTMLImageElement))throw TypeError("'_decodeImage(image, templateName)': Type of 'image' should be 'HTMLImageElement'.");if(a.crossOrigin&&"anonymous"!=a.crossOrigin)throw"cors";b=b||"";d()})).then(function(){var c=document.createElement("canvas");
c.width=a.naturalWidth;c.height=a.naturalHeight;c.getContext("2d").drawImage(a,0,0);a.dbrObjUrl&&URL.revokeObjectURL(a.dbrObjUrl);return d._decodeCanvas(c,b)})};b.prototype._decodeCanvas=function(a,d){var c=this;return(new Promise(function(b){if(!(f.HTMLCanvasElement&&a instanceof HTMLCanvasElement))throw TypeError("'_decodeCanvas(canvas, templateName)': Type of 'canvas' should be 'HTMLCanvasElement'.");if(a.crossOrigin&&"anonymous"!=a.crossOrigin)throw"cors";d=d||"";var c=a.getContext("2d").getImageData(0,
0,a.width,a.height).data;b(c)})).then(function(g){return c._decodeRawImageUint8Array(g,a.width,a.height,4*a.width,b.EnumImagePixelFormat.IPF_ARGB_8888,d)})};b.prototype._decodeVideo=b.prototype.decodeVideo=function(a){var b=this,d,c=arguments;return(new Promise(function(b){if(!(f.HTMLVideoElement&&a instanceof HTMLVideoElement))throw TypeError("'_decodeVideo(video [ [, sx, sy, sWidth, sHeight], dWidth, dHeight] [, templateName] )': Type of 'video' should be 'HTMLVideoElement'.");if(a.crossOrigin&&
"anonymous"!=a.crossOrigin)throw"cors";var g,e,l;if(2>=c.length){var n=g=0;var h=e=a.videoWidth;var k=l=a.videoHeight}else 4>=c.length?(n=g=0,h=a.videoWidth,k=a.videoHeight,e=c[1],l=c[2]):(n=c[1],g=c[2],h=c[3],k=c[4],e=c[5],l=c[6]);d="string"==typeof c[c.length-1]?c[c.length-1]:"";var r=document.createElement("canvas");r.width=e;r.height=l;r.getContext("2d").drawImage(a,n,g,h,k,0,0,e,l);b(r)})).then(function(a){return b._decodeCanvas(a,d)})};b.prototype._decodeBase64=b.prototype.decodeBase64String=
function(a,b){var d=this;if(!("string"==typeof a||"object"==typeof a&&a instanceof String))return Promise.reject("'decodeBase64(base64Str, templateName)': Type of 'base64Str' should be 'String'.");"data:image/"==a.substring(0,11)&&(a=a.substring(a.indexOf(",")+1));b=b||"";return new Promise(function(g){if(c._bNodejs)g(d._decodeArrayBuffer(Buffer.from(a,"base64"),b));else{for(var e=atob(a),f=e.length,l=new Uint8Array(f);f--;)l[f]=e.charCodeAt(f);c._bDom?g(d._decodeBlob(new Blob([l]),b)):g(d._decodeUint8Array(l,
b))}})};b.prototype._decodeUrl=function(a,b){var d=this;return new Promise(function(g,e){if(!("string"==typeof a||"object"==typeof a&&a instanceof String))throw TypeError("'_decodeUrl(url, templateName)': Type of 'url' should be 'String'.");b=b||"";if(c._bNodejs)(a.startsWith("https")?require("https"):require("http")).get(a,function(a){if(200==a.statusCode){var c=[];a.on("data",function(a){c.push(a)}).on("end",function(){g(d._decodeArrayBuffer(Buffer.concat(c),b))})}else e("http get fail, statusCode: "+
a.statusCode)});else{var f=new XMLHttpRequest;f.open("GET",a,!0);f.responseType=c._bDom?"blob":"arraybuffer";f.send();f.onloadend=function(){c._bDom?g(d._decodeBlob(this.response,b)):g(d._decodeArrayBuffer(this.response,b))};f.onerror=function(){e(f.error)}}})};b.prototype._decodeFilePath=function(a,b){var d=this;return new Promise(function(c,g){if(!("string"==typeof a||"object"==typeof a&&a instanceof String))throw TypeError("'_decodeFilePath(path, templateName)': Type of 'path' should be 'String'.");
b=b||"";require("fs").readFile(a,function(a,e){a?g(a):c(d._decodeArrayBuffer(e,b))})})};b.prototype._decodeRawImageBlob=function(a,b,d,c,e,h){var g=this;return(new Promise(function(b,d){if(!(f.Blob&&a instanceof Blob))throw TypeError("'_decodeRawImageBlob(buffer, width, height, stride, enumImagePixelFormat, templateName)': Type of 'buffer' should be 'Blob'.");h=h||"";var c=new FileReader;c.readAsArrayBuffer(a);c.onload=function(){b(c.result)};c.onerror=function(){d(c.error)}})).then(function(a){return g._decodeRawImageUint8Array(new Uint8Array(a),
b,d,c,e,h)})};b.prototype._decodeRawImageArrayBuffer=function(a,b,d,c,e,h){var g=this;return(new Promise(function(b){if(!(f.ArrayBuffer&&a instanceof ArrayBuffer))throw TypeError("'_decodeRawImageArrayBuffer(buffer, width, height, stride, enumImagePixelFormat, templateName)': Type of 'buffer' should be 'ArrayBuffer'.");h=h||"";b()})).then(function(){return g._decodeRawImageUint8Array(new Uint8Array(a),b,d,c,e,h)})};b.prototype._decodeRawImageUint8Array=function(a,c,e,n,p,q){var g=this;return(new Promise(function(b){if(!(f.Uint8Array&&
a instanceof Uint8Array||f.Uint8ClampedArray&&a instanceof Uint8ClampedArray))throw TypeError("'_decodeRawImageUint8Array(buffer, width, height, stride, enumImagePixelFormat, templateName)': Type of 'buffer' should be 'Uint8Array'.");q=q||"";g._localizationResultArray=void 0;b()})).then(function(){if(g._instance){if(b._isShowRelDecodeTimeInResults){var f=(new Date).getTime(),l=g._instance.DecodeBuffer(a,c,e,n,p,q);f=(new Date).getTime()-f;l=h(l);l._decodeTime=f;return Promise.resolve(l)}return Promise.resolve(h(g._instance.DecodeBuffer(a,
c,e,n,p,q)))}var t;l=g._instanceID?Promise.resolve():g._createWorkerInstance();return l.then(function(){return null===g._runtimeSettings?new Promise(function(a,c){var e=Math.random();d[e]=function(b){return b.success?(g._runtimeSettings=void 0,a()):c(b.exception)};b._dbrWorker.postMessage({type:"resetRuntimeSettings",id:e,instanceID:g._instanceID})}):Promise.resolve()}).then(function(){return new Promise(function(f,r){var m=Math.random();d[m]=function(a){return a.success?f(a.results):r(a.exception)};
b._dbrWorker.postMessage({type:"decodeRawImageUint8Array",id:m,instanceID:g._instanceID,body:{buffer:a,width:c,height:e,stride:n,enumImagePixelFormat:p,templateName:q},_isShowRelDecodeTimeInResults:b._isShowRelDecodeTimeInResults})})}).then(function(a){t=a;return new Promise(function(a,c){var e=Math.random();d[e]=function(b){return b.success?a(b.results):c(b.exception)};b._dbrWorker.postMessage({type:"getAllLocalizationResults",id:e,instanceID:g._instanceID})})}).then(function(a){g._localizationResultArray=
a;return Promise.resolve(t)})})};b.prototype.decode=b.prototype.decodeFileInMemory=function(a,b){return f.Blob&&a instanceof Blob?this._decodeBlob(a,b):f.ArrayBuffer&&a instanceof ArrayBuffer||f.Buffer&&a instanceof Buffer?this._decodeArrayBuffer(a,b):f.Uint8Array&&a instanceof Uint8Array||f.Uint8ClampedArray&&a instanceof Uint8ClampedArray?this._decodeUint8Array(a,b):f.HTMLImageElement&&a instanceof HTMLImageElement?this._decodeImage(a,b):f.HTMLCanvasElement&&a instanceof HTMLCanvasElement?this._decodeCanvas(a,
b):f.HTMLVideoElement&&a instanceof HTMLVideoElement?this._decodeVideo(a,b):"string"==typeof a||a instanceof String?"data:image/"==a.substring(0,11)?this._decodeBase64(a,b):c._bNodejs?"http"==a.substring(0,4)?this._decodeUrl(a,b):this._decodeFilePath(a,b):this._decodeUrl(a,b):Promise.reject(TypeError("'_decode(source, templateName)': Type of 'source' should be 'Blob', 'ArrayBuffer', 'Uint8Array', 'HTMLImageElement', 'HTMLCanvasElement', 'HTMLVideoElement', 'String(base64 with image mime)' or 'String(url)'."))};
b.prototype._decodeRawImage=b.prototype.decodeBuffer=function(a,b,c,d,e,h){return f.Blob&&a instanceof Blob?this._decodeRawImageBlob(a,b,c,d,e,h):f.ArrayBuffer&&a instanceof ArrayBuffer?this._decodeRawImageArrayBuffer(a,b,c,d,e,h):f.Uint8Array&&a instanceof Uint8Array||f.Uint8ClampedArray&&a instanceof Uint8ClampedArray?this._decodeRawImageUint8Array(a,b,c,d,e,h):Promise.reject(TypeError("'_decodeRawImage(source, width, height, stride, enumImagePixelFormat, templateName)': Type of 'source' should be 'Blob', 'ArrayBuffer' or 'Uint8Array'."))};
var h=b._handleRetJsonString=function(a){a="string"==typeof a||"object"==typeof a&&a instanceof String?JSON.parse(a):a;var d=b.EnumErrorCode;switch(a.exception){case d.DBR_SUCCESS:case d.DBR_LICENSE_INVALID:case d.DBR_LICENSE_EXPIRED:case d.DBR_1D_LICENSE_INVALID:case d.DBR_QR_LICENSE_INVALID:case d.DBR_PDF417_LICENSE_INVALID:case d.DBR_DATAMATRIX_LICENSE_INVALID:case d.DBR_DBRERR_AZTEC_LICENSE_INVALID:case d.DBR_RECOGNITION_TIMEOUT:if(a.textResult)for(d=0;d<a.textResult.length;++d){var e=a.textResult[d];
try{e.BarcodeText=c._bNodejs?Buffer.from(e.BarcodeText,"base64").toString():atob(e.BarcodeText)}catch(n){e.BarcodeText=""}}return a.textResult||a.localizationResultArray||a.Result||a.templateSettings||a.settings||a.outputSettings||a;default:throw b.BarcodeReaderException(a.exception,a.description);}};b.prototype.getAllLocalizationResults=function(){return this._localizationResultArray?this._localizationResultArray:h(this._instance.GetAllLocalizationResults())};b.prototype.getAllParameterTemplateNames=
function(){return h(this._instance.GetAllParameterTemplateNames())};b.prototype.getRuntimeSettings=function(){return this._instance?h(this._instance.GetRuntimeSettings()):this._runtimeSettings?JSON.parse(this._runtimeSettings):b._defaultRuntimeSettings};b.prototype.updateRuntimeSettings=function(a){var c=this;if("string"==typeof a||"object"==typeof a&&a instanceof String)var e=a;else if("object"==typeof a)e=JSON.stringify(a);else throw TypeError("'UpdateRuntimeSettings(settings)': Type of 'settings' should be 'String' or 'PlainObject'.");
if(c._instance)try{return h(c._instance.UpdateRuntimeSettings(e)),Promise.resolve()}catch(n){return Promise.reject(n)}else return Promise.resolve().then(function(){return c._instanceID?Promise.resolve():c._createWorkerInstance()}).then(function(){return new Promise(function(a,f){var h=Math.random();d[h]=function(b){return b.success?(c._runtimeSettings=e,a()):f(b.exception)};b._dbrWorker.postMessage({type:"updateRuntimeSettings",id:h,instanceID:c._instanceID,body:{settings:e}})})}).catch(function(a){return Promise.reject(a)})};
b.prototype.resetRuntimeSettings=function(){this._instance?h(this._instance.ResetRuntimeSettings()):this._runtimeSettings=null};b.prototype.outputSettingsToString=function(a){return h(this._instance.OutputSettingsToString(a||""))};b.prototype.initRuntimeSettingsWithString=function(a,b){if(!("string"==typeof a||"object"==typeof a&&a instanceof String))if("object"==typeof a)a=JSON.stringify(a);else throw TypeError("'initRuntimeSettingstWithString(template, enumComflictMode)': Type of 'template' should be 'String' or 'PlainObject'.");
h(this._instance.InitRuntimeSettingstWithString(a,b?b:2))};b.prototype.appendTplStringToRuntimeSettings=function(a,b){if(!("string"==typeof a||"object"==typeof a&&a instanceof String))if("object"==typeof a)a=JSON.stringify(a);else throw TypeError("'appendTplStringToRuntimeSettings(template, enumComflictMode)': Type of 'template' should be 'String' or 'PlainObject'.");h(this._instance.AppendTplStringToRuntimeSettings(a,b?b:2))};b.EnumBarcodeFormat=b.EnumBarcodeFormat||{All:503317503,OneD:1023,CODE_39:1,
CODE_128:2,CODE_93:4,CODABAR:8,ITF:16,EAN_13:32,EAN_8:64,UPC_A:128,UPC_E:256,INDUSTRIAL_25:512,PDF417:33554432,QR_CODE:67108864,DATAMATRIX:134217728,AZTEC:268435456};b.EnumErrorCode=b.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,
dynamsoft.TaskQueue=dynamsoft.TaskQueue||function(){var c=function(){this._queue=[];this.isWorking=!1;this.timeout=100};c.prototype.push=function(c,a,e){this._queue.push({task:c,context:a,args:e});this.isWorking||this.next()};c.prototype.unshift=function(c,a,e){this._queue.unshift({task:c,context:a,args:e});this.isWorking||this.next()};c.prototype.next=function(){if(0==this._queue.length)this.isWorking=!1;else{this.isWorking=!0;var c=this._queue.shift(),a=c.task,e=c.context?c.context:null,d=c.args?
c.args:[];setTimeout(function(){a.apply(e,d)},this.timeout)}};return c}();dynamsoft.dbrEnv=dynamsoft.dbrEnv||{};"undefined"!=typeof self?(dynamsoft.dbrEnv._self=self,self.document?dynamsoft.dbrEnv._bDom=!0:dynamsoft.dbrEnv._bWorker=!0):(dynamsoft.dbrEnv._self=global,dynamsoft.dbrEnv._bNodejs=!0);
dynamsoft.BarcodeReader=dynamsoft.BarcodeReader||function(){var c=dynamsoft.dbrEnv,f=c._self,a=function(b){b=b||a.licenseKey||"";if(!("string"==typeof b||"object"==typeof b&&b instanceof String))throw TypeError("'Constructor BarcodeReader(licenseKey)': Type of 'licenseKey' should be 'String'.");this._licenseKey=b;if(a._BarcodeReaderWasm){this._instance=new a._BarcodeReaderWasm(this._licenseKey);if(!this._instance)throw a.BarcodeReaderException(a.EnumErrorCode.DBR_NULL_REFERENCE,"Can't create BarcodeReader instance.");
this._instance.bInWorker&&(this._instance=void 0)}else throw Error("'Constructor BarcodeReader(licenseKey)': Autoload haven't start or you want to call `loadWasm` manually.");};a._jsVersion="6.5.1";a._jsEditVersion="20190426";a.version="loading...(JS "+a._jsVersion+"."+a._jsEditVersion+")";a.isLoaded=function(){return"loaded"==this._loadWasmStatus};a.licenseKey=void 0;var e=c._bDom?import.meta.url.substring(0, import.meta.url.lastIndexOf("/")):void 0;a._resourcesPath=e;a._workerName=void 0;a._wasmjsName=void 0;a._wasmName=void 0;a._workerResourcePath=
void 0;a._wasmjsResourcePath=void 0;a._wasmResourcePath=void 0;a._isShowRelDecodeTimeInResults=!1;a._bCustomWorker=void 0;a._bWithio=void 0;a._onWasmDownloaded=void 0;a.createInstance=function(b){return a.loadWasm().then(function(){return Promise.resolve(new a(b))})};var d={};a._loadWorker=function(){return new Promise(function(b,h){var c=a._workerName||"dbr-"+a._jsVersion+".min.js";if(a._workerResourcePath||a._resourcesPath){var l=a._workerResourcePath||a._resourcesPath;"/"!=l.charAt(l.length-1)&&
(l+="/");c=l+c}fetch(c).then(function(b){return b.blob()}).then(function(c){var l=URL.createObjectURL(c);c=a._dbrWorker=new Worker(l);c.onerror=function(b){b="worker error, you should host the page in web service: "+b.message;f.kConsoleLog&&f.kConsoleError(b);h(b)};c.onmessage=function(c){c=c.data;switch(c.type){case "log":f.kConsoleLog&&f.kConsoleLog(c.message);break;case "load":c.success?(a.version=c.version,a._defaultRuntimeSettings=c._defaultRuntimeSettings,f.kConsoleLog&&f.kConsoleLog("load dbr worker success"),
b()):h(c.exception);URL.revokeObjectURL(l);break;case "task":try{d[c.id](c.body),d[c.id]=void 0}catch(u){throw d[c.id]=void 0,u;}break;default:f.kConsoleLog&&f.kConsoleLog(c)}};var e=document.createElement("a");e.href=a._resourcesPath||"./";var q=void 0;a._wasmjsResourcePath&&(q=document.createElement("a"),q.href=a._wasmjsResourcePath||"./",q=q.href);var p=void 0;a._wasmResourcePath&&(p=document.createElement("a"),p.href=a._wasmResourcePath||"./",p=p.href);c.postMessage({type:"loadWorker",_resourcesPath:e.href,
_wasmjsResourcePath:q,_wasmResourcePath:p,origin:location.origin})}).catch(function(b){h(b)})})};a.prototype._createWorkerInstance=function(){var b=this;return new Promise(function(c,e){var h=Math.random();d[h]=function(d){return d.success?d.instanceID?(b._instanceID=d.instanceID,c()):e(a.BarcodeReaderException(a.EnumErrorCode.DBR_NULL_REFERENCE,"Can't create BarcodeReader instance.")):e(d.exception)};a._dbrWorker.postMessage({type:"createInstance",id:h,licenseKey:b._licenseKey})})};a.prototype.deleteInstance=
function(){var b=this;if(this._instance)this._instance.delete();else return new Promise(function(c,e){var h=Math.random();d[h]=function(b){return b.success?c():e(b.exception)};a._dbrWorker.postMessage({type:"deleteInstance",id:h,instanceID:b._instanceID})})};a.prototype._decodeBlob=function(b,a){var d=this;if(!(f.Blob&&b instanceof Blob))return Promise.reject("'_decodeBlob(blob, templateName)': Type of 'blob' should be 'Blob'.");a=a||"";return c._bDom?(new Promise(function(a,d){var c=URL.createObjectURL(b),
h=new Image;h.dbrObjUrl=c;h.src=c;h.onload=function(){a(h)};h.onerror=function(){d(TypeError("'_decodeBlob(blob, templateName)': Can't convert the blob to image."))}})).then(function(b){return d._decodeImage(b)}):(new Promise(function(a){var d=new FileReader;d.onload=function(){a(d.result)};d.readAsArrayBuffer(b)})).then(function(b){return d._decodeArrayBuffer(b,a)})};a.prototype._decodeArrayBuffer=function(b,a){if(!(f.arrayBuffer&&b instanceof ArrayBuffer||f.Buffer&&b instanceof Buffer))return Promise.reject("'_decodeBlob(arrayBuffer, templateName)': Type of 'arrayBuffer' should be 'ArrayBuffer' or 'Buffer'.");
a=a||"";return c._bDom?this._decodeBlob(new Blob(b),a):this._decodeUint8Array(new Uint8Array(b))};a.prototype._decodeUint8Array=function(b,d){var h=this;if(!(f.Uint8Array&&b instanceof Uint8Array||f.Uint8ClampedArray&&b instanceof Uint8ClampedArray))return Promise.reject("'_decodeBlob(uint8Array, templateName)': Type of 'uint8Array' should be 'Uint8Array'.");d=d||"";return c._bDom?h._decodeBlob(new Blob(b),d):new Promise(function(c){if(a._isShowRelDecodeTimeInResults){var e=(new Date).getTime(),l=
h._instance.DecodeFileInMemory(b,d);e=(new Date).getTime()-e;l=g(l);l._decodeTime=e;return c(l)}return c(g(h._instance.DecodeFileInMemory(b,d)))})};a.prototype._decodeImage=function(b,a){var d=this;return(new Promise(function(d){if(!(f.HTMLImageElement&&b instanceof HTMLImageElement))throw TypeError("'_decodeImage(image, templateName)': Type of 'image' should be 'HTMLImageElement'.");if(b.crossOrigin&&"anonymous"!=b.crossOrigin)throw"cors";a=a||"";d()})).then(function(){var c=document.createElement("canvas");
c.width=b.naturalWidth;c.height=b.naturalHeight;c.getContext("2d").drawImage(b,0,0);b.dbrObjUrl&&URL.revokeObjectURL(b.dbrObjUrl);return d._decodeCanvas(c,a)})};a.prototype._decodeCanvas=function(b,d){var c=this;return(new Promise(function(a){if(!(f.HTMLCanvasElement&&b instanceof HTMLCanvasElement))throw TypeError("'_decodeCanvas(canvas, templateName)': Type of 'canvas' should be 'HTMLCanvasElement'.");if(b.crossOrigin&&"anonymous"!=b.crossOrigin)throw"cors";d=d||"";var c=b.getContext("2d").getImageData(0,
0,b.width,b.height).data;a(c)})).then(function(h){return c._decodeRawImageUint8Array(h,b.width,b.height,4*b.width,a.EnumImagePixelFormat.IPF_ARGB_8888,d)})};a.prototype._decodeVideo=a.prototype.decodeVideo=function(b){var a=this,d,c=arguments,e,r;return(new Promise(function(h){if(!(f.HTMLVideoElement&&b instanceof HTMLVideoElement))throw TypeError("'_decodeVideo(video [ [, sx, sy, sWidth, sHeight], dWidth, dHeight] [, templateName] )': Type of 'video' should be 'HTMLVideoElement'.");if(b.crossOrigin&&
"anonymous"!=b.crossOrigin)throw"cors";var l,g,p;if(2>=c.length){var t=l=0;var k=g=b.videoWidth;var m=p=b.videoHeight}else 4>=c.length?(t=l=0,k=b.videoWidth,m=b.videoHeight,g=c[1],p=c[2]):(t=c[1],l=c[2],k=c[3],m=c[4],g=c[5],p=c[6]);d="string"==typeof c[c.length-1]?c[c.length-1]:"";r=document.createElement("canvas");r.width=g;r.height=p;var n=r.getContext("2d");a._bAddOriVideoCanvasToResult&&(e=document.createElement("canvas"),e.width=b.videoWidth,e.height=b.videoHeight,e.getContext("2d").drawImage(b,
0,0));n.drawImage(e||b,t,l,k,m,0,0,g,p);h()})).then(function(){return a._decodeCanvas(r,d)}).then(function(b){if(a._bAddOriVideoCanvasToResult)for(var d=$jscomp.makeIterator(b),c=d.next();!c.done;c=d.next())c.value.oriVideoCanvas=e;if(a._bAddSearchRegionCanvasToResult)for(d=$jscomp.makeIterator(b),c=d.next();!c.done;c=d.next())c.value.searchRegionCanvas=r;return b})};a.prototype._decodeBase64=a.prototype.decodeBase64String=function(b,a){var d=this;if(!("string"==typeof b||"object"==typeof b&&b instanceof
String))return Promise.reject("'decodeBase64(base64Str, templateName)': Type of 'base64Str' should be 'String'.");"data:image/"==b.substring(0,11)&&(b=b.substring(b.indexOf(",")+1));a=a||"";return new Promise(function(h){if(c._bNodejs)h(d._decodeArrayBuffer(Buffer.from(b,"base64"),a));else{for(var e=atob(b),f=e.length,g=new Uint8Array(f);f--;)g[f]=e.charCodeAt(f);c._bDom?h(d._decodeBlob(new Blob([g]),a)):h(d._decodeUint8Array(g,a))}})};a.prototype._decodeUrl=function(b,a){var d=this;return new Promise(function(e,
h){if(!("string"==typeof b||"object"==typeof b&&b instanceof String))throw TypeError("'_decodeUrl(url, templateName)': Type of 'url' should be 'String'.");a=a||"";if(c._bNodejs)(b.startsWith("https")?require("https"):require("http")).get(b,function(b){if(200==b.statusCode){var c=[];b.on("data",function(b){c.push(b)}).on("end",function(){e(d._decodeArrayBuffer(Buffer.concat(c),a))})}else h("http get fail, statusCode: "+b.statusCode)});else{var f=new XMLHttpRequest;f.open("GET",b,!0);f.responseType=
c._bDom?"blob":"arraybuffer";f.send();f.onloadend=function(){c._bDom?e(d._decodeBlob(this.response,a)):e(d._decodeArrayBuffer(this.response,a))};f.onerror=function(){h(f.error)}}})};a.prototype._decodeFilePath=function(b,a){var d=this;return new Promise(function(c,e){if(!("string"==typeof b||"object"==typeof b&&b instanceof String))throw TypeError("'_decodeFilePath(path, templateName)': Type of 'path' should be 'String'.");a=a||"";require("fs").readFile(b,function(b,h){b?e(b):c(d._decodeArrayBuffer(h,
a))})})};a.prototype._decodeRawImageBlob=function(b,a,d,c,e,g){var h=this;return(new Promise(function(a,d){if(!(f.Blob&&b instanceof Blob))throw TypeError("'_decodeRawImageBlob(buffer, width, height, stride, enumImagePixelFormat, templateName)': Type of 'buffer' should be 'Blob'.");g=g||"";var c=new FileReader;c.readAsArrayBuffer(b);c.onload=function(){a(c.result)};c.onerror=function(){d(c.error)}})).then(function(b){return h._decodeRawImageUint8Array(new Uint8Array(b),a,d,c,e,g)})};a.prototype._decodeRawImageArrayBuffer=
function(b,a,d,c,e,g){var h=this;return(new Promise(function(a){if(!(f.ArrayBuffer&&b instanceof ArrayBuffer))throw TypeError("'_decodeRawImageArrayBuffer(buffer, width, height, stride, enumImagePixelFormat, templateName)': Type of 'buffer' should be 'ArrayBuffer'.");g=g||"";a()})).then(function(){return h._decodeRawImageUint8Array(new Uint8Array(b),a,d,c,e,g)})};a.prototype._decodeRawImageUint8Array=function(b,c,e,l,q,r){var h=this;return(new Promise(function(a){if(!(f.Uint8Array&&b instanceof Uint8Array||
f.Uint8ClampedArray&&b instanceof Uint8ClampedArray))throw TypeError("'_decodeRawImageUint8Array(buffer, width, height, stride, enumImagePixelFormat, templateName)': Type of 'buffer' should be 'Uint8Array'.");r=r||"";h._localizationResultArray=void 0;a()})).then(function(){if(h._instance){if(a._isShowRelDecodeTimeInResults){var f=(new Date).getTime(),p=h._instance.DecodeBuffer(b,c,e,l,q,r);f=(new Date).getTime()-f;p=g(p);p._decodeTime=f;return Promise.resolve(p)}return Promise.resolve(g(h._instance.DecodeBuffer(b,
c,e,l,q,r)))}var t;p=h._instanceID?Promise.resolve():h._createWorkerInstance();return p.then(function(){return null===h._runtimeSettings?new Promise(function(b,c){var m=Math.random();d[m]=function(a){return a.success?(h._runtimeSettings=void 0,b()):c(a.exception)};a._dbrWorker.postMessage({type:"resetRuntimeSettings",id:m,instanceID:h._instanceID})}):Promise.resolve()}).then(function(){return new Promise(function(f,k){var m=Math.random();d[m]=function(b){return b.success?f(b.results):k(b.exception)};
a._dbrWorker.postMessage({type:"decodeRawImageUint8Array",id:m,instanceID:h._instanceID,body:{buffer:b,width:c,height:e,stride:l,enumImagePixelFormat:q,templateName:r},_isShowRelDecodeTimeInResults:a._isShowRelDecodeTimeInResults})})}).then(function(b){t=b;return new Promise(function(b,c){var m=Math.random();d[m]=function(a){return a.success?b(a.results):c(a.exception)};a._dbrWorker.postMessage({type:"getAllLocalizationResults",id:m,instanceID:h._instanceID})})}).then(function(b){h._localizationResultArray=
b;return Promise.resolve(t)})})};a.prototype.decode=a.prototype.decodeFileInMemory=function(b,a){return f.Blob&&b instanceof Blob?this._decodeBlob(b,a):f.ArrayBuffer&&b instanceof ArrayBuffer||f.Buffer&&b instanceof Buffer?this._decodeArrayBuffer(b,a):f.Uint8Array&&b instanceof Uint8Array||f.Uint8ClampedArray&&b instanceof Uint8ClampedArray?this._decodeUint8Array(b,a):f.HTMLImageElement&&b instanceof HTMLImageElement?this._decodeImage(b,a):f.HTMLCanvasElement&&b instanceof HTMLCanvasElement?this._decodeCanvas(b,
a):f.HTMLVideoElement&&b instanceof HTMLVideoElement?this._decodeVideo(b,a):"string"==typeof b||b instanceof String?"data:image/"==b.substring(0,11)?this._decodeBase64(b,a):c._bNodejs?"http"==b.substring(0,4)?this._decodeUrl(b,a):this._decodeFilePath(b,a):this._decodeUrl(b,a):Promise.reject(TypeError("'_decode(source, templateName)': Type of 'source' should be 'Blob', 'ArrayBuffer', 'Uint8Array', 'HTMLImageElement', 'HTMLCanvasElement', 'HTMLVideoElement', 'String(base64 with image mime)' or 'String(url)'."))};
a.prototype._decodeRawImage=a.prototype.decodeBuffer=function(b,a,c,d,e,g){return f.Blob&&b instanceof Blob?this._decodeRawImageBlob(b,a,c,d,e,g):f.ArrayBuffer&&b instanceof ArrayBuffer?this._decodeRawImageArrayBuffer(b,a,c,d,e,g):f.Uint8Array&&b instanceof Uint8Array||f.Uint8ClampedArray&&b instanceof Uint8ClampedArray?this._decodeRawImageUint8Array(b,a,c,d,e,g):Promise.reject(TypeError("'_decodeRawImage(source, width, height, stride, enumImagePixelFormat, templateName)': Type of 'source' should be 'Blob', 'ArrayBuffer' or 'Uint8Array'."))};
var g=a._handleRetJsonString=function(b){b="string"==typeof b||"object"==typeof b&&b instanceof String?JSON.parse(b):b;var d=a.EnumErrorCode;switch(b.exception){case d.DBR_SUCCESS:case d.DBR_LICENSE_INVALID:case d.DBR_LICENSE_EXPIRED:case d.DBR_1D_LICENSE_INVALID:case d.DBR_QR_LICENSE_INVALID:case d.DBR_PDF417_LICENSE_INVALID:case d.DBR_DATAMATRIX_LICENSE_INVALID:case d.DBR_DBRERR_AZTEC_LICENSE_INVALID:case d.DBR_RECOGNITION_TIMEOUT:if(b.textResult)for(d=0;d<b.textResult.length;++d){var e=b.textResult[d];
try{e.BarcodeText=c._bNodejs?Buffer.from(e.BarcodeText,"base64").toString():atob(e.BarcodeText)}catch(l){e.BarcodeText=""}}return b.textResult||b.localizationResultArray||b.Result||b.templateSettings||b.settings||b.outputSettings||b;default:throw a.BarcodeReaderException(b.exception,b.description);}};a.prototype.getAllLocalizationResults=function(){return this._localizationResultArray?this._localizationResultArray:g(this._instance.GetAllLocalizationResults())};a.prototype.getAllParameterTemplateNames=
function(){return g(this._instance.GetAllParameterTemplateNames())};a.prototype.getRuntimeSettings=function(){return this._instance?g(this._instance.GetRuntimeSettings()):this._runtimeSettings?JSON.parse(this._runtimeSettings):a._defaultRuntimeSettings};a.prototype.updateRuntimeSettings=function(b){var c=this;if("string"==typeof b||"object"==typeof b&&b instanceof String)var e=b;else if("object"==typeof b)e=JSON.stringify(b);else throw TypeError("'UpdateRuntimeSettings(settings)': Type of 'settings' should be 'String' or 'PlainObject'.");
if(c._instance)try{return g(c._instance.UpdateRuntimeSettings(e)),Promise.resolve()}catch(l){return Promise.reject(l)}else return Promise.resolve().then(function(){return c._instanceID?Promise.resolve():c._createWorkerInstance()}).then(function(){return new Promise(function(b,f){var g=Math.random();d[g]=function(a){return a.success?(c._runtimeSettings=e,b()):f(a.exception)};a._dbrWorker.postMessage({type:"updateRuntimeSettings",id:g,instanceID:c._instanceID,body:{settings:e}})})}).catch(function(b){return Promise.reject(b)})};
a.prototype.resetRuntimeSettings=function(){this._instance?g(this._instance.ResetRuntimeSettings()):this._runtimeSettings=null};a.prototype.outputSettingsToString=function(b){return g(this._instance.OutputSettingsToString(b||""))};a.prototype.initRuntimeSettingsWithString=function(b,a){if(!("string"==typeof b||"object"==typeof b&&b instanceof String))if("object"==typeof b)b=JSON.stringify(b);else throw TypeError("'initRuntimeSettingstWithString(template, enumComflictMode)': Type of 'template' should be 'String' or 'PlainObject'.");
g(this._instance.InitRuntimeSettingstWithString(b,a?a:2))};a.prototype.appendTplStringToRuntimeSettings=function(b,a){if(!("string"==typeof b||"object"==typeof b&&b instanceof String))if("object"==typeof b)b=JSON.stringify(b);else throw TypeError("'appendTplStringToRuntimeSettings(template, enumComflictMode)': Type of 'template' should be 'String' or 'PlainObject'.");g(this._instance.AppendTplStringToRuntimeSettings(b,a?a:2))};a.EnumBarcodeFormat=a.EnumBarcodeFormat||{All:503317503,OneD:1023,CODE_39:1,
CODE_128:2,CODE_93:4,CODABAR:8,ITF:16,EAN_13:32,EAN_8:64,UPC_A:128,UPC_E:256,INDUSTRIAL_25:512,PDF417:33554432,QR_CODE:67108864,DATAMATRIX:134217728,AZTEC:268435456};a.EnumErrorCode=a.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_DBRERR_AZTEC_LICENSE_INVALID:-10041};b.EnumImagePixelFormat=b.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};b.EnumResultType=b.EnumResultType||{EDT_StandardText:0,EDT_RawText:1,EDT_CandidateText:2,EDT_PartialText:3};b.EnumTerminateStage=b.EnumTerminateStage||{ETS_Prelocalized:0,ETS_Localized:1,ETS_Recognized:2};b.EnumConflictMode=b.EnumConflictMode||{ECM_Ignore:1,ECM_Overwrite:2};b.BarcodeReaderException=b.BarcodeReaderException||function(){return function(a,d){var c=b.EnumErrorCode.DBR_UNKNOWN;"number"==typeof a?(c=a,a=Error(d)):a=Error(a);a.code=c;return a}}();return b}();
!dynamsoft.dbrEnv._bWorker||dynamsoft.BarcodeReader._bCustomWorker||dynamsoft.dbrEnv._self.onmessage||function(){var c=dynamsoft.dbrEnv,f=c._self,b=dynamsoft.BarcodeReader;f.kConsoleLog=f.kConsoleLog||function(d){if(f.onmessage!=b._onWorkerMessage)f.kConsoleLog=void 0;else{var c=void 0;if(void 0===d)c="undefined";else{try{c=JSON.stringify(d,function(){var a=[],b=[];return function(c,d){if("object"===typeof d&&null!==d){var e=a.indexOf(d);if(-1!==e)return"[Circular "+b[e]+"]";a.push(d);b.push(c||"root")}return d}}())}catch(a){}if(void 0===
c||"{}"===c)c=d.toString()}try{postMessage({type:"log",message:c})}catch(a){f.console&&console.error(message)}}};f.kConsoleLog("have detected in worker: "+b.version);var e={};f.onmessage=b._onWorkerMessage=function(d){d=d.data;switch(d.type){case "loadWorker":(function(){b._resourcesPath=d._resourcesPath;b._wasmjsResourcePath=d._wasmjsResourcePath;b._wasmResourcePath=d._wasmResourcePath;c.origin=d.origin;b.loadWasm().then(function(){postMessage({type:"load",success:!0,version:b.version,_defaultRuntimeSettings:b._defaultRuntimeSettings})},
function(b){postMessage({type:"load",success:!1,exception:b.message||b})})})();break;case "createInstance":(function(){try{var c=Math.random();e[c]=new b(d.licenseKey);postMessage({type:"task",id:d.id,body:{success:!0,instanceID:c}})}catch(a){postMessage({type:"task",id:d.id,body:{success:!1,exception:a.message||a}})}})();break;case "deleteInstance":try{e[d.instanceID].deleteInstance(),e[d.instanceID]=void 0,postMessage({type:"task",id:d.id,body:{success:!0}})}catch(h){postMessage({type:"task",id:d.id,
body:{success:!1,exception:h.message||h}})}break;case "decodeRawImageUint8Array":(function(){try{b._isShowRelDecodeTimeInResults=d._isShowRelDecodeTimeInResults;var c=d.body;e[d.instanceID]._decodeRawImageUint8Array(c.buffer,c.width,c.height,c.stride,c.enumImagePixelFormat,c.templateName).then(function(a){postMessage({type:"task",id:d.id,body:{success:!0,results:a}})}).catch(function(a){postMessage({type:"task",id:d.id,body:{success:!1,exception:a.message||a}})})}catch(a){postMessage({type:"task",
id:d.id,body:{success:!1,exception:a.message||a}})}})();break;case "getAllLocalizationResults":(function(){try{var b=e[d.instanceID].getAllLocalizationResults();postMessage({type:"task",id:d.id,body:{success:!0,results:b}})}catch(a){postMessage({type:"task",id:d.id,body:{success:!1,exception:a.message||a}})}})();break;case "getRuntimeSettings":(function(){try{var b=e[d.instanceID].getRuntimeSettings();postMessage({type:"task",id:d.id,body:{success:!0,settings:b}})}catch(a){postMessage({type:"task",
id:d.id,body:{success:!1,exception:a.message||a}})}})();break;case "updateRuntimeSettings":try{e[d.instanceID].updateRuntimeSettings(d.body.settings),postMessage({type:"task",id:d.id,body:{success:!0}})}catch(h){postMessage({type:"task",id:d.id,body:{success:!1,exception:h.message||h}})}break;case "resetRuntimeSettings":try{e[d.instanceID].resetRuntimeSettings(),postMessage({type:"task",id:d.id,body:{success:!0}})}catch(h){postMessage({type:"task",id:d.id,body:{success:!1,exception:h.message||h}})}break;
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_DBRERR_AZTEC_LICENSE_INVALID:-10041};a.EnumImagePixelFormat=a.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};a.EnumResultType=a.EnumResultType||{EDT_StandardText:0,EDT_RawText:1,EDT_CandidateText:2,EDT_PartialText:3};a.EnumTerminateStage=a.EnumTerminateStage||{ETS_Prelocalized:0,ETS_Localized:1,ETS_Recognized:2};a.EnumConflictMode=a.EnumConflictMode||{ECM_Ignore:1,ECM_Overwrite:2};a.BarcodeReaderException=a.BarcodeReaderException||function(){return function(b,d){var c=a.EnumErrorCode.DBR_UNKNOWN;"number"==typeof b?(c=b,b=Error(d)):b=Error(b);
b.code=c;return b}}();return a}();
!dynamsoft.dbrEnv._bWorker||dynamsoft.BarcodeReader._bCustomWorker||dynamsoft.dbrEnv._self.onmessage||function(){var c=dynamsoft.dbrEnv,f=c._self,a=dynamsoft.BarcodeReader;f.kConsoleLog=f.kConsoleLog||function(d){if(f.onmessage!=a._onWorkerMessage)f.kConsoleLog=void 0;else{var c=void 0;if(void 0===d)c="undefined";else{try{c=JSON.stringify(d,function(){var b=[],a=[];return function(c,d){if("object"===typeof d&&null!==d){var e=b.indexOf(d);if(-1!==e)return"[Circular "+a[e]+"]";b.push(d);a.push(c||"root")}return d}}())}catch(b){}if(void 0===
c||"{}"===c)c=d.toString()}try{postMessage({type:"log",message:c})}catch(b){f.console&&console.error(message)}}};f.kConsoleLog("have detected in worker: "+a.version);var e={};f.onmessage=a._onWorkerMessage=function(d){d=d.data;switch(d.type){case "loadWorker":(function(){a._resourcesPath=d._resourcesPath;a._wasmjsResourcePath=d._wasmjsResourcePath;a._wasmResourcePath=d._wasmResourcePath;c.origin=d.origin;a.loadWasm().then(function(){postMessage({type:"load",success:!0,version:a.version,_defaultRuntimeSettings:a._defaultRuntimeSettings})},
function(a){postMessage({type:"load",success:!1,exception:a.message||a})})})();break;case "createInstance":(function(){try{var c=Math.random();e[c]=new a(d.licenseKey);postMessage({type:"task",id:d.id,body:{success:!0,instanceID:c}})}catch(b){postMessage({type:"task",id:d.id,body:{success:!1,exception:b.message||b}})}})();break;case "deleteInstance":try{e[d.instanceID].deleteInstance(),e[d.instanceID]=void 0,postMessage({type:"task",id:d.id,body:{success:!0}})}catch(g){postMessage({type:"task",id:d.id,
body:{success:!1,exception:g.message||g}})}break;case "decodeRawImageUint8Array":(function(){try{a._isShowRelDecodeTimeInResults=d._isShowRelDecodeTimeInResults;var c=d.body;e[d.instanceID]._decodeRawImageUint8Array(c.buffer,c.width,c.height,c.stride,c.enumImagePixelFormat,c.templateName).then(function(b){postMessage({type:"task",id:d.id,body:{success:!0,results:b}})}).catch(function(b){postMessage({type:"task",id:d.id,body:{success:!1,exception:b.message||b}})})}catch(b){postMessage({type:"task",
id:d.id,body:{success:!1,exception:b.message||b}})}})();break;case "getAllLocalizationResults":(function(){try{var a=e[d.instanceID].getAllLocalizationResults();postMessage({type:"task",id:d.id,body:{success:!0,results:a}})}catch(b){postMessage({type:"task",id:d.id,body:{success:!1,exception:b.message||b}})}})();break;case "getRuntimeSettings":(function(){try{var a=e[d.instanceID].getRuntimeSettings();postMessage({type:"task",id:d.id,body:{success:!0,settings:a}})}catch(b){postMessage({type:"task",
id:d.id,body:{success:!1,exception:b.message||b}})}})();break;case "updateRuntimeSettings":try{e[d.instanceID].updateRuntimeSettings(d.body.settings),postMessage({type:"task",id:d.id,body:{success:!0}})}catch(g){postMessage({type:"task",id:d.id,body:{success:!1,exception:g.message||g}})}break;case "resetRuntimeSettings":try{e[d.instanceID].resetRuntimeSettings(),postMessage({type:"task",id:d.id,body:{success:!0}})}catch(g){postMessage({type:"task",id:d.id,body:{success:!1,exception:g.message||g}})}break;
default:postMessage({type:"task",id:d.id,body:{success:!1,exception:"No such task."}})}}}();
dynamsoft.BarcodeReader.loadWasm=dynamsoft.BarcodeReader.loadWasm||function(){return new Promise(function(c,f){var b=dynamsoft.dbrEnv,e=b._self,d=dynamsoft.BarcodeReader;if("loaded"==d._loadWasmStatus)return c();d._loadWasmTaskQueue=d._loadWasmTaskQueue||function(){var b=new dynamsoft.TaskQueue;b.timeout=0;return b}();d._loadWasmTaskQueue.push(function(h){if("loaded"==d._loadWasmStatus)return d._loadWasmTaskQueue.next(),c();if(h)return d._loadWasmTaskQueue.next(),f(d._loadWasmStatus);d._loadWasmStatus=
"loading";return(new Promise(function(a,c){d._BarcodeReaderWasm=function(){throw Error("'Constructor BarcodeReader(licenseKey)': The wasm hasn't finish loading.");};if(!e.WebAssembly||"undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&/\(.+\s11_2_([2-6]).*\)/.test(navigator.userAgent))return c("'Constructor BarcodeReader(licenseKey)': The browser doesn't support Webassembly.");if(b._bDom)return d._loadWorker().then(function(){d._BarcodeReaderWasm=
function(){this.bInWorker=!0};return a()},function(a){d._BarcodeReaderWasm=function(){throw Error("'Constructor BarcodeReader(licenseKey)': The wasm load failed. ex: "+(a.message||a));};return c(a)});var f={locateFile:function(){var a=d._wasmName||"dbr-"+d._jsVersion+(d._bWithio?".withio":"")+".wasm";if(d._wasmResourcePath||d._resourcesPath){var c=d._wasmResourcePath||d._resourcesPath;"/"!=c.charAt(c.length-1)&&(c+="/");a=c+a}else b._bNodejs&&(a=require("path").join(__dirname,a));return a},onRuntimeInitialized:function(){d._BarcodeReaderWasm=
f.BarcodeReaderWasm;var b=new f.BarcodeReaderWasm("");d.version=b.GetVersion()+"(JS "+d._jsVersion+"."+d._jsEditVersion+")";d._defaultRuntimeSettings=d._handleRetJsonString(b.GetRuntimeSettings());b.delete();e.kConsoleLog&&e.kConsoleLog("load dbr wasm success, version: "+d.version);a()}};f.onExit=f.onAbort=function(a){e.kConsoleLog&&kConsoleLog(a);d._BarcodeReaderWasm=function(){throw Error("'Constructor BarcodeReader(licenseKey)': The wasm load failed. Error: "+(a.message||a));};c(a)};f.print=function(a){e.kConsoleLog&&
kConsoleLog(a)};if("undefined"==typeof _dbrLoadWasm){void 0==d._bWithio&&(d._bWithio=b._bNodejs||b._bWorker&&(d._bCustomWorker||e.onmessage!=d._onWorkerMessage));var g=d._wasmjsName||"dbr-"+d._jsVersion+".wasm"+(d._bWithio?".withio":"")+".min.js";if(d._wasmjsResourcePath||d._resourcesPath){var h=d._wasmjsResourcePath||d._resourcesPath;"/"!=h.charAt(h.length-1)&&(h+="/");g=h+g}else b._bNodejs&&(g=require("path").join(__dirname,g));b._bWorker?importScripts(g):_dbrLoadWasm=require(g)}_dbrLoadWasm(f,
function(a,c,f){e.kConsoleLog&&kConsoleLog("start handle dbr wasm, version: "+a);var g=(new Date).getTime();if(b._bNodejs)return new Promise(function(a,b){require("fs").readFile(c,function(c,d){if(c)return b(c);var m=(new Date).getTime();a(WebAssembly.instantiate(d,f).then(function(a){e.kConsoleLog&&kConsoleLog("build instance from binary timecost: "+((new Date).getTime()-m));e.kConsoleLog&&kConsoleLog("finish handle dbr wasm, total timecost: "+((new Date).getTime()-g));return Promise.resolve(a)}))})});
var h=""+a;d._openDb=d._openDb||function(){return new Promise(function(a,b){var c=function(){d.result.createObjectStore("info");d.result.createObjectStore("wasm");d.result.createObjectStore("module")},d=indexedDB.open("dynamsoft-dbr-wasm",1);d.onupgradeneeded=c;d.onsuccess=function(){a(d.result)};d.onerror=function(){var e=d.error.message||d.error;-1!=e.indexOf("version")?(d=indexedDB.deleteDatabase("dynamsoft-dbr-wasm"),d.onsuccess=function(){var d=indexedDB.open("dynamsoft-dbr-wasm",1);d.onupgradeneeded=
c;d.onsuccess=function(){a(d.result)};d.onerror=function(){b("open db [dynamsoft-dbr-wasm] fail")}},d.onerror=function(){b("open db [dynamsoft-dbr-wasm] fail")}):b("open db [dynamsoft-dbr-wasm] fail: "+e)}})};var k=function(a){return new Promise(function(b,c){var d=a.transaction(["info"]).objectStore("info").get("bSupportStoreModuleInDb"),e=function(){var d=a.transaction(["info"],"readwrite").objectStore("info"),e=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,127,3,2,1,0,7,6,1,2,95,97,0,0,10,
6,1,4,0,65,1,11]);try{var f=d.put(new WebAssembly.Module(e.buffer),"testStoreModule");f.onsuccess=function(){d.put(!0,"bSupportStoreModuleInDb").onsuccess=function(){b("set bSupportStoreModuleInDb = true success")}};f.onerror=function(){c("Failed to store [testStoreModule] in wasm cache, bSupportStoreModuleInDb == false: "+(f.error.message||f.error))}}catch(x){c("Failed to store [testStoreModule] in wasm cache, bSupportStoreModuleInDb == false: "+(x.message||x))}};d.onsuccess=function(){d.result?
b("bSupportStoreModuleInDb == true"):e()}})};d._lookupInDatabase=d._lookupInDatabase||function(a,b,c){return new Promise(function(d,e){var f=a.transaction([b]).objectStore(b).get(c);f.onsuccess=function(){f.result?d(f.result):e(c+" was not found in "+b)}})};d._storeInDatabase=d._storeInDatabase||function(a,b,c,d){return new Promise(function(e,f){var g=a.transaction([b],"readwrite").objectStore(b).put(d,c);g.onerror=function(){f("Failed to store "+c+" in wasm cache: "+(g.error.message||g.error))};
g.onsuccess=function(){e("Successfully stored "+c+" in "+b)}})};return d._openDb().then(function(a){e.kConsoleLog&&kConsoleLog("open db success");return k(a).then(function(a){e.kConsoleLog&&kConsoleLog(a);return Promise.resolve(!0)},function(a){e.kConsoleLog&&kConsoleLog(a.message||a);return Promise.resolve(!1)}).then(function(b){var m=(new Date).getTime();return d._lookupInDatabase(a,"wasm",h).then(function(c){if(c instanceof WebAssembly.Module){e.kConsoleLog&&kConsoleLog("get a wasm module from db, timecost:"+
((new Date).getTime()-m));var k=(new Date).getTime();return WebAssembly.instantiate(c,f).then(function(a){e.kConsoleLog&&kConsoleLog("build instance from module timecost: "+((new Date).getTime()-k));e.kConsoleLog&&kConsoleLog("finish handle dbr wasm, total timecost: "+((new Date).getTime()-g));return Promise.resolve({module:c,instance:a})})}e.kConsoleLog&&kConsoleLog("get a wasm binary from db, timecost:"+((new Date).getTime()-m));var r=(new Date).getTime();return WebAssembly.instantiate(c,f).then(function(c){e.kConsoleLog&&
kConsoleLog("build instance from binary timecost: "+((new Date).getTime()-r));if(b){var f=(new Date).getTime();return d._storeInDatabase(a,"wasm",h,c.module).then(function(a){e.kConsoleLog&&kConsoleLog(a+", timecost: "+((new Date).getTime()-f));e.kConsoleLog&&kConsoleLog("finish handle dbr wasm, total timecost: "+((new Date).getTime()-g));return Promise.resolve(c)})}e.kConsoleLog&&kConsoleLog("finish handle dbr wasm, total timecost: "+((new Date).getTime()-g));return Promise.resolve(c)})},function(m){e.kConsoleLog&&
dynamsoft.BarcodeReader.loadWasm=dynamsoft.BarcodeReader.loadWasm||function(){return new Promise(function(c,f){var a=dynamsoft.dbrEnv,e=a._self,d=dynamsoft.BarcodeReader;if("loaded"==d._loadWasmStatus)return c();d._loadWasmTaskQueue=d._loadWasmTaskQueue||function(){var a=new dynamsoft.TaskQueue;a.timeout=0;return a}();d._loadWasmTaskQueue.push(function(g){if("loaded"==d._loadWasmStatus)return d._loadWasmTaskQueue.next(),c();if(g)return d._loadWasmTaskQueue.next(),f(d._loadWasmStatus);d._loadWasmStatus=
"loading";return(new Promise(function(b,c){d._BarcodeReaderWasm=function(){throw Error("'Constructor BarcodeReader(licenseKey)': The wasm hasn't finish loading.");};if(!e.WebAssembly||"undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&/\(.+\s11_2_([2-6]).*\)/.test(navigator.userAgent))return c("'Constructor BarcodeReader(licenseKey)': The browser doesn't support Webassembly.");if(a._bDom)return d._loadWorker().then(function(){d._BarcodeReaderWasm=
function(){this.bInWorker=!0};return b()},function(a){d._BarcodeReaderWasm=function(){throw Error("'Constructor BarcodeReader(licenseKey)': The wasm load failed. ex: "+(a.message||a));};return c(a)});var f={locateFile:function(){var b=d._wasmName||"dbr-"+d._jsVersion+(d._bWithio?".withio":"")+".wasm";if(d._wasmResourcePath||d._resourcesPath){var c=d._wasmResourcePath||d._resourcesPath;"/"!=c.charAt(c.length-1)&&(c+="/");b=c+b}else a._bNodejs&&(b=require("path").join(__dirname,b));return b},onRuntimeInitialized:function(){d._BarcodeReaderWasm=
f.BarcodeReaderWasm;var a=new f.BarcodeReaderWasm("");d.version=a.GetVersion()+"(JS "+d._jsVersion+"."+d._jsEditVersion+")";d._defaultRuntimeSettings=d._handleRetJsonString(a.GetRuntimeSettings());a.delete();e.kConsoleLog&&e.kConsoleLog("load dbr wasm success, version: "+d.version);b()}};f.onExit=f.onAbort=function(a){e.kConsoleLog&&kConsoleLog(a);d._BarcodeReaderWasm=function(){throw Error("'Constructor BarcodeReader(licenseKey)': The wasm load failed. Error: "+(a.message||a));};c(a)};f.print=function(a){e.kConsoleLog&&
kConsoleLog(a)};if("undefined"==typeof _dbrLoadWasm){void 0==d._bWithio&&(d._bWithio=a._bNodejs||a._bWorker&&(d._bCustomWorker||e.onmessage!=d._onWorkerMessage));var g=d._wasmjsName||"dbr-"+d._jsVersion+".wasm"+(d._bWithio?".withio":"")+".min.js";if(d._wasmjsResourcePath||d._resourcesPath){var h=d._wasmjsResourcePath||d._resourcesPath;"/"!=h.charAt(h.length-1)&&(h+="/");g=h+g}else a._bNodejs&&(g=require("path").join(__dirname,g));a._bWorker?importScripts(g):_dbrLoadWasm=require(g)}_dbrLoadWasm(f,
function(b,c,f){e.kConsoleLog&&kConsoleLog("start handle dbr wasm, version: "+b);var g=(new Date).getTime();if(a._bNodejs)return new Promise(function(a,b){require("fs").readFile(c,function(c,d){if(c)return b(c);var m=(new Date).getTime();a(WebAssembly.instantiate(d,f).then(function(a){e.kConsoleLog&&kConsoleLog("build instance from binary timecost: "+((new Date).getTime()-m));e.kConsoleLog&&kConsoleLog("finish handle dbr wasm, total timecost: "+((new Date).getTime()-g));return Promise.resolve(a)}))})});
var h=""+b;d._openDb=d._openDb||function(){return new Promise(function(a,b){var c=function(){d.result.createObjectStore("info");d.result.createObjectStore("wasm");d.result.createObjectStore("module")},d=indexedDB.open("dynamsoft-dbr-wasm",1);d.onupgradeneeded=c;d.onsuccess=function(){a(d.result)};d.onerror=function(){var e=d.error.message||d.error;-1!=e.indexOf("version")?(d=indexedDB.deleteDatabase("dynamsoft-dbr-wasm"),d.onsuccess=function(){var d=indexedDB.open("dynamsoft-dbr-wasm",1);d.onupgradeneeded=
c;d.onsuccess=function(){a(d.result)};d.onerror=function(){b("open db [dynamsoft-dbr-wasm] fail")}},d.onerror=function(){b("open db [dynamsoft-dbr-wasm] fail")}):b("open db [dynamsoft-dbr-wasm] fail: "+e)}})};var l=function(a){return new Promise(function(b,c){var d=a.transaction(["info"]).objectStore("info").get("bSupportStoreModuleInDb"),e=function(){var d=a.transaction(["info"],"readwrite").objectStore("info"),e=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,127,3,2,1,0,7,6,1,2,95,97,0,0,10,
6,1,4,0,65,1,11]);try{var f=d.put(new WebAssembly.Module(e.buffer),"testStoreModule");f.onsuccess=function(){d.put(!0,"bSupportStoreModuleInDb").onsuccess=function(){b("set bSupportStoreModuleInDb = true success")}};f.onerror=function(){c("Failed to store [testStoreModule] in wasm cache, bSupportStoreModuleInDb == false: "+(f.error.message||f.error))}}catch(y){c("Failed to store [testStoreModule] in wasm cache, bSupportStoreModuleInDb == false: "+(y.message||y))}};d.onsuccess=function(){d.result?
b("bSupportStoreModuleInDb == true"):e()}})};d._lookupInDatabase=d._lookupInDatabase||function(a,b,c){return new Promise(function(d,e){var f=a.transaction([b]).objectStore(b).get(c);f.onsuccess=function(){f.result?d(f.result):e(c+" was not found in "+b)}})};d._storeInDatabase=d._storeInDatabase||function(a,b,c,d){return new Promise(function(e,f){var m=a.transaction([b],"readwrite").objectStore(b).put(d,c);m.onerror=function(){f("Failed to store "+c+" in wasm cache: "+(m.error.message||m.error))};
m.onsuccess=function(){e("Successfully stored "+c+" in "+b)}})};return d._openDb().then(function(a){e.kConsoleLog&&kConsoleLog("open db success");return l(a).then(function(a){e.kConsoleLog&&kConsoleLog(a);return Promise.resolve(!0)},function(a){e.kConsoleLog&&kConsoleLog(a.message||a);return Promise.resolve(!1)}).then(function(b){var m=(new Date).getTime();return d._lookupInDatabase(a,"wasm",h).then(function(c){if(c instanceof WebAssembly.Module){e.kConsoleLog&&kConsoleLog("get a wasm module from db, timecost:"+
((new Date).getTime()-m));var k=(new Date).getTime();return WebAssembly.instantiate(c,f).then(function(a){e.kConsoleLog&&kConsoleLog("build instance from module timecost: "+((new Date).getTime()-k));e.kConsoleLog&&kConsoleLog("finish handle dbr wasm, total timecost: "+((new Date).getTime()-g));return Promise.resolve({module:c,instance:a})})}e.kConsoleLog&&kConsoleLog("get a wasm binary from db, timecost:"+((new Date).getTime()-m));var n=(new Date).getTime();return WebAssembly.instantiate(c,f).then(function(c){e.kConsoleLog&&
kConsoleLog("build instance from binary timecost: "+((new Date).getTime()-n));if(b){var f=(new Date).getTime();return d._storeInDatabase(a,"wasm",h,c.module).then(function(a){e.kConsoleLog&&kConsoleLog(a+", timecost: "+((new Date).getTime()-f));e.kConsoleLog&&kConsoleLog("finish handle dbr wasm, total timecost: "+((new Date).getTime()-g));return Promise.resolve(c)})}e.kConsoleLog&&kConsoleLog("finish handle dbr wasm, total timecost: "+((new Date).getTime()-g));return Promise.resolve(c)})},function(m){e.kConsoleLog&&
kConsoleLog(m.message||m);e.kConsoleLog&&kConsoleLog("downloading...");var k=(new Date).getTime();return b?WebAssembly.instantiateStreaming(fetch(c),f).then(function(b){d._onWasmDownloaded&&d._onWasmDownloaded();e.kConsoleLog&&kConsoleLog("download with build timecost: "+((new Date).getTime()-k));var c=(new Date).getTime();return d._storeInDatabase(a,"wasm",h,b.module).then(function(a){e.kConsoleLog&&kConsoleLog(a+", timecost: "+((new Date).getTime()-c));e.kConsoleLog&&kConsoleLog("finish handle dbr wasm, total timecost: "+

@@ -63,21 +75,23 @@ ((new Date).getTime()-g));return Promise.resolve(b)},function(a){e.kConsoleLog&&kConsoleLog(a.message||a);return Promise.reject("Can't store wasm in db.")})}):fetch(c).then(function(a){return a.arrayBuffer()}).then(function(b){e.kConsoleLog&&kConsoleLog("download timecost: "+((new Date).getTime()-k));d._onWasmDownloaded&&d._onWasmDownloaded();var c=(new Date).getTime();return d._storeInDatabase(a,"wasm",h,b).then(function(a){e.kConsoleLog&&kConsoleLog(a+", timecost: "+((new Date).getTime()-c));return Promise.resolve(b)},

d)})).then(function(){d._loadWasmStatus="loaded";d._loadWasmTaskQueue.next();c()}).catch(function(a){d._loadWasmStatus=a;d._loadWasmTaskQueue.next();f(a)})},null,["loading"==d._loadWasmStatus])})};
dynamsoft.BarcodeReader.clearCache=dynamsoft.BarcodeReader.clearCache||function(){return new Promise(function(c,f){try{var b=window.indexedDB.deleteDatabase("dynamsoft-dbr-wasm");b.onsuccess=b.onerror=function(){b.error&&alert("Clear failed: "+(b.error.message||b.error));c()}}catch(e){alert(e.message||e),f()}})};
dynamsoft.BarcodeReader.VideoReader=function(c){c=c||{};var f;(f=c.htmlElement)||(f=document.createElement("div"),f.style.position="fixed",f.style.width="100%",f.style.height="100%",f.style.left="0",f.style.top="0",f.style.background="#eee",f.innerHTML='<p style="width:100%;height:32px;line-height:32px;position:absolute;margin:auto 0;top:0;bottom:0;text-align:center;">loading</p><video class="dbrVideoReader-video" playsinline="true" style="width:100%;height:100%;position:absolute;left:0;top:0;"></video><select class="dbrVideoReader-sel-camera" style="position:absolute;left:0;top:0;"></select><select class="dbrVideoReader-sel-resolution" style="position:absolute;left:0;top:20px;"></select><button class="dbrVideoReader-btn-close" style="position:absolute;right:0;top:0;"><svg width="16" height="16" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1490 1322q0 40-28 68l-136 136q-28 28-68 28t-68-28l-294-294-294 294q-28 28-68 28t-68-28l-136-136q-28-28-28-68t28-68l294-294-294-294q-28-28-28-68t28-68l136-136q28-28 68-28t68 28l294 294 294-294q28-28 68-28t68 28l136 136q28 28 28 68t-28 68l-294 294 294 294q28 28 28 68z"/></svg></button>');
this.htmlElement=f;this.videoSettings=c.videoSettings;this.confidence=c.confidence;void 0==this.confidence&&(this.confidence=30);this.intervalTime=c.intervalTime;void 0==this.intervalTime&&(this.intervalTime=100);this.runtimeSettings=c.runtimeSettings||{};this.beforeDecodeVideo=c.beforeDecodeVideo;this.duringDecodeVideo=c.duringDecodeVideo;this.onFrameRead=c.onFrameRead;this.forgetTime=c.forgetTime;void 0==this.forgetTime&&(this.forgetTime=3E3);this.onDiffCodeRead=c.onDiffCodeRead;this._isReading=
!1};dynamsoft.BarcodeReader.VideoReader.prototype.isReading=function(){return this._isReading};
dynamsoft.BarcodeReader.VideoReader.prototype.read=function(){var c=this;if(c._isReading)return Promise.reject("The VideoReader is reading.");c._isReading=!0;var f=c.htmlElement,b,e,d,h,a;(function(){for(var c=[],g=$jscomp.makeIterator(f.childNodes),m=g.next();!m.done;m=g.next())m=m.value,m.nodeType==Node.ELEMENT_NODE&&c.push(m);for(g=0;g<c.length;++g){var l=$jscomp.makeIterator(c[g].childNodes);for(m=l.next();!m.done;m=l.next())m=m.value,m.nodeType==Node.ELEMENT_NODE&&c.push(m)}c=$jscomp.makeIterator(c);
for(m=c.next();!m.done;m=c.next())m=m.value,m.classList.contains("dbrVideoReader-video")?b=m:m.classList.contains("dbrVideoReader-sel-camera")?e=m:m.classList.contains("dbrVideoReader-sel-resolution")?(d=m,d.options.length||(d.innerHTML='<option class="dbrVideoReader-opt-gotResolution" value="got"></option><option data-width="3840" data-height="2160">ask 3840 x 2160</option><option data-width="2560" data-height="1440">ask 2560 x 1440</option><option data-width="1920" data-height="1080">ask 1920 x 1080</option><option data-width="1600" data-height="1200">ask 1600 x 1200</option><option data-width="1280" data-height="720">ask 1280 x 720</option><option data-width="800" data-height="600">ask 800 x 600</option><option data-width="640" data-height="480">ask 640 x 480</option><option data-width="640" data-height="360">ask 640 x 360</option>',
h=d.options[0])):m.classList.contains("dbrVideoReader-opt-gotResolution")?h=m:m.classList.contains("dbrVideoReader-btn-close")&&(a=m)})();var g=c._updateDevice=function(){return navigator.mediaDevices.enumerateDevices().then(function(a){var c=[],d;if(e){var f=e.value;e.innerHTML=""}for(var g=0;g<a.length;++g){var h=a[g];if("videoinput"==h.kind){var k={};k.deviceId=h.deviceId;k.label=h.label||"camera "+g;c.push(k)}}a=$jscomp.makeIterator(b.srcObject.getTracks());for(g=a.next();!g.done;g=a.next()){g=
g.value;if(l)break;if("video"==g.kind)for(h=$jscomp.makeIterator(c),k=h.next();!k.done;k=h.next())if(k=k.value,g.label==k.label){var l=k;break}}if(e){a=$jscomp.makeIterator(c);for(k=a.next();!k.done;k=a.next())g=k.value,h=document.createElement("option"),h.value=g.deviceId,h.innerText=g.label,e.appendChild(h),f==g.deviceId&&(d=h);f=e.childNodes;if(!d&&l&&f.length)for(f=$jscomp.makeIterator(f),a=f.next();!a.done;a=f.next())if(a=a.value,l.label==a.innerText){d=a;break}d&&(e.value=d.value)}return Promise.resolve({current:l,
all:c})})};c._pausevideo=function(){b.pause()};var l=function(){b.srcObject&&(self.kConsoleLog&&self.kConsoleLog("======stop video========"),b.srcObject.getTracks().forEach(function(a){a.stop()}))},n=c._playvideo=function(a,e,f){return new Promise(function(g,m){l();self.kConsoleLog&&self.kConsoleLog("======before video========");var k=c.videoSettings=c.videoSettings||{video:{facingMode:{ideal:"environment"}}};/Safari/.test(navigator.userAgent)&&/iPhone/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)?
1280<=e?k.video.width=1280:640<=e?k.video.width=640:320<=e&&(k.video.width=320):(e&&(k.video.width={ideal:e}),f&&(k.video.height={ideal:f}));a&&(k.video.facingMode=void 0,k.video.deviceId={exact:a});var r=!1,n=function(){self.kConsoleLog&&self.kConsoleLog("======try getUserMedia========");self.kConsoleLog&&self.kConsoleLog("ask "+JSON.stringify(k.video.width)+"x"+JSON.stringify(k.video.height));navigator.mediaDevices.getUserMedia(k).then(function(a){self.kConsoleLog&&self.kConsoleLog("======get video========");
return new Promise(function(c,e){b.srcObject=a;b.onloadedmetadata=function(){self.kConsoleLog&&self.kConsoleLog("======play video========");b.play().then(function(){self.kConsoleLog&&self.kConsoleLog("======played video========");var a="got "+b.videoWidth+"x"+b.videoHeight;d&&h&&(h.setAttribute("data-width",b.videoWidth),h.setAttribute("data-height",b.videoHeight),d.value="got",h.innerText=a);self.kConsoleLog&&self.kConsoleLog(a);c();g({width:b.videoWidth,height:b.videoHeight})},function(a){e(a)})};
b.onerror=function(){e()}})}).catch(function(a){self.kConsoleLog&&self.kConsoleLog(a);!r&&k.video?(r=!0,k.video.width=void 0,k.video.height=void 0,n()):m(a)})};n()})};c.arrDiffCodeInfo=[];var p,q=function(){if(c._isReading){if(b.paused)return self.kConsoleLog&&self.kConsoleLog("Video is paused. Ask in 1s."),setTimeout(q,1E3);self.kConsoleLog&&self.kConsoleLog("======= once read =======");var a=(new Date).getTime();Promise.all([JSON.stringify(p.getRuntimeSettings())!=JSON.stringify(c.runtimeSettings)?
p.updateRuntimeSettings(c.runtimeSettings):Promise.resolve(),c.beforeDecodeVideo?c.beforeDecodeVideo(b):b]).then(function(a){if(c.duringDecodeVideo)return c.duringDecodeVideo({reader:p,args:a[1]});a=a[1];a instanceof Array||(a=[a]);return p.decodeVideo.apply(p,a)}).then(function(b){var d=(new Date).getTime();self.kConsoleLog&&self.kConsoleLog("time cost: "+(d-a)+"ms");for(var e=[],f=0;f<b.length;++f){var g=b[f],h=g.BarcodeText;self.kConsoleLog&&self.kConsoleLog(h);g.LocalizationResult.ExtendedResultArray[0].Confidence>=
c.confidence&&e.push(g)}e=JSON.parse(JSON.stringify(e));for(f=0;f<c.arrDiffCodeInfo.length;++f){g=c.arrDiffCodeInfo[f];h=-1;for(var k in e){var l=e[k];g.result.BarcodeText==l.BarcodeText&&g.result.BarcodeFormat==l.BarcodeFormat&&(h=k)}-1!=h?(g.time=d,g.result=e[h],e.splice(h,1)):d-g.time>c.forgetTime&&(c.arrDiffCodeInfo.splice(f,1),--f)}for(k=0;k<e.length;++k)for(f=e[k],g=k+1;g<e.length;)h=e[g],f.BarcodeText==h.BarcodeText&&f.BarcodeFormat==h.BarcodeFormat?e.splice(g,1):++g;f=$jscomp.makeIterator(e);
for(k=f.next();!k.done;k=f.next())c.arrDiffCodeInfo.push({result:k.value,time:d});if(c.onFrameRead)c.onFrameRead(JSON.parse(JSON.stringify(b)));b=$jscomp.makeIterator(e);for(k=b.next();!k.done;k=b.next())if(d=k.value,c.onDiffCodeRead)c.onDiffCodeRead(d.BarcodeText,JSON.parse(JSON.stringify(d)));setTimeout(q,c.intervalTime)}).catch(function(a){self.kConsoleLog&&self.kConsoleLog(a);setTimeout(q,c.intervalTime);throw a;})}else p&&(p.deleteInstance(),p=void 0)},t=function(){n(e.value).then(function(){c._isReading||
l()}).catch(function(a){alert("Play video failed: "+(a.message||a))})};e&&e.addEventListener("change",t);var v=function(){if(d&&-1!=d.selectedIndex){var a=d.options[d.selectedIndex];var b=a.getAttribute("data-width");a=a.getAttribute("data-height")}n(void 0,b,a).then(function(){c._isReading||l()}).catch(function(a){alert("Play video failed: "+(a.message||a))})};d&&d.addEventListener("change",v);var w=!!f.parentNode,u=c._closeWindow=function(){l();c._isReading=!1;e&&e.removeEventListener("change",
t);d&&d.removeEventListener("change",v);c._closeWindow=void 0;a&&a.removeEventListener("click",u);var b=f.parentNode;b&&!w&&b.removeChild(f)};a&&a.addEventListener("click",u);w||document.body.appendChild(f);return Promise.all([dynamsoft.BarcodeReader.loadWasm(),n()]).then(function(a){if(!c._isReading)return l(),Promise.resolve();p=new dynamsoft.BarcodeReader;var b=p.getRuntimeSettings();b.mAntiDamageLevel=3;b.mDeblurLevel=0;for(var d in c.runtimeSettings)void 0!=b[d]&&(b[d]=c.runtimeSettings[d]);
c.runtimeSettings=b;return Promise.all([a[1],p.updateRuntimeSettings(b)])}).then(function(a){q();return Promise.all([a[0],g()])}).then(function(a){var b=a[0];a=a[1];return Promise.resolve({width:b.width,height:b.height,current:a.current,all:a.all})})};dynamsoft.BarcodeReader.VideoReader.prototype.play=function(c,f,b){return this._isReading?this._playvideo(c,f,b):Promise.reject("It has not started reading.")};dynamsoft.BarcodeReader.VideoReader.prototype.pause=function(){this._isReading&&this._pausevideo()};
dynamsoft.BarcodeReader.VideoReader.prototype.close=function(){this._isReading&&this._closeWindow()};dynamsoft.BarcodeReader.VideoReader.prototype.updateDevice=function(){return this._isReading?this._updateDevice():Promise.reject("It has not started reading.")};
dynamsoft.BarcodeReader.clearCache=dynamsoft.BarcodeReader.clearCache||function(){return new Promise(function(c,f){try{var a=window.indexedDB.deleteDatabase("dynamsoft-dbr-wasm");a.onsuccess=a.onerror=function(){a.error&&alert("Clear failed: "+(a.error.message||a.error));c()}}catch(e){alert(e.message||e),f()}})};
dynamsoft.BarcodeReader.Scanner=function(c){c=c||{};var f;(f=c.htmlElement)||(f=document.createElement("div"),f.style.position="fixed",f.style.width="100%",f.style.height="100%",f.style.left="0",f.style.top="0",f.style.background="#eee",f.innerHTML='<p style="width:100%;height:32px;line-height:32px;position:absolute;margin:auto 0;top:0;bottom:0;text-align:center;">loading</p><video class="dbrScanner-video" playsinline="true" style="width:100%;height:100%;position:absolute;left:0;top:0;"></video><select class="dbrScanner-sel-camera" style="position:absolute;left:0;top:0;"></select><select class="dbrScanner-sel-resolution" style="position:absolute;left:0;top:20px;"></select><button class="dbrScanner-btn-close" style="position:absolute;right:0;top:0;"><svg width="16" height="16" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1490 1322q0 40-28 68l-136 136q-28 28-68 28t-68-28l-294-294-294 294q-28 28-68 28t-68-28l-136-136q-28-28-28-68t28-68l294-294-294-294q-28-28-28-68t28-68l136-136q28-28 68-28t68 28l294 294 294-294q28-28 68-28t68 28l136 136q28 28 28 68t-28 68l-294 294 294 294q28 28 28 68z"/></svg></button>');
this.htmlElement=f;this.videoSettings=c.videoSettings;this.confidence=c.confidence;void 0==this.confidence&&(this.confidence=30);this.intervalTime=c.intervalTime;void 0==this.intervalTime&&(this.intervalTime=100);this.runtimeSettings=c.runtimeSettings||{};this.searchRegion=c.searchRegion||{sx:void 0,sy:void 0,sWidth:void 0,sHeight:void 0,dWidth:void 0,dHeight:void 0};this.bAddOriVideoCanvasToResult=c.bAddOriVideoCanvasToResult;this.bAddSearchRegionCanvasToResult=c.bAddSearchRegionCanvasToResult;this.onFrameRead=
c.onFrameRead;this.duplicateForgetTime=c.duplicateForgetTime;void 0==this.duplicateForgetTime&&(this.duplicateForgetTime=3E3);this.onNewCodeRead=c.onNewCodeRead;this._isOpen=!1};dynamsoft.BarcodeReader.Scanner.prototype.isOpen=function(){return this._isOpen};
dynamsoft.BarcodeReader.Scanner.prototype.open=function(){var c=this;if(c._isOpen)return Promise.reject("The scanner is already open.");c._isOpen=!0;var f=c.htmlElement,a,e,d,g,b;(function(){for(var c=[],m=$jscomp.makeIterator(f.children),n=m.next();!n.done;n=m.next())c.push(n.value);for(m=0;m<c.length;++m){var h=$jscomp.makeIterator(c[m].children);for(n=h.next();!n.done;n=h.next())c.push(n.value)}c=$jscomp.makeIterator(c);for(n=c.next();!n.done;n=c.next())n=n.value,n.classList.contains("dbrScanner-video")?
a=n:n.classList.contains("dbrScanner-sel-camera")?e=n:n.classList.contains("dbrScanner-sel-resolution")?(d=n,d.options.length||(d.innerHTML='<option class="dbrScanner-opt-gotResolution" value="got"></option><option data-width="3840" data-height="2160">ask 3840 x 2160</option><option data-width="2560" data-height="1440">ask 2560 x 1440</option><option data-width="1920" data-height="1080">ask 1920 x 1080</option><option data-width="1600" data-height="1200">ask 1600 x 1200</option><option data-width="1280" data-height="720">ask 1280 x 720</option><option data-width="800" data-height="600">ask 800 x 600</option><option data-width="640" data-height="480">ask 640 x 480</option><option data-width="640" data-height="360">ask 640 x 360</option>',
g=d.options[0])):n.classList.contains("dbrScanner-opt-gotResolution")?g=n:n.classList.contains("dbrScanner-btn-close")&&(b=n)})();var h=c._updateDevice=function(){return navigator.mediaDevices.enumerateDevices().then(function(b){var c=[],d;if(e){var f=e.value;e.innerHTML=""}for(var g=0;g<b.length;++g){var h=b[g];if("videoinput"==h.kind){var k={};k.deviceId=h.deviceId;k.label=h.label||"camera "+g;c.push(k)}}b=$jscomp.makeIterator(a.srcObject.getTracks());for(g=b.next();!g.done;g=b.next()){g=g.value;
if(l)break;if("video"==g.kind)for(h=$jscomp.makeIterator(c),k=h.next();!k.done;k=h.next())if(k=k.value,g.label==k.label){var l=k;break}}if(e){b=$jscomp.makeIterator(c);for(k=b.next();!k.done;k=b.next())g=k.value,h=document.createElement("option"),h.value=g.deviceId,h.innerText=g.label,e.appendChild(h),f==g.deviceId&&(d=h);f=e.childNodes;if(!d&&l&&f.length)for(f=$jscomp.makeIterator(f),b=f.next();!b.done;b=f.next())if(b=b.value,l.label==b.innerText){d=b;break}d&&(e.value=d.value)}return Promise.resolve({current:l,
all:c})})};c._pausevideo=function(){a.pause()};var p=function(){a.srcObject&&(self.kConsoleLog&&self.kConsoleLog("======stop video========"),a.srcObject.getTracks().forEach(function(a){a.stop()}))},l=c._playvideo=function(b,e,f){return new Promise(function(m,h){p();self.kConsoleLog&&self.kConsoleLog("======before video========");var k=c.videoSettings=c.videoSettings||{video:{facingMode:{ideal:"environment"}}};/Safari/.test(navigator.userAgent)&&/iPhone/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)?
1280<=e?k.video.width=1280:640<=e?k.video.width=640:320<=e&&(k.video.width=320):(e&&(k.video.width={ideal:e}),f&&(k.video.height={ideal:f}));b&&(k.video.facingMode=void 0,k.video.deviceId={exact:b});var n=!1,l=function(){self.kConsoleLog&&self.kConsoleLog("======try getUserMedia========");self.kConsoleLog&&self.kConsoleLog("ask "+JSON.stringify(k.video.width)+"x"+JSON.stringify(k.video.height));navigator.mediaDevices.getUserMedia(k).then(function(b){self.kConsoleLog&&self.kConsoleLog("======get video========");
return new Promise(function(c,e){a.srcObject=b;a.onloadedmetadata=function(){self.kConsoleLog&&self.kConsoleLog("======play video========");a.play().then(function(){self.kConsoleLog&&self.kConsoleLog("======played video========");var b="got "+a.videoWidth+"x"+a.videoHeight;d&&g&&(g.setAttribute("data-width",a.videoWidth),g.setAttribute("data-height",a.videoHeight),d.value="got",g.innerText=b);self.kConsoleLog&&self.kConsoleLog(b);c();m({width:a.videoWidth,height:a.videoHeight})},function(a){e(a)})};
a.onerror=function(){e()}})}).catch(function(a){self.kConsoleLog&&self.kConsoleLog(a);!n&&k.video?(n=!0,k.video.width=void 0,k.video.height=void 0,l()):h(a)})};l()})};c.arrDiffCodeInfo=[];var q,r=function(a,b){if(a instanceof Array){var c=[];a=$jscomp.makeIterator(a);for(var d=a.next();!d.done;d=a.next())c.push(r(d.value,b));return c}c=JSON.parse(JSON.stringify(a,function(a,b){if("oriVideoCanvas"!=a&&"searchRegionCanvas"!=a)return b}));b||(c.oriVideoCanvas=a.oriVideoCanvas,c.searchRegionCanvas=a.searchRegionCanvas);
return c},t=function(){if(c._isOpen){if(a.paused)return self.kConsoleLog&&self.kConsoleLog("Video is paused. Ask in 1s."),setTimeout(t,1E3);self.kConsoleLog&&self.kConsoleLog("======= once read =======");var b=(new Date).getTime();Promise.all([JSON.stringify(q.getRuntimeSettings())!=JSON.stringify(c.runtimeSettings)?q.updateRuntimeSettings(c.runtimeSettings):Promise.resolve(),function(){var b=c.searchRegion;if(b&&(b.sx||b.sy||b.sWidth||b.sHeight||b.dWidth||b.dHeight)){var d=b.sx||0,e=b.sy||0,f=b.sWidth||
a.videoWidth,g=b.sHeight||a.videoHeight,h=b.dWidth||b.sWidth||a.videoWidth;b=b.dHeight||b.sHeight||a.videoHeight;0<d&&1>d&&(d=Math.round(d*a.videoWidth));0<e&&1>e&&(e=Math.round(e*a.videoHeight));1>=f&&(f=Math.round(f*a.videoWidth));1>=g&&(g=Math.round(g*a.videoHeight));1>=h&&(h=Math.round(h*a.videoWidth));1>=g&&(b=Math.round(b*a.videoHeight));return[a,d,e,f,g,h,b]}return a}()]).then(function(a){a=a[1];a instanceof Array||(a=[a]);q._bAddOriVideoCanvasToResult=c.bAddOriVideoCanvasToResult;q._bAddSearchRegionCanvasToResult=
c.bAddSearchRegionCanvasToResult;return q.decodeVideo.apply(q,a)}).then(function(a){var d=(new Date).getTime();self.kConsoleLog&&self.kConsoleLog("time cost: "+(d-b)+"ms");for(var e=[],f=0;f<a.length;++f){var g=a[f],h=g.BarcodeText;self.kConsoleLog&&self.kConsoleLog(h);g.LocalizationResult.ExtendedResultArray[0].Confidence>=c.confidence&&e.push(g)}e=r(e);for(f=0;f<c.arrDiffCodeInfo.length;++f){g=c.arrDiffCodeInfo[f];h=-1;for(var k in e){var m=e[k];if(g.result.BarcodeText==m.BarcodeText&&g.result.BarcodeFormat==
m.BarcodeFormat){h=k;break}}-1!=h?(g.time=d,g.result=e[h],++g.count,e.splice(h,1)):d-g.time>c.duplicateForgetTime&&(c.arrDiffCodeInfo.splice(f,1),--f)}for(k=0;k<e.length;++k)for(f=e[k],g=k+1;g<e.length;)h=e[g],f.BarcodeText==h.BarcodeText&&f.BarcodeFormat==h.BarcodeFormat?e.splice(g,1):++g;f=$jscomp.makeIterator(e);for(k=f.next();!k.done;k=f.next())c.arrDiffCodeInfo.push({result:r(k.value,!0),time:d,count:1});if(c.onFrameRead)c.onFrameRead(r(a));a=$jscomp.makeIterator(e);for(k=a.next();!k.done;k=
a.next())if(d=k.value,c.onNewCodeRead)c.onNewCodeRead(d.BarcodeText,r(d));setTimeout(t,c.intervalTime)}).catch(function(a){self.kConsoleLog&&self.kConsoleLog(a);setTimeout(t,c.intervalTime);throw a;})}else q&&(q.deleteInstance(),q=void 0)},w=function(){l(e.value).then(function(){c._isOpen||p()}).catch(function(a){alert("Play video failed: "+(a.message||a))})};e&&e.addEventListener("change",w);var x=function(){if(d&&-1!=d.selectedIndex){var a=d.options[d.selectedIndex];var b=a.getAttribute("data-width");
a=a.getAttribute("data-height")}l(void 0,b,a).then(function(){c._isOpen||p()}).catch(function(a){alert("Play video failed: "+(a.message||a))})};d&&d.addEventListener("change",x);var v=!!f.parentNode,u=c._closeWindow=function(){p();c._isOpen=!1;e&&e.removeEventListener("change",w);d&&d.removeEventListener("change",x);c._closeWindow=void 0;b&&b.removeEventListener("click",u);var a=f.parentNode;a&&!v&&a.removeChild(f)};b&&b.addEventListener("click",u);v||document.body.appendChild(f);return Promise.all([dynamsoft.BarcodeReader.loadWasm(),
l()]).then(function(a){if(!c._isOpen)return p(),Promise.resolve();q=new dynamsoft.BarcodeReader;var b=q.getRuntimeSettings();b.mAntiDamageLevel=3;b.mDeblurLevel=0;for(var d in c.runtimeSettings)void 0!=b[d]&&(b[d]=c.runtimeSettings[d]);c.runtimeSettings=b;return Promise.all([a[1],q.updateRuntimeSettings(b)])}).then(function(a){t();return Promise.all([a[0],h()])}).then(function(a){var b=a[0];a=a[1];return Promise.resolve({width:b.width,height:b.height,current:a.current,all:a.all})})};
dynamsoft.BarcodeReader.Scanner.prototype.play=function(c,f,a){return this._isOpen?this._playvideo(c,f,a):Promise.reject("The scanner is not open.")};dynamsoft.BarcodeReader.Scanner.prototype.pause=function(){this._isOpen&&this._pausevideo()};dynamsoft.BarcodeReader.Scanner.prototype.close=function(){this._isOpen&&this._closeWindow()};
dynamsoft.BarcodeReader.Scanner.prototype.updateDevice=function(){return this._isOpen?this._updateDevice():navigator.mediaDevices.enumerateDevices().then(function(c){for(var f=[],a=0;a<c.length;++a){var e=c[a];if("videoinput"==e.kind){var d={};d.deviceId=e.deviceId;d.label=e.label||"camera "+a;f.push(d)}}return Promise.resolve({current:void 0,all:f})})};
export default dynamsoft.BarcodeReader;

@@ -1,78 +0,91 @@

var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(h){var c=0;return function(){return c<h.length?{done:!1,value:h[c++]}:{done:!0}}};$jscomp.arrayIterator=function(h){return{next:$jscomp.arrayIteratorImpl(h)}};$jscomp.makeIterator=function(h){var c="undefined"!=typeof Symbol&&Symbol.iterator&&h[Symbol.iterator];return c?c.call(h):$jscomp.arrayIterator(h)};
(function(h,c){"undefined"!=typeof self&&self.document&&(self.__dbrWasmCurrentScript__=document.currentScript.src.substring(0,document.currentScript.src.lastIndexOf("/")));"function"===typeof define&&(define.amd||define.cmd)?define(c):"object"===typeof module&&module.exports?module.exports=c():(h.dynamsoft=h.dynamsoft||{},h.dynamsoft.BarcodeReader=c(),h.BarcodeReader=h.BarcodeReader||c(),h.dbr=h.dbr||c())})(this,function(){var h="undefined"!=typeof h?h:("undefined"!=typeof h?this.dynamsoft:void 0)||
{};h.TaskQueue=h.TaskQueue||function(){var c=function(){this._queue=[];this.isWorking=!1;this.timeout=100};c.prototype.push=function(c,b,e){this._queue.push({task:c,context:b,args:e});this.isWorking||this.next()};c.prototype.unshift=function(c,b,e){this._queue.unshift({task:c,context:b,args:e});this.isWorking||this.next()};c.prototype.next=function(){if(0==this._queue.length)this.isWorking=!1;else{this.isWorking=!0;var c=this._queue.shift(),b=c.task,e=c.context?c.context:null,d=c.args?c.args:[];setTimeout(function(){b.apply(e,
d)},this.timeout)}};return c}();h.dbrEnv=h.dbrEnv||{};"undefined"!=typeof self?(h.dbrEnv._self=self,self.document?h.dbrEnv._bDom=!0:h.dbrEnv._bWorker=!0):(h.dbrEnv._self=global,h.dbrEnv._bNodejs=!0);h.BarcodeReader=h.BarcodeReader||function(){var c=h.dbrEnv,g=c._self,b=function(a){a=a||b.licenseKey||"";if(!("string"==typeof a||"object"==typeof a&&a instanceof String))throw TypeError("'Constructor BarcodeReader(licenseKey)': Type of 'licenseKey' should be 'String'.");this._licenseKey=a;if(b._BarcodeReaderWasm){this._instance=
new b._BarcodeReaderWasm(this._licenseKey);if(!this._instance)throw b.BarcodeReaderException(b.EnumErrorCode.DBR_NULL_REFERENCE,"Can't create BarcodeReader instance.");this._instance.bInWorker&&(this._instance=void 0)}else throw Error("'Constructor BarcodeReader(licenseKey)': Autoload haven't start or you want to call `loadWasm` manually.");};b._jsVersion="6.5.0.3";b._jsEditVersion="20190409";b.version="loading...(JS "+b._jsVersion+"."+b._jsEditVersion+")";b.isLoaded=function(){return"loaded"==this._loadWasmStatus};
b.licenseKey=void 0;var e=c._bDom?__dbrWasmCurrentScript__:void 0;b._resourcesPath=e;b._workerName=void 0;b._wasmjsName=void 0;b._wasmName=void 0;b._workerResourcePath=void 0;b._wasmjsResourcePath=void 0;b._wasmResourcePath=void 0;b._isShowRelDecodeTimeInResults=!1;b._bCustomWorker=void 0;b._bWithio=void 0;b._onWasmDownloaded=void 0;b.createInstance=function(a){return b.loadWasm().then(function(){return Promise.resolve(new b(a))})};var d={};b._loadWorker=function(){return new Promise(function(a,f){var c=
b._workerName||"dbr-"+b._jsVersion+".min.js";if(b._workerResourcePath||b._resourcesPath){var p=b._workerResourcePath||b._resourcesPath;"/"!=p.charAt(p.length-1)&&(p+="/");c=p+c}fetch(c).then(function(a){return a.blob()}).then(function(c){var p=URL.createObjectURL(c);c=b._dbrWorker=new Worker(p);c.onerror=function(a){a="worker error, you should host the page in web service: "+a.message;g.kConsoleLog&&g.kConsoleError(a);f(a)};c.onmessage=function(c){c=c.data;switch(c.type){case "log":g.kConsoleLog&&
g.kConsoleLog(c.message);break;case "load":c.success?(b.version=c.version,b._defaultRuntimeSettings=c._defaultRuntimeSettings,g.kConsoleLog&&g.kConsoleLog("load dbr worker success"),a()):f(c.exception);URL.revokeObjectURL(p);break;case "task":try{d[c.id](c.body),d[c.id]=void 0}catch(l){throw d[c.id]=void 0,l;}break;default:g.kConsoleLog&&g.kConsoleLog(c)}};var e=document.createElement("a");e.href=b._resourcesPath||"./";var n=void 0;b._wasmjsResourcePath&&(n=document.createElement("a"),n.href=b._wasmjsResourcePath||
"./",n=n.href);var q=void 0;b._wasmResourcePath&&(q=document.createElement("a"),q.href=b._wasmResourcePath||"./",q=q.href);c.postMessage({type:"loadWorker",_resourcesPath:e.href,_wasmjsResourcePath:n,_wasmResourcePath:q,origin:location.origin})}).catch(function(a){f(a)})})};b.prototype._createWorkerInstance=function(){var a=this;return new Promise(function(c,n){var f=Math.random();d[f]=function(d){return d.success?d.instanceID?(a._instanceID=d.instanceID,c()):n(b.BarcodeReaderException(b.EnumErrorCode.DBR_NULL_REFERENCE,
"Can't create BarcodeReader instance.")):n(d.exception)};b._dbrWorker.postMessage({type:"createInstance",id:f,licenseKey:a._licenseKey})})};b.prototype.deleteInstance=function(){var a=this;if(this._instance)this._instance.delete();else return new Promise(function(c,n){var f=Math.random();d[f]=function(a){return a.success?c():n(a.exception)};b._dbrWorker.postMessage({type:"deleteInstance",id:f,instanceID:a._instanceID})})};b.prototype._decodeBlob=function(a,b){var d=this;if(!(g.Blob&&a instanceof Blob))return Promise.reject("'_decodeBlob(blob, templateName)': Type of 'blob' should be 'Blob'.");
b=b||"";return c._bDom?(new Promise(function(b,d){var c=URL.createObjectURL(a),f=new Image;f.dbrObjUrl=c;f.src=c;f.onload=function(){b(f)};f.onerror=function(){d(TypeError("'_decodeBlob(blob, templateName)': Can't convert the blob to image."))}})).then(function(a){return d._decodeImage(a)}):(new Promise(function(b){var d=new FileReader;d.onload=function(){b(d.result)};d.readAsArrayBuffer(a)})).then(function(a){return d._decodeArrayBuffer(a,b)})};b.prototype._decodeArrayBuffer=function(a,b){if(!(g.arrayBuffer&&
a instanceof ArrayBuffer||g.Buffer&&a instanceof Buffer))return Promise.reject("'_decodeBlob(arrayBuffer, templateName)': Type of 'arrayBuffer' should be 'ArrayBuffer' or 'Buffer'.");b=b||"";return c._bDom?this._decodeBlob(new Blob(a),b):this._decodeUint8Array(new Uint8Array(a))};b.prototype._decodeUint8Array=function(a,d){var f=this;if(!(g.Uint8Array&&a instanceof Uint8Array||g.Uint8ClampedArray&&a instanceof Uint8ClampedArray))return Promise.reject("'_decodeBlob(uint8Array, templateName)': Type of 'uint8Array' should be 'Uint8Array'.");
d=d||"";return c._bDom?f._decodeBlob(new Blob(a),d):new Promise(function(c){if(b._isShowRelDecodeTimeInResults){var p=(new Date).getTime(),k=f._instance.DecodeFileInMemory(a,d);p=(new Date).getTime()-p;k=m(k);k._decodeTime=p;return c(k)}return c(m(f._instance.DecodeFileInMemory(a,d)))})};b.prototype._decodeImage=function(a,b){var d=this;return(new Promise(function(d){if(!(g.HTMLImageElement&&a instanceof HTMLImageElement))throw TypeError("'_decodeImage(image, templateName)': Type of 'image' should be 'HTMLImageElement'.");
if(a.crossOrigin&&"anonymous"!=a.crossOrigin)throw"cors";b=b||"";d()})).then(function(){var c=document.createElement("canvas");c.width=a.naturalWidth;c.height=a.naturalHeight;c.getContext("2d").drawImage(a,0,0);a.dbrObjUrl&&URL.revokeObjectURL(a.dbrObjUrl);return d._decodeCanvas(c,b)})};b.prototype._decodeCanvas=function(a,d){var c=this;return(new Promise(function(b){if(!(g.HTMLCanvasElement&&a instanceof HTMLCanvasElement))throw TypeError("'_decodeCanvas(canvas, templateName)': Type of 'canvas' should be 'HTMLCanvasElement'.");
if(a.crossOrigin&&"anonymous"!=a.crossOrigin)throw"cors";d=d||"";var c=a.getContext("2d").getImageData(0,0,a.width,a.height).data;b(c)})).then(function(f){return c._decodeRawImageUint8Array(f,a.width,a.height,4*a.width,b.EnumImagePixelFormat.IPF_ARGB_8888,d)})};b.prototype._decodeVideo=b.prototype.decodeVideo=function(a){var b=this,d,c=arguments;return(new Promise(function(b){if(!(g.HTMLVideoElement&&a instanceof HTMLVideoElement))throw TypeError("'_decodeVideo(video [ [, sx, sy, sWidth, sHeight], dWidth, dHeight] [, templateName] )': Type of 'video' should be 'HTMLVideoElement'.");
if(a.crossOrigin&&"anonymous"!=a.crossOrigin)throw"cors";var f,e,n;if(2>=c.length){var p=f=0;var m=e=a.videoWidth;var l=n=a.videoHeight}else 4>=c.length?(p=f=0,m=a.videoWidth,l=a.videoHeight,e=c[1],n=c[2]):(p=c[1],f=c[2],m=c[3],l=c[4],e=c[5],n=c[6]);d="string"==typeof c[c.length-1]?c[c.length-1]:"";var r=document.createElement("canvas");r.width=e;r.height=n;r.getContext("2d").drawImage(a,p,f,m,l,0,0,e,n);b(r)})).then(function(a){return b._decodeCanvas(a,d)})};b.prototype._decodeBase64=b.prototype.decodeBase64String=
function(a,b){var d=this;if(!("string"==typeof a||"object"==typeof a&&a instanceof String))return Promise.reject("'decodeBase64(base64Str, templateName)': Type of 'base64Str' should be 'String'.");"data:image/"==a.substring(0,11)&&(a=a.substring(a.indexOf(",")+1));b=b||"";return new Promise(function(f){if(c._bNodejs)f(d._decodeArrayBuffer(Buffer.from(a,"base64"),b));else{for(var e=atob(a),k=e.length,g=new Uint8Array(k);k--;)g[k]=e.charCodeAt(k);c._bDom?f(d._decodeBlob(new Blob([g]),b)):f(d._decodeUint8Array(g,
b))}})};b.prototype._decodeUrl=function(a,b){var d=this;return new Promise(function(f,e){if(!("string"==typeof a||"object"==typeof a&&a instanceof String))throw TypeError("'_decodeUrl(url, templateName)': Type of 'url' should be 'String'.");b=b||"";if(c._bNodejs)(a.startsWith("https")?require("https"):require("http")).get(a,function(a){if(200==a.statusCode){var c=[];a.on("data",function(a){c.push(a)}).on("end",function(){f(d._decodeArrayBuffer(Buffer.concat(c),b))})}else e("http get fail, statusCode: "+
a.statusCode)});else{var k=new XMLHttpRequest;k.open("GET",a,!0);k.responseType=c._bDom?"blob":"arraybuffer";k.send();k.onloadend=function(){c._bDom?f(d._decodeBlob(this.response,b)):f(d._decodeArrayBuffer(this.response,b))};k.onerror=function(){e(k.error)}}})};b.prototype._decodeFilePath=function(a,b){var d=this;return new Promise(function(c,f){if(!("string"==typeof a||"object"==typeof a&&a instanceof String))throw TypeError("'_decodeFilePath(path, templateName)': Type of 'path' should be 'String'.");
b=b||"";require("fs").readFile(a,function(a,e){a?f(a):c(d._decodeArrayBuffer(e,b))})})};b.prototype._decodeRawImageBlob=function(a,b,d,c,e,k){var f=this;return(new Promise(function(b,d){if(!(g.Blob&&a instanceof Blob))throw TypeError("'_decodeRawImageBlob(buffer, width, height, stride, enumImagePixelFormat, templateName)': Type of 'buffer' should be 'Blob'.");k=k||"";var c=new FileReader;c.readAsArrayBuffer(a);c.onload=function(){b(c.result)};c.onerror=function(){d(c.error)}})).then(function(a){return f._decodeRawImageUint8Array(new Uint8Array(a),
b,d,c,e,k)})};b.prototype._decodeRawImageArrayBuffer=function(a,b,d,c,e,k){var f=this;return(new Promise(function(b){if(!(g.ArrayBuffer&&a instanceof ArrayBuffer))throw TypeError("'_decodeRawImageArrayBuffer(buffer, width, height, stride, enumImagePixelFormat, templateName)': Type of 'buffer' should be 'ArrayBuffer'.");k=k||"";b()})).then(function(){return f._decodeRawImageUint8Array(new Uint8Array(a),b,d,c,e,k)})};b.prototype._decodeRawImageUint8Array=function(a,c,e,h,q,k){var f=this;return(new Promise(function(b){if(!(g.Uint8Array&&
a instanceof Uint8Array||g.Uint8ClampedArray&&a instanceof Uint8ClampedArray))throw TypeError("'_decodeRawImageUint8Array(buffer, width, height, stride, enumImagePixelFormat, templateName)': Type of 'buffer' should be 'Uint8Array'.");k=k||"";f._localizationResultArray=void 0;b()})).then(function(){if(f._instance){if(b._isShowRelDecodeTimeInResults){var g=(new Date).getTime(),n=f._instance.DecodeBuffer(a,c,e,h,q,k);g=(new Date).getTime()-g;n=m(n);n._decodeTime=g;return Promise.resolve(n)}return Promise.resolve(m(f._instance.DecodeBuffer(a,
c,e,h,q,k)))}var p;n=f._instanceID?Promise.resolve():f._createWorkerInstance();return n.then(function(){return null===f._runtimeSettings?new Promise(function(a,c){var e=Math.random();d[e]=function(b){return b.success?(f._runtimeSettings=void 0,a()):c(b.exception)};b._dbrWorker.postMessage({type:"resetRuntimeSettings",id:e,instanceID:f._instanceID})}):Promise.resolve()}).then(function(){return new Promise(function(g,r){var t=Math.random();d[t]=function(a){return a.success?g(a.results):r(a.exception)};
b._dbrWorker.postMessage({type:"decodeRawImageUint8Array",id:t,instanceID:f._instanceID,body:{buffer:a,width:c,height:e,stride:h,enumImagePixelFormat:q,templateName:k},_isShowRelDecodeTimeInResults:b._isShowRelDecodeTimeInResults})})}).then(function(a){p=a;return new Promise(function(a,c){var e=Math.random();d[e]=function(b){return b.success?a(b.results):c(b.exception)};b._dbrWorker.postMessage({type:"getAllLocalizationResults",id:e,instanceID:f._instanceID})})}).then(function(a){f._localizationResultArray=
a;return Promise.resolve(p)})})};b.prototype.decode=b.prototype.decodeFileInMemory=function(a,b){return g.Blob&&a instanceof Blob?this._decodeBlob(a,b):g.ArrayBuffer&&a instanceof ArrayBuffer||g.Buffer&&a instanceof Buffer?this._decodeArrayBuffer(a,b):g.Uint8Array&&a instanceof Uint8Array||g.Uint8ClampedArray&&a instanceof Uint8ClampedArray?this._decodeUint8Array(a,b):g.HTMLImageElement&&a instanceof HTMLImageElement?this._decodeImage(a,b):g.HTMLCanvasElement&&a instanceof HTMLCanvasElement?this._decodeCanvas(a,
b):g.HTMLVideoElement&&a instanceof HTMLVideoElement?this._decodeVideo(a,b):"string"==typeof a||a instanceof String?"data:image/"==a.substring(0,11)?this._decodeBase64(a,b):c._bNodejs?"http"==a.substring(0,4)?this._decodeUrl(a,b):this._decodeFilePath(a,b):this._decodeUrl(a,b):Promise.reject(TypeError("'_decode(source, templateName)': Type of 'source' should be 'Blob', 'ArrayBuffer', 'Uint8Array', 'HTMLImageElement', 'HTMLCanvasElement', 'HTMLVideoElement', 'String(base64 with image mime)' or 'String(url)'."))};
b.prototype._decodeRawImage=b.prototype.decodeBuffer=function(a,b,c,d,e,k){return g.Blob&&a instanceof Blob?this._decodeRawImageBlob(a,b,c,d,e,k):g.ArrayBuffer&&a instanceof ArrayBuffer?this._decodeRawImageArrayBuffer(a,b,c,d,e,k):g.Uint8Array&&a instanceof Uint8Array||g.Uint8ClampedArray&&a instanceof Uint8ClampedArray?this._decodeRawImageUint8Array(a,b,c,d,e,k):Promise.reject(TypeError("'_decodeRawImage(source, width, height, stride, enumImagePixelFormat, templateName)': Type of 'source' should be 'Blob', 'ArrayBuffer' or 'Uint8Array'."))};
var m=b._handleRetJsonString=function(a){a="string"==typeof a||"object"==typeof a&&a instanceof String?JSON.parse(a):a;var d=b.EnumErrorCode;switch(a.exception){case d.DBR_SUCCESS:case d.DBR_LICENSE_INVALID:case d.DBR_LICENSE_EXPIRED:case d.DBR_1D_LICENSE_INVALID:case d.DBR_QR_LICENSE_INVALID:case d.DBR_PDF417_LICENSE_INVALID:case d.DBR_DATAMATRIX_LICENSE_INVALID:case d.DBR_DBRERR_AZTEC_LICENSE_INVALID:case d.DBR_RECOGNITION_TIMEOUT:if(a.textResult)for(d=0;d<a.textResult.length;++d){var e=a.textResult[d];
try{e.BarcodeText=c._bNodejs?Buffer.from(e.BarcodeText,"base64").toString():atob(e.BarcodeText)}catch(p){e.BarcodeText=""}}return a.textResult||a.localizationResultArray||a.Result||a.templateSettings||a.settings||a.outputSettings||a;default:throw b.BarcodeReaderException(a.exception,a.description);}};b.prototype.getAllLocalizationResults=function(){return this._localizationResultArray?this._localizationResultArray:m(this._instance.GetAllLocalizationResults())};b.prototype.getAllParameterTemplateNames=
function(){return m(this._instance.GetAllParameterTemplateNames())};b.prototype.getRuntimeSettings=function(){return this._instance?m(this._instance.GetRuntimeSettings()):this._runtimeSettings?JSON.parse(this._runtimeSettings):b._defaultRuntimeSettings};b.prototype.updateRuntimeSettings=function(a){var c=this;if("string"==typeof a||"object"==typeof a&&a instanceof String)var e=a;else if("object"==typeof a)e=JSON.stringify(a);else throw TypeError("'UpdateRuntimeSettings(settings)': Type of 'settings' should be 'String' or 'PlainObject'.");
if(c._instance)try{return m(c._instance.UpdateRuntimeSettings(e)),Promise.resolve()}catch(p){return Promise.reject(p)}else return Promise.resolve().then(function(){return c._instanceID?Promise.resolve():c._createWorkerInstance()}).then(function(){return new Promise(function(a,g){var f=Math.random();d[f]=function(b){return b.success?(c._runtimeSettings=e,a()):g(b.exception)};b._dbrWorker.postMessage({type:"updateRuntimeSettings",id:f,instanceID:c._instanceID,body:{settings:e}})})}).catch(function(a){return Promise.reject(a)})};
b.prototype.resetRuntimeSettings=function(){this._instance?m(this._instance.ResetRuntimeSettings()):this._runtimeSettings=null};b.prototype.outputSettingsToString=function(a){return m(this._instance.OutputSettingsToString(a||""))};b.prototype.initRuntimeSettingsWithString=function(a,b){if(!("string"==typeof a||"object"==typeof a&&a instanceof String))if("object"==typeof a)a=JSON.stringify(a);else throw TypeError("'initRuntimeSettingstWithString(template, enumComflictMode)': Type of 'template' should be 'String' or 'PlainObject'.");
m(this._instance.InitRuntimeSettingstWithString(a,b?b:2))};b.prototype.appendTplStringToRuntimeSettings=function(a,b){if(!("string"==typeof a||"object"==typeof a&&a instanceof String))if("object"==typeof a)a=JSON.stringify(a);else throw TypeError("'appendTplStringToRuntimeSettings(template, enumComflictMode)': Type of 'template' should be 'String' or 'PlainObject'.");m(this._instance.AppendTplStringToRuntimeSettings(a,b?b:2))};b.EnumBarcodeFormat=b.EnumBarcodeFormat||{All:503317503,OneD:1023,CODE_39:1,
CODE_128:2,CODE_93:4,CODABAR:8,ITF:16,EAN_13:32,EAN_8:64,UPC_A:128,UPC_E:256,INDUSTRIAL_25:512,PDF417:33554432,QR_CODE:67108864,DATAMATRIX:134217728,AZTEC:268435456};b.EnumErrorCode=b.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,
/**
* Dynamsoft JavaScript Library
* @product Dynamsoft Barcode Reader JS Edition
* @website http://www.dynamsoft.com
* @preserve Copyright 2019, Dynamsoft Corporation
* @author Dynamsoft
* @version 6.5.1
* @fileoverview Dynamsoft JavaScript Library for Barcode Reader
* More info on DBR JS: https://www.dynamsoft.com/Products/barcode-recognition-javascript.aspx
*/
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(g){var c=0;return function(){return c<g.length?{done:!1,value:g[c++]}:{done:!0}}};$jscomp.arrayIterator=function(g){return{next:$jscomp.arrayIteratorImpl(g)}};$jscomp.makeIterator=function(g){var c="undefined"!=typeof Symbol&&Symbol.iterator&&g[Symbol.iterator];return c?c.call(g):$jscomp.arrayIterator(g)};
(function(g,c){"undefined"!=typeof self&&self.document&&(self.__dbrWasmCurrentScript__=document.currentScript.src.substring(0,document.currentScript.src.lastIndexOf("/")));"function"===typeof define&&(define.amd||define.cmd)?define(c):"object"===typeof module&&module.exports?module.exports=c():(c=c(),g.dynamsoft=g.dynamsoft||{},g.dynamsoft.BarcodeReader=c,g.BarcodeReader=g.BarcodeReader||c,g.dbr=g.dbr||c)})(this,function(){var g="undefined"!=typeof g?g:("undefined"!=typeof g?this.dynamsoft:void 0)||
{};g.TaskQueue=g.TaskQueue||function(){var c=function(){this._queue=[];this.isWorking=!1;this.timeout=100};c.prototype.push=function(c,a,e){this._queue.push({task:c,context:a,args:e});this.isWorking||this.next()};c.prototype.unshift=function(c,a,e){this._queue.unshift({task:c,context:a,args:e});this.isWorking||this.next()};c.prototype.next=function(){if(0==this._queue.length)this.isWorking=!1;else{this.isWorking=!0;var c=this._queue.shift(),a=c.task,e=c.context?c.context:null,d=c.args?c.args:[];setTimeout(function(){a.apply(e,
d)},this.timeout)}};return c}();g.dbrEnv=g.dbrEnv||{};"undefined"!=typeof self?(g.dbrEnv._self=self,self.document?g.dbrEnv._bDom=!0:g.dbrEnv._bWorker=!0):(g.dbrEnv._self=global,g.dbrEnv._bNodejs=!0);g.BarcodeReader=g.BarcodeReader||function(){var c=g.dbrEnv,f=c._self,a=function(b){b=b||a.licenseKey||"";if(!("string"==typeof b||"object"==typeof b&&b instanceof String))throw TypeError("'Constructor BarcodeReader(licenseKey)': Type of 'licenseKey' should be 'String'.");this._licenseKey=b;if(a._BarcodeReaderWasm){this._instance=
new a._BarcodeReaderWasm(this._licenseKey);if(!this._instance)throw a.BarcodeReaderException(a.EnumErrorCode.DBR_NULL_REFERENCE,"Can't create BarcodeReader instance.");this._instance.bInWorker&&(this._instance=void 0)}else throw Error("'Constructor BarcodeReader(licenseKey)': Autoload haven't start or you want to call `loadWasm` manually.");};a._jsVersion="6.5.1";a._jsEditVersion="20190426";a.version="loading...(JS "+a._jsVersion+"."+a._jsEditVersion+")";a.isLoaded=function(){return"loaded"==this._loadWasmStatus};
a.licenseKey=void 0;var e=c._bDom?__dbrWasmCurrentScript__:void 0;a._resourcesPath=e;a._workerName=void 0;a._wasmjsName=void 0;a._wasmName=void 0;a._workerResourcePath=void 0;a._wasmjsResourcePath=void 0;a._wasmResourcePath=void 0;a._isShowRelDecodeTimeInResults=!1;a._bCustomWorker=void 0;a._bWithio=void 0;a._onWasmDownloaded=void 0;a.createInstance=function(b){return a.loadWasm().then(function(){return Promise.resolve(new a(b))})};var d={};a._loadWorker=function(){return new Promise(function(b,h){var c=
a._workerName||"dbr-"+a._jsVersion+".min.js";if(a._workerResourcePath||a._resourcesPath){var n=a._workerResourcePath||a._resourcesPath;"/"!=n.charAt(n.length-1)&&(n+="/");c=n+c}fetch(c).then(function(b){return b.blob()}).then(function(c){var n=URL.createObjectURL(c);c=a._dbrWorker=new Worker(n);c.onerror=function(b){b="worker error, you should host the page in web service: "+b.message;f.kConsoleLog&&f.kConsoleError(b);h(b)};c.onmessage=function(c){c=c.data;switch(c.type){case "log":f.kConsoleLog&&
f.kConsoleLog(c.message);break;case "load":c.success?(a.version=c.version,a._defaultRuntimeSettings=c._defaultRuntimeSettings,f.kConsoleLog&&f.kConsoleLog("load dbr worker success"),b()):h(c.exception);URL.revokeObjectURL(n);break;case "task":try{d[c.id](c.body),d[c.id]=void 0}catch(t){throw d[c.id]=void 0,t;}break;default:f.kConsoleLog&&f.kConsoleLog(c)}};var e=document.createElement("a");e.href=a._resourcesPath||"./";var p=void 0;a._wasmjsResourcePath&&(p=document.createElement("a"),p.href=a._wasmjsResourcePath||
"./",p=p.href);var r=void 0;a._wasmResourcePath&&(r=document.createElement("a"),r.href=a._wasmResourcePath||"./",r=r.href);c.postMessage({type:"loadWorker",_resourcesPath:e.href,_wasmjsResourcePath:p,_wasmResourcePath:r,origin:location.origin})}).catch(function(b){h(b)})})};a.prototype._createWorkerInstance=function(){var b=this;return new Promise(function(c,e){var h=Math.random();d[h]=function(d){return d.success?d.instanceID?(b._instanceID=d.instanceID,c()):e(a.BarcodeReaderException(a.EnumErrorCode.DBR_NULL_REFERENCE,
"Can't create BarcodeReader instance.")):e(d.exception)};a._dbrWorker.postMessage({type:"createInstance",id:h,licenseKey:b._licenseKey})})};a.prototype.deleteInstance=function(){var b=this;if(this._instance)this._instance.delete();else return new Promise(function(c,e){var h=Math.random();d[h]=function(b){return b.success?c():e(b.exception)};a._dbrWorker.postMessage({type:"deleteInstance",id:h,instanceID:b._instanceID})})};a.prototype._decodeBlob=function(b,a){var d=this;if(!(f.Blob&&b instanceof Blob))return Promise.reject("'_decodeBlob(blob, templateName)': Type of 'blob' should be 'Blob'.");
a=a||"";return c._bDom?(new Promise(function(a,d){var c=URL.createObjectURL(b),h=new Image;h.dbrObjUrl=c;h.src=c;h.onload=function(){a(h)};h.onerror=function(){d(TypeError("'_decodeBlob(blob, templateName)': Can't convert the blob to image."))}})).then(function(b){return d._decodeImage(b)}):(new Promise(function(a){var d=new FileReader;d.onload=function(){a(d.result)};d.readAsArrayBuffer(b)})).then(function(b){return d._decodeArrayBuffer(b,a)})};a.prototype._decodeArrayBuffer=function(b,a){if(!(f.arrayBuffer&&
b instanceof ArrayBuffer||f.Buffer&&b instanceof Buffer))return Promise.reject("'_decodeBlob(arrayBuffer, templateName)': Type of 'arrayBuffer' should be 'ArrayBuffer' or 'Buffer'.");a=a||"";return c._bDom?this._decodeBlob(new Blob(b),a):this._decodeUint8Array(new Uint8Array(b))};a.prototype._decodeUint8Array=function(b,d){var h=this;if(!(f.Uint8Array&&b instanceof Uint8Array||f.Uint8ClampedArray&&b instanceof Uint8ClampedArray))return Promise.reject("'_decodeBlob(uint8Array, templateName)': Type of 'uint8Array' should be 'Uint8Array'.");
d=d||"";return c._bDom?h._decodeBlob(new Blob(b),d):new Promise(function(c){if(a._isShowRelDecodeTimeInResults){var e=(new Date).getTime(),n=h._instance.DecodeFileInMemory(b,d);e=(new Date).getTime()-e;n=m(n);n._decodeTime=e;return c(n)}return c(m(h._instance.DecodeFileInMemory(b,d)))})};a.prototype._decodeImage=function(b,a){var d=this;return(new Promise(function(d){if(!(f.HTMLImageElement&&b instanceof HTMLImageElement))throw TypeError("'_decodeImage(image, templateName)': Type of 'image' should be 'HTMLImageElement'.");
if(b.crossOrigin&&"anonymous"!=b.crossOrigin)throw"cors";a=a||"";d()})).then(function(){var c=document.createElement("canvas");c.width=b.naturalWidth;c.height=b.naturalHeight;c.getContext("2d").drawImage(b,0,0);b.dbrObjUrl&&URL.revokeObjectURL(b.dbrObjUrl);return d._decodeCanvas(c,a)})};a.prototype._decodeCanvas=function(b,d){var c=this;return(new Promise(function(a){if(!(f.HTMLCanvasElement&&b instanceof HTMLCanvasElement))throw TypeError("'_decodeCanvas(canvas, templateName)': Type of 'canvas' should be 'HTMLCanvasElement'.");
if(b.crossOrigin&&"anonymous"!=b.crossOrigin)throw"cors";d=d||"";var c=b.getContext("2d").getImageData(0,0,b.width,b.height).data;a(c)})).then(function(h){return c._decodeRawImageUint8Array(h,b.width,b.height,4*b.width,a.EnumImagePixelFormat.IPF_ARGB_8888,d)})};a.prototype._decodeVideo=a.prototype.decodeVideo=function(b){var a=this,d,c=arguments,e,k;return(new Promise(function(h){if(!(f.HTMLVideoElement&&b instanceof HTMLVideoElement))throw TypeError("'_decodeVideo(video [ [, sx, sy, sWidth, sHeight], dWidth, dHeight] [, templateName] )': Type of 'video' should be 'HTMLVideoElement'.");
if(b.crossOrigin&&"anonymous"!=b.crossOrigin)throw"cors";var n,m,r;if(2>=c.length){var g=n=0;var q=m=b.videoWidth;var l=r=b.videoHeight}else 4>=c.length?(g=n=0,q=b.videoWidth,l=b.videoHeight,m=c[1],r=c[2]):(g=c[1],n=c[2],q=c[3],l=c[4],m=c[5],r=c[6]);d="string"==typeof c[c.length-1]?c[c.length-1]:"";k=document.createElement("canvas");k.width=m;k.height=r;var v=k.getContext("2d");a._bAddOriVideoCanvasToResult&&(e=document.createElement("canvas"),e.width=b.videoWidth,e.height=b.videoHeight,e.getContext("2d").drawImage(b,
0,0));v.drawImage(e||b,g,n,q,l,0,0,m,r);h()})).then(function(){return a._decodeCanvas(k,d)}).then(function(b){if(a._bAddOriVideoCanvasToResult)for(var d=$jscomp.makeIterator(b),c=d.next();!c.done;c=d.next())c.value.oriVideoCanvas=e;if(a._bAddSearchRegionCanvasToResult)for(d=$jscomp.makeIterator(b),c=d.next();!c.done;c=d.next())c.value.searchRegionCanvas=k;return b})};a.prototype._decodeBase64=a.prototype.decodeBase64String=function(b,a){var d=this;if(!("string"==typeof b||"object"==typeof b&&b instanceof
String))return Promise.reject("'decodeBase64(base64Str, templateName)': Type of 'base64Str' should be 'String'.");"data:image/"==b.substring(0,11)&&(b=b.substring(b.indexOf(",")+1));a=a||"";return new Promise(function(h){if(c._bNodejs)h(d._decodeArrayBuffer(Buffer.from(b,"base64"),a));else{for(var e=atob(b),k=e.length,f=new Uint8Array(k);k--;)f[k]=e.charCodeAt(k);c._bDom?h(d._decodeBlob(new Blob([f]),a)):h(d._decodeUint8Array(f,a))}})};a.prototype._decodeUrl=function(b,a){var d=this;return new Promise(function(e,
h){if(!("string"==typeof b||"object"==typeof b&&b instanceof String))throw TypeError("'_decodeUrl(url, templateName)': Type of 'url' should be 'String'.");a=a||"";if(c._bNodejs)(b.startsWith("https")?require("https"):require("http")).get(b,function(b){if(200==b.statusCode){var c=[];b.on("data",function(b){c.push(b)}).on("end",function(){e(d._decodeArrayBuffer(Buffer.concat(c),a))})}else h("http get fail, statusCode: "+b.statusCode)});else{var k=new XMLHttpRequest;k.open("GET",b,!0);k.responseType=
c._bDom?"blob":"arraybuffer";k.send();k.onloadend=function(){c._bDom?e(d._decodeBlob(this.response,a)):e(d._decodeArrayBuffer(this.response,a))};k.onerror=function(){h(k.error)}}})};a.prototype._decodeFilePath=function(b,a){var d=this;return new Promise(function(c,e){if(!("string"==typeof b||"object"==typeof b&&b instanceof String))throw TypeError("'_decodeFilePath(path, templateName)': Type of 'path' should be 'String'.");a=a||"";require("fs").readFile(b,function(b,h){b?e(b):c(d._decodeArrayBuffer(h,
a))})})};a.prototype._decodeRawImageBlob=function(b,a,d,c,e,k){var h=this;return(new Promise(function(a,d){if(!(f.Blob&&b instanceof Blob))throw TypeError("'_decodeRawImageBlob(buffer, width, height, stride, enumImagePixelFormat, templateName)': Type of 'buffer' should be 'Blob'.");k=k||"";var c=new FileReader;c.readAsArrayBuffer(b);c.onload=function(){a(c.result)};c.onerror=function(){d(c.error)}})).then(function(b){return h._decodeRawImageUint8Array(new Uint8Array(b),a,d,c,e,k)})};a.prototype._decodeRawImageArrayBuffer=
function(b,a,c,d,e,k){var h=this;return(new Promise(function(a){if(!(f.ArrayBuffer&&b instanceof ArrayBuffer))throw TypeError("'_decodeRawImageArrayBuffer(buffer, width, height, stride, enumImagePixelFormat, templateName)': Type of 'buffer' should be 'ArrayBuffer'.");k=k||"";a()})).then(function(){return h._decodeRawImageUint8Array(new Uint8Array(b),a,c,d,e,k)})};a.prototype._decodeRawImageUint8Array=function(b,c,e,g,p,k){var h=this;return(new Promise(function(a){if(!(f.Uint8Array&&b instanceof Uint8Array||
f.Uint8ClampedArray&&b instanceof Uint8ClampedArray))throw TypeError("'_decodeRawImageUint8Array(buffer, width, height, stride, enumImagePixelFormat, templateName)': Type of 'buffer' should be 'Uint8Array'.");k=k||"";h._localizationResultArray=void 0;a()})).then(function(){if(h._instance){if(a._isShowRelDecodeTimeInResults){var f=(new Date).getTime(),n=h._instance.DecodeBuffer(b,c,e,g,p,k);f=(new Date).getTime()-f;n=m(n);n._decodeTime=f;return Promise.resolve(n)}return Promise.resolve(m(h._instance.DecodeBuffer(b,
c,e,g,p,k)))}var r;n=h._instanceID?Promise.resolve():h._createWorkerInstance();return n.then(function(){return null===h._runtimeSettings?new Promise(function(b,c){var l=Math.random();d[l]=function(a){return a.success?(h._runtimeSettings=void 0,b()):c(a.exception)};a._dbrWorker.postMessage({type:"resetRuntimeSettings",id:l,instanceID:h._instanceID})}):Promise.resolve()}).then(function(){return new Promise(function(f,q){var l=Math.random();d[l]=function(b){return b.success?f(b.results):q(b.exception)};
a._dbrWorker.postMessage({type:"decodeRawImageUint8Array",id:l,instanceID:h._instanceID,body:{buffer:b,width:c,height:e,stride:g,enumImagePixelFormat:p,templateName:k},_isShowRelDecodeTimeInResults:a._isShowRelDecodeTimeInResults})})}).then(function(b){r=b;return new Promise(function(b,c){var l=Math.random();d[l]=function(a){return a.success?b(a.results):c(a.exception)};a._dbrWorker.postMessage({type:"getAllLocalizationResults",id:l,instanceID:h._instanceID})})}).then(function(b){h._localizationResultArray=
b;return Promise.resolve(r)})})};a.prototype.decode=a.prototype.decodeFileInMemory=function(b,a){return f.Blob&&b instanceof Blob?this._decodeBlob(b,a):f.ArrayBuffer&&b instanceof ArrayBuffer||f.Buffer&&b instanceof Buffer?this._decodeArrayBuffer(b,a):f.Uint8Array&&b instanceof Uint8Array||f.Uint8ClampedArray&&b instanceof Uint8ClampedArray?this._decodeUint8Array(b,a):f.HTMLImageElement&&b instanceof HTMLImageElement?this._decodeImage(b,a):f.HTMLCanvasElement&&b instanceof HTMLCanvasElement?this._decodeCanvas(b,
a):f.HTMLVideoElement&&b instanceof HTMLVideoElement?this._decodeVideo(b,a):"string"==typeof b||b instanceof String?"data:image/"==b.substring(0,11)?this._decodeBase64(b,a):c._bNodejs?"http"==b.substring(0,4)?this._decodeUrl(b,a):this._decodeFilePath(b,a):this._decodeUrl(b,a):Promise.reject(TypeError("'_decode(source, templateName)': Type of 'source' should be 'Blob', 'ArrayBuffer', 'Uint8Array', 'HTMLImageElement', 'HTMLCanvasElement', 'HTMLVideoElement', 'String(base64 with image mime)' or 'String(url)'."))};
a.prototype._decodeRawImage=a.prototype.decodeBuffer=function(b,a,c,d,e,k){return f.Blob&&b instanceof Blob?this._decodeRawImageBlob(b,a,c,d,e,k):f.ArrayBuffer&&b instanceof ArrayBuffer?this._decodeRawImageArrayBuffer(b,a,c,d,e,k):f.Uint8Array&&b instanceof Uint8Array||f.Uint8ClampedArray&&b instanceof Uint8ClampedArray?this._decodeRawImageUint8Array(b,a,c,d,e,k):Promise.reject(TypeError("'_decodeRawImage(source, width, height, stride, enumImagePixelFormat, templateName)': Type of 'source' should be 'Blob', 'ArrayBuffer' or 'Uint8Array'."))};
var m=a._handleRetJsonString=function(b){b="string"==typeof b||"object"==typeof b&&b instanceof String?JSON.parse(b):b;var d=a.EnumErrorCode;switch(b.exception){case d.DBR_SUCCESS:case d.DBR_LICENSE_INVALID:case d.DBR_LICENSE_EXPIRED:case d.DBR_1D_LICENSE_INVALID:case d.DBR_QR_LICENSE_INVALID:case d.DBR_PDF417_LICENSE_INVALID:case d.DBR_DATAMATRIX_LICENSE_INVALID:case d.DBR_DBRERR_AZTEC_LICENSE_INVALID:case d.DBR_RECOGNITION_TIMEOUT:if(b.textResult)for(d=0;d<b.textResult.length;++d){var e=b.textResult[d];
try{e.BarcodeText=c._bNodejs?Buffer.from(e.BarcodeText,"base64").toString():atob(e.BarcodeText)}catch(n){e.BarcodeText=""}}return b.textResult||b.localizationResultArray||b.Result||b.templateSettings||b.settings||b.outputSettings||b;default:throw a.BarcodeReaderException(b.exception,b.description);}};a.prototype.getAllLocalizationResults=function(){return this._localizationResultArray?this._localizationResultArray:m(this._instance.GetAllLocalizationResults())};a.prototype.getAllParameterTemplateNames=
function(){return m(this._instance.GetAllParameterTemplateNames())};a.prototype.getRuntimeSettings=function(){return this._instance?m(this._instance.GetRuntimeSettings()):this._runtimeSettings?JSON.parse(this._runtimeSettings):a._defaultRuntimeSettings};a.prototype.updateRuntimeSettings=function(b){var c=this;if("string"==typeof b||"object"==typeof b&&b instanceof String)var e=b;else if("object"==typeof b)e=JSON.stringify(b);else throw TypeError("'UpdateRuntimeSettings(settings)': Type of 'settings' should be 'String' or 'PlainObject'.");
if(c._instance)try{return m(c._instance.UpdateRuntimeSettings(e)),Promise.resolve()}catch(n){return Promise.reject(n)}else return Promise.resolve().then(function(){return c._instanceID?Promise.resolve():c._createWorkerInstance()}).then(function(){return new Promise(function(b,f){var k=Math.random();d[k]=function(a){return a.success?(c._runtimeSettings=e,b()):f(a.exception)};a._dbrWorker.postMessage({type:"updateRuntimeSettings",id:k,instanceID:c._instanceID,body:{settings:e}})})}).catch(function(b){return Promise.reject(b)})};
a.prototype.resetRuntimeSettings=function(){this._instance?m(this._instance.ResetRuntimeSettings()):this._runtimeSettings=null};a.prototype.outputSettingsToString=function(b){return m(this._instance.OutputSettingsToString(b||""))};a.prototype.initRuntimeSettingsWithString=function(b,a){if(!("string"==typeof b||"object"==typeof b&&b instanceof String))if("object"==typeof b)b=JSON.stringify(b);else throw TypeError("'initRuntimeSettingstWithString(template, enumComflictMode)': Type of 'template' should be 'String' or 'PlainObject'.");
m(this._instance.InitRuntimeSettingstWithString(b,a?a:2))};a.prototype.appendTplStringToRuntimeSettings=function(b,a){if(!("string"==typeof b||"object"==typeof b&&b instanceof String))if("object"==typeof b)b=JSON.stringify(b);else throw TypeError("'appendTplStringToRuntimeSettings(template, enumComflictMode)': Type of 'template' should be 'String' or 'PlainObject'.");m(this._instance.AppendTplStringToRuntimeSettings(b,a?a:2))};a.EnumBarcodeFormat=a.EnumBarcodeFormat||{All:503317503,OneD:1023,CODE_39:1,
CODE_128:2,CODE_93:4,CODABAR:8,ITF:16,EAN_13:32,EAN_8:64,UPC_A:128,UPC_E:256,INDUSTRIAL_25:512,PDF417:33554432,QR_CODE:67108864,DATAMATRIX:134217728,AZTEC:268435456};a.EnumErrorCode=a.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_DBRERR_AZTEC_LICENSE_INVALID:-10041};b.EnumImagePixelFormat=b.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};b.EnumResultType=b.EnumResultType||{EDT_StandardText:0,EDT_RawText:1,EDT_CandidateText:2,EDT_PartialText:3};b.EnumTerminateStage=b.EnumTerminateStage||{ETS_Prelocalized:0,ETS_Localized:1,ETS_Recognized:2};b.EnumConflictMode=b.EnumConflictMode||{ECM_Ignore:1,ECM_Overwrite:2};b.BarcodeReaderException=b.BarcodeReaderException||function(){return function(a,d){var c=b.EnumErrorCode.DBR_UNKNOWN;"number"==typeof a?(c=a,a=Error(d)):a=Error(a);a.code=c;return a}}();return b}();
!h.dbrEnv._bWorker||h.BarcodeReader._bCustomWorker||h.dbrEnv._self.onmessage||function(){var c=h.dbrEnv,g=c._self,b=h.BarcodeReader;g.kConsoleLog=g.kConsoleLog||function(d){if(g.onmessage!=b._onWorkerMessage)g.kConsoleLog=void 0;else{var c=void 0;if(void 0===d)c="undefined";else{try{c=JSON.stringify(d,function(){var a=[],b=[];return function(c,d){if("object"===typeof d&&null!==d){var e=a.indexOf(d);if(-1!==e)return"[Circular "+b[e]+"]";a.push(d);b.push(c||"root")}return d}}())}catch(a){}if(void 0===
c||"{}"===c)c=d.toString()}try{postMessage({type:"log",message:c})}catch(a){g.console&&console.error(message)}}};g.kConsoleLog("have detected in worker: "+b.version);var e={};g.onmessage=b._onWorkerMessage=function(d){d=d.data;switch(d.type){case "loadWorker":(function(){b._resourcesPath=d._resourcesPath;b._wasmjsResourcePath=d._wasmjsResourcePath;b._wasmResourcePath=d._wasmResourcePath;c.origin=d.origin;b.loadWasm().then(function(){postMessage({type:"load",success:!0,version:b.version,_defaultRuntimeSettings:b._defaultRuntimeSettings})},
function(b){postMessage({type:"load",success:!1,exception:b.message||b})})})();break;case "createInstance":(function(){try{var c=Math.random();e[c]=new b(d.licenseKey);postMessage({type:"task",id:d.id,body:{success:!0,instanceID:c}})}catch(a){postMessage({type:"task",id:d.id,body:{success:!1,exception:a.message||a}})}})();break;case "deleteInstance":try{e[d.instanceID].deleteInstance(),e[d.instanceID]=void 0,postMessage({type:"task",id:d.id,body:{success:!0}})}catch(m){postMessage({type:"task",id:d.id,
body:{success:!1,exception:m.message||m}})}break;case "decodeRawImageUint8Array":(function(){try{b._isShowRelDecodeTimeInResults=d._isShowRelDecodeTimeInResults;var c=d.body;e[d.instanceID]._decodeRawImageUint8Array(c.buffer,c.width,c.height,c.stride,c.enumImagePixelFormat,c.templateName).then(function(a){postMessage({type:"task",id:d.id,body:{success:!0,results:a}})}).catch(function(a){postMessage({type:"task",id:d.id,body:{success:!1,exception:a.message||a}})})}catch(a){postMessage({type:"task",
id:d.id,body:{success:!1,exception:a.message||a}})}})();break;case "getAllLocalizationResults":(function(){try{var b=e[d.instanceID].getAllLocalizationResults();postMessage({type:"task",id:d.id,body:{success:!0,results:b}})}catch(a){postMessage({type:"task",id:d.id,body:{success:!1,exception:a.message||a}})}})();break;case "getRuntimeSettings":(function(){try{var b=e[d.instanceID].getRuntimeSettings();postMessage({type:"task",id:d.id,body:{success:!0,settings:b}})}catch(a){postMessage({type:"task",
id:d.id,body:{success:!1,exception:a.message||a}})}})();break;case "updateRuntimeSettings":try{e[d.instanceID].updateRuntimeSettings(d.body.settings),postMessage({type:"task",id:d.id,body:{success:!0}})}catch(m){postMessage({type:"task",id:d.id,body:{success:!1,exception:m.message||m}})}break;case "resetRuntimeSettings":try{e[d.instanceID].resetRuntimeSettings(),postMessage({type:"task",id:d.id,body:{success:!0}})}catch(m){postMessage({type:"task",id:d.id,body:{success:!1,exception:m.message||m}})}break;
default:postMessage({type:"task",id:d.id,body:{success:!1,exception:"No such task."}})}}}();h.BarcodeReader.loadWasm=h.BarcodeReader.loadWasm||function(){return new Promise(function(c,g){var b=h.dbrEnv,e=b._self,d=h.BarcodeReader;if("loaded"==d._loadWasmStatus)return c();d._loadWasmTaskQueue=d._loadWasmTaskQueue||function(){var b=new h.TaskQueue;b.timeout=0;return b}();d._loadWasmTaskQueue.push(function(h){if("loaded"==d._loadWasmStatus)return d._loadWasmTaskQueue.next(),c();if(h)return d._loadWasmTaskQueue.next(),
g(d._loadWasmStatus);d._loadWasmStatus="loading";return(new Promise(function(a,c){d._BarcodeReaderWasm=function(){throw Error("'Constructor BarcodeReader(licenseKey)': The wasm hasn't finish loading.");};if(!e.WebAssembly||"undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&/\(.+\s11_2_([2-6]).*\)/.test(navigator.userAgent))return c("'Constructor BarcodeReader(licenseKey)': The browser doesn't support Webassembly.");if(b._bDom)return d._loadWorker().then(function(){d._BarcodeReaderWasm=
function(){this.bInWorker=!0};return a()},function(a){d._BarcodeReaderWasm=function(){throw Error("'Constructor BarcodeReader(licenseKey)': The wasm load failed. ex: "+(a.message||a));};return c(a)});var g={locateFile:function(){var a=d._wasmName||"dbr-"+d._jsVersion+(d._bWithio?".withio":"")+".wasm";if(d._wasmResourcePath||d._resourcesPath){var c=d._wasmResourcePath||d._resourcesPath;"/"!=c.charAt(c.length-1)&&(c+="/");a=c+a}else b._bNodejs&&(a=require("path").join(__dirname,a));return a},onRuntimeInitialized:function(){d._BarcodeReaderWasm=
g.BarcodeReaderWasm;var b=new g.BarcodeReaderWasm("");d.version=b.GetVersion()+"(JS "+d._jsVersion+"."+d._jsEditVersion+")";d._defaultRuntimeSettings=d._handleRetJsonString(b.GetRuntimeSettings());b.delete();e.kConsoleLog&&e.kConsoleLog("load dbr wasm success, version: "+d.version);a()}};g.onExit=g.onAbort=function(a){e.kConsoleLog&&kConsoleLog(a);d._BarcodeReaderWasm=function(){throw Error("'Constructor BarcodeReader(licenseKey)': The wasm load failed. Error: "+(a.message||a));};c(a)};g.print=function(a){e.kConsoleLog&&
kConsoleLog(a)};if("undefined"==typeof _dbrLoadWasm){void 0==d._bWithio&&(d._bWithio=b._bNodejs||b._bWorker&&(d._bCustomWorker||e.onmessage!=d._onWorkerMessage));var h=d._wasmjsName||"dbr-"+d._jsVersion+".wasm"+(d._bWithio?".withio":"")+".min.js";if(d._wasmjsResourcePath||d._resourcesPath){var f=d._wasmjsResourcePath||d._resourcesPath;"/"!=f.charAt(f.length-1)&&(f+="/");h=f+h}else b._bNodejs&&(h=require("path").join(__dirname,h));b._bWorker?importScripts(h):_dbrLoadWasm=require(h)}_dbrLoadWasm(g,
function(a,c,g){e.kConsoleLog&&kConsoleLog("start handle dbr wasm, version: "+a);var h=(new Date).getTime();if(b._bNodejs)return new Promise(function(a,b){require("fs").readFile(c,function(c,d){if(c)return b(c);var t=(new Date).getTime();a(WebAssembly.instantiate(d,g).then(function(a){e.kConsoleLog&&kConsoleLog("build instance from binary timecost: "+((new Date).getTime()-t));e.kConsoleLog&&kConsoleLog("finish handle dbr wasm, total timecost: "+((new Date).getTime()-h));return Promise.resolve(a)}))})});
var f=""+a;d._openDb=d._openDb||function(){return new Promise(function(a,b){var c=function(){d.result.createObjectStore("info");d.result.createObjectStore("wasm");d.result.createObjectStore("module")},d=indexedDB.open("dynamsoft-dbr-wasm",1);d.onupgradeneeded=c;d.onsuccess=function(){a(d.result)};d.onerror=function(){var e=d.error.message||d.error;-1!=e.indexOf("version")?(d=indexedDB.deleteDatabase("dynamsoft-dbr-wasm"),d.onsuccess=function(){var d=indexedDB.open("dynamsoft-dbr-wasm",1);d.onupgradeneeded=
c;d.onsuccess=function(){a(d.result)};d.onerror=function(){b("open db [dynamsoft-dbr-wasm] fail")}},d.onerror=function(){b("open db [dynamsoft-dbr-wasm] fail")}):b("open db [dynamsoft-dbr-wasm] fail: "+e)}})};var l=function(a){return new Promise(function(b,c){var d=a.transaction(["info"]).objectStore("info").get("bSupportStoreModuleInDb"),e=function(){var d=a.transaction(["info"],"readwrite").objectStore("info"),e=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,127,3,2,1,0,7,6,1,2,95,97,0,0,10,
6,1,4,0,65,1,11]);try{var g=d.put(new WebAssembly.Module(e.buffer),"testStoreModule");g.onsuccess=function(){d.put(!0,"bSupportStoreModuleInDb").onsuccess=function(){b("set bSupportStoreModuleInDb = true success")}};g.onerror=function(){c("Failed to store [testStoreModule] in wasm cache, bSupportStoreModuleInDb == false: "+(g.error.message||g.error))}}catch(y){c("Failed to store [testStoreModule] in wasm cache, bSupportStoreModuleInDb == false: "+(y.message||y))}};d.onsuccess=function(){d.result?
b("bSupportStoreModuleInDb == true"):e()}})};d._lookupInDatabase=d._lookupInDatabase||function(a,b,c){return new Promise(function(d,e){var g=a.transaction([b]).objectStore(b).get(c);g.onsuccess=function(){g.result?d(g.result):e(c+" was not found in "+b)}})};d._storeInDatabase=d._storeInDatabase||function(a,b,c,d){return new Promise(function(e,g){var h=a.transaction([b],"readwrite").objectStore(b).put(d,c);h.onerror=function(){g("Failed to store "+c+" in wasm cache: "+(h.error.message||h.error))};
h.onsuccess=function(){e("Successfully stored "+c+" in "+b)}})};return d._openDb().then(function(a){e.kConsoleLog&&kConsoleLog("open db success");return l(a).then(function(a){e.kConsoleLog&&kConsoleLog(a);return Promise.resolve(!0)},function(a){e.kConsoleLog&&kConsoleLog(a.message||a);return Promise.resolve(!1)}).then(function(b){var t=(new Date).getTime();return d._lookupInDatabase(a,"wasm",f).then(function(c){if(c instanceof WebAssembly.Module){e.kConsoleLog&&kConsoleLog("get a wasm module from db, timecost:"+
((new Date).getTime()-t));var l=(new Date).getTime();return WebAssembly.instantiate(c,g).then(function(a){e.kConsoleLog&&kConsoleLog("build instance from module timecost: "+((new Date).getTime()-l));e.kConsoleLog&&kConsoleLog("finish handle dbr wasm, total timecost: "+((new Date).getTime()-h));return Promise.resolve({module:c,instance:a})})}e.kConsoleLog&&kConsoleLog("get a wasm binary from db, timecost:"+((new Date).getTime()-t));var r=(new Date).getTime();return WebAssembly.instantiate(c,g).then(function(c){e.kConsoleLog&&
kConsoleLog("build instance from binary timecost: "+((new Date).getTime()-r));if(b){var g=(new Date).getTime();return d._storeInDatabase(a,"wasm",f,c.module).then(function(a){e.kConsoleLog&&kConsoleLog(a+", timecost: "+((new Date).getTime()-g));e.kConsoleLog&&kConsoleLog("finish handle dbr wasm, total timecost: "+((new Date).getTime()-h));return Promise.resolve(c)})}e.kConsoleLog&&kConsoleLog("finish handle dbr wasm, total timecost: "+((new Date).getTime()-h));return Promise.resolve(c)})},function(t){e.kConsoleLog&&
kConsoleLog(t.message||t);e.kConsoleLog&&kConsoleLog("downloading...");var l=(new Date).getTime();return b?WebAssembly.instantiateStreaming(fetch(c),g).then(function(b){d._onWasmDownloaded&&d._onWasmDownloaded();e.kConsoleLog&&kConsoleLog("download with build timecost: "+((new Date).getTime()-l));var c=(new Date).getTime();return d._storeInDatabase(a,"wasm",f,b.module).then(function(a){e.kConsoleLog&&kConsoleLog(a+", timecost: "+((new Date).getTime()-c));e.kConsoleLog&&kConsoleLog("finish handle dbr wasm, total timecost: "+
((new Date).getTime()-h));return Promise.resolve(b)},function(a){e.kConsoleLog&&kConsoleLog(a.message||a);return Promise.reject("Can't store wasm in db.")})}):fetch(c).then(function(a){return a.arrayBuffer()}).then(function(b){e.kConsoleLog&&kConsoleLog("download timecost: "+((new Date).getTime()-l));d._onWasmDownloaded&&d._onWasmDownloaded();var c=(new Date).getTime();return d._storeInDatabase(a,"wasm",f,b).then(function(a){e.kConsoleLog&&kConsoleLog(a+", timecost: "+((new Date).getTime()-c));return Promise.resolve(b)},
function(a){e.kConsoleLog&&kConsoleLog(a.message||a);return Promise.reject("Can't store wasm in db.")})}).then(function(a){var b=(new Date).getTime();return WebAssembly.instantiate(a,g).then(function(a){e.kConsoleLog&&kConsoleLog("build instance from binary timecost: "+((new Date).getTime()-b));e.kConsoleLog&&kConsoleLog("finish handle dbr wasm, total timecost: "+((new Date).getTime()-h));return Promise.resolve(a)})})})})},function(a){e.kConsoleLog&&kConsoleLog(a.message||a);return WebAssembly.instantiateStreaming?
WebAssembly.instantiateStreaming(fetch(c),g).then(function(a){d._onWasmDownloaded&&d._onWasmDownloaded();e.kConsoleLog&&kConsoleLog("finish handle dbr wasm, total timecost: "+((new Date).getTime()-h));return Promise.resolve(a)}):fetch(c).then(function(a){return a.arrayBuffer()}).then(function(a){d._onWasmDownloaded&&d._onWasmDownloaded();return WebAssembly.instantiate(a,g).then(function(a){e.kConsoleLog&&kConsoleLog("finish handle dbr wasm, total timecost: "+((new Date).getTime()-h));return Promise.resolve(a)})})})},
d)})).then(function(){d._loadWasmStatus="loaded";d._loadWasmTaskQueue.next();c()}).catch(function(a){d._loadWasmStatus=a;d._loadWasmTaskQueue.next();g(a)})},null,["loading"==d._loadWasmStatus])})};h.BarcodeReader.clearCache=h.BarcodeReader.clearCache||function(){return new Promise(function(c,g){try{var b=window.indexedDB.deleteDatabase("dynamsoft-dbr-wasm");b.onsuccess=b.onerror=function(){b.error&&alert("Clear failed: "+(b.error.message||b.error));c()}}catch(e){alert(e.message||e),g()}})};h.BarcodeReader.VideoReader=
function(c){c=c||{};var g;(g=c.htmlElement)||(g=document.createElement("div"),g.style.position="fixed",g.style.width="100%",g.style.height="100%",g.style.left="0",g.style.top="0",g.style.background="#eee",g.innerHTML='<p style="width:100%;height:32px;line-height:32px;position:absolute;margin:auto 0;top:0;bottom:0;text-align:center;">loading</p><video class="dbrVideoReader-video" playsinline="true" style="width:100%;height:100%;position:absolute;left:0;top:0;"></video><select class="dbrVideoReader-sel-camera" style="position:absolute;left:0;top:0;"></select><select class="dbrVideoReader-sel-resolution" style="position:absolute;left:0;top:20px;"></select><button class="dbrVideoReader-btn-close" style="position:absolute;right:0;top:0;"><svg width="16" height="16" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1490 1322q0 40-28 68l-136 136q-28 28-68 28t-68-28l-294-294-294 294q-28 28-68 28t-68-28l-136-136q-28-28-28-68t28-68l294-294-294-294q-28-28-28-68t28-68l136-136q28-28 68-28t68 28l294 294 294-294q28-28 68-28t68 28l136 136q28 28 28 68t-28 68l-294 294 294 294q28 28 28 68z"/></svg></button>');
this.htmlElement=g;this.videoSettings=c.videoSettings;this.confidence=c.confidence;void 0==this.confidence&&(this.confidence=30);this.intervalTime=c.intervalTime;void 0==this.intervalTime&&(this.intervalTime=100);this.runtimeSettings=c.runtimeSettings||{};this.beforeDecodeVideo=c.beforeDecodeVideo;this.duringDecodeVideo=c.duringDecodeVideo;this.onFrameRead=c.onFrameRead;this.forgetTime=c.forgetTime;void 0==this.forgetTime&&(this.forgetTime=3E3);this.onDiffCodeRead=c.onDiffCodeRead;this._isReading=
!1};h.BarcodeReader.VideoReader.prototype.isReading=function(){return this._isReading};h.BarcodeReader.VideoReader.prototype.read=function(){var c=this;if(c._isReading)return Promise.reject("The VideoReader is reading.");c._isReading=!0;var g=c.htmlElement,b,e,d,m,a;(function(){for(var c=[],h=$jscomp.makeIterator(g.childNodes),f=h.next();!f.done;f=h.next())f=f.value,f.nodeType==Node.ELEMENT_NODE&&c.push(f);for(h=0;h<c.length;++h){var k=$jscomp.makeIterator(c[h].childNodes);for(f=k.next();!f.done;f=
k.next())f=f.value,f.nodeType==Node.ELEMENT_NODE&&c.push(f)}c=$jscomp.makeIterator(c);for(f=c.next();!f.done;f=c.next())f=f.value,f.classList.contains("dbrVideoReader-video")?b=f:f.classList.contains("dbrVideoReader-sel-camera")?e=f:f.classList.contains("dbrVideoReader-sel-resolution")?(d=f,d.options.length||(d.innerHTML='<option class="dbrVideoReader-opt-gotResolution" value="got"></option><option data-width="3840" data-height="2160">ask 3840 x 2160</option><option data-width="2560" data-height="1440">ask 2560 x 1440</option><option data-width="1920" data-height="1080">ask 1920 x 1080</option><option data-width="1600" data-height="1200">ask 1600 x 1200</option><option data-width="1280" data-height="720">ask 1280 x 720</option><option data-width="800" data-height="600">ask 800 x 600</option><option data-width="640" data-height="480">ask 640 x 480</option><option data-width="640" data-height="360">ask 640 x 360</option>',
m=d.options[0])):f.classList.contains("dbrVideoReader-opt-gotResolution")?m=f:f.classList.contains("dbrVideoReader-btn-close")&&(a=f)})();var f=c._updateDevice=function(){return navigator.mediaDevices.enumerateDevices().then(function(a){var c=[],d;if(e){var g=e.value;e.innerHTML=""}for(var f=0;f<a.length;++f){var h=a[f];if("videoinput"==h.kind){var k={};k.deviceId=h.deviceId;k.label=h.label||"camera "+f;c.push(k)}}a=$jscomp.makeIterator(b.srcObject.getTracks());for(f=a.next();!f.done;f=a.next()){f=
f.value;if(l)break;if("video"==f.kind)for(h=$jscomp.makeIterator(c),k=h.next();!k.done;k=h.next())if(k=k.value,f.label==k.label){var l=k;break}}if(e){a=$jscomp.makeIterator(c);for(k=a.next();!k.done;k=a.next())f=k.value,h=document.createElement("option"),h.value=f.deviceId,h.innerText=f.label,e.appendChild(h),g==f.deviceId&&(d=h);g=e.childNodes;if(!d&&l&&g.length)for(g=$jscomp.makeIterator(g),a=g.next();!a.done;a=g.next())if(a=a.value,l.label==a.innerText){d=a;break}d&&(e.value=d.value)}return Promise.resolve({current:l,
all:c})})};c._pausevideo=function(){b.pause()};var n=function(){b.srcObject&&(self.kConsoleLog&&self.kConsoleLog("======stop video========"),b.srcObject.getTracks().forEach(function(a){a.stop()}))},p=c._playvideo=function(a,e,f){return new Promise(function(g,h){n();self.kConsoleLog&&self.kConsoleLog("======before video========");var k=c.videoSettings=c.videoSettings||{video:{facingMode:{ideal:"environment"}}};/Safari/.test(navigator.userAgent)&&/iPhone/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)?
1280<=e?k.video.width=1280:640<=e?k.video.width=640:320<=e&&(k.video.width=320):(e&&(k.video.width={ideal:e}),f&&(k.video.height={ideal:f}));a&&(k.video.facingMode=void 0,k.video.deviceId={exact:a});var l=!1,r=function(){self.kConsoleLog&&self.kConsoleLog("======try getUserMedia========");self.kConsoleLog&&self.kConsoleLog("ask "+JSON.stringify(k.video.width)+"x"+JSON.stringify(k.video.height));navigator.mediaDevices.getUserMedia(k).then(function(a){self.kConsoleLog&&self.kConsoleLog("======get video========");
return new Promise(function(c,e){b.srcObject=a;b.onloadedmetadata=function(){self.kConsoleLog&&self.kConsoleLog("======play video========");b.play().then(function(){self.kConsoleLog&&self.kConsoleLog("======played video========");var a="got "+b.videoWidth+"x"+b.videoHeight;d&&m&&(m.setAttribute("data-width",b.videoWidth),m.setAttribute("data-height",b.videoHeight),d.value="got",m.innerText=a);self.kConsoleLog&&self.kConsoleLog(a);c();g({width:b.videoWidth,height:b.videoHeight})},function(a){e(a)})};
b.onerror=function(){e()}})}).catch(function(a){self.kConsoleLog&&self.kConsoleLog(a);!l&&k.video?(l=!0,k.video.width=void 0,k.video.height=void 0,r()):h(a)})};r()})};c.arrDiffCodeInfo=[];var q,k=function(){if(c._isReading){if(b.paused)return self.kConsoleLog&&self.kConsoleLog("Video is paused. Ask in 1s."),setTimeout(k,1E3);self.kConsoleLog&&self.kConsoleLog("======= once read =======");var a=(new Date).getTime();Promise.all([JSON.stringify(q.getRuntimeSettings())!=JSON.stringify(c.runtimeSettings)?
q.updateRuntimeSettings(c.runtimeSettings):Promise.resolve(),c.beforeDecodeVideo?c.beforeDecodeVideo(b):b]).then(function(a){if(c.duringDecodeVideo)return c.duringDecodeVideo({reader:q,args:a[1]});a=a[1];a instanceof Array||(a=[a]);return q.decodeVideo.apply(q,a)}).then(function(b){var d=(new Date).getTime();self.kConsoleLog&&self.kConsoleLog("time cost: "+(d-a)+"ms");for(var e=[],f=0;f<b.length;++f){var g=b[f],h=g.BarcodeText;self.kConsoleLog&&self.kConsoleLog(h);g.LocalizationResult.ExtendedResultArray[0].Confidence>=
c.confidence&&e.push(g)}e=JSON.parse(JSON.stringify(e));for(f=0;f<c.arrDiffCodeInfo.length;++f){g=c.arrDiffCodeInfo[f];h=-1;for(var l in e){var m=e[l];g.result.BarcodeText==m.BarcodeText&&g.result.BarcodeFormat==m.BarcodeFormat&&(h=l)}-1!=h?(g.time=d,g.result=e[h],e.splice(h,1)):d-g.time>c.forgetTime&&(c.arrDiffCodeInfo.splice(f,1),--f)}for(l=0;l<e.length;++l)for(f=e[l],g=l+1;g<e.length;)h=e[g],f.BarcodeText==h.BarcodeText&&f.BarcodeFormat==h.BarcodeFormat?e.splice(g,1):++g;f=$jscomp.makeIterator(e);
for(l=f.next();!l.done;l=f.next())c.arrDiffCodeInfo.push({result:l.value,time:d});if(c.onFrameRead)c.onFrameRead(JSON.parse(JSON.stringify(b)));b=$jscomp.makeIterator(e);for(l=b.next();!l.done;l=b.next())if(d=l.value,c.onDiffCodeRead)c.onDiffCodeRead(d.BarcodeText,JSON.parse(JSON.stringify(d)));setTimeout(k,c.intervalTime)}).catch(function(a){self.kConsoleLog&&self.kConsoleLog(a);setTimeout(k,c.intervalTime);throw a;})}else q&&(q.deleteInstance(),q=void 0)},v=function(){p(e.value).then(function(){c._isReading||
n()}).catch(function(a){alert("Play video failed: "+(a.message||a))})};e&&e.addEventListener("change",v);var w=function(){if(d&&-1!=d.selectedIndex){var a=d.options[d.selectedIndex];var b=a.getAttribute("data-width");a=a.getAttribute("data-height")}p(void 0,b,a).then(function(){c._isReading||n()}).catch(function(a){alert("Play video failed: "+(a.message||a))})};d&&d.addEventListener("change",w);var x=!!g.parentNode,u=c._closeWindow=function(){n();c._isReading=!1;e&&e.removeEventListener("change",
v);d&&d.removeEventListener("change",w);c._closeWindow=void 0;a&&a.removeEventListener("click",u);var b=g.parentNode;b&&!x&&b.removeChild(g)};a&&a.addEventListener("click",u);x||document.body.appendChild(g);return Promise.all([h.BarcodeReader.loadWasm(),p()]).then(function(a){if(!c._isReading)return n(),Promise.resolve();q=new h.BarcodeReader;var b=q.getRuntimeSettings();b.mAntiDamageLevel=3;b.mDeblurLevel=0;for(var d in c.runtimeSettings)void 0!=b[d]&&(b[d]=c.runtimeSettings[d]);c.runtimeSettings=
b;return Promise.all([a[1],q.updateRuntimeSettings(b)])}).then(function(a){k();return Promise.all([a[0],f()])}).then(function(a){var b=a[0];a=a[1];return Promise.resolve({width:b.width,height:b.height,current:a.current,all:a.all})})};h.BarcodeReader.VideoReader.prototype.play=function(c,g,b){return this._isReading?this._playvideo(c,g,b):Promise.reject("It has not started reading.")};h.BarcodeReader.VideoReader.prototype.pause=function(){this._isReading&&this._pausevideo()};h.BarcodeReader.VideoReader.prototype.close=
function(){this._isReading&&this._closeWindow()};h.BarcodeReader.VideoReader.prototype.updateDevice=function(){return this._isReading?this._updateDevice():Promise.reject("It has not started reading.")};return h.BarcodeReader});
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_DBRERR_AZTEC_LICENSE_INVALID:-10041};a.EnumImagePixelFormat=a.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};a.EnumResultType=a.EnumResultType||{EDT_StandardText:0,EDT_RawText:1,EDT_CandidateText:2,EDT_PartialText:3};a.EnumTerminateStage=a.EnumTerminateStage||{ETS_Prelocalized:0,ETS_Localized:1,ETS_Recognized:2};a.EnumConflictMode=a.EnumConflictMode||{ECM_Ignore:1,ECM_Overwrite:2};a.BarcodeReaderException=a.BarcodeReaderException||function(){return function(b,c){var d=a.EnumErrorCode.DBR_UNKNOWN;"number"==typeof b?(d=b,b=Error(c)):b=Error(b);
b.code=d;return b}}();return a}();!g.dbrEnv._bWorker||g.BarcodeReader._bCustomWorker||g.dbrEnv._self.onmessage||function(){var c=g.dbrEnv,f=c._self,a=g.BarcodeReader;f.kConsoleLog=f.kConsoleLog||function(c){if(f.onmessage!=a._onWorkerMessage)f.kConsoleLog=void 0;else{var d=void 0;if(void 0===c)d="undefined";else{try{d=JSON.stringify(c,function(){var b=[],a=[];return function(c,d){if("object"===typeof d&&null!==d){var e=b.indexOf(d);if(-1!==e)return"[Circular "+a[e]+"]";b.push(d);a.push(c||"root")}return d}}())}catch(b){}if(void 0===
d||"{}"===d)d=c.toString()}try{postMessage({type:"log",message:d})}catch(b){f.console&&console.error(message)}}};f.kConsoleLog("have detected in worker: "+a.version);var e={};f.onmessage=a._onWorkerMessage=function(d){d=d.data;switch(d.type){case "loadWorker":(function(){a._resourcesPath=d._resourcesPath;a._wasmjsResourcePath=d._wasmjsResourcePath;a._wasmResourcePath=d._wasmResourcePath;c.origin=d.origin;a.loadWasm().then(function(){postMessage({type:"load",success:!0,version:a.version,_defaultRuntimeSettings:a._defaultRuntimeSettings})},
function(a){postMessage({type:"load",success:!1,exception:a.message||a})})})();break;case "createInstance":(function(){try{var c=Math.random();e[c]=new a(d.licenseKey);postMessage({type:"task",id:d.id,body:{success:!0,instanceID:c}})}catch(b){postMessage({type:"task",id:d.id,body:{success:!1,exception:b.message||b}})}})();break;case "deleteInstance":try{e[d.instanceID].deleteInstance(),e[d.instanceID]=void 0,postMessage({type:"task",id:d.id,body:{success:!0}})}catch(m){postMessage({type:"task",id:d.id,
body:{success:!1,exception:m.message||m}})}break;case "decodeRawImageUint8Array":(function(){try{a._isShowRelDecodeTimeInResults=d._isShowRelDecodeTimeInResults;var c=d.body;e[d.instanceID]._decodeRawImageUint8Array(c.buffer,c.width,c.height,c.stride,c.enumImagePixelFormat,c.templateName).then(function(b){postMessage({type:"task",id:d.id,body:{success:!0,results:b}})}).catch(function(b){postMessage({type:"task",id:d.id,body:{success:!1,exception:b.message||b}})})}catch(b){postMessage({type:"task",
id:d.id,body:{success:!1,exception:b.message||b}})}})();break;case "getAllLocalizationResults":(function(){try{var a=e[d.instanceID].getAllLocalizationResults();postMessage({type:"task",id:d.id,body:{success:!0,results:a}})}catch(b){postMessage({type:"task",id:d.id,body:{success:!1,exception:b.message||b}})}})();break;case "getRuntimeSettings":(function(){try{var a=e[d.instanceID].getRuntimeSettings();postMessage({type:"task",id:d.id,body:{success:!0,settings:a}})}catch(b){postMessage({type:"task",
id:d.id,body:{success:!1,exception:b.message||b}})}})();break;case "updateRuntimeSettings":try{e[d.instanceID].updateRuntimeSettings(d.body.settings),postMessage({type:"task",id:d.id,body:{success:!0}})}catch(m){postMessage({type:"task",id:d.id,body:{success:!1,exception:m.message||m}})}break;case "resetRuntimeSettings":try{e[d.instanceID].resetRuntimeSettings(),postMessage({type:"task",id:d.id,body:{success:!0}})}catch(m){postMessage({type:"task",id:d.id,body:{success:!1,exception:m.message||m}})}break;
default:postMessage({type:"task",id:d.id,body:{success:!1,exception:"No such task."}})}}}();g.BarcodeReader.loadWasm=g.BarcodeReader.loadWasm||function(){return new Promise(function(c,f){var a=g.dbrEnv,e=a._self,d=g.BarcodeReader;if("loaded"==d._loadWasmStatus)return c();d._loadWasmTaskQueue=d._loadWasmTaskQueue||function(){var a=new g.TaskQueue;a.timeout=0;return a}();d._loadWasmTaskQueue.push(function(g){if("loaded"==d._loadWasmStatus)return d._loadWasmTaskQueue.next(),c();if(g)return d._loadWasmTaskQueue.next(),
f(d._loadWasmStatus);d._loadWasmStatus="loading";return(new Promise(function(b,c){d._BarcodeReaderWasm=function(){throw Error("'Constructor BarcodeReader(licenseKey)': The wasm hasn't finish loading.");};if(!e.WebAssembly||"undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&/\(.+\s11_2_([2-6]).*\)/.test(navigator.userAgent))return c("'Constructor BarcodeReader(licenseKey)': The browser doesn't support Webassembly.");if(a._bDom)return d._loadWorker().then(function(){d._BarcodeReaderWasm=
function(){this.bInWorker=!0};return b()},function(a){d._BarcodeReaderWasm=function(){throw Error("'Constructor BarcodeReader(licenseKey)': The wasm load failed. ex: "+(a.message||a));};return c(a)});var f={locateFile:function(){var b=d._wasmName||"dbr-"+d._jsVersion+(d._bWithio?".withio":"")+".wasm";if(d._wasmResourcePath||d._resourcesPath){var c=d._wasmResourcePath||d._resourcesPath;"/"!=c.charAt(c.length-1)&&(c+="/");b=c+b}else a._bNodejs&&(b=require("path").join(__dirname,b));return b},onRuntimeInitialized:function(){d._BarcodeReaderWasm=
f.BarcodeReaderWasm;var a=new f.BarcodeReaderWasm("");d.version=a.GetVersion()+"(JS "+d._jsVersion+"."+d._jsEditVersion+")";d._defaultRuntimeSettings=d._handleRetJsonString(a.GetRuntimeSettings());a.delete();e.kConsoleLog&&e.kConsoleLog("load dbr wasm success, version: "+d.version);b()}};f.onExit=f.onAbort=function(a){e.kConsoleLog&&kConsoleLog(a);d._BarcodeReaderWasm=function(){throw Error("'Constructor BarcodeReader(licenseKey)': The wasm load failed. Error: "+(a.message||a));};c(a)};f.print=function(a){e.kConsoleLog&&
kConsoleLog(a)};if("undefined"==typeof _dbrLoadWasm){void 0==d._bWithio&&(d._bWithio=a._bNodejs||a._bWorker&&(d._bCustomWorker||e.onmessage!=d._onWorkerMessage));var g=d._wasmjsName||"dbr-"+d._jsVersion+".wasm"+(d._bWithio?".withio":"")+".min.js";if(d._wasmjsResourcePath||d._resourcesPath){var h=d._wasmjsResourcePath||d._resourcesPath;"/"!=h.charAt(h.length-1)&&(h+="/");g=h+g}else a._bNodejs&&(g=require("path").join(__dirname,g));a._bWorker?importScripts(g):_dbrLoadWasm=require(g)}_dbrLoadWasm(f,
function(b,c,f){e.kConsoleLog&&kConsoleLog("start handle dbr wasm, version: "+b);var g=(new Date).getTime();if(a._bNodejs)return new Promise(function(a,b){require("fs").readFile(c,function(c,d){if(c)return b(c);var l=(new Date).getTime();a(WebAssembly.instantiate(d,f).then(function(a){e.kConsoleLog&&kConsoleLog("build instance from binary timecost: "+((new Date).getTime()-l));e.kConsoleLog&&kConsoleLog("finish handle dbr wasm, total timecost: "+((new Date).getTime()-g));return Promise.resolve(a)}))})});
var h=""+b;d._openDb=d._openDb||function(){return new Promise(function(a,b){var c=function(){d.result.createObjectStore("info");d.result.createObjectStore("wasm");d.result.createObjectStore("module")},d=indexedDB.open("dynamsoft-dbr-wasm",1);d.onupgradeneeded=c;d.onsuccess=function(){a(d.result)};d.onerror=function(){var e=d.error.message||d.error;-1!=e.indexOf("version")?(d=indexedDB.deleteDatabase("dynamsoft-dbr-wasm"),d.onsuccess=function(){var d=indexedDB.open("dynamsoft-dbr-wasm",1);d.onupgradeneeded=
c;d.onsuccess=function(){a(d.result)};d.onerror=function(){b("open db [dynamsoft-dbr-wasm] fail")}},d.onerror=function(){b("open db [dynamsoft-dbr-wasm] fail")}):b("open db [dynamsoft-dbr-wasm] fail: "+e)}})};var k=function(a){return new Promise(function(b,c){var d=a.transaction(["info"]).objectStore("info").get("bSupportStoreModuleInDb"),e=function(){var d=a.transaction(["info"],"readwrite").objectStore("info"),e=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,127,3,2,1,0,7,6,1,2,95,97,0,0,10,
6,1,4,0,65,1,11]);try{var l=d.put(new WebAssembly.Module(e.buffer),"testStoreModule");l.onsuccess=function(){d.put(!0,"bSupportStoreModuleInDb").onsuccess=function(){b("set bSupportStoreModuleInDb = true success")}};l.onerror=function(){c("Failed to store [testStoreModule] in wasm cache, bSupportStoreModuleInDb == false: "+(l.error.message||l.error))}}catch(z){c("Failed to store [testStoreModule] in wasm cache, bSupportStoreModuleInDb == false: "+(z.message||z))}};d.onsuccess=function(){d.result?
b("bSupportStoreModuleInDb == true"):e()}})};d._lookupInDatabase=d._lookupInDatabase||function(a,b,c){return new Promise(function(d,e){var l=a.transaction([b]).objectStore(b).get(c);l.onsuccess=function(){l.result?d(l.result):e(c+" was not found in "+b)}})};d._storeInDatabase=d._storeInDatabase||function(a,b,c,d){return new Promise(function(e,l){var f=a.transaction([b],"readwrite").objectStore(b).put(d,c);f.onerror=function(){l("Failed to store "+c+" in wasm cache: "+(f.error.message||f.error))};
f.onsuccess=function(){e("Successfully stored "+c+" in "+b)}})};return d._openDb().then(function(a){e.kConsoleLog&&kConsoleLog("open db success");return k(a).then(function(a){e.kConsoleLog&&kConsoleLog(a);return Promise.resolve(!0)},function(a){e.kConsoleLog&&kConsoleLog(a.message||a);return Promise.resolve(!1)}).then(function(b){var l=(new Date).getTime();return d._lookupInDatabase(a,"wasm",h).then(function(c){if(c instanceof WebAssembly.Module){e.kConsoleLog&&kConsoleLog("get a wasm module from db, timecost:"+
((new Date).getTime()-l));var q=(new Date).getTime();return WebAssembly.instantiate(c,f).then(function(a){e.kConsoleLog&&kConsoleLog("build instance from module timecost: "+((new Date).getTime()-q));e.kConsoleLog&&kConsoleLog("finish handle dbr wasm, total timecost: "+((new Date).getTime()-g));return Promise.resolve({module:c,instance:a})})}e.kConsoleLog&&kConsoleLog("get a wasm binary from db, timecost:"+((new Date).getTime()-l));var v=(new Date).getTime();return WebAssembly.instantiate(c,f).then(function(c){e.kConsoleLog&&
kConsoleLog("build instance from binary timecost: "+((new Date).getTime()-v));if(b){var l=(new Date).getTime();return d._storeInDatabase(a,"wasm",h,c.module).then(function(a){e.kConsoleLog&&kConsoleLog(a+", timecost: "+((new Date).getTime()-l));e.kConsoleLog&&kConsoleLog("finish handle dbr wasm, total timecost: "+((new Date).getTime()-g));return Promise.resolve(c)})}e.kConsoleLog&&kConsoleLog("finish handle dbr wasm, total timecost: "+((new Date).getTime()-g));return Promise.resolve(c)})},function(l){e.kConsoleLog&&
kConsoleLog(l.message||l);e.kConsoleLog&&kConsoleLog("downloading...");var q=(new Date).getTime();return b?WebAssembly.instantiateStreaming(fetch(c),f).then(function(b){d._onWasmDownloaded&&d._onWasmDownloaded();e.kConsoleLog&&kConsoleLog("download with build timecost: "+((new Date).getTime()-q));var c=(new Date).getTime();return d._storeInDatabase(a,"wasm",h,b.module).then(function(a){e.kConsoleLog&&kConsoleLog(a+", timecost: "+((new Date).getTime()-c));e.kConsoleLog&&kConsoleLog("finish handle dbr wasm, total timecost: "+
((new Date).getTime()-g));return Promise.resolve(b)},function(a){e.kConsoleLog&&kConsoleLog(a.message||a);return Promise.reject("Can't store wasm in db.")})}):fetch(c).then(function(a){return a.arrayBuffer()}).then(function(b){e.kConsoleLog&&kConsoleLog("download timecost: "+((new Date).getTime()-q));d._onWasmDownloaded&&d._onWasmDownloaded();var c=(new Date).getTime();return d._storeInDatabase(a,"wasm",h,b).then(function(a){e.kConsoleLog&&kConsoleLog(a+", timecost: "+((new Date).getTime()-c));return Promise.resolve(b)},
function(a){e.kConsoleLog&&kConsoleLog(a.message||a);return Promise.reject("Can't store wasm in db.")})}).then(function(a){var b=(new Date).getTime();return WebAssembly.instantiate(a,f).then(function(a){e.kConsoleLog&&kConsoleLog("build instance from binary timecost: "+((new Date).getTime()-b));e.kConsoleLog&&kConsoleLog("finish handle dbr wasm, total timecost: "+((new Date).getTime()-g));return Promise.resolve(a)})})})})},function(a){e.kConsoleLog&&kConsoleLog(a.message||a);return WebAssembly.instantiateStreaming?
WebAssembly.instantiateStreaming(fetch(c),f).then(function(a){d._onWasmDownloaded&&d._onWasmDownloaded();e.kConsoleLog&&kConsoleLog("finish handle dbr wasm, total timecost: "+((new Date).getTime()-g));return Promise.resolve(a)}):fetch(c).then(function(a){return a.arrayBuffer()}).then(function(a){d._onWasmDownloaded&&d._onWasmDownloaded();return WebAssembly.instantiate(a,f).then(function(a){e.kConsoleLog&&kConsoleLog("finish handle dbr wasm, total timecost: "+((new Date).getTime()-g));return Promise.resolve(a)})})})},
d)})).then(function(){d._loadWasmStatus="loaded";d._loadWasmTaskQueue.next();c()}).catch(function(a){d._loadWasmStatus=a;d._loadWasmTaskQueue.next();f(a)})},null,["loading"==d._loadWasmStatus])})};g.BarcodeReader.clearCache=g.BarcodeReader.clearCache||function(){return new Promise(function(c,f){try{var a=window.indexedDB.deleteDatabase("dynamsoft-dbr-wasm");a.onsuccess=a.onerror=function(){a.error&&alert("Clear failed: "+(a.error.message||a.error));c()}}catch(e){alert(e.message||e),f()}})};g.BarcodeReader.Scanner=
function(c){c=c||{};var f;(f=c.htmlElement)||(f=document.createElement("div"),f.style.position="fixed",f.style.width="100%",f.style.height="100%",f.style.left="0",f.style.top="0",f.style.background="#eee",f.innerHTML='<p style="width:100%;height:32px;line-height:32px;position:absolute;margin:auto 0;top:0;bottom:0;text-align:center;">loading</p><video class="dbrScanner-video" playsinline="true" style="width:100%;height:100%;position:absolute;left:0;top:0;"></video><select class="dbrScanner-sel-camera" style="position:absolute;left:0;top:0;"></select><select class="dbrScanner-sel-resolution" style="position:absolute;left:0;top:20px;"></select><button class="dbrScanner-btn-close" style="position:absolute;right:0;top:0;"><svg width="16" height="16" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1490 1322q0 40-28 68l-136 136q-28 28-68 28t-68-28l-294-294-294 294q-28 28-68 28t-68-28l-136-136q-28-28-28-68t28-68l294-294-294-294q-28-28-28-68t28-68l136-136q28-28 68-28t68 28l294 294 294-294q28-28 68-28t68 28l136 136q28 28 28 68t-28 68l-294 294 294 294q28 28 28 68z"/></svg></button>');
this.htmlElement=f;this.videoSettings=c.videoSettings;this.confidence=c.confidence;void 0==this.confidence&&(this.confidence=30);this.intervalTime=c.intervalTime;void 0==this.intervalTime&&(this.intervalTime=100);this.runtimeSettings=c.runtimeSettings||{};this.searchRegion=c.searchRegion||{sx:void 0,sy:void 0,sWidth:void 0,sHeight:void 0,dWidth:void 0,dHeight:void 0};this.bAddOriVideoCanvasToResult=c.bAddOriVideoCanvasToResult;this.bAddSearchRegionCanvasToResult=c.bAddSearchRegionCanvasToResult;this.onFrameRead=
c.onFrameRead;this.duplicateForgetTime=c.duplicateForgetTime;void 0==this.duplicateForgetTime&&(this.duplicateForgetTime=3E3);this.onNewCodeRead=c.onNewCodeRead;this._isOpen=!1};g.BarcodeReader.Scanner.prototype.isOpen=function(){return this._isOpen};g.BarcodeReader.Scanner.prototype.open=function(){var c=this;if(c._isOpen)return Promise.reject("The scanner is already open.");c._isOpen=!0;var f=c.htmlElement,a,e,d,m,b;(function(){for(var c=[],l=$jscomp.makeIterator(f.children),g=l.next();!g.done;g=
l.next())c.push(g.value);for(l=0;l<c.length;++l){var h=$jscomp.makeIterator(c[l].children);for(g=h.next();!g.done;g=h.next())c.push(g.value)}c=$jscomp.makeIterator(c);for(g=c.next();!g.done;g=c.next())g=g.value,g.classList.contains("dbrScanner-video")?a=g:g.classList.contains("dbrScanner-sel-camera")?e=g:g.classList.contains("dbrScanner-sel-resolution")?(d=g,d.options.length||(d.innerHTML='<option class="dbrScanner-opt-gotResolution" value="got"></option><option data-width="3840" data-height="2160">ask 3840 x 2160</option><option data-width="2560" data-height="1440">ask 2560 x 1440</option><option data-width="1920" data-height="1080">ask 1920 x 1080</option><option data-width="1600" data-height="1200">ask 1600 x 1200</option><option data-width="1280" data-height="720">ask 1280 x 720</option><option data-width="800" data-height="600">ask 800 x 600</option><option data-width="640" data-height="480">ask 640 x 480</option><option data-width="640" data-height="360">ask 640 x 360</option>',
m=d.options[0])):g.classList.contains("dbrScanner-opt-gotResolution")?m=g:g.classList.contains("dbrScanner-btn-close")&&(b=g)})();var h=c._updateDevice=function(){return navigator.mediaDevices.enumerateDevices().then(function(b){var c=[],d;if(e){var g=e.value;e.innerHTML=""}for(var f=0;f<b.length;++f){var h=b[f];if("videoinput"==h.kind){var k={};k.deviceId=h.deviceId;k.label=h.label||"camera "+f;c.push(k)}}b=$jscomp.makeIterator(a.srcObject.getTracks());for(f=b.next();!f.done;f=b.next()){f=f.value;
if(q)break;if("video"==f.kind)for(h=$jscomp.makeIterator(c),k=h.next();!k.done;k=h.next())if(k=k.value,f.label==k.label){var q=k;break}}if(e){b=$jscomp.makeIterator(c);for(k=b.next();!k.done;k=b.next())f=k.value,h=document.createElement("option"),h.value=f.deviceId,h.innerText=f.label,e.appendChild(h),g==f.deviceId&&(d=h);g=e.childNodes;if(!d&&q&&g.length)for(g=$jscomp.makeIterator(g),b=g.next();!b.done;b=g.next())if(b=b.value,q.label==b.innerText){d=b;break}d&&(e.value=d.value)}return Promise.resolve({current:q,
all:c})})};c._pausevideo=function(){a.pause()};var r=function(){a.srcObject&&(self.kConsoleLog&&self.kConsoleLog("======stop video========"),a.srcObject.getTracks().forEach(function(a){a.stop()}))},n=c._playvideo=function(b,e,f){return new Promise(function(g,l){r();self.kConsoleLog&&self.kConsoleLog("======before video========");var h=c.videoSettings=c.videoSettings||{video:{facingMode:{ideal:"environment"}}};/Safari/.test(navigator.userAgent)&&/iPhone/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)?
1280<=e?h.video.width=1280:640<=e?h.video.width=640:320<=e&&(h.video.width=320):(e&&(h.video.width={ideal:e}),f&&(h.video.height={ideal:f}));b&&(h.video.facingMode=void 0,h.video.deviceId={exact:b});var k=!1,q=function(){self.kConsoleLog&&self.kConsoleLog("======try getUserMedia========");self.kConsoleLog&&self.kConsoleLog("ask "+JSON.stringify(h.video.width)+"x"+JSON.stringify(h.video.height));navigator.mediaDevices.getUserMedia(h).then(function(b){self.kConsoleLog&&self.kConsoleLog("======get video========");
return new Promise(function(c,e){a.srcObject=b;a.onloadedmetadata=function(){self.kConsoleLog&&self.kConsoleLog("======play video========");a.play().then(function(){self.kConsoleLog&&self.kConsoleLog("======played video========");var b="got "+a.videoWidth+"x"+a.videoHeight;d&&m&&(m.setAttribute("data-width",a.videoWidth),m.setAttribute("data-height",a.videoHeight),d.value="got",m.innerText=b);self.kConsoleLog&&self.kConsoleLog(b);c();g({width:a.videoWidth,height:a.videoHeight})},function(a){e(a)})};
a.onerror=function(){e()}})}).catch(function(a){self.kConsoleLog&&self.kConsoleLog(a);!k&&h.video?(k=!0,h.video.width=void 0,h.video.height=void 0,q()):l(a)})};q()})};c.arrDiffCodeInfo=[];var p,k=function(a,b){if(a instanceof Array){var c=[];a=$jscomp.makeIterator(a);for(var d=a.next();!d.done;d=a.next())c.push(k(d.value,b));return c}c=JSON.parse(JSON.stringify(a,function(a,b){if("oriVideoCanvas"!=a&&"searchRegionCanvas"!=a)return b}));b||(c.oriVideoCanvas=a.oriVideoCanvas,c.searchRegionCanvas=a.searchRegionCanvas);
return c},u=function(){if(c._isOpen){if(a.paused)return self.kConsoleLog&&self.kConsoleLog("Video is paused. Ask in 1s."),setTimeout(u,1E3);self.kConsoleLog&&self.kConsoleLog("======= once read =======");var b=(new Date).getTime();Promise.all([JSON.stringify(p.getRuntimeSettings())!=JSON.stringify(c.runtimeSettings)?p.updateRuntimeSettings(c.runtimeSettings):Promise.resolve(),function(){var b=c.searchRegion;if(b&&(b.sx||b.sy||b.sWidth||b.sHeight||b.dWidth||b.dHeight)){var d=b.sx||0,e=b.sy||0,f=b.sWidth||
a.videoWidth,g=b.sHeight||a.videoHeight,h=b.dWidth||b.sWidth||a.videoWidth;b=b.dHeight||b.sHeight||a.videoHeight;0<d&&1>d&&(d=Math.round(d*a.videoWidth));0<e&&1>e&&(e=Math.round(e*a.videoHeight));1>=f&&(f=Math.round(f*a.videoWidth));1>=g&&(g=Math.round(g*a.videoHeight));1>=h&&(h=Math.round(h*a.videoWidth));1>=g&&(b=Math.round(b*a.videoHeight));return[a,d,e,f,g,h,b]}return a}()]).then(function(a){a=a[1];a instanceof Array||(a=[a]);p._bAddOriVideoCanvasToResult=c.bAddOriVideoCanvasToResult;p._bAddSearchRegionCanvasToResult=
c.bAddSearchRegionCanvasToResult;return p.decodeVideo.apply(p,a)}).then(function(a){var d=(new Date).getTime();self.kConsoleLog&&self.kConsoleLog("time cost: "+(d-b)+"ms");for(var e=[],f=0;f<a.length;++f){var g=a[f],h=g.BarcodeText;self.kConsoleLog&&self.kConsoleLog(h);g.LocalizationResult.ExtendedResultArray[0].Confidence>=c.confidence&&e.push(g)}e=k(e);for(f=0;f<c.arrDiffCodeInfo.length;++f){g=c.arrDiffCodeInfo[f];h=-1;for(var l in e){var q=e[l];if(g.result.BarcodeText==q.BarcodeText&&g.result.BarcodeFormat==
q.BarcodeFormat){h=l;break}}-1!=h?(g.time=d,g.result=e[h],++g.count,e.splice(h,1)):d-g.time>c.duplicateForgetTime&&(c.arrDiffCodeInfo.splice(f,1),--f)}for(l=0;l<e.length;++l)for(f=e[l],g=l+1;g<e.length;)h=e[g],f.BarcodeText==h.BarcodeText&&f.BarcodeFormat==h.BarcodeFormat?e.splice(g,1):++g;f=$jscomp.makeIterator(e);for(l=f.next();!l.done;l=f.next())c.arrDiffCodeInfo.push({result:k(l.value,!0),time:d,count:1});if(c.onFrameRead)c.onFrameRead(k(a));a=$jscomp.makeIterator(e);for(l=a.next();!l.done;l=
a.next())if(d=l.value,c.onNewCodeRead)c.onNewCodeRead(d.BarcodeText,k(d));setTimeout(u,c.intervalTime)}).catch(function(a){self.kConsoleLog&&self.kConsoleLog(a);setTimeout(u,c.intervalTime);throw a;})}else p&&(p.deleteInstance(),p=void 0)},x=function(){n(e.value).then(function(){c._isOpen||r()}).catch(function(a){alert("Play video failed: "+(a.message||a))})};e&&e.addEventListener("change",x);var y=function(){if(d&&-1!=d.selectedIndex){var a=d.options[d.selectedIndex];var b=a.getAttribute("data-width");
a=a.getAttribute("data-height")}n(void 0,b,a).then(function(){c._isOpen||r()}).catch(function(a){alert("Play video failed: "+(a.message||a))})};d&&d.addEventListener("change",y);var w=!!f.parentNode,t=c._closeWindow=function(){r();c._isOpen=!1;e&&e.removeEventListener("change",x);d&&d.removeEventListener("change",y);c._closeWindow=void 0;b&&b.removeEventListener("click",t);var a=f.parentNode;a&&!w&&a.removeChild(f)};b&&b.addEventListener("click",t);w||document.body.appendChild(f);return Promise.all([g.BarcodeReader.loadWasm(),
n()]).then(function(a){if(!c._isOpen)return r(),Promise.resolve();p=new g.BarcodeReader;var b=p.getRuntimeSettings();b.mAntiDamageLevel=3;b.mDeblurLevel=0;for(var d in c.runtimeSettings)void 0!=b[d]&&(b[d]=c.runtimeSettings[d]);c.runtimeSettings=b;return Promise.all([a[1],p.updateRuntimeSettings(b)])}).then(function(a){u();return Promise.all([a[0],h()])}).then(function(a){var b=a[0];a=a[1];return Promise.resolve({width:b.width,height:b.height,current:a.current,all:a.all})})};g.BarcodeReader.Scanner.prototype.play=
function(c,f,a){return this._isOpen?this._playvideo(c,f,a):Promise.reject("The scanner is not open.")};g.BarcodeReader.Scanner.prototype.pause=function(){this._isOpen&&this._pausevideo()};g.BarcodeReader.Scanner.prototype.close=function(){this._isOpen&&this._closeWindow()};g.BarcodeReader.Scanner.prototype.updateDevice=function(){return this._isOpen?this._updateDevice():navigator.mediaDevices.enumerateDevices().then(function(c){for(var f=[],a=0;a<c.length;++a){var e=c[a];if("videoinput"==e.kind){var d=
{};d.deviceId=e.deviceId;d.label=e.label||"camera "+a;f.push(d)}}return Promise.resolve({current:void 0,all:f})})};return g.BarcodeReader});
{
"name": "dynamsoft-javascript-barcode",
"version": "6.5.1",
"version": "6.5.2",
"author": {

@@ -5,0 +5,0 @@ "name": "Dynamsoft",

@@ -30,10 +30,9 @@ # Dynamsoft JavaScript Barcode SDK for Node and Web

BarcodeReader.licenseKey = 'LICENSE-KEY';
var reader;
BarcodeReader.createInstance().then(r =>
(reader = r) && r.decode('sample.png')
).then(results => {
for(var i = 0; i < results.length; ++i){
console.log(results[i].BarcodeText);
}
reader.deleteInstance();
BarcodeReader.createInstance().then(reader => {
reader.decode('sample.png').then(results => {
for(var i = 0; i < results.length; ++i){
console.log(results[i].BarcodeText);
}
reader.deleteInstance();
});
});

@@ -51,7 +50,7 @@ ```

BarcodeReader.licenseKey = 'LICENSE-KEY';
let videoReader = new BarcodeReader.VideoReader({
let videoReader = new BarcodeReader.Scanner({
onFrameRead: results => {console.log(results);},
onDiffCodeRead: (txt, result) => {alert(txt);}
onNewCodeRead: (txt, result) => {alert(txt);}
});
videoReader.read();
videoReader.open();
</script>

@@ -64,5 +63,18 @@ </body>

```js
<!DOCTYPE html>
<html>
<body>
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode/dist/dbr.min.js"></script>
<script>
BarcodeReader.licenseKey = 'LICENSE-KEY';
let videoReader = new BarcodeReader.Scanner({
onFrameRead: results => {console.log(results);},
onNewCodeRead: (txt, result) => {alert(txt);}
});
videoReader.open();
</script>
</body>
</html>
```
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode"></script>
```

@@ -69,0 +81,0 @@ Use [Web Server for Chrome](https://chrome.google.com/webstore/detail/web-server-for-chrome/ofhbbkphhbklhfoeikjpcbhemlocgigb) for quick deployment.

@@ -1,2 +0,3 @@

var BarcodeReader = require('../../dist/dbr-6.5.0.3.min');
var BarcodeReader = require('../../dist/dbr-6.5.1.min');
// https://www.dynamsoft.com/CustomerPortal/Portal/TrialLicense.aspx
BarcodeReader.licenseKey = 't0068MgAAAAxT9peWqAbLNI2gDlg9yk8dqzhp5Me5BNCgFIg2p5X+8TPYghCr9cz6TNFlkmkpzOJelNHJaQMWGe7Bszoxoo4=';

@@ -3,0 +4,0 @@

@@ -1,2 +0,3 @@

var BarcodeReader = require('../../dist/dbr-6.5.0.3.min');
var BarcodeReader = require('../../dist/dbr-6.5.1.min');
// https://www.dynamsoft.com/CustomerPortal/Portal/TrialLicense.aspx
BarcodeReader.licenseKey = 't0068MgAAAAxT9peWqAbLNI2gDlg9yk8dqzhp5Me5BNCgFIg2p5X+8TPYghCr9cz6TNFlkmkpzOJelNHJaQMWGe7Bszoxoo4=';

@@ -3,0 +4,0 @@ var reader;

@@ -1,2 +0,3 @@

var BarcodeReader = require('../../dist/dbr-6.5.0.3.min');
var BarcodeReader = require('../../dist/dbr-6.5.1.min');
// https://www.dynamsoft.com/CustomerPortal/Portal/TrialLicense.aspx
BarcodeReader.licenseKey = 't0068MgAAAAxT9peWqAbLNI2gDlg9yk8dqzhp5Me5BNCgFIg2p5X+8TPYghCr9cz6TNFlkmkpzOJelNHJaQMWGe7Bszoxoo4=';

@@ -3,0 +4,0 @@ var reader;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc