import clsx from 'clsx' import { useI18n } from '../../i18n' import { useApiTesterState } from './useApiTesterState' import { useChatStreamClient } from './useChatStreamClient' import ConfigPanel from './ConfigPanel' import ChatPanel from './ChatPanel' export default function ApiTesterContainer({ config, onMessage, authFetch }) { const { t } = useI18n() const { model, setModel, message, setMessage, apiKey, setApiKey, selectedAccount, setSelectedAccount, response, setResponse, loading, setLoading, streamingContent, setStreamingContent, streamingThinking, setStreamingThinking, isStreaming, setIsStreaming, streamingMode, setStreamingMode, configExpanded, setConfigExpanded, abortControllerRef, } = useApiTesterState({ t }) const accounts = config.accounts || [] const resolveAccountIdentifier = (acc) => { if (!acc || typeof acc !== 'object') return '' return String(acc.identifier || acc.email || acc.mobile || '').trim() } const configuredKeys = config.keys || [] const trimmedApiKey = apiKey.trim() const defaultKey = configuredKeys[0] || '' const effectiveKey = trimmedApiKey || defaultKey const customKeyActive = trimmedApiKey !== '' const customKeyManaged = customKeyActive && configuredKeys.includes(trimmedApiKey) const models = [ { id: 'deepseek-chat', name: 'deepseek-chat', icon: 'MessageSquare', desc: t('apiTester.models.chat'), color: 'text-amber-500' }, { id: 'deepseek-reasoner', name: 'deepseek-reasoner', icon: 'Cpu', desc: t('apiTester.models.reasoner'), color: 'text-amber-600' }, { id: 'deepseek-chat-search', name: 'deepseek-chat-search', icon: 'SearchIcon', desc: t('apiTester.models.chatSearch'), color: 'text-cyan-500' }, { id: 'deepseek-reasoner-search', name: 'deepseek-reasoner-search', icon: 'SearchIcon', desc: t('apiTester.models.reasonerSearch'), color: 'text-cyan-600' }, ] const { runTest, stopGeneration } = useChatStreamClient({ t, onMessage, model, message, effectiveKey, selectedAccount, streamingMode, abortControllerRef, setLoading, setIsStreaming, setResponse, setStreamingContent, setStreamingThinking, }) return (