barcode-detector 2.3.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,9 +2,37 @@
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/barcode-detector)](https://www.npmjs.com/package/barcode-detector/v/latest) [![npm bundle size (scoped)](https://img.shields.io/bundlephobia/minzip/barcode-detector)](https://www.npmjs.com/package/barcode-detector/v/latest) [![jsDelivr hits (npm scoped)](https://img.shields.io/jsdelivr/npm/hm/barcode-detector?color=%23ff5627)](https://cdn.jsdelivr.net/npm/barcode-detector@latest/)
4
4
 
5
- A [Barcode Detection API](https://wicg.github.io/shape-detection-api/#barcode-detection-api) polyfill that uses [ZXing-C++ WebAssembly](https://github.com/Sec-ant/zxing-wasm) under the hood.
5
+ A [Barcode Detection API](https://wicg.github.io/shape-detection-api/#barcode-detection-api) ponyfill/polyfill that uses [ZXing-C++ WebAssembly](https://github.com/Sec-ant/zxing-wasm) under the hood.
6
6
 
7
- Supported barcode formats: `aztec`, `code_128`, `code_39`, `code_93`, `codabar`, `databar`, `databar_expanded`, `databar_limited`, `data_matrix`, `dx_film_edge`, `ean_13`, `ean_8`, `itf`, `maxi_code` (only generated ones, and no position info), `micro_qr_code`, `pdf417`, `qr_code`, `rm_qr_code`, `upc_a`, `upc_e`, `linear_codes` and `matrix_codes` (for convenience).
7
+ Supported barcode formats:
8
+
9
+ <div align="center">
10
+
11
+ | Linear Barcode Formats | Matrix Barcode Formats | Special Barcode Formats |
12
+ | :--------------------: | :--------------------: | :---------------------: |
13
+ | `codabar` | `aztec` |    `linear_codes`[^2] |
14
+ | `code_39` | `data_matrix` |    `matrix_codes`[^3] |
15
+ | `code_93` |    `maxi_code`[^1] |    `any`[^4] |
16
+ | `code_128` | `pdf417` | |
17
+ | `databar` | `qr_code` | |
18
+ | `databar_limited` | `micro_qr_code` | |
19
+ | `databar_expanded` | `rm_qr_code` | |
20
+ | `dx_film_edge` | | |
21
+ | `ean_8` | | |
22
+ | `ean_13` | | |
23
+ | `itf` | | |
24
+ | `upc_a` | | |
25
+ | `upc_e` | | |
26
+
27
+ [^1]: Detection support for `MaxiCode` requires a pure monochrome image that contains an unrotated and unskewed symbol, along with a sufficient white border surrounding it.
28
+
29
+ [^2]: `linear_codes` is a shorthand for all linear barcode formats.
30
+
31
+ [^3]: `matrix_codes` is a shorthand for all matrix barcode formats.
32
+
33
+ [^4]: `any` is a shorthand for `linear_codes` and `matrix_codes`, i.e., all barcode formats. Note that you don't need to specify `any` in the `formats` option, as not providing the option also indicates detecting all barcode formats.
34
+
35
+ </div>
8
36
 
9
37
  ## Install
10
38
 
@@ -14,51 +42,64 @@ To install, run the following command:
14
42
  npm i barcode-detector
15
43
  ```
16
44
 
17
- ## Recommended Usage with Node + ESM
45
+ ## Usage
18
46
 
19
- This package can be imported in three different ways:
20
-
21
- ### Pure Module
47
+ ### Ponyfill
22
48
 
23
49
  ```ts
24
- import { BarcodeDetector } from "barcode-detector/pure";
50
+ import { BarcodeDetector } from "barcode-detector/ponyfill";
25
51
  ```
26
52
 
27
53
  To avoid potential namespace collisions, you can also rename the export:
28
54
 
29
55
  ```ts
30
- import { BarcodeDetector as BarcodeDetectorPolyfill } from "barcode-detector/pure";
56
+ import { BarcodeDetector as BarcodeDetectorPonyfill } from "barcode-detector/ponyfill";
31
57
  ```
32
58
 
33
- This approach is beneficial when you want to use a package to detect barcodes without polluting `globalThis`, or when your runtime already provides an implementation of the Barcode Detection API, but you still want this package to function.
59
+ A ponyfill is a module required to be explicitly imported without introducing side effects. Use this subpath if you want to avoid polluting the global object with the `BarcodeDetector` class, or if you intend to use the implementation provided by this package instead of the native one.
34
60
 
35
- ### Side Effects
61
+ ### Polyfill
36
62
 
37
63
  ```ts
38
- import "barcode-detector/side-effects";
64
+ import "barcode-detector/polyfill";
39
65
  ```
40
66
 
41
- This approach is beneficial when you need a drop-in polyfill. If there's already an implementation of Barcode Detection API on `globalThis`, this won't take effect (type declarations will, as we cannot optionally declare types). In such cases, please use the [pure module](#pure-module) instead.
67
+ This subpath is used to polyfill the native `BarcodeDetector` class. It will automatically register the `BarcodeDetector` class in the global object **_if it's not already present_**.
68
+
69
+ > [!IMPORTANT]
70
+ >
71
+ > The polyfill will opt in only if no `BarcodeDetector` is present in `globalThis`. It basically works like this:
72
+ >
73
+ > ```ts
74
+ > import { BarcodeDetector } from "barcode-detector/ponyfill";
75
+ > globalThis.BarcodeDetector ??= BarcodeDetector;
76
+ > ```
77
+ >
78
+ > Note that it **_doesn't_** check if the implementation is provided natively or by another polyfill. It also **_doesn't_** try to augment the existing implementation with all the barcode formats supported by this package. If you want all the features provided by this package, but you already have a native or another polyfilled `BarcodeDetector`, you should use the [ponyfill](#ponyfill) approach. You can register it to the `globalThis` object manually if you want to.
42
79
 
43
- ### Both
80
+ ### Ponyfill + Polyfill
44
81
 
45
82
  ```ts
46
83
  import { BarcodeDetector } from "barcode-detector";
47
84
  ```
48
85
 
49
- This approach combines the [pure module](#pure-module) and [side effects](#side-effects).
86
+ This approach combines the [ponyfill](#ponyfill) and [polyfill](#polyfill) approaches.
87
+
88
+ > [!NOTE]
89
+ >
90
+ > The `ponyfill` subpath was named `pure` and the `polyfill` subpath was named `side-effects` in early versions. They are no longer recommended for use and are considered deprecated. Please use the new subpaths as described above.
50
91
 
51
- ## Recommended Usage in Modern Browsers
92
+ ### `<script type="module">`
52
93
 
53
94
  For [modern browsers that support ES modules](https://caniuse.com/es6-module), this package can be imported via the `<script type="module">` tags:
54
95
 
55
- 1. Include side effects:
96
+ 1. Include the polyfill:
56
97
 
57
98
  ```html
58
99
  <!-- register -->
59
100
  <script
60
101
  type="module"
61
- src="https://fastly.jsdelivr.net/npm/barcode-detector@2/dist/es/side-effects.min.js"
102
+ src="https://fastly.jsdelivr.net/npm/barcode-detector@3/dist/es/polyfill.min.js"
62
103
  ></script>
63
104
 
64
105
  <!-- use -->
@@ -71,7 +112,7 @@ For [modern browsers that support ES modules](https://caniuse.com/es6-module), t
71
112
 
72
113
  ```html
73
114
  <script type="module">
74
- import { BarcodeDetector } from "https://fastly.jsdelivr.net/npm/barcode-detector@2/dist/es/pure.min.js";
115
+ import { BarcodeDetector } from "https://fastly.jsdelivr.net/npm/barcode-detector@3/dist/es/ponyfill.min.js";
75
116
  const barcodeDetector = new BarcodeDetector();
76
117
  </script>
77
118
  ```
@@ -83,169 +124,96 @@ For [modern browsers that support ES modules](https://caniuse.com/es6-module), t
83
124
  <script type="importmap">
84
125
  {
85
126
  "imports": {
86
- "barcode-detector/pure": "https://fastly.jsdelivr.net/npm/barcode-detector@2/dist/es/pure.min.js"
127
+ "barcode-detector/ponyfill": "https://fastly.jsdelivr.net/npm/barcode-detector@3/dist/es/ponyfill.min.js"
87
128
  }
88
129
  }
89
130
  </script>
90
131
 
91
132
  <!-- script scoped access -->
92
133
  <script type="module">
93
- import { BarcodeDetector } from "barcode-detector/pure";
134
+ import { BarcodeDetector } from "barcode-detector/ponyfill";
94
135
  const barcodeDetector = new BarcodeDetector();
95
136
  </script>
96
137
  ```
97
138
 
98
- ## Usage with Legacy Compatibility
99
-
100
- Starting from v1.2, this package supports IIFE and CJS build outputs for use cases that require legacy compatibility.
101
-
102
139
  ### IIFE
103
140
 
104
- For legacy browsers that lack support for module type `<script>` tags, or for userscripts, IIFE is the preferred choice. Upon executing the IIFE script, a variable named `BarcodeDetectionAPI` will be registered in the global.
141
+ For legacy browsers or userscripts that lack support for `<script type="module">` tags, IIFE is the preferred choice. Upon executing the IIFE script, a variable named `BarcodeDetectionAPI` will be registered in the global `window` by `var` declaration.
105
142
 
106
143
  ```html
107
144
  <!--
108
- IIFE pure.js registers:
145
+ IIFE ponyfill.js registers:
109
146
  window.BarcodeDetectionAPI.BarcodeDetector
110
- window.BarcodeDetectionAPI.setZXingModuleOverrides
147
+ window.BarcodeDetectionAPI.prepareZXingModule
111
148
  -->
112
- <script src="https://fastly.jsdelivr.net/npm/barcode-detector@2/dist/iife/pure.min.js"></script>
149
+ <script src="https://fastly.jsdelivr.net/npm/barcode-detector@3/dist/iife/ponyfill.min.js"></script>
113
150
 
114
151
  <!--
115
- IIFE side-effects.js registers:
152
+ IIFE polyfill.js registers:
116
153
  window.BarcodeDetector
117
- window.BarcodeDetectionAPI.setZXingModuleOverrides
154
+ window.BarcodeDetectionAPI.prepareZXingModule
118
155
  -->
119
- <script src="https://fastly.jsdelivr.net/npm/barcode-detector@2/dist/iife/side-effects.min.js"></script>
156
+ <script src="https://fastly.jsdelivr.net/npm/barcode-detector@3/dist/iife/polyfill.min.js"></script>
120
157
 
121
158
  <!--
122
159
  IIFE index.js registers:
123
160
  window.BarcodeDetector
124
161
  window.BarcodeDetectionAPI.BarcodeDetector
125
- window.BarcodeDetectionAPI.setZXingModuleOverrides
162
+ window.BarcodeDetectionAPI.prepareZXingModule
126
163
  -->
127
- <script src="https://fastly.jsdelivr.net/npm/barcode-detector@2/dist/iife/index.min.js"></script>
164
+ <script src="https://fastly.jsdelivr.net/npm/barcode-detector@3/dist/iife/index.min.js"></script>
128
165
  ```
129
166
 
130
- ### CJS
131
-
132
- This package can also be consumed as a commonjs package:
167
+ ## `prepareZXingModule`
133
168
 
134
- 1. Vanilla Javascript:
135
-
136
- ```js
137
- // src/index.js
138
- const { BarcodeDetector } = require("barcode-detector/pure");
139
- ```
140
-
141
- 2. With Typescript:
142
-
143
- ```ts
144
- // src/index.ts
145
- import { BarcodeDetector } from "barcode-detector/pure";
146
- ```
147
-
148
- `tsconfig.json`:
149
-
150
- ```json
151
- {
152
- "compilerOptions": {
153
- "module": "CommonJS",
154
- "moduleResolution": "Node",
155
- "skipLibCheck": true
156
- },
157
- "include": ["src"]
158
- }
159
- ```
160
-
161
- ## `setZXingModuleOverrides`
162
-
163
- In addition to `BarcodeDetector`, this package exports another function called `setZXingModuleOverrides`.
164
-
165
- This package employs [zxing-wasm](https://github.com/Sec-ant/zxing-wasm) to enable the core barcode reading functionality. As a result, a `.wasm` binary file is fetched at runtime. The default fetch path for this binary file is:
166
-
167
- ```
168
- https://fastly.jsdelivr.net/npm/zxing-wasm@<version>/dist/reader/zxing_reader.wasm
169
- ```
169
+ The core barcode reading functionality of this package is powered by [`zxing-wasm`](https://github.com/Sec-ant/zxing-wasm). Therefore, a `.wasm` binary file is fetched at runtime. By default, the `.wasm` serving path is initialized with a jsDelivr CDN URL. However, there're cases where this is not desired, such as the allowed serving path is white-listed by the Content Security Policy (CSP), or offline usage is required.
170
170
 
171
- The `setZXingModuleOverrides` function allows you to govern where the `.wasm` binary is served from, thereby enabling offline use of the package, use within a local network, or within a site having strict [CSP](https://developer.mozilla.org/docs/Web/HTTP/CSP) rules.
171
+ To customize the `.wasm` serving path, this package reexports `prepareZXingModule` along with `ZXING_WASM_VERSION` and `ZXING_WASM_SHA256` from `zxing-wasm`. For more details on how to use them, please check [Configuring `.wasm` Serving](https://github.com/Sec-ant/zxing-wasm?tab=readme-ov-file#configuring-wasm-serving) and [Controlling `.wasm` Instantiation Timing and Caching](https://github.com/Sec-ant/zxing-wasm?tab=readme-ov-file#controlling-wasm-instantiation-timing-and-caching) sections in the `zxing-wasm` repository.
172
172
 
173
- For instance, should you want to inline this `.wasm` file in your build output for offline usage, with the assistance of build tools, you could try:
173
+ An example usage to override the `.wasm` serving path with an `unpkg.com` CDN url is as follows:
174
174
 
175
175
  ```ts
176
- // src/index.ts
177
- import wasmFile from "../node_modules/zxing-wasm/dist/reader/zxing_reader.wasm?url";
178
-
179
176
  import {
180
- setZXingModuleOverrides,
181
177
  BarcodeDetector,
182
- } from "barcode-detector/pure";
183
-
184
- setZXingModuleOverrides({
185
- locateFile: (path, prefix) => {
186
- if (path.endsWith(".wasm")) {
187
- return wasmFile;
188
- }
189
- return prefix + path;
178
+ ZXING_WASM_VERSION,
179
+ prepareZXingModule,
180
+ } from "barcode-detector/ponyfill";
181
+
182
+ // Override the locateFile function
183
+ prepareZXingModule({
184
+ overrides: {
185
+ locateFile: (path, prefix) => {
186
+ if (path.endsWith(".wasm")) {
187
+ return `https://unpkg.com/zxing-wasm@${ZXING_WASM_VERSION}/dist/reader/${path}`;
188
+ }
189
+ return prefix + path;
190
+ },
190
191
  },
191
192
  });
192
193
 
193
- const barcodeDetector = new BarcodeDetector();
194
-
195
- // detect barcodes
196
- // ...
194
+ // Now you can create a BarcodeDetector instance
195
+ const barcodeDetector = new BarcodeDetector({
196
+ formats: ["qr_code"],
197
+ });
197
198
  ```
198
199
 
199
- Alternatively, the `.wasm` file could be copied to your dist folder to be served from your local server, without incorporating it into the output as an extensive base64 data URL.
200
-
201
- It's noteworthy that you'll always want to choose the correct version of the `.wasm` file, so the APIs exported by it are exactly what the js code expects.
202
-
203
- For more information on how to use this function, you can check [the notes here](https://github.com/Sec-ant/zxing-wasm#notes) and [discussions here](https://github.com/Sec-ant/barcode-detector/issues/18) and [here](https://github.com/gruhn/vue-qrcode-reader/issues/354).
204
-
205
- This function is exported from all the subpaths, including the [side effects](#side-effects).
200
+ > [!Note]
201
+ > The `setZXingModuleOverrides` method is deprecated in favor of `prepareZXingModule`.
206
202
 
207
203
  ## API
208
204
 
209
205
  Please check the [spec](https://wicg.github.io/shape-detection-api/#barcode-detection-api), [MDN doc](https://developer.mozilla.org/docs/Web/API/Barcode_Detection_API) and [Chromium implementation](https://github.com/chromium/chromium/tree/main/third_party/blink/renderer/modules/shapedetection) for more information.
210
206
 
211
- ## Lifecycle Events
212
-
213
- The `BarcodeDetector` provided by this package also extends class `EventTarget` and provides 2 lifecycle events: `load` and `error`. You can use `addEventListener` and `removeEventListener` to register and remove callback hooks on these events.
214
-
215
- ### `load` Event
216
-
217
- The `load` event, which is a `CustomEvent`, will be dispatched on the successful instantiation of ZXing wasm module. For advanced usage, the instantiated module is passed as the `detail` parameter.
207
+ An example usage is as follows:
218
208
 
219
209
  ```ts
220
- import { BarcodeDetector } from "barcode-detector/pure";
210
+ import { BarcodeDetector } from "barcode-detector/ponyfill";
221
211
 
222
- const barcodeDetector = new BarcodeDetector();
223
-
224
- barcodeDetector.addEventListener("load", ({ detail }) => {
225
- console.log(detail); // zxing wasm module
226
- });
227
- ```
228
-
229
- ### `error` Event
230
-
231
- The `error` event, which is a `CustomEvent`, will be dispatched if the instantiation of ZXing wasm module is failed. An error is passed as the `detail` parameter.
232
-
233
- ```ts
234
- import { BarcodeDetector } from "barcode-detector/pure";
235
-
236
- const barcodeDetector = new BarcodeDetector();
237
-
238
- barcodeDetector.addEventListener("error", ({ detail }) => {
239
- console.log(detail); // an error
240
- });
241
- ```
242
-
243
- ## Example
244
-
245
- ```ts
246
- import { BarcodeDetector } from "barcode-detector/pure";
212
+ // check supported formats
213
+ const supportedFormats = await BarcodeDetector.getSupportedFormats();
247
214
 
248
215
  const barcodeDetector: BarcodeDetector = new BarcodeDetector({
216
+ // make sure the formats are supported
249
217
  formats: ["qr_code"],
250
218
  });
251
219
 
@@ -258,6 +226,4 @@ barcodeDetector.detect(imageFile).then(console.log);
258
226
 
259
227
  ## License
260
228
 
261
- The source code in this repository, as well as the build output, except for the parts listed below, is licensed under the [MIT license](./LICENSE).
262
-
263
- Test samples and resources are collected from [web-platform-tests/wpt](https://github.com/web-platform-tests/wpt), which is licensed under the [3-Clause BSD license](https://raw.githubusercontent.com/web-platform-tests/wpt/master/LICENSE.md).
229
+ The source code in this repository is licensed under the [MIT license](./LICENSE).
@@ -0,0 +1,21 @@
1
+ import { type BarcodeFormat, type ImageBitmapSourceWebCodecs, type ReadResultBarcodeFormat } from "./utils.js";
2
+ export type { BarcodeFormat } from "./utils.js";
3
+ export interface BarcodeDetectorOptions {
4
+ formats?: BarcodeFormat[];
5
+ }
6
+ export interface Point2D {
7
+ x: number;
8
+ y: number;
9
+ }
10
+ export interface DetectedBarcode {
11
+ boundingBox: DOMRectReadOnly;
12
+ rawValue: string;
13
+ format: ReadResultBarcodeFormat;
14
+ cornerPoints: [Point2D, Point2D, Point2D, Point2D];
15
+ }
16
+ export declare class BarcodeDetector {
17
+ #private;
18
+ constructor(barcodeDectorOptions?: BarcodeDetectorOptions);
19
+ static getSupportedFormats(): Promise<readonly BarcodeFormat[]>;
20
+ detect(image: ImageBitmapSourceWebCodecs): Promise<DetectedBarcode[]>;
21
+ }
@@ -1,2 +1,2 @@
1
- import "./side-effects.js";
2
- export * from "./pure.js";
1
+ import "./polyfill.js";
2
+ export * from "./ponyfill.js";
package/dist/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./side-effects.js");const e=require("./pure.js");exports.BarcodeDetector=e.BarcodeDetector;exports.setZXingModuleOverrides=e.setZXingModuleOverrides;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./polyfill.js");const e=require("./ponyfill.js");exports.BarcodeDetector=e.BarcodeDetector;exports.ZXING_CPP_COMMIT=e.ZXING_CPP_COMMIT;exports.ZXING_WASM_SHA256=e.ZXING_WASM_SHA256;exports.ZXING_WASM_VERSION=e.ZXING_WASM_VERSION;exports.prepareZXingModule=e.prepareZXingModule;exports.purgeZXingModule=e.purgeZXingModule;exports.setZXingModuleOverrides=e.setZXingModuleOverrides;
@@ -0,0 +1,8 @@
1
+ declare global {
2
+ var BarcodeDetector: typeof import("./core.js").BarcodeDetector;
3
+ type BarcodeDetector = import("./core.js").BarcodeDetector;
4
+ type BarcodeFormat = import("./core.js").BarcodeFormat;
5
+ type BarcodeDetectorOptions = import("./core.js").BarcodeDetectorOptions;
6
+ type DetectedBarcode = import("./core.js").DetectedBarcode;
7
+ }
8
+ export * from "./zxing-exported.js";
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./ponyfill.js");var r;(r=globalThis.BarcodeDetector)!=null||(globalThis.BarcodeDetector=e.BarcodeDetector);exports.ZXING_CPP_COMMIT=e.ZXING_CPP_COMMIT;exports.ZXING_WASM_SHA256=e.ZXING_WASM_SHA256;exports.ZXING_WASM_VERSION=e.ZXING_WASM_VERSION;exports.prepareZXingModule=e.prepareZXingModule;exports.purgeZXingModule=e.purgeZXingModule;exports.setZXingModuleOverrides=e.setZXingModuleOverrides;
@@ -0,0 +1,2 @@
1
+ export * from "./core.js";
2
+ export * from "./zxing-exported.js";
@@ -0,0 +1,2 @@
1
+ "use strict";var qe=o=>{throw TypeError(o)};var Ze=(o,f,p)=>f.has(o)||qe("Cannot "+p);var Ye=(o,f,p)=>(Ze(o,f,"read from private field"),p?p.call(o):f.get(o)),Qe=(o,f,p)=>f.has(o)?qe("Cannot add the same private member more than once"):f instanceof WeakSet?f.add(o):f.set(o,p),Je=(o,f,p,T)=>(Ze(o,f,"write to private field"),T?T.call(o,p):f.set(o,p),p);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Lt=[["Aztec","M"],["Codabar","L"],["Code39","L"],["Code93","L"],["Code128","L"],["DataBar","L"],["DataBarExpanded","L"],["DataMatrix","M"],["EAN-8","L"],["EAN-13","L"],["ITF","L"],["MaxiCode","M"],["PDF417","M"],["QRCode","M"],["UPC-A","L"],["UPC-E","L"],["MicroQRCode","M"],["rMQRCode","M"],["DXFilmEdge","L"],["DataBarLimited","L"]],Ut=Lt.map(([o])=>o),Za=Ut.filter((o,f)=>Lt[f][1]==="L"),Ya=Ut.filter((o,f)=>Lt[f][1]==="M");function re(o){switch(o){case"Linear-Codes":return Za.reduce((f,p)=>f|re(p),0);case"Matrix-Codes":return Ya.reduce((f,p)=>f|re(p),0);case"Any":return(1<<Lt.length)-1;case"None":return 0;default:return 1<<Ut.indexOf(o)}}function Qa(o){if(o===0)return"None";const f=31-Math.clz32(o);return Ut[f]}function Ja(o){return o.reduce((f,p)=>f|re(p),0)}const Ka=["LocalAverage","GlobalHistogram","FixedThreshold","BoolCast"];function to(o){return Ka.indexOf(o)}const Ke=["Unknown","ASCII","ISO8859_1","ISO8859_2","ISO8859_3","ISO8859_4","ISO8859_5","ISO8859_6","ISO8859_7","ISO8859_8","ISO8859_9","ISO8859_10","ISO8859_11","ISO8859_13","ISO8859_14","ISO8859_15","ISO8859_16","Cp437","Cp1250","Cp1251","Cp1252","Cp1256","Shift_JIS","Big5","GB2312","GB18030","EUC_JP","EUC_KR","UTF16BE","UTF16BE","UTF8","UTF16LE","UTF32BE","UTF32LE","BINARY"];function eo(o){return o==="UnicodeBig"?Ke.indexOf("UTF16BE"):Ke.indexOf(o)}const ro=["Text","Binary","Mixed","GS1","ISO15434","UnknownECI"];function no(o){return ro[o]}const ao=["Ignore","Read","Require"];function oo(o){return ao.indexOf(o)}const io=["Plain","ECI","HRI","Hex","Escaped"];function so(o){return io.indexOf(o)}const Bt={formats:[],tryHarder:!0,tryRotate:!0,tryInvert:!0,tryDownscale:!0,tryDenoise:!1,binarizer:"LocalAverage",isPure:!1,downscaleFactor:3,downscaleThreshold:500,minLineCount:2,maxNumberOfSymbols:255,tryCode39ExtendedMode:!0,returnErrors:!1,eanAddOnSymbol:"Ignore",textMode:"HRI",characterSet:"Unknown"};function tr(o){return{...o,formats:Ja(o.formats),binarizer:to(o.binarizer),eanAddOnSymbol:oo(o.eanAddOnSymbol),textMode:so(o.textMode),characterSet:eo(o.characterSet)}}function uo(o){return{...o,format:Qa(o.format),contentType:no(o.contentType),eccLevel:o.ecLevel}}const co="2.0.1",lo="7be9048e8176fba4f6ffa3dcf528282c6b0151a9",fo={locateFile:(o,f)=>{const p=o.match(/_(.+?)\.wasm$/);return p?`https://fastly.jsdelivr.net/npm/zxing-wasm@2.0.1/dist/${p[1]}/${o}`:f+o}},Rt=new WeakMap;function ho(o,f){return Object.is(o,f)||Object.keys(o).length===Object.keys(f).length&&Object.keys(o).every(p=>Object.prototype.hasOwnProperty.call(f,p)&&o[p]===f[p])}function rr(o,{overrides:f,equalityFn:p=ho,fireImmediately:T=!1}={}){var c;const[O,x]=(c=Rt.get(o))!=null?c:[fo],I=f!=null?f:O;let M;if(T){if(x&&(M=p(O,I)))return x;const L=o({...I});return Rt.set(o,[I,L]),L}(M!=null?M:p(O,I))||Rt.set(o,[I])}function po(o){Rt.delete(o)}async function yo(o,f,p=Bt){const T={...Bt,...p},c=await rr(o,{fireImmediately:!0});let O,x;if("size"in f){const{size:M}=f,L=new Uint8Array(await f.arrayBuffer());x=c._malloc(M),c.HEAPU8.set(L,x),O=c.readBarcodesFromImage(x,M,tr(T))}else{const{data:M,data:{byteLength:L},width:k,height:Z}=f;x=c._malloc(L),c.HEAPU8.set(M,x),O=c.readBarcodesFromPixmap(x,k,Z,tr(T))}c._free(x);const I=[];for(let M=0;M<O.size();++M)I.push(uo(O.get(M)));return I}({...Bt,formats:[...Bt.formats]});var ae=(()=>{var o,f=typeof document<"u"&&((o=document.currentScript)==null?void 0:o.tagName.toUpperCase())==="SCRIPT"?document.currentScript.src:void 0;return function(p={}){var T,c=p,O,x,I=new Promise((t,e)=>{O=t,x=e}),M=typeof window=="object",L=typeof Bun<"u",k=typeof WorkerGlobalScope<"u";typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&process.type!="renderer";var Z=Object.assign({},c),tt="./this.program",R="";function yt(t){return c.locateFile?c.locateFile(t,R):R+t}var ot,it;if(M||k||L){var st;k?R=self.location.href:typeof document<"u"&&((st=document.currentScript)===null||st===void 0?void 0:st.tagName.toUpperCase())==="SCRIPT"&&(R=document.currentScript.src),f&&(R=f),R.startsWith("blob:")?R="":R=R.substr(0,R.replace(/[?#].*/,"").lastIndexOf("/")+1),k&&(it=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),ot=async t=>{var e=await fetch(t,{credentials:"same-origin"});if(e.ok)return e.arrayBuffer();throw new Error(e.status+" : "+e.url)}}var dr=c.print||console.log.bind(console),et=c.printErr||console.error.bind(console);Object.assign(c,Z),Z=null,c.arguments&&c.arguments,c.thisProgram&&(tt=c.thisProgram);var vt=c.wasmBinary,mt,ie=!1,H,B,ut,gt,rt,P,se,ue;function ce(){var t=mt.buffer;c.HEAP8=H=new Int8Array(t),c.HEAP16=ut=new Int16Array(t),c.HEAPU8=B=new Uint8Array(t),c.HEAPU16=gt=new Uint16Array(t),c.HEAP32=rt=new Int32Array(t),c.HEAPU32=P=new Uint32Array(t),c.HEAPF32=se=new Float32Array(t),c.HEAPF64=ue=new Float64Array(t)}var le=[],fe=[],de=[];function hr(){if(c.preRun)for(typeof c.preRun=="function"&&(c.preRun=[c.preRun]);c.preRun.length;)vr(c.preRun.shift());kt(le)}function pr(){kt(fe)}function yr(){if(c.postRun)for(typeof c.postRun=="function"&&(c.postRun=[c.postRun]);c.postRun.length;)gr(c.postRun.shift());kt(de)}function vr(t){le.unshift(t)}function mr(t){fe.unshift(t)}function gr(t){de.unshift(t)}var Y=0,ct=null;function wr(t){var e;Y++,(e=c.monitorRunDependencies)===null||e===void 0||e.call(c,Y)}function $r(t){var e;if(Y--,(e=c.monitorRunDependencies)===null||e===void 0||e.call(c,Y),Y==0&&ct){var r=ct;ct=null,r()}}function Wt(t){var e;(e=c.onAbort)===null||e===void 0||e.call(c,t),t="Aborted("+t+")",et(t),ie=!0,t+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(t);throw x(r),r}var br="data:application/octet-stream;base64,",he=t=>t.startsWith(br);function Cr(){var t="zxing_reader.wasm";return he(t)?t:yt(t)}var wt;function Tr(t){if(t==wt&&vt)return new Uint8Array(vt);if(it)return it(t);throw"both async and sync fetching of the wasm failed"}async function Pr(t){if(!vt)try{var e=await ot(t);return new Uint8Array(e)}catch{}return Tr(t)}async function _r(t,e){try{var r=await Pr(t),n=await WebAssembly.instantiate(r,e);return n}catch(a){et(`failed to asynchronously prepare wasm: ${a}`),Wt(a)}}async function Er(t,e,r){if(!t&&typeof WebAssembly.instantiateStreaming=="function"&&!he(e)&&typeof fetch=="function")try{var n=fetch(e,{credentials:"same-origin"}),a=await WebAssembly.instantiateStreaming(n,r);return a}catch(i){et(`wasm streaming compile failed: ${i}`),et("falling back to ArrayBuffer instantiation")}return _r(e,r)}function Or(){return{a:ha}}async function Ar(){var t;function e(i,u){return E=i.exports,mt=E.xa,ce(),Te=E.Ba,mr(E.ya),$r(),E}wr();function r(i){e(i.instance)}var n=Or();if(c.instantiateWasm)try{return c.instantiateWasm(n,e)}catch(i){et(`Module.instantiateWasm callback failed with error: ${i}`),x(i)}(t=wt)!==null&&t!==void 0||(wt=Cr());try{var a=await Er(vt,wt,n);return r(a),a}catch(i){x(i);return}}var kt=t=>{for(;t.length>0;)t.shift()(c)};c.noExitRuntime;var m=t=>Re(t),g=()=>Be(),$t=[],bt=0,Sr=t=>{var e=new Ht(t);return e.get_caught()||(e.set_caught(!0),bt--),e.set_rethrown(!1),$t.push(e),Ue(t),Fe(t)},V=0,xr=()=>{v(0,0);var t=$t.pop();Le(t.excPtr),V=0};class Ht{constructor(e){this.excPtr=e,this.ptr=e-24}set_type(e){P[this.ptr+4>>2]=e}get_type(){return P[this.ptr+4>>2]}set_destructor(e){P[this.ptr+8>>2]=e}get_destructor(){return P[this.ptr+8>>2]}set_caught(e){e=e?1:0,H[this.ptr+12]=e}get_caught(){return H[this.ptr+12]!=0}set_rethrown(e){e=e?1:0,H[this.ptr+13]=e}get_rethrown(){return H[this.ptr+13]!=0}init(e,r){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(r)}set_adjusted_ptr(e){P[this.ptr+16>>2]=e}get_adjusted_ptr(){return P[this.ptr+16>>2]}}var Dr=t=>{throw V||(V=t),V},Ct=t=>Ie(t),Vt=t=>{var e=V;if(!e)return Ct(0),0;var r=new Ht(e);r.set_adjusted_ptr(e);var n=r.get_type();if(!n)return Ct(0),e;for(var a of t){if(a===0||a===n)break;var i=r.ptr+16;if(We(a,n,i))return Ct(a),e}return Ct(n),e},Mr=()=>Vt([]),jr=t=>Vt([t]),Fr=(t,e)=>Vt([t,e]),Ir=()=>{var t=$t.pop();t||Wt("no exception to throw");var e=t.excPtr;throw t.get_rethrown()||($t.push(t),t.set_rethrown(!0),t.set_caught(!1),bt++),V=e,V},Rr=(t,e,r)=>{var n=new Ht(t);throw n.init(e,r),V=t,bt++,V},Br=()=>bt,Lr=()=>Wt(""),Tt={},Nt=t=>{for(;t.length;){var e=t.pop(),r=t.pop();r(e)}};function lt(t){return this.fromWireType(P[t>>2])}var nt={},Q={},Pt={},pe,_t=t=>{throw new pe(t)},J=(t,e,r)=>{t.forEach(s=>Pt[s]=e);function n(s){var l=r(s);l.length!==t.length&&_t("Mismatched type converter count");for(var d=0;d<t.length;++d)W(t[d],l[d])}var a=new Array(e.length),i=[],u=0;e.forEach((s,l)=>{Q.hasOwnProperty(s)?a[l]=Q[s]:(i.push(s),nt.hasOwnProperty(s)||(nt[s]=[]),nt[s].push(()=>{a[l]=Q[s],++u,u===i.length&&n(a)}))}),i.length===0&&n(a)},Ur=t=>{var e=Tt[t];delete Tt[t];var r=e.rawConstructor,n=e.rawDestructor,a=e.fields,i=a.map(u=>u.getterReturnType).concat(a.map(u=>u.setterArgumentType));J([t],i,u=>{var s={};return a.forEach((l,d)=>{var h=l.fieldName,y=u[d],$=l.getter,C=l.getterContext,_=u[d+a.length],D=l.setter,A=l.setterContext;s[h]={read:S=>y.fromWireType($(C,S)),write:(S,K)=>{var F=[];D(A,S,_.toWireType(F,K)),Nt(F)}}}),[{name:e.name,fromWireType:l=>{var d={};for(var h in s)d[h]=s[h].read(l);return n(l),d},toWireType:(l,d)=>{for(var h in s)if(!(h in d))throw new TypeError(`Missing field: "${h}"`);var y=r();for(h in s)s[h].write(y,d[h]);return l!==null&&l.push(n,y),y},argPackAdvance:N,readValueFromPointer:lt,destructorFunction:n}]})},Wr=(t,e,r,n,a)=>{},kr=()=>{for(var t=new Array(256),e=0;e<256;++e)t[e]=String.fromCharCode(e);ye=t},ye,j=t=>{for(var e="",r=t;B[r];)e+=ye[B[r++]];return e},at,b=t=>{throw new at(t)};function Hr(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var n=e.name;if(t||b(`type "${n}" must have a positive integer typeid pointer`),Q.hasOwnProperty(t)){if(r.ignoreDuplicateRegistrations)return;b(`Cannot register type '${n}' twice`)}if(Q[t]=e,delete Pt[t],nt.hasOwnProperty(t)){var a=nt[t];delete nt[t],a.forEach(i=>i())}}function W(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return Hr(t,e,r)}var N=8,Vr=(t,e,r,n)=>{e=j(e),W(t,{name:e,fromWireType:function(a){return!!a},toWireType:function(a,i){return i?r:n},argPackAdvance:N,readValueFromPointer:function(a){return this.fromWireType(B[a])},destructorFunction:null})},Nr=t=>({count:t.count,deleteScheduled:t.deleteScheduled,preservePointerOnDelete:t.preservePointerOnDelete,ptr:t.ptr,ptrType:t.ptrType,smartPtr:t.smartPtr,smartPtrType:t.smartPtrType}),zt=t=>{function e(r){return r.$$.ptrType.registeredClass.name}b(e(t)+" instance already deleted")},Gt=!1,ve=t=>{},zr=t=>{t.smartPtr?t.smartPtrType.rawDestructor(t.smartPtr):t.ptrType.registeredClass.rawDestructor(t.ptr)},me=t=>{t.count.value-=1;var e=t.count.value===0;e&&zr(t)},ge=(t,e,r)=>{if(e===r)return t;if(r.baseClass===void 0)return null;var n=ge(t,e,r.baseClass);return n===null?null:r.downcast(n)},we={},Gr={},Xr=(t,e)=>{for(e===void 0&&b("ptr should not be undefined");t.baseClass;)e=t.upcast(e),t=t.baseClass;return e},qr=(t,e)=>(e=Xr(t,e),Gr[e]),Et=(t,e)=>{(!e.ptrType||!e.ptr)&&_t("makeClassHandle requires ptr and ptrType");var r=!!e.smartPtrType,n=!!e.smartPtr;return r!==n&&_t("Both smartPtrType and smartPtr must be specified"),e.count={value:1},ft(Object.create(t,{$$:{value:e,writable:!0}}))};function Zr(t){var e=this.getPointee(t);if(!e)return this.destructor(t),null;var r=qr(this.registeredClass,e);if(r!==void 0){if(r.$$.count.value===0)return r.$$.ptr=e,r.$$.smartPtr=t,r.clone();var n=r.clone();return this.destructor(t),n}function a(){return this.isSmartPointer?Et(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:e,smartPtrType:this,smartPtr:t}):Et(this.registeredClass.instancePrototype,{ptrType:this,ptr:t})}var i=this.registeredClass.getActualType(e),u=we[i];if(!u)return a.call(this);var s;this.isConst?s=u.constPointerType:s=u.pointerType;var l=ge(e,this.registeredClass,s.registeredClass);return l===null?a.call(this):this.isSmartPointer?Et(s.registeredClass.instancePrototype,{ptrType:s,ptr:l,smartPtrType:this,smartPtr:t}):Et(s.registeredClass.instancePrototype,{ptrType:s,ptr:l})}var ft=t=>typeof FinalizationRegistry>"u"?(ft=e=>e,t):(Gt=new FinalizationRegistry(e=>{me(e.$$)}),ft=e=>{var r=e.$$,n=!!r.smartPtr;if(n){var a={$$:r};Gt.register(e,a,e)}return e},ve=e=>Gt.unregister(e),ft(t)),Yr=()=>{Object.assign(Ot.prototype,{isAliasOf(t){if(!(this instanceof Ot)||!(t instanceof Ot))return!1;var e=this.$$.ptrType.registeredClass,r=this.$$.ptr;t.$$=t.$$;for(var n=t.$$.ptrType.registeredClass,a=t.$$.ptr;e.baseClass;)r=e.upcast(r),e=e.baseClass;for(;n.baseClass;)a=n.upcast(a),n=n.baseClass;return e===n&&r===a},clone(){if(this.$$.ptr||zt(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var t=ft(Object.create(Object.getPrototypeOf(this),{$$:{value:Nr(this.$$)}}));return t.$$.count.value+=1,t.$$.deleteScheduled=!1,t},delete(){this.$$.ptr||zt(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&b("Object already scheduled for deletion"),ve(this),me(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||zt(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&b("Object already scheduled for deletion"),this.$$.deleteScheduled=!0,this}})};function Ot(){}var At=(t,e)=>Object.defineProperty(e,"name",{value:t}),$e=(t,e,r)=>{if(t[e].overloadTable===void 0){var n=t[e];t[e]=function(){for(var a=arguments.length,i=new Array(a),u=0;u<a;u++)i[u]=arguments[u];return t[e].overloadTable.hasOwnProperty(i.length)||b(`Function '${r}' called with an invalid number of arguments (${i.length}) - expects one of (${t[e].overloadTable})!`),t[e].overloadTable[i.length].apply(this,i)},t[e].overloadTable=[],t[e].overloadTable[n.argCount]=n}},be=(t,e,r)=>{c.hasOwnProperty(t)?((r===void 0||c[t].overloadTable!==void 0&&c[t].overloadTable[r]!==void 0)&&b(`Cannot register public name '${t}' twice`),$e(c,t,t),c[t].overloadTable.hasOwnProperty(r)&&b(`Cannot register multiple overloads of a function with the same number of arguments (${r})!`),c[t].overloadTable[r]=e):(c[t]=e,c[t].argCount=r)},Qr=48,Jr=57,Kr=t=>{t=t.replace(/[^a-zA-Z0-9_]/g,"$");var e=t.charCodeAt(0);return e>=Qr&&e<=Jr?`_${t}`:t};function tn(t,e,r,n,a,i,u,s){this.name=t,this.constructor=e,this.instancePrototype=r,this.rawDestructor=n,this.baseClass=a,this.getActualType=i,this.upcast=u,this.downcast=s,this.pureVirtualFunctions=[]}var Xt=(t,e,r)=>{for(;e!==r;)e.upcast||b(`Expected null or instance of ${r.name}, got an instance of ${e.name}`),t=e.upcast(t),e=e.baseClass;return t};function en(t,e){if(e===null)return this.isReference&&b(`null is not a valid ${this.name}`),0;e.$$||b(`Cannot pass "${Jt(e)}" as a ${this.name}`),e.$$.ptr||b(`Cannot pass deleted object as a pointer of type ${this.name}`);var r=e.$$.ptrType.registeredClass,n=Xt(e.$$.ptr,r,this.registeredClass);return n}function rn(t,e){var r;if(e===null)return this.isReference&&b(`null is not a valid ${this.name}`),this.isSmartPointer?(r=this.rawConstructor(),t!==null&&t.push(this.rawDestructor,r),r):0;(!e||!e.$$)&&b(`Cannot pass "${Jt(e)}" as a ${this.name}`),e.$$.ptr||b(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&e.$$.ptrType.isConst&&b(`Cannot convert argument of type ${e.$$.smartPtrType?e.$$.smartPtrType.name:e.$$.ptrType.name} to parameter type ${this.name}`);var n=e.$$.ptrType.registeredClass;if(r=Xt(e.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(e.$$.smartPtr===void 0&&b("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:e.$$.smartPtrType===this?r=e.$$.smartPtr:b(`Cannot convert argument of type ${e.$$.smartPtrType?e.$$.smartPtrType.name:e.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:r=e.$$.smartPtr;break;case 2:if(e.$$.smartPtrType===this)r=e.$$.smartPtr;else{var a=e.clone();r=this.rawShare(r,G.toHandle(()=>a.delete())),t!==null&&t.push(this.rawDestructor,r)}break;default:b("Unsupporting sharing policy")}return r}function nn(t,e){if(e===null)return this.isReference&&b(`null is not a valid ${this.name}`),0;e.$$||b(`Cannot pass "${Jt(e)}" as a ${this.name}`),e.$$.ptr||b(`Cannot pass deleted object as a pointer of type ${this.name}`),e.$$.ptrType.isConst&&b(`Cannot convert argument of type ${e.$$.ptrType.name} to parameter type ${this.name}`);var r=e.$$.ptrType.registeredClass,n=Xt(e.$$.ptr,r,this.registeredClass);return n}var an=()=>{Object.assign(St.prototype,{getPointee(t){return this.rawGetPointee&&(t=this.rawGetPointee(t)),t},destructor(t){var e;(e=this.rawDestructor)===null||e===void 0||e.call(this,t)},argPackAdvance:N,readValueFromPointer:lt,fromWireType:Zr})};function St(t,e,r,n,a,i,u,s,l,d,h){this.name=t,this.registeredClass=e,this.isReference=r,this.isConst=n,this.isSmartPointer=a,this.pointeeType=i,this.sharingPolicy=u,this.rawGetPointee=s,this.rawConstructor=l,this.rawShare=d,this.rawDestructor=h,!a&&e.baseClass===void 0?n?(this.toWireType=en,this.destructorFunction=null):(this.toWireType=nn,this.destructorFunction=null):this.toWireType=rn}var Ce=(t,e,r)=>{c.hasOwnProperty(t)||_t("Replacing nonexistent public symbol"),c[t].overloadTable!==void 0&&r!==void 0?c[t].overloadTable[r]=e:(c[t]=e,c[t].argCount=r)},on=(t,e,r)=>{t=t.replace(/p/g,"i");var n=c["dynCall_"+t];return n(e,...r)},xt=[],Te,w=t=>{var e=xt[t];return e||(t>=xt.length&&(xt.length=t+1),xt[t]=e=Te.get(t)),e},sn=function(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];if(t.includes("j"))return on(t,e,r);var n=w(e)(...r);return n},un=(t,e)=>function(){for(var r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];return sn(t,e,n)},U=(t,e)=>{t=j(t);function r(){return t.includes("j")?un(t,e):w(e)}var n=r();return typeof n!="function"&&b(`unknown function pointer with signature ${t}: ${e}`),n},cn=(t,e)=>{var r=At(e,function(n){this.name=e,this.message=n;var a=new Error(n).stack;a!==void 0&&(this.stack=this.toString()+`
2
+ `+a.replace(/^Error(:[^\n]*)?\n/,""))});return r.prototype=Object.create(t.prototype),r.prototype.constructor=r,r.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},r},Pe,_e=t=>{var e=je(t),r=j(e);return X(e),r},Dt=(t,e)=>{var r=[],n={};function a(i){if(!n[i]&&!Q[i]){if(Pt[i]){Pt[i].forEach(a);return}r.push(i),n[i]=!0}}throw e.forEach(a),new Pe(`${t}: `+r.map(_e).join([", "]))},ln=(t,e,r,n,a,i,u,s,l,d,h,y,$)=>{h=j(h),i=U(a,i),s&&(s=U(u,s)),d&&(d=U(l,d)),$=U(y,$);var C=Kr(h);be(C,function(){Dt(`Cannot construct ${h} due to unbound types`,[n])}),J([t,e,r],n?[n]:[],_=>{_=_[0];var D,A;n?(D=_.registeredClass,A=D.instancePrototype):A=Ot.prototype;var S=At(h,function(){if(Object.getPrototypeOf(this)!==K)throw new at("Use 'new' to construct "+h);if(F.constructor_body===void 0)throw new at(h+" has no accessible constructor");for(var Ge=arguments.length,Ft=new Array(Ge),It=0;It<Ge;It++)Ft[It]=arguments[It];var Xe=F.constructor_body[Ft.length];if(Xe===void 0)throw new at(`Tried to invoke ctor of ${h} with invalid number of parameters (${Ft.length}) - expected (${Object.keys(F.constructor_body).toString()}) parameters instead!`);return Xe.apply(this,Ft)}),K=Object.create(A,{constructor:{value:S}});S.prototype=K;var F=new tn(h,S,K,$,D,i,s,d);if(F.baseClass){var q,jt;(jt=(q=F.baseClass).__derivedClasses)!==null&&jt!==void 0||(q.__derivedClasses=[]),F.baseClass.__derivedClasses.push(F)}var qa=new St(h,F,!0,!1,!1),Ne=new St(h+"*",F,!1,!1,!1),ze=new St(h+" const*",F,!1,!0,!1);return we[t]={pointerType:Ne,constPointerType:ze},Ce(C,S),[qa,Ne,ze]})},qt=(t,e)=>{for(var r=[],n=0;n<t;n++)r.push(P[e+n*4>>2]);return r};function fn(t){for(var e=1;e<t.length;++e)if(t[e]!==null&&t[e].destructorFunction===void 0)return!0;return!1}function Zt(t,e,r,n,a,i){var u=e.length;u<2&&b("argTypes array size mismatch! Must at least get return value and 'this' types!");var s=e[1]!==null&&r!==null,l=fn(e),d=e[0].name!=="void",h=u-2,y=new Array(h),$=[],C=[],_=function(){C.length=0;var D;$.length=s?2:1,$[0]=a,s&&(D=e[1].toWireType(C,this),$[1]=D);for(var A=0;A<h;++A)y[A]=e[A+2].toWireType(C,A<0||arguments.length<=A?void 0:arguments[A]),$.push(y[A]);var S=n(...$);function K(F){if(l)Nt(C);else for(var q=s?1:2;q<e.length;q++){var jt=q===1?D:y[q-2];e[q].destructorFunction!==null&&e[q].destructorFunction(jt)}if(d)return e[0].fromWireType(F)}return K(S)};return At(t,_)}var dn=(t,e,r,n,a,i)=>{var u=qt(e,r);a=U(n,a),J([],[t],s=>{s=s[0];var l=`constructor ${s.name}`;if(s.registeredClass.constructor_body===void 0&&(s.registeredClass.constructor_body=[]),s.registeredClass.constructor_body[e-1]!==void 0)throw new at(`Cannot register multiple constructors with identical number of parameters (${e-1}) for class '${s.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return s.registeredClass.constructor_body[e-1]=()=>{Dt(`Cannot construct ${s.name} due to unbound types`,u)},J([],u,d=>(d.splice(1,0,null),s.registeredClass.constructor_body[e-1]=Zt(l,d,null,a,i),[])),[]})},Ee=t=>{t=t.trim();const e=t.indexOf("(");return e!==-1?t.substr(0,e):t},hn=(t,e,r,n,a,i,u,s,l,d)=>{var h=qt(r,n);e=j(e),e=Ee(e),i=U(a,i),J([],[t],y=>{y=y[0];var $=`${y.name}.${e}`;e.startsWith("@@")&&(e=Symbol[e.substring(2)]),s&&y.registeredClass.pureVirtualFunctions.push(e);function C(){Dt(`Cannot call ${$} due to unbound types`,h)}var _=y.registeredClass.instancePrototype,D=_[e];return D===void 0||D.overloadTable===void 0&&D.className!==y.name&&D.argCount===r-2?(C.argCount=r-2,C.className=y.name,_[e]=C):($e(_,e,$),_[e].overloadTable[r-2]=C),J([],h,A=>{var S=Zt($,A,y,i,u);return _[e].overloadTable===void 0?(S.argCount=r-2,_[e]=S):_[e].overloadTable[r-2]=S,[]}),[]})},Yt=[],z=[],Qt=t=>{t>9&&--z[t+1]===0&&(z[t]=void 0,Yt.push(t))},pn=()=>z.length/2-5-Yt.length,yn=()=>{z.push(0,1,void 0,1,null,1,!0,1,!1,1),c.count_emval_handles=pn},G={toValue:t=>(t||b("Cannot use deleted val. handle = "+t),z[t]),toHandle:t=>{switch(t){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{const e=Yt.pop()||z.length;return z[e]=t,z[e+1]=1,e}}}},Oe={name:"emscripten::val",fromWireType:t=>{var e=G.toValue(t);return Qt(t),e},toWireType:(t,e)=>G.toHandle(e),argPackAdvance:N,readValueFromPointer:lt,destructorFunction:null},vn=t=>W(t,Oe),Jt=t=>{if(t===null)return"null";var e=typeof t;return e==="object"||e==="array"||e==="function"?t.toString():""+t},mn=(t,e)=>{switch(e){case 4:return function(r){return this.fromWireType(se[r>>2])};case 8:return function(r){return this.fromWireType(ue[r>>3])};default:throw new TypeError(`invalid float width (${e}): ${t}`)}},gn=(t,e,r)=>{e=j(e),W(t,{name:e,fromWireType:n=>n,toWireType:(n,a)=>a,argPackAdvance:N,readValueFromPointer:mn(e,r),destructorFunction:null})},wn=(t,e,r,n,a,i,u,s)=>{var l=qt(e,r);t=j(t),t=Ee(t),a=U(n,a),be(t,function(){Dt(`Cannot call ${t} due to unbound types`,l)},e-1),J([],l,d=>{var h=[d[0],null].concat(d.slice(1));return Ce(t,Zt(t,h,null,a,i),e-1),[]})},$n=(t,e,r)=>{switch(e){case 1:return r?n=>H[n]:n=>B[n];case 2:return r?n=>ut[n>>1]:n=>gt[n>>1];case 4:return r?n=>rt[n>>2]:n=>P[n>>2];default:throw new TypeError(`invalid integer width (${e}): ${t}`)}},bn=(t,e,r,n,a)=>{e=j(e);var i=h=>h;if(n===0){var u=32-8*r;i=h=>h<<u>>>u}var s=e.includes("unsigned"),l=(h,y)=>{},d;s?d=function(h,y){return l(y,this.name),y>>>0}:d=function(h,y){return l(y,this.name),y},W(t,{name:e,fromWireType:i,toWireType:d,argPackAdvance:N,readValueFromPointer:$n(e,r,n!==0),destructorFunction:null})},Cn=(t,e,r)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],a=n[e];function i(u){var s=P[u>>2],l=P[u+4>>2];return new a(H.buffer,l,s)}r=j(r),W(t,{name:r,fromWireType:i,argPackAdvance:N,readValueFromPointer:i},{ignoreDuplicateRegistrations:!0})},Tn=Object.assign({optional:!0},Oe),Pn=(t,e)=>{W(t,Tn)},_n=(t,e,r,n)=>{if(!(n>0))return 0;for(var a=r,i=r+n-1,u=0;u<t.length;++u){var s=t.charCodeAt(u);if(s>=55296&&s<=57343){var l=t.charCodeAt(++u);s=65536+((s&1023)<<10)|l&1023}if(s<=127){if(r>=i)break;e[r++]=s}else if(s<=2047){if(r+1>=i)break;e[r++]=192|s>>6,e[r++]=128|s&63}else if(s<=65535){if(r+2>=i)break;e[r++]=224|s>>12,e[r++]=128|s>>6&63,e[r++]=128|s&63}else{if(r+3>=i)break;e[r++]=240|s>>18,e[r++]=128|s>>12&63,e[r++]=128|s>>6&63,e[r++]=128|s&63}}return e[r]=0,r-a},dt=(t,e,r)=>_n(t,B,e,r),En=t=>{for(var e=0,r=0;r<t.length;++r){var n=t.charCodeAt(r);n<=127?e++:n<=2047?e+=2:n>=55296&&n<=57343?(e+=4,++r):e+=3}return e},Ae=typeof TextDecoder<"u"?new TextDecoder:void 0,Se=function(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:NaN;for(var n=e+r,a=e;t[a]&&!(a>=n);)++a;if(a-e>16&&t.buffer&&Ae)return Ae.decode(t.subarray(e,a));for(var i="";e<a;){var u=t[e++];if(!(u&128)){i+=String.fromCharCode(u);continue}var s=t[e++]&63;if((u&224)==192){i+=String.fromCharCode((u&31)<<6|s);continue}var l=t[e++]&63;if((u&240)==224?u=(u&15)<<12|s<<6|l:u=(u&7)<<18|s<<12|l<<6|t[e++]&63,u<65536)i+=String.fromCharCode(u);else{var d=u-65536;i+=String.fromCharCode(55296|d>>10,56320|d&1023)}}return i},On=(t,e)=>t?Se(B,t,e):"",An=(t,e)=>{e=j(e),W(t,{name:e,fromWireType(r){for(var n=P[r>>2],a=r+4,i,s,u=a,s=0;s<=n;++s){var l=a+s;if(s==n||B[l]==0){var d=l-u,h=On(u,d);i===void 0?i=h:(i+="\0",i+=h),u=l+1}}return X(r),i},toWireType(r,n){n instanceof ArrayBuffer&&(n=new Uint8Array(n));var a,i=typeof n=="string";i||n instanceof Uint8Array||n instanceof Uint8ClampedArray||n instanceof Int8Array||b("Cannot pass non-string to std::string"),i?a=En(n):a=n.length;var u=ee(4+a+1),s=u+4;if(P[u>>2]=a,i)dt(n,s,a+1);else if(i)for(var l=0;l<a;++l){var d=n.charCodeAt(l);d>255&&(X(s),b("String has UTF-16 code units that do not fit in 8 bits")),B[s+l]=d}else for(var l=0;l<a;++l)B[s+l]=n[l];return r!==null&&r.push(X,u),u},argPackAdvance:N,readValueFromPointer:lt,destructorFunction(r){X(r)}})},xe=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,Sn=(t,e)=>{for(var r=t,n=r>>1,a=n+e/2;!(n>=a)&&gt[n];)++n;if(r=n<<1,r-t>32&&xe)return xe.decode(B.subarray(t,r));for(var i="",u=0;!(u>=e/2);++u){var s=ut[t+u*2>>1];if(s==0)break;i+=String.fromCharCode(s)}return i},xn=(t,e,r)=>{var n;if((n=r)!==null&&n!==void 0||(r=2147483647),r<2)return 0;r-=2;for(var a=e,i=r<t.length*2?r/2:t.length,u=0;u<i;++u){var s=t.charCodeAt(u);ut[e>>1]=s,e+=2}return ut[e>>1]=0,e-a},Dn=t=>t.length*2,Mn=(t,e)=>{for(var r=0,n="";!(r>=e/4);){var a=rt[t+r*4>>2];if(a==0)break;if(++r,a>=65536){var i=a-65536;n+=String.fromCharCode(55296|i>>10,56320|i&1023)}else n+=String.fromCharCode(a)}return n},jn=(t,e,r)=>{var n;if((n=r)!==null&&n!==void 0||(r=2147483647),r<4)return 0;for(var a=e,i=a+r-4,u=0;u<t.length;++u){var s=t.charCodeAt(u);if(s>=55296&&s<=57343){var l=t.charCodeAt(++u);s=65536+((s&1023)<<10)|l&1023}if(rt[e>>2]=s,e+=4,e+4>i)break}return rt[e>>2]=0,e-a},Fn=t=>{for(var e=0,r=0;r<t.length;++r){var n=t.charCodeAt(r);n>=55296&&n<=57343&&++r,e+=4}return e},In=(t,e,r)=>{r=j(r);var n,a,i,u;e===2?(n=Sn,a=xn,u=Dn,i=s=>gt[s>>1]):e===4&&(n=Mn,a=jn,u=Fn,i=s=>P[s>>2]),W(t,{name:r,fromWireType:s=>{for(var l=P[s>>2],d,h=s+4,y=0;y<=l;++y){var $=s+4+y*e;if(y==l||i($)==0){var C=$-h,_=n(h,C);d===void 0?d=_:(d+="\0",d+=_),h=$+e}}return X(s),d},toWireType:(s,l)=>{typeof l!="string"&&b(`Cannot pass non-string to C++ string type ${r}`);var d=u(l),h=ee(4+d+e);return P[h>>2]=d/e,a(l,h+4,d+e),s!==null&&s.push(X,h),h},argPackAdvance:N,readValueFromPointer:lt,destructorFunction(s){X(s)}})},Rn=(t,e,r,n,a,i)=>{Tt[t]={name:j(e),rawConstructor:U(r,n),rawDestructor:U(a,i),fields:[]}},Bn=(t,e,r,n,a,i,u,s,l,d)=>{Tt[t].fields.push({fieldName:j(e),getterReturnType:r,getter:U(n,a),getterContext:i,setterArgumentType:u,setter:U(s,l),setterContext:d})},Ln=(t,e)=>{e=j(e),W(t,{isVoid:!0,name:e,argPackAdvance:0,fromWireType:()=>{},toWireType:(r,n)=>{}})},Un=(t,e,r)=>B.copyWithin(t,e,e+r),Kt=[],Wn=(t,e,r,n)=>(t=Kt[t],e=G.toValue(e),t(null,e,r,n)),kn={},Hn=t=>{var e=kn[t];return e===void 0?j(t):e},De=()=>{if(typeof globalThis=="object")return globalThis;function t(e){e.$$$embind_global$$$=e;var r=typeof $$$embind_global$$$=="object"&&e.$$$embind_global$$$==e;return r||delete e.$$$embind_global$$$,r}if(typeof $$$embind_global$$$=="object"||(typeof global=="object"&&t(global)?$$$embind_global$$$=global:typeof self=="object"&&t(self)&&($$$embind_global$$$=self),typeof $$$embind_global$$$=="object"))return $$$embind_global$$$;throw Error("unable to get global object.")},Vn=t=>t===0?G.toHandle(De()):(t=Hn(t),G.toHandle(De()[t])),Nn=t=>{var e=Kt.length;return Kt.push(t),e},Me=(t,e)=>{var r=Q[t];return r===void 0&&b(`${e} has unknown type ${_e(t)}`),r},zn=(t,e)=>{for(var r=new Array(t),n=0;n<t;++n)r[n]=Me(P[e+n*4>>2],"parameter "+n);return r},Gn=Reflect.construct,Xn=(t,e,r)=>{var n=[],a=t.toWireType(n,r);return n.length&&(P[e>>2]=G.toHandle(n)),a},qn=(t,e,r)=>{var n=zn(t,e),a=n.shift();t--;var i=new Array(t),u=(l,d,h,y)=>{for(var $=0,C=0;C<t;++C)i[C]=n[C].readValueFromPointer(y+$),$+=n[C].argPackAdvance;var _=r===1?Gn(d,i):d.apply(l,i);return Xn(a,h,_)},s=`methodCaller<(${n.map(l=>l.name).join(", ")}) => ${a.name}>`;return Nn(At(s,u))},Zn=t=>{t>9&&(z[t+1]+=1)},Yn=t=>{var e=G.toValue(t);Nt(e),Qt(t)},Qn=(t,e)=>{t=Me(t,"_emval_take_value");var r=t.readValueFromPointer(e);return G.toHandle(r)},Jn=(t,e,r,n)=>{var a=new Date().getFullYear(),i=new Date(a,0,1),u=new Date(a,6,1),s=i.getTimezoneOffset(),l=u.getTimezoneOffset(),d=Math.max(s,l);P[t>>2]=d*60,rt[e>>2]=+(s!=l);var h=C=>{var _=C>=0?"-":"+",D=Math.abs(C),A=String(Math.floor(D/60)).padStart(2,"0"),S=String(D%60).padStart(2,"0");return`UTC${_}${A}${S}`},y=h(s),$=h(l);l<s?(dt(y,r,17),dt($,n,17)):(dt(y,n,17),dt($,r,17))},Kn=()=>2147483648,ta=(t,e)=>Math.ceil(t/e)*e,ea=t=>{var e=mt.buffer,r=(t-e.byteLength+65535)/65536|0;try{return mt.grow(r),ce(),1}catch{}},ra=t=>{var e=B.length;t>>>=0;var r=Kn();if(t>r)return!1;for(var n=1;n<=4;n*=2){var a=e*(1+.2/n);a=Math.min(a,t+100663296);var i=Math.min(r,ta(Math.max(t,a),65536)),u=ea(i);if(u)return!0}return!1},te={},na=()=>tt||"./this.program",ht=()=>{if(!ht.strings){var t=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:t,_:na()};for(var r in te)te[r]===void 0?delete e[r]:e[r]=te[r];var n=[];for(var r in e)n.push(`${r}=${e[r]}`);ht.strings=n}return ht.strings},aa=(t,e)=>{for(var r=0;r<t.length;++r)H[e++]=t.charCodeAt(r);H[e]=0},oa=(t,e)=>{var r=0;return ht().forEach((n,a)=>{var i=e+r;P[t+a*4>>2]=i,aa(n,i),r+=n.length+1}),0},ia=(t,e)=>{var r=ht();P[t>>2]=r.length;var n=0;return r.forEach(a=>n+=a.length+1),P[e>>2]=n,0},sa=t=>52;function ua(t,e,r,n,a){return 70}var ca=[null,[],[]],la=(t,e)=>{var r=ca[t];e===0||e===10?((t===1?dr:et)(Se(r)),r.length=0):r.push(e)},fa=(t,e,r,n)=>{for(var a=0,i=0;i<r;i++){var u=P[e>>2],s=P[e+4>>2];e+=8;for(var l=0;l<s;l++)la(t,B[u+l]);a+=s}return P[n>>2]=a,0},da=t=>t;pe=c.InternalError=class extends Error{constructor(t){super(t),this.name="InternalError"}},kr(),at=c.BindingError=class extends Error{constructor(t){super(t),this.name="BindingError"}},Yr(),an(),Pe=c.UnboundTypeError=cn(Error,"UnboundTypeError"),yn();var ha={s:Sr,w:xr,a:Mr,j:jr,l:Fr,M:Ir,p:Rr,ca:Br,d:Dr,Z:Lr,sa:Ur,Y:Wr,na:Vr,qa:ln,pa:dn,D:hn,la:vn,Q:gn,R:wn,x:bn,t:Cn,ra:Pn,ma:An,N:In,J:Rn,ta:Bn,oa:Ln,fa:Un,U:Wn,ua:Qt,wa:Vn,_:qn,S:Zn,va:Yn,ka:Qn,$:Jn,da:ra,aa:oa,ba:ia,ea:sa,W:ua,P:fa,H:Fa,B:Ra,T:wa,O:Va,q:xa,b:ya,C:ja,ha:La,c:ma,ga:Ua,h:ga,i:Pa,r:_a,L:Ma,v:Oa,G:ka,I:Da,z:Ba,F:Na,X:Ga,V:Xa,k:ba,f:$a,e:va,g:pa,K:Ha,m:Ta,ia:Ia,o:Ea,u:Aa,ja:Sa,A:Wa,n:Ca,E:za,y:da},E;Ar();var je=t=>(je=E.za)(t),X=c._free=t=>(X=c._free=E.Aa)(t),ee=c._malloc=t=>(ee=c._malloc=E.Ca)(t),Fe=t=>(Fe=E.Da)(t),v=(t,e)=>(v=E.Ea)(t,e),Ie=t=>(Ie=E.Fa)(t),Re=t=>(Re=E.Ga)(t),Be=()=>(Be=E.Ha)(),Le=t=>(Le=E.Ia)(t),Ue=t=>(Ue=E.Ja)(t),We=(t,e,r)=>(We=E.Ka)(t,e,r);c.dynCall_viijii=(t,e,r,n,a,i,u)=>(c.dynCall_viijii=E.La)(t,e,r,n,a,i,u);var ke=c.dynCall_jiii=(t,e,r,n)=>(ke=c.dynCall_jiii=E.Ma)(t,e,r,n);c.dynCall_jiji=(t,e,r,n,a)=>(c.dynCall_jiji=E.Na)(t,e,r,n,a);var He=c.dynCall_jiiii=(t,e,r,n,a)=>(He=c.dynCall_jiiii=E.Oa)(t,e,r,n,a);c.dynCall_iiiiij=(t,e,r,n,a,i,u)=>(c.dynCall_iiiiij=E.Pa)(t,e,r,n,a,i,u),c.dynCall_iiiiijj=(t,e,r,n,a,i,u,s,l)=>(c.dynCall_iiiiijj=E.Qa)(t,e,r,n,a,i,u,s,l),c.dynCall_iiiiiijj=(t,e,r,n,a,i,u,s,l,d)=>(c.dynCall_iiiiiijj=E.Ra)(t,e,r,n,a,i,u,s,l,d);function pa(t,e,r,n){var a=g();try{w(t)(e,r,n)}catch(i){if(m(a),i!==i+0)throw i;v(1,0)}}function ya(t,e){var r=g();try{return w(t)(e)}catch(n){if(m(r),n!==n+0)throw n;v(1,0)}}function va(t,e,r){var n=g();try{w(t)(e,r)}catch(a){if(m(n),a!==a+0)throw a;v(1,0)}}function ma(t,e,r){var n=g();try{return w(t)(e,r)}catch(a){if(m(n),a!==a+0)throw a;v(1,0)}}function ga(t,e,r,n){var a=g();try{return w(t)(e,r,n)}catch(i){if(m(a),i!==i+0)throw i;v(1,0)}}function wa(t,e,r,n,a){var i=g();try{return w(t)(e,r,n,a)}catch(u){if(m(i),u!==u+0)throw u;v(1,0)}}function $a(t,e){var r=g();try{w(t)(e)}catch(n){if(m(r),n!==n+0)throw n;v(1,0)}}function ba(t){var e=g();try{w(t)()}catch(r){if(m(e),r!==r+0)throw r;v(1,0)}}function Ca(t,e,r,n,a,i,u,s,l,d,h){var y=g();try{w(t)(e,r,n,a,i,u,s,l,d,h)}catch($){if(m(y),$!==$+0)throw $;v(1,0)}}function Ta(t,e,r,n,a){var i=g();try{w(t)(e,r,n,a)}catch(u){if(m(i),u!==u+0)throw u;v(1,0)}}function Pa(t,e,r,n,a){var i=g();try{return w(t)(e,r,n,a)}catch(u){if(m(i),u!==u+0)throw u;v(1,0)}}function _a(t,e,r,n,a,i){var u=g();try{return w(t)(e,r,n,a,i)}catch(s){if(m(u),s!==s+0)throw s;v(1,0)}}function Ea(t,e,r,n,a,i){var u=g();try{w(t)(e,r,n,a,i)}catch(s){if(m(u),s!==s+0)throw s;v(1,0)}}function Oa(t,e,r,n,a,i,u){var s=g();try{return w(t)(e,r,n,a,i,u)}catch(l){if(m(s),l!==l+0)throw l;v(1,0)}}function Aa(t,e,r,n,a,i,u,s){var l=g();try{w(t)(e,r,n,a,i,u,s)}catch(d){if(m(l),d!==d+0)throw d;v(1,0)}}function Sa(t,e,r,n,a,i,u,s,l){var d=g();try{w(t)(e,r,n,a,i,u,s,l)}catch(h){if(m(d),h!==h+0)throw h;v(1,0)}}function xa(t){var e=g();try{return w(t)()}catch(r){if(m(e),r!==r+0)throw r;v(1,0)}}function Da(t,e,r,n,a,i,u,s,l){var d=g();try{return w(t)(e,r,n,a,i,u,s,l)}catch(h){if(m(d),h!==h+0)throw h;v(1,0)}}function Ma(t,e,r,n,a,i,u){var s=g();try{return w(t)(e,r,n,a,i,u)}catch(l){if(m(s),l!==l+0)throw l;v(1,0)}}function ja(t,e,r,n){var a=g();try{return w(t)(e,r,n)}catch(i){if(m(a),i!==i+0)throw i;v(1,0)}}function Fa(t,e,r,n){var a=g();try{return w(t)(e,r,n)}catch(i){if(m(a),i!==i+0)throw i;v(1,0)}}function Ia(t,e,r,n,a,i,u,s){var l=g();try{w(t)(e,r,n,a,i,u,s)}catch(d){if(m(l),d!==d+0)throw d;v(1,0)}}function Ra(t,e,r,n,a,i){var u=g();try{return w(t)(e,r,n,a,i)}catch(s){if(m(u),s!==s+0)throw s;v(1,0)}}function Ba(t,e,r,n,a,i,u,s,l,d){var h=g();try{return w(t)(e,r,n,a,i,u,s,l,d)}catch(y){if(m(h),y!==y+0)throw y;v(1,0)}}function La(t,e,r){var n=g();try{return w(t)(e,r)}catch(a){if(m(n),a!==a+0)throw a;v(1,0)}}function Ua(t,e,r,n,a){var i=g();try{return w(t)(e,r,n,a)}catch(u){if(m(i),u!==u+0)throw u;v(1,0)}}function Wa(t,e,r,n,a,i,u,s,l,d){var h=g();try{w(t)(e,r,n,a,i,u,s,l,d)}catch(y){if(m(h),y!==y+0)throw y;v(1,0)}}function ka(t,e,r,n,a,i,u,s){var l=g();try{return w(t)(e,r,n,a,i,u,s)}catch(d){if(m(l),d!==d+0)throw d;v(1,0)}}function Ha(t,e,r,n,a,i,u){var s=g();try{w(t)(e,r,n,a,i,u)}catch(l){if(m(s),l!==l+0)throw l;v(1,0)}}function Va(t,e,r,n){var a=g();try{return w(t)(e,r,n)}catch(i){if(m(a),i!==i+0)throw i;v(1,0)}}function Na(t,e,r,n,a,i,u,s,l,d,h,y){var $=g();try{return w(t)(e,r,n,a,i,u,s,l,d,h,y)}catch(C){if(m($),C!==C+0)throw C;v(1,0)}}function za(t,e,r,n,a,i,u,s,l,d,h,y,$,C,_,D){var A=g();try{w(t)(e,r,n,a,i,u,s,l,d,h,y,$,C,_,D)}catch(S){if(m(A),S!==S+0)throw S;v(1,0)}}function Ga(t,e,r,n){var a=g();try{return ke(t,e,r,n)}catch(i){if(m(a),i!==i+0)throw i;v(1,0)}}function Xa(t,e,r,n,a){var i=g();try{return He(t,e,r,n,a)}catch(u){if(m(i),u!==u+0)throw u;v(1,0)}}var Mt;ct=function t(){Mt||Ve(),Mt||(ct=t)};function Ve(){if(Y>0||(hr(),Y>0))return;function t(){var e;Mt||(Mt=!0,c.calledRun=!0,!ie&&(pr(),O(c),(e=c.onRuntimeInitialized)===null||e===void 0||e.call(c),yr()))}c.setStatus?(c.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>c.setStatus(""),1),t()},1)):t()}if(c.preInit)for(typeof c.preInit=="function"&&(c.preInit=[c.preInit]);c.preInit.length>0;)c.preInit.pop()();return Ve(),T=I,T}})();function oe(o){return rr(ae,o)}function vo(){return po(ae)}function mo(o){oe({overrides:o,equalityFn:Object.is,fireImmediately:!1})}async function go(o,f){return yo(ae,o,f)}const wo="fd885aab6c1040e991da4bdf2c3849d27b3c238c437a29c8d30efbe68e509bb1",nr=[["aztec","Aztec"],["code_128","Code128"],["code_39","Code39"],["code_93","Code93"],["codabar","Codabar"],["databar","DataBar"],["databar_expanded","DataBarExpanded"],["databar_limited","DataBarLimited"],["data_matrix","DataMatrix"],["dx_film_edge","DXFilmEdge"],["ean_13","EAN-13"],["ean_8","EAN-8"],["itf","ITF"],["maxi_code","MaxiCode"],["micro_qr_code","MicroQRCode"],["pdf417","PDF417"],["qr_code","QRCode"],["rm_qr_code","rMQRCode"],["upc_a","UPC-A"],["upc_e","UPC-E"],["linear_codes","Linear-Codes"],["matrix_codes","Matrix-Codes"],["any","Any"]],$o=[...nr,["unknown"]].map(o=>o[0]),ne=new Map(nr);function bo(o){for(const[f,p]of ne)if(o===p)return f;return"unknown"}function Co(o){if(ar(o))return{width:o.naturalWidth,height:o.naturalHeight};if(or(o))return{width:o.width.baseVal.value,height:o.height.baseVal.value};if(ir(o))return{width:o.videoWidth,height:o.videoHeight};if(ur(o))return{width:o.width,height:o.height};if(lr(o))return{width:o.displayWidth,height:o.displayHeight};if(sr(o))return{width:o.width,height:o.height};if(cr(o))return{width:o.width,height:o.height};throw new TypeError("The provided value is not of type '(Blob or HTMLCanvasElement or HTMLImageElement or HTMLVideoElement or ImageBitmap or ImageData or OffscreenCanvas or SVGImageElement or VideoFrame)'.")}function ar(o){var f,p;try{return o instanceof((p=(f=o==null?void 0:o.ownerDocument)==null?void 0:f.defaultView)==null?void 0:p.HTMLImageElement)}catch{return!1}}function or(o){var f,p;try{return o instanceof((p=(f=o==null?void 0:o.ownerDocument)==null?void 0:f.defaultView)==null?void 0:p.SVGImageElement)}catch{return!1}}function ir(o){var f,p;try{return o instanceof((p=(f=o==null?void 0:o.ownerDocument)==null?void 0:f.defaultView)==null?void 0:p.HTMLVideoElement)}catch{return!1}}function sr(o){var f,p;try{return o instanceof((p=(f=o==null?void 0:o.ownerDocument)==null?void 0:f.defaultView)==null?void 0:p.HTMLCanvasElement)}catch{return!1}}function ur(o){try{return o instanceof ImageBitmap||Object.prototype.toString.call(o)==="[object ImageBitmap]"}catch{return!1}}function cr(o){try{return o instanceof OffscreenCanvas||Object.prototype.toString.call(o)==="[object OffscreenCanvas]"}catch{return!1}}function lr(o){try{return o instanceof VideoFrame||Object.prototype.toString.call(o)==="[object VideoFrame]"}catch{return!1}}function To(o){try{return o instanceof Blob||Object.prototype.toString.call(o)==="[object Blob]"}catch{return!1}}function Po(o){try{return o instanceof ImageData||Object.prototype.toString.call(o)==="[object ImageData]"}catch{return!1}}function _o(o,f){try{const p=new OffscreenCanvas(o,f);if(p.getContext("2d")instanceof OffscreenCanvasRenderingContext2D)return p;throw void 0}catch{const p=document.createElement("canvas");return p.width=o,p.height=f,p}}async function fr(o){if(ar(o)&&!await So(o))throw new DOMException("Failed to load or decode HTMLImageElement.","InvalidStateError");if(or(o)&&!await xo(o))throw new DOMException("Failed to load or decode SVGImageElement.","InvalidStateError");if(lr(o)&&Do(o))throw new DOMException("VideoFrame is closed.","InvalidStateError");if(ir(o)&&(o.readyState===0||o.readyState===1))throw new DOMException("Invalid element or state.","InvalidStateError");if(ur(o)&&jo(o))throw new DOMException("The image source is detached.","InvalidStateError");const{width:f,height:p}=Co(o);if(f===0||p===0)return null;const c=_o(f,p).getContext("2d");c.drawImage(o,0,0);try{return c.getImageData(0,0,f,p)}catch{throw new DOMException("Source would taint origin.","SecurityError")}}async function Eo(o){let f;try{f=await createImageBitmap(o)}catch{try{if(globalThis.Image){f=new Image;let c="";try{c=URL.createObjectURL(o),f.src=c,await f.decode()}finally{URL.revokeObjectURL(c)}}else return o}catch{throw new DOMException("Failed to load or decode Blob.","InvalidStateError")}}return await fr(f)}function Oo(o){const{width:f,height:p}=o;if(f===0||p===0)return null;const T=o.getContext("2d");try{return T.getImageData(0,0,f,p)}catch{throw new DOMException("Source would taint origin.","SecurityError")}}async function Ao(o){if(To(o))return await Eo(o);if(Po(o)){if(Mo(o))throw new DOMException("The image data has been detached.","InvalidStateError");return o}return sr(o)||cr(o)?Oo(o):await fr(o)}async function So(o){try{return await o.decode(),!0}catch{return!1}}async function xo(o){var f;try{return await((f=o.decode)==null?void 0:f.call(o)),!0}catch{return!1}}function Do(o){return o.format===null}function Mo(o){return o.data.buffer.byteLength===0}function jo(o){return o.width===0&&o.height===0}function er(o,f){return Fo(o)?new DOMException(`${f}: ${o.message}`,o.name):Io(o)?new o.constructor(`${f}: ${o.message}`):new Error(`${f}: ${o}`)}function Fo(o){return o instanceof DOMException||Object.prototype.toString.call(o)==="[object DOMException]"}function Io(o){return o instanceof Error||Object.prototype.toString.call(o)==="[object Error]"}var pt;class Ro{constructor(f={}){Qe(this,pt);var p;try{const T=(p=f==null?void 0:f.formats)==null?void 0:p.filter(c=>c!=="unknown");if((T==null?void 0:T.length)===0)throw new TypeError("Hint option provided, but is empty.");for(const c of T!=null?T:[])if(!ne.has(c))throw new TypeError(`Failed to read the 'formats' property from 'BarcodeDetectorOptions': The provided value '${c}' is not a valid enum value of type BarcodeFormat.`);Je(this,pt,T!=null?T:[]),oe({fireImmediately:!0}).catch(()=>{})}catch(T){throw er(T,"Failed to construct 'BarcodeDetector'")}}static async getSupportedFormats(){return $o.filter(f=>f!=="unknown")}async detect(f){try{const p=await Ao(f);if(p===null)return[];let T;const c={tryCode39ExtendedMode:!1,textMode:"Plain",formats:Ye(this,pt).map(O=>ne.get(O))};try{T=await go(p,c)}catch(O){throw console.error(O),new DOMException("Barcode detection service unavailable.","NotSupportedError")}return T.map(O=>{const{topLeft:{x,y:I},topRight:{x:M,y:L},bottomLeft:{x:k,y:Z},bottomRight:{x:tt,y:R}}=O.position,yt=Math.min(x,M,k,tt),ot=Math.min(I,L,Z,R),it=Math.max(x,M,k,tt),st=Math.max(I,L,Z,R);return{boundingBox:new DOMRectReadOnly(yt,ot,it-yt,st-ot),rawValue:O.text,format:bo(O.format),cornerPoints:[{x,y:I},{x:M,y:L},{x:tt,y:R},{x:k,y:Z}]}})}catch(p){throw er(p,"Failed to execute 'detect' on 'BarcodeDetector'")}}}pt=new WeakMap;exports.BarcodeDetector=Ro;exports.ZXING_CPP_COMMIT=lo;exports.ZXING_WASM_SHA256=wo;exports.ZXING_WASM_VERSION=co;exports.prepareZXingModule=oe;exports.purgeZXingModule=vo;exports.setZXingModuleOverrides=mo;
@@ -1,8 +1,10 @@
1
1
  import type { ReadInputBarcodeFormat, ReadOutputBarcodeFormat } from "zxing-wasm/reader";
2
- export declare const BARCODE_FORMATS: ("aztec" | "code_128" | "code_39" | "code_93" | "codabar" | "databar" | "databar_expanded" | "databar_limited" | "data_matrix" | "dx_film_edge" | "ean_13" | "ean_8" | "itf" | "maxi_code" | "micro_qr_code" | "pdf417" | "qr_code" | "rm_qr_code" | "upc_a" | "upc_e" | "linear_codes" | "matrix_codes" | "unknown")[];
2
+ export type CanvasImageSourceWebCodecs = HTMLOrSVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas | VideoFrame;
3
+ export type ImageBitmapSourceWebCodecs = CanvasImageSourceWebCodecs | Blob | ImageData;
4
+ export declare const BARCODE_FORMATS: ("aztec" | "code_128" | "code_39" | "code_93" | "codabar" | "databar" | "databar_expanded" | "databar_limited" | "data_matrix" | "dx_film_edge" | "ean_13" | "ean_8" | "itf" | "maxi_code" | "micro_qr_code" | "pdf417" | "qr_code" | "rm_qr_code" | "upc_a" | "upc_e" | "linear_codes" | "matrix_codes" | "any" | "unknown")[];
3
5
  export type BarcodeFormat = (typeof BARCODE_FORMATS)[number];
4
- export type ReadResultBarcodeFormat = Exclude<BarcodeFormat, "linear_codes" | "matrix_codes">;
5
- export declare const formatMap: Map<"aztec" | "code_128" | "code_39" | "code_93" | "codabar" | "databar" | "databar_expanded" | "databar_limited" | "data_matrix" | "dx_film_edge" | "ean_13" | "ean_8" | "itf" | "maxi_code" | "micro_qr_code" | "pdf417" | "qr_code" | "rm_qr_code" | "upc_a" | "upc_e" | "linear_codes" | "matrix_codes" | "unknown", ReadInputBarcodeFormat>;
6
+ export type ReadResultBarcodeFormat = Exclude<BarcodeFormat, "linear_codes" | "matrix_codes" | "any">;
7
+ export declare const formatMap: Map<"aztec" | "code_128" | "code_39" | "code_93" | "codabar" | "databar" | "databar_expanded" | "databar_limited" | "data_matrix" | "dx_film_edge" | "ean_13" | "ean_8" | "itf" | "maxi_code" | "micro_qr_code" | "pdf417" | "qr_code" | "rm_qr_code" | "upc_a" | "upc_e" | "linear_codes" | "matrix_codes" | "any" | "unknown", ReadInputBarcodeFormat>;
6
8
  export declare function convertFormat(target: ReadOutputBarcodeFormat): ReadResultBarcodeFormat;
7
9
  export declare function isBlob(image: ImageBitmapSourceWebCodecs): image is Blob;
8
10
  export declare function getImageDataOrBlobFromImageBitmapSource(image: ImageBitmapSourceWebCodecs): Promise<ImageData | Blob | null>;
@@ -0,0 +1 @@
1
+ export { ZXING_WASM_VERSION, ZXING_WASM_SHA256, ZXING_CPP_COMMIT, prepareZXingModule, setZXingModuleOverrides, purgeZXingModule, } from "zxing-wasm/reader";
@@ -0,0 +1,21 @@
1
+ import { type BarcodeFormat, type ImageBitmapSourceWebCodecs, type ReadResultBarcodeFormat } from "./utils.js";
2
+ export type { BarcodeFormat } from "./utils.js";
3
+ export interface BarcodeDetectorOptions {
4
+ formats?: BarcodeFormat[];
5
+ }
6
+ export interface Point2D {
7
+ x: number;
8
+ y: number;
9
+ }
10
+ export interface DetectedBarcode {
11
+ boundingBox: DOMRectReadOnly;
12
+ rawValue: string;
13
+ format: ReadResultBarcodeFormat;
14
+ cornerPoints: [Point2D, Point2D, Point2D, Point2D];
15
+ }
16
+ export declare class BarcodeDetector {
17
+ #private;
18
+ constructor(barcodeDectorOptions?: BarcodeDetectorOptions);
19
+ static getSupportedFormats(): Promise<readonly BarcodeFormat[]>;
20
+ detect(image: ImageBitmapSourceWebCodecs): Promise<DetectedBarcode[]>;
21
+ }
@@ -1,2 +1,2 @@
1
- import "./side-effects.js";
2
- export * from "./pure.js";
1
+ import "./polyfill.js";
2
+ export * from "./ponyfill.js";
package/dist/es/index.js CHANGED
@@ -1,6 +1,11 @@
1
- import "./side-effects.js";
2
- import { BarcodeDetector as t, setZXingModuleOverrides as d } from "./pure.js";
1
+ import "./polyfill.js";
2
+ import { BarcodeDetector as M, ZXING_CPP_COMMIT as X, ZXING_WASM_SHA256 as Z, ZXING_WASM_VERSION as _, prepareZXingModule as d, purgeZXingModule as i, setZXingModuleOverrides as p } from "./ponyfill.js";
3
3
  export {
4
- t as BarcodeDetector,
5
- d as setZXingModuleOverrides
4
+ M as BarcodeDetector,
5
+ X as ZXING_CPP_COMMIT,
6
+ Z as ZXING_WASM_SHA256,
7
+ _ as ZXING_WASM_VERSION,
8
+ d as prepareZXingModule,
9
+ i as purgeZXingModule,
10
+ p as setZXingModuleOverrides
6
11
  };
@@ -0,0 +1,8 @@
1
+ declare global {
2
+ var BarcodeDetector: typeof import("./core.js").BarcodeDetector;
3
+ type BarcodeDetector = import("./core.js").BarcodeDetector;
4
+ type BarcodeFormat = import("./core.js").BarcodeFormat;
5
+ type BarcodeDetectorOptions = import("./core.js").BarcodeDetectorOptions;
6
+ type DetectedBarcode = import("./core.js").DetectedBarcode;
7
+ }
8
+ export * from "./zxing-exported.js";
@@ -0,0 +1,12 @@
1
+ import { BarcodeDetector as r } from "./ponyfill.js";
2
+ import { ZXING_CPP_COMMIT as d, ZXING_WASM_SHA256 as i, ZXING_WASM_VERSION as X, prepareZXingModule as Z, purgeZXingModule as _, setZXingModuleOverrides as g } from "./ponyfill.js";
3
+ var e;
4
+ (e = globalThis.BarcodeDetector) != null || (globalThis.BarcodeDetector = r);
5
+ export {
6
+ d as ZXING_CPP_COMMIT,
7
+ i as ZXING_WASM_SHA256,
8
+ X as ZXING_WASM_VERSION,
9
+ Z as prepareZXingModule,
10
+ _ as purgeZXingModule,
11
+ g as setZXingModuleOverrides
12
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./core.js";
2
+ export * from "./zxing-exported.js";