idmission-web-sdk 2.2.163 → 2.2.165

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 (69) hide show
  1. package/dist/components/CompositeWizard.d.ts +2 -1
  2. package/dist/components/CompositeWizard.d.ts.map +1 -1
  3. package/dist/components/customer_flows/CustomerBiometricsEnrollment.d.ts +2 -0
  4. package/dist/components/customer_flows/CustomerBiometricsEnrollment.d.ts.map +1 -1
  5. package/dist/components/customer_flows/CustomerIdAndBiometricsEnrollment.d.ts +2 -0
  6. package/dist/components/customer_flows/CustomerIdAndBiometricsEnrollment.d.ts.map +1 -1
  7. package/dist/components/customer_flows/CustomerIdentification.d.ts +2 -0
  8. package/dist/components/customer_flows/CustomerIdentification.d.ts.map +1 -1
  9. package/dist/components/customer_flows/CustomerVerification.d.ts +2 -0
  10. package/dist/components/customer_flows/CustomerVerification.d.ts.map +1 -1
  11. package/dist/components/customer_flows/DocumentCapture.d.ts +2 -0
  12. package/dist/components/customer_flows/DocumentCapture.d.ts.map +1 -1
  13. package/dist/components/customer_flows/FaceValidation.d.ts +2 -0
  14. package/dist/components/customer_flows/FaceValidation.d.ts.map +1 -1
  15. package/dist/components/customer_flows/IdAndFaceValidation.d.ts +2 -0
  16. package/dist/components/customer_flows/IdAndFaceValidation.d.ts.map +1 -1
  17. package/dist/components/customer_flows/IdValidation.d.ts +2 -0
  18. package/dist/components/customer_flows/IdValidation.d.ts.map +1 -1
  19. package/dist/components/customer_flows/SignatureKYC.d.ts +2 -0
  20. package/dist/components/customer_flows/SignatureKYC.d.ts.map +1 -1
  21. package/dist/components/customer_flows/VideoIdValidation.d.ts +2 -0
  22. package/dist/components/customer_flows/VideoIdValidation.d.ts.map +1 -1
  23. package/dist/components/customer_identification/CustomerIdentificationWizard.d.ts +3 -0
  24. package/dist/components/customer_identification/CustomerIdentificationWizard.d.ts.map +1 -1
  25. package/dist/components/customer_verification/CustomerVerificationWizard.d.ts +3 -0
  26. package/dist/components/customer_verification/CustomerVerificationWizard.d.ts.map +1 -1
  27. package/dist/components/document_capture/DocumentCaptureWizard.d.ts +7 -2
  28. package/dist/components/document_capture/DocumentCaptureWizard.d.ts.map +1 -1
  29. package/dist/components/face_liveness/FaceLivenessWizard.d.ts +3 -0
  30. package/dist/components/face_liveness/FaceLivenessWizard.d.ts.map +1 -1
  31. package/dist/components/id_capture/IdCaptureWizard.d.ts +3 -0
  32. package/dist/components/id_capture/IdCaptureWizard.d.ts.map +1 -1
  33. package/dist/components/video_id/IdVideoCaptureWizard.d.ts +5 -1
  34. package/dist/components/video_id/IdVideoCaptureWizard.d.ts.map +1 -1
  35. package/dist/components/video_signature_capture/VideoSignatureWizard.d.ts +4 -0
  36. package/dist/components/video_signature_capture/VideoSignatureWizard.d.ts.map +1 -1
  37. package/dist/contexts/AuthStateContext.d.ts.map +1 -1
  38. package/dist/lib/camera/cameraStore.d.ts +21 -1
  39. package/dist/lib/camera/cameraStore.d.ts.map +1 -1
  40. package/dist/lib/locales/de.d.ts +3 -1
  41. package/dist/lib/locales/de.d.ts.map +1 -1
  42. package/dist/lib/locales/es.d.ts +3 -1
  43. package/dist/lib/locales/es.d.ts.map +1 -1
  44. package/dist/lib/locales/fr.d.ts +3 -1
  45. package/dist/lib/locales/fr.d.ts.map +1 -1
  46. package/dist/lib/locales/index.d.ts +23 -7
  47. package/dist/lib/locales/index.d.ts.map +1 -1
  48. package/dist/lib/locales/it.d.ts +3 -1
  49. package/dist/lib/locales/it.d.ts.map +1 -1
  50. package/dist/lib/locales/ja.d.ts +3 -1
  51. package/dist/lib/locales/ja.d.ts.map +1 -1
  52. package/dist/lib/locales/pt.d.ts +3 -1
  53. package/dist/lib/locales/pt.d.ts.map +1 -1
  54. package/dist/lib/locales/ru.d.ts +2 -0
  55. package/dist/lib/locales/ru.d.ts.map +1 -1
  56. package/dist/lib/locales/zh.d.ts +3 -1
  57. package/dist/lib/locales/zh.d.ts.map +1 -1
  58. package/dist/sdk2.cjs.development.js +2117 -1958
  59. package/dist/sdk2.cjs.development.js.map +1 -1
  60. package/dist/sdk2.cjs.production.js +1 -1
  61. package/dist/sdk2.cjs.production.js.map +1 -1
  62. package/dist/sdk2.esm.js +2118 -1959
  63. package/dist/sdk2.esm.js.map +1 -1
  64. package/dist/sdk2.umd.development.js +5883 -5724
  65. package/dist/sdk2.umd.development.js.map +1 -1
  66. package/dist/sdk2.umd.production.js +1 -1
  67. package/dist/sdk2.umd.production.js.map +1 -1
  68. package/dist/version.d.ts +1 -1
  69. package/package.json +1 -1
package/dist/sdk2.esm.js CHANGED
@@ -7,13 +7,13 @@ import { useTranslation, initReactI18next } from 'react-i18next';
7
7
  import { Upload } from 'tus-js-client';
8
8
  import SparkMD5 from 'spark-md5';
9
9
  import { ImageSegmenter, FilesetResolver, ImageClassifier, FaceDetector, ObjectDetector } from '@mediapipe/tasks-vision';
10
- import { createStore, useStore, create } from 'zustand';
10
+ import { useStore, createStore, create } from 'zustand';
11
+ import LanguageDetector from 'i18next-browser-languagedetector';
12
+ import i18n from 'i18next';
11
13
  import { useDebouncedCallback, useThrottledCallback } from 'use-debounce';
12
14
  import { devtools } from 'zustand/middleware';
13
15
  import { useShallow } from 'zustand/react/shallow';
14
16
  import { createPortal } from 'react-dom';
15
- import LanguageDetector from 'i18next-browser-languagedetector';
16
- import i18n from 'i18next';
17
17
  import SignatureCanvas from 'react-signature-canvas';
18
18
 
19
19
  /******************************************************************************
@@ -203,7 +203,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
203
203
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
204
204
  };
205
205
 
206
- var webSdkVersion = '2.2.163';
206
+ var webSdkVersion = '2.2.165';
207
207
 
208
208
  function getPlatform() {
209
209
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -364,7 +364,7 @@ function videoDataUrlToB64(url) {
364
364
  });
365
365
  }
366
366
 
367
- var PageContainerDiv = styled.div(templateObject_1$M || (templateObject_1$M = __makeTemplateObject(["\n ", "\n\n ", "\n\n &.flex {\n display: flex;\n }\n\n &.padded {\n box-sizing: border-box;\n padding: 16px 24px;\n }\n"], ["\n ", "\n\n ", "\n\n &.flex {\n display: flex;\n }\n\n &.padded {\n box-sizing: border-box;\n padding: 16px 24px;\n }\n"])), function (props) {
367
+ var PageContainerDiv = styled.div(templateObject_1$N || (templateObject_1$N = __makeTemplateObject(["\n ", "\n\n ", "\n\n &.flex {\n display: flex;\n }\n\n &.padded {\n box-sizing: border-box;\n padding: 16px 24px;\n }\n"], ["\n ", "\n\n ", "\n\n &.flex {\n display: flex;\n }\n\n &.padded {\n box-sizing: border-box;\n padding: 16px 24px;\n }\n"])), function (props) {
368
368
  var _a;
369
369
  return props.theme.isFullscreen === false ? "" : "\n position: fixed;\n top: 0;\n left: 0;\n width: var(--app-width);\n height: calc(\n var(--app-height) - ".concat((_a = props.$heightOffset) !== null && _a !== void 0 ? _a : 0, "px\n );\n overflow-x: hidden;\n overflow-y: auto;\n ");
370
370
  }, function (props) {
@@ -404,7 +404,7 @@ var PageContainer = /*#__PURE__*/forwardRef(function (_a, ref) {
404
404
  }, dimensionsCalculated && children);
405
405
  });
406
406
  PageContainer.displayName = 'PageContainer';
407
- var templateObject_1$M;
407
+ var templateObject_1$N;
408
408
 
409
409
  var LoaderButton = function LoaderButton(_a) {
410
410
  var children = _a.children,
@@ -461,18 +461,18 @@ var LoaderButton = function LoaderButton(_a) {
461
461
  className: "ladda-label"
462
462
  }, children));
463
463
  };
