import { Fragment, jsxs } from "react/jsx-runtime";
import { Box, Text } from "ink";
function ShellRenderer({ data, maxLines = 5 }) {
  const output = data.stdout && data.stdout.length > 0 ? data.stdout : data.stderr || "";
  const outputLines = output.split("\n").filter((line) => line.length > 0);
  const displayLines = outputLines.slice(0, maxLines);
  const truncatedCount = outputLines.length - displayLines.length;
  return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
    data.isBackground && /* @__PURE__ */ jsxs(Text, { color: "gray", children: [
      "    ",
      "(background)"
    ] }),
    outputLines.length === 0 ? /* @__PURE__ */ jsxs(Text, { color: "gray", children: [
      "    ",
      "(No output)"
    ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
      displayLines.map((line, i) => /* @__PURE__ */ jsxs(Text, { color: "gray", wrap: "truncate", children: [
        "    ",
        line
      ] }, i)),
      truncatedCount > 0 && /* @__PURE__ */ jsxs(Text, { color: "gray", children: [
        "    ",
        "+",
        truncatedCount,
        " lines"
      ] })
    ] }),
    data.exitCode !== 0 && /* @__PURE__ */ jsxs(Text, { color: "red", children: [
      "    ",
      "exit code: ",
      data.exitCode
    ] })
  ] });
}
export {
  ShellRenderer
};
