"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SecondaryActions = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const Collapse_1 = require("../../../../components/Collapse");
const Tooltip_1 = require("../../../../components/Tooltip");
const styles_1 = require("./styles");
const useLogic_1 = require("./useLogic");
const SecondaryActions = (props) => {
    const { isDisabled, actions, isActive, isDisablePadding = false } = props;
    const { isShowCollapseActions } = (0, useLogic_1.useLogic)(props);
    const renderMobileButton = ({ text, disabled, isBlockingOperation, ...restButtonProps }) => ((0, jsx_runtime_1.jsx)(styles_1.StyledMobileButton, { disabled: isDisabled || disabled, variant: "outlined", color: "grey", ...restButtonProps, children: text }, text));
    return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(styles_1.MobileActionWrapper, { children: isShowCollapseActions ? ((0, jsx_runtime_1.jsx)(Collapse_1.Collapse, { in: isActive, children: (0, jsx_runtime_1.jsx)(styles_1.ActionWrapper, { "$isDisablePadding": isDisablePadding, children: actions.map(renderMobileButton) }) })) : ((0, jsx_runtime_1.jsx)(styles_1.ActionWrapper, { "$isDisablePadding": isDisablePadding, children: renderMobileButton(actions[0]) })) }), (0, jsx_runtime_1.jsx)(styles_1.DesktopActionWrapper, { children: actions?.map((action) => {
                    const { text, disabled, disabledReason, loading, isBlockingOperation, ...restActionProps } = action;
                    return ((0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { title: disabled && disabledReason, withoutContainer: !(isDisabled || disabled), children: (0, jsx_runtime_1.jsx)(styles_1.StyledButton, { disabled: isDisabled || disabled, loading: loading, size: "large", color: "grey", variant: "outlined", ...restActionProps, children: text }) }, text));
                }) })] }));
};
exports.SecondaryActions = SecondaryActions;
