import React, { useState, useRef, useEffect } from 'react'; import { Brain, Zap, Sparkles, Atom, X } from 'lucide-react'; import { useTranslation } from 'react-i18next'; const thinkingModes = [ { id: 'none', name: 'Standard', description: 'Regular Claude response', icon: null, prefix: '', color: 'text-gray-600' }, { id: 'think', name: 'Think', description: 'Basic extended thinking', icon: Brain, prefix: 'think', color: 'text-blue-600' }, { id: 'think-hard', name: 'Think Hard', description: 'More thorough evaluation', icon: Zap, prefix: 'think hard', color: 'text-purple-600' }, { id: 'think-harder', name: 'Think Harder', description: 'Deep analysis with alternatives', icon: Sparkles, prefix: 'think harder', color: 'text-indigo-600' }, { id: 'ultrathink', name: 'Ultrathink', description: 'Maximum thinking budget', icon: Atom, prefix: 'ultrathink', color: 'text-red-600' } ]; function ThinkingModeSelector({ selectedMode, onModeChange, onClose, className = '' }) { const { t } = useTranslation('chat'); // Mapping from mode ID to translation key const modeKeyMap = { 'think-hard': 'thinkHard', 'think-harder': 'thinkHarder' }; // Create translated modes for display const translatedModes = thinkingModes.map(mode => { const modeKey = modeKeyMap[mode.id] || mode.id; return { ...mode, name: t(`thinkingMode.modes.${modeKey}.name`), description: t(`thinkingMode.modes.${modeKey}.description`), prefix: t(`thinkingMode.modes.${modeKey}.prefix`) }; }); const [isOpen, setIsOpen] = useState(false); const dropdownRef = useRef(null); useEffect(() => { const handleClickOutside = (event) => { if (dropdownRef.current && !dropdownRef.current.contains(event.target)) { setIsOpen(false); if (onClose) onClose(); } }; document.addEventListener('mousedown', handleClickOutside); return () => document.removeEventListener('mousedown', handleClickOutside); }, [onClose]); const currentMode = translatedModes.find(mode => mode.id === selectedMode) || translatedModes[0]; const IconComponent = currentMode.icon || Brain; return (
{t('thinkingMode.selector.description')}
Tip: {t('thinkingMode.selector.tip')}