idmission-web-sdk 2.3.171-feature-barcode-recapture-d495693 → 2.3.171-feature-barcode-recapture-658bede

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
@@ -495,7 +495,7 @@ var OverlayInner$2 = styled.div(templateObject_2$K || (templateObject_2$K = __ma
495
495
  });
496
496
  var OverlayImageContainer = styled.div(templateObject_3$w || (templateObject_3$w = __makeTemplateObject(["\n position: relative;\n display: flex;\n flex-grow: 1;\n padding-bottom: 25px;\n overflow: hidden;\n\n & > img,\n & > svg {\n margin: 0 auto;\n width: max-content;\n max-width: 100%;\n max-height: 100%;\n aspect-ratio: initial;\n object-fit: contain;\n display: block;\n }\n"], ["\n position: relative;\n display: flex;\n flex-grow: 1;\n padding-bottom: 25px;\n overflow: hidden;\n\n & > img,\n & > svg {\n margin: 0 auto;\n width: max-content;\n max-width: 100%;\n max-height: 100%;\n aspect-ratio: initial;\n object-fit: contain;\n display: block;\n }\n"])));
497
497
  var OverlayImageRow = styled.div(templateObject_4$q || (templateObject_4$q = __makeTemplateObject(["\n display: flex;\n margin: auto;\n\n & > div {\n max-height: calc(100% - 320px);\n\n & > img {\n width: 100%;\n max-height: 100%;\n height: auto;\n object-fit: contain;\n }\n }\n"], ["\n display: flex;\n margin: auto;\n\n & > div {\n max-height: calc(100% - 320px);\n\n & > img {\n width: 100%;\n max-height: 100%;\n height: auto;\n object-fit: contain;\n }\n }\n"])));
