@adyen/kyc-components 3.1.2 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/es/adyen-kyc-components.es.js +1178 -1272
  2. package/dist/style.css +4 -0
  3. package/dist/types/components/Company/rules.d.ts +2 -1
  4. package/dist/types/components/Company/types.d.ts +0 -1
  5. package/dist/types/components/CompanyBasics/component/CompanyBasicsComponent.d.ts +1 -1
  6. package/dist/types/components/CompanyBasics/types.d.ts +3 -0
  7. package/dist/types/components/CompanyLookup/component/CompanyLookupComponent.d.ts +1 -1
  8. package/dist/types/components/CompanyLookup/types.d.ts +3 -1
  9. package/dist/types/components/CompanyOtherDetails/component/CompanyOtherDetailsComponent.d.ts +1 -1
  10. package/dist/types/components/CompanyOtherDetails/types.d.ts +3 -1
  11. package/dist/types/components/CompanySearch/types.d.ts +1 -0
  12. package/dist/types/components/CompanyStructure/component/CompanyStructureComponent.d.ts +1 -1
  13. package/dist/types/components/CompanyStructure/types.d.ts +4 -1
  14. package/dist/types/components/Dropins/CompanyDropin/types.d.ts +2 -0
  15. package/dist/types/components/Dropins/CompanySearchDropin/types.d.ts +1 -1
  16. package/dist/types/components/Dropins/CompanySearchDropin/utils.d.ts +10 -3
  17. package/dist/types/components/Dropins/{FormComposer/components/FormNavigation → FormNavigation}/types.d.ts +4 -4
  18. package/dist/types/components/Dropins/FormWrapper/FormWrapper.d.ts +1 -1
  19. package/dist/types/components/Dropins/SolePropDropin/components/SolePropDropinComponent.d.ts +1 -1
  20. package/dist/types/components/Dropins/TrustDropin/components/TrustDropinComponent.d.ts +1 -1
  21. package/dist/types/components/PayoutDetails/types.d.ts +3 -3
  22. package/dist/types/components/PersonalDetails/component/labels.d.ts +1 -1
  23. package/dist/types/components/SoleProp/types.d.ts +1 -1
  24. package/dist/types/components/Trust/types.d.ts +1 -1
  25. package/dist/types/components/internal/Address/utils.d.ts +1 -1
  26. package/dist/types/components/internal/BusinessRegistrationNumber/fieldConfig.d.ts +4 -4
  27. package/dist/types/components/internal/BusinessRegistrationNumberField/BusinessRegistrationNumberField.d.ts +2 -2
  28. package/dist/types/components/internal/BusinessRegistrationNumberField/index.d.ts +1 -0
  29. package/dist/types/components/internal/BusinessRegistrationNumberField/types.d.ts +2 -2
  30. package/dist/types/components/internal/Summary/Summary.d.ts +0 -1
  31. package/dist/types/components/internal/TaxId/fieldConfig.d.ts +2 -3
  32. package/dist/types/components/internal/TaxInformationField/TaxInformationField.d.ts +1 -1
  33. package/dist/types/components/internal/TaxInformationField/fieldConfig.d.ts +10 -0
  34. package/dist/types/components/internal/TaxInformationField/index.d.ts +1 -0
  35. package/dist/types/components/internal/VatNumberField/VatNumberField.d.ts +2 -2
  36. package/dist/types/components/internal/VatNumberField/index.d.ts +1 -0
  37. package/dist/types/core/Context/StateContext/types.d.ts +0 -2
  38. package/dist/types/core/hooks/useCompanySearch/types.d.ts +10 -8
  39. package/dist/types/core/hooks/useCompanySearch/useCompanySearch.d.ts +1 -1
  40. package/dist/types/core/hooks/useForm/types.d.ts +1 -0
  41. package/dist/types/core/process-field-configurations.d.ts +10 -5
  42. package/dist/types/language/config.d.ts +2 -8
  43. package/dist/types/utils/entity-status-util.d.ts +1 -1
  44. package/dist/types/utils/formUtils.d.ts +1 -1
  45. package/dist/types/utils/mapping/companySearch/index.d.ts +1 -0
  46. package/dist/types/utils/mapping/companySearch/mapKompanyOrganizationTypeToCompanyType.d.ts +2 -0
  47. package/dist/types/utils/mapping/componentApiMapping.d.ts +1 -1
  48. package/package.json +1 -1
  49. package/dist/types/components/CompanyBasics/validate.d.ts +0 -4
  50. package/dist/types/components/CompanyOtherDetails/validate.d.ts +0 -10
  51. package/dist/types/components/Dropins/FormComposer/FormComposer.d.ts +0 -34
  52. package/dist/types/components/Dropins/FormComposer/types.d.ts +0 -22
  53. package/dist/types/components/SoleProp/labels.d.ts +0 -5
  54. package/dist/types/components/internal/Summary/index.d.ts +0 -1
  55. /package/dist/types/components/Dropins/{FormComposer/components/FormNavigation → FormNavigation}/FormNavigation.d.ts +0 -0
  56. /package/dist/types/components/Dropins/{FormComposer/components/FormNavigation → FormNavigation}/FormNavigationItem.d.ts +0 -0
  57. /package/dist/types/components/Dropins/{FormComposer/components/FormNavigation → FormNavigation}/index.d.ts +0 -0
  58. /package/dist/types/components/{Dropins/FormComposer/components/StepProgressIndicator → StepProgressIndicator}/StepProgressIndicator.d.ts +0 -0
@@ -3,7 +3,7 @@ import { createContext, createElement, render } from "preact";
3
3
  import { sanitize } from "isomorphic-dompurify";
4
4
  import cx from "classnames";
5
5
  import { jsx, jsxs, Fragment } from "preact/jsx-runtime";
6
- import { useId, forwardRef, memo, useMemo as useMemo$1, useEffect as useEffect$1, useState as useState$1 } from "preact/compat";
6
+ import { useId, forwardRef, memo, useMemo as useMemo$1, useEffect as useEffect$1, useState as useState$1, useCallback as useCallback$1 } from "preact/compat";
7
7
  import { debounce, noop as noop$1, isEmpty as isEmpty$1, range } from "lodash";
8
8
  import OpenBankingSDK from "@adyen/openbankingsdk";
9
9
  import "@adyen/adyen-document-viewer/dist/adyen-document-viewer.min.css";
@@ -189,7 +189,7 @@ const doNotHaveHandelsregisternummer = "I do not have a Handelsregisternummer";
189
189
  const doNotHaveRegonKrsNumber = "I do not have a REGON";
190
190
  const taxIdAbsenceReason = "Tax ID absence reason";
191
191
  const vatNumberExempted = "Exempted from VAT";
192
- const vatNumberAbsenceReason = "VAT number absence reason";
192
+ const vatAbsenceReason = "VAT number absence reason";
193
193
  const belowTaxThreshold = "Below tax threshold";
194
194
  const industryExemption = "Industry exemption";
195
195
  const validationPleaseEnterAValidRegistrationNumber = "Please enter a valid company registration number";
@@ -847,13 +847,7 @@ const legalCompanyName__helperText__US = "Enter the name exactly as it appears o
847
847
  const legalCompanyName__helperText__SG = "Enter the name exactly as it is on your Accounting and Corporate Regulatory Authority (ACRA) BizFile.";
848
848
  const legalCompanyName__helperText__HK = "Enter the name exactly as it is on your Hong Kong Companies Registry's Certificate of Incorporation.";
849
849
  const taxInformationNumber = "Tax Identification Number";
850
- const taxInformationNumber__US = "Tax Identification Number (TIN)";
851
- const taxInformationNumber__helperText__US = "Also known as Employer Identification Number (EIN), this is issued by the IRS to businesses operating in the US.";
852
- const businessRegistrationNumber = "Business registration number";
853
- const businessRegistrationNumber__optional = "Business registration number (optional)";
854
- const businessRegistrationNumber__HK = "Business Registration number (BRN)";
855
- const businessRegistrationNumber__helperText__US = "This can be found on your registration documents or any documents you receive from the registrar such as account reminders.";
856
- const businessRegistrationNumber__placeholder__US = "1234567 AB";
850
+ const taxInformationNumber__HK = "Business Registration number (BRN)";
857
851
  const stockExchangeMIC = "Stock Exchange MIC";
858
852
  const stockExchangeMIC__US = "Market identifier code (MIC)";
859
853
  const stockExchangeMIC__placeholder__US = "XABC";
