"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MainAction = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const IconDropdownButton_1 = require("../../IconDropdownButton");
const MenuItem_1 = require("../../MenuItem");
const Tooltip_1 = require("../../Tooltip");
const MainIconButton_1 = require("./MainIconButton");
const MainAction = ({ action, onActionClick, isDisabled, }) => {
    if ('actions' in action) {
        const { disabled, icon, name, disabledReason, actions } = action;
        return ((0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { title: disabledReason || name, withoutContainer: !disabled, placement: "top", children: (0, jsx_runtime_1.jsx)(IconDropdownButton_1.IconDropdownButton, { icon: icon, variant: "text", disabled: isDisabled || disabled, children: actions.map(({ name: nestedActionName, onClick: onClickNested, ...props }) => ((0, react_1.createElement)(MenuItem_1.MenuItem, { ...props, key: nestedActionName, onClick: onActionClick(onClickNested) }, nestedActionName))) }) }, name));
    }
    return ((0, jsx_runtime_1.jsx)(MainIconButton_1.MainIconButton, { action: action, onActionClick: onActionClick, isDisabled: isDisabled }));
};
exports.MainAction = MainAction;
