/**
 * Accessible Output Components
 *
 * Provides semantic structure and accessibility features for terminal output.
 * Designed to work well with screen readers and provide text alternatives.
 */
import React from "react";
import { Box, Text } from "ink";
export function SectionHeader({ text, level = 1, color = "cyan" }) {
    const prefix = level === 1 ? "══" : level === 2 ? "──" : "••";
    const suffix = level === 1 ? "══" : level === 2 ? "──" : "";
    const separator = level === 1 ? "═" : level === 2 ? "─" : "";
    const separatorLength = level === 1 ? 40 : level === 2 ? 30 : 0;
    return (React.createElement(Box, { flexDirection: "column", marginY: level === 1 ? 1 : 0 },
        React.createElement(Text, { color: color, bold: level === 1 },
            prefix,
            " ",
            text,
            " ",
            suffix),
        separatorLength > 0 && (React.createElement(Text, { color: color, dimColor: true }, separator.repeat(separatorLength)))));
}
const STATUS_CONFIG = {
    success: { icon: "✓", color: "green", label: "[SUCCESS]" },
    error: { icon: "✗", color: "red", label: "[ERROR]" },
    warning: { icon: "⚠", color: "yellow", label: "[WARNING]" },
    info: { icon: "ℹ", color: "blue", label: "[INFO]" },
    pending: { icon: "○", color: "gray", label: "[PENDING]" },
    running: { icon: "◐", color: "cyan", label: "[RUNNING]" },
};
export function StatusWithText({ status, text, showLabel = true, }) {
    const config = STATUS_CONFIG[status];
    return (React.createElement(Box, null,
        React.createElement(Text, { color: config.color },
            config.icon,
            " "),
        showLabel && React.createElement(Text, { color: config.color },
            config.label,
            " "),
        React.createElement(Text, null, text)));
}
export function AccessibleProgress({ current, total, label, showBar = true, showPercentage = true, width = 20, }) {
    const percentage = total > 0 ? Math.round((current / total) * 100) : 0;
    const filledWidth = Math.round((percentage / 100) * width);
    const emptyWidth = width - filledWidth;
    return (React.createElement(Box, { flexDirection: "column" },
        React.createElement(Box, null,
            React.createElement(Text, null,
                label,
                ": "),
            React.createElement(Text, { bold: true },
                current,
                " of ",
                total),
            showPercentage && React.createElement(Text, { dimColor: true },
                " (",
                percentage,
                "%)")),
        showBar && (React.createElement(Box, { marginLeft: 2 },
            React.createElement(Text, { color: "green" }, "█".repeat(filledWidth)),
            React.createElement(Text, { dimColor: true }, "░".repeat(emptyWidth))))));
}
export function KeyboardShortcut({ keys, description }) {
    return (React.createElement(Box, null,
        keys.map((key, index) => (React.createElement(React.Fragment, { key: key },
            index > 0 && React.createElement(Text, { dimColor: true }, " + "),
            React.createElement(Text, { backgroundColor: "gray", color: "white" },
                " ",
                key,
                " ")))),
        React.createElement(Text, null,
            " ",
            description)));
}
export function HelpPanel({ shortcuts, title = "Keyboard Shortcuts" }) {
    return (React.createElement(Box, { flexDirection: "column", borderStyle: "round", borderColor: "gray", padding: 1 },
        React.createElement(SectionHeader, { text: title, level: 2 }),
        React.createElement(Box, { flexDirection: "column", marginTop: 1 }, shortcuts.map((shortcut, index) => (React.createElement(KeyboardShortcut, { key: index, keys: shortcut.keys, description: shortcut.description }))))));
}
export function AccessibleList({ items, ordered = false, bulletChar = "•", }) {
    return (React.createElement(Box, { flexDirection: "column" }, items.map((item, index) => (React.createElement(Box, { key: index },
        React.createElement(Text, { dimColor: true },
            ordered ? `${index + 1}.` : bulletChar,
            " "),
        React.createElement(Text, null, item))))));
}
export function DefinitionList({ items }) {
    const maxTermLength = Math.max(...items.map((i) => i.term.length));
    return (React.createElement(Box, { flexDirection: "column" }, items.map((item, index) => (React.createElement(Box, { key: index },
        React.createElement(Text, { bold: true }, item.term.padEnd(maxTermLength)),
        React.createElement(Text, { dimColor: true }, " : "),
        React.createElement(Text, null, item.definition))))));
}
export function Announcement({ message, type = "polite", prefix, }) {
    const icon = type === "assertive" ? "⚡" : "📢";
    const color = type === "assertive" ? "yellow" : "cyan";
    return (React.createElement(Box, null,
        React.createElement(Text, { color: color },
            icon,
            " "),
        prefix && React.createElement(Text, { bold: true },
            "[",
            prefix,
            "] "),
        React.createElement(Text, null, message)));
}
export function AccessibleError({ code, message, details, suggestion, docUrl, }) {
    return (React.createElement(Box, { flexDirection: "column", borderStyle: "round", borderColor: "red", padding: 1 },
        React.createElement(Box, null,
            React.createElement(Text, { color: "red" }, "\u2717 [ERROR] "),
            React.createElement(Text, { bold: true }, message)),
        code && (React.createElement(Box, { marginTop: 1 },
            React.createElement(Text, { dimColor: true }, "Code: "),
            React.createElement(Text, null, code))),
        details && (React.createElement(Box, { marginTop: 1 },
            React.createElement(Text, { dimColor: true }, "Details: "),
            React.createElement(Text, null, details))),
        suggestion && (React.createElement(Box, { marginTop: 1 },
            React.createElement(Text, { color: "yellow" }, "\uD83D\uDCA1 Suggestion: "),
            React.createElement(Text, null, suggestion))),
        docUrl && (React.createElement(Box, { marginTop: 1 },
            React.createElement(Text, { dimColor: true }, "\uD83D\uDCDA Documentation: "),
            React.createElement(Text, { color: "cyan" }, docUrl)))));
}
export function AccessibleSuccess({ message, details }) {
    return (React.createElement(Box, { flexDirection: "column" },
        React.createElement(Box, null,
            React.createElement(Text, { color: "green" }, "\u2713 [SUCCESS] "),
            React.createElement(Text, null, message)),
        details && details.length > 0 && (React.createElement(Box, { marginTop: 1, marginLeft: 2, flexDirection: "column" }, details.map((detail, index) => (React.createElement(Text, { key: index, dimColor: true },
            "\u2022 ",
            detail)))))));
}
export function AccessibleTable({ headers, rows, caption }) {
    const colWidths = headers.map((header, i) => Math.max(header.length, ...rows.map((row) => (row[i] || "").length)));
    const formatCell = (content, width) => content.padEnd(width);
    const separator = colWidths.map((w) => "─".repeat(w)).join("─┼─");
    return (React.createElement(Box, { flexDirection: "column" },
        caption && (React.createElement(Text, { bold: true, dimColor: true },
            "Table: ",
            caption)),
        React.createElement(Text, { bold: true }, headers.map((h, i) => formatCell(h, colWidths[i])).join(" │ ")),
        React.createElement(Text, { dimColor: true }, separator),
        rows.map((row, rowIndex) => (React.createElement(Text, { key: rowIndex }, row.map((cell, i) => formatCell(cell || "", colWidths[i])).join(" │ "))))));
}
export function AccessibleCodeBlock({ code, language, showLineNumbers = false, }) {
    const lines = code.split("\n");
    const lineNumberWidth = String(lines.length).length;
    return (React.createElement(Box, { flexDirection: "column", borderStyle: "round", borderColor: "gray", padding: 1 },
        language && (React.createElement(Box, { marginBottom: 1 },
            React.createElement(Text, { backgroundColor: "gray", color: "white" },
                " ",
                language,
                " "))),
        React.createElement(Box, { flexDirection: "column" }, lines.map((line, index) => (React.createElement(Box, { key: index },
            showLineNumbers && (React.createElement(Text, { dimColor: true },
                String(index + 1).padStart(lineNumberWidth),
                " \u2502",
                " ")),
            React.createElement(Text, null, line)))))));
}
export function Divider({ label, width = 40, color = "gray" }) {
    if (!label) {
        return React.createElement(Text, { color: color }, "─".repeat(width));
    }
    const sideWidth = Math.floor((width - label.length - 2) / 2);
    return (React.createElement(Text, { color: color },
        "─".repeat(sideWidth),
        " ",
        label,
        " ",
        "─".repeat(width - sideWidth - label.length - 2)));
}
export default {
    SectionHeader,
    StatusWithText,
    AccessibleProgress,
    KeyboardShortcut,
    HelpPanel,
    AccessibleList,
    DefinitionList,
    Announcement,
    AccessibleError,
    AccessibleSuccess,
    AccessibleTable,
    AccessibleCodeBlock,
    Divider,
};
//# sourceMappingURL=AccessibleOutput.js.map