@sekyro/web 0.1.0-rc.6 → 0.1.0-rc.8

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