@incodetech/core 2.0.0 → 2.0.1-rc.0

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 (178) hide show
  1. package/dist/Actor-CI32dTbG.d.ts +2 -0
  2. package/dist/BaseWasmProvider-C_DLEI40.esm.js +1118 -0
  3. package/dist/BrowserStorageProvider-CuOW1Er2.esm.js +55 -0
  4. package/dist/BrowserTimerProvider-DhNc_x02.esm.js +22 -0
  5. package/dist/ITimerCapability-C67ZRskg.esm.js +7 -0
  6. package/dist/IpifyProvider-D7jx52AL.esm.js +139 -0
  7. package/dist/Manager-C8PrhBOx.d.ts +19 -0
  8. package/dist/MotionSensorProvider-4v7xkqAp.esm.js +254 -0
  9. package/dist/OpenViduRecordingProvider-CMu6XVdc.esm.js +87 -0
  10. package/dist/StateMachine-BCQrZJhf.d.ts +2 -0
  11. package/dist/WasmUtilProvider-j98OJf-S.esm.js +114 -0
  12. package/dist/addressSearch-BpTbTWCa.esm.js +430 -0
  13. package/dist/ae-signature-DDDZmWXj.esm.js +12 -0
  14. package/dist/ae-signature.d.ts +25 -0
  15. package/dist/ae-signature.esm.js +8 -0
  16. package/dist/antifraud.d.ts +57 -0
  17. package/dist/antifraud.esm.js +45 -0
  18. package/dist/antifraudStateMachine-O0TMf6yc.esm.js +39 -0
  19. package/dist/api-CESGtpbH.esm.js +53 -0
  20. package/dist/authentication.d.ts +12 -0
  21. package/dist/authentication.esm.js +25 -0
  22. package/dist/authenticationManager-5M-fKzXx.esm.js +67 -0
  23. package/dist/authenticationManager-C83GNIhl.d.ts +66 -0
  24. package/dist/authenticationStateMachine-BMZqatiF.esm.js +139 -0
  25. package/dist/backCameraStream-DMdMeGk2.esm.js +346 -0
  26. package/dist/browserSimulation-gxD8cSpM.esm.js +20 -0
  27. package/dist/camera-DBSxa6ML.d.ts +4 -0
  28. package/dist/camera-PA2Ljri3.esm.js +22 -0
  29. package/dist/camera.d.ts +15 -0
  30. package/dist/camera.esm.js +5 -0
  31. package/dist/chunk-CRF6K_H_.esm.js +49 -0
  32. package/dist/consent.d.ts +398 -0
  33. package/dist/consent.esm.js +79 -0
  34. package/dist/consentStateMachine-CCT-B60O.esm.js +151 -0
  35. package/dist/cpf-PPz2Njto.esm.js +38 -0
  36. package/dist/cpf-ocr.d.ts +204 -0
  37. package/dist/cpf-ocr.esm.js +177 -0
  38. package/dist/cross-document-data-match.d.ts +34 -0
  39. package/dist/cross-document-data-match.esm.js +71 -0
  40. package/dist/curp-validation.d.ts +188 -0
  41. package/dist/curp-validation.esm.js +110 -0
  42. package/dist/curpValidationStateMachine-CitWLr2c.esm.js +595 -0
  43. package/dist/custom-fields.d.ts +115 -0
  44. package/dist/custom-fields.esm.js +177 -0
  45. package/dist/custom-watchlist.d.ts +66 -0
  46. package/dist/custom-watchlist.esm.js +86 -0
  47. package/dist/dateUtils-UoN5xswP.esm.js +23 -0
  48. package/dist/deepsightLoader-Cm4JIT_z.esm.js +52 -0
  49. package/dist/deepsightService-CEVxzehb.d.ts +412 -0
  50. package/dist/deepsightService-O74l4Y__.esm.js +489 -0
  51. package/dist/device.d.ts +46 -0
  52. package/dist/device.esm.js +106 -0
  53. package/dist/displayErrors-DqJ_IbsG.d.ts +39 -0
  54. package/dist/document-capture.d.ts +906 -0
  55. package/dist/document-capture.esm.js +156 -0
  56. package/dist/document-upload.d.ts +331 -0
  57. package/dist/document-upload.esm.js +203 -0
  58. package/dist/documentCaptureStateMachine-BqzTDy9k.esm.js +394 -0
  59. package/dist/dynamic-forms.d.ts +178 -0
  60. package/dist/dynamic-forms.esm.js +323 -0
  61. package/dist/ekyb.d.ts +148 -0
  62. package/dist/ekyb.esm.js +127 -0
  63. package/dist/ekybStateMachine-BR2let5f.esm.js +674 -0
  64. package/dist/ekyc.d.ts +164 -0
  65. package/dist/ekyc.esm.js +104 -0
  66. package/dist/ekycStateMachine-oeO0Iekd.esm.js +10626 -0
  67. package/dist/electronic-signature.d.ts +4 -0
  68. package/dist/electronic-signature.esm.js +7 -0
  69. package/dist/electronicSignatureManager-D9OHzTpG.esm.js +428 -0
  70. package/dist/email.d.ts +4 -0
  71. package/dist/email.esm.js +9 -0
  72. package/dist/emailManager-DIfnS5g1.d.ts +352 -0
  73. package/dist/emailManager-wAV0LE-H.esm.js +238 -0
  74. package/dist/emailStateMachine-DOf4j58N.esm.js +292 -0
  75. package/dist/endpoints-CnN3SyDa.esm.js +87 -0
  76. package/dist/events-D6-e4vok.esm.js +596 -0
  77. package/dist/events.d.ts +265 -0
  78. package/dist/events.esm.js +4 -0
  79. package/dist/extensibility.d.ts +122 -0
  80. package/dist/extensibility.esm.js +43 -0
  81. package/dist/face-match.d.ts +228 -0
  82. package/dist/face-match.esm.js +173 -0
  83. package/dist/faceCaptureManagerFactory-Dh2PdGlF.esm.js +290 -0
  84. package/dist/faceCaptureManagerFactory-yqtpxjnN.d.ts +690 -0
  85. package/dist/faceCaptureSetup-B3faSpYA.esm.js +873 -0
  86. package/dist/faceMatchStateMachine-DNFrxTFS.esm.js +127 -0
  87. package/dist/flow-events.d.ts +6 -0
  88. package/dist/flow-events.esm.js +0 -0
  89. package/dist/flow.d.ts +358 -0
  90. package/dist/flow.esm.js +825 -0
  91. package/dist/flowCompletionService-DhkT4SRY.d.ts +10 -0
  92. package/dist/flowCompletionService-P54yzGvA.esm.js +13 -0
  93. package/dist/flowServices-DG3IdWw6.esm.js +188 -0
  94. package/dist/geolocation.d.ts +127 -0
  95. package/dist/geolocation.esm.js +89 -0
  96. package/dist/geolocationStateMachine-asasuHY2.esm.js +105 -0
  97. package/dist/getBrowser-BSXUTWXw.esm.js +41 -0
  98. package/dist/getDeviceClass-BSntT9_j.esm.js +14 -0
  99. package/dist/government-validation.d.ts +67 -0
  100. package/dist/government-validation.esm.js +81 -0
  101. package/dist/governmentValidationStateMachine-BDDYrJTo.esm.js +271 -0
  102. package/dist/home.d.ts +99 -0
  103. package/dist/home.esm.js +61 -0
  104. package/dist/http.d.ts +68 -0
  105. package/dist/http.esm.js +3 -0
  106. package/dist/id-ocr.d.ts +635 -0
  107. package/dist/id-ocr.esm.js +86 -0
  108. package/dist/id-verification.d.ts +190 -0
  109. package/dist/id-verification.esm.js +43 -0
  110. package/dist/id.d.ts +24 -0
  111. package/dist/id.esm.js +164 -0
  112. package/dist/idCaptureManager-Fyd0eam-.d.ts +958 -0
  113. package/dist/idCaptureManager-ZPkD7Gjk.esm.js +581 -0
  114. package/dist/idCaptureStateMachine-BK0bPHoc.esm.js +2963 -0
  115. package/dist/idOcrStateMachine-YbjjC_Gg.esm.js +388 -0
  116. package/dist/idVerificationStateMachine-xbw9HP1Z.esm.js +71 -0
  117. package/dist/identity-reuse.d.ts +530 -0
  118. package/dist/identity-reuse.esm.js +274 -0
  119. package/dist/index-BcRG8rtJ.d.ts +97 -0
  120. package/dist/index-DZoqeAo9.d.ts +1177 -0
  121. package/dist/index.d.ts +3 -0
  122. package/dist/index.esm.js +12 -0
  123. package/dist/invokeOnCaptureCallback-rc6kBHo5.esm.js +30 -0
  124. package/dist/lib-BB0B_qQX.esm.js +12499 -0
  125. package/dist/mandatory-consent.d.ts +412 -0
  126. package/dist/mandatory-consent.esm.js +78 -0
  127. package/dist/mandatoryConsentStateMachine-Cnco1jvn.esm.js +126 -0
  128. package/dist/openviduLazy-Cm0XFh_v.esm.js +3 -0
  129. package/dist/openviduLazy-Cok70ZSg.esm.js +12 -0
  130. package/dist/permissionServices-D_i6nzEw.esm.js +50 -0
  131. package/dist/phone.d.ts +4 -0
  132. package/dist/phone.esm.js +9 -0
  133. package/dist/phoneManager-B6M30hKE.d.ts +397 -0
  134. package/dist/phoneManager-DAJbGhlY.esm.js +256 -0
  135. package/dist/phoneStateMachine-CuPARRaT.esm.js +351 -0
  136. package/dist/platform-CfrjKhmi.esm.js +83 -0
  137. package/dist/qe-signature-DFo_Cc-I.esm.js +12 -0
  138. package/dist/qe-signature.d.ts +25 -0
  139. package/dist/qe-signature.esm.js +8 -0
  140. package/dist/recordingService-Ig2UgbLv.esm.js +1003 -0
  141. package/dist/redirect-to-mobile.d.ts +107 -0
  142. package/dist/redirect-to-mobile.esm.js +102 -0
  143. package/dist/redirectToMobileStateMachine-BOEqe46A.esm.js +249 -0
  144. package/dist/runChildModule-CqqwqAkW.esm.js +219 -0
  145. package/dist/selfie.d.ts +26 -0
  146. package/dist/selfie.esm.js +146 -0
  147. package/dist/selfieManager-D0lSgd-J.d.ts +68 -0
  148. package/dist/selfieManager-Duisl7qN.esm.js +60 -0
  149. package/dist/selfieStateMachine-D76whWEf.esm.js +68 -0
  150. package/dist/session-CGtQJJzB.esm.js +3206 -0
  151. package/dist/session.d.ts +217 -0
  152. package/dist/session.esm.js +9 -0
  153. package/dist/setup-C5AITV8m.d.ts +254 -0
  154. package/dist/setup-DsM8IG7k.esm.js +887 -0
  155. package/dist/signature.d.ts +94 -0
  156. package/dist/signature.esm.js +66 -0
  157. package/dist/signatureStateMachine-B5-QVUve.esm.js +132 -0
  158. package/dist/stats-CIfiPzb1.esm.js +16 -0
  159. package/dist/stats.d.ts +16 -0
  160. package/dist/stats.esm.js +4 -0
  161. package/dist/trust-graph.d.ts +54 -0
  162. package/dist/trust-graph.esm.js +56 -0
  163. package/dist/types-B06Ypu2F.d.ts +49 -0
  164. package/dist/types-BP1m8VRw.d.ts +340 -0
  165. package/dist/types-CAD4va6a.d.ts +5 -0
  166. package/dist/types-CFV9G_7j.d.ts +24 -0
  167. package/dist/warmup-CEcppFiS.d.ts +63 -0
  168. package/dist/wasm.d.ts +15 -0
  169. package/dist/wasm.esm.js +12 -0
  170. package/dist/watchlist-for-business.d.ts +79 -0
  171. package/dist/watchlist-for-business.esm.js +148 -0
  172. package/dist/watchlist.d.ts +62 -0
  173. package/dist/watchlist.esm.js +86 -0
  174. package/dist/watchlistServices-DMbUhkBX.esm.js +12 -0
  175. package/dist/workflow.d.ts +907 -0
  176. package/dist/workflow.esm.js +702 -0
  177. package/dist/xstate.esm-B70JrNqo.esm.js +3404 -0
  178. package/package.json +1 -1
