import { b as Ne, e as F, aR as Rt, b8 as Nn, Y as qn, b9 as Vn, j as te, ba as Hn, as as Un, an as $n, x as zn, z as Gn, $ as Kn } from "./index-c65ca4a4.mjs";
import { E as p, F as ie, v as Be, S as De, o as d, w as qe, C as Jn, x as _n, y as wt, z as Tt, A as ke, B as It, G as Ot, H as Pt, J as ze, K as Xe, M as E, O as z, g as et, b as Ge, Q as jn, R as K, V as Wt, U as y, W as Qn, X as Yn, Y as ne, Z as M, _ as Zn, $ as Xn, a0 as tt, a1 as re, a2 as er, a3 as tr, a4 as nr, a5 as rr, a6 as or, a7 as ir, a8 as sr, a9 as lr, aa as ar, ab as cr, ac as hr, ad as ur, ae as fr, af as dr, ag as Ft, ah as mr, ai as gr, aj as pr, ak as yr, al as xr, am as kr, an as Nt, ao as br, ap as Sr, t as f, aq as Cr } from "./index-9cc1df42.mjs";
const Ar = (t) => {
  let { state: e } = t, r = e.doc.lineAt(e.selection.main.from), n = rt(t.state, r.from);
  return n.line ? vr(t) : n.block ? Lr(t) : !1;
};
function nt(t, e) {
  return ({ state: r, dispatch: n }) => {
    if (r.readOnly)
      return !1;
    let o = t(e, r);
    return o ? (n(r.update(o)), !0) : !1;
  };
}
const vr = /* @__PURE__ */ nt(
  Er,
  0
  /* CommentOption.Toggle */
), Mr = /* @__PURE__ */ nt(
  qt,
  0
  /* CommentOption.Toggle */
), Lr = /* @__PURE__ */ nt(
  (t, e) => qt(t, e, Dr(e)),
  0
  /* CommentOption.Toggle */
);
function rt(t, e) {
  let r = t.languageDataAt("commentTokens", e);
  return r.length ? r[0] : {};
}
const ee = 50;
function Br(t, { open: e, close: r }, n, o) {
  let i = t.sliceDoc(n - ee, n), s = t.sliceDoc(o, o + ee), l = /\s*$/.exec(i)[0].length, a = /^\s*/.exec(s)[0].length, c = i.length - l;
  if (i.slice(c - e.length, c) == e && s.slice(a, a + r.length) == r)
    return {
      open: { pos: n - l, margin: l && 1 },
      close: { pos: o + a, margin: a && 1 }
    };
  let h, u;
  o - n <= 2 * ee ? h = u = t.sliceDoc(n, o) : (h = t.sliceDoc(n, n + ee), u = t.sliceDoc(o - ee, o));
  let m = /^\s*/.exec(h)[0].length, x = /\s*$/.exec(u)[0].length, S = u.length - x - r.length;
  return h.slice(m, m + e.length) == e && u.slice(S, S + r.length) == r ? {
    open: {
      pos: n + m + e.length,
      margin: /\s/.test(h.charAt(m + e.length)) ? 1 : 0
    },
    close: {
      pos: o - x - r.length,
      margin: /\s/.test(u.charAt(S - 1)) ? 1 : 0
    }
  } : null;
}
function Dr(t) {
  let e = [];
  for (let r of t.selection.ranges) {
    let n = t.doc.lineAt(r.from), o = r.to <= n.to ? n : t.doc.lineAt(r.to), i = e.length - 1;
    i >= 0 && e[i].to > n.from ? e[i].to = o.to : e.push({ from: n.from + /^\s*/.exec(n.text)[0].length, to: o.to });
  }
  return e;
}
function qt(t, e, r = e.selection.ranges) {
  let n = r.map((i) => rt(e, i.from).block);
  if (!n.every((i) => i))
    return null;
  let o = r.map((i, s) => Br(e, n[s], i.from, i.to));
  if (t != 2 && !o.every((i) => i))
    return { changes: e.changes(r.map((i, s) => o[s] ? [] : [{ from: i.from, insert: n[s].open + " " }, { from: i.to, insert: " " + n[s].close }])) };
  if (t != 1 && o.some((i) => i)) {
    let i = [];
    for (let s = 0, l; s < o.length; s++)
      if (l = o[s]) {
        let a = n[s], { open: c, close: h } = l;
        i.push({ from: c.pos - a.open.length, to: c.pos + c.margin }, { from: h.pos - h.margin, to: h.pos + a.close.length });
      }
    return { changes: i };
  }
  return null;
}
function Er(t, e, r = e.selection.ranges) {
  let n = [], o = -1;
  for (let { from: i, to: s } of r) {
    let l = n.length, a = 1e9, c = rt(e, i).line;
    if (c) {
      for (let h = i; h <= s; ) {
        let u = e.doc.lineAt(h);
        if (u.from > o && (i == s || s > u.from)) {
          o = u.from;
          let m = /^\s*/.exec(u.text)[0].length, x = m == u.length, S = u.text.slice(m, m + c.length) == c ? m : -1;
          m < u.text.length && m < a && (a = m), n.push({ line: u, comment: S, token: c, indent: m, empty: x, single: !1 });
        }
        h = u.to + 1;
      }
      if (a < 1e9)
        for (let h = l; h < n.length; h++)
          n[h].indent < n[h].line.text.length && (n[h].indent = a);
      n.length == l + 1 && (n[l].single = !0);
    }
  }
  if (t != 2 && n.some((i) => i.comment < 0 && (!i.empty || i.single))) {
    let i = [];
    for (let { line: l, token: a, indent: c, empty: h, single: u } of n)
      (u || !h) && i.push({ from: l.from + c, insert: a + " " });
    let s = e.changes(i);
    return { changes: s, selection: e.selection.map(s, 1) };
  } else if (t != 1 && n.some((i) => i.comment >= 0)) {
    let i = [];
    for (let { line: s, comment: l, token: a } of n)
      if (l >= 0) {
        let c = s.from + l, h = c + a.length;
        s.text[h - s.from] == " " && h++, i.push({ from: c, to: h });
      }
    return { changes: i };
  }
  return null;
}
const Ke = /* @__PURE__ */ Xe.define(), Rr = /* @__PURE__ */ Xe.define(), wr = /* @__PURE__ */ ie.define(), Vt = /* @__PURE__ */ ie.define({
  combine(t) {
    return Be(t, {
      minDepth: 100,
      newGroupDelay: 500,
      joinToEvent: (e, r) => r
    }, {
      minDepth: Math.max,
      newGroupDelay: Math.min,
      joinToEvent: (e, r) => (n, o) => e(n, o) || r(n, o)
    });
  }
});
function Tr(t) {
  let e = 0;
  return t.iterChangedRanges((r, n) => e = n), e;
}
const Ht = /* @__PURE__ */ De.define({
  create() {
    return w.empty;
  },
  update(t, e) {
    let r = e.state.facet(Vt), n = e.annotation(Ke);
    if (n) {
      let a = e.docChanged ? d.single(Tr(e.changes)) : void 0, c = C.fromTransaction(e, a), h = n.side, u = h == 0 ? t.undone : t.done;
      return c ? u = be(u, u.length, r.minDepth, c) : u = zt(u, e.startState.selection), new w(h == 0 ? n.rest : u, h == 0 ? u : n.rest);
    }
    let o = e.annotation(Rr);
    if ((o == "full" || o == "before") && (t = t.isolate()), e.annotation(qe.addToHistory) === !1)
      return e.changes.empty ? t : t.addMapping(e.changes.desc);
    let i = C.fromTransaction(e), s = e.annotation(qe.time), l = e.annotation(qe.userEvent);
    return i ? t = t.addChanges(i, s, l, r, e) : e.selection && (t = t.addSelection(e.startState.selection, s, l, r.newGroupDelay)), (o == "full" || o == "after") && (t = t.isolate()), t;
  },
  toJSON(t) {
    return { done: t.done.map((e) => e.toJSON()), undone: t.undone.map((e) => e.toJSON()) };
  },
  fromJSON(t) {
    return new w(t.done.map(C.fromJSON), t.undone.map(C.fromJSON));
  }
});
function Ir(t = {}) {
  return [
    Ht,
    Vt.of(t),
    p.domEventHandlers({
      beforeinput(e, r) {
        let n = e.inputType == "historyUndo" ? Ut : e.inputType == "historyRedo" ? Je : null;
        return n ? (e.preventDefault(), n(r)) : !1;
      }
    })
  ];
}
function Ee(t, e) {
  return function({ state: r, dispatch: n }) {
    if (!e && r.readOnly)
      return !1;
    let o = r.field(Ht, !1);
    if (!o)
      return !1;
    let i = o.pop(t, r, e);
    return i ? (n(i), !0) : !1;
  };
}
const Ut = /* @__PURE__ */ Ee(0, !1), Je = /* @__PURE__ */ Ee(1, !1), Or = /* @__PURE__ */ Ee(0, !0), Pr = /* @__PURE__ */ Ee(1, !0);
class C {
  constructor(e, r, n, o, i) {
    this.changes = e, this.effects = r, this.mapped = n, this.startSelection = o, this.selectionsAfter = i;
  }
  setSelAfter(e) {
    return new C(this.changes, this.effects, this.mapped, this.startSelection, e);
  }
  toJSON() {
    var e, r, n;
    return {
      changes: (e = this.changes) === null || e === void 0 ? void 0 : e.toJSON(),
      mapped: (r = this.mapped) === null || r === void 0 ? void 0 : r.toJSON(),
      startSelection: (n = this.startSelection) === null || n === void 0 ? void 0 : n.toJSON(),
      selectionsAfter: this.selectionsAfter.map((o) => o.toJSON())
    };
  }
  static fromJSON(e) {
    return new C(e.changes && Jn.fromJSON(e.changes), [], e.mapped && _n.fromJSON(e.mapped), e.startSelection && d.fromJSON(e.startSelection), e.selectionsAfter.map(d.fromJSON));
  }
  // This does not check `addToHistory` and such, it assumes the
  // transaction needs to be converted to an item. Returns null when
  // there are no changes or effects in the transaction.
  static fromTransaction(e, r) {
    let n = L;
    for (let o of e.startState.facet(wr)) {
      let i = o(e);
      i.length && (n = n.concat(i));
    }
    return !n.length && e.changes.empty ? null : new C(e.changes.invert(e.startState.doc), n, void 0, r || e.startState.selection, L);
  }
  static selection(e) {
    return new C(void 0, L, void 0, void 0, e);
  }
}
function be(t, e, r, n) {
  let o = e + 1 > r + 20 ? e - r - 1 : 0, i = t.slice(o, e);
  return i.push(n), i;
}
function Wr(t, e) {
  let r = [], n = !1;
  return t.iterChangedRanges((o, i) => r.push(o, i)), e.iterChangedRanges((o, i, s, l) => {
    for (let a = 0; a < r.length; ) {
      let c = r[a++], h = r[a++];
      l >= c && s <= h && (n = !0);
    }
  }), n;
}
function Fr(t, e) {
  return t.ranges.length == e.ranges.length && t.ranges.filter((r, n) => r.empty != e.ranges[n].empty).length === 0;
}
function $t(t, e) {
  return t.length ? e.length ? t.concat(e) : t : e;
}
const L = [], Nr = 200;
function zt(t, e) {
  if (t.length) {
    let r = t[t.length - 1], n = r.selectionsAfter.slice(Math.max(0, r.selectionsAfter.length - Nr));
    return n.length && n[n.length - 1].eq(e) ? t : (n.push(e), be(t, t.length - 1, 1e9, r.setSelAfter(n)));
  } else
    return [C.selection([e])];
}
function qr(t) {
  let e = t[t.length - 1], r = t.slice();
  return r[t.length - 1] = e.setSelAfter(e.selectionsAfter.slice(0, e.selectionsAfter.length - 1)), r;
}
function Ve(t, e) {
  if (!t.length)
    return t;
  let r = t.length, n = L;
  for (; r; ) {
    let o = Vr(t[r - 1], e, n);
    if (o.changes && !o.changes.empty || o.effects.length) {
      let i = t.slice(0, r);
      return i[r - 1] = o, i;
    } else
      e = o.mapped, r--, n = o.selectionsAfter;
  }
  return n.length ? [C.selection(n)] : L;
}
function Vr(t, e, r) {
  let n = $t(t.selectionsAfter.length ? t.selectionsAfter.map((l) => l.map(e)) : L, r);
  if (!t.changes)
    return C.selection(n);
  let o = t.changes.map(e), i = e.mapDesc(t.changes, !0), s = t.mapped ? t.mapped.composeDesc(i) : i;
  return new C(o, E.mapEffects(t.effects, e), s, t.startSelection.map(i), n);
}
const Hr = /^(input\.type|delete)($|\.)/;
class w {
  constructor(e, r, n = 0, o = void 0) {
    this.done = e, this.undone = r, this.prevTime = n, this.prevUserEvent = o;
  }
  isolate() {
    return this.prevTime ? new w(this.done, this.undone) : this;
  }
  addChanges(e, r, n, o, i) {
    let s = this.done, l = s[s.length - 1];
    return l && l.changes && !l.changes.empty && e.changes && (!n || Hr.test(n)) && (!l.selectionsAfter.length && r - this.prevTime < o.newGroupDelay && o.joinToEvent(i, Wr(l.changes, e.changes)) || // For compose (but not compose.start) events, always join with previous event
    n == "input.type.compose") ? s = be(s, s.length - 1, o.minDepth, new C(e.changes.compose(l.changes), $t(e.effects, l.effects), l.mapped, l.startSelection, L)) : s = be(s, s.length, o.minDepth, e), new w(s, L, r, n);
  }
  addSelection(e, r, n, o) {
    let i = this.done.length ? this.done[this.done.length - 1].selectionsAfter : L;
    return i.length > 0 && r - this.prevTime < o && n == this.prevUserEvent && n && /^select($|\.)/.test(n) && Fr(i[i.length - 1], e) ? this : new w(zt(this.done, e), this.undone, r, n);
  }
  addMapping(e) {
    return new w(Ve(this.done, e), Ve(this.undone, e), this.prevTime, this.prevUserEvent);
  }
  pop(e, r, n) {
    let o = e == 0 ? this.done : this.undone;
    if (o.length == 0)
      return null;
    let i = o[o.length - 1];
    if (n && i.selectionsAfter.length)
      return r.update({
        selection: i.selectionsAfter[i.selectionsAfter.length - 1],
        annotations: Ke.of({ side: e, rest: qr(o) }),
        userEvent: e == 0 ? "select.undo" : "select.redo",
        scrollIntoView: !0
      });
    if (i.changes) {
      let s = o.length == 1 ? L : o.slice(0, o.length - 1);
      return i.mapped && (s = Ve(s, i.mapped)), r.update({
        changes: i.changes,
        selection: i.startSelection,
        effects: i.effects,
        annotations: Ke.of({ side: e, rest: s }),
        filter: !1,
        userEvent: e == 0 ? "undo" : "redo",
        scrollIntoView: !0
      });
    } else
      return null;
  }
}
w.empty = /* @__PURE__ */ new w(L, L);
const Ur = [
  { key: "Mod-z", run: Ut, preventDefault: !0 },
  { key: "Mod-y", mac: "Mod-Shift-z", run: Je, preventDefault: !0 },
  { linux: "Ctrl-Shift-z", run: Je, preventDefault: !0 },
  { key: "Mod-u", run: Or, preventDefault: !0 },
  { key: "Alt-u", mac: "Mod-Shift-u", run: Pr, preventDefault: !0 }
];
function j(t, e) {
  return d.create(t.ranges.map(e), t.mainIndex);
}
function T(t, e) {
  return t.update({ selection: e, scrollIntoView: !0, userEvent: "select" });
}
function R({ state: t, dispatch: e }, r) {
  let n = j(t.selection, r);
  return n.eq(t.selection) ? !1 : (e(T(t, n)), !0);
}
function Re(t, e) {
  return d.cursor(e ? t.to : t.from);
}
function Gt(t, e) {
  return R(t, (r) => r.empty ? t.moveByChar(r, e) : Re(r, e));
}
function b(t) {
  return t.textDirectionAt(t.state.selection.main.head) == jn.LTR;
}
const Kt = (t) => Gt(t, !b(t)), Jt = (t) => Gt(t, b(t));
function _t(t, e) {
  return R(t, (r) => r.empty ? t.moveByGroup(r, e) : Re(r, e));
}
const $r = (t) => _t(t, !b(t)), zr = (t) => _t(t, b(t));
function Gr(t, e, r) {
  if (e.type.prop(r))
    return !0;
  let n = e.to - e.from;
  return n && (n > 2 || /[^\s,.;:]/.test(t.sliceDoc(e.from, e.to))) || e.firstChild;
}
function we(t, e, r) {
  let n = et(t).resolveInner(e.head), o = r ? Ge.closedBy : Ge.openedBy;
  for (let a = e.head; ; ) {
    let c = r ? n.childAfter(a) : n.childBefore(a);
    if (!c)
      break;
    Gr(t, c, o) ? n = c : a = r ? c.to : c.from;
  }
  let i = n.type.prop(o), s, l;
  return i && (s = r ? z(t, n.from, 1) : z(t, n.to, -1)) && s.matched ? l = r ? s.end.to : s.end.from : l = r ? n.to : n.from, d.cursor(l, r ? -1 : 1);
}
const Kr = (t) => R(t, (e) => we(t.state, e, !b(t))), Jr = (t) => R(t, (e) => we(t.state, e, b(t)));
function jt(t, e) {
  return R(t, (r) => {
    if (!r.empty)
      return Re(r, e);
    let n = t.moveVertically(r, e);
    return n.head != r.head ? n : t.moveToLineBoundary(r, e);
  });
}
const Qt = (t) => jt(t, !1), Yt = (t) => jt(t, !0);
function Zt(t) {
  let e = t.scrollDOM.clientHeight < t.scrollDOM.scrollHeight - 2, r = 0, n = 0, o;
  if (e) {
    for (let i of t.state.facet(p.scrollMargins)) {
      let s = i(t);
      s != null && s.top && (r = Math.max(s == null ? void 0 : s.top, r)), s != null && s.bottom && (n = Math.max(s == null ? void 0 : s.bottom, n));
    }
    o = t.scrollDOM.clientHeight - r - n;
  } else
    o = (t.dom.ownerDocument.defaultView || window).innerHeight;
  return {
    marginTop: r,
    marginBottom: n,
    selfScroll: e,
    height: Math.max(t.defaultLineHeight, o - 5)
  };
}
function Xt(t, e) {
  let r = Zt(t), { state: n } = t, o = j(n.selection, (s) => s.empty ? t.moveVertically(s, e, r.height) : Re(s, e));
  if (o.eq(n.selection))
    return !1;
  let i;
  if (r.selfScroll) {
    let s = t.coordsAtPos(n.selection.main.head), l = t.scrollDOM.getBoundingClientRect(), a = l.top + r.marginTop, c = l.bottom - r.marginBottom;
    s && s.top > a && s.bottom < c && (i = p.scrollIntoView(o.main.head, { y: "start", yMargin: s.top - a }));
  }
  return t.dispatch(T(n, o), { effects: i }), !0;
}
const ht = (t) => Xt(t, !1), _e = (t) => Xt(t, !0);
function W(t, e, r) {
  let n = t.lineBlockAt(e.head), o = t.moveToLineBoundary(e, r);
  if (o.head == e.head && o.head != (r ? n.to : n.from) && (o = t.moveToLineBoundary(e, r, !1)), !r && o.head == n.from && n.length) {
    let i = /^\s*/.exec(t.state.sliceDoc(n.from, Math.min(n.from + 100, n.to)))[0].length;
    i && e.head != n.from + i && (o = d.cursor(n.from + i));
  }
  return o;
}
const _r = (t) => R(t, (e) => W(t, e, !0)), jr = (t) => R(t, (e) => W(t, e, !1)), Qr = (t) => R(t, (e) => W(t, e, !b(t))), Yr = (t) => R(t, (e) => W(t, e, b(t))), Zr = (t) => R(t, (e) => d.cursor(t.lineBlockAt(e.head).from, 1)), Xr = (t) => R(t, (e) => d.cursor(t.lineBlockAt(e.head).to, -1));
function eo(t, e, r) {
  let n = !1, o = j(t.selection, (i) => {
    let s = z(t, i.head, -1) || z(t, i.head, 1) || i.head > 0 && z(t, i.head - 1, 1) || i.head < t.doc.length && z(t, i.head + 1, -1);
    if (!s || !s.end)
      return i;
    n = !0;
    let l = s.start.from == i.head ? s.end.to : s.end.from;
    return r ? d.range(i.anchor, l) : d.cursor(l);
  });
  return n ? (e(T(t, o)), !0) : !1;
}
const to = ({ state: t, dispatch: e }) => eo(t, e, !1);
function B(t, e) {
  let r = j(t.state.selection, (n) => {
    let o = e(n);
    return d.range(n.anchor, o.head, o.goalColumn, o.bidiLevel || void 0);
  });
  return r.eq(t.state.selection) ? !1 : (t.dispatch(T(t.state, r)), !0);
}
function en(t, e) {
  return B(t, (r) => t.moveByChar(r, e));
}
const tn = (t) => en(t, !b(t)), nn = (t) => en(t, b(t));
function rn(t, e) {
  return B(t, (r) => t.moveByGroup(r, e));
}
const no = (t) => rn(t, !b(t)), ro = (t) => rn(t, b(t)), oo = (t) => B(t, (e) => we(t.state, e, !b(t))), io = (t) => B(t, (e) => we(t.state, e, b(t)));
function on(t, e) {
  return B(t, (r) => t.moveVertically(r, e));
}
const sn = (t) => on(t, !1), ln = (t) => on(t, !0);
function an(t, e) {
  return B(t, (r) => t.moveVertically(r, e, Zt(t).height));
}
const ut = (t) => an(t, !1), ft = (t) => an(t, !0), so = (t) => B(t, (e) => W(t, e, !0)), lo = (t) => B(t, (e) => W(t, e, !1)), ao = (t) => B(t, (e) => W(t, e, !b(t))), co = (t) => B(t, (e) => W(t, e, b(t))), ho = (t) => B(t, (e) => d.cursor(t.lineBlockAt(e.head).from)), uo = (t) => B(t, (e) => d.cursor(t.lineBlockAt(e.head).to)), dt = ({ state: t, dispatch: e }) => (e(T(t, { anchor: 0 })), !0), mt = ({ state: t, dispatch: e }) => (e(T(t, { anchor: t.doc.length })), !0), gt = ({ state: t, dispatch: e }) => (e(T(t, { anchor: t.selection.main.anchor, head: 0 })), !0), pt = ({ state: t, dispatch: e }) => (e(T(t, { anchor: t.selection.main.anchor, head: t.doc.length })), !0), fo = ({ state: t, dispatch: e }) => (e(t.update({ selection: { anchor: 0, head: t.doc.length }, userEvent: "select" })), !0), mo = ({ state: t, dispatch: e }) => {
  let r = Ie(t).map(({ from: n, to: o }) => d.range(n, Math.min(o + 1, t.doc.length)));
  return e(t.update({ selection: d.create(r), userEvent: "select" })), !0;
}, go = ({ state: t, dispatch: e }) => {
  let r = j(t.selection, (n) => {
    var o;
    let i = et(t).resolveInner(n.head, 1);
    for (; !(i.from < n.from && i.to >= n.to || i.to > n.to && i.from <= n.from || !(!((o = i.parent) === null || o === void 0) && o.parent)); )
      i = i.parent;
    return d.range(i.to, i.from);
  });
  return e(T(t, r)), !0;
}, po = ({ state: t, dispatch: e }) => {
  let r = t.selection, n = null;
  return r.ranges.length > 1 ? n = d.create([r.main]) : r.main.empty || (n = d.create([d.cursor(r.main.head)])), n ? (e(T(t, n)), !0) : !1;
};
function Te(t, e) {
  if (t.state.readOnly)
    return !1;
  let r = "delete.selection", { state: n } = t, o = n.changeByRange((i) => {
    let { from: s, to: l } = i;
    if (s == l) {
      let a = e(s);
      a < s ? (r = "delete.backward", a = me(t, a, !1)) : a > s && (r = "delete.forward", a = me(t, a, !0)), s = Math.min(s, a), l = Math.max(l, a);
    } else
      s = me(t, s, !1), l = me(t, l, !0);
    return s == l ? { range: i } : { changes: { from: s, to: l }, range: d.cursor(s) };
  });
  return o.changes.empty ? !1 : (t.dispatch(n.update(o, {
    scrollIntoView: !0,
    userEvent: r,
    effects: r == "delete.selection" ? p.announce.of(n.phrase("Selection deleted")) : void 0
  })), !0);
}
function me(t, e, r) {
  if (t instanceof p)
    for (let n of t.state.facet(p.atomicRanges).map((o) => o(t)))
      n.between(e, e, (o, i) => {
        o < e && i > e && (e = r ? i : o);
      });
  return e;
}
const cn = (t, e) => Te(t, (r) => {
  let { state: n } = t, o = n.doc.lineAt(r), i, s;
  if (!e && r > o.from && r < o.from + 200 && !/[^ \t]/.test(i = o.text.slice(0, r - o.from))) {
    if (i[i.length - 1] == "	")
      return r - 1;
    let l = Pt(i, n.tabSize), a = l % ze(n) || ze(n);
    for (let c = 0; c < a && i[i.length - 1 - c] == " "; c++)
      r--;
    s = r;
  } else
    s = K(o.text, r - o.from, e, e) + o.from, s == r && o.number != (e ? n.doc.lines : 1) && (s += e ? 1 : -1);
  return s;
}), je = (t) => cn(t, !1), hn = (t) => cn(t, !0), un = (t, e) => Te(t, (r) => {
  let n = r, { state: o } = t, i = o.doc.lineAt(n), s = o.charCategorizer(n);
  for (let l = null; ; ) {
    if (n == (e ? i.to : i.from)) {
      n == r && i.number != (e ? o.doc.lines : 1) && (n += e ? 1 : -1);
      break;
    }
    let a = K(i.text, n - i.from, e) + i.from, c = i.text.slice(Math.min(n, a) - i.from, Math.max(n, a) - i.from), h = s(c);
    if (l != null && h != l)
      break;
    (c != " " || n != r) && (l = h), n = a;
  }
  return n;
}), fn = (t) => un(t, !1), yo = (t) => un(t, !0), dn = (t) => Te(t, (e) => {
  let r = t.lineBlockAt(e).to;
  return e < r ? r : Math.min(t.state.doc.length, e + 1);
}), xo = (t) => Te(t, (e) => {
  let r = t.lineBlockAt(e).from;
  return e > r ? r : Math.max(0, e - 1);
}), ko = ({ state: t, dispatch: e }) => {
  if (t.readOnly)
    return !1;
  let r = t.changeByRange((n) => ({
    changes: { from: n.from, to: n.to, insert: It.of(["", ""]) },
    range: d.cursor(n.from)
  }));
  return e(t.update(r, { scrollIntoView: !0, userEvent: "input" })), !0;
}, bo = ({ state: t, dispatch: e }) => {
  if (t.readOnly)
    return !1;
  let r = t.changeByRange((n) => {
    if (!n.empty || n.from == 0 || n.from == t.doc.length)
      return { range: n };
    let o = n.from, i = t.doc.lineAt(o), s = o == i.from ? o - 1 : K(i.text, o - i.from, !1) + i.from, l = o == i.to ? o + 1 : K(i.text, o - i.from, !0) + i.from;
    return {
      changes: { from: s, to: l, insert: t.doc.slice(o, l).append(t.doc.slice(s, o)) },
      range: d.cursor(l)
    };
  });
  return r.changes.empty ? !1 : (e(t.update(r, { scrollIntoView: !0, userEvent: "move.character" })), !0);
};
function Ie(t) {
  let e = [], r = -1;
  for (let n of t.selection.ranges) {
    let o = t.doc.lineAt(n.from), i = t.doc.lineAt(n.to);
    if (!n.empty && n.to == i.from && (i = t.doc.lineAt(n.to - 1)), r >= o.number) {
      let s = e[e.length - 1];
      s.to = i.to, s.ranges.push(n);
    } else
      e.push({ from: o.from, to: i.to, ranges: [n] });
    r = i.number + 1;
  }
  return e;
}
function mn(t, e, r) {
  if (t.readOnly)
    return !1;
  let n = [], o = [];
  for (let i of Ie(t)) {
    if (r ? i.to == t.doc.length : i.from == 0)
      continue;
    let s = t.doc.lineAt(r ? i.to + 1 : i.from - 1), l = s.length + 1;
    if (r) {
      n.push({ from: i.to, to: s.to }, { from: i.from, insert: s.text + t.lineBreak });
      for (let a of i.ranges)
        o.push(d.range(Math.min(t.doc.length, a.anchor + l), Math.min(t.doc.length, a.head + l)));
    } else {
      n.push({ from: s.from, to: i.from }, { from: i.to, insert: t.lineBreak + s.text });
      for (let a of i.ranges)
        o.push(d.range(a.anchor - l, a.head - l));
    }
  }
  return n.length ? (e(t.update({
    changes: n,
    scrollIntoView: !0,
    selection: d.create(o, t.selection.mainIndex),
    userEvent: "move.line"
  })), !0) : !1;
}
const So = ({ state: t, dispatch: e }) => mn(t, e, !1), Co = ({ state: t, dispatch: e }) => mn(t, e, !0);
function gn(t, e, r) {
  if (t.readOnly)
    return !1;
  let n = [];
  for (let o of Ie(t))
    r ? n.push({ from: o.from, insert: t.doc.slice(o.from, o.to) + t.lineBreak }) : n.push({ from: o.to, insert: t.lineBreak + t.doc.slice(o.from, o.to) });
  return e(t.update({ changes: n, scrollIntoView: !0, userEvent: "input.copyline" })), !0;
}
const Ao = ({ state: t, dispatch: e }) => gn(t, e, !1), vo = ({ state: t, dispatch: e }) => gn(t, e, !0), Mo = (t) => {
  if (t.state.readOnly)
    return !1;
  let { state: e } = t, r = e.changes(Ie(e).map(({ from: o, to: i }) => (o > 0 ? o-- : i < e.doc.length && i++, { from: o, to: i }))), n = j(e.selection, (o) => t.moveVertically(o, !0)).map(r);
  return t.dispatch({ changes: r, selection: n, scrollIntoView: !0, userEvent: "delete.line" }), !0;
};
function Lo(t, e) {
  if (/\(\)|\[\]|\{\}/.test(t.sliceDoc(e - 1, e + 1)))
    return { from: e, to: e };
  let r = et(t).resolveInner(e), n = r.childBefore(e), o = r.childAfter(e), i;
  return n && o && n.to <= e && o.from >= e && (i = n.type.prop(Ge.closedBy)) && i.indexOf(o.name) > -1 && t.doc.lineAt(n.to).from == t.doc.lineAt(o.from).from ? { from: n.to, to: o.from } : null;
}
const Bo = /* @__PURE__ */ pn(!1), Do = /* @__PURE__ */ pn(!0);
function pn(t) {
  return ({ state: e, dispatch: r }) => {
    if (e.readOnly)
      return !1;
    let n = e.changeByRange((o) => {
      let { from: i, to: s } = o, l = e.doc.lineAt(i), a = !t && i == s && Lo(e, i);
      t && (i = s = (s <= l.to ? l : e.doc.lineAt(s)).to);
      let c = new wt(e, { simulateBreak: i, simulateDoubleBreak: !!a }), h = Tt(c, i);
      for (h == null && (h = /^\s*/.exec(e.doc.lineAt(i).text)[0].length); s < l.to && /\s/.test(l.text[s - l.from]); )
        s++;
      a ? { from: i, to: s } = a : i > l.from && i < l.from + 100 && !/\S/.test(l.text.slice(0, i)) && (i = l.from);
      let u = ["", ke(e, h)];
      return a && u.push(ke(e, c.lineIndent(l.from, -1))), {
        changes: { from: i, to: s, insert: It.of(u) },
        range: d.cursor(i + 1 + u[1].length)
      };
    });
    return r(e.update(n, { scrollIntoView: !0, userEvent: "input" })), !0;
  };
}
function ot(t, e) {
  let r = -1;
  return t.changeByRange((n) => {
    let o = [];
    for (let s = n.from; s <= n.to; ) {
      let l = t.doc.lineAt(s);
      l.number > r && (n.empty || n.to > l.from) && (e(l, o, n), r = l.number), s = l.to + 1;
    }
    let i = t.changes(o);
    return {
      changes: o,
      range: d.range(i.mapPos(n.anchor, 1), i.mapPos(n.head, 1))
    };
  });
}
const Eo = ({ state: t, dispatch: e }) => {
  if (t.readOnly)
    return !1;
  let r = /* @__PURE__ */ Object.create(null), n = new wt(t, { overrideIndentation: (i) => {
    let s = r[i];
    return s ?? -1;
  } }), o = ot(t, (i, s, l) => {
    let a = Tt(n, i.from);
    if (a == null)
      return;
    /\S/.test(i.text) || (a = 0);
    let c = /^\s*/.exec(i.text)[0], h = ke(t, a);
    (c != h || l.from < i.from + c.length) && (r[i.from] = a, s.push({ from: i.from, to: i.from + c.length, insert: h }));
  });
  return o.changes.empty || e(t.update(o, { userEvent: "indent" })), !0;
}, yn = ({ state: t, dispatch: e }) => t.readOnly ? !1 : (e(t.update(ot(t, (r, n) => {
  n.push({ from: r.from, insert: t.facet(Ot) });
}), { userEvent: "input.indent" })), !0), xn = ({ state: t, dispatch: e }) => t.readOnly ? !1 : (e(t.update(ot(t, (r, n) => {
  let o = /^\s*/.exec(r.text)[0];
  if (!o)
    return;
  let i = Pt(o, t.tabSize), s = 0, l = ke(t, Math.max(0, i - ze(t)));
  for (; s < o.length && s < l.length && o.charCodeAt(s) == l.charCodeAt(s); )
    s++;
  n.push({ from: r.from + s, to: r.from + o.length, insert: l.slice(s) });
}), { userEvent: "delete.dedent" })), !0), Ro = [
  { key: "Ctrl-b", run: Kt, shift: tn, preventDefault: !0 },
  { key: "Ctrl-f", run: Jt, shift: nn },
  { key: "Ctrl-p", run: Qt, shift: sn },
  { key: "Ctrl-n", run: Yt, shift: ln },
  { key: "Ctrl-a", run: Zr, shift: ho },
  { key: "Ctrl-e", run: Xr, shift: uo },
  { key: "Ctrl-d", run: hn },
  { key: "Ctrl-h", run: je },
  { key: "Ctrl-k", run: dn },
  { key: "Ctrl-Alt-h", run: fn },
  { key: "Ctrl-o", run: ko },
  { key: "Ctrl-t", run: bo },
  { key: "Ctrl-v", run: _e }
], wo = /* @__PURE__ */ [
  { key: "ArrowLeft", run: Kt, shift: tn, preventDefault: !0 },
  { key: "Mod-ArrowLeft", mac: "Alt-ArrowLeft", run: $r, shift: no, preventDefault: !0 },
  { mac: "Cmd-ArrowLeft", run: Qr, shift: ao, preventDefault: !0 },
  { key: "ArrowRight", run: Jt, shift: nn, preventDefault: !0 },
  { key: "Mod-ArrowRight", mac: "Alt-ArrowRight", run: zr, shift: ro, preventDefault: !0 },
  { mac: "Cmd-ArrowRight", run: Yr, shift: co, preventDefault: !0 },
  { key: "ArrowUp", run: Qt, shift: sn, preventDefault: !0 },
  { mac: "Cmd-ArrowUp", run: dt, shift: gt },
  { mac: "Ctrl-ArrowUp", run: ht, shift: ut },
  { key: "ArrowDown", run: Yt, shift: ln, preventDefault: !0 },
  { mac: "Cmd-ArrowDown", run: mt, shift: pt },
  { mac: "Ctrl-ArrowDown", run: _e, shift: ft },
  { key: "PageUp", run: ht, shift: ut },
  { key: "PageDown", run: _e, shift: ft },
  { key: "Home", run: jr, shift: lo, preventDefault: !0 },
  { key: "Mod-Home", run: dt, shift: gt },
  { key: "End", run: _r, shift: so, preventDefault: !0 },
  { key: "Mod-End", run: mt, shift: pt },
  { key: "Enter", run: Bo },
  { key: "Mod-a", run: fo },
  { key: "Backspace", run: je, shift: je },
  { key: "Delete", run: hn },
  { key: "Mod-Backspace", mac: "Alt-Backspace", run: fn },
  { key: "Mod-Delete", mac: "Alt-Delete", run: yo },
  { mac: "Mod-Backspace", run: xo },
  { mac: "Mod-Delete", run: dn }
].concat(/* @__PURE__ */ Ro.map((t) => ({ mac: t.key, run: t.run, shift: t.shift }))), To = /* @__PURE__ */ [
  { key: "Alt-ArrowLeft", mac: "Ctrl-ArrowLeft", run: Kr, shift: oo },
  { key: "Alt-ArrowRight", mac: "Ctrl-ArrowRight", run: Jr, shift: io },
  { key: "Alt-ArrowUp", run: So },
  { key: "Shift-Alt-ArrowUp", run: Ao },
  { key: "Alt-ArrowDown", run: Co },
  { key: "Shift-Alt-ArrowDown", run: vo },
  { key: "Escape", run: po },
  { key: "Mod-Enter", run: Do },
  { key: "Alt-l", mac: "Ctrl-l", run: mo },
  { key: "Mod-i", run: go, preventDefault: !0 },
  { key: "Mod-[", run: xn },
  { key: "Mod-]", run: yn },
  { key: "Mod-Alt-\\", run: Eo },
  { key: "Shift-Mod-k", run: Mo },
  { key: "Shift-Mod-\\", run: to },
  { key: "Mod-/", run: Ar },
  { key: "Alt-A", run: Mr }
].concat(wo), Io = { key: "Tab", run: yn, shift: xn };
function g() {
  var t = arguments[0];
  typeof t == "string" && (t = document.createElement(t));
  var e = 1, r = arguments[1];
  if (r && typeof r == "object" && r.nodeType == null && !Array.isArray(r)) {
    for (var n in r)
      if (Object.prototype.hasOwnProperty.call(r, n)) {
        var o = r[n];
        typeof o == "string" ? t.setAttribute(n, o) : o != null && (t[n] = o);
      }
    e++;
  }
  for (; e < arguments.length; e++)
    kn(t, arguments[e]);
  return t;
}
function kn(t, e) {
  if (typeof e == "string")
    t.appendChild(document.createTextNode(e));
  else if (e != null)
    if (e.nodeType != null)
      t.appendChild(e);
    else if (Array.isArray(e))
      for (var r = 0; r < e.length; r++)
        kn(t, e[r]);
    else
      throw new RangeError("Unsupported child node: " + e);
}
const yt = typeof String.prototype.normalize == "function" ? (t) => t.normalize("NFKD") : (t) => t;
class J {
  /**
  Create a text cursor. The query is the search string, `from` to
  `to` provides the region to search.
  
  When `normalize` is given, it will be called, on both the query
  string and the content it is matched against, before comparing.
  You can, for example, create a case-insensitive search by
  passing `s => s.toLowerCase()`.
  
  Text is always normalized with
  [`.normalize("NFKD")`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
  (when supported).
  */
  constructor(e, r, n = 0, o = e.length, i, s) {
    this.test = s, this.value = { from: 0, to: 0 }, this.done = !1, this.matches = [], this.buffer = "", this.bufferPos = 0, this.iter = e.iterRange(n, o), this.bufferStart = n, this.normalize = i ? (l) => i(yt(l)) : yt, this.query = this.normalize(r);
  }
  peek() {
    if (this.bufferPos == this.buffer.length) {
      if (this.bufferStart += this.buffer.length, this.iter.next(), this.iter.done)
        return -1;
      this.bufferPos = 0, this.buffer = this.iter.value;
    }
    return Qn(this.buffer, this.bufferPos);
  }
  /**
  Look for the next match. Updates the iterator's
  [`value`](https://codemirror.net/6/docs/ref/#search.SearchCursor.value) and
  [`done`](https://codemirror.net/6/docs/ref/#search.SearchCursor.done) properties. Should be called
  at least once before using the cursor.
  */
  next() {
    for (; this.matches.length; )
      this.matches.pop();
    return this.nextOverlapping();
  }
  /**
  The `next` method will ignore matches that partially overlap a
  previous match. This method behaves like `next`, but includes
  such matches.
  */
  nextOverlapping() {
    for (; ; ) {
      let e = this.peek();
      if (e < 0)
        return this.done = !0, this;
      let r = Xn(e), n = this.bufferStart + this.bufferPos;
      this.bufferPos += Yn(e);
      let o = this.normalize(r);
      for (let i = 0, s = n; ; i++) {
        let l = o.charCodeAt(i), a = this.match(l, s);
        if (i == o.length - 1) {
          if (a)
            return this.value = a, this;
          break;
        }
        s == n && i < r.length && r.charCodeAt(i) == l && s++;
      }
    }
  }
  match(e, r) {
    let n = null;
    for (let o = 0; o < this.matches.length; o += 2) {
      let i = this.matches[o], s = !1;
      this.query.charCodeAt(i) == e && (i == this.query.length - 1 ? n = { from: this.matches[o + 1], to: r + 1 } : (this.matches[o]++, s = !0)), s || (this.matches.splice(o, 2), o -= 2);
    }
    return this.query.charCodeAt(0) == e && (this.query.length == 1 ? n = { from: r, to: r + 1 } : this.matches.push(1, r)), n && this.test && !this.test(n.from, n.to, this.buffer, this.bufferPos) && (n = null), n;
  }
}
typeof Symbol < "u" && (J.prototype[Symbol.iterator] = function() {
  return this;
});
const bn = { from: -1, to: -1, match: /* @__PURE__ */ /.*/.exec("") }, it = "gm" + (/x/.unicode == null ? "" : "u");
class Sn {
  /**
  Create a cursor that will search the given range in the given
  document. `query` should be the raw pattern (as you'd pass it to
  `new RegExp`).
  */
  constructor(e, r, n, o = 0, i = e.length) {
    if (this.text = e, this.to = i, this.curLine = "", this.done = !1, this.value = bn, /\\[sWDnr]|\n|\r|\[\^/.test(r))
      return new Cn(e, r, n, o, i);
    this.re = new RegExp(r, it + (n != null && n.ignoreCase ? "i" : "")), this.test = n == null ? void 0 : n.test, this.iter = e.iter();
    let s = e.lineAt(o);
    this.curLineStart = s.from, this.matchPos = Se(e, o), this.getLine(this.curLineStart);
  }
  getLine(e) {
    this.iter.next(e), this.iter.lineBreak ? this.curLine = "" : (this.curLine = this.iter.value, this.curLineStart + this.curLine.length > this.to && (this.curLine = this.curLine.slice(0, this.to - this.curLineStart)), this.iter.next());
  }
  nextLine() {
    this.curLineStart = this.curLineStart + this.curLine.length + 1, this.curLineStart > this.to ? this.curLine = "" : this.getLine(0);
  }
  /**
  Move to the next match, if there is one.
  */
  next() {
    for (let e = this.matchPos - this.curLineStart; ; ) {
      this.re.lastIndex = e;
      let r = this.matchPos <= this.to && this.re.exec(this.curLine);
      if (r) {
        let n = this.curLineStart + r.index, o = n + r[0].length;
        if (this.matchPos = Se(this.text, o + (n == o ? 1 : 0)), n == this.curLineStart + this.curLine.length && this.nextLine(), (n < o || n > this.value.to) && (!this.test || this.test(n, o, r)))
          return this.value = { from: n, to: o, match: r }, this;
        e = this.matchPos - this.curLineStart;
      } else if (this.curLineStart + this.curLine.length < this.to)
        this.nextLine(), e = 0;
      else
        return this.done = !0, this;
    }
  }
}
const He = /* @__PURE__ */ new WeakMap();
class G {
  constructor(e, r) {
    this.from = e, this.text = r;
  }
  get to() {
    return this.from + this.text.length;
  }
  static get(e, r, n) {
    let o = He.get(e);
    if (!o || o.from >= n || o.to <= r) {
      let l = new G(r, e.sliceString(r, n));
      return He.set(e, l), l;
    }
    if (o.from == r && o.to == n)
      return o;
    let { text: i, from: s } = o;
    return s > r && (i = e.sliceString(r, s) + i, s = r), o.to < n && (i += e.sliceString(o.to, n)), He.set(e, new G(s, i)), new G(r, i.slice(r - s, n - s));
  }
}
class Cn {
  constructor(e, r, n, o, i) {
    this.text = e, this.to = i, this.done = !1, this.value = bn, this.matchPos = Se(e, o), this.re = new RegExp(r, it + (n != null && n.ignoreCase ? "i" : "")), this.test = n == null ? void 0 : n.test, this.flat = G.get(e, o, this.chunkEnd(
      o + 5e3
      /* Base */
    ));
  }
  chunkEnd(e) {
    return e >= this.to ? this.to : this.text.lineAt(e).to;
  }
  next() {
    for (; ; ) {
      let e = this.re.lastIndex = this.matchPos - this.flat.from, r = this.re.exec(this.flat.text);
      if (r && !r[0] && r.index == e && (this.re.lastIndex = e + 1, r = this.re.exec(this.flat.text)), r) {
        let n = this.flat.from + r.index, o = n + r[0].length;
        if ((this.flat.to >= this.to || r.index + r[0].length <= this.flat.text.length - 10) && (!this.test || this.test(n, o, r)))
          return this.value = { from: n, to: o, match: r }, this.matchPos = Se(this.text, o + (n == o ? 1 : 0)), this;
      }
      if (this.flat.to == this.to)
        return this.done = !0, this;
      this.flat = G.get(this.text, this.flat.from, this.chunkEnd(this.flat.from + this.flat.text.length * 2));
    }
  }
}
typeof Symbol < "u" && (Sn.prototype[Symbol.iterator] = Cn.prototype[Symbol.iterator] = function() {
  return this;
});
function Oo(t) {
  try {
    return new RegExp(t, it), !0;
  } catch {
    return !1;
  }
}
function Se(t, e) {
  if (e >= t.length)
    return e;
  let r = t.lineAt(e), n;
  for (; e < r.to && (n = r.text.charCodeAt(e - r.from)) >= 56320 && n < 57344; )
    e++;
  return e;
}
function Qe(t) {
  let e = g("input", { class: "cm-textfield", name: "line" }), r = g("form", {
    class: "cm-gotoLine",
    onkeydown: (o) => {
      o.keyCode == 27 ? (o.preventDefault(), t.dispatch({ effects: Ce.of(!1) }), t.focus()) : o.keyCode == 13 && (o.preventDefault(), n());
    },
    onsubmit: (o) => {
      o.preventDefault(), n();
    }
  }, g("label", t.state.phrase("Go to line"), ": ", e), " ", g("button", { class: "cm-button", type: "submit" }, t.state.phrase("go")));
  function n() {
    let o = /^([+-])?(\d+)?(:\d+)?(%)?$/.exec(e.value);
    if (!o)
      return;
    let { state: i } = t, s = i.doc.lineAt(i.selection.main.head), [, l, a, c, h] = o, u = c ? +c.slice(1) : 0, m = a ? +a : s.number;
    if (a && h) {
      let O = m / 100;
      l && (O = O * (l == "-" ? -1 : 1) + s.number / i.doc.lines), m = Math.round(i.doc.lines * O);
    } else
      a && l && (m = m * (l == "-" ? -1 : 1) + s.number);
    let x = i.doc.line(Math.max(1, Math.min(i.doc.lines, m))), S = d.cursor(x.from + Math.max(0, Math.min(u, x.length)));
    t.dispatch({
      effects: [Ce.of(!1), p.scrollIntoView(S.from, { y: "center" })],
      selection: S
    }), t.focus();
  }
  return { dom: r };
}
const Ce = /* @__PURE__ */ E.define(), xt = /* @__PURE__ */ De.define({
  create() {
    return !0;
  },
  update(t, e) {
    for (let r of e.effects)
      r.is(Ce) && (t = r.value);
    return t;
  },
  provide: (t) => tt.from(t, (e) => e ? Qe : null)
}), Po = (t) => {
  let e = ne(t, Qe);
  if (!e) {
    let r = [Ce.of(!0)];
    t.state.field(xt, !1) == null && r.push(E.appendConfig.of([xt, Wo])), t.dispatch({ effects: r }), e = ne(t, Qe);
  }
  return e && e.dom.querySelector("input").focus(), !0;
}, Wo = /* @__PURE__ */ p.baseTheme({
  ".cm-panel.cm-gotoLine": {
    padding: "2px 6px 4px",
    "& label": { fontSize: "80%" }
  }
}), Fo = {
  highlightWordAroundCursor: !1,
  minSelectionLength: 1,
  maxMatches: 100,
  wholeWords: !1
}, An = /* @__PURE__ */ ie.define({
  combine(t) {
    return Be(t, Fo, {
      highlightWordAroundCursor: (e, r) => e || r,
      minSelectionLength: Math.min,
      maxMatches: Math.min
    });
  }
});
function No(t) {
  let e = [$o, Uo];
  return t && e.push(An.of(t)), e;
}
const qo = /* @__PURE__ */ y.mark({ class: "cm-selectionMatch" }), Vo = /* @__PURE__ */ y.mark({ class: "cm-selectionMatch cm-selectionMatch-main" });
function kt(t, e, r, n) {
  return (r == 0 || t(e.sliceDoc(r - 1, r)) != M.Word) && (n == e.doc.length || t(e.sliceDoc(n, n + 1)) != M.Word);
}
function Ho(t, e, r, n) {
  return t(e.sliceDoc(r, r + 1)) == M.Word && t(e.sliceDoc(n - 1, n)) == M.Word;
}
const Uo = /* @__PURE__ */ Wt.fromClass(class {
  constructor(t) {
    this.decorations = this.getDeco(t);
  }
  update(t) {
    (t.selectionSet || t.docChanged || t.viewportChanged) && (this.decorations = this.getDeco(t.view));
  }
  getDeco(t) {
    let e = t.state.facet(An), { state: r } = t, n = r.selection;
    if (n.ranges.length > 1)
      return y.none;
    let o = n.main, i, s = null;
    if (o.empty) {
      if (!e.highlightWordAroundCursor)
        return y.none;
      let a = r.wordAt(o.head);
      if (!a)
        return y.none;
      s = r.charCategorizer(o.head), i = r.sliceDoc(a.from, a.to);
    } else {
      let a = o.to - o.from;
      if (a < e.minSelectionLength || a > 200)
        return y.none;
      if (e.wholeWords) {
        if (i = r.sliceDoc(o.from, o.to), s = r.charCategorizer(o.head), !(kt(s, r, o.from, o.to) && Ho(s, r, o.from, o.to)))
          return y.none;
      } else if (i = r.sliceDoc(o.from, o.to).trim(), !i)
        return y.none;
    }
    let l = [];
    for (let a of t.visibleRanges) {
      let c = new J(r.doc, i, a.from, a.to);
      for (; !c.next().done; ) {
        let { from: h, to: u } = c.value;
        if ((!s || kt(s, r, h, u)) && (o.empty && h <= o.from && u >= o.to ? l.push(Vo.range(h, u)) : (h >= o.to || u <= o.from) && l.push(qo.range(h, u)), l.length > e.maxMatches))
          return y.none;
      }
    }
    return y.set(l);
  }
}, {
  decorations: (t) => t.decorations
}), $o = /* @__PURE__ */ p.baseTheme({
  ".cm-selectionMatch": { backgroundColor: "#99ff7780" },
  ".cm-searchMatch .cm-selectionMatch": { backgroundColor: "transparent" }
}), zo = ({ state: t, dispatch: e }) => {
  let { selection: r } = t, n = d.create(r.ranges.map((o) => t.wordAt(o.head) || d.cursor(o.head)), r.mainIndex);
  return n.eq(r) ? !1 : (e(t.update({ selection: n })), !0);
};
function Go(t, e) {
  let { main: r, ranges: n } = t.selection, o = t.wordAt(r.head), i = o && o.from == r.from && o.to == r.to;
  for (let s = !1, l = new J(t.doc, e, n[n.length - 1].to); ; )
    if (l.next(), l.done) {
      if (s)
        return null;
      l = new J(t.doc, e, 0, Math.max(0, n[n.length - 1].from - 1)), s = !0;
    } else {
      if (s && n.some((a) => a.from == l.value.from))
        continue;
      if (i) {
        let a = t.wordAt(l.value.from);
        if (!a || a.from != l.value.from || a.to != l.value.to)
          continue;
      }
      return l.value;
    }
}
const Ko = ({ state: t, dispatch: e }) => {
  let { ranges: r } = t.selection;
  if (r.some((i) => i.from === i.to))
    return zo({ state: t, dispatch: e });
  let n = t.sliceDoc(r[0].from, r[0].to);
  if (t.selection.ranges.some((i) => t.sliceDoc(i.from, i.to) != n))
    return !1;
  let o = Go(t, n);
  return o ? (e(t.update({
    selection: t.selection.addRange(d.range(o.from, o.to), !1),
    effects: p.scrollIntoView(o.to)
  })), !0) : !1;
}, Q = /* @__PURE__ */ ie.define({
  combine(t) {
    return Be(t, {
      top: !1,
      caseSensitive: !1,
      literal: !1,
      regexp: !1,
      wholeWord: !1,
      createPanel: (e) => new oi(e),
      scrollToMatch: (e) => p.scrollIntoView(e)
    });
  }
});
class vn {
  /**
  Create a query object.
  */
  constructor(e) {
    this.search = e.search, this.caseSensitive = !!e.caseSensitive, this.literal = !!e.literal, this.regexp = !!e.regexp, this.replace = e.replace || "", this.valid = !!this.search && (!this.regexp || Oo(this.search)), this.unquoted = this.unquote(this.search), this.wholeWord = !!e.wholeWord;
  }
  /**
  @internal
  */
  unquote(e) {
    return this.literal ? e : e.replace(/\\([nrt\\])/g, (r, n) => n == "n" ? `
` : n == "r" ? "\r" : n == "t" ? "	" : "\\");
  }
  /**
  Compare this query to another query.
  */
  eq(e) {
    return this.search == e.search && this.replace == e.replace && this.caseSensitive == e.caseSensitive && this.regexp == e.regexp && this.wholeWord == e.wholeWord;
  }
  /**
  @internal
  */
  create() {
    return this.regexp ? new Qo(this) : new _o(this);
  }
  /**
  Get a search cursor for this query, searching through the given
  range in the given state.
  */
  getCursor(e, r = 0, n) {
    let o = e.doc ? e : re.create({ doc: e });
    return n == null && (n = o.doc.length), this.regexp ? $(this, o, r, n) : U(this, o, r, n);
  }
}
class Mn {
  constructor(e) {
    this.spec = e;
  }
}
function U(t, e, r, n) {
  return new J(e.doc, t.unquoted, r, n, t.caseSensitive ? void 0 : (o) => o.toLowerCase(), t.wholeWord ? Jo(e.doc, e.charCategorizer(e.selection.main.head)) : void 0);
}
function Jo(t, e) {
  return (r, n, o, i) => ((i > r || i + o.length < n) && (i = Math.max(0, r - 2), o = t.sliceString(i, Math.min(t.length, n + 2))), (e(Ae(o, r - i)) != M.Word || e(ve(o, r - i)) != M.Word) && (e(ve(o, n - i)) != M.Word || e(Ae(o, n - i)) != M.Word));
}
class _o extends Mn {
  constructor(e) {
    super(e);
  }
  nextMatch(e, r, n) {
    let o = U(this.spec, e, n, e.doc.length).nextOverlapping();
    return o.done && (o = U(this.spec, e, 0, r).nextOverlapping()), o.done ? null : o.value;
  }
  // Searching in reverse is, rather than implementing an inverted search
  // cursor, done by scanning chunk after chunk forward.
  prevMatchInRange(e, r, n) {
    for (let o = n; ; ) {
      let i = Math.max(r, o - 1e4 - this.spec.unquoted.length), s = U(this.spec, e, i, o), l = null;
      for (; !s.nextOverlapping().done; )
        l = s.value;
      if (l)
        return l;
      if (i == r)
        return null;
      o -= 1e4;
    }
  }
  prevMatch(e, r, n) {
    return this.prevMatchInRange(e, 0, r) || this.prevMatchInRange(e, n, e.doc.length);
  }
  getReplacement(e) {
    return this.spec.unquote(this.spec.replace);
  }
  matchAll(e, r) {
    let n = U(this.spec, e, 0, e.doc.length), o = [];
    for (; !n.next().done; ) {
      if (o.length >= r)
        return null;
      o.push(n.value);
    }
    return o;
  }
  highlight(e, r, n, o) {
    let i = U(this.spec, e, Math.max(0, r - this.spec.unquoted.length), Math.min(n + this.spec.unquoted.length, e.doc.length));
    for (; !i.next().done; )
      o(i.value.from, i.value.to);
  }
}
function $(t, e, r, n) {
  return new Sn(e.doc, t.search, {
    ignoreCase: !t.caseSensitive,
    test: t.wholeWord ? jo(e.charCategorizer(e.selection.main.head)) : void 0
  }, r, n);
}
function Ae(t, e) {
  return t.slice(K(t, e, !1), e);
}
function ve(t, e) {
  return t.slice(e, K(t, e));
}
function jo(t) {
  return (e, r, n) => !n[0].length || (t(Ae(n.input, n.index)) != M.Word || t(ve(n.input, n.index)) != M.Word) && (t(ve(n.input, n.index + n[0].length)) != M.Word || t(Ae(n.input, n.index + n[0].length)) != M.Word);
}
class Qo extends Mn {
  nextMatch(e, r, n) {
    let o = $(this.spec, e, n, e.doc.length).next();
    return o.done && (o = $(this.spec, e, 0, r).next()), o.done ? null : o.value;
  }
  prevMatchInRange(e, r, n) {
    for (let o = 1; ; o++) {
      let i = Math.max(
        r,
        n - o * 1e4
        /* ChunkSize */
      ), s = $(this.spec, e, i, n), l = null;
      for (; !s.next().done; )
        l = s.value;
      if (l && (i == r || l.from > i + 10))
        return l;
      if (i == r)
        return null;
    }
  }
  prevMatch(e, r, n) {
    return this.prevMatchInRange(e, 0, r) || this.prevMatchInRange(e, n, e.doc.length);
  }
  getReplacement(e) {
    return this.spec.unquote(this.spec.replace.replace(/\$([$&\d+])/g, (r, n) => n == "$" ? "$" : n == "&" ? e.match[0] : n != "0" && +n < e.match.length ? e.match[n] : r));
  }
  matchAll(e, r) {
    let n = $(this.spec, e, 0, e.doc.length), o = [];
    for (; !n.next().done; ) {
      if (o.length >= r)
        return null;
      o.push(n.value);
    }
    return o;
  }
  highlight(e, r, n, o) {
    let i = $(this.spec, e, Math.max(
      0,
      r - 250
      /* HighlightMargin */
    ), Math.min(n + 250, e.doc.length));
    for (; !i.next().done; )
      o(i.value.from, i.value.to);
  }
}
const oe = /* @__PURE__ */ E.define(), st = /* @__PURE__ */ E.define(), P = /* @__PURE__ */ De.define({
  create(t) {
    return new Ue(Ye(t).create(), null);
  },
  update(t, e) {
    for (let r of e.effects)
      r.is(oe) ? t = new Ue(r.value.create(), t.panel) : r.is(st) && (t = new Ue(t.query, r.value ? lt : null));
    return t;
  },
  provide: (t) => tt.from(t, (e) => e.panel)
});
class Ue {
  constructor(e, r) {
    this.query = e, this.panel = r;
  }
}
const Yo = /* @__PURE__ */ y.mark({ class: "cm-searchMatch" }), Zo = /* @__PURE__ */ y.mark({ class: "cm-searchMatch cm-searchMatch-selected" }), Xo = /* @__PURE__ */ Wt.fromClass(class {
  constructor(t) {
    this.view = t, this.decorations = this.highlight(t.state.field(P));
  }
  update(t) {
    let e = t.state.field(P);
    (e != t.startState.field(P) || t.docChanged || t.selectionSet || t.viewportChanged) && (this.decorations = this.highlight(e));
  }
  highlight({ query: t, panel: e }) {
    if (!e || !t.spec.valid)
      return y.none;
    let { view: r } = this, n = new er();
    for (let o = 0, i = r.visibleRanges, s = i.length; o < s; o++) {
      let { from: l, to: a } = i[o];
      for (; o < s - 1 && a > i[o + 1].from - 2 * 250; )
        a = i[++o].to;
      t.highlight(r.state, l, a, (c, h) => {
        let u = r.state.selection.ranges.some((m) => m.from == c && m.to == h);
        n.add(c, h, u ? Zo : Yo);
      });
    }
    return n.finish();
  }
}, {
  decorations: (t) => t.decorations
});
function se(t) {
  return (e) => {
    let r = e.state.field(P, !1);
    return r && r.query.spec.valid ? t(e, r) : Dn(e);
  };
}
const Me = /* @__PURE__ */ se((t, { query: e }) => {
  let { to: r } = t.state.selection.main, n = e.nextMatch(t.state, r, r);
  if (!n)
    return !1;
  let o = d.single(n.from, n.to), i = t.state.facet(Q);
  return t.dispatch({
    selection: o,
    effects: [at(t, n), i.scrollToMatch(o.main, t)],
    userEvent: "select.search"
  }), Bn(t), !0;
}), Le = /* @__PURE__ */ se((t, { query: e }) => {
  let { state: r } = t, { from: n } = r.selection.main, o = e.prevMatch(r, n, n);
  if (!o)
    return !1;
  let i = d.single(o.from, o.to), s = t.state.facet(Q);
  return t.dispatch({
    selection: i,
    effects: [at(t, o), s.scrollToMatch(i.main, t)],
    userEvent: "select.search"
  }), Bn(t), !0;
}), ei = /* @__PURE__ */ se((t, { query: e }) => {
  let r = e.matchAll(t.state, 1e3);
  return !r || !r.length ? !1 : (t.dispatch({
    selection: d.create(r.map((n) => d.range(n.from, n.to))),
    userEvent: "select.search.matches"
  }), !0);
}), ti = ({ state: t, dispatch: e }) => {
  let r = t.selection;
  if (r.ranges.length > 1 || r.main.empty)
    return !1;
  let { from: n, to: o } = r.main, i = [], s = 0;
  for (let l = new J(t.doc, t.sliceDoc(n, o)); !l.next().done; ) {
    if (i.length > 1e3)
      return !1;
    l.value.from == n && (s = i.length), i.push(d.range(l.value.from, l.value.to));
  }
  return e(t.update({
    selection: d.create(i, s),
    userEvent: "select.search.matches"
  })), !0;
}, bt = /* @__PURE__ */ se((t, { query: e }) => {
  let { state: r } = t, { from: n, to: o } = r.selection.main;
  if (r.readOnly)
    return !1;
  let i = e.nextMatch(r, n, n);
  if (!i)
    return !1;
  let s = [], l, a, c = [];
  if (i.from == n && i.to == o && (a = r.toText(e.getReplacement(i)), s.push({ from: i.from, to: i.to, insert: a }), i = e.nextMatch(r, i.from, i.to), c.push(p.announce.of(r.phrase("replaced match on line $", r.doc.lineAt(n).number) + "."))), i) {
    let h = s.length == 0 || s[0].from >= i.to ? 0 : i.to - i.from - a.length;
    l = d.single(i.from - h, i.to - h), c.push(at(t, i)), c.push(r.facet(Q).scrollToMatch(l.main, t));
  }
  return t.dispatch({
    changes: s,
    selection: l,
    effects: c,
    userEvent: "input.replace"
  }), !0;
}), ni = /* @__PURE__ */ se((t, { query: e }) => {
  if (t.state.readOnly)
    return !1;
  let r = e.matchAll(t.state, 1e9).map((o) => {
    let { from: i, to: s } = o;
    return { from: i, to: s, insert: e.getReplacement(o) };
  });
  if (!r.length)
    return !1;
  let n = t.state.phrase("replaced $ matches", r.length) + ".";
  return t.dispatch({
    changes: r,
    effects: p.announce.of(n),
    userEvent: "input.replace.all"
  }), !0;
});
function lt(t) {
  return t.state.facet(Q).createPanel(t);
}
function Ye(t, e) {
  var r, n, o, i, s;
  let l = t.selection.main, a = l.empty || l.to > l.from + 100 ? "" : t.sliceDoc(l.from, l.to);
  if (e && !a)
    return e;
  let c = t.facet(Q);
  return new vn({
    search: ((r = e == null ? void 0 : e.literal) !== null && r !== void 0 ? r : c.literal) ? a : a.replace(/\n/g, "\\n"),
    caseSensitive: (n = e == null ? void 0 : e.caseSensitive) !== null && n !== void 0 ? n : c.caseSensitive,
    literal: (o = e == null ? void 0 : e.literal) !== null && o !== void 0 ? o : c.literal,
    regexp: (i = e == null ? void 0 : e.regexp) !== null && i !== void 0 ? i : c.regexp,
    wholeWord: (s = e == null ? void 0 : e.wholeWord) !== null && s !== void 0 ? s : c.wholeWord
  });
}
function Ln(t) {
  let e = ne(t, lt);
  return e && e.dom.querySelector("[main-field]");
}
function Bn(t) {
  let e = Ln(t);
  e && e == t.root.activeElement && e.select();
}
const Dn = (t) => {
  let e = t.state.field(P, !1);
  if (e && e.panel) {
    let r = Ln(t);
    if (r && r != t.root.activeElement) {
      let n = Ye(t.state, e.query.spec);
      n.valid && t.dispatch({ effects: oe.of(n) }), r.focus(), r.select();
    }
  } else
    t.dispatch({ effects: [
      st.of(!0),
      e ? oe.of(Ye(t.state, e.query.spec)) : E.appendConfig.of(si)
    ] });
  return !0;
}, En = (t) => {
  let e = t.state.field(P, !1);
  if (!e || !e.panel)
    return !1;
  let r = ne(t, lt);
  return r && r.dom.contains(t.root.activeElement) && t.focus(), t.dispatch({ effects: st.of(!1) }), !0;
}, ri = [
  { key: "Mod-f", run: Dn, scope: "editor search-panel" },
  { key: "F3", run: Me, shift: Le, scope: "editor search-panel", preventDefault: !0 },
  { key: "Mod-g", run: Me, shift: Le, scope: "editor search-panel", preventDefault: !0 },
  { key: "Escape", run: En, scope: "editor search-panel" },
  { key: "Mod-Shift-l", run: ti },
  { key: "Alt-g", run: Po },
  { key: "Mod-d", run: Ko, preventDefault: !0 }
];
class oi {
  constructor(e) {
    this.view = e;
    let r = this.query = e.state.field(P).query.spec;
    this.commit = this.commit.bind(this), this.searchField = g("input", {
      value: r.search,
      placeholder: A(e, "Find"),
      "aria-label": A(e, "Find"),
      class: "cm-textfield",
      name: "search",
      form: "",
      "main-field": "true",
      onchange: this.commit,
      onkeyup: this.commit
    }), this.replaceField = g("input", {
      value: r.replace,
      placeholder: A(e, "Replace"),
      "aria-label": A(e, "Replace"),
      class: "cm-textfield",
      name: "replace",
      form: "",
      onchange: this.commit,
      onkeyup: this.commit
    }), this.caseField = g("input", {
      type: "checkbox",
      name: "case",
      form: "",
      checked: r.caseSensitive,
      onchange: this.commit
    }), this.reField = g("input", {
      type: "checkbox",
      name: "re",
      form: "",
      checked: r.regexp,
      onchange: this.commit
    }), this.wordField = g("input", {
      type: "checkbox",
      name: "word",
      form: "",
      checked: r.wholeWord,
      onchange: this.commit
    });
    function n(o, i, s) {
      return g("button", { class: "cm-button", name: o, onclick: i, type: "button" }, s);
    }
    this.dom = g("div", { onkeydown: (o) => this.keydown(o), class: "cm-search" }, [
      this.searchField,
      n("next", () => Me(e), [A(e, "next")]),
      n("prev", () => Le(e), [A(e, "previous")]),
      n("select", () => ei(e), [A(e, "all")]),
      g("label", null, [this.caseField, A(e, "match case")]),
      g("label", null, [this.reField, A(e, "regexp")]),
      g("label", null, [this.wordField, A(e, "by word")]),
      ...e.state.readOnly ? [] : [
        g("br"),
        this.replaceField,
        n("replace", () => bt(e), [A(e, "replace")]),
        n("replaceAll", () => ni(e), [A(e, "replace all")])
      ],
      g("button", {
        name: "close",
        onclick: () => En(e),
        "aria-label": A(e, "close"),
        type: "button"
      }, ["×"])
    ]);
  }
  commit() {
    let e = new vn({
      search: this.searchField.value,
      caseSensitive: this.caseField.checked,
      regexp: this.reField.checked,
      wholeWord: this.wordField.checked,
      replace: this.replaceField.value
    });
    e.eq(this.query) || (this.query = e, this.view.dispatch({ effects: oe.of(e) }));
  }
  keydown(e) {
    tr(this.view, e, "search-panel") ? e.preventDefault() : e.keyCode == 13 && e.target == this.searchField ? (e.preventDefault(), (e.shiftKey ? Le : Me)(this.view)) : e.keyCode == 13 && e.target == this.replaceField && (e.preventDefault(), bt(this.view));
  }
  update(e) {
    for (let r of e.transactions)
      for (let n of r.effects)
        n.is(oe) && !n.value.eq(this.query) && this.setQuery(n.value);
  }
  setQuery(e) {
    this.query = e, this.searchField.value = e.search, this.replaceField.value = e.replace, this.caseField.checked = e.caseSensitive, this.reField.checked = e.regexp, this.wordField.checked = e.wholeWord;
  }
  mount() {
    this.searchField.select();
  }
  get pos() {
    return 80;
  }
  get top() {
    return this.view.state.facet(Q).top;
  }
}
function A(t, e) {
  return t.state.phrase(e);
}
const ge = 30, pe = /[\s\.,:;?!]/;
function at(t, { from: e, to: r }) {
  let n = t.state.doc.lineAt(e), o = t.state.doc.lineAt(r).to, i = Math.max(n.from, e - ge), s = Math.min(o, r + ge), l = t.state.sliceDoc(i, s);
  if (i != n.from) {
    for (let a = 0; a < ge; a++)
      if (!pe.test(l[a + 1]) && pe.test(l[a])) {
        l = l.slice(a);
        break;
      }
  }
  if (s != o) {
    for (let a = l.length - 1; a > l.length - ge; a--)
      if (!pe.test(l[a - 1]) && pe.test(l[a])) {
        l = l.slice(0, a);
        break;
      }
  }
  return p.announce.of(`${t.state.phrase("current match")}. ${l} ${t.state.phrase("on line")} ${n.number}.`);
}
const ii = /* @__PURE__ */ p.baseTheme({
  ".cm-panel.cm-search": {
    padding: "2px 6px 4px",
    position: "relative",
    "& [name=close]": {
      position: "absolute",
      top: "0",
      right: "4px",
      backgroundColor: "inherit",
      border: "none",
      font: "inherit",
      padding: 0,
      margin: 0
    },
    "& input, & button, & label": {
      margin: ".2em .6em .2em 0"
    },
    "& input[type=checkbox]": {
      marginRight: ".2em"
    },
    "& label": {
      fontSize: "80%",
      whiteSpace: "pre"
    }
  },
  "&light .cm-searchMatch": { backgroundColor: "#ffff0054" },
  "&dark .cm-searchMatch": { backgroundColor: "#00ffff8a" },
  "&light .cm-searchMatch-selected": { backgroundColor: "#ff6a0054" },
  "&dark .cm-searchMatch-selected": { backgroundColor: "#ff00ff8a" }
}), si = [
  P,
  /* @__PURE__ */ Zn.lowest(Xo),
  ii
];
class li {
  constructor(e, r, n) {
    this.from = e, this.to = r, this.diagnostic = n;
  }
}
class N {
  constructor(e, r, n) {
    this.diagnostics = e, this.panel = r, this.selected = n;
  }
  static init(e, r, n) {
    let o = e, i = n.facet(Tn).markerFilter;
    i && (o = i(o));
    let s = y.set(o.map((l) => l.from == l.to || l.from == l.to - 1 && n.doc.lineAt(l.from).to == l.from ? y.widget({
      widget: new pi(l),
      diagnostic: l
    }).range(l.from) : y.mark({
      attributes: { class: "cm-lintRange cm-lintRange-" + l.severity + (l.markClass ? " " + l.markClass : "") },
      diagnostic: l
    }).range(l.from, l.to)), !0);
    return new N(s, r, _(s));
  }
}
function _(t, e = null, r = 0) {
  let n = null;
  return t.between(r, 1e9, (o, i, { spec: s }) => {
    if (!(e && s.diagnostic != e))
      return n = new li(o, i, s.diagnostic), !1;
  }), n;
}
function ai(t, e) {
  let r = t.startState.doc.lineAt(e.pos);
  return !!(t.effects.some((n) => n.is(Rn)) || t.changes.touchesRange(r.from, r.to));
}
function ci(t, e) {
  return t.field(v, !1) ? e : e.concat(E.appendConfig.of(ki));
}
const Rn = /* @__PURE__ */ E.define(), ct = /* @__PURE__ */ E.define(), wn = /* @__PURE__ */ E.define(), v = /* @__PURE__ */ De.define({
  create() {
    return new N(y.none, null, null);
  },
  update(t, e) {
    if (e.docChanged) {
      let r = t.diagnostics.map(e.changes), n = null;
      if (t.selected) {
        let o = e.changes.mapPos(t.selected.from, 1);
        n = _(r, t.selected.diagnostic, o) || _(r, null, o);
      }
      t = new N(r, t.panel, n);
    }
    for (let r of e.effects)
      r.is(Rn) ? t = N.init(r.value, t.panel, e.state) : r.is(ct) ? t = new N(t.diagnostics, r.value ? Oe.open : null, t.selected) : r.is(wn) && (t = new N(t.diagnostics, t.panel, r.value));
    return t;
  },
  provide: (t) => [
    tt.from(t, (e) => e.panel),
    p.decorations.from(t, (e) => e.diagnostics)
  ]
}), hi = /* @__PURE__ */ y.mark({ class: "cm-lintRange cm-lintRange-active" });
function ui(t, e, r) {
  let { diagnostics: n } = t.state.field(v), o = [], i = 2e8, s = 0;
  n.between(e - (r < 0 ? 1 : 0), e + (r > 0 ? 1 : 0), (a, c, { spec: h }) => {
    e >= a && e <= c && (a == c || (e > a || r > 0) && (e < c || r < 0)) && (o.push(h.diagnostic), i = Math.min(a, i), s = Math.max(c, s));
  });
  let l = t.state.facet(Tn).tooltipFilter;
  return l && (o = l(o)), o.length ? {
    pos: i,
    end: s,
    above: t.state.doc.lineAt(i).to < s,
    create() {
      return { dom: fi(t, o) };
    }
  } : null;
}
function fi(t, e) {
  return g("ul", { class: "cm-tooltip-lint" }, e.map((r) => On(t, r, !1)));
}
const di = (t) => {
  let e = t.state.field(v, !1);
  (!e || !e.panel) && t.dispatch({ effects: ci(t.state, [ct.of(!0)]) });
  let r = ne(t, Oe.open);
  return r && r.dom.querySelector(".cm-panel-lint ul").focus(), !0;
}, St = (t) => {
  let e = t.state.field(v, !1);
  return !e || !e.panel ? !1 : (t.dispatch({ effects: ct.of(!1) }), !0);
}, mi = (t) => {
  let e = t.state.field(v, !1);
  if (!e)
    return !1;
  let r = t.state.selection.main, n = e.diagnostics.iter(r.to + 1);
  return !n.value && (n = e.diagnostics.iter(0), !n.value || n.from == r.from && n.to == r.to) ? !1 : (t.dispatch({ selection: { anchor: n.from, head: n.to }, scrollIntoView: !0 }), !0);
}, gi = [
  { key: "Mod-Shift-m", run: di, preventDefault: !0 },
  { key: "F8", run: mi }
], Tn = /* @__PURE__ */ ie.define({
  combine(t) {
    return Object.assign({ sources: t.map((e) => e.source) }, Be(t.map((e) => e.config), {
      delay: 750,
      markerFilter: null,
      tooltipFilter: null,
      needsRefresh: null
    }, {
      needsRefresh: (e, r) => e ? r ? (n) => e(n) || r(n) : e : r
    }));
  }
});
function In(t) {
  let e = [];
  if (t)
    e:
      for (let { name: r } of t) {
        for (let n = 0; n < r.length; n++) {
          let o = r[n];
          if (/[a-zA-Z]/.test(o) && !e.some((i) => i.toLowerCase() == o.toLowerCase())) {
            e.push(o);
            continue e;
          }
        }
        e.push("");
      }
  return e;
}
function On(t, e, r) {
  var n;
  let o = r ? In(e.actions) : [];
  return g("li", { class: "cm-diagnostic cm-diagnostic-" + e.severity }, g("span", { class: "cm-diagnosticText" }, e.renderMessage ? e.renderMessage() : e.message), (n = e.actions) === null || n === void 0 ? void 0 : n.map((i, s) => {
    let l = !1, a = (m) => {
      if (m.preventDefault(), l)
        return;
      l = !0;
      let x = _(t.state.field(v).diagnostics, e);
      x && i.apply(t, x.from, x.to);
    }, { name: c } = i, h = o[s] ? c.indexOf(o[s]) : -1, u = h < 0 ? c : [
      c.slice(0, h),
      g("u", c.slice(h, h + 1)),
      c.slice(h + 1)
    ];
    return g("button", {
      type: "button",
      class: "cm-diagnosticAction",
      onclick: a,
      onmousedown: a,
      "aria-label": ` Action: ${c}${h < 0 ? "" : ` (access key "${o[s]})"`}.`
    }, u);
  }), e.source && g("div", { class: "cm-diagnosticSource" }, e.source));
}
class pi extends rr {
  constructor(e) {
    super(), this.diagnostic = e;
  }
  eq(e) {
    return e.diagnostic == this.diagnostic;
  }
  toDOM() {
    return g("span", { class: "cm-lintPoint cm-lintPoint-" + this.diagnostic.severity });
  }
}
class Ct {
  constructor(e, r) {
    this.diagnostic = r, this.id = "item_" + Math.floor(Math.random() * 4294967295).toString(16), this.dom = On(e, r, !0), this.dom.id = this.id, this.dom.setAttribute("role", "option");
  }
}
class Oe {
  constructor(e) {
    this.view = e, this.items = [];
    let r = (o) => {
      if (o.keyCode == 27)
        St(this.view), this.view.focus();
      else if (o.keyCode == 38 || o.keyCode == 33)
        this.moveSelection((this.selectedIndex - 1 + this.items.length) % this.items.length);
      else if (o.keyCode == 40 || o.keyCode == 34)
        this.moveSelection((this.selectedIndex + 1) % this.items.length);
      else if (o.keyCode == 36)
        this.moveSelection(0);
      else if (o.keyCode == 35)
        this.moveSelection(this.items.length - 1);
      else if (o.keyCode == 13)
        this.view.focus();
      else if (o.keyCode >= 65 && o.keyCode <= 90 && this.selectedIndex >= 0) {
        let { diagnostic: i } = this.items[this.selectedIndex], s = In(i.actions);
        for (let l = 0; l < s.length; l++)
          if (s[l].toUpperCase().charCodeAt(0) == o.keyCode) {
            let a = _(this.view.state.field(v).diagnostics, i);
            a && i.actions[l].apply(e, a.from, a.to);
          }
      } else
        return;
      o.preventDefault();
    }, n = (o) => {
      for (let i = 0; i < this.items.length; i++)
        this.items[i].dom.contains(o.target) && this.moveSelection(i);
    };
    this.list = g("ul", {
      tabIndex: 0,
      role: "listbox",
      "aria-label": this.view.state.phrase("Diagnostics"),
      onkeydown: r,
      onclick: n
    }), this.dom = g("div", { class: "cm-panel-lint" }, this.list, g("button", {
      type: "button",
      name: "close",
      "aria-label": this.view.state.phrase("close"),
      onclick: () => St(this.view)
    }, "×")), this.update();
  }
  get selectedIndex() {
    let e = this.view.state.field(v).selected;
    if (!e)
      return -1;
    for (let r = 0; r < this.items.length; r++)
      if (this.items[r].diagnostic == e.diagnostic)
        return r;
    return -1;
  }
  update() {
    let { diagnostics: e, selected: r } = this.view.state.field(v), n = 0, o = !1, i = null;
    for (e.between(0, this.view.state.doc.length, (s, l, { spec: a }) => {
      let c = -1, h;
      for (let u = n; u < this.items.length; u++)
        if (this.items[u].diagnostic == a.diagnostic) {
          c = u;
          break;
        }
      c < 0 ? (h = new Ct(this.view, a.diagnostic), this.items.splice(n, 0, h), o = !0) : (h = this.items[c], c > n && (this.items.splice(n, c - n), o = !0)), r && h.diagnostic == r.diagnostic ? h.dom.hasAttribute("aria-selected") || (h.dom.setAttribute("aria-selected", "true"), i = h) : h.dom.hasAttribute("aria-selected") && h.dom.removeAttribute("aria-selected"), n++;
    }); n < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0); )
      o = !0, this.items.pop();
    this.items.length == 0 && (this.items.push(new Ct(this.view, {
      from: -1,
      to: -1,
      severity: "info",
      message: this.view.state.phrase("No diagnostics")
    })), o = !0), i ? (this.list.setAttribute("aria-activedescendant", i.id), this.view.requestMeasure({
      key: this,
      read: () => ({ sel: i.dom.getBoundingClientRect(), panel: this.list.getBoundingClientRect() }),
      write: ({ sel: s, panel: l }) => {
        s.top < l.top ? this.list.scrollTop -= l.top - s.top : s.bottom > l.bottom && (this.list.scrollTop += s.bottom - l.bottom);
      }
    })) : this.selectedIndex < 0 && this.list.removeAttribute("aria-activedescendant"), o && this.sync();
  }
  sync() {
    let e = this.list.firstChild;
    function r() {
      let n = e;
      e = n.nextSibling, n.remove();
    }
    for (let n of this.items)
      if (n.dom.parentNode == this.list) {
        for (; e != n.dom; )
          r();
        e = n.dom.nextSibling;
      } else
        this.list.insertBefore(n.dom, e);
    for (; e; )
      r();
  }
  moveSelection(e) {
    if (this.selectedIndex < 0)
      return;
    let r = this.view.state.field(v), n = _(r.diagnostics, this.items[e].diagnostic);
    n && this.view.dispatch({
      selection: { anchor: n.from, head: n.to },
      scrollIntoView: !0,
      effects: wn.of(n)
    });
  }
  static open(e) {
    return new Oe(e);
  }
}
function yi(t, e = 'viewBox="0 0 40 40"') {
  return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`;
}
function ye(t) {
  return yi(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`, 'width="6" height="3"');
}
const xi = /* @__PURE__ */ p.baseTheme({
  ".cm-diagnostic": {
    padding: "3px 6px 3px 8px",
    marginLeft: "-1px",
    display: "block",
    whiteSpace: "pre-wrap"
  },
  ".cm-diagnostic-error": { borderLeft: "5px solid #d11" },
  ".cm-diagnostic-warning": { borderLeft: "5px solid orange" },
  ".cm-diagnostic-info": { borderLeft: "5px solid #999" },
  ".cm-diagnostic-hint": { borderLeft: "5px solid #66d" },
  ".cm-diagnosticAction": {
    font: "inherit",
    border: "none",
    padding: "2px 4px",
    backgroundColor: "#444",
    color: "white",
    borderRadius: "3px",
    marginLeft: "8px",
    cursor: "pointer"
  },
  ".cm-diagnosticSource": {
    fontSize: "70%",
    opacity: 0.7
  },
  ".cm-lintRange": {
    backgroundPosition: "left bottom",
    backgroundRepeat: "repeat-x",
    paddingBottom: "0.7px"
  },
  ".cm-lintRange-error": { backgroundImage: /* @__PURE__ */ ye("#d11") },
  ".cm-lintRange-warning": { backgroundImage: /* @__PURE__ */ ye("orange") },
  ".cm-lintRange-info": { backgroundImage: /* @__PURE__ */ ye("#999") },
  ".cm-lintRange-hint": { backgroundImage: /* @__PURE__ */ ye("#66d") },
  ".cm-lintRange-active": { backgroundColor: "#ffdd9980" },
  ".cm-tooltip-lint": {
    padding: 0,
    margin: 0
  },
  ".cm-lintPoint": {
    position: "relative",
    "&:after": {
      content: '""',
      position: "absolute",
      bottom: 0,
      left: "-2px",
      borderLeft: "3px solid transparent",
      borderRight: "3px solid transparent",
      borderBottom: "4px solid #d11"
    }
  },
  ".cm-lintPoint-warning": {
    "&:after": { borderBottomColor: "orange" }
  },
  ".cm-lintPoint-info": {
    "&:after": { borderBottomColor: "#999" }
  },
  ".cm-lintPoint-hint": {
    "&:after": { borderBottomColor: "#66d" }
  },
  ".cm-panel.cm-panel-lint": {
    position: "relative",
    "& ul": {
      maxHeight: "100px",
      overflowY: "auto",
      "& [aria-selected]": {
        backgroundColor: "#ddd",
        "& u": { textDecoration: "underline" }
      },
      "&:focus [aria-selected]": {
        background_fallback: "#bdf",
        backgroundColor: "Highlight",
        color_fallback: "white",
        color: "HighlightText"
      },
      "& u": { textDecoration: "none" },
      padding: 0,
      margin: 0
    },
    "& [name=close]": {
      position: "absolute",
      top: "0",
      right: "2px",
      background: "inherit",
      border: "none",
      font: "inherit",
      padding: 0,
      margin: 0
    }
  }
}), ki = [
  v,
  /* @__PURE__ */ p.decorations.compute([v], (t) => {
    let { selected: e, panel: r } = t.field(v);
    return !e || !r || e.from == e.to ? y.none : y.set([
      hi.range(e.from, e.to)
    ]);
  }),
  /* @__PURE__ */ nr(ui, { hideOn: ai }),
  xi
];
var At = function(e) {
  e === void 0 && (e = {});
  var r = [];
  e.closeBracketsKeymap !== !1 && (r = r.concat(or)), e.defaultKeymap !== !1 && (r = r.concat(To)), e.searchKeymap !== !1 && (r = r.concat(ri)), e.historyKeymap !== !1 && (r = r.concat(Ur)), e.foldKeymap !== !1 && (r = r.concat(ir)), e.completionKeymap !== !1 && (r = r.concat(sr)), e.lintKeymap !== !1 && (r = r.concat(gi));
  var n = [];
  return e.lineNumbers !== !1 && n.push(lr()), e.highlightActiveLineGutter !== !1 && n.push(ar()), e.highlightSpecialChars !== !1 && n.push(cr()), e.history !== !1 && n.push(Ir()), e.foldGutter !== !1 && n.push(hr()), e.drawSelection !== !1 && n.push(ur()), e.dropCursor !== !1 && n.push(fr()), e.allowMultipleSelections !== !1 && n.push(re.allowMultipleSelections.of(!0)), e.indentOnInput !== !1 && n.push(dr()), e.syntaxHighlighting !== !1 && n.push(Ft(br, {
    fallback: !0
  })), e.bracketMatching !== !1 && n.push(mr()), e.closeBrackets !== !1 && n.push(gr()), e.autocompletion !== !1 && n.push(pr()), e.rectangularSelection !== !1 && n.push(yr()), e.crosshairCursor !== !1 && n.push(xr()), e.highlightActiveLine !== !1 && n.push(kr()), e.highlightSelectionMatches !== !1 && n.push(No()), e.tabSize && typeof e.tabSize == "number" && n.push(Ot.of(" ".repeat(e.tabSize))), n.concat([Nt.of(r.flat())]).filter(Boolean);
};
const bi = "#e5c07b", vt = "#e06c75", Si = "#56b6c2", Ci = "#ffffff", xe = "#abb2bf", Ze = "#7d8799", Ai = "#61afef", vi = "#98c379", Mt = "#d19a66", Mi = "#c678dd", Li = "#21252b", Lt = "#2c313a", Bt = "#282c34", $e = "#353a42", Bi = "#3E4451", Dt = "#528bff", Di = /* @__PURE__ */ p.theme({
  "&": {
    color: xe,
    backgroundColor: Bt
  },
  ".cm-content": {
    caretColor: Dt
  },
  ".cm-cursor, .cm-dropCursor": { borderLeftColor: Dt },
  "&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: Bi },
  ".cm-panels": { backgroundColor: Li, color: xe },
  ".cm-panels.cm-panels-top": { borderBottom: "2px solid black" },
  ".cm-panels.cm-panels-bottom": { borderTop: "2px solid black" },
  ".cm-searchMatch": {
    backgroundColor: "#72a1ff59",
    outline: "1px solid #457dff"
  },
  ".cm-searchMatch.cm-searchMatch-selected": {
    backgroundColor: "#6199ff2f"
  },
  ".cm-activeLine": { backgroundColor: "#6699ff0b" },
  ".cm-selectionMatch": { backgroundColor: "#aafe661a" },
  "&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket": {
    backgroundColor: "#bad0f847"
  },
  ".cm-gutters": {
    backgroundColor: Bt,
    color: Ze,
    border: "none"
  },
  ".cm-activeLineGutter": {
    backgroundColor: Lt
  },
  ".cm-foldPlaceholder": {
    backgroundColor: "transparent",
    border: "none",
    color: "#ddd"
  },
  ".cm-tooltip": {
    border: "none",
    backgroundColor: $e
  },
  ".cm-tooltip .cm-tooltip-arrow:before": {
    borderTopColor: "transparent",
    borderBottomColor: "transparent"
  },
  ".cm-tooltip .cm-tooltip-arrow:after": {
    borderTopColor: $e,
    borderBottomColor: $e
  },
  ".cm-tooltip-autocomplete": {
    "& > ul > li[aria-selected]": {
      backgroundColor: Lt,
      color: xe
    }
  }
}, { dark: !0 }), Ei = /* @__PURE__ */ Sr.define([
  {
    tag: f.keyword,
    color: Mi
  },
  {
    tag: [f.name, f.deleted, f.character, f.propertyName, f.macroName],
    color: vt
  },
  {
    tag: [/* @__PURE__ */ f.function(f.variableName), f.labelName],
    color: Ai
  },
  {
    tag: [f.color, /* @__PURE__ */ f.constant(f.name), /* @__PURE__ */ f.standard(f.name)],
    color: Mt
  },
  {
    tag: [/* @__PURE__ */ f.definition(f.name), f.separator],
    color: xe
  },
  {
    tag: [f.typeName, f.className, f.number, f.changed, f.annotation, f.modifier, f.self, f.namespace],
    color: bi
  },
  {
    tag: [f.operator, f.operatorKeyword, f.url, f.escape, f.regexp, f.link, /* @__PURE__ */ f.special(f.string)],
    color: Si
  },
  {
    tag: [f.meta, f.comment],
    color: Ze
  },
  {
    tag: f.strong,
    fontWeight: "bold"
  },
  {
    tag: f.emphasis,
    fontStyle: "italic"
  },
  {
    tag: f.strikethrough,
    textDecoration: "line-through"
  },
  {
    tag: f.link,
    color: Ze,
    textDecoration: "underline"
  },
  {
    tag: f.heading,
    fontWeight: "bold",
    color: vt
  },
  {
    tag: [f.atom, f.bool, /* @__PURE__ */ f.special(f.variableName)],
    color: Mt
  },
  {
    tag: [f.processingInstruction, f.string, f.inserted],
    color: vi
  },
  {
    tag: f.invalid,
    color: Ci
  }
]), Ri = [Di, /* @__PURE__ */ Ft(Ei)];
var wi = p.theme({
  "&": {
    backgroundColor: "#fff"
  }
}, {
  dark: !1
}), Ti = function(e) {
  e === void 0 && (e = {});
  var {
    indentWithTab: r = !0,
    editable: n = !0,
    readOnly: o = !1,
    theme: i = "light",
    placeholder: s = "",
    basicSetup: l = !0
  } = e, a = [];
  switch (r && a.unshift(Nt.of([Io])), l && (typeof l == "boolean" ? a.unshift(At()) : a.unshift(At(l))), s && a.unshift(Cr(s)), i) {
    case "light":
      a.push(wi);
      break;
    case "dark":
      a.push(Ri);
      break;
    case "none":
      break;
    default:
      a.push(i);
      break;
  }
  return n === !1 && a.push(p.editable.of(!1)), o && a.push(re.readOnly.of(!0)), [...a];
}, Ii = (t) => ({
  line: t.state.doc.lineAt(t.state.selection.main.from),
  lineCount: t.state.doc.lines,
  lineBreak: t.state.lineBreak,
  length: t.state.doc.length,
  readOnly: t.state.readOnly,
  tabSize: t.state.tabSize,
  selection: t.state.selection,
  selectionAsSingle: t.state.selection.asSingle().main,
  ranges: t.state.selection.ranges,
  selectionCode: t.state.sliceDoc(t.state.selection.main.from, t.state.selection.main.to),
  selections: t.state.selection.ranges.map((e) => t.state.sliceDoc(e.from, e.to)),
  selectedText: t.state.selection.ranges.some((e) => !e.empty)
}), Et = Xe.define(), Oi = [];
function Pi(t) {
  var {
    value: e,
    selection: r,
    onChange: n,
    onStatistics: o,
    onCreateEditor: i,
    onUpdate: s,
    extensions: l = Oi,
    autoFocus: a,
    theme: c = "light",
    height: h = null,
    minHeight: u = null,
    maxHeight: m = null,
    width: x = null,
    minWidth: S = null,
    maxWidth: O = null,
    placeholder: le = "",
    editable: ae = !0,
    readOnly: ce = !1,
    indentWithTab: he = !0,
    basicSetup: ue = !0,
    root: Pe,
    initialState: Y
  } = t, [q, fe] = Ne(), [k, I] = Ne(), [V, H] = Ne(), We = p.theme({
    "&": {
      height: h,
      minHeight: u,
      maxHeight: m,
      width: x,
      minWidth: S,
      maxWidth: O
    },
    "& .cm-scroller": {
      height: "100% !important"
    }
  }), Fe = p.updateListener.of((D) => {
    if (D.docChanged && typeof n == "function" && // Fix echoing of the remote changes:
    // If transaction is market as remote we don't have to call `onChange` handler again
    !D.transactions.some((Fn) => Fn.annotation(Et))) {
      var X = D.state.doc, de = X.toString();
      n(de, D);
    }
    o && o(Ii(D));
  }), Wn = Ti({
    theme: c,
    editable: ae,
    readOnly: ce,
    placeholder: le,
    indentWithTab: he,
    basicSetup: ue
  }), Z = [Fe, We, ...Wn];
  return s && typeof s == "function" && Z.push(p.updateListener.of(s)), Z = Z.concat(l), F(() => {
    if (q && !V) {
      var D = {
        doc: e,
        selection: r,
        extensions: Z
      }, X = Y ? re.fromJSON(Y.json, D, Y.fields) : re.create(D);
      if (H(X), !k) {
        var de = new p({
          state: X,
          parent: q,
          root: Pe
        });
        I(de), i && i(de, X);
      }
    }
    return () => {
      k && (H(void 0), I(void 0));
    };
  }, [q, V]), F(() => fe(t.container), [t.container]), F(() => () => {
    k && (k.destroy(), I(void 0));
  }, [k]), F(() => {
    a && k && k.focus();
  }, [a, k]), F(() => {
    k && k.dispatch({
      effects: E.reconfigure.of(Z)
    });
  }, [c, l, h, u, m, x, S, O, le, ae, ce, he, ue, n, s]), F(() => {
    if (e !== void 0) {
      var D = k ? k.state.doc.toString() : "";
      k && e !== D && k.dispatch({
        changes: {
          from: 0,
          to: D.length,
          insert: e || ""
        },
        annotations: [Et.of(!0)]
      });
    }
  }, [e, k]), {
    state: V,
    setState: H,
    view: k,
    setView: I,
    container: q,
    setContainer: fe
  };
}
var Wi = ["className", "value", "selection", "extensions", "onChange", "onStatistics", "onCreateEditor", "onUpdate", "autoFocus", "theme", "height", "minHeight", "maxHeight", "width", "minWidth", "maxWidth", "basicSetup", "placeholder", "indentWithTab", "editable", "readOnly", "root", "initialState"], Pn = /* @__PURE__ */ Rt((t, e) => {
  var {
    className: r,
    value: n = "",
    selection: o,
    extensions: i = [],
    onChange: s,
    onStatistics: l,
    onCreateEditor: a,
    onUpdate: c,
    autoFocus: h,
    theme: u = "light",
    height: m,
    minHeight: x,
    maxHeight: S,
    width: O,
    minWidth: le,
    maxWidth: ae,
    basicSetup: ce,
    placeholder: he,
    indentWithTab: ue,
    editable: Pe,
    readOnly: Y,
    root: q,
    initialState: fe
  } = t, k = Nn(t, Wi), I = qn(null), {
    state: V,
    view: H,
    container: We
  } = Pi({
    container: I.current,
    root: q,
    value: n,
    autoFocus: h,
    theme: u,
    height: m,
    minHeight: x,
    maxHeight: S,
    width: O,
    minWidth: le,
    maxWidth: ae,
    basicSetup: ce,
    placeholder: he,
    indentWithTab: ue,
    editable: Pe,
    readOnly: Y,
    selection: o,
    onChange: s,
    onStatistics: l,
    onCreateEditor: a,
    onUpdate: c,
    extensions: i,
    initialState: fe
  });
  if (Vn(e, () => ({
    editor: I.current,
    state: V,
    view: H
  }), [I, We, V, H]), typeof n != "string")
    throw new Error("value must be typeof string but got " + typeof n);
  var Fe = typeof u == "string" ? "cm-theme-" + u : "cm-theme";
  return /* @__PURE__ */ te.jsx("div", Hn({
    ref: I,
    className: "" + Fe + (r ? " " + r : "")
  }, k));
});
Pn.displayName = "CodeMirror";
const Fi = p.theme({
  "& .cm-scroller": {
    fontFamily: "Consolas, Liberation Mono, Menlo, Courier, monospace"
  },
  "& .cm-activeLine, & .cm-activeLineGutter": {
    backgroundColor: "transparent"
  }
}), Vi = Rt(function({
  title: e,
  value: r,
  height: n = "200px",
  error: o,
  hint: i,
  clearBg: s = !0,
  extensions: l,
  onChange: a,
  ...c
}, h) {
  const u = Un(), [m, x] = $n.useState(null);
  F(() => {
    Promise.all(l).then(x);
  }, [l]);
  let S = zn(
    "peer order-2 overflow-hidden rounded-sm border",
    s ? "bg-transparent" : "bg-grey-75",
    o ? "border-red" : "border-grey-500 hover:border-grey-700 focus:border-grey-800",
    e && "mt-2",
    n === "full" && "h-full"
  );
  return m ? /* @__PURE__ */ te.jsxs("div", { className: n === "full" ? "h-full" : "", children: [
    /* @__PURE__ */ te.jsx(
      Pn,
      {
        ref: h,
        className: S,
        extensions: m,
        height: n === "full" ? "100%" : n,
        theme: Fi,
        value: r,
        onChange: a,
        ...c
      }
    ),
    e && /* @__PURE__ */ te.jsx(Gn, { className: "order-1 !text-grey-700 peer-focus:!text-black", htmlFor: u, useLabelTag: !0, children: e }),
    i && /* @__PURE__ */ te.jsx(Kn, { className: "order-3", color: o ? "red" : "", children: i })
  ] }) : null;
});
export {
  Vi as default
};
//# sourceMappingURL=CodeEditorView-8aa11a1f.mjs.map
