import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Tooltip, TooltipContent, TooltipTrigger, } from "../../components/ui/tooltip";
import { cn } from "../../lib/utils";
import { createContext, forwardRef, useContext, } from "react";
const defaultSelectedClassName = "bg-neutral-grey-5 text-neutral-grey-100";
const SimpleIconButtonStyleContext = createContext({});
export function SimpleIconButtonStyleProvider({ children, className, selectedClassName, }) {
    return (_jsx(SimpleIconButtonStyleContext.Provider, { value: { className, selectedClassName }, children: children }));
}
export const SimpleIconButton = forwardRef(({ onClick, className, icon, label, disabled, size, id, selected, selectedClassName, children, showTooltip, tooltipContentClassName, "data-testid": dataTestId, ...props }, ref) => {
    const styleContext = useContext(SimpleIconButtonStyleContext);
    const activeSelectedClassName = selectedClassName ??
        styleContext.selectedClassName ??
        defaultSelectedClassName;
    const buttonElement = (_jsxs("button", { ref: ref, id: id, disabled: disabled, "data-testid": dataTestId, "aria-label": label, "aria-pressed": selected, className: cn("text-neutral-grey-100 inline-flex shrink-0 items-center justify-center rounded-[4px] border border-transparent transition-all", typeof icon === "string" ? icon + " p-[6px]" : "", !className?.includes("p-") &&
            !className?.includes("px-") &&
            !className?.includes("py-") &&
            typeof icon !== "string" &&
            "p-1", disabled
            ? "cursor-default"
            : "hover:border-neutral-grey-15 hover:bg-neutral-grey-5 cursor-pointer", styleContext.className, className, disabled && "opacity-40", size === "large" ? "text-lg" : "text-xs", selected ? activeSelectedClassName : ""), onClick: (ev) => {
            onClick(ev);
        }, ...props, children: [typeof icon !== "string" && icon, children] }));
    if (showTooltip === false) {
        return buttonElement;
    }
    return (_jsxs(Tooltip, { delayDuration: 500, children: [_jsx(TooltipTrigger, { asChild: true, children: buttonElement }), _jsx(TooltipContent, { className: tooltipContentClassName, children: label })] }));
});
SimpleIconButton.displayName = "SimpleIconButton";
//# sourceMappingURL=SimpleIconButton.js.map