"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const react = require("react");
const index = require("../_vendor/usehooks-ts/dist-index.cjs");
const index$1 = require("../_vendor/@codemirror/autocomplete/dist-index.cjs");
function useEvent(editorViewRef) {
  const [dragging, setDragging] = react.useState(false);
  const blur = index.useEventCallback(() => {
    const editor = editorViewRef.current;
    if (editor) {
      editor.contentDOM.blur();
      index$1.closeCompletion(editor);
    }
  });
  const blurOnClickOutside = index.useEventCallback((event) => {
    var _a;
    if (event.target && !dragging && !((_a = editorViewRef.current) == null ? void 0 : _a.dom.contains(event.target))) {
      blur();
    }
    setDragging(false);
  });
  return {
    blur,
    blurOnClickOutside
  };
}
exports.useEvent = useEvent;
//# sourceMappingURL=use-event.cjs.map
