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] = "2a9dab94-0940-43dc-86f4-0ea1ae871135", e._sentryDebugIdIdentifier = "sentry-dbid-2a9dab94-0940-43dc-86f4-0ea1ae871135");
} catch (e) {}
import { a as Icon, r as useTranslation } from "./translation-DYpZlvOH.js";
import { n as IconButton } from "./Button-DOLNhJTG.js";
import { t as TaskVerificationStatus } from "./TaskVerificationStatus-CJvFgafc.js";
import { i as TaskStatuses } from "./taskStatus-CvMqhrOK.js";
import { t as Alert } from "./Alert-CBZNxyCL.js";
import { t as Card } from "./Card-D6AEqxyX.js";
import { t as useAnalyticsContext } from "./useAnalyticsContext-Msf0gvuf.js";
import { t as Avatar } from "./Avatar-C8qgdfiR.js";
import { t as LoaderWrapper } from "./LoaderWrapper-B2xqWnWU.js";
import { t as VerificationErrorAlert } from "./VerificationErrorAlert-BiEYkpvf.js";
import { t as Confirm } from "./Confirm-CLCtT6To.js";
import { useState } from "preact/hooks";
import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
//#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 { TaskListItem as t };
