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