import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import React from "react";
import { Text, Box } from "ink";
import { useTheme } from "../theme/theme.js";
const MAX_DISPLAY_LINES = 20;
export function DiffView({ diff }) {
    const theme = useTheme();
    const lines = diff.split("\n");
    const truncated = lines.length > MAX_DISPLAY_LINES;
    const displayLines = truncated ? lines.slice(0, MAX_DISPLAY_LINES) : lines;
    return (_jsxs(Box, { flexDirection: "column", marginLeft: 2, children: [displayLines.map((line, i) => {
                let color = theme.diffContext;
                if (line.startsWith("+"))
                    color = theme.diffAdded;
                else if (line.startsWith("-"))
                    color = theme.diffRemoved;
                return (_jsx(Text, { color: color, children: line }, i));
            }), truncated && (_jsxs(Text, { color: theme.textDim, children: ["... (", lines.length - MAX_DISPLAY_LINES, " more lines)"] }))] }));
}
//# sourceMappingURL=DiffView.js.map