"use client"; import { Bot, Minimize2 } from "lucide-react"; import { useCallback, useEffect, useRef, useState } from "react"; import { ChatPanel } from "./chat-panel"; import { useChatbot } from "./chatbot-context"; export function ChatbotContainer() { const { minimized, setMinimized } = useChatbot(); const [position, setPosition] = useState({ x: 0, y: 0 }); const [dragging, setDragging] = useState(false); const [dragStart, setDragStart] = useState({ x: 0, y: 0 }); const inputRef = useRef(null); const handleMouseDown = useCallback( (e: React.MouseEvent) => { setDragging(true); setDragStart({ x: e.clientX - position.x, y: e.clientY - position.y }); }, [position], ); const handleMouseMove = useCallback( (e: React.MouseEvent) => { if (!dragging) return; setPosition({ x: e.clientX - dragStart.x, y: e.clientY - dragStart.y }); }, [dragging, dragStart], ); const handleMouseUp = useCallback(() => setDragging(false), []); // Focus input when chat opens useEffect(() => { if (!minimized) { const id = setTimeout(() => inputRef.current?.focus(), 150); return () => clearTimeout(id); } }, [minimized]); return ( // biome-ignore lint/a11y/noStaticElementInteractions: drag container — mouse-move gesture surface, not keyboard-interactive content
{/* Main chatbot bubble — minimized FAB opens the full chat directly */}
{minimized ? ( ) : (
{/* Drag handle + controls */} {/* biome-ignore lint/a11y/noStaticElementInteractions: drag handle — mouse-only gesture, keyboard users use the buttons in this header */}
Chatbot
{/* Chat panel — always open when bubble is expanded */}
)}
); }