import { jsx, jsxs } from "react/jsx-runtime";
import { useInput, Text } from "ink";
function CustomInput({
  value,
  onChange,
  onSubmit,
  placeholder,
  isProcessing = false,
  onWordDelete,
  onLineDelete,
  onToggleMultiLine
}) {
  useInput(
    (inputChar, key) => {
      if (isProcessing) return;
      if (key.return && key.shift) {
        onToggleMultiLine?.();
        return;
      }
      if (key.return) {
        onSubmit(value);
        return;
      }
      if (key.ctrl && inputChar === "u") {
        onLineDelete?.();
        return;
      }
      if (key.ctrl && inputChar === "w") {
        onWordDelete?.();
        return;
      }
      if (key.backspace || key.delete) {
        onChange(value.slice(0, -1));
        return;
      }
      if (inputChar && !key.ctrl && !key.meta) {
        onChange(value + inputChar);
      }
    },
    { isActive: true }
  );
  if (!value && placeholder) {
    const firstChar = placeholder[0] || " ";
    const rest = placeholder.slice(1);
    return /* @__PURE__ */ jsxs(Text, { children: [
      /* @__PURE__ */ jsx(Text, { color: "black", backgroundColor: "green", children: firstChar }),
      /* @__PURE__ */ jsx(Text, { color: "gray", children: rest })
    ] });
  }
  return /* @__PURE__ */ jsxs(Text, { children: [
    value,
    /* @__PURE__ */ jsx(Text, { color: "black", backgroundColor: "green", children: " " })
  ] });
}
export {
  CustomInput as default
};
