@adyen/kyc-components 2.27.1 → 2.28.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 (57) hide show
  1. package/dist/es/adyen-kyc-components.es.js +1137 -1284
  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 +252 -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 +4 -4
  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/Dropins/{FormComposer/components/FormNavigation → FormNavigation}/FormNavigation.d.ts +0 -0
  55. /package/dist/types/components/Dropins/{FormComposer/components/FormNavigation → FormNavigation}/FormNavigationItem.d.ts +0 -0
  56. /package/dist/types/components/Dropins/{FormComposer/components/FormNavigation → FormNavigation}/index.d.ts +0 -0
  57. /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";
@@ -278,7 +278,7 @@ const serviceAgreementSignFailed = "Service agreement signing failed";
278
278
  const failedToGetServiceAgreementStatus = "Failed to get the service agreement status";
279
279
  const failedToGetServiceAgreement = "Failed to get the service agreement";
280
280
  const failedToGetServiceAgreementInSelectedLanguageFallbackToEn = "Failed to get the service agreement in the selected language. Falling back to English.";
281
- const iHaveReadAndIAcceptTheseTerms = "I have read and I accept these terms and confirm that I am a legal representative authorized to accept these terms on behalf of the company. I have taken notice of the privacy statement (www.adyen.com/privacy) and I consent to my (personal) data being used for the purposes described therein.";
281
+ const iHaveReadAndIAcceptTheseTerms = "I have read and I accept these terms and confirm that I am a legal representative authorized to accept these terms on behalf of the company. I have taken notice of the privacy statement (www.adyen.com/policies-and-disclaimer/privacy-policy) and I consent to my (personal) data being used for the purposes described therein.";
282
282
  const verified = "Verified";
283
283
  const signed = "Signed";
284
284
  const invalidRole = "Please select a role";
@@ -841,13 +841,7 @@ const legalCompanyName__helperText__US = "Enter the name exactly as it appears o
841
841
  const legalCompanyName__helperText__SG = "Enter the name exactly as it is on your Accounting and Corporate Regulatory Authority (ACRA) BizFile.";
842
842
  const legalCompanyName__helperText__HK = "Enter the name exactly as it is on your Hong Kong Companies Registry's Certificate of Incorporation.";
843
843
  const taxInformationNumber = "Tax Identification Number";
844
- const taxInformationNumber__US = "Tax Identification Number (TIN)";
845
- const taxInformationNumber__helperText__US = "Also known as Employer Identification Number (EIN), this is issued by the IRS to businesses operating in the US.";
846
- const businessRegistrationNumber = "Business registration number";
847
- const businessRegistrationNumber__optional = "Business registration number (optional)";
848
- const businessRegistrationNumber__HK = "Business Registration number (BRN)";
849
- const businessRegistrationNumber__helperText__US = "This can be found on your registration documents or any documents you receive from the registrar such as account reminders.";
850
- const businessRegistrationNumber__placeholder__US = "1234567 AB";
844
+ const taxInformationNumber__HK = "Business Registration number (BRN)";
851
845
  const stockExchangeMIC = "Stock Exchange MIC";
852
846
  const stockExchangeMIC__US = "Market identifier code (MIC)";
853
847
  const stockExchangeMIC__placeholder__US = "XABC";
