import { jsx as _jsx } from "react/jsx-runtime";
import { Text } from "ink";
import { toneColor } from "./terminalTheme.js";
export function Divider(props) {
    const char = props.char ?? "-";
    const width = Math.max(0, props.width);
    const title = props.title?.trim();
    const color = toneColor(props.tone ?? "muted");
    if (!title) {
        return _jsx(Text, { color: color, children: char.repeat(width) });
    }
    const label = ` ${title} `;
    if (label.length >= width) {
        return _jsx(Text, { color: color, children: label.slice(0, width) });
    }
    const remaining = width - label.length;
    const left = Math.floor(remaining / 2);
    const right = remaining - left;
    return _jsx(Text, { color: color, children: `${char.repeat(left)}${label}${char.repeat(right)}` });
}
