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