@exige/web-scanner-sdk 0.2.33 → 0.2.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{driver-license-DBrWpI9w.js → driver-license-CV0oawgf.js} +185 -160
- package/dist/driver-license-CV0oawgf.js.map +1 -0
- package/dist/react.js +1 -1
- package/dist/scanner-sdk.js +1 -1
- package/dist/sdk/barcode.d.ts +13 -2
- package/dist/sdk/zxing-runtime.d.ts +2 -2
- package/package.json +1 -1
- package/dist/driver-license-DBrWpI9w.js.map +0 -1
|
@@ -1890,12 +1890,25 @@ async function Dn(e = fetch) {
|
|
|
1890
1890
|
}
|
|
1891
1891
|
//#endregion
|
|
1892
1892
|
//#region src/sdk/barcode.ts
|
|
1893
|
-
|
|
1893
|
+
var On = [
|
|
1894
|
+
1280,
|
|
1895
|
+
960,
|
|
1896
|
+
720,
|
|
1897
|
+
480
|
|
1898
|
+
];
|
|
1899
|
+
function kn(e, t) {
|
|
1900
|
+
let n = Math.max(e, t);
|
|
1901
|
+
if (!Number.isFinite(n) || n < 1) return [];
|
|
1902
|
+
let r = [n];
|
|
1903
|
+
for (let e of On) e <= n - 16 && r.push(e);
|
|
1904
|
+
return r;
|
|
1905
|
+
}
|
|
1906
|
+
function An() {
|
|
1894
1907
|
let e = globalThis.BarcodeDetector;
|
|
1895
1908
|
return typeof e == "function" ? e : void 0;
|
|
1896
1909
|
}
|
|
1897
|
-
async function
|
|
1898
|
-
let e =
|
|
1910
|
+
async function jn() {
|
|
1911
|
+
let e = An();
|
|
1899
1912
|
if (!e?.getSupportedFormats) return !1;
|
|
1900
1913
|
try {
|
|
1901
1914
|
return (await e.getSupportedFormats()).some((e) => e.toLowerCase() === "pdf417");
|
|
@@ -1903,61 +1916,73 @@ async function kn() {
|
|
|
1903
1916
|
return !1;
|
|
1904
1917
|
}
|
|
1905
1918
|
}
|
|
1906
|
-
|
|
1907
|
-
let t = On();
|
|
1908
|
-
if (!t) return;
|
|
1909
|
-
let n = await new t({ formats: ["pdf417"] }).detect(e);
|
|
1910
|
-
return n.find((e) => {
|
|
1911
|
-
let t = e.format?.toLowerCase() ?? "";
|
|
1912
|
-
return (!t || t === "pdf417") && !!e.rawValue?.trim();
|
|
1913
|
-
})?.rawValue?.trim() || n.find((e) => e.rawValue?.trim())?.rawValue?.trim();
|
|
1914
|
-
}
|
|
1915
|
-
function jn(e) {
|
|
1919
|
+
function Mn(e) {
|
|
1916
1920
|
try {
|
|
1917
1921
|
return e.getContext("2d", { willReadFrequently: !0 })?.getImageData(0, 0, e.width, e.height);
|
|
1918
1922
|
} catch {
|
|
1919
1923
|
return;
|
|
1920
1924
|
}
|
|
1921
1925
|
}
|
|
1922
|
-
async function
|
|
1926
|
+
async function Nn(e) {
|
|
1923
1927
|
let t = [];
|
|
1924
1928
|
if (e instanceof Blob && t.push(e), e instanceof HTMLCanvasElement) {
|
|
1925
|
-
let n =
|
|
1929
|
+
let n = Mn(e);
|
|
1926
1930
|
n && t.push(n);
|
|
1927
1931
|
try {
|
|
1928
1932
|
t.push(await Ge(e, "image/png"));
|
|
1929
1933
|
} catch {}
|
|
1930
1934
|
} else if (!(e instanceof Blob)) try {
|
|
1931
|
-
let n =
|
|
1935
|
+
let n = Mn(await P(e, { cloneCanvas: !1 }));
|
|
1932
1936
|
n && t.push(n);
|
|
1933
1937
|
} catch {}
|
|
1934
1938
|
return t;
|
|
1935
1939
|
}
|
|
1936
|
-
async function
|
|
1940
|
+
async function Pn(e) {
|
|
1937
1941
|
let { prepareZXingModule: t, readBarcodes: n } = await import("zxing-wasm/reader"), r = En(), i = r.binary ? void 0 : await Dn();
|
|
1938
1942
|
await t({
|
|
1939
1943
|
overrides: r.binary ? { wasmBinary: r.binary } : { locateFile: (e, t) => e.endsWith(".wasm") ? i ?? t + e : t + e },
|
|
1940
1944
|
fireImmediately: !0
|
|
1941
1945
|
});
|
|
1942
|
-
for (let t of await
|
|
1946
|
+
for (let t of await Nn(e)) {
|
|
1943
1947
|
let e = (await n(t, {
|
|
1944
1948
|
formats: ["PDF417"],
|
|
1945
1949
|
tryHarder: !0,
|
|
1950
|
+
tryDownscale: !0,
|
|
1951
|
+
downscaleFactor: 2,
|
|
1952
|
+
downscaleThreshold: 300,
|
|
1946
1953
|
maxNumberOfSymbols: 1
|
|
1947
1954
|
})).find((e) => e.text?.trim())?.text?.trim();
|
|
1948
1955
|
if (e) return e;
|
|
1949
1956
|
}
|
|
1950
1957
|
}
|
|
1958
|
+
function Fn(e, t) {
|
|
1959
|
+
let n = Math.max(e.width, e.height);
|
|
1960
|
+
if (n <= t) return e;
|
|
1961
|
+
let r = t / n, i = document.createElement("canvas");
|
|
1962
|
+
i.width = Math.max(1, Math.round(e.width * r)), i.height = Math.max(1, Math.round(e.height * r));
|
|
1963
|
+
let a = i.getContext("2d", { willReadFrequently: !0 }) ?? i.getContext("2d");
|
|
1964
|
+
return a && (a.imageSmoothingEnabled = !0, "imageSmoothingQuality" in a && (a.imageSmoothingQuality = "high"), a.drawImage(e, 0, 0, i.width, i.height)), i;
|
|
1965
|
+
}
|
|
1966
|
+
function In(e) {
|
|
1967
|
+
return kn(e.width, e.height).map((t) => Fn(e, t));
|
|
1968
|
+
}
|
|
1951
1969
|
async function U(e) {
|
|
1952
|
-
|
|
1953
|
-
|
|
1970
|
+
let t;
|
|
1971
|
+
try {
|
|
1972
|
+
t = await P(e, { cloneCanvas: !1 });
|
|
1973
|
+
} catch {
|
|
1974
|
+
t = e instanceof HTMLCanvasElement ? e : document.createElement("canvas");
|
|
1975
|
+
}
|
|
1976
|
+
let n = t.width && t.height ? In(t) : [];
|
|
1977
|
+
for (let e of n) try {
|
|
1978
|
+
let t = await Pn(e);
|
|
1954
1979
|
if (t) return {
|
|
1955
1980
|
text: t,
|
|
1956
|
-
source: "
|
|
1981
|
+
source: "zxing-wasm"
|
|
1957
1982
|
};
|
|
1958
1983
|
} catch {}
|
|
1959
|
-
try {
|
|
1960
|
-
let t = await
|
|
1984
|
+
if (e instanceof Blob) try {
|
|
1985
|
+
let t = await Pn(e);
|
|
1961
1986
|
return t ? {
|
|
1962
1987
|
text: t,
|
|
1963
1988
|
source: "zxing-wasm"
|
|
@@ -1966,11 +1991,11 @@ async function U(e) {
|
|
|
1966
1991
|
return;
|
|
1967
1992
|
}
|
|
1968
1993
|
}
|
|
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(".")),
|
|
1994
|
+
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(".")), Ln = /* @__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("."), Rn = /* @__PURE__ */ new Set([
|
|
1970
1995
|
"expirationDate",
|
|
1971
1996
|
"dateOfBirth",
|
|
1972
1997
|
"issueDate"
|
|
1973
|
-
]),
|
|
1998
|
+
]), zn = {
|
|
1974
1999
|
DAJ: "issuerJurisdiction",
|
|
1975
2000
|
DBA: "expirationDate",
|
|
1976
2001
|
DAQ: "documentNumber",
|
|
@@ -2006,7 +2031,7 @@ function G(e, t, n) {
|
|
|
2006
2031
|
let r = Number(e), i = Number(t), a = Number(n);
|
|
2007
2032
|
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")}`;
|
|
2008
2033
|
}
|
|
2009
|
-
function
|
|
2034
|
+
function Bn(e, t) {
|
|
2010
2035
|
return t ? e >= 30 ? 1900 + e : 2e3 + e : e >= 50 ? 1900 + e : 2e3 + e;
|
|
2011
2036
|
}
|
|
2012
2037
|
function K(e, t = !1) {
|
|
@@ -2015,7 +2040,7 @@ function K(e, t = !1) {
|
|
|
2015
2040
|
let r = /^(\d{1,2})[/-](\d{1,2})[/-](\d{2,4})$/.exec(n);
|
|
2016
2041
|
if (r) {
|
|
2017
2042
|
let e = r[1], n = r[2], i = r[3];
|
|
2018
|
-
return i.length === 2 && (i = String(
|
|
2043
|
+
return i.length === 2 && (i = String(Bn(Number(i), t))), G(i, e.padStart(2, "0"), n.padStart(2, "0"));
|
|
2019
2044
|
}
|
|
2020
2045
|
let i = /^(\d{4})-(\d{2})-(\d{2})$/.exec(n);
|
|
2021
2046
|
if (i) return G(i[1], i[2], i[3]);
|
|
@@ -2025,11 +2050,11 @@ function K(e, t = !1) {
|
|
|
2025
2050
|
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));
|
|
2026
2051
|
}
|
|
2027
2052
|
if (a.length === 6) {
|
|
2028
|
-
let e =
|
|
2053
|
+
let e = Bn(Number(a.slice(4, 6)), t);
|
|
2029
2054
|
return G(String(e), a.slice(0, 2), a.slice(2, 4));
|
|
2030
2055
|
}
|
|
2031
2056
|
}
|
|
2032
|
-
function
|
|
2057
|
+
function Vn(e) {
|
|
2033
2058
|
let t = e.trim();
|
|
2034
2059
|
if (!t || t === "@") return "";
|
|
2035
2060
|
if (/^(ANSI|AAMVA)\b/.test(t)) {
|
|
@@ -2038,10 +2063,10 @@ function Rn(e) {
|
|
|
2038
2063
|
}
|
|
2039
2064
|
return t;
|
|
2040
2065
|
}
|
|
2041
|
-
function
|
|
2066
|
+
function Hn(e) {
|
|
2042
2067
|
return (e.startsWith("DL") || e.startsWith("ID") || e.startsWith("ZV")) && e.length >= 5 && W.has(e.slice(2, 5)) ? e.slice(2) : e;
|
|
2043
2068
|
}
|
|
2044
|
-
function
|
|
2069
|
+
function Un(e, t) {
|
|
2045
2070
|
let n = 0;
|
|
2046
2071
|
for (; n < e.length;) {
|
|
2047
2072
|
let r = e.slice(n, n + 3);
|
|
@@ -2060,7 +2085,7 @@ function Bn(e, t) {
|
|
|
2060
2085
|
(!(r in t) || a) && (t[r] = a), n = i, (e[n] === "\n" || e[n] === "\r" || e[n] === "") && (n += 1);
|
|
2061
2086
|
}
|
|
2062
2087
|
}
|
|
2063
|
-
function
|
|
2088
|
+
function Wn(e) {
|
|
2064
2089
|
let t = /(?:ANSI|AAMVA)\s?(\d{6})(\d{2})(\d{2})(\d{2})/.exec(e);
|
|
2065
2090
|
if (t) return {
|
|
2066
2091
|
iin: t[1],
|
|
@@ -2068,22 +2093,22 @@ function Vn(e) {
|
|
|
2068
2093
|
jurisdictionVersion: t[3]
|
|
2069
2094
|
};
|
|
2070
2095
|
}
|
|
2071
|
-
function
|
|
2096
|
+
function Gn(e) {
|
|
2072
2097
|
let t = e.replace(/\r\n/g, "\n").replace(/\r/g, "\n"), n = {}, r = t.split("\n").flatMap((e) => e.split(""));
|
|
2073
2098
|
if (r.some((e) => {
|
|
2074
|
-
let t =
|
|
2099
|
+
let t = Hn(Vn(e));
|
|
2075
2100
|
return W.has(t.slice(0, 3));
|
|
2076
2101
|
})) {
|
|
2077
2102
|
for (let e of r) {
|
|
2078
|
-
let t =
|
|
2079
|
-
t &&
|
|
2103
|
+
let t = Hn(Vn(e));
|
|
2104
|
+
t && Un(t, n);
|
|
2080
2105
|
}
|
|
2081
2106
|
return n;
|
|
2082
2107
|
}
|
|
2083
|
-
return
|
|
2108
|
+
return Un(t, n), n;
|
|
2084
2109
|
}
|
|
2085
|
-
function
|
|
2086
|
-
if (
|
|
2110
|
+
function Kn(e, t) {
|
|
2111
|
+
if (Rn.has(t)) return K(e, t === "dateOfBirth") ?? e.trim();
|
|
2087
2112
|
if (t === "issuerJurisdiction" || t === "country") return e.trim().toUpperCase();
|
|
2088
2113
|
if (t === "addressPostalCode") {
|
|
2089
2114
|
let t = e.trim();
|
|
@@ -2091,11 +2116,11 @@ function Un(e, t) {
|
|
|
2091
2116
|
}
|
|
2092
2117
|
return e.trim();
|
|
2093
2118
|
}
|
|
2094
|
-
function
|
|
2119
|
+
function qn(e) {
|
|
2095
2120
|
let t = {};
|
|
2096
2121
|
for (let [n, r] of Object.entries(e)) {
|
|
2097
|
-
let e =
|
|
2098
|
-
e && r.trim() && (t[e] || (t[e] =
|
|
2122
|
+
let e = zn[n];
|
|
2123
|
+
e && r.trim() && (t[e] || (t[e] = Kn(r, e)));
|
|
2099
2124
|
}
|
|
2100
2125
|
if (!t.firstName && e.DCT?.trim()) {
|
|
2101
2126
|
let n = e.DCT.trim().split(/\s+/);
|
|
@@ -2103,29 +2128,29 @@ function Wn(e) {
|
|
|
2103
2128
|
}
|
|
2104
2129
|
return t;
|
|
2105
2130
|
}
|
|
2106
|
-
function
|
|
2107
|
-
let t =
|
|
2131
|
+
function Jn(e) {
|
|
2132
|
+
let t = Gn(e);
|
|
2108
2133
|
return {
|
|
2109
2134
|
rawElements: t,
|
|
2110
|
-
fields:
|
|
2111
|
-
header:
|
|
2135
|
+
fields: qn(t),
|
|
2136
|
+
header: Wn(e)
|
|
2112
2137
|
};
|
|
2113
2138
|
}
|
|
2114
|
-
function
|
|
2139
|
+
function Yn() {
|
|
2115
2140
|
return {};
|
|
2116
2141
|
}
|
|
2117
|
-
function
|
|
2118
|
-
for (let r of
|
|
2142
|
+
function Xn(e, t, n) {
|
|
2143
|
+
for (let r of Ln) t[r] && (e[r] = n);
|
|
2119
2144
|
return e;
|
|
2120
2145
|
}
|
|
2121
2146
|
//#endregion
|
|
2122
2147
|
//#region src/sdk/face-model.ts
|
|
2123
|
-
var
|
|
2124
|
-
function
|
|
2148
|
+
var Zn = /* @__PURE__ */ new Map(), Qn = 8400;
|
|
2149
|
+
function $n(e, t) {
|
|
2125
2150
|
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));
|
|
2126
2151
|
return n / Math.max(1, e.width * e.height + t.width * t.height - n);
|
|
2127
2152
|
}
|
|
2128
|
-
function
|
|
2153
|
+
function er(e, t, n, r, i, a, o) {
|
|
2129
2154
|
return {
|
|
2130
2155
|
x: (e - n / 2) / i * a,
|
|
2131
2156
|
y: (t - r / 2) / i * o,
|
|
@@ -2133,20 +2158,20 @@ function Zn(e, t, n, r, i, a, o) {
|
|
|
2133
2158
|
height: r / i * o
|
|
2134
2159
|
};
|
|
2135
2160
|
}
|
|
2136
|
-
function
|
|
2161
|
+
function tr(e, t, n) {
|
|
2137
2162
|
let r = t.length === 3 ? t[1] : t[0], i = t.length === 3 ? t[2] : t[1];
|
|
2138
|
-
if (i !== 6 || r < 1) throw Error(`Face model expects [1, anchors, 6]. A 640 YOLOX-Nano face export is [1, ${
|
|
2163
|
+
if (i !== 6 || r < 1) throw Error(`Face model expects [1, anchors, 6]. A 640 YOLOX-Nano face export is [1, ${Qn}, 6].`);
|
|
2139
2164
|
let a = n.confidence ?? .35, o = n.inputSize ?? 640, s = [];
|
|
2140
2165
|
for (let t = 0; t < r; t += 1) {
|
|
2141
2166
|
let r = t * i, c = e[r + 4] * e[r + 5];
|
|
2142
2167
|
c < a || s.push({
|
|
2143
2168
|
confidence: c,
|
|
2144
|
-
bbox:
|
|
2169
|
+
bbox: er(e[r], e[r + 1], e[r + 2], e[r + 3], o, n.imageWidth, n.imageHeight)
|
|
2145
2170
|
});
|
|
2146
2171
|
}
|
|
2147
|
-
return s.sort((e, t) => t.confidence - e.confidence).filter((e, t, n) => n.slice(0, t).every((t) =>
|
|
2172
|
+
return s.sort((e, t) => t.confidence - e.confidence).filter((e, t, n) => n.slice(0, t).every((t) => $n(e.bbox, t.bbox) < .45)).slice(0, 8);
|
|
2148
2173
|
}
|
|
2149
|
-
async function
|
|
2174
|
+
async function nr(e, n, r = .35) {
|
|
2150
2175
|
let i = await P(e, { cloneCanvas: !1 }), a = await import("onnxruntime-web"), o = document.createElement("canvas");
|
|
2151
2176
|
o.width = 640, o.height = 640;
|
|
2152
2177
|
let s = o.getContext("2d", { willReadFrequently: !0 });
|
|
@@ -2154,18 +2179,18 @@ async function $n(e, n, r = .35) {
|
|
|
2154
2179
|
s.drawImage(i, 0, 0, 640, 640);
|
|
2155
2180
|
let c = s.getImageData(0, 0, 640, 640).data, l = 409600, u = new Float32Array(l * 3);
|
|
2156
2181
|
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;
|
|
2157
|
-
let d =
|
|
2182
|
+
let d = Zn.get(n);
|
|
2158
2183
|
d || (d = a.InferenceSession.create(n, {
|
|
2159
2184
|
executionProviders: ["wasm"],
|
|
2160
2185
|
graphOptimizationLevel: "all"
|
|
2161
|
-
}),
|
|
2186
|
+
}), Zn.set(n, d));
|
|
2162
2187
|
let f = await d, p = (await f.run({ [f.inputNames[0]]: new a.Tensor("float32", u, [
|
|
2163
2188
|
1,
|
|
2164
2189
|
3,
|
|
2165
2190
|
640,
|
|
2166
2191
|
640
|
|
2167
2192
|
]) }))[f.outputNames[0]];
|
|
2168
|
-
return
|
|
2193
|
+
return tr(p.data, p.dims.map(Number), {
|
|
2169
2194
|
confidence: r,
|
|
2170
2195
|
imageWidth: i.width,
|
|
2171
2196
|
imageHeight: i.height,
|
|
@@ -2174,7 +2199,7 @@ async function $n(e, n, r = .35) {
|
|
|
2174
2199
|
}
|
|
2175
2200
|
//#endregion
|
|
2176
2201
|
//#region src/sdk/field-model.ts
|
|
2177
|
-
var q = /* @__PURE__ */ new Map(),
|
|
2202
|
+
var q = /* @__PURE__ */ new Map(), rr = [
|
|
2178
2203
|
"person_name",
|
|
2179
2204
|
"date_of_birth",
|
|
2180
2205
|
"address",
|
|
@@ -2182,19 +2207,19 @@ var q = /* @__PURE__ */ new Map(), er = [
|
|
|
2182
2207
|
"expiration_date",
|
|
2183
2208
|
"postal_code",
|
|
2184
2209
|
"state"
|
|
2185
|
-
],
|
|
2186
|
-
function
|
|
2210
|
+
], ir = 8400;
|
|
2211
|
+
function ar(e) {
|
|
2187
2212
|
return 5 + e;
|
|
2188
2213
|
}
|
|
2189
|
-
var
|
|
2190
|
-
function
|
|
2214
|
+
var or = 640;
|
|
2215
|
+
function sr(e, t) {
|
|
2191
2216
|
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));
|
|
2192
2217
|
return n / Math.max(1, e.bbox.width * e.bbox.height + t.bbox.width * t.bbox.height - n);
|
|
2193
2218
|
}
|
|
2194
|
-
function
|
|
2195
|
-
return e.sort((e, t) => t.confidence - e.confidence).filter((e, t, n) => n.slice(0, t).every((t) => t.field !== e.field ||
|
|
2219
|
+
function cr(e) {
|
|
2220
|
+
return e.sort((e, t) => t.confidence - e.confidence).filter((e, t, n) => n.slice(0, t).every((t) => t.field !== e.field || sr(e, t) < .45)).slice(0, 30);
|
|
2196
2221
|
}
|
|
2197
|
-
function
|
|
2222
|
+
function lr(e, t, n, r, i, a, o) {
|
|
2198
2223
|
return {
|
|
2199
2224
|
x: (e - n / 2) / i * a,
|
|
2200
2225
|
y: (t - r / 2) / i * o,
|
|
@@ -2202,8 +2227,8 @@ function or(e, t, n, r, i, a, o) {
|
|
|
2202
2227
|
height: r / i * o
|
|
2203
2228
|
};
|
|
2204
2229
|
}
|
|
2205
|
-
function
|
|
2206
|
-
let n =
|
|
2230
|
+
function ur(e, t) {
|
|
2231
|
+
let n = ar(t);
|
|
2207
2232
|
return e.length === 3 && e[0] === 1 && e[2] === n && e[1] > e[2] ? {
|
|
2208
2233
|
anchors: e[1],
|
|
2209
2234
|
features: n
|
|
@@ -2212,15 +2237,15 @@ function sr(e, t) {
|
|
|
2212
2237
|
features: n
|
|
2213
2238
|
} : null;
|
|
2214
2239
|
}
|
|
2215
|
-
function
|
|
2240
|
+
function dr(e) {
|
|
2216
2241
|
return e.length === 3 && e[1] >= 5 && e[2] >= 1;
|
|
2217
2242
|
}
|
|
2218
|
-
function
|
|
2219
|
-
let t =
|
|
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, ${
|
|
2243
|
+
function fr(e) {
|
|
2244
|
+
let t = ar(e);
|
|
2245
|
+
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, ${ir}, ${t}].`);
|
|
2221
2246
|
}
|
|
2222
|
-
function
|
|
2223
|
-
if (!
|
|
2247
|
+
function pr(e, t, n, r, i, a, o) {
|
|
2248
|
+
if (!dr(t)) throw Error("Unsupported field-model YOLO output shape.");
|
|
2224
2249
|
let s = t[1], c = t[2], l = [];
|
|
2225
2250
|
for (let t = 0; t < c; t += 1) {
|
|
2226
2251
|
let u = 0, d = 0;
|
|
@@ -2232,14 +2257,14 @@ function ur(e, t, n, r, i, a, o) {
|
|
|
2232
2257
|
!f || u < r || l.push({
|
|
2233
2258
|
field: f,
|
|
2234
2259
|
confidence: u,
|
|
2235
|
-
bbox:
|
|
2260
|
+
bbox: lr(e[t], e[c + t], e[c * 2 + t], e[c * 3 + t], i, a, o)
|
|
2236
2261
|
});
|
|
2237
2262
|
}
|
|
2238
|
-
return
|
|
2263
|
+
return cr(l);
|
|
2239
2264
|
}
|
|
2240
|
-
function
|
|
2241
|
-
let s =
|
|
2242
|
-
if (!s) throw
|
|
2265
|
+
function mr(e, t, n, r, i, a, o) {
|
|
2266
|
+
let s = ur(t, n.length);
|
|
2267
|
+
if (!s) throw fr(n.length);
|
|
2243
2268
|
let c = [];
|
|
2244
2269
|
for (let t = 0; t < s.anchors; t += 1) {
|
|
2245
2270
|
let l = t * s.features, u = e[l + 4], d = 0, f = 0;
|
|
@@ -2251,18 +2276,18 @@ function dr(e, t, n, r, i, a, o) {
|
|
|
2251
2276
|
!p || m < r || c.push({
|
|
2252
2277
|
field: p,
|
|
2253
2278
|
confidence: m,
|
|
2254
|
-
bbox:
|
|
2279
|
+
bbox: lr(e[l], e[l + 1], e[l + 2], e[l + 3], i, a, o)
|
|
2255
2280
|
});
|
|
2256
2281
|
}
|
|
2257
|
-
return
|
|
2282
|
+
return cr(c);
|
|
2258
2283
|
}
|
|
2259
|
-
function
|
|
2260
|
-
let r = n.classes ??
|
|
2284
|
+
function hr(e, t, n) {
|
|
2285
|
+
let r = n.classes ?? rr, i = n.confidence ?? .35, a = n.inputSize ?? or, o = ur(t, r.length);
|
|
2261
2286
|
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.");
|
|
2262
|
-
return (n.layout ?? (o ? "yolox" : "yolov8")) === "yolox" ?
|
|
2287
|
+
return (n.layout ?? (o ? "yolox" : "yolov8")) === "yolox" ? mr(e, t, r, i, a, n.imageWidth, n.imageHeight) : pr(e, t, r, i, a, n.imageWidth, n.imageHeight);
|
|
2263
2288
|
}
|
|
2264
|
-
async function
|
|
2265
|
-
let o = await P(e, { cloneCanvas: !1 }), s = import("onnxruntime-web"), c =
|
|
2289
|
+
async function gr(e, n, r = rr, i = .35, a) {
|
|
2290
|
+
let o = await P(e, { cloneCanvas: !1 }), s = import("onnxruntime-web"), c = or, l = document.createElement("canvas");
|
|
2266
2291
|
l.width = c, l.height = c;
|
|
2267
2292
|
let u = l.getContext("2d", { willReadFrequently: !0 });
|
|
2268
2293
|
if (!u) throw t();
|
|
@@ -2287,7 +2312,7 @@ async function pr(e, n, r = er, i = .35, a) {
|
|
|
2287
2312
|
c,
|
|
2288
2313
|
c
|
|
2289
2314
|
]) }))[g.outputNames[0]];
|
|
2290
|
-
return
|
|
2315
|
+
return hr(_.data, _.dims.map(Number), {
|
|
2291
2316
|
classes: r,
|
|
2292
2317
|
confidence: i,
|
|
2293
2318
|
layout: a,
|
|
@@ -2298,7 +2323,7 @@ async function pr(e, n, r = er, i = .35, a) {
|
|
|
2298
2323
|
}
|
|
2299
2324
|
//#endregion
|
|
2300
2325
|
//#region src/sdk/redact.ts
|
|
2301
|
-
async function
|
|
2326
|
+
async function _r(e, n, r = {}) {
|
|
2302
2327
|
await x("redaction");
|
|
2303
2328
|
let i = await P(e), a = i.getContext("2d");
|
|
2304
2329
|
if (!a) throw t();
|
|
@@ -2333,7 +2358,7 @@ function J(e) {
|
|
|
2333
2358
|
height: i - n
|
|
2334
2359
|
};
|
|
2335
2360
|
}
|
|
2336
|
-
function
|
|
2361
|
+
function vr(e) {
|
|
2337
2362
|
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);
|
|
2338
2363
|
for (let e of n) {
|
|
2339
2364
|
let n = e.bbox.y + e.bbox.height / 2, r = t.find((t) => {
|
|
@@ -2355,7 +2380,7 @@ function Y(e, t, n = !1) {
|
|
|
2355
2380
|
function X(e) {
|
|
2356
2381
|
return e.reduce((e, t) => e + t.confidence, 0) / Math.max(1, e.length);
|
|
2357
2382
|
}
|
|
2358
|
-
function
|
|
2383
|
+
function yr(e, t) {
|
|
2359
2384
|
let n = e.mode, r = n === "case-insensitive", i = e.scope ?? "line", a;
|
|
2360
2385
|
if (n === "regex") {
|
|
2361
2386
|
let t = e.pattern ?? e.values?.[0];
|
|
@@ -2392,22 +2417,22 @@ function gr(e, t) {
|
|
|
2392
2417
|
}
|
|
2393
2418
|
return s;
|
|
2394
2419
|
}
|
|
2395
|
-
function
|
|
2420
|
+
function br(e, t) {
|
|
2396
2421
|
let n = e.labelMode !== "exact", r = Y(e.label, n, !0).split(" ");
|
|
2397
2422
|
for (let e of t) for (let t = 0; t <= e.words.length - r.length; t += 1) {
|
|
2398
2423
|
let i = e.words.slice(t, t + r.length);
|
|
2399
2424
|
if (i.every((e, t) => Y(e.text, n, !0) === r[t])) return i;
|
|
2400
2425
|
}
|
|
2401
2426
|
}
|
|
2402
|
-
function
|
|
2427
|
+
function xr(e, t, n, r, i, a) {
|
|
2403
2428
|
let o = a.window?.distance ?? .28, s = a.window?.crossAxis ?? .12, c = t.x + t.width / 2, l = t.y + t.height / 2;
|
|
2404
2429
|
return e.filter((e) => {
|
|
2405
2430
|
let a = e.bbox.x + e.bbox.width / 2, u = e.bbox.y + e.bbox.height / 2;
|
|
2406
2431
|
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;
|
|
2407
2432
|
});
|
|
2408
2433
|
}
|
|
2409
|
-
function
|
|
2410
|
-
let o =
|
|
2434
|
+
function Sr(e, t, n, r, i, a = "label") {
|
|
2435
|
+
let o = br(e, n);
|
|
2411
2436
|
if (!o) return [];
|
|
2412
2437
|
let s = J(o), c = new Set(o), l = t.filter((e) => !c.has(e)), u = e.direction === "any" ? [
|
|
2413
2438
|
"right",
|
|
@@ -2416,7 +2441,7 @@ function yr(e, t, n, r, i, a = "label") {
|
|
|
2416
2441
|
"above"
|
|
2417
2442
|
] : [e.direction], d;
|
|
2418
2443
|
for (let t of u) {
|
|
2419
|
-
let n =
|
|
2444
|
+
let n = vr(xr(l, s, t, r, i, e));
|
|
2420
2445
|
for (let t of n) {
|
|
2421
2446
|
if (e.valuePattern && !new RegExp(e.valuePattern, e.patternFlags).test(t.text)) continue;
|
|
2422
2447
|
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);
|
|
@@ -2437,7 +2462,7 @@ function yr(e, t, n, r, i, a = "label") {
|
|
|
2437
2462
|
confidence: Math.max(0, X(d.words) * (1 - Math.min(.5, d.distance)))
|
|
2438
2463
|
}];
|
|
2439
2464
|
}
|
|
2440
|
-
var
|
|
2465
|
+
var Cr = {
|
|
2441
2466
|
person_name: [
|
|
2442
2467
|
"LN",
|
|
2443
2468
|
"FN",
|
|
@@ -2474,10 +2499,10 @@ var br = {
|
|
|
2474
2499
|
"POSTAL"
|
|
2475
2500
|
],
|
|
2476
2501
|
state: ["STATE", "DAJ"]
|
|
2477
|
-
},
|
|
2502
|
+
}, wr = new Set(Object.values(Cr).flat()), Tr = /^(?:\d{2}[/-]\d{2}[/-]\d{2,4}|\d{4}[/-]\d{2}[/-]\d{2}|\d{6}|\d{8})$/, Er = /\b(?:ST|STREET|AVE|AVENUE|RD|ROAD|BLVD|BOULEVARD|LN|LANE|DR|DRIVE|WAY|CT|COURT)\b/i, Dr = /\b(?:DRIVER|LICENSE|IDENTIFICATION|CARD|CLASS|SEX|EYES|HEIGHT|RESTRICTIONS)\b/i;
|
|
2478
2503
|
function Z(e, t) {
|
|
2479
2504
|
let n = t.trim();
|
|
2480
|
-
return n ? e === "date_of_birth" || e === "expiration_date" ?
|
|
2505
|
+
return n ? e === "date_of_birth" || e === "expiration_date" ? Tr.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) && !Dr.test(n) : /\d/.test(n) && /[A-Z]/i.test(n) : !1;
|
|
2481
2506
|
}
|
|
2482
2507
|
function Q(e, t, n, r, i = 1) {
|
|
2483
2508
|
return {
|
|
@@ -2489,17 +2514,17 @@ function Q(e, t, n, r, i = 1) {
|
|
|
2489
2514
|
confidence: Math.max(0, Math.min(1, X(n) * i))
|
|
2490
2515
|
};
|
|
2491
2516
|
}
|
|
2492
|
-
function
|
|
2493
|
-
let r =
|
|
2517
|
+
function Or(e, t, n) {
|
|
2518
|
+
let r = Cr[e], i = [];
|
|
2494
2519
|
for (let a of n) for (let n = 0; n < a.words.length; n += 1) {
|
|
2495
2520
|
let o = a.words[n].text.toUpperCase().replace(/[^A-Z0-9]/g, ""), s = r.find((e) => o === e || o.startsWith(e));
|
|
2496
2521
|
if (!s) continue;
|
|
2497
2522
|
let c, l;
|
|
2498
|
-
o === s ? (c = a.words.slice(n + 1).filter((e) => !
|
|
2523
|
+
o === s ? (c = a.words.slice(n + 1).filter((e) => !wr.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));
|
|
2499
2524
|
}
|
|
2500
2525
|
return i;
|
|
2501
2526
|
}
|
|
2502
|
-
function
|
|
2527
|
+
function kr(e, t, n) {
|
|
2503
2528
|
let r = n.filter((e) => {
|
|
2504
2529
|
let t = e.text.replace(/\s/g, "");
|
|
2505
2530
|
return t.includes("<<") || /^[A-Z0-9<]{25,}$/.test(t);
|
|
@@ -2521,7 +2546,7 @@ function Er(e, t, n) {
|
|
|
2521
2546
|
}
|
|
2522
2547
|
return [];
|
|
2523
2548
|
}
|
|
2524
|
-
function
|
|
2549
|
+
function Ar(e) {
|
|
2525
2550
|
let t = e.replace(/\s/g, ""), n = t.match(/\d{4}/)?.[0];
|
|
2526
2551
|
if (n) return Number(n);
|
|
2527
2552
|
let r = t.match(/^\d{2}/)?.[0];
|
|
@@ -2529,16 +2554,16 @@ function Dr(e) {
|
|
|
2529
2554
|
let i = Number(r);
|
|
2530
2555
|
return i > (/* @__PURE__ */ new Date()).getFullYear() % 100 ? 1900 + i : 2e3 + i;
|
|
2531
2556
|
}
|
|
2532
|
-
function
|
|
2557
|
+
function jr(e, t, n, r, i) {
|
|
2533
2558
|
if (e === "address") {
|
|
2534
|
-
let e = r.findIndex((e) => /\d/.test(e.text) &&
|
|
2559
|
+
let e = r.findIndex((e) => /\d/.test(e.text) && Er.test(e.text));
|
|
2535
2560
|
if (e < 0) return [];
|
|
2536
2561
|
let n = [...r[e].words], i = r[e + 1];
|
|
2537
2562
|
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)];
|
|
2538
2563
|
}
|
|
2539
2564
|
if (e === "person_name") {
|
|
2540
2565
|
let e = r.map((e) => {
|
|
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 && !
|
|
2566
|
+
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 && !Dr.test(e.text) && !Er.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);
|
|
2542
2567
|
return {
|
|
2543
2568
|
line: e,
|
|
2544
2569
|
score: r ? .45 + X(e.words) * .3 + a * .15 + (n < .65 ? .1 : 0) : 0
|
|
@@ -2547,9 +2572,9 @@ function Or(e, t, n, r, i) {
|
|
|
2547
2572
|
return !e.length || e[1] && e[0].score - e[1].score < .04 ? [] : [Q(t, "layout", e[0].line.words, void 0, e[0].score)];
|
|
2548
2573
|
}
|
|
2549
2574
|
if (e === "date_of_birth" || e === "expiration_date") {
|
|
2550
|
-
let r = (/* @__PURE__ */ new Date()).getFullYear(), i = n.filter((e) =>
|
|
2575
|
+
let r = (/* @__PURE__ */ new Date()).getFullYear(), i = n.filter((e) => Tr.test(e.text.replace(/\s/g, ""))).map((e) => ({
|
|
2551
2576
|
word: e,
|
|
2552
|
-
year:
|
|
2577
|
+
year: Ar(e.text)
|
|
2553
2578
|
})).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);
|
|
2554
2579
|
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)] : [];
|
|
2555
2580
|
}
|
|
@@ -2567,29 +2592,29 @@ function Or(e, t, n, r, i) {
|
|
|
2567
2592
|
}
|
|
2568
2593
|
return [];
|
|
2569
2594
|
}
|
|
2570
|
-
function
|
|
2595
|
+
function Mr(e, t) {
|
|
2571
2596
|
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);
|
|
2572
2597
|
}
|
|
2573
|
-
function
|
|
2574
|
-
let i =
|
|
2575
|
-
return i.length || a.length ? [...i, ...a] :
|
|
2598
|
+
function Nr(e, t, n, r) {
|
|
2599
|
+
let i = Or(e.field, e.id, n), a = kr(e.field, e.id, n);
|
|
2600
|
+
return i.length || a.length ? [...i, ...a] : jr(e.field, e.id, t, n, r);
|
|
2576
2601
|
}
|
|
2577
|
-
function
|
|
2602
|
+
function Pr(e, t, n) {
|
|
2578
2603
|
let r = (n ?? []).filter((t) => t.field === e.field).sort((e, t) => t.confidence - e.confidence);
|
|
2579
2604
|
for (let n of r) {
|
|
2580
|
-
let r = t.filter((e) =>
|
|
2605
|
+
let r = t.filter((e) => Mr(n.bbox, e.bbox) >= .3);
|
|
2581
2606
|
if (!r.length) continue;
|
|
2582
2607
|
let i = r.map((e) => e.text).join(" ");
|
|
2583
2608
|
if (Z(e.field, i)) return Q(e.id, "model", r, i, n.confidence);
|
|
2584
2609
|
}
|
|
2585
2610
|
}
|
|
2586
|
-
function
|
|
2587
|
-
let o =
|
|
2611
|
+
function Fr(e, t, n, r, i, a) {
|
|
2612
|
+
let o = Nr(e, t, n, r);
|
|
2588
2613
|
if (e.detector !== "model" || !a) return o;
|
|
2589
|
-
let s =
|
|
2614
|
+
let s = Pr(e, t, i);
|
|
2590
2615
|
return s ? [s] : [];
|
|
2591
2616
|
}
|
|
2592
|
-
function
|
|
2617
|
+
function Ir(e, t, n, r) {
|
|
2593
2618
|
let i = (e) => Math.max(0, Math.min(1, e)), a = i(e.rect.x), o = i(e.rect.y);
|
|
2594
2619
|
return {
|
|
2595
2620
|
ruleId: `${t}.${e.id}`,
|
|
@@ -2604,19 +2629,19 @@ function Nr(e, t, n, r) {
|
|
|
2604
2629
|
confidence: 1
|
|
2605
2630
|
};
|
|
2606
2631
|
}
|
|
2607
|
-
function
|
|
2608
|
-
let n = t.imageWidth ?? e?.imageWidth ?? 0, r = t.imageHeight ?? e?.imageHeight ?? 0, i = e?.words ?? [], a =
|
|
2632
|
+
function Lr(e, t) {
|
|
2633
|
+
let n = t.imageWidth ?? e?.imageWidth ?? 0, r = t.imageHeight ?? e?.imageHeight ?? 0, i = e?.words ?? [], a = vr(i), o = [], s = [];
|
|
2609
2634
|
for (let e of t.rules) {
|
|
2610
|
-
let c = e.strategy === "string" ?
|
|
2635
|
+
let c = e.strategy === "string" ? yr(e, a) : e.strategy === "label" ? Sr(e, i, a, n, r) : Fr(e, i, a, r, t.semanticDetections, t.modelRequested === !0);
|
|
2611
2636
|
c.length ? o.push(...c) : s.push(e.id);
|
|
2612
2637
|
}
|
|
2613
2638
|
for (let e of t.template?.fields ?? []) {
|
|
2614
2639
|
let c = `${t.template.id}.${e.id}`;
|
|
2615
2640
|
if (e.strategy === "rect") {
|
|
2616
|
-
n && r ? o.push(
|
|
2641
|
+
n && r ? o.push(Ir(e, t.template.id, n, r)) : s.push(c);
|
|
2617
2642
|
continue;
|
|
2618
2643
|
}
|
|
2619
|
-
let l =
|
|
2644
|
+
let l = Sr({
|
|
2620
2645
|
...e,
|
|
2621
2646
|
id: c,
|
|
2622
2647
|
strategy: "label"
|
|
@@ -2634,34 +2659,34 @@ function Pr(e, t) {
|
|
|
2634
2659
|
confidence: u
|
|
2635
2660
|
};
|
|
2636
2661
|
}
|
|
2637
|
-
function
|
|
2662
|
+
function Rr(e) {
|
|
2638
2663
|
return e.rules.length > 0 || e.template?.fields.some((e) => e.strategy === "anchor") === !0;
|
|
2639
2664
|
}
|
|
2640
|
-
function
|
|
2665
|
+
function zr(e, t = !1) {
|
|
2641
2666
|
return t && !e.complete ? "unmatched" : e.complete ? "success" : "partial";
|
|
2642
2667
|
}
|
|
2643
|
-
async function
|
|
2668
|
+
async function Br(e, t) {
|
|
2644
2669
|
await x("redaction");
|
|
2645
2670
|
let n = await P(e, { cloneCanvas: !1 }), r = t.ocr;
|
|
2646
|
-
|
|
2671
|
+
Rr(t) && !r && (r = await H(n, { includeWords: !0 }));
|
|
2647
2672
|
let i = t.semanticDetections, a = t.modelRequested === !0, o = "not-requested", s;
|
|
2648
2673
|
if (t.models?.fields) try {
|
|
2649
|
-
i = await
|
|
2674
|
+
i = await gr(n, t.models.fields, t.models.fieldClasses, t.models.confidence, t.models.fieldLayout), a = !0, o = "loaded";
|
|
2650
2675
|
} catch (e) {
|
|
2651
2676
|
s = e instanceof Error ? e.message : "The field model could not load.";
|
|
2652
2677
|
let n = t.models.allowHeuristicFallback !== !1;
|
|
2653
2678
|
a = !n, o = n ? "fallback" : "failed";
|
|
2654
2679
|
}
|
|
2655
|
-
let c =
|
|
2680
|
+
let c = Lr(r, {
|
|
2656
2681
|
rules: t.rules,
|
|
2657
2682
|
template: t.template,
|
|
2658
2683
|
imageWidth: n.width,
|
|
2659
2684
|
imageHeight: n.height,
|
|
2660
2685
|
semanticDetections: i,
|
|
2661
2686
|
modelRequested: a
|
|
2662
|
-
}), l =
|
|
2687
|
+
}), l = zr(c, t.requireAll), u = [], d = "not-requested", f;
|
|
2663
2688
|
if (t.models?.face) try {
|
|
2664
|
-
u = await
|
|
2689
|
+
u = await nr(n, t.models.face, t.models.faceConfidence), d = "loaded";
|
|
2665
2690
|
} catch (e) {
|
|
2666
2691
|
f = e instanceof Error ? e.message : "The face model could not load.", d = "failed";
|
|
2667
2692
|
}
|
|
@@ -2675,7 +2700,7 @@ async function Lr(e, t) {
|
|
|
2675
2700
|
faceStatus: d,
|
|
2676
2701
|
faceError: f
|
|
2677
2702
|
};
|
|
2678
|
-
let p = await
|
|
2703
|
+
let p = await _r(n, [...c.matches.map((e) => ({
|
|
2679
2704
|
...e.bbox,
|
|
2680
2705
|
mode: t.style?.mode
|
|
2681
2706
|
})), ...u.map((e) => ({
|
|
@@ -2697,7 +2722,7 @@ async function Lr(e, t) {
|
|
|
2697
2722
|
}
|
|
2698
2723
|
//#endregion
|
|
2699
2724
|
//#region src/sdk/driver-license.ts
|
|
2700
|
-
var
|
|
2725
|
+
var Vr = [
|
|
2701
2726
|
{
|
|
2702
2727
|
id: "issuerJurisdiction",
|
|
2703
2728
|
strategy: "semantic",
|
|
@@ -2734,7 +2759,7 @@ var Rr = [
|
|
|
2734
2759
|
field: "person_name"
|
|
2735
2760
|
}
|
|
2736
2761
|
];
|
|
2737
|
-
function
|
|
2762
|
+
function Hr(e, t, n) {
|
|
2738
2763
|
let r = n.trim();
|
|
2739
2764
|
if (r) {
|
|
2740
2765
|
if (t === "expirationDate" || t === "dateOfBirth" || t === "issueDate") {
|
|
@@ -2748,8 +2773,8 @@ function zr(e, t, n) {
|
|
|
2748
2773
|
e[t] = r;
|
|
2749
2774
|
}
|
|
2750
2775
|
}
|
|
2751
|
-
function
|
|
2752
|
-
let t = {}, n =
|
|
2776
|
+
function Ur(e) {
|
|
2777
|
+
let t = {}, n = Lr(e, { rules: Vr });
|
|
2753
2778
|
for (let e of n.matches) {
|
|
2754
2779
|
let n = e.text?.trim();
|
|
2755
2780
|
if (n) {
|
|
@@ -2758,29 +2783,29 @@ function Br(e) {
|
|
|
2758
2783
|
!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(" "));
|
|
2759
2784
|
continue;
|
|
2760
2785
|
}
|
|
2761
|
-
|
|
2786
|
+
Hr(t, e.ruleId, n);
|
|
2762
2787
|
}
|
|
2763
2788
|
}
|
|
2764
2789
|
return t;
|
|
2765
2790
|
}
|
|
2766
|
-
function
|
|
2767
|
-
let n = { ...e }, r =
|
|
2791
|
+
function Wr(e, t) {
|
|
2792
|
+
let n = { ...e }, r = Xn(Yn(), e, "barcode");
|
|
2768
2793
|
for (let [e, i] of Object.entries(t)) i && (n[e] || (n[e] = i, r[e] = "ocr"));
|
|
2769
2794
|
return {
|
|
2770
2795
|
fields: n,
|
|
2771
2796
|
sources: r
|
|
2772
2797
|
};
|
|
2773
2798
|
}
|
|
2774
|
-
async function
|
|
2799
|
+
async function Gr(e, t, n) {
|
|
2775
2800
|
return t?.status === "success" && t.corners ? ct(e, t.corners, { maxOutputDimension: n?.maxOutputDimension }) : R(e, n);
|
|
2776
2801
|
}
|
|
2777
|
-
async function
|
|
2802
|
+
async function Kr(e, t, n) {
|
|
2778
2803
|
if (!e.width || !e.height) return {
|
|
2779
2804
|
kind: "retry",
|
|
2780
2805
|
status: "frontFailed",
|
|
2781
2806
|
message: "The front photo was empty. Try again."
|
|
2782
2807
|
};
|
|
2783
|
-
let r = await
|
|
2808
|
+
let r = await Gr(e, t, n);
|
|
2784
2809
|
if (r.status !== "success" || !r.canvas) return {
|
|
2785
2810
|
kind: "retry",
|
|
2786
2811
|
status: "frontFailed",
|
|
@@ -2804,7 +2829,7 @@ async function Ur(e, t, n) {
|
|
|
2804
2829
|
function $() {
|
|
2805
2830
|
return new DOMException("The barcode scan was cancelled.", "AbortError");
|
|
2806
2831
|
}
|
|
2807
|
-
function
|
|
2832
|
+
function qr(e, t) {
|
|
2808
2833
|
return new Promise((n, r) => {
|
|
2809
2834
|
if (t?.aborted) {
|
|
2810
2835
|
r($());
|
|
@@ -2818,7 +2843,7 @@ function Wr(e, t) {
|
|
|
2818
2843
|
t?.addEventListener("abort", a, { once: !0 });
|
|
2819
2844
|
});
|
|
2820
2845
|
}
|
|
2821
|
-
async function
|
|
2846
|
+
async function Jr(e, t = {}) {
|
|
2822
2847
|
let n = t.intervalMs ?? 140;
|
|
2823
2848
|
for (;;) {
|
|
2824
2849
|
if (t.signal?.aborted) throw $();
|
|
@@ -2829,10 +2854,10 @@ async function Gr(e, t = {}) {
|
|
|
2829
2854
|
if (t.signal?.aborted) throw $();
|
|
2830
2855
|
if (e instanceof DOMException && e.name === "AbortError") throw e;
|
|
2831
2856
|
}
|
|
2832
|
-
await
|
|
2857
|
+
await qr(n, t.signal);
|
|
2833
2858
|
}
|
|
2834
2859
|
}
|
|
2835
|
-
async function
|
|
2860
|
+
async function Yr(e, t) {
|
|
2836
2861
|
if (!e.width || !e.height) return {
|
|
2837
2862
|
status: "backFailed",
|
|
2838
2863
|
fields: {},
|
|
@@ -2847,18 +2872,18 @@ async function Kr(e, t) {
|
|
|
2847
2872
|
barcodeText: n
|
|
2848
2873
|
};
|
|
2849
2874
|
if (!n) {
|
|
2850
|
-
let e = t.ocr ?
|
|
2875
|
+
let e = t.ocr ? Ur(t.ocr) : {};
|
|
2851
2876
|
return {
|
|
2852
2877
|
status: "barcodeUnreadable",
|
|
2853
2878
|
fields: e,
|
|
2854
2879
|
rawElements: {},
|
|
2855
|
-
sources:
|
|
2880
|
+
sources: Xn(Yn(), e, "ocr"),
|
|
2856
2881
|
front: t,
|
|
2857
2882
|
back: r,
|
|
2858
2883
|
message: "The PDF417 barcode on the back could not be read. Try again."
|
|
2859
2884
|
};
|
|
2860
2885
|
}
|
|
2861
|
-
let i =
|
|
2886
|
+
let i = Jn(n), a = t.ocr ? Ur(t.ocr) : {}, o = Wr(i.fields, a);
|
|
2862
2887
|
return {
|
|
2863
2888
|
status: "success",
|
|
2864
2889
|
fields: o.fields,
|
|
@@ -2868,21 +2893,21 @@ async function Kr(e, t) {
|
|
|
2868
2893
|
back: r
|
|
2869
2894
|
};
|
|
2870
2895
|
}
|
|
2871
|
-
function
|
|
2896
|
+
function Xr(e) {
|
|
2872
2897
|
return e === "back" ? 0 : void 0;
|
|
2873
2898
|
}
|
|
2874
|
-
function
|
|
2899
|
+
function Zr(e, t) {
|
|
2875
2900
|
return e === "front" ? {
|
|
2876
2901
|
title: "Scan a driver’s license",
|
|
2877
2902
|
headline: "Show the front of the license.",
|
|
2878
2903
|
detail: t ? "Take a photo of the front. There is no live document guide." : "Place the front of the license in the frame."
|
|
2879
2904
|
} : {
|
|
2880
2905
|
title: "Scan a driver’s license",
|
|
2881
|
-
headline: "
|
|
2882
|
-
detail: t ? "Take a photo of the PDF417 barcode
|
|
2906
|
+
headline: "Hold the whole barcode in view",
|
|
2907
|
+
detail: t ? "Take a photo of the entire PDF417 barcode. There is no document outline." : "Keep the entire PDF417 in the preview. Closer is fine if the whole code is visible."
|
|
2883
2908
|
};
|
|
2884
2909
|
}
|
|
2885
|
-
async function
|
|
2910
|
+
async function Qr(e = {}) {
|
|
2886
2911
|
await x("scan"), await x("ocr");
|
|
2887
2912
|
let t = "front", n, r = !1;
|
|
2888
2913
|
return {
|
|
@@ -2896,10 +2921,10 @@ async function Yr(e = {}) {
|
|
|
2896
2921
|
message: "This license scan was cancelled."
|
|
2897
2922
|
};
|
|
2898
2923
|
if (t === "front") {
|
|
2899
|
-
let r = await
|
|
2924
|
+
let r = await Kr(i, a, e.scan);
|
|
2900
2925
|
return r.kind === "need-back" && (n = r.front, t = "back"), r;
|
|
2901
2926
|
}
|
|
2902
|
-
let o = await
|
|
2927
|
+
let o = await Yr(i, n ?? {});
|
|
2903
2928
|
return o.status === "backFailed" ? {
|
|
2904
2929
|
kind: "retry",
|
|
2905
2930
|
status: "backFailed",
|
|
@@ -2915,6 +2940,6 @@ async function Yr(e = {}) {
|
|
|
2915
2940
|
};
|
|
2916
2941
|
}
|
|
2917
2942
|
//#endregion
|
|
2918
|
-
export { y as $, ut as A, ve as B, yt as C, st as D, ct as E, N as F, le as G, M as H, k as I, re as J, Ne as K, se as L, ge as M, he as N, Xe as O, Te as P, b as Q, Pe as R, jt as S, qe as T, Fe as U, j as V, ce as W, o as X, a as Y, x as Z, Ct as _,
|
|
2943
|
+
export { y as $, ut as A, ve as B, yt as C, st as D, ct as E, N as F, le as G, M as H, k as I, re as J, Ne as K, se as L, ge as M, he as N, Xe as O, Te as P, b as Q, Pe as R, jt as S, qe as T, Fe as U, j as V, ce as W, o as X, a as Y, x as Z, Ct as _, Qr as a, At as b, Br as c, Jn as d, e as et, U as f, Mt as g, wt as h, Wr as i, lt as j, R as k, _r as l, H as m, Xr as n, Jr as o, jn as p, _e as q, Zr as r, Lr as s, Ur as t, t as tt, K as u, xt as v, It as w, kt as x, bt as y, A as z };
|
|
2919
2944
|
|
|
2920
|
-
//# sourceMappingURL=driver-license-
|
|
2945
|
+
//# sourceMappingURL=driver-license-CV0oawgf.js.map
|