@adyen/kyc-components 2.3.3 → 2.4.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 (55) hide show
  1. package/dist/es/adyen-kyc-components.es.js +1300 -761
  2. package/dist/types/components/Company/types.d.ts +2 -2
  3. package/dist/types/components/Dropins/FormComposer/components/FormNavigation/FormNavigation.d.ts +1 -1
  4. package/dist/types/components/Dropins/FormComposer/components/FormNavigation/types.d.ts +4 -1
  5. package/dist/types/components/Dropins/IndividualDropin/components/IndividualDropinComponent.d.ts +1 -1
  6. package/dist/types/components/Dropins/RoleAndTypeDropin/components/RoleAndTypeDropinComponent.d.ts +1 -1
  7. package/dist/types/components/Dropins/RoleAndTypeDropin/types.d.ts +7 -14
  8. package/dist/types/components/IdentityHK/additionalIdentityInfoSchema.d.ts +8 -0
  9. package/dist/types/components/IdentityHK/component/DriversLicense.d.ts +14 -0
  10. package/dist/types/components/IdentityHK/component/IdentityHKComponent.d.ts +2 -0
  11. package/dist/types/components/IdentityHK/component/PassportNumber.d.ts +9 -0
  12. package/dist/types/components/IdentityHK/component/ProofOfIdentityCard.d.ts +10 -0
  13. package/dist/types/components/IdentityHK/component/TypeOfIdentity.d.ts +12 -0
  14. package/dist/types/components/IdentityHK/types.d.ts +10 -0
  15. package/dist/types/components/IdentityHK/validate.d.ts +7 -0
  16. package/dist/types/components/Individual/types.d.ts +2 -2
  17. package/dist/types/components/TrustMembers/component/CompanyTrustMemberTaskItem.d.ts +12 -0
  18. package/dist/types/components/TrustMembers/component/ExemptSettlorTaskItem.d.ts +10 -0
  19. package/dist/types/components/TrustMembers/component/RegularTrustMemberTaskItem.d.ts +10 -0
  20. package/dist/types/components/TrustMembers/component/RootTrusteeTaskItem.d.ts +8 -0
  21. package/dist/types/components/TrustMembers/component/TrustMembersOverview.d.ts +12 -0
  22. package/dist/types/components/TrustMembers/component/UndefinedBeneficiaryTaskItem.d.ts +7 -0
  23. package/dist/types/components/TrustMembers/types.d.ts +62 -19
  24. package/dist/types/components/TrustRoleAndEntityType/component/TrustRoleAndEntityType.d.ts +2 -0
  25. package/dist/types/components/TrustRoleAndEntityType/convertExistingTrustMember.d.ts +3 -0
  26. package/dist/types/components/TrustRoleAndEntityType/types.d.ts +7 -6
  27. package/dist/types/components/internal/Address/utils.d.ts +1 -1
  28. package/dist/types/components/internal/Address/validate.d.ts +2 -1
  29. package/dist/types/components/internal/EntityAssociation/types.d.ts +6 -2
  30. package/dist/types/core/Context/StateContext/StateContextWatcher.d.ts +2 -2
  31. package/dist/types/core/Context/StateContext/types.d.ts +3 -5
  32. package/dist/types/core/hooks/useExemptSettlor.d.ts +8 -0
  33. package/dist/types/core/models/api/trust-member-type.d.ts +1 -1
  34. package/dist/types/language/config.d.ts +14 -0
  35. package/dist/types/utils/decision-maker-roles.d.ts +1 -1
  36. package/dist/types/utils/entity-status-util.d.ts +2 -2
  37. package/dist/types/utils/formatting/stripCountryIdFormat.d.ts +1 -1
  38. package/dist/types/utils/mapping/trustMembers/getTrustMembers.d.ts +3 -0
  39. package/dist/types/utils/mapping/trustMembers/mapEntityAssociationsToTrustMembers.d.ts +10 -0
  40. package/dist/types/utils/mapping/trustMembers/mapRootLegalEntityToTrustMember.d.ts +3 -0
  41. package/dist/types/utils/mapping/trustMembers/mapUndefinedBeneficiaryInfoToTrustMembers.d.ts +3 -0
  42. package/dist/types/utils/regex/hkIdentityTypePatterns.d.ts +3 -0
  43. package/dist/types/utils/splitAtFirstOccurrence.d.ts +1 -0
  44. package/dist/types/utils/trust-util.d.ts +2 -15
  45. package/dist/types/utils/trustMembers/handlers/addOrUpdateAssociatedTrustMember.d.ts +8 -0
  46. package/dist/types/utils/trustMembers/handlers/addOrUpdateUndefinedBeneficiary.d.ts +8 -0
  47. package/dist/types/utils/trustMembers/handlers/createExemptSettlor.d.ts +8 -0
  48. package/dist/types/utils/trustMembers/handlers/deleteAssociatedTrustMember.d.ts +8 -0
  49. package/dist/types/utils/trustMembers/handlers/deleteUndefinedBeneficiary.d.ts +12 -0
  50. package/dist/types/utils/trustMembers/handlers/updateExemptSettlorName.d.ts +8 -0
  51. package/package.json +1 -1
  52. package/dist/types/components/TrustMembers/component/TrustMembersComponent.d.ts +0 -4
  53. package/dist/types/components/TrustMembers/component/UndefinedBeneficiaries.d.ts +0 -8
  54. package/dist/types/components/TrustRoleAndEntityType/component/TrustRoleAndEntityTypeComponent.d.ts +0 -3
  55. package/dist/types/utils/mapping/mapEntityAssociationsToUniqueTrustMembers.d.ts +0 -12
@@ -307,6 +307,9 @@ const invalidFormatForAuPassportNumber = "This isn't a valid Australian passport
307
307
  const invalidFormatForAuDriversLicenseNumber = "This isn't a valid Australian driver's license number. Expected format: 6-11 alphanumeric characters.";
308
308
  const invalidFormatForAuDriversLicenseCardNumber = "This isn't a valid Australian driver's license card number. Expected format: 6-10 alphanumeric characters.";
309
309
  const invalidFormatForAuProofOfIdentityCardNumber = "This isn't a valid Australian proof of identity card number. Expected format: 6-10 alphanumeric characters.";
310
+ const invalidFormatForHKPassportNumber = "Not valid for HK. Format should be: 9-character alphanumeric. For example: K12345599";
311
+ const invalidFormatForHKDriversLicenseNumber = "Not valid for HK. Format should be: 8-character alphanumeric. For example: A1234567";
312
+ const invalidFormatForHKIdentityCardNumber = "Not valid for HK. Format should be: 8 or 9-character alphanumeric. For example: C668668A";
310
313
  const invalidFormatIdentityNumberBR = "Please use the CFP format: XXX.XXX.XXX-XX";
311
314
  const invalidFormatIdentityNumberDK = "Please use the CPR format: XXXXXX-XXXX";
312
315
  const invalidFormatIdentityNumberCA = "Please use the SIN format: XXXXXXXXX";
@@ -318,6 +321,7 @@ const invalidFormatIdentityNumberSE = "Please use the Personnummer format: YYYYM
318
321
  const invalidFormatIdentityNumberUS = "Please provide last 4 digits";
319
322
  const invalidFormatIdentityNumberUS9 = "Please use the SSN format: XXXXXXXXX";
320
323
  const invalidFormatIdentityNumberSG = "Please use the NRIC format: S1234567A";
324
+ const invalidFormatIdentityNumberHK = "Not valid for HK. Format should be: 8 or 9-character alphanumeric. For example: C668668E";
321
325
  const invalidFormatBankStatementDescription = "Please ensure your input contains solely letters, digits, currency codes, and the specified special characters: -._,:;'*!@#%()+?¿/「」";
322
326
  const residencyCountry = "Country of residence";
323
327
  const stateOrProvince = "State or province";
@@ -334,6 +338,7 @@ const id = "ID";
334
338
  const driversLicense = "Driver's license";
335
339
  const issuerState = "Issuing state";
336
340
  const licenseNumber = "Driver license number";
341
+ const driverLicense = "Driver License";
337
342
  const licenseCardNumber = "Card number";
338
343
  const documents = "Documents";
339
344
  const idDocument$1 = "ID Document";
@@ -410,6 +415,7 @@ const validationPleaseEnterAValidVatNumberWithFormat = "Please enter a valid Tax
410
415
  const validationPleaseEnterAValidTaxIdNumberWithFormat = "Please enter a valid Tax id number. Expected format: %{format}";
411
416
  const aValidAbnShouldBe11Digits = "A valid ABN should be 11 digits.";
412
417
  const aValidUenOrGstShouldBe9To10Characters = "A valid UEN/GST should be 9 to 10 characters.";
418
+ const aValidBrnShouldBe8Digits = "A valid BRN should be 8 digits.";
413
419
  const validationPleaseEnterAValidUen = "Please enter a valid UEN";
414
420
  const validationPleaseEnterAValidIban = "Please enter a valid IBAN";
415
421
  const yourIbanShouldBeginWith_ = "Your IBAN should begin with %{countryCode}.";
@@ -445,6 +451,7 @@ const legalCompanyNameHelper = "Enter the name exactly as it is on your Chamber
445
451
  const legalCompanyNameHelper__AU = "Enter the name exactly as it is on your Australian Securities and Investment Commission's (ASIC)";
446
452
  const legalCompanyNameHelper__US = "Enter the name exactly as it appears on your Secretary of State Registration.";
447
453
  const legalCompanyNameHelper__SG = "Enter the name exactly as it is on your Accounting and Corporate Regulatory Authority (ACRA) BizFile";
454
+ const legalCompanyNameHelper__HK = "Enter the name exactly as it is on your Hong Kong Companies Registry's Certificate of Incorporation";
448
455
  const accountDetailsDescription = "Provide a few details about you to start accepting live payments.";
449
456
  const provideDetails = "Provide details";
450
457
  const payoutAccountsDescription = "To set up your account, let us know where to send your payouts.";
@@ -654,6 +661,7 @@ const numerodeIVA = "Número de IVA";
654
661
  const NIF = "NIF (Número de Identificación Fiscal)";
655
662
  const uen = "Unique Entity Number (UEN)";
656
663
  const nric = "National Registration Identity Card (NRIC)";
664
+ const hkid = "HKID Number";
657
665
  const NIFdeIVA = "Número de Identificación a efectos de IVA";
658
666
  const partitaIVA = "Partita IVA";
659
667
  const organisationsnummer = "Organisationsnummer";
@@ -673,6 +681,7 @@ const cancel = "Cancel";
673
681
  const leave = "Leave";
674
682
  const taxIdNumber = "Tax Identification Number";
675
683
  const companyRegistrationNumber = "Company registration number";
684
+ const companyRegistrationNumber__HK = "Company Registration number (CRN)";
676
685
  const euVatNumber = "EU VAT number";
677
686
  const vatNumber = "VAT number";
678
687
  const regonKrsNumber = "REGON / KRS number";
@@ -924,6 +933,7 @@ const instantVerification = "Instant verification";
924
933
  const xCharactersLeft = "%{charactersLeft} characters left";
925
934
  const goBack = "Go back";
926
935
  const businessRegistrationNumber = "Business registration number";
936
+ const businessRegistrationNumber__HK = "Business Registration number (BRN)";
927
937
  const doNotHaveBusinessNumber = "I do not have a Business number";
928
938
  const enterNameExactlyAsAppearInID = "Enter your first name(s) exactly as it appears on your identity document";
929
939
  const enterLastNameExactlyAsAppearInID = "Enter your last name(s) exactly as it appears on your identity document";
@@ -1199,6 +1209,10 @@ const deceased = "My settlor is deceased";
1199
1209
  const noneOfTheAbove = "None of the above";
1200
1210
  const settlorExemptionReason = "Settlor exemption reasons";
1201
1211
  const otherInformation = "Other information";
