var c = Object.defineProperty;
var r = (e, t) => c(e, "name", { value: t, configurable: !0 });
import { keymap as s, EditorView as a } from "../../../../../@codemirror_view@6.36.4/node_modules/@codemirror/view/dist/index.js";
import { Prec as n } from "../../../../../@codemirror_state@6.5.2/node_modules/@codemirror/state/dist/index.js";
import { completionDecoration as m } from "./completionDecoration.js";
import { completionRequester as l } from "./completionRequester.js";
import { nextSuggestionCommand as u, rejectSuggestionCommand as f, acceptSuggestionCommand as g, sameKeyCommand as p } from "./commands.js";
import { startCompletion as T } from "./commands.js";
import { codeiumConfig as d } from "./config.js";
import { codeiumOtherDocumentsConfig as j } from "./config.js";
import { Language as w } from "./api/proto/exa/codeium_common_pb/codeium_common_pb.js";
function C(e) {
  let t = !1;
  const o = e.state.selection.asSingle().ranges.at(0)?.head, i = e.state.field(m);
  return o !== void 0 && i ? (i.decorations?.between(o, o, () => {
    t = !0;
  }), t) : !1;
}
r(C, "isDecorationClicked");
function y() {
  return a.domEventHandlers({
    keydown(e, t) {
      return e.key === "]" && e.ctrlKey ? !1 : e.key !== "Shift" && e.key !== "Control" && e.key !== "Alt" && e.key !== "Meta" ? p(t, e.key) : !1;
    },
    mouseup(e, t) {
      const o = e.target;
      return o.nodeName === "BUTTON" && o.dataset.action === "codeium-cycle" ? (u(t), e.stopPropagation(), e.preventDefault(), !0) : C(t) ? g(t) : f(t);
    }
  });
}
r(y, "completionPlugin");
function h() {
  return s.of([
    {
      key: "Ctrl-]",
      run: u
    }
  ]);
}
r(h, "nextCompletionPlugin");
function k() {
  return a.updateListener.of((e) => {
    e.focusChanged && f(e.view);
  });
}
r(k, "viewCompletionPlugin");
function N(e) {
  return [
    d.of(e),
    m,
    n.highest(h()),
    n.highest(k()),
    n.high(y()),
    l()
  ];
}
r(N, "copilotPlugin");
export {
  w as Language,
  d as codeiumConfig,
  j as codeiumOtherDocumentsConfig,
  N as copilotPlugin,
  u as nextSuggestionCommand,
  T as startCompletion
};
