import { FluentButton } from "../../inputs/buttons/FluentButton.mjs";
import { FluentIcon } from "../../../utilities/iconLibrary/FluentIcon.mjs";
import { FluentIconButton } from "../../inputs/buttons/FluentIconButton.mjs";
import { Adornment } from "../../components/feedback/Adornment.mjs";
import { CompactDataList } from "../../dataDisplay/CompactDataList.mjs";
import { CompactDataListItem } from "../../dataDisplay/CompactDataListItem.mjs";
import { c } from "react-compiler-runtime";
import React, { useState } from "react";
import { Card, CardContent, IconButton, ListItemIcon, Menu, MenuItem, Tooltip, Typography, darken, lighten, makeStyles, useTheme } from "@material-ui/core";
import { CaretDownSolid8Icon, ChromeCloseIcon, CompletedIcon, ErrorIcon, InfoIcon, MoreVerticalIcon, ViewIcon, WarningIcon } from "@fluentui/react-icons";
import { useTranslation } from "react-i18next";
//#region src/UI/mapLayout/ui/PopoverCard.jsx
const useStyles = makeStyles((theme) => ({
	contentWrapper: {
		display: "flex",
		height: "100%",
		width: (props) => props?.width ?? "100%"
	},
	titleWrapper: {
		display: "flex",
		gap: theme.spacing(1),
		alignItems: "center"
	},
	iconButtonWrapper: { borderRadius: 2 },
	avatar: {
		width: "80px",
		height: "80px"
	},
	iconButtonsWrapper: {
		display: "flex",
		justifyContent: "space-between",
		alignItems: "center"
	},
	primaryButtonContainer: {
		display: "flex",
		justifyContent: "flex-end",
		gap: theme.spacing(1)
	},
	actionButton: { color: "#FFFFFF" },
	fullHeight: { height: "100%" },
	fullWidth: { width: "100%" },
	messageWrapper: {
		display: "flex",
		gap: theme.spacing(1),
		alignItems: "center",
		padding: theme.spacing(1),
		backgroundColor: (props) => props?.status ? lighten(theme.palette[props.status]?.main, .9) : lighten(theme.palette.info.main, .9)
	},
	iconMessage: { color: (props) => props?.status ? theme.palette[props.status]?.main : null },
	message: { color: (props) => props?.status ? darken(theme.palette[props.status]?.main, .6) : null }
}));
const PopoverCard = (props) => {
	const $ = c(89);
	const { data, title, listData, showAdornment: t0, status: t1, detailsEvent, primaryActions, moreIconActions, message, messageIcon, hideMessageIcon: t2, onClose, width } = props;
	const showAdornment = t0 === void 0 ? true : t0;
	const status = t1 === void 0 ? "info" : t1;
	const hideMessageIcon = t2 === void 0 ? false : t2;
	const [moreIconAnchor, setMoreIconAnchor] = useState(null);
	const [primaryActionAnchor, setPrimaryActionAnchor] = useState(null);
	const { t } = useTranslation();
	let t3;
	if ($[0] !== status || $[1] !== width) {
		t3 = {
			width,
			status
		};
		$[0] = status;
		$[1] = width;
		$[2] = t3;
	} else t3 = $[2];
	const classes = useStyles(t3);
	const theme = useTheme();
	let t4;
	if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
		t4 = (event) => {
			setMoreIconAnchor(event?.currentTarget);
		};
		$[3] = t4;
	} else t4 = $[3];
	const handleOnClickMoreIcon = t4;
	let t5;
	if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
		t5 = (event_0) => {
			setPrimaryActionAnchor(event_0?.currentTarget);
		};
		$[4] = t5;
	} else t5 = $[4];
	const handleOnClickPrimaryAction = t5;
	let t6;
	bb0: switch (status) {
		case "success": {
			let t7;
			if ($[5] !== theme.palette.success.main) {
				t7 = lighten(theme.palette.success.main, .7);
				$[5] = theme.palette.success.main;
				$[6] = t7;
			} else t7 = $[6];
			t6 = t7;
			break bb0;
		}
		case "error": {
			let t7;
			if ($[7] !== theme.palette.error.main) {
				t7 = lighten(theme.palette.error.main, .7);
				$[7] = theme.palette.error.main;
				$[8] = t7;
			} else t7 = $[8];
			t6 = t7;
			break bb0;
		}
		case "warning": {
			let t7;
			if ($[9] !== theme.palette.warning.main) {
				t7 = lighten(theme.palette.warning.main, .7);
				$[9] = theme.palette.warning.main;
				$[10] = t7;
			} else t7 = $[10];
			t6 = t7;
			break bb0;
		}
		default: {
			let t7;
			if ($[11] !== theme.palette.info.main) {
				t7 = lighten(theme.palette.info.main, .7);
				$[11] = theme.palette.info.main;
				$[12] = t7;
			} else t7 = $[12];
			t6 = t7;
		}
	}
	const headerBackgroundColor = t6;
	let t7;
	bb1: switch (status) {
		case "success":
			t7 = CompletedIcon;
			break bb1;
		case "error":
			t7 = ErrorIcon;
			break bb1;
		case "warning":
			t7 = WarningIcon;
			break bb1;
		default: t7 = InfoIcon;
	}
	const defaultMessageIcon = t7;
	let t8;
	if ($[13] !== showAdornment || $[14] !== status) {
		t8 = showAdornment && status && /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Adornment, { color: status }));
		$[13] = showAdornment;
		$[14] = status;
		$[15] = t8;
	} else t8 = $[15];
	let t9;
	if ($[16] !== headerBackgroundColor) {
		t9 = { backgroundColor: headerBackgroundColor };
		$[16] = headerBackgroundColor;
		$[17] = t9;
	} else t9 = $[17];
	let t10;
	if ($[18] !== onClose) {
		t10 = /* @__PURE__ */ React.createElement(FluentIconButton, {
			onClick: onClose,
			icon: ChromeCloseIcon
		});
		$[18] = onClose;
		$[19] = t10;
	} else t10 = $[19];
	let t11;
	if ($[20] !== title) {
		t11 = /* @__PURE__ */ React.createElement(Typography, { variant: "h6" }, title);
		$[20] = title;
		$[21] = t11;
	} else t11 = $[21];
	let t12;
	if ($[22] !== classes.titleWrapper || $[23] !== t10 || $[24] !== t11) {
		t12 = /* @__PURE__ */ React.createElement("div", { className: classes.titleWrapper }, t10, t11);
		$[22] = classes.titleWrapper;
		$[23] = t10;
		$[24] = t11;
		$[25] = t12;
	} else t12 = $[25];
	let t13;
	if ($[26] !== classes.iconButtonWrapper || $[27] !== data || $[28] !== moreIconActions || $[29] !== moreIconAnchor || $[30] !== t) {
		t13 = moreIconActions?.length > 0 && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Tooltip, { title: t("More") ?? "" }, /* @__PURE__ */ React.createElement(IconButton, {
			className: classes.iconButtonWrapper,
			onClick: handleOnClickMoreIcon,
			size: "small"
		}, /* @__PURE__ */ React.createElement(MoreVerticalIcon, null))), /* @__PURE__ */ React.createElement(Menu, {
			open: moreIconAnchor ? true : false,
			onClose: () => {
				setMoreIconAnchor(null);
			},
			anchorEl: moreIconAnchor,
			anchorOrigin: {
				vertical: "top",
				horizontal: "right"
			},
			transformOrigin: {
				vertical: "top",
				horizontal: "left"
			}
		}, moreIconActions?.map((action) => /* @__PURE__ */ React.createElement(MenuItem, { onClick: () => {
			action.onClick(data);
		} }, action?.icon && /* @__PURE__ */ React.createElement(ListItemIcon, null, action.icon), action?.name))));
		$[26] = classes.iconButtonWrapper;
		$[27] = data;
		$[28] = moreIconActions;
		$[29] = moreIconAnchor;
		$[30] = t;
		$[31] = t13;
	} else t13 = $[31];
	let t14;
	if ($[32] !== t13) {
		t14 = /* @__PURE__ */ React.createElement("div", null, t13);
		$[32] = t13;
		$[33] = t14;
	} else t14 = $[33];
	let t15;
	if ($[34] !== classes.iconButtonsWrapper || $[35] !== t12 || $[36] !== t14) {
		t15 = /* @__PURE__ */ React.createElement("div", { className: classes.iconButtonsWrapper }, t12, t14);
		$[34] = classes.iconButtonsWrapper;
		$[35] = t12;
		$[36] = t14;
		$[37] = t15;
	} else t15 = $[37];
	let t16;
	if ($[38] !== t15 || $[39] !== t9) {
		t16 = /* @__PURE__ */ React.createElement(CardContent, { style: t9 }, t15);
		$[38] = t15;
		$[39] = t9;
		$[40] = t16;
	} else t16 = $[40];
	let t17;
	if ($[41] !== classes.iconMessage || $[42] !== classes.message || $[43] !== classes.messageWrapper || $[44] !== defaultMessageIcon || $[45] !== hideMessageIcon || $[46] !== message || $[47] !== messageIcon) {
		t17 = message && /* @__PURE__ */ React.createElement("div", { className: classes.messageWrapper }, !hideMessageIcon && /* @__PURE__ */ React.createElement("div", { className: classes.iconMessage }, /* @__PURE__ */ React.createElement(FluentIcon, { component: messageIcon ?? defaultMessageIcon })), /* @__PURE__ */ React.createElement("div", { className: classes.message }, message));
		$[41] = classes.iconMessage;
		$[42] = classes.message;
		$[43] = classes.messageWrapper;
		$[44] = defaultMessageIcon;
		$[45] = hideMessageIcon;
		$[46] = message;
		$[47] = messageIcon;
		$[48] = t17;
	} else t17 = $[48];
	let t18;
	if ($[49] === Symbol.for("react.memo_cache_sentinel")) {
		t18 = { flex: 1 };
		$[49] = t18;
	} else t18 = $[49];
	let t19;
	if ($[50] !== listData) {
		t19 = listData?.map(_temp);
		$[50] = listData;
		$[51] = t19;
	} else t19 = $[51];
	let t20;
	if ($[52] !== t19) {
		t20 = /* @__PURE__ */ React.createElement(CardContent, { style: t18 }, /* @__PURE__ */ React.createElement(CompactDataList, { disableSeparator: false }, t19));
		$[52] = t19;
		$[53] = t20;
	} else t20 = $[53];
	let t21;
	if ($[54] === Symbol.for("react.memo_cache_sentinel")) {
		t21 = {
			flex: 1,
			paddingTop: 0,
			paddingBottom: 16
		};
		$[54] = t21;
	} else t21 = $[54];
	let t22;
	if ($[55] !== detailsEvent || $[56] !== t) {
		t22 = detailsEvent && /* @__PURE__ */ React.createElement(FluentButton, {
			variant: "outlined",
			endIcon: /* @__PURE__ */ React.createElement(ViewIcon, null),
			onClick: detailsEvent
		}, t("Details"));
		$[55] = detailsEvent;
		$[56] = t;
		$[57] = t22;
	} else t22 = $[57];
	let t23;
	if ($[58] !== classes.actionButton || $[59] !== primaryActions?.length || $[60] !== t) {
		t23 = primaryActions?.length > 0 && /* @__PURE__ */ React.createElement(FluentButton, {
			variant: "contained",
			color: "secondary",
			endIcon: /* @__PURE__ */ React.createElement(CaretDownSolid8Icon, null),
			onClick: handleOnClickPrimaryAction,
			className: classes.actionButton
		}, t("Actions"));
		$[58] = classes.actionButton;
		$[59] = primaryActions?.length;
		$[60] = t;
		$[61] = t23;
	} else t23 = $[61];
	const t24 = primaryActionAnchor ? true : false;
	let t25;
	if ($[62] === Symbol.for("react.memo_cache_sentinel")) {
		t25 = () => {
			setPrimaryActionAnchor(null);
		};
		$[62] = t25;
	} else t25 = $[62];
	let t26;
	let t27;
	if ($[63] === Symbol.for("react.memo_cache_sentinel")) {
		t26 = {
			vertical: "bottom",
			horizontal: "left"
		};
		t27 = {
			vertical: "top",
			horizontal: "left"
		};
		$[63] = t26;
		$[64] = t27;
	} else {
		t26 = $[63];
		t27 = $[64];
	}
	let t28;
	if ($[65] !== data || $[66] !== primaryActions) {
		t28 = primaryActions?.map((action_0) => /* @__PURE__ */ React.createElement(MenuItem, { onClick: () => {
			action_0.onClick(data);
		} }, action_0?.icon && /* @__PURE__ */ React.createElement(ListItemIcon, null, action_0.icon), action_0?.name));
		$[65] = data;
		$[66] = primaryActions;
		$[67] = t28;
	} else t28 = $[67];
	let t29;
	if ($[68] !== primaryActionAnchor || $[69] !== t24 || $[70] !== t28) {
		t29 = /* @__PURE__ */ React.createElement(Menu, {
			open: t24,
			onClose: t25,
			anchorEl: primaryActionAnchor,
			anchorOrigin: t26,
			transformOrigin: t27
		}, t28);
		$[68] = primaryActionAnchor;
		$[69] = t24;
		$[70] = t28;
		$[71] = t29;
	} else t29 = $[71];
	let t30;
	if ($[72] !== t23 || $[73] !== t29) {
		t30 = /* @__PURE__ */ React.createElement("div", null, t23, t29);
		$[72] = t23;
		$[73] = t29;
		$[74] = t30;
	} else t30 = $[74];
	let t31;
	if ($[75] !== classes.primaryButtonContainer || $[76] !== t22 || $[77] !== t30) {
		t31 = /* @__PURE__ */ React.createElement(CardContent, { style: t21 }, /* @__PURE__ */ React.createElement("div", { className: classes.primaryButtonContainer }, t22, t30));
		$[75] = classes.primaryButtonContainer;
		$[76] = t22;
		$[77] = t30;
		$[78] = t31;
	} else t31 = $[78];
	let t32;
	if ($[79] !== classes.fullWidth || $[80] !== t16 || $[81] !== t17 || $[82] !== t20 || $[83] !== t31) {
		t32 = /* @__PURE__ */ React.createElement(Card, { className: classes.fullWidth }, t16, t17, t20, t31);
		$[79] = classes.fullWidth;
		$[80] = t16;
		$[81] = t17;
		$[82] = t20;
		$[83] = t31;
		$[84] = t32;
	} else t32 = $[84];
	let t33;
	if ($[85] !== classes.contentWrapper || $[86] !== t32 || $[87] !== t8) {
		t33 = /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { className: classes.contentWrapper }, t8, t32));
		$[85] = classes.contentWrapper;
		$[86] = t32;
		$[87] = t8;
		$[88] = t33;
	} else t33 = $[88];
	return t33;
};
function _temp(t0) {
	const { subject, value } = t0;
	return /* @__PURE__ */ React.createElement(CompactDataListItem, {
		label: subject,
		value
	});
}
//#endregion
export { PopoverCard };

//# sourceMappingURL=PopoverCard.mjs.map