@exige/web-scanner-sdk 0.2.30 → 0.2.33

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 { B as e, I as t, M as n, N as r, R as i, T as a, U as o, V as s, i as c, j as l, n as u, v as d, y as f } from "./driver-license-DpjQqOKx.js";
3
- import { createContext as p, useCallback as m, useContext as h, useEffect as g, useLayoutEffect as ee, useMemo as te, useRef as _, useState as v } from "react";
4
- import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
2
+ import { A as e, C as t, G as n, I as r, J as i, K as a, L as o, R as s, U as c, V as l, a as u, f as d, o as f, r as p, v as m, w as ee } from "./driver-license-DBrWpI9w.js";
3
+ import { createContext as h, useCallback as g, useContext as te, useEffect as _, useLayoutEffect as v, useMemo as ne, useRef as y, useState as b } from "react";
4
+ import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
5
5
  //#region src/sdk/display-quad.ts
6
- function S(e) {
6
+ function w(e) {
7
7
  return [
8
8
  e.topLeft,
9
9
  e.topRight,
@@ -11,7 +11,7 @@ function S(e) {
11
11
  e.bottomLeft
12
12
  ];
13
13
  }
14
- function C(e) {
14
+ function T(e) {
15
15
  let [t, n, r, i] = e;
16
16
  return {
17
17
  topLeft: t,
@@ -38,10 +38,10 @@ function C(e) {
38
38
  }
39
39
  };
40
40
  }
41
- function w(e) {
42
- return C(S(e).map((e) => ({ ...e })));
41
+ function re(e) {
42
+ return T(w(e).map((e) => ({ ...e })));
43
43
  }
44
- var ne = class {
44
+ var ie = class {
45
45
  current;
46
46
  target;
47
47
  response;
@@ -50,11 +50,11 @@ var ne = 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 || S(e).some((e, t) => {
54
- let n = S(this.current)[t];
53
+ let r = Math.max(1, Math.hypot(t, n)), i = !this.current || w(e).some((e, t) => {
54
+ let n = w(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 = w(e), i && (this.current = w(e)), {
57
+ return this.target = re(e), i && (this.current = re(e)), {
58
58
  quad: this.current,
59
59
  snapped: i
60
60
  };
@@ -62,8 +62,8 @@ var ne = 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 = C(S(this.current).map((e, n) => {
66
- let r = S(this.target)[n];
65
+ return this.current = T(w(this.current).map((e, n) => {
66
+ let r = w(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 ne = class {
76
76
  getCurrent() {
77
77
  return this.current;
78
78
  }
79
- }, re = p(null);
79
+ }, ae = h(null);
80
80
  //#endregion
81
81
  //#region src/react/context.tsx
82
- function ie(e) {
82
+ function oe(e) {
83
83
  e?.startsWith("blob:") && URL.revokeObjectURL(e);
84
84
  }
85
- function ae(e) {
85
+ function se(e) {
86
86
  try {
87
87
  let t = e.toDataURL("image/jpeg", .92);
88
88
  return t.startsWith("data:image/") ? t : void 0;
@@ -90,449 +90,516 @@ function ae(e) {
90
90
  return;
91
91
  }
92
92
  }
93
- function oe(e, t) {
93
+ function ce(e, t) {
94
94
  if (typeof e == "function") return e(t);
95
95
  }
96
- function T({ open: l, useCase: u = "document", autoCapture: p = "defaultOn", captureMode: h = "auto", torch: y = "defaultOff", onCapture: x, onDriverLicense: S, onCancel: C, onError: w, onSettings: T, onFinderStatus: E, modelUrl: D, ortWasmPaths: O, detectionIntervalMs: se, apiRef: k, children: ce }) {
97
- let A = e(h), j = _(void 0), M = _(void 0), N = _(void 0), P = _(void 0), F = _({}), I = _(new ne()), L = _(!1), R = _(!1), z = _({
96
+ function le({ open: r, useCase: p = "document", autoCapture: m = "defaultOn", captureMode: h = "auto", torch: te = "defaultOff", onCapture: x, onDriverLicense: C, onCancel: w, onError: T, onSettings: re, onFinderStatus: le, modelUrl: E, ortWasmPaths: D, detectionIntervalMs: ue, apiRef: O, children: de }) {
97
+ let k = n(h), A = y(void 0), j = y(void 0), M = y(void 0), N = y(void 0), P = y({}), F = y(new ie()), I = y(!1), fe = y(!1), L = y({
98
98
  onCapture: x,
99
- onDriverLicense: S,
100
- onCancel: C,
101
- onError: w,
102
- onSettings: T,
103
- onFinderStatus: E,
104
- useCase: u
105
- }), le = _(void 0), B = _(void 0), ue = _(async () => void 0), de = _(null), [V, fe] = v(null), [pe, H] = v(A && l ? "capturing" : A ? "ready" : "starting"), [U, me] = v(), [he, W] = v(), [ge, _e] = v({
99
+ onDriverLicense: C,
100
+ onCancel: w,
101
+ onError: T,
102
+ onSettings: re,
103
+ onFinderStatus: le,
104
+ useCase: p
105
+ }), R = y(void 0), pe = y(void 0), z = y(async () => void 0), B = y(!1), V = y(void 0), me = y(null), [H, he] = b(null), [ge, U] = b(k && r ? "capturing" : k ? "ready" : "starting"), [W, G] = b(), [_e, K] = b(), [ve, ye] = b({
106
106
  width: 1,
107
107
  height: 1
108
- }), [ve, ye] = v(), [be, G] = v(), [xe, K] = v(""), [Se, Ce] = v(0), [we, q] = v(), [Te, J] = v(), [Ee, Y] = v("idle"), [De, Oe] = v(), X = _(void 0), [ke, Ae] = v("front"), je = _("front"), [Me, Ne] = v(!1), [Pe, Fe] = v({
108
+ }), [be, xe] = b(), [Se, q] = b(), [Ce, J] = b(""), [we, Te] = b(0), [Ee, Y] = b(), [De, X] = b(), [Oe, ke] = b("idle"), [Ae, je] = b(), Me = y(void 0), [Ne, Pe] = b("front"), Fe = y("front"), [Ie, Le] = b(!1), [Re, ze] = b({
109
109
  downloading: !1,
110
110
  loaded: 0,
111
111
  total: null
112
- }), Z = m(() => {
113
- ie(X.current), X.current = void 0, Oe(void 0);
114
- }, []), Q = m((e, t) => {
115
- let n = ae(e);
116
- ie(X.current), X.current = n, Oe(n), t?.pause();
112
+ }), Z = g(() => {
113
+ oe(Me.current), Me.current = void 0, je(void 0);
114
+ }, []), Q = g((e, t) => {
115
+ let n = se(e);
116
+ oe(Me.current), Me.current = n, je(n), t?.pause();
117
117
  }, []);
118
- ee(() => {
119
- z.current = {
118
+ v(() => {
119
+ L.current = {
120
120
  onCapture: x,
121
- onDriverLicense: S,
122
- onCancel: C,
123
- onError: w,
124
- onSettings: T,
125
- onFinderStatus: E,
126
- useCase: u
121
+ onDriverLicense: C,
122
+ onCancel: w,
123
+ onError: T,
124
+ onSettings: re,
125
+ onFinderStatus: le,
126
+ useCase: p
127
127
  };
128
128
  }, [
129
129
  x,
130
- S,
131
130
  C,
132
131
  w,
133
132
  T,
134
- E,
135
- u
136
- ]), g(() => o(Fe), []), g(() => {
137
- if (!l || u !== "drivers-license") {
138
- B.current = void 0, le.current = void 0, Ae("front"), Ne(!1);
133
+ re,
134
+ le,
135
+ p
136
+ ]), _(() => i(ze), []), _(() => {
137
+ if (!r || p !== "drivers-license") {
138
+ pe.current = void 0, R.current = void 0, B.current = !1, Pe("front"), Le(!1);
139
139
  return;
140
140
  }
141
- let e = c({ scan: {
142
- modelUrl: D,
143
- ortWasmPaths: O
141
+ let e = u({ scan: {
142
+ modelUrl: E,
143
+ ortWasmPaths: D
144
144
  } });
145
- return B.current = e, e.then((e) => {
146
- le.current = e;
145
+ return pe.current = e, e.then((e) => {
146
+ R.current = e;
147
147
  }), () => {
148
- e.then((e) => e.cancel()), le.current &&= void 0, B.current = void 0;
148
+ e.then((e) => e.cancel()), R.current &&= void 0, pe.current = void 0;
149
149
  };
150
150
  }, [
151
- l,
152
- u,
153
- D,
154
- O
151
+ r,
152
+ p,
153
+ E,
154
+ D
155
155
  ]);
156
- let Ie = m((e) => {
157
- fe(e);
156
+ let Be = g((e) => {
157
+ he(e);
158
158
  }, []);
159
- g(() => {
160
- if (!l || !V) return;
159
+ _(() => {
160
+ if (!r || !H) return;
161
161
  let e = () => {
162
- let e = V.getBoundingClientRect();
163
- _e({
162
+ let e = H.getBoundingClientRect();
163
+ ye({
164
164
  width: e.width,
165
165
  height: e.height
166
166
  });
167
167
  };
168
168
  if (e(), typeof ResizeObserver > "u") return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
169
169
  let t = new ResizeObserver(e);
170
- return t.observe(V), () => t.disconnect();
171
- }, [l, V]), g(() => {
172
- if (!l) return;
170
+ return t.observe(H), () => t.disconnect();
171
+ }, [r, H]), _(() => {
172
+ if (!r) return;
173
173
  let e = window.setInterval(() => {
174
- let e = j.current?.getDiagnostics();
175
- e && q(e);
174
+ let e = A.current?.getDiagnostics();
175
+ e && Y(e);
176
176
  }, 500);
177
177
  return () => window.clearInterval(e);
178
- }, [l, Se]), g(() => {
179
- if (!l) return;
178
+ }, [r, we]), _(() => {
179
+ if (!r) return;
180
180
  let e = 0, t = performance.now(), n = (r) => {
181
- let i = I.current.step(r - t);
182
- t = r, i && W(i), e = requestAnimationFrame(n);
181
+ let i = F.current.step(r - t);
182
+ t = r, i && K(i), e = requestAnimationFrame(n);
183
183
  };
184
184
  return e = requestAnimationFrame(n), () => cancelAnimationFrame(e);
185
- }, [l]), g(() => {
186
- if (!l || A || !V) return;
187
- let e = !1, t = () => {
188
- M.current?.stop(), M.current = void 0, j.current?.stop(), j.current = void 0, P.current = void 0, N.current = void 0, F.current = {}, Z();
185
+ }, [r]), _(() => {
186
+ if (!r || k || !H) return;
187
+ let e = !1, t = new AbortController();
188
+ V.current = t;
189
+ let n = () => {
190
+ t.abort(), V.current === t && (V.current = void 0), j.current?.stop(), j.current = void 0, A.current?.stop(), A.current = void 0, N.current = void 0, M.current = void 0, P.current = {}, Z();
189
191
  };
190
192
  return (async () => {
191
- t(), L.current = !1, H("starting"), K(""), me(void 0), G(void 0), J(void 0), Y("idle"), Z();
193
+ n(), t = new AbortController(), V.current = t, I.current = !1, U("starting"), J(""), G(void 0), q(void 0), X(void 0), ke("idle"), Z();
192
194
  try {
193
- let t = await s(V, { torch: y });
195
+ let n = await a(H, { torch: te });
194
196
  if (e) {
195
- t.stop();
197
+ n.stop();
198
+ return;
199
+ }
200
+ A.current = n;
201
+ let r = n.getSettings();
202
+ if (xe(r), L.current.onSettings?.(r), console.info("[ScannerProvider] camera settings", r), L.current.useCase === "drivers-license" && Fe.current === "back") {
203
+ G(void 0), K(void 0), F.current.clear(), U("ready"), (async () => {
204
+ try {
205
+ let r = await f(() => {
206
+ try {
207
+ return n.capture();
208
+ } catch {
209
+ return;
210
+ }
211
+ }, {
212
+ intervalMs: ue ?? 140,
213
+ signal: t.signal
214
+ });
215
+ if (e || t.signal.aborted || B.current) return;
216
+ B.current = !0, Q(r, H), q("video-frame"), U("captured"), await z.current({
217
+ frame: r,
218
+ reason: "auto",
219
+ method: "video-frame",
220
+ settings: n.getSettings()
221
+ });
222
+ } catch (n) {
223
+ if (e || t.signal.aborted || n instanceof DOMException && n.name === "AbortError") return;
224
+ let r = n instanceof Error ? n : /* @__PURE__ */ Error("Could not read the barcode.");
225
+ I.current = !0, J(r.message), U("error"), L.current.onError?.(r);
226
+ }
227
+ })();
196
228
  return;
197
229
  }
198
- j.current = t;
199
- let n = t.getSettings();
200
- ye(n), z.current.onSettings?.(n), console.info("[ScannerProvider] camera settings", n), M.current = await f({
201
- source: V,
202
- autoCapture: p,
203
- intervalMs: se,
230
+ j.current = await ee({
231
+ source: H,
232
+ autoCapture: m,
233
+ intervalMs: ue,
204
234
  detection: {
205
- modelUrl: D,
206
- ortWasmPaths: O
235
+ modelUrl: E,
236
+ ortWasmPaths: D
207
237
  },
208
238
  onStatus: (e) => {
209
- if (N.current = e, me(e), z.current.onFinderStatus?.(e), e.quad && e.sourceWidth && e.sourceHeight) {
210
- let t = I.current.setTarget(e.quad, e.sourceWidth, e.sourceHeight);
211
- W(t.quad);
212
- } else I.current.clear(), W(void 0);
213
- e.state !== "captured" && !L.current && H("ready");
239
+ if (M.current = e, G(e), L.current.onFinderStatus?.(e), e.quad && e.sourceWidth && e.sourceHeight) {
240
+ let t = F.current.setTarget(e.quad, e.sourceWidth, e.sourceHeight);
241
+ K(t.quad);
242
+ } else F.current.clear(), K(void 0);
243
+ e.state !== "captured" && !I.current && U("ready");
214
244
  },
215
245
  captureFrame: async () => {
216
- H("capturing"), F.current = {
217
- quad: I.current.getCurrent(),
218
- sourceWidth: N.current?.sourceWidth,
219
- sourceHeight: N.current?.sourceHeight
246
+ U("capturing"), P.current = {
247
+ quad: F.current.getCurrent(),
248
+ sourceWidth: M.current?.sourceWidth,
249
+ sourceHeight: M.current?.sourceHeight
220
250
  };
221
- let e = await t.capturePhoto();
222
- if (P.current = e, G(e.method), J(e.diagnostics), q(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.`);
223
- return Q(e.frame, V), H("captured"), e.frame;
251
+ let e = await n.capturePhoto();
252
+ if (N.current = e, q(e.method), X(e.diagnostics), Y(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.`);
253
+ return Q(e.frame, H), U("captured"), e.frame;
224
254
  },
225
255
  onCaptureError: (e) => {
226
- L.current = !0, H("error"), K(e.message);
227
- let t = j.current?.getDiagnostics();
228
- t && q(t), z.current.onError?.(e);
256
+ I.current = !0, U("error"), J(e.message);
257
+ let t = A.current?.getDiagnostics();
258
+ t && Y(t), L.current.onError?.(e);
229
259
  },
230
260
  onCapture: async (e) => {
231
- let n = P.current;
261
+ let t = N.current;
232
262
  await new Promise((e) => window.setTimeout(e, 140));
233
263
  let r = {
234
264
  ...e,
235
- method: n?.method ?? "video-frame",
236
- settings: n?.settings ?? t.getSettings(),
237
- fallbackReason: n?.fallbackReason,
238
- luminance: n?.luminance,
239
- diagnostics: n?.diagnostics,
240
- displayedQuad: F.current.quad,
241
- displaySourceWidth: F.current.sourceWidth,
242
- displaySourceHeight: F.current.sourceHeight
265
+ method: t?.method ?? "video-frame",
266
+ settings: t?.settings ?? n.getSettings(),
267
+ fallbackReason: t?.fallbackReason,
268
+ luminance: t?.luminance,
269
+ diagnostics: t?.diagnostics,
270
+ displayedQuad: P.current.quad,
271
+ displaySourceWidth: P.current.sourceWidth,
272
+ displaySourceHeight: P.current.sourceHeight
243
273
  };
244
- if (z.current.useCase === "drivers-license") {
245
- await ue.current(r);
274
+ if (L.current.useCase === "drivers-license") {
275
+ await z.current(r);
246
276
  return;
247
277
  }
248
- await oe(z.current.onCapture, r);
278
+ await ce(L.current.onCapture, r);
249
279
  }
250
280
  });
251
- } catch (n) {
281
+ } catch (t) {
252
282
  if (e) return;
253
- t();
254
- let r = n instanceof Error ? n : /* @__PURE__ */ Error("Camera access failed.");
255
- K(r.message), H("error"), z.current.onError?.(r);
283
+ n();
284
+ let r = t instanceof Error ? t : /* @__PURE__ */ Error("Camera access failed.");
285
+ J(r.message), U("error"), L.current.onError?.(r);
256
286
  }
257
287
  })(), () => {
258
- e = !0, t();
288
+ e = !0, n();
259
289
  };
260
290
  }, [
261
- l,
262
- V,
263
- A,
264
- p,
265
- y,
291
+ r,
292
+ H,
293
+ k,
294
+ m,
295
+ te,
296
+ E,
266
297
  D,
267
- O,
268
- se,
269
- Se,
298
+ ue,
299
+ we,
270
300
  Z,
271
301
  Q
272
302
  ]);
273
- let Le = {
274
- open: l,
275
- phase: pe,
276
- autoCapture: p,
303
+ let Ve = {
304
+ open: r,
305
+ phase: ge,
306
+ autoCapture: m,
277
307
  captureMode: h,
278
- usingSystemCamera: A,
279
- finderStatus: U,
280
- displayQuad: he,
281
- previewSize: ge,
282
- settings: ve,
283
- captureMethod: be,
284
- error: xe,
285
- diagnostics: we,
286
- shutterDiagnostics: Te,
287
- copyState: Ee,
288
- guidanceHint: U ? d(U.guidance, U.lighting) : void 0,
289
- detectorStatus: U?.modelStatus === "failed" ? `ML failed${U.modelError ? `: ${U.modelError}` : ""}` : U?.detector === "ml" ? `ML ${U.modelProvider ?? ""}`.trim() : "ML loading",
290
- modelDownload: Pe,
291
- frozenPreviewUrl: De,
292
- useCase: u,
293
- licenseSide: u === "drivers-license" ? ke : void 0,
294
- licenseBusy: u === "drivers-license" ? Me : void 0
308
+ usingSystemCamera: k,
309
+ finderStatus: W,
310
+ displayQuad: _e,
311
+ previewSize: ve,
312
+ settings: be,
313
+ captureMethod: Se,
314
+ error: Ce,
315
+ diagnostics: Ee,
316
+ shutterDiagnostics: De,
317
+ copyState: Oe,
318
+ guidanceHint: W ? t(W.guidance, W.lighting) : void 0,
319
+ detectorStatus: W?.modelStatus === "failed" ? `ML failed${W.modelError ? `: ${W.modelError}` : ""}` : W?.detector === "ml" ? `ML ${W.modelProvider ?? ""}`.trim() : "ML loading",
320
+ modelDownload: Re,
321
+ frozenPreviewUrl: Ae,
322
+ useCase: p,
323
+ licenseSide: p === "drivers-license" ? Ne : void 0,
324
+ licenseBusy: p === "drivers-license" ? Ie : void 0
295
325
  };
296
- g(() => {
297
- de.current = Le;
326
+ _(() => {
327
+ me.current = Ve;
298
328
  });
299
- let Re = m(() => {
300
- z.current.onCancel();
301
- }, []), $ = m(async () => {
302
- if (!R.current) {
303
- R.current = !0, L.current = !1, K(""), W(void 0), I.current.clear(), H("capturing");
329
+ let He = g(() => {
330
+ L.current.onCancel();
331
+ }, []), $ = g(async () => {
332
+ if (!fe.current) {
333
+ fe.current = !0, I.current = !1, J(""), K(void 0), F.current.clear(), U("capturing");
304
334
  try {
305
- let e = await i();
306
- Q(e);
335
+ let t = await c();
336
+ Q(t);
307
337
  let n = {
308
- width: e.width,
309
- height: e.height
338
+ width: t.width,
339
+ height: t.height
310
340
  };
311
- ye(n), z.current.onSettings?.(n), G("system-camera");
341
+ xe(n), L.current.onSettings?.(n), q("system-camera");
312
342
  let r;
313
343
  try {
314
- let n = e.getContext("2d", { willReadFrequently: !0 })?.getImageData(0, 0, e.width, e.height).data;
315
- n && (r = t(n));
344
+ let e = t.getContext("2d", { willReadFrequently: !0 })?.getImageData(0, 0, t.width, t.height).data;
345
+ e && (r = l(e));
316
346
  } catch {
317
347
  r = void 0;
318
348
  }
319
- let o = await a(e, {
320
- modelUrl: D,
321
- ortWasmPaths: O
349
+ if (L.current.useCase === "drivers-license" && Fe.current === "back") {
350
+ K(void 0), F.current.clear(), P.current = {}, U("captured"), await z.current({
351
+ frame: t,
352
+ reason: "manual",
353
+ method: "system-camera",
354
+ settings: n,
355
+ luminance: r
356
+ });
357
+ return;
358
+ }
359
+ let i = await e(t, {
360
+ modelUrl: E,
361
+ ortWasmPaths: D
322
362
  });
323
- if ((z.current.useCase !== "drivers-license" || je.current !== "back") && (o.status !== "success" || !o.corners || !o.quad)) {
324
- L.current = !0, H("error"), K(o.message), z.current.onError?.(Error(o.message));
363
+ if (i.status !== "success" || !i.corners || !i.quad) {
364
+ I.current = !0, U("error"), J(i.message), L.current.onError?.(Error(i.message));
325
365
  return;
326
366
  }
327
- F.current = {
328
- quad: o.quad,
329
- sourceWidth: o.sourceWidth,
330
- sourceHeight: o.sourceHeight
331
- }, o.quad && W(o.quad), H("captured");
332
- let s = {
333
- frame: e,
334
- detection: o,
367
+ P.current = {
368
+ quad: i.quad,
369
+ sourceWidth: i.sourceWidth,
370
+ sourceHeight: i.sourceHeight
371
+ }, i.quad && K(i.quad), U("captured");
372
+ let a = {
373
+ frame: t,
374
+ detection: i,
335
375
  reason: "manual",
336
376
  method: "system-camera",
337
377
  settings: n,
338
378
  luminance: r,
339
- displayedQuad: o.quad,
340
- displaySourceWidth: o.sourceWidth,
341
- displaySourceHeight: o.sourceHeight
379
+ displayedQuad: i.quad,
380
+ displaySourceWidth: i.sourceWidth,
381
+ displaySourceHeight: i.sourceHeight
342
382
  };
343
- if (z.current.useCase === "drivers-license") {
344
- await ue.current(s);
383
+ if (L.current.useCase === "drivers-license") {
384
+ await z.current(a);
345
385
  return;
346
386
  }
347
- await oe(z.current.onCapture, s);
387
+ await ce(L.current.onCapture, a);
348
388
  } catch (e) {
349
389
  let t = e instanceof Error ? e : /* @__PURE__ */ Error("Could not take a photo.");
350
390
  if (t.message === "No photo was selected.") {
351
- if (X.current) {
352
- H("error");
391
+ if (Me.current) {
392
+ U("error");
353
393
  return;
354
394
  }
355
- z.current.onCancel();
395
+ L.current.onCancel();
356
396
  return;
357
397
  }
358
- L.current = !0, K(t.message), H("error"), z.current.onError?.(t);
398
+ I.current = !0, J(t.message), U("error"), L.current.onError?.(t);
359
399
  } finally {
360
- R.current = !1;
400
+ fe.current = !1;
361
401
  }
362
402
  }
363
403
  }, [
364
404
  Q,
365
- D,
366
- O
367
- ]), ze = m(async (e) => {
368
- let t = await B.current;
405
+ E,
406
+ D
407
+ ]), Ue = g(async (e) => {
408
+ let t = await pe.current;
369
409
  if (t) {
370
- Ne(!0);
410
+ Le(!0);
371
411
  try {
372
412
  let n = await t.submitStill(e.frame, e.detection);
373
413
  if (n.kind === "need-back") {
374
- if (je.current = "back", Ae("back"), L.current = !1, K(""), W(void 0), I.current.clear(), Z(), A) {
375
- H("ready");
414
+ if (Fe.current = "back", B.current = !1, Pe("back"), I.current = !1, J(""), G(void 0), K(void 0), F.current.clear(), Z(), k) {
415
+ U("ready");
376
416
  return;
377
417
  }
378
- V?.paused && V.play(), H("starting"), Ce((e) => e + 1);
418
+ H?.paused && H.play(), U("starting"), Te((e) => e + 1);
379
419
  return;
380
420
  }
381
421
  if (n.kind === "retry") {
382
- L.current = !0, K(n.message), H("error");
422
+ I.current = !0, J(n.message), U("error");
383
423
  return;
384
424
  }
385
- await oe(z.current.onDriverLicense, n.result);
425
+ await ce(L.current.onDriverLicense, n.result);
386
426
  } catch (e) {
387
427
  let t = e instanceof Error ? e : /* @__PURE__ */ Error("Driver’s license scan failed.");
388
- L.current = !0, K(t.message), H("error"), z.current.onError?.(t);
428
+ I.current = !0, J(t.message), U("error"), L.current.onError?.(t);
389
429
  } finally {
390
- Ne(!1);
430
+ Le(!1);
391
431
  }
392
432
  }
393
433
  }, [
394
434
  Z,
395
- V,
396
- A
435
+ H,
436
+ k
397
437
  ]);
398
- ee(() => {
399
- ue.current = ze;
400
- }, [ze]);
401
- let Be = m(async () => {
402
- if (A) {
438
+ v(() => {
439
+ z.current = Ue;
440
+ }, [Ue]);
441
+ let We = g(async () => {
442
+ if (k) {
403
443
  await $();
404
444
  return;
405
445
  }
446
+ let e = A.current;
447
+ if (e && L.current.useCase === "drivers-license" && Fe.current === "back") {
448
+ try {
449
+ let t = await e.capturePhoto();
450
+ if (!(await d(t.frame))?.text || B.current) return;
451
+ B.current = !0, V.current?.abort(), N.current = t, q(t.method), X(t.diagnostics), Y(t.diagnostics), Q(t.frame, H), U("captured"), await z.current({
452
+ frame: t.frame,
453
+ reason: "manual",
454
+ method: t.method,
455
+ settings: t.settings,
456
+ fallbackReason: t.fallbackReason,
457
+ luminance: t.luminance,
458
+ diagnostics: t.diagnostics
459
+ });
460
+ } catch (e) {
461
+ let t = e instanceof Error ? e : /* @__PURE__ */ Error("Could not capture the camera frame.");
462
+ I.current = !0, J(t.message);
463
+ let n = A.current?.getDiagnostics();
464
+ n && Y(n), N.current?.diagnostics && X(N.current.diagnostics), U("error"), L.current.onError?.(t);
465
+ }
466
+ return;
467
+ }
406
468
  try {
407
- await M.current?.capture();
469
+ await j.current?.capture();
408
470
  } catch (e) {
409
471
  let t = e instanceof Error ? e : /* @__PURE__ */ Error("Could not capture the camera frame.");
410
- L.current = !0, K(t.message);
411
- let n = j.current?.getDiagnostics();
412
- n && q(n), P.current?.diagnostics && J(P.current.diagnostics), H("error"), z.current.onError?.(t);
472
+ I.current = !0, J(t.message);
473
+ let n = A.current?.getDiagnostics();
474
+ n && Y(n), N.current?.diagnostics && X(N.current.diagnostics), U("error"), L.current.onError?.(t);
413
475
  }
414
- }, [$, A]), Ve = _($);
415
- Ve.current = $;
416
- let He = _(!1);
417
- ee(() => {
418
- if (!l || !A) {
419
- He.current = !1;
476
+ }, [
477
+ $,
478
+ Q,
479
+ H,
480
+ k
481
+ ]), Ge = y($);
482
+ Ge.current = $;
483
+ let Ke = y(!1);
484
+ v(() => {
485
+ if (!r || !k) {
486
+ Ke.current = !1;
420
487
  return;
421
488
  }
422
- if (!He.current) {
423
- if (He.current = !0, L.current = !1, K(""), me(void 0), G(void 0), J(void 0), Y("idle"), W(void 0), I.current.clear(), Z(), !r()) {
424
- H("ready");
489
+ if (!Ke.current) {
490
+ if (Ke.current = !0, I.current = !1, J(""), G(void 0), q(void 0), X(void 0), ke("idle"), K(void 0), F.current.clear(), Z(), !s()) {
491
+ U("ready");
425
492
  return;
426
493
  }
427
- Ve.current();
494
+ Ge.current();
428
495
  }
429
496
  }, [
430
- l,
431
- A,
497
+ r,
498
+ k,
432
499
  Z
433
500
  ]);
434
- let Ue = m(() => {
435
- if (L.current = !1, K(""), J(void 0), Y("idle"), W(void 0), I.current.clear(), A) {
501
+ let qe = g(() => {
502
+ if (I.current = !1, B.current = !1, J(""), X(void 0), ke("idle"), G(void 0), K(void 0), F.current.clear(), k) {
436
503
  $();
437
504
  return;
438
505
  }
439
- if (Z(), u === "drivers-license") {
440
- H("starting"), Ce((e) => e + 1);
506
+ if (Z(), p === "drivers-license") {
507
+ U("starting"), Te((e) => e + 1);
441
508
  return;
442
509
  }
443
- let e = j.current;
444
- V?.paused && V.play(), H(e ? "ready" : "starting"), e || Ce((e) => e + 1);
510
+ let e = A.current;
511
+ H?.paused && H.play(), U(e ? "ready" : "starting"), e || Te((e) => e + 1);
445
512
  }, [
446
513
  $,
447
514
  Z,
448
- V,
449
- u,
450
- A
451
- ]), We = m(async (e) => {
452
- let t = j.current;
453
- t && (await t.setTorch(e), q(t.getDiagnostics()));
454
- }, []), Ge = m((e) => {
455
- M.current?.setAutoCapture(e);
456
- }, []), Ke = m(async () => {
457
- let e = de.current, t = j.current?.getDiagnostics() ?? e.diagnostics, r = e.finderStatus, i = n({
515
+ H,
516
+ p,
517
+ k
518
+ ]), Je = g(async (e) => {
519
+ let t = A.current;
520
+ t && (await t.setTorch(e), Y(t.getDiagnostics()));
521
+ }, []), Ye = g((e) => {
522
+ j.current?.setAutoCapture(e);
523
+ }, []), Xe = g(async () => {
524
+ let e = me.current, t = A.current?.getDiagnostics() ?? e.diagnostics, n = e.finderStatus, r = o({
458
525
  error: e.error || void 0,
459
526
  captureMethod: e.captureMethod,
460
- luminance: P.current?.luminance,
461
- fallbackReason: P.current?.fallbackReason,
462
- shutter: e.shutterDiagnostics ?? P.current?.diagnostics,
527
+ luminance: N.current?.luminance,
528
+ fallbackReason: N.current?.fallbackReason,
529
+ shutter: e.shutterDiagnostics ?? N.current?.diagnostics,
463
530
  live: t,
464
- finder: r ? {
465
- state: r.state,
466
- confidence: r.confidence,
467
- stableFrames: r.stableFrames,
468
- requiredStableFrames: r.requiredStableFrames,
469
- detector: r.detector,
470
- modelStatus: r.modelStatus,
471
- modelError: r.modelError,
472
- modelProvider: r.modelProvider,
473
- modelNote: r.modelNote,
474
- inferenceMs: r.inferenceMs,
475
- sourceWidth: r.sourceWidth,
476
- sourceHeight: r.sourceHeight
531
+ finder: n ? {
532
+ state: n.state,
533
+ confidence: n.confidence,
534
+ stableFrames: n.stableFrames,
535
+ requiredStableFrames: n.requiredStableFrames,
536
+ detector: n.detector,
537
+ modelStatus: n.modelStatus,
538
+ modelError: n.modelError,
539
+ modelProvider: n.modelProvider,
540
+ modelNote: n.modelNote,
541
+ inferenceMs: n.inferenceMs,
542
+ sourceWidth: n.sourceWidth,
543
+ sourceHeight: n.sourceHeight
477
544
  } : void 0
478
545
  });
479
546
  try {
480
- if (navigator.clipboard?.writeText) await navigator.clipboard.writeText(i);
547
+ if (navigator.clipboard?.writeText) await navigator.clipboard.writeText(r);
481
548
  else {
482
549
  let e = document.createElement("textarea");
483
- e.value = i, e.setAttribute("readonly", ""), e.style.position = "fixed", e.style.left = "-9999px", document.body.append(e), e.select();
550
+ e.value = r, e.setAttribute("readonly", ""), e.style.position = "fixed", e.style.left = "-9999px", document.body.append(e), e.select();
484
551
  let t = document.execCommand("copy");
485
552
  if (e.remove(), !t) throw Error("Clipboard copy is unavailable.");
486
553
  }
487
- Y("copied");
554
+ ke("copied");
488
555
  } catch {
489
- Y("failed");
556
+ ke("failed");
490
557
  }
491
- }, []), qe = m(() => de.current, []), Je = te(() => ({
492
- capture: Be,
493
- cancel: Re,
494
- retry: Ue,
495
- setTorch: We,
496
- setAutoCapture: Ge,
497
- copyReport: Ke,
498
- getState: qe
558
+ }, []), Ze = g(() => me.current, []), Qe = ne(() => ({
559
+ capture: We,
560
+ cancel: He,
561
+ retry: qe,
562
+ setTorch: Je,
563
+ setAutoCapture: Ye,
564
+ copyReport: Xe,
565
+ getState: Ze
499
566
  }), [
500
- Be,
501
- Re,
502
- Ue,
503
567
  We,
504
- Ge,
505
- Ke,
506
- qe
568
+ He,
569
+ qe,
570
+ Je,
571
+ Ye,
572
+ Xe,
573
+ Ze
507
574
  ]);
508
- g(() => {
509
- if (k) return k.current = Je, () => {
510
- k.current = null;
575
+ _(() => {
576
+ if (O) return O.current = Qe, () => {
577
+ O.current = null;
511
578
  };
512
- }, [Je, k]);
513
- let Ye = {
514
- ...Le,
515
- ...Je,
516
- bindPreview: Ie
579
+ }, [Qe, O]);
580
+ let $e = {
581
+ ...Ve,
582
+ ...Qe,
583
+ bindPreview: Be
517
584
  };
518
- return /* @__PURE__ */ b(re.Provider, {
519
- value: Ye,
520
- children: ce
585
+ return /* @__PURE__ */ S(ae.Provider, {
586
+ value: $e,
587
+ children: de
521
588
  });
522
589
  }
523
590
  //#endregion
524
591
  //#region src/react/hooks.ts
525
592
  function E() {
526
- return _(null);
593
+ return y(null);
527
594
  }
528
595
  function D() {
529
- let e = h(re);
596
+ let e = te(ae);
530
597
  if (!e) throw Error("useScanner must be used within ScannerProvider.");
531
598
  return e;
532
599
  }
533
600
  //#endregion
534
601
  //#region src/live-overlay-geometry.ts
535
- function O(e, t, n, r, i) {
602
+ function ue(e, t, n, r, i) {
536
603
  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;
537
604
  if (i === "contain") return {
538
605
  viewBox: `0 0 ${a} ${o}`,
@@ -541,9 +608,9 @@ function O(e, t, n, r, i) {
541
608
  offsetX: f,
542
609
  offsetY: p
543
610
  };
544
- let m = s / d, h = c / d;
611
+ let m = s / d, ee = c / d;
545
612
  return {
546
- viewBox: `${-f / d} ${-p / d} ${m} ${h}`,
613
+ viewBox: `${-f / d} ${-p / d} ${m} ${ee}`,
547
614
  preserveAspectRatio: "none",
548
615
  scale: d,
549
616
  offsetX: f,
@@ -552,10 +619,10 @@ function O(e, t, n, r, i) {
552
619
  }
553
620
  //#endregion
554
621
  //#region src/components/ModelDownloadRing.tsx
555
- function se({ snapshot: e }) {
622
+ function O({ snapshot: e }) {
556
623
  if (!e.downloading) return null;
557
624
  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;
558
- return /* @__PURE__ */ x("div", {
625
+ return /* @__PURE__ */ C("div", {
559
626
  className: `model-download-ring${t === null ? " is-indeterminate" : ""}`,
560
627
  role: "progressbar",
561
628
  "aria-label": "Model download",
@@ -564,15 +631,15 @@ function se({ snapshot: e }) {
564
631
  "aria-valuenow": n ?? void 0,
565
632
  "data-loaded": e.loaded,
566
633
  "data-total": e.total ?? "",
567
- children: [/* @__PURE__ */ x("svg", {
634
+ children: [/* @__PURE__ */ C("svg", {
568
635
  viewBox: "0 0 72 72",
569
636
  "aria-hidden": "true",
570
- children: [/* @__PURE__ */ b("circle", {
637
+ children: [/* @__PURE__ */ S("circle", {
571
638
  className: "track",
572
639
  cx: "36",
573
640
  cy: "36",
574
641
  r: 28
575
- }), /* @__PURE__ */ b("circle", {
642
+ }), /* @__PURE__ */ S("circle", {
576
643
  className: "value",
577
644
  cx: "36",
578
645
  cy: "36",
@@ -580,13 +647,18 @@ function se({ snapshot: e }) {
580
647
  strokeDasharray: t === null ? void 0 : `${r} ${r}`,
581
648
  strokeDashoffset: t === null ? void 0 : r * (1 - t)
582
649
  })]
583
- }), n === null ? /* @__PURE__ */ b("strong", {
650
+ }), n === null ? /* @__PURE__ */ S("strong", {
584
651
  className: "model-download-ring__pending",
585
652
  children: "…"
586
- }) : /* @__PURE__ */ x("strong", { children: [n, "%"] })]
653
+ }) : /* @__PURE__ */ C("strong", { children: [n, "%"] })]
587
654
  });
588
655
  }
589
656
  //#endregion
657
+ //#region src/react/guidance.ts
658
+ function de(e) {
659
+ if (!(e.usingSystemCamera || e.licenseBusy) && e.phase !== "error") return e.phase === "starting" ? e.licenseHeadline : e.phase === "capturing" ? "Capturing full resolution…" : e.phase === "captured" ? "Document captured" : e.holdStillSeconds && e.holdStillSeconds > 0 ? m(e.holdStillSeconds) : e.guidanceHint && e.guidanceReason && e.guidanceReason !== "place-document" ? e.guidanceHint : e.licenseHeadline ?? e.guidanceHint ?? "Place the document in the frame";
660
+ }
661
+ //#endregion
590
662
  //#region src/react/parts.tsx
591
663
  var k = {
592
664
  primaryColorHex: "--scanner-overlay-primary",
@@ -596,7 +668,7 @@ var k = {
596
668
  readyColorHex: "--scanner-overlay-ready",
597
669
  capturedColorHex: "--scanner-overlay-captured"
598
670
  };
599
- function ce(e) {
671
+ function A(e) {
600
672
  if (!e) return;
601
673
  let t = {};
602
674
  for (let [n, r] of Object.entries(k)) {
@@ -605,37 +677,37 @@ function ce(e) {
605
677
  }
606
678
  return Object.keys(t).length > 0 ? t : void 0;
607
679
  }
608
- function A({ theme: e, style: t, title: n, children: r }) {
680
+ function j({ theme: e, style: t, title: n, children: r }) {
609
681
  let i = D();
610
682
  if (!i.open) return null;
611
- let a = n ?? (i.useCase === "drivers-license" ? "Scan a driver’s license" : "Scan a document"), o = ce(e), s = o ? {
683
+ let a = n ?? (i.useCase === "drivers-license" ? "Scan a driver’s license" : "Scan a document"), o = A(e), s = o ? {
612
684
  ...t,
613
685
  ...o
614
686
  } : t;
615
- return /* @__PURE__ */ x("div", {
687
+ return /* @__PURE__ */ C("div", {
616
688
  className: `scanner-camera-overlay ${i.phase === "captured" || i.finderStatus?.state === "captured" ? "is-captured" : ""} ${i.usingSystemCamera ? "is-system-camera" : ""}`.trim(),
617
689
  style: s,
618
690
  role: "dialog",
619
691
  "aria-modal": "true",
620
692
  "aria-label": a,
621
- children: [r, /* @__PURE__ */ b(R, {})]
693
+ children: [r, /* @__PURE__ */ S(R, {})]
622
694
  });
623
695
  }
624
- function j() {
625
- let { bindPreview: e, frozenPreviewUrl: t, usingSystemCamera: n } = D(), r = _(null), i = m((t) => {
696
+ function M() {
697
+ let { bindPreview: e, frozenPreviewUrl: t, usingSystemCamera: n } = D(), r = y(null), i = g((t) => {
626
698
  r.current = t, e(t);
627
699
  }, [e]);
628
- return g(() => {
700
+ return _(() => {
629
701
  t && r.current?.pause();
630
- }, [t]), n ? t ? /* @__PURE__ */ b("img", {
702
+ }, [t]), n ? t ? /* @__PURE__ */ S("img", {
631
703
  src: t,
632
704
  className: "scanner-camera-overlay__video scanner-camera-overlay__still",
633
705
  alt: "",
634
706
  "aria-label": "Captured document"
635
- }) : /* @__PURE__ */ b("div", {
707
+ }) : /* @__PURE__ */ S("div", {
636
708
  className: "scanner-camera-overlay__video",
637
709
  "aria-hidden": "true"
638
- }) : /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b("video", {
710
+ }) : /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ S("video", {
639
711
  ref: i,
640
712
  className: "scanner-camera-overlay__video",
641
713
  muted: !0,
@@ -644,134 +716,128 @@ function j() {
644
716
  style: { objectFit: "cover" },
645
717
  "aria-hidden": !!t,
646
718
  "aria-label": "Rear camera preview"
647
- }), t ? /* @__PURE__ */ b("img", {
719
+ }), t ? /* @__PURE__ */ S("img", {
648
720
  src: t,
649
721
  className: "scanner-camera-overlay__video scanner-camera-overlay__still",
650
722
  alt: "",
651
723
  "aria-label": "Captured document"
652
724
  }) : null] });
653
725
  }
654
- function M() {
726
+ function N() {
655
727
  let { finderStatus: e, displayQuad: t, previewSize: n } = D();
656
728
  if (!t || !e?.sourceWidth || !e.sourceHeight) return null;
657
- let r = O(e.sourceWidth, e.sourceHeight, n.width, n.height, "cover");
658
- return /* @__PURE__ */ b("svg", {
729
+ let r = ue(e.sourceWidth, e.sourceHeight, n.width, n.height, "cover");
730
+ return /* @__PURE__ */ S("svg", {
659
731
  className: `scanner-camera-overlay__quad ${e.state}`,
660
732
  viewBox: r.viewBox,
661
733
  preserveAspectRatio: r.preserveAspectRatio,
662
734
  "aria-label": `${e.state} document boundary`,
663
- children: /* @__PURE__ */ b("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}` })
735
+ children: /* @__PURE__ */ S("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}` })
664
736
  });
665
737
  }
666
- function N({ title: e }) {
667
- let { phase: t, guidanceHint: n, cancel: r, usingSystemCamera: i, useCase: a, licenseSide: o, licenseBusy: s } = D(), c = a === "drivers-license" ? u(o ?? "front", i) : void 0, l = e ?? c?.title ?? "Scan a document";
668
- return /* @__PURE__ */ x("div", {
738
+ function P({ title: e }) {
739
+ let { phase: t, cancel: n, usingSystemCamera: r, useCase: i, licenseSide: a, licenseBusy: o } = D(), s = i === "drivers-license" ? p(a ?? "front", r) : void 0, c = e ?? s?.title ?? "Scan a document";
740
+ return /* @__PURE__ */ C("div", {
669
741
  className: "scanner-camera-overlay__topbar",
670
- children: [/* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("strong", { children: l }), /* @__PURE__ */ x("span", {
742
+ children: [/* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S("strong", { children: c }), /* @__PURE__ */ C("span", {
671
743
  "aria-live": "polite",
672
744
  children: [
673
- s && (o === "back" ? "Reading the barcode…" : "Reading the front…"),
674
- !s && c && /* @__PURE__ */ x(y, { children: [t === "error" && (o === "back" ? "Could not read the back" : "Could not read the front"), t !== "error" && c.headline] }),
675
- !s && !c && i && /* @__PURE__ */ x(y, { children: [
745
+ o && (a === "back" ? "Reading the barcode…" : "Reading the front…"),
746
+ !o && s && t === "error" && (a === "back" ? "Could not read the back" : "Could not read the front"),
747
+ !o && !s && r && /* @__PURE__ */ C(x, { children: [
676
748
  t === "starting" && "Preparing the system camera…",
677
749
  t === "ready" && "Take a photo. There is no live document guide.",
678
750
  t === "capturing" && "Looking for a document…",
679
751
  t === "captured" && "Document captured",
680
752
  t === "error" && "No document found"
681
753
  ] }),
682
- !s && !c && !i && /* @__PURE__ */ x(y, { children: [
683
- t === "starting" && "Starting rear camera…",
684
- t === "ready" && (n ?? "Place the document in the frame"),
685
- t === "capturing" && "Capturing full resolution…",
686
- t === "captured" && "Document captured",
687
- t === "error" && "Camera unavailable"
688
- ] })
754
+ !o && !s && !r && t === "error" && "Camera unavailable"
689
755
  ]
690
- })] }), /* @__PURE__ */ b("button", {
756
+ })] }), /* @__PURE__ */ S("button", {
691
757
  type: "button",
692
- onClick: r,
758
+ onClick: n,
693
759
  "aria-label": "Close camera",
694
760
  children: "×"
695
761
  })]
696
762
  });
697
763
  }
698
- function P() {
699
- let { phase: e, error: t, diagnostics: n, copyState: r, retry: i, copyReport: a, cancel: o, usingSystemCamera: s, frozenPreviewUrl: c, useCase: l, licenseSide: d, licenseBusy: f } = D(), p = l === "drivers-license" ? u(d ?? "front", s) : void 0;
700
- return e === "error" ? /* @__PURE__ */ x("div", {
764
+ function F() {
765
+ let { phase: e, error: t, diagnostics: n, copyState: r, retry: i, copyReport: a, cancel: o, usingSystemCamera: s, frozenPreviewUrl: c, useCase: l, licenseSide: u, licenseBusy: d } = D(), f = l === "drivers-license" ? p(u ?? "front", s) : void 0;
766
+ return e === "error" ? /* @__PURE__ */ C("div", {
701
767
  className: "scanner-camera-overlay__message",
702
768
  role: "alert",
703
769
  children: [
704
- /* @__PURE__ */ b("strong", { children: p ? d === "back" ? "Could not read the back" : "Could not read the front" : s ? c ? "No document found" : "Could not take a photo" : n ? "Capture failed" : "Could not open the camera" }),
705
- /* @__PURE__ */ b("p", { children: t }),
706
- /* @__PURE__ */ x("div", { children: [
707
- /* @__PURE__ */ b("button", {
770
+ /* @__PURE__ */ S("strong", { children: f ? u === "back" ? "Could not read the back" : "Could not read the front" : s ? c ? "No document found" : "Could not take a photo" : n ? "Capture failed" : "Could not open the camera" }),
771
+ /* @__PURE__ */ S("p", { children: t }),
772
+ /* @__PURE__ */ C("div", { children: [
773
+ /* @__PURE__ */ S("button", {
708
774
  type: "button",
709
775
  onClick: i,
710
776
  children: "Try again"
711
777
  }),
712
- /* @__PURE__ */ b("button", {
778
+ /* @__PURE__ */ S("button", {
713
779
  type: "button",
714
780
  onClick: () => void a(),
715
781
  children: r === "copied" ? "Copied" : r === "failed" ? "Copy failed" : "Copy report"
716
782
  }),
717
- /* @__PURE__ */ b("button", {
783
+ /* @__PURE__ */ S("button", {
718
784
  type: "button",
719
785
  onClick: o,
720
786
  children: "Cancel"
721
787
  })
722
788
  ] })
723
789
  ]
724
- }) : f ? /* @__PURE__ */ x("div", {
790
+ }) : d ? /* @__PURE__ */ C("div", {
725
791
  className: "scanner-camera-overlay__message",
726
792
  "aria-live": "polite",
727
793
  children: [
728
- /* @__PURE__ */ b("span", { className: "scanner-camera-overlay__spinner" }),
729
- /* @__PURE__ */ b("strong", { children: d === "back" ? "Reading the barcode" : "Reading the front" }),
730
- /* @__PURE__ */ b("p", { children: d === "back" ? "Decoding the AAMVA PDF417 on the back." : "Finding the card and reading the front with OCR." })
794
+ /* @__PURE__ */ S("span", { className: "scanner-camera-overlay__spinner" }),
795
+ /* @__PURE__ */ S("strong", { children: u === "back" ? "Reading the barcode" : "Reading the front" }),
796
+ /* @__PURE__ */ S("p", { children: u === "back" ? "Decoding the AAMVA PDF417 on the back." : "Finding the card and reading the front with OCR." })
731
797
  ]
732
- }) : s && e === "capturing" && !c ? /* @__PURE__ */ x("div", {
798
+ }) : s && e === "capturing" && !c ? /* @__PURE__ */ C("div", {
733
799
  className: "scanner-camera-overlay__message",
734
800
  "aria-live": "polite",
735
801
  children: [
736
- /* @__PURE__ */ b("span", { className: "scanner-camera-overlay__spinner" }),
737
- /* @__PURE__ */ b("strong", { children: p ? p.headline : "Opening the system camera" }),
738
- /* @__PURE__ */ b("p", { children: p ? p.detail : "There is no live document guide. We find the page after you take the photo." })
802
+ /* @__PURE__ */ S("span", { className: "scanner-camera-overlay__spinner" }),
803
+ /* @__PURE__ */ S("strong", { children: f ? f.headline : "Opening the system camera" }),
804
+ /* @__PURE__ */ S("p", { children: f ? f.detail : "There is no live document guide. We find the page after you take the photo." })
739
805
  ]
740
- }) : s && e === "ready" && !c ? /* @__PURE__ */ x("div", {
806
+ }) : s && e === "ready" && !c ? /* @__PURE__ */ C("div", {
741
807
  className: "scanner-camera-overlay__message",
742
808
  "aria-live": "polite",
743
- children: [/* @__PURE__ */ b("strong", { children: p ? p.headline : "System camera" }), /* @__PURE__ */ b("p", { children: p ? p.detail : "Tap the shutter to open the Camera app. There is no live document guide." })]
744
- }) : e === "starting" && !s ? /* @__PURE__ */ x("div", {
809
+ children: [/* @__PURE__ */ S("strong", { children: f ? f.headline : "System camera" }), /* @__PURE__ */ S("p", { children: f ? f.detail : "Tap the shutter to open the Camera app. There is no live document guide." })]
810
+ }) : e === "starting" && !s ? /* @__PURE__ */ C("div", {
745
811
  className: "scanner-camera-overlay__message",
746
812
  "aria-live": "polite",
747
813
  children: [
748
- /* @__PURE__ */ b("span", { className: "scanner-camera-overlay__spinner" }),
749
- /* @__PURE__ */ b("strong", { children: "Requesting the highest practical resolution" }),
750
- /* @__PURE__ */ b("p", { children: "Allow camera access to continue." })
814
+ /* @__PURE__ */ S("span", { className: "scanner-camera-overlay__spinner" }),
815
+ /* @__PURE__ */ S("strong", { children: "Requesting the highest practical resolution" }),
816
+ /* @__PURE__ */ S("p", { children: "Allow camera access to continue." })
751
817
  ]
752
818
  }) : null;
753
819
  }
754
- function F() {
820
+ function I() {
755
821
  let { finderStatus: e, detectorStatus: t, settings: n, usingSystemCamera: r, captureMethod: i, phase: a, useCase: o, licenseSide: s } = D(), c = n?.width, l = n?.height, u = o === "drivers-license" ? ` · ${s === "back" ? "back" : "front"}` : "";
756
- return r ? /* @__PURE__ */ b("div", {
822
+ return r ? /* @__PURE__ */ S("div", {
757
823
  className: "scanner-camera-overlay__status",
758
824
  "aria-live": "polite",
759
- children: /* @__PURE__ */ x("div", {
825
+ children: /* @__PURE__ */ C("div", {
760
826
  className: "scanner-camera-overlay__status-line",
761
827
  children: [
762
- /* @__PURE__ */ b("span", { className: a === "captured" ? "ready" : a === "error" ? "seeking" : "detecting" }),
828
+ /* @__PURE__ */ S("span", { className: a === "captured" ? "ready" : a === "error" ? "seeking" : "detecting" }),
763
829
  i === "system-camera" ? "system camera" : "system camera · waiting",
764
830
  u,
765
831
  c && l ? ` · ${c}×${l}` : ""
766
832
  ]
767
833
  })
768
- }) : /* @__PURE__ */ b("div", {
834
+ }) : /* @__PURE__ */ S("div", {
769
835
  className: "scanner-camera-overlay__status",
770
836
  "aria-live": "polite",
771
- children: /* @__PURE__ */ x("div", {
837
+ children: /* @__PURE__ */ C("div", {
772
838
  className: "scanner-camera-overlay__status-line",
773
839
  children: [
774
- /* @__PURE__ */ b("span", { className: e?.state ?? "detecting" }),
840
+ /* @__PURE__ */ S("span", { className: e?.state ?? "detecting" }),
775
841
  e?.state ?? "detecting",
776
842
  u,
777
843
  e ? ` · ${Math.round(e.confidence * 100)}% · ${e.stableFrames}/${e.requiredStableFrames}` : "",
@@ -782,82 +848,98 @@ function F() {
782
848
  })
783
849
  });
784
850
  }
785
- function I() {
786
- let { diagnostics: e, shutterDiagnostics: t, captureMethod: n, copyState: r, copyReport: i } = D(), a = e?.engine ?? l();
787
- return /* @__PURE__ */ x("dl", {
851
+ function fe() {
852
+ let { diagnostics: e, shutterDiagnostics: t, captureMethod: n, copyState: i, copyReport: a } = D(), o = e?.engine ?? r();
853
+ return /* @__PURE__ */ C("dl", {
788
854
  className: "scanner-camera-overlay__diagnostics",
789
855
  "aria-label": "Camera diagnostics",
790
856
  children: [
791
- /* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("dt", { children: "engine" }), /* @__PURE__ */ x("dd", { children: [
792
- a.engine,
857
+ /* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S("dt", { children: "engine" }), /* @__PURE__ */ C("dd", { children: [
858
+ o.engine,
793
859
  "/",
794
- a.browser,
795
- a.iosWebKit ? " ios" : ""
860
+ o.browser,
861
+ o.iosWebKit ? " ios" : ""
796
862
  ] })] }),
797
- /* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("dt", { children: "video" }), /* @__PURE__ */ b("dd", { children: e ? `${e.videoWidth}×${e.videoHeight} rs${e.readyState}${e.paused ? " paused" : ""}${e.rendered ? "" : " hidden"}` : "starting" })] }),
798
- /* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("dt", { children: "track" }), /* @__PURE__ */ b("dd", { children: e ? `${e.trackReadyState}${e.trackMuted ? " muted" : ""}${e.trackEnabled ? "" : " disabled"}` : "—" })] }),
799
- /* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("dt", { children: "torch" }), /* @__PURE__ */ b("dd", { children: e ? `${e.torch.mode} · ${e.torch.supported ? e.torch.on ? "on" : "off" : "unsupported"}` : "starting" })] }),
800
- /* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("dt", { children: "luma" }), /* @__PURE__ */ b("dd", { children: e ? `live ${e.liveLuminance.toFixed(1)} · mirror ${e.mirrorLuminance.toFixed(1)}${Number.isFinite(e.mirrorAgeMs) ? ` (${Math.round(e.mirrorAgeMs)}ms)` : " (none)"}` : "—" })] }),
801
- /* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("dt", { children: "path" }), /* @__PURE__ */ b("dd", { children: n ?? "video-frame / live-mirror" })] }),
802
- t ? /* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("dt", { children: "shutter" }), /* @__PURE__ */ b("dd", { children: `live ${t.liveLuminance.toFixed(1)} · mirror ${t.mirrorLuminance.toFixed(1)}${Number.isFinite(t.mirrorAgeMs) ? ` (${Math.round(t.mirrorAgeMs)}ms)` : " (none)"}` })] }) : null,
803
- /* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("dt", { children: "share" }), /* @__PURE__ */ b("dd", { children: /* @__PURE__ */ b("button", {
863
+ /* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S("dt", { children: "video" }), /* @__PURE__ */ S("dd", { children: e ? `${e.videoWidth}×${e.videoHeight} rs${e.readyState}${e.paused ? " paused" : ""}${e.rendered ? "" : " hidden"}` : "starting" })] }),
864
+ /* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S("dt", { children: "track" }), /* @__PURE__ */ S("dd", { children: e ? `${e.trackReadyState}${e.trackMuted ? " muted" : ""}${e.trackEnabled ? "" : " disabled"}` : "—" })] }),
865
+ /* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S("dt", { children: "torch" }), /* @__PURE__ */ S("dd", { children: e ? `${e.torch.mode} · ${e.torch.supported ? e.torch.on ? "on" : "off" : "unsupported"}` : "starting" })] }),
866
+ /* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S("dt", { children: "luma" }), /* @__PURE__ */ S("dd", { children: e ? `live ${e.liveLuminance.toFixed(1)} · mirror ${e.mirrorLuminance.toFixed(1)}${Number.isFinite(e.mirrorAgeMs) ? ` (${Math.round(e.mirrorAgeMs)}ms)` : " (none)"}` : "—" })] }),
867
+ /* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S("dt", { children: "path" }), /* @__PURE__ */ S("dd", { children: n ?? "video-frame / live-mirror" })] }),
868
+ t ? /* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S("dt", { children: "shutter" }), /* @__PURE__ */ S("dd", { children: `live ${t.liveLuminance.toFixed(1)} · mirror ${t.mirrorLuminance.toFixed(1)}${Number.isFinite(t.mirrorAgeMs) ? ` (${Math.round(t.mirrorAgeMs)}ms)` : " (none)"}` })] }) : null,
869
+ /* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S("dt", { children: "share" }), /* @__PURE__ */ S("dd", { children: /* @__PURE__ */ S("button", {
804
870
  type: "button",
805
871
  className: "scanner-camera-overlay__copy",
806
- onClick: () => void i(),
807
- children: r === "copied" ? "Copied report" : r === "failed" ? "Copy failed" : "Copy report"
872
+ onClick: () => void a(),
873
+ children: i === "copied" ? "Copied report" : i === "failed" ? "Copy failed" : "Copy report"
808
874
  }) })] })
809
875
  ]
810
876
  });
811
877
  }
812
878
  function L() {
813
- let { autoCapture: e, phase: t, finderStatus: n, diagnostics: r, captureMethod: i, settings: a, cancel: o, capture: s, setAutoCapture: c, setTorch: l, usingSystemCamera: u, licenseBusy: d } = D(), f = a?.width, p = a?.height;
814
- return /* @__PURE__ */ x("div", {
879
+ let { autoCapture: e, phase: t, finderStatus: n, diagnostics: r, captureMethod: i, settings: a, cancel: o, capture: s, setAutoCapture: c, setTorch: l, usingSystemCamera: u, licenseBusy: d, useCase: f, licenseSide: m, guidanceHint: ee } = D(), h = a?.width, g = a?.height, te = u ? t === "ready" : e !== "only", _ = f === "drivers-license" ? p(m ?? "front", u) : void 0, v = de({
880
+ usingSystemCamera: u,
881
+ phase: t,
882
+ licenseBusy: d,
883
+ holdStillSeconds: n?.holdStillSeconds,
884
+ guidanceHint: ee,
885
+ guidanceReason: n?.guidance.reason,
886
+ licenseHeadline: _?.headline
887
+ }), ne = !!n?.holdStillSeconds;
888
+ return /* @__PURE__ */ C("div", {
815
889
  className: "scanner-camera-overlay__controls",
816
890
  children: [
817
- /* @__PURE__ */ b("button", {
891
+ /* @__PURE__ */ S("button", {
818
892
  type: "button",
819
893
  className: "scanner-camera-overlay__cancel",
820
894
  onClick: o,
821
895
  children: "Cancel"
822
896
  }),
823
- /* @__PURE__ */ x("div", {
897
+ /* @__PURE__ */ C("div", {
824
898
  className: "scanner-camera-overlay__capture",
825
- children: [(u ? t === "ready" : e !== "only") && /* @__PURE__ */ b("button", {
826
- type: "button",
827
- className: "scanner-camera-overlay__shutter",
828
- onClick: () => void s(),
829
- disabled: t !== "ready" || !!d,
830
- "aria-label": u ? "Take a photo with the system camera" : "Capture full-resolution photo",
831
- children: /* @__PURE__ */ b("span", {})
832
- }), !u && /* @__PURE__ */ x("div", {
833
- className: "scanner-camera-overlay__toggles",
834
- children: [n?.autoCapture.visible && /* @__PURE__ */ x("label", { children: [/* @__PURE__ */ b("input", {
835
- type: "checkbox",
836
- checked: n.autoCapture.checked,
837
- onChange: (e) => c(e.target.checked)
838
- }), "Auto-capture"] }), r?.torch.visible && /* @__PURE__ */ x("label", {
839
- title: r.torch.automatic ? "Torch is controlled automatically from scene brightness" : void 0,
840
- children: [/* @__PURE__ */ b("input", {
899
+ children: [
900
+ v && /* @__PURE__ */ S("p", {
901
+ className: `scanner-camera-overlay__guidance${ne ? " is-ready" : ""}`,
902
+ "aria-live": "polite",
903
+ children: v
904
+ }),
905
+ te && /* @__PURE__ */ S("button", {
906
+ type: "button",
907
+ className: "scanner-camera-overlay__shutter",
908
+ onClick: () => void s(),
909
+ disabled: t !== "ready" || !!d,
910
+ "aria-label": u ? "Take a photo with the system camera" : "Capture full-resolution photo",
911
+ children: /* @__PURE__ */ S("span", {})
912
+ }),
913
+ !u && /* @__PURE__ */ C("div", {
914
+ className: "scanner-camera-overlay__toggles",
915
+ children: [n?.autoCapture.visible && /* @__PURE__ */ C("label", { children: [/* @__PURE__ */ S("input", {
841
916
  type: "checkbox",
842
- checked: r.torch.on,
843
- disabled: !r.torch.mutable,
844
- onChange: (e) => void l(e.target.checked)
845
- }), r.torch.automatic ? "Auto torch" : "Torch"]
846
- })]
847
- })]
917
+ checked: n.autoCapture.checked,
918
+ onChange: (e) => c(e.target.checked)
919
+ }), "Auto-capture"] }), r?.torch.visible && /* @__PURE__ */ C("label", {
920
+ title: r.torch.automatic ? "Torch is controlled automatically from scene brightness" : void 0,
921
+ children: [/* @__PURE__ */ S("input", {
922
+ type: "checkbox",
923
+ checked: r.torch.on,
924
+ disabled: !r.torch.mutable,
925
+ onChange: (e) => void l(e.target.checked)
926
+ }), r.torch.automatic ? "Auto torch" : "Torch"]
927
+ })]
928
+ })
929
+ ]
848
930
  }),
849
- /* @__PURE__ */ x("div", {
931
+ /* @__PURE__ */ C("div", {
850
932
  className: "scanner-camera-overlay__quality",
851
- children: [/* @__PURE__ */ b("span", { children: u ? "System camera" : i === "live-mirror" ? "Mirror" : "Camera" }), /* @__PURE__ */ b("strong", { children: f && p ? `${f} × ${p}` : u ? "Tap to photograph" : "Measuring…" })]
933
+ children: [/* @__PURE__ */ S("span", { children: u ? "System camera" : i === "live-mirror" ? "Mirror" : "Camera" }), /* @__PURE__ */ S("strong", { children: h && g ? `${h} × ${g}` : u ? "Tap to photograph" : "Measuring…" })]
852
934
  })
853
935
  ]
854
936
  });
855
937
  }
856
938
  function R({ snapshot: e }) {
857
939
  let { modelDownload: t } = D();
858
- return /* @__PURE__ */ b(se, { snapshot: e ?? t });
940
+ return /* @__PURE__ */ S(O, { snapshot: e ?? t });
859
941
  }
860
942
  //#endregion
861
- export { L as ScannerControls, I as ScannerDiagnostics, A as ScannerFrame, R as ScannerModelDownload, P as ScannerNotice, j as ScannerPreview, T as ScannerProvider, M as ScannerQuad, F as ScannerStatus, N as ScannerTopBar, D as useScanner, E as useScannerRef };
943
+ export { L as ScannerControls, fe as ScannerDiagnostics, j as ScannerFrame, R as ScannerModelDownload, F as ScannerNotice, M as ScannerPreview, le as ScannerProvider, N as ScannerQuad, I as ScannerStatus, P as ScannerTopBar, D as useScanner, E as useScannerRef };
862
944
 
863
945
  //# sourceMappingURL=react.js.map