import React, { useMemo } from "react";
import { Empty, Input, PisellMenu } from "@pisell/materials";
import { SearchOutlined } from "@ant-design/icons";
import "./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 = useMemo(() => !hasAnyLeaf(items), [items]);
	return /* @__PURE__ */ React.createElement("div", { className: "saas-device-profile-panel" }, title && /* @__PURE__ */ React.createElement("div", { className: "saas-device-profile-title" }, title), searchable && /* @__PURE__ */ React.createElement(Input, {
		allowClear: true,
		prefix: /* @__PURE__ */ React.createElement(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.createElement("div", { className: "saas-device-profile-menu-scroll" }, isEmpty ? /* @__PURE__ */ React.createElement(Empty, {
		image: Empty.PRESENTED_IMAGE_SIMPLE,
		description: emptyText !== null && emptyText !== void 0 ? emptyText : null
	}) : /* @__PURE__ */ React.createElement(PisellMenu, {
		mode: "inline",
		theme: "light",
		dataSource: items,
		selectedKeys: [selectedKey],
		onSelect: ({ key }) => onSelect(String(key))
	})));
};
//#endregion
export { SiderMenuPanel as default };
