"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 MultiLineInput_exports = {};
__export(MultiLineInput_exports, {
  default: () => MultiLineInput
});
module.exports = __toCommonJS(MultiLineInput_exports);
var import_jsx_runtime = require("react/jsx-runtime");
var import_react = require("react");
var import_ink = require("ink");
function MultiLineInput({ value, placeholder, prompt = "> " }) {
  const lines = (0, import_react.useMemo)(() => {
    if (!value) return [];
    return value.split("\n");
  }, [value]);
  const lineCount = lines.length;
  if (!value && placeholder) {
    return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Box, { flexDirection: "row", children: [
      /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { color: "green", bold: true, children: prompt }),
      /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { color: "gray", children: placeholder })
    ] });
  }
  const visibleLines = lineCount > 10 ? lines.slice(-10) : lines;
  const startOffset = lineCount > 10 ? lineCount - 10 : 0;
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Box, { flexDirection: "column", children: [
    startOffset > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Box, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Text, { color: "gray", children: [
      "... (",
      startOffset,
      " more lines above)"
    ] }) }),
    visibleLines.map((line, index) => {
      const actualIndex = startOffset + index;
      return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Box, { flexDirection: "row", children: [
        index === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { color: "green", bold: true, children: prompt }),
        index > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { color: "green", children: " ".repeat(prompt.length) }),
        /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { wrap: "wrap", children: line || " " })
      ] }, actualIndex);
    })
  ] });
}
