const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_index = require("../pisellAvatar/index.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _ant_design_icons = require("@ant-design/icons");
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
require("./index.less");
//#region src/components/profileMenu/index.tsx
const ProfileMenu = ({ menuIcon, userName = "", email = "", isShowUserName = true, isShowEmail = true, isShowUserInfo = false, onClick, avatar, className, style, menuItems = [], placement = "bottomRight", trigger = ["click"], showBadge = false, badgeCount = 1 }) => {
	(0, react.useEffect)(() => {
		document.body.id = "body";
	}, []);
	const handleClick = (e) => {
		e.preventDefault();
		onClick === null || onClick === void 0 || onClick();
	};
	const renderAvatar = (avatarProps) => /* @__PURE__ */ react.default.createElement(require_index.default, {
		style: { margin: "0 6px" },
		size: "md",
		src: (avatarProps === null || avatarProps === void 0 ? void 0 : avatarProps.src) || "",
		alt: (avatarProps === null || avatarProps === void 0 ? void 0 : avatarProps.alt) || "",
		icon: /* @__PURE__ */ react.default.createElement(_ant_design_icons.UserOutlined, { style: {
			fontSize: 24,
			color: "#475467"
		} })
	});
	const finalMenuItems = (0, react.useMemo)(() => {
		if (!isShowUserInfo) return menuItems;
		return [
			{
				key: "user-info",
				label: /* @__PURE__ */ react.default.createElement("div", { className: "profile-menu-user-info-item" }, renderAvatar(avatar), /* @__PURE__ */ react.default.createElement("div", { className: "profile-menu-user-info" }, userName && /* @__PURE__ */ react.default.createElement("p", { className: "profile-menu-user-info-name" }, userName), email && /* @__PURE__ */ react.default.createElement("p", { className: "profile-menu-user-info-email" }, email)))
			},
			{ type: "divider" },
			...menuItems || []
		];
	}, [
		isShowUserInfo,
		menuItems,
		userName,
		email,
		avatar
	]);
	const showUserInfo = isShowUserName && userName || isShowEmail && email;
	return /* @__PURE__ */ react.default.createElement(antd.Dropdown, {
		menu: { items: finalMenuItems },
		placement,
		trigger,
		overlayClassName: "profile-menu-dropdown"
	}, /* @__PURE__ */ react.default.createElement("div", {
		className: (0, classnames.default)("profile-menu-wrap", className),
		style: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, style), {}, { paddingRight: showUserInfo ? 16 : 0 }),
		onClick: handleClick
	}, menuIcon && /* @__PURE__ */ react.default.createElement("div", { className: "profile-menu-icon" }, menuIcon), /* @__PURE__ */ react.default.createElement(antd.Badge, {
		count: showBadge ? badgeCount : 0,
		offset: [-6, 6]
	}, renderAvatar(avatar)), showUserInfo && /* @__PURE__ */ react.default.createElement("div", { className: "profile-menu-user-info" }, isShowUserName && userName && /* @__PURE__ */ react.default.createElement("p", {
		className: "profile-menu-user-info-name",
		title: userName
	}, userName), isShowEmail && email && /* @__PURE__ */ react.default.createElement("p", {
		className: "profile-menu-user-info-email",
		title: email
	}, email))));
};
//#endregion
exports.default = ProfileMenu;
