@incodetech/core 2.5.0-agentic → 2.5.0-agentic.1

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 (224) hide show
  1. package/dist/{FaceDetectionProvider-Dv9iXub0.esm.js → FaceDetectionProvider-Cy2EAL0i.esm.js} +9 -9
  2. package/dist/{IIdCaptureCapability-CAxToGns.d.ts → IIdCaptureCapability-BRAZQtkM.d.ts} +1 -0
  3. package/dist/{MotionSensorProvider-X4_2eBGd.esm.js → MotionSensorProvider-BAGydZPH.esm.js} +5 -0
  4. package/dist/{WasmUtilProvider-DVFDFlIL.esm.js → WasmUtilProvider-C4x5gc1c.esm.js} +2 -2
  5. package/dist/{definitionSource-B-Z2EgJJ.esm.js → addressSearch-DBJeg_g3.esm.js} +76 -9
  6. package/dist/ae-signature.esm.js +1 -1
  7. package/dist/{phoneFormat-C3q0Ukh4.esm.js → allowedCharacters-Bnir--CN.esm.js} +1 -11
  8. package/dist/antifraud.esm.js +2 -2
  9. package/dist/{antifraudManager-BI2zr7YX.esm.js → antifraudManager-DRMBLSh7.esm.js} +3 -3
  10. package/dist/{antifraudStateMachine-TWUu8wLN.esm.js → antifraudStateMachine-Bi0m60oV.esm.js} +1 -1
  11. package/dist/{api-BNxrW8xK.esm.js → api-B58edv6M.esm.js} +0 -1
  12. package/dist/{apiError-BAfdBGxH.esm.js → apiError-B9-B3cMq.esm.js} +1 -1
  13. package/dist/{attemptCarry-DWM8lV9V.esm.js → attemptCarry-CxiYlUAO.esm.js} +1 -1
  14. package/dist/authentication.d.ts +3 -3
  15. package/dist/authentication.esm.js +2 -2
  16. package/dist/{authenticationManager-BJElkTsj.d.ts → authenticationManager-CkD0JR7Q.d.ts} +1 -1
  17. package/dist/{authenticationManager-DFzByAYo.esm.js → authenticationManager-DNWtc0eq.esm.js} +6 -6
  18. package/dist/{authenticationStateMachine-CKTOhwwc.esm.js → authenticationStateMachine-CJ9i4Al-.esm.js} +3 -3
  19. package/dist/{browser-pQZA35G2-CG3C-xGt.esm.js → browser-pQZA35G2-B4Dwja1e.esm.js} +1 -1
  20. package/dist/{calendarDate-DcqGuEht.esm.js → calendarDate-D2zWfUlA.esm.js} +1 -1
  21. package/dist/camera.esm.js +1 -1
  22. package/dist/certificate-issuance.esm.js +2 -2
  23. package/dist/{certificateIssuanceManager-P44yBRop.esm.js → certificateIssuanceManager-Ctj6AJC7.esm.js} +3 -3
  24. package/dist/{certificateIssuanceStateMachine-BPBrILt6.esm.js → certificateIssuanceStateMachine-DDqN9kvL.esm.js} +1 -1
  25. package/dist/{cnpj-Bl_olpdX.esm.js → cnpj-CVq3vL39.esm.js} +1 -9
  26. package/dist/cnpj-D5cxwIe-.esm.js +9 -0
  27. package/dist/consent.d.ts +1 -1
  28. package/dist/consent.esm.js +2 -2
  29. package/dist/{consentManager-Duzd8paN.d.ts → consentManager-B0YKqYtZ.d.ts} +5 -5
  30. package/dist/{consentManager-D43w2ms-.esm.js → consentManager-CyoeiABc.esm.js} +3 -3
  31. package/dist/{consentStateMachine-CLK8PfM4.esm.js → consentStateMachine-BTUrAslr.esm.js} +1 -1
  32. package/dist/cross-document-data-match.esm.js +1 -1
  33. package/dist/{crossDocumentDataMatchManager-Cag_bcyW.esm.js → crossDocumentDataMatchManager-cmQmp7Bi.esm.js} +3 -3
  34. package/dist/curp-validation.d.ts +1 -1
  35. package/dist/curp-validation.esm.js +2 -2
  36. package/dist/{curpValidationManager-C6WmQToS.esm.js → curpValidationManager-EW44fVpH.esm.js} +3 -3
  37. package/dist/{curpValidationManager-CmL52FU8.d.ts → curpValidationManager-HOidAKvT.d.ts} +1 -1
  38. package/dist/{curpValidationStateMachine-BbJ4YAzE.esm.js → curpValidationStateMachine-BFkt90Zs.esm.js} +3 -3
  39. package/dist/custom-fields.esm.js +1 -1
  40. package/dist/custom-watchlist.esm.js +2 -2
  41. package/dist/{customFieldsManager-BBy6X9nh.esm.js → customFieldsManager-DPMBJrcH.esm.js} +4 -4
  42. package/dist/{customWatchlistManager-CtBMy2EF.esm.js → customWatchlistManager-DiYpPjZx.esm.js} +3 -3
  43. package/dist/{customWatchlistStateMachine-SS2ssNCg.esm.js → customWatchlistStateMachine-D7VxQggF.esm.js} +1 -1
  44. package/dist/{deepsightCaptureConfig-Nm_K8twx.esm.js → deepsightCaptureConfig-BxD3mSac.esm.js} +2 -2
  45. package/dist/{deepsightLoader-BInnND1H.esm.js → deepsightLoader-KYZP8_x-.esm.js} +7 -7
  46. package/dist/definitionSource-B9WTvQb9.esm.js +30 -0
  47. package/dist/{desktopCameraElection-JNBOXqvK.esm.js → desktopCameraElection-BGQRIA2u.esm.js} +8 -8
  48. package/dist/document-capture.esm.js +2 -2
  49. package/dist/document-signature.esm.js +3 -3
  50. package/dist/{documentCaptureManager-CGDtkfWj.esm.js → documentCaptureManager-SRG6YEMh.esm.js} +3 -3
  51. package/dist/{documentCaptureStateMachine-flAt9D4q.esm.js → documentCaptureStateMachine-Bh0uyfGq.esm.js} +4 -4
  52. package/dist/{documentSignatureStateMachine-DrRyICFT.esm.js → documentSignatureStateMachine-CLljjltG.esm.js} +4 -4
  53. package/dist/dynamic-forms.esm.js +2 -2
  54. package/dist/{dynamicFormsManager-CxLq2KzT.esm.js → dynamicFormsManager-CnU2hRvl.esm.js} +3 -3
  55. package/dist/{dynamicFormsStateMachine-By-maT_4.esm.js → dynamicFormsStateMachine-huYmjamB.esm.js} +3 -3
  56. package/dist/ekyb.d.ts +4 -4
  57. package/dist/ekyb.esm.js +3 -3
  58. package/dist/{ekybManager-CE19Pcdb.esm.js → ekybManager-CaEErq39.esm.js} +3 -3
  59. package/dist/{ekybManager-BflWuTe4.d.ts → ekybManager-Cjk8pQX0.d.ts} +2 -2
  60. package/dist/{ekybStateMachine-q7JQ-x9l.esm.js → ekybStateMachine-BIU8KIMv.esm.js} +141 -10
  61. package/dist/{ekybUtils-Z9MhFAer.esm.js → ekybUtils-Dl0MU-ib.esm.js} +23 -1
  62. package/dist/ekyc-prefill.d.ts +5 -5
  63. package/dist/ekyc-prefill.esm.js +2 -2
  64. package/dist/ekyc.d.ts +3 -3
  65. package/dist/ekyc.esm.js +3 -3
  66. package/dist/{ekycManager-p3uenUEi.esm.js → ekycManager-D2K8AaMV.esm.js} +3 -3
  67. package/dist/{ekycManager-BKVQazAb.d.ts → ekycManager-DusmB-4j.d.ts} +2 -2
  68. package/dist/{ekycPrefillManager-BcLhkpp8.d.ts → ekycPrefillManager-BwmPXfhY.d.ts} +12 -12
  69. package/dist/{ekycPrefillManager-gPX3XE7u.esm.js → ekycPrefillManager-CENQjdNq.esm.js} +6 -7
  70. package/dist/ekycPrefillStateMachine-jT3hIt2X.esm.js +1289 -0
  71. package/dist/{ekycStateMachine-D0NAHzS7.esm.js → ekycStateMachine-6EKndBd7.esm.js} +740 -230
  72. package/dist/{ekycUtils-DEvtEyBI.esm.js → ekycUtils-C6HZB46m.esm.js} +37 -6
  73. package/dist/electronic-signature.esm.js +1 -1
  74. package/dist/{electronicSignatureManager-C1M-Yxf2.esm.js → electronicSignatureManager-wM8WTgzP.esm.js} +4 -4
  75. package/dist/email.esm.js +2 -2
  76. package/dist/{emailManager-DWnhEsUf.esm.js → emailManager-BBdRYLtH.esm.js} +3 -3
  77. package/dist/{emailStateMachine--T9PHflK.esm.js → emailStateMachine-DO7lWYvn.esm.js} +2 -2
  78. package/dist/{events-ChMS-UzR.esm.js → events-PUWyizJn.esm.js} +2 -2
  79. package/dist/events.d.ts +0 -3
  80. package/dist/events.esm.js +2 -2
  81. package/dist/extensibility.d.ts +15 -15
  82. package/dist/extensibility.esm.js +36 -36
  83. package/dist/face-match.esm.js +2 -2
  84. package/dist/{faceCaptureManagerFactory-CHqmyOjM.d.ts → faceCaptureManagerFactory-D1EJw36F.d.ts} +3 -3
  85. package/dist/{faceCaptureManagerFactory-18QW0lmV.esm.js → faceCaptureManagerFactory-DbEARG3h.esm.js} +6 -6
  86. package/dist/{faceCaptureSetup-CFToXwHy.esm.js → faceCaptureSetup-VaAjMpWX.esm.js} +20 -12
  87. package/dist/{faceMatchManager-DIStK4qi.esm.js → faceMatchManager-nBvS9z0o.esm.js} +3 -3
  88. package/dist/{faceMatchStateMachine-DagrRdo2.esm.js → faceMatchStateMachine-48O8j_Lx.esm.js} +2 -2
  89. package/dist/{feature-management-BlscKbeV.esm.js → feature-management-D7oLtULO.esm.js} +1 -1
  90. package/dist/feature-management.esm.js +1 -1
  91. package/dist/field-comparison.esm.js +1 -1
  92. package/dist/{fieldComparisonManager-BnWBtMN7.esm.js → fieldComparisonManager-B1ipvtnp.esm.js} +3 -3
  93. package/dist/fiscal-qr.esm.js +1 -1
  94. package/dist/{fiscalQrManager-BxXaLhin.esm.js → fiscalQrManager-yecjuXV4.esm.js} +3 -3
  95. package/dist/flow-events.d.ts +1 -1
  96. package/dist/flow.d.ts +7 -7
  97. package/dist/flow.esm.js +5 -5
  98. package/dist/{flowCompletionService-DNLssMAg.esm.js → flowCompletionService-CIjaIpMH.esm.js} +2 -2
  99. package/dist/{flowServices-Bzq3piUR.esm.js → flowServices-Dqt75TXx.esm.js} +9 -9
  100. package/dist/formErrors-lSfh7Y8J.esm.js +512 -0
  101. package/dist/geolocation.esm.js +2 -2
  102. package/dist/{geolocationManager-DoLbpx5e.esm.js → geolocationManager-DHfgXhEs.esm.js} +3 -3
  103. package/dist/{geolocationStateMachine-d5_E7gAm.esm.js → geolocationStateMachine-CrEspaN-.esm.js} +3 -3
  104. package/dist/government-validation.esm.js +2 -2
  105. package/dist/{governmentValidationManager-CaZxyEOO.esm.js → governmentValidationManager-0-L21hu6.esm.js} +3 -3
  106. package/dist/{governmentValidationStateMachine-DeHHhlcf.esm.js → governmentValidationStateMachine-BFIcq3UB.esm.js} +1 -1
  107. package/dist/home.d.ts +1 -1
  108. package/dist/home.esm.js +2 -2
  109. package/dist/http.esm.js +1 -1
  110. package/dist/id-ocr.d.ts +1 -1
  111. package/dist/id-ocr.esm.js +19 -3
  112. package/dist/id-selfie-flow.d.ts +2 -2
  113. package/dist/id-selfie-flow.esm.js +8 -8
  114. package/dist/id-verification.esm.js +2 -2
  115. package/dist/id.d.ts +3 -3
  116. package/dist/id.esm.js +3 -3
  117. package/dist/{idCaptureDefaults-R3rHuTOE.esm.js → idCaptureDefaults-CNopPetU.esm.js} +16 -6
  118. package/dist/{idCaptureManager-D_YGMeCW.esm.js → idCaptureManager-BPDCAV04.esm.js} +24 -18
  119. package/dist/{idCaptureManager-CgkQW3Xc.d.ts → idCaptureManager-CNFBeYgV.d.ts} +20 -5
  120. package/dist/{idCaptureServices-CP6AxsFW.esm.js → idCaptureServices-CWZFmS7l.esm.js} +5 -5
  121. package/dist/{idCaptureStateMachine-BdBtGQZP.esm.js → idCaptureStateMachine-Cyt2BvPB.esm.js} +191 -44
  122. package/dist/{idOcrManager-C0C7lFGd.d.ts → idOcrManager-DflRx-_u.d.ts} +1 -1
  123. package/dist/{idOcrManager-XTbpfHoF.esm.js → idOcrManager-bjBLjrEE.esm.js} +3 -3
  124. package/dist/{idOcrStateMachine-B-00PgPh.esm.js → idOcrStateMachine-D5ifJ1B8.esm.js} +2 -2
  125. package/dist/{idVerificationManager-B4NYLlUl.esm.js → idVerificationManager-C8Ja-vKq.esm.js} +3 -3
  126. package/dist/{idVerificationStateMachine-B48Ikl-7.esm.js → idVerificationStateMachine-BMnfZZli.esm.js} +1 -1
  127. package/dist/identity-reuse.esm.js +2 -2
  128. package/dist/identity-search.esm.js +2 -2
  129. package/dist/{identityReuseManager-tFeYm_So.esm.js → identityReuseManager-B5BWAleT.esm.js} +3 -3
  130. package/dist/{identityReuseStateMachine-Ckf39qFu.esm.js → identityReuseStateMachine-Cuggm1UP.esm.js} +1 -1
  131. package/dist/{index-CNck5TLp.d.ts → index-BMr3MZEI.d.ts} +1 -1
  132. package/dist/{index-CoePktWH.d.ts → index-BoGlwLGK.d.ts} +1 -1
  133. package/dist/index.d.ts +1 -1
  134. package/dist/index.esm.js +1 -1
  135. package/dist/{invokeOnCaptureCallback-DNQX9k5e.esm.js → invokeOnCaptureCallback-D2FOfi4O.esm.js} +1 -1
  136. package/dist/kyb-checks.d.ts +3 -3
  137. package/dist/kyb-checks.esm.js +2 -2
  138. package/dist/{kybChecksManager-DP76y-Qz.esm.js → kybChecksManager-BF2vf0Q2.esm.js} +2 -2
  139. package/dist/{kybChecksManager-B7Di9auB.d.ts → kybChecksManager-CKDy1mel.d.ts} +1 -1
  140. package/dist/{kybChecksStateMachine-OKLT8Zoc.esm.js → kybChecksStateMachine-oBQfgdka.esm.js} +176 -179
  141. package/dist/mandatory-consent.d.ts +2 -2
  142. package/dist/mandatory-consent.esm.js +2 -2
  143. package/dist/{mandatoryConsentManager-kzr5kdc_.d.ts → mandatoryConsentManager-BcxCesP5.d.ts} +6 -6
  144. package/dist/{mandatoryConsentManager-NX1lz6nk.esm.js → mandatoryConsentManager-FfgHdPYw.esm.js} +3 -3
  145. package/dist/{mandatoryConsentStateMachine-D1J2NQSI.esm.js → mandatoryConsentStateMachine-CXuYC3qR.esm.js} +1 -1
  146. package/dist/{multipartRecordingService-Cz-cWrpV.esm.js → multipartRecordingService-CFmOUGQt.esm.js} +1 -1
  147. package/dist/numericRange-2e1vw1W0.esm.js +256 -0
  148. package/dist/{permissionGuards-Cyh71hOt.esm.js → permissionGuards-CZTCRHT-.esm.js} +1 -1
  149. package/dist/{permissionServices-BrtDMB0Z.esm.js → permissionServices-Vd86JiW9.esm.js} +19 -7
  150. package/dist/phone.d.ts +1 -1
  151. package/dist/phone.esm.js +2 -2
  152. package/dist/{phoneManager-VO1HEoUZ.d.ts → phoneManager-bA-xw2TP.d.ts} +0 -8
  153. package/dist/{phoneManager-D1QPNbu0.esm.js → phoneManager-oIMdbeLG.esm.js} +5 -6
  154. package/dist/{phoneServices-DC7AuUed.esm.js → phoneServices-Dk4j3NhI.esm.js} +2 -12
  155. package/dist/{phoneStateMachine-CxCPxTIy.esm.js → phoneStateMachine-Cu3y7ewi.esm.js} +3 -8
  156. package/dist/{processFaceMatch-BQoiqLVh.esm.js → processFaceMatch-CHeI0DEt.esm.js} +1 -1
  157. package/dist/qe-signature.esm.js +1 -1
  158. package/dist/{recordingService-CSCvD2tB.esm.js → recordingService-DK3kjUby.esm.js} +3 -3
  159. package/dist/redirect-to-mobile.esm.js +2 -2
  160. package/dist/{redirectToMobileManager-Dcpg5GfP.esm.js → redirectToMobileManager-yYJGE47m.esm.js} +3 -3
  161. package/dist/{redirectToMobileStateMachine-BMehrtVP.esm.js → redirectToMobileStateMachine-g_NbyHrL.esm.js} +1 -1
  162. package/dist/{runChildModule-DNEmc7of.esm.js → runChildModule-x1rrxjYY.esm.js} +2 -2
  163. package/dist/{sdkVersion-etdZfyCR.esm.js → sdkVersion-kRh5h82H.esm.js} +1 -1
  164. package/dist/selfie.d.ts +3 -3
  165. package/dist/selfie.esm.js +11 -11
  166. package/dist/{selfieErrorUtils-DT-uhK20.esm.js → selfieErrorUtils-B9GfiS9f.esm.js} +1 -1
  167. package/dist/{selfieManager-CdS6a7Q8.esm.js → selfieManager-CivYjnF5.esm.js} +6 -6
  168. package/dist/{selfieManager-DrBYj5kA.d.ts → selfieManager-CqDlUy6B.d.ts} +1 -1
  169. package/dist/{selfieStateMachine-ChCl3nyf.esm.js → selfieStateMachine-dLwrXWll.esm.js} +3 -3
  170. package/dist/{session-VXYuRYzb.esm.js → session-DeJ-rd9u.esm.js} +5 -5
  171. package/dist/session.d.ts +1 -1
  172. package/dist/session.esm.js +5 -5
  173. package/dist/{sessionInitializer-BT_CmYcX.esm.js → sessionInitializer-uZgyxsrL.esm.js} +11 -11
  174. package/dist/{setup-rcXgYUcY.d.ts → setup-Cr2KCwau.d.ts} +1 -1
  175. package/dist/{setup-BXrgDdfx.esm.js → setup-D0QZHkS8.esm.js} +13 -13
  176. package/dist/signature.esm.js +2 -2
  177. package/dist/{signatureManager-B737Gkvk.esm.js → signatureManager-DRUflksL.esm.js} +3 -3
  178. package/dist/{signatureStateMachine-B-QG7fk0.esm.js → signatureStateMachine-BQZenxel.esm.js} +1 -1
  179. package/dist/{stats-CrqhpKkP.esm.js → stats-DHu3li6G.esm.js} +1 -1
  180. package/dist/stats.esm.js +1 -1
  181. package/dist/{tri-BD9z6z0w.esm.js → tri-D_gHPWrq.esm.js} +2 -2
  182. package/dist/tri.d.ts +1 -1
  183. package/dist/{tri.esm-DYdFtcDH.esm.js → tri.esm-CftnGf9w.esm.js} +187 -177
  184. package/dist/tri.esm.js +1 -1
  185. package/dist/trueSight-CbrZUzLx.esm.js +1 -0
  186. package/dist/{trueSightService-BwyLhIAo.esm.js → trueSightService-BMp8g65B.esm.js} +5 -7
  187. package/dist/trust-graph.esm.js +3 -3
  188. package/dist/{trustGraphStateMachine-BxvReuo1.esm.js → trustGraphStateMachine-0Ehwried.esm.js} +1 -1
  189. package/dist/{types-4Re9FSOw.d.ts → types-BZsmNYom.d.ts} +3 -4
  190. package/dist/types-BinnzVrL.d.ts +6 -0
  191. package/dist/{types-BgRHw-dR.d.ts → types-BwMpWCVG.d.ts} +6 -2
  192. package/dist/{types-b0l9b83G.d.ts → types-D-FEM1rT.d.ts} +26 -10
  193. package/dist/{textRules-D4NRinKY.d.ts → types-D6Q1D1kx.d.ts} +1 -9
  194. package/dist/{types-CBQN04Rh.esm.js → types-DLsivQsu.esm.js} +0 -3
  195. package/dist/{types-CTaL0XJz.d.ts → types-DWqO7owj.d.ts} +2 -24
  196. package/dist/{types-CEGG70FK.d.ts → types-HHgsFhZn.d.ts} +1 -1
  197. package/dist/{types-C1056-J1.d.ts → types-LbccjQYX.d.ts} +1 -1
  198. package/dist/{types-DHpz4Y37.d.ts → types-PnJXvTkV.d.ts} +1 -1
  199. package/dist/{types-B-PIc0en.d.ts → types-g3NuVCT9.d.ts} +40 -37
  200. package/dist/{types-DEa3taWc.d.ts → types-tOSLpcSa.d.ts} +16 -2
  201. package/dist/video-selfie.d.ts +14 -6
  202. package/dist/video-selfie.esm.js +12 -9
  203. package/dist/{videoSelfieCameraWarmer-DgRlU_8q.esm.js → videoSelfieCameraWarmer-BpP0_lDr.esm.js} +27 -8
  204. package/dist/{videoSelfieStepDetector-DC_Qh7qI.d.ts → videoSelfieStepDetector-CxOc3kSI.d.ts} +3 -3
  205. package/dist/{warmup-BN8dG2KX.esm.js → warmup-ClZxXOkg.esm.js} +1 -1
  206. package/dist/wasm.d.ts +2 -2
  207. package/dist/wasm.esm.js +3 -3
  208. package/dist/{wasmDsFlagSync-DwBfTlgB.esm.js → wasmDsFlagSync-Bw-P5OG1.esm.js} +1 -1
  209. package/dist/{wasmWebClient-B2P6Vlvv.esm.js → wasmWebClient-BLtlzQhv.esm.js} +9 -9
  210. package/dist/watchlist-for-business.esm.js +2 -2
  211. package/dist/watchlist.esm.js +2 -2
  212. package/dist/{watchlistForBusinessManager-DxeSH80T.esm.js → watchlistForBusinessManager-d8kdf35n.esm.js} +3 -3
  213. package/dist/{watchlistForBusinessStateMachine-BC9UWLuZ.esm.js → watchlistForBusinessStateMachine-Y9wFmuMH.esm.js} +4 -3
  214. package/dist/{watchlistManager-BHzmC9OC.esm.js → watchlistManager-D1BVrd3H.esm.js} +3 -3
  215. package/dist/{watchlistStateMachine-Bxzn16iJ.esm.js → watchlistStateMachine-Da4p0sTE.esm.js} +1 -1
  216. package/dist/workflow.d.ts +1 -1
  217. package/dist/workflow.esm.js +42 -42
  218. package/package.json +3 -3
  219. package/dist/addressSearch-BKlynuBr.esm.js +0 -71
  220. package/dist/ekycPrefillStateMachine-SBnBKPGA.esm.js +0 -685
  221. package/dist/ekycRules-BH_Ll_0A.esm.js +0 -482
  222. package/dist/idOcrCpfUtils-D5Gwskxu.esm.js +0 -18
  223. package/dist/trueSight-BymJD5cW.esm.js +0 -1
  224. package/dist/types-BtrJ5fkm.d.ts +0 -6
