@exige/web-scanner-sdk 0.2.30 → 0.2.31

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