import { useState, useRef, useEffect } from "react"; import { SendHorizontal, Square } from "lucide-react"; import type { VoiceState } from "../../../hooks/useVoiceSession"; import VoiceMicButton from "./VoiceMicButton"; interface ChatInputProps { onSend: (text: string) => void; onStop?: () => void; isLoading: boolean; disabled?: boolean; voiceState: VoiceState; onVoiceToggle: () => void; } export default function ChatInput({ onSend, onStop, isLoading, disabled, voiceState, onVoiceToggle, }: ChatInputProps) { const [value, setValue] = useState(""); const textareaRef = useRef(null); const isVoiceActive = voiceState !== "IDLE" && voiceState !== "ERROR"; useEffect(() => { const el = textareaRef.current; if (!el) return; el.style.height = "auto"; el.style.height = Math.min(el.scrollHeight, 50) + "px"; }, [value]); const handleSend = () => { const trimmed = value.trim(); if (!trimmed || isLoading || disabled || isVoiceActive) return; onSend(trimmed); setValue(""); }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); handleSend(); } }; const canSend = value.trim().length > 0 && !disabled && !isVoiceActive; return (