@exige/web-scanner-sdk 0.2.27 → 0.2.28

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 te() {
187
+ function O() {
188
188
  if (w.size === 0) return {
189
189
  downloading: !1,
190
190
  loaded: 0,
@@ -198,12 +198,12 @@ function te() {
198
198
  total: n ? t : null
199
199
  };
200
200
  }
201
- function O() {
202
- let e = te();
201
+ function te() {
202
+ let e = O();
203
203
  for (let t of T) t(e);
204
204
  }
205
205
  function ne(e) {
206
- return e(te()), T.add(e), () => {
206
+ return e(O()), T.add(e), () => {
207
207
  T.delete(e);
208
208
  };
209
209
  }
@@ -211,7 +211,7 @@ 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
- }), O();
214
+ }), te();
215
215
  }
216
216
  async function re(e, t) {
217
217
  let n = ee(e);
@@ -257,309 +257,12 @@ async function ie(t, n) {
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), O());
261
- }
262
- }
263
- //#endregion
264
- //#region src/sdk/ort-runtime.ts
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 se() {
267
- return {
268
- wasm: ae.href,
269
- mjs: oe.href
270
- };
271
- }
272
- function ce(e) {
273
- return typeof e == "string" ? e.trim() || se() : e?.wasm.trim() && e.mjs.trim() ? {
274
- wasm: e.wasm.trim(),
275
- mjs: e.mjs.trim()
276
- } : se();
277
- }
278
- //#endregion
279
- //#region src/sdk/image.ts
280
- function le(e, t, n) {
281
- let r = n ? Math.min(1, n / Math.max(e, t)) : 1;
282
- return {
283
- width: Math.max(1, Math.round(e * r)),
284
- height: Math.max(1, Math.round(t * r))
285
- };
286
- }
287
- async function ue(e) {
288
- let t = URL.createObjectURL(e);
289
- try {
290
- let e = new Image();
291
- return e.src = t, await e.decode(), e;
292
- } finally {
293
- URL.revokeObjectURL(t);
294
- }
295
- }
296
- async function A(e, n = {}) {
297
- if (e instanceof HTMLCanvasElement && n.cloneCanvas === !1 && !n.maxDimension) return e;
298
- let r = document.createElement("canvas"), i = r.getContext("2d", { willReadFrequently: !0 });
299
- if (!i) throw t();
300
- if (e instanceof Blob) {
301
- if ("createImageBitmap" in window) try {
302
- let t = await createImageBitmap(e), a = le(t.width, t.height, n.maxDimension);
303
- return r.width = a.width, r.height = a.height, i.drawImage(t, 0, 0, a.width, a.height), t.close(), r;
304
- } catch {}
305
- e = await ue(e);
306
- }
307
- let a = e instanceof HTMLImageElement ? e.naturalWidth : e.width, o = e instanceof HTMLImageElement ? e.naturalHeight : e.height;
308
- if (!a || !o) throw Error("The image has no readable dimensions.");
309
- let s = le(a, o, n.maxDimension);
310
- return r.width = s.width, r.height = s.height, i.drawImage(e, 0, 0, s.width, s.height), r;
311
- }
312
- function de(e, t = "image/png", n = .92) {
313
- return new Promise((r, i) => e.toBlob((e) => e ? r(e) : i(/* @__PURE__ */ Error("Could not encode the image.")), t, n));
314
- }
315
- function fe(e, t, n) {
316
- let r = Math.max(0, Math.min(t, e.x)), i = Math.max(0, Math.min(n, e.y));
317
- return {
318
- x: r,
319
- y: i,
320
- width: Math.max(0, Math.min(t - r, e.width)),
321
- height: Math.max(0, Math.min(n - i, e.height))
322
- };
323
- }
324
- //#endregion
325
- //#region src/sdk/scan.ts
326
- var pe = "https://exige-scanner-sdk.vercel.app/models/docaligner-lcnet100-f4117b78.onnx", me = 1280;
327
- function he(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 = ye() ? 560 : 900;
330
- return i >= 1.6 ? Math.min(r, Math.max(a, me)) : a;
331
- }
332
- function j(e) {
333
- return e?.trim() || "https://exige-scanner-sdk.vercel.app/models/docaligner-lcnet100-f4117b78.onnx";
334
- }
335
- var ge = 3, M, _e = 0, N = /* @__PURE__ */ new Map();
336
- function P(e, t) {
337
- return Math.hypot(e.x - t.x, e.y - t.y);
338
- }
339
- function F(e) {
340
- return {
341
- ...e,
342
- edges: {
343
- top: {
344
- start: e.topLeft,
345
- end: e.topRight
346
- },
347
- right: {
348
- start: e.topRight,
349
- end: e.bottomRight
350
- },
351
- bottom: {
352
- start: e.bottomRight,
353
- end: e.bottomLeft
354
- },
355
- left: {
356
- start: e.bottomLeft,
357
- end: e.topLeft
358
- }
359
- }
360
- };
361
- }
362
- function ve(e, t) {
363
- let n = (e) => ({
364
- x: e.x / t,
365
- y: e.y / t
366
- });
367
- return {
368
- topLeft: n(e.topLeft),
369
- topRight: n(e.topRight),
370
- bottomRight: n(e.bottomRight),
371
- bottomLeft: n(e.bottomLeft)
372
- };
373
- }
374
- function ye() {
375
- return typeof navigator > "u" ? !1 : navigator.maxTouchPoints > 0 || navigator.hardwareConcurrency <= 4 || typeof matchMedia == "function" && matchMedia("(pointer: coarse)").matches;
376
- }
377
- function be(t, n, r, i) {
378
- return new Promise((a, o) => {
379
- M || (M = new Worker(new URL("./assets/document-worker.js", import.meta.url), { type: "module" }), M.onmessage = (t) => {
380
- if (t.data.download?.url) {
381
- k(t.data.download.url, t.data.download);
382
- return;
383
- }
384
- let n = N.get(t.data.id);
385
- n && (N.delete(t.data.id), t.data.error ? n.reject(t.data.errorCode ? new e(t.data.errorCode, t.data.error) : Error(t.data.error)) : t.data.result ? n.resolve(t.data.result) : n.reject(/* @__PURE__ */ Error("The document worker returned no result.")));
386
- }, M.onerror = () => {
387
- let t = new e("worker", "The document worker could not start.");
388
- for (let e of N.values()) e.reject(t);
389
- N.clear(), M?.terminate(), M = void 0;
390
- });
391
- let s = ++_e;
392
- N.set(s, {
393
- resolve: a,
394
- reject: o
395
- });
396
- let c = t.slice().buffer;
397
- M.postMessage({
398
- id: s,
399
- pixels: c,
400
- width: n,
401
- height: r,
402
- modelUrl: j(i.modelUrl),
403
- heatmapThreshold: i.heatmapThreshold,
404
- cacheModel: i.cacheModel,
405
- ortWasmPaths: ce(i.ortWasmPaths)
406
- }, [c]);
407
- });
408
- }
409
- async function I(n, r) {
410
- let { width: i, height: a } = n, o = r.minDimension ?? 360;
411
- if (Math.min(i, a) < o) return {
412
- status: "low-quality",
413
- confidence: 0,
414
- message: `Use an image at least ${o}px on its shortest side.`,
415
- sourceWidth: i,
416
- sourceHeight: a
417
- };
418
- let s = he(i, a, r.maxAnalysisDimension), c = Math.min(1, s / Math.max(i, a)), l = document.createElement("canvas");
419
- l.width = Math.max(1, Math.round(i * c)), l.height = Math.max(1, Math.round(a * c));
420
- let u = l.getContext("2d", { willReadFrequently: !0 });
421
- if (!u) throw t();
422
- u.drawImage(n, 0, 0, l.width, l.height);
423
- let d = u.getImageData(0, 0, l.width, l.height).data, f;
424
- if (r.useWorker !== !1 && typeof Worker < "u") try {
425
- f = await be(d, l.width, l.height, r);
426
- } catch (t) {
427
- if (t instanceof e && (t.code === "worker" || t.code === "model-http")) throw t;
428
- f = {
429
- sharpness: 20,
430
- detector: "ml",
431
- modelStatus: "failed",
432
- modelError: t instanceof Error ? t.message : "Document worker failed."
433
- };
434
- }
435
- else f = {
436
- sharpness: 20,
437
- detector: "ml",
438
- modelStatus: "failed",
439
- modelError: "ML detection requires a Web Worker."
440
- };
441
- let { sharpness: p, candidate: m, detector: h, modelStatus: g, modelProvider: _, modelError: v, modelNote: y, inferenceMs: b } = f, x = {
442
- detector: h,
443
- modelStatus: g,
444
- modelProvider: _,
445
- modelError: v,
446
- modelNote: y,
447
- inferenceMs: b
448
- };
449
- if (p < ge) return {
450
- status: "low-quality",
451
- confidence: Math.min(.3, p / 18),
452
- message: "The image is too soft or dark to resolve four document edges.",
453
- sourceWidth: i,
454
- sourceHeight: a,
455
- ...x
456
- };
457
- if (!m) return {
458
- status: "no-document",
459
- confidence: 0,
460
- message: "No document corners found. Place all four edges on a contrasting surface.",
461
- sourceWidth: i,
462
- sourceHeight: a,
463
- ...x
464
- };
465
- let S = ve(m.corners, c), C = F(S), w = r.minConfidence ?? .58;
466
- return m.confidence < w ? {
467
- status: "low-confidence",
468
- quad: C,
469
- corners: S,
470
- confidence: m.confidence,
471
- message: "Four possible corners were found, but the geometry is not reliable enough to crop.",
472
- sourceWidth: i,
473
- sourceHeight: a,
474
- ...x
475
- } : {
476
- status: "success",
477
- quad: C,
478
- corners: S,
479
- confidence: m.confidence,
480
- message: "Four document edges detected.",
481
- sourceWidth: i,
482
- sourceHeight: a,
483
- ...x
484
- };
485
- }
486
- function xe(e, t) {
487
- let n = Math.max(1, Math.round(Math.max(P(e.topLeft, e.topRight), P(e.bottomLeft, e.bottomRight)))), r = Math.max(1, Math.round(Math.max(P(e.topLeft, e.bottomLeft), P(e.topRight, e.bottomRight)))), i = Math.min(1, t / Math.max(n, r));
488
- return {
489
- width: Math.max(1, Math.round(n * i)),
490
- height: Math.max(1, Math.round(r * i))
491
- };
492
- }
493
- function Se(e, t, n, r, i) {
494
- let a = Math.max(0, Math.min(t - 1, r)), o = Math.max(0, Math.min(n - 1, i)), s = Math.floor(a), c = Math.floor(o), l = Math.min(t - 1, s + 1), u = Math.min(n - 1, c + 1), d = a - s, f = o - c, p = c * t, m = u * t, h = (t) => {
495
- let n = e[(p + s) * 4 + t] * (1 - d) + e[(p + l) * 4 + t] * d, r = e[(m + s) * 4 + t] * (1 - d) + e[(m + l) * 4 + t] * d;
496
- return Math.round(n * (1 - f) + r * f);
497
- };
498
- return [
499
- h(0),
500
- h(1),
501
- h(2),
502
- 255
503
- ];
504
- }
505
- function L(e, n, r) {
506
- let { width: i, height: a } = xe(n, r), o = e.getContext("2d", { willReadFrequently: !0 });
507
- if (!o) throw t();
508
- let s = o.getImageData(0, 0, e.width, e.height), c = document.createElement("canvas");
509
- c.width = i, c.height = a;
510
- let l = c.getContext("2d");
511
- if (!l) throw t();
512
- let u = l.createImageData(i, a), { topLeft: d, topRight: f, bottomRight: p, bottomLeft: m } = n, h = f.x - p.x, g = m.x - p.x, _ = f.y - p.y, v = m.y - p.y, y = d.x - f.x + p.x - m.x, b = d.y - f.y + p.y - m.y, x = h * v - g * _, S = Math.abs(x) < 1e-4 ? 0 : (y * v - g * b) / x, C = Math.abs(x) < 1e-4 ? 0 : (h * b - y * _) / x, w = f.x - d.x + S * f.x, T = m.x - d.x + C * m.x, E = f.y - d.y + S * f.y, D = m.y - d.y + C * m.y;
513
- for (let t = 0; t < a; t += 1) {
514
- let n = t / Math.max(1, a - 1);
515
- for (let r = 0; r < i; r += 1) {
516
- let a = r / Math.max(1, i - 1), o = S * a + C * n + 1, c = (w * a + T * n + d.x) / o, l = (E * a + D * n + d.y) / o, [f, p, m, h] = Se(s.data, e.width, e.height, c, l), g = (t * i + r) * 4;
517
- u.data[g] = f, u.data[g + 1] = p, u.data[g + 2] = m, u.data[g + 3] = h;
518
- }
260
+ D.delete(t), w.has(t) && (w.delete(t), te());
519
261
  }
520
- return l.putImageData(u, 0, 0), c;
521
- }
522
- async function R(e, t = {}) {
523
- return await x("scan"), I(await A(e, { cloneCanvas: !1 }), t);
524
- }
525
- async function Ce(e, t, n = {}) {
526
- await x("scan");
527
- let r = await A(e, { cloneCanvas: !1 }), i = n.maxOutputDimension ?? 4096;
528
- return {
529
- status: "success",
530
- corners: t,
531
- quad: F(t),
532
- confidence: 1,
533
- message: "Captured with the document edges shown in the finder.",
534
- sourceWidth: r.width,
535
- sourceHeight: r.height,
536
- canvas: L(r, t, i)
537
- };
538
- }
539
- async function z(e, t = {}) {
540
- await x("scan");
541
- let n = await A(e, { cloneCanvas: !1 }), r = await I(n, t);
542
- if (r.status !== "success" || !r.corners) return r;
543
- let i = t.maxOutputDimension ?? 4096;
544
- return {
545
- ...r,
546
- canvas: L(n, r.corners, i),
547
- message: "Four document edges detected and perspective-corrected."
548
- };
549
- }
550
- function B(e) {
551
- return e.status === "success" ? e.message : e.status === "low-quality" ? e.message.includes("shortest side") ? `${e.message} Take another photo.` : "That photo is too soft or dark to find a document. Take another photo in better light." : e.status === "low-confidence" ? "The page edges were not clear enough to crop. Take another photo with the whole page in frame." : `No document was found in that photo. Take another photo with the whole page in frame.${e.modelStatus === "failed" && e.modelError ? ` (${e.modelError})` : ""}`;
552
- }
553
- async function we(e, t = {}) {
554
- let n = await z(e, t);
555
- return n.status === "success" ? n : {
556
- ...n,
557
- message: B(n)
558
- };
559
262
  }