464
- var StyledButton = styled.button(templateObject_1$L || (templateObject_1$L = __makeTemplateObject(["\n ", "\n\n /*!\n * Ladda\n * http://lab.hakim.se/ladda\n * MIT licensed\n *\n * Copyright (C) 2018 Hakim El Hattab, http://hakim.se\n */\n\n position: relative;\n\n .ladda-spinner {\n position: absolute;\n z-index: 2;\n display: inline-block;\n width: 32px;\n top: 50%;\n margin-top: 0;\n opacity: 0;\n pointer-events: none;\n }\n .ladda-label {\n position: relative;\n z-index: 3;\n }\n .ladda-progress {\n position: absolute;\n width: 0;\n height: 100%;\n left: 0;\n top: 0;\n background: rgba(0, 0, 0, 0.2);\n display: none;\n transition: 0.1s linear all !important;\n }\n &[data-loading] .ladda-progress {\n display: block;\n }\n\n transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;\n\n .ladda-spinner,\n .ladda-label {\n transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;\n }\n &[data-style='zoom-in'],\n &[data-style='zoom-in'] .ladda-spinner,\n &[data-style='zoom-in'] .ladda-label,\n &[data-style='zoom-out'],\n &[data-style='zoom-out'] .ladda-spinner,\n &[data-style='zoom-out'] .ladda-label {\n transition: 0.3s ease all !important;\n }\n &[data-style='expand-right'] .ladda-spinner {\n right: -6px;\n }\n &[data-style='expand-right'][data-size='s'] .ladda-spinner,\n &[data-style='expand-right'][data-size='xs'] .ladda-spinner {\n right: -12px;\n }\n &[data-style='expand-right'][data-loading] {\n padding-right: 56px;\n }\n &[data-style='expand-right'][data-loading] .ladda-spinner {\n opacity: 1;\n }\n &[data-style='expand-right'][data-loading][data-size='s'],\n &[data-style='expand-right'][data-loading][data-size='xs'] {\n padding-right: 40px;\n }\n &[data-style='expand-left'] .ladda-spinner {\n left: 26px;\n }\n &[data-style='expand-left'][data-size='s'] .ladda-spinner,\n &[data-style='expand-left'][data-size='xs'] .ladda-spinner {\n left: 4px;\n }\n &[data-style='expand-left'][data-loading] {\n padding-left: 56px;\n }\n &[data-style='expand-left'][data-loading] .ladda-spinner {\n opacity: 1;\n }\n &[data-style='expand-left'][data-loading][data-size='s'],\n &[data-style='expand-left'][data-loading][data-size='xs'] {\n padding-left: 40px;\n }\n &[data-style='expand-up'] {\n overflow: hidden;\n }\n &[data-style='expand-up'] .ladda-spinner {\n top: -32px;\n left: 50%;\n margin-left: 0;\n }\n &[data-style='expand-up'][data-loading] {\n padding-top: 54px;\n }\n &[data-style='expand-up'][data-loading] .ladda-spinner {\n opacity: 1;\n top: 26px;\n margin-top: 0;\n }\n &[data-style='expand-up'][data-loading][data-size='s'],\n &[data-style='expand-up'][data-loading][data-size='xs'] {\n padding-top: 32px;\n }\n &[data-style='expand-up'][data-loading][data-size='s'] .ladda-spinner,\n &[data-style='expand-up'][data-loading][data-size='xs'] .ladda-spinner {\n top: 4px;\n }\n &[data-style='expand-down'] {\n overflow: hidden;\n }\n &[data-style='expand-down'] .ladda-spinner {\n top: 62px;\n left: 50%;\n margin-left: 0;\n }\n &[data-style='expand-down'][data-size='s'] .ladda-spinner,\n &[data-style='expand-down'][data-size='xs'] .ladda-spinner {\n top: 40px;\n }\n &[data-style='expand-down'][data-loading] {\n padding-bottom: 54px;\n }\n &[data-style='expand-down'][data-loading] .ladda-spinner {\n opacity: 1;\n }\n &[data-style='expand-down'][data-loading][data-size='s'],\n &[data-style='expand-down'][data-loading][data-size='xs'] {\n padding-bottom: 32px;\n }\n &[data-style='slide-left'] {\n overflow: hidden;\n }\n &[data-style='slide-left'] .ladda-label {\n position: relative;\n }\n &[data-style='slide-left'] .ladda-spinner {\n left: 100%;\n margin-left: 0;\n }\n &[data-style='slide-left'][data-loading] .ladda-label {\n opacity: 0;\n left: -100%;\n }\n &[data-style='slide-left'][data-loading] .ladda-spinner {\n opacity: 1;\n left: 50%;\n }\n &[data-style='slide-right'] {\n overflow: hidden;\n }\n &[data-style='slide-right'] .ladda-label {\n position: relative;\n }\n &[data-style='slide-right'] .ladda-spinner {\n right: 100%;\n margin-left: 0;\n left: 16px;\n }\n [dir='rtl'] &[data-style='slide-right'] .ladda-spinner {\n right: auto;\n }\n &[data-style='slide-right'][data-loading] .ladda-label {\n opacity: 0;\n left: 100%;\n }\n &[data-style='slide-right'][data-loading] .ladda-spinner {\n opacity: 1;\n left: 50%;\n }\n &[data-style='slide-up'] {\n overflow: hidden;\n }\n &[data-style='slide-up'] .ladda-label {\n position: relative;\n }\n &[data-style='slide-up'] .ladda-spinner {\n left: 50%;\n margin-left: 0;\n margin-top: 1em;\n }\n &[data-style='slide-up'][data-loading] .ladda-label {\n opacity: 0;\n top: -1em;\n }\n &[data-style='slide-up'][data-loading] .ladda-spinner {\n opacity: 1;\n margin-top: 0;\n }\n &[data-style='slide-down'] {\n overflow: hidden;\n }\n &[data-style='slide-down'] .ladda-label {\n position: relative;\n }\n &[data-style='slide-down'] .ladda-spinner {\n left: 50%;\n margin-left: 0;\n margin-top: -2em;\n }\n &[data-style='slide-down'][data-loading] .ladda-label {\n opacity: 0;\n top: 1em;\n }\n &[data-style='slide-down'][data-loading] .ladda-spinner {\n opacity: 1;\n margin-top: 0;\n }\n &[data-style='zoom-out'] {\n overflow: hidden;\n }\n &[data-style='zoom-out'] .ladda-spinner {\n left: 50%;\n margin-left: 32px;\n transform: scale(2.5);\n }\n &[data-style='zoom-out'] .ladda-label {\n position: relative;\n display: inline-block;\n }\n &[data-style='zoom-out'][data-loading] .ladda-label {\n opacity: 0;\n transform: scale(0.5);\n }\n &[data-style='zoom-out'][data-loading] .ladda-spinner {\n opacity: 1;\n margin-left: 0;\n transform: none;\n }\n &[data-style='zoom-in'] {\n overflow: hidden;\n }\n &[data-style='zoom-in'] .ladda-spinner {\n left: 50%;\n margin-left: -16px;\n transform: scale(0.2);\n }\n &[data-style='zoom-in'] .ladda-label {\n position: relative;\n display: inline-block;\n }\n &[data-style='zoom-in'][data-loading] .ladda-label {\n opacity: 0;\n transform: scale(2.2);\n }\n &[data-style='zoom-in'][data-loading] .ladda-spinner {\n opacity: 1;\n margin-left: 0;\n transform: none;\n }\n &[data-style='contract'] {\n overflow: hidden;\n width: 100px;\n }\n &[data-style='contract'] .ladda-spinner {\n left: 50%;\n margin-left: 0;\n }\n &[data-style='contract'][data-loading] {\n border-radius: 50%;\n width: 52px;\n }\n &[data-style='contract'][data-loading] .ladda-label {\n opacity: 0;\n }\n &[data-style='contract'][data-loading] .ladda-spinner {\n opacity: 1;\n }\n &[data-style='contract-overlay'] {\n overflow: hidden;\n width: 100px;\n box-shadow: 0px 0px 0px 2000px rgba(0, 0, 0, 0);\n }\n &[data-style='contract-overlay'] .ladda-spinner {\n left: 50%;\n margin-left: 0;\n }\n &[data-style='contract-overlay'][data-loading] {\n border-radius: 50%;\n width: 52px;\n box-shadow: 0px 0px 0px 2000px rgba(0, 0, 0, 0.8);\n }\n &[data-style='contract-overlay'][data-loading] .ladda-label {\n opacity: 0;\n }\n &[data-style='contract-overlay'][data-loading] .ladda-spinner {\n opacity: 1;\n }\n [dir='rtl'] .ladda-spinner > div {\n left: 25% !important;\n }\n"], ["\n ", "\n\n /*!\n * Ladda\n * http://lab.hakim.se/ladda\n * MIT licensed\n *\n * Copyright (C) 2018 Hakim El Hattab, http://hakim.se\n */\n\n position: relative;\n\n .ladda-spinner {\n position: absolute;\n z-index: 2;\n display: inline-block;\n width: 32px;\n top: 50%;\n margin-top: 0;\n opacity: 0;\n pointer-events: none;\n }\n .ladda-label {\n position: relative;\n z-index: 3;\n }\n .ladda-progress {\n position: absolute;\n width: 0;\n height: 100%;\n left: 0;\n top: 0;\n background: rgba(0, 0, 0, 0.2);\n display: none;\n transition: 0.1s linear all !important;\n }\n &[data-loading] .ladda-progress {\n display: block;\n }\n\n transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;\n\n .ladda-spinner,\n .ladda-label {\n transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;\n }\n &[data-style='zoom-in'],\n &[data-style='zoom-in'] .ladda-spinner,\n &[data-style='zoom-in'] .ladda-label,\n &[data-style='zoom-out'],\n &[data-style='zoom-out'] .ladda-spinner,\n &[data-style='zoom-out'] .ladda-label {\n transition: 0.3s ease all !important;\n }\n &[data-style='expand-right'] .ladda-spinner {\n right: -6px;\n }\n &[data-style='expand-right'][data-size='s'] .ladda-spinner,\n &[data-style='expand-right'][data-size='xs'] .ladda-spinner {\n right: -12px;\n }\n &[data-style='expand-right'][data-loading] {\n padding-right: 56px;\n }\n &[data-style='expand-right'][data-loading] .ladda-spinner {\n opacity: 1;\n }\n &[data-style='expand-right'][data-loading][data-size='s'],\n &[data-style='expand-right'][data-loading][data-size='xs'] {\n padding-right: 40px;\n }\n &[data-style='expand-left'] .ladda-spinner {\n left: 26px;\n }\n &[data-style='expand-left'][data-size='s'] .ladda-spinner,\n &[data-style='expand-left'][data-size='xs'] .ladda-spinner {\n left: 4px;\n }\n &[data-style='expand-left'][data-loading] {\n padding-left: 56px;\n }\n &[data-style='expand-left'][data-loading] .ladda-spinner {\n opacity: 1;\n }\n &[data-style='expand-left'][data-loading][data-size='s'],\n &[data-style='expand-left'][data-loading][data-size='xs'] {\n padding-left: 40px;\n }\n &[data-style='expand-up'] {\n overflow: hidden;\n }\n &[data-style='expand-up'] .ladda-spinner {\n top: -32px;\n left: 50%;\n margin-left: 0;\n }\n &[data-style='expand-up'][data-loading] {\n padding-top: 54px;\n }\n &[data-style='expand-up'][data-loading] .ladda-spinner {\n opacity: 1;\n top: 26px;\n margin-top: 0;\n }\n &[data-style='expand-up'][data-loading][data-size='s'],\n &[data-style='expand-up'][data-loading][data-size='xs'] {\n padding-top: 32px;\n }\n &[data-style='expand-up'][data-loading][data-size='s'] .ladda-spinner,\n &[data-style='expand-up'][data-loading][data-size='xs'] .ladda-spinner {\n top: 4px;\n }\n &[data-style='expand-down'] {\n overflow: hidden;\n }\n &[data-style='expand-down'] .ladda-spinner {\n top: 62px;\n left: 50%;\n margin-left: 0;\n }\n &[data-style='expand-down'][data-size='s'] .ladda-spinner,\n &[data-style='expand-down'][data-size='xs'] .ladda-spinner {\n top: 40px;\n }\n &[data-style='expand-down'][data-loading] {\n padding-bottom: 54px;\n }\n &[data-style='expand-down'][data-loading] .ladda-spinner {\n opacity: 1;\n }\n &[data-style='expand-down'][data-loading][data-size='s'],\n &[data-style='expand-down'][data-loading][data-size='xs'] {\n padding-bottom: 32px;\n }\n &[data-style='slide-left'] {\n overflow: hidden;\n }\n &[data-style='slide-left'] .ladda-label {\n position: relative;\n }\n &[data-style='slide-left'] .ladda-spinner {\n left: 100%;\n margin-left: 0;\n }\n &[data-style='slide-left'][data-loading] .ladda-label {\n opacity: 0;\n left: -100%;\n }\n &[data-style='slide-left'][data-loading] .ladda-spinner {\n opacity: 1;\n left: 50%;\n }\n &[data-style='slide-right'] {\n overflow: hidden;\n }\n &[data-style='slide-right'] .ladda-label {\n position: relative;\n }\n &[data-style='slide-right'] .ladda-spinner {\n right: 100%;\n margin-left: 0;\n left: 16px;\n }\n [dir='rtl'] &[data-style='slide-right'] .ladda-spinner {\n right: auto;\n }\n &[data-style='slide-right'][data-loading] .ladda-label {\n opacity: 0;\n left: 100%;\n }\n &[data-style='slide-right'][data-loading] .ladda-spinner {\n opacity: 1;\n left: 50%;\n }\n &[data-style='slide-up'] {\n overflow: hidden;\n }\n &[data-style='slide-up'] .ladda-label {\n position: relative;\n }\n &[data-style='slide-up'] .ladda-spinner {\n left: 50%;\n margin-left: 0;\n margin-top: 1em;\n }\n &[data-style='slide-up'][data-loading] .ladda-label {\n opacity: 0;\n top: -1em;\n }\n &[data-style='slide-up'][data-loading] .ladda-spinner {\n opacity: 1;\n margin-top: 0;\n }\n &[data-style='slide-down'] {\n overflow: hidden;\n }\n &[data-style='slide-down'] .ladda-label {\n position: relative;\n }\n &[data-style='slide-down'] .ladda-spinner {\n left: 50%;\n margin-left: 0;\n margin-top: -2em;\n }\n &[data-style='slide-down'][data-loading] .ladda-label {\n opacity: 0;\n top: 1em;\n }\n &[data-style='slide-down'][data-loading] .ladda-spinner {\n opacity: 1;\n margin-top: 0;\n }\n &[data-style='zoom-out'] {\n overflow: hidden;\n }\n &[data-style='zoom-out'] .ladda-spinner {\n left: 50%;\n margin-left: 32px;\n transform: scale(2.5);\n }\n &[data-style='zoom-out'] .ladda-label {\n position: relative;\n display: inline-block;\n }\n &[data-style='zoom-out'][data-loading] .ladda-label {\n opacity: 0;\n transform: scale(0.5);\n }\n &[data-style='zoom-out'][data-loading] .ladda-spinner {\n opacity: 1;\n margin-left: 0;\n transform: none;\n }\n &[data-style='zoom-in'] {\n overflow: hidden;\n }\n &[data-style='zoom-in'] .ladda-spinner {\n left: 50%;\n margin-left: -16px;\n transform: scale(0.2);\n }\n &[data-style='zoom-in'] .ladda-label {\n position: relative;\n display: inline-block;\n }\n &[data-style='zoom-in'][data-loading] .ladda-label {\n opacity: 0;\n transform: scale(2.2);\n }\n &[data-style='zoom-in'][data-loading] .ladda-spinner {\n opacity: 1;\n margin-left: 0;\n transform: none;\n }\n &[data-style='contract'] {\n overflow: hidden;\n width: 100px;\n }\n &[data-style='contract'] .ladda-spinner {\n left: 50%;\n margin-left: 0;\n }\n &[data-style='contract'][data-loading] {\n border-radius: 50%;\n width: 52px;\n }\n &[data-style='contract'][data-loading] .ladda-label {\n opacity: 0;\n }\n &[data-style='contract'][data-loading] .ladda-spinner {\n opacity: 1;\n }\n &[data-style='contract-overlay'] {\n overflow: hidden;\n width: 100px;\n box-shadow: 0px 0px 0px 2000px rgba(0, 0, 0, 0);\n }\n &[data-style='contract-overlay'] .ladda-spinner {\n left: 50%;\n margin-left: 0;\n }\n &[data-style='contract-overlay'][data-loading] {\n border-radius: 50%;\n width: 52px;\n box-shadow: 0px 0px 0px 2000px rgba(0, 0, 0, 0.8);\n }\n &[data-style='contract-overlay'][data-loading] .ladda-label {\n opacity: 0;\n }\n &[data-style='contract-overlay'][data-loading] .ladda-spinner {\n opacity: 1;\n }\n [dir='rtl'] .ladda-spinner > div {\n left: 25% !important;\n }\n"])), function (props) {
464
+ var StyledButton = styled.button(templateObject_1$M || (templateObject_1$M = __makeTemplateObject(["\n ", "\n\n /*!\n * Ladda\n * http://lab.hakim.se/ladda\n * MIT licensed\n *\n * Copyright (C) 2018 Hakim El Hattab, http://hakim.se\n */\n\n position: relative;\n\n .ladda-spinner {\n position: absolute;\n z-index: 2;\n display: inline-block;\n width: 32px;\n top: 50%;\n margin-top: 0;\n opacity: 0;\n pointer-events: none;\n }\n .ladda-label {\n position: relative;\n z-index: 3;\n }\n .ladda-progress {\n position: absolute;\n width: 0;\n height: 100%;\n left: 0;\n top: 0;\n background: rgba(0, 0, 0, 0.2);\n display: none;\n transition: 0.1s linear all !important;\n }\n &[data-loading] .ladda-progress {\n display: block;\n }\n\n transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;\n\n .ladda-spinner,\n .ladda-label {\n transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;\n }\n &[data-style='zoom-in'],\n &[data-style='zoom-in'] .ladda-spinner,\n &[data-style='zoom-in'] .ladda-label,\n &[data-style='zoom-out'],\n &[data-style='zoom-out'] .ladda-spinner,\n &[data-style='zoom-out'] .ladda-label {\n transition: 0.3s ease all !important;\n }\n &[data-style='expand-right'] .ladda-spinner {\n right: -6px;\n }\n &[data-style='expand-right'][data-size='s'] .ladda-spinner,\n &[data-style='expand-right'][data-size='xs'] .ladda-spinner {\n right: -12px;\n }\n &[data-style='expand-right'][data-loading] {\n padding-right: 56px;\n }\n &[data-style='expand-right'][data-loading] .ladda-spinner {\n opacity: 1;\n }\n &[data-style='expand-right'][data-loading][data-size='s'],\n &[data-style='expand-right'][data-loading][data-size='xs'] {\n padding-right: 40px;\n }\n &[data-style='expand-left'] .ladda-spinner {\n left: 26px;\n }\n &[data-style='expand-left'][data-size='s'] .ladda-spinner,\n &[data-style='expand-left'][data-size='xs'] .ladda-spinner {\n left: 4px;\n }\n &[data-style='expand-left'][data-loading] {\n padding-left: 56px;\n }\n &[data-style='expand-left'][data-loading] .ladda-spinner {\n opacity: 1;\n }\n &[data-style='expand-left'][data-loading][data-size='s'],\n &[data-style='expand-left'][data-loading][data-size='xs'] {\n padding-left: 40px;\n }\n &[data-style='expand-up'] {\n overflow: hidden;\n }\n &[data-style='expand-up'] .ladda-spinner {\n top: -32px;\n left: 50%;\n margin-left: 0;\n }\n &[data-style='expand-up'][data-loading] {\n padding-top: 54px;\n }\n &[data-style='expand-up'][data-loading] .ladda-spinner {\n opacity: 1;\n top: 26px;\n margin-top: 0;\n }\n &[data-style='expand-up'][data-loading][data-size='s'],\n &[data-style='expand-up'][data-loading][data-size='xs'] {\n padding-top: 32px;\n }\n &[data-style='expand-up'][data-loading][data-size='s'] .ladda-spinner,\n &[data-style='expand-up'][data-loading][data-size='xs'] .ladda-spinner {\n top: 4px;\n }\n &[data-style='expand-down'] {\n overflow: hidden;\n }\n &[data-style='expand-down'] .ladda-spinner {\n top: 62px;\n left: 50%;\n margin-left: 0;\n }\n &[data-style='expand-down'][data-size='s'] .ladda-spinner,\n &[data-style='expand-down'][data-size='xs'] .ladda-spinner {\n top: 40px;\n }\n &[data-style='expand-down'][data-loading] {\n padding-bottom: 54px;\n }\n &[data-style='expand-down'][data-loading] .ladda-spinner {\n opacity: 1;\n }\n &[data-style='expand-down'][data-loading][data-size='s'],\n &[data-style='expand-down'][data-loading][data-size='xs'] {\n padding-bottom: 32px;\n }\n &[data-style='slide-left'] {\n overflow: hidden;\n }\n &[data-style='slide-left'] .ladda-label {\n position: relative;\n }\n &[data-style='slide-left'] .ladda-spinner {\n left: 100%;\n margin-left: 0;\n }\n &[data-style='slide-left'][data-loading] .ladda-label {\n opacity: 0;\n left: -100%;\n }\n &[data-style='slide-left'][data-loading] .ladda-spinner {\n opacity: 1;\n left: 50%;\n }\n &[data-style='slide-right'] {\n overflow: hidden;\n }\n &[data-style='slide-right'] .ladda-label {\n position: relative;\n }\n &[data-style='slide-right'] .ladda-spinner {\n right: 100%;\n margin-left: 0;\n left: 16px;\n }\n [dir='rtl'] &[data-style='slide-right'] .ladda-spinner {\n right: auto;\n }\n &[data-style='slide-right'][data-loading] .ladda-label {\n opacity: 0;\n left: 100%;\n }\n &[data-style='slide-right'][data-loading] .ladda-spinner {\n opacity: 1;\n left: 50%;\n }\n &[data-style='slide-up'] {\n overflow: hidden;\n }\n &[data-style='slide-up'] .ladda-label {\n position: relative;\n }\n &[data-style='slide-up'] .ladda-spinner {\n left: 50%;\n margin-left: 0;\n margin-top: 1em;\n }\n &[data-style='slide-up'][data-loading] .ladda-label {\n opacity: 0;\n top: -1em;\n }\n &[data-style='slide-up'][data-loading] .ladda-spinner {\n opacity: 1;\n margin-top: 0;\n }\n &[data-style='slide-down'] {\n overflow: hidden;\n }\n &[data-style='slide-down'] .ladda-label {\n position: relative;\n }\n &[data-style='slide-down'] .ladda-spinner {\n left: 50%;\n margin-left: 0;\n margin-top: -2em;\n }\n &[data-style='slide-down'][data-loading] .ladda-label {\n opacity: 0;\n top: 1em;\n }\n &[data-style='slide-down'][data-loading] .ladda-spinner {\n opacity: 1;\n margin-top: 0;\n }\n &[data-style='zoom-out'] {\n overflow: hidden;\n }\n &[data-style='zoom-out'] .ladda-spinner {\n left: 50%;\n margin-left: 32px;\n transform: scale(2.5);\n }\n &[data-style='zoom-out'] .ladda-label {\n position: relative;\n display: inline-block;\n }\n &[data-style='zoom-out'][data-loading] .ladda-label {\n opacity: 0;\n transform: scale(0.5);\n }\n &[data-style='zoom-out'][data-loading] .ladda-spinner {\n opacity: 1;\n margin-left: 0;\n transform: none;\n }\n &[data-style='zoom-in'] {\n overflow: hidden;\n }\n &[data-style='zoom-in'] .ladda-spinner {\n left: 50%;\n margin-left: -16px;\n transform: scale(0.2);\n }\n &[data-style='zoom-in'] .ladda-label {\n position: relative;\n display: inline-block;\n }\n &[data-style='zoom-in'][data-loading] .ladda-label {\n opacity: 0;\n transform: scale(2.2);\n }\n &[data-style='zoom-in'][data-loading] .ladda-spinner {\n opacity: 1;\n margin-left: 0;\n transform: none;\n }\n &[data-style='contract'] {\n overflow: hidden;\n width: 100px;\n }\n &[data-style='contract'] .ladda-spinner {\n left: 50%;\n margin-left: 0;\n }\n &[data-style='contract'][data-loading] {\n border-radius: 50%;\n width: 52px;\n }\n &[data-style='contract'][data-loading] .ladda-label {\n opacity: 0;\n }\n &[data-style='contract'][data-loading] .ladda-spinner {\n opacity: 1;\n }\n &[data-style='contract-overlay'] {\n overflow: hidden;\n width: 100px;\n box-shadow: 0px 0px 0px 2000px rgba(0, 0, 0, 0);\n }\n &[data-style='contract-overlay'] .ladda-spinner {\n left: 50%;\n margin-left: 0;\n }\n &[data-style='contract-overlay'][data-loading] {\n border-radius: 50%;\n width: 52px;\n box-shadow: 0px 0px 0px 2000px rgba(0, 0, 0, 0.8);\n }\n &[data-style='contract-overlay'][data-loading] .ladda-label {\n opacity: 0;\n }\n &[data-style='contract-overlay'][data-loading] .ladda-spinner {\n opacity: 1;\n }\n [dir='rtl'] .ladda-spinner > div {\n left: 25% !important;\n }\n"], ["\n ", "\n\n /*!\n * Ladda\n * http://lab.hakim.se/ladda\n * MIT licensed\n *\n * Copyright (C) 2018 Hakim El Hattab, http://hakim.se\n */\n\n position: relative;\n\n .ladda-spinner {\n position: absolute;\n z-index: 2;\n display: inline-block;\n width: 32px;\n top: 50%;\n margin-top: 0;\n opacity: 0;\n pointer-events: none;\n }\n .ladda-label {\n position: relative;\n z-index: 3;\n }\n .ladda-progress {\n position: absolute;\n width: 0;\n height: 100%;\n left: 0;\n top: 0;\n background: rgba(0, 0, 0, 0.2);\n display: none;\n transition: 0.1s linear all !important;\n }\n &[data-loading] .ladda-progress {\n display: block;\n }\n\n transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;\n\n .ladda-spinner,\n .ladda-label {\n transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;\n }\n &[data-style='zoom-in'],\n &[data-style='zoom-in'] .ladda-spinner,\n &[data-style='zoom-in'] .ladda-label,\n &[data-style='zoom-out'],\n &[data-style='zoom-out'] .ladda-spinner,\n &[data-style='zoom-out'] .ladda-label {\n transition: 0.3s ease all !important;\n }\n &[data-style='expand-right'] .ladda-spinner {\n right: -6px;\n }\n &[data-style='expand-right'][data-size='s'] .ladda-spinner,\n &[data-style='expand-right'][data-size='xs'] .ladda-spinner {\n right: -12px;\n }\n &[data-style='expand-right'][data-loading] {\n padding-right: 56px;\n }\n &[data-style='expand-right'][data-loading] .ladda-spinner {\n opacity: 1;\n }\n &[data-style='expand-right'][data-loading][data-size='s'],\n &[data-style='expand-right'][data-loading][data-size='xs'] {\n padding-right: 40px;\n }\n &[data-style='expand-left'] .ladda-spinner {\n left: 26px;\n }\n &[data-style='expand-left'][data-size='s'] .ladda-spinner,\n &[data-style='expand-left'][data-size='xs'] .ladda-spinner {\n left: 4px;\n }\n &[data-style='expand-left'][data-loading] {\n padding-left: 56px;\n }\n &[data-style='expand-left'][data-loading] .ladda-spinner {\n opacity: 1;\n }\n &[data-style='expand-left'][data-loading][data-size='s'],\n &[data-style='expand-left'][data-loading][data-size='xs'] {\n padding-left: 40px;\n }\n &[data-style='expand-up'] {\n overflow: hidden;\n }\n &[data-style='expand-up'] .ladda-spinner {\n top: -32px;\n left: 50%;\n margin-left: 0;\n }\n &[data-style='expand-up'][data-loading] {\n padding-top: 54px;\n }\n &[data-style='expand-up'][data-loading] .ladda-spinner {\n opacity: 1;\n top: 26px;\n margin-top: 0;\n }\n &[data-style='expand-up'][data-loading][data-size='s'],\n &[data-style='expand-up'][data-loading][data-size='xs'] {\n padding-top: 32px;\n }\n &[data-style='expand-up'][data-loading][data-size='s'] .ladda-spinner,\n &[data-style='expand-up'][data-loading][data-size='xs'] .ladda-spinner {\n top: 4px;\n }\n &[data-style='expand-down'] {\n overflow: hidden;\n }\n &[data-style='expand-down'] .ladda-spinner {\n top: 62px;\n left: 50%;\n margin-left: 0;\n }\n &[data-style='expand-down'][data-size='s'] .ladda-spinner,\n &[data-style='expand-down'][data-size='xs'] .ladda-spinner {\n top: 40px;\n }\n &[data-style='expand-down'][data-loading] {\n padding-bottom: 54px;\n }\n &[data-style='expand-down'][data-loading] .ladda-spinner {\n opacity: 1;\n }\n &[data-style='expand-down'][data-loading][data-size='s'],\n &[data-style='expand-down'][data-loading][data-size='xs'] {\n padding-bottom: 32px;\n }\n &[data-style='slide-left'] {\n overflow: hidden;\n }\n &[data-style='slide-left'] .ladda-label {\n position: relative;\n }\n &[data-style='slide-left'] .ladda-spinner {\n left: 100%;\n margin-left: 0;\n }\n &[data-style='slide-left'][data-loading] .ladda-label {\n opacity: 0;\n left: -100%;\n }\n &[data-style='slide-left'][data-loading] .ladda-spinner {\n opacity: 1;\n left: 50%;\n }\n &[data-style='slide-right'] {\n overflow: hidden;\n }\n &[data-style='slide-right'] .ladda-label {\n position: relative;\n }\n &[data-style='slide-right'] .ladda-spinner {\n right: 100%;\n margin-left: 0;\n left: 16px;\n }\n [dir='rtl'] &[data-style='slide-right'] .ladda-spinner {\n right: auto;\n }\n &[data-style='slide-right'][data-loading] .ladda-label {\n opacity: 0;\n left: 100%;\n }\n &[data-style='slide-right'][data-loading] .ladda-spinner {\n opacity: 1;\n left: 50%;\n }\n &[data-style='slide-up'] {\n overflow: hidden;\n }\n &[data-style='slide-up'] .ladda-label {\n position: relative;\n }\n &[data-style='slide-up'] .ladda-spinner {\n left: 50%;\n margin-left: 0;\n margin-top: 1em;\n }\n &[data-style='slide-up'][data-loading] .ladda-label {\n opacity: 0;\n top: -1em;\n }\n &[data-style='slide-up'][data-loading] .ladda-spinner {\n opacity: 1;\n margin-top: 0;\n }\n &[data-style='slide-down'] {\n overflow: hidden;\n }\n &[data-style='slide-down'] .ladda-label {\n position: relative;\n }\n &[data-style='slide-down'] .ladda-spinner {\n left: 50%;\n margin-left: 0;\n margin-top: -2em;\n }\n &[data-style='slide-down'][data-loading] .ladda-label {\n opacity: 0;\n top: 1em;\n }\n &[data-style='slide-down'][data-loading] .ladda-spinner {\n opacity: 1;\n margin-top: 0;\n }\n &[data-style='zoom-out'] {\n overflow: hidden;\n }\n &[data-style='zoom-out'] .ladda-spinner {\n left: 50%;\n margin-left: 32px;\n transform: scale(2.5);\n }\n &[data-style='zoom-out'] .ladda-label {\n position: relative;\n display: inline-block;\n }\n &[data-style='zoom-out'][data-loading] .ladda-label {\n opacity: 0;\n transform: scale(0.5);\n }\n &[data-style='zoom-out'][data-loading] .ladda-spinner {\n opacity: 1;\n margin-left: 0;\n transform: none;\n }\n &[data-style='zoom-in'] {\n overflow: hidden;\n }\n &[data-style='zoom-in'] .ladda-spinner {\n left: 50%;\n margin-left: -16px;\n transform: scale(0.2);\n }\n &[data-style='zoom-in'] .ladda-label {\n position: relative;\n display: inline-block;\n }\n &[data-style='zoom-in'][data-loading] .ladda-label {\n opacity: 0;\n transform: scale(2.2);\n }\n &[data-style='zoom-in'][data-loading] .ladda-spinner {\n opacity: 1;\n margin-left: 0;\n transform: none;\n }\n &[data-style='contract'] {\n overflow: hidden;\n width: 100px;\n }\n &[data-style='contract'] .ladda-spinner {\n left: 50%;\n margin-left: 0;\n }\n &[data-style='contract'][data-loading] {\n border-radius: 50%;\n width: 52px;\n }\n &[data-style='contract'][data-loading] .ladda-label {\n opacity: 0;\n }\n &[data-style='contract'][data-loading] .ladda-spinner {\n opacity: 1;\n }\n &[data-style='contract-overlay'] {\n overflow: hidden;\n width: 100px;\n box-shadow: 0px 0px 0px 2000px rgba(0, 0, 0, 0);\n }\n &[data-style='contract-overlay'] .ladda-spinner {\n left: 50%;\n margin-left: 0;\n }\n &[data-style='contract-overlay'][data-loading] {\n border-radius: 50%;\n width: 52px;\n box-shadow: 0px 0px 0px 2000px rgba(0, 0, 0, 0.8);\n }\n &[data-style='contract-overlay'][data-loading] .ladda-label {\n opacity: 0;\n }\n &[data-style='contract-overlay'][data-loading] .ladda-spinner {\n opacity: 1;\n }\n [dir='rtl'] .ladda-spinner > div {\n left: 25% !important;\n }\n"])), function (props) {
465
465
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
466
466
  return ((_a = props.theme.buttons) === null || _a === void 0 ? void 0 : _a.style) === 'bootstrap' && "\n border-radius: 0;\n font-family: inherit;\n font-size: inherit;\n line-height: inherit;\n text-transform: none;\n -webkit-appearance: button;\n \n &:not(:disabled),\n &[type='button']:not(:disabled),\n &[type='reset']:not(:disabled),\n &[type='submit']:not(:disabled) {\n cursor: pointer;\n }\n \n &:focus:not(:focus-visible) {\n outline: 0;\n }\n \n --bs-btn-padding-x: 0.75rem;\n --bs-btn-padding-y: 0.375rem;\n --bs-btn-font-family: ;\n --bs-btn-font-size: 1rem;\n --bs-btn-font-weight: 400;\n --bs-btn-line-height: 1.5;\n --bs-btn-color: var(--bs-body-color);\n --bs-btn-bg: transparent;\n --bs-btn-border-width: var(--bs-border-width);\n --bs-btn-border-color: transparent;\n --bs-btn-border-radius: var(--bs-border-radius);\n --bs-btn-hover-border-color: transparent;\n --bs-btn-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15),\n 0 1px 1px rgba(0, 0, 0, 0.075);\n --bs-btn-disabled-opacity: 0.65;\n --bs-btn-focus-box-shadow: 0 0 0 0.25rem\n rgba(var(--bs-btn-focus-shadow-rgb), 0.5);\n display: inline-block;\n padding: var(--bs-btn-padding-y) var(--bs-btn-padding-x);\n font-family: var(--bs-btn-font-family);\n font-size: var(--bs-btn-font-size);\n font-weight: var(--bs-btn-font-weight);\n line-height: var(--bs-btn-line-height);\n color: var(--bs-btn-color);\n text-align: center;\n text-decoration: none;\n vertical-align: middle;\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n border: var(--bs-btn-border-width) solid var(--bs-btn-border-color);\n border-radius: var(--bs-btn-border-radius);\n background-color: var(--bs-btn-bg);\n //transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out,\n // border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;\n \n @media (prefers-reduced-motion: reduce) {\n transition: none;\n }\n \n &:hover {\n filter: brightness(1.15);\n }\n \n &:focus-visible {\n color: var(--bs-btn-hover-color);\n background-color: var(--bs-btn-hover-bg);\n border-color: var(--bs-btn-hover-border-color);\n outline: 0;\n box-shadow: var(--bs-btn-focus-box-shadow);\n }\n \n &:disabled,\n &.disabled,\n fieldset:disabled & {\n color: var(--bs-btn-disabled-color);\n pointer-events: none;\n background-color: var(--bs-btn-disabled-bg);\n border-color: var(--bs-btn-disabled-border-color);\n opacity: var(--bs-btn-disabled-opacity);\n }\n \n --bs-btn-color: ".concat((_f = (_b = props.$textColor) !== null && _b !== void 0 ? _b : (_e = (_c = props.theme.buttons) === null || _c === void 0 ? void 0 : _c[(_d = props.$variant) !== null && _d !== void 0 ? _d : 'primary']) === null || _e === void 0 ? void 0 : _e.textColor) !== null && _f !== void 0 ? _f : '#fff', ";\n --bs-btn-bg: ").concat((_l = (_g = props.$backgroundColor) !== null && _g !== void 0 ? _g : (_k = (_h = props.theme.buttons) === null || _h === void 0 ? void 0 : _h[(_j = props.$variant) !== null && _j !== void 0 ? _j : 'primary']) === null || _k === void 0 ? void 0 : _k.backgroundColor) !== null && _l !== void 0 ? _l : '#0d6efd', ";\n --bs-btn-border-color: var(--bs-btn-bg);\n --bs-btn-focus-shadow-rgb: 49, 132, 253;\n --bs-btn-active-color: #fff;\n --bs-btn-active-bg: #0a58ca;\n --bs-btn-active-border-color: #0a53be;\n --bs-btn-active-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);\n --bs-btn-disabled-color: ").concat((_q = (_m = props.$disabledTextColor) !== null && _m !== void 0 ? _m : (_p = (_o = props.theme.buttons) === null || _o === void 0 ? void 0 : _o.loading) === null || _p === void 0 ? void 0 : _p.textColor) !== null && _q !== void 0 ? _q : '#fff', ";\n --bs-btn-disabled-bg: ").concat((_u = (_r = props.$disabledBackgroundColor) !== null && _r !== void 0 ? _r : (_t = (_s = props.theme.buttons) === null || _s === void 0 ? void 0 : _s.loading) === null || _t === void 0 ? void 0 : _t.backgroundColor) !== null && _u !== void 0 ? _u : 'gray', ";\n --bs-btn-disabled-border-color: ").concat((_v = props.$disabledBackgroundColor) !== null && _v !== void 0 ? _v : '#0d6efd', ";\n \n --bs-btn-padding-y: 14px;\n --bs-btn-padding-x: 1rem;\n --bs-btn-font-size: 18px;\n --bs-btn-border-radius: 4px;\n ");
467
467
  });
468
- var templateObject_1$L;
468
+ var templateObject_1$M;
469
469
 
470
- var OverlayContainer = styled(PageContainer)(templateObject_1$K || (templateObject_1$K = __makeTemplateObject(["\n background: ", ";\n ", "\n z-index: 10000;\n"], ["\n background: ", ";\n ", "\n z-index: 10000;\n"])), function (props) {
470
+ var OverlayContainer = styled(PageContainer)(templateObject_1$L || (templateObject_1$L = __makeTemplateObject(["\n background: ", ";\n ", "\n z-index: 10000;\n"], ["\n background: ", ";\n ", "\n z-index: 10000;\n"])), function (props) {
471
471
  return props.theme.background ? "".concat(props.theme.background) : "white";
472
472
  }, function (props) {
473
473
  return props.theme.textColor ? "color: ".concat(props.theme.textColor, ";") : "";
474
474
  });
475
- var OverlayInner$2 = styled.div(templateObject_2$B || (templateObject_2$B = __makeTemplateObject(["\n text-align: ", ";\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n max-width: 100dvw;\n max-height: 100dvh;\n width: 100%;\n height: 100%;\n ", "\n"], ["\n text-align: ", ";\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n max-width: 100dvw;\n max-height: 100dvh;\n width: 100%;\n height: 100%;\n ", "\n"])), function (props) {
475
+ var OverlayInner$2 = styled.div(templateObject_2$C || (templateObject_2$C = __makeTemplateObject(["\n text-align: ", ";\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n max-width: 100dvw;\n max-height: 100dvh;\n width: 100%;\n height: 100%;\n ", "\n"], ["\n text-align: ", ";\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n max-width: 100dvw;\n max-height: 100dvh;\n width: 100%;\n height: 100%;\n ", "\n"])), function (props) {
476
476
  var _a;
477
477
  return (_a = props.theme.textAlign) !== null && _a !== void 0 ? _a : 'center';
478
478
  }, function (props) {
@@ -493,7 +493,7 @@ var WideBorderButton = styled(WideButton)(templateObject_8$4 || (templateObject_
493
493
  var _a, _b;
494
494
  return (_b = (_a = props.colors) === null || _a === void 0 ? void 0 : _a.borderColor) !== null && _b !== void 0 ? _b : 'var(--idm-color-secondary-500)';
495
495
  });
496
- var templateObject_1$K, templateObject_2$B, templateObject_3$s, templateObject_4$m, templateObject_5$d, templateObject_6$a, templateObject_7$7, templateObject_8$4;
496
+ var templateObject_1$L, templateObject_2$C, templateObject_3$s, templateObject_4$m, templateObject_5$d, templateObject_6$a, templateObject_7$7, templateObject_8$4;
497
497
 
498
498
  var GeolocationAccessDeniedOverlay = function GeolocationAccessDeniedOverlay(_a) {
499
499
  var accessBlockedImageUrl = _a.accessBlockedImageUrl;
@@ -740,13 +740,13 @@ var SessionValidationErrorOverlay = function SessionValidationErrorOverlay(_a) {
740
740
  }, retryText)))));
741
741
  };
742
742
 
743
- var wavesAnimation = keyframes(templateObject_1$J || (templateObject_1$J = __makeTemplateObject(["\n 0% {\n opacity: 0;\n transform: scale3d(1, 1, 1);\n }\n 80% {\n opacity: 1;\n }\n 100% {\n transform: scale3d(2, 2, 1);\n opacity: 0;\n }\n"], ["\n 0% {\n opacity: 0;\n transform: scale3d(1, 1, 1);\n }\n 80% {\n opacity: 1;\n }\n 100% {\n transform: scale3d(2, 2, 1);\n opacity: 0;\n }\n"])));
744
- var progressBarAnimation = keyframes(templateObject_2$A || (templateObject_2$A = __makeTemplateObject(["\n 0% {\n width: 0;\n }\n 100% {\n width: 100%;\n }\n"], ["\n 0% {\n width: 0;\n }\n 100% {\n width: 100%;\n }\n"])));
743
+ var wavesAnimation = keyframes(templateObject_1$K || (templateObject_1$K = __makeTemplateObject(["\n 0% {\n opacity: 0;\n transform: scale3d(1, 1, 1);\n }\n 80% {\n opacity: 1;\n }\n 100% {\n transform: scale3d(2, 2, 1);\n opacity: 0;\n }\n"], ["\n 0% {\n opacity: 0;\n transform: scale3d(1, 1, 1);\n }\n 80% {\n opacity: 1;\n }\n 100% {\n transform: scale3d(2, 2, 1);\n opacity: 0;\n }\n"])));
744
+ var progressBarAnimation = keyframes(templateObject_2$B || (templateObject_2$B = __makeTemplateObject(["\n 0% {\n width: 0;\n }\n 100% {\n width: 100%;\n }\n"], ["\n 0% {\n width: 0;\n }\n 100% {\n width: 100%;\n }\n"])));
745
745
  var dualRingSpinnerAnimation = keyframes(templateObject_3$r || (templateObject_3$r = __makeTemplateObject(["\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n"], ["\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n"])));
746
746
  var progressBorderAnimation = keyframes(templateObject_4$l || (templateObject_4$l = __makeTemplateObject(["\n to {\n stroke-dashoffset: 0;\n }\n"], ["\n to {\n stroke-dashoffset: 0;\n }\n"])));
747
- var templateObject_1$J, templateObject_2$A, templateObject_3$r, templateObject_4$l;
747
+ var templateObject_1$K, templateObject_2$B, templateObject_3$r, templateObject_4$l;
748
748
 
749
- var Spinner = styled.div(templateObject_1$I || (templateObject_1$I = __makeTemplateObject(["\n display: inline-block;\n width: ", "px;\n height: ", "px;\n margin: auto;\n\n &:after {\n content: ' ';\n display: block;\n width: ", "px;\n height: ", "px;\n margin: 8px;\n border-radius: 50%;\n border: ", "px solid\n ", ";\n border-color: ", " transparent\n ", " transparent;\n animation: ", " 1.2s linear infinite;\n box-sizing: content-box;\n }\n"], ["\n display: inline-block;\n width: ", "px;\n height: ", "px;\n margin: auto;\n\n &:after {\n content: ' ';\n display: block;\n width: ", "px;\n height: ", "px;\n margin: 8px;\n border-radius: 50%;\n border: ", "px solid\n ", ";\n border-color: ", " transparent\n ", " transparent;\n animation: ", " 1.2s linear infinite;\n box-sizing: content-box;\n }\n"])), function (_a) {
749
+ var Spinner = styled.div(templateObject_1$J || (templateObject_1$J = __makeTemplateObject(["\n display: inline-block;\n width: ", "px;\n height: ", "px;\n margin: auto;\n\n &:after {\n content: ' ';\n display: block;\n width: ", "px;\n height: ", "px;\n margin: 8px;\n border-radius: 50%;\n border: ", "px solid\n ", ";\n border-color: ", " transparent\n ", " transparent;\n animation: ", " 1.2s linear infinite;\n box-sizing: content-box;\n }\n"], ["\n display: inline-block;\n width: ", "px;\n height: ", "px;\n margin: auto;\n\n &:after {\n content: ' ';\n display: block;\n width: ", "px;\n height: ", "px;\n margin: 8px;\n border-radius: 50%;\n border: ", "px solid\n ", ";\n border-color: ", " transparent\n ", " transparent;\n animation: ", " 1.2s linear infinite;\n box-sizing: content-box;\n }\n"])), function (_a) {
750
750
  var $size = _a.$size;
751
751
  return $size !== null && $size !== void 0 ? $size : 80;
752
752
  }, function (_a) {
@@ -771,7 +771,62 @@ var Spinner = styled.div(templateObject_1$I || (templateObject_1$I = __makeTempl
771
771
  var $color = _a.$color;
772
772
  return $color !== null && $color !== void 0 ? $color : '#888';
773
773
  }, dualRingSpinnerAnimation);
774
- var templateObject_1$I;
774
+ var templateObject_1$J;
775
+
776
+ var LogLevel;
777
+ (function (LogLevel) {
778
+ LogLevel[LogLevel["Off"] = 0] = "Off";
779
+ LogLevel[LogLevel["Error"] = 1] = "Error";
780
+ LogLevel[LogLevel["Warn"] = 2] = "Warn";
781
+ LogLevel[LogLevel["Info"] = 3] = "Info";
782
+ LogLevel[LogLevel["Debug"] = 4] = "Debug";
783
+ })(LogLevel || (LogLevel = {}));
784
+ var logLevel = LogLevel.Warn;
785
+ function useLogLevel(newLogLevel) {
786
+ useEffect(function () {
787
+ var oldLogLevel = logLevel;
788
+ if (newLogLevel === oldLogLevel) return;
789
+ logLevel = newLogLevel;
790
+ return function () {
791
+ logLevel = oldLogLevel;
792
+ };
793
+ }, [newLogLevel]);
794
+ }
795
+ function useDebugLogging(enabled) {
796
+ useLogLevel(enabled ? LogLevel.Debug : logLevel);
797
+ }
798
+ function debug() {
799
+ var parts = [];
800
+ for (var _i = 0; _i < arguments.length; _i++) {
801
+ parts[_i] = arguments[_i];
802
+ }
803
+ if (logLevel < LogLevel.Debug) return;
804
+ console.debug.apply(console, parts); // eslint-disable-line no-console
805
+ }
806
+ function log() {
807
+ var parts = [];
808
+ for (var _i = 0; _i < arguments.length; _i++) {
809
+ parts[_i] = arguments[_i];
810
+ }
811
+ if (logLevel < LogLevel.Info) return;
812
+ console.log.apply(console, parts); // eslint-disable-line no-console
813
+ }
814
+ function warn() {
815
+ var parts = [];
816
+ for (var _i = 0; _i < arguments.length; _i++) {
817
+ parts[_i] = arguments[_i];
818
+ }
819
+ if (logLevel < LogLevel.Warn) return;
820
+ console.warn.apply(console, parts); // eslint-disable-line no-console
821
+ }
822
+ function error() {
823
+ var parts = [];
824
+ for (var _i = 0; _i < arguments.length; _i++) {
825
+ parts[_i] = arguments[_i];
826
+ }
827
+ if (logLevel < LogLevel.Error) return;
828
+ console.error.apply(console, parts); // eslint-disable-line no-console
829
+ }
775
830
 
776
831
  var defaultAuthUrl = 'https://portal-api.idmission.com';
777
832
  var allowedAuthUrls = ['https://portal-api.idmission.com', 'https://portal-api-uat.idmission.com', 'https://portal-api-demo.idmission.com', 'https://portal-api-dev.idmission.com', 'http://localhost:10000'];
@@ -810,8 +865,95 @@ var reducer$4 = function reducer(state, action) {
810
865
  return state;
811
866
  }
812
867
  };
868
+ function makeValidateSessionRequest(authUrl_1, sessionId_1) {
869
+ return __awaiter(this, arguments, void 0, function (authUrl, sessionId, retryCount) {
870
+ var maxRetries, baseDelay, response, delay_1, error_1, delay_2;
871
+ if (retryCount === void 0) {
872
+ retryCount = 0;
873
+ }
874
+ return __generator(this, function (_a) {
875
+ switch (_a.label) {
876
+ case 0:
877
+ maxRetries = 10;
878
+ baseDelay = 1000 // 1 second
879
+ ;
880
+ _a.label = 1;
881
+ case 1:
882
+ _a.trys.push([1, 4,, 6]);
883
+ return [4 /*yield*/, fetch("".concat(authUrl, "/portal.sessions.v1.SessionsService/ValidateSession"), {
884
+ method: 'POST',
885
+ headers: {
886
+ 'Content-Type': 'application/json'
887
+ },
888
+ body: JSON.stringify({
889
+ id: sessionId
890
+ })
891
+ })
892
+ // If the request was successful or we've hit max retries, return the response
893
+ ];
894
+ case 2:
895
+ response = _a.sent();
896
+ // If the request was successful or we've hit max retries, return the response
897
+ if (response.ok || retryCount >= maxRetries) {
898
+ return [2 /*return*/, response];
899
+ }
900
+ delay_1 = baseDelay * Math.pow(2, retryCount) // Exponential backoff
901
+ ;
902
+ return [4 /*yield*/, new Promise(function (resolve) {
903
+ return setTimeout(resolve, delay_1);
904
+ })];
905
+ case 3:
906
+ _a.sent();
907
+ return [2 /*return*/, makeValidateSessionRequest(authUrl, sessionId, retryCount + 1)];
908
+ case 4:
909
+ error_1 = _a.sent();
910
+ // If we've hit max retries, throw the error
911
+ if (retryCount >= maxRetries) {
912
+ throw error_1;
913
+ }
914
+ delay_2 = baseDelay * Math.pow(2, retryCount);
915
+ return [4 /*yield*/, new Promise(function (resolve) {
916
+ return setTimeout(resolve, delay_2);
917
+ })];
918
+ case 5:
919
+ _a.sent();
920
+ return [2 /*return*/, makeValidateSessionRequest(authUrl, sessionId, retryCount + 1)];
921
+ case 6:
922
+ return [2 /*return*/];
923
+ }
924
+ });
925
+ });
926
+ }
927
+ function validateSession(authUrl, sessionId) {
928
+ return __awaiter(this, void 0, void 0, function () {
929
+ var resp, respText, message, valid, respJson;
930
+ return __generator(this, function (_a) {
931
+ switch (_a.label) {
932
+ case 0:
933
+ return [4 /*yield*/, makeValidateSessionRequest(authUrl, sessionId)];
934
+ case 1:
935
+ resp = _a.sent();
936
+ return [4 /*yield*/, resp.text()];
937
+ case 2:
938
+ respText = _a.sent();
939
+ message = respText;
940
+ valid = false;
941
+ try {
942
+ respJson = JSON.parse(respText);
943
+ message = respJson.message;
944
+ valid = respJson.valid;
945
+ } catch (e) {
946
+ warn('Failed to parse session validation response', e);
947
+ }
948
+ if (!resp.ok) {
949
+ throw new SessionValidationFailedError(new Error(message), authUrl);
950
+ }
951
+ return [2 /*return*/, valid];
952
+ }
953
+ });
954
+ });
955
+ }
813
956
  function useAuthReducer(authUrl, sessionId) {
814
- var _this = this;
815
957
  if (authUrl === void 0) {
816
958
  authUrl = defaultAuthUrl;
817
959
  }
@@ -857,51 +999,17 @@ function useAuthReducer(authUrl, sessionId) {
857
999
  type: 'setCheckState',
858
1000
  payload: 'RUNNING'
859
1001
  });
860
- (function () {
861
- return __awaiter(_this, void 0, void 0, function () {
862
- var resp, _a, valid, message, e_1;
863
- return __generator(this, function (_b) {
864
- switch (_b.label) {
865
- case 0:
866
- _b.trys.push([0, 3,, 4]);
867
- return [4 /*yield*/, fetch("".concat(authUrl, "/portal.sessions.v1.SessionsService/ValidateSession"), {
868
- method: 'POST',
869
- headers: {
870
- 'Content-Type': 'application/json'
871
- },
872
- body: JSON.stringify({
873
- id: resolvedSessionId
874
- })
875
- })];
876
- case 1:
877
- resp = _b.sent();
878
- return [4 /*yield*/, resp.json()];
879
- case 2:
880
- _a = _b.sent(), valid = _a.valid, message = _a.message;
881
- if (!resp.ok) {
882
- dispatch({
883
- type: 'setError',
884
- payload: new SessionValidationFailedError(new Error(message), authUrl)
885
- });
886
- }
887
- dispatch({
888
- type: 'setCheckState',
889
- payload: valid ? 'PASSED' : 'FAILED'
890
- });
891
- return [3 /*break*/, 4];
892
- case 3:
893
- e_1 = _b.sent();
894
- dispatch({
895
- type: 'setError',
896
- payload: new SessionValidationFailedError(e_1, authUrl)
897
- });
898
- return [3 /*break*/, 4];
899
- case 4:
900
- return [2 /*return*/];
901
- }
902
- });
1002
+ validateSession(authUrl, resolvedSessionId).then(function (valid) {
1003
+ dispatch({
1004
+ type: 'setCheckState',
1005
+ payload: valid ? 'PASSED' : 'FAILED'
1006
+ });
1007
+ })["catch"](function (e) {
1008
+ dispatch({
1009
+ type: 'setError',
1010
+ payload: new SessionValidationFailedError(e, authUrl)
903
1011
  });
904
- })();
1012
+ });
905
1013
  }
906
1014
  }, [authUrl, sessionCheckState, resolvedSessionId, sessionId]);
907
1015
  return [state, dispatch];
@@ -952,61 +1060,6 @@ function AuthProvider(_a) {
952
1060
  }, children));
953
1061
  }
954
1062
 
955
- var LogLevel;
956
- (function (LogLevel) {
957
- LogLevel[LogLevel["Off"] = 0] = "Off";
958
- LogLevel[LogLevel["Error"] = 1] = "Error";
959
- LogLevel[LogLevel["Warn"] = 2] = "Warn";
960
- LogLevel[LogLevel["Info"] = 3] = "Info";
961
- LogLevel[LogLevel["Debug"] = 4] = "Debug";
962
- })(LogLevel || (LogLevel = {}));
963
- var logLevel = LogLevel.Warn;
964
- function useLogLevel(newLogLevel) {
965
- useEffect(function () {
966
- var oldLogLevel = logLevel;
967
- if (newLogLevel === oldLogLevel) return;
968
- logLevel = newLogLevel;
969
- return function () {
970
- logLevel = oldLogLevel;
971
- };
972
- }, [newLogLevel]);
973
- }
974
- function useDebugLogging(enabled) {
975
- useLogLevel(enabled ? LogLevel.Debug : logLevel);
976
- }
977
- function debug() {
978
- var parts = [];
979
- for (var _i = 0; _i < arguments.length; _i++) {
980
- parts[_i] = arguments[_i];
981
- }
982
- if (logLevel < LogLevel.Debug) return;
983
- console.debug.apply(console, parts); // eslint-disable-line no-console
984
- }
985
- function log() {
986
- var parts = [];
987
- for (var _i = 0; _i < arguments.length; _i++) {
988
- parts[_i] = arguments[_i];
989
- }
990
- if (logLevel < LogLevel.Info) return;
991
- console.log.apply(console, parts); // eslint-disable-line no-console
992
- }
993
- function warn() {
994
- var parts = [];
995
- for (var _i = 0; _i < arguments.length; _i++) {
996
- parts[_i] = arguments[_i];
997
- }
998
- if (logLevel < LogLevel.Warn) return;
999
- console.warn.apply(console, parts); // eslint-disable-line no-console
1000
- }
1001
- function error() {
1002
- var parts = [];
1003
- for (var _i = 0; _i < arguments.length; _i++) {
1004
- parts[_i] = arguments[_i];
1005
- }
1006
- if (logLevel < LogLevel.Error) return;
1007
- console.error.apply(console, parts); // eslint-disable-line no-console
1008
- }
1009
-
1010
1063
  var defaultSubmissionUrl = 'https://portal-api.idmission.com/swagger';
1011
1064
  function setDefaultSubmissionUrl(url) {
1012
1065
  defaultSubmissionUrl = url;
@@ -2061,7 +2114,7 @@ function getFrameDimensions(frame) {
2061
2114
  return [frameWidth, frameHeight];
2062
2115
  }
2063
2116
 
2064
- var InvisibleCanvas = styled.canvas(templateObject_1$H || (templateObject_1$H = __makeTemplateObject(["\n display: none;\n"], ["\n display: none;\n"])));
2117
+ var InvisibleCanvas = styled.canvas(templateObject_1$I || (templateObject_1$I = __makeTemplateObject(["\n display: none;\n"], ["\n display: none;\n"])));
2065
2118
  function drawToCanvas(canvas, frame, width, height) {
2066
2119
  if (!canvas) return;
2067
2120
  var ctx = canvas.getContext('2d');
@@ -2081,7 +2134,7 @@ function clearCanvas(canvas) {
2081
2134
  var _a;
2082
2135
  (_a = canvas === null || canvas === void 0 ? void 0 : canvas.getContext('2d')) === null || _a === void 0 ? void 0 : _a.clearRect(0, 0, canvas === null || canvas === void 0 ? void 0 : canvas.width, canvas === null || canvas === void 0 ? void 0 : canvas.height);
2083
2136
  }
2084
- var templateObject_1$H;
2137
+ var templateObject_1$I;
2085
2138
 
2086
2139
  function cropToShoulders(rawCanvas, cropCanvas, resizeCanvas, frame, face, quality, maxHeight) {
2087
2140
  if (quality === void 0) {
@@ -3504,1568 +3557,6 @@ function releaseCameraAccess() {
3504
3557
  currentCamera = undefined;
3505
3558
  }
3506
3559
 
3507
- var initialState$5 = {
3508
- videoRef: {
3509
- current: null
3510
- },
3511
- videoLoaded: false,
3512
- videoStream: null,
3513
- videoDevice: null,
3514
- isRearFacing: false,
3515
- camera: null,
3516
- cameraReady: false,
3517
- cameraAccessDenied: false,
3518
- iphoneContinuityCameraAvailable: false,
3519
- iphoneContinuityCameraDenied: false,
3520
- preferIphoneContinuityCamera: true,
3521
- audioStream: null,
3522
- microphoneReady: false,
3523
- microphoneAccessDenied: false
3524
- };
3525
- var createCameraStore = function createCameraStore(config) {
3526
- var store = createStore(function (set, get) {
3527
- return _assign(_assign(_assign({}, initialState$5), config), {
3528
- reset: function reset() {
3529
- return set(_assign(_assign({}, initialState$5), config));
3530
- },
3531
- setConfig: function setConfig(config) {
3532
- return set(config);
3533
- },
3534
- onVideoMounted: function onVideoMounted(e) {
3535
- var _a;
3536
- var selectedVideoStreamId = (_a = get().videoStream) === null || _a === void 0 ? void 0 : _a.id;
3537
- if (!selectedVideoStreamId) return;
3538
- var srcObject = e.currentTarget.srcObject;
3539
- if (srcObject.id !== selectedVideoStreamId) {
3540
- warn('camera tampering detected, reloading the page.');
3541
- window.location.reload();
3542
- return;
3543
- }
3544
- set({
3545
- videoLoaded: true
3546
- });
3547
- },
3548
- setIphoneContinuityCameraAllowed: function setIphoneContinuityCameraAllowed(value) {
3549
- return set({
3550
- preferIphoneContinuityCamera: value
3551
- });
3552
- },
3553
- requestCameraAccess: function requestCameraAccess() {
3554
- return __awaiter(this, void 0, void 0, function () {
3555
- var _a, videoRef, releaseCameraAccess, preferFrontFacingCamera, preferIphoneContinuityCamera, iphoneContinuityCameraDenied, availableCameras, selectedCamera, platform_1, iphoneContinuityCamera, constraints, stream_1, e_1, e_2, handleStreamEnded_1, videoTrack_1, camera_1, e_3;
3556
- var _b, _c, _d;
3557
- return __generator(this, function (_e) {
3558
- switch (_e.label) {
3559
- case 0:
3560
- _a = get(), videoRef = _a.videoRef, releaseCameraAccess = _a.releaseCameraAccess, preferFrontFacingCamera = _a.preferFrontFacingCamera, preferIphoneContinuityCamera = _a.preferIphoneContinuityCamera, iphoneContinuityCameraDenied = _a.iphoneContinuityCameraDenied;
3561
- releaseCameraAccess();
3562
- _e.label = 1;
3563
- case 1:
3564
- _e.trys.push([1, 11,, 12]);
3565
- return [4 /*yield*/, listAvailableCameras()];
3566
- case 2:
3567
- availableCameras = _e.sent();
3568
- selectedCamera = void 0;
3569
- debug('availableCameras', availableCameras);
3570
- platform_1 = getPlatform();
3571
- debug('platformDetails', platform_1);
3572
- if (!iphoneContinuityCameraDenied && (!(platform_1 === null || platform_1 === void 0 ? void 0 : platform_1.os) || platform_1.os.family === 'OS X')) {
3573
- iphoneContinuityCamera = availableCameras.find(function (deviceInfo) {
3574
- return cameraLabelMatches(deviceInfo, 'iphone');
3575
- });
3576
- set({
3577
- iphoneContinuityCameraAvailable: !!iphoneContinuityCamera
3578
- });
3579
- if (iphoneContinuityCamera && preferIphoneContinuityCamera) {
3580
- selectedCamera = iphoneContinuityCamera;
3581
- }
3582
- } else if (((_b = platform_1 === null || platform_1 === void 0 ? void 0 : platform_1.os) === null || _b === void 0 ? void 0 : _b.family) === 'Android' || availableCameras.every(function (c) {
3583
- return c.label.startsWith('camera2 ');
3584
- })) {
3585
- availableCameras = availableCameras.sort(function (a, b) {
3586
- return a.label.toLowerCase().localeCompare(b.label.toLowerCase());
3587
- });
3588
- debug('cameras have been sorted', availableCameras);
3589
- }
3590
- if (preferFrontFacingCamera) {
3591
- selectedCamera = availableCameras.find(function (deviceInfo) {
3592
- return cameraLabelMatches(deviceInfo, frontCameraLabels);
3593
- });
3594
- }
3595
- selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
3596
- return cameraLabelMatches(deviceInfo, 'backtriplecamera');
3597
- }));
3598
- selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
3599
- return cameraLabelMatches(deviceInfo, 'backdualcamera');
3600
- }));
3601
- selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
3602
- return cameraLabelMatches(deviceInfo, rearCameraLabels) && !cameraLabelMatches(deviceInfo, backUltraWideCameraLabels);
3603
- }));
3604
- selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
3605
- return cameraLabelMatches(deviceInfo, rearCameraLabels);
3606
- }));
3607
- // on iOS, the front facing camera always is at the first position in the list, so we skip it if all else fails.
3608
- if (!preferFrontFacingCamera && ((_c = platform_1 === null || platform_1 === void 0 ? void 0 : platform_1.os) === null || _c === void 0 ? void 0 : _c.family) === 'iOS' && availableCameras.length > 0) {
3609
- selectedCamera || (selectedCamera = availableCameras[1]);
3610
- }
3611
- selectedCamera || (selectedCamera = availableCameras[0]);
3612
- debug('selectedCamera', selectedCamera);
3613
- set({
3614
- videoDevice: selectedCamera
3615
- });
3616
- constraints = {
3617
- audio: false,
3618
- video: {
3619
- deviceId: {
3620
- exact: selectedCamera.deviceId
3621
- },
3622
- width: {
3623
- ideal: config.maxVideoWidth
3624
- },
3625
- aspectRatio: 1.777777778,
3626
- frameRate: {}
3627
- }
3628
- };
3629
- if (config.maxFps) {
3630
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3631
- // @ts-ignore
3632
- constraints.video.frameRate = {
3633
- max: config.maxFps
3634
- };
3635
- }
3636
- stream_1 = null;
3637
- _e.label = 3;
3638
- case 3:
3639
- _e.trys.push([3, 5,, 6]);
3640
- debug('obtaining camera access with constraints', constraints);
3641
- return [4 /*yield*/, navigator.mediaDevices.getUserMedia(constraints)];
3642
- case 4:
3643
- stream_1 = _e.sent();
3644
- return [3 /*break*/, 6];
3645
- case 5:
3646
- e_1 = _e.sent();
3647
- if (e_1.name === 'NotAllowedError') {
3648
- if (preferIphoneContinuityCamera) {
3649
- set({
3650
- iphoneContinuityCameraAvailable: false,
3651
- iphoneContinuityCameraDenied: true
3652
- });
3653
- } else {
3654
- set({
3655
- cameraAccessDenied: true
3656
- });
3657
- }
3658
- return [2 /*return*/];
3659
- }
3660
- return [3 /*break*/, 6];
3661
- case 6:
3662
- if (!!stream_1) return [3 /*break*/, 10];
3663
- _e.label = 7;
3664
- case 7:
3665
- _e.trys.push([7, 9,, 10]);
3666
- return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
3667
- audio: false,
3668
- video: true
3669
- })];
3670
- case 8:
3671
- stream_1 = _e.sent();
3672
- debug('opened stream with no width and height constraints');
3673
- return [3 /*break*/, 10];
3674
- case 9:
3675
- e_2 = _e.sent();
3676
- debug('cannot open stream at all', e_2);
3677
- return [3 /*break*/, 10];
3678
- case 10:
3679
- if (!stream_1) {
3680
- error('failed to open camera');
3681
- throw new Error('failed to open camera: ');
3682
- }
3683
- debug('camera access granted with constraints', constraints);
3684
- handleStreamEnded_1 = function handleStreamEnded_1() {
3685
- if (preferIphoneContinuityCamera && get().iphoneContinuityCameraAvailable) {
3686
- debug('someone unplugged the continuity camera');
3687
- set({
3688
- videoStream: null,
3689
- videoDevice: null,
3690
- cameraReady: false,
3691
- iphoneContinuityCameraAvailable: false,
3692
- iphoneContinuityCameraDenied: true
3693
- });
3694
- get().requestCameraAccess();
3695
- } else {
3696
- debug('someone unplugged the webcam');
3697
- releaseCameraAccess();
3698
- set({
3699
- videoStream: null,
3700
- videoDevice: null,
3701
- videoLoaded: false,
3702
- cameraReady: false,
3703
- cameraAccessDenied: true
3704
- });
3705
- }
3706
- };
3707
- (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.addEventListener('ended', handleStreamEnded_1);
3708
- videoTrack_1 = stream_1.getVideoTracks()[0];
3709
- videoTrack_1.onended = handleStreamEnded_1;
3710
- camera_1 = obtainCameraAccess(stream_1, selectedCamera.label, videoRef.current);
3711
- setTimeout(function () {
3712
- // iOS 17 has a strange behavior where the video track flickers between muted and unmuted
3713
- // when the camera access is being requested. This delay is a workaround for that.
3714
- videoTrack_1.onmute = function () {
3715
- if (videoTrack_1.readyState !== 'live') handleStreamEnded_1();
3716
- };
3717
- set({
3718
- camera: camera_1,
3719
- cameraReady: true,
3720
- cameraAccessDenied: false,
3721
- isRearFacing: camera_1.isRearFacing,
3722
- videoStream: stream_1
3723
- });
3724
- }, 500);
3725
- return [3 /*break*/, 12];
3726
- case 11:
3727
- e_3 = _e.sent();
3728
- if (e_3.name === 'NotAllowedError') {
3729
- error('camera access has been blocked by the user', e_3);
3730
- set({
3731
- cameraAccessDenied: true
3732
- });
3733
- } else {
3734
- error('camera access encountered some other error', e_3);
3735
- throw e_3;
3736
- }
3737
- return [3 /*break*/, 12];
3738
- case 12:
3739
- return [2 /*return*/];
3740
- }
3741
- });
3742
- });
3743
- },
3744
- releaseCameraAccess: function releaseCameraAccess() {
3745
- return __awaiter(this, void 0, void 0, function () {
3746
- var camera;
3747
- return __generator(this, function (_a) {
3748
- camera = get().camera;
3749
- if (!camera) return [2 /*return*/];
3750
- camera.release();
3751
- set({
3752
- camera: null,
3753
- cameraReady: false,
3754
- cameraAccessDenied: false,
3755
- videoDevice: null,
3756
- videoStream: null,
3757
- videoLoaded: false
3758
- });
3759
- return [2 /*return*/];
3760
- });
3761
- });
3762
- },
3763
- requestMicrophoneAccess: function requestMicrophoneAccess() {
3764
- return __awaiter(this, void 0, void 0, function () {
3765
- var stream_2, e_4;
3766
- return __generator(this, function (_a) {
3767
- switch (_a.label) {
3768
- case 0:
3769
- get().releaseMicrophoneAccess();
3770
- _a.label = 1;
3771
- case 1:
3772
- _a.trys.push([1, 3,, 4]);
3773
- return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
3774
- audio: true,
3775
- video: false
3776
- })
3777
- // iOS 17 has a strange behavior where the video track flickers between muted and unmuted
3778
- // when the camera access is being requested. This delay is a workaround for that.
3779
- ];
3780
- case 2:
3781
- stream_2 = _a.sent();
3782
- // iOS 17 has a strange behavior where the video track flickers between muted and unmuted
3783
- // when the camera access is being requested. This delay is a workaround for that.
3784
- setTimeout(function () {
3785
- set({
3786
- audioStream: stream_2,
3787
- microphoneReady: true,
3788
- microphoneAccessDenied: false
3789
- });
3790
- var handleStreamEnded = function handleStreamEnded() {
3791
- set({
3792
- microphoneReady: false,
3793
- microphoneAccessDenied: true
3794
- });
3795
- };
3796
- var track = stream_2.getAudioTracks()[0];
3797
- track.onended = handleStreamEnded;
3798
- track.onmute = function () {
3799
- if (track.readyState !== 'live') handleStreamEnded();
3800
- };
3801
- }, 500);
3802
- return [3 /*break*/, 4];
3803
- case 3:
3804
- e_4 = _a.sent();
3805
- debug('failed to open microphone', e_4);
3806
- set({
3807
- microphoneAccessDenied: true
3808
- });
3809
- return [3 /*break*/, 4];
3810
- case 4:
3811
- return [2 /*return*/];
3812
- }
3813
- });
3814
- });
3815
- },
3816
- releaseMicrophoneAccess: function releaseMicrophoneAccess() {
3817
- var _a;
3818
- var audioStream = get().audioStream;
3819
- (_a = audioStream === null || audioStream === void 0 ? void 0 : audioStream.stop) === null || _a === void 0 ? void 0 : _a.call(audioStream);
3820
- audioStream === null || audioStream === void 0 ? void 0 : audioStream.getAudioTracks().forEach(function (track) {
3821
- var _a;
3822
- (_a = track.stop) === null || _a === void 0 ? void 0 : _a.call(track);
3823
- });
3824
- set({
3825
- audioStream: null,
3826
- microphoneReady: false,
3827
- microphoneAccessDenied: false
3828
- });
3829
- }
3830
- });
3831
- });
3832
- if (config.requestAccessAutomatically) {
3833
- void store.getState().requestCameraAccess();
3834
- }
3835
- return _assign(_assign({}, store), {
3836
- destroy: function destroy() {
3837
- store.getState().releaseCameraAccess();
3838
- store.getState().releaseMicrophoneAccess();
3839
- }
3840
- });
3841
- };
3842
- var CameraStoreContext = /*#__PURE__*/createContext(undefined);
3843
- function CameraStoreProvider(_a) {
3844
- var children = _a.children,
3845
- _b = _a.requestAccessAutomatically,
3846
- requestAccessAutomatically = _b === void 0 ? true : _b,
3847
- _c = _a.preferIphoneContinuityCamera,
3848
- preferIphoneContinuityCamera = _c === void 0 ? true : _c,
3849
- _d = _a.preferFrontFacingCamera,
3850
- preferFrontFacingCamera = _d === void 0 ? false : _d,
3851
- _e = _a.maxVideoWidth,
3852
- maxVideoWidth = _e === void 0 ? 1920 : _e,
3853
- maxFps = _a.maxFps,
3854
- onCameraAccessDenied = _a.onCameraAccessDenied,
3855
- onMicrophoneAccessDenied = _a.onMicrophoneAccessDenied,
3856
- _f = _a.requireMicrophoneAccess,
3857
- requireMicrophoneAccess = _f === void 0 ? false : _f;
3858
- var videoRef = useRef(null);
3859
- var store = useRef();
3860
- store.current || (store.current = createCameraStore({
3861
- videoRef: videoRef,
3862
- requestAccessAutomatically: requestAccessAutomatically,
3863
- preferIphoneContinuityCamera: preferIphoneContinuityCamera,
3864
- preferFrontFacingCamera: preferFrontFacingCamera,
3865
- maxVideoWidth: maxVideoWidth,
3866
- maxFps: maxFps,
3867
- onCameraAccessDenied: onCameraAccessDenied,
3868
- onMicrophoneAccessDenied: onMicrophoneAccessDenied,
3869
- requireMicrophoneAccess: requireMicrophoneAccess
3870
- }));
3871
- useEffect(function () {
3872
- var _a, _b, _c;
3873
- var state = (_a = store.current) === null || _a === void 0 ? void 0 : _a.getState();
3874
- if (!state) return;
3875
- if (preferIphoneContinuityCamera !== (state === null || state === void 0 ? void 0 : state.preferIphoneContinuityCamera) || preferFrontFacingCamera !== (state === null || state === void 0 ? void 0 : state.preferFrontFacingCamera)) {
3876
- (_b = store.current) === null || _b === void 0 ? void 0 : _b.setState({
3877
- preferIphoneContinuityCamera: preferIphoneContinuityCamera,
3878
- preferFrontFacingCamera: preferFrontFacingCamera
3879
- });
3880
- (_c = store.current) === null || _c === void 0 ? void 0 : _c.getState().requestCameraAccess();
3881
- }
3882
- }, [preferFrontFacingCamera, preferIphoneContinuityCamera]);
3883
- useEffect(function () {
3884
- var _a;
3885
- if (requireMicrophoneAccess) {
3886
- (_a = store.current) === null || _a === void 0 ? void 0 : _a.getState().requestMicrophoneAccess();
3887
- }
3888
- }, [requireMicrophoneAccess]);
3889
- useEffect(function () {
3890
- return function () {
3891
- var _a;
3892
- return (_a = store.current) === null || _a === void 0 ? void 0 : _a.destroy();
3893
- };
3894
- }, []);
3895
- return /*#__PURE__*/React__default.createElement(CameraStoreContext.Provider, {
3896
- value: store.current
3897
- }, children);
3898
- }
3899
- function useCameraStore(selector) {
3900
- var store = useContext(CameraStoreContext);
3901
- if (!store) throw new Error('useCameraStore cannot be used without Provider');
3902
- return useStore(store, selector);
3903
- }
3904
-
3905
- var DocumentDetectionModelContext = /*#__PURE__*/createContext({
3906
- startDocumentDetection: function startDocumentDetection() {
3907
- return null;
3908
- },
3909
- stopDocumentDetection: function stopDocumentDetection() {
3910
- return null;
3911
- },
3912
- loadDocumentDetectionModel: function loadDocumentDetectionModel() {
3913
- return null;
3914
- },
3915
- documentDetectionModelReady: false,
3916
- documentDetectionModelDownloadProgress: 0,
3917
- documentDetectionModelError: null,
3918
- onDocumentDetected: function onDocumentDetected() {
3919
- return null;
3920
- },
3921
- detectionTime: 0,
3922
- documentDetectionThresholds: {},
3923
- setDocumentDetectionThresholds: function setDocumentDetectionThresholds() {
3924
- return null;
3925
- },
3926
- documentDetectionBoundaries: defaultDocumentDetectionBoundaries,
3927
- setDocumentDetectionBoundaries: function setDocumentDetectionBoundaries() {
3928
- return null;
3929
- },
3930
- documentDetectionLastPredictionCanvas: {
3931
- current: null
3932
- },
3933
- clearDocumentDetectionLastPredictionCanvas: function clearDocumentDetectionLastPredictionCanvas() {
3934
- return null;
3935
- }
3936
- });
3937
- function DocumentDetectionModelProvider(_a) {
3938
- var _this = this;
3939
- var _b = _a.autoStart,
3940
- autoStart = _b === void 0 ? true : _b,
3941
- children = _a.children,
3942
- _c = _a.throttleMs,
3943
- throttleMs = _c === void 0 ? 16 : _c,
3944
- _d = _a.delayAfterStartMs,
3945
- delayAfterStartMs = _d === void 0 ? 0 : _d,
3946
- _e = _a.documentDetectionModelPath,
3947
- documentDetectionModelPath = _e === void 0 ? defaultDocumentDetectorModelPath : _e,
3948
- _f = _a.documentDetectionModelScoreThreshold,
3949
- documentDetectionModelScoreThreshold = _f === void 0 ? defaultDocumentDetectionScoreThreshold : _f,
3950
- _g = _a.documentDetectionModelLoadTimeoutMs,
3951
- documentDetectionModelLoadTimeoutMs = _g === void 0 ? defaultDocumentDetectionModelLoadTimeoutMs : _g,
3952
- onDocumentDetectionModelError = _a.onDocumentDetectionModelError,
3953
- _h = _a.shouldLoadModels,
3954
- shouldLoadModelsProp = _h === void 0 ? true : _h;
3955
- var _j = useCameraStore(),
3956
- videoRef = _j.videoRef,
3957
- videoLoaded = _j.videoLoaded,
3958
- cameraReady = _j.cameraReady;
3959
- var lastPredictionCanvas = useRef(null);
3960
- var onPredictionHandler = useRef();
3961
- var _k = useState({}),
3962
- documentDetectionThresholds = _k[0],
3963
- setDocumentDetectionThresholds = _k[1];
3964
- var _l = useState(defaultDocumentDetectionBoundaries),
3965
- documentDetectionBoundaries = _l[0],
3966
- setDocumentDetectionBoundaries = _l[1];
3967
- var _m = useState(0),
3968
- timesAllZero = _m[0],
3969
- setTimesAllZero = _m[1];
3970
- var _o = useState(0),
3971
- canvasKey = _o[0],
3972
- setCanvasKey = _o[1];
3973
- var stopDetection = useRef(0);
3974
- var _p = useState(shouldLoadModelsProp),
3975
- shouldLoadModels = _p[0],
3976
- setShouldLoadModels = _p[1];
3977
- var load = useCallback(function () {
3978
- return setShouldLoadModels(true);
3979
- }, []);
3980
- var _q = useLoadDocumentDetector({
3981
- modelPath: documentDetectionModelPath,
3982
- modelLoadTimeoutMs: documentDetectionModelLoadTimeoutMs,
3983
- scoreThreshold: documentDetectionModelScoreThreshold,
3984
- onModelError: onDocumentDetectionModelError,
3985
- videoRef: videoRef,
3986
- shouldLoadModels: shouldLoadModels
3987
- }),
3988
- ready = _q.ready,
3989
- modelDownloadProgress = _q.modelDownloadProgress,
3990
- modelError = _q.modelError,
3991
- setModelError = _q.setModelError;
3992
- var _r = useFrameLoop(useCallback(function (frameId, timeRunning) {
3993
- return __awaiter(_this, void 0, void 0, function () {
3994
- var stopDetectionAtStart, vw, vh, ctx, prediction, processedPrediction;
3995
- var _a;
3996
- return __generator(this, function (_b) {
3997
- switch (_b.label) {
3998
- case 0:
3999
- if (!videoLoaded || !cameraReady || !ready || !videoRef.current || !lastPredictionCanvas.current) return [2 /*return*/];
4000
- stopDetectionAtStart = stopDetection.current;
4001
- vw = videoRef.current.videoWidth;
4002
- vh = videoRef.current.videoHeight;
4003
- lastPredictionCanvas.current.width = vw;
4004
- lastPredictionCanvas.current.height = vh;
4005
- ctx = lastPredictionCanvas.current.getContext('2d');
4006
- if (!(ctx && videoRef.current.readyState === 4)) return [3 /*break*/, 3];
4007
- if (stopDetectionAtStart !== stopDetection.current) return [2 /*return*/];
4008
- ctx.drawImage(videoRef.current, 0, 0, vw, vh);
4009
- return [4 /*yield*/, makeDocumentDetectorPrediction(lastPredictionCanvas.current)];
4010
- case 1:
4011
- prediction = _b.sent();
4012
- if (!prediction) return [3 /*break*/, 3];
4013
- processedPrediction = processDocumentDetectorPrediction(prediction, documentDetectionThresholds, documentDetectionBoundaries);
4014
- processedPrediction.frameId = frameId;
4015
- setLastDetectionAt(new Date().getTime());
4016
- debug(processedPrediction);
4017
- if (processedPrediction.allZero) setTimesAllZero(function (n) {
4018
- return n + 1;
4019
- });
4020
- if (stopDetectionAtStart !== stopDetection.current) return [2 /*return*/];
4021
- if (timeRunning < delayAfterStartMs) return [2 /*return*/];
4022
- return [4 /*yield*/, (_a = onPredictionHandler.current) === null || _a === void 0 ? void 0 : _a.call(onPredictionHandler, processedPrediction)];
4023
- case 2:
4024
- _b.sent();
4025
- _b.label = 3;
4026
- case 3:
4027
- return [2 /*return*/];
4028
- }
4029
- });
4030
- });
4031
- }, [cameraReady, delayAfterStartMs, documentDetectionBoundaries, documentDetectionThresholds, ready, videoLoaded, videoRef]), {
4032
- throttleMs: throttleMs,
4033
- autoStart: autoStart
4034
- }),
4035
- start = _r.start,
4036
- stop = _r.stop;
4037
- useEffect(function setErrorIfAllZero() {
4038
- if (timesAllZero >= 2) {
4039
- setModelError(new Error('model is returning all zeroes'));
4040
- }
4041
- }, [setModelError, timesAllZero]);
4042
- var onDocumentDetected = useCallback(function (handler) {
4043
- onPredictionHandler.current = handler;
4044
- }, []);
4045
- var clearDocumentDetectionLastPredictionCanvas = useCallback(function () {
4046
- stopDetection.current += 1;
4047
- setCanvasKey(function (n) {
4048
- return n + 1;
4049
- });
4050
- }, []);
4051
- var value = useMemo(function () {
4052
- return {
4053
- startDocumentDetection: start,
4054
- stopDocumentDetection: stop,
4055
- loadDocumentDetectionModel: load,
4056
- documentDetectionModelReady: ready,
4057
- documentDetectionModelError: modelError,
4058
- documentDetectionModelDownloadProgress: modelDownloadProgress,
4059
- onDocumentDetected: onDocumentDetected,
4060
- detectionTime: lastDetectionTime,
4061
- documentDetectionThresholds: documentDetectionThresholds,
4062
- setDocumentDetectionThresholds: setDocumentDetectionThresholds,
4063
- documentDetectionBoundaries: documentDetectionBoundaries,
4064
- setDocumentDetectionBoundaries: setDocumentDetectionBoundaries,
4065
- documentDetectionLastPredictionCanvas: lastPredictionCanvas,
4066
- clearDocumentDetectionLastPredictionCanvas: clearDocumentDetectionLastPredictionCanvas
4067
- };
4068
- }, [start, stop, load, ready, modelError, modelDownloadProgress, onDocumentDetected, documentDetectionThresholds, documentDetectionBoundaries, clearDocumentDetectionLastPredictionCanvas]);
4069
- return /*#__PURE__*/React.createElement(DocumentDetectionModelContext.Provider, {
4070
- value: value
4071
- }, /*#__PURE__*/React.createElement(InvisibleCanvas, {
4072
- key: canvasKey,
4073
- ref: lastPredictionCanvas
4074
- }), children);
4075
- }
4076
-
4077
- var FocusModelContext = /*#__PURE__*/createContext({
4078
- loadFocusModel: function loadFocusModel() {
4079
- return null;
4080
- },
4081
- focusModelReady: false,
4082
- focusModelDownloadProgress: 0,
4083
- focusModelError: null,
4084
- focusThresholds: {},
4085
- setFocusThresholds: function setFocusThresholds() {
4086
- return null;
4087
- },
4088
- makeFocusPrediction: function makeFocusPrediction() {
4089
- return null;
4090
- },
4091
- focusPredictionTime: 0
4092
- });
4093
- function FocusModelProvider(_a) {
4094
- var children = _a.children,
4095
- _b = _a.focusModelPath,
4096
- focusModelPath = _b === void 0 ? defaultFocusModelPath : _b,
4097
- _c = _a.focusModelLoadTimeoutMs,
4098
- focusModelLoadTimeoutMs = _c === void 0 ? defaultFocusModelLoadTimeoutMs : _c,
4099
- onFocusModelError = _a.onFocusModelError,
4100
- _d = _a.showCanvases,
4101
- showCanvases = _d === void 0 ? false : _d,
4102
- _e = _a.shouldLoadModels,
4103
- shouldLoadModelsProp = _e === void 0 ? true : _e;
4104
- var cropCanvas = useRef(null);
4105
- var rotateCanvas = useRef(null);
4106
- var _f = useState({}),
4107
- focusThresholds = _f[0],
4108
- setFocusThresholds = _f[1];
4109
- var videoRef = useCameraStore().videoRef;
4110
- var _g = useState(shouldLoadModelsProp),
4111
- shouldLoadModels = _g[0],
4112
- setShouldLoadModels = _g[1];
4113
- var load = useCallback(function () {
4114
- return setShouldLoadModels(true);
4115
- }, []);
4116
- var _h = useLoadFocusModel({
4117
- modelPath: focusModelPath,
4118
- modelLoadTimeoutMs: focusModelLoadTimeoutMs,
4119
- onModelError: onFocusModelError,
4120
- videoRef: videoRef,
4121
- shouldLoadModels: shouldLoadModels
4122
- }),
4123
- ready = _h.ready,
4124
- modelDownloadProgress = _h.modelDownloadProgress,
4125
- modelError = _h.modelError;
4126
- var makeFocusPrediction = useCallback(function (imageData, box) {
4127
- if (!ready) return null;
4128
- var prediction = makeFocusModelPrediction(imageData, cropCanvas.current, rotateCanvas.current, box);
4129
- if (!prediction) return null;
4130
- setLastFocusPredictionAt(prediction.predictionTime);
4131
- return prediction;
4132
- }, [ready]);
4133
- var value = useMemo(function () {
4134
- return {
4135
- loadFocusModel: load,
4136
- focusModelReady: ready,
4137
- focusModelDownloadProgress: modelDownloadProgress,
4138
- focusModelError: modelError,
4139
- makeFocusPrediction: makeFocusPrediction,
4140
- focusPredictionTime: lastFocusPredictionTime,
4141
- focusThresholds: focusThresholds,
4142
- setFocusThresholds: setFocusThresholds
4143
- };
4144
- }, [focusThresholds, load, makeFocusPrediction, modelDownloadProgress, modelError, ready]);
4145
- return /*#__PURE__*/React__default.createElement(FocusModelContext.Provider, {
4146
- value: value
4147
- }, /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
4148
- ref: rotateCanvas,
4149
- style: showCanvases ? {
4150
- display: 'block'
4151
- } : undefined
4152
- }), /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
4153
- ref: cropCanvas,
4154
- style: showCanvases ? {
4155
- display: 'block'
4156
- } : undefined
4157
- }), children);
4158
- }
4159
-
4160
- function _isNavigatorDefined() {
4161
- return typeof navigator !== 'undefined' && navigator != null;
4162
- }
4163
- var isMobileCache;
4164
- function isMobile() {
4165
- if (isMobileCache !== undefined) return isMobileCache;
4166
- isMobileCache = evaluateIsMobile();
4167
- return isMobileCache;
4168
- }
4169
- function evaluateIsMobile(nav) {
4170
- if (nav || _isNavigatorDefined()) {
4171
- if (!nav) {
4172
- nav = navigator;
4173
- }
4174
- if (nav.product === 'ReactNative') {
4175
- return true;
4176
- }
4177
- var a = nav.userAgent || nav.vendor || (
4178
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
4179
- // @ts-ignore
4180
- typeof window !== 'undefined' ? window.opera : '');
4181
- if (!a) {
4182
- var navAny = nav;
4183
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
4184
- // @ts-ignore
4185
- return navAny.userAgentData && navAny.userAgentData.mobile;
4186
- }
4187
- return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4));
4188
- }
4189
- return false;
4190
- }
4191
-
4192
- var onMobile = isMobile();
4193
- var defaultIdCaptureThresholds = {
4194
- detection: defaultDocumentDetectionThresholds,
4195
- focus: defaultFocusThresholds
4196
- };
4197
- var IdCaptureModelsContext = /*#__PURE__*/createContext({
4198
- ready: false,
4199
- start: function start() {
4200
- return null;
4201
- },
4202
- stop: function stop() {
4203
- return null;
4204
- },
4205
- load: function load() {
4206
- return null;
4207
- },
4208
- modelDownloadProgress: 0,
4209
- modelError: null,
4210
- thresholds: defaultIdCaptureThresholds,
4211
- setThresholds: function setThresholds() {
4212
- return null;
4213
- },
4214
- documentDetectionBoundaries: defaultDocumentDetectionBoundaries,
4215
- setDocumentDetectionBoundaries: function setDocumentDetectionBoundaries() {
4216
- return null;
4217
- },
4218
- onPredictionMade: function onPredictionMade() {
4219
- return null;
4220
- },
4221
- detectionTime: 0,
4222
- focusPredictionTime: 0,
4223
- bestFrameDetails: {
4224
- current: null
4225
- },
4226
- getBestFrame: function getBestFrame() {
4227
- return null;
4228
- },
4229
- resetBestFrame: function resetBestFrame() {
4230
- return null;
4231
- },
4232
- requiredDocumentType: 'none',
4233
- setRequiredDocumentType: function setRequiredDocumentType() {
4234
- return null;
4235
- }
4236
- });
4237
- function IdCaptureModelsProviderInner(_a) {
4238
- var children = _a.children,
4239
- onModelError = _a.onModelError,
4240
- _b = _a.allowSinglePageIdCapture,
4241
- allowSinglePageIdCapture = _b === void 0 ? false : _b;
4242
- var _c = useContext(DocumentDetectionModelContext),
4243
- documentDetectionModelReady = _c.documentDetectionModelReady,
4244
- documentDetectionModelDownloadProgress = _c.documentDetectionModelDownloadProgress,
4245
- startDocumentDetection = _c.startDocumentDetection,
4246
- stopDocumentDetection = _c.stopDocumentDetection,
4247
- loadDocumentDetectionModel = _c.loadDocumentDetectionModel,
4248
- lastPredictionCanvas = _c.documentDetectionLastPredictionCanvas,
4249
- clearDocumentDetectionLastPredictionCanvas = _c.clearDocumentDetectionLastPredictionCanvas,
4250
- onDocumentDetected = _c.onDocumentDetected,
4251
- detectionTime = _c.detectionTime,
4252
- documentDetectionThresholds = _c.documentDetectionThresholds,
4253
- setDocumentDetectionThresholds = _c.setDocumentDetectionThresholds,
4254
- documentDetectionBoundaries = _c.documentDetectionBoundaries,
4255
- setDocumentDetectionBoundaries = _c.setDocumentDetectionBoundaries,
4256
- documentDetectionModelError = _c.documentDetectionModelError;
4257
- var _d = useContext(FocusModelContext),
4258
- loadFocusModel = _d.loadFocusModel,
4259
- focusModelReady = _d.focusModelReady,
4260
- focusModelDownloadProgress = _d.focusModelDownloadProgress,
4261
- makeFocusPrediction = _d.makeFocusPrediction,
4262
- focusThresholds = _d.focusThresholds,
4263
- setFocusThresholds = _d.setFocusThresholds,
4264
- focusPredictionTime = _d.focusPredictionTime,
4265
- focusModelError = _d.focusModelError;
4266
- var onPredictionHandler = useRef();
4267
- var bestFrameDetails = useRef(null);
4268
- var bestPredictionCanvas = useRef(null);
4269
- var bestFocusScore = useRef(0);
4270
- var stopDetection = useRef(0);
4271
- var _e = useState('none'),
4272
- requiredDocumentType = _e[0],
4273
- setRequiredDocumentType = _e[1];
4274
- var thresholds = useMemo(function () {
4275
- return _assign(_assign({}, documentDetectionThresholds), {
4276
- focus: focusThresholds
4277
- });
4278
- }, [documentDetectionThresholds, focusThresholds]);
4279
- var setThresholds = useCallback(function (thresholds) {
4280
- if (thresholds.detection) {
4281
- setDocumentDetectionThresholds(thresholds.detection);
4282
- }
4283
- if (thresholds.focus) {
4284
- setFocusThresholds(thresholds.focus);
4285
- }
4286
- }, [setDocumentDetectionThresholds, setFocusThresholds]);
4287
- useEffect(function handleDetections() {
4288
- var _this = this;
4289
- onDocumentDetected(function (prediction) {
4290
- return __awaiter(_this, void 0, void 0, function () {
4291
- var stopDetectionAtStart, focusPredictionTime, focusScore, focusThresholdMet, isSinglePage, isRequiredDocumentType, focusPrediction, focusThresholdSet, focusThreshold;
4292
- var _a, _b, _c, _d, _e, _f, _g;
4293
- return __generator(this, function (_h) {
4294
- if (!lastPredictionCanvas.current) return [2 /*return*/];
4295
- stopDetectionAtStart = stopDetection.current;
4296
- focusPredictionTime = 0, focusScore = 0, focusThresholdMet = false;
4297
- isSinglePage = prediction.detectedDocumentType === 'singlePage';
4298
- if (!allowSinglePageIdCapture && isSinglePage) {
4299
- prediction.detectedDocumentType = 'passport';
4300
- prediction.passportDetectionScore = prediction.singlePageDetectionScore;
4301
- prediction.passportDetectionThresholdMet = prediction.singlePageDetectionThresholdMet;
4302
- prediction.singlePageDetectionScore = 0;
4303
- prediction.singlePageDetectionThresholdMet = false;
4304
- }
4305
- 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'));
4306
- if (isRequiredDocumentType && prediction.detectedDocumentType !== 'none' && prediction.detectionThresholdMet && prediction.documentInBounds && !prediction.documentTooClose && prediction.documentIsStable) {
4307
- focusPrediction = makeFocusPrediction(lastPredictionCanvas.current, (_c = prediction.bestDocument) === null || _c === void 0 ? void 0 : _c.box);
4308
- if (focusPrediction) {
4309
- focusScore = focusPrediction.score;
4310
- focusPredictionTime = focusPrediction.predictionTime;
4311
- }
4312
- focusThresholdSet = (_d = thresholds.focus) === null || _d === void 0 ? void 0 : _d[prediction.detectedDocumentType];
4313
- focusThreshold = (_e = onMobile ? focusThresholdSet === null || focusThresholdSet === void 0 ? void 0 : focusThresholdSet.mobile : focusThresholdSet === null || focusThresholdSet === void 0 ? void 0 : focusThresholdSet.desktop) !== null && _e !== void 0 ? _e : 0;
4314
- focusThresholdMet = focusScore >= focusThreshold;
4315
- if (bestFocusScore.current <= focusScore && stopDetectionAtStart === stopDetection.current) {
4316
- bestFocusScore.current = focusScore;
4317
- drawToCanvas(bestPredictionCanvas.current, lastPredictionCanvas.current);
4318
- bestFrameDetails.current = {
4319
- boundingBox: (_f = prediction.bestDocument) === null || _f === void 0 ? void 0 : _f.box,
4320
- documentType: prediction.detectedDocumentType,
4321
- detectionScore: prediction.detectionScore,
4322
- focusScore: focusScore
4323
- };
4324
- }
4325
- }
4326
- (_g = onPredictionHandler.current) === null || _g === void 0 ? void 0 : _g.call(onPredictionHandler, _assign(_assign({}, prediction), {
4327
- focusScore: focusScore,
4328
- focusPredictionTime: focusPredictionTime,
4329
- focusThresholdMet: focusThresholdMet
4330
- }));
4331
- return [2 /*return*/];
4332
- });
4333
- });
4334
- });
4335
- }, [allowSinglePageIdCapture, lastPredictionCanvas, makeFocusPrediction, onDocumentDetected, requiredDocumentType, thresholds.focus]);
4336
- var modelError = documentDetectionModelError !== null && documentDetectionModelError !== void 0 ? documentDetectionModelError : focusModelError;
4337
- useEffect(function handleModelErrors() {
4338
- if (modelError) onModelError === null || onModelError === void 0 ? void 0 : onModelError(modelError);
4339
- }, [modelError, onModelError]);
4340
- var onPredictionMade = useCallback(function (handler) {
4341
- onPredictionHandler.current = handler;
4342
- }, []);
4343
- var getBestFrame = useCallback(function () {
4344
- if (!bestFrameDetails.current || !bestPredictionCanvas.current) return null;
4345
- return _assign(_assign({}, bestFrameDetails.current), {
4346
- canvas: bestPredictionCanvas.current
4347
- });
4348
- }, []);
4349
- var _f = useState(0),
4350
- canvasKey = _f[0],
4351
- setCanvasKey = _f[1];
4352
- var resetBestFrame = useCallback(function () {
4353
- stopDetection.current += 1;
4354
- setCanvasKey(function (n) {
4355
- return n + 1;
4356
- });
4357
- clearDocumentDetectionLastPredictionCanvas();
4358
- bestFrameDetails.current = null;
4359
- bestFocusScore.current = 0;
4360
- }, [clearDocumentDetectionLastPredictionCanvas]);
4361
- useEffect(function () {
4362
- if (requiredDocumentType) resetBestFrame();
4363
- }, [requiredDocumentType, resetBestFrame]);
4364
- var load = useCallback(function () {
4365
- loadDocumentDetectionModel();
4366
- loadFocusModel();
4367
- }, [loadDocumentDetectionModel, loadFocusModel]);
4368
- var value = useMemo(function () {
4369
- return {
4370
- ready: documentDetectionModelReady && focusModelReady,
4371
- modelDownloadProgress: (documentDetectionModelDownloadProgress + focusModelDownloadProgress) / 2,
4372
- modelError: modelError,
4373
- start: startDocumentDetection,
4374
- stop: stopDocumentDetection,
4375
- load: load,
4376
- thresholds: thresholds,
4377
- setThresholds: setThresholds,
4378
- documentDetectionBoundaries: documentDetectionBoundaries,
4379
- setDocumentDetectionBoundaries: setDocumentDetectionBoundaries,
4380
- onPredictionMade: onPredictionMade,
4381
- detectionTime: detectionTime,
4382
- focusPredictionTime: focusPredictionTime,
4383
- getBestFrame: getBestFrame,
4384
- resetBestFrame: resetBestFrame,
4385
- bestFrameDetails: bestFrameDetails,
4386
- requiredDocumentType: requiredDocumentType,
4387
- setRequiredDocumentType: setRequiredDocumentType
4388
- };
4389
- }, [detectionTime, documentDetectionBoundaries, documentDetectionModelDownloadProgress, documentDetectionModelReady, focusModelDownloadProgress, focusModelReady, focusPredictionTime, getBestFrame, load, modelError, onPredictionMade, requiredDocumentType, resetBestFrame, setDocumentDetectionBoundaries, setThresholds, startDocumentDetection, stopDocumentDetection, thresholds]);
4390
- return /*#__PURE__*/React__default.createElement(IdCaptureModelsContext.Provider, {
4391
- value: value
4392
- }, /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
4393
- key: canvasKey,
4394
- ref: bestPredictionCanvas
4395
- }), children);
4396
- }
4397
- function IdCaptureModelsProvider(_a) {
4398
- var children = _a.children,
4399
- props = __rest(_a, ["children"]);
4400
- return /*#__PURE__*/React__default.createElement(DocumentDetectionModelProvider, _assign({}, props), /*#__PURE__*/React__default.createElement(FocusModelProvider, _assign({}, props), /*#__PURE__*/React__default.createElement(IdCaptureModelsProviderInner, _assign({}, props), children)));
4401
- }
4402
-
4403
- var CapturedDocumentTypeValues = ['idCardFront', 'idCardBack', 'passport', 'singlePage', 'selfie'];
4404
-
4405
- var acceptedDocumentTypesForIdCaptureRequirementOption = {
4406
- idCardFront: ['idCardFront'],
4407
- idCardBack: ['idCardBack'],
4408
- passport: ['passport'],
4409
- idCard: ['idCardFront', 'idCardBack'],
4410
- idCardAndPassport: ['idCardFront', 'idCardBack', 'passport'],
4411
- idCardOrPassport: ['idCardFront', 'idCardBack', 'passport'] // this one is so weird
4412
- };
4413
- function minImageCountForIdCaptureRequirementOption(idCaptureRequirement) {
4414
- if (idCaptureRequirement === 'idCardOrPassport') return 1;
4415
- return acceptedDocumentTypesForIdCaptureRequirementOption[idCaptureRequirement].length;
4416
- }
4417
- function maxImageCountForIdCaptureRequirementOption(idCaptureRequirement) {
4418
- if (idCaptureRequirement === 'idCardOrPassport') return 2;
4419
- return minImageCountForIdCaptureRequirementOption(idCaptureRequirement);
4420
- }
4421
- function remainingIdCaptureRequirements(captureRequirement, capturedDocuments, requestedDocumentType) {
4422
- var isIdCardOrPassport = captureRequirement === 'idCardOrPassport';
4423
- if (isIdCardOrPassport && requestedDocumentType === 'passport') return [];
4424
- var acceptedTypes = acceptedDocumentTypesForIdCaptureRequirementOption[captureRequirement];
4425
- if (captureRequirement.includes('idCard') && 'singlePage' in capturedDocuments) {
4426
- acceptedTypes = acceptedTypes.filter(function (v) {
4427
- return !v.includes('idCard');
4428
- });
4429
- }
4430
- if (isIdCardOrPassport) {
4431
- acceptedTypes = acceptedTypes.filter(function (v) {
4432
- return v !== 'passport';
4433
- });
4434
- }
4435
- return acceptedTypes.filter(function (v) {
4436
- return !(v in capturedDocuments);
4437
- });
4438
- }
4439
-
4440
- var initialState$4 = {
4441
- initialDrawComplete: false,
4442
- redrawing: false,
4443
- guideRectX: 0,
4444
- guideRectY: 0,
4445
- guideRectWidth: 0,
4446
- guideRectHeight: 0,
4447
- guideRectOffsetTop: 0,
4448
- guideImageWidth: 0,
4449
- guideImageHeight: 0,
4450
- pageWidth: 0,
4451
- pageHeight: 0,
4452
- videoWidth: 0,
4453
- videoHeight: 0,
4454
- detectedObjects: [],
4455
- bestDocument: undefined,
4456
- detectedDocumentType: 'none',
4457
- detectionThresholdMet: false,
4458
- documentInBounds: false,
4459
- documentTooClose: false,
4460
- documentIsStable: false,
4461
- flipRequired: false,
4462
- backDetectedFirst: false,
4463
- idCardDetectedButNotAllowed: false,
4464
- passportDetectedButNotAllowed: false,
4465
- enableOverrideWrongDocumentTypeDialog: false,
4466
- allowOverrideWrongDocumentTypeAfterMs: 8000,
4467
- allowOverrideWrongDocumentTypeGuidance: false,
4468
- overrideWrongDocumentTypeGuidance: false,
4469
- wrongDocumentTypePredictions: 0,
4470
- idCardFrontDetectionScore: 0,
4471
- idCardFrontDetectionThresholdMet: false,
4472
- idCardBackDetectionScore: 0,
4473
- idCardBackDetectionThresholdMet: false,
4474
- passportDetectionScore: 0,
4475
- passportDetectionThresholdMet: false,
4476
- singlePageDetectionScore: 0,
4477
- singlePageDetectionThresholdMet: false,
4478
- focusScore: 0,
4479
- focusThresholdMet: false,
4480
- isGoodFrame: false,
4481
- goodFramesCount: 0,
4482
- goodFramesThreshold: 3,
4483
- goodFramesThresholdMet: false,
4484
- lastFrameCapturedAt: null,
4485
- frameCaptureRate: 0,
4486
- capturing: false,
4487
- captureFailed: false,
4488
- imageUrl: null,
4489
- captureState: 'initializing',
4490
- capturedDocuments: {},
4491
- captureRequirement: 'idCardOrPassport',
4492
- requestedDocumentType: 'idCardFront',
4493
- allowSinglePageIdCapture: false,
4494
- allowIdCardBackToFrontCapture: false,
4495
- allowUploadingDocumentsFromStorage: false,
4496
- isUploadingDocumentsFromStorage: false,
4497
- uploadingDocumentsType: null,
4498
- operationStartedAt: null,
4499
- captureStartedAt: null,
4500
- dispatch: function dispatch() {
4501
- return null;
4502
- }
4503
- };
4504
- var _reducer = function reducer(state, action) {
4505
- var _a;
4506
- switch (action.type) {
4507
- case 'configureWizard':
4508
- {
4509
- var _b = action.payload,
4510
- captureRequirement = _b.captureRequirement,
4511
- precapturedDocuments = _b.precapturedDocuments,
4512
- allowSinglePageIdCapture = _b.allowSinglePageIdCapture,
4513
- allowIdCardBackToFrontCapture = _b.allowIdCardBackToFrontCapture,
4514
- enableOverrideWrongDocumentTypeDialog = _b.enableOverrideWrongDocumentTypeDialog,
4515
- allowOverrideWrongDocumentTypeAfterMs = _b.allowOverrideWrongDocumentTypeAfterMs,
4516
- allowUploadingDocumentsFromStorage = _b.allowUploadingDocumentsFromStorage;
4517
- var newState = _assign(_assign({}, state), {
4518
- captureRequirement: captureRequirement,
4519
- allowSinglePageIdCapture: allowSinglePageIdCapture !== null && allowSinglePageIdCapture !== void 0 ? allowSinglePageIdCapture : false,
4520
- allowIdCardBackToFrontCapture: allowIdCardBackToFrontCapture !== null && allowIdCardBackToFrontCapture !== void 0 ? allowIdCardBackToFrontCapture : false,
4521
- enableOverrideWrongDocumentTypeDialog: enableOverrideWrongDocumentTypeDialog,
4522
- allowOverrideWrongDocumentTypeAfterMs: allowOverrideWrongDocumentTypeAfterMs,
4523
- allowUploadingDocumentsFromStorage: allowUploadingDocumentsFromStorage
4524
- });
4525
- if (captureRequirement === 'idCardBack') newState.requestedDocumentType = 'idCardBack';
4526
- if (captureRequirement === 'passport') newState.requestedDocumentType = 'passport';
4527
- if (precapturedDocuments) {
4528
- for (var _i = 0, CapturedDocumentTypeValues_1 = CapturedDocumentTypeValues; _i < CapturedDocumentTypeValues_1.length; _i++) {
4529
- var k = CapturedDocumentTypeValues_1[_i];
4530
- var payload = precapturedDocuments[k];
4531
- if (payload) {
4532
- newState.requestedDocumentType = k;
4533
- newState = _reducer(newState, {
4534
- type: 'documentCaptured',
4535
- payload: payload
4536
- });
4537
- }
4538
- }
4539
- }
4540
- if (newState.captureState === 'initializing' && !allowUploadingDocumentsFromStorage) {
4541
- newState.captureState = 'capturing';
4542
- }
4543
- return newState;
4544
- }
4545
- case 'setRequiredDocumentType':
4546
- return _assign(_assign({}, state), {
4547
- requiredDocumentType: action.payload
4548
- });
4549
- case 'redrawRequested':
4550
- return _assign(_assign({}, state), {
4551
- redrawing: true,
4552
- guideRectX: 0,
4553
- guideRectY: 0,
4554
- guideRectWidth: 0,
4555
- guideRectHeight: 0,
4556
- guideRectOffsetTop: 0
4557
- });
4558
- case 'redrawInProgress':
4559
- return _assign(_assign({}, state), {
4560
- redrawing: false,
4561
- guideRectX: 0,
4562
- guideRectY: 0,
4563
- guideRectWidth: 0,
4564
- guideRectHeight: 0,
4565
- guideRectOffsetTop: 0
4566
- });
4567
- case 'redrawCompleted':
4568
- return _assign(_assign(_assign({}, state), action.payload), {
4569
- initialDrawComplete: true
4570
- });
4571
- case 'pageRendered':
4572
- return _assign(_assign({}, state), action.payload);
4573
- case 'guideImageLoaded':
4574
- return _assign(_assign({}, state), {
4575
- guideImageWidth: action.payload.width,
4576
- guideImageHeight: action.payload.height
4577
- });
4578
- case 'objectsDetected':
4579
- {
4580
- var _c = action.payload.prediction,
4581
- detectedObjects = _c.detectedObjects,
4582
- detectionThresholdMet = _c.detectionThresholdMet,
4583
- detectedDocumentType = _c.detectedDocumentType,
4584
- idCardFrontDetectionScore = _c.idCardFrontDetectionScore,
4585
- idCardFrontDetectionThresholdMet = _c.idCardFrontDetectionThresholdMet,
4586
- idCardBackDetectionScore = _c.idCardBackDetectionScore,
4587
- idCardBackDetectionThresholdMet = _c.idCardBackDetectionThresholdMet,
4588
- passportDetectionScore = _c.passportDetectionScore,
4589
- passportDetectionThresholdMet = _c.passportDetectionThresholdMet,
4590
- singlePageDetectionScore = _c.singlePageDetectionScore,
4591
- singlePageDetectionThresholdMet = _c.singlePageDetectionThresholdMet,
4592
- bestDocument = _c.bestDocument,
4593
- documentInBounds = _c.documentInBounds,
4594
- documentTooClose = _c.documentTooClose,
4595
- documentIsStable = _c.documentIsStable,
4596
- focusScore = _c.focusScore,
4597
- focusThresholdMet = _c.focusThresholdMet,
4598
- frameWidth = _c.frameWidth,
4599
- frameHeight = _c.frameHeight;
4600
- var frameCapturedAt = new Date();
4601
- var frameCaptureRate = 0;
4602
- var goodFramesThreshold = state.goodFramesThreshold;
4603
- if (state.lastFrameCapturedAt) {
4604
- var frameTime = frameCapturedAt.getTime() - state.lastFrameCapturedAt.getTime();
4605
- if (frameTime > 0) {
4606
- frameCaptureRate = 1000.0 / frameTime;
4607
- if (frameCaptureRate > 0) {
4608
- goodFramesThreshold = Math.ceil(3 * frameCaptureRate);
4609
- }
4610
- }
4611
- }
4612
- var idCardDetected = detectedDocumentType.includes('idCard') || detectedDocumentType === 'singlePage';
4613
- var idCardDetectedButNotAllowed = idCardDetected && !state.captureRequirement.includes('idCard');
4614
- var passportNotAllowed = !state.captureRequirement.toLowerCase().includes('passport');
4615
- var idCardFrontWasCaptured = 'idCardFront' in state.capturedDocuments;
4616
- var idCardBackWasCaptured = 'idCardBack' in state.capturedDocuments;
4617
- var idCardBeingCaptured = idCardFrontWasCaptured && !idCardBackWasCaptured || !idCardFrontWasCaptured && idCardBackWasCaptured;
4618
- var passportDetectedButNotAllowed = detectedDocumentType === 'passport' && (passportNotAllowed || idCardBeingCaptured);
4619
- var flipRequired = !state.overrideWrongDocumentTypeGuidance && (state.allowIdCardBackToFrontCapture ? idCardFrontWasCaptured && detectedDocumentType === 'idCardFront' : state.requestedDocumentType === 'idCardBack' && detectedDocumentType === 'idCardFront');
4620
- var backDetectedFirst = !state.overrideWrongDocumentTypeGuidance && (state.allowIdCardBackToFrontCapture ? idCardBackWasCaptured && detectedDocumentType === 'idCardBack' : state.requestedDocumentType === 'idCardFront' && detectedDocumentType === 'idCardBack');
4621
- var wrongDocumentTypePredictions = state.wrongDocumentTypePredictions;
4622
- if (state.captureState === 'capturing' && (flipRequired || backDetectedFirst)) {
4623
- wrongDocumentTypePredictions += 1;
4624
- }
4625
- var isGoodFrame = detectionThresholdMet && documentInBounds && !documentTooClose && !flipRequired && !backDetectedFirst && focusThresholdMet && !idCardDetectedButNotAllowed && !passportDetectedButNotAllowed && documentIsStable;
4626
- var captureStartedAt = state.captureStartedAt;
4627
- var goodFramesCount = state.goodFramesCount;
4628
- if (isGoodFrame) {
4629
- goodFramesCount += 1;
4630
- captureStartedAt || (captureStartedAt = new Date());
4631
- }
4632
- var goodFramesThresholdMet = goodFramesCount >= goodFramesThreshold;
4633
- var requestedDocumentType = state.requestedDocumentType;
4634
- if (state.captureRequirement.includes('idCard') && state.allowIdCardBackToFrontCapture) {
4635
- if (detectedDocumentType === 'idCardFront' && state.requestedDocumentType !== 'idCardFront' && !idCardFrontWasCaptured) {
4636
- requestedDocumentType = 'idCardFront';
4637
- } else if (detectedDocumentType === 'idCardBack' && state.requestedDocumentType !== 'idCardBack' && !idCardBackWasCaptured) {
4638
- requestedDocumentType = 'idCardBack';
4639
- }
4640
- }
4641
- if (state.captureRequirement === 'idCardOrPassport') {
4642
- if (detectedDocumentType === 'passport' && state.requestedDocumentType !== 'passport') {
4643
- requestedDocumentType = 'passport';
4644
- }
4645
- if (requestedDocumentType === 'passport' && passportDetectionScore < 0.3) {
4646
- requestedDocumentType = idCardFrontWasCaptured ? 'idCardBack' : 'idCardFront';
4647
- }
4648
- }
4649
- var hasBeenRunningForLongEnough = !!state.operationStartedAt && new Date().getTime() - state.operationStartedAt.getTime() > 1000;
4650
- var overrideFlipRequirementThreshold = Math.ceil(state.allowOverrideWrongDocumentTypeAfterMs / 1000 * frameCaptureRate);
4651
- var allowOverrideFlipRequirement = state.enableOverrideWrongDocumentTypeDialog && hasBeenRunningForLongEnough && !state.overrideWrongDocumentTypeGuidance && overrideFlipRequirementThreshold > 0 && (state.allowOverrideWrongDocumentTypeGuidance || wrongDocumentTypePredictions >= overrideFlipRequirementThreshold);
4652
- return _assign(_assign({}, state), {
4653
- videoWidth: frameWidth,
4654
- videoHeight: frameHeight,
4655
- detectedObjects: detectedObjects,
4656
- bestDocument: bestDocument,
4657
- requestedDocumentType: requestedDocumentType,
4658
- detectedDocumentType: detectedDocumentType,
4659
- detectionThresholdMet: detectionThresholdMet,
4660
- documentInBounds: documentInBounds,
4661
- documentTooClose: documentTooClose,
4662
- documentIsStable: documentIsStable,
4663
- flipRequired: flipRequired,
4664
- backDetectedFirst: backDetectedFirst,
4665
- idCardDetectedButNotAllowed: idCardDetectedButNotAllowed,
4666
- passportDetectedButNotAllowed: passportDetectedButNotAllowed,
4667
- allowOverrideWrongDocumentTypeGuidance: allowOverrideFlipRequirement,
4668
- wrongDocumentTypePredictions: wrongDocumentTypePredictions,
4669
- idCardFrontDetectionScore: idCardFrontDetectionScore,
4670
- idCardFrontDetectionThresholdMet: idCardFrontDetectionThresholdMet,
4671
- idCardBackDetectionScore: idCardBackDetectionScore,
4672
- idCardBackDetectionThresholdMet: idCardBackDetectionThresholdMet,
4673
- passportDetectionScore: passportDetectionScore,
4674
- passportDetectionThresholdMet: passportDetectionThresholdMet,
4675
- singlePageDetectionScore: singlePageDetectionScore,
4676
- singlePageDetectionThresholdMet: singlePageDetectionThresholdMet,
4677
- focusScore: focusScore,
4678
- focusThresholdMet: focusThresholdMet,
4679
- isGoodFrame: isGoodFrame,
4680
- goodFramesCount: goodFramesCount,
4681
- goodFramesThreshold: goodFramesThreshold,
4682
- goodFramesThresholdMet: goodFramesThresholdMet,
4683
- captureStartedAt: captureStartedAt,
4684
- lastFrameCapturedAt: frameCapturedAt,
4685
- frameCaptureRate: frameCaptureRate
4686
- });
4687
- }
4688
- case 'captureInitialized':
4689
- return _assign(_assign({}, state), {
4690
- captureState: 'capturing',
4691
- isUploadingDocumentsFromStorage: false
4692
- });
4693
- case 'captureStarted':
4694
- return _assign(_assign({}, state), {
4695
- operationStartedAt: new Date(),
4696
- captureStartedAt: null,
4697
- capturing: false,
4698
- captureFailed: false
4699
- });
4700
- case 'capturing':
4701
- return _assign(_assign({}, state), {
4702
- capturing: true,
4703
- captureFailed: false
4704
- });
4705
- case 'captured':
4706
- return _assign(_assign({}, state), {
4707
- capturing: false,
4708
- captureFailed: false
4709
- });
4710
- case 'frameCaptured':
4711
- return _assign(_assign({}, state), {
4712
- imageUrl: action.payload.imageUrl
4713
- });
4714
- case 'captureFailed':
4715
- return _assign(_assign({}, state), {
4716
- capturing: false,
4717
- captureFailed: true
4718
- });
4719
- case 'documentCaptured':
4720
- {
4721
- var newState = _assign(_assign({}, state), {
4722
- capturing: false,
4723
- captureFailed: false,
4724
- allowOverrideFlipRequirement: false,
4725
- overrideFlipRequirement: false,
4726
- goodFramesCount: 0,
4727
- wrongDocumentTypePredictions: 0,
4728
- capturedDocuments: _assign(_assign({}, state.capturedDocuments), (_a = {}, _a[action.payload.documentType] = action.payload, _a))
4729
- });
4730
- var remainingRequirements = remainingIdCaptureRequirements(state.captureRequirement, newState.capturedDocuments, state.requestedDocumentType);
4731
- if (remainingRequirements.length === 0) {
4732
- newState.captureState = 'complete';
4733
- } else {
4734
- newState.requestedDocumentType = remainingRequirements[0];
4735
- if (state.requestedDocumentType === 'idCardFront' && newState.requestedDocumentType === 'idCardBack' || state.requestedDocumentType === 'idCardBack' && newState.requestedDocumentType === 'idCardFront') {
4736
- if (!newState.isUploadingDocumentsFromStorage) {
4737
- newState.captureState = 'requestingFlip';
4738
- }
4739
- newState.idCardFrontDetectionThresholdMet = false;
4740
- newState.idCardBackDetectionThresholdMet = false;
4741
- newState.passportDetectionThresholdMet = false;
4742
- newState.wrongDocumentTypePredictions = 0;
4743
- }
4744
- }
4745
- return newState;
4746
- }
4747
- case 'documentCapturedManually':
4748
- return _reducer(state, {
4749
- type: 'documentCaptured',
4750
- payload: _assign(_assign({}, action.payload), {
4751
- documentType: state.requestedDocumentType,
4752
- width: 0,
4753
- height: 0
4754
- })
4755
- });
4756
- case 'documentsCaptured':
4757
- {
4758
- var newState = _assign({}, state);
4759
- for (var _d = 0, _e = action.payload; _d < _e.length; _d++) {
4760
- var doc = _e[_d];
4761
- newState = _reducer(newState, {
4762
- type: 'documentCaptured',
4763
- payload: doc
4764
- });
4765
- }
4766
- return newState;
4767
- }
4768
- case 'flipRequestCompleted':
4769
- return _assign(_assign({}, state), {
4770
- captureState: 'capturing',
4771
- allowOverrideWrongDocumentTypeGuidance: false,
4772
- overrideWrongDocumentTypeGuidance: false,
4773
- wrongDocumentTypePredictions: 0
4774
- });
4775
- case 'allowOverrideFlipRequirement':
4776
- return _assign(_assign({}, state), {
4777
- allowOverrideWrongDocumentTypeGuidance: true
4778
- });
4779
- case 'overrideFlipRequirement':
4780
- return _assign(_assign({}, state), {
4781
- allowOverrideWrongDocumentTypeGuidance: false,
4782
- overrideWrongDocumentTypeGuidance: true
4783
- });
4784
- case 'setUploadingDocumentsFromStorage':
4785
- return _assign(_assign({}, state), {
4786
- isUploadingDocumentsFromStorage: action.payload,
4787
- captureState: action.payload ? 'initializing' : 'capturing'
4788
- });
4789
- case 'setUploadingDocumentsType':
4790
- {
4791
- var requestedDocumentType = !action.payload || action.payload === 'idCard' ? 'idCardFront' : action.payload;
4792
- var uploadingDocumentsType = action.payload === 'singlePage' ? 'idCard' : action.payload;
4793
- return _assign(_assign({}, state), {
4794
- captureState: action.payload ? 'uploading' : 'initializing',
4795
- uploadingDocumentsType: uploadingDocumentsType,
4796
- requestedDocumentType: requestedDocumentType
4797
- });
4798
- }
4799
- case 'resetWizard':
4800
- return _assign(_assign({}, initialState$4), {
4801
- dispatch: state.dispatch,
4802
- allowUploadingDocumentsFromStorage: state.allowUploadingDocumentsFromStorage,
4803
- captureState: state.allowUploadingDocumentsFromStorage ? 'initializing' : 'capturing',
4804
- captureRequirement: state.captureRequirement,
4805
- allowIdCardBackToFrontCapture: state.allowIdCardBackToFrontCapture
4806
- });
4807
- default:
4808
- return state;
4809
- }
4810
- };
4811
- var useIdCaptureStore = create()(devtools(function (set) {
4812
- return _assign(_assign({}, initialState$4), {
4813
- dispatch: function dispatch(action) {
4814
- return set(function (state) {
4815
- return _reducer(state, action);
4816
- }, undefined, action);
4817
- }
4818
- });
4819
- }));
4820
- function IdCaptureStateProvider(_a) {
4821
- var children = _a.children;
4822
- var overrideWrongDocumentTypeGuidance = useIdCaptureStore(useShallow(function (state) {
4823
- return state.overrideWrongDocumentTypeGuidance;
4824
- }));
4825
- var setRequiredDocumentType = useContext(IdCaptureModelsContext).setRequiredDocumentType;
4826
- useEffect(function () {
4827
- if (overrideWrongDocumentTypeGuidance) setRequiredDocumentType('none');
4828
- }, [overrideWrongDocumentTypeGuidance, setRequiredDocumentType]);
4829
- var onResize = useDebouncedCallback(function () {
4830
- dispatchIdCaptureAction({
4831
- type: 'redrawRequested'
4832
- });
4833
- }, 500);
4834
- useLayoutEffect(function () {
4835
- if (typeof window === 'undefined') return;
4836
- window.addEventListener('resize', onResize);
4837
- return function () {
4838
- return window.removeEventListener('resize', onResize);
4839
- };
4840
- }, [onResize]);
4841
- useEffect(function resetWhenProviderUnmounts() {
4842
- return function () {
4843
- return useIdCaptureStore.getState().dispatch({
4844
- type: 'resetWizard'
4845
- });
4846
- };
4847
- }, []);
4848
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, children);
4849
- }
4850
- var dispatchIdCaptureAction = function dispatchIdCaptureAction(action) {
4851
- return useIdCaptureStore.getState().dispatch(action);
4852
- };
4853
-
4854
- function DebugStatsPane(_a) {
4855
- var children = _a.children;
4856
- var element = /*#__PURE__*/React__default.createElement(DebugStatsPaneDiv, null, children);
4857
- var portalLocation = document.getElementById('idmission-above-guides-content');
4858
- if (!portalLocation) return element;
4859
- return /*#__PURE__*/createPortal(element, portalLocation);
4860
- }
4861
- var DebugStatsPaneDiv = styled.span(templateObject_1$G || (templateObject_1$G = __makeTemplateObject(["\n font-size: 16px;\n font-family: monospace;\n position: absolute;\n left: 20px;\n bottom: 20px;\n margin-right: 20px;\n padding: 8px;\n color: limegreen;\n background: rgba(0, 0, 0, 0.5);\n z-index: 10002;\n"], ["\n font-size: 16px;\n font-family: monospace;\n position: absolute;\n left: 20px;\n bottom: 20px;\n margin-right: 20px;\n padding: 8px;\n color: limegreen;\n background: rgba(0, 0, 0, 0.5);\n z-index: 10002;\n"])));
4862
- var ObjectDetectionDebugOverlayDiv = styled.div(templateObject_2$z || (templateObject_2$z = __makeTemplateObject(["\n position: absolute;\n z-index: 1001;\n width: 100%;\n height: 100%;\n max-width: 100%;\n max-height: 100%;\n overflow: hidden;\n ", "\n transform-style: preserve-3d;\n"], ["\n position: absolute;\n z-index: 1001;\n width: 100%;\n height: 100%;\n max-width: 100%;\n max-height: 100%;\n overflow: hidden;\n ", "\n transform-style: preserve-3d;\n"])), function (_a) {
4863
- var $flipX = _a.$flipX;
4864
- return $flipX ? 'transform: scaleX(-1);' : '';
4865
- });
4866
- var ObjectDetectionDebugBox = styled.div(templateObject_3$q || (templateObject_3$q = __makeTemplateObject(["\n font: 10px monospace;\n position: absolute;\n border: 3px solid ", ";\n color: ", ";\n ", "\n transform-style: preserve-3d;\n"], ["\n font: 10px monospace;\n position: absolute;\n border: 3px solid ", ";\n color: ", ";\n ", "\n transform-style: preserve-3d;\n"])), function (_a) {
4867
- var $color = _a.$color;
4868
- return $color !== null && $color !== void 0 ? $color : 'green';
4869
- }, function (_a) {
4870
- var $color = _a.$color;
4871
- return $color !== null && $color !== void 0 ? $color : 'green';
4872
- }, function (_a) {
4873
- var $flipX = _a.$flipX;
4874
- return $flipX ? 'transform: scaleX(-1);' : '';
4875
- });
4876
- var FaceDetectionKeypointMarker = styled.div(templateObject_4$k || (templateObject_4$k = __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) {
4877
- var $color = _a.$color;
4878
- return $color !== null && $color !== void 0 ? $color : 'red';
4879
- }, function (_a) {
4880
- var $color = _a.$color;
4881
- return $color !== null && $color !== void 0 ? $color : 'red';
4882
- }, function (_a) {
4883
- var $flipX = _a.$flipX;
4884
- return $flipX ? 'transform: scaleX(-1);' : '';
4885
- });
4886
- function useDebugScalingDetails(_a) {
4887
- var _b = _a.enabled,
4888
- enabled = _b === void 0 ? true : _b,
4889
- pageWidth = _a.pageWidth,
4890
- pageHeight = _a.pageHeight,
4891
- videoWidth = _a.videoWidth,
4892
- videoHeight = _a.videoHeight;
4893
- return useMemo(function () {
4894
- var horizontal = false,
4895
- scaledWidth = 0,
4896
- scaledHeight = 0,
4897
- xOffset = 0,
4898
- yOffset = 0;
4899
- if (enabled) {
4900
- horizontal = pageWidth / pageHeight < videoWidth / videoHeight;
4901
- if (horizontal) {
4902
- scaledWidth = videoWidth * (pageHeight / videoHeight);
4903
- xOffset = (scaledWidth - pageWidth) / 2;
4904
- } else {
4905
- scaledHeight = videoHeight * (pageWidth / videoWidth);
4906
- yOffset = (scaledHeight - pageHeight) / 2;
4907
- }
4908
- }
4909
- return {
4910
- horizontal: horizontal,
4911
- pageWidth: pageWidth,
4912
- pageHeight: pageHeight,
4913
- videoWidth: videoWidth,
4914
- videoHeight: videoHeight,
4915
- scaledWidth: scaledWidth,
4916
- scaledHeight: scaledHeight,
4917
- xOffset: xOffset,
4918
- yOffset: yOffset
4919
- };
4920
- }, [enabled, pageHeight, pageWidth, videoHeight, videoWidth]);
4921
- }
4922
- var DebugBoundingBoxOverlay = function DebugBoundingBoxOverlay(_a) {
4923
- var scaling = _a.scaling,
4924
- $flipX = _a.$flipX,
4925
- children = _a.children;
4926
- var _b = useIdCaptureStore(),
4927
- guideRectWidth = _b.guideRectWidth,
4928
- guideRectHeight = _b.guideRectHeight,
4929
- guideRectX = _b.guideRectX,
4930
- guideRectY = _b.guideRectY;
4931
- return /*#__PURE__*/React__default.createElement(ObjectDetectionDebugOverlayDiv, {
4932
- id: "debug-overlay-div",
4933
- "$flipX": $flipX,
4934
- style: {
4935
- top: guideRectY,
4936
- left: guideRectX,
4937
- width: guideRectWidth || (scaling === null || scaling === void 0 ? void 0 : scaling.pageWidth),
4938
- height: guideRectHeight || (scaling === null || scaling === void 0 ? void 0 : scaling.pageHeight)
4939
- }
4940
- }, children);
4941
- };
4942
- function IdCaptureDetectedObjectDebugBox(_a) {
4943
- var obj = _a.obj,
4944
- flipX = _a.flipX,
4945
- _b = _a.color,
4946
- color = _b === void 0 ? 'green' : _b,
4947
- scaling = _a.scaling;
4948
- var horizontal = scaling.horizontal,
4949
- pageWidth = scaling.pageWidth,
4950
- pageHeight = scaling.pageHeight,
4951
- videoWidth = scaling.videoWidth,
4952
- videoHeight = scaling.videoHeight,
4953
- scaledWidth = scaling.scaledWidth,
4954
- scaledHeight = scaling.scaledHeight,
4955
- xOffset = scaling.xOffset,
4956
- yOffset = scaling.yOffset;
4957
- if (!videoWidth || !videoHeight || !pageWidth || !pageHeight) return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
4958
- var top;
4959
- var left;
4960
- var width;
4961
- var height;
4962
- if (horizontal) {
4963
- top = obj.box.yMin / videoHeight * pageHeight;
4964
- left = obj.box.xMin / videoWidth * scaledWidth - xOffset;
4965
- width = obj.box.width / videoWidth * scaledWidth;
4966
- height = obj.box.height / videoHeight * pageHeight;
4967
- } else {
4968
- top = obj.box.yMin / videoHeight * scaledHeight - yOffset;
4969
- left = obj.box.xMin / videoWidth * pageWidth;
4970
- width = obj.box.width / videoWidth * pageWidth;
4971
- height = obj.box.height / videoHeight * scaledHeight;
4972
- }
4973
- return /*#__PURE__*/React__default.createElement(ObjectDetectionDebugBox, {
4974
- "$flipX": flipX,
4975
- "$color": color,
4976
- style: {
4977
- top: top,
4978
- left: left,
4979
- width: width,
4980
- height: height
4981
- }
4982
- });
4983
- }
4984
- function SelfieCaptureFaceDebugBox(_a) {
4985
- var face = _a.face,
4986
- flipX = _a.flipX,
4987
- _b = _a.color,
4988
- color = _b === void 0 ? 'green' : _b,
4989
- scaling = _a.scaling;
4990
- var horizontal = scaling.horizontal,
4991
- pageWidth = scaling.pageWidth,
4992
- pageHeight = scaling.pageHeight,
4993
- videoWidth = scaling.videoWidth,
4994
- videoHeight = scaling.videoHeight,
4995
- scaledWidth = scaling.scaledWidth,
4996
- scaledHeight = scaling.scaledHeight,
4997
- xOffset = scaling.xOffset,
4998
- yOffset = scaling.yOffset;
4999
- if (!videoWidth || !videoHeight || !pageWidth || !pageHeight) return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
5000
- var top;
5001
- var left;
5002
- var width;
5003
- var height;
5004
- if (horizontal) {
5005
- top = face.box.yMin / videoHeight * pageHeight;
5006
- left = face.box.xMin / videoWidth * scaledWidth - xOffset;
5007
- width = face.box.width / videoWidth * scaledWidth;
5008
- height = face.box.height / videoHeight * pageHeight;
5009
- } else {
5010
- top = face.box.yMin / videoHeight * scaledHeight - yOffset;
5011
- left = face.box.xMin / videoWidth * pageWidth;
5012
- width = face.box.width / videoWidth * pageWidth;
5013
- height = face.box.height / videoHeight * scaledHeight;
5014
- }
5015
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(ObjectDetectionDebugBox, {
5016
- "$flipX": flipX,
5017
- "$color": color,
5018
- style: {
5019
- top: top,
5020
- left: left,
5021
- width: width,
5022
- height: height
5023
- }
5024
- }), face.keypoints.map(function (point, ii) {
5025
- return /*#__PURE__*/React__default.createElement(SelfieCaptureFaceKeypoint, {
5026
- key: ii,
5027
- point: point,
5028
- scaling: scaling,
5029
- flipX: flipX
5030
- });
5031
- }));
5032
- }
5033
- function SelfieCaptureFaceKeypoint(_a) {
5034
- var point = _a.point,
5035
- flipX = _a.flipX,
5036
- _b = _a.color,
5037
- color = _b === void 0 ? 'red' : _b,
5038
- _c = _a.scaling,
5039
- horizontal = _c.horizontal,
5040
- pageWidth = _c.pageWidth,
5041
- pageHeight = _c.pageHeight,
5042
- videoWidth = _c.videoWidth,
5043
- videoHeight = _c.videoHeight,
5044
- scaledWidth = _c.scaledWidth,
5045
- scaledHeight = _c.scaledHeight,
5046
- xOffset = _c.xOffset,
5047
- yOffset = _c.yOffset;
5048
- var left, top;
5049
- if (horizontal) {
5050
- left = point.x / videoWidth * scaledWidth - xOffset;
5051
- top = point.y / videoHeight * pageHeight;
5052
- } else {
5053
- left = point.x / videoWidth * pageWidth;
5054
- top = point.y / videoHeight * scaledHeight - yOffset;
5055
- }
5056
- top -= 2;
5057
- left -= 2;
5058
- return /*#__PURE__*/React__default.createElement(FaceDetectionKeypointMarker, {
5059
- "$flipX": flipX,
5060
- "$color": color,
5061
- style: {
5062
- top: top,
5063
- left: left
5064
- }
5065
- });
5066
- }
5067
- var templateObject_1$G, templateObject_2$z, templateObject_3$q, templateObject_4$k;
5068
-
5069
3560
  var en = {};
