import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
import { ConfirmAction, } from '../../../ConfirmAction';
import { IconButton } from '../../../IconButton';
import { Tooltip } from '../../../Tooltip';
import { useLogic } from './useLogic';
export const MainIconButton = (props) => {
    const { tooltipProps } = useLogic(props);
    const { action, onActionClick, isDisabled } = props;
    const { name, icon, needConfirm, confirmText, confirmButtonProps, disabledReason, disabled, loading, isBlockingOperation, loadingNote, onClick, ...actions } = action;
    const renderButton = (renderProps) => (_jsx(Tooltip, { withoutContainer: !disabled, placement: "top", ...tooltipProps, children: _jsx(IconButton, { disabled: isDisabled || disabled, loading: loading, ...actions, variant: "text", ...renderProps, children: icon }) }, name));
    return (_jsx(_Fragment, { children: needConfirm ? (_jsx(ConfirmAction, { text: confirmText, confirmButtonProps: confirmButtonProps, actionComponent: (renderProps) => renderButton(renderProps), onConfirm: onActionClick(onClick) })) : (renderButton({
            onClick: onActionClick(onClick),
        })) }));
};
