#!/usr/bin/env node
import {
  init_esm_shims
} from "./chunk-DHET7RCE.js";

// src/cli/components/hooks/use-text-input.ts
init_esm_shims();
import { useState, useCallback } from "react";
var MIN_PRINTABLE_CHAR_CODE = 32;
var MAX_PRINTABLE_CHAR_CODE = 126;
function useTextInput(initialValue = "") {
  const [value, setValue] = useState(initialValue);
  const handleInput = useCallback((input, key) => {
    if (key.backspace || key.delete) {
      setValue((prev) => prev.slice(0, -1));
      return;
    }
    if (!key.ctrl && !key.meta && input && input.length === 1) {
      const charCode = input.charCodeAt(0);
      if (charCode >= MIN_PRINTABLE_CHAR_CODE && charCode <= MAX_PRINTABLE_CHAR_CODE) {
        setValue((prev) => prev + input);
      }
    }
  }, []);
  return { value, setValue, handleInput };
}

export {
  useTextInput
};
//# sourceMappingURL=chunk-U3IGFMCY.js.map