5070
3561
 
5071
3562
  var es = {
@@ -5095,7 +3586,7 @@ var es = {
5095
3586
  'Document is not centered': 'Documento no centrado',
5096
3587
  'Document too close please back up': 'Documento muy cerca, favor de alejarse',
5097
3588
  'Please hold your ID document steady': 'Por favor, hay que mantener firme su identificación',
5098
- 'Document out of focus try improving the lighting': 'Documento no enfocado, hay que tratar de mejorar la iluminación',
3589
+ 'Document out of focus - try improving the lighting': 'Documento no enfocado, hay que tratar de mejorar la iluminación',
5099
3590
  'ID card front detected - please flip your ID card': 'Frente de la ID detectado, por favor hay que voltearla',
5100
3591
  'ID card back detected - please flip your ID card': 'Reverso de la ID detectado, por favor hay que voltearla',
5101
3592
  'ID card detected please scan a passport instead': 'Se ha detectado una credencial, por favor hay que escanear un pasaporte',
@@ -5190,7 +3681,9 @@ var es = {
5190
3681
  'Upload ID Front': 'Adjuntar el frente de la ID',
5191
3682
  'Upload ID Back': 'Adjuntar el reverso de la ID',
5192
3683
  Cancel: 'Cancelar',
5193
- 'Upload the back of the ID if it is not included in the front image.': 'Adjuntar el reverso de la ID si no se incluye en la imagen del frente'
3684
+ 'Upload the back of the ID if it is not included in the front image.': 'Adjuntar el reverso de la ID si no se incluye en la imagen del frente',
3685
+ 'Camera tampering detected': 'Se ha detectado un intento de manipulación de la cámara',
3686
+ "We're sorry, but it looks like the camera is being tampered with. Please check your device and try again by reloading the page.": 'Lo sentimos, pero parece que la cámara está siendo manipulada. Por favor, verifique su dispositivo y vuelva a intentarlo recargando la página.'
5194
3687
  };
5195
3688
 
5196
3689
  var de = {
@@ -5220,7 +3713,7 @@ var de = {
5220
3713
  'Document is not centered': 'Dokument ist nicht zentriert',
5221
3714
  'Document too close please back up': 'Dokument ist zu nah, bitte Abstand vergrößern',
5222
3715
  'Please hold your ID document steady': 'Ihr Ausweisdokument ruhig halten',
5223
- 'Document out of focus try improving the lighting': 'Dokument unscharf versuchen Sie, die Beleuchtung zu verbessern',
3716
+ 'Document out of focus - try improving the lighting': 'Dokument unscharf - versuchen Sie, die Beleuchtung zu verbessern',
5224
3717
  'ID card front detected - please flip your ID card': 'Vorderseite des Ausweises erkannt - bitte Ihren Ausweis umdrehen',
5225
3718
  'ID card back detected - please flip your ID card': 'Rückseite des Ausweises erkannt - bitte Ihren Ausweis umdrehen',
5226
3719
  'ID card detected please scan a passport instead': 'Ausweis erkannt, bitte stattdessen einen Pass scannen',
@@ -5303,7 +3796,7 @@ var de = {
5303
3796
  'Camera ready': 'Kamera bereit',
5304
3797
  'Loading guided capture experience...': 'Geführte Erfassung wird geladen...',
5305
3798
  'Guided capture experience ready': 'Geführte Erfassung bereit',
5306
- "Let's Go!": 'Los gehts!',
3799
+ "Let's Go!": "Los geht's!",
5307
3800
  'We are having trouble identifying the correct side of your id do you want to continue with capture anyway?': 'Wir haben Probleme, die richtige Seite Ihres Ausweises zu erkennen. Möchten Sie dennoch mit der Erfassung fortfahren?',
5308
3801
  OK: 'OK',
5309
3802
  'Capture with Camera': 'Mit der Kamera aufnehmen',
@@ -5315,7 +3808,9 @@ var de = {
5315
3808
  'Upload ID Front': 'Vorderseite der ID hochladen',
5316
3809
  'Upload ID Back': 'Rückseite der ID hochladen',
5317
3810
  Cancel: 'Abbrechen',
5318
- 'Upload the back of the ID if it is not included in the front image.': 'Laden Sie die Rückseite des Ausweises hoch, wenn diese nicht im Bild der Vorderseite enthalten ist.\r\n'
3811
+ 'Upload the back of the ID if it is not included in the front image.': 'Laden Sie die Rückseite des Ausweises hoch, wenn diese nicht im Bild der Vorderseite enthalten ist.',
3812
+ 'Camera tampering detected': 'Kamera manipuliert',
3813
+ "We're sorry, but it looks like the camera is being tampered with. Please check your device and try again by reloading the page.": 'Leider scheint die Kamera manipuliert zu werden. Bitte prüfen Sie Ihr Gerät und laden Sie die Seite neu.'
5319
3814
  };
5320
3815
 
5321
3816
  var fr = {
@@ -5345,7 +3840,7 @@ var fr = {
5345
3840
  'Document is not centered': "Le document n'est pas centré",
5346
3841
  'Document too close please back up': 'Document trop proche, veuillez sauvegarder',
5347
3842
  'Please hold your ID document steady': "Veuillez maintenir fermement votre pièce d'identité",
5348
- 'Document out of focus try improving the lighting': 'Document flou essayez daméliorer l’éclairage',
3843
+ 'Document out of focus - try improving the lighting': "Document flou - essayez d'améliorer l'éclairage",
5349
3844
  'ID card front detected - please flip your ID card': "Recto de la carte d'identité détecté - veuillez retourner votre carte d'identité",
5350
3845
  'ID card back detected - please flip your ID card': "Verso de la carte d'identité détectée - veuillez retourner votre carte d'identité",
5351
3846
  'ID card detected please scan a passport instead': "Carte d'identité détectée, veuillez scanner plutôt un passeport",
@@ -5360,7 +3855,7 @@ var fr = {
5360
3855
  'ID card front captured.': "Recto de la carte d'identité capturé.",
5361
3856
  'ID card back captured.': "Verso de la carte d'identité capturé.",
5362
3857
  'ID Capture Successful': "Capture d'identité réussie",
5363
- 'Verify the entire ID was captured clearly with no glare.': "Vérifiez que l'intégralité de la pièce didentité a été capturée clairement, sans reflet.",
3858
+ 'Verify the entire ID was captured clearly with no glare.': "Vérifiez que l'intégralité de la pièce d'identité a été capturée clairement, sans reflet.",
5364
3859
  Submit: 'Soumettre',
5365
3860
  'Submitting...': 'Soumission en cours...',
5366
3861
  'Use your device camera to capture your face': 'Utilisez la caméra de votre appareil pour capturer votre visage',
@@ -5404,20 +3899,20 @@ var fr = {
5404
3899
  'Display the back of your ID card...': "Affichez le verso de votre carte d'identité...",
5405
3900
  'Display the ID page of your passport...': "Montrez la page d'identité de votre passeport...",
5406
3901
  'Please move your face to the center...': 'Veuillez déplacer votre visage vers le centre...',
5407
- 'Searching for ID card...': "Recherche dune carte d'identité...",
3902
+ 'Searching for ID card...': "Recherche d'une carte d'identité...",
5408
3903
  'Please read the following text aloud': 'Veuillez lire le texte suivant à voix haute',
5409
- 'Video ID has been successfully captured!': 'L’ID vidéo a été capturé avec succès!',
5410
- 'ID Front Image': 'Image recto de la pièce didentité',
5411
- 'ID Back Image': 'Image verso de la pièce didentité',
3904
+ 'Video ID has been successfully captured!': "L'ID vidéo a été capturé avec succès!",
3905
+ 'ID Front Image': "Image recto de la pièce d'identité",
3906
+ 'ID Back Image': "Image verso de la pièce d'identité",
5412
3907
  "We're having some trouble.": 'Nous rencontrons quelques problèmes.',
5413
3908
  'On-device capture guidance failed please capture a selfie manually.': "Le guidage de capture sur l'appareil a échoué, veuillez capturer un selfie manuellement.",
5414
3909
  'Verifying...': 'Vérification en cours...',
5415
3910
  'Please capture the front of your ID card.': "Veuillez capturer le recto de votre carte d'identité.",
5416
3911
  'Please capture the back of your ID card.': "Veuillez capturer le verso de votre carte d'identité.",
5417
- 'Please capture the front of your ID card, or the ID page of your passport.': 'Veuillez capturer le recto de votre carte didentité ou la page didentité de votre passeport.',
5418
- 'Please capture the back of your ID card, or click Done if submitting a passport.': 'Veuillez capturer le verso de votre carte didentité ou cliquer sur Terminé si vous soumettez un passeport.',
3912
+ 'Please capture the front of your ID card, or the ID page of your passport.': "Veuillez capturer le recto de votre carte d'identité ou la page d'identité de votre passeport.",
3913
+ 'Please capture the back of your ID card, or click Done if submitting a passport.': "Veuillez capturer le verso de votre carte d'identité ou cliquer sur Terminé si vous soumettez un passeport.",
5419
3914
  'Please capture the ID page of your passport.': "Veuillez capturer la page d'identité de votre passeport.",
5420
- 'On-device capture guidance failed please capture a photo of your ID card manually.': "Le guidage de capture sur l'appareil a échoué, veuillez capturer une photo de votre pièce didentité manuellement.",
3915
+ 'On-device capture guidance failed please capture a photo of your ID card manually.': "Le guidage de capture sur l'appareil a échoué, veuillez capturer une photo de votre pièce d'identité manuellement.",
5421
3916
  'On-device capture guidance failed please capture a photo of your passport manually.': "Le guidage de capture sur l'appareil a échoué, veuillez capturer une photo de votre passeport manuellement.",
5422
3917
  'On-device capture guidance failed please capture photos of your ID card and passport manually.': "Le guidage de capture sur l'appareil a échoué, veuillez capturer manuellement des photos de votre carte d'identité et de votre passeport.",
5423
3918
  'On-device capture guidance failed please capture photos of your ID card or passport manually.': "Le guidage de capture sur l'appareil a échoué, veuillez capturer manuellement des photos de votre carte d'identité ou de votre passeport.",
@@ -5440,7 +3935,9 @@ var fr = {
5440
3935
  'Upload ID Front': "Télécharger le recto de la pièce d'identité",
5441
3936
  'Upload ID Back': "Télécharger le verso de la pièce d'identité",
5442
3937
  Cancel: 'Annuler',
5443
- 'Upload the back of the ID if it is not included in the front image.': "Téléchargez le verso de la pièce d'identité si ce n'est pas inclus dans l'image du recto."
3938
+ 'Upload the back of the ID if it is not included in the front image.': "Téléchargez le verso de la pièce d'identité si ce n'est pas inclus dans l'image du recto.",
3939
+ 'Camera tampering detected': 'Manipulation de la caméra détectée',
3940
+ "We're sorry, but it looks like the camera is being tampered with. Please check your device and try again by reloading the page.": 'Nous sommes désolés, mais il semble que la caméra soit manipulée. Veuillez vérifier votre appareil et réessayer en rechargeant la page.'
5444
3941
  };
5445
3942
 
5446
3943
  var it = {
@@ -5463,27 +3960,27 @@ var it = {
5463
3960
  'Scan the front of ID': 'Scansiona il fronte del documento',
5464
3961
  'Scan the back of ID': 'Scansiona il retro del documento',
5465
3962
  'Scan the ID page of passport': 'Scansione la pagina identificativa del passaporto',
5466
- 'ID Card Front': 'Fronte documento didentità',
5467
- 'ID Card Back': 'Retro documento didentità',
3963
+ 'ID Card Front': "Fronte documento d'identità",
3964
+ 'ID Card Back': "Retro documento d'identità",
5468
3965
  Passport: 'Passaporto',
5469
3966
  'Document not detected': 'Documento non rilevato',
5470
3967
  'Document is not centered': 'Documento non centrato',
5471
3968
  'Document too close please back up': 'Documento troppo vicino, allontanarlo',
5472
- 'Please hold your ID document steady': 'Tenere il documento didentità fermo',
5473
- 'Document out of focus try improving the lighting': 'Documento fuori fuoco - provare a migliorare lilluminazione',
5474
- 'ID card front detected - please flip your ID card': 'Fronte del documento didentità rilevato - Girare il documento didentità',
5475
- 'ID card back detected - please flip your ID card': 'Retro del documento didentità rilevato - Girare il documento didentità',
5476
- 'ID card detected please scan a passport instead': 'Documento didentità rilevato, scansionare un passaporto al suo posto',
5477
- 'Passport detected please scan an ID card instead': 'Passaporto rilevato, scansionare una documento didentità al suo posto',
3969
+ 'Please hold your ID document steady': "Tenere il documento d'identità fermo",
3970
+ 'Document out of focus - try improving the lighting': "Documento fuori fuoco - provare a migliorare l'illuminazione",
3971
+ 'ID card front detected - please flip your ID card': "Fronte del documento d'identità rilevato - Girare il documento d'identità",
3972
+ 'ID card back detected - please flip your ID card': "Retro del documento d'identità rilevato - Girare il documento d'identità",
3973
+ 'ID card detected please scan a passport instead': "Documento d'identità rilevato, scansionare un passaporto al suo posto",
3974
+ 'Passport detected please scan an ID card instead': "Passaporto rilevato, scansionare una documento d'identità al suo posto",
5478
3975
  'Document detected, hold still...': 'Documento rilevato, tenere fermo...',
5479
- 'ID card front detected, hold still...': 'Fronte documento didentità rilevato, tenere fermo...',
5480
- 'ID card back detected, hold still...': 'Retro documento didentità rilevato, tenere fermo...',
3976
+ 'ID card front detected, hold still...': "Fronte documento d'identità rilevato, tenere fermo...",
3977
+ 'ID card back detected, hold still...': "Retro documento d'identità rilevato, tenere fermo...",
5481
3978
  'Passport detected, hold still...': 'Passaporto rilevato, tenere fermo...',
5482
3979
  'Capturing...': 'Acquisizione...',
5483
3980
  'Capture failed!': 'Acquisizione non riuscita!',
5484
- 'Please flip your ID card...': 'Capovolgere il documento didentità',
5485
- 'ID card front captured.': 'Fronte documento didentità acquisito.',
5486
- 'ID card back captured.': 'Retro documento didentità acquisito.',
3981
+ 'Please flip your ID card...': "Capovolgere il documento d'identità",
3982
+ 'ID card front captured.': "Fronte documento d'identità acquisito.",
3983
+ 'ID card back captured.': "Retro documento d'identità acquisito.",
5487
3984
  'ID Capture Successful': 'Acquisizione documento riuscita',
5488
3985
  'Verify the entire ID was captured clearly with no glare.': 'Verificare che tutto il documento sia acquisito chiaramente e senza riflessi.',
5489
3986
  Submit: 'Invia',
@@ -5525,29 +4022,29 @@ var it = {
5525
4022
  'Uploading...': 'Caricamento...',
5526
4023
  'Upload succeeded!': 'Caricamento riuscito!',
5527
4024
  'Performing facial recognition, please hold still...': 'Riconoscimento volto in corso, tenere fermo...',
5528
- 'Display the front of your ID card...': 'Mostrare il fronte del documento didentità...',
5529
- 'Display the back of your ID card...': 'Mostrare il retro della documento didentità...',
4025
+ 'Display the front of your ID card...': "Mostrare il fronte del documento d'identità...",
4026
+ 'Display the back of your ID card...': "Mostrare il retro della documento d'identità...",
5530
4027
  'Display the ID page of your passport...': 'Mostrare la pagina identificativa del passaporto...',
5531
4028
  'Please move your face to the center...': 'Spostare il volto al centro...',
5532
- 'Searching for ID card...': 'Ricerca documento didentità in corso...',
4029
+ 'Searching for ID card...': "Ricerca documento d'identità in corso...",
5533
4030
  'Please read the following text aloud': 'Leggere il testo seguente a voce alta',
5534
- 'Video ID has been successfully captured!': 'L’ID video è stato acquisito correttamente!',
5535
- 'ID Front Image': 'Immagine fronte documento didentità',
5536
- 'ID Back Image': 'Immagine retro documento didentità',
4031
+ 'Video ID has been successfully captured!': "L'ID video è stato acquisito correttamente!",
4032
+ 'ID Front Image': "Immagine fronte documento d'identità",
4033
+ 'ID Back Image': "Immagine retro documento d'identità",
5537
4034
  "We're having some trouble.": 'Si è verificato un problema.',
5538
4035
  'On-device capture guidance failed please capture a selfie manually.': "La guida all'acquisizione sul dispositivo non è riuscita. Scattare un selfie manualmente.",
5539
4036
  'Verifying...': 'Verifica...',
5540
- 'Please capture the front of your ID card.': 'Acquisire il fronte del documento didentità.',
5541
- 'Please capture the back of your ID card.': 'Acquisire il retro del documento didentità.',
5542
- 'Please capture the front of your ID card, or the ID page of your passport.': 'Acquisire il fronte del documento didentità o la pagina identificativa del passaporto.',
5543
- 'Please capture the back of your ID card, or click Done if submitting a passport.': 'Acquisire il retro del documento didentità o fare clic su Fatto se si invia un passaporto.',
4037
+ 'Please capture the front of your ID card.': "Acquisire il fronte del documento d'identità.",
4038
+ 'Please capture the back of your ID card.': "Acquisire il retro del documento d'identità.",
4039
+ 'Please capture the front of your ID card, or the ID page of your passport.': "Acquisire il fronte del documento d'identità o la pagina identificativa del passaporto.",
4040
+ 'Please capture the back of your ID card, or click Done if submitting a passport.': "Acquisire il retro del documento d'identità o fare clic su Fatto se si invia un passaporto.",
5544
4041
  'Please capture the ID page of your passport.': 'Acquisire la pagina identificativa del passaporto.',
5545
- 'On-device capture guidance failed please capture a photo of your ID card manually.': "La guida all'acquisizione sul dispositivo non è riuscita. Acquisire una foto del documento didentità manualmente.",
4042
+ 'On-device capture guidance failed please capture a photo of your ID card manually.': "La guida all'acquisizione sul dispositivo non è riuscita. Acquisire una foto del documento d'identità manualmente.",
5546
4043
  'On-device capture guidance failed please capture a photo of your passport manually.': "La guida all'acquisizione sul dispositivo non è riuscita. Acquisire una foto del passaporto manualmente.",
5547
- 'On-device capture guidance failed please capture photos of your ID card and passport manually.': "La guida all'acquisizione sul dispositivo non è riuscita. Acquisire delle foto del documento didentità e del passaporto manualmente.",
5548
- 'On-device capture guidance failed please capture photos of your ID card or passport manually.': "La guida all'acquisizione sul dispositivo non è riuscita. Acquisire delle foto del documento didentità o del passaporto manualmente.",
4044
+ 'On-device capture guidance failed please capture photos of your ID card and passport manually.': "La guida all'acquisizione sul dispositivo non è riuscita. Acquisire delle foto del documento d'identità e del passaporto manualmente.",
4045
+ 'On-device capture guidance failed please capture photos of your ID card or passport manually.': "La guida all'acquisizione sul dispositivo non è riuscita. Acquisire delle foto del documento d'identità o del passaporto manualmente.",
5549
4046
  'Capture ID page of passport': 'Acquisisci pagina identificativa del passaporto',
5550
- 'Capture back of ID card': 'Acquisisci retro del documento didentità',
4047
+ 'Capture back of ID card': "Acquisisci retro del documento d'identità",
5551
4048
  'Downloading...': 'Download in corso...',
5552
4049
  'Accessing camera...': 'Accesso alla fotocamera...',
5553
4050
  'Camera ready': 'Fotocamera pronta',
@@ -5565,7 +4062,9 @@ var it = {
5565
4062
  'Upload ID Front': "Carica il fronte dell'ID",
5566
4063
  'Upload ID Back': "Carica il retro dell'ID",
5567
4064
  Cancel: 'Annulla',
5568
- 'Upload the back of the ID if it is not included in the front image.': "Carica il retro dell'ID se non è incluso nell'immagine del fronte.\r\n"
4065
+ 'Upload the back of the ID if it is not included in the front image.': "Carica il retro dell'ID se non è incluso nell'immagine del fronte.",
4066
+ 'Camera tampering detected': 'Manipolazione della fotocamera rilevata',
4067
+ "We're sorry, but it looks like the camera is being tampered with. Please check your device and try again by reloading the page.": 'Siamo spiacenti, ma sembra che la fotocamera stia venendo manipolata. Controlla il tuo dispositivo e riprova ricaricando la pagina.'
5569
4068
  };
5570
4069
 
5571
4070
  var ja = {
@@ -5595,7 +4094,7 @@ var ja = {
5595
4094
  'Document is not centered': 'ドキュメントが中央に合っていません',
5596
4095
  'Document too close please back up': 'ドキュメントが近すぎます。遠ざけてください',
5597
4096
  'Please hold your ID document steady': '身分証が動かないように押さえてください',
5598
- 'Document out of focus try improving the lighting': 'ドキュメントの焦点がぼやけています。照明を調節してください',
4097
+ 'Document out of focus - try improving the lighting': 'ドキュメントの焦点がぼやけています。照明を調節してください',
5599
4098
  'ID card front detected - please flip your ID card': '身分証の正面が検出されました。身分証を裏返してください',
5600
4099
  'ID card back detected - please flip your ID card': '身分証の背面が検出されました。身分証を裏返してください',
5601
4100
  'ID card detected please scan a passport instead': '身分証が検出されました。パスポートをスキャンしてください',
@@ -5690,7 +4189,9 @@ var ja = {
5690
4189
  'Upload ID Front': '身分証明書の表面をアップロード',
5691
4190
  'Upload ID Back': '身分証明書の裏面をアップロード',
5692
4191
  Cancel: 'キャンセル',
5693
- 'Upload the back of the ID if it is not included in the front image.': '表面画像に裏面が含まれていない場合は、裏面をアップロードしてください。'
4192
+ 'Upload the back of the ID if it is not included in the front image.': '表面画像に裏面が含まれていない場合は、裏面をアップロードしてください。',
4193
+ 'Camera tampering detected': 'カメラの操作が検出されました',
4194
+ "We're sorry, but it looks like the camera is being tampered with. Please check your device and try again by reloading the page.": 'カメラの操作が検出されました。デバイスを確認し、ページを再読み込みしてください。'
5694
4195
  };
5695
4196
 
5696
4197
  var pt = {
@@ -5720,7 +4221,7 @@ var pt = {
5720
4221
  'Document is not centered': 'Documento não está centralizado',
5721
4222
  'Document too close please back up': 'Documento muito próximo, recue',
5722
4223
  'Please hold your ID document steady': 'Segure seu documento de identificação com firmeza',
5723
- 'Document out of focus try improving the lighting': 'Documento fora de foco - tente melhorar a iluminação',
4224
+ 'Document out of focus - try improving the lighting': 'Documento fora de foco - tente melhorar a iluminação',
5724
4225
  'ID card front detected - please flip your ID card': 'Detectada a frente da carteira de identidade - vire a carteira de identidade',
5725
4226
  'ID card back detected - please flip your ID card': 'Detectado o verso da carteira de identidade - vire a carteira de identidade',
5726
4227
  'ID card detected please scan a passport instead': 'Detectada a carteira de identidade - escaneie um passaporte em seu lugar',
@@ -5815,7 +4316,9 @@ var pt = {
5815
4316
  'Upload ID Front': 'Carregar frente do ID',
5816
4317
  'Upload ID Back': 'Carregar verso do ID',
5817
4318
  Cancel: 'Cancelar',
5818
- 'Upload the back of the ID if it is not included in the front image.': 'Carregue o verso do ID se não estiver incluído na imagem da frente.'
4319
+ 'Upload the back of the ID if it is not included in the front image.': 'Carregue o verso do ID se não estiver incluído na imagem da frente.',
4320
+ 'Camera tampering detected': 'Manipulação da câmera detectada',
4321
+ "We're sorry, but it looks like the camera is being tampered with. Please check your device and try again by reloading the page.": 'Lamentamos, mas parece que a câmera está sendo manipulada. Verifique seu dispositivo e tente novamente recarregando a página.'
5819
4322
  };
5820
4323
 
5821
4324
  var ru = {
@@ -5940,215 +4443,1828 @@ var ru = {
5940
4443
  'Upload ID Front': 'Загрузить переднюю сторону удостоверения личности',
5941
4444
  'Upload ID Back': 'Загрузить заднюю сторону удостоверения личности',
5942
4445
  Cancel: 'Отменить',
5943
- 'Upload the back of the ID if it is not included in the front image.': 'Загрузите заднюю сторону удостоверения, если она не включена в изображение передней стороны.\r\n'
4446
+ 'Upload the back of the ID if it is not included in the front image.': 'Загрузите заднюю сторону удостоверения, если она не включена в изображение передней стороны.',
4447
+ 'Camera tampering detected': 'Обнаружена манипуляция с камерой',
4448
+ "We're sorry, but it looks like the camera is being tampered with. Please check your device and try again by reloading the page.": 'К сожалению, кажется, что камера подвергается манипуляциям. Пожалуйста, проверьте свое устройство и попробуйте снова, перезагрузив страницу.'
4449
+ };
4450
+
4451
+ var zh = {
4452
+ 'English - en': 'Chinese (Traditional) - zh',
4453
+ 'Use your device camera to capture your ID': '使用裝置相機拍攝證件',
4454
+ 'Use your iPhone as a webcam': '將 iPhone 當作網路攝影機使用',
4455
+ 'Models warming up...': '正在暖機...',
4456
+ 'Camera initializing...': '相機正在初始化...',
4457
+ 'Camera access blocked': '相機存取遭封鎖',
4458
+ 'Location access blocked': '位置存取遭封鎖',
4459
+ Continue: '繼續',
4460
+ 'Processing...': '正在處理...',
4461
+ 'Your camera permission is disabled': '已停用相機權限',
4462
+ 'This application requires access to your camera to continue. Please accept the permission once prompted by the browser. If the browser does not prompt for camera permissions you must go to settings and provide camera access to the current browser.': '此應用程式需要存取相機才能繼續。瀏覽器提示後,請接受權限。如果瀏覽器未提示相機權限,必須前往設定並為目前瀏覽器提供相機存取權限。',
4463
+ 'Your microphone permission is disabled': '已停用麥克風權限',
4464
+ 'This application requires access to your microphone to continue. Please accept the permission once prompted by the browser. If the browser does not prompt for microphone permissions you must go to settings and provide microphone access to the current browser.': '此應用程式需要存取麥克風才能繼續。瀏覽器提示後,請接受權限。如果瀏覽器未提示麥克風權限,必須前往設定並為目前瀏覽器提供麥克風存取權限。',
4465
+ 'Your location permission is disabled': '已停用位置權限',
4466
+ 'This application requires access to your location to continue. Please accept the permission once prompted by the browser. If the browser does not prompt for location permissions you must go to settings and provide location access to the current browser.': '此應用程式需要存取位置才能繼續。瀏覽器提示後,請接受權限。如果瀏覽器未提示位置權限,必須前往設定並為目前瀏覽器提供位置存取權限。',
4467
+ Retry: '重試',
4468
+ 'Scan the front of ID': '掃描證件正面',
4469
+ 'Scan the back of ID': '掃描證件背面',
4470
+ 'Scan the ID page of passport': '掃描護照的 ID 頁面',
4471
+ 'ID Card Front': '證件正面',
4472
+ 'ID Card Back': '證件背面',
4473
+ Passport: '護照',
4474
+ 'Document not detected': '未偵測到文件',
4475
+ 'Document is not centered': '文件未置中',
4476
+ 'Document too close please back up': '文件太近,請後退',
4477
+ 'Please hold your ID document steady': '請拿穩證件',
4478
+ 'Document out of focus - try improving the lighting': '文件失焦 - 請嘗試改善燈光',
4479
+ 'ID card front detected - please flip your ID card': '偵測到證件正面 - 請將證件翻面',
4480
+ 'ID card back detected - please flip your ID card': '偵測到證件背面 - 請將證件翻面',
4481
+ 'ID card detected please scan a passport instead': '偵測到證件,請掃描護照',
4482
+ 'Passport detected please scan an ID card instead': '偵測到護照,請掃描證件',
4483
+ 'Document detected, hold still...': '偵測到的文件保持不動...',
4484
+ 'ID card front detected, hold still...': '偵測到的證件正面保持不動...',
4485
+ 'ID card back detected, hold still...': '偵測到的證件背面保持不動...',
4486
+ 'Passport detected, hold still...': '偵測到的護照保持不動...',
4487
+ 'Capturing...': '正在拍攝...',
4488
+ 'Capture failed!': '拍攝失敗!',
4489
+ 'Please flip your ID card...': '請將證件翻面...',
4490
+ 'ID card front captured.': '已拍攝證件正面。',
4491
+ 'ID card back captured.': '已拍攝證件背面。',
4492
+ 'ID Capture Successful': '證件拍攝成功',
4493
+ 'Verify the entire ID was captured clearly with no glare.': '確認是否清楚拍攝整個證件,無眩光。',
4494
+ Submit: '提交',
4495
+ 'Submitting...': '正在提交...',
4496
+ 'Use your device camera to capture your face': '使用裝置相機拍攝您的臉部',
4497
+ 'Remove Sunglasses & Hat': '取下太陽眼鏡和帽子',
4498
+ 'Avoid Excessive Backlighting': '避免過度背光',
4499
+ 'Hold still for a few seconds...': '請保持不動幾秒...',
4500
+ 'Please hold still...': '請保持不動...',
4501
+ 'Look straight into the camera...': '請直視相機...',
4502
+ 'Move back...': '請後退...',
4503
+ 'Move forward...': '請前進...',
4504
+ 'Move to the center...': '請移至中心...',
4505
+ 'Waiting for face to be detected...': '正在等待臉部辨識...',
4506
+ 'Please remove your eye coverings (sunglasses eye patch etc.)...': '請取下眼睛遮蓋物(太陽眼鏡、眼罩等)...',
4507
+ 'Please remove your head coverings (hat scarf etc.)...': '請取下頭部遮蓋物(帽子、圍巾等)...',
4508
+ 'Please remove your mask...': '請脫下口罩...',
4509
+ 'Live face not detected, please try again': '未偵測到活體人臉,請再試一次',
4510
+ Exit: '退出',
4511
+ 'Face liveness has been verified!': '已驗證人臉活體!',
4512
+ Done: '完成',
4513
+ 'Could not verify your face.': '無法驗證您的臉部。',
4514
+ 'An error occurred while verifying your face.': '驗證您的臉部時發生錯誤。',
4515
+ 'Customer has been identified!': '已識別客戶!',
4516
+ 'Customer not found': '找不到客戶',
4517
+ 'Additional document capture': '其他文件拍攝',
4518
+ Next: '下一步',
4519
+ 'Please sign the box below': '請在下方的方框中簽名',
4520
+ Accept: '接受',
4521
+ Clear: '清除',
4522
+ 'Video signature has been successfully captured!': '已成功拍攝影片簽名!',
4523
+ 'Network unreachable': '網路無法連線',
4524
+ "We're having trouble reaching our services please check your connection and try again.": '無法與服務連線,請檢查連線並再試一次。',
4525
+ "We're sorry an unexpected error has occurred.": '很抱歉,發生非預期錯誤。',
4526
+ 'Document Capture': '文件拍攝',
4527
+ Capture: '拍攝',
4528
+ 'Retry capture': '重試拍攝',
4529
+ Upload: '上傳',
4530
+ 'Uploading...': '正在上傳...',
4531
+ 'Upload succeeded!': '上傳成功!',
4532
+ 'Performing facial recognition, please hold still...': '正在進行臉部辨識,請保持不動...',
4533
+ 'Display the front of your ID card...': '出示證件正面...',
4534
+ 'Display the back of your ID card...': '出示證件背面...',
4535
+ 'Display the ID page of your passport...': '出示護照的 ID 頁面...',
4536
+ 'Please move your face to the center...': '請將臉部移至中心...',
4537
+ 'Searching for ID card...': '正在搜尋證件...',
4538
+ 'Please read the following text aloud': '請大聲讀出以下文字',
4539
+ 'Video ID has been successfully captured!': '已成功拍攝影片 ID!',
4540
+ 'ID Front Image': '證件正面影像',
4541
+ 'ID Back Image': '證件背面影像',
4542
+ "We're having some trouble.": '發生一些問題。',
4543
+ 'On-device capture guidance failed please capture a selfie manually.': '裝置上拍攝引導失敗,請手動拍攝自拍照',
4544
+ 'Verifying...': '正在驗證...',
4545
+ 'Please capture the front of your ID card.': '請拍攝證件正面。',
4546
+ 'Please capture the back of your ID card.': '請拍攝證件背面。',
4547
+ 'Please capture the front of your ID card, or the ID page of your passport.': '請拍攝證件正面或護照的 ID 頁面。',
4548
+ 'Please capture the back of your ID card, or click Done if submitting a passport.': '請拍攝證件背面,或者如果提交護照,請按一下「完成」。',
4549
+ 'Please capture the ID page of your passport.': '請拍攝護照的 ID 頁面。',
4550
+ 'On-device capture guidance failed please capture a photo of your ID card manually.': '裝置上拍攝引導失敗,請手動拍攝證件的照片。',
4551
+ 'On-device capture guidance failed please capture a photo of your passport manually.': '裝置上拍攝引導失敗,請手動拍攝護照的照片。',
4552
+ 'On-device capture guidance failed please capture photos of your ID card and passport manually.': '裝置上拍攝引導失敗,請手動拍攝證件和護照的照片。',
4553
+ 'On-device capture guidance failed please capture photos of your ID card or passport manually.': '裝置上拍攝引導失敗,請手動拍攝證件或護照的照片。',
4554
+ 'Capture ID page of passport': '拍攝護照的 ID 頁面',
4555
+ 'Capture back of ID card': '拍攝證件背面',
4556
+ 'Downloading...': '正在下載...',
4557
+ 'Accessing camera...': '正在存取相機...',
4558
+ 'Camera ready': '相機就緒',
4559
+ 'Loading guided capture experience...': '正在載入引導式拍攝體驗...',
4560
+ 'Guided capture experience ready': '引導式拍攝體驗就緒',
4561
+ "Let's Go!": '開始!',
4562
+ 'We are having trouble identifying the correct side of your id do you want to continue with capture anyway?': '無法識別證件的正確一面,是否仍要繼續拍攝?',
4563
+ OK: '確定',
4564
+ 'Capture with Camera': '使用相机拍摄',
4565
+ OR: '或者',
4566
+ 'Upload from Storage': '从存储中上传',
4567
+ 'Select ID Type': '选择身份证类型',
4568
+ 'ID Card': '身份证',
4569
+ 'Upload Passport': '上传护照',
4570
+ 'Upload ID Front': '上传身份证正面',
4571
+ 'Upload ID Back': '上传身份证背面',
4572
+ Cancel: '取消',
4573
+ 'Upload the back of the ID if it is not included in the front image.': '如果正面照片没有包含身份证背面,请上传背面照片。',
4574
+ 'Camera tampering detected': '檢測到相機被篡改',
4575
+ "We're sorry, but it looks like the camera is being tampered with. Please check your device and try again by reloading the page.": '很抱歉,看起來相機被篡改了。請檢查您的設備並重新載入頁面。'
4576
+ };
4577
+
4578
+ var resources = {
4579
+ en: {
4580
+ translation: en
4581
+ },
4582
+ es: {
4583
+ translation: es
4584
+ },
4585
+ de: {
4586
+ translation: de
4587
+ },
4588
+ fr: {
4589
+ translation: fr
4590
+ },
4591
+ it: {
4592
+ translation: it
4593
+ },
4594
+ ja: {
4595
+ translation: ja
4596
+ },
4597
+ pt: {
4598
+ translation: pt
4599
+ },
4600
+ ru: {
4601
+ translation: ru
4602
+ },
4603
+ zh: {
4604
+ translation: zh
4605
+ }
4606
+ };
4607
+ function initializeI18n() {
4608
+ void i18n.use(LanguageDetector).use(initReactI18next).init({
4609
+ resources: resources,
4610
+ detection: {
4611
+ caches: []
4612
+ },
4613
+ fallbackLng: 'en',
4614
+ debug: false,
4615
+ interpolation: {
4616
+ escapeValue: false
4617
+ }
4618
+ });
4619
+ }
4620
+ var useLanguage = function useLanguage(lang) {
4621
+ var i18n = useTranslation().i18n;
4622
+ useEffect(function () {
4623
+ if (lang !== 'auto') {
4624
+ void i18n.changeLanguage(lang);
4625
+ } else {
4626
+ void i18n.changeLanguage(); // call without argument to use detection
4627
+ }
4628
+ }, [i18n, lang]);
4629
+ };
4630
+ function evaluateVerbiage(t, currentLanguage, verbiage, fallback) {
4631
+ if (typeof verbiage === 'string') return verbiage;
4632
+ if (typeof verbiage === 'object') {
4633
+ var translations = verbiage;
4634
+ if (translations[currentLanguage]) return translations[currentLanguage];
4635
+ var nonLocaleLang = currentLanguage.split('-')[0];
4636
+ if (translations[nonLocaleLang]) return translations[nonLocaleLang];
4637
+ }
4638
+ return t(fallback);
4639
+ }
4640
+ function useVerbiage(verbiage, fallback) {
4641
+ var _a = useTranslation(),
4642
+ t = _a.t,
4643
+ i18n = _a.i18n;
4644
+ return useMemo(function () {
4645
+ return evaluateVerbiage(t, i18n.language, verbiage, fallback);
4646
+ }, [fallback, i18n.language, t, verbiage]);
4647
+ }
4648
+ function useTranslations(verbiage, fallbacks) {
4649
+ var _a = useTranslation(),
4650
+ t = _a.t,
4651
+ i18n = _a.i18n;
4652
+ return useMemo(function () {
4653
+ return _assign(_assign({}, verbiage), Object.keys(fallbacks).reduce(function (result, key) {
4654
+ var _a;
4655
+ return _assign(_assign({}, result), (_a = {}, _a[key] = evaluateVerbiage(t, i18n.language, verbiage === null || verbiage === void 0 ? void 0 : verbiage[key], fallbacks[key]), _a));
4656
+ }, {}));
4657
+ }, [fallbacks, i18n.language, t, verbiage]);
4658
+ }
4659
+
4660
+ var initialState$5 = {
4661
+ videoRef: {
4662
+ current: null
4663
+ },
4664
+ videoLoaded: false,
4665
+ videoStream: null,
4666
+ videoDevice: null,
4667
+ isRearFacing: false,
4668
+ camera: null,
4669
+ cameraReady: false,
4670
+ cameraAccessDenied: false,
4671
+ iphoneContinuityCameraAvailable: false,
4672
+ iphoneContinuityCameraDenied: false,
4673
+ preferIphoneContinuityCamera: true,
4674
+ cameraTamperingDetected: false,
4675
+ audioStream: null,
4676
+ microphoneReady: false,
4677
+ microphoneAccessDenied: false
4678
+ };
4679
+ var createCameraStore = function createCameraStore(config) {
4680
+ var store = createStore(function (set, get) {
4681
+ return _assign(_assign(_assign({}, initialState$5), config), {
4682
+ reset: function reset() {
4683
+ return set(_assign(_assign({}, initialState$5), config));
4684
+ },
4685
+ setConfig: function setConfig(config) {
4686
+ return set(config);
4687
+ },
4688
+ onVideoMounted: function onVideoMounted(e) {
4689
+ var _a;
4690
+ var selectedVideoStreamId = (_a = get().videoStream) === null || _a === void 0 ? void 0 : _a.id;
4691
+ if (!selectedVideoStreamId) return;
4692
+ var srcObject = e.currentTarget.srcObject;
4693
+ if (srcObject.id === selectedVideoStreamId) {
4694
+ set({
4695
+ videoLoaded: true
4696
+ });
4697
+ } else {
4698
+ set({
4699
+ cameraTamperingDetected: true
4700
+ });
4701
+ }
4702
+ },
4703
+ setIphoneContinuityCameraAllowed: function setIphoneContinuityCameraAllowed(value) {
4704
+ return set({
4705
+ preferIphoneContinuityCamera: value
4706
+ });
4707
+ },
4708
+ requestCameraAccess: function requestCameraAccess() {
4709
+ return __awaiter(this, void 0, void 0, function () {
4710
+ var _a, videoRef, releaseCameraAccess, preferFrontFacingCamera, preferIphoneContinuityCamera, iphoneContinuityCameraDenied, availableCameras, selectedCamera, platform_1, iphoneContinuityCamera, constraints, stream_1, e_1, e_2, handleStreamEnded_1, videoTrack_1, camera_1, e_3;
4711
+ var _b, _c, _d;
4712
+ return __generator(this, function (_e) {
4713
+ switch (_e.label) {
4714
+ case 0:
4715
+ _a = get(), videoRef = _a.videoRef, releaseCameraAccess = _a.releaseCameraAccess, preferFrontFacingCamera = _a.preferFrontFacingCamera, preferIphoneContinuityCamera = _a.preferIphoneContinuityCamera, iphoneContinuityCameraDenied = _a.iphoneContinuityCameraDenied;
4716
+ releaseCameraAccess();
4717
+ _e.label = 1;
4718
+ case 1:
4719
+ _e.trys.push([1, 11,, 12]);
4720
+ return [4 /*yield*/, listAvailableCameras()];
4721
+ case 2:
4722
+ availableCameras = _e.sent();
4723
+ selectedCamera = void 0;
4724
+ debug('availableCameras', availableCameras);
4725
+ platform_1 = getPlatform();
4726
+ debug('platformDetails', platform_1);
4727
+ if (!iphoneContinuityCameraDenied && (!(platform_1 === null || platform_1 === void 0 ? void 0 : platform_1.os) || platform_1.os.family === 'OS X')) {
4728
+ iphoneContinuityCamera = availableCameras.find(function (deviceInfo) {
4729
+ return cameraLabelMatches(deviceInfo, 'iphone');
4730
+ });
4731
+ set({
4732
+ iphoneContinuityCameraAvailable: !!iphoneContinuityCamera
4733
+ });
4734
+ if (iphoneContinuityCamera && preferIphoneContinuityCamera) {
4735
+ selectedCamera = iphoneContinuityCamera;
4736
+ }
4737
+ } else if (((_b = platform_1 === null || platform_1 === void 0 ? void 0 : platform_1.os) === null || _b === void 0 ? void 0 : _b.family) === 'Android' || availableCameras.every(function (c) {
4738
+ return c.label.startsWith('camera2 ');
4739
+ })) {
4740
+ availableCameras = availableCameras.sort(function (a, b) {
4741
+ return a.label.toLowerCase().localeCompare(b.label.toLowerCase());
4742
+ });
4743
+ debug('cameras have been sorted', availableCameras);
4744
+ }
4745
+ if (preferFrontFacingCamera) {
4746
+ selectedCamera = availableCameras.find(function (deviceInfo) {
4747
+ return cameraLabelMatches(deviceInfo, frontCameraLabels);
4748
+ });
4749
+ }
4750
+ selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
4751
+ return cameraLabelMatches(deviceInfo, 'backtriplecamera');
4752
+ }));
4753
+ selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
4754
+ return cameraLabelMatches(deviceInfo, 'backdualcamera');
4755
+ }));
4756
+ selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
4757
+ return cameraLabelMatches(deviceInfo, rearCameraLabels) && !cameraLabelMatches(deviceInfo, backUltraWideCameraLabels);
4758
+ }));
4759
+ selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
4760
+ return cameraLabelMatches(deviceInfo, rearCameraLabels);
4761
+ }));
4762
+ // on iOS, the front facing camera always is at the first position in the list, so we skip it if all else fails.
4763
+ if (!preferFrontFacingCamera && ((_c = platform_1 === null || platform_1 === void 0 ? void 0 : platform_1.os) === null || _c === void 0 ? void 0 : _c.family) === 'iOS' && availableCameras.length > 0) {
4764
+ selectedCamera || (selectedCamera = availableCameras[1]);
4765
+ }
4766
+ selectedCamera || (selectedCamera = availableCameras[0]);
4767
+ debug('selectedCamera', selectedCamera);
4768
+ set({
4769
+ videoDevice: selectedCamera
4770
+ });
4771
+ constraints = {
4772
+ audio: false,
4773
+ video: {
4774
+ deviceId: {
4775
+ exact: selectedCamera.deviceId
4776
+ },
4777
+ width: {
4778
+ ideal: config.maxVideoWidth
4779
+ },
4780
+ aspectRatio: 1.777777778,
4781
+ frameRate: {}
4782
+ }
4783
+ };
4784
+ if (config.maxFps) {
4785
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
4786
+ // @ts-ignore
4787
+ constraints.video.frameRate = {
4788
+ max: config.maxFps
4789
+ };
4790
+ }
4791
+ stream_1 = null;
4792
+ _e.label = 3;
4793
+ case 3:
4794
+ _e.trys.push([3, 5,, 6]);
4795
+ debug('obtaining camera access with constraints', constraints);
4796
+ return [4 /*yield*/, navigator.mediaDevices.getUserMedia(constraints)];
4797
+ case 4:
4798
+ stream_1 = _e.sent();
4799
+ return [3 /*break*/, 6];
4800
+ case 5:
4801
+ e_1 = _e.sent();
4802
+ if (e_1.name === 'NotAllowedError') {
4803
+ if (preferIphoneContinuityCamera) {
4804
+ set({
4805
+ iphoneContinuityCameraAvailable: false,
4806
+ iphoneContinuityCameraDenied: true
4807
+ });
4808
+ } else {
4809
+ set({
4810
+ cameraAccessDenied: true
4811
+ });
4812
+ }
4813
+ return [2 /*return*/];
4814
+ }
4815
+ return [3 /*break*/, 6];
4816
+ case 6:
4817
+ if (!!stream_1) return [3 /*break*/, 10];
4818
+ _e.label = 7;
4819
+ case 7:
4820
+ _e.trys.push([7, 9,, 10]);
4821
+ return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
4822
+ audio: false,
4823
+ video: true
4824
+ })];
4825
+ case 8:
4826
+ stream_1 = _e.sent();
4827
+ debug('opened stream with no width and height constraints');
4828
+ return [3 /*break*/, 10];
4829
+ case 9:
4830
+ e_2 = _e.sent();
4831
+ debug('cannot open stream at all', e_2);
4832
+ return [3 /*break*/, 10];
4833
+ case 10:
4834
+ if (!stream_1) {
4835
+ error('failed to open camera');
4836
+ throw new Error('failed to open camera: ');
4837
+ }
4838
+ debug('camera access granted with constraints', constraints);
4839
+ handleStreamEnded_1 = function handleStreamEnded_1() {
4840
+ if (preferIphoneContinuityCamera && get().iphoneContinuityCameraAvailable) {
4841
+ debug('someone unplugged the continuity camera');
4842
+ set({
4843
+ videoStream: null,
4844
+ videoDevice: null,
4845
+ cameraReady: false,
4846
+ iphoneContinuityCameraAvailable: false,
4847
+ iphoneContinuityCameraDenied: true
4848
+ });
4849
+ get().requestCameraAccess();
4850
+ } else {
4851
+ debug('someone unplugged the webcam');
4852
+ releaseCameraAccess();
4853
+ set({
4854
+ videoStream: null,
4855
+ videoDevice: null,
4856
+ videoLoaded: false,
4857
+ cameraReady: false,
4858
+ cameraAccessDenied: true
4859
+ });
4860
+ }
4861
+ };
4862
+ (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.addEventListener('ended', handleStreamEnded_1);
4863
+ videoTrack_1 = stream_1.getVideoTracks()[0];
4864
+ videoTrack_1.onended = handleStreamEnded_1;
4865
+ camera_1 = obtainCameraAccess(stream_1, selectedCamera.label, videoRef.current);
4866
+ setTimeout(function () {
4867
+ // iOS 17 has a strange behavior where the video track flickers between muted and unmuted
4868
+ // when the camera access is being requested. This delay is a workaround for that.
4869
+ videoTrack_1.onmute = function () {
4870
+ if (videoTrack_1.readyState !== 'live') handleStreamEnded_1();
4871
+ };
4872
+ set({
4873
+ camera: camera_1,
4874
+ cameraReady: true,
4875
+ cameraAccessDenied: false,
4876
+ isRearFacing: camera_1.isRearFacing,
4877
+ videoStream: stream_1
4878
+ });
4879
+ }, 500);
4880
+ return [3 /*break*/, 12];
4881
+ case 11:
4882
+ e_3 = _e.sent();
4883
+ if (e_3.name === 'NotAllowedError') {
4884
+ error('camera access has been blocked by the user', e_3);
4885
+ set({
4886
+ cameraAccessDenied: true
4887
+ });
4888
+ } else {
4889
+ error('camera access encountered some other error', e_3);
4890
+ throw e_3;
4891
+ }
4892
+ return [3 /*break*/, 12];
4893
+ case 12:
4894
+ return [2 /*return*/];
4895
+ }
4896
+ });
4897
+ });
4898
+ },
4899
+ releaseCameraAccess: function releaseCameraAccess() {
4900
+ return __awaiter(this, void 0, void 0, function () {
4901
+ var camera;
4902
+ return __generator(this, function (_a) {
4903
+ camera = get().camera;
4904
+ if (!camera) return [2 /*return*/];
4905
+ camera.release();
4906
+ set({
4907
+ camera: null,
4908
+ cameraReady: false,
4909
+ cameraAccessDenied: false,
4910
+ videoDevice: null,
4911
+ videoStream: null,
4912
+ videoLoaded: false
4913
+ });
4914
+ return [2 /*return*/];
4915
+ });
4916
+ });
4917
+ },
4918
+ requestMicrophoneAccess: function requestMicrophoneAccess() {
4919
+ return __awaiter(this, void 0, void 0, function () {
4920
+ var stream_2, e_4;
4921
+ return __generator(this, function (_a) {
4922
+ switch (_a.label) {
4923
+ case 0:
4924
+ get().releaseMicrophoneAccess();
4925
+ _a.label = 1;
4926
+ case 1:
4927
+ _a.trys.push([1, 3,, 4]);
4928
+ return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
4929
+ audio: true,
4930
+ video: false
4931
+ })
4932
+ // iOS 17 has a strange behavior where the video track flickers between muted and unmuted
4933
+ // when the camera access is being requested. This delay is a workaround for that.
4934
+ ];
4935
+ case 2:
4936
+ stream_2 = _a.sent();
4937
+ // iOS 17 has a strange behavior where the video track flickers between muted and unmuted
4938
+ // when the camera access is being requested. This delay is a workaround for that.
4939
+ setTimeout(function () {
4940
+ set({
4941
+ audioStream: stream_2,
4942
+ microphoneReady: true,
4943
+ microphoneAccessDenied: false
4944
+ });
4945
+ var handleStreamEnded = function handleStreamEnded() {
4946
+ set({
4947
+ microphoneReady: false,
4948
+ microphoneAccessDenied: true
4949
+ });
4950
+ };
4951
+ var track = stream_2.getAudioTracks()[0];
4952
+ track.onended = handleStreamEnded;
4953
+ track.onmute = function () {
4954
+ if (track.readyState !== 'live') handleStreamEnded();
4955
+ };
4956
+ }, 500);
4957
+ return [3 /*break*/, 4];
4958
+ case 3:
4959
+ e_4 = _a.sent();
4960
+ debug('failed to open microphone', e_4);
4961
+ set({
4962
+ microphoneAccessDenied: true
4963
+ });
4964
+ return [3 /*break*/, 4];
4965
+ case 4:
4966
+ return [2 /*return*/];
4967
+ }
4968
+ });
4969
+ });
4970
+ },
4971
+ releaseMicrophoneAccess: function releaseMicrophoneAccess() {
4972
+ var _a;
4973
+ var audioStream = get().audioStream;
4974
+ (_a = audioStream === null || audioStream === void 0 ? void 0 : audioStream.stop) === null || _a === void 0 ? void 0 : _a.call(audioStream);
4975
+ audioStream === null || audioStream === void 0 ? void 0 : audioStream.getAudioTracks().forEach(function (track) {
4976
+ var _a;
4977
+ (_a = track.stop) === null || _a === void 0 ? void 0 : _a.call(track);
4978
+ });
4979
+ set({
4980
+ audioStream: null,
4981
+ microphoneReady: false,
4982
+ microphoneAccessDenied: false
4983
+ });
4984
+ }
4985
+ });
4986
+ });
4987
+ if (config.requestAccessAutomatically) {
4988
+ void store.getState().requestCameraAccess();
4989
+ }
4990
+ return _assign(_assign({}, store), {
4991
+ destroy: function destroy() {
4992
+ store.getState().releaseCameraAccess();
4993
+ store.getState().releaseMicrophoneAccess();
4994
+ }
4995
+ });
5944
4996
  };
