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/components/pisellDropSort/components/SortableItem/index.tsx
var SortableItem_exports = {};
__export(SortableItem_exports, {
  default: () => SortableItem_default
});
module.exports = __toCommonJS(SortableItem_exports);
var import_react = __toESM(require("react"));
var import_classnames = __toESM(require("classnames"));
var import_DotsSix = __toESM(require("@pisell/icon/es/DotsSix"));
var import_button = __toESM(require("../../../button"));
var import_icon = __toESM(require("../../../icon"));
var import_index = require("./index.less");
var SortableItem = (props) => {
  const {
    itemProps,
    render,
    domRef,
    allowAddChild,
    allowDelete,
    allowDrag,
    disabled,
    onAdd,
    onDelete,
    showBorder,
    spacing,
    maxLevel,
    __designMode,
    isCustomAction,
    getItemStyle
  } = props;
  const {
    item,
    depth,
    clone,
    ghost,
    indicator,
    disableSelection,
    disableInteraction,
    wrapperRef,
    style,
    onCollapse,
    onRemove,
    childCount,
    indentationWidth,
    handleProps,
    collapsed,
    ...otherProps
  } = itemProps;
  const itemStyle = (getItemStyle == null ? void 0 : getItemStyle(itemProps)) || {};
  const mergedStyle = {
    ...itemStyle,
    ...style
  };
  return /* @__PURE__ */ import_react.default.createElement(
    "li",
    {
      className: (0, import_classnames.default)(
        "pisell-lowcode-drop-sort-item",
        clone && "clone",
        ghost && "ghost",
        indicator && "indicator",
        disableSelection && "disableSelection",
        disableInteraction && "disableInteraction"
      ),
      ref: wrapperRef,
      style: {
        "--spacing": `${indentationWidth * depth}px`
      },
      ...otherProps
    },
    /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: (0, import_classnames.default)("pisell-lowcode-drop-sort-item-tree-item", {
          "pisell-lowcode-drop-sort-item-tree-item-border": showBorder,
          disabled
        }),
        ref: domRef,
        style: mergedStyle
      },
      allowDrag && !disabled && /* @__PURE__ */ import_react.default.createElement(
        import_button.default,
        {
          icon: /* @__PURE__ */ import_react.default.createElement(import_DotsSix.default, { className: "pisell-lowcode-drop-sort-item-drag-handle-icon" }),
          type: "text",
          className: "pisell-lowcode-drop-sort-item-button",
          ...__designMode === "design" ? {} : { ...handleProps }
        }
      ),
      onCollapse && /* @__PURE__ */ import_react.default.createElement(
        import_button.default,
        {
          icon: /* @__PURE__ */ import_react.default.createElement(
            import_icon.default,
            {
              type: "pisell2-chevron-down",
              className: "pisell-lowcode-drop-sort-item-icon"
            }
          ),
          onClick: onCollapse,
          type: "text",
          className: (0, import_classnames.default)(
            "Collapse",
            collapsed && "collapsed",
            "pisell-lowcode-drop-sort-item-button"
          )
        }
      ),
      /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode-drop-sort-item-content" }, render && render(itemProps)),
      !isCustomAction && /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, !clone && allowAddChild && !disabled && /* @__PURE__ */ import_react.default.createElement(
        import_button.default,
        {
          icon: /* @__PURE__ */ import_react.default.createElement(
            import_icon.default,
            {
              type: "pisell2-plus",
              className: "pisell-lowcode-drop-sort-item-icon"
            }
          ),
          onClick: () => onAdd == null ? void 0 : onAdd(itemProps),
          type: "text",
          className: "pisell-lowcode-drop-sort-item-button"
        }
      ), !clone && allowDelete && !disabled && /* @__PURE__ */ import_react.default.createElement(
        import_button.default,
        {
          icon: /* @__PURE__ */ import_react.default.createElement(
            import_icon.default,
            {
              type: "pisell2-trash-01",
              className: "pisell-lowcode-drop-sort-item-icon"
            }
          ),
          onClick: () => onDelete == null ? void 0 : onDelete(itemProps),
          type: "text",
          className: "pisell-lowcode-drop-sort-item-button"
        }
      )),
      clone && childCount && childCount > 1 ? /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-lowcode-drop-sort-item-count" }, childCount) : null
    )
  );
};
var SortableItem_default = SortableItem;
