@adyen/kyc-components 2.49.0 → 2.49.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@ import { useContext, useState, useCallback, useEffect, useMemo, useReducer, useR
2
2
  import { createContext, isValidElement, createElement, render } from "preact";
3
3
  import { sanitize } from "isomorphic-dompurify";
4
4
  import cx from "classnames";
5
- import { lazy, Suspense, useId, forwardRef, memo, useMemo as useMemo$1, useEffect as useEffect$1, useState as useState$1 } from "preact/compat";
5
+ import { lazy, Suspense, useId, forwardRef, memo, useMemo as useMemo$1, useEffect as useEffect$1, useState as useState$1, useCallback as useCallback$1 } from "preact/compat";
6
6
  import { jsx, jsxs, Fragment } from "preact/jsx-runtime";
7
7
  import debounce from "lodash-es/debounce";
8
8
  import isISIN from "validator/es/lib/isISIN.js";
@@ -7343,27 +7343,6 @@ const CompanyNameAndCountryComponent = memo(CompanyNameAndCountry, (prevProps, n
7343
7343
  var _a, _b;
7344
7344
  return objectsDeepEqual(prevProps.requiredFields, nextProps.requiredFields) && objectsDeepEqual(prevProps.optionalFields, nextProps.optionalFields) && objectsDeepEqual(prevProps.data, nextProps.data) && objectsDeepEqual(prevProps.formVerificationErrors, nextProps.formVerificationErrors) && objectsDeepEqual(prevProps.fieldValidationErrors, nextProps.fieldValidationErrors) && ((_a = prevProps.data) == null ? void 0 : _a.country) === ((_b = nextProps.data) == null ? void 0 : _b.country) && prevProps.shouldValidate === nextProps.shouldValidate;
7345
7345
  });
7346
- function StateContextSetter({
7347
- stateRef
7348
- }) {
7349
- if (stateRef.current.setState) {
7350
- return null;
7351
- }
7352
- return jsx(StateContext.Consumer, {
7353
- children: (stateContextValue) => {
7354
- if (!stateContextValue) {
7355
- throw new Error("<StateContextSetter> needs to be mounted inside a <StateProvider>");
7356
- }
7357
- const {
7358
- dispatch,
7359
- setActiveForms
7360
- } = stateContextValue;
7361
- stateRef.current.setState = dispatch;
7362
- stateRef.current.setActiveForms = setActiveForms;
7363
- return null;
7364
- }
7365
- });
7366
- }
7367
7346
  var CompanyTypesValue = /* @__PURE__ */ ((CompanyTypesValue2) => {
7368
7347
  CompanyTypesValue2["PRIVATE_COMPANY"] = "privateCompany";
7369
7348
  CompanyTypesValue2["PUBLIC_COMPANY"] = "listedPublicCompany";
@@ -7375,22 +7354,12 @@ var CompanyTypesValue = /* @__PURE__ */ ((CompanyTypesValue2) => {
7375
7354
  CompanyTypesValue2["SOLE_PROPRIETORSHIP"] = "soleProprietorship";
7376
7355
  return CompanyTypesValue2;
7377
7356
  })(CompanyTypesValue || {});
7378
- const cachedStripPatterns = /* @__PURE__ */ new Map();
7379
- const makeStripPattern = (mask) => {
7380
- const inputPatterns = mask.tokens.filter((token) => token.type === "input" && !!token.allow).map((token) => token.allow);
7381
- const nonInputChars = mask.tokens.filter((token) => token.type === "nonInput" && !token.includeInValue).map((token) => token.char);
7382
- const strippedChars = [...new Set(nonInputChars.filter((char) => !inputPatterns.some((pattern) => pattern.test(char))))];
7383
- const stripPattern = new RegExp(`[${strippedChars.join("")}]`, "g");
7384
- cachedStripPatterns.set(mask, stripPattern);
7385
- return stripPattern;
7386
- };
7387
- const displayValueToPureValue = (displayValue, mask) => {
7388
- const stripPattern = cachedStripPatterns.get(mask) ?? makeStripPattern(mask);
7389
- return displayValue.replaceAll(stripPattern, "");
7390
- };
7391
- const isValueObscured = (value) => {
7392
- var _a;
7393
- return typeof value === "string" && !!((_a = value.match(/[*]{1,}/)) == null ? void 0 : _a.length);
7357
+ const makeArrayOfRepeatedObjects = (length, obj) => {
7358
+ const array = [];
7359
+ for (let i = 0; i < length; i += 1) {
7360
+ array.push(cloneObject(obj));
7361
+ }
7362
+ return array;
7394
7363
  };
7395
7364
  const shiftRight = (possibleShifts, matchedTokens, remainingTokens) => {
7396
7365
  let shiftsToTry = [...possibleShifts];
@@ -7487,583 +7456,6 @@ const tryShift = (matchedTokens, remainingTokens, fromIndex, shiftDistance) => {
7487
7456
  remainingTokens: newRemainingTokens
7488
7457
  };
7489
7458
  };
7490
- const getAvailableInputTokens = (tokens) => {
7491
- const availableTokens = [];
7492
- for (const token of tokens) {
7493
- if (token.type === "nonInput") {
7494
- if (token.includeInValue) {
7495
- availableTokens.push({
7496
- ...token,
7497
- offset: tokens.indexOf(token)
7498
- });
7499
- }
7500
- continue;
7501
- }
7502
- availableTokens.push({
7503
- ...token,
7504
- offset: tokens.indexOf(token)
7505
- });
7506
- if (token.type !== "input" || !token.optional) break;
7507
- }
7508
- return availableTokens;
7509
- };
7510
- const findMatchingToken = (tokensWithOffset, char) => tokensWithOffset.find((token) => token.type === "nonInput" || !token.allow || token.allow.test(char)) ?? null;
7511
- const getEagerSuffix = (tokens) => {
7512
- let suffix = "";
7513
- for (const token of tokens) {
7514
- if (token.type === "input") {
7515
- if (token.optional) continue;
7516
- else break;
7517
- }
7518
- if (!token.displayEagerly) break;
7519
- suffix += token.char;
7520
- }
7521
- return suffix;
7522
- };
7523
- const getPotentialForMoreOptionalInput = (tokens) => tokens.some((token) => token.type === "input" && token.optional);
7524
- const matchAgainstMask = (pureValue, mask, acceptObscuredValue = false) => {
7525
- let tokensToProcess = [...mask.tokens];
7526
- let charsToProcess = pureValue;
7527
- let charIndex = 0;
7528
- let matchedTokens = [];
7529
- if (acceptObscuredValue && isValueObscured(pureValue)) {
7530
- return {
7531
- outcome: "obscureCorrect",
7532
- displayValue: pureValue
7533
- };
7534
- }
7535
- const shiftChars = (increment) => {
7536
- charIndex += increment;
7537
- charsToProcess = charsToProcess.slice(increment);
7538
- };
7539
- const shiftTokens = (increment) => {
7540
- tokensToProcess = tokensToProcess.slice(increment);
7541
- };
7542
- const displayValue = () => matchedTokens.map((token) => token.char).join("");
7543
- while (true) {
7544
- const char = charsToProcess[0];
7545
- const token = tokensToProcess[0];
7546
- if (!char && !tokensToProcess.some((t) => t.type === "input" && !t.optional)) return {
7547
- outcome: "correct",
7548
- displayValue: displayValue() + getEagerSuffix(tokensToProcess),
7549
- potentialForMoreOptionalInput: getPotentialForMoreOptionalInput(tokensToProcess)
7550
- };
7551
- if (!char) {
7552
- const output = shiftRight(mask.possibleShifts, matchedTokens, tokensToProcess);
7553
- matchedTokens = output.matchedTokens;
7554
- tokensToProcess = output.remainingTokens;
7555
- return {
7556
- outcome: "partialCorrect",
7557
- displayValue: displayValue() + getEagerSuffix(tokensToProcess)
7558
- };
7559
- }
7560
- if (!token) return {
7561
- outcome: "mismatch",
7562
- badChar: char,
7563
- mismatchAtChar: charIndex,
7564
- mismatchedToken: "inputTooLong",
7565
- partialDisplayValue: displayValue()
7566
- };
7567
- if (token.type === "nonInput") {
7568
- if (token.includeInValue) {
7569
- if (char !== token.char) return {
7570
- outcome: "mismatch",
7571
- badChar: char,
7572
- mismatchAtChar: charIndex,
7573
- mismatchedToken: token,
7574
- partialDisplayValue: displayValue()
7575
- };
7576
- shiftChars(1);
7577
- }
7578
- matchedTokens.push(token);
7579
- shiftTokens(1);
7580
- }
7581
- if (token.type === "input") {
7582
- const availableTokens = getAvailableInputTokens(tokensToProcess);
7583
- const matchingToken = findMatchingToken(availableTokens, char);
7584
- if (!matchingToken) return {
7585
- outcome: "mismatch",
7586
- badChar: char,
7587
- mismatchAtChar: charIndex,
7588
- mismatchedToken: token,
7589
- partialDisplayValue: displayValue()
7590
- };
7591
- matchedTokens.push({
7592
- ...matchingToken,
7593
- char
7594
- });
7595
- shiftTokens(matchingToken.offset + 1);
7596
- shiftChars(1);
7597
- }
7598
- }
7599
- };
7600
- const deriveInputState = (isValid, isFocused, isDisabled, isOptional, hasNullishValue, hasBlurred, errorMessage, shouldValidate, potentiallyMoreOptionalCharacters, formatGuidance, i18n) => {
7601
- if (isDisabled) return {
7602
- isError: false
7603
- };
7604
- if (isOptional && hasNullishValue) {
7605
- return {
7606
- isError: false
7607
- };
7608
- }
7609
- if (isValid && (!potentiallyMoreOptionalCharacters || !isFocused)) return {
7610
- isError: false,
7611
- text: jsxs(Fragment, {
7612
- children: [jsx(Icon, {
7613
- name: "checkmark-small",
7614
- className: "adyen-kyc-helper-text__valid-format-check"
7615
- }), i18n.get("formatIsCorrect")]
7616
- })
7617
- };
7618
- if (isFocused && formatGuidance) return {
7619
- isError: false,
7620
- text: formatGuidance
7621
- };
7622
- if (!isValid && (shouldValidate || hasBlurred)) return {
7623
- isError: true,
7624
- text: typeof errorMessage === "string" && errorMessage ? errorMessage : formatGuidance
7625
- };
7626
- return {
7627
- isError: false
7628
- };
7629
- };
7630
- const MISMATCH_ANIMATION_NAME = "mismatchShake";
7631
- const logger$z = createLogger("MaskedInputText");
7632
- const MaskedInputText = ({
7633
- value,
7634
- onInput,
7635
- onBlur,
7636
- onMismatch: onMismatchExternal,
7637
- isValid: validationIsValid,
7638
- errorMessage,
7639
- shouldValidate,
7640
- mask,
7641
- name,
7642
- label,
7643
- placeholder,
7644
- transformOnType,
7645
- readonly = false,
7646
- disabled = false,
7647
- optional: optional2 = false,
7648
- formatGuidance,
7649
- classNameModifiers,
7650
- acceptObscuredValue = false
7651
- }) => {
7652
- const hasExistingData = !isEmpty(value);
7653
- const [isFocused, setIsFocused] = useState(false);
7654
- const [hasBlurred, setHasBlurred] = useState(hasExistingData);
7655
- const [caretReturnPosition, setCaretReturnPosition] = useState(null);
7656
- const inputRef = useRef(null);
7657
- const [showingMismatch, setShowingMismatch] = useState(false);
7658
- const {
7659
- i18n
7660
- } = useI18nContext();
7661
- const onMismatch = (mismatch) => {
7662
- if (!inputRef.current) return;
7663
- setShowingMismatch(true);
7664
- inputRef.current.addEventListener("animationend", (event) => {
7665
- if (event.animationName !== MISMATCH_ANIMATION_NAME) return;
7666
- setShowingMismatch(false);
7667
- });
7668
- onMismatchExternal == null ? void 0 : onMismatchExternal(mismatch);
7669
- };
7670
- useEffect(() => {
7671
- if (!mask) {
7672
- logger$z.warn("`mask` is undefined. No masking of input will take place.");
7673
- }
7674
- }, [mask]);
7675
- const getMaskResult = useCallback((pureValue) => {
7676
- if (!mask) return {
7677
- outcome: "partialCorrect",
7678
- displayValue: pureValue
7679
- };
7680
- return matchAgainstMask(transformOnType ? transformOnType(pureValue) : pureValue, mask, acceptObscuredValue);
7681
- }, [mask, transformOnType, acceptObscuredValue]);
7682
- const displayValueToPure = useCallback((displayValue2) => {
7683
- if (!mask) return displayValue2;
7684
- return displayValueToPureValue(displayValue2, mask);
7685
- }, [mask]);
7686
- const maskResult = useMemo(() => getMaskResult(value), [getMaskResult, value]);
7687
- const displayValue = maskResult.outcome === "mismatch" ? maskResult.partialDisplayValue : maskResult.displayValue;
7688
- const inputState = deriveInputState(validationIsValid && maskResult.outcome !== "mismatch", isFocused, disabled, optional2, !displayValue, hasBlurred, errorMessage, shouldValidate, maskResult.outcome === "correct" && !!maskResult.potentialForMoreOptionalInput, formatGuidance, i18n);
7689
- useEffect(() => {
7690
- if (mask && maskResult.outcome === "mismatch") {
7691
- const strippedValue = displayValueToPure(value);
7692
- if (getMaskResult(strippedValue).outcome !== "mismatch") {
7693
- onInput(strippedValue);
7694
- return;
7695
- }
7696
- const fallback = displayValueToPure(maskResult.partialDisplayValue);
7697
- logger$z.warn(`Value received "${value}" does not match mask`, maskResult, `
7698
- Falling back to partially valid value "${fallback}"`);
7699
- onInput(fallback);
7700
- }
7701
- }, [mask, maskResult, value, onInput, displayValueToPure, getMaskResult]);
7702
- useLayoutEffect(() => {
7703
- if (caretReturnPosition && inputRef.current && caretReturnPosition !== inputRef.current.selectionStart) {
7704
- inputRef.current.setSelectionRange(caretReturnPosition, caretReturnPosition, "none");
7705
- setCaretReturnPosition(null);
7706
- }
7707
- }, [caretReturnPosition]);
7708
- const handleInput = (event) => {
7709
- const inputEl = event.target;
7710
- const newPureValue = displayValueToPure(inputEl.value);
7711
- const newMaskResult = getMaskResult(newPureValue);
7712
- const returnCaretLater = (offset = 0) => {
7713
- if (!inputEl.selectionStart) return;
7714
- setCaretReturnPosition(inputEl.selectionStart + offset);
7715
- };
7716
- const cancelInput = () => {
7717
- returnCaretLater(-1);
7718
- inputEl.value = displayValue;
7719
- event.preventDefault();
7720
- event.stopPropagation();
7721
- };
7722
- if (newMaskResult.outcome === "mismatch") {
7723
- cancelInput();
7724
- onMismatch(newMaskResult);
7725
- return;
7726
- }
7727
- if (inputEl.selectionStart && inputEl.selectionStart < inputEl.value.length) {
7728
- returnCaretLater();
7729
- }
7730
- inputEl.value = newMaskResult.displayValue;
7731
- onInput(newPureValue);
7732
- };
7733
- return jsx(Field, {
7734
- name,
7735
- label,
7736
- isValid: !inputState.isError,
7737
- errorMessage: inputState.isError ? inputState.text ?? true : void 0,
7738
- helper: inputState.isError ? void 0 : inputState.text,
7739
- helperPosition: "below",
7740
- classNameModifiers: classNameModifiers == null ? void 0 : classNameModifiers.field,
7741
- disabled,
7742
- optional: optional2,
7743
- children: ({
7744
- onBlurHandler: fieldOnBlur,
7745
- onFocusHandler: fieldOnFocus,
7746
- ...childProps
7747
- }) => jsx(InputText, {
7748
- ...childProps,
7749
- value: displayValue,
7750
- onInput: handleInput,
7751
- onPaste: (event) => {
7752
- var _a;
7753
- const pasteValue = (_a = event.clipboardData) == null ? void 0 : _a.getData("text/plain");
7754
- const inputEl = event.target;
7755
- const {
7756
- selectionStart,
7757
- selectionEnd
7758
- } = inputEl;
7759
- if (!pasteValue || !selectionStart || selectionStart !== selectionEnd) return;
7760
- const pureDisplayValue = displayValueToPure(displayValue);
7761
- const purePasteValue = displayValueToPure(pasteValue);
7762
- const newPureValue = pureDisplayValue.slice(0, selectionStart) + purePasteValue + pureDisplayValue.slice(selectionStart);
7763
- if (newPureValue.startsWith(pureDisplayValue + pureDisplayValue)) {
7764
- const withPrefixRemoved = newPureValue.replace(pureDisplayValue, "");
7765
- event.preventDefault();
7766
- handleInput({
7767
- ...event,
7768
- target: {
7769
- ...event.target,
7770
- value: withPrefixRemoved
7771
- }
7772
- });
7773
- }
7774
- },
7775
- onKeyDown: (event) => {
7776
- const inputEl = event.target;
7777
- const isCaretAtEndWithNoSelection = inputEl.selectionStart === inputEl.value.length && inputEl.selectionStart === inputEl.selectionEnd;
7778
- if (event.key !== KEYBOARD_KEYS.backspace || !isCaretAtEndWithNoSelection) return;
7779
- event.preventDefault();
7780
- const withLastCharRemoved = value.slice(0, value.length - 1);
7781
- const newMaskResult = getMaskResult(withLastCharRemoved);
7782
- if (newMaskResult.outcome === "mismatch") {
7783
- inputEl.value = newMaskResult.partialDisplayValue;
7784
- onMismatch(newMaskResult);
7785
- } else {
7786
- inputEl.value = newMaskResult.displayValue;
7787
- onInput(withLastCharRemoved);
7788
- }
7789
- },
7790
- onFocusHandler: (event) => {
7791
- fieldOnFocus(event);
7792
- setIsFocused(true);
7793
- },
7794
- onBlurHandler: (event) => {
7795
- fieldOnBlur(event);
7796
- const eventWithProcessedValue = {
7797
- ...event,
7798
- target: {
7799
- ...event.target,
7800
- value: displayValueToPure(event.target.value)
7801
- }
7802
- };
7803
- onBlur == null ? void 0 : onBlur(eventWithProcessedValue);
7804
- setIsFocused(false);
7805
- setHasBlurred(true);
7806
- },
7807
- name,
7808
- readonly,
7809
- disabled,
7810
- placeholder,
7811
- classNameModifiers: [...(classNameModifiers == null ? void 0 : classNameModifiers.input) ?? [], ...showingMismatch ? ["mismatch"] : []],
7812
- "aria-required": true,
7813
- "aria-label": label,
7814
- "aria-invalid": inputState.isError,
7815
- "aria-placeholder": placeholder,
7816
- ref: inputRef
7817
- })
7818
- });
7819
- };
7820
- let idCounter = Date.now();
7821
- const getUniqueId = (prefix = "id") => {
7822
- idCounter += 1;
7823
- return `${prefix}-${idCounter}`;
7824
- };
7825
- const InputRadio = ({
7826
- className,
7827
- ...props
7828
- }) => jsx("input", {
7829
- ...props,
7830
- className: cx("adyen-kyc-input-radio__input", className)
7831
- });
7832
- function RadioGroup({
7833
- items = [],
7834
- name,
7835
- onChange = noop,
7836
- value,
7837
- isInvalid,
7838
- uniqueId,
7839
- className,
7840
- disabled = false,
7841
- horizontal = false
7842
- }) {
7843
- const {
7844
- i18n
7845
- } = useI18nContext();
7846
- const uniqueIdBase = uniqueId == null ? void 0 : uniqueId.replace(/[0-9]/g, "").substring(0, uniqueId.lastIndexOf("-"));
7847
- const classes = horizontal ? "adyen-kyc-radio-group adyen-kyc-radio-group--horizontal" : "adyen-kyc-radio-group";
7848
- return jsx("div", {
7849
- className: classes,
7850
- children: items.map((item) => {
7851
- const uniqueId2 = getUniqueId(uniqueIdBase);
7852
- return jsxs("label", {
7853
- htmlFor: uniqueId2,
7854
- className: "adyen-kyc-input-radio",
7855
- children: [jsx(InputRadio, {
7856
- id: uniqueId2,
7857
- type: "radio",
7858
- checked: value === item.id,
7859
- "aria-checked": value === item.id,
7860
- name,
7861
- onChange,
7862
- onClick: onChange,
7863
- value: item.id,
7864
- disabled
7865
- }), jsx("span", {
7866
- className: cx(["adyen-kyc-input-radio__label", "adyen-kyc-label__text", className, {
7867
- "adyen-kyc-radio-group__label--invalid": isInvalid
7868
- }]),
7869
- children: i18n.get(item.name)
7870
- })]
7871
- }, item.name || item.id);
7872
- })
7873
- });
7874
- }
7875
- const companyRegistrationNumberOptions = {
7876
- [CountryCodes.Poland]: [{
7877
- id: "regon",
7878
- name: "regon"
7879
- }, {
7880
- id: "krsNumber",
7881
- name: "krsNumber"
7882
- }],
7883
- [CountryCodes.Italy]: [{
7884
- id: "partitaIVA",
7885
- name: "partitaIVA"
7886
- }, {
7887
- id: "CCIAA",
7888
- name: "CCIAA"
7889
- }],
7890
- [CountryCodes.Austria]: [{
7891
- id: "firmenbuchnummer",
7892
- name: "firmenbuchnummer"
7893
- }, {
7894
- id: "ZVR",
7895
- name: "zentralesVereinsregisterId",
7896
- applicableOnlyFor: [CompanyTypesValue.NON_PROFIT_OR_CHARITABLE]
7897
- }],
7898
- [CountryCodes.France]: [{
7899
- id: "SIRET",
7900
- name: "siret"
7901
- }, {
7902
- id: "RNA",
7903
- name: "rnaNumber",
7904
- applicableOnlyFor: [CompanyTypesValue.NON_PROFIT_OR_CHARITABLE]
7905
- }],
7906
- [CountryCodes.NewZealand]: [{
7907
- id: "NZBN",
7908
- name: "NZBN"
7909
- }, {
7910
- id: "companyNumberNZ",
7911
- name: "companyNumberNZ",
7912
- applicableOnlyFor: [CompanyTypesValue.PRIVATE_COMPANY, CompanyTypesValue.PUBLIC_COMPANY, CompanyTypesValue.UNLISTED_PUBLIC_COMPANY]
7913
- }]
7914
- };
7915
- const getCompanyRegistrationNumberOptions = (country2, companyType2) => {
7916
- const optionsForCountry = companyRegistrationNumberOptions[country2];
7917
- if (!companyType2 || !optionsForCountry) return optionsForCountry;
7918
- return optionsForCountry.filter((option) => {
7919
- var _a;
7920
- return ((_a = option.applicableOnlyFor) == null ? void 0 : _a.includes(companyType2)) ?? true;
7921
- });
7922
- };
7923
- const individualIdNumberOptions = {
7924
- [CountryCodes.Spain]: [{
7925
- id: "dni",
7926
- name: "dni"
7927
- }, {
7928
- id: "nie",
7929
- name: "nie"
7930
- }]
7931
- };
7932
- const additionallIdNumberOptions = {
7933
- [CountryCodes.NewZealand]: [{
7934
- id: "driversLicense",
7935
- name: "driversLicense"
7936
- }, {
7937
- id: "passport",
7938
- name: "passportNumber"
7939
- }],
7940
- [CountryCodes.HongKong]: [{
7941
- id: "proofOfIdentityCard",
7942
- name: "stateIssuedProofOfIdentityCard"
7943
- }, {
7944
- id: "driversLicense",
7945
- name: "driversLicense"
7946
- }, {
7947
- id: "passport",
7948
- name: "passportNumber"
7949
- }],
7950
- [CountryCodes.Australia]: [{
7951
- id: "driversLicense",
7952
- name: "driversLicense"
7953
- }, {
7954
- id: "passport",
7955
- name: "passportNumber"
7956
- }]
7957
- };
7958
- const taxIdNumberOptions = {
7959
- [CountryCodes.Denmark]: [{
7960
- id: "momsregistreringsnummerCVR",
7961
- name: "momsregistreringsnummerCVR"
7962
- }, {
7963
- id: "stamregister",
7964
- name: "stamregister"
7965
- }],
7966
- [CountryCodes.France]: [{
7967
- id: "numeroDIdentificationALATaxe",
7968
- name: "numeroDIdentificationALATaxe"
7969
- }, {
7970
- id: "NumeroDeTVA",
7971
- name: "NumeroDeTVA"
7972
- }],
7973
- [CountryCodes.Singapore]: [{
7974
- id: "GST",
7975
- name: "gst"
7976
- }, {
7977
- id: "UEN",
7978
- name: "uen"
7979
- }],
7980
- [CountryCodes.Jersey]: [{
7981
- id: "taxIdentificationNumber",
7982
- name: "taxIdentificationNumber"
7983
- }, {
7984
- id: "socialSecurityNumber",
7985
- name: "socialSecurityNumber",
7986
- applicableOnlyFor: [CompanyTypesValue.SOLE_PROPRIETORSHIP]
7987
- }],
7988
- [CountryCodes.PuertoRico]: [{
7989
- id: "EIN",
7990
- name: "ein"
7991
- }, {
7992
- id: "SSN",
7993
- name: "ssn",
7994
- applicableOnlyFor: [CompanyTypesValue.SOLE_PROPRIETORSHIP]
7995
- }],
7996
- [CountryCodes.UnitedStates]: [{
7997
- id: "EIN",
7998
- name: "ein"
7999
- }, {
8000
- id: "SSN",
8001
- name: "ssn",
8002
- applicableOnlyFor: [CompanyTypesValue.SOLE_PROPRIETORSHIP]
8003
- }]
8004
- };
8005
- const getTaxIdNumberOptions = (country2, companyType2) => {
8006
- const optionsForCountry = taxIdNumberOptions[country2];
8007
- if (!companyType2 || !optionsForCountry) return optionsForCountry;
8008
- if (country2 === "US" || country2 === "PR") return optionsForCountry.filter((option) => option.id === "EIN");
8009
- return optionsForCountry.filter((option) => {
8010
- var _a;
8011
- return ((_a = option.applicableOnlyFor) == null ? void 0 : _a.includes(companyType2)) ?? true;
8012
- });
8013
- };
8014
- function CompanyRegistrationNumberTypeSelector({
8015
- country: country2,
8016
- companyType: companyType2,
8017
- selected,
8018
- setSelected,
8019
- exemptedOption
8020
- }) {
8021
- const {
8022
- i18n
8023
- } = useI18nContext();
8024
- const handleSelect = useCallback((selectedStr) => {
8025
- const newSelected = selectedStr;
8026
- if (newSelected === "exempted") {
8027
- if (exemptedOption) {
8028
- setSelected(newSelected);
8029
- }
8030
- return;
8031
- }
8032
- setSelected(newSelected);
8033
- }, [exemptedOption, setSelected]);
8034
- const options = useMemo(() => {
8035
- const availableOptions = getCompanyRegistrationNumberOptions(country2, companyType2) ?? [];
8036
- if (availableOptions.length === 0 || !exemptedOption) return availableOptions;
8037
- return [...availableOptions, {
8038
- id: "exempted",
8039
- name: exemptedOption
8040
- }];
8041
- }, [companyType2, country2, exemptedOption]);
8042
- useEffect(() => {
8043
- if (!selected && options.length > 0) {
8044
- setSelected(options[0].id);
8045
- }
8046
- }, [options, selected, setSelected]);
8047
- if (options.length <= 1) return null;
8048
- return jsx(Field, {
8049
- name: "companyRegistrationNumberType",
8050
- label: i18n.get("whichTypeOfRegistrationNumberDoYouHave"),
8051
- children: (childProps) => jsx(RadioGroup, {
8052
- ...childProps,
8053
- name: "companyRegistrationNumberType",
8054
- items: options,
8055
- value: selected,
8056
- onChange: (e) => handleSelect(e.target.value)
8057
- })
8058
- });
8059
- }
8060
- const makeArrayOfRepeatedObjects = (length, obj) => {
8061
- const array = [];
8062
- for (let i = 0; i < length; i += 1) {
8063
- array.push(cloneObject(obj));
8064
- }
8065
- return array;
8066
- };
8067
7459
  const nonInputs = (str, options) => Array.from(str).map((char) => ({
8068
7460
  type: "nonInput",
8069
7461
  char,
@@ -9934,154 +9326,685 @@ const defaultFieldConfig$9 = {
9934
9326
  }
9935
9327
  }
9936
9328
  };
9937
- }
9938
- },
9939
- [CountryCodes.UnitedStates]: ({
9940
- state: state2
9941
- }) => ({
9942
- label: "registrationNumber__US",
9943
- helperText: "registrationNumber__helperText__US",
9944
- mask: state2 ? businessRegistrationNumberMasks[CountryCodes.UnitedStates][state2] : businessRegistrationNumberMasks[CountryCodes.UnitedStates].default,
9945
- validators: state2 ? validatePatternOnBlur(businessRegistrationNumberPatterns[CountryCodes.UnitedStates][state2]) : validatePatternOnBlur(businessRegistrationNumberPatterns[CountryCodes.UnitedStates].default),
9946
- guidanceText: state2 ? stateFormatGuidanceText[state2] : stateFormatGuidanceText.default
9947
- })
9329
+ }
9330
+ },
9331
+ [CountryCodes.UnitedStates]: ({
9332
+ state: state2
9333
+ }) => ({
9334
+ label: "registrationNumber__US",
9335
+ helperText: "registrationNumber__helperText__US",
9336
+ mask: state2 ? businessRegistrationNumberMasks[CountryCodes.UnitedStates][state2] : businessRegistrationNumberMasks[CountryCodes.UnitedStates].default,
9337
+ validators: state2 ? validatePatternOnBlur(businessRegistrationNumberPatterns[CountryCodes.UnitedStates][state2]) : validatePatternOnBlur(businessRegistrationNumberPatterns[CountryCodes.UnitedStates].default),
9338
+ guidanceText: state2 ? stateFormatGuidanceText[state2] : stateFormatGuidanceText.default
9339
+ })
9340
+ };
9341
+ const cachedStripPatterns = /* @__PURE__ */ new Map();
9342
+ const makeStripPattern = (mask) => {
9343
+ const inputPatterns = mask.tokens.filter((token) => token.type === "input" && !!token.allow).map((token) => token.allow);
9344
+ const nonInputChars = mask.tokens.filter((token) => token.type === "nonInput" && !token.includeInValue).map((token) => token.char);
9345
+ const strippedChars = [...new Set(nonInputChars.filter((char) => !inputPatterns.some((pattern) => pattern.test(char))))];
9346
+ const stripPattern = new RegExp(`[${strippedChars.join("")}]`, "g");
9347
+ cachedStripPatterns.set(mask, stripPattern);
9348
+ return stripPattern;
9349
+ };
9350
+ const displayValueToPureValue = (displayValue, mask) => {
9351
+ const stripPattern = cachedStripPatterns.get(mask) ?? makeStripPattern(mask);
9352
+ return displayValue.replaceAll(stripPattern, "");
9353
+ };
9354
+ const isValueObscured = (value) => {
9355
+ var _a;
9356
+ return typeof value === "string" && !!((_a = value.match(/[*]{1,}/)) == null ? void 0 : _a.length);
9357
+ };
9358
+ const getAvailableInputTokens = (tokens) => {
9359
+ const availableTokens = [];
9360
+ for (const token of tokens) {
9361
+ if (token.type === "nonInput") {
9362
+ if (token.includeInValue) {
9363
+ availableTokens.push({
9364
+ ...token,
9365
+ offset: tokens.indexOf(token)
9366
+ });
9367
+ }
9368
+ continue;
9369
+ }
9370
+ availableTokens.push({
9371
+ ...token,
9372
+ offset: tokens.indexOf(token)
9373
+ });
9374
+ if (token.type !== "input" || !token.optional) break;
9375
+ }
9376
+ return availableTokens;
9377
+ };
9378
+ const findMatchingToken = (tokensWithOffset, char) => tokensWithOffset.find((token) => token.type === "nonInput" || !token.allow || token.allow.test(char)) ?? null;
9379
+ const getEagerSuffix = (tokens) => {
9380
+ let suffix = "";
9381
+ for (const token of tokens) {
9382
+ if (token.type === "input") {
9383
+ if (token.optional) continue;
9384
+ else break;
9385
+ }
9386
+ if (!token.displayEagerly) break;
9387
+ suffix += token.char;
9388
+ }
9389
+ return suffix;
9390
+ };
9391
+ const getPotentialForMoreOptionalInput = (tokens) => tokens.some((token) => token.type === "input" && token.optional);
9392
+ const matchAgainstMask = (pureValue, mask, acceptObscuredValue = false) => {
9393
+ let tokensToProcess = [...mask.tokens];
9394
+ let charsToProcess = pureValue;
9395
+ let charIndex = 0;
9396
+ let matchedTokens = [];
9397
+ if (acceptObscuredValue && isValueObscured(pureValue)) {
9398
+ return {
9399
+ outcome: "obscureCorrect",
9400
+ displayValue: pureValue
9401
+ };
9402
+ }
9403
+ const shiftChars = (increment) => {
9404
+ charIndex += increment;
9405
+ charsToProcess = charsToProcess.slice(increment);
9406
+ };
9407
+ const shiftTokens = (increment) => {
9408
+ tokensToProcess = tokensToProcess.slice(increment);
9409
+ };
9410
+ const displayValue = () => matchedTokens.map((token) => token.char).join("");
9411
+ while (true) {
9412
+ const char = charsToProcess[0];
9413
+ const token = tokensToProcess[0];
9414
+ if (!char && !tokensToProcess.some((t) => t.type === "input" && !t.optional)) return {
9415
+ outcome: "correct",
9416
+ displayValue: displayValue() + getEagerSuffix(tokensToProcess),
9417
+ potentialForMoreOptionalInput: getPotentialForMoreOptionalInput(tokensToProcess)
9418
+ };
9419
+ if (!char) {
9420
+ const output = shiftRight(mask.possibleShifts, matchedTokens, tokensToProcess);
9421
+ matchedTokens = output.matchedTokens;
9422
+ tokensToProcess = output.remainingTokens;
9423
+ return {
9424
+ outcome: "partialCorrect",
9425
+ displayValue: displayValue() + getEagerSuffix(tokensToProcess)
9426
+ };
9427
+ }
9428
+ if (!token) return {
9429
+ outcome: "mismatch",
9430
+ badChar: char,
9431
+ mismatchAtChar: charIndex,
9432
+ mismatchedToken: "inputTooLong",
9433
+ partialDisplayValue: displayValue()
9434
+ };
9435
+ if (token.type === "nonInput") {
9436
+ if (token.includeInValue) {
9437
+ if (char !== token.char) return {
9438
+ outcome: "mismatch",
9439
+ badChar: char,
9440
+ mismatchAtChar: charIndex,
9441
+ mismatchedToken: token,
9442
+ partialDisplayValue: displayValue()
9443
+ };
9444
+ shiftChars(1);
9445
+ }
9446
+ matchedTokens.push(token);
9447
+ shiftTokens(1);
9448
+ }
9449
+ if (token.type === "input") {
9450
+ const availableTokens = getAvailableInputTokens(tokensToProcess);
9451
+ const matchingToken = findMatchingToken(availableTokens, char);
9452
+ if (!matchingToken) return {
9453
+ outcome: "mismatch",
9454
+ badChar: char,
9455
+ mismatchAtChar: charIndex,
9456
+ mismatchedToken: token,
9457
+ partialDisplayValue: displayValue()
9458
+ };
9459
+ matchedTokens.push({
9460
+ ...matchingToken,
9461
+ char
9462
+ });
9463
+ shiftTokens(matchingToken.offset + 1);
9464
+ shiftChars(1);
9465
+ }
9466
+ }
9467
+ };
9468
+ const deriveInputState = (isValid, isFocused, isDisabled, isOptional, hasNullishValue, hasBlurred, errorMessage, shouldValidate, potentiallyMoreOptionalCharacters, formatGuidance, i18n) => {
9469
+ if (isDisabled) return {
9470
+ isError: false
9471
+ };
9472
+ if (isOptional && hasNullishValue) {
9473
+ return {
9474
+ isError: false
9475
+ };
9476
+ }
9477
+ if (isValid && (!potentiallyMoreOptionalCharacters || !isFocused)) return {
9478
+ isError: false,
9479
+ text: jsxs(Fragment, {
9480
+ children: [jsx(Icon, {
9481
+ name: "checkmark-small",
9482
+ className: "adyen-kyc-helper-text__valid-format-check"
9483
+ }), i18n.get("formatIsCorrect")]
9484
+ })
9485
+ };
9486
+ if (isFocused && formatGuidance) return {
9487
+ isError: false,
9488
+ text: formatGuidance
9489
+ };
9490
+ if (!isValid && (shouldValidate || hasBlurred)) return {
9491
+ isError: true,
9492
+ text: typeof errorMessage === "string" && errorMessage ? errorMessage : formatGuidance
9493
+ };
9494
+ return {
9495
+ isError: false
9496
+ };
9497
+ };
9498
+ const MISMATCH_ANIMATION_NAME = "mismatchShake";
9499
+ const logger$z = createLogger("MaskedInputText");
9500
+ const MaskedInputText = ({
9501
+ value,
9502
+ onInput,
9503
+ onBlur,
9504
+ onMismatch: onMismatchExternal,
9505
+ isValid: validationIsValid,
9506
+ errorMessage,
9507
+ shouldValidate,
9508
+ mask,
9509
+ name,
9510
+ label,
9511
+ placeholder,
9512
+ transformOnType,
9513
+ readonly = false,
9514
+ disabled = false,
9515
+ optional: optional2 = false,
9516
+ formatGuidance,
9517
+ classNameModifiers,
9518
+ acceptObscuredValue = false
9519
+ }) => {
9520
+ const hasExistingData = !isEmpty(value);
9521
+ const [isFocused, setIsFocused] = useState(false);
9522
+ const [hasBlurred, setHasBlurred] = useState(hasExistingData);
9523
+ const [caretReturnPosition, setCaretReturnPosition] = useState(null);
9524
+ const inputRef = useRef(null);
9525
+ const [showingMismatch, setShowingMismatch] = useState(false);
9526
+ const {
9527
+ i18n
9528
+ } = useI18nContext();
9529
+ const onMismatch = (mismatch) => {
9530
+ if (!inputRef.current) return;
9531
+ setShowingMismatch(true);
9532
+ inputRef.current.addEventListener("animationend", (event) => {
9533
+ if (event.animationName !== MISMATCH_ANIMATION_NAME) return;
9534
+ setShowingMismatch(false);
9535
+ });
9536
+ onMismatchExternal == null ? void 0 : onMismatchExternal(mismatch);
9537
+ };
9538
+ useEffect(() => {
9539
+ if (!mask) {
9540
+ logger$z.warn("`mask` is undefined. No masking of input will take place.");
9541
+ }
9542
+ }, [mask]);
9543
+ const getMaskResult = useCallback((pureValue) => {
9544
+ if (!mask) return {
9545
+ outcome: "partialCorrect",
9546
+ displayValue: pureValue
9547
+ };
9548
+ return matchAgainstMask(transformOnType ? transformOnType(pureValue) : pureValue, mask, acceptObscuredValue);
9549
+ }, [mask, transformOnType, acceptObscuredValue]);
9550
+ const displayValueToPure = useCallback((displayValue2) => {
9551
+ if (!mask) return displayValue2;
9552
+ return displayValueToPureValue(displayValue2, mask);
9553
+ }, [mask]);
9554
+ const maskResult = useMemo(() => getMaskResult(value), [getMaskResult, value]);
9555
+ const displayValue = maskResult.outcome === "mismatch" ? maskResult.partialDisplayValue : maskResult.displayValue;
9556
+ const inputState = deriveInputState(validationIsValid && maskResult.outcome !== "mismatch", isFocused, disabled, optional2, !displayValue, hasBlurred, errorMessage, shouldValidate, maskResult.outcome === "correct" && !!maskResult.potentialForMoreOptionalInput, formatGuidance, i18n);
9557
+ useEffect(() => {
9558
+ if (mask && maskResult.outcome === "mismatch") {
9559
+ const strippedValue = displayValueToPure(value);
9560
+ if (getMaskResult(strippedValue).outcome !== "mismatch") {
9561
+ onInput(strippedValue);
9562
+ return;
9563
+ }
9564
+ const fallback = displayValueToPure(maskResult.partialDisplayValue);
9565
+ logger$z.warn(`Value received "${value}" does not match mask`, maskResult, `
9566
+ Falling back to partially valid value "${fallback}"`);
9567
+ onInput(fallback);
9568
+ }
9569
+ }, [mask, maskResult, value, onInput, displayValueToPure, getMaskResult]);
9570
+ useLayoutEffect(() => {
9571
+ if (caretReturnPosition && inputRef.current && caretReturnPosition !== inputRef.current.selectionStart) {
9572
+ inputRef.current.setSelectionRange(caretReturnPosition, caretReturnPosition, "none");
9573
+ setCaretReturnPosition(null);
9574
+ }
9575
+ }, [caretReturnPosition]);
9576
+ const handleInput = (event) => {
9577
+ const inputEl = event.target;
9578
+ const newPureValue = displayValueToPure(inputEl.value);
9579
+ const newMaskResult = getMaskResult(newPureValue);
9580
+ const returnCaretLater = (offset = 0) => {
9581
+ if (!inputEl.selectionStart) return;
9582
+ setCaretReturnPosition(inputEl.selectionStart + offset);
9583
+ };
9584
+ const cancelInput = () => {
9585
+ returnCaretLater(-1);
9586
+ inputEl.value = displayValue;
9587
+ event.preventDefault();
9588
+ event.stopPropagation();
9589
+ };
9590
+ if (newMaskResult.outcome === "mismatch") {
9591
+ cancelInput();
9592
+ onMismatch(newMaskResult);
9593
+ return;
9594
+ }
9595
+ if (inputEl.selectionStart && inputEl.selectionStart < inputEl.value.length) {
9596
+ returnCaretLater();
9597
+ }
9598
+ inputEl.value = newMaskResult.displayValue;
9599
+ onInput(newPureValue);
9600
+ };
9601
+ return jsx(Field, {
9602
+ name,
9603
+ label,
9604
+ isValid: !inputState.isError,
9605
+ errorMessage: inputState.isError ? inputState.text ?? true : void 0,
9606
+ helper: inputState.isError ? void 0 : inputState.text,
9607
+ helperPosition: "below",
9608
+ classNameModifiers: classNameModifiers == null ? void 0 : classNameModifiers.field,
9609
+ disabled,
9610
+ optional: optional2,
9611
+ children: ({
9612
+ onBlurHandler: fieldOnBlur,
9613
+ onFocusHandler: fieldOnFocus,
9614
+ ...childProps
9615
+ }) => jsx(InputText, {
9616
+ ...childProps,
9617
+ value: displayValue,
9618
+ onInput: handleInput,
9619
+ onPaste: (event) => {
9620
+ var _a;
9621
+ const pasteValue = (_a = event.clipboardData) == null ? void 0 : _a.getData("text/plain");
9622
+ const inputEl = event.target;
9623
+ const {
9624
+ selectionStart,
9625
+ selectionEnd
9626
+ } = inputEl;
9627
+ if (!pasteValue || !selectionStart || selectionStart !== selectionEnd) return;
9628
+ const pureDisplayValue = displayValueToPure(displayValue);
9629
+ const purePasteValue = displayValueToPure(pasteValue);
9630
+ const newPureValue = pureDisplayValue.slice(0, selectionStart) + purePasteValue + pureDisplayValue.slice(selectionStart);
9631
+ if (newPureValue.startsWith(pureDisplayValue + pureDisplayValue)) {
9632
+ const withPrefixRemoved = newPureValue.replace(pureDisplayValue, "");
9633
+ event.preventDefault();
9634
+ handleInput({
9635
+ ...event,
9636
+ target: {
9637
+ ...event.target,
9638
+ value: withPrefixRemoved
9639
+ }
9640
+ });
9641
+ }
9642
+ },
9643
+ onKeyDown: (event) => {
9644
+ const inputEl = event.target;
9645
+ const isCaretAtEndWithNoSelection = inputEl.selectionStart === inputEl.value.length && inputEl.selectionStart === inputEl.selectionEnd;
9646
+ if (event.key !== KEYBOARD_KEYS.backspace || !isCaretAtEndWithNoSelection) return;
9647
+ event.preventDefault();
9648
+ const withLastCharRemoved = value.slice(0, value.length - 1);
9649
+ const newMaskResult = getMaskResult(withLastCharRemoved);
9650
+ if (newMaskResult.outcome === "mismatch") {
9651
+ inputEl.value = newMaskResult.partialDisplayValue;
9652
+ onMismatch(newMaskResult);
9653
+ } else {
9654
+ inputEl.value = newMaskResult.displayValue;
9655
+ onInput(withLastCharRemoved);
9656
+ }
9657
+ },
9658
+ onFocusHandler: (event) => {
9659
+ fieldOnFocus(event);
9660
+ setIsFocused(true);
9661
+ },
9662
+ onBlurHandler: (event) => {
9663
+ fieldOnBlur(event);
9664
+ const eventWithProcessedValue = {
9665
+ ...event,
9666
+ target: {
9667
+ ...event.target,
9668
+ value: displayValueToPure(event.target.value)
9669
+ }
9670
+ };
9671
+ onBlur == null ? void 0 : onBlur(eventWithProcessedValue);
9672
+ setIsFocused(false);
9673
+ setHasBlurred(true);
9674
+ },
9675
+ name,
9676
+ readonly,
9677
+ disabled,
9678
+ placeholder,
9679
+ classNameModifiers: [...(classNameModifiers == null ? void 0 : classNameModifiers.input) ?? [], ...showingMismatch ? ["mismatch"] : []],
9680
+ "aria-required": true,
9681
+ "aria-label": label,
9682
+ "aria-invalid": inputState.isError,
9683
+ "aria-placeholder": placeholder,
9684
+ ref: inputRef
9685
+ })
9686
+ });
9948
9687
  };
