/**
 * Pure data transformations for session HTML export.
 *
 * This module takes raw session entries and produces view models
 * consumed by template.js. All functions are pure — no DOM, no side effects.
 *
 * The boundary: session-schema.ts defines the JSONL schema (SessionEntry union),
 * this module transforms it into renderable structures, and template.js handles DOM.
 */
/** Base fields present on every session entry. */
export interface EntryBase {
    type: string;
    id: string;
    parentId: string | null;
    timestamp: string;
}
export interface MessageEntry extends EntryBase {
    type: 'message';
    message: {
        role: string;
        content: unknown;
        [key: string]: unknown;
    };
    durationMs?: number;
}
export interface TurnStartEntry extends EntryBase {
    type: 'turn_start';
    turnIndex: number;
}
export interface TurnEndEntry extends EntryBase {
    type: 'turn_end';
    turnIndex: number;
    durationMs: number;
}
export interface SystemPromptEntry extends EntryBase {
    type: 'system_prompt';
    content: string;
}
export interface ToolDefinitionsEntry extends EntryBase {
    type: 'tool_definitions';
    tools: {
        name: string;
        description: string;
        parameters: unknown;
    }[];
}
export interface ToolExecutionEndEntry extends EntryBase {
    type: 'tool_execution_end';
    toolCallId: string;
    toolName: string;
    isError: boolean;
    result: unknown;
}
export interface LlmCallEntry extends EntryBase {
    type: 'llm_call';
    requestId: string;
    body: {
        effort_level?: string;
        max_tokens?: number;
        messages: unknown[];
        model: string;
        speed?: string;
        thinking_type?: string;
        user_message_id?: string;
        tools?: unknown[];
    };
}
export interface SessionInfoEntry extends EntryBase {
    type: 'session_info';
    name?: string;
}
export interface CustomEntry extends EntryBase {
    type: 'custom';
    customType: string;
    data?: unknown;
}
export interface ModelChangeEntry extends EntryBase {
    type: 'model_change';
    provider: string;
    modelId: string;
}
export interface ThinkingLevelChangeEntry extends EntryBase {
    type: 'thinking_level_change';
    thinkingLevel: string;
}
export interface CompactionEntry extends EntryBase {
    type: 'compaction';
    summary: string;
    tokensBefore: number;
    firstKeptEntryId: string;
}
export interface CustomMessageEntry extends EntryBase {
    type: 'custom_message';
    customType: string;
    content: string | Array<{
        type: string;
        text?: string;
    }>;
    display: boolean;
}
export interface LabelEntry extends EntryBase {
    type: 'label';
    targetId: string;
    label: string | undefined;
}
export type Entry = MessageEntry | TurnStartEntry | TurnEndEntry | SystemPromptEntry | SessionInfoEntry | CustomEntry | ModelChangeEntry | ThinkingLevelChangeEntry | CompactionEntry | CustomMessageEntry | LabelEntry | ToolDefinitionsEntry | ToolExecutionEndEntry | LlmCallEntry;
/** Cast helper for entries that may include unknown types (custom, session_info, etc.) */
export declare function asEntry(raw: EntryBase): Entry;
/** All entry type discriminators that the renderer knows about. */
export declare const KNOWN_ENTRY_TYPES: readonly ["message", "turn_start", "turn_end", "system_prompt", "model_change", "thinking_level_change", "compaction", "custom_message", "label", "custom", "session_info", "tool_definitions", "tool_execution_end", "llm_call"];
export interface SessionIndexes {
    /** Entry lookup by ID */
    byId: Map<string, Entry>;
    /** Tool call ID → { name, arguments } */
    toolCallMap: Map<string, {
        name: string;
        arguments: unknown;
    }>;
    /** Label target entry ID → label string */
    labelMap: Map<string, string>;
    /** First message entry ID after a turn_start → { turnIndex, durationMs } */
    turnInfoByMessageId: Map<string, TurnInfo>;
}
export interface TurnInfo {
    turnIndex: number;
    durationMs: number | undefined;
}
/** Build all indexes from raw entries. O(n) per index. */
export declare function buildIndexes(entries: Entry[]): SessionIndexes;
export interface TreeNode {
    entry: Entry;
    children: TreeNode[];
    label: string | undefined;
}
/** Build tree from flat entries. */
export declare function buildTree(entries: Entry[], labelMap: Map<string, string>): TreeNode[];
/** Get path from root to target (the conversation thread). */
export declare function getPath(targetId: string, byId: Map<string, Entry>): Entry[];
/** Build set of entry IDs on path from root to target. */
export declare function buildActivePathIds(targetId: string, byId: Map<string, Entry>): Set<string>;
export interface ToolResult {
    content: Array<{
        type: string;
        text?: string;
        data?: string;
        mimeType?: string;
    }>;
    isError: boolean;
    details?: unknown;
}
export interface SessionExportViewModel {
    tree: TreeNode[];
    toolCallsById: Record<string, {
        name: string;
        arguments: unknown;
    }>;
    turnInfoByMessageId: Record<string, TurnInfo>;
    toolResultsByCallId: Record<string, ToolResult>;
    stats: SessionStats;
}
/** Find the tool result entry matching a tool call ID. */
export declare function findToolResult(toolCallId: string, entries: Entry[]): ToolResult | null;
export declare function buildToolResultMap(entries: Entry[]): Map<string, ToolResult>;
export interface SessionStats {
    userMessages: number;
    assistantMessages: number;
    toolResults: number;
    customMessages: number;
    compactions: number;
    toolCalls: number;
    turnCount: number;
    totalDurationMs: number;
    totalLlmDurationMs: number;
    totalToolDurationMs: number;
    tokens: {
        input: number;
        output: number;
        cacheRead: number;
        cacheWrite: number;
    };
    cost: {
        input: number;
        output: number;
        cacheRead: number;
        cacheWrite: number;
    };
    models: string[];
}
/** Compute aggregate stats from a list of entries. */
export declare function computeStats(entryList: Entry[]): SessionStats;
export declare function buildSessionExportViewModel(entries: Entry[]): SessionExportViewModel;
export declare function formatTokens(count: number): string;
export declare function formatDuration(ms: number): string;
export declare function formatTimestamp(ts: string | undefined): string;
export type FilterMode = 'default' | 'user-only' | 'no-tools' | 'labeled-only' | 'all';
export declare function hasTextContent(content: unknown): boolean;
export declare function extractContent(content: unknown): string;
export interface FilterableEntry {
    entry: Entry;
    label: string | undefined;
}
/** Test whether an entry passes the current filter. */
export declare function passesFilter(item: FilterableEntry, mode: FilterMode, currentLeafId: string | null): boolean;
//# sourceMappingURL=session-view-model.d.ts.map