import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { ChevronLeft, ChevronRight } from "lucide-react";
import { Button } from "../../components/ui/button";
import { Tooltip, TooltipContent, TooltipTrigger, } from "../../components/ui/tooltip";
export function SuggestionVariantSwitcher({ variants, selectedVariantId, onSelect, }) {
    if (variants.length < 2)
        return null;
    const selectedIndex = Math.max(0, variants.findIndex((variant) => variant.id === selectedVariantId));
    const selectedVariant = variants[selectedIndex];
    if (!selectedVariant)
        return null;
    const selectOffset = (offset) => {
        const nextIndex = (selectedIndex + offset + variants.length) % variants.length;
        const nextVariant = variants[nextIndex];
        if (nextVariant)
            onSelect(nextVariant.id);
    };
    return (_jsxs("div", { "data-testid": "suggestion-variant-switcher", className: "border-border-default flex h-7 items-center rounded-md border bg-white shadow-sm", style: { pointerEvents: "auto" }, role: "group", "aria-label": "Suggestion preview variants", children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(Button, { type: "button", size: "iconXs", variant: "ghost", "aria-label": "Preview previous suggestion variant", onClick: (event) => {
                                event.stopPropagation();
                                selectOffset(-1);
                            }, children: _jsx(ChevronLeft, {}) }) }), _jsx(TooltipContent, { side: "top", children: "Previous variant" })] }), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsxs("span", { className: "text-neutral-grey-100 min-w-10 text-center text-xs font-medium", "aria-hidden": "true", children: [selectedIndex + 1, "/", variants.length] }) }), _jsx(TooltipContent, { side: "top", children: selectedVariant.id === "merged"
                            ? "Merged"
                            : `Conflicting suggestion ${selectedIndex}` })] }), _jsxs("span", { className: "sr-only", "aria-live": "polite", children: ["Variant ", selectedIndex + 1, " of ", variants.length] }), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(Button, { type: "button", size: "iconXs", variant: "ghost", "aria-label": "Preview next suggestion variant", onClick: (event) => {
                                event.stopPropagation();
                                selectOffset(1);
                            }, children: _jsx(ChevronRight, {}) }) }), _jsx(TooltipContent, { side: "top", children: "Next variant" })] })] }));
}
//# sourceMappingURL=SuggestionVariantSwitcher.js.map