import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { EyeIcon, Lightbulb, Pencil } from "lucide-react";
import { useEditContext } from "../../client/editContext";
import { SimpleIconButton } from "../../ui/SimpleIconButton";
export function EditControls({ hideSuggestions, hideEdit, hidePreview, } = {}) {
    const editContext = useEditContext();
    if (!editContext)
        return null;
    // Calculate total count of comments and suggestions
    const suggestionsCount = editContext.suggestedEdits?.filter((x) => x.status === "pending").length ||
        0;
    const totalCount = suggestionsCount;
    return (_jsxs(_Fragment, { children: [!hideEdit && !editContext.user?.isLimitedPreviewUser && (_jsx(SimpleIconButton, { icon: _jsx(Pencil, { className: "h-6 w-6 p-1", strokeWidth: 1 }), label: "Edit", size: "large", "data-testid": "edit-mode-button", selected: editContext.mode === "edit", onClick: () => editContext.setMode("edit") })), !hidePreview && (_jsx(SimpleIconButton, { icon: _jsx(EyeIcon, { className: "h-6 w-6 p-1", strokeWidth: 1 }), label: "Preview", showTooltip: false, size: "large", "data-testid": "preview-mode-button", selected: editContext.mode === "preview", onClick: () => editContext.setMode("preview") })), !hideSuggestions && (_jsx(SimpleIconButton, { className: "relative", selected: editContext?.mode === "suggestions", icon: _jsx(Lightbulb, { strokeWidth: 1, className: "h-6 w-6 p-1" }), label: "Write suggestions", size: "large", "data-testid": "suggestions-mode-button", onClick: () => {
                    editContext?.setMode("suggestions");
                    editContext?.openSidebar("feedback");
                }, children: totalCount > 0 && (_jsx("div", { className: "bg-highlight-100 absolute -top-1 -right-1 h-4 min-w-[16px] rounded-full px-1 text-center text-[10px] leading-4 font-bold text-white tabular-nums", style: { paddingBottom: "1px" }, "data-affects-toolbar-height": true, children: totalCount > 99 ? "99+" : totalCount })) }))] }));
}
//# sourceMappingURL=EditControls.js.map