"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActionsPanel = void 0;
var react_1 = __importDefault(require("react"));
var ui_i18n_1 = __importDefault(require("ui-i18n"));
var ramda_1 = require("ramda");
var MoreVert_1 = __importDefault(require("@mui/icons-material/MoreVert"));
var SmallIconButton_1 = require("../SmallIconButton");
var DropDownMenuButton_1 = require("../DropDownMenuButton");
var MenuItemRenderer_1 = require("./components/MenuItemRenderer");
var ActionButton_1 = require("../ActionButton");
var types_1 = require("../types");
var ActionsPanel = function (_a) {
    var actions = _a.actions, _b = _a.numberOfButtons, numberOfButtons = _b === void 0 ? 2 : _b, _c = _a.mode, mode = _c === void 0 ? 'normal' : _c, actionButtonSize = _a.actionButtonSize, moreOptionsButtonSize = _a.moreOptionsButtonSize, classes = _a.classes, onActionsMenuOpen = _a.onActionsMenuOpen, onActionsMenuClose = _a.onActionsMenuClose, dataReltioId = _a.dataReltioId;
    var _d = (0, ramda_1.pipe)((0, ramda_1.reject)((0, ramda_1.propEq)('show', false)), (0, ramda_1.map)((0, ramda_1.omit)(['show'])), (0, ramda_1.splitAt)(numberOfButtons))(actions), buttonActions = _d[0], menuActions = _d[1];
    var buttonMode = mode === 'normal' ? types_1.ActionButtonMode.button : types_1.ActionButtonMode.iconButton;
    var defaultButtonSize = mode === 'normal' ? 'MPlus' : 'S';
    var buttonSize = moreOptionsButtonSize !== null && moreOptionsButtonSize !== void 0 ? moreOptionsButtonSize : defaultButtonSize;
    return (react_1.default.createElement(react_1.default.Fragment, null,
        buttonActions.map(function (_a, index) {
            var _b = _a.ActionButton, ActionButton = _b === void 0 ? ActionButton_1.ActionButton : _b, props = __rest(_a, ["ActionButton"]);
            return (react_1.default.createElement(ActionButton, __assign({ key: index, mode: buttonMode, className: classes === null || classes === void 0 ? void 0 : classes.actionButton }, (actionButtonSize ? { size: actionButtonSize } : {}), props)));
        }),
        menuActions.length > 0 && (react_1.default.createElement(DropDownMenuButton_1.DropDownMenuButton, { buttonComponent: SmallIconButton_1.SmallIconButtonWithTooltip, buttonProps: {
                icon: MoreVert_1.default,
                size: buttonSize,
                tooltipTitle: ui_i18n_1.default.text('More actions'),
                'data-reltio-id': dataReltioId
            }, className: classes === null || classes === void 0 ? void 0 : classes.moreOptions, menuId: "view-actions", menuItems: menuActions, onMenuOpen: onActionsMenuOpen, onMenuClose: onActionsMenuClose, MenuItemRenderer: MenuItemRenderer_1.MenuItemRenderer }))));
};
exports.ActionsPanel = ActionsPanel;