@@ -1385,7 +1379,7 @@ const defaultTrans = {
1385
1379
  doNotHaveRegonKrsNumber,
1386
1380
  taxIdAbsenceReason,
1387
1381
  vatNumberExempted,
1388
- vatNumberAbsenceReason,
1382
+ vatAbsenceReason,
1389
1383
  belowTaxThreshold,
1390
1384
  industryExemption,
1391
1385
  validationPleaseEnterAValidRegistrationNumber,
@@ -2045,13 +2039,7 @@ const defaultTrans = {
2045
2039
  legalCompanyName__helperText__SG,
2046
2040
  legalCompanyName__helperText__HK,
2047
2041
  taxInformationNumber,
2048
- taxInformationNumber__US,
2049
- taxInformationNumber__helperText__US,
2050
- businessRegistrationNumber,
2051
- businessRegistrationNumber__optional,
2052
- businessRegistrationNumber__HK,
2053
- businessRegistrationNumber__helperText__US,
2054
- businessRegistrationNumber__placeholder__US,
2042
+ taxInformationNumber__HK,
2055
2043
  stockExchangeMIC,
2056
2044
  stockExchangeMIC__US,
2057
2045
  stockExchangeMIC__placeholder__US,
@@ -3291,36 +3279,36 @@ var LegalEntityType = /* @__PURE__ */ ((LegalEntityType2) => {
3291
3279
  })(LegalEntityType || {});
3292
3280
  function getFormProps(props, innerFormId) {
3293
3281
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
3294
- if (innerFormId) {
3295
- const nestedFormProps = {
3296
- placeholders: ((_a = props.placeholders) == null ? void 0 : _a[innerFormId]) ?? {},
3297
- labels: ((_b = props.labels) == null ? void 0 : _b[innerFormId]) ?? {},
3298
- helperText: ((_c = props.helperText) == null ? void 0 : _c[innerFormId]) ?? {},
3299
- masks: ((_d = props.masks) == null ? void 0 : _d[innerFormId]) ?? {},
3300
- data: ((_e = props.data) == null ? void 0 : _e[innerFormId]) ?? {},
3301
- readOnlyFields: ((_f = props.readOnlyFields) == null ? void 0 : _f[innerFormId]) ?? [],
3302
- requiredFields: ((_g = props.requiredFields) == null ? void 0 : _g[innerFormId]) ?? [],
3303
- optionalFields: ((_h = props.optionalFields) == null ? void 0 : _h[innerFormId]) ?? [],
3304
- maskedFields: ((_i = props.maskedFields) == null ? void 0 : _i[innerFormId]) ?? [],
3305
- verifyFields: ((_j = props.verifyFields) == null ? void 0 : _j[innerFormId]) ?? [],
3306
- formVerificationErrors: ((_l = (_k = props.problems) == null ? void 0 : _k.verificationErrors) == null ? void 0 : _l[innerFormId]) ?? {},
3307
- fieldValidationErrors: ((_n = (_m = props.problems) == null ? void 0 : _m.validationErrors) == null ? void 0 : _n[innerFormId]) ?? {},
3308
- /*
3282
+ if (!innerFormId) {
3283
+ return null;
3284
+ }
3285
+ const activeFormId = (_a = props.activeForm) == null ? void 0 : _a.formId;
3286
+ return {
3287
+ placeholders: ((_b = props.placeholders) == null ? void 0 : _b[innerFormId]) ?? {},
3288
+ labels: ((_c = props.labels) == null ? void 0 : _c[innerFormId]) ?? {},
3289
+ helperText: ((_d = props.helperText) == null ? void 0 : _d[innerFormId]) ?? {},
3290
+ masks: ((_e = props.masks) == null ? void 0 : _e[innerFormId]) ?? {},
3291
+ data: ((_f = props.data) == null ? void 0 : _f[innerFormId]) ?? {},
3292
+ readOnlyFields: ((_g = props.readOnlyFields) == null ? void 0 : _g[innerFormId]) ?? [],
3293
+ requiredFields: ((_h = props.requiredFields) == null ? void 0 : _h[innerFormId]) ?? [],
3294
+ optionalFields: ((_i = props.optionalFields) == null ? void 0 : _i[innerFormId]) ?? [],
3295
+ maskedFields: ((_j = props.maskedFields) == null ? void 0 : _j[innerFormId]) ?? [],
3296
+ verifyFields: ((_k = props.verifyFields) == null ? void 0 : _k[innerFormId]) ?? [],
3297
+ formVerificationErrors: ((_m = (_l = props.problems) == null ? void 0 : _l.verificationErrors) == null ? void 0 : _m[innerFormId]) ?? {},
3298
+ fieldValidationErrors: ((_o = (_n = props.problems) == null ? void 0 : _n.validationErrors) == null ? void 0 : _o[innerFormId]) ?? {},
3299
+ /*
3309
3300
  Validators should be `null` and not `{}` by default to make it easier to short circuit it with predetermined validators.
3310
3301
  For example `rules: props.validators || personalDetailsValidationRules`.
3311
3302
  */
3312
- validators: ((_o = props.validators) == null ? void 0 : _o[innerFormId]) ? {
3313
- ...(_p = props.validators) == null ? void 0 : _p[innerFormId]
3314
- } : null,
3315
- /*
3316
- activeForm check is required for shouldValidate because of we render all forms in a multistep form.
3303
+ validators: ((_p = props.validators) == null ? void 0 : _p[innerFormId]) ? {
3304
+ ...(_q = props.validators) == null ? void 0 : _q[innerFormId]
3305
+ } : null,
3306
+ /*
3307
+ activeForm check is required for shouldValidate because we render all forms in a multistep form.
3317
3308
  Should be changed once stateManagement is fixed and this is no longer the case
3318
3309
  */
3319
- shouldValidate: ((_q = props.activeForm) == null ? void 0 : _q.formId) === innerFormId && props.shouldValidate
3320
- };
3321
- return nestedFormProps;
3322
- }
3323
- return null;
3310
+ shouldValidate: (activeFormId ? activeFormId === innerFormId : true) && props.shouldValidate
3311
+ };
3324
3312
  }
3325
3313
  function getFieldProps(props, innerFormFields) {
3326
3314
  if (innerFormFields) {
@@ -5960,7 +5948,11 @@ const matchAgainstMask = (pureValue, mask) => {
5960
5948
  }
5961
5949
  }
5962
5950
  };
5963
- const deriveInputState = (isValid, isFocused, hasBlurred, errorMessage, shouldValidate, potentiallyMoreOptionalCharacters, formatGuidance, i18n) => {
5951
+ const deriveInputState = (isValid, isFocused, hasBlurred, isDisabled, errorMessage, shouldValidate, potentiallyMoreOptionalCharacters, formatGuidance, i18n) => {
5952
+ if (isDisabled)
5953
+ return {
5954
+ isError: false
5955
+ };
5964
5956
  if (isValid && (!potentiallyMoreOptionalCharacters || !isFocused))
5965
5957
  return {
5966
5958
  isError: false,
@@ -6045,7 +6037,7 @@ const MaskedInputText = ({
6045
6037
  }, [mask]);
6046
6038
  const maskResult = useMemo(() => getMaskResult(value), [getMaskResult, value]);
6047
6039
  const displayValue = maskResult.outcome === "mismatch" ? maskResult.partialDisplayValue : maskResult.displayValue;
6048
- const inputState = deriveInputState(validationIsValid && maskResult.outcome !== "mismatch", isFocused, hasBlurred, errorMessage, shouldValidate, maskResult.outcome === "correct" && !!maskResult.potentialForMoreOptionalInput, formatGuidance, i18n);
6040
+ const inputState = deriveInputState(validationIsValid && maskResult.outcome !== "mismatch", isFocused, hasBlurred, disabled, errorMessage, shouldValidate, maskResult.outcome === "correct" && !!maskResult.potentialForMoreOptionalInput, formatGuidance, i18n);
6049
6041
  useEffect(() => {
6050
6042
  if (mask && maskResult.outcome === "mismatch") {
6051
6043
  const strippedValue = displayValueToPure(value);
@@ -6073,6 +6065,7 @@ Falling back to partially valid value "${fallback}"`);
6073
6065
  helper: inputState.isError ? void 0 : inputState.text,
6074
6066
  helperPosition: "below",
6075
6067
  classNameModifiers: classNameModifiers == null ? void 0 : classNameModifiers.field,
6068
+ disabled,
6076
6069
  children: ({
6077
6070
  onBlurHandler: fieldOnBlur,
6078
6071
  onFocusHandler: fieldOnFocus,
@@ -6677,10 +6670,10 @@ const validatePatternOnBlur = (pattern) => ({
6677
6670
  modes: ["blur"],
6678
6671
  validate: (val) => !!val && pattern.test(val)
6679
6672
  });
6680
- const defaultFieldMetadata$2 = {
6673
+ const defaultFieldMetadata$3 = {
6681
6674
  label: "registrationNumber"
6682
6675
  };
6683
- const defaultFieldConfig$2 = {
6676
+ const defaultFieldConfig$3 = {
6684
6677
  [CountryCodes.Australia]: {
6685
6678
  label: "australianBusinessNumberAcn",
6686
6679
  mask: businessRegistrationNumberMasks[CountryCodes.Australia].default,
@@ -6775,7 +6768,7 @@ const defaultFieldConfig$2 = {
6775
6768
  key: "enterNDigitsForExample",
6776
6769
  values: {
6777
6770
  numDigits: "9",
6778
- example: "80020970"
6771
+ example: "080020970"
6779
6772
  }
6780
6773
  }
6781
6774
  },
@@ -6987,13 +6980,17 @@ const defaultFieldConfig$2 = {
6987
6980
  default:
6988
6981
  return {
6989
6982
  label: "partitaIVA",
6990
- mask: businessRegistrationNumberMasks[CountryCodes.Italy].partitaIVA,
6991
- validators: validatePatternOnBlur(businessRegistrationNumberPatterns[CountryCodes.Italy].partitaIVA),
6983
+ validators: validatePatternOnBlur(/^\d{11}$/),
6984
+ mask: {
6985
+ mask: makeMask(...nonInputs("IT", {
6986
+ includeInValue: false
6987
+ }), spacer, ...numericInputs(11))
6988
+ },
6992
6989
  guidanceText: {
6993
- key: "enterNDigitsForExample",
6990
+ key: "enterTheRemainingNDigitsForExample",
6994
6991
  values: {
6995
6992
  numDigits: "11",
6996
- example: "47040001100"
6993
+ example: "IT47040001100"
6997
6994
  }
6998
6995
  }
6999
6996
  };
@@ -7329,7 +7326,7 @@ const defaultFieldConfig$2 = {
7329
7326
  const businessRegistrationNumberFields = ["registrationNumber", "exemptedFromRegistrationNumber"];
7330
7327
  function BusinessRegistrationNumber(props) {
7331
7328
  var _a;
7332
- const fieldConfig = props.fieldConfig ?? defaultFieldConfig$2;
7329
+ const fieldConfig = props.fieldConfig ?? defaultFieldConfig$3;
7333
7330
  const {
7334
7331
  i18n
7335
7332
  } = useI18nContext();
@@ -7345,7 +7342,7 @@ function BusinessRegistrationNumber(props) {
7345
7342
  const metadata = resolveFieldMetadata(fieldConfig[country2], {
7346
7343
  companyType: companyType2,
7347
7344
  registrationNumberType
7348
- }, defaultFieldMetadata$2);
7345
+ }, defaultFieldMetadata$3);
7349
7346
  const mergedProps = mergeFieldMetadataIntoProps("registrationNumber", metadata, {
7350
7347
  requiredFields: schema
7351
7348
  });
@@ -7907,7 +7904,7 @@ function CompanyRegistrationNumberTypeSelector({
7907
7904
  }
7908
7905
  const inferCompanyRegistrationNumberType = (registrationNumber2, country2, companyType2) => {
7909
7906
  const optionsForCountry = companyRegistrationNumberOptions[country2];
7910
- const metadataFn = defaultFieldConfig$2[country2];
7907
+ const metadataFn = defaultFieldConfig$3[country2];
7911
7908
  if (!optionsForCountry || !metadataFn || typeof metadataFn !== "function")
7912
7909
  return void 0;
7913
7910
  for (const option of optionsForCountry) {
@@ -7923,10 +7920,10 @@ const inferCompanyRegistrationNumberType = (registrationNumber2, country2, compa
7923
7920
  }
7924
7921
  }
7925
7922
  };
7926
- const defaultFieldMetadata$1 = {
7923
+ const defaultFieldMetadata$2 = {
7927
7924
  label: "taxId"
7928
7925
  };
7929
- const defaultFieldConfig$1 = {
7926
+ const defaultFieldConfig$2 = {
7930
7927
  [CountryCodes.Canada]: {
7931
7928
  label: "businessNumber",
7932
7929
  validators: validatePatternOnBlur(/^\d{9}$/),
@@ -7942,7 +7939,7 @@ const defaultFieldConfig$1 = {
7942
7939
  }
7943
7940
  },
7944
7941
  [CountryCodes.HongKong]: {
7945
- label: "businessRegistrationNumber__HK",
7942
+ label: "taxInformationNumber__HK",
7946
7943
  validators: validatePatternOnBlur(/^\d{8}$/),
7947
7944
  mask: {
7948
7945
  mask: makeMask(...numericInputs(8))
@@ -8027,7 +8024,7 @@ const defaultFieldConfig$1 = {
8027
8024
  mask: {
8028
8025
  mask: makeMask(...numericInputs(9))
8029
8026
  },
8030
- helperText: {
8027
+ guidanceText: {
8031
8028
  key: "validationPleaseEnterAValidTaxIdNumberWithFormat",
8032
8029
  values: {
8033
8030
  format: "XXXXXXXXX"
@@ -8055,10 +8052,10 @@ const defaultFieldConfig$1 = {
8055
8052
  validators: validatePatternOnBlur(/^\d{12}$/)
8056
8053
  }
8057
8054
  };
8058
- const defaultFieldMetadata = {
8055
+ const defaultFieldMetadata$1 = {
8059
8056
  label: "vatNumber"
8060
8057
  };
8061
- const defaultFieldConfig = {
8058
+ const defaultFieldConfig$1 = {
8062
8059
  [CountryCodes.Austria]: {
8063
8060
  label: "UST-ID",
8064
8061
  validators: validatePatternOnBlur(/^ATU\d{8}$/),
@@ -8348,7 +8345,7 @@ const defaultFieldConfig = {
8348
8345
  key: "enterTheRemainingNDigitsForExample",
8349
8346
  values: {
8350
8347
  numDigits: "11",
8351
- example: "IT12345678901"
8348
+ example: "IT47040001100"
8352
8349
  }
8353
8350
  }
8354
8351
  },
@@ -8613,7 +8610,7 @@ const defaultFieldConfig = {
8613
8610
  numDigits: "9",
8614
8611
  minLetters: "3",
8615
8612
  maxLetters: "4",
8616
- example: "CHE123456789TVA"
8613
+ example: "CHE-123.456.789 TVA"
8617
8614
  }
8618
8615
  }
8619
8616
  },
@@ -8687,7 +8684,7 @@ const defaultFieldConfig = {
8687
8684
  };
8688
8685
  const inferTaxIdNumberType = (taxId2, country2) => {
8689
8686
  const optionsForCountry = taxIdNumberOptions[country2];
8690
- const metadataFn = defaultFieldConfig[country2] ?? defaultFieldConfig$1[country2];
8687
+ const metadataFn = defaultFieldConfig$1[country2] ?? defaultFieldConfig$2[country2];
8691
8688
  if (!optionsForCountry || !metadataFn || typeof metadataFn !== "function")
8692
8689
  return void 0;
8693
8690
  for (const option of optionsForCountry) {
@@ -8743,11 +8740,11 @@ function TaxId(props) {
8743
8740
  fieldValidationErrors,
8744
8741
  dataStoreId,
8745
8742
  taxIdNumberType,
8746
- fieldConfig = defaultFieldConfig$1
8743
+ fieldConfig = defaultFieldConfig$2
8747
8744
  } = props;
8748
8745
  const metadata = resolveFieldMetadata(fieldConfig[country2], {
8749
8746
  taxIdNumberType
8750
- }, defaultFieldMetadata$1);
8747
+ }, defaultFieldMetadata$2);
8751
8748
  const mergedProps = mergeFieldMetadataIntoProps("taxId", metadata, props);
8752
8749
  const {
8753
8750
  i18n
@@ -8862,12 +8859,12 @@ function VatNumber(props) {
8862
8859
  country: country2,
8863
8860
  fieldValidationErrors,
8864
8861
  dataStoreId,
8865
- fieldConfig = defaultFieldConfig,
8862
+ fieldConfig = defaultFieldConfig$1,
8866
8863
  vatNumberType
8867
8864
  } = props;
8868
8865
  const metadata = resolveFieldMetadata(fieldConfig[country2], {
8869
8866
  vatNumberType
8870
- }, defaultFieldMetadata);
8867
+ }, defaultFieldMetadata$1);
8871
8868
  const mergedProps = mergeFieldMetadataIntoProps("vatNumber", metadata, props);
8872
8869
  const {
8873
8870
  i18n
@@ -8949,7 +8946,7 @@ function VatNumber(props) {
8949
8946
  }), data.exemptedFromVat ? jsx(Field, {
8950
8947
  name: "vatAbsenceReason",
8951
8948
  classNameModifiers: ["tax-id-absence-reason"],
8952
- label: formUtils.getLabel("vatAbsenceReason", "vatNumberAbsenceReason"),
8949
+ label: formUtils.getLabel("vatAbsenceReason", "vatAbsenceReason"),
8953
8950
  errorMessage: formUtils.getErrorMessage("vatAbsenceReason", errors, fieldProblems),
8954
8951
  isValid: valid.vatAbsenceReason,
8955
8952
  children: (childProps) => jsx(Select, {
@@ -8961,7 +8958,7 @@ function VatNumber(props) {
8961
8958
  id: reason,
8962
8959
  name: i18n.get(reason)
8963
8960
  })),
8964
- placeholder: i18n.get("vatNumberAbsenceReason")
8961
+ placeholder: i18n.get("vatAbsenceReason")
8965
8962
  })
8966
8963
  }) : null]
8967
8964
  });
@@ -9354,6 +9351,9 @@ const companySearchBase = {
9354
9351
  },
9355
9352
  dateOfIncorporation: {
9356
9353
  rule: "countryRequiresDateOfIncorporationForCompanies"
9354
+ },
9355
+ registrationNumber: {
9356
+ rule: "countryRequiresRegistrationNumberForCompanies"
9357
9357
  }
9358
9358
  };
9359
9359
  const taxIdBase$1 = {
@@ -9469,10 +9469,7 @@ const companySearchFieldsPerScenario = {
9469
9469
  }
9470
9470
  },
9471
9471
  L1: {
9472
- ...companySearchBase,
9473
- taxInformation: {
9474
- rule: "countryRequiresTaxInformationForSearch"
9475
- }
9472
+ ...companySearchBase
9476
9473
  },
9477
9474
  L: {
9478
9475
  ...companySearchBase,
@@ -9501,9 +9498,6 @@ const countryConfig$4 = {
9501
9498
  },
9502
9499
  legalEntityType: {
9503
9500
  label: "companyType"
9504
- },
9505
- taxInformation: {
9506
- label: "australianBusinessNumberAbn"
9507
9501
  }
9508
9502
  },
9509
9503
  [CountryCodes.Austria]: {
@@ -9511,13 +9505,10 @@ const countryConfig$4 = {
9511
9505
  label: "vatNumberExempted"
9512
9506
  },
9513
9507
  vatAbsenceReason: {
9514
- label: "vatNumberAbsenceReason"
9508
+ label: "vatAbsenceReason"
9515
9509
  },
9516
9510
  exemptedFromRegistrationNumber: {
9517
9511
  label: "doNotHaveFirmenbuchnummer"
9518
- },
9519
- exemptedFromBusinessRegistrationNumber: {
9520
- label: "doNotHaveFirmenbuchnummer"
9521
9512
  }
9522
9513
  },
9523
9514
  [CountryCodes.Belgium]: {
@@ -9525,7 +9516,7 @@ const countryConfig$4 = {
9525
9516
  label: "vatNumberExempted"
9526
9517
  },
9527
9518
  vatAbsenceReason: {
9528
- label: "vatNumberAbsenceReason"
9519
+ label: "vatAbsenceReason"
9529
9520
  }
9530
9521
  },
9531
9522
  [CountryCodes.Brazil]: {},
@@ -9541,14 +9532,8 @@ const countryConfig$4 = {
9541
9532
  exemptedFromRegistrationNumber: {
9542
9533
  label: "doNotHaveBusinessIncorporationNumber"
9543
9534
  },
9544
- exemptedFromBusinessRegistrationNumber: {
9545
- label: "doNotHaveBusinessIncorporationNumber"
9546
- },
9547
9535
  exemptedFromTax: {
9548
9536
  label: "doNotHaveBusinessNumber"
9549
- },
9550
- taxInformation: {
9551
- label: "businessNumber"
9552
9537
  }
9553
9538
  },
9554
9539
  [CountryCodes.Croatia]: {
@@ -9563,7 +9548,7 @@ const countryConfig$4 = {
9563
9548
  },
9564
9549
  [CountryCodes.CzechRepublic]: {
9565
9550
  vatAbsenceReason: {
9566
- label: "vatNumberAbsenceReason"
9551
+ label: "vatAbsenceReason"
9567
9552
  },
9568
9553
  exemptedFromVat: {
9569
9554
  label: "vatNumberExempted"
@@ -9583,9 +9568,6 @@ const countryConfig$4 = {
9583
9568
  exemptedFromRegistrationNumber: {
9584
9569
  label: "doNotHaveYTunnus"
9585
9570
  },
9586
- exemptedFromBusinessRegistrationNumber: {
9587
- label: "doNotHaveYTunnus"
9588
- },
9589
9571
  exemptedFromVat: {
9590
9572
  label: "vatNumberExempted"
9591
9573
  }
@@ -9595,14 +9577,11 @@ const countryConfig$4 = {
9595
9577
  exemptedFromRegistrationNumber: {
9596
9578
  label: "doNotHaveHandelsregisternummer"
9597
9579
  },
9598
- exemptedFromBusinessRegistrationNumber: {
9599
- label: "doNotHaveHandelsregisternummer"
9600
- },
9601
9580
  exemptedFromVat: {
9602
9581
  label: "vatNumberExempted"
9603
9582
  },
9604
9583
  vatAbsenceReason: {
9605
- label: "vatNumberAbsenceReason"
9584
+ label: "vatAbsenceReason"
9606
9585
  }
9607
9586
  },
9608
9587
  [CountryCodes.Gibraltar]: {},
@@ -9642,7 +9621,7 @@ const countryConfig$4 = {
9642
9621
  label: "vatNumberExempted"
9643
9622
  },
9644
9623
  vatAbsenceReason: {
9645
- label: "vatNumberAbsenceReason"
9624
+ label: "vatAbsenceReason"
9646
9625
  }
9647
9626
  },
9648
9627
  [CountryCodes.Japan]: {
@@ -9665,9 +9644,6 @@ const countryConfig$4 = {
9665
9644
  exemptedFromRegistrationNumber: {
9666
9645
  label: "doNotHaveLtRegistrationNumber"
9667
9646
  },
9668
- exemptedFromBusinessRegistrationNumber: {
9669
- label: "doNotHaveLtRegistrationNumber"
9670
- },
9671
9647
  exemptedFromVat: {
9672
9648
  label: "vatNumberExempted"
9673
9649
  }
@@ -9676,9 +9652,6 @@ const countryConfig$4 = {
9676
9652
  exemptedFromRegistrationNumber: {
9677
9653
  label: "doNotHaveLuRegistrationNumber"
9678
9654
  },
9679
- exemptedFromBusinessRegistrationNumber: {
9680
- label: "doNotHaveLuRegistrationNumber"
9681
- },
9682
9655
  exemptedFromVat: {
9683
9656
  label: "vatNumberExempted"
9684
9657
  }
@@ -9703,7 +9676,7 @@ const countryConfig$4 = {
9703
9676
  label: "vatNumberExempted"
9704
9677
  },
9705
9678
  vatAbsenceReason: {
9706
- label: "vatNumberAbsenceReason"
9679
+ label: "vatAbsenceReason"
9707
9680
  }
9708
9681
  },
9709
9682
  [CountryCodes.NewZealand]: {
@@ -9722,21 +9695,18 @@ const countryConfig$4 = {
9722
9695
  label: "vatNumberExempted"
9723
9696
  },
9724
9697
  vatAbsenceReason: {
9725
- label: "vatNumberAbsenceReason"
9698
+ label: "vatAbsenceReason"
9726
9699
  }
9727
9700
  },
9728
9701
  [CountryCodes.Poland]: {
9729
9702
  exemptedFromRegistrationNumber: {
9730
9703
  label: "doNotHaveRegonKrsNumber"
9731
9704
  },
9732
- exemptedFromBusinessRegistrationNumber: {
9733
- label: "doNotHaveRegonKrsNumber"
9734
- },
9735
9705
  exemptedFromVat: {
9736
9706
  label: "vatNumberExempted"
9737
9707
  },
9738
9708
  vatAbsenceReason: {
9739
- label: "vatNumberAbsenceReason"
9709
+ label: "vatAbsenceReason"
9740
9710
  }
9741
9711
  },
9742
9712
  [CountryCodes.Portugal]: {
@@ -9744,7 +9714,7 @@ const countryConfig$4 = {
9744
9714
  label: "vatNumberExempted"
9745
9715
  },
9746
9716
  vatAbsenceReason: {
9747
- label: "vatNumberAbsenceReason"
9717
+ label: "vatAbsenceReason"
9748
9718
  }
9749
9719
  },
9750
9720
  [CountryCodes.PuertoRico]: {},
@@ -9768,7 +9738,7 @@ const countryConfig$4 = {
9768
9738
  label: "vatNumberExempted"
9769
9739
  },
9770
9740
  vatAbsenceReason: {
9771
- label: "vatNumberAbsenceReason"
9741
+ label: "vatAbsenceReason"
9772
9742
  }
9773
9743
  },
9774
9744
  [CountryCodes.Singapore]: {
@@ -9789,23 +9759,17 @@ const countryConfig$4 = {
9789
9759
  exemptedFromRegistrationNumber: {
9790
9760
  label: "doNotHaveOrganisationsnummer"
9791
9761
  },
9792
- exemptedFromBusinessRegistrationNumber: {
9793
- label: "doNotHaveOrganisationsnummer"
9794
- },
9795
9762
  exemptedFromVat: {
9796
9763
  label: "vatNumberExempted"
9797
9764
  },
9798
9765
  vatAbsenceReason: {
9799
- label: "vatNumberAbsenceReason"
9766
+ label: "vatAbsenceReason"
9800
9767
  }
9801
9768
  },
9802
9769
  [CountryCodes.Switzerland]: {
9803
9770
  exemptedFromRegistrationNumber: {
9804
9771
  label: "doNotHaveChRegistrationNumber"
9805
9772
  },
9806
- exemptedFromBusinessRegistrationNumber: {
9807
- label: "doNotHaveChRegistrationNumber"
9808
- },
9809
9773
  exemptedFromVat: {
9810
9774
  label: "vatNumberExempted"
9811
9775
  }
@@ -9831,14 +9795,6 @@ const countryConfig$4 = {
9831
9795
  label: "employerIdentificationNumber"
9832
9796
  },
9833
9797
  /* CompanySearchComponent specific fields */
9834
- taxInformation: {
9835
- label: "taxInformationNumber__US",
9836
- helperText: "taxInformationNumber__helperText__US"
9837
- },
9838
- businessRegistrationNumber: {
9839
- label: "businessRegistrationNumber",
9840
- placeholder: "businessRegistrationNumber__placeholder__US"
9841
- },
9842
9798
  stockExchangeMIC: {
9843
9799
  label: "stockExchangeMIC__US",
9844
9800
  placeholder: "stockExchangeMIC__placeholder__US"
@@ -12612,13 +12568,13 @@ const rules$2 = ({
12612
12568
  },
12613
12569
  stockExchangeMICIfTypePublic: () => {
12614
12570
  var _a, _b;
12615
- 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) {
12571
+ 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)) {
12616
12572
  return "REQUIRED";
12617
12573
  }
12618
12574
  },
12619
12575
  stockISINIfTypePublic: () => {
12620
12576
  var _a, _b;
12621
- 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) {
12577
+ 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)) {
12622
12578
  return "REQUIRED";
12623
12579
  }
12624
12580
  },
@@ -12628,7 +12584,7 @@ const rules$2 = ({
12628
12584
  }
12629
12585
  },
12630
12586
  countryUsesTaxId: () => {
12631
- 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))) {
12587
+ 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))) {
12632
12588
  return "REQUIRED";
12633
12589
  }
12634
12590
  },
@@ -12639,7 +12595,7 @@ const rules$2 = ({
12639
12595
  },
12640
12596
  companyRegistrationNumberExemptionAllowed: () => {
12641
12597
  var _a, _b;
12642
- 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);
12598
+ const companyType2 = "companyType" in data && (((_a = data.companyType) == null ? void 0 : _a.entityType) || ((_b = data.companyStructure) == null ? void 0 : _b.entityType));
12643
12599
  if (country2 === "DE" && (companyType2 === CompanyTypesValue.GOVERNMENTAL_ORGANIZATION || companyType2 === CompanyTypesValue.NON_PROFIT_OR_CHARITABLE)) {
12644
12600
  return "REQUIRED";
12645
12601
  }
@@ -13002,7 +12958,7 @@ const companySearchBaseMapping = {
13002
12958
  "companyRegistrationAddress.operationalAddress.otherAddressInformation": "organization.principalPlaceOfBusiness.street2",
13003
12959
  "companyStructure.entityType": "organization.type",
13004
12960
  "companyOtherDetails.tradingName": "organization.doingBusinessAs",
13005
- "companyOtherDetails.businessRegistrationNumber": "organization.registrationNumber",
12961
+ "companyOtherDetails.registrationNumber": "organization.registrationNumber",
13006
12962
  "companyOtherDetails.taxInformation": "organization.taxInformation",
13007
12963
  "companyOtherDetails.vatNumber": "organization.vatNumber",
13008
12964
  "companyOtherDetails.vatAbsenceReason": "organization.vatAbsenceReason",
@@ -21390,7 +21346,7 @@ const trackNavigation = ({
21390
21346
  }
21391
21347
  });
21392
21348
  };
21393
- const getOpeningStep$1 = (forms2, remediationActions) => {
21349
+ const getOpeningStep = (forms2, remediationActions) => {
21394
21350
  var _a;
21395
21351
  if (remediationActions && Object.keys(remediationActions).length > 0) {
21396
21352
  const allRemediationActions = Object.values(remediationActions).flat().filter((rem) => {
@@ -21438,7 +21394,7 @@ const useFormComposer = ({
21438
21394
  useEffect(() => {
21439
21395
  if (hasAlreadyNavigatedForm)
21440
21396
  return;
21441
- const openingStep = getOpeningStep$1(forms2, problems == null ? void 0 : problems.remediationActions);
21397
+ const openingStep = getOpeningStep(forms2, problems == null ? void 0 : problems.remediationActions);
21442
21398
  if (activeForm !== openingStep) {
21443
21399
  setActiveForm(openingStep);
21444
21400
  }
@@ -23010,7 +22966,7 @@ const getTargetLegalEntityType = (businessType, legalArrangement, trusteeType, c
23010
22966
  }
23011
22967
  return currentLegalEntityType;
23012
22968
  };
23013
- const FormComposer = "";
22969
+ const FormWrapper$1 = "";
23014
22970
  const logger$c = createLogger("FormRouterContextProvider");
23015
22971
  function FormRouterContextProvider({
23016
22972
  children,
@@ -23265,16 +23221,16 @@ const FormWrapper = ({
23265
23221
  })
23266
23222
  });
23267
23223
  };
23268
- const parseConfiguration$3 = ({
23224
+ const parseConfiguration$5 = ({
23269
23225
  country: country2,
23270
23226
  matchingScenario
23271
23227
  }) => parseCompanyScenarios(matchingScenario == null ? void 0 : matchingScenario[LegalEntityType.ORGANIZATION], country2);
23272
- const canSubmit$1 = (data) => mandatoryApiFields.ORGANIZATION.every((detail) => {
23228
+ const canSubmit$2 = (data) => mandatoryApiFields.ORGANIZATION.every((detail) => {
23273
23229
  const value = getProp(data, detail);
23274
23230
  return !isEmpty(value);
23275
23231
  });
23276
- const isDocumentsRequired$1 = (forms2) => forms2.some((form) => [companyForms.companyRegistrationDocument.formId, companyForms.companyTaxDocument.formId].includes(form.formId));
23277
- const formatFileSummaryData = (companyRegistrationDocument2, companyTaxDocument) => {
23232
+ const isDocumentsRequired$2 = (forms2) => forms2.some((form) => [companyForms.companyRegistrationDocument.formId, companyForms.companyTaxDocument.formId].includes(form.formId));
23233
+ const formatFileSummaryData$1 = (companyRegistrationDocument2, companyTaxDocument) => {
23278
23234
  var _a, _b;
23279
23235
  const registrationDocument2 = (_a = companyRegistrationDocument2 == null ? void 0 : companyRegistrationDocument2.registrationDocument) == null ? void 0 : _a[0];
23280
23236
  const taxDocument2 = (_b = companyTaxDocument == null ? void 0 : companyTaxDocument.taxDocument) == null ? void 0 : _b[0];
@@ -23362,7 +23318,7 @@ function CompanyDropinComponent({
23362
23318
  fieldConfigurations,
23363
23319
  requiredFields
23364
23320
  } = useScenarioConfiguration({
23365
- parseConfiguration: parseConfiguration$3,
23321
+ parseConfiguration: parseConfiguration$5,
23366
23322
  getConfigurationData,
23367
23323
  setLoadingStatus,
23368
23324
  country: country2
@@ -23398,7 +23354,7 @@ function CompanyDropinComponent({
23398
23354
  legalEntity,
23399
23355
  dataSubmitted
23400
23356
  }) => {
23401
- if (!isDocumentsRequired$1(forms22))
23357
+ if (!isDocumentsRequired$2(forms22))
23402
23358
  return;
23403
23359
  const formattedDocument = await mapCompanyDocumentToApiDocument(dataSubmitted, legalEntity.id);
23404
23360
  if (formattedDocument) {
@@ -23566,16 +23522,16 @@ function CompanyDropinComponent({
23566
23522
  summaryData.companyRegistrationAddress.operationalAddress = mapAddressLabels(summaryData == null ? void 0 : summaryData.companyRegistrationAddress.operationalAddress, datasetUtils);
23567
23523
  }
23568
23524
  if ((_h = summaryData.companyRegistrationDetails) == null ? void 0 : _h.vatAbsenceReason) {
23569
- const vatAbsenceReason = vatAbsenceReasons.find((absenceReason) => absenceReason === summaryData.companyRegistrationDetails.vatAbsenceReason);
23570
- if (vatAbsenceReason) {
23571
- summaryData.companyRegistrationDetails.vatAbsenceReason = i18n.get(vatAbsenceReason);
23525
+ const vatAbsenceReason2 = vatAbsenceReasons.find((absenceReason) => absenceReason === summaryData.companyRegistrationDetails.vatAbsenceReason);
23526
+ if (vatAbsenceReason2) {
23527
+ summaryData.companyRegistrationDetails.vatAbsenceReason = i18n.get(vatAbsenceReason2);
23572
23528
  }
23573
23529
  }
23574
- if (isDocumentsRequired$1(forms22)) {
23530
+ if (isDocumentsRequired$2(forms22)) {
23575
23531
  companyDocumentForms.forEach((formId) => delete summaryData[formId]);
23576
23532
  summaryData = {
23577
23533
  ...summaryData,
23578
- ...formatFileSummaryData(data2.companyRegistrationDocument, data2.companyTaxDocument)
23534
+ ...formatFileSummaryData$1(data2.companyRegistrationDocument, data2.companyTaxDocument)
23579
23535
  };
23580
23536
  }
23581
23537
  return summaryData;
@@ -23611,7 +23567,7 @@ function CompanyDropinComponent({
23611
23567
  baseTrackingPayload,
23612
23568
  onSubmit,
23613
23569
  problems,
23614
- canSubmit: canSubmit$1(data) && hasDataChanged(dataFromResponse, data),
23570
+ canSubmit: canSubmit$2(data) && hasDataChanged(dataFromResponse, data),
23615
23571
  summary: {
23616
23572
  data: formatDataForSummary2(data, forms2),
23617
23573
  omittedKeys: ["operationalAddressIsSame"]
@@ -23645,6 +23601,7 @@ function useCompanySearch({
23645
23601
  taxIdentificationNumber: taxIdentificationNumber2,
23646
23602
  canVerify,
23647
23603
  limit = 15,
23604
+ setKompanyAddress,
23648
23605
  handleChangeFor,
23649
23606
  handleCompanyIndexSearch,
23650
23607
  handleCompanyDeepSearch,
@@ -23700,7 +23657,7 @@ function useCompanySearch({
23700
23657
  } finally {
23701
23658
  setStatus((prevStatus) => prevStatus !== "error" ? "loaded" : prevStatus);
23702
23659
  }
23703
- }, 500), []);
23660
+ }, 700), []);
23704
23661
  const retrySearch = useCallback(async () => {
23705
23662
  if (!legalCompanyName2 || !country2 || !stateOrProvince2) {
23706
23663
  return setStatus("idle");
@@ -23784,17 +23741,17 @@ function useCompanySearch({
23784
23741
  setStatus("loading");
23785
23742
  setSelectedCompanyId(void 0);
23786
23743
  setVerifiedCompany(void 0);
23744
+ setKompanyAddress(void 0);
23787
23745
  setCompaniesList([]);
23788
23746
  if (defaultData) {
23789
- entriesOf(defaultData).forEach(([field, value]) => {
23790
- handleChangeFor(field)(value);
23791
- });
23747
+ handleChangeFor("legalCompanyName")(defaultData.legalCompanyName);
23792
23748
  }
23793
- }, [defaultData, handleChangeFor]);
23749
+ }, [defaultData, handleChangeFor, setKompanyAddress]);
23794
23750
  useEffect(() => {
23795
23751
  var _a;
23796
23752
  setError(void 0);
23797
- if (!legalCompanyName2 || !country2 || !stateOrProvince2 || !taxIdentificationNumber2 || !canVerify) {
23753
+ const isMinLength = legalCompanyName2 && legalCompanyName2.split("").length > 3;
23754
+ if (!legalCompanyName2 || !country2 || !stateOrProvince2 || !taxIdentificationNumber2 || !canVerify || !isMinLength) {
23798
23755
  return setStatus("idle");
23799
23756
  }
23800
23757
  if (!verifiedCompany) {
@@ -23829,6 +23786,15 @@ function useCompanySearch({
23829
23786
  reset
23830
23787
  };
23831
23788
  }
23789
+ const mapKompanyOrganizationTypeToCompanyType = (organizationType) => {
23790
+ const organizationTypeValue = organizationType == null ? void 0 : organizationType.toLowerCase();
23791
+ switch (organizationTypeValue) {
23792
+ case "business":
23793
+ return CompanyTypesValue.PRIVATE_COMPANY;
23794
+ default:
23795
+ return void 0;
23796
+ }
23797
+ };
23832
23798
  const mapCompanyDataResponseToFormSchema = (company2) => ({
23833
23799
  companyBasics: {
23834
23800
  country: company2.country,
@@ -23843,8 +23809,11 @@ const mapCompanyDataResponseToFormSchema = (company2) => ({
23843
23809
  postalCode: company2.zipcode
23844
23810
  }
23845
23811
  },
23812
+ companyStructure: {
23813
+ entityType: mapKompanyOrganizationTypeToCompanyType(company2.organizationType)
23814
+ },
23846
23815
  companyOtherDetails: {
23847
- businessRegistrationNumber: company2.registrationNumber
23816
+ registrationNumber: company2.registrationNumber
23848
23817
  }
23849
23818
  });
23850
23819
  const CompanyLookupResultsHeader = ({
@@ -23966,13 +23935,17 @@ const LookupResult = ({
23966
23935
  return "verified";
23967
23936
  }
23968
23937
  }, [status, isError]);
23969
- const selectAndVerify = (companyTin, company2) => {
23970
- if (ref.current) {
23971
- ref.current.scrollIntoView({
23972
- behavior: "smooth"
23973
- });
23938
+ const selectAndVerify = async (companyTin, company2) => {
23939
+ try {
23940
+ await onSelect(companyTin, company2);
23941
+ } finally {
23942
+ if (ref.current) {
23943
+ ref.current.scrollIntoView({
23944
+ behavior: "smooth",
23945
+ block: "center"
23946
+ });
23947
+ }
23974
23948
  }
23975
- return onSelect(companyTin, company2);
23976
23949
  };
23977
23950
  if (isSelected && verifiedCompany) {
23978
23951
  return jsxs("div", {
@@ -24042,9 +24015,17 @@ const CompanyLookupResultsList = ({
24042
24015
  }
24043
24016
  return "adyen-company-lookup-results-list__result-option";
24044
24017
  };
24018
+ const resultsList = useMemo(() => {
24019
+ if (verifiedCompany) {
24020
+ const filtered = results.filter((option) => option.id !== verifiedCompany.id);
24021
+ const verified2 = results.find((option) => option.id === verifiedCompany.id);
24022
+ return verified2 ? [verified2, ...filtered] : results;
24023
+ }
24024
+ return results;
24025
+ }, [verifiedCompany, results]);
24045
24026
  return jsx("div", {
24046
24027
  className: "adyen-company-lookup-results-list",
24047
- children: results.map((option) => jsx("div", {
24028
+ children: resultsList.map((option) => jsx("div", {
24048
24029
  children: jsx(LookupResult, {
24049
24030
  classes: optionClasses(option),
24050
24031
  option,
@@ -24086,6 +24067,7 @@ function CompanyLookup({
24086
24067
  taxInformationNumber: taxInformationNumber2,
24087
24068
  setLoading,
24088
24069
  setKompanyAddress,
24070
+ setKompanyVerifiedData,
24089
24071
  handleChangeFor,
24090
24072
  handleCompanyIndexSearch,
24091
24073
  handleCompanyDeepSearch,
@@ -24113,6 +24095,7 @@ function CompanyLookup({
24113
24095
  stateOrProvince: stateOrProvince2,
24114
24096
  taxIdentificationNumber: taxInformationNumber2,
24115
24097
  canVerify,
24098
+ setKompanyAddress,
24116
24099
  handleChangeFor,
24117
24100
  handleCompanyIndexSearch,
24118
24101
  handleCompanyDeepSearch,
@@ -24126,11 +24109,14 @@ function CompanyLookup({
24126
24109
  const companyLookupClasses = status === "idle" || !canVerify ? "adyen-kyc-company-lookup adyen-kyc-company-lookup--hidden" : "adyen-kyc-company-lookup";
24127
24110
  const mappedData = useMemo$1(() => {
24128
24111
  if (verifiedCompany) {
24112
+ const verifiedData = mapCompanyDataResponseToFormSchema(verifiedCompany);
24129
24113
  setKompanyAddress(verifiedCompany.address);
24130
- return mapCompanyDataResponseToFormSchema(verifiedCompany);
24114
+ setKompanyVerifiedData(verifiedData);
24115
+ return verifiedData;
24131
24116
  }
24117
+ setKompanyVerifiedData(void 0);
24132
24118
  setKompanyAddress(void 0);
24133
- }, [setKompanyAddress, verifiedCompany]);
24119
+ }, [setKompanyAddress, setKompanyVerifiedData, verifiedCompany]);
24134
24120
  useEffect$1(() => {
24135
24121
  if (mappedData == null ? void 0 : mappedData.companyBasics) {
24136
24122
  entriesOf(mappedData.companyBasics).forEach(([field, data]) => {
@@ -24166,13 +24152,36 @@ function CompanyLookup({
24166
24152
  });
24167
24153
  }
24168
24154
  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);
24155
+ const CountryFieldValidation = () => ({
24156
+ country: {
24157
+ modes: ["blur"],
24158
+ validate: (country2) => !isEmpty(country2),
24159
+ errorMessage: "fieldIsRequired"
24160
+ }
24161
+ });
24162
+ const LegalCompanyNameFieldValidation = () => ({
24163
+ legalCompanyName: {
24164
+ modes: ["blur"],
24165
+ validate: (legalCompanyName2) => !isEmpty(legalCompanyName2),
24166
+ errorMessage: "fieldIsRequired"
24167
+ }
24168
+ });
24169
+ const StateFieldValidation = () => ({
24170
+ stateOrProvince: {
24171
+ modes: ["blur"],
24172
+ validate: (stateOrProvince2) => !isEmpty(stateOrProvince2),
24173
+ errorMessage: "fieldIsRequired"
24174
+ }
24175
+ });
24169
24176
  const TAX_INFORMATION_FIELD = ["taxInformation", "exemptedFromTax", "isUen"];
24170
24177
  function TaxInformationField({
24171
24178
  data,
24172
24179
  valid,
24173
24180
  errors,
24174
24181
  labels: labels2,
24175
- helperText,
24182
+ mask,
24183
+ guidanceText,
24184
+ placeholders,
24176
24185
  readonly,
24177
24186
  handleChangeFor,
24178
24187
  country: country2,
@@ -24182,11 +24191,7 @@ function TaxInformationField({
24182
24191
  var _a;
24183
24192
  return (_a = data == null ? void 0 : data.taxInformation) == null ? void 0 : _a.find((taxInfo) => taxInfo.country === country2);
24184
24193
  }, [data, country2]);
24185
- const handleTaxInformationInput = (e) => {
24186
- var _a;
24187
- const {
24188
- value
24189
- } = e.target;
24194
+ const handleTaxInformationInput = (value) => {
24190
24195
  if (!data.taxInformation) {
24191
24196
  const updatedTaxInformation2 = [{
24192
24197
  country: country2,
@@ -24195,7 +24200,12 @@ function TaxInformationField({
24195
24200
  }];
24196
24201
  return handleChangeFor("taxInformation", "input")(updatedTaxInformation2);
24197
24202
  }
24198
- const updatedTaxInformation = (_a = data.taxInformation) == null ? void 0 : _a.map((taxInfo) => {
24203
+ const taxInformation = currentCountryTaxInformation ? data.taxInformation : [...data.taxInformation, {
24204
+ country: country2,
24205
+ number: value,
24206
+ type: countryToTaxInfoTypeMap[country2]
24207
+ }];
24208
+ const updatedTaxInformation = taxInformation.map((taxInfo) => {
24199
24209
  if (taxInfo.country !== country2)
24200
24210
  return taxInfo;
24201
24211
  return {
@@ -24207,7 +24217,6 @@ function TaxInformationField({
24207
24217
  return handleChangeFor("taxInformation", "input")(updatedTaxInformation);
24208
24218
  };
24209
24219
  const handleTaxInformationBlur = (e) => {
24210
- var _a;
24211
24220
  const {
24212
24221
  value
24213
24222
  } = e.target;
@@ -24219,7 +24228,12 @@ function TaxInformationField({
24219
24228
  }];
24220
24229
  return handleChangeFor("taxInformation", "blur")(updatedTaxInformation2);
24221
24230
  }
24222
- const updatedTaxInformation = (_a = data.taxInformation) == null ? void 0 : _a.map((taxInfo) => {
24231
+ const taxInformation = currentCountryTaxInformation ? data.taxInformation : [...data.taxInformation, {
24232
+ country: country2,
24233
+ number: value,
24234
+ type: countryToTaxInfoTypeMap[country2]
24235
+ }];
24236
+ const updatedTaxInformation = taxInformation.map((taxInfo) => {
24223
24237
  if (taxInfo.country !== country2)
24224
24238
  return taxInfo;
24225
24239
  return {
@@ -24231,23 +24245,22 @@ function TaxInformationField({
24231
24245
  return handleChangeFor("taxInformation", "blur")(updatedTaxInformation);
24232
24246
  };
24233
24247
  return jsxs(Fragment, {
24234
- children: [jsx(Field, {
24235
- name: "taxInformationField",
24236
- label: labels2.taxInformation,
24237
- helper: helperText == null ? void 0 : helperText.taxInformation,
24248
+ children: [jsx(MaskedInputText, {
24249
+ name: "taxInformationNumber",
24250
+ label: labels2.taxInformation ?? "",
24251
+ formatGuidance: (guidanceText == null ? void 0 : guidanceText.taxInformation) ?? "",
24252
+ value: (currentCountryTaxInformation == null ? void 0 : currentCountryTaxInformation.number) ?? "",
24238
24253
  errorMessage: errors.taxInformation,
24239
- isValid: valid.taxInformation,
24240
- children: (childProps) => jsx(InputText, {
24241
- ...childProps,
24242
- "aria-required": true,
24243
- "aria-label": labels2.taxInformation,
24244
- "aria-invalid": !valid.taxInformation,
24245
- name: "taxInformationNumber",
24246
- value: currentCountryTaxInformation == null ? void 0 : currentCountryTaxInformation.number,
24247
- onInput: handleTaxInformationInput,
24248
- onBlur: handleTaxInformationBlur,
24249
- readonly
24250
- })
24254
+ placeholder: placeholders == null ? void 0 : placeholders.taxInformation,
24255
+ isValid: Boolean(valid.taxInformation),
24256
+ "aria-required": true,
24257
+ "aria-label": labels2.taxInformation,
24258
+ "aria-invalid": !valid.taxInformation,
24259
+ onInput: handleTaxInformationInput,
24260
+ onBlur: handleTaxInformationBlur,
24261
+ disabled: data.exemptedFromTax,
24262
+ readonly,
24263
+ ...mask
24251
24264
  }), canExempt && jsx(Checkbox, {
24252
24265
  "aria-required": false,
24253
24266
  "aria-label": labels2.exemptedFromTax,
@@ -24261,116 +24274,37 @@ function TaxInformationField({
24261
24274
  })]
24262
24275
  });
24263
24276
  }
24264
- const DateOfIncorporationFieldValidation = () => ({
24265
- dateOfIncorporation: [{
24266
- modes: ["blur"],
24267
- validate: (dateOfIncorporation2) => !isEmpty(dateOfIncorporation2),
24268
- errorMessage: "fieldIsRequired"
24269
- }, {
24270
- modes: ["blur"],
24271
- validate: (dateOfIncorporation2) => dateOfIncorporation2 ? new Date(dateOfIncorporation2) < /* @__PURE__ */ new Date() : false,
24272
- errorMessage: "invalidDateOfIncorporation"
24273
- }]
24274
- });
24275
- const StockExchangeMICFieldValidation = () => ({
24276
- stockExchangeMIC: [{
24277
- modes: ["blur"],
24278
- validate: (stockExchangeMIC2) => !isEmpty(stockExchangeMIC2),
24279
- errorMessage: "fieldIsRequired"
24280
- }]
24281
- });
24282
- const StockISINFieldValidation = () => ({
24283
- stockISIN: [{
24284
- modes: ["blur"],
24285
- validate: (stockISIN2) => !isEmpty(stockISIN2),
24286
- errorMessage: "fieldIsRequired"
24287
- }, {
24288
- modes: ["blur"],
24289
- validate: (input) => exactLength(input, 12),
24290
- errorMessage: "validationPleaseEnterAValidStockISIN"
24291
- }]
24292
- });
24293
- const TradingNameFieldValidation = () => ({
24294
- tradingName: [{
24295
- modes: ["blur"],
24296
- validate: (tradingName2) => !isEmpty(tradingName2),
24297
- errorMessage: "fieldIsRequired"
24298
- }]
24299
- });
24300
- const BusinessRegistrationNumberValidation = (country2, companyType2, registrationNumberType) => {
24301
- const metadata = resolveFieldMetadata(defaultFieldConfig$2[country2], {
24302
- companyType: companyType2,
24303
- registrationNumberType
24304
- }, defaultFieldMetadata$2);
24305
- return {
24306
- businessRegistrationNumber: metadata.validators
24307
- };
24308
- };
24309
- const TaxInformationFieldValidation = (country2, taxIdNumberType) => {
24310
- const metadata = resolveFieldMetadata(defaultFieldConfig$1[country2], {
24277
+ const defaultFieldMetadata = defaultFieldMetadata$2;
24278
+ const defaultFieldConfig = entriesOf(defaultFieldConfig$2).reduce((fieldConfig, [country2, countryEntry]) => ({
24279
+ ...fieldConfig,
24280
+ [country2]: ({
24311
24281
  taxIdNumberType
24312
- }, defaultFieldMetadata$1);
24313
- if (!metadata.validators)
24314
- return {};
24315
- const validators = Array.isArray(metadata.validators) ? metadata.validators : [metadata.validators];
24316
- return {
24317
- taxInformation: validators.map((validator) => ({
24318
- modes: ["blur"],
24319
- validate: (taxInfos) => (taxInfos == null ? void 0 : taxInfos.every((taxInfo) => validator.validate(taxInfo.number))) ?? false,
24320
- errorMessage: metadata.helperText
24321
- }))
24322
- };
24323
- };
24324
- const VatNumberFieldValidation = (country2, vatNumberType) => {
24325
- const metadata = resolveFieldMetadata(defaultFieldConfig[country2], {
24326
- vatNumberType
24327
- }, defaultFieldMetadata);
24328
- if (!metadata.validators)
24329
- return {};
24330
- const validators = Array.isArray(metadata.validators) ? metadata.validators : [metadata.validators];
24331
- return {
24332
- vatNumber: validators.map((validator) => ({
24282
+ }) => {
24283
+ const fieldMetadata = resolveFieldMetadata(countryEntry, {
24284
+ taxIdNumberType
24285
+ }, defaultFieldMetadata$2);
24286
+ const taxIdValidators = fieldMetadata.validators ? Array.isArray(fieldMetadata.validators) ? fieldMetadata.validators : [fieldMetadata.validators] : [];
24287
+ const mappedValidators = taxIdValidators.map((validator) => ({
24333
24288
  ...validator,
24334
- errorMessage: metadata.helperText
24335
- }))
24336
- };
24337
- };
24338
- const CompanyOtherDetailsValidationRules = (country2, companyType2) => ({
24339
- ...TradingNameFieldValidation(),
24340
- ...StockISINFieldValidation(),
24341
- ...StockExchangeMICFieldValidation(),
24342
- ...TaxInformationFieldValidation(country2),
24343
- ...DateOfIncorporationFieldValidation(),
24344
- ...BusinessRegistrationNumberValidation(country2, companyType2),
24345
- ...VatNumberFieldValidation(country2)
24346
- });
24347
- const CountryFieldValidation = () => ({
24348
- country: {
24349
- modes: ["blur"],
24350
- validate: (country2) => !isEmpty(country2),
24351
- errorMessage: "fieldIsRequired"
24352
- }
24353
- });
24354
- const LegalCompanyNameFieldValidation = () => ({
24355
- legalCompanyName: {
24356
- modes: ["blur"],
24357
- validate: (legalCompanyName2) => !isEmpty(legalCompanyName2),
24358
- errorMessage: "fieldIsRequired"
24359
- }
24360
- });
24361
- const StateFieldValidation = () => ({
24362
- stateOrProvince: {
24363
- modes: ["blur"],
24364
- validate: (stateOrProvince2) => !isEmpty(stateOrProvince2),
24365
- errorMessage: "fieldIsRequired"
24289
+ validate: (taxInformation) => {
24290
+ var _a;
24291
+ const taxIdNumber2 = (_a = taxInformation == null ? void 0 : taxInformation.find((taxId2) => country2 === taxId2.country)) == null ? void 0 : _a.number;
24292
+ return taxIdNumber2 ? validator.validate(taxIdNumber2) : false;
24293
+ },
24294
+ errorMessage: (taxInformation) => {
24295
+ var _a;
24296
+ const taxIdNumber2 = (_a = taxInformation == null ? void 0 : taxInformation.find((taxId2) => country2 === taxId2.country)) == null ? void 0 : _a.number;
24297
+ if (!taxIdNumber2)
24298
+ return void 0;
24299
+ return typeof validator.errorMessage === "function" ? validator.errorMessage(taxIdNumber2) : validator.errorMessage;
24300
+ }
24301
+ }));
24302
+ return {
24303
+ ...fieldMetadata,
24304
+ validators: mappedValidators
24305
+ };
24366
24306
  }
24367
- });
24368
- const CompanyBasicsValidationRules = (country2) => ({
24369
- ...LegalCompanyNameFieldValidation(),
24370
- ...CountryFieldValidation(),
24371
- ...StateFieldValidation(),
24372
- ...TaxInformationFieldValidation(country2)
24373
- });
24307
+ }), {});
24374
24308
  const COMPANY_BASICS_FORM_ID = "companyBasics";
24375
24309
  const companyBasicsFields = [...LEGAL_COMPANY_NAME_FIELD, ...COUNTRY_FIELD, ...STATE_FIELD, ...TAX_INFORMATION_FIELD];
24376
24310
  function CompanyBasics({
@@ -24393,8 +24327,11 @@ function CompanyBasics({
24393
24327
  handleGetCompanyDataset,
24394
24328
  handleRefreshCompanyDataset,
24395
24329
  handleVerifyTin,
24330
+ country: country2,
24331
+ isTopLevelEntity,
24396
24332
  kompanyAddress,
24397
- setKompanyAddress
24333
+ setKompanyAddress,
24334
+ setKompanyVerifiedData
24398
24335
  }) {
24399
24336
  var _a, _b;
24400
24337
  const {
@@ -24404,12 +24341,59 @@ function CompanyBasics({
24404
24341
  isSettingEnabled
24405
24342
  } = useSettingsContext();
24406
24343
  const {
24407
- sliceData,
24408
24344
  updateStateSlice
24409
24345
  } = useGlobalDataSlice(COMPANY_BASICS_FORM_ID);
24410
- const schema = (requiredFields == null ? void 0 : requiredFields.length) ? requiredFields : ["legalCompanyName", "country"];
24411
- const validationRules = CompanyBasicsValidationRules((sliceData == null ? void 0 : sliceData.country) ?? (data == null ? void 0 : data.country));
24412
24346
  const [loading2, setLoading] = useState$1(false);
24347
+ const allowedCountries = useAllowedCountries();
24348
+ const initialFormUtilsProps = useMemo$1(() => ({
24349
+ labels: labels2,
24350
+ placeholders,
24351
+ helperText,
24352
+ readOnly,
24353
+ requiredFields,
24354
+ readOnlyFields,
24355
+ optionalFields,
24356
+ maskedFields,
24357
+ shouldValidate
24358
+ }), [helperText, labels2, maskedFields, optionalFields, placeholders, readOnly, readOnlyFields, requiredFields, shouldValidate]);
24359
+ const mergedFieldProps = useMemo$1(() => {
24360
+ var _a2;
24361
+ return (_a2 = initialFormUtilsProps.requiredFields) == null ? void 0 : _a2.reduce((acc, field) => {
24362
+ switch (field) {
24363
+ case "legalCompanyName":
24364
+ return {
24365
+ ...acc,
24366
+ validators: {
24367
+ ...acc.validators,
24368
+ ...LegalCompanyNameFieldValidation()
24369
+ }
24370
+ };
24371
+ case "country":
24372
+ return {
24373
+ ...acc,
24374
+ validators: {
24375
+ ...acc.validators,
24376
+ ...CountryFieldValidation()
24377
+ }
24378
+ };
24379
+ case "stateOrProvince":
24380
+ return {
24381
+ ...acc,
24382
+ validators: {
24383
+ ...acc.validators,
24384
+ ...StateFieldValidation()
24385
+ }
24386
+ };
24387
+ case "taxInformation":
24388
+ return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig[country2], {
24389
+ taxIdNumberType: countryToTaxInfoTypeMap[country2]
24390
+ }, defaultFieldMetadata), acc);
24391
+ default:
24392
+ return acc;
24393
+ }
24394
+ }, initialFormUtilsProps);
24395
+ }, [country2, initialFormUtilsProps]);
24396
+ const schema = (requiredFields == null ? void 0 : requiredFields.length) ? requiredFields : ["legalCompanyName", "country"];
24413
24397
  const {
24414
24398
  schema: formSchema,
24415
24399
  data: formData,
@@ -24421,35 +24405,17 @@ function CompanyBasics({
24421
24405
  } = useForm({
24422
24406
  schema,
24423
24407
  defaultData: data,
24424
- rules: validationRules,
24408
+ rules: mergedFieldProps == null ? void 0 : mergedFieldProps.validators,
24409
+ optionalFields: mergedFieldProps == null ? void 0 : mergedFieldProps.optionalFields,
24410
+ maskedFields: mergedFieldProps == null ? void 0 : mergedFieldProps.maskedFields,
24425
24411
  fieldProblems: fieldValidationErrors,
24426
- optionalFields,
24427
- maskedFields,
24428
24412
  shouldValidate
24429
24413
  });
24430
24414
  const isAllowedEditPrefilledCountry = isSettingEnabled(SettingNames.AllowPrefilledCountryEdit);
24431
- const formUtils = formUtilities({
24432
- labels: labels2,
24433
- placeholders,
24434
- helperText,
24435
- readOnly,
24436
- requiredFields,
24437
- readOnlyFields,
24438
- optionalFields
24439
- }, i18n);
24415
+ const formUtils = formUtilities(mergedFieldProps ?? initialFormUtilsProps, i18n);
24440
24416
  const hasCompanySearchProvider = formData.country && COUNTRIES_WITH_IN_APP_SEARCH_COMPANY_VERIFICATION.includes(formData.country);
24441
24417
  const currentCountryTaxIdNumber = (_b = (_a = formData.taxInformation) == null ? void 0 : _a.find((taxInfo) => taxInfo.country === formData.country)) == null ? void 0 : _b.number;
24442
- const {
24443
- legalCompanyNameDisabled,
24444
- countryDisabled,
24445
- stateOrProvinceDisabled,
24446
- taxInformationDisabled
24447
- } = useMemo$1(() => ({
24448
- legalCompanyNameDisabled: formUtils.isReadOnly("legalCompanyName") || Boolean(kompanyAddress) || loading2,
24449
- countryDisabled: !isAllowedEditPrefilledCountry || formUtils.isReadOnly("country") || Boolean(kompanyAddress) || loading2,
24450
- stateOrProvinceDisabled: formUtils.isReadOnly("stateOrProvince") || Boolean(kompanyAddress) || loading2,
24451
- taxInformationDisabled: formUtils.isReadOnly("taxInformation") || Boolean(kompanyAddress) || loading2
24452
- }), [kompanyAddress, formUtils, isAllowedEditPrefilledCountry, loading2]);
24418
+ const disabled = (field) => formUtils.isReadOnly(field) || Boolean(kompanyAddress) || loading2;
24453
24419
  useEffect$1(() => {
24454
24420
  updateStateSlice({
24455
24421
  schema: formSchema,
@@ -24480,7 +24446,7 @@ function CompanyBasics({
24480
24446
  helperText: formUtils.getFieldHelperText(LEGAL_COMPANY_NAME_FIELD, {
24481
24447
  legalCompanyName: "legalCompanyName__helperText"
24482
24448
  }),
24483
- readonly: legalCompanyNameDisabled,
24449
+ readonly: disabled("legalCompanyName"),
24484
24450
  handleChangeFor
24485
24451
  })
24486
24452
  }), formUtils.isRequiredField("country") && jsx("div", {
@@ -24490,8 +24456,9 @@ function CompanyBasics({
24490
24456
  valid: formUtils.getFieldValid(formValid, COUNTRY_FIELD),
24491
24457
  errors: formUtils.getFieldErrors(formErrors, formFieldProblems, COUNTRY_FIELD),
24492
24458
  labels: formUtils.getFieldLabels(COUNTRY_FIELD),
24493
- readonly: countryDisabled,
24494
- handleChangeFor
24459
+ readonly: disabled("country") || !isAllowedEditPrefilledCountry,
24460
+ handleChangeFor,
24461
+ allowedCountries: isTopLevelEntity ? allowedCountries : void 0
24495
24462
  })
24496
24463
  }), formUtils.isRequiredField("stateOrProvince") && jsx("div", {
24497
24464
  className: "adyen-kyc-field-wrapper",
@@ -24500,7 +24467,7 @@ function CompanyBasics({
24500
24467
  valid: formUtils.getFieldValid(formValid, STATE_FIELD),
24501
24468
  errors: formUtils.getFieldErrors(formErrors, formFieldProblems, STATE_FIELD),
24502
24469
  labels: formUtils.getFieldLabels(STATE_FIELD),
24503
- readonly: stateOrProvinceDisabled,
24470
+ readonly: disabled("stateOrProvince"),
24504
24471
  handleChangeFor,
24505
24472
  selectedCountry: formData.country
24506
24473
  })
@@ -24511,11 +24478,14 @@ function CompanyBasics({
24511
24478
  valid: formUtils.getFieldValid(formValid, TAX_INFORMATION_FIELD),
24512
24479
  errors: formUtils.getFieldErrors(formErrors, formFieldProblems, TAX_INFORMATION_FIELD),
24513
24480
  labels: formUtils.getFieldLabels(TAX_INFORMATION_FIELD),
24514
- readonly: taxInformationDisabled,
24481
+ mask: formUtils.getMask("taxInformation"),
24482
+ helperText: formUtils.getFieldHelperText(TAX_INFORMATION_FIELD),
24483
+ guidanceText: formUtils.getFieldGuidanceText(TAX_INFORMATION_FIELD),
24484
+ readonly: disabled("taxInformation"),
24515
24485
  handleChangeFor,
24516
- country: formData.country,
24517
24486
  canExempt: formUtils.isRequiredField("exemptedFromTax"),
24518
- isUen: formUtils.isRequiredField("isUen")
24487
+ isUen: formUtils.isRequiredField("isUen"),
24488
+ country: formData.country
24519
24489
  })
24520
24490
  }), hasCompanySearchProvider && jsx(CompanyLookupComponent, {
24521
24491
  defaultData: data,
@@ -24527,6 +24497,7 @@ function CompanyBasics({
24527
24497
  handleChangeFor,
24528
24498
  setLoading,
24529
24499
  setKompanyAddress,
24500
+ setKompanyVerifiedData,
24530
24501
  handleCompanyIndexSearch,
24531
24502
  handleCompanyDeepSearch,
24532
24503
  handleGetCompanyDataset,
@@ -24538,53 +24509,51 @@ function CompanyBasics({
24538
24509
  }
24539
24510
  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);
24540
24511
  const CompanyOtherDetailsComponent$1 = "";
24541
- const BUSINESS_REGISTRATION_NUMBER_FIELD = ["businessRegistrationNumber", "exemptedFromBusinessRegistrationNumber"];
24512
+ const BUSINESS_REGISTRATION_NUMBER_FIELD = ["registrationNumber", "exemptedFromRegistrationNumber"];
24542
24513
  function BusinessRegistrationNumberField({
24543
24514
  data,
24544
24515
  valid,
24545
24516
  errors,
24546
24517
  labels: labels2,
24518
+ mask,
24519
+ guidanceText,
24547
24520
  placeholders,
24548
- helperText,
24549
24521
  readonly,
24550
- classNameModifiers,
24551
24522
  canExempt,
24552
24523
  handleChangeFor
24553
24524
  }) {
24554
24525
  return jsxs(Fragment, {
24555
- children: [jsx(Field, {
24556
- name: "businessRegistrationNumberField",
24557
- label: labels2 == null ? void 0 : labels2.businessRegistrationNumber,
24558
- helper: helperText == null ? void 0 : helperText.businessRegistrationNumber,
24559
- errorMessage: errors.businessRegistrationNumber,
24560
- isValid: valid.businessRegistrationNumber,
24561
- classNameModifiers,
24562
- children: (childProps) => jsx(InputText, {
24563
- ...childProps,
24564
- "aria-required": true,
24565
- "aria-label": labels2 == null ? void 0 : labels2.businessRegistrationNumber,
24566
- "aria-invalid": !valid.businessRegistrationNumber,
24567
- name: "businessRegistrationNumber",
24568
- value: data.businessRegistrationNumber,
24569
- placeholder: placeholders == null ? void 0 : placeholders.businessRegistrationNumber,
24570
- disabled: data.exemptedFromBusinessRegistrationNumber,
24571
- readonly,
24572
- required: true,
24573
- classNameModifiers: ["businessRegistrationNumber"],
24574
- onInput: handleChangeFor("businessRegistrationNumber", "input"),
24575
- onBlur: handleChangeFor("businessRegistrationNumber", "blur")
24576
- })
24577
- }), canExempt && jsx(Checkbox, {
24578
- "aria-required": false,
24579
- "aria-label": labels2 == null ? void 0 : labels2.exemptedFromBusinessRegistrationNumber,
24580
- "aria-invalid": false,
24581
- name: "exemptedFromBusinessRegistrationNumber",
24582
- value: "exemptedFromBusinessRegistrationNumber",
24583
- checked: Boolean(data.exemptedFromBusinessRegistrationNumber),
24584
- label: labels2 == null ? void 0 : labels2.exemptedFromBusinessRegistrationNumber,
24526
+ children: [jsx(MaskedInputText, {
24527
+ "aria-required": true,
24528
+ "aria-label": labels2.registrationNumber,
24529
+ "aria-invalid": !valid.registrationNumber,
24530
+ classNameModifiers: {
24531
+ field: ["registrationNumber"],
24532
+ input: ["registrationNumber"]
24533
+ },
24534
+ name: "registrationNumber",
24535
+ value: (data == null ? void 0 : data.registrationNumber) ?? "",
24536
+ label: labels2.registrationNumber ?? "",
24537
+ formatGuidance: (guidanceText == null ? void 0 : guidanceText.registrationNumber) ?? "",
24538
+ placeholder: placeholders == null ? void 0 : placeholders.registrationNumber,
24539
+ errorMessage: errors.registrationNumber,
24540
+ isValid: Boolean(valid.registrationNumber),
24541
+ onInput: handleChangeFor("registrationNumber", "input"),
24542
+ onBlur: handleChangeFor("registrationNumber", "blur"),
24543
+ disabled: data.exemptedFromRegistrationNumber,
24544
+ readonly,
24545
+ ...mask
24546
+ }), canExempt && jsx(Checkbox, {
24547
+ "aria-required": false,
24548
+ "aria-label": labels2 == null ? void 0 : labels2.exemptedFromRegistrationNumber,
24549
+ "aria-invalid": false,
24550
+ name: "exemptedFromRegistrationNumber",
24551
+ value: "exemptedFromRegistrationNumber",
24552
+ checked: Boolean(data.exemptedFromRegistrationNumber),
24553
+ label: labels2 == null ? void 0 : labels2.exemptedFromRegistrationNumber,
24585
24554
  readonly,
24586
24555
  classNameModifiers: ["exempted-from-registration"],
24587
- onChange: handleChangeFor("exemptedFromBusinessRegistrationNumber")
24556
+ onChange: handleChangeFor("exemptedFromRegistrationNumber")
24588
24557
  })]
24589
24558
  });
24590
24559
  }
@@ -24619,6 +24588,17 @@ function DateOfIncorporationField({
24619
24588
  })
24620
24589
  });
24621
24590
  }
24591
+ const DateOfIncorporationFieldValidation = () => ({
24592
+ dateOfIncorporation: [{
24593
+ modes: ["blur"],
24594
+ validate: (dateOfIncorporation2) => !isEmpty(dateOfIncorporation2),
24595
+ errorMessage: "fieldIsRequired"
24596
+ }, {
24597
+ modes: ["blur"],
24598
+ validate: (dateOfIncorporation2) => dateOfIncorporation2 ? new Date(dateOfIncorporation2) < /* @__PURE__ */ new Date() : false,
24599
+ errorMessage: "invalidDateOfIncorporation"
24600
+ }]
24601
+ });
24622
24602
  const STOCK_EXCHANGE_MIC_FIELD = ["stockExchangeMIC"];
24623
24603
  function StockExchangeMICField({
24624
24604
  data,
@@ -24652,6 +24632,13 @@ function StockExchangeMICField({
24652
24632
  })
24653
24633
  });
24654
24634
  }
24635
+ const StockExchangeMICFieldValidation = () => ({
24636
+ stockExchangeMIC: [{
24637
+ modes: ["blur"],
24638
+ validate: (stockExchangeMIC2) => !isEmpty(stockExchangeMIC2),
24639
+ errorMessage: "fieldIsRequired"
24640
+ }]
24641
+ });
24655
24642
  const STOCK_ISIN_FIELD = ["stockISIN"];
24656
24643
  function StockISINField({
24657
24644
  data,
@@ -24685,6 +24672,17 @@ function StockISINField({
24685
24672
  })
24686
24673
  });
24687
24674
  }
24675
+ const StockISINFieldValidation = () => ({
24676
+ stockISIN: [{
24677
+ modes: ["blur"],
24678
+ validate: (stockISIN2) => !isEmpty(stockISIN2),
24679
+ errorMessage: "fieldIsRequired"
24680
+ }, {
24681
+ modes: ["blur"],
24682
+ validate: (input) => exactLength(input, 12),
24683
+ errorMessage: "validationPleaseEnterAValidStockISIN"
24684
+ }]
24685
+ });
24688
24686
  const TRADING_NAME_FIELD = ["tradingName", "sameNameAsLegalName"];
24689
24687
  function TradingNameField({
24690
24688
  data,
@@ -24736,12 +24734,21 @@ function TradingNameField({
24736
24734
  })]
24737
24735
  });
24738
24736
  }
24737
+ const TradingNameFieldValidation = () => ({
24738
+ tradingName: [{
24739
+ modes: ["blur"],
24740
+ validate: (tradingName2) => !isEmpty(tradingName2),
24741
+ errorMessage: "fieldIsRequired"
24742
+ }]
24743
+ });
24739
24744
  const VAT_NUMBER_FIELD = ["vatNumber", "exemptedFromVat", "vatAbsenceReason"];
24740
24745
  function VatNumberField({
24741
24746
  data,
24742
24747
  valid,
24743
24748
  errors,
24744
24749
  labels: labels2,
24750
+ mask,
24751
+ guidanceText,
24745
24752
  placeholders,
24746
24753
  readonly,
24747
24754
  handleChangeFor,
@@ -24751,25 +24758,26 @@ function VatNumberField({
24751
24758
  i18n
24752
24759
  } = useI18nContext();
24753
24760
  return jsxs(Fragment, {
24754
- children: [jsx(Field, {
24761
+ children: [jsx(MaskedInputText, {
24762
+ "aria-required": true,
24763
+ "aria-label": labels2.vatNumber,
24764
+ "aria-invalid": !valid.vatNumber,
24765
+ classNameModifiers: {
24766
+ field: ["tax-id"],
24767
+ input: ["vatNumber"]
24768
+ },
24755
24769
  name: "vatNumber",
24756
- label: labels2 == null ? void 0 : labels2.vatNumber,
24757
- classNameModifiers: ["tax-id"],
24770
+ value: (data == null ? void 0 : data.vatNumber) ?? "",
24771
+ label: labels2.vatNumber ?? "",
24772
+ formatGuidance: (guidanceText == null ? void 0 : guidanceText.vatNumber) ?? "",
24773
+ placeholder: placeholders == null ? void 0 : placeholders.vatNumber,
24758
24774
  errorMessage: errors.vatNumber,
24759
- isValid: valid.vatNumber,
24760
- children: (childProps) => jsx(InputText, {
24761
- ...childProps,
24762
- "aria-required": true,
24763
- "aria-label": labels2 == null ? void 0 : labels2.vatNumber,
24764
- "aria-invalid": !valid.vatNumber,
24765
- name: "vatNumber",
24766
- value: data.vatNumber,
24767
- readonly,
24768
- classNameModifiers: ["vatNumber"],
24769
- onInput: handleChangeFor("vatNumber", "input"),
24770
- onBlur: handleChangeFor("vatNumber", "blur"),
24771
- disabled: data.exemptedFromVat
24772
- })
24775
+ isValid: Boolean(valid.vatNumber),
24776
+ onInput: handleChangeFor("vatNumber", "input"),
24777
+ onBlur: handleChangeFor("vatNumber", "blur"),
24778
+ disabled: data.exemptedFromVat,
24779
+ readonly,
24780
+ ...mask
24773
24781
  }), canExempt && jsx(Checkbox, {
24774
24782
  "aria-required": false,
24775
24783
  "aria-label": labels2 == null ? void 0 : labels2.exemptedFromVat,
@@ -24819,43 +24827,119 @@ function CompanyOtherDetails({
24819
24827
  readOnlyFields,
24820
24828
  country: country2,
24821
24829
  legalCompanyName: legalCompanyName2,
24822
- companyType: companyType2
24830
+ companyType: companyType2,
24831
+ kompanyVerifiedData
24823
24832
  }) {
24833
+ var _a, _b, _c, _d;
24824
24834
  const {
24825
24835
  i18n
24826
24836
  } = useI18nContext();
24837
+ const {
24838
+ isExperimentEnabled
24839
+ } = useExperimentsContext();
24827
24840
  const {
24828
24841
  sliceData,
24829
24842
  updateStateSlice
24830
24843
  } = useGlobalDataSlice(COMPANY_OTHER_DETAILS_FORM_ID);
24844
+ 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);
24845
+ 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);
24846
+ const [taxIdentificationNumberType, setTaxIdentificationNumberType] = useState$1(existingTaxIdentificationNumber ? inferTaxIdNumberType(existingTaxIdentificationNumber, country2) : (_d = taxIdNumberOptions[country2]) == null ? void 0 : _d[0].id);
24847
+ const isTypeSelectorEnabled = isExperimentEnabled(ExperimentNames.EnableIdentityFieldTypeSelector);
24831
24848
  const directChildFields = companyOtherDetailsFields.filter((field) => ["tradingName", "sameNameAsLegalName", "stockExchangeMIC", "stockISIN", "dateOfIncorporation"].includes(field));
24832
24849
  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]);
24833
- const validationRules = useMemo$1(() => CompanyOtherDetailsValidationRules(country2, companyType2), [companyType2, country2]);
24850
+ const initialFormUtilsProps = useMemo$1(() => ({
24851
+ labels: labels2,
24852
+ placeholders,
24853
+ helperText,
24854
+ readOnly,
24855
+ requiredFields,
24856
+ readOnlyFields,
24857
+ optionalFields,
24858
+ maskedFields,
24859
+ shouldValidate
24860
+ }), [helperText, labels2, maskedFields, optionalFields, placeholders, readOnly, readOnlyFields, requiredFields, shouldValidate]);
24861
+ const mergedFieldProps = useMemo$1(() => {
24862
+ var _a2;
24863
+ return (_a2 = initialFormUtilsProps.requiredFields) == null ? void 0 : _a2.reduce((acc, field) => {
24864
+ switch (field) {
24865
+ case "tradingName":
24866
+ return {
24867
+ ...acc,
24868
+ validators: {
24869
+ ...acc.validators,
24870
+ ...TradingNameFieldValidation()
24871
+ }
24872
+ };
24873
+ case "dateOfIncorporation":
24874
+ return {
24875
+ ...acc,
24876
+ validators: {
24877
+ ...acc.validators,
24878
+ ...DateOfIncorporationFieldValidation()
24879
+ }
24880
+ };
24881
+ case "stockExchangeMIC":
24882
+ return {
24883
+ ...acc,
24884
+ validators: {
24885
+ ...acc.validators,
24886
+ ...StockExchangeMICFieldValidation()
24887
+ }
24888
+ };
24889
+ case "stockISIN":
24890
+ return {
24891
+ ...acc,
24892
+ validators: {
24893
+ ...acc.validators,
24894
+ ...StockISINFieldValidation()
24895
+ }
24896
+ };
24897
+ case "registrationNumber":
24898
+ return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$3[country2], {
24899
+ companyType: companyType2,
24900
+ registrationNumberType
24901
+ }, defaultFieldMetadata$3), acc);
24902
+ case "taxInformation":
24903
+ return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig[country2], {
24904
+ taxIdNumberType: taxIdentificationNumberType
24905
+ }, defaultFieldMetadata), acc);
24906
+ case "vatNumber":
24907
+ return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$1[country2], {
24908
+ vatNumberType: taxIdentificationNumberType
24909
+ }, defaultFieldMetadata$1), acc);
24910
+ default:
24911
+ return acc;
24912
+ }
24913
+ }, initialFormUtilsProps);
24914
+ }, [companyType2, country2, initialFormUtilsProps, registrationNumberType, taxIdentificationNumberType]);
24834
24915
  const {
24835
24916
  schema: formSchema,
24836
24917
  data: formData,
24837
24918
  errors: formErrors,
24838
24919
  valid: formValid,
24839
24920
  fieldProblems: formFieldProblems,
24840
- handleChangeFor
24921
+ handleChangeFor,
24922
+ triggerValidation
24841
24923
  } = useForm({
24842
24924
  schema,
24843
24925
  defaultData: data,
24844
- rules: validationRules,
24926
+ rules: mergedFieldProps == null ? void 0 : mergedFieldProps.validators,
24927
+ optionalFields: mergedFieldProps == null ? void 0 : mergedFieldProps.optionalFields,
24928
+ maskedFields: mergedFieldProps == null ? void 0 : mergedFieldProps.maskedFields,
24845
24929
  fieldProblems: fieldValidationErrors,
24846
- optionalFields,
24847
- maskedFields,
24848
24930
  shouldValidate
24849
24931
  });
24850
- const formUtils = formUtilities({
24851
- labels: labels2,
24852
- placeholders,
24853
- helperText,
24854
- readOnly,
24855
- requiredFields,
24856
- readOnlyFields,
24857
- optionalFields
24858
- }, i18n);
24932
+ const formUtils = formUtilities(mergedFieldProps ?? initialFormUtilsProps, i18n);
24933
+ const handleBusinessRegistrationNumberTypeChange = useCallback$1((type) => {
24934
+ setRegistrationNumberType(type);
24935
+ triggerValidation(["registrationNumber"]);
24936
+ }, [triggerValidation]);
24937
+ const handleTaxIdentificationNumberTypeChange = useCallback$1((type) => {
24938
+ setTaxIdentificationNumberType(type);
24939
+ triggerValidation(["vatNumber", "taxInformation"]);
24940
+ }, [triggerValidation]);
24941
+ useEffect$1(() => {
24942
+ }, [kompanyVerifiedData]);
24859
24943
  useEffect$1(() => {
24860
24944
  updateStateSlice({
24861
24945
  schema: formSchema,
@@ -24893,6 +24977,61 @@ function CompanyOtherDetails({
24893
24977
  handleChangeFor,
24894
24978
  legalCompanyName: legalCompanyName2
24895
24979
  })
24980
+ }), isTypeSelectorEnabled && companyType2 && formUtils.isRequiredField("registrationNumber") && jsx(CompanyRegistrationNumberTypeSelector, {
24981
+ companyType: companyType2,
24982
+ country: country2,
24983
+ setSelected: handleBusinessRegistrationNumberTypeChange,
24984
+ selected: registrationNumberType
24985
+ }), formUtils.isRequiredField("registrationNumber") && jsx("div", {
24986
+ className: "adyen-kyc-field-wrapper",
24987
+ children: jsx(BusinessRegistrationNumberField, {
24988
+ data: formUtils.getFieldData(formData, BUSINESS_REGISTRATION_NUMBER_FIELD),
24989
+ valid: formUtils.getFieldValid(formValid, BUSINESS_REGISTRATION_NUMBER_FIELD),
24990
+ errors: formUtils.getFieldErrors(formErrors, formFieldProblems, BUSINESS_REGISTRATION_NUMBER_FIELD),
24991
+ labels: formUtils.getFieldLabels(BUSINESS_REGISTRATION_NUMBER_FIELD),
24992
+ mask: formUtils.getMask("registrationNumber"),
24993
+ guidanceText: formUtils.getFieldGuidanceText(BUSINESS_REGISTRATION_NUMBER_FIELD),
24994
+ placeholders: formUtils.getFieldPlaceholders(BUSINESS_REGISTRATION_NUMBER_FIELD),
24995
+ helperText: formUtils.getFieldHelperText(BUSINESS_REGISTRATION_NUMBER_FIELD),
24996
+ readonly: formUtils.isReadOnly("registrationNumber"),
24997
+ handleChangeFor,
24998
+ canExempt: formUtils.isRequiredField("exemptedFromRegistrationNumber")
24999
+ })
25000
+ }), isTypeSelectorEnabled && formUtils.isRequiredField("vatNumber") && jsx(TaxIdNumberTypeSelector, {
25001
+ country: country2,
25002
+ setSelected: handleTaxIdentificationNumberTypeChange,
25003
+ selected: taxIdentificationNumberType
25004
+ }), formUtils.isRequiredField("vatNumber") && jsx("div", {
25005
+ className: "adyen-kyc-field-wrapper",
25006
+ children: jsx(VatNumberField, {
25007
+ data: formUtils.getFieldData(formData, VAT_NUMBER_FIELD),
25008
+ valid: formUtils.getFieldValid(formValid, VAT_NUMBER_FIELD),
25009
+ errors: formUtils.getFieldErrors(formErrors, formFieldProblems, VAT_NUMBER_FIELD),
25010
+ labels: formUtils.getFieldLabels(VAT_NUMBER_FIELD),
25011
+ mask: formUtils.getMask("vatNumber"),
25012
+ guidanceText: formUtils.getFieldGuidanceText(VAT_NUMBER_FIELD),
25013
+ placeholders: formUtils.getFieldPlaceholders(VAT_NUMBER_FIELD),
25014
+ readonly: formUtils.isReadOnly("vatNumber"),
25015
+ handleChangeFor,
25016
+ country: country2,
25017
+ canExempt: formUtils.isRequiredField("exemptedFromVat")
25018
+ })
25019
+ }), formUtils.isRequiredField("taxInformation") && jsx("div", {
25020
+ className: "adyen-kyc-field-wrapper",
25021
+ children: jsx(TaxInformationField, {
25022
+ data: formUtils.getFieldData(formData, TAX_INFORMATION_FIELD),
25023
+ valid: formUtils.getFieldValid(formValid, TAX_INFORMATION_FIELD),
25024
+ errors: formUtils.getFieldErrors(formErrors, formFieldProblems, TAX_INFORMATION_FIELD),
25025
+ labels: formUtils.getFieldLabels(TAX_INFORMATION_FIELD),
25026
+ mask: formUtils.getMask("taxInformation"),
25027
+ helperText: formUtils.getFieldHelperText(TAX_INFORMATION_FIELD),
25028
+ guidanceText: formUtils.getFieldGuidanceText(TAX_INFORMATION_FIELD),
25029
+ readonly: formUtils.isReadOnly("taxInformation"),
25030
+ handleChangeFor,
25031
+ country: country2,
25032
+ canExempt: formUtils.isRequiredField("exemptedFromTax"),
25033
+ isUen: formUtils.isRequiredField("isUen")
25034
+ })
24896
25035
  }), formUtils.isRequiredField("dateOfIncorporation") && jsx("div", {
24897
25036
  className: "adyen-kyc-field-wrapper",
24898
25037
  children: jsx(DateOfIncorporationField, {
@@ -24931,50 +25070,11 @@ function CompanyOtherDetails({
24931
25070
  readonly: formUtils.isReadOnly("stockISIN"),
24932
25071
  handleChangeFor
24933
25072
  })
24934
- }), formUtils.isRequiredField("businessRegistrationNumber") && jsx("div", {
24935
- className: "adyen-kyc-field-wrapper",
24936
- children: jsx(BusinessRegistrationNumberField, {
24937
- data: formUtils.getFieldData(formData, BUSINESS_REGISTRATION_NUMBER_FIELD),
24938
- valid: formUtils.getFieldValid(formValid, BUSINESS_REGISTRATION_NUMBER_FIELD),
24939
- errors: formUtils.getFieldErrors(formErrors, formFieldProblems, BUSINESS_REGISTRATION_NUMBER_FIELD),
24940
- labels: formUtils.getFieldLabels(BUSINESS_REGISTRATION_NUMBER_FIELD),
24941
- placeholders: formUtils.getFieldPlaceholders(BUSINESS_REGISTRATION_NUMBER_FIELD),
24942
- helperText: formUtils.getFieldHelperText(BUSINESS_REGISTRATION_NUMBER_FIELD),
24943
- readonly: formUtils.isReadOnly("businessRegistrationNumber"),
24944
- handleChangeFor,
24945
- canExempt: formUtils.isRequiredField("exemptedFromBusinessRegistrationNumber")
24946
- })
24947
- }), formUtils.isRequiredField("taxInformation") && jsx("div", {
24948
- className: "adyen-kyc-field-wrapper",
24949
- children: jsx(TaxInformationField, {
24950
- data: formUtils.getFieldData(formData, TAX_INFORMATION_FIELD),
24951
- valid: formUtils.getFieldValid(formValid, TAX_INFORMATION_FIELD),
24952
- errors: formUtils.getFieldErrors(formErrors, formFieldProblems, TAX_INFORMATION_FIELD),
24953
- labels: formUtils.getFieldLabels(TAX_INFORMATION_FIELD),
24954
- readonly: formUtils.isReadOnly("taxInformation"),
24955
- handleChangeFor,
24956
- country: country2,
24957
- canExempt: formUtils.isRequiredField("exemptedFromTax"),
24958
- isUen: formUtils.isRequiredField("isUen")
24959
- })
24960
- }), formUtils.isRequiredField("vatNumber") && jsx("div", {
24961
- className: "adyen-kyc-field-wrapper",
24962
- children: jsx(VatNumberField, {
24963
- data: formUtils.getFieldData(formData, VAT_NUMBER_FIELD),
24964
- valid: formUtils.getFieldValid(formValid, VAT_NUMBER_FIELD),
24965
- errors: formUtils.getFieldErrors(formErrors, formFieldProblems, VAT_NUMBER_FIELD),
24966
- labels: formUtils.getFieldLabels(VAT_NUMBER_FIELD),
24967
- placeholders: formUtils.getFieldPlaceholders(VAT_NUMBER_FIELD),
24968
- readonly: formUtils.isReadOnly("vatNumber"),
24969
- handleChangeFor,
24970
- country: country2,
24971
- canExempt: formUtils.isRequiredField("exemptedFromVat")
24972
- })
24973
25073
  })]
24974
25074
  })]
24975
25075
  });
24976
25076
  }
24977
- 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);
25077
+ 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);
24978
25078
  const CompanyStructureComponent$1 = "";
24979
25079
  const CompanyStructureValidation = {
24980
25080
  entityType: {
@@ -24992,7 +25092,8 @@ function CompanyStructure({
24992
25092
  description: description2,
24993
25093
  formVerificationErrors,
24994
25094
  fieldValidationErrors,
24995
- requiredFields
25095
+ requiredFields,
25096
+ kompanyVerifiedData
24996
25097
  }) {
24997
25098
  const {
24998
25099
  i18n
@@ -25018,6 +25119,12 @@ function CompanyStructure({
25018
25119
  labels: labels2,
25019
25120
  requiredFields
25020
25121
  }, i18n);
25122
+ useEffect(() => {
25123
+ var _a, _b;
25124
+ if ((_a = kompanyVerifiedData == null ? void 0 : kompanyVerifiedData.companyStructure) == null ? void 0 : _a.entityType) {
25125
+ handleChangeFor("entityType")((_b = kompanyVerifiedData == null ? void 0 : kompanyVerifiedData.companyStructure) == null ? void 0 : _b.entityType);
25126
+ }
25127
+ }, [kompanyVerifiedData]);
25021
25128
  useEffect(() => {
25022
25129
  updateStateSlice({
25023
25130
  schema: formSchema,
@@ -25055,7 +25162,7 @@ function CompanyStructure({
25055
25162
  })]
25056
25163
  });
25057
25164
  }
25058
- 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));
25165
+ 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);
25059
25166
  const forms = {
25060
25167
  companyBasics: {
25061
25168
  formId: "companyBasics",
@@ -25092,32 +25199,40 @@ const forms = {
25092
25199
  fields: ["taxDocument"]
25093
25200
  }
25094
25201
  };
25095
- const parseConfiguration$2 = ({
25202
+ const parseConfiguration$4 = ({
25096
25203
  country: country2,
25097
25204
  matchingScenario
25098
25205
  }) => parseCompanySearchScenarios(matchingScenario == null ? void 0 : matchingScenario[LegalEntityType.ORGANIZATION], country2);
25099
25206
  const mandatoryApiFieldsForCompanySearch = ["companyBasics.legalCompanyName", "companyBasics.country"];
25100
- const canSubmit = (data) => mandatoryApiFieldsForCompanySearch.every((detail) => {
25207
+ const canSubmit$1 = (data) => mandatoryApiFieldsForCompanySearch.every((detail) => {
25101
25208
  const value = getProp(data, detail);
25102
25209
  return !isEmpty$1(value);
25103
25210
  });
25104
- const isDocumentsRequired = (forms$1) => forms$1.some((form) => [forms.companyRegistrationDocument.formId, forms.companyTaxDocument.formId].includes(form.formId));
25105
- const formatOtherDetails = (formData, i18n) => {
25211
+ const isDocumentsRequired$1 = (forms$1) => forms$1.some((form) => [forms.companyRegistrationDocument.formId, forms.companyTaxDocument.formId].includes(form.formId));
25212
+ const formatOtherDetails = (formData, i18n, country2, labels2) => {
25213
+ var _a, _b, _c;
25214
+ const summaryData = {
25215
+ ...formData,
25216
+ [((_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
25217
+ };
25218
+ if (formData.taxInformation) {
25219
+ delete summaryData.taxInformation;
25220
+ }
25106
25221
  if (formData.exemptedFromVat) {
25107
- const summaryData = {
25108
- ...formData,
25109
- "VAT absence reason": i18n.get(formData.vatAbsenceReason)
25110
- };
25111
- delete summaryData.vatAbsenceReason;
25222
+ summaryData.vatAbsenceReason = i18n.get(formData.vatAbsenceReason);
25112
25223
  delete summaryData.vatNumber;
25113
- return summaryData;
25114
25224
  }
25115
- return formData;
25225
+ return summaryData;
25116
25226
  };
25117
- const formatDataForSummary = (data, forms2, i18n) => {
25227
+ const formatDataForSummary = (data, forms2, labels2, i18n) => {
25228
+ var _a;
25118
25229
  const datasetUtils = datasetUtilities(i18n.locale);
25230
+ const country2 = (_a = data.companyBasics) == null ? void 0 : _a.country;
25231
+ const taxIdLabel = resolveFieldMetadata(defaultFieldConfig[country2], {
25232
+ taxIdNumberType: countryToTaxInfoTypeMap[country2]
25233
+ }, defaultFieldMetadata).label;
25119
25234
  return entriesOf(data).reduce((summaryData, [form, formData]) => {
25120
- var _a, _b, _c, _d, _e, _f, _g;
25235
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
25121
25236
  if (!form)
25122
25237
  return summaryData;
25123
25238
  switch (form) {
@@ -25125,10 +25240,10 @@ const formatDataForSummary = (data, forms2, i18n) => {
25125
25240
  return {
25126
25241
  ...summaryData,
25127
25242
  [form]: {
25128
- legalCompanyName: formData.legalCompanyName,
25129
- country: datasetUtils.getCountryName(formData.country),
25243
+ [((_a2 = labels2 == null ? void 0 : labels2.companyBasics) == null ? void 0 : _a2.legalCompanyName) ?? "legalCompanyName"]: formData.legalCompanyName,
25244
+ [((_b = labels2 == null ? void 0 : labels2.companyBasics) == null ? void 0 : _b.country) ?? "country"]: datasetUtils.getCountryName(formData.country),
25130
25245
  [getKeyForField("stateOrProvince", formData.country)]: datasetUtils.getStateName(formData.stateOrProvince, formData.country),
25131
- taxInformationNumber: (_b = (_a = formData.taxInformation) == null ? void 0 : _a.find((taxId2) => formData.country === taxId2.country)) == null ? void 0 : _b.number
25246
+ [taxIdLabel]: (_d = (_c = formData.taxInformation) == null ? void 0 : _c.find((taxId2) => formData.country === taxId2.country)) == null ? void 0 : _d.number
25132
25247
  }
25133
25248
  };
25134
25249
  case "companyRegistrationAddress":
@@ -25144,33 +25259,33 @@ const formatDataForSummary = (data, forms2, i18n) => {
25144
25259
  return {
25145
25260
  ...summaryData,
25146
25261
  [form]: {
25147
- entityType: i18n.get((_c = companyTypes.find((type) => type.id === formData.entityType)) == null ? void 0 : _c.name)
25262
+ entityType: i18n.get((_e = companyTypes.find((type) => type.id === formData.entityType)) == null ? void 0 : _e.name)
25148
25263
  }
25149
25264
  };
25150
25265
  case "companyOtherDetails":
25151
25266
  return {
25152
25267
  ...summaryData,
25153
- [form]: formatOtherDetails(formData, i18n)
25268
+ [form]: formatOtherDetails(formData, i18n, (_f = data.companyBasics) == null ? void 0 : _f.country, labels2)
25154
25269
  };
25155
25270
  case "companyRegistrationDocument":
25156
- if (!isDocumentsRequired(forms2))
25271
+ if (!isDocumentsRequired$1(forms2))
25157
25272
  return summaryData;
25158
25273
  return {
25159
25274
  ...summaryData,
25160
25275
  [form]: {
25161
25276
  companyRegistrationDocument: {
25162
- fileName: (_e = (_d = formData == null ? void 0 : formData.registrationDocument) == null ? void 0 : _d[0]) == null ? void 0 : _e.name
25277
+ fileName: (_h = (_g = formData == null ? void 0 : formData.registrationDocument) == null ? void 0 : _g[0]) == null ? void 0 : _h.name
25163
25278
  }
25164
25279
  }
25165
25280
  };
25166
25281
  case "companyTaxDocument":
25167
- if (!isDocumentsRequired(forms2))
25282
+ if (!isDocumentsRequired$1(forms2))
25168
25283
  return summaryData;
25169
25284
  return {
25170
25285
  ...summaryData,
25171
25286
  [form]: {
25172
25287
  companyTaxDocument: {
25173
- fileName: (_g = (_f = formData == null ? void 0 : formData.taxDocument) == null ? void 0 : _f[0]) == null ? void 0 : _g.name
25288
+ fileName: (_j = (_i = formData == null ? void 0 : formData.taxDocument) == null ? void 0 : _i[0]) == null ? void 0 : _j.name
25174
25289
  }
25175
25290
  }
25176
25291
  };
@@ -25330,7 +25445,7 @@ function useCompanySearchTaskSubmit({
25330
25445
  legalEntity,
25331
25446
  currentForms
25332
25447
  }) => {
25333
- if (!isDocumentsRequired(currentForms))
25448
+ if (!isDocumentsRequired$1(currentForms))
25334
25449
  return;
25335
25450
  const formattedDocument = await mapCompanySearchDocumentToApiDocument(data, legalEntity.id);
25336
25451
  try {
@@ -25441,6 +25556,7 @@ function CompanySearchComponent(props) {
25441
25556
  } = useI18nContext();
25442
25557
  const {
25443
25558
  country: country2,
25559
+ isTopLevelEntity,
25444
25560
  activeForm,
25445
25561
  problems,
25446
25562
  handleAddressSearch,
@@ -25453,6 +25569,7 @@ function CompanySearchComponent(props) {
25453
25569
  } = props;
25454
25570
  const globalData = useGlobalData();
25455
25571
  const [kompanyAddress, setKompanyAddress] = useState();
25572
+ const [kompanyVerifiedData, setKompanyVerifiedData] = useState();
25456
25573
  const formWrapperClasses = (formId) => (activeForm == null ? void 0 : activeForm.formId) !== formId ? "adyen-kyc-form-wrapper adyen-kyc-form-wrapper--hidden" : "adyen-kyc-form-wrapper";
25457
25574
  return jsxs("div", {
25458
25575
  className: "adyen-kyc-company",
@@ -25463,13 +25580,15 @@ function CompanySearchComponent(props) {
25463
25580
  id: forms.companyBasics.formId,
25464
25581
  heading: i18n.get(forms.companyBasics.formName),
25465
25582
  country: country2,
25583
+ isTopLevelEntity,
25466
25584
  handleCompanyIndexSearch,
25467
25585
  handleCompanyDeepSearch,
25468
25586
  handleGetCompanyDataset,
25469
25587
  handleRefreshCompanyDataset,
25470
25588
  handleVerifyTin,
25471
25589
  kompanyAddress,
25472
- setKompanyAddress
25590
+ setKompanyAddress,
25591
+ setKompanyVerifiedData
25473
25592
  })
25474
25593
  }), jsx("div", {
25475
25594
  className: formWrapperClasses(forms.companyRegistrationAddress.formId),
@@ -25492,7 +25611,8 @@ function CompanySearchComponent(props) {
25492
25611
  ...getFormProps(props, forms.companyStructure.formId),
25493
25612
  id: forms.companyStructure.formId,
25494
25613
  heading: i18n.get(forms.companyStructure.formName),
25495
- description: i18n.get(forms.companyStructure.formDescription)
25614
+ description: i18n.get(forms.companyStructure.formDescription),
25615
+ kompanyVerifiedData
25496
25616
  })
25497
25617
  }), jsx("div", {
25498
25618
  className: formWrapperClasses(forms.companyOtherDetails.formId),
@@ -25502,7 +25622,8 @@ function CompanySearchComponent(props) {
25502
25622
  heading: i18n.get(forms.companyOtherDetails.formName),
25503
25623
  country: country2,
25504
25624
  legalCompanyName: (_a = globalData == null ? void 0 : globalData.companyBasics) == null ? void 0 : _a.legalCompanyName,
25505
- companyType: (_b = globalData == null ? void 0 : globalData.companyStructure) == null ? void 0 : _b.entityType
25625
+ companyType: (_b = globalData == null ? void 0 : globalData.companyStructure) == null ? void 0 : _b.entityType,
25626
+ kompanyVerifiedData
25506
25627
  })
25507
25628
  }), jsx("div", {
25508
25629
  className: formWrapperClasses(forms.companyRegistrationDocument.formId),
@@ -25647,13 +25768,13 @@ function CompanySearchDropinComponent({
25647
25768
  }, [documentUtils, eventEmitter, i18n, initialData, legalEntityResponse, setLocale, showToast]);
25648
25769
  const getConfigurationData = useCallback(() => getConfiguration2({
25649
25770
  legalEntityType: LegalEntityType.ORGANIZATION,
25650
- capabilities: capabilities ?? [],
25771
+ capabilities: capabilities ?? Object.keys(legalEntityResponse == null ? void 0 : legalEntityResponse.capabilities),
25651
25772
  country: country2
25652
- }), [getConfiguration2, capabilities, country2]);
25773
+ }), [getConfiguration2, capabilities, country2, legalEntityResponse == null ? void 0 : legalEntityResponse.capabilities]);
25653
25774
  const {
25654
25775
  fieldConfigurations
25655
25776
  } = useScenarioConfiguration({
25656
- parseConfiguration: parseConfiguration$2,
25777
+ parseConfiguration: parseConfiguration$4,
25657
25778
  getConfigurationData,
25658
25779
  setLoadingStatus,
25659
25780
  country: country2
@@ -25689,10 +25810,10 @@ function CompanySearchDropinComponent({
25689
25810
  return addValidityToForms(requiredForms, currentState.validityByForm, problems);
25690
25811
  }, [derivedProps, problems, currentState.validityByForm]);
25691
25812
  const summaryData = useMemo(() => ({
25692
- data: formatDataForSummary(currentState.data, forms$1, i18n),
25813
+ data: formatDataForSummary(currentState.data, forms$1, derivedProps == null ? void 0 : derivedProps.labels, i18n),
25693
25814
  omittedKeys: ["operationalAddressIsSame"]
25694
- }), [currentState.data, forms$1, i18n]);
25695
- const canSubmitForm = useMemo(() => canSubmit(currentState.data) && hasDataChanged(initialData, currentState.data), [initialData, currentState.data]);
25815
+ }), [currentState.data, derivedProps == null ? void 0 : derivedProps.labels, forms$1, i18n]);
25816
+ const canSubmitForm = useMemo(() => canSubmit$1(currentState.data) && hasDataChanged(initialData, currentState.data), [initialData, currentState.data]);
25696
25817
  const baseTrackingPayload = useMemo(() => getBaseTrackingPayload({
25697
25818
  trackingConfig,
25698
25819
  parentLegalEntity,
@@ -25764,6 +25885,7 @@ function CompanySearchDropinComponent({
25764
25885
  problems,
25765
25886
  activeForm,
25766
25887
  shouldValidate,
25888
+ isTopLevelEntity: taskType === TaskTypes.COMPANY_SEARCH,
25767
25889
  handleAddressSearch,
25768
25890
  handleFindAddress,
25769
25891
  handleCompanyIndexSearch,
@@ -28031,7 +28153,7 @@ const omitMaskedFieldsIfUnchanged = (maskedFields, dataSubmitted, savedData) =>
28031
28153
  });
28032
28154
  return filtered;
28033
28155
  };
28034
- const parseConfiguration$1 = ({
28156
+ const parseConfiguration$3 = ({
28035
28157
  country: country2,
28036
28158
  matchingScenario
28037
28159
  }) => parseIndividualScenarios(matchingScenario == null ? void 0 : matchingScenario[LegalEntityType.INDIVIDUAL], country2);
@@ -28115,7 +28237,7 @@ function IndividualDropinComponent({
28115
28237
  const {
28116
28238
  fieldConfigurations
28117
28239
  } = useScenarioConfiguration({
28118
- parseConfiguration: parseConfiguration$1,
28240
+ parseConfiguration: parseConfiguration$3,
28119
28241
  getConfigurationData,
28120
28242
  setLoadingStatus,
28121
28243
  country: country2
@@ -28587,14 +28709,14 @@ const rules$1 = ({
28587
28709
  }
28588
28710
  });
28589
28711
  const getRegistrationCountry = (legalEntityResponse) => legalEntityResponse.type === LegalEntityType.INDIVIDUAL ? legalEntityResponse.individual.residentialAddress.country : legalEntityResponse.organization.registeredAddress.country;
28590
- const labels$1 = () => ({
28712
+ const labels = () => ({
28591
28713
  verifiedAccountHolder: () => "accountHolder",
28592
28714
  verifiedBankCountry: () => "bankCountry",
28593
28715
  verifiedBankName: () => "bankName",
28594
28716
  verifiedCurrencyCode: () => "currencyCode",
28595
28717
  verifiedBankAccountNumber: () => "bankAccountNumber"
28596
28718
  });
28597
- const parseConfiguration = ({
28719
+ const parseConfiguration$2 = ({
28598
28720
  requiredFields,
28599
28721
  country: country2,
28600
28722
  bankVerificationAvailable
@@ -28720,7 +28842,7 @@ function PayoutDetailsDropinComponent({
28720
28842
  requiredFields,
28721
28843
  bankVerificationVendors
28722
28844
  } = useScenarioConfiguration({
28723
- parseConfiguration,
28845
+ parseConfiguration: parseConfiguration$2,
28724
28846
  getConfigurationData,
28725
28847
  getPayoutAccountFormatData,
28726
28848
  instantVerificationEnabled,
@@ -28734,7 +28856,7 @@ function PayoutDetailsDropinComponent({
28734
28856
  taskType,
28735
28857
  requiredFields
28736
28858
  }), [bankAccountCountry2, data, taskType]);
28737
- const fieldsFormCustomLabels = useMemo(() => labels$1 ? labels$1() : {}, [data, bankAccountCountry2]);
28859
+ const fieldsFormCustomLabels = useMemo(() => labels ? labels() : {}, [data, bankAccountCountry2]);
28738
28860
  const payoutDetailsSteps = useMemo(() => {
28739
28861
  var _a2;
28740
28862
  return getAppropriatePayoutDetailsSteps(taskType, Boolean((_a2 = prefilledData == null ? void 0 : prefilledData.payoutAccountDetails) == null ? void 0 : _a2.transferInstrumentId), !transferInstrument && isInstantVerificationAvailable({
@@ -30197,668 +30319,61 @@ function ServiceAgreementDropinComponent({
30197
30319
  })
30198
30320
  });
30199
30321
  }
30200
- function removeObjectPropsWithEmptyValues(obj) {
30201
- keysOf(obj).forEach((key) => {
30202
- if (obj[key] === null || isEmpty(obj[key]))
30203
- delete obj[key];
30204
- });
30205
- return obj;
30206
- }
30207
- const INITIAL_STATE = {
30208
- data: {},
30209
- allData: {},
30210
- initialData: {},
30211
- errors: {},
30212
- valid: {},
30213
- fieldProblems: {},
30214
- isValid: false
30215
- };
30216
- function StateReducer() {
30217
- const [schemas, setSchemas] = useState({});
30218
- const [activeForms, setActiveForms] = useState([]);
30219
- const setCurrentForms = (forms2) => {
30220
- setActiveForms(forms2);
30322
+ const parseConfiguration$1 = ({
30323
+ matchingScenario,
30324
+ country: country2
30325
+ }) => parseSolePropScenarios(matchingScenario[LegalEntityType.SOLE_PROPRIETORSHIP], country2);
30326
+ const isDocumentsRequired = (forms2) => forms2.some((form) => [solePropForms.solePropConstitutionalDocument.formId].includes(form.formId));
30327
+ const formatFileSummaryData = (solePropConstitutionalDocument) => {
30328
+ var _a;
30329
+ const constitutionalDocument2 = (_a = solePropConstitutionalDocument == null ? void 0 : solePropConstitutionalDocument.constitutionalDocument) == null ? void 0 : _a[0];
30330
+ return {
30331
+ ...constitutionalDocument2 && {
30332
+ solePropConstitutionalDocument: {
30333
+ fileName: constitutionalDocument2.name
30334
+ }
30335
+ }
30221
30336
  };
30222
- function reducer2({
30223
- currentState: currState
30224
- }, action) {
30225
- var _a, _b, _c, _d, _e;
30226
- switch (action.type) {
30227
- case "addToState": {
30228
- const state2 = structuredClone(currState);
30229
- const dataStoreId = action.value.dataStoreId ?? action.value.caller;
30230
- const schema = action.value.schema || null;
30231
- const schemaHasChanged = schema && ((_a = schemas == null ? void 0 : schemas[dataStoreId]) == null ? void 0 : _a.toString()) !== schema.toString();
30232
- const mergedState = {
30233
- ...state2,
30234
- data: {
30235
- ...state2.data,
30236
- [dataStoreId]: {
30237
- ...state2.data[dataStoreId],
30238
- ...action.value.data
30239
- }
30240
- },
30241
- // Add data in allData state prop in case we will need them later
30242
- allData: {
30243
- ...state2.allData,
30244
- [dataStoreId]: {
30245
- ...state2.allData[dataStoreId],
30246
- ...removeObjectPropsWithEmptyValues(action.value.data)
30247
- }
30248
- },
30249
- errors: {
30250
- ...state2.errors,
30251
- [dataStoreId]: {
30252
- ...state2.errors[dataStoreId],
30253
- ...action.value.errors
30254
- }
30255
- },
30256
- valid: {
30257
- ...state2.valid,
30258
- [dataStoreId]: {
30259
- ...state2.valid[dataStoreId],
30260
- ...action.value.valid
30261
- }
30262
- },
30263
- fieldProblems: {
30264
- ...state2.fieldProblems,
30265
- [dataStoreId]: {
30266
- ...state2.fieldProblems[dataStoreId],
30267
- ...action.value.fieldProblems
30268
- }
30269
- }
30270
- };
30271
- if (schemaHasChanged) {
30272
- setSchemas({
30273
- ...schemas,
30274
- [dataStoreId]: schema
30275
- });
30276
- const processedBySchema = schema.reduce((acc, fieldKey) => {
30277
- const dataObjByFormId = mergedState.data[dataStoreId];
30278
- const allDataObjByFormId = mergedState.allData[dataStoreId];
30279
- const validObjByFormId = mergedState.valid[dataStoreId];
30280
- const errorsObjByFormId = mergedState.errors[dataStoreId];
30281
- const fieldProblemsObjByFormId = mergedState.fieldProblems[dataStoreId];
30282
- return {
30283
- data: {
30284
- ...acc.data,
30285
- [fieldKey]: dataObjByFormId[fieldKey] ?? allDataObjByFormId[fieldKey]
30286
- },
30287
- valid: {
30288
- ...acc.valid,
30289
- [fieldKey]: validObjByFormId[fieldKey]
30290
- },
30291
- errors: {
30292
- ...acc.errors,
30293
- [fieldKey]: errorsObjByFormId[fieldKey]
30294
- },
30295
- fieldProblems: {
30296
- ...acc.fieldProblems,
30297
- [fieldKey]: fieldProblemsObjByFormId[fieldKey]
30298
- }
30299
- };
30300
- }, {
30301
- data: {},
30302
- valid: {},
30303
- errors: {},
30304
- fieldProblems: {}
30305
- });
30306
- mergedState.data[dataStoreId] = processedBySchema.data;
30307
- mergedState.valid[dataStoreId] = processedBySchema.valid;
30308
- mergedState.errors[dataStoreId] = processedBySchema.errors;
30309
- mergedState.fieldProblems[dataStoreId] = processedBySchema.fieldProblems;
30310
- }
30311
- mergedState.validityByForm = {
30312
- ...mergedState.validityByForm,
30313
- [dataStoreId]: Object.values(mergedState.valid[dataStoreId]).every((isValid) => isValid)
30314
- };
30315
- mergedState.hasDataChanged = {
30316
- ...state2.hasDataChanged,
30317
- [dataStoreId]: {
30318
- hasDataChanged: hasDataChanged((_b = state2.initialData) == null ? void 0 : _b[dataStoreId], (_c = mergedState.data) == null ? void 0 : _c[dataStoreId])
30319
- }
30320
- };
30321
- mergedState.hasAnyDataChanged = Object.values(mergedState.hasDataChanged).some(({
30322
- hasDataChanged: hasDataChanged2
30323
- }) => hasDataChanged2);
30324
- mergedState.allValid = Object.values(mergedState.validityByForm).every((isValid) => isValid);
30325
- mergedState.isValid = !activeForms.length ? mergedState.allValid : activeForms.every((item) => mergedState.validityByForm[item]);
30326
- mergedState.initialData = structuredClone(state2.initialData);
30327
- return {
30328
- currentState: mergedState,
30329
- prevState: state2,
30330
- changeInitiatedBy: dataStoreId
30331
- };
30332
- }
30333
- case "resetState": {
30334
- const dataStoreId = ((_d = action.value) == null ? void 0 : _d.dataStoreId) ?? ((_e = action.value) == null ? void 0 : _e.caller);
30335
- return {
30336
- currentState: INITIAL_STATE,
30337
- prevState: currState,
30338
- changeInitiatedBy: dataStoreId
30339
- };
30340
- }
30341
- default: {
30342
- throw new Error(`Unhandled action type: ${action.type}`);
30343
- }
30344
- }
30345
- }
30346
- return {
30347
- reducer: reducer2,
30348
- setCurrentForms
30349
- };
30350
- }
30351
- function StateProvider({
30352
- defaultData = {},
30353
- children
30354
- }) {
30355
- const defaultState = {
30356
- currentState: {
30357
- data: defaultData,
30358
- allData: defaultData,
30359
- valid: {},
30360
- errors: {},
30361
- fieldProblems: {},
30362
- validityByForm: {},
30363
- initialData: defaultData
30364
- },
30365
- prevState: {},
30366
- changeInitiatedBy: null
30367
- };
30368
- const reducerObj = StateReducer();
30369
- const [state2, dispatch] = useReducer(reducerObj.reducer, defaultState);
30370
- const contextValue = useMemo(() => ({
30371
- state: state2,
30372
- dispatch,
30373
- setActiveForms: reducerObj.setCurrentForms,
30374
- getData: () => {
30375
- var _a;
30376
- return ((_a = state2 == null ? void 0 : state2.currentState) == null ? void 0 : _a.data) ?? {};
30377
- },
30378
- getState: () => state2 == null ? void 0 : state2.currentState
30379
- }), [reducerObj, state2]);
30380
- return jsx(StateContext.Provider, {
30381
- value: contextValue,
30382
- children
30383
- });
30384
- }
30385
- const labels = (data, country2) => ({
30386
- registrationNumber: () => {
30387
- var _a;
30388
- if (country2 === CountryCodes.Monaco && ((_a = data == null ? void 0 : data.solePropNameAndCountry) == null ? void 0 : _a.country) === CountryCodes.Monaco) {
30389
- return "mcRegistrationNumberSoleProp";
30390
- }
30391
- }
30392
- });
30393
- const fontFormats = ["eot", "woff", "woff2", "ttf", "otf"];
30394
- const formatFullNames = {
30395
- eot: "embedded-opentype",
30396
- woff: "woff",
30397
- woff2: "woff2",
30398
- ttf: "truetype",
30399
- otf: "opentype"
30400
- };
30401
- const getFontFaceRule = (fontFamily, fontStyle, fontWeight, fontPath, formats) => {
30402
- const fontSources = formats.map((format) => `url(${fontPath}.${format}) format(${formatFullNames[format]})`);
30403
- const ruleLines = [`font-family: '${fontFamily}'`, `font-style: ${fontStyle}`, `font-weight: ${fontWeight}`, `src: ${fontSources.join(",")}`];
30404
- return `@font-face {${ruleLines.join(";")}}`;
30405
30337
  };
30406
- const addStyleTagForFont = (fontFamily, fontStyle, fontWeight, fontPath, formats) => {
30407
- const style = document.createElement("style");
30408
- style.setAttribute("type", "text/css");
30409
- style.innerText = getFontFaceRule(fontFamily, fontStyle, fontWeight, fontPath, formats);
30410
- document.head.insertBefore(style, document.head.firstChild);
30411
- };
30412
- const addStyleTagForADLIconFont = (loadingContext) => {
30413
- const fontPath = `${loadingContext}static/fonts`;
30414
- const iconFontPath = `${fontPath}/adyen-kyc-icons`;
30415
- addStyleTagForFont("adyen-kyc-icons", "normal", "normal", iconFontPath, fontFormats);
30416
- };
30417
- let isFlagsLoaded = false;
30418
- let isDocumentGuidanceLoaded = false;
30419
- const getIconContainer = () => {
30420
- const container = document.createElement("div");
30421
- container.setAttribute("aria-hidden", "true");
30422
- container.setAttribute("id", "adl-icon-container");
30423
- container.style.height = "0";
30424
- return container;
30425
- };
30426
- const buildSpriteDOMFromResponse = (responseData) => {
30427
- const iconContainer = getIconContainer();
30428
- iconContainer.innerHTML = responseData;
30429
- return iconContainer;
30430
- };
30431
- const loadFlags = async (loadingContext) => {
30432
- if (isFlagsLoaded)
30433
- return;
30434
- isFlagsLoaded = true;
30435
- const responseData = await http({
30436
- loadingContext,
30437
- path: "static/images/country-flags.svg"
30438
- }, null, "text");
30439
- document.body.insertBefore(buildSpriteDOMFromResponse(responseData), document.body.firstChild);
30440
- };
30441
- const loadDocumentGuidance = async (loadingContext) => {
30442
- if (isDocumentGuidanceLoaded)
30443
- return;
30444
- isDocumentGuidanceLoaded = true;
30445
- const responseData = await http({
30446
- loadingContext,
30447
- path: "static/images/document-guidance.svg"
30448
- }, null, "text");
30449
- document.body.insertBefore(buildSpriteDOMFromResponse(responseData), document.body.firstChild);
30450
- };
30451
- const getOpeningStep = (forms2, remediationActions) => {
30338
+ const canSubmit = (data) => mandatoryApiFields.SOLE_PROPRIETORSHIP.every((detail) => {
30339
+ const value = getProp(data, detail);
30340
+ return !isEmpty(value);
30341
+ });
30342
+ const hasRegisteredAddress = (dataFromResponse) => {
30452
30343
  var _a;
30453
- if (remediationActions && Object.keys(remediationActions).length > 0) {
30454
- const allRemediationActions = Object.values(remediationActions).flat().filter((rem) => {
30455
- var _a2;
30456
- return ((_a2 = rem.forms) == null ? void 0 : _a2.length) > 0;
30457
- });
30458
- if (allRemediationActions.length === 1 && ((_a = allRemediationActions[0]) == null ? void 0 : _a.forms.length) === 1) {
30459
- const form = forms2.find((form2) => {
30460
- var _a2;
30461
- return (form2 == null ? void 0 : form2.formId) === ((_a2 = allRemediationActions[0]) == null ? void 0 : _a2.forms[0]);
30462
- });
30463
- if (form)
30464
- return form;
30465
- }
30466
- return forms2[forms2.length - 1];
30467
- }
30468
- return forms2[0];
30344
+ const registeredAddress2 = ((_a = dataFromResponse == null ? void 0 : dataFromResponse.solePropRegistrationAddress) == null ? void 0 : _a.registrationAddress) || {};
30345
+ return Object.entries(registeredAddress2).some(([key, value]) => key !== "country" && Boolean(value));
30346
+ };
30347
+ const getDataWithDefaultAddress = (legalEntityResponse, parentLegalEntity) => {
30348
+ var _a;
30349
+ let solePropData = mapLegalEntityToSoleProp(legalEntityResponse);
30350
+ if (!hasRegisteredAddress(solePropData)) {
30351
+ const defaultAddress = (_a = mapLegalEntityToIndividual(parentLegalEntity, false)) == null ? void 0 : _a.address;
30352
+ solePropData = {
30353
+ ...solePropData,
30354
+ solePropRegistrationAddress: {
30355
+ ...solePropData == null ? void 0 : solePropData.solePropRegistrationAddress,
30356
+ registrationAddress: {
30357
+ ...defaultAddress
30358
+ }
30359
+ }
30360
+ };
30361
+ }
30362
+ return solePropData;
30469
30363
  };
30470
- function withFormComposer(WrappedComponent, {
30471
- getComponentForms,
30472
- parseConfiguration: parseConfiguration2,
30473
- rules: rules2,
30474
- labels: labels2,
30475
- defaultTaskName,
30476
- getConfigFor = "contextCountry"
30477
- }) {
30478
- const WithFormComposer = (props) => {
30479
- var _a, _b, _c, _d;
30480
- const {
30481
- i18n
30482
- } = useI18nContext();
30483
- const {
30484
- contextCountry: initialContextCountry,
30485
- setContextCountry: setInitialContextCountry
30486
- } = useCoreContext();
30487
- const {
30488
- loadingContext
30489
- } = useAuthContext();
30490
- const {
30491
- getConfiguration: getConfiguration2,
30492
- getPayoutAccountFormat: getPayoutAccountFormat2
30493
- } = useConfigurationApi();
30494
- const {
30495
- isSettingEnabled
30496
- } = useSettingsContext();
30497
- const {
30498
- getData,
30499
- getState
30500
- } = useStateContext();
30501
- const {
30502
- getOmittedKeys: getSummaryOmittedKeys = null,
30503
- formatData: formatDataForSummary2 = null,
30504
- omittedForms
30505
- } = props.summary || {};
30506
- const taskName = props.taskName ?? defaultTaskName;
30507
- const [hideDropinLayout, setHideDropinLayout] = useState(false);
30508
- const [hideNavigation, setHideNavigation] = useState(false);
30509
- const [hideFooter, setHideFooter] = useState(false);
30510
- const [hideOnHomeButton, setHideOnHomeButton] = useState(false);
30511
- const [hideBackButton, setHideBackButton] = useState(false);
30512
- const [submitButtonLabel, setSubmitButtonLabel] = useState(null);
30513
- const [skipSubmitAndGoTaskList, setSkipSubmitAndGoTaskList] = useState(false);
30514
- const [customFormNavigationHandlers, setCustomFormNavigationHandlers] = useState({});
30515
- const [shouldValidate, setShouldValidate] = useState(false);
30516
- const [formValidity, setFormValidity] = useState({});
30517
- const formRef = useRef(null);
30518
- const [loadingStatus, setLoadingStatus] = useState("success");
30519
- const [derivedProps, setDerivedProps] = useState(props);
30520
- const [contextCountry, setContextCountry] = useState(props.country || initialContextCountry);
30521
- const {
30522
- sliceData: payoutMethodData
30523
- } = useGlobalDataSlice("payoutVerificationMethod");
30524
- const configCountry = (getConfigFor === "bankCountry" ? payoutMethodData == null ? void 0 : payoutMethodData.bankCountry : contextCountry) ?? contextCountry;
30525
- useEffect(() => {
30526
- loadDocumentGuidance(loadingContext);
30527
- }, [loadingContext]);
30528
- const getConfigurationData = useCallback(() => getConfiguration2({
30529
- legalEntityType: props.legalEntityType,
30530
- capabilities: props.capabilities,
30531
- // for payout forms, we need to get config for the selected bankCountry, not necessarily the same as the residency/registration country
30532
- country: configCountry
30533
- }), [configCountry, props.capabilities, props.legalEntityType]);
30534
- const getPayoutAccountFormatData = useCallback(() => getPayoutAccountFormat2(configCountry), [configCountry]);
30535
- const {
30536
- fieldConfigurations,
30537
- requiredFields,
30538
- bankVerificationVendors
30539
- } = useScenarioConfiguration({
30540
- getConfigurationData,
30541
- getPayoutAccountFormatData,
30542
- parseConfiguration: parseConfiguration2,
30543
- country: configCountry,
30544
- instantVerificationEnabled: derivedProps.instantVerificationEnabled && derivedProps.handleGetBankVerificationVendors,
30545
- setLoadingStatus
30546
- });
30547
- const isFormStepVisible = (formId) => {
30548
- if (derivedProps.requiredFields || derivedProps.optionalFields) {
30549
- return !!derivedProps.requiredFields[formId] || !!derivedProps.optionalFields[formId];
30550
- }
30551
- return true;
30552
- };
30553
- const isFormSummaryStep = (form) => form.formId === summaryStep.formId;
30554
- const componentForms = useMemo(() => getComponentForms({
30555
- ...props,
30556
- bankVerificationVendors
30557
- }, isSettingEnabled), [bankVerificationVendors, isSettingEnabled, props]);
30558
- const componentFormsWithSummary = [...Object.values(componentForms), summaryStep];
30559
- const allowedForms = componentFormsWithSummary.filter((form) => isFormStepVisible(form.formId) || isFormSummaryStep(form));
30560
- const [activeForm, setActiveForm] = useState(getOpeningStep(allowedForms, (_a = props == null ? void 0 : props.problems) == null ? void 0 : _a.remediationActions));
30561
- const [hasAlreadyNavigatedForm, setHasAlreadyNavigatedForm] = useState(false);
30562
- const getFormIndex = (formId) => allowedForms.findIndex((form) => form.formId === formId);
30563
- const isFinalStep = getFormIndex(activeForm.formId) === allowedForms.length - 1;
30564
- const isFirstStep = getFormIndex(activeForm.formId) === 0;
30565
- useEffect(() => {
30566
- var _a2;
30567
- if (hasAlreadyNavigatedForm)
30568
- return;
30569
- const openingStep = getOpeningStep(allowedForms, (_a2 = props == null ? void 0 : props.problems) == null ? void 0 : _a2.remediationActions);
30570
- if (activeForm !== openingStep) {
30571
- setActiveForm(openingStep);
30572
- }
30573
- }, [activeForm, allowedForms, (_b = props == null ? void 0 : props.problems) == null ? void 0 : _b.remediationActions, hasAlreadyNavigatedForm]);
30574
- const evaluateConfiguration = useCallback((scenarioConfiguration, country2, formData, isSettingEnabled2, requiredFields2) => {
30575
- var _a2, _b2, _c2;
30576
- const fieldsFromCustomRules = rules2 ? rules2({
30577
- data: formData,
30578
- country: country2,
30579
- taskType: props.taskType,
30580
- isSettingEnabled: isSettingEnabled2,
30581
- requiredFields: requiredFields2
30582
- }) : {};
30583
- const fieldsFormCustomLabels = labels2 ? labels2(formData, country2) : {};
30584
- 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);
30585
- setShouldValidate(false);
30586
- setDerivedProps({
30587
- ...props,
30588
- ...scenarioProps,
30589
- country: configCountry
30590
- });
30591
- }, [componentForms, configCountry, props]);
30592
- useEffect(() => {
30593
- if (!fieldConfigurations)
30594
- return;
30595
- evaluateConfiguration(fieldConfigurations, configCountry, getData(), isSettingEnabled, requiredFields);
30596
- }, [fieldConfigurations, configCountry, evaluateConfiguration, getData, isSettingEnabled, requiredFields]);
30597
- const trackNavigation2 = ({
30598
- fromForm,
30599
- toForm,
30600
- component
30601
- }) => {
30602
- userEvents.addEvent("Navigated form", {
30603
- segmentation: {
30604
- ...props == null ? void 0 : props.baseTrackingPayload,
30605
- component,
30606
- from: fromForm.formId,
30607
- fromLabel: i18n.get(fromForm.formName),
30608
- to: toForm.formId,
30609
- toLabel: i18n.get(toForm.formName)
30610
- }
30611
- });
30612
- };
30613
- const trackSectionCompletion = (form) => {
30614
- userEvents.addEvent("Completed form section", {
30615
- segmentation: {
30616
- ...props == null ? void 0 : props.baseTrackingPayload,
30617
- sectionName: form.formId
30618
- }
30619
- });
30620
- };
30621
- const gotoFormByFormIndex = (nextFormIndex) => {
30622
- if (formRef.current.verifyForm) {
30623
- formRef.current.verifyForm(activeForm.formId).then((isVerified) => {
30624
- if (isVerified) {
30625
- setHasAlreadyNavigatedForm(true);
30626
- setActiveForm(allowedForms[nextFormIndex]);
30627
- }
30628
- });
30629
- } else {
30630
- setHasAlreadyNavigatedForm(true);
30631
- setActiveForm(allowedForms[nextFormIndex]);
30632
- }
30633
- };
30634
- const validateCurrentForm = () => {
30635
- setShouldValidate(true);
30636
- };
30637
- const handleNextClick = () => {
30638
- var _a2, _b2;
30639
- if (formRef.current.customNavigationHandler) {
30640
- formRef.current.customNavigationHandler();
30641
- return;
30642
- }
30643
- if ((_a2 = customFormNavigationHandlers[activeForm.formId]) == null ? void 0 : _a2.onNext) {
30644
- (_b2 = customFormNavigationHandlers[activeForm.formId]) == null ? void 0 : _b2.onNext();
30645
- return;
30646
- }
30647
- const allFields = (derivedProps == null ? void 0 : derivedProps.allFields) || {};
30648
- if (isFormSummaryStep(activeForm)) {
30649
- if (skipSubmitAndGoTaskList) {
30650
- props.navigateBackToTaskList();
30651
- } else {
30652
- props.onSubmit({
30653
- data: getData(),
30654
- forms: allowedForms,
30655
- allFields,
30656
- setLoadingStatus
30657
- });
30658
- }
30659
- return;
30660
- }
30661
- if (formValidity[activeForm.formId]) {
30662
- if (isFinalStep) {
30663
- props.onSubmit({
30664
- data: getData(),
30665
- forms: allowedForms,
30666
- allFields,
30667
- setLoadingStatus
30668
- });
30669
- return;
30670
- }
30671
- setShouldValidate(false);
30672
- const toFormIndex = allowedForms.findIndex((form) => form.formId === activeForm.formId) + 1;
30673
- gotoFormByFormIndex(toFormIndex);
30674
- const toForm = allowedForms[toFormIndex];
30675
- trackNavigation2({
30676
- fromForm: activeForm,
30677
- toForm,
30678
- component: "ActionBar"
30679
- });
30680
- trackSectionCompletion(activeForm);
30681
- } else {
30682
- validateCurrentForm();
30683
- }
30684
- };
30685
- const handleBackClick = () => {
30686
- const currentFormIndex = allowedForms.findIndex((form) => form.formId === activeForm.formId);
30687
- if (currentFormIndex) {
30688
- const fromForm = allowedForms[currentFormIndex];
30689
- const toForm = allowedForms[currentFormIndex - 1];
30690
- setActiveForm(toForm);
30691
- setHasAlreadyNavigatedForm(true);
30692
- trackNavigation2({
30693
- fromForm,
30694
- toForm,
30695
- component: "ActionBar"
30696
- });
30697
- }
30698
- };
30699
- const setCustomHandlers = (formId, onNext, onBack) => {
30700
- setCustomFormNavigationHandlers({
30701
- ...customFormNavigationHandlers,
30702
- [formId]: {
30703
- onNext,
30704
- onBack
30705
- }
30706
- });
30707
- };
30708
- const nextButtonText = isFinalStep ? i18n.get(submitButtonLabel ?? "submit") : i18n.get("next");
30709
- useEffect(() => {
30710
- props.eventEmitter.on("next", handleNextClick);
30711
- props.eventEmitter.on("back", handleBackClick);
30712
- props.eventEmitter.on("validate", validateCurrentForm);
30713
- return () => {
30714
- props.eventEmitter.off("next", handleNextClick);
30715
- props.eventEmitter.off("back", handleNextClick);
30716
- props.eventEmitter.off("validate", validateCurrentForm);
30717
- };
30718
- }, [activeForm, allowedForms]);
30719
- const onCountryChange = (country2) => {
30720
- setContextCountry(country2);
30721
- };
30722
- const onWrappedComponentChange = (state2) => {
30723
- var _a2;
30724
- setFormValidity(state2.validityByForm);
30725
- (_a2 = props.onChange) == null ? void 0 : _a2.call(props, state2);
30726
- };
30727
- const handleStateChange = ({
30728
- currentState
30729
- }) => {
30730
- onWrappedComponentChange(currentState);
30731
- };
30732
- const handleLeaveDropin = async () => {
30733
- var _a2;
30734
- const data = getData();
30735
- const hasDataChanged2 = getState().hasAnyDataChanged;
30736
- if (hasDataChanged2 && ((_a2 = props.canSubmit) == null ? void 0 : _a2.call(props, data))) {
30737
- setInitialContextCountry(contextCountry);
30738
- const allFields = (derivedProps == null ? void 0 : derivedProps.allFields) || {};
30739
- await props.onSubmit({
30740
- data,
30741
- forms: allowedForms,
30742
- allFields,
30743
- setLoadingStatus
30744
- });
30745
- } else {
30746
- props.handleHomeClick();
30747
- }
30748
- };
30749
- const formFooter = !hideDropinLayout && !hideFooter && jsx(ActionBar, {
30750
- onNext: handleNextClick,
30751
- onBack: isFirstStep ? props.handleBackClick : handleBackClick,
30752
- backButtonLabel: i18n.get("back"),
30753
- nextButtonLabel: nextButtonText,
30754
- onHome: handleLeaveDropin,
30755
- homeButtonLabel: props.homeButtonLabel,
30756
- hideOnHomeButton,
30757
- hideBackButton
30758
- });
30759
- const wrappedComponent = jsx("div", {
30760
- className: "adyen-kyc-form-container",
30761
- children: jsx(LoaderWrapper, {
30762
- status: loadingStatus,
30763
- formOpacityWhenLoading: 0.3,
30764
- loaderSize: "large",
30765
- children: jsxs(FormRouterContextProvider, {
30766
- setFormIndex: gotoFormByFormIndex,
30767
- forms: allowedForms,
30768
- handleGetIdVerificationToken: props.handleGetIdVerificationToken,
30769
- children: [jsx(StateContextWatcher, {
30770
- owner: "FormComposer",
30771
- onChange: handleStateChange
30772
- }), jsx(WrappedComponent, {
30773
- ref: formRef,
30774
- forms: allowedForms,
30775
- activeForm,
30776
- ...derivedProps,
30777
- data: props.data,
30778
- onChange: onWrappedComponentChange,
30779
- evaluateConfiguration: (data) => evaluateConfiguration(fieldConfigurations, configCountry, data, isSettingEnabled, requiredFields),
30780
- country: contextCountry,
30781
- onCountryChange,
30782
- legalEntityId: (_c = props.legalEntityResponse) == null ? void 0 : _c.id,
30783
- problems: props == null ? void 0 : props.problems,
30784
- shouldValidate,
30785
- onNext: handleNextClick,
30786
- onBack: handleBackClick,
30787
- setHideDropinLayout,
30788
- setHideNavigation,
30789
- setHideFooter,
30790
- setCustomFormNavigationHandlers: setCustomHandlers,
30791
- setHideOnHomeButton,
30792
- setHideBackButton,
30793
- setSubmitButtonLabel,
30794
- setSkipSubmitAndGoTaskList,
30795
- bankVerificationVendors
30796
- }), activeForm.formId === summaryStep.formId && jsx("div", {
30797
- className: "adyen-kyc-form-wrapper",
30798
- children: jsx(Summary, {
30799
- trackNavigation: trackNavigation2,
30800
- data: formatDataForSummary2 ? formatDataForSummary2(getData(), allowedForms) : getData(),
30801
- omittedKeys: getSummaryOmittedKeys ? getSummaryOmittedKeys(getData()) : null,
30802
- omittedForms,
30803
- forms: allowedForms,
30804
- gotoForm: gotoFormByFormIndex,
30805
- labels: derivedProps.labels,
30806
- problems: props == null ? void 0 : props.problems
30807
- })
30808
- }), formFooter]
30809
- })
30810
- })
30811
- });
30812
- const allowedFormsWithValidity = addValidityToForms(allowedForms, formValidity, props.problems);
30813
- const sidebar = !hideDropinLayout && !hideNavigation && jsx(LoaderWrapper, {
30814
- status: loadingStatus,
30815
- formOpacityWhenLoading: 0.3,
30816
- showSpinner: false,
30817
- className: "adyen-kyc-dropin__sidebar-wrapper",
30818
- children: jsx(FormNavigation, {
30819
- forms: allowedFormsWithValidity,
30820
- activeForm: allowedFormsWithValidity.find((form) => form.formId === activeForm.formId),
30821
- gotoForm: gotoFormByFormIndex,
30822
- validateForm: validateCurrentForm,
30823
- taskName,
30824
- trackNavigation: trackNavigation2,
30825
- verificationErrors: (_d = props == null ? void 0 : props.problems) == null ? void 0 : _d.verificationErrors
30826
- })
30827
- });
30828
- const content = jsxs(Fragment, {
30829
- children: [sidebar, wrappedComponent]
30830
- });
30831
- if (!props.hideDropinLayout) {
30832
- return jsx(DropinLayout, {
30833
- content
30834
- });
30835
- }
30836
- return wrappedComponent;
30837
- };
30838
- return WithFormComposer;
30839
- }
30840
- const SolePropWithFormComposer = withFormComposer(SolePropComponent, {
30841
- getComponentForms: () => solePropForms,
30842
- // TODO: change trust to soleprop once the configurations for soleprops are added in backend.
30843
- parseConfiguration: ({
30844
- matchingScenario,
30845
- country: country2
30846
- }) => parseSolePropScenarios([matchingScenario[LegalEntityType.TRUST]], country2),
30847
- rules: rules$2,
30848
- labels,
30849
- defaultTaskName: "solePropDetails"
30850
- });
30851
30364
  function SolePropDropinComponent({
30852
30365
  problems: problemsProp,
30853
30366
  capabilities,
30854
- country: country2,
30367
+ country: externalCountry,
30855
30368
  parentLegalEntity,
30856
30369
  legalEntityResponse,
30857
30370
  eventEmitter,
30858
30371
  homeButtonLabel,
30859
30372
  hideDropinLayout,
30860
- onSubmit,
30373
+ onSubmit: onExternalSubmit,
30861
30374
  onChange,
30375
+ taskType,
30376
+ trackingConfig,
30862
30377
  handleHomeClick,
30863
30378
  handleCreateDocument,
30864
30379
  handleGetDocument,
@@ -30868,7 +30383,7 @@ function SolePropDropinComponent({
30868
30383
  handleUpdateLegalEntity,
30869
30384
  handleCreateLegalEntity
30870
30385
  }) {
30871
- var _a;
30386
+ var _a, _b;
30872
30387
  const {
30873
30388
  i18n,
30874
30389
  setLocale
@@ -30878,43 +30393,72 @@ function SolePropDropinComponent({
30878
30393
  } = useExperimentsContext();
30879
30394
  const [problems, setProblems] = useState(problemsProp);
30880
30395
  const datasetUtils = datasetUtilities(i18n.locale);
30881
- const getOmittedKeys = () => ["operationalAddressIsSame"];
30882
30396
  const [newSoleProp, setNewSoleProp] = useState(null);
30883
30397
  const {
30884
- showToast,
30885
- clearToasts
30398
+ showToast
30886
30399
  } = useToastContext();
30887
- const hasRegisteredAddress = (dataFromResponse) => {
30888
- var _a2;
30889
- const registeredAddress2 = ((_a2 = dataFromResponse == null ? void 0 : dataFromResponse.solePropRegistrationAddress) == null ? void 0 : _a2.registrationAddress) || {};
30890
- return Object.entries(registeredAddress2).some(([key, value]) => key !== "country" && Boolean(value));
30891
- };
30892
- const getDataWithDefaultAddress = (legalEntityResponse2, parentLegalEntity2) => {
30893
- var _a2;
30894
- let solePropData = mapLegalEntityToSoleProp(legalEntityResponse2);
30895
- if (!hasRegisteredAddress(solePropData)) {
30896
- const defaultAddress = (_a2 = mapLegalEntityToIndividual(parentLegalEntity2, false)) == null ? void 0 : _a2.address;
30897
- solePropData = {
30898
- ...solePropData,
30899
- solePropRegistrationAddress: {
30900
- ...solePropData == null ? void 0 : solePropData.solePropRegistrationAddress,
30901
- registrationAddress: {
30902
- ...defaultAddress
30903
- }
30904
- }
30905
- };
30400
+ const {
30401
+ getConfiguration: getConfiguration2
30402
+ } = useConfigurationApi();
30403
+ const {
30404
+ isSettingEnabled
30405
+ } = useSettingsContext();
30406
+ const [loadingStatus, setLoadingStatus] = useState("success");
30407
+ const formRef = useRef(null);
30408
+ const dataFromResponse = getDataWithDefaultAddress(legalEntityResponse, parentLegalEntity);
30409
+ const [data, setData] = useState(dataFromResponse);
30410
+ const country2 = ((_a = dataFromResponse == null ? void 0 : dataFromResponse.solePropRegistrationAddress) == null ? void 0 : _a.registrationAddress.country) || externalCountry;
30411
+ const baseTrackingPayload = getBaseTrackingPayload({
30412
+ trackingConfig,
30413
+ parentLegalEntity,
30414
+ legalEntity: legalEntityResponse,
30415
+ task: taskType
30416
+ });
30417
+ const getConfigurationData = useCallback(() => getConfiguration2({
30418
+ legalEntityType: LegalEntityType.SOLE_PROPRIETORSHIP,
30419
+ capabilities,
30420
+ country: country2
30421
+ }), [country2, capabilities]);
30422
+ const {
30423
+ fieldConfigurations,
30424
+ requiredFields
30425
+ } = useScenarioConfiguration({
30426
+ parseConfiguration: parseConfiguration$1,
30427
+ getConfigurationData,
30428
+ setLoadingStatus,
30429
+ country: country2
30430
+ });
30431
+ const fieldsFromCustomRules = useMemo(() => rules$2({
30432
+ data,
30433
+ country: country2,
30434
+ taskType,
30435
+ requiredFields,
30436
+ isSettingEnabled
30437
+ }), [country2, data, taskType, requiredFields, isSettingEnabled]);
30438
+ 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]);
30439
+ const {
30440
+ state: {
30441
+ currentState
30906
30442
  }
30907
- return solePropData;
30908
- };
30909
- const [data, setData] = useState(getDataWithDefaultAddress(legalEntityResponse, parentLegalEntity));
30910
- const isDocumentsRequired2 = (forms2) => forms2.some((form) => [solePropForms.solePropConstitutionalDocument.formId].includes(form.formId));
30443
+ } = useStateContext();
30444
+ const formValidity = currentState.validityByForm;
30445
+ useEffect(() => {
30446
+ setData({
30447
+ ...currentState.data
30448
+ });
30449
+ onChange == null ? void 0 : onChange(currentState);
30450
+ }, [currentState]);
30451
+ const forms2 = useMemo(() => {
30452
+ const requiredForms = getRequiredForms(solePropForms, derivedProps == null ? void 0 : derivedProps.requiredFields, derivedProps == null ? void 0 : derivedProps.optionalFields);
30453
+ return addValidityToForms(requiredForms, formValidity, problems);
30454
+ }, [derivedProps, formValidity, problems]);
30911
30455
  const documentUtils = documentApiUtils(handleCreateDocument, handleGetDocument, handleUpdateDocument);
30912
30456
  const submitDocuments = async ({
30913
- forms: forms2,
30457
+ forms: forms22,
30914
30458
  legalEntity,
30915
30459
  dataSubmitted
30916
30460
  }) => {
30917
- if (isDocumentsRequired2(forms2)) {
30461
+ if (isDocumentsRequired(forms22)) {
30918
30462
  const formattedDocument = await mapSolePropDocumentToApiDocument(dataSubmitted, legalEntity.id);
30919
30463
  if (formattedDocument) {
30920
30464
  await documentUtils.uploadDocuments(formattedDocument, legalEntity.id);
@@ -30969,11 +30513,8 @@ function SolePropDropinComponent({
30969
30513
  const updatedLegalEntity = await handleUpdateLegalEntity(drop("type").from(mappedLegalEntity), (legalEntityResponse == null ? void 0 : legalEntityResponse.id) || (newSoleProp == null ? void 0 : newSoleProp.id));
30970
30514
  return updatedLegalEntity;
30971
30515
  };
30972
- const handleOnSubmit = async ({
30973
- data: dataSubmitted,
30974
- forms: forms2,
30975
- setLoadingStatus
30976
- }) => {
30516
+ const handleOnSubmit = async () => {
30517
+ const dataSubmitted = data;
30977
30518
  setLoadingStatus("loading");
30978
30519
  try {
30979
30520
  const legalEntity = await handleSubmitLegalEntity(mapSolePropToLegalEntity(dataSubmitted));
@@ -30990,7 +30531,7 @@ function SolePropDropinComponent({
30990
30531
  label: i18n.get("successfullyUpdatedDetails"),
30991
30532
  type: ToastType.SUCCESS
30992
30533
  });
30993
- onSubmit(dataSubmitted);
30534
+ onExternalSubmit == null ? void 0 : onExternalSubmit(dataSubmitted);
30994
30535
  } catch (e) {
30995
30536
  showToast({
30996
30537
  label: i18n.get("failedToUpdateDetails"),
@@ -31013,15 +30554,12 @@ function SolePropDropinComponent({
31013
30554
  setLoadingStatus("success");
31014
30555
  }
31015
30556
  };
31016
- const formatDataForSummary2 = (data2, forms2) => {
31017
- var _a2, _b, _c, _d;
30557
+ const formatDataForSummary2 = (data2, forms22) => {
30558
+ var _a2, _b2, _c, _d;
31018
30559
  let summaryData = cloneObject(data2);
31019
- let solePropCountry;
31020
- if ((_a2 = summaryData == null ? void 0 : summaryData.solePropNameAndCountry) == null ? void 0 : _a2.country) {
31021
- solePropCountry = datasetUtils.getCountryName(summaryData.solePropNameAndCountry.country);
31022
- }
30560
+ const solePropCountry = ((_a2 = summaryData == null ? void 0 : summaryData.solePropNameAndCountry) == null ? void 0 : _a2.country) ? datasetUtils.getCountryName(summaryData.solePropNameAndCountry.country) : void 0;
31023
30561
  summaryData.solePropNameAndCountry = {
31024
- legalNameOfSoleProprietor: (_b = data2.solePropNameAndCountry) == null ? void 0 : _b.legalCompanyName,
30562
+ legalNameOfSoleProprietor: (_b2 = data2.solePropNameAndCountry) == null ? void 0 : _b2.legalCompanyName,
31025
30563
  countryOfEstablishment: solePropCountry
31026
30564
  };
31027
30565
  if ((_c = summaryData == null ? void 0 : summaryData.solePropRegistrationAddress) == null ? void 0 : _c.registrationAddress) {
@@ -31031,53 +30569,62 @@ function SolePropDropinComponent({
31031
30569
  if ((_d = summaryData == null ? void 0 : summaryData.solePropRegistrationAddress) == null ? void 0 : _d.operationalAddress) {
31032
30570
  summaryData.solePropRegistrationAddress.operationalAddress = mapAddressLabels(summaryData == null ? void 0 : summaryData.solePropRegistrationAddress.operationalAddress, datasetUtils);
31033
30571
  }
31034
- if (isDocumentsRequired2(forms2)) {
30572
+ if (isDocumentsRequired(forms22)) {
31035
30573
  delete summaryData[solePropDocumentFormId];
31036
30574
  summaryData = {
31037
30575
  ...summaryData,
31038
- ...formatFileSummaryData2(data2.solePropConstitutionalDocument)
30576
+ ...formatFileSummaryData(data2.solePropConstitutionalDocument)
31039
30577
  };
31040
30578
  }
31041
30579
  return summaryData;
31042
30580
  };
31043
- const formatFileSummaryData2 = (solePropConstitutionalDocument) => {
31044
- var _a2;
31045
- const constitutionalDocument2 = (_a2 = solePropConstitutionalDocument == null ? void 0 : solePropConstitutionalDocument.constitutionalDocument) == null ? void 0 : _a2[0];
31046
- return {
31047
- ...constitutionalDocument2 && {
31048
- solePropConstitutionalDocument: {
31049
- fileName: constitutionalDocument2.name
31050
- }
31051
- }
31052
- };
31053
- };
31054
- const canSubmit2 = (data2) => mandatoryApiFields.SOLE_PROPRIETORSHIP.every((detail) => {
31055
- const value = getProp(data2, detail);
31056
- return !isEmpty(value);
30581
+ const {
30582
+ handleNextClick,
30583
+ handleBackClick,
30584
+ activeForm,
30585
+ shouldValidate,
30586
+ setShouldValidate,
30587
+ gotoFormByFormIndex,
30588
+ nextButtonLabel
30589
+ } = useFormComposer({
30590
+ problems,
30591
+ baseTrackingPayload,
30592
+ forms: forms2,
30593
+ formRef,
30594
+ onSubmit: handleOnSubmit
31057
30595
  });
31058
- return jsx(StateProvider, {
31059
- defaultData: data,
31060
- children: jsx(SolePropWithFormComposer, {
30596
+ return jsx(FormWrapper, {
30597
+ taskName: isExperimentEnabled("EnableNewEntryFlow") ? "soleProprietorshipDetails" : "solePropDetails",
30598
+ handleBackClick,
30599
+ handleNextClick,
30600
+ gotoFormByFormIndex,
30601
+ handleHomeClick,
30602
+ hideDropinLayout,
30603
+ nextButtonLabel,
30604
+ homeButtonLabel,
30605
+ loadingStatus,
30606
+ forms: forms2,
30607
+ activeForm,
30608
+ onSubmit: handleOnSubmit,
30609
+ validateForm: () => setShouldValidate(true),
30610
+ canSubmit: canSubmit(data) && hasDataChanged(dataFromResponse, data),
30611
+ baseTrackingPayload,
30612
+ problems,
30613
+ summary: {
30614
+ data: formatDataForSummary2(data, forms2),
30615
+ omittedKeys: ["operationalAddressIsSame"]
30616
+ },
30617
+ children: jsx(SolePropComponent, {
30618
+ ...derivedProps,
30619
+ activeForm,
31061
30620
  capabilities,
31062
- data,
31063
- country: ((_a = data == null ? void 0 : data.solePropNameAndCountry) == null ? void 0 : _a.country) || country2,
30621
+ data: dataFromResponse,
30622
+ country: ((_b = data == null ? void 0 : data.solePropNameAndCountry) == null ? void 0 : _b.country) || country2,
31064
30623
  problems,
31065
- eventEmitter,
31066
- hideDropinLayout,
31067
- legalEntityType: LegalEntityType.TRUST,
31068
- taskName: isExperimentEnabled("EnableNewEntryFlow") ? "soleProprietorshipDetails" : "solePropDetails",
31069
- legalEntityResponse,
31070
- summary: {
31071
- formatData: formatDataForSummary2,
31072
- getOmittedKeys
31073
- },
31074
- canSubmit: canSubmit2,
31075
- onChange,
31076
- onSubmit: handleOnSubmit,
31077
- handleHomeClick,
31078
- homeButtonLabel,
31079
30624
  handleAddressSearch,
31080
- handleFindAddress
30625
+ handleFindAddress,
30626
+ ref: formRef,
30627
+ shouldValidate
31081
30628
  })
31082
30629
  });
31083
30630
  }
@@ -31104,53 +30651,99 @@ const rules = ({
31104
30651
  }
31105
30652
  }
31106
30653
  });
31107
- const TrustWithFormComposer = withFormComposer(TrustComponent, {
31108
- getComponentForms: () => trustForms,
31109
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
31110
- parseConfiguration: ({
31111
- matchingScenario,
31112
- country: country2
31113
- }) => parseTrustScenarios(matchingScenario == null ? void 0 : matchingScenario[LegalEntityType.TRUST], country2),
31114
- rules,
31115
- defaultTaskName: "trustDetails"
31116
- });
31117
- function TrustDropinComponent(props) {
31118
- const {
31119
- parentLegalEntity,
31120
- legalEntityResponse,
31121
- handleCreateDocument,
31122
- handleGetDocument,
31123
- handleUpdateDocument,
31124
- handleAddressSearch,
31125
- handleFindAddress
31126
- } = props;
30654
+ const parseConfiguration = ({
30655
+ matchingScenario,
30656
+ country: country2
30657
+ }) => parseTrustScenarios(matchingScenario == null ? void 0 : matchingScenario[LegalEntityType.TRUST], country2);
30658
+ function TrustDropinComponent({
30659
+ parentLegalEntity,
30660
+ capabilities,
30661
+ country: country2,
30662
+ legalEntityResponse,
30663
+ handleCreateLegalEntity,
30664
+ handleUpdateLegalEntity,
30665
+ handleCreateDocument,
30666
+ handleGetDocument,
30667
+ handleUpdateDocument,
30668
+ handleAddressSearch,
30669
+ handleFindAddress,
30670
+ trackingConfig,
30671
+ taskType,
30672
+ problems: problemsProp,
30673
+ onSubmit: externalOnSubmit,
30674
+ onChange,
30675
+ hideDropinLayout,
30676
+ handleHomeClick,
30677
+ homeButtonLabel
30678
+ }) {
30679
+ var _a;
31127
30680
  const {
31128
30681
  i18n
31129
30682
  } = useI18nContext();
31130
30683
  const dataFromResponse = mapLegalEntityToTrust(legalEntityResponse);
31131
- const [data] = useState(dataFromResponse || props.data);
31132
- const [problems, setProblems] = useState(props.problems);
30684
+ const [data, setData] = useState(dataFromResponse);
30685
+ const [problems, setProblems] = useState(problemsProp);
31133
30686
  const datasetUtils = datasetUtilities(i18n.locale);
31134
- const getOmittedKeys = () => ["operationalAddressIsSame"];
31135
30687
  const [newTrust, setNewTrust] = useState(null);
30688
+ const {
30689
+ getConfiguration: getConfiguration2
30690
+ } = useConfigurationApi();
30691
+ const {
30692
+ isSettingEnabled
30693
+ } = useSettingsContext();
31136
30694
  const {
31137
30695
  showToast,
31138
30696
  clearToasts
31139
30697
  } = useToastContext();
31140
- const onSubmit = async ({
31141
- data: data2,
30698
+ const [loadingStatus, setLoadingStatus] = useState("success");
30699
+ const formRef = useRef(null);
30700
+ const getConfigurationData = useCallback(() => getConfiguration2({
30701
+ legalEntityType: LegalEntityType.TRUST,
30702
+ capabilities,
30703
+ country: country2
30704
+ }), [country2, capabilities]);
30705
+ const {
30706
+ fieldConfigurations,
30707
+ requiredFields
30708
+ } = useScenarioConfiguration({
30709
+ parseConfiguration,
30710
+ getConfigurationData,
31142
30711
  setLoadingStatus,
31143
- forms: forms2
31144
- }) => {
31145
- var _a;
30712
+ country: country2
30713
+ });
30714
+ const fieldsFromCustomRules = useMemo(() => rules({
30715
+ data,
30716
+ country: country2,
30717
+ taskType,
30718
+ requiredFields,
30719
+ isSettingEnabled
30720
+ }), [country2, data, taskType, requiredFields, isSettingEnabled]);
30721
+ 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]);
30722
+ const {
30723
+ state: {
30724
+ currentState
30725
+ }
30726
+ } = useStateContext();
30727
+ const formValidity = currentState.validityByForm;
30728
+ useEffect(() => {
30729
+ setData({
30730
+ ...currentState.data
30731
+ });
30732
+ onChange == null ? void 0 : onChange(currentState);
30733
+ }, [currentState]);
30734
+ const forms2 = useMemo(() => {
30735
+ const requiredForms = getRequiredForms(trustForms, derivedProps == null ? void 0 : derivedProps.requiredFields, derivedProps == null ? void 0 : derivedProps.optionalFields);
30736
+ return addValidityToForms(requiredForms, formValidity, problems);
30737
+ }, [derivedProps, formValidity, problems]);
30738
+ const onSubmit = async () => {
31146
30739
  setLoadingStatus("loading");
31147
- const trustDetails2 = mapTrustToLegalEntity(data2);
30740
+ const trustDetails2 = mapTrustToLegalEntity(data);
31148
30741
  try {
31149
30742
  const updatedTrust = await submitTrustDetails(trustDetails2);
31150
30743
  await submitDocuments({
31151
30744
  forms: forms2,
31152
30745
  legalEntity: updatedTrust,
31153
- dataSubmitted: data2
30746
+ dataSubmitted: data
31154
30747
  });
31155
30748
  await attachTrustToParentLegalEntity(updatedTrust);
31156
30749
  setLoadingStatus("success");
@@ -31158,7 +30751,7 @@ function TrustDropinComponent(props) {
31158
30751
  label: i18n.get("successfullyUpdatedDetails"),
31159
30752
  type: ToastType.SUCCESS
31160
30753
  });
31161
- (_a = props.onSubmit) == null ? void 0 : _a.call(props, data2);
30754
+ externalOnSubmit == null ? void 0 : externalOnSubmit(data);
31162
30755
  } catch (e) {
31163
30756
  showToast({
31164
30757
  label: i18n.get("failedToUpdateDetails"),
@@ -31184,27 +30777,27 @@ function TrustDropinComponent(props) {
31184
30777
  const submitTrustDetails = async (legalEntity) => {
31185
30778
  let updatedTrust;
31186
30779
  if (!(legalEntityResponse == null ? void 0 : legalEntityResponse.id) && !(newTrust == null ? void 0 : newTrust.id)) {
31187
- updatedTrust = await props.handleCreateLegalEntity(legalEntity);
30780
+ updatedTrust = await handleCreateLegalEntity(legalEntity);
31188
30781
  setNewTrust(legalEntity);
31189
30782
  } else {
31190
- updatedTrust = await props.handleUpdateLegalEntity(drop("type").from(legalEntity), (legalEntityResponse == null ? void 0 : legalEntityResponse.id) || (newTrust == null ? void 0 : newTrust.id));
30783
+ updatedTrust = await handleUpdateLegalEntity(drop("type").from(legalEntity), (legalEntityResponse == null ? void 0 : legalEntityResponse.id) || (newTrust == null ? void 0 : newTrust.id));
31191
30784
  }
31192
30785
  return updatedTrust;
31193
30786
  };
31194
30787
  const documentUtils = documentApiUtils(handleCreateDocument, handleGetDocument, handleUpdateDocument);
31195
30788
  const submitDocuments = async ({
31196
- forms: forms2,
30789
+ forms: forms22,
31197
30790
  legalEntity,
31198
30791
  dataSubmitted
31199
30792
  }) => {
31200
- if (isDocumentsRequired2(forms2)) {
30793
+ if (isDocumentsRequired2(forms22)) {
31201
30794
  const formattedDocument = await mapTrustDocumentToApiDocument(dataSubmitted, legalEntity.id);
31202
30795
  if (formattedDocument) {
31203
30796
  await documentUtils.uploadDocuments(formattedDocument, legalEntity.id);
31204
30797
  }
31205
30798
  }
31206
30799
  };
31207
- const isDocumentsRequired2 = (forms2) => forms2.some((form) => [trustForms.trustConstitutionalDocument.formId].includes(form.formId));
30800
+ const isDocumentsRequired2 = (forms22) => forms22.some((form) => [trustForms.trustConstitutionalDocument.formId].includes(form.formId));
31208
30801
  const attachTrustToParentLegalEntity = async (trust2) => {
31209
30802
  if (legalEntityResponse == null ? void 0 : legalEntityResponse.id) {
31210
30803
  return;
@@ -31216,30 +30809,25 @@ function TrustDropinComponent(props) {
31216
30809
  legalEntityId: trust2.id
31217
30810
  }, ...existingEntityAssociations]
31218
30811
  };
31219
- await props.handleUpdateLegalEntity(updatedParentLegalEntity, parentLegalEntity.id);
30812
+ await handleUpdateLegalEntity(updatedParentLegalEntity, parentLegalEntity.id);
31220
30813
  };
31221
- const formatDataForSummary2 = (data2, forms2) => {
31222
- var _a, _b, _c, _d, _e, _f, _g, _h;
31223
- let summaryData = cloneObject(data2);
31224
- let trustCountry;
31225
- let trustType2;
31226
- if ((_a = summaryData == null ? void 0 : summaryData.trustRegistrationDetails) == null ? void 0 : _a.country) {
31227
- trustCountry = datasetUtils.getCountryName(summaryData.trustRegistrationDetails.country);
30814
+ const formatDataForSummary2 = (data2, forms22) => {
30815
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
30816
+ let summaryData = cloneObject(data2) || {};
30817
+ if (summaryData == null ? void 0 : summaryData.trustRegistrationDetails) {
30818
+ const trustCountry = ((_a2 = summaryData == null ? void 0 : summaryData.trustRegistrationDetails) == null ? void 0 : _a2.country) ? datasetUtils.getCountryName(summaryData.trustRegistrationDetails.country) : void 0;
30819
+ const trustType2 = ((_b = summaryData == null ? void 0 : summaryData.trustRegistrationDetails) == null ? void 0 : _b.trustType) ? i18n.get((_c = trustTypeOptions.find((trustType22) => {
30820
+ var _a3;
30821
+ return trustType22.id === ((_a3 = summaryData.trustRegistrationDetails) == null ? void 0 : _a3.trustType);
30822
+ })) == null ? void 0 : _c.name) : void 0;
30823
+ summaryData.trustRegistrationDetails = {
30824
+ nameOfTrustAgreement: (_d = summaryData == null ? void 0 : summaryData.trustRegistrationDetails) == null ? void 0 : _d.legalName,
30825
+ countryOfEstablishment: trustCountry,
30826
+ typeOfTrustAgreement: trustType2,
30827
+ objectOfTrust: (_e = summaryData == null ? void 0 : summaryData.trustRegistrationDetails) == null ? void 0 : _e.objectOfTrust,
30828
+ taxId: (_f = summaryData == null ? void 0 : summaryData.trustRegistrationDetails) == null ? void 0 : _f.taxId
30829
+ };
31228
30830
  }
31229
- if ((_b = summaryData == null ? void 0 : summaryData.trustRegistrationDetails) == null ? void 0 : _b.trustType) {
31230
- const selectedTrustType = (_c = trustTypeOptions.find((trustType22) => {
31231
- var _a2;
31232
- return trustType22.id === ((_a2 = summaryData.trustRegistrationDetails) == null ? void 0 : _a2.trustType);
31233
- })) == null ? void 0 : _c.name;
31234
- trustType2 = i18n.get(selectedTrustType);
31235
- }
31236
- summaryData.trustRegistrationDetails = {
31237
- nameOfTrustAgreement: (_d = data2.trustRegistrationDetails) == null ? void 0 : _d.legalName,
31238
- countryOfEstablishment: trustCountry,
31239
- typeOfTrustAgreement: trustType2,
31240
- objectOfTrust: (_e = data2.trustRegistrationDetails) == null ? void 0 : _e.objectOfTrust,
31241
- taxId: (_f = data2.trustRegistrationDetails) == null ? void 0 : _f.taxId
31242
- };
31243
30831
  if ((_g = summaryData == null ? void 0 : summaryData.trustRegistrationAddress) == null ? void 0 : _g.registrationAddress) {
31244
30832
  summaryData.trustRegistrationAddress.hasInnerForms = true;
31245
30833
  summaryData.trustRegistrationAddress.registrationAddress = mapAddressLabels(summaryData == null ? void 0 : summaryData.trustRegistrationAddress.registrationAddress, datasetUtils);
@@ -31247,18 +30835,18 @@ function TrustDropinComponent(props) {
31247
30835
  if ((_h = summaryData == null ? void 0 : summaryData.trustRegistrationAddress) == null ? void 0 : _h.operationalAddress) {
31248
30836
  summaryData.trustRegistrationAddress.operationalAddress = mapAddressLabels(summaryData == null ? void 0 : summaryData.trustRegistrationAddress.operationalAddress, datasetUtils);
31249
30837
  }
31250
- if (isDocumentsRequired2(forms2)) {
30838
+ if (isDocumentsRequired2(forms22)) {
31251
30839
  delete summaryData[trustConstitutionalDocumentFormId];
31252
30840
  summaryData = {
31253
30841
  ...summaryData,
31254
- ...formatFileSummaryData2(data2.trustConstitutionalDocument)
30842
+ ...formatFileSummaryData2(summaryData == null ? void 0 : summaryData.trustConstitutionalDocument)
31255
30843
  };
31256
30844
  }
31257
30845
  return summaryData;
31258
30846
  };
31259
30847
  const formatFileSummaryData2 = (trustConstitutionalDocument) => {
31260
- var _a;
31261
- const constitutionalDocument2 = (_a = trustConstitutionalDocument == null ? void 0 : trustConstitutionalDocument.constitutionalDocument) == null ? void 0 : _a[0];
30848
+ var _a2;
30849
+ const constitutionalDocument2 = (_a2 = trustConstitutionalDocument == null ? void 0 : trustConstitutionalDocument.constitutionalDocument) == null ? void 0 : _a2[0];
31262
30850
  return {
31263
30851
  ...constitutionalDocument2 && {
31264
30852
  trustConstitutionalDocument: {
@@ -31271,28 +30859,59 @@ function TrustDropinComponent(props) {
31271
30859
  const value = getProp(data2, detail);
31272
30860
  return !isEmpty(value);
31273
30861
  });
31274
- return jsx(StateProvider, {
31275
- defaultData: data,
31276
- children: jsx(TrustWithFormComposer, {
31277
- capabilities: props.capabilities,
30862
+ const baseTrackingPayload = getBaseTrackingPayload({
30863
+ trackingConfig,
30864
+ parentLegalEntity,
30865
+ legalEntity: legalEntityResponse,
30866
+ task: taskType
30867
+ });
30868
+ const {
30869
+ handleNextClick,
30870
+ handleBackClick,
30871
+ activeForm,
30872
+ shouldValidate,
30873
+ setShouldValidate,
30874
+ gotoFormByFormIndex,
30875
+ nextButtonLabel
30876
+ } = useFormComposer({
30877
+ problems,
30878
+ baseTrackingPayload,
30879
+ forms: forms2,
30880
+ formRef,
30881
+ onSubmit
30882
+ });
30883
+ return jsx(FormWrapper, {
30884
+ taskName: "trustDetails",
30885
+ handleNextClick,
30886
+ handleBackClick,
30887
+ gotoFormByFormIndex,
30888
+ nextButtonLabel,
30889
+ loadingStatus,
30890
+ forms: forms2,
30891
+ activeForm,
30892
+ baseTrackingPayload,
30893
+ onSubmit,
30894
+ hideDropinLayout,
30895
+ handleHomeClick,
30896
+ homeButtonLabel,
30897
+ validateForm: () => setShouldValidate(true),
30898
+ canSubmit: canSubmit2(data) && hasDataChanged(dataFromResponse, data),
30899
+ problems,
30900
+ summary: {
30901
+ data: formatDataForSummary2(data, forms2),
30902
+ omittedKeys: ["operationalAddressIsSame"]
30903
+ },
30904
+ children: jsx(TrustComponent, {
30905
+ ...derivedProps,
30906
+ activeForm,
30907
+ capabilities,
31278
30908
  data,
31279
- country: props.country,
30909
+ country: ((_a = data == null ? void 0 : data.trustRegistrationDetails) == null ? void 0 : _a.country) ?? country2,
31280
30910
  problems,
31281
- eventEmitter: props.eventEmitter,
31282
- hideDropinLayout: props.hideDropinLayout,
31283
- onChange: props.onChange,
31284
- handleHomeClick: props.handleHomeClick,
31285
- homeButtonLabel: props.homeButtonLabel,
31286
- onSubmit,
31287
- legalEntityType: LegalEntityType.TRUST,
31288
- legalEntityResponse,
31289
- summary: {
31290
- formatData: formatDataForSummary2,
31291
- getOmittedKeys
31292
- },
31293
- canSubmit: canSubmit2,
31294
30911
  handleAddressSearch,
31295
- handleFindAddress
30912
+ handleFindAddress,
30913
+ shouldValidate,
30914
+ ref: formRef
31296
30915
  })
31297
30916
  });
31298
30917
  }
@@ -31310,7 +30929,7 @@ function DropinComposerComponent({
31310
30929
  onNavigate = noop,
31311
30930
  ...args
31312
30931
  }) {
31313
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
30932
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
31314
30933
  const {
31315
30934
  contextCountry,
31316
30935
  accountHolder: accountHolder2,
@@ -32204,7 +31823,7 @@ function DropinComposerComponent({
32204
31823
  onSubmit: componentOnSubmit,
32205
31824
  handleHomeClick: navigateBack,
32206
31825
  homeButtonLabel: i18n.get("saveAndGoToOverview"),
32207
- country: (_l = (_k = rootLegalEntity == null ? void 0 : rootLegalEntity.individual) == null ? void 0 : _k.residentialAddress) == null ? void 0 : _l.country,
31826
+ 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,
32208
31827
  handleAddressSearch: args == null ? void 0 : args.handleAddressSearch,
32209
31828
  handleFindAddress: args == null ? void 0 : args.handleFindAddress
32210
31829
  });
@@ -32795,6 +32414,64 @@ const AuthProvider = ({
32795
32414
  children
32796
32415
  });
32797
32416
  };
32417
+ const fontFormats = ["eot", "woff", "woff2", "ttf", "otf"];
32418
+ const formatFullNames = {
32419
+ eot: "embedded-opentype",
32420
+ woff: "woff",
32421
+ woff2: "woff2",
32422
+ ttf: "truetype",
32423
+ otf: "opentype"
32424
+ };
32425
+ const getFontFaceRule = (fontFamily, fontStyle, fontWeight, fontPath, formats) => {
32426
+ const fontSources = formats.map((format) => `url(${fontPath}.${format}) format(${formatFullNames[format]})`);
32427
+ const ruleLines = [`font-family: '${fontFamily}'`, `font-style: ${fontStyle}`, `font-weight: ${fontWeight}`, `src: ${fontSources.join(",")}`];
32428
+ return `@font-face {${ruleLines.join(";")}}`;
32429
+ };
32430
+ const addStyleTagForFont = (fontFamily, fontStyle, fontWeight, fontPath, formats) => {
32431
+ const style = document.createElement("style");
32432
+ style.setAttribute("type", "text/css");
32433
+ style.innerText = getFontFaceRule(fontFamily, fontStyle, fontWeight, fontPath, formats);
32434
+ document.head.insertBefore(style, document.head.firstChild);
32435
+ };
32436
+ const addStyleTagForADLIconFont = (loadingContext) => {
32437
+ const fontPath = `${loadingContext}static/fonts`;
32438
+ const iconFontPath = `${fontPath}/adyen-kyc-icons`;
32439
+ addStyleTagForFont("adyen-kyc-icons", "normal", "normal", iconFontPath, fontFormats);
32440
+ };
32441
+ let isFlagsLoaded = false;
32442
+ let isDocumentGuidanceLoaded = false;
32443
+ const getIconContainer = () => {
32444
+ const container = document.createElement("div");
32445
+ container.setAttribute("aria-hidden", "true");
32446
+ container.setAttribute("id", "adl-icon-container");
32447
+ container.style.height = "0";
32448
+ return container;
32449
+ };
32450
+ const buildSpriteDOMFromResponse = (responseData) => {
32451
+ const iconContainer = getIconContainer();
32452
+ iconContainer.innerHTML = responseData;
32453
+ return iconContainer;
32454
+ };
32455
+ const loadFlags = async (loadingContext) => {
32456
+ if (isFlagsLoaded)
32457
+ return;
32458
+ isFlagsLoaded = true;
32459
+ const responseData = await http({
32460
+ loadingContext,
32461
+ path: "static/images/country-flags.svg"
32462
+ }, null, "text");
32463
+ document.body.insertBefore(buildSpriteDOMFromResponse(responseData), document.body.firstChild);
32464
+ };
32465
+ const loadDocumentGuidance = async (loadingContext) => {
32466
+ if (isDocumentGuidanceLoaded)
32467
+ return;
32468
+ isDocumentGuidanceLoaded = true;
32469
+ const responseData = await http({
32470
+ loadingContext,
32471
+ path: "static/images/document-guidance.svg"
32472
+ }, null, "text");
32473
+ document.body.insertBefore(buildSpriteDOMFromResponse(responseData), document.body.firstChild);
32474
+ };
32798
32475
  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-12ed2cb9.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") });
32799
32476
  const getAccountFormatsForCountry = async (country2) => {
32800
32477
  const importForCountry = accountFormatsImports[`./${country2}.json`];
@@ -33243,6 +32920,182 @@ function SettingsContextProvider({
33243
32920
  children
33244
32921
  });
33245
32922
  }
32923
+ function removeObjectPropsWithEmptyValues(obj) {
32924
+ keysOf(obj).forEach((key) => {
32925
+ if (obj[key] === null || isEmpty(obj[key]))
32926
+ delete obj[key];
32927
+ });
32928
+ return obj;
32929
+ }
32930
+ const INITIAL_STATE = {
32931
+ data: {},
32932
+ allData: {},
32933
+ initialData: {},
32934
+ errors: {},
32935
+ valid: {},
32936
+ fieldProblems: {},
32937
+ isValid: false
32938
+ };
32939
+ function StateReducer() {
32940
+ const [schemas, setSchemas] = useState({});
32941
+ const [activeForms, setActiveForms] = useState([]);
32942
+ const setCurrentForms = (forms2) => {
32943
+ setActiveForms(forms2);
32944
+ };
32945
+ function reducer2({
32946
+ currentState: currState
32947
+ }, action) {
32948
+ var _a, _b, _c;
32949
+ switch (action.type) {
32950
+ case "addToState": {
32951
+ const state2 = structuredClone(currState);
32952
+ const dataStoreId = action.value.dataStoreId ?? action.value.caller;
32953
+ const schema = action.value.schema || null;
32954
+ const schemaHasChanged = schema && ((_a = schemas == null ? void 0 : schemas[dataStoreId]) == null ? void 0 : _a.toString()) !== schema.toString();
32955
+ const mergedState = {
32956
+ ...state2,
32957
+ data: {
32958
+ ...state2.data,
32959
+ [dataStoreId]: {
32960
+ ...state2.data[dataStoreId],
32961
+ ...action.value.data
32962
+ }
32963
+ },
32964
+ // Add data in allData state prop in case we will need them later
32965
+ allData: {
32966
+ ...state2.allData,
32967
+ [dataStoreId]: {
32968
+ ...state2.allData[dataStoreId],
32969
+ ...removeObjectPropsWithEmptyValues(action.value.data)
32970
+ }
32971
+ },
32972
+ errors: {
32973
+ ...state2.errors,
32974
+ [dataStoreId]: {
32975
+ ...state2.errors[dataStoreId],
32976
+ ...action.value.errors
32977
+ }
32978
+ },
32979
+ valid: {
32980
+ ...state2.valid,
32981
+ [dataStoreId]: {
32982
+ ...state2.valid[dataStoreId],
32983
+ ...action.value.valid
32984
+ }
32985
+ },
32986
+ fieldProblems: {
32987
+ ...state2.fieldProblems,
32988
+ [dataStoreId]: {
32989
+ ...state2.fieldProblems[dataStoreId],
32990
+ ...action.value.fieldProblems
32991
+ }
32992
+ }
32993
+ };
32994
+ if (schemaHasChanged) {
32995
+ setSchemas({
32996
+ ...schemas,
32997
+ [dataStoreId]: schema
32998
+ });
32999
+ const processedBySchema = schema.reduce((acc, fieldKey) => {
33000
+ const dataObjByFormId = mergedState.data[dataStoreId];
33001
+ const allDataObjByFormId = mergedState.allData[dataStoreId];
33002
+ const validObjByFormId = mergedState.valid[dataStoreId];
33003
+ const errorsObjByFormId = mergedState.errors[dataStoreId];
33004
+ const fieldProblemsObjByFormId = mergedState.fieldProblems[dataStoreId];
33005
+ return {
33006
+ data: {
33007
+ ...acc.data,
33008
+ [fieldKey]: dataObjByFormId[fieldKey] ?? allDataObjByFormId[fieldKey]
33009
+ },
33010
+ valid: {
33011
+ ...acc.valid,
33012
+ [fieldKey]: validObjByFormId[fieldKey]
33013
+ },
33014
+ errors: {
33015
+ ...acc.errors,
33016
+ [fieldKey]: errorsObjByFormId[fieldKey]
33017
+ },
33018
+ fieldProblems: {
33019
+ ...acc.fieldProblems,
33020
+ [fieldKey]: fieldProblemsObjByFormId[fieldKey]
33021
+ }
33022
+ };
33023
+ }, {
33024
+ data: {},
33025
+ valid: {},
33026
+ errors: {},
33027
+ fieldProblems: {}
33028
+ });
33029
+ mergedState.data[dataStoreId] = processedBySchema.data;
33030
+ mergedState.valid[dataStoreId] = processedBySchema.valid;
33031
+ mergedState.errors[dataStoreId] = processedBySchema.errors;
33032
+ mergedState.fieldProblems[dataStoreId] = processedBySchema.fieldProblems;
33033
+ }
33034
+ mergedState.validityByForm = {
33035
+ ...mergedState.validityByForm,
33036
+ [dataStoreId]: Object.values(mergedState.valid[dataStoreId]).every((isValid) => isValid)
33037
+ };
33038
+ mergedState.allValid = Object.values(mergedState.validityByForm).every((isValid) => isValid);
33039
+ mergedState.isValid = !activeForms.length ? mergedState.allValid : activeForms.every((item) => mergedState.validityByForm[item]);
33040
+ mergedState.initialData = structuredClone(state2.initialData);
33041
+ return {
33042
+ currentState: mergedState,
33043
+ prevState: state2,
33044
+ changeInitiatedBy: dataStoreId
33045
+ };
33046
+ }
33047
+ case "resetState": {
33048
+ const dataStoreId = ((_b = action.value) == null ? void 0 : _b.dataStoreId) ?? ((_c = action.value) == null ? void 0 : _c.caller);
33049
+ return {
33050
+ currentState: INITIAL_STATE,
33051
+ prevState: currState,
33052
+ changeInitiatedBy: dataStoreId
33053
+ };
33054
+ }
33055
+ default: {
33056
+ throw new Error(`Unhandled action type: ${action.type}`);
33057
+ }
33058
+ }
33059
+ }
33060
+ return {
33061
+ reducer: reducer2,
33062
+ setCurrentForms
33063
+ };
33064
+ }
33065
+ function StateProvider({
33066
+ defaultData = {},
33067
+ children
33068
+ }) {
33069
+ const defaultState = {
33070
+ currentState: {
33071
+ data: defaultData,
33072
+ allData: defaultData,
33073
+ valid: {},
33074
+ errors: {},
33075
+ fieldProblems: {},
33076
+ validityByForm: {},
33077
+ initialData: defaultData
33078
+ },
33079
+ prevState: {},
33080
+ changeInitiatedBy: null
33081
+ };
33082
+ const reducerObj = StateReducer();
33083
+ const [state2, dispatch] = useReducer(reducerObj.reducer, defaultState);
33084
+ const contextValue = useMemo(() => ({
33085
+ state: state2,
33086
+ dispatch,
33087
+ setActiveForms: reducerObj.setCurrentForms,
33088
+ getData: () => {
33089
+ var _a;
33090
+ return ((_a = state2 == null ? void 0 : state2.currentState) == null ? void 0 : _a.data) ?? {};
33091
+ },
33092
+ getState: () => state2 == null ? void 0 : state2.currentState
33093
+ }), [reducerObj, state2]);
33094
+ return jsx(StateContext.Provider, {
33095
+ value: contextValue,
33096
+ children
33097
+ });
33098
+ }
33246
33099
  function ToastContextProvider({
33247
33100
  children
33248
33101
  }) {