9949
- const inferCompanyRegistrationNumberType = (registrationNumber2, country2, companyType2) => {
9950
- const optionsForCountry = companyRegistrationNumberOptions[country2];
9951
- const metadataFn = defaultFieldConfig$9[country2];
9952
- if (!optionsForCountry || !metadataFn || typeof metadataFn !== "function") return void 0;
9953
- for (const option of optionsForCountry) {
9954
- const fieldMetadata = metadataFn({
9955
- companyType: companyType2,
9956
- registrationNumberType: option.id
9957
- });
9958
- if (!fieldMetadata.validators) continue;
9959
- const validators2 = Array.isArray(fieldMetadata.validators) ? fieldMetadata.validators : [fieldMetadata.validators];
9960
- if (validators2.every((validator) => validator.validate(registrationNumber2))) {
9961
- return option.id;
9962
- }
9963
- }
9688
+ let idCounter = Date.now();
9689
+ const getUniqueId = (prefix = "id") => {
9690
+ idCounter += 1;
9691
+ return `${prefix}-${idCounter}`;
9964
9692
  };
9965
- const businessRegistrationNumberFields = ["registrationNumber", "exemptedFromRegistrationNumber"];
9966
- function BusinessRegistrationNumber(props) {
9967
- var _a, _b, _c, _d;
9968
- const fieldConfig = props.fieldConfig ?? defaultFieldConfig$9;
9693
+ const InputRadio = ({
9694
+ className,
9695
+ ...props
9696
+ }) => jsx("input", {
9697
+ ...props,
9698
+ className: cx("adyen-kyc-input-radio__input", className)
9699
+ });
9700
+ function RadioGroup({
9701
+ items = [],
9702
+ name,
9703
+ onChange = noop,
9704
+ value,
9705
+ isInvalid,
9706
+ uniqueId,
9707
+ className,
9708
+ disabled = false,
9709
+ horizontal = false
9710
+ }) {
9969
9711
  const {
9970
9712
  i18n
9971
9713
  } = useI18nContext();
9972
- const stateRef = useRef({
9973
- setState: null
9714
+ const uniqueIdBase = uniqueId == null ? void 0 : uniqueId.replace(/[0-9]/g, "").substring(0, uniqueId.lastIndexOf("-"));
9715
+ const classes = horizontal ? "adyen-kyc-radio-group adyen-kyc-radio-group--horizontal" : "adyen-kyc-radio-group";
9716
+ return jsx("div", {
9717
+ className: classes,
9718
+ children: items.map((item) => {
9719
+ const uniqueId2 = getUniqueId(uniqueIdBase);
9720
+ return jsxs("label", {
9721
+ htmlFor: uniqueId2,
9722
+ className: "adyen-kyc-input-radio",
9723
+ children: [jsx(InputRadio, {
9724
+ id: uniqueId2,
9725
+ type: "radio",
9726
+ checked: value === item.id,
9727
+ "aria-checked": value === item.id,
9728
+ name,
9729
+ onChange,
9730
+ onClick: onChange,
9731
+ value: item.id,
9732
+ disabled
9733
+ }), jsx("span", {
9734
+ className: cx(["adyen-kyc-input-radio__label", "adyen-kyc-label__text", className, {
9735
+ "adyen-kyc-radio-group__label--invalid": isInvalid
9736
+ }]),
9737
+ children: i18n.get(item.name)
9738
+ })]
9739
+ }, item.name || item.id);
9740
+ })
9974
9741
  });
9975
- const schema = props.requiredFields || ["registrationNumber"];
9976
- const {
9977
- companyType: companyType2,
9978
- country: country2
9979
- } = props;
9980
- const registrationNumberOptions = useMemo(() => getCompanyRegistrationNumberOptions(country2, companyType2), [country2, companyType2]);
9981
- const defaultRegistrationNumberType = ((_a = props.data) == null ? void 0 : _a.registrationNumber) ? inferCompanyRegistrationNumberType((_b = props.data) == null ? void 0 : _b.registrationNumber, country2, companyType2) : registrationNumberOptions == null ? void 0 : registrationNumberOptions[0].id;
9982
- const [registrationNumberType, setRegistrationNumberType] = useState(defaultRegistrationNumberType);
9983
- const metadata = resolveFieldMetadata(fieldConfig[country2], {
9984
- companyType: companyType2,
9985
- registrationNumberType
9986
- }, defaultFieldMetadata$9);
9987
- const mergedProps = mergeFieldMetadataIntoProps("registrationNumber", metadata, {
9988
- requiredFields: schema,
9989
- readOnlyFields: props.readOnlyFields
9742
+ }
9743
+ const companyRegistrationNumberOptions = {
9744
+ [CountryCodes.Poland]: [{
9745
+ id: "regon",
9746
+ name: "regon"
9747
+ }, {
9748
+ id: "krsNumber",
9749
+ name: "krsNumber"
9750
+ }],
9751
+ [CountryCodes.Italy]: [{
9752
+ id: "partitaIVA",
9753
+ name: "partitaIVA"
9754
+ }, {
9755
+ id: "CCIAA",
9756
+ name: "CCIAA"
9757
+ }],
9758
+ [CountryCodes.Austria]: [{
9759
+ id: "firmenbuchnummer",
9760
+ name: "firmenbuchnummer"
9761
+ }, {
9762
+ id: "ZVR",
9763
+ name: "zentralesVereinsregisterId",
9764
+ applicableOnlyFor: [CompanyTypesValue.NON_PROFIT_OR_CHARITABLE]
9765
+ }],
9766
+ [CountryCodes.France]: [{
9767
+ id: "SIRET",
9768
+ name: "siret"
9769
+ }, {
9770
+ id: "RNA",
9771
+ name: "rnaNumber",
9772
+ applicableOnlyFor: [CompanyTypesValue.NON_PROFIT_OR_CHARITABLE]
9773
+ }],
9774
+ [CountryCodes.NewZealand]: [{
9775
+ id: "NZBN",
9776
+ name: "NZBN"
9777
+ }, {
9778
+ id: "companyNumberNZ",
9779
+ name: "companyNumberNZ",
9780
+ applicableOnlyFor: [CompanyTypesValue.PRIVATE_COMPANY, CompanyTypesValue.PUBLIC_COMPANY, CompanyTypesValue.UNLISTED_PUBLIC_COMPANY]
9781
+ }]
9782
+ };
9783
+ const getCompanyRegistrationNumberOptions = (country2, companyType2) => {
9784
+ const optionsForCountry = companyRegistrationNumberOptions[country2];
9785
+ if (!companyType2 || !optionsForCountry) return optionsForCountry;
9786
+ return optionsForCountry.filter((option) => {
9787
+ var _a;
9788
+ return ((_a = option.applicableOnlyFor) == null ? void 0 : _a.includes(companyType2)) ?? true;
9990
9789
  });
9991
- const {
9992
- handleChangeFor,
9993
- data,
9994
- valid,
9995
- errors,
9996
- isValid,
9997
- fieldProblems
9998
- } = useForm({
9999
- ...mergedProps,
10000
- schema: (data2) => data2.exemptedFromRegistrationNumber ? ["exemptedFromRegistrationNumber"] : ["registrationNumber", "exemptedFromRegistrationNumber"],
10001
- rules: mergedProps.validators,
10002
- defaultData: {
10003
- ...props.data,
10004
- exemptedFromRegistrationNumber: !!((_c = props.data) == null ? void 0 : _c.exemptedFromRegistrationNumber)
10005
- },
10006
- // exemptedFromRegistrationNumber should be a boolean
10007
- fieldProblems: props == null ? void 0 : props.fieldValidationErrors
9790
+ };
9791
+ const individualIdNumberOptions = {
9792
+ [CountryCodes.Spain]: [{
9793
+ id: "dni",
9794
+ name: "dni"
9795
+ }, {
9796
+ id: "nie",
9797
+ name: "nie"
9798
+ }]
9799
+ };
9800
+ const additionallIdNumberOptions = {
9801
+ [CountryCodes.NewZealand]: [{
9802
+ id: "driversLicense",
9803
+ name: "driversLicense"
9804
+ }, {
9805
+ id: "passport",
9806
+ name: "passportNumber"
9807
+ }],
9808
+ [CountryCodes.HongKong]: [{
9809
+ id: "proofOfIdentityCard",
9810
+ name: "stateIssuedProofOfIdentityCard"
9811
+ }, {
9812
+ id: "driversLicense",
9813
+ name: "driversLicense"
9814
+ }, {
9815
+ id: "passport",
9816
+ name: "passportNumber"
9817
+ }],
9818
+ [CountryCodes.Australia]: [{
9819
+ id: "driversLicense",
9820
+ name: "driversLicense"
9821
+ }, {
9822
+ id: "passport",
9823
+ name: "passportNumber"
9824
+ }]
9825
+ };
9826
+ const taxIdNumberOptions = {
9827
+ [CountryCodes.Denmark]: [{
9828
+ id: "momsregistreringsnummerCVR",
9829
+ name: "momsregistreringsnummerCVR"
9830
+ }, {
9831
+ id: "stamregister",
9832
+ name: "stamregister"
9833
+ }],
9834
+ [CountryCodes.France]: [{
9835
+ id: "numeroDIdentificationALATaxe",
9836
+ name: "numeroDIdentificationALATaxe"
9837
+ }, {
9838
+ id: "NumeroDeTVA",
9839
+ name: "NumeroDeTVA"
9840
+ }],
9841
+ [CountryCodes.Singapore]: [{
9842
+ id: "GST",
9843
+ name: "gst"
9844
+ }, {
9845
+ id: "UEN",
9846
+ name: "uen"
9847
+ }],
9848
+ [CountryCodes.Jersey]: [{
9849
+ id: "taxIdentificationNumber",
9850
+ name: "taxIdentificationNumber"
9851
+ }, {
9852
+ id: "socialSecurityNumber",
9853
+ name: "socialSecurityNumber",
9854
+ applicableOnlyFor: [CompanyTypesValue.SOLE_PROPRIETORSHIP]
9855
+ }],
9856
+ [CountryCodes.PuertoRico]: [{
9857
+ id: "EIN",
9858
+ name: "ein"
9859
+ }, {
9860
+ id: "SSN",
9861
+ name: "ssn",
9862
+ applicableOnlyFor: [CompanyTypesValue.SOLE_PROPRIETORSHIP]
9863
+ }],
9864
+ [CountryCodes.UnitedStates]: [{
9865
+ id: "EIN",
9866
+ name: "ein"
9867
+ }, {
9868
+ id: "SSN",
9869
+ name: "ssn",
9870
+ applicableOnlyFor: [CompanyTypesValue.SOLE_PROPRIETORSHIP]
9871
+ }]
9872
+ };
9873
+ const getTaxIdNumberOptions = (country2, companyType2) => {
9874
+ const optionsForCountry = taxIdNumberOptions[country2];
9875
+ if (!companyType2 || !optionsForCountry) return optionsForCountry;
9876
+ if (country2 === "US" || country2 === "PR") return optionsForCountry.filter((option) => option.id === "EIN");
9877
+ return optionsForCountry.filter((option) => {
9878
+ var _a;
9879
+ return ((_a = option.applicableOnlyFor) == null ? void 0 : _a.includes(companyType2)) ?? true;
10008
9880
  });
10009
- useEffect(() => {
10010
- var _a2, _b2;
10011
- (_b2 = (_a2 = stateRef == null ? void 0 : stateRef.current) == null ? void 0 : _a2.setState) == null ? void 0 : _b2.call(_a2, {
10012
- type: "addToState",
10013
- value: {
10014
- data,
10015
- valid,
10016
- errors,
10017
- caller: "businessRegistration",
10018
- dataStoreId: props.dataStoreId
9881
+ };
9882
+ function CompanyRegistrationNumberTypeSelector({
9883
+ country: country2,
9884
+ companyType: companyType2,
9885
+ selected,
9886
+ setSelected,
9887
+ exemptedOption
9888
+ }) {
9889
+ const {
9890
+ i18n
9891
+ } = useI18nContext();
9892
+ const handleSelect = useCallback((selectedStr) => {
9893
+ const newSelected = selectedStr;
9894
+ if (newSelected === "exempted") {
9895
+ if (exemptedOption) {
9896
+ setSelected(newSelected);
10019
9897
  }
10020
- });
10021
- }, [data, valid, errors, isValid]);
9898
+ return;
9899
+ }
9900
+ setSelected(newSelected);
9901
+ }, [exemptedOption, setSelected]);
9902
+ const options = useMemo(() => {
9903
+ const availableOptions = getCompanyRegistrationNumberOptions(country2, companyType2) ?? [];
9904
+ if (availableOptions.length === 0 || !exemptedOption) return availableOptions;
9905
+ return [...availableOptions, {
9906
+ id: "exempted",
9907
+ name: exemptedOption
9908
+ }];
9909
+ }, [companyType2, country2, exemptedOption]);
10022
9910
  useEffect(() => {
10023
- if (data.registrationNumber || registrationNumberType) {
10024
- handleChangeFor("registrationNumber", "blur")(data.registrationNumber);
9911
+ if (!selected && options.length > 0) {
9912
+ setSelected(options[0].id);
10025
9913
  }
10026
- }, [props.country, registrationNumberType]);
10027
- const formUtils = formUtilities(mergedProps, i18n);
10028
- const exemptionIsPossible = ((_d = mergedProps.requiredFields) == null ? void 0 : _d.includes("exemptedFromRegistrationNumber")) ?? false;
10029
- const showExemptedOption = exemptionIsPossible && !!registrationNumberOptions && registrationNumberOptions.length > 1;
9914
+ }, [options, selected, setSelected]);
9915
+ if (options.length <= 1) return null;
9916
+ return jsx(Field, {
9917
+ name: "companyRegistrationNumberType",
9918
+ label: i18n.get("whichTypeOfRegistrationNumberDoYouHave"),
9919
+ children: (childProps) => jsx(RadioGroup, {
9920
+ ...childProps,
9921
+ name: "companyRegistrationNumberType",
9922
+ items: options,
9923
+ value: selected,
9924
+ onChange: (e) => handleSelect(e.target.value)
9925
+ })
9926
+ });
9927
+ }
9928
+ const BUSINESS_REGISTRATION_NUMBER_FIELD = ["registrationNumber", "exemptedFromRegistrationNumber"];
9929
+ function BusinessRegistrationNumberField({
9930
+ data,
9931
+ valid,
9932
+ errors,
9933
+ labels: labels2,
9934
+ mask,
9935
+ guidanceText,
9936
+ placeholders,
9937
+ readonly,
9938
+ shouldValidate,
9939
+ optional: optional2,
9940
+ handleChangeFor,
9941
+ country: country2,
9942
+ canExempt,
9943
+ companyType: companyType2,
9944
+ registrationNumberOptions,
9945
+ registrationNumberType,
9946
+ setRegistrationNumberType
9947
+ }) {
9948
+ const showExemptedOption = canExempt && !!registrationNumberOptions && registrationNumberOptions.length > 1;
10030
9949
  const handleCompanyRegistrationNumberTypeChange = (regNumberType) => {
10031
9950
  if (regNumberType === "exempted") {
10032
- if (!exemptionIsPossible) {
9951
+ if (!canExempt) {
10033
9952
  throw Error(`${country2} does not allow tax exemptions`);
10034
9953
  }
10035
9954
  handleChangeFor("exemptedFromRegistrationNumber")(true);
10036
9955
  setRegistrationNumberType(void 0);
10037
9956
  return;
10038
9957
  }
10039
- if (exemptionIsPossible && data.exemptedFromRegistrationNumber === true) {
9958
+ if (canExempt && data.exemptedFromRegistrationNumber === true) {
10040
9959
  handleChangeFor("exemptedFromRegistrationNumber")(false);
10041
9960
  }
10042
9961
  setRegistrationNumberType(regNumberType);
10043
9962
  };
10044
9963
  return jsxs("div", {
10045
- className: "adyen-kyc-field__business-registration adyen-kyc-u-margin-bottom-16",
10046
- children: [jsx(StateContextSetter, {
10047
- stateRef
10048
- }), jsx(CompanyRegistrationNumberTypeSelector, {
9964
+ className: "adyen-kyc-field__business-registration",
9965
+ children: [jsx(CompanyRegistrationNumberTypeSelector, {
10049
9966
  companyType: companyType2,
10050
9967
  country: country2,
10051
9968
  setSelected: handleCompanyRegistrationNumberTypeChange,
10052
9969
  selected: data.exemptedFromRegistrationNumber ? "exempted" : registrationNumberType,
10053
- exemptedOption: showExemptedOption ? formUtils.getLabel("exemptedFromRegistrationNumber", "iDontHaveARegistrationNumber") : false
9970
+ exemptedOption: showExemptedOption ? labels2.exemptedFromRegistrationNumber : false
10054
9971
  }), jsx(MaskedInputText, {
10055
- name: "registrationNumber",
10056
- label: formUtils.getLabel("registrationNumber", "companyRegistrationNumber"),
10057
- formatGuidance: formUtils.getGuidanceText("registrationNumber"),
9972
+ "aria-required": true,
9973
+ "aria-label": labels2.registrationNumber,
9974
+ "aria-invalid": !valid.registrationNumber,
10058
9975
  classNameModifiers: {
10059
9976
  field: ["registrationNumber"],
10060
- input: ["registrationNumber"]
9977
+ input: ["registrationNumberInput"]
10061
9978
  },
10062
- errorMessage: formUtils.getErrorMessage("registrationNumber", errors, fieldProblems),
10063
- shouldValidate: props.shouldValidate,
10064
- isValid: valid.registrationNumber,
10065
- "aria-required": formUtils.isRequiredField("registrationNumber"),
10066
- "aria-label": formUtils.getLabel("registrationNumber"),
10067
- "aria-invalid": !valid.registrationNumber,
10068
- disabled: data.exemptedFromRegistrationNumber,
10069
- onBlur: handleChangeFor("registrationNumber", "blur"),
10070
- readonly: formUtils.isReadOnly("registrationNumber"),
10071
- value: data.registrationNumber ?? "",
9979
+ name: "registrationNumber",
9980
+ value: (data == null ? void 0 : data.registrationNumber) ?? "",
9981
+ label: labels2.registrationNumber ?? "",
9982
+ formatGuidance: (guidanceText == null ? void 0 : guidanceText.registrationNumber) ?? "",
9983
+ placeholder: placeholders == null ? void 0 : placeholders.registrationNumber,
9984
+ errorMessage: errors.registrationNumber,
9985
+ isValid: Boolean(valid.registrationNumber),
10072
9986
  onInput: handleChangeFor("registrationNumber", "input"),
10073
- ...formUtils.getMask("registrationNumber")
10074
- }), formUtils.isRequiredField("exemptedFromRegistrationNumber") && !showExemptedOption && jsx(Checkbox, {
9987
+ onBlur: handleChangeFor("registrationNumber", "blur"),
9988
+ disabled: data.exemptedFromRegistrationNumber,
9989
+ optional: optional2,
9990
+ readonly,
9991
+ shouldValidate: !optional2 && shouldValidate,
9992
+ ...mask
9993
+ }), canExempt && jsx(Field, {
10075
9994
  name: "exemptedFromRegistrationNumber",
10076
- label: formUtils.getLabel("iDontHaveARegistrationNumber"),
10077
- value: "exemptedFromRegistrationNumber",
10078
- readonly: formUtils.isReadOnly("exemptedFromRegistrationNumber"),
10079
- classNameModifiers: ["exempted-from-registration"],
10080
- checked: data.exemptedFromRegistrationNumber ?? false,
10081
- onChange: handleChangeFor("exemptedFromRegistrationNumber"),
10082
- "aria-required": formUtils.isRequiredField("exemptedFromRegistrationNumber"),
10083
- "aria-label": formUtils.getLabel("exemptedFromRegistrationNumber"),
10084
- "aria-invalid": false
9995
+ classNameModifiers: ["exemptedFromRegistrationNumber"],
9996
+ children: (childProps) => jsx(Checkbox, {
9997
+ ...childProps,
9998
+ "aria-required": false,
9999
+ "aria-label": labels2 == null ? void 0 : labels2.exemptedFromRegistrationNumber,
10000
+ "aria-invalid": false,
10001
+ name: "exemptedFromRegistrationNumber",
10002
+ value: "exemptedFromRegistrationNumber",
10003
+ checked: Boolean(data.exemptedFromRegistrationNumber),
10004
+ label: labels2 == null ? void 0 : labels2.exemptedFromRegistrationNumber,
10005
+ readonly,
10006
+ onChange: handleChangeFor("exemptedFromRegistrationNumber")
10007
+ })
10085
10008
  })]
10086
10009
  });
10087
10010
  }
@@ -10255,6 +10178,61 @@ function InputDate(props) {
10255
10178
  maxLength: 10
10256
10179
  });
10257
10180
  }
10181
+ const DATE_OF_INCORPORATION_FIELD = ["dateOfIncorporation"];
10182
+ function DateOfIncorporationField({
10183
+ data,
10184
+ valid,
10185
+ errors,
10186
+ labels: labels2,
10187
+ placeholders,
10188
+ readonly,
10189
+ handleChangeFor
10190
+ }) {
10191
+ return jsx(Field, {
10192
+ name: "dateOfIncorporation",
10193
+ label: labels2.dateOfIncorporation,
10194
+ classNameModifiers: ["dateOfIncorporation"],
10195
+ errorMessage: errors.dateOfIncorporation,
10196
+ isValid: valid.dateOfIncorporation,
10197
+ children: (childProps) => jsx(InputDate, {
10198
+ ...childProps,
10199
+ "aria-required": true,
10200
+ "aria-label": labels2.dateOfIncorporation,
10201
+ "aria-invalid": !valid.dateOfIncorporation,
10202
+ name: "dateOfIncorporation",
10203
+ value: data.dateOfIncorporation,
10204
+ placeholder: placeholders == null ? void 0 : placeholders.dateOfIncorporation,
10205
+ readonly,
10206
+ onInput: handleChangeFor("dateOfIncorporation", "input"),
10207
+ onBlur: handleChangeFor("dateOfIncorporation", "blur"),
10208
+ max: formatDateObj(/* @__PURE__ */ new Date())
10209
+ })
10210
+ });
10211
+ }
10212
+ const dateOfIncorporationFieldMetadata = {
10213
+ label: "dateOfIncorporation",
10214
+ validators: [validateNotEmptyOnBlur, {
10215
+ modes: ["blur"],
10216
+ validate: (dateOfIncorporation2) => dateOfIncorporation2 ? new Date(dateOfIncorporation2) < /* @__PURE__ */ new Date() : false,
10217
+ errorMessage: "invalidDateOfIncorporation"
10218
+ }]
10219
+ };
10220
+ const inferCompanyRegistrationNumberType = (registrationNumber2, country2, companyType2) => {
10221
+ const optionsForCountry = companyRegistrationNumberOptions[country2];
10222
+ const metadataFn = defaultFieldConfig$9[country2];
10223
+ if (!optionsForCountry || !metadataFn || typeof metadataFn !== "function") return void 0;
10224
+ for (const option of optionsForCountry) {
10225
+ const fieldMetadata = metadataFn({
10226
+ companyType: companyType2,
10227
+ registrationNumberType: option.id
10228
+ });
10229
+ if (!fieldMetadata.validators) continue;
10230
+ const validators2 = Array.isArray(fieldMetadata.validators) ? fieldMetadata.validators : [fieldMetadata.validators];
10231
+ if (validators2.every((validator) => validator.validate(registrationNumber2))) {
10232
+ return option.id;
10233
+ }
10234
+ }
10235
+ };
10258
10236
  const defaultFieldMetadata$8 = {
10259
10237
  label: "taxId"
10260
10238
  };
@@ -10432,7 +10410,7 @@ const defaultFieldConfig$8 = {
10432
10410
  };
10433
10411
  default:
10434
10412
  return {
10435
- label: "registrationNumber",
10413
+ label: "taxInformationNumber",
10436
10414
  mask: businessRegistrationNumberMasks[CountryCodes.Guernsey].default,
10437
10415
  validators: validatePatternOnBlur(businessRegistrationNumberPatterns[CountryCodes.Guernsey].default),
10438
10416
  guidanceText: {
@@ -11357,6 +11335,80 @@ const stockTickerSymbolFieldMetadata = {
11357
11335
  }
11358
11336
  }
11359
11337
  };
11338
+ const countryToTaxInfoTypeMap = {
11339
+ US: "EIN",
11340
+ AU: "ABN",
11341
+ NZ: "IRD",
11342
+ HK: "BRN",
11343
+ SG: "GST"
11344
+ };
11345
+ const updateTaxInformation = ({
11346
+ taxId: taxId2,
11347
+ country: country2,
11348
+ exemptedFromTax: exemptedFromTax2 = false,
11349
+ isUen,
11350
+ entity
11351
+ }) => {
11352
+ var _a;
11353
+ const updatedEntity = cloneObject(entity);
11354
+ const taxInformation = ((_a = entity.taxInformation) == null ? void 0 : _a.reduce((acc, info) => {
11355
+ acc[info.country] = info;
11356
+ return acc;
11357
+ }, {})) ?? {};
11358
+ if (exemptedFromTax2) {
11359
+ delete taxInformation[country2];
11360
+ } else if (isUen !== void 0) {
11361
+ taxInformation[country2] = {
11362
+ country: country2,
11363
+ type: isUen ? "UEN" : "GST",
11364
+ number: taxId2
11365
+ };
11366
+ } else {
11367
+ taxInformation[country2] = {
11368
+ country: country2,
11369
+ type: countryToTaxInfoTypeMap[country2],
11370
+ number: taxId2
11371
+ };
11372
+ }
11373
+ updatedEntity.taxInformation = Object.values(taxInformation);
11374
+ if (country2 === "US") {
11375
+ delete updatedEntity.vatNumber;
11376
+ delete updatedEntity.registrationNumber;
11377
+ }
11378
+ return updatedEntity;
11379
+ };
11380
+ const getUpdatedCountryOfGoverningLaw = (nameAndCountry) => {
11381
+ if (!nameAndCountry) {
11382
+ return nameAndCountry;
11383
+ }
11384
+ const updatedNameAndCountry = cloneObject(nameAndCountry);
11385
+ if (updatedNameAndCountry.country === "GB" && !updatedNameAndCountry.differentCountryOfGoverningLaw) {
11386
+ updatedNameAndCountry.countryOfGoverningLaw = "GB";
11387
+ } else if (updatedNameAndCountry.country !== "GB") {
11388
+ delete updatedNameAndCountry.countryOfGoverningLaw;
11389
+ }
11390
+ return updatedNameAndCountry;
11391
+ };
11392
+ const transformCountryOfGoverningLawToLegalEntity = (nameAndCountry, organization) => {
11393
+ const updatedOrganization = cloneObject(organization);
11394
+ if (nameAndCountry.country === "GB") {
11395
+ if (!nameAndCountry.differentCountryOfGoverningLaw) {
11396
+ updatedOrganization.countryOfGoverningLaw = CountryCodes.UnitedKingdom;
11397
+ } else {
11398
+ updatedOrganization.countryOfGoverningLaw = nameAndCountry.countryOfGoverningLaw;
11399
+ }
11400
+ } else {
11401
+ delete updatedOrganization.countryOfGoverningLaw;
11402
+ }
11403
+ return updatedOrganization;
11404
+ };
11405
+ const transformCountryOfGoverningLawToSchema = (nameAndCountry, organization) => {
11406
+ const updatedNameAndCountry = cloneObject(nameAndCountry);
11407
+ if (organization.registeredAddress.country === CountryCodes.UnitedKingdom && organization.countryOfGoverningLaw !== CountryCodes.UnitedKingdom) {
11408
+ updatedNameAndCountry.differentCountryOfGoverningLaw = true;
11409
+ }
11410
+ return updatedNameAndCountry;
11411
+ };
11360
11412
  function TaxIdNumberTypeSelector({
11361
11413
  country: country2,
11362
11414
  companyType: companyType2,
@@ -11404,155 +11456,278 @@ function TaxIdNumberTypeSelector({
11404
11456
  })
11405
11457
  });
11406
11458
  }
11407
- const taxIdFields = ["taxId", "exemptedFromTax", "isUen"];
11408
- function TaxId(props) {
11409
- var _a, _b, _c;
11410
- const {
11411
- data: propData,
11412
- country: country2,
11413
- companyType: companyType2,
11414
- fieldValidationErrors,
11415
- dataStoreId,
11416
- fieldConfig = defaultFieldConfig$8
11417
- } = props;
11418
- const existingTaxId = propData == null ? void 0 : propData.taxId;
11419
- const defaultTaxIdNumberType = existingTaxId ? inferTaxIdNumberType(existingTaxId, country2, companyType2) : (_a = getTaxIdNumberOptions(country2, companyType2)) == null ? void 0 : _a[0].id;
11420
- const [taxIdNumberType, setTaxIdNumberType] = useState(defaultTaxIdNumberType);
11421
- const metadata = resolveFieldMetadata(fieldConfig[country2], {
11422
- taxIdNumberType,
11423
- companyType: companyType2
11424
- }, defaultFieldMetadata$8);
11425
- const mergedProps = mergeFieldMetadataIntoProps("taxId", metadata, props);
11426
- const {
11427
- i18n
11428
- } = useI18nContext();
11429
- const formUtils = formUtilities(mergedProps, i18n);
11430
- const stateRef = useRef({
11431
- setState: null
11432
- });
11433
- const {
11434
- handleChangeFor,
11435
- data,
11436
- valid,
11437
- errors,
11438
- isValid,
11439
- fieldProblems
11440
- } = useForm({
11441
- ...mergedProps,
11442
- schema: (data2) => formUtils.isRequiredField("isUen") ? ["taxId", "isUen"] : data2.exemptedFromTax ? ["exemptedFromTax"] : ["taxId", "exemptedFromTax"],
11443
- rules: mergedProps.validators,
11444
- defaultData: {
11445
- ...propData,
11446
- exemptedFromTax: Boolean(propData == null ? void 0 : propData.exemptedFromTax),
11447
- // exemptedFromTax should be a boolean
11448
- isUen: formUtils.isRequiredField("isUen") ? Boolean(propData == null ? void 0 : propData.isUen) : void 0
11449
- },
11450
- fieldProblems: fieldValidationErrors
11451
- });
11459
+ const TAX_INFORMATION_FIELD = ["taxInformation", "exemptedFromTax", "isUen"];
11460
+ function TaxInformationField({
11461
+ data,
11462
+ valid,
11463
+ errors,
11464
+ labels: labels2,
11465
+ mask,
11466
+ guidanceText,
11467
+ placeholders,
11468
+ readonly,
11469
+ shouldValidate,
11470
+ handleChangeFor,
11471
+ country: country2,
11472
+ canExempt,
11473
+ registrationNumber: registrationNumber2,
11474
+ isUen,
11475
+ companyType: companyType2,
11476
+ taxIdNumberType,
11477
+ setTaxIdNumberType,
11478
+ defaultData
11479
+ }) {
11480
+ var _a;
11452
11481
  useEffect(() => {
11453
- if (data.taxId || taxIdNumberType) {
11454
- handleChangeFor("taxId", "blur")(data.taxId);
11482
+ handleChangeFor("taxInformation", "input")(defaultData);
11483
+ }, [country2]);
11484
+ const showTaxIdExemptedOptions = canExempt && (((_a = getTaxIdNumberOptions(country2, companyType2)) == null ? void 0 : _a.length) ?? 0) > 1;
11485
+ const currentCountryTaxInformation = useMemo(() => {
11486
+ var _a2;
11487
+ return (_a2 = data == null ? void 0 : data.taxInformation) == null ? void 0 : _a2.find((taxInfo) => taxInfo.country === country2);
11488
+ }, [data, country2]);
11489
+ const removeCurrentCountryTaxInformation = () => {
11490
+ var _a2;
11491
+ const filterdTaxInformation = (_a2 = data.taxInformation) == null ? void 0 : _a2.filter((taxId2) => taxId2.country !== country2);
11492
+ handleChangeFor("taxInformation", "input")(filterdTaxInformation);
11493
+ };
11494
+ const setUenAsTaxId = (uen2) => {
11495
+ if (!data.taxInformation) {
11496
+ return handleChangeFor("taxInformation", "blur")([{
11497
+ country: country2,
11498
+ number: uen2 ?? "",
11499
+ type: "UEN"
11500
+ }]);
11455
11501
  }
11456
- }, [taxIdNumberType, country2]);
11457
- useEffect(() => {
11458
- var _a2, _b2;
11459
- (_b2 = (_a2 = stateRef.current) == null ? void 0 : _a2.setState) == null ? void 0 : _b2.call(_a2, {
11460
- type: "addToState",
11461
- value: {
11462
- data,
11463
- valid,
11464
- errors,
11465
- caller: "taxId",
11466
- dataStoreId
11467
- }
11502
+ const taxInformation = currentCountryTaxInformation ? data.taxInformation : [...data.taxInformation, {
11503
+ country: country2,
11504
+ number: uen2 ?? "",
11505
+ type: "UEN"
11506
+ }];
11507
+ const updatedTaxInformation = taxInformation.map((taxInfo) => {
11508
+ if (taxInfo.country !== country2) return taxInfo;
11509
+ return {
11510
+ country: country2,
11511
+ number: uen2 ?? "",
11512
+ type: "UEN"
11513
+ };
11468
11514
  });
11469
- }, [data, valid, errors, isValid, dataStoreId]);
11470
- const {
11471
- sliceData: companyRegistrationDetails
11472
- } = useGlobalDataSlice("companyRegistrationDetails");
11473
- const registrationNumber2 = companyRegistrationDetails == null ? void 0 : companyRegistrationDetails.registrationNumber;
11474
- const handleUenOrGstChange = (isUen) => {
11475
- handleChangeFor("isUen", "input")(isUen);
11476
- if (isUen) {
11477
- handleChangeFor("taxId", "blur")(registrationNumber2);
11478
- return;
11515
+ return handleChangeFor("taxInformation", "blur")(updatedTaxInformation);
11516
+ };
11517
+ const handleTaxInformationInput = (value) => {
11518
+ if (!data.taxInformation) {
11519
+ const updatedTaxInformation2 = [{
11520
+ country: country2,
11521
+ number: value,
11522
+ type: data.isUen ? "UEN" : countryToTaxInfoTypeMap[country2]
11523
+ }];
11524
+ return handleChangeFor("taxInformation", "input")(updatedTaxInformation2);
11479
11525
  }
11480
- handleChangeFor("taxId", "blur")("");
11526
+ const taxInformation = currentCountryTaxInformation ? data.taxInformation : [...data.taxInformation, {
11527
+ country: country2,
11528
+ number: value,
11529
+ type: data.isUen ? "UEN" : countryToTaxInfoTypeMap[country2]
11530
+ }];
11531
+ const updatedTaxInformation = taxInformation.map((taxInfo) => {
11532
+ if (taxInfo.country !== country2) return taxInfo;
11533
+ return {
11534
+ country: country2,
11535
+ number: value,
11536
+ type: data.isUen ? "UEN" : countryToTaxInfoTypeMap[country2]
11537
+ };
11538
+ });
11539
+ return handleChangeFor("taxInformation", "input")(updatedTaxInformation);
11481
11540
  };
11482
- useEffect(() => {
11483
- if (data.isUen) {
11484
- handleChangeFor("taxId", "blur")(registrationNumber2);
11541
+ const handleTaxInformationBlur = (e) => {
11542
+ const {
11543
+ value
11544
+ } = e.target;
11545
+ if (!data.taxInformation) {
11546
+ const updatedTaxInformation2 = [{
11547
+ country: country2,
11548
+ number: value,
11549
+ type: data.isUen ? "UEN" : countryToTaxInfoTypeMap[country2]
11550
+ }];
11551
+ return handleChangeFor("taxInformation", "blur")(updatedTaxInformation2);
11485
11552
  }
11486
- }, [registrationNumber2]);
11487
- if (!formUtils.isRequiredField("taxId")) {
11488
- return null;
11489
- }
11490
- const exemptionIsPossible = ((_b = mergedProps.requiredFields) == null ? void 0 : _b.includes("exemptedFromTax")) ?? false;
11491
- const showTaxIdExemptedOption = exemptionIsPossible && (((_c = getTaxIdNumberOptions(country2, companyType2)) == null ? void 0 : _c.length) ?? 0) > 1;
11553
+ const taxInformation = currentCountryTaxInformation ? data.taxInformation : [...data.taxInformation, {
11554
+ country: country2,
11555
+ number: value,
11556
+ type: data.isUen ? "UEN" : countryToTaxInfoTypeMap[country2]
11557
+ }];
11558
+ const updatedTaxInformation = taxInformation.map((taxInfo) => {
11559
+ if (taxInfo.country !== country2) return taxInfo;
11560
+ return {
11561
+ country: country2,
11562
+ number: value,
11563
+ type: data.isUen ? "UEN" : countryToTaxInfoTypeMap[country2]
11564
+ };
11565
+ });
11566
+ return handleChangeFor("taxInformation", "blur")(updatedTaxInformation);
11567
+ };
11492
11568
  const handleTaxIdNumberTypeChange = (taxIdType) => {
11493
11569
  if (taxIdType === "exempted") {
11494
- if (!exemptionIsPossible) {
11570
+ if (!canExempt) {
11495
11571
  throw Error(`${country2} does not allow tax exemptions`);
11496
11572
  }
11497
11573
  handleChangeFor("exemptedFromTax")(true);
11574
+ removeCurrentCountryTaxInformation();
11498
11575
  setTaxIdNumberType(void 0);
11499
11576
  return;
11500
11577
  }
11501
- if (exemptionIsPossible && data.exemptedFromTax === true) {
11578
+ if (isUen) {
11579
+ if (taxIdType === "UEN") {
11580
+ handleChangeFor("isUen")(true);
11581
+ setUenAsTaxId(registrationNumber2);
11582
+ } else {
11583
+ handleChangeFor("isUen")(false);
11584
+ removeCurrentCountryTaxInformation();
11585
+ }
11586
+ }
11587
+ if (canExempt && data.exemptedFromTax === true) {
11502
11588
  handleChangeFor("exemptedFromTax")(false);
11503
11589
  }
11504
11590
  setTaxIdNumberType(taxIdType);
11505
11591
  };
11592
+ const handleExemptedFromTaxChange = (exempted) => {
11593
+ handleChangeFor("exemptedFromTax")(exempted);
11594
+ removeCurrentCountryTaxInformation();
11595
+ };
11506
11596
  return jsxs("div", {
11507
- className: "adyen-kyc-field--tax-id",
11508
- children: [jsx(StateContextSetter, {
11509
- stateRef
11510
- }), jsx(TaxIdNumberTypeSelector, {
11597
+ className: "adyen-kyc-field__tax-information",
11598
+ children: [jsx(TaxIdNumberTypeSelector, {
11511
11599
  country: country2,
11512
11600
  companyType: companyType2,
11513
11601
  setSelected: handleTaxIdNumberTypeChange,
11514
11602
  selected: data.exemptedFromTax ? "exempted" : taxIdNumberType,
11515
- exemptedOption: showTaxIdExemptedOption ? formUtils.getLabel("exemptedFromTax", "iDontHaveATaxId") : false
11603
+ exemptedOption: showTaxIdExemptedOptions ? labels2.exemptedFromTax : false
11516
11604
  }), !data.isUen && jsx(MaskedInputText, {
11517
- name: "taxId",
11518
- label: formUtils.getLabel("taxId"),
11519
- formatGuidance: formUtils.getGuidanceText("taxId"),
11520
- ...formUtils.getMask("taxId"),
11605
+ "aria-required": true,
11606
+ "aria-label": labels2.taxInformation,
11607
+ "aria-invalid": !valid.taxInformation,
11608
+ name: "taxInformation",
11521
11609
  classNameModifiers: {
11522
- field: ["tax-id"],
11523
- input: ["tax-id"]
11610
+ field: ["taxInformation"],
11611
+ input: ["taxInformationInput"]
11524
11612
  },
11525
- errorMessage: formUtils.getErrorMessage("taxId", errors, fieldProblems),
11526
- shouldValidate: props.shouldValidate,
11527
- isValid: valid.taxId,
11528
- value: data.taxId ?? "",
11529
- readonly: formUtils.isReadOnly("taxId"),
11530
- onInput: handleChangeFor("taxId", "input"),
11531
- onBlur: handleChangeFor("taxId", "blur"),
11532
- disabled: data.exemptedFromTax || data.isUen
11533
- }), formUtils.isRequiredField("isUen") && jsx(Checkbox, {
11534
- name: "isUen",
11535
- label: formUtils.getLabel("iDoNotHaveGst"),
11536
- classNameModifiers: ["exempted-from-tax"],
11537
- checked: Boolean(data.isUen),
11538
- onChange: handleUenOrGstChange,
11539
- "aria-required": false,
11540
- "aria-label": formUtils.getLabel("iDoNotHaveGst"),
11541
- "aria-invalid": false
11542
- }), formUtils.isRequiredField("exemptedFromTax") && !showTaxIdExemptedOption && jsx(Checkbox, {
11613
+ label: labels2.taxInformation ?? "",
11614
+ formatGuidance: (guidanceText == null ? void 0 : guidanceText.taxInformation) ?? "",
11615
+ value: (currentCountryTaxInformation == null ? void 0 : currentCountryTaxInformation.number) ?? "",
11616
+ errorMessage: errors.taxInformation,
11617
+ placeholder: placeholders == null ? void 0 : placeholders.taxInformation,
11618
+ isValid: Boolean(valid.taxInformation) && !!currentCountryTaxInformation,
11619
+ onInput: handleTaxInformationInput,
11620
+ onBlur: handleTaxInformationBlur,
11621
+ disabled: data.exemptedFromTax || data.isUen,
11622
+ readonly,
11623
+ shouldValidate,
11624
+ ...mask
11625
+ }), canExempt && !showTaxIdExemptedOptions && jsx(Field, {
11543
11626
  name: "exemptedFromTax",
11544
- label: formUtils.getLabel("exemptedFromTax", "iDontHaveATaxId"),
11545
- value: "exemptedFromTax",
11546
- readonly: formUtils.isReadOnly("exemptedFromTax"),
11547
- classNameModifiers: ["exempted-from-tax"],
11548
- checked: Boolean(data.exemptedFromTax),
11549
- onChange: handleChangeFor("exemptedFromTax"),
11550
- "aria-required": false,
11551
- "aria-label": formUtils.getLabel("exemptedFromTax"),
11552
- "aria-invalid": false
11627
+ classNameModifiers: ["exemptedFromTax"],
11628
+ children: (childProps) => jsx(Checkbox, {
11629
+ ...childProps,
11630
+ "aria-required": false,
11631
+ "aria-label": labels2.exemptedFromTax,
11632
+ "aria-invalid": false,
11633
+ name: "exemptedFromTax",
11634
+ label: labels2.exemptedFromTax,
11635
+ value: "exemptedFromTax",
11636
+ checked: Boolean(data.exemptedFromTax),
11637
+ onChange: handleExemptedFromTaxChange
11638
+ })
11639
+ })]
11640
+ });
11641
+ }
11642
+ const defaultFieldMetadata$6 = defaultFieldMetadata$8;
11643
+ const defaultFieldConfig$6 = entriesOf(defaultFieldConfig$8).reduce((fieldConfig, [country2, countryEntry]) => ({
11644
+ ...fieldConfig,
11645
+ [country2]: ({
11646
+ taxIdNumberType,
11647
+ companyType: companyType2
11648
+ }) => {
11649
+ const fieldMetadata = resolveFieldMetadata(countryEntry, {
11650
+ taxIdNumberType,
11651
+ companyType: companyType2
11652
+ }, defaultFieldMetadata$8);
11653
+ const taxIdValidators = fieldMetadata.validators ? Array.isArray(fieldMetadata.validators) ? fieldMetadata.validators : [fieldMetadata.validators] : [];
11654
+ const mappedValidators = taxIdValidators.map((validator) => ({
11655
+ ...validator,
11656
+ validate: (taxInformation) => {
11657
+ var _a;
11658
+ const taxIdNumber2 = (_a = taxInformation == null ? void 0 : taxInformation.find((taxId2) => country2 === taxId2.country)) == null ? void 0 : _a.number;
11659
+ return taxIdNumber2 ? validator.validate(taxIdNumber2) : false;
11660
+ }
11661
+ }));
11662
+ return {
11663
+ ...fieldMetadata,
11664
+ validators: mappedValidators
11665
+ };
11666
+ }
11667
+ }), {});
11668
+ const TRADING_NAME_FIELD = ["tradingName", "sameNameAsLegalName"];
11669
+ function TradingNameField({
11670
+ data,
11671
+ valid,
11672
+ errors,
11673
+ labels: labels2,
11674
+ readonly,
11675
+ handleChangeFor,
11676
+ legalCompanyName: legalCompanyName2
11677
+ }) {
11678
+ const handleSameAsLegalName = useCallback((isChecked) => {
11679
+ handleChangeFor("sameNameAsLegalName", "input")(isChecked);
11680
+ if (isChecked) {
11681
+ handleChangeFor("tradingName")(legalCompanyName2);
11682
+ }
11683
+ }, [handleChangeFor, legalCompanyName2]);
11684
+ useEffect(() => {
11685
+ if (data.sameNameAsLegalName && data.tradingName !== legalCompanyName2) {
11686
+ handleChangeFor("tradingName")(legalCompanyName2);
11687
+ }
11688
+ }, [legalCompanyName2, data.sameNameAsLegalName, data.tradingName]);
11689
+ return jsxs("div", {
11690
+ className: "adyen-kyc-field__tradingName",
11691
+ children: [jsx(Field, {
11692
+ name: "tradingName",
11693
+ label: labels2.tradingName,
11694
+ classNameModifiers: ["tradingName"],
11695
+ errorMessage: errors.tradingName,
11696
+ isValid: valid.tradingName,
11697
+ disabled: readonly || data.sameNameAsLegalName,
11698
+ children: (childProps) => jsx(InputText, {
11699
+ ...childProps,
11700
+ "aria-required": true,
11701
+ "aria-label": labels2.tradingName,
11702
+ "aria-invalid": !valid.tradingName,
11703
+ name: "tradingName",
11704
+ value: data.tradingName,
11705
+ readonly: readonly || data.sameNameAsLegalName,
11706
+ onInput: handleChangeFor("tradingName", "input"),
11707
+ onBlur: handleChangeFor("tradingName", "blur")
11708
+ })
11709
+ }), jsx(Field, {
11710
+ name: "sameNameAsLegalName",
11711
+ classNameModifiers: ["sameNameAsLegalName"],
11712
+ errorMessage: errors.sameNameAsLegalName,
11713
+ isValid: valid.sameNameAsLegalName,
11714
+ children: (childProps) => jsx(Checkbox, {
11715
+ ...childProps,
11716
+ "aria-required": false,
11717
+ "aria-label": labels2.sameNameAsLegalName,
11718
+ "aria-invalid": false,
11719
+ name: "sameNameAsLegalName",
11720
+ label: labels2.sameNameAsLegalName,
11721
+ checked: Boolean(data.sameNameAsLegalName),
11722
+ onChange: handleSameAsLegalName
11723
+ })
11553
11724
  })]
11554
11725
  });
11555
11726
  }
11727
+ const tradingNameFieldMetadata = {
11728
+ label: "tradingName",
11729
+ validators: [validateNotEmptyOnBlur]
11730
+ };
11556
11731
  var ExperimentNames = /* @__PURE__ */ ((ExperimentNames2) => {
11557
11732
  ExperimentNames2["EnableCompanySearchFlow"] = "EnableCompanySearchFlow";
11558
11733
  ExperimentNames2["EnableNewBusinessDetailsFlow"] = "EnableNewBusinessDetailsFlow";
@@ -11609,7 +11784,7 @@ function VatNumberField({
11609
11784
  id: VatAbsenceReason.CountryWithoutVatOrGstSystem,
11610
11785
  name: VatAbsenceReason.CountryWithoutVatOrGstSystem
11611
11786
  }]);
11612
- const showVatExemptedOption = canExempt && ((_a = taxIdNumberOptions[country2]) == null ? void 0 : _a.length) > 1;
11787
+ const showVatExemptedOptions = canExempt && ((_a = taxIdNumberOptions[country2]) == null ? void 0 : _a.length) > 1;
11613
11788
  const handleVatNumberTypeChange = (vatType) => {
11614
11789
  if (vatType === "exempted") {
11615
11790
  if (!canExempt) {
@@ -11630,13 +11805,13 @@ function VatNumberField({
11630
11805
  country: country2,
11631
11806
  setSelected: handleVatNumberTypeChange,
11632
11807
  selected: data.exemptedFromVat ? "exempted" : vatNumberType,
11633
- exemptedOption: showVatExemptedOption ? labels2.exemptedFromVat : false
11808
+ exemptedOption: showVatExemptedOptions ? labels2.exemptedFromVat : false
11634
11809
  }), jsx(MaskedInputText, {
11635
11810
  "aria-required": true,
11636
11811
  "aria-label": labels2.vatNumber,
11637
11812
  "aria-invalid": !valid.vatNumber,
11638
11813
  classNameModifiers: {
11639
- field: ["tax-id"],
11814
+ field: ["vatNumber"],
11640
11815
  input: ["vatNumber"]
11641
11816
  },
11642
11817
  name: "vatNumber",
@@ -11652,19 +11827,23 @@ function VatNumberField({
11652
11827
  readonly,
11653
11828
  shouldValidate,
11654
11829
  ...mask
11655
- }), canExempt && !showVatExemptedOption && jsx(Checkbox, {
11656
- "aria-required": false,
11657
- "aria-label": labels2 == null ? void 0 : labels2.exemptedFromVat,
11658
- "aria-invalid": false,
11830
+ }), canExempt && !showVatExemptedOptions && jsx(Field, {
11659
11831
  name: "exemptedFromVat",
11660
- label: labels2 == null ? void 0 : labels2.exemptedFromVat,
11661
- value: "exemptedFromVat",
11662
- classNameModifiers: ["exempted-from-tax"],
11663
- checked: data.exemptedFromVat ?? false,
11664
- onChange: handleChangeFor("exemptedFromVat")
11832
+ classNameModifiers: ["exemptedFromVat"],
11833
+ children: (childProps) => jsx(Checkbox, {
11834
+ ...childProps,
11835
+ "aria-required": false,
11836
+ "aria-label": labels2 == null ? void 0 : labels2.exemptedFromVat,
11837
+ "aria-invalid": false,
11838
+ name: "exemptedFromVat",
11839
+ label: labels2 == null ? void 0 : labels2.exemptedFromVat,
11840
+ value: "exemptedFromVat",
11841
+ checked: data.exemptedFromVat ?? false,
11842
+ onChange: handleChangeFor("exemptedFromVat")
11843
+ })
11665
11844
  }), data.exemptedFromVat && jsx(Field, {
11666
11845
  name: "vatAbsenceReason",
11667
- classNameModifiers: ["tax-id-absence-reason"],
11846
+ classNameModifiers: ["vatAbsenceReason"],
11668
11847
  label: labels2 == null ? void 0 : labels2.vatAbsenceReason,
11669
11848
  errorMessage: errors.vatAbsenceReason,
11670
11849
  isValid: valid.vatAbsenceReason,
@@ -11681,22 +11860,6 @@ function VatNumberField({
11681
11860
  })]
11682
11861
  });
11683
11862
  }
11684
- const companyRegistrationDetailsValidationRules = {
11685
- tradingName: {
11686
- modes: ["blur"],
11687
- validate: (tradingName2) => !isEmpty(tradingName2),
11688
- errorMessage: "fieldIsRequired"
11689
- },
11690
- dateOfIncorporation: [{
11691
- modes: ["blur"],
11692
- validate: (dateOfIncorporation2) => !!dateOfIncorporation2,
11693
- errorMessage: "fieldIsRequired"
11694
- }, {
11695
- modes: ["blur"],
11696
- validate: (dateOfIncorporation2) => !isEmpty(dateOfIncorporation2) && new Date(dateOfIncorporation2) < /* @__PURE__ */ new Date(),
11697
- errorMessage: "invalidDateOfIncorporation"
11698
- }]
11699
- };
11700
11863
  const FLOWS_THAT_HIDE_REGISTRATION_NUMBER = [{
11701
11864
  companyType: [CompanyTypesValue.SOLE_PROPRIETORSHIP],
11702
11865
  country: CountryCodes.Gibraltar
@@ -11716,256 +11879,269 @@ const FLOWS_THAT_HIDE_REGISTRATION_NUMBER = [{
11716
11879
  companyType: [CompanyTypesValue.SOLE_PROPRIETORSHIP],
11717
11880
  country: CountryCodes.PuertoRico
11718
11881
  }];
11719
- const companyRegistrationDetailsFields = ["tradingName", "sameNameAsLegalName", ...businessRegistrationNumberFields, "stockExchangeMIC", "stockISIN", "stockTickerSymbol", ...VAT_NUMBER_FIELD, ...taxIdFields, "dateOfIncorporation"];
11882
+ const companyRegistrationDetailsFields = [...TRADING_NAME_FIELD, ...BUSINESS_REGISTRATION_NUMBER_FIELD, ...STOCK_EXCHANGE_MIC_FIELD, ...STOCK_ISIN_FIELD, ...STOCK_TICKER_SYMBOL_FIELD, ...VAT_NUMBER_FIELD, ...TAX_INFORMATION_FIELD, ...DATE_OF_INCORPORATION_FIELD];
11720
11883
  function CompanyRegistrationDetailsComponent(props) {
11721
- var _a, _b, _c;
11884
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11885
+ let mergedProps = props;
11886
+ const COMPANY_REGISTRATION_DETAILS = mergedProps.id ?? "companyRegistrationDetails";
11722
11887
  const {
11723
11888
  i18n
11724
11889
  } = useI18nContext();
11725
11890
  const {
11726
11891
  companyNameAndCountry
11727
11892
  } = useGlobalData();
11728
- let mergedProps = props;
11729
- const defaultVatNumberType = ((_a = mergedProps.data) == null ? void 0 : _a.vatNumber) ? inferTaxIdNumberType((_b = mergedProps.data) == null ? void 0 : _b.vatNumber, mergedProps.country) : (_c = taxIdNumberOptions[mergedProps.country]) == null ? void 0 : _c[0].id;
11893
+ const {
11894
+ updateStateSlice
11895
+ } = useGlobalDataSlice(COMPANY_REGISTRATION_DETAILS);
11896
+ const country2 = (companyNameAndCountry == null ? void 0 : companyNameAndCountry.country) ?? mergedProps.country;
11897
+ const hideOptionalRegistrationNumberField = FLOWS_THAT_HIDE_REGISTRATION_NUMBER.some((f) => f.country === country2 && mergedProps.companyType && f.companyType.includes(mergedProps.companyType));
11898
+ const requiredFields = mergedProps.requiredFields || companyRegistrationDetailsFields;
11899
+ const legalCompanyName2 = companyNameAndCountry == null ? void 0 : companyNameAndCountry.legalCompanyName;
11900
+ const defaultVatNumberType = ((_a = mergedProps.data) == null ? void 0 : _a.vatNumber) ? inferTaxIdNumberType((_b = mergedProps.data) == null ? void 0 : _b.vatNumber, country2) : (_c = taxIdNumberOptions[country2]) == null ? void 0 : _c[0].id;
11730
11901
  const [vatNumberType, setVatNumberType] = useState(defaultVatNumberType);
11902
+ const registrationNumberOptions = useMemo(() => getCompanyRegistrationNumberOptions(country2, mergedProps.companyType), [country2, mergedProps.companyType]);
11903
+ const defaultRegistrationNumberType = ((_d = mergedProps.data) == null ? void 0 : _d.registrationNumber) ? inferCompanyRegistrationNumberType((_e = mergedProps.data) == null ? void 0 : _e.registrationNumber, country2, mergedProps.companyType) : registrationNumberOptions == null ? void 0 : registrationNumberOptions[0].id;
11904
+ const [registrationNumberType, setRegistrationNumberType] = useState(defaultRegistrationNumberType);
11905
+ const existingTaxId = (_h = (_g = (_f = mergedProps.data) == null ? void 0 : _f.taxInformation) == null ? void 0 : _g.find((taxId2) => taxId2.country === country2)) == null ? void 0 : _h.number;
11906
+ const defaultTaxIdNumberType = existingTaxId ? inferTaxIdNumberType(existingTaxId, country2) : (_i = getTaxIdNumberOptions(country2, mergedProps.companyType)) == null ? void 0 : _i[0].id;
11907
+ const [taxIdNumberType, setTaxIdNumberType] = useState(defaultTaxIdNumberType);
11908
+ mergedProps = mergeFieldMetadataIntoProps("tradingName", tradingNameFieldMetadata, mergedProps);
11731
11909
  mergedProps = mergeFieldMetadataIntoProps("stockExchangeMIC", stockExchangeMICFieldMetadata, mergedProps);
11732
11910
  mergedProps = mergeFieldMetadataIntoProps("stockISIN", stockISINFieldMetadata, mergedProps);
11733
11911
  mergedProps = mergeFieldMetadataIntoProps("stockTickerSymbol", stockTickerSymbolFieldMetadata, mergedProps);
11734
- mergedProps = mergeFieldMetadataIntoProps("vatNumber", resolveFieldMetadata(defaultFieldConfig$7[mergedProps.country], {
11912
+ mergedProps = mergeFieldMetadataIntoProps("vatNumber", resolveFieldMetadata(defaultFieldConfig$7[country2], {
11735
11913
  vatNumberType
11736
11914
  }, defaultFieldMetadata$7), mergedProps);
11737
11915
  mergedProps = mergeFieldMetadataIntoProps("vatAbsenceReason", vatAbsenceReasonMetadata, mergedProps);
11738
- const hideOptionalRegistrationNumberField = FLOWS_THAT_HIDE_REGISTRATION_NUMBER.some((f) => f.country === mergedProps.country && f.companyType.includes(mergedProps.companyType));
11739
- const stateRef = useRef({
11740
- setState: null
11741
- });
11742
- const COMPANY_REGISTRATION_DETAILS = mergedProps.id ?? "companyRegistrationDetails";
11743
- const requiredFields = mergedProps.requiredFields || companyRegistrationDetailsFields;
11744
- const directChildFields = requiredFields.filter((field) => ["tradingName", "sameNameAsLegalName", "stockExchangeMIC", "stockISIN", "stockTickerSymbol", "dateOfIncorporation", "vatNumber"].includes(field));
11745
- const legalCompanyName2 = companyNameAndCountry == null ? void 0 : companyNameAndCountry.legalCompanyName;
11746
- const isSameNameAsLegalName = !mergedProps.data.tradingName ? true : mergedProps.data.tradingName === legalCompanyName2;
11916
+ mergedProps = mergeFieldMetadataIntoProps("registrationNumber", resolveFieldMetadata(defaultFieldConfig$9[country2], {
11917
+ companyType: mergedProps.companyType,
11918
+ registrationNumberType
11919
+ }, defaultFieldMetadata$9), mergedProps);
11920
+ mergedProps = mergeFieldMetadataIntoProps("taxInformation", resolveFieldMetadata(defaultFieldConfig$6[country2], {
11921
+ taxIdNumberType
11922
+ }, defaultFieldMetadata$6), mergedProps);
11923
+ mergedProps = mergeFieldMetadataIntoProps("dateOfIncorporation", dateOfIncorporationFieldMetadata, mergedProps);
11924
+ const getFormSchema2 = useCallback((currentData) => {
11925
+ const fieldsToRemove = [];
11926
+ if (currentData.sameNameAsLegalName) {
11927
+ fieldsToRemove.push("tradingName");
11928
+ }
11929
+ if (currentData.exemptedFromVat) {
11930
+ fieldsToRemove.push("vatNumber");
11931
+ } else {
11932
+ fieldsToRemove.push("exemptedFromVat", "vatAbsenceReason");
11933
+ }
11934
+ if (currentData.exemptedFromTax) {
11935
+ fieldsToRemove.push("taxInformation");
11936
+ } else {
11937
+ fieldsToRemove.push("exemptedFromTax");
11938
+ }
11939
+ if (currentData.isUen) {
11940
+ fieldsToRemove.push("taxInformation", "exemptedFromTax");
11941
+ }
11942
+ if (currentData.exemptedFromRegistrationNumber) {
11943
+ fieldsToRemove.push("registrationNumber");
11944
+ } else {
11945
+ fieldsToRemove.push("exemptedFromRegistrationNumber");
11946
+ }
11947
+ return requiredFields.filter((field) => !fieldsToRemove.includes(field));
11948
+ }, [requiredFields]);
11747
11949
  const {
11748
- handleChangeFor,
11950
+ schema,
11749
11951
  data,
11750
11952
  valid,
11751
- fieldProblems,
11752
11953
  errors,
11753
- isValid,
11754
- triggerValidation,
11755
- setData
11954
+ fieldProblems,
11955
+ handleChangeFor
11756
11956
  } = useForm({
11757
11957
  ...mergedProps,
11758
- schema: (currentData) => !currentData.exemptedFromVat ? (requiredFields == null ? void 0 : requiredFields.filter((field) => field !== "vatAbsenceReason")) ?? directChildFields : (requiredFields == null ? void 0 : requiredFields.filter((field) => field !== "vatNumber")) ?? directChildFields,
11759
- defaultData: {
11760
- ...mergedProps.data,
11761
- sameNameAsLegalName: isSameNameAsLegalName,
11762
- tradingName: isSameNameAsLegalName ? legalCompanyName2 : mergedProps.data.tradingName
11763
- },
11764
- rules: {
11765
- ...mergedProps.validators,
11766
- ...companyRegistrationDetailsValidationRules
11767
- },
11768
- fieldProblems: mergedProps == null ? void 0 : mergedProps.fieldValidationErrors
11958
+ schema: getFormSchema2,
11959
+ defaultData: mergedProps.data,
11960
+ rules: mergedProps.validators,
11961
+ fieldProblems: mergedProps.fieldValidationErrors
11769
11962
  });
11770
11963
  useEffect(() => {
11771
- if (mergedProps.data.tradingName !== data.tradingName && mergedProps.data.tradingName) {
11772
- setData("tradingName", mergedProps.data.tradingName);
11773
- triggerValidation(["tradingName"]);
11774
- }
11775
- }, [mergedProps.data.tradingName]);
11776
- const formUtils = formUtilities(mergedProps, i18n);
11777
- useEffect(() => {
11778
- stateRef.current.setState({
11779
- type: "addToState",
11780
- value: {
11781
- data,
11782
- valid,
11783
- errors,
11784
- caller: COMPANY_REGISTRATION_DETAILS,
11785
- dataStoreId: COMPANY_REGISTRATION_DETAILS,
11786
- schema: requiredFields
11787
- }
11964
+ updateStateSlice({
11965
+ schema,
11966
+ data,
11967
+ errors,
11968
+ valid,
11969
+ fieldProblems
11788
11970
  });
11789
- }, [data, valid, errors, isValid]);
11790
- useEffect(() => {
11791
- setData("sameNameAsLegalName", isSameNameAsLegalName);
11792
- if (isSameNameAsLegalName) {
11793
- setData("tradingName", legalCompanyName2);
11794
- }
11795
- }, [legalCompanyName2]);
11796
- const handleSameLegalNameChange = (tradingNameIsSameAsLegalName) => {
11797
- handleChangeFor("sameNameAsLegalName", "input")(tradingNameIsSameAsLegalName);
11798
- setData("tradingName", tradingNameIsSameAsLegalName ? legalCompanyName2 : "");
11799
- };
11800
- const registrationNumberProps = getFieldProps(mergedProps, businessRegistrationNumberFields);
11801
- const taxIdProps = getFieldProps(mergedProps, taxIdFields);
11802
- const handleChange = ({
11803
- currentState,
11804
- changeInitiatedBy
11805
- }) => {
11806
- if (changeInitiatedBy === COMPANY_REGISTRATION_DETAILS) {
11807
- const currentData = currentState.data[COMPANY_REGISTRATION_DETAILS];
11808
- let schema = requiredFields;
11809
- let hasSchemaChanged = false;
11810
- if (formUtils.isRequiredField("vatNumber")) {
11811
- schema = currentData.exemptedFromVat ? schema.filter((child) => child !== "vatNumber") : schema.filter((child) => child !== "vatAbsenceReason" && child !== "exemptedFromVat");
11812
- hasSchemaChanged = true;
11813
- }
11814
- if (formUtils.isRequiredField("taxId") && currentData.exemptedFromTax) {
11815
- schema = schema.filter((child) => child !== "taxId");
11816
- hasSchemaChanged = true;
11817
- }
11818
- if (formUtils.isRequiredField("registrationNumber") && currentData.exemptedFromRegistrationNumber) {
11819
- schema = schema.filter((child) => child !== "registrationNumber");
11820
- hasSchemaChanged = true;
11821
- }
11822
- if (hasSchemaChanged) {
11823
- stateRef.current.setState({
11824
- type: "addToState",
11825
- value: {
11826
- data,
11827
- valid,
11828
- errors,
11829
- fieldProblems,
11830
- caller: mergedProps.id,
11831
- dataStoreId: mergedProps.id,
11832
- schema
11833
- }
11834
- });
11835
- }
11836
- }
11837
- };
11838
- return jsxs(Fragment, {
11839
- children: [jsx(StateContextSetter, {
11840
- owner: COMPANY_REGISTRATION_DETAILS,
11841
- stateRef
11842
- }), jsx(StateContextWatcher, {
11843
- onChange: handleChange
11844
- }), jsxs("form", {
11845
- className: "adyen-kyc-company__company-registration-details",
11846
- children: [jsx(FormHeader, {
11847
- heading: mergedProps.heading
11848
- }), jsx(ErrorPanel, {
11849
- verificationErrors: mergedProps == null ? void 0 : mergedProps.formVerificationErrors,
11850
- validationErrors: mergedProps == null ? void 0 : mergedProps.fieldValidationErrors,
11851
- formUtils,
11852
- id: "ariaErrorField"
11853
- }), jsx(ContextGuidance, {
11854
- page: "Company registration details",
11855
- title: i18n.get("whyDoINeedToFillInThisInformation"),
11856
- content: i18n.get("reasonForFillingCompanyRegistrationDetails"),
11857
- titleId: "whyDoINeedToFillInThisInformation",
11858
- contentId: "reasonForFillingCompanyRegistrationDetails"
11859
- }), formUtils.isRequiredField("tradingName") && jsxs(Fragment, {
11860
- children: [jsx(Field, {
11861
- name: "tradingName",
11862
- label: formUtils.getLabel("tradingName"),
11863
- classNameModifiers: ["tradingName"],
11864
- errorMessage: formUtils.getErrorMessage("tradingName", errors, fieldProblems),
11865
- isValid: valid.tradingName,
11866
- children: (childProps) => jsx(InputText, {
11867
- ...childProps,
11868
- name: "tradingName",
11869
- value: data.tradingName,
11870
- readonly: formUtils.isReadOnly("tradingName") || data.sameNameAsLegalName,
11871
- classNameModifiers: ["tradingName"],
11872
- onInput: handleChangeFor("tradingName", "input"),
11873
- onBlur: handleChangeFor("tradingName", "blur"),
11874
- "aria-required": true,
11875
- "aria-label": formUtils.getLabel("tradingName"),
11876
- "aria-invalid": !valid.tradingName
11877
- })
11878
- }), jsx("div", {
11879
- className: "adyen-kyc-field--same-name-as-legal-name",
11880
- children: jsx(Checkbox, {
11881
- name: "sameNameAsLegalName",
11882
- label: formUtils.getLabel("sameNameAsLegalName"),
11883
- checked: data.sameNameAsLegalName,
11884
- onChange: handleSameLegalNameChange,
11885
- "aria-required": false,
11886
- "aria-label": formUtils.getLabel("sameNameAsLegalName"),
11887
- "aria-invalid": false
11888
- })
11889
- })]
11890
- }), formUtils.isRequiredField("stockExchangeMIC") && jsx(StockExchangeMICField, {
11891
- data: formUtils.getFieldData(data, STOCK_EXCHANGE_MIC_FIELD),
11892
- valid: formUtils.getFieldValid(valid, STOCK_EXCHANGE_MIC_FIELD),
11893
- errors: formUtils.getFieldErrors(errors, fieldProblems, STOCK_EXCHANGE_MIC_FIELD),
11894
- labels: formUtils.getFieldLabels(STOCK_EXCHANGE_MIC_FIELD),
11895
- placeholders: formUtils.getFieldPlaceholders(STOCK_EXCHANGE_MIC_FIELD),
11896
- mask: formUtils.getMask("stockExchangeMIC"),
11897
- guidanceText: formUtils.getFieldGuidanceText(STOCK_EXCHANGE_MIC_FIELD),
11898
- readonly: formUtils.isReadOnly("stockExchangeMIC"),
11899
- handleChangeFor
11900
- }), formUtils.isRequiredField("stockISIN") && jsx(StockISINField, {
11901
- data: formUtils.getFieldData(data, STOCK_ISIN_FIELD),
11902
- valid: formUtils.getFieldValid(valid, STOCK_ISIN_FIELD),
11903
- errors: formUtils.getFieldErrors(errors, fieldProblems, STOCK_ISIN_FIELD),
11904
- labels: formUtils.getFieldLabels(STOCK_ISIN_FIELD),
11905
- placeholders: formUtils.getFieldPlaceholders(STOCK_ISIN_FIELD),
11906
- mask: formUtils.getMask("stockISIN"),
11907
- guidanceText: formUtils.getFieldGuidanceText(STOCK_ISIN_FIELD),
11908
- readonly: formUtils.isReadOnly("stockISIN"),
11909
- handleChangeFor
11910
- }), formUtils.isRequiredField("stockTickerSymbol") && jsx(StockTickerSymbolField, {
11911
- data: formUtils.getFieldData(data, STOCK_TICKER_SYMBOL_FIELD),
11912
- valid: formUtils.getFieldValid(valid, STOCK_TICKER_SYMBOL_FIELD),
11913
- errors: formUtils.getFieldErrors(errors, fieldProblems, STOCK_TICKER_SYMBOL_FIELD),
11914
- labels: formUtils.getFieldLabels(STOCK_TICKER_SYMBOL_FIELD),
11915
- placeholders: formUtils.getFieldPlaceholders(STOCK_TICKER_SYMBOL_FIELD),
11916
- mask: formUtils.getMask("stockTickerSymbol"),
11917
- guidanceText: formUtils.getFieldGuidanceText(STOCK_TICKER_SYMBOL_FIELD),
11918
- readonly: formUtils.isReadOnly("stockTickerSymbol"),
11919
- handleChangeFor
11920
- }), formUtils.isRequiredField("registrationNumber", !hideOptionalRegistrationNumberField) && jsx(BusinessRegistrationNumber, {
11921
- ...registrationNumberProps,
11922
- companyType: mergedProps.companyType,
11923
- country: mergedProps.country,
11924
- dataStoreId: COMPANY_REGISTRATION_DETAILS
11925
- }), formUtils.isRequiredField("vatNumber") && jsx(VatNumberField, {
11926
- data: formUtils.getFieldData(data, VAT_NUMBER_FIELD),
11927
- valid: formUtils.getFieldValid(valid, VAT_NUMBER_FIELD),
11928
- errors: formUtils.getFieldErrors(errors, fieldProblems, VAT_NUMBER_FIELD),
11929
- labels: formUtils.getFieldLabels(VAT_NUMBER_FIELD, {
11930
- exemptedFromVat: "iDontHaveAVatNumber"
11931
- }),
11932
- mask: formUtils.getMask("vatNumber"),
11933
- guidanceText: formUtils.getFieldGuidanceText(VAT_NUMBER_FIELD),
11934
- placeholders: formUtils.getFieldPlaceholders(VAT_NUMBER_FIELD),
11935
- readonly: formUtils.isReadOnly("vatNumber"),
11936
- handleChangeFor,
11937
- country: mergedProps.country,
11938
- canExempt: formUtils.isRequiredField("exemptedFromVat"),
11939
- vatNumberType,
11940
- setVatNumberType
11941
- }), formUtils.isRequiredField("taxId") && jsx(TaxId, {
11942
- ...taxIdProps,
11943
- dataStoreId: COMPANY_REGISTRATION_DETAILS,
11944
- country: mergedProps.country,
11945
- companyType: mergedProps.companyType
11946
- }), formUtils.isRequiredField("dateOfIncorporation") && jsx(Field, {
11947
- name: "dateOfIncorporation",
11948
- label: formUtils.getLabel("dateOfIncorporation"),
11949
- classNameModifiers: ["dateOfIncorporation"],
11950
- errorMessage: formUtils.getErrorMessage("dateOfIncorporation", errors, fieldProblems),
11951
- isValid: valid.dateOfIncorporation,
11952
- children: (childProps) => jsx(InputDate, {
11953
- ...childProps,
11954
- name: "dateOfIncorporation",
11955
- value: data.dateOfIncorporation,
11956
- placeholder: i18n.get("datePlaceholder"),
11971
+ }, [updateStateSlice, schema, data, errors, valid, fieldProblems]);
11972
+ const formUtils = formUtilities(mergedProps, i18n);
11973
+ return jsxs("form", {
11974
+ id: COMPANY_REGISTRATION_DETAILS,
11975
+ className: "adyen-kyc-company-registration-details",
11976
+ children: [jsx(FormHeader, {
11977
+ heading: mergedProps.heading
11978
+ }), jsx(ErrorPanel, {
11979
+ verificationErrors: mergedProps == null ? void 0 : mergedProps.formVerificationErrors,
11980
+ validationErrors: mergedProps == null ? void 0 : mergedProps.fieldValidationErrors,
11981
+ formUtils,
11982
+ id: "ariaErrorField"
11983
+ }), jsx(ContextGuidance, {
11984
+ page: "Company registration details",
11985
+ title: i18n.get("whyDoINeedToFillInThisInformation"),
11986
+ content: i18n.get("reasonForFillingCompanyRegistrationDetails"),
11987
+ titleId: "whyDoINeedToFillInThisInformation",
11988
+ contentId: "reasonForFillingCompanyRegistrationDetails"
11989
+ }), jsxs("fieldset", {
11990
+ form: COMPANY_REGISTRATION_DETAILS,
11991
+ children: [formUtils.isRequiredField("tradingName") && jsx("div", {
11992
+ className: "adyen-kyc-field-wrapper",
11993
+ children: jsx(TradingNameField, {
11994
+ data: formUtils.getFieldData(data, TRADING_NAME_FIELD),
11995
+ valid: formUtils.getFieldValid(valid, TRADING_NAME_FIELD),
11996
+ errors: formUtils.getFieldErrors(errors, fieldProblems, TRADING_NAME_FIELD),
11997
+ labels: formUtils.getFieldLabels(TRADING_NAME_FIELD),
11998
+ readonly: formUtils.isReadOnly("tradingName"),
11999
+ handleChangeFor,
12000
+ legalCompanyName: legalCompanyName2
12001
+ })
12002
+ }), formUtils.isRequiredField("stockExchangeMIC") && jsx("div", {
12003
+ className: "adyen-kyc-field-wrapper",
12004
+ children: jsx(StockExchangeMICField, {
12005
+ data: formUtils.getFieldData(data, STOCK_EXCHANGE_MIC_FIELD),
12006
+ valid: formUtils.getFieldValid(valid, STOCK_EXCHANGE_MIC_FIELD),
12007
+ errors: formUtils.getFieldErrors(errors, fieldProblems, STOCK_EXCHANGE_MIC_FIELD),
12008
+ labels: formUtils.getFieldLabels(STOCK_EXCHANGE_MIC_FIELD),
12009
+ placeholders: formUtils.getFieldPlaceholders(STOCK_EXCHANGE_MIC_FIELD),
12010
+ mask: formUtils.getMask("stockExchangeMIC"),
12011
+ guidanceText: formUtils.getFieldGuidanceText(STOCK_EXCHANGE_MIC_FIELD),
12012
+ readonly: formUtils.isReadOnly("stockExchangeMIC"),
12013
+ handleChangeFor
12014
+ })
12015
+ }), formUtils.isRequiredField("stockISIN") && jsx("div", {
12016
+ className: "adyen-kyc-field-wrapper",
12017
+ children: jsx(StockISINField, {
12018
+ data: formUtils.getFieldData(data, STOCK_ISIN_FIELD),
12019
+ valid: formUtils.getFieldValid(valid, STOCK_ISIN_FIELD),
12020
+ errors: formUtils.getFieldErrors(errors, fieldProblems, STOCK_ISIN_FIELD),
12021
+ labels: formUtils.getFieldLabels(STOCK_ISIN_FIELD),
12022
+ placeholders: formUtils.getFieldPlaceholders(STOCK_ISIN_FIELD),
12023
+ mask: formUtils.getMask("stockISIN"),
12024
+ guidanceText: formUtils.getFieldGuidanceText(STOCK_ISIN_FIELD),
12025
+ readonly: formUtils.isReadOnly("stockISIN"),
12026
+ handleChangeFor
12027
+ })
12028
+ }), formUtils.isRequiredField("stockTickerSymbol") && jsx("div", {
12029
+ className: "adyen-kyc-field-wrapper",
12030
+ children: jsx(StockTickerSymbolField, {
12031
+ data: formUtils.getFieldData(data, STOCK_TICKER_SYMBOL_FIELD),
12032
+ valid: formUtils.getFieldValid(valid, STOCK_TICKER_SYMBOL_FIELD),
12033
+ errors: formUtils.getFieldErrors(errors, fieldProblems, STOCK_TICKER_SYMBOL_FIELD),
12034
+ labels: formUtils.getFieldLabels(STOCK_TICKER_SYMBOL_FIELD),
12035
+ placeholders: formUtils.getFieldPlaceholders(STOCK_TICKER_SYMBOL_FIELD),
12036
+ mask: formUtils.getMask("stockTickerSymbol"),
12037
+ guidanceText: formUtils.getFieldGuidanceText(STOCK_TICKER_SYMBOL_FIELD),
12038
+ readonly: formUtils.isReadOnly("stockTickerSymbol"),
12039
+ handleChangeFor
12040
+ })
12041
+ }), formUtils.isRequiredField("registrationNumber", !hideOptionalRegistrationNumberField) && jsx("div", {
12042
+ className: "adyen-kyc-field-wrapper",
12043
+ children: jsx(BusinessRegistrationNumberField, {
12044
+ data: formUtils.getFieldData(data, BUSINESS_REGISTRATION_NUMBER_FIELD),
12045
+ valid: formUtils.getFieldValid(valid, BUSINESS_REGISTRATION_NUMBER_FIELD),
12046
+ errors: formUtils.getFieldErrors(errors, fieldProblems, BUSINESS_REGISTRATION_NUMBER_FIELD),
12047
+ labels: formUtils.getFieldLabels(BUSINESS_REGISTRATION_NUMBER_FIELD, {
12048
+ exemptedFromRegistrationNumber: "iDontHaveARegistrationNumber"
12049
+ }),
12050
+ mask: formUtils.getMask("registrationNumber"),
12051
+ guidanceText: formUtils.getFieldGuidanceText(BUSINESS_REGISTRATION_NUMBER_FIELD),
12052
+ placeholders: formUtils.getFieldPlaceholders(BUSINESS_REGISTRATION_NUMBER_FIELD),
12053
+ helperText: formUtils.getFieldHelperText(BUSINESS_REGISTRATION_NUMBER_FIELD),
12054
+ readonly: formUtils.isReadOnly("registrationNumber"),
12055
+ optional: formUtils.isOptionalField("registrationNumber"),
12056
+ shouldValidate: mergedProps.shouldValidate,
12057
+ handleChangeFor,
12058
+ country: country2,
12059
+ canExempt: formUtils.isRequiredField("exemptedFromRegistrationNumber"),
12060
+ companyType: mergedProps.companyType,
12061
+ registrationNumberOptions,
12062
+ registrationNumberType,
12063
+ setRegistrationNumberType
12064
+ })
12065
+ }), formUtils.isRequiredField("vatNumber") && jsx("div", {
12066
+ className: "adyen-kyc-field-wrapper",
12067
+ children: jsx(VatNumberField, {
12068
+ data: formUtils.getFieldData(data, VAT_NUMBER_FIELD),
12069
+ valid: formUtils.getFieldValid(valid, VAT_NUMBER_FIELD),
12070
+ errors: formUtils.getFieldErrors(errors, fieldProblems, VAT_NUMBER_FIELD),
12071
+ labels: formUtils.getFieldLabels(VAT_NUMBER_FIELD, {
12072
+ exemptedFromVat: "iDontHaveAVatNumber"
12073
+ }),
12074
+ mask: formUtils.getMask("vatNumber"),
12075
+ guidanceText: formUtils.getFieldGuidanceText(VAT_NUMBER_FIELD),
12076
+ placeholders: formUtils.getFieldPlaceholders(VAT_NUMBER_FIELD),
12077
+ readonly: formUtils.isReadOnly("vatNumber"),
12078
+ handleChangeFor,
12079
+ country: country2,
12080
+ canExempt: formUtils.isRequiredField("exemptedFromVat"),
12081
+ vatNumberType,
12082
+ setVatNumberType
12083
+ })
12084
+ }), formUtils.isRequiredField("taxInformation") && jsx("div", {
12085
+ className: "adyen-kyc-field-wrapper",
12086
+ children: jsx(TaxInformationField, {
12087
+ data: formUtils.getFieldData(data, TAX_INFORMATION_FIELD),
12088
+ valid: formUtils.getFieldValid(valid, TAX_INFORMATION_FIELD),
12089
+ errors: formUtils.getFieldErrors(errors, fieldProblems, TAX_INFORMATION_FIELD),
12090
+ labels: formUtils.getFieldLabels(TAX_INFORMATION_FIELD, {
12091
+ exemptedFromTax: "iDontHaveATaxId"
12092
+ }),
12093
+ mask: formUtils.getMask("taxInformation"),
12094
+ helperText: formUtils.getFieldHelperText(TAX_INFORMATION_FIELD),
12095
+ guidanceText: formUtils.getFieldGuidanceText(TAX_INFORMATION_FIELD),
12096
+ readonly: formUtils.isReadOnly("taxInformation"),
12097
+ shouldValidate: mergedProps.shouldValidate,
12098
+ handleChangeFor,
12099
+ canExempt: formUtils.isRequiredField("exemptedFromTax"),
12100
+ isUen: formUtils.isRequiredField("isUen"),
12101
+ country: country2,
12102
+ companyType: mergedProps.companyType,
12103
+ taxIdNumberType,
12104
+ setTaxIdNumberType,
12105
+ defaultData: (_j = mergedProps.data) == null ? void 0 : _j.taxInformation
12106
+ })
12107
+ }), formUtils.isRequiredField("dateOfIncorporation") && jsx("div", {
12108
+ className: "adyen-kyc-field-wrapper",
12109
+ children: jsx(DateOfIncorporationField, {
12110
+ data: formUtils.getFieldData(data, DATE_OF_INCORPORATION_FIELD),
12111
+ valid: formUtils.getFieldValid(valid, DATE_OF_INCORPORATION_FIELD),
12112
+ errors: formUtils.getFieldErrors(errors, fieldProblems, DATE_OF_INCORPORATION_FIELD),
12113
+ labels: formUtils.getFieldLabels(DATE_OF_INCORPORATION_FIELD),
12114
+ placeholders: formUtils.getFieldPlaceholders(DATE_OF_INCORPORATION_FIELD, {
12115
+ dateOfIncorporation: "datePlaceholder"
12116
+ }),
11957
12117
  readonly: formUtils.isReadOnly("dateOfIncorporation"),
11958
- onInput: handleChangeFor("dateOfIncorporation", "input"),
11959
- onBlur: handleChangeFor("dateOfIncorporation", "blur"),
11960
- "aria-required": true,
11961
- "aria-label": formUtils.getLabel("dateOfIncorporation"),
11962
- "aria-invalid": !valid.dateOfIncorporation,
11963
- max: formatDateObj(/* @__PURE__ */ new Date())
12118
+ handleChangeFor
11964
12119
  })
11965
12120
  })]
11966
12121
  })]
11967
12122
  });
11968
12123
  }
12124
+ function StateContextSetter({
12125
+ stateRef
12126
+ }) {
12127
+ if (stateRef.current.setState) {
12128
+ return null;
12129
+ }
12130
+ return jsx(StateContext.Consumer, {
12131
+ children: (stateContextValue) => {
12132
+ if (!stateContextValue) {
12133
+ throw new Error("<StateContextSetter> needs to be mounted inside a <StateProvider>");
12134
+ }
12135
+ const {
12136
+ dispatch,
12137
+ setActiveForms
12138
+ } = stateContextValue;
12139
+ stateRef.current.setState = dispatch;
12140
+ stateRef.current.setActiveForms = setActiveForms;
12141
+ return null;
12142
+ }
12143
+ });
12144
+ }
11969
12145
  const companyBase = {
11970
12146
  accountHolder: {
11971
12147
  rule: "accountHolderIfCustomer"
@@ -12110,26 +12286,6 @@ const businessDetailsBase = {
12110
12286
  rule: "countryRequiresRegistrationNumberForCompanies"
12111
12287
  }
12112
12288
  };
12113
- const taxIdBase$1 = {
12114
- exemptedFromTax: {
12115
- rule: "countryHasTaxExemptionsForSomeCompanies"
12116
- },
12117
- taxId: {
12118
- rule: "countryUsesTaxId"
12119
- },
12120
- exemptedFromVat: {
12121
- rule: "countryUsesVat"
12122
- },
12123
- vatAbsenceReason: {
12124
- rule: "countryUsesVat"
12125
- },
12126
- vatNumber: {
12127
- rule: "countryUsesVat"
12128
- },
12129
- isUen: {
12130
- rule: "countryUsesUenOrGst"
12131
- }
12132
- };
12133
12289
  const taxInformationBase = {
12134
12290
  vatNumber: {
12135
12291
  rule: "countryUsesVat"
@@ -12192,7 +12348,7 @@ const fieldsPerScenario$3 = {
12192
12348
  },
12193
12349
  L: {
12194
12350
  ...companyBase,
12195
- ...taxIdBase$1
12351
+ ...taxInformationBase
12196
12352
  },
12197
12353
  L_PROOFOFADDRESS: {
12198
12354
  proofOfAddressDocument: {
@@ -15374,6 +15530,7 @@ function CompanyComponent(props) {
15374
15530
  } = useI18nContext();
15375
15531
  const [currentCompanyType, setCurrentCompanyType] = useState(void 0);
15376
15532
  const [currentCountry, setCurrentCountry] = useState(props.country);
15533
+ const [currentLegalName, setCurrentLegalName] = useState();
15377
15534
  const companyNameAndCountryFormProps = getFormProps(props, CompanyNameAndCountryFormID);
15378
15535
  const companyTypeFormProps = getFormProps(props, CompanyTypeFormID);
15379
15536
  const companyRegistrationDetailsFormProps = getFormProps(props, CompanyRegistrationDetailsFormID);
@@ -15384,13 +15541,15 @@ function CompanyComponent(props) {
15384
15541
  currentState,
15385
15542
  prevState
15386
15543
  }) => {
15387
- var _a, _b, _c, _d, _e, _f, _g, _h;
15388
- const companyType2 = (_b = (_a = currentState.data) == null ? void 0 : _a[CompanyTypeFormID]) == null ? void 0 : _b.entityType;
15544
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
15545
+ const legalCompanyName2 = (_b = (_a = currentState.data) == null ? void 0 : _a[CompanyNameAndCountryFormID]) == null ? void 0 : _b.legalCompanyName;
15546
+ setCurrentLegalName(legalCompanyName2);
15547
+ const companyType2 = (_d = (_c = currentState.data) == null ? void 0 : _c[CompanyTypeFormID]) == null ? void 0 : _d.entityType;
15389
15548
  setCurrentCompanyType(companyType2);
15390
- const companyCountryPrev = (_d = (_c = prevState.data) == null ? void 0 : _c[CompanyNameAndCountryFormID]) == null ? void 0 : _d.country;
15391
- const companyCountry = (_f = (_e = currentState.data) == null ? void 0 : _e[CompanyNameAndCountryFormID]) == null ? void 0 : _f.country;
15549
+ const companyCountryPrev = (_f = (_e = prevState.data) == null ? void 0 : _e[CompanyNameAndCountryFormID]) == null ? void 0 : _f.country;
15550
+ const companyCountry = (_h = (_g = currentState.data) == null ? void 0 : _g[CompanyNameAndCountryFormID]) == null ? void 0 : _h.country;
15392
15551
  setCurrentCountry(companyCountry);
15393
- const accountHolder2 = (_h = (_g = currentState.data) == null ? void 0 : _g[CompanyTypeFormID]) == null ? void 0 : _h.accountHolder;
15552
+ const accountHolder2 = (_j = (_i = currentState.data) == null ? void 0 : _i[CompanyTypeFormID]) == null ? void 0 : _j.accountHolder;
15394
15553
  if (companyCountry != null && companyCountry !== companyCountryPrev) {
15395
15554
  props.onCountryChange(companyCountry);
15396
15555
  }
@@ -15426,8 +15585,9 @@ function CompanyComponent(props) {
15426
15585
  ...companyRegistrationDetailsFormProps,
15427
15586
  heading: i18n.get("registrationDetails"),
15428
15587
  id: CompanyRegistrationDetailsFormID,
15429
- country: props.country,
15430
- companyType: currentCompanyType
15588
+ country: currentCountry,
15589
+ companyType: currentCompanyType,
15590
+ legalName: currentLegalName
15431
15591
  })
15432
15592
  }), jsx("div", {
15433
15593
  className: props.activeForm.formId !== CompanyRegistrationAddressFormID ? "adyen-kyc-form-wrapper adyen-kyc-form-wrapper--hidden" : "adyen-kyc-form-wrapper",
@@ -15786,80 +15946,6 @@ const getObscuredAccountNumber = ({
15786
15946
  accountIdentifier,
15787
15947
  realLastFour
15788
15948
  }) => realLastFour ? `*******${realLastFour}` : accountIdentifier;
15789
- const countryToTaxInfoTypeMap = {
15790
- US: "EIN",
15791
- AU: "ABN",
15792
- NZ: "IRD",
15793
- HK: "BRN",
15794
- SG: "GST"
15795
- };
15796
- const updateTaxInformation = ({
15797
- taxId: taxId2,
15798
- country: country2,
15799
- exemptedFromTax: exemptedFromTax2 = false,
15800
- isUen,
15801
- entity
15802
- }) => {
15803
- var _a;
15804
- const updatedEntity = cloneObject(entity);
15805
- const taxInformation = ((_a = entity.taxInformation) == null ? void 0 : _a.reduce((acc, info) => {
15806
- acc[info.country] = info;
15807
- return acc;
15808
- }, {})) ?? {};
15809
- if (exemptedFromTax2) {
15810
- delete taxInformation[country2];
15811
- } else if (isUen !== void 0) {
15812
- taxInformation[country2] = {
15813
- country: country2,
15814
- type: isUen ? "UEN" : "GST",
15815
- number: taxId2
15816
- };
15817
- } else {
15818
- taxInformation[country2] = {
15819
- country: country2,
15820
- type: countryToTaxInfoTypeMap[country2],
15821
- number: taxId2
15822
- };
15823
- }
15824
- updatedEntity.taxInformation = Object.values(taxInformation);
15825
- if (country2 === "US") {
15826
- delete updatedEntity.vatNumber;
15827
- delete updatedEntity.registrationNumber;
15828
- }
15829
- return updatedEntity;
15830
- };
15831
- const getUpdatedCountryOfGoverningLaw = (nameAndCountry) => {
15832
- if (!nameAndCountry) {
15833
- return nameAndCountry;
15834
- }
15835
- const updatedNameAndCountry = cloneObject(nameAndCountry);
15836
- if (updatedNameAndCountry.country === "GB" && !updatedNameAndCountry.differentCountryOfGoverningLaw) {
15837
- updatedNameAndCountry.countryOfGoverningLaw = "GB";
15838
- } else if (updatedNameAndCountry.country !== "GB") {
15839
- delete updatedNameAndCountry.countryOfGoverningLaw;
15840
- }
15841
- return updatedNameAndCountry;
15842
- };
15843
- const transformCountryOfGoverningLawToLegalEntity = (nameAndCountry, organization) => {
15844
- const updatedOrganization = cloneObject(organization);
15845
- if (nameAndCountry.country === "GB") {
15846
- if (!nameAndCountry.differentCountryOfGoverningLaw) {
15847
- updatedOrganization.countryOfGoverningLaw = CountryCodes.UnitedKingdom;
15848
- } else {
15849
- updatedOrganization.countryOfGoverningLaw = nameAndCountry.countryOfGoverningLaw;
15850
- }
15851
- } else {
15852
- delete updatedOrganization.countryOfGoverningLaw;
15853
- }
15854
- return updatedOrganization;
15855
- };
15856
- const transformCountryOfGoverningLawToSchema = (nameAndCountry, organization) => {
15857
- const updatedNameAndCountry = cloneObject(nameAndCountry);
15858
- if (organization.registeredAddress.country === CountryCodes.UnitedKingdom && organization.countryOfGoverningLaw !== CountryCodes.UnitedKingdom) {
15859
- updatedNameAndCountry.differentCountryOfGoverningLaw = true;
15860
- }
15861
- return updatedNameAndCountry;
15862
- };
15863
15949
  const mandatoryApiFields = {
15864
15950
  INDIVIDUAL: ["personalDetails.firstName", "personalDetails.lastName", "personalDetails.residencyCountry"],
15865
15951
  DECISIONMAKER: ["personalDetails.firstName", "personalDetails.lastName", "personalDetails.residencyCountry", "personalDetails.role", "personalDetails.jobTitle"],
@@ -15952,6 +16038,7 @@ const companyBaseMapping = {
15952
16038
  "companyType.entityType": "organization.type",
15953
16039
  "companyRegistrationDetails.tradingName": "organization.doingBusinessAs",
15954
16040
  "companyRegistrationDetails.registrationNumber": "organization.registrationNumber",
16041
+ "companyRegistrationDetails.taxInformation": "organization.taxInformation",
15955
16042
  "companyRegistrationDetails.vatNumber": "organization.vatNumber",
15956
16043
  "companyRegistrationDetails.vatAbsenceReason": "organization.vatAbsenceReason",
15957
16044
  "companyRegistrationDetails.dateOfIncorporation": "organization.dateOfIncorporation",
@@ -16027,6 +16114,7 @@ const solePropBaseMapping = {
16027
16114
  "solePropRegistrationDetails.vatAbsenceReason": "soleProprietorship.vatAbsenceReason",
16028
16115
  "solePropRegistrationDetails.exemptedFromTax": "soleProprietorship.taxAbsent",
16029
16116
  "solePropRegistrationDetails.registrationNumber": "soleProprietorship.registrationNumber",
16117
+ "solePropRegistrationDetails.taxInformation": "soleProprietorship.taxInformation",
16030
16118
  "solePropRegistrationDetails.dateOfIncorporation": "soleProprietorship.dateOfIncorporation",
16031
16119
  "solePropRegistrationAddress.registrationAddress.city": "soleProprietorship.registeredAddress.city",
16032
16120
  "solePropRegistrationAddress.registrationAddress.country": "soleProprietorship.registeredAddress.country",
@@ -16303,7 +16391,7 @@ const mapIndividualToLegalEntity = (data) => {
16303
16391
  return requestObj;
16304
16392
  };
16305
16393
  const mapLegalEntityToCompany = (legalEntity, isChangingType, accountHolder2) => {
16306
- var _a, _b, _c, _d;
16394
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
16307
16395
  let companyCompData;
16308
16396
  if (legalEntity == null ? void 0 : legalEntity.organization) {
16309
16397
  companyCompData = formatObject(legalEntity, companyComponentsKeyMapping);
@@ -16316,20 +16404,17 @@ const mapLegalEntityToCompany = (legalEntity, isChangingType, accountHolder2) =>
16316
16404
  companyCompData.companyRegistrationAddress.operationalAddressIsSame = operationalAddressIsSameIds.OPERATIONAL_ADDRESS_IS_SAME;
16317
16405
  }
16318
16406
  companyCompData.companyNameAndCountry = transformCountryOfGoverningLawToSchema(companyCompData.companyNameAndCountry, legalEntity.organization);
16407
+ const sameNameAsLegalName2 = !(((_b = companyCompData.companyNameAndCountry) == null ? void 0 : _b.legalCompanyName) && ((_c = companyCompData.companyRegistrationDetails) == null ? void 0 : _c.tradingName) && companyCompData.companyNameAndCountry.legalCompanyName !== companyCompData.companyRegistrationDetails.tradingName);
16319
16408
  companyCompData.companyRegistrationDetails = {
16320
16409
  ...companyCompData.companyRegistrationDetails,
16321
- sameNameAsLegalName: !(((_b = companyCompData.companyNameAndCountry) == null ? void 0 : _b.legalCompanyName) && ((_c = companyCompData.companyRegistrationDetails) == null ? void 0 : _c.tradingName) && companyCompData.companyNameAndCountry.legalCompanyName !== companyCompData.companyRegistrationDetails.tradingName)
16410
+ tradingName: ((_d = companyCompData.companyRegistrationDetails) == null ? void 0 : _d.tradingName) ? (_e = companyCompData.companyRegistrationDetails) == null ? void 0 : _e.tradingName : (_f = companyCompData.companyNameAndCountry) == null ? void 0 : _f.legalCompanyName,
16411
+ sameNameAsLegalName: companyCompData.companyNameAndCountry.legalCompanyName ? sameNameAsLegalName2 : true
16322
16412
  };
16323
- const {
16324
- taxInformation = []
16325
- } = legalEntity.organization;
16326
- if (taxInformation.length) {
16413
+ if ((_h = (_g = legalEntity.organization) == null ? void 0 : _g.taxInformation) == null ? void 0 : _h.length) {
16327
16414
  const {
16328
16415
  country: country2
16329
16416
  } = legalEntity.organization.registeredAddress;
16330
- const countryTaxInformation = taxInformation.find((info) => info.country === country2);
16331
- companyCompData.companyRegistrationDetails.taxId = countryTaxInformation == null ? void 0 : countryTaxInformation.number;
16332
- companyCompData.companyRegistrationDetails.exemptedFromTax = false;
16417
+ const countryTaxInformation = legalEntity.organization.taxInformation.find((info) => info.country === country2);
16333
16418
  if ((countryTaxInformation == null ? void 0 : countryTaxInformation.type) === "UEN") {
16334
16419
  companyCompData.companyRegistrationDetails.isUen = true;
16335
16420
  }
@@ -16337,7 +16422,7 @@ const mapLegalEntityToCompany = (legalEntity, isChangingType, accountHolder2) =>
16337
16422
  companyCompData.companyRegistrationDetails.isUen = false;
16338
16423
  }
16339
16424
  }
16340
- if ((_d = legalEntity == null ? void 0 : legalEntity.documentDetails) == null ? void 0 : _d.length) {
16425
+ if ((_i = legalEntity == null ? void 0 : legalEntity.documentDetails) == null ? void 0 : _i.length) {
16341
16426
  companyCompData = {
16342
16427
  ...companyCompData,
16343
16428
  ...mapApiDocumentToCompanyDocuments(legalEntity == null ? void 0 : legalEntity.id)
@@ -16354,21 +16439,27 @@ const mapLegalEntityToCompany = (legalEntity, isChangingType, accountHolder2) =>
16354
16439
  return companyCompData;
16355
16440
  };
16356
16441
  const mapCompanyToLegalEntity = (data) => {
16442
+ var _a, _b, _c, _d, _e, _f;
16357
16443
  const requestObj = {
16358
16444
  ...formatObject(data, companyApiKeyMapping)
16359
16445
  };
16360
16446
  if (requestObj.organization.vatAbsenceReason) {
16361
16447
  requestObj.organization.vatNumber = "";
16362
16448
  }
16363
- requestObj.organization = transformCountryOfGoverningLawToLegalEntity(data.companyNameAndCountry, requestObj.organization);
16364
- if (data.companyRegistrationDetails.taxId) {
16449
+ const taxId2 = (_a = data.companyRegistrationDetails.taxInformation) == null ? void 0 : _a.find((tax) => {
16450
+ var _a2;
16451
+ return tax.country === ((_a2 = data.companyNameAndCountry) == null ? void 0 : _a2.country);
16452
+ }).number;
16453
+ if (taxId2 || ((_b = data.companyRegistrationDetails) == null ? void 0 : _b.isUen)) {
16365
16454
  requestObj.organization = updateTaxInformation({
16366
- taxId: data.companyRegistrationDetails.taxId,
16367
- country: data.companyNameAndCountry.country,
16368
- isUen: data.companyRegistrationDetails.isUen,
16455
+ taxId: ((_c = data.companyRegistrationDetails) == null ? void 0 : _c.isUen) ? data.companyRegistrationDetails.registrationNumber : taxId2,
16456
+ country: (_d = data.companyNameAndCountry) == null ? void 0 : _d.country,
16457
+ exemptedFromTax: (_e = data.companyRegistrationDetails) == null ? void 0 : _e.exemptedFromTax,
16458
+ isUen: (_f = data.companyRegistrationDetails) == null ? void 0 : _f.isUen,
16369
16459
  entity: requestObj.organization
16370
16460
  });
16371
16461
  }
16462
+ requestObj.organization = transformCountryOfGoverningLawToLegalEntity(data.companyNameAndCountry, requestObj.organization);
16372
16463
  requestObj.type = LegalEntityType.ORGANIZATION;
16373
16464
  return requestObj;
16374
16465
  };
@@ -16431,7 +16522,7 @@ const mapHighExposureToLegalEntity = (data) => ({
16431
16522
  ...formatObject(data, highExposureApiKeyMapping)
16432
16523
  });
16433
16524
  const mapLegalEntityToSoleProp = (legalEntity) => {
16434
- var _a, _b, _c, _d, _e, _f, _g, _h;
16525
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
16435
16526
  let solePropCompData;
16436
16527
  if (legalEntity == null ? void 0 : legalEntity.soleProprietorship) {
16437
16528
  solePropCompData = formatObject(legalEntity, solePropComponentsKeyMapping);
@@ -16452,19 +16543,10 @@ const mapLegalEntityToSoleProp = (legalEntity) => {
16452
16543
  solePropCompData.solePropNameAndCountry = transformCountryOfGoverningLawToSchema(solePropCompData.solePropNameAndCountry, legalEntity.soleProprietorship);
16453
16544
  solePropCompData.solePropRegistrationDetails = {
16454
16545
  ...solePropCompData.solePropRegistrationDetails,
16455
- sameNameAsLegalName: !(((_e = solePropCompData.solePropNameAndCountry) == null ? void 0 : _e.legalCompanyName) && ((_f = solePropCompData.solePropRegistrationDetails) == null ? void 0 : _f.tradingName) && solePropCompData.solePropNameAndCountry.legalCompanyName !== solePropCompData.solePropRegistrationDetails.tradingName)
16546
+ tradingName: ((_e = solePropCompData.solePropRegistrationDetails) == null ? void 0 : _e.tradingName) ? (_f = solePropCompData.solePropRegistrationDetails) == null ? void 0 : _f.tradingName : (_g = solePropCompData.solePropNameAndCountry) == null ? void 0 : _g.legalCompanyName,
16547
+ sameNameAsLegalName: !(((_h = solePropCompData.solePropNameAndCountry) == null ? void 0 : _h.legalCompanyName) && ((_i = solePropCompData.solePropRegistrationDetails) == null ? void 0 : _i.tradingName) && solePropCompData.solePropNameAndCountry.legalCompanyName !== solePropCompData.solePropRegistrationDetails.tradingName)
16456
16548
  };
16457
- const {
16458
- taxInformation = []
16459
- } = legalEntity.soleProprietorship;
16460
- if (taxInformation.length) {
16461
- const {
16462
- country: country2
16463
- } = legalEntity.soleProprietorship.registeredAddress;
16464
- solePropCompData.solePropRegistrationDetails.taxId = (_g = taxInformation.find((info) => info.country === country2)) == null ? void 0 : _g.number;
16465
- solePropCompData.solePropRegistrationDetails.exemptedFromTax = false;
16466
- }
16467
- if ((_h = legalEntity == null ? void 0 : legalEntity.documentDetails) == null ? void 0 : _h.length) {
16549
+ if ((_j = legalEntity == null ? void 0 : legalEntity.documentDetails) == null ? void 0 : _j.length) {
16468
16550
  solePropCompData = {
16469
16551
  ...solePropCompData,
16470
16552
  ...mapApiDocumentToSolePropDocuments(legalEntity == null ? void 0 : legalEntity.id)
@@ -16482,20 +16564,16 @@ const mapSolePropToLegalEntity = (data) => {
16482
16564
  requestObj.soleProprietorship.vatNumber = "";
16483
16565
  }
16484
16566
  requestObj.soleProprietorship = transformCountryOfGoverningLawToLegalEntity(data.solePropNameAndCountry, requestObj.soleProprietorship);
16485
- if (data.solePropRegistrationDetails.taxId || requestObj.soleProprietorship.taxAbsent) {
16486
- requestObj.soleProprietorship = updateTaxInformation({
16487
- taxId: data.solePropRegistrationDetails.taxId,
16488
- exemptedFromTax: data.solePropRegistrationDetails.exemptedFromTax,
16489
- country: data.solePropNameAndCountry.country,
16490
- entity: requestObj.soleProprietorship
16491
- });
16492
- }
16493
16567
  if (data.solePropRegistrationDetails.exemptedFromRegistrationNumber) {
16494
16568
  requestObj.soleProprietorship.registrationNumber = "";
16495
16569
  }
16496
16570
  if (!((_a = requestObj.soleProprietorship) == null ? void 0 : _a.countryOfGoverningLaw) && ((_b = data.solePropNameAndCountry) == null ? void 0 : _b.country)) {
16497
16571
  requestObj.soleProprietorship.countryOfGoverningLaw = data.solePropNameAndCountry.country;
16498
16572
  }
16573
+ if (data.solePropNameAndCountry.country === "US") {
16574
+ delete requestObj.soleProprietorship.vatNumber;
16575
+ delete requestObj.soleProprietorship.registrationNumber;
16576
+ }
16499
16577
  requestObj.type = LegalEntityType.SOLE_PROPRIETORSHIP;
16500
16578
  return requestObj;
16501
16579
  };
@@ -17887,10 +17965,10 @@ const ContactDetailsComp = memo(ContactDetailsComponent, (prevProps, nextProps)
17887
17965
  ContactDetailsComponent.defaultProps = {
17888
17966
  data: {}
17889
17967
  };
17890
- const defaultFieldMetadata$6 = {
17968
+ const defaultFieldMetadata$5 = {
17891
17969
  label: "idNumber"
17892
17970
  };
17893
- const defaultFieldConfig$6 = {
17971
+ const defaultFieldConfig$5 = {
17894
17972
  [CountryCodes.Brazil]: {
17895
17973
  label: "cadastroDePessoasFisicas",
17896
17974
  mask: {
@@ -18351,10 +18429,10 @@ function IdentityNumberComponent(props) {
18351
18429
  idNumberExempt: !!(propData == null ? void 0 : propData.idNumberExempt)
18352
18430
  });
18353
18431
  const schema = requiredFields ?? idNumberFields;
18354
- const fieldConfig = propFieldConfig ?? defaultFieldConfig$6;
18432
+ const fieldConfig = propFieldConfig ?? defaultFieldConfig$5;
18355
18433
  const metadata = resolveFieldMetadata(fieldConfig[country2], {
18356
18434
  idNumberType
18357
- }, defaultFieldMetadata$6);
18435
+ }, defaultFieldMetadata$5);
18358
18436
  const idNumberExemptMetadata = resolveFieldMetadata(idNumberExemptDefaultConfig[country2], {}, idNumberExemptDefaultMetadata);
18359
18437
  const mergedProps = mergeFieldMetadataIntoProps("idNumberExempt", idNumberExemptMetadata, mergeFieldMetadataIntoProps("idNumber", metadata, {
18360
18438
  requiredFields: schema,
@@ -19016,9 +19094,9 @@ function IdentityAuComponent({
19016
19094
  requiredFields
19017
19095
  };
19018
19096
  const mergedProps = useMemo(() => {
19019
- const idNumberMetadata = resolveFieldMetadata(defaultFieldConfig$6[CountryCodes.Australia], {
19097
+ const idNumberMetadata = resolveFieldMetadata(defaultFieldConfig$5[CountryCodes.Australia], {
19020
19098
  idNumberType: identityType
19021
- }, defaultFieldMetadata$6);
19099
+ }, defaultFieldMetadata$5);
19022
19100
  return mergeFieldMetadataIntoProps("idNumber", idNumberMetadata, mergeFieldMetadataIntoProps("licenseCardNumber", licenseCardNumberMetaData$1, initialFormUtilProps));
19023
19101
  }, [identityType]);
19024
19102
  const {
@@ -19141,9 +19219,9 @@ function IdentityHKComponent({
19141
19219
  requiredFields
19142
19220
  };
19143
19221
  const mergedProps = useMemo(() => {
19144
- const idNumberMetadata = resolveFieldMetadata(defaultFieldConfig$6[CountryCodes.HongKong], {
19222
+ const idNumberMetadata = resolveFieldMetadata(defaultFieldConfig$5[CountryCodes.HongKong], {
19145
19223
  idNumberType: identityType
19146
- }, defaultFieldMetadata$6);
19224
+ }, defaultFieldMetadata$5);
19147
19225
  return mergeFieldMetadataIntoProps("idNumber", idNumberMetadata, initialFormUtilProps);
19148
19226
  }, [identityType]);
19149
19227
  const {
@@ -19323,9 +19401,9 @@ function IdentityNZComponent({
19323
19401
  requiredFields
19324
19402
  };
19325
19403
  const mergedProps = useMemo(() => {
19326
- const idNumberMetadata = resolveFieldMetadata(defaultFieldConfig$6[CountryCodes.NewZealand], {
19404
+ const idNumberMetadata = resolveFieldMetadata(defaultFieldConfig$5[CountryCodes.NewZealand], {
19327
19405
  idNumberType: identityType
19328
- }, defaultFieldMetadata$6);
19406
+ }, defaultFieldMetadata$5);
19329
19407
  return mergeFieldMetadataIntoProps("idNumber", idNumberMetadata, mergeFieldMetadataIntoProps("licenseCardNumber", licenseCardNumberMetaData, initialFormUtilProps));
19330
19408
  }, [identityType]);
19331
19409
  const {
@@ -21741,11 +21819,11 @@ const simpleBankAccountNumberMetadata = (example, length, maxLength) => {
21741
21819
  }
21742
21820
  };
21743
21821
  };
21744
- const defaultFieldMetadata$5 = {
21822
+ const defaultFieldMetadata$4 = {
21745
21823
  label: "bankAccountNumber",
21746
21824
  validators: isNotEmptyValidator
21747
21825
  };
21748
- const defaultFieldConfig$5 = {
21826
+ const defaultFieldConfig$4 = {
21749
21827
  [CountryCodes.Denmark]: simpleBankAccountNumberMetadata("2621955959", 10),
21750
21828
  [CountryCodes.Norway]: simpleBankAccountNumberMetadata("1117947", 7),
21751
21829
  [CountryCodes.UnitedKingdom]: simpleBankAccountNumberMetadata("10000003", 8),
@@ -21793,9 +21871,9 @@ function BankAccountNumber(props) {
21793
21871
  } = useI18nContext();
21794
21872
  const {
21795
21873
  country: country2,
21796
- fieldConfig = defaultFieldConfig$5
21874
+ fieldConfig = defaultFieldConfig$4
21797
21875
  } = props;
21798
- const metadata = resolveFieldMetadata(fieldConfig[country2], {}, defaultFieldMetadata$5);
21876
+ const metadata = resolveFieldMetadata(fieldConfig[country2], {}, defaultFieldMetadata$4);
21799
21877
  const mergedProps = mergeFieldMetadataIntoProps("bankAccountNumber", metadata, props);
21800
21878
  const {
21801
21879
  handleChangeFor,
@@ -21896,7 +21974,7 @@ function BankCity(props) {
21896
21974
  })
21897
21975
  });
21898
21976
  }
21899
- const defaultFieldMetadata$4 = {
21977
+ const defaultFieldMetadata$3 = {
21900
21978
  label: "bankCode",
21901
21979
  validators: isNotEmptyValidator
21902
21980
  };
@@ -21914,7 +21992,7 @@ const simpleBankCodeMetadata = (length, example, label) => ({
21914
21992
  }
21915
21993
  }
21916
21994
  });
21917
- const defaultFieldConfig$4 = {
21995
+ const defaultFieldConfig$3 = {
21918
21996
  [CountryCodes.Brazil]: simpleBankCodeMetadata(3, "123"),
21919
21997
  [CountryCodes.Canada]: simpleBankCodeMetadata(3, "100", "institutionNumber"),
21920
21998
  [CountryCodes.Denmark]: simpleBankCodeMetadata(4, "5051"),
@@ -21932,9 +22010,9 @@ function BankCode(props) {
21932
22010
  } = useI18nContext();
21933
22011
  const {
21934
22012
  country: country2,
21935
- fieldConfig = defaultFieldConfig$4
22013
+ fieldConfig = defaultFieldConfig$3
21936
22014
  } = props;
21937
- const metadata = resolveFieldMetadata(fieldConfig[country2], {}, defaultFieldMetadata$4);
22015
+ const metadata = resolveFieldMetadata(fieldConfig[country2], {}, defaultFieldMetadata$3);
21938
22016
  const mergedProps = mergeFieldMetadataIntoProps("bankCode", metadata, props);
21939
22017
  const {
21940
22018
  handleChangeFor,
@@ -22033,11 +22111,11 @@ function BankName(props) {
22033
22111
  })
22034
22112
  });
22035
22113
  }
22036
- const defaultFieldMetadata$3 = {
22114
+ const defaultFieldMetadata$2 = {
22037
22115
  label: "branchCode",
22038
22116
  validators: isNotEmptyValidator
22039
22117
  };
22040
- const defaultFieldConfig$3 = {
22118
+ const defaultFieldConfig$2 = {
22041
22119
  [CountryCodes.UnitedKingdom]: {
22042
22120
  label: "sortCode",
22043
22121
  validators: validatePatternOnBlur(/^\d{6}$/),
@@ -22152,9 +22230,9 @@ function BranchCode(props) {
22152
22230
  } = useI18nContext();
22153
22231
  const {
22154
22232
  country: country2,
22155
- fieldConfig = defaultFieldConfig$3
22233
+ fieldConfig = defaultFieldConfig$2
22156
22234
  } = props;
22157
- const metadata = resolveFieldMetadata(fieldConfig[country2], {}, defaultFieldMetadata$3);
22235
+ const metadata = resolveFieldMetadata(fieldConfig[country2], {}, defaultFieldMetadata$2);
22158
22236
  const mergedProps = mergeFieldMetadataIntoProps("branchCode", metadata, props);
22159
22237
  const {
22160
22238
  handleChangeFor,
@@ -22364,11 +22442,11 @@ const ibanMetadata = (country2, inputLength, example, allowLettersInBban) => ({
22364
22442
  guidanceText: ibanGuidance(allowLettersInBban ? "characters" : "digits", inputLength, example)
22365
22443
  });
22366
22444
  const gbIbanMetadata = ibanMetadata(CountryCodes.UnitedKingdom, 20, "GB09 BARC 2003 9554 8297 59", true);
22367
- const defaultFieldMetadata$2 = {
22445
+ const defaultFieldMetadata$1 = {
22368
22446
  label: "iban",
22369
22447
  validators: isNotEmptyValidator
22370
22448
  };
22371
- const defaultFieldConfig$2 = {
22449
+ const defaultFieldConfig$1 = {
22372
22450
  [CountryCodes.Austria]: ibanMetadata(CountryCodes.Austria, 18, "AT88 5400 0746 7265 9747"),
22373
22451
  [CountryCodes.Belgium]: ibanMetadata(CountryCodes.Belgium, 14, "BE59 9788 6743 2226"),
22374
22452
  [CountryCodes.Croatia]: ibanMetadata(CountryCodes.Croatia, 19, "HR51 2484 0083 5929 6973 8"),
@@ -22415,9 +22493,9 @@ function Iban(props) {
22415
22493
  } = useI18nContext();
22416
22494
  const {
22417
22495
  country: country2,
22418
- fieldConfig = defaultFieldConfig$2
22496
+ fieldConfig = defaultFieldConfig$1
22419
22497
  } = props;
22420
- const metadata = resolveFieldMetadata(fieldConfig[country2], {}, defaultFieldMetadata$2);
22498
+ const metadata = resolveFieldMetadata(fieldConfig[country2], {}, defaultFieldMetadata$1);
22421
22499
  const mergedProps = mergeFieldMetadataIntoProps("iban", metadata, props);
22422
22500
  const {
22423
22501
  handleChangeFor,
@@ -23309,17 +23387,25 @@ function SolePropComponent(props) {
23309
23387
  const {
23310
23388
  isExperimentEnabled
23311
23389
  } = useExperimentsContext();
23312
- const [tradingName2, setTradingName] = useState();
23390
+ const [currentCountry, setCurrentCountry] = useState(props.country);
23391
+ const [currentLegalName, setCurrentLegalName] = useState();
23313
23392
  const solePropNameAndCountryFormProps = getFormProps(props, solePropNameAndCountryFormId);
23314
23393
  const solePropsRegistrationDetailsFormProps = getFormProps(props, solePropRegistrationDetailsFormId);
23315
23394
  const solePropRegistrationAddressFormProps = getNestedOuterFormPropsFromOuterFormProps(props, solePropRegistrationAddressFormId);
23316
23395
  const solePropDocumentsFormProps = getFormProps(props, solePropDocumentFormId);
23317
23396
  const handleStateChange = ({
23318
- currentState
23397
+ currentState,
23398
+ prevState
23319
23399
  }) => {
23320
- var _a, _b, _c;
23321
- const legalCompanyName2 = (_b = (_a = currentState.data) == null ? void 0 : _a.solePropNameAndCountry) == null ? void 0 : _b.legalCompanyName;
23322
- setTradingName(((_c = solePropsRegistrationDetailsFormProps == null ? void 0 : solePropsRegistrationDetailsFormProps.data) == null ? void 0 : _c.tradingName) || legalCompanyName2);
23400
+ var _a, _b, _c, _d, _e, _f, _g;
23401
+ const companyCountryPrev = (_b = (_a = prevState.data) == null ? void 0 : _a[solePropNameAndCountryFormId]) == null ? void 0 : _b.country;
23402
+ const companyCountry = (_d = (_c = currentState.data) == null ? void 0 : _c[solePropNameAndCountryFormId]) == null ? void 0 : _d.country;
23403
+ setCurrentCountry(companyCountry);
23404
+ const legalCompanyName2 = (_f = (_e = currentState.data) == null ? void 0 : _e[solePropNameAndCountryFormId]) == null ? void 0 : _f.legalCompanyName;
23405
+ setCurrentLegalName(legalCompanyName2);
23406
+ if (companyCountry != null && companyCountry !== companyCountryPrev) {
23407
+ (_g = props.onCountryChange) == null ? void 0 : _g.call(props, companyCountry);
23408
+ }
23323
23409
  };
23324
23410
  const renderActiveForm = (activeForm) => {
23325
23411
  var _a;
@@ -23349,14 +23435,11 @@ function SolePropComponent(props) {
23349
23435
  className: activeForm.formId !== solePropRegistrationDetailsFormId ? "adyen-kyc-form-wrapper adyen-kyc-form-wrapper--hidden" : "adyen-kyc-form-wrapper",
23350
23436
  children: jsx(CompanyRegistrationDetailsComponent, {
23351
23437
  ...solePropsRegistrationDetailsFormProps,
23352
- data: {
23353
- ...solePropsRegistrationDetailsFormProps == null ? void 0 : solePropsRegistrationDetailsFormProps.data,
23354
- tradingName: tradingName2
23355
- },
23356
23438
  heading: i18n.get("registrationDetails"),
23357
23439
  id: solePropRegistrationDetailsFormId,
23358
23440
  companyType: CompanyTypesValue.SOLE_PROPRIETORSHIP,
23359
- country: props.country
23441
+ country: currentCountry,
23442
+ legalName: currentLegalName
23360
23443
  })
23361
23444
  }), jsx("div", {
23362
23445
  className: activeForm.formId !== solePropRegistrationAddressFormId ? "adyen-kyc-form-wrapper adyen-kyc-form-wrapper--hidden" : "adyen-kyc-form-wrapper",
@@ -23694,6 +23777,278 @@ const getCountrySpecificTrustTypeOptions = (country2) => {
23694
23777
  return countrySpecificTrustTypeOption;
23695
23778
  });
23696
23779
  };
23780
+ const businessRegistrationNumberFields = ["registrationNumber", "exemptedFromRegistrationNumber"];
23781
+ function BusinessRegistrationNumber(props) {
23782
+ var _a, _b, _c, _d;
23783
+ const fieldConfig = props.fieldConfig ?? defaultFieldConfig$9;
23784
+ const {
23785
+ i18n
23786
+ } = useI18nContext();
23787
+ const stateRef = useRef({
23788
+ setState: null
23789
+ });
23790
+ const schema = props.requiredFields || ["registrationNumber"];
23791
+ const {
23792
+ companyType: companyType2,
23793
+ country: country2
23794
+ } = props;
23795
+ const registrationNumberOptions = useMemo(() => getCompanyRegistrationNumberOptions(country2, companyType2), [country2, companyType2]);
23796
+ const defaultRegistrationNumberType = ((_a = props.data) == null ? void 0 : _a.registrationNumber) ? inferCompanyRegistrationNumberType((_b = props.data) == null ? void 0 : _b.registrationNumber, country2, companyType2) : registrationNumberOptions == null ? void 0 : registrationNumberOptions[0].id;
23797
+ const [registrationNumberType, setRegistrationNumberType] = useState(defaultRegistrationNumberType);
23798
+ const metadata = resolveFieldMetadata(fieldConfig[country2], {
23799
+ companyType: companyType2,
23800
+ registrationNumberType
23801
+ }, defaultFieldMetadata$9);
23802
+ const mergedProps = mergeFieldMetadataIntoProps("registrationNumber", metadata, {
23803
+ requiredFields: schema,
23804
+ readOnlyFields: props.readOnlyFields
23805
+ });
23806
+ const {
23807
+ handleChangeFor,
23808
+ data,
23809
+ valid,
23810
+ errors,
23811
+ isValid,
23812
+ fieldProblems
23813
+ } = useForm({
23814
+ ...mergedProps,
23815
+ schema: (data2) => data2.exemptedFromRegistrationNumber ? ["exemptedFromRegistrationNumber"] : ["registrationNumber", "exemptedFromRegistrationNumber"],
23816
+ rules: mergedProps.validators,
23817
+ defaultData: {
23818
+ ...props.data,
23819
+ exemptedFromRegistrationNumber: !!((_c = props.data) == null ? void 0 : _c.exemptedFromRegistrationNumber)
23820
+ },
23821
+ // exemptedFromRegistrationNumber should be a boolean
23822
+ fieldProblems: props == null ? void 0 : props.fieldValidationErrors
23823
+ });
23824
+ useEffect(() => {
23825
+ var _a2, _b2;
23826
+ (_b2 = (_a2 = stateRef == null ? void 0 : stateRef.current) == null ? void 0 : _a2.setState) == null ? void 0 : _b2.call(_a2, {
23827
+ type: "addToState",
23828
+ value: {
23829
+ data,
23830
+ valid,
23831
+ errors,
23832
+ caller: "businessRegistration",
23833
+ dataStoreId: props.dataStoreId
23834
+ }
23835
+ });
23836
+ }, [data, valid, errors, isValid]);
23837
+ useEffect(() => {
23838
+ if (data.registrationNumber || registrationNumberType) {
23839
+ handleChangeFor("registrationNumber", "blur")(data.registrationNumber);
23840
+ }
23841
+ }, [props.country, registrationNumberType]);
23842
+ const formUtils = formUtilities(mergedProps, i18n);
23843
+ const exemptionIsPossible = ((_d = mergedProps.requiredFields) == null ? void 0 : _d.includes("exemptedFromRegistrationNumber")) ?? false;
23844
+ const showExemptedOption = exemptionIsPossible && !!registrationNumberOptions && registrationNumberOptions.length > 1;
23845
+ const handleCompanyRegistrationNumberTypeChange = (regNumberType) => {
23846
+ if (regNumberType === "exempted") {
23847
+ if (!exemptionIsPossible) {
23848
+ throw Error(`${country2} does not allow tax exemptions`);
23849
+ }
23850
+ handleChangeFor("exemptedFromRegistrationNumber")(true);
23851
+ setRegistrationNumberType(void 0);
23852
+ return;
23853
+ }
23854
+ if (exemptionIsPossible && data.exemptedFromRegistrationNumber === true) {
23855
+ handleChangeFor("exemptedFromRegistrationNumber")(false);
23856
+ }
23857
+ setRegistrationNumberType(regNumberType);
23858
+ };
23859
+ return jsxs("div", {
23860
+ className: "adyen-kyc-field__business-registration adyen-kyc-u-margin-bottom-16",
23861
+ children: [jsx(StateContextSetter, {
23862
+ stateRef
23863
+ }), jsx(CompanyRegistrationNumberTypeSelector, {
23864
+ companyType: companyType2,
23865
+ country: country2,
23866
+ setSelected: handleCompanyRegistrationNumberTypeChange,
23867
+ selected: data.exemptedFromRegistrationNumber ? "exempted" : registrationNumberType,
23868
+ exemptedOption: showExemptedOption ? formUtils.getLabel("exemptedFromRegistrationNumber", "iDontHaveARegistrationNumber") : false
23869
+ }), jsx(MaskedInputText, {
23870
+ name: "registrationNumber",
23871
+ label: formUtils.getLabel("registrationNumber", "companyRegistrationNumber"),
23872
+ formatGuidance: formUtils.getGuidanceText("registrationNumber"),
23873
+ classNameModifiers: {
23874
+ field: ["registrationNumber"],
23875
+ input: ["registrationNumber"]
23876
+ },
23877
+ errorMessage: formUtils.getErrorMessage("registrationNumber", errors, fieldProblems),
23878
+ shouldValidate: props.shouldValidate,
23879
+ isValid: valid.registrationNumber,
23880
+ "aria-required": formUtils.isRequiredField("registrationNumber"),
23881
+ "aria-label": formUtils.getLabel("registrationNumber"),
23882
+ "aria-invalid": !valid.registrationNumber,
23883
+ disabled: data.exemptedFromRegistrationNumber,
23884
+ onBlur: handleChangeFor("registrationNumber", "blur"),
23885
+ readonly: formUtils.isReadOnly("registrationNumber"),
23886
+ value: data.registrationNumber ?? "",
23887
+ onInput: handleChangeFor("registrationNumber", "input"),
23888
+ ...formUtils.getMask("registrationNumber")
23889
+ }), formUtils.isRequiredField("exemptedFromRegistrationNumber") && !showExemptedOption && jsx(Checkbox, {
23890
+ name: "exemptedFromRegistrationNumber",
23891
+ label: formUtils.getLabel("iDontHaveARegistrationNumber"),
23892
+ value: "exemptedFromRegistrationNumber",
23893
+ readonly: formUtils.isReadOnly("exemptedFromRegistrationNumber"),
23894
+ classNameModifiers: ["exempted-from-registration"],
23895
+ checked: data.exemptedFromRegistrationNumber ?? false,
23896
+ onChange: handleChangeFor("exemptedFromRegistrationNumber"),
23897
+ "aria-required": formUtils.isRequiredField("exemptedFromRegistrationNumber"),
23898
+ "aria-label": formUtils.getLabel("exemptedFromRegistrationNumber"),
23899
+ "aria-invalid": false
23900
+ })]
23901
+ });
23902
+ }
23903
+ const taxIdFields = ["taxId", "exemptedFromTax", "isUen"];
23904
+ function TaxId(props) {
23905
+ var _a, _b, _c;
23906
+ const {
23907
+ data: propData,
23908
+ country: country2,
23909
+ companyType: companyType2,
23910
+ fieldValidationErrors,
23911
+ dataStoreId,
23912
+ fieldConfig = defaultFieldConfig$8
23913
+ } = props;
23914
+ const existingTaxId = propData == null ? void 0 : propData.taxId;
23915
+ const defaultTaxIdNumberType = existingTaxId ? inferTaxIdNumberType(existingTaxId, country2, companyType2) : (_a = getTaxIdNumberOptions(country2, companyType2)) == null ? void 0 : _a[0].id;
23916
+ const [taxIdNumberType, setTaxIdNumberType] = useState(defaultTaxIdNumberType);
23917
+ const metadata = resolveFieldMetadata(fieldConfig[country2], {
23918
+ taxIdNumberType,
23919
+ companyType: companyType2
23920
+ }, defaultFieldMetadata$8);
23921
+ const mergedProps = mergeFieldMetadataIntoProps("taxId", metadata, props);
23922
+ const {
23923
+ i18n
23924
+ } = useI18nContext();
23925
+ const formUtils = formUtilities(mergedProps, i18n);
23926
+ const stateRef = useRef({
23927
+ setState: null
23928
+ });
23929
+ const {
23930
+ handleChangeFor,
23931
+ data,
23932
+ valid,
23933
+ errors,
23934
+ isValid,
23935
+ fieldProblems
23936
+ } = useForm({
23937
+ ...mergedProps,
23938
+ schema: (data2) => formUtils.isRequiredField("isUen") ? ["taxId", "isUen"] : data2.exemptedFromTax ? ["exemptedFromTax"] : ["taxId", "exemptedFromTax"],
23939
+ rules: mergedProps.validators,
23940
+ defaultData: {
23941
+ ...propData,
23942
+ exemptedFromTax: Boolean(propData == null ? void 0 : propData.exemptedFromTax),
23943
+ // exemptedFromTax should be a boolean
23944
+ isUen: formUtils.isRequiredField("isUen") ? Boolean(propData == null ? void 0 : propData.isUen) : void 0
23945
+ },
23946
+ fieldProblems: fieldValidationErrors
23947
+ });
23948
+ useEffect(() => {
23949
+ if (data.taxId || taxIdNumberType) {
23950
+ handleChangeFor("taxId", "blur")(data.taxId);
23951
+ }
23952
+ }, [taxIdNumberType, country2]);
23953
+ useEffect(() => {
23954
+ var _a2, _b2;
23955
+ (_b2 = (_a2 = stateRef.current) == null ? void 0 : _a2.setState) == null ? void 0 : _b2.call(_a2, {
23956
+ type: "addToState",
23957
+ value: {
23958
+ data,
23959
+ valid,
23960
+ errors,
23961
+ caller: "taxId",
23962
+ dataStoreId
23963
+ }
23964
+ });
23965
+ }, [data, valid, errors, isValid, dataStoreId]);
23966
+ const {
23967
+ sliceData: companyRegistrationDetails
23968
+ } = useGlobalDataSlice("companyRegistrationDetails");
23969
+ const registrationNumber2 = companyRegistrationDetails == null ? void 0 : companyRegistrationDetails.registrationNumber;
23970
+ const handleUenOrGstChange = (isUen) => {
23971
+ handleChangeFor("isUen", "input")(isUen);
23972
+ if (isUen) {
23973
+ handleChangeFor("taxId", "blur")(registrationNumber2);
23974
+ return;
23975
+ }
23976
+ handleChangeFor("taxId", "blur")("");
23977
+ };
23978
+ useEffect(() => {
23979
+ if (data.isUen) {
23980
+ handleChangeFor("taxId", "blur")(registrationNumber2);
23981
+ }
23982
+ }, [registrationNumber2]);
23983
+ if (!formUtils.isRequiredField("taxId")) {
23984
+ return null;
23985
+ }
23986
+ const exemptionIsPossible = ((_b = mergedProps.requiredFields) == null ? void 0 : _b.includes("exemptedFromTax")) ?? false;
23987
+ const showTaxIdExemptedOption = exemptionIsPossible && (((_c = getTaxIdNumberOptions(country2, companyType2)) == null ? void 0 : _c.length) ?? 0) > 1;
23988
+ const handleTaxIdNumberTypeChange = (taxIdType) => {
23989
+ if (taxIdType === "exempted") {
23990
+ if (!exemptionIsPossible) {
23991
+ throw Error(`${country2} does not allow tax exemptions`);
23992
+ }
23993
+ handleChangeFor("exemptedFromTax")(true);
23994
+ setTaxIdNumberType(void 0);
23995
+ return;
23996
+ }
23997
+ if (exemptionIsPossible && data.exemptedFromTax === true) {
23998
+ handleChangeFor("exemptedFromTax")(false);
23999
+ }
24000
+ setTaxIdNumberType(taxIdType);
24001
+ };
24002
+ return jsxs("div", {
24003
+ className: "adyen-kyc-field--tax-id",
24004
+ children: [jsx(StateContextSetter, {
24005
+ stateRef
24006
+ }), jsx(TaxIdNumberTypeSelector, {
24007
+ country: country2,
24008
+ companyType: companyType2,
24009
+ setSelected: handleTaxIdNumberTypeChange,
24010
+ selected: data.exemptedFromTax ? "exempted" : taxIdNumberType,
24011
+ exemptedOption: showTaxIdExemptedOption ? formUtils.getLabel("exemptedFromTax", "iDontHaveATaxId") : false
24012
+ }), !data.isUen && jsx(MaskedInputText, {
24013
+ name: "taxId",
24014
+ label: formUtils.getLabel("taxId"),
24015
+ formatGuidance: formUtils.getGuidanceText("taxId"),
24016
+ ...formUtils.getMask("taxId"),
24017
+ classNameModifiers: {
24018
+ field: ["tax-id"],
24019
+ input: ["tax-id"]
24020
+ },
24021
+ errorMessage: formUtils.getErrorMessage("taxId", errors, fieldProblems),
24022
+ shouldValidate: props.shouldValidate,
24023
+ isValid: valid.taxId,
24024
+ value: data.taxId ?? "",
24025
+ readonly: formUtils.isReadOnly("taxId"),
24026
+ onInput: handleChangeFor("taxId", "input"),
24027
+ onBlur: handleChangeFor("taxId", "blur"),
24028
+ disabled: data.exemptedFromTax || data.isUen
24029
+ }), formUtils.isRequiredField("isUen") && jsx(Checkbox, {
24030
+ name: "isUen",
24031
+ label: formUtils.getLabel("iDoNotHaveGst"),
24032
+ classNameModifiers: ["exempted-from-tax"],
24033
+ checked: Boolean(data.isUen),
24034
+ onChange: handleUenOrGstChange,
24035
+ "aria-required": false,
24036
+ "aria-label": formUtils.getLabel("iDoNotHaveGst"),
24037
+ "aria-invalid": false
24038
+ }), formUtils.isRequiredField("exemptedFromTax") && !showTaxIdExemptedOption && jsx(Checkbox, {
24039
+ name: "exemptedFromTax",
24040
+ label: formUtils.getLabel("exemptedFromTax", "iDontHaveATaxId"),
24041
+ value: "exemptedFromTax",
24042
+ readonly: formUtils.isReadOnly("exemptedFromTax"),
24043
+ classNameModifiers: ["exempted-from-tax"],
24044
+ checked: Boolean(data.exemptedFromTax),
24045
+ onChange: handleChangeFor("exemptedFromTax"),
24046
+ "aria-required": false,
24047
+ "aria-label": formUtils.getLabel("exemptedFromTax"),
24048
+ "aria-invalid": false
24049
+ })]
24050
+ });
24051
+ }
23697
24052
  const trustRegistrationDetailsValidations = {
23698
24053
  trustType: {
23699
24054
  modes: ["blur"],
@@ -25660,127 +26015,6 @@ const getFieldsWithExistingData = (legalEntity, isExperimentEnabled) => {
25660
26015
  }
25661
26016
  return nonDocumentFields;
25662
26017
  };
25663
- const BUSINESS_REGISTRATION_NUMBER_FIELD = ["registrationNumber", "exemptedFromRegistrationNumber"];
25664
- function BusinessRegistrationNumberField({
25665
- data,
25666
- valid,
25667
- errors,
25668
- labels: labels2,
25669
- mask,
25670
- guidanceText,
25671
- placeholders,
25672
- readonly,
25673
- shouldValidate,
25674
- optional: optional2,
25675
- handleChangeFor,
25676
- country: country2,
25677
- canExempt,
25678
- companyType: companyType2,
25679
- registrationNumberOptions,
25680
- registrationNumberType,
25681
- setRegistrationNumberType
25682
- }) {
25683
- const showExemptedOption = canExempt && !!registrationNumberOptions && registrationNumberOptions.length > 1;
25684
- const handleCompanyRegistrationNumberTypeChange = (regNumberType) => {
25685
- if (regNumberType === "exempted") {
25686
- if (!canExempt) {
25687
- throw Error(`${country2} does not allow tax exemptions`);
25688
- }
25689
- handleChangeFor("exemptedFromRegistrationNumber")(true);
25690
- setRegistrationNumberType(void 0);
25691
- return;
25692
- }
25693
- if (canExempt && data.exemptedFromRegistrationNumber === true) {
25694
- handleChangeFor("exemptedFromRegistrationNumber")(false);
25695
- }
25696
- setRegistrationNumberType(regNumberType);
25697
- };
25698
- return jsxs("div", {
25699
- className: "adyen-kyc-field__business-registration",
25700
- children: [jsx(CompanyRegistrationNumberTypeSelector, {
25701
- companyType: companyType2,
25702
- country: country2,
25703
- setSelected: handleCompanyRegistrationNumberTypeChange,
25704
- selected: data.exemptedFromRegistrationNumber ? "exempted" : registrationNumberType,
25705
- exemptedOption: showExemptedOption ? labels2.exemptedFromRegistrationNumber : false
25706
- }), jsx(MaskedInputText, {
25707
- "aria-required": true,
25708
- "aria-label": labels2.registrationNumber,
25709
- "aria-invalid": !valid.registrationNumber,
25710
- classNameModifiers: {
25711
- field: ["registrationNumber"],
25712
- input: ["registrationNumber"]
25713
- },
25714
- name: "registrationNumber",
25715
- value: (data == null ? void 0 : data.registrationNumber) ?? "",
25716
- label: labels2.registrationNumber ?? "",
25717
- formatGuidance: (guidanceText == null ? void 0 : guidanceText.registrationNumber) ?? "",
25718
- placeholder: placeholders == null ? void 0 : placeholders.registrationNumber,
25719
- errorMessage: errors.registrationNumber,
25720
- isValid: Boolean(valid.registrationNumber),
25721
- onInput: handleChangeFor("registrationNumber", "input"),
25722
- onBlur: handleChangeFor("registrationNumber", "blur"),
25723
- disabled: data.exemptedFromRegistrationNumber,
25724
- optional: optional2,
25725
- readonly,
25726
- shouldValidate: !optional2 && shouldValidate,
25727
- ...mask
25728
- }), canExempt && jsx(Checkbox, {
25729
- "aria-required": false,
25730
- "aria-label": labels2 == null ? void 0 : labels2.exemptedFromRegistrationNumber,
25731
- "aria-invalid": false,
25732
- name: "exemptedFromRegistrationNumber",
25733
- value: "exemptedFromRegistrationNumber",
25734
- checked: Boolean(data.exemptedFromRegistrationNumber),
25735
- label: labels2 == null ? void 0 : labels2.exemptedFromRegistrationNumber,
25736
- readonly,
25737
- classNameModifiers: ["exempted-from-registration"],
25738
- onChange: handleChangeFor("exemptedFromRegistrationNumber")
25739
- })]
25740
- });
25741
- }
25742
- const DATE_OF_INCORPORATION_FIELD = ["dateOfIncorporation"];
25743
- function DateOfIncorporationField({
25744
- data,
25745
- valid,
25746
- errors,
25747
- labels: labels2,
25748
- placeholders,
25749
- readonly,
25750
- handleChangeFor
25751
- }) {
25752
- return jsx(Field, {
25753
- name: "dateOfIncorporation",
25754
- label: labels2.dateOfIncorporation,
25755
- classNameModifiers: ["dateOfIncorporation"],
25756
- errorMessage: errors.dateOfIncorporation,
25757
- isValid: valid.dateOfIncorporation,
25758
- children: (childProps) => jsx(InputDate, {
25759
- ...childProps,
25760
- "aria-required": true,
25761
- "aria-label": labels2.dateOfIncorporation,
25762
- "aria-invalid": !valid.dateOfIncorporation,
25763
- name: "dateOfIncorporation",
25764
- value: data.dateOfIncorporation,
25765
- placeholder: placeholders == null ? void 0 : placeholders.dateOfIncorporation,
25766
- readonly,
25767
- onInput: handleChangeFor("dateOfIncorporation", "input"),
25768
- onBlur: handleChangeFor("dateOfIncorporation", "blur"),
25769
- max: formatDateObj(/* @__PURE__ */ new Date())
25770
- })
25771
- });
25772
- }
25773
- const DateOfIncorporationFieldValidation = () => ({
25774
- dateOfIncorporation: [{
25775
- modes: ["blur"],
25776
- validate: (dateOfIncorporation2) => !isEmpty(dateOfIncorporation2),
25777
- errorMessage: "fieldIsRequired"
25778
- }, {
25779
- modes: ["blur"],
25780
- validate: (dateOfIncorporation2) => dateOfIncorporation2 ? new Date(dateOfIncorporation2) < /* @__PURE__ */ new Date() : false,
25781
- errorMessage: "invalidDateOfIncorporation"
25782
- }]
25783
- });
25784
26018
  const DBA_NAME_FIELD = ["hasDba", "dbaName"];
25785
26019
  function DBANameField({
25786
26020
  data,
@@ -25849,207 +26083,6 @@ const dbaNameFieldMetadata = {
25849
26083
  label: "dbaName",
25850
26084
  validators: [validateNotEmptyOnBlur]
25851
26085
  };
25852
- const TAX_INFORMATION_FIELD = ["taxInformation", "exemptedFromTax", "isUen"];
25853
- function TaxInformationField({
25854
- data,
25855
- valid,
25856
- errors,
25857
- labels: labels2,
25858
- mask,
25859
- guidanceText,
25860
- placeholders,
25861
- readonly,
25862
- shouldValidate,
25863
- handleChangeFor,
25864
- country: country2,
25865
- canExempt,
25866
- registrationNumber: registrationNumber2,
25867
- isUen,
25868
- companyType: companyType2,
25869
- taxIdNumberType,
25870
- setTaxIdNumberType,
25871
- defaultData
25872
- }) {
25873
- var _a;
25874
- useEffect(() => {
25875
- handleChangeFor("taxInformation", "input")(defaultData);
25876
- }, [country2]);
25877
- const currentCountryTaxInformation = useMemo(() => {
25878
- var _a2;
25879
- return (_a2 = data == null ? void 0 : data.taxInformation) == null ? void 0 : _a2.find((taxInfo) => taxInfo.country === country2);
25880
- }, [data, country2]);
25881
- const showTaxIdExemptedOption = canExempt && (((_a = getTaxIdNumberOptions(country2, companyType2)) == null ? void 0 : _a.length) ?? 0) > 1;
25882
- const removeCurrentCountryTaxInformation = () => {
25883
- var _a2;
25884
- const filterdTaxInformation = (_a2 = data.taxInformation) == null ? void 0 : _a2.filter((taxId2) => taxId2.country !== country2);
25885
- handleChangeFor("taxInformation", "input")(filterdTaxInformation);
25886
- };
25887
- const setUenAsTaxId = (uen2) => {
25888
- if (!data.taxInformation) {
25889
- return handleChangeFor("taxInformation", "blur")([{
25890
- country: country2,
25891
- number: uen2 ?? "",
25892
- type: "UEN"
25893
- }]);
25894
- }
25895
- const taxInformation = currentCountryTaxInformation ? data.taxInformation : [...data.taxInformation, {
25896
- country: country2,
25897
- number: uen2 ?? "",
25898
- type: "UEN"
25899
- }];
25900
- const updatedTaxInformation = taxInformation.map((taxInfo) => {
25901
- if (taxInfo.country !== country2) return taxInfo;
25902
- return {
25903
- country: country2,
25904
- number: uen2 ?? "",
25905
- type: "UEN"
25906
- };
25907
- });
25908
- return handleChangeFor("taxInformation", "blur")(updatedTaxInformation);
25909
- };
25910
- const handleTaxInformationInput = (value) => {
25911
- if (!data.taxInformation) {
25912
- const updatedTaxInformation2 = [{
25913
- country: country2,
25914
- number: value,
25915
- type: data.isUen ? "UEN" : countryToTaxInfoTypeMap[country2]
25916
- }];
25917
- return handleChangeFor("taxInformation", "input")(updatedTaxInformation2);
25918
- }
25919
- const taxInformation = currentCountryTaxInformation ? data.taxInformation : [...data.taxInformation, {
25920
- country: country2,
25921
- number: value,
25922
- type: data.isUen ? "UEN" : countryToTaxInfoTypeMap[country2]
25923
- }];
25924
- const updatedTaxInformation = taxInformation.map((taxInfo) => {
25925
- if (taxInfo.country !== country2) return taxInfo;
25926
- return {
25927
- country: country2,
25928
- number: value,
25929
- type: data.isUen ? "UEN" : countryToTaxInfoTypeMap[country2]
25930
- };
25931
- });
25932
- return handleChangeFor("taxInformation", "input")(updatedTaxInformation);
25933
- };
25934
- const handleTaxInformationBlur = (e) => {
25935
- const {
25936
- value
25937
- } = e.target;
25938
- if (!data.taxInformation) {
25939
- const updatedTaxInformation2 = [{
25940
- country: country2,
25941
- number: value,
25942
- type: data.isUen ? "UEN" : countryToTaxInfoTypeMap[country2]
25943
- }];
25944
- return handleChangeFor("taxInformation", "blur")(updatedTaxInformation2);
25945
- }
25946
- const taxInformation = currentCountryTaxInformation ? data.taxInformation : [...data.taxInformation, {
25947
- country: country2,
25948
- number: value,
25949
- type: data.isUen ? "UEN" : countryToTaxInfoTypeMap[country2]
25950
- }];
25951
- const updatedTaxInformation = taxInformation.map((taxInfo) => {
25952
- if (taxInfo.country !== country2) return taxInfo;
25953
- return {
25954
- country: country2,
25955
- number: value,
25956
- type: data.isUen ? "UEN" : countryToTaxInfoTypeMap[country2]
25957
- };
25958
- });
25959
- return handleChangeFor("taxInformation", "blur")(updatedTaxInformation);
25960
- };
25961
- const handleTaxIdNumberTypeChange = (taxIdType) => {
25962
- if (taxIdType === "exempted") {
25963
- if (!canExempt) {
25964
- throw Error(`${country2} does not allow tax exemptions`);
25965
- }
25966
- handleChangeFor("exemptedFromTax")(true);
25967
- removeCurrentCountryTaxInformation();
25968
- setTaxIdNumberType(void 0);
25969
- return;
25970
- }
25971
- if (isUen) {
25972
- if (taxIdType === "UEN") {
25973
- handleChangeFor("isUen")(true);
25974
- setUenAsTaxId(registrationNumber2);
25975
- } else {
25976
- handleChangeFor("isUen")(false);
25977
- removeCurrentCountryTaxInformation();
25978
- }
25979
- }
25980
- if (canExempt && data.exemptedFromTax === true) {
25981
- handleChangeFor("exemptedFromTax")(false);
25982
- }
25983
- setTaxIdNumberType(taxIdType);
25984
- };
25985
- const handleExemptedFromTaxChange = (exempted) => {
25986
- handleChangeFor("exemptedFromTax")(exempted);
25987
- removeCurrentCountryTaxInformation();
25988
- };
25989
- return jsxs("div", {
25990
- className: "adyen-kyc-field__tax-information",
25991
- children: [jsx(TaxIdNumberTypeSelector, {
25992
- country: country2,
25993
- companyType: companyType2,
25994
- setSelected: handleTaxIdNumberTypeChange,
25995
- selected: data.exemptedFromTax ? "exempted" : taxIdNumberType,
25996
- exemptedOption: showTaxIdExemptedOption ? labels2.exemptedFromTax : false
25997
- }), !data.isUen && jsx(MaskedInputText, {
25998
- "aria-required": true,
25999
- "aria-label": labels2.taxInformation,
26000
- "aria-invalid": !valid.taxInformation,
26001
- name: "taxInformationNumber",
26002
- label: labels2.taxInformation ?? "",
26003
- formatGuidance: (guidanceText == null ? void 0 : guidanceText.taxInformation) ?? "",
26004
- value: (currentCountryTaxInformation == null ? void 0 : currentCountryTaxInformation.number) ?? "",
26005
- errorMessage: errors.taxInformation,
26006
- placeholder: placeholders == null ? void 0 : placeholders.taxInformation,
26007
- isValid: Boolean(valid.taxInformation) && !!currentCountryTaxInformation,
26008
- onInput: handleTaxInformationInput,
26009
- onBlur: handleTaxInformationBlur,
26010
- disabled: data.exemptedFromTax || data.isUen,
26011
- readonly,
26012
- shouldValidate,
26013
- ...mask
26014
- }), canExempt && !showTaxIdExemptedOption && jsx(Checkbox, {
26015
- "aria-required": false,
26016
- "aria-label": labels2.exemptedFromTax,
26017
- "aria-invalid": false,
26018
- name: "exemptedFromTax",
26019
- label: labels2.exemptedFromTax,
26020
- value: "exemptedFromTax",
26021
- classNameModifiers: ["exempted-from-tax"],
26022
- checked: Boolean(data.exemptedFromTax),
26023
- onChange: handleExemptedFromTaxChange
26024
- })]
26025
- });
26026
- }
26027
- const defaultFieldMetadata$1 = defaultFieldMetadata$8;
26028
- const defaultFieldConfig$1 = entriesOf(defaultFieldConfig$8).reduce((fieldConfig, [country2, countryEntry]) => ({
26029
- ...fieldConfig,
26030
- [country2]: ({
26031
- taxIdNumberType,
26032
- companyType: companyType2
26033
- }) => {
26034
- const fieldMetadata = resolveFieldMetadata(countryEntry, {
26035
- taxIdNumberType,
26036
- companyType: companyType2
26037
- }, defaultFieldMetadata$8);
26038
- const taxIdValidators = fieldMetadata.validators ? Array.isArray(fieldMetadata.validators) ? fieldMetadata.validators : [fieldMetadata.validators] : [];
26039
- const mappedValidators = taxIdValidators.map((validator) => ({
26040
- ...validator,
26041
- validate: (taxInformation) => {
26042
- var _a;
26043
- const taxIdNumber2 = (_a = taxInformation == null ? void 0 : taxInformation.find((taxId2) => country2 === taxId2.country)) == null ? void 0 : _a.number;
26044
- return taxIdNumber2 ? validator.validate(taxIdNumber2) : false;
26045
- }
26046
- }));
26047
- return {
26048
- ...fieldMetadata,
26049
- validators: mappedValidators
26050
- };
26051
- }
26052
- }), {});
26053
26086
  function VerifiedBusinessCard({
26054
26087
  verifiedBusiness
26055
26088
  }) {
@@ -26179,7 +26212,20 @@ function AdditionalInformationComponent({
26179
26212
  if (currentData.exemptedFromVat) {
26180
26213
  fieldsToRemove.push("vatNumber");
26181
26214
  } else {
26182
- fieldsToRemove.push("vatAbsenceReason");
26215
+ fieldsToRemove.push("exemptedFromVat", "vatAbsenceReason");
26216
+ }
26217
+ if (currentData.exemptedFromTax) {
26218
+ fieldsToRemove.push("taxInformation");
26219
+ } else {
26220
+ fieldsToRemove.push("exemptedFromTax");
26221
+ }
26222
+ if (currentData.isUen) {
26223
+ fieldsToRemove.push("taxInformation", "exemptedFromTax");
26224
+ }
26225
+ if (currentData.exemptedFromRegistrationNumber) {
26226
+ fieldsToRemove.push("registrationNumber");
26227
+ } else {
26228
+ fieldsToRemove.push("exemptedFromRegistrationNumber");
26183
26229
  }
26184
26230
  if (!currentData.hasDba) {
26185
26231
  fieldsToRemove.push("dbaName");
@@ -26204,9 +26250,9 @@ function AdditionalInformationComponent({
26204
26250
  registrationNumberType
26205
26251
  }, defaultFieldMetadata$9), acc);
26206
26252
  case "taxInformation":
26207
- return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$1[country2], {
26253
+ return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$6[country2], {
26208
26254
  taxIdNumberType
26209
- }, defaultFieldMetadata$1), acc);
26255
+ }, defaultFieldMetadata$6), acc);
26210
26256
  case "vatNumber":
26211
26257
  return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$7[country2], {
26212
26258
  vatNumberType
@@ -26214,13 +26260,7 @@ function AdditionalInformationComponent({
26214
26260
  case "vatAbsenceReason":
26215
26261
  return mergeFieldMetadataIntoProps("vatAbsenceReason", vatAbsenceReasonMetadata, acc);
26216
26262
  case "dateOfIncorporation":
26217
- return {
26218
- ...acc,
26219
- validators: {
26220
- ...acc.validators,
26221
- ...DateOfIncorporationFieldValidation()
26222
- }
26223
- };
26263
+ return mergeFieldMetadataIntoProps("dateOfIncorporation", dateOfIncorporationFieldMetadata, acc);
26224
26264
  case "stockExchangeMIC":
26225
26265
  return mergeFieldMetadataIntoProps("stockExchangeMIC", stockExchangeMICFieldMetadata, acc);
26226
26266
  case "stockISIN":
@@ -26606,9 +26646,9 @@ function BasicInformationComponent({
26606
26646
  state: sliceData == null ? void 0 : sliceData.stateOrProvince
26607
26647
  }, defaultFieldMetadata$9), acc);
26608
26648
  case "taxInformation":
26609
- return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$1[country2], {
26649
+ return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$6[country2], {
26610
26650
  taxIdNumberType
26611
- }, defaultFieldMetadata$1), acc);
26651
+ }, defaultFieldMetadata$6), acc);
26612
26652
  default:
26613
26653
  return acc;
26614
26654
  }
@@ -28764,11 +28804,11 @@ const formatBasicInformation = (data, labels2, datasetUtils, companyType2) => {
28764
28804
  companyType: companyType2,
28765
28805
  registrationNumberType: data.registrationNumber ? inferCompanyRegistrationNumberType(data == null ? void 0 : data.registrationNumber, country2, companyType2) : (_a = getCompanyRegistrationNumberOptions(country2, companyType2)) == null ? void 0 : _a[0].id
28766
28806
  }, defaultFieldMetadata$9).label;
28767
- const taxIdLabel = resolveFieldMetadata(defaultFieldConfig$1[country2], {
28807
+ const taxIdLabel = resolveFieldMetadata(defaultFieldConfig$6[country2], {
28768
28808
  taxIdNumberType: countryToTaxInfoTypeMap[country2] ?? void 0,
28769
28809
  // TODO use type selector
28770
28810
  companyType: void 0
28771
- }, defaultFieldMetadata$1).label;
28811
+ }, defaultFieldMetadata$6).label;
28772
28812
  return {
28773
28813
  [((_b = labels2 == null ? void 0 : labels2.basicInformation) == null ? void 0 : _b.country) ?? "country"]: datasetUtils.getCountryName(data.country),
28774
28814
  [getKeyForField("stateOrProvince", data.country)]: datasetUtils.getStateName(data.stateOrProvince, data.country),
@@ -28782,11 +28822,11 @@ const formatAdditionalInformation = (data, labels2, country2, companyType2) => {
28782
28822
  companyType: companyType2,
28783
28823
  registrationNumberType: data.registrationNumber ? inferCompanyRegistrationNumberType(data == null ? void 0 : data.registrationNumber, country2, companyType2) : (_a = getCompanyRegistrationNumberOptions(country2, companyType2)) == null ? void 0 : _a[0].id
28784
28824
  }, defaultFieldMetadata$9).label;
28785
- const taxIdLabel = resolveFieldMetadata(defaultFieldConfig$1[country2], {
28825
+ const taxIdLabel = resolveFieldMetadata(defaultFieldConfig$6[country2], {
28786
28826
  taxIdNumberType: countryToTaxInfoTypeMap[country2] ?? void 0,
28787
28827
  // TODO use type selector
28788
28828
  companyType: void 0
28789
- }, defaultFieldMetadata$1).label;
28829
+ }, defaultFieldMetadata$6).label;
28790
28830
  return {
28791
28831
  [((_b = labels2 == null ? void 0 : labels2.additionalInformation) == null ? void 0 : _b.legalCompanyName) ?? "legalCompanyName"]: data.legalCompanyName,
28792
28832
  [((_c = labels2 == null ? void 0 : labels2.additionalInformation) == null ? void 0 : _c.dbaName) ?? "dbaName"]: data.dbaName,
@@ -29612,7 +29652,7 @@ function CompanyDropinComponent({
29612
29652
  }, []);
29613
29653
  const datasetUtils = datasetUtilities(i18n.locale);
29614
29654
  const formatDataForSummary2 = (data2, forms22) => {
29615
- var _a2, _b2, _c, _d, _e, _f;
29655
+ var _a2, _b2, _c, _d, _e, _f, _g;
29616
29656
  let summaryData = cloneObject(data2);
29617
29657
  if (summaryData.companyNameAndCountry) {
29618
29658
  if (isCountryOfGoverningLawEnabled) {
@@ -29643,6 +29683,16 @@ function CompanyDropinComponent({
29643
29683
  summaryData.companyRegistrationDetails.vatAbsenceReason = i18n.get(vatAbsenceReason2);
29644
29684
  }
29645
29685
  }
29686
+ if ((_g = summaryData.companyRegistrationDetails) == null ? void 0 : _g.taxInformation) {
29687
+ const taxInformation = summaryData.companyRegistrationDetails.taxInformation.find((taxId2) => {
29688
+ var _a3;
29689
+ return taxId2.country === ((_a3 = data2.companyNameAndCountry) == null ? void 0 : _a3.country);
29690
+ });
29691
+ if (taxInformation) {
29692
+ summaryData.companyRegistrationDetails[taxInformation.type] = taxInformation.number;
29693
+ }
29694
+ delete summaryData.companyRegistrationDetails.taxInformation;
29695
+ }
29646
29696
  if (isDocumentsRequired$2(forms22)) {
29647
29697
  companyDocumentForms.forEach((formId) => delete summaryData[formId]);
29648
29698
  summaryData = {
@@ -30153,10 +30203,10 @@ function CompanyBasics({
30153
30203
  isBusiness: false
30154
30204
  }, defaultFieldMetadata), acc);
30155
30205
  case "taxInformation":
30156
- return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$1[country2], {
30206
+ return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$6[country2], {
30157
30207
  taxIdNumberType,
30158
30208
  companyType: companyType2
30159
- }, defaultFieldMetadata$1), acc);
30209
+ }, defaultFieldMetadata$6), acc);
30160
30210
  default:
30161
30211
  return acc;
30162
30212
  }
@@ -30284,64 +30334,6 @@ function CompanyBasics({
30284
30334
  });
30285
30335
  }
30286
30336
  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.obscuredFields === nextProps.obscuredFields && prevProps.optionalFields === nextProps.optionalFields && prevProps.readOnlyFields === nextProps.readOnlyFields && prevProps.shouldValidate === nextProps.shouldValidate && prevProps.companyType === nextProps.companyType && objectsDeepEqual(prevProps.kompanyVerifiedData, nextProps.kompanyVerifiedData));
30287
- const TRADING_NAME_FIELD = ["tradingName", "sameNameAsLegalName"];
30288
- function TradingNameField({
30289
- data,
30290
- valid,
30291
- errors,
30292
- labels: labels2,
30293
- readonly,
30294
- handleChangeFor,
30295
- legalCompanyName: legalCompanyName2
30296
- }) {
30297
- const handleSameAsLegalName = useCallback((isChecked) => {
30298
- handleChangeFor("sameNameAsLegalName", "input")(isChecked);
30299
- if (isChecked) {
30300
- handleChangeFor("tradingName")(legalCompanyName2);
30301
- }
30302
- }, [handleChangeFor, legalCompanyName2]);
30303
- useEffect(() => {
30304
- if (data.sameNameAsLegalName && data.tradingName && legalCompanyName2 && data.tradingName !== legalCompanyName2) {
30305
- return handleChangeFor("tradingName")(legalCompanyName2);
30306
- }
30307
- }, [legalCompanyName2, data.sameNameAsLegalName, data.tradingName, handleChangeFor]);
30308
- return jsxs(Fragment, {
30309
- children: [jsx(Field, {
30310
- name: "tradingNameField",
30311
- label: labels2.tradingName,
30312
- classNameModifiers: ["tradingName"],
30313
- errorMessage: errors.tradingName,
30314
- isValid: valid.tradingName,
30315
- children: (childProps) => jsx(InputText, {
30316
- ...childProps,
30317
- "aria-required": true,
30318
- "aria-label": labels2.tradingName,
30319
- "aria-invalid": !valid.tradingName,
30320
- name: "tradingName",
30321
- value: data.tradingName,
30322
- readonly: readonly || data.sameNameAsLegalName,
30323
- classNameModifiers: ["tradingName"],
30324
- onInput: handleChangeFor("tradingName", "input"),
30325
- onBlur: handleChangeFor("tradingName", "blur")
30326
- })
30327
- }), jsx(Checkbox, {
30328
- "aria-required": false,
30329
- "aria-label": labels2.sameNameAsLegalName,
30330
- "aria-invalid": false,
30331
- name: "sameNameAsLegalName",
30332
- label: labels2.sameNameAsLegalName,
30333
- checked: Boolean(data.sameNameAsLegalName),
30334
- onChange: handleSameAsLegalName
30335
- })]
30336
- });
30337
- }
30338
- const TradingNameFieldValidation = () => ({
30339
- tradingName: [{
30340
- modes: ["blur"],
30341
- validate: (tradingName2) => !isEmpty(tradingName2),
30342
- errorMessage: "fieldIsRequired"
30343
- }]
30344
- });
30345
30337
  const COMPANY_OTHER_DETAILS_FORM_ID = "companyOtherDetails";
30346
30338
  const companyOtherDetailsFields = [...TRADING_NAME_FIELD, ...STOCK_EXCHANGE_MIC_FIELD, ...STOCK_ISIN_FIELD, ...STOCK_TICKER_SYMBOL_FIELD, ...DATE_OF_INCORPORATION_FIELD, ...BUSINESS_REGISTRATION_NUMBER_FIELD, ...TAX_INFORMATION_FIELD, ...VAT_NUMBER_FIELD];
30347
30339
  function CompanyOtherDetails({
@@ -30379,7 +30371,6 @@ function CompanyOtherDetails({
30379
30371
  const existingTaxId = (_c = (_b = data == null ? void 0 : data.taxInformation) == null ? void 0 : _b.find((taxId2) => taxId2.country === country2)) == null ? void 0 : _c.number;
30380
30372
  const defaultTaxIdNumberType = existingTaxId ? inferTaxIdNumberType(existingTaxId, country2, companyType2) : (_d = getTaxIdNumberOptions(country2, companyType2)) == null ? void 0 : _d[0].id;
30381
30373
  const [taxIdNumberType, setTaxIdNumberType] = useState$1(defaultTaxIdNumberType);
30382
- const directChildFields = companyOtherDetailsFields.filter((field) => ["tradingName", "sameNameAsLegalName", "stockExchangeMIC", "stockISIN", "stockTickerSymbol", "dateOfIncorporation"].includes(field));
30383
30374
  const initialFormUtilsProps = useMemo$1(() => ({
30384
30375
  allFields,
30385
30376
  labels: labels2,
@@ -30397,21 +30388,9 @@ function CompanyOtherDetails({
30397
30388
  return (_a2 = initialFormUtilsProps.allFields) == null ? void 0 : _a2.reduce((acc, field) => {
30398
30389
  switch (field) {
30399
30390
  case "tradingName":
30400
- return {
30401
- ...acc,
30402
- validators: {
30403
- ...acc.validators,
30404
- ...TradingNameFieldValidation()
30405
- }
30406
- };
30391
+ return mergeFieldMetadataIntoProps("tradingName", tradingNameFieldMetadata, acc);
30407
30392
  case "dateOfIncorporation":
30408
- return {
30409
- ...acc,
30410
- validators: {
30411
- ...acc.validators,
30412
- ...DateOfIncorporationFieldValidation()
30413
- }
30414
- };
30393
+ return mergeFieldMetadataIntoProps("dateOfIncorporation", dateOfIncorporationFieldMetadata, acc);
30415
30394
  case "stockExchangeMIC":
30416
30395
  return mergeFieldMetadataIntoProps("stockExchangeMIC", stockExchangeMICFieldMetadata, acc);
30417
30396
  case "stockISIN":
@@ -30424,10 +30403,10 @@ function CompanyOtherDetails({
30424
30403
  registrationNumberType
30425
30404
  }, defaultFieldMetadata$9), acc);
30426
30405
  case "taxInformation":
30427
- return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$1[country2], {
30406
+ return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$6[country2], {
30428
30407
  taxIdNumberType,
30429
30408
  companyType: companyType2
30430
- }, defaultFieldMetadata$1), acc);
30409
+ }, defaultFieldMetadata$6), acc);
30431
30410
  case "vatNumber":
30432
30411
  return mergeFieldMetadataIntoProps(field, resolveFieldMetadata(defaultFieldConfig$7[country2], {
30433
30412
  vatNumberType
@@ -30439,6 +30418,32 @@ function CompanyOtherDetails({
30439
30418
  }
30440
30419
  }, initialFormUtilsProps);
30441
30420
  }, [companyType2, country2, initialFormUtilsProps, registrationNumberType, taxIdNumberType, vatNumberType]);
30421
+ const getFormSchema2 = useCallback$1((currentData) => {
30422
+ var _a2;
30423
+ const fieldsToRemove = [];
30424
+ if (currentData.sameNameAsLegalName) {
30425
+ fieldsToRemove.push("tradingName");
30426
+ }
30427
+ if (currentData.exemptedFromVat) {
30428
+ fieldsToRemove.push("vatNumber");
30429
+ } else {
30430
+ fieldsToRemove.push("exemptedFromVat", "vatAbsenceReason");
30431
+ }
30432
+ if (currentData.exemptedFromTax) {
30433
+ fieldsToRemove.push("taxInformation");
30434
+ } else {
30435
+ fieldsToRemove.push("exemptedFromTax");
30436
+ }
30437
+ if (currentData.isUen) {
30438
+ fieldsToRemove.push("taxInformation", "exemptedFromTax");
30439
+ }
30440
+ if (currentData.exemptedFromRegistrationNumber) {
30441
+ fieldsToRemove.push("registrationNumber");
30442
+ } else {
30443
+ fieldsToRemove.push("exemptedFromRegistrationNumber");
30444
+ }
30445
+ return ((_a2 = initialFormUtilsProps.requiredFields) == null ? void 0 : _a2.filter((field) => !fieldsToRemove.includes(field))) ?? TRADING_NAME_FIELD;
30446
+ }, [initialFormUtilsProps.requiredFields]);
30442
30447
  const {
30443
30448
  schema: formSchema,
30444
30449
  data: formData,
@@ -30447,7 +30452,7 @@ function CompanyOtherDetails({
30447
30452
  fieldProblems: formFieldProblems,
30448
30453
  handleChangeFor
30449
30454
  } = useForm({
30450
- schema: (currentData) => !currentData.exemptedFromVat ? (requiredFields == null ? void 0 : requiredFields.filter((field) => field !== "vatAbsenceReason")) ?? directChildFields : (requiredFields == null ? void 0 : requiredFields.filter((field) => field !== "vatNumber")) ?? directChildFields,
30455
+ schema: getFormSchema2,
30451
30456
  defaultData: data,
30452
30457
  rules: mergedFieldProps == null ? void 0 : mergedFieldProps.validators,
30453
30458
  optionalFields: mergedFieldProps == null ? void 0 : mergedFieldProps.optionalFields,
@@ -30681,10 +30686,10 @@ const formatDataForSummary = (data, forms2, labels2, i18n) => {
30681
30686
  var _a;
30682
30687
  const datasetUtils = datasetUtilities(i18n.locale);
30683
30688
  const country2 = (_a = data.companyBasics) == null ? void 0 : _a.country;
30684
- const taxIdLabel = resolveFieldMetadata(defaultFieldConfig$1[country2], {
30689
+ const taxIdLabel = resolveFieldMetadata(defaultFieldConfig$6[country2], {
30685
30690
  taxIdNumberType: countryToTaxInfoTypeMap[country2],
30686
30691
  companyType: void 0
30687
- }, defaultFieldMetadata$1).label;
30692
+ }, defaultFieldMetadata$6).label;
30688
30693
  return entriesOf(data).reduce((summaryData, [form, formData]) => {
30689
30694
  var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
30690
30695
  if (!form) return summaryData;
@@ -36843,7 +36848,7 @@ function SolePropDropinComponent({
36843
36848
  };
36844
36849
  const isCountryOfGoverningLawEnabled = isExperimentEnabled("EnableCountryOfGoverningLawForUKCompanies");
36845
36850
  const formatDataForSummary2 = (data2, forms22) => {
36846
- var _a2, _b2, _c, _d, _e;
36851
+ var _a2, _b2, _c, _d, _e, _f;
36847
36852
  let summaryData = cloneObject(data2);
36848
36853
  if (isCountryOfGoverningLawEnabled) {
36849
36854
  summaryData.solePropNameAndCountry = getUpdatedCountryOfGoverningLaw(summaryData.solePropNameAndCountry);
@@ -36854,11 +36859,21 @@ function SolePropDropinComponent({
36854
36859
  countryRegionOfEstablishment: solePropCountry,
36855
36860
  countryOfGoverningLaw: ((_c = summaryData.solePropNameAndCountry) == null ? void 0 : _c.countryOfGoverningLaw) && datasetUtils.getCountryName(summaryData.solePropNameAndCountry.countryOfGoverningLaw)
36856
36861
  };
36857
- if ((_d = summaryData.solePropRegistrationAddress) == null ? void 0 : _d.registrationAddress) {
36862
+ if ((_d = summaryData.companyRegistrationDetails) == null ? void 0 : _d.taxInformation) {
36863
+ const taxInformation = summaryData.companyRegistrationDetails.taxInformation.find((taxId2) => {
36864
+ var _a3;
36865
+ return taxId2.country === ((_a3 = data2.solePropNameAndCountry) == null ? void 0 : _a3.country);
36866
+ });
36867
+ if (taxInformation) {
36868
+ summaryData.companyRegistrationDetails[taxInformation.type] = taxInformation.number;
36869
+ }
36870
+ delete summaryData.companyRegistrationDetails.taxInformation;
36871
+ }
36872
+ if ((_e = summaryData.solePropRegistrationAddress) == null ? void 0 : _e.registrationAddress) {
36858
36873
  summaryData.solePropRegistrationAddress.hasInnerForms = true;
36859
36874
  summaryData.solePropRegistrationAddress.registrationAddress = mapAddressLabels(summaryData.solePropRegistrationAddress.registrationAddress, datasetUtils);
36860
36875
  }
36861
- if ((_e = summaryData.solePropRegistrationAddress) == null ? void 0 : _e.operationalAddress) {
36876
+ if ((_f = summaryData.solePropRegistrationAddress) == null ? void 0 : _f.operationalAddress) {
36862
36877
  summaryData.solePropRegistrationAddress.operationalAddress = mapAddressLabels(summaryData.solePropRegistrationAddress.operationalAddress, datasetUtils);
36863
36878
  }
36864
36879
  if (isDocumentsRequired(forms22)) {
@@ -41096,7 +41111,7 @@ const ConfigurationApiProvider = ({
41096
41111
  isEmbeddedDropin,
41097
41112
  loadingContext
41098
41113
  } = authContext;
41099
- const sdkVersion = "2.49.0";
41114
+ const sdkVersion = "2.49.1";
41100
41115
  useAnalytics({
41101
41116
  onUserEvent,
41102
41117
  legalEntityId: rootLegalEntityId,