@exige/web-scanner-sdk 0.2.12 → 0.2.13

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.
@@ -184,7 +184,7 @@ function ee(e) {
184
184
  let t = Number(e.headers.get("content-length"));
185
185
  return Number.isFinite(t) && t > 0 ? t : null;
186
186
  }
187
- function O() {
187
+ function te() {
188
188
  if (w.size === 0) return {
189
189
  downloading: !1,
190
190
  loaded: 0,
@@ -198,22 +198,22 @@ function O() {
198
198
  total: n ? t : null
199
199
  };
200
200
  }
201
- function k() {
202
- let e = O();
201
+ function ne() {
202
+ let e = te();
203
203
  for (let t of T) t(e);
204
204
  }
205
- function te(e) {
206
- return e(O()), T.add(e), () => {
205
+ function re(e) {
206
+ return e(te()), T.add(e), () => {
207
207
  T.delete(e);
208
208
  };
209
209
  }
210
- function A(e, t) {
210
+ function O(e, t) {
211
211
  t.done ? w.delete(e) : w.set(e, {
212
212
  loaded: t.loaded,
213
213
  total: t.total
214
- }), k();
214
+ }), ne();
215
215
  }
216
- async function ne(e, t) {
216
+ async function ie(e, t) {
217
217
  let n = ee(e);
218
218
  if (!e.body) {
219
219
  let r = await e.arrayBuffer();
@@ -238,46 +238,46 @@ async function ne(e, t) {
238
238
  total: n
239
239
  }), o.buffer;
240
240
  }
241
- async function re(t, n) {
241
+ async function ae(t, n) {
242
242
  let r = E.get(t);
243
243
  if (r) return r.slice(0);
244
244
  let i = D.get(t);
245
245
  if (i) return i.then((e) => e.slice(0));
246
246
  let a = (async () => {
247
- A(t, {
247
+ O(t, {
248
248
  loaded: 0,
249
249
  total: null
250
250
  });
251
251
  let r = await fetch(t, { cache: n?.cache });
252
252
  if (!r.ok) throw new e("model-http", `Model request failed with HTTP ${r.status}.`);
253
- return ne(r, (e) => A(t, e));
253
+ return ie(r, (e) => O(t, e));
254
254
  })();
255
255
  D.set(t, a);
256
256
  try {
257
257
  let e = await a;
258
258
  return E.set(t, e), e.slice(0);
259
259
  } finally {
260
- D.delete(t), w.has(t) && (w.delete(t), k());
260
+ D.delete(t), w.has(t) && (w.delete(t), ne());
261
261
  }
262
262
  }
263
263
  //#endregion
264
264
  //#region src/sdk/ort-runtime.ts
265
- var ie = new URL("./assets/ort-wasm-simd-threaded.jsep.wasm", import.meta.url), ae = new URL("./assets/ort-wasm-simd-threaded.jsep.mjs", import.meta.url);
266
- function oe() {
265
+ var oe = new URL("./assets/ort-wasm-simd-threaded.jsep.wasm", import.meta.url), se = new URL("./assets/ort-wasm-simd-threaded.jsep.mjs", import.meta.url);
266
+ function k() {
267
267
  return {
268
- wasm: ie.href,
269
- mjs: ae.href
268
+ wasm: oe.href,
269
+ mjs: se.href
270
270
  };
271
271
  }
272
- function se(e) {
273
- return typeof e == "string" ? e.trim() || oe() : e?.wasm.trim() && e.mjs.trim() ? {
272
+ function ce(e) {
273
+ return typeof e == "string" ? e.trim() || k() : e?.wasm.trim() && e.mjs.trim() ? {
274
274
  wasm: e.wasm.trim(),
275
275
  mjs: e.mjs.trim()
276
- } : oe();
276
+ } : k();
277
277
  }
278
278
  //#endregion
279
279
  //#region src/sdk/image.ts
280
- function ce(e, t, n) {
280
+ function A(e, t, n) {
281
281
  let r = n ? Math.min(1, n / Math.max(e, t)) : 1;
282
282
  return {
283
283
  width: Math.max(1, Math.round(e * r)),
@@ -299,14 +299,14 @@ async function j(e, n = {}) {
299
299
  if (!i) throw t();
300
300
  if (e instanceof Blob) {
301
301
  if ("createImageBitmap" in window) try {
302
- let t = await createImageBitmap(e), a = ce(t.width, t.height, n.maxDimension);
302
+ let t = await createImageBitmap(e), a = A(t.width, t.height, n.maxDimension);
303
303
  return r.width = a.width, r.height = a.height, i.drawImage(t, 0, 0, a.width, a.height), t.close(), r;
304
304
  } catch {}
305
305
  e = await le(e);
306
306
  }
307
307
  let a = e instanceof HTMLImageElement ? e.naturalWidth : e.width, o = e instanceof HTMLImageElement ? e.naturalHeight : e.height;
308
308
  if (!a || !o) throw Error("The image has no readable dimensions.");
309
- let s = ce(a, o, n.maxDimension);
309
+ let s = A(a, o, n.maxDimension);
310
310
  return r.width = s.width, r.height = s.height, i.drawImage(e, 0, 0, s.width, s.height), r;
311
311
  }
312
312
  function ue(e, t = "image/png", n = .92) {
@@ -373,7 +373,7 @@ function ge(t, n, r, i) {
373
373
  return new Promise((a, o) => {
374
374
  N || (N = new Worker(new URL("./assets/document-worker.js", import.meta.url), { type: "module" }), N.onmessage = (t) => {
375
375
  if (t.data.download?.url) {
376
- A(t.data.download.url, t.data.download);
376
+ O(t.data.download.url, t.data.download);
377
377
  return;
378
378
  }
379
379
  let n = P.get(t.data.id);
@@ -397,7 +397,7 @@ function ge(t, n, r, i) {
397
397
  modelUrl: M(i.modelUrl),
398
398
  heatmapThreshold: i.heatmapThreshold,
399
399
  cacheModel: i.cacheModel,
400
- ortWasmPaths: se(i.ortWasmPaths)
400
+ ortWasmPaths: ce(i.ortWasmPaths)
401
401
  }, [c]);
402
402
  });
403
403
  }
@@ -570,7 +570,12 @@ function H(e = typeof navigator > "u" ? "" : navigator.userAgent, t = typeof nav
570
570
  userAgent: e
571
571
  };
572
572
  }
573
- var xe = 10, U = class {
573
+ var xe = 1920, Se = 1280;
574
+ function U(e) {
575
+ let t = e ?? H();
576
+ return !t.iosWebKit && t.browser === "chrome" && /Android/i.test(t.userAgent) && !/Edg|OPR|SamsungBrowser/i.test(t.userAgent);
577
+ }
578
+ var Ce = 10, W = class {
574
579
  on = !1;
575
580
  darkCount = 0;
576
581
  brightCount = 0;
@@ -593,7 +598,7 @@ var xe = 10, U = class {
593
598
  return this.on;
594
599
  }
595
600
  };
596
- function W(e, t) {
601
+ function G(e, t) {
597
602
  return t ? e === "alwaysOn" || e === "alwaysOff" ? {
598
603
  mode: e,
599
604
  supported: !0,
@@ -617,37 +622,37 @@ function W(e, t) {
617
622
  automatic: e === "auto"
618
623
  };
619
624
  }
620
- function G(e) {
625
+ function K(e) {
621
626
  let t = Math.floor(e.length / 4);
622
627
  if (!t) return 0;
623
628
  let n = 0;
624
629
  for (let r = 0; r < t * 4; r += 4) n += e[r] * .299 + e[r + 1] * .587 + e[r + 2] * .114;
625
630
  return n / t;
626
631
  }
627
- function Se(e, t = 10) {
632
+ function we(e, t = 10) {
628
633
  if (e.length < 4) return !0;
629
634
  let n = Math.floor(e.length / 4), r = 0;
630
635
  for (let i = 0; i < n * 4; i += 4) e[i] * .299 + e[i + 1] * .587 + e[i + 2] * .114 > t * 2 && (r += 1);
631
- return G(e) <= t && r / n < .01;
636
+ return K(e) <= t && r / n < .01;
632
637
  }
633
- function Ce(e, t, n) {
638
+ function q(e, t, n) {
634
639
  if (!t || !n) return 0;
635
640
  let r = document.createElement("canvas");
636
641
  r.width = Math.min(32, t), r.height = Math.min(32, n);
637
642
  let i = r.getContext("2d", { willReadFrequently: !0 });
638
- return i ? (i.drawImage(e, 0, 0, r.width, r.height), G(i.getImageData(0, 0, r.width, r.height).data)) : 0;
643
+ return i ? (i.drawImage(e, 0, 0, r.width, r.height), K(i.getImageData(0, 0, r.width, r.height).data)) : 0;
639
644
  }
640
- function we(e) {
641
- return Ce(e, e.width, e.height);
645
+ function Te(e) {
646
+ return q(e, e.width, e.height);
642
647
  }
643
- function Te(e, t = 120) {
648
+ function Ee(e, t = 120) {
644
649
  let n = document.createElement("canvas"), r = n.getContext("2d"), i = typeof e.requestVideoFrameCallback == "function", a = !0, o = 0, s = 0, c = 0, l = 0, u = 0, d = () => {
645
650
  a && (o = i ? e.requestVideoFrameCallback(f) : requestAnimationFrame(f));
646
651
  };
647
652
  function f() {
648
653
  if (!a) return;
649
654
  let { videoWidth: i, videoHeight: o } = e, f = performance.now();
650
- r && i && o && f - s >= t && (s = f, l = Ce(e, i, o), l > 10 && ((n.width !== i || n.height !== o) && (n.width = i, n.height = o), r.drawImage(e, 0, 0, i, o), u = l, c = f)), d();
655
+ r && i && o && f - s >= t && (s = f, l = q(e, i, o), l > 10 && ((n.width !== i || n.height !== o) && (n.width = i, n.height = o), r.drawImage(e, 0, 0, i, o), u = l, c = f)), d();
651
656
  }
652
657
  return d(), {
653
658
  stop() {
@@ -659,18 +664,24 @@ function Te(e, t = 120) {
659
664
  getMirrorAgeMs: () => c ? performance.now() - c : Infinity
660
665
  };
661
666
  }
662
- function Ee(e) {
667
+ function De(e) {
663
668
  let t = document.createElement("canvas");
664
669
  return t.width = e.width, t.height = e.height, t.getContext("2d")?.drawImage(e, 0, 0), t;
665
670
  }
666
- function K(e = {}) {
667
- let t = { ideal: e.idealWidth ?? 3840 }, n = { ideal: e.idealHeight ?? 2160 };
668
- return e.maxWidth && (t.max = e.maxWidth), e.maxHeight && (n.max = e.maxHeight), {
671
+ function Oe(e = {}, t = H()) {
672
+ if (e.maxHeight) return e.maxHeight;
673
+ if (U(t)) return xe;
674
+ }
675
+ function J(e = {}, t = H()) {
676
+ let n = { ideal: e.idealWidth ?? 3840 }, r = { ideal: e.idealHeight ?? 2160 };
677
+ e.maxWidth && (n.max = e.maxWidth);
678
+ let i = Oe(e, t);
679
+ return i && (r.max = i), {
669
680
  audio: !1,
670
681
  video: {
671
682
  facingMode: { ideal: e.facingMode ?? "environment" },
672
- width: t,
673
- height: n,
683
+ width: n,
684
+ height: r,
674
685
  frameRate: {
675
686
  ideal: e.maxFrameRate ?? 30,
676
687
  max: e.maxFrameRate ?? 30
@@ -678,7 +689,7 @@ function K(e = {}) {
678
689
  }
679
690
  };
680
691
  }
681
- function q(e, n) {
692
+ function Y(e, n) {
682
693
  if (!e.videoWidth || !e.videoHeight) throw Error("The camera is not ready to capture a frame.");
683
694
  let r = n ? Math.min(1, n / Math.max(e.videoWidth, e.videoHeight)) : 1, i = document.createElement("canvas");
684
695
  i.width = Math.max(1, Math.round(e.videoWidth * r)), i.height = Math.max(1, Math.round(e.videoHeight * r));
@@ -686,33 +697,34 @@ function q(e, n) {
686
697
  if (!a) throw t();
687
698
  return a.drawImage(e, 0, 0, i.width, i.height), i;
688
699
  }
689
- function De(e) {
690
- return e.idealWidth || e.idealHeight || e.maxWidth || e.maxHeight ? [K(e)] : [
691
- K({
700
+ function ke(e) {
701
+ let t = H();
702
+ return e.idealWidth || e.idealHeight || e.maxWidth || e.maxHeight ? [J(e, t)] : [
703
+ J({
692
704
  ...e,
693
705
  idealWidth: 3840,
694
706
  idealHeight: 2160
695
- }),
696
- K({
707
+ }, t),
708
+ J({
697
709
  ...e,
698
710
  idealWidth: 2560,
699
711
  idealHeight: 1440
700
- }),
701
- K({
712
+ }, t),
713
+ J({
702
714
  ...e,
703
715
  idealWidth: 1920,
704
716
  idealHeight: 1080
705
- })
717
+ }, t)
706
718
  ];
707
719
  }
708
- async function Oe(t, n = {}) {
720
+ async function Ae(t, n = {}) {
709
721
  await x("scan");
710
722
  let r = n.torch ?? "alwaysOff";
711
723
  if (r !== "alwaysOff" && await x("torch"), !window.isSecureContext && location.hostname !== "localhost") throw new e("secure-context", "Camera access requires HTTPS.");
712
724
  if (!navigator.mediaDevices?.getUserMedia) throw Error("Live camera access is unavailable. Use the native camera picker instead.");
713
725
  t.muted = !0, t.autoplay = !0, t.playsInline = !0, t.setAttribute("playsinline", "");
714
726
  let i, a;
715
- for (let e of De(n)) try {
727
+ for (let e of ke(n)) try {
716
728
  i = await navigator.mediaDevices.getUserMedia(e);
717
729
  break;
718
730
  } catch (e) {
@@ -725,7 +737,7 @@ async function Oe(t, n = {}) {
725
737
  for (let e of i.getTracks()) e.stop();
726
738
  throw Error("The camera did not provide a video track.");
727
739
  }
728
- let s = Te(t), c = "ImageCapture" in globalThis, l = W(r, (typeof o.getCapabilities == "function" ? o.getCapabilities() : void 0)?.torch === !0), u = !1, d = async (e) => {
740
+ let s = Ee(t), c = "ImageCapture" in globalThis, l = G(r, (typeof o.getCapabilities == "function" ? o.getCapabilities() : void 0)?.torch === !0), u = !1, d = async (e) => {
729
741
  if (!l.supported || o.readyState !== "live") return !1;
730
742
  try {
731
743
  return await o.applyConstraints({ advanced: [{ torch: e }] }), l = {
@@ -743,7 +755,7 @@ async function Oe(t, n = {}) {
743
755
  }
744
756
  };
745
757
  l.on && await d(!0);
746
- let f = r === "auto" && l.supported ? new U() : void 0, p = f ? window.setInterval(() => {
758
+ let f = r === "auto" && l.supported ? new W() : void 0, p = f ? window.setInterval(() => {
747
759
  if (u || !l.supported) return;
748
760
  let e = f.update(s.getLiveLuminance());
749
761
  e !== void 0 && e !== l.on && (u = !0, d(e).finally(() => {
@@ -783,15 +795,15 @@ async function Oe(t, n = {}) {
783
795
  get torchOn() {
784
796
  return l.on;
785
797
  },
786
- capture: (e) => q(t, e),
798
+ capture: (e) => Y(t, e),
787
799
  async capturePhoto() {
788
800
  let e, n = 0;
789
801
  try {
790
- e = q(t), n = we(e);
802
+ e = Y(t), n = Te(e);
791
803
  } catch {
792
804
  e = void 0;
793
805
  }
794
- let r = s.getFrame(), i = e && n > 10 ? e : void 0, a = i ?? (r ? Ee(r) : void 0);
806
+ let r = s.getFrame(), i = e && n > 10 ? e : void 0, a = i ?? (r ? De(r) : void 0);
795
807
  if (!a) throw Error("The camera preview produced no visible pixels. Keep the scanner on screen, wait for the preview, and retake.");
796
808
  return {
797
809
  frame: a,
@@ -817,12 +829,12 @@ async function Oe(t, n = {}) {
817
829
  }
818
830
  //#endregion
819
831
  //#region src/sdk/lighting.ts
820
- function ke(e, t) {
832
+ function je(e, t) {
821
833
  if (!e.length) return 0;
822
834
  let n = [...e].sort((e, t) => e - t);
823
835
  return n[Math.min(n.length - 1, Math.floor(n.length * t))];
824
836
  }
825
- function J(e, t, n, r = 12) {
837
+ function X(e, t, n, r = 12) {
826
838
  if (!t || !n || e.length < t * n) return {
827
839
  strong: !1,
828
840
  strength: 0,
@@ -845,7 +857,7 @@ function J(e, t, n, r = 12) {
845
857
  });
846
858
  }
847
859
  }
848
- let s = ke(o.map((e) => e.mean), .8), c = o.map((e) => s - e.mean >= 24 && e.mean >= 35), l = new Uint8Array(o.length), u = [];
860
+ let s = je(o.map((e) => e.mean), .8), c = o.map((e) => s - e.mean >= 24 && e.mean >= 35), l = new Uint8Array(o.length), u = [];
849
861
  for (let e = 0; e < o.length; e += 1) {
850
862
  if (!c[e] || l[e]) continue;
851
863
  let t = [], n = [e];
@@ -893,7 +905,7 @@ function J(e, t, n, r = 12) {
893
905
  }
894
906
  return d;
895
907
  }
896
- function Ae(e, t, n, r = Math.max(12, Math.round(Math.max(t, n) / 32))) {
908
+ function Me(e, t, n, r = Math.max(12, Math.round(Math.max(t, n) / 32))) {
897
909
  let i = t + 1, a = new Uint32Array((t + 1) * (n + 1));
898
910
  for (let r = 1; r <= n; r += 1) {
899
911
  let n = 0;
@@ -909,7 +921,7 @@ function Ae(e, t, n, r = Math.max(12, Math.round(Math.max(t, n) / 32))) {
909
921
  }
910
922
  return o;
911
923
  }
912
- function je(e, t, n) {
924
+ function Ne(e, t, n) {
913
925
  let r = [
914
926
  e.topLeft,
915
927
  e.topRight,
@@ -923,8 +935,8 @@ function je(e, t, n) {
923
935
  height: s - a
924
936
  };
925
937
  }
926
- function Me(e, t) {
927
- let n = je(t, e.width, e.height);
938
+ function Pe(e, t) {
939
+ let n = Ne(t, e.width, e.height);
928
940
  if (n.width <= 0 || n.height <= 0) return {
929
941
  strong: !1,
930
942
  strength: 0,
@@ -943,18 +955,18 @@ function Me(e, t) {
943
955
  i.drawImage(e, n.left, n.top, n.width, n.height, 0, 0, r.width, r.height);
944
956
  let a = i.getImageData(0, 0, r.width, r.height).data, o = new Uint8Array(r.width * r.height);
945
957
  for (let e = 0, t = 0; e < o.length; e += 1, t += 4) o[e] = Math.round(a[t] * .299 + a[t + 1] * .587 + a[t + 2] * .114);
946
- return J(o, r.width, r.height);
958
+ return X(o, r.width, r.height);
947
959
  }
948
960
  //#endregion
949
961
  //#region src/sdk/finder.ts
950
- function Ne(e, t) {
962
+ function Fe(e, t) {
951
963
  return t.castShadow && (e.reason === "hold-still" || e.reason === "ready") ? t.hint ?? e.hint : e.hint;
952
964
  }
953
- async function Pe(e, t) {
965
+ async function Ie(e, t) {
954
966
  let n = await e();
955
967
  return t(), n;
956
968
  }
957
- function Fe(e) {
969
+ function Le(e) {
958
970
  return e === "alwaysOn" || e === "only" ? {
959
971
  visible: !1,
960
972
  checked: !0,
@@ -969,7 +981,7 @@ function Fe(e) {
969
981
  mutable: !0
970
982
  };
971
983
  }
972
- function Y(e) {
984
+ function Z(e) {
973
985
  return [
974
986
  e.topLeft,
975
987
  e.topRight,
@@ -977,7 +989,11 @@ function Y(e) {
977
989
  e.bottomLeft
978
990
  ];
979
991
  }
980
- function Ie(e) {
992
+ var Re = 1600;
993
+ function ze(e = H()) {
994
+ return U(e) ? Se : Re;
995
+ }
996
+ function Be(e) {
981
997
  let t = 0;
982
998
  for (let n = 0; n < e.length; n += 1) {
983
999
  let r = e[n], i = e[(n + 1) % e.length];
@@ -985,42 +1001,42 @@ function Ie(e) {
985
1001
  }
986
1002
  return Math.abs(t) / 2;
987
1003
  }
988
- function X(e, t) {
1004
+ function Q(e, t) {
989
1005
  return Math.hypot(e.x - t.x, e.y - t.y);
990
1006
  }
991
- var Z = {
1007
+ var $ = {
992
1008
  widthFill: 0,
993
1009
  heightFill: 0,
994
1010
  limitingFill: 0,
995
1011
  areaFill: 0,
996
1012
  aspectRatio: 1
997
1013
  };
998
- function Le(e, t, n) {
999
- let r = Y(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(X(c, l), X(d, u)), p = Math.max(X(c, d), X(l, u));
1014
+ function Ve(e, t, n) {
1015
+ 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(Q(c, l), Q(d, u)), p = Math.max(Q(c, d), Q(l, u));
1000
1016
  return {
1001
1017
  widthFill: o,
1002
1018
  heightFill: s,
1003
1019
  limitingFill: Math.max(o, s),
1004
- areaFill: Ie(r) / Math.max(1, t * n),
1020
+ areaFill: Be(r) / Math.max(1, t * n),
1005
1021
  aspectRatio: Math.max(f, p) / Math.max(1, Math.min(f, p))
1006
1022
  };
1007
1023
  }
1008
- function Re(e, t, n, r = {}) {
1024
+ function He(e, t, n, r = {}) {
1009
1025
  let i = t ? r.exitFillRatio ?? .64 : r.minFillRatio ?? .72, a = r.highAspectRatio ?? 2.2;
1010
1026
  if (e.aspectRatio < a) return i;
1011
1027
  let o = t ? r.highAspectExitFillRatio : r.highAspectFillRatio;
1012
1028
  return Math.min(o ?? i + .08, 1 - n * 2);
1013
1029
  }
1014
- function Q(e, t, n = {}) {
1030
+ function Ue(e, t, n = {}) {
1015
1031
  let r = n.confidenceThreshold ?? .72;
1016
1032
  if (e.status !== "success" || !e.quad || e.confidence < r || !e.sourceWidth || !e.sourceHeight) return {
1017
1033
  hint: "Place the document in the frame",
1018
1034
  reason: "place-document",
1019
1035
  fillRatio: 0,
1020
- fill: Z,
1036
+ fill: $,
1021
1037
  readyForAutoCapture: !1
1022
1038
  };
1023
- let i = Y(e.quad), a = Le(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;
1039
+ let i = Z(e.quad), a = Ve(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;
1024
1040
  if (i.some(({ x: t, y: n }) => t <= c || t >= e.sourceWidth - c || n <= l || n >= e.sourceHeight - l)) return {
1025
1041
  hint: "Move farther away",
1026
1042
  reason: "move-farther-away",
@@ -1028,14 +1044,14 @@ function Q(e, t, n = {}) {
1028
1044
  fill: a,
1029
1045
  readyForAutoCapture: !1
1030
1046
  };
1031
- let [u, d, f, p] = i, m = X(u, d), h = X(d, f), g = X(f, p), _ = X(p, u);
1047
+ let [u, d, f, p] = i, m = Q(u, d), h = Q(d, f), g = Q(f, p), _ = Q(p, u);
1032
1048
  return Math.min(Math.min(m, g) / Math.max(1, Math.max(m, g)), Math.min(_, h) / Math.max(1, Math.max(_, h))) < (t.previouslyReady ? n.exitMinPerspectiveRatio ?? .4 : n.minPerspectiveRatio ?? .48) ? {
1033
1049
  hint: "Hold the camera straight",
1034
1050
  reason: "straighten-camera",
1035
1051
  fillRatio: o,
1036
1052
  fill: a,
1037
1053
  readyForAutoCapture: !1
1038
- } : o < Re(a, t.previouslyReady === !0, s, n) ? {
1054
+ } : o < He(a, t.previouslyReady === !0, s, n) ? {
1039
1055
  hint: "Move closer",
1040
1056
  reason: "move-closer",
1041
1057
  fillRatio: o,
@@ -1049,7 +1065,7 @@ function Q(e, t, n = {}) {
1049
1065
  readyForAutoCapture: t.ready
1050
1066
  };
1051
1067
  }
1052
- var $ = class {
1068
+ var We = class {
1053
1069
  previous;
1054
1070
  count = 0;
1055
1071
  ready = !1;
@@ -1066,8 +1082,8 @@ var $ = class {
1066
1082
  ready: !1,
1067
1083
  movement: Infinity
1068
1084
  };
1069
- let t = Math.hypot(e.sourceWidth, e.sourceHeight), n = this.previous ? Math.max(...Y(e.quad).map((e, n) => {
1070
- let r = Y(this.previous)[n];
1085
+ let t = Math.hypot(e.sourceWidth, e.sourceHeight), n = this.previous ? Math.max(...Z(e.quad).map((e, n) => {
1086
+ let r = Z(this.previous)[n];
1071
1087
  return Math.hypot(e.x - r.x, e.y - r.y) / Math.max(1, t);
1072
1088
  })) : Infinity, r = this.options.exitCornerTolerance ?? Math.max(this.options.cornerTolerance, .036);
1073
1089
  return this.ready && this.previous && n <= r ? this.count = Math.max(this.options.stableFrames, this.count + 1) : (this.ready = !1, this.count = this.previous && n <= this.options.cornerTolerance ? this.count + 1 : 1, this.count >= this.options.stableFrames && (this.ready = !0)), this.previous = e.quad, {
@@ -1077,14 +1093,14 @@ var $ = class {
1077
1093
  };
1078
1094
  }
1079
1095
  };
1080
- function ze(e, n) {
1096
+ function Ge(e, n) {
1081
1097
  let r = Math.min(1, n / Math.max(e.width, e.height)), i = document.createElement("canvas");
1082
1098
  i.width = Math.max(1, Math.round(e.width * r)), i.height = Math.max(1, Math.round(e.height * r));
1083
1099
  let a = i.getContext("2d");
1084
1100
  if (!a) throw t();
1085
1101
  return a.drawImage(e, 0, 0, i.width, i.height), i;
1086
1102
  }
1087
- function Be() {
1103
+ function Ke() {
1088
1104
  let e = window.AudioContext ?? window.webkitAudioContext;
1089
1105
  if (!e) return;
1090
1106
  let t = new e(), n = Math.round(t.sampleRate * .09), r = t.createBuffer(1, n, t.sampleRate), i = r.getChannelData(0);
@@ -1095,29 +1111,29 @@ function Be() {
1095
1111
  let a = t.createBufferSource(), o = t.createBiquadFilter(), s = t.createGain();
1096
1112
  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();
1097
1113
  }
1098
- async function Ve(e) {
1114
+ async function qe(e) {
1099
1115
  let t = document.createElement("video");
1100
1116
  return t.muted = !0, t.autoplay = !0, t.playsInline = !0, t.srcObject = e, await t.play(), t;
1101
1117
  }
1102
- async function He(t) {
1118
+ async function Je(t) {
1103
1119
  await x("scan");
1104
- let n = Fe(t.autoCapture), r = new $({
1120
+ let n = Le(t.autoCapture), r = new We({
1105
1121
  stableFrames: t.stableFrames ?? 4,
1106
1122
  confidenceThreshold: t.confidenceThreshold ?? .72,
1107
1123
  cornerTolerance: t.cornerTolerance ?? .024,
1108
1124
  exitCornerTolerance: t.exitCornerTolerance ?? .036
1109
- }), i = t.maxFrameDimension ?? 1600, a = t.intervalMs ?? 140, o = {
1125
+ }), i = t.maxFrameDimension ?? ze(), a = t.intervalMs ?? 140, o = {
1110
1126
  minDimension: 220,
1111
1127
  maxAnalysisDimension: 520,
1112
1128
  ...t.detection
1113
- }, s = typeof MediaStream < "u" && t.source instanceof MediaStream ? await Ve(t.source) : t.source, c = !0, l = !1, u = !1, d = 0, f, p = {
1129
+ }, s = typeof MediaStream < "u" && t.source instanceof MediaStream ? await qe(t.source) : t.source, c = !0, l = !1, u = !1, d = 0, f, p = {
1114
1130
  state: "detecting",
1115
1131
  confidence: 0,
1116
1132
  guidance: {
1117
1133
  hint: "Place the document in the frame",
1118
1134
  reason: "place-document",
1119
1135
  fillRatio: 0,
1120
- fill: Z,
1136
+ fill: $,
1121
1137
  readyForAutoCapture: !1
1122
1138
  },
1123
1139
  lighting: {
@@ -1127,7 +1143,7 @@ async function He(t) {
1127
1143
  stableFrames: 0,
1128
1144
  requiredStableFrames: t.stableFrames ?? 4,
1129
1145
  autoCapture: { ...n }
1130
- }, m = () => s instanceof HTMLCanvasElement ? ze(s, i) : q(s, i), h = (e) => {
1146
+ }, m = () => s instanceof HTMLCanvasElement ? Ge(s, i) : Y(s, i), h = (e) => {
1131
1147
  p = e, t.onStatus?.(e);
1132
1148
  }, g = () => {
1133
1149
  c = !1, window.clearTimeout(d), s instanceof HTMLVideoElement && s !== t.source && (s.srcObject = null);
@@ -1136,11 +1152,11 @@ async function He(t) {
1136
1152
  l = !0;
1137
1153
  let n;
1138
1154
  try {
1139
- n = await Pe(t.captureFrame ?? m, () => {
1155
+ n = await Ie(t.captureFrame ?? m, () => {
1140
1156
  h({
1141
1157
  ...p,
1142
1158
  state: "captured"
1143
- }), t.playShutterSound !== !1 && Be(), g();
1159
+ }), t.playShutterSound !== !1 && Ke(), g();
1144
1160
  });
1145
1161
  } catch (e) {
1146
1162
  throw l = !1, e instanceof Error ? e : /* @__PURE__ */ Error("The camera frame could not be captured.");
@@ -1156,7 +1172,7 @@ async function He(t) {
1156
1172
  try {
1157
1173
  let e = m(), i = await B(e, o);
1158
1174
  f = i;
1159
- let a = i.quad ? Me(e, i.quad) : {
1175
+ let a = i.quad ? Pe(e, i.quad) : {
1160
1176
  strong: !1,
1161
1177
  strength: 0
1162
1178
  }, s = a.strong ? {
@@ -1166,7 +1182,7 @@ async function He(t) {
1166
1182
  } : {
1167
1183
  castShadow: !1,
1168
1184
  strength: a.strength
1169
- }, c = r.update(i), l = Q(i, {
1185
+ }, c = r.update(i), l = Ue(i, {
1170
1186
  ...c,
1171
1187
  previouslyReady: u
1172
1188
  }, {
@@ -1211,7 +1227,7 @@ async function He(t) {
1211
1227
  hint: "Place the document in the frame",
1212
1228
  reason: "place-document",
1213
1229
  fillRatio: 0,
1214
- fill: Z,
1230
+ fill: $,
1215
1231
  readyForAutoCapture: !1
1216
1232
  },
1217
1233
  lighting: {
@@ -1240,6 +1256,6 @@ async function He(t) {
1240
1256
  };
1241
1257
  }
1242
1258
  //#endregion
1243
- export { a as A, M as C, j as D, de as E, e as F, t as I, x as M, b as N, re as O, y as P, B as S, ue as T, K as _, Q as a, fe as b, J as c, xe as d, q as f, G as g, Se as h, Le as i, o as j, te as k, Ae as l, be as m, Fe as n, Ne as o, H as p, Re as r, He as s, $ as t, U as u, Oe as v, ye as w, ve as x, W as y };
1259
+ export { a as A, M as C, j as D, de as E, e as F, t as I, x as M, b as N, ae as O, y as P, B as S, ue as T, J as _, Ue as a, fe as b, X as c, Ce as d, Y as f, K as g, we as h, Ve as i, o as j, re as k, Me as l, be as m, Le as n, Fe as o, H as p, He as r, Je as s, We as t, W as u, Ae as v, ye as w, ve as x, G as y };
1244
1260
 
1245
- //# sourceMappingURL=finder-B8yMQmN9.js.map
1261
+ //# sourceMappingURL=finder-CLEe-Zhj.js.map