const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_recordBoardColumns = require("../../utils/recordBoardColumns.js");
const require_useRecordBoardContext = require("../../hooks/useRecordBoardContext.js");
const require_ColumnSettingPopover = require("./ColumnSettingPopover.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _ant_design_icons = require("@ant-design/icons");
require("./index.less");
//#region src/components/pisellRecordBoard/shellFrame/ColumnSetting/index.tsx
/**
* RecordBoard 列显示隐藏设置（仅控制表格列展示，不控制 filter/sort）。
* 参考 table Actions ColumnsSetting，仅保留显隐切换，无拖拽排序。
*/
const RecordBoardColumnSetting = () => {
	var _ctx$childComponentPr, _ctx$childComponentPr2, _ctx$columnVisibility, _ctx$columnOrder;
	const ctx = require_useRecordBoardContext.useRecordBoardContext();
	const density = (_ctx$childComponentPr = ctx.childComponentProps) === null || _ctx$childComponentPr === void 0 || (_ctx$childComponentPr = _ctx$childComponentPr.toolBar) === null || _ctx$childComponentPr === void 0 ? void 0 : _ctx$childComponentPr.toolbarDensity;
	const compactToolbar = density === "compact" || density === "compact-narrow";
	const gridColumns = (_ctx$childComponentPr2 = ctx.childComponentProps) === null || _ctx$childComponentPr2 === void 0 || (_ctx$childComponentPr2 = _ctx$childComponentPr2.grid) === null || _ctx$childComponentPr2 === void 0 ? void 0 : _ctx$childComponentPr2.columns;
	const columnVisibility = (_ctx$columnVisibility = ctx.columnVisibility) !== null && _ctx$columnVisibility !== void 0 ? _ctx$columnVisibility : {};
	const onColumnVisibilityChange = ctx.onColumnVisibilityChange;
	const columnOrder = (_ctx$columnOrder = ctx.columnOrder) !== null && _ctx$columnOrder !== void 0 ? _ctx$columnOrder : null;
	const onColumnOrderChange = ctx.onColumnOrderChange;
	const content = (0, react.useMemo)(() => {
		if (!Array.isArray(gridColumns) || gridColumns.length === 0 || typeof onColumnVisibilityChange !== "function") return null;
		return /* @__PURE__ */ react.default.createElement(require_ColumnSettingPopover.default, {
			columns: gridColumns,
			columnVisibility,
			onColumnVisibilityChange,
			columnOrder,
			onColumnOrderChange
		});
	}, [
		gridColumns,
		columnVisibility,
		onColumnVisibilityChange,
		columnOrder,
		onColumnOrderChange
	]);
	const hasHiddenColumns = (0, react.useMemo)(() => {
		if (!Array.isArray(gridColumns)) return false;
		return gridColumns.some((col) => columnVisibility[require_recordBoardColumns.getRecordBoardColumnKey(col)] === false);
	}, [gridColumns, columnVisibility]);
	if (!content) return null;
	return /* @__PURE__ */ react.default.createElement(antd.Popover, {
		content,
		arrow: false,
		placement: "bottomRight",
		trigger: "click"
	}, /* @__PURE__ */ 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__ */ react.default.createElement(_ant_design_icons.EyeOutlined, { style: { fontSize: compactToolbar ? 15 : 18 } })));
};
RecordBoardColumnSetting.displayName = "RecordBoard.ColumnSetting";
//#endregion
exports.default = RecordBoardColumnSetting;
