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/pisellRecordBoard/shellFrame/ColumnSetting/index.tsx
var ColumnSetting_exports = {};
__export(ColumnSetting_exports, {
  default: () => ColumnSetting_default
});
module.exports = __toCommonJS(ColumnSetting_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_icons = require("@ant-design/icons");
var import_useRecordBoardContext = require("../../hooks/useRecordBoardContext");
var import_recordBoardColumns = require("../../utils/recordBoardColumns");
var import_ColumnSettingPopover = __toESM(require("./ColumnSettingPopover"));
var import_index = require("./index.less");
var RecordBoardColumnSetting = () => {
  var _a, _b, _c, _d;
  const ctx = (0, import_useRecordBoardContext.useRecordBoardContext)();
  const compactToolbar = ((_b = (_a = ctx.childComponentProps) == null ? void 0 : _a.toolBar) == null ? void 0 : _b.toolbarDensity) === "compact";
  const gridColumns = (_d = (_c = ctx.childComponentProps) == null ? void 0 : _c.grid) == null ? void 0 : _d.columns;
  const columnVisibility = ctx.columnVisibility ?? {};
  const onColumnVisibilityChange = ctx.onColumnVisibilityChange;
  const columnOrder = ctx.columnOrder ?? null;
  const onColumnOrderChange = ctx.onColumnOrderChange;
  const content = (0, import_react.useMemo)(() => {
    if (!Array.isArray(gridColumns) || gridColumns.length === 0 || typeof onColumnVisibilityChange !== "function") {
      return null;
    }
    return /* @__PURE__ */ import_react.default.createElement(
      import_ColumnSettingPopover.default,
      {
        columns: gridColumns,
        columnVisibility,
        onColumnVisibilityChange,
        columnOrder,
        onColumnOrderChange
      }
    );
  }, [
    gridColumns,
    columnVisibility,
    onColumnVisibilityChange,
    columnOrder,
    onColumnOrderChange
  ]);
  const hasHiddenColumns = (0, import_react.useMemo)(() => {
    if (!Array.isArray(gridColumns)) return false;
    return gridColumns.some(
      (col) => columnVisibility[(0, import_recordBoardColumns.getRecordBoardColumnKey)(col)] === false
    );
  }, [gridColumns, columnVisibility]);
  if (!content) return null;
  return /* @__PURE__ */ import_react.default.createElement(
    import_antd.Popover,
    {
      content,
      arrow: false,
      placement: "bottomRight",
      trigger: "click"
    },
    /* @__PURE__ */ import_react.default.createElement(
      "span",
      {
        className: "record-board-toolbar-column-setting-btn",
        style: {
          display: "inline-flex",
          alignItems: "center",
          justifyContent: "center",
          width: compactToolbar ? 28 : 32,
          height: compactToolbar ? 28 : 32,
          cursor: "pointer",
          borderRadius: 6,
          color: hasHiddenColumns ? "var(--color-primary, #1890ff)" : void 0
        }
      },
      /* @__PURE__ */ import_react.default.createElement(import_icons.EyeOutlined, { style: { fontSize: compactToolbar ? 15 : 18 } })
    )
  );
};
RecordBoardColumnSetting.displayName = "RecordBoard.ColumnSetting";
var ColumnSetting_default = RecordBoardColumnSetting;
