"use client";
import * as React from "react";
function useAiShortcuts(options) {
  const { onSubmit, onCancel, enabled = true } = options;
  const onSubmitRef = React.useRef(onSubmit);
  const onCancelRef = React.useRef(onCancel);
  React.useEffect(() => {
    onSubmitRef.current = onSubmit;
  }, [onSubmit]);
  React.useEffect(() => {
    onCancelRef.current = onCancel;
  }, [onCancel]);
  const handleKeyDown = React.useCallback(
    (event) => {
      if (!enabled) return false;
      if (event.key === "Enter" && !event.shiftKey) {
        if (onSubmitRef.current) {
          event.preventDefault();
          onSubmitRef.current();
          return true;
        }
        return false;
      }
      if (event.key === "Escape") {
        if (onCancelRef.current) {
          event.preventDefault();
          onCancelRef.current();
          return true;
        }
        return false;
      }
      return false;
    },
    [enabled]
  );
  return { handleKeyDown };
}
var useAiShortcuts_default = useAiShortcuts;
export {
  useAiShortcuts_default as default,
  useAiShortcuts
};
//# sourceMappingURL=useAiShortcuts.js.map
