"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Action = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const Button_1 = require("../../../Button");
const ConfirmAction_1 = require("../../../ConfirmAction");
const Tooltip_1 = require("../../../Tooltip");
const useLogic_1 = require("./useLogic");
const Action = (props) => {
    const { tooltipProps } = (0, useLogic_1.useLogic)(props);
    const { action, onActionClick, isDisabled } = props;
    const { name, needConfirm, confirmText, confirmButtonProps, disabledReason, disabled, loading, isBlockingOperation, loadingNote, note, onClick, component, variant, color, ...restProps } = action;
    const renderButton = (renderProps) => {
        return ((0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { withoutContainer: !disabled, placement: "bottom", ...tooltipProps, children: (0, jsx_runtime_1.jsx)(Button_1.Button, { disabled: isDisabled || disabled, loading: loading, component: component, variant: variant, color: color, ...restProps, ...renderProps, children: name }) }, name));
    };
    return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: needConfirm ? ((0, jsx_runtime_1.jsx)(ConfirmAction_1.ConfirmAction, { text: confirmText, confirmButtonProps: confirmButtonProps, actionComponent: (renderProps) => renderButton(renderProps), onConfirm: onActionClick(onClick) })) : (renderButton({
            onClick: onActionClick(onClick),
        })) }));
};
exports.Action = Action;
