@exige/web-scanner-sdk 0.2.11 → 0.2.12

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/dist/react.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use client";
2
- import { m as e, o as t, p as n, s as r, v as i } from "./finder-BeINpYm3.js";
3
- import { createContext as a, useCallback as o, useContext as s, useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
4
- import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
2
+ import { k as e, m as t, o as n, p as r, s as i, v as a } from "./finder-B8yMQmN9.js";
3
+ import { createContext as o, useCallback as s, useContext as c, useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
4
+ import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
5
5
  //#region src/sdk/display-quad.ts
6
- function h(e) {
6
+ function g(e) {
7
7
  return [
8
8
  e.topLeft,
9
9
  e.topRight,
@@ -11,7 +11,7 @@ function h(e) {
11
11
  e.bottomLeft
12
12
  ];
13
13
  }
14
- function g(e) {
14
+ function _(e) {
15
15
  let [t, n, r, i] = e;
16
16
  return {
17
17
  topLeft: t,
@@ -38,8 +38,8 @@ function g(e) {
38
38
  }
39
39
  };
40
40
  }
41
- function _(e) {
42
- return g(h(e).map((e) => ({ ...e })));
41
+ function v(e) {
42
+ return _(g(e).map((e) => ({ ...e })));
43
43
  }
44
44
  var ee = class {
45
45
  current;
@@ -50,11 +50,11 @@ var ee = class {
50
50
  this.response = e.response ?? 14, this.snapDistance = e.snapDistance ?? .1;
51
51
  }
52
52
  setTarget(e, t, n) {
53
- let r = Math.max(1, Math.hypot(t, n)), i = !this.current || h(e).some((e, t) => {
54
- let n = h(this.current)[t];
53
+ let r = Math.max(1, Math.hypot(t, n)), i = !this.current || g(e).some((e, t) => {
54
+ let n = g(this.current)[t];
55
55
  return Math.hypot(e.x - n.x, e.y - n.y) / r > this.snapDistance;
56
56
  });
57
- return this.target = _(e), i && (this.current = _(e)), {
57
+ return this.target = v(e), i && (this.current = v(e)), {
58
58
  quad: this.current,
59
59
  snapped: i
60
60
  };
@@ -62,8 +62,8 @@ var ee = class {
62
62
  step(e) {
63
63
  if (!this.current || !this.target) return this.current;
64
64
  let t = 1 - Math.exp(-this.response * Math.max(0, e) / 1e3);
65
- return this.current = g(h(this.current).map((e, n) => {
66
- let r = h(this.target)[n];
65
+ return this.current = _(g(this.current).map((e, n) => {
66
+ let r = g(this.target)[n];
67
67
  return {
68
68
  x: e.x + (r.x - e.x) * t,
69
69
  y: e.y + (r.y - e.y) * t
@@ -76,13 +76,13 @@ var ee = class {
76
76
  getCurrent() {
77
77
  return this.current;
78
78
  }
79
- }, te = a(null);
79
+ }, y = o(null);
80
80
  //#endregion
81
81
  //#region src/react/context.tsx
82
- function v(e) {
82
+ function b(e) {
83
83
  e?.startsWith("blob:") && URL.revokeObjectURL(e);
84
84
  }
85
- function ne(e) {
85
+ function te(e) {
86
86
  try {
87
87
  let t = e.toDataURL("image/jpeg", .92);
88
88
  return t.startsWith("data:image/") ? t : void 0;
@@ -90,123 +90,127 @@ function ne(e) {
90
90
  return;
91
91
  }
92
92
  }
93
- function y({ open: n, autoCapture: a = "defaultOn", torch: s = "defaultOff", onCapture: f, onCancel: m, onError: h, onSettings: g, onFinderStatus: _, modelUrl: y, ortWasmPaths: b, detectionIntervalMs: x, apiRef: S, children: C }) {
94
- let w = u(void 0), T = u(void 0), E = u(void 0), D = u(void 0), O = u({}), k = u(new ee()), A = u(!1), j = u({
95
- onCapture: f,
96
- onCancel: m,
97
- onError: h,
98
- onSettings: g,
99
- onFinderStatus: _
100
- }), M = u(null), [N, P] = d(null), [re, F] = d("starting"), [I, L] = d(), [ie, R] = d(), [ae, oe] = d({
93
+ function x({ open: r, autoCapture: o = "defaultOn", torch: c = "defaultOff", onCapture: p, onCancel: h, onError: g, onSettings: _, onFinderStatus: v, modelUrl: x, ortWasmPaths: S, detectionIntervalMs: C, apiRef: w, children: T }) {
94
+ let E = d(void 0), D = d(void 0), O = d(void 0), k = d(void 0), A = d({}), j = d(new ee()), M = d(!1), N = d({
95
+ onCapture: p,
96
+ onCancel: h,
97
+ onError: g,
98
+ onSettings: _,
99
+ onFinderStatus: v
100
+ }), P = d(null), [F, I] = f(null), [ne, L] = f("starting"), [R, z] = f(), [re, B] = f(), [ie, ae] = f({
101
101
  width: 1,
102
102
  height: 1
103
- }), [se, ce] = d(), [le, z] = d(), [ue, B] = d(""), [V, de] = d(0), [fe, H] = d(), [pe, U] = d(), [me, W] = d("idle"), [he, G] = d(), K = u(void 0), q = o(() => {
104
- v(K.current), K.current = void 0, G(void 0);
105
- }, []), J = o((e, t) => {
106
- let n = ne(e);
107
- v(K.current), K.current = n, G(n), t?.pause();
103
+ }), [oe, se] = f(), [ce, V] = f(), [le, H] = f(""), [U, ue] = f(0), [de, W] = f(), [fe, G] = f(), [pe, K] = f("idle"), [me, q] = f(), J = d(void 0), [he, ge] = f({
104
+ downloading: !1,
105
+ loaded: 0,
106
+ total: null
107
+ }), Y = s(() => {
108
+ b(J.current), J.current = void 0, q(void 0);
109
+ }, []), X = s((e, t) => {
110
+ let n = te(e);
111
+ b(J.current), J.current = n, q(n), t?.pause();
108
112
  }, []);
109
- c(() => {
110
- j.current = {
111
- onCapture: f,
112
- onCancel: m,
113
- onError: h,
114
- onSettings: g,
115
- onFinderStatus: _
113
+ l(() => {
114
+ N.current = {
115
+ onCapture: p,
116
+ onCancel: h,
117
+ onError: g,
118
+ onSettings: _,
119
+ onFinderStatus: v
116
120
  };
117
121
  }, [
118
- f,
119
- m,
122
+ p,
120
123
  h,
121
124
  g,
122
- _
123
- ]);
124
- let ge = o((e) => {
125
- P(e);
125
+ _,
126
+ v
127
+ ]), l(() => e(ge), []);
128
+ let _e = s((e) => {
129
+ I(e);
126
130
  }, []);
127
- c(() => {
128
- if (!n || !N) return;
131
+ l(() => {
132
+ if (!r || !F) return;
129
133
  let e = () => {
130
- let e = N.getBoundingClientRect();
131
- oe({
134
+ let e = F.getBoundingClientRect();
135
+ ae({
132
136
  width: e.width,
133
137
  height: e.height
134
138
  });
135
139
  };
136
140
  if (e(), typeof ResizeObserver > "u") return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
137
141
  let t = new ResizeObserver(e);
138
- return t.observe(N), () => t.disconnect();
139
- }, [n, N]), c(() => {
140
- if (!n) return;
142
+ return t.observe(F), () => t.disconnect();
143
+ }, [r, F]), l(() => {
144
+ if (!r) return;
141
145
  let e = window.setInterval(() => {
142
- let e = w.current?.getDiagnostics();
143
- e && H(e);
146
+ let e = E.current?.getDiagnostics();
147
+ e && W(e);
144
148
  }, 500);
145
149
  return () => window.clearInterval(e);
146
- }, [n, V]), c(() => {
147
- if (!n) return;
148
- let e = 0, t = performance.now(), r = (n) => {
149
- let i = k.current.step(n - t);
150
- t = n, i && R(i), e = requestAnimationFrame(r);
150
+ }, [r, U]), l(() => {
151
+ if (!r) return;
152
+ let e = 0, t = performance.now(), n = (r) => {
153
+ let i = j.current.step(r - t);
154
+ t = r, i && B(i), e = requestAnimationFrame(n);
151
155
  };
152
- return e = requestAnimationFrame(r), () => cancelAnimationFrame(e);
153
- }, [n]), c(() => {
154
- if (!n || !N) return;
156
+ return e = requestAnimationFrame(n), () => cancelAnimationFrame(e);
157
+ }, [r]), l(() => {
158
+ if (!r || !F) return;
155
159
  let e = !1, t = () => {
156
- T.current?.stop(), T.current = void 0, w.current?.stop(), w.current = void 0, D.current = void 0, E.current = void 0, O.current = {}, q();
160
+ D.current?.stop(), D.current = void 0, E.current?.stop(), E.current = void 0, k.current = void 0, O.current = void 0, A.current = {}, Y();
157
161
  };
158
162
  return (async () => {
159
- t(), A.current = !1, F("starting"), B(""), L(void 0), z(void 0), U(void 0), W("idle"), q();
163
+ t(), M.current = !1, L("starting"), H(""), z(void 0), V(void 0), G(void 0), K("idle"), Y();
160
164
  try {
161
- let t = await i(N, { torch: s });
165
+ let t = await a(F, { torch: c });
162
166
  if (e) {
163
167
  t.stop();
164
168
  return;
165
169
  }
166
- w.current = t;
170
+ E.current = t;
167
171
  let n = t.getSettings();
168
- ce(n), j.current.onSettings?.(n), console.info("[ScannerProvider] camera settings", n), T.current = await r({
169
- source: N,
170
- autoCapture: a,
171
- intervalMs: x,
172
+ se(n), N.current.onSettings?.(n), console.info("[ScannerProvider] camera settings", n), D.current = await i({
173
+ source: F,
174
+ autoCapture: o,
175
+ intervalMs: C,
172
176
  detection: {
173
- modelUrl: y,
174
- ortWasmPaths: b
177
+ modelUrl: x,
178
+ ortWasmPaths: S
175
179
  },
176
180
  onStatus: (e) => {
177
- if (E.current = e, L(e), j.current.onFinderStatus?.(e), e.quad && e.sourceWidth && e.sourceHeight) {
178
- let t = k.current.setTarget(e.quad, e.sourceWidth, e.sourceHeight);
179
- R(t.quad);
180
- } else k.current.clear(), R(void 0);
181
- e.state !== "captured" && !A.current && F("ready");
181
+ if (O.current = e, z(e), N.current.onFinderStatus?.(e), e.quad && e.sourceWidth && e.sourceHeight) {
182
+ let t = j.current.setTarget(e.quad, e.sourceWidth, e.sourceHeight);
183
+ B(t.quad);
184
+ } else j.current.clear(), B(void 0);
185
+ e.state !== "captured" && !M.current && L("ready");
182
186
  },
183
187
  captureFrame: async () => {
184
- F("capturing"), O.current = {
185
- quad: k.current.getCurrent(),
186
- sourceWidth: E.current?.sourceWidth,
187
- sourceHeight: E.current?.sourceHeight
188
+ L("capturing"), A.current = {
189
+ quad: j.current.getCurrent(),
190
+ sourceWidth: O.current?.sourceWidth,
191
+ sourceHeight: O.current?.sourceHeight
188
192
  };
189
193
  let e = await t.capturePhoto();
190
- if (D.current = e, z(e.method), U(e.diagnostics), H(e.diagnostics), e.luminance <= 10) throw Error(`The captured frame was blank (luminance ${e.luminance.toFixed(1)} via ${e.method}). Keep the scanner visible while capturing and retake.`);
191
- return J(e.frame, N), F("captured"), e.frame;
194
+ if (k.current = e, V(e.method), G(e.diagnostics), W(e.diagnostics), e.luminance <= 10) throw Error(`The captured frame was blank (luminance ${e.luminance.toFixed(1)} via ${e.method}). Keep the scanner visible while capturing and retake.`);
195
+ return X(e.frame, F), L("captured"), e.frame;
192
196
  },
193
197
  onCaptureError: (e) => {
194
- A.current = !0, F("error"), B(e.message);
195
- let t = w.current?.getDiagnostics();
196
- t && H(t), j.current.onError?.(e);
198
+ M.current = !0, L("error"), H(e.message);
199
+ let t = E.current?.getDiagnostics();
200
+ t && W(t), N.current.onError?.(e);
197
201
  },
198
202
  onCapture: async (e) => {
199
- let n = D.current;
200
- await new Promise((e) => window.setTimeout(e, 140)), await j.current.onCapture({
203
+ let n = k.current;
204
+ await new Promise((e) => window.setTimeout(e, 140)), await N.current.onCapture({
201
205
  ...e,
202
206
  method: n?.method ?? "video-frame",
203
207
  settings: n?.settings ?? t.getSettings(),
204
208
  fallbackReason: n?.fallbackReason,
205
209
  luminance: n?.luminance,
206
210
  diagnostics: n?.diagnostics,
207
- displayedQuad: O.current.quad,
208
- displaySourceWidth: O.current.sourceWidth,
209
- displaySourceHeight: O.current.sourceHeight
211
+ displayedQuad: A.current.quad,
212
+ displaySourceWidth: A.current.sourceWidth,
213
+ displaySourceHeight: A.current.sourceHeight
210
214
  });
211
215
  }
212
216
  });
@@ -214,70 +218,71 @@ function y({ open: n, autoCapture: a = "defaultOn", torch: s = "defaultOff", onC
214
218
  if (e) return;
215
219
  t();
216
220
  let r = n instanceof Error ? n : /* @__PURE__ */ Error("Camera access failed.");
217
- B(r.message), F("error"), j.current.onError?.(r);
221
+ H(r.message), L("error"), N.current.onError?.(r);
218
222
  }
219
223
  })(), () => {
220
224
  e = !0, t();
221
225
  };
222
226
  }, [
223
- n,
224
- N,
225
- a,
226
- s,
227
- y,
228
- b,
227
+ r,
228
+ F,
229
+ o,
230
+ c,
229
231
  x,
230
- V,
231
- q,
232
- J
232
+ S,
233
+ C,
234
+ U,
235
+ Y,
236
+ X
233
237
  ]);
234
- let Y = {
235
- open: n,
236
- phase: re,
237
- autoCapture: a,
238
- finderStatus: I,
239
- displayQuad: ie,
240
- previewSize: ae,
241
- settings: se,
242
- captureMethod: le,
243
- error: ue,
244
- diagnostics: fe,
245
- shutterDiagnostics: pe,
246
- copyState: me,
247
- guidanceHint: I ? t(I.guidance, I.lighting) : void 0,
248
- detectorStatus: I?.modelStatus === "failed" ? "ML failed" : I?.detector === "ml" ? `ML ${I.modelProvider ?? ""}`.trim() : "ML loading",
249
- frozenPreviewUrl: he
238
+ let Z = {
239
+ open: r,
240
+ phase: ne,
241
+ autoCapture: o,
242
+ finderStatus: R,
243
+ displayQuad: re,
244
+ previewSize: ie,
245
+ settings: oe,
246
+ captureMethod: ce,
247
+ error: le,
248
+ diagnostics: de,
249
+ shutterDiagnostics: fe,
250
+ copyState: pe,
251
+ guidanceHint: R ? n(R.guidance, R.lighting) : void 0,
252
+ detectorStatus: R?.modelStatus === "failed" ? "ML failed" : R?.detector === "ml" ? `ML ${R.modelProvider ?? ""}`.trim() : "ML loading",
253
+ modelDownload: he,
254
+ frozenPreviewUrl: me
250
255
  };
251
- c(() => {
252
- M.current = Y;
256
+ l(() => {
257
+ P.current = Z;
253
258
  });
254
- let X = o(() => {
255
- j.current.onCancel();
256
- }, []), Z = o(async () => {
259
+ let ve = s(() => {
260
+ N.current.onCancel();
261
+ }, []), ye = s(async () => {
257
262
  try {
258
- await T.current?.capture();
263
+ await D.current?.capture();
259
264
  } catch (e) {
260
265
  let t = e instanceof Error ? e : /* @__PURE__ */ Error("Could not capture the camera frame.");
261
- A.current = !0, B(t.message);
262
- let n = w.current?.getDiagnostics();
263
- n && H(n), D.current?.diagnostics && U(D.current.diagnostics), F("error"), j.current.onError?.(t);
266
+ M.current = !0, H(t.message);
267
+ let n = E.current?.getDiagnostics();
268
+ n && W(n), k.current?.diagnostics && G(k.current.diagnostics), L("error"), N.current.onError?.(t);
264
269
  }
265
- }, []), Q = o(() => {
266
- A.current = !1, B(""), U(void 0), W("idle"), q();
267
- let e = w.current;
268
- N?.paused && N.play(), F(e ? "ready" : "starting"), e || de((e) => e + 1);
269
- }, [q, N]), _e = o(async (e) => {
270
- let t = w.current;
271
- t && (await t.setTorch(e), H(t.getDiagnostics()));
272
- }, []), ve = o((e) => {
273
- T.current?.setAutoCapture(e);
274
- }, []), ye = o(async () => {
275
- let t = M.current, n = w.current?.getDiagnostics() ?? t.diagnostics, r = t.finderStatus, i = e({
276
- error: t.error || void 0,
277
- captureMethod: t.captureMethod,
278
- luminance: D.current?.luminance,
279
- fallbackReason: D.current?.fallbackReason,
280
- shutter: t.shutterDiagnostics ?? D.current?.diagnostics,
270
+ }, []), be = s(() => {
271
+ M.current = !1, H(""), G(void 0), K("idle"), Y();
272
+ let e = E.current;
273
+ F?.paused && F.play(), L(e ? "ready" : "starting"), e || ue((e) => e + 1);
274
+ }, [Y, F]), xe = s(async (e) => {
275
+ let t = E.current;
276
+ t && (await t.setTorch(e), W(t.getDiagnostics()));
277
+ }, []), Se = s((e) => {
278
+ D.current?.setAutoCapture(e);
279
+ }, []), Ce = s(async () => {
280
+ let e = P.current, n = E.current?.getDiagnostics() ?? e.diagnostics, r = e.finderStatus, i = t({
281
+ error: e.error || void 0,
282
+ captureMethod: e.captureMethod,
283
+ luminance: k.current?.luminance,
284
+ fallbackReason: k.current?.fallbackReason,
285
+ shutter: e.shutterDiagnostics ?? k.current?.diagnostics,
281
286
  live: n,
282
287
  finder: r ? {
283
288
  state: r.state,
@@ -298,55 +303,55 @@ function y({ open: n, autoCapture: a = "defaultOn", torch: s = "defaultOff", onC
298
303
  let t = document.execCommand("copy");
299
304
  if (e.remove(), !t) throw Error("Clipboard copy is unavailable.");
300
305
  }
301
- W("copied");
306
+ K("copied");
302
307
  } catch {
303
- W("failed");
308
+ K("failed");
304
309
  }
305
- }, []), be = o(() => M.current, []), $ = l(() => ({
306
- capture: Z,
307
- cancel: X,
308
- retry: Q,
309
- setTorch: _e,
310
- setAutoCapture: ve,
311
- copyReport: ye,
312
- getState: be
310
+ }, []), Q = s(() => P.current, []), $ = u(() => ({
311
+ capture: ye,
312
+ cancel: ve,
313
+ retry: be,
314
+ setTorch: xe,
315
+ setAutoCapture: Se,
316
+ copyReport: Ce,
317
+ getState: Q
313
318
  }), [
314
- Z,
315
- X,
316
- Q,
317
- _e,
318
- ve,
319
319
  ye,
320
- be
320
+ ve,
321
+ be,
322
+ xe,
323
+ Se,
324
+ Ce,
325
+ Q
321
326
  ]);
322
- c(() => {
323
- if (S) return S.current = $, () => {
324
- S.current = null;
327
+ l(() => {
328
+ if (w) return w.current = $, () => {
329
+ w.current = null;
325
330
  };
326
- }, [$, S]);
327
- let xe = {
328
- ...Y,
331
+ }, [$, w]);
332
+ let we = {
333
+ ...Z,
329
334
  ...$,
330
- bindPreview: ge
335
+ bindPreview: _e
331
336
  };
332
- return /* @__PURE__ */ p(te.Provider, {
333
- value: xe,
334
- children: C
337
+ return /* @__PURE__ */ m(y.Provider, {
338
+ value: we,
339
+ children: T
335
340
  });
336
341
  }
337
342
  //#endregion
338
343
  //#region src/react/hooks.ts
339
- function b() {
340
- return u(null);
344
+ function S() {
345
+ return d(null);
341
346
  }
342
- function x() {
343
- let e = s(te);
347
+ function C() {
348
+ let e = c(y);
344
349
  if (!e) throw Error("useScanner must be used within ScannerProvider.");
345
350
  return e;
346
351
  }
347
352
  //#endregion
348
353
  //#region src/live-overlay-geometry.ts
349
- function S(e, t, n, r, i) {
354
+ function w(e, t, n, r, i) {
350
355
  let a = Math.max(1, e), o = Math.max(1, t), s = Math.max(1, n), c = Math.max(1, r), l = s / a, u = c / o, d = i === "cover" ? Math.max(l, u) : Math.min(l, u), f = (s - a * d) / 2, p = (c - o * d) / 2;
351
356
  if (i === "contain") return {
352
357
  viewBox: `0 0 ${a} ${o}`,
@@ -366,10 +371,10 @@ function S(e, t, n, r, i) {
366
371
  }
367
372
  //#endregion
368
373
  //#region src/components/ModelDownloadRing.tsx
369
- function C({ snapshot: e }) {
374
+ function T({ snapshot: e }) {
370
375
  if (!e.downloading) return null;
371
376
  let t = e.total && e.total > 0 ? Math.min(1, e.loaded / e.total) : null, n = t === null ? null : Math.round(t * 100), r = 2 * Math.PI * 28;
372
- return /* @__PURE__ */ m("div", {
377
+ return /* @__PURE__ */ h("div", {
373
378
  className: `model-download-ring${t === null ? " is-indeterminate" : ""}`,
374
379
  role: "progressbar",
375
380
  "aria-label": "Model download",
@@ -378,15 +383,15 @@ function C({ snapshot: e }) {
378
383
  "aria-valuenow": n ?? void 0,
379
384
  "data-loaded": e.loaded,
380
385
  "data-total": e.total ?? "",
381
- children: [/* @__PURE__ */ m("svg", {
386
+ children: [/* @__PURE__ */ h("svg", {
382
387
  viewBox: "0 0 72 72",
383
388
  "aria-hidden": "true",
384
- children: [/* @__PURE__ */ p("circle", {
389
+ children: [/* @__PURE__ */ m("circle", {
385
390
  className: "track",
386
391
  cx: "36",
387
392
  cy: "36",
388
393
  r: 28
389
- }), /* @__PURE__ */ p("circle", {
394
+ }), /* @__PURE__ */ m("circle", {
390
395
  className: "value",
391
396
  cx: "36",
392
397
  cy: "36",
@@ -394,15 +399,15 @@ function C({ snapshot: e }) {
394
399
  strokeDasharray: t === null ? void 0 : `${r} ${r}`,
395
400
  strokeDashoffset: t === null ? void 0 : r * (1 - t)
396
401
  })]
397
- }), n === null ? /* @__PURE__ */ p("strong", {
402
+ }), n === null ? /* @__PURE__ */ m("strong", {
398
403
  className: "model-download-ring__pending",
399
404
  children: "…"
400
- }) : /* @__PURE__ */ m("strong", { children: [n, "%"] })]
405
+ }) : /* @__PURE__ */ h("strong", { children: [n, "%"] })]
401
406
  });
402
407
  }
403
408
  //#endregion
404
409
  //#region src/react/parts.tsx
405
- var w = {
410
+ var E = {
406
411
  primaryColorHex: "--scanner-overlay-primary",
407
412
  seekingColorHex: "--scanner-overlay-seeking",
408
413
  detectingColorHex: "--scanner-overlay-detecting",
@@ -410,38 +415,38 @@ var w = {
410
415
  readyColorHex: "--scanner-overlay-ready",
411
416
  capturedColorHex: "--scanner-overlay-captured"
412
417
  };
413
- function T(e) {
418
+ function D(e) {
414
419
  if (!e) return;
415
420
  let t = {};
416
- for (let [n, r] of Object.entries(w)) {
421
+ for (let [n, r] of Object.entries(E)) {
417
422
  let i = e[n]?.trim();
418
423
  i && (t[r] = i);
419
424
  }
420
425
  return Object.keys(t).length > 0 ? t : void 0;
421
426
  }
422
- function E({ theme: e, style: t, title: n = "Scan a document", children: r }) {
423
- let i = x();
427
+ function O({ theme: e, style: t, title: n = "Scan a document", children: r }) {
428
+ let i = C();
424
429
  if (!i.open) return null;
425
- let a = T(e), o = a ? {
430
+ let a = D(e), o = a ? {
426
431
  ...t,
427
432
  ...a
428
433
  } : t;
429
- return /* @__PURE__ */ p("div", {
434
+ return /* @__PURE__ */ h("div", {
430
435
  className: `scanner-camera-overlay ${i.finderStatus?.state === "captured" ? "is-captured" : ""}`.trim(),
431
436
  style: o,
432
437
  role: "dialog",
433
438
  "aria-modal": "true",
434
439
  "aria-label": n,
435
- children: r
440
+ children: [r, /* @__PURE__ */ m(I, {})]
436
441
  });
437
442
  }
438
- function D() {
439
- let { bindPreview: e, frozenPreviewUrl: t } = x(), n = u(null), r = o((t) => {
443
+ function k() {
444
+ let { bindPreview: e, frozenPreviewUrl: t } = C(), n = d(null), r = s((t) => {
440
445
  n.current = t, e(t);
441
446
  }, [e]);
442
- return c(() => {
447
+ return l(() => {
443
448
  t && n.current?.pause();
444
- }, [t]), /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("video", {
449
+ }, [t]), /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m("video", {
445
450
  ref: r,
446
451
  className: "scanner-camera-overlay__video",
447
452
  muted: !0,
@@ -450,30 +455,30 @@ function D() {
450
455
  style: { objectFit: "cover" },
451
456
  "aria-hidden": !!t,
452
457
  "aria-label": "Rear camera preview"
453
- }), t ? /* @__PURE__ */ p("img", {
458
+ }), t ? /* @__PURE__ */ m("img", {
454
459
  src: t,
455
460
  className: "scanner-camera-overlay__video scanner-camera-overlay__still",
456
461
  alt: "",
457
462
  "aria-label": "Captured document"
458
463
  }) : null] });
459
464
  }
460
- function O() {
461
- let { finderStatus: e, displayQuad: t, previewSize: n } = x();
465
+ function A() {
466
+ let { finderStatus: e, displayQuad: t, previewSize: n } = C();
462
467
  if (!t || !e?.sourceWidth || !e.sourceHeight) return null;
463
- let r = S(e.sourceWidth, e.sourceHeight, n.width, n.height, "cover");
464
- return /* @__PURE__ */ p("svg", {
468
+ let r = w(e.sourceWidth, e.sourceHeight, n.width, n.height, "cover");
469
+ return /* @__PURE__ */ m("svg", {
465
470
  className: `scanner-camera-overlay__quad ${e.state}`,
466
471
  viewBox: r.viewBox,
467
472
  preserveAspectRatio: r.preserveAspectRatio,
468
473
  "aria-label": `${e.state} document boundary`,
469
- children: /* @__PURE__ */ p("polygon", { points: `${t.topLeft.x},${t.topLeft.y} ${t.topRight.x},${t.topRight.y} ${t.bottomRight.x},${t.bottomRight.y} ${t.bottomLeft.x},${t.bottomLeft.y}` })
474
+ children: /* @__PURE__ */ m("polygon", { points: `${t.topLeft.x},${t.topLeft.y} ${t.topRight.x},${t.topRight.y} ${t.bottomRight.x},${t.bottomRight.y} ${t.bottomLeft.x},${t.bottomLeft.y}` })
470
475
  });
471
476
  }
472
- function k({ title: e = "Scan a document" }) {
473
- let { phase: t, guidanceHint: n, cancel: r } = x();
474
- return /* @__PURE__ */ m("div", {
477
+ function j({ title: e = "Scan a document" }) {
478
+ let { phase: t, guidanceHint: n, cancel: r } = C();
479
+ return /* @__PURE__ */ h("div", {
475
480
  className: "scanner-camera-overlay__topbar",
476
- children: [/* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("strong", { children: e }), /* @__PURE__ */ m("span", {
481
+ children: [/* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("strong", { children: e }), /* @__PURE__ */ h("span", {
477
482
  "aria-live": "polite",
478
483
  children: [
479
484
  t === "starting" && "Starting rear camera…",
@@ -482,7 +487,7 @@ function k({ title: e = "Scan a document" }) {
482
487
  t === "captured" && "Document captured",
483
488
  t === "error" && "Camera unavailable"
484
489
  ]
485
- })] }), /* @__PURE__ */ p("button", {
490
+ })] }), /* @__PURE__ */ m("button", {
486
491
  type: "button",
487
492
  onClick: r,
488
493
  "aria-label": "Close camera",
@@ -490,51 +495,51 @@ function k({ title: e = "Scan a document" }) {
490
495
  })]
491
496
  });
492
497
  }
493
- function A() {
494
- let { phase: e, error: t, diagnostics: n, copyState: r, retry: i, copyReport: a, cancel: o } = x();
495
- return e === "error" ? /* @__PURE__ */ m("div", {
498
+ function M() {
499
+ let { phase: e, error: t, diagnostics: n, copyState: r, retry: i, copyReport: a, cancel: o } = C();
500
+ return e === "error" ? /* @__PURE__ */ h("div", {
496
501
  className: "scanner-camera-overlay__message",
497
502
  role: "alert",
498
503
  children: [
499
- /* @__PURE__ */ p("strong", { children: n ? "Capture failed" : "Could not open the camera" }),
500
- /* @__PURE__ */ p("p", { children: t }),
501
- /* @__PURE__ */ m("div", { children: [
502
- /* @__PURE__ */ p("button", {
504
+ /* @__PURE__ */ m("strong", { children: n ? "Capture failed" : "Could not open the camera" }),
505
+ /* @__PURE__ */ m("p", { children: t }),
506
+ /* @__PURE__ */ h("div", { children: [
507
+ /* @__PURE__ */ m("button", {
503
508
  type: "button",
504
509
  onClick: i,
505
510
  children: "Try again"
506
511
  }),
507
- /* @__PURE__ */ p("button", {
512
+ /* @__PURE__ */ m("button", {
508
513
  type: "button",
509
514
  onClick: () => void a(),
510
515
  children: r === "copied" ? "Copied" : r === "failed" ? "Copy failed" : "Copy report"
511
516
  }),
512
- /* @__PURE__ */ p("button", {
517
+ /* @__PURE__ */ m("button", {
513
518
  type: "button",
514
519
  onClick: o,
515
520
  children: "Cancel"
516
521
  })
517
522
  ] })
518
523
  ]
519
- }) : e === "starting" ? /* @__PURE__ */ m("div", {
524
+ }) : e === "starting" ? /* @__PURE__ */ h("div", {
520
525
  className: "scanner-camera-overlay__message",
521
526
  "aria-live": "polite",
522
527
  children: [
523
- /* @__PURE__ */ p("span", { className: "scanner-camera-overlay__spinner" }),
524
- /* @__PURE__ */ p("strong", { children: "Requesting the highest practical resolution" }),
525
- /* @__PURE__ */ p("p", { children: "Allow camera access to continue." })
528
+ /* @__PURE__ */ m("span", { className: "scanner-camera-overlay__spinner" }),
529
+ /* @__PURE__ */ m("strong", { children: "Requesting the highest practical resolution" }),
530
+ /* @__PURE__ */ m("p", { children: "Allow camera access to continue." })
526
531
  ]
527
532
  }) : null;
528
533
  }
529
- function j() {
530
- let { finderStatus: e, detectorStatus: t, settings: n } = x(), r = n?.width, i = n?.height;
531
- return /* @__PURE__ */ p("div", {
534
+ function N() {
535
+ let { finderStatus: e, detectorStatus: t, settings: n } = C(), r = n?.width, i = n?.height;
536
+ return /* @__PURE__ */ m("div", {
532
537
  className: "scanner-camera-overlay__status",
533
538
  "aria-live": "polite",
534
- children: /* @__PURE__ */ m("div", {
539
+ children: /* @__PURE__ */ h("div", {
535
540
  className: "scanner-camera-overlay__status-line",
536
541
  children: [
537
- /* @__PURE__ */ p("span", { className: e?.state ?? "detecting" }),
542
+ /* @__PURE__ */ m("span", { className: e?.state ?? "detecting" }),
538
543
  e?.state ?? "detecting",
539
544
  e ? ` · ${Math.round(e.confidence * 100)}% · ${e.stableFrames}/${e.requiredStableFrames}` : "",
540
545
  ` · ${t}`,
@@ -544,25 +549,25 @@ function j() {
544
549
  })
545
550
  });
546
551
  }
547
- function M() {
548
- let { diagnostics: e, shutterDiagnostics: t, captureMethod: r, copyState: i, copyReport: a } = x(), o = e?.engine ?? n();
549
- return /* @__PURE__ */ m("dl", {
552
+ function P() {
553
+ let { diagnostics: e, shutterDiagnostics: t, captureMethod: n, copyState: i, copyReport: a } = C(), o = e?.engine ?? r();
554
+ return /* @__PURE__ */ h("dl", {
550
555
  className: "scanner-camera-overlay__diagnostics",
551
556
  "aria-label": "Camera diagnostics",
552
557
  children: [
553
- /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("dt", { children: "engine" }), /* @__PURE__ */ m("dd", { children: [
558
+ /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("dt", { children: "engine" }), /* @__PURE__ */ h("dd", { children: [
554
559
  o.engine,
555
560
  "/",
556
561
  o.browser,
557
562
  o.iosWebKit ? " ios" : ""
558
563
  ] })] }),
559
- /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("dt", { children: "video" }), /* @__PURE__ */ p("dd", { children: e ? `${e.videoWidth}×${e.videoHeight} rs${e.readyState}${e.paused ? " paused" : ""}${e.rendered ? "" : " hidden"}` : "starting" })] }),
560
- /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("dt", { children: "track" }), /* @__PURE__ */ p("dd", { children: e ? `${e.trackReadyState}${e.trackMuted ? " muted" : ""}${e.trackEnabled ? "" : " disabled"}` : "—" })] }),
561
- /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("dt", { children: "torch" }), /* @__PURE__ */ p("dd", { children: e ? `${e.torch.mode} · ${e.torch.supported ? e.torch.on ? "on" : "off" : "unsupported"}` : "starting" })] }),
562
- /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("dt", { children: "luma" }), /* @__PURE__ */ p("dd", { children: e ? `live ${e.liveLuminance.toFixed(1)} · mirror ${e.mirrorLuminance.toFixed(1)}${Number.isFinite(e.mirrorAgeMs) ? ` (${Math.round(e.mirrorAgeMs)}ms)` : " (none)"}` : "—" })] }),
563
- /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("dt", { children: "path" }), /* @__PURE__ */ p("dd", { children: r ?? "video-frame / live-mirror" })] }),
564
- t ? /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("dt", { children: "shutter" }), /* @__PURE__ */ p("dd", { children: `live ${t.liveLuminance.toFixed(1)} · mirror ${t.mirrorLuminance.toFixed(1)}${Number.isFinite(t.mirrorAgeMs) ? ` (${Math.round(t.mirrorAgeMs)}ms)` : " (none)"}` })] }) : null,
565
- /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("dt", { children: "share" }), /* @__PURE__ */ p("dd", { children: /* @__PURE__ */ p("button", {
564
+ /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("dt", { children: "video" }), /* @__PURE__ */ m("dd", { children: e ? `${e.videoWidth}×${e.videoHeight} rs${e.readyState}${e.paused ? " paused" : ""}${e.rendered ? "" : " hidden"}` : "starting" })] }),
565
+ /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("dt", { children: "track" }), /* @__PURE__ */ m("dd", { children: e ? `${e.trackReadyState}${e.trackMuted ? " muted" : ""}${e.trackEnabled ? "" : " disabled"}` : "—" })] }),
566
+ /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("dt", { children: "torch" }), /* @__PURE__ */ m("dd", { children: e ? `${e.torch.mode} · ${e.torch.supported ? e.torch.on ? "on" : "off" : "unsupported"}` : "starting" })] }),
567
+ /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("dt", { children: "luma" }), /* @__PURE__ */ m("dd", { children: e ? `live ${e.liveLuminance.toFixed(1)} · mirror ${e.mirrorLuminance.toFixed(1)}${Number.isFinite(e.mirrorAgeMs) ? ` (${Math.round(e.mirrorAgeMs)}ms)` : " (none)"}` : "—" })] }),
568
+ /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("dt", { children: "path" }), /* @__PURE__ */ m("dd", { children: n ?? "video-frame / live-mirror" })] }),
569
+ t ? /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("dt", { children: "shutter" }), /* @__PURE__ */ m("dd", { children: `live ${t.liveLuminance.toFixed(1)} · mirror ${t.mirrorLuminance.toFixed(1)}${Number.isFinite(t.mirrorAgeMs) ? ` (${Math.round(t.mirrorAgeMs)}ms)` : " (none)"}` })] }) : null,
570
+ /* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("dt", { children: "share" }), /* @__PURE__ */ m("dd", { children: /* @__PURE__ */ m("button", {
566
571
  type: "button",
567
572
  className: "scanner-camera-overlay__copy",
568
573
  onClick: () => void a(),
@@ -571,35 +576,35 @@ function M() {
571
576
  ]
572
577
  });
573
578
  }
574
- function N() {
575
- let { autoCapture: e, phase: t, finderStatus: n, diagnostics: r, captureMethod: i, settings: a, cancel: o, capture: s, setAutoCapture: c, setTorch: l } = x(), u = a?.width, d = a?.height;
576
- return /* @__PURE__ */ m("div", {
579
+ function F() {
580
+ let { autoCapture: e, phase: t, finderStatus: n, diagnostics: r, captureMethod: i, settings: a, cancel: o, capture: s, setAutoCapture: c, setTorch: l } = C(), u = a?.width, d = a?.height;
581
+ return /* @__PURE__ */ h("div", {
577
582
  className: "scanner-camera-overlay__controls",
578
583
  children: [
579
- /* @__PURE__ */ p("button", {
584
+ /* @__PURE__ */ m("button", {
580
585
  type: "button",
581
586
  className: "scanner-camera-overlay__cancel",
582
587
  onClick: o,
583
588
  children: "Cancel"
584
589
  }),
585
- /* @__PURE__ */ m("div", {
590
+ /* @__PURE__ */ h("div", {
586
591
  className: "scanner-camera-overlay__capture",
587
- children: [e !== "only" && /* @__PURE__ */ p("button", {
592
+ children: [e !== "only" && /* @__PURE__ */ m("button", {
588
593
  type: "button",
589
594
  className: "scanner-camera-overlay__shutter",
590
595
  onClick: () => void s(),
591
596
  disabled: t !== "ready",
592
597
  "aria-label": "Capture full-resolution photo",
593
- children: /* @__PURE__ */ p("span", {})
594
- }), /* @__PURE__ */ m("div", {
598
+ children: /* @__PURE__ */ m("span", {})
599
+ }), /* @__PURE__ */ h("div", {
595
600
  className: "scanner-camera-overlay__toggles",
596
- children: [n?.autoCapture.visible && /* @__PURE__ */ m("label", { children: [/* @__PURE__ */ p("input", {
601
+ children: [n?.autoCapture.visible && /* @__PURE__ */ h("label", { children: [/* @__PURE__ */ m("input", {
597
602
  type: "checkbox",
598
603
  checked: n.autoCapture.checked,
599
604
  onChange: (e) => c(e.target.checked)
600
- }), "Auto-capture"] }), r?.torch.visible && /* @__PURE__ */ m("label", {
605
+ }), "Auto-capture"] }), r?.torch.visible && /* @__PURE__ */ h("label", {
601
606
  title: r.torch.automatic ? "Torch is controlled automatically from scene brightness" : void 0,
602
- children: [/* @__PURE__ */ p("input", {
607
+ children: [/* @__PURE__ */ m("input", {
603
608
  type: "checkbox",
604
609
  checked: r.torch.on,
605
610
  disabled: !r.torch.mutable,
@@ -608,17 +613,18 @@ function N() {
608
613
  })]
609
614
  })]
610
615
  }),
611
- /* @__PURE__ */ m("div", {
616
+ /* @__PURE__ */ h("div", {
612
617
  className: "scanner-camera-overlay__quality",
613
- children: [/* @__PURE__ */ p("span", { children: i === "live-mirror" ? "Mirror" : "Camera" }), /* @__PURE__ */ p("strong", { children: u && d ? `${u} × ${d}` : "Measuring…" })]
618
+ children: [/* @__PURE__ */ m("span", { children: i === "live-mirror" ? "Mirror" : "Camera" }), /* @__PURE__ */ m("strong", { children: u && d ? `${u} × ${d}` : "Measuring…" })]
614
619
  })
615
620
  ]
616
621
  });
617
622
  }
618
- function P({ snapshot: e }) {
619
- return x(), e ? /* @__PURE__ */ p(C, { snapshot: e }) : null;
623
+ function I({ snapshot: e }) {
624
+ let { modelDownload: t } = C();
625
+ return /* @__PURE__ */ m(T, { snapshot: e ?? t });
620
626
  }
621
627
  //#endregion
622
- export { N as ScannerControls, M as ScannerDiagnostics, E as ScannerFrame, P as ScannerModelDownload, A as ScannerNotice, D as ScannerPreview, y as ScannerProvider, O as ScannerQuad, j as ScannerStatus, k as ScannerTopBar, x as useScanner, b as useScannerRef };
628
+ export { F as ScannerControls, P as ScannerDiagnostics, O as ScannerFrame, I as ScannerModelDownload, M as ScannerNotice, k as ScannerPreview, x as ScannerProvider, A as ScannerQuad, N as ScannerStatus, j as ScannerTopBar, C as useScanner, S as useScannerRef };
623
629
 
624
630
  //# sourceMappingURL=react.js.map