498
- var GrayOverlayContainer = styled(OverlayContainer)(templateObject_5$i || (templateObject_5$i = __makeTemplateObject(["\n background: #f7f6fb;\n"], ["\n background: #f7f6fb;\n"])));
498
+ var GrayOverlayContainer = styled(OverlayContainer)(templateObject_5$j || (templateObject_5$j = __makeTemplateObject(["\n background: #f7f6fb;\n"], ["\n background: #f7f6fb;\n"])));
499
499
  var ButtonsColumn = styled.div(templateObject_6$b || (templateObject_6$b = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n gap: 15px 0;\n justify-content: center;\n margin-top: 24px;\n"], ["\n display: flex;\n flex-direction: column;\n gap: 15px 0;\n justify-content: center;\n margin-top: 24px;\n"])));
500
500
  var WideButton = styled(LoaderButton)(templateObject_7$7 || (templateObject_7$7 = __makeTemplateObject(["\n width: 100%;\n border-radius: 30px;\n"], ["\n width: 100%;\n border-radius: 30px;\n"])));
501
501
  var WideBorderButton = styled(WideButton)(templateObject_8$6 || (templateObject_8$6 = __makeTemplateObject(["\n color: ", ";\n background: ", ";\n border: 1px solid\n ", ";\n box-sizing: border-box;\n"], ["\n color: ", ";\n background: ", ";\n border: 1px solid\n ", ";\n box-sizing: border-box;\n"])), function (props) {
@@ -535,7 +535,7 @@ var LoadingOverlayLoadingListItem = styled.li(templateObject_19$2 || (templateOb
535
535
  var LoadingOverlayProgressContainer = styled.div(templateObject_20$2 || (templateObject_20$2 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n"], ["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n"])));
536
536
  var LoadingOverlayCustomLoadingGraphic = styled.img(templateObject_21$2 || (templateObject_21$2 = __makeTemplateObject(["\n transform-style: preserve-3d;\n"], ["\n transform-style: preserve-3d;\n"])));
537
537
  var LoadingOverlayContinueButtonContainer = styled.div(templateObject_22$2 || (templateObject_22$2 = __makeTemplateObject(["\n display: flex;\n"], ["\n display: flex;\n"])));
538
- var templateObject_1$P, templateObject_2$K, templateObject_3$w, templateObject_4$q, templateObject_5$i, templateObject_6$b, templateObject_7$7, templateObject_8$6, templateObject_9$4, templateObject_10$3, templateObject_11$3, templateObject_12$3, templateObject_13$3, templateObject_14$2, templateObject_15$2, templateObject_16$2, templateObject_17$2, templateObject_18$2, templateObject_19$2, templateObject_20$2, templateObject_21$2, templateObject_22$2;
538
+ var templateObject_1$P, templateObject_2$K, templateObject_3$w, templateObject_4$q, templateObject_5$j, templateObject_6$b, templateObject_7$7, templateObject_8$6, templateObject_9$4, templateObject_10$3, templateObject_11$3, templateObject_12$3, templateObject_13$3, templateObject_14$2, templateObject_15$2, templateObject_16$2, templateObject_17$2, templateObject_18$2, templateObject_19$2, templateObject_20$2, templateObject_21$2, templateObject_22$2;
539
539
 
540
540
  var GeolocationAccessDeniedOverlay = function GeolocationAccessDeniedOverlay(_a) {
541
541
  var accessBlockedImageUrl = _a.accessBlockedImageUrl;
@@ -5930,9 +5930,9 @@ var onMobile = isMobile();
5930
5930
  function analyzeBarcodeReadability(prediction, lastPredictionCanvas, croppedDocumentCanvas, bestBarcodeCanvas, currentBestBarcodeScore, documentDetectionThresholds, makeBarcodeReadabilityPrediction, barcodeReadabilityThreshold) {
5931
5931
  return __awaiter(this, void 0, void 0, function () {
5932
5932
  var pdf417PredictionTime, pdf417PredictionScore, pdf417PredictionThresholdMet, newBestBarcodeScore, newBestBarcodeDetails, documentCroppedPrediction, processedCroppedPrediction, pdf417Prediction;
5933
- var _a;
5934
- return __generator(this, function (_b) {
5935
- switch (_b.label) {
5933
+ var _a, _b;
5934
+ return __generator(this, function (_c) {
5935
+ switch (_c.label) {
5936
5936
  case 0:
5937
5937
  pdf417PredictionTime = 0;
5938
5938
  pdf417PredictionScore = 0;
@@ -5943,7 +5943,8 @@ function analyzeBarcodeReadability(prediction, lastPredictionCanvas, croppedDocu
5943
5943
  pdf417PredictionScore: pdf417PredictionScore,
5944
5944
  pdf417PredictionThresholdMet: pdf417PredictionThresholdMet,
5945
5945
  newBestBarcodeScore: newBestBarcodeScore,
5946
- newBestBarcodeDetails: newBestBarcodeDetails
5946
+ newBestBarcodeDetails: newBestBarcodeDetails,
5947
+ processedBarcodeBoundingBox: undefined
5947
5948
  }];
5948
5949
  }
5949
5950
  /**
@@ -5953,7 +5954,7 @@ function analyzeBarcodeReadability(prediction, lastPredictionCanvas, croppedDocu
5953
5954
  cropToDetectedObjectBox(lastPredictionCanvas, prediction.bestDocument.box, croppedDocumentCanvas);
5954
5955
  return [4 /*yield*/, makeDocumentDetectorPrediction(croppedDocumentCanvas)];
5955
5956
  case 1:
5956
- documentCroppedPrediction = _b.sent();
5957
+ documentCroppedPrediction = _c.sent();
5957
5958
  if (!documentCroppedPrediction) {
5958
5959
  // error occurred during prediction (error logged by callee)
5959
5960
  return [2 /*return*/, {
@@ -5961,7 +5962,8 @@ function analyzeBarcodeReadability(prediction, lastPredictionCanvas, croppedDocu
5961
5962
  pdf417PredictionScore: pdf417PredictionScore,
5962
5963
  pdf417PredictionThresholdMet: pdf417PredictionThresholdMet,
5963
5964
  newBestBarcodeScore: newBestBarcodeScore,
5964
- newBestBarcodeDetails: newBestBarcodeDetails
5965
+ newBestBarcodeDetails: newBestBarcodeDetails,
5966
+ processedBarcodeBoundingBox: undefined
5965
5967
  }];
5966
5968
  }
5967
5969
  processedCroppedPrediction = processDocumentDetectorPrediction(documentCroppedPrediction, documentDetectionThresholds);
@@ -5991,7 +5993,9 @@ function analyzeBarcodeReadability(prediction, lastPredictionCanvas, croppedDocu
5991
5993
  pdf417PredictionScore: pdf417PredictionScore,
5992
5994
  pdf417PredictionThresholdMet: pdf417PredictionThresholdMet,
5993
5995
  newBestBarcodeScore: newBestBarcodeScore,
5994
- newBestBarcodeDetails: newBestBarcodeDetails
5996
+ newBestBarcodeDetails: newBestBarcodeDetails,
5997
+ // Return processed barcode bounding box for recapture tracking (valid even when not a new best)
5998
+ processedBarcodeBoundingBox: (_b = processedCroppedPrediction === null || processedCroppedPrediction === void 0 ? void 0 : processedCroppedPrediction.bestPDF417) === null || _b === void 0 ? void 0 : _b.box
5995
5999
  }];
5996
6000
  }
5997
6001
  });
@@ -6082,6 +6086,9 @@ var IdCaptureModelsContext = /*#__PURE__*/createContext({
6082
6086
  getBestBarcode: function getBestBarcode() {
6083
6087
  return null;
6084
6088
  },
6089
+ resetBestBarcode: function resetBestBarcode() {
6090
+ return null;
6091
+ },
6085
6092
  startBarcodeRecapturePhase: function startBarcodeRecapturePhase() {
6086
6093
  return null;
6087
6094
  },
@@ -6182,10 +6189,10 @@ function IdCaptureModelsProviderInner(_a) {
6182
6189
  var _this = this;
6183
6190
  onDocumentDetected(function (prediction) {
6184
6191
  return __awaiter(_this, void 0, void 0, function () {
6185
- var stopDetectionAtStart, focusPredictionTime, focusScore, focusThresholdMet, pdf417PredictionTime, pdf417PredictionScore, pdf417PredictionThresholdMet, isSinglePage, isRequiredDocumentType, isInRecapturePhase, shouldRunBarcodeAnalysisDuringRecapture, focusPrediction, focusThresholdSet, focusThreshold, barcodeAnalysisResult, ctx, barcodeAnalysisResult, ctx;
6186
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
6187
- return __generator(this, function (_k) {
6188
- switch (_k.label) {
6192
+ var stopDetectionAtStart, focusPredictionTime, focusScore, focusThresholdMet, pdf417PredictionTime, pdf417PredictionScore, pdf417PredictionThresholdMet, isSinglePage, isRequiredDocumentType, isInRecapturePhase, shouldRunBarcodeAnalysisDuringRecapture, focusPrediction, focusThresholdSet, focusThreshold, barcodeAnalysisResult, barcodeAnalysisResult;
6193
+ var _a, _b, _c, _d, _e, _f, _g;
6194
+ return __generator(this, function (_h) {
6195
+ switch (_h.label) {
6189
6196
  case 0:
6190
6197
  if (!lastPredictionCanvas.current) return [2 /*return*/];
6191
6198
  stopDetectionAtStart = stopDetection.current;
@@ -6200,7 +6207,7 @@ function IdCaptureModelsProviderInner(_a) {
6200
6207
  }
6201
6208
  isRequiredDocumentType = requiredDocumentType === 'none' || prediction.detectedDocumentType === requiredDocumentType || ((_a = requiredDocumentType.includes) === null || _a === void 0 ? void 0 : _a.call(requiredDocumentType, prediction.detectedDocumentType)) || allowSinglePageIdCapture && isSinglePage && ((_b = requiredDocumentType.includes) === null || _b === void 0 ? void 0 : _b.call(requiredDocumentType, 'idCardFront'));
6202
6209
  isInRecapturePhase = isRecapturePhase.current;
6203
- shouldRunBarcodeAnalysisDuringRecapture = isInRecapturePhase && isRequiredDocumentType && prediction.detectedDocumentType !== 'none' && prediction.detectionThresholdMet && prediction.documentIsStable && prediction.bestDocument && prediction.bestPDF417;
6210
+ shouldRunBarcodeAnalysisDuringRecapture = isInRecapturePhase && isRequiredDocumentType && prediction.detectedDocumentType !== 'none' && prediction.detectionThresholdMet && prediction.bestDocument && prediction.bestPDF417;
6204
6211
  if (!(isRequiredDocumentType && prediction.detectedDocumentType !== 'none' && prediction.detectionThresholdMet && prediction.documentInBounds && !prediction.documentTooClose && prediction.documentIsStable)) return [3 /*break*/, 3];
6205
6212
  focusPrediction = makeFocusPrediction(lastPredictionCanvas.current, (_c = prediction.bestDocument) === null || _c === void 0 ? void 0 : _c.box);
6206
6213
  if (focusPrediction) {
@@ -6224,7 +6231,7 @@ function IdCaptureModelsProviderInner(_a) {
6224
6231
  if (!(enableBarcodeReadabilityModel && prediction.bestDocument && prediction.bestPDF417 && croppedDocumentCanvas.current)) return [3 /*break*/, 2];
6225
6232
  return [4 /*yield*/, analyzeBarcodeReadability(prediction, lastPredictionCanvas.current, croppedDocumentCanvas.current, bestBarcodeCanvas.current, bestBarcodeScore.current)];
6226
6233
  case 1:
6227
- barcodeAnalysisResult = _k.sent();
6234
+ barcodeAnalysisResult = _h.sent();
6228
6235
  pdf417PredictionTime = barcodeAnalysisResult.pdf417PredictionTime;
6229
6236
  pdf417PredictionScore = barcodeAnalysisResult.pdf417PredictionScore;
6230
6237
  pdf417PredictionThresholdMet = barcodeAnalysisResult.pdf417PredictionThresholdMet;
@@ -6236,19 +6243,23 @@ function IdCaptureModelsProviderInner(_a) {
6236
6243
  }
6237
6244
  // During recapture phase, also track best barcode separately for recapture sequence
6238
6245
  if (isRecapturePhase.current && recaptureBarcodeCanvas.current && pdf417PredictionScore > recaptureBarcodeScore.current) {
6246
+ log("[IdCaptureModelsProvider] Recapture tracking: new best score ".concat(pdf417PredictionScore, " (was ").concat(recaptureBarcodeScore.current, ")"));
6239
6247
  recaptureBarcodeScore.current = pdf417PredictionScore;
6240
- recaptureBarcodeDetails.current = (_g = barcodeAnalysisResult.newBestBarcodeDetails) !== null && _g !== void 0 ? _g : null;
6241
- // Copy the current best barcode canvas to recapture canvas
6242
- if (bestBarcodeCanvas.current) {
6243
- ctx = recaptureBarcodeCanvas.current.getContext('2d');
6244
- if (ctx) {
6245
- recaptureBarcodeCanvas.current.width = bestBarcodeCanvas.current.width;
6246
- recaptureBarcodeCanvas.current.height = bestBarcodeCanvas.current.height;
6247
- ctx.drawImage(bestBarcodeCanvas.current, 0, 0);
6248
- }
6248
+ // Create details directly from current prediction (not newBestBarcodeDetails which
6249
+ // is only set when score beats overall best, not just recapture best)
6250
+ recaptureBarcodeDetails.current = {
6251
+ boundingBox: prediction.bestPDF417.box,
6252
+ score: pdf417PredictionScore
6253
+ };
6254
+ // Crop barcode from croppedDocumentCanvas using the processed bounding box
6255
+ // (can't use bestBarcodeCanvas since it's only updated for overall best)
6256
+ if (croppedDocumentCanvas.current && barcodeAnalysisResult.processedBarcodeBoundingBox) {
6257
+ cropToDetectedObjectBox(croppedDocumentCanvas.current, barcodeAnalysisResult.processedBarcodeBoundingBox, recaptureBarcodeCanvas.current, 16);
6258
+ } else {
6259
+ log("[IdCaptureModelsProvider] Recapture tracking: could not crop barcode - croppedDocumentCanvas=".concat(!!croppedDocumentCanvas.current, ", processedBarcodeBoundingBox=").concat(!!barcodeAnalysisResult.processedBarcodeBoundingBox));
6249
6260
  }
6250
6261
  }
6251
- _k.label = 2;
6262
+ _h.label = 2;
6252
6263
  case 2:
6253
6264
  return [3 /*break*/, 5];
6254
6265
  case 3:
@@ -6256,7 +6267,7 @@ function IdCaptureModelsProviderInner(_a) {
6256
6267
  if (!(enableBarcodeReadabilityModel && croppedDocumentCanvas.current && stopDetectionAtStart === stopDetection.current)) return [3 /*break*/, 5];
6257
6268
  return [4 /*yield*/, analyzeBarcodeReadability(prediction, lastPredictionCanvas.current, croppedDocumentCanvas.current, bestBarcodeCanvas.current, bestBarcodeScore.current)];
6258
6269
  case 4:
6259
- barcodeAnalysisResult = _k.sent();
6270
+ barcodeAnalysisResult = _h.sent();
6260
6271
  pdf417PredictionTime = barcodeAnalysisResult.pdf417PredictionTime;
6261
6272
  pdf417PredictionScore = barcodeAnalysisResult.pdf417PredictionScore;
6262
6273
  pdf417PredictionThresholdMet = barcodeAnalysisResult.pdf417PredictionThresholdMet;
@@ -6268,19 +6279,23 @@ function IdCaptureModelsProviderInner(_a) {
6268
6279
  }
6269
6280
  // Track best barcode separately for recapture sequence
6270
6281
  if (recaptureBarcodeCanvas.current && pdf417PredictionScore > recaptureBarcodeScore.current) {
6282
+ log("[IdCaptureModelsProvider] Recapture tracking (relaxed): new best score ".concat(pdf417PredictionScore, " (was ").concat(recaptureBarcodeScore.current, ")"));
6271
6283
  recaptureBarcodeScore.current = pdf417PredictionScore;
6272
- recaptureBarcodeDetails.current = (_h = barcodeAnalysisResult.newBestBarcodeDetails) !== null && _h !== void 0 ? _h : null;
6273
- // Copy the current best barcode canvas to recapture canvas
6274
- if (bestBarcodeCanvas.current) {
6275
- ctx = recaptureBarcodeCanvas.current.getContext('2d');
6276
- if (ctx) {
6277
- recaptureBarcodeCanvas.current.width = bestBarcodeCanvas.current.width;
6278
- recaptureBarcodeCanvas.current.height = bestBarcodeCanvas.current.height;
6279
- ctx.drawImage(bestBarcodeCanvas.current, 0, 0);
6280
- }
6284
+ // Create details directly from current prediction (not newBestBarcodeDetails which
6285
+ // is only set when score beats overall best, not just recapture best)
6286
+ recaptureBarcodeDetails.current = {
6287
+ boundingBox: prediction.bestPDF417.box,
6288
+ score: pdf417PredictionScore
6289
+ };
6290
+ // Crop barcode from croppedDocumentCanvas using the processed bounding box
6291
+ // (can't use bestBarcodeCanvas since it's only updated for overall best)
6292
+ if (croppedDocumentCanvas.current && barcodeAnalysisResult.processedBarcodeBoundingBox) {
6293
+ cropToDetectedObjectBox(croppedDocumentCanvas.current, barcodeAnalysisResult.processedBarcodeBoundingBox, recaptureBarcodeCanvas.current, 16);
6294
+ } else {
6295
+ log("[IdCaptureModelsProvider] Recapture tracking (relaxed): could not crop barcode - croppedDocumentCanvas=".concat(!!croppedDocumentCanvas.current, ", processedBarcodeBoundingBox=").concat(!!barcodeAnalysisResult.processedBarcodeBoundingBox));
6281
6296
  }
6282
6297
  }
6283
- _k.label = 5;
6298
+ _h.label = 5;
6284
6299
  case 5:
6285
6300
  /**
6286
6301
  * @note
@@ -6288,7 +6303,7 @@ function IdCaptureModelsProviderInner(_a) {
6288
6303
  * Do not return early from this function unless
6289
6304
  * lastPredictionCanvas.current is not set
6290
6305
  */
6291
- (_j = onPredictionHandler.current) === null || _j === void 0 ? void 0 : _j.call(onPredictionHandler, _assign(_assign({}, prediction), {
6306
+ (_g = onPredictionHandler.current) === null || _g === void 0 ? void 0 : _g.call(onPredictionHandler, _assign(_assign({}, prediction), {
6292
6307
  focusScore: focusScore,
6293
6308
  focusPredictionTime: focusPredictionTime,
6294
6309
  focusThresholdMet: focusThresholdMet,
@@ -6321,7 +6336,29 @@ function IdCaptureModelsProviderInner(_a) {
6321
6336
  canvas: bestBarcodeCanvas.current
6322
6337
  });
6323
6338
  }, []);
6339
+ var resetBestBarcode = useCallback(function () {
6340
+ // Light-weight reset that only clears barcode tracking without disrupting detection
6341
+ bestBarcodeScore.current = 0;
6342
+ bestBarcodeDetails.current = null;
6343
+ // Also reset recapture tracking so early frames during move-closer window are ignored
6344
+ recaptureBarcodeScore.current = 0;
6345
+ recaptureBarcodeDetails.current = null;
6346
+ // Clear the canvas content but don't recreate it
6347
+ if (bestBarcodeCanvas.current) {
6348
+ var ctx = bestBarcodeCanvas.current.getContext('2d');
6349
+ if (ctx) {
6350
+ ctx.clearRect(0, 0, bestBarcodeCanvas.current.width, bestBarcodeCanvas.current.height);
6351
+ }
6352
+ }
6353
+ if (recaptureBarcodeCanvas.current) {
6354
+ var ctx = recaptureBarcodeCanvas.current.getContext('2d');
6355
+ if (ctx) {
6356
+ ctx.clearRect(0, 0, recaptureBarcodeCanvas.current.width, recaptureBarcodeCanvas.current.height);
6357
+ }
6358
+ }
6359
+ }, []);
6324
6360
  var startBarcodeRecapturePhase = useCallback(function () {
6361
+ log("[IdCaptureModelsProvider] Starting barcode recapture phase. Initial best score: ".concat(bestBarcodeScore.current));
6325
6362
  // Snapshot current best barcode to initial capture canvas
6326
6363
  if (bestBarcodeCanvas.current && initialCaptureBarcodeCanvas.current) {
6327
6364
  var ctx = initialCaptureBarcodeCanvas.current.getContext('2d');
@@ -6438,13 +6475,14 @@ function IdCaptureModelsProviderInner(_a) {
6438
6475
  bestFrameDetails: bestFrameDetails,
6439
6476
  bestBarcodeDetails: bestBarcodeDetails,
6440
6477
  getBestBarcode: getBestBarcode,
6478
+ resetBestBarcode: resetBestBarcode,
6441
6479
  startBarcodeRecapturePhase: startBarcodeRecapturePhase,
6442
6480
  getInitialCaptureBestBarcode: getInitialCaptureBestBarcode,
6443
6481
  getRecaptureBestBarcode: getRecaptureBestBarcode,
6444
6482
  requiredDocumentType: requiredDocumentType,
6445
6483
  setRequiredDocumentType: setRequiredDocumentType
6446
6484
  };
6447
- }, [ready, modelDownloadProgress, modelLoadState, modelWarmingStartedAt, modelError, startDocumentDetection, stopDocumentDetection, load, thresholds, setThresholds, documentDetectionBoundaries, setDocumentDetectionBoundaries, onPredictionMade, detectionTime, focusPredictionTime, barcodeReadabilityPredictionTime, getBestFrame, resetBestFrame, getBestBarcode, startBarcodeRecapturePhase, getInitialCaptureBestBarcode, getRecaptureBestBarcode, requiredDocumentType]);
6485
+ }, [ready, modelDownloadProgress, modelLoadState, modelWarmingStartedAt, modelError, startDocumentDetection, stopDocumentDetection, load, thresholds, setThresholds, documentDetectionBoundaries, setDocumentDetectionBoundaries, onPredictionMade, detectionTime, focusPredictionTime, barcodeReadabilityPredictionTime, getBestFrame, resetBestFrame, getBestBarcode, resetBestBarcode, startBarcodeRecapturePhase, getInitialCaptureBestBarcode, getRecaptureBestBarcode, requiredDocumentType]);
6448
6486
  return /*#__PURE__*/React__default.createElement(IdCaptureModelsContext.Provider, {
6449
6487
  value: value
6450
6488
  }, /*#__PURE__*/React__default.createElement(InvisibleCanvasContainer, null, /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
@@ -7029,7 +7067,11 @@ var ObjectDetectionDebugBox = styled.div(templateObject_3$v || (templateObject_3
7029
7067
  var $flipX = _a.$flipX;
7030
7068
  return $flipX ? 'transform: scaleX(-1);' : '';
7031
7069
  });
7032
- var FaceDetectionKeypointMarker = styled.div(templateObject_4$p || (templateObject_4$p = __makeTemplateObject(["\n position: absolute;\n width: 4px;\n height: 4px;\n border: 2px solid ", ";\n font: 10px monospace;\n color: ", ";\n border-radius: 50%;\n ", "\n transform-style: preserve-3d;\n"], ["\n position: absolute;\n width: 4px;\n height: 4px;\n border: 2px solid ", ";\n font: 10px monospace;\n color: ", ";\n border-radius: 50%;\n ", "\n transform-style: preserve-3d;\n"])), function (_a) {
7070
+ var ObjectDetectionDebugLabel = styled.span(templateObject_4$p || (templateObject_4$p = __makeTemplateObject(["\n position: absolute;\n top: -1px;\n left: -1px;\n background: ", ";\n color: black;\n font: bold 9px monospace;\n padding: 1px 3px;\n white-space: nowrap;\n transform: translateY(-100%);\n"], ["\n position: absolute;\n top: -1px;\n left: -1px;\n background: ", ";\n color: black;\n font: bold 9px monospace;\n padding: 1px 3px;\n white-space: nowrap;\n transform: translateY(-100%);\n"])), function (_a) {
7071
+ var $color = _a.$color;
7072
+ return $color !== null && $color !== void 0 ? $color : 'green';
7073
+ });
7074
+ var FaceDetectionKeypointMarker = styled.div(templateObject_5$i || (templateObject_5$i = __makeTemplateObject(["\n position: absolute;\n width: 4px;\n height: 4px;\n border: 2px solid ", ";\n font: 10px monospace;\n color: ", ";\n border-radius: 50%;\n ", "\n transform-style: preserve-3d;\n"], ["\n position: absolute;\n width: 4px;\n height: 4px;\n border: 2px solid ", ";\n font: 10px monospace;\n color: ", ";\n border-radius: 50%;\n ", "\n transform-style: preserve-3d;\n"])), function (_a) {
7033
7075
  var $color = _a.$color;
7034
7076
  return $color !== null && $color !== void 0 ? $color : 'red';
7035
7077
  }, function (_a) {
@@ -7141,7 +7183,9 @@ function IdCaptureDetectedObjectDebugBox(_a) {
7141
7183
  width: width,
7142
7184
  height: height
7143
7185
  }
7144
- });
7186
+ }, /*#__PURE__*/React__default.createElement(ObjectDetectionDebugLabel, {
7187
+ "$color": color
7188
+ }, obj.label, " ", obj.score.toFixed(2)));
7145
7189
  }
7146
7190
  function SelfieCaptureFaceDebugBox(_a) {
7147
7191
  var face = _a.face,
@@ -7227,7 +7271,7 @@ function SelfieCaptureFaceKeypoint(_a) {
7227
7271
  }
7228
7272
  });
7229
7273
  }
7230
- var templateObject_1$M, templateObject_2$H, templateObject_3$v, templateObject_4$p;
7274
+ var templateObject_1$M, templateObject_2$H, templateObject_3$v, templateObject_4$p, templateObject_5$i;
7231
7275
 
7232
7276
  function OverrideWrongDocumentTypeGuidanceDialog(_a) {
7233
7277
  var _b = _a.classNames,
@@ -11675,6 +11719,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
11675
11719
  setRequiredDocumentType = _18.setRequiredDocumentType,
11676
11720
  modelError = _18.modelError,
11677
11721
  resetBestFrame = _18.resetBestFrame,
11722
+ resetBestBarcode = _18.resetBestBarcode,
11678
11723
  documentDetectionBoundaries = _18.documentDetectionBoundaries,
11679
11724
  setDocumentDetectionBoundaries = _18.setDocumentDetectionBoundaries,
11680
11725
  getBestBarcode = _18.getBestBarcode,
@@ -11948,44 +11993,63 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
11948
11993
  initialCaptureBarcodeImage: initialBarcodeImage
11949
11994
  }
11950
11995
  });
11951
- }, [state.captureState, (_d = state.capturedDocuments.idBarcodeImage) === null || _d === void 0 ? void 0 : _d.imageData, state.initialBarcodeScore, state.initialCaptureBarcodeImage]);
11996
+ // Start recapture phase immediately so barcode analysis runs with relaxed conditions
11997
+ // (don't require document in bounds since user is zooming in)
11998
+ startBarcodeRecapturePhase();
11999
+ }, [startBarcodeRecapturePhase, state.captureState, (_d = state.capturedDocuments.idBarcodeImage) === null || _d === void 0 ? void 0 : _d.imageData, state.initialBarcodeScore, state.initialCaptureBarcodeImage]);
12000
+ // Reset best barcode after 1 second delay to ignore early frames before user has time to move closer
12001
+ useEffect(function () {
12002
+ if (state.captureState !== 'requestingBetterBarcode') return;
12003
+ var t = setTimeout(function () {
12004
+ log('[IdCaptureWizard] Resetting best barcode after 1s delay in move-closer window');
12005
+ resetBestBarcode();
12006
+ }, 1000);
12007
+ return function () {
12008
+ return clearTimeout(t);
12009
+ };
12010
+ }, [resetBestBarcode, state.captureState]);
11952
12011
  // Handle barcode recapture timeout
11953
12012
  useEffect(function () {
11954
12013
  if (state.captureState !== 'requestingBetterBarcode') return;
11955
12014
  // Continue detection to try to get a better barcode
11956
12015
  setTimeout(start, 100);
11957
12016
  var t = setTimeout(function () {
11958
- // Move-closer window expired before recapture began
12017
+ var _a, _b;
12018
+ // Move-closer window expired before growth requirement was met
11959
12019
  if (recapturePhaseStartedRef.current) return;
11960
- var bestBarcode = getBestBarcode();
11961
- var improved = !!bestBarcode && bestBarcode.score > state.initialBarcodeScore;
12020
+ // Use recapture tracking since we start tracking with relaxed conditions immediately
12021
+ var recaptureBarcode = getRecaptureBestBarcode();
12022
+ var recaptureScore = (_a = recaptureBarcode === null || recaptureBarcode === void 0 ? void 0 : recaptureBarcode.score) !== null && _a !== void 0 ? _a : null;
12023
+ var improved = !!recaptureBarcode && recaptureBarcode.score > state.initialBarcodeScore;
11962
12024
  if (improved) {
11963
- log("[IdCaptureWizard] Barcode recapture move-closer window timed out. Found better barcode anyway: ".concat(bestBarcode.score.toFixed(3), " (was ").concat(state.initialBarcodeScore.toFixed(3), ")"));
11964
- // Persist the "after" image for debug visual comparison, even if the
11965
- // model-provider recapture tracker was never started.
11966
- dispatchIdCaptureAction({
11967
- type: 'recaptureBarcodeImageCaptured',
11968
- payload: {
11969
- recaptureBarcodeImage: bestBarcode.canvas.toDataURL('image/jpeg', 0.95)
11970
- }
11971
- });
12025
+ log("[IdCaptureWizard] Barcode recapture move-closer window timed out. Found better barcode anyway: ".concat(recaptureBarcode.score.toFixed(3), " (was ").concat(state.initialBarcodeScore.toFixed(3), ")"));
11972
12026
  dispatchIdCaptureAction({
11973
12027
  type: 'barcodeCaptured',
11974
12028
  payload: {
11975
- imageUrl: bestBarcode.canvas.toDataURL('image/jpeg', 0.95),
11976
- barcodeReadabilityScore: bestBarcode.score
12029
+ imageUrl: recaptureBarcode.canvas.toDataURL('image/jpeg', 0.95),
12030
+ barcodeReadabilityScore: recaptureBarcode.score
11977
12031
  }
11978
12032
  });
11979
12033
  } else {
11980
- log("[IdCaptureWizard] Barcode recapture move-closer window timed out. No better barcode found. Initial score: ".concat(state.initialBarcodeScore.toFixed(3)));
12034
+ log("[IdCaptureWizard] Barcode recapture move-closer window timed out. No better barcode found. Best score during window: ".concat((_b = recaptureScore === null || recaptureScore === void 0 ? void 0 : recaptureScore.toFixed(3)) !== null && _b !== void 0 ? _b : 'none', ", initial score: ").concat(state.initialBarcodeScore.toFixed(3)));
11981
12035
  }
11982
- // Record that recapture was attempted (for diagnostics)
12036
+ // Record recapture attempt data for diagnostics - always store the best score
12037
+ // from the move-closer window so debug info shows what was actually captured
11983
12038
  dispatchIdCaptureAction({
11984
12039
  type: 'barcodeRecaptureScoreUpdated',
11985
12040
  payload: {
11986
- recaptureBarcodeScore: improved ? bestBarcode.score : state.initialBarcodeScore
12041
+ recaptureBarcodeScore: recaptureScore
11987
12042
  }
11988
12043
  });
12044
+ // Persist the barcode image from move-closer window for debug visual comparison
12045
+ if (recaptureBarcode) {
12046
+ dispatchIdCaptureAction({
12047
+ type: 'recaptureBarcodeImageCaptured',
12048
+ payload: {
12049
+ recaptureBarcodeImage: recaptureBarcode.canvas.toDataURL('image/jpeg', 0.95)
12050
+ }
12051
+ });
12052
+ }
11989
12053
  dispatchIdCaptureAction({
11990
12054
  type: 'barcodeRecaptureCompleted'
11991
12055
  });
@@ -11993,7 +12057,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
11993
12057
  return function () {
11994
12058
  return clearTimeout(t);
11995
12059
  };
11996
- }, [barcodeRecaptureMoveCloserTimeoutMs, getBestBarcode, start, state.captureState, state.initialBarcodeScore]);
12060
+ }, [barcodeRecaptureMoveCloserTimeoutMs, getRecaptureBestBarcode, start, state.captureState, state.initialBarcodeScore]);
11997
12061
  useEffect(function () {
11998
12062
  if (state.captureState !== 'requestingBetterBarcode') return;
11999
12063
  if (!barcodeRecaptureGrowthSatisfied) return;
@@ -12004,11 +12068,14 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
12004
12068
  var bestBarcode = getBestBarcode();
12005
12069
  var recaptureScore = (_a = recaptureBarcode === null || recaptureBarcode === void 0 ? void 0 : recaptureBarcode.score) !== null && _a !== void 0 ? _a : null;
12006
12070
  var improved = !!bestBarcode && bestBarcode.score > state.initialBarcodeScore;
12071
+ log("[IdCaptureWizard] Recapture timeout debug: recaptureBarcode=".concat(!!recaptureBarcode, ", recaptureScore=").concat(recaptureScore, ", bestBarcode=").concat(!!bestBarcode, ", bestBarcodeScore=").concat(bestBarcode === null || bestBarcode === void 0 ? void 0 : bestBarcode.score, ", initialScore=").concat(state.initialBarcodeScore, ", improved=").concat(improved));
12007
12072
  // Store the recapture score for diagnostic purposes
12073
+ // Always use actual recapture score (even if worse than initial) so debug info
12074
+ // shows what was actually captured during each sequence
12008
12075
  dispatchIdCaptureAction({
12009
12076
  type: 'barcodeRecaptureScoreUpdated',
12010
12077
  payload: {
12011
- recaptureBarcodeScore: improved ? bestBarcode.score : recaptureScore !== null && recaptureScore !== void 0 ? recaptureScore : state.initialBarcodeScore
12078
+ recaptureBarcodeScore: recaptureScore
12012
12079
  }
12013
12080
  });
12014
12081
  // Store the recapture barcode image if we found one