1212
+ const firstNameOfSettlor = "First name of settlor";
1213
+ const lastNameOfSettlor = "Last name of settlor";
1214
+ const enterSettlorsFirstNameExactlyAsItAppearsInID = "Enter the settlor's first name(s) exactly as it appears on their identity document";
1215
+ const enterSettlorsLastNameExactlyAsItAppearsInID = "Enter the settlor's last name(s) exactly as it appears on their identity document";
1202
1216
  const defaultTrans = {
1203
1217
  close,
1204
1218
  individual,
@@ -1262,6 +1276,9 @@ const defaultTrans = {
1262
1276
  invalidFormatForAuDriversLicenseNumber,
1263
1277
  invalidFormatForAuDriversLicenseCardNumber,
1264
1278
  invalidFormatForAuProofOfIdentityCardNumber,
1279
+ invalidFormatForHKPassportNumber,
1280
+ invalidFormatForHKDriversLicenseNumber,
1281
+ invalidFormatForHKIdentityCardNumber,
1265
1282
  invalidFormatIdentityNumberBR,
1266
1283
  invalidFormatIdentityNumberDK,
1267
1284
  invalidFormatIdentityNumberCA,
@@ -1273,6 +1290,7 @@ const defaultTrans = {
1273
1290
  invalidFormatIdentityNumberUS,
1274
1291
  invalidFormatIdentityNumberUS9,
1275
1292
  invalidFormatIdentityNumberSG,
1293
+ invalidFormatIdentityNumberHK,
1276
1294
  invalidFormatBankStatementDescription,
1277
1295
  residencyCountry,
1278
1296
  stateOrProvince,
@@ -1289,6 +1307,7 @@ const defaultTrans = {
1289
1307
  driversLicense,
1290
1308
  issuerState,
1291
1309
  licenseNumber,
1310
+ driverLicense,
1292
1311
  licenseCardNumber,
1293
1312
  documents,
1294
1313
  idDocument: idDocument$1,
@@ -1365,6 +1384,7 @@ const defaultTrans = {
1365
1384
  validationPleaseEnterAValidTaxIdNumberWithFormat,
1366
1385
  aValidAbnShouldBe11Digits,
1367
1386
  aValidUenOrGstShouldBe9To10Characters,
1387
+ aValidBrnShouldBe8Digits,
1368
1388
  validationPleaseEnterAValidUen,
1369
1389
  validationPleaseEnterAValidIban,
1370
1390
  yourIbanShouldBeginWith_,
@@ -1400,6 +1420,7 @@ const defaultTrans = {
1400
1420
  legalCompanyNameHelper__AU,
1401
1421
  legalCompanyNameHelper__US,
1402
1422
  legalCompanyNameHelper__SG,
1423
+ legalCompanyNameHelper__HK,
1403
1424
  accountDetailsDescription,
1404
1425
  provideDetails,
1405
1426
  payoutAccountsDescription,
@@ -1609,6 +1630,7 @@ const defaultTrans = {
1609
1630
  NIF,
1610
1631
  uen,
1611
1632
  nric,
1633
+ hkid,
1612
1634
  NIFdeIVA,
1613
1635
  partitaIVA,
1614
1636
  organisationsnummer,
@@ -1631,6 +1653,7 @@ const defaultTrans = {
1631
1653
  leave,
1632
1654
  taxIdNumber,
1633
1655
  companyRegistrationNumber,
1656
+ companyRegistrationNumber__HK,
1634
1657
  euVatNumber,
1635
1658
  vatNumber,
1636
1659
  regonKrsNumber,
@@ -1893,6 +1916,7 @@ const defaultTrans = {
1893
1916
  xCharactersLeft,
1894
1917
  goBack,
1895
1918
  businessRegistrationNumber,
1919
+ businessRegistrationNumber__HK,
1896
1920
  doNotHaveBusinessNumber,
1897
1921
  "UEN/GST": "Unique Entity Number (UEN)/Goods and Services Tax (GST)",
1898
1922
  "IRD/GST": "Inland Revenue Department Number (IRD No)/Goods and Services Tax (GST)",
@@ -2169,7 +2193,11 @@ const defaultTrans = {
2169
2193
  deceased,
2170
2194
  noneOfTheAbove,
2171
2195
  settlorExemptionReason,
2172
- otherInformation
2196
+ otherInformation,
2197
+ firstNameOfSettlor,
2198
+ lastNameOfSettlor,
2199
+ enterSettlorsFirstNameExactlyAsItAppearsInID,
2200
+ enterSettlorsLastNameExactlyAsItAppearsInID
2173
2201
  };
2174
2202
  const FALLBACK_LOCALE = "en-US";
2175
2203
  const defaultTranslation = defaultTrans;
@@ -3059,10 +3087,11 @@ function StateContextWatcher({
3059
3087
  }
3060
3088
  }, [JSON.stringify(formState == null ? void 0 : formState.currentState)]);
3061
3089
  return o(StateContext.Consumer, {
3062
- children: ({
3063
- state: state2
3064
- }) => {
3065
- setFormState(state2);
3090
+ children: (stateContextValue) => {
3091
+ if (!stateContextValue) {
3092
+ throw new Error("<StateContextWatcher> needs to be mounted inside a <StateProvider>");
3093
+ }
3094
+ setFormState(stateContextValue.state);
3066
3095
  return null;
3067
3096
  }
3068
3097
  });
@@ -3179,10 +3208,14 @@ function StateContextSetter({
3179
3208
  return null;
3180
3209
  }
3181
3210
  return o(StateContext.Consumer, {
3182
- children: ({
3183
- dispatch,
3184
- setActiveForms
3185
- }) => {
3211
+ children: (stateContextValue) => {
3212
+ if (!stateContextValue) {
3213
+ throw new Error("<StateContextSetter> needs to be mounted inside a <StateProvider>");
3214
+ }
3215
+ const {
3216
+ dispatch,
3217
+ setActiveForms
3218
+ } = stateContextValue;
3186
3219
  stateRef.current.setState = dispatch;
3187
3220
  stateRef.current.setActiveForms = setActiveForms;
3188
3221
  return null;
@@ -3593,6 +3626,17 @@ const useStaticValidator = (rules2) => {
3593
3626
  triggerStaticValidation
3594
3627
  };
3595
3628
  };
3629
+ const mergeStaticAndAsyncErrorsState = (staticValidationErrors, asyncValidationErrors, schema) => {
3630
+ if (!schema.length)
3631
+ return staticValidationErrors;
3632
+ return schema.reduce((acc, field) => {
3633
+ var _a;
3634
+ return {
3635
+ ...acc,
3636
+ [field]: staticValidationErrors[field] ?? ((_a = asyncValidationErrors[field]) == null ? void 0 : _a.getError()) ?? null
3637
+ };
3638
+ }, {});
3639
+ };
3596
3640
  function useForm({
3597
3641
  schema,
3598
3642
  defaultData,
@@ -3626,21 +3670,9 @@ function useForm({
3626
3670
  asyncValidate: triggerAsyncValidation
3627
3671
  }), [defaultData, fieldProblems, maskedFields, formatters, getRequiredFields, triggerStaticValidation, triggerAsyncValidation]);
3628
3672
  const [state2, dispatch] = s(getReducer(), getInitialData(), init);
3629
- const [formErrors, setFormErrors] = h(state2.errors);
3630
- const mergeAsyncErrorsState = T$1((staticValidationErrors, asyncValidationErrors) => {
3631
- if (!state2.schema.length)
3632
- return staticValidationErrors;
3633
- return state2.schema.reduce((acc, field) => {
3634
- var _a;
3635
- return {
3636
- ...acc,
3637
- [field]: staticValidationErrors[field] ?? ((_a = asyncValidationErrors[field]) == null ? void 0 : _a.getError()) ?? null
3638
- };
3639
- }, {});
3640
- }, [state2.schema]);
3641
3673
  const isValid = F$1(() => {
3642
3674
  var _a;
3643
- return (_a = state2.schema) == null ? void 0 : _a.some((key) => !!state2.valid[key]);
3675
+ return (_a = state2.schema) == null ? void 0 : _a.every((key) => state2.valid[key]);
3644
3676
  }, [state2.schema, state2.valid]);
3645
3677
  const getTargetValue = T$1((key, e2) => {
3646
3678
  if (!(e2 == null ? void 0 : e2.target))
@@ -3713,9 +3745,7 @@ function useForm({
3713
3745
  setFieldProblems(fieldProblems);
3714
3746
  }
3715
3747
  }, [JSON.stringify(fieldProblems), setFieldProblems]);
3716
- p(() => {
3717
- setFormErrors(mergeAsyncErrorsState(state2.errors, asyncValidationResults));
3718
- }, [mergeAsyncErrorsState, asyncValidationResults, state2.errors]);
3748
+ const formErrors = F$1(() => mergeStaticAndAsyncErrorsState(state2.errors, asyncValidationResults, state2.schema), [asyncValidationResults, state2.errors]);
3719
3749
  return {
3720
3750
  mergeForm,
3721
3751
  setData,
@@ -4509,7 +4539,7 @@ const lengthValidationPatterns = {
4509
4539
  message: "validationEnter9Or12Digits"
4510
4540
  }
4511
4541
  };
4512
- const bankStatementDescriptionPattern = /^[\s+$\xA2-\xA5\u058F\u060B\u09F2\u09F3\u09FB\u0AF1\u0BF9\u0E3F\u17DB\u20A0-\u20BD\uA838\uFDFC\uFE69\uFF04\uFFE0\uFFE1\uFFE5\uFFE6a-zA-Z0-9-."_,:;'*!@#%()+?¿/&「」]*$/;
4542
+ const bankStatementDescriptionPattern = /^[$\xA2-\xA5\u058F\u060B\u09F2\u09F3\u09FB\u0AF1\u0BF9\u0E3F\u17DB\u20A0-\u20BD\uA838\uFDFC\uFE69\uFF04\uFFE0\uFFE1\uFFE5\uFFE6a-zA-Z0-9-."_,:;'*!@#%()+?¿/&「」]*$/;
4513
4543
  const businessRegistrationNumberPatterns = {
4514
4544
  [CountryCodes.Australia]: {
4515
4545
  default: {
@@ -5721,6 +5751,13 @@ const countryBasedValidatorRules$1 = {
5721
5751
  validate: (taxId2) => validateTaxId(taxId2, "SG"),
5722
5752
  errorMessage: "aValidUenOrGstShouldBe9To10Characters"
5723
5753
  }]
5754
+ },
5755
+ HK: {
5756
+ taxId: [{
5757
+ modes: ["blur"],
5758
+ validate: (taxId2) => validateTaxId(taxId2, "HK"),
5759
+ errorMessage: "aValidBrnShouldBe8Digits"
5760
+ }]
5724
5761
  }
5725
5762
  };
5726
5763
  const taxIdFields = ["taxId", "exemptedFromTax"];
@@ -7655,7 +7692,7 @@ function CompanyDetailsComponent(props) {
7655
7692
  ...taxIdProps,
7656
7693
  dataStoreId: COMPANY_DETAILS,
7657
7694
  country: props.country
7658
- }), props.country === "SG" && formUtils.isRequiredField("dateOfIncorporation") && o(Field, {
7695
+ }), formUtils.isRequiredField("dateOfIncorporation") && o(Field, {
7659
7696
  name: "dateOfIncorporation",
7660
7697
  label: formUtils.getLabel("dateOfIncorporation"),
7661
7698
  classNameModifiers: ["dateOfIncorporation"],
@@ -8438,10 +8475,10 @@ const countryConfig$4 = {
8438
8475
  label: "businessName"
8439
8476
  },
8440
8477
  registrationNumber: {
8441
- label: "companyNumber"
8478
+ label: "companyRegistrationNumber__HK"
8442
8479
  },
8443
8480
  taxId: {
8444
- label: "businessRegistrationNumber"
8481
+ label: "businessRegistrationNumber__HK"
8445
8482
  }
8446
8483
  },
8447
8484
  [CountryCodes.Hungary]: {
@@ -8799,7 +8836,7 @@ var TrustMemberTypes = /* @__PURE__ */ ((TrustMemberTypes2) => {
8799
8836
  TrustMemberTypes2["DEFINED_BENEFICIARY"] = "definedBeneficiary";
8800
8837
  TrustMemberTypes2["UNDEFINED_BENEFICIARY"] = "undefinedBeneficiary";
8801
8838
  TrustMemberTypes2["PROTECTOR"] = "protector";
8802
- TrustMemberTypes2["TRUSTEE"] = "trustee";
8839
+ TrustMemberTypes2["TRUSTEE"] = "secondaryTrustee";
8803
8840
  TrustMemberTypes2["SETTLOR"] = "settlor";
8804
8841
  return TrustMemberTypes2;
8805
8842
  })(TrustMemberTypes || {});
@@ -8935,7 +8972,7 @@ var TaskStatus = /* @__PURE__ */ ((TaskStatus2) => {
8935
8972
  const SOLE_PROP_COUNTRIES = [CountryCodes.Austria, CountryCodes.Australia, CountryCodes.Belgium, CountryCodes.Bulgaria, CountryCodes.Canada, CountryCodes.Croatia, CountryCodes.Cyprus, CountryCodes.CzechRepublic, CountryCodes.Denmark, CountryCodes.Estonia, CountryCodes.Finland, CountryCodes.France, CountryCodes.Germany, CountryCodes.Gibraltar, CountryCodes.Greece, CountryCodes.Guernsey, CountryCodes.Hungary, CountryCodes.Ireland, CountryCodes.IsleOfMan, CountryCodes.Italy, CountryCodes.Jersey, CountryCodes.Latvia, CountryCodes.Liechtenstein, CountryCodes.Lithuania, CountryCodes.Luxembourg, CountryCodes.Malta, CountryCodes.Monaco, CountryCodes.Netherlands, CountryCodes.Norway, CountryCodes.Poland, CountryCodes.Portugal, CountryCodes.PuertoRico, CountryCodes.Romania, CountryCodes.Singapore, CountryCodes.Slovakia, CountryCodes.Slovenia, CountryCodes.Spain, CountryCodes.Sweden, CountryCodes.Switzerland, CountryCodes.UnitedKingdom, CountryCodes.UnitedStates];
8936
8973
  const ID_NUMBER_EXEMPT_COUNTRIES = [CountryCodes.Canada, CountryCodes.UnitedStates];
8937
8974
  const ID_NUMBER_VERIFICATION_COUNTRIES = [CountryCodes.UnitedStates];
8938
- const COUNTRIES_WHICH_USE_MULTIPLE_IDENTITY_TYPES = [CountryCodes.Australia];
8975
+ const COUNTRIES_WHICH_USE_MULTIPLE_IDENTITY_TYPES = [CountryCodes.HongKong, CountryCodes.Australia];
8939
8976
  const ID_NUMBER_REQUIRED_FOR_DIRECTOR_COUNTRIES = [CountryCodes.Singapore];
8940
8977
  const NATIONALITY_REQUIRED_FOR_COUNTRIES = [CountryCodes.Singapore];
8941
8978
  const rules$2 = ({
@@ -9997,6 +10034,7 @@ const ADDRESS_SCHEMAS = {
9997
10034
  [CountryCodes.Canada]: [COUNTRY, STREET, HOUSE_NUMBER, CITY, POSTAL_CODE, STATE],
9998
10035
  [CountryCodes.UnitedKingdom]: [COUNTRY, HOUSE_NUMBER, STREET, CITY, POSTAL_CODE, STATE],
9999
10036
  [CountryCodes.UnitedStates]: [COUNTRY, STREET, HOUSE_NUMBER, CITY, STATE, POSTAL_CODE],
10037
+ [CountryCodes.HongKong]: [COUNTRY, STREET, HOUSE_NUMBER, CITY, STATE],
10000
10038
  default: [COUNTRY, STREET, HOUSE_NUMBER, POSTAL_CODE, CITY, STATE]
10001
10039
  };
10002
10040
  const LABELS = {
@@ -10602,156 +10640,103 @@ const countrySpecificFormatters = {
10602
10640
  postalCode: createFormatByDigits(5)
10603
10641
  }
10604
10642
  };
10605
- const createPatternByDigits = (digits) => ({
10606
- pattern: new RegExp(`\\d{${digits}}`)
10607
- });
10643
+ const createPatternByDigits = (digits) => new RegExp(`\\d{${digits}}`);
10608
10644
  const postalCodePatterns = {
10609
10645
  [CountryCodes.Australia]: createPatternByDigits(4),
10610
10646
  [CountryCodes.Austria]: createPatternByDigits(4),
10611
- [CountryCodes.Belgium]: {
10612
- pattern: /(?:(?:[1-9])(?:\d{3}))/
10613
- },
10647
+ [CountryCodes.Belgium]: /[1-9]\d{3}/,
10614
10648
  [CountryCodes.Brazil]: createPatternByDigits(8),
10615
10649
  [CountryCodes.Bulgaria]: createPatternByDigits(4),
10616
- [CountryCodes.Canada]: {
10617
- pattern: /(?:[ABCEGHJ-NPRSTVXY]\d[A-Z][ -]?\d[A-Z]\d)/
10618
- },
10619
- [CountryCodes.Croatia]: {
10620
- pattern: /^([1-5])[0-9]{4}$/
10621
- },
10650
+ [CountryCodes.Canada]: /[ABCEGHJ-NPRSTVXY]\d[A-Z][ -]?\d[A-Z]\d/,
10651
+ [CountryCodes.Croatia]: /^([1-5])[0-9]{4}$/,
10622
10652
  [CountryCodes.Cyprus]: createPatternByDigits(4),
10623
- [CountryCodes.CzechRepublic]: {
10624
- pattern: /\d{3}\s?\d{2}/
10625
- },
10626
- [CountryCodes.Denmark]: {
10627
- pattern: /^(DK-)?[0-9]{4}$/
10628
- },
10653
+ [CountryCodes.CzechRepublic]: /\d{3}\s?\d{2}/,
10654
+ [CountryCodes.Denmark]: /^(DK-)?[0-9]{4}$/,
10629
10655
  [CountryCodes.Estonia]: createPatternByDigits(5),
10630
10656
  [CountryCodes.Finland]: createPatternByDigits(5),
10631
10657
  [CountryCodes.France]: createPatternByDigits(5),
10632
10658
  [CountryCodes.Georgia]: createPatternByDigits(4),
10633
10659
  [CountryCodes.Germany]: createPatternByDigits(5),
10634
- [CountryCodes.Gibraltar]: {
10635
- pattern: /^GX11[ -]?1AA$/
10636
- },
10637
- [CountryCodes.Greece]: {
10638
- pattern: /^\d{3}\s{0,1}\d{2}$/
10639
- },
10660
+ [CountryCodes.Gibraltar]: /^GX11[ -]?1AA$/,
10661
+ [CountryCodes.Greece]: /^\d{3}\s?\d{2}$/,
10640
10662
  [CountryCodes.Hungary]: createPatternByDigits(4),
10641
10663
  [CountryCodes.Iceland]: createPatternByDigits(3),
10642
- [CountryCodes.Ireland]: {
10643
- pattern: /(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ -]?[0-9AC-FHKNPRTV-Y]{4}/
10644
- },
10664
+ [CountryCodes.Ireland]: /(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ -]?[0-9AC-FHKNPRTV-Y]{4}/,
10645
10665
  [CountryCodes.Italy]: createPatternByDigits(5),
10646
- [CountryCodes.Japan]: {
10647
- pattern: /^\d{3}[-]\d{4}$/
10648
- },
10649
- [CountryCodes.Latvia]: {
10650
- pattern: /^(LV-)?[0-9]{4}$/
10651
- },
10666
+ [CountryCodes.Japan]: /^\d{3}-\d{4}$/,
10667
+ [CountryCodes.Latvia]: /^(LV-)?[0-9]{4}$/,
10652
10668
  [CountryCodes.Liechtenstein]: createPatternByDigits(4),
10653
- [CountryCodes.Lithuania]: {
10654
- pattern: /^(LT-)?[0-9]{4,5}$/
10655
- },
10669
+ [CountryCodes.Lithuania]: /^(LT-)?[0-9]{4,5}$/,
10656
10670
  [CountryCodes.Luxembourg]: createPatternByDigits(4),
10657
10671
  [CountryCodes.Malaysia]: createPatternByDigits(5),
10658
- [CountryCodes.Malta]: {
10659
- pattern: /^[A-Za-z]{2,3}[ ]?\d{2}(?:\d{2})?$/
10660
- },
10661
- [CountryCodes.Monaco]: {
10662
- pattern: /^980\d{2}$/
10663
- },
10664
- [CountryCodes.Netherlands]: {
10665
- pattern: /(?:NL-)?(?:[1-9]\d{3} ?(?:[A-EGHJ-NPRTVWXZ][A-EGHJ-NPRSTVWXZ]|S[BCEGHJ-NPRTVWXZ]))/
10666
- },
10672
+ [CountryCodes.Malta]: /^[A-Za-z]{2,3} ?\d{2}(?:\d{2})?$/,
10673
+ [CountryCodes.Monaco]: /^980\d{2}$/,
10674
+ [CountryCodes.Netherlands]: /(?:NL-)?[1-9]\d{3} ?(?:[A-EGHJ-NPRTVWXZ][A-EGHJ-NPRSTVWXZ]|S[BCEGHJ-NPRTVWXZ])/,
10667
10675
  [CountryCodes.NewZealand]: createPatternByDigits(4),
10668
10676
  [CountryCodes.Norway]: createPatternByDigits(4),
10669
- [CountryCodes.Poland]: {
10670
- pattern: /^\d{2}[-]\d{3}$/
10671
- },
10672
- [CountryCodes.Portugal]: {
10673
- pattern: /^([1-9]\d{3})([- ]?(\d{3})? *)$/
10674
- },
10677
+ [CountryCodes.Poland]: /^\d{2}-\d{3}$/,
10678
+ [CountryCodes.Portugal]: /^([1-9]\d{3})([- ]?(\d{3})? *)$/,
10675
10679
  [CountryCodes.PuertoRico]: createPatternByDigits(5),
10676
10680
  [CountryCodes.Romania]: createPatternByDigits(6),
10677
- [CountryCodes.Slovakia]: {
10678
- pattern: /^(SK-)?[0-9]{5}$/
10679
- },
10680
- [CountryCodes.Slovenia]: {
10681
- pattern: /^(SI-)?[0-9]{4}$/
10682
- },
10681
+ [CountryCodes.Slovakia]: /^(SK-)?[0-9]{5}$/,
10682
+ [CountryCodes.Slovenia]: /^(SI-)?[0-9]{4}$/,
10683
10683
  [CountryCodes.Singapore]: createPatternByDigits(6),
10684
- [CountryCodes.Spain]: {
10685
- pattern: /(?:0[1-9]|[1-4]\d|5[0-2])\d{3}/
10686
- },
10684
+ [CountryCodes.Spain]: /(?:0[1-9]|[1-4]\d|5[0-2])\d{3}/,
10687
10685
  [CountryCodes.Sweden]: createPatternByDigits(5),
10688
- [CountryCodes.Switzerland]: {
10689
- pattern: /[1-9]\d{3}/
10690
- },
10691
- [CountryCodes.UnitedKingdom]: {
10692
- pattern: /^([A-Za-z][A-Ha-hK-Yk-y]?[0-9][A-Za-z0-9]? ?[0-9][A-Za-z]{2}|[Gg][Ii][Rr] ?0[Aa]{2})$/
10693
- },
10694
- [CountryCodes.UnitedStates]: {
10695
- pattern: /^(\d{5})([-]?(\d{4})? *)$/
10696
- }
10686
+ [CountryCodes.Switzerland]: /[1-9]\d{3}/,
10687
+ [CountryCodes.UnitedKingdom]: /^([A-Za-z][A-Ha-hK-Yk-y]?[0-9][A-Za-z0-9]? ?[0-9][A-Za-z]{2}|[Gg][Ii][Rr] ?0[Aa]{2})$/,
10688
+ [CountryCodes.UnitedStates]: /^(\d{5})(-?(\d{4})? *)$/
10697
10689
  };
10698
- const addressValidationRules = {
10699
- street: {
10700
- modes: ["blur"],
10701
- validate: (val) => hasText(val),
10702
- errorMessage: "fieldIsRequired"
10703
- },
10704
- houseNumberOrName: {
10705
- modes: ["blur"],
10706
- validate: (val, context) => {
10707
- const {
10708
- country: country2
10709
- } = context.state.data;
10710
- if (country2 && COUNTRIES_WITH_OPTIONAL_HOUSE_NUMBER.includes(country2)) {
10711
- return true;
10712
- }
10713
- return hasText(val);
10690
+ const addressValidationRules = (country2) => {
10691
+ var _a, _b;
10692
+ const postalCodeFormat = (_b = (_a = countrySpecificFormatters[country2]) == null ? void 0 : _a.postalCode) == null ? void 0 : _b.format;
10693
+ return {
10694
+ street: {
10695
+ modes: ["blur"],
10696
+ validate: (val) => hasText(val),
10697
+ errorMessage: "fieldIsRequired"
10714
10698
  },
10715
- errorMessage: "fieldIsRequired"
10716
- },
10717
- postalCode: {
10718
- modes: ["blur"],
10719
- validate: (val, context) => {
10720
- var _a, _b;
10721
- const {
10722
- country: country2
10723
- } = context.state.data;
10724
- if (country2) {
10725
- addressValidationRules.postalCode.errorMessage = {
10726
- translationKey: "invalidFormatExpects",
10727
- translationObject: {
10728
- values: {
10729
- format: ((_a = countrySpecificFormatters[country2]) == null ? void 0 : _a.postalCode.format) || null
10730
- }
10699
+ houseNumberOrName: {
10700
+ modes: ["blur"],
10701
+ validate: (val) => {
10702
+ if (country2 && COUNTRIES_WITH_OPTIONAL_HOUSE_NUMBER.includes(country2)) {
10703
+ return true;
10704
+ }
10705
+ return hasText(val);
10706
+ },
10707
+ errorMessage: "fieldIsRequired"
10708
+ },
10709
+ postalCode: {
10710
+ modes: ["blur"],
10711
+ validate: (val) => {
10712
+ const pattern = postalCodePatterns[country2];
10713
+ return pattern ? !!val && pattern.test(val) : !!val;
10714
+ },
10715
+ errorMessage: postalCodeFormat ? {
10716
+ translationKey: "invalidFormatExpects",
10717
+ translationObject: {
10718
+ values: {
10719
+ format: postalCodeFormat
10731
10720
  }
10732
- };
10733
- const pattern = (_b = postalCodePatterns[country2]) == null ? void 0 : _b.pattern;
10734
- return pattern ? pattern.test(val) : !!val;
10735
- }
10736
- return !!val;
10721
+ }
10722
+ } : "invalidFormat"
10737
10723
  },
10738
- errorMessage: "fieldIsRequired"
10739
- },
10740
- city: {
10741
- modes: ["blur"],
10742
- validate: hasText,
10743
- errorMessage: "fieldIsRequired"
10744
- },
10745
- stateOrProvince: {
10746
- modes: ["blur"],
10747
- validate: (val) => !!val,
10748
- errorMessage: "fieldIsRequired"
10749
- },
10750
- country: {
10751
- modes: ["blur"],
10752
- validate: (val) => !!val,
10753
- errorMessage: "fieldIsRequired"
10754
- }
10724
+ city: {
10725
+ modes: ["blur"],
10726
+ validate: hasText,
10727
+ errorMessage: "fieldIsRequired"
10728
+ },
10729
+ stateOrProvince: {
10730
+ modes: ["blur"],
10731
+ validate: (val) => !!val,
10732
+ errorMessage: "fieldIsRequired"
10733
+ },
10734
+ country: {
10735
+ modes: ["blur"],
10736
+ validate: (val) => !!val,
10737
+ errorMessage: "fieldIsRequired"
10738
+ }
10739
+ };
10755
10740
  };
10756
10741
  function Address(props) {
10757
10742
  const {
@@ -10782,6 +10767,7 @@ function Address(props) {
10782
10767
  const addressFields = ADDRESS_SCHEMAS[dataProp == null ? void 0 : dataProp.country] ?? ADDRESS_SCHEMAS.default;
10783
10768
  const datasetUtils = datasetUtilities(i18n.locale);
10784
10769
  const requiredFields = (requiredFieldsProp == null ? void 0 : requiredFieldsProp.includes("stateOrProvince")) || dataProp.country && COUNTRIES_WITH_STATES_DATASET.includes(dataProp.country) ? addressFields : addressFields.filter((ad) => ad !== "stateOrProvince");
10770
+ const rules2 = F$1(() => addressValidationRules(dataProp.country), [dataProp.country]);
10785
10771
  const {
10786
10772
  data,
10787
10773
  errors,
@@ -10796,7 +10782,7 @@ function Address(props) {
10796
10782
  schema: requiredFields,
10797
10783
  defaultData: dataProp,
10798
10784
  formatters: addressFormatters,
10799
- rules: addressValidationRules,
10785
+ rules: rules2,
10800
10786
  fieldProblems: fieldValidationErrorsProp,
10801
10787
  maskedFields: []
10802
10788
  });
@@ -10823,11 +10809,6 @@ function Address(props) {
10823
10809
  setShowAddAddressButton(false);
10824
10810
  }
10825
10811
  }, []);
10826
- p(() => {
10827
- if (data.postalCode) {
10828
- handleChangeFor("postalCode", "blur")(data.postalCode);
10829
- }
10830
- }, [data.country]);
10831
10812
  p(() => {
10832
10813
  const processedData = ADDRESS_SCHEMA.reduce((acc, cur) => {
10833
10814
  if (!formUtils.isRequiredField(cur)) {
@@ -11542,7 +11523,7 @@ const COUNTRIES_WITH_POSSIBLE_TAX_EXEMPTION_FOR_SOLE_PROPS = [
11542
11523
  CountryCodes.Canada,
11543
11524
  CountryCodes.UnitedStates
11544
11525
  ];
11545
- const COUNTRIES_THAT_REQUIRE_DATE_OF_INCORPORATION = [CountryCodes.Singapore];
11526
+ const COUNTRIES_THAT_REQUIRE_DATE_OF_INCORPORATION = [CountryCodes.HongKong, CountryCodes.Singapore];
11546
11527
  const rules$1 = ({
11547
11528
  data,
11548
11529
  country: country2,
@@ -11834,21 +11815,6 @@ const getOwnTrustMembers = (trustEntity) => {
11834
11815
  return [];
11835
11816
  return trustEntity.entityAssociations.filter((entityAssociation) => Object.values(TrustMemberTypes).includes(entityAssociation.type) && entityAssociation.associatorId === trustEntity.id);
11836
11817
  };
11837
- const getRootTrusteeInfo = (rootLegalEntity) => ({
11838
- id: rootLegalEntity.id,
11839
- type: TrustMemberTypes.TRUSTEE
11840
- });
11841
- const getUndefinedBeneficiaries = (legalEntity) => {
11842
- var _a;
11843
- return ((_a = legalEntity.trust) == null ? void 0 : _a.undefinedBeneficiaryInfo) || [];
11844
- };
11845
- const getAllTrustMembers = (rootLegalEntity, trustEntity) => [getRootTrusteeInfo(rootLegalEntity), ...getOwnTrustMembers(trustEntity).map((association) => ({
11846
- id: association.legalEntityId || "",
11847
- type: association.type
11848
- })), ...getUndefinedBeneficiaries(trustEntity).map((undefinedBeneficiaryInfo) => ({
11849
- id: undefinedBeneficiaryInfo.reference,
11850
- type: TrustMemberTypes.UNDEFINED_BENEFICIARY
11851
- }))];
11852
11818
  const getOwnTrustMembersLegalEntityIds = (legalEntity) => getOwnTrustMembers(legalEntity).map((ea) => ea.legalEntityId).filter((id2) => id2 !== void 0);
11853
11819
  const getOwnTrustLegalEntityId = (legalEntity) => {
11854
11820
  var _a, _b;
@@ -12136,7 +12102,7 @@ function formatSwedenPersonnummer(value) {
12136
12102
  }
12137
12103
  const formattedCountries = [CountryCodes.Denmark, CountryCodes.Sweden];
12138
12104
  const stripCountryIdFormat = (value, country2) => {
12139
- if (value && formattedCountries.includes(country2)) {
12105
+ if (formattedCountries.includes(country2)) {
12140
12106
  return cleanNonNumbers(value);
12141
12107
  }
12142
12108
  return value;
@@ -14228,7 +14194,7 @@ ContactDetailsComponent.defaultProps = {
14228
14194
  data: {}
14229
14195
  };
14230
14196
  const additionalIdentityInfoFields = ["typeOfIdentity", "licenseCardNumber", "issuerState"];
14231
- const identityTypes = ["nationalIdNumber", "passport", "driversLicense", "proofOfIdentityCard"];
14197
+ const identityTypes$1 = ["nationalIdNumber", "passport", "driversLicense", "proofOfIdentityCard"];
14232
14198
  function useGlobalData() {
14233
14199
  const {
14234
14200
  getData
@@ -14267,25 +14233,25 @@ function useResetGlobalData(caller) {
14267
14233
  }
14268
14234
  }), [dispatch, caller]);
14269
14235
  }
14270
- const isTruthyValidator = {
14236
+ const isTruthyValidator$1 = {
14271
14237
  validate: (value) => !!value,
14272
14238
  modes: ["blur"],
14273
14239
  errorMessage: "fieldIsRequired"
14274
14240
  };
14275
- const PASSPORT_NUMBER_PATTERN = /^[A-Z]{1,2}\d{7}$/;
14276
- const DRIVERS_LICENSE_NUMBER_PATTERN = /^[A-Za-z\d]{6,11}$/;
14277
- const PROOF_OF_IDENTITY_CARD_NUMBER_PATTERN = /^[A-Za-z\d]{6,10}$/;
14241
+ const PASSPORT_NUMBER_PATTERN$1 = /^[A-Z]{1,2}\d{7}$/;
14242
+ const DRIVERS_LICENSE_NUMBER_PATTERN$1 = /^[A-Za-z\d]{6,11}$/;
14243
+ const PROOF_OF_IDENTITY_CARD_NUMBER_PATTERN$1 = /^[A-Za-z\d]{6,10}$/;
14278
14244
  const auIdentityValidationRules = {
14279
- typeOfIdentity: [isTruthyValidator],
14245
+ typeOfIdentity: [isTruthyValidator$1],
14280
14246
  idNumber: [{
14281
14247
  validate: (value, context) => {
14282
14248
  switch (context.state.data.typeOfIdentity) {
14283
14249
  case "passport":
14284
- return PASSPORT_NUMBER_PATTERN.test(value);
14250
+ return PASSPORT_NUMBER_PATTERN$1.test(value);
14285
14251
  case "driversLicense":
14286
- return DRIVERS_LICENSE_NUMBER_PATTERN.test(value);
14252
+ return DRIVERS_LICENSE_NUMBER_PATTERN$1.test(value);
14287
14253
  case "proofOfIdentityCard":
14288
- return PROOF_OF_IDENTITY_CARD_NUMBER_PATTERN.test(value);
14254
+ return PROOF_OF_IDENTITY_CARD_NUMBER_PATTERN$1.test(value);
14289
14255
  }
14290
14256
  },
14291
14257
  errorMessage: (value, context) => {
@@ -14301,13 +14267,13 @@ const auIdentityValidationRules = {
14301
14267
  modes: ["blur"]
14302
14268
  }],
14303
14269
  licenseCardNumber: [{
14304
- validate: (value) => DRIVERS_LICENSE_NUMBER_PATTERN.test(value),
14270
+ validate: (value) => DRIVERS_LICENSE_NUMBER_PATTERN$1.test(value),
14305
14271
  errorMessage: "invalidFormatForAuDriversLicenseCardNumber",
14306
14272
  modes: ["blur"]
14307
14273
  }],
14308
- issuerState: [isTruthyValidator]
14274
+ issuerState: [isTruthyValidator$1]
14309
14275
  };
14310
- const DriversLicense = ({
14276
+ const DriversLicense$1 = ({
14311
14277
  driversLicense: driversLicense2,
14312
14278
  onIssuerStateChange,
14313
14279
  onLicenseNumberInput,
@@ -14385,7 +14351,7 @@ const DriversLicense = ({
14385
14351
  })]
14386
14352
  });
14387
14353
  };
14388
- const PassportNumber = ({
14354
+ const PassportNumber$1 = ({
14389
14355
  passportNumber: passportNumber2,
14390
14356
  onInput,
14391
14357
  onBlur,
@@ -14408,7 +14374,7 @@ const PassportNumber = ({
14408
14374
  placeholder: ""
14409
14375
  })
14410
14376
  });
14411
- const ProofOfIdentityCard = ({
14377
+ const ProofOfIdentityCard$1 = ({
14412
14378
  cardNumber,
14413
14379
  onInput,
14414
14380
  onBlur,
@@ -14431,11 +14397,11 @@ const ProofOfIdentityCard = ({
14431
14397
  placeholder: ""
14432
14398
  })
14433
14399
  });
14434
- const mapIdentityTypeToItem = (type, label) => ({
14400
+ const mapIdentityTypeToItem$1 = (type, label) => ({
14435
14401
  id: type,
14436
14402
  name: label
14437
14403
  });
14438
- const TypeOfIdentity = ({
14404
+ const TypeOfIdentity$1 = ({
14439
14405
  availableIdentityTypes,
14440
14406
  selectedIdentityType,
14441
14407
  setSelectedIdentityType,
@@ -14457,7 +14423,7 @@ const TypeOfIdentity = ({
14457
14423
  children: (childProps) => o(Select, {
14458
14424
  ...childProps,
14459
14425
  isInvalid: false,
14460
- items: availableIdentityTypes.map((type) => mapIdentityTypeToItem(type, i18n.get(type))),
14426
+ items: availableIdentityTypes.map((type) => mapIdentityTypeToItem$1(type, i18n.get(type))),
14461
14427
  placeholder: i18n.get("id"),
14462
14428
  selected: selectedIdentityType,
14463
14429
  onChange: (event) => setSelectedIdentityType(event.target.value)
@@ -14485,7 +14451,6 @@ function IdentityAuComponent(props) {
14485
14451
  maskedFields: props.maskedFields
14486
14452
  });
14487
14453
  p(() => {
14488
- console.log("triggerValidation");
14489
14454
  if (data.typeOfIdentity)
14490
14455
  triggerValidation(["idNumber"]);
14491
14456
  }, [data.typeOfIdentity]);
@@ -14507,28 +14472,28 @@ function IdentityAuComponent(props) {
14507
14472
  } = useCoreContext();
14508
14473
  const formUtils = formUtilities(props, i18n);
14509
14474
  return o(Fragment, {
14510
- children: [o(TypeOfIdentity, {
14511
- availableIdentityTypes: identityTypes.filter((type) => type !== "nationalIdNumber"),
14475
+ children: [o(TypeOfIdentity$1, {
14476
+ availableIdentityTypes: identityTypes$1.filter((type) => type !== "nationalIdNumber"),
14512
14477
  selectedIdentityType: data.typeOfIdentity,
14513
14478
  setSelectedIdentityType: handleChangeFor("typeOfIdentity"),
14514
14479
  formUtils,
14515
14480
  isValid: valid.typeOfIdentity,
14516
14481
  errorMessage: formUtils.getErrorMessage("typeOfIdentity", errors, fieldProblems)
14517
- }), data.typeOfIdentity === "passport" ? o(PassportNumber, {
14482
+ }), data.typeOfIdentity === "passport" ? o(PassportNumber$1, {
14518
14483
  passportNumber: data.idNumber,
14519
14484
  onInput: handleChangeFor("idNumber", "input"),
14520
14485
  onBlur: handleChangeFor("idNumber", "blur"),
14521
14486
  formUtils,
14522
14487
  isValid: valid.idNumber,
14523
14488
  errorMessage: formUtils.getErrorMessage("idNumber", errors, fieldProblems)
14524
- }) : data.typeOfIdentity === "proofOfIdentityCard" ? o(ProofOfIdentityCard, {
14489
+ }) : data.typeOfIdentity === "proofOfIdentityCard" ? o(ProofOfIdentityCard$1, {
14525
14490
  cardNumber: data.idNumber,
14526
14491
  onInput: handleChangeFor("idNumber", "input"),
14527
14492
  onBlur: handleChangeFor("idNumber", "blur"),
14528
14493
  formUtils,
14529
14494
  isValid: valid.idNumber,
14530
14495
  errorMessage: formUtils.getErrorMessage("idNumber", errors, fieldProblems)
14531
- }) : data.typeOfIdentity === "driversLicense" ? o(DriversLicense, {
14496
+ }) : data.typeOfIdentity === "driversLicense" ? o(DriversLicense$1, {
14532
14497
  driversLicense: data,
14533
14498
  onIssuerStateChange: handleChangeFor("issuerState"),
14534
14499
  onLicenseNumberInput: handleChangeFor("idNumber", "input"),
@@ -14550,109 +14515,353 @@ function IdentityAuComponent(props) {
14550
14515
  });
14551
14516
  }
14552
14517
  const auIdentityFields = [...additionalIdentityInfoFields, "idNumber"];
14553
- const IdentityNumber$1 = "";
14554
- function validCheckCharacter(input, calculationInput) {
14555
- if (!/^[A-Z]$/.test(input)) {
14556
- return false;
14557
- }
14558
- const CHECKCHARACTER_ODD_VALUE = {
14559
- 0: 1,
14560
- 9: 21,
14561
- I: 19,
14562
- R: 8,
14563
- 1: 0,
14564
- A: 1,
14565
- J: 21,
14566
- S: 12,
14567
- 2: 5,
14568
- B: 0,
14569
- K: 2,
14570
- T: 14,
14571
- 3: 7,
14572
- C: 5,
14573
- L: 4,
14574
- U: 16,
14575
- 4: 9,
14576
- D: 7,
14577
- M: 18,
14578
- V: 10,
14579
- 5: 13,
14580
- E: 9,
14581
- N: 20,
14582
- W: 22,
14583
- 6: 15,
14584
- F: 13,
14585
- O: 11,
14586
- X: 25,
14587
- 7: 17,
14588
- G: 15,
14589
- P: 3,
14590
- Y: 24,
14591
- 8: 19,
14592
- H: 17,
14593
- Q: 6,
14594
- Z: 23
14595
- };
14596
- const CHECKCHARACTER_EVEN_VALUE = {
14597
- 0: 0,
14598
- 9: 9,
14599
- I: 8,
14600
- R: 17,
14601
- 1: 1,
14602
- A: 0,
14603
- J: 9,
14604
- S: 18,
14605
- 2: 2,
14606
- B: 1,
14607
- K: 10,
14608
- T: 19,
14609
- 3: 3,
14610
- C: 2,
14611
- L: 11,
14612
- U: 20,
14613
- 4: 4,
14614
- D: 3,
14615
- M: 12,
14616
- V: 21,
14617
- 5: 5,
14618
- E: 4,
14619
- N: 13,
14620
- W: 22,
14621
- 6: 6,
14622
- F: 5,
14623
- O: 14,
14624
- X: 23,
14625
- 7: 7,
14626
- G: 6,
14627
- P: 15,
14628
- Y: 24,
14629
- 8: 8,
14630
- H: 7,
14631
- Q: 16,
14632
- Z: 25
14633
- };
14634
- let total = 0;
14635
- for (let i2 = 0; i2 < 15; i2 += 1) {
14636
- const set = i2 % 2 === 1 ? CHECKCHARACTER_EVEN_VALUE : CHECKCHARACTER_ODD_VALUE;
14637
- const token = calculationInput.substring(i2, i2 + 1);
14638
- const value = set[token];
14639
- if (value == null) {
14640
- return true;
14641
- }
14642
- total = (total + value) % 26;
14643
- }
14644
- if (total >= 0 && total <= 26 && "ABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(total) === input) {
14645
- return true;
14646
- }
14647
- return false;
14648
- }
14649
- const helper = {
14650
- validCheckCharacter
14518
+ const identityTypes = ["nationalIdNumber", "passport", "driversLicense", "proofOfIdentityCard"];
14519
+ const PASSPORT_NUMBER_PATTERN = /^(?=.{9}$)[A-Z]{1,2}\d{6}[A-Z0-9]{1,2}$/;
14520
+ const DRIVERS_LICENSE_NUMBER_PATTERN = /^[A-Z]{1}[A-Z0-9]{7}$/;
14521
+ const PROOF_OF_IDENTITY_CARD_NUMBER_PATTERN = /^[A-Z]{1,2}[0-9]{6}[0-9A]$/;
14522
+ const isValidatePassportNumber = (value) => PASSPORT_NUMBER_PATTERN.test(value);
14523
+ const isTruthyValidator = {
14524
+ validate: (value) => !!value,
14525
+ modes: ["blur"],
14526
+ errorMessage: "fieldIsRequired"
14651
14527
  };
14652
- const countryIdNumberFormatters = {
14653
- [CountryCodes.Brazil]: {
14654
- idNumber: {
14655
- formatter: formatBrazilSSN,
14528
+ const identityValidationRules = {
14529
+ typeOfIdentity: [isTruthyValidator],
14530
+ idNumber: [{
14531
+ validate: (val, context) => {
14532
+ const value = val ?? "";
14533
+ switch (context == null ? void 0 : context.state.data.typeOfIdentity) {
14534
+ case "passport":
14535
+ return isValidatePassportNumber(value);
14536
+ case "driversLicense":
14537
+ return DRIVERS_LICENSE_NUMBER_PATTERN.test(value);
14538
+ case "proofOfIdentityCard":
14539
+ return PROOF_OF_IDENTITY_CARD_NUMBER_PATTERN.test(value);
14540
+ default:
14541
+ return false;
14542
+ }
14543
+ },
14544
+ errorMessage: (_2, context) => {
14545
+ switch (context == null ? void 0 : context.state.data.typeOfIdentity) {
14546
+ case "passport":
14547
+ return "invalidFormatForHKPassportNumber";
14548
+ case "driversLicense":
14549
+ return "invalidFormatForHKDriversLicenseNumber";
14550
+ case "proofOfIdentityCard":
14551
+ return "invalidFormatForHKIdentityCardNumber";
14552
+ }
14553
+ },
14554
+ modes: ["blur"]
14555
+ }],
14556
+ licenseCardNumber: [{
14557
+ validate: (value) => DRIVERS_LICENSE_NUMBER_PATTERN.test(value ?? ""),
14558
+ errorMessage: "invalidFormatForHKDriversLicenseNumber",
14559
+ modes: ["blur"]
14560
+ }],
14561
+ issuerState: [isTruthyValidator]
14562
+ };
14563
+ const DriversLicense = ({
14564
+ driversLicense: driversLicense2,
14565
+ onLicenseNumberInput,
14566
+ onLicenseNumberBlur,
14567
+ isValid,
14568
+ errorMessages,
14569
+ label
14570
+ }) => {
14571
+ const {
14572
+ i18n
14573
+ } = useCoreContext();
14574
+ return o(Fragment, {
14575
+ children: [o("div", {
14576
+ className: "adyen-kyc-field-wrapper",
14577
+ children: o(Field, {
14578
+ name: "licenseNumber",
14579
+ label,
14580
+ isValid: isValid.idNumber,
14581
+ errorMessage: errorMessages.idNumber,
14582
+ children: (childProps) => o(InputText, {
14583
+ ...childProps,
14584
+ name: "licenseNumber",
14585
+ value: driversLicense2.idNumber,
14586
+ onInput: onLicenseNumberInput,
14587
+ onBlur: onLicenseNumberBlur,
14588
+ placeholder: ""
14589
+ })
14590
+ })
14591
+ }), o(ContextGuidance, {
14592
+ page: "Personal details",
14593
+ title: i18n.get("whereCanIFindTheseNumbersOnMyDriversLicense"),
14594
+ content: o(Fragment, {
14595
+ children: [i18n.get("whereToFindNumbersOnDriversLicense"), " ", o("a", {
14596
+ href: "https://www.usi.gov.au/about/forms-id/drivers-licence",
14597
+ target: "_blank",
14598
+ rel: "noreferrer",
14599
+ children: i18n.get("iStillCantFindIt")
14600
+ })]
14601
+ }),
14602
+ titleId: "whereCanIFindTheseNumbersOnMyDriversLicense",
14603
+ contentId: "whereToFindNumbersOnDriversLicense"
14604
+ })]
14605
+ });
14606
+ };
14607
+ const PassportNumber = ({
14608
+ passportNumber: passportNumber2,
14609
+ onInput,
14610
+ onBlur,
14611
+ errorMessage,
14612
+ isValid,
14613
+ label
14614
+ }) => o(Field, {
14615
+ name: "passportNumber",
14616
+ label,
14617
+ errorMessage,
14618
+ isValid,
14619
+ children: (childProps) => o(InputText, {
14620
+ ...childProps,
14621
+ name: "passportNumber",
14622
+ value: passportNumber2,
14623
+ onInput,
14624
+ onBlur,
14625
+ placeholder: ""
14626
+ })
14627
+ });
14628
+ const ProofOfIdentityCard = ({
14629
+ cardNumber,
14630
+ onInput,
14631
+ onBlur,
14632
+ label,
14633
+ errorMessage,
14634
+ isValid
14635
+ }) => o(Field, {
14636
+ name: "cardNumber",
14637
+ label,
14638
+ errorMessage,
14639
+ isValid,
14640
+ children: (childProps) => o(InputText, {
14641
+ ...childProps,
14642
+ name: "cardNumber",
14643
+ value: cardNumber,
14644
+ onInput,
14645
+ onBlur,
14646
+ placeholder: ""
14647
+ })
14648
+ });
14649
+ const mapIdentityTypeToItem = (type, label) => ({
14650
+ id: type,
14651
+ name: label
14652
+ });
14653
+ const TypeOfIdentity = ({
14654
+ availableIdentityTypes,
14655
+ selectedIdentityType,
14656
+ setSelectedIdentityType,
14657
+ formUtils: {
14658
+ getLabel
14659
+ },
14660
+ errorMessage,
14661
+ isValid
14662
+ }) => {
14663
+ const {
14664
+ i18n
14665
+ } = useCoreContext();
14666
+ return o(Field, {
14667
+ name: "typeOfIdentity",
14668
+ label: getLabel("typeOfIdentity"),
14669
+ errorMessage,
14670
+ isValid,
14671
+ helper: i18n.get("typeOfIdentitySubtitle"),
14672
+ children: (childProps) => o(Select, {
14673
+ ...childProps,
14674
+ isInvalid: false,
14675
+ items: availableIdentityTypes.map((type) => mapIdentityTypeToItem(type, i18n.get(type))),
14676
+ placeholder: i18n.get("id"),
14677
+ selected: selectedIdentityType,
14678
+ onChange: (event) => setSelectedIdentityType(event.target.value)
14679
+ })
14680
+ });
14681
+ };
14682
+ function IdentityHKComponent(props) {
14683
+ var _a;
14684
+ if (((_a = props.data) == null ? void 0 : _a.typeOfIdentity) === "nationalIdNumber") {
14685
+ props.data.typeOfIdentity = void 0;
14686
+ }
14687
+ const {
14688
+ handleChangeFor,
14689
+ triggerValidation,
14690
+ data,
14691
+ errors,
14692
+ fieldProblems,
14693
+ valid
14694
+ } = useForm({
14695
+ ...props,
14696
+ schema: props.requiredFields ?? [],
14697
+ defaultData: props.data,
14698
+ fieldProblems: props.fieldValidationErrors,
14699
+ rules: identityValidationRules,
14700
+ maskedFields: props.maskedFields
14701
+ });
14702
+ p(() => {
14703
+ if (data.typeOfIdentity) {
14704
+ triggerValidation(["idNumber"]);
14705
+ }
14706
+ }, [data.typeOfIdentity]);
14707
+ const {
14708
+ sliceData,
14709
+ updateStateSlice
14710
+ } = useGlobalDataSlice("personalDetails");
14711
+ p(() => {
14712
+ updateStateSlice({
14713
+ data: {
14714
+ ...sliceData,
14715
+ ...data
14716
+ },
14717
+ errors,
14718
+ valid,
14719
+ fieldProblems
14720
+ });
14721
+ }, [data, errors, valid, fieldProblems]);
14722
+ const {
14723
+ i18n
14724
+ } = useCoreContext();
14725
+ const formUtils = formUtilities(props, i18n);
14726
+ return o(Fragment, {
14727
+ children: [o(TypeOfIdentity, {
14728
+ availableIdentityTypes: identityTypes.filter((type) => type !== "nationalIdNumber"),
14729
+ selectedIdentityType: data.typeOfIdentity,
14730
+ setSelectedIdentityType: handleChangeFor("typeOfIdentity"),
14731
+ formUtils,
14732
+ isValid: valid.typeOfIdentity,
14733
+ errorMessage: formUtils.getErrorMessage("typeOfIdentity", errors, fieldProblems)
14734
+ }), data.typeOfIdentity === "passport" ? o(PassportNumber, {
14735
+ passportNumber: data.idNumber ?? "",
14736
+ onInput: handleChangeFor("idNumber", "input"),
14737
+ onBlur: handleChangeFor("idNumber", "blur"),
14738
+ isValid: valid.idNumber,
14739
+ label: formUtils.getLabel("idNumber", "passportNumber"),
14740
+ errorMessage: formUtils.getErrorMessage("idNumber", errors, fieldProblems)
14741
+ }) : data.typeOfIdentity === "proofOfIdentityCard" ? o(ProofOfIdentityCard, {
14742
+ cardNumber: data.idNumber ?? "",
14743
+ onInput: handleChangeFor("idNumber", "input"),
14744
+ onBlur: handleChangeFor("idNumber", "blur"),
14745
+ isValid: valid.idNumber,
14746
+ label: formUtils.getLabel("idNumber", "hkid"),
14747
+ errorMessage: formUtils.getErrorMessage("idNumber", errors, fieldProblems)
14748
+ }) : data.typeOfIdentity === "driversLicense" ? o(DriversLicense, {
14749
+ driversLicense: data,
14750
+ onLicenseNumberInput: handleChangeFor("idNumber", "input"),
14751
+ onLicenseNumberBlur: handleChangeFor("idNumber", "blur"),
14752
+ label: formUtils.getLabel("idNumber", "driverLicense"),
14753
+ isValid: {
14754
+ idNumber: valid.idNumber
14755
+ },
14756
+ errorMessages: {
14757
+ idNumber: formUtils.getErrorMessage("idNumber", errors, fieldProblems)
14758
+ }
14759
+ }) : void 0]
14760
+ });
14761
+ }
14762
+ const IdentityNumber$1 = "";
14763
+ function validCheckCharacter(input, calculationInput) {
14764
+ if (!/^[A-Z]$/.test(input)) {
14765
+ return false;
14766
+ }
14767
+ const CHECKCHARACTER_ODD_VALUE = {
14768
+ 0: 1,
14769
+ 9: 21,
14770
+ I: 19,
14771
+ R: 8,
14772
+ 1: 0,
14773
+ A: 1,
14774
+ J: 21,
14775
+ S: 12,
14776
+ 2: 5,
14777
+ B: 0,
14778
+ K: 2,
14779
+ T: 14,
14780
+ 3: 7,
14781
+ C: 5,
14782
+ L: 4,
14783
+ U: 16,
14784
+ 4: 9,
14785
+ D: 7,
14786
+ M: 18,
14787
+ V: 10,
14788
+ 5: 13,
14789
+ E: 9,
14790
+ N: 20,
14791
+ W: 22,
14792
+ 6: 15,
14793
+ F: 13,
14794
+ O: 11,
14795
+ X: 25,
14796
+ 7: 17,
14797
+ G: 15,
14798
+ P: 3,
14799
+ Y: 24,
14800
+ 8: 19,
14801
+ H: 17,
14802
+ Q: 6,
14803
+ Z: 23
14804
+ };
14805
+ const CHECKCHARACTER_EVEN_VALUE = {
14806
+ 0: 0,
14807
+ 9: 9,
14808
+ I: 8,
14809
+ R: 17,
14810
+ 1: 1,
14811
+ A: 0,
14812
+ J: 9,
14813
+ S: 18,
14814
+ 2: 2,
14815
+ B: 1,
14816
+ K: 10,
14817
+ T: 19,
14818
+ 3: 3,
14819
+ C: 2,
14820
+ L: 11,
14821
+ U: 20,
14822
+ 4: 4,
14823
+ D: 3,
14824
+ M: 12,
14825
+ V: 21,
14826
+ 5: 5,
14827
+ E: 4,
14828
+ N: 13,
14829
+ W: 22,
14830
+ 6: 6,
14831
+ F: 5,
14832
+ O: 14,
14833
+ X: 23,
14834
+ 7: 7,
14835
+ G: 6,
14836
+ P: 15,
14837
+ Y: 24,
14838
+ 8: 8,
14839
+ H: 7,
14840
+ Q: 16,
14841
+ Z: 25
14842
+ };
14843
+ let total = 0;
14844
+ for (let i2 = 0; i2 < 15; i2 += 1) {
14845
+ const set = i2 % 2 === 1 ? CHECKCHARACTER_EVEN_VALUE : CHECKCHARACTER_ODD_VALUE;
14846
+ const token = calculationInput.substring(i2, i2 + 1);
14847
+ const value = set[token];
14848
+ if (value == null) {
14849
+ return true;
14850
+ }
14851
+ total = (total + value) % 26;
14852
+ }
14853
+ if (total >= 0 && total <= 26 && "ABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(total) === input) {
14854
+ return true;
14855
+ }
14856
+ return false;
14857
+ }
14858
+ const helper = {
14859
+ validCheckCharacter
14860
+ };
14861
+ const countryIdNumberFormatters = {
14862
+ [CountryCodes.Brazil]: {
14863
+ idNumber: {
14864
+ formatter: formatBrazilSSN,
14656
14865
  maxlength: 18
14657
14866
  }
14658
14867
  },
@@ -15147,7 +15356,8 @@ function NameComponent(props) {
15147
15356
  setState: null
15148
15357
  });
15149
15358
  p(() => {
15150
- stateRef.current.setState({
15359
+ var _a, _b, _c;
15360
+ (_b = (_a = stateRef.current) == null ? void 0 : _a.setState) == null ? void 0 : _b.call(_a, {
15151
15361
  type: "addToState",
15152
15362
  value: {
15153
15363
  data,
@@ -15158,6 +15368,14 @@ function NameComponent(props) {
15158
15368
  dataStoreId
15159
15369
  }
15160
15370
  });
15371
+ (_c = props.onChange) == null ? void 0 : _c.call(props, {
15372
+ schema,
15373
+ data,
15374
+ valid,
15375
+ errors,
15376
+ fieldProblems,
15377
+ isValid
15378
+ });
15161
15379
  }, [data, valid, errors, isValid]);
15162
15380
  const formUtils = formUtilities(props, i18n);
15163
15381
  return o("div", {
@@ -15170,7 +15388,7 @@ function NameComponent(props) {
15170
15388
  classNameModifiers: ["firstName", "col-50"],
15171
15389
  errorMessage: formUtils.getErrorMessage("firstName", errors, fieldProblems),
15172
15390
  isValid: valid.firstName,
15173
- helper: i18n.get("enterNameExactlyAsAppearInID"),
15391
+ helper: formUtils.getLabel("enterNameExactlyAsAppearInID"),
15174
15392
  children: (childProps) => o(InputText, {
15175
15393
  ...childProps,
15176
15394
  name: "firstName",
@@ -15191,7 +15409,7 @@ function NameComponent(props) {
15191
15409
  classNameModifiers: ["lastName", "col-50"],
15192
15410
  errorMessage: formUtils.getErrorMessage("lastName", errors, fieldProblems),
15193
15411
  isValid: valid.lastName,
15194
- helper: i18n.get("enterLastNameExactlyAsAppearInID"),
15412
+ helper: formUtils.getLabel("enterLastNameExactlyAsAppearInID"),
15195
15413
  children: (childProps) => o(InputText, {
15196
15414
  ...childProps,
15197
15415
  name: "lastName",
@@ -15418,7 +15636,10 @@ function PersonalDetailsComponent(props) {
15418
15636
  onDropdownChange: handleChangeFor("residencyCountry", "input"),
15419
15637
  value: data.residencyCountry,
15420
15638
  readOnly: !isAllowedEditPrefilledCountry && !isDecisionMakerTask
15421
- }), hasRequiredFields(identityProps) && (data.residencyCountry === "AU" ? o(IdentityAuComponent, {
15639
+ }), hasRequiredFields(identityProps) && (data.residencyCountry === "HK" ? o(IdentityHKComponent, {
15640
+ ...identityAuProps,
15641
+ dataStoreId: PERSONAL_DETAILS
15642
+ }) : data.residencyCountry === "AU" ? o(IdentityAuComponent, {
15422
15643
  ...identityAuProps,
15423
15644
  dataStoreId: PERSONAL_DETAILS
15424
15645
  }) : data.residencyCountry === "US" ? o(IdentityUSComponent, {
@@ -15432,7 +15653,7 @@ function PersonalDetailsComponent(props) {
15432
15653
  errors: externalErrors,
15433
15654
  country: data.residencyCountry,
15434
15655
  dataStoreId: PERSONAL_DETAILS
15435
- })), data.residencyCountry === "SG" && formUtils.isRequiredField("nationality") && o(CountryField, {
15656
+ })), (data.residencyCountry === "SG" || data.residencyCountry === "HK") && formUtils.isRequiredField("nationality") && o(CountryField, {
15436
15657
  label: formUtils.getLabel("nationality"),
15437
15658
  classNameModifiers: ["nationality"],
15438
15659
  errorMessage: formUtils.getErrorMessage("nationality", errors, fieldProblems),
@@ -17589,7 +17810,7 @@ function PayoutBankStatementComponent(props) {
17589
17810
  }) : null]
17590
17811
  });
17591
17812
  }
17592
- const PayoutBankStatement = x(PayoutBankStatementComponent, (prevProps, nextProps) => objectsDeepEqual(prevProps.requiredFields, nextProps.requiredFields) && objectsDeepEqual(prevProps.optionalFields, nextProps.optionalFields) && objectsDeepEqual(prevProps.data, nextProps.data) && objectsDeepEqual(prevProps.formVerificationErrors, nextProps.formVerificationErrors) && objectsDeepEqual(prevProps.fieldValidationErrors, nextProps.fieldValidationErrors) && prevProps.country === nextProps.country && prevProps.shouldValidate === nextProps.shouldValidate);
17813
+ const PayoutBankStatement = x(PayoutBankStatementComponent, (prevProps, nextProps) => objectsDeepEqual(prevProps.requiredFields, nextProps.requiredFields) && objectsDeepEqual(prevProps.optionalFields, nextProps.optionalFields) && objectsDeepEqual(prevProps.data, nextProps.data) && objectsDeepEqual(prevProps.formVerificationErrors, nextProps.formVerificationErrors) && objectsDeepEqual(prevProps.fieldValidationErrors, nextProps.fieldValidationErrors) && prevProps.country === nextProps.country && prevProps.shouldValidate === nextProps.shouldValidate && prevProps.heading === nextProps.heading);
17593
17814
  const VerificationMethod = "";
17594
17815
  const hasLoaded = (loadedValue) => loadedValue !== "loading";
17595
17816
  const eeaCountries = [CountryCodes.Austria, CountryCodes.Belgium, CountryCodes.Bulgaria, CountryCodes.Croatia, CountryCodes.Cyprus, CountryCodes.CzechRepublic, CountryCodes.Denmark, CountryCodes.Estonia, CountryCodes.Finland, CountryCodes.France, CountryCodes.Germany, CountryCodes.Greece, CountryCodes.Hungary, CountryCodes.Ireland, CountryCodes.Italy, CountryCodes.Latvia, CountryCodes.Lithuania, CountryCodes.Luxembourg, CountryCodes.Netherlands, CountryCodes.Norway, CountryCodes.Poland, CountryCodes.Portugal, CountryCodes.Romania, CountryCodes.Slovakia, CountryCodes.Slovenia, CountryCodes.Spain, CountryCodes.Sweden];
@@ -19686,6 +19907,9 @@ const solePropBase = {
19686
19907
  tradingName: {
19687
19908
  rule: "REQUIRED"
19688
19909
  },
19910
+ dateOfIncorporation: {
19911
+ rule: "countryRequiresDateOfIncorporationForCompanies"
19912
+ },
19689
19913
  exemptedFromRegistrationNumber: {
19690
19914
  rule: "countryHasRegistrationExemptionsForSomeSoleProps"
19691
19915
  },
@@ -20031,12 +20255,14 @@ const getRequiredForms = (forms, requiredFields, optionalFields) => {
20031
20255
  };
20032
20256
  const addValidityToForms = (forms, formValidity, problems) => forms.map(({
20033
20257
  formId,
20034
- formName
20258
+ formName,
20259
+ fields
20035
20260
  }) => {
20036
20261
  var _a;
20037
20262
  return {
20038
20263
  formId,
20039
20264
  formName,
20265
+ fields,
20040
20266
  isValid: (formValidity == null ? void 0 : formValidity[formId]) ?? false,
20041
20267
  hasServerValidationErrors: Boolean((_a = problems == null ? void 0 : problems.validationErrors) == null ? void 0 : _a[formId])
20042
20268
  };
@@ -20130,6 +20356,7 @@ const FormNavigationItem = ({
20130
20356
  const {
20131
20357
  i18n
20132
20358
  } = useCoreContext();
20359
+ const hasError = form.hasServerValidationErrors || hasVerificationErrors;
20133
20360
  return o("li", {
20134
20361
  className: cx("adyen-kyc-form-navigation__item", {
20135
20362
  "adyen-kyc-form-navigation__item--active": isActive,
@@ -20142,7 +20369,7 @@ const FormNavigationItem = ({
20142
20369
  children: o(AlertIcon, {
20143
20370
  type: AlertTypes.WARNING
20144
20371
  })
20145
- }), form.isValid && !form.hasServerValidationErrors && !hasVerificationErrors && o("span", {
20372
+ }), form.isValid && !hasError && o("span", {
20146
20373
  className: "adyen-kyc-form-navigation__item-icon adyen-kyc-form-navigation__item-icon--success",
20147
20374
  children: o(Icon, {
20148
20375
  name: "checkmark-small"
@@ -20157,7 +20384,7 @@ function FormNavigation({
20157
20384
  validateForm,
20158
20385
  className,
20159
20386
  taskName,
20160
- hasVerificationErrors = false,
20387
+ verificationErrors,
20161
20388
  trackNavigation: trackNavigation2 = noop
20162
20389
  }) {
20163
20390
  const {
@@ -20205,7 +20432,7 @@ function FormNavigation({
20205
20432
  form,
20206
20433
  isActive: form.formId === activeForm.formId,
20207
20434
  onClick: getNavigateHandler(form, activeForm),
20208
- hasVerificationErrors
20435
+ hasVerificationErrors: Boolean((verificationErrors == null ? void 0 : verificationErrors[form.formId]) ?? false)
20209
20436
  }, form.formId))]
20210
20437
  })]
20211
20438
  });
@@ -20314,7 +20541,7 @@ const FormWrapper = ({
20314
20541
  baseTrackingPayload,
20315
20542
  i18n
20316
20543
  }),
20317
- hasVerificationErrors: Object.keys((problems == null ? void 0 : problems.verificationErrors) ?? {}).length > 0
20544
+ verificationErrors: problems == null ? void 0 : problems.verificationErrors
20318
20545
  })
20319
20546
  });
20320
20547
  return o(DropinLayout, {
@@ -20475,7 +20702,7 @@ function CompanyDropinComponent({
20475
20702
  const existingRoles = (_a2 = existingEntityAssociations == null ? void 0 : existingEntityAssociations.filter((ea) => ea.legalEntityId === parentLegalEntity.id)) == null ? void 0 : _a2.map(({
20476
20703
  type
20477
20704
  }) => type);
20478
- const newRoles = associationDetail == null ? void 0 : associationDetail.types;
20705
+ const newRoles = associationDetail == null ? void 0 : associationDetail.roles;
20479
20706
  if (newRoles && !doArraysMatch(existingRoles, newRoles)) {
20480
20707
  const updatedParentLegalEntity = {
20481
20708
  entityAssociations: [...newRoles.map((role2) => ({
@@ -20662,6 +20889,7 @@ function CompanyDropinComponent({
20662
20889
  validateForm: () => setShouldValidate(true),
20663
20890
  baseTrackingPayload,
20664
20891
  onSubmit,
20892
+ problems,
20665
20893
  canSubmit: canSubmit(data) && hasDataChanged(dataFromResponse, data),
20666
20894
  summary: {
20667
20895
  data: formatDataForSummary(data, forms),
@@ -20683,6 +20911,22 @@ function CompanyDropinComponent({
20683
20911
  })
20684
20912
  });
20685
20913
  }
20914
+ const logger$3 = createLogger("useExemptSettlor");
20915
+ const useExemptSettlor = ({
20916
+ trust,
20917
+ handleGetLegalEntity
20918
+ }) => {
20919
+ const [exemptSettlor, setExemptSettlor] = h();
20920
+ const updateExemptSettlor = T$1(async (trustLE) => {
20921
+ const exemptSettlorAssociation = getOwnEntityAssociations(trustLE).find((association) => association.type === TrustMemberTypes.SETTLOR && Boolean(association.settlorExemptionReason));
20922
+ const exemptSettlorLE = (exemptSettlorAssociation == null ? void 0 : exemptSettlorAssociation.legalEntityId) ? await handleGetLegalEntity(exemptSettlorAssociation.legalEntityId) : void 0;
20923
+ setExemptSettlor(exemptSettlorLE);
20924
+ }, [handleGetLegalEntity]);
20925
+ p(() => {
20926
+ updateExemptSettlor(trust).catch(logger$3.error);
20927
+ }, [trust, updateExemptSettlor]);
20928
+ return exemptSettlor;
20929
+ };
20686
20930
  const downloadFile = async (base64, filename) => {
20687
20931
  saveBlobAsFile(base64ToBlob(base64), filename);
20688
20932
  };
@@ -20745,6 +20989,190 @@ const getPayoutAccountHolderName = (legalEntity, i18n) => {
20745
20989
  }
20746
20990
  return getLegalEntityNameBasedOnType(legalEntity);
20747
20991
  };
20992
+ const splitAtFirstOccurrence = (str, separator) => {
20993
+ const firstOccurrence = str.indexOf(separator);
20994
+ if (firstOccurrence === -1)
20995
+ return [str];
20996
+ return [str.slice(0, firstOccurrence), str.slice(firstOccurrence + 1)];
20997
+ };
20998
+ const getTrustMemberOwnerId = (trustMemberId, entityAssociations) => {
20999
+ var _a;
21000
+ return (_a = entityAssociations.find((association) => association.associatorId === trustMemberId && association.type === TrustMemberTypes.TRUSTEE)) == null ? void 0 : _a.legalEntityId;
21001
+ };
21002
+ const getFallbackName = (exemptSettlorAssociation) => {
21003
+ const [firstName2, lastName2] = splitAtFirstOccurrence(exemptSettlorAssociation.name ?? "", " ");
21004
+ return {
21005
+ firstName: firstName2,
21006
+ lastName: lastName2
21007
+ };
21008
+ };
21009
+ const convertEntityAssociationIntoTrustMember = (association, associations, exemptSettlorLE) => {
21010
+ var _a;
21011
+ if (association.settlorExemptionReason)
21012
+ return {
21013
+ trustMemberType: "exemptSettlor",
21014
+ roles: [TrustMemberTypes.SETTLOR],
21015
+ legalEntityType: LegalEntityType.INDIVIDUAL,
21016
+ legalEntityId: association.legalEntityId,
21017
+ settlorExemptionReason: association.settlorExemptionReason,
21018
+ exemptSettlorName: ((_a = exemptSettlorLE == null ? void 0 : exemptSettlorLE.individual) == null ? void 0 : _a.name) ?? getFallbackName(association)
21019
+ };
21020
+ if (association.entityType === LegalEntityType.ORGANIZATION)
21021
+ return {
21022
+ trustMemberType: "company",
21023
+ roles: [],
21024
+ legalEntityType: LegalEntityType.ORGANIZATION,
21025
+ legalEntityId: association.legalEntityId,
21026
+ name: association.name,
21027
+ ownerId: getTrustMemberOwnerId(association.legalEntityId, associations)
21028
+ };
21029
+ if (association.entityType === LegalEntityType.INDIVIDUAL)
21030
+ return {
21031
+ trustMemberType: "regular",
21032
+ roles: [],
21033
+ legalEntityType: LegalEntityType.INDIVIDUAL,
21034
+ legalEntityId: association.legalEntityId,
21035
+ name: association.name
21036
+ };
21037
+ throw new Error(`Not a valid trust member: ${JSON.stringify(association)}`);
21038
+ };
21039
+ const mapEntityAssociationsToTrustMembers = (trustEntityId, entityAssociations, exemptSettlorLE) => {
21040
+ const mappedTrustMembers = entityAssociations.reduce((acc, entityAssociation) => {
21041
+ if (!Object.values(TrustMemberTypes).includes(entityAssociation.type) || entityAssociation.associatorId !== trustEntityId || !entityAssociation.legalEntityId) {
21042
+ return acc;
21043
+ }
21044
+ const trustMember = acc[entityAssociation.legalEntityId] ?? convertEntityAssociationIntoTrustMember(entityAssociation, entityAssociations, exemptSettlorLE);
21045
+ const trustMemberType = entityAssociation.type;
21046
+ acc[entityAssociation.legalEntityId] = {
21047
+ ...trustMember,
21048
+ roles: [.../* @__PURE__ */ new Set([...trustMember.roles, trustMemberType])]
21049
+ };
21050
+ return acc;
21051
+ }, {});
21052
+ return Object.values(mappedTrustMembers);
21053
+ };
21054
+ const mapRootLegalEntityToTrustMember = (rootLegalEntity) => ({
21055
+ trustMemberType: "rootTrustee",
21056
+ roles: [TrustMemberTypes.TRUSTEE],
21057
+ legalEntityType: rootLegalEntity.type,
21058
+ legalEntityId: rootLegalEntity.id,
21059
+ name: getLegalEntityNameBasedOnType(rootLegalEntity)
21060
+ });
21061
+ const mapUndefinedBeneficiaryInfoToTrustMembers = (undefinedBeneficiaryInfo) => undefinedBeneficiaryInfo.map(({
21062
+ reference,
21063
+ description: description2
21064
+ }) => ({
21065
+ trustMemberType: "undefinedBeneficiary",
21066
+ roles: [TrustMemberTypes.UNDEFINED_BENEFICIARY],
21067
+ reference,
21068
+ description: description2
21069
+ }));
21070
+ const getTrustMembers = (trustLE, rootLegalEntity, exemptSettlorLE) => {
21071
+ var _a;
21072
+ return [mapRootLegalEntityToTrustMember(rootLegalEntity), ...mapEntityAssociationsToTrustMembers(trustLE.id, trustLE.entityAssociations ?? [], exemptSettlorLE), ...mapUndefinedBeneficiaryInfoToTrustMembers(((_a = trustLE.trust) == null ? void 0 : _a.undefinedBeneficiaryInfo) ?? [])];
21073
+ };
21074
+ const mapTrustMemberToEntityAssociations = (trustMember) => {
21075
+ if (trustMember.trustMemberType === "exemptSettlor")
21076
+ return [{
21077
+ legalEntityId: trustMember.legalEntityId,
21078
+ entityType: trustMember.legalEntityType,
21079
+ type: TrustMemberTypes.SETTLOR,
21080
+ settlorExemptionReason: trustMember.settlorExemptionReason,
21081
+ name: `${trustMember.exemptSettlorName.firstName} ${trustMember.exemptSettlorName.lastName}`
21082
+ }];
21083
+ return trustMember.roles.map((role2) => ({
21084
+ legalEntityId: trustMember.legalEntityId,
21085
+ type: role2
21086
+ }));
21087
+ };
21088
+ const addOrUpdateAssociatedTrustMember = async ({
21089
+ newOrUpdated,
21090
+ trust,
21091
+ handleUpdateLegalEntity
21092
+ }) => {
21093
+ const otherAssociations = getOwnEntityAssociations(trust).filter((existingAssociation) => existingAssociation.legalEntityId !== newOrUpdated.legalEntityId);
21094
+ const updatedAssociations = mapTrustMemberToEntityAssociations(newOrUpdated);
21095
+ const patchLE = {
21096
+ entityAssociations: [...otherAssociations, ...updatedAssociations]
21097
+ };
21098
+ await handleUpdateLegalEntity(patchLE, trust.id);
21099
+ };
21100
+ const addOrUpdateUndefinedBeneficiary = async ({
21101
+ newOrUpdated,
21102
+ trust,
21103
+ handleUpdateLegalEntity
21104
+ }) => {
21105
+ var _a, _b;
21106
+ const otherUndefinedBeneficiaries = ((_b = (_a = trust.trust) == null ? void 0 : _a.undefinedBeneficiaryInfo) == null ? void 0 : _b.filter((ub) => ub.reference !== newOrUpdated.reference)) ?? [];
21107
+ const patchLE = {
21108
+ trust: {
21109
+ undefinedBeneficiaryInfo: [...otherUndefinedBeneficiaries, {
21110
+ reference: newOrUpdated.reference,
21111
+ description: newOrUpdated.description
21112
+ }]
21113
+ }
21114
+ };
21115
+ await handleUpdateLegalEntity(patchLE, trust.id);
21116
+ };
21117
+ const createExemptSettlor = async ({
21118
+ exemptSettlor,
21119
+ trust,
21120
+ handleCreateLegalEntity
21121
+ }) => {
21122
+ const exemptSettlorLE = {
21123
+ type: LegalEntityType.INDIVIDUAL,
21124
+ individual: {
21125
+ name: {
21126
+ firstName: exemptSettlor.exemptSettlorName.firstName,
21127
+ lastName: exemptSettlor.exemptSettlorName.lastName
21128
+ },
21129
+ residentialAddress: {
21130
+ country: trust.trust.registeredAddress.country
21131
+ }
21132
+ }
21133
+ };
21134
+ return handleCreateLegalEntity(exemptSettlorLE);
21135
+ };
21136
+ const deleteAssociatedTrustMember = async ({
21137
+ associatedTrustMember,
21138
+ trust,
21139
+ handleUpdateLegalEntity
21140
+ }) => {
21141
+ const ownEntityAssociations = getOwnEntityAssociations(trust);
21142
+ const updatedTrustAssociations = {
21143
+ entityAssociations: ownEntityAssociations.filter((entityAssociation) => entityAssociation.legalEntityId !== associatedTrustMember.legalEntityId)
21144
+ };
21145
+ await handleUpdateLegalEntity(updatedTrustAssociations, trust.id);
21146
+ };
21147
+ const deleteUndefinedBeneficiary = async ({
21148
+ undefinedBeneficiary: undefinedBeneficiary2,
21149
+ trust,
21150
+ handleUpdateLegalEntity
21151
+ }) => {
21152
+ var _a;
21153
+ const existingUndefinedBeneficiaries = ((_a = trust.trust) == null ? void 0 : _a.undefinedBeneficiaryInfo) ?? [];
21154
+ const updatedTrust = {
21155
+ trust: {
21156
+ undefinedBeneficiaryInfo: existingUndefinedBeneficiaries.filter((ub) => ub.reference !== undefinedBeneficiary2.reference)
21157
+ }
21158
+ };
21159
+ await handleUpdateLegalEntity(updatedTrust, trust.id);
21160
+ };
21161
+ const exemptSettlorNamesTheSame = (existingSettlor, newSettlor) => JSON.stringify(existingSettlor.exemptSettlorName) === JSON.stringify(newSettlor.exemptSettlorName);
21162
+ const updateExemptSettlorName = async ({
21163
+ exemptSettlor,
21164
+ handleUpdateLegalEntity
21165
+ }) => {
21166
+ const exemptSettlorPatch = {
21167
+ individual: {
21168
+ name: {
21169
+ firstName: exemptSettlor.exemptSettlorName.firstName,
21170
+ lastName: exemptSettlor.exemptSettlorName.lastName
21171
+ }
21172
+ }
21173
+ };
21174
+ return handleUpdateLegalEntity(exemptSettlorPatch, exemptSettlor.legalEntityId);
21175
+ };
20748
21176
  const DecisionMakers = "";
20749
21177
  const iconStatus = (current, min, max) => {
20750
21178
  const isEmpty2 = current === 0;
@@ -21364,7 +21792,6 @@ const DecisionMakersComponent = ({
21364
21792
  }), (uniqueDecisionMakers == null ? void 0 : uniqueDecisionMakers.length) > 0 ? o(CardGroup, {
21365
21793
  children: uniqueDecisionMakers.map((decisionMaker2) => o(EntityAssociation, {
21366
21794
  types: decisionMaker2.types,
21367
- reference: decisionMaker2.reference,
21368
21795
  name: decisionMaker2.name,
21369
21796
  status: decisionMaker2.status,
21370
21797
  actions: actions(decisionMaker2),
@@ -21863,221 +22290,210 @@ function TaskListComponent({
21863
22290
  })
21864
22291
  });
21865
22292
  }
21866
- const TrustMembers = "";
21867
- const getReference = (entityAssociation) => entityAssociation.legalEntityId ?? (entityAssociation.type === "settlor" ? "exemptSettlor" : "");
21868
- const mapEntityAssociationsToUniqueTrustMembers = (entityAssociations, getTaskStatusForEntityAssociation) => {
21869
- const mappedTrustMembers = entityAssociations.reduce((acc, entityAssociation) => {
21870
- const reference = getReference(entityAssociation);
21871
- const mappedTrustMember = acc[reference];
21872
- const trustMemberType = entityAssociation.type;
21873
- acc[reference] = {
21874
- reference,
21875
- types: mappedTrustMember ? [...mappedTrustMember.types, trustMemberType] : [trustMemberType],
21876
- status: getTaskStatusForEntityAssociation(entityAssociation),
21877
- name: entityAssociation.name ?? "",
21878
- legalEntityType: entityAssociation.entityType,
21879
- settlorExemptionReason: entityAssociation.settlorExemptionReason
21880
- };
21881
- return acc;
21882
- }, {});
21883
- return Object.values(mappedTrustMembers);
21884
- };
21885
- const makeUndefinedBeneficiaryTrustMember = (undefinedBeneficiary2) => ({
21886
- types: [TrustMemberTypes.UNDEFINED_BENEFICIARY],
21887
- reference: undefinedBeneficiary2.reference,
21888
- descriptionUndefinedBeneficiary: undefinedBeneficiary2.description,
21889
- status: TaskStatus.FINISHED,
21890
- name: ""
21891
- });
21892
- function UndefinedBeneficiaries({
21893
- undefinedBeneficiaries,
21894
- onDelete,
21895
- onEdit
21896
- }) {
22293
+ const TrustMembersOverview$1 = "";
22294
+ const CompanyTrustMemberTaskItem = ({
22295
+ companyTrustMember,
22296
+ taskStatus,
22297
+ onEditOwner,
22298
+ onAddOwner,
22299
+ onEdit,
22300
+ onDelete
22301
+ }) => {
21897
22302
  const {
21898
22303
  i18n
21899
22304
  } = useCoreContext();
21900
- const actions = (undefinedBeneficiary2) => {
21901
- const trustMember = makeUndefinedBeneficiaryTrustMember(undefinedBeneficiary2);
21902
- return [{
21903
- icon: "edit",
21904
- onSelect: () => onEdit(trustMember),
21905
- label: i18n.get("editEntityDetails"),
21906
- title: i18n.get("editTrustMember", {
21907
- values: {
21908
- trustMember: i18n.get("undefinedBeneficiary")
21909
- }
21910
- })
21911
- }, {
21912
- icon: "bin",
21913
- onSelect: () => onDelete(trustMember.reference),
21914
- label: i18n.get("remove"),
21915
- title: i18n.get("removeTrustMember", {
21916
- values: {
21917
- trustMember: i18n.get("undefinedBeneficiary")
21918
- }
21919
- })
21920
- }];
21921
- };
21922
- return o(Fragment, {
21923
- children: undefinedBeneficiaries.map((undefinedBeneficiary2) => o(EntityAssociation, {
21924
- types: [TrustMemberTypes.UNDEFINED_BENEFICIARY],
21925
- reference: undefinedBeneficiary2.reference,
21926
- status: TaskStatus.FINISHED,
21927
- name: undefinedBeneficiary2.description,
21928
- actions: actions(undefinedBeneficiary2),
21929
- onNavigateToEntity: () => onEdit(makeUndefinedBeneficiaryTrustMember(undefinedBeneficiary2))
21930
- }, undefinedBeneficiary2.reference))
21931
- });
21932
- }
21933
- const TrustMembersComponent = ({
21934
- parentLegalEntity,
21935
- trustResponse,
21936
- capabilityProblems,
21937
- navigateBackToTaskList,
21938
- navigateToEditTrustMember,
21939
- navigateToEditTrustMemberOwner,
21940
- handleUpdateLegalEntity,
21941
- onTrustMemberDelete
22305
+ const actions = [{
22306
+ icon: "edit",
22307
+ onSelect: onEdit,
22308
+ label: i18n.get("editEntityDetails"),
22309
+ title: i18n.get("editTrustMember", {
22310
+ values: {
22311
+ trustMember: companyTrustMember.name
22312
+ }
22313
+ })
22314
+ }, companyTrustMember.ownerId ? {
22315
+ icon: "edit",
22316
+ onSelect: onEditOwner,
22317
+ label: i18n.get("editEntityOwner"),
22318
+ title: i18n.get("editOwnerOfTrustMember", {
22319
+ values: {
22320
+ trustMember: companyTrustMember.name
22321
+ }
22322
+ })
22323
+ } : {
22324
+ icon: "plus",
22325
+ onSelect: onAddOwner,
22326
+ label: i18n.get("addEntityOwner"),
22327
+ title: i18n.get("addOwnerToTrustMember", {
22328
+ values: {
22329
+ trustMember: companyTrustMember.name
22330
+ }
22331
+ })
22332
+ }, {
22333
+ icon: "bin",
22334
+ onSelect: onDelete,
22335
+ label: i18n.get("remove"),
22336
+ title: i18n.get("removeTrustMember", {
22337
+ values: {
22338
+ trustMember: companyTrustMember.name
22339
+ }
22340
+ })
22341
+ }];
22342
+ const infoContent = companyTrustMember.ownerId ? void 0 : o(Alert, {
22343
+ type: AlertTypes.BASIC,
22344
+ hasCloseButton: false,
22345
+ title: o(Fragment, {
22346
+ children: [i18n.get("helpUsVerifyCompany"), " ", o(Link, {
22347
+ onClick: (e2) => {
22348
+ e2.preventDefault();
22349
+ onAddOwner();
22350
+ },
22351
+ href: "to-company-owner",
22352
+ children: i18n.get("providePersonalDetailsOfOwner")
22353
+ })]
22354
+ }),
22355
+ className: "adl-u-margin-top-16"
22356
+ });
22357
+ return o(EntityAssociation, {
22358
+ types: companyTrustMember.roles,
22359
+ name: companyTrustMember.name,
22360
+ status: taskStatus,
22361
+ actions,
22362
+ infoContent,
22363
+ onNavigateToEntity: onEdit
22364
+ }, companyTrustMember.legalEntityId);
22365
+ };
22366
+ const ExemptSettlorTaskItem = ({
22367
+ exemptSettlor,
22368
+ taskStatus,
22369
+ onEdit,
22370
+ onDelete
21942
22371
  }) => {
21943
- var _a;
21944
22372
  const {
21945
22373
  i18n
21946
22374
  } = useCoreContext();
21947
- const {
21948
- showToast
21949
- } = useToastContext();
21950
- const trustMemberRequirements = DEFAULT_TRUST_MEMBER_REQUIREMENTS;
21951
- const allTrustMembers = getAllTrustMembers(parentLegalEntity, trustResponse);
21952
- const allMappedTrustMembers = allTrustMembers.reduce((mappedTrustMembers, trustMember) => {
21953
- const existingMapping = mappedTrustMembers[trustMember.id];
21954
- mappedTrustMembers[trustMember.id] = {
21955
- id: trustMember.id,
21956
- types: [...(existingMapping == null ? void 0 : existingMapping.types) ?? [], trustMember.type]
21957
- };
21958
- return mappedTrustMembers;
21959
- }, {});
21960
- const allUniqueTrustMembers = allMappedTrustMembers ? Object.values(allMappedTrustMembers) : [];
21961
- const uniqueTrustMembersPerType = (roleTypes) => {
21962
- const filteredTrustMembers = allUniqueTrustMembers.filter(({
21963
- types
21964
- }) => {
21965
- const typeSet = new Set(types);
21966
- return roleTypes.some((label) => typeSet.has(label));
21967
- });
21968
- return filteredTrustMembers.length;
21969
- };
21970
- const trusteeName = getLegalEntityNameBasedOnType(parentLegalEntity);
21971
- const uniqueTrustMembers = mapEntityAssociationsToUniqueTrustMembers(getOwnTrustMembers(trustResponse), (entityAssociation) => getTaskStatus(EntityType.LEGAL_ENTITY, capabilityProblems, parentLegalEntity, entityAssociation.legalEntityId ? [entityAssociation.legalEntityId] : void 0));
21972
- const deleteTrustMember = async (legalEntityId) => {
21973
- try {
21974
- const ownEntityAssociations = getOwnEntityAssociations(trustResponse);
21975
- const updatedTrustAssociations = {
21976
- entityAssociations: ownEntityAssociations.filter((entityAssociation) => entityAssociation.legalEntityId !== legalEntityId)
21977
- };
21978
- await handleUpdateLegalEntity(updatedTrustAssociations, trustResponse.id);
21979
- onTrustMemberDelete();
21980
- showToast({
21981
- type: ToastType.SUCCESS,
21982
- label: i18n.get("successFullyRemovedTrustMember")
21983
- });
21984
- } catch (e2) {
21985
- showToast({
21986
- type: ToastType.ERROR,
21987
- label: i18n.get("failedToRemoveTrustMember")
21988
- });
21989
- }
21990
- };
21991
- const deleteUndefinedBeneficiary = async (undefinedBeneficiaryReference) => {
21992
- var _a2;
21993
- try {
21994
- const existingUndefinedBeneficiaries = ((_a2 = trustResponse.trust) == null ? void 0 : _a2.undefinedBeneficiaryInfo) ?? [];
21995
- const updatedTrust = {
21996
- trust: {
21997
- undefinedBeneficiaryInfo: existingUndefinedBeneficiaries.filter((undefinedBeneficiary2) => undefinedBeneficiary2.reference !== undefinedBeneficiaryReference)
21998
- }
21999
- };
22000
- await handleUpdateLegalEntity(updatedTrust, trustResponse.id);
22001
- onTrustMemberDelete();
22002
- showToast({
22003
- type: ToastType.SUCCESS,
22004
- label: i18n.get("successFullyRemovedTrustMember")
22005
- });
22006
- } catch (e2) {
22007
- showToast({
22008
- type: ToastType.ERROR,
22009
- label: i18n.get("failedToRemoveTrustMember")
22010
- });
22011
- }
22012
- };
22013
- const getTrustMemberOwnerId = (trustMemberId, trustResponse2) => {
22014
- var _a2;
22015
- const associations = trustResponse2.entityAssociations;
22016
- if (associations) {
22017
- return (_a2 = associations.find((association) => association.associatorId === trustMemberId && association.type === TrustMemberTypes.TRUSTEE)) == null ? void 0 : _a2.legalEntityId;
22018
- }
22019
- };
22020
- const infoContent = (trustMember) => {
22021
- const ownerId = getTrustMemberOwnerId(trustMember.reference, trustResponse);
22022
- if (trustMember.legalEntityType === LegalEntityType.ORGANIZATION && !ownerId) {
22023
- return o(Alert, {
22024
- type: AlertTypes.BASIC,
22025
- hasCloseButton: false,
22026
- title: o(Fragment, {
22027
- children: [i18n.get("helpUsVerifyCompany"), " ", o(Link, {
22028
- onClick: (e2) => {
22029
- e2.preventDefault();
22030
- navigateToEditTrustMemberOwner("", trustMember.reference);
22031
- },
22032
- href: "to-company-owner",
22033
- children: i18n.get("providePersonalDetailsOfOwner")
22034
- })]
22035
- }),
22036
- className: "adl-u-margin-top-16"
22037
- });
22038
- }
22039
- };
22040
- const actions = (trustMember) => {
22041
- const ownerId = getTrustMemberOwnerId(trustMember.reference, trustResponse);
22042
- const editCompanyTrusteeAction = trustMember.legalEntityType === LegalEntityType.ORGANIZATION ? ownerId ? {
22043
- icon: "edit",
22044
- onSelect: () => navigateToEditTrustMemberOwner(ownerId, trustMember.reference),
22045
- label: i18n.get("editEntityOwner"),
22046
- title: i18n.get("editOwnerOfTrustMember", {
22047
- values: {
22048
- trustMember: trustMember.name
22049
- }
22050
- })
22051
- } : {
22052
- icon: "plus",
22053
- onSelect: () => navigateToEditTrustMemberOwner("", trustMember.reference),
22054
- label: i18n.get("addEntityOwner"),
22055
- title: i18n.get("addOwnerToTrustMember", {
22056
- values: {
22057
- trustMember: trustMember.name
22058
- }
22059
- })
22060
- } : void 0;
22061
- return [{
22062
- icon: "edit",
22063
- onSelect: () => navigateToEditTrustMember(trustMember),
22064
- label: i18n.get("editEntityDetails"),
22065
- title: i18n.get("editTrustMember", {
22066
- values: {
22067
- trustMember: trustMember.name
22068
- }
22069
- })
22070
- }, editCompanyTrusteeAction, {
22071
- icon: "bin",
22072
- onSelect: () => deleteTrustMember(trustMember.reference),
22073
- label: i18n.get("remove"),
22074
- title: i18n.get("removeTrustMember", {
22075
- values: {
22076
- trustMember: trustMember.name
22077
- }
22078
- })
22079
- }].filter((action) => Boolean(action));
22080
- };
22375
+ const settlorName = `${exemptSettlor.exemptSettlorName.firstName} ${exemptSettlor.exemptSettlorName.lastName}`;
22376
+ const actions = [{
22377
+ icon: "edit",
22378
+ onSelect: onEdit,
22379
+ label: i18n.get("editEntityDetails"),
22380
+ title: i18n.get("editTrustMember", {
22381
+ values: {
22382
+ trustMember: settlorName
22383
+ }
22384
+ })
22385
+ }, {
22386
+ icon: "bin",
22387
+ onSelect: onDelete,
22388
+ label: i18n.get("remove"),
22389
+ title: i18n.get("removeTrustMember", {
22390
+ values: {
22391
+ trustMember: settlorName
22392
+ }
22393
+ })
22394
+ }];
22395
+ return o(EntityAssociation, {
22396
+ types: exemptSettlor.roles,
22397
+ name: settlorName,
22398
+ status: taskStatus,
22399
+ actions,
22400
+ onNavigateToEntity: onEdit
22401
+ }, exemptSettlor.legalEntityId);
22402
+ };
22403
+ const RegularTrustMemberTaskItem = ({
22404
+ trustMember,
22405
+ taskStatus,
22406
+ onEdit,
22407
+ onDelete
22408
+ }) => {
22409
+ const {
22410
+ i18n
22411
+ } = useCoreContext();
22412
+ const actions = [{
22413
+ icon: "edit",
22414
+ onSelect: onEdit,
22415
+ label: i18n.get("editEntityDetails"),
22416
+ title: i18n.get("editTrustMember", {
22417
+ values: {
22418
+ trustMember: trustMember.name
22419
+ }
22420
+ })
22421
+ }, {
22422
+ icon: "bin",
22423
+ onSelect: onDelete,
22424
+ label: i18n.get("remove"),
22425
+ title: i18n.get("removeTrustMember", {
22426
+ values: {
22427
+ trustMember: trustMember.name
22428
+ }
22429
+ })
22430
+ }];
22431
+ return o(EntityAssociation, {
22432
+ types: trustMember.roles,
22433
+ name: trustMember.name,
22434
+ status: taskStatus,
22435
+ actions,
22436
+ onNavigateToEntity: onEdit
22437
+ }, trustMember.legalEntityId);
22438
+ };
22439
+ const RootTrusteeTaskItem = ({
22440
+ rootTrustee,
22441
+ taskStatus
22442
+ }) => o(EntityAssociation, {
22443
+ types: [TrustMemberTypes.TRUSTEE],
22444
+ name: rootTrustee.name,
22445
+ status: taskStatus
22446
+ }, rootTrustee.legalEntityId);
22447
+ const UndefinedBeneficiaryTaskItem = ({
22448
+ undefinedBeneficiary: undefinedBeneficiary2,
22449
+ onEdit,
22450
+ onDelete
22451
+ }) => {
22452
+ const {
22453
+ i18n
22454
+ } = useCoreContext();
22455
+ const actions = [{
22456
+ icon: "edit",
22457
+ onSelect: onEdit,
22458
+ label: i18n.get("editEntityDetails"),
22459
+ title: i18n.get("editTrustMember", {
22460
+ values: {
22461
+ trustMember: i18n.get("undefinedBeneficiary")
22462
+ }
22463
+ })
22464
+ }, {
22465
+ icon: "bin",
22466
+ onSelect: onDelete,
22467
+ label: i18n.get("remove"),
22468
+ title: i18n.get("removeTrustMember", {
22469
+ values: {
22470
+ trustMember: i18n.get("undefinedBeneficiary")
22471
+ }
22472
+ })
22473
+ }];
22474
+ return o(EntityAssociation, {
22475
+ name: undefinedBeneficiary2.description,
22476
+ types: [TrustMemberTypes.UNDEFINED_BENEFICIARY],
22477
+ status: TaskStatus.FINISHED,
22478
+ actions,
22479
+ onNavigateToEntity: onEdit
22480
+ }, undefinedBeneficiary2.reference);
22481
+ };
22482
+ const TrustMembersOverview = ({
22483
+ trustMembers: trustMembers2,
22484
+ navigateBackToTaskList,
22485
+ navigateToEditTrustMember,
22486
+ navigateToEditTrustMemberOwner,
22487
+ deleteTrustMember,
22488
+ getTrustMemberTaskStatus
22489
+ }) => {
22490
+ const {
22491
+ i18n
22492
+ } = useCoreContext();
22493
+ const trustMemberRequirements = DEFAULT_TRUST_MEMBER_REQUIREMENTS;
22494
+ const trustMembersWithOneOfGivenRoles = (roleTypes) => trustMembers2.filter(({
22495
+ roles
22496
+ }) => roleTypes.some((label) => roles.includes(label)));
22081
22497
  return o(DropinLayout, {
22082
22498
  content: o("div", {
22083
22499
  className: "adl-trust-members adl-u-width-full",
@@ -22092,10 +22508,10 @@ const TrustMembersComponent = ({
22092
22508
  max,
22093
22509
  label
22094
22510
  }) => o(EntityGuidanceStatus, {
22095
- country: "AU",
22511
+ country: CountryCodes.Australia,
22096
22512
  currentTask: TaskTypes.TRUST_MEMBER_OVERVIEW,
22097
22513
  entityLabel: label,
22098
- status: iconStatus(uniqueTrustMembersPerType(roleTypes), min, max)
22514
+ status: iconStatus(trustMembersWithOneOfGivenRoles(roleTypes).length, min, max)
22099
22515
  }, label))
22100
22516
  }), o(ReviewAlert, {}), o(ContextGuidance, {
22101
22517
  page: "Trust members",
@@ -22113,36 +22529,54 @@ const TrustMembersComponent = ({
22113
22529
  titleId: "whatIsTheDifferenceBetweenTheseRoles",
22114
22530
  contentId: "differenceBetweenTrustMemberRoles"
22115
22531
  }), o(CardGroup, {
22116
- children: [o(EntityAssociation, {
22117
- types: [TrustMemberTypes.TRUSTEE],
22118
- reference: parentLegalEntity.id,
22119
- status: getTaskStatus(EntityType.LEGAL_ENTITY, capabilityProblems, parentLegalEntity, [parentLegalEntity.id]),
22120
- name: trusteeName,
22121
- legalEntityType: parentLegalEntity.type
22122
- }, parentLegalEntity.id), uniqueTrustMembers.map((trustMember) => o(EntityAssociation, {
22123
- types: trustMember.types,
22124
- reference: trustMember.reference,
22125
- status: trustMember.status,
22126
- name: trustMember.name,
22127
- legalEntityType: trustMember.legalEntityType,
22128
- actions: actions(trustMember),
22129
- infoContent: infoContent(trustMember),
22130
- onNavigateToEntity: () => navigateToEditTrustMember(trustMember)
22131
- }, trustMember.reference)), o(UndefinedBeneficiaries, {
22132
- undefinedBeneficiaries: ((_a = trustResponse.trust) == null ? void 0 : _a.undefinedBeneficiaryInfo) ?? [],
22133
- onDelete: deleteUndefinedBeneficiary,
22134
- onEdit: navigateToEditTrustMember
22135
- })]
22532
+ children: trustMembers2.map((trustMember) => {
22533
+ switch (trustMember.trustMemberType) {
22534
+ case "rootTrustee":
22535
+ return o(RootTrusteeTaskItem, {
22536
+ rootTrustee: trustMember,
22537
+ taskStatus: getTrustMemberTaskStatus(trustMember)
22538
+ });
22539
+ case "regular":
22540
+ return o(RegularTrustMemberTaskItem, {
22541
+ trustMember,
22542
+ taskStatus: getTrustMemberTaskStatus(trustMember),
22543
+ onEdit: () => navigateToEditTrustMember(trustMember),
22544
+ onDelete: () => deleteTrustMember(trustMember)
22545
+ });
22546
+ case "company":
22547
+ return o(CompanyTrustMemberTaskItem, {
22548
+ companyTrustMember: trustMember,
22549
+ taskStatus: getTrustMemberTaskStatus(trustMember),
22550
+ onEdit: () => navigateToEditTrustMember(trustMember),
22551
+ onDelete: () => deleteTrustMember(trustMember),
22552
+ onEditOwner: () => navigateToEditTrustMemberOwner(trustMember.ownerId, trustMember.legalEntityId),
22553
+ onAddOwner: () => navigateToEditTrustMemberOwner("", trustMember.legalEntityId)
22554
+ });
22555
+ case "exemptSettlor":
22556
+ return o(ExemptSettlorTaskItem, {
22557
+ exemptSettlor: trustMember,
22558
+ taskStatus: getTrustMemberTaskStatus(trustMember),
22559
+ onEdit: () => navigateToEditTrustMember(trustMember),
22560
+ onDelete: () => deleteTrustMember(trustMember)
22561
+ });
22562
+ case "undefinedBeneficiary":
22563
+ return o(UndefinedBeneficiaryTaskItem, {
22564
+ undefinedBeneficiary: trustMember,
22565
+ onEdit: () => navigateToEditTrustMember(trustMember),
22566
+ onDelete: () => deleteTrustMember(trustMember)
22567
+ });
22568
+ }
22569
+ })
22136
22570
  }), o(Button, {
22137
22571
  secondary: true,
22138
22572
  className: cx("adl-trust-members__add", {
22139
- "adl-trust-members__add--more": uniqueTrustMembers.length > 0
22573
+ "adl-trust-members__add--more": trustMembers2.length > 0
22140
22574
  }),
22141
22575
  icon: "plus",
22142
22576
  title: i18n.get("addTrustMember"),
22143
22577
  onClick: (e2) => {
22144
22578
  e2.stopPropagation();
22145
- navigateToEditTrustMember();
22579
+ navigateToEditTrustMember("new");
22146
22580
  },
22147
22581
  label: i18n.get("addTrustMember")
22148
22582
  }), o(ActionBar, {
@@ -22257,7 +22691,7 @@ function IndividualDropinComponent({
22257
22691
  onChange,
22258
22692
  problems: propProblems,
22259
22693
  handleUpdateLegalEntity,
22260
- associationDetail,
22694
+ trustMember,
22261
22695
  onSubmit: externalOnSubmit,
22262
22696
  onTypeSwitch
22263
22697
  }) {
@@ -22415,22 +22849,22 @@ function IndividualDropinComponent({
22415
22849
  legalEntity,
22416
22850
  dataSubmitted
22417
22851
  }) => {
22418
- if (!isDocumentsRequired2(forms2))
22419
- return;
22420
- if (hasInstantIdVerification(dataSubmitted)) {
22421
- await handleInstantIdVerificationStartCheck(dataSubmitted.idDocument.instantIdVerificationData, legalEntity.id);
22422
- } else {
22423
- const formattedDocuments = await mapIndividualDocumentToApiDocument(dataSubmitted, legalEntity.id);
22424
- const uploadedDocuments = await documentUtils.uploadDocuments(formattedDocuments, legalEntity.id);
22425
- uploadedDocuments == null ? void 0 : uploadedDocuments.forEach((doc) => {
22426
- userEvents.addEvent("Saved document", {
22427
- segmentation: {
22428
- ...baseTrackingPayload,
22429
- documentType: doc.type,
22430
- fileExtention: doc.attachments.map((item) => getFileExtention(item.pageName))
22431
- }
22852
+ if (isDocumentsRequired2(forms2)) {
22853
+ if (hasInstantIdVerification(dataSubmitted)) {
22854
+ await handleInstantIdVerificationStartCheck(dataSubmitted.idDocument.instantIdVerificationData, legalEntity.id);
22855
+ } else {
22856
+ const formattedDocument = await mapIndividualDocumentToApiDocument(dataSubmitted, legalEntity.id);
22857
+ await documentUtils.uploadDocuments(formattedDocument, legalEntity.id);
22858
+ formattedDocument == null ? void 0 : formattedDocument.forEach((doc) => {
22859
+ userEvents.addEvent("Saved document", {
22860
+ segmentation: {
22861
+ ...baseTrackingPayload,
22862
+ documentType: doc.type,
22863
+ fileExtention: doc.attachments.map((item) => getFileExtention(item.pageName))
22864
+ }
22865
+ });
22432
22866
  });
22433
- });
22867
+ }
22434
22868
  }
22435
22869
  };
22436
22870
  const hasInstantIdVerification = (dataSubmitted) => {
@@ -22456,7 +22890,7 @@ function IndividualDropinComponent({
22456
22890
  dataSubmitted
22457
22891
  }) => {
22458
22892
  var _a2;
22459
- const newRoles = taskType === TaskTypes.DECISION_MAKER || taskType === TaskTypes.TRUST_MEMBER_COMPANY_OWNER ? (_a2 = dataSubmitted == null ? void 0 : dataSubmitted.personalDetails) == null ? void 0 : _a2.role : taskType === TaskTypes.TRUST_MEMBER_INDIVIDUAL ? associationDetail == null ? void 0 : associationDetail.types : null;
22893
+ const newRoles = taskType === TaskTypes.DECISION_MAKER || taskType === TaskTypes.TRUST_MEMBER_COMPANY_OWNER ? (_a2 = dataSubmitted == null ? void 0 : dataSubmitted.personalDetails) == null ? void 0 : _a2.role : taskType === TaskTypes.TRUST_MEMBER_INDIVIDUAL ? trustMember == null ? void 0 : trustMember.roles : null;
22460
22894
  const existingEntityAssociations = getOwnEntityAssociations(parentLegalEntity);
22461
22895
  if (newRoles && hasRolesChanged(legalEntity, existingEntityAssociations, newRoles)) {
22462
22896
  const updatedParentLegalEntity = {
@@ -22597,11 +23031,14 @@ function IndividualDropinComponent({
22597
23031
  };
22598
23032
  };
22599
23033
  const formatDataForSummary = () => {
22600
- var _a2, _b2;
23034
+ var _a2, _b2, _c2;
22601
23035
  let summaryData = cloneObject(data);
22602
23036
  if ((_a2 = summaryData.personalDetails) == null ? void 0 : _a2.residencyCountry) {
22603
23037
  summaryData.personalDetails.residencyCountry = datasetUtils.getCountryName(summaryData.personalDetails.residencyCountry);
22604
23038
  }
23039
+ if ((_b2 = summaryData.personalDetails) == null ? void 0 : _b2.nationality) {
23040
+ summaryData.personalDetails.nationality = datasetUtils.getCountryName(summaryData.personalDetails.nationality);
23041
+ }
22605
23042
  if (summaryData.address) {
22606
23043
  summaryData.address = mapAddressLabels(summaryData.address, datasetUtils);
22607
23044
  }
@@ -22612,7 +23049,7 @@ function IndividualDropinComponent({
22612
23049
  ...formatFileSummaryData2(data)
22613
23050
  };
22614
23051
  }
22615
- if ((_b2 = summaryData == null ? void 0 : summaryData.personalDetails) == null ? void 0 : _b2.accountHolder) {
23052
+ if ((_c2 = summaryData == null ? void 0 : summaryData.personalDetails) == null ? void 0 : _c2.accountHolder) {
22616
23053
  summaryData.personalDetails.accountHolder = i18n.get(summaryData.personalDetails.accountHolder);
22617
23054
  }
22618
23055
  return summaryData;
@@ -22780,7 +23217,8 @@ function PayoutDetailsDropinComponent({
22780
23217
  }) {
22781
23218
  var _a, _b, _c;
22782
23219
  const {
22783
- i18n
23220
+ i18n,
23221
+ setLocale
22784
23222
  } = useCoreContext();
22785
23223
  const {
22786
23224
  showToast,
@@ -22831,6 +23269,7 @@ function PayoutDetailsDropinComponent({
22831
23269
  task: taskType
22832
23270
  });
22833
23271
  p(() => {
23272
+ eventEmitter.on("updateLocale", (locale) => setLocale(locale));
22834
23273
  userEvents.addPageView("Payout dropin");
22835
23274
  userEvents.addEvent("Started payout task", {
22836
23275
  segmentation: {
@@ -23712,11 +24151,42 @@ function PciDropinComponent({
23712
24151
  footer
23713
24152
  });
23714
24153
  }
24154
+ const convertExistingSettlorExemptionReasons = (existingReasons) => {
24155
+ if (!existingReasons || !existingReasons.length)
24156
+ return ["noneOfTheAbove"];
24157
+ return existingReasons;
24158
+ };
24159
+ const convertExistingTrustMember = (trustMember) => {
24160
+ switch (trustMember.trustMemberType) {
24161
+ case "undefinedBeneficiary":
24162
+ return {
24163
+ entityType: LegalEntityType.INDIVIDUAL,
24164
+ role: ["undefinedBeneficiary"],
24165
+ descriptionUndefinedBeneficiary: trustMember.description
24166
+ };
24167
+ case "regular":
24168
+ case "company":
24169
+ case "rootTrustee":
24170
+ return {
24171
+ entityType: trustMember.legalEntityType,
24172
+ role: trustMember.roles,
24173
+ settlorExemptionReason: ["noneOfTheAbove"]
24174
+ };
24175
+ case "exemptSettlor":
24176
+ return {
24177
+ entityType: LegalEntityType.INDIVIDUAL,
24178
+ role: ["settlor"],
24179
+ settlorExemptionReason: convertExistingSettlorExemptionReasons(trustMember.settlorExemptionReason),
24180
+ firstName: trustMember.exemptSettlorName.firstName,
24181
+ lastName: trustMember.exemptSettlorName.lastName
24182
+ };
24183
+ }
24184
+ };
23715
24185
  const allowedCrossoverRolesMatrix = {
23716
- settlor: ["trustee", "protector"],
23717
- trustee: ["settlor", "protector", "definedBeneficiary"],
23718
- protector: ["settlor", "trustee", "definedBeneficiary"],
23719
- definedBeneficiary: ["trustee", "protector"],
24186
+ settlor: ["secondaryTrustee", "protector"],
24187
+ secondaryTrustee: ["settlor", "protector", "definedBeneficiary"],
24188
+ protector: ["settlor", "secondaryTrustee", "definedBeneficiary"],
24189
+ definedBeneficiary: ["secondaryTrustee", "protector"],
23720
24190
  undefinedBeneficiary: []
23721
24191
  };
23722
24192
  const getAvailableRoles = (currentRoles) => {
@@ -23773,31 +24243,22 @@ const decideFields = (data) => {
23773
24243
  return ["role", "descriptionUndefinedBeneficiary"];
23774
24244
  }
23775
24245
  if ((_b = data.role) == null ? void 0 : _b.length) {
23776
- return couldBeExemptSettlor(data) ? ["role", "entityType", "settlorExemptionReason"] : ["role", "entityType"];
24246
+ if (couldBeExemptSettlor(data)) {
24247
+ return isExemptSettlor(data) ? ["role", "entityType", "settlorExemptionReason", "firstName", "lastName"] : ["role", "entityType", "settlorExemptionReason"];
24248
+ }
24249
+ return ["role", "entityType"];
23777
24250
  }
23778
24251
  return ["role"];
23779
24252
  };
23780
- const convertExistingSettlorExemptionReasons = (existingReasons) => {
23781
- if (!existingReasons || !existingReasons.length)
23782
- return ["noneOfTheAbove"];
23783
- return existingReasons;
23784
- };
23785
- function TrustRoleAndEntityTypeComponent(props) {
24253
+ const TrustRoleAndEntityType = (props) => {
23786
24254
  const {
23787
- trustMember,
24255
+ existingTrustMember,
23788
24256
  id: id2
23789
24257
  } = props;
23790
24258
  const {
23791
24259
  i18n
23792
24260
  } = useCoreContext();
23793
- const defaultData = {
23794
- entityType: trustMember == null ? void 0 : trustMember.legalEntityType,
23795
- role: trustMember == null ? void 0 : trustMember.types,
23796
- descriptionUndefinedBeneficiary: trustMember == null ? void 0 : trustMember.descriptionUndefinedBeneficiary
23797
- };
23798
- if (couldBeExemptSettlor(defaultData)) {
23799
- defaultData.settlorExemptionReason = convertExistingSettlorExemptionReasons(trustMember == null ? void 0 : trustMember.settlorExemptionReason);
23800
- }
24261
+ const defaultData = existingTrustMember ? convertExistingTrustMember(existingTrustMember) : {};
23801
24262
  const formUtils = formUtilities(props, i18n);
23802
24263
  const {
23803
24264
  data,
@@ -23806,7 +24267,10 @@ function TrustRoleAndEntityTypeComponent(props) {
23806
24267
  errors,
23807
24268
  fieldProblems,
23808
24269
  handleChangeFor,
23809
- isValid
24270
+ isValid,
24271
+ setData,
24272
+ setValid,
24273
+ setErrors
23810
24274
  } = useForm({
23811
24275
  ...props,
23812
24276
  schema: decideFields,
@@ -23849,6 +24313,19 @@ function TrustRoleAndEntityTypeComponent(props) {
23849
24313
  }
23850
24314
  handleChangeFor("settlorExemptionReason")(exemptionReasons);
23851
24315
  };
24316
+ const nameProps = getFieldProps(props, nameFields);
24317
+ const onNameChange = ({
24318
+ data: data2,
24319
+ valid: valid2,
24320
+ errors: errors2
24321
+ }) => {
24322
+ setData("firstName", data2.firstName);
24323
+ setValid("firstName", valid2.firstName);
24324
+ setErrors("firstName", errors2.firstName);
24325
+ setData("lastName", data2.lastName);
24326
+ setValid("lastName", valid2.lastName);
24327
+ setErrors("lastName", errors2.lastName);
24328
+ };
23852
24329
  return o("form", {
23853
24330
  className: "adyen-kyc-trust__role-and-entity-type adl-u-width-full",
23854
24331
  children: [o(FormHeader, {
@@ -23882,7 +24359,7 @@ function TrustRoleAndEntityTypeComponent(props) {
23882
24359
  errorMessage: formUtils.getErrorMessage("entityType", errors, fieldProblems),
23883
24360
  label: formUtils.getLabel("entityType", "whatTypeOfYourMembersEntity"),
23884
24361
  classNameModifiers: ["entityType"],
23885
- disabled: !!(trustMember == null ? void 0 : trustMember.reference),
24362
+ disabled: Boolean(existingTrustMember),
23886
24363
  children: (childProps) => o(RadioCardSelect, {
23887
24364
  ...childProps,
23888
24365
  options: trustMemberLegalEntityTypes,
@@ -23928,14 +24405,29 @@ function TrustRoleAndEntityTypeComponent(props) {
23928
24405
  name: i18n.get(reason)
23929
24406
  })
23930
24407
  })
23931
- })]
24408
+ }), (schema == null ? void 0 : schema.includes("firstName")) || schema.includes("lastName") ? o(Name, {
24409
+ ...nameProps,
24410
+ data: {
24411
+ firstName: defaultData.firstName,
24412
+ lastName: defaultData.lastName
24413
+ },
24414
+ requiredFields: schema.filter((field) => nameFields.includes(field)),
24415
+ labels: {
24416
+ firstName: "firstNameOfSettlor",
24417
+ lastName: "lastNameOfSettlor",
24418
+ enterNameExactlyAsAppearInID: "enterSettlorsFirstNameExactlyAsItAppearsInID",
24419
+ enterLastNameExactlyAsAppearInID: "enterSettlorsLastNameExactlyAsItAppearsInID"
24420
+ },
24421
+ onChange: onNameChange,
24422
+ dataStoreId: id2
24423
+ }) : void 0]
23932
24424
  });
23933
- }
24425
+ };
23934
24426
  const summary = {
23935
24427
  formId: "summary",
23936
24428
  formName: "summary"
23937
24429
  };
23938
- const roleAndTypeForms = {
24430
+ const regularForms = {
23939
24431
  roleAndEntityType: {
23940
24432
  formId: "roleAndEntityType",
23941
24433
  formName: "roleAndEntityType",
@@ -23963,124 +24455,98 @@ const exemptSettlorForms = {
23963
24455
  },
23964
24456
  summary
23965
24457
  };
23966
- const logger$3 = createLogger("RoleAndTypeDropin");
23967
- function RoleAndTypeDropinComponent(props) {
23968
- var _a, _b;
24458
+ const decideForms = (trustMember) => {
24459
+ if (trustMember === "incomplete")
24460
+ return regularForms;
24461
+ switch (trustMember.trustMemberType) {
24462
+ case "undefinedBeneficiary":
24463
+ return undefinedBeneficiaryForms;
24464
+ case "exemptSettlor":
24465
+ return exemptSettlorForms;
24466
+ case "rootTrustee":
24467
+ case "regular":
24468
+ case "company":
24469
+ return regularForms;
24470
+ }
24471
+ };
24472
+ const convertDataToTrustMember = (data, existingTrustMember) => {
24473
+ var _a;
24474
+ const existingId = existingTrustMember ? existingTrustMember.trustMemberType === "undefinedBeneficiary" ? existingTrustMember.reference : existingTrustMember.legalEntityId : void 0;
24475
+ if ((_a = data.role) == null ? void 0 : _a.length) {
24476
+ if (isExemptSettlor(data))
24477
+ return {
24478
+ trustMemberType: "exemptSettlor",
24479
+ roles: [TrustMemberTypes.SETTLOR],
24480
+ legalEntityType: LegalEntityType.INDIVIDUAL,
24481
+ settlorExemptionReason: data.settlorExemptionReason.filter((reason) => reason !== "noneOfTheAbove"),
24482
+ exemptSettlorName: {
24483
+ firstName: data.firstName ?? "",
24484
+ lastName: data.lastName ?? ""
24485
+ },
24486
+ legalEntityId: existingId ?? ""
24487
+ };
24488
+ if (data.role.includes("undefinedBeneficiary"))
24489
+ return {
24490
+ trustMemberType: "undefinedBeneficiary",
24491
+ roles: [TrustMemberTypes.UNDEFINED_BENEFICIARY],
24492
+ description: data.descriptionUndefinedBeneficiary ?? "",
24493
+ reference: existingId ?? ""
24494
+ };
24495
+ if (data.entityType === LegalEntityType.ORGANIZATION)
24496
+ return {
24497
+ trustMemberType: "company",
24498
+ roles: data.role,
24499
+ legalEntityType: LegalEntityType.ORGANIZATION,
24500
+ legalEntityId: existingId ?? "",
24501
+ name: ""
24502
+ };
24503
+ if (data.entityType === LegalEntityType.INDIVIDUAL)
24504
+ return {
24505
+ trustMemberType: "regular",
24506
+ roles: data.role,
24507
+ legalEntityType: LegalEntityType.INDIVIDUAL,
24508
+ legalEntityId: existingId ?? "",
24509
+ name: ""
24510
+ };
24511
+ }
24512
+ return "incomplete";
24513
+ };
24514
+ function RoleAndTypeDropinComponent({
24515
+ existingTrustMember,
24516
+ navigateToFullDropinFor,
24517
+ navigateBack,
24518
+ addOrUpdateTrustMember
24519
+ }) {
23969
24520
  const {
23970
24521
  i18n
23971
24522
  } = useCoreContext();
23972
- const {
23973
- showToast
23974
- } = useToastContext();
23975
- const [trustMember, setTrustMember] = h(props.trustMember);
24523
+ const [trustMember, setTrustMember] = h(existingTrustMember ?? "incomplete");
23976
24524
  const [shouldValidate, setShouldValidate] = h(false);
23977
- const roleAndEntityTypeFormID = "roleAndEntityType";
23978
- const [formList, setFormList] = h([...Object.values(roleAndTypeForms)]);
24525
+ const formList = decideForms(trustMember);
24526
+ const forms = Object.values(formList);
23979
24527
  const [formValidity, setFormValidity] = h({
23980
- [roleAndEntityTypeFormID]: false
24528
+ roleAndEntityType: false
23981
24529
  });
23982
- const taskName = "trustMembers";
23983
- const [activeForm, setActiveForm] = h(formList[0]);
24530
+ const [activeForm, setActiveForm] = h(regularForms.roleAndEntityType);
23984
24531
  const isSummaryStep = activeForm.formId === summaryStep.formId;
23985
- const trustMemberCase = ((_a = trustMember == null ? void 0 : trustMember.settlorExemptionReason) == null ? void 0 : _a.length) ? "exemptSettlor" : ((_b = trustMember == null ? void 0 : trustMember.types) == null ? void 0 : _b.includes(TrustMemberTypes.UNDEFINED_BENEFICIARY)) ? "undefinedBeneficiary" : "fullEntity";
23986
- const navigateToTrustMember = () => {
23987
- const trustMemberAssociation = {
23988
- ...props.trustMember,
23989
- legalEntityType: trustMember == null ? void 0 : trustMember.legalEntityType,
23990
- types: trustMember == null ? void 0 : trustMember.types
23991
- };
23992
- props.navigateNext(trustMemberAssociation);
23993
- };
23994
- const submitExemptSettlor = async (exemptSettlor, trustLE) => {
23995
- var _a2;
23996
- const existingTrustMembers = getOwnTrustMembers(trustLE);
23997
- const existingSettlor = existingTrustMembers.find((member) => member.type === "settlor");
23998
- const updatedAssociations = [...(trustLE.entityAssociations ?? []).filter((association) => association !== existingSettlor), exemptSettlor];
23999
- const updatedTrustLE = {
24000
- ...trustLE,
24001
- entityAssociations: updatedAssociations
24002
- };
24003
- try {
24004
- await ((_a2 = props.handleUpdateLegalEntity) == null ? void 0 : _a2.call(props, updatedTrustLE, trustLE.id));
24005
- showToast({
24006
- label: i18n.get("successfullyUpdatedDetails"),
24007
- type: ToastType.SUCCESS
24008
- });
24009
- props.onSubmit(updatedTrustLE);
24010
- } catch (e2) {
24011
- logger$3.error(e2);
24012
- showToast({
24013
- label: i18n.get("failedToUpdateDetails"),
24014
- type: ToastType.ERROR
24015
- });
24016
- }
24017
- };
24018
- const submitUndefinedBeneficiary = async () => {
24019
- var _a2, _b2, _c;
24020
- if (((_a2 = props.trustMember) == null ? void 0 : _a2.descriptionUndefinedBeneficiary) === (trustMember == null ? void 0 : trustMember.descriptionUndefinedBeneficiary)) {
24021
- props.onSubmit(props.trust);
24022
- return;
24023
- }
24024
- const existingUndefinedBeneficiaryInfo = (((_b2 = props.trust.trust) == null ? void 0 : _b2.undefinedBeneficiaryInfo) ?? []).filter((ub) => ub.reference !== (trustMember == null ? void 0 : trustMember.reference));
24025
- const updatedTrust = {
24026
- trust: {
24027
- undefinedBeneficiaryInfo: [{
24028
- ...(trustMember == null ? void 0 : trustMember.reference) && {
24029
- reference: trustMember == null ? void 0 : trustMember.reference
24030
- },
24031
- description: (trustMember == null ? void 0 : trustMember.descriptionUndefinedBeneficiary) || ""
24032
- }, ...existingUndefinedBeneficiaryInfo]
24033
- }
24034
- };
24035
- try {
24036
- await ((_c = props.handleUpdateLegalEntity) == null ? void 0 : _c.call(props, updatedTrust, props.trust.id));
24037
- showToast({
24038
- label: i18n.get("successfullyUpdatedDetails"),
24039
- type: ToastType.SUCCESS
24040
- });
24041
- props.onSubmit(updatedTrust);
24042
- } catch (e2) {
24043
- logger$3.error(e2);
24044
- showToast({
24045
- label: i18n.get("failedToUpdateDetails"),
24046
- type: ToastType.ERROR
24047
- });
24048
- }
24049
- };
24050
24532
  const formatRolesForSummary = (roles) => roles.map((role2) => i18n.get(getTrustMemberName(role2))).join(", ");
24051
24533
  const formatSettlorExemptionReasonsForSummary = (reasons) => reasons.map((reason) => i18n.get(reason)).join(", ");
24052
- const summaryData = {
24534
+ const summaryData = trustMember === "incomplete" ? {} : {
24053
24535
  roleAndEntityType: {
24054
- role: formatRolesForSummary((trustMember == null ? void 0 : trustMember.types) ?? []),
24055
- entityType: (trustMember == null ? void 0 : trustMember.legalEntityType) ? i18n.get(trustMember == null ? void 0 : trustMember.legalEntityType) : void 0,
24056
- descriptionUndefinedBeneficiary: trustMember == null ? void 0 : trustMember.descriptionUndefinedBeneficiary,
24057
- otherInformation: formatSettlorExemptionReasonsForSummary((trustMember == null ? void 0 : trustMember.settlorExemptionReason) ?? [])
24536
+ role: formatRolesForSummary(trustMember.roles),
24537
+ entityType: trustMember.trustMemberType !== "undefinedBeneficiary" ? i18n.get(trustMember.legalEntityType) : void 0,
24538
+ descriptionUndefinedBeneficiary: trustMember.trustMemberType === "undefinedBeneficiary" ? trustMember.description : void 0,
24539
+ otherInformation: trustMember.trustMemberType === "exemptSettlor" ? formatSettlorExemptionReasonsForSummary(trustMember.settlorExemptionReason ?? []) : void 0,
24540
+ firstName: trustMember.trustMemberType === "exemptSettlor" ? trustMember.exemptSettlorName.firstName : void 0,
24541
+ lastName: trustMember.trustMemberType === "exemptSettlor" ? trustMember.exemptSettlorName.lastName : void 0
24058
24542
  }
24059
24543
  };
24060
24544
  const onNavigateToNextStep = () => {
24061
- if (isSummaryStep) {
24062
- switch (trustMemberCase) {
24063
- case "exemptSettlor":
24064
- if (!trustMember)
24065
- return;
24066
- submitExemptSettlor(trustMember, props.trust).catch(logger$3.error);
24067
- break;
24068
- case "undefinedBeneficiary":
24069
- submitUndefinedBeneficiary().catch(logger$3.error);
24070
- break;
24071
- default:
24072
- return;
24073
- }
24074
- }
24075
- if (!formValidity[roleAndEntityTypeFormID]) {
24076
- setShouldValidate(true);
24545
+ if (isSummaryStep && trustMember !== "incomplete") {
24546
+ addOrUpdateTrustMember(trustMember);
24077
24547
  return;
24078
24548
  }
24079
- if (trustMemberCase === "fullEntity") {
24080
- navigateToTrustMember();
24081
- } else {
24082
- setActiveForm(summary);
24083
- }
24549
+ gotoFormByFormIndex(forms.findIndex((form) => form.formId === activeForm.formId) + 1);
24084
24550
  };
24085
24551
  const onTrustMemberChange = ({
24086
24552
  data,
@@ -24093,69 +24559,51 @@ function RoleAndTypeDropinComponent(props) {
24093
24559
  [dataStoreId]: isValid
24094
24560
  });
24095
24561
  }
24096
- if ((data == null ? void 0 : data.role) && data.role.includes(TrustMemberTypes.UNDEFINED_BENEFICIARY)) {
24097
- setFormList([...Object.values(undefinedBeneficiaryForms)]);
24098
- } else if (isExemptSettlor(data)) {
24099
- setFormList([...Object.values(exemptSettlorForms)]);
24100
- } else {
24101
- setFormList([...Object.values(roleAndTypeForms)]);
24102
- }
24103
- setTrustMember({
24104
- ...props.trustMember,
24105
- ...data.role ? {
24106
- types: data.role
24107
- } : {},
24108
- legalEntityType: data.entityType,
24109
- ...data.descriptionUndefinedBeneficiary ? {
24110
- descriptionUndefinedBeneficiary: data.descriptionUndefinedBeneficiary
24111
- } : {},
24112
- ...isExemptSettlor(data) ? {
24113
- settlorExemptionReason: data.settlorExemptionReason.filter((reason) => reason !== "noneOfTheAbove")
24114
- } : {}
24115
- });
24562
+ setTrustMember(convertDataToTrustMember(data, existingTrustMember));
24116
24563
  };
24117
24564
  const saveRolesAndNavigate = async () => {
24118
- var _a2, _b2, _c;
24119
- if (!trustMember) {
24565
+ if (trustMember === "incomplete")
24120
24566
  return;
24567
+ if (hasRolesChanged(trustMember.roles, existingTrustMember == null ? void 0 : existingTrustMember.roles)) {
24568
+ addOrUpdateTrustMember(trustMember);
24121
24569
  }
24122
- const {
24123
- reference
24124
- } = trustMember;
24125
- if (reference && hasRolesChanged(trustMember.types, (_a2 = props.trustMember) == null ? void 0 : _a2.types) && props.trust.id) {
24126
- const existingTrustAssociations = getOwnEntityAssociations(props.trust);
24127
- const updatedTrustAssociations = {
24128
- entityAssociations: [...((_b2 = trustMember.types) == null ? void 0 : _b2.map((role2) => ({
24129
- type: role2,
24130
- reference
24131
- }))) || [], ...existingTrustAssociations.filter((ea) => ea.legalEntityId !== trustMember.reference) || []]
24132
- };
24133
- await ((_c = props.handleUpdateLegalEntity) == null ? void 0 : _c.call(props, updatedTrustAssociations, props.trust.id));
24134
- }
24135
- props.navigateBack();
24570
+ navigateBack();
24136
24571
  };
24137
24572
  const hasRolesChanged = (newRoles = [], existingRoles = []) => newRoles.length !== existingRoles.length || !newRoles.every((newRole) => existingRoles.includes(newRole));
24138
- const formsWithValidity = Object.values(formList).map((form) => ({
24573
+ const formsWithValidity = forms.map((form) => ({
24139
24574
  formId: form.formId,
24140
24575
  formName: form.formName,
24141
24576
  isValid: formValidity[form.formId]
24142
24577
  }));
24143
24578
  const gotoFormByFormIndex = (formIndex) => {
24144
- setActiveForm(formList[formIndex]);
24579
+ const targetForm = forms[formIndex];
24580
+ if (!formValidity.roleAndEntityType || trustMember === "incomplete") {
24581
+ setShouldValidate(true);
24582
+ return;
24583
+ }
24584
+ if (trustMember.trustMemberType === "regular" || trustMember.trustMemberType === "company") {
24585
+ if (targetForm.formId === regularForms.memberDetails.formId) {
24586
+ navigateToFullDropinFor(trustMember);
24587
+ return;
24588
+ }
24589
+ if (targetForm.formId === summaryStep.formId)
24590
+ return;
24591
+ }
24592
+ setActiveForm(targetForm);
24145
24593
  };
24146
24594
  const content = o(Fragment, {
24147
24595
  children: [o(FormNavigation, {
24148
24596
  forms: formsWithValidity,
24149
24597
  activeForm: formsWithValidity.find((form) => form.formId === activeForm.formId),
24150
- taskName,
24151
- gotoForm: noop
24598
+ taskName: "trustMembers",
24599
+ gotoForm: gotoFormByFormIndex
24152
24600
  }), o("div", {
24153
24601
  className: "adyen-kyc-form-container",
24154
24602
  children: [o("div", {
24155
24603
  className: activeForm.formId !== "roleAndEntityType" ? "adyen-kyc-form-wrapper adyen-kyc-form-wrapper--hidden" : "adyen-kyc-form-wrapper",
24156
- children: o(TrustRoleAndEntityTypeComponent, {
24157
- id: roleAndEntityTypeFormID,
24158
- trustMember: props.trustMember,
24604
+ children: o(TrustRoleAndEntityType, {
24605
+ id: "roleAndEntityType",
24606
+ existingTrustMember,
24159
24607
  onChange: onTrustMemberChange,
24160
24608
  shouldValidate
24161
24609
  })
@@ -24699,7 +25147,7 @@ function withFormComposer(WrappedComponent, {
24699
25147
  getConfigFor = "contextCountry"
24700
25148
  }) {
24701
25149
  const WithFormComposer = (props) => {
24702
- var _a, _b, _c, _d, _e;
25150
+ var _a, _b, _c;
24703
25151
  const {
24704
25152
  i18n,
24705
25153
  loadingContext,
@@ -25045,7 +25493,7 @@ function withFormComposer(WrappedComponent, {
25045
25493
  validateForm: validateCurrentForm,
25046
25494
  taskName,
25047
25495
  trackNavigation: trackNavigation2,
25048
- hasVerificationErrors: ((_c = props == null ? void 0 : props.problems) == null ? void 0 : _c.verificationErrors) && ((_e = Object.keys((_d = props == null ? void 0 : props.problems) == null ? void 0 : _d.verificationErrors)) == null ? void 0 : _e.length) > 0
25496
+ verificationErrors: (_c = props == null ? void 0 : props.problems) == null ? void 0 : _c.verificationErrors
25049
25497
  })
25050
25498
  });
25051
25499
  const content = o(Fragment, {
@@ -25514,6 +25962,10 @@ function DropinComposerComponent({
25514
25962
  const [legalEntityType, setLegalEntityType] = h(null);
25515
25963
  const [solePropietor, setSolePropietor] = h(null);
25516
25964
  const [trust, setTrust] = h(null);
25965
+ const exemptSettlor = useExemptSettlor({
25966
+ trust,
25967
+ handleGetLegalEntity: args.handleGetLegalEntity
25968
+ });
25517
25969
  const [trustMember, setTrustMember] = h(null);
25518
25970
  const [pciTemplateResponse, setPciTemplateResponse] = h(null);
25519
25971
  const [pciStatus, setPciStatus] = h(null);
@@ -25655,6 +26107,101 @@ function DropinComposerComponent({
25655
26107
  }
25656
26108
  }
25657
26109
  };
26110
+ const deleteTrustMember = async (trustMember2) => {
26111
+ try {
26112
+ switch (trustMember2.trustMemberType) {
26113
+ case "regular":
26114
+ case "exemptSettlor":
26115
+ case "company":
26116
+ await deleteAssociatedTrustMember({
26117
+ associatedTrustMember: trustMember2,
26118
+ trust,
26119
+ handleUpdateLegalEntity: args.handleUpdateLegalEntity
26120
+ });
26121
+ break;
26122
+ case "undefinedBeneficiary":
26123
+ await deleteUndefinedBeneficiary({
26124
+ undefinedBeneficiary: trustMember2,
26125
+ trust,
26126
+ handleUpdateLegalEntity: args.handleUpdateLegalEntity
26127
+ });
26128
+ break;
26129
+ case "rootTrustee":
26130
+ throw new Error("Cannot delete root trustee");
26131
+ }
26132
+ await refreshTrust();
26133
+ showToast({
26134
+ type: ToastType.SUCCESS,
26135
+ label: i18n.get("successFullyRemovedTrustMember")
26136
+ });
26137
+ } catch (err) {
26138
+ logger$1.error(`Failed to delete trust member`, err);
26139
+ showToast({
26140
+ type: ToastType.ERROR,
26141
+ label: i18n.get("failedToRemoveTrustMember")
26142
+ });
26143
+ }
26144
+ };
26145
+ const addOrUpdateTrustMember = async (updated, existing) => {
26146
+ if ((existing == null ? void 0 : existing.trustMemberType) === "undefinedBeneficiary" && updated.trustMemberType === "undefinedBeneficiary" && existing.description === updated.description) {
26147
+ await refreshTrustAndRunOnSubmit(trust);
26148
+ return;
26149
+ }
26150
+ try {
26151
+ switch (updated.trustMemberType) {
26152
+ case "undefinedBeneficiary":
26153
+ await addOrUpdateUndefinedBeneficiary({
26154
+ newOrUpdated: updated,
26155
+ trust,
26156
+ handleUpdateLegalEntity: args.handleUpdateLegalEntity
26157
+ });
26158
+ break;
26159
+ case "exemptSettlor":
26160
+ if (!existing) {
26161
+ const newSettlorLE = await createExemptSettlor({
26162
+ exemptSettlor: updated,
26163
+ trust,
26164
+ handleCreateLegalEntity: args.handleCreateLegalEntity
26165
+ });
26166
+ updated.legalEntityId = newSettlorLE.id;
26167
+ }
26168
+ if (existing && !exemptSettlorNamesTheSame(existing, updated)) {
26169
+ await updateExemptSettlorName({
26170
+ exemptSettlor: updated,
26171
+ handleUpdateLegalEntity: args.handleUpdateLegalEntity
26172
+ });
26173
+ }
26174
+ await addOrUpdateAssociatedTrustMember({
26175
+ newOrUpdated: updated,
26176
+ trust,
26177
+ handleUpdateLegalEntity: args.handleUpdateLegalEntity
26178
+ });
26179
+ break;
26180
+ case "regular":
26181
+ case "company":
26182
+ await addOrUpdateAssociatedTrustMember({
26183
+ newOrUpdated: updated,
26184
+ trust,
26185
+ handleUpdateLegalEntity: args.handleUpdateLegalEntity
26186
+ });
26187
+ break;
26188
+ case "rootTrustee":
26189
+ default:
26190
+ logger$1.warn(`Updating trust member type "${trustMember.trustMemberType}" is not implemented.`);
26191
+ }
26192
+ showToast({
26193
+ label: i18n.get("successfullyUpdatedDetails"),
26194
+ type: ToastType.SUCCESS
26195
+ });
26196
+ await refreshTrustAndRunOnSubmit(trust);
26197
+ } catch (err) {
26198
+ logger$1.error(err);
26199
+ showToast({
26200
+ label: i18n.get("failedToUpdateDetails"),
26201
+ type: ToastType.ERROR
26202
+ });
26203
+ }
26204
+ };
25658
26205
  const onNavigateTo = (task) => {
25659
26206
  setTaskHistory([...taskHistory, task]);
25660
26207
  onNavigate(task);
@@ -25735,14 +26282,14 @@ function DropinComposerComponent({
25735
26282
  };
25736
26283
  const onNavigateToTrustMember = async (tm) => {
25737
26284
  try {
25738
- if (tm == null ? void 0 : tm.reference) {
25739
- const response = await (args == null ? void 0 : args.handleGetLegalEntity(tm.reference));
26285
+ if (tm == null ? void 0 : tm.legalEntityId) {
26286
+ const response = await (args == null ? void 0 : args.handleGetLegalEntity(tm.legalEntityId));
25740
26287
  setAssociatedLegalEntity(response);
25741
26288
  } else {
25742
26289
  setAssociatedLegalEntity(null);
25743
26290
  }
25744
26291
  setTrustMember(tm);
25745
- onNavigateTo(tm.legalEntityType === LegalEntityType.ORGANIZATION ? TaskTypes.TRUST_MEMBER_COMPANY : TaskTypes.TRUST_MEMBER_INDIVIDUAL);
26292
+ onNavigateTo(tm.trustMemberType === "company" ? TaskTypes.TRUST_MEMBER_COMPANY : TaskTypes.TRUST_MEMBER_INDIVIDUAL);
25746
26293
  } catch (e2) {
25747
26294
  showToast({
25748
26295
  label: i18n.get("failedToFetchTrustMemberDetails"),
@@ -25751,11 +26298,7 @@ function DropinComposerComponent({
25751
26298
  }
25752
26299
  };
25753
26300
  const onNavigateToTrustMemberRoleAndType = (tm) => {
25754
- if (tm) {
25755
- setTrustMember(tm);
25756
- } else {
25757
- setTrustMember(null);
25758
- }
26301
+ setTrustMember(tm === "new" ? null : tm);
25759
26302
  onNavigateTo(TaskTypes.TRUST_MEMBER_ROLE_AND_TYPE);
25760
26303
  };
25761
26304
  const navigateBack = (stepCount = 1) => {
@@ -26026,7 +26569,7 @@ function DropinComposerComponent({
26026
26569
  handleBackClick: navigateBack,
26027
26570
  handleHomeClick: () => onNavigateTo(TaskTypes.TRUST_MEMBER_OVERVIEW),
26028
26571
  homeButtonLabel: i18n.get("saveAndGoToOverview"),
26029
- associationDetail: trustMember,
26572
+ trustMember,
26030
26573
  handleAddressSearch: args == null ? void 0 : args.handleAddressSearch,
26031
26574
  handleFindAddress: args == null ? void 0 : args.handleFindAddress,
26032
26575
  handleGetIdVerificationToken: args == null ? void 0 : args.handleGetIdVerificationToken
@@ -26123,27 +26666,23 @@ function DropinComposerComponent({
26123
26666
  handleFindAddress: args == null ? void 0 : args.handleFindAddress
26124
26667
  });
26125
26668
  case TaskTypes.TRUST_MEMBER_OVERVIEW:
26126
- return o(TrustMembersComponent, {
26127
- parentLegalEntity: legalEntity,
26128
- trustResponse: trust,
26129
- capabilityProblems,
26669
+ return o(TrustMembersOverview, {
26670
+ trustMembers: getTrustMembers(trust, legalEntity, exemptSettlor),
26671
+ getTrustMemberTaskStatus: (member) => getTaskStatus(EntityType.LEGAL_ENTITY, capabilityProblems, legalEntity, member.trustMemberType === "undefinedBeneficiary" ? void 0 : [member.legalEntityId]),
26672
+ navigateBackToTaskList: navigateBack,
26130
26673
  navigateToEditTrustMember: onNavigateToTrustMemberRoleAndType,
26131
26674
  navigateToEditTrustMemberOwner: (trustMemberOwnerId, trustMemberId) => onNavigateToDecisionMakerIndividual(TaskTypes.TRUST_MEMBER_COMPANY_OWNER, trustMemberOwnerId, trustMemberId),
26132
- navigateBackToTaskList: navigateBack,
26133
- handleUpdateLegalEntity: args == null ? void 0 : args.handleUpdateLegalEntity,
26134
- onTrustMemberDelete: refreshTrust
26675
+ deleteTrustMember
26135
26676
  });
26136
26677
  case TaskTypes.TRUST_MEMBER_ROLE_AND_TYPE:
26137
26678
  return o(RoleAndTypeDropinComponent, {
26138
- navigateNext: onNavigateToTrustMember,
26679
+ navigateToFullDropinFor: onNavigateToTrustMember,
26139
26680
  navigateBack: async () => {
26140
26681
  await refreshTrust();
26141
26682
  navigateBack();
26142
26683
  },
26143
- trust,
26144
- trustMember,
26145
- handleUpdateLegalEntity: args == null ? void 0 : args.handleUpdateLegalEntity,
26146
- onSubmit: refreshTrustAndRunOnSubmit
26684
+ existingTrustMember: trustMember,
26685
+ addOrUpdateTrustMember: (newOrUpdated) => addOrUpdateTrustMember(newOrUpdated, trustMember)
26147
26686
  });
26148
26687
  case TaskTypes.PCI_DSS:
26149
26688
  return o(PciDropinComponent, {