import { jsx, jsxs } from "react/jsx-runtime";
import { useMemo } from "react";
import { Box, Text } from "ink";
function MultiLineInput({ value, placeholder, prompt = "> " }) {
  const lines = useMemo(() => {
    if (!value) return [];
    return value.split("\n");
  }, [value]);
  const lineCount = lines.length;
  if (!value && placeholder) {
    return /* @__PURE__ */ jsxs(Box, { flexDirection: "row", children: [
      /* @__PURE__ */ jsx(Text, { color: "green", bold: true, children: prompt }),
      /* @__PURE__ */ jsx(Text, { color: "gray", children: placeholder })
    ] });
  }
  const visibleLines = lineCount > 10 ? lines.slice(-10) : lines;
  const startOffset = lineCount > 10 ? lineCount - 10 : 0;
  return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
    startOffset > 0 && /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Text, { color: "gray", children: [
      "... (",
      startOffset,
      " more lines above)"
    ] }) }),
    visibleLines.map((line, index) => {
      const actualIndex = startOffset + index;
      return /* @__PURE__ */ jsxs(Box, { flexDirection: "row", children: [
        index === 0 && /* @__PURE__ */ jsx(Text, { color: "green", bold: true, children: prompt }),
        index > 0 && /* @__PURE__ */ jsx(Text, { color: "green", children: " ".repeat(prompt.length) }),
        /* @__PURE__ */ jsx(Text, { wrap: "wrap", children: line || " " })
      ] }, actualIndex);
    })
  ] });
}
export {
  MultiLineInput as default
};
