import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useMemo } from 'react';
import { escapeAnsiCtrlCodes } from '../utils/textUtils.js';
import { UserMessage } from './messages/UserMessage.js';
import { UserShellMessage } from './messages/UserShellMessage.js';
import { GeminiMessage } from './messages/GeminiMessage.js';
import { InfoMessage } from './messages/InfoMessage.js';
import { ErrorMessage } from './messages/ErrorMessage.js';
import { OAuthUrlMessage } from './messages/OAuthUrlMessage.js';
import { ToolGroupMessage } from './messages/ToolGroupMessage.js';
import { GeminiMessageContent } from './messages/GeminiMessageContent.js';
import { CompressionMessage } from './messages/CompressionMessage.js';
import { WarningMessage } from './messages/WarningMessage.js';
import { Box, Text } from 'ink';
import { AboutBox } from './AboutBox.js';
import { StatsDisplay } from './StatsDisplay.js';
import { ModelStatsDisplay } from './ModelStatsDisplay.js';
import { ToolStatsDisplay } from './ToolStatsDisplay.js';
import { CacheStatsDisplay } from './CacheStatsDisplay.js';
import { LBStatsDisplay } from './LBStatsDisplay.js';
import { SessionSummaryDisplay } from './SessionSummaryDisplay.js';
import { Help } from './Help.js';
import { ChatList } from './views/ChatList.js';
export const HistoryItemDisplay = ({ item, availableTerminalHeight, terminalWidth, isPending, config, isFocused = true, slashCommands = [], showTodoPanel = true, activeShellPtyId: _activeShellPtyId, embeddedShellFocused: _embeddedShellFocused, availableTerminalHeightGemini: _availableTerminalHeightGemini, }) => {
    const itemForDisplay = useMemo(() => {
        // Skip sanitization for trusted system message types that may contain ANSI codes
        // for coloring (e.g. from mcpCommand)
        if (item.type === 'info' ||
            item.type === 'error' ||
            item.type === 'warning' ||
            item.type === 'oauth_url') {
            return item;
        }
        return escapeAnsiCtrlCodes(item);
    }, [item]);
    return (_jsxs(Box, { flexDirection: "column", children: [itemForDisplay.type === 'user' && (_jsx(UserMessage, { text: itemForDisplay.text })), itemForDisplay.type === 'user_shell' && (_jsx(UserShellMessage, { text: itemForDisplay.text })), itemForDisplay.type === 'gemini' && (_jsx(GeminiMessage, { text: itemForDisplay.text, isPending: isPending, availableTerminalHeight: _availableTerminalHeightGemini ?? availableTerminalHeight, terminalWidth: terminalWidth, model: itemForDisplay.model, thinkingBlocks: itemForDisplay.thinkingBlocks })), itemForDisplay.type === 'gemini_content' && (_jsx(GeminiMessageContent, { text: itemForDisplay.text, isPending: isPending, availableTerminalHeight: _availableTerminalHeightGemini ?? availableTerminalHeight, terminalWidth: terminalWidth })), itemForDisplay.type === 'info' && (_jsx(InfoMessage, { text: itemForDisplay.text })), itemForDisplay.type === 'warning' && (_jsx(WarningMessage, { text: itemForDisplay.text })), itemForDisplay.type === 'error' && (_jsx(ErrorMessage, { text: itemForDisplay.text })), itemForDisplay.type === 'oauth_url' && (_jsx(OAuthUrlMessage, { text: itemForDisplay.text, url: itemForDisplay.url })), itemForDisplay.type === 'about' && (_jsx(AboutBox, { cliVersion: itemForDisplay.cliVersion, osVersion: itemForDisplay.osVersion, sandboxEnv: itemForDisplay.sandboxEnv, modelVersion: itemForDisplay.modelVersion, selectedAuthType: itemForDisplay.selectedAuthType, gcpProject: itemForDisplay.gcpProject, ideClient: itemForDisplay.ideClient, provider: itemForDisplay.provider, baseURL: itemForDisplay.baseURL, keyfile: itemForDisplay.keyfile }, itemForDisplay.key)), itemForDisplay.type === 'help' && _jsx(Help, { commands: slashCommands }), itemForDisplay.type === 'stats' && (_jsx(StatsDisplay, { duration: itemForDisplay.duration })), itemForDisplay.type === 'model_stats' && _jsx(ModelStatsDisplay, {}), itemForDisplay.type === 'tool_stats' && _jsx(ToolStatsDisplay, {}), itemForDisplay.type === 'cache_stats' && _jsx(CacheStatsDisplay, {}), itemForDisplay.type === 'lb_stats' && _jsx(LBStatsDisplay, {}), itemForDisplay.type === 'quit' && (_jsx(SessionSummaryDisplay, { duration: itemForDisplay.duration })), itemForDisplay.type === 'tool_group' && (_jsx(ToolGroupMessage, { toolCalls: itemForDisplay.tools, groupId: itemForDisplay.id, agentId: itemForDisplay.agentId, availableTerminalHeight: availableTerminalHeight, terminalWidth: terminalWidth, config: config, isFocused: isFocused, showTodoPanel: showTodoPanel })), itemForDisplay.type === 'compression' && (_jsx(CompressionMessage, { compression: itemForDisplay.compression })), itemForDisplay.type === 'extensions_list' && (_jsx(Box, { children: _jsx(Text, { color: "yellow", children: "Extensions list view not yet implemented" }) })), itemForDisplay.type === 'tools_list' && (_jsx(Box, { children: _jsx(Text, { color: "yellow", children: "Tools list view not yet implemented" }) })), itemForDisplay.type === 'mcp_status' && (_jsx(Box, { children: _jsx(Text, { color: "yellow", children: "MCP status view not yet implemented" }) })), itemForDisplay.type === 'chat_list' && (_jsx(ChatList, { chats: itemForDisplay.chats }))] }, itemForDisplay.id));
};
//# sourceMappingURL=HistoryItemDisplay.js.map