@sekyro/web 0.1.0-rc.2 → 0.1.0-rc.21

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.
Files changed (133) hide show
  1. package/CHANGELOG.md +313 -0
  2. package/LICENSE +25 -16
  3. package/README.md +111 -60
  4. package/THIRD-PARTY-NOTICES.txt +154 -0
  5. package/dist/background-monitor-A7FKJOAG.js +1 -0
  6. package/dist/camera-trait-45MJTW4K.js +1 -0
  7. package/dist/capture-constraints-B5omafmk.d.cts +44 -0
  8. package/dist/capture-constraints-B5omafmk.d.ts +44 -0
  9. package/dist/capture-session-doc-XBZGXWOP.js +1 -0
  10. package/dist/{capture-session-v3-CAoWM8iT.d.cts → capture-session-v3-26FgzBIl.d.cts} +185 -15
  11. package/dist/{capture-session-v3-BJ8ciaWl.d.ts → capture-session-v3-ZO0QOeQH.d.ts} +185 -15
  12. package/dist/chunk-234OZEDB.js +1 -0
  13. package/dist/chunk-33KKMPJ5.js +1 -0
  14. package/dist/chunk-53POX7U4.js +1 -0
  15. package/dist/chunk-7Q4YPMAF.js +1 -0
  16. package/dist/chunk-A3FUGHAH.js +2 -0
  17. package/dist/chunk-B2X33ZW2.js +1 -0
  18. package/dist/chunk-CJHMFPL6.js +1 -0
  19. package/dist/chunk-CQ7SKLMC.js +1 -0
  20. package/dist/chunk-DFTCAWMP.js +1 -0
  21. package/dist/chunk-DK5YPBDQ.js +1 -0
  22. package/dist/chunk-FPXL63KZ.js +1 -0
  23. package/dist/chunk-FUHDOEBP.js +1 -0
  24. package/dist/chunk-G6LKLN4U.js +1 -0
  25. package/dist/chunk-GI3UFGRQ.js +1 -0
  26. package/dist/chunk-GT2ZLGF7.js +1 -0
  27. package/dist/chunk-H3HVCWLF.js +1 -0
  28. package/dist/chunk-MXWLCDFX.js +1 -0
  29. package/dist/chunk-O5WKNZ2C.js +1 -0
  30. package/dist/chunk-OKWG3PVH.js +1 -0
  31. package/dist/chunk-P3H3D33O.js +1 -0
  32. package/dist/chunk-P6UP4UQY.js +1 -0
  33. package/dist/chunk-POIQGEZM.js +1 -0
  34. package/dist/chunk-QYYJLXKA.js +1 -0
  35. package/dist/chunk-RI3E7GBN.js +1 -0
  36. package/dist/chunk-SMKCBUJL.js +1 -0
  37. package/dist/chunk-SNACCYTL.js +1 -0
  38. package/dist/chunk-TDLIXFDT.js +1 -0
  39. package/dist/chunk-TQB3URP2.js +1 -0
  40. package/dist/chunk-VIAT4DEA.js +1 -0
  41. package/dist/chunk-ZADZTM3M.js +1 -0
  42. package/dist/chunk-ZNIZACXD.js +1 -0
  43. package/dist/client/index.cjs +1 -357
  44. package/dist/client/index.d.cts +6 -37
  45. package/dist/client/index.d.ts +6 -37
  46. package/dist/client/index.js +1 -15
  47. package/dist/core/index.cjs +1 -1605
  48. package/dist/core/index.d.cts +5 -4
  49. package/dist/core/index.d.ts +5 -4
  50. package/dist/core/index.js +1 -139
  51. package/dist/core/ocr/worker.bundle.js +42 -0
  52. package/dist/core/ocr/worker.cjs +42 -0
  53. package/dist/core/ocr/worker.d.cts +84 -0
  54. package/dist/core/ocr/worker.d.ts +84 -0
  55. package/dist/core/ocr/worker.js +41 -0
  56. package/dist/core/v3/detect-worker.cjs +1 -392
  57. package/dist/core/v3/detect-worker.d.cts +1 -1
  58. package/dist/core/v3/detect-worker.d.ts +1 -1
  59. package/dist/core/v3/detect-worker.js +1 -13
  60. package/dist/create-document-capture-23R2F47A.js +1 -0
  61. package/dist/create-portrait-capture-AGFHECK7.js +1 -0
  62. package/dist/create-verification-CXhXxknV.d.cts +3313 -0
  63. package/dist/create-verification-KlHIU4Fy.d.ts +3313 -0
  64. package/dist/{detect-worker-CKXHlXx9.d.cts → detect-worker-DclNxkZT.d.cts} +6 -0
  65. package/dist/{detect-worker-CKXHlXx9.d.ts → detect-worker-DclNxkZT.d.ts} +6 -0
  66. package/dist/detector-scanic-YCDNLCGV.js +1 -0
  67. package/dist/icao-gate-DI8VePWd.d.ts +566 -0
  68. package/dist/icao-gate-DvzOzHq6.d.cts +566 -0
  69. package/dist/icao-gate-T3BTOKFJ.js +1 -0
  70. package/dist/icao-policy-DztbA50-.d.ts +71 -0
  71. package/dist/icao-policy-MRB8NMAu.d.cts +71 -0
  72. package/dist/icao-tuning-4ETMF53W.js +1 -0
  73. package/dist/index.cjs +1 -2636
  74. package/dist/index.d.cts +110 -5
  75. package/dist/index.d.ts +110 -5
  76. package/dist/index.js +1 -28
  77. package/dist/internal/index.cjs +1 -4166
  78. package/dist/internal/index.d.cts +369 -324
  79. package/dist/internal/index.d.ts +369 -324
  80. package/dist/internal/index.js +1 -647
  81. package/dist/keyframe-rank-YAJLYJYF.js +1 -0
  82. package/dist/landmarker-KB7LVXAU.js +1 -0
  83. package/dist/mrz-band-VYHOTDHY.js +1 -0
  84. package/dist/plan-runner-NUWONT7F.js +1 -0
  85. package/dist/popup/index.cjs +1 -76
  86. package/dist/popup/index.d.cts +8 -2
  87. package/dist/popup/index.d.ts +8 -2
  88. package/dist/popup/index.js +1 -11
  89. package/dist/print-AYSCRSZB.js +1 -0
  90. package/dist/scanic-ml-stub-KW7IZHUT.js +1 -0
  91. package/dist/segmenter-USLNBX65.js +1 -0
  92. package/dist/turnstile-FATNZ4AG.js +1 -0
  93. package/dist/types-C_XP92JQ.d.cts +1732 -0
  94. package/dist/types-C_XP92JQ.d.ts +1732 -0
  95. package/dist/upload-file-UYXOHCRG.js +1 -0
  96. package/package.json +27 -11
  97. package/sbom.cdx.json +234 -0
  98. package/dist/capture-constraints-BujkZcfb.d.cts +0 -21
  99. package/dist/capture-constraints-BujkZcfb.d.ts +0 -21
  100. package/dist/chunk-BPYVZUJA.js +0 -852
  101. package/dist/chunk-BPYVZUJA.js.map +0 -1
  102. package/dist/chunk-LOTAJDRE.js +0 -1094
  103. package/dist/chunk-LOTAJDRE.js.map +0 -1
  104. package/dist/chunk-MWNFSNMP.js +0 -52
  105. package/dist/chunk-MWNFSNMP.js.map +0 -1
  106. package/dist/chunk-NILNKLK6.js +0 -50
  107. package/dist/chunk-NILNKLK6.js.map +0 -1
  108. package/dist/chunk-NWF46H7K.js +0 -359
  109. package/dist/chunk-NWF46H7K.js.map +0 -1
  110. package/dist/chunk-WY6U7AIK.js +0 -193
  111. package/dist/chunk-WY6U7AIK.js.map +0 -1
  112. package/dist/chunk-YVFF4Q4G.js +0 -327
  113. package/dist/chunk-YVFF4Q4G.js.map +0 -1
  114. package/dist/client/index.cjs.map +0 -1
  115. package/dist/client/index.js.map +0 -1
  116. package/dist/core/index.cjs.map +0 -1
  117. package/dist/core/index.js.map +0 -1
  118. package/dist/core/v3/detect-worker.cjs.map +0 -1
  119. package/dist/core/v3/detect-worker.js.map +0 -1
  120. package/dist/create-verification-CjLnJ0w6.d.ts +0 -348
  121. package/dist/create-verification-EnZ13uY4.d.cts +0 -348
  122. package/dist/detector-scanic-4C6IEW2K.js +0 -787
  123. package/dist/detector-scanic-4C6IEW2K.js.map +0 -1
  124. package/dist/hosted-client-BpvBqu9f.d.cts +0 -408
  125. package/dist/hosted-client-BpvBqu9f.d.ts +0 -408
  126. package/dist/index.cjs.map +0 -1
  127. package/dist/index.js.map +0 -1
  128. package/dist/internal/index.cjs.map +0 -1
  129. package/dist/internal/index.js.map +0 -1
  130. package/dist/popup/index.cjs.map +0 -1
  131. package/dist/popup/index.js.map +0 -1
  132. package/dist/scanic-ml-stub-S2OZ6HEF.js +0 -10
  133. package/dist/scanic-ml-stub-S2OZ6HEF.js.map +0 -1
