var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

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