import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
/**
 * @license
 * Copyright 2025 Vybestack LLC
 * SPDX-License-Identifier: Apache-2.0
 */
import { useCallback, useEffect, useMemo, useState, useRef, useReducer, } from 'react';
import { Box, measureElement, Static, Text, useStdin, useStdout, } from 'ink';
import { StreamingState, MessageType, ToolCallStatus, } from './types.js';
import { useTerminalSize } from './hooks/useTerminalSize.js';
import { useResponsive } from './hooks/useResponsive.js';
import { useGeminiStream } from './hooks/useGeminiStream.js';
import { useLoadingIndicator } from './hooks/useLoadingIndicator.js';
import { useThemeCommand } from './hooks/useThemeCommand.js';
import { useAuthCommand } from './hooks/useAuthCommand.js';
import { useFolderTrust } from './hooks/useFolderTrust.js';
import { useIdeTrustListener } from './hooks/useIdeTrustListener.js';
import { useEditorSettings } from './hooks/useEditorSettings.js';
import { useSlashCommandProcessor } from './hooks/slashCommandProcessor.js';
import { useAutoAcceptIndicator } from './hooks/useAutoAcceptIndicator.js';
import { useConsoleMessages } from './hooks/useConsoleMessages.js';
import { Header } from './components/Header.js';
import { LoadingIndicator } from './components/LoadingIndicator.js';
import { AutoAcceptIndicator } from './components/AutoAcceptIndicator.js';
import { ShellModeIndicator } from './components/ShellModeIndicator.js';
import { InputPrompt } from './components/InputPrompt.js';
import { Footer } from './components/Footer.js';
import { ThemeDialog } from './components/ThemeDialog.js';
import { AuthDialog } from './components/AuthDialog.js';
import { AuthInProgress } from './components/AuthInProgress.js';
import { OAuthCodeDialog } from './components/OAuthCodeDialog.js';
import { EditorSettingsDialog } from './components/EditorSettingsDialog.js';
import { FolderTrustDialog } from './components/FolderTrustDialog.js';
import { ShellConfirmationDialog } from './components/ShellConfirmationDialog.js';
import { RadioButtonSelect } from './components/shared/RadioButtonSelect.js';
import { Colors } from './colors.js';
import { loadHierarchicalLlxprtMemory } from '../config/config.js';
import { SettingScope } from '../config/settings.js';
import { Tips } from './components/Tips.js';
import { ConsolePatcher } from './utils/ConsolePatcher.js';
import { registerCleanup } from '../utils/cleanup.js';
import { DetailedMessagesDisplay } from './components/DetailedMessagesDisplay.js';
import { HistoryItemDisplay } from './components/HistoryItemDisplay.js';
import { ContextSummaryDisplay } from './components/ContextSummaryDisplay.js';
import { useHistory } from './hooks/useHistoryManager.js';
import { useInputHistoryStore } from './hooks/useInputHistoryStore.js';
import { useTodoPausePreserver, TodoPausePreserver, } from './hooks/useTodoPausePreserver.js';
import process from 'node:process';
import { getErrorMessage, getAllLlxprtMdFilenames, ApprovalMode, isEditorAvailable, ideContext, getSettingsService, DebugLogger, uiTelemetryService, } from '@vybestack/llxprt-code-core';
import { IdeIntegrationNudge, } from './IdeIntegrationNudge.js';
import { validateAuthMethod } from '../config/auth.js';
import { useLogger } from './hooks/useLogger.js';
import { StreamingContext } from './contexts/StreamingContext.js';
import { SessionStatsProvider, useSessionStats, } from './contexts/SessionContext.js';
import { useGitBranchName } from './hooks/useGitBranchName.js';
import { useFocus } from './hooks/useFocus.js';
import { useBracketedPaste } from './hooks/useBracketedPaste.js';
import { useTextBuffer } from './components/shared/text-buffer.js';
import { useVimMode, VimModeProvider } from './contexts/VimModeContext.js';
import { useVim } from './hooks/vim.js';
import { useKeypress } from './hooks/useKeypress.js';
import { KeypressProvider } from './contexts/KeypressContext.js';
import { useKittyKeyboardProtocol } from './hooks/useKittyKeyboardProtocol.js';
import { keyMatchers, Command } from './keyMatchers.js';
import * as fs from 'fs';
import { appReducer, initialAppState, } from './reducers/appReducer.js';
import { AppDispatchProvider } from './contexts/AppDispatchContext.js';
import { UpdateNotification } from './components/UpdateNotification.js';
import ansiEscapes from 'ansi-escapes';
import { TodoProvider } from './contexts/TodoProvider.js';
import { ToolCallProvider } from './contexts/ToolCallProvider.js';
import { OverflowProvider } from './contexts/OverflowContext.js';
import { ShowMoreLines } from './components/ShowMoreLines.js';
import { PrivacyNotice } from './privacy/PrivacyNotice.js';
import { useSettingsCommand } from './hooks/useSettingsCommand.js';
import { SettingsDialog } from './components/SettingsDialog.js';
import { setUpdateHandler } from '../utils/handleAutoUpdate.js';
import { appEvents, AppEvent } from '../utils/events.js';
import { getProviderManager } from '../providers/providerManagerInstance.js';
import { useProviderModelDialog } from './hooks/useProviderModelDialog.js';
import { useProviderDialog } from './hooks/useProviderDialog.js';
import { useLoadProfileDialog } from './hooks/useLoadProfileDialog.js';
import { useToolsDialog } from './hooks/useToolsDialog.js';
import { ProviderModelDialog } from './components/ProviderModelDialog.js';
import { ProviderDialog } from './components/ProviderDialog.js';
import { LoadProfileDialog } from './components/LoadProfileDialog.js';
import { ToolsDialog } from './components/ToolsDialog.js';
// Todo UI imports
import { TodoPanel } from './components/TodoPanel.js';
import { useTodoContext } from './contexts/TodoContext.js';
import { useWorkspaceMigration } from './hooks/useWorkspaceMigration.js';
import { WorkspaceMigrationDialog } from './components/WorkspaceMigrationDialog.js';
import { isWorkspaceTrusted } from '../config/trustedFolders.js';
const CTRL_EXIT_PROMPT_DURATION_MS = 1000;
function isToolExecuting(pendingHistoryItems) {
    return pendingHistoryItems.some((item) => {
        if (item && item.type === 'tool_group') {
            return item.tools.some((tool) => ToolCallStatus.Executing === tool.status);
        }
        return false;
    });
}
export const AppWrapper = (props) => {
    const kittyProtocolStatus = useKittyKeyboardProtocol();
    return (_jsx(KeypressProvider, { kittyProtocolEnabled: kittyProtocolStatus.enabled, config: props.config, debugKeystrokeLogging: props.settings.merged.debugKeystrokeLogging, children: _jsx(SessionStatsProvider, { children: _jsx(VimModeProvider, { settings: props.settings, children: _jsx(ToolCallProvider, { sessionId: props.config.getSessionId(), children: _jsx(TodoProvider, { sessionId: props.config.getSessionId(), children: _jsx(AppWithState, { ...props }) }) }) }) }) }));
};
// New intermediate component that manages state and provides context
const AppWithState = (props) => {
    const [appState, appDispatch] = useReducer(appReducer, initialAppState);
    return (_jsx(AppDispatchProvider, { value: appDispatch, children: _jsx(App, { ...props, appState: appState, appDispatch: appDispatch }) }));
};
const App = (props) => {
    const { config, settings, startupWarnings = [], version, appState, appDispatch, } = props;
    const isFocused = useFocus();
    const { isNarrow } = useResponsive();
    useBracketedPaste();
    const [updateInfo, setUpdateInfo] = useState(null);
    const { stdout } = useStdout();
    const nightly = version.includes('nightly');
    const { history, addItem, clearItems, loadHistory } = useHistory();
    const { updateTodos } = useTodoContext();
    const todoPauseController = useMemo(() => new TodoPausePreserver(), []);
    const registerTodoPause = useCallback(() => {
        todoPauseController.registerTodoPause();
    }, [todoPauseController]);
    const [idePromptAnswered, setIdePromptAnswered] = useState(false);
    const currentIDE = config.getIdeClient()?.getCurrentIde();
    useEffect(() => {
        const ideClient = config.getIdeClient();
        if (ideClient) {
            registerCleanup(() => ideClient.disconnect());
        }
    }, [config]);
    const shouldShowIdePrompt = currentIDE &&
        !config.getIdeMode() &&
        !settings.merged.hasSeenIdeIntegrationNudge &&
        !idePromptAnswered;
    useEffect(() => {
        const cleanup = setUpdateHandler(addItem, setUpdateInfo);
        return cleanup;
    }, [addItem]);
    const { consoleMessages, handleNewMessage, clearConsoleMessages: clearConsoleMessagesState, } = useConsoleMessages();
    useEffect(() => {
        const consolePatcher = new ConsolePatcher({
            onNewMessage: handleNewMessage,
            debugMode: config.getDebugMode(),
        });
        consolePatcher.patch();
        registerCleanup(consolePatcher.cleanup);
    }, [handleNewMessage, config]);
    const { stats: sessionStats, updateHistoryTokenCount } = useSessionStats();
    const historyTokenCleanupRef = useRef(null);
    const lastHistoryServiceRef = useRef(null);
    const tokenLogger = useMemo(() => new DebugLogger('llxprt:ui:tokentracking'), []);
    // Set up history token count listener
    useEffect(() => {
        let intervalCleared = false;
        // Poll continuously to detect when the history service changes (e.g., after compression)
        const checkInterval = setInterval(() => {
            if (intervalCleared)
                return;
            const geminiClient = config.getGeminiClient();
            // Check if chat is initialized first
            if (geminiClient?.hasChatInitialized?.()) {
                const historyService = geminiClient.getHistoryService?.();
                if (!historyService && lastHistoryServiceRef.current === null) {
                    tokenLogger.debug(() => 'No history service available yet');
                }
                else if (historyService) {
                    // Always get the current token count even if not a new instance
                    const currentTokens = historyService.getTotalTokens();
                    if (currentTokens > 0) {
                        updateHistoryTokenCount(currentTokens);
                    }
                }
                // Check if we have a new history service instance (happens after compression)
                if (historyService &&
                    historyService !== lastHistoryServiceRef.current) {
                    tokenLogger.debug(() => 'Found new history service, setting up listener');
                    // Clean up old listener if it exists
                    if (historyTokenCleanupRef.current) {
                        historyTokenCleanupRef.current();
                        historyTokenCleanupRef.current = null;
                    }
                    // Store reference to current history service
                    lastHistoryServiceRef.current = historyService;
                    const handleTokensUpdated = (event) => {
                        tokenLogger.debug(() => `Received tokensUpdated event: totalTokens=${event.totalTokens}`);
                        updateHistoryTokenCount(event.totalTokens);
                    };
                    historyService.on('tokensUpdated', handleTokensUpdated);
                    // Initialize with current token count
                    const currentTokens = historyService.getTotalTokens();
                    tokenLogger.debug(() => `Initial token count: ${currentTokens}`);
                    updateHistoryTokenCount(currentTokens);
                    // Store cleanup function for later
                    historyTokenCleanupRef.current = () => {
                        historyService.off('tokensUpdated', handleTokensUpdated);
                    };
                }
            }
        }, 100); // Check every 100ms
        return () => {
            clearInterval(checkInterval);
            intervalCleared = true;
            // Clean up the event listener if it was set up
            if (historyTokenCleanupRef.current) {
                historyTokenCleanupRef.current();
                historyTokenCleanupRef.current = null;
            }
            lastHistoryServiceRef.current = null;
        };
    }, [config, updateHistoryTokenCount, tokenLogger]);
    const [staticNeedsRefresh, setStaticNeedsRefresh] = useState(false);
    const [staticKey, setStaticKey] = useState(0);
    const refreshStatic = useCallback(() => {
        stdout.write(ansiEscapes.clearTerminal);
        setStaticKey((prev) => prev + 1);
    }, [setStaticKey, stdout]);
    const [llxprtMdFileCount, setLlxprtMdFileCount] = useState(0);
    const [debugMessage, setDebugMessage] = useState('');
    const [_themeError, _setThemeError] = useState(null);
    const [authError, setAuthError] = useState(null);
    const [_editorError, _setEditorError] = useState(null);
    const [footerHeight, setFooterHeight] = useState(0);
    // Token metrics state for live updates
    const [tokenMetrics, setTokenMetrics] = useState({
        tokensPerMinute: 0,
        throttleWaitTimeMs: 0,
        sessionTokenTotal: 0,
    });
    const [_corgiMode, setCorgiMode] = useState(false);
    const [_isTrustedFolderState, _setIsTrustedFolder] = useState(isWorkspaceTrusted(settings.merged));
    const [currentModel, setCurrentModel] = useState(config.getModel());
    const [shellModeActive, setShellModeActive] = useState(false);
    const [showErrorDetails, setShowErrorDetails] = useState(false);
    const [showToolDescriptions, setShowToolDescriptions] = useState(false);
    const [ctrlCPressedOnce, setCtrlCPressedOnce] = useState(false);
    const [quittingMessages, setQuittingMessages] = useState(null);
    const ctrlCTimerRef = useRef(null);
    const [ctrlDPressedOnce, setCtrlDPressedOnce] = useState(false);
    const ctrlDTimerRef = useRef(null);
    const [constrainHeight, setConstrainHeight] = useState(true);
    const [showPrivacyNotice, setShowPrivacyNotice] = useState(false);
    const [ideContextState, setIdeContextState] = useState();
    const [showEscapePrompt, setShowEscapePrompt] = useState(false);
    const [showIdeRestartPrompt, setShowIdeRestartPrompt] = useState(false);
    const [isProcessing, setIsProcessing] = useState(false);
    const [providerModels, setProviderModels] = useState([]);
    const { showWorkspaceMigrationDialog, workspaceExtensions, onWorkspaceMigrationDialogOpen, onWorkspaceMigrationDialogClose, } = useWorkspaceMigration(settings);
    useEffect(() => {
        const unsubscribe = ideContext.subscribeToIdeContext(setIdeContextState);
        // Set the initial value
        setIdeContextState(ideContext.getIdeContext());
        return unsubscribe;
    }, []);
    // Update currentModel when settings change - get it from the SAME place as diagnostics
    useEffect(() => {
        const updateModel = async () => {
            const settingsService = getSettingsService();
            // Try to get from SettingsService first (same as diagnostics does)
            if (settingsService && settingsService.getDiagnosticsData) {
                try {
                    const diagnosticsData = await settingsService.getDiagnosticsData();
                    if (diagnosticsData && diagnosticsData.model) {
                        setCurrentModel(diagnosticsData.model);
                        return;
                    }
                }
                catch (_error) {
                    // Fall through to config
                }
            }
            // Otherwise use config (which is what diagnostics falls back to)
            setCurrentModel(config.getModel());
        };
        // Update immediately
        updateModel();
        // Also listen for any changes if SettingsService is available
        const settingsService = getSettingsService();
        if (settingsService) {
            settingsService.on('settings-changed', updateModel);
            return () => {
                settingsService.off('settings-changed', updateModel);
            };
        }
        return undefined;
    }, [config]);
    useEffect(() => {
        const openDebugConsole = () => {
            setShowErrorDetails(true);
            setConstrainHeight(false); // Make sure the user sees the full message.
        };
        appEvents.on(AppEvent.OpenDebugConsole, openDebugConsole);
        const logErrorHandler = (errorMessage) => {
            handleNewMessage({
                type: 'error',
                content: String(errorMessage),
                count: 1,
            });
        };
        appEvents.on(AppEvent.LogError, logErrorHandler);
        return () => {
            appEvents.off(AppEvent.OpenDebugConsole, openDebugConsole);
            appEvents.off(AppEvent.LogError, logErrorHandler);
        };
    }, [handleNewMessage]);
    const openPrivacyNotice = useCallback(() => {
        setShowPrivacyNotice(true);
    }, []);
    const handleEscapePromptChange = useCallback((showPrompt) => {
        setShowEscapePrompt(showPrompt);
    }, []);
    const initialPromptSubmitted = useRef(false);
    const errorCount = useMemo(() => consoleMessages
        .filter((msg) => msg.type === 'error')
        .reduce((total, msg) => total + msg.count, 0), [consoleMessages]);
    const { isThemeDialogOpen, openThemeDialog, handleThemeSelect, handleThemeHighlight, } = useThemeCommand(settings, appState, addItem);
    const { isSettingsDialogOpen, openSettingsDialog, closeSettingsDialog } = useSettingsCommand();
    const { isFolderTrustDialogOpen, handleFolderTrustSelect, isRestarting } = useFolderTrust(settings, config);
    const { needsRestart: ideNeedsRestart } = useIdeTrustListener(config);
    useEffect(() => {
        if (ideNeedsRestart) {
            // IDE trust changed, force a restart.
            setShowIdeRestartPrompt(true);
        }
    }, [ideNeedsRestart]);
    useKeypress((key) => {
        if (key.name === 'r' || key.name === 'R') {
            process.exit(0);
        }
    }, { isActive: showIdeRestartPrompt });
    const { isAuthDialogOpen, openAuthDialog, handleAuthSelect, isAuthenticating, cancelAuthentication, } = useAuthCommand(settings, appState, config);
    useEffect(() => {
        if (settings.merged.selectedAuthType && !settings.merged.useExternalAuth) {
            const error = validateAuthMethod(settings.merged.selectedAuthType);
            if (error) {
                setAuthError(error);
                // Don't automatically open auth dialog - user must use /auth command
            }
        }
    }, [
        settings.merged.selectedAuthType,
        settings.merged.useExternalAuth,
        setAuthError,
    ]);
    // Check for OAuth code needed flag
    useEffect(() => {
        const checkOAuthFlag = setInterval(() => {
            if (global.__oauth_needs_code) {
                // Clear the flag
                global.__oauth_needs_code = false;
                // Open the OAuth code dialog
                appDispatch({ type: 'OPEN_DIALOG', payload: 'oauthCode' });
            }
        }, 100); // Check every 100ms
        return () => clearInterval(checkOAuthFlag);
    }, [appDispatch]);
    const { isEditorDialogOpen, openEditorDialog, handleEditorSelect, exitEditorDialog, } = useEditorSettings(settings, appState, addItem);
    const providerManager = getProviderManager(config, false, settings, addItem);
    const { showDialog: isProviderDialogOpen, openDialog: openProviderDialog, handleSelect: handleProviderSelect, closeDialog: exitProviderDialog, providers: providerOptions, currentProvider: selectedProvider, } = useProviderDialog({
        addMessage: (msg) => addItem({ type: msg.type, text: msg.content }, msg.timestamp.getTime()),
        appState,
        config,
    });
    const { showDialog: isProviderModelDialogOpen, openDialog: openProviderModelDialogRaw, handleSelect: handleProviderModelChange, closeDialog: exitProviderModelDialog, } = useProviderModelDialog({
        addMessage: (msg) => addItem({ type: msg.type, text: msg.content }, msg.timestamp.getTime()),
        appState,
    });
    const openProviderModelDialog = useCallback(async () => {
        try {
            const activeProvider = providerManager.getActiveProvider();
            if (activeProvider) {
                const models = await activeProvider.getModels();
                setProviderModels(models);
            }
        }
        catch (e) {
            console.error('Failed to load models:', e);
            setProviderModels([]);
        }
        await openProviderModelDialogRaw();
    }, [providerManager, openProviderModelDialogRaw]);
    // Watch for model changes from config
    useEffect(() => {
        const checkModelChange = () => {
            const configModel = config.getModel();
            const activeProvider = providerManager.getActiveProvider();
            // Get the actual current model from provider
            const providerModel = activeProvider?.getCurrentModel?.() || configModel;
            // Update UI if different from what we're showing
            if (providerModel !== currentModel) {
                console.debug(`[Model Update] Updating footer from ${currentModel} to ${providerModel}`);
                setCurrentModel(providerModel);
            }
        };
        // Check immediately
        checkModelChange();
        // Check periodically (every 500ms)
        const interval = setInterval(checkModelChange, 500);
        return () => clearInterval(interval);
    }, [config, providerManager, currentModel]); // Include currentModel in dependencies
    const toggleCorgiMode = useCallback(() => {
        setCorgiMode((prev) => !prev);
    }, []);
    const { showDialog: isLoadProfileDialogOpen, openDialog: openLoadProfileDialog, handleSelect: handleProfileSelect, closeDialog: exitLoadProfileDialog, profiles, } = useLoadProfileDialog({
        addMessage: (msg) => addItem({ type: msg.type, text: msg.content }, msg.timestamp.getTime()),
        appState,
        config,
        settings,
    });
    const { showDialog: isToolsDialogOpen, openDialog: openToolsDialogRaw, closeDialog: exitToolsDialog, action: toolsDialogAction, availableTools: toolsDialogTools, disabledTools: toolsDialogDisabledTools, handleSelect: handleToolsSelect, } = useToolsDialog({
        addMessage: (msg) => addItem({ type: msg.type, text: msg.content }, msg.timestamp.getTime()),
        appState,
        config,
    });
    const openToolsDialog = useCallback((action) => {
        openToolsDialogRaw(action);
    }, [openToolsDialogRaw]);
    const performMemoryRefresh = useCallback(async () => {
        addItem({
            type: MessageType.INFO,
            text: 'Refreshing hierarchical memory (LLXPRT.md or other context files)...',
        }, Date.now());
        try {
            const { memoryContent, fileCount } = await loadHierarchicalLlxprtMemory(process.cwd(), settings.merged.loadMemoryFromIncludeDirectories
                ? config.getWorkspaceContext().getDirectories()
                : [], config.getDebugMode(), config.getFileService(), settings.merged, config.getExtensionContextFilePaths(), config.getFolderTrust(), settings.merged.memoryImportFormat || 'tree', // Use setting or default to 'tree'
            config.getFileFilteringOptions());
            config.setUserMemory(memoryContent);
            config.setLlxprtMdFileCount(fileCount);
            setLlxprtMdFileCount(fileCount);
            addItem({
                type: MessageType.INFO,
                text: `Memory refreshed successfully. ${memoryContent.length > 0 ? `Loaded ${memoryContent.length} characters from ${fileCount} file(s).` : 'No memory content found.'}`,
            }, Date.now());
            if (config.getDebugMode()) {
                console.log(`[DEBUG] Refreshed memory content in config: ${memoryContent.substring(0, 200)}...`);
            }
        }
        catch (error) {
            const errorMessage = getErrorMessage(error);
            addItem({
                type: MessageType.ERROR,
                text: `Error refreshing memory: ${errorMessage}`,
            }, Date.now());
            console.error('Error refreshing memory:', error);
        }
    }, [config, addItem, settings.merged]);
    // Removed - consolidated into single useEffect above
    // Poll for token metrics updates
    useEffect(() => {
        const updateTokenMetrics = () => {
            const providerManager = getProviderManager();
            if (providerManager) {
                const metrics = providerManager.getProviderMetrics?.();
                const usage = providerManager.getSessionTokenUsage?.();
                const newMetrics = {
                    tokensPerMinute: metrics?.tokensPerMinute || 0,
                    throttleWaitTimeMs: metrics?.throttleWaitTimeMs || 0,
                    sessionTokenTotal: usage?.total || 0,
                };
                setTokenMetrics(newMetrics);
                // Also update the telemetry service for other components
                if (usage) {
                    uiTelemetryService.setTokenTrackingMetrics({
                        tokensPerMinute: metrics?.tokensPerMinute || 0,
                        throttleWaitTimeMs: metrics?.throttleWaitTimeMs || 0,
                        sessionTokenUsage: {
                            input: usage.input || 0,
                            output: usage.output || 0,
                            cache: usage.cache || 0,
                            tool: usage.tool || 0,
                            thought: usage.thought || 0,
                            total: usage.total || 0,
                        },
                    });
                }
            }
        };
        // Update immediately
        updateTokenMetrics();
        // Poll every second to show live updates
        const interval = setInterval(updateTokenMetrics, 1000);
        return () => clearInterval(interval);
    }, []);
    // Terminal and UI setup
    const { rows: terminalHeight, columns: terminalWidth } = useTerminalSize();
    const { stdin, setRawMode } = useStdin();
    const isInitialMount = useRef(true);
    const widthFraction = 0.9;
    // Calculate inputWidth accounting for:
    // - Prompt: 2 chars ("! " or "> ")
    // - Padding: 2 chars (paddingX={1} on each side in InputPrompt)
    // - Additional margin: 2 chars (for proper wrapping)
    const inputWidth = Math.max(20, Math.floor(terminalWidth * widthFraction) - 6);
    const suggestionsWidth = Math.max(60, Math.floor(terminalWidth * 0.8));
    // Utility callbacks
    const isValidPath = useCallback((filePath) => {
        try {
            return fs.existsSync(filePath) && fs.statSync(filePath).isFile();
        }
        catch (_e) {
            return false;
        }
    }, []);
    const getPreferredEditor = useCallback(() => {
        const editorType = settings.merged.preferredEditor;
        const isValidEditor = isEditorAvailable(editorType);
        if (!isValidEditor) {
            openEditorDialog();
            return;
        }
        return editorType;
    }, [settings, openEditorDialog]);
    const onAuthError = useCallback(() => {
        setAuthError('reauth required');
        // Open the auth dialog when authentication errors occur
        appDispatch({ type: 'OPEN_DIALOG', payload: 'auth' });
    }, [setAuthError, appDispatch]);
    // Commented out unused onOAuthCodeNeeded
    // const onOAuthCodeNeeded = useCallback(
    //   (provider: string) => {
    //     // Store provider for the dialog
    //     (global as unknown as { __oauth_provider: string }).__oauth_provider =
    //       provider;
    //     // Open the OAuth code input dialog
    //     appDispatch({ type: 'OPEN_DIALOG', payload: 'oauthCode' });
    //   },
    //   [appDispatch],
    // );
    const handleAuthTimeout = useCallback(() => {
        setAuthError('Authentication timed out. Please try again.');
        cancelAuthentication();
        // NEVER automatically open auth dialog - user must use /auth
    }, [setAuthError, cancelAuthentication]);
    const handlePrivacyNoticeExit = useCallback(() => {
        setShowPrivacyNotice(false);
    }, []);
    // Core hooks and processors
    const { vimEnabled: vimModeEnabled, vimMode, toggleVimEnabled, } = useVimMode();
    const { handleSlashCommand, slashCommands, pendingHistoryItems: pendingSlashCommandHistoryItems, commandContext, shellConfirmationRequest, confirmationRequest, } = useSlashCommandProcessor(config, settings, addItem, clearItems, loadHistory, refreshStatic, setDebugMessage, openThemeDialog, openAuthDialog, openEditorDialog, openProviderDialog, openProviderModelDialog, openLoadProfileDialog, openToolsDialog, toggleCorgiMode, setQuittingMessages, openPrivacyNotice, openSettingsDialog, toggleVimEnabled, setIsProcessing, setLlxprtMdFileCount);
    // Memoize viewport to ensure it updates when inputWidth changes
    const viewport = useMemo(() => ({ height: 10, width: inputWidth }), [inputWidth]);
    const buffer = useTextBuffer({
        initialText: '',
        viewport,
        stdin,
        setRawMode,
        isValidPath,
        shellModeActive,
    });
    // Independent input history management (unaffected by /clear)
    const inputHistoryStore = useInputHistoryStore();
    const handleUserCancel = useCallback(() => {
        const lastUserMessage = inputHistoryStore.inputHistory.at(-1);
        if (lastUserMessage) {
            buffer.setText(lastUserMessage);
        }
    }, [buffer, inputHistoryStore.inputHistory]);
    const handleOAuthCodeDialogClose = useCallback(() => {
        appDispatch({ type: 'CLOSE_DIALOG', payload: 'oauthCode' });
    }, [appDispatch]);
    const handleOAuthCodeSubmit = useCallback(async (code) => {
        const provider = global
            .__oauth_provider;
        if (provider === 'anthropic') {
            // Get the OAuth manager from provider manager
            const { getOAuthManager } = await import('../providers/providerManagerInstance.js');
            const oauthManager = getOAuthManager();
            if (oauthManager) {
                const anthropicProvider = oauthManager.getProvider('anthropic');
                if (anthropicProvider && 'submitAuthCode' in anthropicProvider) {
                    // This will resolve the promise in initiateAuth
                    anthropicProvider.submitAuthCode(code);
                }
            }
        }
    }, []);
    const { streamingState, submitQuery, initError, pendingHistoryItems: pendingGeminiHistoryItems, thought, cancelOngoingRequest, } = useGeminiStream(config.getGeminiClient(), history, addItem, config, settings, setDebugMessage, handleSlashCommand, shellModeActive, getPreferredEditor, onAuthError, performMemoryRefresh, refreshStatic, handleUserCancel, registerTodoPause);
    const pendingHistoryItems = useMemo(() => [...pendingSlashCommandHistoryItems, ...pendingGeminiHistoryItems], [pendingSlashCommandHistoryItems, pendingGeminiHistoryItems]);
    // Message queue functionality removed - not implemented
    // Update the cancel handler with message queue support
    const cancelHandlerRef = useRef(null);
    cancelHandlerRef.current = useCallback(() => {
        if (isToolExecuting(pendingHistoryItems)) {
            buffer.setText(''); // Just clear the prompt
            return;
        }
        const lastUserMessage = inputHistoryStore.inputHistory.at(-1);
        const textToSet = lastUserMessage || '';
        // Queue functionality removed - no queued messages to append
        if (textToSet) {
            buffer.setText(textToSet);
        }
    }, [buffer, inputHistoryStore.inputHistory, pendingHistoryItems]);
    // Input handling - queue messages for processing
    const handleFinalSubmit = useCallback((submittedValue) => {
        const trimmedValue = submittedValue.trim();
        if (trimmedValue.length > 0) {
            // Add to independent input history
            inputHistoryStore.addInput(trimmedValue);
            submitQuery(trimmedValue);
        }
    }, [submitQuery, inputHistoryStore]);
    const { handleUserInputSubmit } = useTodoPausePreserver({
        controller: todoPauseController,
        updateTodos,
        handleFinalSubmit,
    });
    const handleIdePromptComplete = useCallback((result) => {
        if (result.userSelection === 'yes') {
            if (result.isExtensionPreInstalled) {
                handleSlashCommand('/ide enable');
            }
            else {
                handleSlashCommand('/ide install');
            }
            settings.setValue(SettingScope.User, 'hasSeenIdeIntegrationNudge', true);
        }
        else if (result.userSelection === 'dismiss') {
            settings.setValue(SettingScope.User, 'hasSeenIdeIntegrationNudge', true);
        }
        setIdePromptAnswered(true);
    }, [handleSlashCommand, settings]);
    const { handleInput: vimHandleInput } = useVim(buffer, handleFinalSubmit);
    const { elapsedTime, currentLoadingPhrase } = useLoadingIndicator(streamingState, settings.merged.customWittyPhrases);
    const showAutoAcceptIndicator = useAutoAcceptIndicator({ config, addItem });
    const handleExit = useCallback((pressedOnce, setPressedOnce, timerRef) => {
        if (pressedOnce) {
            if (timerRef.current) {
                clearTimeout(timerRef.current);
            }
            // Directly invoke the central command handler.
            handleSlashCommand('/quit');
        }
        else {
            setPressedOnce(true);
            timerRef.current = setTimeout(() => {
                setPressedOnce(false);
                timerRef.current = null;
            }, CTRL_EXIT_PROMPT_DURATION_MS);
        }
    }, [handleSlashCommand]);
    const handleSettingsRestart = useCallback(() => {
        handleSlashCommand('/quit');
    }, [handleSlashCommand]);
    const handleGlobalKeypress = useCallback((key) => {
        // Debug log keystrokes if enabled
        if (settings.merged.debugKeystrokeLogging) {
            console.log('[DEBUG] Keystroke:', JSON.stringify(key));
        }
        let enteringConstrainHeightMode = false;
        if (!constrainHeight) {
            enteringConstrainHeightMode = true;
            setConstrainHeight(true);
        }
        if (keyMatchers[Command.SHOW_ERROR_DETAILS](key)) {
            setShowErrorDetails((prev) => !prev);
        }
        else if (keyMatchers[Command.TOGGLE_TOOL_DESCRIPTIONS](key)) {
            const newValue = !showToolDescriptions;
            setShowToolDescriptions(newValue);
            const mcpServers = config.getMcpServers();
            if (Object.keys(mcpServers || {}).length > 0) {
                handleSlashCommand(newValue ? '/mcp desc' : '/mcp nodesc');
            }
        }
        else if (keyMatchers[Command.TOGGLE_IDE_CONTEXT_DETAIL](key) &&
            config.getIdeMode() &&
            ideContextState) {
            // Show IDE status when in IDE mode and context is available.
            handleSlashCommand('/ide status');
        }
        else if (keyMatchers[Command.QUIT](key)) {
            // When authenticating, let AuthInProgress component handle Ctrl+C.
            if (isAuthenticating) {
                return;
            }
            if (!ctrlCPressedOnce) {
                cancelOngoingRequest?.();
            }
            handleExit(ctrlCPressedOnce, setCtrlCPressedOnce, ctrlCTimerRef);
        }
        else if (keyMatchers[Command.EXIT](key)) {
            if (buffer.text.length > 0) {
                return;
            }
            handleExit(ctrlDPressedOnce, setCtrlDPressedOnce, ctrlDTimerRef);
        }
        else if (keyMatchers[Command.SHOW_MORE_LINES](key) &&
            !enteringConstrainHeightMode) {
            setConstrainHeight(false);
        }
    }, [
        constrainHeight,
        setConstrainHeight,
        setShowErrorDetails,
        showToolDescriptions,
        setShowToolDescriptions,
        config,
        ideContextState,
        handleExit,
        ctrlCPressedOnce,
        setCtrlCPressedOnce,
        ctrlCTimerRef,
        buffer.text.length,
        ctrlDPressedOnce,
        setCtrlDPressedOnce,
        ctrlDTimerRef,
        handleSlashCommand,
        isAuthenticating,
        cancelOngoingRequest,
        settings.merged.debugKeystrokeLogging,
    ]);
    useKeypress(handleGlobalKeypress, {
        isActive: true,
    });
    useEffect(() => {
        if (config) {
            setLlxprtMdFileCount(config.getLlxprtMdFileCount());
        }
    }, [config, config.getLlxprtMdFileCount]);
    const logger = useLogger(config.storage);
    // Initialize independent input history from logger
    useEffect(() => {
        inputHistoryStore.initializeFromLogger(logger);
    }, [logger, inputHistoryStore]);
    const isInputActive = (streamingState === StreamingState.Idle ||
        streamingState === StreamingState.Responding) &&
        !initError &&
        !isProcessing;
    const handleClearScreen = useCallback(() => {
        clearItems();
        clearConsoleMessagesState();
        console.clear();
        refreshStatic();
    }, [clearItems, clearConsoleMessagesState, refreshStatic]);
    const handleConfirmationSelect = useCallback((value) => {
        if (confirmationRequest) {
            confirmationRequest.onConfirm(value);
        }
    }, [confirmationRequest]);
    const mainControlsRef = useRef(null);
    const pendingHistoryItemRef = useRef(null);
    useEffect(() => {
        if (mainControlsRef.current) {
            const fullFooterMeasurement = measureElement(mainControlsRef.current);
            setFooterHeight(fullFooterMeasurement.height);
        }
    }, [terminalHeight, consoleMessages, showErrorDetails]);
    const staticExtraHeight = /* margins and padding */ 3;
    const availableTerminalHeight = useMemo(() => terminalHeight - footerHeight - staticExtraHeight, [terminalHeight, footerHeight]);
    useEffect(() => {
        // skip refreshing Static during first mount
        if (isInitialMount.current) {
            isInitialMount.current = false;
            return;
        }
        // debounce so it doesn't fire up too often during resize
        const handler = setTimeout(() => {
            setStaticNeedsRefresh(false);
            refreshStatic();
        }, 300);
        return () => {
            clearTimeout(handler);
        };
    }, [terminalWidth, terminalHeight, refreshStatic]);
    useEffect(() => {
        if (streamingState === StreamingState.Idle && staticNeedsRefresh) {
            setStaticNeedsRefresh(false);
            refreshStatic();
        }
    }, [streamingState, refreshStatic, staticNeedsRefresh]);
    const filteredConsoleMessages = useMemo(() => {
        if (config.getDebugMode()) {
            return consoleMessages;
        }
        return consoleMessages.filter((msg) => msg.type !== 'debug');
    }, [consoleMessages, config]);
    const branchName = useGitBranchName(config.getTargetDir());
    const contextFileNames = useMemo(() => {
        const fromSettings = settings.merged.contextFileName;
        if (fromSettings) {
            return Array.isArray(fromSettings) ? fromSettings : [fromSettings];
        }
        return getAllLlxprtMdFilenames();
    }, [settings.merged.contextFileName]);
    const initialPrompt = useMemo(() => config.getQuestion(), [config]);
    const geminiClient = config.getGeminiClient();
    useEffect(() => {
        if (initialPrompt &&
            !initialPromptSubmitted.current &&
            !isAuthenticating &&
            !isAuthDialogOpen &&
            !isThemeDialogOpen &&
            !isEditorDialogOpen &&
            !isProviderDialogOpen &&
            !isProviderModelDialogOpen &&
            !isToolsDialogOpen &&
            !showPrivacyNotice &&
            geminiClient) {
            submitQuery(initialPrompt);
            initialPromptSubmitted.current = true;
        }
    }, [
        initialPrompt,
        submitQuery,
        isAuthenticating,
        isAuthDialogOpen,
        isThemeDialogOpen,
        isEditorDialogOpen,
        isProviderDialogOpen,
        isProviderModelDialogOpen,
        isToolsDialogOpen,
        showPrivacyNotice,
        geminiClient,
    ]);
    if (quittingMessages) {
        return (_jsx(Box, { flexDirection: "column", marginBottom: 1, children: quittingMessages.map((item) => (_jsx(HistoryItemDisplay, { availableTerminalHeight: constrainHeight ? availableTerminalHeight : undefined, terminalWidth: terminalWidth, item: item, isPending: false, config: config, slashCommands: slashCommands, showTodoPanel: showTodoPanelSetting }, item.id))) }));
    }
    const mainAreaWidth = Math.floor(terminalWidth * 0.9);
    const debugConsoleMaxHeight = Math.floor(Math.max(terminalHeight * 0.2, 5));
    // Arbitrary threshold to ensure that items in the static area are large
    // enough but not too large to make the terminal hard to use.
    const staticAreaMaxItemHeight = Math.max(terminalHeight * 4, 100);
    // Detect PowerShell for file reference syntax tip
    const isPowerShell = process.env.PSModulePath !== undefined ||
        process.env.PSVERSION !== undefined;
    const placeholder = vimModeEnabled
        ? "  Press 'i' for INSERT mode and 'Esc' for NORMAL mode."
        : isPowerShell
            ? '  Type your message, @path/to/file or +path/to/file'
            : '  Type your message or @path/to/file';
    const showTodoPanelSetting = settings.merged.showTodoPanel ?? true;
    const hideContextSummary = settings.merged.hideContextSummary ?? false;
    return (_jsx(StreamingContext.Provider, { value: streamingState, children: _jsxs(Box, { flexDirection: "column", width: "90%", children: [_jsx(Static, { items: [
                        _jsxs(Box, { flexDirection: "column", children: [!(settings.merged.hideBanner || config.getScreenReader()) && (_jsx(Header, { terminalWidth: terminalWidth, version: version, nightly: nightly })), !(settings.merged.hideTips || config.getScreenReader()) && (_jsx(Tips, { config: config }))] }, "header"),
                        ...history.map((h) => (_jsx(HistoryItemDisplay, { terminalWidth: mainAreaWidth, availableTerminalHeight: staticAreaMaxItemHeight, item: h, isPending: false, config: config, slashCommands: slashCommands, showTodoPanel: showTodoPanelSetting }, h.id))),
                    ], children: (item) => item }, staticKey), _jsx(OverflowProvider, { children: _jsxs(Box, { ref: pendingHistoryItemRef, flexDirection: "column", children: [pendingHistoryItems.map((item, i) => (_jsx(HistoryItemDisplay, { availableTerminalHeight: constrainHeight ? availableTerminalHeight : undefined, terminalWidth: mainAreaWidth, 
                                // TODO(taehykim): It seems like references to ids aren't necessary in
                                // HistoryItemDisplay. Refactor later. Use a fake id for now.
                                item: { ...item, id: 0 }, isPending: true, config: config, isFocused: !isEditorDialogOpen, slashCommands: slashCommands, showTodoPanel: showTodoPanelSetting }, i))), _jsx(ShowMoreLines, { constrainHeight: constrainHeight })] }) }), _jsxs(Box, { flexDirection: "column", ref: mainControlsRef, children: [updateInfo && _jsx(UpdateNotification, { message: updateInfo.message }), startupWarnings.length > 0 && (_jsx(Box, { borderStyle: "round", borderColor: Colors.AccentYellow, paddingX: 1, marginY: 1, flexDirection: "column", children: startupWarnings.map((warning, index) => (_jsx(Text, { color: Colors.AccentYellow, children: warning }, index))) })), showTodoPanelSetting && _jsx(TodoPanel, { width: inputWidth }), showWorkspaceMigrationDialog ? (_jsx(WorkspaceMigrationDialog, { workspaceExtensions: workspaceExtensions, onOpen: onWorkspaceMigrationDialogOpen, onClose: onWorkspaceMigrationDialogClose })) : shouldShowIdePrompt && currentIDE ? (_jsx(IdeIntegrationNudge, { ide: currentIDE, onComplete: handleIdePromptComplete })) : showIdeRestartPrompt ? (_jsx(Box, { borderStyle: "round", borderColor: Colors.AccentYellow, paddingX: 1, children: _jsx(Text, { color: Colors.AccentYellow, children: "Workspace trust has changed. Press 'r' to restart Gemini to apply the changes." }) })) : isFolderTrustDialogOpen ? (_jsx(FolderTrustDialog, { onSelect: handleFolderTrustSelect, isRestarting: isRestarting })) : shellConfirmationRequest ? (_jsx(ShellConfirmationDialog, { request: shellConfirmationRequest })) : confirmationRequest ? (_jsxs(Box, { flexDirection: "column", children: [confirmationRequest.prompt, _jsx(Box, { paddingY: 1, children: _jsx(RadioButtonSelect, { isFocused: !!confirmationRequest, items: [
                                            { label: 'Yes', value: true },
                                            { label: 'No', value: false },
                                        ], onSelect: handleConfirmationSelect }) })] })) : isThemeDialogOpen ? (_jsxs(Box, { flexDirection: "column", children: [_themeError && (_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: Colors.AccentRed, children: _themeError }) })), _jsx(ThemeDialog, { onSelect: handleThemeSelect, onHighlight: handleThemeHighlight, settings: settings, availableTerminalHeight: constrainHeight
                                        ? terminalHeight - staticExtraHeight
                                        : undefined, terminalWidth: mainAreaWidth })] })) : isSettingsDialogOpen ? (_jsx(Box, { flexDirection: "column", children: _jsx(SettingsDialog, { settings: settings, onSelect: closeSettingsDialog, onRestartRequest: handleSettingsRestart }) })) : isAuthenticating ? (_jsxs(_Fragment, { children: [_jsx(AuthInProgress, { onTimeout: handleAuthTimeout }), showErrorDetails && (_jsx(OverflowProvider, { children: _jsxs(Box, { flexDirection: "column", children: [_jsx(DetailedMessagesDisplay, { messages: filteredConsoleMessages, maxHeight: constrainHeight ? debugConsoleMaxHeight : undefined, width: inputWidth }), _jsx(ShowMoreLines, { constrainHeight: constrainHeight })] }) }))] })) : isAuthDialogOpen ? (_jsx(Box, { flexDirection: "column", children: _jsx(AuthDialog, { onSelect: handleAuthSelect, settings: settings, initialErrorMessage: authError }) })) : appState.openDialogs.oauthCode ? (_jsx(Box, { flexDirection: "column", children: _jsx(OAuthCodeDialog, { provider: global
                                    .__oauth_provider || 'anthropic', onClose: handleOAuthCodeDialogClose, onSubmit: handleOAuthCodeSubmit }) })) : isEditorDialogOpen ? (_jsxs(Box, { flexDirection: "column", children: [_editorError && (_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: Colors.AccentRed, children: _editorError }) })), _jsx(EditorSettingsDialog, { onSelect: handleEditorSelect, settings: settings, onExit: exitEditorDialog })] })) : isProviderDialogOpen ? (_jsx(Box, { flexDirection: "column", children: _jsx(ProviderDialog, { providers: providerOptions, currentProvider: selectedProvider, onSelect: handleProviderSelect, onClose: exitProviderDialog }) })) : isProviderModelDialogOpen ? (_jsx(Box, { flexDirection: "column", children: _jsx(ProviderModelDialog, { models: providerModels, currentModel: currentModel, onSelect: handleProviderModelChange, onClose: exitProviderModelDialog }) })) : isLoadProfileDialogOpen ? (_jsx(Box, { flexDirection: "column", children: _jsx(LoadProfileDialog, { profiles: profiles, onSelect: handleProfileSelect, onClose: exitLoadProfileDialog }) })) : isToolsDialogOpen ? (_jsx(Box, { flexDirection: "column", children: _jsx(ToolsDialog, { tools: toolsDialogTools, action: toolsDialogAction, disabledTools: toolsDialogDisabledTools, onSelect: handleToolsSelect, onClose: exitToolsDialog }) })) : showPrivacyNotice ? (_jsx(PrivacyNotice, { onExit: handlePrivacyNoticeExit, config: config })) : (_jsxs(_Fragment, { children: [_jsx(LoadingIndicator, { thought: streamingState === StreamingState.WaitingForConfirmation ||
                                        config.getAccessibility()?.disableLoadingPhrases ||
                                        config.getScreenReader()
                                        ? undefined
                                        : thought, currentLoadingPhrase: config.getAccessibility()?.disableLoadingPhrases ||
                                        config.getScreenReader()
                                        ? undefined
                                        : currentLoadingPhrase, elapsedTime: elapsedTime }), _jsxs(Box, { marginTop: 1, display: "flex", justifyContent: hideContextSummary ? 'flex-start' : 'space-between', width: "100%", children: [_jsxs(Box, { children: [process.env.GEMINI_SYSTEM_MD && (_jsx(Text, { color: Colors.AccentRed, children: "|\u2310\u25A0_\u25A0| " })), ctrlCPressedOnce ? (_jsx(Text, { color: Colors.AccentYellow, children: "Press Ctrl+C again to exit." })) : ctrlDPressedOnce ? (_jsx(Text, { color: Colors.AccentYellow, children: "Press Ctrl+D again to exit." })) : showEscapePrompt ? (_jsx(Text, { color: Colors.Gray, children: "Press Esc again to clear." })) : !hideContextSummary ? (_jsx(ContextSummaryDisplay, { ideContext: ideContextState, llxprtMdFileCount: llxprtMdFileCount, contextFileNames: contextFileNames, mcpServers: config.getMcpServers(), blockedMcpServers: config.getBlockedMcpServers(), showToolDescriptions: showToolDescriptions })) : null] }), _jsxs(Box, { paddingTop: isNarrow ? 1 : 0, marginLeft: hideContextSummary ? 1 : 2, children: [showAutoAcceptIndicator !== ApprovalMode.DEFAULT &&
                                                    !shellModeActive && (_jsx(AutoAcceptIndicator, { approvalMode: showAutoAcceptIndicator })), shellModeActive && _jsx(ShellModeIndicator, {})] })] }), showErrorDetails && (_jsx(OverflowProvider, { children: _jsxs(Box, { flexDirection: "column", children: [_jsx(DetailedMessagesDisplay, { messages: filteredConsoleMessages, maxHeight: constrainHeight ? debugConsoleMaxHeight : undefined, width: inputWidth }), _jsx(ShowMoreLines, { constrainHeight: constrainHeight })] }) })), isInputActive && (_jsx(_Fragment, { children: _jsx(InputPrompt, { buffer: buffer, inputWidth: inputWidth, suggestionsWidth: suggestionsWidth, onSubmit: handleUserInputSubmit, userMessages: inputHistoryStore.inputHistory, onClearScreen: handleClearScreen, config: config, slashCommands: slashCommands, commandContext: commandContext, shellModeActive: shellModeActive, setShellModeActive: setShellModeActive, onEscapePromptChange: handleEscapePromptChange, focus: isFocused, vimHandleInput: vimHandleInput, placeholder: placeholder }) }))] })), initError && streamingState !== StreamingState.Responding && (_jsx(Box, { borderStyle: "round", borderColor: Colors.AccentRed, paddingX: 1, marginBottom: 1, children: history.find((item) => item.type === 'error' && item.text?.includes(initError))?.text ? (_jsx(Text, { color: Colors.AccentRed, children: history.find((item) => item.type === 'error' && item.text?.includes(initError))?.text })) : (_jsxs(_Fragment, { children: [_jsxs(Text, { color: Colors.AccentRed, children: ["Initialization Error: ", initError] }), _jsxs(Text, { color: Colors.AccentRed, children: [' ', "Please check API key and configuration."] })] })) })), !settings.merged.hideFooter && (_jsx(Footer, { model: currentModel, targetDir: config.getTargetDir(), debugMode: config.getDebugMode(), branchName: branchName, debugMessage: debugMessage, errorCount: errorCount, showErrorDetails: showErrorDetails, showMemoryUsage: config.getDebugMode() ||
                                settings.merged.showMemoryUsage ||
                                false, historyTokenCount: sessionStats.historyTokenCount, nightly: nightly, vimMode: vimModeEnabled ? vimMode : undefined, contextLimit: config.getEphemeralSetting('context-limit'), isTrustedFolder: config.isTrustedFolder(), tokensPerMinute: tokenMetrics.tokensPerMinute, throttleWaitTimeMs: tokenMetrics.throttleWaitTimeMs, sessionTokenTotal: tokenMetrics.sessionTokenTotal, hideCWD: settings.merged.hideCWD, hideSandboxStatus: settings.merged.hideSandboxStatus, hideModelInfo: settings.merged.hideModelInfo }))] })] }) }));
};
//# sourceMappingURL=App.js.map