@exige/web-scanner-sdk 0.2.29 → 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-CKMrW8dP.js → driver-license-yM6pBkNk.js} +314 -302
- 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 +380 -362
- 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-CKMrW8dP.js.map +0 -1
|
@@ -1183,11 +1183,19 @@ function vt(e, t) {
|
|
|
1183
1183
|
function yt(e, t) {
|
|
1184
1184
|
return t.castShadow && (e.reason === "hold-still" || e.reason === "ready") ? t.hint ?? e.hint : e.hint;
|
|
1185
1185
|
}
|
|
1186
|
-
|
|
1186
|
+
function bt(e, t, n) {
|
|
1187
|
+
if (n <= 0) return 0;
|
|
1188
|
+
let r = n - (t - e);
|
|
1189
|
+
return r <= 0 ? 0 : Math.max(1, Math.ceil(r / 1e3));
|
|
1190
|
+
}
|
|
1191
|
+
function xt(e) {
|
|
1192
|
+
return `Hold still for ${e}…`;
|
|
1193
|
+
}
|
|
1194
|
+
async function St(e, t) {
|
|
1187
1195
|
let n = await e();
|
|
1188
1196
|
return t(), n;
|
|
1189
1197
|
}
|
|
1190
|
-
function
|
|
1198
|
+
function Ct(e) {
|
|
1191
1199
|
return e === "alwaysOn" || e === "only" ? {
|
|
1192
1200
|
visible: !1,
|
|
1193
1201
|
checked: !0,
|
|
@@ -1210,19 +1218,19 @@ function z(e) {
|
|
|
1210
1218
|
e.bottomLeft
|
|
1211
1219
|
];
|
|
1212
1220
|
}
|
|
1213
|
-
var
|
|
1214
|
-
function
|
|
1221
|
+
var wt = 3e3, Tt = 1600;
|
|
1222
|
+
function Et(e = k()) {
|
|
1215
1223
|
return e.iosWebKit ? {
|
|
1216
1224
|
intervalMs: 70,
|
|
1217
1225
|
maxFrameDimension: 720,
|
|
1218
1226
|
maxAnalysisDimension: 720
|
|
1219
1227
|
} : {
|
|
1220
1228
|
intervalMs: 140,
|
|
1221
|
-
maxFrameDimension:
|
|
1229
|
+
maxFrameDimension: Tt,
|
|
1222
1230
|
maxAnalysisDimension: 520
|
|
1223
1231
|
};
|
|
1224
1232
|
}
|
|
1225
|
-
function
|
|
1233
|
+
function Dt(e, t) {
|
|
1226
1234
|
let n = e.status === "success" && e.modelStatus !== "failed", r = {
|
|
1227
1235
|
status: e.status,
|
|
1228
1236
|
confidence: Number(e.confidence.toFixed(3)),
|
|
@@ -1245,7 +1253,7 @@ function wt(e, t) {
|
|
|
1245
1253
|
detail: r
|
|
1246
1254
|
};
|
|
1247
1255
|
}
|
|
1248
|
-
function
|
|
1256
|
+
function Ot(e) {
|
|
1249
1257
|
let t = 0;
|
|
1250
1258
|
for (let n = 0; n < e.length; n += 1) {
|
|
1251
1259
|
let r = e[n], i = e[(n + 1) % e.length];
|
|
@@ -1263,23 +1271,23 @@ var V = {
|
|
|
1263
1271
|
areaFill: 0,
|
|
1264
1272
|
aspectRatio: 1
|
|
1265
1273
|
};
|
|
1266
|
-
function
|
|
1274
|
+
function kt(e, t, n) {
|
|
1267
1275
|
let r = z(e), i = r.map(({ x: e }) => e), a = r.map(({ y: e }) => e), o = (Math.max(...i) - Math.min(...i)) / Math.max(1, t), s = (Math.max(...a) - Math.min(...a)) / Math.max(1, n), [c, l, u, d] = r, f = Math.max(B(c, l), B(d, u)), p = Math.max(B(c, d), B(l, u));
|
|
1268
1276
|
return {
|
|
1269
1277
|
widthFill: o,
|
|
1270
1278
|
heightFill: s,
|
|
1271
1279
|
limitingFill: Math.max(o, s),
|
|
1272
|
-
areaFill:
|
|
1280
|
+
areaFill: Ot(r) / Math.max(1, t * n),
|
|
1273
1281
|
aspectRatio: Math.max(f, p) / Math.max(1, Math.min(f, p))
|
|
1274
1282
|
};
|
|
1275
1283
|
}
|
|
1276
|
-
function
|
|
1284
|
+
function At(e, t, n, r = {}) {
|
|
1277
1285
|
let i = t ? r.exitFillRatio ?? .64 : r.minFillRatio ?? .72, a = r.highAspectRatio ?? 2.2;
|
|
1278
1286
|
if (e.aspectRatio < a) return i;
|
|
1279
1287
|
let o = t ? r.highAspectExitFillRatio : r.highAspectFillRatio;
|
|
1280
1288
|
return Math.min(o ?? i + .08, 1 - n * 2);
|
|
1281
1289
|
}
|
|
1282
|
-
function
|
|
1290
|
+
function jt(e, t, n = {}) {
|
|
1283
1291
|
let r = n.confidenceThreshold ?? .72;
|
|
1284
1292
|
if (e.status !== "success" || !e.quad || e.confidence < r || !e.sourceWidth || !e.sourceHeight) return {
|
|
1285
1293
|
hint: "Place the document in the frame",
|
|
@@ -1288,7 +1296,7 @@ function Ot(e, t, n = {}) {
|
|
|
1288
1296
|
fill: V,
|
|
1289
1297
|
readyForAutoCapture: !1
|
|
1290
1298
|
};
|
|
1291
|
-
let i = z(e.quad), a =
|
|
1299
|
+
let i = z(e.quad), a = kt(e.quad, e.sourceWidth, e.sourceHeight), o = a.limitingFill, s = t.previouslyReady ? n.exitEdgeMarginRatio ?? .005 : n.edgeMarginRatio ?? .015, c = e.sourceWidth * s, l = e.sourceHeight * s;
|
|
1292
1300
|
if (i.some(({ x: t, y: n }) => t <= c || t >= e.sourceWidth - c || n <= l || n >= e.sourceHeight - l)) return {
|
|
1293
1301
|
hint: "Move farther away",
|
|
1294
1302
|
reason: "move-farther-away",
|
|
@@ -1303,7 +1311,7 @@ function Ot(e, t, n = {}) {
|
|
|
1303
1311
|
fillRatio: o,
|
|
1304
1312
|
fill: a,
|
|
1305
1313
|
readyForAutoCapture: !1
|
|
1306
|
-
} : o <
|
|
1314
|
+
} : o < At(a, t.previouslyReady === !0, s, n) ? {
|
|
1307
1315
|
hint: "Move closer",
|
|
1308
1316
|
reason: "move-closer",
|
|
1309
1317
|
fillRatio: o,
|
|
@@ -1317,7 +1325,7 @@ function Ot(e, t, n = {}) {
|
|
|
1317
1325
|
readyForAutoCapture: t.ready
|
|
1318
1326
|
};
|
|
1319
1327
|
}
|
|
1320
|
-
var
|
|
1328
|
+
var Mt = class {
|
|
1321
1329
|
previous;
|
|
1322
1330
|
count = 0;
|
|
1323
1331
|
ready = !1;
|
|
@@ -1345,14 +1353,14 @@ var kt = class {
|
|
|
1345
1353
|
};
|
|
1346
1354
|
}
|
|
1347
1355
|
};
|
|
1348
|
-
function
|
|
1356
|
+
function Nt(e, n) {
|
|
1349
1357
|
let r = Math.min(1, n / Math.max(e.width, e.height)), i = document.createElement("canvas");
|
|
1350
1358
|
i.width = Math.max(1, Math.round(e.width * r)), i.height = Math.max(1, Math.round(e.height * r));
|
|
1351
1359
|
let a = i.getContext("2d");
|
|
1352
1360
|
if (!a) throw t();
|
|
1353
1361
|
return a.drawImage(e, 0, 0, i.width, i.height), i;
|
|
1354
1362
|
}
|
|
1355
|
-
function
|
|
1363
|
+
function Pt() {
|
|
1356
1364
|
let e = window.AudioContext ?? window.webkitAudioContext;
|
|
1357
1365
|
if (!e) return;
|
|
1358
1366
|
let t = new e(), n = Math.round(t.sampleRate * .09), r = t.createBuffer(1, n, t.sampleRate), i = r.getChannelData(0);
|
|
@@ -1363,22 +1371,22 @@ function jt() {
|
|
|
1363
1371
|
let a = t.createBufferSource(), o = t.createBiquadFilter(), s = t.createGain();
|
|
1364
1372
|
o.type = "bandpass", o.frequency.value = 1400, s.gain.value = .42, a.buffer = r, a.connect(o).connect(s).connect(t.destination), a.start(), a.onended = () => void t.close();
|
|
1365
1373
|
}
|
|
1366
|
-
async function
|
|
1374
|
+
async function Ft(e) {
|
|
1367
1375
|
let t = document.createElement("video");
|
|
1368
1376
|
return t.muted = !0, t.autoplay = !0, t.playsInline = !0, t.srcObject = e, await t.play(), t;
|
|
1369
1377
|
}
|
|
1370
|
-
async function
|
|
1378
|
+
async function It(t) {
|
|
1371
1379
|
await x("scan");
|
|
1372
|
-
let n =
|
|
1380
|
+
let n = Ct(t.autoCapture), r = t.holdStillMs ?? 3e3, i = new Mt({
|
|
1373
1381
|
stableFrames: t.stableFrames ?? 4,
|
|
1374
1382
|
confidenceThreshold: t.confidenceThreshold ?? .72,
|
|
1375
1383
|
cornerTolerance: t.cornerTolerance ?? .024,
|
|
1376
1384
|
exitCornerTolerance: t.exitCornerTolerance ?? .036
|
|
1377
|
-
}),
|
|
1385
|
+
}), a = Et(), o = t.maxFrameDimension ?? a.maxFrameDimension, s = t.intervalMs ?? a.intervalMs, c = {
|
|
1378
1386
|
minDimension: 220,
|
|
1379
|
-
maxAnalysisDimension:
|
|
1387
|
+
maxAnalysisDimension: a.maxAnalysisDimension,
|
|
1380
1388
|
...t.detection
|
|
1381
|
-
},
|
|
1389
|
+
}, l = typeof MediaStream < "u" && t.source instanceof MediaStream ? await Ft(t.source) : t.source, u = !0, d = !1, f = !1, p, m = 0, h, g = "", _ = 0, v = {
|
|
1382
1390
|
state: "detecting",
|
|
1383
1391
|
confidence: 0,
|
|
1384
1392
|
guidance: {
|
|
@@ -1395,101 +1403,104 @@ async function Nt(t) {
|
|
|
1395
1403
|
stableFrames: 0,
|
|
1396
1404
|
requiredStableFrames: t.stableFrames ?? 4,
|
|
1397
1405
|
autoCapture: { ...n }
|
|
1398
|
-
},
|
|
1399
|
-
|
|
1400
|
-
},
|
|
1401
|
-
let t =
|
|
1402
|
-
width:
|
|
1403
|
-
height:
|
|
1406
|
+
}, y = () => l instanceof HTMLCanvasElement ? Nt(l, o) : N(l, o), b = (e) => {
|
|
1407
|
+
v = e, t.onStatus?.(e);
|
|
1408
|
+
}, S = (e) => {
|
|
1409
|
+
let t = Dt(e, l instanceof HTMLVideoElement ? {
|
|
1410
|
+
width: l.videoWidth,
|
|
1411
|
+
height: l.videoHeight
|
|
1404
1412
|
} : {
|
|
1405
|
-
width:
|
|
1406
|
-
height:
|
|
1413
|
+
width: l.width,
|
|
1414
|
+
height: l.height
|
|
1407
1415
|
}), n = performance.now();
|
|
1408
|
-
t.key ===
|
|
1409
|
-
},
|
|
1410
|
-
|
|
1411
|
-
},
|
|
1412
|
-
if (
|
|
1413
|
-
|
|
1416
|
+
t.key === g && n - _ < 2e3 || (g = t.key, _ = n, console[t.level](`[exige-scanner] ${t.summary}`, t.detail));
|
|
1417
|
+
}, C = () => {
|
|
1418
|
+
u = !1, window.clearTimeout(m), l instanceof HTMLVideoElement && l !== t.source && (l.srcObject = null);
|
|
1419
|
+
}, w = async (e = "manual") => {
|
|
1420
|
+
if (d) throw Error("A finder capture is already in progress.");
|
|
1421
|
+
d = !0;
|
|
1414
1422
|
let n;
|
|
1415
1423
|
try {
|
|
1416
|
-
n = await
|
|
1417
|
-
|
|
1418
|
-
...
|
|
1424
|
+
n = await St(t.captureFrame ?? y, () => {
|
|
1425
|
+
b({
|
|
1426
|
+
...v,
|
|
1419
1427
|
state: "captured"
|
|
1420
|
-
}), t.playShutterSound !== !1 &&
|
|
1428
|
+
}), t.playShutterSound !== !1 && Pt(), C();
|
|
1421
1429
|
});
|
|
1422
1430
|
} catch (e) {
|
|
1423
|
-
throw
|
|
1431
|
+
throw d = !1, e instanceof Error ? e : /* @__PURE__ */ Error("The camera frame could not be captured.");
|
|
1424
1432
|
}
|
|
1425
1433
|
let r = {
|
|
1426
1434
|
frame: n,
|
|
1427
|
-
detection:
|
|
1435
|
+
detection: h,
|
|
1428
1436
|
reason: e
|
|
1429
1437
|
};
|
|
1430
1438
|
return await t.onCapture?.(r), r;
|
|
1431
|
-
},
|
|
1432
|
-
if (
|
|
1439
|
+
}, T = async () => {
|
|
1440
|
+
if (u && !d) {
|
|
1433
1441
|
try {
|
|
1434
|
-
let e =
|
|
1435
|
-
|
|
1436
|
-
let
|
|
1442
|
+
let e = y(), a = await st(e, c);
|
|
1443
|
+
h = a, S(a);
|
|
1444
|
+
let o = a.quad ? vt(e, a.quad) : {
|
|
1437
1445
|
strong: !1,
|
|
1438
1446
|
strength: 0
|
|
1439
|
-
},
|
|
1447
|
+
}, s = o.strong ? {
|
|
1440
1448
|
castShadow: !0,
|
|
1441
|
-
strength:
|
|
1449
|
+
strength: o.strength,
|
|
1442
1450
|
hint: "Tilt to move the shadow off the page"
|
|
1443
1451
|
} : {
|
|
1444
1452
|
castShadow: !1,
|
|
1445
|
-
strength:
|
|
1446
|
-
},
|
|
1447
|
-
...
|
|
1448
|
-
previouslyReady:
|
|
1453
|
+
strength: o.strength
|
|
1454
|
+
}, l = i.update(a), u = jt(a, {
|
|
1455
|
+
...l,
|
|
1456
|
+
previouslyReady: f
|
|
1449
1457
|
}, {
|
|
1450
1458
|
confidenceThreshold: t.confidenceThreshold ?? .72,
|
|
1451
1459
|
...t.guidance
|
|
1452
1460
|
});
|
|
1453
|
-
|
|
1454
|
-
let
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1461
|
+
f = u.readyForAutoCapture;
|
|
1462
|
+
let d = performance.now();
|
|
1463
|
+
u.readyForAutoCapture && n.checked ? p ??= d : p = void 0;
|
|
1464
|
+
let m = p === void 0 ? void 0 : bt(p, d, r), g = a.status !== "success" || u.reason === "place-document" ? "seeking" : u.readyForAutoCapture ? "ready" : "unstable";
|
|
1465
|
+
if (b({
|
|
1466
|
+
state: g,
|
|
1467
|
+
confidence: a.confidence,
|
|
1468
|
+
quad: a.quad,
|
|
1469
|
+
guidance: u,
|
|
1470
|
+
lighting: s,
|
|
1471
|
+
stableFrames: l.stableFrames,
|
|
1472
|
+
requiredStableFrames: v.requiredStableFrames,
|
|
1463
1473
|
autoCapture: { ...n },
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
+
holdStillSeconds: m && m > 0 ? m : void 0,
|
|
1475
|
+
sourceWidth: a.sourceWidth,
|
|
1476
|
+
sourceHeight: a.sourceHeight,
|
|
1477
|
+
detector: a.detector,
|
|
1478
|
+
modelStatus: a.modelStatus,
|
|
1479
|
+
modelProvider: a.modelProvider,
|
|
1480
|
+
modelError: a.modelError,
|
|
1481
|
+
modelNote: a.modelNote,
|
|
1482
|
+
inferenceMs: a.inferenceMs
|
|
1483
|
+
}), u.readyForAutoCapture && n.checked && m === 0) try {
|
|
1484
|
+
await w("auto");
|
|
1474
1485
|
return;
|
|
1475
1486
|
} catch (e) {
|
|
1476
|
-
|
|
1487
|
+
i.reset(), f = !1, p = void 0, t.onCaptureError?.(e instanceof Error ? e : /* @__PURE__ */ Error("Automatic capture failed."));
|
|
1477
1488
|
}
|
|
1478
1489
|
} catch (t) {
|
|
1479
|
-
|
|
1480
|
-
let
|
|
1490
|
+
i.reset(), f = !1, p = void 0;
|
|
1491
|
+
let r = t instanceof e ? {
|
|
1481
1492
|
detector: "ml",
|
|
1482
1493
|
modelStatus: "failed",
|
|
1483
1494
|
modelError: t.message
|
|
1484
1495
|
} : { modelError: t instanceof Error ? t.message : "Finder tick failed." };
|
|
1485
|
-
|
|
1496
|
+
S({
|
|
1486
1497
|
status: "no-document",
|
|
1487
1498
|
confidence: 0,
|
|
1488
|
-
message:
|
|
1499
|
+
message: r.modelError ?? "Finder tick failed.",
|
|
1489
1500
|
sourceWidth: 0,
|
|
1490
1501
|
sourceHeight: 0,
|
|
1491
|
-
...
|
|
1492
|
-
}),
|
|
1502
|
+
...r
|
|
1503
|
+
}), b({
|
|
1493
1504
|
state: "seeking",
|
|
1494
1505
|
confidence: 0,
|
|
1495
1506
|
guidance: {
|
|
@@ -1504,46 +1515,47 @@ async function Nt(t) {
|
|
|
1504
1515
|
strength: 0
|
|
1505
1516
|
},
|
|
1506
1517
|
stableFrames: 0,
|
|
1507
|
-
requiredStableFrames:
|
|
1518
|
+
requiredStableFrames: v.requiredStableFrames,
|
|
1508
1519
|
autoCapture: { ...n },
|
|
1509
|
-
...
|
|
1520
|
+
...r
|
|
1510
1521
|
});
|
|
1511
1522
|
}
|
|
1512
|
-
|
|
1523
|
+
u && (m = window.setTimeout(() => void T(), s));
|
|
1513
1524
|
}
|
|
1514
1525
|
};
|
|
1515
|
-
return t.onStatus?.(
|
|
1516
|
-
stop:
|
|
1517
|
-
capture: () =>
|
|
1526
|
+
return t.onStatus?.(v), T(), {
|
|
1527
|
+
stop: C,
|
|
1528
|
+
capture: () => w("manual"),
|
|
1518
1529
|
setAutoCapture(e) {
|
|
1519
|
-
return !n.mutable ||
|
|
1520
|
-
...
|
|
1521
|
-
autoCapture: { ...n }
|
|
1530
|
+
return !n.mutable || d ? !1 : (n.checked = e, e || (p = void 0), b({
|
|
1531
|
+
...v,
|
|
1532
|
+
autoCapture: { ...n },
|
|
1533
|
+
holdStillSeconds: e ? v.holdStillSeconds : void 0
|
|
1522
1534
|
}), !0);
|
|
1523
1535
|
},
|
|
1524
|
-
getStatus: () =>
|
|
1536
|
+
getStatus: () => v
|
|
1525
1537
|
};
|
|
1526
1538
|
}
|
|
1527
1539
|
//#endregion
|
|
1528
1540
|
//#region src/sdk/ocr-runtime.ts
|
|
1529
|
-
var
|
|
1530
|
-
function
|
|
1541
|
+
var Lt = new URL("./assets/tesseract/worker.min.js", import.meta.url), Rt = new URL("./assets/tesseract/tesseract-core-lstm.wasm.js", import.meta.url), zt = new URL("./assets/tesseract/tesseract-core-simd-lstm.wasm.js", import.meta.url), Bt = new URL("./assets/tesseract/tesseract-core-relaxedsimd-lstm.wasm.js", import.meta.url), Vt = new URL("./assets/tesseract/eng.traineddata.gz", import.meta.url), Ht = Uint8Array.of(0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 0, 1, 123, 3, 2, 1, 0, 10, 15, 1, 13, 0, 65, 1, 253, 15, 65, 2, 253, 15, 253, 128, 2, 11), Ut = Uint8Array.of(0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 0, 1, 123, 3, 2, 1, 0, 10, 10, 1, 8, 0, 65, 0, 253, 15, 253, 98, 11);
|
|
1542
|
+
function Wt(e) {
|
|
1531
1543
|
try {
|
|
1532
1544
|
return typeof WebAssembly < "u" && WebAssembly.validate(e);
|
|
1533
1545
|
} catch {
|
|
1534
1546
|
return !1;
|
|
1535
1547
|
}
|
|
1536
1548
|
}
|
|
1537
|
-
function
|
|
1549
|
+
function Gt() {
|
|
1538
1550
|
return {
|
|
1539
|
-
relaxedSimd:
|
|
1540
|
-
simd:
|
|
1551
|
+
relaxedSimd: Wt(Ht),
|
|
1552
|
+
simd: Wt(Ut)
|
|
1541
1553
|
};
|
|
1542
1554
|
}
|
|
1543
|
-
function
|
|
1544
|
-
return e.relaxedSimd ?
|
|
1555
|
+
function Kt(e) {
|
|
1556
|
+
return e.relaxedSimd ? Bt : e.simd ? zt : Rt;
|
|
1545
1557
|
}
|
|
1546
|
-
function
|
|
1558
|
+
function qt(t, n) {
|
|
1547
1559
|
let r = t?.trim() || "eng", i = n?.trim() || "";
|
|
1548
1560
|
if (i) return {
|
|
1549
1561
|
kind: "lang-path",
|
|
@@ -1556,14 +1568,14 @@ function Wt(t, n) {
|
|
|
1556
1568
|
};
|
|
1557
1569
|
throw new e("language", `OCR language "${r}" is not packaged. Pass langPath, a directory URL that contains ${r}.traineddata.gz.`);
|
|
1558
1570
|
}
|
|
1559
|
-
function
|
|
1571
|
+
function Jt(e = Vt) {
|
|
1560
1572
|
let t = e.href, n = t.lastIndexOf("/");
|
|
1561
1573
|
return n === -1 ? t : t.slice(0, n);
|
|
1562
1574
|
}
|
|
1563
|
-
function
|
|
1564
|
-
return e.kind === "bundled-eng" ?
|
|
1575
|
+
function Yt(e) {
|
|
1576
|
+
return e.kind === "bundled-eng" ? Jt() : e.langPath;
|
|
1565
1577
|
}
|
|
1566
|
-
async function
|
|
1578
|
+
async function Xt(t, n, r) {
|
|
1567
1579
|
return new Promise((i, a) => {
|
|
1568
1580
|
let o = !1, s = (t) => {
|
|
1569
1581
|
o || (o = !0, a(new e("worker", `OCR worker failed to start (${t instanceof Error ? t.message : String(t)}).`)));
|
|
@@ -1586,7 +1598,7 @@ async function qt(t, n, r) {
|
|
|
1586
1598
|
}
|
|
1587
1599
|
//#endregion
|
|
1588
1600
|
//#region src/sdk/ocr.ts
|
|
1589
|
-
function
|
|
1601
|
+
function Zt(e, t = 1, n = 1, r = 0, i = 0) {
|
|
1590
1602
|
return {
|
|
1591
1603
|
text: e.text,
|
|
1592
1604
|
confidence: Math.max(0, Math.min(1, e.confidence / 100)),
|
|
@@ -1598,20 +1610,20 @@ function Jt(e, t = 1, n = 1, r = 0, i = 0) {
|
|
|
1598
1610
|
}
|
|
1599
1611
|
};
|
|
1600
1612
|
}
|
|
1601
|
-
function
|
|
1613
|
+
function Qt(e = .5) {
|
|
1602
1614
|
if (!Number.isFinite(e) || e < 0 || e > 1) throw RangeError("OCR minConfidence must be between 0 and 1.");
|
|
1603
1615
|
return e;
|
|
1604
1616
|
}
|
|
1605
|
-
function
|
|
1617
|
+
function $t(e, t) {
|
|
1606
1618
|
let n = Math.max(e.bbox.x, t.bbox.x), r = Math.max(e.bbox.y, t.bbox.y), i = Math.min(e.bbox.x + e.bbox.width, t.bbox.x + t.bbox.width), a = Math.min(e.bbox.y + e.bbox.height, t.bbox.y + t.bbox.height), o = Math.max(0, i - n) * Math.max(0, a - r), s = Math.min(e.bbox.width * e.bbox.height, t.bbox.width * t.bbox.height);
|
|
1607
1619
|
return s > 0 ? o / s : 0;
|
|
1608
1620
|
}
|
|
1609
|
-
function
|
|
1621
|
+
function en(e) {
|
|
1610
1622
|
let t = [...e].sort((e, t) => t.confidence - e.confidence || e.bbox.y - t.bbox.y || e.bbox.x - t.bbox.x || e.text.localeCompare(t.text)), n = [];
|
|
1611
|
-
for (let e of t) n.some((t) =>
|
|
1623
|
+
for (let e of t) n.some((t) => $t(t, e) >= .65) || n.push(e);
|
|
1612
1624
|
return n;
|
|
1613
1625
|
}
|
|
1614
|
-
function
|
|
1626
|
+
function tn(e, t, n, r, i) {
|
|
1615
1627
|
let a = e.text.trim();
|
|
1616
1628
|
if (!a || !/[\p{L}\p{N}]/u.test(a)) return !1;
|
|
1617
1629
|
let o = e.bbox.width * e.bbox.height / Math.max(1, n * r), s = e.bbox.width / Math.max(1, e.bbox.height);
|
|
@@ -1622,7 +1634,7 @@ function Qt(e, t, n, r, i) {
|
|
|
1622
1634
|
}
|
|
1623
1635
|
return !0;
|
|
1624
1636
|
}
|
|
1625
|
-
function
|
|
1637
|
+
function nn(e) {
|
|
1626
1638
|
let t = [...e].sort((e, t) => e.bbox.y + e.bbox.height / 2 - (t.bbox.y + t.bbox.height / 2) || e.bbox.x - t.bbox.x), n = [];
|
|
1627
1639
|
for (let e of t) {
|
|
1628
1640
|
let t = e.bbox.y + e.bbox.height / 2, r = n.find((n) => Math.abs(n.centerY - t) <= Math.max(n.height, e.bbox.height) * .6);
|
|
@@ -1638,28 +1650,28 @@ function $t(e) {
|
|
|
1638
1650
|
}
|
|
1639
1651
|
return n.sort((e, t) => e.centerY - t.centerY).map((e) => e.words.sort((e, t) => e.bbox.x - t.bbox.x).map((e) => e.text.trim()).join(" ")).join("\n");
|
|
1640
1652
|
}
|
|
1641
|
-
function
|
|
1642
|
-
let i =
|
|
1653
|
+
function rn(e, t, n, r) {
|
|
1654
|
+
let i = Qt(t.minConfidence), a = [], o = [], s = 1, c = 1;
|
|
1643
1655
|
for (let t of e) {
|
|
1644
1656
|
let e = t.scaleX ?? 1, n = t.scaleY ?? 1, r = t.offsetX ?? 0, l = t.offsetY ?? 0;
|
|
1645
1657
|
for (let u of t.blocks ?? []) for (let t of u.paragraphs) for (let u of t.lines) for (let t of u.words) {
|
|
1646
|
-
let u =
|
|
1658
|
+
let u = Zt(t, e, n, r, l);
|
|
1647
1659
|
s = Math.max(s, u.bbox.x + u.bbox.width), c = Math.max(c, u.bbox.y + u.bbox.height), u.confidence >= i && a.push(u);
|
|
1648
1660
|
for (let a of t.symbols) {
|
|
1649
|
-
let t =
|
|
1661
|
+
let t = Zt(a, e, n, r, l);
|
|
1650
1662
|
t.confidence >= i && o.push(t);
|
|
1651
1663
|
}
|
|
1652
1664
|
}
|
|
1653
1665
|
}
|
|
1654
|
-
let l = n?.width ?? s, u = n?.height ?? c, d =
|
|
1666
|
+
let l = n?.width ?? s, u = n?.height ?? c, d = en(a).filter((e) => tn(e, "word", l, u, r)), f = en(o).filter((e) => tn(e, "character", l, u, r));
|
|
1655
1667
|
return {
|
|
1656
|
-
text:
|
|
1668
|
+
text: nn(d),
|
|
1657
1669
|
confidence: d.length ? d.reduce((e, t) => e + t.confidence, 0) / d.length : 0,
|
|
1658
1670
|
words: t.includeWords ? d : [],
|
|
1659
1671
|
characters: t.includeCharacters ? f : []
|
|
1660
1672
|
};
|
|
1661
1673
|
}
|
|
1662
|
-
function
|
|
1674
|
+
function an(e) {
|
|
1663
1675
|
let n = e.getContext("2d", { willReadFrequently: !0 });
|
|
1664
1676
|
if (!n) throw t();
|
|
1665
1677
|
let r = n.getImageData(0, 0, e.width, e.height), i = new Uint8Array(e.width * e.height);
|
|
@@ -1670,7 +1682,7 @@ function tn(e) {
|
|
|
1670
1682
|
luminance: i
|
|
1671
1683
|
};
|
|
1672
1684
|
}
|
|
1673
|
-
function
|
|
1685
|
+
function on(e) {
|
|
1674
1686
|
let t = document.createElement("canvas");
|
|
1675
1687
|
t.width = 72, t.height = 72;
|
|
1676
1688
|
let n = t.getContext("2d", { willReadFrequently: !0 });
|
|
@@ -1681,27 +1693,27 @@ function nn(e) {
|
|
|
1681
1693
|
areaRatio: 0
|
|
1682
1694
|
};
|
|
1683
1695
|
n.drawImage(e, 0, 0, t.width, t.height);
|
|
1684
|
-
let { luminance: r } =
|
|
1696
|
+
let { luminance: r } = an(t);
|
|
1685
1697
|
return ft(r, t.width, t.height);
|
|
1686
1698
|
}
|
|
1687
|
-
function
|
|
1699
|
+
function sn(e, t, n, r) {
|
|
1688
1700
|
let i = (e.bbox.x + e.bbox.width / 2) / n, a = (e.bbox.y + e.bbox.height / 2) / r;
|
|
1689
1701
|
return i >= t.x && i <= t.x + t.width && a >= t.y && a <= t.y + t.height;
|
|
1690
1702
|
}
|
|
1691
|
-
var
|
|
1692
|
-
function
|
|
1703
|
+
var cn = .58;
|
|
1704
|
+
function ln(e) {
|
|
1693
1705
|
let t = e.trim();
|
|
1694
1706
|
if (!t || !/[\p{L}\p{N}]/u.test(t)) return 0;
|
|
1695
1707
|
if (/^\$?\d{1,5}([.,]\d{2})?$/.test(t)) return 1;
|
|
1696
1708
|
let n = t.replace(/[^\p{L}]/gu, "");
|
|
1697
1709
|
return n.length >= 3 && /[aeiouy]/i.test(n) ? .9 : n.length >= 4 ? .7 : t.length <= 2 ? .35 : /[^\p{L}\p{N}.,'’$/-]/u.test(t) ? .25 : .5;
|
|
1698
1710
|
}
|
|
1699
|
-
function
|
|
1711
|
+
function un(e, t, n) {
|
|
1700
1712
|
let r = Math.max(0, Math.min(1, (1 - e.darkness / 80) * (1 - e.strength / 24)));
|
|
1701
1713
|
if (!t.length) return r * .35;
|
|
1702
1714
|
let i = 0;
|
|
1703
1715
|
for (let e of t) {
|
|
1704
|
-
let t =
|
|
1716
|
+
let t = ln(e.text);
|
|
1705
1717
|
if (n) {
|
|
1706
1718
|
let r = n(e.bbox);
|
|
1707
1719
|
(r < .04 || r > .62) && (t *= .4);
|
|
@@ -1710,10 +1722,10 @@ function sn(e, t, n) {
|
|
|
1710
1722
|
}
|
|
1711
1723
|
return r * .7 + i / t.length * .3;
|
|
1712
1724
|
}
|
|
1713
|
-
function
|
|
1714
|
-
return !e.strong || !e.region ? !1 :
|
|
1725
|
+
function dn(e, t, n, r) {
|
|
1726
|
+
return !e.strong || !e.region ? !1 : un(e, t.filter((t) => sn(t, e.region, n.width, n.height)), r) < cn;
|
|
1715
1727
|
}
|
|
1716
|
-
function
|
|
1728
|
+
function fn(e, t, n, r) {
|
|
1717
1729
|
let i = Math.max(0, Math.floor(t.x * e.width)), a = Math.max(0, Math.floor(t.y * e.height)), o = Math.min(e.width, Math.ceil((t.x + t.width) * e.width)), s = Math.min(e.height, Math.ceil((t.y + t.height) * e.height)), c = document.createElement("canvas");
|
|
1718
1730
|
c.width = Math.max(1, o - i), c.height = Math.max(1, s - a), c.getContext("2d")?.drawImage(e, i, a, c.width, c.height, 0, 0, c.width, c.height);
|
|
1719
1731
|
let l = n / e.width, u = r / e.height;
|
|
@@ -1727,26 +1739,26 @@ function ln(e, t, n, r) {
|
|
|
1727
1739
|
}
|
|
1728
1740
|
};
|
|
1729
1741
|
}
|
|
1730
|
-
function
|
|
1742
|
+
function pn(e, t) {
|
|
1731
1743
|
for (let n = 0, r = 0; n < t.length; n += 1, r += 4) e.data[r] = t[n], e.data[r + 1] = t[n], e.data[r + 2] = t[n], e.data[r + 3] = 255;
|
|
1732
1744
|
}
|
|
1733
|
-
function
|
|
1745
|
+
function mn(e) {
|
|
1734
1746
|
let n = 2200, r = Math.max(e.width, e.height), i = r > n ? n / r : Math.min(1.5, n / Math.max(1, r)), a = document.createElement("canvas");
|
|
1735
1747
|
a.width = Math.max(1, Math.round(e.width * i)), a.height = Math.max(1, Math.round(e.height * i));
|
|
1736
1748
|
let o = a.getContext("2d", { willReadFrequently: !0 });
|
|
1737
1749
|
if (!o) throw t();
|
|
1738
1750
|
o.drawImage(e, 0, 0, a.width, a.height);
|
|
1739
|
-
let { image: s, luminance: c } =
|
|
1751
|
+
let { image: s, luminance: c } = an(a), l = ht(c, a.width, a.height), u = gt(l, a.width, a.height), d = document.createElement("canvas");
|
|
1740
1752
|
d.width = a.width, d.height = a.height;
|
|
1741
1753
|
let f = d.getContext("2d", { willReadFrequently: !0 });
|
|
1742
1754
|
if (!f) throw t();
|
|
1743
1755
|
let p = f.createImageData(d.width, d.height);
|
|
1744
|
-
return
|
|
1756
|
+
return pn(p, l), f.putImageData(p, 0, 0), pn(s, u), o.putImageData(s, 0, 0), {
|
|
1745
1757
|
sparseCanvas: a,
|
|
1746
1758
|
flattenedCanvas: d
|
|
1747
1759
|
};
|
|
1748
1760
|
}
|
|
1749
|
-
function
|
|
1761
|
+
function hn(e) {
|
|
1750
1762
|
let t = document.createElement("canvas");
|
|
1751
1763
|
t.width = 24, t.height = 24;
|
|
1752
1764
|
let n = t.getContext("2d", { willReadFrequently: !0 });
|
|
@@ -1766,17 +1778,17 @@ function fn(e) {
|
|
|
1766
1778
|
}
|
|
1767
1779
|
async function H(e, t = {}) {
|
|
1768
1780
|
await x("ocr");
|
|
1769
|
-
let n =
|
|
1770
|
-
|
|
1771
|
-
let i = await P(e, { cloneCanvas: !1 }), { sparseCanvas: a, flattenedCanvas: o } =
|
|
1781
|
+
let n = qt(t.language, t.langPath), r = n.language;
|
|
1782
|
+
Qt(t.minConfidence);
|
|
1783
|
+
let i = await P(e, { cloneCanvas: !1 }), { sparseCanvas: a, flattenedCanvas: o } = mn(i), s = t.shadowPass === !1 ? {
|
|
1772
1784
|
strong: !1,
|
|
1773
1785
|
strength: 0,
|
|
1774
1786
|
darkness: 0,
|
|
1775
1787
|
areaRatio: 0
|
|
1776
|
-
} :
|
|
1777
|
-
workerPath:
|
|
1778
|
-
corePath:
|
|
1779
|
-
langPath:
|
|
1788
|
+
} : on(i), { createWorker: c, PSM: l } = await import("tesseract.js"), u = 0, d = s.strong ? 3 : 2, f = await Xt(c, r, {
|
|
1789
|
+
workerPath: Lt.href,
|
|
1790
|
+
corePath: Kt(Gt()).href,
|
|
1791
|
+
langPath: Yt(n),
|
|
1780
1792
|
logger(e) {
|
|
1781
1793
|
typeof e.progress == "number" && t.onProgress?.(Math.min(1, (u + e.progress) / d), e.status ?? "recognizing text");
|
|
1782
1794
|
}
|
|
@@ -1801,16 +1813,16 @@ async function H(e, t = {}) {
|
|
|
1801
1813
|
}], d = {
|
|
1802
1814
|
...t,
|
|
1803
1815
|
includeWords: !0
|
|
1804
|
-
}, p =
|
|
1816
|
+
}, p = hn(i), m = rn(c, d, {
|
|
1805
1817
|
width: i.width,
|
|
1806
1818
|
height: i.height
|
|
1807
|
-
}, p), h = t.shadowPass !== !1 &&
|
|
1819
|
+
}, p), h = t.shadowPass !== !1 && dn(s, m.words, {
|
|
1808
1820
|
width: i.width,
|
|
1809
1821
|
height: i.height
|
|
1810
1822
|
}, p);
|
|
1811
1823
|
if (h && s.region) {
|
|
1812
1824
|
u = 2;
|
|
1813
|
-
let { tile: e, passMapping: t } =
|
|
1825
|
+
let { tile: e, passMapping: t } = fn(o, s.region, i.width, i.height);
|
|
1814
1826
|
await f.setParameters({
|
|
1815
1827
|
tessedit_pageseg_mode: l.SPARSE_TEXT,
|
|
1816
1828
|
preserve_interword_spaces: "1"
|
|
@@ -1824,7 +1836,7 @@ async function H(e, t = {}) {
|
|
|
1824
1836
|
...t
|
|
1825
1837
|
});
|
|
1826
1838
|
}
|
|
1827
|
-
let g = c.length === 2 ? m :
|
|
1839
|
+
let g = c.length === 2 ? m : rn(c, d, {
|
|
1828
1840
|
width: i.width,
|
|
1829
1841
|
height: i.height
|
|
1830
1842
|
}, p);
|
|
@@ -1853,37 +1865,37 @@ async function H(e, t = {}) {
|
|
|
1853
1865
|
}
|
|
1854
1866
|
//#endregion
|
|
1855
1867
|
//#region src/sdk/zxing-runtime.ts
|
|
1856
|
-
var
|
|
1857
|
-
function
|
|
1868
|
+
var gn = new URL("./assets/zxing_reader.wasm", import.meta.url), _n = "3.1.6", vn = "zxing_reader.wasm", yn = `https://exige-scanner-sdk.vercel.app/zxing/${_n}/`, bn = `https://cdn.jsdelivr.net/npm/zxing-wasm@${_n}/dist/reader/`;
|
|
1869
|
+
function xn(e, t) {
|
|
1858
1870
|
return `${e.endsWith("/") ? e : `${e}/`}${t}`;
|
|
1859
1871
|
}
|
|
1860
|
-
function
|
|
1861
|
-
return
|
|
1872
|
+
function Sn(e = yn) {
|
|
1873
|
+
return xn(e, vn);
|
|
1862
1874
|
}
|
|
1863
|
-
function bn() {
|
|
1864
|
-
return pn.href;
|
|
1865
|
-
}
|
|
1866
|
-
var xn, Sn;
|
|
1867
1875
|
function Cn() {
|
|
1876
|
+
return gn.href;
|
|
1877
|
+
}
|
|
1878
|
+
var wn, Tn;
|
|
1879
|
+
function En() {
|
|
1868
1880
|
return {
|
|
1869
|
-
binary:
|
|
1870
|
-
url:
|
|
1881
|
+
binary: wn,
|
|
1882
|
+
url: Tn
|
|
1871
1883
|
};
|
|
1872
1884
|
}
|
|
1873
|
-
async function
|
|
1874
|
-
let t =
|
|
1885
|
+
async function Dn(e = fetch) {
|
|
1886
|
+
let t = Cn();
|
|
1875
1887
|
if (await Re(t, e)) return t;
|
|
1876
|
-
let n = yn
|
|
1877
|
-
return await Re(n, e) ? n :
|
|
1888
|
+
let n = Sn(yn);
|
|
1889
|
+
return await Re(n, e) ? n : Sn(bn);
|
|
1878
1890
|
}
|
|
1879
1891
|
//#endregion
|
|
1880
1892
|
//#region src/sdk/barcode.ts
|
|
1881
|
-
function
|
|
1893
|
+
function On() {
|
|
1882
1894
|
let e = globalThis.BarcodeDetector;
|
|
1883
1895
|
return typeof e == "function" ? e : void 0;
|
|
1884
1896
|
}
|
|
1885
|
-
async function
|
|
1886
|
-
let e =
|
|
1897
|
+
async function kn() {
|
|
1898
|
+
let e = On();
|
|
1887
1899
|
if (!e?.getSupportedFormats) return !1;
|
|
1888
1900
|
try {
|
|
1889
1901
|
return (await e.getSupportedFormats()).some((e) => e.toLowerCase() === "pdf417");
|
|
@@ -1891,8 +1903,8 @@ async function En() {
|
|
|
1891
1903
|
return !1;
|
|
1892
1904
|
}
|
|
1893
1905
|
}
|
|
1894
|
-
async function
|
|
1895
|
-
let t =
|
|
1906
|
+
async function An(e) {
|
|
1907
|
+
let t = On();
|
|
1896
1908
|
if (!t) return;
|
|
1897
1909
|
let n = await new t({ formats: ["pdf417"] }).detect(e);
|
|
1898
1910
|
return n.find((e) => {
|
|
@@ -1900,34 +1912,34 @@ async function Dn(e) {
|
|
|
1900
1912
|
return (!t || t === "pdf417") && !!e.rawValue?.trim();
|
|
1901
1913
|
})?.rawValue?.trim() || n.find((e) => e.rawValue?.trim())?.rawValue?.trim();
|
|
1902
1914
|
}
|
|
1903
|
-
function
|
|
1915
|
+
function jn(e) {
|
|
1904
1916
|
try {
|
|
1905
1917
|
return e.getContext("2d", { willReadFrequently: !0 })?.getImageData(0, 0, e.width, e.height);
|
|
1906
1918
|
} catch {
|
|
1907
1919
|
return;
|
|
1908
1920
|
}
|
|
1909
1921
|
}
|
|
1910
|
-
async function
|
|
1922
|
+
async function Mn(e) {
|
|
1911
1923
|
let t = [];
|
|
1912
1924
|
if (e instanceof Blob && t.push(e), e instanceof HTMLCanvasElement) {
|
|
1913
|
-
let n =
|
|
1925
|
+
let n = jn(e);
|
|
1914
1926
|
n && t.push(n);
|
|
1915
1927
|
try {
|
|
1916
1928
|
t.push(await Ge(e, "image/png"));
|
|
1917
1929
|
} catch {}
|
|
1918
1930
|
} else if (!(e instanceof Blob)) try {
|
|
1919
|
-
let n =
|
|
1931
|
+
let n = jn(await P(e, { cloneCanvas: !1 }));
|
|
1920
1932
|
n && t.push(n);
|
|
1921
1933
|
} catch {}
|
|
1922
1934
|
return t;
|
|
1923
1935
|
}
|
|
1924
|
-
async function
|
|
1925
|
-
let { prepareZXingModule: t, readBarcodes: n } = await import("zxing-wasm/reader"), r =
|
|
1936
|
+
async function Nn(e) {
|
|
1937
|
+
let { prepareZXingModule: t, readBarcodes: n } = await import("zxing-wasm/reader"), r = En(), i = r.binary ? void 0 : await Dn();
|
|
1926
1938
|
await t({
|
|
1927
1939
|
overrides: r.binary ? { wasmBinary: r.binary } : { locateFile: (e, t) => e.endsWith(".wasm") ? i ?? t + e : t + e },
|
|
1928
1940
|
fireImmediately: !0
|
|
1929
1941
|
});
|
|
1930
|
-
for (let t of await
|
|
1942
|
+
for (let t of await Mn(e)) {
|
|
1931
1943
|
let e = (await n(t, {
|
|
1932
1944
|
formats: ["PDF417"],
|
|
1933
1945
|
tryHarder: !0,
|
|
@@ -1937,15 +1949,15 @@ async function An(e) {
|
|
|
1937
1949
|
}
|
|
1938
1950
|
}
|
|
1939
1951
|
async function U(e) {
|
|
1940
|
-
if (await
|
|
1941
|
-
let t = await
|
|
1952
|
+
if (await kn()) try {
|
|
1953
|
+
let t = await An(e instanceof HTMLCanvasElement || e instanceof Blob ? e : await P(e, { cloneCanvas: !1 }));
|
|
1942
1954
|
if (t) return {
|
|
1943
1955
|
text: t,
|
|
1944
1956
|
source: "barcode-detector"
|
|
1945
1957
|
};
|
|
1946
1958
|
} catch {}
|
|
1947
1959
|
try {
|
|
1948
|
-
let t = await
|
|
1960
|
+
let t = await Nn(e);
|
|
1949
1961
|
return t ? {
|
|
1950
1962
|
text: t,
|
|
1951
1963
|
source: "zxing-wasm"
|
|
@@ -1954,11 +1966,11 @@ async function U(e) {
|
|
|
1954
1966
|
return;
|
|
1955
1967
|
}
|
|
1956
1968
|
}
|
|
1957
|
-
var W = new Set(/* @__PURE__ */ "DCA.DCB.DCD.DBA.DCS.DAC.DAD.DBD.DBB.DBC.DAY.DAU.DAG.DAI.DAJ.DAK.DAQ.DCF.DCG.DDE.DDF.DDG.DAH.DAZ.DCI.DCJ.DCK.DBN.DBG.DBS.DCU.DCE.DCL.DCM.DCN.DCO.DCP.DCQ.DCR.DDA.DDB.DDC.DDD.DAW.DAX.DDH.DDI.DDJ.DDK.DDL.DCT.DAL.DAM.DAN.DAO.DAR.DAS.DAT.DAV.DBH.DBI.DBJ.DBK.DBL.DBM.DCH".split(".")),
|
|
1969
|
+
var W = new Set(/* @__PURE__ */ "DCA.DCB.DCD.DBA.DCS.DAC.DAD.DBD.DBB.DBC.DAY.DAU.DAG.DAI.DAJ.DAK.DAQ.DCF.DCG.DDE.DDF.DDG.DAH.DAZ.DCI.DCJ.DCK.DBN.DBG.DBS.DCU.DCE.DCL.DCM.DCN.DCO.DCP.DCQ.DCR.DDA.DDB.DDC.DDD.DAW.DAX.DDH.DDI.DDJ.DDK.DDL.DCT.DAL.DAM.DAN.DAO.DAR.DAS.DAT.DAV.DBH.DBI.DBJ.DBK.DBL.DBM.DCH".split(".")), Pn = /* @__PURE__ */ "issuerJurisdiction.expirationDate.documentNumber.firstName.middleName.lastName.dateOfBirth.sex.eyeColor.height.addressStreet.addressCity.addressPostalCode.issueDate.country.addressStreet2.hairColor.nameSuffix.vehicleClass.restrictionCodes.endorsementCodes.documentDiscriminator.inventoryControlNumber.raceEthnicity.organDonor.veteran.weight".split("."), Fn = /* @__PURE__ */ new Set([
|
|
1958
1970
|
"expirationDate",
|
|
1959
1971
|
"dateOfBirth",
|
|
1960
1972
|
"issueDate"
|
|
1961
|
-
]),
|
|
1973
|
+
]), In = {
|
|
1962
1974
|
DAJ: "issuerJurisdiction",
|
|
1963
1975
|
DBA: "expirationDate",
|
|
1964
1976
|
DAQ: "documentNumber",
|
|
@@ -1994,7 +2006,7 @@ function G(e, t, n) {
|
|
|
1994
2006
|
let r = Number(e), i = Number(t), a = Number(n);
|
|
1995
2007
|
if (Number.isInteger(r) && Number.isInteger(i) && Number.isInteger(a) && !(r < 1900 || r > 2100 || i < 1 || i > 12 || a < 1 || a > 31)) return `${String(r).padStart(4, "0")}-${String(i).padStart(2, "0")}-${String(a).padStart(2, "0")}`;
|
|
1996
2008
|
}
|
|
1997
|
-
function
|
|
2009
|
+
function Ln(e, t) {
|
|
1998
2010
|
return t ? e >= 30 ? 1900 + e : 2e3 + e : e >= 50 ? 1900 + e : 2e3 + e;
|
|
1999
2011
|
}
|
|
2000
2012
|
function K(e, t = !1) {
|
|
@@ -2003,7 +2015,7 @@ function K(e, t = !1) {
|
|
|
2003
2015
|
let r = /^(\d{1,2})[/-](\d{1,2})[/-](\d{2,4})$/.exec(n);
|
|
2004
2016
|
if (r) {
|
|
2005
2017
|
let e = r[1], n = r[2], i = r[3];
|
|
2006
|
-
return i.length === 2 && (i = String(
|
|
2018
|
+
return i.length === 2 && (i = String(Ln(Number(i), t))), G(i, e.padStart(2, "0"), n.padStart(2, "0"));
|
|
2007
2019
|
}
|
|
2008
2020
|
let i = /^(\d{4})-(\d{2})-(\d{2})$/.exec(n);
|
|
2009
2021
|
if (i) return G(i[1], i[2], i[3]);
|
|
@@ -2013,11 +2025,11 @@ function K(e, t = !1) {
|
|
|
2013
2025
|
return e >= 1900 && e <= 2100 ? G(a.slice(0, 4), a.slice(4, 6), a.slice(6, 8)) : G(a.slice(4, 8), a.slice(0, 2), a.slice(2, 4));
|
|
2014
2026
|
}
|
|
2015
2027
|
if (a.length === 6) {
|
|
2016
|
-
let e =
|
|
2028
|
+
let e = Ln(Number(a.slice(4, 6)), t);
|
|
2017
2029
|
return G(String(e), a.slice(0, 2), a.slice(2, 4));
|
|
2018
2030
|
}
|
|
2019
2031
|
}
|
|
2020
|
-
function
|
|
2032
|
+
function Rn(e) {
|
|
2021
2033
|
let t = e.trim();
|
|
2022
2034
|
if (!t || t === "@") return "";
|
|
2023
2035
|
if (/^(ANSI|AAMVA)\b/.test(t)) {
|
|
@@ -2026,10 +2038,10 @@ function Fn(e) {
|
|
|
2026
2038
|
}
|
|
2027
2039
|
return t;
|
|
2028
2040
|
}
|
|
2029
|
-
function
|
|
2041
|
+
function zn(e) {
|
|
2030
2042
|
return (e.startsWith("DL") || e.startsWith("ID") || e.startsWith("ZV")) && e.length >= 5 && W.has(e.slice(2, 5)) ? e.slice(2) : e;
|
|
2031
2043
|
}
|
|
2032
|
-
function
|
|
2044
|
+
function Bn(e, t) {
|
|
2033
2045
|
let n = 0;
|
|
2034
2046
|
for (; n < e.length;) {
|
|
2035
2047
|
let r = e.slice(n, n + 3);
|
|
@@ -2048,7 +2060,7 @@ function Ln(e, t) {
|
|
|
2048
2060
|
(!(r in t) || a) && (t[r] = a), n = i, (e[n] === "\n" || e[n] === "\r" || e[n] === "") && (n += 1);
|
|
2049
2061
|
}
|
|
2050
2062
|
}
|
|
2051
|
-
function
|
|
2063
|
+
function Vn(e) {
|
|
2052
2064
|
let t = /(?:ANSI|AAMVA)\s?(\d{6})(\d{2})(\d{2})(\d{2})/.exec(e);
|
|
2053
2065
|
if (t) return {
|
|
2054
2066
|
iin: t[1],
|
|
@@ -2056,22 +2068,22 @@ function Rn(e) {
|
|
|
2056
2068
|
jurisdictionVersion: t[3]
|
|
2057
2069
|
};
|
|
2058
2070
|
}
|
|
2059
|
-
function
|
|
2071
|
+
function Hn(e) {
|
|
2060
2072
|
let t = e.replace(/\r\n/g, "\n").replace(/\r/g, "\n"), n = {}, r = t.split("\n").flatMap((e) => e.split(""));
|
|
2061
2073
|
if (r.some((e) => {
|
|
2062
|
-
let t =
|
|
2074
|
+
let t = zn(Rn(e));
|
|
2063
2075
|
return W.has(t.slice(0, 3));
|
|
2064
2076
|
})) {
|
|
2065
2077
|
for (let e of r) {
|
|
2066
|
-
let t =
|
|
2067
|
-
t &&
|
|
2078
|
+
let t = zn(Rn(e));
|
|
2079
|
+
t && Bn(t, n);
|
|
2068
2080
|
}
|
|
2069
2081
|
return n;
|
|
2070
2082
|
}
|
|
2071
|
-
return
|
|
2083
|
+
return Bn(t, n), n;
|
|
2072
2084
|
}
|
|
2073
|
-
function
|
|
2074
|
-
if (
|
|
2085
|
+
function Un(e, t) {
|
|
2086
|
+
if (Fn.has(t)) return K(e, t === "dateOfBirth") ?? e.trim();
|
|
2075
2087
|
if (t === "issuerJurisdiction" || t === "country") return e.trim().toUpperCase();
|
|
2076
2088
|
if (t === "addressPostalCode") {
|
|
2077
2089
|
let t = e.trim();
|
|
@@ -2079,11 +2091,11 @@ function Bn(e, t) {
|
|
|
2079
2091
|
}
|
|
2080
2092
|
return e.trim();
|
|
2081
2093
|
}
|
|
2082
|
-
function
|
|
2094
|
+
function Wn(e) {
|
|
2083
2095
|
let t = {};
|
|
2084
2096
|
for (let [n, r] of Object.entries(e)) {
|
|
2085
|
-
let e =
|
|
2086
|
-
e && r.trim() && (t[e] || (t[e] =
|
|
2097
|
+
let e = In[n];
|
|
2098
|
+
e && r.trim() && (t[e] || (t[e] = Un(r, e)));
|
|
2087
2099
|
}
|
|
2088
2100
|
if (!t.firstName && e.DCT?.trim()) {
|
|
2089
2101
|
let n = e.DCT.trim().split(/\s+/);
|
|
@@ -2091,29 +2103,29 @@ function Vn(e) {
|
|
|
2091
2103
|
}
|
|
2092
2104
|
return t;
|
|
2093
2105
|
}
|
|
2094
|
-
function
|
|
2095
|
-
let t =
|
|
2106
|
+
function Gn(e) {
|
|
2107
|
+
let t = Hn(e);
|
|
2096
2108
|
return {
|
|
2097
2109
|
rawElements: t,
|
|
2098
|
-
fields:
|
|
2099
|
-
header:
|
|
2110
|
+
fields: Wn(t),
|
|
2111
|
+
header: Vn(e)
|
|
2100
2112
|
};
|
|
2101
2113
|
}
|
|
2102
|
-
function
|
|
2114
|
+
function Kn() {
|
|
2103
2115
|
return {};
|
|
2104
2116
|
}
|
|
2105
|
-
function
|
|
2106
|
-
for (let r of
|
|
2117
|
+
function qn(e, t, n) {
|
|
2118
|
+
for (let r of Pn) t[r] && (e[r] = n);
|
|
2107
2119
|
return e;
|
|
2108
2120
|
}
|
|
2109
2121
|
//#endregion
|
|
2110
2122
|
//#region src/sdk/face-model.ts
|
|
2111
|
-
var
|
|
2112
|
-
function
|
|
2123
|
+
var Jn = /* @__PURE__ */ new Map(), Yn = 8400;
|
|
2124
|
+
function Xn(e, t) {
|
|
2113
2125
|
let n = Math.max(0, Math.min(e.x + e.width, t.x + t.width) - Math.max(e.x, t.x)) * Math.max(0, Math.min(e.y + e.height, t.y + t.height) - Math.max(e.y, t.y));
|
|
2114
2126
|
return n / Math.max(1, e.width * e.height + t.width * t.height - n);
|
|
2115
2127
|
}
|
|
2116
|
-
function
|
|
2128
|
+
function Zn(e, t, n, r, i, a, o) {
|
|
2117
2129
|
return {
|
|
2118
2130
|
x: (e - n / 2) / i * a,
|
|
2119
2131
|
y: (t - r / 2) / i * o,
|
|
@@ -2121,20 +2133,20 @@ function Jn(e, t, n, r, i, a, o) {
|
|
|
2121
2133
|
height: r / i * o
|
|
2122
2134
|
};
|
|
2123
2135
|
}
|
|
2124
|
-
function
|
|
2136
|
+
function Qn(e, t, n) {
|
|
2125
2137
|
let r = t.length === 3 ? t[1] : t[0], i = t.length === 3 ? t[2] : t[1];
|
|
2126
|
-
if (i !== 6 || r < 1) throw Error(`Face model expects [1, anchors, 6]. A 640 YOLOX-Nano face export is [1, ${
|
|
2138
|
+
if (i !== 6 || r < 1) throw Error(`Face model expects [1, anchors, 6]. A 640 YOLOX-Nano face export is [1, ${Yn}, 6].`);
|
|
2127
2139
|
let a = n.confidence ?? .35, o = n.inputSize ?? 640, s = [];
|
|
2128
2140
|
for (let t = 0; t < r; t += 1) {
|
|
2129
2141
|
let r = t * i, c = e[r + 4] * e[r + 5];
|
|
2130
2142
|
c < a || s.push({
|
|
2131
2143
|
confidence: c,
|
|
2132
|
-
bbox:
|
|
2144
|
+
bbox: Zn(e[r], e[r + 1], e[r + 2], e[r + 3], o, n.imageWidth, n.imageHeight)
|
|
2133
2145
|
});
|
|
2134
2146
|
}
|
|
2135
|
-
return s.sort((e, t) => t.confidence - e.confidence).filter((e, t, n) => n.slice(0, t).every((t) =>
|
|
2147
|
+
return s.sort((e, t) => t.confidence - e.confidence).filter((e, t, n) => n.slice(0, t).every((t) => Xn(e.bbox, t.bbox) < .45)).slice(0, 8);
|
|
2136
2148
|
}
|
|
2137
|
-
async function
|
|
2149
|
+
async function $n(e, n, r = .35) {
|
|
2138
2150
|
let i = await P(e, { cloneCanvas: !1 }), a = await import("onnxruntime-web"), o = document.createElement("canvas");
|
|
2139
2151
|
o.width = 640, o.height = 640;
|
|
2140
2152
|
let s = o.getContext("2d", { willReadFrequently: !0 });
|
|
@@ -2142,18 +2154,18 @@ async function Xn(e, n, r = .35) {
|
|
|
2142
2154
|
s.drawImage(i, 0, 0, 640, 640);
|
|
2143
2155
|
let c = s.getImageData(0, 0, 640, 640).data, l = 409600, u = new Float32Array(l * 3);
|
|
2144
2156
|
for (let e = 0; e < l; e += 1) u[e] = c[e * 4] / 255, u[l + e] = c[e * 4 + 1] / 255, u[l * 2 + e] = c[e * 4 + 2] / 255;
|
|
2145
|
-
let d =
|
|
2157
|
+
let d = Jn.get(n);
|
|
2146
2158
|
d || (d = a.InferenceSession.create(n, {
|
|
2147
2159
|
executionProviders: ["wasm"],
|
|
2148
2160
|
graphOptimizationLevel: "all"
|
|
2149
|
-
}),
|
|
2161
|
+
}), Jn.set(n, d));
|
|
2150
2162
|
let f = await d, p = (await f.run({ [f.inputNames[0]]: new a.Tensor("float32", u, [
|
|
2151
2163
|
1,
|
|
2152
2164
|
3,
|
|
2153
2165
|
640,
|
|
2154
2166
|
640
|
|
2155
2167
|
]) }))[f.outputNames[0]];
|
|
2156
|
-
return
|
|
2168
|
+
return Qn(p.data, p.dims.map(Number), {
|
|
2157
2169
|
confidence: r,
|
|
2158
2170
|
imageWidth: i.width,
|
|
2159
2171
|
imageHeight: i.height,
|
|
@@ -2162,7 +2174,7 @@ async function Xn(e, n, r = .35) {
|
|
|
2162
2174
|
}
|
|
2163
2175
|
//#endregion
|
|
2164
2176
|
//#region src/sdk/field-model.ts
|
|
2165
|
-
var q = /* @__PURE__ */ new Map(),
|
|
2177
|
+
var q = /* @__PURE__ */ new Map(), er = [
|
|
2166
2178
|
"person_name",
|
|
2167
2179
|
"date_of_birth",
|
|
2168
2180
|
"address",
|
|
@@ -2170,19 +2182,19 @@ var q = /* @__PURE__ */ new Map(), Zn = [
|
|
|
2170
2182
|
"expiration_date",
|
|
2171
2183
|
"postal_code",
|
|
2172
2184
|
"state"
|
|
2173
|
-
],
|
|
2174
|
-
function
|
|
2185
|
+
], tr = 8400;
|
|
2186
|
+
function nr(e) {
|
|
2175
2187
|
return 5 + e;
|
|
2176
2188
|
}
|
|
2177
|
-
var
|
|
2178
|
-
function
|
|
2189
|
+
var rr = 640;
|
|
2190
|
+
function ir(e, t) {
|
|
2179
2191
|
let n = Math.max(0, Math.min(e.bbox.x + e.bbox.width, t.bbox.x + t.bbox.width) - Math.max(e.bbox.x, t.bbox.x)) * Math.max(0, Math.min(e.bbox.y + e.bbox.height, t.bbox.y + t.bbox.height) - Math.max(e.bbox.y, t.bbox.y));
|
|
2180
2192
|
return n / Math.max(1, e.bbox.width * e.bbox.height + t.bbox.width * t.bbox.height - n);
|
|
2181
2193
|
}
|
|
2182
|
-
function
|
|
2183
|
-
return e.sort((e, t) => t.confidence - e.confidence).filter((e, t, n) => n.slice(0, t).every((t) => t.field !== e.field ||
|
|
2194
|
+
function ar(e) {
|
|
2195
|
+
return e.sort((e, t) => t.confidence - e.confidence).filter((e, t, n) => n.slice(0, t).every((t) => t.field !== e.field || ir(e, t) < .45)).slice(0, 30);
|
|
2184
2196
|
}
|
|
2185
|
-
function
|
|
2197
|
+
function or(e, t, n, r, i, a, o) {
|
|
2186
2198
|
return {
|
|
2187
2199
|
x: (e - n / 2) / i * a,
|
|
2188
2200
|
y: (t - r / 2) / i * o,
|
|
@@ -2190,8 +2202,8 @@ function rr(e, t, n, r, i, a, o) {
|
|
|
2190
2202
|
height: r / i * o
|
|
2191
2203
|
};
|
|
2192
2204
|
}
|
|
2193
|
-
function
|
|
2194
|
-
let n =
|
|
2205
|
+
function sr(e, t) {
|
|
2206
|
+
let n = nr(t);
|
|
2195
2207
|
return e.length === 3 && e[0] === 1 && e[2] === n && e[1] > e[2] ? {
|
|
2196
2208
|
anchors: e[1],
|
|
2197
2209
|
features: n
|
|
@@ -2200,15 +2212,15 @@ function ir(e, t) {
|
|
|
2200
2212
|
features: n
|
|
2201
2213
|
} : null;
|
|
2202
2214
|
}
|
|
2203
|
-
function
|
|
2215
|
+
function cr(e) {
|
|
2204
2216
|
return e.length === 3 && e[1] >= 5 && e[2] >= 1;
|
|
2205
2217
|
}
|
|
2206
|
-
function
|
|
2207
|
-
let t =
|
|
2208
|
-
return /* @__PURE__ */ Error(`YOLOX field layout expects [1, anchors, ${t}] (cx, cy, w, h, objectness, ${e} class scores). A 640 YOLOX-Nano export with decode baked in is [1, ${
|
|
2218
|
+
function lr(e) {
|
|
2219
|
+
let t = nr(e);
|
|
2220
|
+
return /* @__PURE__ */ Error(`YOLOX field layout expects [1, anchors, ${t}] (cx, cy, w, h, objectness, ${e} class scores). A 640 YOLOX-Nano export with decode baked in is [1, ${tr}, ${t}].`);
|
|
2209
2221
|
}
|
|
2210
|
-
function
|
|
2211
|
-
if (!
|
|
2222
|
+
function ur(e, t, n, r, i, a, o) {
|
|
2223
|
+
if (!cr(t)) throw Error("Unsupported field-model YOLO output shape.");
|
|
2212
2224
|
let s = t[1], c = t[2], l = [];
|
|
2213
2225
|
for (let t = 0; t < c; t += 1) {
|
|
2214
2226
|
let u = 0, d = 0;
|
|
@@ -2220,14 +2232,14 @@ function sr(e, t, n, r, i, a, o) {
|
|
|
2220
2232
|
!f || u < r || l.push({
|
|
2221
2233
|
field: f,
|
|
2222
2234
|
confidence: u,
|
|
2223
|
-
bbox:
|
|
2235
|
+
bbox: or(e[t], e[c + t], e[c * 2 + t], e[c * 3 + t], i, a, o)
|
|
2224
2236
|
});
|
|
2225
2237
|
}
|
|
2226
|
-
return
|
|
2238
|
+
return ar(l);
|
|
2227
2239
|
}
|
|
2228
|
-
function
|
|
2229
|
-
let s =
|
|
2230
|
-
if (!s) throw
|
|
2240
|
+
function dr(e, t, n, r, i, a, o) {
|
|
2241
|
+
let s = sr(t, n.length);
|
|
2242
|
+
if (!s) throw lr(n.length);
|
|
2231
2243
|
let c = [];
|
|
2232
2244
|
for (let t = 0; t < s.anchors; t += 1) {
|
|
2233
2245
|
let l = t * s.features, u = e[l + 4], d = 0, f = 0;
|
|
@@ -2239,18 +2251,18 @@ function cr(e, t, n, r, i, a, o) {
|
|
|
2239
2251
|
!p || m < r || c.push({
|
|
2240
2252
|
field: p,
|
|
2241
2253
|
confidence: m,
|
|
2242
|
-
bbox:
|
|
2254
|
+
bbox: or(e[l], e[l + 1], e[l + 2], e[l + 3], i, a, o)
|
|
2243
2255
|
});
|
|
2244
2256
|
}
|
|
2245
|
-
return
|
|
2257
|
+
return ar(c);
|
|
2246
2258
|
}
|
|
2247
|
-
function
|
|
2248
|
-
let r = n.classes ??
|
|
2259
|
+
function fr(e, t, n) {
|
|
2260
|
+
let r = n.classes ?? er, i = n.confidence ?? .35, a = n.inputSize ?? rr, o = sr(t, r.length);
|
|
2249
2261
|
if (n.layout === "yolov8" && o) throw Error("This tensor is YOLOX [1, anchors, 5+classes]. Pass fieldLayout: 'yolox', or omit fieldLayout to detect it from the shape.");
|
|
2250
|
-
return (n.layout ?? (o ? "yolox" : "yolov8")) === "yolox" ?
|
|
2262
|
+
return (n.layout ?? (o ? "yolox" : "yolov8")) === "yolox" ? dr(e, t, r, i, a, n.imageWidth, n.imageHeight) : ur(e, t, r, i, a, n.imageWidth, n.imageHeight);
|
|
2251
2263
|
}
|
|
2252
|
-
async function
|
|
2253
|
-
let o = await P(e, { cloneCanvas: !1 }), s = import("onnxruntime-web"), c =
|
|
2264
|
+
async function pr(e, n, r = er, i = .35, a) {
|
|
2265
|
+
let o = await P(e, { cloneCanvas: !1 }), s = import("onnxruntime-web"), c = rr, l = document.createElement("canvas");
|
|
2254
2266
|
l.width = c, l.height = c;
|
|
2255
2267
|
let u = l.getContext("2d", { willReadFrequently: !0 });
|
|
2256
2268
|
if (!u) throw t();
|
|
@@ -2275,7 +2287,7 @@ async function ur(e, n, r = Zn, i = .35, a) {
|
|
|
2275
2287
|
c,
|
|
2276
2288
|
c
|
|
2277
2289
|
]) }))[g.outputNames[0]];
|
|
2278
|
-
return
|
|
2290
|
+
return fr(_.data, _.dims.map(Number), {
|
|
2279
2291
|
classes: r,
|
|
2280
2292
|
confidence: i,
|
|
2281
2293
|
layout: a,
|
|
@@ -2286,7 +2298,7 @@ async function ur(e, n, r = Zn, i = .35, a) {
|
|
|
2286
2298
|
}
|
|
2287
2299
|
//#endregion
|
|
2288
2300
|
//#region src/sdk/redact.ts
|
|
2289
|
-
async function
|
|
2301
|
+
async function mr(e, n, r = {}) {
|
|
2290
2302
|
await x("redaction");
|
|
2291
2303
|
let i = await P(e), a = i.getContext("2d");
|
|
2292
2304
|
if (!a) throw t();
|
|
@@ -2321,7 +2333,7 @@ function J(e) {
|
|
|
2321
2333
|
height: i - n
|
|
2322
2334
|
};
|
|
2323
2335
|
}
|
|
2324
|
-
function
|
|
2336
|
+
function hr(e) {
|
|
2325
2337
|
let t = [], n = [...e].sort((e, t) => e.bbox.y + e.bbox.height / 2 - (t.bbox.y + t.bbox.height / 2) || e.bbox.x - t.bbox.x);
|
|
2326
2338
|
for (let e of n) {
|
|
2327
2339
|
let n = e.bbox.y + e.bbox.height / 2, r = t.find((t) => {
|
|
@@ -2343,7 +2355,7 @@ function Y(e, t, n = !1) {
|
|
|
2343
2355
|
function X(e) {
|
|
2344
2356
|
return e.reduce((e, t) => e + t.confidence, 0) / Math.max(1, e.length);
|
|
2345
2357
|
}
|
|
2346
|
-
function
|
|
2358
|
+
function gr(e, t) {
|
|
2347
2359
|
let n = e.mode, r = n === "case-insensitive", i = e.scope ?? "line", a;
|
|
2348
2360
|
if (n === "regex") {
|
|
2349
2361
|
let t = e.pattern ?? e.values?.[0];
|
|
@@ -2380,22 +2392,22 @@ function pr(e, t) {
|
|
|
2380
2392
|
}
|
|
2381
2393
|
return s;
|
|
2382
2394
|
}
|
|
2383
|
-
function
|
|
2395
|
+
function _r(e, t) {
|
|
2384
2396
|
let n = e.labelMode !== "exact", r = Y(e.label, n, !0).split(" ");
|
|
2385
2397
|
for (let e of t) for (let t = 0; t <= e.words.length - r.length; t += 1) {
|
|
2386
2398
|
let i = e.words.slice(t, t + r.length);
|
|
2387
2399
|
if (i.every((e, t) => Y(e.text, n, !0) === r[t])) return i;
|
|
2388
2400
|
}
|
|
2389
2401
|
}
|
|
2390
|
-
function
|
|
2402
|
+
function vr(e, t, n, r, i, a) {
|
|
2391
2403
|
let o = a.window?.distance ?? .28, s = a.window?.crossAxis ?? .12, c = t.x + t.width / 2, l = t.y + t.height / 2;
|
|
2392
2404
|
return e.filter((e) => {
|
|
2393
2405
|
let a = e.bbox.x + e.bbox.width / 2, u = e.bbox.y + e.bbox.height / 2;
|
|
2394
2406
|
return n === "right" ? e.bbox.x >= t.x + t.width && e.bbox.x - t.x - t.width <= r * o && Math.abs(u - l) <= i * s : n === "left" ? e.bbox.x + e.bbox.width <= t.x && t.x - e.bbox.x - e.bbox.width <= r * o && Math.abs(u - l) <= i * s : n === "below" ? e.bbox.y >= t.y + t.height && e.bbox.y - t.y - t.height <= i * o && Math.abs(a - c) <= r * s : e.bbox.y + e.bbox.height <= t.y && t.y - e.bbox.y - e.bbox.height <= i * o && Math.abs(a - c) <= r * s;
|
|
2395
2407
|
});
|
|
2396
2408
|
}
|
|
2397
|
-
function
|
|
2398
|
-
let o =
|
|
2409
|
+
function yr(e, t, n, r, i, a = "label") {
|
|
2410
|
+
let o = _r(e, n);
|
|
2399
2411
|
if (!o) return [];
|
|
2400
2412
|
let s = J(o), c = new Set(o), l = t.filter((e) => !c.has(e)), u = e.direction === "any" ? [
|
|
2401
2413
|
"right",
|
|
@@ -2404,7 +2416,7 @@ function gr(e, t, n, r, i, a = "label") {
|
|
|
2404
2416
|
"above"
|
|
2405
2417
|
] : [e.direction], d;
|
|
2406
2418
|
for (let t of u) {
|
|
2407
|
-
let n =
|
|
2419
|
+
let n = hr(vr(l, s, t, r, i, e));
|
|
2408
2420
|
for (let t of n) {
|
|
2409
2421
|
if (e.valuePattern && !new RegExp(e.valuePattern, e.patternFlags).test(t.text)) continue;
|
|
2410
2422
|
let n = t.bbox.x + t.bbox.width / 2, a = t.bbox.y + t.bbox.height / 2, o = s.x + s.width / 2, c = s.y + s.height / 2, l = Math.hypot((n - o) / r, (a - c) / i);
|
|
@@ -2425,7 +2437,7 @@ function gr(e, t, n, r, i, a = "label") {
|
|
|
2425
2437
|
confidence: Math.max(0, X(d.words) * (1 - Math.min(.5, d.distance)))
|
|
2426
2438
|
}];
|
|
2427
2439
|
}
|
|
2428
|
-
var
|
|
2440
|
+
var br = {
|
|
2429
2441
|
person_name: [
|
|
2430
2442
|
"LN",
|
|
2431
2443
|
"FN",
|
|
@@ -2462,10 +2474,10 @@ var _r = {
|
|
|
2462
2474
|
"POSTAL"
|
|
2463
2475
|
],
|
|
2464
2476
|
state: ["STATE", "DAJ"]
|
|
2465
|
-
},
|
|
2477
|
+
}, xr = new Set(Object.values(br).flat()), Sr = /^(?:\d{2}[/-]\d{2}[/-]\d{2,4}|\d{4}[/-]\d{2}[/-]\d{2}|\d{6}|\d{8})$/, Cr = /\b(?:ST|STREET|AVE|AVENUE|RD|ROAD|BLVD|BOULEVARD|LN|LANE|DR|DRIVE|WAY|CT|COURT)\b/i, wr = /\b(?:DRIVER|LICENSE|IDENTIFICATION|CARD|CLASS|SEX|EYES|HEIGHT|RESTRICTIONS)\b/i;
|
|
2466
2478
|
function Z(e, t) {
|
|
2467
2479
|
let n = t.trim();
|
|
2468
|
-
return n ? e === "date_of_birth" || e === "expiration_date" ?
|
|
2480
|
+
return n ? e === "date_of_birth" || e === "expiration_date" ? Sr.test(n.replace(/\s/g, "")) : e === "postal_code" ? /^(?:\d{5}(?:-\d{4})?|[A-Z]\d[A-Z]\s?\d[A-Z]\d)$/i.test(n) : e === "state" ? /^[A-Z]{2}$/i.test(n) : e === "document_number" ? /^(?=.*\d)[A-Z0-9-]{5,20}$/i.test(n) : e === "person_name" ? !/\d/.test(n) && /^[A-ZÀ-ÖØ-öø-ÿ' -]{3,}$/i.test(n) && !wr.test(n) : /\d/.test(n) && /[A-Z]/i.test(n) : !1;
|
|
2469
2481
|
}
|
|
2470
2482
|
function Q(e, t, n, r, i = 1) {
|
|
2471
2483
|
return {
|
|
@@ -2477,17 +2489,17 @@ function Q(e, t, n, r, i = 1) {
|
|
|
2477
2489
|
confidence: Math.max(0, Math.min(1, X(n) * i))
|
|
2478
2490
|
};
|
|
2479
2491
|
}
|
|
2480
|
-
function
|
|
2481
|
-
let r =
|
|
2492
|
+
function Tr(e, t, n) {
|
|
2493
|
+
let r = br[e], i = [];
|
|
2482
2494
|
for (let a of n) for (let n = 0; n < a.words.length; n += 1) {
|
|
2483
2495
|
let o = a.words[n].text.toUpperCase().replace(/[^A-Z0-9]/g, ""), s = r.find((e) => o === e || o.startsWith(e));
|
|
2484
2496
|
if (!s) continue;
|
|
2485
2497
|
let c, l;
|
|
2486
|
-
o === s ? (c = a.words.slice(n + 1).filter((e) => !
|
|
2498
|
+
o === s ? (c = a.words.slice(n + 1).filter((e) => !xr.has(e.text.toUpperCase().replace(/[^A-Z0-9]/g, ""))), l = c.map((e) => e.text).join(" ")) : (c = [a.words[n]], l = a.words[n].text.replace(RegExp(`^${s}[:\\s-]*`, "i"), "")), c.length && Z(e, l) && i.push(Q(t, "alias", c, l, .98));
|
|
2487
2499
|
}
|
|
2488
2500
|
return i;
|
|
2489
2501
|
}
|
|
2490
|
-
function
|
|
2502
|
+
function Er(e, t, n) {
|
|
2491
2503
|
let r = n.filter((e) => {
|
|
2492
2504
|
let t = e.text.replace(/\s/g, "");
|
|
2493
2505
|
return t.includes("<<") || /^[A-Z0-9<]{25,}$/.test(t);
|
|
@@ -2509,7 +2521,7 @@ function Cr(e, t, n) {
|
|
|
2509
2521
|
}
|
|
2510
2522
|
return [];
|
|
2511
2523
|
}
|
|
2512
|
-
function
|
|
2524
|
+
function Dr(e) {
|
|
2513
2525
|
let t = e.replace(/\s/g, ""), n = t.match(/\d{4}/)?.[0];
|
|
2514
2526
|
if (n) return Number(n);
|
|
2515
2527
|
let r = t.match(/^\d{2}/)?.[0];
|
|
@@ -2517,16 +2529,16 @@ function wr(e) {
|
|
|
2517
2529
|
let i = Number(r);
|
|
2518
2530
|
return i > (/* @__PURE__ */ new Date()).getFullYear() % 100 ? 1900 + i : 2e3 + i;
|
|
2519
2531
|
}
|
|
2520
|
-
function
|
|
2532
|
+
function Or(e, t, n, r, i) {
|
|
2521
2533
|
if (e === "address") {
|
|
2522
|
-
let e = r.findIndex((e) => /\d/.test(e.text) &&
|
|
2534
|
+
let e = r.findIndex((e) => /\d/.test(e.text) && Cr.test(e.text));
|
|
2523
2535
|
if (e < 0) return [];
|
|
2524
2536
|
let n = [...r[e].words], i = r[e + 1];
|
|
2525
2537
|
return i && /(?:\b[A-Z]{2}\b.*\d{5}|\d{5})/i.test(i.text) && n.push(...i.words), [Q(t, "layout", n, void 0, .76)];
|
|
2526
2538
|
}
|
|
2527
2539
|
if (e === "person_name") {
|
|
2528
2540
|
let e = r.map((e) => {
|
|
2529
|
-
let t = e.words.filter((e) => /^[A-ZÀ-ÖØ-öø-ÿ'-]+$/i.test(e.text)), n = e.bbox.y / Math.max(1, i), r = t.length >= 2 && t.length <= 5 && t.length === e.words.length && !
|
|
2541
|
+
let t = e.words.filter((e) => /^[A-ZÀ-ÖØ-öø-ÿ'-]+$/i.test(e.text)), n = e.bbox.y / Math.max(1, i), r = t.length >= 2 && t.length <= 5 && t.length === e.words.length && !wr.test(e.text) && !Cr.test(e.text) && !e.text.includes("<"), a = e.text.replace(/[^A-Z]/g, "").length / Math.max(1, e.text.replace(/[^A-Za-z]/g, "").length);
|
|
2530
2542
|
return {
|
|
2531
2543
|
line: e,
|
|
2532
2544
|
score: r ? .45 + X(e.words) * .3 + a * .15 + (n < .65 ? .1 : 0) : 0
|
|
@@ -2535,9 +2547,9 @@ function Tr(e, t, n, r, i) {
|
|
|
2535
2547
|
return !e.length || e[1] && e[0].score - e[1].score < .04 ? [] : [Q(t, "layout", e[0].line.words, void 0, e[0].score)];
|
|
2536
2548
|
}
|
|
2537
2549
|
if (e === "date_of_birth" || e === "expiration_date") {
|
|
2538
|
-
let r = (/* @__PURE__ */ new Date()).getFullYear(), i = n.filter((e) =>
|
|
2550
|
+
let r = (/* @__PURE__ */ new Date()).getFullYear(), i = n.filter((e) => Sr.test(e.text.replace(/\s/g, ""))).map((e) => ({
|
|
2539
2551
|
word: e,
|
|
2540
|
-
year:
|
|
2552
|
+
year: Dr(e.text)
|
|
2541
2553
|
})).filter((e) => e.year !== void 0), a = e === "date_of_birth" ? i.filter((e) => e.year <= r - 14 && e.year >= r - 120) : i.filter((e) => e.year >= r - 1);
|
|
2542
2554
|
return a.sort((t, n) => e === "date_of_birth" ? t.year - n.year : n.year - t.year), a.length ? [Q(t, "layout", [a[0].word], void 0, .72)] : [];
|
|
2543
2555
|
}
|
|
@@ -2555,29 +2567,29 @@ function Tr(e, t, n, r, i) {
|
|
|
2555
2567
|
}
|
|
2556
2568
|
return [];
|
|
2557
2569
|
}
|
|
2558
|
-
function
|
|
2570
|
+
function kr(e, t) {
|
|
2559
2571
|
return Math.max(0, Math.min(e.x + e.width, t.x + t.width) - Math.max(e.x, t.x)) * Math.max(0, Math.min(e.y + e.height, t.y + t.height) - Math.max(e.y, t.y)) / Math.max(1, t.width * t.height);
|
|
2560
2572
|
}
|
|
2561
|
-
function
|
|
2562
|
-
let i =
|
|
2563
|
-
return i.length || a.length ? [...i, ...a] :
|
|
2573
|
+
function Ar(e, t, n, r) {
|
|
2574
|
+
let i = Tr(e.field, e.id, n), a = Er(e.field, e.id, n);
|
|
2575
|
+
return i.length || a.length ? [...i, ...a] : Or(e.field, e.id, t, n, r);
|
|
2564
2576
|
}
|
|
2565
|
-
function
|
|
2577
|
+
function jr(e, t, n) {
|
|
2566
2578
|
let r = (n ?? []).filter((t) => t.field === e.field).sort((e, t) => t.confidence - e.confidence);
|
|
2567
2579
|
for (let n of r) {
|
|
2568
|
-
let r = t.filter((e) =>
|
|
2580
|
+
let r = t.filter((e) => kr(n.bbox, e.bbox) >= .3);
|
|
2569
2581
|
if (!r.length) continue;
|
|
2570
2582
|
let i = r.map((e) => e.text).join(" ");
|
|
2571
2583
|
if (Z(e.field, i)) return Q(e.id, "model", r, i, n.confidence);
|
|
2572
2584
|
}
|
|
2573
2585
|
}
|
|
2574
|
-
function
|
|
2575
|
-
let o =
|
|
2586
|
+
function Mr(e, t, n, r, i, a) {
|
|
2587
|
+
let o = Ar(e, t, n, r);
|
|
2576
2588
|
if (e.detector !== "model" || !a) return o;
|
|
2577
|
-
let s =
|
|
2589
|
+
let s = jr(e, t, i);
|
|
2578
2590
|
return s ? [s] : [];
|
|
2579
2591
|
}
|
|
2580
|
-
function
|
|
2592
|
+
function Nr(e, t, n, r) {
|
|
2581
2593
|
let i = (e) => Math.max(0, Math.min(1, e)), a = i(e.rect.x), o = i(e.rect.y);
|
|
2582
2594
|
return {
|
|
2583
2595
|
ruleId: `${t}.${e.id}`,
|
|
@@ -2593,18 +2605,18 @@ function Ar(e, t, n, r) {
|
|
|
2593
2605
|
};
|
|
2594
2606
|
}
|
|
2595
2607
|
function $(e, t) {
|
|
2596
|
-
let n = t.imageWidth ?? e?.imageWidth ?? 0, r = t.imageHeight ?? e?.imageHeight ?? 0, i = e?.words ?? [], a =
|
|
2608
|
+
let n = t.imageWidth ?? e?.imageWidth ?? 0, r = t.imageHeight ?? e?.imageHeight ?? 0, i = e?.words ?? [], a = hr(i), o = [], s = [];
|
|
2597
2609
|
for (let e of t.rules) {
|
|
2598
|
-
let c = e.strategy === "string" ?
|
|
2610
|
+
let c = e.strategy === "string" ? gr(e, a) : e.strategy === "label" ? yr(e, i, a, n, r) : Mr(e, i, a, r, t.semanticDetections, t.modelRequested === !0);
|
|
2599
2611
|
c.length ? o.push(...c) : s.push(e.id);
|
|
2600
2612
|
}
|
|
2601
2613
|
for (let e of t.template?.fields ?? []) {
|
|
2602
2614
|
let c = `${t.template.id}.${e.id}`;
|
|
2603
2615
|
if (e.strategy === "rect") {
|
|
2604
|
-
n && r ? o.push(
|
|
2616
|
+
n && r ? o.push(Nr(e, t.template.id, n, r)) : s.push(c);
|
|
2605
2617
|
continue;
|
|
2606
2618
|
}
|
|
2607
|
-
let l =
|
|
2619
|
+
let l = yr({
|
|
2608
2620
|
...e,
|
|
2609
2621
|
id: c,
|
|
2610
2622
|
strategy: "label"
|
|
@@ -2622,19 +2634,19 @@ function $(e, t) {
|
|
|
2622
2634
|
confidence: u
|
|
2623
2635
|
};
|
|
2624
2636
|
}
|
|
2625
|
-
function
|
|
2637
|
+
function Pr(e) {
|
|
2626
2638
|
return e.rules.length > 0 || e.template?.fields.some((e) => e.strategy === "anchor") === !0;
|
|
2627
2639
|
}
|
|
2628
|
-
function
|
|
2640
|
+
function Fr(e, t = !1) {
|
|
2629
2641
|
return t && !e.complete ? "unmatched" : e.complete ? "success" : "partial";
|
|
2630
2642
|
}
|
|
2631
|
-
async function
|
|
2643
|
+
async function Ir(e, t) {
|
|
2632
2644
|
await x("redaction");
|
|
2633
2645
|
let n = await P(e, { cloneCanvas: !1 }), r = t.ocr;
|
|
2634
|
-
|
|
2646
|
+
Pr(t) && !r && (r = await H(n, { includeWords: !0 }));
|
|
2635
2647
|
let i = t.semanticDetections, a = t.modelRequested === !0, o = "not-requested", s;
|
|
2636
2648
|
if (t.models?.fields) try {
|
|
2637
|
-
i = await
|
|
2649
|
+
i = await pr(n, t.models.fields, t.models.fieldClasses, t.models.confidence, t.models.fieldLayout), a = !0, o = "loaded";
|
|
2638
2650
|
} catch (e) {
|
|
2639
2651
|
s = e instanceof Error ? e.message : "The field model could not load.";
|
|
2640
2652
|
let n = t.models.allowHeuristicFallback !== !1;
|
|
@@ -2647,9 +2659,9 @@ async function Nr(e, t) {
|
|
|
2647
2659
|
imageHeight: n.height,
|
|
2648
2660
|
semanticDetections: i,
|
|
2649
2661
|
modelRequested: a
|
|
2650
|
-
}), l =
|
|
2662
|
+
}), l = Fr(c, t.requireAll), u = [], d = "not-requested", f;
|
|
2651
2663
|
if (t.models?.face) try {
|
|
2652
|
-
u = await
|
|
2664
|
+
u = await $n(n, t.models.face, t.models.faceConfidence), d = "loaded";
|
|
2653
2665
|
} catch (e) {
|
|
2654
2666
|
f = e instanceof Error ? e.message : "The face model could not load.", d = "failed";
|
|
2655
2667
|
}
|
|
@@ -2663,7 +2675,7 @@ async function Nr(e, t) {
|
|
|
2663
2675
|
faceStatus: d,
|
|
2664
2676
|
faceError: f
|
|
2665
2677
|
};
|
|
2666
|
-
let p = await
|
|
2678
|
+
let p = await mr(n, [...c.matches.map((e) => ({
|
|
2667
2679
|
...e.bbox,
|
|
2668
2680
|
mode: t.style?.mode
|
|
2669
2681
|
})), ...u.map((e) => ({
|
|
@@ -2685,7 +2697,7 @@ async function Nr(e, t) {
|
|
|
2685
2697
|
}
|
|
2686
2698
|
//#endregion
|
|
2687
2699
|
//#region src/sdk/driver-license.ts
|
|
2688
|
-
var
|
|
2700
|
+
var Lr = [
|
|
2689
2701
|
{
|
|
2690
2702
|
id: "issuerJurisdiction",
|
|
2691
2703
|
strategy: "semantic",
|
|
@@ -2722,7 +2734,7 @@ var Pr = [
|
|
|
2722
2734
|
field: "person_name"
|
|
2723
2735
|
}
|
|
2724
2736
|
];
|
|
2725
|
-
function
|
|
2737
|
+
function Rr(e, t, n) {
|
|
2726
2738
|
let r = n.trim();
|
|
2727
2739
|
if (r) {
|
|
2728
2740
|
if (t === "expirationDate" || t === "dateOfBirth" || t === "issueDate") {
|
|
@@ -2736,8 +2748,8 @@ function Fr(e, t, n) {
|
|
|
2736
2748
|
e[t] = r;
|
|
2737
2749
|
}
|
|
2738
2750
|
}
|
|
2739
|
-
function
|
|
2740
|
-
let t = {}, n = $(e, { rules:
|
|
2751
|
+
function zr(e) {
|
|
2752
|
+
let t = {}, n = $(e, { rules: Lr });
|
|
2741
2753
|
for (let e of n.matches) {
|
|
2742
2754
|
let n = e.text?.trim();
|
|
2743
2755
|
if (n) {
|
|
@@ -2746,29 +2758,29 @@ function Ir(e) {
|
|
|
2746
2758
|
!t.firstName && e[0] && (t.firstName = e[0]), !t.lastName && e.length > 1 && (t.lastName = e[e.length - 1]), !t.middleName && e.length > 2 && (t.middleName = e.slice(1, -1).join(" "));
|
|
2747
2759
|
continue;
|
|
2748
2760
|
}
|
|
2749
|
-
|
|
2761
|
+
Rr(t, e.ruleId, n);
|
|
2750
2762
|
}
|
|
2751
2763
|
}
|
|
2752
2764
|
return t;
|
|
2753
2765
|
}
|
|
2754
|
-
function
|
|
2755
|
-
let n = { ...e }, r =
|
|
2766
|
+
function Br(e, t) {
|
|
2767
|
+
let n = { ...e }, r = qn(Kn(), e, "barcode");
|
|
2756
2768
|
for (let [e, i] of Object.entries(t)) i && (n[e] || (n[e] = i, r[e] = "ocr"));
|
|
2757
2769
|
return {
|
|
2758
2770
|
fields: n,
|
|
2759
2771
|
sources: r
|
|
2760
2772
|
};
|
|
2761
2773
|
}
|
|
2762
|
-
async function
|
|
2774
|
+
async function Vr(e, t, n) {
|
|
2763
2775
|
return t?.status === "success" && t.corners ? ct(e, t.corners, { maxOutputDimension: n?.maxOutputDimension }) : R(e, n);
|
|
2764
2776
|
}
|
|
2765
|
-
async function
|
|
2777
|
+
async function Hr(e, t, n) {
|
|
2766
2778
|
if (!e.width || !e.height) return {
|
|
2767
2779
|
kind: "retry",
|
|
2768
2780
|
status: "frontFailed",
|
|
2769
2781
|
message: "The front photo was empty. Try again."
|
|
2770
2782
|
};
|
|
2771
|
-
let r = await
|
|
2783
|
+
let r = await Vr(e, t, n);
|
|
2772
2784
|
if (r.status !== "success" || !r.canvas) return {
|
|
2773
2785
|
kind: "retry",
|
|
2774
2786
|
status: "frontFailed",
|
|
@@ -2789,7 +2801,7 @@ async function zr(e, t, n) {
|
|
|
2789
2801
|
}
|
|
2790
2802
|
};
|
|
2791
2803
|
}
|
|
2792
|
-
async function
|
|
2804
|
+
async function Ur(e, t, n) {
|
|
2793
2805
|
if (!e.width || !e.height) return {
|
|
2794
2806
|
status: "backFailed",
|
|
2795
2807
|
fields: {},
|
|
@@ -2799,25 +2811,25 @@ async function Br(e, t, n) {
|
|
|
2799
2811
|
back: {},
|
|
2800
2812
|
message: "The back photo was empty. Try again."
|
|
2801
2813
|
};
|
|
2802
|
-
let r = await
|
|
2814
|
+
let r = await Vr(e, void 0, n), i = r.status === "success" ? r.canvas : void 0, a;
|
|
2803
2815
|
i && (a = (await U(i))?.text), a ||= (await U(e))?.text;
|
|
2804
2816
|
let o = {
|
|
2805
2817
|
canvas: i ?? e,
|
|
2806
2818
|
barcodeText: a
|
|
2807
2819
|
};
|
|
2808
2820
|
if (!a) {
|
|
2809
|
-
let e = t.ocr ?
|
|
2821
|
+
let e = t.ocr ? zr(t.ocr) : {};
|
|
2810
2822
|
return {
|
|
2811
2823
|
status: "barcodeUnreadable",
|
|
2812
2824
|
fields: e,
|
|
2813
2825
|
rawElements: {},
|
|
2814
|
-
sources:
|
|
2826
|
+
sources: qn(Kn(), e, "ocr"),
|
|
2815
2827
|
front: t,
|
|
2816
2828
|
back: o,
|
|
2817
2829
|
message: "The PDF417 barcode on the back could not be read. Try again."
|
|
2818
2830
|
};
|
|
2819
2831
|
}
|
|
2820
|
-
let s =
|
|
2832
|
+
let s = Gn(a), c = t.ocr ? zr(t.ocr) : {}, l = Br(s.fields, c);
|
|
2821
2833
|
return {
|
|
2822
2834
|
status: "success",
|
|
2823
2835
|
fields: l.fields,
|
|
@@ -2827,7 +2839,7 @@ async function Br(e, t, n) {
|
|
|
2827
2839
|
back: o
|
|
2828
2840
|
};
|
|
2829
2841
|
}
|
|
2830
|
-
function
|
|
2842
|
+
function Wr(e, t) {
|
|
2831
2843
|
return e === "front" ? {
|
|
2832
2844
|
title: "Scan a driver’s license",
|
|
2833
2845
|
headline: "Show the front of the license.",
|
|
@@ -2838,7 +2850,7 @@ function Vr(e, t) {
|
|
|
2838
2850
|
detail: t ? "Take a photo of the back so the PDF417 barcode is in frame." : "Place the back of the license in the frame so the barcode is visible."
|
|
2839
2851
|
};
|
|
2840
2852
|
}
|
|
2841
|
-
async function
|
|
2853
|
+
async function Gr(e = {}) {
|
|
2842
2854
|
await x("scan"), await x("ocr");
|
|
2843
2855
|
let t = "front", n, r = !1;
|
|
2844
2856
|
return {
|
|
@@ -2852,15 +2864,15 @@ async function Hr(e = {}) {
|
|
|
2852
2864
|
message: "This license scan was cancelled."
|
|
2853
2865
|
};
|
|
2854
2866
|
if (t === "front") {
|
|
2855
|
-
let r = await
|
|
2867
|
+
let r = await Hr(i, a, e.scan);
|
|
2856
2868
|
return r.kind === "need-back" && (n = r.front, t = "back"), r;
|
|
2857
2869
|
}
|
|
2858
|
-
let o = await
|
|
2870
|
+
let o = await Ur(i, n ?? {}, e.scan);
|
|
2859
2871
|
return o.status === "backFailed" ? {
|
|
2860
2872
|
kind: "retry",
|
|
2861
2873
|
status: "backFailed",
|
|
2862
2874
|
message: o.message ?? "The back of the license could not be captured. Try again."
|
|
2863
|
-
} : (r = !0, await e.onDriverLicense
|
|
2875
|
+
} : (r = !0, typeof e.onDriverLicense == "function" && await e.onDriverLicense(o), {
|
|
2864
2876
|
kind: "complete",
|
|
2865
2877
|
result: o
|
|
2866
2878
|
});
|
|
@@ -2871,6 +2883,6 @@ async function Hr(e = {}) {
|
|
|
2871
2883
|
};
|
|
2872
2884
|
}
|
|
2873
2885
|
//#endregion
|
|
2874
|
-
export {
|
|
2886
|
+
export { t as $, ge as A, M as B, qe as C, R as D, Xe as E, se as F, _e as G, ce as H, Pe as I, o as J, re as K, A as L, Te as M, N, ut as O, k as P, e as Q, ve as R, It as S, st as T, le as U, Fe as V, Ne as W, b as X, x as Y, y as Z, bt as _, $ as a, jt as b, K as c, kn as d, H as f, xt as g, Ct as h, Gr as i, he as j, lt as k, Gn as l, Mt as m, Wr as n, Ir as o, wt as p, a as q, Br as r, mr as s, zr as t, U as u, At as v, ct as w, yt as x, kt as y, j as z };
|
|
2875
2887
|
|
|
2876
|
-
//# sourceMappingURL=driver-license-
|
|
2888
|
+
//# sourceMappingURL=driver-license-yM6pBkNk.js.map
|