/**
 * Semantic color helpers for CLI output.
 * Wraps picocolors for consistent styling across all commands.
 */
import pc from 'picocolors';
// ── Base colors (re-export for direct use when semantic helpers don't fit) ───
export { default as pc } from 'picocolors';
// ── Action colors ────────────────────────────────────────────────────────────
export const created = (s) => pc.green(s);
export const updated = (s) => pc.yellow(s);
export const skipped = (s) => pc.dim(s);
export const error = (s) => pc.red(s);
export const success = (s) => pc.green(pc.bold(s));
export const warn = (s) => pc.yellow(s);
export const info = (s) => pc.cyan(s);
// ── Structural colors ────────────────────────────────────────────────────────
export const entityRef = (s) => pc.cyan(s);
export const header = (s) => pc.bold(s);
export const count = (s) => pc.bold(s);
export const dimText = (s) => pc.dim(s);
export const accent = (s) => pc.blue(s);
export const toolRef = (s) => pc.cyan(pc.bold(s));
// ── Diff colorizer ───────────────────────────────────────────────────────────
/**
 * Colorize a raw unified diff string line-by-line.
 *
 * - `+` lines → green
 * - `-` lines → red
 * - `@@` hunk headers → magenta
 * - `---`/`+++` file headers → cyan bold
 * - everything else → dim
 */
export function colorizeDiff(rawDiff) {
    if (!rawDiff)
        return '';
    return rawDiff
        .split('\n')
        .map((line) => {
        if (line.startsWith('+++') || line.startsWith('---')) {
            return pc.cyan(pc.bold(line));
        }
        if (line.startsWith('@@')) {
            return pc.magenta(line);
        }
        if (line.startsWith('+')) {
            return pc.green(line);
        }
        if (line.startsWith('-')) {
            return pc.red(line);
        }
        if (line.startsWith('diff ')) {
            return pc.bold(line);
        }
        return pc.dim(line);
    })
        .join('\n');
}
// ── Agent output colorizer ──────────────────────────────────────────────────
/**
 * Colorize a single line of agent text output for the CLI chat interface.
 * Detects patterns the agent uses (ALL CAPS headers, bullet lists, numbered
 * items) and applies minimal coloring to improve scanability.
 */
export function colorizeAgentLine(line) {
    const trimmed = line.trim();
    // ALL CAPS header lines (2+ chars, only uppercase + digits + spaces + punctuation)
    if (trimmed.length > 2 && /^[A-Z][A-Z\s\d\-—:,.()&/]+$/.test(trimmed)) {
        return pc.bold(line);
    }
    // Numbered items: "1. text" or "  2. text" — color the number
    const numMatch = line.match(/^(\s*)(\d+\.)(\s)(.*)/);
    if (numMatch) {
        return numMatch[1] + pc.cyan(numMatch[2]) + numMatch[3] + numMatch[4];
    }
    // Bullet points: "- text" or "  - text" — dim the dash
    const bulletMatch = line.match(/^(\s*)(- )(.*)/);
    if (bulletMatch) {
        return bulletMatch[1] + pc.dim(bulletMatch[2]) + bulletMatch[3];
    }
    return line;
}
/**
 * Render a user prompt line with a dark gray background (256-color mode).
 * The \x1b[K clears to end of line with the current background, giving
 * a full-width bar effect.
 */
export function renderUserPrompt(message) {
    return `\x1b[48;5;237m > ${message} \x1b[K\x1b[0m`;
}
// ── Compound formatters ──────────────────────────────────────────────────────
/**
 * Format an action line like "  Created: person/john-doe"
 */
export function formatAction(action, type, id) {
    const ref = entityRef(`${type}/${id}`);
    switch (action) {
        case 'create':
            return `  ${created('Created')}: ${ref}`;
        case 'update':
            return `  ${updated('Updated')}: ${ref}`;
        case 'skip':
            return `  ${skipped('Skipped')}: ${skipped(`${type}/${id}`)}`;
    }
}
/**
 * Format a summary line like "3 created, 5 updated, 1 skipped"
 */
export function formatSummary(counts) {
    const parts = [];
    if (counts.created && counts.created > 0)
        parts.push(created(`${counts.created} created`));
    if (counts.updated && counts.updated > 0)
        parts.push(updated(`${counts.updated} updated`));
    if (counts.skipped && counts.skipped > 0)
        parts.push(skipped(`${counts.skipped} skipped`));
    return parts.join(', ') || dimText('no changes');
}
// ── File status helpers (for review) ─────────────────────────────────────────
export function statusIcon(status) {
    switch (status) {
        case 'A': return created('+');
        case 'M': return updated('~');
        case 'D': return error('−');
    }
}
export function statusLabel(status) {
    switch (status) {
        case 'A': return created('new');
        case 'M': return updated('modified');
        case 'D': return error('deleted');
    }
}
//# sourceMappingURL=colors.js.map