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] = "f5998ade-3ffc-4476-92ee-4a2def01fab1", e._sentryDebugIdIdentifier = "sentry-dbid-f5998ade-3ffc-4476-92ee-4a2def01fab1");
} catch (e) {}
import { i as Typography, r as useTranslation } from "./translation-Br5wIPO-.js";
import { r as Loader, t as Button } from "./Button-BDEdGXnd.js";
import { n as httpGet, s as useApiContext } from "./http-CHTzpXCd.js";
import { t as LegalEntityTypes } from "./legal-entity-type-VIfNYnJP.js";
import { t as useSettingsContext } from "./useSettingsContext-DzwVt0W0.js";
import { n as cloneObject } from "./AnalyticsContext-C0HNdPss.js";
import { t as Header } from "./Header-B_MIsVov.js";
import { n as datasetUtilities } from "./datasetUtil-BZmNUckr.js";
import { y as reverseMapping } from "./processCapabilities-CDSEJpB8.js";
import { f as hasSolePropInLegalEntity } from "./entityAssociationUtil-C0gX4Ewv.js";
import { t as isEeaCountry } from "./country-C5KY5i2U.js";
import { t as useAnalyticsContext } from "./useAnalyticsContext-DfTXpZbA.js";
import { t as SettingNames } from "./types-BklAlvuU.js";
import { t as useToastContext } from "./useToastContext-CK7UoZ5Z.js";
import { t as EndStateLayout } from "./EndStateLayout-DxdIVWL3.js";
import { t as useInvalidateRootLegalEntity } from "./invalidateRootLegalEntity-BHyct4ev.js";
import { t as useAssociatedLegalEntity } from "./useAssociatedLegalEntity-CYu0lsaE.js";
import { n as translateTranslatable } from "./utils-g_Wl4-9Z.js";
import { t as useCreateLegalEntity } from "./useCreateLegalEntity-C149Z7Xu.js";
import { t as useUpdateLegalEntity } from "./useUpdateLegalEntity-CUs6TYPF.js";
import { t as Address } from "./Address-CHpJLi-Q.js";
import { i as FormFlow, n as addValidityToForms, o as useFormComposer, r as getRequiredForms, s as FormContextProvider, t as useFormContext } from "./useFormContext-Cu4dKSCy.js";
import { t as ErrorPanel } from "./ErrorPanel-5g1eTEVD.js";
import { t as createFormUtils } from "./formUtils-DERTAXyh.js";
import { t as useMultiForm } from "./useMultiForm-tpVMuqHM.js";
import { t as useTaskLandedEvent } from "./useTaskLandedEvent-DCdJo64z.js";
import { c as COUNTRIES_WITH_STATES_DATASET, n as getAddressSchemaLabelsByCountry, t as getAddressSchemaForCountry } from "./utils-DLDyhf2J.js";
import { i as isValidationError, o as processValidationErrors, s as isMaintenanceModeError } from "./validationError-Dr0g0lGN.js";
import { r as formatObject } from "./utils--gwzjjeS.js";
import { t as localizeDateString } from "./localizeDateString-B7EYBFnd.js";
import { t as Field } from "./Field-BEqknhTe.js";
import { t as Select } from "./Select-CMFHti4N.js";
import { t as Checkbox } from "./Checkbox-BJJIXNHL.js";
import { t as getFieldProps } from "./getProps-DQy_qV_x.js";
import { t as Link } from "./Link-BoduD1oh.js";
import { t as InputText } from "./InputText-CadVntiC.js";
import { t as InputDate } from "./InputDate-DsEAx7kx.js";
import { n as CountryField } from "./CountryField-B-JxQ6z9.js";
import { t as RadioGroup } from "./RadioGroup-XuCtbRrH.js";
import { t as currencyByCountry } from "./types-DjplYXLf.js";
import { a as LegalFormField, i as InputCurrency, n as Currency, o as mapFinancialReportsToFinancialInformation, r as InputNumber, s as mapFinancialInformationToFinancialReport, t as CURRENCY_FIELD } from "./Currency-BbWaBY8A.js";
import { t as NewSummary } from "./NewSummary-BQHtEgHV.js";
import { t as businessFinancingMultiformRules } from "./validate-_5wbUbU9.js";
import { useEffect, useMemo, useRef, useState } from "preact/hooks";
import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
import { useQuery } from "@tanstack/preact-query";
//#region src/components/EFP/mapping/businessFinancingKeyMappings.ts
var businessFinancingBaseMapping = {
	legalProceedingsDate: "organization.dateOfInitiationOfLegalProceeding",
	legalInformationInsolvency: "organization.statusOfLegalProceeding",
	legalEntityIdentifier: "organization.globalLegalEntityIdentifier",
	naceCode: "organization.economicSector",
	legalForm: "organization.legalForm",
	legalName: "organization.legalName",
	"registrationAddress.city": "organization.registeredAddress.city",
	"registrationAddress.country": "organization.registeredAddress.country",
	"registrationAddress.postalCode": "organization.registeredAddress.postalCode",
	"registrationAddress.stateOrProvince": "organization.registeredAddress.stateOrProvince",
	"registrationAddress.address": "organization.registeredAddress.street",
	"registrationAddress.otherAddressInformation": "organization.registeredAddress.street2"
};
var businessFinancingIndividualMapping = {
	gender: "individual.birthData.genderCode",
	countryOfBirth: "individual.birthData.birthCountry"
};
var businessFinancingSoleProprietorMapping = {
	legalProceedingsDate: "soleProprietorship.dateOfInitiationOfLegalProceeding",
	legalInformationInsolvency: "soleProprietorship.statusOfLegalProceeding",
	naceCode: "soleProprietorship.economicSector"
};
var businessFinancingComponentsKeyMapping = { ...businessFinancingBaseMapping };
({ ...businessFinancingIndividualMapping });
var businessFinancingSoleProprietorComponentsKeyMapping = { ...businessFinancingSoleProprietorMapping };
var businessFinancingApiKeyMapping = { ...reverseMapping(businessFinancingBaseMapping) };
var businessFinancingIndividualApiKeyMapping = { ...reverseMapping(businessFinancingIndividualMapping) };
var businessFinancingSoleProprietorApiKeyMapping = { ...reverseMapping(businessFinancingSoleProprietorMapping) };
//#endregion
//#region src/components/EFP/mapping/mapBusinessFinancingToLegalEntity.ts
var mapBusinessFinancingToLegalEntity = (data, isIndividualOrSoleProprietor, customMapping) => {
	if (customMapping) return formatObject(data, customMapping);
	return formatObject(data, isIndividualOrSoleProprietor ? businessFinancingSoleProprietorApiKeyMapping : businessFinancingApiKeyMapping);
};
//#endregion
//#region src/components/EFP/tasks/BusinessFinancingDropin/types.ts
var BusinessFinancingPages = {
	COMPANY_PAGE: "company",
	SOLE_PROPRIETOR_PAGE: "soleProprietor",
	PARENT_COMPANY_PAGE: "parentCompany",
	ULTIMATE_PARENT_COMPANY_PAGE: "ultimateParentCompany"
};
var BusinessFinancingRadioIds = {
	YES: "Yes",
	NO: "No"
};
var businessFinancingRadioItems = [{
	id: BusinessFinancingRadioIds.YES,
	name: "yes"
}, {
	id: BusinessFinancingRadioIds.NO,
	name: "no"
}];
var businessFinancingParentRadioItems = [{
	id: BusinessFinancingRadioIds.YES,
	name: "yes"
}, {
	id: BusinessFinancingRadioIds.NO,
	name: "noIdontKnow"
}];
var companySchemaKeys = [
	"legalForm",
	"naceCode",
	"numberOfEmployees",
	"doesYourCompanyHaveLEI",
	"legalEntityIdentifier",
	"isCompanyOwnedByAnotherCompany",
	"isParentOwnedByAnotherCompany",
	"financialReportingDate",
	"currency",
	"balanceSheetTotal",
	"annualTurnover",
	"legalInformationInsolvency",
	"legalProceedingsDate"
];
var soleProprietorSchemaKeys = [
	"gender",
	"countryOfBirth",
	"naceCode",
	"legalInformationInsolvency",
	"legalProceedingsDate"
];
var parentCompaniesSchemaKeys = [
	"legalName",
	"legalForm",
	"naceCode",
	"numberOfEmployees",
	"doesYourCompanyHaveLEI",
	"legalEntityIdentifier",
	"isThisAddressTheMainHeadquarters",
	"financialReportingDate",
	"currency",
	"balanceSheetTotal",
	"annualTurnover",
	"legalInformationInsolvency",
	"legalProceedingsDate",
	"registrationAddress",
	"sameAddressAsRootEntity"
];
var businessFinancingForms = {
	company: {
		formId: "company",
		formName: "businessInformation",
		fields: [...companySchemaKeys]
	},
	soleProprietor: {
		formId: "soleProprietor",
		formName: "businessInformation",
		fields: [...soleProprietorSchemaKeys]
	},
	parentCompany: {
		formId: "parentCompany",
		formName: "parentCompanyInformation",
		fields: [...parentCompaniesSchemaKeys]
	},
	ultimateParentCompany: {
		formId: "ultimateParentCompany",
		formName: "ultimateParentCompanyInformation",
		fields: [...parentCompaniesSchemaKeys]
	}
};
var BusinessFinancingIndices = {
	COMPANY: "company",
	SOLE_PROPRIETOR: "soleProprietor",
	PARENT_COMPANY: "parentCompany",
	ULTIMATE_PARENT_COMPANY: "ultimateParentCompany"
};
//#endregion
//#region src/components/EFP/tasks/BusinessFinancingDropin/utils.ts
var getLegalEntityId = (businessFinancingIndex, rootLegalEntity) => {
	if (!rootLegalEntity) return void 0;
	if (businessFinancingIndex === BusinessFinancingIndices.COMPANY || businessFinancingIndex === BusinessFinancingIndices.SOLE_PROPRIETOR) return rootLegalEntity.id;
	if (!rootLegalEntity?.entityAssociations) return void 0;
	const businessFinancingEntityType = BusinessFinancingIndices.PARENT_COMPANY ? "immediateParentCompany" : "ultimateParentCompany";
	return (rootLegalEntity.entityAssociations?.find((entity) => entity.type === businessFinancingEntityType))?.legalEntityId;
};
var USER_LOCALE = typeof navigator !== "undefined" ? navigator.language : "en-US";
var entityHasParentCompany = (data) => data.company?.isCompanyOwnedByAnotherCompany && data.company?.isCompanyOwnedByAnotherCompany === "Yes";
var entityHasUltimateParentCompany = (data) => data.company?.isParentOwnedByAnotherCompany && data.company?.isParentOwnedByAnotherCompany === "Yes";
var financialReportsToString = (financialReports) => {
	return {
		...financialReports,
		numberOfEmployees: financialReports.numberOfEmployees ? financialReports.numberOfEmployees.toString() : void 0,
		annualTurnover: financialReports.annualTurnover ? financialReports.annualTurnover.toString() : void 0,
		balanceSheetTotal: financialReports.balanceSheetTotal ? financialReports.balanceSheetTotal.toString() : void 0
	};
};
/**
* Prepares sole proprietor business financing data for submission.
* IMPORTANT: Both root LE (individual) and sole prop LE MUST exist before calling this.
* This function always returns UPDATE payloads (with IDs), never CREATE payloads.
*/
var prepareSoleProprietorBusinessFinancingSubmitData = (data, rootLegalEntity, soleProprietorLegalEntity) => {
	const businessFinancingData = data.soleProprietor;
	if (!businessFinancingData || !rootLegalEntity?.id || !soleProprietorLegalEntity?.id) return null;
	const individualChanges = mapBusinessFinancingToLegalEntity(businessFinancingData, true, businessFinancingIndividualApiKeyMapping);
	const { identificationData: _identificationData, ...individualWithoutIdData } = rootLegalEntity.individual || {};
	const individualPayload = {
		id: rootLegalEntity.id,
		individual: {
			...individualWithoutIdData,
			...individualChanges.individual
		}
	};
	const solePropChanges = mapBusinessFinancingToLegalEntity(businessFinancingData, true, businessFinancingSoleProprietorApiKeyMapping);
	if (!solePropChanges.soleProprietorship) return null;
	if (solePropChanges.soleProprietorship.statusOfLegalProceeding === "iDontKnow") solePropChanges.soleProprietorship.statusOfLegalProceeding = "noLegalActionsTaken";
	if (solePropChanges.soleProprietorship.statusOfLegalProceeding === "iDontKnow" || solePropChanges.soleProprietorship.statusOfLegalProceeding === "noLegalActionsTaken") solePropChanges.soleProprietorship.dateOfInitiationOfLegalProceeding = "";
	return {
		individualPayload,
		solePropPayload: {
			id: soleProprietorLegalEntity.id,
			soleProprietorship: {
				...soleProprietorLegalEntity.soleProprietorship,
				...solePropChanges.soleProprietorship
			}
		}
	};
};
var prepareBusinessFinancingSubmitData = (businessFinancingIndex, data, rootLegalEntity) => {
	const businessFinancingData = data[businessFinancingIndex];
	if (!businessFinancingData) return null;
	if (businessFinancingIndex === BusinessFinancingIndices.PARENT_COMPANY && !entityHasParentCompany(data)) return null;
	if (businessFinancingIndex === BusinessFinancingIndices.ULTIMATE_PARENT_COMPANY && (!entityHasUltimateParentCompany(data) || !entityHasParentCompany(data))) return null;
	const businessFinancingDetails = mapBusinessFinancingToLegalEntity(businessFinancingData);
	const isSoleProprietor = businessFinancingIndex === BusinessFinancingIndices.SOLE_PROPRIETOR;
	if (isSoleProprietor) throw new Error("Use prepareSoleProprietorBusinessFinancingSubmitData for sole proprietor business financing");
	else if (isSoleProprietor === false) {
		if (!businessFinancingDetails.organization) return null;
		const businessFinancingCountry = businessFinancingDetails.organization.registeredAddress?.country || rootLegalEntity?.organization?.registeredAddress?.country;
		const companyData = businessFinancingData;
		if (companyData.financialReportingDate && isEeaCountry(businessFinancingCountry)) {
			const { balanceSheetTotal: bst, ...restFinancialReport } = mapFinancialInformationToFinancialReport({
				currency: companyData.currency,
				financialReportingDate: companyData.financialReportingDate,
				numberOfEmployees: companyData.numberOfEmployees ? Number(companyData.numberOfEmployees) : void 0,
				balanceSheetTotal: companyData.balanceSheetTotal ? Number(companyData.balanceSheetTotal) : void 0,
				annualTurnover: companyData.annualTurnover ? Number(companyData.annualTurnover) : void 0
			});
			const businessFinancingFinancialReport = {
				...restFinancialReport,
				netAssets: bst
			};
			businessFinancingDetails.organization.financialReports = [businessFinancingFinancialReport];
		}
		if (!isEeaCountry(businessFinancingCountry)) businessFinancingDetails.organization.financialReports = void 0;
		if (businessFinancingDetails.organization.statusOfLegalProceeding === "iDontKnow") businessFinancingDetails.organization.statusOfLegalProceeding = "noLegalActionsTaken";
		if (businessFinancingDetails.organization.statusOfLegalProceeding === "iDontKnow" || businessFinancingDetails.organization.statusOfLegalProceeding === "noLegalActionsTaken") businessFinancingDetails.organization.dateOfInitiationOfLegalProceeding = "";
		if (companyData.sameAddressAsRootEntity && rootLegalEntity?.organization?.registeredAddress) businessFinancingDetails.organization.registeredAddress = { ...rootLegalEntity.organization.registeredAddress };
		if (companyData.isThisAddressTheMainHeadquarters) businessFinancingDetails.organization.principalPlaceOfBusiness = { ...businessFinancingDetails.organization.registeredAddress };
		if (companyData.doesYourCompanyHaveLEI !== "Yes") delete businessFinancingDetails.organization.globalLegalEntityIdentifier;
	}
	const businessFinancingLegalEntityId = getLegalEntityId(businessFinancingIndex, rootLegalEntity);
	if (businessFinancingLegalEntityId) {
		delete businessFinancingDetails.type;
		businessFinancingDetails.id = businessFinancingLegalEntityId;
	} else {
		delete businessFinancingDetails.id;
		businessFinancingDetails.type = isSoleProprietor ? LegalEntityTypes.SOLE_PROPRIETORSHIP : LegalEntityTypes.ORGANIZATION;
	}
	return businessFinancingDetails;
};
var appendBusinessFinancingData = (legalOrganization, businessFinancingData) => {
	if (!legalOrganization || !businessFinancingData) return businessFinancingData;
	const clonedBusinessFinancingData = { ...businessFinancingData };
	let financialReportData = {};
	if (legalOrganization.financialReports) {
		financialReportData = financialReportsToString(mapFinancialReportsToFinancialInformation((Array.isArray(legalOrganization.financialReports) ? legalOrganization.financialReports : [legalOrganization.financialReports]).map(({ netAssets, ...rest }) => ({
			...rest,
			balanceSheetTotal: rest.balanceSheetTotal ?? netAssets
		})), false));
		if (financialReportData.numberOfEmployees) financialReportData.numberOfEmployees = financialReportData.numberOfEmployees.toString();
	}
	return {
		...clonedBusinessFinancingData,
		...financialReportData,
		numberOfEmployees: financialReportData.numberOfEmployees ? financialReportData.numberOfEmployees.toString() : void 0,
		doesYourCompanyHaveLEI: legalOrganization.globalLegalEntityIdentifier ? "Yes" : "No",
		isThisAddressTheMainHeadquarters: legalOrganization.principalPlaceOfBusiness ? "Yes" : clonedBusinessFinancingData.isThisAddressTheMainHeadquarters
	};
};
var appendSoleProprietorBusinessFinancingData = (legalArrangement, businessFinancingData) => {
	if (!legalArrangement || !businessFinancingData) return businessFinancingData;
	return {
		...businessFinancingData,
		naceCode: businessFinancingData.naceCode ?? legalArrangement.economicSector,
		legalInformationInsolvency: businessFinancingData.legalInformationInsolvency ?? legalArrangement.statusOfLegalProceeding,
		legalProceedingsDate: businessFinancingData.legalProceedingsDate ?? legalArrangement.dateOfInitiationOfLegalProceeding
	};
};
var handleBusinessFinancingFormSubmission = async (businessFinancingType, details, createFunction, updateFunction, entityId) => {
	if (!details) throw new Error(`Missing details for ${businessFinancingType}`);
	try {
		if (entityId) return await updateFunction({
			...details,
			id: entityId
		});
		return await createFunction(details);
	} catch (error) {
		const businessFinancingError = /* @__PURE__ */ new Error(`Form submission failed for ${businessFinancingType}`);
		businessFinancingError.actualError = error;
		businessFinancingError.businessFinancingType = businessFinancingError;
		throw businessFinancingError;
	}
};
var getCompanySchemaKeys = (country, currentData, schemaKeys) => {
	const fieldsToRemove = [];
	if (!isEeaCountry(country)) fieldsToRemove.push("financialReportingDate", "balanceSheetTotal", "annualTurnover", "currency", "numberOfEmployees");
	if (currentData.isCompanyOwnedByAnotherCompany !== "Yes") fieldsToRemove.push("isParentOwnedByAnotherCompany");
	if (currentData.doesYourCompanyHaveLEI !== "Yes") fieldsToRemove.push("legalEntityIdentifier");
	if (!currentData?.legalInformationInsolvency || ["noLegalActionsTaken", "iDontKnow"].includes(currentData?.legalInformationInsolvency)) fieldsToRemove.push("legalProceedingsDate");
	return schemaKeys.filter((field) => !fieldsToRemove.includes(field));
};
var getSoleProprietorSchemaKeys = (currentData, schemaKeys) => {
	const fieldsToRemove = [];
	if (!currentData?.legalInformationInsolvency || ["noLegalActionsTaken", "iDontKnow"].includes(currentData?.legalInformationInsolvency)) fieldsToRemove.push("legalProceedingsDate");
	return schemaKeys.filter((field) => !fieldsToRemove.includes(field));
};
var getParentCompanySchemaKeys = (currentData, schemaKeys, rootEntityAddress) => {
	const fieldsToRemove = [];
	if (!isEeaCountry(currentData?.sameAddressAsRootEntity && rootEntityAddress ? rootEntityAddress.country : currentData?.registrationAddress?.country)) fieldsToRemove.push("financialReportingDate", "balanceSheetTotal", "annualTurnover", "currency", "numberOfEmployees");
	if (currentData?.sameAddressAsRootEntity) fieldsToRemove.push("registrationAddress");
	if (currentData.doesYourCompanyHaveLEI !== "Yes") fieldsToRemove.push("legalEntityIdentifier");
	if (!currentData?.legalInformationInsolvency || ["noLegalActionsTaken", "iDontKnow"].includes(currentData?.legalInformationInsolvency)) fieldsToRemove.push("legalProceedingsDate");
	return schemaKeys.filter((field) => !fieldsToRemove.includes(field));
};
var getBusinessFinancingRequiredFields = (country, data, rootEntityAddress) => {
	let requiredFields = void 0;
	if (!data) return requiredFields;
	const { company, soleProprietor, parentCompany = {}, ultimateParentCompany = {} } = data;
	if (soleProprietor) {
		requiredFields = {};
		requiredFields.soleProprietor = getSoleProprietorSchemaKeys(soleProprietor, soleProprietorSchemaKeys);
		delete requiredFields.company;
		return requiredFields;
	}
	if (company) {
		requiredFields = {};
		requiredFields.company = getCompanySchemaKeys(country, company, companySchemaKeys);
	}
	if (company?.isCompanyOwnedByAnotherCompany === "Yes") {
		const parentCompanyRequiredFields = getParentCompanySchemaKeys(parentCompany, parentCompaniesSchemaKeys, rootEntityAddress);
		requiredFields = {
			...requiredFields,
			parentCompany: parentCompanyRequiredFields
		};
	}
	if (company?.isParentOwnedByAnotherCompany === "Yes") {
		const ultimateParentCompanyRequiredFields = getParentCompanySchemaKeys(ultimateParentCompany, parentCompaniesSchemaKeys, rootEntityAddress);
		requiredFields = {
			...requiredFields,
			ultimateParentCompany: ultimateParentCompanyRequiredFields
		};
	}
	return requiredFields;
};
var getAddressCountryForParentCompany = (parentCompany, leAddress) => {
	return parentCompany?.sameAddressAsRootEntity && leAddress ? leAddress?.country : parentCompany?.registrationAddress?.country;
};
//#endregion
//#region src/components/EmbeddedDropins/BusinessFinancingComponent/utils.ts
var getTranslatedGender = (t, gender) => {
	if (!gender) return void 0;
	const key = {
		M: "male",
		F: "female",
		U: "preferNotToSay"
	}[gender];
	return key ? t(($) => $[key]) : gender;
};
var getTranslatedLegalInsolvency = (t, insolvencyData) => {
	if (!insolvencyData) return void 0;
	return insolvencyData === "noLegalActionsTaken" ? t(($) => $["no"]) : t(($) => $[insolvencyData]);
};
var getValidUserLocale = (locale) => {
	try {
		new Intl.NumberFormat(locale);
		return locale;
	} catch (error) {
		console.warn(`Invalid locale '${locale}' provided. Falling back to 'en-US'.`, error);
		return "en-US";
	}
};
var getFormattedAmount = (value, currency) => {
	if (!value) return void 0;
	const userLocale = getValidUserLocale(USER_LOCALE);
	return `${currency} ${Number(value).toLocaleString(userLocale)}`;
};
var formatDataForSummary = (language, t, datasetUtils, data, rootLeAddress) => {
	const summaryData = cloneObject(data) || {};
	const { company, parentCompany, ultimateParentCompany, soleProprietor } = summaryData;
	if (soleProprietor) {
		soleProprietor.naceCode = soleProprietor.naceCodeLabel;
		soleProprietor.countryOfBirth = soleProprietor.countryOfBirth ? datasetUtils.getCountryName(soleProprietor.countryOfBirth) ?? void 0 : void 0;
		soleProprietor.legalInformationInsolvency = getTranslatedLegalInsolvency(t, soleProprietor.legalInformationInsolvency);
		soleProprietor.legalProceedingsDate = soleProprietor.legalProceedingsDate ? localizeDateString(soleProprietor.legalProceedingsDate, language) : void 0;
		if (soleProprietor.gender) soleProprietor.gender = getTranslatedGender(t, soleProprietor.gender);
	}
	if (company) {
		company.legalForm = company.legalFormLabel;
		company.naceCode = company.naceCodeLabel;
		company.legalEntityIdentifier = company.legalEntityIdentifier ?? "None";
		company.legalInformationInsolvency = getTranslatedLegalInsolvency(t, company?.legalInformationInsolvency);
		company.annualTurnover = getFormattedAmount(company.annualTurnover, company.currency);
		company.balanceSheetTotal = getFormattedAmount(company.balanceSheetTotal, company.currency);
		const { legalProceedingsDate, financialReportingDate } = company;
		company.legalProceedingsDate = legalProceedingsDate ? localizeDateString(legalProceedingsDate, language) : void 0;
		company.financialReportingDate = financialReportingDate ? localizeDateString(financialReportingDate, language) : void 0;
	}
	if (parentCompany) {
		const { legalName, legalFormLabel, naceCodeLabel, country, legalEntityIdentifier, legalInformationInsolvency, annualTurnover, currency, balanceSheetTotal, legalProceedingsDate, financialReportingDate, sameAddressAsRootEntity, registrationAddress } = parentCompany;
		if (legalName) {
			parentCompany.legalForm = legalFormLabel;
			parentCompany.naceCode = naceCodeLabel;
			parentCompany.country = country ? datasetUtils.getCountryName(country) : "";
			if (registrationAddress) parentCompany.registrationAddress = {
				...registrationAddress,
				country: datasetUtils.getCountryName(registrationAddress?.country)
			};
			parentCompany.legalEntityIdentifier = legalEntityIdentifier ?? "None";
			parentCompany.legalInformationInsolvency = getTranslatedLegalInsolvency(t, legalInformationInsolvency);
			parentCompany.annualTurnover = getFormattedAmount(annualTurnover, currency);
			parentCompany.balanceSheetTotal = getFormattedAmount(balanceSheetTotal, currency);
			parentCompany.legalProceedingsDate = legalProceedingsDate ? localizeDateString(legalProceedingsDate, language) : void 0;
			parentCompany.financialReportingDate = financialReportingDate ? localizeDateString(financialReportingDate, language) : void 0;
			if (sameAddressAsRootEntity) {
				delete parentCompany.country;
				summaryData.parentCompany = {
					...parentCompany,
					registrationAddress: {
						...rootLeAddress,
						country: datasetUtils.getCountryName(rootLeAddress?.country)
					}
				};
			}
		}
	}
	if (ultimateParentCompany) {
		const { legalName, legalFormLabel, naceCodeLabel, country, legalEntityIdentifier, legalInformationInsolvency, annualTurnover, currency, balanceSheetTotal, legalProceedingsDate, financialReportingDate, sameAddressAsRootEntity, registrationAddress } = ultimateParentCompany;
		if (legalName) {
			ultimateParentCompany.legalForm = legalFormLabel;
			ultimateParentCompany.naceCode = naceCodeLabel;
			ultimateParentCompany.country = country ? datasetUtils.getCountryName(country) : "";
			if (registrationAddress) ultimateParentCompany.registrationAddress = {
				...registrationAddress,
				country: datasetUtils.getCountryName(registrationAddress?.country)
			};
			ultimateParentCompany.legalEntityIdentifier = legalEntityIdentifier ?? "None";
			ultimateParentCompany.legalInformationInsolvency = getTranslatedLegalInsolvency(t, legalInformationInsolvency);
			ultimateParentCompany.annualTurnover = getFormattedAmount(annualTurnover, currency);
			ultimateParentCompany.balanceSheetTotal = getFormattedAmount(balanceSheetTotal, currency);
			ultimateParentCompany.legalProceedingsDate = legalProceedingsDate ? localizeDateString(legalProceedingsDate, language) : void 0;
			ultimateParentCompany.financialReportingDate = financialReportingDate ? localizeDateString(financialReportingDate, language) : void 0;
			if (sameAddressAsRootEntity) {
				delete ultimateParentCompany.country;
				summaryData.ultimateParentCompany = {
					...ultimateParentCompany,
					registrationAddress: {
						...rootLeAddress,
						country: datasetUtils.getCountryName(rootLeAddress?.country)
					}
				};
			}
		}
	}
	return summaryData;
};
//#endregion
//#region src/components/EFP/mapping/mapLegalEntityToBusinessFinancing.ts
var mapLegalEntityToBusinessFinancing = (legalEntity) => {
	if (legalEntity.type === LegalEntityTypes.SOLE_PROPRIETORSHIP) return formatObject(legalEntity, businessFinancingSoleProprietorComponentsKeyMapping);
	if (legalEntity.type === LegalEntityTypes.INDIVIDUAL) {
		if (legalEntity.entityAssociations?.find((ea) => ea.entityType === LegalEntityTypes.SOLE_PROPRIETORSHIP && ea.associatorId === legalEntity.id)) {
			const solePropMapped = formatObject(legalEntity, businessFinancingSoleProprietorComponentsKeyMapping);
			const birthData = legalEntity.individual?.birthData;
			return {
				...solePropMapped,
				gender: birthData?.genderCode || legalEntity.individual?.gender,
				countryOfBirth: birthData?.birthCountry || legalEntity.individual?.countryOfBirth
			};
		}
	}
	return formatObject(legalEntity, businessFinancingComponentsKeyMapping);
};
//#endregion
//#region src/api/datasets/useNaceCodes.ts
var getNaceCodes = async (baseUrl) => {
	return httpGet({
		baseUrl,
		path: `datasets/naceCodes`
	});
};
var useNaceCodes = (options) => {
	const { baseUrl } = useApiContext();
	return useQuery({
		queryKey: ["naceCodes"],
		queryFn: () => getNaceCodes(baseUrl.value),
		...options
	});
};
//#endregion
//#region src/components/EFP/fields/NaceCodeField/NaceCodeField.tsx
function NaceCodeField({ name = "naceCode", data, valid, errorMessage, label, readonly, handleChangeFor }) {
	const { t: commonT } = useTranslation("common");
	const { data: naceCodesData } = useNaceCodes();
	const handleChangeForRef = useRef(handleChangeFor);
	useEffect(() => {
		handleChangeForRef.current = handleChangeFor;
	}, [handleChangeFor]);
	const handleChangeForNaceCode = (e) => {
		const naceCodeEvent = { target: {
			name: "naceCode",
			value: e.target.value
		} };
		handleChangeFor("naceCode")(naceCodeEvent);
	};
	useEffect(() => {
		const naceCodeEvent = { target: {
			name: "naceCodeLabel",
			value: naceCodesData?.find((naceCode) => naceCode.id === data.naceCode)?.name
		} };
		handleChangeForRef.current("naceCodeLabel")(naceCodeEvent);
	}, [data.naceCode, naceCodesData]);
	return /* @__PURE__ */ jsx(Field, {
		name,
		label,
		errorMessage,
		isValid: valid.naceCode,
		children: (childProps) => /* @__PURE__ */ jsx(Select, {
			...childProps,
			name,
			placeholder: commonT(($) => $["selectOne"]),
			selected: data.naceCode,
			items: naceCodesData ?? [],
			readonly: readonly && !!data,
			onChange: handleChangeForNaceCode
		})
	});
}
var BusinessFinancing_module_default = {
	"business-financing-lei-radio": "adyen-kyc-business-financing-lei-radio",
	businessFinancingLeiRadio: "adyen-kyc-business-financing-lei-radio",
	"business-financing-title": "adyen-kyc-business-financing-title",
	businessFinancingTitle: "adyen-kyc-business-financing-title",
	"business-financing-body": "adyen-kyc-business-financing-body",
	businessFinancingBody: "adyen-kyc-business-financing-body",
	"business-financing-exposure-financials": "adyen-kyc-business-financing-exposure-financials",
	businessFinancingExposureFinancials: "adyen-kyc-business-financing-exposure-financials",
	"business-financing-structured-address": "adyen-kyc-business-financing-structured-address",
	businessFinancingStructuredAddress: "adyen-kyc-business-financing-structured-address"
};
//#endregion
//#region src/components/EFP/tasks/BusinessFinancingDropin/BusinessFinancingBusinessInformation.tsx
var businessInformationFields = [
	"legalForm",
	"naceCode",
	"naceCodeLabel",
	"legalFormLabel",
	"doesYourCompanyHaveLEI",
	"legalEntityIdentifier"
];
function BusinessFinancingBusinessInformation(props) {
	const { data, valid, errors, country, handleFieldChange, fieldValidationErrors, targetPage, sectionHeading, hideSectionHeading, isSoleProprietor } = props;
	const { t: businessFinancingT } = useTranslation("businessFinancing");
	const { t: commonT } = useTranslation("common");
	const formUtils = createFormUtils(props, commonT);
	if (!handleFieldChange) return;
	const isMainCompany = targetPage === BusinessFinancingPages.COMPANY_PAGE;
	return /* @__PURE__ */ jsxs(Fragment, { children: [
		!hideSectionHeading && /* @__PURE__ */ jsx(Typography, {
			el: "h3",
			variant: "title",
			className: BusinessFinancing_module_default.businessFinancingTitle,
			children: sectionHeading ? businessFinancingT(($) => $[sectionHeading]) : businessFinancingT(($) => $["businessInformation"])
		}),
		!isSoleProprietor && /* @__PURE__ */ jsx(LegalFormField, {
			name: "legalForm",
			countryCode: country,
			data: { legalForm: data?.legalForm },
			valid: { legalForm: valid?.legalForm },
			errorMessage: formUtils.getErrorMessage("legalForm", errors, fieldValidationErrors),
			handleChangeFor: handleFieldChange,
			readonly: false,
			label: businessFinancingT(($) => $["businessStructure"])
		}),
		/* @__PURE__ */ jsx(NaceCodeField, {
			name: "naceCode",
			data: { naceCode: data?.naceCode },
			valid: { naceCode: valid?.naceCode },
			errorMessage: formUtils.getErrorMessage("naceCode", errors, fieldValidationErrors),
			handleChangeFor: handleFieldChange,
			readonly: false,
			label: businessFinancingT(($) => $["industryAndNaceCode"])
		}),
		!isSoleProprietor && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Field, {
			el: "fieldset",
			name: "doesYourCompanyHaveLEI",
			label: businessFinancingT(($) => $[isMainCompany ? "doesYourCompanyHaveLEI" : "doesThisCompanyHaveLEI"]),
			helper: /* @__PURE__ */ jsxs(Typography, {
				el: "div",
				variant: "body",
				color: "secondary",
				className: BusinessFinancing_module_default.businessFinancingBody,
				children: [
					businessFinancingT(($) => $["anLEIIsAUniqueCode"]),
					" ",
					/* @__PURE__ */ jsx(Link, {
						href: "https://search.gleif.org/#/search/",
						external: true,
						inline: true,
						children: businessFinancingT(($) => $["lookUpYourLEI"])
					})
				]
			}),
			errorMessage: formUtils.getErrorMessage("doesYourCompanyHaveLEI", errors, fieldValidationErrors),
			children: (childProps) => /* @__PURE__ */ jsx(RadioGroup, {
				...childProps,
				name: "doesYourCompanyHaveLEI",
				items: isMainCompany ? businessFinancingRadioItems : businessFinancingParentRadioItems,
				value: data?.doesYourCompanyHaveLEI,
				disabled: false,
				className: BusinessFinancing_module_default.businessFinancingLeiRadio,
				onChange: handleFieldChange("doesYourCompanyHaveLEI"),
				"aria-required": true,
				"aria-invalid": !valid?.doesYourCompanyHaveLEI
			})
		}), data?.doesYourCompanyHaveLEI === "Yes" && /* @__PURE__ */ jsx(Field, {
			name: "legalEntityIdentifier",
			label: businessFinancingT(($) => $["legalEntityIdentifier"]),
			errorMessage: formUtils.getErrorMessage("legalEntityIdentifier", errors, fieldValidationErrors),
			isValid: valid?.legalEntityIdentifier,
			helper: commonT(($) => $["enterNCharactersWithAMixForExample"], {
				numChars: 20,
				example: "529900T8BM49AURSDO55"
			}),
			children: (childProps) => /* @__PURE__ */ jsx(InputText, {
				...childProps,
				name: "legalEntityIdentifier",
				value: data?.legalEntityIdentifier,
				readonly: false,
				onInput: handleFieldChange("legalEntityIdentifier", "input"),
				onBlur: handleFieldChange("legalEntityIdentifier", "blur"),
				"aria-required": true,
				"aria-invalid": !valid?.legalEntityIdentifier,
				isValid: valid?.legalEntityIdentifier
			})
		})] })
	] });
}
//#endregion
//#region src/components/EFP/tasks/BusinessFinancingDropin/BusinessFinancingFinancialInformation.tsx
var TODAY_DATE$1 = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
var financialInformationFields = [
	"numberOfEmployees",
	"financialReportingDate",
	"legalEntityIdentifier",
	"currency",
	"balanceSheetTotal",
	"annualTurnover"
];
function BusinessFinancingFinancialInformation(props) {
	const { data, valid, errors, country, sectionHeading, handleFieldChange, fieldValidationErrors } = props;
	const { t: businessFinancingT, i18n: i18next } = useTranslation("businessFinancing");
	const { t: commonT } = useTranslation("common");
	const formUtils = createFormUtils(props, commonT);
	const currenciesForCurrCountry = useMemo(() => currencyByCountry[country] ?? [], [country]);
	if (!handleFieldChange) return;
	const financialData = data;
	const financialErrors = errors;
	const isFinancialDataValid = valid;
	const [firstCurrency] = currenciesForCurrCountry;
	const defaultCurrency = firstCurrency ?? "EUR";
	if (currenciesForCurrCountry.length === 1 && data?.currency !== firstCurrency) handleFieldChange("currency")(firstCurrency);
	return /* @__PURE__ */ jsxs("section", { children: [
		/* @__PURE__ */ jsx(Typography, {
			el: "h3",
			variant: "title",
			className: BusinessFinancing_module_default.businessFinancingTitle,
			children: sectionHeading ? businessFinancingT(($) => $[sectionHeading]) : businessFinancingT(($) => $["businessFinancials"])
		}),
		/* @__PURE__ */ jsx(Field, {
			name: "numberOfEmployees",
			label: businessFinancingT(($) => $["numberOfEmployees"]),
			helper: businessFinancingT(($) => $["theNumberOfIndividualsReceivingAWageOrSalary"]),
			errorMessage: formUtils.getErrorMessage("numberOfEmployees", errors, fieldValidationErrors),
			isValid: valid?.numberOfEmployees,
			children: (childProps) => /* @__PURE__ */ jsx(InputNumber, {
				...childProps,
				"aria-required": true,
				"aria-invalid": !valid?.numberOfEmployees,
				name: "numberOfEmployees",
				min: "0",
				step: "1",
				value: data?.numberOfEmployees,
				onInput: handleFieldChange("numberOfEmployees", "input"),
				onBlur: handleFieldChange("numberOfEmployees", "blur")
			})
		}),
		currenciesForCurrCountry?.length > 1 && /* @__PURE__ */ jsx(Currency, {
			country,
			data: formUtils.getFieldData(financialData, CURRENCY_FIELD),
			errors: formUtils.getFieldErrors(financialErrors, fieldValidationErrors, CURRENCY_FIELD),
			handleChangeFor: handleFieldChange,
			labels: { currency: businessFinancingT(($) => $["financialStatementReportingCurrency"]) },
			readonly: formUtils.isReadOnly("currency"),
			valid: formUtils.getFieldValid(isFinancialDataValid, CURRENCY_FIELD)
		}),
		/* @__PURE__ */ jsxs("div", {
			className: BusinessFinancing_module_default.businessFinancingExposureFinancials,
			children: [
				/* @__PURE__ */ jsx(Field, {
					name: "balanceSheetTotal",
					label: businessFinancingT(($) => $["balanceSheetTotal"]),
					helper: businessFinancingT(($) => $["theSumOfTotalLiabilities"]),
					errorMessage: formUtils.getErrorMessage("balanceSheetTotal", errors, fieldValidationErrors),
					isValid: valid?.balanceSheetTotal,
					children: (childProps) => /* @__PURE__ */ jsx(InputCurrency, {
						...childProps,
						"aria-required": formUtils.isRequiredField("balanceSheetTotal"),
						"aria-invalid": !valid?.balanceSheetTotal,
						locale: i18next.language,
						currency: data?.currency ?? defaultCurrency,
						amount: data?.balanceSheetTotal ? Number(data?.balanceSheetTotal) : void 0,
						onAmountChanged: handleFieldChange("balanceSheetTotal")
					})
				}),
				/* @__PURE__ */ jsx(Field, {
					name: "financialReportingDate",
					label: businessFinancingT(($) => $["statementReportingDate"]),
					helper: businessFinancingT(($) => $["useTheMoreRecentOfTheReportingDates"]),
					errorMessage: formUtils.getErrorMessage("financialReportingDate", errors, fieldValidationErrors),
					isValid: valid?.financialReportingDate,
					children: (childProps) => /* @__PURE__ */ jsx(InputDate, {
						...childProps,
						name: "financialReportingDate",
						value: data?.financialReportingDate,
						onInput: handleFieldChange("financialReportingDate", "input"),
						onBlur: handleFieldChange("financialReportingDate", "blur"),
						"aria-required": true,
						"aria-invalid": !valid?.financialReportingDate,
						max: TODAY_DATE$1
					})
				}),
				/* @__PURE__ */ jsx(Field, {
					name: "annualTurnover",
					label: businessFinancingT(($) => $["annualTurnover"]),
					helper: businessFinancingT(($) => $["theAnnualSalesRevenue"]),
					errorMessage: formUtils.getErrorMessage("annualTurnover", errors, fieldValidationErrors),
					isValid: valid?.annualTurnover,
					children: (childProps) => /* @__PURE__ */ jsx(InputCurrency, {
						...childProps,
						name: "annualTurnover",
						"aria-required": formUtils.isRequiredField("annualTurnover"),
						"aria-invalid": !valid?.annualTurnover,
						locale: i18next.language,
						currency: data?.currency ?? defaultCurrency,
						amount: data?.annualTurnover ? Number(data?.annualTurnover) : void 0,
						onAmountChanged: handleFieldChange("annualTurnover")
					})
				})
			]
		})
	] });
}
//#endregion
//#region src/components/EFP/tasks/BusinessFinancingDropin/BusinessFinancingLegalInformation.tsx
var TODAY_DATE = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
var legalInformationFields = ["legalInformationInsolvency", "legalProceedingsDate"];
function BusinessFinancingLegalInformation(props) {
	const { data, valid, errors, fieldValidationErrors, handleFieldChange, sectionHeading } = props;
	const { t: businessFinancingT } = useTranslation("businessFinancing");
	const { t: commonT } = useTranslation("common");
	const formUtils = createFormUtils(props, commonT);
	if (!handleFieldChange) return;
	const legalInformationInsolvencyItems = [
		{
			id: "noLegalActionsTaken",
			name: commonT(($) => $["no"])
		},
		{
			id: "underJudicialAdministration",
			name: businessFinancingT(($) => $["yesTheCompanyIsUnderJudicialAdministration"])
		},
		{
			id: "bankruptcyInsolvency",
			name: businessFinancingT(($) => $["yesTheCompanyIsFilingForBankruptcy"])
		},
		{
			id: "otherLegalMeasures",
			name: businessFinancingT(($) => $["yesTheCompanyIsFacingOtherLegalMeasures"])
		},
		{
			id: "iDontKnow",
			name: commonT(($) => $["iDontKnow"])
		}
	];
	const showLegalProceedingsDateField = data?.legalInformationInsolvency && !["noLegalActionsTaken", "iDontKnow"].includes(data?.legalInformationInsolvency);
	return /* @__PURE__ */ jsxs(Fragment, { children: [
		/* @__PURE__ */ jsx(Typography, {
			el: "h3",
			variant: "title",
			className: BusinessFinancing_module_default.businessFinancingTitle,
			children: sectionHeading ? businessFinancingT(($) => $[sectionHeading]) : businessFinancingT(($) => $["legalInformation"])
		}),
		/* @__PURE__ */ jsx(Field, {
			name: "legalInformationInsolvency",
			label: businessFinancingT(($) => $["legalInformationInsolvency"]),
			errorMessage: formUtils.getErrorMessage("legalInformationInsolvency", errors, fieldValidationErrors),
			isValid: valid?.legalInformationInsolvency,
			children: (childProps) => /* @__PURE__ */ jsx(Select, {
				...childProps,
				onChange: handleFieldChange("legalInformationInsolvency", "blur"),
				name: "legalInformationInsolvency",
				placeholder: commonT(($) => $["selectOne"]),
				selected: data?.legalInformationInsolvency,
				items: legalInformationInsolvencyItems,
				"aria-required": true,
				"aria-invalid": !valid?.legalInformationInsolvency
			})
		}),
		showLegalProceedingsDateField && /* @__PURE__ */ jsx(Field, {
			name: "legalProceedingsDate",
			label: businessFinancingT(($) => $["legalProceedingsDate"]),
			errorMessage: formUtils.getErrorMessage("legalProceedingsDate", errors, fieldValidationErrors),
			isValid: valid?.legalProceedingsDate,
			children: (childProps) => /* @__PURE__ */ jsx(InputDate, {
				...childProps,
				name: "legalProceedingsDate",
				value: data.legalProceedingsDate,
				onInput: handleFieldChange("legalProceedingsDate", "input"),
				onBlur: handleFieldChange("legalProceedingsDate", "blur"),
				"aria-required": true,
				"aria-invalid": !valid?.legalProceedingsDate,
				max: TODAY_DATE
			})
		})
	] });
}
//#endregion
//#region src/components/EFP/tasks/BusinessFinancingDropin/BusinessFinancingOwnershipStructure.tsx
var ownershipStructureFields = ["isCompanyOwnedByAnotherCompany", "isParentOwnedByAnotherCompany"];
function BusinessFinancingOwnershipStructure(props) {
	const { data, valid, errors = {}, legalEntity, fieldValidationErrors, handleFieldChange } = props;
	const { t: businessFinancingT } = useTranslation("businessFinancing");
	const { t: commonT } = useTranslation("common");
	const formUtils = createFormUtils(props, commonT);
	if (!handleFieldChange) return;
	return /* @__PURE__ */ jsxs(Fragment, { children: [
		/* @__PURE__ */ jsx(Typography, {
			el: "h3",
			variant: "title",
			className: BusinessFinancing_module_default.businessFinancingTitle,
			children: businessFinancingT(($) => $["ownershipStructure"])
		}),
		/* @__PURE__ */ jsx(Field, {
			el: "fieldset",
			name: "isCompanyOwnedByAnotherCompany",
			label: businessFinancingT(($) => $["isCompanyOwnedByAnotherCompany"], { company: legalEntity?.organization ? legalEntity.organization.legalName : "" }),
			errorMessage: formUtils.getErrorMessage("isCompanyOwnedByAnotherCompany", errors, fieldValidationErrors),
			helper: /* @__PURE__ */ jsx(Typography, {
				el: "div",
				variant: "body",
				color: "secondary",
				className: BusinessFinancing_module_default.businessFinancingBody,
				children: businessFinancingT(($) => $["thisMeansYouHaveAParentCompany"])
			}),
			children: (childProps) => /* @__PURE__ */ jsx(RadioGroup, {
				...childProps,
				name: "isCompanyOwnedByAnotherCompany",
				items: businessFinancingRadioItems,
				value: data?.isCompanyOwnedByAnotherCompany,
				className: BusinessFinancing_module_default.businessFinancingLeiRadio,
				disabled: false,
				onChange: handleFieldChange("isCompanyOwnedByAnotherCompany"),
				"aria-required": true,
				"aria-invalid": !valid?.isCompanyOwnedByAnotherCompany
			})
		}),
		data?.isCompanyOwnedByAnotherCompany === "Yes" && /* @__PURE__ */ jsx(Field, {
			el: "fieldset",
			name: "isParentOwnedByAnotherCompany",
			label: businessFinancingT(($) => $["isParentOwnedByAnotherCompany"]),
			helper: /* @__PURE__ */ jsx(Typography, {
				el: "div",
				variant: "body",
				color: "secondary",
				className: BusinessFinancing_module_default.businessFinancingBody,
				children: businessFinancingT(($) => $["thisMeansYouHaveAnUltimateParentCompany"])
			}),
			errorMessage: formUtils.getErrorMessage("isParentOwnedByAnotherCompany", errors, fieldValidationErrors),
			children: (childProps) => /* @__PURE__ */ jsx(RadioGroup, {
				...childProps,
				name: "isParentOwnedByAnotherCompany",
				items: businessFinancingRadioItems,
				value: data.isParentOwnedByAnotherCompany,
				className: BusinessFinancing_module_default.businessFinancingLeiRadio,
				disabled: false,
				onChange: handleFieldChange("isParentOwnedByAnotherCompany"),
				"aria-required": true,
				"aria-invalid": !valid?.isParentOwnedByAnotherCompany
			})
		})
	] });
}
//#endregion
//#region src/components/EFP/tasks/BusinessFinancingDropin/AdditionalFieldsForBusinessFinancingCompany.tsx
function AdditionalFieldsForBusinessFinancingCompany(props) {
	const { t: businessFinancingT } = useTranslation("businessFinancing");
	const { t: commonT } = useTranslation("common");
	const { form: { handleChangeFor, data, setValid } } = useFormContext();
	const { country, formVerificationErrors, legalEntity, fieldValidationErrors } = props;
	const formUtils = createFormUtils(props, commonT);
	const handleChange = (fieldName, mode) => handleChangeFor(fieldName, "company", mode);
	const ownershipStructureProps = getFieldProps(props, ownershipStructureFields);
	const businessInformationProps = getFieldProps(props, businessInformationFields);
	const financialInformationProps = getFieldProps(props, financialInformationFields);
	const legalInformationProps = getFieldProps(props, legalInformationFields);
	if ((currencyByCountry[country] ?? [])?.length === 1) setValid("currency", true, "company");
	return /* @__PURE__ */ jsxs("form", {
		"data-testid": "businessFinancingCompany",
		children: [
			/* @__PURE__ */ jsx(Header, {
				title: businessFinancingT(($) => $["additionalInformationForBusinessFinancing"]),
				description: businessFinancingT(($) => $["weNeedAFewMoreDetailsAboutYouAndYourBusiness"]),
				secondary: true
			}),
			/* @__PURE__ */ jsx(ErrorPanel, {
				verificationErrors: formVerificationErrors,
				validationErrors: fieldValidationErrors,
				formUtils,
				id: "ariaErrorField"
			}),
			/* @__PURE__ */ jsx(BusinessFinancingBusinessInformation, {
				...businessInformationProps,
				handleFieldChange: handleChange,
				country,
				targetPage: BusinessFinancingPages.COMPANY_PAGE,
				sectionHeading: "businessInformation",
				data: formUtils.getFieldData(data?.company ?? {}, businessInformationFields)
			}),
			isEeaCountry(country) && /* @__PURE__ */ jsx(BusinessFinancingFinancialInformation, {
				...financialInformationProps,
				handleFieldChange: handleChange,
				country,
				targetPage: BusinessFinancingPages.COMPANY_PAGE,
				data: formUtils.getFieldData(data?.company ?? {}, financialInformationFields)
			}),
			/* @__PURE__ */ jsx(BusinessFinancingLegalInformation, {
				...legalInformationProps,
				country,
				handleFieldChange: handleChange,
				targetPage: BusinessFinancingPages.COMPANY_PAGE,
				sectionHeading: "legalInformation",
				data: formUtils.getFieldData(data?.company ?? {}, legalInformationFields)
			}),
			/* @__PURE__ */ jsx(BusinessFinancingOwnershipStructure, {
				...ownershipStructureProps,
				legalEntity,
				handleFieldChange: handleChange,
				data: formUtils.getFieldData(data?.company ?? {}, ownershipStructureFields)
			})
		]
	});
}
//#endregion
//#region src/components/EFP/tasks/BusinessFinancingDropin/BusinessFinancingBasicCompanyInformation.tsx
var basicInformationFields = ["legalName"];
function BusinessFinancingBasicCompanyInformation(props) {
	const { data, valid, errors, fieldValidationErrors, handleFieldChange, sectionHeading } = props;
	const { t: businessFinancingT } = useTranslation("businessFinancing");
	const { t: commonT } = useTranslation("common");
	const formUtils = createFormUtils(props, commonT);
	if (!handleFieldChange) return;
	return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Typography, {
		el: "h3",
		variant: "title",
		className: BusinessFinancing_module_default.businessFinancingTitle,
		children: sectionHeading ? businessFinancingT(($) => $[sectionHeading]) : businessFinancingT(($) => $["basicCompanyInformation"])
	}), /* @__PURE__ */ jsx(Field, {
		name: "legalName",
		label: businessFinancingT(($) => $["legalName"]),
		errorMessage: formUtils.getErrorMessage("legalName", errors, fieldValidationErrors),
		isValid: valid?.legalName,
		helper: businessFinancingT(($) => $["legalNameIsUsedToIdentifyABusinessWithTheGovernment"]),
		helperPosition: "below",
		children: (childProps) => /* @__PURE__ */ jsx(InputText, {
			...childProps,
			name: "legalName",
			value: data?.legalName,
			readonly: false,
			onInput: handleFieldChange("legalName", "input"),
			onBlur: handleFieldChange("legalName", "blur"),
			"aria-required": true,
			"aria-invalid": !valid?.legalName
		})
	})] });
}
//#endregion
//#region src/components/EFP/tasks/BusinessFinancingDropin/BusinessFinancingRegisteredAddress.tsx
var OPTIONAL_ADDRESS_FIELDS = ["otherAddressInformation"];
var registeredAddressFields = [
	"isThisAddressTheMainHeadquarters",
	"registrationAddress",
	"sameAddressAsRootEntity"
];
function BusinessFinancingRegisteredAddress(props) {
	const { data, valid, errors, fieldValidationErrors, shouldValidate, defaultData, handleFieldChange, formId, legalEntity, sectionHeading } = props;
	const { t: businessFinancingT, i18n } = useTranslation("businessFinancing");
	const { t: commonT } = useTranslation("common");
	const formUtils = createFormUtils(props, commonT);
	const addressCountry = data?.registrationAddress?.country;
	const datasetUtils = datasetUtilities(i18n.language);
	const addressSchema = useMemo(() => {
		return getAddressSchemaForCountry(addressCountry).filter((field) => {
			if (addressCountry) return !COUNTRIES_WITH_STATES_DATASET.includes(addressCountry) ? field !== "stateOrProvince" : true;
			return true;
		});
	}, [addressCountry]);
	if (!handleFieldChange) return;
	const handleRegistrationAddressChange = (state) => {
		if (!state.data.country) state.data.country = addressCountry;
		handleFieldChange("registrationAddress")(state.data);
	};
	return /* @__PURE__ */ jsxs(Fragment, { children: [
		/* @__PURE__ */ jsx(Typography, {
			el: "h3",
			variant: "title",
			className: BusinessFinancing_module_default.businessFinancingTitle,
			children: sectionHeading ? translateTranslatable(commonT, sectionHeading) : commonT(($) => $["registeredAddress"])
		}),
		/* @__PURE__ */ jsx(Field, {
			name: "sameAddressAsRootEntity",
			errorMessage: errors?.sameAddressAsRootEntity?.errorMessage,
			isValid: valid?.sameAddressAsRootEntity,
			children: (childProps) => /* @__PURE__ */ jsx(Checkbox, {
				...childProps,
				"aria-required": formUtils.isRequiredField("sameAddressAsRootEntity"),
				"aria-invalid": !valid?.sameAddressAsRootEntity,
				name: "sameAddressAsRootEntity",
				label: businessFinancingT(($) => $["sameAddressAsRootEntity"], { rootLegalEntityName: legalEntity?.organization?.legalName ?? "" }),
				checked: data?.sameAddressAsRootEntity ?? false,
				onChange: handleFieldChange("sameAddressAsRootEntity")
			})
		}),
		data?.sameAddressAsRootEntity && legalEntity?.organization?.registeredAddress ? /* @__PURE__ */ jsxs("div", {
			className: BusinessFinancing_module_default.businessFinancingStructuredAddress,
			children: [
				/* @__PURE__ */ jsx("div", { children: legalEntity.organization.registeredAddress.street }),
				/* @__PURE__ */ jsx("div", { children: legalEntity.organization.registeredAddress.street2 }),
				/* @__PURE__ */ jsxs("div", { children: [
					legalEntity.organization.registeredAddress.city,
					" ",
					legalEntity.organization.registeredAddress.postalCode ? `, ${legalEntity.organization.registeredAddress.postalCode}` : ""
				] }),
				/* @__PURE__ */ jsx("div", { children: legalEntity.organization.registeredAddress.stateOrProvince }),
				/* @__PURE__ */ jsx("div", { children: legalEntity.organization.registeredAddress.country ? datasetUtils.getCountryName(legalEntity.organization.registeredAddress.country) : "" })
			]
		}) : /* @__PURE__ */ jsx(Address, {
			id: formId,
			addressType: "registrationAddress",
			data: {
				...defaultData?.registrationAddress,
				country: addressCountry
			},
			labels: addressCountry ? getAddressSchemaLabelsByCountry(addressCountry) : void 0,
			countryCode: addressCountry,
			requiredFields: addressSchema,
			optionalFields: OPTIONAL_ADDRESS_FIELDS,
			onChange: handleRegistrationAddressChange,
			shouldValidate
		}),
		/* @__PURE__ */ jsx(Field, {
			el: "fieldset",
			name: "isThisAddressTheMainHeadquarters",
			label: businessFinancingT(($) => $["areTheMainHeadquartersAtThisAddress"]),
			helper: businessFinancingT(($) => $["addressRegisteredWithGovernment"]),
			errorMessage: formUtils.getErrorMessage("isThisAddressTheMainHeadquarters", errors, fieldValidationErrors),
			children: (childProps) => /* @__PURE__ */ jsx(RadioGroup, {
				...childProps,
				name: "isThisAddressTheMainHeadquarters",
				items: businessFinancingRadioItems,
				value: data?.isThisAddressTheMainHeadquarters,
				className: BusinessFinancing_module_default.businessFinancingLeiRadio,
				disabled: false,
				onChange: handleFieldChange("isThisAddressTheMainHeadquarters"),
				"aria-required": true,
				"aria-invalid": !valid?.isThisAddressTheMainHeadquarters
			})
		})
	] });
}
//#endregion
//#region src/components/EFP/tasks/BusinessFinancingDropin/AdditionalFieldsForBusinessFinancingParentCompany.tsx
var parentCompanyFormId$1 = businessFinancingForms.parentCompany.formId;
function AdditionalFieldsForBusinessFinancingParentCompany(props) {
	const { t: businessFinancingT } = useTranslation("businessFinancing");
	const { t: commonT } = useTranslation("common");
	const { form: { handleChangeFor, data, setValid } } = useFormContext();
	const { country, formVerificationErrors, fieldValidationErrors, legalEntity } = props;
	const formUtils = createFormUtils(props, commonT);
	const handleChange = (fieldName, mode) => handleChangeFor(fieldName, "parentCompany", mode);
	setValid("sameAddressAsRootEntity", true, "parentCompany");
	const basicCompanyInformationProps = getFieldProps(props, basicInformationFields);
	const registeredAddressProps = getFieldProps(props, registeredAddressFields);
	const businessInformationProps = getFieldProps(props, businessInformationFields);
	const financialInformationProps = getFieldProps(props, financialInformationFields);
	const legalInformationProps = getFieldProps(props, legalInformationFields);
	const addressCountry = getAddressCountryForParentCompany(data?.parentCompany, legalEntity?.organization?.registeredAddress);
	if ((currencyByCountry[addressCountry ?? country] ?? [])?.length === 1) setValid("currency", true, "parentCompany");
	return /* @__PURE__ */ jsxs("form", {
		"data-testid": "businessFinancingParentCompany",
		children: [
			/* @__PURE__ */ jsx(Typography, {
				el: "h1",
				variant: "title-l",
				className: BusinessFinancing_module_default.businessFinancingBody,
				children: commonT(($) => $["parentCompanyInformation"])
			}),
			/* @__PURE__ */ jsx(Typography, {
				el: "p",
				variant: "body",
				className: BusinessFinancing_module_default.businessFinancingBody,
				children: businessFinancingT(($) => $["inThePreviousStepOwnedByAParentCompany"])
			}),
			/* @__PURE__ */ jsx(ErrorPanel, {
				verificationErrors: formVerificationErrors,
				validationErrors: fieldValidationErrors,
				formUtils,
				id: "ariaErrorField"
			}),
			/* @__PURE__ */ jsx(BusinessFinancingBasicCompanyInformation, {
				...basicCompanyInformationProps,
				sectionHeading: "parentCompanyInformation",
				handleFieldChange: handleChange,
				data: formUtils.getFieldData(data?.parentCompany ?? {}, basicInformationFields)
			}),
			/* @__PURE__ */ jsx(BusinessFinancingRegisteredAddress, {
				...registeredAddressProps,
				formId: parentCompanyFormId$1,
				sectionHeading: "parentCompanyAddress",
				defaultData: data?.parentCompany,
				legalEntity,
				handleFieldChange: handleChange,
				data: formUtils.getFieldData(data?.parentCompany ?? {}, registeredAddressFields)
			}),
			/* @__PURE__ */ jsx(BusinessFinancingBusinessInformation, {
				...businessInformationProps,
				hideSectionHeading: true,
				country: addressCountry ?? country,
				targetPage: BusinessFinancingPages.PARENT_COMPANY_PAGE,
				handleFieldChange: handleChange,
				data: formUtils.getFieldData(data?.parentCompany ?? {}, businessInformationFields)
			}),
			isEeaCountry(addressCountry) && /* @__PURE__ */ jsx(BusinessFinancingFinancialInformation, {
				...financialInformationProps,
				country: addressCountry ?? country,
				targetPage: BusinessFinancingPages.PARENT_COMPANY_PAGE,
				handleFieldChange: handleChange,
				data: formUtils.getFieldData(data?.parentCompany ?? {}, financialInformationFields)
			}),
			/* @__PURE__ */ jsx(BusinessFinancingLegalInformation, {
				...legalInformationProps,
				country: addressCountry ?? country,
				targetPage: BusinessFinancingPages.PARENT_COMPANY_PAGE,
				sectionHeading: "legalInformation",
				handleFieldChange: handleChange,
				data: formUtils.getFieldData(data?.parentCompany ?? {}, legalInformationFields)
			})
		]
	});
}
//#endregion
//#region src/components/EFP/tasks/BusinessFinancingDropin/BusinessFinancingSoleProprietorPersonalInformation.tsx
var soleProprietorPersonalInformationFields = ["gender", "countryOfBirth"];
function BusinessFinancingSoleProprietorPersonalInformation(props) {
	const { data, valid, errors, handleFieldChange, fieldValidationErrors, sectionHeading } = props;
	const { t: businessFinancingT } = useTranslation("businessFinancing");
	const { t: commonT } = useTranslation("common");
	const formUtils = createFormUtils(props, commonT);
	if (!handleFieldChange) return;
	const genderItems = [
		{
			id: "M",
			name: businessFinancingT(($) => $["male"])
		},
		{
			id: "F",
			name: businessFinancingT(($) => $["female"])
		},
		{
			id: "U",
			name: businessFinancingT(($) => $["preferNotToSay"])
		}
	];
	return /* @__PURE__ */ jsxs(Fragment, { children: [
		/* @__PURE__ */ jsx(Typography, {
			el: "h3",
			variant: "title",
			className: BusinessFinancing_module_default.businessFinancingTitle,
			children: sectionHeading ? businessFinancingT(($) => $[sectionHeading]) : businessFinancingT(($) => $["personalInformation"])
		}),
		/* @__PURE__ */ jsx(CountryField, {
			data: { country: data?.countryOfBirth },
			valid: { country: valid?.countryOfBirth },
			name: "countryOfBirth",
			errors: { country: formUtils.getErrorMessage("countryOfBirth", errors, fieldValidationErrors) },
			labels: { country: businessFinancingT(($) => $["countryOfBirth"]) },
			readonly: formUtils.isReadOnly("countryOfBirth"),
			handleChangeFor: () => handleFieldChange("countryOfBirth", "input")
		}),
		/* @__PURE__ */ jsx(Field, {
			name: "gender",
			label: businessFinancingT(($) => $["gender"]),
			errorMessage: formUtils.getErrorMessage("gender", errors, fieldValidationErrors),
			isValid: valid?.gender,
			children: (childProps) => /* @__PURE__ */ jsx(Select, {
				...childProps,
				onChange: handleFieldChange("gender", "blur"),
				name: "gender",
				placeholder: commonT(($) => $["selectOne"]),
				selected: data?.gender,
				items: genderItems,
				"aria-required": true,
				"aria-invalid": !valid?.gender
			})
		})
	] });
}
//#endregion
//#region src/components/EFP/tasks/BusinessFinancingDropin/AdditionalFieldsForBusinessFinancingSoleProprietor.tsx
function AdditionalFieldsForBusinessFinancingSoleProprietor(props) {
	const { t: businessFinancingT } = useTranslation("businessFinancing");
	const { t: commonT } = useTranslation("common");
	const { form: { handleChangeFor, data } } = useFormContext();
	const { country, formVerificationErrors, fieldValidationErrors } = props;
	const formUtils = createFormUtils(props, commonT);
	const handleChange = (fieldName, mode) => handleChangeFor(fieldName, "soleProprietor", mode);
	const personalInformationProps = getFieldProps(props, soleProprietorPersonalInformationFields);
	const businessInformationProps = getFieldProps(props, ["naceCode", "naceCodeLabel"]);
	const legalInformationProps = getFieldProps(props, legalInformationFields);
	return /* @__PURE__ */ jsxs("form", {
		"data-testid": "businessFinancingCompany",
		children: [
			/* @__PURE__ */ jsx(Header, {
				title: businessFinancingT(($) => $["additionalInformationForBusinessFinancing"]),
				description: businessFinancingT(($) => $["weNeedAFewMoreDetailsAboutYouAndYourBusiness"]),
				secondary: true
			}),
			/* @__PURE__ */ jsx(ErrorPanel, {
				verificationErrors: formVerificationErrors,
				validationErrors: fieldValidationErrors,
				formUtils,
				id: "ariaErrorField"
			}),
			/* @__PURE__ */ jsx(BusinessFinancingSoleProprietorPersonalInformation, {
				...personalInformationProps,
				handleFieldChange: handleChange,
				country,
				targetPage: BusinessFinancingPages.SOLE_PROPRIETOR_PAGE,
				sectionHeading: "personalInformation",
				data: formUtils.getFieldData(data?.soleProprietor ?? {}, soleProprietorPersonalInformationFields)
			}),
			/* @__PURE__ */ jsx(BusinessFinancingBusinessInformation, {
				...businessInformationProps,
				handleFieldChange: handleChange,
				country,
				targetPage: BusinessFinancingPages.SOLE_PROPRIETOR_PAGE,
				sectionHeading: "businessInformation",
				isSoleProprietor: true,
				data: formUtils.getFieldData(data?.soleProprietor ?? {}, ["naceCode", "naceCodeLabel"])
			}),
			/* @__PURE__ */ jsx(BusinessFinancingLegalInformation, {
				...legalInformationProps,
				country,
				handleFieldChange: handleChange,
				targetPage: BusinessFinancingPages.SOLE_PROPRIETOR_PAGE,
				sectionHeading: "legalInformation",
				data: formUtils.getFieldData(data?.soleProprietor ?? {}, legalInformationFields)
			})
		]
	});
}
//#endregion
//#region src/components/EFP/tasks/BusinessFinancingDropin/AdditionalFieldsForBusinessFinancingUltimateParentCompany.tsx
var ultimateParentCompanyFormId$1 = businessFinancingForms.ultimateParentCompany.formId;
function AdditionalFieldsForBusinessFinancingUltimateParentCompany(props) {
	const { formVerificationErrors, country, fieldValidationErrors, legalEntity } = props;
	const { t: businessFinancingT } = useTranslation("businessFinancing");
	const { t: commonT } = useTranslation("common");
	const formUtils = createFormUtils(props, commonT);
	const { form: { handleChangeFor, data, setValid } } = useFormContext();
	const handleChange = (fieldName, mode) => handleChangeFor(fieldName, "ultimateParentCompany", mode);
	setValid("sameAddressAsRootEntity", true, "ultimateParentCompany");
	const basicCompanyInformationProps = getFieldProps(props, basicInformationFields);
	const registeredAddressProps = getFieldProps(props, registeredAddressFields);
	const businessInformationProps = getFieldProps(props, businessInformationFields);
	const financialInformationProps = getFieldProps(props, financialInformationFields);
	const legalInformationProps = getFieldProps(props, legalInformationFields);
	const addressCountry = getAddressCountryForParentCompany(data?.ultimateParentCompany, legalEntity?.organization?.registeredAddress);
	if ((currencyByCountry[addressCountry ?? country] ?? [])?.length === 1) setValid("currency", true, "ultimateParentCompany");
	return /* @__PURE__ */ jsxs("form", {
		"data-testid": "businessFinancingUltimateParentCompany",
		children: [
			/* @__PURE__ */ jsx(Typography, {
				el: "h1",
				variant: "title-l",
				className: BusinessFinancing_module_default.businessFinancingBody,
				children: commonT(($) => $["ultimateParentCompanyInformation"])
			}),
			/* @__PURE__ */ jsx(Typography, {
				el: "p",
				variant: "body",
				className: BusinessFinancing_module_default.businessFinancingBody,
				children: businessFinancingT(($) => $["inThePreviousStepOwnedByAnUltimateParentCompany"])
			}),
			/* @__PURE__ */ jsx(ErrorPanel, {
				verificationErrors: formVerificationErrors,
				validationErrors: fieldValidationErrors,
				formUtils,
				id: "ariaErrorField"
			}),
			/* @__PURE__ */ jsx(BusinessFinancingBasicCompanyInformation, {
				...basicCompanyInformationProps,
				sectionHeading: "ultimateParentCompanyInformation",
				handleFieldChange: handleChange,
				data: formUtils.getFieldData(data?.ultimateParentCompany ?? {}, basicInformationFields)
			}),
			/* @__PURE__ */ jsx(BusinessFinancingRegisteredAddress, {
				...registeredAddressProps,
				formId: ultimateParentCompanyFormId$1,
				sectionHeading: "ultimateParentCompanyAddress",
				defaultData: data?.ultimateParentCompany,
				handleFieldChange: handleChange,
				data: formUtils.getFieldData(data?.ultimateParentCompany ?? {}, registeredAddressFields),
				legalEntity
			}),
			/* @__PURE__ */ jsx(BusinessFinancingBusinessInformation, {
				...businessInformationProps,
				hideSectionHeading: true,
				country: addressCountry ?? country,
				targetPage: BusinessFinancingPages.ULTIMATE_PARENT_COMPANY_PAGE,
				handleFieldChange: handleChange,
				data: formUtils.getFieldData(data?.ultimateParentCompany ?? {}, businessInformationFields)
			}),
			isEeaCountry(addressCountry) && /* @__PURE__ */ jsx(BusinessFinancingFinancialInformation, {
				...financialInformationProps,
				country: addressCountry ?? country,
				targetPage: BusinessFinancingPages.ULTIMATE_PARENT_COMPANY_PAGE,
				handleFieldChange: handleChange,
				data: formUtils.getFieldData(data?.ultimateParentCompany ?? {}, financialInformationFields)
			}),
			/* @__PURE__ */ jsx(BusinessFinancingLegalInformation, {
				...legalInformationProps,
				country: addressCountry ?? country,
				sectionHeading: "legalInformation",
				targetPage: BusinessFinancingPages.ULTIMATE_PARENT_COMPANY_PAGE,
				handleFieldChange: handleChange,
				data: formUtils.getFieldData(data?.ultimateParentCompany ?? {}, legalInformationFields)
			})
		]
	});
}
//#endregion
//#region src/components/EFP/tasks/BusinessFinancingDropin/BusinessFinancingSummary.tsx
var omittedSummaryKeys = [
	"naceCodeLabel",
	"legalFormLabel",
	"currency",
	"doesYourCompanyHaveLEI",
	"sameAddressAsRootEntity"
];
var customLabels = {
	legalForm: "businessStructure",
	naceCode: "industryAndNaceCode",
	balanceSheetTotal: "totalAssets",
	annualTurnover: "annualTurnover",
	legalInformationInsolvency: "legalProceedings",
	isCompanyOwnedByAnotherCompany: "hasParentCompany",
	isParentOwnedByAnotherCompany: "hasUltimateParentCompany",
	isThisAddressTheMainHeadquarters: "addressIsHeadquarters"
};
var isOmmitted = (key) => {
	return omittedSummaryKeys.includes(key);
};
var isCustomLabel = (key) => {
	return key in customLabels;
};
/**
* Business and data layer around Summary, processing all the data
*/
var BusinessFinancingSummary = ({ forms, items, handleEditForm, children }) => {
	const { t: businessFinancingT } = useTranslation("businessFinancing");
	const { t: commonT } = useTranslation("common");
	const formatItemForStructuredList = (data) => {
		if (!data) return [];
		const structuredListItems = Object.entries(data).map(([key, value]) => {
			if (isOmmitted(key) || !value) return;
			return {
				term: isCustomLabel(key) ? businessFinancingT(($) => $[customLabels[key]]) : commonT(($) => $[key]),
				details: value
			};
		}).filter((v) => v !== void 0);
		const structuredListItemsWithInnerForms = [];
		structuredListItems.map((it) => {
			if (typeof it?.details === "object") structuredListItemsWithInnerForms.push(...formatItemForStructuredList(it?.details));
			else structuredListItemsWithInnerForms.push(it);
		});
		return structuredListItemsWithInnerForms;
	};
	const processSummarySections = (forms) => {
		return forms.map(({ formId, formName }) => ({
			formId,
			label: commonT(($) => $[formName]),
			items: formatItemForStructuredList(items[formId])
		}));
	};
	return /* @__PURE__ */ jsx(NewSummary, {
		handleEditForm,
		sections: processSummarySections(forms),
		children
	});
};
//#endregion
//#region src/components/EFP/tasks/BusinessFinancingDropin/BusinessFinancingDropin.tsx
var getOrgAnalyticsData = (prefix, details) => {
	const org = details?.organization;
	const soleProp = details?.soleProprietorship;
	const entity = org || soleProp;
	if (!entity) return {};
	return {
		[`${prefix}--economicSector`]: entity?.economicSector ?? "",
		[`${prefix}--legalForm`]: org?.legalForm ?? "",
		[`${prefix}--statusOfLegalProceeding`]: entity?.statusOfLegalProceeding ?? ""
	};
};
var businessFinancingFormsRequiredFields = {
	soleProprietor: businessFinancingForms.soleProprietor.fields,
	company: businessFinancingForms.company.fields,
	parentCompany: businessFinancingForms.parentCompany.fields,
	ultimateParentCompany: businessFinancingForms.ultimateParentCompany.fields
};
var parentCompanyFormId = businessFinancingForms.parentCompany.formId;
var companyFormId = businessFinancingForms.company.formId;
var ultimateParentCompanyFormId = businessFinancingForms.ultimateParentCompany.formId;
function BusinessFinancingDropin(props) {
	const { country, rootLegalEntity, externalOnSubmit, externalOnSubmitLabel, isStandaloneComponent, handleHomeClick } = props;
	const { t: businessFinancingT } = useTranslation("businessFinancing");
	const { t: commonT, i18n } = useTranslation("common");
	const userEvents = useAnalyticsContext();
	const invalidateRootLegalEntity = useInvalidateRootLegalEntity();
	const { mutateAsync: createLegalEntity } = useCreateLegalEntity();
	const { mutateAsync: updateLegalEntity } = useUpdateLegalEntity();
	const { data: immediateParentCompany, isLoading: immediateParentCompanyIsLoading } = useAssociatedLegalEntity(rootLegalEntity, "immediateParentCompany");
	const { data: ultimateParentCompany, isLoading: ultimateParentCompanyIsLoading } = useAssociatedLegalEntity(rootLegalEntity, "ultimateParentCompany");
	const { data: soleProprietor, isLoading: soleProprietorIsLoading } = useAssociatedLegalEntity(rootLegalEntity, "soleProprietorship");
	/**
	* Analytics
	*/
	useTaskLandedEvent("BUSINESS_FINANCING");
	const derivedData = useMemo(() => {
		if (immediateParentCompanyIsLoading || ultimateParentCompanyIsLoading || soleProprietorIsLoading) return void 0;
		const isSoleProprietor = hasSolePropInLegalEntity(rootLegalEntity);
		const dataFromResponse = {};
		if (isSoleProprietor && soleProprietor) {
			dataFromResponse.soleProprietor = mapLegalEntityToBusinessFinancing(rootLegalEntity);
			dataFromResponse.soleProprietor = appendSoleProprietorBusinessFinancingData(soleProprietor.soleProprietorship, dataFromResponse.soleProprietor);
		} else if (rootLegalEntity.type === LegalEntityTypes.ORGANIZATION) {
			dataFromResponse.company = mapLegalEntityToBusinessFinancing(rootLegalEntity);
			dataFromResponse.company = appendBusinessFinancingData(rootLegalEntity.organization, dataFromResponse.company);
			dataFromResponse.company.isCompanyOwnedByAnotherCompany = "No";
			dataFromResponse.company.isParentOwnedByAnotherCompany = "No";
			if (immediateParentCompany) {
				dataFromResponse.parentCompany = mapLegalEntityToBusinessFinancing(immediateParentCompany);
				dataFromResponse.parentCompany = appendBusinessFinancingData(immediateParentCompany.organization, dataFromResponse.parentCompany);
				dataFromResponse.company.isCompanyOwnedByAnotherCompany = "Yes";
			}
			if (ultimateParentCompany) {
				dataFromResponse.ultimateParentCompany = mapLegalEntityToBusinessFinancing(ultimateParentCompany);
				dataFromResponse.ultimateParentCompany = appendBusinessFinancingData(ultimateParentCompany.organization, dataFromResponse.ultimateParentCompany);
				dataFromResponse.company.isParentOwnedByAnotherCompany = "Yes";
			}
		}
		return dataFromResponse;
	}, [
		immediateParentCompanyIsLoading,
		ultimateParentCompanyIsLoading,
		soleProprietorIsLoading,
		rootLegalEntity,
		immediateParentCompany,
		ultimateParentCompany,
		soleProprietor
	]);
	const datasetUtils = datasetUtilities(i18n.language);
	const [problems, setProblems] = useState();
	const [loadingStatus, setLoadingStatus] = useState("success");
	const [showEndState, setShowEndState] = useState(false);
	const { showToast } = useToastContext();
	const { isSettingEnabled } = useSettingsContext();
	const showBusinessFinancingFirst = isSettingEnabled(SettingNames.ShowBusinessFinancingFirst);
	const onSubmit = async () => {
		setLoadingStatus("loading");
		if (!umfData) return;
		const isSoleProprietor = hasSolePropInLegalEntity(rootLegalEntity);
		const mainEntityDetails = !isSoleProprietor ? prepareBusinessFinancingSubmitData(BusinessFinancingIndices.COMPANY, umfData, rootLegalEntity) : null;
		const soleProprietorPayloads = isSoleProprietor ? prepareSoleProprietorBusinessFinancingSubmitData(umfData, rootLegalEntity, soleProprietor) : null;
		const parentCompanyBusinessFinancingDetails = !isSoleProprietor ? prepareBusinessFinancingSubmitData(BusinessFinancingIndices.PARENT_COMPANY, umfData, rootLegalEntity) : null;
		const ultimateParentCompanyBusinessFinancingDetails = !isSoleProprietor ? prepareBusinessFinancingSubmitData(BusinessFinancingIndices.ULTIMATE_PARENT_COMPANY, umfData, rootLegalEntity) : null;
		if (isSoleProprietor) {
			if (!soleProprietorPayloads || !rootLegalEntity || !soleProprietor?.id) {
				showToast({
					label: businessFinancingT(($) => $["missingCompanyDetails"]),
					variant: "error"
				});
				return;
			}
			try {
				await handleBusinessFinancingFormSubmission(BusinessFinancingIndices.SOLE_PROPRIETOR, soleProprietorPayloads.individualPayload, createLegalEntity, updateLegalEntity, rootLegalEntity.id);
				const eventsAdditionalData = { ...getOrgAnalyticsData("SoleProprietor", await handleBusinessFinancingFormSubmission(BusinessFinancingIndices.SOLE_PROPRIETOR, soleProprietorPayloads.solePropPayload, createLegalEntity, updateLegalEntity, soleProprietor.id)) };
				userEvents.addTaskEvent("Success", {
					actionType: "submit",
					returnValue: [BusinessFinancingIndices.SOLE_PROPRIETOR],
					additionalData: eventsAdditionalData
				});
				await invalidateRootLegalEntity();
				if (showBusinessFinancingFirst || isStandaloneComponent) setShowEndState(true);
				else externalOnSubmit?.({ ...umfData });
				setProblems({});
			} catch (e) {
				showToast({
					label: commonT(($) => $["failedToUpdateDetails"]),
					variant: "error"
				});
				handleSubmissionError(e, BusinessFinancingIndices.SOLE_PROPRIETOR);
			} finally {
				setLoadingStatus("success");
			}
		} else {
			if (!mainEntityDetails || !rootLegalEntity) {
				showToast({
					label: businessFinancingT(($) => $["missingCompanyDetails"]),
					variant: "error"
				});
				return;
			}
			let parentCompanyFailed = false;
			let ultimateParentCompanyFailed = false;
			try {
				const promises = [];
				if (parentCompanyBusinessFinancingDetails) {
					const parentCompanyPromise = handleBusinessFinancingFormSubmission(BusinessFinancingIndices.PARENT_COMPANY, parentCompanyBusinessFinancingDetails, createLegalEntity, updateLegalEntity, parentCompanyBusinessFinancingDetails?.id);
					promises.push(parentCompanyPromise);
				}
				if (ultimateParentCompanyBusinessFinancingDetails) {
					const ultimateParentCompanyPromise = handleBusinessFinancingFormSubmission(BusinessFinancingIndices.ULTIMATE_PARENT_COMPANY, ultimateParentCompanyBusinessFinancingDetails, createLegalEntity, updateLegalEntity, ultimateParentCompanyBusinessFinancingDetails?.id);
					promises.push(ultimateParentCompanyPromise);
				}
				const results = await Promise.allSettled(promises);
				const businessFinancingEntityAssociations = [...rootLegalEntity.entityAssociations ? rootLegalEntity.entityAssociations.filter((entityAssociation) => entityAssociation.type !== "immediateParentCompany" && entityAssociation.type !== "ultimateParentCompany") : []];
				const entitiesToTrack = [BusinessFinancingIndices.COMPANY];
				results.forEach((result, index) => {
					const businessFinancingType = index === 0 ? BusinessFinancingIndices.PARENT_COMPANY : BusinessFinancingIndices.ULTIMATE_PARENT_COMPANY;
					if (result.status === "fulfilled") {
						const response = result.value;
						if (businessFinancingType === BusinessFinancingIndices.PARENT_COMPANY) {
							businessFinancingEntityAssociations.push({
								type: "immediateParentCompany",
								legalEntityId: response.id,
								associatorId: mainEntityDetails.id
							});
							entitiesToTrack.push(BusinessFinancingIndices.PARENT_COMPANY);
						} else if (businessFinancingType === BusinessFinancingIndices.ULTIMATE_PARENT_COMPANY) {
							businessFinancingEntityAssociations.push({
								type: "ultimateParentCompany",
								legalEntityId: response.id,
								associatorId: mainEntityDetails.id
							});
							entitiesToTrack.push(BusinessFinancingIndices.ULTIMATE_PARENT_COMPANY);
						}
					} else {
						if (businessFinancingType === BusinessFinancingIndices.PARENT_COMPANY) parentCompanyFailed = true;
						else if (businessFinancingType === BusinessFinancingIndices.ULTIMATE_PARENT_COMPANY) ultimateParentCompanyFailed = true;
						handleSubmissionError(result.reason, businessFinancingType);
					}
				});
				if (!parentCompanyFailed && !ultimateParentCompanyFailed) {
					mainEntityDetails.entityAssociations = [...businessFinancingEntityAssociations];
					const eventsAdditionalData = {
						...getOrgAnalyticsData("Business", mainEntityDetails),
						...getOrgAnalyticsData("ParentCompany", parentCompanyBusinessFinancingDetails),
						...getOrgAnalyticsData("UltimateParentCompany", ultimateParentCompanyBusinessFinancingDetails)
					};
					try {
						await handleBusinessFinancingFormSubmission(BusinessFinancingIndices.COMPANY, mainEntityDetails, createLegalEntity, updateLegalEntity, mainEntityDetails?.id);
						userEvents.addTaskEvent("Success", {
							actionType: "submit",
							returnValue: entitiesToTrack,
							additionalData: eventsAdditionalData
						});
						await invalidateRootLegalEntity();
						if (showBusinessFinancingFirst || isStandaloneComponent) setShowEndState(true);
						else externalOnSubmit?.({ ...umfData });
					} catch (e) {
						showToast({
							label: commonT(($) => $["failedToUpdateDetails"]),
							variant: "error"
						});
						handleSubmissionError(e, BusinessFinancingIndices.COMPANY);
					}
					setProblems({});
				}
			} catch (e) {
				if (!parentCompanyFailed && !ultimateParentCompanyFailed) handleSubmissionError(e, BusinessFinancingIndices.COMPANY);
				showToast({
					label: commonT(($) => $["failedToUpdateDetails"]),
					variant: "error"
				});
			} finally {
				setLoadingStatus("success");
			}
		}
	};
	const handleSubmissionError = (error, businessFinancingType) => {
		const keyMapping = businessFinancingType === BusinessFinancingIndices.SOLE_PROPRIETOR ? {
			...businessFinancingIndividualApiKeyMapping,
			...businessFinancingSoleProprietorApiKeyMapping
		} : businessFinancingApiKeyMapping;
		if (isValidationError(error.actualError)) {
			const validationErrors = processValidationErrors(error.actualError, void 0, keyMapping);
			setProblems((prevProblems) => ({
				...prevProblems,
				validationErrors: {
					...prevProblems?.validationErrors,
					[businessFinancingType]: validationErrors?.[businessFinancingType] ?? {}
				}
			}));
		} else if (isMaintenanceModeError(error)) showToast({
			label: commonT(($) => $["maintenanceModeMessage"]),
			variant: "error",
			duration: "indefinite"
		});
		else showToast({
			label: commonT(($) => $["failedToUpdateDetails"]),
			variant: "error"
		});
	};
	const [requiredFields, setRequiredFields] = useState(void 0);
	const form = useMultiForm({
		requiredFields,
		defaultData: derivedData,
		rules: businessFinancingMultiformRules
	});
	const { data: umfData = derivedData, isValid, errors, valid } = form;
	const businessFinancingRequiredForms = useMemo(() => {
		let updateForms = {};
		if (umfData?.soleProprietor) updateForms = { soleProprietor: { ...businessFinancingForms.soleProprietor } };
		else {
			updateForms = { company: { ...businessFinancingForms.company } };
			const showParentCompany = umfData?.company?.isCompanyOwnedByAnotherCompany === "Yes";
			const showUltimateParentCompany = umfData?.company?.isParentOwnedByAnotherCompany === "Yes";
			if (showParentCompany) updateForms = {
				...updateForms,
				parentCompany: businessFinancingForms.parentCompany
			};
			if (showParentCompany && showUltimateParentCompany) updateForms = {
				...updateForms,
				ultimateParentCompany: businessFinancingForms.ultimateParentCompany
			};
		}
		return updateForms;
	}, [
		umfData?.soleProprietor,
		umfData?.company?.isCompanyOwnedByAnotherCompany,
		umfData?.company?.isParentOwnedByAnotherCompany
	]);
	useEffect(() => {
		setRequiredFields(getBusinessFinancingRequiredFields(country, umfData, rootLegalEntity?.organization?.registeredAddress));
	}, [umfData, rootLegalEntity?.organization?.registeredAddress]);
	const forms = useMemo(() => {
		return addValidityToForms(getRequiredForms(businessFinancingRequiredForms, businessFinancingFormsRequiredFields, {}), isValid, problems);
	}, [
		businessFinancingRequiredForms,
		isValid,
		businessFinancingFormsRequiredFields,
		problems
	]);
	const { handleNextClick, handleBackClick, activeForm, gotoFormByFormIndex, gotoFormByFormId, steps, shouldValidate } = useFormComposer({
		problems,
		forms,
		onSubmit
	});
	const renderActiveForm = (selectedForm) => /* @__PURE__ */ jsxs("div", { children: [
		selectedForm.formId === "soleProprietor" && /* @__PURE__ */ jsx(AdditionalFieldsForBusinessFinancingSoleProprietor, {
			data: derivedData?.soleProprietor,
			legalEntity: rootLegalEntity,
			heading: businessFinancingT(($) => $["additionalInformationForBusinessFinancing"]),
			id: selectedForm.formId,
			country,
			shouldValidate,
			fieldValidationErrors: problems?.validationErrors?.[selectedForm?.formId],
			formVerificationErrors: problems?.verificationErrors?.[selectedForm?.formId],
			errors: errors?.soleProprietor,
			valid: valid?.soleProprietor
		}),
		selectedForm.formId === companyFormId && /* @__PURE__ */ jsx(AdditionalFieldsForBusinessFinancingCompany, {
			data: derivedData?.company,
			legalEntity: rootLegalEntity,
			heading: businessFinancingT(($) => $["additionalInformationForBusinessFinancing"]),
			id: companyFormId,
			country,
			shouldValidate,
			fieldValidationErrors: problems?.validationErrors?.[selectedForm?.formId],
			formVerificationErrors: problems?.verificationErrors?.[selectedForm?.formId],
			errors: errors?.company,
			valid: valid?.company
		}),
		selectedForm.formId === parentCompanyFormId && /* @__PURE__ */ jsx(AdditionalFieldsForBusinessFinancingParentCompany, {
			data: derivedData?.parentCompany,
			heading: commonT(($) => $["parentCompanyInformation"]),
			id: companyFormId,
			country,
			shouldValidate,
			errors: errors?.parentCompany,
			legalEntity: rootLegalEntity
		}),
		selectedForm.formId === ultimateParentCompanyFormId && /* @__PURE__ */ jsx(AdditionalFieldsForBusinessFinancingUltimateParentCompany, {
			data: derivedData?.ultimateParentCompany,
			heading: commonT(($) => $["ultimateParentCompanyInformation"]),
			id: companyFormId,
			country,
			shouldValidate,
			errors: errors?.ultimateParentCompany,
			legalEntity: rootLegalEntity
		})
	] });
	if (!derivedData?.company && !derivedData?.soleProprietor) return /* @__PURE__ */ jsx(Loader, {});
	const allValidationErrors = problems?.validationErrors && Object.values(problems.validationErrors)?.reduce((acc, validError) => ({
		...acc,
		...validError
	}), {});
	const allVerificationErrors = problems?.verificationErrors && Object.values(problems.verificationErrors)?.reduce((acc, verifError) => ({
		...acc,
		...verifError
	}), {});
	const formUtils = createFormUtils({ labels: {} }, commonT);
	const handleEditForm = (formId) => {
		const formIndex = forms.findIndex((form) => form.formId === formId);
		if (formIndex >= 0) gotoFormByFormIndex(formIndex);
	};
	const summaryComponent = /* @__PURE__ */ jsx(BusinessFinancingSummary, {
		items: formatDataForSummary(i18n.language, businessFinancingT, datasetUtils, umfData, rootLegalEntity?.organization?.registeredAddress),
		handleEditForm,
		forms,
		children: /* @__PURE__ */ jsx(ErrorPanel, {
			validationErrors: allValidationErrors,
			verificationErrors: allVerificationErrors,
			formUtils,
			id: "ariaErrorField",
			slot: "errorPanel"
		})
	});
	return showEndState ? /* @__PURE__ */ jsx(EndStateLayout, {
		title: businessFinancingT(($) => $["submissionReceived"]),
		description: businessFinancingT(($) => $["theInformationProvidedIsBeingReviewed"]),
		action: externalOnSubmit && !showBusinessFinancingFirst ? /* @__PURE__ */ jsx(Button, {
			onClick: () => externalOnSubmit?.({ ...umfData }),
			children: externalOnSubmitLabel || commonT(($) => $["finish"])
		}) : void 0
	}) : /* @__PURE__ */ jsx(FormContextProvider, {
		form,
		children: /* @__PURE__ */ jsx(FormFlow, {
			summaryComponent,
			currentStep: steps.current,
			disableNextButton: !activeForm.isValid,
			forms,
			activeForm,
			gotoFormByFormIndex,
			gotoFormByFormId,
			handleBackClick,
			handleCancelClick: handleHomeClick,
			handleNextClick,
			loadingStatus,
			totalSteps: steps.total,
			children: /* @__PURE__ */ jsx("div", { children: renderActiveForm(activeForm || (derivedData?.soleProprietor ? businessFinancingForms.soleProprietor : businessFinancingForms.company)) })
		})
	});
}
//#endregion
export { BusinessFinancingDropin as t };
