import { Brain, Check, ChevronDown } from 'lucide-react'; import React, { useRef } from 'react'; import { createPortal } from 'react-dom'; import { useI18n } from '../../application/i18n/I18nProvider'; import { formatComposerThinkingLabel } from '../../infrastructure/ai/composerPicker'; import { Tooltip, TooltipContent, TooltipTrigger } from '../ui/tooltip'; export interface ComposerThinkingChipProps { levels: readonly string[]; selectedLevel?: string; disabled?: boolean; open: boolean; menuPos: { left: number; bottom: number } | null; onToggle: (rect: DOMRect | undefined) => void; onSelect: (level: string) => void; onClose: () => void; } const chipClassName = 'inline-flex h-6 items-center gap-1 rounded-full px-1.5 text-[10.5px] text-foreground/72'; export const ComposerThinkingChip: React.FC = ({ levels, selectedLevel, disabled = false, open, menuPos, onToggle, onSelect, onClose, }) => { const { t } = useI18n(); const btnRef = useRef(null); const formatLevel = (level: string) => ( level === 'off' ? t('ai.chat.thinkingOff') : formatComposerThinkingLabel(level) ); const label = selectedLevel ? formatLevel(selectedLevel) : t('ai.chat.thinkingLevel'); return ( <> {t('ai.chat.thinkingLevel')} {open && menuPos && createPortal( <>
{levels.map((level) => { const isSelected = selectedLevel === level; return ( ); })}
, document.body, )} ); }; export default React.memo(ComposerThinkingChip);