import React, { useState, useRef, useEffect } from 'react'; interface ChatInputProps { onSendMessage: (content: string) => void; isSending: boolean; disabled: boolean; } const ChatInput: React.FC = ({ onSendMessage, isSending, disabled }) => { const [message, setMessage] = useState(''); const textareaRef = useRef(null); // Auto-resize textarea useEffect(() => { if (textareaRef.current) { textareaRef.current.style.height = 'auto'; textareaRef.current.style.height = `${Math.min(textareaRef.current.scrollHeight, 200)}px`; } }, [message]); const handleSubmit = () => { const trimmed = message.trim(); if (trimmed && !isSending && !disabled) { onSendMessage(trimmed); setMessage(''); if (textareaRef.current) { textareaRef.current.style.height = 'auto'; } } }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); handleSubmit(); } }; return (