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] = "58b2e2eb-4f25-45ab-9572-e0c6523ea9a6", e._sentryDebugIdIdentifier = "sentry-dbid-58b2e2eb-4f25-45ab-9572-e0c6523ea9a6");
} catch (e) {}
import { a as Icon, r as useTranslation } from "./translation-Br5wIPO-.js";
import { n as IconButton } from "./Button-BDEdGXnd.js";
import { t as TaskVerificationStatus } from "./TaskVerificationStatus-jBBIJN_A.js";
import { i as TaskStatuses } from "./taskStatus-CvMqhrOK.js";
import { t as Alert } from "./Alert-CjZYipjN.js";
import { t as getCapabilities } from "./processCapabilities-CDSEJpB8.js";
import { t as Card } from "./Card-DXdUqwyQ.js";
import { t as useAnalyticsContext } from "./useAnalyticsContext-DfTXpZbA.js";
import { t as Avatar } from "./Avatar-4gshS6xA.js";
import { t as LoaderWrapper } from "./LoaderWrapper-CRf5MAK1.js";
import { t as VerificationErrorAlert } from "./VerificationErrorAlert-x74LQ1wJ.js";
import { t as Confirm } from "./Confirm-BqhBxIWm.js";
import { useState } from "preact/hooks";
import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
//#region src/adaptiveWorkflow/utils/utils.ts
/** Read a value from a nested object using dot-notation path. */
function getNestedValue(obj, path) {
	return path.split(".").reduce((acc, key) => acc?.[key], obj);
}
/** Write a value into a nested object at a dot-notation path, creating intermediary objects as needed. */
function setNestedValue(obj, path, value) {
	const keys = path.split(".");
	keys.reduce((acc, key, index) => {
		if (index === keys.length - 1) acc[key] = value;
		else {
			if (typeof acc[key] !== "object" || acc[key] === null) acc[key] = {};
			return acc[key];
		}
		return acc;
	}, obj);
}
/**
* Resolve props for components from awe response, some props are diretly provided with value, other
* which depend on other fields are provided in globals.
* @param globals
* @param componentProps
*/
function resolveComponentProps(globals, componentProps) {
	if (!componentProps) return;
	const props = {};
	for (const propName in componentProps) {
		const propData = componentProps[propName];
		props[propName] = propData.type === "global" ? globals[propData.value]?.value : propData.value;
	}
	return props;
}
/**
* Check if adaptive POC can be shown
* @param isPocEnabled feature toggle
* @param legalEntityData legal entity data to check the BBA capability
*/
var canShowAdaptivePoc = function(isPocEnabled, legalEntityData) {
	return isPocEnabled && getCapabilities(legalEntityData).includes("issueBankAccount");
};
//#endregion
//#region src/components/Apps/tasks/TaskList/TaskListItem.tsx
var TaskListItem = ({ titleKey, title, icon, status, onNavigateToTask, disabled = false, problems, downloadHandler, info, loading = false, showErrorAlerts = "onErrorStatus", warningMessage, deleteEntity, testId, enableTracking = true, fallbackErrorMessage }) => {
	const { t } = useTranslation("common");
	const userEvents = useAnalyticsContext();
	const [isConfirmShown, setIsConfirmShown] = useState(false);
	const isDeletable = !!deleteEntity;
	const isDownloadable = !!downloadHandler && status === TaskStatuses.DOWNLOAD;
	const shouldShowErrorAlert = showErrorAlerts === "always" || showErrorAlerts === "onErrorStatus" && status === TaskStatuses.ERROR || !!problems?.verificationErrors;
	const handleNavigateToTask = () => {
		if (enableTracking) userEvents.addJourneyEvent("Clicked button", {
			actionType: "open",
			task: void 0,
			label: titleKey
		});
		onNavigateToTask?.();
	};
	const avatarVariant = disabled ? "disabled" : "primary";
	const handleRemoveIntent = (event) => {
		event.stopPropagation();
		setIsConfirmShown(true);
	};
	const dismissConfirm = () => {
		setIsConfirmShown(false);
	};
	const getTaskAccessory = () => {
		switch (status) {
			case TaskStatuses.SIGN: return t(($) => $["sign"]);
			case TaskStatuses.DETAILS_REQUIRED:
			case TaskStatuses.EMPTY: return t(($) => $["add"]);
			default: return /* @__PURE__ */ jsx(TaskVerificationStatus, { status });
		}
	};
	return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Card, {
		onClick: handleNavigateToTask,
		disabled: loading || disabled,
		children: /* @__PURE__ */ jsxs(LoaderWrapper, {
			status: loading ? "loading" : "success",
			formOpacityWhenLoading: .3,
			loaderSize: "medium",
			children: [
				/* @__PURE__ */ jsxs("div", {
					className: "adyen-task-item",
					"data-testid": testId,
					children: [/* @__PURE__ */ jsxs("div", {
						className: "adyen-task-item__header",
						children: [/* @__PURE__ */ jsxs("div", {
							className: "adyen-task-item__heading",
							children: [/* @__PURE__ */ jsx(Avatar, {
								variant: avatarVariant,
								iconName: icon
							}), /* @__PURE__ */ jsx("div", {
								className: "adyen-task-item__body",
								children: /* @__PURE__ */ jsx("span", {
									className: "adyen-task-item__title",
									children: title || t(($) => $[titleKey])
								})
							})]
						}), info && /* @__PURE__ */ jsxs("div", {
							className: "adyen-task-item__info",
							children: [/* @__PURE__ */ jsx(Icon, { name: "info-circle" }), /* @__PURE__ */ jsx("span", { children: info })]
						})]
					}), /* @__PURE__ */ jsxs("aside", {
						className: "adyen-task-item__status",
						children: [
							getTaskAccessory(),
							isDownloadable && /* @__PURE__ */ jsx(IconButton, {
								ariaLabel: t(($) => $["download"]),
								icon: "download",
								onClick: downloadHandler,
								variant: "tertiary"
							}),
							isDeletable && /* @__PURE__ */ jsx(IconButton, {
								ariaLabel: t(($) => $["delete"]),
								icon: "bin",
								variant: "tertiary",
								onClick: handleRemoveIntent,
								disabled: isConfirmShown
							}),
							!isDownloadable && !isDeletable && /* @__PURE__ */ jsx(Icon, { name: "chevron-right" })
						]
					})]
				}),
				warningMessage ? /* @__PURE__ */ jsx(Alert, {
					variant: "warning",
					title: warningMessage,
					className: "adyen-task-item__warning-message"
				}) : void 0,
				shouldShowErrorAlert && /* @__PURE__ */ jsx(VerificationErrorAlert, {
					className: "adyen-task-item-alert",
					problems,
					fallbackErrorMessage
				})
			]
		})
	}), isConfirmShown && isDeletable && /* @__PURE__ */ jsx(Confirm, {
		title: t(($) => $["deleteItem"], { item: title }),
		description: t(($) => $["thisActionIsPermanent"]),
		onConfirm: deleteEntity,
		confirmText: t(($) => $["delete"]),
		onCancel: dismissConfirm,
		critical: true
	})] });
};
//#endregion
export { setNestedValue as a, resolveComponentProps as i, canShowAdaptivePoc as n, getNestedValue as r, TaskListItem as t };