4997
+ var CameraStoreContext = /*#__PURE__*/createContext(undefined);
4998
+ function CameraStoreProvider(_a) {
4999
+ var children = _a.children,
5000
+ _b = _a.requestAccessAutomatically,
5001
+ requestAccessAutomatically = _b === void 0 ? true : _b,
5002
+ _c = _a.preferIphoneContinuityCamera,
5003
+ preferIphoneContinuityCamera = _c === void 0 ? true : _c,
5004
+ _d = _a.preferFrontFacingCamera,
5005
+ preferFrontFacingCamera = _d === void 0 ? false : _d,
5006
+ _e = _a.maxVideoWidth,
5007
+ maxVideoWidth = _e === void 0 ? 1920 : _e,
5008
+ maxFps = _a.maxFps,
5009
+ onCameraAccessDenied = _a.onCameraAccessDenied,
5010
+ onCameraTamperingDetected = _a.onCameraTamperingDetected,
5011
+ onMicrophoneAccessDenied = _a.onMicrophoneAccessDenied,
5012
+ _f = _a.requireMicrophoneAccess,
5013
+ requireMicrophoneAccess = _f === void 0 ? false : _f,
5014
+ _g = _a.classNames,
5015
+ classNames = _g === void 0 ? {} : _g,
5016
+ _h = _a.verbiage,
5017
+ verbiage = _h === void 0 ? {} : _h;
5018
+ var videoRef = useRef(null);
5019
+ var store = useRef();
5020
+ store.current || (store.current = createCameraStore({
5021
+ videoRef: videoRef,
5022
+ requestAccessAutomatically: requestAccessAutomatically,
5023
+ preferIphoneContinuityCamera: preferIphoneContinuityCamera,
5024
+ preferFrontFacingCamera: preferFrontFacingCamera,
5025
+ maxVideoWidth: maxVideoWidth,
5026
+ maxFps: maxFps,
5027
+ onCameraAccessDenied: onCameraAccessDenied,
5028
+ onMicrophoneAccessDenied: onMicrophoneAccessDenied,
5029
+ requireMicrophoneAccess: requireMicrophoneAccess
5030
+ }));
5031
+ useEffect(function () {
5032
+ var _a, _b, _c;
5033
+ var state = (_a = store.current) === null || _a === void 0 ? void 0 : _a.getState();
5034
+ if (!state) return;
5035
+ if (preferIphoneContinuityCamera !== (state === null || state === void 0 ? void 0 : state.preferIphoneContinuityCamera) || preferFrontFacingCamera !== (state === null || state === void 0 ? void 0 : state.preferFrontFacingCamera)) {
5036
+ (_b = store.current) === null || _b === void 0 ? void 0 : _b.setState({
5037
+ preferIphoneContinuityCamera: preferIphoneContinuityCamera,
5038
+ preferFrontFacingCamera: preferFrontFacingCamera
5039
+ });
5040
+ (_c = store.current) === null || _c === void 0 ? void 0 : _c.getState().requestCameraAccess();
5041
+ }
5042
+ }, [preferFrontFacingCamera, preferIphoneContinuityCamera]);
5043
+ useEffect(function () {
5044
+ var _a;
5045
+ if (requireMicrophoneAccess) {
5046
+ (_a = store.current) === null || _a === void 0 ? void 0 : _a.getState().requestMicrophoneAccess();
5047
+ }
5048
+ }, [requireMicrophoneAccess]);
5049
+ useEffect(function () {
5050
+ return function () {
5051
+ var _a;
5052
+ return (_a = store.current) === null || _a === void 0 ? void 0 : _a.destroy();
5053
+ };
5054
+ }, []);
5055
+ return /*#__PURE__*/React__default.createElement(CameraStoreContext.Provider, {
5056
+ value: store.current
5057
+ }, /*#__PURE__*/React__default.createElement(CameraTamperSeal, {
5058
+ onCameraTamperingDetected: onCameraTamperingDetected,
5059
+ classNames: classNames.cameraTamperSeal,
5060
+ verbiage: verbiage.cameraTamperSeal
5061
+ }, children));
5062
+ }
5063
+ function CameraTamperSeal(_a) {
5064
+ var children = _a.children,
5065
+ onCameraTamperingDetected = _a.onCameraTamperingDetected,
5066
+ _b = _a.classNames,
5067
+ classNames = _b === void 0 ? {} : _b,
5068
+ _c = _a.verbiage,
5069
+ rawVerbiage = _c === void 0 ? {} : _c;
5070
+ var cameraTamperingDetected = useCameraStore().cameraTamperingDetected;
5071
+ var _d = useTranslations(rawVerbiage, {
5072
+ headingText: 'Camera tampering detected',
5073
+ messageText: "We're sorry, but it looks like the camera is being tampered with. Please check your device and try again by reloading the page."
5074
+ }),
5075
+ headingText = _d.headingText,
5076
+ messageText = _d.messageText;
5077
+ var onCameraTamperingDetectedRef = useRef(onCameraTamperingDetected);
5078
+ useEffect(function () {
5079
+ onCameraTamperingDetectedRef.current = onCameraTamperingDetected;
5080
+ }, [onCameraTamperingDetected]);
5081
+ useEffect(function () {
5082
+ var _a;
5083
+ if (cameraTamperingDetected) (_a = onCameraTamperingDetectedRef.current) === null || _a === void 0 ? void 0 : _a.call(onCameraTamperingDetectedRef);
5084
+ }, [cameraTamperingDetected]);
5085
+ if (!cameraTamperingDetected) return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, children);
5086
+ return /*#__PURE__*/React__default.createElement(OverlayContainer, {
5087
+ className: classNames.container
5088
+ }, /*#__PURE__*/React__default.createElement(StyledOverlayInner$4, {
5089
+ className: classNames.inner
5090
+ }, /*#__PURE__*/React__default.createElement(StyledOverlayHeading, {
5091
+ className: classNames.heading
5092
+ }, headingText), /*#__PURE__*/React__default.createElement("p", {
5093
+ className: classNames.message
5094
+ }, messageText)));
5095
+ }
5096
+ var StyledOverlayInner$4 = styled(OverlayInner$2)(templateObject_1$H || (templateObject_1$H = __makeTemplateObject(["\n justify-content: center;\n"], ["\n justify-content: center;\n"])));
5097
+ var StyledOverlayHeading = styled.h3(templateObject_2$A || (templateObject_2$A = __makeTemplateObject(["\n margin-bottom: 8px;\n"], ["\n margin-bottom: 8px;\n"])));
5098
+ function useCameraStore(selector) {
5099
+ var store = useContext(CameraStoreContext);
5100
+ if (!store) throw new Error('useCameraStore cannot be used without Provider');
5101
+ return useStore(store, selector);
5102
+ }
5103
+ var templateObject_1$H, templateObject_2$A;
5104
+
5105
+ var DocumentDetectionModelContext = /*#__PURE__*/createContext({
5106
+ startDocumentDetection: function startDocumentDetection() {
5107
+ return null;
5108
+ },
5109
+ stopDocumentDetection: function stopDocumentDetection() {
5110
+ return null;
5111
+ },
5112
+ loadDocumentDetectionModel: function loadDocumentDetectionModel() {
5113
+ return null;
5114
+ },
5115
+ documentDetectionModelReady: false,
5116
+ documentDetectionModelDownloadProgress: 0,
5117
+ documentDetectionModelError: null,
5118
+ onDocumentDetected: function onDocumentDetected() {
5119
+ return null;
5120
+ },
5121
+ detectionTime: 0,
5122
+ documentDetectionThresholds: {},
5123
+ setDocumentDetectionThresholds: function setDocumentDetectionThresholds() {
5124
+ return null;
5125
+ },
5126
+ documentDetectionBoundaries: defaultDocumentDetectionBoundaries,
5127
+ setDocumentDetectionBoundaries: function setDocumentDetectionBoundaries() {
5128
+ return null;
5129
+ },
5130
+ documentDetectionLastPredictionCanvas: {
5131
+ current: null
5132
+ },
5133
+ clearDocumentDetectionLastPredictionCanvas: function clearDocumentDetectionLastPredictionCanvas() {
5134
+ return null;
5135
+ }
5136
+ });
5137
+ function DocumentDetectionModelProvider(_a) {
5138
+ var _this = this;
5139
+ var _b = _a.autoStart,
5140
+ autoStart = _b === void 0 ? true : _b,
5141
+ children = _a.children,
5142
+ _c = _a.throttleMs,
5143
+ throttleMs = _c === void 0 ? 16 : _c,
5144
+ _d = _a.delayAfterStartMs,
5145
+ delayAfterStartMs = _d === void 0 ? 0 : _d,
5146
+ _e = _a.documentDetectionModelPath,
5147
+ documentDetectionModelPath = _e === void 0 ? defaultDocumentDetectorModelPath : _e,
5148
+ _f = _a.documentDetectionModelScoreThreshold,
5149
+ documentDetectionModelScoreThreshold = _f === void 0 ? defaultDocumentDetectionScoreThreshold : _f,
5150
+ _g = _a.documentDetectionModelLoadTimeoutMs,
5151
+ documentDetectionModelLoadTimeoutMs = _g === void 0 ? defaultDocumentDetectionModelLoadTimeoutMs : _g,
5152
+ onDocumentDetectionModelError = _a.onDocumentDetectionModelError,
5153
+ _h = _a.shouldLoadModels,
5154
+ shouldLoadModelsProp = _h === void 0 ? true : _h;
5155
+ var _j = useCameraStore(),
5156
+ videoRef = _j.videoRef,
5157
+ videoLoaded = _j.videoLoaded,
5158
+ cameraReady = _j.cameraReady;
5159
+ var lastPredictionCanvas = useRef(null);
5160
+ var onPredictionHandler = useRef();
5161
+ var _k = useState({}),
5162
+ documentDetectionThresholds = _k[0],
5163
+ setDocumentDetectionThresholds = _k[1];
5164
+ var _l = useState(defaultDocumentDetectionBoundaries),
5165
+ documentDetectionBoundaries = _l[0],
5166
+ setDocumentDetectionBoundaries = _l[1];
5167
+ var _m = useState(0),
5168
+ timesAllZero = _m[0],
5169
+ setTimesAllZero = _m[1];
5170
+ var _o = useState(0),
5171
+ canvasKey = _o[0],
5172
+ setCanvasKey = _o[1];
5173
+ var stopDetection = useRef(0);
5174
+ var _p = useState(shouldLoadModelsProp),
5175
+ shouldLoadModels = _p[0],
5176
+ setShouldLoadModels = _p[1];
5177
+ var load = useCallback(function () {
5178
+ return setShouldLoadModels(true);
5179
+ }, []);
5180
+ var _q = useLoadDocumentDetector({
5181
+ modelPath: documentDetectionModelPath,
5182
+ modelLoadTimeoutMs: documentDetectionModelLoadTimeoutMs,
5183
+ scoreThreshold: documentDetectionModelScoreThreshold,
5184
+ onModelError: onDocumentDetectionModelError,
5185
+ videoRef: videoRef,
5186
+ shouldLoadModels: shouldLoadModels
5187
+ }),
5188
+ ready = _q.ready,
5189
+ modelDownloadProgress = _q.modelDownloadProgress,
5190
+ modelError = _q.modelError,
5191
+ setModelError = _q.setModelError;
5192
+ var _r = useFrameLoop(useCallback(function (frameId, timeRunning) {
5193
+ return __awaiter(_this, void 0, void 0, function () {
5194
+ var stopDetectionAtStart, vw, vh, ctx, prediction, processedPrediction;
5195
+ var _a;
5196
+ return __generator(this, function (_b) {
5197
+ switch (_b.label) {
5198
+ case 0:
5199
+ if (!videoLoaded || !cameraReady || !ready || !videoRef.current || !lastPredictionCanvas.current) return [2 /*return*/];
5200
+ stopDetectionAtStart = stopDetection.current;
5201
+ vw = videoRef.current.videoWidth;
5202
+ vh = videoRef.current.videoHeight;
5203
+ lastPredictionCanvas.current.width = vw;
5204
+ lastPredictionCanvas.current.height = vh;
5205
+ ctx = lastPredictionCanvas.current.getContext('2d');
5206
+ if (!(ctx && videoRef.current.readyState === 4)) return [3 /*break*/, 3];
5207
+ if (stopDetectionAtStart !== stopDetection.current) return [2 /*return*/];
5208
+ ctx.drawImage(videoRef.current, 0, 0, vw, vh);
5209
+ return [4 /*yield*/, makeDocumentDetectorPrediction(lastPredictionCanvas.current)];
5210
+ case 1:
5211
+ prediction = _b.sent();
5212
+ if (!prediction) return [3 /*break*/, 3];
5213
+ processedPrediction = processDocumentDetectorPrediction(prediction, documentDetectionThresholds, documentDetectionBoundaries);
5214
+ processedPrediction.frameId = frameId;
5215
+ setLastDetectionAt(new Date().getTime());
5216
+ debug(processedPrediction);
5217
+ if (processedPrediction.allZero) setTimesAllZero(function (n) {
5218
+ return n + 1;
5219
+ });
5220
+ if (stopDetectionAtStart !== stopDetection.current) return [2 /*return*/];
5221
+ if (timeRunning < delayAfterStartMs) return [2 /*return*/];
5222
+ return [4 /*yield*/, (_a = onPredictionHandler.current) === null || _a === void 0 ? void 0 : _a.call(onPredictionHandler, processedPrediction)];
5223
+ case 2:
5224
+ _b.sent();
5225
+ _b.label = 3;
5226
+ case 3:
5227
+ return [2 /*return*/];
5228
+ }
5229
+ });
5230
+ });
5231
+ }, [cameraReady, delayAfterStartMs, documentDetectionBoundaries, documentDetectionThresholds, ready, videoLoaded, videoRef]), {
5232
+ throttleMs: throttleMs,
5233
+ autoStart: autoStart
5234
+ }),
5235
+ start = _r.start,
5236
+ stop = _r.stop;
5237
+ useEffect(function setErrorIfAllZero() {
5238
+ if (timesAllZero >= 2) {
5239
+ setModelError(new Error('model is returning all zeroes'));
5240
+ }
5241
+ }, [setModelError, timesAllZero]);
5242
+ var onDocumentDetected = useCallback(function (handler) {
5243
+ onPredictionHandler.current = handler;
5244
+ }, []);
5245
+ var clearDocumentDetectionLastPredictionCanvas = useCallback(function () {
5246
+ stopDetection.current += 1;
5247
+ setCanvasKey(function (n) {
5248
+ return n + 1;
5249
+ });
5250
+ }, []);
5251
+ var value = useMemo(function () {
5252
+ return {
5253
+ startDocumentDetection: start,
5254
+ stopDocumentDetection: stop,
5255
+ loadDocumentDetectionModel: load,
5256
+ documentDetectionModelReady: ready,
5257
+ documentDetectionModelError: modelError,
5258
+ documentDetectionModelDownloadProgress: modelDownloadProgress,
5259
+ onDocumentDetected: onDocumentDetected,
5260
+ detectionTime: lastDetectionTime,
5261
+ documentDetectionThresholds: documentDetectionThresholds,
5262
+ setDocumentDetectionThresholds: setDocumentDetectionThresholds,
5263
+ documentDetectionBoundaries: documentDetectionBoundaries,
5264
+ setDocumentDetectionBoundaries: setDocumentDetectionBoundaries,
5265
+ documentDetectionLastPredictionCanvas: lastPredictionCanvas,
5266
+ clearDocumentDetectionLastPredictionCanvas: clearDocumentDetectionLastPredictionCanvas
5267
+ };
5268
+ }, [start, stop, load, ready, modelError, modelDownloadProgress, onDocumentDetected, documentDetectionThresholds, documentDetectionBoundaries, clearDocumentDetectionLastPredictionCanvas]);
5269
+ return /*#__PURE__*/React.createElement(DocumentDetectionModelContext.Provider, {
5270
+ value: value
5271
+ }, /*#__PURE__*/React.createElement(InvisibleCanvas, {
5272
+ key: canvasKey,
5273
+ ref: lastPredictionCanvas
5274
+ }), children);
5275
+ }
5945
5276
 
