"use client"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "@/components/ui/tooltip"; import { BotIcon } from "lucide-react"; import { useEffect, useState } from "react"; import { useTranslations } from "next-intl"; import { Toggle } from "@/components/ui/toggle"; import { useDockviewStore } from "@/stores/dockview"; export default function BotVisibilityToggle() { const { api } = useDockviewStore(); const t = useTranslations(); const [isLoading, setIsLoading] = useState(true); const [isBotVisible, setBotVisible] = useState(false); useEffect(() => { if (api) { const panel = api.getPanel("Bot"); setBotVisible(!!panel); setIsLoading(false); } }, [api]); const handleBotToggle = (newState: boolean) => { if (!api) return; const panel = api.getPanel("Bot"); if (newState) { if (panel) { panel.api.setActive(); } else { api.addPanel({ id: "Bot", component: "Bot", tabComponent: "Bot", title: t("ProblemPage.Bot"), position: { direction: "right", }, }); } } else { if (panel) { api.removePanel(panel); } } setBotVisible(newState); }; return (

{isBotVisible ? t("BotVisibilityToggle.close") : t("BotVisibilityToggle.open")}

); }