const require_runtime = require("../../../../../_virtual/_rolldown/runtime.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_materials = require("@pisell/materials");
let _ant_design_icons = require("@ant-design/icons");
require("./index.less");
//#region src/plus/saasDevice/deviceProfile/components/SiderMenuPanel/index.tsx
const hasAnyLeaf = (items) => {
	if (!items || !items.length) return false;
	return items.some((it) => {
		if (!it) return false;
		if (it.type === "group") return hasAnyLeaf(it.children);
		return true;
	});
};
const SiderMenuPanel = ({ title, searchable, searchPlaceholder, onSearch, items, selectedKey, onSelect, emptyText }) => {
	const isEmpty = (0, react.useMemo)(() => !hasAnyLeaf(items), [items]);
	return /* @__PURE__ */ react.default.createElement("div", { className: "saas-device-profile-panel" }, title && /* @__PURE__ */ react.default.createElement("div", { className: "saas-device-profile-title" }, title), searchable && /* @__PURE__ */ react.default.createElement(_pisell_materials.Input, {
		allowClear: true,
		prefix: /* @__PURE__ */ react.default.createElement(_ant_design_icons.SearchOutlined, { className: "saas-device-profile-search-icon" }),
		placeholder: searchPlaceholder !== null && searchPlaceholder !== void 0 ? searchPlaceholder : "Search...",
		onChange: (e) => onSearch === null || onSearch === void 0 ? void 0 : onSearch(e.target.value)
	}), /* @__PURE__ */ react.default.createElement("div", { className: "saas-device-profile-menu-scroll" }, isEmpty ? /* @__PURE__ */ react.default.createElement(_pisell_materials.Empty, {
		image: _pisell_materials.Empty.PRESENTED_IMAGE_SIMPLE,
		description: emptyText !== null && emptyText !== void 0 ? emptyText : null
	}) : /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellMenu, {
		mode: "inline",
		theme: "light",
		dataSource: items,
		selectedKeys: [selectedKey],
		onSelect: ({ key }) => onSelect(String(key))
	})));
};
//#endregion
exports.default = SiderMenuPanel;
