import { jsx } from "react/jsx-runtime";
import { useInput } from "ink";
import TextInput from "ink-text-input";
function CustomTextInput({
  value,
  onChange,
  onSubmit,
  placeholder,
  onWordDelete,
  onLineDelete,
  onNewline
}) {
  useInput(
    (inputChar, key) => {
      if (key.return && key.shift || key.ctrl && inputChar === "e") {
        onNewline?.();
        return;
      }
      if ((key.delete || key.backspace) && (key.meta || key.ctrl)) {
        onWordDelete?.();
        return;
      }
      if (key.delete && key.meta && key.shift || key.ctrl && inputChar === "u") {
        onLineDelete?.();
        return;
      }
      if (key.delete && key.ctrl && key.shift) {
        onWordDelete?.();
        return;
      }
    },
    { isActive: true }
  );
  return /* @__PURE__ */ jsx(
    TextInput,
    {
      value,
      onChange,
      onSubmit,
      ...placeholder ? { placeholder } : {}
    }
  );
}
export {
  CustomTextInput as default
};
