@yenio-pld/blocks 1.2.0-rc.32 → 1.2.0-rc.33

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.
package/dist/kyc.cjs ADDED
@@ -0,0 +1,1580 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var lucideReact = require('lucide-react');
5
+ var react = require('react');
6
+ var button_js = require('./ui/button.js');
7
+ var drawer_js = require('./ui/drawer.js');
8
+ var jsxRuntime = require('react/jsx-runtime');
9
+ var clsx = require('clsx');
10
+ var tailwindMerge = require('tailwind-merge');
11
+ var progress_js = require('./ui/progress.js');
12
+ var sonner_js = require('./ui/sonner.js');
13
+
14
+ // src/components/kyc/kyc-capture.ts
15
+ var KYC_IMAGE_MAX_SIDE = 1600;
16
+ var KYC_BLUR_MIN = 80;
17
+ var KYC_DARK_MAX_MEAN = 40;
18
+ var GUIDE_SAMPLE_WIDTH = 320;
19
+ var GUIDE_EDGE_MARGIN = 0.15;
20
+ var EDGE_BAND_X = 0.08;
21
+ var EDGE_BAND_Y = 0.1;
22
+ var EDGE_SPAN = 0.6;
23
+ var EDGE_SEGMENTS = 3;
24
+ var EDGE_SEGMENTS_NEEDED = 2;
25
+ var EDGE_MIN_STRENGTH = 50;
26
+ var EDGE_MIN_CONTRAST = 4;
27
+ var GUIDE_INTERIOR_INSET = 0.12;
28
+ var SHARPNESS_SAMPLE_WIDTH = 800;
29
+ var KYC_SHARPNESS_MIN = 20;
30
+ var FOCUS_PLATEAU_RATIO = 0.8;
31
+ var FOCUS_SETTLE_SAMPLES = 3;
32
+ var FOCUS_WINDOW_MS = 1200;
33
+ var SHARPEST_FRAME_MAX_AGE_MS = 500;
34
+ var AUTO_CAPTURE_SAMPLE_HZ = 8;
35
+ var AUTO_CAPTURE_READY_COUNT = 4;
36
+ function assessGrayPixels(gray, width, height, blurMin = KYC_BLUR_MIN) {
37
+ if (width < 3 || height < 3 || gray.length < width * height) {
38
+ return { blurScore: 0, meanLuma: 0, tooBlurry: true, tooDark: true };
39
+ }
40
+ let sum = 0;
41
+ for (let i = 0; i < width * height; i += 1) sum += gray[i] ?? 0;
42
+ const meanLuma = sum / (width * height);
43
+ let lapSum = 0;
44
+ let lapSq = 0;
45
+ let count = 0;
46
+ for (let y = 1; y < height - 1; y += 1) {
47
+ for (let x = 1; x < width - 1; x += 1) {
48
+ const i = y * width + x;
49
+ const value = -(gray[i - width] ?? 0) - (gray[i - 1] ?? 0) + 4 * (gray[i] ?? 0) - (gray[i + 1] ?? 0) - (gray[i + width] ?? 0);
50
+ lapSum += value;
51
+ lapSq += value * value;
52
+ count += 1;
53
+ }
54
+ }
55
+ const mean = count === 0 ? 0 : lapSum / count;
56
+ const blurScore = count === 0 ? 0 : lapSq / count - mean * mean;
57
+ return {
58
+ blurScore,
59
+ meanLuma,
60
+ tooBlurry: blurScore < blurMin,
61
+ tooDark: meanLuma < KYC_DARK_MAX_MEAN
62
+ };
63
+ }
64
+ function rgbaToGray(rgba, pixelCount) {
65
+ const gray = new Float64Array(pixelCount);
66
+ for (let i = 0; i < pixelCount; i += 1) {
67
+ const o = i * 4;
68
+ gray[i] = 0.299 * (rgba[o] ?? 0) + 0.587 * (rgba[o + 1] ?? 0) + 0.114 * (rgba[o + 2] ?? 0);
69
+ }
70
+ return gray;
71
+ }
72
+ function assessImageData(image) {
73
+ return assessGrayPixels(
74
+ rgbaToGray(image.data, image.width * image.height),
75
+ image.width,
76
+ image.height
77
+ );
78
+ }
79
+ function segmentHasEdge(gray, width, vertical, a0, a1, s0, s1) {
80
+ const at = (x, y) => gray[y * width + x] ?? 0;
81
+ const profile = [];
82
+ for (let a = a0; a <= a1; a += 1) {
83
+ let sum = 0;
84
+ for (let s = s0; s <= s1; s += 1) {
85
+ const x = vertical ? a : s;
86
+ const y = vertical ? s : a;
87
+ sum += vertical ? at(x + 1, y - 1) + 2 * at(x + 1, y) + at(x + 1, y + 1) - at(x - 1, y - 1) - 2 * at(x - 1, y) - at(x - 1, y + 1) : at(x - 1, y + 1) + 2 * at(x, y + 1) + at(x + 1, y + 1) - at(x - 1, y - 1) - 2 * at(x, y - 1) - at(x + 1, y - 1);
88
+ }
89
+ profile.push(Math.abs(sum / (s1 - s0 + 1)));
90
+ }
91
+ let peak = 0;
92
+ for (let i = 0; i < profile.length; i += 1) {
93
+ const here = profile[i] ?? 0;
94
+ peak = Math.max(
95
+ peak,
96
+ ((profile[i - 1] ?? here) + here + (profile[i + 1] ?? here)) / 3
97
+ );
98
+ }
99
+ const sorted = [...profile].sort((x, y) => x - y);
100
+ const median = sorted[Math.floor(sorted.length / 2)] ?? 0;
101
+ return peak >= EDGE_MIN_STRENGTH && peak >= EDGE_MIN_CONTRAST * Math.max(median, 4);
102
+ }
103
+ function hasEdgeOnSide(gray, width, height, vertical, center, halfBand, spanFrom, spanTo) {
104
+ const acrossMax = vertical ? width - 2 : height - 2;
105
+ const alongMax = vertical ? height - 2 : width - 2;
106
+ const a0 = Math.max(1, Math.round(center - halfBand));
107
+ const a1 = Math.min(acrossMax, Math.round(center + halfBand));
108
+ if (a1 - a0 < 2) return false;
109
+ const segment = (spanTo - spanFrom) / EDGE_SEGMENTS;
110
+ let passed = 0;
111
+ for (let i = 0; i < EDGE_SEGMENTS; i += 1) {
112
+ const s0 = Math.max(1, Math.round(spanFrom + i * segment));
113
+ const s1 = Math.min(alongMax, Math.round(spanFrom + (i + 1) * segment));
114
+ if (s1 - s0 >= 2 && segmentHasEdge(gray, width, vertical, a0, a1, s0, s1))
115
+ passed += 1;
116
+ }
117
+ return passed >= EDGE_SEGMENTS_NEEDED;
118
+ }
119
+ function countGuideEdges(gray, width, height, guide) {
120
+ const bandX = guide.width * EDGE_BAND_X;
121
+ const bandY = guide.height * EDGE_BAND_Y;
122
+ const vFrom = guide.y + guide.height * (1 - EDGE_SPAN) / 2;
123
+ const vTo = guide.y + guide.height * (1 + EDGE_SPAN) / 2;
124
+ const hFrom = guide.x + guide.width * (1 - EDGE_SPAN) / 2;
125
+ const hTo = guide.x + guide.width * (1 + EDGE_SPAN) / 2;
126
+ const sides = [
127
+ hasEdgeOnSide(gray, width, height, true, guide.x, bandX, vFrom, vTo),
128
+ hasEdgeOnSide(
129
+ gray,
130
+ width,
131
+ height,
132
+ true,
133
+ guide.x + guide.width,
134
+ bandX,
135
+ vFrom,
136
+ vTo
137
+ ),
138
+ hasEdgeOnSide(gray, width, height, false, guide.y, bandY, hFrom, hTo),
139
+ hasEdgeOnSide(
140
+ gray,
141
+ width,
142
+ height,
143
+ false,
144
+ guide.y + guide.height,
145
+ bandY,
146
+ hFrom,
147
+ hTo
148
+ )
149
+ ];
150
+ return sides.filter(Boolean).length;
151
+ }
152
+ var ID_CARD_ASPECT = 85.6 / 53.98;
153
+ var ID_PREVIEW_ZOOM = 1.28;
154
+ function idGuideLayout(frameWidth, frameHeight) {
155
+ const fw = Math.max(1, frameWidth);
156
+ const fh = Math.max(1, frameHeight);
157
+ const maxW = fw * 0.92;
158
+ const maxH = fh * 0.5;
159
+ let width = maxW;
160
+ let height = width / ID_CARD_ASPECT;
161
+ if (height > maxH) {
162
+ height = maxH;
163
+ width = height * ID_CARD_ASPECT;
164
+ }
165
+ const left = (fw - width) / 2 / fw;
166
+ const top = Math.max(0.08, (fh - height) / 2 / fh - 0.06);
167
+ return {
168
+ left,
169
+ top,
170
+ width: width / fw,
171
+ height: height / fh
172
+ };
173
+ }
174
+ function defaultIdGuideRect(videoWidth, videoHeight) {
175
+ const layout = idGuideLayout(videoWidth, videoHeight);
176
+ return {
177
+ x: layout.left * videoWidth,
178
+ y: layout.top * videoHeight,
179
+ width: Math.max(1, layout.width * videoWidth),
180
+ height: Math.max(1, layout.height * videoHeight)
181
+ };
182
+ }
183
+ function objectCoverVisibleRect(videoWidth, videoHeight, stageWidth, stageHeight, zoom = 1) {
184
+ const vw = Math.max(1, videoWidth);
185
+ const vh = Math.max(1, videoHeight);
186
+ const sw = Math.max(1, stageWidth);
187
+ const sh = Math.max(1, stageHeight);
188
+ const scale = Math.max(sw / vw, sh / vh) * Math.max(1, zoom);
189
+ const width = sw / scale;
190
+ const height = sh / scale;
191
+ return { x: (vw - width) / 2, y: (vh - height) / 2, width, height };
192
+ }
193
+ function idGuideRectForCoveredStage(videoWidth, videoHeight, stageWidth, stageHeight, zoom = 1) {
194
+ const visible = objectCoverVisibleRect(
195
+ videoWidth,
196
+ videoHeight,
197
+ stageWidth,
198
+ stageHeight,
199
+ zoom
200
+ );
201
+ const layout = idGuideLayout(stageWidth, stageHeight);
202
+ return {
203
+ x: visible.x + layout.left * visible.width,
204
+ y: visible.y + layout.top * visible.height,
205
+ width: Math.max(1, layout.width * visible.width),
206
+ height: Math.max(1, layout.height * visible.height)
207
+ };
208
+ }
209
+ var UNUSABLE_IMAGE = {
210
+ blurScore: 0,
211
+ meanLuma: 0,
212
+ tooBlurry: true,
213
+ tooDark: true
214
+ };
215
+ var UNUSABLE_GUIDE = {
216
+ ...UNUSABLE_IMAGE,
217
+ edgesFound: 0,
218
+ aligned: false,
219
+ ready: false
220
+ };
221
+ function frameSize(source) {
222
+ return "videoWidth" in source ? { width: source.videoWidth, height: source.videoHeight } : { width: source.width, height: source.height };
223
+ }
224
+ function grabGray(source, sx, sy, sw, sh, dw, dh) {
225
+ const canvas = document.createElement("canvas");
226
+ canvas.width = dw;
227
+ canvas.height = dh;
228
+ const ctx = canvas.getContext("2d", { willReadFrequently: true });
229
+ if (!ctx) return null;
230
+ ctx.drawImage(source, sx, sy, sw, sh, 0, 0, dw, dh);
231
+ const sample = ctx.getImageData(0, 0, dw, dh);
232
+ canvas.width = 0;
233
+ canvas.height = 0;
234
+ return {
235
+ gray: rgbaToGray(sample.data, sample.width * sample.height),
236
+ width: sample.width,
237
+ height: sample.height
238
+ };
239
+ }
240
+ function assessSharpness(gray, width, height) {
241
+ const w = Math.max(0, width - 1);
242
+ const h = Math.max(0, height - 1);
243
+ const smooth = new Float64Array(w * h);
244
+ for (let y = 0; y < h; y += 1) {
245
+ for (let x = 0; x < w; x += 1) {
246
+ const i = y * width + x;
247
+ smooth[y * w + x] = ((gray[i] ?? 0) + (gray[i + 1] ?? 0) + (gray[i + width] ?? 0) + (gray[i + width + 1] ?? 0)) / 4;
248
+ }
249
+ }
250
+ return assessGrayPixels(smooth, w, h, KYC_SHARPNESS_MIN);
251
+ }
252
+ function sampleGuideSharpness(source, guideRect) {
253
+ const { width: fw, height: fh } = frameSize(source);
254
+ if (fw < 1 || fh < 1 || guideRect.width < 1 || guideRect.height < 1)
255
+ return UNUSABLE_IMAGE;
256
+ const x0 = Math.max(
257
+ 0,
258
+ Math.round(guideRect.x + guideRect.width * GUIDE_INTERIOR_INSET)
259
+ );
260
+ const y0 = Math.max(
261
+ 0,
262
+ Math.round(guideRect.y + guideRect.height * GUIDE_INTERIOR_INSET)
263
+ );
264
+ const x1 = Math.min(
265
+ fw,
266
+ Math.round(guideRect.x + guideRect.width * (1 - GUIDE_INTERIOR_INSET))
267
+ );
268
+ const y1 = Math.min(
269
+ fh,
270
+ Math.round(guideRect.y + guideRect.height * (1 - GUIDE_INTERIOR_INSET))
271
+ );
272
+ if (x1 - x0 < 1 || y1 - y0 < 1) return UNUSABLE_IMAGE;
273
+ const scale = Math.min(1, SHARPNESS_SAMPLE_WIDTH / guideRect.width);
274
+ const sample = grabGray(
275
+ source,
276
+ x0,
277
+ y0,
278
+ x1 - x0,
279
+ y1 - y0,
280
+ Math.max(1, Math.round((x1 - x0) * scale)),
281
+ Math.max(1, Math.round((y1 - y0) * scale))
282
+ );
283
+ if (!sample) return UNUSABLE_IMAGE;
284
+ return assessSharpness(sample.gray, sample.width, sample.height);
285
+ }
286
+ function sampleVideoQuality(video, guideRect, sampleWidth = GUIDE_SAMPLE_WIDTH) {
287
+ const vw = video.videoWidth;
288
+ const vh = video.videoHeight;
289
+ if (vw < 1 || vh < 1 || guideRect.width < 1 || guideRect.height < 1)
290
+ return UNUSABLE_GUIDE;
291
+ const mx = guideRect.width * GUIDE_EDGE_MARGIN;
292
+ const my = guideRect.height * GUIDE_EDGE_MARGIN;
293
+ const sx = Math.max(0, guideRect.x - mx);
294
+ const sy = Math.max(0, guideRect.y - my);
295
+ const sw = Math.max(1, Math.min(vw, guideRect.x + guideRect.width + mx) - sx);
296
+ const sh = Math.max(
297
+ 1,
298
+ Math.min(vh, guideRect.y + guideRect.height + my) - sy
299
+ );
300
+ const scale = Math.min(1, sampleWidth / guideRect.width);
301
+ const sample = grabGray(
302
+ video,
303
+ sx,
304
+ sy,
305
+ sw,
306
+ sh,
307
+ Math.max(1, Math.round(sw * scale)),
308
+ Math.max(1, Math.round(sh * scale))
309
+ );
310
+ if (!sample) return UNUSABLE_GUIDE;
311
+ const edgesFound = countGuideEdges(sample.gray, sample.width, sample.height, {
312
+ x: (guideRect.x - sx) * scale,
313
+ y: (guideRect.y - sy) * scale,
314
+ width: guideRect.width * scale,
315
+ height: guideRect.height * scale
316
+ });
317
+ const interior = sampleGuideSharpness(video, guideRect);
318
+ const aligned = edgesFound === 4;
319
+ return {
320
+ ...interior,
321
+ edgesFound,
322
+ aligned,
323
+ ready: aligned && !interior.tooBlurry && !interior.tooDark
324
+ };
325
+ }
326
+ var SharpestFrame = class {
327
+ canvas = null;
328
+ score = 0;
329
+ at = Number.NEGATIVE_INFINITY;
330
+ offer(video, score, now) {
331
+ const { videoWidth: width, videoHeight: height } = video;
332
+ if (width < 1 || height < 1) return;
333
+ if (score <= this.score && now - this.at <= SHARPEST_FRAME_MAX_AGE_MS)
334
+ return;
335
+ const canvas = this.canvas ?? document.createElement("canvas");
336
+ if (canvas.width !== width || canvas.height !== height) {
337
+ canvas.width = width;
338
+ canvas.height = height;
339
+ }
340
+ const ctx = canvas.getContext("2d");
341
+ if (!ctx) return;
342
+ ctx.drawImage(video, 0, 0, width, height);
343
+ this.canvas = canvas;
344
+ this.score = score;
345
+ this.at = now;
346
+ }
347
+ take(now) {
348
+ return this.canvas && now - this.at <= SHARPEST_FRAME_MAX_AGE_MS ? this.canvas : null;
349
+ }
350
+ release() {
351
+ if (this.canvas) {
352
+ this.canvas.width = 0;
353
+ this.canvas.height = 0;
354
+ }
355
+ this.canvas = null;
356
+ this.score = 0;
357
+ this.at = Number.NEGATIVE_INFINITY;
358
+ }
359
+ };
360
+ async function requestContinuousFocus(track) {
361
+ try {
362
+ const caps = track?.getCapabilities();
363
+ if (!track || !caps?.focusMode?.includes("continuous")) return;
364
+ const advanced = [{ focusMode: "continuous" }];
365
+ await track.applyConstraints({ advanced });
366
+ } catch {
367
+ }
368
+ }
369
+ var AutoCaptureController = class {
370
+ readyStreak = 0;
371
+ fired = false;
372
+ lastSampleAt = 0;
373
+ focus = [];
374
+ intervalMs;
375
+ needed;
376
+ constructor(opts) {
377
+ const hz = opts?.hz ?? AUTO_CAPTURE_SAMPLE_HZ;
378
+ this.intervalMs = 1e3 / Math.max(1, hz);
379
+ this.needed = opts?.readyCount ?? AUTO_CAPTURE_READY_COUNT;
380
+ }
381
+ reset() {
382
+ this.readyStreak = 0;
383
+ this.fired = false;
384
+ this.lastSampleAt = 0;
385
+ this.focus = [];
386
+ }
387
+ focusSettled(sample, now) {
388
+ if (!sample.aligned) {
389
+ this.focus = [];
390
+ return false;
391
+ }
392
+ this.focus = this.focus.filter(
393
+ (entry) => now - entry.at <= FOCUS_WINDOW_MS
394
+ );
395
+ this.focus.push({ at: now, score: sample.blurScore });
396
+ return this.focus.length >= FOCUS_SETTLE_SAMPLES && this.focusStats.settleRatio >= FOCUS_PLATEAU_RATIO;
397
+ }
398
+ /** Best score in the focus window and the weakest of the last settle samples as a fraction of it. */
399
+ get focusStats() {
400
+ if (this.focus.length === 0) return { best: 0, settleRatio: 0 };
401
+ const best = Math.max(...this.focus.map((entry) => entry.score));
402
+ const weakest = Math.min(
403
+ ...this.focus.slice(-FOCUS_SETTLE_SAMPLES).map((entry) => entry.score)
404
+ );
405
+ return { best, settleRatio: best > 0 ? weakest / best : 0 };
406
+ }
407
+ get progress() {
408
+ return Math.min(1, this.readyStreak / this.needed);
409
+ }
410
+ get hasFired() {
411
+ return this.fired;
412
+ }
413
+ observe(sample, now = typeof performance !== "undefined" ? performance.now() : Date.now()) {
414
+ if (this.fired) {
415
+ return { progress: 1, shouldCapture: false };
416
+ }
417
+ if (this.lastSampleAt > 0 && now - this.lastSampleAt < this.intervalMs) {
418
+ return { progress: this.progress, shouldCapture: false };
419
+ }
420
+ this.lastSampleAt = now;
421
+ const settled = this.focusSettled(sample, now);
422
+ if (!sample.ready || !settled) {
423
+ this.readyStreak = Math.max(0, this.readyStreak - 1);
424
+ return { progress: this.progress, shouldCapture: false };
425
+ }
426
+ this.readyStreak += 1;
427
+ const progress = Math.min(1, this.readyStreak / this.needed);
428
+ if (this.readyStreak >= this.needed) {
429
+ this.fired = true;
430
+ return { progress: 1, shouldCapture: true };
431
+ }
432
+ return { progress, shouldCapture: false };
433
+ }
434
+ };
435
+ function pickRecorderMime() {
436
+ if (typeof MediaRecorder === "undefined") return null;
437
+ const candidates = [
438
+ "video/webm;codecs=vp8,opus",
439
+ "video/webm;codecs=vp8",
440
+ "video/webm",
441
+ "video/mp4"
442
+ ];
443
+ for (const mime of candidates) {
444
+ if (MediaRecorder.isTypeSupported(mime)) return mime;
445
+ }
446
+ return null;
447
+ }
448
+ function recorderExtension(mime) {
449
+ return mime.includes("mp4") ? "mp4" : "webm";
450
+ }
451
+ function prefersReducedMotion(matchMediaImpl) {
452
+ const impl = matchMediaImpl ?? (typeof globalThis.matchMedia === "function" ? globalThis.matchMedia : void 0);
453
+ if (!impl) return false;
454
+ return impl("(prefers-reduced-motion: reduce)").matches;
455
+ }
456
+ function drawScaled(source, crop, maxSide) {
457
+ const scale = Math.min(1, maxSide / Math.max(crop.width, crop.height));
458
+ const width = Math.max(1, Math.round(crop.width * scale));
459
+ const height = Math.max(1, Math.round(crop.height * scale));
460
+ const canvas = document.createElement("canvas");
461
+ canvas.width = width;
462
+ canvas.height = height;
463
+ const ctx = canvas.getContext("2d");
464
+ if (!ctx) throw new Error("canvas");
465
+ ctx.drawImage(
466
+ source,
467
+ crop.x,
468
+ crop.y,
469
+ crop.width,
470
+ crop.height,
471
+ 0,
472
+ 0,
473
+ width,
474
+ height
475
+ );
476
+ return canvas;
477
+ }
478
+ async function prepareIdJpeg(source, maxSide = KYC_IMAGE_MAX_SIDE) {
479
+ const bitmap = await createImageBitmap(source);
480
+ try {
481
+ const canvas = drawScaled(
482
+ bitmap,
483
+ { x: 0, y: 0, width: bitmap.width, height: bitmap.height },
484
+ maxSide
485
+ );
486
+ const ctx = canvas.getContext("2d");
487
+ if (!ctx) throw new Error("canvas");
488
+ const sample = ctx.getImageData(0, 0, canvas.width, canvas.height);
489
+ const quality = assessImageData(sample);
490
+ const blob = await new Promise((resolve, reject) => {
491
+ canvas.toBlob(
492
+ (next) => next ? resolve(next) : reject(new Error("jpeg")),
493
+ "image/jpeg",
494
+ 0.92
495
+ );
496
+ });
497
+ return { blob, quality };
498
+ } finally {
499
+ bitmap.close();
500
+ }
501
+ }
502
+ async function captureVideoFrame(source, maxSide = KYC_IMAGE_MAX_SIDE, qualityRect, cropRect) {
503
+ const { width, height } = frameSize(source);
504
+ if (width < 1 || height < 1) throw new Error("video");
505
+ const x0 = cropRect ? Math.max(0, Math.round(cropRect.x)) : 0;
506
+ const y0 = cropRect ? Math.max(0, Math.round(cropRect.y)) : 0;
507
+ const x1 = cropRect ? Math.min(width, Math.round(cropRect.x + cropRect.width)) : width;
508
+ const y1 = cropRect ? Math.min(height, Math.round(cropRect.y + cropRect.height)) : height;
509
+ const crop = x1 - x0 >= 1 && y1 - y0 >= 1 ? { x: x0, y: y0, width: x1 - x0, height: y1 - y0 } : { x: 0, y: 0, width, height };
510
+ const canvas = drawScaled(source, crop, maxSide);
511
+ const ctx = canvas.getContext("2d");
512
+ if (!ctx) throw new Error("canvas");
513
+ const quality = qualityRect && qualityRect.width >= 1 && qualityRect.height >= 1 ? sampleGuideSharpness(source, qualityRect) : assessImageData(ctx.getImageData(0, 0, canvas.width, canvas.height));
514
+ const blob = await new Promise((resolve, reject) => {
515
+ canvas.toBlob(
516
+ (next) => next ? resolve(next) : reject(new Error("jpeg")),
517
+ "image/jpeg",
518
+ 0.92
519
+ );
520
+ });
521
+ return { blob, quality };
522
+ }
523
+
524
+ // src/components/kyc/bytes.ts
525
+ function bytesToBase64(bytes) {
526
+ let binary = "";
527
+ for (const byte of bytes) binary += String.fromCharCode(byte);
528
+ return btoa(binary);
529
+ }
530
+
531
+ // src/components/kyc/capture-cues.ts
532
+ var CAPTURE_MUTE_KEY = "kyc-capture-muted";
533
+ function isCaptureMuted(storage) {
534
+ const store = storage ?? (typeof sessionStorage !== "undefined" ? sessionStorage : null);
535
+ if (!store) return false;
536
+ try {
537
+ return store.getItem(CAPTURE_MUTE_KEY) === "1";
538
+ } catch {
539
+ return false;
540
+ }
541
+ }
542
+ function setCaptureMuted(muted, storage) {
543
+ const store = storage ?? (typeof sessionStorage !== "undefined" ? sessionStorage : null);
544
+ if (!store) return;
545
+ try {
546
+ store.setItem(CAPTURE_MUTE_KEY, muted ? "1" : "0");
547
+ } catch {
548
+ }
549
+ }
550
+ var SAMPLE_RATE = 22050;
551
+ function toneWavDataUri(frequency, durationSec, amplitude) {
552
+ const samples = Math.round(SAMPLE_RATE * durationSec);
553
+ const bytes = new Uint8Array(44 + samples * 2);
554
+ const view = new DataView(bytes.buffer);
555
+ const ascii = (offset, text) => {
556
+ for (let i = 0; i < text.length; i++)
557
+ view.setUint8(offset + i, text.charCodeAt(i));
558
+ };
559
+ ascii(0, "RIFF");
560
+ view.setUint32(4, 36 + samples * 2, true);
561
+ ascii(8, "WAVE");
562
+ ascii(12, "fmt ");
563
+ view.setUint32(16, 16, true);
564
+ view.setUint16(20, 1, true);
565
+ view.setUint16(22, 1, true);
566
+ view.setUint32(24, SAMPLE_RATE, true);
567
+ view.setUint32(28, SAMPLE_RATE * 2, true);
568
+ view.setUint16(32, 2, true);
569
+ view.setUint16(34, 16, true);
570
+ ascii(36, "data");
571
+ view.setUint32(40, samples * 2, true);
572
+ const attack = SAMPLE_RATE * 4e-3;
573
+ for (let i = 0; i < samples; i++) {
574
+ const envelope = Math.min(1, i / attack) * Math.exp(-5 * i / samples);
575
+ const value = Math.sin(2 * Math.PI * frequency * i / SAMPLE_RATE) * envelope * amplitude;
576
+ view.setInt16(44 + i * 2, Math.round(value * 32767), true);
577
+ }
578
+ return `data:audio/wav;base64,${bytesToBase64(bytes)}`;
579
+ }
580
+ var beepUri = null;
581
+ var silenceUri = null;
582
+ var cueAudio = null;
583
+ function audioElement() {
584
+ if (cueAudio) return cueAudio;
585
+ if (typeof Audio === "undefined") return null;
586
+ try {
587
+ cueAudio = new Audio();
588
+ cueAudio.preload = "auto";
589
+ return cueAudio;
590
+ } catch {
591
+ return null;
592
+ }
593
+ }
594
+ function playSource(audio, src) {
595
+ try {
596
+ if (audio.getAttribute("src") !== src) audio.src = src;
597
+ else audio.currentTime = 0;
598
+ void Promise.resolve(audio.play()).catch(() => void 0);
599
+ } catch {
600
+ }
601
+ }
602
+ function primeCaptureAudio() {
603
+ const audio = audioElement();
604
+ if (!audio) return;
605
+ silenceUri ??= toneWavDataUri(0, 0.05, 0);
606
+ playSource(audio, silenceUri);
607
+ }
608
+ function playCaptureBeep(options = {}) {
609
+ if (options.muted ?? isCaptureMuted()) return;
610
+ const audio = audioElement();
611
+ if (!audio) return;
612
+ beepUri ??= toneWavDataUri(880, 0.15, 0.5);
613
+ playSource(audio, beepUri);
614
+ }
615
+ function resetCaptureAudioForTests() {
616
+ cueAudio = null;
617
+ }
618
+ function readInitialCaptureMute() {
619
+ return isCaptureMuted();
620
+ }
621
+ function persistCaptureMute(muted) {
622
+ setCaptureMuted(muted);
623
+ }
624
+ function readCaptureDebugFlag() {
625
+ return new URLSearchParams(window.location.search).get("kycDebug") === "1";
626
+ }
627
+ function CaptureDebugReadout({ lines }) {
628
+ return /* @__PURE__ */ jsxRuntime.jsx(
629
+ "pre",
630
+ {
631
+ className: "pointer-events-none absolute left-2 top-12 z-10 rounded bg-black/70 px-2 py-1 font-mono text-[10px] leading-tight text-white",
632
+ "data-testid": "kyc-debug",
633
+ children: lines.join("\n")
634
+ }
635
+ );
636
+ }
637
+ function CaptureStage({
638
+ stepLabel,
639
+ pillLabel,
640
+ progressLabel,
641
+ statusText,
642
+ statusPoliteness = "polite",
643
+ muted,
644
+ onMutedChange,
645
+ muteLabel,
646
+ unmuteLabel,
647
+ helpLabel,
648
+ helpTitle,
649
+ helpTips,
650
+ helpIllustrationSrc,
651
+ children,
652
+ autoFocusStatus = true,
653
+ fullBleed = false,
654
+ className
655
+ }) {
656
+ const statusId = react.useId();
657
+ const statusRef = react.useRef(null);
658
+ react.useEffect(() => {
659
+ if (!autoFocusStatus) return;
660
+ statusRef.current?.focus({ preventScroll: true });
661
+ }, [autoFocusStatus, stepLabel]);
662
+ const help = helpLabel && helpTitle && helpTips && helpTips.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(drawer_js.Drawer, { children: [
663
+ /* @__PURE__ */ jsxRuntime.jsx(drawer_js.DrawerTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
664
+ button_js.Button,
665
+ {
666
+ className: fullBleed ? "min-h-11 shrink-0 border-white/30 bg-black/40 text-white hover:bg-black/60" : "min-h-11 shrink-0",
667
+ size: "sm",
668
+ type: "button",
669
+ variant: "outline",
670
+ children: helpLabel
671
+ }
672
+ ) }),
673
+ /* @__PURE__ */ jsxRuntime.jsxs(drawer_js.DrawerContent, { children: [
674
+ /* @__PURE__ */ jsxRuntime.jsxs(drawer_js.DrawerHeader, { children: [
675
+ /* @__PURE__ */ jsxRuntime.jsx(drawer_js.DrawerTitle, { children: helpTitle }),
676
+ /* @__PURE__ */ jsxRuntime.jsx(drawer_js.DrawerDescription, { children: helpTitle })
677
+ ] }),
678
+ helpIllustrationSrc ? /* @__PURE__ */ jsxRuntime.jsx(
679
+ "img",
680
+ {
681
+ src: helpIllustrationSrc,
682
+ alt: "",
683
+ className: "mx-auto w-full max-w-[200px] object-contain px-4",
684
+ loading: "lazy",
685
+ decoding: "async"
686
+ }
687
+ ) : null,
688
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "list-disc space-y-2 px-4 pb-2 pl-8 text-left text-sm text-muted-foreground", children: helpTips.map((tip) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: tip }, tip)) }),
689
+ /* @__PURE__ */ jsxRuntime.jsx(drawer_js.DrawerFooter, { children: /* @__PURE__ */ jsxRuntime.jsx(drawer_js.DrawerClose, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(button_js.Button, { type: "button", variant: "outline", children: helpLabel }) }) })
690
+ ] })
691
+ ] }) : null;
692
+ return /* @__PURE__ */ jsxRuntime.jsxs(
693
+ "div",
694
+ {
695
+ className: `flex flex-col gap-3 ${fullBleed ? "min-h-dvh gap-0" : ""} ${className ?? ""}`.trim(),
696
+ children: [
697
+ fullBleed ? null : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-3", children: [
698
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0", children: [
699
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "truncate text-sm font-medium text-foreground", children: stepLabel }),
700
+ progressLabel ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: progressLabel }) : null
701
+ ] }),
702
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
703
+ help,
704
+ /* @__PURE__ */ jsxRuntime.jsx(
705
+ button_js.Button,
706
+ {
707
+ "aria-label": muted ? unmuteLabel : muteLabel,
708
+ "aria-pressed": muted,
709
+ className: "min-h-11 min-w-11 shrink-0",
710
+ onClick: () => {
711
+ const next = !muted;
712
+ persistCaptureMute(next);
713
+ onMutedChange(next);
714
+ },
715
+ size: "icon",
716
+ type: "button",
717
+ variant: "outline",
718
+ children: muted ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.VolumeX, { "aria-hidden": true, className: "size-4" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Volume2, { "aria-hidden": true, className: "size-4" })
719
+ }
720
+ )
721
+ ] })
722
+ ] }),
723
+ /* @__PURE__ */ jsxRuntime.jsxs(
724
+ "div",
725
+ {
726
+ className: fullBleed ? "relative flex min-h-dvh flex-1 flex-col overflow-hidden bg-neutral-950 text-white" : "relative overflow-hidden rounded-xl bg-neutral-950 text-white",
727
+ children: [
728
+ fullBleed ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute inset-x-0 top-0 z-30 flex items-center justify-between gap-2 bg-gradient-to-b from-black/80 to-transparent px-3 pb-10 pt-3", children: [
729
+ pillLabel ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "rounded-full bg-black/55 px-3 py-1 text-xs font-medium text-white", children: pillLabel }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: stepLabel }),
730
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
731
+ help,
732
+ /* @__PURE__ */ jsxRuntime.jsx(
733
+ button_js.Button,
734
+ {
735
+ "aria-label": muted ? unmuteLabel : muteLabel,
736
+ "aria-pressed": muted,
737
+ className: "min-h-11 min-w-11 shrink-0 border-white/30 bg-black/40 text-white hover:bg-black/60",
738
+ onClick: () => {
739
+ const next = !muted;
740
+ persistCaptureMute(next);
741
+ onMutedChange(next);
742
+ },
743
+ size: "icon",
744
+ type: "button",
745
+ variant: "outline",
746
+ children: muted ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.VolumeX, { "aria-hidden": true, className: "size-4" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Volume2, { "aria-hidden": true, className: "size-4" })
747
+ }
748
+ )
749
+ ] })
750
+ ] }) : null,
751
+ children,
752
+ /* @__PURE__ */ jsxRuntime.jsx(
753
+ "div",
754
+ {
755
+ className: `pointer-events-none absolute inset-x-0 ${fullBleed ? "top-14" : "top-0"} bg-gradient-to-b from-black/70 to-transparent px-3 pb-8 pt-3`,
756
+ children: /* @__PURE__ */ jsxRuntime.jsx(
757
+ "p",
758
+ {
759
+ "aria-live": statusPoliteness,
760
+ className: "text-center text-sm font-medium drop-shadow outline-none",
761
+ id: statusId,
762
+ ref: statusRef,
763
+ role: "status",
764
+ tabIndex: -1,
765
+ children: statusText
766
+ }
767
+ )
768
+ }
769
+ )
770
+ ]
771
+ }
772
+ )
773
+ ]
774
+ }
775
+ );
776
+ }
777
+ function CaptureCheck({ reduceMotion }) {
778
+ return /* @__PURE__ */ jsxRuntime.jsx(
779
+ "div",
780
+ {
781
+ "aria-hidden": true,
782
+ className: `pointer-events-none absolute inset-0 z-10 flex items-center justify-center ${reduceMotion ? "" : "animate-pulse"}`,
783
+ "data-testid": "capture-check",
784
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex size-16 items-center justify-center rounded-full bg-emerald-500 text-white shadow-lg", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "size-8", strokeWidth: 3 }) })
785
+ }
786
+ );
787
+ }
788
+ function CaptureProgressRing({
789
+ progress,
790
+ size = 72,
791
+ stroke = 4,
792
+ children,
793
+ className
794
+ }) {
795
+ const radius = (size - stroke) / 2;
796
+ const circumference = 2 * Math.PI * radius;
797
+ const clamped = Math.max(0, Math.min(1, progress));
798
+ const offset = circumference * (1 - clamped);
799
+ return /* @__PURE__ */ jsxRuntime.jsxs(
800
+ "div",
801
+ {
802
+ className: `relative inline-flex items-center justify-center ${className ?? ""}`.trim(),
803
+ style: { width: size, height: size },
804
+ children: [
805
+ /* @__PURE__ */ jsxRuntime.jsxs(
806
+ "svg",
807
+ {
808
+ "aria-hidden": true,
809
+ className: "pointer-events-none absolute inset-0 -rotate-90",
810
+ height: size,
811
+ width: size,
812
+ children: [
813
+ /* @__PURE__ */ jsxRuntime.jsx(
814
+ "circle",
815
+ {
816
+ cx: size / 2,
817
+ cy: size / 2,
818
+ fill: "none",
819
+ r: radius,
820
+ stroke: "rgba(255,255,255,0.25)",
821
+ strokeWidth: stroke
822
+ }
823
+ ),
824
+ /* @__PURE__ */ jsxRuntime.jsx(
825
+ "circle",
826
+ {
827
+ cx: size / 2,
828
+ cy: size / 2,
829
+ fill: "none",
830
+ r: radius,
831
+ stroke: "white",
832
+ strokeDasharray: circumference,
833
+ strokeDashoffset: offset,
834
+ strokeLinecap: "round",
835
+ strokeWidth: stroke
836
+ }
837
+ )
838
+ ]
839
+ }
840
+ ),
841
+ children
842
+ ]
843
+ }
844
+ );
845
+ }
846
+ function cn(...inputs) {
847
+ return tailwindMerge.twMerge(clsx.clsx(inputs));
848
+ }
849
+ var SIZE_CLASS = {
850
+ sm: "max-w-[140px]",
851
+ md: "max-w-[220px]",
852
+ lg: "max-w-[280px]"
853
+ };
854
+ function ProductIllustration({
855
+ src,
856
+ alt = "",
857
+ className,
858
+ size = "md"
859
+ }) {
860
+ return /* @__PURE__ */ jsxRuntime.jsx(
861
+ "img",
862
+ {
863
+ src,
864
+ alt,
865
+ loading: "lazy",
866
+ decoding: "async",
867
+ className: cn(
868
+ "mx-auto h-auto w-full object-contain",
869
+ SIZE_CLASS[size],
870
+ className
871
+ )
872
+ }
873
+ );
874
+ }
875
+ function DebugReadout({
876
+ quality,
877
+ progress,
878
+ stats
879
+ }) {
880
+ const yesNo = (value) => value ? "yes" : "no";
881
+ const lines = [
882
+ `edges ${quality?.edgesFound ?? 0}/4 aligned ${yesNo(quality?.aligned)}`,
883
+ `sharp ${(quality?.blurScore ?? 0).toFixed(1)} (min ${KYC_SHARPNESS_MIN}) best ${(stats?.best ?? 0).toFixed(1)}`,
884
+ `settle ${(stats?.settleRatio ?? 0).toFixed(2)} (need ${FOCUS_PLATEAU_RATIO}) ready ${yesNo(quality?.ready)}`,
885
+ `luma ${(quality?.meanLuma ?? 0).toFixed(0)} progress ${progress.toFixed(2)}`,
886
+ `video ${stats?.videoWidth ?? 0}x${stats?.videoHeight ?? 0} zoom ${ID_PREVIEW_ZOOM}`
887
+ ];
888
+ return /* @__PURE__ */ jsxRuntime.jsx(CaptureDebugReadout, { lines });
889
+ }
890
+ function guideTone(quality, progress) {
891
+ if (!quality) return "bad";
892
+ if (quality.ready && progress > 0) return "ready";
893
+ if (quality.aligned && !quality.tooDark) return "warming";
894
+ return "bad";
895
+ }
896
+ function statusForQuality(quality, progress, labels) {
897
+ if (!quality) return labels.autoCaptureHint;
898
+ if (quality.tooDark) return labels.tooDark;
899
+ if (!quality.aligned) return labels.alignCard;
900
+ if (quality.tooBlurry) return labels.focusing;
901
+ if (quality.ready && progress >= 1) return labels.capturing;
902
+ if (quality.ready) return labels.holdStill;
903
+ return labels.autoCaptureHint;
904
+ }
905
+ var TONE_STROKE = {
906
+ bad: "border-red-400/95",
907
+ warming: "border-amber-300/95",
908
+ ready: "border-emerald-400/95"
909
+ };
910
+ var TONE_CORNER = {
911
+ bad: "border-red-300",
912
+ warming: "border-amber-200",
913
+ ready: "border-emerald-300"
914
+ };
915
+ function IdCardGuideOverlay({
916
+ layout,
917
+ tone,
918
+ reduceMotion
919
+ }) {
920
+ const style = {
921
+ left: `${layout.left * 100}%`,
922
+ top: `${layout.top * 100}%`,
923
+ width: `${layout.width * 100}%`,
924
+ height: `${layout.height * 100}%`,
925
+ boxShadow: "0 0 0 9999px rgba(0,0,0,0.62)"
926
+ };
927
+ const corner = `pointer-events-none absolute size-[14%] max-h-10 max-w-10 border-[3px] ${TONE_CORNER[tone]} ${reduceMotion ? "" : "transition-colors duration-200"}`;
928
+ return /* @__PURE__ */ jsxRuntime.jsxs(
929
+ "div",
930
+ {
931
+ "aria-hidden": true,
932
+ className: `pointer-events-none absolute rounded-md border-2 ${TONE_STROKE[tone]} ${reduceMotion ? "" : "transition-colors duration-200"}`,
933
+ style,
934
+ children: [
935
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-[6px] rounded-sm border border-dashed border-white/35" }),
936
+ /* @__PURE__ */ jsxRuntime.jsx(
937
+ "span",
938
+ {
939
+ className: `${corner} left-[-2px] top-[-2px] rounded-tl-md border-b-0 border-r-0`
940
+ }
941
+ ),
942
+ /* @__PURE__ */ jsxRuntime.jsx(
943
+ "span",
944
+ {
945
+ className: `${corner} right-[-2px] top-[-2px] rounded-tr-md border-b-0 border-l-0`
946
+ }
947
+ ),
948
+ /* @__PURE__ */ jsxRuntime.jsx(
949
+ "span",
950
+ {
951
+ className: `${corner} bottom-[-2px] left-[-2px] rounded-bl-md border-r-0 border-t-0`
952
+ }
953
+ ),
954
+ /* @__PURE__ */ jsxRuntime.jsx(
955
+ "span",
956
+ {
957
+ className: `${corner} bottom-[-2px] right-[-2px] rounded-br-md border-l-0 border-t-0`
958
+ }
959
+ )
960
+ ]
961
+ }
962
+ );
963
+ }
964
+ function IdCapture({
965
+ slot,
966
+ labels,
967
+ onCaptured,
968
+ onBusyChange,
969
+ onFullBleedChange,
970
+ illustrationSrc,
971
+ uploading = false,
972
+ pillLabel,
973
+ sampleQuality
974
+ }) {
975
+ const videoRef = react.useRef(null);
976
+ const stageRef = react.useRef(null);
977
+ const fileRef = react.useRef(null);
978
+ const streamRef = react.useRef(null);
979
+ const previewUrlRef = react.useRef(null);
980
+ const controllerRef = react.useRef(new AutoCaptureController());
981
+ const sharpestRef = react.useRef(new SharpestFrame());
982
+ const capturingRef = react.useRef(false);
983
+ const sampleFn = sampleQuality ?? sampleVideoQuality;
984
+ const [phase, setPhase] = react.useState("briefing");
985
+ const [pendingCapture, setPendingCapture] = react.useState(null);
986
+ const [previewUrl, setPreviewUrl] = react.useState(null);
987
+ const [cameraReady, setCameraReady] = react.useState(false);
988
+ const [cameraFailed, setCameraFailed] = react.useState(false);
989
+ const [busy, setBusy] = react.useState(false);
990
+ const [justCaptured, setJustCaptured] = react.useState(false);
991
+ const [progress, setProgress] = react.useState(0);
992
+ const [quality, setQuality] = react.useState(null);
993
+ const [statusOverride, setStatusOverride] = react.useState(null);
994
+ const [statusPoliteness, setStatusPoliteness] = react.useState("polite");
995
+ const [muted, setMuted] = react.useState(false);
996
+ const [debug, setDebug] = react.useState(false);
997
+ const [debugStats, setDebugStats] = react.useState(null);
998
+ const reduceMotion = prefersReducedMotion();
999
+ react.useEffect(() => {
1000
+ setMuted(readInitialCaptureMute());
1001
+ setDebug(readCaptureDebugFlag());
1002
+ }, []);
1003
+ const fullBleed = phase === "live" || phase === "confirm";
1004
+ react.useEffect(() => {
1005
+ onFullBleedChange?.(fullBleed);
1006
+ return () => onFullBleedChange?.(false);
1007
+ }, [fullBleed, onFullBleedChange]);
1008
+ react.useEffect(() => {
1009
+ return () => {
1010
+ if (previewUrlRef.current) {
1011
+ URL.revokeObjectURL(previewUrlRef.current);
1012
+ previewUrlRef.current = null;
1013
+ }
1014
+ };
1015
+ }, []);
1016
+ react.useEffect(() => {
1017
+ if (phase !== "live") {
1018
+ setCameraReady(false);
1019
+ return;
1020
+ }
1021
+ let cancelled = false;
1022
+ async function openCamera() {
1023
+ if (!navigator.mediaDevices?.getUserMedia) {
1024
+ setCameraFailed(true);
1025
+ return;
1026
+ }
1027
+ try {
1028
+ const stream = await navigator.mediaDevices.getUserMedia({
1029
+ audio: false,
1030
+ video: {
1031
+ facingMode: { ideal: "environment" },
1032
+ width: { ideal: 1920 },
1033
+ height: { ideal: 1080 }
1034
+ }
1035
+ });
1036
+ if (cancelled) {
1037
+ for (const track of stream.getTracks()) track.stop();
1038
+ return;
1039
+ }
1040
+ streamRef.current = stream;
1041
+ void requestContinuousFocus(stream.getTracks()[0]);
1042
+ const video = videoRef.current;
1043
+ if (video) {
1044
+ video.srcObject = stream;
1045
+ await video.play();
1046
+ }
1047
+ setCameraReady(true);
1048
+ setCameraFailed(false);
1049
+ } catch {
1050
+ if (!cancelled) setCameraFailed(true);
1051
+ }
1052
+ }
1053
+ void openCamera();
1054
+ return () => {
1055
+ cancelled = true;
1056
+ const stream = streamRef.current;
1057
+ streamRef.current = null;
1058
+ if (stream) for (const track of stream.getTracks()) track.stop();
1059
+ const video = videoRef.current;
1060
+ if (video) video.srcObject = null;
1061
+ sharpestRef.current.release();
1062
+ setCameraReady(false);
1063
+ };
1064
+ }, [phase]);
1065
+ function setPending(next) {
1066
+ setBusy(next);
1067
+ onBusyChange?.(next);
1068
+ }
1069
+ const clearPreview = react.useCallback(() => {
1070
+ if (previewUrlRef.current) {
1071
+ URL.revokeObjectURL(previewUrlRef.current);
1072
+ previewUrlRef.current = null;
1073
+ }
1074
+ setPreviewUrl(null);
1075
+ setPendingCapture(null);
1076
+ }, []);
1077
+ const announceCaptured = react.useCallback(() => {
1078
+ setStatusPoliteness("assertive");
1079
+ setStatusOverride(labels.photoCaptured);
1080
+ playCaptureBeep({ muted });
1081
+ setJustCaptured(true);
1082
+ window.setTimeout(() => setJustCaptured(false), 700);
1083
+ }, [labels.photoCaptured, muted]);
1084
+ const enterConfirm = react.useCallback(
1085
+ (blob, fileName) => {
1086
+ if (previewUrlRef.current) URL.revokeObjectURL(previewUrlRef.current);
1087
+ const url = URL.createObjectURL(blob);
1088
+ previewUrlRef.current = url;
1089
+ setPreviewUrl(url);
1090
+ setPendingCapture({ blob, fileName });
1091
+ announceCaptured();
1092
+ setPhase("confirm");
1093
+ controllerRef.current.reset();
1094
+ setProgress(0);
1095
+ setQuality(null);
1096
+ },
1097
+ [announceCaptured]
1098
+ );
1099
+ const finishPrepared = react.useCallback(
1100
+ async (blob, fileName) => {
1101
+ setPending(true);
1102
+ try {
1103
+ const prepared = await prepareIdJpeg(blob);
1104
+ if (prepared.quality.tooBlurry || prepared.quality.tooDark) {
1105
+ sonner_js.toast.error(labels.retakeClearer);
1106
+ controllerRef.current.reset();
1107
+ setProgress(0);
1108
+ capturingRef.current = false;
1109
+ setPending(false);
1110
+ return;
1111
+ }
1112
+ enterConfirm(prepared.blob, fileName);
1113
+ } catch {
1114
+ sonner_js.toast.error(labels.captureFailed);
1115
+ controllerRef.current.reset();
1116
+ capturingRef.current = false;
1117
+ } finally {
1118
+ setPending(false);
1119
+ }
1120
+ },
1121
+ [enterConfirm, labels.captureFailed, labels.retakeClearer]
1122
+ );
1123
+ const resolveStageRects = react.useCallback(() => {
1124
+ const video = videoRef.current;
1125
+ const stage = stageRef.current;
1126
+ if (!video || video.videoWidth < 1 || video.videoHeight < 1) return null;
1127
+ const args = [
1128
+ video.videoWidth,
1129
+ video.videoHeight,
1130
+ stage?.clientWidth || 3,
1131
+ stage?.clientHeight || 4,
1132
+ ID_PREVIEW_ZOOM
1133
+ ];
1134
+ return {
1135
+ guide: idGuideRectForCoveredStage(...args),
1136
+ visible: objectCoverVisibleRect(...args)
1137
+ };
1138
+ }, []);
1139
+ const shutterFromVideo = react.useCallback(
1140
+ async (sharpest) => {
1141
+ const video = videoRef.current;
1142
+ if (!video || !cameraReady || capturingRef.current || phase !== "live")
1143
+ return;
1144
+ capturingRef.current = true;
1145
+ setPending(true);
1146
+ try {
1147
+ const rects = resolveStageRects();
1148
+ const prepared = await captureVideoFrame(
1149
+ sharpest ?? video,
1150
+ void 0,
1151
+ rects?.guide,
1152
+ rects?.visible
1153
+ );
1154
+ enterConfirm(
1155
+ prepared.blob,
1156
+ slot === "id_front" ? "id-front.jpg" : "id-back.jpg"
1157
+ );
1158
+ if (prepared.quality.tooBlurry || prepared.quality.tooDark) {
1159
+ sonner_js.toast.warning(labels.softPhotoWarning);
1160
+ }
1161
+ } catch {
1162
+ sonner_js.toast.error(labels.captureFailed);
1163
+ controllerRef.current.reset();
1164
+ setProgress(0);
1165
+ } finally {
1166
+ sharpestRef.current.release();
1167
+ capturingRef.current = false;
1168
+ setPending(false);
1169
+ }
1170
+ },
1171
+ [
1172
+ cameraReady,
1173
+ enterConfirm,
1174
+ labels.captureFailed,
1175
+ labels.softPhotoWarning,
1176
+ phase,
1177
+ resolveStageRects,
1178
+ slot
1179
+ ]
1180
+ );
1181
+ react.useEffect(() => {
1182
+ if (sampleQuality) {
1183
+ controllerRef.current = new AutoCaptureController({
1184
+ hz: 1e3,
1185
+ readyCount: 4
1186
+ });
1187
+ }
1188
+ }, [sampleQuality]);
1189
+ react.useEffect(() => {
1190
+ if (phase !== "live" || !cameraReady || busy || cameraFailed) return;
1191
+ let raf = 0;
1192
+ let alive = true;
1193
+ let lastSampleAt = Number.NEGATIVE_INFINITY;
1194
+ const tick = () => {
1195
+ if (!alive || capturingRef.current) {
1196
+ if (alive) raf = window.requestAnimationFrame(tick);
1197
+ return;
1198
+ }
1199
+ const now = performance.now();
1200
+ if (now - lastSampleAt < 1e3 / AUTO_CAPTURE_SAMPLE_HZ) {
1201
+ raf = window.requestAnimationFrame(tick);
1202
+ return;
1203
+ }
1204
+ const video = videoRef.current;
1205
+ if (!video) {
1206
+ raf = window.requestAnimationFrame(tick);
1207
+ return;
1208
+ }
1209
+ const hasPixels = video.videoWidth >= 1 && video.videoHeight >= 1;
1210
+ if (!hasPixels && !sampleQuality) {
1211
+ raf = window.requestAnimationFrame(tick);
1212
+ return;
1213
+ }
1214
+ const guide = resolveStageRects()?.guide ?? {
1215
+ x: 0,
1216
+ y: 0,
1217
+ width: Math.max(1, video.videoWidth),
1218
+ height: Math.max(1, video.videoHeight)
1219
+ };
1220
+ lastSampleAt = now;
1221
+ const nextQuality = sampleFn(video, guide);
1222
+ setQuality(nextQuality);
1223
+ if (nextQuality.ready)
1224
+ sharpestRef.current.offer(video, nextQuality.blurScore, now);
1225
+ const result = controllerRef.current.observe(nextQuality, now);
1226
+ setProgress(result.progress);
1227
+ if (debug) {
1228
+ setDebugStats({
1229
+ ...controllerRef.current.focusStats,
1230
+ videoWidth: video.videoWidth,
1231
+ videoHeight: video.videoHeight
1232
+ });
1233
+ }
1234
+ if (result.shouldCapture) {
1235
+ void shutterFromVideo(sharpestRef.current.take(now));
1236
+ }
1237
+ raf = window.requestAnimationFrame(tick);
1238
+ };
1239
+ raf = window.requestAnimationFrame(tick);
1240
+ return () => {
1241
+ alive = false;
1242
+ window.cancelAnimationFrame(raf);
1243
+ };
1244
+ }, [
1245
+ busy,
1246
+ cameraFailed,
1247
+ cameraReady,
1248
+ debug,
1249
+ phase,
1250
+ resolveStageRects,
1251
+ sampleFn,
1252
+ sampleQuality,
1253
+ shutterFromVideo
1254
+ ]);
1255
+ async function onFileChange() {
1256
+ const file = fileRef.current?.files?.[0];
1257
+ if (!file) return;
1258
+ await finishPrepared(
1259
+ file,
1260
+ file.name || (slot === "id_front" ? "id-front.jpg" : "id-back.jpg")
1261
+ );
1262
+ if (fileRef.current) fileRef.current.value = "";
1263
+ }
1264
+ function onStageKeyDown(event) {
1265
+ if (event.key !== " " && event.key !== "Enter") return;
1266
+ event.preventDefault();
1267
+ void shutterFromVideo();
1268
+ }
1269
+ function onAcceptPhoto() {
1270
+ if (!pendingCapture || busy) return;
1271
+ const { blob, fileName } = pendingCapture;
1272
+ clearPreview();
1273
+ onCaptured(blob, fileName);
1274
+ }
1275
+ function onDiscardPhoto() {
1276
+ clearPreview();
1277
+ setStatusOverride(null);
1278
+ setStatusPoliteness("polite");
1279
+ setJustCaptured(false);
1280
+ capturingRef.current = false;
1281
+ controllerRef.current.reset();
1282
+ setProgress(0);
1283
+ setQuality(null);
1284
+ setPhase(cameraFailed ? "briefing" : "live");
1285
+ }
1286
+ const tone = guideTone(quality, progress);
1287
+ const liveStatus = statusOverride ?? statusForQuality(quality, progress, labels);
1288
+ const stepLabel = slot === "id_front" ? labels.stepFront : labels.stepBack;
1289
+ const progressLabel = slot === "id_front" ? "1 / 2" : "2 / 2";
1290
+ const guideLayout = idGuideLayout(3, 4);
1291
+ const showFilePicker = phase !== "confirm" && !uploading;
1292
+ const sideHint = slot === "id_front" ? labels.frontHint : labels.backHint;
1293
+ const helpTips = [
1294
+ labels.captureHelpFlat,
1295
+ labels.captureHelpLight,
1296
+ labels.captureHelpEdges,
1297
+ labels.captureHelpGlare
1298
+ ];
1299
+ if (uploading) {
1300
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1301
+ "div",
1302
+ {
1303
+ "aria-busy": true,
1304
+ "aria-live": "polite",
1305
+ className: "flex flex-col items-center gap-4 rounded-xl border border-border bg-muted/30 p-8 text-center",
1306
+ children: [
1307
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium", children: labels.uploadingSecurely }),
1308
+ /* @__PURE__ */ jsxRuntime.jsx(
1309
+ progress_js.Progress,
1310
+ {
1311
+ className: "w-full max-w-xs",
1312
+ label: labels.uploadingSecurely,
1313
+ value: 66
1314
+ }
1315
+ )
1316
+ ]
1317
+ }
1318
+ );
1319
+ }
1320
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
1321
+ phase === "briefing" ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4 rounded-xl border border-border bg-muted/30 p-5", children: [
1322
+ /* @__PURE__ */ jsxRuntime.jsx(ProductIllustration, { alt: "", size: "md", src: illustrationSrc }),
1323
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1.5", children: [
1324
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-foreground", children: stepLabel }),
1325
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: progressLabel }),
1326
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: sideHint }),
1327
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: labels.briefingTip })
1328
+ ] }),
1329
+ /* @__PURE__ */ jsxRuntime.jsx(
1330
+ button_js.Button,
1331
+ {
1332
+ className: "self-start",
1333
+ disabled: busy,
1334
+ onClick: () => {
1335
+ primeCaptureAudio();
1336
+ setCameraFailed(false);
1337
+ setPhase("live");
1338
+ },
1339
+ type: "button",
1340
+ children: labels.startCamera
1341
+ }
1342
+ )
1343
+ ] }) : null,
1344
+ phase === "live" && !cameraFailed ? /* @__PURE__ */ jsxRuntime.jsx(
1345
+ CaptureStage,
1346
+ {
1347
+ fullBleed: true,
1348
+ helpIllustrationSrc: illustrationSrc,
1349
+ helpLabel: labels.captureHelp,
1350
+ helpTips,
1351
+ helpTitle: labels.captureHelpTitle,
1352
+ muteLabel: labels.muteSound,
1353
+ muted,
1354
+ onMutedChange: setMuted,
1355
+ pillLabel: pillLabel ?? stepLabel,
1356
+ progressLabel,
1357
+ statusPoliteness,
1358
+ statusText: liveStatus,
1359
+ stepLabel,
1360
+ unmuteLabel: labels.unmuteSound,
1361
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
1362
+ "div",
1363
+ {
1364
+ "aria-label": slot === "id_front" ? labels.frontCameraLabel : labels.backCameraLabel,
1365
+ className: "relative aspect-[3/4] max-h-[min(70vh,100dvh)] w-full flex-1 outline-none sm:mx-auto sm:max-w-md",
1366
+ onKeyDown: onStageKeyDown,
1367
+ ref: stageRef,
1368
+ role: "group",
1369
+ tabIndex: 0,
1370
+ children: [
1371
+ /* @__PURE__ */ jsxRuntime.jsx(
1372
+ "video",
1373
+ {
1374
+ "aria-hidden": true,
1375
+ autoPlay: true,
1376
+ className: `h-full w-full object-cover ${cameraReady ? "" : "opacity-0"}`,
1377
+ muted: true,
1378
+ playsInline: true,
1379
+ ref: videoRef,
1380
+ style: { transform: `scale(${ID_PREVIEW_ZOOM})` }
1381
+ }
1382
+ ),
1383
+ !cameraReady ? /* @__PURE__ */ jsxRuntime.jsx(
1384
+ "div",
1385
+ {
1386
+ "aria-busy": true,
1387
+ "aria-label": labels.cameraOpening,
1388
+ className: `absolute inset-0 bg-neutral-900 ${reduceMotion ? "" : "animate-pulse"}`
1389
+ }
1390
+ ) : null,
1391
+ /* @__PURE__ */ jsxRuntime.jsx(
1392
+ IdCardGuideOverlay,
1393
+ {
1394
+ layout: guideLayout,
1395
+ reduceMotion,
1396
+ tone
1397
+ }
1398
+ ),
1399
+ debug ? /* @__PURE__ */ jsxRuntime.jsx(
1400
+ DebugReadout,
1401
+ {
1402
+ progress,
1403
+ quality,
1404
+ stats: debugStats
1405
+ }
1406
+ ) : null,
1407
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-x-0 bottom-0 z-20 flex justify-center bg-gradient-to-t from-black/80 to-transparent p-5", children: /* @__PURE__ */ jsxRuntime.jsx(CaptureProgressRing, { progress, children: /* @__PURE__ */ jsxRuntime.jsx(
1408
+ "button",
1409
+ {
1410
+ "aria-busy": busy,
1411
+ "aria-label": labels.shutter,
1412
+ className: "flex size-14 items-center justify-center rounded-full bg-white text-black shadow focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white disabled:opacity-50",
1413
+ disabled: !cameraReady || busy,
1414
+ onClick: (event) => {
1415
+ event.preventDefault();
1416
+ event.stopPropagation();
1417
+ void shutterFromVideo();
1418
+ },
1419
+ type: "button",
1420
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pointer-events-none size-10 rounded-full border-2 border-neutral-900/80" })
1421
+ }
1422
+ ) }) })
1423
+ ]
1424
+ }
1425
+ )
1426
+ }
1427
+ ) : null,
1428
+ phase === "confirm" && previewUrl ? /* @__PURE__ */ jsxRuntime.jsxs(
1429
+ CaptureStage,
1430
+ {
1431
+ fullBleed: true,
1432
+ helpIllustrationSrc: illustrationSrc,
1433
+ helpLabel: labels.captureHelp,
1434
+ helpTips,
1435
+ helpTitle: labels.captureHelpTitle,
1436
+ muteLabel: labels.muteSound,
1437
+ muted,
1438
+ onMutedChange: setMuted,
1439
+ pillLabel: pillLabel ?? stepLabel,
1440
+ progressLabel,
1441
+ statusPoliteness: "assertive",
1442
+ statusText: labels.confirmPhoto,
1443
+ stepLabel,
1444
+ unmuteLabel: labels.unmuteSound,
1445
+ children: [
1446
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative mx-auto aspect-[3/4] max-h-[min(70vh,100dvh)] w-full sm:max-w-md", children: [
1447
+ /* @__PURE__ */ jsxRuntime.jsx(
1448
+ "img",
1449
+ {
1450
+ alt: labels.previewAlt,
1451
+ className: `h-full w-full object-contain ${reduceMotion ? "" : "transition-opacity duration-200"}`,
1452
+ src: previewUrl
1453
+ }
1454
+ ),
1455
+ justCaptured ? /* @__PURE__ */ jsxRuntime.jsx(CaptureCheck, { reduceMotion }) : null
1456
+ ] }),
1457
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute inset-x-0 bottom-0 z-30 flex flex-wrap justify-center gap-2 bg-gradient-to-t from-black/80 to-transparent p-5", children: [
1458
+ /* @__PURE__ */ jsxRuntime.jsx(
1459
+ button_js.Button,
1460
+ {
1461
+ disabled: busy || !pendingCapture,
1462
+ onClick: onAcceptPhoto,
1463
+ type: "button",
1464
+ children: labels.acceptPhoto
1465
+ }
1466
+ ),
1467
+ /* @__PURE__ */ jsxRuntime.jsx(
1468
+ button_js.Button,
1469
+ {
1470
+ disabled: busy,
1471
+ onClick: onDiscardPhoto,
1472
+ type: "button",
1473
+ variant: "outline",
1474
+ className: "border-white/30 bg-black/40 text-white hover:bg-black/60",
1475
+ children: labels.discardPhoto
1476
+ }
1477
+ )
1478
+ ] })
1479
+ ]
1480
+ }
1481
+ ) : null,
1482
+ showFilePicker ? /* @__PURE__ */ jsxRuntime.jsxs(
1483
+ "div",
1484
+ {
1485
+ className: `flex flex-col gap-1.5 ${fullBleed ? "px-4 pb-6" : ""}`,
1486
+ children: [
1487
+ cameraFailed ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: labels.fileFallback }) : null,
1488
+ /* @__PURE__ */ jsxRuntime.jsx(
1489
+ "input",
1490
+ {
1491
+ accept: "image/*",
1492
+ capture: "environment",
1493
+ className: "sr-only",
1494
+ disabled: busy,
1495
+ id: `kyc-file-${slot}`,
1496
+ onChange: () => void onFileChange(),
1497
+ ref: fileRef,
1498
+ tabIndex: -1,
1499
+ type: "file"
1500
+ }
1501
+ ),
1502
+ /* @__PURE__ */ jsxRuntime.jsx(
1503
+ button_js.Button,
1504
+ {
1505
+ className: "self-start px-0",
1506
+ disabled: busy,
1507
+ onClick: () => fileRef.current?.click(),
1508
+ type: "button",
1509
+ variant: "link",
1510
+ children: cameraFailed ? labels.fileFallback : labels.fileFallbackAlt
1511
+ }
1512
+ )
1513
+ ]
1514
+ }
1515
+ ) : null
1516
+ ] });
1517
+ }
1518
+ var KycIdCapture = IdCapture;
1519
+
1520
+ exports.AUTO_CAPTURE_READY_COUNT = AUTO_CAPTURE_READY_COUNT;
1521
+ exports.AUTO_CAPTURE_SAMPLE_HZ = AUTO_CAPTURE_SAMPLE_HZ;
1522
+ exports.AutoCaptureController = AutoCaptureController;
1523
+ exports.CAPTURE_MUTE_KEY = CAPTURE_MUTE_KEY;
1524
+ exports.CaptureCheck = CaptureCheck;
1525
+ exports.CaptureDebugReadout = CaptureDebugReadout;
1526
+ exports.CaptureProgressRing = CaptureProgressRing;
1527
+ exports.CaptureStage = CaptureStage;
1528
+ exports.EDGE_BAND_X = EDGE_BAND_X;
1529
+ exports.EDGE_BAND_Y = EDGE_BAND_Y;
1530
+ exports.EDGE_MIN_CONTRAST = EDGE_MIN_CONTRAST;
1531
+ exports.EDGE_MIN_STRENGTH = EDGE_MIN_STRENGTH;
1532
+ exports.EDGE_SEGMENTS = EDGE_SEGMENTS;
1533
+ exports.EDGE_SEGMENTS_NEEDED = EDGE_SEGMENTS_NEEDED;
1534
+ exports.EDGE_SPAN = EDGE_SPAN;
1535
+ exports.FOCUS_PLATEAU_RATIO = FOCUS_PLATEAU_RATIO;
1536
+ exports.FOCUS_SETTLE_SAMPLES = FOCUS_SETTLE_SAMPLES;
1537
+ exports.FOCUS_WINDOW_MS = FOCUS_WINDOW_MS;
1538
+ exports.GUIDE_EDGE_MARGIN = GUIDE_EDGE_MARGIN;
1539
+ exports.GUIDE_INTERIOR_INSET = GUIDE_INTERIOR_INSET;
1540
+ exports.GUIDE_SAMPLE_WIDTH = GUIDE_SAMPLE_WIDTH;
1541
+ exports.ID_CARD_ASPECT = ID_CARD_ASPECT;
1542
+ exports.ID_PREVIEW_ZOOM = ID_PREVIEW_ZOOM;
1543
+ exports.IdCapture = IdCapture;
1544
+ exports.KYC_BLUR_MIN = KYC_BLUR_MIN;
1545
+ exports.KYC_DARK_MAX_MEAN = KYC_DARK_MAX_MEAN;
1546
+ exports.KYC_IMAGE_MAX_SIDE = KYC_IMAGE_MAX_SIDE;
1547
+ exports.KYC_SHARPNESS_MIN = KYC_SHARPNESS_MIN;
1548
+ exports.KycIdCapture = KycIdCapture;
1549
+ exports.SHARPEST_FRAME_MAX_AGE_MS = SHARPEST_FRAME_MAX_AGE_MS;
1550
+ exports.SHARPNESS_SAMPLE_WIDTH = SHARPNESS_SAMPLE_WIDTH;
1551
+ exports.SharpestFrame = SharpestFrame;
1552
+ exports.assessGrayPixels = assessGrayPixels;
1553
+ exports.assessImageData = assessImageData;
1554
+ exports.assessSharpness = assessSharpness;
1555
+ exports.bytesToBase64 = bytesToBase64;
1556
+ exports.captureVideoFrame = captureVideoFrame;
1557
+ exports.countGuideEdges = countGuideEdges;
1558
+ exports.defaultIdGuideRect = defaultIdGuideRect;
1559
+ exports.idGuideLayout = idGuideLayout;
1560
+ exports.idGuideRectForCoveredStage = idGuideRectForCoveredStage;
1561
+ exports.isCaptureMuted = isCaptureMuted;
1562
+ exports.objectCoverVisibleRect = objectCoverVisibleRect;
1563
+ exports.persistCaptureMute = persistCaptureMute;
1564
+ exports.pickRecorderMime = pickRecorderMime;
1565
+ exports.playCaptureBeep = playCaptureBeep;
1566
+ exports.prefersReducedMotion = prefersReducedMotion;
1567
+ exports.prepareIdJpeg = prepareIdJpeg;
1568
+ exports.primeCaptureAudio = primeCaptureAudio;
1569
+ exports.readCaptureDebugFlag = readCaptureDebugFlag;
1570
+ exports.readInitialCaptureMute = readInitialCaptureMute;
1571
+ exports.recorderExtension = recorderExtension;
1572
+ exports.requestContinuousFocus = requestContinuousFocus;
1573
+ exports.resetCaptureAudioForTests = resetCaptureAudioForTests;
1574
+ exports.rgbaToGray = rgbaToGray;
1575
+ exports.sampleGuideSharpness = sampleGuideSharpness;
1576
+ exports.sampleVideoQuality = sampleVideoQuality;
1577
+ exports.setCaptureMuted = setCaptureMuted;
1578
+ exports.toneWavDataUri = toneWavDataUri;
1579
+ //# sourceMappingURL=kyc.cjs.map
1580
+ //# sourceMappingURL=kyc.cjs.map