import { useCallback as s, useMemo as m } from "react";
import { MonacoDragNDropProvider as p } from "../provider/MonacoDragAndDropProvider.js";
function D() {
  const u = s(
    (e, t, o = [0, 0], r = !1) => {
      const n = window.monaco;
      if (!n)
        return;
      const { Range: i, Selection: a } = n, l = new i(o[0], o[1], o[0], o[1]);
      if (r) {
        const d = new a(o[0], o[1], o[0], o[1]);
        e.executeEdits("insert", [{ range: l, text: t, forceMoveMarkers: !0 }], [d]), e.focus();
      } else
        e.executeEdits("insert", [{ range: l, text: t, forceMoveMarkers: !0 }]);
      e.pushUndoStop();
    },
    []
  ), c = s(
    (e, t, o) => {
      var n, i, a;
      e.preventDefault(), e.stopPropagation();
      const r = (n = e.dataTransfer) == null ? void 0 : n.getData("text");
      r && o && u(o, r, [((i = t.position) == null ? void 0 : i.lineNumber) ?? 0, ((a = t.position) == null ? void 0 : a.column) ?? 0], !0);
    },
    [u]
  ), f = s(() => {
    if (window.monaco && window.monaco.editor && window.monaco.editor.getEditors) {
      const e = window.monaco.editor.getEditors();
      if (e && e.length > 0)
        return e[0];
    }
    return null;
  }, []);
  return m(() => new p(c, f), [c, f]);
}
export {
  D as default
};
//# sourceMappingURL=useDragAndDropProvider.js.map
