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