/**
 * OwlCoda Native Display Formatter
 *
 * Delegates to the TUI engine (src/native/tui/) for all rendering.
 * This module preserves the legacy API surface for backward compatibility.
 */
import { sgr, Spinner as TuiSpinner, formatToolUseHeader, formatToolResult, formatErrorMessage, formatTokenUsage, formatStopReason as tuiStopReason, formatIterations as tuiIterations, renderWelcome, } from './tui/index.js';
// ─── Legacy ANSI helpers (kept for existing imports) ──────────
/** ANSI color helpers — thin wrapper over TUI sgr. */
export const ansi = {
    reset: sgr.reset,
    bold: sgr.bold,
    dim: sgr.dim,
    italic: sgr.italic,
    red: '\x1b[31m',
    green: '\x1b[32m',
    yellow: '\x1b[33m',
    blue: '\x1b[34m',
    magenta: '\x1b[35m',
    cyan: '\x1b[36m',
    gray: '\x1b[90m',
};
// ─── Tool display (delegates to TUI message.ts) ──────────────
/** Format a tool start message. */
export function formatToolStart(name, input) {
    return formatToolUseHeader(name, input);
}
/** Format a tool end message. */
export function formatToolEnd(name, result, isError, durationMs) {
    return formatToolResult(name, result, isError, durationMs);
}
/** Format an error message. */
export function formatError(error) {
    return formatErrorMessage(error);
}
/** Format iteration count. */
export function formatIterations(count) {
    return tuiIterations(count);
}
/** Truncate long tool output for display. */
export function truncateOutput(text, maxLines = 20) {
    const lines = text.split('\n');
    if (lines.length <= maxLines)
        return text;
    const head = lines.slice(0, maxLines / 2);
    const tail = lines.slice(-maxLines / 2);
    const omitted = lines.length - maxLines;
    return [
        ...head,
        `${sgr.dim}... (${omitted} lines omitted) ...${sgr.reset}`,
        ...tail,
    ].join('\n');
}
/** Render a box-drawn welcome banner using the TUI engine. */
export function formatBanner(opts) {
    return renderWelcome({
        version: opts.version,
        model: opts.model,
        mode: opts.mode,
        sessionId: opts.sessionId,
        cwd: opts.cwd,
        columns: opts.columns,
        recentSessions: opts.recentSessions,
        logoFrame: opts.logoFrame,
        isFirstRun: opts.isFirstRun,
        tips: opts.tips ?? [
            '/help for commands',
            '/model to switch',
            '/editor for multi-line',
            '/quit to exit',
        ],
    });
}
// ─── Response metadata (delegates to TUI message.ts) ─────────
/** Format token usage line (shown after each response). */
export function formatUsage(inputTokens, outputTokens) {
    return formatTokenUsage(inputTokens, outputTokens);
}
/** Format stop reason (shown after truncated/unusual stops). */
export function formatStopReason(reason) {
    return tuiStopReason(reason);
}
// ─── Spinner (delegates to TUI spinner.ts) ────────────────────
/**
 * Spinner for indicating activity.
 * Now backed by the TUI engine's enhanced spinner.
 */
export class Spinner {
    inner = new TuiSpinner({ message: '', style: 'dots' });
    start(message = '') {
        this.inner.start(message);
    }
    stop(clearLine = true) {
        this.inner.stop(clearLine);
    }
}
//# sourceMappingURL=display.js.map