"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", "ref"];
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
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 (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
var HeaderAction = function HeaderAction(_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,
    ref = _ref.ref,
    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;