"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TableBatchActions = void 0;
const react_1 = __importDefault(require("react"));
const Box_1 = require("../Box");
const Flex_1 = require("../Flex");
const Text_1 = require("../Text");
const Icon_1 = require("../Icon");
const Button_1 = require("../Button");
exports.TableBatchActions = ({ batchActions, showBatchActions, totalSelectedRows, selectedData, selectedRowIndices, refresh, lastUpdate, }) => {
    const label = (str) => str
        .replace('{0}', `${totalSelectedRows}`)
        .replace('{s}', totalSelectedRows === 1 ? '' : 's');
    return (react_1.default.createElement(Flex_1.Flex, null, batchActions.map((action, index) => action.condition === true ||
        (action.condition === undefined &&
            (!action.needsSelection ||
                (action.needsSelection &&
                    showBatchActions &&
                    totalSelectedRows > 0))) ? (react_1.default.createElement(react_1.default.Fragment, null,
        action.isRefresh && lastUpdate && (react_1.default.createElement(Box_1.Box, { key: `action${index + 1}lastUpdate`, ml: "4px" },
            react_1.default.createElement(Text_1.Text, { variant: "b3", color: "gray.1" }, lastUpdate))),
        react_1.default.createElement(Box_1.Box, { key: `action${index + 1}`, ml: "s" },
            react_1.default.createElement(Button_1.Button, Object.assign({ onClick: () => {
                    if (refresh && action.isRefresh)
                        refresh();
                    else
                        action.click(selectedData, selectedRowIndices);
                } }, action.buttonProps),
                action.icon && (react_1.default.createElement(Icon_1.Icon, { Asset: action.icon, width: 15, height: 15, color: "brandMain", mt: "-2px", mr: "s" })),
                action.buttonProps &&
                    action.buttonProps.variant === 'ghost' ? (react_1.default.createElement(Text_1.Text, { variant: "b2", color: "brandMain" }, label(action.label))) : (label(action.label)))))) : null)));
};
//# sourceMappingURL=TableBatchActions.js.map