@@ -0,0 +1,1289 @@
1
+ import { t as getLocalIsoDate } from "./IBrowserEnvironmentCapability-D7JG7ML3.esm.js";
2
+ import { t as api, u as endpoints } from "./api-B58edv6M.esm.js";
3
+ import { i as toIncodeApiError } from "./apiError-B9-B3cMq.esm.js";
4
+ import { n as loadPhoneValidation } from "./phoneValidation-OggtfjRt.esm.js";
5
+ import { i as assign, t as setup } from "./xstate.esm-CIqUf_i6.esm.js";
6
+ import { n as fromPromise } from "./xstate-actors.esm-BCcwgosu.esm.js";
7
+ import { t as isValidCurp } from "./curp-DZGvefg3.esm.js";
8
+ import { a as isPoBox, c as hasDigitCount, d as isValidInDrivingLicenseNumber, f as isValidFiPersonalIdentityCode, i as isWithinMaxAge, l as resolvePrefill, n as isNotFuture, o as isEmailFormat, p as isValidEsDni, r as hasNameCharacters, s as digitCountError, t as isInNumericRange, u as isValidRut } from "./numericRange-2e1vw1W0.esm.js";
9
+ import { t as validateCNPJ } from "./cnpj-CVq3vL39.esm.js";
10
+ import { n as checkSupport, t as resolveForm } from "./resolveForm-DaaQSVWp.esm.js";
11
+ import { n as matchesCharTemplate, t as createBundledDefinitionSource } from "./definitionSource-B9WTvQb9.esm.js";
12
+ import { a as e164, c as setFieldValue, d as createFormRegistry, f as supportedIds, i as oneOfRequired, l as validateAllValues, m as withMessage, n as requiredError, o as allowedCharacters, p as buildPayload, r as trim, s as phoneDeps, t as STRUCTURE_MESSAGES, u as validateFieldValue } from "./formErrors-lSfh7Y8J.esm.js";
13
+ import { t as validateCPF } from "./cpf-DDXMTLYr.esm.js";
14
+ //#region src/internal/forms/formatValue.ts
15
+ /**
16
+ * A typed or prefilled value after the field's input formats
17
+ * (`input.format`), in order. Formats the registry doesn't implement are
18
+ * skipped: call `checkSupport` first for a definition that wasn't bundled.
19
+ * Only the registry's transforms are read, so a module that formats but
20
+ * doesn't validate with the kernel yet can pass just those.
21
+ */
22
+ function formatValue(field, value, registry, env) {
23
+ return (field.input?.format ?? []).reduce((formatted, ref) => {
24
+ const transform = registry.transforms.get(ref.id);
25
+ return transform ? transform.apply(formatted, ref.params ?? {}, env) : formatted;
26
+ }, value);
27
+ }
28
+ //#endregion
29
+ //#region src/modules/ekyc-prefill/ekycPrefillConfig.ts
30
+ const isString = (value) => typeof value === "string" && value !== "";
31
+ function toConfigField(raw) {
32
+ if (typeof raw !== "object" || raw === null) return void 0;
33
+ const { field, check, mandatory, source, displayMode } = raw;
34
+ if (!isString(field)) return void 0;
35
+ return {
36
+ field,
37
+ check: check === true,
38
+ mandatory: mandatory === true,
39
+ ...isString(source) && { source },
40
+ ...isString(displayMode) && { displayMode }
41
+ };
42
+ }
43
+ /**
44
+ * Normalizes the served `EKYC_PREFILL` configuration. Idempotent, so a
45
+ * configuration that is already normalized passes through unchanged.
46
+ *
47
+ * - `check` and `mandatory` are `true` only when served as `true`; a `null`
48
+ * check hides the field.
49
+ * - `fields` stays `undefined` when the configuration has no `fields` array:
50
+ * the flat dashboard shape, which the module can't render.
51
+ * - A field's `source` and `displayMode` are kept when served as non-empty
52
+ * strings; other per-field keys are dropped.
53
+ */
54
+ function toEkycPrefillConfig(raw) {
55
+ const config = raw ?? {};
56
+ const fields = Array.isArray(config.fields) ? config.fields.map(toConfigField).filter((field) => !!field) : void 0;
57
+ const requireAnyOf = Array.isArray(config.requireAnyOf) ? config.requireAnyOf.filter(isString) : [];
58
+ return {
59
+ country: isString(config.country) ? config.country : void 0,
60
+ source: isString(config.source) ? config.source : void 0,
61
+ fields,
62
+ requireAnyOf,
63
+ autoExecution: config.autoExecution === true
64
+ };
65
+ }
66
+ //#endregion
67
+ //#region ../form-definitions/generated/ekycprefill.ts
68
+ const EKYCPREFILL_DEFINITIONS = {
69
+ "ekycprefill/BR/BR_PREFILL": {
70
+ schemaVersion: 1,
71
+ vocabulary: "1.4",
72
+ id: "ekycprefill/BR/BR_PREFILL",
73
+ module: "ekycprefill",
74
+ country: "BR",
75
+ source: "BR_PREFILL",
76
+ fields: [{
77
+ name: "taxIdNumber",
78
+ kind: "text",
79
+ group: "ssn",
80
+ required: true,
81
+ label: { key: "verification.labels.taxId" },
82
+ displayLabel: {
83
+ key: "verification.labels.cpf",
84
+ text: "CPF"
85
+ },
86
+ input: {
87
+ maxLength: 14,
88
+ keyboard: "numeric",
89
+ format: [{
90
+ id: "digitGroups",
91
+ params: {
92
+ groups: [
93
+ 3,
94
+ 3,
95
+ 3,
96
+ 2
97
+ ],
98
+ separator: ".",
99
+ separators: [
100
+ ".",
101
+ ".",
102
+ "-"
103
+ ]
104
+ }
105
+ }]
106
+ },
107
+ rules: [{ id: "cpf" }],
108
+ payload: { transforms: [{ id: "trim" }, {
109
+ id: "stripSeparators",
110
+ params: { chars: ".-" }
111
+ }] }
112
+ }],
113
+ submit: {
114
+ static: { plugins: ["kyc-prefill"] },
115
+ context: {
116
+ countryCode: "country",
117
+ source: "source"
118
+ }
119
+ }
120
+ },
121
+ "ekycprefill/US/US_PREFILL": {
122
+ schemaVersion: 1,
123
+ vocabulary: "1.3",
124
+ id: "ekycprefill/US/US_PREFILL",
125
+ module: "ekycprefill",
126
+ country: "US",
127
+ source: "US_PREFILL",
128
+ fields: [
129
+ {
130
+ name: "phone",
131
+ kind: "phone",
132
+ group: "phone",
133
+ required: true,
134
+ label: { key: "verification.labels.phone" },
135
+ input: { autofill: "phone" },
136
+ phone: { lockCountry: true },
137
+ rules: [{ id: "phoneFormat" }],
138
+ payload: { transforms: [{ id: "e164" }] }
139
+ },
140
+ {
141
+ name: "dateOfBirth",
142
+ kind: "date",
143
+ group: "dateOfBirth",
144
+ label: { key: "verification.labels.dateOfBirth" },
145
+ input: { autofill: "birthday" },
146
+ rules: [{ id: "notFuture" }, {
147
+ id: "maxAge",
148
+ params: { years: 120 }
149
+ }],
150
+ payload: { transforms: [{ id: "trim" }] }
151
+ },
152
+ {
153
+ name: "ssn",
154
+ kind: "text",
155
+ group: "ssn",
156
+ widget: "masked",
157
+ label: { key: "verification.labels.ssn" },
158
+ input: {
159
+ maxLength: 11,
160
+ keyboard: "numeric",
161
+ format: [{
162
+ id: "digitGroups",
163
+ params: {
164
+ groups: [
165
+ 3,
166
+ 2,
167
+ 4
168
+ ],
169
+ separator: "-"
170
+ }
171
+ }]
172
+ },
173
+ rules: [{ id: "ssnFormat" }],
174
+ payload: { transforms: [{ id: "trim" }, {
175
+ id: "stripSeparators",
176
+ params: { chars: "-" }
177
+ }] }
178
+ },
179
+ {
180
+ name: "surName",
181
+ kind: "text",
182
+ group: "name",
183
+ label: { key: "verification.labels.lastName" },
184
+ placeholder: { key: "verification.placeholder.lastName" },
185
+ input: {
186
+ maxLength: 100,
187
+ autofill: "familyName"
188
+ },
189
+ rules: [{ id: "nameCharacters" }],
190
+ payload: { transforms: [{ id: "trim" }] }
191
+ }
192
+ ],
193
+ groupRules: [{
194
+ id: "oneOfRequired",
195
+ fields: [
196
+ "dateOfBirth",
197
+ "ssn",
198
+ "surName"
199
+ ],
200
+ message: {
201
+ key: "ekycPrefill.errors.requireAnyOf",
202
+ text: "Provide at least one of {{fields}}"
203
+ }
204
+ }],
205
+ submit: {
206
+ static: { plugins: ["kyc-prefill"] },
207
+ context: {
208
+ countryCode: "country",
209
+ source: "source"
210
+ }
211
+ }
212
+ },
213
+ "ekycprefill/US/US_PREFILL_EXPRESS": {
214
+ schemaVersion: 1,
215
+ vocabulary: "1.0",
216
+ id: "ekycprefill/US/US_PREFILL_EXPRESS",
217
+ module: "ekycprefill",
218
+ country: "US",
219
+ source: "US_PREFILL_EXPRESS",
220
+ fields: [{
221
+ name: "phone",
222
+ kind: "phone",
223
+ group: "phone",
224
+ required: true,
225
+ label: { key: "verification.labels.phone" },
226
+ input: { autofill: "phone" },
227
+ phone: { lockCountry: true },
228
+ rules: [{ id: "phoneFormat" }],
229
+ payload: { transforms: [{ id: "e164" }] }
230
+ }],
231
+ submit: {
232
+ static: { plugins: ["kyc-prefill"] },
233
+ context: {
234
+ countryCode: "country",
235
+ source: "source"
236
+ }
237
+ }
238
+ }
239
+ };
240
+ //#endregion
241
+ //#region src/internal/forms/rules/charTemplate.ts
242
+ const isTemplate = (value) => typeof value === "string" && value !== "";
243
+ /**
244
+ * `charTemplate`, leading and trailing whitespace ignored as eKYC trims the
245
+ * value first. Without a non-empty list of non-empty templates, or with an
246
+ * `ignoreCase` that isn't a boolean, the rule passes.
247
+ */
248
+ const charTemplate = {
249
+ id: "charTemplate",
250
+ test: (value, { templates, ignoreCase }) => {
251
+ if (!Array.isArray(templates) || templates.length === 0 || !templates.every(isTemplate) || ignoreCase !== void 0 && typeof ignoreCase !== "boolean") return true;
252
+ return matchesCharTemplate(value.trim(), templates, ignoreCase);
253
+ }
254
+ };
255
+ //#endregion
256
+ //#region src/internal/forms/rules/cnpj.ts
257
+ /**
258
+ * `cnpj`: a Brazilian CNPJ, as eKYB checks it: 14 digits, or the
259
+ * 18-character `00.000.000/0000-00` layout, with surrounding whitespace
260
+ * ignored.
261
+ */
262
+ const cnpj = {
263
+ id: "cnpj",
264
+ test: (value) => validateCNPJ(value)
265
+ };
266
+ //#endregion
267
+ //#region src/internal/forms/rules/cpf.ts
268
+ /**
269
+ * `cpf`: a Brazilian CPF, as eKYC and eKYC Pre-fill check it, on the value as
270
+ * typed: 11 digits, or the 14-character `000.000.000-00` layout.
271
+ */
272
+ const cpf = {
273
+ id: "cpf",
274
+ test: (value) => validateCPF(value)
275
+ };
276
+ //#endregion
277
+ //#region src/internal/forms/rules/curp.ts
278
+ /**
279
+ * `curp`: the Mexican CURP layout, as the CURP module checks it. The value is
280
+ * trimmed first, as eKYC does today.
281
+ */
282
+ const curp = {
283
+ id: "curp",
284
+ test: (value) => isValidCurp(value.trim())
285
+ };
286
+ //#endregion
287
+ //#region src/internal/forms/rules/digitCount.ts
288
+ const isCount = (value) => typeof value === "number" && Number.isInteger(value) && value > 0;
289
+ /**
290
+ * The rule's counts, in the two shapes its message can name: `lengths` alone
291
+ * (a non-empty list of positive whole numbers), or both `min` and `max` with
292
+ * `min` no greater than `max`. These are the params eKYC accepts.
293
+ */
294
+ function countOf({ lengths, min, max }) {
295
+ if (lengths !== void 0) return Array.isArray(lengths) && lengths.length > 0 && lengths.every(isCount) && min === void 0 && max === void 0 ? { lengths } : void 0;
296
+ return isCount(min) && isCount(max) && min <= max ? {
297
+ min,
298
+ max
299
+ } : void 0;
300
+ }
301
+ /**
302
+ * `digitCount`, leading and trailing whitespace ignored as eKYC trims the
303
+ * value first. With params of another shape, such as `min` alone, the rule
304
+ * passes: no message names an open range.
305
+ */
306
+ const digitCount = {
307
+ id: "digitCount",
308
+ test: (value, params) => {
309
+ const count = countOf(params);
310
+ return !count || hasDigitCount(value.trim(), count);
311
+ },
312
+ error: (params) => digitCountError(countOf(params) ?? {})
313
+ };
314
+ //#endregion
315
+ //#region src/internal/forms/rules/digitGroups.ts
316
+ /**
317
+ * `digitGroups`: formats digits as the user types, such as an SSN shown as
318
+ * 3-2-4 (`groups: [3, 2, 4]`, `separator: "-"`). Other characters are
319
+ * dropped, digits past the last group are cut, and a separator appears once
320
+ * the next group has a digit (`1234` is `123-4`).
321
+ *
322
+ * `separators` (vocabulary 1.4) gives the separator after each group, in
323
+ * order, such as a CPF shown as 3.3.3-2 (`separators: [".", ".", "-"]`). A
324
+ * gap past the end of the list uses `separator`.
325
+ */
326
+ const digitGroups = {
327
+ id: "digitGroups",
328
+ apply: (value, params) => {
329
+ const groups = Array.isArray(params.groups) ? params.groups.filter((size) => typeof size === "number") : [];
330
+ const separator = typeof params.separator === "string" ? params.separator : "";
331
+ const separators = Array.isArray(params.separators) ? params.separators : [];
332
+ const separatorAfter = (index) => {
333
+ const own = separators[index];
334
+ return typeof own === "string" ? own : separator;
335
+ };
336
+ let digits = value.replace(/[^0-9]/g, "");
337
+ let formatted = "";
338
+ for (const [index, size] of groups.entries()) {
339
+ if (!digits) break;
340
+ if (index > 0) formatted += separatorAfter(index - 1);
341
+ formatted += digits.slice(0, size);
342
+ digits = digits.slice(size);
343
+ }
344
+ return formatted;
345
+ }
346
+ };
347
+ //#endregion
348
+ //#region src/internal/forms/rules/e164NoPlus.ts
349
+ /** `e164NoPlus`: the phone as E.164 without the `+`. */
350
+ const e164NoPlus = {
351
+ id: "e164NoPlus",
352
+ apply: (value, params, env) => e164.apply(value, params, env).replace(/^\+/, "")
353
+ };
354
+ //#endregion
355
+ //#region src/internal/forms/rules/emailFormat.ts
356
+ /** `emailFormat`: an email's shape, the value as typed, as eKYC checks it. */
357
+ const emailFormat = {
358
+ id: "emailFormat",
359
+ test: (value) => isEmailFormat(value)
360
+ };
361
+ //#endregion
362
+ //#region src/internal/forms/rules/esDni.ts
363
+ /** `esDni`: a Spanish DNI, as eKYC checks it. */
364
+ const esDni = {
365
+ id: "esDni",
366
+ test: (value) => isValidEsDni(value)
367
+ };
368
+ //#endregion
369
+ //#region src/internal/forms/rules/exactLength.ts
370
+ /**
371
+ * `exactLength`: exactly `length` characters, the value as typed. Characters
372
+ * are Unicode code points, as `maxLength` counts them; eKYC counts UTF-16
373
+ * units, which differs only for characters outside the BMP, such as emoji.
374
+ * Without a positive whole `length` the rule passes. The message is the
375
+ * vocabulary's, without params, as eKYC gives it.
376
+ */
377
+ const exactLength = {
378
+ id: "exactLength",
379
+ test: (value, { length }) => typeof length !== "number" || !Number.isInteger(length) || length < 1 || [...value].length === length
380
+ };
381
+ //#endregion
382
+ //#region src/internal/forms/rules/fiPersonalIdentityCode.ts
383
+ /**
384
+ * `fiPersonalIdentityCode`: a Finnish personal identity code, as eKYC checks
385
+ * it.
386
+ */
387
+ const fiPersonalIdentityCode = {
388
+ id: "fiPersonalIdentityCode",
389
+ test: (value) => isValidFiPersonalIdentityCode(value)
390
+ };
391
+ //#endregion
392
+ //#region src/internal/forms/rules/inDrivingLicenseNumber.ts
393
+ /**
394
+ * `inDrivingLicenseNumber`: an Indian driving licence number, as eKYC checks
395
+ * it.
396
+ */
397
+ const inDrivingLicenseNumber = {
398
+ id: "inDrivingLicenseNumber",
399
+ test: (value) => isValidInDrivingLicenseNumber(value)
400
+ };
401
+ //#endregion
402
+ //#region src/internal/forms/rules/maxAge.ts
403
+ const isYears = (value) => typeof value === "number" && Number.isInteger(value) && value >= 0;
404
+ /**
405
+ * `maxAge`: at most `years` full years before `env.today`, trimmed as eKYC
406
+ * checks it. Unusable params pass.
407
+ */
408
+ const maxAge = {
409
+ id: "maxAge",
410
+ test: (value, params, env) => isYears(params.years) ? isWithinMaxAge(value.trim(), env.today, params.years) : true
411
+ };
412
+ //#endregion
413
+ //#region src/internal/forms/rules/nameCharacters.ts
414
+ /**
415
+ * `nameCharacters`: a name's characters. Leading and trailing whitespace is
416
+ * ignored, as eKYC trims the value before checking it.
417
+ */
418
+ const nameCharacters = {
419
+ id: "nameCharacters",
420
+ test: (value) => hasNameCharacters(value.trim())
421
+ };
422
+ //#endregion
423
+ //#region src/internal/forms/rules/nationalNumber.ts
424
+ /**
425
+ * `nationalNumber`: the phone's national significant number, without the
426
+ * calling code or a trunk 0. While the phone rules aren't loaded, or the
427
+ * number can't be read, it stays as typed.
428
+ */
429
+ const nationalNumber = {
430
+ id: "nationalNumber",
431
+ apply: (value, _params, env) => env.deps.phone?.nationalNumber(value, env.country) ?? value
432
+ };
433
+ //#endregion
434
+ //#region src/internal/forms/rules/noPoBox.ts
435
+ /** `noPoBox`: the street doesn't describe a P.O. box, as eKYC checks it. */
436
+ const noPoBox = {
437
+ id: "noPoBox",
438
+ test: (value) => !isPoBox(value)
439
+ };
440
+ //#endregion
441
+ //#region src/internal/forms/rules/notFuture.ts
442
+ /** `notFuture`: on or before `env.today`, trimmed as eKYC checks it. */
443
+ const notFuture = {
444
+ id: "notFuture",
445
+ test: (value, _params, env) => isNotFuture(value.trim(), env.today)
446
+ };
447
+ //#endregion
448
+ //#region src/internal/forms/rules/numericRange.ts
449
+ const isWhole = (value) => typeof value === "number" && Number.isInteger(value);
450
+ /** Whole-number `min` and `max` with `min` no greater than `max`. */
451
+ function rangeOf({ min, max }) {
452
+ return isWhole(min) && isWhole(max) && min <= max ? {
453
+ min,
454
+ max
455
+ } : void 0;
456
+ }
457
+ /**
458
+ * `numericRange`, leading and trailing whitespace ignored as eKYC trims the
459
+ * value first. The message names the range (`min`, `max`). Without a usable
460
+ * range the rule passes.
461
+ */
462
+ const numericRange = {
463
+ id: "numericRange",
464
+ test: (value, params) => {
465
+ const range = rangeOf(params);
466
+ return !range || isInNumericRange(value.trim(), range.min, range.max);
467
+ },
468
+ error: (params) => {
469
+ const range = rangeOf(params);
470
+ return {
471
+ key: "verification.errors.numberBetween",
472
+ ...range && { params: {
473
+ min: range.min,
474
+ max: range.max
475
+ } }
476
+ };
477
+ }
478
+ };
479
+ //#endregion
480
+ //#region src/internal/forms/rules/phoneDigits.ts
481
+ const isDigitCount = (value) => typeof value === "number" && Number.isInteger(value) && value >= 0;
482
+ /**
483
+ * `phoneDigits`: the national significant number has `min` to `max` digits,
484
+ * so the calling code and a trunk prefix don't count. As in eKYC, the value
485
+ * is trimmed, and a number the phone rules can't read fails, as does every
486
+ * phone while they aren't loaded. Unusable params pass.
487
+ */
488
+ const phoneDigits = {
489
+ id: "phoneDigits",
490
+ test: (value, params, env) => {
491
+ const { min, max } = params;
492
+ if (!isDigitCount(min) || !isDigitCount(max) || min > max) return true;
493
+ const national = env.deps.phone?.nationalNumber(value.trim(), env.country);
494
+ if (!national) return false;
495
+ return national.length >= min && national.length <= max;
496
+ }
497
+ };
498
+ //#endregion
499
+ //#region src/internal/forms/rules/phoneFormat.ts
500
+ /**
501
+ * `phoneFormat`: a valid number for its own country, without its leading and
502
+ * trailing whitespace, as eKYC checks it. While the phone rules aren't loaded
503
+ * every phone fails, as in eKYC.
504
+ */
505
+ const phoneFormat = {
506
+ id: "phoneFormat",
507
+ test: (value, _params, env) => env.deps.phone?.isValid(value.trim(), env.country) ?? false
508
+ };
509
+ //#endregion
510
+ //#region src/internal/forms/rules/postalCodeFormat.ts
511
+ /**
512
+ * `postalCodeFormat`: the postal format of the form's country, checked on the
513
+ * value as typed, as eKYC does. The tables and the message, which depends on
514
+ * the country, come from `env.deps.postal`; without them every value passes.
515
+ */
516
+ const postalCodeFormat = {
517
+ id: "postalCodeFormat",
518
+ test: (value, _params, env) => env.deps.postal ? env.deps.postal.isValid(value, env.country) : true,
519
+ error: (_params, env) => {
520
+ const postal = env.deps.postal;
521
+ if (!postal) return { key: "postalCodeFormat" };
522
+ return {
523
+ key: postal.errorKey(env.country),
524
+ params: postal.params(env.country)
525
+ };
526
+ }
527
+ };
528
+ //#endregion
529
+ //#region src/internal/forms/rules/rulesByOption.ts
530
+ const isCaseRule = (value) => typeof value === "object" && value !== null && typeof value.id === "string";
531
+ /**
532
+ * `rulesByOption`: the `target` field must pass the rules listed for the
533
+ * `selector` field's current value. It runs only while both are shown and the
534
+ * target has a value; a value with no case adds no rules. The error goes on
535
+ * the target: a case rule's own message first, then the group rule's
536
+ * message, then the rule's own error.
537
+ */
538
+ const rulesByOption = {
539
+ id: "rulesByOption",
540
+ check: ({ rule, fields, values, isEmpty, checkRule }) => {
541
+ const { selector, target, cases } = rule.params ?? {};
542
+ if (typeof selector !== "string" || typeof target !== "string") return {};
543
+ if (!fields.includes(selector) || !fields.includes(target)) return {};
544
+ if (isEmpty(target)) return {};
545
+ if (typeof cases !== "object" || cases === null || Array.isArray(cases)) return {};
546
+ const option = String(values[selector] ?? "").trim();
547
+ const rules = Object.prototype.hasOwnProperty.call(cases, option) ? cases[option] : void 0;
548
+ if (!Array.isArray(rules)) return {};
549
+ const value = String(values[target]);
550
+ for (const ref of rules) {
551
+ if (!isCaseRule(ref)) continue;
552
+ const error = checkRule(ref, value);
553
+ if (!error) continue;
554
+ return { [target]: rule.message && !ref.message ? withMessage(error, rule.message) : error };
555
+ }
556
+ return {};
557
+ }
558
+ };
559
+ //#endregion
560
+ //#region src/internal/forms/rules/rut.ts
561
+ /** `rut`: a Chilean RUT, as eKYC checks it. */
562
+ const rut = {
563
+ id: "rut",
564
+ test: (value) => isValidRut(value)
565
+ };
566
+ //#endregion
567
+ //#region src/internal/forms/checks/ssnFormat.ts
568
+ /** Nine digits in 3-2-4 groups, each `-` between the groups optional. */
569
+ const SSN_PATTERN = /^[0-9]{3}-?[0-9]{2}-?[0-9]{4}$/;
570
+ /**
571
+ * Whether a value is a US SSN as the vocabulary defines it: nine digits, with
572
+ * optional `-` separators in the 3-2-4 groups (`123456789`, `123-45-6789`,
573
+ * `123-456789`).
574
+ */
575
+ function isSsnFormat(value) {
576
+ return SSN_PATTERN.test(value);
577
+ }
578
+ //#endregion
579
+ //#region src/internal/forms/rules/ssnFormat.ts
580
+ /**
581
+ * `ssnFormat`: a US SSN, the value as typed. eKYC's own validator still
582
+ * requires both dashes; this follows the vocabulary.
583
+ */
584
+ const ssnFormat = {
585
+ id: "ssnFormat",
586
+ test: (value) => isSsnFormat(value)
587
+ };
588
+ //#endregion
589
+ //#region src/internal/forms/rules/stripSeparators.ts
590
+ /**
591
+ * `stripSeparators`: removes spaces, `-`, `.` and `/`, or the characters in
592
+ * `chars`. "Spaces" means any whitespace, as eKYC's input format reads it.
593
+ */
594
+ const stripSeparators = {
595
+ id: "stripSeparators",
596
+ apply: (value, params) => {
597
+ if (typeof params.chars !== "string") return value.replace(/[\s./-]/g, "");
598
+ const remove = new Set(params.chars);
599
+ return [...value].filter((char) => !remove.has(char)).join("");
600
+ }
601
+ };
602
+ //#endregion
603
+ //#region src/internal/forms/rules/uppercase.ts
604
+ /** `uppercase`: converts letters to uppercase, over Unicode code points. */
605
+ const uppercase = {
606
+ id: "uppercase",
607
+ apply: (value) => value.toUpperCase()
608
+ };
609
+ //#endregion
610
+ //#region src/internal/forms/rules/index.ts
611
+ /** Every vocabulary rule, in vocabulary order. */
612
+ const STANDARD_RULES = [
613
+ ssnFormat,
614
+ cpf,
615
+ cnpj,
616
+ postalCodeFormat,
617
+ phoneFormat,
618
+ emailFormat,
619
+ noPoBox,
620
+ exactLength,
621
+ nameCharacters,
622
+ notFuture,
623
+ maxAge,
624
+ digitCount,
625
+ allowedCharacters,
626
+ charTemplate,
627
+ numericRange,
628
+ rut,
629
+ esDni,
630
+ fiPersonalIdentityCode,
631
+ inDrivingLicenseNumber,
632
+ curp,
633
+ phoneDigits
634
+ ];
635
+ /** Every vocabulary transform, in vocabulary order. */
636
+ const STANDARD_TRANSFORMS = [
637
+ uppercase,
638
+ stripSeparators,
639
+ e164,
640
+ trim,
641
+ nationalNumber,
642
+ e164NoPlus,
643
+ digitGroups
644
+ ];
645
+ /** Every vocabulary group rule, in vocabulary order. */
646
+ const STANDARD_GROUP_RULES = [oneOfRequired, rulesByOption];
647
+ //#endregion
648
+ //#region src/shared/ruleMessages.ts
649
+ /**
650
+ * Each rule's default message, as the vocabulary gives it, for a registry
651
+ * that doesn't bundle the vocabulary (eKYC Pre-fill). Its own file, so only
652
+ * that registry's bundle carries it. A test pins it to the
653
+ * vocabulary. A rule with no default (`postalCodeFormat`, `digitCount`) gives
654
+ * its own message.
655
+ */
656
+ const RULE_MESSAGES = {
657
+ ssnFormat: "verification.errors.ssnFormat",
658
+ cpf: "verification.errors.invalidTaxId",
659
+ cnpj: "ekyb.error.invalidTaxId",
660
+ phoneFormat: "verification.errors.phoneInvalid",
661
+ emailFormat: "verification.errors.emailInvalid",
662
+ noPoBox: "verification.errors.poBox",
663
+ exactLength: "verification.errors.exactly10Characters",
664
+ nameCharacters: "verification.errors.nameCharacters",
665
+ notFuture: "verification.errors.futureDate",
666
+ maxAge: "verification.errors.dateOfBirthMaxAge",
667
+ allowedCharacters: "verification.errors.invalidCharacters",
668
+ charTemplate: "verification.errors.invalidFormat",
669
+ numericRange: "verification.errors.numberBetween",
670
+ rut: "verification.errors.invalidIdNumber",
671
+ esDni: "verification.errors.invalidIdNumber",
672
+ fiPersonalIdentityCode: "verification.errors.invalidIdNumber",
673
+ inDrivingLicenseNumber: "verification.errors.invalidIdNumber",
674
+ curp: "verification.errors.invalidIdNumber",
675
+ phoneDigits: "verification.errors.phoneInvalid"
676
+ };
677
+ //#endregion
678
+ //#region src/modules/ekyc-prefill/ekycPrefillDefinition.ts
679
+ /**
680
+ * eKYC Pre-fill adapter for form definitions.
681
+ *
682
+ * The catalog (`catalog/ekycprefill`) holds one definition per backend
683
+ * source, keyed by (source, country) as eKYC's are: the inputs the source
684
+ * takes, which are required and which are "at least one of", with their
685
+ * labels, rules and request keys. The served module configuration
686
+ * (ENG-61990) turns inputs on (`check`) and says where each value comes from
687
+ * (`source`) and how it shows (`displayMode`). This adapter selects the
688
+ * definition and translates the configuration into a `ResolveContext`. It
689
+ * never changes the definition, so a definition the backend serves later
690
+ * takes the same path. Values are checked and the request is built by the
691
+ * kernel with the standard registry (`EKYC_PREFILL_REGISTRY`).
692
+ */
693
+ const EKYC_PREFILL_MODULE = "ekycprefill";
694
+ /**
695
+ * Every rule and transform the kernel implements, so a rule the Pre-fill
696
+ * catalog starts using needs no change here. It is the standard registry
697
+ * without the vocabulary in the bundle: the default messages, groups and
698
+ * version come from small tables a test pins to it.
699
+ */
700
+ const EKYC_PREFILL_REGISTRY = createFormRegistry({
701
+ schemaVersions: [1],
702
+ vocabulary: "1.4",
703
+ kinds: [
704
+ "text",
705
+ "date",
706
+ "phone"
707
+ ],
708
+ groups: [
709
+ "name",
710
+ "dateOfBirth",
711
+ "phone",
712
+ "ssn"
713
+ ],
714
+ rules: STANDARD_RULES,
715
+ transforms: STANDARD_TRANSFORMS,
716
+ groupRules: STANDARD_GROUP_RULES,
717
+ messages: RULE_MESSAGES,
718
+ flags: ["payload.omitWhenEmpty"],
719
+ required: requiredError,
720
+ structure: STRUCTURE_MESSAGES
721
+ });
722
+ /**
723
+ * Typing formats (`input.format`) the module applies as the user types, with
724
+ * the kernel's implementations: the SSN's and the CPF's `digitGroups`.
725
+ */
726
+ const EKYC_PREFILL_INPUT_FORMATS = /* @__PURE__ */ new Map([[digitGroups.id, digitGroups]]);
727
+ const ONE_OF_REQUIRED$1 = "oneOfRequired";
728
+ /**
729
+ * A rule its environment can't check yet: `postalCodeFormat` needs the postal
730
+ * tables, which Pre-fill doesn't load (its env only has the phone rules).
731
+ * Left out of the supported ids, a definition that uses it is refused rather
732
+ * than checked by nothing.
733
+ */
734
+ const NEEDS_UNLOADED_DEPS = /* @__PURE__ */ new Set(["postalCodeFormat"]);
735
+ /**
736
+ * The ids this build can render, validate and send: the registry's rules and
737
+ * transforms, and only what the form renders. It shows text, date and phone
738
+ * fields and one "at least one of" rule, with no option lists or conditions.
739
+ */
740
+ const EKYC_PREFILL_SUPPORTED_IDS = {
741
+ ...supportedIds(EKYC_PREFILL_REGISTRY),
742
+ rules: new Set([...EKYC_PREFILL_REGISTRY.rules.keys()].filter((id) => !NEEDS_UNLOADED_DEPS.has(id))),
743
+ kinds: /* @__PURE__ */ new Set([
744
+ "text",
745
+ "date",
746
+ "phone"
747
+ ]),
748
+ groupRules: /* @__PURE__ */ new Set([ONE_OF_REQUIRED$1]),
749
+ optionLists: /* @__PURE__ */ new Set(),
750
+ conditions: /* @__PURE__ */ new Set(),
751
+ prefillSources: /* @__PURE__ */ new Set(),
752
+ flags: /* @__PURE__ */ new Set()
753
+ };
754
+ /**
755
+ * Module configuration's value sources → the vocabulary's prefill origins
756
+ * (each origin's `configValues`). A test pins this table to the vocabulary.
757
+ */
758
+ const PREFILL_ORIGINS = /* @__PURE__ */ new Map([
759
+ ["userInput", "userInput"],
760
+ ["document", "document"],
761
+ ["poa", "poa"],
762
+ ["phoneModuleInput", "phoneModule"],
763
+ ["emailModuleInput", "emailModule"]
764
+ ]);
765
+ /** Origins whose values another module verified (the vocabulary's `locks`). */
766
+ const LOCKING_ORIGINS = ["phoneModule", "emailModule"];
767
+ const bundled = createBundledDefinitionSource(EKYCPREFILL_DEFINITIONS);
768
+ /**
769
+ * The definition for exactly this source and country, or `undefined` when
770
+ * there is none. Bundled today; a served definition source (P4) plugs in
771
+ * here, and nothing after selection changes.
772
+ */
773
+ function selectEkycPrefillDefinition(source, country) {
774
+ return bundled.select({
775
+ module: EKYC_PREFILL_MODULE,
776
+ source,
777
+ country
778
+ });
779
+ }
780
+ const projectable = /* @__PURE__ */ new WeakMap();
781
+ /**
782
+ * Whether the form can render a definition: the supported ids, typing
783
+ * formats it applies, at most one `oneOfRequired` rule without message params
784
+ * (the form shows one "at least one of" hint and lists its members itself),
785
+ * and no collections.
786
+ */
787
+ function isProjectableEkycPrefillDefinition(definition) {
788
+ let result = projectable.get(definition);
789
+ if (result === void 0) {
790
+ const groupRules = definition.groupRules ?? [];
791
+ result = definition.module === "ekycprefill" && checkSupport(definition, EKYC_PREFILL_SUPPORTED_IDS).supported && definition.fields.every((field) => (field.input?.format ?? []).every((format) => EKYC_PREFILL_INPUT_FORMATS.has(format.id))) && groupRules.length <= 1 && groupRules.every((rule) => rule.id === ONE_OF_REQUIRED$1 && !rule.message?.params) && !definition.collections?.length;
792
+ projectable.set(definition, result);
793
+ }
794
+ return result;
795
+ }
796
+ /**
797
+ * Translates the served configuration into the kernel's `ResolveContext`:
798
+ *
799
+ * - `check: true` turns the field's group on;
800
+ * - `source` becomes the group's prefill origin;
801
+ * - `displayMode` becomes the group's display mode.
802
+ *
803
+ * A shown input the definition has no field for is left out with a warning.
804
+ * `mandatory` and `requireAnyOf` are not read here: the definition decides
805
+ * requiredness (see `ekycPrefillDrift`).
806
+ */
807
+ function toEkycPrefillContext(definition, config) {
808
+ const groupOf = new Map(definition.fields.map((field) => [field.name, field.group]));
809
+ const groups = {};
810
+ const origins = {};
811
+ const displayModes = {};
812
+ const unknownMandatory = [];
813
+ for (const field of config.fields ?? []) {
814
+ const group = groupOf.get(field.field);
815
+ if (group === void 0) {
816
+ if (!field.check) continue;
817
+ console.warn(`[ekyc-prefill] No "${field.field}" field for ${definition.id}; it is not shown`);
818
+ if (field.mandatory) unknownMandatory.push(field.field);
819
+ continue;
820
+ }
821
+ if (field.check) groups[group] = true;
822
+ const origin = field.source && PREFILL_ORIGINS.get(field.source);
823
+ if (origin) origins[group] = origin;
824
+ if (field.displayMode) displayModes[group] = field.displayMode;
825
+ }
826
+ return {
827
+ context: {
828
+ groups,
829
+ origins,
830
+ displayModes,
831
+ lockingOrigins: LOCKING_ORIGINS
832
+ },
833
+ unknownMandatory
834
+ };
835
+ }
836
+ const sorted = (names) => [...new Set(names)].sort();
837
+ const listOf = (names) => `[${names.join(", ")}]`;
838
+ /**
839
+ * Where the served `mandatory` and `requireAnyOf` disagree with the resolved
840
+ * definition, one line each: the required fields, and the shown members of
841
+ * its "at least one of" rule. The definition wins; the module logs these, and
842
+ * the contract test fails on any.
843
+ */
844
+ function ekycPrefillDrift(form, config) {
845
+ const shown = new Set(form.fields.map(({ field }) => field.name));
846
+ const servedRequired = sorted((config.fields ?? []).filter((field) => field.check && field.mandatory).map((field) => field.field).filter((name) => shown.has(name)));
847
+ const required = sorted(form.fields.filter((field) => field.required).map(({ field }) => field.name));
848
+ const servedAnyOf = sorted(config.requireAnyOf.filter((name) => shown.has(name)));
849
+ const anyOf = sorted(form.groupRules.filter(({ rule }) => rule.id === ONE_OF_REQUIRED$1).flatMap(({ fields }) => fields));
850
+ const lines = [];
851
+ if (listOf(servedRequired) !== listOf(required)) lines.push(`required: served ${listOf(servedRequired)}, definition ${listOf(required)}`);
852
+ if (listOf(servedAnyOf) !== listOf(anyOf)) lines.push(`at least one of: served ${listOf(servedAnyOf)}, definition ${listOf(anyOf)}`);
853
+ return lines;
854
+ }
855
+ //#endregion
856
+ //#region src/modules/ekyc-prefill/ekycPrefillFields.ts
857
+ /**
858
+ * eKYC Pre-fill on the forms kernel: selects the source's definition,
859
+ * resolves it against the served configuration and projects it to
860
+ * `EkycPrefillFieldDef`s. Values are checked with the kernel's
861
+ * `validateForm` and the request body is the kernel's `buildPayload`, both
862
+ * with `EKYC_PREFILL_REGISTRY`. The resolved form never leaves this file, so
863
+ * no kernel type reaches the published `.d.ts`.
864
+ */
865
+ const PHONE_INVALID_ERROR = { key: "verification.errors.phoneInvalid" };
866
+ /** Vocabulary autofill ids → HTML `autocomplete` tokens (WCAG 2.2 SC 1.3.5). */
867
+ const AUTOCOMPLETE = {
868
+ givenName: "given-name",
869
+ middleName: "additional-name",
870
+ familyName: "family-name",
871
+ email: "email",
872
+ phone: "tel",
873
+ addressLine1: "address-line1",
874
+ addressLine2: "address-line2",
875
+ addressLevel1: "address-level1",
876
+ addressLevel2: "address-level2",
877
+ postalCode: "postal-code",
878
+ birthday: "bday",
879
+ organization: "organization"
880
+ };
881
+ const TYPES = {
882
+ date: "date",
883
+ phone: "phone"
884
+ };
885
+ const ONE_OF_REQUIRED = "oneOfRequired";
886
+ function projectField(resolved, displayMode) {
887
+ const { field, required, phoneLocked } = resolved;
888
+ const autoComplete = field.input?.autofill ? AUTOCOMPLETE[field.input.autofill] : void 0;
889
+ return {
890
+ name: field.name,
891
+ type: TYPES[field.kind] ?? "text",
892
+ label: field.label.key,
893
+ required,
894
+ ...field.displayLabel && { displayLabel: field.displayLabel.text ?? field.displayLabel.key },
895
+ ...field.placeholder && { placeholder: field.placeholder.key },
896
+ ...field.input?.maxLength !== void 0 && { maxLength: field.input.maxLength },
897
+ ...field.kind === "phone" && { disableCountrySelector: phoneLocked },
898
+ ...displayMode === "readOnly" && { readonly: true },
899
+ ...field.widget === "masked" && { masked: true },
900
+ ...field.input?.keyboard === "numeric" && { numeric: true },
901
+ ...autoComplete && { autoComplete }
902
+ };
903
+ }
904
+ /**
905
+ * The form the kernel checks: only the rendered fields, and the "at least one
906
+ * of" rule over its rendered members. With one member left, that member is
907
+ * required instead, so it shows the usual asterisk and required message (CK1
908
+ * decision K13); with none, the rule goes. A copy: the definition and the
909
+ * resolved form are never changed.
910
+ */
911
+ function requireLoneMember(form, rendered) {
912
+ const lone = /* @__PURE__ */ new Set();
913
+ const groupRules = form.groupRules.flatMap((groupRule) => {
914
+ const members = groupRule.fields.filter((name) => rendered.has(name));
915
+ if (groupRule.rule.id === ONE_OF_REQUIRED && members.length <= 1) {
916
+ for (const name of members) lone.add(name);
917
+ return [];
918
+ }
919
+ return [{
920
+ ...groupRule,
921
+ fields: members
922
+ }];
923
+ });
924
+ return {
925
+ ...form,
926
+ fields: form.fields.filter(({ field }) => rendered.has(field.name)).map((resolved) => lone.has(resolved.field.name) ? {
927
+ ...resolved,
928
+ required: true
929
+ } : resolved),
930
+ groupRules
931
+ };
932
+ }
933
+ const preparedForms = /* @__PURE__ */ new WeakMap();
934
+ function prepared(config) {
935
+ if (preparedForms.has(config)) return preparedForms.get(config) ?? void 0;
936
+ const result = prepare(config);
937
+ preparedForms.set(config, result ?? null);
938
+ return result;
939
+ }
940
+ /**
941
+ * Pre-fill reads no field values yet (its catalog lists no prefill sources),
942
+ * so `resolvePrefill` gets none and only decides display modes. These checks
943
+ * never run; they reject any value, so none could slip in unchecked.
944
+ */
945
+ const NO_VALUES = {};
946
+ const NO_PREFILL_CHECKS = {
947
+ format: (_field, value) => value,
948
+ isValid: () => false
949
+ };
950
+ /**
951
+ * The served configuration on the forms kernel: the source's definition,
952
+ * checked, resolved against the configuration and projected. `undefined`
953
+ * when the module can't render it: no `fields` (the flat dashboard shape),
954
+ * no source or country, no definition for the pair, a mandatory input the
955
+ * definition doesn't know, a definition this build can't render, or no input
956
+ * to show. The definition decides requiredness; where the served `mandatory`
957
+ * or `requireAnyOf` disagree, a warning names the difference.
958
+ */
959
+ function prepareEkycPrefillForm(config) {
960
+ return prepared(config)?.form;
961
+ }
962
+ /** What the kernel checks the form's values against. */
963
+ function ekycPrefillFormCheck(config) {
964
+ return prepared(config)?.check;
965
+ }
966
+ function prepare(config) {
967
+ const { country, source, fields } = config;
968
+ if (!fields || !country || !source) return void 0;
969
+ const definition = selectEkycPrefillDefinition(source, country);
970
+ if (!definition) {
971
+ console.warn(`[ekyc-prefill] No form definition for source ${source} in ${country}`);
972
+ return;
973
+ }
974
+ const { context, unknownMandatory } = toEkycPrefillContext(definition, config);
975
+ if (unknownMandatory.length > 0) return void 0;
976
+ if (!isProjectableEkycPrefillDefinition(definition)) {
977
+ const support = checkSupport(definition, EKYC_PREFILL_SUPPORTED_IDS);
978
+ console.warn(`[ekyc-prefill] ${definition.id} can't be rendered by this build`, support.supported ? [] : support.problems);
979
+ return;
980
+ }
981
+ const resolved = resolveForm(definition, context);
982
+ for (const line of ekycPrefillDrift(resolved, config)) console.warn(`[ekyc-prefill] ${definition.id}: ${line}; the definition applies`);
983
+ const { fields: prefilled } = resolvePrefill(resolved, context, NO_VALUES, NO_PREFILL_CHECKS);
984
+ const rendered = prefilled.filter((field) => field.displayMode !== "hidden");
985
+ if (rendered.length === 0) return void 0;
986
+ const form = requireLoneMember(resolved, new Set(rendered.map(({ field }) => field.name)));
987
+ const required = new Set(form.fields.filter((field) => field.required).map(({ field }) => field.name));
988
+ const [anyOf] = form.groupRules;
989
+ return {
990
+ form: {
991
+ country,
992
+ fields: rendered.map((field) => projectField({
993
+ ...field,
994
+ required: required.has(field.field.name)
995
+ }, field.displayMode)),
996
+ anyOf: anyOf && {
997
+ fields: [...anyOf.fields],
998
+ message: anyOf.rule.message?.key ?? anyOf.rule.id
999
+ }
1000
+ },
1001
+ check: {
1002
+ form,
1003
+ registry: EKYC_PREFILL_REGISTRY,
1004
+ env: () => ({
1005
+ country,
1006
+ today: getLocalIsoDate(),
1007
+ source,
1008
+ deps: phoneDeps()
1009
+ }),
1010
+ invalidFormatError: PHONE_INVALID_ERROR
1011
+ },
1012
+ fields: new Map(rendered.map(({ field }) => [field.name, field]))
1013
+ };
1014
+ }
1015
+ /**
1016
+ * Formats a value as it is typed, with the field's typing formats from its
1017
+ * definition (`input.format`), such as the SSN's and the CPF's
1018
+ * `digitGroups`. A field without one, or unknown, keeps the value as typed.
1019
+ */
1020
+ function formatFieldValue(config, name, value) {
1021
+ const form = prepared(config);
1022
+ const field = form?.fields.get(name);
1023
+ if (!form || !field) return value;
1024
+ return formatValue(field, value, { transforms: EKYC_PREFILL_INPUT_FORMATS }, {
1025
+ country: form.form.country,
1026
+ today: getLocalIsoDate(),
1027
+ deps: {}
1028
+ });
1029
+ }
1030
+ /** The rendered field with this rule, such as the CPF's `cpf`. */
1031
+ function fieldWithRule(config, rule) {
1032
+ for (const [name, field] of prepared(config)?.fields ?? []) if (field.rules?.some((ref) => ref.id === rule)) return name;
1033
+ }
1034
+ /** Whether a rendered field's request needs the phone rules (`e164`). */
1035
+ function needsPhoneRules(config) {
1036
+ return [...prepared(config)?.fields.values() ?? []].some((field) => field.payload?.transforms?.some((transform) => transform.id === "e164"));
1037
+ }
1038
+ /**
1039
+ * The `POST /omni/externalVerification/ekyc-prefill` body: the kernel's
1040
+ * request body for the rendered fields. Empty values are left out, each
1041
+ * value goes through its transforms (`trim`, `stripSeparators`, `e164`), then
1042
+ * the static and context keys.
1043
+ */
1044
+ function buildEkycPrefillBody(config, values) {
1045
+ const check = prepared(config)?.check;
1046
+ if (!check) return {};
1047
+ const { body, problems } = buildPayload(check.form, values, check.registry, check.env());
1048
+ if (problems.length > 0) console.warn("[ekyc-prefill] Request body problems", problems);
1049
+ return { ...body };
1050
+ }
1051
+ //#endregion
1052
+ //#region src/modules/ekyc-prefill/ekycPrefillServices.ts
1053
+ /**
1054
+ * Runs the eKYC Pre-fill lookup for the session. Throws an `IncodeApiError`
1055
+ * on failure; its `status` is the body's status (4210 for a rejected phone)
1056
+ * and `httpStatus` the HTTP one.
1057
+ */
1058
+ async function submitEkycPrefill(body, signal) {
1059
+ try {
1060
+ return (await api.post(endpoints.ekycPrefillSubmit, body, { signal })).data;
1061
+ } catch (error) {
1062
+ throw toIncodeApiError(endpoints.ekycPrefillSubmit, error);
1063
+ }
1064
+ }
1065
+ //#endregion
1066
+ //#region src/modules/ekyc-prefill/ekycPrefillStateMachine.ts
1067
+ /** The body status the backend answers a phone it rejects with. */
1068
+ const PHONE_REJECTED_STATUS = 4210;
1069
+ /** Shown when the backend rejects the request and no single field is to blame. */
1070
+ const SUBMIT_REJECTED_KEY = "ekycPrefill.errors.checkInformation";
1071
+ const CPF_INVALID_KEY = "verification.errors.invalidTaxId";
1072
+ /** Loads the phone rules, rejecting when the load fails or times out. */
1073
+ const requirePhoneRules = async () => {
1074
+ if (!await loadPhoneValidation()) throw new Error("Failed to load the phone validation rules");
1075
+ };
1076
+ /**
1077
+ * The HTTP and body statuses of a failed request. Read by shape rather than
1078
+ * `instanceof IncodeApiError`, so a test or story double reaches each branch.
1079
+ */
1080
+ const statusesOf = (error) => {
1081
+ if (typeof error !== "object" || error === null) return {};
1082
+ const { httpStatus, status } = error;
1083
+ return {
1084
+ ...typeof httpStatus === "number" && { httpStatus },
1085
+ ...typeof status === "number" && { status }
1086
+ };
1087
+ };
1088
+ const httpStatusOf = (error) => statusesOf(error).httpStatus;
1089
+ const errorOf = (event) => event.error;
1090
+ const ekycPrefillMachine = setup({
1091
+ types: {
1092
+ context: {},
1093
+ events: {},
1094
+ input: {}
1095
+ },
1096
+ actors: {
1097
+ loadPhoneRules: fromPromise(async ({ input }) => {
1098
+ if (input.hasPhone) await requirePhoneRules();
1099
+ }),
1100
+ submit: fromPromise(async ({ input, signal }) => {
1101
+ if (needsPhoneRules(input.config)) await requirePhoneRules();
1102
+ return submitEkycPrefill(buildEkycPrefillBody(input.config, input.values), signal);
1103
+ })
1104
+ },
1105
+ actions: {
1106
+ applyForm: assign(({ context }) => ({ prepared: prepareEkycPrefillForm(context.config) })),
1107
+ setPhoneRulesLoaded: assign({ phoneRulesLoaded: true }),
1108
+ setPhoneRulesFailed: assign(({ event }) => {
1109
+ const error = errorOf(event);
1110
+ return {
1111
+ phoneRulesFailed: true,
1112
+ errorKind: "unavailable",
1113
+ errorMessage: error instanceof Error ? error.message : String(error)
1114
+ };
1115
+ }),
1116
+ setFieldValue: assign(({ context, event }) => {
1117
+ const { name, value, isValid } = event;
1118
+ const formatted = formatFieldValue(context.config, name, value);
1119
+ const check = ekycPrefillFormCheck(context.config);
1120
+ return {
1121
+ ...check ? setFieldValue(context, {
1122
+ type: "SET_FIELD",
1123
+ name,
1124
+ value: formatted,
1125
+ isValid
1126
+ }, check) : { values: {
1127
+ ...context.values,
1128
+ [name]: formatted
1129
+ } },
1130
+ submitError: void 0
1131
+ };
1132
+ }),
1133
+ validateOneField: assign(({ context, event }) => {
1134
+ const { name } = event;
1135
+ const check = ekycPrefillFormCheck(context.config);
1136
+ return { errors: check ? validateFieldValue(context, name, check) : {} };
1137
+ }),
1138
+ validateAll: assign(({ context }) => {
1139
+ const check = ekycPrefillFormCheck(context.config);
1140
+ return { errors: check ? validateAllValues(context, check) : {} };
1141
+ }),
1142
+ applyRejection: assign(({ context, event }) => {
1143
+ const error = errorOf(event);
1144
+ const names = context.prepared.fields.map((field) => field.name);
1145
+ if (statusesOf(error).status === PHONE_REJECTED_STATUS && names.includes("phone")) return { errors: {
1146
+ ...context.errors,
1147
+ phone: PHONE_INVALID_ERROR
1148
+ } };
1149
+ const cpfField = fieldWithRule(context.config, "cpf");
1150
+ if (cpfField && names.length === 1) return { errors: {
1151
+ ...context.errors,
1152
+ [cpfField]: { key: CPF_INVALID_KEY }
1153
+ } };
1154
+ return { submitError: SUBMIT_REJECTED_KEY };
1155
+ }),
1156
+ setSubmitError: assign(({ event }) => {
1157
+ const error = errorOf(event);
1158
+ return {
1159
+ errorKind: httpStatusOf(error) === 409 ? "busy" : "unavailable",
1160
+ errorMessage: error instanceof Error ? error.message : String(error)
1161
+ };
1162
+ }),
1163
+ clearError: assign({
1164
+ errorKind: void 0,
1165
+ errorMessage: void 0,
1166
+ phoneRulesFailed: false
1167
+ })
1168
+ },
1169
+ guards: {
1170
+ phoneRulesFailed: ({ context }) => context.phoneRulesFailed,
1171
+ isAutoExecution: ({ context }) => context.config.autoExecution,
1172
+ canRender: ({ context }) => !!prepareEkycPrefillForm(context.config),
1173
+ isValid: ({ context }) => Object.keys(context.errors).length === 0 && !!context.prepared,
1174
+ isBadRequest: ({ event }) => httpStatusOf(errorOf(event)) === 400,
1175
+ isForbidden: ({ event }) => httpStatusOf(errorOf(event)) === 403,
1176
+ isLimitReached: ({ event }) => httpStatusOf(errorOf(event)) === 429
1177
+ }
1178
+ }).createMachine({
1179
+ id: "ekycPrefill",
1180
+ initial: "idle",
1181
+ context: ({ input }) => ({
1182
+ config: toEkycPrefillConfig(input?.config),
1183
+ prepared: void 0,
1184
+ values: {},
1185
+ errors: {},
1186
+ invalidFormats: {},
1187
+ phoneRulesLoaded: false,
1188
+ phoneRulesFailed: false,
1189
+ submitError: void 0,
1190
+ errorKind: void 0,
1191
+ errorMessage: void 0
1192
+ }),
1193
+ states: {
1194
+ idle: { on: { LOAD: [
1195
+ {
1196
+ guard: "isAutoExecution",
1197
+ target: "finished"
1198
+ },
1199
+ {
1200
+ guard: "canRender",
1201
+ target: "form",
1202
+ actions: "applyForm"
1203
+ },
1204
+ { target: "misconfigured" }
1205
+ ] } },
1206
+ form: {
1207
+ invoke: {
1208
+ id: "loadPhoneRules",
1209
+ src: "loadPhoneRules",
1210
+ input: ({ context }) => ({ hasPhone: !!context.prepared?.fields.some((field) => field.type === "phone") }),
1211
+ onDone: { actions: "setPhoneRulesLoaded" },
1212
+ onError: {
1213
+ target: "#ekycPrefill.error",
1214
+ actions: "setPhoneRulesFailed"
1215
+ }
1216
+ },
1217
+ initial: "inputting",
1218
+ states: {
1219
+ inputting: { on: {
1220
+ SET_FIELD: { actions: "setFieldValue" },
1221
+ VALIDATE_FIELD: { actions: "validateOneField" },
1222
+ SUBMIT: "validating"
1223
+ } },
1224
+ validating: {
1225
+ entry: "validateAll",
1226
+ always: [{
1227
+ guard: "isValid",
1228
+ target: "#ekycPrefill.submitting"
1229
+ }, { target: "inputting" }]
1230
+ }
1231
+ },
1232
+ on: { CLOSE: "closed" }
1233
+ },
1234
+ submitting: { invoke: {
1235
+ id: "submit",
1236
+ src: "submit",
1237
+ input: ({ context }) => ({
1238
+ config: context.config,
1239
+ values: context.values
1240
+ }),
1241
+ onDone: { target: "finished" },
1242
+ onError: [
1243
+ {
1244
+ guard: "isLimitReached",
1245
+ target: "limitReached"
1246
+ },
1247
+ {
1248
+ guard: "isBadRequest",
1249
+ target: "form.inputting",
1250
+ actions: "applyRejection"
1251
+ },
1252
+ {
1253
+ guard: "isForbidden",
1254
+ target: "misconfigured"
1255
+ },
1256
+ {
1257
+ target: "error",
1258
+ actions: "setSubmitError"
1259
+ }
1260
+ ]
1261
+ } },
1262
+ /**
1263
+ * The lookup could not run (409, 503, a network failure), or the phone
1264
+ * rules did not load: offer a retry of whichever failed.
1265
+ */
1266
+ error: { on: {
1267
+ RETRY: [{
1268
+ guard: "phoneRulesFailed",
1269
+ target: "form",
1270
+ actions: "clearError"
1271
+ }, {
1272
+ target: "submitting",
1273
+ actions: "clearError"
1274
+ }],
1275
+ CLOSE: "closed"
1276
+ } },
1277
+ /** The lookup limit is reached; it does not reset within the session, so the flow moves on. */
1278
+ limitReached: { on: {
1279
+ CONTINUE: "finished",
1280
+ CLOSE: "closed"
1281
+ } },
1282
+ /** The configuration can't be rendered, or the session's flow doesn't allow the lookup. */
1283
+ misconfigured: { on: { CLOSE: "closed" } },
1284
+ finished: { type: "final" },
1285
+ closed: { type: "final" }
1286
+ }
1287
+ });
1288
+ //#endregion
1289
+ export { ekycPrefillFormCheck as n, toEkycPrefillConfig as r, ekycPrefillMachine as t };