idmission-web-sdk 2.3.87 → 2.3.88

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 (54) hide show
  1. package/dist/components/customer_flows/SignatureKYC.d.ts +6 -0
  2. package/dist/components/customer_flows/SignatureKYC.d.ts.map +1 -1
  3. package/dist/components/selfie_capture/SelfieCapture.d.ts +4 -0
  4. package/dist/components/selfie_capture/SelfieCapture.d.ts.map +1 -1
  5. package/dist/components/selfie_capture/SelfieGuidanceModelsProvider.d.ts +4 -1
  6. package/dist/components/selfie_capture/SelfieGuidanceModelsProvider.d.ts.map +1 -1
  7. package/dist/components/submission/SubmissionProvider.d.ts +0 -2
  8. package/dist/components/submission/SubmissionProvider.d.ts.map +1 -1
  9. package/dist/components/submission/types.d.ts +0 -2
  10. package/dist/components/submission/types.d.ts.map +1 -1
  11. package/dist/components/video_signature_capture/VideoSignatureCapture.d.ts.map +1 -1
  12. package/dist/components/video_signature_capture/VideoSignatureContext.d.ts +2 -7
  13. package/dist/components/video_signature_capture/VideoSignatureContext.d.ts.map +1 -1
  14. package/dist/components/video_signature_capture/VideoSignatureGuides.d.ts.map +1 -1
  15. package/dist/components/video_signature_capture/VideoSignaturePad.d.ts.map +1 -1
  16. package/dist/components/video_signature_capture/VideoSignatureWizard.d.ts +4 -1
  17. package/dist/components/video_signature_capture/VideoSignatureWizard.d.ts.map +1 -1
  18. package/dist/lib/camera/useVideoRecorder.d.ts.map +1 -1
  19. package/dist/lib/locales/de.d.ts +1 -0
  20. package/dist/lib/locales/de.d.ts.map +1 -1
  21. package/dist/lib/locales/es.d.ts +1 -0
  22. package/dist/lib/locales/es.d.ts.map +1 -1
  23. package/dist/lib/locales/fr.d.ts +1 -0
  24. package/dist/lib/locales/fr.d.ts.map +1 -1
  25. package/dist/lib/locales/index.d.ts +8 -0
  26. package/dist/lib/locales/index.d.ts.map +1 -1
  27. package/dist/lib/locales/it.d.ts +1 -0
  28. package/dist/lib/locales/it.d.ts.map +1 -1
  29. package/dist/lib/locales/ja.d.ts +1 -0
  30. package/dist/lib/locales/ja.d.ts.map +1 -1
  31. package/dist/lib/locales/pt.d.ts +1 -0
  32. package/dist/lib/locales/pt.d.ts.map +1 -1
  33. package/dist/lib/locales/ru.d.ts +1 -0
  34. package/dist/lib/locales/ru.d.ts.map +1 -1
  35. package/dist/lib/locales/zh.d.ts +1 -0
  36. package/dist/lib/locales/zh.d.ts.map +1 -1
  37. package/dist/lib/models/FaceDetection.d.ts +9 -1
  38. package/dist/lib/models/FaceDetection.d.ts.map +1 -1
  39. package/dist/lib/utils/lighting.d.ts +19 -0
  40. package/dist/lib/utils/lighting.d.ts.map +1 -0
  41. package/dist/sdk2.cjs.development.js +247 -221
  42. package/dist/sdk2.cjs.development.js.map +1 -1
  43. package/dist/sdk2.cjs.production.js +1 -1
  44. package/dist/sdk2.cjs.production.js.map +1 -1
  45. package/dist/sdk2.esm.js +247 -221
  46. package/dist/sdk2.esm.js.map +1 -1
  47. package/dist/sdk2.umd.development.js +247 -221
  48. package/dist/sdk2.umd.development.js.map +1 -1
  49. package/dist/sdk2.umd.production.js +1 -1
  50. package/dist/sdk2.umd.production.js.map +1 -1
  51. package/dist/version.d.ts +1 -1
  52. package/package.json +3 -3
  53. package/dist/lib/utils/blobs.d.ts +0 -3
  54. package/dist/lib/utils/blobs.d.ts.map +0 -1
@@ -211,7 +211,7 @@
211
211
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
212
212
  };
213
213
 
214
- var webSdkVersion = '2.3.87';
214
+ var webSdkVersion = '2.3.88';
215
215
 