5946
- var zh = {
5947
- 'English - en': 'Chinese (Traditional) - zh',
5948
- 'Use your device camera to capture your ID': '使用裝置相機拍攝證件',
5949
- 'Use your iPhone as a webcam': '將 iPhone 當作網路攝影機使用',
5950
- 'Models warming up...': '正在暖機...',
5951
- 'Camera initializing...': '相機正在初始化...',
5952
- 'Camera access blocked': '相機存取遭封鎖',
5953
- 'Location access blocked': '位置存取遭封鎖',
5954
- Continue: '繼續',
5955
- 'Processing...': '正在處理...',
5956
- 'Your camera permission is disabled': '已停用相機權限',
5957
- 'This application requires access to your camera to continue. Please accept the permission once prompted by the browser. If the browser does not prompt for camera permissions you must go to settings and provide camera access to the current browser.': '此應用程式需要存取相機才能繼續。瀏覽器提示後,請接受權限。如果瀏覽器未提示相機權限,必須前往設定並為目前瀏覽器提供相機存取權限。',
5958
- 'Your microphone permission is disabled': '已停用麥克風權限',
5959
- 'This application requires access to your microphone to continue. Please accept the permission once prompted by the browser. If the browser does not prompt for microphone permissions you must go to settings and provide microphone access to the current browser.': '此應用程式需要存取麥克風才能繼續。瀏覽器提示後,請接受權限。如果瀏覽器未提示麥克風權限,必須前往設定並為目前瀏覽器提供麥克風存取權限。',
5960
- 'Your location permission is disabled': '已停用位置權限',
5961
- 'This application requires access to your location to continue. Please accept the permission once prompted by the browser. If the browser does not prompt for location permissions you must go to settings and provide location access to the current browser.': '此應用程式需要存取位置才能繼續。瀏覽器提示後,請接受權限。如果瀏覽器未提示位置權限,必須前往設定並為目前瀏覽器提供位置存取權限。',
5962
- Retry: '重試',
5963
- 'Scan the front of ID': '掃描證件正面',
5964
- 'Scan the back of ID': '掃描證件背面',
5965
- 'Scan the ID page of passport': '掃描護照的 ID 頁面',
5966
- 'ID Card Front': '證件正面',
5967
- 'ID Card Back': '證件背面',
5968
- Passport: '護照',
5969
- 'Document not detected': '未偵測到文件',
5970
- 'Document is not centered': '文件未置中',
5971
- 'Document too close please back up': '文件太近,請後退',
5972
- 'Please hold your ID document steady': '請拿穩證件',
5973
- 'Document out of focus – try improving the lighting': '文件失焦 – 請嘗試改善燈光',
5974
- 'ID card front detected - please flip your ID card': '偵測到證件正面 - 請將證件翻面',
5975
- 'ID card back detected - please flip your ID card': '偵測到證件背面 - 請將證件翻面',
5976
- 'ID card detected please scan a passport instead': '偵測到證件,請掃描護照',
5977
- 'Passport detected please scan an ID card instead': '偵測到護照,請掃描證件',
5978
- 'Document detected, hold still...': '偵測到的文件保持不動...',
5979
- 'ID card front detected, hold still...': '偵測到的證件正面保持不動...',
5980
- 'ID card back detected, hold still...': '偵測到的證件背面保持不動...',
5981
- 'Passport detected, hold still...': '偵測到的護照保持不動...',
5982
- 'Capturing...': '正在拍攝...',
5983
- 'Capture failed!': '拍攝失敗!',
5984
- 'Please flip your ID card...': '請將證件翻面...',
5985
- 'ID card front captured.': '已拍攝證件正面。',
5986
- 'ID card back captured.': '已拍攝證件背面。',
5987
- 'ID Capture Successful': '證件拍攝成功',
5988
- 'Verify the entire ID was captured clearly with no glare.': '確認是否清楚拍攝整個證件,無眩光。',
5989
- Submit: '提交',
5990
- 'Submitting...': '正在提交...',
5991
- 'Use your device camera to capture your face': '使用裝置相機拍攝您的臉部',
5992
- 'Remove Sunglasses & Hat': '取下太陽眼鏡和帽子',
5993
- 'Avoid Excessive Backlighting': '避免過度背光',
5994
- 'Hold still for a few seconds...': '請保持不動幾秒...',
5995
- 'Please hold still...': '請保持不動...',
5996
- 'Look straight into the camera...': '請直視相機...',
5997
- 'Move back...': '請後退...',
5998
- 'Move forward...': '請前進...',
5999
- 'Move to the center...': '請移至中心...',
6000
- 'Waiting for face to be detected...': '正在等待臉部辨識...',
6001
- 'Please remove your eye coverings (sunglasses eye patch etc.)...': '請取下眼睛遮蓋物(太陽眼鏡、眼罩等)...',
6002
- 'Please remove your head coverings (hat scarf etc.)...': '請取下頭部遮蓋物(帽子、圍巾等)...',
6003
- 'Please remove your mask...': '請脫下口罩...',
6004
- 'Live face not detected, please try again': '未偵測到活體人臉,請再試一次',
6005
- Exit: '退出',
6006
- 'Face liveness has been verified!': '已驗證人臉活體!',
6007
- Done: '完成',
6008
- 'Could not verify your face.': '無法驗證您的臉部。',
6009
- 'An error occurred while verifying your face.': '驗證您的臉部時發生錯誤。',
6010
- 'Customer has been identified!': '已識別客戶!',
6011
- 'Customer not found': '找不到客戶',
6012
- 'Additional document capture': '其他文件拍攝',
6013
- Next: '下一步',
6014
- 'Please sign the box below': '請在下方的方框中簽名',
6015
- Accept: '接受',
6016
- Clear: '清除',
6017
- 'Video signature has been successfully captured!': '已成功拍攝影片簽名!',
6018
- 'Network unreachable': '網路無法連線',
6019
- "We're having trouble reaching our services please check your connection and try again.": '無法與服務連線,請檢查連線並再試一次。',
6020
- "We're sorry an unexpected error has occurred.": '很抱歉,發生非預期錯誤。',
6021
- 'Document Capture': '文件拍攝',
6022
- Capture: '拍攝',
6023
- 'Retry capture': '重試拍攝',
6024
- Upload: '上傳',
6025
- 'Uploading...': '正在上傳...',
6026
- 'Upload succeeded!': '上傳成功!',
6027
- 'Performing facial recognition, please hold still...': '正在進行臉部辨識,請保持不動...',
6028
- 'Display the front of your ID card...': '出示證件正面...',
6029
- 'Display the back of your ID card...': '出示證件背面...',
6030
- 'Display the ID page of your passport...': '出示護照的 ID 頁面...',
6031
- 'Please move your face to the center...': '請將臉部移至中心...',
6032
- 'Searching for ID card...': '正在搜尋證件...',
6033
- 'Please read the following text aloud': '請大聲讀出以下文字',
6034
- 'Video ID has been successfully captured!': '已成功拍攝影片 ID!',
6035
- 'ID Front Image': '證件正面影像',
6036
- 'ID Back Image': '證件背面影像',
6037
- "We're having some trouble.": '發生一些問題。',
6038
- 'On-device capture guidance failed please capture a selfie manually.': '裝置上拍攝引導失敗,請手動拍攝自拍照',
6039
- 'Verifying...': '正在驗證...',
6040
- 'Please capture the front of your ID card.': '請拍攝證件正面。',
6041
- 'Please capture the back of your ID card.': '請拍攝證件背面。',
6042
- 'Please capture the front of your ID card, or the ID page of your passport.': '請拍攝證件正面或護照的 ID 頁面。',
6043
- 'Please capture the back of your ID card, or click Done if submitting a passport.': '請拍攝證件背面,或者如果提交護照,請按一下「完成」。',
6044
- 'Please capture the ID page of your passport.': '請拍攝護照的 ID 頁面。',
6045
- 'On-device capture guidance failed please capture a photo of your ID card manually.': '裝置上拍攝引導失敗,請手動拍攝證件的照片。',
6046
- 'On-device capture guidance failed please capture a photo of your passport manually.': '裝置上拍攝引導失敗,請手動拍攝護照的照片。',
6047
- 'On-device capture guidance failed please capture photos of your ID card and passport manually.': '裝置上拍攝引導失敗,請手動拍攝證件和護照的照片。',
6048
- 'On-device capture guidance failed please capture photos of your ID card or passport manually.': '裝置上拍攝引導失敗,請手動拍攝證件或護照的照片。',
6049
- 'Capture ID page of passport': '拍攝護照的 ID 頁面',
6050
- 'Capture back of ID card': '拍攝證件背面',
6051
- 'Downloading...': '正在下載...',
6052
- 'Accessing camera...': '正在存取相機...',
6053
- 'Camera ready': '相機就緒',
6054
- 'Loading guided capture experience...': '正在載入引導式拍攝體驗...',
6055
- 'Guided capture experience ready': '引導式拍攝體驗就緒',
6056
- "Let's Go!": '開始!',
6057
- 'We are having trouble identifying the correct side of your id do you want to continue with capture anyway?': '無法識別證件的正確一面,是否仍要繼續拍攝?',
6058
- OK: '確定',
6059
- 'Capture with Camera': '使用相机拍摄',
6060
- OR: '或者',
6061
- 'Upload from Storage': '从存储中上传',
6062
- 'Select ID Type': '选择身份证类型',
6063
- 'ID Card': '身份证',
6064
- 'Upload Passport': '上传护照',
6065
- 'Upload ID Front': '上传身份证正面',
6066
- 'Upload ID Back': '上传身份证背面',
6067
- Cancel: '取消',
6068
- 'Upload the back of the ID if it is not included in the front image.': '如果正面照片没有包含身份证背面,请上传背面照片。'
5277
+ var FocusModelContext = /*#__PURE__*/createContext({
5278
+ loadFocusModel: function loadFocusModel() {
5279
+ return null;
5280
+ },
5281
+ focusModelReady: false,
5282
+ focusModelDownloadProgress: 0,
5283
+ focusModelError: null,
5284
+ focusThresholds: {},
5285
+ setFocusThresholds: function setFocusThresholds() {
5286
+ return null;
5287
+ },
5288
+ makeFocusPrediction: function makeFocusPrediction() {
5289
+ return null;
5290
+ },
5291
+ focusPredictionTime: 0
5292
+ });
5293
+ function FocusModelProvider(_a) {
5294
+ var children = _a.children,
5295
+ _b = _a.focusModelPath,
5296
+ focusModelPath = _b === void 0 ? defaultFocusModelPath : _b,
5297
+ _c = _a.focusModelLoadTimeoutMs,
5298
+ focusModelLoadTimeoutMs = _c === void 0 ? defaultFocusModelLoadTimeoutMs : _c,
5299
+ onFocusModelError = _a.onFocusModelError,
5300
+ _d = _a.showCanvases,
5301
+ showCanvases = _d === void 0 ? false : _d,
5302
+ _e = _a.shouldLoadModels,
5303
+ shouldLoadModelsProp = _e === void 0 ? true : _e;
5304
+ var cropCanvas = useRef(null);
5305
+ var rotateCanvas = useRef(null);
5306
+ var _f = useState({}),
5307
+ focusThresholds = _f[0],
5308
+ setFocusThresholds = _f[1];
5309
+ var videoRef = useCameraStore().videoRef;
5310
+ var _g = useState(shouldLoadModelsProp),
5311
+ shouldLoadModels = _g[0],
5312
+ setShouldLoadModels = _g[1];
5313
+ var load = useCallback(function () {
5314
+ return setShouldLoadModels(true);
5315
+ }, []);
5316
+ var _h = useLoadFocusModel({
5317
+ modelPath: focusModelPath,
5318
+ modelLoadTimeoutMs: focusModelLoadTimeoutMs,
5319
+ onModelError: onFocusModelError,
5320
+ videoRef: videoRef,
5321
+ shouldLoadModels: shouldLoadModels
5322
+ }),
5323
+ ready = _h.ready,
5324
+ modelDownloadProgress = _h.modelDownloadProgress,
5325
+ modelError = _h.modelError;
5326
+ var makeFocusPrediction = useCallback(function (imageData, box) {
5327
+ if (!ready) return null;
5328
+ var prediction = makeFocusModelPrediction(imageData, cropCanvas.current, rotateCanvas.current, box);
5329
+ if (!prediction) return null;
5330
+ setLastFocusPredictionAt(prediction.predictionTime);
5331
+ return prediction;
5332
+ }, [ready]);
5333
+ var value = useMemo(function () {
5334
+ return {
5335
+ loadFocusModel: load,
5336
+ focusModelReady: ready,
5337
+ focusModelDownloadProgress: modelDownloadProgress,
5338
+ focusModelError: modelError,
5339
+ makeFocusPrediction: makeFocusPrediction,
5340
+ focusPredictionTime: lastFocusPredictionTime,
5341
+ focusThresholds: focusThresholds,
5342
+ setFocusThresholds: setFocusThresholds
5343
+ };
5344
+ }, [focusThresholds, load, makeFocusPrediction, modelDownloadProgress, modelError, ready]);
5345
+ return /*#__PURE__*/React__default.createElement(FocusModelContext.Provider, {
5346
+ value: value
5347
+ }, /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
5348
+ ref: rotateCanvas,
5349
+ style: showCanvases ? {
5350
+ display: 'block'
5351
+ } : undefined
5352
+ }), /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
5353
+ ref: cropCanvas,
5354
+ style: showCanvases ? {
5355
+ display: 'block'
5356
+ } : undefined
5357
+ }), children);
5358
+ }
5359
+
5360
+ function _isNavigatorDefined() {
5361
+ return typeof navigator !== 'undefined' && navigator != null;
5362
+ }
5363
+ var isMobileCache;
5364
+ function isMobile() {
5365
+ if (isMobileCache !== undefined) return isMobileCache;
5366
+ isMobileCache = evaluateIsMobile();
5367
+ return isMobileCache;
5368
+ }
5369
+ function evaluateIsMobile(nav) {
5370
+ if (nav || _isNavigatorDefined()) {
5371
+ if (!nav) {
5372
+ nav = navigator;
5373
+ }
5374
+ if (nav.product === 'ReactNative') {
5375
+ return true;
5376
+ }
5377
+ var a = nav.userAgent || nav.vendor || (
5378
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
5379
+ // @ts-ignore
5380
+ typeof window !== 'undefined' ? window.opera : '');
5381
+ if (!a) {
5382
+ var navAny = nav;
5383
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
5384
+ // @ts-ignore
5385
+ return navAny.userAgentData && navAny.userAgentData.mobile;
5386
+ }
5387
+ return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4));
5388
+ }
5389
+ return false;
5390
+ }
5391
+
5392
+ var onMobile = isMobile();
5393
+ var defaultIdCaptureThresholds = {
5394
+ detection: defaultDocumentDetectionThresholds,
5395
+ focus: defaultFocusThresholds
5396
+ };
5397
+ var IdCaptureModelsContext = /*#__PURE__*/createContext({
5398
+ ready: false,
5399
+ start: function start() {
5400
+ return null;
5401
+ },
5402
+ stop: function stop() {
5403
+ return null;
5404
+ },
5405
+ load: function load() {
5406
+ return null;
5407
+ },
5408
+ modelDownloadProgress: 0,
5409
+ modelError: null,
5410
+ thresholds: defaultIdCaptureThresholds,
5411
+ setThresholds: function setThresholds() {
5412
+ return null;
5413
+ },
5414
+ documentDetectionBoundaries: defaultDocumentDetectionBoundaries,
5415
+ setDocumentDetectionBoundaries: function setDocumentDetectionBoundaries() {
5416
+ return null;
5417
+ },
5418
+ onPredictionMade: function onPredictionMade() {
5419
+ return null;
5420
+ },
5421
+ detectionTime: 0,
5422
+ focusPredictionTime: 0,
5423
+ bestFrameDetails: {
5424
+ current: null
5425
+ },
5426
+ getBestFrame: function getBestFrame() {
5427
+ return null;
5428
+ },
5429
+ resetBestFrame: function resetBestFrame() {
5430
+ return null;
5431
+ },
5432
+ requiredDocumentType: 'none',
5433
+ setRequiredDocumentType: function setRequiredDocumentType() {
5434
+ return null;
5435
+ }
5436
+ });
5437
+ function IdCaptureModelsProviderInner(_a) {
5438
+ var children = _a.children,
5439
+ onModelError = _a.onModelError,
5440
+ _b = _a.allowSinglePageIdCapture,
5441
+ allowSinglePageIdCapture = _b === void 0 ? false : _b;
5442
+ var _c = useContext(DocumentDetectionModelContext),
5443
+ documentDetectionModelReady = _c.documentDetectionModelReady,
5444
+ documentDetectionModelDownloadProgress = _c.documentDetectionModelDownloadProgress,
5445
+ startDocumentDetection = _c.startDocumentDetection,
5446
+ stopDocumentDetection = _c.stopDocumentDetection,
5447
+ loadDocumentDetectionModel = _c.loadDocumentDetectionModel,
5448
+ lastPredictionCanvas = _c.documentDetectionLastPredictionCanvas,
5449
+ clearDocumentDetectionLastPredictionCanvas = _c.clearDocumentDetectionLastPredictionCanvas,
5450
+ onDocumentDetected = _c.onDocumentDetected,
5451
+ detectionTime = _c.detectionTime,
5452
+ documentDetectionThresholds = _c.documentDetectionThresholds,
5453
+ setDocumentDetectionThresholds = _c.setDocumentDetectionThresholds,
5454
+ documentDetectionBoundaries = _c.documentDetectionBoundaries,
5455
+ setDocumentDetectionBoundaries = _c.setDocumentDetectionBoundaries,
5456
+ documentDetectionModelError = _c.documentDetectionModelError;
5457
+ var _d = useContext(FocusModelContext),
5458
+ loadFocusModel = _d.loadFocusModel,
5459
+ focusModelReady = _d.focusModelReady,
5460
+ focusModelDownloadProgress = _d.focusModelDownloadProgress,
5461
+ makeFocusPrediction = _d.makeFocusPrediction,
5462
+ focusThresholds = _d.focusThresholds,
5463
+ setFocusThresholds = _d.setFocusThresholds,
5464
+ focusPredictionTime = _d.focusPredictionTime,
5465
+ focusModelError = _d.focusModelError;
5466
+ var onPredictionHandler = useRef();
5467
+ var bestFrameDetails = useRef(null);
5468
+ var bestPredictionCanvas = useRef(null);
5469
+ var bestFocusScore = useRef(0);
5470
+ var stopDetection = useRef(0);
5471
+ var _e = useState('none'),
5472
+ requiredDocumentType = _e[0],
5473
+ setRequiredDocumentType = _e[1];
5474
+ var thresholds = useMemo(function () {
5475
+ return _assign(_assign({}, documentDetectionThresholds), {
5476
+ focus: focusThresholds
5477
+ });
5478
+ }, [documentDetectionThresholds, focusThresholds]);
5479
+ var setThresholds = useCallback(function (thresholds) {
5480
+ if (thresholds.detection) {
5481
+ setDocumentDetectionThresholds(thresholds.detection);
5482
+ }
5483
+ if (thresholds.focus) {
5484
+ setFocusThresholds(thresholds.focus);
5485
+ }
5486
+ }, [setDocumentDetectionThresholds, setFocusThresholds]);
5487
+ useEffect(function handleDetections() {
5488
+ var _this = this;
5489
+ onDocumentDetected(function (prediction) {
5490
+ return __awaiter(_this, void 0, void 0, function () {
5491
+ var stopDetectionAtStart, focusPredictionTime, focusScore, focusThresholdMet, isSinglePage, isRequiredDocumentType, focusPrediction, focusThresholdSet, focusThreshold;
5492
+ var _a, _b, _c, _d, _e, _f, _g;
5493
+ return __generator(this, function (_h) {
5494
+ if (!lastPredictionCanvas.current) return [2 /*return*/];
5495
+ stopDetectionAtStart = stopDetection.current;
5496
+ focusPredictionTime = 0, focusScore = 0, focusThresholdMet = false;
5497
+ isSinglePage = prediction.detectedDocumentType === 'singlePage';
5498
+ if (!allowSinglePageIdCapture && isSinglePage) {
5499
+ prediction.detectedDocumentType = 'passport';
5500
+ prediction.passportDetectionScore = prediction.singlePageDetectionScore;
5501
+ prediction.passportDetectionThresholdMet = prediction.singlePageDetectionThresholdMet;
5502
+ prediction.singlePageDetectionScore = 0;
5503
+ prediction.singlePageDetectionThresholdMet = false;
5504
+ }
5505
+ 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'));
5506
+ if (isRequiredDocumentType && prediction.detectedDocumentType !== 'none' && prediction.detectionThresholdMet && prediction.documentInBounds && !prediction.documentTooClose && prediction.documentIsStable) {
5507
+ focusPrediction = makeFocusPrediction(lastPredictionCanvas.current, (_c = prediction.bestDocument) === null || _c === void 0 ? void 0 : _c.box);
5508
+ if (focusPrediction) {
5509
+ focusScore = focusPrediction.score;
5510
+ focusPredictionTime = focusPrediction.predictionTime;
5511
+ }
5512
+ focusThresholdSet = (_d = thresholds.focus) === null || _d === void 0 ? void 0 : _d[prediction.detectedDocumentType];
5513
+ focusThreshold = (_e = onMobile ? focusThresholdSet === null || focusThresholdSet === void 0 ? void 0 : focusThresholdSet.mobile : focusThresholdSet === null || focusThresholdSet === void 0 ? void 0 : focusThresholdSet.desktop) !== null && _e !== void 0 ? _e : 0;
5514
+ focusThresholdMet = focusScore >= focusThreshold;
5515
+ if (bestFocusScore.current <= focusScore && stopDetectionAtStart === stopDetection.current) {
5516
+ bestFocusScore.current = focusScore;
5517
+ drawToCanvas(bestPredictionCanvas.current, lastPredictionCanvas.current);
5518
+ bestFrameDetails.current = {
5519
+ boundingBox: (_f = prediction.bestDocument) === null || _f === void 0 ? void 0 : _f.box,
5520
+ documentType: prediction.detectedDocumentType,
5521
+ detectionScore: prediction.detectionScore,
5522
+ focusScore: focusScore
5523
+ };
5524
+ }
5525
+ }
5526
+ (_g = onPredictionHandler.current) === null || _g === void 0 ? void 0 : _g.call(onPredictionHandler, _assign(_assign({}, prediction), {
5527
+ focusScore: focusScore,
5528
+ focusPredictionTime: focusPredictionTime,
5529
+ focusThresholdMet: focusThresholdMet
5530
+ }));
5531
+ return [2 /*return*/];
5532
+ });
5533
+ });
5534
+ });
5535
+ }, [allowSinglePageIdCapture, lastPredictionCanvas, makeFocusPrediction, onDocumentDetected, requiredDocumentType, thresholds.focus]);
5536
+ var modelError = documentDetectionModelError !== null && documentDetectionModelError !== void 0 ? documentDetectionModelError : focusModelError;
5537
+ useEffect(function handleModelErrors() {
5538
+ if (modelError) onModelError === null || onModelError === void 0 ? void 0 : onModelError(modelError);
5539
+ }, [modelError, onModelError]);
5540
+ var onPredictionMade = useCallback(function (handler) {
5541
+ onPredictionHandler.current = handler;
5542
+ }, []);
5543
+ var getBestFrame = useCallback(function () {
5544
+ if (!bestFrameDetails.current || !bestPredictionCanvas.current) return null;
5545
+ return _assign(_assign({}, bestFrameDetails.current), {
5546
+ canvas: bestPredictionCanvas.current
5547
+ });
5548
+ }, []);
5549
+ var _f = useState(0),
5550
+ canvasKey = _f[0],
5551
+ setCanvasKey = _f[1];
5552
+ var resetBestFrame = useCallback(function () {
5553
+ stopDetection.current += 1;
5554
+ setCanvasKey(function (n) {
5555
+ return n + 1;
5556
+ });
5557
+ clearDocumentDetectionLastPredictionCanvas();
5558
+ bestFrameDetails.current = null;
5559
+ bestFocusScore.current = 0;
5560
+ }, [clearDocumentDetectionLastPredictionCanvas]);
5561
+ useEffect(function () {
5562
+ if (requiredDocumentType) resetBestFrame();
5563
+ }, [requiredDocumentType, resetBestFrame]);
5564
+ var load = useCallback(function () {
5565
+ loadDocumentDetectionModel();
5566
+ loadFocusModel();
5567
+ }, [loadDocumentDetectionModel, loadFocusModel]);
5568
+ var value = useMemo(function () {
5569
+ return {
5570
+ ready: documentDetectionModelReady && focusModelReady,
5571
+ modelDownloadProgress: (documentDetectionModelDownloadProgress + focusModelDownloadProgress) / 2,
5572
+ modelError: modelError,
5573
+ start: startDocumentDetection,
5574
+ stop: stopDocumentDetection,
5575
+ load: load,
5576
+ thresholds: thresholds,
5577
+ setThresholds: setThresholds,
5578
+ documentDetectionBoundaries: documentDetectionBoundaries,
5579
+ setDocumentDetectionBoundaries: setDocumentDetectionBoundaries,
5580
+ onPredictionMade: onPredictionMade,
5581
+ detectionTime: detectionTime,
5582
+ focusPredictionTime: focusPredictionTime,
5583
+ getBestFrame: getBestFrame,
5584
+ resetBestFrame: resetBestFrame,
5585
+ bestFrameDetails: bestFrameDetails,
5586
+ requiredDocumentType: requiredDocumentType,
5587
+ setRequiredDocumentType: setRequiredDocumentType
5588
+ };
5589
+ }, [detectionTime, documentDetectionBoundaries, documentDetectionModelDownloadProgress, documentDetectionModelReady, focusModelDownloadProgress, focusModelReady, focusPredictionTime, getBestFrame, load, modelError, onPredictionMade, requiredDocumentType, resetBestFrame, setDocumentDetectionBoundaries, setThresholds, startDocumentDetection, stopDocumentDetection, thresholds]);
5590
+ return /*#__PURE__*/React__default.createElement(IdCaptureModelsContext.Provider, {
5591
+ value: value
5592
+ }, /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
5593
+ key: canvasKey,
5594
+ ref: bestPredictionCanvas
5595
+ }), children);
5596
+ }
5597
+ function IdCaptureModelsProvider(_a) {
5598
+ var children = _a.children,
5599
+ props = __rest(_a, ["children"]);
5600
+ return /*#__PURE__*/React__default.createElement(DocumentDetectionModelProvider, _assign({}, props), /*#__PURE__*/React__default.createElement(FocusModelProvider, _assign({}, props), /*#__PURE__*/React__default.createElement(IdCaptureModelsProviderInner, _assign({}, props), children)));
5601
+ }
5602
+
5603
+ var CapturedDocumentTypeValues = ['idCardFront', 'idCardBack', 'passport', 'singlePage', 'selfie'];
5604
+
5605
+ var acceptedDocumentTypesForIdCaptureRequirementOption = {
5606
+ idCardFront: ['idCardFront'],
5607
+ idCardBack: ['idCardBack'],
5608
+ passport: ['passport'],
5609
+ idCard: ['idCardFront', 'idCardBack'],
5610
+ idCardAndPassport: ['idCardFront', 'idCardBack', 'passport'],
5611
+ idCardOrPassport: ['idCardFront', 'idCardBack', 'passport'] // this one is so weird
6069
5612
  };
