@exige/web-scanner-sdk 0.2.13 → 0.2.15

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.
@@ -198,22 +198,22 @@ function te() {
198
198
  total: n ? t : null
199
199
  };
200
200
  }
201
- function ne() {
201
+ function O() {
202
202
  let e = te();
203
203
  for (let t of T) t(e);
204
204
  }
205
- function re(e) {
205
+ function ne(e) {
206
206
  return e(te()), T.add(e), () => {
207
207
  T.delete(e);
208
208
  };
209
209
  }
210
- function O(e, t) {
210
+ function k(e, t) {
211
211
  t.done ? w.delete(e) : w.set(e, {
212
212
  loaded: t.loaded,
213
213
  total: t.total
214
- }), ne();
214
+ }), O();
215
215
  }
216
- async function ie(e, t) {
216
+ async function re(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 ie(e, t) {
238
238
  total: n
239
239
  }), o.buffer;
240
240
  }
241
- async function ae(t, n) {
241
+ async function ie(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
- O(t, {
247
+ k(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 ie(r, (e) => O(t, e));
253
+ return re(r, (e) => k(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), ne());
260
+ D.delete(t), w.has(t) && (w.delete(t), O());
261
261
  }
262
262
  }
263
263
  //#endregion
264
264
  //#region src/sdk/ort-runtime.ts
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() {
265
+ var ae = new URL("./assets/ort-wasm-simd-threaded.jsep.wasm", import.meta.url), oe = new URL("./assets/ort-wasm-simd-threaded.jsep.mjs", import.meta.url);
266
+ function A() {
267
267
  return {
268
- wasm: oe.href,
269
- mjs: se.href
268
+ wasm: ae.href,
269
+ mjs: oe.href
270
270
  };
271
271
  }
272
- function ce(e) {
273
- return typeof e == "string" ? e.trim() || k() : e?.wasm.trim() && e.mjs.trim() ? {
272
+ function se(e) {
273
+ return typeof e == "string" ? e.trim() || A() : e?.wasm.trim() && e.mjs.trim() ? {
274
274
  wasm: e.wasm.trim(),
275
275
  mjs: e.mjs.trim()
276
- } : k();
276
+ } : A();
277
277
  }
278
278
  //#endregion
279
279
  //#region src/sdk/image.ts
280
- function A(e, t, n) {
280
+ function ce(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 = A(t.width, t.height, n.maxDimension);
302
+ let t = await createImageBitmap(e), a = ce(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 = A(a, o, n.maxDimension);
309
+ let s = ce(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) {
@@ -323,11 +323,16 @@ function de(e, t, n) {
323
323
  }
324
324
  //#endregion
325
325
  //#region src/sdk/scan.ts
326
- var fe = "https://exige-scanner-sdk.vercel.app/models/docaligner-lcnet100-f4117b78.onnx";
326
+ var fe = "https://exige-scanner-sdk.vercel.app/models/docaligner-lcnet100-f4117b78.onnx", pe = 1280;
327
+ function me(e, t, n) {
328
+ if (n) return n;
329
+ let r = Math.max(e, t), i = r / Math.max(1, Math.min(e, t)), a = L() ? 560 : 900;
330
+ return i >= 1.6 ? Math.min(r, Math.max(a, pe)) : a;
331
+ }
327
332
  function M(e) {
328
333
  return e?.trim() || "https://exige-scanner-sdk.vercel.app/models/docaligner-lcnet100-f4117b78.onnx";
329
334
  }
330
- var pe = 3, N, me = 0, P = /* @__PURE__ */ new Map();
335
+ var he = 3, N, ge = 0, P = /* @__PURE__ */ new Map();
331
336
  function F(e, t) {
332
337
  return Math.hypot(e.x - t.x, e.y - t.y);
333
338
  }
@@ -354,7 +359,7 @@ function I(e) {
354
359
  }
355
360
  };
356
361
  }
357
- function he(e, t) {
362
+ function _e(e, t) {
358
363
  let n = (e) => ({
359
364
  x: e.x / t,
360
365
  y: e.y / t
@@ -369,11 +374,11 @@ function he(e, t) {
369
374
  function L() {
370
375
  return typeof navigator > "u" ? !1 : navigator.maxTouchPoints > 0 || navigator.hardwareConcurrency <= 4 || typeof matchMedia == "function" && matchMedia("(pointer: coarse)").matches;
371
376
  }
372
- function ge(t, n, r, i) {
377
+ function ve(t, n, r, i) {
373
378
  return new Promise((a, o) => {
374
379
  N || (N = new Worker(new URL("./assets/document-worker.js", import.meta.url), { type: "module" }), N.onmessage = (t) => {
375
380
  if (t.data.download?.url) {
376
- O(t.data.download.url, t.data.download);
381
+ k(t.data.download.url, t.data.download);
377
382
  return;
378
383
  }
379
384
  let n = P.get(t.data.id);
@@ -383,7 +388,7 @@ function ge(t, n, r, i) {
383
388
  for (let e of P.values()) e.reject(t);
384
389
  P.clear(), N?.terminate(), N = void 0;
385
390
  });
386
- let s = ++me;
391
+ let s = ++ge;
387
392
  P.set(s, {
388
393
  resolve: a,
389
394
  reject: o
@@ -397,7 +402,7 @@ function ge(t, n, r, i) {
397
402
  modelUrl: M(i.modelUrl),
398
403
  heatmapThreshold: i.heatmapThreshold,
399
404
  cacheModel: i.cacheModel,
400
- ortWasmPaths: ce(i.ortWasmPaths)
405
+ ortWasmPaths: se(i.ortWasmPaths)
401
406
  }, [c]);
402
407
  });
403
408
  }
@@ -410,14 +415,14 @@ async function R(n, r) {
410
415
  sourceWidth: i,
411
416
  sourceHeight: a
412
417
  };
413
- let s = L() ? 560 : 900, c = Math.min(1, (r.maxAnalysisDimension ?? s) / Math.max(i, a)), l = document.createElement("canvas");
418
+ let s = me(i, a, r.maxAnalysisDimension), c = Math.min(1, s / Math.max(i, a)), l = document.createElement("canvas");
414
419
  l.width = Math.max(1, Math.round(i * c)), l.height = Math.max(1, Math.round(a * c));
415
420
  let u = l.getContext("2d", { willReadFrequently: !0 });
416
421
  if (!u) throw t();
417
422
  u.drawImage(n, 0, 0, l.width, l.height);
418
423
  let d = u.getImageData(0, 0, l.width, l.height).data, f;
419
424
  if (r.useWorker !== !1 && typeof Worker < "u") try {
420
- f = await ge(d, l.width, l.height, r);
425
+ f = await ve(d, l.width, l.height, r);
421
426
  } catch (t) {
422
427
  if (t instanceof e && (t.code === "worker" || t.code === "model-http")) throw t;
423
428
  f = {
@@ -440,7 +445,7 @@ async function R(n, r) {
440
445
  modelError: v,
441
446
  inferenceMs: y
442
447
  };
443
- if (p < pe) return {
448
+ if (p < he) return {
444
449
  status: "low-quality",
445
450
  confidence: Math.min(.3, p / 18),
446
451
  message: "The image is too soft or dark to resolve four document edges.",
@@ -456,7 +461,7 @@ async function R(n, r) {
456
461
  sourceHeight: a,
457
462
  ...b
458
463
  };
459
- let x = he(m.corners, c), S = I(x), C = r.minConfidence ?? .58;
464
+ let x = _e(m.corners, c), S = I(x), C = r.minConfidence ?? .58;
460
465
  return m.confidence < C ? {
461
466
  status: "low-confidence",
462
467
  quad: S,
@@ -477,7 +482,7 @@ async function R(n, r) {
477
482
  ...b
478
483
  };
479
484
  }
480
- function _e(e, t) {
485
+ function ye(e, t) {
481
486
  let n = Math.max(1, Math.round(Math.max(F(e.topLeft, e.topRight), F(e.bottomLeft, e.bottomRight)))), r = Math.max(1, Math.round(Math.max(F(e.topLeft, e.bottomLeft), F(e.topRight, e.bottomRight)))), i = Math.min(1, t / Math.max(n, r));
482
487
  return {
483
488
  width: Math.max(1, Math.round(n * i)),
@@ -485,7 +490,7 @@ function _e(e, t) {
485
490
  };
486
491
  }
487
492
  function z(e, n, r) {
488
- let { width: i, height: a } = _e(n, r), o = e.getContext("2d", { willReadFrequently: !0 });
493
+ let { width: i, height: a } = ye(n, r), o = e.getContext("2d", { willReadFrequently: !0 });
489
494
  if (!o) throw t();
490
495
  let s = o.getImageData(0, 0, e.width, e.height), c = document.createElement("canvas");
491
496
  c.width = i, c.height = a;
@@ -504,7 +509,7 @@ function z(e, n, r) {
504
509
  async function B(e, t = {}) {
505
510
  return await x("scan"), R(await j(e, { cloneCanvas: !1 }), t);
506
511
  }
507
- async function ve(e, t, n = {}) {
512
+ async function be(e, t, n = {}) {
508
513
  await x("scan");
509
514
  let r = await j(e, { cloneCanvas: !1 }), i = n.maxOutputDimension ?? (L() ? 2048 : 4096);
510
515
  return {
@@ -518,7 +523,7 @@ async function ve(e, t, n = {}) {
518
523
  canvas: z(r, t, i)
519
524
  };
520
525
  }
521
- async function ye(e, t = {}) {
526
+ async function xe(e, t = {}) {
522
527
  await x("scan");
523
528
  let n = await j(e, { cloneCanvas: !1 }), r = await R(n, t);
524
529
  if (r.status !== "success" || !r.corners) return r;
@@ -546,7 +551,7 @@ function V(e, t) {
546
551
  ` torch: ${t.torch.mode} supported=${t.torch.supported} on=${t.torch.on}`
547
552
  ].join("\n");
548
553
  }
549
- function be(e) {
554
+ function Se(e) {
550
555
  let t = ["Exige scanner capture report", `time: ${e.capturedAt ?? (/* @__PURE__ */ new Date()).toISOString()}`];
551
556
  if (e.error && t.push(`error: ${e.error}`), e.captureMethod && t.push(`method: ${e.captureMethod}`), e.luminance !== void 0 && t.push(`luminance: ${e.luminance.toFixed(1)}`), e.fallbackReason && t.push(`fallback: ${e.fallbackReason}`), e.shutter && t.push(V("shutter", e.shutter)), e.live && t.push(V("live", e.live)), e.finder) {
552
557
  let n = e.finder;
@@ -570,12 +575,12 @@ function H(e = typeof navigator > "u" ? "" : navigator.userAgent, t = typeof nav
570
575
  userAgent: e
571
576
  };
572
577
  }
573
- var xe = 1920, Se = 1280;
578
+ var Ce = 1080, we = 1920, Te = 1920, Ee = 1280;
574
579
  function U(e) {
575
580
  let t = e ?? H();
576
581
  return !t.iosWebKit && t.browser === "chrome" && /Android/i.test(t.userAgent) && !/Edg|OPR|SamsungBrowser/i.test(t.userAgent);
577
582
  }
578
- var Ce = 10, W = class {
583
+ var De = 10, W = class {
579
584
  on = !1;
580
585
  darkCount = 0;
581
586
  brightCount = 0;
@@ -629,7 +634,7 @@ function K(e) {
629
634
  for (let r = 0; r < t * 4; r += 4) n += e[r] * .299 + e[r + 1] * .587 + e[r + 2] * .114;
630
635
  return n / t;
631
636
  }
632
- function we(e, t = 10) {
637
+ function Oe(e, t = 10) {
633
638
  if (e.length < 4) return !0;
634
639
  let n = Math.floor(e.length / 4), r = 0;
635
640
  for (let i = 0; i < n * 4; i += 4) e[i] * .299 + e[i + 1] * .587 + e[i + 2] * .114 > t * 2 && (r += 1);
@@ -642,10 +647,10 @@ function q(e, t, n) {
642
647
  let i = r.getContext("2d", { willReadFrequently: !0 });
643
648
  return i ? (i.drawImage(e, 0, 0, r.width, r.height), K(i.getImageData(0, 0, r.width, r.height).data)) : 0;
644
649
  }
645
- function Te(e) {
650
+ function ke(e) {
646
651
  return q(e, e.width, e.height);
647
652
  }
648
- function Ee(e, t = 120) {
653
+ function Ae(e, t = 120) {
649
654
  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 = () => {
650
655
  a && (o = i ? e.requestVideoFrameCallback(f) : requestAnimationFrame(f));
651
656
  };
@@ -664,24 +669,18 @@ function Ee(e, t = 120) {
664
669
  getMirrorAgeMs: () => c ? performance.now() - c : Infinity
665
670
  };
666
671
  }
667
- function De(e) {
672
+ function je(e) {
668
673
  let t = document.createElement("canvas");
669
674
  return t.width = e.width, t.height = e.height, t.getContext("2d")?.drawImage(e, 0, 0), t;
670
675
  }
671
- function Oe(e = {}, t = H()) {
672
- if (e.maxHeight) return e.maxHeight;
673
- if (U(t)) return xe;
674
- }
675
676
  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), {
677
+ let n = U(t), r = e.idealWidth ?? (n ? 1080 : 3840), i = e.idealHeight ?? (n ? 1920 : 2160), a = { ideal: r }, o = { ideal: i };
678
+ return e.maxWidth && (a.max = e.maxWidth), e.maxHeight ? o.max = e.maxHeight : n && e.maxWidth === void 0 && (o.max = Te), {
680
679
  audio: !1,
681
680
  video: {
682
681
  facingMode: { ideal: e.facingMode ?? "environment" },
683
- width: n,
684
- height: r,
682
+ width: a,
683
+ height: o,
685
684
  frameRate: {
686
685
  ideal: e.maxFrameRate ?? 30,
687
686
  max: e.maxFrameRate ?? 30
@@ -689,17 +688,40 @@ function J(e = {}, t = H()) {
689
688
  }
690
689
  };
691
690
  }
691
+ function Me(e, t, n) {
692
+ let r = n ? Math.min(1, n / Math.max(e, t)) : 1;
693
+ return {
694
+ width: Math.max(1, Math.round(e * r)),
695
+ height: Math.max(1, Math.round(t * r))
696
+ };
697
+ }
692
698
  function Y(e, n) {
693
699
  if (!e.videoWidth || !e.videoHeight) throw Error("The camera is not ready to capture a frame.");
694
- let r = n ? Math.min(1, n / Math.max(e.videoWidth, e.videoHeight)) : 1, i = document.createElement("canvas");
695
- i.width = Math.max(1, Math.round(e.videoWidth * r)), i.height = Math.max(1, Math.round(e.videoHeight * r));
700
+ let r = Me(e.videoWidth, e.videoHeight, n), i = document.createElement("canvas");
701
+ i.width = r.width, i.height = r.height;
696
702
  let a = i.getContext("2d");
697
703
  if (!a) throw t();
698
704
  return a.drawImage(e, 0, 0, i.width, i.height), i;
699
705
  }
700
- function ke(e) {
706
+ function Ne(e) {
701
707
  let t = H();
702
- return e.idealWidth || e.idealHeight || e.maxWidth || e.maxHeight ? [J(e, t)] : [
708
+ return e.idealWidth || e.idealHeight || e.maxWidth || e.maxHeight ? [J(e, t)] : U(t) ? [
709
+ J({
710
+ ...e,
711
+ idealWidth: Ce,
712
+ idealHeight: we
713
+ }, t),
714
+ J({
715
+ ...e,
716
+ idealWidth: 720,
717
+ idealHeight: 1280
718
+ }, t),
719
+ J({
720
+ ...e,
721
+ idealWidth: 1920,
722
+ idealHeight: 1080
723
+ }, t)
724
+ ] : [
703
725
  J({
704
726
  ...e,
705
727
  idealWidth: 3840,
@@ -717,14 +739,14 @@ function ke(e) {
717
739
  }, t)
718
740
  ];
719
741
  }
720
- async function Ae(t, n = {}) {
742
+ async function Pe(t, n = {}) {
721
743
  await x("scan");
722
744
  let r = n.torch ?? "alwaysOff";
723
745
  if (r !== "alwaysOff" && await x("torch"), !window.isSecureContext && location.hostname !== "localhost") throw new e("secure-context", "Camera access requires HTTPS.");
724
746
  if (!navigator.mediaDevices?.getUserMedia) throw Error("Live camera access is unavailable. Use the native camera picker instead.");
725
747
  t.muted = !0, t.autoplay = !0, t.playsInline = !0, t.setAttribute("playsinline", "");
726
748
  let i, a;
727
- for (let e of ke(n)) try {
749
+ for (let e of Ne(n)) try {
728
750
  i = await navigator.mediaDevices.getUserMedia(e);
729
751
  break;
730
752
  } catch (e) {
@@ -737,7 +759,7 @@ async function Ae(t, n = {}) {
737
759
  for (let e of i.getTracks()) e.stop();
738
760
  throw Error("The camera did not provide a video track.");
739
761
  }
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) => {
762
+ let s = Ae(t), c = "ImageCapture" in globalThis, l = G(r, (typeof o.getCapabilities == "function" ? o.getCapabilities() : void 0)?.torch === !0), u = !1, d = async (e) => {
741
763
  if (!l.supported || o.readyState !== "live") return !1;
742
764
  try {
743
765
  return await o.applyConstraints({ advanced: [{ torch: e }] }), l = {
@@ -799,11 +821,11 @@ async function Ae(t, n = {}) {
799
821
  async capturePhoto() {
800
822
  let e, n = 0;
801
823
  try {
802
- e = Y(t), n = Te(e);
824
+ e = Y(t), n = ke(e);
803
825
  } catch {
804
826
  e = void 0;
805
827
  }
806
- let r = s.getFrame(), i = e && n > 10 ? e : void 0, a = i ?? (r ? De(r) : void 0);
828
+ let r = s.getFrame(), i = e && n > 10 ? e : void 0, a = i ?? (r ? je(r) : void 0);
807
829
  if (!a) throw Error("The camera preview produced no visible pixels. Keep the scanner on screen, wait for the preview, and retake.");
808
830
  return {
809
831
  frame: a,
@@ -829,12 +851,12 @@ async function Ae(t, n = {}) {
829
851
  }
830
852
  //#endregion
831
853
  //#region src/sdk/lighting.ts
832
- function je(e, t) {
854
+ function Fe(e, t) {
833
855
  if (!e.length) return 0;
834
856
  let n = [...e].sort((e, t) => e - t);
835
857
  return n[Math.min(n.length - 1, Math.floor(n.length * t))];
836
858
  }
837
- function X(e, t, n, r = 12) {
859
+ function Ie(e, t, n, r = 12) {
838
860
  if (!t || !n || e.length < t * n) return {
839
861
  strong: !1,
840
862
  strength: 0,
@@ -857,7 +879,7 @@ function X(e, t, n, r = 12) {
857
879
  });
858
880
  }
859
881
  }
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 = [];
882
+ let s = Fe(o.map((e) => e.mean), .8), c = o.map((e) => s - e.mean >= 24 && e.mean >= 35), l = new Uint8Array(o.length), u = [];
861
883
  for (let e = 0; e < o.length; e += 1) {
862
884
  if (!c[e] || l[e]) continue;
863
885
  let t = [], n = [e];
@@ -905,7 +927,7 @@ function X(e, t, n, r = 12) {
905
927
  }
906
928
  return d;
907
929
  }
908
- function Me(e, t, n, r = Math.max(12, Math.round(Math.max(t, n) / 32))) {
930
+ function Le(e, t, n, r = Math.max(12, Math.round(Math.max(t, n) / 32))) {
909
931
  let i = t + 1, a = new Uint32Array((t + 1) * (n + 1));
910
932
  for (let r = 1; r <= n; r += 1) {
911
933
  let n = 0;
@@ -921,7 +943,7 @@ function Me(e, t, n, r = Math.max(12, Math.round(Math.max(t, n) / 32))) {
921
943
  }
922
944
  return o;
923
945
  }
924
- function Ne(e, t, n) {
946
+ function Re(e, t, n) {
925
947
  let r = [
926
948
  e.topLeft,
927
949
  e.topRight,
@@ -935,8 +957,8 @@ function Ne(e, t, n) {
935
957
  height: s - a
936
958
  };
937
959
  }
938
- function Pe(e, t) {
939
- let n = Ne(t, e.width, e.height);
960
+ function ze(e, t) {
961
+ let n = Re(t, e.width, e.height);
940
962
  if (n.width <= 0 || n.height <= 0) return {
941
963
  strong: !1,
942
964
  strength: 0,
@@ -955,18 +977,18 @@ function Pe(e, t) {
955
977
  i.drawImage(e, n.left, n.top, n.width, n.height, 0, 0, r.width, r.height);
956
978
  let a = i.getImageData(0, 0, r.width, r.height).data, o = new Uint8Array(r.width * r.height);
957
979
  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);
958
- return X(o, r.width, r.height);
980
+ return Ie(o, r.width, r.height);
959
981
  }
960
982
  //#endregion
961
983
  //#region src/sdk/finder.ts
962
- function Fe(e, t) {
984
+ function Be(e, t) {
963
985
  return t.castShadow && (e.reason === "hold-still" || e.reason === "ready") ? t.hint ?? e.hint : e.hint;
964
986
  }
965
- async function Ie(e, t) {
987
+ async function Ve(e, t) {
966
988
  let n = await e();
967
989
  return t(), n;
968
990
  }
969
- function Le(e) {
991
+ function He(e) {
970
992
  return e === "alwaysOn" || e === "only" ? {
971
993
  visible: !1,
972
994
  checked: !0,
@@ -981,7 +1003,7 @@ function Le(e) {
981
1003
  mutable: !0
982
1004
  };
983
1005
  }
984
- function Z(e) {
1006
+ function X(e) {
985
1007
  return [
986
1008
  e.topLeft,
987
1009
  e.topRight,
@@ -989,11 +1011,11 @@ function Z(e) {
989
1011
  e.bottomLeft
990
1012
  ];
991
1013
  }
992
- var Re = 1600;
993
- function ze(e = H()) {
994
- return U(e) ? Se : Re;
1014
+ var Ue = 1600;
1015
+ function We(e = H()) {
1016
+ return U(e) ? Ee : Ue;
995
1017
  }
996
- function Be(e) {
1018
+ function Ge(e) {
997
1019
  let t = 0;
998
1020
  for (let n = 0; n < e.length; n += 1) {
999
1021
  let r = e[n], i = e[(n + 1) % e.length];
@@ -1001,42 +1023,42 @@ function Be(e) {
1001
1023
  }
1002
1024
  return Math.abs(t) / 2;
1003
1025
  }
1004
- function Q(e, t) {
1026
+ function Z(e, t) {
1005
1027
  return Math.hypot(e.x - t.x, e.y - t.y);
1006
1028
  }
1007
- var $ = {
1029
+ var Q = {
1008
1030
  widthFill: 0,
1009
1031
  heightFill: 0,
1010
1032
  limitingFill: 0,
1011
1033
  areaFill: 0,
1012
1034
  aspectRatio: 1
1013
1035
  };
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));
1036
+ function Ke(e, t, n) {
1037
+ let r = X(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(Z(c, l), Z(d, u)), p = Math.max(Z(c, d), Z(l, u));
1016
1038
  return {
1017
1039
  widthFill: o,
1018
1040
  heightFill: s,
1019
1041
  limitingFill: Math.max(o, s),
1020
- areaFill: Be(r) / Math.max(1, t * n),
1042
+ areaFill: Ge(r) / Math.max(1, t * n),
1021
1043
  aspectRatio: Math.max(f, p) / Math.max(1, Math.min(f, p))
1022
1044
  };
1023
1045
  }
1024
- function He(e, t, n, r = {}) {
1046
+ function qe(e, t, n, r = {}) {
1025
1047
  let i = t ? r.exitFillRatio ?? .64 : r.minFillRatio ?? .72, a = r.highAspectRatio ?? 2.2;
1026
1048
  if (e.aspectRatio < a) return i;
1027
1049
  let o = t ? r.highAspectExitFillRatio : r.highAspectFillRatio;
1028
1050
  return Math.min(o ?? i + .08, 1 - n * 2);
1029
1051
  }
1030
- function Ue(e, t, n = {}) {
1052
+ function Je(e, t, n = {}) {
1031
1053
  let r = n.confidenceThreshold ?? .72;
1032
1054
  if (e.status !== "success" || !e.quad || e.confidence < r || !e.sourceWidth || !e.sourceHeight) return {
1033
1055
  hint: "Place the document in the frame",
1034
1056
  reason: "place-document",
1035
1057
  fillRatio: 0,
1036
- fill: $,
1058
+ fill: Q,
1037
1059
  readyForAutoCapture: !1
1038
1060
  };
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;
1061
+ let i = X(e.quad), a = Ke(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;
1040
1062
  if (i.some(({ x: t, y: n }) => t <= c || t >= e.sourceWidth - c || n <= l || n >= e.sourceHeight - l)) return {
1041
1063
  hint: "Move farther away",
1042
1064
  reason: "move-farther-away",
@@ -1044,14 +1066,14 @@ function Ue(e, t, n = {}) {
1044
1066
  fill: a,
1045
1067
  readyForAutoCapture: !1
1046
1068
  };
1047
- let [u, d, f, p] = i, m = Q(u, d), h = Q(d, f), g = Q(f, p), _ = Q(p, u);
1069
+ let [u, d, f, p] = i, m = Z(u, d), h = Z(d, f), g = Z(f, p), _ = Z(p, u);
1048
1070
  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) ? {
1049
1071
  hint: "Hold the camera straight",
1050
1072
  reason: "straighten-camera",
1051
1073
  fillRatio: o,
1052
1074
  fill: a,
1053
1075
  readyForAutoCapture: !1
1054
- } : o < He(a, t.previouslyReady === !0, s, n) ? {
1076
+ } : o < qe(a, t.previouslyReady === !0, s, n) ? {
1055
1077
  hint: "Move closer",
1056
1078
  reason: "move-closer",
1057
1079
  fillRatio: o,
@@ -1065,7 +1087,7 @@ function Ue(e, t, n = {}) {
1065
1087
  readyForAutoCapture: t.ready
1066
1088
  };
1067
1089
  }
1068
- var We = class {
1090
+ var $ = class {
1069
1091
  previous;
1070
1092
  count = 0;
1071
1093
  ready = !1;
@@ -1082,8 +1104,8 @@ var We = class {
1082
1104
  ready: !1,
1083
1105
  movement: Infinity
1084
1106
  };
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];
1107
+ let t = Math.hypot(e.sourceWidth, e.sourceHeight), n = this.previous ? Math.max(...X(e.quad).map((e, n) => {
1108
+ let r = X(this.previous)[n];
1087
1109
  return Math.hypot(e.x - r.x, e.y - r.y) / Math.max(1, t);
1088
1110
  })) : Infinity, r = this.options.exitCornerTolerance ?? Math.max(this.options.cornerTolerance, .036);
1089
1111
  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, {
@@ -1093,14 +1115,14 @@ var We = class {
1093
1115
  };
1094
1116
  }
1095
1117
  };
1096
- function Ge(e, n) {
1097
- let r = Math.min(1, n / Math.max(e.width, e.height)), i = document.createElement("canvas");
1098
- i.width = Math.max(1, Math.round(e.width * r)), i.height = Math.max(1, Math.round(e.height * r));
1118
+ function Ye(e, n) {
1119
+ let r = Me(e.width, e.height, n), i = document.createElement("canvas");
1120
+ i.width = r.width, i.height = r.height;
1099
1121
  let a = i.getContext("2d");
1100
1122
  if (!a) throw t();
1101
1123
  return a.drawImage(e, 0, 0, i.width, i.height), i;
1102
1124
  }
1103
- function Ke() {
1125
+ function Xe() {
1104
1126
  let e = window.AudioContext ?? window.webkitAudioContext;
1105
1127
  if (!e) return;
1106
1128
  let t = new e(), n = Math.round(t.sampleRate * .09), r = t.createBuffer(1, n, t.sampleRate), i = r.getChannelData(0);
@@ -1111,29 +1133,29 @@ function Ke() {
1111
1133
  let a = t.createBufferSource(), o = t.createBiquadFilter(), s = t.createGain();
1112
1134
  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();
1113
1135
  }
1114
- async function qe(e) {
1136
+ async function Ze(e) {
1115
1137
  let t = document.createElement("video");
1116
1138
  return t.muted = !0, t.autoplay = !0, t.playsInline = !0, t.srcObject = e, await t.play(), t;
1117
1139
  }
1118
- async function Je(t) {
1140
+ async function Qe(t) {
1119
1141
  await x("scan");
1120
- let n = Le(t.autoCapture), r = new We({
1142
+ let n = He(t.autoCapture), r = new $({
1121
1143
  stableFrames: t.stableFrames ?? 4,
1122
1144
  confidenceThreshold: t.confidenceThreshold ?? .72,
1123
1145
  cornerTolerance: t.cornerTolerance ?? .024,
1124
1146
  exitCornerTolerance: t.exitCornerTolerance ?? .036
1125
- }), i = t.maxFrameDimension ?? ze(), a = t.intervalMs ?? 140, o = {
1147
+ }), i = t.maxFrameDimension ?? We(), a = t.intervalMs ?? 140, o = {
1126
1148
  minDimension: 220,
1127
- maxAnalysisDimension: 520,
1149
+ maxAnalysisDimension: i,
1128
1150
  ...t.detection
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 = {
1151
+ }, s = typeof MediaStream < "u" && t.source instanceof MediaStream ? await Ze(t.source) : t.source, c = !0, l = !1, u = !1, d = 0, f, p = {
1130
1152
  state: "detecting",
1131
1153
  confidence: 0,
1132
1154
  guidance: {
1133
1155
  hint: "Place the document in the frame",
1134
1156
  reason: "place-document",
1135
1157
  fillRatio: 0,
1136
- fill: $,
1158
+ fill: Q,
1137
1159
  readyForAutoCapture: !1
1138
1160
  },
1139
1161
  lighting: {
@@ -1143,7 +1165,7 @@ async function Je(t) {
1143
1165
  stableFrames: 0,
1144
1166
  requiredStableFrames: t.stableFrames ?? 4,
1145
1167
  autoCapture: { ...n }
1146
- }, m = () => s instanceof HTMLCanvasElement ? Ge(s, i) : Y(s, i), h = (e) => {
1168
+ }, m = () => s instanceof HTMLCanvasElement ? Ye(s, i) : Y(s, i), h = (e) => {
1147
1169
  p = e, t.onStatus?.(e);
1148
1170
  }, g = () => {
1149
1171
  c = !1, window.clearTimeout(d), s instanceof HTMLVideoElement && s !== t.source && (s.srcObject = null);
@@ -1152,11 +1174,11 @@ async function Je(t) {
1152
1174
  l = !0;
1153
1175
  let n;
1154
1176
  try {
1155
- n = await Ie(t.captureFrame ?? m, () => {
1177
+ n = await Ve(t.captureFrame ?? m, () => {
1156
1178
  h({
1157
1179
  ...p,
1158
1180
  state: "captured"
1159
- }), t.playShutterSound !== !1 && Ke(), g();
1181
+ }), t.playShutterSound !== !1 && Xe(), g();
1160
1182
  });
1161
1183
  } catch (e) {
1162
1184
  throw l = !1, e instanceof Error ? e : /* @__PURE__ */ Error("The camera frame could not be captured.");
@@ -1172,7 +1194,7 @@ async function Je(t) {
1172
1194
  try {
1173
1195
  let e = m(), i = await B(e, o);
1174
1196
  f = i;
1175
- let a = i.quad ? Pe(e, i.quad) : {
1197
+ let a = i.quad ? ze(e, i.quad) : {
1176
1198
  strong: !1,
1177
1199
  strength: 0
1178
1200
  }, s = a.strong ? {
@@ -1182,7 +1204,7 @@ async function Je(t) {
1182
1204
  } : {
1183
1205
  castShadow: !1,
1184
1206
  strength: a.strength
1185
- }, c = r.update(i), l = Ue(i, {
1207
+ }, c = r.update(i), l = Je(i, {
1186
1208
  ...c,
1187
1209
  previouslyReady: u
1188
1210
  }, {
@@ -1227,7 +1249,7 @@ async function Je(t) {
1227
1249
  hint: "Place the document in the frame",
1228
1250
  reason: "place-document",
1229
1251
  fillRatio: 0,
1230
- fill: $,
1252
+ fill: Q,
1231
1253
  readyForAutoCapture: !1
1232
1254
  },
1233
1255
  lighting: {
@@ -1256,6 +1278,6 @@ async function Je(t) {
1256
1278
  };
1257
1279
  }
1258
1280
  //#endregion
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 };
1281
+ 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, ie as O, y as P, B as S, ue as T, J as _, Je as a, fe as b, Ie as c, De as d, Y as f, K as g, Oe as h, Ke as i, o as j, ne as k, Le as l, Se as m, He as n, Be as o, H as p, qe as r, Qe as s, $ as t, W as u, Pe as v, xe as w, be as x, G as y };
1260
1282
 
1261
- //# sourceMappingURL=finder-CLEe-Zhj.js.map
1283
+ //# sourceMappingURL=finder-Bjo3TAHi.js.map