idmission-web-sdk 2.3.114 → 2.3.115

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/sdk2.esm.js CHANGED
@@ -7,7 +7,7 @@ import { createPortal } from 'react-dom';
7
7
  import { useTranslation, initReactI18next } from 'react-i18next';
8
8
  import { Upload } from 'tus-js-client';
9
9
  import SparkMD5 from 'spark-md5';
10
- import { ImageSegmenter, FilesetResolver, ObjectDetector, ImageClassifier, FaceDetector } from '@mediapipe/tasks-vision';
10
+ import { ImageSegmenter, FilesetResolver, ObjectDetector, ImageClassifier } from '@mediapipe/tasks-vision';
11
11
  import { useStore, createStore, create } from 'zustand';
12
12
  import LanguageDetector from 'i18next-browser-languagedetector';
13
13
  import i18n from 'i18next';
@@ -205,7 +205,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
205
205
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
206
206
  };
207
207
 
208
- var webSdkVersion = '2.3.114';
208
+ var webSdkVersion = '2.3.115';
209
209
 
210
210
  function getPlatform() {
211
211
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -2348,8 +2348,8 @@ function giveUpAfter(maxTime) {
2348
2348
 
2349
2349
  var DEFAULT_CDN_URL = 'https://websdk-cdn-dev.idmission.com/assets';
2350
2350
 
2351
- var defaultDocumentDetectorModelPath = "".concat(DEFAULT_CDN_URL, "/models/DocumentDetector/DocumentDetector-20250815_115859.tflite");
2352
- var defaultDocumentDetectorModelHash = '64LSaO2ctQsTkGJoZ6Et4v2KH28Fz1ettgkxD+qFg6frxY7ufL9l/lkjw2ljX2cR';
2351
+ var defaultDocumentDetectorModelPath = "".concat(DEFAULT_CDN_URL, "/models/DocumentDetector/DocumentDetector-20251018_121234.tflite");
2352
+ var defaultDocumentDetectorModelHash = 'cTLjb4g6H+a+RHnLaYrvVF8050qv/Ox04rMtxFXBDR6Xv8Pv+X//hsaO3K3jNPog';
2353
2353
 
2354
2354
  var defaultFocusModelPath = "".concat(DEFAULT_CDN_URL, "/models/Focus/Focus-20241008_102708.tflite");
2355
2355
  var defaultFocusModelHash = 'HTJNLB7QybtPXIIyUI9oNqW40vE5bgSV5V24R1wXLQHknNEVOSyDQDo/QzRgJ8jb';
@@ -2666,8 +2666,8 @@ var documentTypeDisplayNames = {
2666
2666
  singlePage: 'Single page',
2667
2667
  none: 'None'
2668
2668
  };
2669
- var detector$1 = null;
2670
- var detectorSettings$1 = null;
2669
+ var detector = null;
2670
+ var detectorSettings = null;
2671
2671
  function loadDocumentDetector() {
2672
2672
  return __awaiter(this, arguments, void 0, function (modelAssetPath, scoreThreshold) {
2673
2673
  var _a, _b;
@@ -2680,7 +2680,7 @@ function loadDocumentDetector() {
2680
2680
  return __generator(this, function (_c) {
2681
2681
  switch (_c.label) {
2682
2682
  case 0:
2683
- if (detector$1 && (detectorSettings$1 === null || detectorSettings$1 === void 0 ? void 0 : detectorSettings$1.modelAssetPath) === modelAssetPath && (detectorSettings$1 === null || detectorSettings$1 === void 0 ? void 0 : detectorSettings$1.scoreThreshold) === scoreThreshold) return [2 /*return*/, detector$1];
2683
+ if (detector && (detectorSettings === null || detectorSettings === void 0 ? void 0 : detectorSettings.modelAssetPath) === modelAssetPath && (detectorSettings === null || detectorSettings === void 0 ? void 0 : detectorSettings.scoreThreshold) === scoreThreshold) return [2 /*return*/, detector];
2684
2684
  closeDocumentDetector();
2685
2685
  return [4 /*yield*/, preloadDocumentDetectorDependencies()];
2686
2686
  case 1:
@@ -2701,20 +2701,20 @@ function loadDocumentDetector() {
2701
2701
  runningMode: 'VIDEO'
2702
2702
  }])];
2703
2703
  case 3:
2704
- detector$1 = _c.sent();
2705
- detectorSettings$1 = {
2704
+ detector = _c.sent();
2705
+ detectorSettings = {
2706
2706
  modelAssetPath: modelAssetPath,
2707
2707
  scoreThreshold: scoreThreshold
2708
2708
  };
2709
- return [2 /*return*/, detector$1];
2709
+ return [2 /*return*/, detector];
2710
2710
  }
2711
2711
  });
2712
2712
  });
2713
2713
  }
2714
2714
  function closeDocumentDetector() {
2715
- detector$1 === null || detector$1 === void 0 ? void 0 : detector$1.close();
2716
- detector$1 = null;
2717
- detectorSettings$1 = null;
2715
+ detector === null || detector === void 0 ? void 0 : detector.close();
2716
+ detector = null;
2717
+ detectorSettings = null;
2718
2718
  }
2719
2719
  function useLoadDocumentDetector(_a) {
2720
2720
  var _b = _a.shouldLoadModels,
@@ -2815,12 +2815,12 @@ function makeDocumentDetectorPrediction(frame) {
2815
2815
  return __awaiter(this, void 0, void 0, function () {
2816
2816
  var startedAt, prediction, time, frameWidth, frameHeight;
2817
2817
  return __generator(this, function (_a) {
2818
- if (!detector$1) return [2 /*return*/, null];
2818
+ if (!detector) return [2 /*return*/, null];
2819
2819
  startedAt = performance.now();
2820
2820
  // Detectors can throw errors, for example when using custom URLs that
2821
2821
  // contain a model that doesn't provide the expected output.
2822
2822
  try {
2823
- prediction = detector$1.detectForVideo(frame, performance.now());
2823
+ prediction = detector.detectForVideo(frame, performance.now());
2824
2824
  time = performance.now() - startedAt;
2825
2825
  frameWidth = frame.width;
2826
2826
  frameHeight = frame.height;
@@ -6800,6 +6800,7 @@ function SelfieCaptureFaceKeypoint(_a) {
6800
6800
  scaledHeight = _c.scaledHeight,
6801
6801
  xOffset = _c.xOffset,
6802
6802
  yOffset = _c.yOffset;
6803
+ if (!point) return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
6803
6804
  var left, top;
6804
6805
  if (horizontal) {
6805
6806
  left = point.x / videoWidth * scaledWidth - xOffset;
@@ -11874,136 +11875,6 @@ var FaceCaptureGuideOverlay = function FaceCaptureGuideOverlay(_a) {
11874
11875
  var templateObject_1$n, templateObject_2$l;
11875
11876
 
11876
11877
  var defaultSelfieCaptureModelLoadTimeoutMs = 45000;
11877
- var detector = null;
11878
- var detectorSettings = null;
11879
- function loadFaceDetector() {
11880
- return __awaiter(this, arguments, void 0, function (modelAssetPath) {
11881
- var _a, _b;
11882
- if (modelAssetPath === void 0) {
11883
- modelAssetPath = defaultFaceDetectorModelPath;
11884
- }
11885
- return __generator(this, function (_c) {
11886
- switch (_c.label) {
11887
- case 0:
11888
- if (detector && (detectorSettings === null || detectorSettings === void 0 ? void 0 : detectorSettings.modelAssetPath) === modelAssetPath) return [2 /*return*/, detector];
11889
- closeFaceDetector();
11890
- return [4 /*yield*/, preloadFaceDetectorDependencies()];
11891
- case 1:
11892
- _c.sent();
11893
- if (modelCapabilities.delegate === 'NONE') {
11894
- throw new Error('No available delegate for face detector.');
11895
- }
11896
- _b = (_a = FaceDetector).createFromOptions;
11897
- return [4 /*yield*/, FilesetResolver.forVisionTasks(visionTasksBasePath)];
11898
- case 2:
11899
- return [4 /*yield*/, _b.apply(_a, [_c.sent(), {
11900
- // canvas: document.createElement('canvas'),
11901
- baseOptions: {
11902
- modelAssetPath: modelAssetPath,
11903
- delegate: modelCapabilities.delegate
11904
- },
11905
- runningMode: 'VIDEO'
11906
- }])];
11907
- case 3:
11908
- detector = _c.sent();
11909
- detectorSettings = {
11910
- modelAssetPath: modelAssetPath
11911
- };
11912
- return [2 /*return*/, detector];
11913
- }
11914
- });
11915
- });
11916
- }
11917
- function closeFaceDetector() {
11918
- detector === null || detector === void 0 ? void 0 : detector.close();
11919
- detector = null;
11920
- detectorSettings = null;
11921
- }
11922
- function useLoadFaceDetector(_a) {
11923
- var onModelError = _a.onModelError,
11924
- _b = _a.modelLoadTimeoutMs,
11925
- modelLoadTimeoutMs = _b === void 0 ? defaultSelfieCaptureModelLoadTimeoutMs : _b,
11926
- videoRef = _a.videoRef;
11927
- var _c = useState('not-started'),
11928
- modelLoadState = _c[0],
11929
- setModelLoadState = _c[1];
11930
- var _d = useState(0),
11931
- modelDownloadProgress = _d[0],
11932
- setModelDownloadProgress = _d[1];
11933
- var _e = useState(null),
11934
- modelWarmingStartedAt = _e[0],
11935
- setModelWarmingStartedAt = _e[1];
11936
- var _f = useState(null),
11937
- modelError = _f[0],
11938
- setModelError = _f[1];
11939
- useEffect(function loadModel() {
11940
- var _this = this;
11941
- setModelLoadState('downloading');
11942
- setModelWarmingStartedAt(null);
11943
- var modelLoadTimeout = setTimeout(function () {
11944
- setModelError(new Error('Model loading time limit exceeded.'));
11945
- }, modelLoadTimeoutMs);
11946
- function handleDownloadProgress(event) {
11947
- setModelDownloadProgress(progressToPercentage(event.detail));
11948
- }
11949
- document.addEventListener('idmission.preloadProgress.faceDetection', handleDownloadProgress);
11950
- var cancelVideoReady = function cancelVideoReady() {};
11951
- loadFaceDetector().then(function (model) {
11952
- return __awaiter(_this, void 0, void 0, function () {
11953
- var _a, videoReady, cancel, cancelled;
11954
- return __generator(this, function (_b) {
11955
- switch (_b.label) {
11956
- case 0:
11957
- setModelDownloadProgress(100);
11958
- clearTimeout(modelLoadTimeout);
11959
- setModelLoadState('warming');
11960
- setModelWarmingStartedAt(performance.now());
11961
- return [4 /*yield*/, testFaceDetectionAgainstKnownImage(model)];
11962
- case 1:
11963
- _b.sent();
11964
- _a = waitForVideoReady(videoRef), videoReady = _a[0], cancel = _a[1];
11965
- cancelled = false;
11966
- cancelVideoReady = function cancelVideoReady() {
11967
- cancelled = true;
11968
- cancel();
11969
- };
11970
- return [4 /*yield*/, videoReady];
11971
- case 2:
11972
- _b.sent();
11973
- if (cancelled) return [2 /*return*/];
11974
- model.detectForVideo(videoRef.current, performance.now());
11975
- setModelLoadState('ready');
11976
- return [2 /*return*/];
11977
- }
11978
- });
11979
- });
11980
- })["catch"](function (e) {
11981
- setModelError(e);
11982
- setModelLoadState('error');
11983
- })["finally"](function () {
11984
- clearTimeout(modelLoadTimeout);
11985
- });
11986
- return function () {
11987
- log('unloading face detection model');
11988
- cancelVideoReady();
11989
- closeFaceDetector();
11990
- clearTimeout(modelLoadTimeout);
11991
- document.removeEventListener('idmission.preloadProgress.faceDetection', handleDownloadProgress);
11992
- };
11993
- }, [modelLoadTimeoutMs, videoRef]);
11994
- useEffect(function handleModelError() {
11995
- if (modelError) onModelError === null || onModelError === void 0 ? void 0 : onModelError(modelError);
11996
- }, [modelError, onModelError]);
11997
- return useMemo(function () {
11998
- return {
11999
- ready: modelLoadState === 'ready',
12000
- modelLoadState: modelLoadState,
12001
- modelDownloadProgress: modelDownloadProgress,
12002
- modelWarmingStartedAt: modelWarmingStartedAt,
12003
- modelError: modelError
12004
- };
12005
- }, [modelLoadState, modelDownloadProgress, modelWarmingStartedAt, modelError]);
12006
- }
12007
11878
  var lastFaceDetectionAt = 0;
12008
11879
  var lastFaceDetectionTime = 0;
12009
11880
  function setLastFaceDetectionAt(time) {
@@ -12053,24 +11924,68 @@ function trackFace(face, framesNeeded, frameWidth, frameHeight) {
12053
11924
  if (lastNNosePairs.length > framesNeeded - 1) lastNNosePairs.length = framesNeeded - 1;
12054
11925
  }
12055
11926
  }
12056
- function makeFaceDetectorPrediction(imageData) {
12057
- if (!detector) return null;
12058
- var prediction = detector.detectForVideo(imageData, performance.now());
12059
- var faces = prediction.detections.map(function (d) {
12060
- return {
12061
- box: convertBoundingBox(d.boundingBox),
12062
- keypoints: d.keypoints.map(function (k) {
12063
- var _a;
12064
- return _assign(_assign({}, k), {
12065
- x: k.x * imageData.width,
12066
- y: k.y * imageData.height,
12067
- name: (_a = k.label) !== null && _a !== void 0 ? _a : ''
12068
- });
12069
- })
12070
- };
11927
+ function isFaceDetection(detection) {
11928
+ return detection.boundingBox && detection.categories.some(function (c) {
11929
+ return c.categoryName === 'Primary face' || c.categoryName === 'Secondary face';
12071
11930
  });
12072
- return _assign(_assign({}, prediction), {
12073
- faces: faces
11931
+ }
11932
+ function isNoseDetection(detection) {
11933
+ return detection.categories.some(function (c) {
11934
+ return c.categoryName === 'Nose';
11935
+ });
11936
+ }
11937
+ function makeFacePredictionWithDocumentDetector(frame) {
11938
+ return __awaiter(this, void 0, void 0, function () {
11939
+ var prediction, faceDetections, noseDetections, _i, _a, detection, faces, _b, faceDetections_1, d, faceBox, nose, _c, noseDetections_1, n, noseBox, cX, cY;
11940
+ return __generator(this, function (_d) {
11941
+ switch (_d.label) {
11942
+ case 0:
11943
+ return [4 /*yield*/, makeDocumentDetectorPrediction(frame)];
11944
+ case 1:
11945
+ prediction = _d.sent();
11946
+ if (!prediction) return [2 /*return*/, null];
11947
+ faceDetections = [];
11948
+ noseDetections = [];
11949
+ for (_i = 0, _a = prediction.detections; _i < _a.length; _i++) {
11950
+ detection = _a[_i];
11951
+ if (isNoseDetection(detection)) {
11952
+ noseDetections.push(detection);
11953
+ } else if (isFaceDetection(detection)) {
11954
+ faceDetections.push(detection);
11955
+ }
11956
+ }
11957
+ faces = [];
11958
+ for (_b = 0, faceDetections_1 = faceDetections; _b < faceDetections_1.length; _b++) {
11959
+ d = faceDetections_1[_b];
11960
+ faceBox = d.boundingBox;
11961
+ if (!faceBox) continue;
11962
+ nose = null;
11963
+ for (_c = 0, noseDetections_1 = noseDetections; _c < noseDetections_1.length; _c++) {
11964
+ n = noseDetections_1[_c];
11965
+ noseBox = n.boundingBox;
11966
+ if (!noseBox) continue;
11967
+ cX = noseBox.originX + noseBox.width / 2;
11968
+ cY = noseBox.originY + noseBox.height / 2;
11969
+ if (cX >= faceBox.originX && cX <= faceBox.originX + faceBox.width && cY >= faceBox.originY && cY <= faceBox.originY + faceBox.height) {
11970
+ nose = {
11971
+ x: cX,
11972
+ y: cY,
11973
+ name: 'nose'
11974
+ };
11975
+ break;
11976
+ }
11977
+ }
11978
+ faces.push({
11979
+ box: convertBoundingBox(d.boundingBox),
11980
+ keypoints: [null, null, nose, null, null]
11981
+ });
11982
+ }
11983
+ debug('faces', faces);
11984
+ return [2 /*return*/, _assign(_assign({}, prediction), {
11985
+ faces: faces
11986
+ })];
11987
+ }
11988
+ });
12074
11989
  });
12075
11990
  }
12076
11991
  function processFaceDetectorPrediction(_a) {
@@ -12098,13 +12013,9 @@ function processFaceDetectorPrediction(_a) {
12098
12013
  // this represents the edge that the centroid of the face should not cross -- 12.5% of video width
12099
12014
  yCentroidBoundary = _h === void 0 ? 0.125 : _h,
12100
12015
  // this represents the edge that the centroid of the face should not cross -- 12.5% of video height
12101
- _j = _a.foreheadRatio,
12016
+ _j = _a.noseTrackingThreshold,
12102
12017
  // this represents the edge that the centroid of the face should not cross -- 12.5% of video height
12103
- foreheadRatio = _j === void 0 ? 0.275 : _j,
12104
- // 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.
12105
- _k = _a.noseTrackingThreshold,
12106
- // 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.
12107
- noseTrackingThreshold = _k === void 0 ? 0.2 : _k,
12018
+ noseTrackingThreshold = _j === void 0 ? 0.2 : _j,
12108
12019
  // 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
12109
12020
  minCaptureBrightnessThreshold = _a.minCaptureBrightnessThreshold,
12110
12021
  minCaptureRangeThreshold = _a.minCaptureRangeThreshold,
@@ -12131,10 +12042,10 @@ function processFaceDetectorPrediction(_a) {
12131
12042
  var frameCX = videoWidth / 2;
12132
12043
  var frameCY = videoHeight / 2;
12133
12044
  // calculate head bounding box, with forehead extension
12134
- var foreheadSize = face.box.height * foreheadRatio;
12045
+ // const foreheadSize = face.box.height * foreheadRatio
12135
12046
  var headXMin = face.box.xMin;
12136
12047
  var headXMax = face.box.xMax;
12137
- var headYMin = face.box.yMin - foreheadSize;
12048
+ var headYMin = face.box.yMin; // - foreheadSize
12138
12049
  var headYMax = face.box.yMax;
12139
12050
  // calculate head centroids
12140
12051
  var headCX = (headXMin + headXMax) / 2;
@@ -12190,26 +12101,6 @@ function processFaceDetectorPrediction(_a) {
12190
12101
  faceVisibilityTooLow: faceVisibilityTooLow
12191
12102
  };
12192
12103
  }
12193
- function testFaceDetectionAgainstKnownImage(detector) {
12194
- return new Promise(function (resolve, reject) {
12195
- var img = new Image();
12196
- img.crossOrigin = 'anonymous';
12197
- img.onload = function () {
12198
- var prediction = detector.detectForVideo(img, performance.now());
12199
- if (prediction.detections.length > 0) {
12200
- debug('face detection test result', prediction.detections);
12201
- resolve(void 0);
12202
- } else {
12203
- warn('face detection test failed');
12204
- reject(new Error('testFaceDetectionAgainstKnownImage failed to predict'));
12205
- }
12206
- };
12207
- img.onerror = function () {
12208
- return reject(new Error('testFaceDetectionAgainstKnownImage failed to load image'));
12209
- };
12210
- img.src = "".concat(DEFAULT_CDN_URL, "/head-test.jpg");
12211
- });
12212
- }
12213
12104
 
12214
12105
  function detectBrightnessAndContrast(frame, brightnessAverager) {
12215
12106
  var ctx = frame.getContext('2d');
@@ -12361,16 +12252,27 @@ function SelfieGuidanceModelsProvider(_a) {
12361
12252
  var canvasRef = useRef(null);
12362
12253
  var onPredictionHandler = useRef();
12363
12254
  var addToAverage = useRunningAvg(5).addToAverage;
12364
- var _f = useLoadFaceDetector({
12255
+ var _f = useLoadDocumentDetector({
12256
+ videoRef: videoRef,
12365
12257
  onModelError: onModelError,
12366
- modelLoadTimeoutMs: modelLoadTimeoutMs,
12367
- videoRef: videoRef
12258
+ modelLoadTimeoutMs: modelLoadTimeoutMs
12368
12259
  }),
12369
12260
  ready = _f.ready,
12370
12261
  modelLoadState = _f.modelLoadState,
12371
12262
  modelDownloadProgress = _f.modelDownloadProgress,
12372
12263
  modelWarmingStartedAt = _f.modelWarmingStartedAt,
12373
12264
  modelError = _f.modelError;
12265
+ // const {
12266
+ // ready,
12267
+ // modelLoadState,
12268
+ // modelDownloadProgress,
12269
+ // modelWarmingStartedAt,
12270
+ // modelError,
12271
+ // } = useLoadFaceDetector({
12272
+ // onModelError,
12273
+ // modelLoadTimeoutMs,
12274
+ // videoRef,
12275
+ // })
12374
12276
  var _g = useFrameLoop(useCallback(function () {
12375
12277
  return __awaiter(_this, void 0, void 0, function () {
12376
12278
  var vw, vh, ctx, thresholdsProvided, brightnessResults, brightness, range, variance, prediction, processed, e_1;
@@ -12384,19 +12286,21 @@ function SelfieGuidanceModelsProvider(_a) {
12384
12286
  ctx = canvasRef.current.getContext('2d');
12385
12287
  canvasRef.current.width = vw;
12386
12288
  canvasRef.current.height = vh;
12387
- if (!(ctx && videoRef.current.readyState === 4)) return [3 /*break*/, 4];
12289
+ if (!(ctx && videoRef.current.readyState === 4)) return [3 /*break*/, 5];
12388
12290
  ctx.translate(vw, 0);
12389
12291
  ctx.scale(-1, 1);
12390
12292
  ctx.drawImage(videoRef.current, 0, 0, vw, vh);
12391
12293
  _c.label = 1;
12392
12294
  case 1:
12393
- _c.trys.push([1, 3,, 4]);
12295
+ _c.trys.push([1, 4,, 5]);
12394
12296
  thresholdsProvided = minCaptureBrightnessThreshold !== undefined || minCaptureRangeThreshold !== undefined || minCaptureVarianceThreshold !== undefined;
12395
12297
  brightnessResults = thresholdsProvided ? detectBrightnessAndContrast(canvasRef.current, addToAverage) : undefined;
12396
12298
  brightness = brightnessResults === null || brightnessResults === void 0 ? void 0 : brightnessResults.brightness;
12397
12299
  range = brightnessResults === null || brightnessResults === void 0 ? void 0 : brightnessResults.range;
12398
12300
  variance = brightnessResults === null || brightnessResults === void 0 ? void 0 : brightnessResults.variance;
12399
- prediction = makeFaceDetectorPrediction(canvasRef.current);
12301
+ return [4 /*yield*/, makeFacePredictionWithDocumentDetector(canvasRef.current)];
12302
+ case 2:
12303
+ prediction = _c.sent();
12400
12304
  processed = processFaceDetectorPrediction({
12401
12305
  faces: (_a = prediction === null || prediction === void 0 ? void 0 : prediction.faces) !== null && _a !== void 0 ? _a : [],
12402
12306
  videoWidth: vw,
@@ -12412,15 +12316,15 @@ function SelfieGuidanceModelsProvider(_a) {
12412
12316
  setLastFaceDetectionAt(new Date().getTime());
12413
12317
  // setLastPrediction(processed)
12414
12318
  return [4 /*yield*/, (_b = onPredictionHandler.current) === null || _b === void 0 ? void 0 : _b.call(onPredictionHandler, processed)];
12415
- case 2:
12319
+ case 3:
12416
12320
  // setLastPrediction(processed)
12417
12321
  _c.sent();
12418
- return [3 /*break*/, 4];
12419
- case 3:
12322
+ return [3 /*break*/, 5];
12323
+ case 4:
12420
12324
  e_1 = _c.sent();
12421
12325
  error('caught face detection error', e_1);
12422
- return [3 /*break*/, 4];
12423
- case 4:
12326
+ return [3 /*break*/, 5];
12327
+ case 5:
12424
12328
  return [2 /*return*/];
12425
12329
  }
12426
12330
  });
@@ -14957,7 +14861,8 @@ function VideoSignatureCaptureComponent(_a, ref) {
14957
14861
  var rightEdge = videoWidth * (1 - headTrackingBoundaryPercentage);
14958
14862
  var topEdge = videoHeight * headTrackingBoundaryPercentage;
14959
14863
  var bottomEdge = videoHeight * (1 - headTrackingBoundaryPercentage);
14960
- var nearBoundary = !!face && (headTrackingBoundaryType === 'nose' ? face.keypoints[2].x < leftEdge || face.keypoints[2].x > rightEdge || face.keypoints[2].y < topEdge || face.keypoints[2].y > bottomEdge : (face === null || face === void 0 ? void 0 : face.box.xMin) < leftEdge || (face === null || face === void 0 ? void 0 : face.box.xMax) > rightEdge || (face === null || face === void 0 ? void 0 : face.box.yMin) < topEdge || (face === null || face === void 0 ? void 0 : face.box.yMax) > bottomEdge);
14864
+ var nose = face === null || face === void 0 ? void 0 : face.keypoints[2];
14865
+ var nearBoundary = !!face && !!nose && (headTrackingBoundaryType === 'nose' ? nose.x < leftEdge || nose.x > rightEdge || nose.y < topEdge || nose.y > bottomEdge : (face === null || face === void 0 ? void 0 : face.box.xMin) < leftEdge || (face === null || face === void 0 ? void 0 : face.box.xMax) > rightEdge || (face === null || face === void 0 ? void 0 : face.box.yMin) < topEdge || (face === null || face === void 0 ? void 0 : face.box.yMax) > bottomEdge);
14961
14866
  setLastFace(face);
14962
14867
  setHeadTrackingSatisfied(!!face && !nearBoundary);
14963
14868
  setNumFramesWithoutFaces(face ? 0 : function (n) {
@@ -15438,6 +15343,7 @@ function VideoSignatureWizardComponent(_a, ref) {
15438
15343
  return n + 1;
15439
15344
  });
15440
15345
  setCaptureState(skipLivenessValidation ? 'CAPTURING_SELFIE' : 'CHECKING_LIVENESS');
15346
+ useVideoSignatureStore.getState().clearRecordedData();
15441
15347
  }, [onRetryClicked, skipLivenessValidation]);
15442
15348
  var onExitSignatureCapture = useCallback(function () {
15443
15349
  setAttempt(function (n) {
@@ -15905,6 +15811,16 @@ var useVideoRecorderStore = create()(devtools(function (set, get) {
15905
15811
  clearRecordedData: function clearRecordedData() {
15906
15812
  clearVideoChunks();
15907
15813
  clearAudioChunks();
15814
+ set({
15815
+ videoUrl: null,
15816
+ audioUrl: null,
15817
+ isRecordingVideo: false,
15818
+ isRecordingAudio: false,
15819
+ videoRecordingStopped: false,
15820
+ audioRecordingStopped: false,
15821
+ videoRecordingIntentionallyStopped: false,
15822
+ audioRecordingIntentionallyStopped: false
15823
+ });
15908
15824
  }
15909
15825
  });
15910
15826
  }));
@@ -16187,10 +16103,10 @@ var IdVideoCapture = function IdVideoCapture(_a) {
16187
16103
  var _14 = useState(null),
16188
16104
  videoStartsAt = _14[0],
16189
16105
  setVideoStartsAt = _14[1];
16190
- var _15 = useContext(SubmissionContext),
16106
+ var _15 = useSubmissionContext(),
16191
16107
  setIdCaptureVideoAudioStartsAt = _15.setIdCaptureVideoAudioStartsAt,
16192
16108
  setExpectedAudioText = _15.setExpectedAudioText;
16193
- var _16 = useContext(SelfieGuidanceModelsContext),
16109
+ var _16 = useSelfieGuidanceModelsContext(),
16194
16110
  startSelfieGuidance = _16.start,
16195
16111
  stopSelfieGuidance = _16.stop,
16196
16112
  onSelfiePredictionMade = _16.onPredictionMade,
@@ -16787,6 +16703,7 @@ var VideoIdWizard = function VideoIdWizard(_a) {
16787
16703
  return n + 1;
16788
16704
  });
16789
16705
  setCaptureState('CAPTURING_ID');
16706
+ useVideoRecorderStore.getState().clearRecordedData();
16790
16707
  }, []);
16791
16708
  var isCapturingId = !skipIdCapture && ['LOADING', 'CAPTURING_ID'].includes(captureState);
16792
16709
  useEffect(function () {
@@ -16821,6 +16738,7 @@ var VideoIdWizard = function VideoIdWizard(_a) {
16821
16738
  });
16822
16739
  }, [capturedIdDocumentType, (_b = classNames.idVideoCapture) === null || _b === void 0 ? void 0 : _b.guides, (_c = colors.idVideoCapture) === null || _c === void 0 ? void 0 : _c.guidesSatisfiedColor, (_d = colors.idVideoCapture) === null || _d === void 0 ? void 0 : _d.guidesUnsatisfiedColor, idCaptureGuideImages, (_e = verbiage.idVideoCapture) === null || _e === void 0 ? void 0 : _e.guides]);
16823
16740
  return /*#__PURE__*/React__default.createElement(CameraStoreProvider, {
16741
+ key: "camera-store-".concat(attempt),
16824
16742
  preferIphoneContinuityCamera: isCapturingId,
16825
16743
  preferFrontFacingCamera: !isCapturingId,
16826
16744
  requireMicrophoneAccess: !isCapturingId && !!readTextPrompt,
@@ -16832,6 +16750,7 @@ var VideoIdWizard = function VideoIdWizard(_a) {
16832
16750
  classNames: classNames === null || classNames === void 0 ? void 0 : classNames.cameraStoreProvider,
16833
16751
  verbiage: verbiage === null || verbiage === void 0 ? void 0 : verbiage.cameraStoreProvider
16834
16752
  }, /*#__PURE__*/React__default.createElement(IdCaptureModelsProvider, {
16753
+ key: "id-capture-models-".concat(attempt),
16835
16754
  autoStart: false,
16836
16755
  documentDetectionModelUrl: (_g = (_f = idCaptureProps.assets) === null || _f === void 0 ? void 0 : _f.documentDetectionModelUrl) !== null && _g !== void 0 ? _g : '',
16837
16756
  focusModelUrl: (_j = (_h = idCaptureProps.assets) === null || _h === void 0 ? void 0 : _h.focusModelUrl) !== null && _j !== void 0 ? _j : '',
@@ -16839,6 +16758,7 @@ var VideoIdWizard = function VideoIdWizard(_a) {
16839
16758
  modelLoadTimeoutMs: idCaptureModelLoadTimeoutMs,
16840
16759
  allowSinglePageIdCapture: idCaptureProps.allowSinglePageIdCapture
16841
16760
  }, /*#__PURE__*/React__default.createElement(SelfieGuidanceModelsProvider, {
16761
+ key: "selfie-guidance-models-".concat(attempt),
16842
16762
  autoStart: false,
16843
16763
  onModelError: faceLivenessProps === null || faceLivenessProps === void 0 ? void 0 : faceLivenessProps.onModelError,
16844
16764
  modelLoadTimeoutMs: faceLivenessProps === null || faceLivenessProps === void 0 ? void 0 : faceLivenessProps.modelLoadTimeoutMs,
@@ -16848,7 +16768,9 @@ var VideoIdWizard = function VideoIdWizard(_a) {
16848
16768
  })), function () {
16849
16769
  switch (captureState) {
16850
16770
  case 'CAPTURING_ID':
16851
- return /*#__PURE__*/React__default.createElement(IdCaptureStateProvider, null, /*#__PURE__*/React__default.createElement(GuideOrientationContextProvider, null, /*#__PURE__*/React__default.createElement(IdCaptureWizard, _assign({
16771
+ return /*#__PURE__*/React__default.createElement(IdCaptureStateProvider, {
16772
+ key: "id-capture-state-".concat(attempt)
16773
+ }, /*#__PURE__*/React__default.createElement(GuideOrientationContextProvider, null, /*#__PURE__*/React__default.createElement(IdCaptureWizard, _assign({
16852
16774
  key: "id-capture-".concat(attempt),
16853
16775
  loadingOverlayMode: idCaptureLoadingOverlayMode,
16854
16776
  customOverlayContent: customOverlayContent,