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/table/Actions/component/ColumnsSetting/PopoverContent.tsx
var PopoverContent_exports = {};
__export(PopoverContent_exports, {
  default: () => PopoverContent_default
});
module.exports = __toCommonJS(PopoverContent_exports);
var import_react = __toESM(require("react"));
var import_DotsSix = __toESM(require("@pisell/icon/es/DotsSix"));
var import_Lock01 = __toESM(require("@pisell/icon/es/Lock01"));
var import_classnames = __toESM(require("classnames"));
var import_antd = require("antd");
var import_icons = require("@ant-design/icons");
var import_DragSortList = __toESM(require("../../../../DragSortList"));
var import_utils = require("./utils");
var import_PopoverContent = require("./PopoverContent.less");
var import_locales = require("../../../../../locales");
var prefix = "pisell-lowcode-";
var DragItem = import_react.default.forwardRef((props, ref) => {
  const { attributes, listeners, setActivatorNodeRef, style, isLock } = props;
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      ref,
      ...attributes,
      style,
      className: `${prefix}table-action-column-drag-item`
    },
    isLock ? /* @__PURE__ */ import_react.default.createElement(import_antd.Tooltip, { title: (0, import_locales.getText)("table-column-group-lock-tip") }, /* @__PURE__ */ import_react.default.createElement(import_Lock01.default, { className: `${prefix}table-action-column-drag-bar` })) : /* @__PURE__ */ import_react.default.createElement(
      import_DotsSix.default,
      {
        ref: setActivatorNodeRef,
        ...listeners,
        style: {
          ...listeners.style || {},
          touchAction: "none"
        },
        className: `${prefix}table-action-column-drag-bar`
      }
    ),
    props.children
  );
});
var defaultValue = [];
var PopoverContent = (props) => {
  const {
    value = defaultValue,
    onChange,
    isShowTitle = true,
    headerContent
  } = props;
  const handleChange = (index, isShow) => {
    value[index] = {
      ...value[index],
      isShow
    };
    onChange == null ? void 0 : onChange([...value]);
  };
  return /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefix}table-action-column-popover-content-wrap` }, /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefix}table-action-column-header` }, isShowTitle && /* @__PURE__ */ import_react.default.createElement("span", { className: `${prefix}table-action-column-header-title` }, (0, import_locales.getText)("table-action-column-title")), headerContent && headerContent), /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefix}table-action-column-content` }, /* @__PURE__ */ import_react.default.createElement(
    import_DragSortList.default,
    {
      list: value,
      rowKey: (item) => {
        var _a;
        return `${item.key}-${(_a = item.dataIndex) == null ? void 0 : _a.toString()}`;
      },
      onChange: (list) => {
        if (!(0, import_utils.isFixedOrderValid)(list)) return;
        onChange == null ? void 0 : onChange(
          list.map((item, index) => ({
            ...item,
            sortIndex: index
          }))
        );
      }
    },
    ({
      item,
      index,
      style,
      props: props2,
      attributes,
      setActivatorNodeRef,
      listeners
    }) => {
      return /* @__PURE__ */ import_react.default.createElement(
        DragItem,
        {
          ...props2,
          isLock: item.fixed,
          index,
          attributes,
          setActivatorNodeRef,
          listeners,
          style
        },
        /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefix}table-action-column-drag-item-right` }, /* @__PURE__ */ import_react.default.createElement(
          "span",
          {
            className: (0, import_classnames.default)(
              `${prefix}table-action-column-drag-item-right-text`,
              {
                [`${prefix}table-action-column-drag-item-right-text-hidden`]: !item.isShow
              }
            )
          },
          item.titleString || item.title
        ), /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement(
          "span",
          {
            className: `${prefix}table-action-column-drag-item-right-icon-wrap`,
            onClick: () => {
              handleChange(index, !item.isShow);
            }
          },
          item.isShow ? /* @__PURE__ */ import_react.default.createElement(import_icons.EyeOutlined, null) : /* @__PURE__ */ import_react.default.createElement(import_icons.EyeInvisibleOutlined, null)
        )))
      );
    }
  )));
};
var PopoverContent_default = PopoverContent;
