const require_runtime = require("../../../../../_virtual/_rolldown/runtime.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_materials = require("@pisell/materials");
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
let _ant_design_icons = require("@ant-design/icons");
require("./index.less");
//#region src/plus/saasDevice/appDevicePlanning/components/WorkAreaList/index.tsx
const WorkAreaListItem = ({ item, selected, title, getText, onSelect, onEdit, onDelete }) => {
	const menuItems = item ? [{
		key: "edit",
		icon: /* @__PURE__ */ react.default.createElement(_ant_design_icons.EditOutlined, null),
		label: getText("pisell2.saas.device-planning.action.edit"),
		onClick: ({ domEvent }) => {
			domEvent.stopPropagation();
			onEdit(item);
		}
	}, {
		key: "delete",
		danger: true,
		icon: /* @__PURE__ */ react.default.createElement(_ant_design_icons.DeleteOutlined, null),
		label: getText("pisell2.saas.device-planning.action.delete"),
		onClick: ({ domEvent }) => {
			domEvent.stopPropagation();
			onDelete(item);
		}
	}] : [];
	return /* @__PURE__ */ react.default.createElement("div", {
		className: (0, classnames.default)("saas-app-device-planning-workarea-item", { "is-selected": selected }),
		onClick: () => onSelect(item === null || item === void 0 ? void 0 : item.id)
	}, item ? null : /* @__PURE__ */ react.default.createElement("span", { className: "saas-app-device-planning-workarea-item__icon" }, /* @__PURE__ */ react.default.createElement(_pisell_materials.Icon, {
		type: "AppstoreOutlined",
		color: selected ? "#1677ff" : "#999"
	})), /* @__PURE__ */ react.default.createElement("span", { className: "saas-app-device-planning-workarea-item__name" }, title), item ? /* @__PURE__ */ react.default.createElement(antd.Dropdown, {
		trigger: ["click"],
		menu: { items: menuItems },
		placement: "bottomRight"
	}, /* @__PURE__ */ react.default.createElement(_pisell_materials.Button, {
		type: "text",
		className: "saas-app-device-planning-workarea-item__more",
		icon: /* @__PURE__ */ react.default.createElement(_ant_design_icons.MoreOutlined, null),
		onClick: (event) => event.stopPropagation()
	})) : null);
};
const WorkAreaList = ({ className, loading, workAreas, selectedWorkAreaId, getText, translation, onCreate, onSelect, onEdit, onDelete }) => /* @__PURE__ */ react.default.createElement("aside", { className: (0, classnames.default)("saas-app-device-planning-sider", className) }, /* @__PURE__ */ react.default.createElement("div", { className: "saas-app-device-planning-sider__header" }, /* @__PURE__ */ react.default.createElement("div", null, /* @__PURE__ */ react.default.createElement("div", { className: "saas-app-device-planning-sider__title" }, getText("pisell2.saas.device-planning.work-areas")), /* @__PURE__ */ react.default.createElement("div", { className: "saas-app-device-planning-sider__desc" }, getText("pisell2.saas.device-planning.work-areas-desc"))), /* @__PURE__ */ react.default.createElement(_pisell_materials.Button, {
	type: "text",
	icon: /* @__PURE__ */ react.default.createElement(_ant_design_icons.PlusOutlined, null),
	onClick: onCreate
})), /* @__PURE__ */ react.default.createElement("div", { className: "saas-app-device-planning-sider__list" }, /* @__PURE__ */ react.default.createElement(WorkAreaListItem, {
	selected: !selectedWorkAreaId,
	title: getText("pisell2.saas.device-planning.all-work-areas"),
	getText,
	onSelect,
	onEdit,
	onDelete
}), loading && !workAreas.length ? /* @__PURE__ */ react.default.createElement("div", { className: "saas-app-device-planning-sider__loading" }, /* @__PURE__ */ react.default.createElement(antd.Spin, null)) : workAreas.length ? workAreas.map((item) => /* @__PURE__ */ react.default.createElement(WorkAreaListItem, {
	key: item.id,
	item,
	title: translation(item.name),
	selected: item.id === selectedWorkAreaId,
	getText,
	onSelect,
	onEdit,
	onDelete
})) : /* @__PURE__ */ react.default.createElement(antd.Empty, { image: antd.Empty.PRESENTED_IMAGE_SIMPLE })));
//#endregion
exports.default = WorkAreaList;
