import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import React from "react";
import { Text, Box, useStdout } from "ink";
import { useTheme } from "../theme/theme.js";
import { getUserMessageDisplayParts } from "../utils/user-message-display.js";
const USER_MESSAGE_BACKGROUND = "#374151";
const USER_MESSAGE_PREFIX = "> ";
const USER_MESSAGE_TOP_FILL = "▄";
const USER_MESSAGE_BOTTOM_FILL = "▀";
export function UserMessage({ text, imageCount, videoCount, pasteInfo, }) {
    const theme = useTheme();
    const { stdout } = useStdout();
    const parts = getUserMessageDisplayParts(text, pasteInfo);
    const imageLabels = imageCount != null && imageCount > 0
        ? Array.from({ length: imageCount }, (_, i) => `[Image #${i + 1}]`)
        : [];
    const videoLabels = videoCount != null && videoCount > 0
        ? Array.from({ length: videoCount }, (_, i) => `[Video #${i + 1}]`)
        : [];
    const mediaLabels = [...imageLabels, ...videoLabels];
    const messageWidth = Math.max(1, stdout.columns ?? 80);
    const renderUserMessageEdge = (fill) => (_jsx(Box, { width: messageWidth, children: _jsx(Text, { color: USER_MESSAGE_BACKGROUND, children: fill.repeat(messageWidth) }) }));
    return (_jsxs(Box, { flexDirection: "column", width: messageWidth, flexGrow: 0, flexShrink: 0, children: [renderUserMessageEdge(USER_MESSAGE_TOP_FILL), _jsxs(Box, { flexDirection: "row", paddingLeft: 1, paddingRight: 1, flexGrow: 0, flexShrink: 0, backgroundColor: USER_MESSAGE_BACKGROUND, width: messageWidth, children: [_jsx(Box, { width: USER_MESSAGE_PREFIX.length, flexShrink: 0, children: _jsx(Text, { color: theme.commandColor, bold: true, backgroundColor: USER_MESSAGE_BACKGROUND, children: USER_MESSAGE_PREFIX }) }), _jsx(Box, { flexGrow: 1, backgroundColor: USER_MESSAGE_BACKGROUND, children: _jsxs(Text, { wrap: "wrap", color: theme.commandColor, backgroundColor: USER_MESSAGE_BACKGROUND, children: [parts.map((part, index) => (_jsxs(React.Fragment, { children: [index > 0 ? (_jsx(Text, { color: theme.commandColor, backgroundColor: USER_MESSAGE_BACKGROUND, children: " " })) : null, _jsx(Text, { color: theme.commandColor, dimColor: part.kind === "paste", backgroundColor: USER_MESSAGE_BACKGROUND, children: part.text })] }, index))), mediaLabels.map((label) => (_jsx(Text, { color: theme.accent, backgroundColor: USER_MESSAGE_BACKGROUND, children: ` ${label}` }, label)))] }) })] }), renderUserMessageEdge(USER_MESSAGE_BOTTOM_FILL)] }));
}
//# sourceMappingURL=UserMessage.js.map