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