560
263
  //#endregion
561
264
  //#region src/sdk/camera.ts
562
- function V(e, t) {
265
+ function ae(e, t) {
563
266
  let { engine: n } = t;
564
267
  return [
565
268
  `${e}:`,
@@ -574,9 +277,9 @@ function V(e, t) {
574
277
  ` torch: ${t.torch.mode} supported=${t.torch.supported} on=${t.torch.on}`
575
278
  ].join("\n");
576
279
  }
577
- function Te(e) {
280
+ function oe(e) {
578
281
  let t = ["Exige scanner capture report", `time: ${e.capturedAt ?? (/* @__PURE__ */ new Date()).toISOString()}`];
579
- 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) {
282
+ 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(ae("shutter", e.shutter)), e.live && t.push(ae("live", e.live)), e.finder) {
580
283
  let n = e.finder;
581
284
  t.push([
582
285
  "finder:",
@@ -593,7 +296,7 @@ function Te(e) {
593
296
  }
594
297
  return `${t.join("\n")}\n`;
595
298
  }
596
- function H(e = typeof navigator > "u" ? "" : navigator.userAgent, t = typeof navigator > "u" ? 0 : navigator.maxTouchPoints) {
299
+ function A(e = typeof navigator > "u" ? "" : navigator.userAgent, t = typeof navigator > "u" ? 0 : navigator.maxTouchPoints) {
597
300
  let n = /CriOS|Chrome/i.test(e) ? "chrome" : /EdgiOS|Edg/i.test(e) ? "edge" : /FxiOS|Firefox/i.test(e) ? "firefox" : /Safari/i.test(e) ? "safari" : "unknown", r = /iPhone|iPad|iPod/i.test(e) || /Macintosh/i.test(e) && t > 1, i = /CriOS|EdgiOS|FxiOS|OPiOS|Mercury/i.test(e), a = r || i;
598
301
  return {
599
302
  engine: a || /AppleWebKit/i.test(e) && !/Chrome|Chromium|Edg/i.test(e) ? "webkit" : /Chrome|Chromium|Edg/i.test(e) ? "blink" : /Gecko\//i.test(e) ? "gecko" : "unknown",
@@ -602,37 +305,40 @@ function H(e = typeof navigator > "u" ? "" : navigator.userAgent, t = typeof nav
602
305
  userAgent: e
603
306
  };
604
307
  }
605
- function U(e) {
308
+ function j(e) {
606
309
  return /Android/i.test(e.userAgent) && !e.iosWebKit;
607
310
  }
608
- function Ee(e = "auto", t = H()) {
609
- return e === "system-camera" || e !== "live" && U(t);
311
+ function M(e = A()) {
312
+ return e.engine === "webkit" && !j(e);
313
+ }
314
+ function se(e = "auto", t = A()) {
315
+ return e === "system-camera" || e !== "live" && j(t);
610
316
  }
611
- function De(e, t) {
317
+ function ce(e, t) {
612
318
  return t && !e.iosWebKit;
613
319
  }
614
- function W(e, t) {
320
+ function N(e, t) {
615
321
  if (!e || !Number.isFinite(e)) return;
616
322
  let n = t?.max;
617
323
  if (!n || !Number.isFinite(n)) return Math.round(e);
618
324
  let r = t?.min && Number.isFinite(t.min) ? t.min : 1, i = t?.step && t.step > 0 ? t.step : 1, a = r + Math.round((Math.min(n, Math.max(r, e)) - r) / i) * i;
619
325
  return Math.round(Math.min(n, Math.max(r, a)));
620
326
  }
621
- function Oe(e) {
622
- let t = W(e?.imageWidth?.max ?? 0, e?.imageWidth), n = W(e?.imageHeight?.max ?? 0, e?.imageHeight);
327
+ function le(e) {
328
+ let t = N(e?.imageWidth?.max ?? 0, e?.imageWidth), n = N(e?.imageHeight?.max ?? 0, e?.imageHeight);
623
329
  if (t && n) return t >= n ? { imageWidth: t } : { imageHeight: n };
624
330
  if (t) return { imageWidth: t };
625
331
  if (n) return { imageHeight: n };
626
332
  }
627
- function ke(e, t) {
333
+ function ue(e, t) {
628
334
  return !e.width || !e.height || !t.width || !t.height ? !1 : e.width * e.height > t.width * t.height * 1.15;
629
335
  }
630
- function Ae(e, t) {
336
+ function de(e, t) {
631
337
  if (!e.width || !e.height || !t.width || !t.height) return !1;
632
338
  let n = e.width / e.height / (t.width / t.height);
633
339
  return n > .97 && n < 1.03;
634
340
  }
635
- var je = 10, G = class {
341
+ var fe = 10, P = class {
636
342
  on = !1;
637
343
  darkCount = 0;
638
344
  brightCount = 0;
@@ -655,7 +361,7 @@ var je = 10, G = class {
655
361
  return this.on;
656
362
  }
657
363
  };
658
- function K(e, t) {
364
+ function F(e, t) {
659
365
  return t ? e === "alwaysOn" || e === "alwaysOff" ? {
660
366
  mode: e,
661
367
  supported: !0,
@@ -679,37 +385,37 @@ function K(e, t) {
679
385
  automatic: e === "auto"
680
386
  };
681
387
  }
682
- function q(e) {
388
+ function I(e) {
683
389
  let t = Math.floor(e.length / 4);
684
390
  if (!t) return 0;
685
391
  let n = 0;
686
392
  for (let r = 0; r < t * 4; r += 4) n += e[r] * .299 + e[r + 1] * .587 + e[r + 2] * .114;
687
393
  return n / t;
688
394
  }
689
- function Me(e, t = 10) {
395
+ function pe(e, t = 10) {
690
396
  if (e.length < 4) return !0;
691
397
  let n = Math.floor(e.length / 4), r = 0;
692
398
  for (let i = 0; i < n * 4; i += 4) e[i] * .299 + e[i + 1] * .587 + e[i + 2] * .114 > t * 2 && (r += 1);
693
- return q(e) <= t && r / n < .01;
399
+ return I(e) <= t && r / n < .01;
694
400
  }
695
- function Ne(e, t, n) {
401
+ function me(e, t, n) {
696
402
  if (!t || !n) return 0;
697
403
  let r = document.createElement("canvas");
698
404
  r.width = Math.min(32, t), r.height = Math.min(32, n);
699
405
  let i = r.getContext("2d", { willReadFrequently: !0 });
700
- return i ? (i.drawImage(e, 0, 0, r.width, r.height), q(i.getImageData(0, 0, r.width, r.height).data)) : 0;
406
+ return i ? (i.drawImage(e, 0, 0, r.width, r.height), I(i.getImageData(0, 0, r.width, r.height).data)) : 0;
701
407
  }
702
- function Pe(e) {
703
- return Ne(e, e.width, e.height);
408
+ function he(e) {
409
+ return me(e, e.width, e.height);
704
410
  }
705
- function Fe(e, t = 120) {
411
+ function ge(e, t = 120) {
706
412
  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 = () => {
707
413
  a && (o = i ? e.requestVideoFrameCallback(f) : requestAnimationFrame(f));
708
414
  };
709
415
  function f() {
710
416
  if (!a) return;
711
417
  let { videoWidth: i, videoHeight: o } = e, f = performance.now();
712
- r && i && o && f - s >= t && (s = f, l = Ne(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();
418
+ r && i && o && f - s >= t && (s = f, l = me(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();
713
419
  }
714
420
  return d(), {
715
421
  stop() {
@@ -721,14 +427,14 @@ function Fe(e, t = 120) {
721
427
  getMirrorAgeMs: () => c ? performance.now() - c : Infinity
722
428
  };
723
429
  }
724
- function Ie(e) {
430
+ function _e(e) {
725
431
  let t = document.createElement("canvas");
726
432
  return t.width = e.width, t.height = e.height, t.getContext("2d")?.drawImage(e, 0, 0), t;
727
433
  }
728
- function Le(e) {
434
+ function ve(e) {
729
435
  return e.engine === "blink";
730
436
  }
731
- function J(e = {}, t = H()) {
437
+ function L(e = {}, t = A()) {
732
438
  let n = { ideal: e.idealWidth ?? 3840 }, r = { ideal: e.idealHeight ?? 2160 };
733
439
  e.maxWidth && (n.max = e.maxWidth), e.maxHeight && (r.max = e.maxHeight);
734
440
  let i = {
@@ -740,20 +446,20 @@ function J(e = {}, t = H()) {
740
446
  max: e.maxFrameRate ?? 30
741
447
  }
742
448
  };
743
- return Le(t) && (i.resizeMode = { ideal: "none" }), {
449
+ return ve(t) && (i.resizeMode = { ideal: "none" }), {
744
450
  audio: !1,
745
451
  video: i
746
452
  };
747
453
  }
748
- function Re(e, t, n) {
454
+ function ye(e, t, n) {
749
455
  let r = n ? Math.min(1, n / Math.max(e, t)) : 1;
750
456
  return {
751
457
  width: Math.max(1, Math.round(e * r)),
752
458
  height: Math.max(1, Math.round(t * r))
753
459
  };
754
460
  }
755
- var ze = 4096;
756
- function Be(e, t) {
461
+ var R = 4096;
462
+ function be(e, t) {
757
463
  let n = e.width, r = e.height, i = t?.width?.max, a = t?.height?.max;
758
464
  if (!n || !r || !i || !a) return;
759
465
  let o = Math.min(i / n, a / r);
@@ -762,13 +468,13 @@ function Be(e, t) {
762
468
  height: { ideal: Math.round(r * o) }
763
469
  };
764
470
  }
765
- async function Ve(e) {
766
- let t = Be(e.getSettings(), typeof e.getCapabilities == "function" ? e.getCapabilities() : void 0);
471
+ async function xe(e) {
472
+ let t = be(e.getSettings(), typeof e.getCapabilities == "function" ? e.getCapabilities() : void 0);
767
473
  if (t) try {
768
474
  await e.applyConstraints(t);
769
475
  } catch {}
770
476
  }
771
- async function He(e) {
477
+ async function Se(e) {
772
478
  try {
773
479
  return await createImageBitmap(e, {
774
480
  imageOrientation: "from-image",
@@ -778,7 +484,7 @@ async function He(e) {
778
484
  return await createImageBitmap(e);
779
485
  }
780
486
  }
781
- async function Ue(e) {
487
+ async function Ce(e) {
782
488
  try {
783
489
  await e.applyConstraints({ advanced: [{ pointsOfInterest: [{
784
490
  x: .5,
@@ -786,25 +492,25 @@ async function Ue(e) {
786
492
  }] }] }), await new Promise((e) => window.setTimeout(e, 180));
787
493
  } catch {}
788
494
  }
789
- async function We(e) {
790
- let n = await He(e), r = Re(n.width, n.height, ze), i = document.createElement("canvas");
495
+ async function z(e) {
496
+ let n = await Se(e), r = ye(n.width, n.height, R), i = document.createElement("canvas");
791
497
  i.width = r.width, i.height = r.height;
792
498
  let a = i.getContext("2d");
793
499
  if (!a) throw n.close?.(), t();
794
500
  return a.imageSmoothingEnabled = r.width !== n.width || r.height !== n.height, a.imageSmoothingQuality = "high", a.drawImage(n, 0, 0, i.width, i.height), n.close?.(), i;
795
501
  }
796
- async function Ge(e) {
502
+ async function we(e) {
797
503
  let t = globalThis.ImageCapture;
798
504
  if (!t) return;
799
- await Ue(e);
800
- let n = new t(e), r = n.getPhotoCapabilities ? await n.getPhotoCapabilities() : void 0, i = Oe(r), a;
505
+ await Ce(e);
506
+ let n = new t(e), r = n.getPhotoCapabilities ? await n.getPhotoCapabilities() : void 0, i = le(r), a;
801
507
  try {
802
508
  a = await n.takePhoto(i);
803
509
  } catch {
804
510
  a = await n.takePhoto();
805
511
  }
806
512
  return {
807
- frame: await We(a),
513
+ frame: await z(a),
808
514
  requested: i,
809
515
  photoMax: {
810
516
  width: r?.imageWidth?.max,
@@ -812,42 +518,42 @@ async function Ge(e) {
812
518
  }
813
519
  };
814
520
  }
815
- function Y(e, n) {
521
+ function B(e, n) {
816
522
  if (!e.videoWidth || !e.videoHeight) throw Error("The camera is not ready to capture a frame.");
817
- let r = Re(e.videoWidth, e.videoHeight, n), i = document.createElement("canvas");
523
+ let r = ye(e.videoWidth, e.videoHeight, n), i = document.createElement("canvas");
818
524
  i.width = r.width, i.height = r.height;
819
525
  let a = i.getContext("2d");
820
526
  if (!a) throw t();
821
527
  return a.drawImage(e, 0, 0, i.width, i.height), i;
822
528
  }
823
- function Ke(e) {
824
- let t = H();
825
- return e.idealWidth || e.idealHeight || e.maxWidth || e.maxHeight ? [J(e, t)] : [
826
- J({
529
+ function Te(e) {
530
+ let t = A();
531
+ return e.idealWidth || e.idealHeight || e.maxWidth || e.maxHeight ? [L(e, t)] : [
532
+ L({
827
533
  ...e,
828
534
  idealWidth: 3840,
829
535
  idealHeight: 2160
830
536
  }, t),
831
- J({
537
+ L({
832
538
  ...e,
833
539
  idealWidth: 2560,
834
540
  idealHeight: 1440
835
541
  }, t),
836
- J({
542
+ L({
837
543
  ...e,
838
544
  idealWidth: 1920,
839
545
  idealHeight: 1080
840
546
  }, t)
841
547
  ];
842
548
  }
843
- async function qe(t, n = {}) {
549
+ async function Ee(t, n = {}) {
844
550
  await x("scan");
845
551
  let r = n.torch ?? "alwaysOff";
846
552
  if (r !== "alwaysOff" && await x("torch"), !window.isSecureContext && location.hostname !== "localhost") throw new e("secure-context", "Camera access requires HTTPS.");
847
553
  if (!navigator.mediaDevices?.getUserMedia) throw Error("Live camera access is unavailable. Use the native camera picker instead.");
848
554
  t.muted = !0, t.autoplay = !0, t.playsInline = !0, t.setAttribute("playsinline", "");
849
555
  let i, a;
850
- for (let e of Ke(n)) try {
556
+ for (let e of Te(n)) try {
851
557
  i = await navigator.mediaDevices.getUserMedia(e);
852
558
  break;
853
559
  } catch (e) {
@@ -860,8 +566,8 @@ async function qe(t, n = {}) {
860
566
  for (let e of i.getTracks()) e.stop();
861
567
  throw Error("The camera did not provide a video track.");
862
568
  }
863
- await Ve(o);
864
- let s = Fe(t), c = "ImageCapture" in globalThis, l = K(r, (typeof o.getCapabilities == "function" ? o.getCapabilities() : void 0)?.torch === !0), u = !1, d = async (e) => {
569
+ await xe(o);
570
+ let s = ge(t), c = "ImageCapture" in globalThis, l = F(r, (typeof o.getCapabilities == "function" ? o.getCapabilities() : void 0)?.torch === !0), u = !1, d = async (e) => {
865
571
  if (!l.supported || o.readyState !== "live") return !1;
866
572
  try {
867
573
  return await o.applyConstraints({ advanced: [{ torch: e }] }), l = {
@@ -879,7 +585,7 @@ async function qe(t, n = {}) {
879
585
  }
880
586
  };
881
587
  l.on && await d(!0);
882
- let f = r === "auto" && l.supported ? new G() : void 0, p = f ? window.setInterval(() => {
588
+ let f = r === "auto" && l.supported ? new P() : void 0, p = f ? window.setInterval(() => {
883
589
  if (u || !l.supported) return;
884
590
  let e = f.update(s.getLiveLuminance());
885
591
  e !== void 0 && e !== l.on && (u = !0, d(e).finally(() => {
@@ -905,7 +611,7 @@ async function qe(t, n = {}) {
905
611
  torchSupported: l.supported,
906
612
  torchOn: l.on,
907
613
  torch: { ...l },
908
- engine: H()
614
+ engine: A()
909
615
  };
910
616
  };
911
617
  return {
@@ -919,17 +625,17 @@ async function qe(t, n = {}) {
919
625
  get torchOn() {
920
626
  return l.on;
921
627
  },
922
- capture: (e) => Y(t, e),
628
+ capture: (e) => B(t, e),
923
629
  async capturePhoto() {
924
630
  let e, n = 0;
925
631
  try {
926
- e = Y(t), n = Pe(e);
632
+ e = B(t), n = he(e);
927
633
  } catch {
928
634
  e = void 0;
929
635
  }
930
636
  let r = s.getFrame(), i, a = !1, l = !1, u, d;
931
- if (De(H(), c)) try {
932
- let e = await Ge(o);
637
+ if (ce(A(), c)) try {
638
+ let e = await we(o);
933
639
  i = e?.frame, u = e?.requested, d = e?.photoMax;
934
640
  } catch {
935
641
  a = !0, i = void 0;
@@ -937,14 +643,14 @@ async function qe(t, n = {}) {
937
643
  let f = {
938
644
  width: t.videoWidth,
939
645
  height: t.videoHeight
940
- }, p = i ? Pe(i) : 0, h = !!(i && p > 10 && ke(i, f));
646
+ }, p = i ? he(i) : 0, h = !!(i && p > 10 && ue(i, f));
941
647
  if (i && p > 10 && !h && (l = !0), h && i) return console.info("[exige-scanner] capture", {
942
648
  method: "image-capture",
943
649
  frame: `${i.width}×${i.height}`,
944
650
  video: `${t.videoWidth}×${t.videoHeight}`,
945
651
  photoMax: d ? `${d.width ?? "—"}×${d.height ?? "—"}` : void 0,
946
652
  photoRequest: u,
947
- aspectMatch: Ae(i, f)
653
+ aspectMatch: de(i, f)
948
654
  }), {
949
655
  frame: i,
950
656
  method: "image-capture",
@@ -952,7 +658,7 @@ async function qe(t, n = {}) {
952
658
  luminance: p,
953
659
  diagnostics: m()
954
660
  };
955
- let g = e && n > 10 ? e : void 0, _ = g ?? (r ? Ie(r) : void 0);
661
+ let g = e && n > 10 ? e : void 0, _ = g ?? (r ? _e(r) : void 0);
956
662
  if (!_) throw Error("The camera preview produced no visible pixels. Keep the scanner on screen, wait for the preview, and retake.");
957
663
  let v = l ? "image-capture-preview-size" : i ? "image-capture-empty" : a ? "image-capture-failed" : g ? void 0 : "video-frame-empty";
958
664
  return console.info("[exige-scanner] capture", {
@@ -984,13 +690,13 @@ async function qe(t, n = {}) {
984
690
  }
985
691
  };
986
692
  }
987
- function Je() {
693
+ function De() {
988
694
  let e = typeof navigator > "u" ? void 0 : navigator.userActivation;
989
695
  return !e || e.isActive;
990
696
  }
991
- async function Ye() {
697
+ async function Oe() {
992
698
  let e = document.createElement("input");
993
- return e.type = "file", e.accept = "image/*", e.capture = "environment", e.setAttribute("capture", "environment"), We(await new Promise((t, n) => {
699
+ return e.type = "file", e.accept = "image/*", e.capture = "environment", e.setAttribute("capture", "environment"), z(await new Promise((t, n) => {
994
700
  e.addEventListener("change", () => {
995
701
  let r = e.files?.[0];
996
702
  r ? t(r) : n(/* @__PURE__ */ Error("No photo was selected."));
@@ -1000,13 +706,318 @@ async function Ye() {
1000
706
  }));
1001
707
  }
1002
708
  //#endregion
709
+ //#region src/sdk/ort-runtime.ts
710
+ var ke = 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);
711
+ function V() {
712
+ return {
713
+ wasm: ke.href,
714
+ mjs: Ae.href
715
+ };
716
+ }
717
+ function je(e) {
718
+ return typeof e == "string" ? e.trim() || V() : e?.wasm.trim() && e.mjs.trim() ? {
719
+ wasm: e.wasm.trim(),
720
+ mjs: e.mjs.trim()
721
+ } : V();
722
+ }
723
+ //#endregion
724
+ //#region src/sdk/image.ts
725
+ function H(e, t, n) {
726
+ let r = n ? Math.min(1, n / Math.max(e, t)) : 1;
727
+ return {
728
+ width: Math.max(1, Math.round(e * r)),
729
+ height: Math.max(1, Math.round(t * r))
730
+ };
731
+ }
732
+ async function Me(e) {
733
+ let t = URL.createObjectURL(e);
734
+ try {
735
+ let e = new Image();
736
+ return e.src = t, await e.decode(), e;
737
+ } finally {
738
+ URL.revokeObjectURL(t);
739
+ }
740
+ }
741
+ async function U(e, n = {}) {
742
+ if (e instanceof HTMLCanvasElement && n.cloneCanvas === !1 && !n.maxDimension) return e;
743
+ let r = document.createElement("canvas"), i = r.getContext("2d", { willReadFrequently: !0 });
744
+ if (!i) throw t();
745
+ if (e instanceof Blob) {
746
+ if ("createImageBitmap" in window) try {
747
+ let t = await createImageBitmap(e), a = H(t.width, t.height, n.maxDimension);
748
+ return r.width = a.width, r.height = a.height, i.drawImage(t, 0, 0, a.width, a.height), t.close(), r;
749
+ } catch {}
750
+ e = await Me(e);
751
+ }
752
+ let a = e instanceof HTMLImageElement ? e.naturalWidth : e.width, o = e instanceof HTMLImageElement ? e.naturalHeight : e.height;
753
+ if (!a || !o) throw Error("The image has no readable dimensions.");
754
+ let s = H(a, o, n.maxDimension);
755
+ return r.width = s.width, r.height = s.height, i.drawImage(e, 0, 0, s.width, s.height), r;
756
+ }
757
+ function Ne(e, t = "image/png", n = .92) {
758
+ return new Promise((r, i) => e.toBlob((e) => e ? r(e) : i(/* @__PURE__ */ Error("Could not encode the image.")), t, n));
759
+ }
760
+ function Pe(e, t, n) {
761
+ let r = Math.max(0, Math.min(t, e.x)), i = Math.max(0, Math.min(n, e.y));
762
+ return {
763
+ x: r,
764
+ y: i,
765
+ width: Math.max(0, Math.min(t - r, e.width)),
766
+ height: Math.max(0, Math.min(n - i, e.height))
767
+ };
768
+ }
769
+ //#endregion
770
+ //#region src/sdk/scan.ts
771
+ var Fe = "https://exige-scanner-sdk.vercel.app/models/docaligner-lcnet100-f4117b78.onnx", Ie = 1280;
772
+ function Le(e, t, n) {
773
+ if (n) return n;
774
+ let r = Math.max(e, t), i = r / Math.max(1, Math.min(e, t)), a = Ve() ? 560 : 900;
775
+ return i >= 1.6 ? Math.min(r, Math.max(a, Ie)) : a;
776
+ }
777
+ function W(e) {
778
+ return e?.trim() || "https://exige-scanner-sdk.vercel.app/models/docaligner-lcnet100-f4117b78.onnx";
779
+ }
780
+ var Re = 3, G, ze = 0, K = /* @__PURE__ */ new Map();
781
+ function q(e, t) {
782
+ return Math.hypot(e.x - t.x, e.y - t.y);
783
+ }
784
+ function J(e) {
785
+ return {
786
+ ...e,
787
+ edges: {
788
+ top: {
789
+ start: e.topLeft,
790
+ end: e.topRight
791
+ },
792
+ right: {
793
+ start: e.topRight,
794
+ end: e.bottomRight
795
+ },
796
+ bottom: {
797
+ start: e.bottomRight,
798
+ end: e.bottomLeft
799
+ },
800
+ left: {
801
+ start: e.bottomLeft,
802
+ end: e.topLeft
803
+ }
804
+ }
805
+ };
806
+ }
807
+ function Be(e, t) {
808
+ let n = (e) => ({
809
+ x: e.x / t,
810
+ y: e.y / t
811
+ });
812
+ return {
813
+ topLeft: n(e.topLeft),
814
+ topRight: n(e.topRight),
815
+ bottomRight: n(e.bottomRight),
816
+ bottomLeft: n(e.bottomLeft)
817
+ };
818
+ }
819
+ function Ve() {
820
+ return typeof navigator > "u" ? !1 : navigator.maxTouchPoints > 0 || navigator.hardwareConcurrency <= 4 || typeof matchMedia == "function" && matchMedia("(pointer: coarse)").matches;
821
+ }
822
+ function He(t, n, r, i) {
823
+ return new Promise((a, o) => {
824
+ G || (G = new Worker(new URL("./assets/document-worker.js", import.meta.url), { type: "module" }), G.onmessage = (t) => {
825
+ if (t.data.download?.url) {
826
+ k(t.data.download.url, t.data.download);
827
+ return;
828
+ }
829
+ let n = K.get(t.data.id);
830
+ n && (K.delete(t.data.id), t.data.error ? n.reject(t.data.errorCode ? new e(t.data.errorCode, t.data.error) : Error(t.data.error)) : t.data.result ? n.resolve(t.data.result) : n.reject(/* @__PURE__ */ Error("The document worker returned no result.")));
831
+ }, G.onerror = () => {
832
+ let t = new e("worker", "The document worker could not start.");
833
+ for (let e of K.values()) e.reject(t);
834
+ K.clear(), G?.terminate(), G = void 0;
835
+ });
836
+ let s = ++ze;
837
+ K.set(s, {
838
+ resolve: a,
839
+ reject: o
840
+ });
841
+ let c = t.slice().buffer;
842
+ G.postMessage({
843
+ id: s,
844
+ pixels: c,
845
+ width: n,
846
+ height: r,
847
+ modelUrl: W(i.modelUrl),
848
+ heatmapThreshold: i.heatmapThreshold,
849
+ cacheModel: i.cacheModel,
850
+ ortWasmPaths: je(i.ortWasmPaths),
851
+ preferWebGpu: i.preferWebGpu ?? M()
852
+ }, [c]);
853
+ });
854
+ }
855
+ async function Y(n, r) {
856
+ let { width: i, height: a } = n, o = r.minDimension ?? 360;
857
+ if (Math.min(i, a) < o) return {
858
+ status: "low-quality",
859
+ confidence: 0,
860
+ message: `Use an image at least ${o}px on its shortest side.`,
861
+ sourceWidth: i,
862
+ sourceHeight: a
863
+ };
864
+ let s = Le(i, a, r.maxAnalysisDimension), c = Math.min(1, s / Math.max(i, a)), l = Math.max(1, Math.round(i * c)), u = Math.max(1, Math.round(a * c)), d;
865
+ if (c === 1) {
866
+ let e = n.getContext("2d", { willReadFrequently: !0 });
867
+ if (!e) throw t();
868
+ d = e.getImageData(0, 0, l, u).data;
869
+ } else {
870
+ let e = document.createElement("canvas");
871
+ e.width = l, e.height = u;
872
+ let r = e.getContext("2d", { willReadFrequently: !0 });
873
+ if (!r) throw t();
874
+ r.drawImage(n, 0, 0, e.width, e.height), d = r.getImageData(0, 0, e.width, e.height).data;
875
+ }
876
+ let f;
877
+ if (r.useWorker !== !1 && typeof Worker < "u") try {
878
+ f = await He(d, l, u, r);
879
+ } catch (t) {
880
+ if (t instanceof e && (t.code === "worker" || t.code === "model-http")) throw t;
881
+ f = {
882
+ sharpness: 20,
883
+ detector: "ml",
884
+ modelStatus: "failed",
885
+ modelError: t instanceof Error ? t.message : "Document worker failed."
886
+ };
887
+ }
888
+ else f = {
889
+ sharpness: 20,
890
+ detector: "ml",
891
+ modelStatus: "failed",
892
+ modelError: "ML detection requires a Web Worker."
893
+ };
894
+ let { sharpness: p, candidate: m, detector: h, modelStatus: g, modelProvider: _, modelError: v, modelNote: y, inferenceMs: b } = f, x = {
895
+ detector: h,
896
+ modelStatus: g,
897
+ modelProvider: _,
898
+ modelError: v,
899
+ modelNote: y,
900
+ inferenceMs: b
901
+ };
902
+ if (p < Re) return {
903
+ status: "low-quality",
904
+ confidence: Math.min(.3, p / 18),
905
+ message: "The image is too soft or dark to resolve four document edges.",
906
+ sourceWidth: i,
907
+ sourceHeight: a,
908
+ ...x
909
+ };
910
+ if (!m) return {
911
+ status: "no-document",
912
+ confidence: 0,
913
+ message: "No document corners found. Place all four edges on a contrasting surface.",
914
+ sourceWidth: i,
915
+ sourceHeight: a,
916
+ ...x
917
+ };
918
+ let S = Be(m.corners, c), C = J(S), w = r.minConfidence ?? .58;
919
+ return m.confidence < w ? {
920
+ status: "low-confidence",
921
+ quad: C,
922
+ corners: S,
923
+ confidence: m.confidence,
924
+ message: "Four possible corners were found, but the geometry is not reliable enough to crop.",
925
+ sourceWidth: i,
926
+ sourceHeight: a,
927
+ ...x
928
+ } : {
929
+ status: "success",
930
+ quad: C,
931
+ corners: S,
932
+ confidence: m.confidence,
933
+ message: "Four document edges detected.",
934
+ sourceWidth: i,
935
+ sourceHeight: a,
936
+ ...x
937
+ };
938
+ }
939
+ function Ue(e, t) {
940
+ let n = Math.max(1, Math.round(Math.max(q(e.topLeft, e.topRight), q(e.bottomLeft, e.bottomRight)))), r = Math.max(1, Math.round(Math.max(q(e.topLeft, e.bottomLeft), q(e.topRight, e.bottomRight)))), i = Math.min(1, t / Math.max(n, r));
941
+ return {
942
+ width: Math.max(1, Math.round(n * i)),
943
+ height: Math.max(1, Math.round(r * i))
944
+ };
945
+ }
946
+ function We(e, t, n, r, i) {
947
+ let a = Math.max(0, Math.min(t - 1, r)), o = Math.max(0, Math.min(n - 1, i)), s = Math.floor(a), c = Math.floor(o), l = Math.min(t - 1, s + 1), u = Math.min(n - 1, c + 1), d = a - s, f = o - c, p = c * t, m = u * t, h = (t) => {
948
+ let n = e[(p + s) * 4 + t] * (1 - d) + e[(p + l) * 4 + t] * d, r = e[(m + s) * 4 + t] * (1 - d) + e[(m + l) * 4 + t] * d;
949
+ return Math.round(n * (1 - f) + r * f);
950
+ };
951
+ return [
952
+ h(0),
953
+ h(1),
954
+ h(2),
955
+ 255
956
+ ];
957
+ }
958
+ function Ge(e, n, r) {
959
+ let { width: i, height: a } = Ue(n, r), o = e.getContext("2d", { willReadFrequently: !0 });
960
+ if (!o) throw t();
961
+ let s = o.getImageData(0, 0, e.width, e.height), c = document.createElement("canvas");
962
+ c.width = i, c.height = a;
963
+ let l = c.getContext("2d");
964
+ if (!l) throw t();
965
+ let u = l.createImageData(i, a), { topLeft: d, topRight: f, bottomRight: p, bottomLeft: m } = n, h = f.x - p.x, g = m.x - p.x, _ = f.y - p.y, v = m.y - p.y, y = d.x - f.x + p.x - m.x, b = d.y - f.y + p.y - m.y, x = h * v - g * _, S = Math.abs(x) < 1e-4 ? 0 : (y * v - g * b) / x, C = Math.abs(x) < 1e-4 ? 0 : (h * b - y * _) / x, w = f.x - d.x + S * f.x, T = m.x - d.x + C * m.x, E = f.y - d.y + S * f.y, D = m.y - d.y + C * m.y;
966
+ for (let t = 0; t < a; t += 1) {
967
+ let n = t / Math.max(1, a - 1);
968
+ for (let r = 0; r < i; r += 1) {
969
+ let a = r / Math.max(1, i - 1), o = S * a + C * n + 1, c = (w * a + T * n + d.x) / o, l = (E * a + D * n + d.y) / o, [f, p, m, h] = We(s.data, e.width, e.height, c, l), g = (t * i + r) * 4;
970
+ u.data[g] = f, u.data[g + 1] = p, u.data[g + 2] = m, u.data[g + 3] = h;
971
+ }
972
+ }
973
+ return l.putImageData(u, 0, 0), c;
974
+ }
975
+ async function Ke(e, t = {}) {
976
+ return await x("scan"), Y(await U(e, { cloneCanvas: !1 }), t);
977
+ }
978
+ async function qe(e, t, n = {}) {
979
+ await x("scan");
980
+ let r = await U(e, { cloneCanvas: !1 }), i = n.maxOutputDimension ?? 4096;
981
+ return {
982
+ status: "success",
983
+ corners: t,
984
+ quad: J(t),
985
+ confidence: 1,
986
+ message: "Captured with the document edges shown in the finder.",
987
+ sourceWidth: r.width,
988
+ sourceHeight: r.height,
989
+ canvas: Ge(r, t, i)
990
+ };
991
+ }
992
+ async function Je(e, t = {}) {
993
+ await x("scan");
994
+ let n = await U(e, { cloneCanvas: !1 }), r = await Y(n, t);
995
+ if (r.status !== "success" || !r.corners) return r;
996
+ let i = t.maxOutputDimension ?? 4096;
997
+ return {
998
+ ...r,
999
+ canvas: Ge(n, r.corners, i),
1000
+ message: "Four document edges detected and perspective-corrected."
1001
+ };
1002
+ }
1003
+ function Ye(e) {
1004
+ return e.status === "success" ? e.message : e.status === "low-quality" ? e.message.includes("shortest side") ? `${e.message} Take another photo.` : "That photo is too soft or dark to find a document. Take another photo in better light." : e.status === "low-confidence" ? "The page edges were not clear enough to crop. Take another photo with the whole page in frame." : `No document was found in that photo. Take another photo with the whole page in frame.${e.modelStatus === "failed" && e.modelError ? ` (${e.modelError})` : ""}`;
1005
+ }
1006
+ async function Xe(e, t = {}) {
1007
+ let n = await Je(e, t);
1008
+ return n.status === "success" ? n : {
1009
+ ...n,
1010
+ message: Ye(n)
1011
+ };
1012
+ }
1013
+ //#endregion
1003
1014
  //#region src/sdk/lighting.ts
1004
- function Xe(e, t) {
1015
+ function Ze(e, t) {
1005
1016
  if (!e.length) return 0;
1006
1017
  let n = [...e].sort((e, t) => e - t);
1007
1018
  return n[Math.min(n.length - 1, Math.floor(n.length * t))];
1008
1019
  }
1009
- function Ze(e, t, n, r = 12) {
1020
+ function Qe(e, t, n, r = 12) {
1010
1021
  if (!t || !n || e.length < t * n) return {
1011
1022
  strong: !1,
1012
1023
  strength: 0,
@@ -1029,7 +1040,7 @@ function Ze(e, t, n, r = 12) {
1029
1040
  });
1030
1041
  }
1031
1042
  }
1032
- let s = Xe(o.map((e) => e.mean), .8), c = o.map((e) => s - e.mean >= 24 && e.mean >= 35), l = new Uint8Array(o.length), u = [];
1043
+ let s = Ze(o.map((e) => e.mean), .8), c = o.map((e) => s - e.mean >= 24 && e.mean >= 35), l = new Uint8Array(o.length), u = [];
1033
1044
  for (let e = 0; e < o.length; e += 1) {
1034
1045
  if (!c[e] || l[e]) continue;
1035
1046
  let t = [], n = [e];
@@ -1077,11 +1088,11 @@ function Ze(e, t, n, r = 12) {
1077
1088
  }
1078
1089
  return d;
1079
1090
  }
1080
- function Qe(e, t, n, r, i, a, o) {
1091
+ function $e(e, t, n, r, i, a, o) {
1081
1092
  let s = Math.max(0, a - o), c = Math.min(r, a + o + 1), l = Math.max(0, i - o), u = Math.min(n, i + o + 1), d = Math.max(1, (u - l) * (c - s));
1082
1093
  return (e[c * t + u] - e[s * t + u] - e[c * t + l] + e[s * t + l]) / d;
1083
1094
  }
1084
- function $e(e, t, n) {
1095
+ function X(e, t, n) {
1085
1096
  let r = t + 1, i = new Uint32Array((t + 1) * (n + 1));
1086
1097
  for (let a = 1; a <= n; a += 1) {
1087
1098
  let n = 0;
@@ -1093,17 +1104,17 @@ function $e(e, t, n) {
1093
1104
  };
1094
1105
  }
1095
1106
  function et(e, t, n, r = Math.max(12, Math.round(Math.max(t, n) / 32))) {
1096
- let { integral: i, stride: a } = $e(e, t, n), o = new Uint8Array(e.length);
1107
+ let { integral: i, stride: a } = X(e, t, n), o = new Uint8Array(e.length);
1097
1108
  for (let s = 0; s < n; s += 1) for (let c = 0; c < t; c += 1) {
1098
- let l = Qe(i, a, t, n, c, s, r);
1109
+ let l = $e(i, a, t, n, c, s, r);
1099
1110
  o[s * t + c] = Math.max(0, Math.min(255, Math.round(e[s * t + c] * 235 / Math.max(24, l))));
1100
1111
  }
1101
1112
  return o;
1102
1113
  }
1103
1114
  function tt(e, t, n, r = Math.max(8, Math.round(Math.max(t, n) / 64)), i = .12) {
1104
- let { integral: a, stride: o } = $e(e, t, n), s = new Uint8Array(e.length), c = 1 - i;
1115
+ let { integral: a, stride: o } = X(e, t, n), s = new Uint8Array(e.length), c = 1 - i;
1105
1116
  for (let i = 0; i < n; i += 1) for (let l = 0; l < t; l += 1) {
1106
- let u = Qe(a, o, t, n, l, i, r);
1117
+ let u = $e(a, o, t, n, l, i, r);
1107
1118
  s[i * t + l] = e[i * t + l] < u * c ? 0 : 255;
1108
1119
  }
1109
1120
  return s;
@@ -1142,7 +1153,7 @@ function rt(e, t) {
1142
1153
  i.drawImage(e, n.left, n.top, n.width, n.height, 0, 0, r.width, r.height);
1143
1154
  let a = i.getImageData(0, 0, r.width, r.height).data, o = new Uint8Array(r.width * r.height);
1144
1155
  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);
1145
- return Ze(o, r.width, r.height);
1156
+ return Qe(o, r.width, r.height);
1146
1157
  }
1147
1158
  //#endregion
1148
1159
  //#region src/sdk/finder.ts
@@ -1168,7 +1179,7 @@ function ot(e) {
1168
1179
  mutable: !0
1169
1180
  };
1170
1181
  }
1171
- function X(e) {
1182
+ function Z(e) {
1172
1183
  return [
1173
1184
  e.topLeft,
1174
1185
  e.topRight,
@@ -1176,7 +1187,19 @@ function X(e) {
1176
1187
  e.bottomLeft
1177
1188
  ];
1178
1189
  }
1179
- function st(e, t) {
1190
+ var st = 1600;
1191
+ function ct(e = A()) {
1192
+ return e.iosWebKit ? {
1193
+ intervalMs: 70,
1194
+ maxFrameDimension: 720,
1195
+ maxAnalysisDimension: 720
1196
+ } : {
1197
+ intervalMs: 140,
1198
+ maxFrameDimension: st,
1199
+ maxAnalysisDimension: 520
1200
+ };
1201
+ }
1202
+ function lt(e, t) {
1180
1203
  let n = e.status === "success" && e.modelStatus !== "failed", r = {
1181
1204
  status: e.status,
1182
1205
  confidence: Number(e.confidence.toFixed(3)),
@@ -1199,7 +1222,7 @@ function st(e, t) {
1199
1222
  detail: r
1200
1223
  };
1201
1224
  }
1202
- function ct(e) {
1225
+ function ut(e) {
1203
1226
  let t = 0;
1204
1227
  for (let n = 0; n < e.length; n += 1) {
1205
1228
  let r = e[n], i = e[(n + 1) % e.length];
@@ -1207,42 +1230,42 @@ function ct(e) {
1207
1230
  }
1208
1231
  return Math.abs(t) / 2;
1209
1232
  }
1210
- function Z(e, t) {
1233
+ function Q(e, t) {
1211
1234
  return Math.hypot(e.x - t.x, e.y - t.y);
1212
1235
  }
1213
- var Q = {
1236
+ var $ = {
1214
1237
  widthFill: 0,
1215
1238
  heightFill: 0,
1216
1239
  limitingFill: 0,
1217
1240
  areaFill: 0,
1218
1241
  aspectRatio: 1
1219
1242
  };
1220
- function lt(e, t, n) {
1221
- 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));
1243
+ function dt(e, t, n) {
1244
+ 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));
1222
1245
  return {
1223
1246
  widthFill: o,
1224
1247
  heightFill: s,
1225
1248
  limitingFill: Math.max(o, s),
1226
- areaFill: ct(r) / Math.max(1, t * n),
1249
+ areaFill: ut(r) / Math.max(1, t * n),
1227
1250
  aspectRatio: Math.max(f, p) / Math.max(1, Math.min(f, p))
1228
1251
  };
1229
1252
  }
1230
- function ut(e, t, n, r = {}) {
1253
+ function ft(e, t, n, r = {}) {
1231
1254
  let i = t ? r.exitFillRatio ?? .64 : r.minFillRatio ?? .72, a = r.highAspectRatio ?? 2.2;
1232
1255
  if (e.aspectRatio < a) return i;
1233
1256
  let o = t ? r.highAspectExitFillRatio : r.highAspectFillRatio;
1234
1257
  return Math.min(o ?? i + .08, 1 - n * 2);
1235
1258
  }
1236
- function dt(e, t, n = {}) {
1259
+ function pt(e, t, n = {}) {
1237
1260
  let r = n.confidenceThreshold ?? .72;
1238
1261
  if (e.status !== "success" || !e.quad || e.confidence < r || !e.sourceWidth || !e.sourceHeight) return {
1239
1262
  hint: "Place the document in the frame",
1240
1263
  reason: "place-document",
1241
1264
  fillRatio: 0,
1242
- fill: Q,
1265
+ fill: $,
1243
1266
  readyForAutoCapture: !1
1244
1267
  };
1245
- let i = X(e.quad), a = lt(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;
1268
+ let i = Z(e.quad), a = dt(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;
1246
1269
  if (i.some(({ x: t, y: n }) => t <= c || t >= e.sourceWidth - c || n <= l || n >= e.sourceHeight - l)) return {
1247
1270
  hint: "Move farther away",
1248
1271
  reason: "move-farther-away",
@@ -1250,14 +1273,14 @@ function dt(e, t, n = {}) {
1250
1273
  fill: a,
1251
1274
  readyForAutoCapture: !1
1252
1275
  };
1253
- let [u, d, f, p] = i, m = Z(u, d), h = Z(d, f), g = Z(f, p), _ = Z(p, u);
1276
+ let [u, d, f, p] = i, m = Q(u, d), h = Q(d, f), g = Q(f, p), _ = Q(p, u);
1254
1277
  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) ? {
1255
1278
  hint: "Hold the camera straight",
1256
1279
  reason: "straighten-camera",
1257
1280
  fillRatio: o,
1258
1281
  fill: a,
1259
1282
  readyForAutoCapture: !1
1260
- } : o < ut(a, t.previouslyReady === !0, s, n) ? {
1283
+ } : o < ft(a, t.previouslyReady === !0, s, n) ? {
1261
1284
  hint: "Move closer",
1262
1285
  reason: "move-closer",
1263
1286
  fillRatio: o,
@@ -1271,7 +1294,7 @@ function dt(e, t, n = {}) {
1271
1294
  readyForAutoCapture: t.ready
1272
1295
  };
1273
1296
  }
1274
- var $ = class {
1297
+ var mt = class {
1275
1298
  previous;
1276
1299
  count = 0;
1277
1300
  ready = !1;
@@ -1288,8 +1311,8 @@ var $ = class {
1288
1311
  ready: !1,
1289
1312
  movement: Infinity
1290
1313
  };
1291
- let t = Math.hypot(e.sourceWidth, e.sourceHeight), n = this.previous ? Math.max(...X(e.quad).map((e, n) => {
1292
- let r = X(this.previous)[n];
1314
+ let t = Math.hypot(e.sourceWidth, e.sourceHeight), n = this.previous ? Math.max(...Z(e.quad).map((e, n) => {
1315
+ let r = Z(this.previous)[n];
1293
1316
  return Math.hypot(e.x - r.x, e.y - r.y) / Math.max(1, t);
1294
1317
  })) : Infinity, r = this.options.exitCornerTolerance ?? Math.max(this.options.cornerTolerance, .036);
1295
1318
  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, {
@@ -1299,14 +1322,14 @@ var $ = class {
1299
1322
  };
1300
1323
  }
1301
1324
  };
1302
- function ft(e, n) {
1325
+ function ht(e, n) {
1303
1326
  let r = Math.min(1, n / Math.max(e.width, e.height)), i = document.createElement("canvas");
1304
1327
  i.width = Math.max(1, Math.round(e.width * r)), i.height = Math.max(1, Math.round(e.height * r));
1305
1328
  let a = i.getContext("2d");
1306
1329
  if (!a) throw t();
1307
1330
  return a.drawImage(e, 0, 0, i.width, i.height), i;
1308
1331
  }
1309
- function pt() {
1332
+ function gt() {
1310
1333
  let e = window.AudioContext ?? window.webkitAudioContext;
1311
1334
  if (!e) return;
1312
1335
  let t = new e(), n = Math.round(t.sampleRate * .09), r = t.createBuffer(1, n, t.sampleRate), i = r.getChannelData(0);
@@ -1317,29 +1340,29 @@ function pt() {
1317
1340
  let a = t.createBufferSource(), o = t.createBiquadFilter(), s = t.createGain();
1318
1341
  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();
1319
1342
  }
1320
- async function mt(e) {
1343
+ async function _t(e) {
1321
1344
  let t = document.createElement("video");
1322
1345
  return t.muted = !0, t.autoplay = !0, t.playsInline = !0, t.srcObject = e, await t.play(), t;
1323
1346
  }
1324
- async function ht(t) {
1347
+ async function vt(t) {
1325
1348
  await x("scan");
1326
- let n = ot(t.autoCapture), r = new $({
1349
+ let n = ot(t.autoCapture), r = new mt({
1327
1350
  stableFrames: t.stableFrames ?? 4,
1328
1351
  confidenceThreshold: t.confidenceThreshold ?? .72,
1329
1352
  cornerTolerance: t.cornerTolerance ?? .024,
1330
1353
  exitCornerTolerance: t.exitCornerTolerance ?? .036
1331
- }), i = t.maxFrameDimension ?? 1600, a = t.intervalMs ?? 140, o = {
1354
+ }), i = ct(), a = t.maxFrameDimension ?? i.maxFrameDimension, o = t.intervalMs ?? i.intervalMs, s = {
1332
1355
  minDimension: 220,
1333
- maxAnalysisDimension: 520,
1356
+ maxAnalysisDimension: i.maxAnalysisDimension,
1334
1357
  ...t.detection
1335
- }, s = typeof MediaStream < "u" && t.source instanceof MediaStream ? await mt(t.source) : t.source, c = !0, l = !1, u = !1, d = 0, f, p = "", m = 0, h = {
1358
+ }, c = typeof MediaStream < "u" && t.source instanceof MediaStream ? await _t(t.source) : t.source, l = !0, u = !1, d = !1, f = 0, p, m = "", h = 0, g = {
1336
1359
  state: "detecting",
1337
1360
  confidence: 0,
1338
1361
  guidance: {
1339
1362
  hint: "Place the document in the frame",
1340
1363
  reason: "place-document",
1341
1364
  fillRatio: 0,
1342
- fill: Q,
1365
+ fill: $,
1343
1366
  readyForAutoCapture: !1
1344
1367
  },
1345
1368
  lighting: {
@@ -1349,71 +1372,71 @@ async function ht(t) {
1349
1372
  stableFrames: 0,
1350
1373
  requiredStableFrames: t.stableFrames ?? 4,
1351
1374
  autoCapture: { ...n }
1352
- }, g = () => s instanceof HTMLCanvasElement ? ft(s, i) : Y(s, i), _ = (e) => {
1353
- h = e, t.onStatus?.(e);
1354
- }, v = (e) => {
1355
- let t = st(e, s instanceof HTMLVideoElement ? {
1356
- width: s.videoWidth,
1357
- height: s.videoHeight
1375
+ }, _ = () => c instanceof HTMLCanvasElement ? ht(c, a) : B(c, a), v = (e) => {
1376
+ g = e, t.onStatus?.(e);
1377
+ }, y = (e) => {
1378
+ let t = lt(e, c instanceof HTMLVideoElement ? {
1379
+ width: c.videoWidth,
1380
+ height: c.videoHeight
1358
1381
  } : {
1359
- width: s.width,
1360
- height: s.height
1382
+ width: c.width,
1383
+ height: c.height
1361
1384
  }), n = performance.now();
1362
- t.key === p && n - m < 2e3 || (p = t.key, m = n, console[t.level](`[exige-scanner] ${t.summary}`, t.detail));
1363
- }, y = () => {
1364
- c = !1, window.clearTimeout(d), s instanceof HTMLVideoElement && s !== t.source && (s.srcObject = null);
1365
- }, b = async (e = "manual") => {
1366
- if (l) throw Error("A finder capture is already in progress.");
1367
- l = !0;
1385
+ t.key === m && n - h < 2e3 || (m = t.key, h = n, console[t.level](`[exige-scanner] ${t.summary}`, t.detail));
1386
+ }, b = () => {
1387
+ l = !1, window.clearTimeout(f), c instanceof HTMLVideoElement && c !== t.source && (c.srcObject = null);
1388
+ }, S = async (e = "manual") => {
1389
+ if (u) throw Error("A finder capture is already in progress.");
1390
+ u = !0;
1368
1391
  let n;
1369
1392
  try {
1370
- n = await at(t.captureFrame ?? g, () => {
1371
- _({
1372
- ...h,
1393
+ n = await at(t.captureFrame ?? _, () => {
1394
+ v({
1395
+ ...g,
1373
1396
  state: "captured"
1374
- }), t.playShutterSound !== !1 && pt(), y();
1397
+ }), t.playShutterSound !== !1 && gt(), b();
1375
1398
  });
1376
1399
  } catch (e) {
1377
- throw l = !1, e instanceof Error ? e : /* @__PURE__ */ Error("The camera frame could not be captured.");
1400
+ throw u = !1, e instanceof Error ? e : /* @__PURE__ */ Error("The camera frame could not be captured.");
1378
1401
  }
1379
1402
  let r = {
1380
1403
  frame: n,
1381
- detection: f,
1404
+ detection: p,
1382
1405
  reason: e
1383
1406
  };
1384
1407
  return await t.onCapture?.(r), r;
1385
- }, S = async () => {
1386
- if (c && !l) {
1408
+ }, C = async () => {
1409
+ if (l && !u) {
1387
1410
  try {
1388
- let e = g(), i = await R(e, o);
1389
- f = i, v(i);
1411
+ let e = _(), i = await Ke(e, s);
1412
+ p = i, y(i);
1390
1413
  let a = i.quad ? rt(e, i.quad) : {
1391
1414
  strong: !1,
1392
1415
  strength: 0
1393
- }, s = a.strong ? {
1416
+ }, o = a.strong ? {
1394
1417
  castShadow: !0,
1395
1418
  strength: a.strength,
1396
1419
  hint: "Tilt to move the shadow off the page"
1397
1420
  } : {
1398
1421
  castShadow: !1,
1399
1422
  strength: a.strength
1400
- }, c = r.update(i), l = dt(i, {
1423
+ }, c = r.update(i), l = pt(i, {
1401
1424
  ...c,
1402
- previouslyReady: u
1425
+ previouslyReady: d
1403
1426
  }, {
1404
1427
  confidenceThreshold: t.confidenceThreshold ?? .72,
1405
1428
  ...t.guidance
1406
1429
  });
1407
- u = l.readyForAutoCapture;
1408
- let d = i.status !== "success" || l.reason === "place-document" ? "seeking" : l.readyForAutoCapture ? "ready" : "unstable";
1409
- if (_({
1410
- state: d,
1430
+ d = l.readyForAutoCapture;
1431
+ let u = i.status !== "success" || l.reason === "place-document" ? "seeking" : l.readyForAutoCapture ? "ready" : "unstable";
1432
+ if (v({
1433
+ state: u,
1411
1434
  confidence: i.confidence,
1412
1435
  quad: i.quad,
1413
1436
  guidance: l,
1414
- lighting: s,
1437
+ lighting: o,
1415
1438
  stableFrames: c.stableFrames,
1416
- requiredStableFrames: h.requiredStableFrames,
1439
+ requiredStableFrames: g.requiredStableFrames,
1417
1440
  autoCapture: { ...n },
1418
1441
  sourceWidth: i.sourceWidth,
1419
1442
  sourceHeight: i.sourceHeight,
@@ -1424,33 +1447,33 @@ async function ht(t) {
1424
1447
  modelNote: i.modelNote,
1425
1448
  inferenceMs: i.inferenceMs
1426
1449
  }), l.readyForAutoCapture && n.checked) try {
1427
- await b("auto");
1450
+ await S("auto");
1428
1451
  return;
1429
1452
  } catch (e) {
1430
- r.reset(), u = !1, t.onCaptureError?.(e instanceof Error ? e : /* @__PURE__ */ Error("Automatic capture failed."));
1453
+ r.reset(), d = !1, t.onCaptureError?.(e instanceof Error ? e : /* @__PURE__ */ Error("Automatic capture failed."));
1431
1454
  }
1432
1455
  } catch (t) {
1433
- r.reset(), u = !1;
1456
+ r.reset(), d = !1;
1434
1457
  let i = t instanceof e ? {
1435
1458
  detector: "ml",
1436
1459
  modelStatus: "failed",
1437
1460
  modelError: t.message
1438
1461
  } : { modelError: t instanceof Error ? t.message : "Finder tick failed." };
1439
- v({
1462
+ y({
1440
1463
  status: "no-document",
1441
1464
  confidence: 0,
1442
1465
  message: i.modelError ?? "Finder tick failed.",
1443
1466
  sourceWidth: 0,
1444
1467
  sourceHeight: 0,
1445
1468
  ...i
1446
- }), _({
1469
+ }), v({
1447
1470
  state: "seeking",
1448
1471
  confidence: 0,
1449
1472
  guidance: {
1450
1473
  hint: "Place the document in the frame",
1451
1474
  reason: "place-document",
1452
1475
  fillRatio: 0,
1453
- fill: Q,
1476
+ fill: $,
1454
1477
  readyForAutoCapture: !1
1455
1478
  },
1456
1479
  lighting: {
@@ -1458,27 +1481,27 @@ async function ht(t) {
1458
1481
  strength: 0
1459
1482
  },
1460
1483
  stableFrames: 0,
1461
- requiredStableFrames: h.requiredStableFrames,
1484
+ requiredStableFrames: g.requiredStableFrames,
1462
1485
  autoCapture: { ...n },
1463
1486
  ...i
1464
1487
  });
1465
1488
  }
1466
- c && (d = window.setTimeout(() => void S(), a));
1489
+ l && (f = window.setTimeout(() => void C(), o));
1467
1490
  }
1468
1491
  };
1469
- return t.onStatus?.(h), S(), {
1470
- stop: y,
1471
- capture: () => b("manual"),
1492
+ return t.onStatus?.(g), C(), {
1493
+ stop: b,
1494
+ capture: () => S("manual"),
1472
1495
  setAutoCapture(e) {
1473
- return !n.mutable || l ? !1 : (n.checked = e, _({
1474
- ...h,
1496
+ return !n.mutable || u ? !1 : (n.checked = e, v({
1497
+ ...g,
1475
1498
  autoCapture: { ...n }
1476
1499
  }), !0);
1477
1500
  },
1478
- getStatus: () => h
1501
+ getStatus: () => g
1479
1502
  };
1480
1503
  }
1481
1504
  //#endregion
1482
- export { z as A, x as B, Ee as C, Ce as D, pe as E, A as F, y as H, ie as I, ne as L, B as M, de as N, R as O, fe as P, a as R, Ye as S, K as T, e as U, b as V, t as W, Je as _, dt as a, q as b, tt as c, G as d, je as f, Te as g, H as h, lt as i, we as j, j as k, Ze as l, Y as m, ot as n, it as o, ze as p, ut as r, ht as s, $ as t, et as u, U as v, qe as w, J as x, Me as y, o as z };
1505
+ export { I as A, o as B, R as C, De as D, oe as E, Ee as F, t as G, b as H, F as I, ie as L, Oe as M, M as N, j as O, se as P, ne as R, fe as S, A as T, y as U, x as V, e as W, Ye as _, pt as a, U as b, tt as c, Fe as d, qe as f, Xe as g, Je as h, dt as i, L as j, pe as k, Qe as l, W as m, ot as n, it as o, Ke as p, ft as r, vt as s, mt as t, et as u, Ne as v, B as w, P as x, Pe as y, a as z };
1483
1506
 
1484
- //# sourceMappingURL=finder-BlN89ZeT.js.map
1507
+ //# sourceMappingURL=finder-BvBpdbHa.js.map