@exige/web-scanner-sdk 0.2.33 → 0.2.36

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