"use strict";

exports.__esModule = true;
exports["default"] = void 0;
var _react = _interopRequireWildcard(require("react"));
var _action = _interopRequireDefault(require("../../components/action"));
var _utils = require("../../../../utils");
var _excluded = ["isDisabled", "isVisible", "testPrefix", "id", "icon", "handleAction", "selectedRows", "table", "tooltipText", "alwaysEnabled", "disabledTooltipText"];
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
var HeaderAction = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
  var isDisabled = _ref.isDisabled,
    isVisible = _ref.isVisible,
    testPrefix = _ref.testPrefix,
    id = _ref.id,
    icon = _ref.icon,
    _handleAction = _ref.handleAction,
    selectedRows = _ref.selectedRows,
    table = _ref.table,
    tooltipText = _ref.tooltipText,
    alwaysEnabled = _ref.alwaysEnabled,
    disabledTooltipText = _ref.disabledTooltipText,
    rest = _objectWithoutPropertiesLoose(_ref, _excluded);
  var actionRef = (0, _react.useRef)();
  var disabled = typeof isDisabled === "function" ? isDisabled() : isDisabled;
  var visible = typeof isVisible === "function" ? isVisible() : isVisible;
  return /*#__PURE__*/_react["default"].createElement(_action["default"], _extends({
    ref: (0, _utils.mergeRefs)(actionRef, ref),
    testPrefix: testPrefix + "-bulk",
    key: id,
    visible: visible,
    id: id,
    icon: icon,
    handleAction: function handleAction() {
      return _handleAction(selectedRows, table);
    },
    tooltipText: tooltipText,
    disabled: !alwaysEnabled && (selectedRows == null ? void 0 : selectedRows.length) < 1 || disabled,
    background: "elementBackground",
    selectedRows: selectedRows,
    disabledTooltipText: typeof disabledTooltipText === "function" ? disabledTooltipText(selectedRows) : disabledTooltipText
  }, rest));
});
var _default = exports["default"] = HeaderAction;