5613
+ function minImageCountForIdCaptureRequirementOption(idCaptureRequirement) {
5614
+ if (idCaptureRequirement === 'idCardOrPassport') return 1;
5615
+ return acceptedDocumentTypesForIdCaptureRequirementOption[idCaptureRequirement].length;
5616
+ }
5617
+ function maxImageCountForIdCaptureRequirementOption(idCaptureRequirement) {
5618
+ if (idCaptureRequirement === 'idCardOrPassport') return 2;
5619
+ return minImageCountForIdCaptureRequirementOption(idCaptureRequirement);
5620
+ }
5621
+ function remainingIdCaptureRequirements(captureRequirement, capturedDocuments, requestedDocumentType) {
5622
+ var isIdCardOrPassport = captureRequirement === 'idCardOrPassport';
5623
+ if (isIdCardOrPassport && requestedDocumentType === 'passport') return [];
5624
+ var acceptedTypes = acceptedDocumentTypesForIdCaptureRequirementOption[captureRequirement];
5625
+ if (captureRequirement.includes('idCard') && 'singlePage' in capturedDocuments) {
5626
+ acceptedTypes = acceptedTypes.filter(function (v) {
5627
+ return !v.includes('idCard');
5628
+ });
5629
+ }
5630
+ if (isIdCardOrPassport) {
5631
+ acceptedTypes = acceptedTypes.filter(function (v) {
5632
+ return v !== 'passport';
5633
+ });
5634
+ }
5635
+ return acceptedTypes.filter(function (v) {
5636
+ return !(v in capturedDocuments);
5637
+ });
5638
+ }
6070
5639
 