@@ -0,0 +1,173 @@
1
+ import "./api-CESGtpbH.esm.js";
2
+ import { n as eventModuleNames, o as createManagerInstrumentation } from "./events-D6-e4vok.esm.js";
3
+ import "./endpoints-CnN3SyDa.esm.js";
4
+ import { c as createManager, s as createActor } from "./xstate.esm-B70JrNqo.esm.js";
5
+ import { t as faceMatchMachine } from "./faceMatchStateMachine-DNFrxTFS.esm.js";
6
+
7
+ //#region src/modules/face-match/faceMatchActor.ts
8
+ function createFaceMatchActor(options) {
9
+ return createActor(faceMatchMachine, { input: { config: options.config } }).start();
10
+ }
11
+
12
+ //#endregion
13
+ //#region src/modules/face-match/faceMatchManager.ts
14
+ /**
15
+ * @module @incodetech/core/face-match
16
+ *
17
+ * Face match module for the Incode Web SDK.
18
+ * Supports both headless (programmatic) and UI-driven usage patterns.
19
+ *
20
+ * ## Headless Usage
21
+ *
22
+ * The face match manager can be used entirely without UI for backend integrations,
23
+ * custom UI implementations, or automated workflows.
24
+ *
25
+ * @example Basic headless face match with auto-skip
26
+ * ```typescript
27
+ * import { createFaceMatchManager } from '@incodetech/core/face-match';
28
+ * import { setup } from '@incodetech/core';
29
+ *
30
+ * // 1. Configure the SDK (required before using any module)
31
+ * setup({ apiURL: 'https://api.example.com', token: 'your-token' });
32
+ *
33
+ * // 2. Create the face match manager
34
+ * const faceMatchManager = createFaceMatchManager({
35
+ * config: {
36
+ * matchingType: 'selfieVsId',
37
+ * disableFaceMatchAnimation: true,
38
+ * },
39
+ * });
40
+ *
41
+ * // 3. Subscribe to state changes (optional but recommended)
42
+ * faceMatchManager.subscribe((state) => {
43
+ * console.log('Face match state:', state.status);
44
+ * if (state.status === 'finished') {
45
+ * console.log('Face match complete!', state.matched);
46
+ * }
47
+ * if (state.status === 'error') {
48
+ * console.error('Error:', state.error);
49
+ * }
50
+ * });
51
+ *
52
+ * // 4. Start the flow
53
+ * faceMatchManager.load();
54
+ *
55
+ * // 5. Auto-completes when disableFaceMatchAnimation is true
56
+ * // Or call faceMatchManager.continue() after animation in custom UI
57
+ *
58
+ * // 6. Clean up when done
59
+ * faceMatchManager.stop();
60
+ * ```
61
+ *
62
+ * @example Headless face match with custom UI
63
+ * ```typescript
64
+ * const faceMatchManager = createFaceMatchManager({
65
+ * config: { matchingType: 'selfieVsId', disableFaceMatchAnimation: false },
66
+ * });
67
+ *
68
+ * faceMatchManager.subscribe((state) => {
69
+ * if (state.status === 'animating') {
70
+ * // Render your custom animation
71
+ * renderAnimation(state.images, state.result);
72
+ * }
73
+ * if (state.status === 'result') {
74
+ * // Show result and wait for user to click continue
75
+ * showResult(state.matched);
76
+ * }
77
+ * });
78
+ *
79
+ * faceMatchManager.load();
80
+ * // When animation completes in your UI:
81
+ * faceMatchManager.animationComplete();
82
+ * // When user clicks continue:
83
+ * faceMatchManager.continue();
84
+ * ```
85
+ */
86
+ function mapState(snapshot) {
87
+ const typedSnapshot = snapshot;
88
+ const { context } = typedSnapshot;
89
+ if (typedSnapshot.matches("idle")) return { status: "idle" };
90
+ if (typedSnapshot.matches("loading")) return { status: "loading" };
91
+ if (typedSnapshot.matches("animating")) return {
92
+ status: "animating",
93
+ images: context.images,
94
+ result: context.result
95
+ };
96
+ if (typedSnapshot.matches("result")) return {
97
+ status: "result",
98
+ images: context.images,
99
+ result: context.result,
100
+ matched: context.result.matched
101
+ };
102
+ if (typedSnapshot.matches("finished")) return {
103
+ status: "finished",
104
+ matched: context.result?.matched ?? null
105
+ };
106
+ if (typedSnapshot.matches("error")) return {
107
+ status: "error",
108
+ error: context.error ?? "An error occurred"
109
+ };
110
+ return { status: "idle" };
111
+ }
112
+ function createApi({ actor, trackElementClicked }) {
113
+ return {
114
+ load() {
115
+ actor.send({ type: "LOAD" });
116
+ },
117
+ animationComplete() {
118
+ actor.send({ type: "ANIMATION_COMPLETE" });
119
+ },
120
+ continue() {
121
+ trackElementClicked?.("continue");
122
+ actor.send({ type: "CONTINUE" });
123
+ },
124
+ reset() {
125
+ actor.send({ type: "RESET" });
126
+ }
127
+ };
128
+ }
129
+ /**
130
+ * Creates a face match manager for headless or UI-driven usage.
131
+ *
132
+ * The manager provides a state machine-based API for face comparison
133
+ * with optional animation display.
134
+ *
135
+ * @param options - Configuration options
136
+ * @param options.config - Face match configuration
137
+ * @param options.config.matchingType - Which images to compare (default: 'selfieVsId')
138
+ * @param options.config.disableFaceMatchAnimation - Skip animation and auto-complete (default: false)
139
+ *
140
+ * @returns Face match manager with state, API methods, and subscription
141
+ *
142
+ * @example Headless usage
143
+ * ```typescript
144
+ * const manager = createFaceMatchManager({
145
+ * config: { matchingType: 'selfieVsId', disableFaceMatchAnimation: true },
146
+ * });
147
+ *
148
+ * manager.subscribe((state) => console.log(state.status));
149
+ * manager.load();
150
+ * // Auto-completes when disableFaceMatchAnimation is true
151
+ * manager.stop();
152
+ * ```
153
+ *
154
+ * @example With React/Preact UI hook
155
+ * ```tsx
156
+ * const [state, manager] = useManager(() => createFaceMatchManager({ config }));
157
+ *
158
+ * if (state.status === 'animating') {
159
+ * return <Animation images={state.images} />;
160
+ * }
161
+ * ```
162
+ */
163
+ function createFaceMatchManager(options) {
164
+ return createManager({
165
+ actor: createFaceMatchActor(options),
166
+ mapState,
167
+ createApi,
168
+ instrumentation: createManagerInstrumentation(eventModuleNames.faceMatch)
169
+ });
170
+ }
171
+
172
+ //#endregion
173
+ export { createFaceMatchManager, faceMatchMachine };
@@ -0,0 +1,290 @@
1
+ import { n as eventModuleNames, o as createManagerInstrumentation, r as eventScreenNames } from "./events-D6-e4vok.esm.js";
2
+ import { c as createManager } from "./xstate.esm-B70JrNqo.esm.js";
3
+
4
+ //#region src/internal/faceCapture/faceCaptureManagerFactory.ts
5
+ function getPermissionStatus(snapshot) {
6
+ if (!snapshot.matches("permissions")) return;
7
+ if (snapshot.matches({ permissions: "idle" })) return "idle";
8
+ if (snapshot.matches({ permissions: "learnMore" })) return "learnMore";
9
+ if (snapshot.matches({ permissions: "requesting" })) return "requesting";
10
+ if (snapshot.matches({ permissions: "denied" })) return "denied";
11
+ }
12
+ function getCaptureStatus(snapshot) {
13
+ if (snapshot.matches({ capture: "initializing" })) return "initializing";
14
+ if (snapshot.matches({ capture: "detecting" })) return "detecting";
15
+ if (snapshot.matches({ capture: "capturing" })) return "capturing";
16
+ if (snapshot.matches({ capture: "capturingManual" })) return "capturing";
17
+ if (snapshot.matches({ capture: "preparingUpload" })) return "uploading";
18
+ if (snapshot.matches({ capture: "uploading" })) return "uploading";
19
+ if (snapshot.matches({ capture: "validatingUpload" })) return "uploading";
20
+ if (snapshot.matches({ capture: "uploadError" })) return "uploadError";
21
+ if (snapshot.matches({ capture: "success" })) return "success";
22
+ }
23
+ function mapState(snapshot) {
24
+ const { context } = snapshot;
25
+ if (snapshot.matches("idle")) return { status: "idle" };
26
+ if (snapshot.matches("loading")) return { status: "loading" };
27
+ if (snapshot.matches("tutorial")) return {
28
+ status: "tutorial",
29
+ ageAssurance: context.config?.ageAssurance === true
30
+ };
31
+ if (snapshot.matches("closed")) return { status: "closed" };
32
+ if (snapshot.matches("permissions")) {
33
+ const permissionStatus = getPermissionStatus(snapshot);
34
+ if (permissionStatus === void 0) return {
35
+ status: "permissions",
36
+ permissionStatus: "idle"
37
+ };
38
+ return {
39
+ status: "permissions",
40
+ permissionStatus
41
+ };
42
+ }
43
+ if (snapshot.matches("capture")) return {
44
+ status: "capture",
45
+ captureStatus: getCaptureStatus(snapshot) ?? "initializing",
46
+ stream: context.stream,
47
+ detectionStatus: context.detectionStatus ?? "idle",
48
+ debugFrame: context.debugFrame,
49
+ attemptsRemaining: context.attemptsRemaining ?? 0,
50
+ uploadError: context.uploadError,
51
+ assistedOnboarding: context.config?.assistedOnboarding ?? false,
52
+ ageAssurance: context.config?.ageAssurance === true
53
+ };
54
+ if (snapshot.matches("processing")) return { status: "processing" };
55
+ if (snapshot.matches("finished")) return {
56
+ status: "finished",
57
+ processResponse: context.processResponse
58
+ };
59
+ if (snapshot.matches("error")) {
60
+ const errorValue = context.error;
61
+ return {
62
+ status: "error",
63
+ error: typeof errorValue === "string" ? errorValue : errorValue ? errorValue.message : "Unknown error"
64
+ };
65
+ }
66
+ return { status: "idle" };
67
+ }
68
+ function getFaceCaptureTutorialScreen(snapshot) {
69
+ if (snapshot.context?.config?.ageAssurance === true) return "faceCapture.tutorial.ageAssurance";
70
+ if (typeof snapshot.value === "object" && snapshot.value !== null) {
71
+ const tutorialValue = snapshot.value.tutorial;
72
+ if (typeof tutorialValue === "object" && tutorialValue !== null && "initializingCamera" in tutorialValue) return "faceCapture.tutorial.loading";
73
+ }
74
+ return "faceCapture.tutorial.default";
75
+ }
76
+ function getCapturingScreen(detectionStatus) {
77
+ switch (detectionStatus) {
78
+ case "getReady":
79
+ case "getReadyFinished": return "faceCapture.capturing.getReady";
80
+ case "dark": return "faceCapture.capturing.tooDark";
81
+ case "tooBright": return "faceCapture.capturing.tooBright";
82
+ case "tooClose": return "faceCapture.capturing.moveAway";
83
+ case "tooFar": return "faceCapture.capturing.moveCloser";
84
+ case "moveLeft": return "faceCapture.capturing.moveLeft";
85
+ case "moveRight": return "faceCapture.capturing.moveRight";
86
+ case "blur":
87
+ case "centerFace":
88
+ case "noFace":
89
+ case "tooManyFaces": return "faceCapture.capturing.alignFace";
90
+ case "faceAngle":
91
+ case "lookAtCamera": return "faceCapture.capturing.lookAtCamera";
92
+ case "eyesClosed": return "faceCapture.capturing.eyesClosed";
93
+ case "faceMask": return "faceCapture.capturing.maskDetected";
94
+ case "lenses": return "faceCapture.capturing.glassesDetected";
95
+ case "headWear": return "faceCapture.capturing.hatDetected";
96
+ case "faceOcclusion": return "faceCapture.capturing.faceOcclusion";
97
+ case "manualCapture": return "faceCapture.manualCapture.default";
98
+ case "capturing": return "faceCapture.loading.processing";
99
+ case "detecting":
100
+ case "idle":
101
+ case "offline": return "faceCapture.genericErrors.noConnection";
102
+ case "success":
103
+ case "error":
104
+ default: return "faceCapture.capturing.initiatingState";
105
+ }
106
+ }
107
+ function getResultErrorScreen(errorCode, attemptsRemaining) {
108
+ const exhaustedSuffix = attemptsRemaining === 0 ? "Exhausted" : "";
109
+ switch (errorCode) {
110
+ case "LENSES_ERROR":
111
+ case "LENSES_DETECTED": return `faceCapture.resultError.lensesDetected${exhaustedSuffix}`;
112
+ case "BRIGHTNESS_ERROR": return `faceCapture.resultError.tooBright${exhaustedSuffix}`;
113
+ case "MASK_ERROR":
114
+ case "FACE_MASK_DETECTED": return `faceCapture.resultError.faceMaskDetected${exhaustedSuffix}`;
115
+ case "FACE_TOO_DARK":
116
+ case "TOO_DARK_ERROR": return `faceCapture.resultError.tooDark${exhaustedSuffix}`;
117
+ case "CLOSED_EYES_ERROR":
118
+ case "CLOSED_EYES_DETECTED": return `faceCapture.resultError.eyesClosed${exhaustedSuffix}`;
119
+ case "HEAD_COVER_ERROR":
120
+ case "HEAD_COVER_DETECTED": return `faceCapture.resultError.headCovered${exhaustedSuffix}`;
121
+ case "FACE_OCCLUDED": return `faceCapture.resultError.faceOcclusion${exhaustedSuffix}`;
122
+ case "TOO_BLURRY_ERROR":
123
+ case "FACE_TOO_BLURRY":
124
+ case "BAD_PHOTO_QUALITY":
125
+ case "SELFIE_IMAGE_LOW_QUALITY": return `faceCapture.resultError.lowQuality${exhaustedSuffix}`;
126
+ case "SERVER_ERROR":
127
+ case "PROCESSING_ERROR":
128
+ case "BAD_REQUEST": return `faceCapture.resultError.processingFailed${exhaustedSuffix}`;
129
+ case "FACE_NOT_FOUND":
130
+ case "MULTIPLE_FACES":
131
+ case "FACE_CROPPING_FAILED":
132
+ case "FACE_TOO_SMALL":
133
+ case "LIVENESS_ERROR":
134
+ default: return `faceCapture.resultError.faceNotAligned${exhaustedSuffix}`;
135
+ }
136
+ }
137
+ function getCaptureSubstateScreen(snapshot) {
138
+ const { value, context } = snapshot;
139
+ if (typeof value !== "object" || value === null) return void 0;
140
+ const captureValue = value.capture;
141
+ if (captureValue === void 0) return void 0;
142
+ if (typeof captureValue === "string") switch (captureValue) {
143
+ case "checkingDeepsight":
144
+ case "initializingDeepsight":
145
+ case "checkingStream":
146
+ case "initializing": return "faceCapture.capturing.initiatingState";
147
+ case "detecting": return getCapturingScreen(context?.detectionStatus);
148
+ case "capturing": return "faceCapture.loading.processing";
149
+ case "capturingManual": return "faceCapture.manualCapture.default";
150
+ case "preparingUpload":
151
+ case "uploading":
152
+ case "validatingUpload": return "faceCapture.loading.uploading";
153
+ case "uploadError": return getResultErrorScreen(context?.uploadError, context?.attemptsRemaining);
154
+ case "success": return "faceCapture.resultSuccess.default";
155
+ }
156
+ if (typeof captureValue === "object" && captureValue !== null) {
157
+ const substates = Object.keys(captureValue);
158
+ if (substates.includes("uploading")) return "faceCapture.loading.uploading";
159
+ if (substates.includes("uploadError")) return getResultErrorScreen(context?.uploadError, context?.attemptsRemaining);
160
+ if (substates.includes("success")) return "faceCapture.resultSuccess.default";
161
+ }
162
+ return "faceCapture.capturing.initiatingState";
163
+ }
164
+ function getAuthFaceCaptureSubstateScreen(snapshot) {
165
+ const { value } = snapshot;
166
+ if (typeof value !== "object" || value === null) return void 0;
167
+ const captureValue = value.capture;
168
+ if (captureValue === void 0) return void 0;
169
+ if (typeof captureValue === "string") switch (captureValue) {
170
+ case "preparingUpload":
171
+ case "uploading":
172
+ case "validatingUpload": return eventScreenNames.authFaceUpload;
173
+ case "uploadError": return eventScreenNames.authFaceError;
174
+ case "success": return eventScreenNames.authFaceUploadSuccess;
175
+ case "checkingDeepsight":
176
+ case "initializingDeepsight":
177
+ case "checkingStream":
178
+ case "initializing":
179
+ case "detecting":
180
+ case "capturing":
181
+ case "capturingManual": return eventScreenNames.authFace;
182
+ }
183
+ if (typeof captureValue === "object" && captureValue !== null) {
184
+ const substates = Object.keys(captureValue);
185
+ if (substates.includes("uploading") || substates.includes("validatingUpload")) return eventScreenNames.authFaceUpload;
186
+ if (substates.includes("uploadError")) return eventScreenNames.authFaceError;
187
+ if (substates.includes("success")) return eventScreenNames.authFaceUploadSuccess;
188
+ }
189
+ return eventScreenNames.authFace;
190
+ }
191
+ function getTopLevelState(value) {
192
+ if (typeof value === "string") return value;
193
+ if (typeof value === "object") return Object.keys(value)[0];
194
+ }
195
+ function getAuthFaceScreenName(snapshot) {
196
+ const { value } = snapshot;
197
+ if (value === void 0 || value === null) return void 0;
198
+ const topLevel = getTopLevelState(value);
199
+ if (topLevel === void 0) return void 0;
200
+ switch (topLevel) {
201
+ case "tutorial": return eventScreenNames.authFaceTutorial;
202
+ case "capture": return getAuthFaceCaptureSubstateScreen(snapshot);
203
+ case "finished": return eventScreenNames.authFaceUploadSuccess;
204
+ case "error": return eventScreenNames.authFaceUploadFailed;
205
+ case "idle":
206
+ case "loading":
207
+ case "permissions":
208
+ case "processing":
209
+ case "closed":
210
+ default: return eventScreenNames.authFace;
211
+ }
212
+ }
213
+ function getFaceCaptureScreenName(snapshot, moduleName) {
214
+ if (moduleName === eventModuleNames.authFace || moduleName === eventModuleNames.authentication) return getAuthFaceScreenName(snapshot);
215
+ const { value } = snapshot;
216
+ if (value === void 0 || value === null) return void 0;
217
+ const topLevel = getTopLevelState(value);
218
+ if (topLevel === void 0) return void 0;
219
+ switch (topLevel) {
220
+ case "idle": return "faceCapture.loading.processing";
221
+ case "loading": return "faceCapture.loading.processing";
222
+ case "tutorial": return getFaceCaptureTutorialScreen(snapshot);
223
+ case "permissions": return "faceCapture.tutorial.default";
224
+ case "capture": return getCaptureSubstateScreen(snapshot);
225
+ case "processing": return "faceCapture.loading.processing";
226
+ case "finished": return "faceCapture.resultSuccess.default";
227
+ case "closed": return "faceCapture.closed";
228
+ case "error": return "faceCapture.resultError.processingFailed";
229
+ default: return `faceCapture.${topLevel}`;
230
+ }
231
+ }
232
+ function createApi({ actor, trackElementClicked, trackCaptureAttemptFinished }) {
233
+ const snapshot = actor.getSnapshot();
234
+ snapshot.context.dependencies.trackCaptureAttemptFinished = trackCaptureAttemptFinished;
235
+ return {
236
+ load() {
237
+ actor.send({ type: "LOAD" });
238
+ },
239
+ nextStep() {
240
+ trackElementClicked?.("nextStep");
241
+ actor.send({ type: "NEXT_STEP" });
242
+ },
243
+ requestPermission() {
244
+ trackElementClicked?.("requestPermission");
245
+ actor.send({ type: "REQUEST_PERMISSION" });
246
+ },
247
+ goToLearnMore() {
248
+ trackElementClicked?.("goToLearnMore");
249
+ actor.send({ type: "GO_TO_LEARN_MORE" });
250
+ },
251
+ back() {
252
+ trackElementClicked?.("back");
253
+ actor.send({ type: "BACK" });
254
+ },
255
+ close() {
256
+ trackElementClicked?.("close");
257
+ actor.send({ type: "QUIT" });
258
+ },
259
+ reset() {
260
+ actor.send({ type: "RESET" });
261
+ },
262
+ retryCapture() {
263
+ trackElementClicked?.("retryCapture");
264
+ actor.send({ type: "RETRY_CAPTURE" });
265
+ },
266
+ capture() {
267
+ trackElementClicked?.("capture");
268
+ actor.send({ type: "MANUAL_CAPTURE" });
269
+ }
270
+ };
271
+ }
272
+ function getFaceCaptureErrorPayload(snapshot) {
273
+ const errorCode = snapshot.context.uploadError;
274
+ if (typeof errorCode !== "string" || errorCode.length === 0) return;
275
+ return { errorCode };
276
+ }
277
+ function createFaceCaptureManagerFromActor(actor, moduleName) {
278
+ return createManager({
279
+ actor,
280
+ mapState,
281
+ createApi,
282
+ instrumentation: createManagerInstrumentation(moduleName, {
283
+ getEventScreenName: (snapshot) => getFaceCaptureScreenName(snapshot, moduleName),
284
+ getErrorPayload: getFaceCaptureErrorPayload
285
+ })
286
+ });
287
+ }
288
+
289
+ //#endregion
290
+ export { createFaceCaptureManagerFromActor as t };