@@ -1,647 +1 @@
1
- import {
2
- AttestationError,
3
- CLIP_MIME_ALLOWLIST,
4
- PROCESSING_POLL_DELAY_MS,
5
- PROCESSING_POLL_MAX,
6
- REGISTRY_RETRY_DELAY_MS,
7
- RETRYABLE_REASONS,
8
- TRANSPORT_REPLAY_ATTEMPTS,
9
- TRANSPORT_REPLAY_DELAY_MS,
10
- TURNSTILE_EXECUTE_TIMEOUT_MS,
11
- TURNSTILE_SCRIPT_SRC,
12
- createLivenessCaptureInternal,
13
- createVerificationInternal,
14
- executeTurnstile,
15
- frontierStep,
16
- isExecutable,
17
- isTerminalView,
18
- loadTurnstile,
19
- mapEngineState,
20
- mapErrorKind,
21
- mapGuidanceHint,
22
- mapSessionResult,
23
- mergeSessionView,
24
- randomUuid,
25
- resetTurnstileForTests,
26
- runLivenessFlow,
27
- runSubmission,
28
- stepOf
29
- } from "../chunk-BPYVZUJA.js";
30
- import {
31
- CENTERED_FACTOR,
32
- CIRCLE_RADIUS_FACTOR,
33
- IN_CIRCLE_FACTOR,
34
- classifyDevice,
35
- mapGetUserMediaError,
36
- probeDevice
37
- } from "../chunk-LOTAJDRE.js";
38
- import "../chunk-YVFF4Q4G.js";
39
- import "../chunk-NWF46H7K.js";
40
- import {
41
- ASPECT_BANDS,
42
- DOC_DETECT_WIDTH,
43
- DOC_GATE_V1_DEFAULTS,
44
- DocGateV1,
45
- MR_DOC_CATALOG,
46
- aspectBand,
47
- quadAreaFrac,
48
- quadBounds,
49
- quadIou
50
- } from "../chunk-WY6U7AIK.js";
51
- import {
52
- EXPOSURE_BAND,
53
- exposure,
54
- meanLuma,
55
- sharpness
56
- } from "../chunk-MWNFSNMP.js";
57
-
58
- // src/core/doc/mrz-band.ts
59
- var MRZ_BAND_DEFAULTS = Object.freeze({
60
- EDGE_LUMA_DELTA: 40,
61
- MIN_ROW_DENSITY: 0.08,
62
- MIN_COLUMN_COVERAGE: 0.6,
63
- MIN_WIDTH_FRAC: 0.55,
64
- MIN_HEIGHT_FRAC: 0.02,
65
- MAX_HEIGHT_FRAC: 0.16,
66
- ROW_MERGE_GAP: 18
67
- });
68
- var COLUMN_BUCKETS = 12;
69
- function detectMrzBand(frame, overrides = {}) {
70
- const t = { ...MRZ_BAND_DEFAULTS, ...overrides };
71
- const { data, width, height } = frame;
72
- if (width < 32 || height < 32) return null;
73
- const qualifies = new Array(height).fill(false);
74
- const density = new Float32Array(height);
75
- const minX = new Int32Array(height).fill(width);
76
- const maxX = new Int32Array(height).fill(-1);
77
- const bucketWidth = width / COLUMN_BUCKETS;
78
- const buckets = new Array(COLUMN_BUCKETS);
79
- for (let y = 0; y < height; y++) {
80
- let edges = 0;
81
- buckets.fill(false);
82
- const rowOffset = y * width * 4;
83
- let previousLuma = 0.299 * (data[rowOffset] ?? 0) + 0.587 * (data[rowOffset + 1] ?? 0) + 0.114 * (data[rowOffset + 2] ?? 0);
84
- for (let x = 1; x < width; x++) {
85
- const i = rowOffset + x * 4;
86
- const luma = 0.299 * (data[i] ?? 0) + 0.587 * (data[i + 1] ?? 0) + 0.114 * (data[i + 2] ?? 0);
87
- if (Math.abs(luma - previousLuma) >= t.EDGE_LUMA_DELTA) {
88
- edges += 1;
89
- buckets[Math.min(COLUMN_BUCKETS - 1, Math.floor(x / bucketWidth))] = true;
90
- if (x < minX[y]) minX[y] = x;
91
- if (x > maxX[y]) maxX[y] = x;
92
- }
93
- previousLuma = luma;
94
- }
95
- density[y] = edges / width;
96
- const coverage = buckets.filter(Boolean).length / COLUMN_BUCKETS;
97
- qualifies[y] = density[y] >= t.MIN_ROW_DENSITY && coverage >= t.MIN_COLUMN_COVERAGE && maxX[y] - minX[y] >= t.MIN_WIDTH_FRAC * width;
98
- }
99
- let best = null;
100
- let runTop = -1;
101
- let lastQualifying = -1;
102
- let runRows = 0;
103
- const flush = (bottom) => {
104
- if (runTop < 0) return;
105
- const bandHeight = bottom - runTop + 1;
106
- if (bandHeight >= t.MIN_HEIGHT_FRAC * height && bandHeight <= t.MAX_HEIGHT_FRAC * height && runRows >= 4 && // at least a few real stroke rows, not a lone edge
107
- (best === null || runRows > best.rows)) {
108
- best = { top: runTop, bottom, rows: runRows };
109
- }
110
- runTop = -1;
111
- runRows = 0;
112
- };
113
- for (let y = 0; y < height; y++) {
114
- if (qualifies[y]) {
115
- if (runTop < 0) runTop = y;
116
- else if (y - lastQualifying > t.ROW_MERGE_GAP) {
117
- flush(lastQualifying);
118
- runTop = y;
119
- }
120
- lastQualifying = y;
121
- runRows += 1;
122
- }
123
- }
124
- flush(lastQualifying);
125
- if (best === null) return null;
126
- const band = best;
127
- let x1 = width;
128
- let x2 = -1;
129
- let densitySum = 0;
130
- let densityRows = 0;
131
- for (let y = band.top; y <= band.bottom; y++) {
132
- if (!qualifies[y]) continue;
133
- if (minX[y] < x1) x1 = minX[y];
134
- if (maxX[y] > x2) x2 = maxX[y];
135
- densitySum += density[y];
136
- densityRows += 1;
137
- }
138
- if (x2 - x1 < t.MIN_WIDTH_FRAC * width) return null;
139
- return {
140
- x: x1,
141
- y: band.top,
142
- width: x2 - x1,
143
- height: band.bottom - band.top + 1,
144
- density: densityRows > 0 ? densitySum / densityRows : 0
145
- };
146
- }
147
-
148
- // src/core/doc/frame-analysis.ts
149
- var DOC_ANALYSIS_DEFAULTS = Object.freeze({
150
- /** Doc area fraction above which the camera is too close (capture would crop). */
151
- MAX_AREA_FRAC: 0.92,
152
- /** Opposite-side length ratio beyond which the view is too oblique. */
153
- TILT_MAX_SIDE_RATIO: 1.3,
154
- /** Specular-pixel fraction at/above which the frame reads as glare. */
155
- GLARE_MAX_SPECULAR_FRAC: 0.025
156
- });
157
- function specularFraction(crop) {
158
- const { data, width, height } = crop;
159
- const pixels = width * height;
160
- if (pixels === 0) return 0;
161
- let hot = 0;
162
- for (let i = 0; i < pixels; i++) {
163
- const o = i * 4;
164
- const luma = 0.299 * (data[o] ?? 0) + 0.587 * (data[o + 1] ?? 0) + 0.114 * (data[o + 2] ?? 0);
165
- if (luma >= 252) hot++;
166
- }
167
- return hot / pixels;
168
- }
169
- function quadTiltRatio(quad) {
170
- const len = (a, b) => Math.hypot(b.x - a.x, b.y - a.y);
171
- const top = len(quad.topLeft, quad.topRight);
172
- const bottom = len(quad.bottomLeft, quad.bottomRight);
173
- const left = len(quad.topLeft, quad.bottomLeft);
174
- const right = len(quad.topRight, quad.bottomRight);
175
- const h = Math.max(top, bottom) / Math.max(1e-6, Math.min(top, bottom));
176
- const v = Math.max(left, right) / Math.max(1e-6, Math.min(left, right));
177
- return Math.max(h, v);
178
- }
179
- function analyzeDocFrame(input) {
180
- const t = { ...DOC_GATE_V1_DEFAULTS, ...input.thresholds };
181
- const a = DOC_ANALYSIS_DEFAULTS;
182
- const { quad, frameWidth, frameHeight, measures } = input;
183
- const bandMode = input.format === "ID-3";
184
- let framing = "ok";
185
- if (quad === null) {
186
- framing = "no_document";
187
- } else if (bandMode) {
188
- const bounds = quadBounds(quad);
189
- const widthFrac = frameWidth > 0 ? bounds.width / frameWidth : 0;
190
- const aspect = bounds.height > 0 ? bounds.width / bounds.height : 0;
191
- if (widthFrac < t.ID3_BAND_MIN_WIDTH_FRAC) framing = "too_far";
192
- else if (edgeClipped(quad, frameWidth, frameHeight, t.EDGE_CLIP_MARGIN_PX)) {
193
- framing = "edge_clipped";
194
- } else if (aspect < t.ID3_BAND_ASPECT_MIN || aspect > t.ID3_BAND_ASPECT_MAX) {
195
- framing = "wrong_shape";
196
- }
197
- } else {
198
- const areaFrac = quadAreaFrac(quad, frameWidth, frameHeight);
199
- const band = aspectBand(input.format);
200
- const bounds = quadBounds(quad);
201
- const aspect = Math.max(bounds.width, bounds.height) / Math.max(1e-6, Math.min(bounds.width, bounds.height));
202
- if (areaFrac < t.MIN_AREA_FRAC) framing = "too_far";
203
- else if (areaFrac > a.MAX_AREA_FRAC) framing = "too_close";
204
- else if (edgeClipped(quad, frameWidth, frameHeight, t.EDGE_CLIP_MARGIN_PX)) {
205
- framing = "edge_clipped";
206
- } else if (Math.abs(aspect - band.center) > band.tolerance) framing = "wrong_shape";
207
- else if (quadTiltRatio(quad) > a.TILT_MAX_SIDE_RATIO) framing = "tilted";
208
- }
209
- const lighting = measures.exposure >= t.GUIDE_EXPOSURE ? "ok" : measures.meanLuma < (EXPOSURE_BAND[0] + EXPOSURE_BAND[1]) / 2 ? "too_dark" : "too_bright";
210
- const blur = measures.sharpness >= t.GUIDE_SHARPNESS ? "ok" : "blurry";
211
- const glare = measures.specularFraction >= a.GLARE_MAX_SPECULAR_FRAC ? "glare" : "ok";
212
- return {
213
- framing,
214
- lighting,
215
- blur,
216
- glare,
217
- acceptable: framing === "ok" && lighting === "ok" && blur === "ok" && glare === "ok"
218
- };
219
- }
220
- function edgeClipped(quad, frameWidth, frameHeight, margin) {
221
- const pts = [quad.topLeft, quad.topRight, quad.bottomRight, quad.bottomLeft];
222
- return pts.some(
223
- (p) => p.x <= margin || p.y <= margin || p.x >= frameWidth - margin || p.y >= frameHeight - margin
224
- );
225
- }
226
-
227
- // src/core/doc/feedback-aggregator.ts
228
- var DOC_FEEDBACK_STATES = Object.freeze({
229
- sensing: { key: "sensing", reticle: "searching", minDurationMs: 900 },
230
- too_far: { key: "too_far", reticle: "coaching", minDurationMs: 1400 },
231
- too_close: { key: "too_close", reticle: "coaching", minDurationMs: 1400 },
232
- edge_clipped: { key: "edge_clipped", reticle: "coaching", minDurationMs: 1400 },
233
- wrong_shape: { key: "wrong_shape", reticle: "coaching", minDurationMs: 1400 },
234
- tilted: { key: "tilted", reticle: "coaching", minDurationMs: 1400 },
235
- too_dark: { key: "too_dark", reticle: "coaching", minDurationMs: 1400 },
236
- too_bright: { key: "too_bright", reticle: "coaching", minDurationMs: 1400 },
237
- blurry: { key: "blurry", reticle: "coaching", minDurationMs: 1400 },
238
- glare: { key: "glare", reticle: "coaching", minDurationMs: 1400 },
239
- hold_still: { key: "hold_still", reticle: "locking", minDurationMs: 900 },
240
- processing: { key: "processing", reticle: "processing", minDurationMs: 800 },
241
- side_captured: { key: "side_captured", reticle: "flip", minDurationMs: 2600 },
242
- captured: { key: "captured", reticle: "done", minDurationMs: 800 }
243
- });
244
- function feedbackVoteOf(analysis) {
245
- if (analysis.framing === "no_document") return "sensing";
246
- if (analysis.framing === "too_far") return "too_far";
247
- if (analysis.framing === "too_close") return "too_close";
248
- if (analysis.framing === "edge_clipped") return "edge_clipped";
249
- if (analysis.framing === "wrong_shape") return "wrong_shape";
250
- if (analysis.framing === "tilted") return "tilted";
251
- if (analysis.lighting === "too_dark") return "too_dark";
252
- if (analysis.lighting === "too_bright") return "too_bright";
253
- if (analysis.glare === "glare") return "glare";
254
- if (analysis.blur === "blurry") return "blurry";
255
- return "hold_still";
256
- }
257
- var DocFeedbackAggregator = class {
258
- constructor(windowMs = 2600, decayPerSecond = 0.35) {
259
- this.windowMs = windowMs;
260
- this.decayPerSecond = decayPerSecond;
261
- this.votes = [];
262
- this.current = DOC_FEEDBACK_STATES.sensing;
263
- this.currentSinceMs = null;
264
- }
265
- reset() {
266
- this.votes = [];
267
- this.current = DOC_FEEDBACK_STATES.sensing;
268
- this.currentSinceMs = null;
269
- }
270
- /** Force a terminal/choreography state (capture fired, side flip, upload). */
271
- force(key, nowMs) {
272
- this.votes = [];
273
- this.current = DOC_FEEDBACK_STATES[key];
274
- this.currentSinceMs = nowMs;
275
- return this.current;
276
- }
277
- /** Cast this frame's vote and return the (possibly held) winning state. */
278
- tick(vote, nowMs) {
279
- if (this.currentSinceMs === null) this.currentSinceMs = nowMs;
280
- this.votes.push({ key: vote, atMs: nowMs });
281
- this.votes = this.votes.filter((v) => nowMs - v.atMs <= this.windowMs);
282
- if (nowMs - this.currentSinceMs < this.current.minDurationMs) return this.current;
283
- const scores = /* @__PURE__ */ new Map();
284
- for (const v of this.votes) {
285
- const ageSeconds = (nowMs - v.atMs) / 1e3;
286
- const weight = this.decayPerSecond ** ageSeconds;
287
- scores.set(v.key, (scores.get(v.key) ?? 0) + weight);
288
- }
289
- let winner = this.current.key;
290
- let best = -1;
291
- for (const [key, score] of scores) {
292
- if (score > best) {
293
- best = score;
294
- winner = key;
295
- }
296
- }
297
- if (winner !== this.current.key) {
298
- this.current = DOC_FEEDBACK_STATES[winner];
299
- this.currentSinceMs = nowMs;
300
- }
301
- return this.current;
302
- }
303
- };
304
-
305
- // src/core/doc/capture-session-doc.ts
306
- var scanicDetect = null;
307
- async function lazyScanicDetect(image) {
308
- if (scanicDetect === null) {
309
- const module_ = await import("../detector-scanic-4C6IEW2K.js");
310
- scanicDetect = module_.detectQuad;
311
- }
312
- return scanicDetect(image);
313
- }
314
- async function mrzBandDetect(image) {
315
- const band = detectMrzBand(image);
316
- if (band === null) return null;
317
- return {
318
- topLeft: { x: band.x, y: band.y },
319
- topRight: { x: band.x + band.width, y: band.y },
320
- bottomRight: { x: band.x + band.width, y: band.y + band.height },
321
- bottomLeft: { x: band.x, y: band.y + band.height }
322
- };
323
- }
324
- function warmDocDetector() {
325
- if (scanicDetect !== null) return;
326
- void import("../detector-scanic-4C6IEW2K.js").then((module_) => {
327
- scanicDetect = module_.detectQuad;
328
- }).catch(() => void 0);
329
- }
330
- var DOC_CADENCE_HZ = Object.freeze({
331
- LOW: 3,
332
- MID: 5,
333
- HIGH: 6
334
- });
335
- var CaptureSessionDoc = class {
336
- constructor(opts) {
337
- this.handlers = /* @__PURE__ */ new Map();
338
- this.stream = null;
339
- this.timer = null;
340
- this.state = "idle";
341
- this.lastGuidance = null;
342
- this.attempt = 0;
343
- this.capturing = false;
344
- this.feedback = new DocFeedbackAggregator();
345
- this.lastFeedbackKey = null;
346
- this.opts = opts;
347
- this.gate = new DocGateV1(opts.format ?? "ID-1", opts.thresholds);
348
- const deviceClass = opts.deviceClass ?? classifyDevice(probeDevice());
349
- this.cadenceMs = 1e3 / DOC_CADENCE_HZ[deviceClass];
350
- }
351
- on(event, handler) {
352
- let set = this.handlers.get(event);
353
- if (!set) {
354
- set = /* @__PURE__ */ new Set();
355
- this.handlers.set(event, set);
356
- }
357
- set.add(handler);
358
- return () => set?.delete(handler);
359
- }
360
- emit(event, payload) {
361
- for (const handler of [...this.handlers.get(event) ?? []]) {
362
- handler(payload);
363
- }
364
- }
365
- async start() {
366
- const attempt = ++this.attempt;
367
- this.gate.reset();
368
- this.feedback.reset();
369
- this.lastFeedbackKey = null;
370
- this.lastGuidance = null;
371
- this.capturing = false;
372
- this.setState("preflight");
373
- try {
374
- const getUserMedia = this.opts.getUserMedia ?? ((constraints) => navigator.mediaDevices.getUserMedia(constraints));
375
- this.setState("acquiring");
376
- this.stream = await getUserMedia({
377
- audio: false,
378
- video: {
379
- facingMode: { ideal: "environment" },
380
- width: { ideal: 1920 },
381
- height: { ideal: 1080 }
382
- }
383
- });
384
- if (attempt !== this.attempt) {
385
- for (const track of this.stream.getTracks()) track.stop();
386
- return;
387
- }
388
- this.opts.video.srcObject = this.stream;
389
- await this.opts.video.play().catch(() => void 0);
390
- this.setState("positioning");
391
- this.scheduleTick(attempt);
392
- } catch (err) {
393
- const kind = mapGetUserMediaError(err);
394
- this.setState("error");
395
- this.emit("error", { kind, retryable: true });
396
- }
397
- }
398
- /** Restart the gate for another side / a retake (same stream). */
399
- rearm(side) {
400
- if (side !== void 0) this.opts.side = side;
401
- this.gate.reset();
402
- this.feedback.reset();
403
- this.lastFeedbackKey = null;
404
- this.lastGuidance = null;
405
- this.capturing = false;
406
- if (this.state === "captured") {
407
- this.setState("positioning");
408
- this.scheduleTick(this.attempt);
409
- }
410
- }
411
- destroy() {
412
- this.attempt += 1;
413
- if (this.timer !== null) (this.opts.clearTimer ?? clearTimeout)(this.timer);
414
- this.timer = null;
415
- if (this.stream) for (const track of this.stream.getTracks()) track.stop();
416
- this.stream = null;
417
- this.opts.video.srcObject = null;
418
- }
419
- setState(state) {
420
- this.state = state;
421
- this.emit("statechange", { state });
422
- }
423
- scheduleTick(attempt) {
424
- const setTimer = this.opts.setTimer ?? setTimeout;
425
- this.timer = setTimer(() => void this.tick(attempt), this.cadenceMs);
426
- }
427
- async tick(attempt) {
428
- if (attempt !== this.attempt || this.state !== "positioning" || this.capturing) return;
429
- const now = this.opts.now ?? (() => performance.now());
430
- const grab = this.opts.grabDetectFrame ?? defaultGrabDetectFrame;
431
- const detect = this.opts.detect ?? ((this.opts.format ?? "ID-1") === "ID-3" ? mrzBandDetect : lazyScanicDetect);
432
- const frame = grab(this.opts.video, DOC_DETECT_WIDTH);
433
- if (frame === null) {
434
- this.scheduleTick(attempt);
435
- return;
436
- }
437
- let quad = null;
438
- try {
439
- quad = await detect(frame);
440
- } catch {
441
- quad = null;
442
- }
443
- if (attempt !== this.attempt) return;
444
- const crop = quad !== null ? cropQuadRegion(frame, quad) : frame;
445
- const atMs = now();
446
- const measures = {
447
- sharpness: sharpness(crop),
448
- exposure: exposure(crop),
449
- meanLuma: meanLuma(crop),
450
- specularFraction: specularFraction(crop)
451
- };
452
- const analysis = analyzeDocFrame({
453
- format: this.opts.format ?? "ID-1",
454
- quad,
455
- frameWidth: frame.width,
456
- frameHeight: frame.height,
457
- measures,
458
- ...this.opts.thresholds !== void 0 ? { thresholds: this.opts.thresholds } : {}
459
- });
460
- const tick = this.gate.tick({
461
- timestampMs: atMs,
462
- quad,
463
- quality: measures,
464
- frameWidth: frame.width,
465
- frameHeight: frame.height
466
- });
467
- this.emit("checks", {
468
- engine: "docv1",
469
- p: tick.p,
470
- plausible: tick.plausible,
471
- stableTicks: tick.stableTicks,
472
- quad: tick.quad,
473
- frameWidth: frame.width,
474
- frameHeight: frame.height,
475
- analysis
476
- });
477
- const feedbackState = this.feedback.tick(feedbackVoteOf(analysis), atMs);
478
- if (feedbackState.key !== this.lastFeedbackKey) {
479
- this.lastFeedbackKey = feedbackState.key;
480
- this.emit("feedback", feedbackState);
481
- }
482
- if (tick.guidanceKey !== this.lastGuidance) {
483
- this.lastGuidance = tick.guidanceKey;
484
- this.emit("guidance", { key: tick.guidanceKey });
485
- }
486
- if (tick.ready && quad !== null) {
487
- const processing = this.feedback.force("processing", atMs);
488
- this.lastFeedbackKey = processing.key;
489
- this.emit("feedback", processing);
490
- await this.fire(attempt, quad, {
491
- width: frame.width,
492
- height: frame.height,
493
- tickSharpness: measures.sharpness
494
- });
495
- return;
496
- }
497
- this.scheduleTick(attempt);
498
- }
499
- /**
500
- * BEST-FRAME capture window (capture-v2): the first ready tick captures a
501
- * candidate immediately, then up to CAPTURE_EXTRA_CANDIDATES more stills are
502
- * taken at CAPTURE_CANDIDATE_SPACING_MS while the user holds — each scored
503
- * by the live detect-tick sharpness at its capture moment — and the SHARPEST
504
- * wins. Beats first-acceptable-frame capture without decoding stills.
505
- */
506
- async fire(attempt, quad, detectSize) {
507
- this.capturing = true;
508
- const capture = this.opts.captureStill ?? defaultCaptureStill;
509
- const grab = this.opts.grabDetectFrame ?? defaultGrabDetectFrame;
510
- const setTimer = this.opts.setTimer ?? setTimeout;
511
- const size = { width: detectSize.width, height: detectSize.height };
512
- try {
513
- let best = {
514
- still: await capture(this.opts.video, quad, size),
515
- sharpness: detectSize.tickSharpness
516
- };
517
- for (let i = 0; i < CAPTURE_EXTRA_CANDIDATES; i++) {
518
- await new Promise((resolve) => {
519
- setTimer(() => resolve(), CAPTURE_CANDIDATE_SPACING_MS);
520
- });
521
- if (attempt !== this.attempt) return;
522
- const frame = grab(this.opts.video, DOC_DETECT_WIDTH);
523
- if (frame === null) continue;
524
- const candidateSharpness = sharpness(cropQuadRegion(frame, quad));
525
- if (candidateSharpness > best.sharpness * CAPTURE_IMPROVEMENT_MIN_RATIO) {
526
- const still = await capture(this.opts.video, quad, size);
527
- if (attempt !== this.attempt) return;
528
- best = { still, sharpness: candidateSharpness };
529
- }
530
- }
531
- if (attempt !== this.attempt) return;
532
- this.setState("captured");
533
- this.emit("artifacts", {
534
- keyframe: best.still.blob,
535
- previewDataUrl: best.still.previewDataUrl,
536
- ...this.opts.side !== void 0 ? { side: this.opts.side } : {}
537
- });
538
- } catch {
539
- if (attempt !== this.attempt) return;
540
- this.capturing = false;
541
- this.gate.reset();
542
- this.scheduleTick(attempt);
543
- }
544
- }
545
- };
546
- var CAPTURE_EXTRA_CANDIDATES = 2;
547
- var CAPTURE_CANDIDATE_SPACING_MS = 260;
548
- var CAPTURE_IMPROVEMENT_MIN_RATIO = 1.08;
549
- function defaultGrabDetectFrame(video, targetWidth) {
550
- const vw = video.videoWidth;
551
- const vh = video.videoHeight;
552
- if (vw === 0 || vh === 0) return null;
553
- const scale = Math.min(1, targetWidth / vw);
554
- const width = Math.round(vw * scale);
555
- const height = Math.round(vh * scale);
556
- const canvas = document.createElement("canvas");
557
- canvas.width = width;
558
- canvas.height = height;
559
- const context = canvas.getContext("2d", { willReadFrequently: true });
560
- if (context === null) return null;
561
- context.drawImage(video, 0, 0, width, height);
562
- return context.getImageData(0, 0, width, height);
563
- }
564
- async function defaultCaptureStill(video, _quad, _detectSize) {
565
- const canvas = document.createElement("canvas");
566
- canvas.width = Math.max(1, video.videoWidth);
567
- canvas.height = Math.max(1, video.videoHeight);
568
- const context = canvas.getContext("2d");
569
- if (context === null) throw new Error("2d context unavailable");
570
- context.drawImage(video, 0, 0, canvas.width, canvas.height);
571
- const blob = await new Promise((resolve, reject) => {
572
- canvas.toBlob((b) => b ? resolve(b) : reject(new Error("toBlob failed")), "image/jpeg", 0.92);
573
- });
574
- return { blob, previewDataUrl: canvas.toDataURL("image/jpeg", 0.85) };
575
- }
576
- function cropQuadRegion(frame, quad) {
577
- const xs = [quad.topLeft.x, quad.topRight.x, quad.bottomRight.x, quad.bottomLeft.x];
578
- const ys = [quad.topLeft.y, quad.topRight.y, quad.bottomRight.y, quad.bottomLeft.y];
579
- const x1 = Math.max(0, Math.floor(Math.min(...xs)));
580
- const y1 = Math.max(0, Math.floor(Math.min(...ys)));
581
- const x2 = Math.min(frame.width, Math.ceil(Math.max(...xs)));
582
- const y2 = Math.min(frame.height, Math.ceil(Math.max(...ys)));
583
- const width = Math.max(1, x2 - x1);
584
- const height = Math.max(1, y2 - y1);
585
- const data = new Uint8ClampedArray(width * height * 4);
586
- for (let row = 0; row < height; row++) {
587
- const src = ((y1 + row) * frame.width + x1) * 4;
588
- data.set(frame.data.subarray(src, src + width * 4), row * width * 4);
589
- }
590
- return { data, width, height, colorSpace: frame.colorSpace };
591
- }
592
- export {
593
- ASPECT_BANDS,
594
- AttestationError,
595
- CAPTURE_CANDIDATE_SPACING_MS,
596
- CAPTURE_EXTRA_CANDIDATES,
597
- CENTERED_FACTOR,
598
- CIRCLE_RADIUS_FACTOR,
599
- CLIP_MIME_ALLOWLIST,
600
- CaptureSessionDoc,
601
- DOC_ANALYSIS_DEFAULTS,
602
- DOC_CADENCE_HZ,
603
- DOC_DETECT_WIDTH,
604
- DOC_FEEDBACK_STATES,
605
- DOC_GATE_V1_DEFAULTS,
606
- DocFeedbackAggregator,
607
- DocGateV1,
608
- IN_CIRCLE_FACTOR,
609
- MRZ_BAND_DEFAULTS,
610
- MR_DOC_CATALOG,
611
- PROCESSING_POLL_DELAY_MS,
612
- PROCESSING_POLL_MAX,
613
- REGISTRY_RETRY_DELAY_MS,
614
- RETRYABLE_REASONS,
615
- TRANSPORT_REPLAY_ATTEMPTS,
616
- TRANSPORT_REPLAY_DELAY_MS,
617
- TURNSTILE_EXECUTE_TIMEOUT_MS,
618
- TURNSTILE_SCRIPT_SRC,
619
- analyzeDocFrame,
620
- aspectBand,
621
- createLivenessCaptureInternal,
622
- createVerificationInternal,
623
- detectMrzBand,
624
- executeTurnstile,
625
- feedbackVoteOf,
626
- frontierStep,
627
- isExecutable,
628
- isTerminalView,
629
- loadTurnstile,
630
- mapEngineState,
631
- mapErrorKind,
632
- mapGuidanceHint,
633
- mapSessionResult,
634
- mergeSessionView,
635
- quadAreaFrac,
636
- quadBounds,
637
- quadIou,
638
- quadTiltRatio,
639
- randomUuid,
640
- resetTurnstileForTests,
641
- runLivenessFlow,
642
- runSubmission,
643
- specularFraction,
644
- stepOf,
645
- warmDocDetector
646
- };
647
- //# sourceMappingURL=index.js.map
1
+ import{c as _e,d as Le,e as Re,h as Se,i as Te,j as ce}from"../chunk-234OZEDB.js";import{a as Vt,b as Xt,c as Zt,d as Jt,e as Qt,f as jt,g as qt,h as $t,i as er,j as ae,k as se,m as Ee,n as me}from"../chunk-ZNIZACXD.js";import{a as Nt,b as vt,c as gt,d as bt,e as Gt,f as ht,g as Ut,h as Yt,i as Ht,j as Wt,k as kt,l as Kt,m as Bt}from"../chunk-53POX7U4.js";import{a as wt,b as zt}from"../chunk-33KKMPJ5.js";import{b as pe,c as ie,d as ne}from"../chunk-CJHMFPL6.js";import"../chunk-RI3E7GBN.js";import"../chunk-GI3UFGRQ.js";import{a as d,b as M,c as F,d as N,e as v}from"../chunk-O5WKNZ2C.js";import{A as yt,B as ft,C as ut,D as Ot,E as At,F as It,G as xt,H as Ct,I as Pt,J as Dt,K as dt,L as Mt,M as Ft,a as We,b as ke,c as Ke,d as Je,e as Qe,f as je,g as qe,h as $e,i as et,j as tt,k as rt,l as ot,m as pt,n as it,o as nt,p as at,q as st,r as Et,s as mt,t as _t,u as Lt,v as Rt,w as St,x as Tt,y as ct,z as lt}from"../chunk-P6UP4UQY.js";import{a as Ye,b as He}from"../chunk-SMKCBUJL.js";import{a as Be,b as we,c as ze,d as Ve,e as Xe,f as Ze}from"../chunk-MXWLCDFX.js";import{a as k,b as Fe,c as Ne,d as ve,e as ge,f as be,g as Ge,h as he,i as Ue,j as K,k as B,l as w,m as Z,n as J,o as Q,p as j,q,r as $,s as ee,t as te,u as re,x as oe}from"../chunk-QYYJLXKA.js";import{a as g,b,c as G,d as h,e as U,f as Y,g as H,h as W,i as z,j as V,l as X}from"../chunk-G6LKLN4U.js";import{a as xe,b as Ce,c as Pe,d as De,e as de,f as Me}from"../chunk-TDLIXFDT.js";import{b as ye,c as fe,d as ue,e as Oe,g as Ae,h as tr,i as rr,j as or,k as pr,l as ir,m as nr,s as Ie}from"../chunk-ZADZTM3M.js";import{A as P,B as D,g as S,m as T,n as c,o as l,p as y,s as f,u,v as O,w as A,x as I,y as x,z as C}from"../chunk-H3HVCWLF.js";import{a as i,b as n,c as a,d as s,i as E,j as m,k as _,l as L,n as R}from"../chunk-P3H3D33O.js";import"../chunk-GT2ZLGF7.js";import"../chunk-7Q4YPMAF.js";import{c as e,d as t,f as r,g as o,h as p}from"../chunk-FUHDOEBP.js";import"../chunk-POIQGEZM.js";import"../chunk-CQ7SKLMC.js";import"../chunk-FPXL63KZ.js";import"../chunk-B2X33ZW2.js";import"../chunk-VIAT4DEA.js";import"../chunk-OKWG3PVH.js";import{a as le}from"../chunk-DFTCAWMP.js";import"../chunk-DK5YPBDQ.js";export{ae as ANALYSIS_LONG_EDGE,xe as ASPECT_BANDS,C as AttestationError,Ge as BLUR_REFUSE_SHARPNESS_MAX,Ft as CAPTURE_CANDIDATE_SPACING_MS,Mt as CAPTURE_EXTRA_CANDIDATES,p as CENTERED_FACTOR,r as CIRCLE_RADIUS_FACTOR,Vt as CLIPPED_LUMA,u as CLIP_MIME_ALLOWLIST,Dt as CaptureSessionDoc,rr as DOCUMENT_TYPE_ORDER,Je as DOC_ANALYSIS_DEFAULTS,At as DOC_BLACK_FRAME_LUMA,It as DOC_BLACK_FRAME_TICKS,xt as DOC_CADENCE_HZ,$e as DOC_CAMERA_TUNING_DEFAULTS,de as DOC_CATALOG,Be as DOC_DETECT_WIDTH,We as DOC_FEEDBACK_STATES,Ot as DOC_FIRST_FRAME_MS,we as DOC_GATE_V1_DEFAULTS,Ct as DOC_SHUTTER_DEFAULTS,X as DocAssist,Ke as DocFeedbackAggregator,Ze as DocGateV1,Rt as EMPTY_GUIDE_METRICS,Ne as FLIP_FILL_MIN,Fe as FLIP_GAP_MS,ve as FLIP_TIMEOUT_MS,lt as GUIDE_LOCK_DEFAULTS,ft as GuideLock,bt as ICAO_CANVAS,wt as ICAO_FALLBACK,Yt as ICAO_GATE_CRITERIA,Xt as ICAO_SHARP_REF,I as INFERENCE_RETRY_ATTEMPTS,x as INFERENCE_RETRY_DEFAULT_S,o as IN_CIRCLE_FACTOR,tr as ISSUER_CODES,pe as LANDMARKER_MODEL,ot as LENS_STORAGE_KEY,_t as LENS_TRY_MAX,V as LIVE_MRZ_DEFAULTS,Le as LIVE_PHOTO_IDLE_MS,_e as LIVE_PHOTO_MAX_HZ,ge as MANUAL_SHUTTER_MS,Ye as MRZ_BAND_DEFAULTS,De as MR_DOC_CATALOG,be as NO_REPORT_MS,le as OCR_ASSET_SET,Te as OTP_RESEND_COOLDOWN_MS,se as PORTRAIT_JPEG_QUALITY,i as PRELOAD_BLAZE_INIT_TIMEOUT_MS,n as PRELOAD_BUDGET_MS,Se as PROCESSING_BACKOFF_MS,fe as PROCESSING_POLL_DELAY_MS,ue as PROCESSING_POLL_MAX,G as REGION_PAD,ye as REGISTRY_RETRY_DELAY_MS,S as RETRYABLE_REASONS,re as SAME_FACE_MAX_DROPS,g as SHARPNESS_LONG_EDGE,z as TEXT_LOCK_DEFAULTS,O as TRANSPORT_REPLAY_ATTEMPTS,A as TRANSPORT_REPLAY_DELAY_MS,M as TURNSTILE_EXECUTE_TIMEOUT_MS,d as TURNSTILE_SCRIPT_SRC,Q as WEB_OCR_ENGINE,pr as acceptedIssuers,or as acceptedTypesFor,qe as analyzeDocFrame,Tt as analyzeGuide,Ce as aspectBand,Pe as aspectFits,qt as backgroundStats,$ as browserFamily,Z as buildDeviceReadHint,B as classifyCardSide,K as classifyCardSideWith,st as coverPointToVideo,oe as createDocumentCaptureInternal,ne as createFaceLandmarker,Bt as createIcaoGate,Re as createLivePhotoKit,R as createLivenessCaptureInternal,me as createPortraitCaptureInternal,ce as createStepRunner,Ae as createVerificationInternal,U as cropImage,e as detectFormFactor,t as detectIsMobile,He as detectMrzBand,Et as docZoomFor,k as encodeDocumentImage,v as executeTurnstile,gt as eyeLineRoll,Wt as eyeOpenness,jt as eyeSpecular,Nt as faceGeometry,Qt as faceLighting,$t as faceSharpness,ie as facesOf,ke as feedbackVoteOf,nr as flagOf,mt as focusOk,te as formatMismatch,l as frontierStep,ct as guideQuad,St as guideRegionInFrame,er as icaoPixelStats,Gt as icaoWindow,he as initialScanState,T as isExecutable,c as isTerminalView,Ht as judgeIcao,tt as lensKindOf,ee as liveMrzWireReport,N as loadTurnstile,Zt as lumaPlane,_ as mapEngineState,L as mapErrorKind,m as mapGuidanceHint,f as mapSessionResult,W as measureBitmapSharpness,H as measureRegionSharpness,Ue as nextScanState,Ee as observePortraitFrame,Lt as openDocCamera,dt as passportBandOf,kt as percentile,b as photoSharpness,Ut as portraitCropRegion,Ie as portraitMatchStep,vt as poseFromMatrix,E as preloadedDetectorFactory,ze as quadAreaFrac,Xe as quadBounds,Ve as quadIou,je as quadTiltRatio,Oe as randomUuid,rt as rankBackCameras,pt as readStoredLens,Jt as regionStats,s as resetLivenessAssetsForTests,F as resetTurnstileForTests,Y as resizeLongEdge,ir as resolveAcceptedDocuments,et as resolveDocCameraTuning,Pt as resolveDocShutterTuning,yt as resolveGuideLockTuning,zt as resolveIcaoTuning,j as resolveWebOcrPlan,D as runLivenessFlow,P as runSubmission,Me as scannerFormatFor,Kt as scoreFrame,a as setPreloadLoaderForTests,J as settledHint,at as singleShotFocusAt,Qe as specularFraction,q as startWebOcr,y as stepOf,h as stillRegionOf,w as stillToImageData,nt as supportsFocusMode,ut as warmDocDetector,ht as windowOverflow,it as writeStoredLens};
@@ -0,0 +1 @@
1
+ var C=4,P=600,k=.5,W=30,A={frontal:.1,eyes:.1,score:.05},_=e=>e<0?0:e>1?1:e;function w(e){let r=e.eyes;if(r===void 0)return{frontal:1,yaw:null,roll:null};let a=r.right.x-r.left.x,n=r.right.y-r.left.y,t=a*a+n*n;if(t===0)return{frontal:1,yaw:null,roll:null};let s=Math.abs(Math.atan2(n,Math.abs(a))*180/Math.PI),u=_(1-s/30),o=null,l=e.nose;if(l!==void 0){let m=(r.left.x+r.right.x)/2,f=(r.left.y+r.right.y)/2;o=Math.abs(((l.x-m)*a+(l.y-f)*n)/t),u*=_(1-o/.5)}return{frontal:u,yaw:o,roll:s}}function F(e,r){return e===null?{face:!1,frontal:0,yaw:null,roll:null,eyes:null,score:0,sharpness:r}:{face:!0,...w(e),eyes:null,score:e.score,sharpness:r}}function v(e){let r=e.map((t,s)=>s),a=(t,s)=>{let u=Number.NEGATIVE_INFINITY;for(let o of r)u=Math.max(u,t(e[o]));r=r.filter(o=>t(e[o])>=u-s)};a(t=>t.frontal,A.frontal),a(t=>t.eyes??1,A.eyes),a(t=>t.score,A.score);let n=-1;for(let t of r)(n===-1||e[t].sharpness>e[n].sharpness)&&(n=t);return n}var i=e=>Number.isFinite(e)?Math.round(e*1e3)/1e3:0,D=99,S=999999;function T(e){return{face:e.face,frontal:i(e.frontal),...e.yaw!==null?{yaw:Math.min(i(e.yaw),D)}:{},...e.roll!==null?{roll:i(e.roll)}:{},...e.eyes!==null?{eyes:i(e.eyes)}:{},score:i(e.score),sharpness:Math.min(i(e.sharpness),S)}}var g=I;async function I(e,r){let{options:a}=e,n=a.video,t=a.now??(()=>performance.now()),s=a.captureKeyframe??(c=>e.defaultKeyframe(c)),u=600/3,o=[],l=[],m=0;for(let c=0;c<4;c+=1){if(r!==e.attempt)return null;let d=e.detector,E=Promise.resolve(null),p,y=0;try{if(d!==null){let b=e.profiler?.profile.inputWidth??160,R=a.makeSnapshot?.(n,b)??e.defaultSnapshot(n,b);p=s(n).then(K=>(y=t(),K));let N=t();E=d.detect(R,n.videoWidth,n.videoHeight).then(K=>(m+=t()-N,K),()=>null)}else p=s(n).then(b=>(y=t(),b));let[h,O]=await Promise.all([p,E]);o.push(h),l.push(F(O,h.sharpness))}catch{p?.catch(()=>{})}let M=y>0?Math.max(0,t()-y):0;c<3&&await new Promise(h=>setTimeout(h,Math.max(0,u-M)))}if(r!==e.attempt)return null;let f=v(l);if(f===-1)return null;let x=0;l.forEach((c,d)=>{c.sharpness>l[x].sharpness&&(x=d)});try{a.telemetry?.({type:"keyframe",tier:e.detector?.tier??null,chosen:f,sharpest:x,detectMs:Math.round(m),candidates:l.map(T)})}catch{}return o[f]??null}export{C as RANK_CANDIDATES,A as RANK_TOLERANCE,P as RANK_WINDOW_MS,W as ROLL_ZERO_DEG,S as SHARPNESS_REPORT_MAX,D as YAW_REPORT_MAX,k as YAW_ZERO_IOD,I as collectRankedKeyframes,g as default,F as featuresOf,w as frontalOf,v as rankKeyframes};
@@ -0,0 +1 @@
1
+ import{a,b,c,d}from"./chunk-CJHMFPL6.js";export{a as LANDMARKER_INIT_TIMEOUT_MS,b as LANDMARKER_MODEL,d as createFaceLandmarker,c as facesOf};
@@ -0,0 +1 @@
1
+ import{a,b}from"./chunk-SMKCBUJL.js";export{a as MRZ_BAND_DEFAULTS,b as detectMrzBand};