6071
- var resources = {
6072
- en: {
6073
- translation: en
6074
- },
6075
- es: {
6076
- translation: es
6077
- },
6078
- de: {
6079
- translation: de
6080
- },
6081
- fr: {
6082
- translation: fr
6083
- },
6084
- it: {
6085
- translation: it
6086
- },
6087
- ja: {
6088
- translation: ja
6089
- },
6090
- pt: {
6091
- translation: pt
6092
- },
6093
- ru: {
6094
- translation: ru
6095
- },
6096
- zh: {
6097
- translation: zh
5640
+ var initialState$4 = {
5641
+ initialDrawComplete: false,
5642
+ redrawing: false,
5643
+ guideRectX: 0,
5644
+ guideRectY: 0,
5645
+ guideRectWidth: 0,
5646
+ guideRectHeight: 0,
5647
+ guideRectOffsetTop: 0,
5648
+ guideImageWidth: 0,
5649
+ guideImageHeight: 0,
5650
+ pageWidth: 0,
5651
+ pageHeight: 0,
5652
+ videoWidth: 0,
5653
+ videoHeight: 0,
5654
+ detectedObjects: [],
5655
+ bestDocument: undefined,
5656
+ detectedDocumentType: 'none',
5657
+ detectionThresholdMet: false,
5658
+ documentInBounds: false,
5659
+ documentTooClose: false,
5660
+ documentIsStable: false,
5661
+ flipRequired: false,
5662
+ backDetectedFirst: false,
5663
+ idCardDetectedButNotAllowed: false,
5664
+ passportDetectedButNotAllowed: false,
5665
+ enableOverrideWrongDocumentTypeDialog: false,
5666
+ allowOverrideWrongDocumentTypeAfterMs: 8000,
5667
+ allowOverrideWrongDocumentTypeGuidance: false,
5668
+ overrideWrongDocumentTypeGuidance: false,
5669
+ wrongDocumentTypePredictions: 0,
5670
+ idCardFrontDetectionScore: 0,
5671
+ idCardFrontDetectionThresholdMet: false,
5672
+ idCardBackDetectionScore: 0,
5673
+ idCardBackDetectionThresholdMet: false,
5674
+ passportDetectionScore: 0,
5675
+ passportDetectionThresholdMet: false,
5676
+ singlePageDetectionScore: 0,
5677
+ singlePageDetectionThresholdMet: false,
5678
+ focusScore: 0,
5679
+ focusThresholdMet: false,
5680
+ isGoodFrame: false,
5681
+ goodFramesCount: 0,
5682
+ goodFramesThreshold: 3,
5683
+ goodFramesThresholdMet: false,
5684
+ lastFrameCapturedAt: null,
5685
+ frameCaptureRate: 0,
5686
+ capturing: false,
5687
+ captureFailed: false,
5688
+ imageUrl: null,
5689
+ captureState: 'initializing',
5690
+ capturedDocuments: {},
5691
+ captureRequirement: 'idCardOrPassport',
5692
+ requestedDocumentType: 'idCardFront',
5693
+ allowSinglePageIdCapture: false,
5694
+ allowIdCardBackToFrontCapture: false,
5695
+ allowUploadingDocumentsFromStorage: false,
5696
+ isUploadingDocumentsFromStorage: false,
5697
+ uploadingDocumentsType: null,
5698
+ operationStartedAt: null,
5699
+ captureStartedAt: null,
5700
+ dispatch: function dispatch() {
5701
+ return null;
5702
+ }
5703
+ };
5704
+ var _reducer = function reducer(state, action) {
5705
+ var _a;
5706
+ switch (action.type) {
5707
+ case 'configureWizard':
5708
+ {
5709
+ var _b = action.payload,
5710
+ captureRequirement = _b.captureRequirement,
5711
+ precapturedDocuments = _b.precapturedDocuments,
5712
+ allowSinglePageIdCapture = _b.allowSinglePageIdCapture,
5713
+ allowIdCardBackToFrontCapture = _b.allowIdCardBackToFrontCapture,
5714
+ enableOverrideWrongDocumentTypeDialog = _b.enableOverrideWrongDocumentTypeDialog,
5715
+ allowOverrideWrongDocumentTypeAfterMs = _b.allowOverrideWrongDocumentTypeAfterMs,
5716
+ allowUploadingDocumentsFromStorage = _b.allowUploadingDocumentsFromStorage;
5717
+ var newState = _assign(_assign({}, state), {
5718
+ captureRequirement: captureRequirement,
5719
+ allowSinglePageIdCapture: allowSinglePageIdCapture !== null && allowSinglePageIdCapture !== void 0 ? allowSinglePageIdCapture : false,
5720
+ allowIdCardBackToFrontCapture: allowIdCardBackToFrontCapture !== null && allowIdCardBackToFrontCapture !== void 0 ? allowIdCardBackToFrontCapture : false,
5721
+ enableOverrideWrongDocumentTypeDialog: enableOverrideWrongDocumentTypeDialog,
5722
+ allowOverrideWrongDocumentTypeAfterMs: allowOverrideWrongDocumentTypeAfterMs,
5723
+ allowUploadingDocumentsFromStorage: allowUploadingDocumentsFromStorage
5724
+ });
5725
+ if (captureRequirement === 'idCardBack') newState.requestedDocumentType = 'idCardBack';
5726
+ if (captureRequirement === 'passport') newState.requestedDocumentType = 'passport';
5727
+ if (precapturedDocuments) {
5728
+ for (var _i = 0, CapturedDocumentTypeValues_1 = CapturedDocumentTypeValues; _i < CapturedDocumentTypeValues_1.length; _i++) {
5729
+ var k = CapturedDocumentTypeValues_1[_i];
5730
+ var payload = precapturedDocuments[k];
5731
+ if (payload) {
5732
+ newState.requestedDocumentType = k;
5733
+ newState = _reducer(newState, {
5734
+ type: 'documentCaptured',
5735
+ payload: payload
5736
+ });
5737
+ }
5738
+ }
5739
+ }
5740
+ if (newState.captureState === 'initializing' && !allowUploadingDocumentsFromStorage) {
5741
+ newState.captureState = 'capturing';
5742
+ }
5743
+ return newState;
5744
+ }
5745
+ case 'setRequiredDocumentType':
5746
+ return _assign(_assign({}, state), {
5747
+ requiredDocumentType: action.payload
5748
+ });
5749
+ case 'redrawRequested':
5750
+ return _assign(_assign({}, state), {
5751
+ redrawing: true,
5752
+ guideRectX: 0,
5753
+ guideRectY: 0,
5754
+ guideRectWidth: 0,
5755
+ guideRectHeight: 0,
5756
+ guideRectOffsetTop: 0
5757
+ });
5758
+ case 'redrawInProgress':
5759
+ return _assign(_assign({}, state), {
5760
+ redrawing: false,
5761
+ guideRectX: 0,
5762
+ guideRectY: 0,
5763
+ guideRectWidth: 0,
5764
+ guideRectHeight: 0,
5765
+ guideRectOffsetTop: 0
5766
+ });
5767
+ case 'redrawCompleted':
5768
+ return _assign(_assign(_assign({}, state), action.payload), {
5769
+ initialDrawComplete: true
5770
+ });
5771
+ case 'pageRendered':
5772
+ return _assign(_assign({}, state), action.payload);
5773
+ case 'guideImageLoaded':
5774
+ return _assign(_assign({}, state), {
5775
+ guideImageWidth: action.payload.width,
5776
+ guideImageHeight: action.payload.height
5777
+ });
5778
+ case 'objectsDetected':
5779
+ {
5780
+ var _c = action.payload.prediction,
5781
+ detectedObjects = _c.detectedObjects,
5782
+ detectionThresholdMet = _c.detectionThresholdMet,
5783
+ detectedDocumentType = _c.detectedDocumentType,
5784
+ idCardFrontDetectionScore = _c.idCardFrontDetectionScore,
5785
+ idCardFrontDetectionThresholdMet = _c.idCardFrontDetectionThresholdMet,
5786
+ idCardBackDetectionScore = _c.idCardBackDetectionScore,
5787
+ idCardBackDetectionThresholdMet = _c.idCardBackDetectionThresholdMet,
5788
+ passportDetectionScore = _c.passportDetectionScore,
5789
+ passportDetectionThresholdMet = _c.passportDetectionThresholdMet,
5790
+ singlePageDetectionScore = _c.singlePageDetectionScore,
5791
+ singlePageDetectionThresholdMet = _c.singlePageDetectionThresholdMet,
5792
+ bestDocument = _c.bestDocument,
5793
+ documentInBounds = _c.documentInBounds,
5794
+ documentTooClose = _c.documentTooClose,
5795
+ documentIsStable = _c.documentIsStable,
5796
+ focusScore = _c.focusScore,
5797
+ focusThresholdMet = _c.focusThresholdMet,
5798
+ frameWidth = _c.frameWidth,
5799
+ frameHeight = _c.frameHeight;
5800
+ var frameCapturedAt = new Date();
5801
+ var frameCaptureRate = 0;
5802
+ var goodFramesThreshold = state.goodFramesThreshold;
5803
+ if (state.lastFrameCapturedAt) {
5804
+ var frameTime = frameCapturedAt.getTime() - state.lastFrameCapturedAt.getTime();
5805
+ if (frameTime > 0) {
5806
+ frameCaptureRate = 1000.0 / frameTime;
5807
+ if (frameCaptureRate > 0) {
5808
+ goodFramesThreshold = Math.ceil(3 * frameCaptureRate);
5809
+ }
5810
+ }
5811
+ }
5812
+ var idCardDetected = detectedDocumentType.includes('idCard') || detectedDocumentType === 'singlePage';
5813
+ var idCardDetectedButNotAllowed = idCardDetected && !state.captureRequirement.includes('idCard');
5814
+ var passportNotAllowed = !state.captureRequirement.toLowerCase().includes('passport');
5815
+ var idCardFrontWasCaptured = 'idCardFront' in state.capturedDocuments;
5816
+ var idCardBackWasCaptured = 'idCardBack' in state.capturedDocuments;
5817
+ var idCardBeingCaptured = idCardFrontWasCaptured && !idCardBackWasCaptured || !idCardFrontWasCaptured && idCardBackWasCaptured;
5818
+ var passportDetectedButNotAllowed = detectedDocumentType === 'passport' && (passportNotAllowed || idCardBeingCaptured);
5819
+ var flipRequired = !state.overrideWrongDocumentTypeGuidance && (state.allowIdCardBackToFrontCapture ? idCardFrontWasCaptured && detectedDocumentType === 'idCardFront' : state.requestedDocumentType === 'idCardBack' && detectedDocumentType === 'idCardFront');
5820
+ var backDetectedFirst = !state.overrideWrongDocumentTypeGuidance && (state.allowIdCardBackToFrontCapture ? idCardBackWasCaptured && detectedDocumentType === 'idCardBack' : state.requestedDocumentType === 'idCardFront' && detectedDocumentType === 'idCardBack');
5821
+ var wrongDocumentTypePredictions = state.wrongDocumentTypePredictions;
5822
+ if (state.captureState === 'capturing' && (flipRequired || backDetectedFirst)) {
5823
+ wrongDocumentTypePredictions += 1;
5824
+ }
5825
+ var isGoodFrame = detectionThresholdMet && documentInBounds && !documentTooClose && !flipRequired && !backDetectedFirst && focusThresholdMet && !idCardDetectedButNotAllowed && !passportDetectedButNotAllowed && documentIsStable;
5826
+ var captureStartedAt = state.captureStartedAt;
5827
+ var goodFramesCount = state.goodFramesCount;
5828
+ if (isGoodFrame) {
5829
+ goodFramesCount += 1;
5830
+ captureStartedAt || (captureStartedAt = new Date());
5831
+ }
5832
+ var goodFramesThresholdMet = goodFramesCount >= goodFramesThreshold;
5833
+ var requestedDocumentType = state.requestedDocumentType;
5834
+ if (state.captureRequirement.includes('idCard') && state.allowIdCardBackToFrontCapture) {
5835
+ if (detectedDocumentType === 'idCardFront' && state.requestedDocumentType !== 'idCardFront' && !idCardFrontWasCaptured) {
5836
+ requestedDocumentType = 'idCardFront';
5837
+ } else if (detectedDocumentType === 'idCardBack' && state.requestedDocumentType !== 'idCardBack' && !idCardBackWasCaptured) {
5838
+ requestedDocumentType = 'idCardBack';
5839
+ }
5840
+ }
5841
+ if (state.captureRequirement === 'idCardOrPassport') {
5842
+ if (detectedDocumentType === 'passport' && state.requestedDocumentType !== 'passport') {
5843
+ requestedDocumentType = 'passport';
5844
+ }
5845
+ if (requestedDocumentType === 'passport' && passportDetectionScore < 0.3) {
5846
+ requestedDocumentType = idCardFrontWasCaptured ? 'idCardBack' : 'idCardFront';
5847
+ }
5848
+ }
5849
+ var hasBeenRunningForLongEnough = !!state.operationStartedAt && new Date().getTime() - state.operationStartedAt.getTime() > 1000;
5850
+ var overrideFlipRequirementThreshold = Math.ceil(state.allowOverrideWrongDocumentTypeAfterMs / 1000 * frameCaptureRate);
5851
+ var allowOverrideFlipRequirement = state.enableOverrideWrongDocumentTypeDialog && hasBeenRunningForLongEnough && !state.overrideWrongDocumentTypeGuidance && overrideFlipRequirementThreshold > 0 && (state.allowOverrideWrongDocumentTypeGuidance || wrongDocumentTypePredictions >= overrideFlipRequirementThreshold);
5852
+ return _assign(_assign({}, state), {
5853
+ videoWidth: frameWidth,
5854
+ videoHeight: frameHeight,
5855
+ detectedObjects: detectedObjects,
5856
+ bestDocument: bestDocument,
5857
+ requestedDocumentType: requestedDocumentType,
5858
+ detectedDocumentType: detectedDocumentType,
5859
+ detectionThresholdMet: detectionThresholdMet,
5860
+ documentInBounds: documentInBounds,
5861
+ documentTooClose: documentTooClose,
5862
+ documentIsStable: documentIsStable,
5863
+ flipRequired: flipRequired,
5864
+ backDetectedFirst: backDetectedFirst,
5865
+ idCardDetectedButNotAllowed: idCardDetectedButNotAllowed,
5866
+ passportDetectedButNotAllowed: passportDetectedButNotAllowed,
5867
+ allowOverrideWrongDocumentTypeGuidance: allowOverrideFlipRequirement,
5868
+ wrongDocumentTypePredictions: wrongDocumentTypePredictions,
5869
+ idCardFrontDetectionScore: idCardFrontDetectionScore,
5870
+ idCardFrontDetectionThresholdMet: idCardFrontDetectionThresholdMet,
5871
+ idCardBackDetectionScore: idCardBackDetectionScore,
5872
+ idCardBackDetectionThresholdMet: idCardBackDetectionThresholdMet,
5873
+ passportDetectionScore: passportDetectionScore,
5874
+ passportDetectionThresholdMet: passportDetectionThresholdMet,
5875
+ singlePageDetectionScore: singlePageDetectionScore,
5876
+ singlePageDetectionThresholdMet: singlePageDetectionThresholdMet,
5877
+ focusScore: focusScore,
5878
+ focusThresholdMet: focusThresholdMet,
5879
+ isGoodFrame: isGoodFrame,
5880
+ goodFramesCount: goodFramesCount,
5881
+ goodFramesThreshold: goodFramesThreshold,
5882
+ goodFramesThresholdMet: goodFramesThresholdMet,
5883
+ captureStartedAt: captureStartedAt,
5884
+ lastFrameCapturedAt: frameCapturedAt,
5885
+ frameCaptureRate: frameCaptureRate
5886
+ });
5887
+ }
5888
+ case 'captureInitialized':
5889
+ return _assign(_assign({}, state), {
5890
+ captureState: 'capturing',
5891
+ isUploadingDocumentsFromStorage: false
5892
+ });
5893
+ case 'captureStarted':
5894
+ return _assign(_assign({}, state), {
5895
+ operationStartedAt: new Date(),
5896
+ captureStartedAt: null,
5897
+ capturing: false,
5898
+ captureFailed: false
5899
+ });
5900
+ case 'capturing':
5901
+ return _assign(_assign({}, state), {
5902
+ capturing: true,
5903
+ captureFailed: false
5904
+ });
5905
+ case 'captured':
5906
+ return _assign(_assign({}, state), {
5907
+ capturing: false,
5908
+ captureFailed: false
5909
+ });
5910
+ case 'frameCaptured':
5911
+ return _assign(_assign({}, state), {
5912
+ imageUrl: action.payload.imageUrl
5913
+ });
5914
+ case 'captureFailed':
5915
+ return _assign(_assign({}, state), {
5916
+ capturing: false,
5917
+ captureFailed: true
5918
+ });
5919
+ case 'documentCaptured':
5920
+ {
5921
+ var newState = _assign(_assign({}, state), {
5922
+ capturing: false,
5923
+ captureFailed: false,
5924
+ allowOverrideFlipRequirement: false,
5925
+ overrideFlipRequirement: false,
5926
+ goodFramesCount: 0,
5927
+ wrongDocumentTypePredictions: 0,
5928
+ capturedDocuments: _assign(_assign({}, state.capturedDocuments), (_a = {}, _a[action.payload.documentType] = action.payload, _a))
5929
+ });
5930
+ var remainingRequirements = remainingIdCaptureRequirements(state.captureRequirement, newState.capturedDocuments, state.requestedDocumentType);
5931
+ if (remainingRequirements.length === 0) {
5932
+ newState.captureState = 'complete';
5933
+ } else {
5934
+ newState.requestedDocumentType = remainingRequirements[0];
5935
+ if (state.requestedDocumentType === 'idCardFront' && newState.requestedDocumentType === 'idCardBack' || state.requestedDocumentType === 'idCardBack' && newState.requestedDocumentType === 'idCardFront') {
5936
+ if (!newState.isUploadingDocumentsFromStorage) {
5937
+ newState.captureState = 'requestingFlip';
5938
+ }
5939
+ newState.idCardFrontDetectionThresholdMet = false;
5940
+ newState.idCardBackDetectionThresholdMet = false;
5941
+ newState.passportDetectionThresholdMet = false;
5942
+ newState.wrongDocumentTypePredictions = 0;
5943
+ }
5944
+ }
5945
+ return newState;
5946
+ }
5947
+ case 'documentCapturedManually':
5948
+ return _reducer(state, {
5949
+ type: 'documentCaptured',
5950
+ payload: _assign(_assign({}, action.payload), {
5951
+ documentType: state.requestedDocumentType,
5952
+ width: 0,
5953
+ height: 0
5954
+ })
5955
+ });
5956
+ case 'documentsCaptured':
5957
+ {
5958
+ var newState = _assign({}, state);
5959
+ for (var _d = 0, _e = action.payload; _d < _e.length; _d++) {
5960
+ var doc = _e[_d];
5961
+ newState = _reducer(newState, {
5962
+ type: 'documentCaptured',
5963
+ payload: doc
5964
+ });
5965
+ }
5966
+ return newState;
5967
+ }
5968
+ case 'flipRequestCompleted':
5969
+ return _assign(_assign({}, state), {
5970
+ captureState: 'capturing',
5971
+ allowOverrideWrongDocumentTypeGuidance: false,
5972
+ overrideWrongDocumentTypeGuidance: false,
5973
+ wrongDocumentTypePredictions: 0
5974
+ });
5975
+ case 'allowOverrideFlipRequirement':
5976
+ return _assign(_assign({}, state), {
5977
+ allowOverrideWrongDocumentTypeGuidance: true
5978
+ });
5979
+ case 'overrideFlipRequirement':
5980
+ return _assign(_assign({}, state), {
5981
+ allowOverrideWrongDocumentTypeGuidance: false,
5982
+ overrideWrongDocumentTypeGuidance: true
5983
+ });
5984
+ case 'setUploadingDocumentsFromStorage':
5985
+ return _assign(_assign({}, state), {
5986
+ isUploadingDocumentsFromStorage: action.payload,
5987
+ captureState: action.payload ? 'initializing' : 'capturing'
5988
+ });
5989
+ case 'setUploadingDocumentsType':
5990
+ {
5991
+ var requestedDocumentType = !action.payload || action.payload === 'idCard' ? 'idCardFront' : action.payload;
5992
+ var uploadingDocumentsType = action.payload === 'singlePage' ? 'idCard' : action.payload;
5993
+ return _assign(_assign({}, state), {
5994
+ captureState: action.payload ? 'uploading' : 'initializing',
5995
+ uploadingDocumentsType: uploadingDocumentsType,
5996
+ requestedDocumentType: requestedDocumentType
5997
+ });
5998
+ }
5999
+ case 'resetWizard':
6000
+ return _assign(_assign({}, initialState$4), {
6001
+ dispatch: state.dispatch,
6002
+ allowUploadingDocumentsFromStorage: state.allowUploadingDocumentsFromStorage,
6003
+ captureState: state.allowUploadingDocumentsFromStorage ? 'initializing' : 'capturing',
6004
+ captureRequirement: state.captureRequirement,
6005
+ allowIdCardBackToFrontCapture: state.allowIdCardBackToFrontCapture
6006
+ });
6007
+ default:
6008
+ return state;
6098
6009
  }
6099
6010
  };
6100
- function initializeI18n() {
6101
- void i18n.use(LanguageDetector).use(initReactI18next).init({
6102
- resources: resources,
6103
- detection: {
6104
- caches: []
6105
- },
6106
- fallbackLng: 'en',
6107
- debug: false,
6108
- interpolation: {
6109
- escapeValue: false
6011
+ var useIdCaptureStore = create()(devtools(function (set) {
6012
+ return _assign(_assign({}, initialState$4), {
6013
+ dispatch: function dispatch(action) {
6014
+ return set(function (state) {
6015
+ return _reducer(state, action);
6016
+ }, undefined, action);
6017
+ }
6018
+ });
6019
+ }));
6020
+ function IdCaptureStateProvider(_a) {
6021
+ var children = _a.children;
6022
+ var overrideWrongDocumentTypeGuidance = useIdCaptureStore(useShallow(function (state) {
6023
+ return state.overrideWrongDocumentTypeGuidance;
6024
+ }));
6025
+ var setRequiredDocumentType = useContext(IdCaptureModelsContext).setRequiredDocumentType;
6026
+ useEffect(function () {
6027
+ if (overrideWrongDocumentTypeGuidance) setRequiredDocumentType('none');
6028
+ }, [overrideWrongDocumentTypeGuidance, setRequiredDocumentType]);
6029
+ var onResize = useDebouncedCallback(function () {
6030
+ dispatchIdCaptureAction({
6031
+ type: 'redrawRequested'
6032
+ });
6033
+ }, 500);
6034
+ useLayoutEffect(function () {
6035
+ if (typeof window === 'undefined') return;
6036
+ window.addEventListener('resize', onResize);
6037
+ return function () {
6038
+ return window.removeEventListener('resize', onResize);
6039
+ };
6040
+ }, [onResize]);
6041
+ useEffect(function resetWhenProviderUnmounts() {
6042
+ return function () {
6043
+ return useIdCaptureStore.getState().dispatch({
6044
+ type: 'resetWizard'
6045
+ });
6046
+ };
6047
+ }, []);
6048
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, children);
6049
+ }
6050
+ var dispatchIdCaptureAction = function dispatchIdCaptureAction(action) {
6051
+ return useIdCaptureStore.getState().dispatch(action);
6052
+ };
6053
+
6054
+ function DebugStatsPane(_a) {
6055
+ var children = _a.children;
6056
+ var element = /*#__PURE__*/React__default.createElement(DebugStatsPaneDiv, null, children);
6057
+ var portalLocation = document.getElementById('idmission-above-guides-content');
6058
+ if (!portalLocation) return element;
6059
+ return /*#__PURE__*/createPortal(element, portalLocation);
6060
+ }
6061
+ var DebugStatsPaneDiv = styled.span(templateObject_1$G || (templateObject_1$G = __makeTemplateObject(["\n font-size: 16px;\n font-family: monospace;\n position: absolute;\n left: 20px;\n bottom: 20px;\n margin-right: 20px;\n padding: 8px;\n color: limegreen;\n background: rgba(0, 0, 0, 0.5);\n z-index: 10002;\n"], ["\n font-size: 16px;\n font-family: monospace;\n position: absolute;\n left: 20px;\n bottom: 20px;\n margin-right: 20px;\n padding: 8px;\n color: limegreen;\n background: rgba(0, 0, 0, 0.5);\n z-index: 10002;\n"])));
6062
+ var ObjectDetectionDebugOverlayDiv = styled.div(templateObject_2$z || (templateObject_2$z = __makeTemplateObject(["\n position: absolute;\n z-index: 1001;\n width: 100%;\n height: 100%;\n max-width: 100%;\n max-height: 100%;\n overflow: hidden;\n ", "\n transform-style: preserve-3d;\n"], ["\n position: absolute;\n z-index: 1001;\n width: 100%;\n height: 100%;\n max-width: 100%;\n max-height: 100%;\n overflow: hidden;\n ", "\n transform-style: preserve-3d;\n"])), function (_a) {
6063
+ var $flipX = _a.$flipX;
6064
+ return $flipX ? 'transform: scaleX(-1);' : '';
6065
+ });
6066
+ var ObjectDetectionDebugBox = styled.div(templateObject_3$q || (templateObject_3$q = __makeTemplateObject(["\n font: 10px monospace;\n position: absolute;\n border: 3px solid ", ";\n color: ", ";\n ", "\n transform-style: preserve-3d;\n"], ["\n font: 10px monospace;\n position: absolute;\n border: 3px solid ", ";\n color: ", ";\n ", "\n transform-style: preserve-3d;\n"])), function (_a) {
6067
+ var $color = _a.$color;
6068
+ return $color !== null && $color !== void 0 ? $color : 'green';
6069
+ }, function (_a) {
6070
+ var $color = _a.$color;
6071
+ return $color !== null && $color !== void 0 ? $color : 'green';
6072
+ }, function (_a) {
6073
+ var $flipX = _a.$flipX;
6074
+ return $flipX ? 'transform: scaleX(-1);' : '';
6075
+ });
6076
+ var FaceDetectionKeypointMarker = styled.div(templateObject_4$k || (templateObject_4$k = __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) {
6077
+ var $color = _a.$color;
6078
+ return $color !== null && $color !== void 0 ? $color : 'red';
6079
+ }, function (_a) {
6080
+ var $color = _a.$color;
6081
+ return $color !== null && $color !== void 0 ? $color : 'red';
6082
+ }, function (_a) {
6083
+ var $flipX = _a.$flipX;
6084
+ return $flipX ? 'transform: scaleX(-1);' : '';
6085
+ });
6086
+ function useDebugScalingDetails(_a) {
6087
+ var _b = _a.enabled,
6088
+ enabled = _b === void 0 ? true : _b,
6089
+ pageWidth = _a.pageWidth,
6090
+ pageHeight = _a.pageHeight,
6091
+ videoWidth = _a.videoWidth,
6092
+ videoHeight = _a.videoHeight;
6093
+ return useMemo(function () {
6094
+ var horizontal = false,
6095
+ scaledWidth = 0,
6096
+ scaledHeight = 0,
6097
+ xOffset = 0,
6098
+ yOffset = 0;
6099
+ if (enabled) {
6100
+ horizontal = pageWidth / pageHeight < videoWidth / videoHeight;
6101
+ if (horizontal) {
6102
+ scaledWidth = videoWidth * (pageHeight / videoHeight);
6103
+ xOffset = (scaledWidth - pageWidth) / 2;
6104
+ } else {
6105
+ scaledHeight = videoHeight * (pageWidth / videoWidth);
6106
+ yOffset = (scaledHeight - pageHeight) / 2;
6107
+ }
6110
6108
  }
6111
- });
6109
+ return {
6110
+ horizontal: horizontal,
6111
+ pageWidth: pageWidth,
6112
+ pageHeight: pageHeight,
6113
+ videoWidth: videoWidth,
6114
+ videoHeight: videoHeight,
6115
+ scaledWidth: scaledWidth,
6116
+ scaledHeight: scaledHeight,
6117
+ xOffset: xOffset,
6118
+ yOffset: yOffset
6119
+ };
6120
+ }, [enabled, pageHeight, pageWidth, videoHeight, videoWidth]);
6112
6121
  }
6113
- var useLanguage = function useLanguage(lang) {
6114
- var i18n = useTranslation().i18n;
6115
- useEffect(function () {
6116
- if (lang !== 'auto') {
6117
- void i18n.changeLanguage(lang);
6118
- } else {
6119
- void i18n.changeLanguage(); // call without argument to use detection
6122
+ var DebugBoundingBoxOverlay = function DebugBoundingBoxOverlay(_a) {
6123
+ var scaling = _a.scaling,
6124
+ $flipX = _a.$flipX,
6125
+ children = _a.children;
6126
+ var _b = useIdCaptureStore(),
6127
+ guideRectWidth = _b.guideRectWidth,
6128
+ guideRectHeight = _b.guideRectHeight,
6129
+ guideRectX = _b.guideRectX,
6130
+ guideRectY = _b.guideRectY;
6131
+ return /*#__PURE__*/React__default.createElement(ObjectDetectionDebugOverlayDiv, {
6132
+ id: "debug-overlay-div",
6133
+ "$flipX": $flipX,
6134
+ style: {
6135
+ top: guideRectY,
6136
+ left: guideRectX,
6137
+ width: guideRectWidth || (scaling === null || scaling === void 0 ? void 0 : scaling.pageWidth),
6138
+ height: guideRectHeight || (scaling === null || scaling === void 0 ? void 0 : scaling.pageHeight)
6120
6139
  }
6121
- }, [i18n, lang]);
6140
+ }, children);
6122
6141
  };
6123
- function evaluateVerbiage(t, currentLanguage, verbiage, fallback) {
6124
- if (typeof verbiage === 'string') return verbiage;
6125
- if (typeof verbiage === 'object') {
6126
- var translations = verbiage;
6127
- if (translations[currentLanguage]) return translations[currentLanguage];
6128
- var nonLocaleLang = currentLanguage.split('-')[0];
6129
- if (translations[nonLocaleLang]) return translations[nonLocaleLang];
6142
+ function IdCaptureDetectedObjectDebugBox(_a) {
6143
+ var obj = _a.obj,
6144
+ flipX = _a.flipX,
6145
+ _b = _a.color,
6146
+ color = _b === void 0 ? 'green' : _b,
6147
+ scaling = _a.scaling;
6148
+ var horizontal = scaling.horizontal,
6149
+ pageWidth = scaling.pageWidth,
6150
+ pageHeight = scaling.pageHeight,
6151
+ videoWidth = scaling.videoWidth,
6152
+ videoHeight = scaling.videoHeight,
6153
+ scaledWidth = scaling.scaledWidth,
6154
+ scaledHeight = scaling.scaledHeight,
6155
+ xOffset = scaling.xOffset,
6156
+ yOffset = scaling.yOffset;
6157
+ if (!videoWidth || !videoHeight || !pageWidth || !pageHeight) return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
6158
+ var top;
6159
+ var left;
6160
+ var width;
6161
+ var height;
6162
+ if (horizontal) {
6163
+ top = obj.box.yMin / videoHeight * pageHeight;
6164
+ left = obj.box.xMin / videoWidth * scaledWidth - xOffset;
6165
+ width = obj.box.width / videoWidth * scaledWidth;
6166
+ height = obj.box.height / videoHeight * pageHeight;
6167
+ } else {
6168
+ top = obj.box.yMin / videoHeight * scaledHeight - yOffset;
6169
+ left = obj.box.xMin / videoWidth * pageWidth;
6170
+ width = obj.box.width / videoWidth * pageWidth;
6171
+ height = obj.box.height / videoHeight * scaledHeight;
6130
6172
  }
6131
- return t(fallback);
6173
+ return /*#__PURE__*/React__default.createElement(ObjectDetectionDebugBox, {
6174
+ "$flipX": flipX,
6175
+ "$color": color,
6176
+ style: {
6177
+ top: top,
6178
+ left: left,
6179
+ width: width,
6180
+ height: height
6181
+ }
6182
+ });
6132
6183
  }
6133
- function useVerbiage(verbiage, fallback) {
6134
- var _a = useTranslation(),
6135
- t = _a.t,
6136
- i18n = _a.i18n;
6137
- return useMemo(function () {
6138
- return evaluateVerbiage(t, i18n.language, verbiage, fallback);
6139
- }, [fallback, i18n.language, t, verbiage]);
6184
+ function SelfieCaptureFaceDebugBox(_a) {
6185
+ var face = _a.face,
6186
+ flipX = _a.flipX,
6187
+ _b = _a.color,
6188
+ color = _b === void 0 ? 'green' : _b,
6189
+ scaling = _a.scaling;
6190
+ var horizontal = scaling.horizontal,
6191
+ pageWidth = scaling.pageWidth,
6192
+ pageHeight = scaling.pageHeight,
6193
+ videoWidth = scaling.videoWidth,
6194
+ videoHeight = scaling.videoHeight,
6195
+ scaledWidth = scaling.scaledWidth,
6196
+ scaledHeight = scaling.scaledHeight,
6197
+ xOffset = scaling.xOffset,
6198
+ yOffset = scaling.yOffset;
6199
+ if (!videoWidth || !videoHeight || !pageWidth || !pageHeight) return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
6200
+ var top;
6201
+ var left;
6202
+ var width;
6203
+ var height;
6204
+ if (horizontal) {
6205
+ top = face.box.yMin / videoHeight * pageHeight;
6206
+ left = face.box.xMin / videoWidth * scaledWidth - xOffset;
6207
+ width = face.box.width / videoWidth * scaledWidth;
6208
+ height = face.box.height / videoHeight * pageHeight;
6209
+ } else {
6210
+ top = face.box.yMin / videoHeight * scaledHeight - yOffset;
6211
+ left = face.box.xMin / videoWidth * pageWidth;
6212
+ width = face.box.width / videoWidth * pageWidth;
6213
+ height = face.box.height / videoHeight * scaledHeight;
6214
+ }
6215
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(ObjectDetectionDebugBox, {
6216
+ "$flipX": flipX,
6217
+ "$color": color,
6218
+ style: {
6219
+ top: top,
6220
+ left: left,
6221
+ width: width,
6222
+ height: height
6223
+ }
6224
+ }), face.keypoints.map(function (point, ii) {
6225
+ return /*#__PURE__*/React__default.createElement(SelfieCaptureFaceKeypoint, {
6226
+ key: ii,
6227
+ point: point,
6228
+ scaling: scaling,
6229
+ flipX: flipX
6230
+ });
6231
+ }));
6140
6232
  }
6141
- function useTranslations(verbiage, fallbacks) {
6142
- var _a = useTranslation(),
6143
- t = _a.t,
6144
- i18n = _a.i18n;
6145
- return useMemo(function () {
6146
- return _assign(_assign({}, verbiage), Object.keys(fallbacks).reduce(function (result, key) {
6147
- var _a;
6148
- return _assign(_assign({}, result), (_a = {}, _a[key] = evaluateVerbiage(t, i18n.language, verbiage === null || verbiage === void 0 ? void 0 : verbiage[key], fallbacks[key]), _a));
6149
- }, {}));
6150
- }, [fallbacks, i18n.language, t, verbiage]);
6233
+ function SelfieCaptureFaceKeypoint(_a) {
6234
+ var point = _a.point,
6235
+ flipX = _a.flipX,
6236
+ _b = _a.color,
6237
+ color = _b === void 0 ? 'red' : _b,
6238
+ _c = _a.scaling,
6239
+ horizontal = _c.horizontal,
6240
+ pageWidth = _c.pageWidth,
6241
+ pageHeight = _c.pageHeight,
6242
+ videoWidth = _c.videoWidth,
6243
+ videoHeight = _c.videoHeight,
6244
+ scaledWidth = _c.scaledWidth,
6245
+ scaledHeight = _c.scaledHeight,
6246
+ xOffset = _c.xOffset,
6247
+ yOffset = _c.yOffset;
6248
+ var left, top;
6249
+ if (horizontal) {
6250
+ left = point.x / videoWidth * scaledWidth - xOffset;
6251
+ top = point.y / videoHeight * pageHeight;
6252
+ } else {
6253
+ left = point.x / videoWidth * pageWidth;
6254
+ top = point.y / videoHeight * scaledHeight - yOffset;
6255
+ }
6256
+ top -= 2;
6257
+ left -= 2;
6258
+ return /*#__PURE__*/React__default.createElement(FaceDetectionKeypointMarker, {
6259
+ "$flipX": flipX,
6260
+ "$color": color,
6261
+ style: {
6262
+ top: top,
6263
+ left: left
6264
+ }
6265
+ });
6151
6266
  }
6267
+ var templateObject_1$G, templateObject_2$z, templateObject_3$q, templateObject_4$k;
6152
6268
 
6153
6269
  var GuidanceMessageContainerDiv = styled.div(templateObject_1$F || (templateObject_1$F = __makeTemplateObject(["\n position: absolute;\n top: calc(", ");\n ", "\n font-weight: bold;\n width: 100%;\n display: flex;\n"], ["\n position: absolute;\n top: calc(", ");\n ", "\n font-weight: bold;\n width: 100%;\n display: flex;\n"])), function (_a) {
6154
6270
  var $top = _a.$top;
@@ -13752,9 +13868,10 @@ function VideoSignatureWizardGuides(_a) {
13752
13868
  });
13753
13869
  }
13754
13870
  var VideoSignatureWizardWithProviders = function VideoSignatureWizardWithProviders(props) {
13755
- var _a = useState(0),
13756
- attempts = _a[0],
13757
- setAttempts = _a[1];
13871
+ var _a, _b;
13872
+ var _c = useState(0),
13873
+ attempts = _c[0],
13874
+ setAttempts = _c[1];
13758
13875
  var onRetryClickedProp = props.onRetryClicked;
13759
13876
  var onRetryClicked = useCallback(function () {
13760
13877
  setAttempts(function (n) {
@@ -13770,7 +13887,10 @@ var VideoSignatureWizardWithProviders = function VideoSignatureWizardWithProvide
13770
13887
  maxVideoWidth: 1280,
13771
13888
  maxFps: 30,
13772
13889
  onCameraAccessDenied: props.onCameraAccessDenied,
13773
- onMicrophoneAccessDenied: props.onMicrophoneAccessDenied
13890
+ onCameraTamperingDetected: props.onCameraTamperingDetected,
13891
+ onMicrophoneAccessDenied: props.onMicrophoneAccessDenied,
13892
+ classNames: (_a = props.classNames) === null || _a === void 0 ? void 0 : _a.cameraStoreProvider,
13893
+ verbiage: (_b = props.verbiage) === null || _b === void 0 ? void 0 : _b.cameraStoreProvider
13774
13894
  }, /*#__PURE__*/React__default.createElement(SelfieGuidanceModelsProvider, {
13775
13895
  autoStart: false,
13776
13896
  throttleMs: 250,
@@ -14609,6 +14729,7 @@ var VideoIdWizard = function VideoIdWizard(_a) {
14609
14729
  onUserCancel = _a.onUserCancel,
14610
14730
  onIdCaptureModelError = _a.onIdCaptureModelError,
14611
14731
  onCameraAccessDenied = _a.onCameraAccessDenied,
14732
+ onCameraTamperingDetected = _a.onCameraTamperingDetected,
14612
14733
  onMicrophoneAccessDenied = _a.onMicrophoneAccessDenied,
14613
14734
  _l = _a.idCaptureProps,
14614
14735
  idCaptureProps = _l === void 0 ? {} : _l,
@@ -14767,7 +14888,10 @@ var VideoIdWizard = function VideoIdWizard(_a) {
14767
14888
  maxVideoWidth: isCapturingId ? 1920 : 1280,
14768
14889
  maxFps: isCapturingId ? 60 : 30,
14769
14890
  onCameraAccessDenied: onCameraAccessDenied,
14770
- onMicrophoneAccessDenied: onMicrophoneAccessDenied
14891
+ onCameraTamperingDetected: onCameraTamperingDetected,
14892
+ onMicrophoneAccessDenied: onMicrophoneAccessDenied,
14893
+ classNames: classNames === null || classNames === void 0 ? void 0 : classNames.cameraStoreProvider,
14894
+ verbiage: verbiage === null || verbiage === void 0 ? void 0 : verbiage.cameraStoreProvider
14771
14895
  }, /*#__PURE__*/React__default.createElement(IdCaptureModelsProvider, {
14772
14896
  autoStart: false,
14773
14897
  documentDetectionModelUrl: (_g = (_f = idCaptureProps.assets) === null || _f === void 0 ? void 0 : _f.documentDetectionModelUrl) !== null && _g !== void 0 ? _g : '',
@@ -14878,35 +15002,36 @@ var VideoIdWizard = function VideoIdWizard(_a) {
14878
15002
  };
14879
15003
 
14880
15004
  function CompositeWizard(_a) {
14881
- var _b, _c, _d, _e, _f;
15005
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k;
14882
15006
  var userChecks = _a.checks,
14883
- _g = _a.idCaptureProps,
14884
- idCaptureProps = _g === void 0 ? {} : _g,
14885
- _h = _a.faceLivenessProps,
14886
- faceLivenessProps = _h === void 0 ? {} : _h,
15007
+ _l = _a.idCaptureProps,
15008
+ idCaptureProps = _l === void 0 ? {} : _l,
15009
+ _m = _a.faceLivenessProps,
15010
+ faceLivenessProps = _m === void 0 ? {} : _m,
14887
15011
  additionalDocumentCaptureProps = _a.additionalDocumentCaptureProps,
14888
- _j = _a.signatureCaptureProps,
14889
- signatureCaptureProps = _j === void 0 ? {} : _j,
14890
- _k = _a.videoSignatureCaptureProps,
14891
- videoSignatureCaptureProps = _k === void 0 ? {} : _k,
14892
- _l = _a.videoIdCaptureProps,
14893
- videoIdCaptureProps = _l === void 0 ? {} : _l,
14894
- _m = _a.captureSignature,
14895
- captureSignature = _m === void 0 ? false : _m,
14896
- _o = _a.captureSignatureVideo,
14897
- captureSignatureVideo = _o === void 0 ? false : _o,
15012
+ _o = _a.signatureCaptureProps,
15013
+ signatureCaptureProps = _o === void 0 ? {} : _o,
15014
+ _p = _a.videoSignatureCaptureProps,
15015
+ videoSignatureCaptureProps = _p === void 0 ? {} : _p,
15016
+ _q = _a.videoIdCaptureProps,
15017
+ videoIdCaptureProps = _q === void 0 ? {} : _q,
15018
+ _r = _a.captureSignature,
15019
+ captureSignature = _r === void 0 ? false : _r,
15020
+ _s = _a.captureSignatureVideo,
15021
+ captureSignatureVideo = _s === void 0 ? false : _s,
14898
15022
  onCameraAccessDenied = _a.onCameraAccessDenied,
15023
+ onCameraTamperingDetected = _a.onCameraTamperingDetected,
14899
15024
  onMicrophoneAccessDenied = _a.onMicrophoneAccessDenied,
14900
- _p = _a.debugMode,
14901
- debugMode = _p === void 0 ? false : _p;
14902
- var _q = useContext(SubmissionContext),
14903
- submit = _q.submit,
14904
- submissionStatus = _q.submissionStatus,
14905
- setSignatureData = _q.setSignatureData,
14906
- setAdditionalDocuments = _q.setAdditionalDocuments;
14907
- var _r = useState(0),
14908
- checkIndex = _r[0],
14909
- setCheckIndex = _r[1];
15025
+ _t = _a.debugMode,
15026
+ debugMode = _t === void 0 ? false : _t;
15027
+ var _u = useContext(SubmissionContext),
15028
+ submit = _u.submit,
15029
+ submissionStatus = _u.submissionStatus,
15030
+ setSignatureData = _u.setSignatureData,
15031
+ setAdditionalDocuments = _u.setAdditionalDocuments;
15032
+ var _v = useState(0),
15033
+ checkIndex = _v[0],
15034
+ setCheckIndex = _v[1];
14910
15035
  var checks = useMemo(function () {
14911
15036
  var _a, _b;
14912
15037
  var checks = __spreadArray([], userChecks, true);
@@ -15017,13 +15142,16 @@ function CompositeWizard(_a) {
15017
15142
  case 'IdCapture':
15018
15143
  return /*#__PURE__*/React__default.createElement(CameraStoreProvider, {
15019
15144
  onCameraAccessDenied: onCameraAccessDenied,
15145
+ onCameraTamperingDetected: onCameraTamperingDetected,
15020
15146
  onMicrophoneAccessDenied: onMicrophoneAccessDenied,
15021
- requestAccessAutomatically: shouldLoadIdCaptureModels
15147
+ requestAccessAutomatically: shouldLoadIdCaptureModels,
15148
+ classNames: (_c = idCaptureProps.classNames) === null || _c === void 0 ? void 0 : _c.cameraStoreProvider,
15149
+ verbiage: (_d = idCaptureProps.verbiage) === null || _d === void 0 ? void 0 : _d.cameraStoreProvider
15022
15150
  }, /*#__PURE__*/React__default.createElement(IdCaptureModelsProvider, {
15023
15151
  autoStart: false,
15024
15152
  shouldLoadModels: shouldLoadIdCaptureModels,
15025
- documentDetectionModelUrl: (_d = (_c = idCaptureProps.assets) === null || _c === void 0 ? void 0 : _c.documentDetectionModelUrl) !== null && _d !== void 0 ? _d : '',
15026
- focusModelUrl: (_f = (_e = idCaptureProps.assets) === null || _e === void 0 ? void 0 : _e.focusModelUrl) !== null && _f !== void 0 ? _f : '',
15153
+ documentDetectionModelUrl: (_f = (_e = idCaptureProps.assets) === null || _e === void 0 ? void 0 : _e.documentDetectionModelUrl) !== null && _f !== void 0 ? _f : '',
15154
+ focusModelUrl: (_h = (_g = idCaptureProps.assets) === null || _g === void 0 ? void 0 : _g.focusModelUrl) !== null && _h !== void 0 ? _h : '',
15027
15155
  onModelError: idCaptureProps.onModelError,
15028
15156
  modelLoadTimeoutMs: idCaptureProps.modelLoadTimeoutMs,
15029
15157
  allowSinglePageIdCapture: idCaptureProps.allowSinglePageIdCapture
@@ -15034,6 +15162,7 @@ function CompositeWizard(_a) {
15034
15162
  return /*#__PURE__*/React__default.createElement(VideoIdWizard, _assign({}, videoIdCaptureProps, {
15035
15163
  onComplete: onVideoIdCaptureComplete,
15036
15164
  onCameraAccessDenied: onCameraAccessDenied,
15165
+ onCameraTamperingDetected: onCameraTamperingDetected,
15037
15166
  onMicrophoneAccessDenied: onMicrophoneAccessDenied
15038
15167
  }));
15039
15168
  case 'FaceLiveness':
@@ -15041,7 +15170,10 @@ function CompositeWizard(_a) {
15041
15170
  preferFrontFacingCamera: true,
15042
15171
  preferIphoneContinuityCamera: false,
15043
15172
  onCameraAccessDenied: onCameraAccessDenied,
15044
- onMicrophoneAccessDenied: onMicrophoneAccessDenied
15173
+ onCameraTamperingDetected: onCameraTamperingDetected,
15174
+ onMicrophoneAccessDenied: onMicrophoneAccessDenied,
15175
+ classNames: (_j = faceLivenessProps.classNames) === null || _j === void 0 ? void 0 : _j.cameraStoreProvider,
15176
+ verbiage: (_k = faceLivenessProps.verbiage) === null || _k === void 0 ? void 0 : _k.cameraStoreProvider
15045
15177
  }, /*#__PURE__*/React__default.createElement(SelfieGuidanceModelsProvider, {
15046
15178
  autoStart: false,
15047
15179
  onModelError: faceLivenessProps.onModelError,
@@ -15057,6 +15189,7 @@ function CompositeWizard(_a) {
15057
15189
  return /*#__PURE__*/React__default.createElement(VideoSignatureWizardWithProviders, _assign({}, videoSignatureCaptureProps, {
15058
15190
  onComplete: onVideoSignatureComplete,
15059
15191
  onCameraAccessDenied: onCameraAccessDenied,
15192
+ onCameraTamperingDetected: onCameraTamperingDetected,
15060
15193
  onMicrophoneAccessDenied: onMicrophoneAccessDenied
15061
15194
  }));
15062
15195
  case 'AdditionalDocumentCapture':
@@ -15386,6 +15519,7 @@ var IdValidation = function IdValidation(_a) {
15386
15519
  onUserCancel = _a.onUserCancel,
15387
15520
  onModelError = _a.onModelError,
15388
15521
  onCameraAccessDenied = _a.onCameraAccessDenied,
15522
+ onCameraTamperingDetected = _a.onCameraTamperingDetected,
15389
15523
  _u = _a.theme,
15390
15524
  theme = _u === void 0 ? 'default' : _u,
15391
15525
  _v = _a.assets,
@@ -15527,6 +15661,7 @@ var IdValidation = function IdValidation(_a) {
15527
15661
  captureSignature: captureSignature,
15528
15662
  captureSignatureVideo: captureSignatureVideo,
15529
15663
  onCameraAccessDenied: onCameraAccessDenied,
15664
+ onCameraTamperingDetected: onCameraTamperingDetected,
15530
15665
  debugMode: debugMode
15531
15666
  }))));
15532
15667
  };
@@ -15581,6 +15716,7 @@ var FaceValidation = function FaceValidation(_a) {
15581
15716
  onUserCancel = _a.onUserCancel,
15582
15717
  onModelError = _a.onModelError,
15583
15718
  onCameraAccessDenied = _a.onCameraAccessDenied,
15719
+ onCameraTamperingDetected = _a.onCameraTamperingDetected,
15584
15720
  _j = _a.theme,
15585
15721
  theme = _j === void 0 ? 'default' : _j,
15586
15722
  assets = _a.assets,
@@ -15656,6 +15792,7 @@ var FaceValidation = function FaceValidation(_a) {
15656
15792
  }, []),
15657
15793
  faceLivenessProps: faceLivenessProps,
15658
15794
  onCameraAccessDenied: onCameraAccessDenied,
15795
+ onCameraTamperingDetected: onCameraTamperingDetected,
15659
15796
  debugMode: debugMode
15660
15797
  }))));
15661
15798
  };
@@ -15752,6 +15889,7 @@ var IdAndFaceValidation = function IdAndFaceValidation(_a) {
15752
15889
  onIdCaptureModelError = _a.onIdCaptureModelError,
15753
15890
  onSelfieCaptureModelError = _a.onSelfieCaptureModelError,
15754
15891
  onCameraAccessDenied = _a.onCameraAccessDenied,
15892
+ onCameraTamperingDetected = _a.onCameraTamperingDetected,
15755
15893
  _y = _a.captureSignature,
15756
15894
  captureSignature = _y === void 0 ? false : _y,
15757
15895
  _z = _a.captureSignatureVideo,
@@ -15915,6 +16053,7 @@ var IdAndFaceValidation = function IdAndFaceValidation(_a) {
15915
16053
  captureSignature: captureSignature,
15916
16054
  captureSignatureVideo: captureSignatureVideo,
15917
16055
  onCameraAccessDenied: onCameraAccessDenied,
16056
+ onCameraTamperingDetected: onCameraTamperingDetected,
15918
16057
  debugMode: debugMode
15919
16058
  }))));
15920
16059
  };
@@ -16014,6 +16153,7 @@ var CustomerIdAndBiometricsEnrollment = function CustomerIdAndBiometricsEnrollme
16014
16153
  onIdCaptureModelError = _a.onIdCaptureModelError,
16015
16154
  onSelfieCaptureModelError = _a.onSelfieCaptureModelError,
16016
16155
  onCameraAccessDenied = _a.onCameraAccessDenied,
16156
+ onCameraTamperingDetected = _a.onCameraTamperingDetected,
16017
16157
  _y = _a.captureSignature,
16018
16158
  captureSignature = _y === void 0 ? false : _y,
16019
16159
  _z = _a.captureSignatureVideo,
@@ -16199,6 +16339,7 @@ var CustomerIdAndBiometricsEnrollment = function CustomerIdAndBiometricsEnrollme
16199
16339
  captureSignature: captureSignature,
16200
16340
  captureSignatureVideo: captureSignatureVideo,
16201
16341
  onCameraAccessDenied: onCameraAccessDenied,
16342
+ onCameraTamperingDetected: onCameraTamperingDetected,
16202
16343
  debugMode: debugMode
16203
16344
  }))));
16204
16345
  };
@@ -16708,6 +16849,7 @@ var CustomerVerification = function CustomerVerification(_a) {
16708
16849
  onUserCancel = _a.onUserCancel,
16709
16850
  onModelError = _a.onModelError,
16710
16851
  onCameraAccessDenied = _a.onCameraAccessDenied,
16852
+ onCameraTamperingDetected = _a.onCameraTamperingDetected,
16711
16853
  _h = _a.geolocationEnabled,
16712
16854
  geolocationEnabled = _h === void 0 ? true : _h,
16713
16855
  _j = _a.geolocationRequired,
@@ -16749,7 +16891,10 @@ var CustomerVerification = function CustomerVerification(_a) {
16749
16891
  useDocumentServiceForLivenessChecks: useDocumentServiceForLivenessChecks
16750
16892
  }, /*#__PURE__*/React__default.createElement(CameraStoreProvider, {
16751
16893
  preferFrontFacingCamera: true,
16752
- onCameraAccessDenied: onCameraAccessDenied
16894
+ onCameraAccessDenied: onCameraAccessDenied,
16895
+ onCameraTamperingDetected: onCameraTamperingDetected,
16896
+ classNames: classNames === null || classNames === void 0 ? void 0 : classNames.cameraStoreProvider,
16897
+ verbiage: verbiage === null || verbiage === void 0 ? void 0 : verbiage.cameraStoreProvider
16753
16898
  }, /*#__PURE__*/React__default.createElement(SelfieGuidanceModelsProvider, {
16754
16899
  autoStart: false,
16755
16900
  onModelError: onModelError,
@@ -17269,6 +17414,7 @@ var CustomerIdentification = function CustomerIdentification(_a) {
17269
17414
  onUserCancel = _a.onUserCancel,
17270
17415
  onModelError = _a.onModelError,
17271
17416
  onCameraAccessDenied = _a.onCameraAccessDenied,
17417
+ onCameraTamperingDetected = _a.onCameraTamperingDetected,
17272
17418
  _g = _a.theme,
17273
17419
  theme = _g === void 0 ? 'default' : _g,
17274
17420
  assets = _a.assets,
@@ -17314,7 +17460,10 @@ var CustomerIdentification = function CustomerIdentification(_a) {
17314
17460
  useDocumentServiceForLivenessChecks: useDocumentServiceForLivenessChecks
17315
17461
  }, /*#__PURE__*/React__default.createElement(CameraStoreProvider, {
17316
17462
  preferFrontFacingCamera: true,
17317
- onCameraAccessDenied: onCameraAccessDenied
17463
+ onCameraAccessDenied: onCameraAccessDenied,
17464
+ onCameraTamperingDetected: onCameraTamperingDetected,
17465
+ classNames: classNames === null || classNames === void 0 ? void 0 : classNames.cameraStoreProvider,
17466
+ verbiage: verbiage === null || verbiage === void 0 ? void 0 : verbiage.cameraStoreProvider
17318
17467
  }, /*#__PURE__*/React__default.createElement(SelfieGuidanceModelsProvider, {
17319
17468
  autoStart: false,
17320
17469
  modelLoadTimeoutMs: modelLoadTimeoutMs,
@@ -17362,6 +17511,7 @@ var SignatureKYC = function SignatureKYC(_a) {
17362
17511
  onUserCancel = _a.onUserCancel,
17363
17512
  onModelError = _a.onModelError,
17364
17513
  onCameraAccessDenied = _a.onCameraAccessDenied,
17514
+ onCameraTamperingDetected = _a.onCameraTamperingDetected,
17365
17515
  onLoadingOverlayDismissed = _a.onLoadingOverlayDismissed,
17366
17516
  _c = _a.loadingOverlayMode,
17367
17517
  loadingOverlayMode = _c === void 0 ? 'default' : _c,
@@ -17420,6 +17570,7 @@ var SignatureKYC = function SignatureKYC(_a) {
17420
17570
  return ['VideoSignatureCapture'];
17421
17571
  }, []),
17422
17572
  onCameraAccessDenied: onCameraAccessDenied,
17573
+ onCameraTamperingDetected: onCameraTamperingDetected,
17423
17574
  videoSignatureCaptureProps: useMemo(function () {
17424
17575
  return {
17425
17576
  customOverlayContent: customOverlayContent,
@@ -17488,6 +17639,7 @@ var VideoIdValidation = function VideoIdValidation(_a) {
17488
17639
  onExitAfterFailure = _a.onExitAfterFailure,
17489
17640
  onUserCancel = _a.onUserCancel,
17490
17641
  onCameraAccessDenied = _a.onCameraAccessDenied,
17642
+ onCameraTamperingDetected = _a.onCameraTamperingDetected,
17491
17643
  onMicrophoneAccessDenied = _a.onMicrophoneAccessDenied,
17492
17644
  idCaptureProps = _a.idCaptureProps,
17493
17645
  faceLivenessProps = _a.faceLivenessProps,
@@ -17671,6 +17823,7 @@ var VideoIdValidation = function VideoIdValidation(_a) {
17671
17823
  captureSignature: captureSignature,
17672
17824
  captureSignatureVideo: captureSignatureVideo,
17673
17825
  onCameraAccessDenied: onCameraAccessDenied,
17826
+ onCameraTamperingDetected: onCameraTamperingDetected,
17674
17827
  onMicrophoneAccessDenied: onMicrophoneAccessDenied,
17675
17828
  debugMode: debugMode
17676
17829
  }))));
@@ -17726,6 +17879,7 @@ var CustomerBiometricsEnrollment = function CustomerBiometricsEnrollment(_a) {
17726
17879
  onUserCancel = _a.onUserCancel,
17727
17880
  onModelError = _a.onModelError,
17728
17881
  onCameraAccessDenied = _a.onCameraAccessDenied,
17882
+ onCameraTamperingDetected = _a.onCameraTamperingDetected,
17729
17883
  _h = _a.captureAdditionalDocuments,
17730
17884
  captureAdditionalDocuments = _h === void 0 ? [] : _h,
17731
17885
  _j = _a.captureSignature,
@@ -17847,6 +18001,7 @@ var CustomerBiometricsEnrollment = function CustomerBiometricsEnrollment(_a) {
17847
18001
  captureSignature: captureSignature,
17848
18002
  captureSignatureVideo: captureSignatureVideo,
17849
18003
  onCameraAccessDenied: onCameraAccessDenied,
18004
+ onCameraTamperingDetected: onCameraTamperingDetected,
17850
18005
  debugMode: debugMode
17851
18006
  }))));
17852
18007
  };
@@ -17874,6 +18029,7 @@ var DocumentCapture = function DocumentCapture(_a) {
17874
18029
  onExitCapture = _a.onExitCapture,
17875
18030
  onUserCancel = _a.onUserCancel,
17876
18031
  onCameraAccessDenied = _a.onCameraAccessDenied,
18032
+ onCameraTamperingDetected = _a.onCameraTamperingDetected,
17877
18033
  _c = _a.documents,
17878
18034
  documents = _c === void 0 ? [] : _c,
17879
18035
  aspectRatio = _a.aspectRatio,
@@ -17916,7 +18072,10 @@ var DocumentCapture = function DocumentCapture(_a) {
17916
18072
  }, /*#__PURE__*/React__default.createElement(CameraStoreProvider, {
17917
18073
  requestAccessAutomatically: false,
17918
18074
  preferIphoneContinuityCamera: true,
17919
- onCameraAccessDenied: onCameraAccessDenied
18075
+ onCameraAccessDenied: onCameraAccessDenied,
18076
+ onCameraTamperingDetected: onCameraTamperingDetected,
18077
+ classNames: classNames === null || classNames === void 0 ? void 0 : classNames.cameraStoreProvider,
18078
+ verbiage: verbiage === null || verbiage === void 0 ? void 0 : verbiage.cameraStoreProvider
17920
18079
  }, /*#__PURE__*/React__default.createElement(DocumentCaptureWizard, {
17921
18080
  onSuccess: onComplete,
17922
18081
  onExitCapture: onExitCapture,