216
216
  function getPlatform() {
217
217
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -2125,12 +2125,6 @@
2125
2125
  setIdCaptureVideoUrl: function setIdCaptureVideoUrl() {
2126
2126
  return null;
2127
2127
  },
2128
- setSignatureStartTimestamp: function setSignatureStartTimestamp() {
2129
- return null;
2130
- },
2131
- setSignatureEndTimestamp: function setSignatureEndTimestamp() {
2132
- return null;
2133
- },
2134
2128
  setIdCaptureVideoIdFrontImage: function setIdCaptureVideoIdFrontImage() {
2135
2129
  return null;
2136
2130
  },
@@ -2295,50 +2289,44 @@
2295
2289
  signatureVideoUrl = _16[0],
2296
2290
  setSignatureVideoUrl = _16[1];
2297
2291
  var _17 = React.useState(null),
2298
- signatureStartTimestamp = _17[0],
2299
- setSignatureStartTimestamp = _17[1];
2292
+ idCaptureVideoUrl = _17[0],
2293
+ setIdCaptureVideoUrl = _17[1];
2300
2294
  var _18 = React.useState(null),
2301
- signatureEndTimestamp = _18[0],
2302
- setSignatureEndTimestamp = _18[1];
2295
+ idCaptureVideoIdFrontImage = _18[0],
2296
+ setIdCaptureVideoIdFrontImage = _18[1];
2303
2297
  var _19 = React.useState(null),
2304
- idCaptureVideoUrl = _19[0],
2305
- setIdCaptureVideoUrl = _19[1];
2298
+ idCaptureVideoIdBackImage = _19[0],
2299
+ setIdCaptureVideoIdBackImage = _19[1];
2306
2300
  var _20 = React.useState(null),
2307
- idCaptureVideoIdFrontImage = _20[0],
2308
- setIdCaptureVideoIdFrontImage = _20[1];
2301
+ idCaptureVideoAudioUrl = _20[0],
2302
+ setIdCaptureVideoAudioUrl = _20[1];
2309
2303
  var _21 = React.useState(null),
2310
- idCaptureVideoIdBackImage = _21[0],
2311
- setIdCaptureVideoIdBackImage = _21[1];
2304
+ idCaptureVideoAudioStartsAt = _21[0],
2305
+ setIdCaptureVideoAudioStartsAt = _21[1];
2312
2306
  var _22 = React.useState(null),
2313
- idCaptureVideoAudioUrl = _22[0],
2314
- setIdCaptureVideoAudioUrl = _22[1];
2307
+ expectedAudioText = _22[0],
2308
+ setExpectedAudioText = _22[1];
2315
2309
  var _23 = React.useState(null),
2316
- idCaptureVideoAudioStartsAt = _23[0],
2317
- setIdCaptureVideoAudioStartsAt = _23[1];
2310
+ additionalDocuments = _23[0],
2311
+ setAdditionalDocuments = _23[1];
2318
2312
  var _24 = React.useState(null),
2319
- expectedAudioText = _24[0],
2320
- setExpectedAudioText = _24[1];
2321
- var _25 = React.useState(null),
2322
- additionalDocuments = _25[0],
2323
- setAdditionalDocuments = _25[1];
2324
- var _26 = React.useState(null),
2325
- geolocationResult = _26[0],
2326
- setGeolocationResult = _26[1];
2327
- var _27 = React.useState(0),
2328
- geolocationAttempts = _27[0],
2329
- setGeolocationAttempts = _27[1];
2330
- var _28 = React.useState(false),
2331
- geolocationBlocked = _28[0],
2332
- setGeolocationBlocked = _28[1];
2313
+ geolocationResult = _24[0],
2314
+ setGeolocationResult = _24[1];
2315
+ var _25 = React.useState(0),
2316
+ geolocationAttempts = _25[0],
2317
+ setGeolocationAttempts = _25[1];
2318
+ var _26 = React.useState(false),
2319
+ geolocationBlocked = _26[0],
2320
+ setGeolocationBlocked = _26[1];
2321
+ var _27 = React.useState([]),
2322
+ idFrontCaptureAttempts = _27[0],
2323
+ setIdFrontCaptureAttempts = _27[1];
2324
+ var _28 = React.useState([]),
2325
+ idBackCaptureAttempts = _28[0],
2326
+ setIdBackCaptureAttempts = _28[1];
2333
2327
  var _29 = React.useState([]),
2334
- idFrontCaptureAttempts = _29[0],
2335
- setIdFrontCaptureAttempts = _29[1];
2336
- var _30 = React.useState([]),
2337
- idBackCaptureAttempts = _30[0],
2338
- setIdBackCaptureAttempts = _30[1];
2339
- var _31 = React.useState([]),
2340
- selfieCaptureAttempts = _31[0],
2341
- setSelfieCaptureAttempts = _31[1];
2328
+ selfieCaptureAttempts = _29[0],
2329
+ setSelfieCaptureAttempts = _29[1];
2342
2330
  var logIdFrontCaptureAttempt = React.useCallback(function (attempt) {
2343
2331
  setIdFrontCaptureAttempts(function (attempts) {
2344
2332
  return __spreadArray(__spreadArray([], attempts, true), [attempt], false);
@@ -2615,12 +2603,6 @@
2615
2603
  submissionRequest.customerData.signatureData.signatureVideo = documents.signatureVideo;
2616
2604
  }
2617
2605
  }
2618
- if (signatureStartTimestamp) {
2619
- submissionRequest.customerData.signatureStartTimestamp = signatureStartTimestamp;
2620
- }
2621
- if (signatureEndTimestamp) {
2622
- submissionRequest.customerData.signatureEndTimestamp = signatureEndTimestamp;
2623
- }
2624
2606
  if (additionalDocuments) {
2625
2607
  submissionRequest.customerData.additionalDocuments = additionalDocuments.map(function (d) {
2626
2608
  return _assign(_assign({}, d), {
@@ -2663,7 +2645,7 @@
2663
2645
  }
2664
2646
  });
2665
2647
  });
2666
- }, [additionalDocuments, bypassAgeValidation, bypassNameMatching, cardData, clientRequestID, companyId, customerDataMatchConfig, deduplicationEnabled, deduplicationSynchronous, documentServiceUrl, enrollmentId, expectedAudioText, geolocationResult, idBackCaptureAttempts, idBackImage, idBackImageRequired, idBackIrImage, idBackUvImage, idCaptureVideoAudioStartsAt, idCaptureVideoAudioUrl, idCaptureVideoIdBackImage, idCaptureVideoIdFrontImage, idCaptureVideoUrl, idCardForFaceMatch, idData, idFrontCaptureAttempts, idFrontImage, idFrontIrImage, idFrontUvImage, idImageResolutionCheck, jobId, manualReviewRequired, needImmediateResponse, passportImage, personalData, selfieCaptureAttempts, selfieImage, signatureData, signatureEndTimestamp, signatureStartTimestamp, signatureVideoUrl, uploadDocument, verifyIdWithExternalDatabases, webhooksClientTraceId, webhooksEnabled, webhooksFireOnReview, webhooksFireOnReviewURL, webhooksSendInputImages, webhooksSendProcessedImages, webhooksStripSpecialCharacters, webhooksURL]);
2648
+ }, [additionalDocuments, bypassAgeValidation, bypassNameMatching, cardData, clientRequestID, companyId, customerDataMatchConfig, deduplicationEnabled, deduplicationSynchronous, documentServiceUrl, enrollmentId, expectedAudioText, geolocationResult, idBackCaptureAttempts, idBackImage, idBackImageRequired, idBackIrImage, idBackUvImage, idCaptureVideoAudioStartsAt, idCaptureVideoAudioUrl, idCaptureVideoIdBackImage, idCaptureVideoIdFrontImage, idCaptureVideoUrl, idCardForFaceMatch, idData, idFrontCaptureAttempts, idFrontImage, idFrontIrImage, idFrontUvImage, idImageResolutionCheck, jobId, manualReviewRequired, needImmediateResponse, passportImage, personalData, selfieCaptureAttempts, selfieImage, signatureData, signatureVideoUrl, uploadDocument, verifyIdWithExternalDatabases, webhooksClientTraceId, webhooksEnabled, webhooksFireOnReview, webhooksFireOnReviewURL, webhooksSendInputImages, webhooksSendProcessedImages, webhooksStripSpecialCharacters, webhooksURL]);
2667
2649
  var defaultOnSubmit = React.useCallback(function () {
2668
2650
  return __awaiter(void 0, void 0, void 0, function () {
2669
2651
  var submissionResponse_1, payload, host, endpoint, response, statusMessage, submissionResponse_2, e_1, err;
@@ -2960,8 +2942,6 @@
2960
2942
  setSelfieImage: setSelfieImage,
2961
2943
  setSignatureData: setSignatureData,
2962
2944
  setSignatureVideoUrl: setSignatureVideoUrl,
2963
- setSignatureStartTimestamp: setSignatureStartTimestamp,
2964
- setSignatureEndTimestamp: setSignatureEndTimestamp,
2965
2945
  setIdCaptureVideoUrl: setIdCaptureVideoUrl,
2966
2946
  setIdCaptureVideoIdFrontImage: setIdCaptureVideoIdFrontImage,
2967
2947
  setIdCaptureVideoIdBackImage: setIdCaptureVideoIdBackImage,
@@ -8800,14 +8780,29 @@
8800
8780
  // we found that the bounding box ends at the brow and misses the forehead. this ratio represents how much we should extend the box to include the forehead.
8801
8781
  _k = _a.noseTrackingThreshold,
8802
8782
  // we found that the bounding box ends at the brow and misses the forehead. this ratio represents how much we should extend the box to include the forehead.
8803
- noseTrackingThreshold = _k === void 0 ? 0.2 : _k;
8783
+ noseTrackingThreshold = _k === void 0 ? 0.2 : _k,
8784
+ // this represents the maximum distance that the nose can be from the center of the face box -- 20% of the face box width or height
8785
+ minCaptureBrightnessThreshold = _a.minCaptureBrightnessThreshold,
8786
+ minCaptureRangeThreshold = _a.minCaptureRangeThreshold,
8787
+ minCaptureVarianceThreshold = _a.minCaptureVarianceThreshold,
8788
+ brightness = _a.brightness,
8789
+ range = _a.range,
8790
+ variance = _a.variance;
8804
8791
  var face = faces[0];
8805
8792
  var faceNotDetected = faces.length === 0;
8806
8793
  var faceNotCentered = false,
8807
8794
  faceLookingAway = false,
8808
8795
  faceTooClose = false,
8809
- faceTooFar = false;
8810
- if (face) {
8796
+ faceTooFar = false,
8797
+ faceVisibilityTooLow = false;
8798
+ var hasAnyThreshold = minCaptureBrightnessThreshold !== undefined || minCaptureRangeThreshold !== undefined || minCaptureVarianceThreshold !== undefined;
8799
+ if (hasAnyThreshold) {
8800
+ var tooDark = minCaptureBrightnessThreshold !== undefined && brightness !== undefined && brightness < minCaptureBrightnessThreshold;
8801
+ var tooLowRange = minCaptureRangeThreshold !== undefined && range !== undefined && range < minCaptureRangeThreshold;
8802
+ var tooLowVariance = minCaptureVarianceThreshold !== undefined && variance !== undefined && variance < minCaptureVarianceThreshold;
8803
+ faceVisibilityTooLow = !!(tooDark || tooLowRange || tooLowVariance);
8804
+ }
8805
+ if (face && !faceVisibilityTooLow) {
8811
8806
  // calculate frame centroids
8812
8807
  var frameCX = videoWidth / 2;
8813
8808
  var frameCY = videoHeight / 2;
@@ -8846,7 +8841,7 @@
8846
8841
  }
8847
8842
  var faceIsStable = false,
8848
8843
  noseIsStable = false;
8849
- if (faceInGuides) {
8844
+ if (faceInGuides && !faceVisibilityTooLow) {
8850
8845
  var framesNeeded = Math.max(Math.ceil(average(framesNeededSamples$1)), 5);
8851
8846
  trackFace(face, framesNeeded, videoWidth, videoHeight);
8852
8847
  faceIsStable = lastNFaces.length >= framesNeeded && !lastNFacePairs.some(function (pair) {
@@ -8856,7 +8851,7 @@
8856
8851
  return pair.distance > noseDistanceThreshold;
8857
8852
  });
8858
8853
  }
8859
- var faceReady = faceInGuides && faceIsStable && noseIsStable;
8854
+ var faceReady = faceInGuides && faceIsStable && noseIsStable && !faceVisibilityTooLow;
8860
8855
  return {
8861
8856
  face: face,
8862
8857
  faceNotDetected: faceNotDetected,
@@ -8867,7 +8862,8 @@
8867
8862
  faceReady: faceReady,
8868
8863
  faceReadyAt: faceReady ? new Date() : null,
8869
8864
  faceIsStable: faceIsStable,
8870
- noseIsStable: noseIsStable
8865
+ noseIsStable: noseIsStable,
8866
+ faceVisibilityTooLow: faceVisibilityTooLow
8871
8867
  };
8872
8868
  }
8873
8869
  function testFaceDetectionAgainstKnownImage(detector) {
@@ -12599,6 +12595,7 @@
12599
12595
  'Move forward...': 'Hay que moverse hacia adelante...',
12600
12596
  'Move to the center...': 'Hay que moverse hacia el centro...',
12601
12597
  'Waiting for face to be detected...': 'Esperando que se detecte la cara...',
12598
+ 'Improve lighting conditions...': 'Hay que buscar mejor iluminación...',
12602
12599
  'Please remove your eye coverings (sunglasses eye patch etc.)...': 'Hay que quitarse lo que cubre los ojos (lentes, parche, etc.)...',
12603
12600
  'Please remove your head coverings (hat scarf etc.)...': 'Hay que quitarse lo que cubre la cabeza (gorra, mascada, etc.)...',
12604
12601
  'Please remove your mask...': 'Hay que quitarse el cubrebocas...',
@@ -12730,6 +12727,7 @@
12730
12727
  'Move forward...': 'Nach vorne bewegen...',
12731
12728
  'Move to the center...': 'In die Mitte bewegen...',
12732
12729
  'Waiting for face to be detected...': 'Warte auf die Gesichtserkennung...',
12730
+ 'Improve lighting conditions...': 'Beleuchtungsbedingungen verbessern...',
12733
12731
  'Please remove your eye coverings (sunglasses eye patch etc.)...': 'Bitte Augenbedeckung entfernen (Sonnenbrille, Augenklappe usw.)...',
12734
12732
  'Please remove your head coverings (hat scarf etc.)...': 'Bitte Kopfbedeckung abnehmen (Mütze, Schal usw.)...',
12735
12733
  'Please remove your mask...': 'Bitte Maske ablegen...',
@@ -12861,6 +12859,7 @@
12861
12859
  'Move forward...': 'Avancez...',
12862
12860
  'Move to the center...': 'Déplacez-vous vers le centre...',
12863
12861
  'Waiting for face to be detected...': 'En attente de détection du visage...',
12862
+ 'Improve lighting conditions...': "Améliorer les conditions d'éclairage...",
12864
12863
  'Please remove your eye coverings (sunglasses eye patch etc.)...': 'Veuillez retirer ce qui recouvre vos yeux (lunettes de soleil, cache-œil, etc.)...',
12865
12864
  'Please remove your head coverings (hat scarf etc.)...': 'Veuillez retirer vos couvre-chefs (chapeau, foulard, etc.)...',
12866
12865
  'Please remove your mask...': 'Veuillez retirer votre masque...',
@@ -12992,6 +12991,7 @@
12992
12991
  'Move forward...': 'Spostarsi più vicino...',
12993
12992
  'Move to the center...': 'Spostarsi al centro...',
12994
12993
  'Waiting for face to be detected...': 'In attesa che venga rilevato il volto...',
12994
+ 'Improve lighting conditions...': 'Migliorare le condizioni di illuminazione...',
12995
12995
  'Please remove your eye coverings (sunglasses eye patch etc.)...': 'Rimuovere tutto ciò che copre gli occhi (occhiali da sole, bende, ecc.)...',
12996
12996
  'Please remove your head coverings (hat scarf etc.)...': 'Rimuovere tutto ciò che ricopre il capo (cappello, sciarpa, ecc.)...',
12997
12997
  'Please remove your mask...': 'Rimuovere la mascherina...',
@@ -13123,6 +13123,7 @@
13123
13123
  'Move forward...': '近づいてください…',
13124
13124
  'Move to the center...': '中央へ移動してください…',
13125
13125
  'Waiting for face to be detected...': '顔が検出されるのを待っています…',
13126
+ 'Improve lighting conditions...': '照明条件を改善してください…',
13126
13127
  'Please remove your eye coverings (sunglasses eye patch etc.)...': '目を覆うもの(サングラスや眼帯など)を取り外してください…',
13127
13128
  'Please remove your head coverings (hat scarf etc.)...': '頭を覆うもの(帽子やスカーフなど)を取り外してください…',
13128
13129
  'Please remove your mask...': 'マスクを取り外してください…',
@@ -13254,6 +13255,7 @@
13254
13255
  'Move forward...': 'Mover para frente...',
13255
13256
  'Move to the center...': 'Mover para o centro...',
13256
13257
  'Waiting for face to be detected...': 'Aguardando a detecção de rosto...',
13258
+ 'Improve lighting conditions...': 'Melhore as condições de iluminação...',
13257
13259
  'Please remove your eye coverings (sunglasses eye patch etc.)...': 'Por favor, remova as coberturas dos olhos (óculos de sol, tapa-olho, etc.)...',
13258
13260
  'Please remove your head coverings (hat scarf etc.)...': 'Por favor, remova as coberturas da cabeça (chapéu, cachecol, etc.)...',
13259
13261
  'Please remove your mask...': 'Por favor, remova sua máscara...',
@@ -13385,6 +13387,7 @@
13385
13387
  'Move forward...': 'Подвиньтесь вперед…',
13386
13388
  'Move to the center...': 'Переместите к центру…',
13387
13389
  'Waiting for face to be detected...': 'Ожидание обнаружения лица…',
13390
+ 'Improve lighting conditions...': 'Улучшите условия освещения…',
13388
13391
  'Please remove your eye coverings (sunglasses eye patch etc.)...': 'Снимите предметы, закрывающие глаза (солнцезащитные очки, повязку и т.д.)…',
13389
13392
  'Please remove your head coverings (hat scarf etc.)...': 'Снимите предметы, покрывающие голову (шапку, шарф и т.д.)…',
13390
13393
  'Please remove your mask...': 'Снимите маску…',
@@ -13516,6 +13519,7 @@
13516
13519
  'Move forward...': '請前進...',
13517
13520
  'Move to the center...': '請移至中心...',
13518
13521
  'Waiting for face to be detected...': '正在等待臉部辨識...',
13522
+ 'Improve lighting conditions...': '改善照明條件...',
13519
13523
  'Please remove your eye coverings (sunglasses eye patch etc.)...': '請取下眼睛遮蓋物(太陽眼鏡、眼罩等)...',
13520
13524
  'Please remove your head coverings (hat scarf etc.)...': '請取下頭部遮蓋物(帽子、圍巾等)...',
13521
13525
  'Please remove your mask...': '請脫下口罩...',
@@ -20773,6 +20777,110 @@
20773
20777
  };
20774
20778
  var templateObject_1$n, templateObject_2$l;
20775
20779
 
20780
+ function detectBrightnessAndContrast(frame, brightnessAverager) {
20781
+ var ctx = frame.getContext('2d');
20782
+ if (!ctx || frame.width === 0 || frame.height === 0) return {};
20783
+ var imageData = ctx.getImageData(0, 0, frame.width, frame.height);
20784
+ var pixels = imageData.data; // This is already Uint8ClampedArray
20785
+ var width = frame.width;
20786
+ var sampleResolution = 10;
20787
+ var xStep = Math.max(1, Math.floor(width / sampleResolution));
20788
+ var yStep = Math.max(1, Math.floor(frame.height / sampleResolution));
20789
+ var brightness = 0;
20790
+ var brightnessForVariance = 0;
20791
+ var minBrightness = Infinity;
20792
+ var maxBrightness = -Infinity;
20793
+ var iterations = 0;
20794
+ for (var y = Math.floor(yStep / 2); y < frame.height; y += yStep) {
20795
+ for (var x = Math.floor(xStep / 2); x < width; x += xStep) {
20796
+ var pixelIndex = (y * width + x) * 4;
20797
+ var r = pixels[pixelIndex];
20798
+ var g = pixels[pixelIndex + 1];
20799
+ var b = pixels[pixelIndex + 2];
20800
+ // https://en.wikipedia.org/wiki/Relative_luminance
20801
+ // pixels are represented by 4 channels/bytes, thus a step of 4
20802
+ // the luminance formula is: 0.2126 * R + 0.7152 * G + 0.0722 * B (alpha is not used in this formula)
20803
+ var luminance = r * 0.2126 + g * 0.7152 + b * 0.0722;
20804
+ brightness += luminance;
20805
+ brightnessForVariance += luminance * luminance;
20806
+ minBrightness = Math.min(minBrightness, luminance);
20807
+ maxBrightness = Math.max(maxBrightness, luminance);
20808
+ iterations++;
20809
+ }
20810
+ }
20811
+ var _a = brightnessAverager(brightness / iterations),
20812
+ avg = _a.avg,
20813
+ isFull = _a.isFull;
20814
+ var range = maxBrightness - minBrightness;
20815
+ var variance = brightnessForVariance / iterations - Math.pow(brightness / iterations, 2);
20816
+ return {
20817
+ brightness: isFull ? avg : undefined,
20818
+ range: isFull ? range : undefined,
20819
+ variance: isFull ? variance : undefined
20820
+ };
20821
+ }
20822
+ function createRunningAvgFIFO(capacity) {
20823
+ var cap = capacity | 0;
20824
+ var buf = new Float64Array(cap);
20825
+ var head = 0; // next write index
20826
+ var count = 0; // how many valid items (<= cap)
20827
+ var sum = 0;
20828
+ return {
20829
+ add: function add(x) {
20830
+ if (count === cap) {
20831
+ sum -= buf[head];
20832
+ } else {
20833
+ count++;
20834
+ }
20835
+ buf[head] = x;
20836
+ sum += x;
20837
+ head = head + 1 === cap ? 0 : head + 1;
20838
+ return {
20839
+ avg: sum / count,
20840
+ isFull: count === cap
20841
+ };
20842
+ },
20843
+ avg: function avg() {
20844
+ return count ? sum / count : 0;
20845
+ },
20846
+ size: function size() {
20847
+ return count;
20848
+ },
20849
+ clear: function clear() {
20850
+ head = 0;
20851
+ count = 0;
20852
+ sum = 0;
20853
+ },
20854
+ isFull: function isFull() {
20855
+ return count === cap;
20856
+ }
20857
+ };
20858
+ }
20859
+ function useRunningAvg(capacity) {
20860
+ var fifoRef = React.useRef();
20861
+ if (!fifoRef.current) fifoRef.current = createRunningAvgFIFO(capacity);
20862
+ React.useEffect(function () {
20863
+ fifoRef.current = createRunningAvgFIFO(capacity);
20864
+ }, [capacity]);
20865
+ return {
20866
+ addToAverage: function addToAverage(x) {
20867
+ return fifoRef.current.add(x);
20868
+ },
20869
+ average: function average() {
20870
+ return fifoRef.current.avg();
20871
+ },
20872
+ size: function size() {
20873
+ return fifoRef.current.size();
20874
+ },
20875
+ isFull: function isFull() {
20876
+ return fifoRef.current.isFull();
20877
+ },
20878
+ clear: function clear() {
20879
+ return fifoRef.current.clear();
20880
+ }
20881
+ };
20882
+ }
20883
+
20776
20884
  var SelfieGuidanceModelsContext = /*#__PURE__*/React.createContext({
20777
20885
  start: function start() {
20778
20886
  return null;
@@ -20802,7 +20910,10 @@
20802
20910
  _c = _a.modelLoadTimeoutMs,
20803
20911
  modelLoadTimeoutMs = _c === void 0 ? defaultSelfieCaptureModelLoadTimeoutMs : _c,
20804
20912
  _d = _a.requireVerticalFaceCentering,
20805
- requireVerticalFaceCentering = _d === void 0 ? true : _d;
20913
+ requireVerticalFaceCentering = _d === void 0 ? true : _d,
20914
+ minCaptureBrightnessThreshold = _a.minCaptureBrightnessThreshold,
20915
+ minCaptureRangeThreshold = _a.minCaptureRangeThreshold,
20916
+ minCaptureVarianceThreshold = _a.minCaptureVarianceThreshold;
20806
20917
  var _e = useCameraStore(useShallow(function (state) {
20807
20918
  return {
20808
20919
  videoRef: state.videoRef,
@@ -20815,6 +20926,7 @@
20815
20926
  cameraReady = _e.cameraReady;
20816
20927
  var canvasRef = React.useRef(null);
20817
20928
  var onPredictionHandler = React.useRef();
20929
+ var addToAverage = useRunningAvg(5).addToAverage;
20818
20930
  var _f = useLoadFaceDetector({
20819
20931
  onModelError: onModelError,
20820
20932
  modelLoadTimeoutMs: modelLoadTimeoutMs,
@@ -20827,7 +20939,7 @@
20827
20939
  modelError = _f.modelError;
20828
20940
  var _g = useFrameLoop(React.useCallback(function () {
20829
20941
  return __awaiter(_this, void 0, void 0, function () {
20830
- var vw, vh, ctx, prediction, processed, e_1;
20942
+ var vw, vh, ctx, thresholdsProvided, brightnessResults, brightness, range, variance, prediction, processed, e_1;
20831
20943
  var _a, _b;
20832
20944
  return __generator(this, function (_c) {
20833
20945
  switch (_c.label) {
@@ -20845,12 +20957,23 @@
20845
20957
  _c.label = 1;
20846
20958
  case 1:
20847
20959
  _c.trys.push([1, 3,, 4]);
20960
+ thresholdsProvided = minCaptureBrightnessThreshold !== undefined || minCaptureRangeThreshold !== undefined || minCaptureVarianceThreshold !== undefined;
20961
+ brightnessResults = thresholdsProvided ? detectBrightnessAndContrast(canvasRef.current, addToAverage) : undefined;
20962
+ brightness = brightnessResults === null || brightnessResults === void 0 ? void 0 : brightnessResults.brightness;
20963
+ range = brightnessResults === null || brightnessResults === void 0 ? void 0 : brightnessResults.range;
20964
+ variance = brightnessResults === null || brightnessResults === void 0 ? void 0 : brightnessResults.variance;
20848
20965
  prediction = makeFaceDetectorPrediction(canvasRef.current);
20849
20966
  processed = processFaceDetectorPrediction({
20850
20967
  faces: (_a = prediction === null || prediction === void 0 ? void 0 : prediction.faces) !== null && _a !== void 0 ? _a : [],
20851
20968
  videoWidth: vw,
20852
20969
  videoHeight: vh,
20853
- requireVerticalFaceCentering: requireVerticalFaceCentering
20970
+ requireVerticalFaceCentering: requireVerticalFaceCentering,
20971
+ minCaptureBrightnessThreshold: minCaptureBrightnessThreshold,
20972
+ minCaptureRangeThreshold: minCaptureRangeThreshold,
20973
+ minCaptureVarianceThreshold: minCaptureVarianceThreshold,
20974
+ brightness: brightness,
20975
+ range: range,
20976
+ variance: variance
20854
20977
  });
20855
20978
  setLastFaceDetectionAt(new Date().getTime());
20856
20979
  // setLastPrediction(processed)
@@ -20868,7 +20991,7 @@
20868
20991
  }
20869
20992
  });
20870
20993
  });
20871
- }, [cameraReady, modelError, ready, requireVerticalFaceCentering, videoLoaded, videoRef]), {
20994
+ }, [cameraReady, modelError, ready, requireVerticalFaceCentering, videoLoaded, videoRef, addToAverage, minCaptureBrightnessThreshold, minCaptureRangeThreshold, minCaptureVarianceThreshold]), {
20872
20995
  throttleMs: throttleMs,
20873
20996
  autoStart: autoStart
20874
20997
  }),
@@ -21241,6 +21364,7 @@
21241
21364
  guidanceMoveForwardText: 'Move forward...',
21242
21365
  guidanceMoveToCenterText: 'Move to the center...',
21243
21366
  guidanceNoFaceDetectedText: 'Waiting for face to be detected...',
21367
+ guidanceVisibilityTooLowText: 'Improve lighting conditions...',
21244
21368
  guidanceNotStableText: 'Please hold still...',
21245
21369
  guidanceManualCaptureText: 'Position your face in the circle and click to capture.',
21246
21370
  manualCaptureBtnText: 'Capture'
@@ -21248,7 +21372,7 @@
21248
21372
  var allowManualCapture = !!guidanceError && allowManualSelfieCaptureOnLoadingError;
21249
21373
  var satisfied = allowManualCapture || ((_b = prediction === null || prediction === void 0 ? void 0 : prediction.faceReady) !== null && _b !== void 0 ? _b : false);
21250
21374
  if (typeof guidanceSatisfied === 'boolean') satisfied = guidanceSatisfied;
21251
- guidanceMessage || (guidanceMessage = allowManualCapture ? verbiage.guidanceManualCaptureText : satisfied ? verbiage.guidanceHoldStillText : !prediction || (prediction === null || prediction === void 0 ? void 0 : prediction.faceNotDetected) ? verbiage.guidanceNoFaceDetectedText : (prediction === null || prediction === void 0 ? void 0 : prediction.faceNotCentered) ? verbiage.guidanceMoveToCenterText : (prediction === null || prediction === void 0 ? void 0 : prediction.faceLookingAway) ? verbiage.guidanceLookStraightText : (prediction === null || prediction === void 0 ? void 0 : prediction.faceTooClose) ? verbiage.guidanceMoveBackText : (prediction === null || prediction === void 0 ? void 0 : prediction.faceTooFar) ? verbiage.guidanceMoveForwardText : !(prediction === null || prediction === void 0 ? void 0 : prediction.faceIsStable) || !(prediction === null || prediction === void 0 ? void 0 : prediction.noseIsStable) ? verbiage.guidanceNotStableText : '');
21375
+ guidanceMessage || (guidanceMessage = allowManualCapture ? verbiage.guidanceManualCaptureText : satisfied ? verbiage.guidanceHoldStillText : (prediction === null || prediction === void 0 ? void 0 : prediction.faceVisibilityTooLow) ? verbiage.guidanceVisibilityTooLowText : !prediction || (prediction === null || prediction === void 0 ? void 0 : prediction.faceNotDetected) ? verbiage.guidanceNoFaceDetectedText : (prediction === null || prediction === void 0 ? void 0 : prediction.faceNotCentered) ? verbiage.guidanceMoveToCenterText : (prediction === null || prediction === void 0 ? void 0 : prediction.faceLookingAway) ? verbiage.guidanceLookStraightText : (prediction === null || prediction === void 0 ? void 0 : prediction.faceTooClose) ? verbiage.guidanceMoveBackText : (prediction === null || prediction === void 0 ? void 0 : prediction.faceTooFar) ? verbiage.guidanceMoveForwardText : !(prediction === null || prediction === void 0 ? void 0 : prediction.faceIsStable) || !(prediction === null || prediction === void 0 ? void 0 : prediction.noseIsStable) ? verbiage.guidanceNotStableText : '');
21252
21376
  if (guidanceError && !allowManualSelfieCaptureOnLoadingError) {
21253
21377
  return /*#__PURE__*/React.createElement(SelfieCaptureFallback, {
21254
21378
  classNames: classNames.fallback
@@ -23566,16 +23690,6 @@
23566
23690
  var AcceptBtn$1 = styled(LoaderButton)(templateObject_2$b || (templateObject_2$b = __makeTemplateObject(["\n margin-left: auto;\n"], ["\n margin-left: auto;\n"])));
23567
23691
  var templateObject_1$c, templateObject_2$b;
23568
23692
 
23569
- function isBlob(blobPart) {
23570
- return typeof Blob !== 'undefined' && blobPart instanceof Blob;
23571
- }
23572
- function inferBlobType(blobPart) {
23573
- var _a;
23574
- if (!isBlob(blobPart)) return undefined;
23575
- var t = ((_a = blobPart.type) !== null && _a !== void 0 ? _a : '').trim();
23576
- return t.length > 0 ? t : undefined;
23577
- }
23578
-
23579
23693
  var videoRecorder = null;
23580
23694
  var audioRecorder = null;
23581
23695
  var videoChunks = [];
@@ -23709,9 +23823,8 @@
23709
23823
  useVideoRecorderStore.getState().clearRecordedData();
23710
23824
  }, []);
23711
23825
  var processVideo = React.useCallback(function () {
23712
- var inferredType = inferBlobType(videoChunks[0]) || (videoRecorder === null || videoRecorder === void 0 ? void 0 : videoRecorder.mimeType) || 'video/mp4';
23713
23826
  var videoBlob = new Blob(videoChunks, {
23714
- type: inferredType
23827
+ type: 'video/mp4'
23715
23828
  });
23716
23829
  useVideoRecorderStore.setState({
23717
23830
  videoUrl: URL.createObjectURL(videoBlob),
@@ -23721,9 +23834,8 @@
23721
23834
  setVideoRecorder(null);
23722
23835
  }, []);
23723
23836
  var processAudio = React.useCallback(function () {
23724
- var inferredType = inferBlobType(audioChunks[0]) || (audioRecorder === null || audioRecorder === void 0 ? void 0 : audioRecorder.mimeType) || 'audio/mp4';
23725
23837
  var audioBlob = new Blob(audioChunks, {
23726
- type: inferredType
23838
+ type: 'audio/mp4'
23727
23839
  });
23728
23840
  useVideoRecorderStore.setState({
23729
23841
  audioUrl: URL.createObjectURL(audioBlob),
@@ -23763,7 +23875,6 @@
23763
23875
  }, [audioRecordingIntentionallyStopped, audioRecordingStopped, audioUrl, isRecordingAudio, isRecordingVideo, videoRecordingIntentionallyStopped, videoRecordingStopped, videoUrl]);
23764
23876
  };
23765
23877
 
23766
- var RECORDING_TIMESTAMP_PADDING_MS = 1000;
23767
23878
  var signatureRecorder = null;
23768
23879
  var signatureChunks = [];
23769
23880
  var videoSignatureInitialState = {
@@ -23776,6 +23887,7 @@
23776
23887
  clearRecordedData: function clearRecordedData() {
23777
23888
  return null;
23778
23889
  },
23890
+ isRecording: false,
23779
23891
  signaturePad: {
23780
23892
  current: null
23781
23893
  },
@@ -23798,7 +23910,7 @@
23798
23910
  if (!camera) throw new Error('Camera not found');
23799
23911
  // set our flag and clear whatever we have recorded so far.
23800
23912
  set({
23801
- recordingStartedAt: performance.now()
23913
+ isRecording: true
23802
23914
  });
23803
23915
  signatureChunks = [];
23804
23916
  // start recording video and audio
@@ -23812,52 +23924,27 @@
23812
23924
  videoBitsPerSecond: 270000,
23813
23925
  audioBitsPerSecond: 32000
23814
23926
  });
23815
- var hasFirstChunk = false;
23816
23927
  signatureRecorder.ondataavailable = function (event) {
23817
23928
  signatureChunks.push(event.data);
23818
- if (!hasFirstChunk) {
23819
- hasFirstChunk = true;
23820
- set({
23821
- firstChunkReceivedAt: performance.now(),
23822
- lastChunkReceivedAt: performance.now()
23823
- });
23824
- } else {
23825
- set({
23826
- lastChunkReceivedAt: performance.now()
23827
- });
23828
- }
23829
23929
  };
23830
23930
  signatureRecorder.start(100);
23831
23931
  },
23832
23932
  stopRecording: function stopRecording(signatureData, imageUrl) {
23833
23933
  set({
23834
- firstChunkReceivedAt: undefined,
23835
- recordingStoppedAt: performance.now()
23836
- });
23837
- waitForOneMoreChunk().then(function () {
23838
- if (!signatureRecorder) return;
23839
- signatureRecorder.stop();
23840
- signatureRecorder.onstop = function () {
23841
- var inferredType = inferBlobType(signatureChunks[0]) || (signatureRecorder === null || signatureRecorder === void 0 ? void 0 : signatureRecorder.mimeType) || 'video/mp4';
23842
- var blob = new Blob(signatureChunks, {
23843
- type: inferredType
23844
- });
23845
- signatureChunks = [];
23846
- signatureRecorder = null;
23847
- if (!signatureData) return;
23848
- var _a = get(),
23849
- onSignatureVideoCaptured = _a.onSignatureVideoCaptured,
23850
- recordingStartedAt = _a.recordingStartedAt,
23851
- signatureStartedAt = _a.signatureStartedAt,
23852
- signatureEndedAt = _a.signatureEndedAt,
23853
- lastChunkReceivedAt = _a.lastChunkReceivedAt;
23854
- var endMs = Math.min(signatureEndedAt !== null && signatureEndedAt !== void 0 ? signatureEndedAt : Infinity, lastChunkReceivedAt !== null && lastChunkReceivedAt !== void 0 ? lastChunkReceivedAt : Infinity);
23855
- var signatureStartTimestamp = signatureStartedAt && recordingStartedAt ? formatTimestamp(Math.max(0, signatureStartedAt - recordingStartedAt - RECORDING_TIMESTAMP_PADDING_MS)) : undefined;
23856
- var signatureEndTimestamp = endMs !== Infinity && recordingStartedAt ? formatTimestamp(Math.min(endMs - recordingStartedAt + RECORDING_TIMESTAMP_PADDING_MS, lastChunkReceivedAt !== null && lastChunkReceivedAt !== void 0 ? lastChunkReceivedAt : Infinity)) : undefined;
23857
- onSignatureVideoCaptured(blob, signatureData, imageUrl !== null && imageUrl !== void 0 ? imageUrl : null, signatureStartTimestamp, signatureEndTimestamp);
23858
- };
23859
- useVideoRecorderStore.getState().stopRecording();
23934
+ isRecording: false
23860
23935
  });
23936
+ if (!signatureRecorder) return;
23937
+ signatureRecorder.stop();
23938
+ signatureRecorder.onstop = function () {
23939
+ var blob = new Blob(signatureChunks, {
23940
+ type: 'video/mp4'
23941
+ });
23942
+ signatureChunks = [];
23943
+ signatureRecorder = null;
23944
+ if (!signatureData) return;
23945
+ get().onSignatureVideoCaptured(blob, signatureData, imageUrl !== null && imageUrl !== void 0 ? imageUrl : null);
23946
+ };
23947
+ useVideoRecorderStore.getState().stopRecording();
23861
23948
  },
23862
23949
  clearRecordedData: function clearRecordedData() {
23863
23950
  signatureChunks = [];
@@ -23866,42 +23953,13 @@
23866
23953
  signatureRecorder === null || signatureRecorder === void 0 ? void 0 : signatureRecorder.stop();
23867
23954
  signatureRecorder = null;
23868
23955
  set({
23869
- recordingStartedAt: undefined,
23870
- recordingStoppedAt: undefined,
23871
- firstChunkReceivedAt: undefined,
23872
- lastChunkReceivedAt: undefined,
23956
+ isRecording: false,
23873
23957
  signaturePadEmpty: true,
23874
- signatureValid: false,
23875
- signatureStartedAt: undefined,
23876
- signatureEndedAt: undefined
23958
+ signatureValid: false
23877
23959
  });
23878
23960
  }
23879
23961
  });
23880
23962
  }));
23881
- function waitForOneMoreChunk(timeoutMs) {
23882
- if (timeoutMs === void 0) {
23883
- timeoutMs = 3000;
23884
- }
23885
- var start = performance.now();
23886
- return new Promise(function (resolve) {
23887
- var initialLastChunkReceivedAt = useVideoSignatureStore.getState().lastChunkReceivedAt;
23888
- if (!initialLastChunkReceivedAt) return resolve();
23889
- function gotAChunk() {
23890
- var lastChunkReceivedAt = useVideoSignatureStore.getState().lastChunkReceivedAt;
23891
- return performance.now() - start > timeoutMs || !lastChunkReceivedAt || !initialLastChunkReceivedAt || lastChunkReceivedAt > initialLastChunkReceivedAt;
23892
- }
23893
- setTimeout(function () {
23894
- if (gotAChunk()) return resolve(); // check immediately
23895
- // otherwise, check every 100ms
23896
- var interval = setInterval(function () {
23897
- if (gotAChunk()) {
23898
- clearInterval(interval);
23899
- resolve();
23900
- }
23901
- }, 100);
23902
- }, 0);
23903
- });
23904
- }
23905
23963
  function VideoSignatureContextProvider(_a) {
23906
23964
  var _this = this;
23907
23965
  var _b, _c;
@@ -23920,14 +23978,7 @@
23920
23978
  // clear recorded data when the component is mounted
23921
23979
  useVideoSignatureStore.getState().clearRecordedData();
23922
23980
  }, []);
23923
- var _e = useVideoSignatureStore(useShallow(function (state) {
23924
- return {
23925
- recordingStartedAt: state.recordingStartedAt,
23926
- recordingStoppedAt: state.recordingStoppedAt
23927
- };
23928
- })),
23929
- recordingStartedAt = _e.recordingStartedAt,
23930
- recordingStoppedAt = _e.recordingStoppedAt;
23981
+ var isRecording = useVideoSignatureStore().isRecording;
23931
23982
  useFrameLoop(React.useCallback(function () {
23932
23983
  return __awaiter(_this, void 0, void 0, function () {
23933
23984
  var signaturePad, ctx, _a, w, h, isPortrait, rect;
@@ -23954,7 +24005,7 @@
23954
24005
  });
23955
24006
  });
23956
24007
  }, [videoRef]), {
23957
- autoStart: !!recordingStartedAt && !recordingStoppedAt,
24008
+ autoStart: isRecording,
23958
24009
  throttleMs: 1000 / 24
23959
24010
  });
23960
24011
  return /*#__PURE__*/React.createElement(React.Fragment, null, children, /*#__PURE__*/React.createElement(InvisibleCanvas, {
@@ -23963,17 +24014,6 @@
23963
24014
  height: (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.videoHeight
23964
24015
  }));
23965
24016
  }
23966
- function formatTimestamp(durationMs) {
23967
- // should be in the format of 00:00:00:00 (hh:mm:ss:cs)
23968
- var hours = Math.floor(durationMs / 3600000);
23969
- var minutes = Math.floor(durationMs % 3600000 / 60000);
23970
- var seconds = Math.floor(durationMs % 60000 / 1000);
23971
- var milliseconds = durationMs % 1000;
23972
- // Convert milliseconds to centiseconds (1/100th of a second)
23973
- var centiseconds = Math.floor(milliseconds / 10);
23974
- var csString = centiseconds.toString().padStart(2, '0');
23975
- return "".concat(hours.toString().padStart(2, '0'), ":") + "".concat(minutes.toString().padStart(2, '0'), ":") + "".concat(seconds.toString().padStart(2, '0'), ":") + "".concat(csString);
23976
- }
23977
24017
 
23978
24018
  function VideoSignaturePad(_a) {
23979
24019
  var onAcceptBtnClicked = _a.onAcceptBtnClicked,
@@ -24035,11 +24075,8 @@
24035
24075
  ref: signaturePad,
24036
24076
  canvasProps: canvasProps,
24037
24077
  onBegin: function onBegin() {
24038
- return useVideoSignatureStore.setState(function (s) {
24039
- return {
24040
- signaturePadEmpty: false,
24041
- signatureStartedAt: s.signatureStartedAt || performance.now()
24042
- };
24078
+ return useVideoSignatureStore.setState({
24079
+ signaturePadEmpty: false
24043
24080
  });
24044
24081
  },
24045
24082
  onEnd: function onEnd() {
@@ -24049,8 +24086,7 @@
24049
24086
  return point;
24050
24087
  });
24051
24088
  useVideoSignatureStore.setState({
24052
- signatureValid: points.length >= minSignaturePadPoints,
24053
- signatureEndedAt: performance.now()
24089
+ signatureValid: points.length >= minSignaturePadPoints
24054
24090
  });
24055
24091
  }
24056
24092
  }), !headTrackingSatisfied && !!verbiage.headTrackingUnsatisfiedText ? ( /*#__PURE__*/React.createElement(SignaturePadContentContainer, {
@@ -24117,12 +24153,6 @@
24117
24153
  React.useEffect(function () {
24118
24154
  if (guideToDisplay) setMode(guideToDisplay);
24119
24155
  }, [guideToDisplay]);
24120
- var firstChunkReceivedAt = useVideoSignatureStore(useShallow(function (state) {
24121
- return {
24122
- firstChunkReceivedAt: state.firstChunkReceivedAt
24123
- };
24124
- })).firstChunkReceivedAt;
24125
- var signaturePadDisabled = requestedAction !== 'CAPTURE_SIGNATURE' || !firstChunkReceivedAt;
24126
24156
  return /*#__PURE__*/React.createElement(Container$3, {
24127
24157
  className: classNames.container
24128
24158
  }, /*#__PURE__*/React.createElement(Inner$1, {
@@ -24146,7 +24176,7 @@
24146
24176
  }, /*#__PURE__*/React.createElement(VideoSignaturePad, {
24147
24177
  onAcceptBtnClicked: onAcceptBtnClicked,
24148
24178
  onClearBtnClicked: onClearBtnClicked,
24149
- disabled: signaturePadDisabled,
24179
+ disabled: requestedAction !== 'CAPTURE_SIGNATURE',
24150
24180
  headTrackingSatisfied: headTrackingSatisfied,
24151
24181
  minSignaturePadPoints: minSignaturePadPoints,
24152
24182
  classNames: classNames,
@@ -24203,11 +24233,9 @@
24203
24233
  onHeadTrackingPredictionMade = _o.onPredictionMade,
24204
24234
  startHeadTracking = _o.start,
24205
24235
  stopHeadTracking = _o.stop;
24206
- var firstChunkReceivedAt = useVideoSignatureStore(useShallow(function (state) {
24207
- return {
24208
- firstChunkReceivedAt: state.firstChunkReceivedAt
24209
- };
24210
- })).firstChunkReceivedAt;
24236
+ var _p = useVideoSignatureStore(),
24237
+ clearRecordedData = _p.clearRecordedData,
24238
+ isRecording = _p.isRecording;
24211
24239
  React.useEffect(function () {
24212
24240
  useVideoSignatureStore.setState({
24213
24241
  onSignatureVideoCaptured: onSignatureVideoCaptured
@@ -24226,15 +24254,15 @@
24226
24254
  var verbiage = useTranslations(rawVerbiage, {
24227
24255
  guidanceMessageText: 'Please sign the box below'
24228
24256
  });
24229
- var _p = React.useState(true),
24230
- headTrackingSatisfied = _p[0],
24231
- setHeadTrackingSatisfied = _p[1];
24232
- var _q = React.useState(null),
24233
- lastFace = _q[0],
24234
- setLastFace = _q[1];
24235
- var _r = React.useState(0),
24236
- numFramesWithoutFaces = _r[0],
24237
- setNumFramesWithoutFaces = _r[1];
24257
+ var _q = React.useState(true),
24258
+ headTrackingSatisfied = _q[0],
24259
+ setHeadTrackingSatisfied = _q[1];
24260
+ var _r = React.useState(null),
24261
+ lastFace = _r[0],
24262
+ setLastFace = _r[1];
24263
+ var _s = React.useState(0),
24264
+ numFramesWithoutFaces = _s[0],
24265
+ setNumFramesWithoutFaces = _s[1];
24238
24266
  onHeadTrackingPredictionMade(f(React.useCallback(function (_a) {
24239
24267
  var face = _a.face;
24240
24268
  if (headTrackingDisabled) return;
@@ -24249,12 +24277,12 @@
24249
24277
  return n + 1;
24250
24278
  });
24251
24279
  }, [headTrackingBoundaryPercentage, headTrackingBoundaryType, headTrackingDisabled, videoHeight, videoWidth]), 16));
24252
- var _s = useResizeObserver(),
24253
- ref = _s.ref,
24254
- _t = _s.width,
24255
- width = _t === void 0 ? 1 : _t,
24256
- _u = _s.height,
24257
- height = _u === void 0 ? 1 : _u;
24280
+ var _t = useResizeObserver(),
24281
+ ref = _t.ref,
24282
+ _u = _t.width,
24283
+ width = _u === void 0 ? 1 : _u,
24284
+ _v = _t.height,
24285
+ height = _v === void 0 ? 1 : _v;
24258
24286
  var debugScalingDetails = useDebugScalingDetails({
24259
24287
  enabled: debugMode,
24260
24288
  pageWidth: width,
@@ -24285,19 +24313,13 @@
24285
24313
  classNames: classNames.guides,
24286
24314
  verbiage: rawVerbiage.guides,
24287
24315
  onClearBtnClicked: restartVideoOnSignaturePadCleared ? function () {
24288
- return setTimeout(function () {
24289
- return useVideoSignatureStore.getState().clearRecordedData();
24290
- }, 100);
24291
- } : function () {
24292
- return useVideoSignatureStore.setState({
24293
- signatureStartedAt: undefined
24294
- });
24295
- }
24316
+ return setTimeout(clearRecordedData, 100);
24317
+ } : undefined
24296
24318
  }), debugMode && ( /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ObjectDetectionDebugOverlayDiv, null, lastFace && ( /*#__PURE__*/React.createElement(SelfieCaptureFaceDebugBox, {
24297
24319
  face: lastFace,
24298
24320
  scaling: debugScalingDetails,
24299
24321
  color: headTrackingSatisfied ? 'green' : 'red'
24300
- }))), /*#__PURE__*/React.createElement(DebugStatsPane, null, "Video: ", videoWidth, "x", videoHeight, /*#__PURE__*/React.createElement("br", null), "Recording: ", firstChunkReceivedAt ? 'true' : 'false'))), /*#__PURE__*/React.createElement(ExitCaptureButton, {
24322
+ }))), /*#__PURE__*/React.createElement(DebugStatsPane, null, "Video: ", videoWidth, "x", videoHeight, /*#__PURE__*/React.createElement("br", null), "Recording: ", isRecording ? 'true' : 'false'))), /*#__PURE__*/React.createElement(ExitCaptureButton, {
24301
24323
  onClick: onExit,
24302
24324
  className: classNames.exitCaptureBtn
24303
24325
  }));
@@ -24628,8 +24650,6 @@
24628
24650
  setSelfieImage = _u.setSelfieImage,
24629
24651
  setSignatureData = _u.setSignatureData,
24630
24652
  setSignatureVideoUrl = _u.setSignatureVideoUrl,
24631
- setSignatureStartTimestamp = _u.setSignatureStartTimestamp,
24632
- setSignatureEndTimestamp = _u.setSignatureEndTimestamp,
24633
24653
  logSelfieCaptureAttempt = _u.logSelfieCaptureAttempt,
24634
24654
  uploadDocument = _u.uploadDocument;
24635
24655
  var cameraAccessDenied = useCameraStore(useShallow(function (state) {
@@ -24689,14 +24709,12 @@
24689
24709
  filetype: 'image/jpeg'
24690
24710
  }).then(onSelfieCaptured);
24691
24711
  }, [logCaptureMetadata, onSelfieCaptured, setSelfieImage, uploadDocument]);
24692
- var onSignatureCaptureCompleted = React.useCallback(function (videoData, signatureData, signatureImageData, signatureStartTimestamp, signatureEndTimestamp) {
24712
+ var onSignatureCaptureCompleted = React.useCallback(function (videoData, signatureData, signatureImageData) {
24693
24713
  setSignatureData(signatureData);
24694
24714
  setSignatureVideoUrl(URL.createObjectURL(videoData));
24695
- if (signatureStartTimestamp) setSignatureStartTimestamp(signatureStartTimestamp);
24696
- if (signatureEndTimestamp) setSignatureEndTimestamp(signatureEndTimestamp);
24697
24715
  setCaptureState('SUCCESS');
24698
- onVideoCaptured === null || onVideoCaptured === void 0 ? void 0 : onVideoCaptured(videoData, signatureData, signatureImageData, signatureStartTimestamp, signatureEndTimestamp);
24699
- }, [onVideoCaptured, setSignatureData, setSignatureEndTimestamp, setSignatureStartTimestamp, setSignatureVideoUrl]);
24716
+ onVideoCaptured === null || onVideoCaptured === void 0 ? void 0 : onVideoCaptured(videoData, signatureData, signatureImageData);
24717
+ }, [onVideoCaptured, setSignatureData, setSignatureVideoUrl]);
24700
24718
  var _x = React.useState(true),
24701
24719
  showLoadingOverlay = _x[0],
24702
24720
  setShowLoadingOverlay = _x[1];
@@ -24865,7 +24883,6 @@
24865
24883
  var onClearBtnClicked = React.useCallback(function () {
24866
24884
  var _a, _b;
24867
24885
  useVideoSignatureStore.setState({
24868
- signatureStartedAt: undefined,
24869
24886
  signaturePadEmpty: true,
24870
24887
  signatureValid: false
24871
24888
  });
@@ -24916,7 +24933,10 @@
24916
24933
  throttleMs: 250,
24917
24934
  onModelError: props.onModelError,
24918
24935
  modelLoadTimeoutMs: props.modelLoadTimeoutMs,
24919
- requireVerticalFaceCentering: false
24936
+ requireVerticalFaceCentering: false,
24937
+ minCaptureBrightnessThreshold: props.minCaptureBrightnessThreshold,
24938
+ minCaptureRangeThreshold: props.minCaptureRangeThreshold,
24939
+ minCaptureVarianceThreshold: props.minCaptureVarianceThreshold
24920
24940
  }, /*#__PURE__*/React.createElement(VideoSignatureWizard, _assign({}, props, {
24921
24941
  onRetryClicked: onRetryClicked
24922
24942
  }))));
@@ -28667,6 +28687,9 @@
28667
28687
  guidesComponent = _a.guidesComponent,
28668
28688
  _q = _a.showFaceGuideThenSignaturePad,
28669
28689
  showFaceGuideThenSignaturePad = _q === void 0 ? false : _q,
28690
+ minCaptureBrightnessThreshold = _a.minCaptureBrightnessThreshold,
28691
+ minCaptureRangeThreshold = _a.minCaptureRangeThreshold,
28692
+ minCaptureVarianceThreshold = _a.minCaptureVarianceThreshold,
28670
28693
  _r = _a.theme,
28671
28694
  theme = _r === void 0 ? 'default' : _r,
28672
28695
  classNames = _a.classNames,
@@ -28737,6 +28760,9 @@
28737
28760
  allowManualSelfieCaptureOnLoadingError: allowManualSelfieCaptureOnLoadingError,
28738
28761
  guidesComponent: guidesComponent,
28739
28762
  showFaceGuideThenSignaturePad: showFaceGuideThenSignaturePad,
28763
+ minCaptureBrightnessThreshold: minCaptureBrightnessThreshold,
28764
+ minCaptureRangeThreshold: minCaptureRangeThreshold,
28765
+ minCaptureVarianceThreshold: minCaptureVarianceThreshold,
28740
28766
  classNames: classNames,
28741
28767
  colors: colors,
28742
28768
  debugMode: debugMode,
@@ -28744,7 +28770,7 @@
28744
28770
  onModelError: onModelError,
28745
28771
  onUserCancel: onUserCancel
28746
28772
  };
28747
- }, [onLoadingStarted, onLoadingProgress, onLoadingCompleted, onLoadingFailed, onSelfieCaptured, customOverlayContent, onLoadingOverlayDismissed, loadingOverlayMode, skipSuccessScreen, captureAudio, minSignaturePadPoints, headTrackingDisabled, headTrackingBoundaryPercentage, headTrackingBoundaryType, modelLoadTimeoutMs, faceLivenessProps, allowSignatureAfterLivenessCheckFailure, restartVideoOnSignaturePadCleared, skipLivenessValidation, allowManualSelfieCaptureOnLoadingError, guidesComponent, showFaceGuideThenSignaturePad, classNames, colors, debugMode, verbiage, onModelError, onUserCancel])
28773
+ }, [onLoadingStarted, onLoadingProgress, onLoadingCompleted, onLoadingFailed, onSelfieCaptured, customOverlayContent, onLoadingOverlayDismissed, loadingOverlayMode, skipSuccessScreen, captureAudio, minSignaturePadPoints, headTrackingDisabled, headTrackingBoundaryPercentage, headTrackingBoundaryType, modelLoadTimeoutMs, faceLivenessProps, allowSignatureAfterLivenessCheckFailure, restartVideoOnSignaturePadCleared, skipLivenessValidation, allowManualSelfieCaptureOnLoadingError, guidesComponent, showFaceGuideThenSignaturePad, minCaptureBrightnessThreshold, minCaptureRangeThreshold, minCaptureVarianceThreshold, classNames, colors, debugMode, verbiage, onModelError, onUserCancel])
28748
28774
  })))));
28749
28775
  };
28750
28776