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] = "bc6c8e24-46de-4746-ad3f-c96860502253", e._sentryDebugIdIdentifier = "sentry-dbid-bc6c8e24-46de-4746-ad3f-c96860502253");
} catch (e) {}
import { c as __exportAll, n as addResourceBundles, o as createLogger, r as useTranslation } from "./translation-Br5wIPO-.js";
import { r as Loader, t as Button } from "./Button-BDEdGXnd.js";
import { n as httpGet, r as httpPost, s as useApiContext } from "./http-CHTzpXCd.js";
import { r as useLegalEntity, t as ROOT_LE } from "./useLegalEntity-Dm6g0wmt.js";
import { t as LegalEntityTypes } from "./legal-entity-type-VIfNYnJP.js";
import { t as getLegalEntityCountry } from "./getLegalEntityCountry-C6bSV6sB.js";
import { t as useToggleContext } from "./useToggleContext-CLfowItk.js";
import { t as _rolldown_dynamic_import_helper_default } from "./_rolldown_dynamic_import_helper-CCXvMgfE.js";
import { t as StackLayout } from "./StackLayout-BMQXXBDb.js";
import { t as Alert } from "./Alert-CjZYipjN.js";
import { t as TaskTypes } from "./taskTypes-DWaxzvnQ.js";
import { a as getLegalRepresentative } from "./entityAssociationUtil-C0gX4Ewv.js";
import { a as getOwnSignatories } from "./decisionMakerRoles-wy4KpDQg.js";
import { t as doesLegalEntityRequiresLegalRepresentative } from "./birthDateUtils-CMLWoaT8.js";
import { n as useTermsOfServiceAcceptanceInfos, t as useTermsOfServiceStatus } from "./useTermsOfServiceStatus-Dh4huPkR.js";
import { t as Card } from "./Card-DXdUqwyQ.js";
import { t as useAnalyticsContext } from "./useAnalyticsContext-DfTXpZbA.js";
import { t as useToastContext } from "./useToastContext-CK7UoZ5Z.js";
import { t as EndStateLayout } from "./EndStateLayout-DxdIVWL3.js";
import { t as downloadFile } from "./file-C9ni6Xpv.js";
import { t as useInvalidateRootLegalEntity } from "./invalidateRootLegalEntity-BHyct4ev.js";
import { t as LoaderWrapper } from "./LoaderWrapper-CRf5MAK1.js";
import { t as getLanguageCode } from "./utils-g_Wl4-9Z.js";
import { n as getLegalEntityNameBasedOnType } from "./getName-ODLD6UPV.js";
import { t as useTaskLandedEvent } from "./useTaskLandedEvent-DCdJo64z.js";
import { t as MaybeModal } from "./MaybeModal-DkRlF_Mg.js";
import { t as ProgressBar } from "./ProgressBar-DrvdkkV2.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 useForm } from "./useForm-DzG9tJAE.js";
import { t as FormNavigation } from "./FormNavigation-Btkou5O7.js";
import { t as ContractViewer } from "./ContractViewer-BieoFdY1.js";
import { useCallback, useEffect, useMemo, useState } from "preact/hooks";
import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
import { skipToken, useMutation, useQuery } from "@tanstack/preact-query";
//#region src/api/termsOfService/useAcceptTermsOfService.ts
var acceptTermsOfService = async (legalEntityId, baseUrl, termsOfServiceDocumentId, data) => {
	return httpPost({
		baseUrl,
		path: `legalEntities/${legalEntityId}/termsOfService/accept`
	}, {
		...data,
		legalEntityReference: legalEntityId,
		termsOfServiceDocumentId
	});
};
var useAcceptTermsOfService = (options) => {
	const { rootLegalEntityId, baseUrl } = useApiContext();
	const invalidateRootLegalEntity = useInvalidateRootLegalEntity();
	return useMutation({
		mutationFn: (data) => acceptTermsOfService(rootLegalEntityId.value, baseUrl.value, data.termsOfServiceDocumentId, data),
		onSuccess: async () => {
			await invalidateRootLegalEntity();
		},
		...options
	});
};
//#endregion
//#region src/api/termsOfService/useAcceptedTermsOfService.ts
var getAcceptedTermsOfService = async (legalEntityId, baseUrl, termsOfServiceAcceptanceReference, documentFormat) => {
	return httpGet({
		baseUrl,
		path: `legalEntities/${legalEntityId}/termsOfService/acceptedTermsOfServiceDocument/${termsOfServiceAcceptanceReference}?documentformat=${documentFormat} `
	});
};
var useAcceptedTermsOfService = (termsOfServiceAcceptanceReference, documentFormat, options) => {
	const { rootLegalEntityId, baseUrl } = useApiContext();
	return useQuery({
		queryKey: [
			"acceptedTermsOfService",
			termsOfServiceAcceptanceReference,
			documentFormat
		],
		queryFn: termsOfServiceAcceptanceReference ? () => getAcceptedTermsOfService(rootLegalEntityId.value, baseUrl.value, termsOfServiceAcceptanceReference, documentFormat) : skipToken,
		...options
	});
};
//#endregion
//#region src/api/termsOfService/useTermsOfService.ts
var getTermsOfService = async (legalEntityId, baseUrl, data) => {
	return httpPost({
		baseUrl,
		path: `legalEntities/${legalEntityId}/termsOfService`
	}, data);
};
var useTermsOfService = (data, options) => {
	const { rootLegalEntityId, baseUrl } = useApiContext();
	return useQuery({
		queryKey: ["termsOfService", data],
		queryFn: () => getTermsOfService(rootLegalEntityId.value, baseUrl.value, data),
		...options
	});
};
var ServiceAgreementDropin_module_default = {
	"tos-signed-alert": "adyen-kyc-tos-signed-alert",
	tosSignedAlert: "adyen-kyc-tos-signed-alert",
	"tos-container": "adyen-kyc-tos-container",
	tosContainer: "adyen-kyc-tos-container",
	"tos-content": "adyen-kyc-tos-content",
	tosContent: "adyen-kyc-tos-content",
	"tos-signer-field": "adyen-kyc-tos-signer-field",
	tosSignerField: "adyen-kyc-tos-signer-field",
	"tos-actions": "adyen-kyc-tos-actions",
	tosActions: "adyen-kyc-tos-actions"
};
//#endregion
//#region src/components/Contract/tasks/ServiceAgreementDropin/useServiceAgreement.ts
var logger$1 = createLogger();
var FALLBACK_LANGUAGE_CODE$1 = "en";
var useServiceAgreement = ({ handleServiceAgreementIsNotAvailableInThatLanguage, acceptanceId, serviceAgreementType, language }) => {
	const [agreementLanguage, setAgreementLanguage] = useState(language);
	useEffect(() => {
		if (agreementLanguage !== language) setAgreementLanguage(language);
	}, [language]);
	const { data: unAcceptedServiceAgreement, isSuccess: isUnAcceptedServiceAgreementSuccess, isError, error } = useTermsOfService({
		language: agreementLanguage,
		type: serviceAgreementType,
		termsOfServiceDocumentFormat: "JSON"
	}, { enabled: !acceptanceId });
	const { data: acceptedServiceAgreement, isSuccess: isAcceptedServiceAgreementSuccess } = useAcceptedTermsOfService(acceptanceId, "JSON");
	const fetchedServiceAgreement = useMemo(() => {
		const termsOfService = unAcceptedServiceAgreement ?? acceptedServiceAgreement;
		const documentId = unAcceptedServiceAgreement?.termsOfServiceDocumentId ?? acceptedServiceAgreement?.termsOfServiceAcceptanceReference;
		if (termsOfService?.document && documentId) return {
			loading: "success",
			serviceAgreement: {
				id: documentId,
				contract: JSON.parse(decodeURIComponent(escape(window.atob(termsOfService.document))))
			}
		};
	}, [acceptedServiceAgreement, unAcceptedServiceAgreement]);
	if ((isUnAcceptedServiceAgreementSuccess || isAcceptedServiceAgreementSuccess) && fetchedServiceAgreement) return fetchedServiceAgreement;
	if (isError) {
		if (agreementLanguage !== FALLBACK_LANGUAGE_CODE$1) {
			handleServiceAgreementIsNotAvailableInThatLanguage();
			setAgreementLanguage(FALLBACK_LANGUAGE_CODE$1);
		} else logger$1.error(error);
		return {
			loading: "success",
			serviceAgreement: void 0
		};
	}
	return {
		loading: "loading",
		serviceAgreement: void 0
	};
};
//#endregion
//#region src/components/Contract/tasks/ServiceAgreementDropin/validate.ts
var serviceAgreementValidationRules = {
	signer: {
		modes: ["blur"],
		validate: (signer) => !!signer,
		errorMessage: "fieldIsRequired"
	},
	acceptServiceAgreement: {
		modes: ["blur"],
		validate: (acceptServiceAgreement) => !!acceptServiceAgreement,
		errorMessage: "fieldIsRequired"
	}
};
//#endregion
//#region src/components/Contract/tasks/ServiceAgreementDropin/ServiceAgreementDropin.tsx
var serviceAgreementTypesTranslationMapping = {
	adyenForPlatformsManage: "paymentProcessingTerms",
	adyenIssuing: "accountHolderTerms",
	adyenForPlatformsAdvanced: "paymentProcessingTerms",
	adyenCapital: "capitalUserTerms",
	adyenAccount: "businessAccountTerms",
	adyenCard: "cardUserTerms",
	adyenFranchisee: "franchiseesTAndCs",
	adyenPccr: "pccr",
	adyenChargeCard: "chargeCardUserAgreement",
	kycOnInvite: "kycOnInvite",
	directDebit: "directDebit"
};
var logger = createLogger();
var FALLBACK_LANGUAGE_CODE = "en";
function ServiceAgreementDropin({ legalEntityResponse, handleAddSigner, handleSign, serviceAgreementTypes, serviceAgreementAcceptanceInfos, asEmbedded = false, asModal = false, handleCloseClick, showInitialBackButton = false, onComplete }) {
	const { t, i18n } = useTranslation(["contract", "common"]);
	const userEvents = useAnalyticsContext();
	const { showToast } = useToastContext();
	const { isFeatureEnabled } = useToggleContext();
	const isAgeVerificationEnabled = isFeatureEnabled("EnableAgeVerification");
	const { rootLegalEntityId, baseUrl } = useApiContext();
	const [loadingStatus, setLoadingStatus] = useState();
	const country = getLegalEntityCountry(legalEntityResponse);
	const acceptanceMessageKey = (() => {
		switch (country) {
			case "IT": return "iHaveReadAndIAcceptTheseTermsIT";
			default: return "iHaveReadAndIAcceptTheseTerms";
		}
	})();
	const signedForms = serviceAgreementAcceptanceInfos.map((serviceAgreementAcceptanceInfo) => ({
		formId: serviceAgreementAcceptanceInfo.id,
		serviceAgreementType: serviceAgreementAcceptanceInfo.type,
		acceptanceId: serviceAgreementAcceptanceInfo.id,
		createdAt: serviceAgreementAcceptanceInfo.createdAt,
		formName: serviceAgreementTypesTranslationMapping[serviceAgreementAcceptanceInfo.type],
		isValid: true
	}));
	const formsToBeSigned = serviceAgreementTypes.map((serviceAgreementType) => ({
		formId: serviceAgreementType,
		serviceAgreementType,
		formName: serviceAgreementTypesTranslationMapping[serviceAgreementType],
		isValid: false
	}));
	const forms = [...signedForms, ...formsToBeSigned];
	const [activeFormIndex, setActiveFormIndex] = useState(0);
	const [activeForm, setActiveForm] = useState(forms[activeFormIndex]);
	const [hasFinished, setHasFinished] = useState(false);
	const canSign = serviceAgreementTypes.includes(activeForm.serviceAgreementType) && !activeForm.acceptanceId;
	const isFirstStep = activeFormIndex === 0;
	const isLastStep = activeFormIndex === forms.length - 1;
	const showSignedAlert = !!activeForm.acceptanceId;
	const { refetch: downloadAcceptedTermsAsPdf } = useAcceptedTermsOfService(activeForm.acceptanceId, "PDF", { enabled: false });
	const { loading: contractLoadingStatus, serviceAgreement } = useServiceAgreement({
		handleServiceAgreementIsNotAvailableInThatLanguage: useCallback(() => {
			showToast({
				label: t(($) => $["failedToGetServiceAgreementInSelectedLanguageFallbackToEn"]),
				variant: "error"
			});
		}, [t, showToast]),
		acceptanceId: activeForm.acceptanceId,
		serviceAgreementType: activeForm.serviceAgreementType,
		language: getLanguageCode(i18n.language)
	});
	const { handleChangeFor, triggerValidation, data, valid, isValid, errors } = useForm({
		schema: ["signer", "acceptServiceAgreement"],
		rules: serviceAgreementValidationRules
	});
	const getSigners = () => {
		if (legalEntityResponse.type === LegalEntityTypes.ORGANIZATION) return getOwnSignatories(legalEntityResponse).map(({ legalEntityId: id, name }) => ({
			id: id ?? "",
			name: name ?? ""
		}));
		if (isAgeVerificationEnabled && doesLegalEntityRequiresLegalRepresentative(legalEntityResponse)) {
			const legalRepresentative = getLegalRepresentative(legalEntityResponse);
			return legalRepresentative ? [{
				id: legalRepresentative.legalEntityId,
				name: legalRepresentative.name
			}] : [];
		}
		return [{
			id: legalEntityResponse.id,
			name: `${legalEntityResponse.individual?.name.firstName ?? ""} ${legalEntityResponse.individual?.name.lastName ?? ""}`
		}];
	};
	const signers = getSigners();
	const handleSignClick = async () => {
		const baseTracking = { actionType: "sign" };
		triggerValidation();
		if (loadingStatus === "loading" || !serviceAgreement || !data.signer) return;
		if (isValid) try {
			setLoadingStatus("loading");
			await handleSign(legalEntityResponse.id, serviceAgreement.id, { acceptedBy: data.signer });
			setLoadingStatus("success");
			showToast({
				label: t(($) => $["serviceAgreementSignedSuccessfully"]),
				variant: "success"
			});
			userEvents.addTaskEvent("Success", baseTracking);
			data.acceptServiceAgreement = false;
			data.signer = void 0;
		} catch (e) {
			setLoadingStatus("success");
			showToast({
				label: t(($) => $["signingFailed"]),
				variant: "error"
			});
			userEvents.addTaskEvent("Encountered error", {
				...baseTracking,
				returnType: e?.errorCode || "backend",
				returnValue: e?.title ?? e?.message
			});
		}
		else userEvents.addTaskEvent("Encountered error", {
			...baseTracking,
			returnType: "validation",
			returnValue: Object.entries(valid).filter(([, value]) => !value).map(([key]) => key)
		});
	};
	const handleExpandSection = useCallback((title) => {
		userEvents.addFieldEvent("Clicked accordion", {
			actionType: "open",
			field: title
		});
	}, []);
	useEffect(() => {
		if (!serviceAgreementAcceptanceInfos.length) return;
		gotoForm(serviceAgreementAcceptanceInfos.length - 1);
	}, [serviceAgreementAcceptanceInfos]);
	/**
	* Analytics
	*/
	useTaskLandedEvent("SERVICE_AGREEMENT");
	useEffect(() => {
		gotoForm(forms.length === signedForms.length ? 0 : signedForms.length);
	}, []);
	useEffect(() => {
		userEvents.updateSharedEventProperties({ page: activeForm?.formName });
	}, [activeForm]);
	const gotoForm = (index) => {
		setActiveForm(forms[index]);
		setActiveFormIndex(index);
	};
	const onDownloadAcceptedTermsOfServiceDocument = async () => {
		const { isError, isSuccess, data } = await downloadAcceptedTermsAsPdf();
		if (isSuccess && data.document) await downloadFile(data.document, `${t(($) => $[activeForm.formName], { ns: "common" })}.pdf`);
		if (isError) showToast({
			label: t(($) => $["failedToDownloadAcceptedServiceAgreementDocument"]),
			variant: "error"
		});
	};
	const onDownloadUnacceptedTermsOfServiceDocument = async () => {
		const languageCode = getLanguageCode(i18n.language);
		const requestAndDownload = async (languageCode) => {
			const response = await getTermsOfService(rootLegalEntityId.value, baseUrl.value, {
				type: activeForm.serviceAgreementType,
				language: languageCode,
				termsOfServiceDocumentFormat: "PDF"
			});
			if (!response.document) throw new Error(`No terms Of service document found in response`);
			await downloadFile(response.document, `${t(($) => $[activeForm.formName], { ns: "common" })}.pdf`);
		};
		try {
			if (["fr", "en"].includes(i18n.language)) await requestAndDownload(languageCode);
			await requestAndDownload("en");
		} catch {
			if (languageCode !== FALLBACK_LANGUAGE_CODE) {
				await requestAndDownload(FALLBACK_LANGUAGE_CODE).catch(logger.error);
				return;
			}
			showToast({
				label: t(($) => $["failedToDownloadServiceAgreementDocument"]),
				variant: "error"
			});
		}
	};
	const isIndividual = legalEntityResponse.type === "individual";
	const addSignerAlert = handleAddSigner && /* @__PURE__ */ jsx(Alert, {
		variant: signers.length ? "info" : "warning",
		className: "u-margin-top-16",
		title: t(($) => $[signers.length ? "isYourNameMissingFromSigners" : "thereAreNoSigners"]),
		children: /* @__PURE__ */ jsx(Button, {
			onClick: handleAddSigner,
			variant: "link",
			children: t(($) => $["addYourselfAsSigner"])
		})
	});
	const getSignedName = (acceptanceId) => {
		if (!acceptanceId) return "";
		const signatory = serviceAgreementAcceptanceInfos.find(({ id }) => id === acceptanceId);
		return (legalEntityResponse.entityAssociations?.find(({ legalEntityId }) => legalEntityId === signatory?.acceptedBy))?.name ?? getLegalEntityNameBasedOnType(legalEntityResponse);
	};
	const signedAlert = showSignedAlert && /* @__PURE__ */ jsx(Alert, {
		variant: "success",
		className: ServiceAgreementDropin_module_default.tosSignedAlert,
		title: t(($) => $["signedByOn"], {
			date: localizeDateString(activeForm.createdAt, i18n.language) ?? "",
			signer: getSignedName(activeForm.acceptanceId)
		})
	});
	const sidebar = /* @__PURE__ */ jsx(LoaderWrapper, {
		status: loadingStatus,
		formOpacityWhenLoading: .3,
		showSpinner: false,
		className: "adyen-kyc-dropin__sidebar-wrapper",
		children: /* @__PURE__ */ jsx(FormNavigation, {
			forms,
			activeForm,
			gotoForm,
			taskName: "signServiceAgreement",
			className: "u-margin-bottom-24"
		})
	});
	const content = /* @__PURE__ */ jsxs(LoaderWrapper, {
		status: loadingStatus,
		formOpacityWhenLoading: .3,
		showSpinner: false,
		className: "adyen-kyc-form-container",
		children: [/* @__PURE__ */ jsxs(LoaderWrapper, {
			status: contractLoadingStatus,
			formOpacityWhenLoading: .3,
			showSpinner: false,
			children: [serviceAgreement && /* @__PURE__ */ jsxs(StackLayout, { children: [
				signedAlert,
				/* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(ContractViewer, {
					contract: serviceAgreement.contract,
					onExpandSection: handleExpandSection,
					showSectionNumbering: true
				}) }),
				/* @__PURE__ */ jsx(Button, {
					variant: "secondary",
					onClick: activeForm?.acceptanceId ? onDownloadAcceptedTermsOfServiceDocument : onDownloadUnacceptedTermsOfServiceDocument,
					icon: "download",
					children: t(($) => $["downloadAsPdf"])
				})
			] }), !forms.length && /* @__PURE__ */ jsx(Alert, {
				variant: "info",
				title: t(($) => $["nothingNeedsToBeSigned"])
			})]
		}), canSign && /* @__PURE__ */ jsxs(Fragment, { children: [
			!!signers.length && /* @__PURE__ */ jsx(Field, {
				name: "signer",
				label: t(($) => $["signer"]),
				className: ServiceAgreementDropin_module_default.tosSignerField,
				errorMessage: errors.signer?.errorMessage,
				isValid: valid.signer,
				dataTestId: "signer",
				children: (childProps) => /* @__PURE__ */ jsx(Select, {
					...childProps,
					onChange: handleChangeFor("signer", "blur"),
					name: "signer",
					placeholder: t(($) => $["selectSigner"]),
					selected: data.signer,
					items: signers
				})
			}),
			!isIndividual && addSignerAlert,
			/* @__PURE__ */ jsx(Field, {
				name: "acceptServiceAgreement",
				className: "u-margin-top-16",
				errorMessage: errors.acceptServiceAgreement?.errorMessage,
				isValid: valid.acceptServiceAgreement,
				children: (childProps) => /* @__PURE__ */ jsx(Checkbox, {
					...childProps,
					label: t(($) => $[acceptanceMessageKey], { ns: "contract" }),
					checked: data.acceptServiceAgreement ?? false,
					name: "acceptServiceAgreement",
					onChange: handleChangeFor("acceptServiceAgreement")
				})
			})
		] })]
	});
	const currentStep = signedForms.length;
	const totalSteps = forms.length;
	const handleClick = () => {
		if (canSign) handleSignClick();
		else if (!isLastStep) gotoForm(activeFormIndex + 1);
		else setHasFinished(true);
	};
	/** The finish button needs to trigger both consumer onClose and onComplete */
	const handleFinishClick = () => {
		handleCloseClick();
		onComplete?.();
	};
	const endScreen = hasFinished && /* @__PURE__ */ jsx(EndStateLayout, {
		title: t(($) => $["serviceAgreementSignedAndDated"]),
		action: /* @__PURE__ */ jsx(Button, {
			onClick: handleFinishClick,
			fullWidth: true,
			children: t(($) => $["finish"], { ns: "common" })
		})
	});
	const progress = Math.floor(currentStep / (totalSteps - 1) * 100);
	return /* @__PURE__ */ jsx(MaybeModal, {
		inline: !asModal,
		onClose: handleCloseClick,
		children: /* @__PURE__ */ jsxs("div", {
			className: ServiceAgreementDropin_module_default.tosContainer,
			children: [/* @__PURE__ */ jsxs("div", {
				className: ServiceAgreementDropin_module_default.tosContent,
				children: [!asEmbedded && sidebar, endScreen || content]
			}), !hasFinished && /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(ProgressBar, {
				ariaLabel: t(($) => $["progress"], { ns: "common" }),
				progress
			}), /* @__PURE__ */ jsxs("div", {
				className: ServiceAgreementDropin_module_default.tosActions,
				children: [isFirstStep ? showInitialBackButton && /* @__PURE__ */ jsx(Button, {
					onClick: handleCloseClick,
					variant: "secondary",
					children: t(($) => $["cancel"], { ns: "common" })
				}) : /* @__PURE__ */ jsx(Button, {
					icon: "chevron-left",
					onClick: () => {
						gotoForm(activeFormIndex - 1);
					},
					variant: "secondary",
					children: t(($) => $["back"], { ns: "common" })
				}), /* @__PURE__ */ jsx(Button, {
					variant: canSign ? "primary" : "secondary",
					onClick: handleClick,
					children: canSign ? t(($) => $["sign"], { ns: "common" }) : t(($) => $["continue"], { ns: "common" })
				})]
			})] })]
		})
	});
}
//#endregion
//#region src/components/EmbeddedDropins/AcceptTermsOfServiceComponent/AcceptTermsOfServiceComponent.tsx
var AcceptTermsOfServiceComponent_exports = /* @__PURE__ */ __exportAll({ AcceptTermsOfServiceComponent: () => AcceptTermsOfServiceComponent });
function AcceptTermsOfServiceComponent({ legalEntityId, modalView = false, asEmbedded = true, onClose, onComplete, onUnmount, onAccept, handleAddSigner }) {
	if (!legalEntityId) throw new Error("Must provide at-least a legalEntityId");
	const { i18n } = useTranslation();
	addResourceBundles(i18n, [
		{
			ns: "common",
			importFn: (lang) => _rolldown_dynamic_import_helper_default(/* @__PURE__ */ Object.assign({
				"../../../language/locales/bg-BG.json": () => import("./bg-BG-NwL6SZRu.js"),
				"../../../language/locales/cs-CZ.json": () => import("./cs-CZ-BZkot6xs.js"),
				"../../../language/locales/da-DK.json": () => import("./da-DK-Bc6oX5Ct.js"),
				"../../../language/locales/de-DE.json": () => import("./de-DE-JZBqb8ce.js"),
				"../../../language/locales/el-GR.json": () => import("./el-GR-C8jFvyDg.js"),
				"../../../language/locales/en-US.instructions.json": () => import("./en-US.instructions-DlxMDbRu.js"),
				"../../../language/locales/en-US.json": () => import("./en-US-Cq6Cl6Yl.js"),
				"../../../language/locales/es-ES.json": () => import("./es-ES-mdSA-CIT.js"),
				"../../../language/locales/et-EE.json": () => import("./et-EE-B4ZMHksf.js"),
				"../../../language/locales/fi-FI.json": () => import("./fi-FI-koFpyMaq.js"),
				"../../../language/locales/fr-FR.json": () => import("./fr-FR-B0eVVc8V.js"),
				"../../../language/locales/hr-HR.json": () => import("./hr-HR-D_X-RNUl.js"),
				"../../../language/locales/hu-HU.json": () => import("./hu-HU-3FpAw9b1.js"),
				"../../../language/locales/it-IT.json": () => import("./it-IT-BgULENxX.js"),
				"../../../language/locales/ja-JP.json": () => import("./ja-JP-BT70_5Cd.js"),
				"../../../language/locales/lt-LT.json": () => import("./lt-LT-CKltvr9j.js"),
				"../../../language/locales/lv-LV.json": () => import("./lv-LV-DwsdNJrk.js"),
				"../../../language/locales/nl-NL.json": () => import("./nl-NL-CxlTSECX.js"),
				"../../../language/locales/no-NO.json": () => import("./no-NO-FtH9gIpv.js"),
				"../../../language/locales/pl-PL.json": () => import("./pl-PL-CK40GB3R.js"),
				"../../../language/locales/pt-BR.json": () => import("./pt-BR-zUBVM8_b.js"),
				"../../../language/locales/pt-PT.json": () => import("./pt-PT-CxnB9Jff.js"),
				"../../../language/locales/ro-RO.json": () => import("./ro-RO-Cuw1RmFc.js"),
				"../../../language/locales/sk-SK.json": () => import("./sk-SK-1i0L4zIs.js"),
				"../../../language/locales/sl-SI.json": () => import("./sl-SI-D3zK3MPP.js"),
				"../../../language/locales/sv-SE.json": () => import("./sv-SE-CVRa-6Y0.js")
			}), `../../../language/locales/${lang}.json`, 6)
		},
		{
			ns: "contract",
			importFn: (lang) => _rolldown_dynamic_import_helper_default(/* @__PURE__ */ Object.assign({
				"../../Contract/language/bg-BG.json": () => import("./bg-BG-mf-xq3ph.js"),
				"../../Contract/language/cs-CZ.json": () => import("./cs-CZ-B_nYIuIi.js"),
				"../../Contract/language/da-DK.json": () => import("./da-DK-CBt4gQjw.js"),
				"../../Contract/language/de-DE.json": () => import("./de-DE-D8Is4iJk.js"),
				"../../Contract/language/el-GR.json": () => import("./el-GR-BZ9AJNm4.js"),
				"../../Contract/language/en-US.json": () => import("./en-US-BhctnSAK.js"),
				"../../Contract/language/es-ES.json": () => import("./es-ES-B2MIlPdM.js"),
				"../../Contract/language/et-EE.json": () => import("./et-EE-Lw-rTsG-.js"),
				"../../Contract/language/fi-FI.json": () => import("./fi-FI-TDF0ZiiC.js"),
				"../../Contract/language/fr-FR.json": () => import("./fr-FR-fwcu0Hmd.js"),
				"../../Contract/language/hr-HR.json": () => import("./hr-HR-dL_cUkZa.js"),
				"../../Contract/language/hu-HU.json": () => import("./hu-HU-ReTWA1v3.js"),
				"../../Contract/language/it-IT.json": () => import("./it-IT-C2JfprsD.js"),
				"../../Contract/language/ja-JP.json": () => import("./ja-JP-BRGxY7zc.js"),
				"../../Contract/language/lt-LT.json": () => import("./lt-LT-_MAUl9-y.js"),
				"../../Contract/language/lv-LV.json": () => import("./lv-LV-Br4-Sv0n.js"),
				"../../Contract/language/nl-NL.json": () => import("./nl-NL-ByNQn3Ma.js"),
				"../../Contract/language/no-NO.json": () => import("./no-NO-CX2Lkpbt.js"),
				"../../Contract/language/pl-PL.json": () => import("./pl-PL-W0KU0YTp.js"),
				"../../Contract/language/pt-BR.json": () => import("./pt-BR-CdeMGenL.js"),
				"../../Contract/language/pt-PT.json": () => import("./pt-PT-BEkfXdZQ.js"),
				"../../Contract/language/ro-RO.json": () => import("./ro-RO-tf_g2ahZ.js"),
				"../../Contract/language/sk-SK.json": () => import("./sk-SK-DaSC7QsL.js"),
				"../../Contract/language/sl-SI.json": () => import("./sl-SI-C6KiyZyh.js"),
				"../../Contract/language/sv-SE.json": () => import("./sv-SE-CTB2971Y.js")
			}), `../../Contract/language/${lang}.json`, 5)
		},
		{
			ns: "ui",
			importFn: (lang) => _rolldown_dynamic_import_helper_default(/* @__PURE__ */ Object.assign({
				"../../ui/language/bg-BG.json": () => import("./bg-BG-IjNKw0Zu.js"),
				"../../ui/language/cs-CZ.json": () => import("./cs-CZ-B6AZX4nL.js"),
				"../../ui/language/da-DK.json": () => import("./da-DK-B8aHvZ1W.js"),
				"../../ui/language/de-DE.json": () => import("./de-DE-cPL-uSMG.js"),
				"../../ui/language/el-GR.json": () => import("./el-GR-BDXwftjw.js"),
				"../../ui/language/en-US.json": () => import("./en-US-_l9425V1.js"),
				"../../ui/language/es-ES.json": () => import("./es-ES-D67pkLVu.js"),
				"../../ui/language/et-EE.json": () => import("./et-EE-Dg93VJbx.js"),
				"../../ui/language/fi-FI.json": () => import("./fi-FI-BNtrKnDN.js"),
				"../../ui/language/fr-FR.json": () => import("./fr-FR-DYDmBWWT.js"),
				"../../ui/language/hr-HR.json": () => import("./hr-HR-DbebVQF9.js"),
				"../../ui/language/hu-HU.json": () => import("./hu-HU-e9KN8lp6.js"),
				"../../ui/language/it-IT.json": () => import("./it-IT-16IjDttL.js"),
				"../../ui/language/ja-JP.json": () => import("./ja-JP-CJY6uqPb.js"),
				"../../ui/language/lt-LT.json": () => import("./lt-LT-BVVTYN3z.js"),
				"../../ui/language/lv-LV.json": () => import("./lv-LV-BeobSRYx.js"),
				"../../ui/language/nl-NL.json": () => import("./nl-NL-DKpjFbpm.js"),
				"../../ui/language/no-NO.json": () => import("./no-NO-CG5RteG_.js"),
				"../../ui/language/pl-PL.json": () => import("./pl-PL-R6bNjSQB.js"),
				"../../ui/language/pt-BR.json": () => import("./pt-BR-VlNZLr8f.js"),
				"../../ui/language/pt-PT.json": () => import("./pt-PT-Dmor9x6o.js"),
				"../../ui/language/ro-RO.json": () => import("./ro-RO-BRtHlgch.js"),
				"../../ui/language/sk-SK.json": () => import("./sk-SK--ohjuOMW.js"),
				"../../ui/language/sl-SI.json": () => import("./sl-SI-DWJzi8r_.js"),
				"../../ui/language/sv-SE.json": () => import("./sv-SE-DTpqjuJd.js")
			}), `../../ui/language/${lang}.json`, 5)
		}
	]);
	const [stepsData, setStepsData] = useState({
		unAcceptedTermsOfServiceTypes: [],
		acceptedTermsOfServices: []
	});
	const { data: legalEntity } = useLegalEntity(ROOT_LE);
	const { data: serviceAgreementStatus, isLoading: isStatusLoading } = useTermsOfServiceStatus();
	const { data: serviceAgreementAcceptanceInfos, isLoading: isAcceptanceInfoLoading } = useTermsOfServiceAcceptanceInfos();
	const { mutateAsync: acceptTermsOfService } = useAcceptTermsOfService();
	const handleOnClose = () => {
		if (modalView) onUnmount?.();
		onClose?.();
	};
	const handleSign = useCallback(async (legalEntityId, termsOfServiceDocumentId, signedBy) => {
		const acceptedTermsOfService = await acceptTermsOfService({
			acceptedBy: signedBy.acceptedBy,
			legalEntityReference: legalEntityId,
			termsOfServiceDocumentId
		});
		const paramAllowList = {
			type: acceptedTermsOfService.type,
			acceptedBy: acceptedTermsOfService.acceptedBy,
			id: acceptedTermsOfService.id,
			language: acceptedTermsOfService.language,
			termsOfServiceDocumentId: acceptedTermsOfService.termsOfServiceDocumentId
		};
		const { acceptedTermsOfServices } = stepsData;
		acceptedTermsOfServices.push(paramAllowList);
		const newStepsData = {
			unAcceptedTermsOfServiceTypes: serviceAgreementStatus?.termsOfServiceTypes?.filter((tosType) => tosType !== acceptedTermsOfService.type) ?? [],
			acceptedTermsOfServices
		};
		setStepsData(newStepsData);
		onAccept?.(newStepsData);
	}, [
		onAccept,
		stepsData,
		acceptTermsOfService,
		serviceAgreementStatus?.termsOfServiceTypes
	]);
	const handleOnComplete = () => {
		onComplete?.(stepsData);
	};
	return isStatusLoading || isAcceptanceInfoLoading || !legalEntity ? /* @__PURE__ */ jsx(Loader, {}) : /* @__PURE__ */ jsx(ServiceAgreementDropin, {
		taskType: TaskTypes.SERVICE_AGREEMENT,
		legalEntityResponse: legalEntity,
		serviceAgreementTypes: serviceAgreementStatus?.termsOfServiceTypes ?? [],
		serviceAgreementAcceptanceInfos: serviceAgreementAcceptanceInfos?.data ?? [],
		handleSign,
		asEmbedded,
		asModal: modalView,
		handleCloseClick: handleOnClose,
		showInitialBackButton: !!onClose,
		onComplete: handleOnComplete,
		handleAddSigner
	});
}
//#endregion
export { AcceptTermsOfServiceComponent_exports as n, AcceptTermsOfServiceComponent as t };
