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/pisellActionPanel/PisellActionPanel.tsx
var PisellActionPanel_exports = {};
__export(PisellActionPanel_exports, {
  PisellActionPanel: () => PisellActionPanel
});
module.exports = __toCommonJS(PisellActionPanel_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_classnames = __toESM(require("classnames"));
var import_PisellActionPanel = require("./PisellActionPanel.less");
function renderActionItem(item, index) {
  const visible = item.visible !== false;
  if (!visible) return null;
  const key = item.key ?? `action-${index}`;
  const priority = item.priority ?? "default";
  const buttonType = priority === "danger" ? "primary" : priority === "primary" ? "primary" : "default";
  const danger = priority === "danger";
  return /* @__PURE__ */ import_react.default.createElement(
    import_antd.Button,
    {
      key,
      type: buttonType,
      danger,
      icon: item.icon,
      onClick: item.onClick,
      disabled: item.disabled,
      className: (0, import_classnames.default)("pisell-action-panel-btn", item.className),
      style: item.style
    },
    item.label
  );
}
function PisellActionPanel({
  groups,
  layout = "horizontal",
  align = "left",
  overflowStrategy = "wrap",
  groupGap,
  itemGap,
  className,
  style
}) {
  const effectiveGroups = (0, import_react.useMemo)(() => {
    return groups.filter((g) => g.visible !== false).map((g) => ({
      ...g,
      items: g.items.filter((i) => i.visible !== false)
    })).filter((g) => g.items.length > 0);
  }, [groups]);
  const rootStyle = (0, import_react.useMemo)(() => {
    const s = { ...style };
    if (groupGap !== void 0) {
      s.gap = typeof groupGap === "number" ? `${groupGap}px` : groupGap;
    }
    return s;
  }, [style, groupGap]);
  const itemGapValue = typeof itemGap === "number" ? itemGap : itemGap ?? 8;
  const isVertical = layout === "vertical";
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: (0, import_classnames.default)(
        "pisell-action-panel-root",
        `pisell-action-panel-layout-${layout}`,
        `pisell-action-panel-align-${align}`,
        overflowStrategy === "scroll" && "pisell-action-panel-overflow-scroll",
        overflowStrategy === "wrap" && "pisell-action-panel-overflow-wrap",
        className
      ),
      style: rootStyle
    },
    effectiveGroups.map((group, groupIndex) => /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        key: group.key ?? `group-${groupIndex}`,
        className: (0, import_classnames.default)("pisell-action-panel-group", group.className),
        style: group.style
      },
      /* @__PURE__ */ import_react.default.createElement(
        import_antd.Space,
        {
          size: itemGapValue,
          direction: isVertical ? "vertical" : "horizontal",
          wrap: !isVertical && overflowStrategy === "wrap",
          className: "pisell-action-panel-group-space"
        },
        group.items.map(
          (item, itemIndex) => renderActionItem(item, itemIndex)
        )
      )
    ))
  );
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  PisellActionPanel
});