@@ -1404,7 +1398,7 @@ const defaultTrans = {
1404
1398
  doNotHaveRegonKrsNumber,
1405
1399
  taxIdAbsenceReason,
1406
1400
  vatNumberExempted,
1407
- vatNumberAbsenceReason,
1401
+ vatAbsenceReason,
1408
1402
  belowTaxThreshold,
1409
1403
  industryExemption,
1410
1404
  validationPleaseEnterAValidRegistrationNumber,
@@ -2070,13 +2064,7 @@ const defaultTrans = {
2070
2064
  legalCompanyName__helperText__SG,
2071
2065
  legalCompanyName__helperText__HK,
2072
2066
  taxInformationNumber,
2073
- taxInformationNumber__US,
2074
- taxInformationNumber__helperText__US,
2075
- businessRegistrationNumber,
2076
- businessRegistrationNumber__optional,
2077
- businessRegistrationNumber__HK,
2078
- businessRegistrationNumber__helperText__US,
2079
- businessRegistrationNumber__placeholder__US,
2067
+ taxInformationNumber__HK,
2080
2068
  stockExchangeMIC,
2081
2069
  stockExchangeMIC__US,
2082
2070
  stockExchangeMIC__placeholder__US,
@@ -3341,36 +3329,36 @@ var LegalEntityType = /* @__PURE__ */ ((LegalEntityType2) => {
3341
3329
  })(LegalEntityType || {});
3342
3330
  function getFormProps(props, innerFormId) {
3343
3331
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
3344
- if (innerFormId) {
3345
- const nestedFormProps = {
3346
- placeholders: ((_a = props.placeholders) == null ? void 0 : _a[innerFormId]) ?? {},
3347
- labels: ((_b = props.labels) == null ? void 0 : _b[innerFormId]) ?? {},
3348
- helperText: ((_c = props.helperText) == null ? void 0 : _c[innerFormId]) ?? {},
3349
- masks: ((_d = props.masks) == null ? void 0 : _d[innerFormId]) ?? {},
3350
- data: ((_e = props.data) == null ? void 0 : _e[innerFormId]) ?? {},
3351
- readOnlyFields: ((_f = props.readOnlyFields) == null ? void 0 : _f[innerFormId]) ?? [],
3352
- requiredFields: ((_g = props.requiredFields) == null ? void 0 : _g[innerFormId]) ?? [],
3353
- optionalFields: ((_h = props.optionalFields) == null ? void 0 : _h[innerFormId]) ?? [],
3354
- maskedFields: ((_i = props.maskedFields) == null ? void 0 : _i[innerFormId]) ?? [],
3355
- verifyFields: ((_j = props.verifyFields) == null ? void 0 : _j[innerFormId]) ?? [],
3356
- formVerificationErrors: ((_l = (_k = props.problems) == null ? void 0 : _k.verificationErrors) == null ? void 0 : _l[innerFormId]) ?? {},
3357
- fieldValidationErrors: ((_n = (_m = props.problems) == null ? void 0 : _m.validationErrors) == null ? void 0 : _n[innerFormId]) ?? {},
3358
- /*
3332
+ if (!innerFormId) {
3333
+ return null;
3334
+ }
3335
+ const activeFormId = (_a = props.activeForm) == null ? void 0 : _a.formId;
3336
+ return {
3337
+ placeholders: ((_b = props.placeholders) == null ? void 0 : _b[innerFormId]) ?? {},
3338
+ labels: ((_c = props.labels) == null ? void 0 : _c[innerFormId]) ?? {},
3339
+ helperText: ((_d = props.helperText) == null ? void 0 : _d[innerFormId]) ?? {},
3340
+ masks: ((_e = props.masks) == null ? void 0 : _e[innerFormId]) ?? {},
3341
+ data: ((_f = props.data) == null ? void 0 : _f[innerFormId]) ?? {},
3342
+ readOnlyFields: ((_g = props.readOnlyFields) == null ? void 0 : _g[innerFormId]) ?? [],
3343
+ requiredFields: ((_h = props.requiredFields) == null ? void 0 : _h[innerFormId]) ?? [],
3344
+ optionalFields: ((_i = props.optionalFields) == null ? void 0 : _i[innerFormId]) ?? [],
3345
+ maskedFields: ((_j = props.maskedFields) == null ? void 0 : _j[innerFormId]) ?? [],
3346
+ verifyFields: ((_k = props.verifyFields) == null ? void 0 : _k[innerFormId]) ?? [],
3347
+ formVerificationErrors: ((_m = (_l = props.problems) == null ? void 0 : _l.verificationErrors) == null ? void 0 : _m[innerFormId]) ?? {},
3348
+ fieldValidationErrors: ((_o = (_n = props.problems) == null ? void 0 : _n.validationErrors) == null ? void 0 : _o[innerFormId]) ?? {},
3349
+ /*
3359
3350
  Validators should be `null` and not `{}` by default to make it easier to short circuit it with predetermined validators.
3360
3351
  For example `rules: props.validators || personalDetailsValidationRules`.
3361
3352
  */
3362
- validators: ((_o = props.validators) == null ? void 0 : _o[innerFormId]) ? {
3363
- ...(_p = props.validators) == null ? void 0 : _p[innerFormId]
3364
- } : null,
3365
- /*
3366
- activeForm check is required for shouldValidate because of we render all forms in a multistep form.
3353
+ validators: ((_p = props.validators) == null ? void 0 : _p[innerFormId]) ? {
3354
+ ...(_q = props.validators) == null ? void 0 : _q[innerFormId]
3355
+ } : null,
3356
+ /*
3357
+ activeForm check is required for shouldValidate because we render all forms in a multistep form.
3367
3358
  Should be changed once stateManagement is fixed and this is no longer the case
3368
3359
  */
3369
- shouldValidate: ((_q = props.activeForm) == null ? void 0 : _q.formId) === innerFormId && props.shouldValidate
3370
- };
3371
- return nestedFormProps;
3372
- }
3373
- return null;
3360
+ shouldValidate: (activeFormId ? activeFormId === innerFormId : true) && props.shouldValidate
3361
+ };
3374
3362
  }
3375
3363
  function getFieldProps(props, innerFormFields) {
3376
3364
  if (innerFormFields) {
@@ -6732,10 +6720,10 @@ const validatePatternOnBlur = (pattern) => ({
6732
6720
  modes: ["blur"],
6733
6721
  validate: (val) => !!val && pattern.test(val)
6734
6722
  });
6735
- const defaultFieldMetadata$2 = {
6723
+ const defaultFieldMetadata$3 = {
6736
6724
  label: "registrationNumber"
6737
6725
  };
6738
- const defaultFieldConfig$2 = {
6726
+ const defaultFieldConfig$3 = {
6739
6727
  [CountryCodes.Australia]: {
6740
6728
  label: "australianBusinessNumberAcn",
6741
6729
  mask: businessRegistrationNumberMasks[CountryCodes.Australia].default,
@@ -6830,7 +6818,7 @@ const defaultFieldConfig$2 = {
6830
6818
  key: "enterNDigitsForExample",
6831
6819
  values: {
6832
6820
  numDigits: "9",
6833
- example: "80020970"
6821
+ example: "080020970"
6834
6822
  }
6835
6823
  }
6836
6824
  },
@@ -7042,13 +7030,17 @@ const defaultFieldConfig$2 = {
7042
7030
  default:
7043
7031
  return {
7044
7032
  label: "partitaIVA",
7045
- mask: businessRegistrationNumberMasks[CountryCodes.Italy].partitaIVA,
7046
- validators: validatePatternOnBlur(businessRegistrationNumberPatterns[CountryCodes.Italy].partitaIVA),
7033
+ validators: validatePatternOnBlur(/^\d{11}$/),
7034
+ mask: {
7035
+ mask: makeMask(...nonInputs("IT", {
7036
+ includeInValue: false
7037
+ }), spacer, ...numericInputs(11))
7038
+ },
7047
7039
  guidanceText: {
7048
- key: "enterNDigitsForExample",
7040
+ key: "enterTheRemainingNDigitsForExample",
7049
7041
  values: {
7050
7042
  numDigits: "11",
7051
- example: "47040001100"
7043
+ example: "IT47040001100"
7052
7044
  }
7053
7045
  }
7054
7046
  };
@@ -7384,7 +7376,7 @@ const defaultFieldConfig$2 = {
7384
7376
  const businessRegistrationNumberFields = ["registrationNumber", "exemptedFromRegistrationNumber"];
7385
7377
  function BusinessRegistrationNumber(props) {
7386
7378
  var _a;
7387
- const fieldConfig = props.fieldConfig ?? defaultFieldConfig$2;
7379
+ const fieldConfig = props.fieldConfig ?? defaultFieldConfig$3;
7388
7380
  const {
7389
7381
  i18n
7390
7382
  } = useI18nContext();
@@ -7400,7 +7392,7 @@ function BusinessRegistrationNumber(props) {
7400
7392
  const metadata = resolveFieldMetadata(fieldConfig[country2], {
7401
7393
  companyType: companyType2,
7402
7394
  registrationNumberType
7403
- }, defaultFieldMetadata$2);
7395
+ }, defaultFieldMetadata$3);
7404
7396
  const mergedProps = mergeFieldMetadataIntoProps("registrationNumber", metadata, {
7405
7397
  requiredFields: schema
7406
7398
  });
@@ -7969,7 +7961,7 @@ function CompanyRegistrationNumberTypeSelector({
7969
7961
  }
7970
7962
  const inferCompanyRegistrationNumberType = (registrationNumber2, country2, companyType2) => {
7971
7963
  const optionsForCountry = companyRegistrationNumberOptions[country2];
7972
- const metadataFn = defaultFieldConfig$2[country2];
7964
+ const metadataFn = defaultFieldConfig$3[country2];
7973
7965
  if (!optionsForCountry || !metadataFn || typeof metadataFn !== "function")
7974
7966
  return void 0;
7975
7967
  for (const option of optionsForCountry) {
@@ -7985,10 +7977,10 @@ const inferCompanyRegistrationNumberType = (registrationNumber2, country2, compa
7985
7977
  }
7986
7978
  }
7987
7979
  };
7988
- const defaultFieldMetadata$1 = {
7980
+ const defaultFieldMetadata$2 = {
7989
7981
  label: "taxId"
7990
7982
  };
7991
- const defaultFieldConfig$1 = {
7983
+ const defaultFieldConfig$2 = {
7992
7984
  [CountryCodes.Canada]: {
7993
7985
  label: "businessNumber",
7994
7986
  validators: validatePatternOnBlur(/^\d{9}$/),
@@ -8004,7 +7996,7 @@ const defaultFieldConfig$1 = {
8004
7996
  }
8005
7997
  },
8006
7998
  [CountryCodes.HongKong]: {
8007
- label: "businessRegistrationNumber__HK",
7999
+ label: "taxInformationNumber__HK",
8008
8000
  validators: validatePatternOnBlur(/^\d{8}$/),
8009
8001
  mask: {
8010
8002
  mask: makeMask(...numericInputs(8))
@@ -8089,7 +8081,7 @@ const defaultFieldConfig$1 = {
8089
8081
  mask: {
8090
8082
  mask: makeMask(...numericInputs(9))
8091
8083
  },
8092
- helperText: {
8084
+ guidanceText: {
8093
8085
  key: "validationPleaseEnterAValidTaxIdNumberWithFormat",
8094
8086
  values: {
8095
8087
  format: "XXXXXXXXX"
@@ -8117,10 +8109,10 @@ const defaultFieldConfig$1 = {
8117
8109
  validators: validatePatternOnBlur(/^\d{12}$/)
8118
8110
  }
8119
8111
  };
8120
- const defaultFieldMetadata = {
8112
+ const defaultFieldMetadata$1 = {
8121
8113
  label: "vatNumber"
8122
8114
  };
8123
- const defaultFieldConfig = {
8115
+ const defaultFieldConfig$1 = {
8124
8116
  [CountryCodes.Austria]: {
8125
8117
  label: "UST-ID",
8126
8118
  validators: validatePatternOnBlur(/^ATU\d{8}$/),
@@ -8410,7 +8402,7 @@ const defaultFieldConfig = {
8410
8402
  key: "enterTheRemainingNDigitsForExample",
8411
8403
  values: {
8412
8404
  numDigits: "11",
8413
- example: "IT12345678901"
8405
+ example: "IT47040001100"
8414
8406
  }
8415
8407
  }
8416
8408
  },
@@ -8675,7 +8667,7 @@ const defaultFieldConfig = {
8675
8667
  numDigits: "9",
8676
8668
  minLetters: "3",
8677
8669
  maxLetters: "4",
8678
- example: "CHE123456789TVA"
8670
+ example: "CHE-123.456.789 TVA"
8679
8671
  }
8680
8672
  }
8681
8673
  },
@@ -8749,7 +8741,7 @@ const defaultFieldConfig = {
8749
8741
  };
8750
8742
  const inferTaxIdNumberType = (taxId2, country2) => {
8751
8743
  const optionsForCountry = taxIdNumberOptions[country2];
8752
- const metadataFn = defaultFieldConfig[country2] ?? defaultFieldConfig$1[country2];
8744
+ const metadataFn = defaultFieldConfig$1[country2] ?? defaultFieldConfig$2[country2];
8753
8745
  if (!optionsForCountry || !metadataFn || typeof metadataFn !== "function")
8754
8746
  return void 0;
8755
8747
  for (const option of optionsForCountry) {
@@ -8805,11 +8797,11 @@ function TaxId(props) {
8805
8797
  fieldValidationErrors,
8806
8798
  dataStoreId,
8807
8799
  taxIdNumberType,
8808
- fieldConfig = defaultFieldConfig$1
8800
+ fieldConfig = defaultFieldConfig$2
8809
8801
  } = props;
8810
8802
  const metadata = resolveFieldMetadata(fieldConfig[country2], {
8811
8803
  taxIdNumberType
8812
- }, defaultFieldMetadata$1);
8804
+ }, defaultFieldMetadata$2);
8813
8805
  const mergedProps = mergeFieldMetadataIntoProps("taxId", metadata, props);
8814
8806
  const {
8815
8807
  i18n
@@ -8924,12 +8916,12 @@ function VatNumber(props) {
8924
8916
  country: country2,
8925
8917
  fieldValidationErrors,
8926
8918
  dataStoreId,
8927
- fieldConfig = defaultFieldConfig,
8919
+ fieldConfig = defaultFieldConfig$1,
8928
8920
  vatNumberType
8929
8921
  } = props;
8930
8922
  const metadata = resolveFieldMetadata(fieldConfig[country2], {
8931
8923
  vatNumberType
8932
- }, defaultFieldMetadata);
8924
+ }, defaultFieldMetadata$1);
8933
8925
  const mergedProps = mergeFieldMetadataIntoProps("vatNumber", metadata, props);
8934
8926
  const {
8935
8927
  i18n
@@ -9011,7 +9003,7 @@ function VatNumber(props) {
9011
9003
  }), data.exemptedFromVat ? jsx(Field, {
9012
9004
  name: "vatAbsenceReason",
9013
9005
  classNameModifiers: ["tax-id-absence-reason"],
9014
- label: formUtils.getLabel("vatAbsenceReason", "vatNumberAbsenceReason"),
9006
+ label: formUtils.getLabel("vatAbsenceReason", "vatAbsenceReason"),
9015
9007
  errorMessage: formUtils.getErrorMessage("vatAbsenceReason", errors, fieldProblems),
9016
9008
  isValid: valid.vatAbsenceReason,
9017
9009
  children: (childProps) => jsx(Select, {
@@ -9023,7 +9015,7 @@ function VatNumber(props) {
9023
9015
  id: reason,
9024
9016
  name: i18n.get(reason)
9025
9017
  })),
9026
- placeholder: i18n.get("vatNumberAbsenceReason")
9018
+ placeholder: i18n.get("vatAbsenceReason")
9027
9019
  })
9028
9020
  }) : null]
9029
9021
  });
@@ -9416,6 +9408,9 @@ const companySearchBase = {
9416
9408
  },
9417
9409
  dateOfIncorporation: {
9418
9410
  rule: "countryRequiresDateOfIncorporationForCompanies"
9411
+ },
9412
+ registrationNumber: {
9413
+ rule: "countryRequiresRegistrationNumberForCompanies"
9419
9414
  }
9420
9415
  };
9421
9416
  const taxIdBase$1 = {
@@ -9531,10 +9526,7 @@ const companySearchFieldsPerScenario = {
9531
9526
  }
9532
9527
  },
9533
9528
  L1: {
9534
- ...companySearchBase,
9535
- taxInformation: {
9536
- rule: "countryRequiresTaxInformationForSearch"
9537
- }
9529
+ ...companySearchBase
9538
9530
  },
9539
9531
  L: {
9540
9532
  ...companySearchBase,
@@ -9563,9 +9555,6 @@ const countryConfig$4 = {
9563
9555
  },
9564
9556
  legalEntityType: {
9565
9557
  label: "companyType"
9566
- },
9567
- taxInformation: {
9568
- label: "australianBusinessNumberAbn"
9569
9558
  }
9570
9559
  },
9571
9560
  [CountryCodes.Austria]: {
@@ -9573,13 +9562,10 @@ const countryConfig$4 = {
9573
9562
  label: "vatNumberExempted"
9574
9563
  },
9575
9564
  vatAbsenceReason: {
9576
- label: "vatNumberAbsenceReason"
9565
+ label: "vatAbsenceReason"
9577
9566
  },
9578
9567
  exemptedFromRegistrationNumber: {
9579
9568
  label: "doNotHaveFirmenbuchnummer"
9580
- },
9581
- exemptedFromBusinessRegistrationNumber: {
9582
- label: "doNotHaveFirmenbuchnummer"
9583
9569
  }
9584
9570
  },
9585
9571
  [CountryCodes.Belgium]: {
@@ -9587,7 +9573,7 @@ const countryConfig$4 = {
9587
9573
  label: "vatNumberExempted"
9588
9574
  },
9589
9575
  vatAbsenceReason: {
9590
- label: "vatNumberAbsenceReason"
9576
+ label: "vatAbsenceReason"
9591
9577
  }
9592
9578
  },
9593
9579
  [CountryCodes.Brazil]: {},
@@ -9603,14 +9589,8 @@ const countryConfig$4 = {
9603
9589
  exemptedFromRegistrationNumber: {
9604
9590
  label: "doNotHaveBusinessIncorporationNumber"
9605
9591
  },
9606
- exemptedFromBusinessRegistrationNumber: {
9607
- label: "doNotHaveBusinessIncorporationNumber"
9608
- },
9609
9592
  exemptedFromTax: {
9610
9593
  label: "doNotHaveBusinessNumber"
9611
- },
9612
- taxInformation: {
9613
- label: "businessNumber"
9614
9594
  }
9615
9595
  },
9616
9596
  [CountryCodes.Croatia]: {
@@ -9625,7 +9605,7 @@ const countryConfig$4 = {
9625
9605
  },
9626
9606
  [CountryCodes.CzechRepublic]: {
9627
9607
  vatAbsenceReason: {
9628
- label: "vatNumberAbsenceReason"
9608
+ label: "vatAbsenceReason"
9629
9609
  },
9630
9610
  exemptedFromVat: {
9631
9611
  label: "vatNumberExempted"
@@ -9645,9 +9625,6 @@ const countryConfig$4 = {
9645
9625
  exemptedFromRegistrationNumber: {
9646
9626
  label: "doNotHaveYTunnus"
9647
9627
  },
9648
- exemptedFromBusinessRegistrationNumber: {
9649
- label: "doNotHaveYTunnus"
9650
- },
9651
9628
  exemptedFromVat: {
9652
9629
  label: "vatNumberExempted"
9653
9630
  }
@@ -9657,14 +9634,11 @@ const countryConfig$4 = {
9657
9634
  exemptedFromRegistrationNumber: {
9658
9635
  label: "doNotHaveHandelsregisternummer"
9659
9636
  },
9660
- exemptedFromBusinessRegistrationNumber: {
9661
- label: "doNotHaveHandelsregisternummer"
9662
- },
9663
9637
  exemptedFromVat: {
9664
9638
  label: "vatNumberExempted"
9665
9639
  },
9666
9640
  vatAbsenceReason: {
9667
- label: "vatNumberAbsenceReason"
9641
+ label: "vatAbsenceReason"
9668
9642
  }
9669
9643
  },
9670
9644
  [CountryCodes.Gibraltar]: {},
@@ -9704,7 +9678,7 @@ const countryConfig$4 = {
9704
9678
  label: "vatNumberExempted"
9705
9679
  },
9706
9680
  vatAbsenceReason: {
9707
- label: "vatNumberAbsenceReason"
9681
+ label: "vatAbsenceReason"
9708
9682
  }
9709
9683
  },
9710
9684
  [CountryCodes.Japan]: {
@@ -9727,9 +9701,6 @@ const countryConfig$4 = {
9727
9701
  exemptedFromRegistrationNumber: {
9728
9702
  label: "doNotHaveLtRegistrationNumber"
9729
9703
  },
9730
- exemptedFromBusinessRegistrationNumber: {
9731
- label: "doNotHaveLtRegistrationNumber"
9732
- },
9733
9704
  exemptedFromVat: {
9734
9705
  label: "vatNumberExempted"
9735
9706
  }
@@ -9738,9 +9709,6 @@ const countryConfig$4 = {
9738
9709
  exemptedFromRegistrationNumber: {
9739
9710
  label: "doNotHaveLuRegistrationNumber"
9740
9711
  },
9741
- exemptedFromBusinessRegistrationNumber: {
9742
- label: "doNotHaveLuRegistrationNumber"
9743
- },
9744
9712
  exemptedFromVat: {
9745
9713
  label: "vatNumberExempted"
9746
9714
  }
@@ -9765,7 +9733,7 @@ const countryConfig$4 = {
9765
9733
  label: "vatNumberExempted"
9766
9734
  },
9767
9735
  vatAbsenceReason: {
9768
- label: "vatNumberAbsenceReason"
9736
+ label: "vatAbsenceReason"
9769
9737
  }
9770
9738
  },
9771
9739
  [CountryCodes.NewZealand]: {
@@ -9784,21 +9752,18 @@ const countryConfig$4 = {
9784
9752
  label: "vatNumberExempted"
9785
9753
  },
9786
9754
  vatAbsenceReason: {
9787
- label: "vatNumberAbsenceReason"
9755
+ label: "vatAbsenceReason"
9788
9756
  }
9789
9757
  },
9790
9758
  [CountryCodes.Poland]: {
9791
9759
  exemptedFromRegistrationNumber: {
9792
9760
  label: "doNotHaveRegonKrsNumber"
9793
9761
  },
9794
- exemptedFromBusinessRegistrationNumber: {
9795
- label: "doNotHaveRegonKrsNumber"
9796
- },
9797
9762
  exemptedFromVat: {
9798
9763
  label: "vatNumberExempted"
9799
9764
  },
9800
9765
  vatAbsenceReason: {
9801
- label: "vatNumberAbsenceReason"
9766
+ label: "vatAbsenceReason"
9802
9767
  }
9803
9768
  },
9804
9769
  [CountryCodes.Portugal]: {
@@ -9806,7 +9771,7 @@ const countryConfig$4 = {
9806
9771
  label: "vatNumberExempted"
9807
9772
  },
9808
9773
  vatAbsenceReason: {
9809
- label: "vatNumberAbsenceReason"
9774
+ label: "vatAbsenceReason"
9810
9775
  }
9811
9776
  },
9812
9777
  [CountryCodes.PuertoRico]: {},
@@ -9830,7 +9795,7 @@ const countryConfig$4 = {
9830
9795
  label: "vatNumberExempted"
9831
9796
  },
9832
9797
  vatAbsenceReason: {
9833
- label: "vatNumberAbsenceReason"
9798
+ label: "vatAbsenceReason"
9834
9799
  }
9835
9800
  },
9836
9801
  [CountryCodes.Singapore]: {
@@ -9851,23 +9816,17 @@ const countryConfig$4 = {
9851
9816
  exemptedFromRegistrationNumber: {
9852
9817
  label: "doNotHaveOrganisationsnummer"
9853
9818
  },
9854
- exemptedFromBusinessRegistrationNumber: {
9855
- label: "doNotHaveOrganisationsnummer"
9856
- },
9857
9819
  exemptedFromVat: {
9858
9820
  label: "vatNumberExempted"
9859
9821
  },
9860
9822
  vatAbsenceReason: {
9861
- label: "vatNumberAbsenceReason"
9823
+ label: "vatAbsenceReason"
9862
9824
  }
9863
9825
  },
9864
9826
  [CountryCodes.Switzerland]: {
9865
9827
  exemptedFromRegistrationNumber: {
9866
9828
  label: "doNotHaveChRegistrationNumber"
9867
9829
  },
9868
- exemptedFromBusinessRegistrationNumber: {
9869
- label: "doNotHaveChRegistrationNumber"
9870
- },
9871
9830
  exemptedFromVat: {
9872
9831
  label: "vatNumberExempted"
9873
9832
  }
@@ -9893,14 +9852,6 @@ const countryConfig$4 = {
9893
9852
  label: "employerIdentificationNumber"
9894
9853
  },
9895
9854
  /* CompanySearchComponent specific fields */
9896
- taxInformation: {
9897
- label: "taxInformationNumber__US",
9898
- helperText: "taxInformationNumber__helperText__US"
9899
- },
9900
- businessRegistrationNumber: {
9901
- label: "businessRegistrationNumber",
9902
- placeholder: "businessRegistrationNumber__placeholder__US"
9903
- },
9904
9855
  stockExchangeMIC: {
9905
9856
  label: "stockExchangeMIC__US",
9906
9857
  placeholder: "stockExchangeMIC__placeholder__US"
@@ -12674,13 +12625,13 @@ const rules$2 = ({
12674
12625
  },
12675
12626
  stockExchangeMICIfTypePublic: () => {
12676
12627
  var _a, _b;
12677
- if (((_a = data == null ? void 0 : data.companyType) == null ? void 0 : _a.entityType) === CompanyTypesValue.PUBLIC_COMPANY || ((_b = data == null ? void 0 : data.companyStructure) == null ? void 0 : _b.entityType) === CompanyTypesValue.PUBLIC_COMPANY) {
12628
+ if ("companyType" in data && (((_a = data.companyType) == null ? void 0 : _a.entityType) === CompanyTypesValue.PUBLIC_COMPANY || ((_b = data.companyStructure) == null ? void 0 : _b.entityType) === CompanyTypesValue.PUBLIC_COMPANY)) {
12678
12629
  return "REQUIRED";
12679
12630
  }
12680
12631
  },
12681
12632
  stockISINIfTypePublic: () => {
12682
12633
  var _a, _b;
12683
- if (((_a = data == null ? void 0 : data.companyType) == null ? void 0 : _a.entityType) === CompanyTypesValue.PUBLIC_COMPANY || ((_b = data == null ? void 0 : data.companyStructure) == null ? void 0 : _b.entityType) === CompanyTypesValue.PUBLIC_COMPANY) {
12634
+ if ("companyType" in data && (((_a = data.companyType) == null ? void 0 : _a.entityType) === CompanyTypesValue.PUBLIC_COMPANY || ((_b = data.companyStructure) == null ? void 0 : _b.entityType) === CompanyTypesValue.PUBLIC_COMPANY)) {
12684
12635
  return "REQUIRED";
12685
12636
  }
12686
12637
  },
@@ -12690,7 +12641,7 @@ const rules$2 = ({
12690
12641
  }
12691
12642
  },
12692
12643
  countryUsesTaxId: () => {
12693
- if (COUNTRIES_THAT_USE_TAX_ID_INSTEAD_OF_VAT.includes(country2) && !("solePropNameAndCountry" in data && COUNTRIES_THAT_DO_NOT_USE_TAX_ID_FOR_SOLE_PROP.includes(country2))) {
12644
+ if (COUNTRIES_THAT_USE_TAX_ID_INSTEAD_OF_VAT.includes(country2) && !(taskType === TaskTypes.SOLE_PROPRIETOR_COMPANY && COUNTRIES_THAT_DO_NOT_USE_TAX_ID_FOR_SOLE_PROP.includes(country2))) {
12694
12645
  return "REQUIRED";
12695
12646
  }
12696
12647
  },
@@ -12701,7 +12652,7 @@ const rules$2 = ({
12701
12652
  },
12702
12653
  companyRegistrationNumberExemptionAllowed: () => {
12703
12654
  var _a, _b;
12704
- const companyType2 = ((_a = data == null ? void 0 : data.companyType) == null ? void 0 : _a.entityType) || ((_b = data == null ? void 0 : data.companyStructure) == null ? void 0 : _b.entityType);
12655
+ const companyType2 = "companyType" in data && (((_a = data.companyType) == null ? void 0 : _a.entityType) || ((_b = data.companyStructure) == null ? void 0 : _b.entityType));
12705
12656
  if (country2 === "DE" && (companyType2 === CompanyTypesValue.GOVERNMENTAL_ORGANIZATION || companyType2 === CompanyTypesValue.NON_PROFIT_OR_CHARITABLE)) {
12706
12657
  return "REQUIRED";
12707
12658
  }
@@ -13146,7 +13097,7 @@ const companySearchBaseMapping = {
13146
13097
  "companyRegistrationAddress.operationalAddress.otherAddressInformation": "organization.principalPlaceOfBusiness.street2",
13147
13098
  "companyStructure.entityType": "organization.type",
13148
13099
  "companyOtherDetails.tradingName": "organization.doingBusinessAs",
13149
- "companyOtherDetails.businessRegistrationNumber": "organization.registrationNumber",
13100
+ "companyOtherDetails.registrationNumber": "organization.registrationNumber",
13150
13101
  "companyOtherDetails.taxInformation": "organization.taxInformation",
13151
13102
  "companyOtherDetails.vatNumber": "organization.vatNumber",
13152
13103
  "companyOtherDetails.vatAbsenceReason": "organization.vatAbsenceReason",
@@ -21689,7 +21640,7 @@ const trackNavigation = ({
21689
21640
  }
21690
21641
  });
21691
21642
  };
21692
- const getOpeningStep$1 = (forms2, remediationActions) => {
21643
+ const getOpeningStep = (forms2, remediationActions) => {
21693
21644
  var _a;
21694
21645
  if (remediationActions && Object.keys(remediationActions).length > 0) {
21695
21646
  const allRemediationActions = Object.values(remediationActions).flat().filter((rem) => {
@@ -21735,7 +21686,7 @@ const useFormComposer = ({
21735
21686
  useEffect(() => {
21736
21687
  if (hasAlreadyNavigatedForm)
21737
21688
  return;
21738
- const openingStep = getOpeningStep$1(forms2, problems == null ? void 0 : problems.remediationActions);
21689
+ const openingStep = getOpeningStep(forms2, problems == null ? void 0 : problems.remediationActions);
21739
21690
  if (activeForm !== openingStep) {
21740
21691
  setActiveForm(openingStep);
21741
21692
  }
@@ -23315,7 +23266,7 @@ const getTargetLegalEntityType = (businessType, legalArrangement, trusteeType, c
23315
23266
  }
23316
23267
  return currentLegalEntityType;
23317
23268
  };
23318
- const FormComposer = "";
23269
+ const FormWrapper$1 = "";
23319
23270
  const logger$e = createLogger("FormRouterContextProvider");
23320
23271
  function FormRouterContextProvider({
23321
23272
  children,
@@ -23570,16 +23521,16 @@ const FormWrapper = ({
23570
23521
  })
23571
23522
  });
23572
23523
  };
23573
- const parseConfiguration$3 = ({
23524
+ const parseConfiguration$5 = ({
23574
23525
  country: country2,
23575
23526
  matchingScenario
23576
23527
  }) => parseCompanyScenarios(matchingScenario == null ? void 0 : matchingScenario[LegalEntityType.ORGANIZATION], country2);
23577
- const canSubmit$1 = (data) => mandatoryApiFields.ORGANIZATION.every((detail) => {
23528
+ const canSubmit$2 = (data) => mandatoryApiFields.ORGANIZATION.every((detail) => {
23578
23529
  const value = getProp(data, detail);
23579
23530
  return !isEmpty(value);
23580
23531
  });
23581
- const isDocumentsRequired$1 = (forms2) => forms2.some((form) => [companyForms.companyRegistrationDocument.formId, companyForms.companyTaxDocument.formId].includes(form.formId));
23582
- const formatFileSummaryData = (companyRegistrationDocument2, companyTaxDocument) => {
23532
+ const isDocumentsRequired$2 = (forms2) => forms2.some((form) => [companyForms.companyRegistrationDocument.formId, companyForms.companyTaxDocument.formId].includes(form.formId));
23533
+ const formatFileSummaryData$1 = (companyRegistrationDocument2, companyTaxDocument) => {
23583
23534
  var _a, _b;
23584
23535
  const registrationDocument2 = (_a = companyRegistrationDocument2 == null ? void 0 : companyRegistrationDocument2.registrationDocument) == null ? void 0 : _a[0];
23585
23536
  const taxDocument2 = (_b = companyTaxDocument == null ? void 0 : companyTaxDocument.taxDocument) == null ? void 0 : _b[0];
@@ -23667,7 +23618,7 @@ function CompanyDropinComponent({
23667
23618
  fieldConfigurations,
23668
23619
  requiredFields
23669
23620
  } = useScenarioConfiguration({
23670
- parseConfiguration: parseConfiguration$3,
23621
+ parseConfiguration: parseConfiguration$5,
23671
23622
  getConfigurationData,
23672
23623
  setLoadingStatus,
23673
23624
  country: country2
@@ -23703,7 +23654,7 @@ function CompanyDropinComponent({
23703
23654
  legalEntity,
23704
23655
  dataSubmitted
23705
23656
  }) => {
23706
- if (!isDocumentsRequired$1(forms22))
23657
+ if (!isDocumentsRequired$2(forms22))
23707
23658
  return;
23708
23659
  const formattedDocument = await mapCompanyDocumentToApiDocument(dataSubmitted, legalEntity.id);
23709
23660
  if (formattedDocument) {
@@ -23871,16 +23822,16 @@ function CompanyDropinComponent({
23871
23822
  summaryData.companyRegistrationAddress.operationalAddress = mapAddressLabels(summaryData == null ? void 0 : summaryData.companyRegistrationAddress.operationalAddress, datasetUtils);
23872
23823
  }
23873
23824
  if ((_h = summaryData.companyRegistrationDetails) == null ? void 0 : _h.vatAbsenceReason) {
23874
- const vatAbsenceReason = vatAbsenceReasons.find((absenceReason) => absenceReason === summaryData.companyRegistrationDetails.vatAbsenceReason);
23875
- if (vatAbsenceReason) {
23876
- summaryData.companyRegistrationDetails.vatAbsenceReason = i18n.get(vatAbsenceReason);
23825
+ const vatAbsenceReason2 = vatAbsenceReasons.find((absenceReason) => absenceReason === summaryData.companyRegistrationDetails.vatAbsenceReason);
23826
+ if (vatAbsenceReason2) {
23827
+ summaryData.companyRegistrationDetails.vatAbsenceReason = i18n.get(vatAbsenceReason2);
23877
23828
  }
23878
23829
  }
23879
- if (isDocumentsRequired$1(forms22)) {
23830
+ if (isDocumentsRequired$2(forms22)) {
23880
23831
  companyDocumentForms.forEach((formId) => delete summaryData[formId]);
23881
23832
  summaryData = {
23882
23833
  ...summaryData,
23883
- ...formatFileSummaryData(data2.companyRegistrationDocument, data2.companyTaxDocument)
23834
+ ...formatFileSummaryData$1(data2.companyRegistrationDocument, data2.companyTaxDocument)
23884
23835
  };
23885
23836
  }
23886
23837
  return summaryData;
@@ -23916,7 +23867,7 @@ function CompanyDropinComponent({
23916
23867
  baseTrackingPayload,
23917
23868
  onSubmit,
23918
23869
  problems,
23919
- canSubmit: canSubmit$1(data) && hasDataChanged(dataFromResponse, data),
23870
+ canSubmit: canSubmit$2(data) && hasDataChanged(dataFromResponse, data),
23920
23871
  summary: {
23921
23872
  data: formatDataForSummary2(data, forms2),
23922
23873
  omittedKeys: ["operationalAddressIsSame"]
@@ -23950,6 +23901,7 @@ function useCompanySearch({
23950
23901
  taxIdentificationNumber: taxIdentificationNumber2,
23951
23902
  canVerify,
23952
23903
  limit = 15,
23904
+ setKompanyAddress,
23953
23905
  handleChangeFor,
23954
23906
  handleCompanyIndexSearch,
23955
23907
  handleCompanyDeepSearch,
@@ -24005,7 +23957,7 @@ function useCompanySearch({
24005
23957
  } finally {
24006
23958
  setStatus((prevStatus) => prevStatus !== "error" ? "loaded" : prevStatus);
24007
23959
  }
24008
- }, 500), []);
23960
+ }, 700), []);
24009
23961
  const retrySearch = useCallback(async () => {
24010
23962
  if (!legalCompanyName2 || !country2 || !stateOrProvince2) {
24011
23963
  return setStatus("idle");
@@ -24089,17 +24041,17 @@ function useCompanySearch({
24089
24041
  setStatus("loading");
24090
24042
  setSelectedCompanyId(void 0);
24091
24043
  setVerifiedCompany(void 0);
24044
+ setKompanyAddress(void 0);
24092
24045
  setCompaniesList([]);
24093
24046
  if (defaultData) {
24094
- entriesOf(defaultData).forEach(([field, value]) => {
24095
- handleChangeFor(field)(value);
24096
- });
24047
+ handleChangeFor("legalCompanyName")(defaultData.legalCompanyName);
24097
24048
  }
24098
- }, [defaultData, handleChangeFor]);
24049
+ }, [defaultData, handleChangeFor, setKompanyAddress]);
24099
24050
  useEffect(() => {
24100
24051
  var _a;
24101
24052
  setError(void 0);
24102
- if (!legalCompanyName2 || !country2 || !stateOrProvince2 || !taxIdentificationNumber2 || !canVerify) {
24053
+ const isMinLength = legalCompanyName2 && legalCompanyName2.split("").length > 3;
24054
+ if (!legalCompanyName2 || !country2 || !stateOrProvince2 || !taxIdentificationNumber2 || !canVerify || !isMinLength) {
24103
24055
  return setStatus("idle");
24104
24056
  }
24105
24057
  if (!verifiedCompany) {
@@ -24134,6 +24086,15 @@ function useCompanySearch({
24134
24086
  reset
24135
24087
  };
24136
24088
  }
24089
+ const mapKompanyOrganizationTypeToCompanyType = (organizationType) => {
24090
+ const organizationTypeValue = organizationType == null ? void 0 : organizationType.toLowerCase();
24091
+ switch (organizationTypeValue) {
24092
+ case "business":
24093
+ return CompanyTypesValue.PRIVATE_COMPANY;
24094
+ default:
24095
+ return void 0;
24096
+ }
24097
+ };
24137
24098
  const mapCompanyDataResponseToFormSchema = (company2) => ({
24138
24099
  companyBasics: {
24139
24100
  country: company2.country,
@@ -24148,8 +24109,11 @@ const mapCompanyDataResponseToFormSchema = (company2) => ({
24148
24109
  postalCode: company2.zipcode
24149
24110
  }
24150
24111
  },
24112
+ companyStructure: {
24113
+ entityType: mapKompanyOrganizationTypeToCompanyType(company2.organizationType)
24114
+ },
24151
24115
  companyOtherDetails: {
24152
- businessRegistrationNumber: company2.registrationNumber
24116
+ registrationNumber: company2.registrationNumber
24153
24117
  }
24154
24118
  });
24155
24119
  const CompanyLookupResultsHeader = ({
@@ -24271,13 +24235,17 @@ const LookupResult = ({
24271
24235
  return "verified";
24272
24236
  }
24273
24237
  }, [status, isError]);
24274
- const selectAndVerify = (companyTin, company2) => {
24275
- if (ref.current) {
24276
- ref.current.scrollIntoView({
24277
- behavior: "smooth"
24278
- });
24238
+ const selectAndVerify = async (companyTin, company2) => {
24239
+ try {
24240
+ await onSelect(companyTin, company2);
24241
+ } finally {
24242
+ if (ref.current) {
24243
+ ref.current.scrollIntoView({
24244
+ behavior: "smooth",
24245
+ block: "center"
24246
+ });
24247
+ }
24279
24248
  }
24280
- return onSelect(companyTin, company2);
24281
24249
  };
24282
24250
  if (isSelected && verifiedCompany) {
24283
24251
  return jsxs("div", {
@@ -24347,9 +24315,17 @@ const CompanyLookupResultsList = ({
24347
24315
  }
24348
24316
  return "adyen-company-lookup-results-list__result-option";
24349
24317
  };
24318
+ const resultsList = useMemo(() => {
24319
+ if (verifiedCompany) {
24320
+ const filtered = results.filter((option) => option.id !== verifiedCompany.id);
24321
+ const verified2 = results.find((option) => option.id === verifiedCompany.id);
24322
+ return verified2 ? [verified2, ...filtered] : results;
24323
+ }
24324
+ return results;
24325
+ }, [verifiedCompany, results]);
24350
24326
  return jsx("div", {
24351
24327
  className: "adyen-company-lookup-results-list",
24352
- children: results.map((option) => jsx("div", {
24328
+ children: resultsList.map((option) => jsx("div", {
24353
24329
  children: jsx(LookupResult, {
24354
24330
  classes: optionClasses(option),
24355
24331
  option,
@@ -24391,6 +24367,7 @@ function CompanyLookup({
24391
24367
  taxInformationNumber: taxInformationNumber2,
24392
24368
  setLoading,
24393
24369
  setKompanyAddress,
24370
+ setKompanyVerifiedData,
24394
24371
  handleChangeFor,
24395
24372
  handleCompanyIndexSearch,
24396
24373
  handleCompanyDeepSearch,
@@ -24418,6 +24395,7 @@ function CompanyLookup({
24418
24395
  stateOrProvince: stateOrProvince2,
24419
24396
  taxIdentificationNumber: taxInformationNumber2,
24420
24397
  canVerify,
24398
+ setKompanyAddress,
24421
24399
  handleChangeFor,
24422
24400
  handleCompanyIndexSearch,
24423
24401
  handleCompanyDeepSearch,
@@ -24431,11 +24409,14 @@ function CompanyLookup({
24431
24409
  const companyLookupClasses = status === "idle" || !canVerify ? "adyen-kyc-company-lookup adyen-kyc-company-lookup--hidden" : "adyen-kyc-company-lookup";
24432
24410
  const mappedData = useMemo$1(() => {
24433
24411
  if (verifiedCompany) {
24412
+ const verifiedData = mapCompanyDataResponseToFormSchema(verifiedCompany);
24434
24413
  setKompanyAddress(verifiedCompany.address);
24435
- return mapCompanyDataResponseToFormSchema(verifiedCompany);
24414
+ setKompanyVerifiedData(verifiedData);
24415
+ return verifiedData;
24436
24416
  }
24417
+ setKompanyVerifiedData(void 0);
24437
24418
  setKompanyAddress(void 0);
24438
- }, [setKompanyAddress, verifiedCompany]);
24419
+ }, [setKompanyAddress, setKompanyVerifiedData, verifiedCompany]);
24439
24420
  useEffect$1(() => {
24440
24421
  if (mappedData == null ? void 0 : mappedData.companyBasics) {
24441
24422
  entriesOf(mappedData.companyBasics).forEach(([field, data]) => {
@@ -24471,13 +24452,36 @@ function CompanyLookup({
24471
24452
  });
24472
24453
  }
24473
24454
  const CompanyLookupComponent = memo(CompanyLookup, (prevProps, nextProps) => objectsDeepEqual(prevProps.defaultData, nextProps.defaultData) && prevProps.canVerify === nextProps.canVerify && prevProps.legalCompanyName === nextProps.legalCompanyName && prevProps.country === nextProps.country && prevProps.stateOrProvince === nextProps.stateOrProvince && prevProps.taxInformationNumber === nextProps.taxInformationNumber && prevProps.setLoading === nextProps.setLoading && prevProps.setKompanyAddress === nextProps.setKompanyAddress && prevProps.handleCompanyIndexSearch === nextProps.handleCompanyIndexSearch && prevProps.handleCompanyDeepSearch === nextProps.handleCompanyDeepSearch && prevProps.handleGetCompanyDataset === nextProps.handleGetCompanyDataset && prevProps.handleRefreshCompanyDataset === nextProps.handleRefreshCompanyDataset && prevProps.handleVerifyTin === nextProps.handleVerifyTin);
24455
+ const CountryFieldValidation = () => ({
24456
+ country: {
24457
+ modes: ["blur"],
24458
+ validate: (country2) => !isEmpty(country2),
24459
+ errorMessage: "fieldIsRequired"
24460
+ }
24461
+ });
24462
+ const LegalCompanyNameFieldValidation = () => ({
24463
+ legalCompanyName: {
24464
+ modes: ["blur"],
24465
+ validate: (legalCompanyName2) => !isEmpty(legalCompanyName2),
24466
+ errorMessage: "fieldIsRequired"
24467
+ }
24468
+ });
24469
+ const StateFieldValidation = () => ({
24470
+ stateOrProvince: {
24471
+ modes: ["blur"],
24472
+ validate: (stateOrProvince2) => !isEmpty(stateOrProvince2),
24473
+ errorMessage: "fieldIsRequired"
24474
+ }
24475
+ });
24474
24476
  const TAX_INFORMATION_FIELD = ["taxInformation", "exemptedFromTax", "isUen"];
24475
24477
  function TaxInformationField({
24476
24478
  data,
24477
24479
  valid,
24478
24480
  errors,
24479
24481
  labels: labels2,
24480
- helperText,
24482
+ mask,
24483
+ guidanceText,
24484
+ placeholders,
24481
24485
  readonly,
24482
24486
  handleChangeFor,
24483
24487
  country: country2,
@@ -24487,11 +24491,7 @@ function TaxInformationField({
24487
24491
  var _a;
24488
24492
  return (_a = data == null ? void 0 : data.taxInformation) == null ? void 0 : _a.find((taxInfo) => taxInfo.country === country2);
24489
24493
  }, [data, country2]);
24490
- const handleTaxInformationInput = (e) => {
24491
- var _a;
24492
- const {
24493
- value
24494
- } = e.target;
24494
+ const handleTaxInformationInput = (value) => {
24495
24495
  if (!data.taxInformation) {
24496
24496
  const updatedTaxInformation2 = [{
24497
24497
  country: country2,
@@ -24500,7 +24500,12 @@ function TaxInformationField({
24500
24500
  }];
24501
24501
  return handleChangeFor("taxInformation", "input")(updatedTaxInformation2);
24502
24502
  }
24503
- const updatedTaxInformation = (_a = data.taxInformation) == null ? void 0 : _a.map((taxInfo) => {
24503
+ const taxInformation = currentCountryTaxInformation ? data.taxInformation : [...data.taxInformation, {
24504
+ country: country2,
24505
+ number: value,
24506
+ type: countryToTaxInfoTypeMap[country2]
24507
+ }];
24508
+ const updatedTaxInformation = taxInformation.map((taxInfo) => {
24504
24509
  if (taxInfo.country !== country2)
24505
24510
  return taxInfo;
24506
24511
  return {
@@ -24512,7 +24517,6 @@ function TaxInformationField({
24512
24517
  return handleChangeFor("taxInformation", "input")(updatedTaxInformation);
24513
24518
  };
24514
24519
  const handleTaxInformationBlur = (e) => {
24515
- var _a;
24516
24520
  const {
24517
24521
  value
24518
24522
  } = e.target;
@@ -24524,7 +24528,12 @@ function TaxInformationField({
24524
24528
  }];
24525
24529
  return handleChangeFor("taxInformation", "blur")(updatedTaxInformation2);
24526
24530
  }
24527
- const updatedTaxInformation = (_a = data.taxInformation) == null ? void 0 : _a.map((taxInfo) => {
24531
+ const taxInformation = currentCountryTaxInformation ? data.taxInformation : [...data.taxInformation, {
24532
+ country: country2,
24533
+ number: value,
24534
+ type: countryToTaxInfoTypeMap[country2]
24535
+ }];
24536
+ const updatedTaxInformation = taxInformation.map((taxInfo) => {
24528
24537
  if (taxInfo.country !== country2)
24529
24538
  return taxInfo;
24530
24539
  return {
@@ -24536,23 +24545,22 @@ function TaxInformationField({
24536
24545
  return handleChangeFor("taxInformation", "blur")(updatedTaxInformation);
24537
24546
  };
24538
24547
  return jsxs(Fragment, {
24539
- children: [jsx(Field, {
24540
- name: "taxInformationField",
24541
- label: labels2.taxInformation,
24542
- helper: helperText == null ? void 0 : helperText.taxInformation,
24548
+ children: [jsx(MaskedInputText, {
24549
+ name: "taxInformationNumber",
24550
+ label: labels2.taxInformation ?? "",
24551
+ formatGuidance: (guidanceText == null ? void 0 : guidanceText.taxInformation) ?? "",
24552
+ value: (currentCountryTaxInformation == null ? void 0 : currentCountryTaxInformation.number) ?? "",
24543
24553
  errorMessage: errors.taxInformation,
24544
- isValid: valid.taxInformation,
24545
- children: (childProps) => jsx(InputText, {
24546
- ...childProps,
24547
- "aria-required": true,
24548
- "aria-label": labels2.taxInformation,
24549
- "aria-invalid": !valid.taxInformation,
24550
- name: "taxInformationNumber",
24551
- value: currentCountryTaxInformation == null ? void 0 : currentCountryTaxInformation.number,
24552
- onInput: handleTaxInformationInput,
24553
- onBlur: handleTaxInformationBlur,
24554
- readonly
24555
- })
24554
+ placeholder: placeholders == null ? void 0 : placeholders.taxInformation,
24555
+ isValid: Boolean(valid.taxInformation),
24556
+ "aria-required": true,
24557
+ "aria-label": labels2.taxInformation,
24558
+ "aria-invalid": !valid.taxInformation,
24559
+ onInput: handleTaxInformationInput,
24560
+ onBlur: handleTaxInformationBlur,
24561
+ disabled: data.exemptedFromTax,
24562
+ readonly,
24563
+ ...mask
24556
24564
  }), canExempt && jsx(Checkbox, {
24557
24565
  "aria-required": false,
24558
24566
  "aria-label": labels2.exemptedFromTax,
@@ -24566,116 +24574,95 @@ function TaxInformationField({
24566
24574
  })]
24567
24575
  });
24568
24576
  }
24569
- const DateOfIncorporationFieldValidation = () => ({
24570
- dateOfIncorporation: [{
24571
- modes: ["blur"],
24572
- validate: (dateOfIncorporation2) => !isEmpty(dateOfIncorporation2),
24573
- errorMessage: "fieldIsRequired"
24574
- }, {
24575
- modes: ["blur"],
24576
- validate: (dateOfIncorporation2) => dateOfIncorporation2 ? new Date(dateOfIncorporation2) < /* @__PURE__ */ new Date() : false,
24577
- errorMessage: "invalidDateOfIncorporation"
24578
- }]
24579
- });
24580
- const StockExchangeMICFieldValidation = () => ({
24581
- stockExchangeMIC: [{
24582
- modes: ["blur"],
24583
- validate: (stockExchangeMIC2) => !isEmpty(stockExchangeMIC2),
24584
- errorMessage: "fieldIsRequired"
24585
- }]
24586
- });
24587
- const StockISINFieldValidation = () => ({
24588
- stockISIN: [{
24589
- modes: ["blur"],
24590
- validate: (stockISIN2) => !isEmpty(stockISIN2),
24591
- errorMessage: "fieldIsRequired"
24592
- }, {
24593
- modes: ["blur"],
24594
- validate: (input) => exactLength(input, 12),
24595
- errorMessage: "validationPleaseEnterAValidStockISIN"
24596
- }]
24597
- });
24598
- const TradingNameFieldValidation = () => ({
24599
- tradingName: [{
24600
- modes: ["blur"],
24601
- validate: (tradingName2) => !isEmpty(tradingName2),
24602
- errorMessage: "fieldIsRequired"
24603
- }]
24577
+ const taxInformationFieldValidation = (pattern, country2) => ({
24578
+ modes: ["blur"],
24579
+ validate: (taxInformation) => {
24580
+ var _a;
24581
+ const taxIdNumber2 = (_a = taxInformation == null ? void 0 : taxInformation.find((taxId2) => country2 === taxId2.country)) == null ? void 0 : _a.number;
24582
+ return taxIdNumber2 ? pattern.test(taxIdNumber2) : false;
24583
+ }
24604
24584
  });
24605
- const BusinessRegistrationNumberValidation = (country2, companyType2, registrationNumberType) => {
24606
- const metadata = resolveFieldMetadata(defaultFieldConfig$2[country2], {
24607
- companyType: companyType2,
24608
- registrationNumberType
24609
- }, defaultFieldMetadata$2);
24610
- return {
24611
- businessRegistrationNumber: metadata.validators
24612
- };
24585
+ const defaultFieldMetadata = {
24586
+ label: "taxId"
24613
24587
  };
24614
- const TaxInformationFieldValidation = (country2, taxIdNumberType) => {
24615
- const metadata = resolveFieldMetadata(defaultFieldConfig$1[country2], {
24588
+ const defaultFieldConfig = {
24589
+ ...defaultFieldConfig$2,
24590
+ [CountryCodes.Canada]: {
24591
+ ...defaultFieldConfig$2.CA,
24592
+ validators: taxInformationFieldValidation(/^\d{9}$/, CountryCodes.Canada)
24593
+ },
24594
+ [CountryCodes.HongKong]: {
24595
+ ...defaultFieldConfig$2.HK,
24596
+ validators: taxInformationFieldValidation(/^\d{8}$/, CountryCodes.HongKong)
24597
+ },
24598
+ [CountryCodes.Australia]: {
24599
+ ...defaultFieldConfig$2.AU,
24600
+ validators: taxInformationFieldValidation(/^\d{11}$/, CountryCodes.Australia)
24601
+ },
24602
+ [CountryCodes.NewZealand]: {
24603
+ ...defaultFieldConfig$2.NZ,
24604
+ validators: taxInformationFieldValidation(/^\d{8,9}$/, CountryCodes.NewZealand)
24605
+ },
24606
+ [CountryCodes.Singapore]: {
24607
+ ...defaultFieldConfig$2.SG,
24608
+ validators: taxInformationFieldValidation(/^[A-Z0-9]{9,10}$/, CountryCodes.Singapore)
24609
+ },
24610
+ [CountryCodes.UnitedStates]: ({
24616
24611
  taxIdNumberType
24617
- }, defaultFieldMetadata$1);
24618
- if (!metadata.validators)
24619
- return {};
24620
- const validators = Array.isArray(metadata.validators) ? metadata.validators : [metadata.validators];
24621
- return {
24622
- taxInformation: validators.map((validator) => ({
24623
- modes: ["blur"],
24624
- validate: (taxInfos) => (taxInfos == null ? void 0 : taxInfos.every((taxInfo) => validator.validate(taxInfo.number))) ?? false,
24625
- errorMessage: metadata.helperText
24626
- }))
24627
- };
24628
- };
24629
- const VatNumberFieldValidation = (country2, vatNumberType) => {
24630
- const metadata = resolveFieldMetadata(defaultFieldConfig[country2], {
24631
- vatNumberType
24632
- }, defaultFieldMetadata);
24633
- if (!metadata.validators)
24634
- return {};
24635
- const validators = Array.isArray(metadata.validators) ? metadata.validators : [metadata.validators];
24636
- return {
24637
- vatNumber: validators.map((validator) => ({
24638
- ...validator,
24639
- errorMessage: metadata.helperText
24640
- }))
24641
- };
24642
- };
24643
- const CompanyOtherDetailsValidationRules = (country2, companyType2) => ({
24644
- ...TradingNameFieldValidation(),
24645
- ...StockISINFieldValidation(),
24646
- ...StockExchangeMICFieldValidation(),
24647
- ...TaxInformationFieldValidation(country2),
24648
- ...DateOfIncorporationFieldValidation(),
24649
- ...BusinessRegistrationNumberValidation(country2, companyType2),
24650
- ...VatNumberFieldValidation(country2)
24651
- });
24652
- const CountryFieldValidation = () => ({
24653
- country: {
24654
- modes: ["blur"],
24655
- validate: (country2) => !isEmpty(country2),
24656
- errorMessage: "fieldIsRequired"
24657
- }
24658
- });
24659
- const LegalCompanyNameFieldValidation = () => ({
24660
- legalCompanyName: {
24661
- modes: ["blur"],
24662
- validate: (legalCompanyName2) => !isEmpty(legalCompanyName2),
24663
- errorMessage: "fieldIsRequired"
24664
- }
24665
- });
24666
- const StateFieldValidation = () => ({
24667
- stateOrProvince: {
24668
- modes: ["blur"],
24669
- validate: (stateOrProvince2) => !isEmpty(stateOrProvince2),
24670
- errorMessage: "fieldIsRequired"
24612
+ }) => {
24613
+ switch (taxIdNumberType) {
24614
+ case "ssn":
24615
+ return {
24616
+ label: "socialSecurityNumber9Digits",
24617
+ validators: taxInformationFieldValidation(/^\d{9}$/, CountryCodes.UnitedStates),
24618
+ mask: {
24619
+ mask: makeMask(...numericInputs(9))
24620
+ }
24621
+ };
24622
+ case "ssnLastFour":
24623
+ return {
24624
+ label: "last4DigitsOfSocialSecurityNumber",
24625
+ validators: taxInformationFieldValidation(/^\d{4}$/, CountryCodes.UnitedStates),
24626
+ mask: {
24627
+ mask: makeMask(...nonInputs("*** — ** — "), ...numericInputs(4))
24628
+ }
24629
+ };
24630
+ case "ein":
24631
+ default:
24632
+ return {
24633
+ label: "employerIdentificationNumber",
24634
+ validators: taxInformationFieldValidation(/^\d{9}$/, CountryCodes.UnitedStates),
24635
+ mask: {
24636
+ mask: makeMask(...numericInputs(9))
24637
+ },
24638
+ guidanceText: {
24639
+ key: "validationPleaseEnterAValidTaxIdNumberWithFormat",
24640
+ values: {
24641
+ format: "XXXXXXXXX"
24642
+ }
24643
+ }
24644
+ };
24645
+ }
24646
+ },
24647
+ /**
24648
+ * NOT YET SUPPORTED
24649
+ * These are brought over from the old pattern files. We have no idea if they are accurate or not.
24650
+ * See https://en.wikipedia.org/wiki/VAT_identification_number
24651
+ */
24652
+ [CountryCodes.India]: {
24653
+ validators: taxInformationFieldValidation(/^[A-Z0-9]{15}$/, CountryCodes.India)
24654
+ },
24655
+ [CountryCodes.Japan]: {
24656
+ validators: taxInformationFieldValidation(/^\d{13}$/, CountryCodes.Japan)
24657
+ },
24658
+ [CountryCodes.Mexico]: {
24659
+ validators: taxInformationFieldValidation(/^\D{3}\d{6}\w{3}$/, CountryCodes.Mexico)
24660
+ // Examples: P&G851223B24, LFM200817DGA
24661
+ },
24662
+ [CountryCodes.Philippines]: {
24663
+ validators: taxInformationFieldValidation(/^\d{12}$/, CountryCodes.Philippines)
24671
24664
  }
24672
- });
24673
- const CompanyBasicsValidationRules = (country2) => ({
24674
- ...LegalCompanyNameFieldValidation(),
24675
- ...CountryFieldValidation(),
24676
- ...StateFieldValidation(),
24677
- ...TaxInformationFieldValidation(country2)
24678
- });
24665
+ };
24679
24666
  const COMPANY_BASICS_FORM_ID = "companyBasics";
24680
24667
  const companyBasicsFields = [...LEGAL_COMPANY_NAME_FIELD, ...COUNTRY_FIELD, ...STATE_FIELD, ...TAX_INFORMATION_FIELD];
24681
24668
  function CompanyBasics({
@@ -24698,8 +24685,11 @@ function CompanyBasics({
24698
24685
  handleGetCompanyDataset,
24699
24686
  handleRefreshCompanyDataset,
24700
24687
  handleVerifyTin,
24688
+ country: country2,
24689
+ isTopLevelEntity,
24701
24690
  kompanyAddress,
24702
- setKompanyAddress
24691
+ setKompanyAddress,
24692
+ setKompanyVerifiedData
24703
24693
  }) {
24704
24694
  var _a, _b;
24705
24695
  const {
@@ -24709,12 +24699,59 @@ function CompanyBasics({
24709
24699
  isSettingEnabled
24710
24700
  } = useSettingsContext();
24711
24701
  const {
24712
- sliceData,
24713
24702
  updateStateSlice
24714
24703
  } = useGlobalDataSlice(COMPANY_BASICS_FORM_ID);
24715
- const schema = (requiredFields == null ? void 0 : requiredFields.length) ? requiredFields : ["legalCompanyName", "country"];
24716
- const validationRules = CompanyBasicsValidationRules((sliceData == null ? void 0 : sliceData.country) ?? (data == null ? void 0 : data.country));
24717
24704
  const [loading2, setLoading] = useState$1(false);
24705
+ const allowedCountries = useAllowedCountries();
24706
+ const initialFormUtilsProps = useMemo$1(() => ({
24707
+ labels: labels2,
24708
+ placeholders,
24709
+ helperText,
24710
+ readOnly,
24711
+ requiredFields,
24712
+ readOnlyFields,
24713
+ optionalFields,
24714
+ maskedFields,
24715
+ shouldValidate
24716
+ }), [helperText, labels2, maskedFields, optionalFields, placeholders, readOnly, readOnlyFields, requiredFields, shouldValidate]);
24717
+ const mergedFieldProps = useMemo$1(() => {
24718
+ var _a2;
24719
+ return (_a2 = initialFormUtilsProps.requiredFields) == null ? void 0 : _a2.reduce((acc, field) => {
24720
+ switch (field) {
24721
+ case "legalCompanyName":
24722
+ return {
24723
+ ...acc,
24724
+ validators: {
24725
+ ...acc.validators,
24726
+ ...LegalCompanyNameFieldValidation()
24727
+ }
24728
+ };
24729
+ case "country":
24730
+ return {
24731
+ ...acc,
24732
+ validators: {
24733
+ ...acc.validators,
24734
+ ...CountryFieldValidation()
24735
+ }
24736
+ };
24737
+ case "stateOrProvince":
24738
+ return {
24739
+ ...acc,
24740
+ validators: {
24741
+ ...acc.validators,
24742
+ ...StateFieldValidation()
24743
+ }
24744
+ };
24745
+ case "taxInformation":
24746
+ return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig[country2], {
24747
+ taxIdNumberType: countryToTaxInfoTypeMap[country2]
24748
+ }, defaultFieldMetadata), acc);
24749
+ default:
24750
+ return acc;
24751
+ }
24752
+ }, initialFormUtilsProps);
24753
+ }, [country2, initialFormUtilsProps]);
24754
+ const schema = (requiredFields == null ? void 0 : requiredFields.length) ? requiredFields : ["legalCompanyName", "country"];
24718
24755
  const {
24719
24756
  schema: formSchema,
24720
24757
  data: formData,
@@ -24726,35 +24763,17 @@ function CompanyBasics({
24726
24763
  } = useForm({
24727
24764
  schema,
24728
24765
  defaultData: data,
24729
- rules: validationRules,
24766
+ rules: mergedFieldProps == null ? void 0 : mergedFieldProps.validators,
24767
+ optionalFields: mergedFieldProps == null ? void 0 : mergedFieldProps.optionalFields,
24768
+ maskedFields: mergedFieldProps == null ? void 0 : mergedFieldProps.maskedFields,
24730
24769
  fieldProblems: fieldValidationErrors,
24731
- optionalFields,
24732
- maskedFields,
24733
24770
  shouldValidate
24734
24771
  });
24735
24772
  const isAllowedEditPrefilledCountry = isSettingEnabled(SettingNames.AllowPrefilledCountryEdit);
24736
- const formUtils = formUtilities({
24737
- labels: labels2,
24738
- placeholders,
24739
- helperText,
24740
- readOnly,
24741
- requiredFields,
24742
- readOnlyFields,
24743
- optionalFields
24744
- }, i18n);
24773
+ const formUtils = formUtilities(mergedFieldProps ?? initialFormUtilsProps, i18n);
24745
24774
  const hasCompanySearchProvider = formData.country && COUNTRIES_WITH_IN_APP_SEARCH_COMPANY_VERIFICATION.includes(formData.country);
24746
24775
  const currentCountryTaxIdNumber = (_b = (_a = formData.taxInformation) == null ? void 0 : _a.find((taxInfo) => taxInfo.country === formData.country)) == null ? void 0 : _b.number;
24747
- const {
24748
- legalCompanyNameDisabled,
24749
- countryDisabled,
24750
- stateOrProvinceDisabled,
24751
- taxInformationDisabled
24752
- } = useMemo$1(() => ({
24753
- legalCompanyNameDisabled: formUtils.isReadOnly("legalCompanyName") || Boolean(kompanyAddress) || loading2,
24754
- countryDisabled: !isAllowedEditPrefilledCountry || formUtils.isReadOnly("country") || Boolean(kompanyAddress) || loading2,
24755
- stateOrProvinceDisabled: formUtils.isReadOnly("stateOrProvince") || Boolean(kompanyAddress) || loading2,
24756
- taxInformationDisabled: formUtils.isReadOnly("taxInformation") || Boolean(kompanyAddress) || loading2
24757
- }), [kompanyAddress, formUtils, isAllowedEditPrefilledCountry, loading2]);
24776
+ const disabled = (field) => formUtils.isReadOnly(field) || Boolean(kompanyAddress) || loading2;
24758
24777
  useEffect$1(() => {
24759
24778
  updateStateSlice({
24760
24779
  schema: formSchema,
@@ -24785,7 +24804,7 @@ function CompanyBasics({
24785
24804
  helperText: formUtils.getFieldHelperText(LEGAL_COMPANY_NAME_FIELD, {
24786
24805
  legalCompanyName: "legalCompanyName__helperText"
24787
24806
  }),
24788
- readonly: legalCompanyNameDisabled,
24807
+ readonly: disabled("legalCompanyName"),
24789
24808
  handleChangeFor
24790
24809
  })
24791
24810
  }), formUtils.isRequiredField("country") && jsx("div", {
@@ -24795,8 +24814,9 @@ function CompanyBasics({
24795
24814
  valid: formUtils.getFieldValid(formValid, COUNTRY_FIELD),
24796
24815
  errors: formUtils.getFieldErrors(formErrors, formFieldProblems, COUNTRY_FIELD),
24797
24816
  labels: formUtils.getFieldLabels(COUNTRY_FIELD),
24798
- readonly: countryDisabled,
24799
- handleChangeFor
24817
+ readonly: disabled("country") || !isAllowedEditPrefilledCountry,
24818
+ handleChangeFor,
24819
+ allowedCountries: isTopLevelEntity ? allowedCountries : void 0
24800
24820
  })
24801
24821
  }), formUtils.isRequiredField("stateOrProvince") && jsx("div", {
24802
24822
  className: "adyen-kyc-field-wrapper",
@@ -24805,7 +24825,7 @@ function CompanyBasics({
24805
24825
  valid: formUtils.getFieldValid(formValid, STATE_FIELD),
24806
24826
  errors: formUtils.getFieldErrors(formErrors, formFieldProblems, STATE_FIELD),
24807
24827
  labels: formUtils.getFieldLabels(STATE_FIELD),
24808
- readonly: stateOrProvinceDisabled,
24828
+ readonly: disabled("stateOrProvince"),
24809
24829
  handleChangeFor,
24810
24830
  selectedCountry: formData.country
24811
24831
  })
@@ -24816,11 +24836,14 @@ function CompanyBasics({
24816
24836
  valid: formUtils.getFieldValid(formValid, TAX_INFORMATION_FIELD),
24817
24837
  errors: formUtils.getFieldErrors(formErrors, formFieldProblems, TAX_INFORMATION_FIELD),
24818
24838
  labels: formUtils.getFieldLabels(TAX_INFORMATION_FIELD),
24819
- readonly: taxInformationDisabled,
24839
+ mask: formUtils.getMask("taxInformation"),
24840
+ helperText: formUtils.getFieldHelperText(TAX_INFORMATION_FIELD),
24841
+ guidanceText: formUtils.getFieldGuidanceText(TAX_INFORMATION_FIELD),
24842
+ readonly: disabled("taxInformation"),
24820
24843
  handleChangeFor,
24821
- country: formData.country,
24822
24844
  canExempt: formUtils.isRequiredField("exemptedFromTax"),
24823
- isUen: formUtils.isRequiredField("isUen")
24845
+ isUen: formUtils.isRequiredField("isUen"),
24846
+ country: formData.country
24824
24847
  })
24825
24848
  }), hasCompanySearchProvider && jsx(CompanyLookupComponent, {
24826
24849
  defaultData: data,
@@ -24832,6 +24855,7 @@ function CompanyBasics({
24832
24855
  handleChangeFor,
24833
24856
  setLoading,
24834
24857
  setKompanyAddress,
24858
+ setKompanyVerifiedData,
24835
24859
  handleCompanyIndexSearch,
24836
24860
  handleCompanyDeepSearch,
24837
24861
  handleGetCompanyDataset,
@@ -24843,53 +24867,51 @@ function CompanyBasics({
24843
24867
  }
24844
24868
  const CompanyBasicsComponent = memo(CompanyBasics, (prevProps, nextProps) => objectsDeepEqual(prevProps.data, nextProps.data) && objectsDeepEqual(prevProps.labels, nextProps.labels) && objectsDeepEqual(prevProps.placeholders, nextProps.placeholders) && objectsDeepEqual(prevProps.helperText, nextProps.helperText) && objectsDeepEqual(prevProps.formVerificationErrors, nextProps.formVerificationErrors) && objectsDeepEqual(prevProps.fieldValidationErrors, nextProps.fieldValidationErrors) && prevProps.heading === nextProps.heading && prevProps.description === nextProps.description && prevProps.readOnly === nextProps.readOnly && prevProps.requiredFields === nextProps.requiredFields && prevProps.maskedFields === nextProps.maskedFields && prevProps.optionalFields === nextProps.optionalFields && prevProps.readOnlyFields === nextProps.readOnlyFields && prevProps.shouldValidate === nextProps.shouldValidate && prevProps.kompanyAddress === nextProps.kompanyAddress);
24845
24869
  const CompanyOtherDetailsComponent$1 = "";
24846
- const BUSINESS_REGISTRATION_NUMBER_FIELD = ["businessRegistrationNumber", "exemptedFromBusinessRegistrationNumber"];
24870
+ const BUSINESS_REGISTRATION_NUMBER_FIELD = ["registrationNumber", "exemptedFromRegistrationNumber"];
24847
24871
  function BusinessRegistrationNumberField({
24848
24872
  data,
24849
24873
  valid,
24850
24874
  errors,
24851
24875
  labels: labels2,
24876
+ mask,
24877
+ guidanceText,
24852
24878
  placeholders,
24853
- helperText,
24854
24879
  readonly,
24855
- classNameModifiers,
24856
24880
  canExempt,
24857
24881
  handleChangeFor
24858
24882
  }) {
24859
24883
  return jsxs(Fragment, {
24860
- children: [jsx(Field, {
24861
- name: "businessRegistrationNumberField",
24862
- label: labels2 == null ? void 0 : labels2.businessRegistrationNumber,
24863
- helper: helperText == null ? void 0 : helperText.businessRegistrationNumber,
24864
- errorMessage: errors.businessRegistrationNumber,
24865
- isValid: valid.businessRegistrationNumber,
24866
- classNameModifiers,
24867
- children: (childProps) => jsx(InputText, {
24868
- ...childProps,
24869
- "aria-required": true,
24870
- "aria-label": labels2 == null ? void 0 : labels2.businessRegistrationNumber,
24871
- "aria-invalid": !valid.businessRegistrationNumber,
24872
- name: "businessRegistrationNumber",
24873
- value: data.businessRegistrationNumber,
24874
- placeholder: placeholders == null ? void 0 : placeholders.businessRegistrationNumber,
24875
- disabled: data.exemptedFromBusinessRegistrationNumber,
24876
- readonly,
24877
- required: true,
24878
- classNameModifiers: ["businessRegistrationNumber"],
24879
- onInput: handleChangeFor("businessRegistrationNumber", "input"),
24880
- onBlur: handleChangeFor("businessRegistrationNumber", "blur")
24881
- })
24884
+ children: [jsx(MaskedInputText, {
24885
+ "aria-required": true,
24886
+ "aria-label": labels2.registrationNumber,
24887
+ "aria-invalid": !valid.registrationNumber,
24888
+ classNameModifiers: {
24889
+ field: ["registrationNumber"],
24890
+ input: ["registrationNumber"]
24891
+ },
24892
+ name: "registrationNumber",
24893
+ value: (data == null ? void 0 : data.registrationNumber) ?? "",
24894
+ label: labels2.registrationNumber ?? "",
24895
+ formatGuidance: (guidanceText == null ? void 0 : guidanceText.registrationNumber) ?? "",
24896
+ placeholder: placeholders == null ? void 0 : placeholders.registrationNumber,
24897
+ errorMessage: errors.registrationNumber,
24898
+ isValid: Boolean(valid.registrationNumber),
24899
+ onInput: handleChangeFor("registrationNumber", "input"),
24900
+ onBlur: handleChangeFor("registrationNumber", "blur"),
24901
+ disabled: data.exemptedFromRegistrationNumber,
24902
+ readonly,
24903
+ ...mask
24882
24904
  }), canExempt && jsx(Checkbox, {
24883
24905
  "aria-required": false,
24884
- "aria-label": labels2 == null ? void 0 : labels2.exemptedFromBusinessRegistrationNumber,
24906
+ "aria-label": labels2 == null ? void 0 : labels2.exemptedFromRegistrationNumber,
24885
24907
  "aria-invalid": false,
24886
- name: "exemptedFromBusinessRegistrationNumber",
24887
- value: "exemptedFromBusinessRegistrationNumber",
24888
- checked: Boolean(data.exemptedFromBusinessRegistrationNumber),
24889
- label: labels2 == null ? void 0 : labels2.exemptedFromBusinessRegistrationNumber,
24908
+ name: "exemptedFromRegistrationNumber",
24909
+ value: "exemptedFromRegistrationNumber",
24910
+ checked: Boolean(data.exemptedFromRegistrationNumber),
24911
+ label: labels2 == null ? void 0 : labels2.exemptedFromRegistrationNumber,
24890
24912
  readonly,
24891
24913
  classNameModifiers: ["exempted-from-registration"],
24892
- onChange: handleChangeFor("exemptedFromBusinessRegistrationNumber")
24914
+ onChange: handleChangeFor("exemptedFromRegistrationNumber")
24893
24915
  })]
24894
24916
  });
24895
24917
  }
@@ -24924,6 +24946,17 @@ function DateOfIncorporationField({
24924
24946
  })
24925
24947
  });
24926
24948
  }
24949
+ const DateOfIncorporationFieldValidation = () => ({
24950
+ dateOfIncorporation: [{
24951
+ modes: ["blur"],
24952
+ validate: (dateOfIncorporation2) => !isEmpty(dateOfIncorporation2),
24953
+ errorMessage: "fieldIsRequired"
24954
+ }, {
24955
+ modes: ["blur"],
24956
+ validate: (dateOfIncorporation2) => dateOfIncorporation2 ? new Date(dateOfIncorporation2) < /* @__PURE__ */ new Date() : false,
24957
+ errorMessage: "invalidDateOfIncorporation"
24958
+ }]
24959
+ });
24927
24960
  const STOCK_EXCHANGE_MIC_FIELD = ["stockExchangeMIC"];
24928
24961
  function StockExchangeMICField({
24929
24962
  data,
@@ -24957,6 +24990,13 @@ function StockExchangeMICField({
24957
24990
  })
24958
24991
  });
24959
24992
  }
24993
+ const StockExchangeMICFieldValidation = () => ({
24994
+ stockExchangeMIC: [{
24995
+ modes: ["blur"],
24996
+ validate: (stockExchangeMIC2) => !isEmpty(stockExchangeMIC2),
24997
+ errorMessage: "fieldIsRequired"
24998
+ }]
24999
+ });
24960
25000
  const STOCK_ISIN_FIELD = ["stockISIN"];
24961
25001
  function StockISINField({
24962
25002
  data,
@@ -24990,6 +25030,17 @@ function StockISINField({
24990
25030
  })
24991
25031
  });
24992
25032
  }
25033
+ const StockISINFieldValidation = () => ({
25034
+ stockISIN: [{
25035
+ modes: ["blur"],
25036
+ validate: (stockISIN2) => !isEmpty(stockISIN2),
25037
+ errorMessage: "fieldIsRequired"
25038
+ }, {
25039
+ modes: ["blur"],
25040
+ validate: (input) => exactLength(input, 12),
25041
+ errorMessage: "validationPleaseEnterAValidStockISIN"
25042
+ }]
25043
+ });
24993
25044
  const TRADING_NAME_FIELD = ["tradingName", "sameNameAsLegalName"];
24994
25045
  function TradingNameField({
24995
25046
  data,
@@ -25041,12 +25092,21 @@ function TradingNameField({
25041
25092
  })]
25042
25093
  });
25043
25094
  }
25095
+ const TradingNameFieldValidation = () => ({
25096
+ tradingName: [{
25097
+ modes: ["blur"],
25098
+ validate: (tradingName2) => !isEmpty(tradingName2),
25099
+ errorMessage: "fieldIsRequired"
25100
+ }]
25101
+ });
25044
25102
  const VAT_NUMBER_FIELD = ["vatNumber", "exemptedFromVat", "vatAbsenceReason"];
25045
25103
  function VatNumberField({
25046
25104
  data,
25047
25105
  valid,
25048
25106
  errors,
25049
25107
  labels: labels2,
25108
+ mask,
25109
+ guidanceText,
25050
25110
  placeholders,
25051
25111
  readonly,
25052
25112
  handleChangeFor,
@@ -25056,25 +25116,26 @@ function VatNumberField({
25056
25116
  i18n
25057
25117
  } = useI18nContext();
25058
25118
  return jsxs(Fragment, {
25059
- children: [jsx(Field, {
25119
+ children: [jsx(MaskedInputText, {
25120
+ "aria-required": true,
25121
+ "aria-label": labels2.vatNumber,
25122
+ "aria-invalid": !valid.vatNumber,
25123
+ classNameModifiers: {
25124
+ field: ["tax-id"],
25125
+ input: ["vatNumber"]
25126
+ },
25060
25127
  name: "vatNumber",
25061
- label: labels2 == null ? void 0 : labels2.vatNumber,
25062
- classNameModifiers: ["tax-id"],
25128
+ value: (data == null ? void 0 : data.vatNumber) ?? "",
25129
+ label: labels2.vatNumber ?? "",
25130
+ formatGuidance: (guidanceText == null ? void 0 : guidanceText.vatNumber) ?? "",
25131
+ placeholder: placeholders == null ? void 0 : placeholders.vatNumber,
25063
25132
  errorMessage: errors.vatNumber,
25064
- isValid: valid.vatNumber,
25065
- children: (childProps) => jsx(InputText, {
25066
- ...childProps,
25067
- "aria-required": true,
25068
- "aria-label": labels2 == null ? void 0 : labels2.vatNumber,
25069
- "aria-invalid": !valid.vatNumber,
25070
- name: "vatNumber",
25071
- value: data.vatNumber,
25072
- readonly,
25073
- classNameModifiers: ["vatNumber"],
25074
- onInput: handleChangeFor("vatNumber", "input"),
25075
- onBlur: handleChangeFor("vatNumber", "blur"),
25076
- disabled: data.exemptedFromVat
25077
- })
25133
+ isValid: Boolean(valid.vatNumber),
25134
+ onInput: handleChangeFor("vatNumber", "input"),
25135
+ onBlur: handleChangeFor("vatNumber", "blur"),
25136
+ disabled: data.exemptedFromVat,
25137
+ readonly,
25138
+ ...mask
25078
25139
  }), canExempt && jsx(Checkbox, {
25079
25140
  "aria-required": false,
25080
25141
  "aria-label": labels2 == null ? void 0 : labels2.exemptedFromVat,
@@ -25124,43 +25185,119 @@ function CompanyOtherDetails({
25124
25185
  readOnlyFields,
25125
25186
  country: country2,
25126
25187
  legalCompanyName: legalCompanyName2,
25127
- companyType: companyType2
25188
+ companyType: companyType2,
25189
+ kompanyVerifiedData
25128
25190
  }) {
25191
+ var _a, _b, _c, _d;
25129
25192
  const {
25130
25193
  i18n
25131
25194
  } = useI18nContext();
25195
+ const {
25196
+ isExperimentEnabled
25197
+ } = useExperimentsContext();
25132
25198
  const {
25133
25199
  sliceData,
25134
25200
  updateStateSlice
25135
25201
  } = useGlobalDataSlice(COMPANY_OTHER_DETAILS_FORM_ID);
25202
+ const [registrationNumberType, setRegistrationNumberType] = useState$1((data == null ? void 0 : data.registrationNumber) ? inferCompanyRegistrationNumberType(data == null ? void 0 : data.registrationNumber, country2, companyType2) : (_a = companyRegistrationNumberOptions[country2]) == null ? void 0 : _a[0].id);
25203
+ const existingTaxIdentificationNumber = (data == null ? void 0 : data.vatNumber) ?? ((_c = (_b = data == null ? void 0 : data.taxInformation) == null ? void 0 : _b.find((taxId2) => taxId2.country === country2)) == null ? void 0 : _c.number);
25204
+ const [taxIdentificationNumberType, setTaxIdentificationNumberType] = useState$1(existingTaxIdentificationNumber ? inferTaxIdNumberType(existingTaxIdentificationNumber, country2) : (_d = taxIdNumberOptions[country2]) == null ? void 0 : _d[0].id);
25205
+ const isTypeSelectorEnabled = isExperimentEnabled(ExperimentNames.EnableIdentityFieldTypeSelector);
25136
25206
  const directChildFields = companyOtherDetailsFields.filter((field) => ["tradingName", "sameNameAsLegalName", "stockExchangeMIC", "stockISIN", "dateOfIncorporation"].includes(field));
25137
25207
  const schema = useMemo$1(() => !(sliceData == null ? void 0 : sliceData.exemptedFromVat) ? (requiredFields == null ? void 0 : requiredFields.filter((field) => field !== "vatAbsenceReason")) ?? directChildFields : (requiredFields == null ? void 0 : requiredFields.filter((field) => field !== "vatNumber")) ?? directChildFields, [requiredFields, directChildFields, sliceData]);
25138
- const validationRules = useMemo$1(() => CompanyOtherDetailsValidationRules(country2, companyType2), [companyType2, country2]);
25208
+ const initialFormUtilsProps = useMemo$1(() => ({
25209
+ labels: labels2,
25210
+ placeholders,
25211
+ helperText,
25212
+ readOnly,
25213
+ requiredFields,
25214
+ readOnlyFields,
25215
+ optionalFields,
25216
+ maskedFields,
25217
+ shouldValidate
25218
+ }), [helperText, labels2, maskedFields, optionalFields, placeholders, readOnly, readOnlyFields, requiredFields, shouldValidate]);
25219
+ const mergedFieldProps = useMemo$1(() => {
25220
+ var _a2;
25221
+ return (_a2 = initialFormUtilsProps.requiredFields) == null ? void 0 : _a2.reduce((acc, field) => {
25222
+ switch (field) {
25223
+ case "tradingName":
25224
+ return {
25225
+ ...acc,
25226
+ validators: {
25227
+ ...acc.validators,
25228
+ ...TradingNameFieldValidation()
25229
+ }
25230
+ };
25231
+ case "dateOfIncorporation":
25232
+ return {
25233
+ ...acc,
25234
+ validators: {
25235
+ ...acc.validators,
25236
+ ...DateOfIncorporationFieldValidation()
25237
+ }
25238
+ };
25239
+ case "stockExchangeMIC":
25240
+ return {
25241
+ ...acc,
25242
+ validators: {
25243
+ ...acc.validators,
25244
+ ...StockExchangeMICFieldValidation()
25245
+ }
25246
+ };
25247
+ case "stockISIN":
25248
+ return {
25249
+ ...acc,
25250
+ validators: {
25251
+ ...acc.validators,
25252
+ ...StockISINFieldValidation()
25253
+ }
25254
+ };
25255
+ case "registrationNumber":
25256
+ return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$3[country2], {
25257
+ companyType: companyType2,
25258
+ registrationNumberType
25259
+ }, defaultFieldMetadata$3), acc);
25260
+ case "taxInformation":
25261
+ return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig[country2], {
25262
+ taxIdNumberType: taxIdentificationNumberType
25263
+ }, defaultFieldMetadata), acc);
25264
+ case "vatNumber":
25265
+ return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$1[country2], {
25266
+ vatNumberType: taxIdentificationNumberType
25267
+ }, defaultFieldMetadata$1), acc);
25268
+ default:
25269
+ return acc;
25270
+ }
25271
+ }, initialFormUtilsProps);
25272
+ }, [companyType2, country2, initialFormUtilsProps, registrationNumberType, taxIdentificationNumberType]);
25139
25273
  const {
25140
25274
  schema: formSchema,
25141
25275
  data: formData,
25142
25276
  errors: formErrors,
25143
25277
  valid: formValid,
25144
25278
  fieldProblems: formFieldProblems,
25145
- handleChangeFor
25279
+ handleChangeFor,
25280
+ triggerValidation
25146
25281
  } = useForm({
25147
25282
  schema,
25148
25283
  defaultData: data,
25149
- rules: validationRules,
25284
+ rules: mergedFieldProps == null ? void 0 : mergedFieldProps.validators,
25285
+ optionalFields: mergedFieldProps == null ? void 0 : mergedFieldProps.optionalFields,
25286
+ maskedFields: mergedFieldProps == null ? void 0 : mergedFieldProps.maskedFields,
25150
25287
  fieldProblems: fieldValidationErrors,
25151
- optionalFields,
25152
- maskedFields,
25153
25288
  shouldValidate
25154
25289
  });
25155
- const formUtils = formUtilities({
25156
- labels: labels2,
25157
- placeholders,
25158
- helperText,
25159
- readOnly,
25160
- requiredFields,
25161
- readOnlyFields,
25162
- optionalFields
25163
- }, i18n);
25290
+ const formUtils = formUtilities(mergedFieldProps ?? initialFormUtilsProps, i18n);
25291
+ const handleBusinessRegistrationNumberTypeChange = useCallback$1((type) => {
25292
+ setRegistrationNumberType(type);
25293
+ triggerValidation(["registrationNumber"]);
25294
+ }, [triggerValidation]);
25295
+ const handleTaxIdentificationNumberTypeChange = useCallback$1((type) => {
25296
+ setTaxIdentificationNumberType(type);
25297
+ triggerValidation(["vatNumber", "taxInformation"]);
25298
+ }, [triggerValidation]);
25299
+ useEffect$1(() => {
25300
+ }, [kompanyVerifiedData]);
25164
25301
  useEffect$1(() => {
25165
25302
  updateStateSlice({
25166
25303
  schema: formSchema,
@@ -25198,6 +25335,61 @@ function CompanyOtherDetails({
25198
25335
  handleChangeFor,
25199
25336
  legalCompanyName: legalCompanyName2
25200
25337
  })
25338
+ }), isTypeSelectorEnabled && companyType2 && formUtils.isRequiredField("registrationNumber") && jsx(CompanyRegistrationNumberTypeSelector, {
25339
+ companyType: companyType2,
25340
+ country: country2,
25341
+ setSelected: handleBusinessRegistrationNumberTypeChange,
25342
+ selected: registrationNumberType
25343
+ }), formUtils.isRequiredField("registrationNumber") && jsx("div", {
25344
+ className: "adyen-kyc-field-wrapper",
25345
+ children: jsx(BusinessRegistrationNumberField, {
25346
+ data: formUtils.getFieldData(formData, BUSINESS_REGISTRATION_NUMBER_FIELD),
25347
+ valid: formUtils.getFieldValid(formValid, BUSINESS_REGISTRATION_NUMBER_FIELD),
25348
+ errors: formUtils.getFieldErrors(formErrors, formFieldProblems, BUSINESS_REGISTRATION_NUMBER_FIELD),
25349
+ labels: formUtils.getFieldLabels(BUSINESS_REGISTRATION_NUMBER_FIELD),
25350
+ mask: formUtils.getMask("registrationNumber"),
25351
+ guidanceText: formUtils.getFieldGuidanceText(BUSINESS_REGISTRATION_NUMBER_FIELD),
25352
+ placeholders: formUtils.getFieldPlaceholders(BUSINESS_REGISTRATION_NUMBER_FIELD),
25353
+ helperText: formUtils.getFieldHelperText(BUSINESS_REGISTRATION_NUMBER_FIELD),
25354
+ readonly: formUtils.isReadOnly("registrationNumber"),
25355
+ handleChangeFor,
25356
+ canExempt: formUtils.isRequiredField("exemptedFromRegistrationNumber")
25357
+ })
25358
+ }), isTypeSelectorEnabled && formUtils.isRequiredField("vatNumber") && jsx(TaxIdNumberTypeSelector, {
25359
+ country: country2,
25360
+ setSelected: handleTaxIdentificationNumberTypeChange,
25361
+ selected: taxIdentificationNumberType
25362
+ }), formUtils.isRequiredField("vatNumber") && jsx("div", {
25363
+ className: "adyen-kyc-field-wrapper",
25364
+ children: jsx(VatNumberField, {
25365
+ data: formUtils.getFieldData(formData, VAT_NUMBER_FIELD),
25366
+ valid: formUtils.getFieldValid(formValid, VAT_NUMBER_FIELD),
25367
+ errors: formUtils.getFieldErrors(formErrors, formFieldProblems, VAT_NUMBER_FIELD),
25368
+ labels: formUtils.getFieldLabels(VAT_NUMBER_FIELD),
25369
+ mask: formUtils.getMask("vatNumber"),
25370
+ guidanceText: formUtils.getFieldGuidanceText(VAT_NUMBER_FIELD),
25371
+ placeholders: formUtils.getFieldPlaceholders(VAT_NUMBER_FIELD),
25372
+ readonly: formUtils.isReadOnly("vatNumber"),
25373
+ handleChangeFor,
25374
+ country: country2,
25375
+ canExempt: formUtils.isRequiredField("exemptedFromVat")
25376
+ })
25377
+ }), formUtils.isRequiredField("taxInformation") && jsx("div", {
25378
+ className: "adyen-kyc-field-wrapper",
25379
+ children: jsx(TaxInformationField, {
25380
+ data: formUtils.getFieldData(formData, TAX_INFORMATION_FIELD),
25381
+ valid: formUtils.getFieldValid(formValid, TAX_INFORMATION_FIELD),
25382
+ errors: formUtils.getFieldErrors(formErrors, formFieldProblems, TAX_INFORMATION_FIELD),
25383
+ labels: formUtils.getFieldLabels(TAX_INFORMATION_FIELD),
25384
+ mask: formUtils.getMask("taxInformation"),
25385
+ helperText: formUtils.getFieldHelperText(TAX_INFORMATION_FIELD),
25386
+ guidanceText: formUtils.getFieldGuidanceText(TAX_INFORMATION_FIELD),
25387
+ readonly: formUtils.isReadOnly("taxInformation"),
25388
+ handleChangeFor,
25389
+ country: country2,
25390
+ canExempt: formUtils.isRequiredField("exemptedFromTax"),
25391
+ isUen: formUtils.isRequiredField("isUen")
25392
+ })
25201
25393
  }), formUtils.isRequiredField("dateOfIncorporation") && jsx("div", {
25202
25394
  className: "adyen-kyc-field-wrapper",
25203
25395
  children: jsx(DateOfIncorporationField, {
@@ -25236,50 +25428,11 @@ function CompanyOtherDetails({
25236
25428
  readonly: formUtils.isReadOnly("stockISIN"),
25237
25429
  handleChangeFor
25238
25430
  })
25239
- }), formUtils.isRequiredField("businessRegistrationNumber") && jsx("div", {
25240
- className: "adyen-kyc-field-wrapper",
25241
- children: jsx(BusinessRegistrationNumberField, {
25242
- data: formUtils.getFieldData(formData, BUSINESS_REGISTRATION_NUMBER_FIELD),
25243
- valid: formUtils.getFieldValid(formValid, BUSINESS_REGISTRATION_NUMBER_FIELD),
25244
- errors: formUtils.getFieldErrors(formErrors, formFieldProblems, BUSINESS_REGISTRATION_NUMBER_FIELD),
25245
- labels: formUtils.getFieldLabels(BUSINESS_REGISTRATION_NUMBER_FIELD),
25246
- placeholders: formUtils.getFieldPlaceholders(BUSINESS_REGISTRATION_NUMBER_FIELD),
25247
- helperText: formUtils.getFieldHelperText(BUSINESS_REGISTRATION_NUMBER_FIELD),
25248
- readonly: formUtils.isReadOnly("businessRegistrationNumber"),
25249
- handleChangeFor,
25250
- canExempt: formUtils.isRequiredField("exemptedFromBusinessRegistrationNumber")
25251
- })
25252
- }), formUtils.isRequiredField("taxInformation") && jsx("div", {
25253
- className: "adyen-kyc-field-wrapper",
25254
- children: jsx(TaxInformationField, {
25255
- data: formUtils.getFieldData(formData, TAX_INFORMATION_FIELD),
25256
- valid: formUtils.getFieldValid(formValid, TAX_INFORMATION_FIELD),
25257
- errors: formUtils.getFieldErrors(formErrors, formFieldProblems, TAX_INFORMATION_FIELD),
25258
- labels: formUtils.getFieldLabels(TAX_INFORMATION_FIELD),
25259
- readonly: formUtils.isReadOnly("taxInformation"),
25260
- handleChangeFor,
25261
- country: country2,
25262
- canExempt: formUtils.isRequiredField("exemptedFromTax"),
25263
- isUen: formUtils.isRequiredField("isUen")
25264
- })
25265
- }), formUtils.isRequiredField("vatNumber") && jsx("div", {
25266
- className: "adyen-kyc-field-wrapper",
25267
- children: jsx(VatNumberField, {
25268
- data: formUtils.getFieldData(formData, VAT_NUMBER_FIELD),
25269
- valid: formUtils.getFieldValid(formValid, VAT_NUMBER_FIELD),
25270
- errors: formUtils.getFieldErrors(formErrors, formFieldProblems, VAT_NUMBER_FIELD),
25271
- labels: formUtils.getFieldLabels(VAT_NUMBER_FIELD),
25272
- placeholders: formUtils.getFieldPlaceholders(VAT_NUMBER_FIELD),
25273
- readonly: formUtils.isReadOnly("vatNumber"),
25274
- handleChangeFor,
25275
- country: country2,
25276
- canExempt: formUtils.isRequiredField("exemptedFromVat")
25277
- })
25278
25431
  })]
25279
25432
  })]
25280
25433
  });
25281
25434
  }
25282
- const CompanyOtherDetailsComponent = memo(CompanyOtherDetails, (prevProps, nextProps) => objectsDeepEqual(prevProps.data, nextProps.data) && objectsDeepEqual(prevProps.labels, nextProps.labels) && objectsDeepEqual(prevProps.placeholders, nextProps.placeholders) && objectsDeepEqual(prevProps.helperText, nextProps.helperText) && objectsDeepEqual(prevProps.heading, nextProps.heading) && objectsDeepEqual(prevProps.description, nextProps.description) && objectsDeepEqual(prevProps.readOnly, nextProps.readOnly) && objectsDeepEqual(prevProps.requiredFields, nextProps.requiredFields) && objectsDeepEqual(prevProps.maskedFields, nextProps.maskedFields) && objectsDeepEqual(prevProps.optionalFields, nextProps.optionalFields) && objectsDeepEqual(prevProps.readOnlyFields, nextProps.readOnlyFields) && objectsDeepEqual(prevProps.shouldValidate, nextProps.shouldValidate) && objectsDeepEqual(prevProps.formVerificationErrors, nextProps.formVerificationErrors) && objectsDeepEqual(prevProps.fieldValidationErrors, nextProps.fieldValidationErrors) && prevProps.country === nextProps.country && prevProps.legalCompanyName === nextProps.legalCompanyName && prevProps.companyType === nextProps.companyType);
25435
+ const CompanyOtherDetailsComponent = memo(CompanyOtherDetails, (prevProps, nextProps) => objectsDeepEqual(prevProps.data, nextProps.data) && objectsDeepEqual(prevProps.labels, nextProps.labels) && objectsDeepEqual(prevProps.placeholders, nextProps.placeholders) && objectsDeepEqual(prevProps.helperText, nextProps.helperText) && objectsDeepEqual(prevProps.formVerificationErrors, nextProps.formVerificationErrors) && objectsDeepEqual(prevProps.fieldValidationErrors, nextProps.fieldValidationErrors) && prevProps.heading === nextProps.heading && prevProps.description === nextProps.description && prevProps.requiredFields === nextProps.requiredFields && prevProps.maskedFields === nextProps.maskedFields && prevProps.optionalFields === nextProps.optionalFields && prevProps.readOnlyFields === nextProps.readOnlyFields && prevProps.shouldValidate === nextProps.shouldValidate && prevProps.readOnly === nextProps.readOnly && prevProps.country === nextProps.country && prevProps.legalCompanyName === nextProps.legalCompanyName && prevProps.companyType === nextProps.companyType && prevProps.kompanyVerifiedData === nextProps.kompanyVerifiedData);
25283
25436
  const CompanyStructureComponent$1 = "";
25284
25437
  const CompanyStructureValidation = {
25285
25438
  entityType: {
@@ -25297,7 +25450,8 @@ function CompanyStructure({
25297
25450
  description: description2,
25298
25451
  formVerificationErrors,
25299
25452
  fieldValidationErrors,
25300
- requiredFields
25453
+ requiredFields,
25454
+ kompanyVerifiedData
25301
25455
  }) {
25302
25456
  const {
25303
25457
  i18n
@@ -25323,6 +25477,12 @@ function CompanyStructure({
25323
25477
  labels: labels2,
25324
25478
  requiredFields
25325
25479
  }, i18n);
25480
+ useEffect(() => {
25481
+ var _a, _b;
25482
+ if ((_a = kompanyVerifiedData == null ? void 0 : kompanyVerifiedData.companyStructure) == null ? void 0 : _a.entityType) {
25483
+ handleChangeFor("entityType")((_b = kompanyVerifiedData == null ? void 0 : kompanyVerifiedData.companyStructure) == null ? void 0 : _b.entityType);
25484
+ }
25485
+ }, [kompanyVerifiedData]);
25326
25486
  useEffect(() => {
25327
25487
  updateStateSlice({
25328
25488
  schema: formSchema,
@@ -25360,7 +25520,7 @@ function CompanyStructure({
25360
25520
  })]
25361
25521
  });
25362
25522
  }
25363
- const CompanyStructureComponent = memo(CompanyStructure, (prevProps, nextProps) => objectsDeepEqual(prevProps.data, nextProps.data) && objectsDeepEqual(prevProps.labels, nextProps.labels) && objectsDeepEqual(prevProps.heading, nextProps.heading) && objectsDeepEqual(prevProps.description, nextProps.description) && objectsDeepEqual(prevProps.formVerificationErrors, nextProps.formVerificationErrors) && objectsDeepEqual(prevProps.fieldValidationErrors, nextProps.fieldValidationErrors) && objectsDeepEqual(prevProps.requiredFields, nextProps.requiredFields));
25523
+ const CompanyStructureComponent = memo(CompanyStructure, (prevProps, nextProps) => objectsDeepEqual(prevProps.data, nextProps.data) && objectsDeepEqual(prevProps.labels, nextProps.labels) && objectsDeepEqual(prevProps.heading, nextProps.heading) && objectsDeepEqual(prevProps.description, nextProps.description) && objectsDeepEqual(prevProps.formVerificationErrors, nextProps.formVerificationErrors) && objectsDeepEqual(prevProps.fieldValidationErrors, nextProps.fieldValidationErrors) && objectsDeepEqual(prevProps.requiredFields, nextProps.requiredFields) && prevProps.kompanyVerifiedData === nextProps.kompanyVerifiedData);
25364
25524
  const forms = {
25365
25525
  companyBasics: {
25366
25526
  formId: "companyBasics",
@@ -25397,32 +25557,40 @@ const forms = {
25397
25557
  fields: ["taxDocument"]
25398
25558
  }
25399
25559
  };
25400
- const parseConfiguration$2 = ({
25560
+ const parseConfiguration$4 = ({
25401
25561
  country: country2,
25402
25562
  matchingScenario
25403
25563
  }) => parseCompanySearchScenarios(matchingScenario == null ? void 0 : matchingScenario[LegalEntityType.ORGANIZATION], country2);
25404
25564
  const mandatoryApiFieldsForCompanySearch = ["companyBasics.legalCompanyName", "companyBasics.country"];
25405
- const canSubmit = (data) => mandatoryApiFieldsForCompanySearch.every((detail) => {
25565
+ const canSubmit$1 = (data) => mandatoryApiFieldsForCompanySearch.every((detail) => {
25406
25566
  const value = getProp(data, detail);
25407
25567
  return !isEmpty$1(value);
25408
25568
  });
25409
- const isDocumentsRequired = (forms$1) => forms$1.some((form) => [forms.companyRegistrationDocument.formId, forms.companyTaxDocument.formId].includes(form.formId));
25410
- const formatOtherDetails = (formData, i18n) => {
25569
+ const isDocumentsRequired$1 = (forms$1) => forms$1.some((form) => [forms.companyRegistrationDocument.formId, forms.companyTaxDocument.formId].includes(form.formId));
25570
+ const formatOtherDetails = (formData, i18n, country2, labels2) => {
25571
+ var _a, _b, _c;
25572
+ const summaryData = {
25573
+ ...formData,
25574
+ [((_a = labels2 == null ? void 0 : labels2.companyOtherDetails) == null ? void 0 : _a.taxInformation) ?? "taxId"]: (_c = (_b = formData.taxInformation) == null ? void 0 : _b.find((taxId2) => country2 === taxId2.country)) == null ? void 0 : _c.number
25575
+ };
25576
+ if (formData.taxInformation) {
25577
+ delete summaryData.taxInformation;
25578
+ }
25411
25579
  if (formData.exemptedFromVat) {
25412
- const summaryData = {
25413
- ...formData,
25414
- "VAT absence reason": i18n.get(formData.vatAbsenceReason)
25415
- };
25416
- delete summaryData.vatAbsenceReason;
25580
+ summaryData.vatAbsenceReason = i18n.get(formData.vatAbsenceReason);
25417
25581
  delete summaryData.vatNumber;
25418
- return summaryData;
25419
25582
  }
25420
- return formData;
25583
+ return summaryData;
25421
25584
  };
25422
- const formatDataForSummary = (data, forms2, i18n) => {
25585
+ const formatDataForSummary = (data, forms2, labels2, i18n) => {
25586
+ var _a;
25423
25587
  const datasetUtils = datasetUtilities(i18n.locale);
25588
+ const country2 = (_a = data.companyBasics) == null ? void 0 : _a.country;
25589
+ const taxIdLabel = resolveFieldMetadata(defaultFieldConfig[country2], {
25590
+ taxIdNumberType: countryToTaxInfoTypeMap[country2]
25591
+ }, defaultFieldMetadata).label;
25424
25592
  return entriesOf(data).reduce((summaryData, [form, formData]) => {
25425
- var _a, _b, _c, _d, _e, _f, _g;
25593
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
25426
25594
  if (!form)
25427
25595
  return summaryData;
25428
25596
  switch (form) {
@@ -25430,10 +25598,10 @@ const formatDataForSummary = (data, forms2, i18n) => {
25430
25598
  return {
25431
25599
  ...summaryData,
25432
25600
  [form]: {
25433
- legalCompanyName: formData.legalCompanyName,
25434
- country: datasetUtils.getCountryName(formData.country),
25601
+ [((_a2 = labels2 == null ? void 0 : labels2.companyBasics) == null ? void 0 : _a2.legalCompanyName) ?? "legalCompanyName"]: formData.legalCompanyName,
25602
+ [((_b = labels2 == null ? void 0 : labels2.companyBasics) == null ? void 0 : _b.country) ?? "country"]: datasetUtils.getCountryName(formData.country),
25435
25603
  [getKeyForField("stateOrProvince", formData.country)]: datasetUtils.getStateName(formData.stateOrProvince, formData.country),
25436
- taxInformationNumber: (_b = (_a = formData.taxInformation) == null ? void 0 : _a.find((taxId2) => formData.country === taxId2.country)) == null ? void 0 : _b.number
25604
+ [taxIdLabel]: (_d = (_c = formData.taxInformation) == null ? void 0 : _c.find((taxId2) => formData.country === taxId2.country)) == null ? void 0 : _d.number
25437
25605
  }
25438
25606
  };
25439
25607
  case "companyRegistrationAddress":
@@ -25449,33 +25617,33 @@ const formatDataForSummary = (data, forms2, i18n) => {
25449
25617
  return {
25450
25618
  ...summaryData,
25451
25619
  [form]: {
25452
- entityType: i18n.get((_c = companyTypes.find((type) => type.id === formData.entityType)) == null ? void 0 : _c.name)
25620
+ entityType: i18n.get((_e = companyTypes.find((type) => type.id === formData.entityType)) == null ? void 0 : _e.name)
25453
25621
  }
25454
25622
  };
25455
25623
  case "companyOtherDetails":
25456
25624
  return {
25457
25625
  ...summaryData,
25458
- [form]: formatOtherDetails(formData, i18n)
25626
+ [form]: formatOtherDetails(formData, i18n, (_f = data.companyBasics) == null ? void 0 : _f.country, labels2)
25459
25627
  };
25460
25628
  case "companyRegistrationDocument":
25461
- if (!isDocumentsRequired(forms2))
25629
+ if (!isDocumentsRequired$1(forms2))
25462
25630
  return summaryData;
25463
25631
  return {
25464
25632
  ...summaryData,
25465
25633
  [form]: {
25466
25634
  companyRegistrationDocument: {
25467
- fileName: (_e = (_d = formData == null ? void 0 : formData.registrationDocument) == null ? void 0 : _d[0]) == null ? void 0 : _e.name
25635
+ fileName: (_h = (_g = formData == null ? void 0 : formData.registrationDocument) == null ? void 0 : _g[0]) == null ? void 0 : _h.name
25468
25636
  }
25469
25637
  }
25470
25638
  };
25471
25639
  case "companyTaxDocument":
25472
- if (!isDocumentsRequired(forms2))
25640
+ if (!isDocumentsRequired$1(forms2))
25473
25641
  return summaryData;
25474
25642
  return {
25475
25643
  ...summaryData,
25476
25644
  [form]: {
25477
25645
  companyTaxDocument: {
25478
- fileName: (_g = (_f = formData == null ? void 0 : formData.taxDocument) == null ? void 0 : _f[0]) == null ? void 0 : _g.name
25646
+ fileName: (_j = (_i = formData == null ? void 0 : formData.taxDocument) == null ? void 0 : _i[0]) == null ? void 0 : _j.name
25479
25647
  }
25480
25648
  }
25481
25649
  };
@@ -25635,7 +25803,7 @@ function useCompanySearchTaskSubmit({
25635
25803
  legalEntity,
25636
25804
  currentForms
25637
25805
  }) => {
25638
- if (!isDocumentsRequired(currentForms))
25806
+ if (!isDocumentsRequired$1(currentForms))
25639
25807
  return;
25640
25808
  const formattedDocument = await mapCompanySearchDocumentToApiDocument(data, legalEntity.id);
25641
25809
  try {
@@ -25746,6 +25914,7 @@ function CompanySearchComponent(props) {
25746
25914
  } = useI18nContext();
25747
25915
  const {
25748
25916
  country: country2,
25917
+ isTopLevelEntity,
25749
25918
  activeForm,
25750
25919
  problems,
25751
25920
  handleAddressSearch,
@@ -25758,6 +25927,7 @@ function CompanySearchComponent(props) {
25758
25927
  } = props;
25759
25928
  const globalData = useGlobalData();
25760
25929
  const [kompanyAddress, setKompanyAddress] = useState();
25930
+ const [kompanyVerifiedData, setKompanyVerifiedData] = useState();
25761
25931
  const formWrapperClasses = (formId) => (activeForm == null ? void 0 : activeForm.formId) !== formId ? "adyen-kyc-form-wrapper adyen-kyc-form-wrapper--hidden" : "adyen-kyc-form-wrapper";
25762
25932
  return jsxs("div", {
25763
25933
  className: "adyen-kyc-company",
@@ -25768,13 +25938,15 @@ function CompanySearchComponent(props) {
25768
25938
  id: forms.companyBasics.formId,
25769
25939
  heading: i18n.get(forms.companyBasics.formName),
25770
25940
  country: country2,
25941
+ isTopLevelEntity,
25771
25942
  handleCompanyIndexSearch,
25772
25943
  handleCompanyDeepSearch,
25773
25944
  handleGetCompanyDataset,
25774
25945
  handleRefreshCompanyDataset,
25775
25946
  handleVerifyTin,
25776
25947
  kompanyAddress,
25777
- setKompanyAddress
25948
+ setKompanyAddress,
25949
+ setKompanyVerifiedData
25778
25950
  })
25779
25951
  }), jsx("div", {
25780
25952
  className: formWrapperClasses(forms.companyRegistrationAddress.formId),
@@ -25797,7 +25969,8 @@ function CompanySearchComponent(props) {
25797
25969
  ...getFormProps(props, forms.companyStructure.formId),
25798
25970
  id: forms.companyStructure.formId,
25799
25971
  heading: i18n.get(forms.companyStructure.formName),
25800
- description: i18n.get(forms.companyStructure.formDescription)
25972
+ description: i18n.get(forms.companyStructure.formDescription),
25973
+ kompanyVerifiedData
25801
25974
  })
25802
25975
  }), jsx("div", {
25803
25976
  className: formWrapperClasses(forms.companyOtherDetails.formId),
@@ -25807,7 +25980,8 @@ function CompanySearchComponent(props) {
25807
25980
  heading: i18n.get(forms.companyOtherDetails.formName),
25808
25981
  country: country2,
25809
25982
  legalCompanyName: (_a = globalData == null ? void 0 : globalData.companyBasics) == null ? void 0 : _a.legalCompanyName,
25810
- companyType: (_b = globalData == null ? void 0 : globalData.companyStructure) == null ? void 0 : _b.entityType
25983
+ companyType: (_b = globalData == null ? void 0 : globalData.companyStructure) == null ? void 0 : _b.entityType,
25984
+ kompanyVerifiedData
25811
25985
  })
25812
25986
  }), jsx("div", {
25813
25987
  className: formWrapperClasses(forms.companyRegistrationDocument.formId),
@@ -25952,13 +26126,13 @@ function CompanySearchDropinComponent({
25952
26126
  }, [documentUtils, eventEmitter, i18n, initialData, legalEntityResponse, setLocale, showToast]);
25953
26127
  const getConfigurationData = useCallback(() => getConfiguration2({
25954
26128
  legalEntityType: LegalEntityType.ORGANIZATION,
25955
- capabilities: capabilities ?? [],
26129
+ capabilities: capabilities ?? Object.keys(legalEntityResponse == null ? void 0 : legalEntityResponse.capabilities),
25956
26130
  country: country2
25957
- }), [getConfiguration2, capabilities, country2]);
26131
+ }), [getConfiguration2, capabilities, country2, legalEntityResponse == null ? void 0 : legalEntityResponse.capabilities]);
25958
26132
  const {
25959
26133
  fieldConfigurations
25960
26134
  } = useScenarioConfiguration({
25961
- parseConfiguration: parseConfiguration$2,
26135
+ parseConfiguration: parseConfiguration$4,
25962
26136
  getConfigurationData,
25963
26137
  setLoadingStatus,
25964
26138
  country: country2
@@ -25994,10 +26168,10 @@ function CompanySearchDropinComponent({
25994
26168
  return addValidityToForms(requiredForms, currentState.validityByForm, problems);
25995
26169
  }, [derivedProps, problems, currentState.validityByForm]);
25996
26170
  const summaryData = useMemo(() => ({
25997
- data: formatDataForSummary(currentState.data, forms$1, i18n),
26171
+ data: formatDataForSummary(currentState.data, forms$1, derivedProps == null ? void 0 : derivedProps.labels, i18n),
25998
26172
  omittedKeys: ["operationalAddressIsSame"]
25999
- }), [currentState.data, forms$1, i18n]);
26000
- const canSubmitForm = useMemo(() => canSubmit(currentState.data) && hasDataChanged(initialData, currentState.data), [initialData, currentState.data]);
26173
+ }), [currentState.data, derivedProps == null ? void 0 : derivedProps.labels, forms$1, i18n]);
26174
+ const canSubmitForm = useMemo(() => canSubmit$1(currentState.data) && hasDataChanged(initialData, currentState.data), [initialData, currentState.data]);
26001
26175
  const baseTrackingPayload = useMemo(() => getBaseTrackingPayload({
26002
26176
  trackingConfig,
26003
26177
  parentLegalEntity,
@@ -26069,6 +26243,7 @@ function CompanySearchDropinComponent({
26069
26243
  problems,
26070
26244
  activeForm,
26071
26245
  shouldValidate,
26246
+ isTopLevelEntity: taskType === TaskTypes.COMPANY_SEARCH,
26072
26247
  handleAddressSearch,
26073
26248
  handleFindAddress,
26074
26249
  handleCompanyIndexSearch,
@@ -28356,7 +28531,7 @@ const omitMaskedFieldsIfUnchanged = (maskedFields, dataSubmitted, savedData) =>
28356
28531
  });
28357
28532
  return filtered;
28358
28533
  };
28359
- const parseConfiguration$1 = ({
28534
+ const parseConfiguration$3 = ({
28360
28535
  country: country2,
28361
28536
  matchingScenario
28362
28537
  }) => parseIndividualScenarios(matchingScenario == null ? void 0 : matchingScenario[LegalEntityType.INDIVIDUAL], country2);
@@ -28440,7 +28615,7 @@ function IndividualDropinComponent({
28440
28615
  const {
28441
28616
  fieldConfigurations
28442
28617
  } = useScenarioConfiguration({
28443
- parseConfiguration: parseConfiguration$1,
28618
+ parseConfiguration: parseConfiguration$3,
28444
28619
  getConfigurationData,
28445
28620
  setLoadingStatus,
28446
28621
  country: country2
@@ -28912,14 +29087,14 @@ const rules$1 = ({
28912
29087
  }
28913
29088
  });
28914
29089
  const getRegistrationCountry = (legalEntityResponse) => legalEntityResponse.type === LegalEntityType.INDIVIDUAL ? legalEntityResponse.individual.residentialAddress.country : legalEntityResponse.organization.registeredAddress.country;
28915
- const labels$1 = () => ({
29090
+ const labels = () => ({
28916
29091
  verifiedAccountHolder: () => "accountHolder",
28917
29092
  verifiedBankCountry: () => "bankCountry",
28918
29093
  verifiedBankName: () => "bankName",
28919
29094
  verifiedCurrencyCode: () => "currencyCode",
28920
29095
  verifiedBankAccountNumber: () => "bankAccountNumber"
28921
29096
  });
28922
- const parseConfiguration = ({
29097
+ const parseConfiguration$2 = ({
28923
29098
  requiredFields,
28924
29099
  country: country2,
28925
29100
  bankVerificationAvailable
@@ -29062,7 +29237,7 @@ function PayoutDetailsDropinComponent({
29062
29237
  requiredFields,
29063
29238
  bankVerificationVendors
29064
29239
  } = useScenarioConfiguration({
29065
- parseConfiguration,
29240
+ parseConfiguration: parseConfiguration$2,
29066
29241
  getConfigurationData,
29067
29242
  getPayoutAccountFormatData,
29068
29243
  instantVerificationEnabled,
@@ -29076,7 +29251,7 @@ function PayoutDetailsDropinComponent({
29076
29251
  taskType,
29077
29252
  requiredFields
29078
29253
  }), [bankAccountCountry2, data, taskType]);
29079
- const fieldsFormCustomLabels = useMemo(() => labels$1 ? labels$1() : {}, [data, bankAccountCountry2]);
29254
+ const fieldsFormCustomLabels = useMemo(() => labels ? labels() : {}, [data, bankAccountCountry2]);
29080
29255
  const payoutDetailsSteps = useMemo(() => {
29081
29256
  var _a2;
29082
29257
  return getAppropriatePayoutDetailsSteps(taskType, Boolean((_a2 = prefilledData == null ? void 0 : prefilledData.payoutAccountDetails) == null ? void 0 : _a2.transferInstrumentId), !transferInstrument && isInstantVerificationAvailable({
@@ -30516,668 +30691,61 @@ function ServiceAgreementDropinComponent({
30516
30691
  })
30517
30692
  });
30518
30693
  }
30519
- function removeObjectPropsWithEmptyValues(obj) {
30520
- keysOf(obj).forEach((key) => {
30521
- if (obj[key] === null || isEmpty(obj[key]))
30522
- delete obj[key];
30523
- });
30524
- return obj;
30525
- }
30526
- const INITIAL_STATE = {
30527
- data: {},
30528
- allData: {},
30529
- initialData: {},
30530
- errors: {},
30531
- valid: {},
30532
- fieldProblems: {},
30533
- isValid: false
30534
- };
30535
- function StateReducer() {
30536
- const [schemas, setSchemas] = useState({});
30537
- const [activeForms, setActiveForms] = useState([]);
30538
- const setCurrentForms = (forms2) => {
30539
- setActiveForms(forms2);
30540
- };
30541
- function reducer2({
30542
- currentState: currState
30543
- }, action) {
30544
- var _a, _b, _c, _d, _e;
30545
- switch (action.type) {
30546
- case "addToState": {
30547
- const state2 = structuredClone(currState);
30548
- const dataStoreId = action.value.dataStoreId ?? action.value.caller;
30549
- const schema = action.value.schema || null;
30550
- const schemaHasChanged = schema && ((_a = schemas == null ? void 0 : schemas[dataStoreId]) == null ? void 0 : _a.toString()) !== schema.toString();
30551
- const mergedState = {
30552
- ...state2,
30553
- data: {
30554
- ...state2.data,
30555
- [dataStoreId]: {
30556
- ...state2.data[dataStoreId],
30557
- ...action.value.data
30558
- }
30559
- },
30560
- // Add data in allData state prop in case we will need them later
30561
- allData: {
30562
- ...state2.allData,
30563
- [dataStoreId]: {
30564
- ...state2.allData[dataStoreId],
30565
- ...removeObjectPropsWithEmptyValues(action.value.data)
30566
- }
30567
- },
30568
- errors: {
30569
- ...state2.errors,
30570
- [dataStoreId]: {
30571
- ...state2.errors[dataStoreId],
30572
- ...action.value.errors
30573
- }
30574
- },
30575
- valid: {
30576
- ...state2.valid,
30577
- [dataStoreId]: {
30578
- ...state2.valid[dataStoreId],
30579
- ...action.value.valid
30580
- }
30581
- },
30582
- fieldProblems: {
30583
- ...state2.fieldProblems,
30584
- [dataStoreId]: {
30585
- ...state2.fieldProblems[dataStoreId],
30586
- ...action.value.fieldProblems
30587
- }
30588
- }
30589
- };
30590
- if (schemaHasChanged) {
30591
- setSchemas({
30592
- ...schemas,
30593
- [dataStoreId]: schema
30594
- });
30595
- const processedBySchema = schema.reduce((acc, fieldKey) => {
30596
- const dataObjByFormId = mergedState.data[dataStoreId];
30597
- const allDataObjByFormId = mergedState.allData[dataStoreId];
30598
- const validObjByFormId = mergedState.valid[dataStoreId];
30599
- const errorsObjByFormId = mergedState.errors[dataStoreId];
30600
- const fieldProblemsObjByFormId = mergedState.fieldProblems[dataStoreId];
30601
- return {
30602
- data: {
30603
- ...acc.data,
30604
- [fieldKey]: dataObjByFormId[fieldKey] ?? allDataObjByFormId[fieldKey]
30605
- },
30606
- valid: {
30607
- ...acc.valid,
30608
- [fieldKey]: validObjByFormId[fieldKey]
30609
- },
30610
- errors: {
30611
- ...acc.errors,
30612
- [fieldKey]: errorsObjByFormId[fieldKey]
30613
- },
30614
- fieldProblems: {
30615
- ...acc.fieldProblems,
30616
- [fieldKey]: fieldProblemsObjByFormId[fieldKey]
30617
- }
30618
- };
30619
- }, {
30620
- data: {},
30621
- valid: {},
30622
- errors: {},
30623
- fieldProblems: {}
30624
- });
30625
- mergedState.data[dataStoreId] = processedBySchema.data;
30626
- mergedState.valid[dataStoreId] = processedBySchema.valid;
30627
- mergedState.errors[dataStoreId] = processedBySchema.errors;
30628
- mergedState.fieldProblems[dataStoreId] = processedBySchema.fieldProblems;
30629
- }
30630
- mergedState.validityByForm = {
30631
- ...mergedState.validityByForm,
30632
- [dataStoreId]: Object.values(mergedState.valid[dataStoreId]).every((isValid) => isValid)
30633
- };
30634
- mergedState.hasDataChanged = {
30635
- ...state2.hasDataChanged,
30636
- [dataStoreId]: {
30637
- hasDataChanged: hasDataChanged((_b = state2.initialData) == null ? void 0 : _b[dataStoreId], (_c = mergedState.data) == null ? void 0 : _c[dataStoreId])
30638
- }
30639
- };
30640
- mergedState.hasAnyDataChanged = Object.values(mergedState.hasDataChanged).some(({
30641
- hasDataChanged: hasDataChanged2
30642
- }) => hasDataChanged2);
30643
- mergedState.allValid = Object.values(mergedState.validityByForm).every((isValid) => isValid);
30644
- mergedState.isValid = !activeForms.length ? mergedState.allValid : activeForms.every((item) => mergedState.validityByForm[item]);
30645
- mergedState.initialData = structuredClone(state2.initialData);
30646
- return {
30647
- currentState: mergedState,
30648
- prevState: state2,
30649
- changeInitiatedBy: dataStoreId
30650
- };
30651
- }
30652
- case "resetState": {
30653
- const dataStoreId = ((_d = action.value) == null ? void 0 : _d.dataStoreId) ?? ((_e = action.value) == null ? void 0 : _e.caller);
30654
- return {
30655
- currentState: INITIAL_STATE,
30656
- prevState: currState,
30657
- changeInitiatedBy: dataStoreId
30658
- };
30659
- }
30660
- default: {
30661
- throw new Error(`Unhandled action type: ${action.type}`);
30694
+ const parseConfiguration$1 = ({
30695
+ matchingScenario,
30696
+ country: country2
30697
+ }) => parseSolePropScenarios(matchingScenario[LegalEntityType.SOLE_PROPRIETORSHIP], country2);
30698
+ const isDocumentsRequired = (forms2) => forms2.some((form) => [solePropForms.solePropConstitutionalDocument.formId].includes(form.formId));
30699
+ const formatFileSummaryData = (solePropConstitutionalDocument) => {
30700
+ var _a;
30701
+ const constitutionalDocument2 = (_a = solePropConstitutionalDocument == null ? void 0 : solePropConstitutionalDocument.constitutionalDocument) == null ? void 0 : _a[0];
30702
+ return {
30703
+ ...constitutionalDocument2 && {
30704
+ solePropConstitutionalDocument: {
30705
+ fileName: constitutionalDocument2.name
30662
30706
  }
30663
30707
  }
30664
- }
30665
- return {
30666
- reducer: reducer2,
30667
- setCurrentForms
30668
30708
  };
30669
- }
30670
- function StateProvider({
30671
- defaultData = {},
30672
- children
30673
- }) {
30674
- const defaultState = {
30675
- currentState: {
30676
- data: defaultData,
30677
- allData: defaultData,
30678
- valid: {},
30679
- errors: {},
30680
- fieldProblems: {},
30681
- validityByForm: {},
30682
- initialData: defaultData
30683
- },
30684
- prevState: {},
30685
- changeInitiatedBy: null
30686
- };
30687
- const reducerObj = StateReducer();
30688
- const [state2, dispatch] = useReducer(reducerObj.reducer, defaultState);
30689
- const contextValue = useMemo(() => ({
30690
- state: state2,
30691
- dispatch,
30692
- setActiveForms: reducerObj.setCurrentForms,
30693
- getData: () => {
30694
- var _a;
30695
- return ((_a = state2 == null ? void 0 : state2.currentState) == null ? void 0 : _a.data) ?? {};
30696
- },
30697
- getState: () => state2 == null ? void 0 : state2.currentState
30698
- }), [reducerObj, state2]);
30699
- return jsx(StateContext.Provider, {
30700
- value: contextValue,
30701
- children
30702
- });
30703
- }
30704
- const labels = (data, country2) => ({
30705
- registrationNumber: () => {
30706
- var _a;
30707
- if (country2 === CountryCodes.Monaco && ((_a = data == null ? void 0 : data.solePropNameAndCountry) == null ? void 0 : _a.country) === CountryCodes.Monaco) {
30708
- return "mcRegistrationNumberSoleProp";
30709
- }
30710
- }
30711
- });
30712
- const fontFormats = ["eot", "woff", "woff2", "ttf", "otf"];
30713
- const formatFullNames = {
30714
- eot: "embedded-opentype",
30715
- woff: "woff",
30716
- woff2: "woff2",
30717
- ttf: "truetype",
30718
- otf: "opentype"
30719
- };
30720
- const getFontFaceRule = (fontFamily, fontStyle, fontWeight, fontPath, formats) => {
30721
- const fontSources = formats.map((format) => `url(${fontPath}.${format}) format(${formatFullNames[format]})`);
30722
- const ruleLines = [`font-family: '${fontFamily}'`, `font-style: ${fontStyle}`, `font-weight: ${fontWeight}`, `src: ${fontSources.join(",")}`];
30723
- return `@font-face {${ruleLines.join(";")}}`;
30724
- };
30725
- const addStyleTagForFont = (fontFamily, fontStyle, fontWeight, fontPath, formats) => {
30726
- const style = document.createElement("style");
30727
- style.setAttribute("type", "text/css");
30728
- style.innerText = getFontFaceRule(fontFamily, fontStyle, fontWeight, fontPath, formats);
30729
- document.head.insertBefore(style, document.head.firstChild);
30730
30709
  };
30731
- const addStyleTagForADLIconFont = (loadingContext) => {
30732
- const fontPath = `${loadingContext}static/fonts`;
30733
- const iconFontPath = `${fontPath}/adyen-kyc-icons`;
30734
- addStyleTagForFont("adyen-kyc-icons", "normal", "normal", iconFontPath, fontFormats);
30735
- };
30736
- let isFlagsLoaded = false;
30737
- let isDocumentGuidanceLoaded = false;
30738
- const getIconContainer = () => {
30739
- const container = document.createElement("div");
30740
- container.setAttribute("aria-hidden", "true");
30741
- container.setAttribute("id", "adl-icon-container");
30742
- container.style.height = "0";
30743
- return container;
30744
- };
30745
- const buildSpriteDOMFromResponse = (responseData) => {
30746
- const iconContainer = getIconContainer();
30747
- iconContainer.innerHTML = responseData;
30748
- return iconContainer;
30749
- };
30750
- const loadFlags = async (loadingContext) => {
30751
- if (isFlagsLoaded)
30752
- return;
30753
- isFlagsLoaded = true;
30754
- const responseData = await http({
30755
- loadingContext,
30756
- path: "static/images/country-flags.svg"
30757
- }, null, "text");
30758
- document.body.insertBefore(buildSpriteDOMFromResponse(responseData), document.body.firstChild);
30759
- };
30760
- const loadDocumentGuidance = async (loadingContext) => {
30761
- if (isDocumentGuidanceLoaded)
30762
- return;
30763
- isDocumentGuidanceLoaded = true;
30764
- const responseData = await http({
30765
- loadingContext,
30766
- path: "static/images/document-guidance.svg"
30767
- }, null, "text");
30768
- document.body.insertBefore(buildSpriteDOMFromResponse(responseData), document.body.firstChild);
30769
- };
30770
- const getOpeningStep = (forms2, remediationActions) => {
30710
+ const canSubmit = (data) => mandatoryApiFields.SOLE_PROPRIETORSHIP.every((detail) => {
30711
+ const value = getProp(data, detail);
30712
+ return !isEmpty(value);
30713
+ });
30714
+ const hasRegisteredAddress = (dataFromResponse) => {
30771
30715
  var _a;
30772
- if (remediationActions && Object.keys(remediationActions).length > 0) {
30773
- const allRemediationActions = Object.values(remediationActions).flat().filter((rem) => {
30774
- var _a2;
30775
- return ((_a2 = rem.forms) == null ? void 0 : _a2.length) > 0;
30776
- });
30777
- if (allRemediationActions.length === 1 && ((_a = allRemediationActions[0]) == null ? void 0 : _a.forms.length) === 1) {
30778
- const form = forms2.find((form2) => {
30779
- var _a2;
30780
- return (form2 == null ? void 0 : form2.formId) === ((_a2 = allRemediationActions[0]) == null ? void 0 : _a2.forms[0]);
30781
- });
30782
- if (form)
30783
- return form;
30784
- }
30785
- return forms2[forms2.length - 1];
30786
- }
30787
- return forms2[0];
30716
+ const registeredAddress2 = ((_a = dataFromResponse == null ? void 0 : dataFromResponse.solePropRegistrationAddress) == null ? void 0 : _a.registrationAddress) || {};
30717
+ return Object.entries(registeredAddress2).some(([key, value]) => key !== "country" && Boolean(value));
30788
30718
  };
30789
- function withFormComposer(WrappedComponent, {
30790
- getComponentForms,
30791
- parseConfiguration: parseConfiguration2,
30792
- rules: rules2,
30793
- labels: labels2,
30794
- defaultTaskName,
30795
- getConfigFor = "contextCountry"
30796
- }) {
30797
- const WithFormComposer = (props) => {
30798
- var _a, _b, _c, _d;
30799
- const {
30800
- i18n
30801
- } = useI18nContext();
30802
- const {
30803
- contextCountry: initialContextCountry,
30804
- setContextCountry: setInitialContextCountry
30805
- } = useCoreContext();
30806
- const {
30807
- loadingContext
30808
- } = useAuthContext();
30809
- const {
30810
- getConfiguration: getConfiguration2,
30811
- getPayoutAccountFormat: getPayoutAccountFormat2
30812
- } = useConfigurationApi();
30813
- const {
30814
- isSettingEnabled
30815
- } = useSettingsContext();
30816
- const {
30817
- getData,
30818
- getState
30819
- } = useStateContext();
30820
- const {
30821
- getOmittedKeys: getSummaryOmittedKeys = null,
30822
- formatData: formatDataForSummary2 = null,
30823
- omittedForms
30824
- } = props.summary || {};
30825
- const taskName = props.taskName ?? defaultTaskName;
30826
- const [hideDropinLayout, setHideDropinLayout] = useState(false);
30827
- const [hideNavigation, setHideNavigation] = useState(false);
30828
- const [hideFooter, setHideFooter] = useState(false);
30829
- const [hideOnHomeButton, setHideOnHomeButton] = useState(false);
30830
- const [hideBackButton, setHideBackButton] = useState(false);
30831
- const [submitButtonLabel, setSubmitButtonLabel] = useState(null);
30832
- const [skipSubmitAndGoTaskList, setSkipSubmitAndGoTaskList] = useState(false);
30833
- const [customFormNavigationHandlers, setCustomFormNavigationHandlers] = useState({});
30834
- const [shouldValidate, setShouldValidate] = useState(false);
30835
- const [formValidity, setFormValidity] = useState({});
30836
- const formRef = useRef(null);
30837
- const [loadingStatus, setLoadingStatus] = useState("success");
30838
- const [derivedProps, setDerivedProps] = useState(props);
30839
- const [contextCountry, setContextCountry] = useState(props.country || initialContextCountry);
30840
- const {
30841
- sliceData: payoutMethodData
30842
- } = useGlobalDataSlice("payoutVerificationMethod");
30843
- const configCountry = (getConfigFor === "bankCountry" ? payoutMethodData == null ? void 0 : payoutMethodData.bankCountry : contextCountry) ?? contextCountry;
30844
- useEffect(() => {
30845
- loadDocumentGuidance(loadingContext);
30846
- }, [loadingContext]);
30847
- const getConfigurationData = useCallback(() => getConfiguration2({
30848
- legalEntityType: props.legalEntityType,
30849
- capabilities: props.capabilities,
30850
- // for payout forms, we need to get config for the selected bankCountry, not necessarily the same as the residency/registration country
30851
- country: configCountry
30852
- }), [configCountry, props.capabilities, props.legalEntityType]);
30853
- const getPayoutAccountFormatData = useCallback(() => getPayoutAccountFormat2(configCountry), [configCountry]);
30854
- const {
30855
- fieldConfigurations,
30856
- requiredFields,
30857
- bankVerificationVendors
30858
- } = useScenarioConfiguration({
30859
- getConfigurationData,
30860
- getPayoutAccountFormatData,
30861
- parseConfiguration: parseConfiguration2,
30862
- country: configCountry,
30863
- instantVerificationEnabled: derivedProps.instantVerificationEnabled && derivedProps.handleGetBankVerificationVendors,
30864
- setLoadingStatus
30865
- });
30866
- const isFormStepVisible = (formId) => {
30867
- if (derivedProps.requiredFields || derivedProps.optionalFields) {
30868
- return !!derivedProps.requiredFields[formId] || !!derivedProps.optionalFields[formId];
30869
- }
30870
- return true;
30871
- };
30872
- const isFormSummaryStep = (form) => form.formId === summaryStep.formId;
30873
- const componentForms = useMemo(() => getComponentForms({
30874
- ...props,
30875
- bankVerificationVendors
30876
- }, isSettingEnabled), [bankVerificationVendors, isSettingEnabled, props]);
30877
- const componentFormsWithSummary = [...Object.values(componentForms), summaryStep];
30878
- const allowedForms = componentFormsWithSummary.filter((form) => isFormStepVisible(form.formId) || isFormSummaryStep(form));
30879
- const [activeForm, setActiveForm] = useState(getOpeningStep(allowedForms, (_a = props == null ? void 0 : props.problems) == null ? void 0 : _a.remediationActions));
30880
- const [hasAlreadyNavigatedForm, setHasAlreadyNavigatedForm] = useState(false);
30881
- const getFormIndex = (formId) => allowedForms.findIndex((form) => form.formId === formId);
30882
- const isFinalStep = getFormIndex(activeForm.formId) === allowedForms.length - 1;
30883
- const isFirstStep = getFormIndex(activeForm.formId) === 0;
30884
- useEffect(() => {
30885
- var _a2;
30886
- if (hasAlreadyNavigatedForm)
30887
- return;
30888
- const openingStep = getOpeningStep(allowedForms, (_a2 = props == null ? void 0 : props.problems) == null ? void 0 : _a2.remediationActions);
30889
- if (activeForm !== openingStep) {
30890
- setActiveForm(openingStep);
30891
- }
30892
- }, [activeForm, allowedForms, (_b = props == null ? void 0 : props.problems) == null ? void 0 : _b.remediationActions, hasAlreadyNavigatedForm]);
30893
- const evaluateConfiguration = useCallback((scenarioConfiguration, country2, formData, isSettingEnabled2, requiredFields2) => {
30894
- var _a2, _b2, _c2;
30895
- const fieldsFromCustomRules = rules2 ? rules2({
30896
- data: formData,
30897
- country: country2,
30898
- taskType: props.taskType,
30899
- isSettingEnabled: isSettingEnabled2,
30900
- requiredFields: requiredFields2
30901
- }) : {};
30902
- const fieldsFormCustomLabels = labels2 ? labels2(formData, country2) : {};
30903
- const scenarioProps = getPropsFromConfigurations(scenarioConfiguration, componentForms, ((_a2 = props == null ? void 0 : props.problems) == null ? void 0 : _a2.remediationActions) ? Object.values((_b2 = props == null ? void 0 : props.problems) == null ? void 0 : _b2.remediationActions) : [], ((_c2 = props.problems) == null ? void 0 : _c2.missingData) ?? [], props.legalEntityResponse ? getFieldsWithExistingData(props.legalEntityResponse) : [], fieldsFromCustomRules, fieldsFormCustomLabels);
30904
- setShouldValidate(false);
30905
- setDerivedProps({
30906
- ...props,
30907
- ...scenarioProps,
30908
- country: configCountry
30909
- });
30910
- }, [componentForms, configCountry, props]);
30911
- useEffect(() => {
30912
- if (!fieldConfigurations)
30913
- return;
30914
- evaluateConfiguration(fieldConfigurations, configCountry, getData(), isSettingEnabled, requiredFields);
30915
- }, [fieldConfigurations, configCountry, evaluateConfiguration, getData, isSettingEnabled, requiredFields]);
30916
- const trackNavigation2 = ({
30917
- fromForm,
30918
- toForm,
30919
- component
30920
- }) => {
30921
- userEvents.addEvent("Navigated form", {
30922
- segmentation: {
30923
- ...props == null ? void 0 : props.baseTrackingPayload,
30924
- component,
30925
- from: fromForm.formId,
30926
- fromLabel: i18n.get(fromForm.formName),
30927
- to: toForm.formId,
30928
- toLabel: i18n.get(toForm.formName)
30929
- }
30930
- });
30931
- };
30932
- const trackSectionCompletion = (form) => {
30933
- userEvents.addEvent("Completed form section", {
30934
- segmentation: {
30935
- ...props == null ? void 0 : props.baseTrackingPayload,
30936
- sectionName: form.formId
30937
- }
30938
- });
30939
- };
30940
- const gotoFormByFormIndex = (nextFormIndex) => {
30941
- if (formRef.current.verifyForm) {
30942
- formRef.current.verifyForm(activeForm.formId).then((isVerified) => {
30943
- if (isVerified) {
30944
- setHasAlreadyNavigatedForm(true);
30945
- setActiveForm(allowedForms[nextFormIndex]);
30946
- }
30947
- });
30948
- } else {
30949
- setHasAlreadyNavigatedForm(true);
30950
- setActiveForm(allowedForms[nextFormIndex]);
30951
- }
30952
- };
30953
- const validateCurrentForm = () => {
30954
- setShouldValidate(true);
30955
- };
30956
- const handleNextClick = () => {
30957
- var _a2, _b2;
30958
- if (formRef.current.customNavigationHandler) {
30959
- formRef.current.customNavigationHandler();
30960
- return;
30961
- }
30962
- if ((_a2 = customFormNavigationHandlers[activeForm.formId]) == null ? void 0 : _a2.onNext) {
30963
- (_b2 = customFormNavigationHandlers[activeForm.formId]) == null ? void 0 : _b2.onNext();
30964
- return;
30965
- }
30966
- const allFields = (derivedProps == null ? void 0 : derivedProps.allFields) || {};
30967
- if (isFormSummaryStep(activeForm)) {
30968
- if (skipSubmitAndGoTaskList) {
30969
- props.navigateBackToTaskList();
30970
- } else {
30971
- props.onSubmit({
30972
- data: getData(),
30973
- forms: allowedForms,
30974
- allFields,
30975
- setLoadingStatus
30976
- });
30977
- }
30978
- return;
30979
- }
30980
- if (formValidity[activeForm.formId]) {
30981
- if (isFinalStep) {
30982
- props.onSubmit({
30983
- data: getData(),
30984
- forms: allowedForms,
30985
- allFields,
30986
- setLoadingStatus
30987
- });
30988
- return;
30989
- }
30990
- setShouldValidate(false);
30991
- const toFormIndex = allowedForms.findIndex((form) => form.formId === activeForm.formId) + 1;
30992
- gotoFormByFormIndex(toFormIndex);
30993
- const toForm = allowedForms[toFormIndex];
30994
- trackNavigation2({
30995
- fromForm: activeForm,
30996
- toForm,
30997
- component: "ActionBar"
30998
- });
30999
- trackSectionCompletion(activeForm);
31000
- } else {
31001
- validateCurrentForm();
31002
- }
31003
- };
31004
- const handleBackClick = () => {
31005
- const currentFormIndex = allowedForms.findIndex((form) => form.formId === activeForm.formId);
31006
- if (currentFormIndex) {
31007
- const fromForm = allowedForms[currentFormIndex];
31008
- const toForm = allowedForms[currentFormIndex - 1];
31009
- setActiveForm(toForm);
31010
- setHasAlreadyNavigatedForm(true);
31011
- trackNavigation2({
31012
- fromForm,
31013
- toForm,
31014
- component: "ActionBar"
31015
- });
31016
- }
31017
- };
31018
- const setCustomHandlers = (formId, onNext, onBack) => {
31019
- setCustomFormNavigationHandlers({
31020
- ...customFormNavigationHandlers,
31021
- [formId]: {
31022
- onNext,
31023
- onBack
30719
+ const getDataWithDefaultAddress = (legalEntityResponse, parentLegalEntity) => {
30720
+ var _a;
30721
+ let solePropData = mapLegalEntityToSoleProp(legalEntityResponse);
30722
+ if (!hasRegisteredAddress(solePropData)) {
30723
+ const defaultAddress = (_a = mapLegalEntityToIndividual(parentLegalEntity, false)) == null ? void 0 : _a.address;
30724
+ solePropData = {
30725
+ ...solePropData,
30726
+ solePropRegistrationAddress: {
30727
+ ...solePropData == null ? void 0 : solePropData.solePropRegistrationAddress,
30728
+ registrationAddress: {
30729
+ ...defaultAddress
31024
30730
  }
31025
- });
31026
- };
31027
- const nextButtonText = isFinalStep ? i18n.get(submitButtonLabel ?? "submit") : i18n.get("next");
31028
- useEffect(() => {
31029
- props.eventEmitter.on("next", handleNextClick);
31030
- props.eventEmitter.on("back", handleBackClick);
31031
- props.eventEmitter.on("validate", validateCurrentForm);
31032
- return () => {
31033
- props.eventEmitter.off("next", handleNextClick);
31034
- props.eventEmitter.off("back", handleNextClick);
31035
- props.eventEmitter.off("validate", validateCurrentForm);
31036
- };
31037
- }, [activeForm, allowedForms]);
31038
- const onCountryChange = (country2) => {
31039
- setContextCountry(country2);
31040
- };
31041
- const onWrappedComponentChange = (state2) => {
31042
- var _a2;
31043
- setFormValidity(state2.validityByForm);
31044
- (_a2 = props.onChange) == null ? void 0 : _a2.call(props, state2);
31045
- };
31046
- const handleStateChange = ({
31047
- currentState
31048
- }) => {
31049
- onWrappedComponentChange(currentState);
31050
- };
31051
- const handleLeaveDropin = async () => {
31052
- var _a2;
31053
- const data = getData();
31054
- const hasDataChanged2 = getState().hasAnyDataChanged;
31055
- if (hasDataChanged2 && ((_a2 = props.canSubmit) == null ? void 0 : _a2.call(props, data))) {
31056
- setInitialContextCountry(contextCountry);
31057
- const allFields = (derivedProps == null ? void 0 : derivedProps.allFields) || {};
31058
- await props.onSubmit({
31059
- data,
31060
- forms: allowedForms,
31061
- allFields,
31062
- setLoadingStatus
31063
- });
31064
- } else {
31065
- props.handleHomeClick();
31066
30731
  }
31067
30732
  };
31068
- const formFooter = !hideDropinLayout && !hideFooter && jsx(ActionBar, {
31069
- onNext: handleNextClick,
31070
- onBack: isFirstStep ? props.handleBackClick : handleBackClick,
31071
- backButtonLabel: i18n.get("back"),
31072
- nextButtonLabel: nextButtonText,
31073
- onHome: handleLeaveDropin,
31074
- homeButtonLabel: props.homeButtonLabel,
31075
- hideOnHomeButton,
31076
- hideBackButton
31077
- });
31078
- const wrappedComponent = jsx("div", {
31079
- className: "adyen-kyc-form-container",
31080
- children: jsx(LoaderWrapper, {
31081
- status: loadingStatus,
31082
- formOpacityWhenLoading: 0.3,
31083
- loaderSize: "large",
31084
- children: jsxs(FormRouterContextProvider, {
31085
- setFormIndex: gotoFormByFormIndex,
31086
- forms: allowedForms,
31087
- handleGetIdVerificationToken: props.handleGetIdVerificationToken,
31088
- children: [jsx(StateContextWatcher, {
31089
- owner: "FormComposer",
31090
- onChange: handleStateChange
31091
- }), jsx(WrappedComponent, {
31092
- ref: formRef,
31093
- forms: allowedForms,
31094
- activeForm,
31095
- ...derivedProps,
31096
- data: props.data,
31097
- onChange: onWrappedComponentChange,
31098
- evaluateConfiguration: (data) => evaluateConfiguration(fieldConfigurations, configCountry, data, isSettingEnabled, requiredFields),
31099
- country: contextCountry,
31100
- onCountryChange,
31101
- legalEntityId: (_c = props.legalEntityResponse) == null ? void 0 : _c.id,
31102
- problems: props == null ? void 0 : props.problems,
31103
- shouldValidate,
31104
- onNext: handleNextClick,
31105
- onBack: handleBackClick,
31106
- setHideDropinLayout,
31107
- setHideNavigation,
31108
- setHideFooter,
31109
- setCustomFormNavigationHandlers: setCustomHandlers,
31110
- setHideOnHomeButton,
31111
- setHideBackButton,
31112
- setSubmitButtonLabel,
31113
- setSkipSubmitAndGoTaskList,
31114
- bankVerificationVendors
31115
- }), activeForm.formId === summaryStep.formId && jsx("div", {
31116
- className: "adyen-kyc-form-wrapper",
31117
- children: jsx(Summary, {
31118
- trackNavigation: trackNavigation2,
31119
- data: formatDataForSummary2 ? formatDataForSummary2(getData(), allowedForms) : getData(),
31120
- omittedKeys: getSummaryOmittedKeys ? getSummaryOmittedKeys(getData()) : null,
31121
- omittedForms,
31122
- forms: allowedForms,
31123
- gotoForm: gotoFormByFormIndex,
31124
- labels: derivedProps.labels,
31125
- problems: props == null ? void 0 : props.problems
31126
- })
31127
- }), formFooter]
31128
- })
31129
- })
31130
- });
31131
- const allowedFormsWithValidity = addValidityToForms(allowedForms, formValidity, props.problems);
31132
- const sidebar = !hideDropinLayout && !hideNavigation && jsx(LoaderWrapper, {
31133
- status: loadingStatus,
31134
- formOpacityWhenLoading: 0.3,
31135
- showSpinner: false,
31136
- className: "adyen-kyc-dropin__sidebar-wrapper",
31137
- children: jsx(FormNavigation, {
31138
- forms: allowedFormsWithValidity,
31139
- activeForm: allowedFormsWithValidity.find((form) => form.formId === activeForm.formId),
31140
- gotoForm: gotoFormByFormIndex,
31141
- validateForm: validateCurrentForm,
31142
- taskName,
31143
- trackNavigation: trackNavigation2,
31144
- verificationErrors: (_d = props == null ? void 0 : props.problems) == null ? void 0 : _d.verificationErrors
31145
- })
31146
- });
31147
- const content = jsxs(Fragment, {
31148
- children: [sidebar, wrappedComponent]
31149
- });
31150
- if (!props.hideDropinLayout) {
31151
- return jsx(DropinLayout, {
31152
- content
31153
- });
31154
- }
31155
- return wrappedComponent;
31156
- };
31157
- return WithFormComposer;
31158
- }
31159
- const SolePropWithFormComposer = withFormComposer(SolePropComponent, {
31160
- getComponentForms: () => solePropForms,
31161
- // TODO: change trust to soleprop once the configurations for soleprops are added in backend.
31162
- parseConfiguration: ({
31163
- matchingScenario,
31164
- country: country2
31165
- }) => parseSolePropScenarios([matchingScenario[LegalEntityType.TRUST]], country2),
31166
- rules: rules$2,
31167
- labels,
31168
- defaultTaskName: "solePropDetails"
31169
- });
30733
+ }
30734
+ return solePropData;
30735
+ };
31170
30736
  function SolePropDropinComponent({
31171
30737
  problems: problemsProp,
31172
30738
  capabilities,
31173
- country: country2,
30739
+ country: externalCountry,
31174
30740
  parentLegalEntity,
31175
30741
  legalEntityResponse,
31176
30742
  eventEmitter,
31177
30743
  homeButtonLabel,
31178
30744
  hideDropinLayout,
31179
- onSubmit,
30745
+ onSubmit: onExternalSubmit,
31180
30746
  onChange,
30747
+ taskType,
30748
+ trackingConfig,
31181
30749
  handleHomeClick,
31182
30750
  handleCreateDocument,
31183
30751
  handleGetDocument,
@@ -31187,7 +30755,7 @@ function SolePropDropinComponent({
31187
30755
  handleUpdateLegalEntity,
31188
30756
  handleCreateLegalEntity
31189
30757
  }) {
31190
- var _a;
30758
+ var _a, _b;
31191
30759
  const {
31192
30760
  i18n,
31193
30761
  setLocale
@@ -31197,43 +30765,72 @@ function SolePropDropinComponent({
31197
30765
  } = useExperimentsContext();
31198
30766
  const [problems, setProblems] = useState(problemsProp);
31199
30767
  const datasetUtils = datasetUtilities(i18n.locale);
31200
- const getOmittedKeys = () => ["operationalAddressIsSame"];
31201
30768
  const [newSoleProp, setNewSoleProp] = useState(null);
31202
30769
  const {
31203
- showToast,
31204
- clearToasts
30770
+ showToast
31205
30771
  } = useToastContext();
31206
- const hasRegisteredAddress = (dataFromResponse) => {
31207
- var _a2;
31208
- const registeredAddress2 = ((_a2 = dataFromResponse == null ? void 0 : dataFromResponse.solePropRegistrationAddress) == null ? void 0 : _a2.registrationAddress) || {};
31209
- return Object.entries(registeredAddress2).some(([key, value]) => key !== "country" && Boolean(value));
31210
- };
31211
- const getDataWithDefaultAddress = (legalEntityResponse2, parentLegalEntity2) => {
31212
- var _a2;
31213
- let solePropData = mapLegalEntityToSoleProp(legalEntityResponse2);
31214
- if (!hasRegisteredAddress(solePropData)) {
31215
- const defaultAddress = (_a2 = mapLegalEntityToIndividual(parentLegalEntity2, false)) == null ? void 0 : _a2.address;
31216
- solePropData = {
31217
- ...solePropData,
31218
- solePropRegistrationAddress: {
31219
- ...solePropData == null ? void 0 : solePropData.solePropRegistrationAddress,
31220
- registrationAddress: {
31221
- ...defaultAddress
31222
- }
31223
- }
31224
- };
30772
+ const {
30773
+ getConfiguration: getConfiguration2
30774
+ } = useConfigurationApi();
30775
+ const {
30776
+ isSettingEnabled
30777
+ } = useSettingsContext();
30778
+ const [loadingStatus, setLoadingStatus] = useState("success");
30779
+ const formRef = useRef(null);
30780
+ const dataFromResponse = getDataWithDefaultAddress(legalEntityResponse, parentLegalEntity);
30781
+ const [data, setData] = useState(dataFromResponse);
30782
+ const country2 = ((_a = dataFromResponse == null ? void 0 : dataFromResponse.solePropRegistrationAddress) == null ? void 0 : _a.registrationAddress.country) || externalCountry;
30783
+ const baseTrackingPayload = getBaseTrackingPayload({
30784
+ trackingConfig,
30785
+ parentLegalEntity,
30786
+ legalEntity: legalEntityResponse,
30787
+ task: taskType
30788
+ });
30789
+ const getConfigurationData = useCallback(() => getConfiguration2({
30790
+ legalEntityType: LegalEntityType.SOLE_PROPRIETORSHIP,
30791
+ capabilities,
30792
+ country: country2
30793
+ }), [country2, capabilities]);
30794
+ const {
30795
+ fieldConfigurations,
30796
+ requiredFields
30797
+ } = useScenarioConfiguration({
30798
+ parseConfiguration: parseConfiguration$1,
30799
+ getConfigurationData,
30800
+ setLoadingStatus,
30801
+ country: country2
30802
+ });
30803
+ const fieldsFromCustomRules = useMemo(() => rules$2({
30804
+ data,
30805
+ country: country2,
30806
+ taskType,
30807
+ requiredFields,
30808
+ isSettingEnabled
30809
+ }), [country2, data, taskType, requiredFields, isSettingEnabled]);
30810
+ const derivedProps = useMemo(() => getPropsFromConfigurations(fieldConfigurations, solePropForms, (problems == null ? void 0 : problems.remediationActions) ? Object.values(problems == null ? void 0 : problems.remediationActions) : [], (problems == null ? void 0 : problems.missingData) ?? [], legalEntityResponse ? getFieldsWithExistingData(legalEntityResponse) : [], fieldsFromCustomRules), [fieldConfigurations, fieldsFromCustomRules, problems == null ? void 0 : problems.remediationActions]);
30811
+ const {
30812
+ state: {
30813
+ currentState
31225
30814
  }
31226
- return solePropData;
31227
- };
31228
- const [data, setData] = useState(getDataWithDefaultAddress(legalEntityResponse, parentLegalEntity));
31229
- const isDocumentsRequired2 = (forms2) => forms2.some((form) => [solePropForms.solePropConstitutionalDocument.formId].includes(form.formId));
30815
+ } = useStateContext();
30816
+ const formValidity = currentState.validityByForm;
30817
+ useEffect(() => {
30818
+ setData({
30819
+ ...currentState.data
30820
+ });
30821
+ onChange == null ? void 0 : onChange(currentState);
30822
+ }, [currentState]);
30823
+ const forms2 = useMemo(() => {
30824
+ const requiredForms = getRequiredForms(solePropForms, derivedProps == null ? void 0 : derivedProps.requiredFields, derivedProps == null ? void 0 : derivedProps.optionalFields);
30825
+ return addValidityToForms(requiredForms, formValidity, problems);
30826
+ }, [derivedProps, formValidity, problems]);
31230
30827
  const documentUtils = documentApiUtils(handleCreateDocument, handleGetDocument, handleUpdateDocument);
31231
30828
  const submitDocuments = async ({
31232
- forms: forms2,
30829
+ forms: forms22,
31233
30830
  legalEntity,
31234
30831
  dataSubmitted
31235
30832
  }) => {
31236
- if (isDocumentsRequired2(forms2)) {
30833
+ if (isDocumentsRequired(forms22)) {
31237
30834
  const formattedDocument = await mapSolePropDocumentToApiDocument(dataSubmitted, legalEntity.id);
31238
30835
  if (formattedDocument) {
31239
30836
  await documentUtils.uploadDocuments(formattedDocument, legalEntity.id);
@@ -31288,11 +30885,8 @@ function SolePropDropinComponent({
31288
30885
  const updatedLegalEntity = await handleUpdateLegalEntity(drop("type").from(mappedLegalEntity), (legalEntityResponse == null ? void 0 : legalEntityResponse.id) || (newSoleProp == null ? void 0 : newSoleProp.id));
31289
30886
  return updatedLegalEntity;
31290
30887
  };
31291
- const handleOnSubmit = async ({
31292
- data: dataSubmitted,
31293
- forms: forms2,
31294
- setLoadingStatus
31295
- }) => {
30888
+ const handleOnSubmit = async () => {
30889
+ const dataSubmitted = data;
31296
30890
  setLoadingStatus("loading");
31297
30891
  try {
31298
30892
  const legalEntity = await handleSubmitLegalEntity(mapSolePropToLegalEntity(dataSubmitted));
@@ -31309,7 +30903,7 @@ function SolePropDropinComponent({
31309
30903
  label: i18n.get("successfullyUpdatedDetails"),
31310
30904
  type: ToastType.SUCCESS
31311
30905
  });
31312
- onSubmit(dataSubmitted);
30906
+ onExternalSubmit == null ? void 0 : onExternalSubmit(dataSubmitted);
31313
30907
  } catch (e) {
31314
30908
  showToast({
31315
30909
  label: i18n.get("failedToUpdateDetails"),
@@ -31332,15 +30926,12 @@ function SolePropDropinComponent({
31332
30926
  setLoadingStatus("success");
31333
30927
  }
31334
30928
  };
31335
- const formatDataForSummary2 = (data2, forms2) => {
31336
- var _a2, _b, _c, _d;
30929
+ const formatDataForSummary2 = (data2, forms22) => {
30930
+ var _a2, _b2, _c, _d;
31337
30931
  let summaryData = cloneObject(data2);
31338
- let solePropCountry;
31339
- if ((_a2 = summaryData == null ? void 0 : summaryData.solePropNameAndCountry) == null ? void 0 : _a2.country) {
31340
- solePropCountry = datasetUtils.getCountryName(summaryData.solePropNameAndCountry.country);
31341
- }
30932
+ const solePropCountry = ((_a2 = summaryData == null ? void 0 : summaryData.solePropNameAndCountry) == null ? void 0 : _a2.country) ? datasetUtils.getCountryName(summaryData.solePropNameAndCountry.country) : void 0;
31342
30933
  summaryData.solePropNameAndCountry = {
31343
- legalNameOfSoleProprietor: (_b = data2.solePropNameAndCountry) == null ? void 0 : _b.legalCompanyName,
30934
+ legalNameOfSoleProprietor: (_b2 = data2.solePropNameAndCountry) == null ? void 0 : _b2.legalCompanyName,
31344
30935
  countryOfEstablishment: solePropCountry
31345
30936
  };
31346
30937
  if ((_c = summaryData == null ? void 0 : summaryData.solePropRegistrationAddress) == null ? void 0 : _c.registrationAddress) {
@@ -31350,53 +30941,62 @@ function SolePropDropinComponent({
31350
30941
  if ((_d = summaryData == null ? void 0 : summaryData.solePropRegistrationAddress) == null ? void 0 : _d.operationalAddress) {
31351
30942
  summaryData.solePropRegistrationAddress.operationalAddress = mapAddressLabels(summaryData == null ? void 0 : summaryData.solePropRegistrationAddress.operationalAddress, datasetUtils);
31352
30943
  }
31353
- if (isDocumentsRequired2(forms2)) {
30944
+ if (isDocumentsRequired(forms22)) {
31354
30945
  delete summaryData[solePropDocumentFormId];
31355
30946
  summaryData = {
31356
30947
  ...summaryData,
31357
- ...formatFileSummaryData2(data2.solePropConstitutionalDocument)
30948
+ ...formatFileSummaryData(data2.solePropConstitutionalDocument)
31358
30949
  };
31359
30950
  }
31360
30951
  return summaryData;
31361
30952
  };
31362
- const formatFileSummaryData2 = (solePropConstitutionalDocument) => {
31363
- var _a2;
31364
- const constitutionalDocument2 = (_a2 = solePropConstitutionalDocument == null ? void 0 : solePropConstitutionalDocument.constitutionalDocument) == null ? void 0 : _a2[0];
31365
- return {
31366
- ...constitutionalDocument2 && {
31367
- solePropConstitutionalDocument: {
31368
- fileName: constitutionalDocument2.name
31369
- }
31370
- }
31371
- };
31372
- };
31373
- const canSubmit2 = (data2) => mandatoryApiFields.SOLE_PROPRIETORSHIP.every((detail) => {
31374
- const value = getProp(data2, detail);
31375
- return !isEmpty(value);
30953
+ const {
30954
+ handleNextClick,
30955
+ handleBackClick,
30956
+ activeForm,
30957
+ shouldValidate,
30958
+ setShouldValidate,
30959
+ gotoFormByFormIndex,
30960
+ nextButtonLabel
30961
+ } = useFormComposer({
30962
+ problems,
30963
+ baseTrackingPayload,
30964
+ forms: forms2,
30965
+ formRef,
30966
+ onSubmit: handleOnSubmit
31376
30967
  });
31377
- return jsx(StateProvider, {
31378
- defaultData: data,
31379
- children: jsx(SolePropWithFormComposer, {
30968
+ return jsx(FormWrapper, {
30969
+ taskName: isExperimentEnabled("EnableNewEntryFlow") ? "soleProprietorshipDetails" : "solePropDetails",
30970
+ handleBackClick,
30971
+ handleNextClick,
30972
+ gotoFormByFormIndex,
30973
+ handleHomeClick,
30974
+ hideDropinLayout,
30975
+ nextButtonLabel,
30976
+ homeButtonLabel,
30977
+ loadingStatus,
30978
+ forms: forms2,
30979
+ activeForm,
30980
+ onSubmit: handleOnSubmit,
30981
+ validateForm: () => setShouldValidate(true),
30982
+ canSubmit: canSubmit(data) && hasDataChanged(dataFromResponse, data),
30983
+ baseTrackingPayload,
30984
+ problems,
30985
+ summary: {
30986
+ data: formatDataForSummary2(data, forms2),
30987
+ omittedKeys: ["operationalAddressIsSame"]
30988
+ },
30989
+ children: jsx(SolePropComponent, {
30990
+ ...derivedProps,
30991
+ activeForm,
31380
30992
  capabilities,
31381
- data,
31382
- country: ((_a = data == null ? void 0 : data.solePropNameAndCountry) == null ? void 0 : _a.country) || country2,
30993
+ data: dataFromResponse,
30994
+ country: ((_b = data == null ? void 0 : data.solePropNameAndCountry) == null ? void 0 : _b.country) || country2,
31383
30995
  problems,
31384
- eventEmitter,
31385
- hideDropinLayout,
31386
- legalEntityType: LegalEntityType.TRUST,
31387
- taskName: isExperimentEnabled("EnableNewEntryFlow") ? "soleProprietorshipDetails" : "solePropDetails",
31388
- legalEntityResponse,
31389
- summary: {
31390
- formatData: formatDataForSummary2,
31391
- getOmittedKeys
31392
- },
31393
- canSubmit: canSubmit2,
31394
- onChange,
31395
- onSubmit: handleOnSubmit,
31396
- handleHomeClick,
31397
- homeButtonLabel,
31398
30996
  handleAddressSearch,
31399
- handleFindAddress
30997
+ handleFindAddress,
30998
+ ref: formRef,
30999
+ shouldValidate
31400
31000
  })
31401
31001
  });
31402
31002
  }
@@ -31423,53 +31023,99 @@ const rules = ({
31423
31023
  }
31424
31024
  }
31425
31025
  });
31426
- const TrustWithFormComposer = withFormComposer(TrustComponent, {
31427
- getComponentForms: () => trustForms,
31428
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
31429
- parseConfiguration: ({
31430
- matchingScenario,
31431
- country: country2
31432
- }) => parseTrustScenarios(matchingScenario == null ? void 0 : matchingScenario[LegalEntityType.TRUST], country2),
31433
- rules,
31434
- defaultTaskName: "trustDetails"
31435
- });
31436
- function TrustDropinComponent(props) {
31437
- const {
31438
- parentLegalEntity,
31439
- legalEntityResponse,
31440
- handleCreateDocument,
31441
- handleGetDocument,
31442
- handleUpdateDocument,
31443
- handleAddressSearch,
31444
- handleFindAddress
31445
- } = props;
31026
+ const parseConfiguration = ({
31027
+ matchingScenario,
31028
+ country: country2
31029
+ }) => parseTrustScenarios(matchingScenario == null ? void 0 : matchingScenario[LegalEntityType.TRUST], country2);
31030
+ function TrustDropinComponent({
31031
+ parentLegalEntity,
31032
+ capabilities,
31033
+ country: country2,
31034
+ legalEntityResponse,
31035
+ handleCreateLegalEntity,
31036
+ handleUpdateLegalEntity,
31037
+ handleCreateDocument,
31038
+ handleGetDocument,
31039
+ handleUpdateDocument,
31040
+ handleAddressSearch,
31041
+ handleFindAddress,
31042
+ trackingConfig,
31043
+ taskType,
31044
+ problems: problemsProp,
31045
+ onSubmit: externalOnSubmit,
31046
+ onChange,
31047
+ hideDropinLayout,
31048
+ handleHomeClick,
31049
+ homeButtonLabel
31050
+ }) {
31051
+ var _a;
31446
31052
  const {
31447
31053
  i18n
31448
31054
  } = useI18nContext();
31449
31055
  const dataFromResponse = mapLegalEntityToTrust(legalEntityResponse);
31450
- const [data] = useState(dataFromResponse || props.data);
31451
- const [problems, setProblems] = useState(props.problems);
31056
+ const [data, setData] = useState(dataFromResponse);
31057
+ const [problems, setProblems] = useState(problemsProp);
31452
31058
  const datasetUtils = datasetUtilities(i18n.locale);
31453
- const getOmittedKeys = () => ["operationalAddressIsSame"];
31454
31059
  const [newTrust, setNewTrust] = useState(null);
31060
+ const {
31061
+ getConfiguration: getConfiguration2
31062
+ } = useConfigurationApi();
31063
+ const {
31064
+ isSettingEnabled
31065
+ } = useSettingsContext();
31455
31066
  const {
31456
31067
  showToast,
31457
31068
  clearToasts
31458
31069
  } = useToastContext();
31459
- const onSubmit = async ({
31460
- data: data2,
31070
+ const [loadingStatus, setLoadingStatus] = useState("success");
31071
+ const formRef = useRef(null);
31072
+ const getConfigurationData = useCallback(() => getConfiguration2({
31073
+ legalEntityType: LegalEntityType.TRUST,
31074
+ capabilities,
31075
+ country: country2
31076
+ }), [country2, capabilities]);
31077
+ const {
31078
+ fieldConfigurations,
31079
+ requiredFields
31080
+ } = useScenarioConfiguration({
31081
+ parseConfiguration,
31082
+ getConfigurationData,
31461
31083
  setLoadingStatus,
31462
- forms: forms2
31463
- }) => {
31464
- var _a;
31084
+ country: country2
31085
+ });
31086
+ const fieldsFromCustomRules = useMemo(() => rules({
31087
+ data,
31088
+ country: country2,
31089
+ taskType,
31090
+ requiredFields,
31091
+ isSettingEnabled
31092
+ }), [country2, data, taskType, requiredFields, isSettingEnabled]);
31093
+ const derivedProps = useMemo(() => getPropsFromConfigurations(fieldConfigurations, trustForms, (problems == null ? void 0 : problems.remediationActions) ? Object.values(problems == null ? void 0 : problems.remediationActions) : [], (problems == null ? void 0 : problems.missingData) ?? [], legalEntityResponse ? getFieldsWithExistingData(legalEntityResponse) : [], fieldsFromCustomRules), [fieldConfigurations, fieldsFromCustomRules, problems == null ? void 0 : problems.remediationActions]);
31094
+ const {
31095
+ state: {
31096
+ currentState
31097
+ }
31098
+ } = useStateContext();
31099
+ const formValidity = currentState.validityByForm;
31100
+ useEffect(() => {
31101
+ setData({
31102
+ ...currentState.data
31103
+ });
31104
+ onChange == null ? void 0 : onChange(currentState);
31105
+ }, [currentState]);
31106
+ const forms2 = useMemo(() => {
31107
+ const requiredForms = getRequiredForms(trustForms, derivedProps == null ? void 0 : derivedProps.requiredFields, derivedProps == null ? void 0 : derivedProps.optionalFields);
31108
+ return addValidityToForms(requiredForms, formValidity, problems);
31109
+ }, [derivedProps, formValidity, problems]);
31110
+ const onSubmit = async () => {
31465
31111
  setLoadingStatus("loading");
31466
- const trustDetails2 = mapTrustToLegalEntity(data2);
31112
+ const trustDetails2 = mapTrustToLegalEntity(data);
31467
31113
  try {
31468
31114
  const updatedTrust = await submitTrustDetails(trustDetails2);
31469
31115
  await submitDocuments({
31470
31116
  forms: forms2,
31471
31117
  legalEntity: updatedTrust,
31472
- dataSubmitted: data2
31118
+ dataSubmitted: data
31473
31119
  });
31474
31120
  await attachTrustToParentLegalEntity(updatedTrust);
31475
31121
  setLoadingStatus("success");
@@ -31477,7 +31123,7 @@ function TrustDropinComponent(props) {
31477
31123
  label: i18n.get("successfullyUpdatedDetails"),
31478
31124
  type: ToastType.SUCCESS
31479
31125
  });
31480
- (_a = props.onSubmit) == null ? void 0 : _a.call(props, data2);
31126
+ externalOnSubmit == null ? void 0 : externalOnSubmit(data);
31481
31127
  } catch (e) {
31482
31128
  showToast({
31483
31129
  label: i18n.get("failedToUpdateDetails"),
@@ -31503,27 +31149,27 @@ function TrustDropinComponent(props) {
31503
31149
  const submitTrustDetails = async (legalEntity) => {
31504
31150
  let updatedTrust;
31505
31151
  if (!(legalEntityResponse == null ? void 0 : legalEntityResponse.id) && !(newTrust == null ? void 0 : newTrust.id)) {
31506
- updatedTrust = await props.handleCreateLegalEntity(legalEntity);
31152
+ updatedTrust = await handleCreateLegalEntity(legalEntity);
31507
31153
  setNewTrust(legalEntity);
31508
31154
  } else {
31509
- updatedTrust = await props.handleUpdateLegalEntity(drop("type").from(legalEntity), (legalEntityResponse == null ? void 0 : legalEntityResponse.id) || (newTrust == null ? void 0 : newTrust.id));
31155
+ updatedTrust = await handleUpdateLegalEntity(drop("type").from(legalEntity), (legalEntityResponse == null ? void 0 : legalEntityResponse.id) || (newTrust == null ? void 0 : newTrust.id));
31510
31156
  }
31511
31157
  return updatedTrust;
31512
31158
  };
31513
31159
  const documentUtils = documentApiUtils(handleCreateDocument, handleGetDocument, handleUpdateDocument);
31514
31160
  const submitDocuments = async ({
31515
- forms: forms2,
31161
+ forms: forms22,
31516
31162
  legalEntity,
31517
31163
  dataSubmitted
31518
31164
  }) => {
31519
- if (isDocumentsRequired2(forms2)) {
31165
+ if (isDocumentsRequired2(forms22)) {
31520
31166
  const formattedDocument = await mapTrustDocumentToApiDocument(dataSubmitted, legalEntity.id);
31521
31167
  if (formattedDocument) {
31522
31168
  await documentUtils.uploadDocuments(formattedDocument, legalEntity.id);
31523
31169
  }
31524
31170
  }
31525
31171
  };
31526
- const isDocumentsRequired2 = (forms2) => forms2.some((form) => [trustForms.trustConstitutionalDocument.formId].includes(form.formId));
31172
+ const isDocumentsRequired2 = (forms22) => forms22.some((form) => [trustForms.trustConstitutionalDocument.formId].includes(form.formId));
31527
31173
  const attachTrustToParentLegalEntity = async (trust2) => {
31528
31174
  if (legalEntityResponse == null ? void 0 : legalEntityResponse.id) {
31529
31175
  return;
@@ -31535,30 +31181,25 @@ function TrustDropinComponent(props) {
31535
31181
  legalEntityId: trust2.id
31536
31182
  }, ...existingEntityAssociations]
31537
31183
  };
31538
- await props.handleUpdateLegalEntity(updatedParentLegalEntity, parentLegalEntity.id);
31184
+ await handleUpdateLegalEntity(updatedParentLegalEntity, parentLegalEntity.id);
31539
31185
  };
31540
- const formatDataForSummary2 = (data2, forms2) => {
31541
- var _a, _b, _c, _d, _e, _f, _g, _h;
31542
- let summaryData = cloneObject(data2);
31543
- let trustCountry;
31544
- let trustType2;
31545
- if ((_a = summaryData == null ? void 0 : summaryData.trustRegistrationDetails) == null ? void 0 : _a.country) {
31546
- trustCountry = datasetUtils.getCountryName(summaryData.trustRegistrationDetails.country);
31186
+ const formatDataForSummary2 = (data2, forms22) => {
31187
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
31188
+ let summaryData = cloneObject(data2) || {};
31189
+ if (summaryData == null ? void 0 : summaryData.trustRegistrationDetails) {
31190
+ const trustCountry = ((_a2 = summaryData == null ? void 0 : summaryData.trustRegistrationDetails) == null ? void 0 : _a2.country) ? datasetUtils.getCountryName(summaryData.trustRegistrationDetails.country) : void 0;
31191
+ const trustType2 = ((_b = summaryData == null ? void 0 : summaryData.trustRegistrationDetails) == null ? void 0 : _b.trustType) ? i18n.get((_c = trustTypeOptions.find((trustType22) => {
31192
+ var _a3;
31193
+ return trustType22.id === ((_a3 = summaryData.trustRegistrationDetails) == null ? void 0 : _a3.trustType);
31194
+ })) == null ? void 0 : _c.name) : void 0;
31195
+ summaryData.trustRegistrationDetails = {
31196
+ nameOfTrustAgreement: (_d = summaryData == null ? void 0 : summaryData.trustRegistrationDetails) == null ? void 0 : _d.legalName,
31197
+ countryOfEstablishment: trustCountry,
31198
+ typeOfTrustAgreement: trustType2,
31199
+ objectOfTrust: (_e = summaryData == null ? void 0 : summaryData.trustRegistrationDetails) == null ? void 0 : _e.objectOfTrust,
31200
+ taxId: (_f = summaryData == null ? void 0 : summaryData.trustRegistrationDetails) == null ? void 0 : _f.taxId
31201
+ };
31547
31202
  }
31548
- if ((_b = summaryData == null ? void 0 : summaryData.trustRegistrationDetails) == null ? void 0 : _b.trustType) {
31549
- const selectedTrustType = (_c = trustTypeOptions.find((trustType22) => {
31550
- var _a2;
31551
- return trustType22.id === ((_a2 = summaryData.trustRegistrationDetails) == null ? void 0 : _a2.trustType);
31552
- })) == null ? void 0 : _c.name;
31553
- trustType2 = i18n.get(selectedTrustType);
31554
- }
31555
- summaryData.trustRegistrationDetails = {
31556
- nameOfTrustAgreement: (_d = data2.trustRegistrationDetails) == null ? void 0 : _d.legalName,
31557
- countryOfEstablishment: trustCountry,
31558
- typeOfTrustAgreement: trustType2,
31559
- objectOfTrust: (_e = data2.trustRegistrationDetails) == null ? void 0 : _e.objectOfTrust,
31560
- taxId: (_f = data2.trustRegistrationDetails) == null ? void 0 : _f.taxId
31561
- };
31562
31203
  if ((_g = summaryData == null ? void 0 : summaryData.trustRegistrationAddress) == null ? void 0 : _g.registrationAddress) {
31563
31204
  summaryData.trustRegistrationAddress.hasInnerForms = true;
31564
31205
  summaryData.trustRegistrationAddress.registrationAddress = mapAddressLabels(summaryData == null ? void 0 : summaryData.trustRegistrationAddress.registrationAddress, datasetUtils);
@@ -31566,18 +31207,18 @@ function TrustDropinComponent(props) {
31566
31207
  if ((_h = summaryData == null ? void 0 : summaryData.trustRegistrationAddress) == null ? void 0 : _h.operationalAddress) {
31567
31208
  summaryData.trustRegistrationAddress.operationalAddress = mapAddressLabels(summaryData == null ? void 0 : summaryData.trustRegistrationAddress.operationalAddress, datasetUtils);
31568
31209
  }
31569
- if (isDocumentsRequired2(forms2)) {
31210
+ if (isDocumentsRequired2(forms22)) {
31570
31211
  delete summaryData[trustConstitutionalDocumentFormId];
31571
31212
  summaryData = {
31572
31213
  ...summaryData,
31573
- ...formatFileSummaryData2(data2.trustConstitutionalDocument)
31214
+ ...formatFileSummaryData2(summaryData == null ? void 0 : summaryData.trustConstitutionalDocument)
31574
31215
  };
31575
31216
  }
31576
31217
  return summaryData;
31577
31218
  };
31578
31219
  const formatFileSummaryData2 = (trustConstitutionalDocument) => {
31579
- var _a;
31580
- const constitutionalDocument2 = (_a = trustConstitutionalDocument == null ? void 0 : trustConstitutionalDocument.constitutionalDocument) == null ? void 0 : _a[0];
31220
+ var _a2;
31221
+ const constitutionalDocument2 = (_a2 = trustConstitutionalDocument == null ? void 0 : trustConstitutionalDocument.constitutionalDocument) == null ? void 0 : _a2[0];
31581
31222
  return {
31582
31223
  ...constitutionalDocument2 && {
31583
31224
  trustConstitutionalDocument: {
@@ -31590,28 +31231,59 @@ function TrustDropinComponent(props) {
31590
31231
  const value = getProp(data2, detail);
31591
31232
  return !isEmpty(value);
31592
31233
  });
31593
- return jsx(StateProvider, {
31594
- defaultData: data,
31595
- children: jsx(TrustWithFormComposer, {
31596
- capabilities: props.capabilities,
31234
+ const baseTrackingPayload = getBaseTrackingPayload({
31235
+ trackingConfig,
31236
+ parentLegalEntity,
31237
+ legalEntity: legalEntityResponse,
31238
+ task: taskType
31239
+ });
31240
+ const {
31241
+ handleNextClick,
31242
+ handleBackClick,
31243
+ activeForm,
31244
+ shouldValidate,
31245
+ setShouldValidate,
31246
+ gotoFormByFormIndex,
31247
+ nextButtonLabel
31248
+ } = useFormComposer({
31249
+ problems,
31250
+ baseTrackingPayload,
31251
+ forms: forms2,
31252
+ formRef,
31253
+ onSubmit
31254
+ });
31255
+ return jsx(FormWrapper, {
31256
+ taskName: "trustDetails",
31257
+ handleNextClick,
31258
+ handleBackClick,
31259
+ gotoFormByFormIndex,
31260
+ nextButtonLabel,
31261
+ loadingStatus,
31262
+ forms: forms2,
31263
+ activeForm,
31264
+ baseTrackingPayload,
31265
+ onSubmit,
31266
+ hideDropinLayout,
31267
+ handleHomeClick,
31268
+ homeButtonLabel,
31269
+ validateForm: () => setShouldValidate(true),
31270
+ canSubmit: canSubmit2(data) && hasDataChanged(dataFromResponse, data),
31271
+ problems,
31272
+ summary: {
31273
+ data: formatDataForSummary2(data, forms2),
31274
+ omittedKeys: ["operationalAddressIsSame"]
31275
+ },
31276
+ children: jsx(TrustComponent, {
31277
+ ...derivedProps,
31278
+ activeForm,
31279
+ capabilities,
31597
31280
  data,
31598
- country: props.country,
31281
+ country: ((_a = data == null ? void 0 : data.trustRegistrationDetails) == null ? void 0 : _a.country) ?? country2,
31599
31282
  problems,
31600
- eventEmitter: props.eventEmitter,
31601
- hideDropinLayout: props.hideDropinLayout,
31602
- onChange: props.onChange,
31603
- handleHomeClick: props.handleHomeClick,
31604
- homeButtonLabel: props.homeButtonLabel,
31605
- onSubmit,
31606
- legalEntityType: LegalEntityType.TRUST,
31607
- legalEntityResponse,
31608
- summary: {
31609
- formatData: formatDataForSummary2,
31610
- getOmittedKeys
31611
- },
31612
- canSubmit: canSubmit2,
31613
31283
  handleAddressSearch,
31614
- handleFindAddress
31284
+ handleFindAddress,
31285
+ shouldValidate,
31286
+ ref: formRef
31615
31287
  })
31616
31288
  });
31617
31289
  }
@@ -31629,7 +31301,7 @@ function DropinComposerComponent({
31629
31301
  onNavigate = noop,
31630
31302
  ...args
31631
31303
  }) {
31632
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
31304
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
31633
31305
  const {
31634
31306
  contextCountry,
31635
31307
  accountHolder: accountHolder2,
@@ -32523,7 +32195,7 @@ function DropinComposerComponent({
32523
32195
  onSubmit: componentOnSubmit,
32524
32196
  handleHomeClick: navigateBack,
32525
32197
  homeButtonLabel: i18n.get("saveAndGoToOverview"),
32526
- country: (_l = (_k = rootLegalEntity == null ? void 0 : rootLegalEntity.individual) == null ? void 0 : _k.residentialAddress) == null ? void 0 : _l.country,
32198
+ country: (((_k = solePropietor == null ? void 0 : solePropietor.soleProprietorship) == null ? void 0 : _k.countryOfGoverningLaw) || ((_m = (_l = solePropietor == null ? void 0 : solePropietor.soleProprietorship) == null ? void 0 : _l.registeredAddress) == null ? void 0 : _m.country)) ?? rootLegalEntityCountry,
32527
32199
  handleAddressSearch: args == null ? void 0 : args.handleAddressSearch,
32528
32200
  handleFindAddress: args == null ? void 0 : args.handleFindAddress
32529
32201
  });
@@ -33462,6 +33134,64 @@ const AuthProvider = ({
33462
33134
  children
33463
33135
  });
33464
33136
  };
33137
+ const fontFormats = ["eot", "woff", "woff2", "ttf", "otf"];
33138
+ const formatFullNames = {
33139
+ eot: "embedded-opentype",
33140
+ woff: "woff",
33141
+ woff2: "woff2",
33142
+ ttf: "truetype",
33143
+ otf: "opentype"
33144
+ };
33145
+ const getFontFaceRule = (fontFamily, fontStyle, fontWeight, fontPath, formats) => {
33146
+ const fontSources = formats.map((format) => `url(${fontPath}.${format}) format(${formatFullNames[format]})`);
33147
+ const ruleLines = [`font-family: '${fontFamily}'`, `font-style: ${fontStyle}`, `font-weight: ${fontWeight}`, `src: ${fontSources.join(",")}`];
33148
+ return `@font-face {${ruleLines.join(";")}}`;
33149
+ };
33150
+ const addStyleTagForFont = (fontFamily, fontStyle, fontWeight, fontPath, formats) => {
33151
+ const style = document.createElement("style");
33152
+ style.setAttribute("type", "text/css");
33153
+ style.innerText = getFontFaceRule(fontFamily, fontStyle, fontWeight, fontPath, formats);
33154
+ document.head.insertBefore(style, document.head.firstChild);
33155
+ };
33156
+ const addStyleTagForADLIconFont = (loadingContext) => {
33157
+ const fontPath = `${loadingContext}static/fonts`;
33158
+ const iconFontPath = `${fontPath}/adyen-kyc-icons`;
33159
+ addStyleTagForFont("adyen-kyc-icons", "normal", "normal", iconFontPath, fontFormats);
33160
+ };
33161
+ let isFlagsLoaded = false;
33162
+ let isDocumentGuidanceLoaded = false;
33163
+ const getIconContainer = () => {
33164
+ const container = document.createElement("div");
33165
+ container.setAttribute("aria-hidden", "true");
33166
+ container.setAttribute("id", "adl-icon-container");
33167
+ container.style.height = "0";
33168
+ return container;
33169
+ };
33170
+ const buildSpriteDOMFromResponse = (responseData) => {
33171
+ const iconContainer = getIconContainer();
33172
+ iconContainer.innerHTML = responseData;
33173
+ return iconContainer;
33174
+ };
33175
+ const loadFlags = async (loadingContext) => {
33176
+ if (isFlagsLoaded)
33177
+ return;
33178
+ isFlagsLoaded = true;
33179
+ const responseData = await http({
33180
+ loadingContext,
33181
+ path: "static/images/country-flags.svg"
33182
+ }, null, "text");
33183
+ document.body.insertBefore(buildSpriteDOMFromResponse(responseData), document.body.firstChild);
33184
+ };
33185
+ const loadDocumentGuidance = async (loadingContext) => {
33186
+ if (isDocumentGuidanceLoaded)
33187
+ return;
33188
+ isDocumentGuidanceLoaded = true;
33189
+ const responseData = await http({
33190
+ loadingContext,
33191
+ path: "static/images/document-guidance.svg"
33192
+ }, null, "text");
33193
+ document.body.insertBefore(buildSpriteDOMFromResponse(responseData), document.body.firstChild);
33194
+ };
33465
33195
  const accountFormatsImports = /* @__PURE__ */ Object.assign({ "./AD.json": () => import("./AD-43128b9f.mjs"), "./AE.json": () => import("./AE-81598d61.mjs"), "./AG.json": () => import("./AG-ed98ae0e.mjs"), "./AI.json": () => import("./AI-3e78c886.mjs"), "./AL.json": () => import("./AL-3ad2778a.mjs"), "./AM.json": () => import("./AM-6a5175fb.mjs"), "./AN.json": () => import("./AN-311f7139.mjs"), "./AO.json": () => import("./AO-99b5ef59.mjs"), "./AQ.json": () => import("./AQ-effe27c7.mjs"), "./AR.json": () => import("./AR-4013d95c.mjs"), "./AS.json": () => import("./AS-f15d56b2.mjs"), "./AT.json": () => import("./AT-d4d62b74.mjs"), "./AU.json": () => import("./AU-b9cba969.mjs"), "./AW.json": () => import("./AW-581f73fb.mjs"), "./AX.json": () => import("./AX-07af957a.mjs"), "./AZ.json": () => import("./AZ-be214142.mjs"), "./BA.json": () => import("./BA-af4be83f.mjs"), "./BB.json": () => import("./BB-df28f015.mjs"), "./BD.json": () => import("./BD-7aef0af6.mjs"), "./BE.json": () => import("./BE-fc7cf8d5.mjs"), "./BF.json": () => import("./BF-090b06e2.mjs"), "./BG.json": () => import("./BG-1f54cf4f.mjs"), "./BH.json": () => import("./BH-1e9cc2b9.mjs"), "./BJ.json": () => import("./BJ-d5dd5c6f.mjs"), "./BM.json": () => import("./BM-a808b13f.mjs"), "./BN.json": () => import("./BN-b13f6f6a.mjs"), "./BR.json": () => import("./BR-55d93100.mjs"), "./BS.json": () => import("./BS-db6a5bce.mjs"), "./BT.json": () => import("./BT-dfed2604.mjs"), "./BV.json": () => import("./BV-e123b0a8.mjs"), "./BW.json": () => import("./BW-08473bd7.mjs"), "./BY.json": () => import("./BY-2762d989.mjs"), "./BZ.json": () => import("./BZ-7f28b1ff.mjs"), "./CA.json": () => import("./CA-aa1f78ab.mjs"), "./CC.json": () => import("./CC-2cc6ac39.mjs"), "./CF.json": () => import("./CF-78ae0244.mjs"), "./CH.json": () => import("./CH-47f538c0.mjs"), "./CI.json": () => import("./CI-10feb889.mjs"), "./CK.json": () => import("./CK-e308c734.mjs"), "./CL.json": () => import("./CL-4a6c3e0b.mjs"), "./CM.json": () => import("./CM-fddc630d.mjs"), "./CN.json": () => import("./CN-46bb9203.mjs"), "./CO.json": () => import("./CO-1b150cda.mjs"), "./CR.json": () => import("./CR-2bf50f66.mjs"), "./CU.json": () => import("./CU-904aea8f.mjs"), "./CX.json": () => import("./CX-750ccd92.mjs"), "./CY.json": () => import("./CY-1508b23e.mjs"), "./CZ.json": () => import("./CZ-b6eaa1d5.mjs"), "./DE.json": () => import("./DE-e02051d4.mjs"), "./DJ.json": () => import("./DJ-0032728a.mjs"), "./DK.json": () => import("./DK-6116657e.mjs"), "./DM.json": () => import("./DM-a2c158c9.mjs"), "./DO.json": () => import("./DO-cedffa27.mjs"), "./DZ.json": () => import("./DZ-d44be6f8.mjs"), "./EC.json": () => import("./EC-c2e5813b.mjs"), "./EE.json": () => import("./EE-1a10f52d.mjs"), "./EG.json": () => import("./EG-8f29aebd.mjs"), "./EH.json": () => import("./EH-2dafda3e.mjs"), "./ES.json": () => import("./ES-42b3562e.mjs"), "./ET.json": () => import("./ET-ffa87ef0.mjs"), "./FI.json": () => import("./FI-8e3bb2bb.mjs"), "./FJ.json": () => import("./FJ-088ea689.mjs"), "./FK.json": () => import("./FK-16d84ff5.mjs"), "./FM.json": () => import("./FM-32616e6f.mjs"), "./FO.json": () => import("./FO-62c08e45.mjs"), "./FR.json": () => import("./FR-3db03e20.mjs"), "./GA.json": () => import("./GA-4de2f994.mjs"), "./GB.json": () => import("./GB-28ea0b5a.mjs"), "./GD.json": () => import("./GD-0ad67069.mjs"), "./GE.json": () => import("./GE-0f594b35.mjs"), "./GF.json": () => import("./GF-a062cea7.mjs"), "./GG.json": () => import("./GG-e00581ea.mjs"), "./GH.json": () => import("./GH-80209e7e.mjs"), "./GI.json": () => import("./GI-b0f7c8b3.mjs"), "./GL.json": () => import("./GL-8f5e8ba9.mjs"), "./GM.json": () => import("./GM-ff3ca013.mjs"), "./GN.json": () => import("./GN-fc7c0f8c.mjs"), "./GP.json": () => import("./GP-68f23382.mjs"), "./GQ.json": () => import("./GQ-f9867fbd.mjs"), "./GR.json": () => import("./GR-64a2d25c.mjs"), "./GS.json": () => import("./GS-49ce0f4c.mjs"), "./GT.json": () => import("./GT-fa779b14.mjs"), "./GU.json": () => import("./GU-f0dceb37.mjs"), "./GW.json": () => import("./GW-471336ea.mjs"), "./GY.json": () => import("./GY-2889ae39.mjs"), "./HK.json": () => import("./HK-675b8651.mjs"), "./HM.json": () => import("./HM-924a724f.mjs"), "./HN.json": () => import("./HN-6dae206e.mjs"), "./HR.json": () => import("./HR-85763090.mjs"), "./HT.json": () => import("./HT-a659da85.mjs"), "./HU.json": () => import("./HU-f9ea5037.mjs"), "./ID.json": () => import("./ID-cb5cfce1.mjs"), "./IE.json": () => import("./IE-b341cbd2.mjs"), "./IL.json": () => import("./IL-657901df.mjs"), "./IM.json": () => import("./IM-5bd6279a.mjs"), "./IN.json": () => import("./IN-3c11df0e.mjs"), "./IO.json": () => import("./IO-24f6d2e7.mjs"), "./IQ.json": () => import("./IQ-241c0148.mjs"), "./IS.json": () => import("./IS-4a7e436f.mjs"), "./IT.json": () => import("./IT-f9755e76.mjs"), "./JE.json": () => import("./JE-46968fa2.mjs"), "./JM.json": () => import("./JM-a6657a34.mjs"), "./JO.json": () => import("./JO-bd1eabea.mjs"), "./JP.json": () => import("./JP-9b5a30fa.mjs"), "./KE.json": () => import("./KE-2a866579.mjs"), "./KG.json": () => import("./KG-7713761d.mjs"), "./KH.json": () => import("./KH-a5f0f831.mjs"), "./KI.json": () => import("./KI-8376e298.mjs"), "./KM.json": () => import("./KM-48c8c9c0.mjs"), "./KN.json": () => import("./KN-b34777c7.mjs"), "./KR.json": () => import("./KR-8bcf8499.mjs"), "./KW.json": () => import("./KW-4dd6ab01.mjs"), "./KY.json": () => import("./KY-4f921c93.mjs"), "./KZ.json": () => import("./KZ-68b655f3.mjs"), "./LA.json": () => import("./LA-582a34e2.mjs"), "./LB.json": () => import("./LB-7e5023a3.mjs"), "./LC.json": () => import("./LC-4e610f91.mjs"), "./LI.json": () => import("./LI-3979434e.mjs"), "./LK.json": () => import("./LK-23f5002d.mjs"), "./LT.json": () => import("./LT-2076ca77.mjs"), "./LU.json": () => import("./LU-b0538582.mjs"), "./LV.json": () => import("./LV-440617df.mjs"), "./MA.json": () => import("./MA-f2af9aa6.mjs"), "./MC.json": () => import("./MC-f619d821.mjs"), "./MD.json": () => import("./MD-ffe4e2f4.mjs"), "./ME.json": () => import("./ME-46686aa8.mjs"), "./MH.json": () => import("./MH-c535387d.mjs"), "./MK.json": () => import("./MK-11442cf1.mjs"), "./ML.json": () => import("./ML-b2c3720e.mjs"), "./MM.json": () => import("./MM-0ae1a124.mjs"), "./MN.json": () => import("./MN-baba0d9d.mjs"), "./MO.json": () => import("./MO-2c51f9f7.mjs"), "./MP.json": () => import("./MP-55044c4b.mjs"), "./MQ.json": () => import("./MQ-aaefd2b2.mjs"), "./MR.json": () => import("./MR-f122a6f0.mjs"), "./MS.json": () => import("./MS-7623ec5f.mjs"), "./MT.json": () => import("./MT-315c76bb.mjs"), "./MU.json": () => import("./MU-126673fe.mjs"), "./MV.json": () => import("./MV-d8748aca.mjs"), "./MW.json": () => import("./MW-26492427.mjs"), "./MX.json": () => import("./MX-ca79b44b.mjs"), "./MY.json": () => import("./MY-443e729e.mjs"), "./MZ.json": () => import("./MZ-192a5094.mjs"), "./NC.json": () => import("./NC-3849aac0.mjs"), "./NE.json": () => import("./NE-bf76bc84.mjs"), "./NF.json": () => import("./NF-46f5dffa.mjs"), "./NG.json": () => import("./NG-458396e5.mjs"), "./NI.json": () => import("./NI-efe8c864.mjs"), "./NL.json": () => import("./NL-3e38d0eb.mjs"), "./NO.json": () => import("./NO-088fac56.mjs"), "./NP.json": () => import("./NP-26b20587.mjs"), "./NR.json": () => import("./NR-ba1f7da1.mjs"), "./NU.json": () => import("./NU-6dc3ed45.mjs"), "./NZ.json": () => import("./NZ-d7a003bc.mjs"), "./OM.json": () => import("./OM-4976855b.mjs"), "./PA.json": () => import("./PA-3b45122a.mjs"), "./PE.json": () => import("./PE-ad6e8281.mjs"), "./PF.json": () => import("./PF-2b1b6f30.mjs"), "./PG.json": () => import("./PG-b94ea47f.mjs"), "./PH.json": () => import("./PH-1b96a1eb.mjs"), "./PK.json": () => import("./PK-35cadd30.mjs"), "./PL.json": () => import("./PL-6a490cd1.mjs"), "./PM.json": () => import("./PM-d508f3c5.mjs"), "./PN.json": () => import("./PN-1f6ccf43.mjs"), "./PR.json": () => import("./PR-730f2830.mjs"), "./PS.json": () => import("./PS-f3ef78cd.mjs"), "./PT.json": () => import("./PT-66954cea.mjs"), "./PW.json": () => import("./PW-0d1c7797.mjs"), "./PY.json": () => import("./PY-c8e58794.mjs"), "./QA.json": () => import("./QA-35be8b1e.mjs"), "./RE.json": () => import("./RE-9f92ed9b.mjs"), "./RO.json": () => import("./RO-5c62edb1.mjs"), "./RS.json": () => import("./RS-bc256d90.mjs"), "./RU.json": () => import("./RU-bbee5e73.mjs"), "./RW.json": () => import("./RW-95b5d859.mjs"), "./SA.json": () => import("./SA-69b2f72a.mjs"), "./SB.json": () => import("./SB-567c239a.mjs"), "./SC.json": () => import("./SC-9e5a0d31.mjs"), "./SE.json": () => import("./SE-4ed53265.mjs"), "./SG.json": () => import("./SG-970463e3.mjs"), "./SH.json": () => import("./SH-d8ab21b7.mjs"), "./SI.json": () => import("./SI-3b6d3545.mjs"), "./SJ.json": () => import("./SJ-e3430cfd.mjs"), "./SK.json": () => import("./SK-2385e057.mjs"), "./SL.json": () => import("./SL-92bf45d9.mjs"), "./SM.json": () => import("./SM-bafbc267.mjs"), "./SN.json": () => import("./SN-5733e740.mjs"), "./SO.json": () => import("./SO-d5b69054.mjs"), "./SR.json": () => import("./SR-0a8c71c0.mjs"), "./ST.json": () => import("./ST-d40d86c1.mjs"), "./TC.json": () => import("./TC-ccbc7116.mjs"), "./TD.json": () => import("./TD-679d137c.mjs"), "./TF.json": () => import("./TF-6bfcf75d.mjs"), "./TG.json": () => import("./TG-a20ef9ed.mjs"), "./TH.json": () => import("./TH-e39a447c.mjs"), "./TK.json": () => import("./TK-89a81d38.mjs"), "./TL.json": () => import("./TL-8d6ca9b7.mjs"), "./TN.json": () => import("./TN-6e746476.mjs"), "./TO.json": () => import("./TO-a8c55d73.mjs"), "./TR.json": () => import("./TR-b1175ddc.mjs"), "./TT.json": () => import("./TT-5c4a3940.mjs"), "./TV.json": () => import("./TV-e1a267b9.mjs"), "./TW.json": () => import("./TW-9e0e34fa.mjs"), "./TZ.json": () => import("./TZ-c8a8159b.mjs"), "./UA.json": () => import("./UA-7014199a.mjs"), "./UG.json": () => import("./UG-1fe39fa7.mjs"), "./UM.json": () => import("./UM-3fcbf872.mjs"), "./US.json": () => import("./US-6fbdfc0c.mjs"), "./UY.json": () => import("./UY-e6d05d75.mjs"), "./UZ.json": () => import("./UZ-433656c8.mjs"), "./VA.json": () => import("./VA-e8e13d32.mjs"), "./VC.json": () => import("./VC-331669c0.mjs"), "./VE.json": () => import("./VE-5e7b0d3b.mjs"), "./VG.json": () => import("./VG-43e85e33.mjs"), "./VI.json": () => import("./VI-3d9d6d8b.mjs"), "./VN.json": () => import("./VN-9442a8c1.mjs"), "./VU.json": () => import("./VU-96fae02f.mjs"), "./WF.json": () => import("./WF-90a27056.mjs"), "./WS.json": () => import("./WS-ddcb2b71.mjs"), "./YE.json": () => import("./YE-02c4c81e.mjs"), "./YT.json": () => import("./YT-33751cc9.mjs"), "./ZA.json": () => import("./ZA-0084b083.mjs"), "./ZM.json": () => import("./ZM-c6a4d6cc.mjs") });
33466
33196
  const getAccountFormatsForCountry = async (country2) => {
33467
33197
  const importForCountry = accountFormatsImports[`./${country2}.json`];
@@ -33934,6 +33664,182 @@ function SettingsContextProvider({
33934
33664
  children
33935
33665
  });
33936
33666
  }
33667
+ function removeObjectPropsWithEmptyValues(obj) {
33668
+ keysOf(obj).forEach((key) => {
33669
+ if (obj[key] === null || isEmpty(obj[key]))
33670
+ delete obj[key];
33671
+ });
33672
+ return obj;
33673
+ }
33674
+ const INITIAL_STATE = {
33675
+ data: {},
33676
+ allData: {},
33677
+ initialData: {},
33678
+ errors: {},
33679
+ valid: {},
33680
+ fieldProblems: {},
33681
+ isValid: false
33682
+ };
33683
+ function StateReducer() {
33684
+ const [schemas, setSchemas] = useState({});
33685
+ const [activeForms, setActiveForms] = useState([]);
33686
+ const setCurrentForms = (forms2) => {
33687
+ setActiveForms(forms2);
33688
+ };
33689
+ function reducer2({
33690
+ currentState: currState
33691
+ }, action) {
33692
+ var _a, _b, _c;
33693
+ switch (action.type) {
33694
+ case "addToState": {
33695
+ const state2 = structuredClone(currState);
33696
+ const dataStoreId = action.value.dataStoreId ?? action.value.caller;
33697
+ const schema = action.value.schema || null;
33698
+ const schemaHasChanged = schema && ((_a = schemas == null ? void 0 : schemas[dataStoreId]) == null ? void 0 : _a.toString()) !== schema.toString();
33699
+ const mergedState = {
33700
+ ...state2,
33701
+ data: {
33702
+ ...state2.data,
33703
+ [dataStoreId]: {
33704
+ ...state2.data[dataStoreId],
33705
+ ...action.value.data
33706
+ }
33707
+ },
33708
+ // Add data in allData state prop in case we will need them later
33709
+ allData: {
33710
+ ...state2.allData,
33711
+ [dataStoreId]: {
33712
+ ...state2.allData[dataStoreId],
33713
+ ...removeObjectPropsWithEmptyValues(action.value.data)
33714
+ }
33715
+ },
33716
+ errors: {
33717
+ ...state2.errors,
33718
+ [dataStoreId]: {
33719
+ ...state2.errors[dataStoreId],
33720
+ ...action.value.errors
33721
+ }
33722
+ },
33723
+ valid: {
33724
+ ...state2.valid,
33725
+ [dataStoreId]: {
33726
+ ...state2.valid[dataStoreId],
33727
+ ...action.value.valid
33728
+ }
33729
+ },
33730
+ fieldProblems: {
33731
+ ...state2.fieldProblems,
33732
+ [dataStoreId]: {
33733
+ ...state2.fieldProblems[dataStoreId],
33734
+ ...action.value.fieldProblems
33735
+ }
33736
+ }
33737
+ };
33738
+ if (schemaHasChanged) {
33739
+ setSchemas({
33740
+ ...schemas,
33741
+ [dataStoreId]: schema
33742
+ });
33743
+ const processedBySchema = schema.reduce((acc, fieldKey) => {
33744
+ const dataObjByFormId = mergedState.data[dataStoreId];
33745
+ const allDataObjByFormId = mergedState.allData[dataStoreId];
33746
+ const validObjByFormId = mergedState.valid[dataStoreId];
33747
+ const errorsObjByFormId = mergedState.errors[dataStoreId];
33748
+ const fieldProblemsObjByFormId = mergedState.fieldProblems[dataStoreId];
33749
+ return {
33750
+ data: {
33751
+ ...acc.data,
33752
+ [fieldKey]: dataObjByFormId[fieldKey] ?? allDataObjByFormId[fieldKey]
33753
+ },
33754
+ valid: {
33755
+ ...acc.valid,
33756
+ [fieldKey]: validObjByFormId[fieldKey]
33757
+ },
33758
+ errors: {
33759
+ ...acc.errors,
33760
+ [fieldKey]: errorsObjByFormId[fieldKey]
33761
+ },
33762
+ fieldProblems: {
33763
+ ...acc.fieldProblems,
33764
+ [fieldKey]: fieldProblemsObjByFormId[fieldKey]
33765
+ }
33766
+ };
33767
+ }, {
33768
+ data: {},
33769
+ valid: {},
33770
+ errors: {},
33771
+ fieldProblems: {}
33772
+ });
33773
+ mergedState.data[dataStoreId] = processedBySchema.data;
33774
+ mergedState.valid[dataStoreId] = processedBySchema.valid;
33775
+ mergedState.errors[dataStoreId] = processedBySchema.errors;
33776
+ mergedState.fieldProblems[dataStoreId] = processedBySchema.fieldProblems;
33777
+ }
33778
+ mergedState.validityByForm = {
33779
+ ...mergedState.validityByForm,
33780
+ [dataStoreId]: Object.values(mergedState.valid[dataStoreId]).every((isValid) => isValid)
33781
+ };
33782
+ mergedState.allValid = Object.values(mergedState.validityByForm).every((isValid) => isValid);
33783
+ mergedState.isValid = !activeForms.length ? mergedState.allValid : activeForms.every((item) => mergedState.validityByForm[item]);
33784
+ mergedState.initialData = structuredClone(state2.initialData);
33785
+ return {
33786
+ currentState: mergedState,
33787
+ prevState: state2,
33788
+ changeInitiatedBy: dataStoreId
33789
+ };
33790
+ }
33791
+ case "resetState": {
33792
+ const dataStoreId = ((_b = action.value) == null ? void 0 : _b.dataStoreId) ?? ((_c = action.value) == null ? void 0 : _c.caller);
33793
+ return {
33794
+ currentState: INITIAL_STATE,
33795
+ prevState: currState,
33796
+ changeInitiatedBy: dataStoreId
33797
+ };
33798
+ }
33799
+ default: {
33800
+ throw new Error(`Unhandled action type: ${action.type}`);
33801
+ }
33802
+ }
33803
+ }
33804
+ return {
33805
+ reducer: reducer2,
33806
+ setCurrentForms
33807
+ };
33808
+ }
33809
+ function StateProvider({
33810
+ defaultData = {},
33811
+ children
33812
+ }) {
33813
+ const defaultState = {
33814
+ currentState: {
33815
+ data: defaultData,
33816
+ allData: defaultData,
33817
+ valid: {},
33818
+ errors: {},
33819
+ fieldProblems: {},
33820
+ validityByForm: {},
33821
+ initialData: defaultData
33822
+ },
33823
+ prevState: {},
33824
+ changeInitiatedBy: null
33825
+ };
33826
+ const reducerObj = StateReducer();
33827
+ const [state2, dispatch] = useReducer(reducerObj.reducer, defaultState);
33828
+ const contextValue = useMemo(() => ({
33829
+ state: state2,
33830
+ dispatch,
33831
+ setActiveForms: reducerObj.setCurrentForms,
33832
+ getData: () => {
33833
+ var _a;
33834
+ return ((_a = state2 == null ? void 0 : state2.currentState) == null ? void 0 : _a.data) ?? {};
33835
+ },
33836
+ getState: () => state2 == null ? void 0 : state2.currentState
33837
+ }), [reducerObj, state2]);
33838
+ return jsx(StateContext.Provider, {
33839
+ value: contextValue,
33840
+ children
33841
+ });
33842
+ }
33937
33843
  function ToastContextProvider({
33938
33844
  children
33939
33845
  }) {