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/index.tsx
var Actions_exports = {};
__export(Actions_exports, {
  default: () => Actions_default
});
module.exports = __toCommonJS(Actions_exports);
var import_antd = require("antd");
var import_react = __toESM(require("react"));
var import_filter = __toESM(require("../../filter"));
var import_sort = __toESM(require("../../sort"));
var import_Buttons = __toESM(require("../Header/Buttons"));
var import_ColumnsSetting = __toESM(require("./component/ColumnsSetting"));
var import_ExportImport = __toESM(require("./component/ExportImport"));
var import_GallerySetting = __toESM(require("./component/GallerySetting"));
var import_Group = __toESM(require("./component/Group"));
var import_ViewMode = __toESM(require("./component/ViewMode"));
var import_useIsMobileTable = __toESM(require("../hooks/useIsMobileTable"));
var import_index = require("./index.less");
var Actions = ({
  filter,
  sort,
  columnSetting,
  dataSourceGroup,
  tableId,
  localPagination,
  buttons,
  view,
  gallery,
  exportImport
}) => {
  const form = import_antd.Form.useFormInstance();
  const isMobileBool = (0, import_useIsMobileTable.default)();
  const viewMode = import_antd.Form.useWatch("view_mode", {
    form,
    preserve: true
  });
  const showActions = (0, import_react.useMemo)(() => {
    if (import_react.default.isValidElement(filter) || import_react.default.isValidElement(filter == null ? void 0 : filter.dom)) {
      return true;
    }
    return (filter == null ? void 0 : filter.show) || (sort == null ? void 0 : sort.show) || (columnSetting == null ? void 0 : columnSetting.show) || (dataSourceGroup == null ? void 0 : dataSourceGroup.show) || view.multiple || (exportImport == null ? void 0 : exportImport.show);
  }, [
    filter == null ? void 0 : filter.show,
    sort == null ? void 0 : sort.show,
    columnSetting == null ? void 0 : columnSetting.show,
    dataSourceGroup == null ? void 0 : dataSourceGroup.show,
    view.multiple,
    exportImport == null ? void 0 : exportImport.show
  ]);
  const filterRender = (0, import_react.useMemo)(() => {
    if (import_react.default.isValidElement(filter)) {
      return filter;
    }
    if (import_react.default.isValidElement(filter == null ? void 0 : filter.dom)) {
      return filter.dom;
    }
    return /* @__PURE__ */ import_react.default.createElement(
      import_filter.default,
      {
        filter,
        isRenderFormContent: false,
        tableId,
        viewMode,
        isMobile: isMobileBool
      }
    );
  }, [filter, tableId, viewMode, isMobileBool]);
  return showActions ? /* @__PURE__ */ import_react.default.createElement("div", { className: "materials-grid-actions" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "left-wrap" }, filterRender), /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: "right-wrap",
      style: {
        columnGap: isMobileBool ? 0 : 12
      }
    },
    view.multiple && /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { name: "view_mode", noStyle: true }, /* @__PURE__ */ import_react.default.createElement(import_ViewMode.default, { view })),
    (exportImport == null ? void 0 : exportImport.show) ? /* @__PURE__ */ import_react.default.createElement(import_ExportImport.default, { exportImport }) : null,
    (dataSourceGroup == null ? void 0 : dataSourceGroup.show) && viewMode === "grid" && /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { name: "group_by", noStyle: true }, /* @__PURE__ */ import_react.default.createElement(import_Group.default, { setting: dataSourceGroup })),
    (columnSetting == null ? void 0 : columnSetting.show) && viewMode === "grid" && /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { name: ["column_setting"], noStyle: true }, /* @__PURE__ */ import_react.default.createElement(import_ColumnsSetting.default, null)),
    (columnSetting == null ? void 0 : columnSetting.show) && viewMode === "gallery" && /* @__PURE__ */ import_react.default.createElement(import_GallerySetting.default, { setting: gallery, currentViewMode: viewMode }),
    (sort == null ? void 0 : sort.show) ? /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { name: "order_by", noStyle: true }, /* @__PURE__ */ import_react.default.createElement(import_sort.default, { list: (sort == null ? void 0 : sort.list) || [], localPagination })) : null,
    !!(buttons == null ? void 0 : buttons.length) && /* @__PURE__ */ import_react.default.createElement(
      import_Buttons.default,
      {
        list: buttons,
        style: isMobileBool ? { marginLeft: 8 } : {}
      }
    )
  )) : null;
};
var Actions_default = Actions;
