import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { memo, useMemo } from 'react';
import { useMessages } from '../../hooks/useMessages';
import { useSessionStream } from '../../hooks/useSessionStream';
import { useSessions } from '../../hooks/useSessions';
import { MessageThread } from './MessageThread';
import { useToolApprovalShortcuts } from '../../hooks/useToolApprovalShortcuts';
import { SetuTopupModal } from '../settings/SetuTopupModal';
export const MessageThreadContainer = memo(function MessageThreadContainer({ sessionId, onSelectSession, }) {
    const { data: messages = [], isLoading } = useMessages(sessionId);
    const { data: sessions = [] } = useSessions();
    useSessionStream(sessionId);
    // Enable keyboard shortcuts (Y/N/A) for tool approval in this session
    useToolApprovalShortcuts(sessionId);
    const session = useMemo(() => sessions.find((s) => s.id === sessionId), [sessions, sessionId]);
    const isGenerating = useMemo(() => messages.some((m) => m.role === 'assistant' && m.status === 'pending'), [messages]);
    if (isLoading) {
        return (_jsx("div", { className: "flex-1 flex items-center justify-center text-muted-foreground", children: "Loading messages..." }));
    }
    return (_jsxs(_Fragment, { children: [_jsx(MessageThread, { messages: messages, sessionId: sessionId, session: session, isGenerating: isGenerating, onSelectSession: onSelectSession }), _jsx(SetuTopupModal, {})] }));
});
//# sourceMappingURL=MessageThreadContainer.js.map