import { o as V, a as F, p as N, q as _, h as C, b as A, s as L, t as u, i as D, l as J, f as M, g as B, E as q, j as H } from "./index-CiDp87m0.js";
var b = /* @__PURE__ */ (function(n) {
  return n[n.Simple = 0] = "Simple", n[n.TrackDel = 1] = "TrackDel", n[n.TrackBefore = 2] = "TrackBefore", n[n.TrackAfter = 3] = "TrackAfter", n;
})(b || (b = {}));
class p {
  constructor(O, t, e) {
    this.from = O, this.to = t, this.flags = e;
  }
  /**
  The anchor of the range—the side that doesn't move when you
  extend it.
  */
  get anchor() {
    return this.flags & 32 ? this.to : this.from;
  }
  /**
  The head of the range, which is moved when the range is
  [extended](https://codemirror.net/6/docs/ref/#state.SelectionRange.extend).
  */
  get head() {
    return this.flags & 32 ? this.from : this.to;
  }
  /**
  True when `anchor` and `head` are at the same position.
  */
  get empty() {
    return this.from == this.to;
  }
  /**
  If this is a cursor that is explicitly associated with the
  character on one of its sides, this returns the side. -1 means
  the character before its position, 1 the character after, and 0
  means no association.
  */
  get assoc() {
    return this.flags & 8 ? -1 : this.flags & 16 ? 1 : 0;
  }
  /**
  The bidirectional text level associated with this cursor, if
  any.
  */
  get bidiLevel() {
    let O = this.flags & 7;
    return O == 7 ? null : O;
  }
  /**
  The goal column (stored vertical offset) associated with a
  cursor. This is used to preserve the vertical position when
  [moving](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) across
  lines of different length.
  */
  get goalColumn() {
    let O = this.flags >> 6;
    return O == 16777215 ? void 0 : O;
  }
  /**
  Map this range through a change, producing a valid range in the
  updated document.
  */
  map(O, t = -1) {
    let e, i;
    return this.empty ? e = i = O.mapPos(this.from, t) : (e = O.mapPos(this.from, 1), i = O.mapPos(this.to, -1)), e == this.from && i == this.to ? this : new p(e, i, this.flags);
  }
  /**
  Extend this range to cover at least `from` to `to`.
  */
  extend(O, t = O) {
    if (O <= this.anchor && t >= this.anchor)
      return f.range(O, t);
    let e = Math.abs(O - this.anchor) > Math.abs(t - this.anchor) ? O : t;
    return f.range(this.anchor, e);
  }
  /**
  Compare this range to another range.
  */
  eq(O, t = !1) {
    return this.anchor == O.anchor && this.head == O.head && (!t || !this.empty || this.assoc == O.assoc);
  }
  /**
  Return a JSON-serializable object representing the range.
  */
  toJSON() {
    return { anchor: this.anchor, head: this.head };
  }
  /**
  Convert a JSON representation of a range to a `SelectionRange`
  instance.
  */
  static fromJSON(O) {
    if (!O || typeof O.anchor != "number" || typeof O.head != "number")
      throw new RangeError("Invalid JSON representation for SelectionRange");
    return f.range(O.anchor, O.head);
  }
  /**
  @internal
  */
  static create(O, t, e) {
    return new p(O, t, e);
  }
}
class f {
  constructor(O, t) {
    this.ranges = O, this.mainIndex = t;
  }
  /**
  Map a selection through a change. Used to adjust the selection
  position for changes.
  */
  map(O, t = -1) {
    return O.empty ? this : f.create(this.ranges.map((e) => e.map(O, t)), this.mainIndex);
  }
  /**
  Compare this selection to another selection. By default, ranges
  are compared only by position. When `includeAssoc` is true,
  cursor ranges must also have the same
  [`assoc`](https://codemirror.net/6/docs/ref/#state.SelectionRange.assoc) value.
  */
  eq(O, t = !1) {
    if (this.ranges.length != O.ranges.length || this.mainIndex != O.mainIndex)
      return !1;
    for (let e = 0; e < this.ranges.length; e++)
      if (!this.ranges[e].eq(O.ranges[e], t))
        return !1;
    return !0;
  }
  /**
  Get the primary selection range. Usually, you should make sure
  your code applies to _all_ ranges, by using methods like
  [`changeByRange`](https://codemirror.net/6/docs/ref/#state.EditorState.changeByRange).
  */
  get main() {
    return this.ranges[this.mainIndex];
  }
  /**
  Make sure the selection only has one range. Returns a selection
  holding only the main range from this selection.
  */
  asSingle() {
    return this.ranges.length == 1 ? this : new f([this.main], 0);
  }
  /**
  Extend this selection with an extra range.
  */
  addRange(O, t = !0) {
    return f.create([O].concat(this.ranges), t ? 0 : this.mainIndex + 1);
  }
  /**
  Replace a given range with another range, and then normalize the
  selection to merge and sort ranges if necessary.
  */
  replaceRange(O, t = this.mainIndex) {
    let e = this.ranges.slice();
    return e[t] = O, f.create(e, this.mainIndex);
  }
  /**
  Convert this selection to an object that can be serialized to
  JSON.
  */
  toJSON() {
    return { ranges: this.ranges.map((O) => O.toJSON()), main: this.mainIndex };
  }
  /**
  Create a selection from a JSON representation.
  */
  static fromJSON(O) {
    if (!O || !Array.isArray(O.ranges) || typeof O.main != "number" || O.main >= O.ranges.length)
      throw new RangeError("Invalid JSON representation for EditorSelection");
    return new f(O.ranges.map((t) => p.fromJSON(t)), O.main);
  }
  /**
  Create a selection holding a single range.
  */
  static single(O, t = O) {
    return new f([f.range(O, t)], 0);
  }
  /**
  Sort and merge the given set of ranges, creating a valid
  selection.
  */
  static create(O, t = 0) {
    if (O.length == 0)
      throw new RangeError("A selection needs at least one range");
    for (let e = 0, i = 0; i < O.length; i++) {
      let r = O[i];
      if (r.empty ? r.from <= e : r.from < e)
        return f.normalized(O.slice(), t);
      e = r.to;
    }
    return new f(O, t);
  }
  /**
  Create a cursor selection range at the given position. You can
  safely ignore the optional arguments in most situations.
  */
  static cursor(O, t = 0, e, i) {
    return p.create(O, O, (t == 0 ? 0 : t < 0 ? 8 : 16) | (e == null ? 7 : Math.min(6, e)) | (i ?? 16777215) << 6);
  }
  /**
  Create a selection range.
  */
  static range(O, t, e, i) {
    let r = (e ?? 16777215) << 6 | (i == null ? 7 : Math.min(6, i));
    return t < O ? p.create(t, O, 48 | r) : p.create(O, t, (t > O ? 8 : 0) | r);
  }
  /**
  @internal
  */
  static normalized(O, t = 0) {
    let e = O[t];
    O.sort((i, r) => i.from - r.from), t = O.indexOf(e);
    for (let i = 1; i < O.length; i++) {
      let r = O[i], a = O[i - 1];
      if (r.empty ? r.from <= a.to : r.from < a.to) {
        let s = a.from, o = Math.max(r.to, a.to);
        i <= t && t--, O.splice(--i, 2, r.anchor > r.head ? f.range(o, s) : f.range(s, o));
      }
    }
    return new f(O, t);
  }
}
let K;
try {
  K = /* @__PURE__ */ new RegExp("[\\p{Alphabetic}\\p{Number}_]", "u");
} catch {
}
b.TrackDel;
class $ {
  constructor(O, t, e) {
    this.from = O, this.to = t, this.value = e;
  }
  /**
  @internal
  */
  static create(O, t, e) {
    return new $(O, t, e);
  }
}
function R(n, O) {
  return n.from - O.from || n.value.startSide - O.value.startSide;
}
class T {
  constructor(O, t, e, i) {
    this.from = O, this.to = t, this.value = e, this.maxPoint = i;
  }
  get length() {
    return this.to[this.to.length - 1];
  }
  // Find the index of the given position and side. Use the ranges'
  // `from` pos when `end == false`, `to` when `end == true`.
  findIndex(O, t, e, i = 0) {
    let r = e ? this.to : this.from;
    for (let a = i, s = r.length; ; ) {
      if (a == s)
        return a;
      let o = a + s >> 1, h = r[o] - O || (e ? this.value[o].endSide : this.value[o].startSide) - t;
      if (o == a)
        return h >= 0 ? a : s;
      h >= 0 ? s = o : a = o + 1;
    }
  }
  between(O, t, e, i) {
    for (let r = this.findIndex(t, -1e9, !0), a = this.findIndex(e, 1e9, !1, r); r < a; r++)
      if (i(this.from[r] + O, this.to[r] + O, this.value[r]) === !1)
        return !1;
  }
  map(O, t) {
    let e = [], i = [], r = [], a = -1, s = -1;
    for (let o = 0; o < this.value.length; o++) {
      let h = this.value[o], l = this.from[o] + O, P = this.to[o] + O, c, d;
      if (l == P) {
        let Z = t.mapPos(l, h.startSide, h.mapMode);
        if (Z == null || (c = d = Z, h.startSide != h.endSide && (d = t.mapPos(l, h.endSide), d < c)))
          continue;
      } else if (c = t.mapPos(l, h.startSide), d = t.mapPos(P, h.endSide), c > d || c == d && h.startSide > 0 && h.endSide <= 0)
        continue;
      (d - c || h.endSide - h.startSide) < 0 || (a < 0 && (a = c), h.point && (s = Math.max(s, d - c)), e.push(h), i.push(c - a), r.push(d - a));
    }
    return { mapped: e.length ? new T(i, r, e, s) : null, pos: a };
  }
}
class Q {
  constructor(O, t, e, i) {
    this.chunkPos = O, this.chunk = t, this.nextLayer = e, this.maxPoint = i;
  }
  /**
  @internal
  */
  static create(O, t, e, i) {
    return new Q(O, t, e, i);
  }
  /**
  @internal
  */
  get length() {
    let O = this.chunk.length - 1;
    return O < 0 ? 0 : Math.max(this.chunkEnd(O), this.nextLayer.length);
  }
  /**
  The number of ranges in the set.
  */
  get size() {
    if (this.isEmpty)
      return 0;
    let O = this.nextLayer.size;
    for (let t of this.chunk)
      O += t.value.length;
    return O;
  }
  /**
  @internal
  */
  chunkEnd(O) {
    return this.chunkPos[O] + this.chunk[O].length;
  }
  /**
  Update the range set, optionally adding new ranges or filtering
  out existing ones.
  
  (Note: The type parameter is just there as a kludge to work
  around TypeScript variance issues that prevented `RangeSet<X>`
  from being a subtype of `RangeSet<Y>` when `X` is a subtype of
  `Y`.)
  */
  update(O) {
    let { add: t = [], sort: e = !1, filterFrom: i = 0, filterTo: r = this.length } = O, a = O.filter;
    if (t.length == 0 && !a)
      return this;
    if (e && (t = t.slice().sort(R)), this.isEmpty)
      return t.length ? Q.of(t) : this;
    let s = new W(this, null, -1).goto(0), o = 0, h = [], l = new x();
    for (; s.value || o < t.length; )
      if (o < t.length && (s.from - t[o].from || s.startSide - t[o].value.startSide) >= 0) {
        let P = t[o++];
        l.addInner(P.from, P.to, P.value) || h.push(P);
      } else s.rangeIndex == 1 && s.chunkIndex < this.chunk.length && (o == t.length || this.chunkEnd(s.chunkIndex) < t[o].from) && (!a || i > this.chunkEnd(s.chunkIndex) || r < this.chunkPos[s.chunkIndex]) && l.addChunk(this.chunkPos[s.chunkIndex], this.chunk[s.chunkIndex]) ? s.nextChunk() : ((!a || i > s.to || r < s.from || a(s.from, s.to, s.value)) && (l.addInner(s.from, s.to, s.value) || h.push($.create(s.from, s.to, s.value))), s.next());
    return l.finishInner(this.nextLayer.isEmpty && !h.length ? Q.empty : this.nextLayer.update({ add: h, filter: a, filterFrom: i, filterTo: r }));
  }
  /**
  Map this range set through a set of changes, return the new set.
  */
  map(O) {
    if (O.empty || this.isEmpty)
      return this;
    let t = [], e = [], i = -1;
    for (let a = 0; a < this.chunk.length; a++) {
      let s = this.chunkPos[a], o = this.chunk[a], h = O.touchesRange(s, s + o.length);
      if (h === !1)
        i = Math.max(i, o.maxPoint), t.push(o), e.push(O.mapPos(s));
      else if (h === !0) {
        let { mapped: l, pos: P } = o.map(s, O);
        l && (i = Math.max(i, l.maxPoint), t.push(l), e.push(P));
      }
    }
    let r = this.nextLayer.map(O);
    return t.length == 0 ? r : new Q(e, t, r || Q.empty, i);
  }
  /**
  Iterate over the ranges that touch the region `from` to `to`,
  calling `f` for each. There is no guarantee that the ranges will
  be reported in any specific order. When the callback returns
  `false`, iteration stops.
  */
  between(O, t, e) {
    if (!this.isEmpty) {
      for (let i = 0; i < this.chunk.length; i++) {
        let r = this.chunkPos[i], a = this.chunk[i];
        if (t >= r && O <= r + a.length && a.between(r, O - r, t - r, e) === !1)
          return;
      }
      this.nextLayer.between(O, t, e);
    }
  }
  /**
  Iterate over the ranges in this set, in order, including all
  ranges that end at or after `from`.
  */
  iter(O = 0) {
    return m.from([this]).goto(O);
  }
  /**
  @internal
  */
  get isEmpty() {
    return this.nextLayer == this;
  }
  /**
  Iterate over the ranges in a collection of sets, in order,
  starting from `from`.
  */
  static iter(O, t = 0) {
    return m.from(O).goto(t);
  }
  /**
  Iterate over two groups of sets, calling methods on `comparator`
  to notify it of possible differences.
  */
  static compare(O, t, e, i, r = -1) {
    let a = O.filter((P) => P.maxPoint > 0 || !P.isEmpty && P.maxPoint >= r), s = t.filter((P) => P.maxPoint > 0 || !P.isEmpty && P.maxPoint >= r), o = X(a, s, e), h = new S(a, o, r), l = new S(s, o, r);
    e.iterGaps((P, c, d) => U(h, P, l, c, d, i)), e.empty && e.length == 0 && U(h, 0, l, 0, 0, i);
  }
  /**
  Compare the contents of two groups of range sets, returning true
  if they are equivalent in the given range.
  */
  static eq(O, t, e = 0, i) {
    i == null && (i = 999999999);
    let r = O.filter((l) => !l.isEmpty && t.indexOf(l) < 0), a = t.filter((l) => !l.isEmpty && O.indexOf(l) < 0);
    if (r.length != a.length)
      return !1;
    if (!r.length)
      return !0;
    let s = X(r, a), o = new S(r, s, 0).goto(e), h = new S(a, s, 0).goto(e);
    for (; ; ) {
      if (o.to != h.to || !y(o.active, h.active) || o.point && (!h.point || !o.point.eq(h.point)))
        return !1;
      if (o.to > i)
        return !0;
      o.next(), h.next();
    }
  }
  /**
  Iterate over a group of range sets at the same time, notifying
  the iterator about the ranges covering every given piece of
  content. Returns the open count (see
  [`SpanIterator.span`](https://codemirror.net/6/docs/ref/#state.SpanIterator.span)) at the end
  of the iteration.
  */
  static spans(O, t, e, i, r = -1) {
    let a = new S(O, null, r).goto(t), s = t, o = a.openStart;
    for (; ; ) {
      let h = Math.min(a.to, e);
      if (a.point) {
        let l = a.activeForPoint(a.to), P = a.pointFrom < t ? l.length + 1 : a.point.startSide < 0 ? l.length : Math.min(l.length, o);
        i.point(s, h, a.point, l, P, a.pointRank), o = Math.min(a.openEnd(h), l.length);
      } else h > s && (i.span(s, h, a.active, o), o = a.openEnd(h));
      if (a.to > e)
        return o + (a.point && a.to > e ? 1 : 0);
      s = a.to, a.next();
    }
  }
  /**
  Create a range set for the given range or array of ranges. By
  default, this expects the ranges to be _sorted_ (by start
  position and, if two start at the same position,
  `value.startSide`). You can pass `true` as second argument to
  cause the method to sort them.
  */
  static of(O, t = !1) {
    let e = new x();
    for (let i of O instanceof $ ? [O] : t ? OO(O) : O)
      e.add(i.from, i.to, i.value);
    return e.finish();
  }
  /**
  Join an array of range sets into a single set.
  */
  static join(O) {
    if (!O.length)
      return Q.empty;
    let t = O[O.length - 1];
    for (let e = O.length - 2; e >= 0; e--)
      for (let i = O[e]; i != Q.empty; i = i.nextLayer)
        t = new Q(i.chunkPos, i.chunk, t, Math.max(i.maxPoint, t.maxPoint));
    return t;
  }
}
Q.empty = /* @__PURE__ */ new Q([], [], null, -1);
function OO(n) {
  if (n.length > 1)
    for (let O = n[0], t = 1; t < n.length; t++) {
      let e = n[t];
      if (R(O, e) > 0)
        return n.slice().sort(R);
      O = e;
    }
  return n;
}
Q.empty.nextLayer = Q.empty;
class x {
  finishChunk(O) {
    this.chunks.push(new T(this.from, this.to, this.value, this.maxPoint)), this.chunkPos.push(this.chunkStart), this.chunkStart = -1, this.setMaxPoint = Math.max(this.setMaxPoint, this.maxPoint), this.maxPoint = -1, O && (this.from = [], this.to = [], this.value = []);
  }
  /**
  Create an empty builder.
  */
  constructor() {
    this.chunks = [], this.chunkPos = [], this.chunkStart = -1, this.last = null, this.lastFrom = -1e9, this.lastTo = -1e9, this.from = [], this.to = [], this.value = [], this.maxPoint = -1, this.setMaxPoint = -1, this.nextLayer = null;
  }
  /**
  Add a range. Ranges should be added in sorted (by `from` and
  `value.startSide`) order.
  */
  add(O, t, e) {
    this.addInner(O, t, e) || (this.nextLayer || (this.nextLayer = new x())).add(O, t, e);
  }
  /**
  @internal
  */
  addInner(O, t, e) {
    let i = O - this.lastTo || e.startSide - this.last.endSide;
    if (i <= 0 && (O - this.lastFrom || e.startSide - this.last.startSide) < 0)
      throw new Error("Ranges must be added sorted by `from` position and `startSide`");
    return i < 0 ? !1 : (this.from.length == 250 && this.finishChunk(!0), this.chunkStart < 0 && (this.chunkStart = O), this.from.push(O - this.chunkStart), this.to.push(t - this.chunkStart), this.last = e, this.lastFrom = O, this.lastTo = t, this.value.push(e), e.point && (this.maxPoint = Math.max(this.maxPoint, t - O)), !0);
  }
  /**
  @internal
  */
  addChunk(O, t) {
    if ((O - this.lastTo || t.value[0].startSide - this.last.endSide) < 0)
      return !1;
    this.from.length && this.finishChunk(!0), this.setMaxPoint = Math.max(this.setMaxPoint, t.maxPoint), this.chunks.push(t), this.chunkPos.push(O);
    let e = t.value.length - 1;
    return this.last = t.value[e], this.lastFrom = t.from[e] + O, this.lastTo = t.to[e] + O, !0;
  }
  /**
  Finish the range set. Returns the new set. The builder can't be
  used anymore after this has been called.
  */
  finish() {
    return this.finishInner(Q.empty);
  }
  /**
  @internal
  */
  finishInner(O) {
    if (this.from.length && this.finishChunk(!1), this.chunks.length == 0)
      return O;
    let t = Q.create(this.chunkPos, this.chunks, this.nextLayer ? this.nextLayer.finishInner(O) : O, this.setMaxPoint);
    return this.from = null, t;
  }
}
function X(n, O, t) {
  let e = /* @__PURE__ */ new Map();
  for (let r of n)
    for (let a = 0; a < r.chunk.length; a++)
      r.chunk[a].maxPoint <= 0 && e.set(r.chunk[a], r.chunkPos[a]);
  let i = /* @__PURE__ */ new Set();
  for (let r of O)
    for (let a = 0; a < r.chunk.length; a++) {
      let s = e.get(r.chunk[a]);
      s != null && (t ? t.mapPos(s) : s) == r.chunkPos[a] && !(t != null && t.touchesRange(s, s + r.chunk[a].length)) && i.add(r.chunk[a]);
    }
  return i;
}
class W {
  constructor(O, t, e, i = 0) {
    this.layer = O, this.skip = t, this.minPoint = e, this.rank = i;
  }
  get startSide() {
    return this.value ? this.value.startSide : 0;
  }
  get endSide() {
    return this.value ? this.value.endSide : 0;
  }
  goto(O, t = -1e9) {
    return this.chunkIndex = this.rangeIndex = 0, this.gotoInner(O, t, !1), this;
  }
  gotoInner(O, t, e) {
    for (; this.chunkIndex < this.layer.chunk.length; ) {
      let i = this.layer.chunk[this.chunkIndex];
      if (!(this.skip && this.skip.has(i) || this.layer.chunkEnd(this.chunkIndex) < O || i.maxPoint < this.minPoint))
        break;
      this.chunkIndex++, e = !1;
    }
    if (this.chunkIndex < this.layer.chunk.length) {
      let i = this.layer.chunk[this.chunkIndex].findIndex(O - this.layer.chunkPos[this.chunkIndex], t, !0);
      (!e || this.rangeIndex < i) && this.setRangeIndex(i);
    }
    this.next();
  }
  forward(O, t) {
    (this.to - O || this.endSide - t) < 0 && this.gotoInner(O, t, !0);
  }
  next() {
    for (; ; )
      if (this.chunkIndex == this.layer.chunk.length) {
        this.from = this.to = 1e9, this.value = null;
        break;
      } else {
        let O = this.layer.chunkPos[this.chunkIndex], t = this.layer.chunk[this.chunkIndex], e = O + t.from[this.rangeIndex];
        if (this.from = e, this.to = O + t.to[this.rangeIndex], this.value = t.value[this.rangeIndex], this.setRangeIndex(this.rangeIndex + 1), this.minPoint < 0 || this.value.point && this.to - this.from >= this.minPoint)
          break;
      }
  }
  setRangeIndex(O) {
    if (O == this.layer.chunk[this.chunkIndex].value.length) {
      if (this.chunkIndex++, this.skip)
        for (; this.chunkIndex < this.layer.chunk.length && this.skip.has(this.layer.chunk[this.chunkIndex]); )
          this.chunkIndex++;
      this.rangeIndex = 0;
    } else
      this.rangeIndex = O;
  }
  nextChunk() {
    this.chunkIndex++, this.rangeIndex = 0, this.next();
  }
  compare(O) {
    return this.from - O.from || this.startSide - O.startSide || this.rank - O.rank || this.to - O.to || this.endSide - O.endSide;
  }
}
class m {
  constructor(O) {
    this.heap = O;
  }
  static from(O, t = null, e = -1) {
    let i = [];
    for (let r = 0; r < O.length; r++)
      for (let a = O[r]; !a.isEmpty; a = a.nextLayer)
        a.maxPoint >= e && i.push(new W(a, t, e, r));
    return i.length == 1 ? i[0] : new m(i);
  }
  get startSide() {
    return this.value ? this.value.startSide : 0;
  }
  goto(O, t = -1e9) {
    for (let e of this.heap)
      e.goto(O, t);
    for (let e = this.heap.length >> 1; e >= 0; e--)
      w(this.heap, e);
    return this.next(), this;
  }
  forward(O, t) {
    for (let e of this.heap)
      e.forward(O, t);
    for (let e = this.heap.length >> 1; e >= 0; e--)
      w(this.heap, e);
    (this.to - O || this.value.endSide - t) < 0 && this.next();
  }
  next() {
    if (this.heap.length == 0)
      this.from = this.to = 1e9, this.value = null, this.rank = -1;
    else {
      let O = this.heap[0];
      this.from = O.from, this.to = O.to, this.value = O.value, this.rank = O.rank, O.value && O.next(), w(this.heap, 0);
    }
  }
}
function w(n, O) {
  for (let t = n[O]; ; ) {
    let e = (O << 1) + 1;
    if (e >= n.length)
      break;
    let i = n[e];
    if (e + 1 < n.length && i.compare(n[e + 1]) >= 0 && (i = n[e + 1], e++), t.compare(i) < 0)
      break;
    n[e] = t, n[O] = i, O = e;
  }
}
class S {
  constructor(O, t, e) {
    this.minPoint = e, this.active = [], this.activeTo = [], this.activeRank = [], this.minActive = -1, this.point = null, this.pointFrom = 0, this.pointRank = 0, this.to = -1e9, this.endSide = 0, this.openStart = -1, this.cursor = m.from(O, t, e);
  }
  goto(O, t = -1e9) {
    return this.cursor.goto(O, t), this.active.length = this.activeTo.length = this.activeRank.length = 0, this.minActive = -1, this.to = O, this.endSide = t, this.openStart = -1, this.next(), this;
  }
  forward(O, t) {
    for (; this.minActive > -1 && (this.activeTo[this.minActive] - O || this.active[this.minActive].endSide - t) < 0; )
      this.removeActive(this.minActive);
    this.cursor.forward(O, t);
  }
  removeActive(O) {
    g(this.active, O), g(this.activeTo, O), g(this.activeRank, O), this.minActive = z(this.active, this.activeTo);
  }
  addActive(O) {
    let t = 0, { value: e, to: i, rank: r } = this.cursor;
    for (; t < this.activeRank.length && (r - this.activeRank[t] || i - this.activeTo[t]) > 0; )
      t++;
    v(this.active, t, e), v(this.activeTo, t, i), v(this.activeRank, t, r), O && v(O, t, this.cursor.from), this.minActive = z(this.active, this.activeTo);
  }
  // After calling this, if `this.point` != null, the next range is a
  // point. Otherwise, it's a regular range, covered by `this.active`.
  next() {
    let O = this.to, t = this.point;
    this.point = null;
    let e = this.openStart < 0 ? [] : null;
    for (; ; ) {
      let i = this.minActive;
      if (i > -1 && (this.activeTo[i] - this.cursor.from || this.active[i].endSide - this.cursor.startSide) < 0) {
        if (this.activeTo[i] > O) {
          this.to = this.activeTo[i], this.endSide = this.active[i].endSide;
          break;
        }
        this.removeActive(i), e && g(e, i);
      } else if (this.cursor.value)
        if (this.cursor.from > O) {
          this.to = this.cursor.from, this.endSide = this.cursor.startSide;
          break;
        } else {
          let r = this.cursor.value;
          if (!r.point)
            this.addActive(e), this.cursor.next();
          else if (t && this.cursor.to == this.to && this.cursor.from < this.cursor.to)
            this.cursor.next();
          else {
            this.point = r, this.pointFrom = this.cursor.from, this.pointRank = this.cursor.rank, this.to = this.cursor.to, this.endSide = r.endSide, this.cursor.next(), this.forward(this.to, this.endSide);
            break;
          }
        }
      else {
        this.to = this.endSide = 1e9;
        break;
      }
    }
    if (e) {
      this.openStart = 0;
      for (let i = e.length - 1; i >= 0 && e[i] < O; i--)
        this.openStart++;
    }
  }
  activeForPoint(O) {
    if (!this.active.length)
      return this.active;
    let t = [];
    for (let e = this.active.length - 1; e >= 0 && !(this.activeRank[e] < this.pointRank); e--)
      (this.activeTo[e] > O || this.activeTo[e] == O && this.active[e].endSide >= this.point.endSide) && t.push(this.active[e]);
    return t.reverse();
  }
  openEnd(O) {
    let t = 0;
    for (let e = this.activeTo.length - 1; e >= 0 && this.activeTo[e] > O; e--)
      t++;
    return t;
  }
}
function U(n, O, t, e, i, r) {
  n.goto(O), t.goto(e);
  let a = e + i, s = e, o = e - O;
  for (; ; ) {
    let h = n.to + o - t.to, l = h || n.endSide - t.endSide, P = l < 0 ? n.to + o : t.to, c = Math.min(P, a);
    if (n.point || t.point ? n.point && t.point && (n.point == t.point || n.point.eq(t.point)) && y(n.activeForPoint(n.to), t.activeForPoint(t.to)) || r.comparePoint(s, c, n.point, t.point) : c > s && !y(n.active, t.active) && r.compareRange(s, c, n.active, t.active), P > a)
      break;
    (h || n.openEnd != t.openEnd) && r.boundChange && r.boundChange(P), s = P, l <= 0 && n.next(), l >= 0 && t.next();
  }
}
function y(n, O) {
  if (n.length != O.length)
    return !1;
  for (let t = 0; t < n.length; t++)
    if (n[t] != O[t] && !n[t].eq(O[t]))
      return !1;
  return !0;
}
function g(n, O) {
  for (let t = O, e = n.length - 1; t < e; t++)
    n[t] = n[t + 1];
  n.pop();
}
function v(n, O, t) {
  for (let e = n.length - 1; e >= O; e--)
    n[e + 1] = n[e];
  n[O] = t;
}
function z(n, O) {
  let t = -1, e = 1e9;
  for (let i = 0; i < O.length; i++)
    (O[i] - e || n[i].endSide - n[t].endSide) < 0 && (t = i, e = O[i]);
  return t;
}
const tO = 1, eO = 2, iO = 3, nO = 155, rO = 4, aO = 156;
function sO(n) {
  return n >= 65 && n <= 90 || n >= 97 && n <= 122;
}
const oO = /* @__PURE__ */ new q((n) => {
  let O = n.pos;
  for (; ; ) {
    let { next: t } = n;
    if (t < 0)
      break;
    if (t == 123) {
      let e = n.peek(1);
      if (e == 123) {
        if (n.pos > O)
          break;
        n.acceptToken(tO, 2);
        return;
      } else if (e == 35) {
        if (n.pos > O)
          break;
        n.acceptToken(eO, 2);
        return;
      } else if (e == 37) {
        if (n.pos > O)
          break;
        let i = 2, r = 2;
        for (; ; ) {
          let a = n.peek(i);
          if (a == 32 || a == 10)
            ++i;
          else if (a == 35)
            for (++i; ; ) {
              let s = n.peek(i);
              if (s < 0 || s == 10)
                break;
              i++;
            }
          else if (a == 45 && r == 2)
            r = ++i;
          else {
            n.acceptToken(iO, r);
            return;
          }
        }
      }
    }
    if (n.advance(), t == 10)
      break;
  }
  n.pos > O && n.acceptToken(nO);
});
function hO(n, O, t) {
  return new q((e) => {
    let i = e.pos;
    for (; ; ) {
      let { next: r } = e;
      if (r == 123 && e.peek(1) == 37) {
        let a = 2;
        for (; ; a++) {
          let o = e.peek(a);
          if (o != 32 && o != 10)
            break;
        }
        let s = "";
        for (; ; a++) {
          let o = e.peek(a);
          if (!sO(o))
            break;
          s += String.fromCharCode(o);
        }
        if (s == n) {
          if (e.pos > i)
            break;
          e.acceptToken(t, 2);
          break;
        }
      } else if (r < 0)
        break;
      if (e.advance(), r == 10)
        break;
    }
    e.pos > i && e.acceptToken(O);
  });
}
const lO = /* @__PURE__ */ hO("endraw", aO, rO), uO = { __proto__: null, in: 38, is: 40, and: 46, or: 48, not: 52, if: 78, else: 80, true: 98, false: 98, self: 100, super: 102, loop: 104, recursive: 136, scoped: 160, required: 162, as: 256, import: 260, ignore: 268, missing: 270, with: 272, without: 274, context: 276 }, PO = { __proto__: null, if: 112, elif: 118, else: 122, endif: 126, for: 132, endfor: 140, raw: 146, endraw: 152, block: 158, endblock: 166, macro: 172, endmacro: 182, call: 188, endcall: 192, filter: 198, endfilter: 202, set: 208, endset: 212, trans: 218, pluralize: 222, endtrans: 226, with: 232, endwith: 236, autoescape: 242, endautoescape: 246, import: 254, from: 258, include: 266 }, fO = /* @__PURE__ */ B.deserialize({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aR$m!u!bcOTVWXYZ[]^dqtu{!O!R!U!X![!]!`!c#b#c#i#k#{#}%[%a%kTnSoQgRQ#WhQ#YiQ#[jQ#_lQ$U!eQ$W!fQ$i!pQ$j!qQ$k!rQ$l!sQ$p!xS$q!y)gQ$r!zQ$s!{Q$t!|Q$u!}Q$z#RQ${#SQ$|#TQ$}#UQ%O#VQ%]#eQ%l$OQ&h%PQ&k%UQ&l%VQ&y%tQ'U&UQ'V&VQ'X&XQ'a&bQ'e&dQ'f&gQ'g(yQ'i&xQ'm&}Q'r'TQ'w'WS(R(z)zQ(S({Q(T(|Q(U(}Q(W)PQ(X)QQ(Y)RQ(Z)SQ([)TQ(]'hQ(m(QQ(o(`Q(t)WQ(u(pQ(w(rQ(x(vQ)U)ZQ)V)[Q)X)bQ)Y)cQ)])fQ)^)lQ)_)mQ)`)nQ)a)sQ)d*TQ)e*UQ)o)hQ)p)iQ)q)jQ)r)kQ)t)yQ)u*PQ)v*QQ)w*RQ)x*SQ*V){Q*W)|Q*X)}R*Y*OQ$c!lT$y#O)OR$x!}R#XhR#^jR%|$^R$h!o",
  nodeNames: "⚠ {{ {# {% {% Template Text }} Interpolation VariableName MemberExpression . PropertyName SubscriptExpression BinaryExpression ConcatOp ArithOp ArithOp CompareOp in is StringLiteral NumberLiteral and or NotExpression not FilterExpression FilterOp FilterName FilterCall ) ( ArgumentList NamedArgument AssignOp , NamedArgument ConditionalExpression if else CallExpression ArrayExpression TupleExpression ParenthesizedExpression DictExpression Entry : Entry BooleanLiteral self super loop IfStatement Tag TagName if %} Tag elif Tag else EndTag endif ForStatement Tag for Definition recursive EndTag endfor RawStatement Tag raw RawText EndTag endraw BlockStatement Tag block scoped required EndTag endblock MacroStatement Tag macro ParamList OptionalParameter OptionalParameter EndTag endmacro CallStatement Tag call EndTag endcall FilterStatement Tag filter EndTag endfilter SetStatement Tag set EndTag endset TransStatement Tag trans Tag pluralize EndTag endtrans WithStatement Tag with EndTag endwith AutoescapeStatement Tag autoescape EndTag endautoescape Tag Tag Tag import as from import ImportItem Tag include ignore missing with without context Comment #}",
  maxTerm: 173,
  nodeProps: [
    ["closedBy", 1, "}}", 2, "#}", -2, 3, 4, "%}", 32, ")"],
    ["openedBy", 7, "{{", 31, "(", 57, "{%", 140, "{#"],
    ["group", -18, 9, 10, 13, 14, 21, 22, 25, 27, 38, 41, 42, 43, 44, 45, 49, 50, 51, 52, "Expression", -11, 53, 64, 71, 77, 84, 92, 97, 102, 107, 114, 119, "Statement"]
  ],
  skippedNodes: [0],
  repeatNodeCount: 13,
  tokenData: ".|~RqXY#YYZ#Y]^#Ypq#Yqr#krs#vuv&nwx&{xy)nyz)sz{)x{|*V|}+|}!O,R!O!P,g!P!Q,o!Q![+h![!],w!^!_,|!_!`-U!`!a,|!c!}-^!}#O.U#P#Q.Z#R#S-^#T#o-^#o#p.`#p#q.e#q#r.j#r#s.w%W;'S-^;'S;:j.O<%lO-^~#_S$d~XY#YYZ#Y]^#Ypq#Y~#nP!_!`#q~#vOb~~#yWOY#vZr#vrs$cs#O#v#O#P$h#P;'S#v;'S;=`%x<%lO#v~$hOe~~$kYOY#vYZ#vZr#vrs%Zs#O#v#O#P$h#P;'S#v;'S;=`&O;=`<%l#v<%lO#v~%`We~OY#vZr#vrs$cs#O#v#O#P$h#P;'S#v;'S;=`%x<%lO#v~%{P;=`<%l#v~&RXOY#vZr#vrs$cs#O#v#O#P$h#P;'S#v;'S;=`%x;=`<%l#v<%lO#v~&sP`~#q#r&v~&{O!Z~~'OWOY&{Zw&{wx$cx#O&{#O#P'h#P;'S&{;'S;=`(x<%lO&{~'kYOY&{YZ&{Zw&{wx(Zx#O&{#O#P'h#P;'S&{;'S;=`)O;=`<%l&{<%lO&{~(`We~OY&{Zw&{wx$cx#O&{#O#P'h#P;'S&{;'S;=`(x<%lO&{~({P;=`<%l&{~)RXOY&{Zw&{wx$cx#O&{#O#P'h#P;'S&{;'S;=`(x;=`<%l&{<%lO&{~)sOp~~)xOo~~)}P`~z{*Q~*VO`~~*[Qa~!O!P*b!Q![+h~*eP!Q![*h~*mSf~!Q![*h!g!h*y#R#S*h#X#Y*y~*|R{|+V}!O+V!Q![+]~+YP!Q![+]~+bQf~!Q![+]#R#S+]~+mTf~!O!P*b!Q![+h!g!h*y#R#S+h#X#Y*y~,ROt~~,WRa~uv,a!O!P*b!Q![+h~,dP#q#r&v~,lPZ~!Q![*h~,tP`~!P!Q*Q~,|O!P~~-RPb~!_!`#q~-ZPs~!_!`#q!`-iVm`[p!XS$gY!Q![-^!c!}-^#R#S-^#T#o-^%W;'S-^;'S;:j.O<%lO-^!`.RP;=`<%l-^~.ZO$i~~.`O$h~~.eO$n~~.jOl~^.oP$m[#q#r.rQ.wOVQ~.|O_~",
  tokenizers: [oO, lO, 1, 2, 3, 4, 5, /* @__PURE__ */ new H("b~RPstU~XP#q#r[~aO$Q~~", 17, 173)],
  topRules: { Template: [0, 5] },
  specialized: [{ term: 161, get: (n) => uO[n] || -1 }, { term: 55, get: (n) => PO[n] || -1 }],
  tokenPrec: 3602
});
function k(n, O) {
  return n.split(" ").map((t) => ({ label: t, type: O }));
}
const cO = /* @__PURE__ */ k("abs attr batch capitalize center default dictsort escape filesizeformat first float forceescape format groupby indent int items join last length list lower map max min pprint random reject rejectattr replace reverse round safe select selectattr slice sort string striptags sum title tojson trim truncate unique upper urlencode urlize wordcount wordwrap xmlattr", "function"), QO = /* @__PURE__ */ k("boolean callable defined divisibleby eq escaped even filter float ge gt in integer iterable le lower lt mapping ne none number odd sameas sequence string test undefined upper range lipsum dict joiner namespace", "function"), dO = /* @__PURE__ */ k("loop super self true false varargs kwargs caller name arguments catch_kwargs catch_varargs caller", "keyword"), E = /* @__PURE__ */ QO.concat(dO), j = /* @__PURE__ */ k("raw endraw filter endfilter trans pluralize endtrans with endwith autoescape endautoescape if elif else endif for endfor call endcall block endblock set endset macro endmacro import include break continue debug do extends", "keyword");
function pO(n) {
  var O;
  let { state: t, pos: e } = n, i = C(t).resolveInner(e, -1).enterUnfinishedNodesBefore(e), r = ((O = i.childBefore(e)) === null || O === void 0 ? void 0 : O.name) || i.name;
  if (i.name == "FilterName")
    return { type: "filter", node: i };
  if (n.explicit && (r == "FilterOp" || r == "filter"))
    return { type: "filter" };
  if (i.name == "TagName")
    return { type: "tag", node: i };
  if (n.explicit && r == "{%")
    return { type: "tag" };
  if (i.name == "PropertyName" && i.parent.name == "MemberExpression")
    return { type: "prop", node: i, target: i.parent };
  if (i.name == "." && i.parent.name == "MemberExpression")
    return { type: "prop", target: i.parent };
  if (i.name == "MemberExpression" && r == ".")
    return { type: "prop", target: i };
  if (i.name == "VariableName")
    return { type: "expr", from: i.from };
  if (i.name == "Comment" || i.name == "StringLiteral" || i.name == "NumberLiteral")
    return null;
  let a = n.matchBefore(/[\w\u00c0-\uffff]+$/);
  return a ? { type: "expr", from: a.from } : n.explicit ? { type: "expr" } : null;
}
function SO(n, O, t, e) {
  let i = [];
  for (; ; ) {
    let r = O.getChild("Expression");
    if (!r)
      return [];
    if (r.name == "VariableName") {
      i.unshift(n.sliceDoc(r.from, r.to));
      break;
    } else if (r.name == "MemberExpression") {
      let a = r.getChild("PropertyName");
      a && i.unshift(n.sliceDoc(a.from, a.to)), O = r;
    } else
      return [];
  }
  return e(i, n, t);
}
function mO(n = {}) {
  let O = n.tags ? n.tags.concat(j) : j, t = n.variables ? n.variables.concat(E) : E, { properties: e } = n;
  return (i) => {
    var r;
    let a = pO(i);
    if (!a)
      return null;
    let s = (r = a.from) !== null && r !== void 0 ? r : a.node ? a.node.from : i.pos, o;
    return a.type == "filter" ? o = cO : a.type == "tag" ? o = O : a.type == "expr" ? o = t : o = e ? SO(i.state, a.target, i, e) : [], o.length ? { options: o, from: s, validFor: /^[\w\u00c0-\uffff]*$/ } : null;
  };
}
const gO = /* @__PURE__ */ V.inputHandler.of((n, O, t, e) => e != "%" || O != t || n.state.doc.sliceString(O - 1, t + 1) != "{}" ? !1 : (n.dispatch(n.state.changeByRange((i) => ({
  changes: { from: i.from, to: i.to, insert: "%%" },
  range: f.cursor(i.from + 1)
})), {
  scrollIntoView: !0,
  userEvent: "input.type"
}), !0));
function Y(n) {
  return (O) => {
    let t = n.test(O.textAfter);
    return O.lineIndent(O.node.from) + (t ? 0 : O.unit);
  };
}
const vO = /* @__PURE__ */ A.define({
  name: "jinja",
  parser: /* @__PURE__ */ fO.configure({
    props: [
      /* @__PURE__ */ L({
        "TagName raw endraw filter endfilter as trans pluralize endtrans with endwith autoescape endautoescape": u.keyword,
        "required scoped recursive with without context ignore missing": u.modifier,
        self: u.self,
        "loop super": /* @__PURE__ */ u.standard(u.variableName),
        "if elif else endif for endfor call endcall": u.controlKeyword,
        "block endblock set endset macro endmacro import from include": u.definitionKeyword,
        "Comment/...": u.blockComment,
        VariableName: u.variableName,
        Definition: /* @__PURE__ */ u.definition(u.variableName),
        PropertyName: u.propertyName,
        FilterName: /* @__PURE__ */ u.special(u.variableName),
        ArithOp: u.arithmeticOperator,
        AssignOp: u.definitionOperator,
        "not and or": u.logicOperator,
        CompareOp: u.compareOperator,
        "in is": u.operatorKeyword,
        "FilterOp ConcatOp": u.operator,
        StringLiteral: u.string,
        NumberLiteral: u.number,
        BooleanLiteral: u.bool,
        "{% %} {# #} {{ }} { }": u.brace,
        "( )": u.paren,
        ".": u.derefOperator,
        ": , .": u.punctuation
      }),
      /* @__PURE__ */ D.add({
        Tag: /* @__PURE__ */ J({ closing: "%}" }),
        "IfStatement ForStatement": /* @__PURE__ */ Y(/^\s*(\{%-?\s*)?(endif|endfor|else|elif)\b/),
        Statement: /* @__PURE__ */ Y(/^\s*(\{%-?\s*)?end\w/)
      }),
      /* @__PURE__ */ M.add({
        "Statement Comment"(n) {
          let O = n.firstChild, t = n.lastChild;
          return !O || O.name != "Tag" && O.name != "{#" ? null : { from: O.to, to: t.name == "EndTag" || t.name == "#}" ? t.from : n.to };
        }
      })
    ]
  }),
  languageData: {
    indentOnInput: /^\s*{%-?\s*(?:end|elif|else)$/
  }
}), G = /* @__PURE__ */ N();
function I(n) {
  return vO.configure({
    wrap: _((O) => O.type.isTop ? {
      parser: n.parser,
      overlay: (t) => t.name == "Text" || t.name == "RawText"
    } : null)
  }, "jinja");
}
const $O = /* @__PURE__ */ I(G.language);
function kO(n = {}) {
  let O = n.base || G, t = O.language == G.language ? $O : I(O.language);
  return new F(t, [
    O.support,
    t.data.of({ autocomplete: mO(n) }),
    O.language.data.of({ closeBrackets: { brackets: ["{"] } }),
    gO
  ]);
}
export {
  gO as closePercentBrace,
  kO as jinja,
  mO as jinjaCompletionSource,
  $O as jinjaLanguage
};
