import { jsx as _jsx } from "react/jsx-runtime";
// (C) 2021-2026 GoodData Corporation
import { useCallback } from "react";
import cx from "classnames";
import { FormattedMessage, useIntl } from "react-intl";
import { UiTooltip } from "../../../@ui/UiTooltip/UiTooltip.js";
import { useIdPrefixed } from "../../../utils/useId.js";
import { ADD_GRANTEE_ID } from "./utils.js";
/**
 * @internal
 */
export function AddUserOrGroupButton({ isDisabled, onClick }) {
    const intl = useIntl();
    const buttonClassNames = cx({
        disabled: isDisabled,
    }, "gd-button", "gd-button-link", "gd-icon-plus", "s-add-users-or-groups");
    const handleClick = useCallback((e) => {
        e.preventDefault();
        if (isDisabled) {
            return;
        }
        onClick();
    }, [isDisabled, onClick]);
    const addGranteeTooltipId = useIdPrefixed("add-grantee-tooltip");
    return (_jsx("div", { children: _jsx(UiTooltip, { id: addGranteeTooltipId, arrowPlacement: "left", triggerBy: ["hover", "focus"], content: _jsx(FormattedMessage, { id: "shareDialog.share.grantee.add.info" }), anchor: _jsx("button", { id: ADD_GRANTEE_ID, className: buttonClassNames, onClick: handleClick, "aria-label": intl.formatMessage({ id: "shareDialog.share.grantee.addLabel" }), "aria-describedby": addGranteeTooltipId, children: _jsx(FormattedMessage, { id: "shareDialog.share.grantee.add" }) }) }) }));
}
