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] = "a237c1ca-b52f-4eb4-b2fa-7fe78b50752f", e._sentryDebugIdIdentifier = "sentry-dbid-a237c1ca-b52f-4eb4-b2fa-7fe78b50752f");
} catch (e) {}
import { i as Typography, n as addResourceBundles, o as createLogger, r as useTranslation } from "./translation-Br5wIPO-.js";
import { i as stylesheets, n as EmbedShell, t as resolveEnvironment } from "./resolveEnvironment-BcrJH82n.js";
import { r as Loader, t as Button } from "./Button-BDEdGXnd.js";
import { n as httpGet, s as useApiContext } from "./http-CHTzpXCd.js";
import { c as entriesOf, n as cloneObject } from "./AnalyticsContext-C0HNdPss.js";
import { t as _rolldown_dynamic_import_helper_default } from "./_rolldown_dynamic_import_helper-CCXvMgfE.js";
import { i as TaskStatuses } from "./taskStatus-CvMqhrOK.js";
import { t as useDataset } from "./useDataset-BRZZoPVn.js";
import { n as datasetUtilities, t as datasetIdentifier } from "./datasetUtil-BZmNUckr.js";
import { t as Alert } from "./Alert-CjZYipjN.js";
import { n as getCapabilityProblems } from "./processCapabilities-CDSEJpB8.js";
import { t as Card } from "./Card-DXdUqwyQ.js";
import { t as useToastContext } from "./useToastContext-CK7UoZ5Z.js";
import { t as useDeleteTransferInstrument } from "./useDeleteTransferInstrument-CZM3f7yq.js";
import { t as VerificationErrorAlert } from "./VerificationErrorAlert-x74LQ1wJ.js";
import { t as Modal } from "./Modal-DOC6JgPI.js";
import { t as Confirm } from "./Confirm-BqhBxIWm.js";
import { t as StructuredList } from "./StructuredList-S4LIZQiJ.js";
import { t as emitAdyenSdkEvent } from "./emitEvent-DYC1em5m.js";
import { t as Tag } from "./Tag-BTQ4nyKS.js";
import { n as statusToTag, t as EmbeddedStatus } from "./EmbeddedStatus-Ch7vvcve.js";
import { n as useTransferInstrument, t as mapTransferInstrumentToPayoutAccount } from "./mapTransferInstrumentToPayoutAccount-DUrX63iT.js";
import { t as currencyByCountry } from "./types-DjplYXLf.js";
import { t as DetailViewLayout } from "./DetailViewLayout-H4b1E5Ih.js";
import register from "preact-custom-element";
import { useRef, useState } from "preact/hooks";
import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
import { useQuery } from "@tanstack/preact-query";
//#region src/api/transferInstruments/useTransferInstruments.ts
var getTransferInstruments = async (legalEntityId, baseUrl) => {
	return httpGet({
		baseUrl,
		path: `legalEntities/${legalEntityId}/transferInstruments`
	});
};
/**
* Gets a list of transfer instruments associated with a legal entity
* @param options additional options passed to Tanstack Query, eg; refetchInterval for polling
*/
var useTransferInstruments = (options) => {
	const { rootLegalEntityId, baseUrl } = useApiContext();
	return useQuery({
		queryKey: ["transferInstruments"],
		queryFn: () => getTransferInstruments(rootLegalEntityId.value, baseUrl.value),
		...options
	});
};
//#endregion
//#region src/components/EmbeddedDropins/ManageTransferInstrumentComponent/ManageTransferInstrumentOverviewItemModal/ManageTransferInstrumentOverviewItemModal.tsx
function ManageTransferInstrumentOverviewItemModal({ status, transferInstrument, onEdit, onClose, onRemove, onInitiateRemove }) {
	const { t } = useTranslation("ui");
	const { t: tCommon, i18n } = useTranslation("common");
	const [confirmOpen, setConfirmOpen] = useState(false);
	const datasetUtils = datasetUtilities(i18n.language);
	const isReviewInProgress = status === "PROCESSING";
	const showEditButton = !transferInstrument?.bankAccount.trustedSource;
	const problems = transferInstrument ? getCapabilityProblems(transferInstrument, transferInstrument.bankAccount.countryCode) : {};
	const formatDataForStructuredList = (data) => {
		const summaryData = cloneObject(data);
		if (!summaryData.payoutAccountDetails) return [];
		if (summaryData.payoutVerificationMethod?.bankCountry) {
			summaryData.payoutAccountDetails.bankCountry = datasetUtils.getCountryName(summaryData.payoutVerificationMethod.bankCountry);
			summaryData.payoutAccountDetails.currency = currencyByCountry[summaryData.payoutVerificationMethod.bankCountry]?.[0];
		}
		delete summaryData.payoutAccountDetails.transferInstrumentId;
		return entriesOf(summaryData.payoutAccountDetails).map(([key, value]) => ({
			term: tCommon(($) => $[key]),
			details: value
		}));
	};
	const getStatusTag = () => {
		const statusTagProps = statusToTag(TaskStatuses[status], t);
		if (!statusTagProps) return;
		return /* @__PURE__ */ jsx(Tag, {
			variant: statusTagProps.variant,
			children: statusTagProps.text
		});
	};
	const getPayoutDetailSummary = (ti) => {
		const mappedTI = formatDataForStructuredList(mapTransferInstrumentToPayoutAccount(ti));
		const statusTag = getStatusTag();
		mappedTI.push({
			term: tCommon(($) => $["status"]),
			details: statusTag
		});
		return mappedTI;
	};
	const getStructuredLists = () => {
		if (!transferInstrument) return [];
		const summaries = [];
		summaries.push(getPayoutDetailSummary(transferInstrument));
		if (transferInstrument.documentDetails) summaries.push([
			{
				term: tCommon(($) => $["verificationMethod"]),
				details: tCommon(($) => $["documentUpload"])
			},
			{
				term: tCommon(($) => $["documentType"]),
				details: tCommon(($) => {
					return $[transferInstrument.documentDetails[0]?.type];
				})
			},
			{
				term: tCommon(($) => $["documentName"]),
				details: transferInstrument.documentDetails[0]?.fileName
			}
		]);
		return summaries;
	};
	const handleRemove = async () => {
		await onRemove(transferInstrument.id);
		onClose();
	};
	const handleDeleteClick = async () => {
		if (onInitiateRemove) {
			if (onInitiateRemove()) await handleRemove();
		} else setConfirmOpen(true);
	};
	const actions = /* @__PURE__ */ jsxs(Fragment, { children: [transferInstrument && showEditButton && /* @__PURE__ */ jsx(Button, {
		onClick: () => onEdit(transferInstrument.id),
		disabled: isReviewInProgress,
		children: tCommon(($) => $["edit"])
	}), /* @__PURE__ */ jsx(Button, {
		variant: "secondary",
		onClick: handleDeleteClick,
		disabled: isReviewInProgress,
		children: tCommon(($) => $["delete"])
	})] });
	return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Modal, {
		onClose,
		ariaLabel: tCommon(($) => $["bankAccount"]),
		inset: true,
		children: !transferInstrument ? /* @__PURE__ */ jsx(Loader, {}) : /* @__PURE__ */ jsxs(DetailViewLayout, {
			title: tCommon(($) => $["bankAccount"]),
			actions,
			compact: true,
			children: [!!problems.BankAccount?.[transferInstrument.id]?.verificationErrors && /* @__PURE__ */ jsx(VerificationErrorAlert, {
				problems: problems.BankAccount?.[transferInstrument.id],
				children: /* @__PURE__ */ jsx(Button, {
					variant: "link",
					onClick: () => onEdit(transferInstrument.id),
					children: tCommon(($) => $["editDetails"])
				})
			}), getStructuredLists().map((listItems) => /* @__PURE__ */ jsx(Card, {
				variant: "secondary",
				children: /* @__PURE__ */ jsx(StructuredList, { items: listItems })
			}, listItems))]
		})
	}), confirmOpen && /* @__PURE__ */ jsx(Confirm, {
		title: tCommon(($) => $["areYouSureYouWantToDeleteThisBankAccount"]),
		onConfirm: handleRemove,
		confirmText: tCommon(($) => $["delete"]),
		onCancel: () => setConfirmOpen(false),
		critical: true
	})] });
}
//#endregion
//#region src/components/EmbeddedDropins/ManageTransferInstrumentComponent/ManageTransferInstrumentOverviewItem/ManageTransferInstrumentOverviewItem.tsx
function ManageTransferInstrumentOverviewItem({ transferInstrumentReference, onEdit, onRemove, onInitiateRemove }) {
	const { t } = useTranslation("common");
	const { status, transferInstrument: transferInstrumentRef } = transferInstrumentReference;
	const [fetchedTi, setFetchedTi] = useState(false);
	const [modalOpen, setModalOpen] = useState(false);
	const { data: transferInstrument } = useTransferInstrument(transferInstrumentRef.id, { enabled: fetchedTi });
	const isDetailsRequired = status === "DETAILS_REQUIRED";
	const accountIdentifier = transferInstrumentRef.accountIdentifier?.replaceAll("*", "•");
	const handleClick = () => {
		if (!fetchedTi) setFetchedTi(true);
		if (isDetailsRequired) {
			onEdit(transferInstrumentRef.id);
			return;
		}
		setModalOpen(true);
	};
	return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(EmbeddedStatus, {
		status: TaskStatuses[status],
		iconName: "bank",
		title: accountIdentifier,
		subtitle: t(($) => $["bankAccount"]),
		onClick: handleClick,
		actionIndicator: isDetailsRequired ? { text: t(($) => $["continue"]) } : void 0,
		"aria-label": `${t(($) => $["bankAccount"])} ${accountIdentifier}`
	}), modalOpen && /* @__PURE__ */ jsx(ManageTransferInstrumentOverviewItemModal, {
		transferInstrument,
		onEdit,
		onRemove,
		onInitiateRemove,
		onClose: () => setModalOpen(false),
		status
	})] });
}
//#endregion
//#region src/components/EmbeddedDropins/ManageTransferInstrumentComponent/ManageTransferInstrumentOverview/ManageTransferInstrumentOverview.tsx
function ManageTransferInstrumentOverview({ transferInstrumentReferences, legalEntityId, onEdit, onAdd, onRemove, onInitiateRemove }) {
	const { t } = useTranslation("common");
	const transferInstrumentListEle = transferInstrumentReferences?.map((transferInstrumentRef) => {
		if (!transferInstrumentRef?.transferInstrument?.id || !transferInstrumentRef.status) return;
		return /* @__PURE__ */ jsx(ManageTransferInstrumentOverviewItem, {
			transferInstrumentReference: transferInstrumentRef,
			onEdit,
			onRemove,
			onInitiateRemove
		}, transferInstrumentRef.transferInstrument?.id);
	});
	return /* @__PURE__ */ jsxs("section", {
		className: "adyen-kyc-manage-ti-overview",
		children: [transferInstrumentListEle, /* @__PURE__ */ jsx(EmbeddedStatus, {
			title: t(($) => $["addBankAccount"]),
			iconName: "plus",
			light: true,
			onClick: () => onAdd(legalEntityId),
			"aria-label": t(($) => $["addBankAccount"])
		})]
	});
}
//#endregion
//#region src/components/EmbeddedDropins/ManageTransferInstrumentComponent/ManageTransferInstrumentComponent.tsx
var REFETCH_INTERVAL = 3e3;
var logger = createLogger();
function ManageTransferInstrumentComponent({ legalEntityId, onAdd, onEdit, onInitiateRemove, onRemoveSuccess }) {
	const { rootLegalEntityId: currentLegalEntityId } = useApiContext();
	currentLegalEntityId.value = legalEntityId;
	const { t, i18n: i18next } = useTranslation(["common", "banking"]);
	const { showToast } = useToastContext();
	const { mutateAsync: deleteTransferInstrument } = useDeleteTransferInstrument();
	addResourceBundles(i18next, [
		{
			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: "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)
		},
		{
			ns: "banking",
			importFn: (lang) => _rolldown_dynamic_import_helper_default(/* @__PURE__ */ Object.assign({
				"../../BankAccount/language/bg-BG.json": () => import("./bg-BG-C12I_ehJ.js"),
				"../../BankAccount/language/cs-CZ.json": () => import("./cs-CZ-TiWySd9u.js"),
				"../../BankAccount/language/da-DK.json": () => import("./da-DK-DtPE4OIu.js"),
				"../../BankAccount/language/de-DE.json": () => import("./de-DE-CnB43wjo.js"),
				"../../BankAccount/language/el-GR.json": () => import("./el-GR-DJJbbbY3.js"),
				"../../BankAccount/language/en-US.json": () => import("./en-US-BxBNcm3S.js"),
				"../../BankAccount/language/es-ES.json": () => import("./es-ES-FQbC3B0S.js"),
				"../../BankAccount/language/et-EE.json": () => import("./et-EE-DrQLDWH2.js"),
				"../../BankAccount/language/fi-FI.json": () => import("./fi-FI-CqM2eaKi.js"),
				"../../BankAccount/language/fr-FR.json": () => import("./fr-FR-CqvZpq5B.js"),
				"../../BankAccount/language/hr-HR.json": () => import("./hr-HR-C_7O4gxx.js"),
				"../../BankAccount/language/hu-HU.json": () => import("./hu-HU-DORWpwoE.js"),
				"../../BankAccount/language/it-IT.json": () => import("./it-IT-CW0ZFuCZ.js"),
				"../../BankAccount/language/ja-JP.json": () => import("./ja-JP-BllN9kcD.js"),
				"../../BankAccount/language/lt-LT.json": () => import("./lt-LT-DZvEoBgI.js"),
				"../../BankAccount/language/lv-LV.json": () => import("./lv-LV-DPQ4Tm3o.js"),
				"../../BankAccount/language/nl-NL.json": () => import("./nl-NL-Br1QBepE.js"),
				"../../BankAccount/language/no-NO.json": () => import("./no-NO-BSrcMnDk.js"),
				"../../BankAccount/language/pl-PL.json": () => import("./pl-PL-CxlgXMRg.js"),
				"../../BankAccount/language/pt-BR.json": () => import("./pt-BR-kU7AfzPy.js"),
				"../../BankAccount/language/pt-PT.json": () => import("./pt-PT-hj7CUska.js"),
				"../../BankAccount/language/ro-RO.json": () => import("./ro-RO-CmHNsQpo.js"),
				"../../BankAccount/language/sk-SK.json": () => import("./sk-SK-CtsgM8bj.js"),
				"../../BankAccount/language/sl-SI.json": () => import("./sl-SI-DywGyzEa.js"),
				"../../BankAccount/language/sv-SE.json": () => import("./sv-SE-BN0dUpwI.js")
			}), `../../BankAccount/language/${lang}.json`, 5)
		}
	]);
	const { data: transferInstrumentReferences, isLoading, isError } = useTransferInstruments({
		refetchOnMount: "always",
		refetchInterval: (query) => query.state.data?.every(({ status }) => status === "FINISHED") ? 0 : REFETCH_INTERVAL
	});
	useDataset(datasetIdentifier.country);
	const onRemove = async (transferInstrumentId) => {
		try {
			await deleteTransferInstrument(transferInstrumentId);
			onRemoveSuccess?.(transferInstrumentId, legalEntityId);
		} catch (e) {
			showToast({
				label: t(($) => $["thereWasAnErrorTryAgain"]),
				variant: "error"
			});
			logger.error(e);
		}
	};
	const render = () => {
		if (isLoading) return /* @__PURE__ */ jsx(EmbeddedStatus, { loading: true });
		if (isError) return /* @__PURE__ */ jsx(Alert, {
			title: t(($) => $["sorryAnErrorOccurred"]),
			variant: "error"
		});
		return /* @__PURE__ */ jsxs(Fragment, { children: [!transferInstrumentReferences?.length && /* @__PURE__ */ jsxs("div", {
			className: "u-margin-bottom-12",
			children: [/* @__PURE__ */ jsx(Typography, {
				el: "h1",
				variant: "title-l",
				children: t(($) => $["bankDetails"])
			}), /* @__PURE__ */ jsx(Typography, { children: t(($) => $["addMissingBankDetails"]) })]
		}), /* @__PURE__ */ jsx(ManageTransferInstrumentOverview, {
			transferInstrumentReferences,
			onEdit: (transferInstrumentId) => onEdit(transferInstrumentId, legalEntityId),
			onRemove,
			onInitiateRemove,
			onAdd,
			legalEntityId
		})] });
	};
	return /* @__PURE__ */ jsx("div", {
		className: "adyen-kyc-manage-transfer-instrument",
		children: render()
	});
}
//#endregion
//#region src/embeds/transfer-instrument-management/adyen-transfer-instrument-management.tsx
var AdyenManageTransferInstruments = ({ rootlegalentityid, fetchToken, environment, locale, settings = {}, experiments = {} }) => {
	const eventEmitterRef = useRef(null);
	const handleOnAdd = (rootLegalEntityId) => {
		emitAdyenSdkEvent(eventEmitterRef, "add", rootLegalEntityId);
	};
	const handleOnEdit = (transferInstrumentId) => {
		emitAdyenSdkEvent(eventEmitterRef, "edit", transferInstrumentId);
	};
	const handleOnRemove = (transferInstrumentId) => {
		emitAdyenSdkEvent(eventEmitterRef, "remove", transferInstrumentId);
	};
	return /* @__PURE__ */ jsx("div", {
		ref: eventEmitterRef,
		style: "width:100%;",
		children: /* @__PURE__ */ jsx(EmbedShell, {
			componentName: "adyen-transfer-instrument-management",
			rootLegalEntityId: rootlegalentityid,
			settings,
			features: experiments,
			getSdkToken: fetchToken,
			locale,
			baseUrl: resolveEnvironment(environment),
			children: /* @__PURE__ */ jsx(ManageTransferInstrumentComponent, {
				legalEntityId: rootlegalentityid,
				onAdd: handleOnAdd,
				onEdit: handleOnEdit,
				onRemoveSuccess: handleOnRemove
			})
		})
	});
};
register(AdyenManageTransferInstruments, "adyen-transfer-instrument-management", [
	"rootlegalentityid",
	"fetchToken",
	"environment",
	"locale",
	"settings",
	"experiments"
], {
	shadow: true,
	adoptedStyleSheets: stylesheets
});
//#endregion
