"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var ShellRenderer_exports = {};
__export(ShellRenderer_exports, {
  ShellRenderer: () => ShellRenderer
});
module.exports = __toCommonJS(ShellRenderer_exports);
var import_jsx_runtime = require("react/jsx-runtime");
var import_ink = require("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__ */ (0, import_jsx_runtime.jsxs)(import_ink.Box, { flexDirection: "column", children: [
    data.isBackground && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Text, { color: "gray", children: [
      "    ",
      "(background)"
    ] }),
    outputLines.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Text, { color: "gray", children: [
      "    ",
      "(No output)"
    ] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
      displayLines.map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Text, { color: "gray", wrap: "truncate", children: [
        "    ",
        line
      ] }, i)),
      truncatedCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Text, { color: "gray", children: [
        "    ",
        "+",
        truncatedCount,
        " lines"
      ] })
    ] }),
    data.exitCode !== 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Text, { color: "red", children: [
      "    ",
      "exit code: ",
      data.exitCode
    ] })
  ] });
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  ShellRenderer
});
