;
{
  try {
    let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
    n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "b1065bd2-1a53-4363-b4f2-8fd73e56a65a", e._sentryDebugIdIdentifier = "sentry-dbid-b1065bd2-1a53-4363-b4f2-8fd73e56a65a");
  } catch (e) {
  }
}
;
import { jsx, jsxs, Fragment } from "preact/jsx-runtime";
import { C as Checkbox } from "./Checkbox-CyQM2V4n.js";
import { F as Field } from "./Field-BL3Mh7gm.js";
import { m as makeMask, n as numericInputs, s as spacer, M as MaskedInput, a as nonInputs, b as alphaInputs, d as alphanumericInputs } from "./MaskedInput-DgjlsFWR.js";
import { useMemo, useCallback, useEffect, useRef } from "preact/hooks";
import { R as RadioGroup } from "./RadioGroup-jkgDMvvX.js";
import { u as useTranslation, a0 as CountryCodes, v as useExperimentsContext, a6 as objectsDeepEqual, o as LegalEntityTypes } from "./StoreProvider-CqQrndhS.js";
import { m as getCompanyRegistrationNumberOptions, s as stateFormatGuidanceText, p as businessRegistrationNumberMasks, q as businessRegistrationNumberPatterns, v as vatNumberOptions, w as getVatNumberOptions, M as MemoizedDocumentUpload } from "./TaxInformationField-Cd1at8Ld.js";
import { C as CompanyTypesValues } from "./company-types-value-D_mKv5PT.js";
import { a as validateNotEmptyOnBlur, v as validatePatternOnBlur } from "./patternValidators-Bv0Mmhgd.js";
import { I as InputText } from "./InputText-DRSK56ma.js";
import { u as uppercase } from "./mapExistingFile-DOPjFNWj.js";
import { createElement } from "preact";
import { H as Header } from "./Header-Dt-hNg1U.js";
import { S as StateContextSetter } from "./validate-CtroZEiR.js";
import { u as useForm } from "./useForm-BFLyeF0c.js";
import { C as ContextGuidance } from "./ContextGuidance-BESxqmbz.js";
import { E as ErrorPanel } from "./ErrorPanel-D-VMcBB9.js";
import { c as createFormUtils } from "./formUtils-CwOJPw6N.js";
import { a as getFormProps } from "./getProps-Cc3J2-z9.js";
import { A as Address } from "./Address-DMDTO9vd.js";
import { memo } from "preact/compat";
import { u as usePageLandedEvent } from "./Summary-6z7-keBb.js";
function CompanyRegistrationNumberTypeSelector({
  country,
  companyType,
  selected,
  setSelected,
  exemptedOption
}) {
  const { t } = useTranslation("common");
  const options = useMemo(() => {
    const availableOptions = getCompanyRegistrationNumberOptions(country, companyType) ?? [];
    if (availableOptions.length === 0 || !exemptedOption) return availableOptions;
    return [
      ...availableOptions,
      {
        id: "exempted",
        name: exemptedOption
      }
    ];
  }, [companyType, country, exemptedOption]);
  const handleSelect = useCallback(
    (selectedStr) => {
      const newSelected = selectedStr;
      if (newSelected === "exempted") {
        if (exemptedOption) {
          setSelected(newSelected);
        }
        return;
      }
      setSelected(newSelected);
    },
    [exemptedOption, setSelected]
  );
  useEffect(() => {
    if (options.length > 0 && (!selected || !options.some((option) => option.id === selected))) {
      if (selected === "exempted") return;
      setSelected(options[0].id);
    }
  }, [options, selected, setSelected]);
  if (options.length <= 1) return null;
  return /* @__PURE__ */ jsx(
    Field,
    {
      el: "fieldset",
      name: "companyRegistrationNumberType",
      label: t(($) => $["whichTypeOfRegistrationNumberDoYouHave"]),
      children: (childProps) => /* @__PURE__ */ jsx(
        RadioGroup,
        {
          ...childProps,
          name: "companyRegistrationNumberType",
          items: options,
          value: selected,
          onChange: handleSelect
        }
      )
    }
  );
}
const registrationNumberDefaultFieldMetadata = {
  label: "registrationNumber"
};
const registrationNumberDefaultFieldConfig = {
  [CountryCodes.Australia]: ({ companyType }) => {
    if (companyType === CompanyTypesValues.INCORPORATED_ASSOCIATION) {
      return {
        label: "incorporatedAssociationRegistrationNumber",
        mask: businessRegistrationNumberMasks[CountryCodes.Australia].associationIncorporated,
        validators: validatePatternOnBlur(
          businessRegistrationNumberPatterns[CountryCodes.Australia].associationIncorporated
        ),
        guidanceText: {
          key: "enterXToYCharactersForExample",
          values: {
            minChars: "3",
            maxChars: "20",
            example: "200312345A"
          }
        }
      };
    }
    return {
      label: "australianBusinessNumberAcn",
      mask: businessRegistrationNumberMasks[CountryCodes.Australia].default,
      validators: validatePatternOnBlur(
        businessRegistrationNumberPatterns[CountryCodes.Australia].default
      ),
      guidanceText: {
        key: "enterNDigitsForExample",
        values: {
          numDigits: "9",
          example: "123 456 789"
        }
      }
    };
  },
  [CountryCodes.Austria]: ({ registrationNumberType }) => registrationNumberType === "ZVR" ? {
    label: "zentralesVereinsregisterId",
    mask: businessRegistrationNumberMasks[CountryCodes.Austria].ZVR,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Austria].ZVR
    ),
    guidanceText: {
      key: "enterTheRemainingNDigitsForExample",
      values: {
        numDigits: "9-10",
        example: "AT-ZVR-555769679"
      }
    }
  } : {
    label: "firmenbuchnummer",
    mask: businessRegistrationNumberMasks[CountryCodes.Austria].firmenbuchnummer,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Austria].firmenbuchnummer
    ),
    guidanceText: {
      key: "enterAMaximumOfNCharactersWithAMixForExample",
      values: {
        maxChars: "9",
        example: "T1001a, FN89060n"
      }
    }
  },
  [CountryCodes.Belgium]: {
    label: "enterpriseNumber",
    mask: businessRegistrationNumberMasks[CountryCodes.Belgium].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Belgium].default
    ),
    guidanceText: {
      key: "enterNDigitsForExample",
      values: {
        numDigits: "10",
        example: "1234567890"
      }
    }
  },
  [CountryCodes.Brazil]: {
    label: "CNPJ",
    mask: businessRegistrationNumberMasks[CountryCodes.Brazil].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Brazil].default
    ),
    guidanceText: {
      key: "enterNDigitsForExample",
      values: {
        numDigits: "14",
        example: "28.773.626/8318-21"
      }
    }
  },
  [CountryCodes.Bulgaria]: {
    label: "uniqueIdentificationCode",
    mask: businessRegistrationNumberMasks[CountryCodes.Bulgaria].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Bulgaria].default
    ),
    guidanceText: {
      key: "enterNDigitsForExample",
      values: {
        numDigits: "9",
        example: "812114069"
      }
    }
  },
  [CountryCodes.Canada]: {
    label: "businessIncorporationNumber",
    mask: businessRegistrationNumberMasks[CountryCodes.Canada].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Canada].default
    ),
    guidanceText: {
      key: "enterXToYCharactersForExample",
      values: {
        minChars: "5",
        maxChars: "10",
        example: "BC1234567"
      }
    }
  },
  [CountryCodes.Croatia]: ({ companyType }) => {
    switch (companyType) {
      case CompanyTypesValues.SOLE_PROPRIETORSHIP:
        return {
          label: "MBO",
          mask: businessRegistrationNumberMasks[CountryCodes.Croatia].soleProprietorship,
          validators: validatePatternOnBlur(
            businessRegistrationNumberPatterns[CountryCodes.Croatia].soleProprietorship
          ),
          guidanceText: {
            key: "enterNDigitsForExample",
            values: {
              numDigits: "8",
              example: "12345678"
            }
          }
        };
      default:
        return {
          label: "MBS",
          mask: businessRegistrationNumberMasks[CountryCodes.Croatia].default,
          validators: validatePatternOnBlur(
            businessRegistrationNumberPatterns[CountryCodes.Croatia].default
          ),
          guidanceText: {
            key: "enterNDigitsForExample",
            values: {
              numDigits: "9",
              example: "080020970"
            }
          }
        };
    }
  },
  [CountryCodes.Cyprus]: {
    label: "cyRegistrationNumber",
    mask: businessRegistrationNumberMasks[CountryCodes.Cyprus].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Cyprus].default
    ),
    guidanceText: {
      key: "enterEnglishLetterFollowedByXtoYDigitsForExample",
      values: {
        minDigits: "1",
        maxDigits: "8",
        example: "C12345678"
      }
    }
  },
  [CountryCodes.CzechRepublic]: {
    label: "ICO",
    mask: businessRegistrationNumberMasks[CountryCodes.CzechRepublic].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.CzechRepublic].default
    ),
    guidanceText: {
      key: "enterXToYDigitsForExample",
      values: {
        minDigits: "8",
        maxDigits: "10",
        example: "12345678"
      }
    }
  },
  [CountryCodes.Denmark]: {
    label: "CVR-nummer",
    mask: businessRegistrationNumberMasks[CountryCodes.Denmark].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Denmark].default
    ),
    guidanceText: {
      key: "enterNDigitsForExample",
      values: {
        numDigits: "8",
        example: "22756214"
      }
    }
  },
  [CountryCodes.Estonia]: {
    label: "registrikood",
    mask: businessRegistrationNumberMasks[CountryCodes.Estonia].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Estonia].default
    ),
    guidanceText: {
      key: "enterNDigitsForExample",
      values: {
        numDigits: "8",
        example: "10345833"
      }
    }
  },
  [CountryCodes.Finland]: {
    label: "YTunnus",
    mask: businessRegistrationNumberMasks[CountryCodes.Finland].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Finland].default
    ),
    guidanceText: {
      key: "enterNDigitsForExample",
      values: {
        numDigits: "8",
        example: "1234567-8"
      }
    }
  },
  [CountryCodes.France]: ({ registrationNumberType }) => registrationNumberType === "RNA" ? {
    label: "rnaNumber",
    mask: businessRegistrationNumberMasks[CountryCodes.France].RNA,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.France].RNA
    ),
    guidanceText: {
      key: "enterTheRemainingNDigitsForExample",
      values: {
        numDigits: "9",
        example: "W123456789 or W9M1234567"
      }
    }
  } : {
    label: "siret",
    mask: businessRegistrationNumberMasks[CountryCodes.France].SIRET,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.France].SIRET
    ),
    guidanceText: {
      key: "enterNDigitsForExample",
      values: {
        numDigits: "14",
        example: "542051180-00066"
      }
    }
  },
  [CountryCodes.Germany]: {
    label: "handelsregisternummerOrVereinsregisternummer",
    mask: businessRegistrationNumberMasks[CountryCodes.Germany].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Germany].default
    ),
    guidanceText: {
      key: "enterAMaximumOfNCharactersWithAMixForExample",
      values: {
        maxChars: "20",
        example: "HRB100484, HRA123456ABCDE-A1234, VR350378A"
      }
    }
  },
  [CountryCodes.Gibraltar]: {
    label: "companyRegistrationNumber",
    mask: businessRegistrationNumberMasks[CountryCodes.Gibraltar].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Gibraltar].default
    ),
    guidanceText: {
      key: "enterAMaximumOfNCharactersForExample",
      values: {
        maxChars: "8",
        example: "04366849"
      }
    }
  },
  [CountryCodes.Greece]: {
    label: "GEMI-number",
    mask: businessRegistrationNumberMasks[CountryCodes.Greece].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Greece].default
    ),
    guidanceText: {
      key: "enterNDigitsForExample",
      values: {
        numDigits: "12",
        example: "757001000000"
      }
    }
  },
  [CountryCodes.Guernsey]: {
    label: "registrationNumber",
    mask: businessRegistrationNumberMasks[CountryCodes.Guernsey].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Guernsey].default
    ),
    guidanceText: {
      key: "enterAMaximumOfNDigitsForExample",
      values: {
        maxDigits: "9",
        example: "123456"
      }
    }
  },
  [CountryCodes.HongKong]: {
    label: "companyRegistrationNumber__HK",
    mask: businessRegistrationNumberMasks[CountryCodes.HongKong].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.HongKong].default
    ),
    guidanceText: {
      key: "enterNDigitsForExample",
      values: {
        numDigits: "7",
        example: "1234567"
      }
    }
  },
  [CountryCodes.Hungary]: ({ companyType }) => {
    if (companyType === CompanyTypesValues.SOLE_PROPRIETORSHIP) {
      return {
        label: "huRegistrationNumberForSoleProp",
        mask: businessRegistrationNumberMasks[CountryCodes.Hungary].nyilvantartasiSzam,
        validators: validatePatternOnBlur(
          businessRegistrationNumberPatterns[CountryCodes.Hungary].nyilvantartasiSzam
        ),
        guidanceText: {
          key: "enterXToYDigitsForExample",
          values: {
            minDigits: "7",
            maxDigits: "10",
            example: "06123456"
          }
        }
      };
    }
    return {
      label: "huRegistrationNumber",
      mask: businessRegistrationNumberMasks[CountryCodes.Hungary].default,
      validators: validatePatternOnBlur(
        businessRegistrationNumberPatterns[CountryCodes.Hungary].default
      ),
      guidanceText: {
        key: "enterNDigitsForExample",
        values: {
          numDigits: "10",
          example: "06-12-345678"
        }
      }
    };
  },
  [CountryCodes.Ireland]: {
    label: "companyNumber",
    mask: businessRegistrationNumberMasks[CountryCodes.Ireland].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Ireland].default
    ),
    guidanceText: {
      key: "enterAMaximumOfNDigitsForExample",
      values: {
        maxDigits: "8",
        example: "10123456"
      }
    }
  },
  [CountryCodes.IsleOfMan]: {
    label: "registrationNumber",
    mask: businessRegistrationNumberMasks[CountryCodes.IsleOfMan].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.IsleOfMan].default
    ),
    guidanceText: {
      key: "enterNDigitsAndThen1LetterForExample",
      values: {
        numDigits: "6",
        example: "114293C"
      }
    }
  },
  [CountryCodes.Italy]: ({ registrationNumberType }) => {
    switch (registrationNumberType) {
      case "CCIAA":
        return {
          label: "CCIAA",
          mask: businessRegistrationNumberMasks[CountryCodes.Italy].CCIAA,
          validators: validatePatternOnBlur(
            businessRegistrationNumberPatterns[CountryCodes.Italy].CCIAA
          ),
          guidanceText: {
            key: "enterNLettersAndThenXToYDigitsForExample",
            values: {
              numLetters: "2",
              minDigits: "6",
              maxDigits: "7",
              example: "TO0091712"
            }
          }
        };
      case "partitaIVA":
      default:
        return {
          label: "codiceFiscalePartitaIVA",
          validators: validatePatternOnBlur(/^\d{11}$/),
          mask: {
            mask: makeMask(spacer, ...numericInputs(11))
          },
          guidanceText: {
            key: "enterTheRemainingNDigitsForExample",
            values: {
              numDigits: "11",
              example: "47040001100"
            }
          }
        };
    }
  },
  [CountryCodes.Japan]: {
    label: "corporateRegistrationNumber",
    mask: businessRegistrationNumberMasks[CountryCodes.Japan].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Japan].default
    ),
    guidanceText: {
      key: "enterAMaximumOfNCharactersForExample",
      values: {
        maxChars: "12",
        example: "224863141686"
      }
    }
  },
  [CountryCodes.Jersey]: {
    label: "registrationNumber",
    mask: businessRegistrationNumberMasks[CountryCodes.Jersey].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Jersey].default
    ),
    guidanceText: {
      key: "enterAMaximumOfNCharactersForExample",
      values: {
        maxChars: "9",
        example: "123722"
      }
    }
  },
  [CountryCodes.Latvia]: {
    label: "lvRegistrationNumber",
    mask: businessRegistrationNumberMasks[CountryCodes.Latvia].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Latvia].default
    ),
    guidanceText: {
      key: "enterNDigitsForExample",
      values: {
        numDigits: "11",
        example: "50003251661"
      }
    }
  },
  [CountryCodes.Liechtenstein]: {
    label: "liRegistrationNumber",
    mask: businessRegistrationNumberMasks[CountryCodes.Liechtenstein].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Liechtenstein].default
    ),
    guidanceText: {
      key: "enterTheRemainingNDigitsForExample",
      values: {
        numDigits: "11",
        example: "FL-0001.012.124-5"
      }
    }
  },
  [CountryCodes.Lithuania]: {
    label: "ltRegistrationNumber",
    mask: businessRegistrationNumberMasks[CountryCodes.Lithuania].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Lithuania].default
    ),
    guidanceText: {
      key: "enterXToYDigitsForExample",
      values: {
        minDigits: "6",
        maxDigits: "9",
        example: "123456789"
      }
    }
  },
  [CountryCodes.Luxembourg]: {
    label: "luRegistrationNumber",
    mask: businessRegistrationNumberMasks[CountryCodes.Luxembourg].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Luxembourg].default
    ),
    guidanceText: {
      key: "enter1LetterAndThenNDigitsForExample",
      values: {
        example: "C127766"
      }
    }
  },
  [CountryCodes.Malta]: {
    label: "companyRegistrationNumber",
    mask: businessRegistrationNumberMasks[CountryCodes.Malta].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Malta].default
    ),
    guidanceText: {
      key: "enterTheRemainingXToYDigitsForExample",
      values: {
        minDigits: "4",
        maxDigits: "6",
        example: "C 43070, P 1234"
      }
    }
  },
  [CountryCodes.Malaysia]: {
    label: "SSM",
    mask: businessRegistrationNumberMasks[CountryCodes.Malaysia].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Malaysia].default
    ),
    guidanceText: {
      key: "enterXOrYDigitsForExample",
      values: {
        xDigits: "7",
        yDigits: "12",
        example: "1234567, 201901000005"
      }
    }
  },
  [CountryCodes.Mexico]: {
    label: "RFC",
    mask: businessRegistrationNumberMasks[CountryCodes.Mexico].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Mexico].default
    ),
    guidanceText: {
      key: "enterNDigitsForExample",
      values: {
        numDigits: "12",
        example: "LFM200817DGA"
      }
    }
  },
  [CountryCodes.Monaco]: ({ companyType }) => companyType === CompanyTypesValues.SOLE_PROPRIETORSHIP ? {
    label: "mcRegistrationNumberSoleProp",
    mask: businessRegistrationNumberMasks[CountryCodes.Monaco].soleProprietorship,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Monaco].soleProprietorship
    ),
    guidanceText: {
      key: "enterXToYCharactersWithAMixForExample",
      values: {
        minChars: "8",
        maxChars: "11",
        example: "8732P92873"
      }
    }
  } : {
    label: "mcRegistrationNumber",
    mask: businessRegistrationNumberMasks[CountryCodes.Monaco].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Monaco].default
    ),
    guidanceText: {
      key: "enterXToYCharactersWithAMixForExample",
      values: {
        minChars: "8",
        maxChars: "11",
        example: "84SB02071"
      }
    }
  },
  [CountryCodes.Netherlands]: {
    label: "chamberOfCommerceRegistrationNumber",
    mask: businessRegistrationNumberMasks[CountryCodes.Netherlands].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Netherlands].default
    ),
    guidanceText: {
      key: "enterNDigitsForExample",
      values: {
        numDigits: "8",
        example: "34179503"
      }
    }
  },
  [CountryCodes.NewZealand]: ({ registrationNumberType }) => registrationNumberType === "NZBN" ? {
    label: "NZBN",
    mask: businessRegistrationNumberMasks[CountryCodes.NewZealand].NZBN,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.NewZealand].NZBN
    ),
    guidanceText: {
      key: "enterNDigitsForExample",
      values: {
        numDigits: "13",
        example: "1234567890123"
      }
    }
  } : {
    label: "companyNumberNZ",
    mask: businessRegistrationNumberMasks[CountryCodes.NewZealand].companyNumberNZ,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.NewZealand].companyNumberNZ
    ),
    guidanceText: {
      key: "enterNDigitsForExample",
      values: {
        numDigits: "7",
        example: "1234567"
      }
    }
  },
  [CountryCodes.Norway]: {
    label: "organisasjonsnummer",
    mask: businessRegistrationNumberMasks[CountryCodes.Norway].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Norway].default
    ),
    guidanceText: {
      key: "enterNDigitsForExample",
      values: {
        numDigits: "9",
        example: "923609016"
      }
    }
  },
  [CountryCodes.Poland]: ({ registrationNumberType }) => registrationNumberType === "krsNumber" ? {
    label: "krsNumber",
    mask: businessRegistrationNumberMasks[CountryCodes.Poland].krsNumber,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Poland].krsNumber
    ),
    guidanceText: {
      key: "enterNDigitsForExample",
      values: {
        numDigits: "10",
        example: "1234567890"
      }
    }
  } : {
    label: "regon",
    mask: businessRegistrationNumberMasks[CountryCodes.Poland].regon,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Poland].regon
    ),
    guidanceText: {
      key: "enterNDigitsForExample",
      values: {
        numDigits: "9",
        example: "123456789"
      }
    }
  },
  [CountryCodes.Portugal]: {
    label: "NIPC",
    mask: businessRegistrationNumberMasks[CountryCodes.Portugal].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Portugal].default
    ),
    guidanceText: {
      key: "enterNDigitsForExample",
      values: {
        numDigits: "9",
        example: "123456789"
      }
    }
  },
  [CountryCodes.PuertoRico]: {
    // should exactly match CountryCodes.UnitedStates
  },
  [CountryCodes.Romania]: ({ registrationNumberType }) => registrationNumberType === "roRegNumberOldFormat" ? {
    label: "roRegNumberOldFormat_label",
    mask: businessRegistrationNumberMasks[CountryCodes.Romania].roRegNumberOldFormat,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Romania].roRegNumberOldFormat
    ),
    guidanceText: {
      key: "roRegNumberOldFormat_maskGuidance"
    }
  } : {
    label: "roRegNumberNewFormat_label",
    mask: businessRegistrationNumberMasks[CountryCodes.Romania].roRegNumberNewFormat,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Romania].roRegNumberNewFormat
    ),
    guidanceText: {
      key: "roRegNumberNewFormat_maskGuidance"
    }
  },
  [CountryCodes.Singapore]: {
    label: "uen",
    mask: businessRegistrationNumberMasks[CountryCodes.Singapore].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Singapore].default
    ),
    guidanceText: {
      key: "enterXToYCharactersWithAMixForExample",
      values: {
        minChars: "9",
        maxChars: "10",
        example: "200312345A"
      }
    }
  },
  [CountryCodes.Slovakia]: {
    label: "skRegistrationNumber",
    mask: businessRegistrationNumberMasks[CountryCodes.Slovakia].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Slovakia].default
    ),
    guidanceText: {
      key: "enterNDigitsForExample",
      values: {
        numDigits: "8",
        example: "12345678"
      }
    }
  },
  [CountryCodes.Slovenia]: {
    label: "siRegistrationNumber",
    mask: businessRegistrationNumberMasks[CountryCodes.Slovenia].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Slovenia].default
    ),
    guidanceText: {
      key: "enterNDigitsForExample",
      values: {
        numDigits: "10",
        example: "1006500006"
      }
    }
  },
  [CountryCodes.Spain]: {
    label: "NIF",
    mask: businessRegistrationNumberMasks[CountryCodes.Spain].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Spain].default
    ),
    guidanceText: {
      key: "enter1LetterAndThenNDigitsForExample",
      values: {
        numDigits: "8",
        example: "A39000013"
      }
    }
  },
  [CountryCodes.Sweden]: {
    label: "organisationsnummer",
    mask: businessRegistrationNumberMasks[CountryCodes.Sweden].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Sweden].default
    ),
    guidanceText: {
      key: "enterNDigitsForExample",
      values: {
        numDigits: "10",
        example: "202100-5489"
      }
    }
  },
  [CountryCodes.Switzerland]: {
    label: "chRegistrationNumber",
    mask: businessRegistrationNumberMasks[CountryCodes.Switzerland].default,
    validators: validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.Switzerland].default
    ),
    guidanceText: {
      key: "enterTheRemainingNDigitsForExample",
      values: {
        numDigits: "9",
        example: "CHE-123.456.789"
      }
    }
  },
  [CountryCodes.UnitedArabEmirates]: {
    label: "commercialLicence",
    validators: validateNotEmptyOnBlur
  },
  [CountryCodes.UnitedKingdom]: ({ companyType, registrationNumberType }) => {
    const defaultConfig = {
      label: "companyNumber",
      mask: businessRegistrationNumberMasks[CountryCodes.UnitedKingdom].default,
      validators: validatePatternOnBlur(
        businessRegistrationNumberPatterns[CountryCodes.UnitedKingdom].default
      ),
      guidanceText: {
        key: "enterNCharactersForExample",
        values: {
          numChars: "8",
          example: "43668490"
        }
      }
    };
    switch (companyType) {
      case "nonProfit":
        switch (registrationNumberType) {
          case "charity":
            return {
              label: "charityNumber",
              mask: businessRegistrationNumberMasks[CountryCodes.UnitedKingdom].nonProfit,
              validators: validatePatternOnBlur(
                businessRegistrationNumberPatterns[CountryCodes.UnitedKingdom].nonProfit
              ),
              guidanceText: {
                key: "enterThreeDifferingOptionsForExample",
                values: {
                  firstOption: "6, 7 or 8 digits",
                  secondOption: "6 digits with a 2-letter prefix",
                  thirdOption: "6 digits with a suffix like -0",
                  firstExample: "123456",
                  secondExample: "SC012345",
                  thirdExample: "123456-0"
                }
              }
            };
          default:
            return defaultConfig;
        }
      default:
        return defaultConfig;
    }
  },
  [CountryCodes.UnitedStates]: ({ state }) => ({
    label: "registrationNumber__US",
    mask: state ? businessRegistrationNumberMasks[CountryCodes.UnitedStates][state] : businessRegistrationNumberMasks[CountryCodes.UnitedStates].default,
    validators: state ? validatePatternOnBlur(businessRegistrationNumberPatterns[CountryCodes.UnitedStates][state]) : validatePatternOnBlur(
      businessRegistrationNumberPatterns[CountryCodes.UnitedStates].default
    ),
    guidanceText: state ? stateFormatGuidanceText[state] : stateFormatGuidanceText.default
  })
};
const exemptFromRegistrationNumberDefaultFieldMetadata = {
  label: "iDontHaveARegistrationNumber"
};
const exemptFromRegistrationNumberDefaultFieldConfig = {
  [CountryCodes.Australia]: {
    label: "doNotHaveAcn"
  },
  [CountryCodes.Austria]: {
    label: "doNotHaveFirmenbuchnummer"
  },
  [CountryCodes.Finland]: {
    label: "doNotHaveYTunnus"
  },
  [CountryCodes.HongKong]: {
    label: "iDoNotHaveCompanyRegistrationNumber"
  },
  [CountryCodes.Germany]: {
    label: "doNotHaveHandelsregisternummerOrVereinsregisternummer"
  },
  [CountryCodes.Lithuania]: {
    label: "doNotHaveLtRegistrationNumber"
  },
  [CountryCodes.Luxembourg]: {
    label: "doNotHaveLuRegistrationNumber"
  },
  [CountryCodes.Poland]: {
    label: "doNotHaveRegonKrsNumber"
  },
  [CountryCodes.PuertoRico]: {
    label: "doNotHaveEIN"
  },
  [CountryCodes.Sweden]: {
    label: "doNotHaveOrganisationsnummer"
  },
  [CountryCodes.Switzerland]: {
    label: "doNotHaveChRegistrationNumber"
  }
};
const getRegistrationNumberHelperText = (t, { country, companyType }) => {
  if (country === CountryCodes.Australia && companyType === CompanyTypesValues.INCORPORATED_ASSOCIATION) {
    return t(($) => $["findYourIncorporatedAssociationNumberInThePublicRegistryForYourState"]);
  }
  return void 0;
};
const inferCompanyRegistrationNumberType = (registrationNumber, country, companyType) => {
  const optionsForCountry = getCompanyRegistrationNumberOptions(country, companyType);
  const metadataFn = registrationNumberDefaultFieldConfig[country];
  if (!optionsForCountry) return void 0;
  if (optionsForCountry.length === 1)
    return optionsForCountry[0].id;
  if (!optionsForCountry || !metadataFn) return void 0;
  const allMetaData = optionsForCountry.reduce(
    (acc, option) => {
      const meta = typeof metadataFn === "function" ? metadataFn({
        registrationNumberType: option.id,
        companyType
      }) : metadataFn;
      if (meta.label && !acc[meta.label]) {
        acc[meta.label] = meta;
      }
      return acc;
    },
    {}
  );
  for (const option of optionsForCountry) {
    const fieldMetadata = allMetaData[option.name];
    if (!fieldMetadata?.validators) continue;
    const validators = Array.isArray(fieldMetadata.validators) ? fieldMetadata.validators : [fieldMetadata.validators];
    if (validators.every((validator) => validator.validate(registrationNumber))) {
      return option.id;
    }
  }
};
function getDefaultRegistrationNumberType(registrationNumber, country, companyType) {
  return registrationNumber ? inferCompanyRegistrationNumberType(registrationNumber, country, companyType) : getCompanyRegistrationNumberOptions(country, companyType)?.[0]?.id;
}
const BUSINESS_REGISTRATION_NUMBER_FIELD = ["registrationNumber", "registrationNumberType", "exemptedFromRegistrationNumber"];
function BusinessRegistrationNumberField({
  data,
  valid,
  errors,
  labels,
  mask,
  guidanceText,
  helperText,
  readonly,
  shouldValidate,
  optional,
  handleChangeFor,
  country,
  canExempt,
  companyType
}) {
  const registrationNumberOptions = getCompanyRegistrationNumberOptions(country, companyType);
  const defaultType = getDefaultRegistrationNumberType(
    data.registrationNumber,
    country,
    companyType
  );
  const showExemptedOption = canExempt && !!registrationNumberOptions && registrationNumberOptions.length > 1;
  const registrationNumberType = data.exemptedFromRegistrationNumber ? "exempted" : data.registrationNumberType ? data.registrationNumberType : defaultType;
  const handleRegistrationNumberChange = (e, mode) => {
    const value = typeof e === "string" ? e : e.currentTarget.value;
    handleChangeFor("registrationNumber", mode)(value);
    handleChangeFor("registrationNumberType")(registrationNumberType);
  };
  const handleExemptedFromRegistrationNumber = (exempt) => {
    if (exempt) handleChangeFor("registrationNumber")("");
    handleChangeFor("exemptedFromRegistrationNumber")(exempt);
  };
  const handleCompanyRegistrationNumberTypeChange = (regNumberType) => {
    if (regNumberType === "exempted") {
      if (!canExempt) {
        throw Error(`${country} does not allow tax exemptions`);
      }
      handleChangeFor("registrationNumber")("");
      handleChangeFor("exemptedFromRegistrationNumber")(true);
      handleChangeFor("registrationNumberType")(void 0);
      return;
    }
    if (canExempt && data.exemptedFromRegistrationNumber === true) {
      handleChangeFor("exemptedFromRegistrationNumber")(false);
    }
    handleChangeFor("registrationNumber")("");
    handleChangeFor("registrationNumberType")(regNumberType);
  };
  if (registrationNumberType && registrationNumberType !== "exempted") {
    const countryHasType = registrationNumberOptions?.find(
      (option) => option.id === registrationNumberType
    );
    if (!countryHasType) {
      handleChangeFor("registrationNumberType")(defaultType);
    }
  }
  return /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-field__business-registration", children: [
    /* @__PURE__ */ jsx(
      CompanyRegistrationNumberTypeSelector,
      {
        companyType,
        country,
        setSelected: handleCompanyRegistrationNumberTypeChange,
        selected: registrationNumberType,
        exemptedOption: showExemptedOption ? labels.exemptedFromRegistrationNumber : false
      }
    ),
    /* @__PURE__ */ jsx(
      MaskedInput,
      {
        "aria-required": true,
        "aria-invalid": !valid.registrationNumber,
        name: "registrationNumber",
        type: "text",
        value: data?.registrationNumber ?? "",
        label: labels.registrationNumber ?? "",
        formatGuidance: guidanceText?.registrationNumber ?? "",
        errorMessage: errors.registrationNumber,
        isValid: Boolean(valid.registrationNumber),
        onInput: (e) => handleRegistrationNumberChange(e, "input"),
        onBlur: (e) => handleRegistrationNumberChange(e, "blur"),
        disabled: data.exemptedFromRegistrationNumber,
        optional,
        readonly,
        shouldValidate: !optional && shouldValidate,
        helper: helperText,
        ...mask
      }
    ),
    canExempt && !showExemptedOption && /* @__PURE__ */ jsx(Field, { name: "exemptedFromRegistrationNumber", children: (childProps) => /* @__PURE__ */ jsx(
      Checkbox,
      {
        ...childProps,
        "aria-required": false,
        "aria-invalid": false,
        name: "exemptedFromRegistrationNumber",
        value: "exemptedFromRegistrationNumber",
        checked: Boolean(data.exemptedFromRegistrationNumber),
        label: labels?.exemptedFromRegistrationNumber,
        readonly,
        onChange: handleExemptedFromRegistrationNumber
      }
    ) })
  ] });
}
const DBA_NAME_FIELD = [
  "hasDoingBusinessAs",
  "doingBusinessAs"
];
function DBANameField({
  data,
  valid,
  errors,
  labels,
  readonly,
  handleChangeFor
}) {
  const { t } = useTranslation("common");
  const hasDoingBusinessAsValue = useMemo(() => {
    if (typeof data.hasDoingBusinessAs !== "boolean") return void 0;
    return data.hasDoingBusinessAs ? "yes" : "no";
  }, [data.hasDoingBusinessAs]);
  const handleHasDoingBusinessAsChange = (val) => {
    handleChangeFor("hasDoingBusinessAs")(val === "yes" ? true : false);
  };
  return /* @__PURE__ */ jsxs(Fragment, { children: [
    /* @__PURE__ */ jsx(
      Field,
      {
        el: "fieldset",
        name: "hasDoingBusinessAsName",
        label: labels.hasDoingBusinessAs ?? t(($) => $["hasDba"]),
        helper: t(($) => $["hasDba__helperText"]),
        isValid: valid.hasDoingBusinessAs,
        errorMessage: errors.hasDoingBusinessAs,
        children: (childProps) => /* @__PURE__ */ jsx(
          RadioGroup,
          {
            ...childProps,
            name: "hasDoingBusinessAs",
            items: [
              { id: "yes", name: "yes" },
              { id: "no", name: "no" }
            ],
            value: hasDoingBusinessAsValue,
            onChange: handleHasDoingBusinessAsChange,
            horizontal: true
          }
        )
      }
    ),
    data.hasDoingBusinessAs && /* @__PURE__ */ jsx(
      Field,
      {
        name: "doingBusinessAs",
        label: labels.doingBusinessAs ?? t(($) => $["dbaName"]),
        errorMessage: errors.doingBusinessAs,
        isValid: valid.doingBusinessAs,
        children: (childProps) => /* @__PURE__ */ jsx(
          InputText,
          {
            ...childProps,
            "aria-required": true,
            "aria-invalid": !valid.doingBusinessAs,
            name: "doingBusinessAs",
            value: data.doingBusinessAs,
            readonly,
            onInput: handleChangeFor("doingBusinessAs", "input"),
            onBlur: handleChangeFor("doingBusinessAs", "blur")
          }
        )
      }
    )
  ] });
}
const doingBusinessAsAbsentFieldMetadata = {
  validators: [validateNotEmptyOnBlur]
};
const doingBusinessAsFieldMetadata = {
  label: "doingBusinessAs",
  validators: [validateNotEmptyOnBlur]
};
const vatAbsenceReasonMetadata = {
  validators: [validateNotEmptyOnBlur]
};
const defaultFieldMetadata = {
  label: "vatNumber"
};
const defaultFieldConfig = {
  [CountryCodes.Austria]: {
    label: "UST-ID",
    validators: validatePatternOnBlur(/^ATU\d{8}$/),
    mask: {
      mask: makeMask(...nonInputs("ATU", { includeInValue: true }), spacer, ...numericInputs(8))
    },
    guidanceText: {
      key: "enterTheRemainingNDigitsForExample",
      values: {
        numDigits: "8",
        example: "ATU51507409"
      }
    }
  },
  [CountryCodes.Belgium]: {
    label: "euVatNumber",
    validators: validatePatternOnBlur(/^BE[10]\d{9}$/),
    mask: {
      mask: makeMask(...nonInputs("BE", { includeInValue: true }), spacer, ...numericInputs(10))
    },
    guidanceText: {
      key: "enterTheRemainingNDigitsForExample",
      values: {
        numDigits: "10",
        example: "BE1234567890"
      }
    }
  },
  [CountryCodes.Bulgaria]: {
    label: "identifikacionenNomerDDS",
    validators: validatePatternOnBlur(/^BG\d{9,10}$/),
    mask: {
      mask: makeMask(
        ...nonInputs("BG", { includeInValue: true }),
        spacer,
        ...numericInputs(9),
        ...numericInputs(1, true)
      )
    },
    guidanceText: {
      key: "enterTheRemainingXToYDigitsForExample",
      values: {
        minDigits: "9",
        maxDigits: "10",
        example: "BG1234567890"
      }
    }
  },
  [CountryCodes.Croatia]: {
    label: "PDVIdBrojOIB",
    validators: validatePatternOnBlur(/^HR\d{11}$/),
    mask: {
      mask: makeMask(...nonInputs("HR", { includeInValue: true }), spacer, ...numericInputs(11))
    },
    guidanceText: {
      key: "enterTheRemainingNDigitsForExample",
      values: {
        numDigits: "11",
        example: "HR94577403194"
      }
    }
  },
  [CountryCodes.Cyprus]: {
    label: "arithmosEngraphes",
    validators: validatePatternOnBlur(/^CY[A-Z0-9]{9}$/),
    mask: {
      mask: makeMask(
        ...nonInputs("CY", { includeInValue: true }),
        spacer,
        ...alphanumericInputs(9)
      ),
      transformOnType: uppercase
    },
    guidanceText: {
      key: "enterTheRemainingNCharactersForExample",
      values: {
        numChars: "9",
        example: "CY12345678X"
      }
    }
  },
  [CountryCodes.CzechRepublic]: {
    label: "DIC",
    validators: validatePatternOnBlur(/^CZ\d{8,10}$/),
    mask: {
      mask: makeMask(
        ...nonInputs("CZ", { includeInValue: true }),
        spacer,
        ...numericInputs(8),
        ...numericInputs(2, true)
      )
    },
    guidanceText: {
      key: "enterTheRemainingXToYDigitsForExample",
      values: {
        minDigits: "8",
        maxDigits: "10",
        example: "CZ00177041"
      }
    }
  },
  [CountryCodes.Denmark]: ({ vatNumberType }) => {
    switch (vatNumberType) {
      case "stamregister":
        return {
          label: "stamregister",
          validators: validatePatternOnBlur(/^SE\d{8}$/),
          mask: {
            mask: makeMask(
              ...nonInputs("SE", { includeInValue: true }),
              spacer,
              ...numericInputs(8)
            )
          },
          guidanceText: {
            key: "enterTheRemainingNDigitsForExample",
            values: {
              numDigits: "8",
              example: "SE12345678"
            }
          }
        };
      case "momsregistreringsnummerCVR":
      default:
        return {
          label: "momsregistreringsnummerCVR",
          validators: validatePatternOnBlur(/^DK\d{8}$/),
          mask: {
            mask: makeMask(
              ...nonInputs("DK", { includeInValue: true }),
              spacer,
              ...numericInputs(8)
            )
          },
          guidanceText: {
            key: "enterTheRemainingNDigitsForExample",
            values: {
              numDigits: "8",
              example: "DK12345678"
            }
          }
        };
    }
  },
  [CountryCodes.Estonia]: {
    label: "kaibemaksukohustuslaseNumber",
    validators: validatePatternOnBlur(/^EE\d{9}$/),
    mask: {
      mask: makeMask(...nonInputs("EE", { includeInValue: true }), spacer, ...numericInputs(9))
    },
    guidanceText: {
      key: "enterTheRemainingNDigitsForExample",
      values: {
        numDigits: "9",
        example: "EE100254507"
      }
    }
  },
  [CountryCodes.Finland]: {
    label: "arvonlisaveronumeroMervardesskattenummer",
    validators: validatePatternOnBlur(/^FI\d{8}$/),
    mask: {
      mask: makeMask(...nonInputs("FI", { includeInValue: true }), spacer, ...numericInputs(8))
    },
    guidanceText: {
      key: "enterTheRemainingNDigitsForExample",
      values: {
        numDigits: "9",
        example: "FI12345678"
      }
    }
  },
  [CountryCodes.France]: ({ vatNumberType }) => {
    const sharedMetadata = {
      validators: validatePatternOnBlur(/^FR\d{11}$/),
      mask: {
        mask: makeMask(...nonInputs("FR", { includeInValue: true }), spacer, ...numericInputs(11))
      }
    };
    switch (vatNumberType) {
      case "NumeroDeTVA":
        return {
          ...sharedMetadata,
          label: "NumeroDeTVA",
          guidanceText: {
            key: "enterTheRemainingNDigitsForExample",
            values: {
              numDigits: "11",
              example: "FR12999999999"
            }
          }
        };
      case "numeroDIdentificationALATaxe":
      default:
        return {
          ...sharedMetadata,
          label: "numeroDIdentificationALATaxe",
          guidanceText: {
            key: "enterTheRemainingNDigitsForExample",
            values: {
              numDigits: "11",
              example: "FR12345678901"
            }
          }
        };
    }
  },
  [CountryCodes.Germany]: {
    label: "USt-IdNr",
    validators: validatePatternOnBlur(/^DE\d{9}$/),
    mask: {
      mask: makeMask(...nonInputs("DE", { includeInValue: true }), spacer, ...numericInputs(9))
    },
    guidanceText: {
      key: "enterTheRemainingNDigitsForExample",
      values: {
        numDigits: "9",
        example: "DE115235681"
      }
    }
  },
  [CountryCodes.Greece]: {
    label: "grTaxId",
    validators: validatePatternOnBlur(/^EL\d{9}$/),
    mask: {
      mask: makeMask(...nonInputs("EL", { includeInValue: true }), spacer, ...numericInputs(9))
    },
    guidanceText: {
      key: "enterTheRemainingNDigitsForExample",
      values: {
        numDigits: "9",
        example: "EL123456789"
      }
    }
  },
  [CountryCodes.Hungary]: {
    label: "huTaxId",
    validators: validatePatternOnBlur(/^HU\d{8}$/),
    mask: {
      mask: makeMask(...nonInputs("HU", { includeInValue: true }), spacer, ...numericInputs(8))
    },
    guidanceText: {
      key: "enterTheRemainingNDigitsForExample",
      values: {
        numDigits: "8",
        example: "HU12345678"
      }
    }
  },
  [CountryCodes.Ireland]: {
    label: "vatNumber",
    validators: validatePatternOnBlur(/^IE[A-Z0-9]{8,9}$/),
    mask: {
      mask: makeMask(
        ...nonInputs("IE", { includeInValue: true }),
        spacer,
        ...alphanumericInputs(8),
        ...alphanumericInputs(1, true)
      ),
      transformOnType: uppercase
    },
    guidanceText: {
      key: "enterTheRemainingXToYCharactersForExample",
      values: {
        minChars: "8",
        maxChars: "9",
        example: "IE999999XX"
      }
    }
  },
  [CountryCodes.Italy]: {
    label: "partitaIVA",
    validators: validatePatternOnBlur(/^IT\d{11}$/),
    mask: {
      mask: makeMask(...nonInputs("IT", { includeInValue: true }), spacer, ...numericInputs(11))
    },
    guidanceText: {
      key: "enterTheRemainingNDigitsForExample",
      values: {
        numDigits: "11",
        example: "IT47040001100"
      }
    }
  },
  [CountryCodes.Latvia]: {
    label: "lvTaxId",
    validators: validatePatternOnBlur(/^LV\d{11}$/),
    mask: {
      mask: makeMask(...nonInputs("LV", { includeInValue: true }), spacer, ...numericInputs(11))
    },
    guidanceText: {
      key: "enterTheRemainingNDigitsForExample",
      values: {
        numDigits: "11",
        example: "LV43603021620"
      }
    }
  },
  [CountryCodes.Liechtenstein]: {
    label: "vatRegistrationNumber",
    validators: validatePatternOnBlur(/^[0-9]{1,6}$/),
    mask: {
      mask: makeMask(...numericInputs(1), ...numericInputs(5, true))
    },
    guidanceText: {
      key: "enterAMaximumOfNDigitsForExample",
      values: {
        maxDigits: "6",
        example: "123456"
      }
    }
  },
  [CountryCodes.Lithuania]: {
    label: "PVMmoketojoKodas",
    validators: validatePatternOnBlur(/^LT\d{9,12}$/),
    mask: {
      mask: makeMask(
        ...nonInputs("LT", { includeInValue: true }),
        spacer,
        ...numericInputs(9),
        ...numericInputs(3, true)
      )
    },
    guidanceText: {
      key: "enterTheRemainingXToYDigitsForExample",
      values: {
        minDigits: "9",
        maxDigits: "12",
        example: "LT664517219"
      }
    }
  },
  [CountryCodes.Luxembourg]: {
    label: "numeroDIdentificationALATaxe",
    validators: validatePatternOnBlur(/^LU\d{8}$/),
    mask: {
      mask: makeMask(...nonInputs("LU", { includeInValue: true }), spacer, ...numericInputs(8))
    },
    guidanceText: {
      key: "enterTheRemainingNDigitsForExample",
      values: {
        numDigits: "8",
        example: "LU18928066"
      }
    }
  },
  [CountryCodes.Malaysia]: {
    label: "SST",
    validators: validatePatternOnBlur(/^([A-Z]\d{2}[-]\d{4}[-]\d{8}|\d{12})$/),
    guidanceText: {
      key: "enterXOrYCharactersForExample",
      values: {
        xChars: "12",
        yChars: "14",
        example: "123456789012, D11-1808-20032117"
      }
    }
  },
  [CountryCodes.Malta]: {
    label: "vatNumber",
    validators: validatePatternOnBlur(/^MT\d{8}$/),
    mask: {
      mask: makeMask(...nonInputs("MT", { includeInValue: true }), spacer, ...numericInputs(8))
    },
    guidanceText: {
      key: "enterTheRemainingNDigitsForExample",
      values: {
        numDigits: "8",
        example: "MT12345678"
      }
    }
  },
  [CountryCodes.Monaco]: {
    label: "numeroDIdentificationALATaxe",
    validators: validatePatternOnBlur(/^FR[0-9]{11}$/),
    mask: {
      mask: makeMask(...nonInputs("FR", { includeInValue: true }), spacer, ...numericInputs(11))
    },
    guidanceText: {
      key: "enterTheRemainingNDigitsForExample",
      values: {
        numDigits: "11",
        example: "FR12345678999"
      }
    }
  },
  [CountryCodes.Netherlands]: {
    label: "btwNummer",
    validators: validatePatternOnBlur(/^NL\d{9}B\d{2}$/),
    mask: {
      mask: makeMask(
        ...nonInputs("NL", { includeInValue: true }),
        spacer,
        ...numericInputs(9),
        spacer,
        ...nonInputs("B", { includeInValue: true }),
        spacer,
        ...numericInputs(2)
      ),
      transformOnType: uppercase
    },
    guidanceText: {
      key: "enterTheRemainingNCharactersForExample",
      values: {
        numChars: "12",
        example: "NL123456789B01"
      }
    }
  },
  [CountryCodes.Norway]: {
    label: "mvanummer",
    validators: validatePatternOnBlur(/^\d{9}MVA$/),
    mask: {
      mask: makeMask(
        ...numericInputs(9),
        ...nonInputs("MVA", { includeInValue: true, displayEagerly: true })
      )
    },
    guidanceText: {
      key: "enterNDigitsForExample",
      values: {
        numDigits: "9",
        example: "123456789MVA"
      }
    }
  },
  [CountryCodes.Poland]: {
    label: "NIP",
    validators: validatePatternOnBlur(/^PL\d{10}$/),
    mask: {
      mask: makeMask(...nonInputs("PL", { includeInValue: true }), spacer, ...numericInputs(10))
    },
    guidanceText: {
      key: "enterTheRemainingNDigitsForExample",
      values: {
        numDigits: "10",
        example: "PL1234567890"
      }
    }
  },
  [CountryCodes.Portugal]: {
    label: "numerodeIVA",
    validators: validatePatternOnBlur(/^PT\d{9}$/),
    mask: {
      mask: makeMask(...nonInputs("PT", { includeInValue: true }), spacer, ...numericInputs(9))
    },
    guidanceText: {
      key: "enterTheRemainingNDigitsForExample",
      values: {
        numDigits: "9",
        example: "PT123456789"
      }
    }
  },
  [CountryCodes.Romania]: {
    label: "codulDeIdentificareFiscala",
    validators: validatePatternOnBlur(/^RO\d{2,12}$/),
    mask: {
      mask: makeMask(
        ...nonInputs("RO", { includeInValue: true }),
        spacer,
        ...numericInputs(2),
        ...numericInputs(8, true)
      )
    },
    guidanceText: {
      key: "enterTheRemainingXToYDigitsForExample",
      values: {
        minDigits: "2",
        maxDigits: "10",
        example: "RO12345678"
      }
    }
  },
  [CountryCodes.Slovakia]: {
    label: "skTaxId",
    validators: validatePatternOnBlur(/^SK\d{10}$/),
    mask: {
      mask: makeMask(...nonInputs("SK", { includeInValue: true }), spacer, ...numericInputs(10))
    },
    guidanceText: {
      key: "enterTheRemainingNDigitsForExample",
      values: {
        numDigits: "10",
        example: "SK1234567890"
      }
    }
  },
  [CountryCodes.Slovenia]: {
    label: "siTaxId",
    validators: validatePatternOnBlur(/^SI\d{8}$/),
    mask: {
      mask: makeMask(...nonInputs("SI", { includeInValue: true }), spacer, ...numericInputs(8))
    },
    guidanceText: {
      key: "enterTheRemainingNDigitsForExample",
      values: {
        numDigits: "8",
        example: "SI12345678"
      }
    }
  },
  [CountryCodes.Spain]: {
    label: "NIFdeIVA",
    validators: validatePatternOnBlur(/^ES[A-Z0-9]\d{7}[A-Z0-9]$/),
    mask: {
      mask: makeMask(
        ...nonInputs("ES", { includeInValue: true }),
        spacer,
        ...alphanumericInputs(9)
      ),
      transformOnType: uppercase
    },
    guidanceText: {
      key: "enterTheRemainingNCharactersForExample",
      values: {
        numChars: "9",
        example: "ES12345678X"
      }
    }
  },
  [CountryCodes.Sweden]: {
    label: "vatNummerMomsregistreringsnummerOrMomsnummer",
    validators: validatePatternOnBlur(/^SE\d{12}$/),
    mask: {
      mask: makeMask(...nonInputs("SE", { includeInValue: true }), spacer, ...numericInputs(12))
    },
    guidanceText: {
      key: "enterTheRemainingNDigitsForExample",
      values: {
        numDigits: "12",
        example: "SE123456789001"
      }
    }
  },
  [CountryCodes.Switzerland]: {
    label: "Mehrwertsteuernummer",
    // CHE123456789TVA | CHE....MWST | CHE.......IVA
    validators: validatePatternOnBlur(/^CHE\d{9}(TVA|MWST|IVA)$/),
    mask: {
      mask: makeMask(
        ...nonInputs("CHE", { includeInValue: true }),
        ...nonInputs(" - "),
        ...numericInputs(3),
        ...nonInputs(" . "),
        ...numericInputs(3),
        ...nonInputs(" . "),
        ...numericInputs(3),
        spacer,
        ...alphaInputs(3),
        ...alphaInputs(1, true)
      ),
      transformOnType: uppercase
    },
    guidanceText: {
      key: "enterTheRemainingNDigitsThenXToYLettersForExample",
      values: {
        numDigits: "9",
        minLetters: "3",
        maxLetters: "4",
        example: "CHE-123.456.789 TVA"
      }
    }
  },
  [CountryCodes.UnitedArabEmirates]: {
    label: "vatRegistrationNumber",
    validators: validateNotEmptyOnBlur
  },
  [CountryCodes.UnitedKingdom]: {
    label: "vatRegistrationNumber",
    validators: validatePatternOnBlur(/^GB\d{9,12}$/),
    mask: {
      mask: makeMask(
        ...nonInputs("GB", { includeInValue: true }),
        spacer,
        ...numericInputs(9),
        ...numericInputs(3, true)
      )
    },
    guidanceText: {
      key: "enterTheRemainingXToYDigitsForExample",
      values: {
        minDigits: "9",
        maxDigits: "12",
        example: "GB1234567890"
      }
    }
  },
  /**
   * NOT YET SUPPORTED
   * These are brought over from the old pattern files. We have no idea if they are accurate or not.
   * See https://en.wikipedia.org/wiki/VAT_identification_number
   */
  [CountryCodes.Albania]: {
    validators: validatePatternOnBlur(/^[JKLM][A-Z0-9]{8}[A-Z]$/)
  },
  [CountryCodes.Belarus]: {
    validators: validatePatternOnBlur(/^\d{9}$/)
  },
  [CountryCodes.RussianFederation]: {
    validators: validatePatternOnBlur(/^(\d{10}|\d{12})$/)
  },
  [CountryCodes.SanMarino]: {
    validators: validatePatternOnBlur(/^\d{5}$/)
  },
  [CountryCodes.Serbia]: {
    validators: validatePatternOnBlur(/^\d{9}$/)
  },
  [CountryCodes.Turkey]: {
    validators: validatePatternOnBlur(/^\d{10}$/)
  },
  [CountryCodes.Ukraine]: {
    validators: validatePatternOnBlur(/^\d{12}$/)
  },
  [CountryCodes.Argentina]: {
    validators: validatePatternOnBlur(/^\d{11}$/)
  },
  [CountryCodes.Chile]: {
    validators: validatePatternOnBlur(/^\d{9}$/)
  },
  [CountryCodes.Colombia]: {
    validators: validatePatternOnBlur(/^\d{10}$/)
  },
  [CountryCodes.CostaRica]: {
    validators: validatePatternOnBlur(/^\d{9,12}$/)
  },
  [CountryCodes.Ecuador]: {
    validators: validatePatternOnBlur(/^\d{13}$/)
  },
  [CountryCodes.Guatemala]: {
    validators: validatePatternOnBlur(/^\d{8}$/)
  },
  [CountryCodes.Peru]: {
    validators: validatePatternOnBlur(/^\d{11}$/)
  },
  [CountryCodes.Venezuela]: {
    validators: validatePatternOnBlur(/^[JGVE]-\d{8}-?\d$/)
  }
};
const inferVatNumberType = (vatNumber, country) => {
  const optionsForCountry = vatNumberOptions[country];
  const metadataFn = defaultFieldConfig[country];
  if (!optionsForCountry || !metadataFn) return void 0;
  for (const option of optionsForCountry) {
    const fieldMetadata = typeof metadataFn === "function" ? metadataFn({
      vatNumberType: option.id
    }) : metadataFn;
    if (!fieldMetadata.validators) continue;
    const validators = Array.isArray(fieldMetadata.validators) ? fieldMetadata.validators : [fieldMetadata.validators];
    if (validators.every((validator) => validator.validate(vatNumber))) {
      return option.id;
    }
  }
};
function getDefaultVatNumberType(vatNumber, country) {
  return vatNumber ? inferVatNumberType(vatNumber, country) : vatNumberOptions[country]?.[0]?.id;
}
function VatNumberTypeSelector({
  country,
  companyType,
  selected,
  setSelected,
  exemptedOption
}) {
  const { t } = useTranslation("common");
  const handleSelect = useCallback(
    (selectedStr) => {
      const newSelected = selectedStr;
      if (newSelected === "exempted") {
        if (exemptedOption) {
          setSelected(newSelected, true);
        }
        return;
      }
      setSelected(newSelected, false);
    },
    [exemptedOption, setSelected]
  );
  const options = useMemo(() => {
    const availableOptions = getVatNumberOptions(country, companyType) ?? [];
    if (availableOptions.length === 0 || !exemptedOption) return availableOptions;
    return [
      ...availableOptions,
      {
        id: "exempted",
        name: exemptedOption
      }
    ];
  }, [country, companyType, exemptedOption]);
  useEffect(() => {
    if (!selected && options.length > 0) {
      handleSelect(options[0].id);
    }
  }, [options, selected, handleSelect]);
  if (options.length <= 1) return null;
  return /* @__PURE__ */ jsx(
    Field,
    {
      el: "fieldset",
      name: "vatNumberType",
      label: t(($) => $["whichTypeOfTaxIdNumberDoYouHave"]),
      children: (childProps) => /* @__PURE__ */ jsx(
        RadioGroup,
        {
          ...childProps,
          name: "vatNumberType",
          items: options,
          value: selected,
          onChange: handleSelect
        }
      )
    }
  );
}
const VAT_NUMBER_FIELD = [
  "vatNumber",
  "vatNumberType",
  "exemptedFromVat",
  "vatAbsenceReason"
];
function VatNumberField({
  data,
  valid,
  errors,
  labels,
  mask,
  guidanceText,
  readonly,
  optional,
  shouldValidate,
  handleChangeFor,
  canExempt,
  country
}) {
  const { isExperimentEnabled } = useExperimentsContext();
  const options = vatNumberOptions[country];
  const defaultType = getDefaultVatNumberType(data.vatNumber, country);
  const vatAbsenceReasons = isExperimentEnabled("ShowExtraTaxExemptionReasons") ? ["belowTaxThreshold", "industryExemption", "countryWithoutVatOrGstSystem"] : ["belowTaxThreshold", "industryExemption"];
  const showVatExemptedOptions = canExempt && options?.length > 1;
  const vatNumberType = data.exemptedFromVat ? "exempted" : data.vatNumberType ? data.vatNumberType : defaultType;
  const handleVatNumberChange = (e, mode) => {
    const value = typeof e === "string" ? e : e.currentTarget.value;
    handleChangeFor("vatNumber", mode)(value);
    handleChangeFor("vatNumberType")(vatNumberType);
  };
  const handleVatNumberTypeChange = (vatType, exemptValue) => {
    if (vatType === "exempted") {
      if (!canExempt) {
        throw Error(`${country} does not allow VAT exemptions`);
      }
      handleChangeFor("vatNumber")(null);
      handleChangeFor("vatNumberType")(void 0);
      handleChangeFor("exemptedFromVat")(exemptValue);
      return;
    }
    if (canExempt) {
      handleChangeFor("exemptedFromVat")(exemptValue);
    }
    handleChangeFor("vatNumberType")(vatType);
  };
  if (vatNumberType && vatNumberType !== "exempted") {
    const countryHasType = options?.find((option) => option.id === vatNumberType);
    if (!countryHasType) {
      handleChangeFor("vatNumberType")(defaultType);
    }
  }
  if (data.exemptedFromVat === false && data.vatAbsenceReason) {
    handleChangeFor("vatAbsenceReason")(null);
  }
  return /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-field__vat-number", children: [
    /* @__PURE__ */ jsx(
      VatNumberTypeSelector,
      {
        country,
        setSelected: handleVatNumberTypeChange,
        selected: vatNumberType,
        exemptedOption: showVatExemptedOptions ? labels.exemptedFromVat : false
      }
    ),
    /* @__PURE__ */ jsx(
      MaskedInput,
      {
        type: "text",
        "aria-required": true,
        "aria-invalid": !valid.vatNumber,
        name: "vatNumber",
        value: data?.vatNumber ?? "",
        label: labels.vatNumber ?? "",
        formatGuidance: guidanceText?.vatNumber ?? "",
        errorMessage: errors.vatNumber,
        isValid: Boolean(valid.vatNumber),
        onInput: (e) => handleVatNumberChange(e, "input"),
        onBlur: (e) => handleVatNumberChange(e, "blur"),
        disabled: data.exemptedFromVat,
        readonly,
        optional,
        shouldValidate,
        ...mask
      }
    ),
    canExempt && !showVatExemptedOptions && /* @__PURE__ */ jsx(Field, { name: "exemptedFromVat", children: (childProps) => /* @__PURE__ */ jsx(
      Checkbox,
      {
        ...childProps,
        "aria-required": false,
        "aria-invalid": false,
        name: "exemptedFromVat",
        label: labels?.exemptedFromVat,
        value: "exemptedFromVat",
        checked: Boolean(data.exemptedFromVat),
        onChange: (e) => handleVatNumberTypeChange("exempted", e)
      }
    ) }),
    data.exemptedFromVat && /* @__PURE__ */ jsx(
      Field,
      {
        el: "fieldset",
        name: "vatAbsenceReason",
        label: labels?.vatAbsenceReason,
        errorMessage: errors.vatAbsenceReason,
        isValid: valid.vatAbsenceReason,
        children: (childProps) => /* @__PURE__ */ jsx(
          RadioGroup,
          {
            ...childProps,
            name: "vatAbsenceReason",
            onChange: handleChangeFor("vatAbsenceReason"),
            value: data.vatAbsenceReason,
            items: vatAbsenceReasons.map((reason) => ({ id: reason, name: reason }))
          }
        )
      }
    )
  ] });
}
const operationalAddressIsSameIds = {
  OPERATIONAL_ADDRESS_IS_SAME: "OperationAddressAnswerYes",
  OPERATIONAL_ADDRESS_IS_NOT_SAME: "OperationAddressAnswerNo"
};
const operationalAddressIsSameItems = [
  {
    id: operationalAddressIsSameIds.OPERATIONAL_ADDRESS_IS_SAME,
    name: "operationalAddressIsSameItemName"
  },
  {
    id: operationalAddressIsSameIds.OPERATIONAL_ADDRESS_IS_NOT_SAME,
    name: "operationalAddressIsNotSameItemName"
  }
];
const registrationAddressValidationRules = {
  operationalAddressIsSame: {
    modes: ["blur"],
    validate: (operationalAddressIsSame) => !!operationalAddressIsSame,
    errorMessage: "fieldIsRequired"
  }
};
const registrationAddressFields = [
  "registrationAddress",
  "operationalAddress",
  "operationalAddressIsSame"
];
const registrationAddressForms = {
  registrationAddress: {
    formId: "registrationAddress"
  },
  operationalAddress: {
    formId: "operationalAddress"
  }
};
const registrationAddressFormID = registrationAddressForms.registrationAddress.formId;
const operationalAddressFormID = registrationAddressForms.operationalAddress.formId;
function RegistrationAddress(props) {
  const { t } = useTranslation("common");
  const { id, heading, description, country, data, validators, problems } = props;
  const {
    requiredFields: registrationAddressRequiredFields,
    optionalFields: registrationAddressOptionalFields,
    readOnlyFields: registrationAddressReadOnlyFields,
    obscuredFields: registrationAddressObscuredFields,
    verifyFields: registrationAddressVerifyFields,
    trustedFields: registrationAddressTrustedFields
  } = getFormProps(props, registrationAddressFormID);
  const {
    data: formData,
    valid: formValid,
    errors: formErrors,
    fieldProblems: formFieldProblems,
    handleChangeFor,
    setValid
  } = useForm({
    ...props,
    schema: ["operationalAddressIsSame"],
    defaultData: data,
    rules: validators || registrationAddressValidationRules,
    obscuredFields: [],
    optionalFields: registrationAddressOptionalFields,
    trustedFields: registrationAddressTrustedFields
  });
  const mergedProps = {
    ...props,
    requiredFields: registrationAddressRequiredFields,
    optionalFields: registrationAddressOptionalFields,
    readOnlyFields: registrationAddressReadOnlyFields,
    obscuredFields: registrationAddressObscuredFields,
    trustedFields: registrationAddressTrustedFields
  };
  const formUtils = createFormUtils(mergedProps, t);
  const stateRef = useRef({ setState: null });
  useEffect(() => {
    stateRef?.current?.setState?.({
      type: "addToState",
      value: {
        data: formData,
        valid: formValid,
        errors: formErrors,
        fieldProblems: formFieldProblems,
        dataStoreId: id,
        schema: [
          "registrationAddress",
          "operationalAddressIsSame",
          ...isOperationAddressNotSame() ? ["operationalAddress"] : []
        ]
      }
    });
  }, [formData, formValid, formErrors, formFieldProblems]);
  const isOperationAddressNotSame = () => formData.operationalAddressIsSame === operationalAddressIsSameIds.OPERATIONAL_ADDRESS_IS_NOT_SAME;
  const registrationAddressFormProps = getFormProps(props, registrationAddressFormID);
  const operationalAddressFormProps = getFormProps(props, operationalAddressFormID);
  const handleRegistrationAddressChange = (state) => {
    handleChangeFor("registrationAddress")(state.data);
    setValid("registrationAddress", Boolean(state.isValid));
  };
  const handleOperationalAddressChange = (state) => {
    handleChangeFor("operationalAddress")(state.data);
    setValid("operationalAddress", Boolean(state.isValid));
  };
  const handleOperationalAddressIsSameChange = (value) => {
    handleChangeFor("operationalAddressIsSame")(value);
    if (value === "OperationAddressAnswerYes") setValid("operationalAddress", true);
  };
  return /* @__PURE__ */ jsxs(Fragment, { children: [
    /* @__PURE__ */ jsx(StateContextSetter, { owner: id, stateRef }),
    heading && /* @__PURE__ */ jsx(Header, { title: heading, description }),
    /* @__PURE__ */ jsx(
      ErrorPanel,
      {
        verificationErrors: id ? problems?.verificationErrors?.[id] : void 0,
        validationErrors: id ? problems?.validationErrors?.[id] : void 0,
        formUtils,
        id: "ariaErrorField"
      }
    ),
    /* @__PURE__ */ jsx(
      ContextGuidance,
      {
        titleId: "whyDoINeedToFillInThisInformation",
        contentId: "reasonForFillingCompanyAddressDetails",
        title: t(($) => $["whyDoINeedToFillInThisInformation"]),
        content: t(($) => $["reasonForFillingCompanyAddressDetails"])
      }
    ),
    /* @__PURE__ */ jsx(
      Address,
      {
        ...registrationAddressFormProps,
        data: { ...registrationAddressFormProps?.data, country },
        hideCountry: true,
        id,
        addressType: "registrationAddress",
        optionalFields: ["otherAddressInformation"],
        onChange: handleRegistrationAddressChange
      }
    ),
    /* @__PURE__ */ jsx(Header, { title: t(($) => $["operationalAddressHeader"]), secondary: true }),
    /* @__PURE__ */ jsx(
      Field,
      {
        el: "fieldset",
        name: "operationalAddressIsSame",
        label: formUtils.getLabel("operationalAddressIsSame"),
        errorMessage: formErrors.operationalAddressIsSame?.errorMessage,
        children: (childProps) => /* @__PURE__ */ jsx(
          RadioGroup,
          {
            ...childProps,
            name: "operationalAddressIsSame",
            items: operationalAddressIsSameItems,
            value: formData.operationalAddressIsSame,
            disabled: formUtils.isReadOnly("operationalAddressIsSame"),
            onChange: handleOperationalAddressIsSameChange,
            "aria-required": true,
            "aria-invalid": !formValid.operationalAddressIsSame
          }
        )
      }
    ),
    isOperationAddressNotSame() && /* @__PURE__ */ createElement(
      Address,
      {
        ...operationalAddressFormProps,
        key: "operationalAddress",
        data: { ...operationalAddressFormProps?.data, country },
        hideCountry: true,
        id,
        optionalFields: ["otherAddressInformation"],
        addressType: "operationalAddress",
        onChange: handleOperationalAddressChange
      }
    )
  ] });
}
const ConstitutionalDocumentTypes = {
  BUSINESS_NAME_FILING: "doingBusinessAsNameFiling",
  TAX_FILING: "taxFiling",
  EMPLOYER_IDENTIFICATION_NUMBER_VERIFICATION_LETTER: "einVerificationLetter",
  BUSINESS_REGISTRATION_DOCUMENT: "businessRegistrationDocument",
  TRUST_DEED: "trustDeed",
  TRUST_INSTRUMENT: "trustInstrument",
  PARTNERSHIP_AGREEMENT: "partnershipAgreement",
  MEETING_MINUTES: "meetingMinutes"
};
const getConstitutionDocumentTypeOptionsMapping = (legalEntityType, country) => {
  switch (legalEntityType) {
    case LegalEntityTypes.SOLE_PROPRIETORSHIP:
      switch (country) {
        case "FR":
          return [
            {
              id: ConstitutionalDocumentTypes.BUSINESS_NAME_FILING,
              name: "doingBusinessAsNameFiling__FR"
            },
            { id: ConstitutionalDocumentTypes.TAX_FILING, name: "taxFiling" },
            {
              id: ConstitutionalDocumentTypes.BUSINESS_REGISTRATION_DOCUMENT,
              name: "businessRegistrationDocument__FR"
            }
          ];
        case "US":
          return [
            {
              id: ConstitutionalDocumentTypes.BUSINESS_NAME_FILING,
              name: "doingBusinessAsNameFiling__US"
            },
            { id: ConstitutionalDocumentTypes.TAX_FILING, name: "taxFiling__US" },
            {
              id: ConstitutionalDocumentTypes.EMPLOYER_IDENTIFICATION_NUMBER_VERIFICATION_LETTER,
              name: "einVerificationLetter"
            }
          ];
        default:
          return [
            {
              id: ConstitutionalDocumentTypes.BUSINESS_NAME_FILING,
              name: "doingBusinessAsNameFiling"
            },
            { id: ConstitutionalDocumentTypes.TAX_FILING, name: "taxFiling" }
          ];
      }
    case LegalEntityTypes.UNINCORPORATED_PARTNERSHIP:
      return [
        {
          id: ConstitutionalDocumentTypes.PARTNERSHIP_AGREEMENT,
          name: "partnershipAgreement"
        },
        {
          id: ConstitutionalDocumentTypes.MEETING_MINUTES,
          name: "meetingMinutes"
        }
      ];
    default:
      return [
        { id: ConstitutionalDocumentTypes.TRUST_DEED, name: "trustDeed" },
        { id: ConstitutionalDocumentTypes.TRUST_INSTRUMENT, name: "trustInstrument" }
      ];
  }
};
function getLegalEntityTypeBasedConstitutionalDocumentHeaderDescriptionTranslationkey(legalEntityType) {
  switch (legalEntityType) {
    case LegalEntityTypes.SOLE_PROPRIETORSHIP:
      return "constitutionalDocumentSoleProprietorshipHeaderDescription";
    case LegalEntityTypes.TRUST:
      return "constitutionalDocumentTrustHeaderDescription";
    case LegalEntityTypes.UNINCORPORATED_PARTNERSHIP:
      return "constitutionalDocumentUnincorporatedPartnershipDescription";
    default:
      return "constitutionalDocumentHeaderDescription";
  }
}
const unincorporatedPartnershipRequirementsVariants = ["Name", "Details", "UpToDate"];
function ConstitutionalDocumentUpload({
  id,
  legalEntityType,
  ...props
}) {
  const { t } = useTranslation(["common"]);
  usePageLandedEvent();
  const isUnincorporatedPartnership = legalEntityType === LegalEntityTypes.UNINCORPORATED_PARTNERSHIP;
  const constitutionalDocumentRequirements = getConstitutionDocumentTypeOptionsMapping(
    legalEntityType,
    props.country
  );
  const guidanceContent = /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-upload-field__guidance adyen-kyc-u-margin-bottom-24", children: [
    /* @__PURE__ */ jsx("strong", { children: t(($) => $["uploadOneOfTheseDocuments"]) }),
    /* @__PURE__ */ jsx("ul", { children: constitutionalDocumentRequirements?.map(({ name }, i) => /* @__PURE__ */ jsx("li", { children: t(($) => $[name]) }, i)) }),
    isUnincorporatedPartnership && /* @__PURE__ */ jsxs(Fragment, { children: [
      /* @__PURE__ */ jsx("strong", { children: t(($) => $["documentRequirements"]) }),
      /* @__PURE__ */ jsx("ul", { children: unincorporatedPartnershipRequirementsVariants.map((item, i) => /* @__PURE__ */ jsx("li", { children: t(
        ($) => $[`documentRequirementsUnincorporatedPartnership${item}`],
        { ns: "common" }
      ) }, i)) })
    ] }),
    props.country !== "US" && !isUnincorporatedPartnership && /* @__PURE__ */ jsx("div", { className: "adyen-kyc-u-margin-y-16", children: /* @__PURE__ */ jsxs("span", { children: [
      t(($) => $["infoInUploadedDocumentIsTrue"]),
      " "
    ] }) })
  ] });
  return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
    MemoizedDocumentUpload,
    {
      ...props,
      documentType: "constitutionalDocument",
      documentField: "constitutionalDocument",
      heading: t(($) => $["constitutionalDocumentHeader"]),
      description: t(
        ($) => $[getLegalEntityTypeBasedConstitutionalDocumentHeaderDescriptionTranslationkey(
          legalEntityType
        )],
        { ns: "common" }
      ),
      guidanceContent,
      id,
      hidePageCount: true
    }
  ) });
}
const MemoizedConstitutionalDocument = memo(
  ConstitutionalDocumentUpload,
  (prevProps, nextProps) => objectsDeepEqual(prevProps.requiredFields, nextProps.requiredFields) && objectsDeepEqual(prevProps.data, nextProps.data) && objectsDeepEqual(prevProps.formVerificationErrors, nextProps.formVerificationErrors) && objectsDeepEqual(prevProps.fieldValidationErrors, nextProps.fieldValidationErrors) && prevProps.shouldValidate === nextProps.shouldValidate
);
export {
  BUSINESS_REGISTRATION_NUMBER_FIELD as B,
  DBA_NAME_FIELD as D,
  MemoizedConstitutionalDocument as M,
  RegistrationAddress as R,
  VAT_NUMBER_FIELD as V,
  defaultFieldConfig as a,
  registrationNumberDefaultFieldMetadata as b,
  registrationNumberDefaultFieldConfig as c,
  defaultFieldMetadata as d,
  doingBusinessAsFieldMetadata as e,
  doingBusinessAsAbsentFieldMetadata as f,
  DBANameField as g,
  BusinessRegistrationNumberField as h,
  getRegistrationNumberHelperText as i,
  VatNumberField as j,
  getDefaultRegistrationNumberType as k,
  getDefaultVatNumberType as l,
  inferCompanyRegistrationNumberType as m,
  exemptFromRegistrationNumberDefaultFieldMetadata as n,
  operationalAddressIsSameIds as o,
  exemptFromRegistrationNumberDefaultFieldConfig as p,
  operationalAddressIsSameItems as q,
  registrationAddressFields as r,
  vatAbsenceReasonMetadata as v
};
