@adyen/kyc-components 2.4.0 → 2.4.2

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.
@@ -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";
@@ -1266,6 +1276,9 @@ const defaultTrans = {
1266
1276
  invalidFormatForAuDriversLicenseNumber,
1267
1277
  invalidFormatForAuDriversLicenseCardNumber,
1268
1278
  invalidFormatForAuProofOfIdentityCardNumber,
1279
+ invalidFormatForHKPassportNumber,
1280
+ invalidFormatForHKDriversLicenseNumber,
1281
+ invalidFormatForHKIdentityCardNumber,
1269
1282
  invalidFormatIdentityNumberBR,
1270
1283
  invalidFormatIdentityNumberDK,
1271
1284
  invalidFormatIdentityNumberCA,
@@ -1277,6 +1290,7 @@ const defaultTrans = {
1277
1290
  invalidFormatIdentityNumberUS,
1278
1291
  invalidFormatIdentityNumberUS9,
1279
1292
  invalidFormatIdentityNumberSG,
1293
+ invalidFormatIdentityNumberHK,
1280
1294
  invalidFormatBankStatementDescription,
1281
1295
  residencyCountry,
1282
1296
  stateOrProvince,
@@ -1293,6 +1307,7 @@ const defaultTrans = {
1293
1307
  driversLicense,
1294
1308
  issuerState,
1295
1309
  licenseNumber,
1310
+ driverLicense,
1296
1311
  licenseCardNumber,
1297
1312
  documents,
1298
1313
  idDocument: idDocument$1,
@@ -1369,6 +1384,7 @@ const defaultTrans = {
1369
1384
  validationPleaseEnterAValidTaxIdNumberWithFormat,
1370
1385
  aValidAbnShouldBe11Digits,
1371
1386
  aValidUenOrGstShouldBe9To10Characters,
1387
+ aValidBrnShouldBe8Digits,
1372
1388
  validationPleaseEnterAValidUen,
1373
1389
  validationPleaseEnterAValidIban,
1374
1390
  yourIbanShouldBeginWith_,
@@ -1404,6 +1420,7 @@ const defaultTrans = {
1404
1420
  legalCompanyNameHelper__AU,
1405
1421
  legalCompanyNameHelper__US,
1406
1422
  legalCompanyNameHelper__SG,
1423
+ legalCompanyNameHelper__HK,
1407
1424
  accountDetailsDescription,
1408
1425
  provideDetails,
1409
1426
  payoutAccountsDescription,
@@ -1613,6 +1630,7 @@ const defaultTrans = {
1613
1630
  NIF,
1614
1631
  uen,
1615
1632
  nric,
1633
+ hkid,
1616
1634
  NIFdeIVA,
1617
1635
  partitaIVA,
1618
1636
  organisationsnummer,
@@ -1635,6 +1653,7 @@ const defaultTrans = {
1635
1653
  leave,
1636
1654
  taxIdNumber,
1637
1655
  companyRegistrationNumber,
1656
+ companyRegistrationNumber__HK,
1638
1657
  euVatNumber,
1639
1658
  vatNumber,
1640
1659
  regonKrsNumber,
@@ -1897,6 +1916,7 @@ const defaultTrans = {
1897
1916
  xCharactersLeft,
1898
1917
  goBack,
1899
1918
  businessRegistrationNumber,
1919
+ businessRegistrationNumber__HK,
1900
1920
  doNotHaveBusinessNumber,
1901
1921
  "UEN/GST": "Unique Entity Number (UEN)/Goods and Services Tax (GST)",
1902
1922
  "IRD/GST": "Inland Revenue Department Number (IRD No)/Goods and Services Tax (GST)",
@@ -3606,6 +3626,17 @@ const useStaticValidator = (rules2) => {
3606
3626
  triggerStaticValidation
3607
3627
  };
3608
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
+ };
3609
3640
  function useForm({
3610
3641
  schema,
3611
3642
  defaultData,
@@ -3639,21 +3670,9 @@ function useForm({
3639
3670
  asyncValidate: triggerAsyncValidation
3640
3671
  }), [defaultData, fieldProblems, maskedFields, formatters, getRequiredFields, triggerStaticValidation, triggerAsyncValidation]);
3641
3672
  const [state2, dispatch] = s(getReducer(), getInitialData(), init);
3642
- const [formErrors, setFormErrors] = h(state2.errors);
3643
- const mergeAsyncErrorsState = T$1((staticValidationErrors, asyncValidationErrors) => {
3644
- if (!state2.schema.length)
3645
- return staticValidationErrors;
3646
- return state2.schema.reduce((acc, field) => {
3647
- var _a;
3648
- return {
3649
- ...acc,
3650
- [field]: staticValidationErrors[field] ?? ((_a = asyncValidationErrors[field]) == null ? void 0 : _a.getError()) ?? null
3651
- };
3652
- }, {});
3653
- }, [state2.schema]);
3654
3673
  const isValid = F$1(() => {
3655
3674
  var _a;
3656
- 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]);
3657
3676
  }, [state2.schema, state2.valid]);
3658
3677
  const getTargetValue = T$1((key, e2) => {
3659
3678
  if (!(e2 == null ? void 0 : e2.target))
@@ -3726,9 +3745,7 @@ function useForm({
3726
3745
  setFieldProblems(fieldProblems);
3727
3746
  }
3728
3747
  }, [JSON.stringify(fieldProblems), setFieldProblems]);
3729
- p(() => {
3730
- setFormErrors(mergeAsyncErrorsState(state2.errors, asyncValidationResults));
3731
- }, [mergeAsyncErrorsState, asyncValidationResults, state2.errors]);
3748
+ const formErrors = F$1(() => mergeStaticAndAsyncErrorsState(state2.errors, asyncValidationResults, state2.schema), [asyncValidationResults, state2.errors]);
3732
3749
  return {
3733
3750
  mergeForm,
3734
3751
  setData,
@@ -4522,7 +4539,7 @@ const lengthValidationPatterns = {
4522
4539
  message: "validationEnter9Or12Digits"
4523
4540
  }
4524
4541
  };
4525
- 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-."_,:;'*!@#%()+?¿/&「」]*$/;
4542
+ 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-."_,:;'*!@#%()+?¿/&「」]*$/;
4526
4543
  const businessRegistrationNumberPatterns = {
4527
4544
  [CountryCodes.Australia]: {
4528
4545
  default: {
@@ -5734,6 +5751,13 @@ const countryBasedValidatorRules$1 = {
5734
5751
  validate: (taxId2) => validateTaxId(taxId2, "SG"),
5735
5752
  errorMessage: "aValidUenOrGstShouldBe9To10Characters"
5736
5753
  }]
5754
+ },
5755
+ HK: {
5756
+ taxId: [{
5757
+ modes: ["blur"],
5758
+ validate: (taxId2) => validateTaxId(taxId2, "HK"),
5759
+ errorMessage: "aValidBrnShouldBe8Digits"
5760
+ }]
5737
5761
  }
5738
5762
  };
5739
5763
  const taxIdFields = ["taxId", "exemptedFromTax"];
@@ -7668,7 +7692,7 @@ function CompanyDetailsComponent(props) {
7668
7692
  ...taxIdProps,
7669
7693
  dataStoreId: COMPANY_DETAILS,
7670
7694
  country: props.country
7671
- }), props.country === "SG" && formUtils.isRequiredField("dateOfIncorporation") && o(Field, {
7695
+ }), formUtils.isRequiredField("dateOfIncorporation") && o(Field, {
7672
7696
  name: "dateOfIncorporation",
7673
7697
  label: formUtils.getLabel("dateOfIncorporation"),
7674
7698
  classNameModifiers: ["dateOfIncorporation"],
@@ -8451,10 +8475,10 @@ const countryConfig$4 = {
8451
8475
  label: "businessName"
8452
8476
  },
8453
8477
  registrationNumber: {
8454
- label: "companyNumber"
8478
+ label: "companyRegistrationNumber__HK"
8455
8479
  },
8456
8480
  taxId: {
8457
- label: "businessRegistrationNumber"
8481
+ label: "businessRegistrationNumber__HK"
8458
8482
  }
8459
8483
  },
8460
8484
  [CountryCodes.Hungary]: {
@@ -8948,7 +8972,7 @@ var TaskStatus = /* @__PURE__ */ ((TaskStatus2) => {
8948
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];
8949
8973
  const ID_NUMBER_EXEMPT_COUNTRIES = [CountryCodes.Canada, CountryCodes.UnitedStates];
8950
8974
  const ID_NUMBER_VERIFICATION_COUNTRIES = [CountryCodes.UnitedStates];
8951
- const COUNTRIES_WHICH_USE_MULTIPLE_IDENTITY_TYPES = [CountryCodes.Australia];
8975
+ const COUNTRIES_WHICH_USE_MULTIPLE_IDENTITY_TYPES = [CountryCodes.HongKong, CountryCodes.Australia];
8952
8976
  const ID_NUMBER_REQUIRED_FOR_DIRECTOR_COUNTRIES = [CountryCodes.Singapore];
8953
8977
  const NATIONALITY_REQUIRED_FOR_COUNTRIES = [CountryCodes.Singapore];
8954
8978
  const rules$2 = ({
@@ -10010,6 +10034,7 @@ const ADDRESS_SCHEMAS = {
10010
10034
  [CountryCodes.Canada]: [COUNTRY, STREET, HOUSE_NUMBER, CITY, POSTAL_CODE, STATE],
10011
10035
  [CountryCodes.UnitedKingdom]: [COUNTRY, HOUSE_NUMBER, STREET, CITY, POSTAL_CODE, STATE],
10012
10036
  [CountryCodes.UnitedStates]: [COUNTRY, STREET, HOUSE_NUMBER, CITY, STATE, POSTAL_CODE],
10037
+ [CountryCodes.HongKong]: [COUNTRY, STREET, HOUSE_NUMBER, CITY, STATE],
10013
10038
  default: [COUNTRY, STREET, HOUSE_NUMBER, POSTAL_CODE, CITY, STATE]
10014
10039
  };
10015
10040
  const LABELS = {
@@ -10381,6 +10406,55 @@ const SearchAddress = ({
10381
10406
  })
10382
10407
  });
10383
10408
  };
10409
+ const createRegExpByDigits = (digits) => new RegExp(`^\\d{${digits}}$`);
10410
+ const postalCodePatterns = {
10411
+ [CountryCodes.Australia]: createRegExpByDigits(4),
10412
+ [CountryCodes.Austria]: createRegExpByDigits(4),
10413
+ [CountryCodes.Belgium]: /^[1-9]\d{3}$/,
10414
+ [CountryCodes.Brazil]: createRegExpByDigits(8),
10415
+ [CountryCodes.Bulgaria]: createRegExpByDigits(4),
10416
+ [CountryCodes.Canada]: /^[ABCEGHJKLMNPRSTVXY]\d[A-Z][ -]?(?:\d[A-Z]\d)?$/,
10417
+ [CountryCodes.Croatia]: /^([1-5])\d{4}$/,
10418
+ [CountryCodes.Cyprus]: createRegExpByDigits(4),
10419
+ [CountryCodes.CzechRepublic]: /^\d{3} ?\d{2}$/,
10420
+ [CountryCodes.Denmark]: /^(?:DK-)?\d{4}$/,
10421
+ [CountryCodes.Estonia]: createRegExpByDigits(5),
10422
+ [CountryCodes.Finland]: createRegExpByDigits(5),
10423
+ [CountryCodes.France]: createRegExpByDigits(5),
10424
+ [CountryCodes.Georgia]: createRegExpByDigits(4),
10425
+ [CountryCodes.Germany]: createRegExpByDigits(5),
10426
+ [CountryCodes.Gibraltar]: /^GX11[ -]?1AA$/,
10427
+ [CountryCodes.Greece]: /^\d{3} ?\d{2}$/,
10428
+ [CountryCodes.Hungary]: createRegExpByDigits(4),
10429
+ [CountryCodes.Iceland]: createRegExpByDigits(3),
10430
+ [CountryCodes.Ireland]: /^(?:[ACDEFHKNPRTVWXY]\d{2}|D6W)[ -]?[0-9ACDEFHKNPRTVWXY]{4}$/,
10431
+ [CountryCodes.Italy]: createRegExpByDigits(5),
10432
+ [CountryCodes.Japan]: /^\d{3}-\d{4}$/,
10433
+ [CountryCodes.Latvia]: /^(?:LV-)?\d{4}$/,
10434
+ [CountryCodes.Liechtenstein]: createRegExpByDigits(4),
10435
+ [CountryCodes.Lithuania]: /^(?:LT-)?\d{4,5}$/,
10436
+ [CountryCodes.Luxembourg]: createRegExpByDigits(4),
10437
+ [CountryCodes.Malaysia]: createRegExpByDigits(5),
10438
+ [CountryCodes.Malta]: /^[A-Za-z]{2,3} ?\d{2}(?:\d{2})?$/,
10439
+ [CountryCodes.Monaco]: /^980\d{2}$/,
10440
+ [CountryCodes.Netherlands]: /^(?:NL-)?[1-9]\d{3} ?(?:[ABCDEFGHIJKLMNOPQRTUVWXYZ][A-Z]|S[BCEFGHIJKLMNOPQRTUVWXYZ])$/,
10441
+ [CountryCodes.NewZealand]: createRegExpByDigits(4),
10442
+ [CountryCodes.Norway]: createRegExpByDigits(4),
10443
+ [CountryCodes.Poland]: /^\d{2}-\d{3}$/,
10444
+ [CountryCodes.Portugal]: /^[1-9]\d{3}([- ]?\d{3})?$/,
10445
+ [CountryCodes.PuertoRico]: createRegExpByDigits(5),
10446
+ [CountryCodes.Romania]: createRegExpByDigits(6),
10447
+ [CountryCodes.Slovakia]: /^(SK-)?\d{5}$/,
10448
+ [CountryCodes.Slovenia]: /^(SI-)?\d{4}$/,
10449
+ [CountryCodes.Singapore]: createRegExpByDigits(6),
10450
+ [CountryCodes.Spain]: /(?:0[1-9]|[1-4]\d|5[0-2])\d{3}/,
10451
+ [CountryCodes.Sweden]: createRegExpByDigits(5),
10452
+ [CountryCodes.Switzerland]: /^[1-9]\d{3}$/,
10453
+ // https://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom#Validation
10454
+ // follows most of the bullet points but not all the restrictions
10455
+ [CountryCodes.UnitedKingdom]: /^[ABCDEFGHIJKLMNOPRSTUWYZ](?:[ABCDEFGHKLMNOPQRSTUVWXY][0-9][ABEHMNPRVWXY0-9]?|[0-9][ABCDEFGHJKPSTUW0-9]?)(?: ?[0-9][ABDEFGHJLNPQRSTUWXYZ]{1,2})?$/,
10456
+ [CountryCodes.UnitedStates]: /^\d{5}(?:[ -]?\d{4})?$/
10457
+ };
10384
10458
  const createFormatByDigits = (digits) => {
10385
10459
  const format = new Array(digits).fill("9").join("");
10386
10460
  return {
@@ -10615,156 +10689,56 @@ const countrySpecificFormatters = {
10615
10689
  postalCode: createFormatByDigits(5)
10616
10690
  }
10617
10691
  };
10618
- const createPatternByDigits = (digits) => ({
10619
- pattern: new RegExp(`\\d{${digits}}`)
10620
- });
10621
- const postalCodePatterns = {
10622
- [CountryCodes.Australia]: createPatternByDigits(4),
10623
- [CountryCodes.Austria]: createPatternByDigits(4),
10624
- [CountryCodes.Belgium]: {
10625
- pattern: /(?:(?:[1-9])(?:\d{3}))/
10626
- },
10627
- [CountryCodes.Brazil]: createPatternByDigits(8),
10628
- [CountryCodes.Bulgaria]: createPatternByDigits(4),
10629
- [CountryCodes.Canada]: {
10630
- pattern: /(?:[ABCEGHJ-NPRSTVXY]\d[A-Z][ -]?\d[A-Z]\d)/
10631
- },
10632
- [CountryCodes.Croatia]: {
10633
- pattern: /^([1-5])[0-9]{4}$/
10634
- },
10635
- [CountryCodes.Cyprus]: createPatternByDigits(4),
10636
- [CountryCodes.CzechRepublic]: {
10637
- pattern: /\d{3}\s?\d{2}/
10638
- },
10639
- [CountryCodes.Denmark]: {
10640
- pattern: /^(DK-)?[0-9]{4}$/
10641
- },
10642
- [CountryCodes.Estonia]: createPatternByDigits(5),
10643
- [CountryCodes.Finland]: createPatternByDigits(5),
10644
- [CountryCodes.France]: createPatternByDigits(5),
10645
- [CountryCodes.Georgia]: createPatternByDigits(4),
10646
- [CountryCodes.Germany]: createPatternByDigits(5),
10647
- [CountryCodes.Gibraltar]: {
10648
- pattern: /^GX11[ -]?1AA$/
10649
- },
10650
- [CountryCodes.Greece]: {
10651
- pattern: /^\d{3}\s{0,1}\d{2}$/
10652
- },
10653
- [CountryCodes.Hungary]: createPatternByDigits(4),
10654
- [CountryCodes.Iceland]: createPatternByDigits(3),
10655
- [CountryCodes.Ireland]: {
10656
- pattern: /(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ -]?[0-9AC-FHKNPRTV-Y]{4}/
10657
- },
10658
- [CountryCodes.Italy]: createPatternByDigits(5),
10659
- [CountryCodes.Japan]: {
10660
- pattern: /^\d{3}[-]\d{4}$/
10661
- },
10662
- [CountryCodes.Latvia]: {
10663
- pattern: /^(LV-)?[0-9]{4}$/
10664
- },
10665
- [CountryCodes.Liechtenstein]: createPatternByDigits(4),
10666
- [CountryCodes.Lithuania]: {
10667
- pattern: /^(LT-)?[0-9]{4,5}$/
10668
- },
10669
- [CountryCodes.Luxembourg]: createPatternByDigits(4),
10670
- [CountryCodes.Malaysia]: createPatternByDigits(5),
10671
- [CountryCodes.Malta]: {
10672
- pattern: /^[A-Za-z]{2,3}[ ]?\d{2}(?:\d{2})?$/
10673
- },
10674
- [CountryCodes.Monaco]: {
10675
- pattern: /^980\d{2}$/
10676
- },
10677
- [CountryCodes.Netherlands]: {
10678
- pattern: /(?:NL-)?(?:[1-9]\d{3} ?(?:[A-EGHJ-NPRTVWXZ][A-EGHJ-NPRSTVWXZ]|S[BCEGHJ-NPRTVWXZ]))/
10679
- },
10680
- [CountryCodes.NewZealand]: createPatternByDigits(4),
10681
- [CountryCodes.Norway]: createPatternByDigits(4),
10682
- [CountryCodes.Poland]: {
10683
- pattern: /^\d{2}[-]\d{3}$/
10684
- },
10685
- [CountryCodes.Portugal]: {
10686
- pattern: /^([1-9]\d{3})([- ]?(\d{3})? *)$/
10687
- },
10688
- [CountryCodes.PuertoRico]: createPatternByDigits(5),
10689
- [CountryCodes.Romania]: createPatternByDigits(6),
10690
- [CountryCodes.Slovakia]: {
10691
- pattern: /^(SK-)?[0-9]{5}$/
10692
- },
10693
- [CountryCodes.Slovenia]: {
10694
- pattern: /^(SI-)?[0-9]{4}$/
10695
- },
10696
- [CountryCodes.Singapore]: createPatternByDigits(6),
10697
- [CountryCodes.Spain]: {
10698
- pattern: /(?:0[1-9]|[1-4]\d|5[0-2])\d{3}/
10699
- },
10700
- [CountryCodes.Sweden]: createPatternByDigits(5),
10701
- [CountryCodes.Switzerland]: {
10702
- pattern: /[1-9]\d{3}/
10703
- },
10704
- [CountryCodes.UnitedKingdom]: {
10705
- 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})$/
10706
- },
10707
- [CountryCodes.UnitedStates]: {
10708
- pattern: /^(\d{5})([-]?(\d{4})? *)$/
10709
- }
10710
- };
10711
- const addressValidationRules = {
10712
- street: {
10713
- modes: ["blur"],
10714
- validate: (val) => hasText(val),
10715
- errorMessage: "fieldIsRequired"
10716
- },
10717
- houseNumberOrName: {
10718
- modes: ["blur"],
10719
- validate: (val, context) => {
10720
- const {
10721
- country: country2
10722
- } = context.state.data;
10723
- if (country2 && COUNTRIES_WITH_OPTIONAL_HOUSE_NUMBER.includes(country2)) {
10724
- return true;
10725
- }
10726
- return hasText(val);
10692
+ const addressValidationRules = (country2) => {
10693
+ var _a, _b;
10694
+ const postalCodeFormat = (_b = (_a = countrySpecificFormatters[country2]) == null ? void 0 : _a.postalCode) == null ? void 0 : _b.format;
10695
+ return {
10696
+ street: {
10697
+ modes: ["blur"],
10698
+ validate: (val) => hasText(val),
10699
+ errorMessage: "fieldIsRequired"
10727
10700
  },
10728
- errorMessage: "fieldIsRequired"
10729
- },
10730
- postalCode: {
10731
- modes: ["blur"],
10732
- validate: (val, context) => {
10733
- var _a, _b;
10734
- const {
10735
- country: country2
10736
- } = context.state.data;
10737
- if (country2) {
10738
- addressValidationRules.postalCode.errorMessage = {
10739
- translationKey: "invalidFormatExpects",
10740
- translationObject: {
10741
- values: {
10742
- format: ((_a = countrySpecificFormatters[country2]) == null ? void 0 : _a.postalCode.format) || null
10743
- }
10701
+ houseNumberOrName: {
10702
+ modes: ["blur"],
10703
+ validate: (val) => {
10704
+ if (country2 && COUNTRIES_WITH_OPTIONAL_HOUSE_NUMBER.includes(country2)) {
10705
+ return true;
10706
+ }
10707
+ return hasText(val);
10708
+ },
10709
+ errorMessage: "fieldIsRequired"
10710
+ },
10711
+ postalCode: {
10712
+ modes: ["blur"],
10713
+ validate: (val) => {
10714
+ const pattern = postalCodePatterns[country2];
10715
+ return pattern ? !!val && pattern.test(val) : !!val;
10716
+ },
10717
+ errorMessage: postalCodeFormat ? {
10718
+ translationKey: "invalidFormatExpects",
10719
+ translationObject: {
10720
+ values: {
10721
+ format: postalCodeFormat
10744
10722
  }
10745
- };
10746
- const pattern = (_b = postalCodePatterns[country2]) == null ? void 0 : _b.pattern;
10747
- return pattern ? pattern.test(val) : !!val;
10748
- }
10749
- return !!val;
10723
+ }
10724
+ } : "invalidFormat"
10750
10725
  },
10751
- errorMessage: "fieldIsRequired"
10752
- },
10753
- city: {
10754
- modes: ["blur"],
10755
- validate: hasText,
10756
- errorMessage: "fieldIsRequired"
10757
- },
10758
- stateOrProvince: {
10759
- modes: ["blur"],
10760
- validate: (val) => !!val,
10761
- errorMessage: "fieldIsRequired"
10762
- },
10763
- country: {
10764
- modes: ["blur"],
10765
- validate: (val) => !!val,
10766
- errorMessage: "fieldIsRequired"
10767
- }
10726
+ city: {
10727
+ modes: ["blur"],
10728
+ validate: hasText,
10729
+ errorMessage: "fieldIsRequired"
10730
+ },
10731
+ stateOrProvince: {
10732
+ modes: ["blur"],
10733
+ validate: (val) => !!val,
10734
+ errorMessage: "fieldIsRequired"
10735
+ },
10736
+ country: {
10737
+ modes: ["blur"],
10738
+ validate: (val) => !!val,
10739
+ errorMessage: "fieldIsRequired"
10740
+ }
10741
+ };
10768
10742
  };
10769
10743
  function Address(props) {
10770
10744
  const {
@@ -10795,6 +10769,7 @@ function Address(props) {
10795
10769
  const addressFields = ADDRESS_SCHEMAS[dataProp == null ? void 0 : dataProp.country] ?? ADDRESS_SCHEMAS.default;
10796
10770
  const datasetUtils = datasetUtilities(i18n.locale);
10797
10771
  const requiredFields = (requiredFieldsProp == null ? void 0 : requiredFieldsProp.includes("stateOrProvince")) || dataProp.country && COUNTRIES_WITH_STATES_DATASET.includes(dataProp.country) ? addressFields : addressFields.filter((ad) => ad !== "stateOrProvince");
10772
+ const rules2 = F$1(() => addressValidationRules(dataProp.country), [dataProp.country]);
10798
10773
  const {
10799
10774
  data,
10800
10775
  errors,
@@ -10809,7 +10784,7 @@ function Address(props) {
10809
10784
  schema: requiredFields,
10810
10785
  defaultData: dataProp,
10811
10786
  formatters: addressFormatters,
10812
- rules: addressValidationRules,
10787
+ rules: rules2,
10813
10788
  fieldProblems: fieldValidationErrorsProp,
10814
10789
  maskedFields: []
10815
10790
  });
@@ -10836,11 +10811,6 @@ function Address(props) {
10836
10811
  setShowAddAddressButton(false);
10837
10812
  }
10838
10813
  }, []);
10839
- p(() => {
10840
- if (data.postalCode) {
10841
- handleChangeFor("postalCode", "blur")(data.postalCode);
10842
- }
10843
- }, [data.country]);
10844
10814
  p(() => {
10845
10815
  const processedData = ADDRESS_SCHEMA.reduce((acc, cur) => {
10846
10816
  if (!formUtils.isRequiredField(cur)) {
@@ -11555,7 +11525,7 @@ const COUNTRIES_WITH_POSSIBLE_TAX_EXEMPTION_FOR_SOLE_PROPS = [
11555
11525
  CountryCodes.Canada,
11556
11526
  CountryCodes.UnitedStates
11557
11527
  ];
11558
- const COUNTRIES_THAT_REQUIRE_DATE_OF_INCORPORATION = [CountryCodes.Singapore];
11528
+ const COUNTRIES_THAT_REQUIRE_DATE_OF_INCORPORATION = [CountryCodes.HongKong, CountryCodes.Singapore];
11559
11529
  const rules$1 = ({
11560
11530
  data,
11561
11531
  country: country2,
@@ -14226,7 +14196,7 @@ ContactDetailsComponent.defaultProps = {
14226
14196
  data: {}
14227
14197
  };
14228
14198
  const additionalIdentityInfoFields = ["typeOfIdentity", "licenseCardNumber", "issuerState"];
14229
- const identityTypes = ["nationalIdNumber", "passport", "driversLicense", "proofOfIdentityCard"];
14199
+ const identityTypes$1 = ["nationalIdNumber", "passport", "driversLicense", "proofOfIdentityCard"];
14230
14200
  function useGlobalData() {
14231
14201
  const {
14232
14202
  getData
@@ -14265,25 +14235,25 @@ function useResetGlobalData(caller) {
14265
14235
  }
14266
14236
  }), [dispatch, caller]);
14267
14237
  }
14268
- const isTruthyValidator = {
14238
+ const isTruthyValidator$1 = {
14269
14239
  validate: (value) => !!value,
14270
14240
  modes: ["blur"],
14271
14241
  errorMessage: "fieldIsRequired"
14272
14242
  };
14273
- const PASSPORT_NUMBER_PATTERN = /^[A-Z]{1,2}\d{7}$/;
14274
- const DRIVERS_LICENSE_NUMBER_PATTERN = /^[A-Za-z\d]{6,11}$/;
14275
- const PROOF_OF_IDENTITY_CARD_NUMBER_PATTERN = /^[A-Za-z\d]{6,10}$/;
14243
+ const PASSPORT_NUMBER_PATTERN$1 = /^[A-Z]{1,2}\d{7}$/;
14244
+ const DRIVERS_LICENSE_NUMBER_PATTERN$1 = /^[A-Za-z\d]{6,11}$/;
14245
+ const PROOF_OF_IDENTITY_CARD_NUMBER_PATTERN$1 = /^[A-Za-z\d]{6,10}$/;
14276
14246
  const auIdentityValidationRules = {
14277
- typeOfIdentity: [isTruthyValidator],
14247
+ typeOfIdentity: [isTruthyValidator$1],
14278
14248
  idNumber: [{
14279
14249
  validate: (value, context) => {
14280
14250
  switch (context.state.data.typeOfIdentity) {
14281
14251
  case "passport":
14282
- return PASSPORT_NUMBER_PATTERN.test(value);
14252
+ return PASSPORT_NUMBER_PATTERN$1.test(value);
14283
14253
  case "driversLicense":
14284
- return DRIVERS_LICENSE_NUMBER_PATTERN.test(value);
14254
+ return DRIVERS_LICENSE_NUMBER_PATTERN$1.test(value);
14285
14255
  case "proofOfIdentityCard":
14286
- return PROOF_OF_IDENTITY_CARD_NUMBER_PATTERN.test(value);
14256
+ return PROOF_OF_IDENTITY_CARD_NUMBER_PATTERN$1.test(value);
14287
14257
  }
14288
14258
  },
14289
14259
  errorMessage: (value, context) => {
@@ -14299,13 +14269,13 @@ const auIdentityValidationRules = {
14299
14269
  modes: ["blur"]
14300
14270
  }],
14301
14271
  licenseCardNumber: [{
14302
- validate: (value) => DRIVERS_LICENSE_NUMBER_PATTERN.test(value),
14272
+ validate: (value) => DRIVERS_LICENSE_NUMBER_PATTERN$1.test(value),
14303
14273
  errorMessage: "invalidFormatForAuDriversLicenseCardNumber",
14304
14274
  modes: ["blur"]
14305
14275
  }],
14306
- issuerState: [isTruthyValidator]
14276
+ issuerState: [isTruthyValidator$1]
14307
14277
  };
14308
- const DriversLicense = ({
14278
+ const DriversLicense$1 = ({
14309
14279
  driversLicense: driversLicense2,
14310
14280
  onIssuerStateChange,
14311
14281
  onLicenseNumberInput,
@@ -14383,7 +14353,7 @@ const DriversLicense = ({
14383
14353
  })]
14384
14354
  });
14385
14355
  };
14386
- const PassportNumber = ({
14356
+ const PassportNumber$1 = ({
14387
14357
  passportNumber: passportNumber2,
14388
14358
  onInput,
14389
14359
  onBlur,
@@ -14406,7 +14376,7 @@ const PassportNumber = ({
14406
14376
  placeholder: ""
14407
14377
  })
14408
14378
  });
14409
- const ProofOfIdentityCard = ({
14379
+ const ProofOfIdentityCard$1 = ({
14410
14380
  cardNumber,
14411
14381
  onInput,
14412
14382
  onBlur,
@@ -14429,11 +14399,11 @@ const ProofOfIdentityCard = ({
14429
14399
  placeholder: ""
14430
14400
  })
14431
14401
  });
14432
- const mapIdentityTypeToItem = (type, label) => ({
14402
+ const mapIdentityTypeToItem$1 = (type, label) => ({
14433
14403
  id: type,
14434
14404
  name: label
14435
14405
  });
14436
- const TypeOfIdentity = ({
14406
+ const TypeOfIdentity$1 = ({
14437
14407
  availableIdentityTypes,
14438
14408
  selectedIdentityType,
14439
14409
  setSelectedIdentityType,
@@ -14455,7 +14425,7 @@ const TypeOfIdentity = ({
14455
14425
  children: (childProps) => o(Select, {
14456
14426
  ...childProps,
14457
14427
  isInvalid: false,
14458
- items: availableIdentityTypes.map((type) => mapIdentityTypeToItem(type, i18n.get(type))),
14428
+ items: availableIdentityTypes.map((type) => mapIdentityTypeToItem$1(type, i18n.get(type))),
14459
14429
  placeholder: i18n.get("id"),
14460
14430
  selected: selectedIdentityType,
14461
14431
  onChange: (event) => setSelectedIdentityType(event.target.value)
@@ -14483,7 +14453,6 @@ function IdentityAuComponent(props) {
14483
14453
  maskedFields: props.maskedFields
14484
14454
  });
14485
14455
  p(() => {
14486
- console.log("triggerValidation");
14487
14456
  if (data.typeOfIdentity)
14488
14457
  triggerValidation(["idNumber"]);
14489
14458
  }, [data.typeOfIdentity]);
@@ -14505,28 +14474,28 @@ function IdentityAuComponent(props) {
14505
14474
  } = useCoreContext();
14506
14475
  const formUtils = formUtilities(props, i18n);
14507
14476
  return o(Fragment, {
14508
- children: [o(TypeOfIdentity, {
14509
- availableIdentityTypes: identityTypes.filter((type) => type !== "nationalIdNumber"),
14477
+ children: [o(TypeOfIdentity$1, {
14478
+ availableIdentityTypes: identityTypes$1.filter((type) => type !== "nationalIdNumber"),
14510
14479
  selectedIdentityType: data.typeOfIdentity,
14511
14480
  setSelectedIdentityType: handleChangeFor("typeOfIdentity"),
14512
14481
  formUtils,
14513
14482
  isValid: valid.typeOfIdentity,
14514
14483
  errorMessage: formUtils.getErrorMessage("typeOfIdentity", errors, fieldProblems)
14515
- }), data.typeOfIdentity === "passport" ? o(PassportNumber, {
14484
+ }), data.typeOfIdentity === "passport" ? o(PassportNumber$1, {
14516
14485
  passportNumber: data.idNumber,
14517
14486
  onInput: handleChangeFor("idNumber", "input"),
14518
14487
  onBlur: handleChangeFor("idNumber", "blur"),
14519
14488
  formUtils,
14520
14489
  isValid: valid.idNumber,
14521
14490
  errorMessage: formUtils.getErrorMessage("idNumber", errors, fieldProblems)
14522
- }) : data.typeOfIdentity === "proofOfIdentityCard" ? o(ProofOfIdentityCard, {
14491
+ }) : data.typeOfIdentity === "proofOfIdentityCard" ? o(ProofOfIdentityCard$1, {
14523
14492
  cardNumber: data.idNumber,
14524
14493
  onInput: handleChangeFor("idNumber", "input"),
14525
14494
  onBlur: handleChangeFor("idNumber", "blur"),
14526
14495
  formUtils,
14527
14496
  isValid: valid.idNumber,
14528
14497
  errorMessage: formUtils.getErrorMessage("idNumber", errors, fieldProblems)
14529
- }) : data.typeOfIdentity === "driversLicense" ? o(DriversLicense, {
14498
+ }) : data.typeOfIdentity === "driversLicense" ? o(DriversLicense$1, {
14530
14499
  driversLicense: data,
14531
14500
  onIssuerStateChange: handleChangeFor("issuerState"),
14532
14501
  onLicenseNumberInput: handleChangeFor("idNumber", "input"),
@@ -14548,6 +14517,250 @@ function IdentityAuComponent(props) {
14548
14517
  });
14549
14518
  }
14550
14519
  const auIdentityFields = [...additionalIdentityInfoFields, "idNumber"];
14520
+ const identityTypes = ["nationalIdNumber", "passport", "driversLicense", "proofOfIdentityCard"];
14521
+ const PASSPORT_NUMBER_PATTERN = /^(?=.{9}$)[A-Z]{1,2}\d{6}[A-Z0-9]{1,2}$/;
14522
+ const DRIVERS_LICENSE_NUMBER_PATTERN = /^[A-Z]{1}[A-Z0-9]{7}$/;
14523
+ const PROOF_OF_IDENTITY_CARD_NUMBER_PATTERN = /^[A-Z]{1,2}[0-9]{6}[0-9A]$/;
14524
+ const isValidatePassportNumber = (value) => PASSPORT_NUMBER_PATTERN.test(value);
14525
+ const isTruthyValidator = {
14526
+ validate: (value) => !!value,
14527
+ modes: ["blur"],
14528
+ errorMessage: "fieldIsRequired"
14529
+ };
14530
+ const identityValidationRules = {
14531
+ typeOfIdentity: [isTruthyValidator],
14532
+ idNumber: [{
14533
+ validate: (val, context) => {
14534
+ const value = val ?? "";
14535
+ switch (context == null ? void 0 : context.state.data.typeOfIdentity) {
14536
+ case "passport":
14537
+ return isValidatePassportNumber(value);
14538
+ case "driversLicense":
14539
+ return DRIVERS_LICENSE_NUMBER_PATTERN.test(value);
14540
+ case "proofOfIdentityCard":
14541
+ return PROOF_OF_IDENTITY_CARD_NUMBER_PATTERN.test(value);
14542
+ default:
14543
+ return false;
14544
+ }
14545
+ },
14546
+ errorMessage: (_2, context) => {
14547
+ switch (context == null ? void 0 : context.state.data.typeOfIdentity) {
14548
+ case "passport":
14549
+ return "invalidFormatForHKPassportNumber";
14550
+ case "driversLicense":
14551
+ return "invalidFormatForHKDriversLicenseNumber";
14552
+ case "proofOfIdentityCard":
14553
+ return "invalidFormatForHKIdentityCardNumber";
14554
+ }
14555
+ },
14556
+ modes: ["blur"]
14557
+ }],
14558
+ licenseCardNumber: [{
14559
+ validate: (value) => DRIVERS_LICENSE_NUMBER_PATTERN.test(value ?? ""),
14560
+ errorMessage: "invalidFormatForHKDriversLicenseNumber",
14561
+ modes: ["blur"]
14562
+ }],
14563
+ issuerState: [isTruthyValidator]
14564
+ };
14565
+ const DriversLicense = ({
14566
+ driversLicense: driversLicense2,
14567
+ onLicenseNumberInput,
14568
+ onLicenseNumberBlur,
14569
+ isValid,
14570
+ errorMessages,
14571
+ label
14572
+ }) => {
14573
+ const {
14574
+ i18n
14575
+ } = useCoreContext();
14576
+ return o(Fragment, {
14577
+ children: [o("div", {
14578
+ className: "adyen-kyc-field-wrapper",
14579
+ children: o(Field, {
14580
+ name: "licenseNumber",
14581
+ label,
14582
+ isValid: isValid.idNumber,
14583
+ errorMessage: errorMessages.idNumber,
14584
+ children: (childProps) => o(InputText, {
14585
+ ...childProps,
14586
+ name: "licenseNumber",
14587
+ value: driversLicense2.idNumber,
14588
+ onInput: onLicenseNumberInput,
14589
+ onBlur: onLicenseNumberBlur,
14590
+ placeholder: ""
14591
+ })
14592
+ })
14593
+ }), o(ContextGuidance, {
14594
+ page: "Personal details",
14595
+ title: i18n.get("whereCanIFindTheseNumbersOnMyDriversLicense"),
14596
+ content: o(Fragment, {
14597
+ children: [i18n.get("whereToFindNumbersOnDriversLicense"), " ", o("a", {
14598
+ href: "https://www.usi.gov.au/about/forms-id/drivers-licence",
14599
+ target: "_blank",
14600
+ rel: "noreferrer",
14601
+ children: i18n.get("iStillCantFindIt")
14602
+ })]
14603
+ }),
14604
+ titleId: "whereCanIFindTheseNumbersOnMyDriversLicense",
14605
+ contentId: "whereToFindNumbersOnDriversLicense"
14606
+ })]
14607
+ });
14608
+ };
14609
+ const PassportNumber = ({
14610
+ passportNumber: passportNumber2,
14611
+ onInput,
14612
+ onBlur,
14613
+ errorMessage,
14614
+ isValid,
14615
+ label
14616
+ }) => o(Field, {
14617
+ name: "passportNumber",
14618
+ label,
14619
+ errorMessage,
14620
+ isValid,
14621
+ children: (childProps) => o(InputText, {
14622
+ ...childProps,
14623
+ name: "passportNumber",
14624
+ value: passportNumber2,
14625
+ onInput,
14626
+ onBlur,
14627
+ placeholder: ""
14628
+ })
14629
+ });
14630
+ const ProofOfIdentityCard = ({
14631
+ cardNumber,
14632
+ onInput,
14633
+ onBlur,
14634
+ label,
14635
+ errorMessage,
14636
+ isValid
14637
+ }) => o(Field, {
14638
+ name: "cardNumber",
14639
+ label,
14640
+ errorMessage,
14641
+ isValid,
14642
+ children: (childProps) => o(InputText, {
14643
+ ...childProps,
14644
+ name: "cardNumber",
14645
+ value: cardNumber,
14646
+ onInput,
14647
+ onBlur,
14648
+ placeholder: ""
14649
+ })
14650
+ });
14651
+ const mapIdentityTypeToItem = (type, label) => ({
14652
+ id: type,
14653
+ name: label
14654
+ });
14655
+ const TypeOfIdentity = ({
14656
+ availableIdentityTypes,
14657
+ selectedIdentityType,
14658
+ setSelectedIdentityType,
14659
+ formUtils: {
14660
+ getLabel
14661
+ },
14662
+ errorMessage,
14663
+ isValid
14664
+ }) => {
14665
+ const {
14666
+ i18n
14667
+ } = useCoreContext();
14668
+ return o(Field, {
14669
+ name: "typeOfIdentity",
14670
+ label: getLabel("typeOfIdentity"),
14671
+ errorMessage,
14672
+ isValid,
14673
+ helper: i18n.get("typeOfIdentitySubtitle"),
14674
+ children: (childProps) => o(Select, {
14675
+ ...childProps,
14676
+ isInvalid: false,
14677
+ items: availableIdentityTypes.map((type) => mapIdentityTypeToItem(type, i18n.get(type))),
14678
+ placeholder: i18n.get("id"),
14679
+ selected: selectedIdentityType,
14680
+ onChange: (event) => setSelectedIdentityType(event.target.value)
14681
+ })
14682
+ });
14683
+ };
14684
+ function IdentityHKComponent(props) {
14685
+ var _a;
14686
+ if (((_a = props.data) == null ? void 0 : _a.typeOfIdentity) === "nationalIdNumber") {
14687
+ props.data.typeOfIdentity = void 0;
14688
+ }
14689
+ const {
14690
+ handleChangeFor,
14691
+ triggerValidation,
14692
+ data,
14693
+ errors,
14694
+ fieldProblems,
14695
+ valid
14696
+ } = useForm({
14697
+ ...props,
14698
+ schema: props.requiredFields ?? [],
14699
+ defaultData: props.data,
14700
+ fieldProblems: props.fieldValidationErrors,
14701
+ rules: identityValidationRules,
14702
+ maskedFields: props.maskedFields
14703
+ });
14704
+ p(() => {
14705
+ if (data.typeOfIdentity) {
14706
+ triggerValidation(["idNumber"]);
14707
+ }
14708
+ }, [data.typeOfIdentity]);
14709
+ const {
14710
+ sliceData,
14711
+ updateStateSlice
14712
+ } = useGlobalDataSlice("personalDetails");
14713
+ p(() => {
14714
+ updateStateSlice({
14715
+ data: {
14716
+ ...sliceData,
14717
+ ...data
14718
+ },
14719
+ errors,
14720
+ valid,
14721
+ fieldProblems
14722
+ });
14723
+ }, [data, errors, valid, fieldProblems]);
14724
+ const {
14725
+ i18n
14726
+ } = useCoreContext();
14727
+ const formUtils = formUtilities(props, i18n);
14728
+ return o(Fragment, {
14729
+ children: [o(TypeOfIdentity, {
14730
+ availableIdentityTypes: identityTypes.filter((type) => type !== "nationalIdNumber"),
14731
+ selectedIdentityType: data.typeOfIdentity,
14732
+ setSelectedIdentityType: handleChangeFor("typeOfIdentity"),
14733
+ formUtils,
14734
+ isValid: valid.typeOfIdentity,
14735
+ errorMessage: formUtils.getErrorMessage("typeOfIdentity", errors, fieldProblems)
14736
+ }), data.typeOfIdentity === "passport" ? o(PassportNumber, {
14737
+ passportNumber: data.idNumber ?? "",
14738
+ onInput: handleChangeFor("idNumber", "input"),
14739
+ onBlur: handleChangeFor("idNumber", "blur"),
14740
+ isValid: valid.idNumber,
14741
+ label: formUtils.getLabel("idNumber", "passportNumber"),
14742
+ errorMessage: formUtils.getErrorMessage("idNumber", errors, fieldProblems)
14743
+ }) : data.typeOfIdentity === "proofOfIdentityCard" ? o(ProofOfIdentityCard, {
14744
+ cardNumber: data.idNumber ?? "",
14745
+ onInput: handleChangeFor("idNumber", "input"),
14746
+ onBlur: handleChangeFor("idNumber", "blur"),
14747
+ isValid: valid.idNumber,
14748
+ label: formUtils.getLabel("idNumber", "hkid"),
14749
+ errorMessage: formUtils.getErrorMessage("idNumber", errors, fieldProblems)
14750
+ }) : data.typeOfIdentity === "driversLicense" ? o(DriversLicense, {
14751
+ driversLicense: data,
14752
+ onLicenseNumberInput: handleChangeFor("idNumber", "input"),
14753
+ onLicenseNumberBlur: handleChangeFor("idNumber", "blur"),
14754
+ label: formUtils.getLabel("idNumber", "driverLicense"),
14755
+ isValid: {
14756
+ idNumber: valid.idNumber
14757
+ },
14758
+ errorMessages: {
14759
+ idNumber: formUtils.getErrorMessage("idNumber", errors, fieldProblems)
14760
+ }
14761
+ }) : void 0]
14762
+ });
14763
+ }
14551
14764
  const IdentityNumber$1 = "";
14552
14765
  function validCheckCharacter(input, calculationInput) {
14553
14766
  if (!/^[A-Z]$/.test(input)) {
@@ -15425,7 +15638,10 @@ function PersonalDetailsComponent(props) {
15425
15638
  onDropdownChange: handleChangeFor("residencyCountry", "input"),
15426
15639
  value: data.residencyCountry,
15427
15640
  readOnly: !isAllowedEditPrefilledCountry && !isDecisionMakerTask
15428
- }), hasRequiredFields(identityProps) && (data.residencyCountry === "AU" ? o(IdentityAuComponent, {
15641
+ }), hasRequiredFields(identityProps) && (data.residencyCountry === "HK" ? o(IdentityHKComponent, {
15642
+ ...identityAuProps,
15643
+ dataStoreId: PERSONAL_DETAILS
15644
+ }) : data.residencyCountry === "AU" ? o(IdentityAuComponent, {
15429
15645
  ...identityAuProps,
15430
15646
  dataStoreId: PERSONAL_DETAILS
15431
15647
  }) : data.residencyCountry === "US" ? o(IdentityUSComponent, {
@@ -15439,7 +15655,7 @@ function PersonalDetailsComponent(props) {
15439
15655
  errors: externalErrors,
15440
15656
  country: data.residencyCountry,
15441
15657
  dataStoreId: PERSONAL_DETAILS
15442
- })), data.residencyCountry === "SG" && formUtils.isRequiredField("nationality") && o(CountryField, {
15658
+ })), (data.residencyCountry === "SG" || data.residencyCountry === "HK") && formUtils.isRequiredField("nationality") && o(CountryField, {
15443
15659
  label: formUtils.getLabel("nationality"),
15444
15660
  classNameModifiers: ["nationality"],
15445
15661
  errorMessage: formUtils.getErrorMessage("nationality", errors, fieldProblems),
@@ -20775,6 +20991,7 @@ const getPayoutAccountHolderName = (legalEntity, i18n) => {
20775
20991
  }
20776
20992
  return getLegalEntityNameBasedOnType(legalEntity);
20777
20993
  };
20994
+ const isNewEntity = Symbol("isNewEntity");
20778
20995
  const splitAtFirstOccurrence = (str, separator) => {
20779
20996
  const firstOccurrence = str.indexOf(separator);
20780
20997
  if (firstOccurrence === -1)
@@ -20858,6 +21075,9 @@ const getTrustMembers = (trustLE, rootLegalEntity, exemptSettlorLE) => {
20858
21075
  return [mapRootLegalEntityToTrustMember(rootLegalEntity), ...mapEntityAssociationsToTrustMembers(trustLE.id, trustLE.entityAssociations ?? [], exemptSettlorLE), ...mapUndefinedBeneficiaryInfoToTrustMembers(((_a = trustLE.trust) == null ? void 0 : _a.undefinedBeneficiaryInfo) ?? [])];
20859
21076
  };
20860
21077
  const mapTrustMemberToEntityAssociations = (trustMember) => {
21078
+ if (trustMember.legalEntityId === isNewEntity) {
21079
+ throw Error("Cannot map a new trust member, you must create it first");
21080
+ }
20861
21081
  if (trustMember.trustMemberType === "exemptSettlor")
20862
21082
  return [{
20863
21083
  legalEntityId: trustMember.legalEntityId,
@@ -20892,7 +21112,9 @@ const addOrUpdateUndefinedBeneficiary = async ({
20892
21112
  const otherUndefinedBeneficiaries = ((_b = (_a = trust.trust) == null ? void 0 : _a.undefinedBeneficiaryInfo) == null ? void 0 : _b.filter((ub) => ub.reference !== newOrUpdated.reference)) ?? [];
20893
21113
  const patchLE = {
20894
21114
  trust: {
20895
- undefinedBeneficiaryInfo: [...otherUndefinedBeneficiaries, {
21115
+ undefinedBeneficiaryInfo: [...otherUndefinedBeneficiaries, newOrUpdated.reference === isNewEntity ? {
21116
+ description: newOrUpdated.description
21117
+ } : {
20896
21118
  reference: newOrUpdated.reference,
20897
21119
  description: newOrUpdated.description
20898
21120
  }]
@@ -24269,21 +24491,21 @@ const convertDataToTrustMember = (data, existingTrustMember) => {
24269
24491
  firstName: data.firstName ?? "",
24270
24492
  lastName: data.lastName ?? ""
24271
24493
  },
24272
- legalEntityId: existingId ?? ""
24494
+ legalEntityId: existingId ?? isNewEntity
24273
24495
  };
24274
24496
  if (data.role.includes("undefinedBeneficiary"))
24275
24497
  return {
24276
24498
  trustMemberType: "undefinedBeneficiary",
24277
24499
  roles: [TrustMemberTypes.UNDEFINED_BENEFICIARY],
24278
24500
  description: data.descriptionUndefinedBeneficiary ?? "",
24279
- reference: existingId ?? ""
24501
+ reference: existingId ?? isNewEntity
24280
24502
  };
24281
24503
  if (data.entityType === LegalEntityType.ORGANIZATION)
24282
24504
  return {
24283
24505
  trustMemberType: "company",
24284
24506
  roles: data.role,
24285
24507
  legalEntityType: LegalEntityType.ORGANIZATION,
24286
- legalEntityId: existingId ?? "",
24508
+ legalEntityId: existingId ?? isNewEntity,
24287
24509
  name: ""
24288
24510
  };
24289
24511
  if (data.entityType === LegalEntityType.INDIVIDUAL)
@@ -24291,7 +24513,7 @@ const convertDataToTrustMember = (data, existingTrustMember) => {
24291
24513
  trustMemberType: "regular",
24292
24514
  roles: data.role,
24293
24515
  legalEntityType: LegalEntityType.INDIVIDUAL,
24294
- legalEntityId: existingId ?? "",
24516
+ legalEntityId: existingId ?? isNewEntity,
24295
24517
  name: ""
24296
24518
  };
24297
24519
  }
@@ -25930,7 +26152,7 @@ function DropinComposerComponent({
25930
26152
  };
25931
26153
  const addOrUpdateTrustMember = async (updated, existing) => {
25932
26154
  if ((existing == null ? void 0 : existing.trustMemberType) === "undefinedBeneficiary" && updated.trustMemberType === "undefinedBeneficiary" && existing.description === updated.description) {
25933
- await refreshTrustAndRunOnSubmit(trust);
26155
+ await refreshTrustAndRunOnSubmit(trust, 1);
25934
26156
  return;
25935
26157
  }
25936
26158
  try {
@@ -25979,7 +26201,7 @@ function DropinComposerComponent({
25979
26201
  label: i18n.get("successfullyUpdatedDetails"),
25980
26202
  type: ToastType.SUCCESS
25981
26203
  });
25982
- await refreshTrustAndRunOnSubmit(trust);
26204
+ await refreshTrustAndRunOnSubmit(trust, 1);
25983
26205
  } catch (err) {
25984
26206
  logger$1.error(err);
25985
26207
  showToast({
@@ -26068,11 +26290,11 @@ function DropinComposerComponent({
26068
26290
  };
26069
26291
  const onNavigateToTrustMember = async (tm) => {
26070
26292
  try {
26071
- if (tm == null ? void 0 : tm.legalEntityId) {
26293
+ if (tm.legalEntityId === isNewEntity) {
26294
+ setAssociatedLegalEntity(null);
26295
+ } else {
26072
26296
  const response = await (args == null ? void 0 : args.handleGetLegalEntity(tm.legalEntityId));
26073
26297
  setAssociatedLegalEntity(response);
26074
- } else {
26075
- setAssociatedLegalEntity(null);
26076
26298
  }
26077
26299
  setTrustMember(tm);
26078
26300
  onNavigateTo(tm.trustMemberType === "company" ? TaskTypes.TRUST_MEMBER_COMPANY : TaskTypes.TRUST_MEMBER_INDIVIDUAL);
@@ -26149,9 +26371,9 @@ function DropinComposerComponent({
26149
26371
  await refreshLegalEntity();
26150
26372
  navigateBack(backStepCount);
26151
26373
  };
26152
- const refreshTrustAndRunOnSubmit = async (data) => {
26374
+ const refreshTrustAndRunOnSubmit = async (data, backSteps) => {
26153
26375
  await refreshTrust();
26154
- await componentOnSubmit(data, 2);
26376
+ await componentOnSubmit(data, backSteps);
26155
26377
  };
26156
26378
  const onPciDownload = async () => {
26157
26379
  const baseTrackingPayload = getBaseTrackingPayload({
@@ -26351,7 +26573,7 @@ function DropinComposerComponent({
26351
26573
  capabilities: Object.keys((legalEntityResponse == null ? void 0 : legalEntityResponse.capabilities) ?? {}),
26352
26574
  onChange: componentOnChange,
26353
26575
  eventEmitter,
26354
- onSubmit: refreshTrustAndRunOnSubmit,
26576
+ onSubmit: (data) => refreshTrustAndRunOnSubmit(data, 2),
26355
26577
  handleBackClick: navigateBack,
26356
26578
  handleHomeClick: () => onNavigateTo(TaskTypes.TRUST_MEMBER_OVERVIEW),
26357
26579
  homeButtonLabel: i18n.get("saveAndGoToOverview"),
@@ -26399,7 +26621,7 @@ function DropinComposerComponent({
26399
26621
  problems: (_a2 = capabilityProblems == null ? void 0 : capabilityProblems.LegalEntity) == null ? void 0 : _a2[legalEntity.id],
26400
26622
  onChange: componentOnChange,
26401
26623
  eventEmitter,
26402
- onSubmit: refreshTrustAndRunOnSubmit,
26624
+ onSubmit: (data) => refreshTrustAndRunOnSubmit(data, 2),
26403
26625
  handleBackClick: navigateBack,
26404
26626
  handleHomeClick: navigateBack,
26405
26627
  homeButtonLabel: i18n.get("saveAndGoToOverview"),